@pennyfarthing/core 7.6.1 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +109 -201
  2. package/package.json +1 -1
  3. package/packages/core/dist/cli/commands/doctor.d.ts.map +1 -1
  4. package/packages/core/dist/cli/commands/doctor.js +91 -0
  5. package/packages/core/dist/cli/commands/doctor.js.map +1 -1
  6. package/packages/core/dist/cli/commands/init.js +31 -0
  7. package/packages/core/dist/cli/commands/init.js.map +1 -1
  8. package/packages/core/dist/cli/commands/update.js +31 -0
  9. package/packages/core/dist/cli/commands/update.js.map +1 -1
  10. package/pennyfarthing-dist/agents/architect.md +48 -53
  11. package/pennyfarthing-dist/agents/dev.md +74 -164
  12. package/pennyfarthing-dist/agents/devops.md +44 -39
  13. package/pennyfarthing-dist/agents/handoff.md +46 -23
  14. package/pennyfarthing-dist/agents/orchestrator.md +84 -255
  15. package/pennyfarthing-dist/agents/pm.md +40 -50
  16. package/pennyfarthing-dist/agents/reviewer-preflight.md +58 -26
  17. package/pennyfarthing-dist/agents/reviewer.md +107 -298
  18. package/pennyfarthing-dist/agents/sm-file-summary.md +51 -30
  19. package/pennyfarthing-dist/agents/sm-finish.md +59 -38
  20. package/pennyfarthing-dist/agents/sm-handoff.md +40 -33
  21. package/pennyfarthing-dist/agents/sm-setup.md +89 -47
  22. package/pennyfarthing-dist/agents/sm.md +171 -558
  23. package/pennyfarthing-dist/agents/tea.md +77 -146
  24. package/pennyfarthing-dist/agents/tech-writer.md +43 -24
  25. package/pennyfarthing-dist/agents/testing-runner.md +73 -30
  26. package/pennyfarthing-dist/agents/ux-designer.md +39 -25
  27. package/pennyfarthing-dist/agents/workflow-status-check.md +34 -16
  28. package/pennyfarthing-dist/commands/benchmark.md +19 -1
  29. package/pennyfarthing-dist/commands/continue-session.md +1 -1
  30. package/pennyfarthing-dist/commands/solo.md +5 -0
  31. package/pennyfarthing-dist/commands/theme-maker.md +5 -5
  32. package/pennyfarthing-dist/commands/work.md +1 -1
  33. package/pennyfarthing-dist/guides/XML-TAGS.md +179 -0
  34. package/pennyfarthing-dist/guides/agent-behavior.md +22 -9
  35. package/pennyfarthing-dist/guides/agent-tag-taxonomy.md +432 -0
  36. package/pennyfarthing-dist/guides/patterns/approval-gates-pattern.md +27 -7
  37. package/pennyfarthing-dist/guides/scale-levels.md +114 -0
  38. package/pennyfarthing-dist/personas/themes/gilligans-island.yaml +2 -2
  39. package/pennyfarthing-dist/personas/themes/star-trek-tos.yaml +1 -1
  40. package/pennyfarthing-dist/scripts/core/agent-session.sh +13 -7
  41. package/pennyfarthing-dist/scripts/core/check-context.sh +6 -1
  42. package/pennyfarthing-dist/scripts/core/prime.sh +57 -32
  43. package/pennyfarthing-dist/scripts/git/create-feature-branches.sh +45 -4
  44. package/pennyfarthing-dist/scripts/git/git-status-all.sh +32 -7
  45. package/pennyfarthing-dist/scripts/hooks/bell-mode-hook.sh +30 -11
  46. package/pennyfarthing-dist/scripts/hooks/pre-commit.sh +80 -23
  47. package/pennyfarthing-dist/scripts/hooks/question-reflector-check.mjs +66 -53
  48. package/pennyfarthing-dist/scripts/hooks/question-reflector-check.sh +4 -4
  49. package/pennyfarthing-dist/scripts/hooks/question_reflector_check.py +402 -0
  50. package/pennyfarthing-dist/scripts/hooks/session-stop.sh +7 -0
  51. package/pennyfarthing-dist/scripts/hooks/welcome-hook.sh +94 -0
  52. package/pennyfarthing-dist/scripts/jira/jira-claim-story.sh +10 -152
  53. package/pennyfarthing-dist/scripts/jira/jira-sync-story.sh +14 -4
  54. package/pennyfarthing-dist/scripts/jira/jira-sync.sh +12 -4
  55. package/pennyfarthing-dist/scripts/jira/sync-epic-jira.sh +11 -99
  56. package/pennyfarthing-dist/scripts/lib/common.sh +55 -0
  57. package/pennyfarthing-dist/scripts/maintenance/sidecar-health.sh +97 -0
  58. package/pennyfarthing-dist/scripts/misc/statusline.sh +27 -22
  59. package/pennyfarthing-dist/scripts/story/create-story.sh +14 -154
  60. package/pennyfarthing-dist/scripts/story/size-story.sh +12 -192
  61. package/pennyfarthing-dist/scripts/story/story-template.sh +12 -156
  62. package/pennyfarthing-dist/scripts/test/ground-truth-judge.py +24 -93
  63. package/pennyfarthing-dist/scripts/test/swebench-judge.py +33 -59
  64. package/pennyfarthing-dist/scripts/validation/validate-agent-schema.sh +575 -0
  65. package/pennyfarthing-dist/scripts/workflow/check.py +502 -0
  66. package/pennyfarthing-dist/skills/skill-registry.yaml +52 -16
  67. package/pennyfarthing-dist/skills/sprint/skill.md +1 -1
  68. package/pennyfarthing-dist/templates/settings.local.json.template +11 -0
