maxsimcli 5.0.7 → 5.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 (91) hide show
  1. package/README.md +101 -99
  2. package/dist/assets/CHANGELOG.md +7 -0
  3. package/dist/assets/hooks/maxsim-capture-learnings.cjs +128 -0
  4. package/dist/assets/hooks/maxsim-capture-learnings.cjs.map +1 -0
  5. package/dist/assets/hooks/maxsim-check-update.cjs +126 -88
  6. package/dist/assets/hooks/maxsim-check-update.cjs.map +1 -1
  7. package/dist/assets/hooks/maxsim-notification-sound.cjs +87 -43
  8. package/dist/assets/hooks/maxsim-notification-sound.cjs.map +1 -1
  9. package/dist/assets/hooks/maxsim-statusline.cjs +45 -171
  10. package/dist/assets/hooks/maxsim-statusline.cjs.map +1 -1
  11. package/dist/assets/hooks/maxsim-stop-sound.cjs +86 -43
  12. package/dist/assets/hooks/maxsim-stop-sound.cjs.map +1 -1
  13. package/dist/assets/hooks/maxsim-sync-reminder.cjs +72 -21
  14. package/dist/assets/hooks/maxsim-sync-reminder.cjs.map +1 -1
  15. package/dist/assets/templates/agents/AGENTS.md +62 -51
  16. package/dist/assets/templates/agents/executor.md +44 -59
  17. package/dist/assets/templates/agents/planner.md +36 -31
  18. package/dist/assets/templates/agents/researcher.md +35 -43
  19. package/dist/assets/templates/agents/verifier.md +29 -31
  20. package/dist/assets/templates/commands/maxsim/debug.md +20 -154
  21. package/dist/assets/templates/commands/maxsim/execute.md +19 -33
  22. package/dist/assets/templates/commands/maxsim/go.md +21 -20
  23. package/dist/assets/templates/commands/maxsim/help.md +5 -14
  24. package/dist/assets/templates/commands/maxsim/init.md +18 -40
  25. package/dist/assets/templates/commands/maxsim/plan.md +22 -37
  26. package/dist/assets/templates/commands/maxsim/progress.md +15 -16
  27. package/dist/assets/templates/commands/maxsim/quick.md +18 -29
  28. package/dist/assets/templates/commands/maxsim/settings.md +18 -26
  29. package/dist/assets/templates/references/continuation-format.md +2 -4
  30. package/dist/assets/templates/references/model-profiles.md +2 -2
  31. package/dist/assets/templates/references/planning-config.md +10 -11
  32. package/dist/assets/templates/references/self-improvement.md +120 -0
  33. package/dist/assets/templates/rules/conventions.md +1 -1
  34. package/dist/assets/templates/rules/verification-protocol.md +1 -1
  35. package/dist/assets/templates/skills/brainstorming/SKILL.md +35 -26
  36. package/dist/assets/templates/skills/code-review/SKILL.md +78 -55
  37. package/dist/assets/templates/skills/commit-conventions/SKILL.md +70 -36
  38. package/dist/assets/templates/skills/github-operations/SKILL.md +142 -0
  39. package/dist/assets/templates/skills/handoff-contract/SKILL.md +62 -28
  40. package/dist/assets/templates/skills/maxsim-batch/SKILL.md +68 -42
  41. package/dist/assets/templates/skills/maxsim-simplify/SKILL.md +65 -40
  42. package/dist/assets/templates/skills/project-memory/SKILL.md +121 -0
  43. package/dist/assets/templates/skills/research/SKILL.md +126 -0
  44. package/dist/assets/templates/skills/roadmap-writing/SKILL.md +71 -68
  45. package/dist/assets/templates/skills/systematic-debugging/SKILL.md +37 -25
  46. package/dist/assets/templates/skills/tdd/SKILL.md +36 -39
  47. package/dist/assets/templates/skills/using-maxsim/SKILL.md +69 -55
  48. package/dist/assets/templates/skills/verification/SKILL.md +167 -0
  49. package/dist/assets/templates/workflows/batch.md +249 -268
  50. package/dist/assets/templates/workflows/diagnose-issues.md +225 -151
  51. package/dist/assets/templates/workflows/execute-plan.md +191 -981
  52. package/dist/assets/templates/workflows/execute.md +350 -309
  53. package/dist/assets/templates/workflows/go.md +119 -138
  54. package/dist/assets/templates/workflows/health.md +71 -114
  55. package/dist/assets/templates/workflows/help.md +85 -147
  56. package/dist/assets/templates/workflows/init-existing.md +180 -1373
  57. package/dist/assets/templates/workflows/init.md +53 -165
  58. package/dist/assets/templates/workflows/new-milestone.md +91 -334
  59. package/dist/assets/templates/workflows/new-project.md +165 -1384
  60. package/dist/assets/templates/workflows/plan-create.md +182 -73
  61. package/dist/assets/templates/workflows/plan-discuss.md +89 -82
  62. package/dist/assets/templates/workflows/plan-research.md +191 -85
  63. package/dist/assets/templates/workflows/plan.md +122 -58
  64. package/dist/assets/templates/workflows/progress.md +76 -310
  65. package/dist/assets/templates/workflows/quick.md +70 -495
  66. package/dist/assets/templates/workflows/sdd.md +231 -221
  67. package/dist/assets/templates/workflows/settings.md +90 -120
  68. package/dist/assets/templates/workflows/verify-phase.md +296 -258
  69. package/dist/cli.cjs +17 -23465
  70. package/dist/cli.cjs.map +1 -1
  71. package/dist/install.cjs +356 -8358
  72. package/dist/install.cjs.map +1 -1
  73. package/package.json +16 -22
  74. package/dist/assets/templates/skills/agent-system-map/SKILL.md +0 -92
  75. package/dist/assets/templates/skills/evidence-collection/SKILL.md +0 -87
  76. package/dist/assets/templates/skills/github-artifact-protocol/SKILL.md +0 -67
  77. package/dist/assets/templates/skills/github-tools-guide/SKILL.md +0 -89
  78. package/dist/assets/templates/skills/input-validation/SKILL.md +0 -51
  79. package/dist/assets/templates/skills/memory-management/SKILL.md +0 -75
  80. package/dist/assets/templates/skills/research-methodology/SKILL.md +0 -137
  81. package/dist/assets/templates/skills/sdd/SKILL.md +0 -91
  82. package/dist/assets/templates/skills/tool-priority-guide/SKILL.md +0 -80
  83. package/dist/assets/templates/skills/verification-before-completion/SKILL.md +0 -71
  84. package/dist/assets/templates/skills/verification-gates/SKILL.md +0 -169
  85. package/dist/assets/templates/workflows/discuss-phase.md +0 -683
  86. package/dist/assets/templates/workflows/research-phase.md +0 -73
  87. package/dist/assets/templates/workflows/verify-work.md +0 -572
  88. package/dist/core-D5zUr9cb.cjs +0 -4305
  89. package/dist/core-D5zUr9cb.cjs.map +0 -1
  90. package/dist/skills-CjFWZIGM.cjs +0 -6824
  91. package/dist/skills-CjFWZIGM.cjs.map +0 -1
