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
@@ -28,12 +28,12 @@ Run a comprehensive code review of the current branch by spawning parallel revie
28
28
  - **Exactly one listed:** load neither the skill nor the reference — that worktree is the only candidate, and Step 0c's Git agent validates its branch
29
29
  2. **If `--path` flag provided:** use only that worktree, skip discovery
30
30
  **`--path` validation**: Before proceeding, verify the path exists as a directory and appears in `git worktree list` output. If not: report error and stop.
31
- 3. **If only 1 reviewable worktree** (the common case): proceed as single-worktree flow — zero behavior change
31
+ 3. **If only 1 reviewable worktree**: proceed as single-worktree flow — zero behavior change
32
32
  4. **If multiple reviewable worktrees:** report "Found N worktrees with reviewable branches: {list with paths and branches}" and proceed with multi-worktree flow
33
33
 
34
- #### Step 0b: Resolve the compliance lens
34
+ #### Step 0b: Resolve the compliance lens and gate level
35
35
 
36
- **Produces:** COMPLIANCE_ACTIVE, COMPLIANCE_FRAMEWORKS
36
+ **Produces:** COMPLIANCE_ACTIVE, COMPLIANCE_FRAMEWORKS, GATE_LEVEL
37
37
 
38
38
  **Resolve the settings line** once per worktree root, reusing a line this run already resolved for the same root. `{root}` is the worktree the values are for — the repository root when the run has one worktree:
39
39
 
@@ -41,16 +41,16 @@ Run a comprehensive code review of the current branch by spawning parallel revie
41
41
  node "$HOME/.devflow/scripts/resolve-settings.cjs" "{root}" 2>/dev/null; echo "exit=$?"
42
42
  ```
43
43
 
44
- Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `TRACKER=<github|jira|linear> TRACKER_SOURCE=<project|personal|machine|default> TRACKER_WARN=<none|mismatch|invalid> SITE=<none|https://<host>> KEY=<none|<key>> REVIEW_PUBLICATION=<off|auto|full> COMPLIANCE=<off|generic|<id>[,<id>…]> MEMORY=<on|off> LEARNING=<on|off> KNOWLEDGE=<on|off>` — these fields, in this order, nothing else, where `<host>` is a lowercase dotted host name alone, `<key>` is 2–10 of `A-Z`, `0-9` and `_` starting with a letter, and each `<id>` is one of `gdpr`, `hipaa`, `pci-dss`, `soc2`, `iso-27001`, `sox`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `TRACKER=github TRACKER_SOURCE=default TRACKER_WARN=invalid SITE=none KEY=none REVIEW_PUBLICATION=off COMPLIANCE=generic MEMORY=on LEARNING=on KNOWLEDGE=off` instead.
44
+ Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `TRACKER=<github|jira|linear> TRACKER_SOURCE=<project|personal|machine|default> TRACKER_WARN=<none|mismatch|invalid> SITE=<none|https://<host>> KEY=<none|<key>> REVIEW_PUBLICATION=<off|auto|full> COMPLIANCE=<off|generic|<id>[,<id>…]> MEMORY=<on|off> LEARNING=<on|off> KNOWLEDGE=<on|off> GATE_LEVEL=<full|standard|lean>` — these fields, in this order, nothing else, where `<host>` is a lowercase dotted host name alone, `<key>` is 2–10 of `A-Z`, `0-9` and `_` starting with a letter, and each `<id>` is one of `gdpr`, `hipaa`, `pci-dss`, `soc2`, `iso-27001`, `sox`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `TRACKER=github TRACKER_SOURCE=default TRACKER_WARN=invalid SITE=none KEY=none REVIEW_PUBLICATION=off COMPLIANCE=generic MEMORY=on LEARNING=on KNOWLEDGE=off GATE_LEVEL=full` instead.
45
45
 
46
- The accepted line is the only source of these values: the script alone folds the committed `.devflow/project.json`, the personal `.devflow/config.json` and the machine manifest.
46
+ The accepted line is the only source of these values.
47
47
 
