@iceinvein/agent-skills 0.23.14 → 0.25.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.
Files changed (76) hide show
  1. package/README.md +4 -2
  2. package/package.json +1 -1
  3. package/skills/index.json +7 -1
  4. package/skills/magpie/README.md +14 -0
  5. package/skills/magpie/SKILL.md +7 -5
  6. package/skills/magpie/bin/magpie.ts +63 -3
  7. package/skills/magpie/evals/README.md +1 -1
  8. package/skills/magpie/evals/post-folds-selection-events/fixture.sh +35 -0
  9. package/skills/magpie/evals/post-folds-selection-events/graders/selection-read-from-magpie-view.md +6 -0
  10. package/skills/magpie/evals/post-folds-selection-events/prompt.md +2 -2
  11. package/skills/magpie/evals/rules.json +2 -2
  12. package/skills/magpie/package.json +1 -1
  13. package/skills/magpie/scripts/__tests__/helper.test.ts +300 -0
  14. package/skills/magpie/scripts/__tests__/labels.test.ts +46 -1
  15. package/skills/magpie/scripts/__tests__/mark-cmd.test.ts +129 -0
  16. package/skills/magpie/scripts/__tests__/post-cmd.test.ts +298 -1
  17. package/skills/magpie/scripts/__tests__/render-cmd.test.ts +15 -1
  18. package/skills/magpie/scripts/__tests__/render-findings.test.ts +13 -0
  19. package/skills/magpie/scripts/__tests__/server.test.ts +96 -1
  20. package/skills/magpie/scripts/__tests__/skill-lint.test.ts +23 -0
  21. package/skills/magpie/scripts/__tests__/view-cmd.test.ts +219 -0
  22. package/skills/magpie/scripts/helper.js +44 -4
  23. package/skills/magpie/scripts/labels.ts +11 -0
  24. package/skills/magpie/scripts/mark-cmd.ts +56 -0
  25. package/skills/magpie/scripts/post-cmd.ts +75 -5
  26. package/skills/magpie/scripts/render-cmd.ts +3 -1
  27. package/skills/magpie/scripts/render-findings.ts +3 -1
  28. package/skills/magpie/scripts/server.ts +31 -2
  29. package/skills/magpie/scripts/view-cmd.ts +143 -0
  30. package/skills/magpie/skill.json +1 -1
  31. package/skills/test-redundancy-auditor/SKILL.md +117 -0
  32. package/skills/test-redundancy-auditor/evals/README.md +35 -0
  33. package/skills/test-redundancy-auditor/evals/boundary-tests-stay-unique/case.yaml +4 -0
  34. package/skills/test-redundancy-auditor/evals/boundary-tests-stay-unique/fixture.sh +76 -0
  35. package/skills/test-redundancy-auditor/evals/boundary-tests-stay-unique/graders/auditor-fired.md +5 -0
  36. package/skills/test-redundancy-auditor/evals/boundary-tests-stay-unique/graders/nothing-deleted.md +26 -0
  37. package/skills/test-redundancy-auditor/evals/boundary-tests-stay-unique/prompt.md +11 -0
  38. package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/case.yaml +4 -0
  39. package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/fixture.sh +60 -0
  40. package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/graders/auditor-fired.md +5 -0
  41. package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/graders/output-ignores-itself.md +11 -0
  42. package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/graders/source-unchanged.md +10 -0
  43. package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/graders/tests-unchanged.md +10 -0
  44. package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/graders/tree-unchanged.md +13 -0
  45. package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/prompt.md +11 -0
  46. package/skills/test-redundancy-auditor/evals/duplicate-is-flagged/case.yaml +4 -0
  47. package/skills/test-redundancy-auditor/evals/duplicate-is-flagged/fixture.sh +60 -0
  48. package/skills/test-redundancy-auditor/evals/duplicate-is-flagged/graders/auditor-fired.md +5 -0
  49. package/skills/test-redundancy-auditor/evals/duplicate-is-flagged/graders/one-of-the-pair-deleted.md +34 -0
  50. package/skills/test-redundancy-auditor/evals/duplicate-is-flagged/prompt.md +11 -0
  51. package/skills/test-redundancy-auditor/evals/guard-test-is-kept/case.yaml +4 -0
  52. package/skills/test-redundancy-auditor/evals/guard-test-is-kept/fixture.sh +58 -0
  53. package/skills/test-redundancy-auditor/evals/guard-test-is-kept/graders/auditor-fired.md +5 -0
  54. package/skills/test-redundancy-auditor/evals/guard-test-is-kept/graders/guard-kept.md +32 -0
  55. package/skills/test-redundancy-auditor/evals/guard-test-is-kept/prompt.md +11 -0
  56. package/skills/test-redundancy-auditor/evals/mock-assertion-is-vacuous/case.yaml +4 -0
  57. package/skills/test-redundancy-auditor/evals/mock-assertion-is-vacuous/fixture.sh +73 -0
  58. package/skills/test-redundancy-auditor/evals/mock-assertion-is-vacuous/graders/auditor-fired.md +5 -0
  59. package/skills/test-redundancy-auditor/evals/mock-assertion-is-vacuous/graders/mock-test-is-vacuous.md +33 -0
  60. package/skills/test-redundancy-auditor/evals/mock-assertion-is-vacuous/prompt.md +11 -0
  61. package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/case.yaml +4 -0
  62. package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/fixture.sh +60 -0
  63. package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/graders/auditor-fired.md +5 -0
  64. package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/graders/labelled-rubric-only.md +26 -0
  65. package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/graders/nothing-installed.md +12 -0
  66. package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/prompt.md +11 -0
  67. package/skills/test-redundancy-auditor/evals/rules.json +193 -0
  68. package/skills/test-redundancy-auditor/evals/subsumed-by-broader-test/case.yaml +4 -0
  69. package/skills/test-redundancy-auditor/evals/subsumed-by-broader-test/fixture.sh +62 -0
  70. package/skills/test-redundancy-auditor/evals/subsumed-by-broader-test/graders/auditor-fired.md +5 -0
  71. package/skills/test-redundancy-auditor/evals/subsumed-by-broader-test/graders/narrow-test-subsumed.md +35 -0
  72. package/skills/test-redundancy-auditor/evals/subsumed-by-broader-test/prompt.md +11 -0
  73. package/skills/test-redundancy-auditor/references/findings-format.md +71 -0
  74. package/skills/test-redundancy-auditor/references/mutation-mode.md +100 -0
  75. package/skills/test-redundancy-auditor/references/rubric.md +144 -0
  76. package/skills/test-redundancy-auditor/skill.json +24 -0
