maestro-flow-one 0.1.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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/bin/maestro-flow.js +730 -0
  4. package/claude/maestro-flow/SKILL.md +239 -0
  5. package/claude/maestro-flow/chains/templates.json +256 -0
  6. package/claude/maestro-flow/commands/learn/decompose.md +176 -0
  7. package/claude/maestro-flow/commands/learn/follow.md +167 -0
  8. package/claude/maestro-flow/commands/learn/investigate.md +221 -0
  9. package/claude/maestro-flow/commands/learn/retro.md +303 -0
  10. package/claude/maestro-flow/commands/learn/second-opinion.md +167 -0
  11. package/claude/maestro-flow/commands/lifecycle/amend.md +300 -0
  12. package/claude/maestro-flow/commands/lifecycle/analyze.md +126 -0
  13. package/claude/maestro-flow/commands/lifecycle/brainstorm.md +100 -0
  14. package/claude/maestro-flow/commands/lifecycle/composer.md +354 -0
  15. package/claude/maestro-flow/commands/lifecycle/execute.md +114 -0
  16. package/claude/maestro-flow/commands/lifecycle/fork.md +86 -0
  17. package/claude/maestro-flow/commands/lifecycle/init.md +78 -0
  18. package/claude/maestro-flow/commands/lifecycle/learn.md +140 -0
  19. package/claude/maestro-flow/commands/lifecycle/link-coordinate.md +71 -0
  20. package/claude/maestro-flow/commands/lifecycle/merge.md +61 -0
  21. package/claude/maestro-flow/commands/lifecycle/overlay.md +178 -0
  22. package/claude/maestro-flow/commands/lifecycle/plan.md +138 -0
  23. package/claude/maestro-flow/commands/lifecycle/player.md +404 -0
  24. package/claude/maestro-flow/commands/lifecycle/quick.md +56 -0
  25. package/claude/maestro-flow/commands/lifecycle/roadmap.md +164 -0
  26. package/claude/maestro-flow/commands/lifecycle/ui-design.md +93 -0
  27. package/claude/maestro-flow/commands/lifecycle/update.md +176 -0
  28. package/claude/maestro-flow/commands/lifecycle/verify.md +90 -0
  29. package/claude/maestro-flow/commands/manage/codebase-rebuild.md +75 -0
  30. package/claude/maestro-flow/commands/manage/codebase-refresh.md +57 -0
  31. package/claude/maestro-flow/commands/manage/harvest.md +94 -0
  32. package/claude/maestro-flow/commands/manage/issue-discover.md +77 -0
  33. package/claude/maestro-flow/commands/manage/issue.md +73 -0
  34. package/claude/maestro-flow/commands/manage/knowhow-capture.md +193 -0
  35. package/claude/maestro-flow/commands/manage/knowhow.md +77 -0
  36. package/claude/maestro-flow/commands/manage/learn.md +67 -0
  37. package/claude/maestro-flow/commands/manage/status.md +51 -0
  38. package/claude/maestro-flow/commands/manage/wiki.md +62 -0
  39. package/claude/maestro-flow/commands/milestone/audit.md +68 -0
  40. package/claude/maestro-flow/commands/milestone/complete.md +75 -0
  41. package/claude/maestro-flow/commands/milestone/release.md +96 -0
  42. package/claude/maestro-flow/commands/quality/auto-test.md +124 -0
  43. package/claude/maestro-flow/commands/quality/debug.md +115 -0
  44. package/claude/maestro-flow/commands/quality/refactor.md +55 -0
  45. package/claude/maestro-flow/commands/quality/retrospective.md +78 -0
  46. package/claude/maestro-flow/commands/quality/review.md +108 -0
  47. package/claude/maestro-flow/commands/quality/sync.md +51 -0
  48. package/claude/maestro-flow/commands/quality/test.md +103 -0
  49. package/claude/maestro-flow/commands/spec/add.md +49 -0
  50. package/claude/maestro-flow/commands/spec/load.md +51 -0
  51. package/claude/maestro-flow/commands/spec/remove.md +51 -0
  52. package/claude/maestro-flow/commands/spec/setup.md +51 -0
  53. package/claude/maestro-flow/commands/wiki/connect.md +62 -0
  54. package/claude/maestro-flow/commands/wiki/digest.md +69 -0
  55. package/codex/maestro-flow/SKILL.md +505 -0
  56. package/codex/maestro-flow/chains/templates.json +256 -0
  57. package/codex/maestro-flow/commands/learn/decompose.md +113 -0
  58. package/codex/maestro-flow/commands/learn/follow.md +83 -0
  59. package/codex/maestro-flow/commands/learn/investigate.md +83 -0
  60. package/codex/maestro-flow/commands/learn/retro.md +83 -0
  61. package/codex/maestro-flow/commands/learn/second-opinion.md +86 -0
  62. package/codex/maestro-flow/commands/lifecycle/amend.md +300 -0
  63. package/codex/maestro-flow/commands/lifecycle/analyze.md +483 -0
  64. package/codex/maestro-flow/commands/lifecycle/brainstorm.md +397 -0
  65. package/codex/maestro-flow/commands/lifecycle/composer.md +213 -0
  66. package/codex/maestro-flow/commands/lifecycle/execute.md +318 -0
  67. package/codex/maestro-flow/commands/lifecycle/fork.md +98 -0
  68. package/codex/maestro-flow/commands/lifecycle/init.md +134 -0
  69. package/codex/maestro-flow/commands/lifecycle/learn.md +80 -0
  70. package/codex/maestro-flow/commands/lifecycle/link-coordinate.md +257 -0
  71. package/codex/maestro-flow/commands/lifecycle/merge.md +69 -0
  72. package/codex/maestro-flow/commands/lifecycle/overlay.md +119 -0
  73. package/codex/maestro-flow/commands/lifecycle/plan.md +460 -0
  74. package/codex/maestro-flow/commands/lifecycle/player.md +323 -0
  75. package/codex/maestro-flow/commands/lifecycle/quick.md +124 -0
  76. package/codex/maestro-flow/commands/lifecycle/roadmap.md +468 -0
  77. package/codex/maestro-flow/commands/lifecycle/ui-design.md +135 -0
  78. package/codex/maestro-flow/commands/lifecycle/update.md +176 -0
  79. package/codex/maestro-flow/commands/lifecycle/verify.md +468 -0
  80. package/codex/maestro-flow/commands/manage/codebase-rebuild.md +347 -0
  81. package/codex/maestro-flow/commands/manage/codebase-refresh.md +66 -0
  82. package/codex/maestro-flow/commands/manage/harvest.md +91 -0
  83. package/codex/maestro-flow/commands/manage/issue-discover.md +431 -0
  84. package/codex/maestro-flow/commands/manage/issue.md +75 -0
  85. package/codex/maestro-flow/commands/manage/knowhow-capture.md +110 -0
  86. package/codex/maestro-flow/commands/manage/knowhow.md +95 -0
  87. package/codex/maestro-flow/commands/manage/learn.md +137 -0
  88. package/codex/maestro-flow/commands/manage/status.md +76 -0
  89. package/codex/maestro-flow/commands/manage/wiki.md +55 -0
  90. package/codex/maestro-flow/commands/milestone/audit.md +87 -0
  91. package/codex/maestro-flow/commands/milestone/complete.md +91 -0
  92. package/codex/maestro-flow/commands/milestone/release.md +70 -0
  93. package/codex/maestro-flow/commands/quality/auto-test.md +547 -0
  94. package/codex/maestro-flow/commands/quality/debug.md +334 -0
  95. package/codex/maestro-flow/commands/quality/refactor.md +151 -0
  96. package/codex/maestro-flow/commands/quality/retrospective.md +292 -0
  97. package/codex/maestro-flow/commands/quality/review.md +364 -0
  98. package/codex/maestro-flow/commands/quality/sync.md +111 -0
  99. package/codex/maestro-flow/commands/quality/test.md +498 -0
  100. package/codex/maestro-flow/commands/spec/add.md +101 -0
  101. package/codex/maestro-flow/commands/spec/load.md +77 -0
  102. package/codex/maestro-flow/commands/spec/remove.md +69 -0
  103. package/codex/maestro-flow/commands/spec/setup.md +75 -0
  104. package/codex/maestro-flow/commands/wiki/connect.md +73 -0
  105. package/codex/maestro-flow/commands/wiki/digest.md +87 -0
  106. package/package.json +24 -0