48
48
  **Resolve the compliance lens** for each worktree root, from its settings line — the line resolved above for that root, by the settings block when this run has not yet resolved it (every framework reference is installed on every machine, so no file check decides it).
49
49
 
50
50
  **Set the compliance lens** from that line: `COMPLIANCE_FRAMEWORKS` is the settings line's `COMPLIANCE` with `generic` written `none`: `off`, `none`, or the framework ids the machine and this repository declare.
51
51
 
52
52
  `COMPLIANCE_ACTIVE` is `true` unless `COMPLIANCE_FRAMEWORKS` is `off`.
53
- Keep each worktree's values for every downstream phase of that worktree.
53
+ Keep each worktree's values for every downstream phase.
54
54
 
55
55
  #### Step 0b-ii: Resolve the evidence policy
56
56
 
@@ -100,7 +100,7 @@ Validate branch, commit if needed, push, create PR if needed.
100
100
  Return: branch, base_branch, branch-slug, PR#"
101
101
  ```
102
102
 
103
- In multi-worktree mode, spawn all pre-flight agents **in a single message** (parallel).
103
+ In multi-worktree mode, spawn all pre-flight agents **in a single message**.
104
104
 
105
105
  **If BLOCKED:** In single-worktree mode, stop and report. In multi-worktree mode, report the failure but continue with other worktrees.
106
106
 
@@ -140,7 +140,7 @@ For each worktree, perform a single pass over timestamped directories:
140
140
  2. Iterate once: accumulate CYCLE_NUMBER count for each directory containing `resolution-summary.md`; capture the first (most-recent) such directory as PRIOR_DIR.
141
141
  3. If CYCLE_NUMBER = 0: set PRIOR_RESOLUTIONS=(none), CYCLE_NUMBER=1, proceed.
142
142
  4. Otherwise: set CYCLE_NUMBER = count + 1. Read `{PRIOR_DIR}/resolution-summary.md` as PRIOR_RESOLUTIONS.
143
- 5. If `--full`: still load PRIOR_RESOLUTIONS (valuable for Review agent cross-cycle awareness).
143
+ 5. If `--full`: still load PRIOR_RESOLUTIONS.
144
144
 
145
145
  #### Step 0e-ii: Convergence Assessment
146
146
 
@@ -186,7 +186,7 @@ Note: `auto` is NOT fail-open — under `auto`, the Git agent probes the reposit
186
186
  ### Phase 1: Analyze Changed Files
187
187
 
188
188
  **Produces:** REVIEW_FOCUS_LIST, DIFF_CLASS, DIFF_FILES
189
- **Requires:** DIFF_RANGE, REVIEW_DIR, COMPLIANCE_ACTIVE (from Step 0b)
189
+ **Requires:** DIFF_RANGE, REVIEW_DIR, COMPLIANCE_ACTIVE, GATE_LEVEL (from Step 0b)
190
190
 
191
191
  Per worktree, in order. Each `git` command here writes to a file and prints nothing.
192
192
 
@@ -202,7 +202,7 @@ git -C "{WORKTREE_PATH}" diff --name-only --no-renames {DIFF_RANGE} > "{REVIEW_D
202
202
  wc -l < "{REVIEW_DIR}/paths.txt"
203
203
  ```
204
204
 
205
- Read `paths.txt` once when the count is about 40 or fewer, and in ranges of about 40 lines (Read with offset and limit) when it is more. `--no-renames` lists a moved file under its old path and its new one, so a move cannot take a file out of its own class.
205
+ Read `paths.txt` once when the count is about 40 or fewer, and in ranges of about 40 lines (Read with offset and limit) when it is more.
206
206
 
207
207
  Set `DIFF_CLASS` by these rules, in order; the first that decides wins:
208
208
 
@@ -219,7 +219,7 @@ Each reduced class runs only its focus set, every member reading `diff.patch`:
219
219
  - `tests-only`: testing, reliability, consistency, security
