@arbiterforge/ca-pi 0.6.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 (206) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +558 -0
  3. package/package.json +35 -0
  4. package/plugins/ca-pi/CHANGELOG.md +1030 -0
  5. package/plugins/ca-pi/COMMANDS.md +90 -0
  6. package/plugins/ca-pi/ORCHESTRATOR.md +159 -0
  7. package/plugins/ca-pi/SKILLS.md +47 -0
  8. package/plugins/ca-pi/SPRINT.md +142 -0
  9. package/plugins/ca-pi/agents/INDEX.md +31 -0
  10. package/plugins/ca-pi/agents/architecture-drift-reviewer.md +86 -0
  11. package/plugins/ca-pi/agents/auth-crypto-reviewer.md +60 -0
  12. package/plugins/ca-pi/agents/backend-author.md +60 -0
  13. package/plugins/ca-pi/agents/checkpoint-aggregator.md +111 -0
  14. package/plugins/ca-pi/agents/coverage-auditor.md +71 -0
  15. package/plugins/ca-pi/agents/decision-challenger.md +116 -0
  16. package/plugins/ca-pi/agents/dependency-reviewer.md +79 -0
  17. package/plugins/ca-pi/agents/design-quality-reviewer.md +80 -0
  18. package/plugins/ca-pi/agents/finding-triage.md +86 -0
  19. package/plugins/ca-pi/agents/frontend-author.md +64 -0
  20. package/plugins/ca-pi/agents/grader.md +173 -0
  21. package/plugins/ca-pi/agents/infra-author.md +64 -0
  22. package/plugins/ca-pi/agents/map-deps.md +35 -0
  23. package/plugins/ca-pi/agents/map-structure.md +37 -0
  24. package/plugins/ca-pi/agents/migration-reviewer.md +65 -0
  25. package/plugins/ca-pi/agents/scout.md +127 -0
  26. package/plugins/ca-pi/agents/security-reviewer.md +72 -0
  27. package/plugins/ca-pi/agents/tribunal-lens-reviewer.md +65 -0
  28. package/plugins/ca-pi/extensions/codearbiter-child.js +1885 -0
  29. package/plugins/ca-pi/extensions/codearbiter.js +9802 -0
  30. package/plugins/ca-pi/generated/command-catalog.json +197 -0
  31. package/plugins/ca-pi/generated/roles.json +213 -0
  32. package/plugins/ca-pi/helpers/windows-supervisor.js +205 -0
  33. package/plugins/ca-pi/hooks/_activationlib.py +196 -0
  34. package/plugins/ca-pi/hooks/_arbiterstatelib.py +208 -0
  35. package/plugins/ca-pi/hooks/_babysitlib.py +76 -0
  36. package/plugins/ca-pi/hooks/_bashguardlib.py +1667 -0
  37. package/plugins/ca-pi/hooks/_boxlib.py +131 -0
  38. package/plugins/ca-pi/hooks/_colorlib.py +304 -0
  39. package/plugins/ca-pi/hooks/_durabilitylib.py +186 -0
  40. package/plugins/ca-pi/hooks/_entrylib.py +41 -0
  41. package/plugins/ca-pi/hooks/_fmtlib.py +161 -0
  42. package/plugins/ca-pi/hooks/_gitexec.py +45 -0
  43. package/plugins/ca-pi/hooks/_githooks.py +920 -0
  44. package/plugins/ca-pi/hooks/_gitlib.py +110 -0
  45. package/plugins/ca-pi/hooks/_hooklib.py +595 -0
  46. package/plugins/ca-pi/hooks/_host.py +115 -0
  47. package/plugins/ca-pi/hooks/_intentlib.py +242 -0
  48. package/plugins/ca-pi/hooks/_ledgerlib.py +1035 -0
  49. package/plugins/ca-pi/hooks/_metricslib.py +709 -0
  50. package/plugins/ca-pi/hooks/_pathnorm.py +74 -0
  51. package/plugins/ca-pi/hooks/_planfilelib.py +664 -0
  52. package/plugins/ca-pi/hooks/_previewlib.py +193 -0
  53. package/plugins/ca-pi/hooks/_protectedlib.py +312 -0
  54. package/plugins/ca-pi/hooks/_protectedstatelib.py +411 -0
  55. package/plugins/ca-pi/hooks/_provenancelib.py +971 -0
  56. package/plugins/ca-pi/hooks/_prunelib.py +1398 -0
  57. package/plugins/ca-pi/hooks/_prunepolicy.py +235 -0
  58. package/plugins/ca-pi/hooks/_readinjectlib.py +1080 -0
  59. package/plugins/ca-pi/hooks/_releaselib.py +2657 -0
  60. package/plugins/ca-pi/hooks/_scopelib.py +262 -0
  61. package/plugins/ca-pi/hooks/_segmentslib.py +278 -0
  62. package/plugins/ca-pi/hooks/_sensitivelib.py +270 -0
  63. package/plugins/ca-pi/hooks/_sessionlib.py +78 -0
  64. package/plugins/ca-pi/hooks/_sloplib.py +244 -0
  65. package/plugins/ca-pi/hooks/_standuplib.py +214 -0
  66. package/plugins/ca-pi/hooks/_subagentslib.py +219 -0
  67. package/plugins/ca-pi/hooks/_taskboardlib.py +1088 -0
  68. package/plugins/ca-pi/hooks/_updatelib.py +278 -0
  69. package/plugins/ca-pi/hooks/babysit.py +47 -0
  70. package/plugins/ca-pi/hooks/boardsync.py +129 -0
  71. package/plugins/ca-pi/hooks/doctor.py +420 -0
  72. package/plugins/ca-pi/hooks/git-enforce.py +325 -0
  73. package/plugins/ca-pi/hooks/hostapi.py +460 -0
  74. package/plugins/ca-pi/hooks/init-codearbiter.py +225 -0
  75. package/plugins/ca-pi/hooks/metrics.py +62 -0
  76. package/plugins/ca-pi/hooks/migration-pass.py +129 -0
  77. package/plugins/ca-pi/hooks/pi-bridge.py +543 -0
  78. package/plugins/ca-pi/hooks/post-write-edit.py +231 -0
  79. package/plugins/ca-pi/hooks/pre-bash.py +90 -0
  80. package/plugins/ca-pi/hooks/pre-edit.py +284 -0
  81. package/plugins/ca-pi/hooks/pre-read.py +81 -0
  82. package/plugins/ca-pi/hooks/pre-write.py +217 -0
  83. package/plugins/ca-pi/hooks/preview.py +69 -0
  84. package/plugins/ca-pi/hooks/prune-transcript.py +232 -0
  85. package/plugins/ca-pi/hooks/releasehash.py +216 -0
  86. package/plugins/ca-pi/hooks/security-pass.py +139 -0
  87. package/plugins/ca-pi/hooks/session-start.py +1218 -0
  88. package/plugins/ca-pi/hooks/statusline.py +736 -0
  89. package/plugins/ca-pi/hooks/taskwrite.py +351 -0
  90. package/plugins/ca-pi/hooks/update-refresh.py +51 -0
  91. package/plugins/ca-pi/hooks/wire-statusline.py +435 -0
  92. package/plugins/ca-pi/includes/anti-slop-design/INDEX.md +55 -0
  93. package/plugins/ca-pi/includes/anti-slop-design/color.md +43 -0
  94. package/plugins/ca-pi/includes/anti-slop-design/core.md +244 -0
  95. package/plugins/ca-pi/includes/anti-slop-design/images.md +32 -0
  96. package/plugins/ca-pi/includes/anti-slop-design/layout.md +45 -0
  97. package/plugins/ca-pi/includes/anti-slop-design/medium-cli.md +39 -0
  98. package/plugins/ca-pi/includes/anti-slop-design/medium-dataviz.md +43 -0
  99. package/plugins/ca-pi/includes/anti-slop-design/medium-diagram.md +35 -0
  100. package/plugins/ca-pi/includes/anti-slop-design/medium-documents.md +70 -0
  101. package/plugins/ca-pi/includes/anti-slop-design/medium-slides.md +30 -0
  102. package/plugins/ca-pi/includes/anti-slop-design/medium-web.md +39 -0
  103. package/plugins/ca-pi/includes/anti-slop-design/typography.md +51 -0
  104. package/plugins/ca-pi/includes/author-tdd-workflow.md +14 -0
  105. package/plugins/ca-pi/includes/compaction-charter.md +16 -0
  106. package/plugins/ca-pi/includes/cut-docs.md +16 -0
  107. package/plugins/ca-pi/includes/dev-mode.md +30 -0
  108. package/plugins/ca-pi/includes/farm.md +237 -0
  109. package/plugins/ca-pi/includes/fresh-verification.md +14 -0
  110. package/plugins/ca-pi/includes/harvest.md +69 -0
  111. package/plugins/ca-pi/includes/maturity-coverage.md +102 -0
  112. package/plugins/ca-pi/includes/pi-host-notes.md +69 -0
  113. package/plugins/ca-pi/includes/redirect.md +69 -0
  114. package/plugins/ca-pi/includes/reference-map.md +22 -0
  115. package/plugins/ca-pi/includes/review-matrix.md +14 -0
  116. package/plugins/ca-pi/includes/reviewer-contract.md +53 -0
  117. package/plugins/ca-pi/includes/routing-table.md +47 -0
  118. package/plugins/ca-pi/includes/security-gate-record.md +22 -0
  119. package/plugins/ca-pi/includes/smarts/core.md +90 -0
  120. package/plugins/ca-pi/includes/smarts/decision-log-format.md +56 -0
  121. package/plugins/ca-pi/routines/INDEX.md +32 -0
  122. package/plugins/ca-pi/routines/brainstorming/SKILL.md +122 -0
  123. package/plugins/ca-pi/routines/commit-gate/SKILL.md +151 -0
  124. package/plugins/ca-pi/routines/context-check/SKILL.md +85 -0
  125. package/plugins/ca-pi/routines/context-creation/SKILL.md +171 -0
  126. package/plugins/ca-pi/routines/crypto-compliance/SKILL.md +41 -0
  127. package/plugins/ca-pi/routines/debug/SKILL.md +99 -0
  128. package/plugins/ca-pi/routines/decision-lifecycle/SKILL.md +104 -0
  129. package/plugins/ca-pi/routines/decision-lifecycle/references/adr-template.md +74 -0
  130. package/plugins/ca-pi/routines/decision-variance/SKILL.md +147 -0
  131. package/plugins/ca-pi/routines/decompose/SKILL.md +168 -0
  132. package/plugins/ca-pi/routines/dispatching-parallel-agents/SKILL.md +76 -0
  133. package/plugins/ca-pi/routines/executing-plans/SKILL.md +83 -0
  134. package/plugins/ca-pi/routines/finishing-a-development-branch/SKILL.md +91 -0
  135. package/plugins/ca-pi/routines/post-merge-cleanup/SKILL.md +233 -0
  136. package/plugins/ca-pi/routines/refactor/SKILL.md +91 -0
  137. package/plugins/ca-pi/routines/release/SKILL.md +315 -0
  138. package/plugins/ca-pi/routines/secret-handling/SKILL.md +67 -0
  139. package/plugins/ca-pi/routines/security-architecture/SKILL.md +63 -0
  140. package/plugins/ca-pi/routines/skill-author/SKILL.md +108 -0
  141. package/plugins/ca-pi/routines/skill-author/references/skill-template.md +58 -0
  142. package/plugins/ca-pi/routines/subagent-driven-development/SKILL.md +149 -0
  143. package/plugins/ca-pi/routines/subagent-driven-development/references/farm-dispatch.md +145 -0
  144. package/plugins/ca-pi/routines/tdd/SKILL.md +139 -0
  145. package/plugins/ca-pi/routines/tribunal/SKILL.md +109 -0
  146. package/plugins/ca-pi/routines/tribunal/references/ai-markers.md +29 -0
  147. package/plugins/ca-pi/routines/tribunal/references/cost-and-models.md +64 -0
  148. package/plugins/ca-pi/routines/tribunal/references/finding-record.md +27 -0
  149. package/plugins/ca-pi/routines/tribunal/references/issue-filing.md +47 -0
  150. package/plugins/ca-pi/routines/tribunal/references/lenses/appsec.md +22 -0
  151. package/plugins/ca-pi/routines/tribunal/references/lenses/architecture.md +23 -0
  152. package/plugins/ca-pi/routines/tribunal/references/lenses/coverage.md +20 -0
  153. package/plugins/ca-pi/routines/tribunal/references/lenses/infra.md +24 -0
  154. package/plugins/ca-pi/routines/tribunal/references/lenses/migration.md +22 -0
  155. package/plugins/ca-pi/routines/tribunal/references/lenses/observability.md +21 -0
  156. package/plugins/ca-pi/routines/tribunal/references/lenses/performance.md +22 -0
  157. package/plugins/ca-pi/routines/tribunal/references/lenses/reliability.md +23 -0
  158. package/plugins/ca-pi/routines/tribunal/references/lenses/secrets-supply.md +22 -0
  159. package/plugins/ca-pi/routines/tribunal/references/lenses/test-fidelity.md +24 -0
  160. package/plugins/ca-pi/routines/tribunal/references/lenses/typesafety.md +21 -0
  161. package/plugins/ca-pi/routines/tribunal/references/report.md +19 -0
  162. package/plugins/ca-pi/routines/tribunal/references/schemas.md +58 -0
  163. package/plugins/ca-pi/routines/tribunal/references/telemetry.md +28 -0
  164. package/plugins/ca-pi/routines/tribunal/references/triage.md +53 -0
  165. package/plugins/ca-pi/routines/using-git-worktrees/SKILL.md +85 -0
  166. package/plugins/ca-pi/routines/writing-plans/SKILL.md +129 -0
  167. package/plugins/ca-pi/routines/writing-plans/references/farm-plan.md +50 -0
  168. package/plugins/ca-pi/skills/ca-add-dep/SKILL.md +88 -0
  169. package/plugins/ca-pi/skills/ca-adr/SKILL.md +30 -0
  170. package/plugins/ca-pi/skills/ca-adr-status/SKILL.md +30 -0
  171. package/plugins/ca-pi/skills/ca-arbiter/SKILL.md +36 -0
  172. package/plugins/ca-pi/skills/ca-audit/SKILL.md +51 -0
  173. package/plugins/ca-pi/skills/ca-btw/SKILL.md +23 -0
  174. package/plugins/ca-pi/skills/ca-checkpoint/SKILL.md +50 -0
  175. package/plugins/ca-pi/skills/ca-chore/SKILL.md +58 -0
  176. package/plugins/ca-pi/skills/ca-cleanup/SKILL.md +55 -0
  177. package/plugins/ca-pi/skills/ca-commands/SKILL.md +21 -0
  178. package/plugins/ca-pi/skills/ca-commit/SKILL.md +27 -0
  179. package/plugins/ca-pi/skills/ca-conflict/SKILL.md +61 -0
  180. package/plugins/ca-pi/skills/ca-context-check/SKILL.md +32 -0
  181. package/plugins/ca-pi/skills/ca-create-context/SKILL.md +32 -0
  182. package/plugins/ca-pi/skills/ca-debug/SKILL.md +42 -0
  183. package/plugins/ca-pi/skills/ca-decompose/SKILL.md +30 -0
  184. package/plugins/ca-pi/skills/ca-dev/SKILL.md +42 -0
  185. package/plugins/ca-pi/skills/ca-doctor/SKILL.md +44 -0
  186. package/plugins/ca-pi/skills/ca-feature/SKILL.md +105 -0
  187. package/plugins/ca-pi/skills/ca-fix/SKILL.md +42 -0
  188. package/plugins/ca-pi/skills/ca-init/SKILL.md +56 -0
  189. package/plugins/ca-pi/skills/ca-metrics/SKILL.md +80 -0
  190. package/plugins/ca-pi/skills/ca-new-skill/SKILL.md +34 -0
  191. package/plugins/ca-pi/skills/ca-override/SKILL.md +72 -0
  192. package/plugins/ca-pi/skills/ca-pr/SKILL.md +61 -0
  193. package/plugins/ca-pi/skills/ca-preview/SKILL.md +86 -0
  194. package/plugins/ca-pi/skills/ca-prune/SKILL.md +100 -0
  195. package/plugins/ca-pi/skills/ca-reconcile/SKILL.md +43 -0
  196. package/plugins/ca-pi/skills/ca-refactor/SKILL.md +43 -0
  197. package/plugins/ca-pi/skills/ca-release/SKILL.md +57 -0
  198. package/plugins/ca-pi/skills/ca-review/SKILL.md +63 -0
  199. package/plugins/ca-pi/skills/ca-spike/SKILL.md +41 -0
  200. package/plugins/ca-pi/skills/ca-sprint/SKILL.md +44 -0
  201. package/plugins/ca-pi/skills/ca-standup/SKILL.md +112 -0
  202. package/plugins/ca-pi/skills/ca-status/SKILL.md +56 -0
  203. package/plugins/ca-pi/skills/ca-task/SKILL.md +61 -0
  204. package/plugins/ca-pi/skills/ca-threat-model/SKILL.md +45 -0
  205. package/plugins/ca-pi/skills/ca-tribunal/SKILL.md +44 -0
  206. package/plugins/ca-pi/skills/ca-watch/SKILL.md +78 -0
