devflow-kit 3.5.0 → 3.7.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.
Files changed (146) hide show
  1. package/CHANGELOG.md +178 -1
  2. package/README.md +10 -6
  3. package/dist/agents/code.md +7 -11
  4. package/dist/agents/{diagnose.md → debug.md} +4 -4
  5. package/dist/agents/{code-fix.md → fix.md} +7 -8
  6. package/dist/agents/{scrutinize.md → harden.md} +6 -6
  7. package/dist/agents/{code-edit.md → refactor.md} +8 -9
  8. package/dist/agents/review.md +2 -0
  9. package/dist/cli/agents-view/render.js +1 -1
  10. package/dist/cli/commands/gates.js +276 -0
  11. package/dist/cli/commands/init-seed.js +9 -1
  12. package/dist/cli/commands/init.js +34 -11
  13. package/dist/cli/commands/learning.js +12 -12
  14. package/dist/cli/commands/legacy-hooks.js +1 -1
  15. package/dist/cli/commands/memory.js +18 -0
  16. package/dist/cli/commands/uninstall.js +111 -5
  17. package/dist/cli.js +2 -0
  18. package/dist/commands/bug-analysis.md +21 -17
  19. package/dist/commands/code-review.md +65 -66
  20. package/dist/commands/debug.md +17 -17
  21. package/dist/commands/dynamic-build.md +104 -116
  22. package/dist/commands/dynamic-plan.md +13 -11
  23. package/dist/commands/dynamic-profile.md +9 -7
  24. package/dist/commands/dynamic-tickets.md +13 -11
  25. package/dist/commands/explore.md +15 -15
  26. package/dist/commands/implement.md +80 -154
  27. package/dist/commands/plan.md +34 -66
  28. package/dist/commands/release.md +11 -7
  29. package/dist/commands/research.md +14 -10
  30. package/dist/commands/resolve.md +44 -88
  31. package/dist/commands/self-review.md +44 -44
  32. package/dist/core/agent-models.js +47 -11
  33. package/dist/core/{learning-tuning-config.js → curate-tuning-config.js} +14 -14
  34. package/dist/core/echo-value.js +42 -0
  35. package/dist/core/evidence-policy.js +17 -5
  36. package/dist/core/gate-level.js +213 -0
  37. package/dist/core/learning-queue-cleanup.js +1 -1
  38. package/dist/core/manifest.js +26 -10
  39. package/dist/core/migrations.js +63 -44
  40. package/dist/core/model-discovery.js +7 -1
  41. package/dist/core/plugins.js +14 -12
  42. package/dist/core/project-paths.js +3 -3
  43. package/dist/core/tracker.js +5 -33
  44. package/dist/hud/codex-usage.js +247 -0
  45. package/dist/hud/components/codex-quota.js +37 -0
  46. package/dist/hud/components/usage-quota.js +1 -1
  47. package/dist/hud/config.js +1 -0
  48. package/dist/hud/index.js +16 -3
  49. package/dist/hud/render.js +3 -1
  50. package/dist/learning-off/agents/code.md +7 -11
  51. package/dist/learning-off/agents/{diagnose.md → debug.md} +4 -4
  52. package/dist/learning-off/agents/{code-fix.md → fix.md} +7 -8
  53. package/dist/learning-off/agents/{scrutinize.md → harden.md} +6 -6
  54. package/dist/learning-off/agents/{code-edit.md → refactor.md} +8 -9
  55. package/dist/learning-off/agents/review.md +2 -0
  56. package/dist/learning-off/commands/bug-analysis.md +9 -9
  57. package/dist/learning-off/commands/code-review.md +54 -59
  58. package/dist/learning-off/commands/debug.md +6 -10
  59. package/dist/learning-off/commands/dynamic-build.md +98 -112
  60. package/dist/learning-off/commands/dynamic-plan.md +5 -5
  61. package/dist/learning-off/commands/dynamic-profile.md +1 -1
  62. package/dist/learning-off/commands/dynamic-tickets.md +5 -5
  63. package/dist/learning-off/commands/explore.md +4 -8
  64. package/dist/learning-off/commands/implement.md +68 -146
  65. package/dist/learning-off/commands/plan.md +23 -58
  66. package/dist/learning-off/commands/release.md +4 -2
  67. package/dist/learning-off/commands/research.md +2 -2
  68. package/dist/learning-off/commands/resolve.md +33 -81
  69. package/dist/learning-off/commands/self-review.md +32 -36
  70. package/dist/skills/git/references/pr/check-merge-readiness.md +2 -0
  71. package/dist/skills/git/references/pr/update-pr-evidence.md +4 -6
  72. package/dist/skills/git/references/tracker/github/ensure-pr-ready.md +7 -9
  73. package/dist/skills/git/references/tracker/jira/ensure-pr-ready.md +7 -15
  74. package/dist/skills/git/references/tracker/linear/ensure-pr-ready.md +7 -15
  75. package/dist/targets/claude-code/installer.js +117 -84
  76. package/dist/targets/claude-code/learning-install.js +15 -3
  77. package/dist/targets/claude-code/tracker-servers.js +1 -1
  78. package/package.json +1 -1
  79. package/src/assets/agents/_partials/_code.mds +7 -8
  80. package/src/assets/agents/code.mds +4 -7
  81. package/src/assets/agents/{learning.md → curate.md} +8 -10
  82. package/src/assets/agents/{diagnose.mds → debug.mds} +4 -4
  83. package/src/assets/agents/evaluate.md +4 -4
  84. package/src/assets/agents/{code-fix.mds → fix.mds} +5 -5
  85. package/src/assets/agents/{scrutinize.mds → harden.mds} +6 -6
  86. package/src/assets/agents/{simplify.md → polish.md} +4 -4
  87. package/src/assets/agents/{code-edit.mds → refactor.mds} +6 -6
  88. package/src/assets/agents/review.mds +2 -0
  89. package/src/assets/agents/synthesize.md +2 -2
  90. package/src/assets/agents/test.md +2 -2
  91. package/src/assets/commands/_partials/_compliance.mds +1 -1
  92. package/src/assets/commands/_partials/_decisions.mds +26 -6
  93. package/src/assets/commands/_partials/_engine.mds +15 -15
  94. package/src/assets/commands/_partials/_evidence_policy.mds +0 -17
  95. package/src/assets/commands/_partials/_knowledge.mds +14 -9
  96. package/src/assets/commands/_partials/_preamble.mds +4 -2
  97. package/src/assets/commands/_partials/_roster.mds +4 -4
  98. package/src/assets/commands/_partials/_settings.mds +2 -2
  99. package/src/assets/commands/_partials/_wave.mds +10 -17
  100. package/src/assets/commands/bug-analysis.mds +7 -7
  101. package/src/assets/commands/code-review.mds +51 -56
  102. package/src/assets/commands/debug.mds +2 -2
  103. package/src/assets/commands/dynamic-build.mds +67 -74
  104. package/src/assets/commands/implement.mds +65 -127
  105. package/src/assets/commands/plan.mds +21 -61
  106. package/src/assets/commands/release.mds +5 -1
  107. package/src/assets/commands/resolve.mds +28 -76
  108. package/src/assets/commands/self-review.mds +27 -27
  109. package/src/assets/mds/git/_ops_steps.mds +3 -3
  110. package/src/assets/mds/git/_pr.mds +6 -6
  111. package/src/assets/mds/tracker/_common.mds +23 -12
  112. package/src/assets/mds/tracker/_github.mds +2 -9
  113. package/src/assets/mds/tracker/_jira.mds +2 -15
  114. package/src/assets/mds/tracker/_linear.mds +2 -15
  115. package/src/assets/scripts/ci-wait.cjs +22 -4
  116. package/src/assets/scripts/claude-md-audit.cjs +66 -51
  117. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +4 -3
  118. package/src/assets/scripts/hooks/background-memory-update +404 -95
  119. package/src/assets/scripts/hooks/capture-prompt +1 -1
  120. package/src/assets/scripts/hooks/capture-question +1 -1
  121. package/src/assets/scripts/hooks/capture-turn +1 -1
  122. package/src/assets/scripts/hooks/json-helper.cjs +13 -2
  123. package/src/assets/scripts/hooks/json-parse +18 -3
  124. package/src/assets/scripts/hooks/lib/learning-store.cjs +1 -1
  125. package/src/assets/scripts/hooks/lib/project-paths.cjs +4 -4
  126. package/src/assets/scripts/hooks/memory-permission +358 -0
  127. package/src/assets/scripts/hooks/preamble +1 -1
  128. package/src/assets/scripts/hooks/session-start-context +60 -47
  129. package/src/assets/scripts/hooks/session-start-memory +26 -5
  130. package/src/assets/scripts/lib/project-config.cjs +19 -4
  131. package/src/assets/scripts/resolve-settings.cjs +200 -32
  132. package/src/assets/scripts/verify-evidence.cjs +726 -9
  133. package/src/assets/skills/agent-references/SKILL.md +14 -6
  134. package/src/assets/skills/agent-references/references/commands/code-review-levels.md +19 -0
  135. package/src/assets/skills/agent-references/references/commands/implement-evidence-asks.md +35 -0
  136. package/src/assets/skills/agent-references/references/commands/implement-revalidate.md +15 -0
  137. package/src/assets/skills/agent-references/references/commands/plan-levels.md +40 -0
  138. package/src/assets/skills/agent-references/references/synthesize/bug-analysis.md +1 -1
  139. package/src/assets/skills/agent-references/references/synthesize/planning.md +9 -22
  140. package/src/assets/skills/agent-references/references/synthesize/review.md +11 -11
  141. package/src/assets/skills/apply-decisions/SKILL.md +6 -4
  142. package/src/assets/skills/docs-framework/SKILL.md +3 -3
  143. package/src/assets/skills/qa/SKILL.md +1 -1
  144. package/src/assets/skills/quality-gates/SKILL.md +7 -7
  145. package/src/assets/skills/quality-gates/references/report-template.md +7 -7
  146. /package/src/assets/skills/agent-references/references/{learning → curate}/maintain.md +0 -0
