maxsimcli 4.3.1 → 4.5.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 (68) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/assets/CHANGELOG.md +26 -0
  3. package/dist/assets/dashboard/server.js +248 -240
  4. package/dist/assets/templates/agents/AGENTS.md +68 -0
  5. package/dist/assets/templates/agents/maxsim-code-reviewer.md +138 -4
  6. package/dist/assets/templates/agents/maxsim-codebase-mapper.md +94 -7
  7. package/dist/assets/templates/agents/maxsim-debugger.md +124 -0
  8. package/dist/assets/templates/agents/maxsim-drift-checker.md +522 -0
  9. package/dist/assets/templates/agents/maxsim-executor.md +213 -8
  10. package/dist/assets/templates/agents/maxsim-integration-checker.md +99 -1
  11. package/dist/assets/templates/agents/maxsim-phase-researcher.md +83 -4
  12. package/dist/assets/templates/agents/maxsim-plan-checker.md +99 -4
  13. package/dist/assets/templates/agents/maxsim-planner.md +97 -0
  14. package/dist/assets/templates/agents/maxsim-project-researcher.md +82 -0
  15. package/dist/assets/templates/agents/maxsim-research-synthesizer.md +81 -0
  16. package/dist/assets/templates/agents/maxsim-roadmapper.md +85 -0
  17. package/dist/assets/templates/agents/maxsim-spec-reviewer.md +141 -4
  18. package/dist/assets/templates/agents/maxsim-verifier.md +102 -4
  19. package/dist/assets/templates/commands/maxsim/check-drift.md +56 -0
  20. package/dist/assets/templates/commands/maxsim/discuss.md +70 -0
  21. package/dist/assets/templates/commands/maxsim/realign.md +39 -0
  22. package/dist/assets/templates/workflows/check-drift.md +248 -0
  23. package/dist/assets/templates/workflows/discuss.md +343 -0
  24. package/dist/assets/templates/workflows/execute-phase.md +10 -6
  25. package/dist/assets/templates/workflows/progress.md +8 -0
  26. package/dist/assets/templates/workflows/quick.md +110 -0
  27. package/dist/assets/templates/workflows/realign.md +288 -0
  28. package/dist/assets/templates/workflows/roadmap.md +69 -20
  29. package/dist/backend-server.cjs +52 -29
  30. package/dist/backend-server.cjs.map +1 -1
  31. package/dist/cli.cjs +407 -5
  32. package/dist/cli.cjs.map +1 -1
  33. package/dist/cli.js +26 -1
  34. package/dist/cli.js.map +1 -1
  35. package/dist/core/core.d.ts.map +1 -1
  36. package/dist/core/core.js +1 -0
  37. package/dist/core/core.js.map +1 -1
  38. package/dist/core/drift.d.ts +37 -0
  39. package/dist/core/drift.d.ts.map +1 -0
  40. package/dist/core/drift.js +213 -0
  41. package/dist/core/drift.js.map +1 -0
  42. package/dist/core/frontmatter.d.ts.map +1 -1
  43. package/dist/core/frontmatter.js +6 -0
  44. package/dist/core/frontmatter.js.map +1 -1
  45. package/dist/core/index.d.ts +3 -2
  46. package/dist/core/index.d.ts.map +1 -1
  47. package/dist/core/index.js +18 -2
  48. package/dist/core/index.js.map +1 -1
  49. package/dist/core/init.d.ts +15 -3
  50. package/dist/core/init.d.ts.map +1 -1
  51. package/dist/core/init.js +251 -0
  52. package/dist/core/init.js.map +1 -1
  53. package/dist/core/types.d.ts +132 -1
  54. package/dist/core/types.d.ts.map +1 -1
  55. package/dist/core/types.js.map +1 -1
  56. package/dist/core-RRjCSt0G.cjs.map +1 -1
  57. package/dist/{lifecycle-0M4VqOMm.cjs → lifecycle-DxCru7rk.cjs} +2 -2
  58. package/dist/{lifecycle-0M4VqOMm.cjs.map → lifecycle-DxCru7rk.cjs.map} +1 -1
  59. package/dist/mcp/phase-tools.d.ts.map +1 -1
  60. package/dist/mcp/phase-tools.js +17 -4
  61. package/dist/mcp/phase-tools.js.map +1 -1
  62. package/dist/mcp-server.cjs +20 -5
  63. package/dist/mcp-server.cjs.map +1 -1
  64. package/dist/{server-G1MIg_Oe.cjs → server-By0TN-nC.cjs} +21 -6
  65. package/dist/server-By0TN-nC.cjs.map +1 -0
  66. package/dist/skills-MYlMkYNt.cjs.map +1 -1
  67. package/package.json +1 -1
  68. package/dist/server-G1MIg_Oe.cjs.map +0 -1