220
220
  - `lockfile-only`: dependencies, security
221
221
 
222
- A mixed non-code diff runs the union of the sets of the classes it holds. Language and conditional triggers inside a reduced class are suppressed: they add no focus, and Step 1.2 applies to the `code` class only.
222
+ A mixed non-code diff runs the union of the sets of the classes it holds. Language and conditional triggers inside a reduced class are suppressed.
223
223
 
224
224
  #### Step 1.2: Choose the focuses
225
225
 
@@ -243,13 +243,27 @@ When `DIFF_CLASS` is `code`, read the file types from the paths in `paths.txt` t
243
243
  | Docs or significant code | documentation |
244
244
  | COMPLIANCE_ACTIVE AND diff touches regulated surface | compliance |
245
245
 
246
- If `COMPLIANCE_ACTIVE` AND the diff touches regulated surface (data models, auth flows, logging/observability, payments, IaC, retention): add `compliance` to REVIEW_FOCUS_LIST for this worktree.
246
+ If `COMPLIANCE_ACTIVE` AND the diff touches regulated surface (data models, auth flows, logging/observability, payments, IaC, retention): on a `code` diff, add `compliance`.
247
247
 
248
248
  **Language focus stamp.** The eight language focuses — `typescript`, `react`, `accessibility`, `ui-design`, `go`, `java`, `python`, `rust` — ship with optional plugins, and the installer stamps the ones installed on this machine onto this line, rewriting it on every install and on `uninstall --plugin`:
249
249
 
250
250
  Installed language focuses: (none)
251
251
 
252
- A language focus is spawned only when its file-type condition above fires AND its name appears in that stamped line. A focus missing from the line is never spawned, even when its trigger fires. The eight core focuses are unconditional and are never stamp-gated.
252
+ A language focus is spawned only when its file-type condition above fires AND its name appears in that stamped line. A focus missing from the line is never spawned, even when its trigger fires. On a `code` diff, REVIEW_FOCUS_LIST starts with the eight core focuses. Step 1.2b may narrow them; they are never stamp-gated.
253
+
254
+ #### Step 1.2b: Narrow by gate level
255
+
256
+ **Produces:** REVIEW_FOCUS_LIST, GATE_LEVEL
257
+ **Requires:** REVIEW_FOCUS_LIST, DIFF_CLASS, CHANGED_PATHS, GATE_LEVEL
258
+
259
+ **Gate level.** Narrow REVIEW_FOCUS_LIST, for every class, by this worktree's `GATE_LEVEL`. `full` keeps it and reads nothing.
260
+
261
+ At `standard` or `lean`, once per run, run `d="${CLAUDE_CONFIG_DIR:-}"; case "$d" in /*) ;; *) d="$HOME/.claude" ;; esac; printf '%s\n' "$d"` in Bash and Read `<that directory>/skills/devflow:agent-references/references/commands/code-review-levels.md` with the Read tool.
262
+
263
+ - Apply each class's row to that class's own set, then take the union of the results. A row only removes focuses.
264
+ - If the Read fails, or a row is missing or malformed, set `GATE_LEVEL` to `full` for every worktree of this run and say `level reference unreadable: full sets applied`.
265
+ - Security runs at every level and in every class.
266
+ - Compliance keeps the trigger above at every level.
253
267
 
254
268
  #### Step 1.3: Write the diff files
255
269
 
@@ -306,7 +320,7 @@ If `index.md` exists and contains at least one entry line, use it for relevance
306
320
 
307
321
  **Step 2 — Fallback: glob frontmatter (if `index.md` is absent or empty):**
308
322
 
309
- Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters). The frontmatter fields `name`, `description`, and `directories` are the authoritative relevance surface — `index.md` is only a cache.
323
+ Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters).
310
324
 
311
325
  **Step 3 — Pick relevant KBs:**
312
326
 
