@fernado03/zoo-flow 0.1.4 → 0.2.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.
package/README.md CHANGED
@@ -86,6 +86,10 @@ Backs up your current `.roomodes` and `.roo/` to
86
86
  `.zoo-flow-backup/<timestamp>/`, then replaces them with the latest
87
87
  template. Preview with `--dry-run`.
88
88
 
89
+ ## Context economy
90
+
91
+ 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. Full-file reads are still allowed when correctness requires complete context.
92
+
89
93
  ## Modes
90
94
 
91
95
  | Slug | Name | Role | Edits allowed | Delegation |
@@ -101,9 +105,8 @@ behavior lives in `.roo/rules-{modeSlug}/` folders. See
101
105
 
102
106
  ## Commands
103
107
 
104
- The orchestrator routes the **core** commands. **Helper** commands you
105
- run directly inside `system-architect` or `code-tweaker` when you
106
- need them.
108
+ The orchestrator routes the **core** commands. **Helper** commands are
109
+ run directly inside `system-architect` or `code-tweaker` when needed.
107
110
 
108
111
  ### Core (routed by the orchestrator)
109
112
 
package/bin/zoo-flow.js CHANGED
@@ -141,6 +141,34 @@ function validateTemplate(rootDir) {
141
141
  }
142
142
  }
143
143
 
