From da978add9bdb2d5d2487e6f61ff3de2deec568ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 23:08:25 +0000 Subject: [PATCH 01/12] Initial plan From 5bb3f54c6241e7ed71d154cca9b8caa00931d4e5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 23:19:36 +0000 Subject: [PATCH 02/12] Add detection for additional context # commands Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> --- docs/TRACKABLE-DATA.md | 6 +++ src/extension.ts | 69 +++++++++++++++++++++++++++++++++++ src/webview/logviewer/main.ts | 6 +++ src/webview/usage/main.ts | 6 +++ 4 files changed, 87 insertions(+) diff --git a/docs/TRACKABLE-DATA.md b/docs/TRACKABLE-DATA.md index e89a852..09bf02a 100644 --- a/docs/TRACKABLE-DATA.md +++ b/docs/TRACKABLE-DATA.md @@ -114,6 +114,12 @@ References detected via regex: - `#selection` - Selected code/text references - `#symbol` - Code symbol references (functions, classes, variables) - `#codebase` - Entire codebase references +- `#terminalLastCommand` - Last command run in terminal +- `#terminalSelection` - Selected terminal output +- `#clipboard` - Clipboard contents +- `#changes` - Uncommitted git changes +- `#outputPanel` - Output panel contents +- `#problemsPanel` - Problems panel contents - `@workspace` - Workspace-wide context - `@terminal` - Terminal/command-line context - `@vscode` - VS Code settings/environment diff --git a/src/extension.ts b/src/extension.ts index 3fa29d4..76408ba 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -124,6 +124,12 @@ interface ContextReferenceUsage { workspace: number; // @workspace references terminal: number; // @terminal references vscode: number; // @vscode references + terminalLastCommand: number; // #terminalLastCommand references + terminalSelection: number; // #terminalSelection references + clipboard: number; // #clipboard references + changes: number; // #changes references + outputPanel: number; // #outputPanel references + problemsPanel: number; // #problemsPanel references // contentReferences tracking from session logs byKind: { [kind: string]: number }; // Count by reference kind copilotInstructions: number; // .github/copilot-instructions.md @@ -1124,6 +1130,12 @@ class CopilotTokenTracker implements vscode.Disposable { workspace: 0, terminal: 0, vscode: 0, + terminalLastCommand: 0, + terminalSelection: 0, + clipboard: 0, + changes: 0, + outputPanel: 0, + problemsPanel: 0, byKind: {}, copilotInstructions: 0, agentsMd: 0, @@ -1230,6 +1242,12 @@ class CopilotTokenTracker implements vscode.Disposable { period.contextReferences.workspace += analysis.contextReferences.workspace; period.contextReferences.terminal += analysis.contextReferences.terminal; period.contextReferences.vscode += analysis.contextReferences.vscode; + period.contextReferences.terminalLastCommand += analysis.contextReferences.terminalLastCommand || 0; + period.contextReferences.terminalSelection += analysis.contextReferences.terminalSelection || 0; + period.contextReferences.clipboard += analysis.contextReferences.clipboard || 0; + period.contextReferences.changes += analysis.contextReferences.changes || 0; + period.contextReferences.outputPanel += analysis.contextReferences.outputPanel || 0; + period.contextReferences.problemsPanel += analysis.contextReferences.problemsPanel || 0; // Merge contentReferences counts period.contextReferences.copilotInstructions += analysis.contextReferences.copilotInstructions || 0; @@ -1525,6 +1543,12 @@ class CopilotTokenTracker implements vscode.Disposable { workspace: 0, terminal: 0, vscode: 0, + terminalLastCommand: 0, + terminalSelection: 0, + clipboard: 0, + changes: 0, + outputPanel: 0, + problemsPanel: 0, byKind: {}, copilotInstructions: 0, agentsMd: 0, @@ -1943,6 +1967,42 @@ class CopilotTokenTracker implements vscode.Disposable { refs.codebase += codebaseMatches.length; } + // Count #terminalLastCommand references + const terminalLastCommandMatches = text.match(/#terminalLastCommand/gi); + if (terminalLastCommandMatches) { + refs.terminalLastCommand += terminalLastCommandMatches.length; + } + + // Count #terminalSelection references + const terminalSelectionMatches = text.match(/#terminalSelection/gi); + if (terminalSelectionMatches) { + refs.terminalSelection += terminalSelectionMatches.length; + } + + // Count #clipboard references + const clipboardMatches = text.match(/#clipboard/gi); + if (clipboardMatches) { + refs.clipboard += clipboardMatches.length; + } + + // Count #changes references + const changesMatches = text.match(/#changes/gi); + if (changesMatches) { + refs.changes += changesMatches.length; + } + + // Count #outputPanel references + const outputPanelMatches = text.match(/#outputPanel/gi); + if (outputPanelMatches) { + refs.outputPanel += outputPanelMatches.length; + } + + // Count #problemsPanel references + const problemsPanelMatches = text.match(/#problemsPanel/gi); + if (problemsPanelMatches) { + refs.problemsPanel += problemsPanelMatches.length; + } + // Count @workspace references const workspaceMatches = text.match(/@workspace/gi); if (workspaceMatches) { @@ -2370,6 +2430,12 @@ class CopilotTokenTracker implements vscode.Disposable { workspace: 0, terminal: 0, vscode: 0, + terminalLastCommand: 0, + terminalSelection: 0, + clipboard: 0, + changes: 0, + outputPanel: 0, + problemsPanel: 0, byKind: {}, copilotInstructions: 0, agentsMd: 0, @@ -2494,6 +2560,7 @@ class CopilotTokenTracker implements vscode.Disposable { contextReferences: { file: 0, selection: 0, implicitSelection: 0, symbol: 0, codebase: 0, workspace: 0, terminal: 0, vscode: 0, + terminalLastCommand: 0, terminalSelection: 0, clipboard: 0, changes: 0, outputPanel: 0, problemsPanel: 0, // Extended fields expected by SessionUsageAnalysis in the webview byKind: {}, copilotInstructions: 0, agentsMd: 0, byPath: {} }, @@ -2550,6 +2617,7 @@ class CopilotTokenTracker implements vscode.Disposable { contextReferences: { file: 0, selection: 0, implicitSelection: 0, symbol: 0, codebase: 0, workspace: 0, terminal: 0, vscode: 0, + terminalLastCommand: 0, terminalSelection: 0, clipboard: 0, changes: 0, outputPanel: 0, problemsPanel: 0, byKind: {}, copilotInstructions: 0, agentsMd: 0, byPath: {} }, firstInteraction: null, @@ -3058,6 +3126,7 @@ class CopilotTokenTracker implements vscode.Disposable { return { file: 0, selection: 0, implicitSelection: 0, symbol: 0, codebase: 0, workspace: 0, terminal: 0, vscode: 0, + terminalLastCommand: 0, terminalSelection: 0, clipboard: 0, changes: 0, outputPanel: 0, problemsPanel: 0, byKind: {}, copilotInstructions: 0, agentsMd: 0, byPath: {} }; } diff --git a/src/webview/logviewer/main.ts b/src/webview/logviewer/main.ts index 6d5e3d1..f74e247 100644 --- a/src/webview/logviewer/main.ts +++ b/src/webview/logviewer/main.ts @@ -99,6 +99,12 @@ function getContextRefBadges(refs: ContextReferenceUsage): string { if (refs.workspace > 0) { badges.push(`@workspace: ${refs.workspace}`); } if (refs.terminal > 0) { badges.push(`@terminal: ${refs.terminal}`); } if (refs.vscode > 0) { badges.push(`@vscode: ${refs.vscode}`); } + if ((refs.terminalLastCommand || 0) > 0) { badges.push(`#terminalLastCommand: ${refs.terminalLastCommand}`); } + if ((refs.terminalSelection || 0) > 0) { badges.push(`#terminalSelection: ${refs.terminalSelection}`); } + if ((refs.clipboard || 0) > 0) { badges.push(`#clipboard: ${refs.clipboard}`); } + if ((refs.changes || 0) > 0) { badges.push(`#changes: ${refs.changes}`); } + if ((refs.outputPanel || 0) > 0) { badges.push(`#outputPanel: ${refs.outputPanel}`); } + if ((refs.problemsPanel || 0) > 0) { badges.push(`#problemsPanel: ${refs.problemsPanel}`); } if (refs.implicitSelection > 0) { badges.push(`implicit: ${refs.implicitSelection}`); } return badges.join(''); } diff --git a/src/webview/usage/main.ts b/src/webview/usage/main.ts index 2ce194b..f1de4f5 100644 --- a/src/webview/usage/main.ts +++ b/src/webview/usage/main.ts @@ -197,6 +197,12 @@ function renderLayout(stats: UsageAnalysisStats): void {
📁 @workspace
${stats.month.contextReferences.workspace}
Today: ${stats.today.contextReferences.workspace}
💻 @terminal
${stats.month.contextReferences.terminal}
Today: ${stats.today.contextReferences.terminal}
🔧 @vscode
${stats.month.contextReferences.vscode}
Today: ${stats.today.contextReferences.vscode}
+
⌨️ #terminalLastCommand
${stats.month.contextReferences.terminalLastCommand || 0}
Today: ${stats.today.contextReferences.terminalLastCommand || 0}
+
🖱️ #terminalSelection
${stats.month.contextReferences.terminalSelection || 0}
Today: ${stats.today.contextReferences.terminalSelection || 0}
+
📋 #clipboard
${stats.month.contextReferences.clipboard || 0}
Today: ${stats.today.contextReferences.clipboard || 0}
+
📝 #changes
${stats.month.contextReferences.changes || 0}
Today: ${stats.today.contextReferences.changes || 0}
+
📤 #outputPanel
${stats.month.contextReferences.outputPanel || 0}
Today: ${stats.today.contextReferences.outputPanel || 0}
+
⚠️ #problemsPanel
${stats.month.contextReferences.problemsPanel || 0}
Today: ${stats.today.contextReferences.problemsPanel || 0}
📋 Copilot Instructions
${stats.month.contextReferences.copilotInstructions}
Today: ${stats.today.contextReferences.copilotInstructions}
🤖 Agents.md
${stats.month.contextReferences.agentsMd}
Today: ${stats.today.contextReferences.agentsMd}
📊 Total References
${monthTotalRefs}
Today: ${todayTotalRefs}
From 88062ba5aff132bc3b31495e456f89a770fa25e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 23:20:05 +0000 Subject: [PATCH 03/12] Update USAGE-ANALYSIS documentation with new context commands Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> --- docs/USAGE-ANALYSIS.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/USAGE-ANALYSIS.md b/docs/USAGE-ANALYSIS.md index 8820310..a226308 100644 --- a/docs/USAGE-ANALYSIS.md +++ b/docs/USAGE-ANALYSIS.md @@ -49,6 +49,12 @@ Tracks how often you provide different types of context to Copilot: - **✂️ #selection**: References to selected code or text - **🔤 #symbol**: References to code symbols (functions, classes, variables) - **🗂️ #codebase**: References to the entire codebase for search/analysis +- **⌨️ #terminalLastCommand**: References to the last command run in terminal +- **🖱️ #terminalSelection**: References to selected terminal output +- **📋 #clipboard**: References to clipboard contents +- **📝 #changes**: References to uncommitted git changes +- **📤 #outputPanel**: References to output panel contents +- **⚠️ #problemsPanel**: References to problems panel contents - **📁 @workspace**: References to workspace-wide context - **💻 @terminal**: References to terminal or command-line context - **🔧 @vscode**: References to VS Code settings or environment @@ -125,6 +131,9 @@ Session analysis data is cached alongside token counts to improve performance: - **High #file usage**: You often work with specific files - **High #selection usage**: You frequently reference selected code +- **High #terminalLastCommand usage**: You often ask about terminal commands or errors +- **High #changes usage**: You frequently review uncommitted changes with Copilot +- **High #outputPanel or #problemsPanel usage**: You use Copilot to debug build/test output - **High @workspace usage**: You provide broad context for better suggestions - **Low context usage**: Consider providing more context for better results @@ -141,7 +150,7 @@ Session analysis data is cached alongside token counts to improve performance: ## Tips for Optimization -1. **Provide Rich Context**: Use #file, #selection, and @workspace to give Copilot better context +1. **Provide Rich Context**: Use #file, #selection, #terminalLastCommand, #changes, and @workspace to give Copilot better context 2. **Try Different Modes**: Experiment with ask vs. edit mode for different tasks 3. **Leverage Agent Mode**: For complex tasks, consider using agent mode or Copilot CLI 4. **Monitor Tool Usage**: Tools can extend Copilot's capabilities - check which are being used From 5845401c5d2257e58bb168af8783a322c90c0ba6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 19:05:07 +0000 Subject: [PATCH 04/12] Initial plan From 23eeb14ddedcb0aed0cb0d8f8d9c1497d3743b3b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 22:23:41 +0000 Subject: [PATCH 05/12] Initial plan From 31644bea7de9d09e0629a1e539234a896ae02704 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Sun, 8 Feb 2026 17:09:19 +0100 Subject: [PATCH 06/12] Refactor context reference handling: consolidate utility functions and enhance context reference analysis in webviews --- package-lock.json | 7 --- src/extension.ts | 89 +++++++++++++++++++++++++++ src/webview/shared/contextRefUtils.ts | 28 ++++++++- 3 files changed, 114 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1d5d923..481bb71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -626,7 +626,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=18" }, @@ -665,7 +664,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=18" } @@ -2009,7 +2007,6 @@ "integrity": "sha512-BtE0k6cjwjLZoZixN0t5AKP0kSzlGu7FctRXYuPAm//aaiZhmfq1JwdYpYr1brzEspYyFeF+8XF5j2VK6oalrA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.54.0", "@typescript-eslint/types": "8.54.0", @@ -2670,7 +2667,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -4263,7 +4259,6 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -9475,7 +9470,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -9711,7 +9705,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/src/extension.ts b/src/extension.ts index 76408ba..0073159 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1669,6 +1669,95 @@ class CopilotTokenTracker implements vscode.Disposable { try { const event = JSON.parse(line); + // Handle VS Code incremental format - detect mode from session header + if (event.kind === 0 && event.v?.inputState?.mode?.kind) { + sessionMode = event.v.inputState.mode.kind; + + // Detect implicit selections in initial state (only if there's an actual range) + if (event.v?.inputState?.selections && Array.isArray(event.v.inputState.selections)) { + for (const sel of event.v.inputState.selections) { + // Only count if it's an actual selection (not just a cursor position) + if (sel.startLineNumber !== sel.endLineNumber || sel.startColumn !== sel.endColumn) { + analysis.contextReferences.implicitSelection++; + break; // Count once per session + } + } + } + } + + // Handle mode changes (kind: 1 with mode update) + if (event.kind === 1 && event.k?.includes('mode') && event.v?.kind) { + sessionMode = event.v.kind; + } + + // Detect implicit selections in updates to inputState.selections + if (event.kind === 1 && event.k?.includes('selections') && Array.isArray(event.v)) { + for (const sel of event.v) { + // Only count if it's an actual selection (not just a cursor position) + if (sel && (sel.startLineNumber !== sel.endLineNumber || sel.startColumn !== sel.endColumn)) { + analysis.contextReferences.implicitSelection++; + break; // Count once per update + } + } + } + + // Handle contentReferences updates (kind: 1 with contentReferences update) + if (event.kind === 1 && event.k?.includes('contentReferences') && Array.isArray(event.v)) { + this.analyzeContentReferences(event.v, analysis.contextReferences); + } + + // Handle variableData updates (kind: 1 with variableData update) + if (event.kind === 1 && event.k?.includes('variableData') && event.v) { + this.analyzeVariableData(event.v, analysis.contextReferences); + } + + // Handle VS Code incremental format - count requests as interactions + if (event.kind === 2 && event.k?.[0] === 'requests' && Array.isArray(event.v)) { + for (const request of event.v) { + if (request.requestId) { + // Count by mode + if (sessionMode === 'agent') { + analysis.modeUsage.agent++; + } else if (sessionMode === 'edit') { + analysis.modeUsage.edit++; + } else { + analysis.modeUsage.ask++; + } + } + // Check for agent in request + if (request.agent?.id) { + const toolName = request.agent.id; + analysis.toolCalls.total++; + analysis.toolCalls.byTool[toolName] = (analysis.toolCalls.byTool[toolName] || 0) + 1; + } + + // Analyze all context references from this request + this.analyzeRequestContext(request, analysis.contextReferences); + + // Extract tool calls from request.response array (when full request is added) + if (request.response && Array.isArray(request.response)) { + for (const responseItem of request.response) { + if (responseItem.kind === 'toolInvocationSerialized' || responseItem.kind === 'prepareToolInvocation') { + analysis.toolCalls.total++; + const toolName = responseItem.toolId || responseItem.toolName || responseItem.invocationMessage?.toolName || responseItem.toolSpecificData?.kind || 'unknown'; + analysis.toolCalls.byTool[toolName] = (analysis.toolCalls.byTool[toolName] || 0) + 1; + } + } + } + } + } + + // Handle VS Code incremental format - tool invocations in responses + if (event.kind === 2 && event.k?.includes('response') && Array.isArray(event.v)) { + for (const responseItem of event.v) { + if (responseItem.kind === 'toolInvocationSerialized') { + analysis.toolCalls.total++; + const toolName = responseItem.toolId || responseItem.toolName || responseItem.invocationMessage?.toolName || responseItem.toolSpecificData?.kind || 'unknown'; + analysis.toolCalls.byTool[toolName] = (analysis.toolCalls.byTool[toolName] || 0) + 1; + } + } + } + // Handle Copilot CLI format // Detect mode from event type - CLI can be chat or agent mode if (event.type === 'user.message') { diff --git a/src/webview/shared/contextRefUtils.ts b/src/webview/shared/contextRefUtils.ts index 89d18bb..3b45b07 100644 --- a/src/webview/shared/contextRefUtils.ts +++ b/src/webview/shared/contextRefUtils.ts @@ -11,6 +11,12 @@ export type ContextReferenceUsage = { workspace: number; terminal: number; vscode: number; + terminalLastCommand: number; + terminalSelection: number; + clipboard: number; + changes: number; + outputPanel: number; + problemsPanel: number; byKind: { [kind: string]: number }; copilotInstructions: number; agentsMd: number; @@ -23,7 +29,9 @@ export type ContextReferenceUsage = { */ export function getTotalContextRefs(refs: ContextReferenceUsage): number { return refs.file + refs.selection + refs.implicitSelection + refs.symbol + refs.codebase + - refs.workspace + refs.terminal + refs.vscode + refs.copilotInstructions + refs.agentsMd; + refs.workspace + refs.terminal + refs.vscode + refs.copilotInstructions + refs.agentsMd + + (refs.terminalLastCommand || 0) + (refs.terminalSelection || 0) + (refs.clipboard || 0) + + (refs.changes || 0) + (refs.outputPanel || 0) + (refs.problemsPanel || 0); } /** @@ -36,11 +44,13 @@ export function getImplicitContextRefs(refs: ContextReferenceUsage): number { /** * Calculate the count of explicit (user-initiated) context references. - * Explicit refs are user-initiated: #file, #selection, #symbol, #codebase, @workspace, @terminal, @vscode + * Explicit refs are user-initiated: #file, #selection, #symbol, #codebase, @workspace, @terminal, @vscode, etc. */ export function getExplicitContextRefs(refs: ContextReferenceUsage): number { return refs.file + refs.selection + refs.symbol + refs.codebase + - refs.workspace + refs.terminal + refs.vscode; + refs.workspace + refs.terminal + refs.vscode + + (refs.terminalLastCommand || 0) + (refs.terminalSelection || 0) + (refs.clipboard || 0) + + (refs.changes || 0) + (refs.outputPanel || 0) + (refs.problemsPanel || 0); } /** @@ -61,6 +71,12 @@ export function getContextRefsSummary(refs: ContextReferenceUsage, abbreviated = if (refs.workspace > 0) { parts.push(`@ws: ${refs.workspace}`); } if (refs.terminal > 0) { parts.push(`@term: ${refs.terminal}`); } if (refs.vscode > 0) { parts.push(`@vsc: ${refs.vscode}`); } + if ((refs.terminalLastCommand || 0) > 0) { parts.push(`#termLC: ${refs.terminalLastCommand}`); } + if ((refs.terminalSelection || 0) > 0) { parts.push(`#termSel: ${refs.terminalSelection}`); } + if ((refs.clipboard || 0) > 0) { parts.push(`#clip: ${refs.clipboard}`); } + if ((refs.changes || 0) > 0) { parts.push(`#chg: ${refs.changes}`); } + if ((refs.outputPanel || 0) > 0) { parts.push(`#out: ${refs.outputPanel}`); } + if ((refs.problemsPanel || 0) > 0) { parts.push(`#prob: ${refs.problemsPanel}`); } if (refs.copilotInstructions > 0) { parts.push(`📋 inst: ${refs.copilotInstructions}`); } if (refs.agentsMd > 0) { parts.push(`🤖 ag: ${refs.agentsMd}`); } } else { @@ -73,6 +89,12 @@ export function getContextRefsSummary(refs: ContextReferenceUsage, abbreviated = if (refs.workspace > 0) { parts.push(`@workspace: ${refs.workspace}`); } if (refs.terminal > 0) { parts.push(`@terminal: ${refs.terminal}`); } if (refs.vscode > 0) { parts.push(`@vscode: ${refs.vscode}`); } + if ((refs.terminalLastCommand || 0) > 0) { parts.push(`#terminalLastCommand: ${refs.terminalLastCommand}`); } + if ((refs.terminalSelection || 0) > 0) { parts.push(`#terminalSelection: ${refs.terminalSelection}`); } + if ((refs.clipboard || 0) > 0) { parts.push(`#clipboard: ${refs.clipboard}`); } + if ((refs.changes || 0) > 0) { parts.push(`#changes: ${refs.changes}`); } + if ((refs.outputPanel || 0) > 0) { parts.push(`#outputPanel: ${refs.outputPanel}`); } + if ((refs.problemsPanel || 0) > 0) { parts.push(`#problemsPanel: ${refs.problemsPanel}`); } if (refs.copilotInstructions > 0) { parts.push(`📋 instructions: ${refs.copilotInstructions}`); } if (refs.agentsMd > 0) { parts.push(`🤖 agents: ${refs.agentsMd}`); } } From 6790c1c937fd506f320a51667d9266ef50c5e6de Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 20:05:28 +0000 Subject: [PATCH 07/12] Initial plan From 8845e46cb8274ab329bcfc2674b839e8fef61ea4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 19:32:34 +0000 Subject: [PATCH 08/12] Initial plan From ebe56bb18571ba8eb785830e77d15fe11c34be87 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Sun, 8 Feb 2026 21:43:56 +0100 Subject: [PATCH 09/12] Enhance context reference utilities by adding support for additional reference types in calculations and summaries --- src/webview/shared/contextRefUtils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/webview/shared/contextRefUtils.ts b/src/webview/shared/contextRefUtils.ts index 3b45b07..7e07806 100644 --- a/src/webview/shared/contextRefUtils.ts +++ b/src/webview/shared/contextRefUtils.ts @@ -44,7 +44,8 @@ export function getImplicitContextRefs(refs: ContextReferenceUsage): number { /** * Calculate the count of explicit (user-initiated) context references. - * Explicit refs are user-initiated: #file, #selection, #symbol, #codebase, @workspace, @terminal, @vscode, etc. + * Explicit refs are user-initiated: #file, #selection, #symbol, #codebase, @workspace, @terminal, @vscode, + * #terminalLastCommand, #terminalSelection, #clipboard, #changes, #outputPanel, #problemsPanel */ export function getExplicitContextRefs(refs: ContextReferenceUsage): number { return refs.file + refs.selection + refs.symbol + refs.codebase + From 87852b320c3d7dd5d7b67e4b1acfcec0079c17db Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Sun, 8 Feb 2026 21:51:48 +0100 Subject: [PATCH 10/12] Add in more toolnames --- src/toolNames.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/toolNames.json b/src/toolNames.json index 2cf37cc..58fea42 100644 --- a/src/toolNames.json +++ b/src/toolNames.json @@ -6,6 +6,10 @@ ,"mcp_io_github_git_pull_request_read": "GitHub MCP: Pull Request Read" ,"mcp_io_github_git_issue_read": "GitHub MCP: Issue Read" ,"mcp_io_github_git_issue_write": "GitHub MCP: Issue Write" + ,"mcp_io_github_git_get_file_contents": "GitHub MCP: Get File Contents" + ,"mcp_io_github_git_search_code": "GitHub MCP: Search Code" + ,"mcp_io_github_git_search_pull_requests": "GitHub MCP: Search Pull Requests" + ,"mcp_com_microsoft_get_bestpractices": "GitHub MCP: Get Best Practices" ,"manage_todo_list": "Manage TODO List" ,"copilot_readFile": "Read File" ,"copilot_applyPatch": "Apply Patch" @@ -23,4 +27,5 @@ ,"github.copilot.editsAgent": "GitHub Copilot Edits Agent" ,"todoList": "TODO List" ,"terminal": "Terminal" + ,"terminal_last_command": "Terminal Last Command" } From f7c0b8cc6ccfcc5d01a4f618bc508397d7027988 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Sun, 8 Feb 2026 21:59:31 +0100 Subject: [PATCH 11/12] Add tool name mapping from JSON for improved display in MCP server extraction --- src/extension.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 0073159..62a34f2 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -4,6 +4,7 @@ import * as path from 'path'; import * as os from 'os'; import tokenEstimatorsData from './tokenEstimators.json'; import modelPricingData from './modelPricing.json'; +import toolNamesData from './toolNames.json'; import { BackendFacade } from './backend/facade'; import { BackendCommandHandler } from './backend/commands'; import * as packageJson from '../package.json'; @@ -265,6 +266,9 @@ class CopilotTokenTracker implements vscode.Disposable { // These are reference prices for cost estimation purposes only private modelPricing: { [key: string]: ModelPricing } = modelPricingData.pricing as { [key: string]: ModelPricing }; + // Tool name mapping - loaded from toolNames.json for friendly display names + private toolNameMap: { [key: string]: string } = toolNamesData as { [key: string]: string }; + // Helper method to get repository URL from package.json private getRepositoryUrl(): string { const repoUrl = packageJson.repository?.url?.replace(/^git\+/, '').replace(/\.git$/, ''); @@ -1981,10 +1985,19 @@ class CopilotTokenTracker implements vscode.Disposable { /** * Extract server name from an MCP tool name. * MCP tool names follow the format: mcp.server.tool or mcp_server_tool - * For example: "mcp.io.github.git" → "io", "mcp_io_github_git" → "io" - * Note: Splits on both '.' and '_' to handle various naming conventions + * For example: "mcp.io.github.git.assign_copilot_to_issue" → "GitHub MCP" + * Uses the display name from toolNames.json (the part before the colon). + * Falls back to extracting the second segment if no mapping exists. */ private extractMcpServerName(toolName: string): string { + // First, try to get the display name from toolNames.json and extract the server part + const displayName = this.toolNameMap[toolName]; + if (displayName && displayName.includes(':')) { + // Extract the part before the colon (e.g., "GitHub MCP" from "GitHub MCP: Issue Read") + return displayName.split(':')[0].trim(); + } + + // Fallback: extract from tool name structure // Remove the mcp. or mcp_ prefix const withoutPrefix = toolName.replace(/^mcp[._]/, ''); // Split on . or _ and take the first part (server identifier) From b6762375d260151af08e30b8c7095bbf3f70563f Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Sun, 8 Feb 2026 22:20:45 +0100 Subject: [PATCH 12/12] fix: add sessionMode declaration in non-delta JSONL parser --- src/extension.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/extension.ts b/src/extension.ts index 62a34f2..d69e700 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1668,6 +1668,7 @@ class CopilotTokenTracker implements vscode.Disposable { } // Non-delta JSONL (Copilot CLI format) - process line-by-line + let sessionMode = 'ask'; for (const line of lines) { if (!line.trim()) { continue; } try {