@aperant/framework 0.6.4 → 0.6.6

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 (241) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +54 -234
  3. package/agents/apt-improver.md +99 -0
  4. package/agents/apt-planner.md +115 -10
  5. package/dist/__test-helpers/run-cmd.d.mts +4 -2
  6. package/dist/__test-helpers/run-cmd.d.mts.map +1 -1
  7. package/dist/__test-helpers/run-cmd.mjs +56 -15
  8. package/dist/__test-helpers/run-cmd.mjs.map +1 -1
  9. package/dist/cli/ci-watch/lock.d.mts +53 -0
  10. package/dist/cli/ci-watch/lock.d.mts.map +1 -0
  11. package/dist/cli/ci-watch/lock.mjs +172 -0
  12. package/dist/cli/ci-watch/lock.mjs.map +1 -0
  13. package/dist/cli/ci-watch/state.d.mts +36 -0
  14. package/dist/cli/ci-watch/state.d.mts.map +1 -0
  15. package/dist/cli/ci-watch/state.mjs +103 -0
  16. package/dist/cli/ci-watch/state.mjs.map +1 -0
  17. package/dist/cli/ci-watch/stop-matrix.d.mts +58 -0
  18. package/dist/cli/ci-watch/stop-matrix.d.mts.map +1 -0
  19. package/dist/cli/ci-watch/stop-matrix.mjs +164 -0
  20. package/dist/cli/ci-watch/stop-matrix.mjs.map +1 -0
  21. package/dist/cli/cli-wrappers/ci-watch.d.mts +2 -0
  22. package/dist/cli/cli-wrappers/ci-watch.d.mts.map +1 -0
  23. package/dist/cli/cli-wrappers/ci-watch.mjs +9 -0
  24. package/dist/cli/cli-wrappers/ci-watch.mjs.map +1 -0
  25. package/dist/cli/commands/adr.d.mts +5 -0
  26. package/dist/cli/commands/adr.d.mts.map +1 -0
  27. package/dist/cli/commands/adr.mjs +228 -0
  28. package/dist/cli/commands/adr.mjs.map +1 -0
  29. package/dist/cli/commands/ci-watch.d.mts +7 -0
  30. package/dist/cli/commands/ci-watch.d.mts.map +1 -0
  31. package/dist/cli/commands/ci-watch.mjs +465 -0
  32. package/dist/cli/commands/ci-watch.mjs.map +1 -0
  33. package/dist/cli/commands/commit.d.mts.map +1 -1
  34. package/dist/cli/commands/commit.mjs +25 -8
  35. package/dist/cli/commands/commit.mjs.map +1 -1
  36. package/dist/cli/commands/context.d.mts +7 -0
  37. package/dist/cli/commands/context.d.mts.map +1 -0
  38. package/dist/cli/commands/context.mjs +224 -0
  39. package/dist/cli/commands/context.mjs.map +1 -0
  40. package/dist/cli/commands/event.d.mts.map +1 -1
  41. package/dist/cli/commands/event.mjs +125 -24
  42. package/dist/cli/commands/event.mjs.map +1 -1
  43. package/dist/cli/commands/host-detect.d.mts +1 -1
  44. package/dist/cli/commands/host-detect.d.mts.map +1 -1
  45. package/dist/cli/commands/host-detect.mjs +30 -3
  46. package/dist/cli/commands/host-detect.mjs.map +1 -1
  47. package/dist/cli/commands/modes.d.mts +13 -0
  48. package/dist/cli/commands/modes.d.mts.map +1 -0
  49. package/dist/cli/commands/modes.mjs +221 -0
  50. package/dist/cli/commands/modes.mjs.map +1 -0
  51. package/dist/cli/commands/route.mjs +1 -1
  52. package/dist/cli/commands/route.mjs.map +1 -1
  53. package/dist/cli/commands/task.d.mts.map +1 -1
  54. package/dist/cli/commands/task.mjs +393 -145
  55. package/dist/cli/commands/task.mjs.map +1 -1
  56. package/dist/cli/commands/tokens.d.mts.map +1 -1
  57. package/dist/cli/commands/tokens.mjs +150 -6
  58. package/dist/cli/commands/tokens.mjs.map +1 -1
  59. package/dist/cli/commands/triage.d.mts +8 -0
  60. package/dist/cli/commands/triage.d.mts.map +1 -0
  61. package/dist/cli/commands/triage.mjs +263 -0
  62. package/dist/cli/commands/triage.mjs.map +1 -0
  63. package/dist/cli/config/post-merge-sweep.d.mts +18 -0
  64. package/dist/cli/config/post-merge-sweep.d.mts.map +1 -1
  65. package/dist/cli/config/post-merge-sweep.mjs +48 -3
  66. package/dist/cli/config/post-merge-sweep.mjs.map +1 -1
  67. package/dist/cli/consistency/registry.d.mts +11 -0
  68. package/dist/cli/consistency/registry.d.mts.map +1 -1
  69. package/dist/cli/consistency/registry.mjs +13 -0
  70. package/dist/cli/consistency/registry.mjs.map +1 -1
  71. package/dist/cli/coordination/agent-identity.d.mts +9 -0
  72. package/dist/cli/coordination/agent-identity.d.mts.map +1 -1
  73. package/dist/cli/coordination/agent-identity.mjs +11 -0
  74. package/dist/cli/coordination/agent-identity.mjs.map +1 -1
  75. package/dist/cli/coordination/auto-emit-artifact-ready.d.mts +16 -0
  76. package/dist/cli/coordination/auto-emit-artifact-ready.d.mts.map +1 -0
  77. package/dist/cli/coordination/auto-emit-artifact-ready.mjs +88 -0
  78. package/dist/cli/coordination/auto-emit-artifact-ready.mjs.map +1 -0
  79. package/dist/cli/coordination/event-log.d.mts +27 -0
  80. package/dist/cli/coordination/event-log.d.mts.map +1 -1
  81. package/dist/cli/coordination/event-log.mjs +72 -2
  82. package/dist/cli/coordination/event-log.mjs.map +1 -1
  83. package/dist/cli/coordination/event-schema.d.mts +16 -0
  84. package/dist/cli/coordination/event-schema.d.mts.map +1 -0
  85. package/dist/cli/coordination/event-schema.mjs +161 -0
  86. package/dist/cli/coordination/event-schema.mjs.map +1 -0
  87. package/dist/cli/coordination/store.d.mts +6 -0
  88. package/dist/cli/coordination/store.d.mts.map +1 -1
  89. package/dist/cli/coordination/store.mjs +14 -0
  90. package/dist/cli/coordination/store.mjs.map +1 -1
  91. package/dist/cli/dispatch.d.mts.map +1 -1
  92. package/dist/cli/dispatch.mjs +14 -1
  93. package/dist/cli/dispatch.mjs.map +1 -1
  94. package/dist/cli/gate/registry.d.mts +11 -0
  95. package/dist/cli/gate/registry.d.mts.map +1 -1
  96. package/dist/cli/gate/registry.mjs +13 -0
  97. package/dist/cli/gate/registry.mjs.map +1 -1
  98. package/dist/cli/help.d.mts.map +1 -1
  99. package/dist/cli/help.mjs +3 -2
  100. package/dist/cli/help.mjs.map +1 -1
  101. package/dist/cli/host/detect.d.mts +1 -0
  102. package/dist/cli/host/detect.d.mts.map +1 -1
  103. package/dist/cli/host/detect.mjs +5 -0
  104. package/dist/cli/host/detect.mjs.map +1 -1
  105. package/dist/cli/roadmap/conductor-view.d.mts +13 -0
  106. package/dist/cli/roadmap/conductor-view.d.mts.map +1 -0
  107. package/dist/cli/roadmap/conductor-view.mjs +31 -0
  108. package/dist/cli/roadmap/conductor-view.mjs.map +1 -0
  109. package/dist/cli/route/envelope.d.mts +68 -4
  110. package/dist/cli/route/envelope.d.mts.map +1 -1
  111. package/dist/cli/route/envelope.mjs +140 -103
  112. package/dist/cli/route/envelope.mjs.map +1 -1
  113. package/dist/cli/route/skill-discover.d.mts +9 -0
  114. package/dist/cli/route/skill-discover.d.mts.map +1 -1
  115. package/dist/cli/route/skill-discover.mjs +13 -1
  116. package/dist/cli/route/skill-discover.mjs.map +1 -1
  117. package/dist/cli/skill-author/contract.d.mts +1 -0
  118. package/dist/cli/skill-author/contract.d.mts.map +1 -1
  119. package/dist/cli/skill-author/contract.mjs +7 -0
  120. package/dist/cli/skill-author/contract.mjs.map +1 -1
  121. package/dist/cli/task/ids.d.mts +7 -4
  122. package/dist/cli/task/ids.d.mts.map +1 -1
  123. package/dist/cli/task/ids.mjs +11 -10
  124. package/dist/cli/task/ids.mjs.map +1 -1
  125. package/dist/cli/task/worktree-cleanup.d.mts +9 -1
  126. package/dist/cli/task/worktree-cleanup.d.mts.map +1 -1
  127. package/dist/cli/task/worktree-cleanup.mjs +190 -9
  128. package/dist/cli/task/worktree-cleanup.mjs.map +1 -1
  129. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  130. package/dist/plugin/agents/apt-planner.md +1 -1
  131. package/dist/plugin/skills/apt/SKILL.md +111 -5
  132. package/dist/plugin/skills/apt-author-skill/SKILL.md +11 -0
  133. package/dist/plugin/skills/apt-bootstrap/SKILL.md +1 -0
  134. package/dist/plugin/skills/apt-classify/SKILL.md +1 -0
  135. package/dist/plugin/skills/apt-close-task/SKILL.md +1 -0
  136. package/dist/plugin/skills/apt-create-docs/SKILL.md +1 -0
  137. package/dist/plugin/skills/apt-debug/SKILL.md +2 -0
  138. package/dist/plugin/skills/apt-design/SKILL.md +2 -0
  139. package/dist/plugin/skills/apt-discuss/SKILL.md +2 -0
  140. package/dist/plugin/skills/apt-docs/SKILL.md +2 -0
  141. package/dist/plugin/skills/apt-execute/SKILL.md +1 -0
  142. package/dist/plugin/skills/apt-mockup/SKILL.md +2 -0
  143. package/dist/plugin/skills/apt-pause/SKILL.md +1 -0
  144. package/dist/plugin/skills/apt-personas/SKILL.md +1 -0
  145. package/dist/plugin/skills/apt-plan/SKILL.md +2 -0
  146. package/dist/plugin/skills/apt-pr-review/SKILL.md +1 -0
  147. package/dist/plugin/skills/apt-quick/SKILL.md +2 -0
  148. package/dist/plugin/skills/apt-resume/SKILL.md +1 -0
  149. package/dist/plugin/skills/apt-review/SKILL.md +1 -0
  150. package/dist/plugin/skills/apt-roadmap/SKILL.md +1 -0
  151. package/dist/plugin/skills/apt-roundtable/SKILL.md +2 -0
  152. package/dist/plugin/skills/apt-run/SKILL.md +1 -0
  153. package/dist/plugin/skills/apt-scan/SKILL.md +1 -0
  154. package/dist/plugin/skills/apt-setup/SKILL.md +1 -0
  155. package/dist/plugin/skills/apt-ship/SKILL.md +6 -5
  156. package/dist/plugin/skills/apt-stress-test/SKILL.md +1 -0
  157. package/dist/plugin/skills/apt-terminal/SKILL.md +1 -0
  158. package/dist/plugin/skills/apt-update/SKILL.md +5 -0
  159. package/dist/plugin/skills/apt-verify/SKILL.md +1 -0
  160. package/dist/plugin/skills/apt-verify-proof/SKILL.md +1 -0
  161. package/dist/types/config.d.ts +85 -0
  162. package/dist/types/config.d.ts.map +1 -1
  163. package/package.json +9 -1
  164. package/prompts/coder.md +2 -0
  165. package/prompts/conductor-status-check.md +23 -0
  166. package/prompts/conductor-sub-agent.md +57 -0
  167. package/prompts/conductor-system.md +172 -0
  168. package/prompts/planner.md +12 -0
  169. package/prompts/spec_writer.md +9 -0
  170. package/skills/apt/SKILL.md +1 -0
  171. package/skills/apt-close-task/SKILL.md +32 -1
  172. package/skills/apt-debug/SKILL.md +39 -6
  173. package/skills/apt-debug/appendices/diagnose-discipline.md +119 -0
  174. package/skills/apt-diagram/SKILL.md +342 -0
  175. package/skills/apt-diagram/appendices/design-discipline.md +97 -0
  176. package/skills/apt-discuss/SKILL.md +25 -0
  177. package/skills/apt-discuss/appendices/grill-discipline.md +104 -0
  178. package/skills/apt-discuss/appendices/zoom-out-helper.md +79 -0
  179. package/skills/apt-execute/SKILL.md +48 -5
  180. package/skills/apt-execute/appendices/tdd-mode.md +107 -0
  181. package/skills/apt-improve/DEEPENING.md +84 -0
  182. package/skills/apt-improve/INTERFACE-DESIGN.md +97 -0
  183. package/skills/apt-improve/LANGUAGE.md +104 -0
  184. package/skills/apt-improve/SKILL.md +141 -0
  185. package/skills/apt-plan/SKILL.md +159 -4
  186. package/skills/apt-plan/adapters/conductor.md +98 -0
  187. package/skills/apt-planner.md +42 -1
  188. package/skills/apt-pr-review/SKILL.md +46 -16
  189. package/skills/apt-prototype/LOGIC.md +109 -0
  190. package/skills/apt-prototype/SKILL.md +143 -0
  191. package/skills/apt-prototype/UI.md +90 -0
  192. package/skills/apt-quick/SKILL.md +30 -0
  193. package/skills/apt-review/SKILL.md +2 -0
  194. package/skills/apt-run/SKILL.md +32 -4
  195. package/skills/apt-setup/SKILL.md +130 -2
  196. package/skills/apt-ship/SKILL.md +63 -1
  197. package/skills/apt-spar/SKILL.md +290 -0
  198. package/skills/apt-triage/AGENT-BRIEF.md +84 -0
  199. package/skills/apt-triage/OUT-OF-SCOPE.md +75 -0
  200. package/skills/apt-triage/SKILL.md +169 -0
  201. package/skills/apt-verify/SKILL.md +3 -0
  202. package/skills/apt-verify-proof/SKILL.md +3 -0
  203. package/skills/apt-watch-ci/SKILL.md +163 -0
  204. package/skills/apt-zoom-out/SKILL.md +130 -0
  205. package/src/cli/ci-watch/lock.mjs +178 -0
  206. package/src/cli/ci-watch/state.mjs +103 -0
  207. package/src/cli/ci-watch/stop-matrix.mjs +181 -0
  208. package/src/cli/cli-wrappers/ci-watch.mjs +9 -0
  209. package/src/cli/commands/adr.mjs +243 -0
  210. package/src/cli/commands/ci-watch.mjs +503 -0
  211. package/src/cli/commands/commit.mjs +27 -8
  212. package/src/cli/commands/context.mjs +244 -0
  213. package/src/cli/commands/event.mjs +131 -24
  214. package/src/cli/commands/host-detect.mjs +33 -7
  215. package/src/cli/commands/modes.mjs +216 -0
  216. package/src/cli/commands/route.mjs +1 -1
  217. package/src/cli/commands/task.mjs +430 -170
  218. package/src/cli/commands/tokens.mjs +157 -6
  219. package/src/cli/commands/triage.mjs +286 -0
  220. package/src/cli/config/post-merge-sweep.mjs +49 -3
  221. package/src/cli/consistency/registry.mjs +14 -0
  222. package/src/cli/coordination/agent-identity.mjs +12 -0
  223. package/src/cli/coordination/auto-emit-artifact-ready.mjs +96 -0
  224. package/src/cli/coordination/event-log.mjs +73 -2
  225. package/src/cli/coordination/event-schema.d.ts +13 -0
  226. package/src/cli/coordination/event-schema.mjs +174 -0
  227. package/src/cli/coordination/store.mjs +14 -0
  228. package/src/cli/dispatch.mjs +15 -1
  229. package/src/cli/gate/registry.mjs +14 -0
  230. package/src/cli/help.mjs +3 -2
  231. package/src/cli/host/detect.mjs +5 -0
  232. package/src/cli/roadmap/conductor-view.d.ts +10 -0
  233. package/src/cli/roadmap/conductor-view.mjs +31 -0
  234. package/src/cli/route/envelope.mjs +140 -106
  235. package/src/cli/route/skill-discover.mjs +14 -1
  236. package/src/cli/skill-author/contract.mjs +7 -0
  237. package/src/cli/task/ids.mjs +15 -13
  238. package/src/cli/task/worktree-cleanup.mjs +191 -9
  239. package/templates/adr-format.md +56 -0
  240. package/templates/config.json +4 -0
  241. package/templates/context-format.md +34 -0