@@ -1,11 +1,28 @@
1
1
  <purpose>
2
- Discussion stage sub-workflow for /maxsim:plan. Extracts implementation decisions that downstream agents (researcher, planner) need. Analyzes the phase to identify gray areas, lets the user choose what to discuss, then deep-dives each selected area until satisfied.
2
+ Discussion stage sub-workflow for /maxsim:plan. Extracts implementation decisions that
3
+ downstream agents (researcher, planner) need by analyzing the phase, presenting gray areas
4
+ to the user, and conducting a focused dialogue. Posts the resulting context as a GitHub
5
+ Issue comment with <!-- maxsim:type=context -->.
3
6
 
4
- This file is loaded by the plan.md orchestrator. It does NOT handle gate confirmations or stage routing -- the orchestrator handles that. This sub-workflow focuses ONLY on running the discussion and posting the context decisions to GitHub.
7
+ This file is loaded by the plan.md orchestrator. It does NOT handle gate confirmations or
8
+ stage routing -- the orchestrator handles that. This sub-workflow focuses ONLY on running
9
+ the discussion and posting the context decisions to GitHub.
5
10
 
6
- You are a thinking partner, not an interviewer. The user is the visionary -- you are the builder. Your job is to capture decisions that will guide research and planning, not to figure out implementation yourself.
11
+ GitHub Issues is the sole source of truth. No local CONTEXT.md file is written.
12
+
13
+ You are a thinking partner, not an interviewer. The user is the visionary -- you are the
14
+ builder. Your job is to capture decisions that will guide research and planning, not to
15
+ figure out implementation yourself.
7
16
  </purpose>
8
17
 
18
+ <critical_rules>
19
+ - Tool name is `Agent` (NOT `Task`)
20
+ - Context is posted to GitHub as a comment with <!-- maxsim:type=context -->
21
+ - Use `node ~/.claude/maxsim/bin/maxsim-tools.cjs` for all CLI operations
22
+ - No local CONTEXT.md file is written -- GitHub is the sole source of truth
23
+ - Do NOT show gate confirmation or next steps -- the orchestrator handles those
24
+ </critical_rules>
25
+
9
26
  <required_reading>
10
27
  @~/.claude/maxsim/references/thinking-partner.md
11
28
  </required_reading>
@@ -21,9 +38,11 @@ You are a thinking partner, not an interviewer. The user is the visionary -- you
21
38
  - "Pull-to-refresh on mobile" -> planner includes that in task specs
22
39
  - "Claude's Discretion: loading skeleton" -> planner can decide approach
23
40
 
24
- **Your job:** Capture decisions clearly enough that downstream agents can act on them without asking the user again.
41
+ **Your job:** Capture decisions clearly enough that downstream agents can act on them without
42
+ asking the user again.
25
43
 
26
- **Not your job:** Figure out HOW to implement. That's what research and planning do with the decisions you capture.
44
+ **Not your job:** Figure out HOW to implement. That's what research and planning do with the
45
+ decisions you capture.
27
46
  </downstream_awareness>
28
47
 
29
48
  <philosophy>
