maestro-flow 0.5.37 → 0.5.38

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 (152) hide show
  1. package/.agents/skills/maestro/SKILL.md +11 -5
  2. package/.agents/skills/maestro-ralph/SKILL.md +80 -12
  3. package/.agents/skills/maestro-ralph-execute/SKILL.md +17 -6
  4. package/.agents/skills/manage-drift-realign/SKILL.md +153 -0
  5. package/.agy/skills/maestro/SKILL.md +11 -5
  6. package/.agy/skills/maestro-ralph/SKILL.md +80 -12
  7. package/.agy/skills/maestro-ralph-execute/SKILL.md +17 -6
  8. package/.agy/skills/manage-drift-realign/SKILL.md +153 -0
  9. package/.claude/commands/maestro-ralph-execute.md +17 -6
  10. package/.claude/commands/maestro-ralph.md +80 -12
  11. package/.claude/commands/maestro.md +11 -5
  12. package/.claude/commands/manage-drift-realign.md +151 -0
  13. package/.codex/skills/maestro/SKILL.md +16 -8
  14. package/.codex/skills/maestro-ralph/SKILL.md +138 -11
  15. package/.codex/skills/maestro-ralph-execute/SKILL.md +17 -6
  16. package/.codex/skills/manage-drift-realign/SKILL.md +471 -0
  17. package/README.md +25 -8
  18. package/README.zh-CN.md +6 -6
  19. package/dashboard/dist-server/src/commands/install-backend.d.ts +10 -0
  20. package/dashboard/dist-server/src/commands/install-backend.js +69 -0
  21. package/dashboard/dist-server/src/commands/install-backend.js.map +1 -1
  22. package/dashboard/dist-server/src/core/component-defs.d.ts +11 -0
  23. package/dashboard/dist-server/src/core/component-defs.js +34 -2
  24. package/dashboard/dist-server/src/core/component-defs.js.map +1 -1
  25. package/dist/src/cli.js +3 -2
  26. package/dist/src/cli.js.map +1 -1
  27. package/dist/src/commands/install-backend.d.ts +10 -0
  28. package/dist/src/commands/install-backend.d.ts.map +1 -1
  29. package/dist/src/commands/install-backend.js +69 -0
  30. package/dist/src/commands/install-backend.js.map +1 -1
  31. package/dist/src/commands/install.js +1 -0
  32. package/dist/src/commands/install.js.map +1 -1
  33. package/dist/src/commands/ralph.d.ts.map +1 -1
  34. package/dist/src/commands/ralph.js +8 -0
  35. package/dist/src/commands/ralph.js.map +1 -1
  36. package/dist/src/commands/timeline.d.ts +14 -0
  37. package/dist/src/commands/timeline.d.ts.map +1 -0
  38. package/dist/src/commands/timeline.js +377 -0
  39. package/dist/src/commands/timeline.js.map +1 -0
  40. package/dist/src/core/component-defs.d.ts +11 -0
  41. package/dist/src/core/component-defs.d.ts.map +1 -1
  42. package/dist/src/core/component-defs.js +34 -2
  43. package/dist/src/core/component-defs.js.map +1 -1
  44. package/dist/src/core/install-executor.d.ts.map +1 -1
  45. package/dist/src/core/install-executor.js +11 -1
  46. package/dist/src/core/install-executor.js.map +1 -1
  47. package/dist/src/core/install-profile.d.ts.map +1 -1
  48. package/dist/src/core/install-profile.js +52 -17
  49. package/dist/src/core/install-profile.js.map +1 -1
  50. package/dist/src/i18n/locales/en.d.ts.map +1 -1
  51. package/dist/src/i18n/locales/en.js +4 -1
  52. package/dist/src/i18n/locales/en.js.map +1 -1
  53. package/dist/src/i18n/locales/zh.d.ts.map +1 -1
  54. package/dist/src/i18n/locales/zh.js +4 -1
  55. package/dist/src/i18n/locales/zh.js.map +1 -1
  56. package/dist/src/i18n/types.d.ts +3 -0
  57. package/dist/src/i18n/types.d.ts.map +1 -1
  58. package/dist/src/ralph/cmd-complete.d.ts +4 -0
  59. package/dist/src/ralph/cmd-complete.d.ts.map +1 -1
  60. package/dist/src/ralph/cmd-complete.js +8 -0
  61. package/dist/src/ralph/cmd-complete.js.map +1 -1
  62. package/dist/src/ralph/cmd-next.js +58 -8
  63. package/dist/src/ralph/cmd-next.js.map +1 -1
  64. package/dist/src/ralph/status-schema.d.ts +29 -2
  65. package/dist/src/ralph/status-schema.d.ts.map +1 -1
  66. package/dist/src/ralph/status-schema.js +1 -1
  67. package/dist/src/tui/install-ui/ComponentGrid.d.ts.map +1 -1
  68. package/dist/src/tui/install-ui/ComponentGrid.js +71 -38
  69. package/dist/src/tui/install-ui/ComponentGrid.js.map +1 -1
  70. package/dist/src/tui/install-ui/ComponentGrid.logic.d.ts +12 -3
  71. package/dist/src/tui/install-ui/ComponentGrid.logic.d.ts.map +1 -1
  72. package/dist/src/tui/install-ui/ComponentGrid.logic.js +21 -4
  73. package/dist/src/tui/install-ui/ComponentGrid.logic.js.map +1 -1
  74. package/dist/src/tui/install-ui/CyberItem.d.ts +3 -1
  75. package/dist/src/tui/install-ui/CyberItem.d.ts.map +1 -1
  76. package/dist/src/tui/install-ui/CyberItem.js +6 -5
  77. package/dist/src/tui/install-ui/CyberItem.js.map +1 -1
  78. package/dist/src/tui/install-ui/GroupedHub.d.ts +9 -0
  79. package/dist/src/tui/install-ui/GroupedHub.d.ts.map +1 -1
  80. package/dist/src/tui/install-ui/GroupedHub.js +54 -47
  81. package/dist/src/tui/install-ui/GroupedHub.js.map +1 -1
  82. package/dist/src/tui/install-ui/InstallConfirm.js +1 -1
  83. package/dist/src/tui/install-ui/InstallConfirm.js.map +1 -1
  84. package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
  85. package/dist/src/tui/install-ui/InstallFlow.js +54 -5
  86. package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
  87. package/dist/src/tui/install-ui/types.d.ts +1 -0
  88. package/dist/src/tui/install-ui/types.d.ts.map +1 -1
  89. package/dist/src/tui/install-ui/types.js.map +1 -1
  90. package/dist/src/tui/install-ui/useInstallFlowState.d.ts +8 -2
  91. package/dist/src/tui/install-ui/useInstallFlowState.d.ts.map +1 -1
  92. package/dist/src/tui/install-ui/useInstallFlowState.js +145 -15
  93. package/dist/src/tui/install-ui/useInstallFlowState.js.map +1 -1
  94. package/dist/src/utils/update-notices.js +12 -0
  95. package/dist/src/utils/update-notices.js.map +1 -1
  96. package/package.json +1 -1
  97. package/workflows/agy-instructions.md +127 -88
  98. package/workflows/analyze.md +2 -2
  99. package/workflows/auto-test.md +7 -1
  100. package/workflows/blueprint.md +22 -19
  101. package/workflows/brainstorm.md +11 -3
  102. package/workflows/business-test.md +4 -0
  103. package/workflows/codebase-rebuild.md +8 -1
  104. package/workflows/codebase-refresh.md +7 -1
  105. package/workflows/codex-instructions.md +1 -1
  106. package/workflows/debug.md +5 -2
  107. package/workflows/domain-add.md +6 -0
  108. package/workflows/drift-realign.md +396 -0
  109. package/workflows/execute.md +5 -4
  110. package/workflows/explore-usage.md +2 -2
  111. package/workflows/finish-work.md +6 -6
  112. package/workflows/fork.md +2 -2
  113. package/workflows/grill.md +6 -5
  114. package/workflows/harvest.md +2 -2
  115. package/workflows/impeccable.md +3 -2
  116. package/workflows/init.md +7 -7
  117. package/workflows/integration-test.md +1 -0
  118. package/workflows/issue-gaps-analyze.codex.md +2 -0
  119. package/workflows/issue-gaps-analyze.md +4 -4
  120. package/workflows/issue-plan.md +1 -1
  121. package/workflows/knowhow.md +7 -1
  122. package/workflows/knowledge-audit.md +1 -1
  123. package/workflows/maestro-super.md +2 -2
  124. package/workflows/maestro.md +3 -3
  125. package/workflows/map.md +2 -2
  126. package/workflows/milestone-audit.md +1 -1
  127. package/workflows/milestone-complete.md +1 -1
  128. package/workflows/plan.md +7 -6
  129. package/workflows/quick.md +8 -6
  130. package/workflows/ralph-amend-goal.md +177 -0
  131. package/workflows/refactor.md +2 -0
  132. package/workflows/retrospective.md +7 -3
  133. package/workflows/review.md +6 -4
  134. package/workflows/roadmap-common.md +3 -3
  135. package/workflows/roadmap.md +8 -5
  136. package/workflows/spec-generate.md +23 -18
  137. package/workflows/specs-load.md +1 -1
  138. package/workflows/specs-setup.md +2 -0
  139. package/workflows/sync.md +4 -2
  140. package/workflows/test-gen.md +1 -1
  141. package/workflows/test.md +1 -1
  142. package/workflows/ui-codify-extract.md +1 -0
  143. package/workflows/ui-codify-knowhow.md +1 -1
  144. package/workflows/ui-codify-package.md +1 -1
  145. package/workflows/ui-codify.md +9 -7
  146. package/workflows/ui-design.md +9 -7
  147. package/workflows/ui-style.md +6 -4
  148. package/workflows/verify.md +4 -4
  149. package/workflows/wiki-connect.md +2 -0
  150. package/workflows/wiki-digest.md +5 -3
  151. package/workflows/wiki-manage.md +4 -0
  152. package/workflows/maestro.codex.md +0 -365
