probe: getManagerTrace + getWorkbenchTrace + LS port discovery

This commit is contained in:
2026-03-07 18:04:18 +09:00
parent 952883d3d2
commit 150967deee

View File

@@ -97,34 +97,78 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('gravityBridge.reject', () => handleManualAction(false)),
);
// Probe getDiagnostics to discover AI response data structure
// === PROBE: Find where AI conversation text lives ===
setTimeout(async () => {
console.log('Gravity Bridge: === PROBE START ===');
// Probe 1: getManagerTrace — may contain step-level data
try {
const diag: any = await vscode.commands.executeCommand('antigravity.getDiagnostics');
if (typeof diag === 'string') {
const parsed = JSON.parse(diag);
console.log(`Gravity Bridge: getDiagnostics keys: ${Object.keys(parsed).join(', ')}`);
// Sample each key to understand structure
for (const key of Object.keys(parsed)) {
const val = parsed[key];
if (Array.isArray(val)) {
console.log(` [${key}] Array(${val.length})`);
if (val.length > 0) {
const sample = val[val.length - 1]; // last item
console.log(` last: ${JSON.stringify(sample).substring(0, 300)}`);
}
} else if (typeof val === 'object') {
console.log(` [${key}] Object: ${JSON.stringify(val).substring(0, 200)}`);
} else {
console.log(` [${key}] ${typeof val}: ${String(val).substring(0, 100)}`);
}
const trace: any = await vscode.commands.executeCommand('antigravity.getManagerTrace');
console.log(`Gravity Bridge: [getManagerTrace] type=${typeof trace}`);
if (trace) {
const str = typeof trace === 'string' ? trace : JSON.stringify(trace);
console.log(` length=${str.length}`);
console.log(` sample: ${str.substring(0, 500)}`);
// If object, show keys
const parsed = typeof trace === 'string' ? JSON.parse(trace) : trace;
if (parsed && typeof parsed === 'object') {
console.log(` keys: ${Object.keys(parsed).join(', ')}`);
}
} else {
console.log(`Gravity Bridge: getDiagnostics returned ${typeof diag}`);
}
} catch (e) {
console.log(`Gravity Bridge: getDiagnostics error: ${e}`);
console.log(`Gravity Bridge: [getManagerTrace] error: ${e}`);
}
// Probe 2: getWorkbenchTrace — may contain conversation/step data
try {
const trace: any = await vscode.commands.executeCommand('antigravity.getWorkbenchTrace');
console.log(`Gravity Bridge: [getWorkbenchTrace] type=${typeof trace}`);
if (trace) {
const str = typeof trace === 'string' ? trace : JSON.stringify(trace);
console.log(` length=${str.length}`);
console.log(` sample: ${str.substring(0, 500)}`);
}
} catch (e) {
console.log(`Gravity Bridge: [getWorkbenchTrace] error: ${e}`);
}
// Probe 3: Find LS process for ConnectRPC port + CSRF token
try {
const { exec } = require('child_process');
exec(
'powershell -Command "Get-CimInstance Win32_Process | Where-Object {$_.CommandLine -like \'*language_server*\'} | Select-Object ProcessId, CommandLine | Format-List"',
{ maxBuffer: 1024 * 1024 },
(err: any, stdout: string) => {
if (err) {
console.log(`Gravity Bridge: [LS discovery] error: ${err.message}`);
return;
}
if (stdout.trim()) {
console.log(`Gravity Bridge: [LS process found]`);
// Extract port and csrf_token from command line
const portMatch = stdout.match(/--(?:port|httpPort|httpsPort)[= ](\d+)/);
const csrfMatch = stdout.match(/--csrf_token[= ]([^\s"]+)/);
const extPortMatch = stdout.match(/--extension_server_port[= ](\d+)/);
console.log(` port: ${portMatch?.[1] || 'not found'}`);
console.log(` csrf: ${csrfMatch?.[1]?.substring(0, 12) || 'not found'}...`);
console.log(` ext_port: ${extPortMatch?.[1] || 'not found'}`);
// Show full command line for analysis
const lines = stdout.split('\n');
for (const line of lines) {
if (line.includes('CommandLine')) {
console.log(` cmdline: ${line.substring(0, 500)}`);
}
}
} else {
console.log(`Gravity Bridge: [LS process] not found`);
}
}
);
} catch (e) {
console.log(`Gravity Bridge: [LS discovery] error: ${e}`);
}
console.log('Gravity Bridge: === PROBE END ===');
}, 5000);
// Chat document change listener — captures AI text responses