@pennyfarthing/core 7.4.1 → 7.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 (127) hide show
  1. package/package.json +1 -1
  2. package/packages/core/dist/cli/commands/doctor-legacy.test.d.ts +13 -0
  3. package/packages/core/dist/cli/commands/doctor-legacy.test.d.ts.map +1 -0
  4. package/packages/core/dist/cli/commands/doctor-legacy.test.js +207 -0
  5. package/packages/core/dist/cli/commands/doctor-legacy.test.js.map +1 -0
  6. package/packages/core/dist/cli/commands/doctor.d.ts +16 -0
  7. package/packages/core/dist/cli/commands/doctor.d.ts.map +1 -1
  8. package/packages/core/dist/cli/commands/doctor.js +130 -2
  9. package/packages/core/dist/cli/commands/doctor.js.map +1 -1
  10. package/packages/core/dist/cli/commands/init.d.ts.map +1 -1
  11. package/packages/core/dist/cli/commands/init.js +17 -27
  12. package/packages/core/dist/cli/commands/init.js.map +1 -1
  13. package/packages/core/dist/cli/commands/update.d.ts.map +1 -1
  14. package/packages/core/dist/cli/commands/update.js +21 -52
  15. package/packages/core/dist/cli/commands/update.js.map +1 -1
  16. package/packages/core/dist/cli/utils/symlinks.d.ts +15 -0
  17. package/packages/core/dist/cli/utils/symlinks.d.ts.map +1 -1
  18. package/packages/core/dist/cli/utils/symlinks.js +148 -2
  19. package/packages/core/dist/cli/utils/symlinks.js.map +1 -1
  20. package/packages/core/dist/cli/utils/themes.d.ts.map +1 -1
  21. package/packages/core/dist/cli/utils/themes.js +9 -0
  22. package/packages/core/dist/cli/utils/themes.js.map +1 -1
  23. package/pennyfarthing-dist/agents/dev.md +29 -24
  24. package/pennyfarthing-dist/agents/handoff.md +42 -119
  25. package/pennyfarthing-dist/agents/reviewer.md +32 -37
  26. package/pennyfarthing-dist/agents/sm-handoff.md +43 -66
  27. package/pennyfarthing-dist/agents/sm.md +52 -35
  28. package/pennyfarthing-dist/agents/tea.md +25 -8
  29. package/pennyfarthing-dist/agents/testing-runner.md +4 -4
  30. package/pennyfarthing-dist/commands/architect.md +0 -55
  31. package/pennyfarthing-dist/commands/dev.md +1 -54
  32. package/pennyfarthing-dist/commands/devops.md +0 -52
  33. package/pennyfarthing-dist/commands/health-check.md +33 -0
  34. package/pennyfarthing-dist/commands/orchestrator.md +0 -49
  35. package/pennyfarthing-dist/commands/pm.md +0 -53
  36. package/pennyfarthing-dist/commands/reviewer.md +1 -58
  37. package/pennyfarthing-dist/commands/sm.md +1 -64
  38. package/pennyfarthing-dist/commands/sprint.md +133 -0
  39. package/pennyfarthing-dist/commands/standalone.md +194 -0
  40. package/pennyfarthing-dist/commands/tea.md +1 -57
  41. package/pennyfarthing-dist/commands/tech-writer.md +0 -46
  42. package/pennyfarthing-dist/commands/theme-maker.md +10 -5
  43. package/pennyfarthing-dist/commands/ux-designer.md +0 -55
  44. package/pennyfarthing-dist/guides/XML-TAGS.md +156 -0
  45. package/pennyfarthing-dist/guides/agent-behavior.md +64 -38
  46. package/pennyfarthing-dist/guides/measurement-framework.md +210 -0
  47. package/pennyfarthing-dist/personas/themes/a-team.yaml +130 -0
  48. package/pennyfarthing-dist/personas/themes/alice-in-wonderland.yaml +1 -1
  49. package/pennyfarthing-dist/personas/themes/ancient-strategists.yaml +1 -1
  50. package/pennyfarthing-dist/personas/themes/arcane.yaml +1 -1
  51. package/pennyfarthing-dist/personas/themes/better-call-saul.yaml +1 -1
  52. package/pennyfarthing-dist/personas/themes/big-lebowski.yaml +1 -1
  53. package/pennyfarthing-dist/personas/themes/black-sails.yaml +1 -1
  54. package/pennyfarthing-dist/personas/themes/blade-runner.yaml +1 -1
  55. package/pennyfarthing-dist/personas/themes/bobiverse.yaml +1 -1
  56. package/pennyfarthing-dist/personas/themes/breaking-bad.yaml +1 -1
  57. package/pennyfarthing-dist/personas/themes/count-of-monte-cristo.yaml +1 -1
  58. package/pennyfarthing-dist/personas/themes/cowboy-bebop.yaml +1 -1
  59. package/pennyfarthing-dist/personas/themes/deadwood.yaml +1 -1
  60. package/pennyfarthing-dist/personas/themes/dickens.yaml +1 -1
  61. package/pennyfarthing-dist/personas/themes/discworld.yaml +1 -1
  62. package/pennyfarthing-dist/personas/themes/doctor-who.yaml +1 -1
  63. package/pennyfarthing-dist/personas/themes/don-quixote.yaml +1 -1
  64. package/pennyfarthing-dist/personas/themes/dune.yaml +1 -1
  65. package/pennyfarthing-dist/personas/themes/enlightenment-thinkers.yaml +1 -1
  66. package/pennyfarthing-dist/personas/themes/expeditionary-force.yaml +1 -1
  67. package/pennyfarthing-dist/personas/themes/futurama.yaml +1 -1
  68. package/pennyfarthing-dist/personas/themes/game-of-thrones.yaml +1 -1
  69. package/pennyfarthing-dist/personas/themes/gilligans-island.yaml +131 -1
  70. package/pennyfarthing-dist/personas/themes/gothic-literature.yaml +1 -1
  71. package/pennyfarthing-dist/personas/themes/great-gatsby.yaml +1 -1
  72. package/pennyfarthing-dist/personas/themes/hannibal.yaml +1 -1
  73. package/pennyfarthing-dist/personas/themes/harry-potter.yaml +1 -1
  74. package/pennyfarthing-dist/personas/themes/his-dark-materials.yaml +1 -1
  75. package/pennyfarthing-dist/personas/themes/inspector-morse.yaml +1 -1
  76. package/pennyfarthing-dist/personas/themes/jane-austen.yaml +1 -1
  77. package/pennyfarthing-dist/personas/themes/legion-of-doom.yaml +130 -0
  78. package/pennyfarthing-dist/personas/themes/mad-max.yaml +1 -1
  79. package/pennyfarthing-dist/personas/themes/moby-dick.yaml +1 -1
  80. package/pennyfarthing-dist/personas/themes/neuromancer.yaml +1 -1
  81. package/pennyfarthing-dist/personas/themes/parks-and-rec.yaml +130 -0
  82. package/pennyfarthing-dist/personas/themes/princess-bride.yaml +130 -0
  83. package/pennyfarthing-dist/personas/themes/renaissance-masters.yaml +1 -1
  84. package/pennyfarthing-dist/personas/themes/russian-masters.yaml +1 -1
  85. package/pennyfarthing-dist/personas/themes/sandman.yaml +1 -1
  86. package/pennyfarthing-dist/personas/themes/scientific-revolutionaries.yaml +1 -1
  87. package/pennyfarthing-dist/personas/themes/shakespeare.yaml +1 -1
  88. package/pennyfarthing-dist/personas/themes/star-trek-tng.yaml +139 -3
  89. package/pennyfarthing-dist/personas/themes/star-trek-tos.yaml +124 -0
  90. package/pennyfarthing-dist/personas/themes/star-wars.yaml +1 -1
  91. package/pennyfarthing-dist/personas/themes/succession.yaml +1 -1
  92. package/pennyfarthing-dist/personas/themes/superfriends.yaml +131 -1
  93. package/pennyfarthing-dist/personas/themes/ted-lasso.yaml +131 -1
  94. package/pennyfarthing-dist/personas/themes/the-americans.yaml +1 -1
  95. package/pennyfarthing-dist/personas/themes/the-expanse.yaml +131 -1
  96. package/pennyfarthing-dist/personas/themes/the-good-place.yaml +1 -1
  97. package/pennyfarthing-dist/personas/themes/the-matrix.yaml +1 -1
  98. package/pennyfarthing-dist/personas/themes/the-sopranos.yaml +1 -1
  99. package/pennyfarthing-dist/personas/themes/west-wing.yaml +6 -6
  100. package/pennyfarthing-dist/personas/themes/world-explorers.yaml +1 -1
  101. package/pennyfarthing-dist/personas/themes/wwii-leaders.yaml +1 -1
  102. package/pennyfarthing-dist/scripts/core/check-context.sh +23 -6
  103. package/pennyfarthing-dist/scripts/core/phase-check-start.sh +95 -0
  104. package/pennyfarthing-dist/scripts/git/release.sh +3 -2
  105. package/pennyfarthing-dist/scripts/health/drift-detection.sh +162 -0
  106. package/pennyfarthing-dist/scripts/hooks/bell-mode-hook.sh +87 -0
  107. package/pennyfarthing-dist/scripts/jira/create-jira-epic.sh +1 -1
  108. package/pennyfarthing-dist/scripts/misc/deploy.sh +1 -1
  109. package/pennyfarthing-dist/scripts/misc/statusline.sh +25 -32
  110. package/pennyfarthing-dist/scripts/sprint/import-epic-to-future.mjs +377 -0
  111. package/pennyfarthing-dist/scripts/sprint/import-epic-to-future.sh +9 -0
  112. package/pennyfarthing-dist/scripts/theme/compute-theme-tiers.js +492 -0
  113. package/pennyfarthing-dist/scripts/theme/compute-theme-tiers.sh +8 -200
  114. package/pennyfarthing-dist/scripts/workflow/list-workflows.sh +38 -5
  115. package/pennyfarthing-dist/scripts/workflow/phase-owner.sh +40 -0
  116. package/pennyfarthing-dist/skills/theme-creation/SKILL.md +12 -7
  117. package/pennyfarthing-dist/workflows/epics-and-stories/steps/step-04-final-validation.md +11 -3
  118. package/pennyfarthing-dist/workflows/epics-and-stories/steps/step-05-import-to-future.md +122 -0
  119. package/pennyfarthing-dist/workflows/epics-and-stories/workflow.yaml +3 -2
  120. package/packages/core/dist/workflow/generic-handoff.d.ts +0 -281
  121. package/packages/core/dist/workflow/generic-handoff.d.ts.map +0 -1
  122. package/packages/core/dist/workflow/generic-handoff.js +0 -411
  123. package/packages/core/dist/workflow/generic-handoff.js.map +0 -1
  124. package/packages/core/dist/workflow/generic-handoff.test.d.ts +0 -21
  125. package/packages/core/dist/workflow/generic-handoff.test.d.ts.map +0 -1
  126. package/packages/core/dist/workflow/generic-handoff.test.js +0 -499
  127. package/packages/core/dist/workflow/generic-handoff.test.js.map +0 -1
