crossexamdev 0.2.0 → 0.3.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/README.md +7 -2
- package/bin/crossexam.js +88 -4
- package/package.json +1 -1
- package/src/claims.js +138 -120
- package/src/github.js +93 -69
- package/src/mcp.js +198 -109
- package/src/mutate.js +443 -0
- package/src/report.js +194 -99
- package/src/sandbox.js +627 -0
- package/src/strength.js +628 -0
package/README.md
CHANGED
|
@@ -8,11 +8,16 @@ crossexam cross-examines what coding agents claim ("all tests pass", "every call
|
|
|
8
8
|
npx crossexamdev scan # how often have your agents been wrong?
|
|
9
9
|
npx crossexamdev verify "All tests pass." # re-check any agent's summary right now
|
|
10
10
|
npx crossexamdev init --mcp # make every agent in this repo check itself
|
|
11
|
-
npx crossexamdev mcp # MCP server with
|
|
11
|
+
npx crossexamdev mcp # MCP server with verify_claims and assess_test_strength
|
|
12
|
+
npx crossexamdev mutate # would the tests notice a bug in what the agent changed?
|
|
12
13
|
```
|
|
13
14
|
|
|
14
15
|
Node 18.17+, zero dependencies, runs entirely on your machine. Once installed, the command is also available as `crossexam`.
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
`mutate` plants small defects in the changed lines and runs your tests against each one, in a disposable copy of the repo. Tests run inside a sandbox (bubblewrap on Linux, `sandbox-exec` on macOS, or Docker). Where none is available, crossexam refuses unless you pass `--unsandboxed`. Details and the threat model: https://github.com/zackt223/crossexam/blob/master/docs/mutation-security.md
|
|
18
|
+
|
|
19
|
+
Site: https://zackt223.github.io/crossexam/
|
|
20
|
+
|
|
21
|
+
Full docs and the GitHub Action: https://github.com/zackt223/crossexam
|
|
17
22
|
|
|
18
23
|
Free and open source under the MIT license. Built by [Zack Telsem](https://zacktelsem.com).
|
package/bin/crossexam.js
CHANGED
|
@@ -4,15 +4,17 @@ import os from 'node:os';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { analyzeSession } from '../src/analyze.js';
|
|
7
|
+
import { detectWorkClaims } from '../src/claims.js';
|
|
7
8
|
import { emitActions, readPullRequest } from '../src/github.js';
|
|
8
9
|
import { globalSnippets, runInit } from '../src/init.js';
|
|
9
10
|
import { detectCommands, verifyText } from '../src/live.js';
|
|
10
11
|
import { formatForAgent, startMcpServer } from '../src/mcp.js';
|
|
11
12
|
import { discoverAider, discoverMore } from '../src/readers.js';
|
|
12
|
-
import { buildReport, c, printReport } from '../src/report.js';
|
|
13
|
+
import { buildReport, c, printReport, printStrength } from '../src/report.js';
|
|
14
|
+
import { assessStrength, ledgerRecord, qualityOf, strengthHistory, toCsv, withoutSource } from '../src/strength.js';
|
|
13
15
|
import { AGENTS, defaultSources, findTranscripts, readSession } from '../src/transcripts.js';
|
|
14
16
|
|
|
15
|
-
const VERSION = '0.
|
|
17
|
+
const VERSION = '0.3.0';
|
|
16
18
|
const HELP = `
|
|
17
19
|
${c.bold('crossexam')} — cross-examine what your coding agents claim
|
|
18
20
|
|
|
@@ -22,6 +24,10 @@ const HELP = `
|
|
|
22
24
|
crossexam init [--mcp] add the rule to AGENTS.md (and MCP configs) so agents check themselves
|
|
23
25
|
crossexam verify --github in CI: check the claims in an agent's pull request description
|
|
24
26
|
|
|
27
|
+
${c.bold('Test strength')}
|
|
28
|
+
crossexam mutate plant small defects in the changed code and see if the tests notice
|
|
29
|
+
crossexam verify --mutate verify claims, then grade how strong the tests behind them are
|
|
30
|
+
|
|
25
31
|
${c.bold('History')}
|
|
26
32
|
crossexam scan check local transcripts: Claude Code, Codex, Gemini CLI, Cline,
|
|
27
33
|
Roo Code, Kilo Code, Aider and the open format
|
|
@@ -35,6 +41,23 @@ const HELP = `
|
|
|
35
41
|
--json machine-readable result
|
|
36
42
|
--fail-on <contradicted|none> exit 1 when a claim is contradicted (default: contradicted)
|
|
37
43
|
--timeout <seconds> per command (default 300)
|
|
44
|
+
--mutate also assess test strength when tests or finished work are claimed
|
|
45
|
+
|
|
46
|
+
${c.bold('mutate')}
|
|
47
|
+
--base <ref> compare against this ref (default: uncommitted changes, else HEAD~1)
|
|
48
|
+
--files <a.ts,b.js> mutate these files, every line, instead of the diff
|
|
49
|
+
--max <n> mutants to run this time (default 25; finished ones are cached)
|
|
50
|
+
--budget <seconds> stop starting new mutants after this long (default 300)
|
|
51
|
+
--isolation <auto|bwrap|sandbox-exec|docker>
|
|
52
|
+
sandbox for the test runs (default auto: the first one that works here;
|
|
53
|
+
refuses to run if none does)
|
|
54
|
+
--unsandboxed run without a sandbox, with your own permissions (code you trust only)
|
|
55
|
+
--test-command <cmd> the oracle (default: the repo's test command)
|
|
56
|
+
--no-cache ignore cached results
|
|
57
|
+
--json [out.json] / --csv <f> write the full report (secret-looking values are redacted)
|
|
58
|
+
--no-source leave code lines out of the report
|
|
59
|
+
--agent <name> record which agent made the change, for history
|
|
60
|
+
--fail-under <0-1> exit 1 when the mutation score is below this
|
|
38
61
|
|
|
39
62
|
${c.bold('scan')}
|
|
40
63
|
--since <30d|12h|all> how far back to look (default 30d)
|
|
@@ -52,7 +75,7 @@ const HELP = `
|
|
|
52
75
|
--dry-run print the change, write nothing
|
|
53
76
|
`;
|
|
54
77
|
|
|
55
|
-
const VALUED = new Set(['since', 'agent', 'repo', 'file', 'json', 'limit', 'path', 'cwd', 'fail-on', 'timeout']);
|
|
78
|
+
const VALUED = new Set(['since', 'agent', 'repo', 'file', 'json', 'limit', 'path', 'cwd', 'fail-on', 'timeout', 'base', 'files', 'max', 'budget', 'isolation', 'test-command', 'csv', 'fail-under']);
|
|
56
79
|
const args = process.argv.slice(2);
|
|
57
80
|
const cmd = args[0] && !args[0].startsWith('-') ? args.shift() : 'scan';
|
|
58
81
|
const flag = (name) => args.includes(`--${name}`);
|
|
@@ -70,6 +93,7 @@ try {
|
|
|
70
93
|
else if (flag('version') || cmd === 'version') console.log(VERSION);
|
|
71
94
|
else if (cmd === 'scan') await scan();
|
|
72
95
|
else if (cmd === 'verify') await verify();
|
|
96
|
+
else if (cmd === 'mutate') await mutate();
|
|
73
97
|
else if (cmd === 'mcp') startMcpServer({ version: VERSION, defaultCwd: path.resolve(String(opt('cwd', process.cwd()))) });
|
|
74
98
|
else if (cmd === 'init') init();
|
|
75
99
|
else if (cmd === 'hook') await hook();
|
|
@@ -125,6 +149,9 @@ async function scan() {
|
|
|
125
149
|
}
|
|
126
150
|
|
|
127
151
|
const report = buildReport(claims, { sessions, turns, ranCheckTurns, contradictedTurns, agents: [...agents], since: since ? new Date(since).toISOString() : null });
|
|
152
|
+
// Test strength from earlier `mutate` / `verify --mutate` / MCP runs: a separate dimension.
|
|
153
|
+
const mutation = strengthHistory({ since, agent: typeof onlyAgent === 'string' ? onlyAgent : undefined, repo: typeof onlyRepo === 'string' ? onlyRepo : undefined });
|
|
154
|
+
if (mutation) report.mutation = mutation;
|
|
128
155
|
const json = opt('json');
|
|
129
156
|
if (json) {
|
|
130
157
|
const out = typeof json === 'string' ? json : 'crossexam-report.json';
|
|
@@ -158,17 +185,74 @@ async function verify() {
|
|
|
158
185
|
onRun: (command) => !json && process.stderr.write(c.dim(` running ${command}…\n`)),
|
|
159
186
|
});
|
|
160
187
|
|
|
188
|
+
if (flag('mutate') && wantsStrength(text, r)) {
|
|
189
|
+
if (!json) process.stderr.write(c.dim(' assessing test strength (planting defects in an isolated copy)…\n'));
|
|
190
|
+
const strength = await assessStrength({ cwd, ...mutateOpts(), onProgress: json ? undefined : progress });
|
|
191
|
+
attachStrength(r, strength);
|
|
192
|
+
ledger([ledgerRecord(strength, { agent: pr?.agent || String(opt('agent', 'unknown')), claim: r.results.find((x) => x.kind === 'tests')?.claim ?? null, source: github ? 'github' : 'verify' })]);
|
|
193
|
+
}
|
|
194
|
+
|
|
161
195
|
if (json) process.stdout.write(JSON.stringify({ ...r, pr }, null, 2) + '\n');
|
|
162
196
|
else if (github) emitActions(pr, r);
|
|
163
197
|
else {
|
|
164
198
|
console.log();
|
|
165
199
|
console.log(formatForAgent(r).replace(/^/gm, ' '));
|
|
200
|
+
if (r.strength) printStrength(r.strength, { limit: 4 });
|
|
166
201
|
if (!r.results.length && Object.keys(r.commands).length) console.log(c.dim(`\n Checks available here: ${Object.entries(r.commands).map(([k, v]) => `${k} (${v.command})`).join(', ')}`));
|
|
167
202
|
console.log();
|
|
168
203
|
}
|
|
169
204
|
if (opt('fail-on', 'contradicted') !== 'none' && !r.ok) process.exitCode = 1;
|
|
170
205
|
}
|
|
171
206
|
|
|
207
|
+
async function mutate() {
|
|
208
|
+
const cwd = path.resolve(String(opt('cwd', process.cwd())));
|
|
209
|
+
const json = opt('json');
|
|
210
|
+
const toStdout = json === true;
|
|
211
|
+
const full = await assessStrength({ cwd, ...mutateOpts(), onProgress: toStdout ? undefined : progress });
|
|
212
|
+
const r = flag('no-source') ? withoutSource(full) : full;
|
|
213
|
+
ledger([ledgerRecord(r, { agent: String(opt('agent', 'unknown')), source: 'mutate' })]);
|
|
214
|
+
const csv = opt('csv');
|
|
215
|
+
if (typeof csv === 'string') fs.writeFileSync(csv, toCsv(r));
|
|
216
|
+
if (toStdout) process.stdout.write(JSON.stringify(r, null, 2) + '\n');
|
|
217
|
+
else {
|
|
218
|
+
if (typeof json === 'string') fs.writeFileSync(json, JSON.stringify(r, null, 2));
|
|
219
|
+
printStrength(r, { limit: Number(opt('limit', 8)) });
|
|
220
|
+
if (typeof json === 'string') console.log(` ${c.dim('Report written to')} ${path.resolve(json)}\n`);
|
|
221
|
+
}
|
|
222
|
+
const under = opt('fail-under');
|
|
223
|
+
if (under !== undefined && r.summary.score != null && r.summary.score < Number(under)) process.exitCode = 1;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function mutateOpts() {
|
|
227
|
+
const files = opts('files').flatMap((f) => f.split(',')).filter(Boolean);
|
|
228
|
+
const str = (k) => (typeof opt(k) === 'string' ? String(opt(k)) : undefined);
|
|
229
|
+
const num = (k) => (typeof opt(k) === 'string' ? Number(opt(k)) : undefined);
|
|
230
|
+
const unsandboxed = flag('unsandboxed');
|
|
231
|
+
return { base: str('base'), files: files.length ? files : undefined, max: num('max'), budgetSeconds: num('budget'), isolation: str('isolation') || (unsandboxed ? 'none' : undefined), allowUnsandboxed: unsandboxed, testCommand: str('test-command'), cache: !flag('no-cache') };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function progress(e) {
|
|
235
|
+
if (!process.stderr.isTTY) return;
|
|
236
|
+
if (e.phase === 'copy') process.stderr.write(c.dim(` copying the repo to a temporary folder; tests will run ${e.isolation?.sandboxed ? 'sandboxed (' + e.isolation.method + ')' : 'NOT SANDBOXED'}…\n`));
|
|
237
|
+
else if (e.phase === 'baseline') process.stderr.write(c.dim(' running the unmutated test suite (baseline)…\n'));
|
|
238
|
+
else if (e.phase === 'mutant') {
|
|
239
|
+
const st = { MUTATION_KILLED: c.green('killed '), MUTATION_SURVIVED: c.red('survived '), MUTATION_INVALID: c.gray('invalid '), MUTATION_UNRESOLVED: c.yellow('unresolved') }[e.status];
|
|
240
|
+
process.stderr.write(c.dim(` [${String(e.i).padStart(2)}/${e.total}] `) + st + c.dim(` ${e.mutant.file}:${e.mutant.line} ${e.mutant.operator}${e.cached ? ' (cached)' : ''}\n`));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** Only grade test strength when someone claimed tests pass or that work was done. */
|
|
245
|
+
function wantsStrength(text, r) {
|
|
246
|
+
return r.results.some((x) => x.kind === 'tests') || detectWorkClaims(text).length > 0;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Quality rides alongside the verdict; it never changes it. */
|
|
250
|
+
function attachStrength(r, strength) {
|
|
251
|
+
r.strength = strength;
|
|
252
|
+
const q = qualityOf(strength);
|
|
253
|
+
for (const x of r.results) if (x.kind === 'tests') x.quality = q;
|
|
254
|
+
}
|
|
255
|
+
|
|
172
256
|
function init() {
|
|
173
257
|
const cwd = path.resolve(String(opt('cwd', process.cwd())));
|
|
174
258
|
const { cli, server } = selfCommands();
|
|
@@ -266,7 +350,7 @@ function parseSince(v) {
|
|
|
266
350
|
|
|
267
351
|
function ledger(claims) {
|
|
268
352
|
try {
|
|
269
|
-
const dir = path.join(os.homedir(), '.crossexam');
|
|
353
|
+
const dir = (process.env.CROSSEXAM_HOME || path.join(os.homedir(), '.crossexam'));
|
|
270
354
|
fs.mkdirSync(dir, { recursive: true });
|
|
271
355
|
fs.appendFileSync(path.join(dir, 'ledger.jsonl'), claims.map((x) => JSON.stringify(x)).join('\n') + '\n');
|
|
272
356
|
} catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crossexamdev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Cross-examine what any coding agent claims: verify CLI, MCP server, GitHub Action and transcript history for Claude Code, Codex, Gemini CLI, Cline, Aider and more.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/claims.js
CHANGED
|
@@ -1,120 +1,138 @@
|
|
|
1
|
-
// Claim detection: find sentences where an agent asserts something is done
|
|
2
|
-
// and classify what kind of claim it is.
|
|
3
|
-
|
|
4
|
-
/** @typedef {'tests'|'build'|'types'|'lint'|'refactor'|'migration'|'deps'|'security'} ClaimKind */
|
|
5
|
-
|
|
6
|
-
const KINDS = /** @type {const} */ ({
|
|
7
|
-
tests: [
|
|
8
|
-
/\b(?:all\s+)?(?:the\s+)?(?:\d+\s+)?(?:unit\s+|e2e\s+|integration\s+|existing\s+|new\s+)?tests?\s+(?:now\s+|still\s+|all\s+|are\s+all\s+)?(?:pass(?:es|ed|ing)?|are\s+(?:passing|green)|(?:is|are)\s+green|succeed(?:s|ed)?)\b/i,
|
|
9
|
-
/\btest\s+suite\s+(?:now\s+)?(?:passes|passed|is\s+green|is\s+passing)\b/i,
|
|
10
|
-
/\b\d+\s*(?:\/\s*\d+\s*)?(?:tests?\s+)?passing\b/i,
|
|
11
|
-
/\b(?:all|every)\s+(?:\d+\s+)?(?:specs?|test\s+cases?)\s+pass/i,
|
|
12
|
-
],
|
|
13
|
-
build: [
|
|
14
|
-
/\b(?:the\s+)?build\s+(?:now\s+)?(?:succeeds|succeeded|passes|passed|is\s+green|is\s+clean|works)\b/i,
|
|
15
|
-
/\bbuilds?\s+(?:cleanly|successfully|without\s+errors)\b/i,
|
|
16
|
-
/\bcompiles\s+(?:cleanly|successfully|without\s+(?:any\s+)?errors|fine)\b/i,
|
|
17
|
-
],
|
|
18
|
-
types: [
|
|
19
|
-
/\b(?:typecheck(?:ing)?|type[- ]check(?:ing)?|tsc)\s+(?:now\s+)?(?:passes|passed|is\s+clean|comes\s+back\s+clean|clean)\b/i,
|
|
20
|
-
/\bno\s+(?:remaining\s+)?(?:type|typescript|ts)\s+errors\b/i,
|
|
21
|
-
],
|
|
22
|
-
lint: [
|
|
23
|
-
/\blint(?:er|ing)?\s+(?:now\s+)?(?:passes|passed|is\s+clean|comes\s+back\s+clean|clean)\b/i,
|
|
24
|
-
/\bno\s+(?:remaining\s+)?lint(?:ing)?\s+(?:errors|warnings|issues)\b/i,
|
|
25
|
-
],
|
|
26
|
-
refactor: [
|
|
27
|
-
/\b(?:all|every)\s+(?:the\s+)?(?:remaining\s+)?(?:callers?|call\s*sites?|usages?|references?|imports?|occurrences?|consumers?|uses)\s+(?:\S+\s+){0,4}?(?:have\s+been\s+|has\s+been\s+|were\s+|are\s+(?:now\s+)?)?(?:updated|migrated|renamed|changed|replaced|switched|moved|fixed)\b/i,
|
|
28
|
-
/\brenamed\s+`?[\w.$]+`?\s+(?:to|→|->)\s+`?[\w.$]+`?\s+(?:everywhere|across|throughout)/i,
|
|
29
|
-
],
|
|
30
|
-
migration: [
|
|
31
|
-
/\bmigrations?\s+(?:\S+\s+){0,3}?(?:ran|applied|succeeded|completed|went\s+through|(?:has|have)\s+been\s+(?:applied|run))\b/i,
|
|
32
|
-
/\b(?:applied|ran)\s+(?:the\s+)?(?:\S+\s+)?migrations?\s+(?:successfully|cleanly)\b/i,
|
|
33
|
-
],
|
|
34
|
-
deps: [
|
|
35
|
-
/\b(?:upgraded|bumped|updated|pinned)\s+`?(@?[\w./-]+)`?\s+(?:from\s+`?v?[\w.^~-]+`?\s+)?to\s+`?v?\d[\w.-]*`?/i,
|
|
36
|
-
],
|
|
37
|
-
security: [
|
|
38
|
-
/\b(?:fixed|patched|closed|resolved|mitigated|plugged)\s+(?:the\s+)?(?:\S+\s+){0,3}?(?:vulnerability|vuln|xss|injection|cve-\d{4}-\d+|ssrf|csrf|rce|security\s+(?:issue|bug|hole|flaw))/i,
|
|
39
|
-
],
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// A sentence that talks about a check rather than asserting its result.
|
|
43
|
-
const HEDGE =
|
|
44
|
-
/\b(?:make\s+sure|ensure|should|to\s+verify|to\s+confirm|check\s+(?:that|whether|if)|until|once|if|unless|whether|will|would|could|might|need(?:s)?\s+to|let'?s|let\s+me|i'?ll|want\s+to|try\s+to|expect(?:ed)?|hopefully|before)\b/i;
|
|
45
|
-
const NEGATION =
|
|
46
|
-
/\b(?:not|n't|never|no\s+longer|fail(?:s|ed|ing)?|broken|still\s+(?:fail|broken|red)|couldn'?t|unable|can'?t|without\s+running|didn'?t\s+run|haven'?t\s+run)\b/i;
|
|
47
|
-
|
|
48
|
-
/** Split assistant prose into sentence-ish units without breaking `code`. */
|
|
49
|
-
export function sentences(text) {
|
|
50
|
-
const clean = text
|
|
51
|
-
.replace(/```[\s\S]*?```/g, ' ')
|
|
52
|
-
.replace(/\r/g, '');
|
|
53
|
-
const out = [];
|
|
54
|
-
for (const line of clean.split(/\n+/)) {
|
|
55
|
-
const parts = line.split(/(?<=[.!?])\s+(?=[A-Z`*✅✓])/);
|
|
56
|
-
for (const p of parts) {
|
|
57
|
-
const s = p.replace(/^[\s>*\-•#|]+/, '').replace(/\*\*/g, '').trim();
|
|
58
|
-
if (s.length >= 8) out.push(s);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return out;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Find claims in a piece of assistant text.
|
|
66
|
-
* @returns {{kind: ClaimKind, sentence: string, subject?: {from?: string, to?: string, pkg?: string, version?: string}}[]}
|
|
67
|
-
*/
|
|
68
|
-
export function detectClaims(text) {
|
|
69
|
-
const found = [];
|
|
70
|
-
for (const s of sentences(text)) {
|
|
71
|
-
for (const [kind, patterns] of Object.entries(KINDS)) {
|
|
72
|
-
const hit = patterns.map((re) => s.match(re)).find(Boolean);
|
|
73
|
-
if (!hit) continue;
|
|
74
|
-
// Look only at the words leading into the claim for hedges and negations,
|
|
75
|
-
// so "I fixed X, and all tests pass" counts but "make sure tests pass" doesn't.
|
|
76
|
-
const lead = s.slice(Math.max(0, hit.index - 60), hit.index);
|
|
77
|
-
const own = hit[0];
|
|
78
|
-
if (HEDGE.test(lead) || HEDGE.test(own)) continue;
|
|
79
|
-
if (NEGATION.test(lead.slice(-30)) || NEGATION.test(own)) continue;
|
|
80
|
-
if (/\?\s*$/.test(s)) continue;
|
|
81
|
-
// Quoting a claim ("the agent said “all tests pass”") isn't making one.
|
|
82
|
-
if (insideQuotes(s, hit.index)) continue;
|
|
83
|
-
found.push({ kind: /** @type {ClaimKind} */ (kind), sentence: s.slice(0, 280), subject: subjectOf(kind, s) });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return found;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function insideQuotes(s, at) {
|
|
90
|
-
const before = s.slice(0, at);
|
|
91
|
-
const straight = (before.match(/"/g) || []).length % 2 === 1;
|
|
92
|
-
const curly = before.lastIndexOf('“') > before.lastIndexOf('”');
|
|
93
|
-
return straight || curly;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function subjectOf(kind, s) {
|
|
97
|
-
if (kind === 'refactor') {
|
|
98
|
-
const r = s.match(/\brenamed\s+`([\w.$]+)`\s+(?:to|→|->)\s+`([\w.$]+)`/i) || s.match(/`([\w.$]+)`\s*(?:→|->)\s*`([\w.$]+)`/);
|
|
99
|
-
if (r) return { from: r[1].split('.').pop(), to: r[2].split('.').pop() };
|
|
100
|
-
const tick = s.match(/`([A-Za-z_$][\w$]{2,})`/);
|
|
101
|
-
return tick ? { from: tick[1] } : undefined;
|
|
102
|
-
}
|
|
103
|
-
if (kind === 'deps') {
|
|
104
|
-
const d = s.match(/\b(?:upgraded|bumped|updated|pinned)\s+`?(@?[\w./-]+)`?\s+(?:from\s+`?v?[\w.^~-]+`?\s+)?to\s+`?v?(\d+(?:\.\d+)*(?:-[\w.]+)?)`?/i);
|
|
105
|
-
return d ? { pkg: d[1], version: d[2] } : undefined;
|
|
106
|
-
}
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
1
|
+
// Claim detection: find sentences where an agent asserts something is done
|
|
2
|
+
// and classify what kind of claim it is.
|
|
3
|
+
|
|
4
|
+
/** @typedef {'tests'|'build'|'types'|'lint'|'refactor'|'migration'|'deps'|'security'} ClaimKind */
|
|
5
|
+
|
|
6
|
+
const KINDS = /** @type {const} */ ({
|
|
7
|
+
tests: [
|
|
8
|
+
/\b(?:all\s+)?(?:the\s+)?(?:\d+\s+)?(?:unit\s+|e2e\s+|integration\s+|existing\s+|new\s+)?tests?\s+(?:now\s+|still\s+|all\s+|are\s+all\s+)?(?:pass(?:es|ed|ing)?|are\s+(?:passing|green)|(?:is|are)\s+green|succeed(?:s|ed)?)\b/i,
|
|
9
|
+
/\btest\s+suite\s+(?:now\s+)?(?:passes|passed|is\s+green|is\s+passing)\b/i,
|
|
10
|
+
/\b\d+\s*(?:\/\s*\d+\s*)?(?:tests?\s+)?passing\b/i,
|
|
11
|
+
/\b(?:all|every)\s+(?:\d+\s+)?(?:specs?|test\s+cases?)\s+pass/i,
|
|
12
|
+
],
|
|
13
|
+
build: [
|
|
14
|
+
/\b(?:the\s+)?build\s+(?:now\s+)?(?:succeeds|succeeded|passes|passed|is\s+green|is\s+clean|works)\b/i,
|
|
15
|
+
/\bbuilds?\s+(?:cleanly|successfully|without\s+errors)\b/i,
|
|
16
|
+
/\bcompiles\s+(?:cleanly|successfully|without\s+(?:any\s+)?errors|fine)\b/i,
|
|
17
|
+
],
|
|
18
|
+
types: [
|
|
19
|
+
/\b(?:typecheck(?:ing)?|type[- ]check(?:ing)?|tsc)\s+(?:now\s+)?(?:passes|passed|is\s+clean|comes\s+back\s+clean|clean)\b/i,
|
|
20
|
+
/\bno\s+(?:remaining\s+)?(?:type|typescript|ts)\s+errors\b/i,
|
|
21
|
+
],
|
|
22
|
+
lint: [
|
|
23
|
+
/\blint(?:er|ing)?\s+(?:now\s+)?(?:passes|passed|is\s+clean|comes\s+back\s+clean|clean)\b/i,
|
|
24
|
+
/\bno\s+(?:remaining\s+)?lint(?:ing)?\s+(?:errors|warnings|issues)\b/i,
|
|
25
|
+
],
|
|
26
|
+
refactor: [
|
|
27
|
+
/\b(?:all|every)\s+(?:the\s+)?(?:remaining\s+)?(?:callers?|call\s*sites?|usages?|references?|imports?|occurrences?|consumers?|uses)\s+(?:\S+\s+){0,4}?(?:have\s+been\s+|has\s+been\s+|were\s+|are\s+(?:now\s+)?)?(?:updated|migrated|renamed|changed|replaced|switched|moved|fixed)\b/i,
|
|
28
|
+
/\brenamed\s+`?[\w.$]+`?\s+(?:to|→|->)\s+`?[\w.$]+`?\s+(?:everywhere|across|throughout)/i,
|
|
29
|
+
],
|
|
30
|
+
migration: [
|
|
31
|
+
/\bmigrations?\s+(?:\S+\s+){0,3}?(?:ran|applied|succeeded|completed|went\s+through|(?:has|have)\s+been\s+(?:applied|run))\b/i,
|
|
32
|
+
/\b(?:applied|ran)\s+(?:the\s+)?(?:\S+\s+)?migrations?\s+(?:successfully|cleanly)\b/i,
|
|
33
|
+
],
|
|
34
|
+
deps: [
|
|
35
|
+
/\b(?:upgraded|bumped|updated|pinned)\s+`?(@?[\w./-]+)`?\s+(?:from\s+`?v?[\w.^~-]+`?\s+)?to\s+`?v?\d[\w.-]*`?/i,
|
|
36
|
+
],
|
|
37
|
+
security: [
|
|
38
|
+
/\b(?:fixed|patched|closed|resolved|mitigated|plugged)\s+(?:the\s+)?(?:\S+\s+){0,3}?(?:vulnerability|vuln|xss|injection|cve-\d{4}-\d+|ssrf|csrf|rce|security\s+(?:issue|bug|hole|flaw))/i,
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// A sentence that talks about a check rather than asserting its result.
|
|
43
|
+
const HEDGE =
|
|
44
|
+
/\b(?:make\s+sure|ensure|should|to\s+verify|to\s+confirm|check\s+(?:that|whether|if)|until|once|if|unless|whether|will|would|could|might|need(?:s)?\s+to|let'?s|let\s+me|i'?ll|want\s+to|try\s+to|expect(?:ed)?|hopefully|before)\b/i;
|
|
45
|
+
const NEGATION =
|
|
46
|
+
/\b(?:not|n't|never|no\s+longer|fail(?:s|ed|ing)?|broken|still\s+(?:fail|broken|red)|couldn'?t|unable|can'?t|without\s+running|didn'?t\s+run|haven'?t\s+run)\b/i;
|
|
47
|
+
|
|
48
|
+
/** Split assistant prose into sentence-ish units without breaking `code`. */
|
|
49
|
+
export function sentences(text) {
|
|
50
|
+
const clean = text
|
|
51
|
+
.replace(/```[\s\S]*?```/g, ' ')
|
|
52
|
+
.replace(/\r/g, '');
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const line of clean.split(/\n+/)) {
|
|
55
|
+
const parts = line.split(/(?<=[.!?])\s+(?=[A-Z`*✅✓])/);
|
|
56
|
+
for (const p of parts) {
|
|
57
|
+
const s = p.replace(/^[\s>*\-•#|]+/, '').replace(/\*\*/g, '').trim();
|
|
58
|
+
if (s.length >= 8) out.push(s);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Find claims in a piece of assistant text.
|
|
66
|
+
* @returns {{kind: ClaimKind, sentence: string, subject?: {from?: string, to?: string, pkg?: string, version?: string}}[]}
|
|
67
|
+
*/
|
|
68
|
+
export function detectClaims(text) {
|
|
69
|
+
const found = [];
|
|
70
|
+
for (const s of sentences(text)) {
|
|
71
|
+
for (const [kind, patterns] of Object.entries(KINDS)) {
|
|
72
|
+
const hit = patterns.map((re) => s.match(re)).find(Boolean);
|
|
73
|
+
if (!hit) continue;
|
|
74
|
+
// Look only at the words leading into the claim for hedges and negations,
|
|
75
|
+
// so "I fixed X, and all tests pass" counts but "make sure tests pass" doesn't.
|
|
76
|
+
const lead = s.slice(Math.max(0, hit.index - 60), hit.index);
|
|
77
|
+
const own = hit[0];
|
|
78
|
+
if (HEDGE.test(lead) || HEDGE.test(own)) continue;
|
|
79
|
+
if (NEGATION.test(lead.slice(-30)) || NEGATION.test(own)) continue;
|
|
80
|
+
if (/\?\s*$/.test(s)) continue;
|
|
81
|
+
// Quoting a claim ("the agent said “all tests pass”") isn't making one.
|
|
82
|
+
if (insideQuotes(s, hit.index)) continue;
|
|
83
|
+
found.push({ kind: /** @type {ClaimKind} */ (kind), sentence: s.slice(0, 280), subject: subjectOf(kind, s) });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return found;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function insideQuotes(s, at) {
|
|
90
|
+
const before = s.slice(0, at);
|
|
91
|
+
const straight = (before.match(/"/g) || []).length % 2 === 1;
|
|
92
|
+
const curly = before.lastIndexOf('“') > before.lastIndexOf('”');
|
|
93
|
+
return straight || curly;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function subjectOf(kind, s) {
|
|
97
|
+
if (kind === 'refactor') {
|
|
98
|
+
const r = s.match(/\brenamed\s+`([\w.$]+)`\s+(?:to|→|->)\s+`([\w.$]+)`/i) || s.match(/`([\w.$]+)`\s*(?:→|->)\s*`([\w.$]+)`/);
|
|
99
|
+
if (r) return { from: r[1].split('.').pop(), to: r[2].split('.').pop() };
|
|
100
|
+
const tick = s.match(/`([A-Za-z_$][\w$]{2,})`/);
|
|
101
|
+
return tick ? { from: tick[1] } : undefined;
|
|
102
|
+
}
|
|
103
|
+
if (kind === 'deps') {
|
|
104
|
+
const d = s.match(/\b(?:upgraded|bumped|updated|pinned)\s+`?(@?[\w./-]+)`?\s+(?:from\s+`?v?[\w.^~-]+`?\s+)?to\s+`?v?(\d+(?:\.\d+)*(?:-[\w.]+)?)`?/i);
|
|
105
|
+
return d ? { pkg: d[1], version: d[2] } : undefined;
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// "I implemented X", "fixed the bug in Y", "added support for Z". These aren't
|
|
111
|
+
// factual claims crossexam can verify, so they never get a verdict and never
|
|
112
|
+
// count in reliability stats. They only trigger a test-strength assessment.
|
|
113
|
+
const WORK = /\b(?:implemented|fixed|added|built|wrote|rewrote|refactored|resolved|handled|patched|corrected|introduced|completed)\b/i;
|
|
114
|
+
|
|
115
|
+
/** Sentences asserting that work was done (implemented / fixed / added). */
|
|
116
|
+
export function detectWorkClaims(text) {
|
|
117
|
+
const found = [];
|
|
118
|
+
for (const s of sentences(text)) {
|
|
119
|
+
const hit = s.match(WORK);
|
|
120
|
+
if (!hit) continue;
|
|
121
|
+
const lead = s.slice(Math.max(0, hit.index - 60), hit.index);
|
|
122
|
+
if (HEDGE.test(lead) || NEGATION.test(lead.slice(-30)) || /\?\s*$/.test(s) || insideQuotes(s, hit.index)) continue;
|
|
123
|
+
found.push({ sentence: s.slice(0, 280), verb: hit[0].toLowerCase() });
|
|
124
|
+
}
|
|
125
|
+
return found;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Rough task type from the user's prompt, used to bucket reliability history. */
|
|
129
|
+
export function taskTypeOf(prompt = '') {
|
|
130
|
+
const p = prompt.toLowerCase();
|
|
131
|
+
if (/\bmigrat/.test(p)) return 'migration';
|
|
132
|
+
if (/\b(refactor|rename|extract|clean ?up|restructure|move\s+\w+\s+to)\b/.test(p)) return 'refactor';
|
|
133
|
+
if (/\b(upgrade|bump|dependenc|update\s+\w+\s+to\s+v?\d)/.test(p)) return 'dependency';
|
|
134
|
+
if (/\b(cve|vulnerab|xss|injection|security|auth bypass)/.test(p)) return 'security';
|
|
135
|
+
if (/\b(test|spec|coverage)\b/.test(p)) return 'tests';
|
|
136
|
+
if (/\b(fix|bug|broken|error|crash|fails?|issue)\b/.test(p)) return 'bugfix';
|
|
137
|
+
return 'feature';
|
|
138
|
+
}
|
package/src/github.js
CHANGED
|
@@ -1,69 +1,93 @@
|
|
|
1
|
-
// Pull-request mode: every cloud agent that opens a PR (Copilot coding agent,
|
|
2
|
-
// Codex, Devin, Jules, Cursor background agents, Claude) writes its claims in
|
|
3
|
-
// the PR description. In CI the branch is checked out, so verify them there.
|
|
4
|
-
|
|
5
|
-
import crypto from 'node:crypto';
|
|
6
|
-
import fs from 'node:fs';
|
|
7
|
-
|
|
8
|
-
const BOTS = [
|
|
9
|
-
[/^copilot(-swe-agent)?(\[bot\])?$/i, 'copilot'],
|
|
10
|
-
[/^devin-ai-integration\[bot\]$/i, 'devin'],
|
|
11
|
-
[/^chatgpt-codex-connector\[bot\]$|codex/i, 'codex'],
|
|
12
|
-
[/^google-labs-jules\[bot\]$|jules/i, 'jules'],
|
|
13
|
-
[/^cursor(-agent)?\[bot\]$|^cursor$/i, 'cursor'],
|
|
14
|
-
[/^claude(\[bot\])?$|anthropic/i, 'claude-code'],
|
|
15
|
-
[/^sweep-ai\[bot\]$/i, 'sweep'],
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
/** Read the PR from the Actions event payload. */
|
|
19
|
-
export function readPullRequest(eventPath = process.env.GITHUB_EVENT_PATH) {
|
|
20
|
-
if (!eventPath || !fs.existsSync(eventPath)) return null;
|
|
21
|
-
const ev = JSON.parse(fs.readFileSync(eventPath, 'utf8'));
|
|
22
|
-
const pr = ev.pull_request;
|
|
23
|
-
if (!pr) return null;
|
|
24
|
-
return { number: pr.number, title: pr.title || '', body: pr.body || '', author: pr.user?.login || '', agent: agentOf(pr.user?.login || '', pr.body || '') };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function agentOf(login, body = '') {
|
|
28
|
-
for (const [re, name] of BOTS) if (re.test(login)) return name;
|
|
29
|
-
if (/Generated with \[?Claude Code/i.test(body)) return 'claude-code';
|
|
30
|
-
if (/codex/i.test(body) && /openai/i.test(body)) return 'codex';
|
|
31
|
-
return 'unknown';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const ICON = { verified: '✅', contradicted: '❌', review: '🔎', stale: '⏱️', unbacked: '⚪' };
|
|
35
|
-
|
|
36
|
-
export function markdownSummary(pr, r) {
|
|
37
|
-
const head = `### crossexam · ${r.ok ? 'claims hold up' : 'false claims in this PR'}`;
|
|
38
|
-
const who = pr ? `PR #${pr.number}${pr.agent !== 'unknown' ? ` by **${pr.agent}**` : pr.author ? ` by @${pr.author}` : ''}` : '';
|
|
39
|
-
if (!r.results.length) return `${head}\n\n${who}\n\nNo checkable completion claims in the description.\n`;
|
|
40
|
-
const rows = r.results.map((x) => `| ${ICON[x.verdict]} ${x.verdict} | ${cell(x.claim)} | ${cell(x.reason)} |`);
|
|
41
|
-
const details = r.results
|
|
42
|
-
.filter((x) => x.verdict === 'contradicted' && x.evidence?.excerpt)
|
|
43
|
-
.map((x) => `<details><summary><code>${escapeHtml(x.evidence.command)}</code></summary>\n\n\`\`\`\n${x.evidence.excerpt}\n\`\`\`\n</details>`);
|
|
44
|
-
return `${head}\n\n${who}\n\n| Verdict | Claim | Why |\n|---|---|---|\n${rows.join('\n')}\n\n${details.join('\n\n')}\n`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
1
|
+
// Pull-request mode: every cloud agent that opens a PR (Copilot coding agent,
|
|
2
|
+
// Codex, Devin, Jules, Cursor background agents, Claude) writes its claims in
|
|
3
|
+
// the PR description. In CI the branch is checked out, so verify them there.
|
|
4
|
+
|
|
5
|
+
import crypto from 'node:crypto';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
|
|
8
|
+
const BOTS = [
|
|
9
|
+
[/^copilot(-swe-agent)?(\[bot\])?$/i, 'copilot'],
|
|
10
|
+
[/^devin-ai-integration\[bot\]$/i, 'devin'],
|
|
11
|
+
[/^chatgpt-codex-connector\[bot\]$|codex/i, 'codex'],
|
|
12
|
+
[/^google-labs-jules\[bot\]$|jules/i, 'jules'],
|
|
13
|
+
[/^cursor(-agent)?\[bot\]$|^cursor$/i, 'cursor'],
|
|
14
|
+
[/^claude(\[bot\])?$|anthropic/i, 'claude-code'],
|
|
15
|
+
[/^sweep-ai\[bot\]$/i, 'sweep'],
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/** Read the PR from the Actions event payload. */
|
|
19
|
+
export function readPullRequest(eventPath = process.env.GITHUB_EVENT_PATH) {
|
|
20
|
+
if (!eventPath || !fs.existsSync(eventPath)) return null;
|
|
21
|
+
const ev = JSON.parse(fs.readFileSync(eventPath, 'utf8'));
|
|
22
|
+
const pr = ev.pull_request;
|
|
23
|
+
if (!pr) return null;
|
|
24
|
+
return { number: pr.number, title: pr.title || '', body: pr.body || '', author: pr.user?.login || '', agent: agentOf(pr.user?.login || '', pr.body || '') };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function agentOf(login, body = '') {
|
|
28
|
+
for (const [re, name] of BOTS) if (re.test(login)) return name;
|
|
29
|
+
if (/Generated with \[?Claude Code/i.test(body)) return 'claude-code';
|
|
30
|
+
if (/codex/i.test(body) && /openai/i.test(body)) return 'codex';
|
|
31
|
+
return 'unknown';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const ICON = { verified: '✅', contradicted: '❌', review: '🔎', stale: '⏱️', unbacked: '⚪' };
|
|
35
|
+
|
|
36
|
+
export function markdownSummary(pr, r) {
|
|
37
|
+
const head = `### crossexam · ${r.ok ? 'claims hold up' : 'false claims in this PR'}`;
|
|
38
|
+
const who = pr ? `PR #${pr.number}${pr.agent !== 'unknown' ? ` by **${pr.agent}**` : pr.author ? ` by @${pr.author}` : ''}` : '';
|
|
39
|
+
if (!r.results.length) return `${head}\n\n${who}\n\nNo checkable completion claims in the description.\n${r.strength ? strengthMarkdown(r.strength) : ''}`;
|
|
40
|
+
const rows = r.results.map((x) => `| ${ICON[x.verdict]} ${x.verdict} | ${cell(x.claim)} | ${cell(x.reason)} |`);
|
|
41
|
+
const details = r.results
|
|
42
|
+
.filter((x) => x.verdict === 'contradicted' && x.evidence?.excerpt)
|
|
43
|
+
.map((x) => `<details><summary><code>${escapeHtml(x.evidence.command)}</code></summary>\n\n\`\`\`\n${x.evidence.excerpt}\n\`\`\`\n</details>`);
|
|
44
|
+
return `${head}\n\n${who}\n\n| Verdict | Claim | Why |\n|---|---|---|\n${rows.join('\n')}\n\n${details.join('\n\n')}\n${r.strength ? strengthMarkdown(r.strength) : ''}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const RATING_ICON = { strong: '🟢', moderate: '🟡', weak: '🔴', inconclusive: '⚪' };
|
|
48
|
+
|
|
49
|
+
/** Test strength is its own section: it never changes a verdict above. */
|
|
50
|
+
export function strengthMarkdown(s) {
|
|
51
|
+
const t = s.summary;
|
|
52
|
+
const score = t.score != null ? ` · ${Math.round(t.score * 100)}% of planted defects caught` : '';
|
|
53
|
+
const surv = s.mutants.filter((m) => m.status === 'MUTATION_SURVIVED').slice(0, 8);
|
|
54
|
+
const code = (x) => `<code>${escapeHtml(x.split('\n')[0].trim().slice(0, 80)).replace(/\|/g, '|')}</code>`;
|
|
55
|
+
const rows = surv.map((m) => `| \`${m.file}:${m.line}\` | ${cell(m.function || 'top level')} | ${code(m.before)} → ${code(m.after)} |`);
|
|
56
|
+
return [
|
|
57
|
+
`\n#### Test strength: ${RATING_ICON[s.rating]} ${s.rating}${score}`,
|
|
58
|
+
s.headline ? `\n${cell(s.headline.text)}` : '',
|
|
59
|
+
t.attempted ? `\n${t.attempted} mutants · ${t.killed} killed · ${t.survived} survived · ${t.invalid} invalid · ${t.unresolved} unresolved · ${(t.ms / 1000).toFixed(0)}s` : '',
|
|
60
|
+
rows.length ? `\n<details><summary>Defects the tests did not notice</summary>\n\n| Where | Function | Change that still passed |\n|---|---|---|\n${rows.join('\n')}\n</details>` : '',
|
|
61
|
+
'\n<sub>Separate from the verdicts above: a mutation score measures how well the tests pin down the changed code, not whether the code is correct.</sub>\n',
|
|
62
|
+
].join('\n');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Workflow commands: annotations on the run, plus the job summary. */
|
|
66
|
+
export function emitActions(pr, r) {
|
|
67
|
+
for (const x of r.results) {
|
|
68
|
+
const msg = `${x.claim} → ${x.reason}`.replace(/\r?\n/g, ' ').replace(/%/g, '%25');
|
|
69
|
+
if (x.verdict === 'contradicted') console.log(`::error title=crossexam: false claim::${msg}`);
|
|
70
|
+
else if (x.verdict === 'review') console.log(`::warning title=crossexam: needs review::${msg}`);
|
|
71
|
+
else console.log(`::notice title=crossexam: verified::${msg}`);
|
|
72
|
+
}
|
|
73
|
+
if (r.strength?.headline && (r.strength.rating === 'weak' || r.strength.rating === 'moderate')) {
|
|
74
|
+
const top = r.strength.mutants.find((m) => m.id === r.strength.headline.mutant);
|
|
75
|
+
const loc = top ? ` file=${top.file},line=${top.line},` : ' ';
|
|
76
|
+
console.log(`::warning${loc}title=crossexam: ${r.strength.rating} tests::${r.strength.headline.text.replace(/\r?\n/g, ' ').replace(/%/g, '%25')}`);
|
|
77
|
+
}
|
|
78
|
+
const md = markdownSummary(pr, r);
|
|
79
|
+
if (process.env.GITHUB_STEP_SUMMARY) fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY, md);
|
|
80
|
+
if (process.env.GITHUB_OUTPUT) {
|
|
81
|
+
const n = (v) => r.results.filter((x) => x.verdict === v).length;
|
|
82
|
+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `ok=${r.ok}\ncontradicted=${n('contradicted')}\nverified=${n('verified')}\nagent=${pr?.agent ?? 'unknown'}\n`);
|
|
83
|
+
if (r.strength) fs.appendFileSync(process.env.GITHUB_OUTPUT, `mutation-score=${r.strength.summary.score ?? ''}\nmutation-rating=${r.strength.rating}\nmutants-survived=${r.strength.summary.survived}\n`);
|
|
84
|
+
// A fresh delimiter each run, so test output or grepped repo text can't end
|
|
85
|
+
// the block early and set outputs of its own.
|
|
86
|
+
const eof = `CROSSEXAM_EOF_${crypto.randomUUID().replace(/-/g, '')}`;
|
|
87
|
+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `summary<<${eof}\n${md}\n${eof}\n`);
|
|
88
|
+
}
|
|
89
|
+
return md;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const cell = (s) => String(s).replace(/\|/g, '\\|').replace(/\r?\n/g, ' ').replace(/`([^`]+)`/g, '<code>$1</code>');
|
|
93
|
+
const escapeHtml = (s) => String(s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c]);
|