Skip to content

Commit 459d600

Browse files
committed
feat: capture terminal diagnostics for runtime errors
1 parent 5253dc5 commit 459d600

File tree

5 files changed

+1074
-20
lines changed

5 files changed

+1074
-20
lines changed

.vscode-test.mjs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
11
// import { execSync } from 'node:child_process';
2-
import { existsSync, rmSync } from 'node:fs';
3-
import { dirname, resolve } from 'node:path';
2+
import { existsSync, rmSync } from "node:fs";
3+
import { dirname, resolve } from "node:path";
44
// import process from 'node:process';
5-
import { fileURLToPath } from 'node:url';
5+
import { fileURLToPath } from "node:url";
66

7-
import { defineConfig } from '@vscode/test-cli';
7+
import { defineConfig } from "@vscode/test-cli";
88

99
const __filename = fileURLToPath(import.meta.url);
1010
const __dirname = dirname(__filename);
1111

1212
// Clear user data directory before tests to prevent cached workspace state
13-
const userDataDir = resolve(__dirname, '.vscode-test/user-data');
13+
const userDataDir = resolve(__dirname, ".vscode-test/user-data");
1414
if (existsSync(userDataDir)) {
1515
rmSync(userDataDir, { recursive: true, force: true });
1616
}
1717

1818
export default defineConfig({
19-
files: 'src/test/**/*.test.ts',
20-
version: 'stable', // Match the parent VS Code version
19+
files: "src/test/**/*.test.ts",
20+
version: "stable", // Match the parent VS Code version
2121
mocha: {
22-
ui: 'bdd',
22+
ui: "bdd",
2323
timeout: 30000,
2424
parallel: false,
25-
require: ['esbuild-register'],
25+
require: ["esbuild-register"],
26+
bail: true,
2627
},
2728
// Allow extensions to load; we install required ones below via the 'extensions' field.
2829
// Run with a temporary profile for isolation between test runs.
2930
launchArgs: [
30-
resolve(__dirname, 'test-workspace', 'test-workspace.code-workspace'),
31+
resolve(__dirname, "test-workspace", "test-workspace.code-workspace"),
3132
// '--profile-temp',
32-
'--disable-extensions',
33+
"--disable-extensions",
34+
"--enable-proposed-api",
35+
"dkattan.copilot-breakpoint-debugger",
3336
],
3437
// Request automatic installation of required marketplace extensions for tests.
3538
// @vscode/test-cli will ensure these are present before running.
3639
// extensions: ['ms-vscode.powershell'],
3740
coverage: {
38-
reporter: ['text', 'html', 'lcov'],
39-
exclude: ['src/test/**', '**/node_modules/**'],
41+
reporter: ["text", "html", "lcov"],
42+
exclude: ["src/test/**", "**/node_modules/**"],
4043
},
4144
timeout: 30000,
4245
});

agents.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ The debug tracker extension provides API services for monitoring debug sessions
140140
- Always validate workspace folder exists before debugging operations
141141
- **NO FALLBACK CODE**: Never implement fallback code or fallback logic. Fallback code hides underlying issues and makes debugging harder. If something fails, it should fail explicitly with a clear error message.
142142

143+
### Runtime Diagnostics Capture
144+
145+
- `startDebuggingAndWaitForStop` now streams integrated-terminal output using `vscode.window.onDidWriteTerminalData` so crash diagnostics are available even when adapters bypass the Debug Console (e.g., configs with `console: "integratedTerminal"`).
146+
- The extension declares the `terminalDataWriteEvent` proposal via `enabledApiProposals` in `package.json` and tests pass `--enable-proposed-api dkattan.copilot-breakpoint-debugger` through `.vscode-test.mjs` launch args.
147+
- Runtime error messages automatically append exit codes, DAP stderr, and/or terminal lines (capped by `copilot-debugger.maxOutputLines`), keeping messaging concise while surfacing crash context for Copilot tools.
148+
143149
## External Dependencies
144150

145151
### debug-tracker-vscode Integration

package.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
"onLanguageModelTools",
3737
"onStartupFinished"
3838
],
39+
"enabledApiProposals": [
40+
"terminalDataWriteEvent"
41+
],
3942
"contributes": {
4043
"commands": [
4144
{
@@ -82,6 +85,18 @@
8285
],
8386
"default": "httpRequest",
8487
"description": "Preferred serverReady action type surfaced in samples and quick insert command."
88+
},
89+
"copilot-debugger.maxBuildErrors": {
90+
"type": "integer",
91+
"default": 5,
92+
"description": "Maximum number of build diagnostics (from problem matchers) to include in error messages when debug session fails to start.",
93+
"scope": "resource"
94+
},
95+
"copilot-debugger.maxOutputLines": {
96+
"type": "integer",
97+
"default": 50,
98+
"description": "Maximum number of output lines (stderr/stdout) to buffer per debug session for runtime error reporting.",
99+
"scope": "resource"
85100
}
86101
}
87102
},
@@ -461,15 +476,16 @@
461476
"compile-tests": "tsc -p ./",
462477
"pretest": "npm run lint && npm run compile-tests && npm run build:dist",
463478
"lint": "eslint",
464-
"test": "node -e \"try{require('fs').rmSync('./.vscode-test/user-data/DIP',{recursive:true,force:true});}catch(e){}\" && npx vscode-test",
479+
"test": "node -e \"try{require('fs').rmSync('./.vscode-test/user-data',{recursive:true,force:true});}catch(e){}\" && npx vscode-test",
465480
"test:coverage": "npm run compile-tests && npx vscode-test --coverage"
466481
},
467482
"dependencies": {
468483
"@actions/core": "^1.11.1",
469484
"@actions/github": "^6.0.0",
470485
"@anthropic-ai/sdk": "^0.27.3",
471486
"@vscode/prompt-tsx": "^0.4.0-alpha.5",
472-
"mocha": "^10.7.3"
487+
"mocha": "^10.7.3",
488+
"strip-ansi": "^7.1.2"
473489
},
474490
"devDependencies": {
475491
"@antfu/eslint-config": "^3.0.0",

0 commit comments

Comments
 (0)