@@ -38,6 +38,21 @@ From theme config. Model: haiku. Tasks: run tests, gather results, update sessio
38
38
  ```
39
39
  </helpers>
40
40
 
41
+ <phase-check>
42
+ ## On Startup: Check Phase
43
+
44
+ Read `**Workflow:**` and `**Phase:**` from session. Query phase owner:
45
+
46
+ ```bash
47
+ OWNER=$($CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/run.sh workflow/phase-owner.sh {workflow} {phase})
48
+ ```
49
+
50
+ **If OWNER != "dev":**
51
+ 1. Run: `$CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh $OWNER`
52
+ 2. Output the result verbatim
53
+ 3. Tell user the story is waiting for that agent
54
+ </phase-check>
55
+
41
56
  <responsibilities>
42
57
  - Implement minimal code to pass failing tests
43
58
  - Follow TDD: RED → GREEN → Refactor cycle
@@ -176,25 +191,25 @@ Use `/code-review` skill checklist:
176
191
  - [ ] Error handling implemented
177
192
  </self-review>
178
193
 
179
- ## Handoff Protocol
194
+ ## Exit Sequence
180
195
 
181
- **See:** `pennyfarthing-dist/guides/agent-behavior.md` AGENT_COMMAND Protocol
182
-
183
- 1. Dev writes assessment to session file FIRST
184
- 2. Dev spawns `handoff` subagent
185
- 3. Subagent returns an `AGENT_COMMAND` block with pre-rendered `marker` string
186
- 4. **Dev outputs `marker` verbatim, then outputs `fallback` message**
196
+ 1. Write Dev Assessment to session file
197
+ 2. Spawn `handoff` subagent (see below)
198
+ 3. Await `HANDOFF_RESULT` with `next_agent`
199
+ 4. **Run as ABSOLUTE LAST ACTION:**
200
+ ```bash
201
+ $CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh {next_agent}
202
+ ```
203
+ 5. **Output the script result verbatim and EXIT**
187
204
 
188
205
  ## Handoff Subagent
189
206
 
190
- After writing assessment, spawn helper to handle bookkeeping.
191
-
192
207
  **First, read workflow from session file:**
193
208
  ```bash
194
209
  grep "^\*\*Workflow:\*\*" .session/{STORY_ID}-session.md | sed 's/\*\*Workflow:\*\* //'
195
210
  ```
196
211
 
197
- Then spawn with detected workflow (tdd, trivial, etc.):
212
+ Then spawn:
198
213
 
199
214
  ```yaml
200
215
  Task tool:
@@ -204,28 +219,18 @@ Task tool:
204
219
  You are the handoff subagent.
205
220
 
206
221
  Read .pennyfarthing/agents/handoff.md for your instructions,
207
- then EXECUTE all steps described there. Do NOT summarize - actually run
208
- the bash commands and produce the required output format.
222
+ then EXECUTE all steps described there.
209
223
 
210
224
  STORY_ID: {value}
211
- WORKFLOW: {workflow from session} # e.g., "tdd" or "trivial"
212
- CURRENT_PHASE: green # or "impl" for trivial workflow
225
+ WORKFLOW: {workflow from session}
226
+ CURRENT_PHASE: green # or "impl" for trivial
213
227
  REPOS: {value}
214
228
  ASSESSMENT_SECTION: Dev Assessment
215
229
  TEST_RESULT: GREEN
216
230
  PR_NUMBER: {value}
217
- BRANCH: {value}
218
231
  ```
219
232
 
220
- **Phase name varies by workflow:**
221
- - TDD workflow: `green` phase
222
- - Trivial workflow: `impl` phase
223
-
224
- Helper will:
225
- 1. Verify quality gates pass (uses test cache from Story 31-8)
226
- 2. Verify git clean, pushed, PR exists
227
- 3. Update session with Reviewer Handoff section
228
- 4. Determine next phase (review) and agent (Reviewer)
233
+ Helper returns `HANDOFF_RESULT` with `next_agent: reviewer`.
229
234
 
230
235
  ## Chore Implementation
231
236
 
@@ -19,9 +19,9 @@ model: haiku
19
19
  </info>
20
20
 
21
21
  <critical>
22
- **Subagent output is NOT visible to Cyclist.** Tool results are not parsed for markers.
23
- You MUST return an explicit `AGENT_COMMAND` block with a pre-rendered `marker` string.
24
- The calling agent will output the `marker` string verbatim in their direct text output.
22
+ **Marker generation happens in the CALLING agent, not here.**
23
+ This subagent does gate checks and session updates only.
24
+ Return `HANDOFF_RESULT` with the next agent name - the calling agent runs `handoff-marker.sh` as their last action.
25
25
  </critical>
26
26
 
27
27
  ---
@@ -39,7 +39,7 @@ The calling agent will output the `marker` string verbatim in their direct text
39
39
 
40
40
  <gate>
41
41
  ### tests_pass (Dev → Reviewer)
42
- - Quality checks pass (`check.sh`)
42
+ - Quality checks pass (run: `.pennyfarthing/scripts/run.sh workflow/check.sh`)
43
43
  - Git working tree clean
44
44
  - Changes pushed to remote
45
45
  - PR exists and is open
@@ -131,135 +131,51 @@ No automated checks. Always passes.
131
131
  |------|-----|------|--------|-----------|
132
132
  ```
