maestro-flow 0.3.38 → 0.3.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.
Files changed (181) hide show
  1. package/.claude/agents/workflow-analyzer.md +2 -0
  2. package/.claude/agents/workflow-debugger.md +2 -0
  3. package/.claude/agents/workflow-executor.md +2 -0
  4. package/.claude/agents/workflow-integration-checker.md +1 -0
  5. package/.claude/agents/workflow-nyquist-auditor.md +1 -0
  6. package/.claude/agents/workflow-planner.md +2 -0
  7. package/.claude/agents/workflow-reviewer.md +2 -0
  8. package/.claude/agents/workflow-verifier.md +2 -0
  9. package/.claude/commands/learn-decompose.md +176 -176
  10. package/.claude/commands/learn-follow.md +167 -167
  11. package/.claude/commands/learn-investigate.md +221 -221
  12. package/.claude/commands/learn-retro.md +303 -303
  13. package/.claude/commands/learn-second-opinion.md +167 -167
  14. package/.claude/commands/maestro-amend.md +300 -300
  15. package/.claude/commands/maestro-analyze.md +126 -126
  16. package/.claude/commands/maestro-brainstorm.md +100 -100
  17. package/.claude/commands/maestro-composer.md +354 -354
  18. package/.claude/commands/maestro-execute.md +120 -114
  19. package/.claude/commands/maestro-fork.md +86 -86
  20. package/.claude/commands/maestro-init.md +78 -78
  21. package/.claude/commands/maestro-learn.md +140 -140
  22. package/.claude/commands/maestro-link-coordinate.md +1 -1
  23. package/.claude/commands/maestro-merge.md +61 -61
  24. package/.claude/commands/maestro-milestone-release.md +96 -96
  25. package/.claude/commands/maestro-overlay.md +178 -178
  26. package/.claude/commands/maestro-plan.md +150 -138
  27. package/.claude/commands/maestro-player.md +404 -404
  28. package/.claude/commands/maestro-quick.md +56 -56
  29. package/.claude/commands/maestro-ralph-execute.md +7 -18
  30. package/.claude/commands/maestro-ralph.md +9 -3
  31. package/.claude/commands/maestro-roadmap.md +1 -1
  32. package/.claude/commands/maestro-ui-design.md +93 -93
  33. package/.claude/commands/maestro-update.md +176 -176
  34. package/.claude/commands/maestro-verify.md +96 -90
  35. package/.claude/commands/maestro.md +121 -121
  36. package/.claude/commands/manage-codebase-rebuild.md +75 -75
  37. package/.claude/commands/manage-codebase-refresh.md +57 -57
  38. package/.claude/commands/manage-harvest.md +94 -94
  39. package/.claude/commands/manage-issue-discover.md +77 -77
  40. package/.claude/commands/manage-issue.md +73 -73
  41. package/.claude/commands/manage-knowhow-capture.md +193 -193
  42. package/.claude/commands/manage-knowhow.md +77 -77
  43. package/.claude/commands/manage-learn.md +67 -67
  44. package/.claude/commands/manage-status.md +51 -51
  45. package/.claude/commands/manage-wiki.md +62 -62
  46. package/.claude/commands/quality-auto-test.md +1 -1
  47. package/.claude/commands/quality-debug.md +121 -115
  48. package/.claude/commands/quality-refactor.md +55 -55
  49. package/.claude/commands/quality-retrospective.md +78 -78
  50. package/.claude/commands/quality-review.md +114 -108
  51. package/.claude/commands/quality-sync.md +51 -51
  52. package/.claude/commands/quality-test.md +103 -103
  53. package/.claude/commands/spec-add.md +49 -49
  54. package/.claude/commands/spec-load.md +51 -51
  55. package/.claude/commands/spec-remove.md +51 -51
  56. package/.claude/commands/spec-setup.md +51 -51
  57. package/.claude/commands/wiki-connect.md +62 -62
  58. package/.claude/commands/wiki-digest.md +69 -69
  59. package/.codex/skills/learn-decompose/SKILL.md +113 -113
  60. package/.codex/skills/learn-follow/SKILL.md +1 -1
  61. package/.codex/skills/learn-investigate/SKILL.md +83 -83
  62. package/.codex/skills/learn-retro/SKILL.md +83 -83
  63. package/.codex/skills/learn-second-opinion/SKILL.md +86 -86
  64. package/.codex/skills/maestro/SKILL.md +304 -304
  65. package/.codex/skills/maestro-analyze/SKILL.md +4 -3
  66. package/.codex/skills/maestro-brainstorm/SKILL.md +442 -397
  67. package/.codex/skills/maestro-composer/SKILL.md +213 -213
  68. package/.codex/skills/maestro-execute/SKILL.md +346 -318
  69. package/.codex/skills/maestro-fork/SKILL.md +56 -2
  70. package/.codex/skills/maestro-init/SKILL.md +40 -16
  71. package/.codex/skills/maestro-learn/SKILL.md +80 -80
  72. package/.codex/skills/maestro-link-coordinate/SKILL.md +257 -257
  73. package/.codex/skills/maestro-merge/SKILL.md +1 -1
  74. package/.codex/skills/maestro-milestone-audit/SKILL.md +1 -1
  75. package/.codex/skills/maestro-milestone-complete/SKILL.md +40 -9
  76. package/.codex/skills/maestro-milestone-release/SKILL.md +70 -70
  77. package/.codex/skills/maestro-overlay/SKILL.md +1 -1
  78. package/.codex/skills/maestro-plan/SKILL.md +19 -4
  79. package/.codex/skills/maestro-player/SKILL.md +323 -323
  80. package/.codex/skills/maestro-quick/SKILL.md +1 -1
  81. package/.codex/skills/maestro-ralph/SKILL.md +681 -578
  82. package/.codex/skills/maestro-roadmap/SKILL.md +518 -468
  83. package/.codex/skills/maestro-ui-design/SKILL.md +109 -12
  84. package/.codex/skills/maestro-verify/SKILL.md +27 -9
  85. package/.codex/skills/manage-codebase-rebuild/SKILL.md +3 -2
  86. package/.codex/skills/manage-codebase-refresh/SKILL.md +1 -1
  87. package/.codex/skills/manage-harvest/SKILL.md +91 -91
  88. package/.codex/skills/manage-issue/SKILL.md +19 -6
  89. package/.codex/skills/manage-issue-discover/SKILL.md +1 -1
  90. package/.codex/skills/manage-knowhow/SKILL.md +95 -95
  91. package/.codex/skills/manage-knowhow-capture/SKILL.md +110 -110
  92. package/.codex/skills/manage-learn/SKILL.md +1 -1
  93. package/.codex/skills/manage-status/SKILL.md +1 -1
  94. package/.codex/skills/manage-wiki/SKILL.md +55 -55
  95. package/.codex/skills/quality-auto-test/SKILL.md +547 -547
  96. package/.codex/skills/quality-debug/SKILL.md +339 -334
  97. package/.codex/skills/quality-refactor/SKILL.md +1 -1
  98. package/.codex/skills/quality-retrospective/SKILL.md +292 -292
  99. package/.codex/skills/quality-review/SKILL.md +365 -364
  100. package/.codex/skills/quality-sync/SKILL.md +1 -1
  101. package/.codex/skills/quality-test/SKILL.md +498 -498
  102. package/.codex/skills/spec-add/SKILL.md +101 -101
  103. package/.codex/skills/spec-load/SKILL.md +77 -77
  104. package/.codex/skills/spec-map/SKILL.md +1 -1
  105. package/.codex/skills/spec-remove/SKILL.md +69 -69
  106. package/.codex/skills/spec-setup/SKILL.md +1 -1
  107. package/.codex/skills/team-coordinate/SKILL.md +2 -1
  108. package/.codex/skills/team-executor/SKILL.md +116 -115
  109. package/.codex/skills/team-lifecycle-v4/SKILL.md +2 -1
  110. package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +14 -6
  111. package/.codex/skills/team-lifecycle-v4/roles/analyst/role.md +16 -4
  112. package/.codex/skills/team-lifecycle-v4/roles/executor/commands/implement.md +7 -1
  113. package/.codex/skills/team-lifecycle-v4/roles/planner/role.md +16 -4
  114. package/.codex/skills/team-lifecycle-v4/roles/writer/role.md +8 -2
  115. package/.codex/skills/team-quality-assurance/SKILL.md +2 -1
  116. package/.codex/skills/team-quality-assurance/roles/scout/role.md +9 -2
  117. package/.codex/skills/team-review/SKILL.md +2 -1
  118. package/.codex/skills/team-review/roles/reviewer/role.md +10 -1
  119. package/.codex/skills/team-review/roles/scanner/role.md +10 -1
  120. package/.codex/skills/team-tech-debt/SKILL.md +144 -143
  121. package/.codex/skills/team-tech-debt/roles/executor/role.md +9 -5
  122. package/.codex/skills/team-tech-debt/roles/scanner/role.md +10 -0
  123. package/.codex/skills/team-tech-debt/roles/validator/role.md +8 -2
  124. package/.codex/skills/team-testing/SKILL.md +2 -1
  125. package/.codex/skills/team-testing/roles/executor/role.md +8 -2
  126. package/.codex/skills/team-testing/roles/generator/role.md +8 -2
  127. package/.codex/skills/wiki-connect/SKILL.md +73 -73
  128. package/.codex/skills/wiki-digest/SKILL.md +87 -87
  129. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js +4 -0
  130. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js.map +1 -1
  131. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js +6 -0
  132. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js.map +1 -1
  133. package/dashboard/dist-server/shared/agent-types.d.ts +2 -0
  134. package/dashboard/dist-server/src/agents/cli-agent-runner.d.ts +2 -0
  135. package/dashboard/dist-server/src/agents/cli-agent-runner.js +4 -0
  136. package/dashboard/dist-server/src/agents/cli-agent-runner.js.map +1 -1
  137. package/dashboard/dist-server/src/commands/delegate.d.ts +2 -0
  138. package/dashboard/dist-server/src/commands/delegate.js +18 -0
  139. package/dashboard/dist-server/src/commands/delegate.js.map +1 -1
  140. package/dashboard/dist-server/src/config/cli-tools-config.d.ts +6 -0
  141. package/dashboard/dist-server/src/config/cli-tools-config.js +2 -0
  142. package/dashboard/dist-server/src/config/cli-tools-config.js.map +1 -1
  143. package/dist/shared/agent-types.d.ts +2 -0
  144. package/dist/shared/agent-types.d.ts.map +1 -1
  145. package/dist/src/agents/cli-agent-runner.d.ts +2 -0
  146. package/dist/src/agents/cli-agent-runner.d.ts.map +1 -1
  147. package/dist/src/agents/cli-agent-runner.js +4 -0
  148. package/dist/src/agents/cli-agent-runner.js.map +1 -1
  149. package/dist/src/commands/config.d.ts.map +1 -1
  150. package/dist/src/commands/config.js +29 -1
  151. package/dist/src/commands/config.js.map +1 -1
  152. package/dist/src/commands/delegate.d.ts +2 -0
  153. package/dist/src/commands/delegate.d.ts.map +1 -1
  154. package/dist/src/commands/delegate.js +18 -0
  155. package/dist/src/commands/delegate.js.map +1 -1
  156. package/dist/src/commands/launcher.d.ts.map +1 -1
  157. package/dist/src/commands/launcher.js +27 -4
  158. package/dist/src/commands/launcher.js.map +1 -1
  159. package/dist/src/config/cli-tools-config.d.ts +6 -0
  160. package/dist/src/config/cli-tools-config.d.ts.map +1 -1
  161. package/dist/src/config/cli-tools-config.js +2 -0
  162. package/dist/src/config/cli-tools-config.js.map +1 -1
  163. package/dist/src/core/overlay/applier.d.ts.map +1 -1
  164. package/dist/src/core/overlay/applier.js +65 -5
  165. package/dist/src/core/overlay/applier.js.map +1 -1
  166. package/dist/src/core/overlay/loader.d.ts.map +1 -1
  167. package/dist/src/core/overlay/loader.js +9 -4
  168. package/dist/src/core/overlay/loader.js.map +1 -1
  169. package/dist/src/core/overlay/types.d.ts +2 -0
  170. package/dist/src/core/overlay/types.d.ts.map +1 -1
  171. package/dist/src/core/overlay/types.js +2 -0
  172. package/dist/src/core/overlay/types.js.map +1 -1
  173. package/dist/src/tui/tools-ui/ToolsDashboard.d.ts.map +1 -1
  174. package/dist/src/tui/tools-ui/ToolsDashboard.js +1 -1
  175. package/dist/src/tui/tools-ui/ToolsDashboard.js.map +1 -1
  176. package/dist/src/tui/tools-ui/ToolsOverview.d.ts.map +1 -1
  177. package/dist/src/tui/tools-ui/ToolsOverview.js +51 -4
  178. package/dist/src/tui/tools-ui/ToolsOverview.js.map +1 -1
  179. package/package.json +1 -1
  180. package/shared/agent-types.ts +2 -0
  181. package/workflows/delegate-protocol.codex.md +65 -0