@@ -50,26 +69,13 @@ Ask about vision and implementation choices. Capture decisions for downstream ag
50
69
  - **Make consequences visible** -- "Infinite scroll means no shareable page positions."
51
70
  - **Disagree constructively** -- If an approach has risks, name them.
52
71
  - **Follow the thread** -- Build on what they just said. Don't jump topics.
53
-
54
- Apply these behaviors within each discussion area. The user should feel like they're thinking through decisions with a collaborator, not answering a survey.
55
72
  </philosophy>
56
73
 
57
74
  <scope_guardrail>
58
75
  **CRITICAL: No scope creep.**
59
76
 
60
- The phase boundary comes from ROADMAP.md and is FIXED. Discussion clarifies HOW to implement what's scoped, never WHETHER to add new capabilities.
61
-
62
- **Allowed (clarifying ambiguity):**
63
- - "How should posts be displayed?" (layout, density, info shown)
64
- - "What happens on empty state?" (within the feature)
65
- - "Pull to refresh or manual?" (behavior choice)
66
-
67
- **Not allowed (scope creep):**
68
- - "Should we also add comments?" (new capability)
69
- - "What about search/filtering?" (new capability)
70
- - "Maybe include bookmarking?" (new capability)
71
-
72
- **The heuristic:** Does this clarify how we implement what's already in the phase, or does it add a new capability that could be its own phase?
77
+ The phase boundary comes from ROADMAP.md and is FIXED. Discussion clarifies HOW to implement
78
+ what's scoped, never WHETHER to add new capabilities.
73
79
 
74
80
  **When user suggests scope creep:**
75
81
  ```
@@ -83,34 +89,18 @@ Capture the idea in a "Deferred Ideas" section. Don't lose it, don't act on it.
83
89
  </scope_guardrail>
84
90
 
85
91
  <gray_area_identification>
86
- Gray areas are **implementation decisions the user cares about** -- things that could go multiple ways and would change the result.
92
+ Gray areas are **implementation decisions the user cares about** -- things that could go
93
+ multiple ways and would change the result.
87
94
 
88
95
  **How to identify gray areas:**
89
-
90
- 1. **Read the phase goal** from ROADMAP.md
91
- 2. **Understand the domain** -- What kind of thing is being built?
96
+ 1. Read the phase goal from the GitHub Issue description
97
+ 2. Understand the domain -- What kind of thing is being built?
92
98
  - Something users SEE -> visual presentation, interactions, states matter
93
99
  - Something users CALL -> interface contracts, responses, errors matter
94
100
  - Something users RUN -> invocation, output, behavior modes matter
95
101
  - Something users READ -> structure, tone, depth, flow matter
96
102
  - Something being ORGANIZED -> criteria, grouping, handling exceptions matter
97
- 3. **Generate phase-specific gray areas** -- Not generic categories, but concrete decisions for THIS phase
98
-
99
- **Don't use generic category labels** (UI, UX, Behavior). Generate specific gray areas:
100
-
101
- ```
102
- Phase: "User authentication"
103
- -> Session handling, Error responses, Multi-device policy, Recovery flow
104
-
105
- Phase: "Organize photo library"
106
- -> Grouping criteria, Duplicate handling, Naming convention, Folder structure
107
-
108
- Phase: "CLI for database backups"
109
- -> Output format, Flag design, Progress reporting, Error recovery
110
-
111
- Phase: "API documentation"
112
- -> Structure/navigation, Code examples depth, Versioning approach, Interactive elements
113
- ```
103
+ 3. Generate phase-specific gray areas -- Not generic categories, but concrete decisions for THIS phase
114
104
 
115
105
  **The key question:** What decisions would change the outcome that the user should weigh in on?
116
106
 
@@ -128,37 +118,41 @@ Phase: "API documentation"
128
118
  Phase number, name, directory, and GitHub issue number come from the orchestrator context.
129
119
 
130
120
  ```bash
131
- INIT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs init phase-op "${PHASE}")
121
+ PHASE_ISSUE=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs github get-issue \
122
+ --issue-number $PHASE_ISSUE_NUMBER)
132
123
  ```
133
124
 
134
- Parse JSON for: `commit_docs`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`, `has_research`, `has_context`, `has_plans`, `plan_count`, `roadmap_exists`, `planning_exists`.
135
-
136
- Also extract `phase_issue_number` passed from the orchestrator.
125
+ Extract `phase_goal` and `phase_description` from the issue body for use in gray area analysis.
137
126
 
138
- **If `phase_found` is false:** Error -- the orchestrator should have caught this, but fail safe.
127
+ **If issue fetch fails:** Error -- the orchestrator should have caught this, but fail safe:
128
+ ```
129
+ Cannot read phase issue #{phase_issue_number}. Check GitHub connection.
130
+ ```
139
131
 
140
132
  ## Step 2: Check Existing Context
141
133
 
142
- Check if a context comment already exists on the phase GitHub Issue by calling:
134
+ Check if a context comment already exists on the phase GitHub Issue:
143
135
  ```bash
144
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github get-issue --issue-number $PHASE_ISSUE_NUMBER --include-comments
136
+ ISSUE_DATA=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs github get-issue \
137
+ --issue-number $PHASE_ISSUE_NUMBER --include-comments)
145
138
  ```
