5-phase-workflow 3.1.2 → 3.2.0
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/docs/workflow-guide.md
CHANGED
|
@@ -56,7 +56,7 @@ A compact plan (1-2 files, no migration, security/auth, or public API change) is
|
|
|
56
56
|
A full plan goes through four steps:
|
|
57
57
|
|
|
58
58
|
1. `step-orchestrator-agent` derives the execution graph — steps, execution mode, dependency edges, model choice, targeted pattern references, and verify commands.
|
|
59
|
-
2. Executor agents implement the components using an inline executor contract, independent ones in parallel. Each follows the repository standards and style skills that apply to its target. Mechanical work runs on `haiku`, ordinary logic on `sonnet`, complex work and every retry on `opus` at medium effort.
|
|
59
|
+
2. Executor agents implement the components using an inline executor contract, independent ones in parallel. Each follows the repository standards and style skills that apply to its target. Mechanical work runs on `haiku`, ordinary logic on `sonnet`, complex work and every retry on `opus` at medium effort. With `advisor: true` in `.5/config.json` (opt-in, Claude Code only, off by default), executors consult Claude Code's advisor tool at hard decisions and the first retry stays on the planned model; turn the advisor on with `/advisor opus`.
|
|
60
60
|
3. When every component was mechanical and passed, build and tests run once plus the scope check. Otherwise `verification-agent` checks completeness, build/tests, the plan's acceptance criteria when it states any, and scope.
|
|
61
61
|
4. `/5:review` runs once on the files the run changed — `code-review`, `security-review` for security-sensitive files, and `review-style` — and `/5:address-review-findings` then fixes the clear findings on its own and asks you only about real decisions, one question at a time. Auto-commit comes after, so approved fixes land in the same commit.
|
|
62
62
|
|
package/package.json
CHANGED
|
@@ -19,6 +19,10 @@ You follow the plan, your component, and existing codebase patterns. You do not
|
|
|
19
19
|
6. Run every verify command assigned to your component. If none is assigned, verify touched files exist and run the narrowest relevant test/build command you can infer.
|
|
20
20
|
7. Fix local mechanical issues you caused. Stop for architectural changes, auth gates, missing external services, or unclear product decisions.
|
|
21
21
|
|
|
22
|
+
## Advisor (opt-in)
|
|
23
|
+
|
|
24
|
+
Only when `/5:implement` says the advisor is enabled (`.5/config.json` `advisor: true`) and an advisor tool is available: consult it before committing to an approach when the intent is ambiguous or crosses modules, and when the same verify failure returns after a fix. Do not consult it for mechanical edits or to confirm work that already passes. On a retry, consult it before your first edit.
|
|
25
|
+
|
|
22
26
|
## Simplicity
|
|
23
27
|
|
|
24
28
|
Write the minimum that satisfies the component (the "smallest coherent change"): reuse what already exists in this codebase first, then prefer the standard library, a native framework feature, or an already-installed dependency over anything new. Add no new dependency, no abstraction for single-use code, no unrequested flexibility, and no error handling for impossible cases. Touch only the target file and what it strictly needs (its test, an import site). Follow `Simplicity First` in the project `AGENTS.md`.
|
|
@@ -137,6 +137,12 @@ If "Cancel": Exit immediately with message "Configuration unchanged."
|
|
|
137
137
|
1. "No (recommended)" → `git.autoCommit: false`
|
|
138
138
|
2. "Yes - commit after each implementation step" → `git.autoCommit: true`
|
|
139
139
|
|
|
140
|
+
**2f2. Advisor during implementation (Claude Code only — skip on Codex and set `advisor: false`):**
|
|
141
|
+
- "Let `/5:implement` executors consult Claude Code's advisor tool at hard decisions, and retry a failed component once on its planned model before escalating to opus? Needs the advisor turned on in Claude Code (`/advisor opus`); it is experimental and Anthropic-API only."
|
|
142
|
+
- Options:
|
|
143
|
+
1. "No (recommended)" → `advisor: false`
|
|
144
|
+
2. "Yes" → `advisor: true`
|
|
145
|
+
|
|
140
146
|
**2g. Commit message pattern:**
|
|
141
147
|
|
|
142
148
|
When the repository already documents a commit convention (step 1e or 1e2), that convention wins and AGENTS.md links it. Skip the question, and derive the closest pattern from the convention with the `{ticket-id}` and `{short-description}` placeholders — for example `feat({ticket-id}): {short-description}` for Conventional Commits — and store it as `git.commitMessage.pattern`, so auto-commits follow the convention too. Otherwise ask:
|
|
@@ -189,7 +195,7 @@ Using the values gathered from Steps 1 and 2, write `.5/config.json` directly.
|
|
|
189
195
|
mkdir -p .5
|
|
190
196
|
```
|
|
191
197
|
|
|
192
|
-
**Schema:** Read `.claude/references/configure-tables.md` section "Config Schema" for the full JSON structure. Fill all values from user responses (including `rules.generate` from step 2j2). Write with pretty-printed JSON. Read back to verify correctness.
|
|
198
|
+
**Schema:** Read `.claude/references/configure-tables.md` section "Config Schema" for the full JSON structure. Fill all values from user responses (including `advisor` from step 2f2 and `rules.generate` from step 2j2). Write with pretty-printed JSON. Read back to verify correctness.
|
|
193
199
|
|
|
194
200
|
**Update `.5/version.json` with configure timestamp:**
|
|
195
201
|
|
|
@@ -23,7 +23,7 @@ Find the plan:
|
|
|
23
23
|
|
|
24
24
|
Plans have no fixed shape. The feature name is the plan's `feature` frontmatter field when it has one, otherwise the file name without `.md`.
|
|
25
25
|
|
|
26
|
-
Read the plan and `.5/config.json` if it exists. Nothing is persisted between runs; a rerun starts over, and executors see work that is already done in the files.
|
|
26
|
+
Read the plan and `.5/config.json` if it exists. The advisor is **enabled** for this run only when `.5/config.json` has `advisor: true` and the runtime is Claude Code; Codex has no advisor tool and ignores the setting. Nothing is persisted between runs; a rerun starts over, and executors see work that is already done in the files.
|
|
27
27
|
|
|
28
28
|
A plan is **compact** when it changes 1-2 files with no data migration, no security/auth change, and no public API change. Every other plan is **full**.
|
|
29
29
|
|
|
@@ -59,12 +59,14 @@ It moves orchestration into deterministic JS, fires parallel components concurre
|
|
|
59
59
|
"feature": "{feature-name}",
|
|
60
60
|
"paths": {"plan": "{plan-path}", "config": ".5/config.json"},
|
|
61
61
|
"standards": {"repo": ["CONTRIBUTING.md"], "styles": ["/abs/path/.claude/skills/fowler-code-smells/SKILL.md"]},
|
|
62
|
-
"baseline": [{"command": "...", "status": "passed|failed|skipped", "summary": "one line"}]
|
|
62
|
+
"baseline": [{"command": "...", "status": "passed|failed|skipped", "summary": "one line"}],
|
|
63
|
+
"advisor": false
|
|
63
64
|
}
|
|
64
65
|
```
|
|
65
66
|
|
|
66
67
|
- `standards` holds the repository standards and style skill paths from Step 1. Executors follow them while writing code.
|
|
67
68
|
- `baseline` is the array from Step 2 (or `[]`); the workflow's verifier treats those failures as pre-existing and reuses passing results instead of rerunning them.
|
|
69
|
+
- `advisor` is `true` only when the advisor is enabled (Step 1). It adds the advisor rule to the executors and keeps their first retry on the planned model.
|
|
68
70
|
- The workflow reads the config **file** at `paths.config` itself; do not pass build/test/commit settings inline.
|
|
69
71
|
|
|
70
72
|
2. If the returned `verification.inline` is `true` (every component was mechanical and passed, so no verification agent ran), run the **fast-path check** (3c) and take its result as the verification.
|
|
@@ -86,7 +88,7 @@ For each step:
|
|
|
86
88
|
2. Spawn executors with the component's model. Run `opus` at `effort: "medium"`.
|
|
87
89
|
- **Parallel step: emit all of the step's executor Agent calls in a single message so they run concurrently.**
|
|
88
90
|
- Sequential step (same-file or dependency): one executor at a time.
|
|
89
|
-
- Give each executor only its component block, required `patternRefs`, verify commands, the standards from Step 1, and the inline contract below — do not make it read `step-executor-agent.md`.
|
|
91
|
+
- Give each executor only its component block, required `patternRefs`, verify commands, the standards from Step 1, and the inline contract below — do not make it read `step-executor-agent.md`. When the advisor is enabled, append the advisor line after the contract.
|
|
90
92
|
|
|
91
93
|
```text
|
|
92
94
|
Implement exactly the assigned component. Read only listed patternRefs ranges/symbols and the target file. Nothing is persisted between runs, so your work may already be done: for `create`, read the target first when it exists — if it already fulfils the intent, report success with no change; otherwise complete it, never overwrite it blindly. Read the parts of the repository standards and style skills that apply to your target and follow them; repository standards win over the styles. Make the smallest coherent change — reuse existing codebase code first, then stdlib, native platform features, and installed dependencies; touch only the target file and what it strictly needs (its test, an import site) — run assigned verify commands, and stop (STATUS: failed) for missing dependencies, unplanned auth/schema/API changes, or unclear product decisions. If verify fails only from pre-existing unrelated issues, report it under DEVIATIONS with the exact evidence and keep STATUS: success — your change is complete. Do not make more than three attempts on the same failing issue.
|
|
@@ -103,9 +105,15 @@ ERROR: none | {error description}
|
|
|
103
105
|
---END---
|
|
104
106
|
```
|
|
105
107
|
|
|
108
|
+
Advisor line (only when the advisor is enabled):
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
Advisor: if an advisor tool is available, consult it before committing to an approach when the intent is ambiguous or crosses modules, and when the same verify failure returns after a fix. Do not consult it for mechanical edits or to confirm work that already passes.
|
|
112
|
+
```
|
|
113
|
+
|
|
106
114
|
3. Parse only the `---RESULT---` block from each executor. Trust the executor's report — do not re-read files you did not change to confirm them.
|
|
107
115
|
|
|
108
|
-
Retry failed
|
|
116
|
+
Retry a failed component up to twice, right after it fails (in a sequential step, before the next component starts), on `opus` at `effort: "medium"`. When the advisor is enabled, the first retry stays on the component's planned model and asks the executor to consult the advisor before its first edit; only the second escalates to `opus`. Give every retry the previous attempt's `STATUS`, `VERIFY`, `ERROR`, and `DEVIATIONS` (or that it returned no result). A `STATUS: success` with `VERIFY: failed` is no retry reason: it can come from pre-existing failures, which verification separates using the baseline. Never fix code in the orchestrator context.
|
|
109
117
|
|
|
110
118
|
#### 3c. Verify
|
|
111
119
|
|
|
@@ -19,7 +19,9 @@ export const meta = {
|
|
|
19
19
|
// auto-commit after this returns. Nothing is persisted: a rerun starts over.
|
|
20
20
|
//
|
|
21
21
|
// Models: haiku for mechanical work, sonnet for ordinary logic, opus at effort
|
|
22
|
-
// medium for complex work and for every retry.
|
|
22
|
+
// medium for complex work and for every retry. With args.advisor (opt-in, from
|
|
23
|
+
// .5/config.json) executors consult Claude Code's advisor tool at decision points
|
|
24
|
+
// and the first retry stays on the planned model.
|
|
23
25
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
24
26
|
|
|
25
27
|
const RESULT_SCHEMA = {
|
|
@@ -141,15 +143,24 @@ The plan has no fixed shape. Derive the components from whatever it describes: o
|
|
|
141
143
|
Return an object matching the schema (steps[] and pendingComponents[]).`
|
|
142
144
|
}
|
|
143
145
|
|
|
146
|
+
const ADVISOR_RULE = 'Advisor: if an advisor tool is available, consult it before committing to an approach when the intent is ambiguous or crosses modules, and when the same verify failure returns after a fix. Do not consult it for mechanical edits or to confirm work that already passes.'
|
|
147
|
+
|
|
148
|
+
function retryContext(previous, a) {
|
|
149
|
+
const failure = previous
|
|
150
|
+
? `status ${previous.status}, verify ${previous.verify}, error: ${previous.error || 'none'}, deviations: ${previous.deviations || 'none'}`
|
|
151
|
+
: 'the agent crashed without returning a result'
|
|
152
|
+
const advisor = a.advisor ? ' Consult the advisor, if available, before your first edit.' : ''
|
|
153
|
+
return `This is a RETRY of a failed attempt (${failure}). Read the target as the previous attempt left it, find the root cause, and correct it.${advisor}`
|
|
154
|
+
}
|
|
155
|
+
|
|
144
156
|
function executorPrompt(c, a, opts) {
|
|
145
157
|
const refs = (c.patternRefs || []).map(r => ` - ${r.file}${r.read ? ` (${r.read})` : ''}${r.reason ? ` — ${r.reason}` : ''}`).join('\n') || ' - none'
|
|
146
158
|
const verify = (c.verifyCommands || []).join(' && ') || 'infer the narrowest relevant test/build command'
|
|
147
159
|
const standards = a.standards || {}
|
|
148
160
|
const repoStandards = (standards.repo || []).map(f => ` - ${f}`).join('\n') || ' - none found'
|
|
149
161
|
const styles = (standards.styles || []).map(f => ` - ${f}`).join('\n') || ' - none found'
|
|
150
|
-
const retry = opts && opts.retry
|
|
151
|
-
|
|
152
|
-
: ''
|
|
162
|
+
const retry = opts && opts.retry ? `\n${retryContext(opts.result, a)}` : ''
|
|
163
|
+
const advisor = a.advisor ? `\n\n${ADVISOR_RULE}` : ''
|
|
153
164
|
return `You are a Step Executor. Implement EXACTLY this component and nothing more.${retry}
|
|
154
165
|
|
|
155
166
|
Component: ${c.name}
|
|
@@ -166,7 +177,7 @@ ${repoStandards}
|
|
|
166
177
|
Style skills:
|
|
167
178
|
${styles}
|
|
168
179
|
|
|
169
|
-
Rules: Nothing is persisted between runs, so your work may already be done: for \`create\`, read the target first when it exists — if it already fulfils the intent, report success with no change; otherwise complete it, never overwrite it blindly. Smallest coherent change; reuse what already exists in this codebase before writing new code, then prefer stdlib, native platform features, and installed dependencies; touch only the target file and what it strictly needs (its test, an import site); mirror existing naming/exports/layout/tests; follow any local skill or rule; add no new dependency; no abstraction or error handling beyond what the intent requires. Fix mechanical issues you cause (imports, types, lint). STOP and report failed for missing dependencies, unplanned auth/schema/API/contract changes, or unclear product decisions. If verify fails only from pre-existing unrelated issues, report that as a deviation with the exact evidence — do not mark the component failed. Do not make more than three attempts on the same failing issue
|
|
180
|
+
Rules: Nothing is persisted between runs, so your work may already be done: for \`create\`, read the target first when it exists — if it already fulfils the intent, report success with no change; otherwise complete it, never overwrite it blindly. Smallest coherent change; reuse what already exists in this codebase before writing new code, then prefer stdlib, native platform features, and installed dependencies; touch only the target file and what it strictly needs (its test, an import site); mirror existing naming/exports/layout/tests; follow any local skill or rule; add no new dependency; no abstraction or error handling beyond what the intent requires. Fix mechanical issues you cause (imports, types, lint). STOP and report failed for missing dependencies, unplanned auth/schema/API/contract changes, or unclear product decisions. If verify fails only from pre-existing unrelated issues, report that as a deviation with the exact evidence — do not mark the component failed. Do not make more than three attempts on the same failing issue.${advisor}
|
|
170
181
|
|
|
171
182
|
Then run: ${verify}
|
|
172
183
|
|
|
@@ -175,7 +186,7 @@ Return structured output: status, filesCreated, filesModified, verify, deviation
|
|
|
175
186
|
|
|
176
187
|
function verifyPrompt(a, results) {
|
|
177
188
|
const ran = results.flatMap(s => s.items.map(i =>
|
|
178
|
-
` step ${s.step} ${i.component.name}: ${i.result ? i.result.status : 'no result'} (verify ${i.result ? i.result.verify : '?'})${i.escalated ? ' [escalated to opus]' : ''}`))
|
|
189
|
+
` step ${s.step} ${i.component.name}: ${i.result ? i.result.status : 'no result'} (verify ${i.result ? i.result.verify : '?'})${i.escalated ? ' [escalated to opus]' : i.retried ? ' [retried]' : ''}`))
|
|
179
190
|
const summary = ran.join('\n') || ' (no components ran)'
|
|
180
191
|
const repoStandards = ((a.standards && a.standards.repo) || []).join(', ') || 'none found'
|
|
181
192
|
const baseline = (a.baseline && a.baseline.length)
|
|
@@ -206,42 +217,50 @@ function modelOpts(model) {
|
|
|
206
217
|
return model === 'opus' ? { model: 'opus', effort: 'medium' } : { model: model || 'haiku' }
|
|
207
218
|
}
|
|
208
219
|
|
|
220
|
+
// A crashed agent (null result) counts as failed: an infra error should not be treated more
|
|
221
|
+
// harshly than a clean structured failure. verify "failed" alone is no retry reason: it can come
|
|
222
|
+
// from pre-existing issues, which the verifier separates using the baseline.
|
|
223
|
+
function needsRetry(result) {
|
|
224
|
+
return result == null || result.status === 'failed'
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Retries escalate to opus. With the advisor opted in, the first retry stays on the planned model
|
|
228
|
+
// and consults the advisor instead; only the second escalates.
|
|
229
|
+
function retryModel(c, attempt, a) {
|
|
230
|
+
return a.advisor && attempt === 1 ? c.model : 'opus'
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Runs one component and retries it up to twice, handing each retry the previous failure.
|
|
234
|
+
async function runComponent(c, a) {
|
|
235
|
+
const run = (model, label, previous) => agent(executorPrompt(c, a, previous),
|
|
236
|
+
{ label, phase: 'Execute', ...modelOpts(model), schema: RESULT_SCHEMA }).catch(() => null)
|
|
237
|
+
|
|
238
|
+
// `last` is the latest attempt, null when it crashed; `item.result` keeps the latest structured result.
|
|
239
|
+
let last = await run(c.model, `exec:${c.name}`)
|
|
240
|
+
const item = { component: c, result: last, retried: false, escalated: false }
|
|
241
|
+
for (let attempt = 1; attempt <= 2 && needsRetry(item.result); attempt++) {
|
|
242
|
+
const model = retryModel(c, attempt, a)
|
|
243
|
+
log(`retry ${c.name} (attempt ${attempt + 1}) on ${model || 'haiku'}`)
|
|
244
|
+
item.retried = true
|
|
245
|
+
item.escalated = item.escalated || model === 'opus'
|
|
246
|
+
last = await run(model, `retry:${c.name}`, { retry: true, result: last })
|
|
247
|
+
if (last) item.result = last
|
|
248
|
+
}
|
|
249
|
+
return item
|
|
250
|
+
}
|
|
251
|
+
|
|
209
252
|
async function runStep(step, components, a) {
|
|
210
253
|
const stepComps = components.filter(c => step.components.includes(c.name))
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
// Fire every parallel component together — true concurrency, one wave.
|
|
216
|
-
waveResults = await parallel(stepComps.map(c => () =>
|
|
217
|
-
agent(executorPrompt(c, a), { label: `exec:${c.name}`, phase: 'Execute', ...modelOpts(c.model), schema: RESULT_SCHEMA })
|
|
218
|
-
.then(result => ({ component: c, result }))
|
|
219
|
-
.catch(() => ({ component: c, result: null }))))
|
|
254
|
+
let items
|
|
255
|
+
if (step.mode === 'parallel') {
|
|
256
|
+
// Fire every parallel component together, retries included — true concurrency, one wave.
|
|
257
|
+
items = await parallel(stepComps.map(c => () => runComponent(c, a)))
|
|
220
258
|
} else {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
.catch(() => null)
|
|
225
|
-
waveResults.push({ component: c, result })
|
|
226
|
-
}
|
|
259
|
+
// Sequential components depend on each other, so each one is retried before the next starts.
|
|
260
|
+
items = []
|
|
261
|
+
for (const c of stepComps) items.push(await runComponent(c, a))
|
|
227
262
|
}
|
|
228
|
-
|
|
229
|
-
// Retry failed OR crashed (null) components up to twice, escalating to opus.
|
|
230
|
-
// A crashed agent (null result) is retried too — an infra error should not be
|
|
231
|
-
// treated more harshly than a clean structured failure.
|
|
232
|
-
for (const wr of waveResults) {
|
|
233
|
-
let attempt = 1
|
|
234
|
-
while ((wr.result == null || wr.result.status === 'failed') && attempt <= 2) {
|
|
235
|
-
log(`retry ${wr.component.name} (attempt ${attempt + 1}) on opus`)
|
|
236
|
-
wr.escalated = true
|
|
237
|
-
const retried = await agent(executorPrompt(wr.component, a, { retry: true }),
|
|
238
|
-
{ label: `retry:${wr.component.name}`, phase: 'Execute', ...modelOpts('opus'), schema: RESULT_SCHEMA }).catch(() => null)
|
|
239
|
-
if (retried) wr.result = retried
|
|
240
|
-
attempt++
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return { step: step.number, name: step.name, mode: step.mode, items: waveResults }
|
|
263
|
+
return { step: step.number, name: step.name, mode: step.mode, items }
|
|
245
264
|
}
|
|
246
265
|
|
|
247
266
|
// ── Main ─────────────────────────────────────────────────────────────────────
|
|
@@ -265,7 +284,7 @@ const allPassed = allItems.length > 0 && allItems.every(i => i.result && i.resul
|
|
|
265
284
|
// Mechanical when every component was planned as haiku and none needed a retry; anything
|
|
266
285
|
// else signals reasoning-level work that warrants the full verification agent.
|
|
267
286
|
const usedOpus = components.some(c => c.model === 'opus') || allItems.some(i => i.escalated)
|
|
268
|
-
const mechanical = !usedOpus && components.every(c => (c.model || 'haiku') === 'haiku')
|
|
287
|
+
const mechanical = !usedOpus && !allItems.some(i => i.retried) && components.every(c => (c.model || 'haiku') === 'haiku')
|
|
269
288
|
// Deterministic scope signal: files an executor touched beyond its planned target(s).
|
|
270
289
|
// Tests and import sites are legitimate, so this is reported for the user, never a failure.
|
|
271
290
|
const extraFiles = allItems.flatMap(i => {
|
|
@@ -295,7 +314,7 @@ return {
|
|
|
295
314
|
step: s.step,
|
|
296
315
|
name: s.name,
|
|
297
316
|
mode: s.mode,
|
|
298
|
-
items: s.items.map(i => ({ component: i.component.name, file: i.component.file, sourceFile: i.component.sourceFile, escalated:
|
|
317
|
+
items: s.items.map(i => ({ component: i.component.name, file: i.component.file, sourceFile: i.component.sourceFile, retried: i.retried, escalated: i.escalated, result: i.result }))
|
|
299
318
|
})),
|
|
300
319
|
verification,
|
|
301
320
|
extraFiles,
|