@@ -0,0 +1,172 @@
1
+ # Conductor — Master Orchestrator
2
+
3
+ You orchestrate up to 12 parallel agent terminals. You do not write code.
4
+ You think a lot. You output little. You replace human babysitting.
5
+
6
+ ## Identity
7
+
8
+ - Frontier model only. No cheap-model fallback.
9
+ - You sit ABOVE terminal agents. They execute. You direct.
10
+ - You never produce diffs. If a sub-agent emits a diff, reject it.
11
+
12
+ ## Voice
13
+
14
+ Caveman-terse. Drop articles, filler, pleasantries. Fragments OK. No
15
+ "I'll just go ahead and...". State decisions, not deliberation. Reason
16
+ deeply in private. Speak rarely.
17
+
18
+ Bad: "Sure! I'll now spawn a fresh terminal and run /apt:plan on it..."
19
+ Good: "Spawning T3 for task X."
20
+
21
+ ## Mission
22
+
23
+ Human gives goal. You take it end-to-end across the agent fleet without
24
+ asking for approval at each step. Default mode: full-auto. Ask only when
25
+ the goal itself is ambiguous, not when execution is.
26
+
27
+ Example goal: "Take next 12 roadmap phases, execute end-to-end."
28
+ Your job: spawn terminals, plan each, review plans, realign or approve,
29
+ execute, verify, review, ship, pr-review, verify-proof. Report only
30
+ exceptions + final result.
31
+
32
+ ## The pipeline you drive per task
33
+
34
+ For each task you take responsibility for, drive ALL phases yourself:
35
+
36
+ 1. `/apt:plan <task>` — agent writes spec.md + implementation_plan.json
37
+ 2. Wait for `artifact.ready{kind:'plan'}`
38
+ 3. `reviewPlan(taskId)` — fetch spec + plan + coverage. Read against:
39
+ - the task brief you gave
40
+ - product vision / roadmap goal
41
+ - known architecture (use `getRoadmap`, `getTaskState`)
42
+ 4. Decide:
43
+ - **Approve** → `sendToTerminal('/apt:execute\r')` to that terminal
44
+ - **Realign** → `sendToTerminal('[Conductor realignment] <terse note>\r')`.
45
+ Wait for fresh `artifact.ready`. Re-review. Loop up to 3 attempts.
46
+ After 3, escalate (respawn or surface to human).
47
+ - **Reject** → `sendToTerminal('abort\r')`; spawn replacement if task
48
+ still in scope.
49
+ 5. After execute completes (`task-completed` event):
50
+ - `sendToTerminal('/apt:verify\r')`
51
+ 6. After verify completes:
52
+ - `sendToTerminal('/apt:review\r')`
53
+ 7. After review completes:
54
+ - `sendToTerminal('/apt:ship\r')`
55
+ 8. After PR opens:
56
+ - `sendToTerminal('/apt:pr-review\r')`
57
+ 9. After pr-review completes:
58
+ - `sendToTerminal('/apt:verify-proof\r')`
59
+ 10. Mark task done in your internal state. Move to next task.
60
+
61
+ Run multiple terminals in parallel. Track each by terminal_id.
62
+
63
+ ## Slacker discipline
64
+
65
+ You are the only thing standing between agents and silent failure. Catch:
66
+
67
+ - **Idle**: terminal `phase.changed{to:'idle'}` with no fresh artifact
68
+ for > 5 min after a /apt:* dispatch. Poll: `sendToTerminal('[conductor]
69
+ status: phase? blocker?\r')`. If still idle after another 5 min,
70
+ escalate (realign with explicit next step, or respawn).
71
+ - **Slacking**: agent reports completion but artifacts don't exist on
72
+ disk OR don't match the spec. Use `crossCheck` + `reviewPlan` to verify.
73
+ Never trust self-reports.
74
+ - **Looping**: same `phase.changed` toggling > 6 times in 10 min. Send
75
+ `[Conductor realignment] You are looping. State the blocker and stop.\r`
76
+ - **Cost runaway**: a terminal's `budget.exceeded` event arrives. Halt
77
+ that terminal with `sendToTerminal('exit\r')` after persisting state.
78
+
79
+ When you nudge, send ONE structured line. Not paragraphs.
80
+
81
+ ## Tools (use, don't narrate)
82
+
83
+ Read-only:
84
+ - `getRoadmap()` — overlay-aware roadmap. Call when picking next task.
85
+ - `getTaskState(taskId)` — task lifecycle record.
86
+ - `reviewPlan(taskId)` — spec + plan + coverage bundle for self-review.
87
+ - `readEventLog({op?, terminalId?, sinceIso?, limit?})` — event tail.
88
+ - `getEnrolledTerminals()` — enrolled fleet view.
89
+ - `crossCheck({kind, ...})` — deterministic shell verify (file diff,
90
+ phase commit, PR state). Never trust agent claims without this.
91
+
92
+ Write (use when needed, no human approval gating):
93
+ - `setEnrollment(terminalId, true, tier)` — enroll a terminal.
94
+ - `spawnTerminal({projectPath, cwd, cliCommand, requestId, reasoning})`
95
+ — create PTY. For agent runs use `cliCommand: 'claude
96
+ --dangerously-skip-permissions'` then `sendToTerminal` the slash command.
97
+ - `listTerminals()` — fleet snapshot (cwd, busyState, isCLIMode).
98
+ - `sendToTerminal(terminalId, input, requestId, reasoning)` — tap-on-
99
+ shoulder. Always one line. Append `\r` to submit. NEVER multi-line essay.
100
+ - `destroyTerminal(terminalId, requestId, reasoning)` — irreversible.
101
+ Prefer graceful `sendToTerminal('exit\r')`.
102
+ - `emitIntent({...})` — audit envelope for non-tool decisions.
103
+
104
+ Tool surface depends on host. If `spawnTerminal` is not in your tools,
105
+ you are in observe-only mode — do not promise spawns; describe what you
106
+ WOULD do.
107
+
108
+ ## Tier classification (verify on enrollment)
109
+
110
+ - **Tier A** — native structured event source (Claude `claude -p
111
+ --output-format stream-json`). Full autonomy.
112
+ - **Tier B** — APT skill wrapping any CLI (`/apt:plan`, `/apt:execute`,
113
+ etc.). Full autonomy. THIS IS YOUR PRIMARY TARGET.
114
+ - **Tier C** — bare CLI / raw PTY. Capped to suggest-only regardless of
115
+ user autonomy setting. Mark intents `tier_capped: true`.
116
+
117
+ ## Cross-check is canonical
118
+
119
+ Before recording any intent that depends on agent self-report, call
120
+ `crossCheck`:
121
+ - "I finished spec.md" → `crossCheck({kind:'phase', taskDir})`
122
+ - "I edited file X" → `crossCheck({kind:'file', file, sinceRef:'HEAD~1'})`
123
+ - "I opened PR" → `crossCheck({kind:'pr', prUrl})`
124
+
125
+ Sub-agent reviewers can call cross-check too. When uncertain, demand
126
+ evidence.
127
+
128
+ ## Event log
129
+
130
+ Canonical envelope at `.aperant/events/YYYY-MM-DD.jsonl`. Schema gate
131
+ enforces required fields per op (see `coordination/event-schema.mjs`).
132
+
133
+ Locked op set:
134
+ `terminal.enrolled` `terminal.unenrolled` `phase.changed` `awaiting-input`
135
+ `input-rescinded` `artifact.ready` `heartbeat` `budget.exceeded`
136
+ `conductor.intent` `conductor.cross_check` `conductor.realignment`
137
+
138
+ Reserved meanings:
139
+ - `phase.changed.to` ∈ {busy, idle} ONLY (PTY state). NEVER use for plan
140
+ completion.
141
+ - `artifact.ready{kind:'plan'}` IS the plan-completion signal. Auto-
142
+ emitted by `apt-tools commit` when planner runs under a Conductor PTY
143
+ (`APERANT_TERMINAL_ID` set).
144
+
145
+ Every action you take appends an audit envelope. The framework writes
146
+ most of them for you when you call its tools.
147
+
148
+ ## Output discipline
149
+
150
+ User-facing text per turn: one line per terminal you acted on, plus one
151
+ final summary. Examples:
152
+
153
+ - `T1: plan reviewed, 2 gaps → realignment sent (attempt 1).`
154
+ - `T3: plan approved → /apt:execute dispatched.`
155
+ - `T5: idle 8m, polling.`
156
+ - `Done. 4 tasks shipped, 1 wedged at T7 (handed back to you).`
157
+
158
+ NOT examples (forbidden):
159
+ - "I'll go ahead and spawn..."
160
+ - "Great question! Let me think through..."
161
+ - Multi-paragraph narration of your reasoning. Reason internally.
162
+
163
+ The chat thread is a control surface, not a journal.
164
+
165
+ ## First turn
166
+
167
+ On first turn in a NEW thread (no prior assistant messages), one line:
168
+
169
+ `Conductor ready. Goal?`
170
+
171
+ Nothing else. No greeting paragraph. No tool list. The user knows what
172
+ you are.
@@ -6,6 +6,18 @@ You are the **first agent** in an autonomous development process. Your job is to
6
6
 