146
139
 
147
- Look for a comment that contains `<!-- maxsim:type=context -->`.
140
+ Look for a comment containing `<!-- maxsim:type=context -->`.
148
141
 
149
142
  **If a context comment exists:**
150
143
 
151
144
  Ask the user (via natural conversation):
152
145
  ```
153
146
  Phase {phase_number} already has context on GitHub Issue #{phase_issue_number}. What would you like to do?
147
+
154
148
  1. Update it -- review and revise existing context
155
149
  2. View it -- show me what's there
156
150
  3. Use as-is -- keep existing context and return to orchestrator
157
151
  ```
158
152
 
159
- - If "Update": Load existing context comment content, continue to Step 3.
153
+ - If "Update": Load existing context comment content, continue to Step 3 with it pre-loaded.
160
154
  - If "View": Display context comment contents, then offer update/use-as-is.
161
- - If "Use as-is": Return control to orchestrator.
155
+ - If "Use as-is": Return control to orchestrator (display "Using existing context from Issue #{phase_issue_number}.").
162
156
 
163
157
  **If no context comment exists:** Continue to Step 3.
164
158
 
@@ -166,15 +160,22 @@ Phase {phase_number} already has context on GitHub Issue #{phase_issue_number}.
166
160
 
167
161
  Analyze the phase to identify gray areas worth discussing.
168
162
 
169
- **Read the phase description from ROADMAP.md and determine:**
163
+ **Read the phase description from the GitHub Issue and determine:**
170
164
 
171
165
  1. **Domain boundary** -- What capability is this phase delivering? State it clearly.
172
166
 
173
- 2. **Gray areas by category** -- For each relevant category, identify 1-2 specific ambiguities that would change implementation.
167
+ 2. **Gray areas** -- For each relevant decision area, identify 1-2 specific ambiguities
168
+ that would change implementation. Generate phase-specific areas, not generic labels.
174
169
 
175
- 3. **Skip assessment** -- If no meaningful gray areas exist (pure infrastructure, clear-cut implementation), note this but still present options.
170
+ Examples:
171
+ - Phase "User authentication": Session handling, Error responses, Multi-device policy, Recovery flow
172
+ - Phase "CLI for database backups": Output format, Flag design, Progress reporting, Error recovery
173
+ - Phase "API documentation": Structure/navigation, Code examples depth, Versioning approach
176
174
 
177
- **Output your analysis internally, then present to user.**
175
+ 3. **Skip assessment** -- If no meaningful gray areas exist (pure infrastructure, clear-cut
176
+ implementation), note this but still present options.
177
+
178
+ Output your analysis internally, then proceed to Step 4.
178
179
 
179
180
  ## Step 4: Present Gray Areas
180
181
 
@@ -198,10 +199,10 @@ Which areas do you want to discuss for {phase_name}?
198
199
  3. {Specific area 3} -- {what decisions this covers}
199
200
  4. {Specific area 4} -- {what decisions this covers}
200
201
 
201
- Select by number (e.g., "1, 3" or "all").
202
+ Select by number (e.g., "1, 3" or "all"). Or say "skip" to proceed without discussion.
202
203
  ```
203
204
 
204
- Generate 3-4 **phase-specific** gray areas, not generic categories. Each should be a concrete decision area.
205
+ Generate 3-4 **phase-specific** gray areas -- concrete decision areas, not generic labels.
205
206
 
206
207
  ## Step 5: Discuss Areas
207
208
 
@@ -209,7 +210,8 @@ For each selected area, conduct a focused discussion loop.
209
210
 
210
211
  **Philosophy: 4 questions, then check.**
211
212
 
212
- Ask 4 questions per area before offering to continue or move on. Each answer often reveals the next question.
213
+ Ask 4 questions per area before offering to continue or move on. Each answer often reveals
214
+ the next question.
213
215
 
214
216
  **For each area:**
215
217
 
@@ -226,6 +228,8 @@ Ask 4 questions per area before offering to continue or move on. Each answer oft
226
228
  3. **After 4 questions, check:**
227
229
  ```
228
230
  More questions about {area}, or move to next?
231
+ 1. More questions
232
+ 2. Next area
229
233
  ```
230
234
  - If "More" -> ask 4 more, then check again
231
235
  - If "Next" -> proceed to next selected area
@@ -242,18 +246,12 @@ Ask 4 questions per area before offering to continue or move on. Each answer oft
242
246
  - If "Ready": Proceed to Step 6.
243
247
 
244
248
  **Adaptive probing (thinking-partner mode):**
245
-
246
- Within each area, adapt your questioning based on the user's certainty level:
247
249
  - **User is confident** (picks options quickly) -- probe deeper: "You chose X -- have you considered how that interacts with Y?"
248
250
  - **User is uncertain** (hedges) -- propose alternatives: "Here are 3 approaches with trade-offs..."
249
251
  - **User defers** (picks "You decide") -- accept but name consequences: "I'll go with X because [reason]. That means Y."
250
252
 
251
- Challenge decisions that may have hidden costs. If the user picks something that conflicts with an earlier decision, surface it: "Earlier you said A, but this implies B. Which takes priority?"
252
-
253
- **Question design:**
254
- - Options should be concrete, not abstract ("Cards" not "Option A")
255
- - Each answer should inform the next question
256
- - If user gives free text, reflect it back and confirm
253
+ Challenge decisions that may have hidden costs. If the user picks something that conflicts
254
+ with an earlier decision, surface it: "Earlier you said A, but this implies B. Which takes priority?"
257
255
 
258
256
  **Scope creep handling:**
259
257
  If user mentions something outside the phase domain:
@@ -265,19 +263,18 @@ Back to [current area]: [return to current question]"
265
263
  ```