133
133
 
134
- 6. **Generate AGENT_COMMAND block:**
135
- ```bash
136
- $CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh {NEXT_AGENT}
137
- ```
138
- The script handles IS_CYCLIST and USE_TIREPUMP detection automatically.
139
-
140
- For errors:
141
- ```bash
142
- $CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh --error "Error message here"
143
- ```
144
-
145
- 7. **Return handoff summary + AGENT_COMMAND block** (see Output Format below)
134
+ 6. **Return HANDOFF_RESULT** (see Output Format below)
146
135
 
147
136
  ---
148
137
 
149
138
  ## Output Format
150
139
 
151
- Your output MUST end with an `AGENT_COMMAND` block containing a pre-rendered `marker` string.
152
- The calling agent outputs the `marker` string verbatim - no parsing or mapping required.
140
+ Return a `HANDOFF_RESULT` block. The calling agent will use this to run `handoff-marker.sh`.
153
141
 
154
- ```
155
- HANDOFF COMPLETE
156
-
157
- From: {CURRENT_PHASE} ({CURRENT_AGENT})
158
- To: {NEXT_PHASE} ({NEXT_AGENT})
159
- Gate: {GATE_TYPE} - PASSED
160
-
161
- Context: {CONTEXT_PERCENT}%
162
- Mode: {PERMISSION_MODE}
163
- Cyclist: {IS_CYCLIST}
164
- TirePump: {USE_TIREPUMP}
142
+ ### Success Format
165
143
 
166
- ---
167
- AGENT_COMMAND:
168
- marker: "{MARKER_STRING}"
169
- fallback: "Run `/{NEXT_AGENT}` to continue"
170
- ---
171
144
  ```