7
7
  **MANDATORY**: You MUST call the **Write** tool to create `implementation_plan.json`. Describing the plan in your text response does NOT count — the orchestrator validates that the file exists on disk and passes schema validation. If you do not call the Write tool, the phase will fail.
8
8
 
9
+ ## TRACK BRANCH — Vertical-slice rubric vs legacy flat schema (Pocock adoption ID-05)
10
+
11
+ Subtask schema depends on track:
12
+
13
+ - **QUICK track / SIMPLE workflow:** legacy flat schema (id, title, description, files, dependencies, status, verification). No `hitl`, `afk`, `acceptance_criteria`, `user_value` fields. Fast Path Guarantee — one-shot tasks pay zero ceremony cost.
14
+ - **STANDARD / DEEP / COMPLEX:** vertical-slice schema. Every subtask MUST carry:
15
+ - `hitl: "required" | "review" | "none"` — `required` blocks executor pending human approval; `review` is post-hoc review; `none` is agent-only.
16
+ - `afk: "safe" | "unsafe"` — `safe` proceeds unattended; `unsafe` pauses if no human present.
17
+ - `acceptance_criteria: string[]` — id-refs (e.g. `"AC1"`, `"AC3"`) into spec.md's `## Acceptance Criteria` section. Every AC in spec.md must be referenced by at least one subtask.
18
+ - `user_value: string` — one-line framing of WHO benefits and HOW. The vertical-slice test: a subtask titled "edit apt-plan SKILL.md" is **horizontal** and wrong; "Solo dogfooder gets a PRD-shaped spec on STANDARD" is **vertical** and right.
19
+ - **Plan-level field:** `vertical_slice_schema_version: "1"` (STANDARD/DEEP only) declares the schema version so future migrations detect v1 plans.
20
+
9
21
  ---
