@fernado03/zoo-flow 0.5.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +102 -79
  2. package/bin/zoo-flow.js +398 -50
  3. package/docs/architecture.md +380 -0
  4. package/docs/bloat-control.md +49 -0
  5. package/docs/command-design.md +38 -0
  6. package/docs/command-flow.md +133 -0
  7. package/docs/comparison.md +86 -0
  8. package/docs/context-packs.md +35 -0
  9. package/docs/dogfood/01-small-library.md +28 -0
  10. package/docs/dogfood/02-web-app.md +29 -0
  11. package/docs/dogfood/03-mixed-monorepo.md +29 -0
  12. package/docs/mode-rules.md +86 -0
  13. package/docs/npm-publishing.md +79 -0
  14. package/docs/out-of-scope/mainstream-issue-trackers-only.md +25 -0
  15. package/docs/out-of-scope/question-limits.md +18 -0
  16. package/docs/out-of-scope/setup-skill-verify-mode.md +15 -0
  17. package/docs/overview.md +61 -0
  18. package/docs/philosophy.md +73 -0
  19. package/docs/quality-scorecard.md +23 -0
  20. package/docs/skill-maintenance.md +32 -0
  21. package/docs/skills-index.md +61 -0
  22. package/docs/team-mode.md +46 -0
  23. package/docs/token-budget.md +22 -0
  24. package/docs/troubleshooting.md +288 -0
  25. package/examples/demo-transcripts/01-small-tweak.md +37 -0
  26. package/examples/demo-transcripts/02-unknown-bug-fix.md +37 -0
  27. package/examples/demo-transcripts/03-new-feature.md +37 -0
  28. package/examples/demo-transcripts/04-refactor.md +37 -0
  29. package/examples/demo-transcripts/05-review-and-verify.md +37 -0
  30. package/examples/feature-flow.md +117 -0
  31. package/examples/fix-flow.md +139 -0
  32. package/package.json +16 -5
  33. package/quality/scorecard.json +88 -0
  34. package/quality/token-budget.exceptions.json +13 -0
  35. package/scripts/bundle.ps1 +135 -0
  36. package/scripts/check-golden-transcripts.js +69 -0
  37. package/scripts/check-package-links.js +72 -0
  38. package/scripts/check-package-manifest.js +70 -0
  39. package/scripts/eval-routing.js +149 -0
  40. package/scripts/score-quality.js +292 -0
  41. package/scripts/test-doctor.js +107 -0
  42. package/scripts/test-project-shapes.js +99 -0
  43. package/scripts/token-budget.js +105 -0
  44. package/templates/full/.roo/commands/caveman.md +1 -1
  45. package/templates/full/.roo/commands/diagnose.md +2 -1
  46. package/templates/full/.roo/commands/feature.md +1 -1
  47. package/templates/full/.roo/commands/fix.md +1 -1
  48. package/templates/full/.roo/commands/grill-me.md +2 -1
  49. package/templates/full/.roo/commands/grill-with-docs.md +2 -1
  50. package/templates/full/.roo/commands/handoff.md +2 -1
  51. package/templates/full/.roo/commands/improve-codebase-architecture.md +2 -1
  52. package/templates/full/.roo/commands/prototype.md +1 -1
  53. package/templates/full/.roo/commands/refactor.md +1 -1
  54. package/templates/full/.roo/commands/review.md +11 -0
  55. package/templates/full/.roo/commands/setup-matt-pocock-skills.md +1 -1
  56. package/templates/full/.roo/commands/tdd.md +1 -1
  57. package/templates/full/.roo/commands/to-issues.md +2 -1
  58. package/templates/full/.roo/commands/to-prd.md +2 -1
  59. package/templates/full/.roo/commands/triage.md +1 -1
  60. package/templates/full/.roo/commands/tweak.md +1 -1
  61. package/templates/full/.roo/commands/verify.md +11 -0
  62. package/templates/full/.roo/commands/write-a-skill.md +2 -1
  63. package/templates/full/.roo/commands/zoom-out.md +2 -1
  64. package/templates/full/.roo/rules/01-command-protocol.md +1 -1
  65. package/templates/full/.roo/rules/04-context-economy.md +3 -5
  66. package/templates/full/.roo/rules-code-tweaker/01-completion.md +12 -8
  67. package/templates/full/.roo/rules-custom-orchestrator/00-routing.md +23 -9
  68. package/templates/full/.roo/rules-custom-orchestrator/01-delegation-message.md +11 -7
  69. package/templates/full/.roo/rules-system-architect/02-completion.md +6 -2
  70. package/templates/full/.roo/skills/engineering/README.md +2 -0
  71. package/templates/full/.roo/skills/engineering/commit-and-document/SKILL.md +1 -2
  72. package/templates/full/.roo/skills/engineering/grill-with-docs/ADR-FORMAT.md +1 -1
  73. package/templates/full/.roo/skills/engineering/grill-with-docs/CONTEXT-FORMAT.md +7 -32
  74. package/templates/full/.roo/skills/engineering/grill-with-docs/SKILL.md +1 -1
  75. package/templates/full/.roo/skills/engineering/improve-codebase-architecture/SKILL.md +3 -3
  76. package/templates/full/.roo/skills/engineering/review/SKILL.md +111 -0
  77. package/templates/full/.roo/skills/engineering/scaffold-context/SKILL.md +66 -0
  78. package/templates/full/.roo/skills/engineering/scaffold-context/templates/writing-patterns.md +17 -0
  79. package/templates/full/.roo/skills/engineering/setup-matt-pocock-skills/SKILL.md +3 -3
  80. package/templates/full/.roo/skills/engineering/setup-matt-pocock-skills/domain.md +2 -3
  81. package/templates/full/.roo/skills/engineering/tdd/SKILL.md +2 -0
  82. package/templates/full/.roo/skills/engineering/tweak/SKILL.md +2 -1
  83. package/templates/full/.roo/skills/engineering/verify/SKILL.md +80 -0
  84. package/templates/full/.roo/skills/in-progress/README.md +0 -1
  85. package/templates/full/.roomodes +3 -3
  86. package/templates/full/.zoo-flow/evals/no-regression-checklist.md +4 -2
  87. package/templates/full/.zoo-flow/evals/routing-cases.jsonl +20 -0
  88. package/templates/full/.zoo-flow/evals/routing-cases.md +27 -3
  89. package/templates/full/.zoo-flow/project-profile.json +24 -0
  90. package/tests/fixtures/bad-routing-cases/bad-json.jsonl +1 -0
  91. package/tests/fixtures/bad-routing-cases/bad-mode.jsonl +1 -0
  92. package/tests/fixtures/bad-routing-cases/missing-command.jsonl +1 -0
  93. package/tests/fixtures/doctor/bad-built-in-delegation/fixture.json +1 -0
  94. package/tests/fixtures/doctor/bad-mode-slug/fixture.json +1 -0
  95. package/tests/fixtures/doctor/bad-skill-wrapper/fixture.json +1 -0
  96. package/tests/fixtures/doctor/bad-zoo-path/fixture.json +1 -0
  97. package/tests/fixtures/doctor/helper-missing-mode/fixture.json +1 -0
  98. package/tests/fixtures/doctor/helper-not-permitted/fixture.json +1 -0
  99. package/tests/fixtures/doctor/manual-good-template/fixture.json +1 -0
  100. package/tests/fixtures/doctor/missing-command/fixture.json +1 -0
  101. package/tests/fixtures/doctor/missing-roomodes/fixture.json +1 -0
  102. package/tests/fixtures/doctor/missing-skill/fixture.json +1 -0
  103. package/tests/fixtures/project-shapes/cli-tool/cmd/root.go +1 -0
  104. package/tests/fixtures/project-shapes/cli-tool/fixture.json +1 -0
  105. package/tests/fixtures/project-shapes/cli-tool/package.json +1 -0
  106. package/tests/fixtures/project-shapes/data-pipeline/fixture.json +1 -0
  107. package/tests/fixtures/project-shapes/data-pipeline/pipelines/invoices.py +1 -0
  108. package/tests/fixtures/project-shapes/data-pipeline/pyproject.toml +2 -0
  109. package/tests/fixtures/project-shapes/library/fixture.json +1 -0
  110. package/tests/fixtures/project-shapes/library/package.json +1 -0
  111. package/tests/fixtures/project-shapes/library/src/index.ts +1 -0
  112. package/tests/fixtures/project-shapes/monorepo/fixture.json +1 -0
  113. package/tests/fixtures/project-shapes/monorepo/package.json +1 -0
  114. package/tests/fixtures/project-shapes/monorepo/packages/core/index.ts +1 -0
  115. package/tests/fixtures/project-shapes/monorepo/packages/web/index.ts +1 -0
  116. package/tests/fixtures/project-shapes/serverless/fixture.json +1 -0
  117. package/tests/fixtures/project-shapes/serverless/functions/webhook.ts +1 -0
  118. package/tests/fixtures/project-shapes/serverless/package.json +1 -0
  119. package/tests/fixtures/project-shapes/web-app/app/routes/index.tsx +1 -0
  120. package/tests/fixtures/project-shapes/web-app/fixture.json +1 -0
  121. package/tests/fixtures/project-shapes/web-app/package.json +1 -0
  122. package/tests/golden-transcripts/01-small-tweak-golden.md +21 -0
  123. package/tests/golden-transcripts/02-diagnosis-golden.md +26 -0
  124. package/tests/golden-transcripts/03-verification-golden.md +24 -0
  125. package/tests/golden-transcripts/04-review-golden.md +26 -0
  126. package/tests/golden-transcripts/05-feature-planning-golden.md +23 -0
  127. package/templates/full/.roo/skills/in-progress/review/SKILL.md +0 -39
