@jeiemgi/cckit 0.5.0 → 0.7.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 (144) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +34 -3
  3. package/README.md +95 -6
  4. package/bin/cckit +90 -3
  5. package/cckit.config.json +7 -2
  6. package/kit.config.schema.json +26 -1
  7. package/package.json +1 -1
  8. package/profiles/automation.json +2 -1
  9. package/profiles/content.json +2 -1
  10. package/profiles/minimal.json +2 -1
  11. package/profiles/research.json +2 -1
  12. package/profiles/software.json +2 -1
  13. package/scripts/benchmark/benchmark-test.sh +83 -0
  14. package/scripts/benchmark/gate.sh +55 -0
  15. package/scripts/benchmark/lib/bench-common.sh +70 -0
  16. package/scripts/benchmark/lib/model.sh +116 -0
  17. package/scripts/benchmark/report.sh +105 -0
  18. package/scripts/benchmark/run-quality.sh +102 -0
  19. package/scripts/benchmark/run.sh +166 -0
  20. package/scripts/benchmark/stop-check.sh +83 -0
  21. package/scripts/commitlint-test.sh +58 -0
  22. package/scripts/init.sh +57 -1
  23. package/scripts/kit-self-update.sh +55 -0
  24. package/scripts/lib/board-view-test.sh +1 -0
  25. package/scripts/lib/board-view.sh +1 -0
  26. package/scripts/lib/captain-test.sh +62 -0
  27. package/scripts/lib/captain.sh +105 -17
  28. package/scripts/lib/cckit-output.sh +1 -0
  29. package/scripts/lib/commitlint.sh +54 -0
  30. package/scripts/lib/config-path-test.sh +1 -0
  31. package/scripts/lib/config-path.sh +1 -0
  32. package/scripts/lib/copilot-test.sh +1 -0
  33. package/scripts/lib/copilot.sh +1 -0
  34. package/scripts/lib/effort-dispatch-test.sh +10 -0
  35. package/scripts/lib/effort-flows-test.sh +1 -0
  36. package/scripts/lib/effort-metrics-test.sh +1 -0
  37. package/scripts/lib/effort-metrics.sh +1 -0
  38. package/scripts/lib/effort-ops-test.sh +360 -0
  39. package/scripts/lib/effort-ops.sh +372 -16
  40. package/scripts/lib/effort-parity-test.sh +1 -0
  41. package/scripts/lib/effort-plan.sh +1 -0
  42. package/scripts/lib/effort-slug-test.sh +32 -0
  43. package/scripts/lib/effort-slug.sh +72 -8
  44. package/scripts/lib/effort.sh +1 -0
  45. package/scripts/lib/engine-adapter.sh +1 -0
  46. package/scripts/lib/errors-header-test.sh +86 -0
  47. package/scripts/lib/gh-log.sh +1 -0
  48. package/scripts/lib/gh-project-test.sh +1 -0
  49. package/scripts/lib/gh-project.sh +1 -0
  50. package/scripts/lib/git-remote-test.sh +1 -0
  51. package/scripts/lib/git-remote.sh +1 -0
  52. package/scripts/lib/handoff.sh +23 -2
  53. package/scripts/lib/kit-brief-test.sh +292 -0
  54. package/scripts/lib/kit-brief.sh +376 -0
  55. package/scripts/lib/kit-cli-test.sh +1 -0
  56. package/scripts/lib/kit-cli.sh +1 -0
  57. package/scripts/lib/kit-config-resolve.sh +1 -0
  58. package/scripts/lib/kit-config-test.sh +14 -0
  59. package/scripts/lib/kit-config.sh +7 -0
  60. package/scripts/lib/kit-engine-test.sh +1 -0
  61. package/scripts/lib/kit-events.sh +1 -0
  62. package/scripts/lib/kit-gc-test.sh +125 -0
  63. package/scripts/lib/kit-gc.sh +193 -5
  64. package/scripts/lib/kit-interview-test.sh +1 -0
  65. package/scripts/lib/kit-interview.sh +1 -0
  66. package/scripts/lib/kit-lib-test.sh +226 -0
  67. package/scripts/lib/kit-lib.sh +308 -0
  68. package/scripts/lib/kit-local.sh +1 -0
  69. package/scripts/lib/kit-manifest.sh +1 -0
  70. package/scripts/lib/kit-mode-test.sh +1 -0
  71. package/scripts/lib/kit-mode.sh +1 -0
  72. package/scripts/lib/kit-msg-test.sh +1 -0
  73. package/scripts/lib/kit-msg.sh +1 -0
  74. package/scripts/lib/kit-operate.sh +1 -0
  75. package/scripts/lib/kit-profile-test.sh +1 -0
  76. package/scripts/lib/kit-profile.sh +1 -0
  77. package/scripts/lib/kit-state-test.sh +89 -0
  78. package/scripts/lib/kit-state.sh +61 -0
  79. package/scripts/lib/kit-status-test.sh +233 -0
  80. package/scripts/lib/kit-status.sh +415 -0
  81. package/scripts/lib/kit-task-ops-test.sh +22 -0
  82. package/scripts/lib/kit-task-ops.sh +51 -2
  83. package/scripts/lib/next.sh +1 -0
  84. package/scripts/lib/plan-machine-test.sh +54 -0
  85. package/scripts/lib/plan-machine.sh +86 -25
  86. package/scripts/lib/plan-next-test.sh +1 -0
  87. package/scripts/lib/plan-next.sh +1 -0
  88. package/scripts/lib/pr-evidence-test.sh +259 -0
  89. package/scripts/lib/pr-evidence.sh +220 -35
  90. package/scripts/lib/project-scan.sh +1 -0
  91. package/scripts/lib/react-detect.sh +1 -0
  92. package/scripts/lib/render-test.sh +1 -0
  93. package/scripts/lib/render.sh +1 -0
  94. package/scripts/lib/role-identity.sh +1 -0
  95. package/scripts/lib/secret-guard.sh +21 -1
  96. package/scripts/lib/toon.sh +1 -0
  97. package/scripts/lib/ui.sh +1 -0
  98. package/scripts/lib/version-bump-test.sh +1 -0
  99. package/scripts/lib/version-bump.sh +1 -0
  100. package/scripts/lib/worktree-bootstrap-test.sh +220 -0
  101. package/scripts/lib/worktree-issue-test.sh +15 -1
  102. package/scripts/lib/worktree-issue.sh +23 -8
  103. package/scripts/lib/worktree-start.sh +191 -7
  104. package/scripts/lib/zsh-safety-test.sh +10 -0
  105. package/scripts/orchestrate.sh +8 -1
  106. package/scripts/portable-test.sh +13 -2
  107. package/scripts/self-install-test.sh +282 -0
  108. package/scripts/setup-labels.sh +1 -0
  109. package/scripts/status.sh +68 -40
  110. package/scripts/task-sync.sh +13 -0
  111. package/scripts/ux-a11y-scan.sh +96 -0
  112. package/scripts/ux-ds-audit.sh +146 -0
  113. package/scripts/ux-graph-scan.sh +188 -0
  114. package/skills/kit-autopilot/SKILL.md +6 -1
  115. package/skills/kit-cleanup/SKILL.md +83 -0
  116. package/skills/kit-effort-close/SKILL.md +3 -0
  117. package/skills/kit-effort-new/SKILL.md +7 -0
  118. package/skills/kit-effort-start/SKILL.md +39 -4
  119. package/skills/kit-gc/SKILL.md +19 -0
  120. package/skills/kit-next/SKILL.md +5 -0
  121. package/skills/kit-status/SKILL.md +92 -0
  122. package/skills/kit-task-start/SKILL.md +7 -1
  123. package/skills/kit-ux-audit/SKILL.md +241 -0
  124. package/skills/kit-ux-audit/references/a11y.md +79 -0
  125. package/skills/kit-ux-audit/references/consistency.md +106 -0
  126. package/skills/kit-ux-audit/references/graph-model.md +92 -0
  127. package/skills/kit-ux-audit/references/heuristics.md +157 -0
  128. package/skills/kit-ux-audit/references/report.md +172 -0
  129. package/templates/agents/ux.md +89 -0
  130. package/templates/benchmarks/SCHEMA.md +75 -0
  131. package/templates/benchmarks/abstain.jsonl +8 -0
  132. package/templates/benchmarks/adversarial.jsonl +8 -0
  133. package/templates/benchmarks/benchmark.config.json +14 -0
  134. package/templates/benchmarks/quality.jsonl +8 -0
  135. package/templates/benchmarks/retrieval.jsonl +7 -0
  136. package/templates/rules/branch-naming.md +20 -1
  137. package/templates/rules/communication-style.md +8 -0
  138. package/templates/rules/delegation-brief.md +38 -4
  139. package/templates/rules/effort-model.md +47 -4
  140. package/templates/rules/naming-and-ids.md +199 -0
  141. package/templates/rules/task-management.md +1 -1
  142. package/templates/settings/settings.json.tmpl +9 -0
  143. package/templates/skills/concrete/SKILL.md +117 -0
  144. package/templates/skills/karpathy-guidelines/SKILL.md +1 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cckit",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "installationPreference": "beta",
