maestro-flow 0.4.17 → 0.4.18

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 (80) hide show
  1. package/.agents/skills/maestro/SKILL.md +1 -1
  2. package/.agents/skills/maestro-analyze/SKILL.md +5 -0
  3. package/.agents/skills/maestro-blueprint/SKILL.md +5 -0
  4. package/.agents/skills/maestro-brainstorm/SKILL.md +5 -0
  5. package/.agents/skills/maestro-next/SKILL.md +219 -0
  6. package/.agy/skills/maestro/SKILL.md +1 -1
  7. package/.agy/skills/maestro-analyze/SKILL.md +5 -0
  8. package/.agy/skills/maestro-blueprint/SKILL.md +5 -0
  9. package/.agy/skills/maestro-brainstorm/SKILL.md +5 -0
  10. package/.agy/skills/maestro-next/SKILL.md +215 -0
  11. package/.claude/commands/maestro-analyze.md +5 -0
  12. package/.claude/commands/maestro-blueprint.md +5 -0
  13. package/.claude/commands/maestro-brainstorm.md +5 -0
  14. package/.claude/commands/maestro-next.md +217 -0
  15. package/.claude/commands/maestro.md +1 -1
  16. package/.codex/skills/learn-decompose/SKILL.md +34 -3
  17. package/.codex/skills/learn-retro/SKILL.md +31 -1
  18. package/.codex/skills/learn-second-opinion/SKILL.md +34 -4
  19. package/.codex/skills/maestro-analyze/SKILL.md +44 -5
  20. package/.codex/skills/maestro-blueprint/SKILL.md +5 -0
  21. package/.codex/skills/maestro-brainstorm/SKILL.md +46 -0
  22. package/.codex/skills/maestro-execute/SKILL.md +61 -5
  23. package/.codex/skills/maestro-milestone-audit/SKILL.md +64 -13
  24. package/.codex/skills/maestro-milestone-complete/SKILL.md +12 -0
  25. package/.codex/skills/maestro-plan/SKILL.md +36 -1
  26. package/.codex/skills/maestro-player/SKILL.md +25 -6
  27. package/.codex/skills/maestro-ralph/SKILL.md +17 -10
  28. package/.codex/skills/maestro-ralph-execute/SKILL.md +2 -1
  29. package/.codex/skills/maestro-roadmap/SKILL.md +35 -4
  30. package/.codex/skills/maestro-ui-codify/SKILL.md +38 -10
  31. package/.codex/skills/maestro-verify/SKILL.md +40 -5
  32. package/.codex/skills/manage-codebase-rebuild/SKILL.md +52 -5
  33. package/.codex/skills/manage-issue-discover/SKILL.md +106 -15
  34. package/.codex/skills/quality-auto-test/SKILL.md +70 -16
  35. package/.codex/skills/quality-debug/SKILL.md +139 -28
  36. package/.codex/skills/quality-refactor/SKILL.md +61 -11
  37. package/.codex/skills/quality-review/SKILL.md +45 -9
  38. package/.codex/skills/quality-test/SKILL.md +58 -3
  39. package/.codex/skills/security-audit/SKILL.md +38 -0
  40. package/.codex/skills/spec-map/SKILL.md +65 -8
  41. package/.codex/skills/team-coordinate/SKILL.md +28 -11
  42. package/.codex/skills/team-coordinate/specs/role-catalog.md +20 -0
  43. package/.codex/skills/team-lifecycle-v4/SKILL.md +23 -7
  44. package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +20 -0
  45. package/.codex/skills/team-quality-assurance/SKILL.md +40 -2
  46. package/.codex/skills/team-review/SKILL.md +42 -2
  47. package/.codex/skills/team-tech-debt/SKILL.md +45 -2
  48. package/.codex/skills/team-testing/SKILL.md +42 -2
  49. package/dashboard/dist-server/dashboard/src/server/wiki/search.d.ts +6 -4
  50. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +50 -8
  51. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  52. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +32 -0
  53. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +294 -0
  54. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  55. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
  56. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +35 -1
  57. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  58. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js +235 -0
  59. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js.map +1 -1
  60. package/dist/src/ralph/cmd-check.js +1 -1
  61. package/dist/src/ralph/cmd-check.js.map +1 -1
  62. package/dist/src/ralph/cmd-complete.js +1 -1
  63. package/dist/src/ralph/cmd-complete.js.map +1 -1
  64. package/dist/src/ralph/cmd-next.d.ts.map +1 -1
  65. package/dist/src/ralph/cmd-next.js +12 -4
  66. package/dist/src/ralph/cmd-next.js.map +1 -1
  67. package/dist/src/ralph/cmd-session.js +2 -2
  68. package/dist/src/ralph/cmd-session.js.map +1 -1
  69. package/dist/src/ralph/status-store.d.ts +8 -1
  70. package/dist/src/ralph/status-store.d.ts.map +1 -1
  71. package/dist/src/ralph/status-store.js +12 -2
  72. package/dist/src/ralph/status-store.js.map +1 -1
  73. package/dist/src/tools/store-knowhow.d.ts.map +1 -1
  74. package/dist/src/tools/store-knowhow.js +51 -64
  75. package/dist/src/tools/store-knowhow.js.map +1 -1
  76. package/dist/src/utils/update-notices.js +12 -0
  77. package/dist/src/utils/update-notices.js.map +1 -1
  78. package/package.json +1 -1
  79. package/workflows/finish-work.md +119 -0
  80. package/workflows/milestone-complete.md +23 -1
@@ -28,9 +28,9 @@ $maestro-milestone-audit "M1"
28
28
  ### tasks.csv (Master State)