@@ -5,7 +5,7 @@ output-dir: dist/commands
5
5
  @import { knowledge_load, knowledge_writeback } from "./_partials/_knowledge.mds"
6
6
  @import { decisions_load } from "./_partials/_decisions.mds"
7
7
  @import { docs_root } from "./_partials/_docs_root.mds"
8
- @import { evidence_policy, evidence_exception } from "./_partials/_evidence_policy.mds"
8
+ @import { evidence_policy } from "./_partials/_evidence_policy.mds"
9
9
  @import { issue_ref_grammar, issue_capture_contract } from "./_partials/_tracker.mds"
10
10
  @import { test_plan_line } from "./_partials/_plan_contract.mds"
11
11
  @import { publication_gate } from "./_partials/_publication.mds"
@@ -46,15 +46,7 @@ $ARGUMENTS
46
46
 
47
47
  ### Re-validation Continuation Path
48
48
 
49
- When the user explicitly asks to re-validate, re-check, or re-run quality gates after making their own changes:
50
-
51
- 1. **Branch safety check**: If on a protected branch (main, master, develop, etc.), run Phase 1 to create/switch to a work branch. If already on a work branch, skip Phase 1.
52
- 2. **Skip Phase 2** — no Code agent needed, user already made changes.
53
- 3. **Detect FILES_CHANGED**: `git diff --name-only {base_branch}...HEAD`
54
- 4. **Run Phases 3-8** — Simplify, Self-Review, Alignment, the one full Validate, QA Testing and the conditional Re-Validate, on the detected changes.
55
- 5. **Proceed to Phase 9** (Open PR), **Phase 11** (Evidence) and **Phase 12** (Report).
56
-
57
- If the user prompt does NOT match re-validation, proceed with the full pipeline below.
49
+ When the user explicitly asks to re-validate, re-check, or re-run quality gates after making their own changes, run `d="${CLAUDE_CONFIG_DIR:-}"; case "$d" in /*) ;; *) d="$HOME/.claude" ;; esac; printf '%s\n' "$d"` in Bash, Read `<that directory>/skills/devflow:agent-references/references/commands/implement-revalidate.md` with the Read tool and follow it. Otherwise proceed with the full pipeline below.
58
50
 