@@ -0,0 +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>
@@ -0,0 +1,221 @@
1
+ ---
2
+ name: learn-investigate
3
+ description: Systematic question investigation with hypothesis testing, evidence logging, and 3-strike escalation
4
+ argument-hint: "<question> [--scope <path>] [--max-hypotheses N]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - Agent
12
+ - AskUserQuestion
13
+ ---
14
+ <purpose>
15
+ Systematic investigation workflow for understanding questions (not bug-fixing). Inspired by gstack `/investigate` with its 4-phase approach, scope lock, and 3-strike escalation rule.
16
+
17
+ Unlike `quality-debug` which is designed for fixing bugs during execution phases, this command is for answering "how does X work?", "why does Y happen?", "what would happen if Z?" questions. It produces structured evidence trails and understanding documents that persist to the learning system.
18
+ </purpose>
19
+
20
+ <context>
21
+ Arguments: $ARGUMENTS
22
+
23
+ **Target:** First argument is the question or topic to investigate (quoted string or keywords).
24
+
25
+ **Flags:**
26
+ - `--scope <path>` — Restrict investigation to files under this directory (default: entire project)
27
+ - `--max-hypotheses N` — Maximum hypotheses to test before escalating (default: 3)
28
+
29
+ **Storage written:**
30
+ - `.workflow/learning/investigate-{slug}/evidence.ndjson` — Structured evidence log (one JSON line per evidence)
31
+ - `.workflow/learning/investigate-{slug}/understanding.md` — Evolving understanding document
32
+ - `.workflow/learning/investigate-{slug}/report.md` — Final investigation report
33
+ - `.workflow/learning/lessons.jsonl` — Investigation findings as insights (source: "investigate")
34
+ - `.workflow/learning/learning-index.json` — Updated index
35
+
36
+ **Storage read:**
37
+ - Source files within scope
38
+ - `maestro wiki search "<question>"` — Prior knowledge about the topic
39
+ - `.workflow/learning/lessons.jsonl` — Prior related investigations
40
+ - `.workflow/specs/debug-notes.md` — Known gotchas and patterns
41
+ - `.workflow/codebase/architecture.md` — Structural context (if exists)
42
+ </context>
43
+
44
+ <execution>
45
+
46
+ ### Stage 1: Frame the Question
47
+ - Parse question from arguments
48
+ - Determine scope (--scope or full project)
49
+ - Generate investigation slug from question keywords
50
+ - Create `.workflow/learning/investigate-{slug}/` directory
51
+ - Search prior knowledge:
52
+ - `maestro wiki search "<question>"` for related entries
53
+ - Grep `lessons.jsonl` for related insights
54
+ - Read `debug-notes.md` for known gotchas
55
+
56
+ Write initial `understanding.md`:
57
+ ```markdown
58
+ # Investigation: {question}
59
+ ## Initial Understanding
60
+ - Prior knowledge: {summary of wiki/lessons findings}
61
+ - Scope: {path or "full project"}
62
+ - Started: {timestamp}
63
+ ```
64
+
65
+ ### Stage 2: Evidence Collection
66
+ Systematically gather evidence related to the question:
67
+
68
+ 1. **Code search**: Grep for keywords from the question across the scoped files
69
+ 2. **File inspection**: Read the most relevant files identified by search
70
+ 3. **Import/dependency tracing**: Follow imports to understand the dependency chain
71
+ 4. **Git history**: `git log --oneline -10 -- <relevant-files>` for recent changes
72
+
73
+ For each piece of evidence, append to `evidence.ndjson`:
74
+ ```json
75
+ {"ts": "ISO", "type": "code|git|search|doc", "source": "file:line", "relevance": "high|medium|low", "content": "...", "note": "why this matters"}
76
+ ```
77
+
78
+ ### Stage 3: Pattern Matching
79
+ Compare collected evidence against known patterns:
80
+ - Check `debug-notes.md` entries for matching situations
81
+ - Check `lessons.jsonl` for related technique/pattern/gotcha entries
82
+ - Identify: does this match a documented pattern, or is it novel?
83
+
84
+ Update `understanding.md` with pattern analysis section.
85
+
86
+ ### Stage 4: Hypothesis Formation
87
+ From evidence and patterns, generate ranked hypotheses:
88
+ - Each hypothesis: a specific, testable claim about "how/why"
89
+ - Rank by plausibility (evidence strength)
90
+ - Write hypotheses to `understanding.md`
91
+
92
+ ```markdown
93
+ ## Hypotheses
94
+ 1. **[HIGH]** {hypothesis 1} — Evidence: {refs}
95
+ 2. **[MEDIUM]** {hypothesis 2} — Evidence: {refs}
96
+ 3. **[LOW]** {hypothesis 3} — Evidence: {refs}
97
+ ```
98
+
99
+ ### Stage 4.5: CLI Supplementary Exploration (optional)
100
+
101
+ **Skip if** no enabled CLI tools or hypotheses are trivially testable.
102
+
103
+ ```
104
+ IF no CLI tools enabled: skip to Stage 5
105
+
106
+ hypothesis_summary = hypotheses.map(h => "${h.rank}: ${h.claim}").join("\n")
107
+
108
+ Bash({
109
+ command: 'maestro delegate "PURPOSE: Gather evidence for investigation hypotheses
110
+ TASK: For each hypothesis, trace relevant call chains and data flows | Find corroborating or contradicting code patterns
111
+ MODE: analysis
112
+ CONTEXT: @${scope_path}/**/*
113
+ EXPECTED: JSON array of { hypothesis_rank, evidence: [{ file, line, supports: bool, explanation }] }
114
+ CONSTRAINTS: Focus on code-level evidence only | Max 5 evidence items per hypothesis
115
+
116
+ Hypotheses:
117
+ ${hypothesis_summary}
118
+ " --role explore --mode analysis',
119
+ run_in_background: true
120
+ })
121
+ ```
122
+
123
+ **On callback:** Parse result, append each evidence item to `evidence.ndjson` with `type: "cli-exploration"`. Pass as supplementary context to Stage 5 testing.
124
+
125
+ ### Stage 5: Hypothesis Testing
126
+ For each hypothesis (in rank order):
127
+
128
+ 1. **Design test**: What specific evidence would confirm or disprove this?
129
+ 2. **Execute test**: Code trace, targeted search, data inspection, or experiment
130
+ 3. **Record result**: Append to `evidence.ndjson` with `type: "test"`
131
+ 4. **Update understanding**: Mark hypothesis as confirmed / disproved / inconclusive
132
+
133
+ ```markdown
134
+ ## Test Results
135
+ ### Hypothesis 1: {claim}
136
+ - Test: {what was done}
137
+ - Result: CONFIRMED / DISPROVED / INCONCLUSIVE
138
+ - Evidence: {file:line references}
139
+ ```
140
+
141
+ ### Stage 6: 3-Strike Escalation
142
+ If `--max-hypotheses` hypotheses all fail:
143
+
144
+ 1. **Broaden scope**: If scope was restricted, suggest expanding. AskUserQuestion:
145
+ ```
146
+ {N} hypotheses tested, none confirmed.
147
+ A) Broaden scope to full project
148
+ B) I have a new hypothesis: [user provides]
149
+ C) Escalate — this needs deeper investigation
150
+ ```
151
+ 2. **Search wiki for clues**: `maestro wiki search` with alternative keywords
152
+ 3. **If still stuck**: Mark as INCONCLUSIVE with what was learned and what remains unknown
153
+
154
+ ### Stage 7: Synthesize & Report
155
+ Write final `report.md`:
156
+
157
+ ```markdown
158
+ # Investigation Report: {question}
159
+
160
+ ## Answer
161
+ {confirmed understanding or "INCONCLUSIVE: ..."}
162
+
163
+ ## Evidence Trail
164
+ | # | Type | Source | Relevance | Finding |
165
+ |---|------|--------|-----------|---------|
166
+ | 1 | code | file:line | high | ... |
167
+
168
+ ## Hypotheses Tested
169
+ | Hypothesis | Result | Key Evidence |
170
+ |-----------|--------|-------------|
171
+ | ... | confirmed/disproved | file:line |
172
+
173
+ ## Key Learnings
174
+ - {learning 1}
175
+ - {learning 2}
176
+
177
+ ## Open Questions
178
+ - {what remains unknown}
179
+ ```
180
+
181
+ ### Stage 8: Persist
182
+ 1. Append findings to `lessons.jsonl`:
183
+ - Confirmed hypotheses → `category: "technique"` or `"pattern"`
184
+ - Disproved hypotheses → `category: "gotcha"` (what looked true but wasn't)
185
+ - `source: "investigate"`, tags: `["investigate", "{question-slug}"]`
186
+ - Stable INS-id from `hash("investigate" + question + finding_title)`
187
+ 2. Update `learning-index.json`
188
+ 3. Display summary with answer and next steps
189
+
190
+ **Next-step routing:**
191
+ - Save finding to specs → `/spec-add debug <finding>`
192
+ - Follow-along on discovered code → `/learn-follow <path>`
193
+ - Decompose patterns found → `/learn-decompose <module>`
194
+ - Create wiki entry for understanding → `maestro wiki create --type note`
195
+ </execution>
196
+
197
+ <error_codes>
198
+ | Code | Severity | Condition | Recovery |
199
+ |------|----------|-----------|----------|
200
+ | E001 | error | No question provided | Provide a question as the first argument |
201
+ | E002 | error | Scope path does not exist | Check --scope path is valid |
202
+ | W001 | warning | No prior knowledge found in wiki/lessons | Proceed with fresh investigation |
203
+ | W002 | warning | Evidence collection found very few matches (<3) | Broaden search terms or expand scope |
204
+ | W003 | warning | All hypotheses inconclusive — escalating | Investigation marked INCONCLUSIVE |
205
+ </error_codes>
206
+
207
+ <success_criteria>
208
+ - [ ] Question parsed and investigation slug generated
209
+ - [ ] Investigation directory created under `.workflow/learning/`
210
+ - [ ] Prior knowledge loaded from wiki and lessons
211
+ - [ ] Evidence collected and logged to `evidence.ndjson` (structured NDJSON)
212
+ - [ ] Pattern matching performed against debug-notes and lessons
213
+ - [ ] At least 1 hypothesis formed and tested
214
+ - [ ] `understanding.md` tracks evolving understanding with timestamps
215
+ - [ ] `report.md` written with answer, evidence trail, hypothesis results
216
+ - [ ] Findings appended to `lessons.jsonl` with stable INS-ids
217
+ - [ ] `learning-index.json` updated
218
+ - [ ] 3-strike escalation triggered if all hypotheses fail
219
+ - [ ] No files modified outside `.workflow/learning/`
220
+ - [ ] Summary displayed with answer and next-step routing
221
+ </success_criteria>
@@ -0,0 +1,303 @@
1
+ ---
2
+ name: learn-retro
3
+ description: Unified retrospective — git activity metrics and decision quality evaluation with lens-based selection
4
+ argument-hint: "[--lens git|decision|all] [--days N] [--author <name>] [--area <path>] [--phase N] [--tag <tag>] [--id <id>] [--compare]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - Agent
12
+ - AskUserQuestion
13
+ ---
14
+ <purpose>
15
+ Unified retrospective that combines git activity analysis and decision quality evaluation into a single command with lens-based selection. Works on raw git history and wiki/spec data — does not require completed phase artifacts (unlike `quality-retrospective`).
16
+
17
+ Two lenses, usable independently or together:
18
+ - **git**: Commit metrics, session detection, per-author breakdown, file hotspots, trend tracking
19
+ - **decision**: Decision tracing across wiki/specs/git, multi-perspective evaluation, lifecycle classification
20
+
21
+ All insights persist to `.workflow/learning/lessons.jsonl` for cross-session queryability via `manage-learn`.
22
+ </purpose>
23
+
24
+ <context>
25
+ Arguments: $ARGUMENTS
26
+
27
+ **Lens selection:**
28
+ - `--lens git` — Git activity retrospective only
29
+ - `--lens decision` — Decision evaluation only
30
+ - `--lens all` — Both lenses (default)
31
+
32
+ **Git lens flags:**
33
+ - `--days N` — Time window in days (default: 7)
34
+ - `--author <name>` — Filter commits by author name (substring match)
35
+ - `--area <path>` — Scope to files under a specific directory
36
+ - `--compare` — Compare against the previous retro report if one exists
37
+
38
+ **Decision lens flags:**
39
+ - `--phase N` — Decisions from phase N's context and related specs
40
+ - `--tag <tag>` — Decisions tagged with specific tag in wiki/specs
41
+ - `--id <id>` — Single decision by wiki ID or lessons.jsonl INS-id
42
+
43
+ **Storage written:**
44
+ - `.workflow/learning/retro-{YYYY-MM-DD}.md` — Unified human-readable report
45
+ - `.workflow/learning/retro-{YYYY-MM-DD}.json` — Structured metrics (machine-readable)
46
+ - `.workflow/learning/lessons.jsonl` — Appended insights (source: "retro-git" or "retro-decision")
47
+ - `.workflow/learning/learning-index.json` — Updated index
48
+
49
+ **Storage read:**
50
+ - `.workflow/state.json` — Current phase context (optional)
51
+ - `.workflow/learning/retro-*.json` — Prior retro for trend comparison
52
+ - `.workflow/learning/lessons.jsonl` — Existing insights for dedup
53
+ - `maestro wiki list --type spec --json` — Spec entries (decision lens)
54
+ - `.workflow/specs/architecture-constraints.md` — Documented architectural decisions (decision lens)
55
+ - Phase context with Locked/Free/Deferred decisions (decision lens) — resolve via `state.json.artifacts[]` scratch paths
56
+ </context>
57
+
58
+ <execution>
59
+
60
+ ### Stage 1: Parse Arguments & Select Lenses
61
+ - Parse `--lens` flag: `git`, `decision`, or `all` (default: `all`)
62
+ - Extract lens-specific flags
63
+ - Check `.workflow/learning/` exists; bootstrap if missing
64
+
65
+ Display banner:
66
+ ```
67
+ ============================================================
68
+ LEARN RETRO
69
+ ============================================================
70
+ Lens: {git | decision | all}
71
+ Scope: {days/author/area for git} {phase/tag/id for decision}
72
+ ```
73
+
74
+ ---
75
+
76
+ ### Stage 2: Git Lens (skip if --lens decision)
77
+
78
+ #### 2a: Gather Raw Data (parallel git commands)
79
+ Run ALL these git commands in parallel:
80
+
81
+ ```bash
82
+ # Commit stats with author, timestamp, subject, files changed
83
+ git log --since="<start-date>T00:00:00" --format="%H|%aN|%ae|%ai|%s" --shortstat
84
+
85
+ # Per-commit numstat for test vs production LOC split
86
+ git log --since="<start-date>T00:00:00" --format="COMMIT:%H|%aN" --numstat
87
+
88
+ # Timestamps for session detection (sorted)
89
+ git log --since="<start-date>T00:00:00" --format="%at|%aN|%ai|%s" | sort -n
90
+
91
+ # File hotspots (most frequently changed files)
92
+ git log --since="<start-date>T00:00:00" --format="" --name-only | grep -v '^$' | sort | uniq -c | sort -rn | head -20
93
+
94
+ # Per-author commit counts
95
+ git shortlog --since="<start-date>T00:00:00" -sn --no-merges
96
+ ```
97
+
98
+ Apply `--author` and `--area` filters if provided.
99
+
100
+ #### 2b: Compute Metrics
101
+ | Metric | Computation |
102
+ |--------|-------------|
103
+ | Commits | Count of non-merge commits |
104
+ | Contributors | Unique author count |
105
+ | Total insertions / deletions | Sum from shortstat |
106
+ | Net LOC | insertions - deletions |
107
+ | Test LOC (insertions) | Sum insertions for test files from numstat |
108
+ | Test ratio | test_insertions / total_insertions x 100% |
109
+ | Churn rate | Files changed >2 times / total unique files |
110
+ | Active days | Distinct dates with commits |
111
+
112
+ #### 2c: Detect Work Sessions
113
+ Cluster commits by >2hr gaps in timestamps:
114
+ - Per session: start time, end time, duration, commit count, primary focus area
115
+ - Compute: total sessions, avg session duration, avg LOC/session-hour
116
+
117
+ #### 2d: Per-Author Breakdown
118
+ For each author:
119
+ - Commit count, LOC added/removed, top 3 file areas
120
+ - Test ratio (their test LOC / their total LOC)
121
+ - Session count and patterns
122
+
123
+ #### 2e: Trend Comparison (if --compare or prior report exists)
124
+ - Find most recent `.workflow/learning/retro-*.json`
125
+ - Compute deltas: commits, LOC, test ratio, churn rate, session count
126
+ - Flag significant changes (>20% delta) as trend highlights
127
+
128
+ #### 2f: Distill Git Insights
129
+ - **High churn files** (changed >3 times): instability signal
130
+ - **Low test ratio areas** (<20%): testing gap
131
+ - **Session patterns**: scattered vs deep sessions
132
+ - **Area drift**: commits not aligned with current roadmap phase
133
+
134
+ Each insight: title, description, category (pattern/antipattern/technique), tags, confidence.
135
+
136
+ ---
137
+
138
+ ### Stage 3: Decision Lens (skip if --lens git)
139
+
140
+ #### 3a: Collect Decisions (parallel)
141
+ ```bash
142
+ maestro wiki search "decision" --json
143
+ maestro wiki list --type spec --json
144
+ git log --oneline --all --grep="decision\|chose\|decided\|architecture" -20
145
+ ```
146
+
147
+ Also read:
148
+ - `.workflow/specs/architecture-constraints.md` — grep for `<spec-entry category="arch"` blocks
149
+ - Phase context files — resolve via `state.json.artifacts[]` scratch paths — scan for "Locked:", "Deferred:" sections
150
+ - `.workflow/learning/lessons.jsonl` — filter `category == "decision"`
151
+
152
+ Apply scope filter (--phase, --tag, --id).
153
+
154
+ #### 3b: Build Decision Registry
155
+ Per decision:
156
+ ```json
157
+ {
158
+ "id": "source id",
159
+ "title": "what was decided",
160
+ "source": "wiki|spec|phase-context|lesson|git",
161
+ "date": "when decided",
162
+ "rationale": "why",
163
+ "alternatives": "what was considered",
164
+ "phase": "which phase",
165
+ "implementation_evidence": ["file paths from git"]
166
+ }
167
+ ```
168
+
169
+ #### 3c: Multi-Perspective Evaluation
170
+ Spawn 3 Agents in a single message:
171
+
172
+ **Agent 1 — Technical Soundness:**
173
+ - Does implementation match stated intent?
174
+ - Has technical context changed since decision was made?
175
+ - Grade: sound / degraded / violated
176
+
177
+ **Agent 2 — Cost Assessment:**
178
+ - What complexity did this decision add?
179
+ - Is it creating coupling or tech debt?
180
+ - Grade: low-cost / acceptable / expensive / debt-creating
181
+
182
+ **Agent 3 — Alternative Hindsight:**
183
+ - With what we know now, was this the right call?
184
+ - Would reversing be feasible?
185
+ - Grade: confirmed / questionable / should-revisit
186
+
187
+ #### 3d: Classify Decision Lifecycle
188
+ | Status | Criteria |
189
+ |--------|---------|
190
+ | **Validated** | Sound + Low/Acceptable cost + Confirmed |
191
+ | **Aging** | Sound but Expensive + Confirmed |
192
+ | **Questionable** | Degraded or Violated + Questionable |
193
+ | **Stale** | Any + Should-revisit |
194
+ | **Reversed** | Code contradicts the decision |
195
+
196
+ #### 3e: Generate Recommendations
197
+ - **Aging**: flag for tech debt review
198
+ - **Questionable**: create issue for investigation
199
+ - **Stale**: suggest decision refresh
200
+ - **Reversed**: suggest documenting the reversal
201
+
202
+ ---
203
+
204
+ ### Stage 4: Unified Report
205
+
206
+ Write `.workflow/learning/retro-{date}.md`:
207
+
208
+ ```markdown
209
+ # Retrospective: {date}
210
+ **Lenses:** {active lenses} | **Period:** {days}d
211
+
212
+ ## Git Activity (if git lens active)
213
+ ### Metrics
214
+ | Metric | Value | Trend |
215
+ |--------|-------|-------|
216
+ | Commits | N | +/-% |
217
+ | ...
218
+
219
+ ### Work Sessions
220
+ {session timeline}
221
+
222
+ ### File Hotspots
223
+ {top 10 most-changed files}
224
+
225
+ ### Per-Author
226
+ {author breakdown table}
227
+
228
+ ## Decision Health (if decision lens active)
229
+ ### Dashboard
230
+ | Status | Count | Decisions |
231
+ |--------|-------|-----------|
232
+ | Validated | N | {list} |
233
+ | Aging | N | {list} |
234
+ | ...
235
+
236
+ ### Per-Decision Evaluation
237
+ {detailed evaluations}
238
+
239
+ ## Combined Insights
240
+ {merged insights from both lenses, deduplicated}
241
+
242
+ ## Recommended Actions
243
+ 1. {action}: {reason}
244
+ ```
245
+
246
+ Write `.workflow/learning/retro-{date}.json` with structured data.
247
+
248
+ ---
249
+
250
+ ### Stage 5: Persist
251
+ 1. Write report files
252
+ 2. Append insights to `lessons.jsonl`:
253
+ - Git insights: `source: "retro-git"`, `category` per insight type
254
+ - Decision insights: `source: "retro-decision"`, `category: "decision"`
255
+ - Stable INS-id from `hash(lens + metric_or_decision + date)`
256
+ 3. Update `learning-index.json`
257
+ 4. Display summary
258
+
259
+ **Next-step routing:**
260
+ - Browse insights → `/manage-learn list --tag retro`
261
+ - Deep dive on high-churn file → `/learn-follow <path>`
262
+ - Fix test gaps → `/quality-auto-test <area>`
263
+ - Create issue for questionable decision → `/manage-issue create ...`
264
+ - Investigate stale decision → `/learn-investigate <question>`
265
+ - Full phase retrospective → `/quality-retrospective`
266
+ </execution>
267
+
268
+ <error_codes>
269
+ | Code | Severity | Condition | Recovery |
270
+ |------|----------|-----------|----------|
271
+ | E001 | error | Not inside a git repository (git lens) | Navigate to a git repo directory |
272
+ | E002 | error | No commits found in time window (git lens) | Increase --days or check filters |
273
+ | E003 | error | No decisions found in any source (decision lens) | Check wiki/specs content, or provide --id |
274
+ | E004 | error | --id not found in wiki or lessons (decision lens) | Verify the decision ID exists |
275
+ | W001 | warning | `.workflow/learning/` not found, bootstrapping | Auto-created; proceed normally |
276
+ | W002 | warning | No prior retro report for comparison | Skip trend section; first retro establishes baseline |
277
+ | W003 | warning | One perspective agent failed — partial evaluation (decision lens) | Proceed with available perspectives |
278
+ | W004 | warning | No git implementation evidence for a decision | Evaluation is theoretical only |
279
+ | W005 | warning | Phase context files not found (decision lens) | Skip phase-context decisions |
280
+ </error_codes>
281
+
282
+ <success_criteria>
283
+ - [ ] Lens selection parsed correctly (git / decision / all)
284
+ - [ ] Git lens (if active):
285
+ - [ ] All git commands executed successfully
286
+ - [ ] Metrics computed: commits, LOC, test ratio, churn rate, sessions
287
+ - [ ] Sessions detected with >2hr gap clustering
288
+ - [ ] Per-author breakdown generated
289
+ - [ ] Trend comparison computed if prior report exists
290
+ - [ ] At least 1 actionable insight distilled
291
+ - [ ] Decision lens (if active):
292
+ - [ ] Decisions collected from available sources
293
+ - [ ] Scope filter applied correctly
294
+ - [ ] 3 perspective agents spawned in parallel
295
+ - [ ] Each decision classified by lifecycle status
296
+ - [ ] Recommendations generated for non-Validated decisions
297
+ - [ ] Unified report written to `retro-{date}.md`
298
+ - [ ] Structured data written to `retro-{date}.json`
299
+ - [ ] `lessons.jsonl` appended with insights (stable INS-ids)
300
+ - [ ] `learning-index.json` updated
301
+ - [ ] No files modified outside `.workflow/learning/`
302
+ - [ ] Summary displayed with next-step routing
303
+ </success_criteria>