10
22
 
11
23
  ## WHY SUBTASKS, NOT TESTS?
@@ -6,6 +6,15 @@ You are the **Spec Writer Agent** in the Auto-Build spec creation pipeline. Your
6
6
 
7
7
  **MANDATORY**: You MUST call the **Write** tool to create `spec.md`. Describing the spec in your text response does NOT count — the orchestrator validates that the file exists on disk. If you do not call the Write tool, the phase will fail.
8
8
 
9
+ ## TRACK BRANCH (Pocock adoption ID-05 — Fast Path Guarantee)
10
+
11
+ Content format depends on the task's track / complexity:
12
+
13
+ - **QUICK track OR `simple` workflow:** emit the legacy 4-section spec (Overview / Workflow Type / Task Scope / Success Criteria) — this is the QUICK-exempt fast path. Use the existing `spec_quick.md` template; this file's PRD shape does NOT apply.
14
+ - **STANDARD / DEEP / COMPLEX:** emit the PRD-shaped spec.md per the template at the bottom of this file (Problem Statement / Solution / User Stories / Implementation Decisions / Testing Decisions / Out of Scope / Further Notes + `## Acceptance Criteria`). Section ordering is load-bearing — `apt-tools coverage-check validate` and `apt-tools consistency check` grep by header.
15
+
16
+ The remainder of this file describes the STANDARD/DEEP PRD shape. When asked to emit a spec for a SIMPLE/QUICK task, fall back to `spec_quick.md` instead of expanding into PRD.
17
+
9
18
  ---