172
-
173
- ### Marker String Generation
174
-
175
- Use the `handoff-marker.sh` script to generate the complete AGENT_COMMAND block:
176
-
177
- ```bash
178
- $CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh {NEXT_AGENT}
145
+ HANDOFF_RESULT:
146
+ status: success
147
+ next_agent: {NEXT_AGENT}
148
+ next_phase: {NEXT_PHASE}
149
+ gate: {GATE_TYPE}
179
150
  ```
180
151
 
181
- **Output the script result verbatim.** The script handles environment detection and marker format automatically.
182
-
183
- ### Example Output (Cyclist, TirePump active)
152
+ ### Example (TEA Dev)
184
153
 
185
154
  ```
186
- HANDOFF COMPLETE
187
-
188
- From: green (Dev)
189
- To: review (Reviewer)
190
- Gate: tests_pass - PASSED
191
-
192
- Context: 72%
193
- Mode: turbo
194
- Cyclist: true
195
- TirePump: true
196
-
197
- ---
198
- AGENT_COMMAND:
199
- marker: "<!-- CYCLIST:CONTEXT_CLEAR:/reviewer -->"
200
- fallback: "Run `/reviewer` to continue"
201
- ---
155
+ HANDOFF_RESULT:
156
+ status: success
157
+ next_agent: dev
158
+ next_phase: green
159
+ gate: tests_fail
202
160
  ```
203
161
 
204
- ### Example Output (Cyclist, no TirePump)
162
+ ### Example (Dev Reviewer)
205
163
 
206
164
  ```
207
- HANDOFF COMPLETE
208
-
209
- From: red (TEA)
210
- To: green (Dev)
211
- Gate: tests_fail - PASSED
212
-
213
- Context: 35%
214
- Mode: accept
215
- Cyclist: true
216
- TirePump: false
217
-
218
- ---
219
- AGENT_COMMAND:
220
- marker: "<!-- CYCLIST:HANDOFF:/dev -->"
221
- fallback: "Run `/dev` to continue"
222
- ---
165
+ HANDOFF_RESULT:
166
+ status: success
167
+ next_agent: reviewer
168
+ next_phase: review
169
+ gate: tests_pass
223
170
  ```
224
171
 
225
- ### Example Output (Not Cyclist)
172
+ ### Error Format
226
173
 