266
264
 
267
265
  Track deferred ideas internally.
268
- </process>
269
266
 
270
267
  ## Step 6: Post Context to GitHub
271
268
 
272
269
  Build the context content in memory, then post it as a comment on the phase GitHub Issue.
273
270
 
274
- **Structure the content by what was discussed:**
271
+ **Structure the context content:**
275
272
 
276
273
  ```markdown
277
274
  <!-- maxsim:type=context -->
278
275
  # Phase {X} Context: {Name}
279
276
 
280
- **Phase Goal:** {goal from ROADMAP.md}
277
+ **Phase Goal:** {goal from GitHub Issue}
281
278
  **Created:** {date}
282
279
  **Requirements:** {requirement IDs if any}
283
280
 
@@ -315,29 +312,39 @@ Build the context content in memory, then post it as a comment on the phase GitH
315
312
  Post the comment to GitHub:
316
313
  ```bash
317
314
  TMPFILE=$(mktemp)
318
- echo "$CONTEXT_CONTENT" > "$TMPFILE"
319
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment --issue-number $PHASE_ISSUE_NUMBER --body-file "$TMPFILE" --type context
315
+ cat > "$TMPFILE" << 'BODY_EOF'
316
+ {context_content}
317
+ BODY_EOF
318
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment \
319
+ --issue-number $PHASE_ISSUE_NUMBER --body-file "$TMPFILE" --type context
320
320
  ```
321
321
 
322
- Context decisions are posted as a GitHub comment on phase issue #{phase_issue_number}. No local CONTEXT.md file is written.
322
+ Context decisions are posted as a GitHub comment on phase issue #{phase_issue_number}.
323
+ No local CONTEXT.md file is written.
323
324
 
324
325
  ## Step 7: Return to Orchestrator
325
326
 
326
- After posting the context comment to GitHub, return control to the plan.md orchestrator. Do NOT show gate confirmation or next steps -- the orchestrator handles the gate between Discussion and Research.
327
+ After posting the context comment to GitHub, return control to the plan.md orchestrator.
328
+ Do NOT show gate confirmation or next steps -- the orchestrator handles the gate between
329
+ Discussion and Research.
327
330
 
328
331
  Display a brief completion message:
329
332
  ```
330
333
  Discussion complete. Context decisions posted to GitHub Issue #{phase_issue_number}.