59
51
  ### Phase 1: Setup
60
52
 
@@ -64,7 +56,7 @@ If the user prompt does NOT match re-validation, proceed with the full pipeline
64
56
  **Produces:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, PR_DESCRIPTION_GUIDANCE, ISSUE_NUMBER, ISSUE_PR_LINK, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, PR_EXCEPTIONS, TEST_PLAN, EVIDENCE_FILE, PR_TEST_PLAN_BLOCK, REVIEW_PUBLICATION
65
57
  <!-- learning:end -->
66
58
 
67
- Record the current branch name as `BASE_BRANCH` - this will be the PR target.
59
+ Record the current branch name as `BASE_BRANCH`. Stop the run unless it matches `^[A-Za-z0-9._/+@,#-]{1,200}$`, telling the user it allows only ASCII letters, digits and `._/+@,#-`, at most 200.
68
60
 
69
61
  {{docs_root()}}
70
62
 
@@ -122,11 +114,6 @@ The two tests this command does make are its own under every provider:
122
114
  `setup-task` fetches whatever it is handed — so the command would derive a
123
115
  branch from a failed lookup and drop the request on the floor.
124
116
 
125
- The cost of the count gate is a one-word task description (`/implement refactor`)
126
- reaching `setup-task` as an issue reference, where it fails the lookup and is
127
- reported. That is the direction the failure has to fall: an unfetched issue is
128
- visible, a silently discarded request is not.
129
-
130
117
  **Capture from Git agent output** (used throughout flow):
131
118
  - `TASK_ID`: The branch name created by Git agent (use as TASK_ID for rest of flow)
132
119
  - `BASE_BRANCH`: Branch this feature was created from (for PR target)
@@ -135,13 +122,7 @@ visible, a silently discarded request is not.
135
122
 
136
123
  {{issue_capture_contract()}}
137
124
 
138
- **Ticket link, only when `ISSUE_REQUIRED` is `true`:** when the capture above holds no `ISSUE_PR_LINK` (absent, or `(none)`), ask with AskUserQuestion before any Code spawn — "No tracker issue is linked to this task. Record a self-attested exception, or stop?" — offering exactly these two options:
139
- - **Record an exception** — the user gives the reason as free text. Render it with the grammar below, as kind `ticket-link`; when the rendered reason is empty, ask for it once more, and stop as below if it is empty again.
140
- - **Stop** — report `BLOCKED (no ticket link)`, name the branch setup-task created (`TASK_ID`) and `BASE_BRANCH` so it can be reused or removed, and give the remedy: create or link the tracker issue and re-run `/implement` with its reference, or — for a team that does not want ticket links — commit `.devflow/project.json` as `{"version":1,"evidence":"standard"}` on the default branch; a machine with compliance enabled still resolves `required` whatever that file says. Spawn nothing further.
141
-
142
- {{evidence_exception()}}
143
-
144
- **Record the exception at once**, before any Code spawn: write the rendered section as the `## Evidence Exceptions` section of `{worktree}/.devflow/docs/handoff-{branch_slug}.md`, creating the file if absent, and set `PR_EXCEPTIONS` to that section. The file is its one home until the PR exists: every later write to the file keeps the section byte-identical, the Phase 9 Git spawn passes it verbatim as `PR_EXCEPTIONS`, and the file is deleted only once the PR exists — after Phase 9, under every strategy. With no exception recorded, `PR_EXCEPTIONS` is `(none)`.
125
+ **Ticket link, only when `ISSUE_REQUIRED` is `true`:** when the capture above holds no `ISSUE_PR_LINK` (absent, or `(none)`), run `d="${CLAUDE_CONFIG_DIR:-}"; case "$d" in /*) ;; *) d="$HOME/.claude" ;; esac; printf '%s\n' "$d"` in Bash, Read `<that directory>/skills/devflow:agent-references/references/commands/implement-evidence-asks.md` with the Read tool (once per run), then run its ticket link ask and **Record the exception at once** as it directs, before any Code spawn. `PR_EXCEPTIONS` is `(none)` until an exception is recorded.
145
126
 
146
127
  **Test plan.** Before any Code spawn, give the task a test plan in the evidence file `{worktree}/.devflow/docs/evidence-{branch_slug}.md` (`EVIDENCE_FILE`) — unlike the handoff file, it stays after the PR exists. It holds up to three sections, in this order and nothing else: `## Test Plan`; `## Evidence Exceptions`, a byte copy of `PR_EXCEPTIONS` present only while that is not `(none)`; and `## Claims`, always last, so every claim is appended at the end of the file. Create the file if absent; if it exists, replace its `## Test Plan` and `## Evidence Exceptions` sections and keep `## Claims` byte-identical.
147
128
 
@@ -157,9 +138,7 @@ node "$HOME/.devflow/scripts/verify-evidence.cjs" check tp "{worktree}/.devflow/
157
138
 
158
139
  `exit=0` passes. On any other result, rewrite the section once — the script names the failing line and its code on stderr — and check again. Still failing, or no line to write, means the test plan is **missing**: drop the `## Test Plan` section from the file.
159
140
 
160
- **Missing test plan, only when `EVIDENCE_POLICY` is `required`:** when the check above leaves the test plan missing, ask with AskUserQuestion before any Code spawn — "No test plan could be written for this task. Record a self-attested exception, or stop?" — offering exactly these two options:
161
- - **Record an exception** — the user gives the reason as free text. Render it with the exception grammar above, as kind `test-plan`; when the rendered reason is empty, ask for it once more, and stop as below if it is empty again. Add the rendered line to the `## Evidence Exceptions` section of `{worktree}/.devflow/docs/handoff-{branch_slug}.md` — after any `ticket-link` line, creating the section and the file when absent — and set `PR_EXCEPTIONS` to that section, under the same rules as the record above.
162
- - **Stop** — report `BLOCKED (no test plan)`, name `TASK_ID` and `BASE_BRANCH` so the branch can be reused or removed, and give the remedy: state the acceptance criteria in the task, the issue or a `/plan` document (its `## Test Plan` section is copied) and re-run `/implement`, or — for a team that does not want test plans enforced — commit `.devflow/project.json` as `{"version":1,"evidence":"standard"}` on the default branch; a machine with compliance enabled still resolves `required` whatever that file says. Spawn nothing further.
141
+ **Missing test plan, only when `EVIDENCE_POLICY` is `required`:** when the check above leaves the test plan missing, Read the evidence-asks reference as in the ticket link step (when this run has not) and run its missing test plan ask before any Code spawn.
163
142
 