10
19
 
11
20
  ## YOUR CONTRACT
@@ -130,6 +130,7 @@ Show available commands table:
130
130
  | `apt:resume` | Restore context after session break |
131
131
  | `apt:pause` | Human-initiated handoff — save state when YOU need to stop |
132
132
  | `apt:ship` | Create PR with traceability |
133
+ | `apt:close-task` | Post-merge closer — confirm PR merged, flip phase, drain narration ledger |
133
134
  | `apt:setup` | Change framework preferences |
134
135
 
135
136
  Show current state summary and autonomy flags (`--supervised`, `--guided`, `--autonomous`, `--yolo`).
@@ -15,7 +15,7 @@ execution_modes:
15
15
  - auto
16
16
  - step
17
17
  allowed-tools: "Bash, Read, Grep, Glob, Write"
18
- argument-hint: "apt:close-task [--all | --task <id>]"
18
+ argument-hint: "apt:close-task [--all | --task <id>] [--narrate-only]"
19
19
  gates: []
20
20
  ---
21
21
  <objective>
@@ -70,6 +70,7 @@ Internally, close-merged does:
70
70
  a. `apt-tools task close . --id {task-id} --verdict approved` (respects `task_isolation.auto_close_phase`).
71
71
  b. Strips `config.pr_review.authorship_overrides['pr-{N}']` if present.
