crossexamdev 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/crossexam.js +168 -4
- package/package.json +1 -1
- package/src/evidence.js +3 -1
- package/src/findings.js +194 -0
- package/src/mcp.js +259 -198
- package/src/mutate.js +142 -3
- package/src/redact.js +59 -0
- package/src/reliability.js +154 -0
- package/src/report.js +2 -1
- package/src/strength.js +637 -628
- package/src/upload.js +212 -0
package/src/mcp.js
CHANGED
|
@@ -1,198 +1,259 @@
|
|
|
1
|
-
// A Model Context Protocol server over stdio, so any MCP-capable agent
|
|
2
|
-
// (Claude Code, Cursor, Copilot, Codex, Gemini CLI, Windsurf, Cline, Zed,
|
|
3
|
-
// Goose…) can ask crossexam to check its summary before it says "done".
|
|
4
|
-
// Newline-delimited JSON-RPC 2.0, no dependencies. stdout is the protocol;
|
|
5
|
-
// anything human goes to stderr.
|
|
6
|
-
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import readline from 'node:readline';
|
|
9
|
-
import fs from 'node:fs';
|
|
10
|
-
import os from 'node:os';
|
|
11
|
-
import { detectWorkClaims } from './claims.js';
|
|
12
|
-
import { detectCommands, verifyText } from './live.js';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
} catch
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
]
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
1
|
+
// A Model Context Protocol server over stdio, so any MCP-capable agent
|
|
2
|
+
// (Claude Code, Cursor, Copilot, Codex, Gemini CLI, Windsurf, Cline, Zed,
|
|
3
|
+
// Goose…) can ask crossexam to check its summary before it says "done".
|
|
4
|
+
// Newline-delimited JSON-RPC 2.0, no dependencies. stdout is the protocol;
|
|
5
|
+
// anything human goes to stderr.
|
|
6
|
+
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import readline from 'node:readline';
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import os from 'node:os';
|
|
11
|
+
import { detectWorkClaims } from './claims.js';
|
|
12
|
+
import { detectCommands, verifyText } from './live.js';
|
|
13
|
+
import { findingsFrom, formatFindingsForAgent, openSession, reverify, reverifyRecord } from './findings.js';
|
|
14
|
+
import { describeAgent, reliability } from './reliability.js';
|
|
15
|
+
import { STATUS, assessStrength, ledgerRecord, qualityOf } from './strength.js';
|
|
16
|
+
|
|
17
|
+
const SUPPORTED = ['2025-06-18', '2025-03-26', '2024-11-05'];
|
|
18
|
+
|
|
19
|
+
const INSTRUCTIONS = `crossexam checks claims against the repository. Before you tell the user a task is done, call verify_claims with the exact summary you are about to give and the absolute path of the workspace. If any claim comes back "contradicted", fix the problem or correct the summary before finishing. Never say tests, build, types or lint pass unless verify_claims verified it. When a result includes a findings session, fix each finding, then call reverify_findings with that session: only its independent re-check can close a finding, so never report findings as fixed before it does.`;
|
|
20
|
+
|
|
21
|
+
const TOOLS = [
|
|
22
|
+
{
|
|
23
|
+
name: 'verify_claims',
|
|
24
|
+
title: 'Verify completion claims',
|
|
25
|
+
description:
|
|
26
|
+
'Check what you are about to tell the user ("all tests pass", "build is clean", "renamed `foo` to `bar` everywhere", "bumped zod to 3.23.8") against the repository right now. Runs the project\'s own test/build/typecheck/lint commands and searches the code. Call this before reporting a task as done.',
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
summary: { type: 'string', description: 'The completion message you are about to send, verbatim.' },
|
|
31
|
+
cwd: { type: 'string', description: 'Absolute path of the workspace/repository root. Defaults to the server\'s working directory.' },
|
|
32
|
+
mutate: { type: 'boolean', description: 'Also grade how strong the tests behind a "tests pass" or "implemented/fixed" claim are, by planting small defects in the changed code (slower: runs the test suite once per mutant).' },
|
|
33
|
+
},
|
|
34
|
+
required: ['summary'],
|
|
35
|
+
},
|
|
36
|
+
annotations: { readOnlyHint: false, openWorldHint: false },
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'assess_test_strength',
|
|
40
|
+
title: 'Assess test strength (mutation testing)',
|
|
41
|
+
description:
|
|
42
|
+
"Plant small deterministic defects (flipped comparisons, inverted conditions, swapped operators) in the code you changed, run the repo's tests against each one in an isolated copy, and report which defects the tests failed to notice. Your working tree is never modified. Use the surviving defects to write tests that would catch them.",
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
cwd: { type: 'string', description: 'Absolute path of the repository root.' },
|
|
47
|
+
base: { type: 'string', description: 'Git ref to compare against. Default: uncommitted changes, else the last commit.' },
|
|
48
|
+
files: { type: 'array', items: { type: 'string' }, description: 'Mutate these files (every line) instead of the diff.' },
|
|
49
|
+
max: { type: 'number', description: 'Most mutants to run in this call (default 15). Finished results are cached, so calling again continues.' },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'reverify_findings',
|
|
56
|
+
title: 'Submit fixes for independent re-verification',
|
|
57
|
+
description:
|
|
58
|
+
'After fixing the findings from verify_claims or assess_test_strength, call this with the session id they returned. crossexam re-checks every open finding itself: contradicted claims are verified again from scratch, and each surviving defect is planted again and your tests re-run. Returns what is now resolved, what is still open, and what no longer applies because the code changed. You cannot mark a finding resolved any other way.',
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
session: { type: 'string', description: 'The findings session id, like cx-1a2b3c4d5e.' },
|
|
63
|
+
cwd: { type: 'string', description: 'Absolute path of the repository root, if it moved since the session opened.' },
|
|
64
|
+
},
|
|
65
|
+
required: ['session'],
|
|
66
|
+
},
|
|
67
|
+
annotations: { readOnlyHint: false, openWorldHint: false },
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'agent_reliability',
|
|
71
|
+
title: 'Reliability by agent',
|
|
72
|
+
description: 'How reliably each coding agent has produced working software on this machine, from recorded verification evidence: how often its claims held up, how many planted defects its tests caught, and how often its fixes closed findings on the first independent re-check. Three separate measures, never blended.',
|
|
73
|
+
inputSchema: { type: 'object', properties: { days: { type: 'number', description: 'How far back to look (default 90).' }, agent: { type: 'string', description: 'Only this agent.' } } },
|
|
74
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'list_checks',
|
|
78
|
+
title: 'List the checks crossexam would run',
|
|
79
|
+
description: 'Show which test, build, typecheck, lint and migration-status commands crossexam found for a repository.',
|
|
80
|
+
inputSchema: { type: 'object', properties: { cwd: { type: 'string', description: 'Absolute path of the repository root.' } } },
|
|
81
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
export function startMcpServer({ version, defaultCwd = process.cwd() }) {
|
|
86
|
+
let client = 'unknown';
|
|
87
|
+
const send = (msg) => process.stdout.write(JSON.stringify(msg) + '\n');
|
|
88
|
+
const reply = (id, result) => send({ jsonrpc: '2.0', id, result });
|
|
89
|
+
const fail = (id, code, message) => send({ jsonrpc: '2.0', id, error: { code, message } });
|
|
90
|
+
|
|
91
|
+
const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
92
|
+
rl.on('line', async (line) => {
|
|
93
|
+
if (!line.trim()) return;
|
|
94
|
+
let msg;
|
|
95
|
+
try {
|
|
96
|
+
msg = JSON.parse(line);
|
|
97
|
+
} catch {
|
|
98
|
+
return fail(null, -32700, 'Parse error');
|
|
99
|
+
}
|
|
100
|
+
const { id, method, params = {} } = msg;
|
|
101
|
+
const isRequest = id !== undefined && id !== null;
|
|
102
|
+
try {
|
|
103
|
+
switch (method) {
|
|
104
|
+
case 'initialize':
|
|
105
|
+
client = agentFromClient(params.clientInfo?.name);
|
|
106
|
+
return reply(id, {
|
|
107
|
+
protocolVersion: SUPPORTED.includes(params.protocolVersion) ? params.protocolVersion : SUPPORTED[0],
|
|
108
|
+
capabilities: { tools: { listChanged: false } },
|
|
109
|
+
serverInfo: { name: 'crossexam', title: 'crossexam', version },
|
|
110
|
+
instructions: INSTRUCTIONS,
|
|
111
|
+
});
|
|
112
|
+
case 'ping':
|
|
113
|
+
return reply(id, {});
|
|
114
|
+
case 'tools/list':
|
|
115
|
+
return reply(id, { tools: TOOLS });
|
|
116
|
+
case 'tools/call':
|
|
117
|
+
return reply(id, await callTool(params.name, params.arguments || {}, defaultCwd, client));
|
|
118
|
+
default:
|
|
119
|
+
if (isRequest) return fail(id, -32601, `Method not found: ${method}`);
|
|
120
|
+
}
|
|
121
|
+
} catch (e) {
|
|
122
|
+
if (isRequest) fail(id, -32603, String(e?.message || e));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
rl.on('close', () => process.exit(0));
|
|
126
|
+
process.stderr.write(`crossexam MCP server ${version} ready (cwd ${defaultCwd})\n`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Keep MCP calls well inside client timeouts; results are cached, so the agent can call again.
|
|
130
|
+
const MCP_LIMITS = { max: 15, budgetSeconds: 120 };
|
|
131
|
+
|
|
132
|
+
async function callTool(name, args, defaultCwd, client = 'unknown') {
|
|
133
|
+
const cwd = path.resolve(typeof args.cwd === 'string' && args.cwd ? args.cwd : defaultCwd);
|
|
134
|
+
if (name === 'list_checks') {
|
|
135
|
+
const cmds = detectCommands(cwd);
|
|
136
|
+
const lines = ['tests', 'build', 'types', 'lint', 'migration'].map((k) => `${k.padEnd(9)} ${cmds[k] ? `${cmds[k].command} (from ${cmds[k].source})` : '—'}`);
|
|
137
|
+
return { content: [{ type: 'text', text: `Checks for ${cwd}\n\n${lines.join('\n')}` }], structuredContent: { cwd, commands: cmds } };
|
|
138
|
+
}
|
|
139
|
+
if (name === 'verify_claims') {
|
|
140
|
+
if (typeof args.summary !== 'string' || !args.summary.trim()) {
|
|
141
|
+
return { isError: true, content: [{ type: 'text', text: 'summary is required: pass the completion message you are about to send.' }] };
|
|
142
|
+
}
|
|
143
|
+
const r = await verifyText(args.summary, { cwd });
|
|
144
|
+
if (args.mutate === true && (r.results.some((x) => x.kind === 'tests') || detectWorkClaims(args.summary).length)) {
|
|
145
|
+
const strength = await assessStrength({ cwd, ...MCP_LIMITS });
|
|
146
|
+
r.strength = strength;
|
|
147
|
+
for (const x of r.results) if (x.kind === 'tests') x.quality = qualityOf(strength);
|
|
148
|
+
ledger(ledgerRecord(strength, { agent: client, claim: args.summary.slice(0, 280), source: 'mcp' }));
|
|
149
|
+
}
|
|
150
|
+
const at = new Date().toISOString();
|
|
151
|
+
ledger(...r.results.map((x) => ({ type: 'verify', at, agent: client, repo: path.basename(cwd), source: 'mcp', kind: x.kind, verdict: x.verdict })));
|
|
152
|
+
const findings = findingsFrom({ verify: r, strength: r.strength });
|
|
153
|
+
const session = findings.length ? openSession({ findings, cwd, repo: r.strength?.repo, agent: client, source: 'mcp', testCommand: r.strength?.testCommand }) : null;
|
|
154
|
+
const text = formatForAgent(r) + (r.strength ? '\n\n' + formatStrengthForAgent(r.strength) : '') + (session ? '\n\n' + formatFindingsForAgent(session) : '');
|
|
155
|
+
return { content: [{ type: 'text', text }], structuredContent: { ok: r.ok, results: r.results, strength: r.strength ? qualityOf(r.strength) : undefined, session: session?.id ?? null, findings } };
|
|
156
|
+
}
|
|
157
|
+
if (name === 'assess_test_strength') {
|
|
158
|
+
const files = Array.isArray(args.files) ? args.files.filter((x) => typeof x === 'string') : undefined;
|
|
159
|
+
const max = Number.isFinite(args.max) ? Math.min(Math.max(1, args.max), 50) : MCP_LIMITS.max;
|
|
160
|
+
const strength = await assessStrength({ cwd, base: typeof args.base === 'string' ? args.base : undefined, files, max, budgetSeconds: MCP_LIMITS.budgetSeconds });
|
|
161
|
+
ledger(ledgerRecord(strength, { agent: client, source: 'mcp' }));
|
|
162
|
+
const findings = findingsFrom({ strength });
|
|
163
|
+
const session = findings.length ? openSession({ findings, cwd, repo: strength.repo, agent: client, source: 'mcp', testCommand: strength.testCommand }) : null;
|
|
164
|
+
const tail = session ? `\n\nFindings session ${session.id}: after adding tests, call reverify_findings with this session. Only that independent re-check closes a finding.` : '';
|
|
165
|
+
return {
|
|
166
|
+
content: [{ type: 'text', text: formatStrengthForAgent(strength) + tail }],
|
|
167
|
+
structuredContent: { quality: qualityOf(strength), summary: strength.summary, survivors: strength.mutants.filter((m) => m.status === STATUS.SURVIVED), session: session?.id ?? null, findings },
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (name === 'reverify_findings') {
|
|
171
|
+
if (typeof args.session !== 'string' || !args.session.trim()) return { isError: true, content: [{ type: 'text', text: 'session is required: pass the findings session id you were given.' }] };
|
|
172
|
+
let result;
|
|
173
|
+
try {
|
|
174
|
+
result = await reverify(args.session.trim(), { cwd: typeof args.cwd === 'string' && args.cwd ? args.cwd : undefined });
|
|
175
|
+
} catch (e) {
|
|
176
|
+
return { isError: true, content: [{ type: 'text', text: String(e?.message || e) }] };
|
|
177
|
+
}
|
|
178
|
+
const { session, summary, changes } = result;
|
|
179
|
+
ledger(reverifyRecord(session, summary));
|
|
180
|
+
const mark = { resolved: '✓ resolved', 'still-open': '✗ STILL OPEN', superseded: '○ superseded' };
|
|
181
|
+
const lines = changes.map((ch) => {
|
|
182
|
+
const f = session.findings.find((x) => x.id === ch.id);
|
|
183
|
+
const what = f.type === 'claim' ? `"${f.claim}"` : `${f.file}:${f.line} (${f.category} · ${f.operator})`;
|
|
184
|
+
return `${mark[ch.status]}: ${what}\n ${ch.evidence}`;
|
|
185
|
+
});
|
|
186
|
+
const open = session.findings.filter((f) => f.status === 'still-open' || f.status === 'open');
|
|
187
|
+
const head = summary.blocker
|
|
188
|
+
? `The re-check could not run: ${summary.blocker}`
|
|
189
|
+
: open.length
|
|
190
|
+
? `${open.length} finding${open.length === 1 ? ' is' : 's are'} still open. Keep working on them and call reverify_findings again; do not report them as fixed.`
|
|
191
|
+
: 'Every finding in this session is closed by an independent re-check. You may report them as fixed.';
|
|
192
|
+
return { content: [{ type: 'text', text: `Re-check ${summary.round} of session ${session.id}\n\n${head}\n\n${lines.join('\n\n')}` }], structuredContent: { session: session.id, ...summary, changes, open: open.map((f) => f.id) } };
|
|
193
|
+
}
|
|
194
|
+
if (name === 'agent_reliability') {
|
|
195
|
+
const days = Number.isFinite(args.days) ? Math.min(Math.max(1, args.days), 3650) : 90;
|
|
196
|
+
const r = reliability({ since: Date.now() - days * 86400000, agent: typeof args.agent === 'string' ? args.agent : undefined });
|
|
197
|
+
const text = r.agents.length ? r.agents.map((a) => `${a.agent}: ${describeAgent(a)}.`).join('\n') : 'No verification evidence recorded on this machine yet.';
|
|
198
|
+
return { content: [{ type: 'text', text: `Reliability over the last ${days} days, from recorded evidence (three separate measures, never blended):\n\n${text}` }], structuredContent: r };
|
|
199
|
+
}
|
|
200
|
+
return { isError: true, content: [{ type: 'text', text: `Unknown tool: ${name}` }] };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function formatForAgent(r) {
|
|
204
|
+
if (!r.results.length) {
|
|
205
|
+
return 'No checkable claims found in that summary. If you are saying tests, build, types or lint pass, say so explicitly; if you renamed something, name it in `backticks`.';
|
|
206
|
+
}
|
|
207
|
+
const mark = { verified: '✓ verified', contradicted: '✗ CONTRADICTED', review: '◇ needs review', stale: '◷ stale', unbacked: '○ unbacked' };
|
|
208
|
+
const lines = r.results.map((x) => `${mark[x.verdict]}: "${x.claim}"\n ${x.reason.replace(/`/g, '')}${x.quality ? `\n test strength: ${x.quality.rating}${x.quality.score != null ? ` (${Math.round(x.quality.score * 100)}% of planted defects caught)` : ''}. This is separate from the verdict above.` : ''}${x.verdict === 'contradicted' && x.evidence?.excerpt ? `\n Output:\n${x.evidence.excerpt.split('\n').map((l) => ' ' + l).join('\n')}` : ''}`);
|
|
209
|
+
const head = r.ok
|
|
210
|
+
? 'No claim was contradicted. You may report these as checked.'
|
|
211
|
+
: 'At least one claim is FALSE. Do not report the task as done: fix the problem and verify again, or correct your summary to say what is actually true.';
|
|
212
|
+
return `${head}\n\n${lines.join('\n\n')}`;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** What an agent needs to act on: the gap, the exact surviving defects, and what to do next. */
|
|
216
|
+
export function formatStrengthForAgent(r) {
|
|
217
|
+
const s = r.summary;
|
|
218
|
+
const head = `Test strength: ${r.rating}${s.score != null ? ` (${s.killed} of ${s.killed + s.survived} planted defects caught)` : ''}. ${r.headline?.text ?? ''}`.trim();
|
|
219
|
+
const surv = r.mutants.filter((m) => m.status === STATUS.SURVIVED).slice(0, 10);
|
|
220
|
+
const lines = surv.map((m) => `- ${m.file}:${m.line} (${m.function || 'top level'}): changing\n ${m.before.split('\n')[0].trim()}\n to\n ${m.after.split('\n')[0].trim()}\n did not fail any test.`);
|
|
221
|
+
const next = surv.length
|
|
222
|
+
? 'Add or strengthen tests so each of these changes would fail them, then call assess_test_strength again. Do not describe the tests as thorough until it reports strong.'
|
|
223
|
+
: r.blocker
|
|
224
|
+
? ''
|
|
225
|
+
: 'The tests caught every planted defect in the changed code.';
|
|
226
|
+
const tail = [
|
|
227
|
+
r.remaining ? `${r.remaining} more mutants were not run in this call; call again to continue (finished ones are cached).` : '',
|
|
228
|
+
'A mutation score measures how well tests pin down the changed code, not whether the code is correct. The working tree was not modified.',
|
|
229
|
+
].filter(Boolean);
|
|
230
|
+
return [head, lines.join('\n'), next, ...tail].filter(Boolean).join('\n\n');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const CLIENTS = [
|
|
234
|
+
[/claude/i, 'claude-code'],
|
|
235
|
+
[/codex/i, 'codex'],
|
|
236
|
+
[/cursor/i, 'cursor'],
|
|
237
|
+
[/copilot|visual studio code|vscode/i, 'copilot'],
|
|
238
|
+
[/gemini/i, 'gemini'],
|
|
239
|
+
[/windsurf|codeium/i, 'windsurf'],
|
|
240
|
+
[/roo/i, 'roo-code'],
|
|
241
|
+
[/kilo/i, 'kilo-code'],
|
|
242
|
+
[/cline/i, 'cline'],
|
|
243
|
+
[/zed/i, 'zed'],
|
|
244
|
+
[/goose/i, 'goose'],
|
|
245
|
+
];
|
|
246
|
+
function agentFromClient(name = '') {
|
|
247
|
+
for (const [re, id] of CLIENTS) if (re.test(name)) return id;
|
|
248
|
+
return name ? String(name).toLowerCase().slice(0, 40) : 'unknown';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function ledger(...recs) {
|
|
252
|
+
try {
|
|
253
|
+
const dir = (process.env.CROSSEXAM_HOME || path.join(os.homedir(), '.crossexam'));
|
|
254
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
255
|
+
if (recs.length) fs.appendFileSync(path.join(dir, 'ledger.jsonl'), recs.map((r) => JSON.stringify(r)).join('\n') + '\n');
|
|
256
|
+
} catch {
|
|
257
|
+
/* history is best effort */
|
|
258
|
+
}
|
|
259
|
+
}
|