@@ -337,7 +351,7 @@ Headings: L5 Rules · L40 Overview · L62 Anti-Patterns · L118 Key Files
337
351
 
338
352
  A KB with no Rules section labels its entries `Rules ({section name}):` and gives them no ID. `FEATURE_KNOWLEDGE` is these blocks; `FEATURE_KNOWLEDGE_RULES` is the same blocks without the `Headings:` line. Both come from this one selection, and each spawn names the variable its recipient takes. If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set both to `(none)`.
339
353
 
340
- **One git call, then direct reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), plus one heading listing and one Rules read per selected KB, bounded by KB count.
354
+ **One git call, then direct reads — no `.cjs` script.**
341
355
 
342
356
  Pass `FEATURE_KNOWLEDGE` to all Review agents.
343
357
 
@@ -346,9 +360,9 @@ Pass `FEATURE_KNOWLEDGE` to all Review agents.
346
360
  **Produces:** REVIEW_FOCUS_OUTPUTS
347
361
  **Requires:** DIFF_RANGE, REVIEW_DIR, TIMESTAMP, FEATURE_KNOWLEDGE, PR_DESCRIPTION, PRIOR_RESOLUTIONS, REVIEW_FOCUS_LIST, DIFF_CLASS, DIFF_FILES
348
362
 
349
- Spawn Review agents **in a single message**, for the focus set `DIFF_CLASS` selects (max 20 per worktree):
363
+ Spawn Review agents **in a single message**, one per focus in REVIEW_FOCUS_LIST (max 20 per worktree):
350
364
 
351
- - `code`: the 8 core reviews on the full `diff.patch`, plus the language and conditional focuses Phase 1 added.
365
+ - `code`: the 8 core reviews on the full `diff.patch` (lean keeps 3), plus the language and conditional focuses Phase 1 added.
352
366
  - `docs-only`, `tests-only`, `lockfile-only`: only the reduced set Phase 1 names, each reading `diff.patch`; a mixed non-code diff runs the union. No language or conditional focus is spawned, whatever its trigger.
353
367
 
354
368
  | Focus | Runs | Pattern Skill | DIFF_FILE |
@@ -374,7 +388,7 @@ Spawn Review agents **in a single message**, for the focus set `DIFF_CLASS` sele
374
388
  | documentation | conditional | devflow:documentation | diff.patch |
375
389
  | compliance | diff-driven | devflow:compliance | diff.patch |
376
390
 
377
- Review agent count: `code` runs 8 core, +1-12 added by Phase 1 (max 20 total per worktree); a reduced class or a mix runs 2-6.
391
+ Review agent count: at `full`, `code` runs 8 core +1-12; `standard` runs up to 2 fewer; lean `code` runs 3-4; a reduced class or a mix runs 2-6.
378
392
 
379
393
  **Set the compliance focus directive** from `COMPLIANCE_FRAMEWORKS`. `COMPLIANCE_FOCUS_DIRECTIVE` is this one line, with `<ids>` replaced by the value of `COMPLIANCE_FRAMEWORKS`; only the compliance focus's spawn carries it:
380
394
 
@@ -398,16 +412,16 @@ Follow devflow:apply-feature-knowledge for FEATURE_KNOWLEDGE — feature-specifi
398
412
  IMPORTANT: Write report to {worktree_path}/.devflow/docs/reviews/{branch-slug}/{timestamp}/{focus}.md using Write tool"