164
143
  When `EVIDENCE_POLICY` is `standard`, a missing test plan is never asked about: carry `Test plan: missing` to the Phase 12 report.
165
144
 
@@ -176,15 +155,15 @@ node "$HOME/.devflow/scripts/verify-evidence.cjs" render --plan "{worktree}/.dev
176
155
  {{settings.settings_resolve()}}
177
156
 
178
157
  {{publication_gate()}}
179
- Phase 11 passes the resolved value to `update-pr-evidence`, which decides what each value means for the evidence comment. From the same line: {{compliance.compliance_frameworks()}}
158
+ Phase 11 passes the resolved value to the evidence script (`publish`), which decides what each value means for the evidence comment. From the same line: {{compliance.compliance_frameworks()}}
180
159
 
181
160
  {{compliance.compliance_inject()}}
182
161
 
183
- Pass `COMPLIANCE_DIRECTIVE` to every Code and Code-fix spawn, on a line of its own.
162
+ Pass `COMPLIANCE_DIRECTIVE` to every Code and Fix spawn, on a line of its own.
184
163
 
185
164
  {{decisions_load()}}
186
165
  <!-- learning:on -->
187
- Pass `DECISIONS_CONTEXT` to Code agent (Phase 2) and Scrutinize agent (Phase 4).
166
+ Pass `DECISIONS_CONTEXT` to Code agent (Phase 2) and Harden agent (Phase 4).
188
167
 
189
168
  <!-- learning:end -->
190
169
  {{knowledge_load()}}
@@ -197,14 +176,14 @@ Pass `DECISIONS_CONTEXT` to Code agent (Phase 2) and Scrutinize agent (Phase 4).
197
176
  Based on Setup context (plan document, issue body, or conversation context), use the three-strategy framework:
198
177
 
199
178
  **Strategy Selection**:
200
- - If plan document provided: use `execution-strategy` from frontmatter (default: SINGLE_CODE_AGENT if absent)
201
- - Otherwise: default to SINGLE_CODE_AGENT unless task description signals high complexity
179
+ - If plan document provided: use `execution-strategy` from frontmatter (if absent, use the table below)
180
+ - Otherwise: SINGLE_CODE_AGENT, because there is no Subtask Breakdown to split
202
181
 
203
- | Strategy | When | Frequency |
204
- |----------|------|-----------|
205
- | **SINGLE_CODE_AGENT** | Default. Coherent A→Z implementation | ~80% |
206
- | **SEQUENTIAL_CODE_AGENTS** | Context overflow risk, layered dependencies | ~15% |
207
- | **PARALLEL_CODE_AGENTS** | True artifact independence (rare) | ~5% |
182
+ | Strategy | When |
183
+ |----------|------|
184
+ | **SINGLE_CODE_AGENT** | Default. Coherent A→Z implementation |
185
+ | **SEQUENTIAL_CODE_AGENTS** | The plan writes >= 10 files or has >= 7 steps |
186
+ | **PARALLEL_CODE_AGENTS** | True artifact independence (rare) |
208
187
 
209
188
  ---
210
189
 
@@ -227,7 +206,7 @@ DECISIONS_CONTEXT: {decisions_context}
227
206
 
228
207
  ---
229
208
 
230
- **SEQUENTIAL_CODE_AGENTS** (for HIGH/CRITICAL context risk):
209
+ **SEQUENTIAL_CODE_AGENTS** (>= 10 files or >= 7 steps):
231
210
 
232
211
  Spawn Code agents one at a time. Each appends its own phase section to the handoff file, and the next reads only the section before it:
233
212
 
@@ -311,33 +290,33 @@ DECISIONS_CONTEXT: {decisions_context}
311
290
  - Different files/modules with no imports between them
312
291
  - Each subtask is self-contained
313
292
 
314
- ### Phase 3: Simplify
293
+ ### Phase 3: Polish
315
294
 
316
- **Produces:** SIMPLIFY_OUTPUT
317
- **Requires:** FILES_CHANGED
295
+ **Produces:** POLISH_OUTPUT
296
+ **Requires:** BASE_BRANCH
318
297
 
319
- After the Code agent completes, spawn Simplify agent to polish the code. The Phase 6 Validate covers its commits.
298
+ After the Code agent completes, spawn Polish agent to polish the code. The Phase 6 Validate covers its commits. `{branch_diff}` is the output of `git diff --name-only --diff-filter=d {BASE_BRANCH}...HEAD`, run again at each spawn.
320
299
 
321
300
  ```
322
- Agent(subagent_type="Simplify"):
323
- "Simplify recently implemented code
301
+ Agent(subagent_type="Polish"):
302
+ "Polish recently implemented code
324
303
  Task: {task description}
325
- FILES_CHANGED: {list of files from Code agent output}
304
+ FILES_CHANGED: {branch_diff}
326
305
  Focus on code modified by Code agent, apply project standards, enhance clarity
327
306
  Commit any improvements with a conventional-commit message."
328
307
  ```
329
308
 
330
309
  ### Phase 4: Self-Review
331
310
 
332
- **Produces:** SCRUTINIZE_OUTPUT
333
- **Requires:** FILES_CHANGED
311
+ **Produces:** HARDEN_OUTPUT
312
+ **Requires:** BASE_BRANCH
334
313
 
335
- After Simplify agent completes, spawn Scrutinize agent as the quality gate:
314
+ After Polish agent completes, spawn Harden agent as the quality gate:
336
315
 