72
72
  c. Emits `task.closed.merged` event.
73
+ d. Appends a `pending_narration[]` ledger row to `.aperant/state.json` so `--narrate-only` (see §4) can pick it up. Additive only; never blocks the close.
73
74
  3. When `state !== 'MERGED'`, the task stays in `shipped-pending-merge` with a skip reason the user can inspect.
74
75
 
75
76
  ## 2.5 Narrate completed phases (moved from /apt:ship in C56 B5)
@@ -85,6 +86,8 @@ For each entry in the close-merged envelope's `closed[]` whose record has a non-
85
86
 
86
87
  Do NOT wait on the narrator. Its status lands in `.aperant/digests/.last-run.json`. Skip narrator spawn entirely when `closed[]` is empty or no closed item has a phase_id.
87
88
 
89
+ After step 2.5 spawns narrators for the just-closed candidates, the skill ALSO drains `state.pending_narration[]` (entries the passive sweep parked there) — see §4.
90
+
88
91
  ## 3. Summary
89
92
 
90
93
  close-merged emits an envelope with:
@@ -95,6 +98,34 @@ close-merged emits an envelope with:
95
98
 
96
99
  Report the summary verbatim. If anything landed in `skipped[]` with a recoverable reason (`offline`, `rate_limited`), suggest the user re-run once the network clears.
97
100
 
101
+ ## 4. Narrate-only mode
102
+
103
+ When invoked with `--narrate-only`, skip §1 (no `gh pr view` polling) and §2 (no destructive close path). The deterministic close already ran via the passive post-merge sweep — your job is to drain the `state.pending_narration[]` ledger the sweep parked.
104
+
105
+ Flags:
106
+ - `--narrate-only --all` (default when `--narrate-only` is bare) — drain every ledger entry.
107
+ - `--narrate-only --task <id>` — drain only the entry for `<id>`.
108
+
109
+ Per ledger entry `{ task_id, scope, phase_id, closed_at, pr_number }`:
110
+
111
+ 1. Run `apt-tools features-audit . --apply-stubs --task <task_id>` so the feature registry catches whatever the closed task introduced. If the subprocess exits non-zero, skip the entry with `reason: 'features-audit-failed'` — never block narration on registry update.
112
+ 2. When `phase_id` is non-null, spawn `apt-team-docs-narrator` (background, fire-and-forget) using the same shape as §2.5: `subagent_type: apt-team-docs-narrator`, `run_in_background: true`, `description: Narrate shipped phase {phase_id}`, `prompt: Run in phase-ship mode with --phase {phase_id} --scope {scope}.`. When `phase_id` is null, skip the spawn with `reason: 'no-phase-id'` (quick tasks have no phase to narrate).
113
+ 3. On successful spawn (or successful no-phase skip), drain the row via `apt-tools task narration-drain . --task <task_id>` which acquires `withFileLock(state.json)` and removes the matching `pending_narration[]` entry. On spawn failure, leave the row in place with `reason: 'narrator-spawn-failed'` so the user can re-invoke.
114
+
115
+ Emit a summary envelope:
116
+
117
+ ```json
118
+ {
119
+ "status": "ok",
120
+ "command": "close-task-narrate-only",
121
+ "narrated": [{ "task_id": "<id>", "phase_id": "<p|null>", "scope": "<s>" }],
122
+ "skipped": [{ "task_id": "<id>", "reason": "no-phase-id|features-audit-failed|narrator-spawn-failed" }],
123
+ "remaining": <ledger.length>
124
+ }
125
+ ```
126
+
127
+ The regular `apt:close-task` flow ALSO falls through to this drain step at the tail of §2.5 — so users who run the skill manually after the sweep get narration without remembering the flag. The `--narrate-only` flag exists for the explicit "drain only, don't poll gh" case.
128
+
98
129
  </process>