@@ -1,404 +1,404 @@
1
- ---
2
- name: maestro-player
3
- description: Workflow template player load JSON template, bind variables, execute DAG nodes in order, persist state at checkpoints, support resume
4
- argument-hint: "<template-slug|path> [--context key=value...] [-c [session-id]] [--list] [--dry-run]"
5
- allowed-tools:
6
- - Read
7
- - Write
8
- - Edit
9
- - Bash
10
- - Glob
11
- - Grep
12
- - Agent
13
- - AskUserQuestion
14
- - Skill
15
- ---
16
- <purpose>
17
- Load a workflow template (produced by maestro-composer) → bind context variables →
18
- execute DAG nodes in topological order → persist state at checkpoints → support resume.
19
-
20
- Node execution mechanisms:
21
- - `skill` node → `Skill()` (synchronous)
22
- - `command` node → `Skill()` with namespace (synchronous)
23
- - `cli` node → `maestro delegate` (background + wait for callback)
24
- - `agent` node → `Agent()` (sync or background per config)
25
- - `checkpoint` node → state save, optional user pause
26
-
27
- Session state persisted at `.workflow/.maestro/<session_id>/status.json` (same tracking
28
- location as maestro.md), enabling resume from any checkpoint via `-c`.
29
- </purpose>
30
-
31
- <context>
32
- $ARGUMENTS — template slug/path, or flags.
33
-
34
- **Flags:**
35
- - `--context key=value` — Bind context variables (repeatable)
36
- - `-c` / `--continue [session-id]` — Resume paused/interrupted session (consistent with maestro.md)
37
- - `--list` — List available templates from `~/.maestro/templates/workflows/index.json`
38
- - `--dry-run` — Show execution plan without executing
39
-
40
- **Entry routing:**
41
-
42
- | Detection | Condition | Handler |
43
- |-----------|-----------|---------|
44
- | List templates | `--list` in args | handleList |
45
- | Resume session | `-c [session-id]` | Phase 0: Resume |
46
- | Dry run | `--dry-run` in args | Phase 1 + 2, print plan, exit |
47
- | Normal | Template slug/path provided | Phase 1 |
48
- | No args | Empty args | handleList + AskUserQuestion |
49
-
50
- **Shared constants (aligned with maestro.md tracking):**
51
-
52
- | Constant | Value |
53
- |----------|-------|
54
- | Session prefix | `player` |
55
- | Session dir | `.workflow/.maestro/player-<YYYYMMDD>-<HHmmss>/` |
56
- | State file | `status.json` |
57
- | Template dir (global) | `~/.maestro/templates/workflows/` |
58
- | Template index (global) | `~/.maestro/templates/workflows/index.json` |
59
-
60
- **Session status.json schema (aligned with maestro.md):**
61
-
62
- ```json
63
- {
64
- "session_id": "player-<YYYYMMDD>-<HHmmss>",
65
- "created_at": "<ISO>",
66
- "intent": "<template_name> with context",
67
- "task_type": "player",
68
- "chain_name": "<template_id>",
69
- "template_id": "wft-<slug>-<date>",
70
- "template_path": "~/.maestro/templates/workflows/<slug>.json",
71
- "template_name": "<name>",
72
- "auto_mode": false,
73
- "status": "running | paused | completed | failed | aborted",
74
- "context": { "goal": "...", "scope": "..." },
75
- "steps": [
76
- {
77
- "index": 0,
78
- "node_id": "N-001",
79
- "skill": "<executor>",
80
- "args": "<resolved_args>",
81
- "type": "skill | cli | command | agent | checkpoint",
82
- "status": "pending | running | completed | skipped | failed",
83
- "started_at": null,
84
- "completed_at": null,
85
- "session_id": null,
86
- "output_path": null,
87
- "artifacts": [],
88
- "error": null
89
- }
90
- ],
91
- "current_step": 0,
92
- "last_checkpoint": null,
93
- "updated_at": "<ISO>",
94
- "completed_at": null
95
- }
96
- ```
97
-
98
- **Session directory structure (under .workflow/.maestro/):**
99
-
100
- ```
101
- .workflow/.maestro/player-<YYYYMMDD>-<HHmmss>/
102
- ├── status.json # Main state file (maestro.md compatible)
103
- ├── checkpoints/
104
- │ ├── CP-01.json
105
- │ └── CP-02.json
106
- └── artifacts/
107
- └── N-001-output.md
108
- ```
109
-
110
- **Node execution mechanisms:**
111
-
112
- | Node type | Mechanism | Blocking |
113
- |-----------|-----------|----------|
114
- | skill | `Skill(skill=executor, args=resolved_args)` | sync |
115
- | command | `Skill(skill=executor, args=resolved_args)` | sync |
116
- | cli | `maestro delegate "prompt" --to tool --mode mode --rule rule` via `Bash(run_in_background: true)` | async, wait for callback |
117
- | agent | `Agent(subagent_type=executor, prompt=resolved_args)` | configurable |
118
- | checkpoint | State save + optional user pause | — |
119
-
120
- **Runtime reference resolution:**
121
-
122
- Before executing each node, resolve `{ref}` patterns in `args_template`:
123
-
124
- | Reference | Resolves To |
125
- |-----------|-------------|
126
- | `{variable}` | `session_state.context[variable]` |
127
- | `{N-001.session_id}` | `node_states["N-001"].session_id` |
128
- | `{N-001.output_path}` | `node_states["N-001"].output_path` |
129
- | `{prev_session_id}` | session_id of previous non-checkpoint node |
130
- | `{prev_output_path}` | output_path of previous non-checkpoint node |
131
-
132
- Fallback: if referenced field is null, substitution results in empty string.
133
- </context>
134
-
135
- <execution>
136
-
137
- ### handleList
138
-
139
- Scan `~/.maestro/templates/workflows/index.json`. Display:
140
- ```
141
- Available workflow templates:
142
- feature-tdd-review [feature, complex] 3 work nodes, 2 checkpoints
143
- quick-bugfix [bugfix, simple] 2 work nodes, 1 checkpoint
144
-
145
- Run: /maestro-player <slug> --context goal="..."
146
- ```
147
-
148
- If index not found, output: "No templates found. Create one with /maestro-composer"
149
-
150
- ---
151
-
152
- ### Phase 0: Resume — Session Reconciliation
153
-
154
- **Trigger**: `-c [session-id]`
155
-
156
- 1. If session-id provided: load `.workflow/.maestro/<session-id>/status.json`
157
- 2. If no session-id: scan `.workflow/.maestro/player-*/status.json` for `status = "running" | "paused"`
158
- 3. Multiple found → AskUserQuestion for selection
159
- 4. None found → error E004
160
- 5. Reset any `running` steps back to `pending` (interrupted mid-execution)
161
- 6. Determine next executable step from `steps[]` after `last_checkpoint`
162
- 7. Set `current_step` to resume point
163
- 8. Resume at Phase 3 (Execute Loop) from that step
164
-
165
- ---
166
-
167
- ### Phase 1: Load & Bind
168
-
169
- **Objective**: Load template, collect missing variables, bind all references.
170
-
171
- **Step 1.1** — Resolve template path:
172
- 1. Absolute path → use as-is
173
- 2. Relative path (`.` prefix) → resolve from cwd
174
- 3. Slug only → look up in `~/.maestro/templates/workflows/index.json`
175
- 4. Partial match → scan index, confirm with user
176
- 5. Not found → show available templates, AskUserQuestion
177
-
178
- **Step 1.2** — Parse `--context key=value` pairs into `bound_context`.
179
-
180
- **Step 1.3** — Load and validate template JSON (`template_id`, `nodes`, `edges`, `context_schema` must be present).
181
-
182
- **Step 1.4** — Collect missing required variables:
183
- - For each `context_schema` entry where `required: true` and not in `bound_context`:
184
- AskUserQuestion to collect value
185
- - For optional variables: use `default` or empty string
186
-
187
- **Step 1.5** — Bind variables: replace `{variable_name}` with values in all `args_template` strings. Leave `{N-xxx.field}` and `{prev_*}` unresolved (runtime Phase 3).
188
-
189
- **Step 1.6** — If `--dry-run`: print execution plan and exit:
190
- ```
191
- Workflow: <template.name>
192
- Context: goal = "<value>"
193
-
194
- Execution Plan:
195
- [1] N-001 [skill] maestro-plan "<goal>"
196
- [2] CP-01 [checkpoint] After Plan auto-continue
197
- [3] N-002 [skill] maestro-execute --resume-session {N-001.session_id}
198
-
199
- To execute: /maestro-player <slug> --context goal="..."
200
- ```
201
-
202
- ---
203
-
204
- ### Phase 2: Instantiate — Init Session State
205
-
206
- **Objective**: Create session directory, init state, compute execution plan.
207
-
208
- **Step 2.1** — Generate session ID: `player-<YYYYMMDD>-<HHmmss>`. Create directory at `.workflow/.maestro/<session_id>/`.
209
-
210
- **Step 2.2** — Topological sort via Kahn's algorithm. Flatten nodes into `steps[]` array (maestro.md format). Parallel nodes get same batch index.
211
-
212
- **Step 2.3** — Init all steps as `status: "pending"`.
213
-
214
- **Step 2.4** — Write `status.json` (see schema in Context section).
215
-
216
- **Step 2.5** — Show execution start banner:
217
- ```
218
- ============================================================
219
- MAESTRO PLAYER
220
- ============================================================
221
- Template: <template.name>
222
- Session: <session_id>
223
- Context: goal="<value>"
224
-
225
- Pipeline:
226
- 1. N-001 [skill] maestro-plan
227
- 2. CP-01 [checkpoint] After Plan
228
- 3. N-002 [skill] maestro-execute
229
- ============================================================
230
- ```
231
-
232
- ---
233
-
234
- ### Phase 3: Execute Loop
235
-
236
- **Objective**: Execute each step in order. Save state after every step.
237
-
238
- **CRITICAL**: After each step status change, write `status.json` immediately. This enables resume on interruption.
239
-
240
- **For each step starting at `current_step`:**
241
-
242
- **3a. Display step banner** (consistent with maestro.md):
243
- ```
244
- ------------------------------------------------------------
245
- STEP {i+1}/{total}: {node_id} [{type}] {executor}
246
- ------------------------------------------------------------
247
- Args: {resolved_args}
248
- ```
249
-
250
- **3b. Update status.json**: Set step status = `"running"`, started_at = now.
251
-
252
- **3c. Execute by node type:**
253
-
254
- **skill / command node**:
255
- ```
256
- resolved_args = resolveArgs(step.args_template, status)
257
- Skill(skill=step.skill, args=resolved_args)
258
-
259
- Extract from result: session_id (WFS-*), output_path, artifacts
260
- Update step: status="completed", session_id, output_path, artifacts, completed_at
261
- Write status.json
262
- ```
263
-
264
- **cli node — CRITICAL: background + stop**:
265
- ```
266
- resolved_args = resolveArgs(step.args_template, status)
267
-
268
- Bash({
269
- command: `maestro delegate "${resolved_args}" --to ${step.cli_tool} --mode ${step.cli_mode} --rule ${step.cli_rule}`,
270
- run_in_background: true
271
- })
272
-
273
- Write status.json // persist "running" state
274
- STOP — wait for background callback
275
- ```
276
-
277
- On callback:
278
- ```
279
- Load status.json
280
- Find step with status "running"
281
- Retrieve output: maestro delegate output <exec_id>
282
- Update step: status="completed", output_path, completed_at
283
- Write status.json
284
- Advance to next step
285
- ```
286
-
287
- **agent node**:
288
- ```
289
- resolved_args = resolveArgs(step.args_template, status)
290
-
291
- Agent({
292
- subagent_type: step.skill,
293
- prompt: resolved_args,
294
- run_in_background: step.run_in_background ?? false,
295
- description: step.node_id
296
- })
297
-
298
- Update step: status="completed", output_path, completed_at
299
- Write status.json
300
- ```
301
-
302
- **checkpoint node**:
303
- ```
304
- // 1. Write checkpoint snapshot
305
- Write <session_dir>/checkpoints/<step.node_id>.json with:
306
- session_id, checkpoint_id, saved_at, steps_snapshot, last_completed_step
307
-
308
- // 2. Update status.json
309
- status.last_checkpoint = step.node_id
310
- Mark step completed, write status.json
311
-
312
- // 3. If auto_continue == false: pause for user
313
- AskUserQuestion:
314
- - Continue → proceed
315
- - Pause → set status="paused", write status.json, output resume command, EXIT
316
- - Abort → set status="aborted", EXIT
317
- ```
318
-
319
- **3d. Handle result** (consistent with maestro.md):
320
-
321
- On success: update step status = `"completed"`, advance `current_step`.
322
-
323
- On failure:
324
- ```
325
- on_fail = step.on_fail || "abort"
326
-
327
- skip → mark "skipped", log warning, advance
328
- retry → retry once, if still fails → fall to abort
329
- abort → AskUserQuestion: Retry / Skip / Abort
330
- On Abort: save progress, display: "Resume with: /maestro-player -c"
331
- ```
332
-
333
- **3e. Context cleanup hint** (after step 3+, consistent with maestro.md):
334
- ```
335
- ⚡ 已执行 {i} 步,上下文较重。可随时 /maestro-player -c 在新上下文中恢复。
336
- ```
337
-
338
- ---
339
-
340
- ### Phase 4: Complete — Archive + Summary
341
-
342
- **Objective**: Mark session complete, output summary.
343
-
344
- **Step 4.1** — Set `status = "completed"`, `completed_at = <ISO>`, write `status.json`.
345
-
346
- **Step 4.2** — Collect all artifacts from steps.
347
-
348
- **Step 4.3** — Display execution summary (consistent with maestro.md):
349
- ```
350
- ============================================================
351
- MAESTRO PLAYER SESSION COMPLETE
352
- ============================================================
353
- Session: <session_id>
354
- Template: <template_name> (<template_id>)
355
- Steps: <completed>/<total> completed
356
- Context: goal="<value>"
357
-
358
- Results:
359
- [✓] 1. N-001 maestro-plan — completed (WFS-plan-xxx)
360
- [✓] 2. CP-01 After Plan — completed (checkpoint)
361
- [✓] 3. N-002 maestro-execute — completed (WFS-exec-xxx)
362
- [✓] 4. N-003 quality-test — completed (WFS-test-xxx)
363
-
364
- Artifacts:
365
- - IMPL_PLAN.md (N-001)
366
- - src/auth/index.ts (N-002)
367
- - test/auth.test.ts (N-003)
368
-
369
- Session dir: .workflow/.maestro/<session_id>/
370
- ============================================================
371
- ```
372
-
373
- **Step 4.4** — AskUserQuestion completion action:
374
- - **Keep session** → leave at current path
375
- - **Run again** → AskUserQuestion for same/new context, re-enter Phase 1
376
- - **Nothing** → done
377
- </execution>
378
-
379
- <error_codes>
380
- | Code | Severity | Description | Recovery |
381
- |------|----------|-------------|----------|
382
- | E001 | error | Template not found | Show --list output, suggest closest match |
383
- | E002 | error | Template JSON invalid (missing required fields) | Point to template file for fix |
384
- | E003 | error | Required context variable missing and user declined | Cannot proceed without required vars |
385
- | E004 | error | Resume session not found | Scan `.workflow/.maestro/player-*/`, list available |
386
- | E005 | error | DAG cycle in template | Point to template for fix, suggest maestro-composer --edit |
387
- | E006 | error | Node execution failed + abort chosen | Save state, suggest --resume |
388
- | W001 | warning | Node completed with warnings | Log and continue |
389
- | W002 | warning | Runtime reference resolved to empty string | Log, executor handles gracefully |
390
- </error_codes>
391
-
392
- <success_criteria>
393
- - [ ] Template loaded from `~/.maestro/templates/workflows/` and validated
394
- - [ ] All required context variables bound (from --context or user input)
395
- - [ ] Session directory created at `.workflow/.maestro/player-*/` with `status.json`
396
- - [ ] Steps array computed via topological sort (maestro.md compatible format)
397
- - [ ] Each step executed with correct mechanism (Skill/delegate/Agent)
398
- - [ ] Runtime references ({N-xxx.field}, {prev_*}) resolved before each step
399
- - [ ] `status.json` written after every step status change (resume-safe)
400
- - [ ] Checkpoints saved with snapshots under `checkpoints/`
401
- - [ ] CLI nodes use `maestro delegate` with `Bash(run_in_background: true)` + stop pattern
402
- - [ ] Step banners and completion report match maestro.md format
403
- - [ ] Resume via `-c` scans `.workflow/.maestro/player-*/status.json`
404
- </success_criteria>
1
+ ---
2
+ name: maestro-player
3
+ description: Play workflow templates with checkpoint resume
4
+ argument-hint: "<template-slug|path> [--context key=value...] [-c [session-id]] [--list] [--dry-run]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Agent
13
+ - AskUserQuestion
14
+ - Skill
15
+ ---
16
+ <purpose>
17
+ Load a workflow template (produced by maestro-composer) → bind context variables →
18
+ execute DAG nodes in topological order → persist state at checkpoints → support resume.
19
+
20
+ Node execution mechanisms:
21
+ - `skill` node → `Skill()` (synchronous)
22
+ - `command` node → `Skill()` with namespace (synchronous)
23
+ - `cli` node → `maestro delegate` (background + wait for callback)
24
+ - `agent` node → `Agent()` (sync or background per config)
25
+ - `checkpoint` node → state save, optional user pause
26
+
27
+ Session state persisted at `.workflow/.maestro/<session_id>/status.json` (same tracking
28
+ location as maestro.md), enabling resume from any checkpoint via `-c`.
29
+ </purpose>
30
+
31
+ <context>
32
+ $ARGUMENTS — template slug/path, or flags.
33
+
34
+ **Flags:**
35
+ - `--context key=value` — Bind context variables (repeatable)
36
+ - `-c` / `--continue [session-id]` — Resume paused/interrupted session (consistent with maestro.md)
37
+ - `--list` — List available templates from `~/.maestro/templates/workflows/index.json`
38
+ - `--dry-run` — Show execution plan without executing
39
+
40
+ **Entry routing:**
41
+
42
+ | Detection | Condition | Handler |
43
+ |-----------|-----------|---------|
44
+ | List templates | `--list` in args | handleList |
45
+ | Resume session | `-c [session-id]` | Phase 0: Resume |
46
+ | Dry run | `--dry-run` in args | Phase 1 + 2, print plan, exit |
47
+ | Normal | Template slug/path provided | Phase 1 |
48
+ | No args | Empty args | handleList + AskUserQuestion |
49
+
50
+ **Shared constants (aligned with maestro.md tracking):**
51
+
52
+ | Constant | Value |
53
+ |----------|-------|
54
+ | Session prefix | `player` |
55
+ | Session dir | `.workflow/.maestro/player-<YYYYMMDD>-<HHmmss>/` |
56
+ | State file | `status.json` |
57
+ | Template dir (global) | `~/.maestro/templates/workflows/` |
58
+ | Template index (global) | `~/.maestro/templates/workflows/index.json` |
59
+
60
+ **Session status.json schema (aligned with maestro.md):**
61
+
62
+ ```json
63
+ {
64
+ "session_id": "player-<YYYYMMDD>-<HHmmss>",
65
+ "created_at": "<ISO>",
66
+ "intent": "<template_name> with context",
67
+ "task_type": "player",
68
+ "chain_name": "<template_id>",
69
+ "template_id": "wft-<slug>-<date>",
70
+ "template_path": "~/.maestro/templates/workflows/<slug>.json",
71
+ "template_name": "<name>",
72
+ "auto_mode": false,
73
+ "status": "running | paused | completed | failed | aborted",
74
+ "context": { "goal": "...", "scope": "..." },
75
+ "steps": [
76
+ {
77
+ "index": 0,
78
+ "node_id": "N-001",
79
+ "skill": "<executor>",
80
+ "args": "<resolved_args>",
81
+ "type": "skill | cli | command | agent | checkpoint",
82
+ "status": "pending | running | completed | skipped | failed",
83
+ "started_at": null,
84
+ "completed_at": null,
85
+ "session_id": null,
86
+ "output_path": null,
87
+ "artifacts": [],
88
+ "error": null
89
+ }
90
+ ],
91
+ "current_step": 0,
92
+ "last_checkpoint": null,
93
+ "updated_at": "<ISO>",
94
+ "completed_at": null
95
+ }
96
+ ```
97
+
98
+ **Session directory structure (under .workflow/.maestro/):**
99
+
100
+ ```
101
+ .workflow/.maestro/player-<YYYYMMDD>-<HHmmss>/
102
+ ├── status.json # Main state file (maestro.md compatible)
103
+ ├── checkpoints/
104
+ │ ├── CP-01.json
105
+ │ └── CP-02.json
106
+ └── artifacts/
107
+ └── N-001-output.md
108
+ ```
109
+
110
+ **Node execution mechanisms:**
111
+
112
+ | Node type | Mechanism | Blocking |
113
+ |-----------|-----------|----------|
114
+ | skill | `Skill(skill=executor, args=resolved_args)` | sync |
115
+ | command | `Skill(skill=executor, args=resolved_args)` | sync |
116
+ | cli | `maestro delegate "prompt" --to tool --mode mode --rule rule` via `Bash(run_in_background: true)` | async, wait for callback |
117
+ | agent | `Agent(subagent_type=executor, prompt=resolved_args)` | configurable |
118
+ | checkpoint | State save + optional user pause | — |
119
+
120
+ **Runtime reference resolution:**
121
+
122
+ Before executing each node, resolve `{ref}` patterns in `args_template`:
123
+
124
+ | Reference | Resolves To |
125
+ |-----------|-------------|
126
+ | `{variable}` | `session_state.context[variable]` |
127
+ | `{N-001.session_id}` | `node_states["N-001"].session_id` |
128
+ | `{N-001.output_path}` | `node_states["N-001"].output_path` |
129
+ | `{prev_session_id}` | session_id of previous non-checkpoint node |
130
+ | `{prev_output_path}` | output_path of previous non-checkpoint node |
131
+
132
+ Fallback: if referenced field is null, substitution results in empty string.
133
+ </context>
134
+
135
+ <execution>
136
+
137
+ ### handleList
138
+
139
+ Scan `~/.maestro/templates/workflows/index.json`. Display:
140
+ ```
141
+ Available workflow templates:
142
+ feature-tdd-review [feature, complex] 3 work nodes, 2 checkpoints
143
+ quick-bugfix [bugfix, simple] 2 work nodes, 1 checkpoint
144
+
145
+ Run: /maestro-player <slug> --context goal="..."
146
+ ```
147
+
148
+ If index not found, output: "No templates found. Create one with /maestro-composer"
149
+
150
+ ---
151
+
152
+ ### Phase 0: Resume — Session Reconciliation
153
+
154
+ **Trigger**: `-c [session-id]`
155
+
156
+ 1. If session-id provided: load `.workflow/.maestro/<session-id>/status.json`
157
+ 2. If no session-id: scan `.workflow/.maestro/player-*/status.json` for `status = "running" | "paused"`
158
+ 3. Multiple found → AskUserQuestion for selection
159
+ 4. None found → error E004
160
+ 5. Reset any `running` steps back to `pending` (interrupted mid-execution)
161
+ 6. Determine next executable step from `steps[]` after `last_checkpoint`
162
+ 7. Set `current_step` to resume point
163
+ 8. Resume at Phase 3 (Execute Loop) from that step
164
+
165
+ ---
166
+
167
+ ### Phase 1: Load & Bind
168
+
169
+ **Objective**: Load template, collect missing variables, bind all references.
170
+
171
+ **Step 1.1** — Resolve template path:
172
+ 1. Absolute path → use as-is
173
+ 2. Relative path (`.` prefix) → resolve from cwd
174
+ 3. Slug only → look up in `~/.maestro/templates/workflows/index.json`
175
+ 4. Partial match → scan index, confirm with user
176
+ 5. Not found → show available templates, AskUserQuestion
177
+
178
+ **Step 1.2** — Parse `--context key=value` pairs into `bound_context`.
179
+
180
+ **Step 1.3** — Load and validate template JSON (`template_id`, `nodes`, `edges`, `context_schema` must be present).
181
+
182
+ **Step 1.4** — Collect missing required variables:
183
+ - For each `context_schema` entry where `required: true` and not in `bound_context`:
184
+ AskUserQuestion to collect value
185
+ - For optional variables: use `default` or empty string
186
+
187
+ **Step 1.5** — Bind variables: replace `{variable_name}` with values in all `args_template` strings. Leave `{N-xxx.field}` and `{prev_*}` unresolved (runtime Phase 3).
188
+
189
+ **Step 1.6** — If `--dry-run`: print execution plan and exit:
190
+ ```
191
+ Workflow: <template.name>
192
+ Context: goal = "<value>"
193
+
194
+ Execution Plan:
195
+ [1] N-001 [skill] maestro-plan "<goal>"
196
+ [2] CP-01 [checkpoint] After Plan auto-continue
197
+ [3] N-002 [skill] maestro-execute --resume-session {N-001.session_id}
198
+
199
+ To execute: /maestro-player <slug> --context goal="..."
200
+ ```
201
+
202
+ ---
203
+
204
+ ### Phase 2: Instantiate — Init Session State
205
+
206
+ **Objective**: Create session directory, init state, compute execution plan.
207
+
208
+ **Step 2.1** — Generate session ID: `player-<YYYYMMDD>-<HHmmss>`. Create directory at `.workflow/.maestro/<session_id>/`.
209
+
210
+ **Step 2.2** — Topological sort via Kahn's algorithm. Flatten nodes into `steps[]` array (maestro.md format). Parallel nodes get same batch index.
211
+
212
+ **Step 2.3** — Init all steps as `status: "pending"`.
213
+
214
+ **Step 2.4** — Write `status.json` (see schema in Context section).
215
+
216
+ **Step 2.5** — Show execution start banner:
217
+ ```
218
+ ============================================================
219
+ MAESTRO PLAYER
220
+ ============================================================
221
+ Template: <template.name>
222
+ Session: <session_id>
223
+ Context: goal="<value>"
224
+
225
+ Pipeline:
226
+ 1. N-001 [skill] maestro-plan
227
+ 2. CP-01 [checkpoint] After Plan
228
+ 3. N-002 [skill] maestro-execute
229
+ ============================================================
230
+ ```
231
+
232
+ ---
233
+
234
+ ### Phase 3: Execute Loop
235
+
236
+ **Objective**: Execute each step in order. Save state after every step.
237
+
238
+ **CRITICAL**: After each step status change, write `status.json` immediately. This enables resume on interruption.
239
+
240
+ **For each step starting at `current_step`:**
241
+
242
+ **3a. Display step banner** (consistent with maestro.md):
243
+ ```
244
+ ------------------------------------------------------------
245
+ STEP {i+1}/{total}: {node_id} [{type}] {executor}
246
+ ------------------------------------------------------------
247
+ Args: {resolved_args}
248
+ ```
249
+
250
+ **3b. Update status.json**: Set step status = `"running"`, started_at = now.
251
+
252
+ **3c. Execute by node type:**
253
+
254
+ **skill / command node**:
255
+ ```
256
+ resolved_args = resolveArgs(step.args_template, status)
257
+ Skill(skill=step.skill, args=resolved_args)
258
+
259
+ Extract from result: session_id (WFS-*), output_path, artifacts
260
+ Update step: status="completed", session_id, output_path, artifacts, completed_at
261
+ Write status.json
262
+ ```
263
+
264
+ **cli node — CRITICAL: background + stop**:
265
+ ```
266
+ resolved_args = resolveArgs(step.args_template, status)
267
+
268
+ Bash({
269
+ command: `maestro delegate "${resolved_args}" --to ${step.cli_tool} --mode ${step.cli_mode} --rule ${step.cli_rule}`,
270
+ run_in_background: true
271
+ })
272
+
273
+ Write status.json // persist "running" state
274
+ STOP — wait for background callback
275
+ ```
276
+
277
+ On callback:
278
+ ```
279
+ Load status.json
280
+ Find step with status "running"
281
+ Retrieve output: maestro delegate output <exec_id>
282
+ Update step: status="completed", output_path, completed_at
283
+ Write status.json
284
+ Advance to next step
285
+ ```
286
+
287
+ **agent node**:
288
+ ```
289
+ resolved_args = resolveArgs(step.args_template, status)
290
+
291
+ Agent({
292
+ subagent_type: step.skill,
293
+ prompt: resolved_args,
294
+ run_in_background: step.run_in_background ?? false,
295
+ description: step.node_id
296
+ })
297
+
298
+ Update step: status="completed", output_path, completed_at
299
+ Write status.json
300
+ ```
301
+
302
+ **checkpoint node**:
303
+ ```
304
+ // 1. Write checkpoint snapshot
305
+ Write <session_dir>/checkpoints/<step.node_id>.json with:
306
+ session_id, checkpoint_id, saved_at, steps_snapshot, last_completed_step
307
+
308
+ // 2. Update status.json
309
+ status.last_checkpoint = step.node_id
310
+ Mark step completed, write status.json
311
+
312
+ // 3. If auto_continue == false: pause for user
313
+ AskUserQuestion:
314
+ - Continue → proceed
315
+ - Pause → set status="paused", write status.json, output resume command, EXIT
316
+ - Abort → set status="aborted", EXIT
317
+ ```
318
+
319
+ **3d. Handle result** (consistent with maestro.md):
320
+
321
+ On success: update step status = `"completed"`, advance `current_step`.
322
+
323
+ On failure:
324
+ ```
325
+ on_fail = step.on_fail || "abort"
326
+
327
+ skip → mark "skipped", log warning, advance
328
+ retry → retry once, if still fails → fall to abort
329
+ abort → AskUserQuestion: Retry / Skip / Abort
330
+ On Abort: save progress, display: "Resume with: /maestro-player -c"
331
+ ```
332
+
333
+ **3e. Context cleanup hint** (after step 3+, consistent with maestro.md):
334
+ ```
335
+ ⚡ 已执行 {i} 步,上下文较重。可随时 /maestro-player -c 在新上下文中恢复。
336
+ ```
337
+
338
+ ---
339
+
340
+ ### Phase 4: Complete — Archive + Summary
341
+
342
+ **Objective**: Mark session complete, output summary.
343
+
344
+ **Step 4.1** — Set `status = "completed"`, `completed_at = <ISO>`, write `status.json`.
345
+
346
+ **Step 4.2** — Collect all artifacts from steps.
347
+
348
+ **Step 4.3** — Display execution summary (consistent with maestro.md):
349
+ ```
350
+ ============================================================
351
+ MAESTRO PLAYER SESSION COMPLETE
352
+ ============================================================
353
+ Session: <session_id>
354
+ Template: <template_name> (<template_id>)
355
+ Steps: <completed>/<total> completed
356
+ Context: goal="<value>"
357
+
358
+ Results:
359
+ [✓] 1. N-001 maestro-plan — completed (WFS-plan-xxx)
360
+ [✓] 2. CP-01 After Plan — completed (checkpoint)
361
+ [✓] 3. N-002 maestro-execute — completed (WFS-exec-xxx)
362
+ [✓] 4. N-003 quality-test — completed (WFS-test-xxx)
363
+
364
+ Artifacts:
365
+ - IMPL_PLAN.md (N-001)
366
+ - src/auth/index.ts (N-002)
367
+ - test/auth.test.ts (N-003)
368
+
369
+ Session dir: .workflow/.maestro/<session_id>/
370
+ ============================================================
371
+ ```
372
+
373
+ **Step 4.4** — AskUserQuestion completion action:
374
+ - **Keep session** → leave at current path
375
+ - **Run again** → AskUserQuestion for same/new context, re-enter Phase 1
376
+ - **Nothing** → done
377
+ </execution>
378
+
379
+ <error_codes>
380
+ | Code | Severity | Description | Recovery |
381
+ |------|----------|-------------|----------|
382
+ | E001 | error | Template not found | Show --list output, suggest closest match |
383
+ | E002 | error | Template JSON invalid (missing required fields) | Point to template file for fix |
384
+ | E003 | error | Required context variable missing and user declined | Cannot proceed without required vars |
385
+ | E004 | error | Resume session not found | Scan `.workflow/.maestro/player-*/`, list available |
386
+ | E005 | error | DAG cycle in template | Point to template for fix, suggest maestro-composer --edit |
387
+ | E006 | error | Node execution failed + abort chosen | Save state, suggest --resume |
388
+ | W001 | warning | Node completed with warnings | Log and continue |
389
+ | W002 | warning | Runtime reference resolved to empty string | Log, executor handles gracefully |
390
+ </error_codes>
391
+
392
+ <success_criteria>
393
+ - [ ] Template loaded from `~/.maestro/templates/workflows/` and validated
394
+ - [ ] All required context variables bound (from --context or user input)
395
+ - [ ] Session directory created at `.workflow/.maestro/player-*/` with `status.json`
396
+ - [ ] Steps array computed via topological sort (maestro.md compatible format)
397
+ - [ ] Each step executed with correct mechanism (Skill/delegate/Agent)
398
+ - [ ] Runtime references ({N-xxx.field}, {prev_*}) resolved before each step
399
+ - [ ] `status.json` written after every step status change (resume-safe)
400
+ - [ ] Checkpoints saved with snapshots under `checkpoints/`
401
+ - [ ] CLI nodes use `maestro delegate` with `Bash(run_in_background: true)` + stop pattern
402
+ - [ ] Step banners and completion report match maestro.md format
403
+ - [ ] Resume via `-c` scans `.workflow/.maestro/player-*/status.json`
404
+ </success_criteria>