399
413
  ```
400
414
 
401
- In multi-worktree mode, process worktrees **sequentially** (one worktree at a time). Complete Phases 1-4 for each worktree before starting the next. This prevents agent overload — spawning 8-20 Review agents per worktree across multiple worktrees simultaneously overwhelms the system.
415
+ In multi-worktree mode, process worktrees **sequentially**: complete Phases 1-4 for one worktree before starting the next, so Review spawns never pile up.
402
416
 
403
417
  ### Phase 3: Synthesis → Review Comment (Sequential)
404
418
 
405
419
  **Produces:** REVIEW_SUMMARY, PR_COMMENT
406
- **Requires:** REVIEW_FOCUS_OUTPUTS, REVIEW_DIR, PR_INFO
420
+ **Requires:** REVIEW_FOCUS_OUTPUTS, REVIEW_DIR, PR_INFO, GATE_LEVEL, REVIEW_FOCUS_LIST
407
421
 
408
422
  **WAIT** for Phase 2. For each worktree, run steps 3a and 3b in sequence:
409
423
 
410
- **Step 3a — Synthesize agent** per worktree (wait for completion before 3b):
424
+ **Step 3a — Synthesize agent** per worktree:
411
425
  ```
412
426
  Agent(subagent_type="Synthesize", run_in_background=false):
413
427
  "Mode: review
@@ -415,6 +429,8 @@ WORKTREE_PATH: {worktree_path} (omit if cwd)
415
429
  REVIEW_BASE_DIR: {worktree_path}/.devflow/docs/reviews/{branch-slug}/{timestamp}
416
430
  TIMESTAMP: {timestamp}
417
431
  CYCLE_NUMBER: {cycle_number}
432
+ GATE_LEVEL: {GATE_LEVEL}
433
+ FOCUSES: {REVIEW_FOCUS_LIST}
418
434
  PRIOR_RESOLUTIONS: <prior-resolution-summary>{prior_resolutions}</prior-resolution-summary>
419
435
  Include Convergence Status section in review-summary.md.
420
436
  Aggregate findings, determine merge recommendation.
@@ -447,8 +463,6 @@ Per worktree, after successful completion:
447
463
  - Publication status: FULL (private repo) | FULL (config override) | STUB (public repository) | OFF (publication disabled by config) | STUB (visibility undeterminable) | STUB (evidence policy) (from Git agent)
448
464
  - Artifact paths
449
465
 
450
- In multi-worktree mode, report results per worktree.
451
-
452
466
  ## Architecture
453
467
 
454
468
  ```
@@ -456,29 +470,27 @@ In multi-worktree mode, report results per worktree.
456
470
  │
457
471
  ├─ Phase 0: Worktree Discovery & Pre-flight
458
472
  │ ├─ Step 0a: git worktree list → filter reviewable
459
- │ ├─ Step 0b: Resolve the compliance lens
473
+ │ ├─ Step 0b: Resolve the compliance lens and gate level
460
474
  │ ├─ Step 0c: Git agent (ensure-pr-ready) per worktree [parallel]
461
475
  │ ├─ Step 0d: Incremental detection + timestamp setup per worktree
462
476
  │ ├─ Step 0e-i: Load prior resolution-summary.md
463
- │ ├─ Step 0e-ii: Convergence assessment (warn if FP ratio > 70%)
477
+ │ ├─ Step 0e-ii: Convergence assessment (warn only)
464
478
  │ └─ Step 0f: Resolve REVIEW_PUBLICATION per worktree (publication gate)
465
479
  │
466
480
  ├─ Per worktree (SEQUENTIAL — one worktree at a time):
467
481
  │ │
468
482
  │ ├─ Phase 1: Analyze changed files
469
483
  │ │ ├─ Classify the diff (paths.txt → DIFF_CLASS)
470
- │ │ ├─ Choose the focuses (code class: file types + the language stamp)
484
+ │ │ ├─ Choose the focuses (code: file types + the language stamp; all: the gate level)
471
485
  │ │ └─ Write diff.patch and diff-{focus}.patch, by redirect
472
486
  │ │
473
- │ ├─ Phase 2: Reviews (PARALLEL within worktree)
474
- │ │ ├─ code: Review agents security, architecture, performance, complexity,
475
- │ │ │ consistency, regression, testing, reliability (diff.patch)
476
- │ │ ├─ code: + language (diff-{focus}.patch) and conditional Review agents
487
+ │ ├─ Phase 2: Reviews (PARALLEL within worktree), one per REVIEW_FOCUS_LIST focus
488
+ │ │ ├─ code: core (diff.patch), language (diff-{focus}.patch), conditional
477
489
  │ │ └─ docs-only / tests-only / lockfile-only: the reduced set (diff.patch)
478
490
  │ │
479
491
  │ ├─ Phase 3: Synthesis → Review Comment (SEQUENTIAL within worktree)
480
492
  │ │ ├─ Step 3a: Synthesize agent (mode: review, writes review-summary.md)
481
- │ │ └─ Step 3b: Git agent (post-review-summary, D7 marker-dedup, REVIEW_PUBLICATION)
493
+ │ │ └─ Step 3b: Git agent (post-review-summary)
482
494
  │ │
483
495
  │ └─ Phase 4: Write .last-review-head + display results
484
496
  ```