@@ -0,0 +1,471 @@
1
+ ---
2
+ name: manage-drift-realign
3
+ description: Detect and realign .workflow/ artifact drift against code reality after refactoring
4
+ argument-hint: "[-y|--yes] [-c|--concurrency 4] [--continue] \"--scope <all|roadmap|spec|codebase|state|issue|knowhow|project> [--since YYYY-MM-DD|commit|HEAD~N] [--depth shallow|deep] [--dry-run] [--report] [--auto-archive]\""
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, request_user_input
6
+ ---
7
+
8
+ <purpose>
9
+ Detect divergence between code reality and `.workflow/` artifacts (roadmap, specs, codebase docs, state, issues, knowhow, project.md) after major refactoring + incremental changes. Reconstructs git + session timeline, runs 4 parallel drift scanners via CSV-wave, then proposes realignment actions.
10
+
11
+ Complementary to `manage-knowledge-audit` (internal contradictions within knowledge stores) — this skill detects **code ↔ document** drift.
12
+
13
+ **Core workflow**: Timeline Reconstruction → Drift Score → Parallel Scan (4 agents) → Triage → Apply
14
+
15
+ **Topology**: Single-wave parallel (4 independent scanners)
16
+
17
+ ```
18
+ +--------------------------------------------------------------------------+
19
+ | DRIFT REALIGN CSV WAVE WORKFLOW |
20
+ +--------------------------------------------------------------------------+
21
+ | |
22
+ | Phase 1: Setup + Timeline |
23
+ | +-- Validate .workflow/ exists, parse arguments |
24
+ | +-- Run maestro timeline --since <date> --json → timeline.json |
25
+ | +-- Compute drift_score (LOW / MODERATE / SEVERE) |
26
+ | +-- Platform inquiry: ask user which platform to focus (if multi) |
27
+ | +-- Generate tasks.csv with 4 scanner tasks (all wave 1) |
28
+ | |
29
+ | Phase 2: Wave Execution (Single Wave) |
30
+ | +-- Wave 1: 4 scanners run concurrently |
31
+ | | +-- roadmap-scanner |
32
+ | | +-- spec-scanner |
33
+ | | +-- codebase-scanner |
34
+ | | +-- artifact-scanner |
35
+ | +-- discoveries.ndjson shared (append-only) |
36
+ | |
37
+ | Phase 3: Synthesize + Triage |
38
+ | +-- Merge findings, dedup, sort by P0 > P1 > P2 |
39
+ | +-- Merge existing conflict-markers from maestro spec conflict list |
40
+ | +-- Interactive triage (or --auto-archive / --report / --dry-run) |
41
+ | |
42
+ | Phase 4: Apply + Report |
43
+ | +-- Backup to .trash/, apply actions, auto-rebuild if needed |
44
+ | +-- Update state.json (last_drift_realign) |
45
+ | +-- Generate drift-report + drift-log.jsonl |
46
+ | |
47
+ +--------------------------------------------------------------------------+
48
+ ```
49
+
50
+ </purpose>
51
+
52
+ <context>
53
+ $ARGUMENTS -- optional flags for drift realign control.
54
+
55
+ **Usage**:
56
+
57
+ ```bash
58
+ $manage-drift-realign ""
59
+ $manage-drift-realign -y "--scope all --since 2026-04-01"
60
+ $manage-drift-realign -c 4 "--scope spec --depth deep"
61
+ $manage-drift-realign -y "--scope codebase --auto-archive"
62
+ $manage-drift-realign "" "--scope all --report"
63
+ $manage-drift-realign "" "--scope all --dry-run"
64
+ $manage-drift-realign --continue "20260624-drift-realign"
65
+ ```
66
+
67
+ **Flags**:
68
+ - `-y, --yes`: Skip all confirmations (auto mode)
69
+ - `-c, --concurrency N`: Max concurrent scanner agents (default: 4)
70
+ - `--continue`: Resume existing session
71
+
72
+ **Inner flags** (passed inside quotes):
73
+ - `--scope <type>`: roadmap / spec / codebase / state / issue / knowhow / project / all (default: all)
74
+ - `--since <date|commit|HEAD~N>`: Analysis starting point (default: auto-detect from state.json)
75
+ - `--depth <shallow|deep>`: shallow = mtime + reference check; deep = LLM semantic analysis (default: shallow)
76
+ - `--dry-run`: Full preview, no writes
77
+ - `--report`: Generate report only, skip triage
78
+ - `--auto-archive`: Auto-apply suggested actions for P1/P2, only P0 gets interactive review
79
+
80
+ **Output Directory**: `.workflow/.csv-wave/{session-id}/`
81
+ **Core Output**: `tasks.csv` + `results.csv` + `discoveries.ndjson` + `context.md`
82
+ **Report Output**: `.workflow/.drift-realign/drift-report-{date}.md` + `drift-log.jsonl`
83
+
84
+ **State files read**:
85
+ - `.workflow/state.json` — project state + artifact registry
86
+ - `.workflow/roadmap.md` — milestone/phase roadmap
87
+ - `.workflow/specs/*.md` — spec entries
88
+ - `.workflow/codebase/*.md` — codebase docs (architecture, features, tech-stack, concerns)
89
+ - `.workflow/codebase/doc-index.json` — documentation index
90
+ - `.workflow/issues/issues.jsonl` — issue tracking
91
+ - `.workflow/knowhow/*.md` — knowledge documents
92
+ - `.workflow/project.md` — project definition
93
+ </context>
94
+
95
+ <csv_schema>
96
+
97
+ ### tasks.csv (Master State)
98
+
99
+ ```csv
100
+ id,title,description,scan_scope,output_format,deps,context_from,wave
101
+ "1","Roadmap Scanner","Scan .workflow/roadmap.md and .workflow/state.json for drift against code reality. Read timeline.json for git change context. Detect: phantom_phase (P0), stale_progress (P1), milestone_mismatch (P0), outdated_criteria (P1), dependency_ghost (P1), timeline_impossible (P2). For each finding: verify against code/state.json before reporting. Return JSON array of DriftFinding objects via output_schema.","roadmap","json","","","1"
102
+ "2","Spec Scanner","Scan .workflow/specs/*.md spec-entry blocks for drift against actual code patterns. Read timeline.json hot_paths to focus on high-change areas. Detect: convention_violation (P0), dead_import_pattern (P1), architecture_breach (P0), stale_dependency (P1), naming_drift (P2), test_convention_gap (P2). {DEPTH_INSTRUCTION}. Return JSON array of DriftFinding objects via output_schema.","spec","json","","","1"
103
+ "3","Codebase Scanner","Scan .workflow/codebase/*.md and doc-index.json for drift against current code structure. Read timeline.json for git changes. Detect: architecture_outdated (P0), feature_missing (P1), tech_stack_changed (P0), concern_drift (P1), doc_index_stale (P0). {DEPTH_INSTRUCTION}. Return JSON array of DriftFinding objects via output_schema.","codebase","json","","","1"
104
+ "4","Artifact Scanner","Scan .workflow/issues/issues.jsonl, .workflow/knowhow/*.md, .workflow/project.md, and state.json accumulated_context for drift. Read timeline.json for git context. Detect: issue_code_ref_dead (P1), issue_stale_open (P1), knowhow_code_ref_dead (P1), orphan_session (P2), project_tech_drift (P0), project_req_drift (P1), accumulated_stale (P1), deferred_resolved (P2). Return JSON array of DriftFinding objects via output_schema.","artifact","json","","","1"
105
+ ```
106
+
107
+ **Substitutions (orchestrator MUST do BEFORE writing tasks.csv)**:
108
+ - `{DEPTH_INSTRUCTION}`: If `--depth shallow` → "Use file existence checks and grep pattern matching only. Do NOT make LLM-based semantic judgments." If `--depth deep` → "Use LLM semantic analysis: read spec/doc content alongside code samples from hot_paths and judge alignment."
109
+
110
+ **Columns**:
111
+
112
+ | Column | Description |
113
+ |--------|-------------|
114
+ | `id` | Scanner identifier (1-4) |
115
+ | `title` | Scanner name |
116
+ | `description` | Detailed scan instructions with drift type definitions |
117
+ | `scan_scope` | roadmap / spec / codebase / artifact |
118
+ | `output_format` | Always "json" |
119
+ | `deps` | Empty (all independent) |
120
+ | `context_from` | Empty (all read timeline.json directly) |
121
+ | `wave` | Always 1 (single wave) |
122
+
123
+ **Output columns** (returned exclusively via `output_schema`):
124
+
125
+ | Column | Description |
126
+ |--------|-------------|
127
+ | `result_status` | `completed` / `failed` |
128
+ | `result_findings` | JSON array of DriftFinding objects (stringified) |
129
+ | `error` | Error message if failed |
130
+
131
+ ### DriftFinding Schema (per finding in result_findings array)
132
+
133
+ ```json
134
+ {
135
+ "id": "DFT-{8hex}",
136
+ "scope": "roadmap|spec|codebase|state|issue|knowhow|project",
137
+ "severity": "P0|P1|P2",
138
+ "target": { "file": "string", "section": "string (optional)" },
139
+ "drift_type": "string (one of the defined types per scanner)",
140
+ "evidence": {
141
+ "code_reality": "string (what code actually shows)",
142
+ "doc_claim": "string (what the document claims)",
143
+ "git_ref": "string (commit reference, optional)"
144
+ },
145
+ "suggested_action": "keep|update|archive|rebuild",
146
+ "update_hint": "string (specific update suggestion, optional)"
147
+ }
148
+ ```
149
+
150
+ </csv_schema>
151
+
152
+ <invariants>
153
+ 1. **Code-as-Truth**: Code is the single source of truth. When doc says X but code does Y, the doc is drifted.
154
+ 2. **Start Immediately**: First action is session init, then Phase 1.
155
+ 3. **CSV is Source of Truth**: tasks.csv holds all scanner state.
156
+ 4. **Discovery Board is Append-Only**: Scanners share findings via NDJSON.
157
+ 5. **Partial Results OK**: If 3/4 scanners succeed, proceed with available findings.
158
+ 6. **Backup Before Mutate**: Phase 4 backup MUST succeed before any file mutations.
159
+ 7. **No Auto-Delete**: Archive moves to .trash/, never physically deletes.
160
+ 8. **Rebuild is Scoped**: Auto-rebuild only triggers for codebase scope (/quality-sync --full).
161
+ 9. **Timeline as Shared Context**: All scanners read timeline.json — orchestrator writes it BEFORE generating tasks.csv.
162
+ 10. **DO NOT STOP**: Execute until all scanners complete or fail, then proceed through triage and apply.
163
+ </invariants>
164
+
165
+ <execution>
166
+
167
+ ### Output Artifacts
168
+
169
+ | File | Purpose | Lifecycle |
170
+ |------|---------|-----------|
171
+ | `tasks.csv` | Master state — 4 scanner tasks | Updated after wave |
172
+ | `wave-1.csv` | Wave input (temporary) | Created before wave, deleted after |
173
+ | `wave-1-results.csv` | Wave output | Created by spawn_agents_on_csv |
174
+ | `results.csv` | Final export | Created in Phase 3 |
175
+ | `discoveries.ndjson` | Shared exploration board | Append-only during wave |
176
+ | `context.md` | Human-readable report | Created in Phase 4 |
177
+ | `timeline.json` | Git + session timeline | Created in Phase 1 |
178
+
179
+ ### Session Initialization
180
+
181
+ Parse `$ARGUMENTS` to extract:
182
+ - `AUTO_YES` from `--yes` / `-y`
183
+ - `continueMode` from `--continue`
184
+ - `maxConcurrency` from `--concurrency N` / `-c N` (default: 4)
185
+ - Inner flags: `scope`, `since`, `depth`, `dryRun`, `reportOnly`, `autoArchive`
186
+
187
+ Session ID: `{YYYYMMDD}-drift-realign`
188
+ Session folder: `.workflow/.csv-wave/{sessionId}/` — create via `mkdir -p`
189
+
190
+ ### Phase 1: Setup + Timeline
191
+
192
+ **Step 1.1: Validate**
193
+ - `.workflow/state.json` exists — abort with E001 if missing
194
+ - git available — abort with E003 if not a git repo
195
+
196
+ **Step 1.2: Resolve --since**
197
+ 1. Explicit `--since` value → parse as date/commit/HEAD~N
198
+ 2. `state.json.last_drift_realign` → use that timestamp
199
+ 3. `state.json.last_pruned` → use that timestamp
200
+ 4. Fallback → 90 days ago
201
+
202
+ **Step 1.3: Build timeline**
203
+ ```bash
204
+ maestro timeline --since <resolved_date> --json --output <sessionFolder>/timeline.json
205
+ ```
206
+ If command fails, fallback to inline git log + session load.
207
+ Parse timeline.json to extract: `window`, `git_summary`, `session_summary`, `hot_paths`, `cold_workflow_files`.
208
+
209
+ **Step 1.4: Compute drift score**
210
+ ```
211
+ drift_score = drift_window_days × sqrt(changed_files_count) × scope_weight
212
+ changed_files_count = |Set(git_files) ∪ Set(session_edited_files)|
213
+
214
+ scope_weight: roadmap=1.5, project=1.4, spec=1.3, state=1.2, codebase=1.0, issue=0.8, knowhow=0.7
215
+ (scope=all: weighted average)
216
+
217
+ Thresholds:
218
+ LOW: score < 30
219
+ MODERATE: 30 ≤ score < 100
220
+ SEVERE: score ≥ 100 → auto-upgrade to --depth deep
221
+ drift_window > 180 days → force --depth deep + W002
222
+ ```
223
+
224
+ Display drift summary to user.
225
+
226
+ **Step 1.5: Platform inquiry (interactive)**
227
+ If `session_summary.by_platform` has multiple platforms AND total sessions > 20 AND NOT AUTO_YES:
228
+ - Use `request_user_input` to ask: "Multiple session platforms detected. Focus on a specific platform?"
229
+ - Options: All / Claude / Codex
230
+ - If specific platform chosen: re-run `maestro timeline --platform <choice> --since <date> --json --output ...`
231
+
232
+ **Step 1.6: Generate tasks.csv**
233
+ - 4 rows (scanners), all wave 1, no dependencies
234
+ - Substitute `{DEPTH_INSTRUCTION}` based on resolved depth
235
+ - If `--scope` is not "all", generate only the matching scanner task(s)
236
+ - User validation: display scanner breakdown (skip if AUTO_YES)
237
+
238
+ ### Phase 2: Wave Execution (Single Wave)
239
+
240
+ Filter master `tasks.csv` for `wave == 1 AND status == pending` → write `wave-1.csv`.
241
+
242
+ ```javascript
243
+ spawn_agents_on_csv({
244
+ csv_path: `${sessionFolder}/wave-1.csv`,
245
+ id_column: "id",
246
+ instruction: SCANNER_INSTRUCTION,
247
+ max_concurrency: maxConcurrency,
248
+ max_runtime_seconds: 3600,
249
+ output_csv_path: `${sessionFolder}/wave-1-results.csv`,
250
+ output_schema: {
251
+ type: "object",
252
+ properties: {
253
+ id: { type: "string" },
254
+ result_status: { type: "string", enum: ["completed", "failed"] },
255
+ result_findings: { type: "string", description: "JSON array of DriftFinding objects" },
256
+ error: { type: "string" }
257
+ },
258
+ required: ["id", "result_status", "result_findings"]
259
+ }
260
+ })
261
+ ```
262
+
263
+ Merge `wave-1-results.csv` into master `tasks.csv`. Delete temporary wave files.
264
+
265
+ #### Scanner Worker Contract (SCANNER_INSTRUCTION)
266
+
267
+ ```
268
+ You are a drift scanner for ONE scope (roadmap / spec / codebase / artifact). Your task is to detect divergence between .workflow/ documentation and actual code reality.
269
+
270
+ CORE PRINCIPLE: Code is ALWAYS right. When code and documentation disagree, the DOCUMENT is drifted.
271
+
272
+ REQUIRED STEPS:
273
+ 1. Read {sessionFolder}/timeline.json for git change context (hot_paths, cold_workflow_files, events)
274
+ 2. Read the .workflow/ files specified in your description
275
+ 3. For each drift type in your description, run the detection algorithm:
276
+ - shallow: file existence checks, grep pattern matching, path verification
277
+ - deep: read code samples + doc content, make semantic alignment judgments
278
+ 4. For each detected drift, construct a DriftFinding JSON object with evidence
279
+ 5. Append significant discoveries to {sessionFolder}/discoveries.ndjson
280
+ 6. Call report_agent_job_result EXACTLY ONCE
281
+
282
+ OUTPUT (must match output_schema):
283
+ {
284
+ "id": "<your row id>",
285
+ "result_status": "completed" | "failed",
286
+ "result_findings": "<JSON array of DriftFinding objects, stringified>",
287
+ "error": "<message if failed, else empty>"
288
+ }
289
+
290
+ CONSTRAINTS:
291
+ - Do NOT modify any .workflow/ files (read-only scan)
292
+ - Do NOT write to tasks.csv, wave-*.csv, results.csv
293
+ - Do NOT call spawn_agents_on_csv (no recursion)
294
+ - NEVER report a finding without evidence (code_reality + doc_claim fields required)
295
+ ```
296
+
297
+ ### Phase 3: Synthesize + Triage
298
+
299
+ **Step 3.1: Merge findings**
300
+ - Parse `result_findings` from each scanner (JSON arrays of DriftFinding)
301
+ - Dedup: same file + section → keep highest severity
302
+ - Sort: P0 first, then P1, then P2
303
+ - Filter by `--scope` if not "all"
304
+
305
+ **Step 3.2: Conflict-marker integration**
306
+ ```bash
307
+ maestro spec conflict list
308
+ ```
309
+ For spec entries with existing conflict-markers that also appear in scanner findings: merge and elevate to P0.
310
+
311
+ **Step 3.3: Triage**
312
+ - If `--report` → skip to Phase 4 report
313
+ - If `--dry-run` → display all findings with suggested actions, skip Phase 4 apply
314
+ - If `--auto-archive` → auto-apply each finding's `suggested_action` for P1/P2; only P0 gets interactive review
315
+ - Otherwise → interactive triage per finding using `request_user_input`:
316
+
317
+ ```
318
+ [!] Drift Detected (P0 - architecture_outdated)
319
+ Scope: codebase
320
+ Target: .workflow/codebase/architecture.md §Module Boundaries
321
+ Evidence:
322
+ Doc claims: "Three-layer architecture: api/, service/, db/"
323
+ Code reality: New src/payments/ module added, not described
324
+ Git ref: commit abc123 (2026-06-10)
325
+ Hint: Add Payments module section
326
+ Suggestion: update
327
+ ```
328
+
329
+ Actions: keep / update / archive / rebuild / skip
330
+
331
+ | Action | Behavior |
332
+ |--------|----------|
333
+ | keep | Confirmed no drift, log as reviewed |
334
+ | update | Inject `<!-- DRIFT-TODO: {hint} (DFT-{id}) -->` at file top |
335
+ | archive | Move to .trash/ |
336
+ | rebuild | Mark for auto-rebuild (codebase → $quality-sync --full) |
337
+ | skip | Skip without decision, will reappear on next run |
338
+
339
+ Export master `tasks.csv` as `results.csv`.
340
+
341
+ ### Phase 4: Apply + Report
342
+
343
+ **Step 4.1: Backup**
344
+ ```bash
345
+ mkdir -p .workflow/.trash/drift-realign-{timestamp}/
346
+ ```
347
+ Copy all affected files + state.json to backup. If backup fails → abort (E005).
348
+
349
+ **Step 4.2: Apply actions**
350
+
351
+ | Action | Implementation |
352
+ |--------|---------------|
353
+ | keep | Write drift-log.jsonl entry (action=keep) |
354
+ | skip | Write drift-log.jsonl entry (action=skipped) |
355
+ | update | Prepend `<!-- DRIFT-TODO: {hint} (DFT-{id}, {date}) -->` to target file |
356
+ | archive | Move file to `.trash/{timestamp}/`, update state.json refs |
357
+ | rebuild | Collect targets; after all other actions: invoke $quality-sync --full |
358
+
359
+ After rebuild: if sync reports major structural changes → suggest $manage-codebase-rebuild.
360
+
361
+ Conflict-marker cleanup: for update/archive targets with existing conflict-markers:
362
+ ```bash
363
+ maestro spec conflict clear <file> <line>
364
+ ```
365
+
366
+ Update state.json: `last_drift_realign = now` (atomic: backup → write → verify).
367
+
368
+ **Step 4.3: Generate report**
369
+
370
+ Write `.workflow/.drift-realign/drift-report-{date}.md`:
371
+
372
+ ```markdown
373
+ # Drift Realign Report — {date}
374
+
375
+ ## Timeline Window
376
+ - From: {from} → To: {to} ({days} days)
377
+ - Git: {commits} commits, {files_changed} files (+{ins}/-{del})
378
+ - Sessions: {total} total, {with_edits} with edits ({platform breakdown})
379
+ - Drift Score: {score} ({LOW|MODERATE|SEVERE})
380
+
381
+ ## Scan Summary
382
+ - Total findings: {N} ({P0} P0 / {P1} P1 / {P2} P2)
383
+ - By scope: roadmap {N} / spec {N} / codebase {N} / artifact {N}
384
+
385
+ ## Actions Applied
386
+ | # | Scope | Drift Type | Target | Severity | Action | Status |
387
+ |---|-------|-----------|--------|----------|--------|--------|
388
+
389
+ ## Backup
390
+ - Location: .workflow/.trash/drift-realign-{timestamp}/
391
+ ```
392
+
393
+ Append to `.workflow/.drift-realign/drift-log.jsonl` (one JSON per line).
394
+
395
+ **Step 4.4: Generate context.md** (in session folder):
396
+
397
+ ```markdown
398
+ # Drift Realign Session Report
399
+
400
+ ## Summary
401
+ - Scope: {scope}
402
+ - Depth: {depth}
403
+ - Drift Score: {score} ({level})
404
+ - Scanners: {completed}/{total} succeeded
405
+ - Findings: {total} ({P0} P0 / {P1} P1 / {P2} P2)
406
+ - Actions: {updated} updated, {archived} archived, {rebuilt} rebuilt, {kept} kept, {skipped} skipped
407
+
408
+ ## Next Steps
409
+ - Edit DRIFT-TODO markers: grep -r "DRIFT-TODO" .workflow/
410
+ - Deep knowledge audit: $manage-knowledge-audit --scope all
411
+ - Full codebase rebuild: $manage-codebase-rebuild
412
+ - View status: $manage-status
413
+ ```
414
+
415
+ Display completion report:
416
+
417
+ ```
418
+ === DRIFT REALIGN COMPLETE ===
419
+ Timeline: {from} → {to} ({days} days, {commits} commits)
420
+ Score: {score} ({level})
421
+
422
+ Findings: {N} total ({P0} P0 / {P1} P1 / {P2} P2)
423
+ Updated: {N} (DRIFT-TODO markers)
424
+ Archived: {N} (moved to .trash/)
425
+ Rebuilt: {rebuild_status}
426
+ Kept: {N}
427
+ Skipped: {N}
428
+
429
+ Report: .workflow/.drift-realign/drift-report-{date}.md
430
+ Backup: .workflow/.trash/drift-realign-{timestamp}/
431
+
432
+ Next:
433
+ → grep -r "DRIFT-TODO" .workflow/ (edit marked files)
434
+ → $manage-knowledge-audit --scope all
435
+ → $manage-status
436
+ ```
437
+
438
+ </execution>
439
+
440
+ <error_codes>
441
+ | Code | Severity | Condition | Recovery |
442
+ |------|----------|-----------|----------|
443
+ | E001 | error | `.workflow/` not initialized | Run `$maestro-init` first |
444
+ | E002 | error | `--scope` value invalid | Provide valid scope |
445
+ | E003 | error | git not available (not a git repo) | Initialize git |
446
+ | E004 | error | `--since` cannot be resolved | Check date format or commit ref |
447
+ | E005 | error | Backup failed | Check disk space |
448
+ | W001 | warning | Session history unavailable (wiki not indexed) | Run `maestro wiki rebuild` |
449
+ | W002 | warning | `drift_window` > 180 days | Auto-upgraded to `--depth deep` |
450
+ | W003 | warning | Some scanner agents failed | Proceeding with partial findings |
451
+ | W004 | warning | git log > 1000 commits | Auto-truncated to most recent 1000 |
452
+ | W005 | warning | $quality-sync --full failed or reported major changes | Suggest $manage-codebase-rebuild |
453
+ </error_codes>
454
+
455
+ <success_criteria>
456
+ - [ ] Session initialized with timeline.json and tasks.csv
457
+ - [ ] drift_score computed and displayed (LOW/MODERATE/SEVERE)
458
+ - [ ] Platform inquiry offered (if multi-platform sessions > 20)
459
+ - [ ] 4 scanner agents executed via spawn_agents_on_csv (or subset per --scope)
460
+ - [ ] DriftFinding[] merged, deduplicated, sorted by P0 > P1 > P2
461
+ - [ ] Conflict-markers merged into findings
462
+ - [ ] Triage completed (interactive / auto-archive / report / dry-run)
463
+ - [ ] Backup tarball generated in .trash/ before any mutations
464
+ - [ ] update actions injected DRIFT-TODO markers
465
+ - [ ] archive actions moved files to .trash/
466
+ - [ ] rebuild actions triggered $quality-sync --full
467
+ - [ ] state.json updated with last_drift_realign timestamp
468
+ - [ ] drift-report-{date}.md and drift-log.jsonl written
469
+ - [ ] context.md generated in session folder
470
+ - [ ] Completion report displayed with next-step routing
471
+ </success_criteria>
package/README.md CHANGED
@@ -65,7 +65,7 @@ npm install -g maestro-flow
65
65
  maestro install