29
29
 
30
30
  ```csv
31
- id,title,description,scope,check_targets,deps,wave
32
- "integ-1","Interface & dependency chains","Verify shared interfaces are consistent across phases: re-exports match, dependency chains unbroken, no circular imports between phase outputs","cross-phase imports, shared types, re-exports","grep for shared type names across phase output dirs; verify export/import consistency","","1"
33
- "integ-2","Data contracts & API consistency","Verify request/response schemas match across phases: API signatures consistent, error codes aligned, no contract drift","request/response schemas, API signatures, error codes","diff API type definitions across phases; check error code enum consistency","","1"
31
+ id,title,description,scope,check_targets,deps,wave,status,findings,gaps_found,severity,error
32
+ "integ-1","Interface & dependency chains","Verify shared interfaces are consistent across phases: re-exports match, dependency chains unbroken, no circular imports between phase outputs","cross-phase imports, shared types, re-exports","grep for shared type names across phase output dirs; verify export/import consistency","","1","pending","","","",""
33
+ "integ-2","Data contracts & API consistency","Verify request/response schemas match across phases: API signatures consistent, error codes aligned, no contract drift","request/response schemas, API signatures, error codes","diff API type definitions across phases; check error code enum consistency","","1","pending","","","",""
34
34
  ```
35
35
 
36
36
  **Columns**:
@@ -44,13 +44,13 @@ id,title,description,scope,check_targets,deps,wave
44
44
  | `check_targets` | Input | Specific verification commands/grep patterns |
45
45
  | `deps` | Input | Dependencies (empty — all wave 1) |
46
46
  | `wave` | Computed | Wave number (always 1 — single parallel wave) |
