Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export interface CacheData {
const cacheFilePath = (): string => path.join(getCacheDir(), 'parsed.json');
const cacheMetaPath = (): string => path.join(getCacheDir(), 'meta.json');

const CACHE_VERSION = 30;
const CACHE_VERSION = 31;

/** Refuse to JSON.parse cache files beyond these sizes: a corrupted (or
* tampered) cache must degrade to a full re-parse, not OOM the host. */
Expand Down
31 changes: 30 additions & 1 deletion src/core/parser-vscode-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { parseCLIEventsFile, parseCLIEventsFileAsync } from './parser-vscode-cli
import { getParseWarningCounts, resetParseWarnings, setCuriosityDetector } from './parser-shared';
import { detectCuriosity } from './curiosity';
import { CuriosityAnalyzer } from './analyzer-curiosity';
import { runDetectors } from './detector-registry';
import { runDetectors, runEmitters } from './detector-registry';

const tempDirs: string[] = [];

Expand Down Expand Up @@ -52,6 +52,35 @@ afterEach(() => {
});

describe('parseCLIEventsFileAsync', () => {
it.each([false, true])('recognizes MCP server metadata (Copilot App: %s)', async (remoteSteerable) => {
const file = writeEvents([
{ type: 'session.start', data: { sessionId: 'mcp-session', ...(remoteSteerable ? { remoteSteerable: true } : {}) } },
...Array.from({ length: 30 }, (_, index) => [
{ type: 'user.message', timestamp: new Date(Date.UTC(2026, 9, 1, 12, index)).toISOString(), data: { content: 'Find the issue' } },
{ type: 'assistant.message', data: { toolRequests: [{ toolName: 'github-search_code', arguments: {} }] } },
{ type: 'tool.execution_start', data: { toolName: 'github-search_code', mcpServerName: 'github' } },
{ type: 'tool.execution_start', data: { toolName: 'view' } },
{ type: 'tool.execution_start', data: { toolName: 'grep', mcpServerName: '' } },
]).flat(),
]);
for (const parsed of [parseCLIEventsFile(file, 'ws', 'Workspace'), await parseCLIEventsFileAsync(file, 'ws', 'Workspace')]) {
expect(parsed?.requests).toHaveLength(30);
expect(parsed?.harness).toBe(remoteSteerable ? 'GitHub Copilot App' : 'GitHub Copilot CLI');
expect(parsed?.requests[0].toolsUsed).toEqual(['mcp_github_github-search_code', 'view', 'grep']);
const mcpName = parsed?.requests[0].toolsUsed[0] ?? '';
expect(mcpName.slice(4).split('_')[0]).toBe('github');
const sessions = parsed ? [parsed] : [];
const emission = runEmitters(parsed?.requests ?? [], sessions, false).get('context-engineering-gaps');
const withoutMcp = sessions.map(session => ({
...session, requests: session.requests.map(request => ({ ...request, toolsUsed: ['search', 'view', 'grep'] })),
}));
const missing = runEmitters(withoutMcp.flatMap(session => session.requests), withoutMcp, false).get('context-engineering-gaps');
expect(emission).toBeDefined();
expect(missing).toBeDefined();
expect(emission?.count).toBe((missing?.count ?? 0) - 1);
}
});

it('classifies PowerShell-only commands and parallel calls through both parser paths', async () => {
setCuriosityDetector(detectCuriosity);
const file = writeEvents([
Expand Down
10 changes: 9 additions & 1 deletion src/core/parser-vscode-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,15 @@ function handleToolExecutionStart(ev: CLIEvent, state: CLIParseState): void {
const ts = ev.timestamp ? new Date(ev.timestamp).getTime() : null;

if (ts && turn.firstToolTs === null) turn.firstToolTs = ts;
addRecordedTools(turn, toolName, data.arguments);
// CLI/App logs identify MCP calls by server metadata rather than a name prefix.
// Use the MCP naming convention consumed by rules and feature analysis.
const mcpServerName = str(data.mcpServerName);
const recordedName = mcpServerName && toolName && !toolName.startsWith('mcp_')
? `mcp_${mcpServerName}_${toolName}`
: toolName;
// The assistant request may have recorded the raw name before server metadata arrived.
if (recordedName !== toolName) turn.toolNames.delete(toolName);
addRecordedTools(turn, recordedName, data.arguments);
const pending: PendingToolEdit = {
editLocs: new Map(),
editedFiles: new Set(recordedToolFiles(toolName, rawArgs).edited),
Expand Down
Loading