331
334
  ```
332
335
 
336
+ </process>
337
+
333
338
  <success_criteria>
334
- - Phase validated against roadmap
335
- - Gray areas identified through intelligent analysis (not generic questions)
336
- - User selected which areas to discuss
337
- - Each selected area explored until user satisfied
338
- - Scope creep redirected to deferred ideas
339
- - Context comment captures actual decisions (not vague vision) with <!-- maxsim:type=context --> marker
340
- - Context posted to GitHub Issue #{phase_issue_number} as a comment (no local CONTEXT.md written)
341
- - Deferred ideas preserved for future phases
342
- - Control returned to orchestrator without showing gate or next steps
339
+ - [ ] Phase description read from GitHub Issue (not local ROADMAP.md)
340
+ - [ ] Existing context comment detected from GitHub Issue and handled (update/view/use-as-is)
341
+ - [ ] Gray areas identified through intelligent phase analysis (not generic questions)
342
+ - [ ] User selected which areas to discuss
343
+ - [ ] Each selected area explored with 4-question depth, adaptive probing applied
344
+ - [ ] Scope creep redirected to deferred ideas
345
+ - [ ] Context comment captures actual decisions (not vague vision) with <!-- maxsim:type=context --> marker
346
+ - [ ] Context posted to GitHub Issue #{phase_issue_number} as a comment (no local CONTEXT.md written)
347
+ - [ ] Deferred ideas preserved in context comment
348
+ - [ ] Control returned to orchestrator without showing gate or next steps
349
+ - [ ] Agent tool used (not Task) for any agent spawning
343
350
  </success_criteria>
@@ -1,9 +1,26 @@
1
1
  <purpose>
2
- Research stage sub-workflow for /maxsim:plan. Spawns the researcher agent with phase context to produce research findings, then posts them to GitHub as a comment on the phase issue.
2
+ Research stage sub-workflow for /maxsim:plan. Spawns 5-10 parallel researcher agents (using
3
+ Agent tool with run_in_background=true) to investigate different aspects of the phase in
4
+ parallel, aggregates their findings, and posts the consolidated research to GitHub as a comment
5
+ with <!-- maxsim:type=research -->.
3
6
 
4
- This file is loaded by the plan.md orchestrator. It does NOT handle gate confirmations or stage routing -- the orchestrator handles that. This sub-workflow focuses ONLY on running research and posting the output to GitHub.
7
+ This file is loaded by the plan.md orchestrator. It does NOT handle gate confirmations or
8
+ stage routing -- the orchestrator handles that. This sub-workflow focuses ONLY on running
9
+ research and posting the output to GitHub.
10
+
11
+ GitHub Issues is the sole source of truth. No local RESEARCH.md file is written.
5
12
  </purpose>
6
13
 
14
+ <critical_rules>
15
+ - Tool name is `Agent` (NOT `Task`)
16
+ - Agent spawning: Agent(prompt, model, isolation, run_in_background)
17
+ - Parallel agents use run_in_background=true, then collect results
18
+ - Research is posted to GitHub with <!-- maxsim:type=research -->
19
+ - Use `node ~/.claude/maxsim/bin/maxsim-tools.cjs` for all CLI operations
20
+ - No local RESEARCH.md file is written -- GitHub is the sole source of truth
21
+ - Do NOT show gate confirmation or next steps -- the orchestrator handles those
22
+ </critical_rules>
23
+
7
24
  <process>
8
25
 
9
26
  ## Step 1: Check Prerequisites
@@ -13,7 +30,7 @@ The orchestrator provides phase context. Verify we have what we need:
13
30
  - `phase_number`, `phase_name`, `phase_dir`, `padded_phase`, `phase_slug`
14
31
  - `researcher_model`, `research_enabled`
15
32
  - `has_research` (whether a research comment already exists on the phase issue)
16
- - `state_path`, `roadmap_path`, `requirements_path`, `context_path`
33
+ - `state_path`, `roadmap_path`, `requirements_path`
17
34
  - `phase_req_ids` (requirement IDs that this phase must address)
18
35
  - `phase_issue_number` (GitHub Issue number for the phase)
19
36
  - `--force-research` flag presence
@@ -26,7 +43,9 @@ RESEARCHER_MODEL=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs resolve-model rese
26
43
 
27
44
  ## Step 3: Check Existing Research
28
45
 
29
- Determine whether a research comment already exists on the phase GitHub Issue by checking for a comment containing `<!-- maxsim:type=research -->`. This is reflected in the `has_research` flag passed from the orchestrator (which performs the GitHub query).
46
+ Determine whether a research comment already exists on the phase GitHub Issue by checking
47
+ for a comment containing `<!-- maxsim:type=research -->`. This is reflected in the
48
+ `has_research` flag passed from the orchestrator.
30
49
 
31
50
  **If `has_research` is true AND `--force-research` is NOT set:**
32
51
 
@@ -55,124 +74,211 @@ Skipping research stage.
55
74
 
56
75
  Return control to orchestrator.
57
76
 
58
- ## Step 4: Gather Phase Context
77
+ ## Step 4: Read Phase Context from GitHub
78
+
79
+ Fetch the phase issue with all comments to extract context for research scoping:
59
80
 
60
81
  ```bash
61
- PHASE_DESC=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs roadmap get-phase "${PHASE}" 2>/dev/null)
82
+ ISSUE_DATA=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs github get-issue \
83
+ --issue-number $PHASE_ISSUE_NUMBER --include-comments)
62
84
  ```
63
85
 
64
- Extract the phase section/description from the JSON output for the researcher prompt.
86
+ Extract from the response:
87
+ - Phase goal and description from the issue body
88
+ - Context comment content (from the `<!-- maxsim:type=context -->` comment, if present)
89
+
90
+ The context comment determines WHAT to research: user decisions lock certain approaches,
91
+ guiding researchers away from alternatives.
92
+
93
+ ## Step 5: Define Research Domains
94
+
95
+ Based on the phase description and context decisions, identify 5-10 distinct research domains.
96
+ Each domain should be independently investigatable by a separate agent.
65
97
 
66
- ## Step 5: Spawn Researcher
98
+ **Research domain categories (select those relevant to this phase):**
99
+
100
+ 1. **Existing code patterns** -- How is similar functionality implemented in the codebase?
101
+ File structure, naming conventions, module patterns used.
102
+ 2. **Dependencies & libraries** -- What packages/APIs are already available? Which to use?
103
+ 3. **API contracts** -- External service interfaces, response shapes, error codes.
104
+ 4. **Test patterns** -- How are tests written for this type of code? Coverage expectations.
105
+ 5. **Data models** -- Existing schema, types, validation patterns relevant to the phase.
106
+ 6. **Integration points** -- Where does this phase connect to existing systems?
107
+ 7. **Security & validation** -- Input validation patterns, auth flows, edge cases.
108
+ 8. **Performance considerations** -- Known bottlenecks, caching patterns, query patterns.
109
+ 9. **Configuration & environment** -- Config file patterns, env vars, feature flags.
110
+ 10. **Error handling** -- How errors surface, logging patterns, user-facing error formats.
111
+
112
+ Select 5-10 domains most relevant to this phase. Define a focused research question for each.
113
+
114
+ ## Step 6: Spawn Parallel Research Agents
67
115
 
68
116
  Display:
69
117
  ```