66
66
  ```
67
67
 
68
- **Prerequisites**: Node.js ≥ 18, Claude Code CLI. Optional: Codex CLI, Gemini CLI for multi-agent workflows.
68
+ **Prerequisites**: Node.js ≥ 18, Claude Code CLI. Optional: Codex CLI, agy (Antigravity) CLI for multi-agent workflows.
69
69
 
70
70
  `maestro install` provides an interactive component selector — choose which assets (commands, hooks, MCP, agents) to install. Use `maestro workspace link` to share knowledge (specs, knowhow, domain) across multiple projects.
71
71
 
@@ -97,6 +97,23 @@ Ralph automatically determines where you are (brainstorm → plan → execute
97
97
  | `/maestro-quick` | Quick fixes, small features (analyze → plan → execute) |
98
98
  | `/maestro-*` | Step-by-step: brainstorm, blueprint, analyze, plan, execute, verify |
99
99
 
100
+ ### Knowledge Management
101
+
102
+ ```bash
103
+ # Search across wiki + code (BM25F ranking)
104
+ maestro search "user authentication"
105
+
106
+ # Load specific knowledge types
107
+ maestro load --type spec --category coding
108
+ maestro load --type knowhow --list
109
+
110
+ # Explore codebase via API endpoints
111
+ maestro explore "Find all database query patterns"
112
+
113
+ # Manage domain terminology
114
+ maestro domain add "API Gateway" "Unified entry point for all API requests"
115
+ ```
116
+
100
117
  ### Odyssey — Long-Running Iterative Cycles
101
118
 
102
119
  Odyssey commands run extended, self-correcting loops that combine archaeology, diagnosis, fix, verification, and knowledge persistence until acceptance criteria are met:
@@ -243,15 +260,15 @@ Built with React 19, Zustand, Tailwind CSS 4, Framer Motion, Hono, WebSocket.
243
260
 
244
261
  | Metric | Count |
245
262
  |--------|-------|
246
- | Source files (TypeScript) | 454 |
247
- | Lines of code | ~111,000 |
263
+ | Source files (TypeScript) | 333 |
264
+ | Lines of code | ~80,700 |
248
265
  | Slash commands | 64 |
249
266
  | Workflow definitions | 115 |
250
267
  | Skill packages | 45 |
251
268
  | Agent definitions | 23 |
252
- | CLI commands | 32 |
269
+ | CLI commands | 35+ |
253
270
  | Templates | 92 |
254
- | Guides (bilingual) | 67 |
271
+ | Guides (bilingual) | 76 |
255
272
 
256
273
  ### Tech Stack
257
274
 
@@ -262,7 +279,7 @@ Built with React 19, Zustand, Tailwind CSS 4, Framer Motion, Hono, WebSocket.
262
279
  | Knowledge Graph | better-sqlite3, Drizzle ORM, web-tree-sitter |
263
280
  | Frontend | React 19, Zustand, Tailwind CSS 4, Framer Motion, Radix UI |
264
281
  | Backend | Hono, WebSocket, SSE |
265
- | Agents | Claude Agent SDK, Codex CLI, Gemini CLI, OpenCode |
282
+ | Agents | Claude Agent SDK, Codex CLI, agy (Antigravity) CLI, OpenCode |
266
283
  | Build | Vite 6, TypeScript 5.7, Vitest |
267
284
 
268
285
  ### Architecture
@@ -271,7 +288,7 @@ Built with React 19, Zustand, Tailwind CSS 4, Framer Motion, Hono, WebSocket.
271
288
  maestro/
272
289
  ├── bin/ # CLI entry points
273
290
  ├── src/ # Core CLI (Commander.js + MCP SDK)
274
- │ ├── commands/ # 32 CLI commands
291
+ │ ├── commands/ # 35+ CLI commands
275
292
  │ ├── mcp/ # MCP server (stdio transport)
276
293
  │ ├── graph/ # Knowledge Graph (SQLite + tree-sitter)
277
294
  │ └── core/ # Tool registry, extension loader
@@ -300,7 +317,7 @@ maestro/
300
317
 
301
318
  **Workflow**
302
319
  - **[Command Usage Guide](guide/command-usage-guide.en.md)** — All 64 commands with workflow diagrams and pipeline chaining
303
- - **[CLI Commands Reference](guide/cli-commands-guide.en.md)** — All 32 terminal commands
320
+ - **[CLI Commands Reference](guide/cli-commands-guide.en.md)** — All 35+ terminal commands
304
321
  - **[Workflow Structure Guide](guide/workflow-structure-guide.en.md)** — Command topology, chain composition
305
322
  - **[Quality Pipeline Guide](guide/quality-pipeline-guide.en.md)** — Verify, review, test pipeline
306
323
  - **[Maestro Coordinator Guide](guide/maestro-coordinator-guide.en.md)** — Multi-agent coordination patterns
package/README.zh-CN.md CHANGED
@@ -242,15 +242,15 @@ maestro command-help # 交互式命令参考(别名: ch)
242
242
 
243
243
  | 指标 | 数量 |
244
244
  |------|------|
245
- | 源文件 (TypeScript) | 454 |
246
- | 代码行数 | ~111,000 |
245
+ | 源文件 (TypeScript) | 333 |
246
+ | 代码行数 | ~80,700 |
247
247
  | 斜杠命令 | 64 |
248
248
  | 工作流定义 | 115 |
249
249
  | 技能包 | 45 |
250
250
  | Agent 定义 | 23 |
251
- | CLI 命令 | 32 |
251
+ | CLI 命令 | 35+ |
252
252
  | 模板 | 92 |
253
- | 指南(双语) | 67 |
253
+ | 指南(双语) | 76 |
254
254
 
255
255
  ### 技术栈
256
256
 
@@ -270,7 +270,7 @@ maestro command-help # 交互式命令参考(别名: ch)
270
270
  maestro/
271
271
  ├── bin/ # CLI 入口
272
272
  ├── src/ # 核心 CLI (Commander.js + MCP SDK)
273
- │ ├── commands/ # 32 个 CLI 命令
273
+ │ ├── commands/ # 35+ 个 CLI 命令
274
274
  │ ├── mcp/ # MCP 服务器 (stdio 传输)
275
275
  │ ├── graph/ # 知识图谱 (SQLite + tree-sitter)
276
276
  │ └── core/ # 工具注册、扩展加载器
@@ -299,7 +299,7 @@ maestro/
299
299
 
300
300
  **工作流**
301
301
  - **[命令使用指南](guide/command-usage-guide.md)** — 全部 64 个命令,含工作流图表和管线衔接
302
- - **[CLI 命令参考](guide/cli-commands-guide.md)** — 全部 32 个终端命令
302
+ - **[CLI 命令参考](guide/cli-commands-guide.md)** — 全部 35+ 个终端命令
303
303
  - **[工作流结构指南](guide/workflow-structure-guide.md)** — 命令拓扑、链组合
304
304
  - **[质量管线指南](guide/quality-pipeline-guide.md)** — verify、review、test 管线
305
305
  - **[Maestro 协调器指南](guide/maestro-coordinator-guide.md)** — 多智能体协调模式
@@ -110,3 +110,13 @@ export interface UninstallOptions {
110
110
  * (schema < 2.0) that don't have hooks/mcp/statusline records.
111
111
  */
112
112
  export declare function uninstallManifest(manifest: Manifest, opts?: UninstallOptions): UninstallResult;
113
+ /**
114
+ * Write `[[skills.config]]` entries to `~/.codex/config.toml` to disable
115
+ * .agents/ skills that duplicate the native codex skills.
116
+ * Returns the number of entries written.
117
+ */
118
+ export declare function writeCodexSkillDedupeConfig(scope: 'global' | 'project', projectPath: string): number;
119
+ /**
120
+ * Remove the maestro-managed dedupe block from codex config.
121
+ */
122
+ export declare function removeCodexSkillDedupeConfig(scope: 'global' | 'project', projectPath: string): boolean;
@@ -710,4 +710,73 @@ function legacyCleanup(manifest, result) {
710
710
  result.mcpRemoved.claude = true;
711
711
  }
712
712
  }
713
+ // ---------------------------------------------------------------------------
714
+ // Codex skill deduplication — disable .agents/ skills in codex config
715
+ // ---------------------------------------------------------------------------
716
+ /**
717
+ * Write `[[skills.config]]` entries to `~/.codex/config.toml` to disable
718
+ * .agents/ skills that duplicate the native codex skills.
719
+ * Returns the number of entries written.
720
+ */
721
+ export function writeCodexSkillDedupeConfig(scope, projectPath) {
722
+ const agentsSkillsDir = scope === 'global'
723
+ ? join(homedir(), '.agents', 'skills')
724
+ : join(projectPath, '.agents', 'skills');
725
+ if (!existsSync(agentsSkillsDir))
726
+ return 0;
727
+ const skillDirs = readdirSync(agentsSkillsDir, { withFileTypes: true })
728
+ .filter(e => e.isDirectory())
729
+ .map(e => e.name);
730
+ if (skillDirs.length === 0)
731
+ return 0;
732
+ const fp = getCodexConfigPath(scope, projectPath);
733
+ let content = '';
734
+ if (existsSync(fp)) {
735
+ content = readFileSync(fp, 'utf-8');
736
+ }
737
+ // Remove existing maestro-managed dedupe block
738
+ const DEDUPE_START = '# maestro:dedupe-agents-start';
739
+ const DEDUPE_END = '# maestro:dedupe-agents-end';
740
+ const startIdx = content.indexOf(DEDUPE_START);
741
+ const endIdx = content.indexOf(DEDUPE_END);
742
+ if (startIdx !== -1 && endIdx !== -1) {
743
+ content = (content.slice(0, startIdx) + content.slice(endIdx + DEDUPE_END.length))
744
+ .replace(/\n{3,}/g, '\n\n').trim();
745
+ }
746
+ const entries = skillDirs.map(name => {
747
+ const skillPath = join(agentsSkillsDir, name, 'SKILL.md').replace(/\\/g, '/');
748
+ return `[[skills.config]]\npath = "${skillPath}"\nenabled = false`;
749
+ });
750
+ const block = [
751
+ '',
752
+ DEDUPE_START,
753
+ ...entries,
754
+ DEDUPE_END,
755
+ ].join('\n');
756
+ content = content ? content + '\n' + block + '\n' : block.trimStart() + '\n';
757
+ const dir = join(fp, '..');
758
+ if (!existsSync(dir))
759
+ mkdirSync(dir, { recursive: true });
760
+ writeFileSync(fp, content, 'utf-8');
761
+ return skillDirs.length;
762
+ }
763
+ /**
764
+ * Remove the maestro-managed dedupe block from codex config.
765
+ */
766
+ export function removeCodexSkillDedupeConfig(scope, projectPath) {
767
+ const fp = getCodexConfigPath(scope, projectPath);
768
+ if (!existsSync(fp))
769
+ return false;
770
+ const content = readFileSync(fp, 'utf-8');
771
+ const DEDUPE_START = '# maestro:dedupe-agents-start';
772
+ const DEDUPE_END = '# maestro:dedupe-agents-end';
773
+ const startIdx = content.indexOf(DEDUPE_START);
774
+ const endIdx = content.indexOf(DEDUPE_END);
775
+ if (startIdx === -1 || endIdx === -1)
776
+ return false;
777
+ const cleaned = (content.slice(0, startIdx) + content.slice(endIdx + DEDUPE_END.length))
778
+ .replace(/\n{3,}/g, '\n\n').trim();
779
+ writeFileSync(fp, cleaned + '\n', 'utf-8');
780
+ return true;
781
+ }
713
782
  //# sourceMappingURL=install-backend.js.map