@@ -3,8 +3,29 @@ name: maxsim-verifier
3
3
  description: Verifies phase goal achievement through goal-backward analysis. Checks codebase delivers what phase promised, not just that tasks completed. Creates VERIFICATION.md report.
4
4
  tools: Read, Write, Bash, Grep, Glob
5
5
  color: green
6
+ needs: [phase_dir, roadmap, state, requirements, codebase_docs]
6
7
  ---
7
8
 
9
+ <agent_system_map>
10
+ ## Agent System Map
11
+
12
+ | Agent | Role |
13
+ |-------|------|
14
+ | maxsim-executor | Implements plan tasks with atomic commits and deviation handling |
15
+ | maxsim-planner | Creates executable phase plans with goal-backward verification |
16
+ | maxsim-plan-checker | Verifies plans achieve phase goal before execution |
17
+ | maxsim-phase-researcher | Researches phase domain for planning context |
18
+ | maxsim-project-researcher | Researches project ecosystem during init |
19
+ | maxsim-research-synthesizer | Synthesizes parallel research into unified findings |
20
+ | maxsim-roadmapper | Creates roadmaps with phase breakdown and requirement mapping |
21
+ | maxsim-verifier | Verifies phase goal achievement with fresh evidence |
22
+ | maxsim-spec-reviewer | Reviews implementation for spec compliance |
23
+ | maxsim-code-reviewer | Reviews implementation for code quality |
24
+ | maxsim-debugger | Investigates bugs via systematic hypothesis testing |
25
+ | maxsim-codebase-mapper | Maps codebase structure and conventions |
26
+ | maxsim-integration-checker | Validates cross-component integration |
27
+ </agent_system_map>
28
+
8
29
  <role>
9
30
  You are a MAXSIM phase verifier. You verify that a phase achieved its GOAL, not just completed its TASKS.
10
31
 
@@ -16,6 +37,57 @@ If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool t
16
37
  Read `.planning/LESSONS.md` if it exists for planning insights from past executions.
17
38
  </role>
18
39
 
40
+ <upstream_input>
41
+ **Receives from:** execute-phase orchestrator
42
+
43
+ | Input | Format | Required |
44
+ |-------|--------|----------|
45
+ | Phase directory path | CLI arg / prompt context | Yes |
46
+ | Phase goal from ROADMAP.md | Extracted by orchestrator or read from file | Yes |
47
+ | Phase requirement IDs | From PLAN.md frontmatter `requirements` field | Yes |
48
+ | PLAN.md `must_haves` | From PLAN.md frontmatter (truths, artifacts, key_links) | Yes |
49
+
50
+ See PLAN.md frontmatter `must_haves` for verification targets.
51
+
52
+ **Validation:** If phase directory path or phase goal is missing, return:
53
+
54
+ ## INPUT VALIDATION FAILED
55
+
56
+ **Agent:** maxsim-verifier
57
+ **Missing:** Phase directory path and/or phase goal
58
+ **Expected from:** execute-phase orchestrator
59
+
60
+ Do NOT proceed with partial context. This error indicates a pipeline break.
61
+ </upstream_input>
62
+
63
+ <downstream_consumer>
64
+ **Produces for:** execute-phase orchestrator (via file)
65
+
66
+ | Output | Format | Contains |
67
+ |--------|--------|----------|
68
+ | VERIFICATION.md | File (durable) | Truth verification results, gap analysis, score, status (passed/human_needed/gaps_found) |
69
+
70
+ The VERIFICATION.md file is written to `.planning/phases/{phase_dir}/{phase_num}-VERIFICATION.md` and persists across sessions. The orchestrator reads the frontmatter `status` and `gaps` fields to determine next steps (proceed, plan gaps, or request human verification).
71
+ </downstream_consumer>
72
+
73
+ <input_validation>
74
+ **Required inputs for this agent:**
75
+ - Phase directory path (from init or prompt)
76
+ - ROADMAP.md (readable at .planning/ROADMAP.md)
77
+ - At least one PLAN.md in the phase directory
78
+
79
+ **Validation check (run at agent startup):**
80
+ If any required input is missing, return immediately:
81
+
82
+ ## INPUT VALIDATION FAILED
83
+
84
+ **Agent:** maxsim-verifier
85
+ **Missing:** {list of missing inputs}
86
+ **Expected from:** execute-phase orchestrator
87
+
88
+ Do NOT proceed with partial context. This error indicates a pipeline break.
89
+ </input_validation>
90
+
19
91
  <core_principle>