70
118
  Researching Phase {phase_number}: {phase_name}...
119
+ Spawning {N} parallel research agents...
71
120
  ```
72
121
 
73
- Construct the research prompt. The researcher must return its findings as a structured markdown document (not write to a local file -- the orchestrator will post findings to GitHub):
122
+ Spawn each researcher as a background Agent. All agents run in parallel:
74
123
 
75
- ```markdown
76
- <objective>
77
- Research how to implement Phase {phase_number}: {phase_name}
78
- Answer: "What do I need to know to PLAN this phase well?"
79
- </objective>
124
+ ```
125
+ Agent(
126
+ prompt="<objective>
127
+ Research Domain: {domain_name}
128
+ Phase: {phase_number} -- {phase_name}
80
129
 
81
- <files_to_read>
82
- - GitHub Issue #{phase_issue_number} context comment (USER DECISIONS -- locked choices that constrain research)
83
- - {requirements_path} (Project requirements)
84
- - {state_path} (Project decisions and history)
85
- </files_to_read>
130
+ Research Question: {focused question for this domain}
86
131
 
87
- <additional_context>
88
- **Phase description:** {phase_description from PHASE_DESC}
89
- **Phase requirement IDs (MUST address):** {phase_req_ids}
132
+ <context>
133
+ Phase Goal: {phase_goal}
134
+ User Decisions (from context comment): {key decisions that constrain this domain}
135
+ Phase Requirements: {phase_req_ids}
136
+ </context>
90
137
 
91
- **Project instructions:** Read ./CLAUDE.md if exists -- follow project-specific guidelines
92
- **Project skills:** Check .skills/ directory (if exists) -- read SKILL.md files, research should account for project skill patterns
93
- </additional_context>
138
+ <instructions>
139
+ Investigate this specific domain. Use Read, Grep, Glob to explore the codebase.
140
+ Use WebFetch for external documentation if needed.
94
141
 
95
- <output>
96
- Return findings as a structured markdown document in your response.
97
- Do NOT write to a local file -- findings will be posted to GitHub by the orchestrator.
98
- </output>
99
- ```
142
+ Focus on: what the planner needs to know to create correct tasks for this domain.
143
+ Answer the research question with evidence from the codebase or official sources.
100
144
 
101
- Spawn the researcher:
145
+ <output_format>
146
+ Return findings as structured markdown:
102
147
 
103
- ```
104
- Task(
105
- prompt=research_prompt,
106
- subagent_type="researcher",
148
+ ## {Domain Name}
149
+
150
+ **Research Question:** {question}
151
+ **Confidence:** HIGH | MEDIUM | LOW
152
+
153
+ ### Findings
154
+ {evidence-backed findings}
155
+
156
+ ### Recommended Approach
157
+ {what the planner should do, based on findings}
158
+
159
+ ### Pitfalls
160
+ {known risks or gotchas to avoid}
161
+
162
+ ### Open Questions
163
+ {anything that needs user decision or remains uncertain}
164
+ </output_format>
165
+ </instructions>",
107
166
  model="{researcher_model}",
108
- description="Research Phase {phase_number}"
167
+ isolation=true,
168
+ run_in_background=true
109
169
  )
110
170
  ```
111
171
 
112
- ## Step 6: Handle Researcher Return
172
+ Spawn all research agents in parallel using `run_in_background=true`. Do not await any
173
+ individual agent before spawning the next.
174
+
175
+ ## Step 7: Collect and Aggregate Findings
176
+
177
+ After all background agents complete, collect their results.
113
178
 
114
- Parse the researcher's return message:
179
+ For each agent result:
180
+ - Extract the domain findings markdown
181
+ - Note the confidence level (HIGH/MEDIUM/LOW)
182
+ - Note any open questions flagged by the agent
115
183
 
116
- - **`## RESEARCH COMPLETE`:**
117
- Extract the research findings document from the researcher's response.
184
+ **Aggregate into a consolidated research document:**
185
+
186
+ ```markdown
187
+ <!-- maxsim:type=research -->
188
+ # Phase {X} Research: {Name}
118
189
 
119
- Post research findings to GitHub:
120
- ```bash
121
- TMPFILE=$(mktemp)
122
- cat > "$TMPFILE" << 'BODY_EOF'
123
- <!-- maxsim:type=research -->
124
- {research_findings_document}
125
- BODY_EOF
126
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment --issue-number $PHASE_ISSUE_NUMBER --body-file "$TMPFILE" --type research
127
- ```
190
+ **Phase Goal:** {goal}
191
+ **Researched:** {date}
192
+ **Domains investigated:** {N}
193
+ **Overall confidence:** {HIGH if all HIGH, MEDIUM if mixed, LOW if any LOW}
128
194
 
129
- Research findings are posted as a GitHub comment on phase issue #{phase_issue_number}. No local RESEARCH.md file is written.
195
+ ## Summary
130
196
 
131
- Display confirmation:
132
- ```
133
- Research complete. Findings posted to GitHub Issue #{phase_issue_number}.
134
- ```
197
+ {3-5 bullet executive summary of the most important findings}
135
198
 
136
- Return control to orchestrator.
199
+ ---
137
200
 
138
- - **`## RESEARCH BLOCKED`:**
139
- Display the blocker reason. Offer options:
140
- ```
141
- Research blocked: {reason}
201
+ {Insert each domain findings section in order of relevance}
142
202
 
143
- 1. Provide additional context and retry
144
- 2. Skip research and proceed to planning
145
- 3. Abort
146
- ```
147
- Wait for user choice.
203
+ ---
148
204
 
