stryker-agent-reporter
stryker-agent-reporterv0.3.0Apache-2.0
A Stryker reporter that writes JSON Lines a coding agent can act on directly
Install
npm install stryker-agent-reporter- Source on GitHub
- Uses: archstrict, nukadoko
- Used by: archstrict, autospawn, finderscope, firstlight, polylinedb, solarsql
stryker-agent-reporter is a Stryker reporter for a coding agent.
It writes JSON Lines, one object per line, so an agent can read the result a line at a time and filter it with grep or jq.
Each surviving mutant’s line carries its location, the original and replacement text, a ready-to-apply patch, and a rerun command.
The agent does not need to work any of that out again from Stryker’s own report.
Two more commands, convert and gate, work from that output alone.
Features
Section titled “Features”- One line per mutant.
reports/mutation/agent.jsonlstarts with arunline, then onescopeline per mutated file, one line per actionable mutant, and onetestWithoutKillsline per test that killed no mutant. ItscoveredMutantscounts the mutants of this run that the test reached, which separates a test that ran against mutants and killed none from a test that a narrowed--mutatenever reached. Asummaryline comes last, so a file without one is a run that did not finish. - Material for a fix. A
survivorline carriespatch, ready forgit apply --unidiff-zero. It also carriesrerunfor its file andrerunExactfor that one mutant. - Stable keys. Each mutant’s
keycomes from its own source text, not its line number, so an edit elsewhere in the file keeps it. Ascopeline lists every key of its file, which tells a killed mutant apart from one that a narrowermutaterange left out. - Results during the run. The reporter appends each finished mutant to
reports/mutation/agent.partial.jsonl, sotail -fshows survivors while Stryker still runs. - A gate for pull requests.
stryker-agent-reporter gate --since origin/main --format githubchecks only the changed lines and annotates them in GitHub Actions. Exit code 1 means a survivor or an uncovered mutant remains, and exit code 3 means a measurement failure, not a proven gap. With--baseline <file>, only a new survivor fails the gate. - Saved reports.
stryker-agent-reporter convertturns a savedmutation.jsoninto the same JSON Lines.
How an agent uses it
Section titled “How an agent uses it”- Run Stryker with the
agentreporter, and readagent.partial.jsonlwhile the run goes. - Select the survivors, for example with
jq -c 'select(.kind=="survivor")' reports/mutation/agent.jsonl. - For each survivor, read
original,replacement, andpatch, make the change, then run itsrerunExactcommand to test that mutant again. - In CI, run
gate --since, so a pull request fails only on mutants in the lines it changed.
Getting started
Section titled “Getting started”npm install --save-dev stryker-agent-reporterAdd the agent reporter to the Stryker config. Stryker’s default plugins loads only @stryker-mutator/*, so name this package too.
{ "reporters": ["clear-text", "agent"], "plugins": ["@stryker-mutator/*", "stryker-agent-reporter"]}