@@ -0,0 +1,432 @@
1
+ # Agent Tag Taxonomy
2
+
3
+ This document defines the XML tag vocabulary for Pennyfarthing agent files. All content in agent files must be contained within tags (except the `# Header` line).
4
+
5
+ ## Tag Categories
6
+
7
+ | Category | Purpose | Validation |
8
+ |----------|---------|------------|
9
+ | **Required** | Must exist in every primary agent | Error if missing |
10
+ | **Mindset** | Steers agent behavior against failure modes | Error if missing |
11
+ | **Structural** | Organizes agent content | Warning if missing when applicable |
12
+ | **Workflow** | Documents agent-specific workflows | No validation |
13
+ | **Subagent** | Used in subagent files | Error/Warning per tag |
14
+
15
+ ---
16
+
17
+ ## Required Tags (Primary Agents)
18
+
19
+ Every primary agent MUST have these tags:
20
+
21
+ | Tag | Purpose | Position |
22
+ |-----|---------|----------|
23
+ | `<role>` | One-line role description | Line 2-4 |
24
+ | `<helpers>` | Subagent table and model info | After mindset/critical |
25
+ | `<exit>` | Final exit instruction | Last tag in file |
26
+
27
+ ### `<role>`
28
+ ```xml
29
+ <role>
30
+ Feature implementation, making tests pass, code changes
31
+ </role>
32
+ ```
33
+ - **Content:** Single line describing the agent's responsibility
34
+ - **Position:** Immediately after `# Header`
35
+
36
+ ### `<helpers>`
37
+ ```xml
38
+ <helpers>
39
+ **Model:** haiku | **Execution:** foreground (sequential)
40
+
41
+ | Subagent | Purpose |
42
+ |----------|---------|
43
+ | `testing-runner` | Run tests, gather results |
44
+ | `handoff` | Update session for handoff |
45
+ </helpers>
46
+ ```
47
+ - **Content:** Model info, execution mode, subagent table
48
+ - **Paired with:** `<parameters>` (should follow immediately)
49
+
50
+ ### `<exit>`
51
+ ```xml
52
+ <exit>
53
+ Nothing after the marker. EXIT.
54
+ </exit>
55
+ ```
56
+ - **Content:** Final instruction before agent exits
57
+ - **Position:** Must be the last tag in the file
58
+
59
+ ---
60
+
61
+ ## Mindset Tags (Primary Agents)
62
+
63
+ Each primary agent has ONE mindset tag that counters its natural failure mode.
64
+
65
+ | Agent | Tag | Counters |
66
+ |-------|-----|----------|
67
+ | SM | `<coordination-discipline>` | Scope creep into implementation |
68
+ | TEA | `<test-paranoia>` | Happy-path-only testing |
69
+ | Dev | `<minimalist-discipline>` | Over-engineering, gold-plating |
70
+ | Reviewer | `<adversarial-mindset>` | Rubber-stamping, approval bias |
71
+ | Orchestrator | `<systems-thinking>` | Symptom-fixing vs system-fixing |
72
+ | Architect | `<pragmatic-restraint>` | Premature abstraction, not reusing |
73
+ | PM | `<ruthless-prioritization>` | Feature bloat, scope creep |
74
+ | DevOps | `<automation-discipline>` | Manual processes, one-off fixes |
75
+ | Tech Writer | `<clarity-obsession>` | Unclear documentation |
76
+ | UX Designer | `<consistency-guardian>` | Introducing unnecessary patterns |
77
+
78
+ ### Structure
79
+ ```xml
80
+ <{mindset-tag}>
81
+ **You are not here to {default behavior}. You are here to {correct behavior}.**
82
+
83
+ {Context paragraph explaining the failure mode.}
84
+
85
+ **Default stance:** {One word}. {Question to ask self?}
86
+
87
+ - {Counter-example 1}
88
+ - {Counter-example 2}
89
+ - {Counter-example 3}
90
+
91
+ **{Closing maxim.}**
92
+ </{mindset-tag}>
93
+ ```
94
+
95
+ ### Position
96
+ - After `<role>`
97
+ - Before first `<critical>`
98
+
99
+ ---
100
+
101
+ ## Structural Tags
102
+
103
+ ### `<critical>`
104
+ High-priority instruction that MUST be followed.
105
+
106
+ ```xml
107
+ <critical>
108
+ **HANDOFF REQUIRES MARKER OUTPUT.** After `handoff` subagent returns:
109
+ Run `handoff-marker.sh {next_agent}` as ABSOLUTE LAST ACTION, output result, EXIT.
110
+ </critical>
111
+ ```
112
+ - **Validation:** First `<critical>` should be within line 30
113
+ - **Usage:** Multiple allowed per agent
114
+
115
+ ### `<parameters>`
116
+ Documents what parameters to pass to each subagent.
117
+
118
+ ```xml
119
+ <parameters>
120
+ ## Subagent Parameters
121
+
122
+ ### testing-runner
123
+ ```yaml
124
+ REPOS: {repo name or "all"}
125
+ CONTEXT: "Verifying GREEN state for Story {STORY_ID}"
126
+ RUN_ID: "{STORY_ID}-dev-green"
127
+ ```
128
+ </parameters>
129
+ ```
130
+ - **Paired with:** `<helpers>` (should follow it)
131
+ - **Validation:** Warning if `<helpers>` exists without `<parameters>`
132
+
133
+ ### `<arguments>` (Subagents Only)
134
+ Documents what parameters the subagent expects to receive.
135
+
136
+ ```xml
137
+ <arguments>
138
+ | Argument | Required | Description |
139
+ |----------|----------|-------------|
140
+ | `REPOS` | Yes | Repository name(s) |
141
+ | `CONTEXT` | Yes | Why tests are being run |
142
+ </arguments>
143
+ ```
144
+ - **Position:** Near top of subagent file, after frontmatter
145
+ - **Validation:** Warning if missing in subagent
146
+
147
+ ### `<context>`
148
+ Files to load on activation.
149
+
150
+ ```xml
151
+ <context>
152
+ **Load on activation:**
153
+ - `pennyfarthing-dist/sidecars/sm-patterns.md` (if exists)
154
+ - `pennyfarthing-dist/sidecars/sm-gotchas.md` (if exists)
155
+ </context>
156
+ ```
157
+
158
+ ### `<on-activation>`
159
+ Steps to execute when agent activates.
160
+
161
+ ```xml
162
+ <on-activation>
163
+ 1. Context already loaded by /prime
164
+ 2. If handed off to Dev: "Story X-Y has tests ready. Shall I make them GREEN?"
165
+ </on-activation>
166
+ ```
167
+ - **Validation:** Should be within line 100
168
+
169
+ ### `<phase-check>`
170
+ Logic for checking if this agent owns the current phase.
171
+
172
+ ```xml
173
+ <phase-check>
174
+ ## On Startup: Check Phase
175
+
176
+ Read `**Workflow:**` and `**Phase:**` from session. Query:
177
+ ```bash
178
+ OWNER=$(.pennyfarthing/scripts/core/run.sh workflow/phase-owner.sh {workflow} {phase})
179
+ ```
180
+
181
+ **If OWNER != "dev":** Run `handoff-marker.sh $OWNER`, output result, tell user.
182
+ </phase-check>
183
+ ```
184
+
185
+ ### `<skills>`
186
+ Available slash commands for this agent.
187
+
188
+ ```xml
189
+ <skills>
190
+ - `/testing` - Test commands and patterns
191
+ - `/dev-patterns` - Implementation patterns and gotchas
192
+ </skills>
193
+ ```
194
+
195
+ ### `<handoffs>`
196
+ Documents handoff relationships with other agents.
197
+
198
+ ```xml
199
+ <handoffs>
200
+ ### From PM/SM
201
+ **When:** Epic or story needs architectural design
202
+ **Input:** Business requirements, technical constraints
203
+ **Action:** Design solution and provide guidance
204
+
205
+ ### To Dev
206
+ **When:** Design is complete
207
+ **Output:** Architecture decision and implementation plan
208
+ </handoffs>
209
+ ```
210
+
211
+ ### `<delegation>`
212
+ Opus vs Haiku responsibility division.
213
+
214
+ ```xml
215
+ <delegation>
216
+ ## What I Do vs What Helper Does
217
+
218
+ | I Do (Opus) | Helper Does (Haiku) |
219
+ |-------------|------------------|
220
+ | Read tests, plan implementation | Run tests, report results |
221
+ | Write code to pass tests | Update session for handoff |
222
+ </delegation>
223
+ ```
224
+
225
+ ### `<reasoning-mode>`
226
+ Controls verbose/quiet reasoning output.
227
+
228
+ ```xml
229
+ <reasoning-mode>
230
+ **Default:** Quiet mode - follow ReAct pattern internally, show only key decisions
231
+
232
+ **Toggle:** User says "verbose mode" to see explicit reasoning
233
+ </reasoning-mode>
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Gate Tags
239
+
240
+ Tags that contain checklists with `- [ ]` items.
241
+
242
+ | Tag | Purpose | Used By |
243
+ |-----|---------|---------|
244
+ | `<gate>` | General checklist gate | Subagents, SM |
245
+ | `<handoff-gate>` | Pre-handoff checklist | TEA, Dev, Reviewer |
246
+ | `<self-review>` | Self-review before handoff | Dev |
247
+ | `<review-checklist>` | Mandatory review steps | Reviewer |
248
+
249
+ ```xml
250
+ <handoff-gate>
251
+ ## MANDATORY: Complete Before Exiting
252
+
253
+ - [ ] Write Dev Assessment to session file
254
+ - [ ] Spawn `handoff` subagent
255
+ - [ ] Verify handoff completed (subagent emits marker)
256
+ </handoff-gate>
257
+ ```
258
+
259
+ ---
260
+
261
+ ## Workflow Tags
262
+
263
+ Agent-specific workflow documentation.
264
+
265
+ ### Generic Workflow Tags
266
+
267
+ | Tag | Purpose |
268
+ |-----|---------|
269
+ | `<workflow>` | Single primary workflow |
270
+ | `<workflows>` | Multiple workflow sections |
271
+ | `<workflow-participation>` | Role in agent-docs workflow |
272
+
273
+ ### SM-Specific Flow Tags
274
+
275
+ | Tag | Purpose |
276
+ |-----|---------|
277
+ | `<finish-flow>` | Story completion flow |
278
+ | `<new-work-flow>` | Starting new work flow |
279
+ | `<empty-backlog-flow>` | Empty backlog handling |
280
+ | `<workflow-routing>` | Workflow → agent routing table |
281
+
282
+ ### Assessment Tags
283
+
284
+ | Tag | Purpose | Used By |
285
+ |-----|---------|---------|
286
+ | `<assessment-template>` | Single assessment format | TEA, Dev |
287
+ | `<assessment-templates>` | Multiple assessment formats | Reviewer |
288
+
289
+ ### Exit Tags
290
+
291
+ | Tag | Purpose |
292
+ |-----|---------|
293
+ | `<exit-sequence>` | Detailed exit steps |
294
+ | `<exit>` | Final exit instruction (required) |
295
+
296
+ ### Specialized Tags
297
+
298
+ | Tag | Purpose | Used By |
299
+ |-----|---------|---------|
300
+ | `<severity-levels>` | Review severity table | Reviewer |
301
+ | `<design-principles>` | UX design rules | UX Designer |
302
+ | `<coordination>` | Agent coordination table | Orchestrator |
303
+ | `<handoff-protocol>` | Handoff procedure | Tech Writer |
304
+
305
+ ---
306
+
307
+ ## Subagent Tags
308
+
309
+ ### Required (Subagent Files)
310
+
311
+ | Tag | Purpose |
312
+ |-----|---------|
313
+ | `<arguments>` | Expected parameters table |
314
+ | `<output>` | Output format specification |
315
+
316
+ ### Optional (Subagent Files)
317
+
318
+ | Tag | Purpose |
319
+ |-----|---------|
320
+ | `<gate>` | Execution checklist |
321
+ | `<critical>` | High-priority instruction |
322
+ | `<info>` | Informational note |
323
+
324
+ ---
325
+
326
+ ## Informational Tags
327
+
328
+ | Tag | Purpose |
329
+ |-----|---------|
330
+ | `<info>` | Non-critical information |
331
+ | `<output>` | Output format specification |
332
+
333
+ ```xml
334
+ <info>
335
+ Universal entry point telling agents: what work exists, what phase, and whether to activate.
336
+ </info>
337
+ ```
338
+
339
+ ```xml
340
+ <output>
341
+ ## Output Format
342
+
343
+ Return a `TEST_RESULT` block:
344
+
345
+ ### Success (GREEN)
346
+ ```
347
+ TEST_RESULT:
348
+ status: success
349
+ overall: GREEN
350
+ ```
351
+ </output>
352
+ ```
353
+
354
+ ---
355
+
356
+ ## File Structure Template
357
+
358
+ ### Primary Agent
359
+ ```
360
+ # {Name} Agent - {Title}
361
+ <role>...</role>
362
+
363
+ <{mindset-tag}>...</{mindset-tag}>
364
+
365
+ <critical>...</critical>
366
+
367
+ <helpers>...</helpers>
368
+
369
+ <parameters>...</parameters>
370
+
371
+ <context>...</context>
372
+
373
+ <phase-check>...</phase-check>
374
+
375
+ <on-activation>...</on-activation>
376
+
377
+ <delegation>...</delegation>
378
+
379
+ <workflow(s)>...</workflow(s)>
380
+
381
+ <gate>...</gate>
382
+
383
+ <assessment-template>...</assessment-template>
384
+
385
+ <exit-sequence>...</exit-sequence>
386
+
387
+ <handoffs>...</handoffs>
388
+
389
+ <skills>...</skills>
390
+
391
+ <exit>...</exit>
392
+ ```
393
+
394
+ ### Subagent
395
+ ```
396
+ ---
397
+ name: {subagent-name}
398
+ description: {one-line description}
399
+ tools: Bash, Read, Edit
400
+ model: haiku
401
+ ---
402
+
403
+ <info>...</info>
404
+
405
+ <arguments>...</arguments>
406
+
407
+ <critical>...</critical>
408
+
409
+ <gate>...</gate>
410
+
411
+ {## Workflow steps}
412
+
413
+ <output>...</output>
414
+ ```
415
+
416
+ ---
417
+
418
+ ## Validation Rules
419
+
420
+ The validator (`validate-agent-schema.sh`) enforces:
421
+
422
+ | Rule | Severity | Description |
423
+ |------|----------|-------------|
424
+ | Required tags present | Error | `<role>`, `<helpers>`, `<exit>` |
425
+ | Mindset tag present | Error | Agent-specific mindset tag |
426
+ | All content in tags | Error | No orphan content outside tags |
427
+ | XML tags balanced | Error | Every `<tag>` has `</tag>` |
428
+ | `<parameters>` with `<helpers>` | Warning | Should have both |
429
+ | `<arguments>` in subagents | Warning | Expected in all subagents |
430
+ | First `<critical>` position | Warning | Should be ≤ line 30 |
431
+ | `<on-activation>` position | Warning | Should be ≤ line 100 |
432
+ | File length | Error | Max 300 lines |
@@ -21,7 +21,7 @@ Without approval gates, workflows may:
21
21
 
22
22
  ## Solution
23
23
 
24
- Implement **explicit verification points** where workflow progression requires passing a gate condition. Gates can be automated (tests must pass), require human review (Reviewer approval), or request user decisions (AskUserQuestion).
24
+ Implement **explicit verification points** where workflow progression requires passing a gate condition. Gates can be automated (tests must pass), require human review (Reviewer approval), or request user decisions (via Reflector-aware prompts).
25
25
 
26
26
  ```
27
27
  Workflow Stage
@@ -47,7 +47,7 @@ The key insight: **Make workflow progression conditional on explicit verificatio
47
47
 
48
48
  1. **Automated Gates** - Mechanical checks that must pass (tests, lint, pre-flight)
49
49
  2. **Human Review Gates** - Expert judgment required before proceeding
50
- 3. **User Decision Gates** - Interactive choices via AskUserQuestion
50
+ 3. **User Decision Gates** - Interactive choices via Reflector (CYCLIST marker + AskUserQuestion)
51
51
  4. **Plan Approval Gates** - Confirmation of proposed approach via EnterPlanMode
52
52
 
53
53
  ## State Diagram
@@ -228,12 +228,19 @@ The Reviewer agent implements an adversarial review gate:
228
228
 
229
229
  ### Gate Type 3: User Decision Gates
230
230
 
231
- Interactive prompts that pause workflow for user input.
231
+ Interactive prompts that pause workflow for user input. **Requires Reflector pattern:**
232
232
 
233
- **Example: AskUserQuestion for Story Selection**
233
+ 1. Output CYCLIST marker first (enables Cyclist UI integration)
234
+ 2. Then use AskUserQuestion tool
235
+
236
+ **Example: Reflector-Aware Story Selection**
237
+
238
+ ```markdown
239
+ <!-- CYCLIST:CHOICES:story -->
240
+ ```
234
241
 
235
242
  ```yaml
236
- # SM presents story options to user
243
+ # SM presents story options to user (after outputting marker)
237
244
  AskUserQuestion:
238
245
  questions:
239
246
  - question: "Which story shall we work on?"
@@ -252,8 +259,12 @@ AskUserQuestion:
252
259
 
253
260
  **Example: Confirmation Before Destructive Action**
254
261
 
262
+ ```markdown
263
+ <!-- CYCLIST:QUESTION:yesno -->
264
+ ```
265
+
255
266
  ```yaml
256
- # Before Jira claim or branch deletion
267
+ # Before Jira claim or branch deletion (after outputting marker)
257
268
  AskUserQuestion:
258
269
  questions:
259
270
  - question: "Confirm claiming MSSCI-11374 and creating branch?"
@@ -266,6 +277,11 @@ AskUserQuestion:
266
277
  description: "Abort setup and return to story selection"
267
278
  ```
268
279
 
280
+ **Reflector Markers:**
281
+ - `<!-- CYCLIST:CHOICES:{category} -->` - Multiple choice selection
282
+ - `<!-- CYCLIST:QUESTION:yesno -->` - Yes/No confirmation
283
+ - `<!-- CYCLIST:QUESTION:open -->` - Free-text input
284
+
269
285
  ### Gate Type 4: Plan Approval Gates
270
286
 
271
287
  Present proposed approach for user confirmation before execution.
@@ -736,10 +752,14 @@ When implementing approval gates:
736
752
  - GREEN verification: `agents/dev-handoff.md`
737
753
 
738
754
  ### Claude Code Tools
739
- - `AskUserQuestion`: Interactive user decision gates
755
+ - `AskUserQuestion`: Interactive user decision gates (requires CYCLIST marker via Reflector)
740
756
  - `EnterPlanMode` / `ExitPlanMode`: Plan approval gates
741
757
  - `Task` with `subagent_type`: Delegated gate execution
742
758
 
759
+ ### Reflector Hook
760
+ - `question-reflector-check.mjs`: Enforces CYCLIST marker before AskUserQuestion
761
+ - Markers: `<!-- CYCLIST:CHOICES:... -->`, `<!-- CYCLIST:QUESTION:yesno|open -->`
762
+
743
763
  ---
744
764
 
745
765
  *Last verified: 2026-01-06*
@@ -0,0 +1,114 @@
1
+ # Scale Levels Guide
2
+
3
+ Pennyfarthing uses scale levels (0-4) to route work to appropriate workflows. Scale levels are aligned with BMAD 6.0 methodology.
4
+
5
+ ## Scale Level Definitions
6
+
7
+ | Level | Scope | Story Count | Workflow | Required Artifacts |
8
+ |-------|-------|-------------|----------|-------------------|
9
+ | **0** | fix, bug, typo, small change, patch | 1 | `trivial` | None |
10
+ | **1** | simple, basic, small feature, add | 1-10 | `quick-spec` | tech-spec |
11
+ | **2** | dashboard, several features, admin panel | 5-15 | `prd` | PRD |
12
+ | **3** | platform, integration, complex, system | 12-40 | `prd` | PRD + architecture |
13
+ | **4** | enterprise, multi-tenant, multiple products | 40+ | `prd` | Full BMAD process |
14
+
15
+ ## Automatic Detection
16
+
17
+ When you describe work to Pennyfarthing, the scale level is detected from keywords:
18
+
19
+ ### Level 0 Keywords
20
+ - fix, bug, typo, patch, hotfix, small change
21
+
22
+ ### Level 1 Keywords
23
+ - simple, basic, small, add, minor
24
+
25
+ ### Level 2 Keywords
26
+ - dashboard, admin panel, several, multiple features
27
+
28
+ ### Level 3 Keywords
29
+ - platform, integration, complex, system
30
+
31
+ ### Level 4 Keywords
32
+ - enterprise, multi-tenant, multiple products
33
+
34
+ **Priority:** Higher levels take precedence. "Enterprise dashboard" → Level 4.
35
+
36
+ ## Workflow Routing
37
+
38
+ | Level | Workflow | Description |
39
+ |-------|----------|-------------|
40
+ | 0 | `trivial` | Direct fix, no planning artifacts |
41
+ | 1 | `quick-spec` | Conversational spec, produces tech-spec |
42
+ | 2-4 | `prd` | Full PRD workflow with gates |
43
+
44
+ ## Required Artifacts
45
+
46
+ ### Level 0: None
47
+ Just fix it. No planning documents required.
48
+
49
+ ### Level 1: Tech-Spec
50
+ Quick conversational spec producing implementation-ready technical specification.
51
+
52
+ ### Level 2: PRD
53
+ Product Requirements Document. Architecture is optional.
54
+
55
+ ### Level 3: PRD + Architecture
56
+ Both PRD and architecture documents required. System-level changes need design review.
57
+
58
+ ### Level 4: Full BMAD
59
+ Complete BMAD process:
60
+ - PRD
61
+ - Architecture
62
+ - Epics and Stories breakdown
63
+ - Implementation Readiness checklist
64
+
65
+ ## User Override
66
+
67
+ You can always override the detected level:
68
+
69
+ ```bash
70
+ # Explicitly set scale level
71
+ /workflow start prd --scale 3
72
+ ```
73
+
74
+ Or when asked during workflow initiation, specify your preferred level.
75
+
76
+ ## Python API
77
+
78
+ ```python
79
+ from pennyfarthing_scripts.workflow import (
80
+ detect_scale_level,
81
+ get_workflow_for_scale_level,
82
+ get_required_artifacts,
83
+ get_scale_level_info,
84
+ )
85
+
86
+ # Detect from description
87
+ level = detect_scale_level("build an enterprise platform") # Returns 4
88
+
89
+ # Get recommended workflow
90
+ workflow = get_workflow_for_scale_level(level) # Returns "prd"
91
+
92
+ # Get required artifacts
93
+ artifacts = get_required_artifacts(level) # Returns ["prd", "architecture", "epics-and-stories"]
94
+
95
+ # Get full metadata
96
+ info = get_scale_level_info(level)
97
+ # Returns: {"level": 4, "scope": "...", "stories_min": 40, ...}
98
+ ```
99
+
100
+ ## Examples
101
+
102
+ | Description | Detected Level | Workflow |
103
+ |-------------|----------------|----------|
104
+ | "Fix the login bug" | 0 | trivial |
105
+ | "Add a logout button" | 1 | quick-spec |
106
+ | "Build an admin dashboard" | 2 | prd |
107
+ | "New platform for data processing" | 3 | prd |
108
+ | "Enterprise multi-tenant SaaS" | 4 | prd |
109
+
110
+ ## Related
111
+
112
+ - [Workflow Skill](/workflow) - Workflow management commands
113
+ - [PRD Workflow](../workflows/prd/) - Full PRD stepped workflow
114
+ - [Quick-Spec Workflow](../workflows/quick-spec/) - Lightweight spec workflow
@@ -333,7 +333,7 @@ agents:
333
333
  quirks:
334
334
  - Source of every useful material on the island
335
335
  - Patched together with vines, bamboo, and determination
336
- - "The tiny ship was tossed" but never truly sank
336
+ - '"The tiny ship was tossed" but never truly sank'
337
337
  - Every repair reveals another piece needed for rescue attempts
338
338
  - Somehow keeps providing what the castaways need, against all odds
339
339
  catchphrases:
@@ -342,7 +342,7 @@ agents:
342
342
  - "The weather started getting rough... but we're still afloat. Barely."
343
343
  - "Every salvage operation yields something new. The ship keeps giving."
344
344
  - "Held together with coconut rope and prayer, but she hasn't failed us yet."
345
- - "The tiny ship was tossed... but never broken. That's infrastructure resilience."
345
+ - '"The tiny ship was tossed... but never broken. That''s infrastructure resilience."'
346
346
  quote: "A three-hour tour... a three-hour deployment that became a three-year maintenance contract..."
347
347
  emoji: "🚢"
348
348
  helper:
@@ -160,7 +160,7 @@ agents:
160
160
  quote: I'm a doctor, not a code monkey!
161
161
  trait: Grumpy exterior hiding deep care, medical metaphors
162
162
  quirks:
163
- - "I'm a doctor, not a..." (insert current task) is reflexive
163
+ - '"I''m a doctor, not a..." (insert current task) is reflexive'
164
164
  - Grumpy exterior hides genuine care for code health
165
165
  - Uses medical metaphors for everything
166
166
  - Argues with Spock about logic vs intuition in reviews
@@ -211,16 +211,22 @@ case "$1" in
211
211
  echo "$2" > "$AGENT_FILE"
212
212
  echo "Session: $session_id -> $2"
213
213
 
214
- # Output persona on start (unless character_voice is disabled)
215
- if is_character_voice_enabled; then
216
- output_persona "$2"
217
- fi
218
-
219
- # Auto-prime context after persona (reduces cold-start overhead)
220
- # Pass agent name so prime can load agent-specific sidecar
214
+ # Context loading order (optimized for attention):
215
+ # 1. CLAUDE.md (system prompt - already loaded)
216
+ # 2. Agent definition + behavior guide (loaded by prime.sh FIRST)
217
+ # 3. Persona (output here, AFTER agent definition)
218
+ # 4. Session summary (loaded by prime.sh)
219
+ # 5. Sidecars (loaded by prime.sh LAST)
220
+
221
+ # Auto-prime loads agent definition FIRST (highest attention zone)
221
222
  if [[ -f "$PROJECT_ROOT/.pennyfarthing/scripts/prime.sh" ]]; then
222
223
  "$PROJECT_ROOT/.pennyfarthing/scripts/prime.sh" --quiet --agent "$2"
223
224
  fi
225
+
226
+ # Output persona AFTER agent definition (character voice is supplementary)
227
+ if is_character_voice_enabled; then
228
+ output_persona "$2"
229
+ fi
224
230
  ;;
225
231
  stop)
226
232
  # Use provided session ID, fall back to SESSION_ID env var
@@ -204,9 +204,14 @@ if last_total is not None:
204
204
  # Use usable percent for status decisions (more accurate for user)
205
205
  if usable_pct > warning_threshold:
206
206
  print('CONTEXT_STATUS=HIGH')
207
- print('HANDOFF_MODE=auto')
208
207
  else:
209
208
  print('CONTEXT_STATUS=OK')
209
+
210
+ # HANDOFF_MODE: 'auto' if relay_mode enabled, 'ask' otherwise
211
+ # MSSCI-12395: relay_mode controls autohandoff independent of context level
212
+ if relay_mode:
213
+ print('HANDOFF_MODE=auto')
214
+ else:
210
215
  print('HANDOFF_MODE=ask')
211
216
 
212
217
  # TirePump: Use CONTEXT_CLEAR (clear + load next agent) when: