maestro-flow 0.3.37 → 0.3.39

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 (186) hide show
  1. package/.claude/agents/workflow-analyzer.md +2 -0
  2. package/.claude/agents/workflow-debugger.md +2 -0
  3. package/.claude/agents/workflow-executor.md +2 -0
  4. package/.claude/agents/workflow-integration-checker.md +1 -0
  5. package/.claude/agents/workflow-nyquist-auditor.md +1 -0
  6. package/.claude/agents/workflow-planner.md +2 -0
  7. package/.claude/agents/workflow-reviewer.md +2 -0
  8. package/.claude/agents/workflow-verifier.md +2 -0
  9. package/.claude/commands/learn-decompose.md +176 -176
  10. package/.claude/commands/learn-follow.md +167 -167
  11. package/.claude/commands/learn-investigate.md +221 -221
  12. package/.claude/commands/learn-retro.md +303 -303
  13. package/.claude/commands/learn-second-opinion.md +167 -167
  14. package/.claude/commands/maestro-amend.md +300 -300
  15. package/.claude/commands/maestro-analyze.md +126 -126
  16. package/.claude/commands/maestro-brainstorm.md +100 -100
  17. package/.claude/commands/maestro-composer.md +354 -354
  18. package/.claude/commands/maestro-execute.md +120 -114
  19. package/.claude/commands/maestro-fork.md +86 -86
  20. package/.claude/commands/maestro-init.md +78 -78
  21. package/.claude/commands/maestro-learn.md +140 -140
  22. package/.claude/commands/maestro-link-coordinate.md +1 -1
  23. package/.claude/commands/maestro-merge.md +61 -61
  24. package/.claude/commands/maestro-milestone-release.md +96 -96
  25. package/.claude/commands/maestro-overlay.md +178 -178
  26. package/.claude/commands/maestro-plan.md +150 -138
  27. package/.claude/commands/maestro-player.md +404 -404
  28. package/.claude/commands/maestro-quick.md +56 -56
  29. package/.claude/commands/maestro-ralph-execute.md +7 -18
  30. package/.claude/commands/maestro-ralph.md +9 -3
  31. package/.claude/commands/maestro-roadmap.md +1 -1
  32. package/.claude/commands/maestro-ui-design.md +93 -93
  33. package/.claude/commands/maestro-update.md +176 -176
  34. package/.claude/commands/maestro-verify.md +96 -90
  35. package/.claude/commands/maestro.md +121 -121
  36. package/.claude/commands/manage-codebase-rebuild.md +75 -75
  37. package/.claude/commands/manage-codebase-refresh.md +57 -57
  38. package/.claude/commands/manage-harvest.md +94 -94
  39. package/.claude/commands/manage-issue-discover.md +77 -77
  40. package/.claude/commands/manage-issue.md +73 -73
  41. package/.claude/commands/manage-knowhow-capture.md +193 -193
  42. package/.claude/commands/manage-knowhow.md +77 -77
  43. package/.claude/commands/manage-learn.md +67 -67
  44. package/.claude/commands/manage-status.md +51 -51
  45. package/.claude/commands/manage-wiki.md +62 -62
  46. package/.claude/commands/quality-auto-test.md +1 -1
  47. package/.claude/commands/quality-debug.md +121 -115
  48. package/.claude/commands/quality-refactor.md +55 -55
  49. package/.claude/commands/quality-retrospective.md +78 -78
  50. package/.claude/commands/quality-review.md +114 -108
  51. package/.claude/commands/quality-sync.md +51 -51
  52. package/.claude/commands/quality-test.md +103 -103
  53. package/.claude/commands/spec-add.md +49 -49
  54. package/.claude/commands/spec-load.md +51 -51
  55. package/.claude/commands/spec-remove.md +51 -51
  56. package/.claude/commands/spec-setup.md +51 -51
  57. package/.claude/commands/wiki-connect.md +62 -62
  58. package/.claude/commands/wiki-digest.md +69 -69
  59. package/.codex/skills/learn-decompose/SKILL.md +113 -113
  60. package/.codex/skills/learn-follow/SKILL.md +1 -1
  61. package/.codex/skills/learn-investigate/SKILL.md +83 -83
  62. package/.codex/skills/learn-retro/SKILL.md +83 -83
  63. package/.codex/skills/learn-second-opinion/SKILL.md +86 -86
  64. package/.codex/skills/maestro/SKILL.md +304 -304
  65. package/.codex/skills/maestro-analyze/SKILL.md +9 -8
  66. package/.codex/skills/maestro-brainstorm/SKILL.md +442 -397
  67. package/.codex/skills/maestro-composer/SKILL.md +213 -213
  68. package/.codex/skills/maestro-execute/SKILL.md +346 -318
  69. package/.codex/skills/maestro-fork/SKILL.md +56 -2
  70. package/.codex/skills/maestro-init/SKILL.md +40 -16
  71. package/.codex/skills/maestro-learn/SKILL.md +80 -80
  72. package/.codex/skills/maestro-link-coordinate/SKILL.md +257 -257
  73. package/.codex/skills/maestro-merge/SKILL.md +1 -1
  74. package/.codex/skills/maestro-milestone-audit/SKILL.md +1 -1
  75. package/.codex/skills/maestro-milestone-complete/SKILL.md +40 -9
  76. package/.codex/skills/maestro-milestone-release/SKILL.md +70 -70
  77. package/.codex/skills/maestro-overlay/SKILL.md +1 -1
  78. package/.codex/skills/maestro-plan/SKILL.md +19 -4
  79. package/.codex/skills/maestro-player/SKILL.md +323 -323
  80. package/.codex/skills/maestro-quick/SKILL.md +1 -1
  81. package/.codex/skills/maestro-ralph/SKILL.md +681 -578
  82. package/.codex/skills/maestro-roadmap/SKILL.md +518 -468
  83. package/.codex/skills/maestro-ui-design/SKILL.md +109 -12
  84. package/.codex/skills/maestro-verify/SKILL.md +27 -9
  85. package/.codex/skills/manage-codebase-rebuild/SKILL.md +3 -2
  86. package/.codex/skills/manage-codebase-refresh/SKILL.md +1 -1
  87. package/.codex/skills/manage-harvest/SKILL.md +91 -91
  88. package/.codex/skills/manage-issue/SKILL.md +19 -6
  89. package/.codex/skills/manage-issue-discover/SKILL.md +1 -1
  90. package/.codex/skills/manage-knowhow/SKILL.md +95 -95
  91. package/.codex/skills/manage-knowhow-capture/SKILL.md +110 -110
  92. package/.codex/skills/manage-learn/SKILL.md +1 -1
  93. package/.codex/skills/manage-status/SKILL.md +1 -1
  94. package/.codex/skills/manage-wiki/SKILL.md +55 -55
  95. package/.codex/skills/quality-auto-test/SKILL.md +547 -547
  96. package/.codex/skills/quality-debug/SKILL.md +339 -334
  97. package/.codex/skills/quality-refactor/SKILL.md +1 -1
  98. package/.codex/skills/quality-retrospective/SKILL.md +292 -292
  99. package/.codex/skills/quality-review/SKILL.md +365 -364
  100. package/.codex/skills/quality-sync/SKILL.md +1 -1
  101. package/.codex/skills/quality-test/SKILL.md +498 -498
  102. package/.codex/skills/spec-add/SKILL.md +101 -101
  103. package/.codex/skills/spec-load/SKILL.md +77 -77
  104. package/.codex/skills/spec-map/SKILL.md +1 -1
  105. package/.codex/skills/spec-remove/SKILL.md +69 -69
  106. package/.codex/skills/spec-setup/SKILL.md +1 -1
  107. package/.codex/skills/team-coordinate/SKILL.md +2 -1
  108. package/.codex/skills/team-executor/SKILL.md +116 -115
  109. package/.codex/skills/team-lifecycle-v4/SKILL.md +2 -1
  110. package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +14 -6
  111. package/.codex/skills/team-lifecycle-v4/roles/analyst/role.md +16 -4
  112. package/.codex/skills/team-lifecycle-v4/roles/executor/commands/implement.md +7 -1
  113. package/.codex/skills/team-lifecycle-v4/roles/planner/role.md +16 -4
  114. package/.codex/skills/team-lifecycle-v4/roles/writer/role.md +8 -2
  115. package/.codex/skills/team-quality-assurance/SKILL.md +2 -1
  116. package/.codex/skills/team-quality-assurance/roles/scout/role.md +9 -2
  117. package/.codex/skills/team-review/SKILL.md +2 -1
  118. package/.codex/skills/team-review/roles/reviewer/role.md +10 -1
  119. package/.codex/skills/team-review/roles/scanner/role.md +10 -1
  120. package/.codex/skills/team-tech-debt/SKILL.md +144 -143
  121. package/.codex/skills/team-tech-debt/roles/executor/role.md +9 -5
  122. package/.codex/skills/team-tech-debt/roles/scanner/role.md +10 -0
  123. package/.codex/skills/team-tech-debt/roles/validator/role.md +8 -2
  124. package/.codex/skills/team-testing/SKILL.md +2 -1
  125. package/.codex/skills/team-testing/roles/executor/role.md +8 -2
  126. package/.codex/skills/team-testing/roles/generator/role.md +8 -2
  127. package/.codex/skills/wiki-connect/SKILL.md +73 -73
  128. package/.codex/skills/wiki-digest/SKILL.md +87 -87
  129. package/README.md +6 -0
  130. package/README.zh-CN.md +6 -0
  131. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js +4 -0
  132. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js.map +1 -1
  133. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js +118 -7
  134. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js.map +1 -1
  135. package/dashboard/dist-server/shared/agent-types.d.ts +2 -0
  136. package/dashboard/dist-server/src/agents/cli-agent-runner.d.ts +2 -0
  137. package/dashboard/dist-server/src/agents/cli-agent-runner.js +4 -0
  138. package/dashboard/dist-server/src/agents/cli-agent-runner.js.map +1 -1
  139. package/dashboard/dist-server/src/commands/delegate.d.ts +2 -0
  140. package/dashboard/dist-server/src/commands/delegate.js +18 -0
  141. package/dashboard/dist-server/src/commands/delegate.js.map +1 -1
  142. package/dashboard/dist-server/src/config/cli-tools-config.d.ts +6 -0
  143. package/dashboard/dist-server/src/config/cli-tools-config.js +2 -0
  144. package/dashboard/dist-server/src/config/cli-tools-config.js.map +1 -1
  145. package/dist/shared/agent-types.d.ts +2 -0
  146. package/dist/shared/agent-types.d.ts.map +1 -1
  147. package/dist/src/agents/cli-agent-runner.d.ts +2 -0
  148. package/dist/src/agents/cli-agent-runner.d.ts.map +1 -1
  149. package/dist/src/agents/cli-agent-runner.js +4 -0
  150. package/dist/src/agents/cli-agent-runner.js.map +1 -1
  151. package/dist/src/commands/config.d.ts.map +1 -1
  152. package/dist/src/commands/config.js +29 -1
  153. package/dist/src/commands/config.js.map +1 -1
  154. package/dist/src/commands/delegate.d.ts +2 -0
  155. package/dist/src/commands/delegate.d.ts.map +1 -1
  156. package/dist/src/commands/delegate.js +18 -0
  157. package/dist/src/commands/delegate.js.map +1 -1
  158. package/dist/src/commands/launcher.d.ts.map +1 -1
  159. package/dist/src/commands/launcher.js +27 -4
  160. package/dist/src/commands/launcher.js.map +1 -1
  161. package/dist/src/config/cli-tools-config.d.ts +6 -0
  162. package/dist/src/config/cli-tools-config.d.ts.map +1 -1
  163. package/dist/src/config/cli-tools-config.js +2 -0
  164. package/dist/src/config/cli-tools-config.js.map +1 -1
  165. package/dist/src/core/overlay/applier.d.ts.map +1 -1
  166. package/dist/src/core/overlay/applier.js +65 -5
  167. package/dist/src/core/overlay/applier.js.map +1 -1
  168. package/dist/src/core/overlay/loader.d.ts.map +1 -1
  169. package/dist/src/core/overlay/loader.js +9 -4
  170. package/dist/src/core/overlay/loader.js.map +1 -1
  171. package/dist/src/core/overlay/types.d.ts +2 -0
  172. package/dist/src/core/overlay/types.d.ts.map +1 -1
  173. package/dist/src/core/overlay/types.js +2 -0
  174. package/dist/src/core/overlay/types.js.map +1 -1
  175. package/dist/src/tui/tools-ui/ToolsDashboard.d.ts.map +1 -1
  176. package/dist/src/tui/tools-ui/ToolsDashboard.js +1 -1
  177. package/dist/src/tui/tools-ui/ToolsDashboard.js.map +1 -1
  178. package/dist/src/tui/tools-ui/ToolsOverview.d.ts.map +1 -1
  179. package/dist/src/tui/tools-ui/ToolsOverview.js +51 -4
  180. package/dist/src/tui/tools-ui/ToolsOverview.js.map +1 -1
  181. package/package.json +1 -1
  182. package/shared/agent-types.ts +2 -0
  183. package/workflows/delegate-protocol.codex.md +65 -0
  184. package/workflows/issue-analyze.md +2 -3
  185. package/workflows/issue-gaps-analyze.codex.md +260 -0
  186. package/workflows/issue-gaps-analyze.md +214 -0
@@ -1,167 +1,167 @@
1
- ---
2
- name: learn-follow
3
- description: Guided follow-along reading of code or wiki entries, extracting patterns and building understanding
4
- argument-hint: "<path|wiki-id|topic> [--depth shallow|deep] [--save-wiki]"
5
- allowed-tools:
6
- - Read
7
- - Write
8
- - Bash
9
- - Glob
10
- - Grep
11
- - Agent
12
- - AskUserQuestion
13
- ---
14
- <purpose>
15
- Guided reading experience for code files, wiki entries, or topics. Instead of just reading code, this command walks through content section by section using forcing questions (inspired by gstack `/office-hours` brainstorming) to extract patterns, identify assumptions, and build a structured understanding map.
16
-
17
- Outputs reading notes with extracted patterns, open questions, and connection points. Insights persist to `lessons.jsonl` and optionally become wiki note entries for the knowledge graph.
18
- </purpose>
19
-
20
- <context>
21
- Arguments: $ARGUMENTS
22
-
23
- **Target resolution (auto-detected from first argument):**
24
- - File path (e.g., `src/commands/wiki.ts`) → Read source file
25
- - Wiki ID (e.g., `spec-auth`, `phase-planning`) → Fetch via `maestro wiki get`
26
- - Topic string (e.g., `"authentication flow"`) → Search via `maestro wiki search`, use top result
27
-
28
- **Flags:**
29
- - `--depth shallow` — Quick pass: key patterns and structure only (default)
30
- - `--depth deep` — Thorough: every function, every branch, every assumption
31
- - `--save-wiki` — Create a wiki note entry with the reading notes via `maestro wiki create --type note`
32
-
33
- **Storage written:**
34
- - `.workflow/learning/follow-{slug}-{YYYY-MM-DD}.md` — Reading notes with understanding map
35
- - `.workflow/learning/lessons.jsonl` — Appended pattern/technique insights
36
- - `.workflow/learning/learning-index.json` — Updated index
37
- - If `--save-wiki`: new wiki note entry
38
-
39
- **Storage read:**
40
- - Target source file or wiki entry
41
- - `maestro wiki backlinks <id>` / `maestro wiki forward <id>` — Relationship context
42
- - `.workflow/specs/coding-conventions.md` — Convention reference for pattern matching
43
- - `.workflow/learning/lessons.jsonl` — Prior insights for dedup and cross-reference
44
- </context>
45
-
46
- <execution>
47
-
48
- ### Stage 1: Resolve Target
49
- - If argument looks like a file path (contains `/` or `\`, or matches a glob): verify file exists via Read
50
- - If argument matches wiki ID pattern (`<type>-<slug>`): fetch via `maestro wiki get <id>` (offline mode)
51
- - Otherwise: treat as topic string, run `maestro wiki search "<topic>"`, take the top result. If no result, fall back to Grep across `src/` for the topic.
52
- - If target cannot be resolved, AskUserQuestion with suggestions.
53
-
54
- ### Stage 2: Load Context Web
55
- For the resolved target, build a 1-hop context neighborhood:
56
-
57
- **If wiki entry:**
58
- - `maestro wiki forward <id>` — What this entry references
59
- - `maestro wiki backlinks <id>` — What references this entry
60
- - Read the body of top 3 related entries for context
61
-
62
- **If code file:**
63
- - Parse imports/requires to identify dependency files
64
- - Grep for exports used by other files (reverse dependencies)
65
- - Read the first 50 lines of top 3 dependent files for context
66
-
67
- **If directory:**
68
- - List files, identify entry points (index.ts, main.ts, cli.ts)
69
- - Build reading order: entry point → core modules → utilities → tests
70
-
71
- ### Stage 3: Build Reading Order
72
- - For a single file: split into logical sections (function boundaries, class boundaries, export groups)
73
- - For a wiki entry: split by markdown headings
74
- - For a directory: order files by dependency (entry points first, leaf modules last)
75
- - For `--depth shallow`: limit to top-level structure (function signatures, section headers)
76
- - For `--depth deep`: include every function body, every branch
77
-
78
- ### Stage 4: Guided Reading with Forcing Questions
79
- Walk through each section in reading order. For each section, apply 4 forcing questions:
80
-
81
- 1. **"What pattern is being used here?"** — Identify design patterns, idioms, conventions. Compare against `coding-conventions.md`.
82
- 2. **"Why this approach instead of alternatives?"** — What trade-offs were made? What was the simpler approach not chosen?
83
- 3. **"What assumption does this depend on?"** — What must be true for this code/content to be correct? External state? Input shape? Ordering?
84
- 4. **"What would break if this changed?"** — Fragility analysis. What downstream effects would a change have?
85
-
86
- Record answers as structured annotations per section.
87
-
88
- ### Stage 5: Extract Patterns
89
- From the forcing question answers, extract:
90
- - **Design patterns**: named patterns with code anchors (file:line)
91
- - **Naming conventions**: how things are named and why
92
- - **Error handling approach**: how errors flow through this code/content
93
- - **Data flow**: how data enters, transforms, and exits
94
- - **Assumptions**: explicit and implicit assumptions identified
95
-
96
- Cross-reference each pattern against existing `coding-conventions.md` entries:
97
- - Already documented → note as "confirmed convention"
98
- - Not documented → flag as "undocumented pattern" (candidate for `spec-add`)
99
-
100
- ### Stage 6: Produce Understanding Map
101
- Build a structured summary document:
102
-
103
- ```markdown
104
- # Follow-Along: {target name}
105
-
106
- ## Key Concepts
107
- - {concept}: {one-line explanation}
108
-
109
- ## Patterns Identified
110
- | Pattern | Location | Convention Status |
111
- |---------|----------|-------------------|
112
- | {name} | {file:line} | documented / undocumented |
113
-
114
- ## Assumptions
115
- - {assumption}: {what depends on it}
116
-
117
- ## Open Questions
118
- - {question}: {why it matters}
119
-
120
- ## Connections
121
- - Links to: {forward link entries}
122
- - Referenced by: {backlink entries}
123
- - Related lessons: {matching lessons.jsonl entries}
124
- ```
125
-
126
- ### Stage 7: Persist
127
- 1. Write `.workflow/learning/follow-{slug}-{date}.md` with the understanding map
128
- 2. Append each new pattern/technique as an insight to `lessons.jsonl`:
129
- - `source: "follow"`, `category: "pattern"` or `"technique"`
130
- - Tags: `["follow", "{target-slug}"]`
131
- - Stable INS-id from `hash("follow" + target + pattern_name)`
132
- 3. Update `learning-index.json`
133
- 4. If `--save-wiki`: run `maestro wiki create --type note --slug follow-{slug} --title "Follow-Along: {target}" --body-file .workflow/learning/follow-{slug}-{date}.md`
134
- 5. Display summary with key findings and next steps
135
-
136
- **Next-step routing:**
137
- - Deep dive into a discovered pattern → `/learn-decompose <path>`
138
- - Add undocumented pattern to specs → `/spec-add coding <description>`
139
- - Get second opinion on a finding → `/learn-second-opinion <file>`
140
- - Browse related wiki entries → `/wiki-digest <topic>`
141
- </execution>
142
-
143
- <error_codes>
144
- | Code | Severity | Condition | Recovery |
145
- |------|----------|-----------|----------|
146
- | E001 | error | Target not resolvable (file not found, wiki ID not found, search returned 0) | Check path/ID, or rephrase topic for search |
147
- | E002 | error | `.workflow/` not initialized | Run `/maestro-init` first |
148
- | W001 | warning | Wiki graph unavailable (no .workflow/ wiki entries) — skipping context web | Proceed with code-only context (imports/exports) |
149
- | W002 | warning | coding-conventions.md not found — skipping convention comparison | Patterns flagged as "unknown convention status" |
150
- | W003 | warning | Target is very large (>1000 lines) — auto-switching to shallow depth | Use --depth deep to override |
151
- </error_codes>
152
-
153
- <success_criteria>
154
- - [ ] Target resolved to concrete content (file, wiki entry, or search result)
155
- - [ ] Context web loaded (forward/backlinks for wiki, imports/exports for code)
156
- - [ ] Reading order established (sections/files ordered logically)
157
- - [ ] All 4 forcing questions applied per section
158
- - [ ] Patterns extracted with file:line anchors
159
- - [ ] Convention comparison performed against coding-conventions.md
160
- - [ ] Understanding map produced with: concepts, patterns, assumptions, questions, connections
161
- - [ ] `follow-{slug}-{date}.md` written
162
- - [ ] `lessons.jsonl` appended with discovered patterns (stable INS-ids)
163
- - [ ] `learning-index.json` updated
164
- - [ ] If --save-wiki: wiki note entry created
165
- - [ ] No files modified outside `.workflow/learning/` (and optionally wiki)
166
- - [ ] Summary displayed with next-step routing
167
- </success_criteria>
1
+ ---
2
+ name: learn-follow
3
+ description: Guided reading of code or wiki to extract patterns
4
+ argument-hint: "<path|wiki-id|topic> [--depth shallow|deep] [--save-wiki]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - Agent
12
+ - AskUserQuestion
13
+ ---
14
+ <purpose>
15
+ Guided reading experience for code files, wiki entries, or topics. Instead of just reading code, this command walks through content section by section using forcing questions (inspired by gstack `/office-hours` brainstorming) to extract patterns, identify assumptions, and build a structured understanding map.
16
+
17
+ Outputs reading notes with extracted patterns, open questions, and connection points. Insights persist to `lessons.jsonl` and optionally become wiki note entries for the knowledge graph.
18
+ </purpose>
19
+
20
+ <context>
21
+ Arguments: $ARGUMENTS
22
+
23
+ **Target resolution (auto-detected from first argument):**
24
+ - File path (e.g., `src/commands/wiki.ts`) → Read source file
25
+ - Wiki ID (e.g., `spec-auth`, `phase-planning`) → Fetch via `maestro wiki get`
26
+ - Topic string (e.g., `"authentication flow"`) → Search via `maestro wiki search`, use top result
27
+
28
+ **Flags:**
29
+ - `--depth shallow` — Quick pass: key patterns and structure only (default)
30
+ - `--depth deep` — Thorough: every function, every branch, every assumption
31
+ - `--save-wiki` — Create a wiki note entry with the reading notes via `maestro wiki create --type note`
32
+
33
+ **Storage written:**
34
+ - `.workflow/learning/follow-{slug}-{YYYY-MM-DD}.md` — Reading notes with understanding map
35
+ - `.workflow/learning/lessons.jsonl` — Appended pattern/technique insights
36
+ - `.workflow/learning/learning-index.json` — Updated index
37
+ - If `--save-wiki`: new wiki note entry
38
+
39
+ **Storage read:**
40
+ - Target source file or wiki entry
41
+ - `maestro wiki backlinks <id>` / `maestro wiki forward <id>` — Relationship context
42
+ - `.workflow/specs/coding-conventions.md` — Convention reference for pattern matching
43
+ - `.workflow/learning/lessons.jsonl` — Prior insights for dedup and cross-reference
44
+ </context>
45
+
46
+ <execution>
47
+
48
+ ### Stage 1: Resolve Target
49
+ - If argument looks like a file path (contains `/` or `\`, or matches a glob): verify file exists via Read
50
+ - If argument matches wiki ID pattern (`<type>-<slug>`): fetch via `maestro wiki get <id>` (offline mode)
51
+ - Otherwise: treat as topic string, run `maestro wiki search "<topic>"`, take the top result. If no result, fall back to Grep across `src/` for the topic.
52
+ - If target cannot be resolved, AskUserQuestion with suggestions.
53
+
54
+ ### Stage 2: Load Context Web
55
+ For the resolved target, build a 1-hop context neighborhood:
56
+
57
+ **If wiki entry:**
58
+ - `maestro wiki forward <id>` — What this entry references
59
+ - `maestro wiki backlinks <id>` — What references this entry
60
+ - Read the body of top 3 related entries for context
61
+
62
+ **If code file:**
63
+ - Parse imports/requires to identify dependency files
64
+ - Grep for exports used by other files (reverse dependencies)
65
+ - Read the first 50 lines of top 3 dependent files for context
66
+
67
+ **If directory:**
68
+ - List files, identify entry points (index.ts, main.ts, cli.ts)
69
+ - Build reading order: entry point → core modules → utilities → tests
70
+
71
+ ### Stage 3: Build Reading Order
72
+ - For a single file: split into logical sections (function boundaries, class boundaries, export groups)
73
+ - For a wiki entry: split by markdown headings
74
+ - For a directory: order files by dependency (entry points first, leaf modules last)
75
+ - For `--depth shallow`: limit to top-level structure (function signatures, section headers)
76
+ - For `--depth deep`: include every function body, every branch
77
+
78
+ ### Stage 4: Guided Reading with Forcing Questions
79
+ Walk through each section in reading order. For each section, apply 4 forcing questions:
80
+
81
+ 1. **"What pattern is being used here?"** — Identify design patterns, idioms, conventions. Compare against `coding-conventions.md`.
82
+ 2. **"Why this approach instead of alternatives?"** — What trade-offs were made? What was the simpler approach not chosen?
83
+ 3. **"What assumption does this depend on?"** — What must be true for this code/content to be correct? External state? Input shape? Ordering?
84
+ 4. **"What would break if this changed?"** — Fragility analysis. What downstream effects would a change have?
85
+
86
+ Record answers as structured annotations per section.
87
+
88
+ ### Stage 5: Extract Patterns
89
+ From the forcing question answers, extract:
90
+ - **Design patterns**: named patterns with code anchors (file:line)
91
+ - **Naming conventions**: how things are named and why
92
+ - **Error handling approach**: how errors flow through this code/content
93
+ - **Data flow**: how data enters, transforms, and exits
94
+ - **Assumptions**: explicit and implicit assumptions identified
95
+
96
+ Cross-reference each pattern against existing `coding-conventions.md` entries:
97
+ - Already documented → note as "confirmed convention"
98
+ - Not documented → flag as "undocumented pattern" (candidate for `spec-add`)
99
+
100
+ ### Stage 6: Produce Understanding Map
101
+ Build a structured summary document:
102
+
103
+ ```markdown
104
+ # Follow-Along: {target name}
105
+
106
+ ## Key Concepts
107
+ - {concept}: {one-line explanation}
108
+
109
+ ## Patterns Identified
110
+ | Pattern | Location | Convention Status |
111
+ |---------|----------|-------------------|
112
+ | {name} | {file:line} | documented / undocumented |
113
+
114
+ ## Assumptions
115
+ - {assumption}: {what depends on it}
116
+
117
+ ## Open Questions
118
+ - {question}: {why it matters}
119
+
120
+ ## Connections
121
+ - Links to: {forward link entries}
122
+ - Referenced by: {backlink entries}
123
+ - Related lessons: {matching lessons.jsonl entries}
124
+ ```
125
+
126
+ ### Stage 7: Persist
127
+ 1. Write `.workflow/learning/follow-{slug}-{date}.md` with the understanding map
128
+ 2. Append each new pattern/technique as an insight to `lessons.jsonl`:
129
+ - `source: "follow"`, `category: "pattern"` or `"technique"`
130
+ - Tags: `["follow", "{target-slug}"]`
131
+ - Stable INS-id from `hash("follow" + target + pattern_name)`
132
+ 3. Update `learning-index.json`
133
+ 4. If `--save-wiki`: run `maestro wiki create --type note --slug follow-{slug} --title "Follow-Along: {target}" --body-file .workflow/learning/follow-{slug}-{date}.md`
134
+ 5. Display summary with key findings and next steps
135
+
136
+ **Next-step routing:**
137
+ - Deep dive into a discovered pattern → `/learn-decompose <path>`
138
+ - Add undocumented pattern to specs → `/spec-add coding <description>`
139
+ - Get second opinion on a finding → `/learn-second-opinion <file>`
140
+ - Browse related wiki entries → `/wiki-digest <topic>`
141
+ </execution>
142
+
143
+ <error_codes>
144
+ | Code | Severity | Condition | Recovery |
145
+ |------|----------|-----------|----------|
146
+ | E001 | error | Target not resolvable (file not found, wiki ID not found, search returned 0) | Check path/ID, or rephrase topic for search |
147
+ | E002 | error | `.workflow/` not initialized | Run `/maestro-init` first |
148
+ | W001 | warning | Wiki graph unavailable (no .workflow/ wiki entries) — skipping context web | Proceed with code-only context (imports/exports) |
149
+ | W002 | warning | coding-conventions.md not found — skipping convention comparison | Patterns flagged as "unknown convention status" |
150
+ | W003 | warning | Target is very large (>1000 lines) — auto-switching to shallow depth | Use --depth deep to override |
151
+ </error_codes>
152
+
153
+ <success_criteria>
154
+ - [ ] Target resolved to concrete content (file, wiki entry, or search result)
155
+ - [ ] Context web loaded (forward/backlinks for wiki, imports/exports for code)
156
+ - [ ] Reading order established (sections/files ordered logically)
157
+ - [ ] All 4 forcing questions applied per section
158
+ - [ ] Patterns extracted with file:line anchors
159
+ - [ ] Convention comparison performed against coding-conventions.md
160
+ - [ ] Understanding map produced with: concepts, patterns, assumptions, questions, connections
161
+ - [ ] `follow-{slug}-{date}.md` written
162
+ - [ ] `lessons.jsonl` appended with discovered patterns (stable INS-ids)
163
+ - [ ] `learning-index.json` updated
164
+ - [ ] If --save-wiki: wiki note entry created
165
+ - [ ] No files modified outside `.workflow/learning/` (and optionally wiki)
166
+ - [ ] Summary displayed with next-step routing
167
+ </success_criteria>