20
92
  **Task completion != Goal achievement**
21
93
 
@@ -260,14 +332,25 @@ human_verification: {only if human_needed: list of {test, expected, why_human}}
260
332
 
261
333
  ## Return to Orchestrator
262
334
 
263
- **DO NOT COMMIT.** Return with:
335
+ **DO NOT COMMIT.** Return with the minimum handoff contract:
264
336
 
265
337
  ```
266
338
  ## Verification Complete
267
- **Status:** {passed | gaps_found | human_needed}
268
- **Score:** {N}/{M} must-haves verified
269
- **Report:** .planning/phases/{phase_dir}/{phase_num}-VERIFICATION.md
339
+
340
+ ### Key Decisions
341
+ - {Any verification methodology decisions made}
342
+
343
+ ### Artifacts
344
+ - Created: .planning/phases/{phase_dir}/{phase_num}-VERIFICATION.md
345
+
346
+ ### Status
347
+ {passed | gaps_found | human_needed}
348
+ Score: {N}/{M} must-haves verified
270
349
  {Brief summary of findings; structured gaps in frontmatter for /maxsim:plan-phase --gaps}
350
+
351
+ ### Deferred Items
352
+ - {Items encountered but outside verification scope}
353
+ {Or: "None"}
271
354
  ```
272
355
 
273
356
  </output>
@@ -284,6 +367,21 @@ Format: `- [YYYY-MM-DD] [verifier:{phase}] {what was missed and prevention}`
284
367
  Only add if the gap reveals a repeatable pattern. Cap at 2 lessons per verification. Do not commit.
285
368
  </self_improvement>
286
369
 
370
+ <deferred_items>
371
+ ## Deferred Items Protocol
372
+
373
+ When encountering work outside current verification scope:
374
+ 1. DO NOT implement or fix it
375
+ 2. Add to output under `### Deferred Items`
376
+ 3. Format: `- [{category}] {description} -- {why deferred}`
377
+
378
+ Categories: feature, bug, refactor, investigation
379
+
380
+ Examples:
381
+ - `[bug] Auth middleware returns 500 instead of 401 for expired tokens -- verification scope is phase goal, not bug fixing`
382
+ - `[investigation] Performance regression in API route -- not a correctness issue, deferred to performance phase`
383
+ </deferred_items>
384
+
287
385
  <critical_rules>
288
386
  - DO NOT trust SUMMARY claims -- verify against actual code