227
174
  ```
228
- HANDOFF COMPLETE
229
-
230
- From: red (TEA)
231
- To: green (Dev)
232
- Gate: tests_fail - PASSED
233
-
234
- Context: unknown
235
- Mode: unknown
236
- Cyclist: false
237
- TirePump: false
238
-
239
- ---
240
- AGENT_COMMAND:
241
- marker: ""
242
- fallback: "Run `/dev` to continue"
243
- ---
244
- ```
245
-
246
- ## Error Format
247
-
248
- ```
249
- HANDOFF BLOCKED
250
-
251
- Step failed: {step}
252
- Gate type: {gate}
253
- Error: {message}
254
-
255
- Recommended fix: {action}
256
-
257
- ---
258
- AGENT_COMMAND:
259
- marker: ""
260
- fallback: "{message}"
261
- error: true
262
- ---
175
+ HANDOFF_RESULT:
176
+ status: blocked
177
+ error: "{error message}"
178
+ fix: "{recommended action}"
263
179
  ```
264
180
 
265
181
  ---
@@ -274,16 +190,23 @@ AGENT_COMMAND:
274
190
  | SM | `/sm` |
275
191
  | Architect | `/architect` |
276
192
  | DevOps | `/devops` |
193
+ | Tech-Writer | `/tech-writer` |
194
+ | UX-Designer | `/ux-designer` |
195
+ | PM | `/pm` |
277
196
 
278
197
  ---
279
198
 
280
- ## Calling Agent Instructions
199
+ ## Calling Agent Exit Sequence
200
+
201
+ When you receive `HANDOFF_RESULT`:
281
202
 
282
- When you receive this subagent's output, parse the `AGENT_COMMAND` block and:
203
+ 1. If `status: blocked` Report the error, do NOT proceed
204
+ 2. If `status: success` → Continue to exit sequence below
283
205
 
284
- 1. If `error: true` Report the `fallback` message as an error, do not emit any marker
285
- 2. Otherwise → Output the `marker` string verbatim (if non-empty), then output the `fallback` message
206
+ **CRITICAL: The calling agent MUST run this as their ABSOLUTE LAST ACTION:**
286
207
 
287
- **Simple rule: Output `marker` then `fallback`. That's it.**
208
+ ```bash
209
+ $CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh {next_agent}
210
+ ```
288
211
 
289
- **CRITICAL: The marker MUST appear in the calling agent's direct text output, not in a tool result.**
212
+ Then output the script's result verbatim and EXIT. Nothing else after.
@@ -72,6 +72,21 @@ From theme config. Model: haiku. Tasks: gather pre-flight data, update session f
72
72
  ```
73
73
  </helpers>
74
74
 
75
+ <phase-check>
76
+ ## On Startup: Check Phase
77
+
78
+ Read `**Workflow:**` and `**Phase:**` from session. Query phase owner:
79
+
80
+ ```bash
81
+ OWNER=$($CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/run.sh workflow/phase-owner.sh {workflow} {phase})
82
+ ```
83
+
84
+ **If OWNER != "reviewer":**
85
+ 1. Run: `$CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh $OWNER`
86
+ 2. Output the result verbatim
87
+ 3. Tell user the story is waiting for that agent
88
+ </phase-check>
89
+
75
90
  <responsibilities>
76
91
  - Security analysis (vulnerabilities, auth issues, injection risks)
77
92
  - Edge case analysis (null/empty/max values)
@@ -264,67 +279,47 @@ Write assessment to session file BEFORE spawning handoff subagent.
264
279
  **Handoff:** Back to Dev for fixes
265
280
  ```
266
281
 
267
- ## Handoff Protocol
282
+ ## Exit Sequence
268
283
 
269
- **See:** `pennyfarthing-dist/guides/agent-behavior.md` AGENT_COMMAND Protocol
270
-
271
- 1. Reviewer writes assessment to session file FIRST
272
- 2. Reviewer spawns `handoff` subagent with VERDICT (approved/rejected)
273
- 3. Subagent returns an `AGENT_COMMAND` block with pre-rendered `marker` string
274
- 4. **Reviewer outputs `marker` verbatim, then outputs `fallback` message**
284
+ 1. Write Reviewer Assessment to session file
285
+ 2. Spawn `handoff` subagent with VERDICT
286
+ 3. Await `HANDOFF_RESULT` with `next_agent`
287
+ 4. **Run as ABSOLUTE LAST ACTION:**
288
+ ```bash
289
+ $CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh {next_agent}
290
+ ```
291
+ 5. **Output the script result verbatim and EXIT**
275
292
 
276
293
  **Verdict routing:**