@@ -487,44 +499,27 @@ In multi-worktree mode, report results per worktree.
487
499
 
488
500
  | Case | Handling |
489
501
  |------|----------|
490
- | No new commits since last review | Skip review, report: "No new commits since last review. Use --full for a full re-review." |
491
- | Rebase invalidates `.last-review-head` SHA | `git cat-file -t` check fails → fallback to full diff |
492
- | Same-minute review collision | `mkdir` fails → retry with seconds appended (`YYYY-MM-DD_HHMMSS`) |
493
- | Worktree in detached HEAD | Filtered out (no branch name → not reviewable) |
494
- | Worktree mid-rebase or mid-merge | Filtered out by status check |
495
- | Two worktrees on same branch | Deduplicate by branch — review once, use first worktree's path |
496
- | Worktree on protected branch | Filtered out (not reviewable) |
497
- | Worktree pre-flight fails | Report failure, continue with other worktrees |
498
- | `--full` in multi-worktree mode | Applies to all worktrees (global modifier) |
499
- | Many worktrees (5+) | Report count and proceed — user manages their worktree count |
502
+ | `--full` in multi-worktree mode | Applies to all worktrees (global modifier). It sets the diff range, never the gate level |
500
503
  | Review comment already posted | Git agent matches its own marker on the `{cycle, timestamp}` pair → skip silently (D7); a re-review in the same cycle (different timestamp) posts its own comment. The marker's format belongs to the operation; this caller passes the pair and never restates the literal |
501
- | First review (no prior resolution) | PRIOR_RESOLUTIONS=(none), no convergence check |
502
- | fp_ratio denominator = 0 | fp_ratio = 0, no warning |
503
- | `--full` flag | Bypass incremental detection (Step 0d), still load PRIOR_RESOLUTIONS for cross-cycle awareness |
504
- | Parsing failure on resolution-summary.md | fp_ratio = 0, convergence tracking degraded (see Step 0e-ii) |
505
- | Concurrent sessions | Advisory only, each session computes independently |
506
- | Docs-only diff | `docs-only`: documentation, consistency, security on `diff.patch`; no language or conditional focus |
507
- | Tests-only diff | `tests-only`: testing, reliability, consistency, security on `diff.patch`; no language or conditional focus |
508
- | Lockfile-only diff | `lockfile-only`: dependencies, security on `diff.patch` |
509
- | Mixed non-code diff (docs with tests, tests with a lockfile) | The union of the matching sets, on `diff.patch` |
510
- | A path matching no class pattern, or an empty path list | `code` (fail-safe): the 8 core focuses on the full diff |
511
- | A file moved across classes | `--no-renames` lists the old and the new path, so a code path makes the diff `code` |
512
- | Path listing above about 40 lines | The count is printed; `paths.txt` is read in ranges of about 40 lines |
504
+ | Docs-only diff | Its Step 1.1 set, narrowed by level |
505
+ | Tests-only diff | Its Step 1.1 set, narrowed by level |
506
+ | Lockfile-only diff | Its Step 1.1 set, narrowed by level |
507
+ | Mixed non-code diff | The union of the matching sets |
508
+ | A path matching no class pattern, or an empty path list | `code` (fail-safe) |
509
+ | A file moved across classes | `--no-renames` lists both paths, so a code path makes the diff `code` |
510
+ | Path listing above about 40 lines | Read in ranges (Step 1.1) |
513
511
  | Language files changed, plugin not installed | The focus is absent from the stamped line: not spawned |