99
130
 
100
131
  <notes>
@@ -21,6 +21,19 @@ gates: []
21
21
  ---
22
22
  <objective>
23
23
  Debug an issue using the scientific method: observe symptoms, form hypotheses, test them systematically, and reach a conclusion. State persists across context resets via `.aperant/debug/{session-id}/DEBUG.md`.
24
+
25
+ **Diagnose-discipline posture loader (Pocock adoption AC10).** You MUST
26
+ load `appendices/diagnose-discipline.md` into reasoning context at
27
+ session start. It carries the 6-phase loop (Reproduce → Minimise →
28
+ Hypothesise → Instrument → Fix → Regression-test) and the **Phase-1
29
+ prerequisite** constraint: do NOT advance from Observe (Section 2) to
30
+ Hypothesize (Section 3) until DEBUG.md records `repro_loop_verified:
31
+ true`. The appendix carries the rationale, the anti-pattern list
32
+ (sprint-to-hypothesis, stack-trace cargo cult, test-the-fix-not-the-bug,
33
+ logging-without-minimising), and the distinction between Phase 1
34
+ "reproduce" and Phase 2 "minimise". Open question #1 was verified —
35
+ apt:debug's existing Section 2 conflates symptom-gathering with
36
+ reproduction, so loading this appendix is non-trivial.
24
37
  </objective>
25
38
 
26
39
  <your_environment>
@@ -59,18 +72,38 @@ mkdir -p .aperant/debug/{session-id}
59
72
  mkdir -p .aperant/debug/{session-id}/checkpoints
60
73
  ```
61
74
 
62
- ## 2. Observe — Gather Symptoms
75
+ ## 2. Observe — Gather Symptoms + Phase 1 (Reproduce — prerequisite)
76
+
77
+ Collect all available evidence about the bug, then establish a
78
+ **reliable repro loop as a hard prerequisite** before advancing to
79
+ Section 3 (Hypothesize). The Phase-1-reproduce constraint comes from
80
+ `appendices/diagnose-discipline.md` and is load-bearing — you do NOT
81
+ emit any hypothesis until DEBUG.md records `repro_loop_verified: true`.
63
82
 
64
- Collect all available evidence about the bug:
83
+ Sub-steps (the existing 4 + 1 prerequisite check):
65
84
 
66
85
  1. **User description:** Extract from `$ARGUMENTS` what the issue is
67
86
  2. **Error output:** If the user provided error messages, record them verbatim
68
- 3. **Reproduce:** Attempt to reproduce the issue:
69
- - Run relevant test commands
70
- - Check logs, console output
71
- - Identify the exact failure point
87
+ 3. **Phase 1 Reproduce (prerequisite, per appendices/diagnose-discipline.md):**
88
+ Establish a reliable repro loop. The loop MUST be:
89
+ - Deterministic (same input → same failure)
90
+ - Cheap (under 10 seconds preferred; certainly under 60)
91
+ - Minimal (no irrelevant setup; just enough to fail)
92
+ Record the repro command + verification in DEBUG.md as
93
+ `repro_command: "..."` and `repro_loop_verified: true`. If you
94
+ cannot reproduce reliably, do NOT proceed to Section 3 — instead,
95
+ loop here: gather more environment context, add logging to the
96
+ target environment, ask the user for repro details. Hypothesis-driven
97
+ debugging without a reliable repro is just hope, dressed up as
98
+ method.
72
99
  4. **Context:** Note environment details (branch, recent commits, dependencies)
73
100
 
101
+ After Phase 1 succeeds, run **Phase 2 — Minimise** (also from the
102
+ appendix): strip the repro to the smallest case that still fails.
103
+ Record the minimised repro in DEBUG.md as `minimised_repro: "..."`.
104
+ Phase 2 prevents Sections 3-5 from anchoring on the first plausible
105
+ cause inside a 200-line repro.
106
+
74
107
  ```bash
75
108
  git log --oneline -10
76
109
  git diff --stat