@@ -0,0 +1,105 @@
1
+ ---
2
+ name: ca-feature
3
+ description: "Start a feature: brainstorm a spec, get it approved, then drive it test-first through the pipeline. The one entry to implementation."
4
+ argument-hint: "<what you want to build>"
5
+ ---
6
+
7
+ # /ca-feature — spec-driven feature
8
+
9
+ The single permitted entry to implementation work. No feature code is written before a spec is approved and `tdd` Phase 1 clears. A one-line idea is not a spec — `brainstorming` makes it one.
10
+
11
+ **Orientation:** if `.codearbiter/code-map.md` is present, read it first — a coarse concern→path→role map that orients task authoring. Absent is fine; it is read-on-demand, populated by context-creation or commit-gate heal.
12
+
13
+ ## Resume — an interrupted pipeline is re-entered, never restarted
14
+
15
+ Before triage, scan `<project-root>/.codearbiter/specs/` and `plans/` for an existing slug
16
+ matching `$ARGUMENTS` (invoked bare, list every resumable pipeline and ask which). A crash,
17
+ compaction, or closed session mid-pipeline loses nothing — the spec, the plan, and each task's
18
+ `status` cell are on disk. On a match, confirm the resume with the user in one line
19
+ ("resume `<slug>` at <point>?") and re-enter at the furthest checkpoint reached:
20
+
21
+ 1. **Plan exists with non-`ACCEPTED` tasks** → `executing-plans` (its Phase 1 batches only the
22
+ remaining tasks).
23
+ 2. **Plan exists, every task `ACCEPTED`** → `commit-gate` (the work is done and verified; it was the
24
+ commit that never happened).
25
+ 3. **Spec approved, no plan** → `writing-plans` (`<plugin-root>/routines/writing-plans/SKILL.md`).
26
+ 4. **Spec exists but never approved** → `brainstorming` (`<plugin-root>/routines/brainstorming/SKILL.md`), at its approval gate — not from scratch.
27
+
28
+ Re-running `brainstorming` against an already-approved spec is the failure mode this section exists
29
+ to prevent: it discards approved decisions and re-asks answered questions. Only an explicit user
30
+ request ("start over") restarts an existing slug — and that is logged to `triage.log` like any
31
+ classification.
32
+
33
+ ## Step 0 — change-class triage (logged)
34
+
35
+ Before routing, classify the request. The **small lane** applies only when ALL of these hold —
36
+ judged against `$ARGUMENTS` and a quick look at the code, never assumed:
37
+
38
+ - the change touches ≤ 2 implementation files (plus their tests);
39
+ - no §4 reference-map scope-touch: auth/crypto/secrets, dependencies, migrations/schema, telemetry,
40
+ public API surface, domain vocabulary;
41
+ - no new dependency, endpoint, command, or configuration surface;
42
+ - the behavior change is expressible as 1–3 concrete, individually testable acceptance criteria.
43
+
44
+ **Small lane:** state the mini-spec inline (the 1–3 criteria) and STOP for the user's one-reply
45
+ confirmation. On confirmation, append one line to `<project-root>/.codearbiter/triage.log`
46
+ (append-only, `>>`):
47
+
48
+ ```
49
+ [ISO-8601 timestamp] | BY: <git user.email> | LANE: small | SCOPE: <one-line> | BASIS: <criteria met>
50
+ ```
51
+
52
+ Then route directly to `tdd` (`<plugin-root>/routines/tdd/SKILL.md`) — the confirmed criteria are its Phase 1 obligations; Phases 2–6 run
53
+ unchanged — and exit through the full `commit-gate` and `finishing-a-development-branch` exactly as
54
+ the full lane does. The lane trims ceremony, never gates.
55
+
56
+ Any criterion violated, or uncertain → **full lane** (below). Uncertainty is full-lane; the triage
57
+ never guesses.
58
+
59
+ ## Flow — full lane
60
+
61
+ Route through the pipeline in order; each step gates the next:
62
+
63
+ 1. **`brainstorming`** (`<plugin-root>/routines/brainstorming/SKILL.md`) — refine `$ARGUMENTS` into a concrete spec by Socratic questioning: challenge
64
+ vague language, surface hidden complexity, force trade-offs. Writes the spec to
65
+ `<project-root>/.codearbiter/specs/<slug>.md`. **Hard gate: no plan and no code until the
66
+ user approves the spec.** Genuinely-unresolved unknowns become `[CONFIRM-NN]` in
67
+ `open-questions.md`, never guesses.
68
+ 2. **`writing-plans`** (`<plugin-root>/routines/writing-plans/SKILL.md`) — decompose the approved spec into small tasks, each with an exact path and a
69
+ verification that maps to a `tdd` obligation (it does not replace one). Writes
70
+ `<project-root>/.codearbiter/plans/<slug>.md` with bijective criterion↔task coverage.
71
+ 3. **`executing-plans`** (`<plugin-root>/routines/executing-plans/SKILL.md`) — coordinates the plan in small batches with human checkpoints. Each batch is
72
+ delegated to `subagent-driven-development` (`<plugin-root>/routines/subagent-driven-development/SKILL.md` — fresh author agent per task, spec-compliance review,
73
+ quality review, fresh verification). The user acknowledges between batches; nothing advances until
74
+ they do.
75
+ 4. **`commit-gate`** — the only path to a commit; nine gates, including behavioral proof.
76
+ 5. **`finishing-a-development-branch`** — terminal step: open-PR / merge-via-PR / discard. Every
77
+ change lands through a PR; never a direct write to the default branch.
78
+
79
+ The autonomous counterpart (`/ca-sprint`) runs the same spec→plan but passes the full plan to
80
+ `subagent-driven-development` directly, without per-batch checkpoints. That path is its own entry,
81
+ not `/feature`.
82
+
83
+ ## Scope routing
84
+
85
+ Scope determines which author agent `subagent-driven-development` dispatches per task:
86
+ `backend-author`, `frontend-author`, or `infra-author` — per the mapping in `tech-stack.md`. A
87
+ multi-area feature runs the appropriate agent per task; the full suite must be green before
88
+ transitioning between scope areas.
89
+
90
+ ## When NOT to use
91
+
92
+ - A known defect with a reproduction → `/fix`.
93
+ - A behavior-preserving restructure → `/refactor`.
94
+ - A question or quick discussion → `/btw`.
95
+ - Persisting work already written → `/commit`.
96
+
97
+ ## Hard gate
98
+
99
+ MUST NOT write feature code before a spec is approved AND `tdd` Phase 1 clears — the brainstormed
100
+ spec in the full lane, the user-confirmed mini-spec in the small lane. MUST NOT take the small lane
101
+ unless every Step 0 criterion holds, and MUST log the classification to
102
+ `.codearbiter/triage.log` before `tdd` begins. MUST NOT skip `writing-plans` in the full lane.
103
+ MUST NOT resolve a `[CONFIRM-NN]` in the spec by guessing — surface it.
104
+ MUST NOT restart an interrupted pipeline whose artifacts exist on disk — resume at the furthest
105
+ checkpoint per the Resume ladder, unless the user explicitly asks to start over.
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: ca-fix
3
+ description: "Fix a confirmed bug: a failing regression test first, then a minimal fix, then the rest of the tdd gates."
4
+ argument-hint: "<what's happening vs. what should happen>"
5
+ ---
6
+
7
+ # /ca-fix — regression-first bug fix
8
+
9
+ The only permitted entry to bug-fix work. No fix code is written before a regression test reproduces the defect and goes red for the right reason. Give the observed behavior and the expected behavior, plus a stack trace or reproduction when you have one.
10
+
11
+ **Orientation:** if `.codearbiter/code-map.md` is present, read it before diagnosing — a coarse concern→path→role map that helps locate the defect. Absent is fine; it is read-on-demand.
12
+
13
+ ## Flow
14
+
15
+ Routes to the `tdd` skill, bug variant — Phase 1 is framed around confirming the defect, not building
16
+ new behavior:
17
+
18
+ 1. **Reproduce** the bug consistently.
19
+ 2. **Locate the root cause** — the exact code path producing the wrong behavior.
20
+ 3. **Write a regression test** that fails in the current state for the precise reason the bug causes
21
+ (not an unrelated error).
22
+ 4. **Confirm it's red for the right reason** — the failure message matches the described defect.
23
+
24
+ Only then does `tdd` proceed: minimal fix to green, then the remaining `tdd` gates. The implementation
25
+ agent (`backend-author`, `frontend-author`, or `infra-author`) is selected by where the bug lives. If
26
+ the defect cannot be pinned by a failing test, STOP and surface the question.
27
+
28
+ ## Routes to
29
+
30
+ `tdd` (`<plugin-root>/routines/tdd/SKILL.md`) — all phases, Phase 1 framed for bug confirmation.
31
+
32
+ ## When NOT to use
33
+
34
+ - New behavior → `/ca-feature`.
35
+ - A behavior-preserving restructure → `/ca-refactor`.
36
+ - "Why does it do this?" → `/ca-btw`.
37
+ - Persisting fix code already written → `/ca-commit` (the gates still apply).
38
+
39
+ ## Hard gate
40
+
41
+ MUST NOT write fix code before the regression test is red for the right reason. MUST NOT accept a test
42
+ that passes against the broken state as proof of the defect.
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: ca-init
3
+ description: Opt this repo into codeArbiter — scaffold the root-level .codearbiter/ state store.
4
+ argument-hint: "(none) | --stage N | --check"
5
+ ---
6
+
7
+ # /ca-init — first-run scaffold
8
+
9
+ Stand up the root-level `.codearbiter/` project-state store that opts a repo into arbiter
10
+ management. This is the v2 replacement for vendoring/`init-vendor`: no symlinks, no shims, no dual
11
+ root. It writes the activation flag and the empty state files, then hands off to the populator.
12
+
13
+ `.codearbiter/CONTEXT.md` frontmatter `arbiter: enabled` is the single activation flag — it gates
14
+ the SessionStart persona injection. The scaffolded
15
+ `CONTEXT.md` is a **stub** (no initialization sentinel), so after scaffolding the project still needs
16
+ populating before normal operation.
17
+
18
+ ## Procedure
19
+
20
+ 1. Run the scaffolder against the repo's git toplevel (resolved by the script):
21
+
22
+ ```
23
+ python "<plugin-root>/hooks/init-codearbiter.py"
24
+ ```
25
+
26
+ It is idempotent and refuses if `.codearbiter/CONTEXT.md` already exists — it never overwrites
27
+ state. Pass `--stage N` to set the initial maturity value (default `1`). Use `--check` to report
28
+ state without creating anything.
29
+
30
+ 2. It creates `.codearbiter/` with: `CONTEXT.md` (`arbiter: enabled`, `stage: N`, stub body),
31
+ `open-tasks.md`, `open-questions.md`, `overrides.log` (audit header), and `last-checkpoint` (`0`).
32
+
33
+ 3. **Then route to the populator** — the stub is not yet usable:
34
+ - **Source code already exists** in the repo → route to `/ca-create-context` (brownfield: scouts
35
+ read the codebase and synthesize the full context, writing the initialization sentinel).
36
+ - **Greenfield** (no meaningful source) → route to `/ca-decompose` (layered interview).
37
+
38
+ The populator is **mandatory, not optional**: it authors `tech-stack.md`, `coding-standards.md`,
39
+ and `security-controls.md` (and writes the initialization sentinel). The pipeline gates BLOCK on
40
+ reading those files — `writing-plans` and `tdd` need `tech-stack.md`, the security gates need
41
+ `security-controls.md` — so `/ca-feature` run on a freshly-scaffolded stub will STOP at pre-flight
42
+ until the populator has run. `session-start` surfaces this as `NOT INITIALIZED` every session.
43
+
44
+ 4. Report what was created and which populator you are routing to.
45
+
46
+ ## When NOT to use
47
+
48
+ - `.codearbiter/` already scaffolded → the scaffolder refuses; run `/ca-create-context` or
49
+ `/ca-decompose` to populate, or `/ca-status` to see state.
50
+ - You only want to re-check detection state → run the scaffolder with `--check`.
51
+
52
+ ## Hard gate
53
+
54
+ MUST NOT hand-author `.codearbiter/CONTEXT.md` frontmatter — the scaffolder is the sanctioned path so
55
+ the activation flag and state-file shapes match what the hook parses. MUST NOT mark a
56
+ stub initialized; only the populator writes the initialization sentinel.
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: ca-metrics
3
+ description: Read-only 3-metric governance glance — override rate, small-lane rate, sprint low-confidence ratio — each with a trend arrow vs. the prior 20-commit window.
4
+ argument-hint: "[--window N]"
5
+ ---
6
+
7
+ # /ca-metrics — governance trend glance
8
+
9
+ A bare-numbers summary of the three governance-health metrics that `_metricslib.py`
10
+ tracks across commit windows. Each metric shows its value for the **current** 20-commit
11
+ window and a direction arrow (↑/↓/→) relative to the immediately preceding window.
12
+
13
+ This is NOT a second `/ca-audit` packet. It prints numbers and arrows only — no
14
+ verbatim override lines, no commit list, no file write. Use it to spot a trend at a
15
+ glance; reach for `/ca-audit` when you need the full evidentiary packet.
16
+
17
+ ## Flow
18
+
19
+ 1. **Invoke the helper.** Call the thin entry hook `metrics.py`, which wraps
20
+ `compute` from `_metricslib.py`. Resolve the interpreter once by presence —
21
+ `PY=python3; { command -v python3 >/dev/null 2>&1 && python3 --version >/dev/null 2>&1; } || PY=python`
22
+ — never `python3 … || python …`, which reruns the helper on any nonzero exit
23
+ and reports the second run's code instead of the first's (#577). Pass
24
+ `<project-root>` as `--root`. If `--window N` was
25
+ supplied, pass it through as `--window N`; otherwise omit it (the helper
26
+ applies the default of 20).
27
+
28
+ ```
29
+ "$PY" "<plugin-root>/hooks/metrics.py" --root "<project-root>"
30
+ ```
31
+
32
+ > **`ensure_ascii` note — do not remove this.** `metrics.py` calls `json.dumps`
33
+ > with its default `ensure_ascii=True`. This ASCII-escapes the arrow glyphs
34
+ > (↑↓→) in the subprocess stdout, which avoids a `UnicodeEncodeError` on Windows
35
+ > `cp1252` consoles that cannot encode those code-points raw. The rendered output
36
+ > you present to the user (step 2 below) uses the real glyphs — they are written
37
+ > by the assistant, not piped through the subprocess stdout. Do NOT add
38
+ > `ensure_ascii=False` here.
39
+
40
+ With a custom window size:
41
+ ```
42
+ "$PY" "<plugin-root>/hooks/metrics.py" --root "<project-root>" --window N
43
+ ```
44
+ Replace `N` with the integer the user supplied.
45
+
46
+ 2. **Render the glance.** Parse the returned JSON dict. Present exactly three lines,
47
+ one per metric, in this order:
48
+
49
+ ```
50
+ override rate: <current> <arrow> (prior: <prior>)
51
+ small-lane rate: <current> <arrow> (prior: <prior>)
52
+ sprint low-conf ratio: <current> <arrow> (prior: <prior>)
53
+ ```
54
+
55
+ - Use the real glyphs ↑, ↓, → in your message (not the JSON-escaped forms).
56
+ - For `sprint_low_conf_ratio`, the `current` or `prior` value may be the string
57
+ `"n/a"` — render it literally (e.g. `n/a ↑`).
58
+ - ↑ on `override_rate` and `sprint_low_conf_ratio` is a worsening signal; state
59
+ this briefly below the table so the reader does not have to guess.
60
+
61
+ 3. **State the window.** Append one line naming the window size used, e.g.
62
+ `Window: 20 commits (default)` or `Window: N commits (--window N)`.
63
+
64
+ ## Hard gate
65
+
66
+ - Read-only. MUST NOT write, create, or modify any file. MUST NOT stage or commit.
67
+ `git status` MUST be unchanged after a run.
68
+ - Emits ONLY the fixed 3-metric glance: `override_rate`, `small_lane_rate`,
69
+ `sprint_low_conf_ratio`. MUST NOT emit verbatim override log lines, verbatim
70
+ triage entries, commit lists, or any other content from the governance logs.
71
+ - MUST NOT require `/ca-init` to have been run. The helper degrades gracefully on
72
+ absent logs (counts return 0 / ratio returns `"n/a"`); surface the degraded
73
+ values as-is rather than blocking.
74
+ - If the helper subprocess fails entirely (import error, Python not found), report
75
+ the error and stop — do not fabricate metric values.
76
+
77
+ ## When NOT to use
78
+
79
+ - Full governance packet with verbatim overrides and audit trail → `/ca-audit`.
80
+ - Live project state (active sprint, open confirms, hook health) → `/ca-status`.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: ca-new-skill
3
+ description: "Author a new codeArbiter skill: prove the gap is real, get the spec approved, then write it."
4
+ argument-hint: "<verb-noun skill name>"
5
+ ---
6
+
7
+ # /ca-new-skill — author a skill
8
+
9
+ The only permitted entry to creating a skill. Nothing is written until the gap is proven uncovered — skills are not created speculatively. Name the skill in verb-noun form (`"dependency-review"`), not as a description (`"the thing that checks packages"`).
10
+
11
+ ## Flow
12
+
13
+ Routes to the `skill-author` skill, which owns the work end to end through its five gated phases — gap
14
+ evidence, scope, authoring, self-review against the v2 house style, and routing integration (the
15
+ `INDEX.md` + routing-table entry that makes the new skill reachable). The phase definitions live in the
16
+ skill; this command does not restate them. Nothing is authored until an existing skill or agent is
17
+ proven not to cover the need; nothing ships until the new skill carries gated phases, hard rules, and
18
+ its routing entry.
19
+
20
+ ## Routes to
21
+
22
+ `skill-author` (`<plugin-root>/routines/skill-author/SKILL.md`) — all five phases.
23
+
24
+ ## When NOT to use
25
+
26
+ - A one-time action → `/ca-feature` or a command definition.
27
+ - An existing skill nearly covers it → extend that skill via `/ca-feature`.
28
+ - "Do we even need a skill here?" → `/ca-btw`.
29
+
30
+ ## Hard gate
31
+
32
+ MUST prove the gap is real in Phase 1 before writing any skill content. MUST get user approval on the
33
+ spec before authoring. MUST NOT create a skill that duplicates an existing skill's purpose — surface
34
+ the overlap instead. Skill files live only under `<plugin-root>/routines/<name>/`.
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: ca-override
3
+ description: Sanctioned, logged bypass of a gate or hard rule — one audit line, then proceed.
4
+ argument-hint: "<reason>"
5
+ ---
6
+
7
+ # /ca-override — logged bypass
8
+
9
+ The sanctioned escape hatch. Bypass is permitted only with an audit log entry. Overrides are always
10
+ logged, always visible, never silent. Single identity, single confirm.
11
+
12
+ ## Flow
13
+
14
+ 1. Validate `$ARGUMENTS` — the reason names the gate being bypassed and a justification. Reject a
15
+ vague reason ("just skip it") and ask for a specific one.
16
+ 2. Detect the operator identity from `git config user.email` only. If it is unset, ask the user once
17
+ to state their identity for the log. (No platform ladder, no second confirmation.)
18
+ 3. Append one line to `<project-root>/.codearbiter/overrides.log`:
19
+
20
+ ```
21
+ [ISO-8601 timestamp] | BY: <email> | GATE: <gate bypassed> | REASON: <reason>
22
+ ```
23
+
24
+ The log is append-only — never edited or deleted, committed as a permanent audit artifact.
25
+ 4. Proceed with the overridden action. Note in the response that the override is logged.
26
+
27
+ ## Security ceiling — heavier path for security-critical stops
28
+
29
+ A routine gate (lint, a style rule, a non-security review finding) takes the single-confirm path above.
30
+ But a **security-critical stop is NOT bypassable by a single confirm.** The following require the
31
+ heavier path below, never the one-line flow:
32
+
33
+ - a security **CRITICAL** finding;
34
+ - the crypto/secret commit gate (hook **H-09b / H-10b** — staged crypto/TLS or secret without a gate pass);
35
+ - an **irreversible** operation (data loss, a destructive migration, anything unrollbackable).
36
+
37
+ Heavier path (all required, in order):
38
+ 1. **Surface the specific finding verbatim** — name the exact primitive/secret/operation and the
39
+ concrete risk. A generic "security override" is rejected.
40
+ 2. **Explicit per-finding acknowledgement** — the user must acknowledge *that specific finding* in
41
+ their own words (a bare "yes"/"go ahead"/"I trust you" is declined — this mirrors `decision-variance`).
42
+ Detect identity from `git config user.email`; if unset, ask once.
43
+ 3. **Heavier log entry** — append a line tagged `SECURITY-OVERRIDE` that records the specific finding,
44
+ not just the gate name:
45
+
46
+ ```
47
+ [ISO-8601] | BY: <email> | SECURITY-OVERRIDE | FINDING: <specific finding> | REASON: <reason>
48
+ ```
49
+ 4. **Only then** record the bypass. For the crypto/secret commit gate, that means resolving the
50
+ interpreter once by presence — `PY=python3; { command -v python3 >/dev/null 2>&1 && python3 --version >/dev/null 2>&1; } || PY=python`
51
+ — never `python3 X || python X`, which reruns X on any nonzero exit (#577), and running
52
+ `"$PY" "<plugin-root>/hooks/security-pass.py"`,
53
+ which writes `<project-root>/.codearbiter/.markers/security-gate-passed` bound to the
54
+ sensitive lines it approves, so hook H-09b/H-10b allows the commit — recorded **only** after
55
+ steps 1–3, never to skip the gate proper.
56
+
57
+ Under `/ca-sprint`, a security-critical override is a hard-gate STOP: it surfaces to the user and is
58
+ **never** auto-decided, even in autonomous mode (`SPRINT.md` hard gates).
59
+
60
+ ## Hard gate
61
+
62
+ MUST write the log line before proceeding — it is not optional. MUST capture an operator identity —
63
+ "codeArbiter" or "automated" are not valid. MUST include a justification. The override is scoped to
64
+ the immediate action only; it creates no standing exception. MUST NOT edit or delete an existing
65
+ `overrides.log` entry. MUST route a security-critical / crypto-secret / irreversible stop through the
66
+ **Security ceiling** path — never the single-confirm flow — and MUST NOT auto-decide such an override
67
+ under `/ca-sprint`.
68
+
69
+ ## When NOT to use
70
+
71
+ - Routine work that passes all gates — never needed.
72
+ - Reconciling two conflicting sources → `/ca-conflict`.
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: ca-pr
3
+ description: Open a pull request the only sanctioned way — clear every BLOCK-level review finding, then stage the PR. Never a direct write to the default branch.
4
+ argument-hint: (none)
5
+ ---
6
+
7
+ # /ca-pr — open a pull request
8
+
9
+ The only permitted path to a pull request. Every change lands through a PR — never a direct write or force-push to the default branch. No PR is drafted while any BLOCK-level review finding stands.
10
+
11
+ ## Flow
12
+
13
+ Routes to the `finishing-a-development-branch` skill, open-PR path. The orchestrator reads the current
14
+ branch, its diff against the base, and the commit log to determine what changed and which reviewers
15
+ apply, then:
16
+
17
+ 1. **Confirm the commit gate cleared** this session (`commit-gate` green, or `/ca-commit` completed).
18
+ 2. **Path matrix** — inspect the diff and dispatch the reviewer agents the change demands:
19
+ - auth / crypto / middleware paths → `auth-crypto-reviewer` + `security-reviewer`
20
+ - migration files → `migration-reviewer`
21
+ - dependency manifests → `dependency-reviewer`
22
+ - all paths → `coverage-auditor`
23
+ 3. **Run reviewers** in parallel where there are no dependencies.
24
+ 4. **BLOCK check** — any CRITICAL or HIGH finding STOPs the flow; present it and do not draft the PR.
25
+ The user resolves, re-runs `/ca-commit`, then `/ca-pr`.
26
+ 5. **Stage the PR** once all BLOCK findings clear: concise title; summary of what changed and why; a
27
+ bulleted test plan; a conflict-hierarchy tradeoff citation for any non-obvious tradeoff; a link to
28
+ any ADR the change implements or contradicts. The PR body is a user-facing deliverable: before
29
+ composing it, load `<plugin-root>/includes/anti-slop-design/core.md` and the
30
+ `medium-documents` leaf, and apply at least the §3.A em-dash ban and the §3.B copy self-audit to the
31
+ prose. Then `gh pr create`; return the URL.
32
+ 6. **Auto-attach the babysitter** — resolve the flag with the canonical resolver, never by eyeballing
33
+ the env var (so the accepted `on|true|1` spellings and the dormancy gate can't drift). Resolve the
34
+ interpreter once by presence — `PY=python3; { command -v python3 >/dev/null 2>&1 && python3 --version >/dev/null 2>&1; } || PY=python`
35
+ — never `python3 X || python X`, which reruns X on any nonzero exit (#577):
36
+ ```
37
+ "$PY" "<plugin-root>/hooks/babysit.py" --root "<project-root>"
38
+ ```
39
+ It prints one JSON line, e.g. `{"enabled": true, "on_red": "propose"}`. Only when `enabled` is
40
+ true (the global flag `CODEARBITER_BABYSIT` is on — default off, mirrors `CODEARBITER_PRUNE` — and
41
+ the repo is arbiter-active), attach a CI watcher to the PR just opened, equivalent to
42
+ `/ca-watch <new-PR>`. When `enabled` is false, do nothing here — the user can still run `/ca-watch`
43
+ ad-hoc. Never enable the flag on the user's behalf.
44
+
45
+ ## Routes to
46
+
47
+ `finishing-a-development-branch` (`<plugin-root>/routines/finishing-a-development-branch/SKILL.md`),
48
+ open-PR path.
49
+
50
+ ## When NOT to use
51
+
52
+ - Staged changes not yet committed → `/ca-commit`.
53
+ - Review a diff without opening a PR → `/ca-review`.
54
+ - A pre-implementation security pass → `/ca-threat-model`.
55
+
56
+ ## Hard gate
57
+
58
+ MUST NOT open a PR while any BLOCK-level (CRITICAL or HIGH) finding is unresolved. MUST NOT skip a
59
+ reviewer the path matrix requires. MUST NOT open a PR before the commit gate ran this session. MUST
60
+ NOT open a PR, write, or force-push directly to the default branch. MUST NOT auto-attach a CI watcher
61
+ unless `CODEARBITER_BABYSIT` is on, and MUST NOT enable that flag on the user's behalf.
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: ca-preview
3
+ description: Zero-onboarding, read-only dry-run of the reviewer fleet against the current uncommitted diff. Predicts reviewers, runs the state-free secret scan, writes nothing.
4
+ argument-hint: (none)
5
+ ---
6
+
7
+ # /ca-preview — reviewer-fleet dry-run
8
+
9
+ See what codeArbiter would do to your real code before paying any onboarding cost. This is a
10
+ read-only dry-run against the current uncommitted diff: it predicts which reviewers the change
11
+ would dispatch, runs the checks that need no project rules, and reports. It never writes state.
12
+
13
+ It requires no `/ca-init`, no `.codearbiter/` directory, and no decompose or create-context
14
+ interview. It functions in a repo that never opted in, and it modifies nothing: not the worktree,
15
+ not the index, not `.codearbiter/`. `git status` is unchanged by a run.
16
+
17
+ ## Flow
18
+
19
+ 1. **Collect the diff.** Call the thin entry hook `preview.py` in `diff` mode, which wraps
20
+ `collect_diff` from `<plugin-root>/hooks/_previewlib.py`. It unions HEAD-vs-worktree
21
+ changes, staged changes, and untracked files (forward-slash paths). Run it from the project
22
+ root so `_previewlib`/`_hooklib` resolve on the same `sys.path`. Resolve the interpreter once
23
+ by presence — `PY=python3; { command -v python3 >/dev/null 2>&1 && python3 --version >/dev/null 2>&1; } || PY=python`
24
+ — never `python3 X || python X`, which reruns X on any nonzero exit (#577):
25
+ ```
26
+ "$PY" "<plugin-root>/hooks/preview.py" diff
27
+ ```
28
+ If the result is empty (clean tree, or not a git repo), print a friendly **"Nothing to
29
+ preview"** line and STOP. This is a clean exit, not an error: no stack trace, no failure.
30
+
31
+ 2. **Predict reviewers by path.** Read the reviewer-to-path matrix at
32
+ `<plugin-root>/includes/review-matrix.md`. That include is the single source of truth
33
+ for which reviewer is dispatched when scope touches a given path: do NOT restate, fork, or
34
+ inline a second copy of the table here. For each changed path, list the reviewers that WOULD
35
+ dispatch and name the triggering path for each. This is the same mapping `/ca-review` uses, so
36
+ the predicted set matches what a real review would dispatch.
37
+
38
+ 3. **Run the state-free secret scan.** Call the thin entry hook `preview.py` in `secrets` mode,
39
+ which wraps `scan_secrets` from `<plugin-root>/hooks/_previewlib.py`. It reads each
40
+ changed file's current content and returns `SecretFinding(path, line_no, snippet)` for every
41
+ credential line, with the secret VALUE already masked to `****` in `snippet`:
42
+ ```
43
+ "$PY" "<plugin-root>/hooks/preview.py" secrets
44
+ ```
45
+ Report each finding by `path:line_no` with its redacted snippet. The snippet arrives already
46
+ masked: never reconstruct or print a raw secret value.
47
+
48
+ ## Report
49
+
50
+ Emit one clear report with these parts:
51
+
52
+ - **Changed files** — the reviewed-file set from step 1, each with its change kind(s) (unstaged,
53
+ staged, untracked).
54
+ - **Predicted reviewers** — per the matrix, which reviewers would dispatch and the triggering path
55
+ for each. These are predicted (would-dispatch), not run here.
56
+ - **Secret findings** — the results of the real scan from step 3, by `path:line_no` with the
57
+ redacted snippet, marked as found (ran locally), at BLOCK severity. State "none found" when the
58
+ scan is clean.
59
+ - **Onboarding nudge** — close with one line: the full gated review comes via `/ca-init` then
60
+ `/ca-review`.
61
+
62
+ ## Distinct from /ca-doctor
63
+
64
+ This reports reviewer and gate behavior on the current diff. It makes NO hook-probe claims and says
65
+ nothing about wrapper wiring or the active-dispatch coverage gap: that is `/ca-doctor`.
66
+ Do not blend the two.
67
+
68
+ ## When NOT to use
69
+
70
+ - An onboarded repo wanting the full gated verdict → `/ca-init` then `/ca-review`.
71
+ - Inspecting wrapper wiring and the active-dispatch coverage gap → `/ca-doctor`.
72
+
73
+ - A question about the code → `/ca-btw`.
74
+
75
+ ## Hard gate
76
+
77
+ - Read-only. MUST NOT write, create, or modify any file, including anything under `.codearbiter/`;
78
+ MUST NOT stage or commit. `git status` MUST be unchanged after a run.
79
+ - MUST NOT require, trigger, or error on missing `/ca-init`, `.codearbiter/` state, or the
80
+ decompose / create-context interview.
81
+ - MUST NOT print a raw secret value: the lib returns the snippet already redacted, and the report
82
+ carries only that masked form.
83
+ - An empty diff or a non-git directory MUST yield the "Nothing to preview" message and a clean
84
+ exit, never a stack trace.
85
+ - MUST treat the reviewer prediction as predicted (would-dispatch) and the secret scan as found
86
+ (ran locally): it MUST NOT attribute fabricated findings to any predicted reviewer.
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: ca-prune
3
+ description: Trim transcript clutter to extend session lifetime — analyze, prune a copy, or toggle the after-each-turn service. Dry-run by default; gains land at resume/compaction, not the current turn.
4
+ argument-hint: "status | dry | run <path> | audit <path> | on | off"
5
+ ---
6
+
7
+ # /ca-prune — session transcript pruner
8
+
9
+ Long sessions die when their semantic history fills the context window with bulk: oversized tool
10
+ outputs, thinking blocks, MCP/shell noise, stale file reads, and host-specific sidecars. The shared
11
+ policy trims that bulk at safe quiescence boundaries while each host codec preserves its native
12
+ integrity model and the K most recent tool-bearing turns verbatim. Claude keeps byte-safe JSONL
13
+ serialization; Pi uses semantic entries and returns a native custom-compaction result.
14
+ Gains land at the host's next native resume/restart or compaction boundary, not by mutating the
15
+ running session's active file. **Pi-native compaction** is event-driven and never rewrites an active
16
+ Pi session file.
17
+
18
+ ## Argument
19
+
20
+ `$ARGUMENTS` is one of:
21
+
22
+ - `status` (default) — report cumulative reduction and service state for this session from
23
+ `~/.codearbiter/prune-state.json`, and whether `CODEARBITER_PRUNE` is `on`/`dry`/`off`. When
24
+ the service has run in `dry` mode, every would-be prune is also recorded — one JSONL row per
25
+ decision, across all sessions — to the shared data-collection log
26
+ `~/.codearbiter/metrics/prune-dry.jsonl` (override with `CODEARBITER_PRUNE_METRICS`). That log is
27
+ the evidence base for the `dry`→`on` decision: a clean record (every row `verdict: dry-run`,
28
+ `validation_errors: 0`) over a representative set of sessions is the signal that enabling is safe.
29
+ Read `context_bytes_freed` / `context_est_tokens_freed` for model-context benefit and
30
+ `file_bytes_freed` / `file_pct` for disk and resume-parse benefit. `sidecar-collapse` is explicitly
31
+ `file-only`; it must not count toward the context-benefit or cold-cache decision.
32
+ The legacy `freed_bytes`, `pct`, and `est_tokens_before` / `est_tokens_after` fields remain
33
+ whole-file compatibility aliases; do not use them as model-context evidence.
34
+ - `dry` — create a read-only semantic plan (or analyze a scratch copy where the host exposes a
35
+ serialized transcript); present the per-strategy reduction table with every strategy labeled
36
+ `context` or `file-only`. Never writes the active session.
37
+ - `run <path>` — prune the target with `--execute`. Targets a **copy or an old/inactive
38
+ transcript only** — the tool refuses an active or recently-modified target by construction.
39
+ - `audit <path>` — read-only integrity report: line-parse, uuid chain, tool-pair coverage,
40
+ condensation markers.
41
+ - `on` / `off` — guidance on enabling or disabling the after-each-turn service.
42
+
43
+ ## Flow
44
+
45
+ 1. **status / dry / audit** — run the backing tool and present its output verbatim. Resolve the
46
+ interpreter once by presence — `PY=python3; { command -v python3 >/dev/null 2>&1 && python3 --version >/dev/null 2>&1; } || PY=python`
47
+ — never `python3 X || python X`, which reruns X on any nonzero exit (#577):
48
+ ```
49
+ "$PY" "<plugin-root>/hooks/prune-transcript.py" <subcommand> [<path>]
50
+ ```
51
+ For serialized hosts, `dry` analyzes `<path>.copy.jsonl`; Pi active sessions use the native
52
+ semantic planner and return a custom compaction result without session-file writes.
53
+
54
+ 2. **run** — confirm the path is a copy or an inactive session, then:
55
+ ```
56
+ "$PY" "<plugin-root>/hooks/prune-transcript.py" <path> --execute [--tier T]
57
+ ```
58
+ Present the per-strategy reduction report; follow with `audit` on the result.
59
+
60
+ 3. **on/off** — explain the after-each-turn service: `UserPromptSubmit` and `PreCompact` hooks
61
+ prune at safe quiescence points, always exit 0, and never block the prompt. Tiers: `gentle`
62
+ (sidecar + oversize clamp), `standard` (+ reasoning fold, aged/MCP/shell), `aggressive`
63
+ (+ stale-read, reminder dedup, image evict). Config via `CODEARBITER_PRUNE` (`off`|`dry`|`on`,
64
+ ships **off**), `CODEARBITER_PRUNE_TIER`, `CODEARBITER_PRUNE_KEEP_RECENT` (the K most recent
65
+ tool **turns** kept verbatim — each turn is an assistant tool_use plus its results),
66
+ `CODEARBITER_PRUNE_MAXBYTES`. Enabling is the user's explicit choice — never set it unbidden.
67
+ In `dry` mode the service writes no transcript but appends each would-be prune to
68
+ `~/.codearbiter/metrics/prune-dry.jsonl` (path override: `CODEARBITER_PRUNE_METRICS`) for
69
+ data collection; in `on` mode the executed prunes are recorded in `~/.codearbiter/prune.log`.
70
+ If a prior service-mode prune was killed mid-write, the next run self-heals the transcript
71
+ from the newest backup in `~/.codearbiter/prune-backups/` before doing anything else.
72
+
73
+ **Cold-miss nudge** [Feature Forge — `preview`]: when `CODEARBITER_PRUNE` is `on`, an
74
+ optional submit-time speed bump warns once before a cold cache re-cache lands on bloated
75
+ context. Enable with `CODEARBITER_PRUNE_NUDGE=on` (default `off`). When all arming conditions
76
+ hold (idle ≥ `CODEARBITER_PRUNE_NUDGE_IDLE_SECS`, default 240 s; estimated model-context
77
+ tokens freed ≥
78
+ `CODEARBITER_PRUNE_NUDGE_MIN_TOKENS`, default 80 000), the hook blocks the submit once with
79
+ an advisory on stderr and returns exit code 2. File-only sidecar reduction never arms it. The
80
+ advisory names the approximate avoidable context-token count and the host-native actions that
81
+ move the re-cache to pruned context:
82
+ native compaction or a normal exit + resume/restart. Resubmitting immediately proceeds. The block fires at most
83
+ once per cold window; a subsequent warm submit (idle < floor) resets the window so the next
84
+ genuine cold stretch re-arms. The gate is strictly opt-in, never fires in `dry`/`off` mode,
85
+ and fails open on any error — a pruner fault will never block the session.
86
+
87
+ ## When NOT to use
88
+
89
+ - Context bar nowhere near compaction — the most recent turns are protected anyway.
90
+ - Install health → `/ca-doctor`.
91
+ - Project progress → `/ca-status`.
92
+
93
+ ## Hard gate
94
+
95
+ - MUST NOT run `--execute` against the **live** session's transcript — the tool refuses a
96
+ recently-modified file by construction; manual `run` targets copies or old sessions only.
97
+ - MUST surface the native-boundary-only gains limitation whenever a user expects an immediate
98
+ active-file context drop.
99
+ - MUST NOT enable the service (`CODEARBITER_PRUNE=on`) on behalf of the user — explain and let
100
+ them decide.