514
512
  | Public repo (`auto` mode) | Git agent probes visibility, posts counts-only STUB comment; full report stays local |
515
513
  | `reviewPublication: off` | Git agent skips posting the review comment (OFF) — except that, only when `EVIDENCE_POLICY` is `required`, Step 0f passes `stub` and a counts-only STUB comment posts |
516
514
 
517
515
  ## Backwards Compatibility
518
516
 
519
- - **Single worktree**: Auto-discovery finds only one worktree → proceeds exactly as before. Zero behavior change.
520
- - **Legacy flat layout**: If `{worktree}/.devflow/docs/reviews/{branch-slug}/` contains flat `*.md` files (no timestamped subdirectories), new runs create timestamped subdirectories. Old flat files remain untouched.
517
+ - **Gate level**: `full` runs the sets named here; the default `standard` and `lean` narrow them. `devflow gates --set full` keeps them.
521
518
 
522
519
  ## Principles
523
520
 
524
521
  1. **Orchestration only** - Command spawns agents, doesn't do git/review work itself. The exceptions are the read-only Phase 0 probes (`git worktree list`, `git -C ... branch --show-current`, `git -C ... cat-file -t`), the bounded Phase 1 path listing (a redirect into `paths.txt`, a `wc -l` count and ranged reads) and the redirect-only patch writes (`diff.patch`, `diff-{focus}.patch`). Redirect-only writes print nothing, so no diff content reaches this thread
525
522
  2. **Parallel, not background** - Multiple agents in one message, but `run_in_background=false` so phases complete before proceeding
526
523
  3. **Git agent for git work** - All git operations go through Git agent, except the exceptions named in Principle 1; redirect-only writes print nothing
527
- 4. **Clear ownership** - Each agent owns its output completely
528
- 5. **Honest reporting** - Display agent outputs directly
529
- 6. **Incremental by default** - Only review new changes unless `--full` specified
530
- 7. **Auto-discover worktrees** - One command handles all reviewable branches
524
+ 4. **Honest reporting** - Display agent outputs directly
525
+ 5. **Incremental by default** - Only review new changes unless `--full` specified
@@ -36,9 +36,9 @@ $ARGUMENTS
36
36
  node "$HOME/.devflow/scripts/resolve-settings.cjs" "{root}" 2>/dev/null; echo "exit=$?"
37
37
  ```
38
38
 
39
- Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `TRACKER=<github|jira|linear> TRACKER_SOURCE=<project|personal|machine|default> TRACKER_WARN=<none|mismatch|invalid> SITE=<none|https://<host>> KEY=<none|<key>> REVIEW_PUBLICATION=<off|auto|full> COMPLIANCE=<off|generic|<id>[,<id>…]> MEMORY=<on|off> LEARNING=<on|off> KNOWLEDGE=<on|off>` — these fields, in this order, nothing else, where `<host>` is a lowercase dotted host name alone, `<key>` is 2–10 of `A-Z`, `0-9` and `_` starting with a letter, and each `<id>` is one of `gdpr`, `hipaa`, `pci-dss`, `soc2`, `iso-27001`, `sox`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `TRACKER=github TRACKER_SOURCE=default TRACKER_WARN=invalid SITE=none KEY=none REVIEW_PUBLICATION=off COMPLIANCE=generic MEMORY=on LEARNING=on KNOWLEDGE=off` instead.
39
+ Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `TRACKER=<github|jira|linear> TRACKER_SOURCE=<project|personal|machine|default> TRACKER_WARN=<none|mismatch|invalid> SITE=<none|https://<host>> KEY=<none|<key>> REVIEW_PUBLICATION=<off|auto|full> COMPLIANCE=<off|generic|<id>[,<id>…]> MEMORY=<on|off> LEARNING=<on|off> KNOWLEDGE=<on|off> GATE_LEVEL=<full|standard|lean>` — these fields, in this order, nothing else, where `<host>` is a lowercase dotted host name alone, `<key>` is 2–10 of `A-Z`, `0-9` and `_` starting with a letter, and each `<id>` is one of `gdpr`, `hipaa`, `pci-dss`, `soc2`, `iso-27001`, `sox`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `TRACKER=github TRACKER_SOURCE=default TRACKER_WARN=invalid SITE=none KEY=none REVIEW_PUBLICATION=off COMPLIANCE=generic MEMORY=on LEARNING=on KNOWLEDGE=off GATE_LEVEL=full` instead.
40
40
 