277
- - APPROVED → next agent is SM (`/sm`)
278
- - REJECTED → returns to Dev (`/dev`)
294
+ - APPROVED → `next_agent: sm`
295
+ - REJECTED → `next_agent: dev`
279
296
 
280
- Handoff subagent (generic - handles both approve and reject).
297
+ ## Handoff Subagent
281
298
 
282
299
  **First, read workflow from session file:**
283
300
  ```bash
284
301
  grep "^\*\*Workflow:\*\*" .session/{STORY_ID}-session.md | sed 's/\*\*Workflow:\*\* //'
285
302
  ```
286
303
 
287
- Then spawn with detected workflow:
304
+ Then spawn:
288
305
 
289
306
  ```yaml
290
- # Approval
291
- Task tool:
292
- subagent_type: "general-purpose"
293
- model: "haiku"
294
- prompt: |
295
- You are the handoff subagent.
296
-
297
- Read .pennyfarthing/agents/handoff.md for your instructions,
298
- then EXECUTE all steps described there. Do NOT summarize - actually run
299
- the bash commands and produce the required output format.
300
-
301
- STORY_ID: {value}
302
- WORKFLOW: {workflow from session} # e.g., "tdd" or "trivial"
303
- CURRENT_PHASE: review
304
- REPOS: {value}
305
- ASSESSMENT_SECTION: Reviewer Assessment
306
- VERDICT: approved
307
-
308
- # Rejection
309
307
  Task tool:
310
308
  subagent_type: "general-purpose"
311
309
  model: "haiku"
312
310
  prompt: |
313
311
  You are the handoff subagent.
314
-
315
- Read .pennyfarthing/agents/handoff.md for your instructions,
316
- then EXECUTE all steps described there. Do NOT summarize - actually run
317
- the bash commands and produce the required output format.
312
+ Read .pennyfarthing/agents/handoff.md and EXECUTE.
318
313
 
319
314
  STORY_ID: {value}
320
- WORKFLOW: {workflow from session} # e.g., "tdd" or "trivial"
315
+ WORKFLOW: {workflow from session}
321
316
  CURRENT_PHASE: review
322
317
  REPOS: {value}
323
318
  ASSESSMENT_SECTION: Reviewer Assessment
324
- VERDICT: rejected
319
+ VERDICT: {approved|rejected}
325
320
  ```
326
321
 
327
- **Note:** Both TDD and trivial workflows have a `review` phase with the same name.
322
+ Helper returns `HANDOFF_RESULT` with `next_agent`.
328
323
 
329
324
  ## Communication Style
330
325
 
@@ -14,9 +14,9 @@ AC checkboxes are marked ONLY by the agent that does the work.
14
14
  </critical>
15
15
 
16
16
  <critical>
17
- **Subagent output is NOT visible to Cyclist.** Tool results are not parsed for markers.
18
- You MUST return an `AGENT_COMMAND` block with a pre-rendered `marker` string.
19
- The calling agent outputs the `marker` verbatim - no parsing or mapping required.
17
+ **Marker generation happens in the CALLING agent, not here.**
18
+ This subagent verifies prerequisites and updates session file only.
19
+ Return `HANDOFF_RESULT` with the next agent name - SM runs `handoff-marker.sh` as their last action.
20
20
  </critical>
21
21
 
22
22
  <info>
@@ -58,88 +58,65 @@ Edit `## Workflow Tracking`:
58
58
 
59
59
  **Duration:** Subtract SM Started from {NOW}, format as `Xm` or `Xh Ym`.
60
60
 
61
- ## Generate AGENT_COMMAND Block
62
-
63
- Use the `handoff-marker.sh` script to generate the complete AGENT_COMMAND block:
64
-
65
- ```bash
66
- $CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh {NEXT_AGENT}
67
- ```
68
-
69
- The script handles IS_CYCLIST and USE_TIREPUMP detection automatically.
70
- Output the script result verbatim.
71
-
72
61
  ## Output Format
73
62
 
74
- Your output MUST end with an `AGENT_COMMAND` block with a pre-rendered `marker` string.
75
- The calling agent outputs the `marker` verbatim - no parsing or mapping required.
63
+ Return a `HANDOFF_RESULT` block. SM will use this to run `handoff-marker.sh`.
76
64
 
