@dtlabs/ai-toolkit 0.13.0 → 0.14.1
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/CHANGELOG.md +52 -0
- package/bin/cli.js +371 -2
- package/docs/task-executor-bootstrap.md +195 -0
- package/docs/task-executor-cli.md +319 -0
- package/docs/workflow-control-plane.md +102 -0
- package/lib/execution-ledger.js +186 -4
- package/lib/task-executor/claude-process.js +563 -0
- package/lib/task-executor/git.js +1362 -0
- package/lib/task-executor/index.js +3729 -0
- package/lib/task-executor/ownership.js +590 -0
- package/lib/task-executor/plan.js +725 -0
- package/lib/task-executor/store.js +1164 -0
- package/lib/workflow-artifacts.js +102 -0
- package/lib/workflow-control.js +225 -0
- package/lib/workflow-runner.js +39 -0
- package/package.json +1 -1
- package/src/claude/agents/gaia-intervention-documentation-standard.md +9 -9
- package/src/claude/agents/gaia-validate-feature-docs.md +31 -28
- package/src/claude/skills/assess-codebase/SKILL.md +9 -103
- package/src/claude/skills/implement-feature/SKILL.md +74 -159
- package/src/claude/workflows/am-phase1.js +43 -294
- package/src/claude/workflows/am-phase2.js +10 -164
- package/src/claude/workflows/pm-phase1.js +45 -358
- package/src/claude/workflows/pm-phase2.js +50 -571
- package/src/claude/workflows/pm-phase3.js +5 -824
|
@@ -9,8 +9,7 @@ Orchestrates the full codebase assessment pipeline by invoking two sequential wo
|
|
|
9
9
|
(`am-phase1`, `am-phase2`), handling the Findings Gate in the main loop between the phases,
|
|
10
10
|
and recording the real token consumption at the end.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
with accurate per-agent `usage` data and their declared `model:` frontmatter honoured.
|
|
12
|
+
Run workflows through the deterministic Node host. Workflows are not agent types. Resolve the absolute Claude executable path using docs/task-executor-bootstrap.md.
|
|
14
13
|
|
|
15
14
|
---
|
|
16
15
|
|
|
@@ -25,16 +24,14 @@ found, or start at `ASSESS-001`. This prefix is used for all output files in thi
|
|
|
25
24
|
|
|
26
25
|
Invoke the `am-phase1` workflow:
|
|
27
26
|
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
prompt: <path> [--scope=<areas>] --prefix ASSESS-NNN [--force]
|
|
27
|
+
```bash
|
|
28
|
+
ai-toolkit workflow run am-phase1 --project . --claude-path "{ABSOLUTE_CLAUDE_EXE}" -- "<path>" [--scope=<areas>] --prefix ASSESS-NNN
|
|
31
29
|
```
|
|
32
30
|
|
|
33
31
|
If no path was provided by the user, use `.` (current working directory).
|
|
34
32
|
Always pass `--prefix ASSESS-NNN` with the prefix determined in Step 1.
|
|
35
33
|
|
|
36
|
-
Wait for
|
|
37
|
-
(format: `subagent_tokens: N`). Extract from the result:
|
|
34
|
+
Wait for exit 0, then parse stdout JSON. A nonzero exit is a HARD STOP; do not present a successful Findings Gate. The host owns ledger transitions. Extract from the result:
|
|
38
35
|
- `prefix` — confirmed assessment prefix
|
|
39
36
|
- `output_dir` — path to `docs/assessments/ASSESS-NNN/`
|
|
40
37
|
- `assessment_summaries` — list of `{ agent, output_file }` for each completed assessment
|
|
@@ -46,8 +43,7 @@ Wait for the workflow to complete. Capture its full result, including the `<usag
|
|
|
46
43
|
- `token_estimate_path` — path to `{PREFIX}-Token-Estimate.md`
|
|
47
44
|
- `errors` — any agent failures during phase 1
|
|
48
45
|
|
|
49
|
-
If
|
|
50
|
-
Partial assessments are acceptable — present the Findings Gate with available data.
|
|
46
|
+
If any worker fails, stop. Partial assessments must not be represented as a completed workflow.
|
|
51
47
|
|
|
52
48
|
---
|
|
53
49
|
|
|
@@ -112,9 +108,8 @@ Capture the flagged identifiers (as a comma-separated string, or "none").
|
|
|
112
108
|
|
|
113
109
|
Invoke the `am-phase2` workflow:
|
|
114
110
|
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
prompt: --prefix {prefix} --output-dir {output_dir} --flagged {flagged_ids} --ack "{acknowledgement_text}"
|
|
111
|
+
```bash
|
|
112
|
+
ai-toolkit workflow run am-phase2 --project . -- "--prefix" "{prefix}" --output-dir "{output_dir}" --flagged "{flagged_ids}" --ack "{acknowledgement_text}"
|
|
118
113
|
```
|
|
119
114
|
|
|
120
115
|
Where `{flagged_ids}` is the comma-separated list of INT-NNN identifiers (or "none").
|
|
@@ -126,95 +121,6 @@ Wait for the workflow to complete. Extract from the result:
|
|
|
126
121
|
|
|
127
122
|
---
|
|
128
123
|
|
|
129
|
-
## Step 5 —
|
|
130
|
-
|
|
131
|
-
From the `<usage>` block of the am-phase1 result, read:
|
|
132
|
-
- `subagent_tokens` — total tokens consumed by the am-phase1 workflow
|
|
133
|
-
- `duration_ms` — wall-clock duration of am-phase1
|
|
134
|
-
|
|
135
|
-
If the `<usage>` block is missing: log warning
|
|
136
|
-
`"am-phase1 produced no <usage> block; orchestrator token data unavailable"`
|
|
137
|
-
and set `actual_tokens = "N/A"`.
|
|
138
|
-
|
|
139
|
-
Read `{token_estimate_path}`. Append the following in order:
|
|
140
|
-
|
|
141
|
-
### 5a — Orchestrator row (for use in 5b only)
|
|
142
|
-
|
|
143
|
-
Compute values:
|
|
144
|
-
- Estimated tokens: 80,000 (baseline from estimation model)
|
|
145
|
-
- Estimated cost: $0.4320 — `80,000 × $0.005400 / 1,000` using sonnet blended rate
|
|
146
|
-
- Actual tokens: `subagent_tokens` from `<usage>` block; `"N/A"` if missing
|
|
147
|
-
- Actual cost: `(actual_tokens / 1,000) × 0.005400` at 4 decimal places; `"N/A"` if unavailable
|
|
148
|
-
|
|
149
|
-
### 5b — Actuals vs Estimate section
|
|
150
|
-
|
|
151
|
-
Append a horizontal rule (`---`) followed by:
|
|
152
|
-
|
|
153
|
-
```markdown
|
|
154
|
-
## Actuals vs Estimate
|
|
155
|
-
|
|
156
|
-
| Agent | Task/Scope | Model | Est. tokens | Actual tokens | Delta | Est. cost ($) | Actual cost ($) | Duration |
|
|
157
|
-
|-------|------------|-------|-------------|---------------|-------|---------------|-----------------|----------|
|
|
158
|
-
| {agent} | {scope} | {model} | {est} | {actual} | {±delta} | {est_cost} | {actual_cost} | {Xmin Ys} |
|
|
159
|
-
...
|
|
160
|
-
| am-phase1 (orchestrator) | — | sonnet | 80,000 | {actual} | ±{delta} | $0.4320 | ${actual_cost} | {duration} |
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Column rules:
|
|
164
|
-
- **Delta**: `actual_tokens − est_tokens`; show as `+N` or `−N`. Show `"N/A"` if either missing.
|
|
165
|
-
- **Duration**: convert `duration_ms` to `Xmin Ys` where available; use `"—"` where not.
|
|
166
|
-
- Rows with `"N/A"` actual tokens are still shown but excluded from aggregate calculations.
|
|
167
|
-
|
|
168
|
-
### 5c — Estimation accuracy by agent type (conditional)
|
|
169
|
-
|
|
170
|
-
If 2+ distinct model tiers appear with non-N/A actuals, append:
|
|
171
|
-
|
|
172
|
-
```markdown
|
|
173
|
-
## Estimation accuracy by agent type
|
|
174
|
-
|
|
175
|
-
| Model | Count | Avg est. tokens | Avg actual tokens | Avg delta | Trend |
|
|
176
|
-
|-------|-------|-----------------|-------------------|-----------|-------|
|
|
177
|
-
| {model} | {N} | {avg_est} | {avg_actual} | {avg_delta} | {trend} |
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
- One row per model tier (e.g., `haiku`, `sonnet`)
|
|
181
|
-
- Exclude N/A rows from averages
|
|
182
|
-
- **Trend**: `"over-target"` if avg delta > +20% of avg est; `"under-target"` if < −20%; else `"on-target"`
|
|
183
|
-
|
|
184
|
-
### 5d — Grand Total section
|
|
185
|
-
|
|
186
|
-
Update the Grand Total section: replace `"partial — updated at pipeline end"` with Final values:
|
|
187
|
-
|
|
188
|
-
```markdown
|
|
189
|
-
## Grand Total (Final)
|
|
190
|
-
|
|
191
|
-
| Metric | Estimated | Actual | Delta | Delta % |
|
|
192
|
-
|--------|-----------|--------|-------|---------|
|
|
193
|
-
| Total tokens (all agents) | {sum_est} | {sum_actual} | ±{delta} | {delta_pct} |
|
|
194
|
-
| Total cost ($) | ${sum_est_cost} | ${sum_actual_cost} | ±${delta_cost} | {delta_cost_pct} |
|
|
195
|
-
| Total wall-clock | — | {Xmin Ys} | — | — |
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
- **Delta %**: `(delta / estimated) × 100` at 1 decimal place; `"N/A"` if estimated is 0
|
|
199
|
-
- Sum all agents' tokens and costs; exclude `"N/A"` rows from sums
|
|
200
|
-
- Cost: 2 decimal places for totals; 4 decimal places for per-row costs
|
|
201
|
-
- The "Remediation" section contains a static note — leave it as-is
|
|
202
|
-
- Wall-clock: convert `duration_ms` from am-phase1 `<usage>` to minutes/seconds
|
|
203
|
-
|
|
204
|
-
---
|
|
205
|
-
|
|
206
|
-
## Step 6 — Report to user
|
|
207
|
-
|
|
208
|
-
After writing to the Token Estimate file, report:
|
|
209
|
-
|
|
210
|
-
```
|
|
211
|
-
Assessment pipeline complete.
|
|
212
|
-
Token estimate + actuals → {token_estimate_path}
|
|
213
|
-
Approvals → {approvals_path}
|
|
214
|
-
Process log → {output_dir}/{prefix}-process-log.txt
|
|
215
|
-
|
|
216
|
-
{summary from am-phase2}
|
|
217
|
-
```
|
|
124
|
+
## Step 5 — Report results
|
|
218
125
|
|
|
219
|
-
|
|
220
|
-
note this in the report but do not halt — the skill has completed its work.
|
|
126
|
+
Use the deterministic Token-Estimate and Effort-Estimate files returned by am-phase1, and the summary returned by am-phase2. Worker usage is in token_ledger; missing usage remains unavailable. Do not invent an orchestrator usage block or overwrite the host-generated metrics.
|
|
@@ -5,12 +5,9 @@ argument-hint: <path-to-feature.md> [--force]
|
|
|
5
5
|
|
|
6
6
|
# Implement Feature
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
(`pm-phase1`, `pm-phase2`, `pm-phase3`), handling approval gates in the main loop between
|
|
10
|
-
each phase, and recording the real token consumption at the end.
|
|
8
|
+
Runs documentation and work breakdown through the deterministic Node workflow host, then implementation through the FTR-018 task executor. Approval gates remain in the main loop.
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
with their declared `model:` frontmatter honoured and producing accurate per-agent `usage` data.
|
|
10
|
+
Workflows are JavaScript assets, never agent types. Do not pass pm-phase1/2/3 or am-phase1/2 to agentType, subagent_type, or --agent. Use the workflow CLI below. Resolve the absolute Claude executable path as described in docs/task-executor-bootstrap.md.
|
|
14
11
|
|
|
15
12
|
---
|
|
16
13
|
|
|
@@ -58,53 +55,13 @@ Before starting the pipeline, verify that every pipeline agent is installed and
|
|
|
58
55
|
|
|
59
56
|
## Step 1 — Invoke pm-phase1 (Documentation Phase)
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Before dispatching, resolve and verify the pm-phase1 orchestrator:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
ai-toolkit agents resolve \
|
|
67
|
-
--project . \
|
|
68
|
-
--id gaia.orchestrator.feature.phase1 \
|
|
69
|
-
--require-verified
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
If exit non-zero → **HARD STOP**: report the error, do not dispatch pm-phase1.
|
|
73
|
-
|
|
74
|
-
Store the resolution record fields: `nativeName`, `sha256` (definitionHash), `scope` (resolutionScope), `toolkitVersion`.
|
|
75
|
-
|
|
76
|
-
Open the dispatch ledger entry (fail-closed):
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
ai-toolkit ledger open \
|
|
80
|
-
--prefix {PREFIX} \
|
|
81
|
-
--agent pm-phase1:dispatch \
|
|
82
|
-
--phase phase3 \
|
|
83
|
-
--dir {LEDGER_DIR} \
|
|
84
|
-
--metadata-json '{"agentId":"gaia.orchestrator.feature.phase1","nativeAgentName":"{nativeName}","platform":"claude","toolkitVersion":"{toolkitVersion}","resolutionScope":"{scope}","definitionHash":"{sha256}"}'
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
If exit non-zero → **HARD STOP** (fail-closed): do not dispatch.
|
|
88
|
-
|
|
89
|
-
### Step 1b — Invoke pm-phase1 using verified nativeName
|
|
90
|
-
|
|
91
|
-
Invoke the workflow using ONLY the resolved `nativeName` (never a hardcoded name):
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
subagent_type: {nativeName}
|
|
95
|
-
prompt: <path-to-feature.md>
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Wait for the workflow to complete. Do NOT proceed until it returns.
|
|
99
|
-
|
|
100
|
-
After the workflow returns, close the dispatch ledger entry:
|
|
58
|
+
Run directly via the shell tool:
|
|
101
59
|
|
|
102
60
|
```bash
|
|
103
|
-
ai-toolkit
|
|
104
|
-
--prefix {PREFIX} --agent pm-phase1:dispatch --dir {LEDGER_DIR}
|
|
61
|
+
ai-toolkit workflow run pm-phase1 --project . --claude-path "{ABSOLUTE_CLAUDE_EXE}" -- "<path-to-feature.md>" [--force]
|
|
105
62
|
```
|
|
106
63
|
|
|
107
|
-
|
|
64
|
+
The host verifies the installed workflow and each worker and owns all ledger transitions. Do not manually open/close its entries. Nonzero exit is a HARD STOP: do not present the next gate or report successful completion. Parse stdout as JSON only on exit 0. Never dispatch the workflow as a subagent.
|
|
108
65
|
|
|
109
66
|
Extract from the result:
|
|
110
67
|
- `prefix` — feature prefix (e.g. `FTR-009`)
|
|
@@ -174,40 +131,15 @@ If the file is missing or incomplete, write it again before proceeding.
|
|
|
174
131
|
|
|
175
132
|
## Step 3 — Invoke pm-phase2 (Work Breakdown Phase)
|
|
176
133
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
Resolve and verify pm-phase2:
|
|
134
|
+
Run directly via the shell tool:
|
|
180
135
|
|
|
181
136
|
```bash
|
|
182
|
-
ai-toolkit
|
|
183
|
-
--project . \
|
|
184
|
-
--id gaia.orchestrator.feature.phase2 \
|
|
185
|
-
--require-verified
|
|
137
|
+
ai-toolkit workflow run pm-phase2 --project . --claude-path "{ABSOLUTE_CLAUDE_EXE}" -- "<path-to-feature.md>"
|
|
186
138
|
```
|
|
187
139
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
Open the dispatch ledger entry (fail-closed):
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
ai-toolkit ledger open \
|
|
194
|
-
--prefix {PREFIX} \
|
|
195
|
-
--agent pm-phase2:dispatch \
|
|
196
|
-
--phase phase3 \
|
|
197
|
-
--dir {LEDGER_DIR} \
|
|
198
|
-
--metadata-json '{"agentId":"gaia.orchestrator.feature.phase2","nativeAgentName":"{nativeName}","platform":"claude","toolkitVersion":"{toolkitVersion}","resolutionScope":"{scope}","definitionHash":"{sha256}"}'
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
If exit non-zero → **HARD STOP** (fail-closed).
|
|
202
|
-
|
|
203
|
-
### Step 3b — Invoke pm-phase2 using verified nativeName
|
|
204
|
-
|
|
205
|
-
```
|
|
206
|
-
subagent_type: {nativeName}
|
|
207
|
-
prompt: <path-to-feature.md>
|
|
208
|
-
```
|
|
140
|
+
The host verifies the installed workflow and each worker and owns all ledger transitions. Do not manually open/close its entries. Nonzero exit is a HARD STOP: do not present the next gate or report successful completion. Parse stdout as JSON only on exit 0. Never dispatch the workflow as a subagent.
|
|
209
141
|
|
|
210
|
-
|
|
142
|
+
Extract from the result:
|
|
211
143
|
- `user_stories` — number of User Stories
|
|
212
144
|
- `total_tasks` — total task count
|
|
213
145
|
- `domain_breakdown` — tasks per domain
|
|
@@ -216,15 +148,6 @@ Wait for the workflow to complete. Extract from the result:
|
|
|
216
148
|
- `agent_estimate` — agent parallel estimate
|
|
217
149
|
- `token_ledger` — per-agent token data from phase 2
|
|
218
150
|
|
|
219
|
-
Close the dispatch ledger entry after the workflow returns:
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
ai-toolkit ledger close \
|
|
223
|
-
--prefix {PREFIX} --agent pm-phase2:dispatch --dir {LEDGER_DIR}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
If ledger close fails → **HARD STOP**: report the error. Do not continue to Gate 2. The error is not swallowed (AC-22).
|
|
227
|
-
|
|
228
151
|
---
|
|
229
152
|
|
|
230
153
|
## Step 4 — Present Gate 2 (HARD STOP — present in main loop)
|
|
@@ -276,7 +199,7 @@ Read back `{PREFIX}-Approvals.md` and verify Gate 2 ✅ is present before contin
|
|
|
276
199
|
|
|
277
200
|
## Step 5 — Create feature branch
|
|
278
201
|
|
|
279
|
-
Before
|
|
202
|
+
Before launching the task executor, create the feature branch:
|
|
280
203
|
|
|
281
204
|
```bash
|
|
282
205
|
git checkout -b feature/{PREFIX}-{short-slug}
|
|
@@ -290,102 +213,88 @@ git checkout feature/{PREFIX}-{short-slug}
|
|
|
290
213
|
|
|
291
214
|
---
|
|
292
215
|
|
|
293
|
-
## Step 6 —
|
|
216
|
+
## Step 6 — Launch the task executor (Implementation Phase)
|
|
294
217
|
|
|
295
218
|
Pre-condition check: read `{PREFIX}-Approvals.md` and verify BOTH Gate 1 ✅ and Gate 2 ✅.
|
|
296
219
|
If either is missing, return to the missing gate.
|
|
297
220
|
|
|
298
|
-
|
|
221
|
+
Implementation is no longer dispatched as a subagent from this skill. There is no
|
|
222
|
+
pm-phase3 workflow, no Tier-1 dispatch guard, and no `pm-phase3:dispatch` ledger entry for
|
|
223
|
+
this step — none of that applies once implementation runs as an external process instead of
|
|
224
|
+
an in-chat subagent. Once Gate 2 is approved, this skill's job is limited to presenting or
|
|
225
|
+
launching **one explicit `task-executor` start command**; the executor process itself then
|
|
226
|
+
owns the repo, plans, executes, checkpoints and resumes tasks deterministically, independent
|
|
227
|
+
of this chat.
|
|
228
|
+
|
|
229
|
+
**No subagent orchestrates the run, and no assistant or agent involvement is required for
|
|
230
|
+
each task transition once the run has started.** This is a deliberate behavioral change from
|
|
231
|
+
the retired pm-phase3 grouping model: previously an assistant-driven subagent had to be
|
|
232
|
+
present for the whole implementation phase; now a single durable command launch is enough,
|
|
233
|
+
and the run may keep going, checkpointing and resuming, even after this conversation ends.
|
|
234
|
+
|
|
235
|
+
### Step 6a — Present or launch the executor start command
|
|
299
236
|
|
|
300
|
-
|
|
237
|
+
Build the start command:
|
|
301
238
|
|
|
302
239
|
```bash
|
|
303
|
-
ai-toolkit
|
|
240
|
+
ai-toolkit executor start \
|
|
304
241
|
--project . \
|
|
305
|
-
--
|
|
306
|
-
--
|
|
242
|
+
--feature <path-to-feature.md> \
|
|
243
|
+
--max-concurrency 1 \
|
|
244
|
+
--claude-path <resolved-claude-cli-path> \
|
|
245
|
+
--task-timeout-ms <task-timeout-ms, e.g. 900000> \
|
|
246
|
+
--agent-budget-usd <per-agent budget in USD, e.g. 5.00>
|
|
307
247
|
```
|
|
308
248
|
|
|
309
|
-
|
|
249
|
+
Placeholders:
|
|
250
|
+
- `<path-to-feature.md>` — the feature.md path passed to this skill
|
|
251
|
+
- `<resolved-claude-cli-path>` — the Claude CLI executable path on this host; ask the user if unknown
|
|
252
|
+
- `<task-timeout-ms>` and `<agent-budget-usd>` — must be supplied explicitly; there is no hidden default timeout or spend
|
|
310
253
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
Remediation:
|
|
315
|
-
1. Run: ai-toolkit agents resolve --project . --id gaia.orchestrator.feature.phase3
|
|
316
|
-
2. Check the status field in the output for the failure reason.
|
|
317
|
-
3. Re-install the toolkit if the status is not-installed or hash-mismatch.
|
|
318
|
-
4. Contact the toolkit team if the issue persists.
|
|
254
|
+
**If the host's ordinary terminal capability can launch a durable external command**, launch
|
|
255
|
+
it directly through that capability so the process persists independently of this chat.
|
|
319
256
|
|
|
320
|
-
|
|
321
|
-
|
|
257
|
+
**If the host cannot launch a durable external command, show the exact command above for the
|
|
258
|
+
user to run themselves in a terminal.** Do not attempt to fake a durable launch by running it
|
|
259
|
+
as a blocking in-chat command — the run must be able to outlive this conversation.
|
|
322
260
|
|
|
323
|
-
|
|
261
|
+
In both cases, capture (or ask the user to report back) the `run-id` printed by `start` — it
|
|
262
|
+
is required for every subsequent `status`, `diagnose`, `stop`, `reconcile`, `resume`, and
|
|
263
|
+
`replan` call; there is no implicit last-run selection.
|
|
324
264
|
|
|
325
|
-
|
|
265
|
+
Tell the user that implementation has been launched and that progress and cost can be
|
|
266
|
+
checked at any time with:
|
|
326
267
|
|
|
327
268
|
```bash
|
|
328
|
-
ai-toolkit
|
|
329
|
-
--prefix {PREFIX} \
|
|
330
|
-
--agent pm-phase3:dispatch \
|
|
331
|
-
--phase phase3 \
|
|
332
|
-
--dir {LEDGER_DIR} \
|
|
333
|
-
--metadata-json '{"agentId":"gaia.orchestrator.feature.phase3","nativeAgentName":"{nativeName}","platform":"claude","toolkitVersion":"{toolkitVersion}","resolutionScope":"{scope}","definitionHash":"{sha256}"}'
|
|
269
|
+
ai-toolkit executor status --run-id {run_id} --format json
|
|
334
270
|
```
|
|
335
271
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
272
|
+
Do not block this skill on the run reaching a terminal state — proceed to Step 7 with
|
|
273
|
+
whatever the latest `status` reports at this point. No fallback to the retired pm-phase3
|
|
274
|
+
grouping model is permitted.
|
|
339
275
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
```
|
|
343
|
-
subagent_type: {nativeName}
|
|
344
|
-
prompt: <path-to-feature.md> --branch feature/{PREFIX}-{short-slug}
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
Wait for the workflow to complete. Capture its full result, including the `<usage>` block
|
|
348
|
-
(format: `subagent_tokens: N`). Extract from the result:
|
|
349
|
-
- `pr_url` — the created pull request URL
|
|
350
|
-
- `token_ledger` — all per-agent token data from phase 3
|
|
351
|
-
- `issues_summary` — escalation and issues counts
|
|
352
|
-
|
|
353
|
-
If `issues_summary.escalations > 0`, report the escalation details to the user.
|
|
354
|
-
|
|
355
|
-
**If pm-phase3 returned an error or escalation:** mark the dispatch ledger entry failed before stopping:
|
|
356
|
-
|
|
357
|
-
```bash
|
|
358
|
-
ai-toolkit ledger fail \
|
|
359
|
-
--prefix {PREFIX} --agent pm-phase3:dispatch \
|
|
360
|
-
--error "pm-phase3 returned an error or escalation" \
|
|
361
|
-
--dir {LEDGER_DIR}
|
|
362
|
-
```
|
|
276
|
+
---
|
|
363
277
|
|
|
364
|
-
|
|
278
|
+
## Step 7 — Complete Token Estimate file
|
|
365
279
|
|
|
366
|
-
|
|
280
|
+
Phases 1 and 2 return JSON token_ledger entries from measured worker subprocess usage. They do not return a workflow subagent usage block. Missing measurements stay unavailable. For phase 3 use the executor:
|
|
367
281
|
|
|
368
282
|
```bash
|
|
369
|
-
ai-toolkit
|
|
370
|
-
--prefix {PREFIX} --agent pm-phase3:dispatch --dir {LEDGER_DIR}
|
|
283
|
+
ai-toolkit executor status --run-id {run_id} --format json
|
|
371
284
|
```
|
|
372
285
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
286
|
+
Read the run's total actual tokens/cost and duration from that ledger-sourced summary. If the
|
|
287
|
+
run has not yet reached a terminal state (it may still be executing or may outlive this
|
|
288
|
+
chat), treat its actuals as **not yet available** for this pass — apply the same
|
|
289
|
+
null-compatibility rule below, and note in the file that the run is still in progress and the
|
|
290
|
+
row should be refreshed with a later `status` call.
|
|
376
291
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
From the `<usage>` block of the pm-phase3 result, read:
|
|
380
|
-
- `subagent_tokens` — total tokens consumed by the pm-phase3 workflow
|
|
381
|
-
- `duration_ms` — wall-clock duration of pm-phase3
|
|
382
|
-
|
|
383
|
-
Read `{PREFIX}-Token-Estimate.md`. Append the orchestrator row and grand total:
|
|
292
|
+
Read `{PREFIX}-Token-Estimate.md`. Append the executor run row and grand total:
|
|
384
293
|
|
|
385
294
|
> **Null-compatibility — actuals reading and cost calculation:** Treat a token value of `null`, `0`, or `not_available` as **data unavailable** — never as a real, observable zero consumption. Render unavailable values as `—` in the Actual tokens and Actual cost columns; exclude them from sums, averages, and grand totals. Preventing resume clobber and legacy misinterpretation requires that no unavailable measurement is coerced into a real zero.
|
|
386
295
|
|
|
387
296
|
```markdown
|
|
388
|
-
|
|
|
297
|
+
| task-executor (run {run_id}) | — | — | 80,000 (estimated) | {ledger_actual_tokens} (actual) | ±{delta} | {ledger_duration} |
|
|
389
298
|
|
|
390
299
|
---
|
|
391
300
|
|
|
@@ -393,8 +302,8 @@ Read `{PREFIX}-Token-Estimate.md`. Append the orchestrator row and grand total:
|
|
|
393
302
|
|
|
394
303
|
| Agent | Task / Scope | Model | Est. tokens | Actual tokens | Delta | Est. cost ($) | Actual cost ($) | Duration |
|
|
395
304
|
|-------|-------------|-------|------------|---------------|-------|--------------|----------------|----------|
|
|
396
|
-
{one row per entry in token_ledger
|
|
397
|
-
|
|
|
305
|
+
{one row per entry in token_ledger from phase 1 and 2, plus per-task ledger entries recorded by the executor run for phase 3; for any entry where actual tokens is null, 0, or not_available show — in Actual tokens and Actual cost and exclude that row from totals}
|
|
306
|
+
| task-executor (run {run_id}) | — | — | 80,000 | {ledger_actual_tokens} | ±{delta} | $0.4320 | ${ledger_actual_cost} | {ledger_duration} |
|
|
398
307
|
|
|
399
308
|
## Estimation accuracy by agent type
|
|
400
309
|
|
|
@@ -412,9 +321,9 @@ Read `{PREFIX}-Token-Estimate.md`. Append the orchestrator row and grand total:
|
|
|
412
321
|
```
|
|
413
322
|
|
|
414
323
|
> Per-agent values marked *(proportional)* are estimated distributions of the phase total.
|
|
415
|
-
> Phase
|
|
324
|
+
> Phase 1/2 actuals come from worker usage in token_ledger; implementation actuals come from the task executor ledger. Missing measurements remain unavailable.
|
|
416
325
|
|
|
417
|
-
If the Token Estimate file does not exist (
|
|
326
|
+
If the Token Estimate file does not exist (a prior phase failed before writing it), create it
|
|
418
327
|
from scratch using the data available in the token_ledger.
|
|
419
328
|
|
|
420
329
|
---
|
|
@@ -424,8 +333,14 @@ from scratch using the data available in the token_ledger.
|
|
|
424
333
|
After writing the token file, report:
|
|
425
334
|
|
|
426
335
|
```
|
|
427
|
-
Feature pipeline complete.
|
|
336
|
+
Feature pipeline complete through implementation launch.
|
|
428
337
|
Token estimate + actuals → {PREFIX}-Token-Estimate.md
|
|
429
338
|
Effort estimate + actuals → {PREFIX}-Effort-Estimate.md
|
|
430
|
-
|
|
339
|
+
Implementation run → run-id {run_id} (check with `ai-toolkit executor status --run-id {run_id}`)
|
|
431
340
|
```
|
|
341
|
+
|
|
342
|
+
Unlike the retired pm-phase3 model, this skill does not itself produce a pull request: the
|
|
343
|
+
executor's scope is task execution, checkpointing and branch integration, not PR creation.
|
|
344
|
+
Once `executor status` reports the run has reached a terminal, fully-integrated state, open
|
|
345
|
+
the pull request the same way you would for any other finished branch (e.g. `gh pr create`,
|
|
346
|
+
or the toolkit's own `/pr-description` skill).
|