@@ -0,0 +1,380 @@
1
+ # Architecture
2
+
3
+ Zoo Flow ships three custom modes, a fixed routing matrix, a small set of
4
+ always-on rules, and a directory layout for slash commands and on-demand
5
+ skills. This document explains what each piece does and why it is shaped
6
+ the way it is.
7
+
8
+ ## Components
9
+
10
+ ```
11
+ templates/full/
12
+ ├── .roomodes # minimal: slug, groups, short pointers
13
+ └── .roo/
14
+ ├── rules/ # always-on, every mode, every turn
15
+ │ ├── 00-paths.md
16
+ │ ├── 01-command-protocol.md
17
+ │ ├── 02-three-failure-rule.md
18
+ │ ├── 03-manual-reply-protocol.md
19
+ │ ├── 04-context-economy.md
20
+ │ └── 05-mcp-awareness.md
21
+ ├── rules-custom-orchestrator/ # mode-scoped, orchestrator only
22
+ │ ├── 00-routing.md
23
+ │ └── 01-delegation-message.md
24
+ ├── rules-system-architect/ # mode-scoped, architect only
25
+ │ ├── 00-scope.md
26
+ │ ├── 01-feature-prototype.md
27
+ │ └── 02-completion.md
28
+ ├── rules-code-tweaker/ # mode-scoped, tweaker only
29
+ │ ├── 00-scope.md
30
+ │ └── 01-completion.md
31
+ ├── commands/ # slash commands (the public API)
32
+ └── skills/ # on-demand skills, loaded by commands
33
+ ├── engineering/
34
+ ├── productivity/
35
+ ├── misc/
36
+ ├── personal/
37
+ └── in-progress/
38
+ ```
39
+
40
+ `.roomodes` is intentionally minimal. It declares each mode's slug,
41
+ role, tool groups, and a short `customInstructions` block that points
42
+ at the matching `.roo/rules-{modeSlug}/` folder. All detailed mode
43
+ behavior lives in the rule files inside that folder. See
44
+ [`mode-rules.md`](mode-rules.md) for the full layout rationale.
45
+
46
+ > Zoo Flow uses the preferred `.roo/rules-{modeSlug}/` directory form
47
+ > only. Legacy single-file fallbacks such as `.roorules-{modeSlug}` and
48
+ > `.clinerules-{modeSlug}` are not used by this template.
49
+
50
+ ## Modes
51
+
52
+ ### `custom-orchestrator`
53
+
54
+ Defined in `templates/full/.roomodes`. Tool groups: **none**. Detailed
55
+ behavior lives in
56
+ [`.roo/rules-custom-orchestrator/`](../templates/full/.roo/rules-custom-orchestrator/)
57
+ (`00-routing.md`, `01-delegation-message.md`).
58
+
59
+ The orchestrator cannot read, edit, run commands, or call MCP tools. It
60
+ exists to do exactly four things:
61
+
62
+ 1. Read the user request.
63
+ 2. Map it to a command using the routing matrix in its
64
+ `customInstructions`.
65
+ 3. Either delegate via `new_task` (when the user supplied an explicit
66
+ slash command) or offer 1-2 numbered workflow choices and halt
67
+ (when they did not).
68
+ 4. Summarize the subtask result and halt again.
69
+
70
+ It never uses `switch_mode`. If `new_task` is unavailable, it stops and
71
+ reports — it does not try to do the work itself.
72
+
73
+ ### `system-architect`
74
+
75
+ Tool groups: `command`, `mcp`, `read`, and a constrained `edit` that only
76
+ matches Markdown files, `.scratch/`, and `docs/`. The `fileRegex` lives in
77
+ `.roomodes`:
78
+
79
+ ```json
80
+ { "fileRegex": "(.*\\.md$|^\\.scratch/.*|^docs/.*)" }
81
+ ```
82
+
83
+ Detailed behavior lives in
84
+ [`.roo/rules-system-architect/`](../templates/full/.roo/rules-system-architect/)
85
+ (`00-scope.md`, `01-feature-prototype.md`, `02-completion.md`).
86
+
87
+ The architect plans, diagnoses, refactors, explores, and triages. It cannot
88
+ edit application source code. When implementation is needed, it
89
+ `switch_mode`s to `code-tweaker` inside the same task window.
90
+
91
+ Hard stops are baked in:
92
+
93
+ - 3-strike rule on diagnosis: after three failed attempts, halt and ask
94
+ the user.
95
+ - HITL stop before testing a hypothesis, finalizing a plan, publishing
96
+ issues, or making any irreversible decision.
97
+ - During `/feature`, never run a prototype directly. Summarize and
98
+ switch to the tweaker.
99
+
100
+ ### `code-tweaker`
101
+
102
+ Tool groups: `read`, `edit`, `command`, `mcp`. Full repo access within the
103
+ assigned command. Detailed behavior lives in
104
+ [`.roo/rules-code-tweaker/`](../templates/full/.roo/rules-code-tweaker/)
105
+ (`00-scope.md`, `01-completion.md`).
106
+
107
+ The tweaker implements, runs tests, updates docs, builds prototypes, and
108
+ prepares commits.
109
+
110
+ Hard stops:
111
+
112
+ - Auto-escalate to the architect on the **same task window** if the work
113
+ needs major architecture decisions or the same approach fails three times.
114
+ - Git stop: never run `git commit` or `git push` without explicit user
115
+ approval. Pushes only happen when the user asks.
116
+ - Complete the whole chain, not the current phase. `attempt_completion`
117
+ returns to the orchestrator only after the command's **final** phase.
118
+ If a later phase belongs to the architect (e.g. `/fix` post-mortem),
119
+ hand back with `switch_mode` instead of completing early.
120
+
121
+ ## Command protocol
122
+
123
+ The protocol is in
124
+ [`templates/full/.roo/rules/01-command-protocol.md`](../templates/full/.roo/rules/01-command-protocol.md).
125
+ It is loaded on every turn for every mode.
126
+
127
+ When a mode is assigned a slash command:
128
+
129
+ 1. **Normalize.** `/fix` becomes `fix`.
130
+ 2. **Prefer `run_slash_command`.** Pass the normalized name as `command`
131
+ and the full task context as `args`.
132
+ 3. **Fall back to the file.** If `run_slash_command` is unavailable,
133
+ disabled, or fails, read `templates/full/.roo/commands/{command}.md`
134
+ and execute its instructions.
135
+ 4. **Resolve skills via the file.** If the command references a skill,
136
+ read the exact `.roo/skills/...` path the command provides. Do not
137
+ compute paths from anywhere else.
138
+ 5. **Do not chain.** A command suggested inside a subtask summary is
139
+ *not* authorization to run that command. Only the human or the
140
+ orchestrator's routing may launch a new command.
141
+
142
+ The protocol exists to make slash commands work the same way whether the
143
+ host UI exposes a native command runner or only file reads.
144
+
145
+ ### Command types
146
+
147
+ Zoo Flow supports two command types:
148
+
149
+ 1. **Skill-wrapper commands.** The command file declares a skill via a
150
+ line like:
151
+
152
+ ```md
153
+ Skill: `.roo/skills/engineering/tdd/SKILL.md`
154
+ ```
155
+
156
+ The worker loads and follows that skill.
157
+
158
+ 2. **Direct workflow commands.** The command file contains the
159
+ procedure directly (no `Skill:` line). The worker executes those
160
+ steps directly and must not invent a skill path.
161
+
162
+ This prevents redundant loading and avoids hallucinated skill paths.
163
+
164
+ ## Path safety
165
+
166
+ The path-safety contract is in
167
+ [`templates/full/.roo/rules/00-paths.md`](../templates/full/.roo/rules/00-paths.md).
168
+ Two rules:
169
+
170
+ - Skills are at workspace-root paths under `.roo/skills/{bucket}/{skill}/SKILL.md`.
171
+ - Commands are at workspace-root paths under `.roo/commands/{name}.md`.
172
+
173
+ The forbidden form is anything under `.roo/rules/skills/...` or
174
+ `.roo/rules/commands/...`. Modes that try to load skills relative to a
175
+ `rules/` file have produced the most common failure in practice
176
+ (`ENOENT: .roo/rules/skills/...`). The rule blocks it before it happens.
177
+
178
+ ## Slash commands
179
+
180
+ Each command is a Markdown file with a YAML front matter and a body. The
181
+ front matter declares the target mode and the argument hint:
182
+
183
+ ```markdown
184
+ ---
185
+ description: "Direct implementation mode for small, known fixes or UI updates."
186
+ argument-hint: <what to change>
187
+ mode: code-tweaker
188
+ ---
189
+
190
+ Skill: `.roo/skills/engineering/tweak/SKILL.md`
191
+
192
+ $ARGUMENTS
193
+ ```
194
+
195
+ The body is the actual instruction set. Some commands invoke a single
196
+ skill (`/tweak`, `/prototype`). Others orchestrate a multi-phase chain
197
+ across modes (`/fix`, `/feature`, `/refactor`).
198
+
199
+ A command can:
200
+
201
+ - Reference a skill by its exact `.roo/skills/...` path.
202
+ - Spell out HITL stops between phases.
203
+ - Direct a mode to `switch_mode` to another mode at a specific phase.
204
+ - Substitute `$ARGUMENTS` with the user / delegated context.
205
+
206
+ A command must not:
207
+
208
+ - Compute skill paths dynamically.
209
+ - Bypass the orchestrator when handing the human a choice.
210
+ - Auto-launch a follow-up command from a subtask summary.
211
+
212
+ ### Core vs. helper commands
213
+
214
+ The orchestrator's **routing matrix** intentionally only routes a small
215
+ set of core workflow commands:
216
+
217
+ - `/tweak`, `/tdd`, `/update-docs`, `/commit-and-document`, `/prototype`, `/verify`
218
+ → `code-tweaker`
219
+ - `/fix`, `/feature`, `/refactor`, `/explore`, `/triage`, `/review`
220
+ → `system-architect`
221
+
222
+ Every other command in `templates/full/.roo/commands/` is a **helper**.
223
+ Helpers are real, working commands. They are run directly inside the
224
+ appropriate mode rather than delegated by the orchestrator. This keeps
225
+ the orchestrator's routing matrix small and predictable, while leaving
226
+ the broader command library available when you want it.
227
+
228
+ If a helper command starts being used often enough to deserve
229
+ delegation, promote it to the routing matrix in `.roomodes` and add it
230
+ to the routed table in [`README.md`](../README.md#commands).
231
+
232
+ ## Skills
233
+
234
+ Skills live under `templates/full/.roo/skills/`. Each skill is a folder
235
+ with a `SKILL.md` and any supporting files (templates, scripts, sub-docs).
236
+ They are organized into buckets:
237
+
238
+ - `engineering/` — code work.
239
+ - `productivity/` — non-code workflow.
240
+ - `misc/` — kept around but rarely used.
241
+ - `personal/` — tied to a maintainer's setup, not promoted.
242
+ - `in-progress/` — drafts, not ready to ship.
243
+
244
+ Skills are loaded **only** through commands. There is no "skill autoloader"
245
+ that pulls them on every turn. The orchestrator does not see skills at all;
246
+ it only sees commands.
247
+
248
+ The skills index lives in [`docs/skills-index.md`](skills-index.md).
249
+ It is human-facing reference documentation, intentionally kept outside
250
+ `.roo/rules/` because `.roo/rules/` is injected on every turn. Commands
251
+ load skills directly from explicit `.roo/skills/.../SKILL.md` paths, so
252
+ the index is not required for runtime execution.
253
+
254
+ ### Skill output placement
255
+
256
+ Skills that produce throwaway working files share a single convention
257
+ so cleanup is mechanical:
258
+
259
+ - `.scratch/<command>-<slug>.md` — phase checklists for `/fix`,
260
+ `/feature`, `/refactor`; optional `/explore` save-targets under
261
+ `.scratch/explorations/<date>/`; local PRDs and issues from
262
+ `setup-matt-pocock-skills` (`.scratch/{feature-slug}/`).
263
+ - `.scratch/prototypes/<slug>/` — logic, state, and data-model
264
+ prototypes from `/prototype` (`LOGIC.md` branch). UI prototypes stay
265
+ adjacent to the real page they mock up because they need the route,
266
+ data fetching, and auth.
267
+ - `docs/journal/` — entries written by `/commit-and-document`.
268
+ - In-place edits — `/tweak`, `/tdd`, `migrate-to-shoehorn`,
269
+ `update-docs`.
270
+
271
+ `.scratch/` is on the architect's `fileRegex` allowlist, so it is a
272
+ safe edit target for `system-architect` and a natural bulk-cleanup
273
+ target for the user.
274
+
275
+ ## Three-folder contract
276
+
277
+ Zoo Flow uses three distinct folders, each with a different lifetime
278
+ and replacement policy. Keeping them separate is intentional:
279
+
280
+ | Folder | Lifetime | Loaded every turn? | Replaced by `init`/`update`? | Gitignored? | Authored by |
281
+ |---|---|---|---|---|---|
282
+ | `.roo/` | Per release | ✅ (rules/) | ✅ (full replace) | No | Template |
283
+ | `.scratch/` | Per chain | ❌ | ❌ | Convention | Worker |
284
+ | `.zoo-flow/` | Per project | ❌ | ❌ (migrated) | ✅ (init appends) | User via /grill-with-docs |
285
+
286
+ **Why three folders, not one.** Each row has a different replacement
287
+ policy and a different authorship model. Collapsing them would force
288
+ the host to grow exception mechanisms (don't auto-load, don't replace
289
+ this subset, don't wipe user content) that defeat the point of having
290
+ a single contract.
291
+
292
+ **Why `.zoo-flow/` instead of root.** Root `CONTEXT.md` and root
293
+ `docs/adr/` polluted every project with files only some projects
294
+ needed. `.zoo-flow/` is hidden, gitignored by default, and houses only
295
+ the universally-essential `CONTEXT.md` placeholder plus user-authored
296
+ ADRs. The other slots (ARCHITECTURE.md, APP_MAP.md, FLOW.md) are
297
+ created on demand and never pre-shipped. The full slot list and
298
+ discovery rule live in
299
+ [`grill-with-docs/CONTEXT-FORMAT.md`](../templates/full/.roo/skills/engineering/grill-with-docs/CONTEXT-FORMAT.md).
300
+
301
+ ## Same-window `switch_mode`
302
+
303
+ Used inside a single task window when one mode needs the other for a phase
304
+ of the same workflow. Examples:
305
+
306
+ - `/fix` going architect (diagnose) → tweaker (implement) → architect
307
+ (post-mortem).
308
+ - `/feature` going architect (sharpen) → tweaker (prototype) → architect
309
+ (PRD).
310
+ - `code-tweaker` auto-escalating after a 3-strike test failure.
311
+
312
+ `switch_mode` preserves context. The receiving mode reads the same task
313
+ window and continues. Use it for tight loops where the cost of losing
314
+ context outweighs the benefit of a clean boundary.
315
+
316
+ ## Delegated `new_task`
317
+
318
+ Used by the orchestrator only. The orchestrator does not implement
319
+ anything; it hands work off to the architect or the tweaker via
320
+ `new_task`. The delegated message must include:
321
+
322
+ - The slash command, including the leading slash.
323
+ - The user context.
324
+ - A proceed policy. One of: `Proceed automatically after audit if
325
+ clean`, `Ask user before implementation`, or `Stop and report only`.
326
+ - A reminder to follow `.roo/rules/01-command-protocol.md`.
327
+ - A reminder that skills live under `.roo/skills/...`.
328
+ - A completion rule: finish the **whole command chain**, then end with
329
+ `attempt_completion` containing summary, files inspected/changed,
330
+ commands/tests run, blockers, and a recommended next command. Mid-chain
331
+ mode handoffs use `switch_mode`, not `attempt_completion`.
332
+
333
+ `new_task` opens a fresh subtask window. The boundary is the point.
334
+ Mode-internal context, scratch work, and false starts stay in the
335
+ subtask.
336
+
337
+ ## Proceed policy
338
+
339
+ Zoo Flow delegated tasks include a proceed policy so workers know when
340
+ to continue and when to ask the user.
341
+
342
+ Policies:
343
+
344
+ - `Proceed automatically after audit if clean`
345
+ - `Ask user before implementation`
346
+ - `Stop and report only`
347
+
348
+ This prevents unnecessary questions during well-specified subtasks,
349
+ while preserving approval gates for hypotheses, architecture decisions,
350
+ commits, issue changes, and irreversible actions.
351
+
352
+ ## `attempt_completion`
353
+
354
+ Used at the end of a delegated subtask. It is **not** an escape hatch.
355
+
356
+ A delegated task is the **entire command chain** — every phase and every
357
+ mode switch the command body defines — not the single phase a mode is
358
+ currently running. A worker returns via `attempt_completion` only after
359
+ the command's **final** phase. Mid-chain handoffs between modes use
360
+ `switch_mode`.
361
+
362
+ Specifically, the architect must not use `attempt_completion` to skip
363
+ required implementation work — if the work belongs to the tweaker, the
364
+ architect uses `switch_mode` first. Likewise the tweaker must not complete
365
+ out from under a remaining architect phase (e.g. `/fix` post-mortem); it
366
+ `switch_mode`s back. Before any `attempt_completion`, the worker re-checks
367
+ the command body and confirms no later phase is assigned to another mode.
368
+ The composite commands (`/fix`, `/feature`, `/refactor`) persist a phase
369
+ checklist under `.scratch/` so this survives context growth and mode
370
+ switches.
371
+
372
+ `attempt_completion` returns to the orchestrator with a structured summary.
373
+ The orchestrator then summarizes for the user and halts. It never
374
+ auto-launches the next subtask, even if the summary suggests one.
375
+
376
+ ## Context economy
377
+
378
+ Zoo Flow avoids unnecessary token use by asking agents to search or list before broad reads, use targeted line ranges when possible, and avoid re-reading unchanged files.
379
+
380
+ Full-file reads are still allowed when correctness requires complete context.
@@ -0,0 +1,49 @@
1
+ # Bloat Control
2
+
3
+ Zoo Flow must stay small, focused, and hard to break. Every addition
4
+ of a command, doc, rule, or skill must clear a bloat gate.
5
+
6
+ ## Bloat gate
7
+
8
+ Before adding any new:
9
+
10
+ - **Command** (composite or routed)
11
+ - **Documentation file** under `docs/`
12
+ - **Global rule** under `.roo/rules/`
13
+ - **Mode-specific rule** under `.roo/rules-{mode}/`
14
+ - **Skill** that ships by default
15
+
16
+ Answer these:
17
+
18
+ 1. **Is it needed by most projects?** If not, it should be a
19
+ context pack or a community skill, not a default.
20
+ 2. **Does it cross SA/CT boundaries?** If not, prefer a skill or
21
+ helper command over a composite.
22
+ 3. **Does it add a new check to doctor?** Every file addition should
23
+ also add a doctor validation for it.
24
+ 4. **Does it fit a token budget tier?** Every file has a budget
25
+ (see `docs/token-budget.md`). If it exceeds the tier, add an
26
+ exception with justification.
27
+ 5. **Does it require documentation?** Every command and every new
28
+ doc file needs README or docs/ coverage with a link that
29
+ `check-package-links.js` validates.
30
+
31
+ ## Guardrails
32
+
33
+ - Do not create optional docs by default. `/scaffold-context` may
34
+ offer them, but they are never written without user confirmation.
35
+ - Do not add composite commands unless they meet all criteria in
36
+ `docs/command-design.md`.
37
+ - Do not weaken approval gates or auto-run `/verify`, `/review`, or
38
+ `/commit-and-document`.
39
+ - Token budgets with explicit exceptions are enforced by
40
+ `scripts/token-budget.js`.
41
+
42
+ ## Anti-patterns
43
+
44
+ - Adding a command "because it might be useful" — put it in a skill
45
+ or context pack.
46
+ - Accepting doc bloat "because it clarifies things" — token budget
47
+ will catch it.
48
+ - Creating optional docs as defaults — they are only offered through
49
+ `/scaffold-context` after user confirmation.
@@ -0,0 +1,38 @@
1
+ # Command Design
2
+
3
+ Zoo Flow should not add a composite command unless it meets all criteria:
4
+
5
+ 1. It crosses `system-architect` / `code-tweaker` boundaries.
6
+ 2. It needs hard stops or user approval gates.
7
+ 3. It benefits from `.scratch/` phase tracking.
8
+ 4. It is common across many projects.
9
+ 5. Chaining existing commands manually is awkward or unsafe.
10
+
11
+ If not, prefer:
12
+
13
+ - a skill
14
+ - a helper command
15
+ - a routing eval
16
+ - a doctor check
17
+ - documentation
18
+
19
+ ## Good composites
20
+
21
+ - `/feature`
22
+ - `/fix`
23
+ - `/refactor`
24
+
25
+ ## Good non-composites
26
+
27
+ - `/review`
28
+ - `/verify`
29
+ - `/update-docs`
30
+ - `/commit-and-document`
31
+
32
+ ## Do not add yet
33
+
34
+ - `/ship`
35
+ - `/release`
36
+ - `/migrate`
37
+ - `/security-audit`
38
+ - `/cleanup`
@@ -0,0 +1,133 @@
1
+ # Command flow
2
+
3
+ This document walks the lifecycle of a slash command from chat input to
4
+ completion, and shows the difference between same-window switches and
5
+ delegated subtasks.
6
+
7
+ ## End-to-end: explicit slash command
8
+
9
+ ```mermaid
10
+ sequenceDiagram
11
+ autonumber
12
+ actor User
13
+ participant O as 🪃 custom-orchestrator
14
+ participant A as 🏗️ system-architect
15
+ participant T as ⚡ code-tweaker
16
+
17
+ User->>O: /fix Login button is dead on second click.
18
+ O->>O: Look up routing matrix
19
+ O->>A: new_task("/fix ...", protocol + skill location)
20
+ A->>A: Load /fix command, run diagnose phases 1-3
21
+ A-->>User: Hypotheses, HITL stop
22
+ User->>A: Choose hypothesis 2
23
+ A->>A: Diagnose phase 4 (instrument), find root cause
24
+ A->>T: switch_mode (same window) — implement fix
25
+ T->>T: Phase 5 — patch + tests
26
+ T->>A: switch_mode — back for post-mortem
27
+ A->>A: Phase 6 — post-mortem
28
+ A->>O: attempt_completion (summary, files, blockers)
29
+ O-->>User: Summary + halt
30
+ ```
31
+
32
+ Notes:
33
+
34
+ - Step 3 is the only `new_task` in the flow. The orchestrator never uses
35
+ `switch_mode`.
36
+ - Steps 7 and 9 are `switch_mode` calls in the **same task window**.
37
+ Context is preserved across them.
38
+ - Step 11 is `attempt_completion`. It returns to the orchestrator, which
39
+ then halts in step 12.
40
+
41
+ ## End-to-end: free-form request
42
+
43
+ ```mermaid
44
+ sequenceDiagram
45
+ autonumber
46
+ actor User
47
+ participant O as 🪃 custom-orchestrator
48
+
49
+ User->>O: Tweak the README to mention Windows first.
50
+ O->>O: No explicit slash command
51
+ O->>O: Map to /tweak (or /update-docs)
52
+ O-->>User: Offers numbered choices: 1. Tweak README 2. Update docs
53
+ User->>O: 1
54
+ ```
55
+
56
+ After step 5 the flow continues exactly like the explicit case above.
57
+
58
+ ## Same-window vs delegated
59
+
60
+ | Primitive | Used by | When | Cost | Context |
61
+ | -------------------- | ------------------------------- | --------------------------------------------- | --------- | ----------- |
62
+ | `switch_mode` | architect ↔ tweaker | Tight loop inside one workflow | Cheap | Preserved |
63
+ | `new_task` | orchestrator → architect / tweaker | Top-level delegation of a workflow | Expensive | Fresh |
64
+ | `attempt_completion` | architect / tweaker → orchestrator | End of the command chain (final phase) | Free | Returns up |
65
+
66
+ The orchestrator only uses `new_task`. Modes only use `switch_mode` and
67
+ `attempt_completion`. Crossing those wires is a bug. `attempt_completion`
68
+ fires only after the command's final phase — mid-chain mode handoffs use
69
+ `switch_mode`.
70
+
71
+ ## Phase chains
72
+
73
+ Some commands are single-skill (`/tweak`, `/prototype`). Others chain
74
+ phases across modes. The composite chains are `/fix`, `/feature`, and
75
+ `/refactor`.
76
+
77
+ Helper commands are directly runnable in their documented mode because
78
+ their command files include `mode:` frontmatter. `/caveman` is intentionally
79
+ modeless because it changes communication style, not workflow authority.
80
+
81
+ Each composite command writes an unchecked phase checklist to `.scratch/`
82
+ at the start and updates it before every `switch_mode` or
83
+ `attempt_completion`. A worker must not `attempt_completion` while any
84
+ phase is still unchecked — it `switch_mode`s to the phase's owner instead.
85
+ This anchors the chain so a mid-chain mode does not mistake "this phase is
86
+ done" for "the command is done" after the command body scrolls out of
87
+ attention.
88
+
89
+ ### `/fix` chain
90
+
91
+ | Phase | Mode | Action | Hard stop? |
92
+ | ----- | --------- | ----------------------------------------------- | ----------------- |
93
+ | 1 | Architect | Diagnose phases 1–3, propose hypotheses | Yes — pick one |
94
+ | 2 | Architect | Diagnose phase 4, instrument chosen hypothesis | No |
95
+ | 3 | Tweaker | Implement fix, add/extend tests | No |
96
+ | 4 | Architect | Post-mortem; suggest `/refactor` if rot found | No |
97
+ | 5 | Tweaker | Suggest `/verify`, `/review`, then commit | Yes — user approval|
98
+
99
+ ### `/feature` chain
100
+
101
+ | Phase | Mode | Action | Hard stop? |
102
+ | ----- | --------- | --------------------------------------------------- | --------------------------- |
103
+ | 1 | Architect | Sharpen via `grill-with-docs`; update docs | Yes — Prototype or skip? |
104
+ | 2a | Tweaker | Prototype via `/prototype` (only if user picks it) | Yes — verdict on prototype |
105
+ | 3 | Architect | Build PRD via `to-prd` | Yes — ready to slice? |
106
+ | 4 | Architect | Slice into issues via `to-issues` | Yes — approve issue list |
107
+ | 5 | Tweaker | For each issue, run `/tdd`; suggest verify/review/commit | Yes — user approval per issue|
108
+
109
+ Hard stops are not optional. Removing them is the fastest way to make the
110
+ flow unsafe.
111
+
112
+ ## What the delegated message looks like
113
+
114
+ When the orchestrator hands work to a mode, the `new_task` message
115
+ contains, at minimum:
116
+
117
+ - the slash command, including the leading slash
118
+ - the user context
119
+ - a proceed policy
120
+ - a reminder to follow `.roo/rules/01-command-protocol.md`
121
+ - a reminder that skills live under `.roo/skills/...`
122
+ - a completion rule: finish the **whole command chain**, then end with
123
+ `attempt_completion` containing summary, files inspected/changed,
124
+ commands/tests run, blockers, and a recommended next command. Mid-chain
125
+ mode handoffs use `switch_mode`, not `attempt_completion`.
126
+
127
+ Command normalization is handled by `.roo/rules/01-command-protocol.md`,
128
+ not repeated in the delegated message.
129
+
130
+ For non-trivial implementation, the recommended follow-up chain is
131
+ `/verify` -> `/review` -> `/commit-and-document`. This is a suggestion,
132
+ not authorization: workers and the orchestrator must not auto-launch those
133
+ commands merely because they were mentioned.
@@ -0,0 +1,86 @@
1
+ # Comparison and positioning
2
+
3
+ A few projects in the agentic-coding space share vocabulary with Zoo
4
+ Flow — "skills", "agents", "commands". They are doing different things.
5
+ This page is meant to make the differences clear so you can pick the
6
+ right tool for the job.
7
+
8
+ ## Short version
9
+
10
+ - **Superpowers** is a broad methodology and skills library. The center
11
+ of gravity is the *skills*: a large, well-curated collection of named
12
+ techniques the agent can pull in.
13
+ - **ECC (Extended Coding Companion / "extended coding context")** is a
14
+ large agent harness. The center of gravity is the *runtime*: a rich
15
+ agent loop, memory, and tooling stack.
16
+ - **Zoo Flow** is a Zoo Code-native workflow control plane. It focuses
17
+ on mode-safe delegation, slash-command routing, and path-safe skill
18
+ loading. The center of gravity is the
19
+ *contract*: three modes, a routing matrix, a command protocol, and a
20
+ path-safety guarantee.
21
+
22
+ These projects are complementary more than competitive. You can run a
23
+ broad skills library inside Zoo Flow's three-mode contract, and you can
24
+ plug Zoo Flow's commands into a richer harness if you have one.
25
+
26
+ ## What Zoo Flow is not
27
+
28
+ - It is not a replacement for a methodology like Superpowers. If you
29
+ want a long, opinionated guide to *how to think* about agentic
30
+ coding, look there.
31
+ - It is not a runtime. Zoo Flow runs inside Zoo Code; it does not ship
32
+ its own agent loop, memory store, or tool registry.
33
+ - It is not a giant skills pack. The bundled skills are a starting
34
+ point. The control plane is the product.
35
+
36
+ ## What Zoo Flow is
37
+
38
+ - A `.roomodes` file that defines three custom modes with deliberate
39
+ tool-group boundaries.
40
+ - A handful of always-on rules: path safety, command protocol,
41
+ three-failure guardrail, manual reply safety, and context economy.
42
+ - A directory layout for slash commands and on-demand skills.
43
+
44
+ If you only adopt one piece of Zoo Flow, adopt the path-safety rule and
45
+ the command protocol. Those two files alone fix most of the "agent
46
+ hallucinated a path" problems.
47
+
48
+ ## When to pick Zoo Flow
49
+
50
+ - You are using Zoo Code as your primary host.
51
+ - You want a small, validated control plane more than a big skill set.
52
+ - You care about the mode boundary between planning and implementation.
53
+ - You want explicit human-in-the-loop checkpoints in multi-phase flows
54
+ like `/fix` and `/feature`.
55
+
56
+ ## When to pick something else
57
+
58
+ - You want a comprehensive methodology and a broad skill set out of the
59
+ box. Superpowers and similar projects are a better fit.
60
+ - You are not on Zoo Code and you do not plan to be. Zoo Flow leans on
61
+ `customModes`, `run_slash_command`, `new_task`, and `switch_mode`
62
+ semantics from that host.
63
+ - You want a full agent runtime with its own loop and memory layer.
64
+ ECC-style harnesses are aimed at that.
65
+
66
+ ## Working alongside other projects
67
+
68
+ Zoo Flow plays well with broader skills libraries. The skills under
69
+ `templates/full/.roo/skills/` follow a standard `SKILL.md` format and
70
+ are loaded by command. If you want to bring in a skill from another
71
+ project, drop it under the right bucket, add a one-line entry to the
72
+ bucket `README.md` and to `docs/skills-index.md`, and reference it from
73
+ a command file. The control plane does not care where the skill came
74
+ from.
75
+
76
+ The opposite direction works too: if you want to take just the modes
77
+ and the command protocol into a different setup, that is two files
78
+ (`.roomodes` and `01-command-protocol.md`) plus the path-safety rule
79
+ (`00-paths.md`).
80
+
81
+ ## Respect
82
+
83
+ The projects mentioned here are the work of people who care about this
84
+ problem space. Zoo Flow exists because their work raised the bar.
85
+ Where Zoo Flow disagrees with them, it disagrees on tradeoffs, not on
86
+ intent.