fix(observer): v30 Running command 추출 — includes 매칭 + raw fallback + 디버그 로그 (v0.5.94)

This commit is contained in:
Variet Worker
2026-04-19 15:03:09 +09:00
parent a99a1e3f54
commit cbfd137dcb
3 changed files with 23 additions and 8 deletions

View File

@@ -1,12 +1,12 @@
{ {
"name": "gravity-bridge", "name": "gravity-bridge",
"version": "0.5.93", "version": "0.5.94",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "gravity-bridge", "name": "gravity-bridge",
"version": "0.5.93", "version": "0.5.94",
"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.93", "version": "0.5.94",
"publisher": "variet", "publisher": "variet",
"engines": { "engines": {
"vscode": "^1.100.0" "vscode": "^1.100.0"

View File

@@ -192,20 +192,35 @@ export function generateApprovalObserverScript(_port: number): string {
// v30: Command text is in plain divs near "Running command" header, not pre/code // v30: Command text is in plain divs near "Running command" header, not pre/code
var rcDivs = node.querySelectorAll('div'); var rcDivs = node.querySelectorAll('div');
for (var rci = 0; rci < rcDivs.length; rci++) { for (var rci = 0; rci < rcDivs.length; rci++) {
var rcTxt = (rcDivs[rci].textContent || '').trim(); var rcEl = rcDivs[rci];
if (rcTxt === 'Running command' && rcDivs[rci].parentElement) { var rcChildCount = rcEl.children ? rcEl.children.length : 0;
var rcP = rcDivs[rci].parentElement; 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) {
var rcP = rcEl.parentElement;
log('CONTEXT-v30 found RC header at d'+depth+' siblings='+rcP.children.length);
for (var rcsi = 0; rcsi < rcP.children.length; rcsi++) { for (var rcsi = 0; rcsi < rcP.children.length; rcsi++) {
if (rcP.children[rcsi] === rcDivs[rci]) 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;
// Skip button-bar text
if (/^(Always|Run|Allow|Cancel|Deny|keyboard_arrow)/i.test(sibT)) continue;
if (sibT.indexOf('Always run') !== -1 && sibT.indexOf('Cancel') !== -1) continue;
// Try prompt marker extraction
var pM = sibT.match(/[\\u003e\\u00bb\\u276f]\\s+(.+)/); var pM = sibT.match(/[\\u003e\\u00bb\\u276f]\\s+(.+)/);
if (pM && pM[1].trim().length > 3) { if (pM && pM[1].trim().length > 3) {
var cmdV = pM[1].trim().substring(0, 300); var cmdV = pM[1].trim().substring(0, 300);
if (/^(Always|Run|Allow|Cancel|Deny)/i.test(cmdV)) continue; if (/^(Always|Run|Allow|Cancel|Deny)/i.test(cmdV)) continue;
log('CONTEXT-OK d='+depth+' src=running-cmd trail='+_debugTrail.join(' ')); log('CONTEXT-OK d='+depth+' src=running-cmd cmdV='+cmdV.substring(0,60));
_lastContextDebug = _debugTrail.join(' '); _lastContextDebug = _debugTrail.join(' ');
return 'Running command: ' + cmdV; return 'Running command: ' + cmdV;
} }
// Fallback: use raw sibling text if it looks like a terminal line
if (sibT.length > 10 && /[\\u276f\\u003e]/.test(sibT)) {
log('CONTEXT-OK d='+depth+' src=running-cmd-raw sibT='+sibT.substring(0,60));
_lastContextDebug = _debugTrail.join(' ');
return sibT.substring(0, 300);
}
} }
} }
} }