149
- - If "Provide context": Get additional info, re-spawn researcher with augmented prompt.
150
- - If "Skip": Return to orchestrator without posting research comment.
151
- - If "Abort": Exit workflow.
205
+ ## Synthesis: Key Decisions for Planner
152
206
 
153
- - **`## RESEARCH INCONCLUSIVE`:**
154
- Display what was attempted. Offer:
155
- ```
156
- Research inconclusive after {N} attempts.
207
+ {Cross-cutting decisions the planner should make, derived from aggregate findings}
208
+
209
+ | Decision | Recommended | Rationale |
210
+ |----------|-------------|-----------|
211
+ | {decision area} | {what to do} | {why, from evidence} |
212
+
213
+ ## Open Questions
214
+
215
+ {Unresolved questions that require user input or further investigation}
216
+
217
+ ---
218
+ *Research created: {date}*
219
+ *Agents: {N} researchers across {N} domains*
220
+ ```
221
+
222
+ ## Step 8: Post Research to GitHub
223
+
224
+ Post the consolidated research as a comment on the phase GitHub Issue:
225
+
226
+ ```bash
227
+ TMPFILE=$(mktemp)
228
+ cat > "$TMPFILE" << 'BODY_EOF'
229
+ {consolidated_research_document}
230
+ BODY_EOF
231
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment \
232
+ --issue-number $PHASE_ISSUE_NUMBER --body-file "$TMPFILE" --type research
233
+ ```
234
+
235
+ Research findings are posted as a GitHub comment on phase issue #{phase_issue_number}.
236
+ No local RESEARCH.md file is written.
237
+
238
+ Display confirmation:
239
+ ```
240
+ Research complete. Findings from {N} agents posted to GitHub Issue #{phase_issue_number}.
241
+ ```
242
+
243
+ ## Step 9: Handle Agent Failures
244
+
245
+ If any research agent fails or returns no findings:
246
+
247
+ - Log which domain failed: "Agent for '{domain}' returned no findings."
248
+ - Continue with findings from the agents that did succeed.
249
+ - Note the failed domain in the research document under "Incomplete Research".
250
+ - Do NOT block progress on a single failed agent -- partial research is better than none.
251
+
252
+ If more than half the agents fail:
253
+ ```
254
+ Research partially failed. Only {N}/{total} agents returned findings.
255
+
256
+ 1. Retry failed agents
257
+ 2. Proceed with partial research
258
+ 3. Skip research and proceed to planning
259
+ ```
157
260
 
158
- 1. Provide more context and retry
159
- 2. Skip research
160
- 3. Abort
161
- ```
162
- Handle same as BLOCKED options.
261
+ Wait for user choice.
163
262
 
164
- ## Step 7: Return to Orchestrator
263
+ ## Step 10: Return to Orchestrator
165
264
 
166
- After research is posted to GitHub (or research is skipped), return control to the plan.md orchestrator. Do NOT show gate confirmation or next steps -- the orchestrator handles the gate between Research and Planning.
265
+ After research is posted to GitHub (or research is skipped), return control to the plan.md
266
+ orchestrator. Do NOT show gate confirmation or next steps -- the orchestrator handles the gate
267
+ between Research and Planning.
167
268
 
168
269
  </process>
169
270
 
170
271
  <success_criteria>
171
- - Researcher model resolved from config
172
- - Existing research detected from GitHub Issue comment (<!-- maxsim:type=research --> marker) and reused unless --force-research
173
- - researcher agent spawned with full context (GitHub context comment, requirements, state)
174
- - Research findings returned from researcher as document, then posted as GitHub comment on Issue #{phase_issue_number}
175
- - No local RESEARCH.md file written
176
- - Blocked/inconclusive scenarios handled with user options
177
- - Control returned to orchestrator without showing gate or next steps
272
+ - [ ] Researcher model resolved from config
273
+ - [ ] Existing research detected from GitHub Issue comment (<!-- maxsim:type=research --> marker) and reused unless --force-research
274
+ - [ ] Phase context read from GitHub Issue (context comment + issue body)
275
+ - [ ] 5-10 research domains defined based on phase characteristics
276
+ - [ ] All research agents spawned in parallel using run_in_background=true
277
+ - [ ] Agent tool used (not Task) for all agent spawning
278
+ - [ ] Each agent investigates a distinct, focused domain
279
+ - [ ] Agent failures handled gracefully -- partial research does not block progress
280
+ - [ ] Findings aggregated into consolidated research document
281
+ - [ ] Research document posted as GitHub comment with <!-- maxsim:type=research --> marker
282
+ - [ ] No local RESEARCH.md file written
283
+ - [ ] Control returned to orchestrator without showing gate or next steps
178
284
  </success_criteria>