337
316
  ```
338
- Agent(subagent_type="Scrutinize"):
317
+ Agent(subagent_type="Harden"):
339
318
  "TASK_DESCRIPTION: {task description}
340
- FILES_CHANGED: {list of files from Code agent output}
319
+ FILES_CHANGED: {branch_diff}
341
320
  <!-- learning:on -->
342
321
  DECISIONS_CONTEXT: {decisions_context}
343
322
  <!-- learning:end -->
@@ -345,20 +324,20 @@ FEATURE_KNOWLEDGE: {feature_knowledge_rules}
345
324
  Evaluate 9 pillars, fix P0/P1 issues, report status"
346
325
  ```
347
326
 
348
- Scrutinize agent reports `### Status: PASS | FIXED | BLOCKED`. **If BLOCKED:** report to user and halt. **If PASS or FIXED:** continue to Phase 5. A FIXED status commits fixes and starts no Validate of its own: the Phase 6 run covers them.
327
+ Harden agent reports `### Status: PASS | FIXED | BLOCKED`. **If BLOCKED:** report to user and halt. **If PASS or FIXED:** continue to Phase 5. A FIXED status commits fixes and starts no Validate of its own: the Phase 6 run covers them.
349
328
 
350
329
  ### Phase 5: Alignment Check
351
330
 
352
331
  **Produces:** ALIGNMENT_RESULT
353
- **Requires:** FILES_CHANGED, EXECUTION_PLAN
332
+ **Requires:** BASE_BRANCH, EXECUTION_PLAN
354
333
 
355
- After Scrutinize agent passes, spawn Evaluate agent to validate alignment. Evaluate agent receives `FEATURE_KNOWLEDGE_RULES` as acceptance context only; pattern and anti-pattern judgments belong to Scrutinize agent:
334
+ After Harden agent passes, spawn Evaluate agent to validate alignment. Evaluate agent receives `FEATURE_KNOWLEDGE_RULES` as acceptance context only; pattern and anti-pattern judgments belong to Harden agent:
356
335
 
357
336
  ```
358
337
  Agent(subagent_type="Evaluate"):
359
338
  "ORIGINAL_REQUEST: {task description or issue content}
360
339
  EXECUTION_PLAN: {execution plan from Phase 1}
361
- FILES_CHANGED: {list of files from Code agent output}
340
+ FILES_CHANGED: {branch_diff}
362
341
  ACCEPTANCE_CRITERIA: {extracted criteria if available}
363
342
  FEATURE_KNOWLEDGE: {feature_knowledge_rules}
364
343
  Validate alignment with request and plan. Report ALIGNED or MISALIGNED with details."
@@ -370,9 +349,9 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
370
349
  1. Extract misalignment details from Evaluate agent output
371
350
  2. Increment `alignment_fix_count`
372
351
  3. If `alignment_fix_count <= 2`:
373
- - Spawn Code-fix agent to fix misalignments:
352
+ - Spawn Fix agent to fix misalignments:
374
353
  ```
375
- Agent(subagent_type="Code-fix"):
354
+ Agent(subagent_type="Fix"):
376
355
  "OPERATION: alignment-fix
377
356
  TASK_ID: {task-id}
378
357
  TASK_DESCRIPTION: Fix alignment issues
@@ -391,11 +370,11 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
391
370
  **Produces:** VALIDATION_RESULT, VALIDATED_HEAD
392
371
  **Requires:** BASE_BRANCH
393
372
 
394
- Validate takes the one full-suite slot, after every commit it must cover: Code, Simplify, Scrutinize and the alignment fixes. After Evaluate agent passes, spawn Validate agent. `FILES_CHANGED` is the branch diff, because the Code agent's own list misses the Simplify, Scrutinize and fix commits (`{base}` is `BASE_BRANCH`):
373
+ Validate takes the one full-suite slot, after every commit it must cover: Code, Polish, Harden and the alignment fixes. After Evaluate agent passes, spawn Validate agent. `FILES_CHANGED` is the branch diff:
395
374
 
396
375
  ```
397
376
  Agent(subagent_type="Validate"):
398
- "FILES_CHANGED: {output of `git diff --name-only {base}...HEAD`}
377
+ "FILES_CHANGED: {branch_diff}
399
378
  VALIDATION_SCOPE: full
400
379
  Run build, typecheck, lint, test. Report pass/fail with failure details."
401
380
  ```
@@ -404,9 +383,9 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
404
383
  1. Extract failure details from Validate agent output
405
384
  2. Increment `validation_retry_count`
406
385
  3. If `validation_retry_count <= 2`:
407
- - Spawn Code-fix agent with fix context:
386
+ - Spawn Fix agent with fix context:
408
387
  ```
409
- Agent(subagent_type="Code-fix"):
388
+ Agent(subagent_type="Fix"):
410
389
  "OPERATION: validation-fix
411
390
  TASK_ID: {task-id}
412
391
  TASK_DESCRIPTION: Fix validation failures
@@ -436,7 +415,7 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
436
415
  ### Phase 7: QA Testing
437
416
 
438
417
  **Produces:** QA_RESULT
439
- **Requires:** FILES_CHANGED, EXECUTION_PLAN, TEST_PLAN, VALIDATED_HEAD
418
+ **Requires:** BASE_BRANCH, EXECUTION_PLAN, TEST_PLAN, VALIDATED_HEAD
440
419
 
441
420
  After Phase 6 passes, spawn Test agent for scenario-based acceptance testing:
442
421
 
@@ -444,7 +423,7 @@ After Phase 6 passes, spawn Test agent for scenario-based acceptance testing:
444
423
  Agent(subagent_type="Test"):
445
424
  "ORIGINAL_REQUEST: {task description or issue content}
446
425
  EXECUTION_PLAN: {execution plan from Phase 1}
447
- FILES_CHANGED: {list of files from Code agent output}
426
+ FILES_CHANGED: {branch_diff}
448
427
  ACCEPTANCE_CRITERIA: {extracted criteria if available}
449
428
  TEST_PLAN: {the TP lines of the evidence file's ## Test Plan section, or (none)}
450
429
  Design and execute scenario-based acceptance tests. Report PASS or FAIL with evidence."
@@ -458,9 +437,9 @@ After every Test agent run — PASS or FAIL, first run or retry — append its T
458
437
  1. Extract failure details from Test agent output
459
438
  2. Increment `qa_retry_count`
460
439
  3. If `qa_retry_count <= 2`:
461
- - Spawn Code-fix agent to fix QA failures:
440
+ - Spawn Fix agent to fix QA failures:
462
441
  ```
