maestro-flow 0.5.37 → 0.5.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/maestro/SKILL.md +11 -5
- package/.agents/skills/maestro-ralph/SKILL.md +80 -12
- package/.agents/skills/maestro-ralph-execute/SKILL.md +17 -6
- package/.agents/skills/manage-drift-realign/SKILL.md +153 -0
- package/.agents/skills/odyssey-debug/SKILL.md +90 -269
- package/.agents/skills/odyssey-improve/SKILL.md +39 -240
- package/.agents/skills/odyssey-planex/SKILL.md +21 -105
- package/.agents/skills/odyssey-review-test-fix/SKILL.md +98 -318
- package/.agents/skills/odyssey-ui/SKILL.md +82 -265
- package/.agy/skills/maestro/SKILL.md +11 -5
- package/.agy/skills/maestro-ralph/SKILL.md +80 -12
- package/.agy/skills/maestro-ralph-execute/SKILL.md +17 -6
- package/.agy/skills/manage-drift-realign/SKILL.md +153 -0
- package/.agy/skills/odyssey-debug/SKILL.md +90 -269
- package/.agy/skills/odyssey-improve/SKILL.md +39 -240
- package/.agy/skills/odyssey-planex/SKILL.md +21 -105
- package/.agy/skills/odyssey-review-test-fix/SKILL.md +98 -318
- package/.agy/skills/odyssey-ui/SKILL.md +82 -265
- package/.claude/commands/maestro-ralph-execute.md +17 -6
- package/.claude/commands/maestro-ralph.md +80 -12
- package/.claude/commands/maestro.md +11 -5
- package/.claude/commands/manage-drift-realign.md +151 -0
- package/.claude/commands/odyssey-debug.md +90 -269
- package/.claude/commands/odyssey-improve.md +39 -240
- package/.claude/commands/odyssey-planex.md +21 -105
- package/.claude/commands/odyssey-review-test-fix.md +98 -318
- package/.claude/commands/odyssey-ui.md +82 -265
- package/.codex/skills/maestro/SKILL.md +16 -8
- package/.codex/skills/maestro-ralph/SKILL.md +138 -11
- package/.codex/skills/maestro-ralph-execute/SKILL.md +17 -6
- package/.codex/skills/manage-drift-realign/SKILL.md +471 -0
- package/.codex/skills/odyssey-debug/SKILL.md +167 -338
- package/.codex/skills/odyssey-improve/SKILL.md +226 -395
- package/.codex/skills/odyssey-planex/SKILL.md +317 -159
- package/.codex/skills/odyssey-review-test-fix/SKILL.md +137 -255
- package/.codex/skills/odyssey-ui/SKILL.md +197 -338
- package/README.md +25 -8
- package/README.zh-CN.md +6 -6
- package/dashboard/dist-server/dashboard/src/server/wiki/embedding.d.ts +23 -2
- package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +242 -26
- package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +2 -0
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +92 -29
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
- package/dashboard/dist-server/src/commands/hooks.d.ts +2 -1
- package/dashboard/dist-server/src/commands/hooks.js +16 -9
- package/dashboard/dist-server/src/commands/hooks.js.map +1 -1
- package/dashboard/dist-server/src/commands/install-backend.d.ts +10 -0
- package/dashboard/dist-server/src/commands/install-backend.js +69 -0
- package/dashboard/dist-server/src/commands/install-backend.js.map +1 -1
- package/dashboard/dist-server/src/core/component-defs.d.ts +11 -0
- package/dashboard/dist-server/src/core/component-defs.js +34 -2
- package/dashboard/dist-server/src/core/component-defs.js.map +1 -1
- package/dashboard/dist-server/src/hooks/kg-sync-hook.js +5 -0
- package/dashboard/dist-server/src/hooks/kg-sync-hook.js.map +1 -1
- package/dashboard/dist-server/src/hooks/session-context.js +276 -3
- package/dashboard/dist-server/src/hooks/session-context.js.map +1 -1
- package/dashboard/dist-server/src/search/daemon-client.d.ts +8 -3
- package/dashboard/dist-server/src/search/daemon-client.js +20 -0
- package/dashboard/dist-server/src/search/daemon-client.js.map +1 -1
- package/dist/src/cli.js +3 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/domain.d.ts.map +1 -1
- package/dist/src/commands/domain.js +12 -3
- package/dist/src/commands/domain.js.map +1 -1
- package/dist/src/commands/hooks.d.ts +2 -1
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +16 -9
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/install-backend.d.ts +10 -0
- package/dist/src/commands/install-backend.d.ts.map +1 -1
- package/dist/src/commands/install-backend.js +69 -0
- package/dist/src/commands/install-backend.js.map +1 -1
- package/dist/src/commands/install.js +34 -2
- package/dist/src/commands/install.js.map +1 -1
- package/dist/src/commands/ralph.d.ts.map +1 -1
- package/dist/src/commands/ralph.js +8 -0
- package/dist/src/commands/ralph.js.map +1 -1
- package/dist/src/commands/search.d.ts.map +1 -1
- package/dist/src/commands/search.js +59 -6
- package/dist/src/commands/search.js.map +1 -1
- package/dist/src/commands/spec.d.ts.map +1 -1
- package/dist/src/commands/spec.js +15 -0
- package/dist/src/commands/spec.js.map +1 -1
- package/dist/src/commands/timeline.d.ts +14 -0
- package/dist/src/commands/timeline.d.ts.map +1 -0
- package/dist/src/commands/timeline.js +377 -0
- package/dist/src/commands/timeline.js.map +1 -0
- package/dist/src/core/component-defs.d.ts +11 -0
- package/dist/src/core/component-defs.d.ts.map +1 -1
- package/dist/src/core/component-defs.js +34 -2
- package/dist/src/core/component-defs.js.map +1 -1
- package/dist/src/core/install-executor.d.ts.map +1 -1
- package/dist/src/core/install-executor.js +11 -1
- package/dist/src/core/install-executor.js.map +1 -1
- package/dist/src/core/install-profile.d.ts.map +1 -1
- package/dist/src/core/install-profile.js +52 -17
- package/dist/src/core/install-profile.js.map +1 -1
- package/dist/src/hooks/kg-sync-hook.d.ts.map +1 -1
- package/dist/src/hooks/kg-sync-hook.js +5 -0
- package/dist/src/hooks/kg-sync-hook.js.map +1 -1
- package/dist/src/hooks/session-context.d.ts.map +1 -1
- package/dist/src/hooks/session-context.js +276 -3
- package/dist/src/hooks/session-context.js.map +1 -1
- package/dist/src/i18n/locales/en.d.ts.map +1 -1
- package/dist/src/i18n/locales/en.js +4 -1
- package/dist/src/i18n/locales/en.js.map +1 -1
- package/dist/src/i18n/locales/zh.d.ts.map +1 -1
- package/dist/src/i18n/locales/zh.js +4 -1
- package/dist/src/i18n/locales/zh.js.map +1 -1
- package/dist/src/i18n/types.d.ts +3 -0
- package/dist/src/i18n/types.d.ts.map +1 -1
- package/dist/src/ralph/cmd-complete.d.ts +4 -0
- package/dist/src/ralph/cmd-complete.d.ts.map +1 -1
- package/dist/src/ralph/cmd-complete.js +8 -0
- package/dist/src/ralph/cmd-complete.js.map +1 -1
- package/dist/src/ralph/cmd-next.js +58 -8
- package/dist/src/ralph/cmd-next.js.map +1 -1
- package/dist/src/ralph/status-schema.d.ts +29 -2
- package/dist/src/ralph/status-schema.d.ts.map +1 -1
- package/dist/src/ralph/status-schema.js +1 -1
- package/dist/src/search/daemon-client.d.ts +8 -3
- package/dist/src/search/daemon-client.d.ts.map +1 -1
- package/dist/src/search/daemon-client.js +20 -0
- package/dist/src/search/daemon-client.js.map +1 -1
- package/dist/src/search/daemon.d.ts +3 -3
- package/dist/src/search/daemon.d.ts.map +1 -1
- package/dist/src/search/daemon.js +9 -3
- package/dist/src/search/daemon.js.map +1 -1
- package/dist/src/tui/install-ui/ComponentGrid.d.ts.map +1 -1
- package/dist/src/tui/install-ui/ComponentGrid.js +71 -38
- package/dist/src/tui/install-ui/ComponentGrid.js.map +1 -1
- package/dist/src/tui/install-ui/ComponentGrid.logic.d.ts +12 -3
- package/dist/src/tui/install-ui/ComponentGrid.logic.d.ts.map +1 -1
- package/dist/src/tui/install-ui/ComponentGrid.logic.js +21 -4
- package/dist/src/tui/install-ui/ComponentGrid.logic.js.map +1 -1
- package/dist/src/tui/install-ui/CyberItem.d.ts +3 -1
- package/dist/src/tui/install-ui/CyberItem.d.ts.map +1 -1
- package/dist/src/tui/install-ui/CyberItem.js +6 -5
- package/dist/src/tui/install-ui/CyberItem.js.map +1 -1
- package/dist/src/tui/install-ui/GroupedHub.d.ts +9 -0
- package/dist/src/tui/install-ui/GroupedHub.d.ts.map +1 -1
- package/dist/src/tui/install-ui/GroupedHub.js +54 -47
- package/dist/src/tui/install-ui/GroupedHub.js.map +1 -1
- package/dist/src/tui/install-ui/InstallConfirm.js +1 -1
- package/dist/src/tui/install-ui/InstallConfirm.js.map +1 -1
- package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
- package/dist/src/tui/install-ui/InstallFlow.js +54 -5
- package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
- package/dist/src/tui/install-ui/types.d.ts +1 -0
- package/dist/src/tui/install-ui/types.d.ts.map +1 -1
- package/dist/src/tui/install-ui/types.js.map +1 -1
- package/dist/src/tui/install-ui/useInstallFlowState.d.ts +8 -2
- package/dist/src/tui/install-ui/useInstallFlowState.d.ts.map +1 -1
- package/dist/src/tui/install-ui/useInstallFlowState.js +145 -15
- package/dist/src/tui/install-ui/useInstallFlowState.js.map +1 -1
- package/dist/src/utils/update-notices.js +12 -0
- package/dist/src/utils/update-notices.js.map +1 -1
- package/package.json +1 -1
- package/workflows/agy-instructions.md +127 -88
- package/workflows/analyze.md +2 -2
- package/workflows/auto-test.md +7 -1
- package/workflows/blueprint.md +22 -19
- package/workflows/brainstorm.md +11 -3
- package/workflows/business-test.md +4 -0
- package/workflows/codebase-rebuild.md +8 -1
- package/workflows/codebase-refresh.md +7 -1
- package/workflows/codex-instructions.md +1 -1
- package/workflows/debug.md +5 -2
- package/workflows/domain-add.md +6 -0
- package/workflows/drift-realign.md +396 -0
- package/workflows/execute.md +5 -4
- package/workflows/explore-usage.md +2 -2
- package/workflows/finish-work.md +6 -6
- package/workflows/fork.md +2 -2
- package/workflows/grill.md +6 -5
- package/workflows/harvest.md +2 -2
- package/workflows/impeccable.md +3 -2
- package/workflows/init.md +7 -7
- package/workflows/integration-test.md +1 -0
- package/workflows/issue-gaps-analyze.codex.md +2 -0
- package/workflows/issue-gaps-analyze.md +4 -4
- package/workflows/issue-plan.md +1 -1
- package/workflows/knowhow.md +7 -1
- package/workflows/knowledge-audit.md +1 -1
- package/workflows/maestro-super.md +2 -2
- package/workflows/maestro.md +3 -3
- package/workflows/map.md +2 -2
- package/workflows/milestone-audit.md +1 -1
- package/workflows/milestone-complete.md +1 -1
- package/workflows/odyssey-base.md +258 -0
- package/workflows/plan.md +7 -6
- package/workflows/quick.md +8 -6
- package/workflows/ralph-amend-goal.md +177 -0
- package/workflows/refactor.md +2 -0
- package/workflows/retrospective.md +7 -3
- package/workflows/review.md +6 -4
- package/workflows/roadmap-common.md +3 -3
- package/workflows/roadmap.md +8 -5
- package/workflows/spec-generate.md +23 -18
- package/workflows/specs-load.md +1 -1
- package/workflows/specs-setup.md +2 -0
- package/workflows/sync.md +4 -2
- package/workflows/test-gen.md +1 -1
- package/workflows/test.md +1 -1
- package/workflows/ui-codify-extract.md +1 -0
- package/workflows/ui-codify-knowhow.md +1 -1
- package/workflows/ui-codify-package.md +1 -1
- package/workflows/ui-codify.md +9 -7
- package/workflows/ui-design.md +9 -7
- package/workflows/ui-style.md +6 -4
- package/workflows/verify.md +4 -4
- package/workflows/wiki-connect.md +2 -0
- package/workflows/wiki-digest.md +5 -3
- package/workflows/wiki-manage.md +4 -0
- 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>
|