47
- | `result_status` | Output | `pass` / `fail` / `warning` |
48
- | `findings` | Output | Detailed findings per dimension (max 500 chars) |
49
- | `gaps_found` | Output | Semicolon-separated list of integration gaps |
50
- | `severity` | Output | `critical` / `warning` / `info` per gap |
51
- | `error` | Output | Error message if check failed |
47
+ | `status` | Lifecycle | `pending` (initial) `pass`/`fail`/`warning`/`failed` (set by merge step from worker's `result_status`) |
48
+ | `findings` | Lifecycle | Detailed findings per dimension (max 500 chars; merged) |
49
+ | `gaps_found` | Lifecycle | Semicolon-separated list of integration gaps (merged) |
50
+ | `severity` | Lifecycle | `critical` / `warning` / `info` per gap (merged) |
51
+ | `error` | Lifecycle | Error message if check failed (merged) |
52
52
 
53
- **Column separation rule**: Input columns and Output columns MUST NOT share names. Wave CSV only contains Input columns. Output columns are returned exclusively via output_schema.
53
+ **Column separation rule**: Wave CSV (input to `spawn_agents_on_csv`) contains Input columns only. Workers return Output columns exclusively via `output_schema` using `result_status` (NOT `status`). Merge maps `result_status` master `status`.
54
54
 
55
55
  ### Session Structure
56
56
 
@@ -95,16 +95,67 @@ Verify all adhoc-scoped artifacts completed. For each execute artifact, verify a
95
95
 
96
96
  ```javascript
97
97
  spawn_agents_on_csv({
98
- csv_path: `${sessionFolder}/wave-1.csv`,
98
+ csv_path: `${sessionFolder}/wave-1.csv`, // rows where wave==1 AND status=="pending"
99
99
  id_column: "id",
100
- instruction: `You are an integration checker for milestone ${milestone}. For each row, examine the scope and check_targets. Search the codebase for inconsistencies, contract drift, and broken dependencies across phase outputs. Report findings with file:line references. Set result_status to pass/fail/warning. List specific gaps in gaps_found (semicolon-separated).`,
101
- max_concurrency: 2, max_runtime_seconds: 600,
100
+ instruction: AUDIT_INTEGRATION_INSTRUCTION, // see "Integration Checker Worker Contract" below
101
+ max_concurrency: 2,
102
+ max_runtime_seconds: 600,
102
103
  output_csv_path: `${sessionFolder}/wave-1-results.csv`,
103
- output_schema: { id, result_status: [pass|fail|warning], findings, gaps_found, severity, error }
104
+ output_schema: {
105
+ type: "object",
106
+ properties: {
107
+ id: { type: "string" },
108
+ result_status: { type: "string", enum: ["pass", "fail", "warning", "failed"] },
109
+ findings: { type: "string", maxLength: 500 },
110
+ gaps_found: { type: "string", description: "Semicolon-separated list of gaps" },
111
+ severity: { type: "string", enum: ["critical", "warning", "info", ""] },
112
+ error: { type: "string" }
113
+ },
114
+ required: ["id", "result_status", "findings", "severity"]
115
+ }
104
116
  })
105
117
  ```
106
118
 
107
119
  4. Merge results into master `tasks.csv`: map `result_status` → master `status` column, copy `findings`, `gaps_found`, `severity`, `error`. Delete temporary files (`wave-1.csv`, `wave-1-results.csv`) after merge.
120
+
121
+ #### Integration Checker Worker Contract (AUDIT_INTEGRATION_INSTRUCTION)
122
+
123
+ ```
124
+ You are an integration checker for milestone {milestone}. ONE integration dimension row is assigned to you.
125
+
126
+ INPUT (from your CSV row):
127
+ - id (integ-N), title, description, scope, check_targets
128
+
129
+ REQUIRED STEPS:
130
+ 1. Examine scope and check_targets fields
131
+ 2. Run check_targets — grep / read phase output dirs / diff API definitions
132
+ 3. Identify inconsistencies, contract drift, broken dependencies across phase outputs
133
+ 4. Record findings with file:line references for every gap
134
+ 5. Call report_agent_job_result EXACTLY ONCE
135
+
136
+ TERMINATION CONTRACT (mandatory — NO worker may end without calling report_agent_job_result):
137
+ - Pass path → no gaps found → result_status=pass, severity="info"
138
+ - Warning path → minor gaps → result_status=warning, severity="warning"
139
+ - Fail path → critical contract drift or broken dependencies → result_status=fail, severity="critical"
140
+ - Failure path → cannot read scope, tool error → result_status=failed with error message
141
+ - Timeout path → near 600s, finalize current findings → report with what was collected
142
+ - NEVER skip report_agent_job_result.
143
+
144
+ OUTPUT (must match output_schema):
145
+ {
146
+ "id": "<your row id>",
147
+ "result_status": "pass" | "warning" | "fail" | "failed",
148
+ "findings": "<one-sentence summary, max 500 chars>",
149
+ "gaps_found": "<semicolon-separated list of gaps, each with file:line; empty if pass>",
150
+ "severity": "critical" | "warning" | "info" | "",
151
+ "error": "<message if failed, else empty>"
152
+ }
153
+
154
+ CONSTRAINTS:
155
+ - Read-only inspection. Do NOT modify phase outputs.
156
+ - Do NOT write to tasks.csv, wave-*.csv, audit-report.md (orchestrator owns those).
157
+ - Do NOT call spawn_agents_on_csv (no recursion).
158
+ ```
108
159
  5. Parse `gaps_found` from all workers — aggregate into `.workflow/milestones/{milestone}/audit-report.md`
109
160
  6. Any worker with `result_status == fail` and `severity == critical` → milestone verdict = FAIL
110
161
 
@@ -51,6 +51,18 @@ Copy each milestone artifact's directory to `.workflow/milestones/{milestone}/ar
51
51
  - If `artifact.path` is absolute, use as-is
52
52
  - Copy the entire resolved directory to `.workflow/milestones/{milestone}/artifacts/{artifact.name}/`
53
53
 
54
+ **After each copy** (per archived session dir):
55
+
56
+ a. If destination contains `archive.json` with `lifecycle.status == "sealed"`:
57
+ - Set `lifecycle.status = "archived"`, `lifecycle.archived_at = now`, `lifecycle.linked_milestone = {milestone}` (if null).
58
+
59
+ b. If destination contains `context-package.json`, prune (scheme C — non-destructive):
60
+ - Compute `pruned` = { `open_questions` without answer/resolved_in; `constraints` status=open; `insights` beyond top 20; `references` whose path does not exist on disk }
61
+ - If any `pruned.*` non-empty: write `context-package.pruned.json` with the dropped items; rewrite `context-package.json` keeping only answered/resolved questions, locked constraints, `insights[0..20]`, valid-path references; update `archive.json.pruned = { at: now, counts, ref: "context-package.pruned.json" }`
62
+ - Otherwise: set `archive.json.pruned = { at: now, counts: zeros, ref: null }`
63
+
64
+ c. If session dir lacks `archive.json` (legacy): skip a+b silently — legacy sessions are not indexed.
65
+
54
66
  Snapshot `roadmap.md` as `roadmap-snapshot.md` in the milestone archive.
55
67
 
56
68
  ### Step 3: Extract Learnings
@@ -154,8 +154,41 @@ S_REGISTER → END DO: A_REGISTER
154
154
 
155
155
  <actions>
156
156
 
157
+ ### Shared Spawn Contract (W1 and W2)
158
+
159
+ Every `spawn_agents_on_csv` call MUST filter `wave==N AND status=="pending"` rows from master tasks.csv, use the strict JSON Schema below, and embed the termination contract.
160
+
161
+ **Output Schema**:
162
+
163
+ ```json
164
+ {
165
+ "type": "object",
166
+ "properties": {
167
+ "id": { "type": "string" },
168
+ "result_status": { "type": "string", "enum": ["completed", "failed", "blocked"] },
169
+ "findings": { "type": "string", "maxLength": 500 },
170
+ "files_modified":{ "type": "string", "description": "Semicolon-separated paths (W2 writes plan.json + .task/*)" },
171
+ "error": { "type": "string" }
172
+ },
173
+ "required": ["id", "result_status", "findings"]
174
+ }
175
+ ```
176
+
177
+ Merge: `result_status` → master `status`; copy `findings`, `files_modified`, `error`.
178
+
179
+ **Termination contract** (embed in every instruction):
180
+ ```
181
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
182
+ - Success → result_status=completed (W2: plan.json AND .task/* MUST exist on disk before reporting completed)
183
+ - Failure → result_status=failed with error message
184
+ - Blocked → upstream context insufficient → result_status=blocked
185
+ - Timeout → near max_runtime_seconds → result_status=blocked, error="timeout"
186
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
187
+ Do NOT write to tasks.csv, wave-*.csv, results.csv, state.json. Do NOT call spawn_agents_on_csv (no recursion).
188
+ ```
189
+
157
190
  ### Exploration agent responsibilities (W1)
158
- Each explores one angle: architecture (module boundaries, deps), patterns (similar implementations), tests (framework, conventions), risks (complexity, blockers). Reads files, maps dependencies, shares via discoveries.ndjson.
191
+ Each explores one angle: architecture (module boundaries, deps), patterns (similar implementations), tests (framework, conventions), risks (complexity, blockers). Reads files, maps dependencies, shares via discoveries.ndjson. Read-only — does NOT write plan.json.
159
192
 
160
193
  ### Planning agent responsibilities (W2)
161
194
  Consumes all exploration findings + context.md + specs. Produces:
@@ -163,6 +196,8 @@ Consumes all exploration findings + context.md + specs. Produces:
163
196
  - `.task/TASK-*.json`: each with read_first[], convergence.criteria[] (grep-verifiable), concrete action/implementation
164
197
  - Deep Work Rules: every task has read_first with file being modified + source of truth files
165
198
 
199
+ Verifies plan.json and every .task/*.json exists on disk before reporting completed; else report blocked.
200
+
166
201
  ### A_PLAN_CHECK
167
202
  Run plan-checker: coverage, dependency validity, criteria quality, pressure pass on highest-complexity task.
168
203
  Confidence: 5-dimension factor model + readiness gate.
@@ -137,17 +137,17 @@ S_COMPLETE:
137
137
 
138
138
  1. **Checkpoint**: handle inline — save snapshot, update context.last_checkpoint, mark completed. If auto_continue==false: AskUserQuestion (Continue/Pause/Abort).
139
139
 
140
- 2. **Skill nodes**: resolve runtime references → write wave-{N}.csv → spawn:
140
+ 2. **Skill nodes**: resolve runtime references → write wave-{N}.csv (only rows with status == "pending") → spawn:
141
141
  ```
142
142
  spawn_agents_on_csv({
143
143
  csv_path: "wave-{N}.csv", id_column: "id",
144
144
  instruction: SUB_AGENT_INSTRUCTION,
145
- max_workers: waveSteps.length, max_runtime_seconds: 3600,
145
+ max_concurrency: waveSteps.length, max_runtime_seconds: 3600,
146
146
  output_csv_path: "wave-{N}-results.csv", output_schema: RESULT_SCHEMA
147
147
  })
148
148
  ```
149
149
 
150
- 3. Read results → update step status/findings/artifacts
150
+ 3. Read results → map `result_status` → master step `status`; copy `summary` into findings and `artifacts` into the step artifact list
151
151
  4. **Barrier analysis**: read artifacts, update context per barrier table
152
152
  5. Append wave record to state.waves[], persist state.json
153
153
 
@@ -158,14 +158,33 @@ spawn_agents_on_csv({
158
158
  先原样执行技能调用:{skill_call}
159
159
  然后基于结果完成任务说明:{topic}
160
160
  限制:不要修改 .workflow/.maestro/ 下的 state 文件
161
- 最后调用 report_agent_job_result,返回 JSON:
162
- {"status":"completed|failed","skill_call":"...","summary":"一句话","artifacts":"路径或空","error":"原因或空"}
161
+ 最后必须调用 report_agent_job_result(无论成功/失败/超时都必须上报)。
162
+
163
+ TERMINATION CONTRACT(强制):
164
+ - 成功:result_status = completed,summary 描述产出
165
+ - 失败:result_status = failed,error 写明原因
166
+ - 超时:临近 max_runtime_seconds 时立即上报 result_status = failed,error = "timeout"
167
+ - 禁止:无限循环、静默退出、跳过 report_agent_job_result
168
+
169
+ OUTPUT(必须匹配 output_schema):
170
+ {"id":"<row id>","result_status":"completed|failed","skill_call":"...","summary":"一句话","artifacts":"路径或空","error":"原因或空"}
163
171
  ```
164
172
 
165
173
  ### RESULT_SCHEMA
166
174
 
167
175
  ```json
168
- { "status": "completed|failed", "skill_call": "", "summary": "", "artifacts": "", "error": "" }
176
+ {
177
+ "type": "object",
178
+ "properties": {
179
+ "id": { "type": "string" },
180
+ "result_status": { "type": "string", "enum": ["completed", "failed"] },
181
+ "skill_call": { "type": "string" },
182
+ "summary": { "type": "string", "maxLength": 500 },
183
+ "artifacts": { "type": "string" },
184
+ "error": { "type": "string" }
185
+ },
186
+ "required": ["id", "result_status", "summary"]
187
+ }
169
188
  ```
170
189
 
171
190
  </actions>
@@ -1,17 +1,22 @@
1
1
  ---
2
2
  name: maestro-ralph
3
3
  description: Use when the optimal command sequence is unclear and needs automated state-based determination
4
- argument-hint: "<intent> [-y] | status | continue"
4
+ argument-hint: "<intent> [-y] | status [session-id] | continue [session-id]"
5
5
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep, request_user_input
6
6
  ---
7
7
  <purpose>
8
8
  Closed-loop decision engine for the maestro workflow lifecycle.
9
9
  Reads project state → infers position → builds adaptive chain → delegates execution.
10
10
 
11
- Entry points:
12
- - **`/maestro-ralph "intent"`** — New session: infer → decompose → build → emit /goal prompt(如有 decomposition)→ dispatch ralph-execute
13
- - **`/maestro-ralph continue`** Wrapper; dispatches to ralph-execute(首选直接 `/maestro-ralph-execute` 推进 step)
14
- - **`/maestro-ralph status`** — Display session progress
11
+ ### Session
12
+
13
+ `.workflow/.maestro/{session_id}/status.json`工作流唯一真源(schema `<appendix>`)。session_id 格式:`ralph-{YYYYMMDD-HHmmss}`(本 skill 创建,自适应链)或 `maestro-{YYYYMMDD-HHmmss}`(`/maestro` coordinator 创建,静态链)。两类都由 `/maestro-ralph-execute` 推进。session-id 省略时取最新 `status=="running"`。
14
+
15
+ ### Entry points
16
+
17
+ - **`/maestro-ralph "intent"`** — 新建 session:infer → decompose → build → emit /goal prompt(如有 decomposition)→ dispatch ralph-execute
18
+ - **`/maestro-ralph continue [session-id]`** — 恢复执行;省略=最新 running(首选直接 `/maestro-ralph-execute [session-id]`)
19
+ - **`/maestro-ralph status [session-id]`** — 显示进度;省略=最新 ralph session
15
20
 
16
21
  > 推进规则:**step 推进由 `/maestro-ralph-execute` 负责**;ralph 仅在 build / decision 评估时介入。decision 节点由 ralph-execute 自动 `$maestro-ralph` 直调 handoff,无需用户手动切换。
17
22
 
@@ -48,9 +53,10 @@ $ARGUMENTS — intent text, flags, or keywords.
48
53
 
49
54
  **Parse:**
50
55
  ```
51
- -y flag → auto_confirm = true
52
- .md/.txt path → input_doc (supplementary context only, NEVER substitutes lifecycle stages)
53
- Remaining → intent
56
+ -y flag → auto_confirm = true
57
+ .md/.txt path → input_doc (supplementary context only, NEVER substitutes lifecycle stages)
58
+ status|continue + session-idintent ∈ {status,continue} 且后续 token 匹配 ralph-*|maestro-* → target_session_id
59
+ Remaining → intent
54
60
  ```
55
61
 
56
62
  **State files:**
@@ -108,7 +114,8 @@ S_STATUS:
108
114
  → END DO: A_SHOW_STATUS
109
115
 
110
116
  S_CONTINUE:
111
- → S_DISPATCH WHEN: running session found
117
+ → S_DISPATCH WHEN: target_session_id provided AND session exists
118
+ → S_DISPATCH WHEN: running session found (no target_session_id → latest running)
112
119
  → S_FALLBACK WHEN: no running session DO: display "无运行中的 ralph 会话"
113
120
 
114
121
  S_RESOLVE_PHASE:
@@ -189,7 +196,7 @@ S_FALLBACK:
189
196
 
190
197
  ### A_SHOW_STATUS
191
198
 
192
- 1. Find latest ralph session (by created_at)
199
+ 1. `target_session_id` 提供 → 直接加载 `.workflow/.maestro/{target_session_id}/status.json`;否则取最新 ralph sessionby created_at
193
200
  2. Display: Session, Status, Position, Progress, Current step
194
201
  3. List steps: [✓] completion_confirmed, [▸] current, [ ] pending, [◆] decision(`step.decision` 非空);执行 step 附 `command_scope`(global/project) + `command_path`
195
202
  4. If `task_decomposition` present (absent → skip):
@@ -9,7 +9,8 @@ Single-step executor for ralph (adaptive) and maestro (static) sessions.
9
9
  Each invocation: locate session → find next step → resolve args → execute → update → self-invoke next.
10
10
 
11
11
  Mutual invocation with `/maestro-ralph` forms a self-perpetuating work loop.
12
- Session: `.workflow/.maestro/*/status.json`
12
+
13
+ **Session**: `.workflow/.maestro/{session_id}/status.json` — 工作流唯一真源。session_id 格式 `ralph-{YYYYMMDD-HHmmss}`(/maestro-ralph 创建,自适应链)或 `maestro-{YYYYMMDD-HHmmss}`(/maestro 创建,静态链)。两类都由本 skill 推进;省略 `[session-id]` 时取最新 `status=="running"`。Schema 详见 `/maestro-ralph` 的 Session Schema。
13
14
  </purpose>
14
15
 
15
16
  <context>
@@ -110,19 +110,50 @@ S_AGGREGATE:
110
110
 
111
111
  <actions>
112
112
 
113
+ ### Shared Spawn Contract (W1 and W2)
114
+
115
+ Every `spawn_agents_on_csv` call MUST filter `wave==N AND status=="pending"` and use this strict JSON Schema:
116
+
117
+ ```json
118
+ {
119
+ "type": "object",
120
+ "properties": {
121
+ "id": { "type": "string" },
122
+ "result_status": { "type": "string", "enum": ["completed", "failed", "blocked"] },
123
+ "findings": { "type": "string", "maxLength": 500 },
124
+ "output_path": { "type": "string", "description": "W2 only: absolute path of roadmap.md (empty for W1 agents that just return findings)" },
125
+ "error": { "type": "string" }
126
+ },
127
+ "required": ["id", "result_status", "findings"]
128
+ }
129
+ ```
130
+
131
+ Merge: `result_status` → master `status`; copy `findings`, `output_path`, `error`.
132
+
133
+ **Shared termination contract** (embed in every instruction):
134
+ ```
135
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
136
+ - Success → result_status=completed (W2: roadmap.md MUST exist on disk)
137
+ - Failure → result_status=failed with error message
138
+ - Blocked → upstream context insufficient → result_status=blocked
139
+ - Timeout → near max_runtime_seconds → result_status=blocked, error="timeout"
140
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
141
+ Do NOT write to tasks.csv, wave-*.csv, results.csv. Do NOT call spawn_agents_on_csv (no recursion).
142
+ ```
143
+
113
144
  ### A_SPAWN_WAVE_1
114
145
 
115
- Filter wave==1 -> write wave-1.csv -> `spawn_agents_on_csv`.
146
+ Filter `wave==1 AND status=="pending"` -> write wave-1.csv -> spawn.
116
147
 
117
- **Agents**: scope analysis (feature inventory + priority), risk analysis (unknowns + mitigations), dependency analysis (dependency graph + critical path).
148
+ **Agents**: scope analysis (feature inventory + priority), risk analysis (unknowns + mitigations), dependency analysis (dependency graph + critical path). Read-only.
118
149
 
119
150
  Merge results -> master tasks.csv.
120
151
 
121
152
  ### A_SPAWN_WAVE_2
122
153
 
123
- Build prev_context from wave 1. Inject strategy + `--phases` constraint. Spawn.
154
+ Filter `wave==2 AND status=="pending"`. Build prev_context from wave 1. Inject strategy + `--phases` constraint. Spawn.
124
155
 
125
- Assembly agent produces roadmap.md with Milestone > Phase hierarchy (goal, depends-on, requirements, success criteria), scope decisions.
156
+ Assembly agent produces roadmap.md with Milestone > Phase hierarchy (goal, depends-on, requirements, success criteria), scope decisions. Verifies roadmap.md on disk before reporting completed.
126
157
 
127
158
  **Strategy selection** via uncertainty assessment (5 factors):
128
159
  | Factor | Low | Medium | High |
@@ -260,7 +260,35 @@ Write `tasks.csv` to `${sessionFolder}/tasks.csv`.
260
260
 
261
261
  ### Step 4: Wave Execution
262
262
 
263
- Execute waves sequentially via `spawn_agents_on_csv`.
263
+ Execute waves sequentially via `spawn_agents_on_csv`. All four waves share the same `output_schema` shape (below) — only `instruction` differs.
264
+
265
+ **Shared output_schema** (strict JSON Schema):
266
+
267
+ ```javascript
268
+ const UI_CODIFY_OUTPUT_SCHEMA = {
269
+ type: "object",
270
+ properties: {
271
+ id: { type: "string" },
272
+ result_status: { type: "string", enum: ["completed", "failed"] },
273
+ findings: { type: "string", maxLength: 500 },
274
+ output_path: { type: "string", description: "Absolute path of the file/dir produced by this worker (empty if failed)" },
275
+ error: { type: "string" }
276
+ },
277
+ required: ["id", "result_status", "findings"]
278
+ }
279
+ ```
280
+
281
+ **Shared termination contract** (embed in every `instruction` below):
282
+
283
+ ```
284
+ TERMINATION CONTRACT (mandatory — NO worker may end without calling report_agent_job_result):
285
+ - Success → result_status=completed, output_path set to the absolute path of the artifact you wrote
286
+ - Failure → unrecoverable error → result_status=failed, output_path=""
287
+ - Timeout → near max_runtime_seconds, finalize current write if safe → otherwise report failed with error="timeout"
288
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
289
+ - Do NOT write to tasks.csv, wave-*.csv, results.csv (orchestrator owns those).
290
+ - Do NOT call spawn_agents_on_csv (no recursion).
291
+ ```
264
292
 
265
293
  #### Wave 1: File Discovery (Barrier)
266
294
 
@@ -270,15 +298,15 @@ Filter `wave == 1 && status == pending` from master CSV. Write `wave-1.csv`.
270
298
  spawn_agents_on_csv({
271
299
  csv_path: `${sessionFolder}/wave-1.csv`,
272
300
  id_column: "id",
273
- instruction: `You are scanning a source directory for design-relevant files. Read the 'description' column for full instructions. Use Glob to find files, Read to sample content. Write file inventory JSON to the specified path. Report findings as a concise summary.`,
301
+ instruction: `You are scanning a source directory for design-relevant files. Read the 'description' column for full instructions. Use Glob to find files, Read to sample content. Write file inventory JSON to the specified path. Report findings as a concise summary.\n\n${SHARED_TERMINATION_CONTRACT}`,
274
302
  max_concurrency: 1,
275
303
  max_runtime_seconds: 1800,
276
304
  output_csv_path: `${sessionFolder}/wave-1-results.csv`,
277
- output_schema: { id, result_status: ["completed"|"failed"], findings, output_path, error }
305
+ output_schema: UI_CODIFY_OUTPUT_SCHEMA
278
306
  })
279
307
  ```
280
308
 
281
- Merge wave-1-results.csv into master `tasks.csv`: map `result_status` -> master `status` column, then delete `wave-1.csv` and `wave-1-results.csv`.
309
+ Merge wave-1-results.csv into master `tasks.csv`: map `result_status` -> master `status` column; copy `findings`, `output_path`, `error`. Delete `wave-1.csv` and `wave-1-results.csv`.
282
310
 
283
311
  #### Wave 2: Parallel Extraction (3 agents)
284
312
 
@@ -288,11 +316,11 @@ Filter `wave == 2 && status == pending`. Build `prev_context` from wave 1 findin
288
316
  spawn_agents_on_csv({
289
317
  csv_path: `${sessionFolder}/wave-2.csv`,
290
318
  id_column: "id",
291
- instruction: `You are extracting design tokens from source code. Read the 'description' column for your specific extraction task. Use prev_context for file inventory from discovery phase. Read source files, extract tokens, write output JSON to the specified path.`,
319
+ instruction: `You are extracting design tokens from source code. Read the 'description' column for your specific extraction task. Use prev_context for file inventory from discovery phase. Read source files, extract tokens, write output JSON to the specified path.\n\n${SHARED_TERMINATION_CONTRACT}`,
292
320
  max_concurrency: 3,
293
321
  max_runtime_seconds: 3600,
294
322
  output_csv_path: `${sessionFolder}/wave-2-results.csv`,
295
- output_schema: { id, result_status: ["completed"|"failed"], findings, output_path, error }
323
+ output_schema: UI_CODIFY_OUTPUT_SCHEMA
296
324
  })
297
325
  ```
298
326
 
@@ -308,11 +336,11 @@ Filter `wave == 3 && status == pending`. Build `prev_context` from wave 2 findin
308
336
  spawn_agents_on_csv({
309
337
  csv_path: `${sessionFolder}/wave-3.csv`,
310
338
  id_column: "id",
311
- instruction: `You are generating a reference design package. Read the 'description' column for full instructions. Copy token files, generate preview.html and preview.css. Report package contents in findings.`,
339
+ instruction: `You are generating a reference design package. Read the 'description' column for full instructions. Copy token files, generate preview.html and preview.css. Report package contents in findings.\n\n${SHARED_TERMINATION_CONTRACT}`,
312
340
  max_concurrency: 1,
313
341
  max_runtime_seconds: 1800,
314
342
  output_csv_path: `${sessionFolder}/wave-3-results.csv`,
315
- output_schema: { id, result_status: ["completed"|"failed"], findings, output_path, error }
343
+ output_schema: UI_CODIFY_OUTPUT_SCHEMA
316
344
  })
317
345
  ```
318
346
 
@@ -326,11 +354,11 @@ Filter `wave == 4 && status == pending`. Build `prev_context` from wave 3 findin
326
354
  spawn_agents_on_csv({
327
355
  csv_path: `${sessionFolder}/wave-4.csv`,
328
356
  id_column: "id",
329
- instruction: `You are building knowledge assets from a design package. Read the 'description' column for full instructions. Build manifest, write knowhow files, create spec entries, refresh wiki index, cleanup temp files. Report asset counts in findings.`,
357
+ instruction: `You are building knowledge assets from a design package. Read the 'description' column for full instructions. Build manifest, write knowhow files, create spec entries, refresh wiki index, cleanup temp files. Report asset counts in findings.\n\n${SHARED_TERMINATION_CONTRACT}`,
330
358
  max_concurrency: 1,
331
359
  max_runtime_seconds: 1800,
332
360
  output_csv_path: `${sessionFolder}/wave-4-results.csv`,
333
- output_schema: { id, result_status: ["completed"|"failed"], findings, output_path, error }
361
+ output_schema: UI_CODIFY_OUTPUT_SCHEMA
334
362
  })
335
363
  ```
336
364
 
@@ -128,23 +128,58 @@ S_AGGREGATE:
128
128
 
129
129
  <actions>
130
130
 
131
+ ### Shared Spawn Contract (W1, W2, W3)
132
+
133
+ Every `spawn_agents_on_csv` call MUST filter `wave==N AND status=="pending"` from master tasks.csv and use the strict JSON Schema below.
134
+
135
+ **output_schema**:
136
+
137
+ ```json
138
+ {
139
+ "type": "object",
140
+ "properties": {
141
+ "id": { "type": "string" },
142
+ "result_status": { "type": "string", "enum": ["completed", "failed", "blocked"] },
143
+ "verdict": { "type": "string", "description": "Per-agent verdict (e.g., VERIFIED/FAILED/UNCERTAIN, SUBSTANTIVE/STUB, WIRED/ORPHANED/NOT_WIRED, COVERED/PARTIAL/MISSING)" },
144
+ "findings": { "type": "string", "maxLength": 500 },
145
+ "gaps_found": { "type": "string", "description": "Semicolon-separated gaps with severity + fix direction" },
146
+ "error": { "type": "string" }
147
+ },
148
+ "required": ["id", "result_status", "findings", "verdict"]
149
+ }
150
+ ```
151
+
152
+ Merge: `result_status` → master `status`; copy `verdict`, `findings`, `gaps_found`, `error`.
153
+
154
+ **Shared termination contract** (embed in every instruction):
155
+ ```
156
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
157
+ - Success → result_status=completed with concrete verdict
158
+ - Failure → result_status=failed with error message
159
+ - Blocked → upstream missing (W2/W3 cannot proceed) → result_status=blocked
160
+ - Timeout → near max_runtime_seconds → result_status=blocked, error="timeout"
161
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
162
+ - Read-only verification. Do NOT modify source files.
163
+ Do NOT write to tasks.csv, wave-*.csv, results.csv, verification.json. Do NOT call spawn_agents_on_csv (no recursion).
164
+ ```
165
+
131
166
  ### A_SPAWN_WAVE_1
132
167
 
133
- Filter wave==1 -> write wave-1.csv -> spawn.
168
+ Filter `wave==1 AND status=="pending"` -> write wave-1.csv -> spawn.
134
169
 
135
- **Truth check agent**: Identify supporting artifacts, check existence + substance + wiring indicators. Status: VERIFIED / FAILED / UNCERTAIN. Report gaps with severity + fix direction.
170
+ **Truth check agent**: Identify supporting artifacts, check existence + substance + wiring indicators. verdict: VERIFIED / FAILED / UNCERTAIN. Report gaps with severity + fix direction.
136
171
  **Artifact existence agent**: Check file on disk. Missing = gap (severity=critical). Exists = note size + structure for wave 2.
137
172
 
138
173
  ### A_SPAWN_WAVE_2
139
174
 
140
- Filter wave==2, skip if existence failed for that artifact. Build prev_context from wave 1 -> spawn.
175
+ Filter `wave==2 AND status=="pending"`, skip if existence failed for that artifact. Build prev_context from wave 1 -> spawn.
141
176
 
142
177
  **Substance agent**: <10 lines real logic or placeholder markers = STUB. Otherwise SUBSTANTIVE.
143
- **Wiring agent**: Grep for import + actual usage beyond imports. Status: WIRED / ORPHANED / NOT_WIRED.
178
+ **Wiring agent**: Grep for import + actual usage beyond imports. verdict: WIRED / ORPHANED / NOT_WIRED.
144
179
 
145
180
  ### A_SPAWN_WAVE_3
146
181
 
147
- Filter wave==3. Mark skipped per --skip-antipattern / --skip-tests. Build prev_context from waves 1+2 -> spawn.
182
+ Filter `wave==3 AND status=="pending"`. Mark skipped per --skip-antipattern / --skip-tests. Build prev_context from waves 1+2 -> spawn.
148
183
 
149
184
  **Anti-pattern agent**: Extract modified files from summaries. Scan for TODO/FIXME/XXX/HACK, placeholder, empty returns, disabled tests. Categorize: Blocker / Warning / Info.
150
185
  **Nyquist agent**: Detect test framework, map requirements to test files, classify COVERED / PARTIAL / MISSING. Run coverage if available.
@@ -210,17 +210,17 @@ Filter master `tasks.csv` for `wave == 1 AND status == pending` → write `wave-
210
210
  spawn_agents_on_csv({
211
211
  csv_path: `${sessionFolder}/wave-1.csv`,
212
212
  id_column: "id",
213
- instruction: buildRebuildInstruction(sessionFolder, sourceDirs), // agent: ~/.codex/agents/workflow-codebase-mapper.toml
213
+ instruction: REBUILD_INSTRUCTION, // see "Rebuild Worker Contract" below
214
214
  max_concurrency: maxConcurrency,
215
215
  max_runtime_seconds: 3600,
216
216
  output_csv_path: `${sessionFolder}/wave-1-results.csv`,
217
217
  output_schema: {
218
218
  type: "object",
219
219
  properties: {
220
- id: { type: "string" },
221
- result_status: { type: "string", enum: ["completed", "failed"] },
222
- result_findings: { type: "string" },
223
- error: { type: "string" }
220
+ id: { type: "string" },
221
+ result_status: { type: "string", enum: ["completed", "failed"] },
222
+ result_findings: { type: "string", description: "For task 1-3: JSON payload to merge into doc-index.json. For task 4-5: list of files written" },
223
+ error: { type: "string" }
224
224
  },
225
225
  required: ["id", "result_status", "result_findings"]
226
226
  }
@@ -229,6 +229,53 @@ spawn_agents_on_csv({
229
229
 
230
230
  Merge `wave-1-results.csv` into master `tasks.csv`: map `result_status` -> master `status`, `result_findings` -> master `findings`, copy `error` as-is. After merge, delete temporary files (`wave-1.csv` and `wave-1-results.csv`).
231
231
 
232
+ #### Rebuild Worker Contract (REBUILD_INSTRUCTION)
233
+
234
+ ```
235
+ You are a codebase doc generator for ONE task (Component Scanner / Feature Mapper / Requirement Linker / Tech Registry Writer / Feature Map Writer). Your contract depends on your task id — read description carefully.
236
+
237
+ DUAL CONTRACT (per task id):
238
+ Tasks 1-3 (Scanner/Mapper/Linker) → RETURN data via result_findings (JSON payload). Do NOT write files.
239
+ Tasks 4-5 (Writers) → MUST WRITE files via the Write tool. Verify each via Glob. Return file count + absolute paths via result_findings.
240
+
241
+ REQUIRED STEPS:
242
+ 1. Scan codebase per description and focus_area
243
+ 2. For tasks 1-3: assemble JSON payload matching the documented section schema (components / features / requirements)
244
+ 3. For tasks 4-5: render markdown documents and write them to disk; verify every intended file exists via Glob; if any file missing → result_status=failed
245
+ 4. Append discoveries to {sessionFolder}/discoveries.ndjson if reusable
246
+ 5. Call report_agent_job_result EXACTLY ONCE
247
+
248
+ TERMINATION CONTRACT (mandatory — NO worker may end without calling report_agent_job_result):
249
+ - Success → result_status=completed
250
+ - Failure → unrecoverable error / write verification fails → result_status=failed
251
+ - Timeout → near max_runtime_seconds, finish current write/scan if safe, then report failed with error="timeout (partial)"
252
+ - NEVER skip report_agent_job_result.
253
+
254
+ CONTRACT VIOLATION GUARD:
255
+ - Tasks 4-5 returning markdown content in result_findings instead of writing files → MUST self-report failed (orchestrator cannot assemble docs from text).
256
+ - Tasks 1-3 writing files to .workflow/codebase/ → MUST self-report failed (orchestrator owns assembly).
257
+
258
+ OUTPUT (must match output_schema):
259
+ Tasks 1-3:
260
+ {
261
+ "id": "<your row id>",
262
+ "result_status": "completed" | "failed",
263
+ "result_findings": "<JSON payload to merge into doc-index.json section>",
264
+ "error": "<message if failed, else empty>"
265
+ }
266
+ Tasks 4-5:
267
+ {
268
+ "id": "<your row id>",
269
+ "result_status": "completed" | "failed",
270
+ "result_findings": "<count + semicolon-separated absolute paths of files written>",
271
+ "error": "<message if failed, else empty>"
272
+ }
273
+
274
+ CONSTRAINTS:
275
+ - Do NOT write to tasks.csv, wave-*.csv, results.csv, doc-index.json (orchestrator assembles in Phase 3).
276
+ - Do NOT call spawn_agents_on_csv (no recursion).
277
+ ```
278
+
232
279
  ### Phase 3: Results -> .workflow/codebase/
233
280
 
234
281
  **Objective**: Assemble doc-index.json from agent findings, validate, update state.