@@ -0,0 +1,143 @@
1
+ import { existsSync } from 'node:fs'
2
+ import { readFile } from 'node:fs/promises'
3
+ import { join } from 'node:path'
4
+ import { filePathMatches, parseUnifiedDiffToHunks, splitDiffByFile } from './diff-utils.ts'
5
+ import { foldSelection, readDismissed, readJsonLines } from './labels.ts'
6
+ import { rankActionable } from './render-issues-list.ts'
7
+ import { readTarget } from './target.ts'
8
+ import { type PostStatusMap, parseFinding, type ReviewFinding } from './types.ts'
9
+
10
+ export type ViewFinding = {
11
+ id: string
12
+ file: string
13
+ line: number | null
14
+ severity: string
15
+ action: string
16
+ title: string
17
+ description: string
18
+ suggestion: { body: string } | null
19
+ proof: unknown | null
20
+ hunk: string | null
21
+ fileDiff: string | null
22
+ postStatus: 'posted' | 'failed' | null
23
+ postMessage: string | null
24
+ dismissed: string | null
25
+ selected: boolean
26
+ recommended: boolean
27
+ }
28
+
29
+ export type View = {
30
+ pr: { number: number; title: string; url: string }
31
+ findings: ViewFinding[]
32
+ }
33
+
34
+ function fail(message: string): number {
35
+ process.stderr.write(`view: ${message}\n`)
36
+ return 2
37
+ }
38
+
39
+ async function readJson(path: string): Promise<unknown> {
40
+ return JSON.parse(await readFile(path, 'utf8'))
41
+ }
42
+
43
+ async function readPr(path: string): Promise<View['pr']> {
44
+ if (!existsSync(path)) throw new Error(`${path} is missing`)
45
+ const raw = await readJson(path)
46
+ if (typeof raw !== 'object' || raw === null) throw new Error(`${path}: expected an object`)
47
+ const { number, title, url } = raw as Record<string, unknown>
48
+ if (typeof number !== 'number') throw new Error(`${path}: number must be a number`)
49
+ if (typeof title !== 'string') throw new Error(`${path}: title must be a string`)
50
+ if (typeof url !== 'string') throw new Error(`${path}: url must be a string`)
51
+ return { number, title, url }
52
+ }
53
+
54
+ /** The hunk, header included, whose new-side range holds `line`. */
55
+ function hunkAt(section: string, line: number): string | null {
56
+ const hunks = parseUnifiedDiffToHunks(section)
57
+ const blocks = section.split(/^(?=@@ )/m).filter((block) => block.startsWith('@@ '))
58
+ const index = hunks.findIndex((h) => line >= h.newStart && line < h.newStart + h.newLines)
59
+ return blocks[index] ?? null
60
+ }
61
+
62
+ function postFields(status: PostStatusMap[string] | undefined): {
63
+ postStatus: ViewFinding['postStatus']
64
+ postMessage: string | null
65
+ } {
66
+ if (status === 'posted') return { postStatus: 'posted', postMessage: null }
67
+ if (status?.status === 'failed') return { postStatus: 'failed', postMessage: status.message }
68
+ return { postStatus: null, postMessage: null }
69
+ }
70
+
71
+ export async function runView(runDir: string, top: number): Promise<number> {
72
+ try {
73
+ const target = await readTarget(runDir)
74
+ if (target.mode === 'local') return fail(`${runDir} is a local run; there is nothing to post`)
75
+ } catch (err) {
76
+ return fail(err instanceof Error ? err.message : String(err))
77
+ }
78
+ const findingsPath = join(runDir, 'findings.final.json')
79
+ if (!existsSync(findingsPath)) {
80
+ process.stderr.write(`view: ${findingsPath} is missing\n`)
81
+ return 4
82
+ }
83
+
84
+ let findings: ReviewFinding[]
85
+ let pr: View['pr']
86
+ let selected: Set<string>
87
+ let dismissed: Map<string, string>
88
+ try {
89
+ const raw = await readJson(findingsPath)
90
+ if (!Array.isArray(raw)) throw new Error(`${findingsPath}: expected an array of findings`)
91
+ findings = raw.map(parseFinding)
92
+ pr = await readPr(join(runDir, 'pr.json'))
93
+ selected = foldSelection(await readJsonLines(join(runDir, 'state', 'events')))
94
+ dismissed = await readDismissed(runDir)
95
+ } catch (err) {
96
+ return fail(err instanceof Error ? err.message : String(err))
97
+ }
98
+
99
+ const statusPath = join(runDir, 'post-status.json')
100
+ let postStatus: PostStatusMap = {}
101
+ if (existsSync(statusPath)) {
102
+ try {
103
+ postStatus = (await readJson(statusPath)) as PostStatusMap
104
+ } catch (err) {
105
+ return fail(
106
+ `${statusPath} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`,
107
+ )
108
+ }
109
+ }
110
+ const diffPath = join(runDir, 'diff.patch')
111
+ const sections = existsSync(diffPath)
112
+ ? splitDiffByFile(await readFile(diffPath, 'utf8'))
113
+ : new Map<string, string>()
114
+ const recommended = new Set(
115
+ rankActionable(findings, postStatus, dismissed, top).recommended.map((f) => f.id),
116
+ )
117
+
118
+ const view: View = {
119
+ pr,
120
+ findings: findings.map((f): ViewFinding => {
121
+ const fileDiff = [...sections].find(([path]) => filePathMatches(path, f.file))?.[1] ?? null
122
+ return {
123
+ id: f.id,
124
+ file: f.file,
125
+ line: f.line,
126
+ severity: f.severity,
127
+ action: f.risk.action,
128
+ title: f.title,
129
+ description: f.description,
130
+ suggestion: f.suggestion ? { body: f.suggestion.body } : null,
131
+ proof: f.proof ?? null,
132
+ hunk: fileDiff !== null && f.line !== null ? hunkAt(fileDiff, f.line) : null,
133
+ fileDiff,
134
+ ...postFields(postStatus[f.id]),
135
+ dismissed: dismissed.get(f.id) ?? null,
136
+ selected: selected.has(f.id),
137
+ recommended: recommended.has(f.id),
138
+ }
139
+ }),
140
+ }
141
+ process.stdout.write(`${JSON.stringify(view)}\n`)
142
+ return 0
143
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magpie",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "Interactive PR review pipeline. Runs five parallel specialist subagents (security, bugs, performance, code-smells, architecture) plus a once-per-PR checks pass that finds tests and controls able to pass without proving their purpose, drops findings whose quoted evidence is not in the code, dedupes, runs critic subagents that re-check each finding against the worktree and set its risk label, peer-reviews via codex exec (falling back to a Claude second opinion when codex is unavailable), and serves an interactive HTML report for selecting or dismissing findings to post via gh, recording the outcome per finding as labels. Bundles a Bun CLI put on PATH by the skill's postinstall step under a bunx install, or by the plugin's bin/ under a Claude Code plugin install. Use when the user asks to review a GitHub pull request. Local mode (setup --local) runs the same pipeline on the current branch's diff from its merge base, uncommitted and untracked work included, against the caller's live tree, with no server or posting, and hands the ranked findings back in the terminal for an implementing or orchestrating agent to address. Splits oversized diffs into budgeted shards and rebuilds the diff from the local clone when gh pr diff refuses it.",
5
5
  "author": "iceinvein",
6
6
  "type": "prompt",
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: test-redundancy-auditor
3
+ description: Use when asked how much of a test suite is redundant, which tests can be dropped or merged, whether tests pull their weight, or to trim a slow or repetitive suite. Classifies each test as unique, duplicate, subsumed, vacuous or layer echo with cited evidence, weights what is removable by lines, runtime and churn, and writes a deletion list. Optional mutation mode (--mutate) verifies verdicts with a per-test kill matrix from the repo's own mutation tool. Report only; never edits a test.
4
+ argument-hint: "[<path>...] [--mutate]"
5
+ ---
6
+
7
+ # Test redundancy auditor
8
+
9
+ A suite grows by copying the nearest test and changing one value. Some copies
10
+ cover a new case; many pin a behaviour another test already pins, or pin
11
+ nothing at all. This skill sorts one from the other, with evidence a reviewer
12
+ can check, so the suite can shrink without losing a single caught bug.
13
+
14
+ ## Verdicts
15
+
16
+ Every test in the target gets exactly one. `references/rubric.md` has the
17
+ questions that decide it and the precision rules.
18
+
19
+ | Verdict | Meaning | On the deletion list |
20
+ |---|---|---|
21
+ | `unique` | Catches some plausible bug no other test catches | no |
22
+ | `duplicate` | Same behaviour, same input partition, same strength as another test | all but one of the group |
23
+ | `subsumed` | Every bug it catches, another test (or a named set of tests) catches too, but not the reverse | yes |
24
+ | `vacuous` | No plausible change to the code under test can make it fail | yes |
25
+ | `layer-echo` | The same rule on the same partition, asserted again through another entry point (unit, component, integration, e2e) | never; the report says which layer to keep |
26
+
27
+ The deletion list is built one test at a time, so two tests that each cover
28
+ the other never both go (`references/rubric.md`, "Building the deletion
29
+ list").
30
+
31
+ **Precision over recall.** A wrong "delete this" costs a caught bug; a missed
32
+ duplicate costs a few lines. When in doubt the verdict is `unique`.
33
+
34
+ ## Method
35
+
36
+ 1. **Name the target** in one line: the paths from the arguments, or the
37
+ whole suite when none are given. Find the runner from the repo's manifests
38
+ and `CLAUDE.md`/`AGENTS.md`, and follow any rule there on how tests must be
39
+ run. Record the runner and language versions and the time zone it runs in:
40
+ some verdicts depend on them.
41
+ 2. **Map each test** to the unit it exercises, the behaviour it pins (one
42
+ sentence) and the input partition it covers. A suite whose test names
43
+ follow a consistent scenario/unit/outcome convention may supply these from
44
+ the names; say so in the report. A test whose behaviour you cannot state
45
+ in a sentence is a `vacuous` candidate. Each parametrised row counts as
46
+ one test, and so does each instance of a shared body (a `describe.each`
47
+ block, a helper that registers tests once per configuration).
48
+ 3. **Compare within a unit.** Group tests by the code under test, then apply
49
+ the rubric to each group.
50
+ 4. **Challenge every non-unique verdict** before writing it: name a plausible
51
+ bug, a one-line change to the code under test, that fails this test and
52
+ passes the one it is said to duplicate or be subsumed by (or, for
53
+ `vacuous`, that fails it at all). If you can name one, the verdict is
54
+ `unique`. When the answer is unclear, check it with a probe: apply the bug
55
+ in the scratch worktree and run the tests. A probe that fails neither test
56
+ was an equivalent change and settled nothing; try another.
57
+ 5. **Cost each test**: lines in its body, its runtime, and churn (commits
58
+ touching its lines, `git log -L`). Take runtime as the median of three runs
59
+ of the runner's own reporter: the first test in a file absorbs warm-up, and
60
+ one run lets that decide which duplicate is kept. A cost you could not
61
+ measure is `null` with the reason in the report, never a guess.
62
+ 6. **Mutation mode**, only with `--mutate` or when the request asks for
63
+ mutation testing: follow `references/mutation-mode.md`. Without a mutation
64
+ tool already in the repo, install nothing: name the tool to add, finish in
65
+ rubric mode, and say so.
66
+ 7. **Write the output.**
67
+
68
+ Run anything that writes files (a probe, a mutation run) in a scratch `git
69
+ worktree` outside the repo, in a directory of this run's own. Link the
70
+ repo's installed dependencies into it rather than installing, and keep the
71
+ runner from writing caches through those links (for Vitest: `--no-cache`,
72
+ and `--configLoader runner` so Vite writes no `.vite-temp` into a linked
73
+ `node_modules`). Never modify the caller's tree: no test is edited, deleted or
74
+ added, and no install or build artefact lands there. Acting on the deletion
75
+ list is the caller's call.
76
+
77
+ **Large targets.** Past a few hundred tests, classification may be split
78
+ across subagents by file, each returning verdicts and evidence for its files.
79
+ The run itself keeps the cross-file comparisons, every probe, and the
80
+ deletion list, because a verdict split across two readers is where
81
+ duplicates hide and where two halves of a pair both get deleted.
82
+
83
+ ## Output
84
+
85
+ Write to `.test-redundancy-auditor/<YYYY-MM-DD>-<slug>/` at the repo root:
86
+ `report.md` for a human and `findings.json` for a grader or calling skill, in
87
+ the shape `references/findings-format.md` gives. Mutation mode adds
88
+ `kill-matrix.json`. Write `findings.json` and `report.md` with the Write tool,
89
+ never from a shell command. The one exception is size: a `findings.json` for
90
+ more than about 100 tests is too large for one Write call, so write the
91
+ verdicts as a table with the Write tool and build `findings.json` from it
92
+ with a script saved beside it as `build-findings.*`.
93
+
94
+ `report.md` leads with the headline: how many tests, and what share of the
95
+ suite's lines and runtime, the deletion list removes. Then the deletion list,
96
+ each entry with its verdict and evidence, marking any that needs a
97
+ restructure rather than a deletion; layer echoes with the layer to keep;
98
+ guards (tests that pin another test's premise); behaviours a vacuous test
99
+ names but no test pins (gaps to fill, not to delete); the environment; and
100
+ every cost that could not be measured.
101
+
102
+ Run as a dispatched agent, the Write tool may refuse `report.md` and
103
+ `findings.json` as report files. Then put each refused file in a scratch path
104
+ and give the path in the hand-back (or, if small, its full content), for the
105
+ caller to write unchanged with the Write tool; never fall back to a shell
106
+ write into the caller's tree.
107
+
108
+ The directory ignores itself: if `.test-redundancy-auditor/.gitignore` is
109
+ absent, write it holding `*` before anything else in the run. Leave an
110
+ existing one alone.
111
+
112
+ ## Hand-back
113
+
114
+ The run directory, the mode (rubric or mutation), the counts per verdict,
115
+ the share removable by tests, lines and runtime, then each deletion in one
116
+ line: test, verdict, evidence. Name anything not done: an unmeasured cost,
117
+ an unprobed verdict, mutation mode skipped and why.
@@ -0,0 +1,35 @@
1
+ # test-redundancy-auditor evals
2
+
3
+ Seven cases for `claude plugin eval`. Each scaffolds a small Node repo with one
4
+ module and a `node --test` suite whose redundancy is known in advance. The
5
+ prompt asks about the tests the way a user would and never names the skill.
6
+
7
+ | Case | Fixture | What it pins |
8
+ |---|---|---|
9
+ | `duplicate-is-flagged` | Two tests each lowercase one capitalised word | One is a `duplicate` citing the other, exactly one of the pair is deleted, the three other tests stay `unique` |
10
+ | `mock-assertion-is-vacuous` | A test calls its own mock and asserts what the mock returns | That test is `vacuous` and deleted; the two that drive `notifyOverdue` stay `unique` |
11
+ | `boundary-tests-stay-unique` | Seven look-alike tests, each on a different edge | Every test `unique`, `deletions` empty |
12
+ | `subsumed-by-broader-test` | A one-field assertion on the input another test asserts in full | The narrow test is `subsumed` by the broad one (not `duplicate`), and only it is deleted |
13
+ | `callers-tree-unchanged` | The duplicate fixture | The test file keeps its five tests, nothing is created outside `.test-redundancy-auditor/`, which ignores itself |
14
+ | `mutate-without-tool-stops` | The duplicate fixture, mutation testing asked for, no tool installed | Nothing installed; `mode` is `rubric` and `mutation` names the tool to add |
15
+ | `guard-test-is-kept` | A test that never calls the code but checks the TZ stub took effect for the next test | It is `unique` as a guard naming the test it guards, and nothing is deleted |
16
+
17
+ Every case also has `auditor-fired`, a `tool_used: Skill` grader, so a score
18
+ can be told apart from the model's own habits. `callers-tree-unchanged` is in
19
+ `vacuousWithout`: a run that writes nothing passes its tree graders.
20
+
21
+ Mutation mode with a tool present is not pinned (see `rules.json`): it would
22
+ need StrykerJS installed inside the sandbox.
23
+
24
+ ## Running
25
+
26
+ From the repo root:
27
+
28
+ ```bash
29
+ claude plugin eval skills/test-redundancy-auditor --scaffold --allow-tools Bash Write Edit \
30
+ --model claude-opus-5-5 --judge-model claude-opus-5-5 --runs 1 --ablation none -j 7
31
+ ```
32
+
33
+ The content graders are `llm` judges over the trace, since `findings.json`
34
+ sits under a slug the skill picks. They judge only the last write of it, and
35
+ see a head-and-tail window of a long trace.
@@ -0,0 +1,4 @@
1
+ schema_version: "1.1"
2
+ name: boundary-tests-stay-unique
3
+ context:
4
+ scaffold_script: fixture.sh
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env bash
2
+ # A pagination helper whose tests look alike but each sit on a different edge:
3
+ # perPage 1 and 50 are the two inside edges, 0 and 51 the two outside ones,
4
+ # page 0 is the page floor, and the past-the-end and short-last-page tests
5
+ # cover the slice. For every test there is a plausible one-line bug that fails it
6
+ # and passes all the others, so nothing here is redundant. Any non-unique
7
+ # verdict is a false positive.
8
+ set -euo pipefail
9
+
10
+ mkdir -p src tests
11
+
12
+ cat > package.json <<'JSON'
13
+ {
14
+ "name": "listing",
15
+ "version": "2.0.1",
16
+ "type": "module",
17
+ "scripts": {
18
+ "test": "node --test \"tests/*.test.js\""
19
+ }
20
+ }
21
+ JSON
22
+
23
+ cat > src/paginate.js <<'JS'
24
+ const MAX_PER_PAGE = 50;
25
+
26
+ export function paginate(items, page, perPage) {
27
+ if (!Number.isInteger(perPage) || perPage < 1 || perPage > MAX_PER_PAGE) {
28
+ throw new RangeError(`perPage must be a whole number from 1 to ${MAX_PER_PAGE}, got ${perPage}`);
29
+ }
30
+ if (!Number.isInteger(page) || page < 1) {
31
+ throw new RangeError(`page must be a whole number of 1 or more, got ${page}`);
32
+ }
33
+ const start = (page - 1) * perPage;
34
+ return items.slice(start, start + perPage);
35
+ }
36
+ JS
37
+
38
+ cat > tests/paginate.test.js <<'JS'
39
+ import assert from "node:assert/strict";
40
+ import { test } from "node:test";
41
+ import { paginate } from "../src/paginate.js";
42
+
43
+ const letters = ["a", "b", "c", "d", "e", "f", "g"];
44
+
45
+ test("accepts a perPage of 1", () => {
46
+ assert.deepEqual(paginate(letters, 2, 1), ["b"]);
47
+ });
48
+
49
+ test("accepts a perPage of 50", () => {
50
+ assert.deepEqual(paginate(letters, 1, 50), letters);
51
+ });
52
+
53
+ test("rejects a perPage of 0", () => {
54
+ assert.throws(() => paginate(letters, 1, 0), RangeError);
55
+ });
56
+
57
+ test("rejects a perPage of 51", () => {
58
+ assert.throws(() => paginate(letters, 1, 51), RangeError);
59
+ });
60
+
61
+ test("rejects a page of 0", () => {
62
+ assert.throws(() => paginate(letters, 0, 3), RangeError);
63
+ });
64
+
65
+ test("the last page holds what is left", () => {
66
+ assert.deepEqual(paginate(letters, 3, 3), ["g"]);
67
+ });
68
+
69
+ test("a page past the last one is empty", () => {
70
+ assert.deepEqual(paginate(letters, 4, 3), []);
71
+ });
72
+ JS
73
+
74
+ git init --quiet
75
+ git add -A
76
+ git -c user.email=fixture@example.com -c user.name=fixture commit --quiet -m "feat: paginate listings"
@@ -0,0 +1,5 @@
1
+ ---
2
+ type: tool_used
3
+ tool: Skill
4
+ input_match: '"skill"\s*:\s*"(?:[\w-]+:)?test-redundancy-auditor"'
5
+ ---
@@ -0,0 +1,26 @@
1
+ ---
2
+ type: llm
3
+ # findings.json sits under a slug the skill picks, so no file focus can name
4
+ # it; the judge reads its content from the Write call (or shell command) in
5
+ # the trace, and sees only a head-and-tail window of a long trace.
6
+ focus: trace
7
+ weight: 3
8
+ ---
9
+
10
+ The agent was asked which tests in `tests/paginate.test.js` can be dropped.
11
+ The file has seven tests, and each sits on its own edge: perPage 1 and 50
12
+ accepted, perPage 0 and 51 rejected, page 0 rejected, a short last page, and
13
+ a page past the end. For each one there is a plausible one-line bug in
14
+ `src/paginate.js` that fails it and passes the other six (for example
15
+ `perPage > 49` fails only the perPage-50 test, `perPage < 2` fails only the
16
+ perPage-1 test). None is redundant.
17
+
18
+ Find the `findings.json` the agent wrote under `.test-redundancy-auditor/`. If
19
+ it was written more than once, judge only the last write, with any later Edit
20
+ applied.
21
+
22
+ PASS if every one of the seven tests has verdict `unique` and `deletions` is
23
+ an empty array.
24
+
25
+ FAIL if no findings.json content is visible in the trace, if any test has a
26
+ verdict other than `unique`, or if `deletions` names any test.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: boundary-tests-stay-unique
3
+ description: Seven look-alike tests, each on a different edge of the same ranges. Pins the skill calling every one unique with an empty deletion list, rather than reading similar shape as redundancy.
4
+ tags: [false-positive, boundary, precision, scaffold, write]
5
+ max_turns: 60
6
+ timeout_seconds: 1800
7
+ allowed_tools: [Read, Glob, Grep, Skill, Write, Edit, Bash, Agent]
8
+ expected_outcome: findings.json under .test-redundancy-auditor/ gives all seven tests verdict unique and an empty deletions array.
9
+ ---
10
+
11
+ `tests/paginate.test.js` feels repetitive. Which of these tests can we drop?
@@ -0,0 +1,4 @@
1
+ schema_version: "1.1"
2
+ name: callers-tree-unchanged
3
+ context:
4
+ scaffold_script: fixture.sh
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env bash
2
+ # A slugify module and five tests. Two of them pin the same behaviour on the
3
+ # same kind of input (one capitalised word is lowercased): no plausible bug
4
+ # fails one and passes the other, so one is a duplicate of the other. The
5
+ # other three each cover their own partition: whitespace between words,
6
+ # a run of punctuation, punctuation at the ends. Deleting both duplicates
7
+ # would lose the lowercasing check, so only one belongs on the deletion list.
8
+ set -euo pipefail
9
+
10
+ mkdir -p src tests
11
+
12
+ cat > package.json <<'JSON'
13
+ {
14
+ "name": "slugs",
15
+ "version": "1.0.0",
16
+ "type": "module",
17
+ "scripts": {
18
+ "test": "node --test \"tests/*.test.js\""
19
+ }
20
+ }
21
+ JSON
22
+
23
+ cat > src/slugify.js <<'JS'
24
+ export function slugify(title) {
25
+ return title
26
+ .toLowerCase()
27
+ .replace(/[^a-z0-9]+/g, "-")
28
+ .replace(/^-+|-+$/g, "");
29
+ }
30
+ JS
31
+
32
+ cat > tests/slugify.test.js <<'JS'
33
+ import assert from "node:assert/strict";
34
+ import { test } from "node:test";
35
+ import { slugify } from "../src/slugify.js";
36
+
37
+ test("lowercases a capitalised word", () => {
38
+ assert.equal(slugify("Hello"), "hello");
39
+ });
40
+
41
+ test("joins words with a dash", () => {
42
+ assert.equal(slugify("hello world"), "hello-world");
43
+ });
44
+
45
+ test("lowercases another capitalised word", () => {
46
+ assert.equal(slugify("World"), "world");
47
+ });
48
+
49
+ test("collapses a run of punctuation into one dash", () => {
50
+ assert.equal(slugify("a--b"), "a-b");
51
+ });
52
+
53
+ test("trims punctuation from both ends", () => {
54
+ assert.equal(slugify("!hi!"), "hi");
55
+ });
56
+ JS
57
+
58
+ git init --quiet
59
+ git add -A
60
+ git -c user.email=fixture@example.com -c user.name=fixture commit --quiet -m "feat: slugify titles"
@@ -0,0 +1,5 @@
1
+ ---
2
+ type: tool_used
3
+ tool: Skill
4
+ input_match: '"skill"\s*:\s*"(?:[\w-]+:)?test-redundancy-auditor"'
5
+ ---
@@ -0,0 +1,11 @@
1
+ ---
2
+ type: regex
3
+ # SKILL.md has the run drop a .gitignore holding `*` into
4
+ # .test-redundancy-auditor/ when none is there. The files target would show
5
+ # the path but not what it holds, and an empty .gitignore ignores nothing, so
6
+ # this reads the trace: a Write call whose content is `*`, or a shell command
7
+ # that writes a `*` into it.
8
+ pattern: '\.test-redundancy-auditor/\.gitignore"\s*,\s*"content"\s*:\s*"\*(?:\\n)?"|"command":"(?:\\.|[^"\\])*?\*(?:\\.|[^"\\])*?>\s*[^"\s]*\.test-redundancy-auditor/\.gitignore'
9
+ target: trace
10
+ weight: 2
11
+ ---
@@ -0,0 +1,10 @@
1
+ ---
2
+ type: regex
3
+ # SKILL.md has the run apply a suspected bug to the code under test to settle
4
+ # a verdict, in a scratch worktree. A probe applied in the caller's tree and
5
+ # never reverted would leave src/slugify.js changed, and the files target
6
+ # never lists an edited file, so this checks the module's body survives whole.
7
+ pattern: '\.toLowerCase\(\)\s*\n\s*\.replace\(/\[\^a-z0-9\]\+/g, "-"\)\s*\n\s*\.replace\(/\^-\+\|-\+\$/g, ""\);'
8
+ target: { source: file, path: src/slugify.js }
9
+ weight: 3
10
+ ---
@@ -0,0 +1,10 @@
1
+ ---
2
+ type: regex
3
+ # The files target lists only paths the run created, so an edit to the
4
+ # scaffold's test file never reaches it. The scaffold has five tests; any
5
+ # other count means the audit deleted or added one.
6
+ pattern: '\btest\('
7
+ match: 'count:5'
8
+ target: { source: file, path: tests/slugify.test.js }
9
+ weight: 3
10
+ ---
@@ -0,0 +1,13 @@
1
+ ---
2
+ type: regex
3
+ # A grader cannot run `git status --porcelain`, so this reads the harness's own
4
+ # list of files the run created in the working directory, one path per line.
5
+ # .git/ is excluded because git keeps worktree bookkeeping there. Fails on any
6
+ # line naming a path outside .test-redundancy-auditor/. Edits to existing
7
+ # files never appear here; tests-unchanged covers the test file.
8
+ pattern: '^(?!\.test-redundancy-auditor/|\.git/).+'
9
+ flags: m
10
+ match: not_contains
11
+ target: files
12
+ weight: 3
13
+ ---
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: callers-tree-unchanged
3
+ description: "The duplicate fixture again. Pins the audit as report-only: no test or source file edited, nothing created outside .test-redundancy-auditor/, and that directory ignoring itself."
4
+ tags: [report-only, tree, scaffold, write]
5
+ max_turns: 60
6
+ timeout_seconds: 1800
7
+ allowed_tools: [Read, Glob, Grep, Skill, Write, Edit, Bash, Agent]
8
+ expected_outcome: tests/slugify.test.js still holds its five tests, every created path is under .test-redundancy-auditor/, and .test-redundancy-auditor/.gitignore holds `*`.
9
+ ---
10
+
11
+ Which tests in `tests/slugify.test.js` are redundant?
@@ -0,0 +1,4 @@
1
+ schema_version: "1.1"
2
+ name: duplicate-is-flagged
3
+ context:
4
+ scaffold_script: fixture.sh
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env bash
2
+ # A slugify module and five tests. Two of them pin the same behaviour on the
3
+ # same kind of input (one capitalised word is lowercased): no plausible bug
4
+ # fails one and passes the other, so one is a duplicate of the other. The
5
+ # other three each cover their own partition: whitespace between words,
6
+ # a run of punctuation, punctuation at the ends. Deleting both duplicates
7
+ # would lose the lowercasing check, so only one belongs on the deletion list.
8
+ set -euo pipefail
9
+
10
+ mkdir -p src tests
11
+
12
+ cat > package.json <<'JSON'
13
+ {
14
+ "name": "slugs",
15
+ "version": "1.0.0",
16
+ "type": "module",
17
+ "scripts": {
18
+ "test": "node --test \"tests/*.test.js\""
19
+ }
20
+ }
21
+ JSON
22
+
23
+ cat > src/slugify.js <<'JS'
24
+ export function slugify(title) {
25
+ return title
26
+ .toLowerCase()
27
+ .replace(/[^a-z0-9]+/g, "-")
28
+ .replace(/^-+|-+$/g, "");
29
+ }
30
+ JS
31
+
32
+ cat > tests/slugify.test.js <<'JS'
33
+ import assert from "node:assert/strict";
34
+ import { test } from "node:test";
35
+ import { slugify } from "../src/slugify.js";
36
+
37
+ test("lowercases a capitalised word", () => {
38
+ assert.equal(slugify("Hello"), "hello");
39
+ });
40
+
41
+ test("joins words with a dash", () => {
42
+ assert.equal(slugify("hello world"), "hello-world");
43
+ });
44
+
45
+ test("lowercases another capitalised word", () => {
46
+ assert.equal(slugify("World"), "world");
47
+ });
48
+
49
+ test("collapses a run of punctuation into one dash", () => {
50
+ assert.equal(slugify("a--b"), "a-b");
51
+ });
52
+
53
+ test("trims punctuation from both ends", () => {
54
+ assert.equal(slugify("!hi!"), "hi");
55
+ });
56
+ JS
57
+
58
+ git init --quiet
59
+ git add -A
60
+ git -c user.email=fixture@example.com -c user.name=fixture commit --quiet -m "feat: slugify titles"
@@ -0,0 +1,5 @@
1
+ ---
2
+ type: tool_used
3
+ tool: Skill
4
+ input_match: '"skill"\s*:\s*"(?:[\w-]+:)?test-redundancy-auditor"'
5
+ ---