463
- Agent(subagent_type="Code-fix"):
442
+ Agent(subagent_type="Fix"):
464
443
  "OPERATION: qa-fix
465
444
  TASK_ID: {task-id}
466
445
  TASK_DESCRIPTION: Fix QA test failures
@@ -483,7 +462,7 @@ Run this phase only if a qa-fix committed (`git rev-parse HEAD` differs from `VA
483
462
 
484
463
  ```
485
464
  Agent(subagent_type="Validate"):
486
- "FILES_CHANGED: {output of `git diff --name-only VALIDATED_HEAD..HEAD`}
465
+ "FILES_CHANGED: {output of `git diff --name-only --diff-filter=d VALIDATED_HEAD..HEAD`}
487
466
  VALIDATION_SCOPE: changed-only
488
467
  Verify the qa-fix commits did not break anything."
489
468
  ```
@@ -515,7 +494,7 @@ COMMIT_UNCOMMITTED: false
515
494
  Open the pull request for this branch and return the pre-flight summary."
516
495
  ```
517
496
 
518
- `COMMIT_UNCOMMITTED: false` keeps the Git agent from committing a stray file: the Code, Simplify, Scrutinize and fix agents commit their own work. Capture the `- **PR**: #{number}` line of its `### Branch` as `PR_NUMBER`, its `### Uncommitted files` list and its `TRACEABILITY: DEGRADED ({reason})` lines for the Phase 12 report. If it returns `### Status: BLOCKED` or no PR number, report its reason to the user and stop at the report (Phase 12); Phases 10 and 11 do not run.
497
+ `COMMIT_UNCOMMITTED: false` keeps the Git agent from committing a stray file: the Code, Polish, Harden and Fix agents commit their own work. Capture the `- **PR**: #{number}` line of its `### Branch` as `PR_NUMBER`, its `### Uncommitted files` list and its `TRACEABILITY: DEGRADED ({reason})` lines for the Phase 12 report. If it returns `### Status: BLOCKED` or no PR number, report its reason to the user and stop at the report (Phase 12); Phases 10 and 11 do not run.
519
498
 
520
499
  ### Phase 10: CI Status Gate
521
500
 
@@ -524,7 +503,7 @@ Open the pull request for this branch and return the pre-flight summary."
524
503
 
525
504
  Run under every strategy: Phase 9 opened the PR.
526
505
 
527
- **Push first, outside the gate block.** The gate reads CI for the pushed head, and the Simplify, Scrutinize and fix commits reach the PR only by a push. Push once — never force, and no retry:
506
+ **Push first, outside the gate block.** The gate reads CI for the pushed head, and the Polish, Harden and Fix commits reach the PR only by a push. Push once — never force, and no retry:
528
507
 
529
508
  ```bash
530
509
  git push origin HEAD; echo "exit=$?"
@@ -539,9 +518,9 @@ git push origin HEAD; echo "exit=$?"
539
518
  4. **If PENDING** and fewer than 3 waits have run → wait again (step 1). After the third wait → report "CI still running — verify manually before merging" and proceed.
540
519
  5. **If INDETERMINATE** and fewer than 3 waits have run → wait again (step 1). After the third wait → report "CI status unknown — verify manually before merging" and proceed.
541
520
  <!-- learning:on -->
542
- 6. **If FAILING** and fewer than 2 fixes have run → report the failing checks from the line. Spawn `Agent(subagent_type="Code-fix")` whose prompt opens with `OPERATION: ci-fix`, with `COMPLIANCE_DIRECTIVE` (when it is not empty), `CI_FAILURES`, `DECISIONS_CONTEXT` and `PUSH: false`; `CI_FAILURES` holds the failing-check names from the line and nothing else, because the Code-fix agent fetches the full names and reads the logs itself and this command reads none. After a fix, push with the command above and, if a wait remains, wait again (step 1); a failed push records `TRACEABILITY: DEGRADED (ci push failed)`, reports "CI status unknown — verify manually before merging" and stops waiting. After the second fix still FAILING → report the failing checks and proceed.
521
+ 6. **If FAILING** and fewer than 2 fixes have run → report the failing checks from the line. Spawn `Agent(subagent_type="Fix")` whose prompt opens with `OPERATION: ci-fix`, with `COMPLIANCE_DIRECTIVE` (when it is not empty), `CI_FAILURES`, `DECISIONS_CONTEXT` and `PUSH: false`; `CI_FAILURES` holds the failing-check names from the line and nothing else, because the Fix agent fetches the full names and reads the logs itself and this command reads none. After a fix, push with the command above and, if a wait remains, wait again (step 1); a failed push records `TRACEABILITY: DEGRADED (ci push failed)`, reports "CI status unknown — verify manually before merging" and stops waiting. After the second fix still FAILING → report the failing checks and proceed.
543
522
  <!-- learning:off -->
544
- 6. **If FAILING** and fewer than 2 fixes have run → report the failing checks from the line. Spawn `Agent(subagent_type="Code-fix")` whose prompt opens with `OPERATION: ci-fix`, with `COMPLIANCE_DIRECTIVE` (when it is not empty), `CI_FAILURES` and `PUSH: false`; `CI_FAILURES` holds the failing-check names from the line and nothing else, because the Code-fix agent fetches the full names and reads the logs itself and this command reads none. After a fix, push with the command above and, if a wait remains, wait again (step 1); a failed push records `TRACEABILITY: DEGRADED (ci push failed)`, reports "CI status unknown — verify manually before merging" and stops waiting. After the second fix still FAILING → report the failing checks and proceed.
523
+ 6. **If FAILING** and fewer than 2 fixes have run → report the failing checks from the line. Spawn `Agent(subagent_type="Fix")` whose prompt opens with `OPERATION: ci-fix`, with `COMPLIANCE_DIRECTIVE` (when it is not empty), `CI_FAILURES` and `PUSH: false`; `CI_FAILURES` holds the failing-check names from the line and nothing else, because the Fix agent fetches the full names and reads the logs itself and this command reads none. After a fix, push with the command above and, if a wait remains, wait again (step 1); a failed push records `TRACEABILITY: DEGRADED (ci push failed)`, reports "CI status unknown — verify manually before merging" and stops waiting. After the second fix still FAILING → report the failing checks and proceed.
545
524
  <!-- learning:end -->
546
525
  7. **Budget**: at most 3 waits and 2 fixes in all. When one is spent, report the current status and proceed.
547
526
  <!-- /PATTERN: ci-status-gate -->
@@ -553,25 +532,21 @@ git push origin HEAD; echo "exit=$?"
553
532
 
554
533
  Run once, after Phase 10, under every strategy: the PR exists by now, opened in Phase 9. The re-validation path has no CI gate and runs this phase straight after Phase 9. Skip it only when Phase 9 stopped the run. A `ci` TP reads `INDETERMINATE` only when the CI gate could not tell or did not run.
555
534
 
556
- **Push first.** Every claim is keyed to the HEAD an agent reported, and a Scrutinize or fix agent may have committed without pushing; a claim whose SHA is not in the PR reads `UNVERIFIED`. So push the branch once before the spawn — never force, and no retry:
535
+ **Push first.** Every claim is keyed to the HEAD an agent reported, and a Harden or Fix agent may have committed without pushing; a claim whose SHA is not in the PR reads `UNVERIFIED`. So push the branch once before the script — never force, and no retry:
557
536
 
558
537
  ```bash
559
538
  git push origin HEAD; echo "exit=$?"
560
539
  ```
561
540
 
562
- `exit=0` continues to the spawn. Any other result, a rejected non-fast-forward push included, does not block: record `TRACEABILITY: DEGRADED (evidence push failed)` for the Phase 12 report and spawn anyway.
541
+ `exit=0` continues to the script. Any other result, a rejected non-fast-forward push included, does not block: record `TRACEABILITY: DEGRADED (evidence push failed)` for the Phase 12 report and run the script anyway.
563
542
 
564
- ```
565
- Agent(subagent_type="Git"):
566
- "OPERATION: update-pr-evidence
567
- PR_NUMBER: {PR_NUMBER}
568
- EVIDENCE_FILE: .devflow/docs/evidence-{branch_slug}.md
569
- REVIEW_PUBLICATION: {REVIEW_PUBLICATION resolved in Phase 1, or auto}
570
- WORKTREE_PATH: {worktree}
571
- Update the PR's test-plan block and post its evidence comment."
543
+ **Then refresh, inline.** The refresh is plumbing, so no Git agent runs it: `verify-evidence.cjs publish` is the whole `update-pr-evidence` operation — verify, the scrubbed block edit with its read-back, the scrubbed evidence comment — in one call. Use the Bash tool with `timeout: 180000`:
544
+
545
+ ```bash
546
+ cd "{worktree}" && node "$HOME/.devflow/scripts/verify-evidence.cjs" publish --pr {PR_NUMBER} --evidence ".devflow/docs/evidence-{branch_slug}.md" --publication {REVIEW_PUBLICATION resolved in Phase 1, or auto}; echo "exit=$?"
572
547
  ```
573
548
 
574
- Omit the `EVIDENCE_FILE` line when that file does not exist. Capture the op's `## PR Evidence` block — its `EVIDENCE` line and its `**Body**:` / `**Comment**:` line — as `EVIDENCE_RESULT`, or its `TRACEABILITY: DEGRADED ({reason})` line. It never blocks: whatever it returns, continue to Phase 12.
549
+ Drop the `--evidence` pair when that file does not exist or its path does not match `^[A-Za-z0-9._/-]{1,255}$`. `{PR_NUMBER}` is digits only, and the publication value is `auto`, `full`, `off` or `stub`. Capture its stdout as `EVIDENCE_RESULT`: the `## PR Evidence` block — its `EVIDENCE` line and its `**Body**:` / `**Comment**:` line — and any `TRACEABILITY: DEGRADED ({reason})` lines after it (exit 0), or the one line `TRACEABILITY: DEGRADED (evidence unavailable)` (exit 2). Empty stdout or any other exit is `TRACEABILITY: DEGRADED (evidence unavailable)`. It never blocks: whatever it returns, continue to Phase 12.
575
550
 
576
551
  ### Phase 12: Report
577
552
 
@@ -581,7 +556,7 @@ Display completion summary with phase status, PR info, and next steps.
581
556
 
582
557
  Show the test plan's evidence from Phase 11: `Test plan: {VERIFIED-CI + ATTESTED-LOCAL}/{total} verified (VERIFIED-CI {n}, ATTESTED-LOCAL {n})`, read from the `EVIDENCE` line and never inferred, then its `**Body**:` / `**Comment**:` line verbatim. Without an `EVIDENCE` line, show `Test plan: evidence unavailable`; with no test plan, `Test plan: missing`.
583
558
 
584
- If any Git agent output emitted `TRACEABILITY: DEGRADED ({reason})` lines during the run, or Phase 10's push or Phase 11's push recorded one, surface them verbatim in the report under a `### Traceability` subsection so the user can act on them.
559
+ If any Git agent output emitted `TRACEABILITY: DEGRADED ({reason})` lines during the run, or Phase 10's push, Phase 11's push or Phase 11's script output carried one, surface them verbatim in the report under a `### Traceability` subsection so the user can act on them.
585
560
 
586
561
  If Phase 9 listed uncommitted files, show them as a `### Uncommitted files` subsection: the user commits them or discards them.
587
562
 
@@ -595,71 +570,34 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
595
570
  /implement (orchestrator - spawns agents only)
596
571
  │
597
572
  ├─ Re-validation Path (when user says "re-validate"/"re-check"/"re-run gates")
598
- │ └─ Branch safety → skip Phase 2 → detect FILES_CHANGED → Phases 3-8 → Phase 9, 11, 12
573
+ │ └─ Branch safety → skip Phase 2 → record BASE_BRANCH → Phases 3-8 → Phase 9, 11, 12
599
574
  │
600
575
  ├─ Phase 1: Setup
601
- │ └─ Plan document parsing (if .md path provided) - extracts execution plan, strategy, frontmatter issue
602
- │ └─ Git agent (operation: setup-task) - creates feature branch, fetches issue
603
- │ └─ Ticket-link ask (no linked ticket, issue required) - record a self-attested exception or stop
604
- │ └─ Test plan (evidence file) - copy or author TP lines, check them, render the PR block; missing under a required policy: record a test-plan exception or stop
605
- │
606
576
  ├─ Phase 2: Implement (3-strategy framework)
607
- │ ├─ SINGLE_CODE_AGENT (80%): One Code agent, full plan
608
- │ ├─ SEQUENTIAL_CODE_AGENTS (15%): N Code agents with handoff summaries
609
- │ └─ PARALLEL_CODE_AGENTS (5%): N Code agents in single message (rare)
610
- │
611
- ├─ Phase 3: Simplify
612
- │ └─ Simplify agent (refines code clarity and consistency)
613
- │
577
+ ├─ Phase 3: Polish
614
578
  ├─ Phase 4: Self-Review
615
- │ └─ Scrutinize agent (quality gate, fixes P0/P1; status PASS | FIXED | BLOCKED)
616
- │
617
579
  ├─ Phase 5: Alignment Check
618
- │ └─ Evaluate agent (validates alignment - reports only, no fixes)
619
- │ └─ If MISALIGNED: Code-fix agent loop (max 2 iterations) → re-check alignment
620
- │
621
580
  ├─ Phase 6: Validate (the one full-suite slot)
622
- │ └─ Validate agent (build, typecheck, lint, test over the branch diff)
623
- │ └─ If FAIL: Code-fix agent loop (max 2 retries) → re-validate at the new HEAD
624
- │ └─ If PASS: record VALIDATED_HEAD, gate:validate claim → evidence file
625
- │
626
581
  ├─ Phase 7: QA Testing
627
- │ └─ Test agent (scenario-based acceptance tests, TEST_PLAN) → one claim per TP row → evidence file
628
- │ └─ If FAIL: Code-fix agent loop (max 2 retries) → re-test
629
- │
630
582
  ├─ Phase 8: Re-Validate (only if a qa-fix committed)
631
- │ └─ Validate agent (changed-only over VALIDATED_HEAD..HEAD) → gate:validate claim
632
- │
633
583
  ├─ Phase 9: Open PR (every strategy, outside the strategy branches)
634
- │ └─ Git agent (operation: ensure-pr-ready) - commits nothing (COMMIT_UNCOMMITTED: false), pushes, opens the PR with the pasted link line, exceptions and test-plan block, D11-scrubbed body
635
- │
636
584
  ├─ Phase 10: CI Status Gate (every strategy)
637
- │ └─ Push the branch, then ci-wait.cjs (inline, one wait ≤ 570 s) → Code-fix agent on FAILING (3 waits + 2 fixes)
638
- │
639
585
  ├─ Phase 11: Evidence (every strategy, once the PR exists)
640
- │ └─ Push the branch (never force; a failure is DEGRADED, not a stop)
641
- │ └─ Git agent (update-pr-evidence) - test-plan block + evidence comment; never blocks
642
- │
643
586
  ├─ Phase 12: Report
644
587
  │
645
588
  └─ Feature Knowledge Write-Back (Conditional)
646
- └─ Knowledge agent (if documented area changed AND knowledge enabled)
647
589
  ```
648
590
 
649
591
  ## Principles
650
592
 
651
- 1. **Orchestration only** - Command spawns agents, never does work itself; the inline calls are the bounded plumbing the charter allows: the Phase 10 and Phase 11 pushes, the Phase 10 ci-wait call and the evidence script checks
652
- 2. **Plan-first** - Plan documents from `/plan` skip exploration/planning overhead entirely
653
- 3. **Coherence-first** - Single Code agent produces more consistent code (default ~80% of tasks)
654
- 4. **Agent ownership** - Each agent owns its output completely
655
- 5. **Clean handoffs** - Each phase passes structured data to next; sequential Code agents pass implementation summaries
656
- 6. **Honest reporting** - Display agent outputs directly
657
- 7. **Simplification pass** - Code refined for clarity before PR
658
- 8. **Strict delegation** - Never perform agent work in main session. "Spawn X" means call Agent tool with X, not do X's work yourself
659
- 9. **Validate agent owns validation** - Never run `npm test`, `npm run build`, or similar in main session; always delegate to Validate agent
660
- 10. **Code-fix agent owns fixes** - Never implement fixes in main session; spawn Code-fix agent for validation failures and alignment fixes
661
- 11. **Loop limits** - Max 2 validation retries, max 2 alignment fix iterations, max 2 QA retries before escalating to user; the CI gate allows at most 3 waits and 2 fixes
662
- 12. **CI awareness** - CI status is checked before merge under every strategy, once Phase 9 has opened the PR; test-plan evidence (Phase 11) is recorded under every strategy once the PR exists
593
+ 1. **Orchestration only** - Command spawns agents, never does work itself; the inline calls are the bounded plumbing the charter allows: the Phase 10 and Phase 11 pushes, the Phase 10 ci-wait call, the Phase 11 evidence publish call and the evidence script checks
594
+ 2. **Agent ownership** - Each agent owns its output completely
595
+ 3. **Honest reporting** - Display agent outputs directly
596
+ 4. **Strict delegation** - Never perform agent work in main session. "Spawn X" means call Agent tool with X, not do X's work yourself
597
+ 5. **Validate agent owns validation** - Never run `npm test`, `npm run build`, or similar in main session; always delegate to Validate agent
598
+ 6. **Fix agent owns fixes** - Never implement fixes in main session; spawn Fix agent for validation failures and alignment fixes
599
+ 7. **Loop limits** - Max 2 validation retries, max 2 alignment fix iterations, max 2 QA retries before escalating to user; the CI gate allows at most 3 waits and 2 fixes
600
+ 8. **CI awareness** - CI status is checked before merge under every strategy, once Phase 9 has opened the PR; test-plan evidence (Phase 11) is recorded under every strategy once the PR exists
663
601
 
664
602
  ## Error Handling
665
603