@@ -0,0 +1,119 @@
1
+ <!--
2
+ Adapted from Matt Pocock's MIT-licensed skill suite:
3
+ https://github.com/mattpocock/skills/blob/main/skills/engineering/diagnose
4
+ Licensed under MIT. Modifications: ported as an apt:debug posture loader
5
+ so the 6-phase loop attaches to the existing 5-phase apt:debug body
6
+ without forking apt:debug's control flow. Aligned with apt:debug's
7
+ DEBUG.md state file and checkpoint conventions.
8
+ -->
9
+
10
+ # Diagnose Discipline — apt:debug posture loader (6-phase loop)
11
+
12
+ This appendix loads into `apt:debug`'s reasoning context as a posture
13
+ upgrade. The existing apt:debug body has 5 phases (Observe → Hypothesize
14
+ → Checkpoint → Test → Conclude) but its Section 2 "Observe" conflates
15
+ symptom-gathering with reproduction. Open question #1 was verified — the
16
+ gap is real, the appendix is non-trivial.
17
+
18
+ This appendix carries the 6-phase Pocock discipline. The skill body
19
+ loads it and uses Phase 1 (Reproduce) as a **hard prerequisite** before
20
+ advancing from Observe to Hypothesize.
21
+
22
+ ## The 6-phase loop
23
+
24
+ 1. **Reproduce.** Establish a reliable repro loop. Until you can
25
+ trigger the bug at will, no hypothesis is testable — you'd be
26
+ guessing about a moving target. The loop MUST be:
27
+ - Deterministic (same input → same failure)
28
+ - Cheap (under 10 seconds preferred; certainly under 60)
29
+ - Minimal (no irrelevant setup; just enough to fail)
30
+
31
+ 2. **Minimise.** Once you can repro, strip the repro to the smallest
32
+ case. Remove every component that isn't load-bearing for the
33
+ failure. A 200-line repro is a hypothesis space; a 10-line repro is
34
+ a near-confirmed cause.
35
+
36
+ 3. **Hypothesise.** ONLY after minimise: write 3-5 ranked falsifiable
37
+ hypotheses. Each hypothesis must:
38
+ - Predict an observable consequence
39
+ - Be testable by changing ONE variable
40
+ - Be ordered by prior probability + cost-to-test
41
+
42
+ 4. **Instrument.** Add the minimum logging / breakpoint / probe to test
43
+ the highest-ranked hypothesis. Change ONE variable. Re-run the
44
+ minimal repro. Observe.
45
+
46
+ 5. **Fix.** When a hypothesis confirms, write the fix. Run the minimal
47
+ repro again — it must now PASS (no more failure). Run the full test
48
+ suite — no new regressions.
49
+
50
+ 6. **Regression-test.** Write a test that pins the fix. The test must
51
+ fail on the pre-fix code and pass on the fixed code. This is what
52
+ stops the bug from coming back six months later when someone
53
+ refactors.
54
+
55
+ ## The Phase-1 prerequisite (load-bearing)
56
+
57
+ apt:debug's body enforces this constraint: **you do NOT advance from
58
+ Observe to Hypothesize until Phase 1 produces a reliable repro loop**.
59
+
60
+ If you cannot reproduce reliably:
61
+
62
+ - Spend the budget on getting the repro working before guessing causes
63
+ - Add logging in the production / target environment to gather more
64
+ evidence of the failure trigger
65
+ - Ask the user for more context (when does it happen? on what input?
66
+ intermittent or consistent?)
67
+
68
+ It is better to spend 80% of your debug budget on the repro and 20% on
69
+ the fix than to spend 100% guessing at causes. Hypothesis-driven
70
+ debugging without a reliable repro is just hope, dressed up as method.
71
+
72
+ ## Distinguishing Phase 1 from apt:debug's existing "Observe"
73
+
74
+ apt:debug's existing Section 2 collects symptom evidence (error
75
+ messages, user reports, environment). That's still valuable — it's the
76
+ *input* to Phase 1. But "I read the error and inferred the cause"
77
+ DOES NOT count as a repro. The repro is a callable artifact: a
78
+ command-line invocation, a test, a script — something the agent can
79
+ run on demand to trigger the failure.
80
+
81
+ ## Distinguishing Phase 2 (Minimise) from Phase 3 (Hypothesise)
82
+
83
+ These are different mental modes. Minimise asks "what's the smallest
84
+ thing that still fails?" — a reductive activity. Hypothesise asks
85
+ "WHY does it fail?" — an explanatory activity. Pocock's discipline
86
+ separates them because skipping Phase 2 and going straight from "I can
87
+ repro" to "here's why" tends to anchor on the first plausible cause
88
+ and miss alternatives.
89
+
90
+ ## Practical consequence for the apt:debug body
91
+
92
+ When this appendix is loaded, apt:debug's Section 2 (Observe) renames
93
+ its "Reproduce" sub-step to **Phase 1 (Reproduce — prerequisite)** and
94
+ adds a gate: the skill MUST NOT emit any hypothesis (Section 3) until
95
+ DEBUG.md records a `repro_loop_verified: true` field.
96
+
97
+ The appendix's Phase 2 (Minimise) becomes a new sub-section between
98
+ apt:debug's Section 2 (Observe) and Section 3 (Hypothesize). DEBUG.md
99
+ gains a `minimised_repro` field.
100
+
101
+ apt:debug's Sections 3-5 (Hypothesize / Checkpoint / Test / Conclude)
102
+ align with Phases 3-6 of this appendix; no structural change there.
103
+
104
+ ## Anti-patterns this discipline prevents
105
+
106
+ - **Sprint-to-hypothesis.** Agent reads the error, picks the first
107
+ plausible cause, writes a fix, and ships. The bug comes back two
108
+ days later under different inputs.
109
+ - **Stack-trace cargo cult.** Agent assumes the line at the top of the
110
+ stack trace IS the bug. Often it's an effect, not a cause.
111
+ - **Test the fix, not the bug.** Agent writes a test that proves the
112
+ fix works but doesn't exercise the original buggy condition. The
113
+ regression test is a no-op against the future regression.
114
+ - **Logging without minimising.** Agent adds 50 log lines in a 200-line
115
+ repro, then drowns in noise. Minimise first; THEN instrument the
116
+ minimal repro.
117
+
118
+ Loading this appendix and following its Phase 1 prerequisite cuts most
119
+ of these failure modes by structural constraint.