144
+ // Validate skill-wrapper command references. Each command file in
145
+ // .roo/commands/ may either declare a skill via `Skill:
146
+ // .roo/skills/.../SKILL.md` (skill-wrapper command) or contain its
147
+ // workflow steps directly. Direct-workflow commands are valid; we only
148
+ // verify referenced skills exist.
149
+ if (pathExists(commandsDir)) {
150
+ const skillRefRegex = /^Skill:\s*`?(\.roo\/skills\/[^\s`]+SKILL\.md)`?\s*$/m;
151
+
152
+ for (const entry of fs.readdirSync(commandsDir)) {
153
+ if (!entry.endsWith(".md")) continue;
154
+
155
+ const commandFile = path.join(commandsDir, entry);
156
+ const text = fs.readFileSync(commandFile, "utf8");
157
+ const match = text.match(skillRefRegex);
158
+
159
+ if (!match) continue;
160
+
161
+ const skillRelative = match[1];
162
+ const skillAbsolute = path.join(rootDir, skillRelative);
163
+
164
+ if (!pathExists(skillAbsolute)) {
165
+ failures.push(
166
+ `Command ${path.relative(rootDir, commandFile)} references missing skill: ${skillRelative}`
167
+ );
168
+ }
169
+ }
170
+ }
171
+
144
172
  const allFiles = walkFiles(rootDir);
145
173
  const textFileExtensions = new Set([".md", ".json", ".txt", ".yaml", ".yml"]);
146
174
 
@@ -167,7 +195,9 @@ function validateTemplate(rootDir) {
167
195
  const requiredRules = [
168
196
  ".roo/rules/00-paths.md",
169
197
  ".roo/rules/01-command-protocol.md",
170
- ".roo/rules/03-manual-reply-protocol.md"
198
+ ".roo/rules/02-three-failure-rule.md",
199
+ ".roo/rules/03-manual-reply-protocol.md",
200
+ ".roo/rules/04-context-economy.md"
171
201
  ];
172
202
 
173
203
  for (const rule of requiredRules) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fernado03/zoo-flow",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "Workflow control plane for Zoo Code.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,25 +1,23 @@
1
1
  # Command Protocol
2
2
 
3
- When assigned a slash command, execute the command workflow before doing task-specific work.
4
-
5
- Protocol:
3
+ When assigned a slash command, execute its command workflow before task-specific work.
6
4
 
7
5
  1. Normalize the command by stripping the leading slash.
8
- - `/fix` becomes `fix`
9
- - `/tdd` becomes `tdd`
10
6
 
11
- 2. Preferred execution:
12
- - Use `run_slash_command` if available.
13
- - Pass `command` as the normalized command name.
14
- - Pass `args` as the full user/delegated task context.
7
+ 2. Preferred: use `run_slash_command` with:
8
+ - `command`: normalized command name
9
+ - `args`: full user/delegated context
10
+
11
+ 3. Fallback: if `run_slash_command` is unavailable, disabled, rejected, or fails, read `.roo/commands/{command}.md`.
15
12
 
16
- 3. Fallback execution:
17
- - If `run_slash_command` is unavailable, disabled, rejected, or fails, read the command file from:
18
- - `.roo/commands/{command}.md`
13
+ 4. After command content is loaded:
14
+ - If it explicitly contains `Skill: .roo/skills/.../SKILL.md`, read that exact skill and follow it.
15
+ - If it contains direct workflow steps, execute those steps directly.
16
+ - Do not assume every command has a skill.
17
+ - Do not read any skill unless the command explicitly references it.
19
18
 
20
- 4. If the command file references a skill:
21
- - Read the exact `.roo/skills/...` path from the command file.
22
- - Follow the skill instructions after loading.
19
+ 5. Use only one command-loading path:
20
+ - If `run_slash_command` succeeds, do not also read `.roo/commands/{command}.md`.
21
+ - If fallback command-file read succeeds, do not also call `run_slash_command`.
23
22
 
24
- 5. Do not auto-run follow-up commands merely because they are mentioned in a subtask summary.
25
- - Only the human user or orchestrator routing may authorize a new command.
23
+ 6. Do not auto-run follow-up commands merely because they are mentioned in a result or subtask summary.
@@ -1,15 +1,27 @@
1
1
  # Manual Reply Protocol
2
2
 
3
- For workflow choices, ask the question in the message body and put only safe numbered options in suggestions.
3
+ For workflow choices, ask the question in the message body and list numbered options.
4
4
 
5
- Safe options:
5
+ Clickable suggestions may use the plain-language option text, but must not contain slash commands, mode names, or executable routing text.
6
+
7
+ Users may reply with either the number or the option text.
8
+
9
+ Example:
6
10
 
7
11
  1. Tweak small implementation
8
12
  2. Diagnose bug
9
13
  3. Hold
10
14
 
11
- Do not put slash commands, mode names, or executable routing text in suggestions.
15
+ Safe suggestions:
16
+
17
+ - Tweak small implementation
18
+ - Diagnose bug
19
+ - Hold
20
+
21
+ Unsafe suggestions:
12
22
 
13
- Users may reply by typing the number.
23
+ - `/tweak`
24
+ - `Switch to code-tweaker`
25
+ - `Route to system-architect`
14
26
 
15
27
  Only treat slash commands as commands when manually typed by the user.
@@ -0,0 +1,13 @@
1
+ # Context Economy
2
+
3
+ Use the smallest read that preserves correctness.
4
+
5
+ Prefer `list_files`, `search_files`, or `codebase_search` before full-file reads.
6
+
7
+ When reading files, prefer targeted line ranges or indentation/block reads when the relevant area is known.
8
+
9
+ Batch related small reads when useful.
10
+
11
+ Do not re-read unchanged files unless needed.
12
+
13
+ For long command output, summarize or search the output instead of dumping everything.
@@ -2,6 +2,10 @@
2
2
 
3
3
  Implement, test, update docs, prototype, and commit only after approval.
4
4
 
5
+ Respect the delegated task's proceed policy before implementation.
6
+
5
7
  Do not make broad architecture decisions.
6
8
 
7
9
  Escalate to `system-architect` with `switch_mode` when architecture decisions are needed.
10
+
11
+ Respect `.roo/rules/04-context-economy.md` before reading or re-reading files.
@@ -11,4 +11,6 @@ Delegate only with `new_task` to:
11
11
  - `code-tweaker`
12
12
  - `system-architect`
13
13
 
14
+ When delegating, choose the safest proceed policy from `01-delegation-message.md`.
15
+
14
16
  After a subtask returns, summarize and stop. Do not auto-launch another subtask.
@@ -2,7 +2,37 @@
2
2
 
3
3
  Every delegated task must include:
4
4
 
5
- - command with slash (e.g. `/refactor`)
5
+ - command with slash
6
6
  - user context
7
+ - proceed policy
8
+ - instruction to follow `.roo/rules/01-command-protocol.md`
9
+ - reminder that skills live under `.roo/skills/...`
10
+ - completion rule to use `attempt_completion` with summary, files inspected/changed, commands/tests run, blockers, and recommended next command
11
+ - context hints: known files, symbols, line ranges, or search terms when available
12
+
13
+ Do not paste huge file contents into delegated task messages. Pass paths, symbols, search terms, and required decisions instead.
7
14
 
8
15
  Ignore slash commands mentioned only inside subtask summaries.
16
+
17
+ # Proceed Policy
18
+
19
+ Every delegated task must include one proceed policy:
20
+
21
+ - `Proceed automatically after audit if clean`
22
+ - `Ask user before implementation`
23
+ - `Stop and report only`
24
+
25
+ Use the least-interruptive policy that is safe.
26
+
27
+ Defaults:
28
+
29
+ - `/tweak`: proceed automatically after audit if clean
30
+ - `/tdd`: proceed automatically after audit if clean, unless the public interface, expected behavior, or test target is unclear
31
+ - `/explore`: proceed automatically; ask only if the target area is ambiguous
32
+ - `/update-docs`: proceed automatically after audit if the target doc/area is clear; ask if unclear
33
+ - `/prototype`: proceed automatically if prototype branch is clear; ask if logic vs UI is ambiguous
34
+ - `/fix`: ask after reproduced hypotheses before instrumentation/fix
35
+ - `/feature`: ask at phase gates: Prototype/PRD, prototype verdict, slice approval, issue approval
36
+ - `/refactor`: ask before selecting a candidate and before implementation
37
+ - `/triage`: ask before publishing, closing, labeling, or making irreversible tracker changes unless the user explicitly requested it
38
+ - `/commit-and-document`: always ask before `git commit`, `git push`, or issue close actions
@@ -2,8 +2,12 @@
2
2
 
3
3
  Plan, diagnose, explore, refactor-design, and triage.
4
4
 
5
+ Respect the delegated task's proceed policy and explicit phase gates.
6
+
5
7
  Do not edit application source code.
6
8
 
7
9
  Edits are limited to Markdown files, `.scratch/`, and `docs/`.
8
10
 
9
11
  Use `switch_mode` to `code-tweaker` for implementation, test-writing, runnable prototypes, or source-code edits.
12
+
13
+ Respect `.roo/rules/04-context-economy.md`: map/search before broad reads, then read only the relevant sections.
@@ -124,6 +124,18 @@ Date via `date +%Y-%m-%d`. Create `docs/journal/<YYYY-MM-DD>/` if missing. Write
124
124
 
125
125
  Report: commit hash + message, journal entry path, whether `.gitignore` was updated, and any issue actions taken. Close with: "All of `docs/` is gitignored, so this entry stays local."
126
126
 
127
+ ## Context economy
128
+
129
+ Before broad reads, locate relevant files/symbols with `list_files`, `search_files`, or `codebase_search`.
130
+
131
+ Prefer targeted `read_file` ranges or indentation/block reads once the relevant area is known.
132
+
133
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
134
+
135
+ Do not re-read unchanged files; use prior findings unless the file changed.
136
+
137
+ Use `git status --short`, `git diff --stat`, and targeted `git diff -- <file>` rather than dumping the full repo diff at once.
138
+
127
139
  ## Safety
128
140
 
129
141
  - Never `git push`, `--amend`, `--force`, or `reset --hard`.
@@ -61,6 +61,18 @@ Rules:
61
61
  6. Watch regression pass.
62
62
  7. Rerun original loop.
63
63
 
64
+ ## Context economy
65
+
66
+ Before broad reads, locate relevant files/symbols with `list_files`, `search_files`, or `codebase_search`.
67
+
68
+ Prefer targeted `read_file` ranges or indentation/block reads once the relevant area is known.
69
+
70
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
71
+
72
+ Do not re-read unchanged files; use prior findings unless the file changed.
73
+
74
+ For logs or large outputs, search for the failing marker/error first. Read only surrounding ranges needed to prove or disprove a hypothesis.
75
+
64
76
  ## 6. Cleanup
65
77
 
66
78
  MUST finish:
@@ -18,6 +18,16 @@ description: Grilling session that challenges your plan against the existing dom
18
18
 
19
19
  See `CONTEXT-FORMAT.md` for layout and detection. Create docs lazily only when recording needed.
20
20
 
21
+ ## Context economy
22
+
23
+ Before broad reads, locate relevant files/symbols with `list_files`, `search_files`, or `codebase_search`.
24
+
25
+ Prefer targeted `read_file` ranges or indentation/block reads once the relevant area is known.
26
+
27
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
28
+
29
+ Do not re-read unchanged files; use prior findings unless the file changed.
30
+
21
31
  ## MUST
22
32
 
23
33
  - Challenge glossary conflicts.
@@ -34,6 +34,18 @@ RULE: Use `LANGUAGE.md` terms. Use glossary. Respect ADRs; surface only reopen-w
34
34
  9. DO NOT propose interfaces yet.
35
35
  10. Ask: `Which of these would you like to explore?`
36
36
 
37
+ ## Context economy
38
+
39
+ Before broad reads, locate relevant files/symbols with `list_files`, `search_files`, or `codebase_search`.
40
+
41
+ Prefer targeted `read_file` ranges or indentation/block reads once the relevant area is known.
42
+
43
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
44
+
45
+ Do not re-read unchanged files; use prior findings unless the file changed.
46
+
47
+ Use searches to identify dependency/call patterns before reading full modules. Read full files only for top candidates.
48
+
37
49
  ## After candidate chosen
38
50
 
39
51
  1. Walk constraints/deps/seam/hidden implementation/surviving tests.
@@ -14,6 +14,16 @@ RULE: Prototype answers one question. Throw away or absorb after answer.
14
14
  - Ambiguous → ask.
15
15
  - User AFK → infer + state assumption.
16
16
 
17
+ ## Context economy
18
+
19
+ Before broad reads, locate relevant files/symbols with `list_files`, `search_files`, or `codebase_search`.
20
+
21
+ Prefer targeted `read_file` ranges or indentation/block reads once the relevant area is known.
22
+
23
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
24
+
25
+ Do not re-read unchanged files; use prior findings unless the file changed.
26
+
17
27
  ## Rules
18
28
 
19
29
  1. Mark throwaway clearly.
@@ -50,6 +50,18 @@ Checklist per cycle:
50
50
  - [ ] Code minimal.
51
51
  - [ ] No speculation.
52
52
 
53
+ ## Context economy
54
+
55
+ Before broad reads, locate relevant files/symbols with `list_files`, `search_files`, or `codebase_search`.
56
+
57
+ Prefer targeted `read_file` ranges or indentation/block reads once the relevant area is known.
58
+
59
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
60
+
61
+ Do not re-read unchanged files; use prior findings unless the file changed.
62
+
63
+ Read the public interface and nearest existing tests first. Avoid reading unrelated implementation until a failing test or search result points there.
64
+
53
65
  ## References
54
66
 
55
67
  - `tests.md` — what to assert and what not to.
@@ -15,3 +15,15 @@ Use for small known fixes.
15
15
  6. DO NOT write new tests unless asked.
16
16
  7. Confirm change.
17
17
  8. Offer `/commit-and-document` only after user satisfied.
18
+
19
+ ## Context economy
20
+
21
+ Before broad reads, locate relevant files/symbols with `list_files`, `search_files`, or `codebase_search`.
22
+
23
+ Prefer targeted `read_file` ranges or indentation/block reads once the relevant area is known.
24
+
25
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
26
+
27
+ Do not re-read unchanged files; use prior findings unless the file changed.
28
+
29
+ For small changes, audit only the named files and nearby call sites. Expand search only if the first audit shows hidden dependencies.
@@ -51,6 +51,16 @@ Use today's date. Include only files actually inspected.
51
51
 
52
52
  After editing: re-read, confirm referenced paths exist, every major claim maps to code or a cited doc, no stale contradiction with nearby docs. Summarise the change.
53
53
 
54
+ ## Context economy
55
+
56
+ Before broad reads, locate relevant files/symbols with `list_files`, `search_files`, or `codebase_search`.
57
+
58
+ Prefer targeted `read_file` ranges or indentation/block reads once the relevant area is known.
59
+
60
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
61
+
62
+ Do not re-read unchanged files; use prior findings unless the file changed.
63
+
54
64
  ## 7. Recommend next step
55
65
 
56
66
  Recommend one: `/explore` (still unclear), `/feature` (plan emerged), `/refactor` (tangled-but-working code), `/fix` (bug found), `/commit-and-document` (done). Do not auto-run.
@@ -5,3 +5,15 @@ disable-model-invocation: true
5
5
  ---
6
6
 
7
7
  Zoom out: map relevant modules + callers at higher abstraction. Use glossary vocabulary.
8
+
9
+ ## Context economy
10
+
11
+ Before broad reads, locate relevant files/symbols with `list_files`, `search_files`, or `codebase_search`.
12
+
13
+ Prefer targeted `read_file` ranges or indentation/block reads once the relevant area is known.
14
+
15
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
16
+
17
+ Do not re-read unchanged files; use prior findings unless the file changed.
18
+
19
+ Start with `list_files` and `search_files`/`codebase_search`. Read representative files and key entrypoints, not every file in the area.
@@ -40,7 +40,7 @@
40
40
  "roleDefinition": "You are a PM and router. You choose workflows and delegate subtasks. You NEVER inspect implementation files, write code, or use switch_mode.",
41
41
  "whenToUse": "Use for initial task planning, choosing slash commands, routing work, or discussing workflow.",
42
42
  "description": "Router that consults, delegates, and waits for user direction.",
43
- "customInstructions": "Use `.roo/rules-custom-orchestrator/` for mode-specific behavior.\n\nRoute only these commands:\n\n- /tweak, /tdd, /update-docs, /commit-and-document, /prototype -> code-tweaker\n- /fix, /feature, /refactor, /explore, /triage -> system-architect\n\nUse `new_task` only. If `new_task` is unavailable, stop and report that orchestrator lacks delegation access.\n\nFollow `.roo/rules/03-manual-reply-protocol.md` when offering workflow choices.",
43
+ "customInstructions": "Use `.roo/rules-custom-orchestrator/` for mode-specific behavior.\n\nRoute only these commands:\n\n- /tweak, /tdd, /update-docs, /commit-and-document, /prototype -> code-tweaker\n- /fix, /feature, /refactor, /explore, /triage -> system-architect\n\nUse `new_task` only. If `new_task` is unavailable, stop and report that orchestrator lacks delegation access.\n\nFollow `.roo/rules/03-manual-reply-protocol.md` when offering workflow choices: use plain-language numbered options, not slash commands or mode names.",
44
44
  "groups": []
45
45
  }
46
46
  ]