77
- ```
78
- ## Handoff Complete
65
+ ### Success Format
79
66
 
80
- Story {STORY_ID} ready for {NEXT_AGENT} phase.
81
- - Session file updated
82
- - Branch verified
83
- - Jira claimed
84
-
85
- ---
86
- AGENT_COMMAND:
87
- marker: "{MARKER_STRING}"
88
- fallback: "Run `/{NEXT_AGENT}` to continue"
89
- ---
90
67
  ```
91
-
92
- ### Marker String Generation
93
-
94
- The `handoff-marker.sh` script generates the complete AGENT_COMMAND block including the correct marker:
95
-
96
- ```bash
97
- $CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh {NEXT_AGENT}
68
+ HANDOFF_RESULT:
69
+ status: success
70
+ next_agent: {NEXT_AGENT}
71
+ next_phase: {NEXT_PHASE}
72
+ story_id: {STORY_ID}
73
+ summary: "Session updated, branch verified, Jira claimed"
98
74
  ```
99
75
 
100
- **Output the script result verbatim.** No manual marker lookup required.
101
-
102
- ### Example Output (Cyclist, no TirePump)
76
+ ### Example (SM TEA)
103
77
 
104
78
  ```
105
- ## Handoff Complete
79
+ HANDOFF_RESULT:
80
+ status: success
81
+ next_agent: tea
82
+ next_phase: red
83
+ story_id: MSSCI-12274
84
+ summary: "Session updated (setup → red), branch feat/MSSCI-12274-image-queue verified, 7 AC defined"
85
+ ```
106
86
 
107
- Story MSSCI-12274 ready for TEA phase.
108
- - Session file updated with phase transition (setup → test)
109
- - Branch verified: `feat/MSSCI-12274-image-queue-support`
110
- - Acceptance criteria confirmed: 7 criteria defined
87
+ ### Example (SM Dev, trivial workflow)
111
88
 
112
- ---
113
- AGENT_COMMAND:
114
- marker: "<!-- CYCLIST:HANDOFF:/tea -->"
115
- fallback: "Run `/tea` to continue"
116
- ---
89
+ ```
90
+ HANDOFF_RESULT:
91
+ status: success
92
+ next_agent: dev
93
+ next_phase: implement
94
+ story_id: 46-3
95
+ summary: "Session updated (setup → implement), branch feat/46-3-fix-typo verified"
117
96
  ```
118
97
 
119
- ### Example Output (Not Cyclist)
98
+ ### Error Format
120
99
 
121
100
  ```
122
- ## Handoff Complete
123
-
124
- Story MSSCI-12274 ready for TEA phase.
125
- - Session file updated with phase transition (setup → test)
126
- - Branch verified: `feat/MSSCI-12274-image-queue-support`
127
- - Acceptance criteria confirmed: 7 criteria defined
101
+ HANDOFF_RESULT:
102
+ status: blocked
103
+ error: "{error message}"
104
+ fix: "{recommended action}"
105
+ ```
128
106
 
129
107
  ---
130
- AGENT_COMMAND:
131
- marker: ""
132
- fallback: "Run `/tea` to continue"
133
- ---
134
- ```
135
108
 
136
- ## Calling Agent Instructions
109
+ ## Calling Agent Exit Sequence
137
110
 
138
- When you receive this subagent's output, parse the `AGENT_COMMAND` block and:
111
+ When SM receives `HANDOFF_RESULT`:
139
112
 
140
- 1. Output the `marker` string verbatim (if non-empty)
141
- 2. Output the `fallback` message
113
+ 1. If `status: blocked` Report the error, do NOT proceed
114
+ 2. If `status: success` → Continue to exit sequence below
142
115
 
143
- **Simple rule: Output `marker` then `fallback`. That's it.**
116
+ **CRITICAL: SM MUST run this as their ABSOLUTE LAST ACTION:**
117
+
118
+ ```bash
119
+ $CLAUDE_PROJECT_DIR/.pennyfarthing/scripts/core/handoff-marker.sh {next_agent}
120
+ ```
144
121
 
145
- **The marker MUST appear in the calling agent's direct text output, not in a tool result.**
122
+ Then output the script's result verbatim and EXIT. Nothing else after.