fix(observer): v31 — content_copy 아이콘 필터 + 후보 길이순 정렬 + trailing icon strip (v0.5.96)

This commit is contained in:
Variet Worker
2026-04-19 15:18:11 +09:00
parent 4f2be831a1
commit 8ada5f7daf
3 changed files with 21 additions and 15 deletions

View File

@@ -1,12 +1,12 @@
{ {
"name": "gravity-bridge", "name": "gravity-bridge",
"version": "0.5.95", "version": "0.5.96",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "gravity-bridge", "name": "gravity-bridge",
"version": "0.5.95", "version": "0.5.96",
"dependencies": { "dependencies": {
"cheerio": "^1.2.0", "cheerio": "^1.2.0",
"ws": "^8.19.0" "ws": "^8.19.0"

View File

@@ -2,7 +2,7 @@
"name": "gravity-bridge", "name": "gravity-bridge",
"displayName": "Gravity Bridge", "displayName": "Gravity Bridge",
"description": "Discord-based unified approval system for Antigravity AI interactions.", "description": "Discord-based unified approval system for Antigravity AI interactions.",
"version": "0.5.95", "version": "0.5.96",
"publisher": "variet", "publisher": "variet",
"engines": { "engines": {
"vscode": "^1.100.0" "vscode": "^1.100.0"

View File

@@ -205,31 +205,37 @@ export function generateApprovalObserverScript(_port: number): string {
var rcEl = rcDivs[rci]; var rcEl = rcDivs[rci];
var rcChildCount = rcEl.children ? rcEl.children.length : 0; var rcChildCount = rcEl.children ? rcEl.children.length : 0;
var rcTxt = (rcEl.textContent || '').trim(); var rcTxt = (rcEl.textContent || '').trim();
// Match leaf div with exact or near-exact "Running command" text
if ((rcTxt === 'Running command' || (rcChildCount === 0 && rcTxt.indexOf('Running command') !== -1 && rcTxt.length < 30)) && rcEl.parentElement) { if ((rcTxt === 'Running command' || (rcChildCount === 0 && rcTxt.indexOf('Running command') !== -1 && rcTxt.length < 30)) && rcEl.parentElement) {
var rcP = rcEl.parentElement; var rcP = rcEl.parentElement;
log('CONTEXT-v30 found RC header at d'+depth+' siblings='+rcP.children.length); var rcCands = [];
for (var rcsi = 0; rcsi < rcP.children.length; rcsi++) { for (var rcsi = 0; rcsi < rcP.children.length; rcsi++) {
if (rcP.children[rcsi] === rcEl) continue; if (rcP.children[rcsi] === rcEl) continue;
var sibT = (rcP.children[rcsi].textContent || '').trim(); var sibT = (rcP.children[rcsi].textContent || '').trim();
if (sibT.length < 5) continue; if (sibT.length < 5) continue;
// Skip button-bar text if (/^(content_copy|content_paste|play_arrow|check_circle|chevron_|keyboard_arrow|more_horiz|more_vert|expand_|alternate_email|arrow_drop)/.test(sibT)) continue;
if (/^(Always|Run|Allow|Cancel|Deny|keyboard_arrow)/i.test(sibT)) continue; if (/^(Always|Run|Allow|Cancel|Deny|keyboard_arrow)/i.test(sibT)) continue;
if (sibT.indexOf('Always run') !== -1 && sibT.indexOf('Cancel') !== -1) continue; if (sibT.indexOf('Always run') !== -1 && sibT.indexOf('Cancel') !== -1) continue;
// Try prompt marker extraction rcCands.push(sibT);
var pM = sibT.match(/[\\u003e\\u00bb\\u276f]\\s+(.+)/);
if (pM && pM[1].trim().length > 3) {
var cmdV = pM[1].trim().substring(0, 300);
if (/^(Always|Run|Allow|Cancel|Deny)/i.test(cmdV)) continue;
log('CONTEXT-OK d='+depth+' src=running-cmd cmdV='+cmdV.substring(0,60));
_lastContextDebug = _debugTrail.join(' ');
return 'Running command: ' + cmdV;
} }
// Fallback: use raw sibling text if it looks like a terminal line rcCands.sort(function(a,b){ return b.length - a.length; });
if (sibT.length > 10 && /[\\u276f\\u003e]/.test(sibT)) { log('CONTEXT-v30 RC d='+depth+' cands='+rcCands.length+(rcCands.length>0?' best="'+rcCands[0].substring(0,60)+'"':''));
log('CONTEXT-OK d='+depth+' src=running-cmd-raw sibT='+sibT.substring(0,60)); for (var rcci = 0; rcci < rcCands.length; rcci++) {
var candT = rcCands[rcci];
var pM = candT.match(/[\\u003e\\u00bb\\u276f]\\s+(.+)/);
if (pM && pM[1].trim().length > 3) {
var cmdV = pM[1].trim();
cmdV = cmdV.replace(/\\s*(content_copy|content_paste|play_arrow|check_circle|keyboard_arrow[_a-z]*)\\s*$/, '').trim();
if (cmdV.length < 3) continue;
if (/^(Always|Run|Allow|Cancel|Deny)/i.test(cmdV)) continue;
log('CONTEXT-OK d='+depth+' src=running-cmd cmdV='+cmdV.substring(0,80));
_lastContextDebug = _debugTrail.join(' '); _lastContextDebug = _debugTrail.join(' ');
return sibT.substring(0, 300); return 'Running command: ' + cmdV.substring(0, 300);
}
if (candT.length > 10 && /[\\u276f\\u003e]/.test(candT)) {
var rawC = candT.replace(/\\s*(content_copy|content_paste|play_arrow)\\s*$/, '').trim();
log('CONTEXT-OK d='+depth+' src=running-cmd-raw rawC='+rawC.substring(0,80));
_lastContextDebug = _debugTrail.join(' ');
return rawC.substring(0, 300);
} }
} }
} }