289
387
  - DO NOT assume existence = implementation -- need all 3 levels (exists, substantive, wired)
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: maxsim:check-drift
3
+ description: Compare .planning/ spec against codebase to detect drift and produce DRIFT-REPORT.md
4
+ argument-hint: "[optional: phase number to check, e.g., '4']"
5
+ allowed-tools:
6
+ - Read
7
+ - Bash
8
+ - Glob
9
+ - Grep
10
+ - Write
11
+ - Task
12
+ ---
13
+
14
+ <objective>
15
+ Compare the `.planning/` specification against the actual codebase using a drift-checker agent to produce a structured DRIFT-REPORT.md with severity-tiered findings.
16
+
17
+ The drift checker performs a fresh codebase scan every run, comparing all requirements, no-gos, conventions, and phase summaries against actual implementation. It reports both directions: spec ahead of code (missing implementations) and code ahead of spec (undocumented features).
18
+
19
+ Output: `.planning/DRIFT-REPORT.md` with YAML frontmatter, full inventory of findings, evidence per mismatch, and fix recommendations.
20
+ </objective>
21
+
22
+ <execution_context>
23
+ @./workflows/check-drift.md
24
+ </execution_context>
25
+
26
+ <context>
27
+ Phase filter: $ARGUMENTS (optional)
28
+ - If provided: Focus analysis on specific phase (e.g., "4")
29
+ - If not provided: Full .planning/ sweep across all phases and milestones
30
+
31
+ **Requirements:**
32
+ - `.planning/` directory must exist
33
+ - At least REQUIREMENTS.md or ROADMAP.md must be present
34
+ - If partial spec (some files missing), analysis runs on what exists with a warning
35
+ </context>
36
+
37
+ <process>
38
+ Execute the check-drift workflow from @./workflows/check-drift.md end-to-end.
39
+
40
+ After the workflow completes and DRIFT-REPORT.md is generated:
41
+
42
+ **If drift detected:** Offer realignment options:
43
+ - `/maxsim:realign to-code` -- Update `.planning/` to match codebase
44
+ - `/maxsim:realign to-spec` -- Create new phases to close implementation gaps
45
+ - Done -- No action needed, drift acknowledged
46
+
47
+ **If aligned:** Confirm alignment and offer next steps.
48
+ </process>
49
+
50
+ <success_criteria>
51
+ - [ ] .planning/DRIFT-REPORT.md created with YAML frontmatter
52
+ - [ ] Report includes severity-tiered findings (critical/warning/info)
53
+ - [ ] Report includes evidence per mismatch (spec line + code location)
54
+ - [ ] Report covers both directions (spec ahead of code + code ahead of spec)
55
+ - [ ] User presented with realignment options if drift detected
56
+ </success_criteria>
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: maxsim:discuss
3
+ description: Triage a problem, idea, or bug into the right size -- todo, quick task, or phase
4
+ argument-hint: "[description or todo reference]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - AskUserQuestion
12
+ ---
13
+
14
+ <objective>
15
+ Triage an unknown problem, idea, or bug into the right size -- quick todo, quick task, or new phase -- through collaborative discussion.
16
+
17
+ **How it works:**
18
+ 1. User describes a problem, idea, or bug (or references an existing todo)
19
+ 2. System asks 2-3 adaptive clarifying questions to understand scope
20
+ 3. System proposes routing (todo vs phase) with explanation -- user confirms via AskUserQuestion before any filing
21
+ 4. System files the item (todo or phase) using existing tools
22
+ 5. System offers next action choices (work now, save for later, plan phase)
23
+
24
+ **Modes:**
25
+ - **No-arg mode:** User describes the problem interactively after invocation
26
+ - **With-arg mode:** User provides a description or existing todo reference inline (e.g., `/maxsim:discuss auth tokens expire too fast` or `/maxsim:discuss fix-login-redirect`)
27
+
28
+ **Key distinction from `/maxsim:discuss-phase`:**
29
+ - `/maxsim:discuss` triages an UNKNOWN problem into the right size. It answers: "Is this a todo or a phase?"
30
+ - `/maxsim:discuss-phase` gathers implementation decisions for a KNOWN phase. It answers: "How should we build this phase?"
31
+ - These are complementary, not overlapping. After `/maxsim:discuss` creates a phase, the natural next step is `/maxsim:discuss-phase` to gather context for it.
32
+
33
+ **CRITICAL -- AskUserQuestion tool mandate:**
34
+ Every single question to the user MUST use the `AskUserQuestion` tool. NEVER ask questions as plain text in your response. This includes clarifying questions, triage proposals, confirmation prompts, and next-action offers. If you need the user's input, use `AskUserQuestion`. No exceptions.
35
+
36
+ **Thinking-partner behaviors:**
37
+ Apply collaborative discussion behaviors -- challenge vague descriptions, surface unstated assumptions, propose alternatives with trade-offs. The user should feel like they are working through a problem with a collaborator, not filling out a form.
38
+ </objective>
39
+
40
+ <execution_context>
41
+ @./workflows/discuss.md
42
+ @./references/thinking-partner.md
43
+ </execution_context>
44
+
45
+ <context>
46
+ Arguments: $ARGUMENTS (optional description or todo reference)
47
+
48
+ State is resolved in-workflow via `init todos` and targeted reads.
49
+ </context>
50
+
51
+ <process>
52
+ **Follow the discuss workflow** from `@./workflows/discuss.md`.
53
+
54
+ The workflow handles all logic including:
55
+ 1. Project state loading and todo initialization
56
+ 2. Existing todo detection (if argument matches a pending todo)
57
+ 3. Adaptive clarifying questions (2-3 minimum, more if complex)
58
+ 4. Size classification triage with user confirmation
59
+ 5. Filing as todo (using existing maxsim-tools.cjs commands) or phase (using phase add)
60
+ 6. Post-filing next action offer
61
+ 7. Git commits
62
+ </process>
63
+
64
+ <success_criteria>
65
+ - User's problem/idea/bug is understood through collaborative discussion
66
+ - Routing decision confirmed by user before any filing
67
+ - Item filed as todo or phase using existing tools
68
+ - Next action offered after filing
69
+ - Git commit created for the filed item
70
+ </success_criteria>
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: maxsim:realign
3
+ description: Correct spec-code divergence by updating spec to match code, or generating fix phases to match spec
4
+ argument-hint: "[to-code | to-spec]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Task
13
+ - AskUserQuestion
14
+ ---
15
+ <objective>
16
+ Correct spec-code divergence detected by `/maxsim:check-drift`. Updates `.planning/` to match code (realign-to-code), or generates fix phases to make code match spec (realign-to-spec).
17
+
18
+ Purpose: After a drift report is generated, this command acts on the findings -- either accepting code reality into the spec or creating phases to close implementation gaps.
19
+
20
+ Pre-requisite: A DRIFT-REPORT.md must exist in `.planning/`. Run `/maxsim:check-drift` first if none exists.
21
+ </objective>
22
+
23
+ <execution_context>
24
+ @./workflows/realign.md
25
+ </execution_context>
26
+
27
+ <context>
28
+ Direction: $ARGUMENTS
29
+ - `to-code` -- Update `.planning/` to match current codebase (spec follows code)
30
+ - `to-spec` -- Generate fix phases to make code match spec (code follows spec)
31
+ - If not provided: workflow will ask which direction
32
+
33
+ Reads the latest `.planning/DRIFT-REPORT.md` produced by `/maxsim:check-drift`.
34
+ </context>
35
+
36
+ <process>
37
+ Execute the realign workflow from @./workflows/realign.md end-to-end.
38
+ Pass $ARGUMENTS as the direction parameter.
39
+ </process>
@@ -0,0 +1,248 @@
1
+ <purpose>
2
+ Orchestrate a drift-checker agent to compare .planning/ spec against the codebase and produce DRIFT-REPORT.md.
3
+
4
+ The drift-checker agent writes the report directly. The orchestrator only receives a summary (status + counts) to prevent context bloat. After the report is generated, the orchestrator reads only the YAML frontmatter for key metrics and presents results to the user.
5
+
6
+ Output: .planning/DRIFT-REPORT.md with severity-tiered findings and YAML frontmatter.
7
+ </purpose>
8
+
9
+ <philosophy>
10
+ **Agent writes output directly:**
11
+ The drift-checker agent writes DRIFT-REPORT.md directly to `.planning/`. The orchestrator does NOT receive the full report content -- it only gets confirmation and counts. This follows the same pattern as maxsim-codebase-mapper (which writes documents directly to `.planning/codebase/`).
12
+
13
+ **Why:** The drift report can be large (50+ items with evidence). Passing the full report back to the orchestrator would waste context. Only metadata flows back.
14
+
15
+ **Fresh scan every run:**
16
+ Every drift check performs a fresh codebase analysis. Previous reports are only used for diff tracking (NEW/RESOLVED/UNCHANGED labels), never as a substitute for current analysis.
17
+ </philosophy>
18
+
19
+ <process>
20
+
21
+ <step name="init_context" priority="first">
22
+ Load drift check context:
23
+
24
+ ```bash
25
+ INIT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs init check-drift)
26
+ ```
27
+
28
+ Extract from init JSON:
29
+ - `drift_model` -- model resolution for the drift-checker agent
30
+ - `commit_docs` -- whether to commit the report
31
+ - `has_planning` -- whether .planning/ exists
32
+ - `has_requirements` -- whether REQUIREMENTS.md exists
33
+ - `has_roadmap` -- whether ROADMAP.md exists
34
+ - `has_nogos` -- whether NO-GOS.md exists
35
+ - `has_conventions` -- whether CONVENTIONS.md exists
36
+ - `has_previous_report` -- whether a previous DRIFT-REPORT.md exists
37
+ - `spec_files` -- list of all spec file paths found
38
+ - `phase_dirs` -- list of active phase directories
39
+ - `archived_milestone_dirs` -- list of archived milestone directories
40
+ - Paths: `requirements_path`, `roadmap_path`, `nogos_path`, `conventions_path`, `state_path`
41
+ </step>
42
+
43
+ <step name="validate">
44
+ **Gate: Verify project is initialized.**
45
+
46
+ If `has_planning` is false:
47
+
48
+ ```
49
+ No .planning/ directory found.
50
+
51
+ Run `/maxsim:new-project` to initialize your project first.
52
+ ```
53
+
54
+ Stop workflow.
55
+
56
+ If `has_requirements` is false AND `has_roadmap` is false:
57
+
58
+ ```
59
+ No REQUIREMENTS.md or ROADMAP.md found in .planning/.
60
+
61
+ At least one spec file is needed for drift detection.
62
+ Run `/maxsim:new-project` to create project specification.
63
+ ```
64
+
65
+ Stop workflow.
66
+
67
+ If `has_planning` is true and at least one spec file exists, continue.
68
+
69
+ If some spec files are missing (e.g., no NO-GOS.md or CONVENTIONS.md), note this for the agent -- it will include a warning in the report header.
70
+ </step>
71
+
72
+ <step name="announce">
73
+ Display progress to user:
74
+
75
+ ```
76
+ Scanning codebase for spec drift...
77
+
78
+ Spec files: {list of found spec files}
79
+ Phase directories: {count} active{, {count} archived if any}
80
+ {If previous report exists: "Previous report found -- will track NEW/RESOLVED/UNCHANGED"}
81
+ {If no previous report: "First drift check -- all findings will be marked NEW"}
82
+
83
+ Spawning drift-checker agent...
84
+ ```
85
+ </step>
86
+
87
+ <step name="spawn_drift_checker">
88
+ Spawn the maxsim-drift-checker agent using the Task tool.
89
+
90
+ ```
91
+ Task(
92
+ subagent_type="maxsim-drift-checker",
93
+ model="{drift_model}",
94
+ description="Check spec-vs-code drift",
95
+ prompt="Perform a complete drift analysis of this project.
96
+
97
+ <check_drift_context>
98
+ {Full CheckDriftContext JSON from init step}
99
+ </check_drift_context>
100
+
101
+ {If $ARGUMENTS contains a phase number:}
102
+ <phase_filter>
103
+ Focus analysis on phase {phase_number}. Still check no-gos and conventions globally.
104
+ </phase_filter>
105
+
106
+ Analyze all spec files against the codebase. Write DRIFT-REPORT.md to .planning/.
107
+ Return only your summary (status and counts) -- do NOT return the full report content."
108
+ )
109
+ ```
110
+
111
+ Wait for agent to complete.
112
+ </step>
113
+
114
+ <step name="read_results">
115
+ After the agent returns, read ONLY the frontmatter of the drift report (not the full content):
116
+
117
+ ```bash
118
+ head -20 .planning/DRIFT-REPORT.md
119
+ ```
120
+
121
+ Parse the YAML frontmatter for:
122
+ - `status` (aligned | drift)
123
+ - `critical_count`
124
+ - `warning_count`
125
+ - `info_count`
126
+ - `undocumented_count`
127
+ - `total_items`
128
+ - `aligned_count`
129
+
130
+ If the file was not created, report agent failure and suggest re-running.
131
+ </step>
132
+
133
+ <step name="commit_report">
134
+ If `commit_docs` is true, commit the drift report:
135
+
136
+ ```bash
137
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "docs: drift report - {status}" --files .planning/DRIFT-REPORT.md
138
+ ```
139
+ </step>
140
+
141
+ <step name="present_results">
142
+ Present the drift check results to the user.
143
+
144
+ **If status is "aligned":**
145
+
146
+ ```
147
+ ## Drift Check Complete
148
+
149
+ **Status:** ALIGNED
150
+ **Total items checked:** {total_items}
151
+ **All {aligned_count} items aligned** -- spec and code are in sync.
152
+
153
+ Report: .planning/DRIFT-REPORT.md
154
+
155
+ ---
156
+
157
+ No realignment needed. Ready to continue development.
158
+
159
+ - `/maxsim:execute-phase` -- Continue executing current phase
160
+ - `/maxsim:plan-phase` -- Plan next phase
161
+ ```
162
+
163
+ **If status is "drift":**
164
+
165
+ ```
166
+ ## Drift Check Complete
167
+
168
+ **Status:** DRIFT DETECTED
169
+
170
+ | Category | Count |
171
+ |----------|-------|
172
+ | Aligned | {aligned_count} |
173
+ | Critical | {critical_count} |
174
+ | Warning | {warning_count} |
175
+ | Info | {info_count} |
176
+ | Undocumented | {undocumented_count} |
177
+
178
+ {If critical_count > 0:}
179
+ **Critical findings require attention** -- requirements marked complete but implementation is missing.
180
+
181
+ Report: .planning/DRIFT-REPORT.md
182
+
183
+ Review the full report, then choose:
184
+ ```
185
+
186
+ Continue to offer_realignment.
187
+ </step>
188
+
189
+ <step name="offer_realignment">
190
+ Present realignment options:
191
+
192
+ ```
193
+ ---
194
+
195
+ ## Realignment Options
196
+
197
+ 1. **Realign to code** -- Update `.planning/` to match what's actually built
198
+ Accepts current implementation as source of truth. Updates requirements and roadmap.
199
+ `/maxsim:realign to-code`
200
+
201
+ 2. **Realign to spec** -- Create new phases to close implementation gaps
202
+ Keeps spec as source of truth. Generates fix phases for missing implementations.
203
+ `/maxsim:realign to-spec`
204
+
205
+ 3. **Done** -- Acknowledge drift, no action needed now
206
+ The DRIFT-REPORT.md is saved for future reference.
207
+
208
+ ---
209
+ ```
210
+
211
+ Wait for user response.
212
+
213
+ - If user chooses option 1: Direct them to run `/maxsim:realign to-code`
214
+ - If user chooses option 2: Direct them to run `/maxsim:realign to-spec`
215
+ - If user chooses option 3 or "done": End workflow
216
+ </step>
217
+
218
+ </process>
219
+
220
+ <error_handling>
221
+
222
+ **Agent failure:** If the drift-checker agent fails or returns without creating DRIFT-REPORT.md:
223
+ ```
224
+ Drift check failed. The drift-checker agent did not produce a report.
225
+
226
+ Possible causes:
227
+ - Insufficient spec files for analysis
228
+ - Agent context overload (too many requirements)
229
+
230
+ Try: `/maxsim:check-drift {specific_phase}` to narrow the scope.
231
+ ```
232
+
233
+ **Partial spec:** The agent handles partial specs internally (runs analysis on what exists, warns about missing files). The workflow does not need to handle this specially.
234
+
235
+ **Previous report comparison failure:** If `drift previous-hash` fails, the agent runs without diff tracking. All items will be marked `[NEW]`.
236
+
237
+ </error_handling>
238
+
239
+ <success_criteria>
240
+ - [ ] Init context loaded with all spec file existence flags
241
+ - [ ] Validation gate prevents running on un-initialized projects
242
+ - [ ] Drift-checker agent spawned with full context
243
+ - [ ] Report frontmatter read (not full content) for result display
244
+ - [ ] Report committed if commit_docs is true
245
+ - [ ] Results presented with counts and status
246
+ - [ ] Realignment options offered when drift detected
247
+ - [ ] Only frontmatter read from report (no context bloat)
248
+ </success_criteria>