41
- The accepted line is the only source of these values: the script alone folds the committed `.devflow/project.json`, the personal `.devflow/config.json` and the machine manifest.
41
+ The accepted line is the only source of these values.
42
42
 
43
43
  From the same line: `COMPLIANCE_FRAMEWORKS` is the settings line's `COMPLIANCE` with `generic` written `none`: `off`, `none`, or the framework ids the machine and this repository declare.
44
44
 
@@ -198,7 +198,7 @@ Produce the final report:
198
198
 
199
199
  Ask user via AskUserQuestion: "Want me to implement this fix?"
200
200
 
201
- - **YES** → implement the fix through the Code agent, never in this thread, then spawn `Agent(subagent_type="Simplify")` on the changed files. /debug loads no feature knowledge, so the fix gets none:
201
+ - **YES** → implement the fix through the Code agent, never in this thread, then spawn `Agent(subagent_type="Polish")` on the changed files. /debug loads no feature knowledge, so the fix gets none:
202
202
 
203
203
  ```
204
204
  Agent(subagent_type="Code"):
@@ -249,16 +249,12 @@ FILES_CHANGED: {list of files changed}
249
249
  Write the knowledge base to:
250
250
  {worktree}/.devflow/features/{slug}/KNOWLEDGE.md
251
251
 
252
- Then update the index cache by performing a read-modify-write on:
252
+ Then update the index cache:
253
253
  {worktree}/.devflow/features/index.md
254
254
 
255
255
  Index line format: `- **{slug}** — {areas} — {Use-when description}` — at most 300 characters, the description at most 220; reword a longer one, never cut it.
256
256
 
257
- If the line for this slug already exists in index.md, replace it. If it does not exist, append it. If index.md does not exist, create it with just this line.
258
-
259
- The frontmatter in KNOWLEDGE.md is the source of truth — index.md is only a cache. Write the two files directly — no intermediate result JSON files, no external scripts.
260
-
261
- After writing, commit the two files to the current worktree branch yourself by running git via your Bash tool (do not use a script). Stage ONLY .devflow/features/index.md and .devflow/features/{slug}/KNOWLEDGE.md, then commit just those paths with a docs(knowledge): message. Do NOT push, do NOT force, do NOT stage anything else. Follow your Commit Protocol — it is non-blocking, so if any git step fails, report KB_COMMIT and finish normally."
257
+ Then commit the two files as your Commit Protocol directs."
262
258
  ```
263
259
 
264
260
  **Step 4 — Surface an uncommitted knowledge base:**
@@ -290,7 +286,7 @@ When the Knowledge agent reports `KB_COMMIT: skipped (detached HEAD)`, the files
290
286
  ├─ Phase 6: Root cause report with confidence level
291
287
  │
292
288
  ├─ Phase 7: Offer Fix
293
- │ └─ AskUserQuestion → Code agent (fix) + Simplify agent, or done
289
+ │ └─ AskUserQuestion → Code agent (fix) + Polish agent, or done
294
290
  │
295
291
  └─ Feature Knowledge Write-Back (Conditional)
296
292
  └─ Knowledge agent (if investigation surfaced durable cross-cutting knowledge)