5
5
  "description": "cckit — a project operating system for coding agents. The full GitHub work lifecycle (start/pr/close/sync, efforts, worktrees, orchestrate, gc) as agents + skills + rules, drivable by Claude Code and any other agent. Driven from cckit.config.json; no org or repo hardcoded.",
6
6
  "author": {
package/AGENTS.md CHANGED
@@ -11,6 +11,12 @@ adapter one) — is described in [the Adapters page](docs-site/src/content/docs/
11
11
  - **Read state before acting.** `cckit sync --llm` returns the board as TOON. Decide from data.
12
12
  - **One issue = one branch = one worktree = one PR.** `cckit start <issue>` creates the isolated
13
13
  worktree; do all work there; `cckit pr <issue>` opens the PR. Never commit to the base branch.
14
+ **The effort flow is the one exception, and it is deliberate:** an effort is *1 parent issue = 1
15
+ `effort/<N>` branch = 1 PR* covering **N sub-issues**. Sequential sub-issues commit straight onto
16
+ `effort/<N>` (one commit per sub-issue — that commit's diff is the sub's patch); parallel ones get
17
+ their own file-disjoint `sub/<N><letter>` worktree and merge back into `effort/<N>`. Either way
18
+ exactly one PR opens, from `effort/<N>` — never one per sub-issue. Full spec:
19
+ `.claude/rules/effort-model.md`.
14
20
  - **Structured output, TOON-first.** Append `--llm` to any verb for machine-readable output. List
15
21
  reads (sync, next, plan, wave) come back as **TOON** (token-cheap); single-result action verbs
16
22
  (start, pr, close) return one JSON object. Human (pretty) output is the default; agents prefer `--llm`.
@@ -19,6 +25,23 @@ adapter one) — is described in [the Adapters page](docs-site/src/content/docs/
19
25
  - **Hand off when you stop with unfinished work.** `cckit handoff "<what's pending, next step, refs>"`
20
26
  saves a local resume-here note; bare `cckit` (no verb) prints it so the next session resumes
21
27
  exactly where this one stopped.
28
+ - **Run durable prose through `concrete` before writing it.** Every durable artifact — a commit
29
+ message, a PR or issue body, a rule, an ADR, a knowledge doc — goes through
30
+ `.claude/skills/concrete/SKILL.md`: cut only by named offense, never by length;
31
+ evidence, commands, paths and numbers are untouchable; `O13` unverifiable claim and `O14` undecided
32
+ decision are fixed at the gap, not reworded. `cckit brief <issue>` emits this instruction in its
33
+ `## Durable prose` section, so a delegated agent gets it without being told twice.
34
+
35
+ ## What cckit installs for itself
36
+
37
+ `templates/` is what `cckit init` writes into a consuming project. `.claude/skills/` and
38
+ `.claude/rules/` in this repo are the subset cckit applies to its **own** work — `concrete`,
39
+ `karpathy-guidelines`, and the rules for branches, efforts, PR titles, delegation and communication
40
+ style. No agents are installed: this file plus `cckit brief` is the delegation contract here.
41
+
42
+ The manifest and the reason for every skipped template are in `scripts/self-install-test.sh`, which
43
+ also fails if an installed copy drifts from its template. Edit a template and its installed copy in
44
+ the same commit.
22
45
 
23
46
  ## Core verbs
24
47
 
@@ -27,24 +50,32 @@ adapter one) — is described in [the Adapters page](docs-site/src/content/docs/
27
50
  | `cckit init` | scaffold config + `.claude/` | — |
28
51
  | `cckit sync` | board state / what's unblocked | `--llm` → TOON |
29
52
  | `cckit next` | the next unblocked issue + how to start it | `--llm` → TOON |
30
- | `cckit plan` | wave plan: deps-ordered, file-disjoint, session-fit | `--llm` → TOON |
53
+ | `cckit plan` | wave plan: deps-ordered, priority-sorted within a wave, file-disjoint, session-fit | `--llm` → TOON |
31
54
  | `cckit plan-next` | forward plan: inventory current skills/verbs/rules/docs → propose what to build next | `--llm` → TOON |
55
+ | `cckit status` | where are we: local undone work, open PRs waiting on a human, cleanup available (local + remote) | `--llm` → JSON |
56
+ | `cckit brief <issue>` | the delegation brief for an issue, from real state: worktree, seed freshness, owned files, the helpers they sit on, standing gotchas | — |
32
57
  | `cckit wave` | read open efforts, propose incoming waves: fan-out brief + captain drive | `--llm` → TOON |
33
58
  | `cckit watch [--merge] [--loop]` | captain: gate open PRs, squash-merge CLEAN, advance the wave | — |
34
- | `cckit start <issue> [slug]` | isolated worktree + branch | `--llm` |
59
+ | `cckit start <issue> [slug]` | isolated worktree + branch, bootstrapped: env files copied, per-worktree dev PORT, deps installed at the selected targets. Precedence: **`worktree.installPaths` if set** (those dirs only, installed whether or not each declares dependencies — `[]` installs nothing, and the root/workspace checks are skipped entirely), **else** the root *only when* its manifest declares dependencies or it is a workspace root **with at least one member** (a non-empty `packages:` list, or a non-empty `workspaces` / `workspaces.packages` array), **else nothing** — so a dependency-free root never gets a stray empty `pnpm-lock.yaml`. `installPaths` entries that escape the worktree are refused. `KIT_WT_INSTALL=0` skips the install | `--llm` |
35
60
  | `cckit pr <issue> <summary>` | commit + push + open PR | `--llm` |
36
61
  | `cckit close <issue> <summary>` | close issue + mark done | `--llm` |
37
62
  | `cckit effort new "<name>" ["sub :: desc" …]` | parent (4-section body + ctx/kind/priority/role/flow labels) + linted native sub-issues — identical to `/kit-effort-new` (one shared core); `start`/`pr`/`close` take `<slug\|N>` | flags: `--flow/--role/--priority/--goal/--scope/--for-agents/--verification/--depends-on/--milestone`, `--slug` |
63
+ | `cckit effort chain <a> <b> [<c> …]` | wire 2+ issues into a linear order: `b` `blocked_by` `a`, `c` `blocked_by` `b`, plus a `- Depends on #<predecessor>` line in each successor's `## Relations` section. These are the edges `cckit plan` layers into waves. Idempotent (an edge or line already there is skipped); pre-existing blockers are kept, never replaced. Validates everything first — fewer than two numbers, a non-numeric arg, an issue that does not exist, a repeated number, or an edge that would close a cycle refuses the whole chain and writes nothing | — |
64
+ | `cckit effort start [--force] <slug\|N> [slug]` | effort branch + bootstrapped worktree, **WIP-limited**: refuses a NEW effort once `effort.wipLimit` (default 2) are already in progress. In progress = an `effort/<N>-<slug>` branch exists as a local head **or** on origin, read with `git ls-remote` rather than the cached `refs/remotes` (which is wrong both ways: it misses a branch pushed since the last fetch and keeps one deleted on origin until a prune). At the limit refuses; only strictly under it starts. Re-starting an effort that is already in progress is never gated. The check runs before the fetch/branch/worktree/bootstrap, so a refusal makes no branch, no worktree and no board change — it is not read-free (it queries origin, and a `<slug>` arg was resolved first, which can run `gh issue list`). `0` refuses every ordinary start; `--force` still starts. A non-integer value is ignored with a warning and the default 2 is used; `EFFORT_WIP_LIMIT` overrides the config per invocation. `EFFORT_WIP_REMOTE=0` — or an unreachable origin, which warns and proceeds — counts the cached refs instead. Does **not** gate `cckit start <issue>` | `--force`, or `KIT_FORCE=1` |
38
65
  | `cckit effort plan` | session-fit effort plan | `--llm` → JSON |
39
66
  | `cckit orchestrate <a> <b> …` | run N flows in parallel worktrees | — (use `--dry-run`) |
40
67
  | `cckit autopilot [<a> …]` | unattended multi-flow: drive (or auto-pick) issues under a cap | — (use `--dry-run`) |
41
- | `cckit gc` | report prunable branches + worktrees | `--llm` → JSON counts |
68
+ | `cckit gc` | report prunable branches + worktrees — never one whose issue is still open; aborts if the protection helper is missing | `--llm` → JSON counts |
69
+ | `cckit cleanup [--yes]` | the guided destructive sweep over that report: plan first, delete only the SAFE rows and prune the listed ZOMBIE metadata (staged work recovered to its branch first); ORPHAN / PROTECTED / stashes are never deletable | `--llm` → JSON counts + `applied` |
42
70
  | `cckit render` | stdin markdown → rich (glow on a TTY; verbatim when piped) | — |
43
71
  | `cckit version` | the installed cckit version | `--llm` |
44
72
 
45
73
  Every verb accepts a global `--llm` (alias `--output=json`); verbs that produce a result emit a
46
74
  single JSON object/array on stdout, with human text on stderr. Interactive/launch verbs
47
75
  (`init`, `orchestrate`, `autopilot`) have no JSON result — use `--dry-run` to inspect their plan.
76
+ `cckit brief` has no JSON form either, and deliberately: its output IS the prompt you hand a
77
+ delegated agent, so markdown is the machine-readable form. Read the facts behind it as data with
78
+ `cckit lib --llm` and `cckit status --llm`.
48
79
 
49
80
  > **`cckit plan-next` is the one exception to "feed verb output back to the model."** Its forward
50
81
  > plan is for the human/orchestrator's decision only — never inject it into a monitored model's
package/README.md CHANGED
@@ -90,17 +90,27 @@ cckit doctor # onboarding preflight: deps, gh auth
90
90
  cckit init --profile software # scaffold cckit.config.json + .claude/ for this repo
91
91
  # profiles: software · content · research · automation · minimal
92
92
  cckit plan-next # propose what to build next, grounded in current capabilities
93
+ cckit status # where are we: local undone work, PRs to attend, cleanup available
93
94
  cckit next # the next unblocked issue + how to start it
94
- cckit start 42 # isolated worktree + branch for issue #42
95
+ cckit start 42 # isolated worktree + branch for issue #42, bootstrapped:
96
+ # env files copied, dev port assigned, deps installed at the
97
+ # selected targets — worktree.installPaths if set (those dirs
98
+ # regardless of their manifests), else a root that declares
99
+ # deps or is a workspace root with members, else nothing
100
+ # (KIT_WT_INSTALL=0 skips the install entirely)
101
+ cckit brief 42 # the delegation brief for #42, read out of the repo not memory
102
+ cckit lib # every scripts/lib helper: functions, purpose, error contract
95
103
  cckit pr 42 "what changed" # commit, push, open the PR
96
104
  cckit sync # board state, what's unblocked
97
105
  cckit handoff "resume note" # save a handoff — bare `cckit` prints it next session
98
- cckit gc # prune merged branches + worktrees
106
+ cckit gc # report prunable branches + worktrees (deletes nothing)
107
+ cckit cleanup [--yes] # act on that report: delete the SAFE rows, prune listed zombies, keep orphans/stashes
99
108
  ```
100
109
 
101
110
  Adopting cckit in a repo that already has history? `cckit scan` detects the stack, `cckit adopt`
102
- records kit-shaped files the repo already has, and `cckit status` is the thin dashboard — board,
103
- worktrees, and the resume handoff in one screen. Run `cckit help` for the full verb list, or
111
+ records kit-shaped files the repo already has, and `cckit status` answers "where are we" — local
112
+ undone work, the open PRs waiting on a human, and the cleanup available, plus the board and the
113
+ resume handoff in one screen. Run `cckit help` for the full verb list, or
104
114
  `cckit <verb> --help` for any one.
105
115
 
106
116
  ## Efforts and slug handles
@@ -128,13 +138,72 @@ A pure-digits argument is always a number; anything else is resolved to the cano
128
138
  matching `effort/*` branches, the `slug:<slug>` label, then open effort titles. An unknown or
129
139
  ambiguous slug fails with a clear error rather than guessing. Efforts render as `slug #N`.
130
140
 
141
+ ### Ordering work — `cckit effort chain`
142
+
143
+ When several issues have to land in a set order, `cckit effort chain` declares that order once:
144
+
145
+ ```bash
146
+ cckit effort chain 241 242 243 # 242 blocked_by 241 · 243 blocked_by 242
147
+ ```
148
+
149
+ Each issue after the first gets a native GitHub `blocked_by` edge on its predecessor **and** a
150
+ `- Depends on #<predecessor>` line in its `## Relations` section — the same line
151
+ `cckit effort new --depends-on` writes, from the same formatter. Those `blocked_by` edges are
152
+ exactly what `cckit plan` reads, so a chained set lands one issue per wave, in the order you gave.
153
+
154
+ It is **idempotent**: an edge or a `Depends on` line that is already there is reported and skipped,
155
+ so re-running changes nothing. It only ever **adds** — an issue already blocked by something else
156
+ keeps that blocker and ends up with both. And it validates the whole chain before writing anything,
157
+ so a refusal leaves the board untouched: fewer than two numbers, an argument that is not an issue
158
+ number, an issue that does not exist, a number repeated in the list (`chain 1 2 1`), or an edge that
159
+ would close a cycle through dependencies GitHub already holds are all refused whole. A cycle is
160
+ refused rather than written because `cckit plan` cannot layer a cyclic graph into waves.
161
+
162
+ ### One at a time — the effort WIP limit
163
+
164
+ `cckit effort start` refuses to start a **new** effort once too many are already in progress:
165
+
166
+ ```console
167
+ $ cckit effort start 244
168
+ effort_start: 2 effort(s) already in progress and the WIP limit is 2.
169
+ · order-and-cadence #241 (effort/241-order-and-cadence)
170
+ · release-gates #257 (effort/257-release-gates)
171
+ → refusing to start #244 — nothing was created.
172
+ Close one with 'cckit effort close <N>', or start anyway with --force (or KIT_FORCE=1).
173
+ The limit is effort.wipLimit in the project config (default 2); EFFORT_WIP_LIMIT overrides it.
174
+ ```
175
+
176
+ **In progress** means an `effort/<N>-<slug>` branch exists — as a local head, **or** on origin, so
177
+ an effort another machine started counts too. `cckit effort start` creates the branch and
178
+ `cckit effort close` deletes it, so the set is exactly "started and not yet closed".
179
+
180
+ The origin half is read with `git ls-remote` on each `cckit effort start`, not from your cached
181
+ `refs/remotes`, because the cache is wrong in both directions: a branch pushed since your last fetch
182
+ is missing from it, and a branch deleted on origin lingers in it until a prune. One network
183
+ round-trip buys a count that is right either way.
184
+
185
+ - The check runs **before** the fetch, the branch, the worktree and the bootstrap, so a refusal
186
+ makes **no branch, no worktree and no board change**.
187
+ - **At** the limit refuses; only strictly under it starts. The default limit is `2`.
188
+ - Re-running `cckit effort start` on an effort that is **already** in progress is never gated — it
189
+ adds no WIP, so the verb stays safe to re-run even at or over the limit.
190
+ - `--force` (or `KIT_FORCE=1`, the same escape hatch `cckit effort close` uses) starts anyway.
191
+ - Set your own limit with `effort.wipLimit` in `cckit.config.json`; `0` refuses every ordinary
192
+ start, **though `--force` still works**. A value that is not a non-negative integer is ignored
193
+ with a warning and the default `2` is used. `EFFORT_WIP_LIMIT` in the environment overrides the
194
+ config per invocation.
195
+ - This gates **efforts only**. `cckit start <issue>` (a plain task worktree) has no WIP limit.
196
+ - **No network, no problem.** `EFFORT_WIP_REMOTE=0` skips the origin query and counts local heads
197
+ plus your cached `refs/remotes`. If origin is simply unreachable, the count falls back to those
198
+ same cached refs, prints one line saying the count may be stale, and the start proceeds.
199
+
131
200
  ## Waves — parallel agentic development
132
201
 
133
202
  `cckit wave` reads your open efforts and proposes the incoming waves of work — parallel agent tasks
134
203
  that gate and merge themselves. This is the part that turns one keyboard into a small team:
135
204
 
136
205
  ```bash
137
- cckit plan # the wave plan: deps-ordered, file-disjoint, session-fit
206
+ cckit plan # the wave plan: deps-ordered, p0-first inside a wave, file-disjoint
138
207
  cckit wave # a Task-subagent fan-out brief Claude Code enacts (proposes the next wave)
139
208
  cckit orchestrate 12 14 17 # run N flows in parallel worktrees (--dry-run / --cap / --agent)
140
209
  cckit watch --merge # the captain: gate open PRs, squash-merge the CLEAN ones, advance
@@ -156,7 +225,9 @@ cckit wave --llm # the fan-out (one subagent prompt per issue) as TOON
156
225
  ```
157
226
 
158
227
  Human output renders as markdown — rich via `glow` in a terminal, native in the Claude Code
159
- transcript, pipe-safe everywhere (`cckit render` exposes the seam for any script).
228
+ transcript, pipe-safe everywhere. Every human-facing verb (`sync`, `plan`, `next`, `status`) shares
229
+ one rendering seam, so board tables, wave plans, and the status dashboard read the same in every
230
+ surface and never leak escape codes down a pipe (`cckit render` exposes the seam for any script).
160
231
 
161
232
  ## cckit builds cckit
162
233
 
@@ -166,6 +237,14 @@ public: [every issue closed in the repo →](https://github.com/jeiemgi/cckit/is
166
237
  — including [the effort that produced this README](https://github.com/jeiemgi/cckit/issues/160).
167
238
  The board is both the plan and the proof.
168
239
 
240
+ cckit also runs on the rules and skills it ships. `templates/` is what `cckit init` writes into a
241
+ project; `.claude/skills/` and `.claude/rules/` here are the subset cckit applies to its own work —
242
+ `concrete` (the anti-slop catalogue every commit and PR body goes through) and
243
+ `karpathy-guidelines`, plus the rules that govern this repo's branches, efforts, PR titles and
244
+ delegation. It is a subset on purpose: several templates target stacks cckit does not have.
245
+ `scripts/self-install-test.sh` holds the manifest, the reason for every skip, and the assertion that
246
+ the installed copies have not drifted from their templates.
247
+
169
248
  ## Documentation
170
249
 
171
250
  Full docs live at **[cckit.dev](https://cckit.dev)** — start with
@@ -182,14 +261,24 @@ prompt** you can paste straight into Claude Code — start exactly where you are
182
261
  cckit/
183
262
  bin/cckit # the CLI dispatcher
184
263
  scripts/lib/*.sh # the git-mechanics bundle (effort, worktree, gh, gc, …)
264
+ # each declares `# errors:` — see CONTRIBUTING.md
265
+ scripts/benchmark/ # doc-retrieval benchmark harness (cckit bench)
185
266
  .claude-plugin/ # the Claude Code plugin manifest
186
267
  skills/ commands/ # Claude Code skills + slash commands
187
268
  profiles/ templates/ # init profiles + scaffold templates
188
269
  routines/ modules/ # scheduled routines + optional modules
189
270
  docs-site/ # documentation source — Astro/Starlight (deployed to cckit.dev)
271
+ .claude/skills/ # the subset of templates/skills/ cckit installs for ITSELF
272
+ .claude/rules/ # the subset of templates/rules/ cckit installs for ITSELF
273
+ # the manifest + every skip reason: scripts/self-install-test.sh
190
274
  cckit.config.json # project configuration (no hardcoded org/repo)
191
275
  ```
192
276
 
277
+ `cckit init` also scaffolds `benchmarks/` — a per-project **documentation benchmark** that scores how
278
+ well an agent finds and uses your own canonical docs (retrieval / adversarial / abstain / quality
279
+ tiers). Run `cckit bench report` after a docs or kit-version change to catch findability regressions;
280
+ see the [benchmark guide](https://cckit.dev/benchmark/).
281
+
193
282
  ## Built with cckit
194
283
 
195
284
  Using cckit in your project? Add a badge (optional, but appreciated):
package/bin/cckit CHANGED
@@ -13,12 +13,20 @@
13
13
  # cckit close <issue> <summary> close issue + mark done
14
14
  # cckit contribute "<summary>" open a contribution PR to cckit, gated on scripts/check.sh
15
15
  # cckit sync [--llm] board state / what's unblocked
16
- # cckit plan [--llm] [--effort N] wave plan: deps-ordered, file-disjoint, session-fit (TOON --llm)
16
+ # cckit plan [--llm] [--effort N] wave plan: deps-ordered, p0-first in a wave, file-disjoint (TOON --llm)
17
17
  # cckit plan-next [--llm] forward plan: current skills/verbs/rules/docs -> what to build next
18
- # cckit effort <new|start|pr|close|plan> the effort lifecycle
18
+ # cckit effort <new|chain|start|pr|close|plan> the effort lifecycle
19
19
  # effort new [--flow F --role R --priority p1 --goal G --scope S --for-agents A
20
20
  # --verification V --depends-on "#1,#2" --milestone M] "<name>" ["sub :: desc" …]
21
21
  # parent (4-section body + ctx/kind/priority/role/flow labels) + linted native sub-issues
22
+ # effort chain <a> <b> [<c> …] linear order: b blocked_by a, c blocked_by b, + a
23
+ # `Depends on #<predecessor>` line in each body. Idempotent; refuses a cycle.
24
+ # effort start [--force] <slug|N> [slug] effort branch + worktree, WIP-limited: refuses a NEW
25
+ # effort once effort.wipLimit (default 2) are already in progress — an `effort/<N>-<slug>`
26
+ # branch exists locally or on origin (git ls-remote, not the cached refs/remotes;
27
+ # EFFORT_WIP_REMOTE=0 or an unreachable origin uses the cache and still starts). Refuses
28
+ # before writing anything; --force (or KIT_FORCE=1) starts anyway, at limit 0 too.
29
+ # `cckit start <issue>` is not affected.
22
30
  # cckit orchestrate <a> <b> … run N flows in parallel worktrees (--dry-run/--cap/--agent)
23
31
  # cckit autopilot [<a> …] unattended multi-flow: drive (or auto-pick) issues under a cap
24
32
  # cckit watch [--merge] [--loop] captain: gate open PRs, squash-merge CLEAN, advance the wave
@@ -26,6 +34,7 @@
26
34
  # cckit wave [--effort N] read open efforts, propose incoming waves: fan-out + captain drive
27
35
  # cckit msg <send|read|list> session mail across projects: steer a live session (--steer)
28
36
  # cckit gc [--prune [--yes]] report (default) or prune merged branches + worktrees
37
+ # cckit cleanup [--yes] guided destructive sweep over the gc report (plan first)
29
38
  # cckit status thin dashboard: board + worktrees + resume handoff
30
39
  # cckit scan [--llm] detect this repo's stack + kit state (JSON)
31
40
  # cckit debug [--check] <args> optional browser-debug via chrome-devtools-axi (auto-detected)
@@ -36,9 +45,12 @@
36
45
  # cckit migrate reshuffle an old kit layout to the current one
37
46
  # cckit adopt record kit-shaped files a repo already has into the manifest
38
47
  # cckit digest <path|url> summarize a file or URL (local model)
48
+ # cckit bench [run|report|…] doc-retrieval benchmark: score how well docs are found + used
39
49
  # cckit release <ver> [--publish] cut a release (dry-run by default)
40
50
  # cckit version [--llm] the installed cckit version
41
51
  # cckit commands [--llm] list every verb (the command catalog)
52
+ # cckit lib [--llm] [--all] list every scripts/lib helper: functions, purpose, error contract
53
+ # cckit brief <issue> the delegation brief for an issue, from real state
42
54
  # cckit completions [bash|zsh] print a shell-completion script to source
43
55
  # cckit help
44
56
  set -eu
@@ -127,11 +139,12 @@ case "$cmd" in
127
139
  source "$LIB/role-identity.sh" 2>/dev/null || true
128
140
  fi
129
141
  effort_new "$@" ;;
142
+ chain) effort_chain "$@" ;;
130
143
  start) effort_start "$@" ;;
131
144
  pr) effort_pr "$@" ;;
132
145
  close) effort_close "$@" ;;
133
146
  plan) source "$LIB/effort-plan.sh"; effort_plan "$@" ;;
134
- *) echo "cckit effort <new|start|pr|close|plan>" >&2; exit 2 ;;
147
+ *) echo "cckit effort <new|chain|start|pr|close|plan>" >&2; exit 2 ;;
135
148
  esac
136
149
  ;;
137
150
  start)
@@ -188,6 +201,38 @@ case "$cmd" in
188
201
  # shellcheck source=/dev/null
189
202
  source "$LIB/plan-next.sh"; plan_next "$@"
190
203
  ;;
204
+ cleanup)
205
+ # ONE guided destructive sweep over the gc analysis: plan first, delete only the SAFE rows, and
206
+ # only with --yes. Orphans, protected branches and stashes are surfaced and left alone.
207
+ # shellcheck source=/dev/null
208
+ source "$LIB/kit-config.sh" && load_kit_config
209
+ # shellcheck source=/dev/null
210
+ source "$LIB/kit-gc.sh"
211
+ if cckit_is_json; then
212
+ # Keep BOTH the exit status and the diagnostic. `|| true` + `2>/dev/null` would turn a refusal
213
+ # (protection helper missing, analysis failed) or a partial run (a remote delete that failed)
214
+ # into `applied: yes` with zero counts and rc 0 — a JSON consumer would read that as a clean
215
+ # sweep. Reporting a wrong success is the failure mode this whole op exists to avoid.
216
+ cleanup_err="$(mktemp)"; cleanup_rc=0
217
+ out="$(kit_gc_cleanup "$@" 2>"$cleanup_err")" || cleanup_rc=$?
218
+ safe="$(printf '%s\n' "$out" | awk '/^ SAFE branches/{print $3}')"
219
+ wt="$(printf '%s\n' "$out" | awk '/^ SAFE worktrees/{print $3}')"
220
+ orphan="$(printf '%s\n' "$out" | awk '/^ ORPHAN kept/{print $3}')"
221
+ protected="$(printf '%s\n' "$out" | awk '/^ PROTECTED kept/{print $3}')"
222
+ stash="$(printf '%s\n' "$out" | awk '/^ stashes kept/{print $3}')"
223
+ zombie="$(printf '%s\n' "$out" | awk '/^ ZOMBIE worktrees/{print $3}')"
224
+ rfail="$(printf '%s\n' "$out" | awk '/^ remote deletes failed/{print $4}')"
225
+ applied=no
226
+ if [ "$cleanup_rc" -eq 0 ]; then case " $* " in *" --yes "*|*" -y "*) applied=yes ;; esac; fi
227
+ err="$(tr '\n' ' ' < "$cleanup_err" | sed 's/[[:space:]]*$//')"; rm -f "$cleanup_err"
228
+ cckit_json verb cleanup safe "${safe:-0}" worktrees "${wt:-0}" orphan "${orphan:-0}" \
229
+ protected "${protected:-0}" stash "${stash:-0}" zombie "${zombie:-0}" applied "$applied" \
230
+ remote_failed "${rfail:-0}" rc "$cleanup_rc" error "$err"
231
+ [ "$cleanup_rc" -eq 0 ] || exit "$cleanup_rc"
232
+ else
233
+ kit_gc_cleanup "$@"
234
+ fi
235
+ ;;
191
236
  gc)
192
237
  # shellcheck source=/dev/null
193
238
  source "$LIB/kit-config.sh" && load_kit_config
@@ -259,6 +304,23 @@ case "$cmd" in
259
304
  adopt) exec "$ROOT/scripts/kit-adopt.sh" "$@" ;;
260
305
  doctor) exec "$ROOT/scripts/kit-doctor.sh" "$@" ;;
261
306
  digest) exec "$ROOT/scripts/kit-digest.sh" "$@" ;;
307
+ bench)
308
+ # Documentation benchmark (#200) — score how well this project finds + uses its OWN canonical
309
+ # docs. Runs the PROJECT's scaffolded harness if present, else cckit's own copy. BENCH_KIT_ROOT
310
+ # lets the runner fall back to the shipped example set before a project grows its own data.
311
+ BENCH_ROOT="$PWD/scripts/benchmark"; [ -d "$BENCH_ROOT" ] || BENCH_ROOT="$ROOT/scripts/benchmark"
312
+ export BENCH_KIT_ROOT="$ROOT"
313
+ sub="${1:-report}"; shift || true
314
+ case "$sub" in
315
+ run) exec bash "$BENCH_ROOT/run.sh" "$@" ;;
316
+ quality) exec bash "$BENCH_ROOT/run-quality.sh" "$@" ;;
317
+ report) exec bash "$BENCH_ROOT/report.sh" "$@" ;;
318
+ gate) exec bash "$BENCH_ROOT/gate.sh" "$@" ;;
319
+ stop-check) exec bash "$BENCH_ROOT/stop-check.sh" "$@" ;;
320
+ -h|--help) echo 'cckit bench <run|quality|report|gate|stop-check> [--dry] [--json]'; exit 0 ;;
321
+ *) echo 'cckit bench <run|quality|report|gate|stop-check> [--dry] [--json]' >&2; exit 2 ;;
322
+ esac
323
+ ;;
262
324
  scan) source "$LIB/project-scan.sh"; project_scan "$@" ;;
263
325
  encode-context) source "$LIB/toon.sh"; toon_encode ;;
264
326
  render) source "$LIB/render.sh"; cckit_render ;;
@@ -286,6 +348,31 @@ case "$cmd" in
286
348
  verbs="$(grep -oE '^ [a-z][a-z|-]*\)' "$BIN/cckit" | sed 's/[) ]//g' | tr '|' '\n' | grep -vE '^(-|$)' | sort -u)"
287
349
  if cckit_is_json; then printf '%s\n' "$verbs" | jq -R . | jq -cs .; else printf '%s\n' "$verbs" | tr '\n' ' '; echo; fi
288
350
  ;;
351
+ lib)
352
+ # The HELPER catalog — the companion to `commands` (#222). `commands` lists the verbs; this
353
+ # lists the library they are built from, so a helper like pr-evidence.sh is discoverable
354
+ # without an `ls`. Filesystem-only; config is loaded purely for the project-root inference
355
+ # (KIT_CONFIG), then it catalogs that project's scripts/lib, else cckit's own.
356
+ # shellcheck source=/dev/null
357
+ source "$LIB/kit-config.sh" && load_kit_config 2>/dev/null || true
358
+ # shellcheck source=/dev/null
359
+ source "$LIB/kit-lib.sh"; kit_lib "$@"
360
+ ;;
361
+ brief)
362
+ # The delegation BRIEF for an issue, generated from real state (#221). The companion to `lib`:
363
+ # `lib` says what helpers exist, this says which of them THIS issue's files sit on, where the
364
+ # work happens, and whether the branch's seed is stale. Reads the issue via gh; every other
365
+ # section degrades to an explicit line rather than going quietly missing.
366
+ # shellcheck source=/dev/null
367
+ source "$LIB/kit-config.sh" && load_kit_config 2>/dev/null || true
368
+ # shellcheck source=/dev/null
369
+ source "$LIB/worktree-issue.sh" 2>/dev/null || true
370
+ # shellcheck source=/dev/null
371
+ source "$LIB/kit-lib.sh"
372
+ # shellcheck source=/dev/null
373
+ source "$LIB/kit-brief.sh"
374
+ CCKIT_ROOT="$ROOT" kit_brief "$@"
375
+ ;;
289
376
  completions)
290
377
  case "${1:-bash}" in
291
378
  bash) cat "$ROOT/completions/cckit.bash" ;;
package/cckit.config.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "./kit.config.schema.json",
3
- "kitVersion": "0.5.0",
3
+ "kitVersion": "0.7.0",
4
4
  "project": {
5
5
  "name": "cckit",
6
6
  "slug": "cckit",
@@ -12,7 +12,7 @@
12
12
  "github": {
13
13
  "repo": "jeiemgi/cckit",
14
14
  "owner": "jeiemgi",
15
- "baseBranch": "main",
15
+ "baseBranch": "develop",
16
16
  "projectsV2": false,
17
17
  "projectNumber": null,
18
18
  "projectTitle": null
@@ -30,5 +30,10 @@
30
30
  },
31
31
  "engine": {
32
32
  "mode": "off"
33
+ },
34
+ "captain": {
35
+ "mergePolicy": {
36
+ "requireChecks": true
37
+ }
33
38
  }
34
39
  }
@@ -69,7 +69,8 @@
69
69
  "additionalProperties": true,
70
70
  "properties": {
71
71
  "flows": { "type": "array", "items": { "type": "string" }, "description": "Controlled flow vocabulary for effort titles — the values accepted by the leading [Flow] title tag and `--flow` (also the flow:<flow> labels). Replaces the built-in default (Core UI API Docs Infra Auth Data Web App); an explicit EFFORT_FLOWS env var still wins per invocation." },
72
- "knowledgeIngestHook": { "type": "string", "description": "Optional path to an executable run after `cckit effort close`, invoked as `<hook> <effort-number> <trace-dir>` to fold the closed effort's work record into a knowledge base. No-op when unset or not executable; the kit ships no default." }
72
+ "knowledgeIngestHook": { "type": "string", "description": "Optional path to an executable run after `cckit effort close`, invoked as `<hook> <effort-number> <trace-dir>` to fold the closed effort's work record into a knowledge base. No-op when unset or not executable; the kit ships no default." },
73
+ "wipLimit": { "type": "integer", "minimum": 0, "description": "How many efforts may be in progress at once before `cckit effort start` refuses a NEW effort (default 2). In progress = an `effort/<N>-<slug>` branch exists as a local head or on origin (read with `git ls-remote`, not the cached refs/remotes; EFFORT_WIP_REMOTE=0 or an unreachable origin counts the cached refs instead). Refusal happens before anything is written; `--force` (or KIT_FORCE=1) starts anyway. 0 refuses every ordinary start of a NEW effort but not a forced one, and not a re-start of an effort already in progress (that adds no WIP, so it is never gated); a non-integer value is ignored with a warning and the default is used. An explicit EFFORT_WIP_LIMIT env var wins per invocation. Does not affect `cckit start <issue>`." }
73
74
  }
74
75
  },
75
76
  "captain": {
@@ -125,6 +126,30 @@
125
126
  "description": "Map of original scaffolded path -> the project's new name. The original (key) is treated as removed (never re-added); the value documents where it went."
126
127
  }
127
128
  }
129
+ },
130
+ "worktree": {
131
+ "type": "object",
132
+ "additionalProperties": true,
133
+ "description": "How `cckit start` / `cckit effort start` bootstrap a fresh worktree (env copy, dev port, dependency install). Every key is optional; the kit hardcodes no project layout.",
134
+ "properties": {
135
+ "installPaths": {
136
+ "type": "array",
137
+ "items": { "type": "string" },
138
+ "description": "Worktree-relative directories to run `pnpm install` in during bootstrap (e.g. [\"docs-site\"]). Set, it wins outright — only these dirs are installed and the checks below are skipped; [] installs nothing. Entries MUST stay inside the worktree: an absolute path, a `..` that climbs out, or a symlink pointing outside is refused and skipped. Unset: install at the root only when its package.json declares dependencies or it is a workspace root WITH AT LEAST ONE MEMBER — a dependency-free root (or an empty `packages:` / `workspaces` list) is skipped so pnpm cannot plant an empty pnpm-lock.yaml (#255). KIT_WT_INSTALL=0 skips the install entirely."
139
+ },
140
+ "devPorts": {
141
+ "type": "array",
142
+ "description": "Per-app dev PORT lanes. Each entry assigns PORT = base + (issue % 40) * <count> into that app's .env.local, so parallel worktrees never fight for a port.",
143
+ "items": {
144
+ "type": "object",
145
+ "additionalProperties": true,
146
+ "properties": {
147
+ "path": { "type": "string", "description": "Repo-relative path to the app's .env.local file." },
148
+ "base": { "type": "integer", "description": "Base port for this app's lane." }
149
+ }
150
+ }
151
+ }
152
+ }
128
153
  }
129
154
  }
130
155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeiemgi/cckit",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "private": false,
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "description": "cckit — a project operating system for coding agents (CLI + Claude Code plugin).",
@@ -9,7 +9,8 @@
9
9
  ],
10
10
  "skills": [
11
11
  "morning-briefing",
12
- "karpathy-guidelines"
12
+ "karpathy-guidelines",
13
+ "concrete"
13
14
  ],
14
15
  "rules": [
15
16
  "branch-naming",
@@ -11,7 +11,8 @@
11
11
  "skills": [
12
12
  "morning-briefing",
13
13
  "copywriting",
14
- "karpathy-guidelines"
14
+ "karpathy-guidelines",
15
+ "concrete"
15
16
  ],
16
17
  "rules": [
17
18
  "branch-naming",
@@ -7,7 +7,8 @@
7
7
  "generalist"
8
8
  ],
9
9
  "skills": [
10
- "karpathy-guidelines"
10
+ "karpathy-guidelines",
11
+ "concrete"
11
12
  ],
12
13
  "rules": [
13
14
  "communication-style",
@@ -9,7 +9,8 @@
9
9
  ],
10
10
  "skills": [
11
11
  "morning-briefing",
12
- "karpathy-guidelines"
12
+ "karpathy-guidelines",
13
+ "concrete"
13
14
  ],
14
15
  "rules": [
15
16
  "branch-naming",
@@ -8,7 +8,8 @@
8
8
  "speckit",
9
9
  "feature-build-refine",
10
10
  "supabase-patterns",
11
- "karpathy-guidelines"
11
+ "karpathy-guidelines",
12
+ "concrete"
12
13
  ],
13
14
  "rules": [
14
15
  "branch-naming",
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env bash
2
+ # benchmark-test.sh — self-test for the benchmark harness (#200). Offline only: the mock backend +
3
+ # --dry paths, so it never calls a real model. Run: bash scripts/benchmark/benchmark-test.sh
4
+ set -uo pipefail
5
+ HERE="$(cd "$(dirname "$0")" && pwd)"
6
+
7
+ fail=0
8
+ t() { if [ "$2" != "$3" ]; then echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; else echo "ok: $1"; fi; }
9
+
10
+ command -v jq >/dev/null 2>&1 || { echo "SKIP: jq absent"; exit 0; }
11
+
12
+ # ---- isolated fixture ------------------------------------------------------
13
+ FIX="$(mktemp -d)"; trap 'rm -rf "$FIX"' EXIT
14
+ mkdir -p "$FIX/bench"
15
+ cat > "$FIX/bench/benchmark.config.json" <<'JSON'
16
+ { "knowledgeDir": "knowledge",
17
+ "sets": [
18
+ {"name":"retrieval","file":"retrieval.jsonl","tier":"retrieval"},
19
+ {"name":"abstain","file":"abstain.jsonl","tier":"abstain"},
20
+ {"name":"quality","file":"quality.jsonl","tier":"quality"} ],
21
+ "target": {"minRecords": 3, "cleanRounds": 2} }
22
+ JSON
23
+ printf '%s\n' '{"id":"r1","q":"How do we release?","expect":"releasing.md"}' \
24
+ '{"id":"r2","q":"Branch model?","expect":["branching.md","git.md"]}' > "$FIX/bench/retrieval.jsonl"
25
+ printf '%s\n' '{"id":"a1","q":"DB password?","expect":"NONE"}' > "$FIX/bench/abstain.jsonl"
26
+ printf '%s\n' '{"id":"q1","claim":"Summarize releasing.","must":["version bumped","tag pushed"]}' > "$FIX/bench/quality.jsonl"
27
+
28
+ export BENCH_DIR="$FIX/bench"
29
+
30
+ # ---- 1. --dry on well-formed data passes -----------------------------------
31
+ bash "$HERE/run.sh" --dry >/dev/null 2>&1; t "run --dry well-formed" "$?" "0"
32
+ bash "$HERE/run-quality.sh" --dry >/dev/null 2>&1; t "quality --dry well-formed" "$?" "0"
33
+
34
+ # ---- 2. --dry catches a malformed record -----------------------------------
35
+ printf '%s\n' '{"id":"bad","expect":"x.md"}' >> "$FIX/bench/retrieval.jsonl" # no q
36
+ bash "$HERE/run.sh" --dry >/dev/null 2>&1; t "run --dry missing q fails" "$?" "1"
37
+ # restore
38
+ printf '%s\n' '{"id":"r1","q":"How do we release?","expect":"releasing.md"}' \
39
+ '{"id":"r2","q":"Branch model?","expect":["branching.md","git.md"]}' > "$FIX/bench/retrieval.jsonl"
40
+
41
+ # ---- 3. abstain record with a stray expect path is caught? (abstain allows NONE only, so a non-
42
+ # abstain tier needs an expect; abstain with NONE is fine — validate a retrieval with NONE) -
43
+ printf '%s\n' '{"id":"noexp","q":"orphan?","expect":"NONE"}' >> "$FIX/bench/retrieval.jsonl"
44
+ bash "$HERE/run.sh" --dry >/dev/null 2>&1; t "run --dry retrieval w/ NONE expect fails" "$?" "1"
45
+ printf '%s\n' '{"id":"r1","q":"How do we release?","expect":"releasing.md"}' \
46
+ '{"id":"r2","q":"Branch model?","expect":["branching.md","git.md"]}' > "$FIX/bench/retrieval.jsonl"
47
+
48
+ # ---- 4. path matching ------------------------------------------------------
49
+ # shellcheck source=/dev/null
50
+ . "$HERE/lib/bench-common.sh"
51
+ bench_path_match "knowledge/releasing.md" '"releasing.md"'; t "match: kdir prefix stripped" "$?" "0"
52
+ bench_path_match "./releasing.md" '"releasing.md"'; t "match: ./ stripped" "$?" "0"
53
+ bench_path_match "git.md" '["branching.md","git.md"]'; t "match: array member" "$?" "0"
54
+ bench_path_match "other.md" '"releasing.md"'; t "no-match: different doc" "$?" "1"
55
+
56
+ # ---- 5. mock live scoring (mock backend always returns NONE) ----------------
57
+ # retrieval records fail (NONE != a path); the abstain record passes (NONE is correct).
58
+ res="$(BENCH_BACKEND=mock bash "$HERE/run.sh" --json 2>/dev/null)"
59
+ t "mock: abstain passes only" "$(printf '%s' "$res" | jq -r '.pass')" "1"
60
+ t "mock: retrieval both fail" "$(printf '%s' "$res" | jq -r '.fail')" "2"
61
+
62
+ # ---- 6. gate.sh clean on well-formed fixture -------------------------------
63
+ BENCH_SKIP_KNOWLEDGE_LINT=1 bash "$HERE/gate.sh" >/dev/null 2>&1; t "gate clean" "$?" "0"
64
+
65
+ # ---- 7. stop-check: size met but streak < rounds -> CONTINUE; 2nd clean -> STOP ----
66
+ rm -f "$FIX/bench/.stop-state.json"
67
+ BENCH_SKIP_KNOWLEDGE_LINT=1 bash "$HERE/stop-check.sh" >/dev/null 2>&1; rc1=$?
68
+ BENCH_SKIP_KNOWLEDGE_LINT=1 bash "$HERE/stop-check.sh" >/dev/null 2>&1; rc2=$?
69
+ t "stop-check round1 CONTINUE" "$rc1" "1"
70
+ t "stop-check round2 STOP" "$rc2" "0"
71
+
72
+ # ---- 8. stop-check below size target never stops ---------------------------
73
+ # minRecords=99 forces size_ok=false regardless of clean streak.
74
+ rm -f "$FIX/bench/.stop-state.json"
75
+ BENCH_SKIP_KNOWLEDGE_LINT=1 bash "$HERE/stop-check.sh" --min 99 >/dev/null 2>&1; t "stop-check below size CONTINUE" "$?" "1"
76
+
77
+ # ---- 9. report.sh writes a RESULTS.md --------------------------------------
78
+ bash "$HERE/report.sh" --dry --out "$FIX/RESULTS.md" >/dev/null 2>&1
79
+ t "report wrote RESULTS.md" "$([ -s "$FIX/RESULTS.md" ] && echo yes)" "yes"
80
+ grep -q "Documentation benchmark" "$FIX/RESULTS.md"; t "report has heading" "$?" "0"
81
+
82
+ [ "$fail" -eq 0 ] && echo "ALL OK" || echo "SOME FAILED"
83
+ exit "$fail"