devflow-kit 2.5.0 → 3.0.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 (158) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +44 -19
  3. package/dist/agents/git.md +13 -15
  4. package/dist/cli/commands/ambient.js +160 -145
  5. package/dist/cli/commands/capture.js +29 -55
  6. package/dist/cli/commands/compliance.js +32 -61
  7. package/dist/cli/commands/context.js +17 -32
  8. package/dist/cli/commands/debug.js +65 -26
  9. package/dist/cli/commands/flags.js +3 -3
  10. package/dist/cli/commands/hud.js +34 -10
  11. package/dist/cli/commands/init-seed.js +40 -4
  12. package/dist/cli/commands/init.js +249 -271
  13. package/dist/cli/commands/install-report.js +10 -15
  14. package/dist/cli/commands/knowledge/index.js +1 -1
  15. package/dist/cli/commands/knowledge/toggle.js +11 -3
  16. package/dist/cli/commands/learning.js +52 -37
  17. package/dist/cli/commands/legacy-hooks.js +11 -14
  18. package/dist/cli/commands/memory.js +67 -78
  19. package/dist/cli/commands/proxy.js +23 -41
  20. package/dist/cli/commands/security.js +5 -13
  21. package/dist/cli/commands/skills.js +21 -3
  22. package/dist/cli/commands/tracker.js +100 -228
  23. package/dist/cli/commands/uninstall.js +343 -138
  24. package/dist/commands/bug-analysis.md +38 -12
  25. package/dist/commands/code-review.md +70 -21
  26. package/dist/commands/debug.md +37 -7
  27. package/dist/commands/dynamic-build.md +66 -17
  28. package/dist/commands/dynamic-plan.md +19 -8
  29. package/dist/commands/dynamic-profile.md +24 -10
  30. package/dist/commands/dynamic-tickets.md +22 -11
  31. package/dist/commands/explore.md +37 -7
  32. package/dist/commands/implement.md +96 -32
  33. package/dist/commands/plan.md +62 -19
  34. package/dist/commands/release.md +2 -2
  35. package/dist/commands/research.md +34 -8
  36. package/dist/commands/resolve.md +65 -17
  37. package/dist/commands/self-review.md +45 -9
  38. package/dist/core/compliance-compose.js +27 -27
  39. package/dist/core/evidence-policy.js +240 -24
  40. package/dist/core/feature-config.js +94 -25
  41. package/dist/core/feature-switch.js +1 -1
  42. package/dist/core/flags.js +30 -2
  43. package/dist/core/fs-atomic.js +27 -0
  44. package/dist/core/hook-log-dirs.js +104 -0
  45. package/dist/core/learning-tuning-config.js +5 -3
  46. package/dist/core/ledger-root.js +102 -0
  47. package/dist/core/manifest.js +6 -4
  48. package/dist/core/mds-variants.js +34 -97
  49. package/dist/core/migrations.js +49 -23
  50. package/dist/core/plugins.js +5 -4
  51. package/dist/core/project-paths.js +0 -17
  52. package/dist/core/same-location.js +25 -0
  53. package/dist/core/tracker.js +226 -139
  54. package/dist/hud/components/config-counts.js +15 -4
  55. package/dist/hud/components/learning-counts.js +14 -0
  56. package/dist/hud/config.js +2 -1
  57. package/dist/hud/cost-history.js +2 -4
  58. package/dist/hud/git.js +52 -7
  59. package/dist/hud/index.js +7 -9
  60. package/dist/skills/git/references/pr/check-merge-readiness.md +1 -1
  61. package/dist/skills/git/references/pr/ensure-pr-ready.md +1 -1
  62. package/dist/skills/git/references/pr/update-pr-evidence.md +1 -1
  63. package/dist/skills/git/references/tracker/_mcp.md +1 -1
  64. package/dist/skills/git/references/tracker/github/backlink-shipped-issues.md +1 -1
  65. package/dist/skills/git/references/tracker/github/ensure-traceable-issue.md +1 -1
  66. package/dist/skills/git/references/tracker/github/gather-release-evidence.md +2 -2
  67. package/dist/skills/git/references/tracker/github/manage-debt.md +3 -3
  68. package/dist/skills/git/references/tracker/jira/backlink-shipped-issues.md +1 -1
  69. package/dist/skills/git/references/tracker/jira/ensure-traceable-issue.md +1 -1
  70. package/dist/skills/git/references/tracker/jira/gather-release-evidence.md +2 -2
  71. package/dist/skills/git/references/tracker/jira/manage-debt.md +1 -1
  72. package/dist/skills/git/references/tracker/jira/post-wave-report.md +1 -1
  73. package/dist/skills/git/references/tracker/jira/setup-task.md +1 -1
  74. package/dist/skills/git/references/tracker/linear/backlink-shipped-issues.md +1 -1
  75. package/dist/skills/git/references/tracker/linear/ensure-traceable-issue.md +1 -1
  76. package/dist/skills/git/references/tracker/linear/gather-release-evidence.md +2 -2
  77. package/dist/skills/git/references/tracker/linear/manage-debt.md +1 -1
  78. package/dist/skills/git/references/tracker/linear/post-wave-report.md +1 -1
  79. package/dist/skills/git/references/tracker/linear/setup-task.md +1 -1
  80. package/dist/targets/claude-code/claude-paths.js +59 -57
  81. package/dist/targets/claude-code/compliance-install.js +49 -65
  82. package/dist/targets/claude-code/hooks.js +108 -3
  83. package/dist/targets/claude-code/installer.js +30 -57
  84. package/dist/targets/claude-code/post-install.js +232 -139
  85. package/dist/targets/claude-code/tracker-install.js +38 -65
  86. package/package.json +5 -4
  87. package/src/assets/agents/code.md +4 -3
  88. package/src/assets/agents/design.md +1 -0
  89. package/src/assets/agents/git.mds +55 -57
  90. package/src/assets/agents/knowledge.md +2 -2
  91. package/src/assets/agents/review.md +3 -1
  92. package/src/assets/agents/tracker.md +37 -30
  93. package/src/assets/commands/_partials/_compliance.mds +19 -1
  94. package/src/assets/commands/_partials/_decisions.mds +15 -3
  95. package/src/assets/commands/_partials/_docs_root.mds +35 -0
  96. package/src/assets/commands/_partials/_engine.mds +2 -2
  97. package/src/assets/commands/_partials/_evidence_policy.mds +3 -3
  98. package/src/assets/commands/_partials/_factory.mds +1 -1
  99. package/src/assets/commands/_partials/_knowledge.mds +27 -9
  100. package/src/assets/commands/_partials/_plan_contract.mds +2 -2
  101. package/src/assets/commands/_partials/_preamble.mds +1 -1
  102. package/src/assets/commands/_partials/_publication.mds +6 -2
  103. package/src/assets/commands/_partials/_settings.mds +28 -0
  104. package/src/assets/commands/_partials/_ticket_template.mds +3 -3
  105. package/src/assets/commands/_partials/_tracker.mds +4 -4
  106. package/src/assets/commands/_partials/_wave.mds +4 -4
  107. package/src/assets/commands/bug-analysis.mds +19 -17
  108. package/src/assets/commands/code-review.mds +39 -33
  109. package/src/assets/commands/debug.mds +4 -5
  110. package/src/assets/commands/dynamic-build.mds +75 -53
  111. package/src/assets/commands/dynamic-plan.mds +20 -15
  112. package/src/assets/commands/dynamic-profile.mds +24 -11
  113. package/src/assets/commands/dynamic-tickets.mds +25 -20
  114. package/src/assets/commands/explore.mds +4 -5
  115. package/src/assets/commands/implement.mds +58 -45
  116. package/src/assets/commands/plan.mds +34 -29
  117. package/src/assets/commands/release.md +2 -2
  118. package/src/assets/commands/research.mds +11 -9
  119. package/src/assets/commands/resolve.mds +41 -39
  120. package/src/assets/commands/self-review.mds +24 -25
  121. package/src/assets/mds/git/_pr.mds +61 -61
  122. package/src/assets/mds/git/_references.mds +19 -19
  123. package/src/assets/mds/tracker/_common.mds +8 -8
  124. package/src/assets/mds/tracker/_github.mds +71 -71
  125. package/src/assets/mds/tracker/_jira.mds +74 -74
  126. package/src/assets/mds/tracker/_linear.mds +75 -75
  127. package/src/assets/mds/tracker/_mcp.mds +23 -17
  128. package/src/assets/scripts/hooks/background-memory-update +35 -19
  129. package/src/assets/scripts/hooks/capture-prompt +18 -12
  130. package/src/assets/scripts/hooks/capture-question +18 -12
  131. package/src/assets/scripts/hooks/capture-turn +27 -17
  132. package/src/assets/scripts/hooks/debug-trace +11 -6
  133. package/src/assets/scripts/hooks/ensure-devflow-init +33 -6
  134. package/src/assets/scripts/hooks/ensure-proxy +9 -8
  135. package/src/assets/scripts/hooks/ensure-root-gitignore +111 -36
  136. package/src/assets/scripts/hooks/git-marker +48 -0
  137. package/src/assets/scripts/hooks/json-helper.cjs +6 -1
  138. package/src/assets/scripts/hooks/lib/project-paths.cjs +0 -19
  139. package/src/assets/scripts/hooks/log-paths +80 -0
  140. package/src/assets/scripts/hooks/memory-worker +17 -15
  141. package/src/assets/scripts/hooks/pre-compact-memory +41 -16
  142. package/src/assets/scripts/hooks/queue-append +104 -30
  143. package/src/assets/scripts/hooks/resolve-project-root +101 -7
  144. package/src/assets/scripts/hooks/session-start-context +289 -122
  145. package/src/assets/scripts/hooks/session-start-memory +35 -16
  146. package/src/assets/scripts/lib/project-config.cjs +633 -0
  147. package/src/assets/scripts/resolve-evidence-policy.cjs +300 -220
  148. package/src/assets/scripts/resolve-settings.cjs +1054 -0
  149. package/src/assets/scripts/verify-evidence.cjs +1 -1
  150. package/src/assets/skills/compliance/SKILL.md +2 -2
  151. package/src/assets/skills/docs-framework/SKILL.md +6 -7
  152. package/src/assets/skills/docs-framework/references/patterns.md +10 -17
  153. package/src/assets/skills/gap-analysis/SKILL.md +2 -2
  154. package/src/assets/skills/git/references/github-api.md +9 -9
  155. package/src/assets/skills/git/references/patterns.md +1 -1
  156. package/src/assets/skills/worktree-support/SKILL.md +1 -1
  157. package/src/assets/skills/worktree-support/references/roots.md +29 -0
  158. package/src/targets/claude-code/templates/managed-settings.json +25 -9
@@ -52,10 +52,18 @@ If the user prompt does NOT match re-validation, proceed with the full pipeline
52
52
 
53
53
  Record the current branch name as `BASE_BRANCH` - this will be the PR target.
54
54
 
55
+ **Docs root (D-DOCS-ROOT).** Every `.devflow/docs/` path this command reads or writes lives at the checkout's toplevel, never under the directory the session started in. Resolve `{worktree}` from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`) — by running
56
+
57
+ ```bash
58
+ git -C "{start}" rev-parse --show-toplevel
59
+ ```
60
+
61
+ and using its one-line output. If the command fails (outside a git repository), `{worktree}` is the start directory itself. Every docs path below is written `{worktree}/.devflow/docs/…`; a repo-relative docs path handed to an agent always travels with a `WORKTREE_PATH` naming the checkout it is relative to.
62
+
55
63
  **Resolve the evidence policy once per run**, from the repository root, before any step reads the values:
56
64
 
57
65
  ```bash
58
- node "${DEVFLOW_DIR:-$HOME/.devflow}/scripts/resolve-evidence-policy.cjs" 2>/dev/null; echo "exit=$?"
66
+ node "$HOME/.devflow/scripts/resolve-evidence-policy.cjs" 2>/dev/null; echo "exit=$?"
59
67
  ```
60
68
 
61
69
  Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `EVIDENCE_POLICY=<required|standard> SOURCE=<file|worktree|default|invalid|error> REF=<branch|none>[ WARN=<remote-unavailable|invalid-file|raised-by-compliance|pr-changes-policy>[,…]] ISSUE_REQUIRED=<true|false> APPLY_CONVENTIONS=<true|false> REQUIRE_NON_AUTHOR_APPROVAL=<true|false>` — these fields, in this order, nothing else, where `<branch>` is a branch name such as `main`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `EVIDENCE_POLICY=required SOURCE=error REF=none ISSUE_REQUIRED=true APPLY_CONVENTIONS=true REQUIRE_NON_AUTHOR_APPROVAL=true` instead.
@@ -130,7 +138,7 @@ Note: `ISSUE_CONTENT` stays inside its `<untrusted-issue-body>` markers wherever
130
138
 
131
139
  **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:
132
140
  - **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.
133
- - **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/policy.json` as `{"version":1,"evidencePolicy":"standard"}` on the default branch; a machine with compliance enabled still resolves `required` whatever that file says. Spawn nothing further.
141
+ - **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.
134
142
 
135
143
  **Render each evidence exception** as one line under a `## Evidence Exceptions` heading, in exactly this shape:
136
144
 
@@ -146,9 +154,9 @@ Note: `ISSUE_CONTENT` stays inside its `<untrusted-issue-body>` markers wherever
146
154
 
147
155
  Note: the section reaches a public PR body. The Code agent re-checks every line against this shape before it pastes, and the body's D11 scrub is the reason's secret scrub — rendering filters no secrets. A rendered reason carries no HTML or comment markers, link or image syntax, @-mentions, `#N` or full-URL references (no `/` survives), entities or shell-expansion characters; plain emphasis and `www.` or `GH-N` autolinks can remain — the requester authors the reason.
148
156
 
149
- **Record the exception at once**, before any Code spawn: write the rendered section as the `## Evidence Exceptions` section of `.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, every PR-creating Code spawn passes it verbatim as `PR_EXCEPTIONS`, and the file is deleted only once the PR exists — after the PR-creating Phase 2 Code agent under SINGLE_CODE_AGENT and SEQUENTIAL_CODE_AGENTS, after Phase 10 under PARALLEL_CODE_AGENTS. With no exception recorded, `PR_EXCEPTIONS` is `(none)`.
157
+ **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, every PR-creating Code spawn passes it verbatim as `PR_EXCEPTIONS`, and the file is deleted only once the PR exists — after the PR-creating Phase 2 Code agent under SINGLE_CODE_AGENT and SEQUENTIAL_CODE_AGENTS, after Phase 10 under PARALLEL_CODE_AGENTS. With no exception recorded, `PR_EXCEPTIONS` is `(none)`.
150
158
 
151
- **Test plan.** Before any Code spawn, give the task a test plan in the evidence file `.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.
159
+ **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.
152
160
 
153
161
  Write the `## Test Plan` section: when `$ARGUMENTS` is a plan document with a `## Test Plan` section, copy that section's lines verbatim; otherwise write one TP line per acceptance criterion the plan, the issue or the task text states, numbered from `TP-1`. Never invent a criterion, and word every scenario yourself in plain words: the lines reach the PR body, so a scenario holds no `#`, `@` or `/` — no issue reference, mention, closing keyword target or URL — and the files a TP covers go in its `files:` field. Each line follows the TP-line contract:
154
162
 
@@ -162,14 +170,14 @@ Write the `## Test Plan` section: when `$ARGUMENTS` is a plan document with a `#
162
170
  Check the section:
163
171
 
164
172
  ```bash
165
- node "${DEVFLOW_DIR:-$HOME/.devflow}/scripts/verify-evidence.cjs" check tp .devflow/docs/evidence-{branch_slug}.md; echo "exit=$?"
173
+ node "$HOME/.devflow/scripts/verify-evidence.cjs" check tp "{worktree}/.devflow/docs/evidence-{branch_slug}.md"; echo "exit=$?"
166
174
  ```
167
175
 
168
176
  `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.
169
177
 
170
178
  **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:
171
- - **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 `.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.
172
- - **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/policy.json` as `{"version":1,"evidencePolicy":"standard"}` on the default branch; a machine with compliance enabled still resolves `required` whatever that file says. Spawn nothing further.
179
+ - **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.
180
+ - **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.
173
181
 
174
182
  When `EVIDENCE_POLICY` is `standard`, a missing test plan is never asked about: carry `Test plan: missing` to the Phase 11 report.
175
183
 
@@ -178,30 +186,52 @@ When `EVIDENCE_POLICY` is `standard`, a missing test plan is never asked about:
178
186
  - `PR_TEST_PLAN_BLOCK` — when the test plan is present and this render ends in `exit=0`, its stdout byte for byte without that `exit=` line; `(none)` otherwise:
179
187
 
180
188
  ```bash
181
- node "${DEVFLOW_DIR:-$HOME/.devflow}/scripts/verify-evidence.cjs" render --plan .devflow/docs/evidence-{branch_slug}.md; echo "exit=$?"
189
+ node "$HOME/.devflow/scripts/verify-evidence.cjs" render --plan "{worktree}/.devflow/docs/evidence-{branch_slug}.md"; echo "exit=$?"
182
190
  ```
183
191
 
184
- - `EVIDENCE_FILE` — `.devflow/docs/evidence-{branch_slug}.md`, its `## Evidence Exceptions` section now a byte copy of `PR_EXCEPTIONS` (absent when that is `(none)`).
192
+ - `EVIDENCE_FILE` — `{worktree}/.devflow/docs/evidence-{branch_slug}.md`, its `## Evidence Exceptions` section now a byte copy of `PR_EXCEPTIONS` (absent when that is `(none)`).
193
+
194
+ **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:
195
+
196
+ ```bash
197
+ node "$HOME/.devflow/scripts/resolve-settings.cjs" "{root}" 2>/dev/null; echo "exit=$?"
198
+ ```
185
199
 
186
- **Resolve `REVIEW_PUBLICATION` per worktree:** Read the current worktree's `.devflow/config.json` (a single, direct file read — multi-worktree repos may have different publication settings per worktree root). If the file exists and `reviewPublication` is one of `auto`, `full`, or `off`, set `REVIEW_PUBLICATION` to that value; otherwise set `REVIEW_PUBLICATION = "auto"`.
200
+ 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.
187
201
 
188
- **Evidence stub:** only when `EVIDENCE_POLICY` is `required`, a resolved `off` becomes `stub`, so a counts-only record still reaches the PR. `stub` is never a config value: a configured `stub` is unrecognised and resolves to `auto` like any other.
202
+ 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.
203
+
204
+ **Resolve `REVIEW_PUBLICATION` per worktree:** take `REVIEW_PUBLICATION` from that worktree's settings line, with `{root}` the worktree's root — multi-worktree repos may resolve different values per worktree. The line already caps the personal choice at the team's (D-PUBLICATION-CEILING), so it is `off`, `auto` or `full`, and `off` when the line was unresolvable.
205
+
206
+ **Evidence stub:** only when `EVIDENCE_POLICY` is `required`, a resolved `off` becomes `stub`, so a counts-only record still reaches the PR. `stub` is never a config value: the settings line never carries it.
189
207
 
190
208
  Note: `auto` is NOT fail-open — under `auto`, the Git agent probes the repository visibility and treats any error or unrecognised value as PUBLIC (mode STUB). What each value does is decided by the Git agent's publication gate (`references/publication-gate.md` step 2); this partial only resolves the value.
191
- Phase 10b passes the resolved value to `update-pr-evidence`, which decides what each value means for the evidence comment.
209
+ Phase 10b passes the resolved value to `update-pr-evidence`, which decides what each value means for the evidence comment. 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. Pass it to every Code spawn.
192
210
 
193
211
  ### Load DECISIONS_CONTEXT
194
212
 
195
- Resolve the worktree root using the `devflow:worktree-support` algorithm (use WORKTREE_PATH if provided, otherwise cwd). All paths below are relative to `{worktree}`.
213
+ The decisions ledger belongs to the repository, not to one checkout: in a linked worktree it lives in the main worktree, and a session started in a subdirectory reads the copy at the repository root. Locate it with ONE git call, run from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`):
214
+
215
+ ```bash
216
+ git -C "{start}" rev-parse --path-format=absolute --show-toplevel --git-common-dir
217
+ ```
218
+
219
+ Line 1 is the checkout's toplevel, line 2 the repository's common git directory. A git older than 2.31 echoes `--path-format=absolute` back as a line of its own first. `{ledger}` is the first of these that applies:
220
+
221
+ 1. **The main worktree** — line 2 without its trailing `/.git`, when the output is exactly two lines each beginning with `/`, line 2 ends in `/.git`, and the directory left once it is removed is not your home directory and contains a `.devflow/` directory.
222
+ 2. **The toplevel** — line 1, or on an older git the line after the echoed flag.
223
+ 3. **The start directory itself** — when the command failed or printed no absolute toplevel (outside a git repository).
224
+
225
+ This is the rule the learning hooks apply (D-LEDGER-MAIN-WORKTREE, D-PROMPT-ROOT), so you read the index the Learning agent writes.
196
226
 
197
227
  **Step 1 — Read the pre-rendered index:**
198
228
 
199
- Attempt to read `{worktree}/.devflow/learning/index.md`.
229
+ Attempt to read `{ledger}/.devflow/learning/index.md`.
200
230
 
201
231
  - If the file exists and contains non-empty content: use that content as `DECISIONS_CONTEXT`.
202
232
  - If the file is absent or empty: set `DECISIONS_CONTEXT` to `(none)`.
203
233
 
204
- **No subprocess, no `.cjs` script.** This is a single direct file read — the index is written at render time by `render-decisions.cjs` alongside `decisions.md`/`pitfalls.md`.
234
+ The index is one direct file read, written at render time by `render-decisions.cjs` alongside `decisions.md`/`pitfalls.md` — no `.cjs` script runs here, and the index's own footer names the files that hold each entry's full body.
205
235
 
206
236
  **Step 2 — Apply decisions using `devflow:apply-decisions`:**
207
237
 
@@ -211,7 +241,13 @@ Pass to Code agent (Phase 2) and Scrutinize agent (Phase 5).
211
241
 
212
242
  ### Load Feature Knowledge
213
243
 
214
- Resolve the worktree root using the `devflow:worktree-support` algorithm (use WORKTREE_PATH if provided, otherwise cwd). All paths below are relative to `{worktree}`.
244
+ Resolve `{worktree}` as the checkout's toplevel, because feature knowledge bases are committed with the branch (D-PROMPT-ROOT): from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`) — run
245
+
246
+ ```bash
247
+ git -C "{start}" rev-parse --show-toplevel
248
+ ```
249
+
250
+ and use its one-line output. If the command fails (outside a git repository), `{worktree}` is the start directory itself. All paths below are relative to `{worktree}`.
215
251
 
216
252
  **Step 1 — Read the index cache:**
217
253
 
@@ -246,7 +282,7 @@ Concatenate the selected KNOWLEDGE.md files under slug headers:
246
282
 
247
283
  If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set `FEATURE_KNOWLEDGE` to `(none)`.
248
284
 
249
- **No subprocess, no git calls, no `.cjs` script.** This entire step is direct file reads — 1 index read (or N frontmatter reads on fallback), bounded by KB count.
285
+ **One git call, then direct file reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), bounded by KB count.
250
286
 
251
287
  ### Phase 2: Implement
252
288
 
@@ -280,10 +316,11 @@ CREATE_PR: true
280
316
  DOMAIN: {detected domain or 'fullstack'}
281
317
  FEATURE_KNOWLEDGE: {feature_knowledge}
282
318
  DECISIONS_CONTEXT: {decisions_context}
319
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
283
320
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
284
321
  ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
285
322
  ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
286
- PR_EXCEPTIONS: {the ## Evidence Exceptions section of .devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
323
+ PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
287
324
  PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}"
288
325
  ```
289
326
 
@@ -305,11 +342,12 @@ CREATE_PR: false
305
342
  DOMAIN: {phase 1 domain, e.g., 'backend'}
306
343
  FEATURE_KNOWLEDGE: {feature_knowledge}
307
344
  DECISIONS_CONTEXT: {decisions_context}
345
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
308
346
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
309
347
  ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
310
348
  ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
311
349
  HANDOFF_REQUIRED: true
312
- HANDOFF_FILE: .devflow/docs/handoff-{branch_slug}.md"
350
+ HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
313
351
  ```
314
352
 
315
353
  **Phase 2+ Code agents** (after prior phase completes):
@@ -326,16 +364,17 @@ PRIOR_PHASE_SUMMARY: {summary from previous Code agent}
326
364
  FILES_FROM_PRIOR_PHASE: {list of files created}
327
365
  FEATURE_KNOWLEDGE: {feature_knowledge}
328
366
  DECISIONS_CONTEXT: {decisions_context}
367
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
329
368
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
330
369
  ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
331
370
  ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
332
- PR_EXCEPTIONS: {the ## Evidence Exceptions section of .devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
371
+ PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
333
372
  PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}
334
373
  HANDOFF_REQUIRED: {true if not last phase}
335
- HANDOFF_FILE: .devflow/docs/handoff-{branch_slug}.md"
374
+ HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
336
375
  ```
337
376
 
338
- **Handoff Protocol**: Each sequential Code agent receives the prior Code agent's implementation summary via PRIOR_PHASE_SUMMARY and FILES_FROM_PRIOR_PHASE. The Code agent's built-in branch orientation step handles git log scanning, file reading, and pattern discovery automatically. After each Code agent with HANDOFF_REQUIRED=true completes, write its phase summary to `.devflow/docs/handoff-{branch_slug}.md` using the Write tool (survives context compaction), keeping any `## Evidence Exceptions` section byte-identical. Delete `.devflow/docs/handoff-{branch_slug}.md` once the PR exists — after the final Code agent, which creates it, completes (cleanup).
377
+ **Handoff Protocol**: Each sequential Code agent receives the prior Code agent's implementation summary via PRIOR_PHASE_SUMMARY and FILES_FROM_PRIOR_PHASE. The Code agent's built-in branch orientation step handles git log scanning, file reading, and pattern discovery automatically. After each Code agent with HANDOFF_REQUIRED=true completes, write its phase summary to `{worktree}/.devflow/docs/handoff-{branch_slug}.md` using the Write tool (survives context compaction), keeping any `## Evidence Exceptions` section byte-identical. Delete `{worktree}/.devflow/docs/handoff-{branch_slug}.md` once the PR exists — after the final Code agent, which creates it, completes (cleanup).
339
378
 
340
379
  ---
341
380
 
@@ -354,6 +393,7 @@ CREATE_PR: false
354
393
  DOMAIN: {subtask 1 domain}
355
394
  FEATURE_KNOWLEDGE: {feature_knowledge}
356
395
  DECISIONS_CONTEXT: {decisions_context}
396
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
357
397
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
358
398
  ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
359
399
  ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
@@ -368,6 +408,7 @@ CREATE_PR: false
368
408
  DOMAIN: {subtask 2 domain}
369
409
  FEATURE_KNOWLEDGE: {feature_knowledge}
370
410
  DECISIONS_CONTEXT: {decisions_context}
411
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
371
412
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
372
413
  ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
373
414
  ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
@@ -407,7 +448,8 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
407
448
  SCOPE: Fix only the listed failures, no other changes
408
449
  CREATE_PR: false
409
450
  ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
410
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
451
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
452
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
411
453
  ```
412
454
  - Loop back to Phase 3 (re-validate)
413
455
  4. If `validation_retry_count > 2`: Report failures to user and halt
@@ -509,7 +551,8 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
509
551
  SCOPE: Fix only the listed misalignments, no other changes
510
552
  CREATE_PR: false
511
553
  ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
512
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
554
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
555
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
513
556
  ```
514
557
  - Spawn Validate agent to verify fix didn't break tests:
515
558
  ```
@@ -556,7 +599,8 @@ After every Test agent run — PASS or FAIL, first run or retry — append its T
556
599
  SCOPE: Fix only the listed failures, no other changes
557
600
  CREATE_PR: false
558
601
  ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
559
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
602
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
603
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
560
604
  ```
561
605
  - Spawn Validate agent to verify fix didn't break tests:
562
606
  ```
@@ -581,7 +625,7 @@ Strategy-conditional: run when the PR already exists — **SINGLE_CODE_AGENT** a
581
625
  3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to Phase 10.
582
626
  4. **If PENDING** → poll every 60 seconds (global budget, see step 7). Re-spawn Git agent each poll. If PASSING → proceed. If still PENDING after budget exhausted → report "CI still running — verify manually before merging" and proceed.
583
627
  5. **If INDETERMINATE** → poll as PENDING within the same budget. If still INDETERMINATE after budget exhausted → report "CI status unknown — verify manually before merging" and proceed.
584
- 6. **If FAILING** → report failing checks. Spawn `Agent(subagent_type="Code")` to fix CI failures based on check names and failure context. After fix, push and re-check. Max 2 fix attempts. If still failing → report failures and proceed.
628
+ 6. **If FAILING** → report failing checks. Spawn `Agent(subagent_type="Code")` with `COMPLIANCE_FRAMEWORKS` to fix CI failures based on check names and failure context. After fix, push and re-check. Max 2 fix attempts. If still failing → report failures and proceed.
585
629
  7. **Total budget**: max 10 polls and max 2 fix attempts across all check/fix cycles combined. If budget exhausted, report current status and proceed.
586
630
  <!-- /PATTERN: ci-status-gate -->
587
631
 
@@ -604,8 +648,9 @@ CREATE_PR: true
604
648
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
605
649
  ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
606
650
  ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
607
- PR_EXCEPTIONS: {the ## Evidence Exceptions section of .devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
608
- PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}"
651
+ PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
652
+ PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}
653
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
609
654
  ```
610
655
 
611
656
  Its Responsibility 7 composes the body, pastes `ISSUE_PR_LINK`, `PR_EXCEPTIONS` and `PR_TEST_PLAN_BLOCK` through their paste gates and scrubs the body (D11) before `gh pr create`. This command renders no link line and creates no PR itself: the Git agent's Phase-1 rendering is the only one, forwarded verbatim.
@@ -633,6 +678,7 @@ Agent(subagent_type="Git"):
633
678
  PR_NUMBER: {number from PR_URL}
634
679
  EVIDENCE_FILE: .devflow/docs/evidence-{branch_slug}.md
635
680
  REVIEW_PUBLICATION: {REVIEW_PUBLICATION resolved in Phase 1, or auto}
681
+ WORKTREE_PATH: {worktree}
636
682
  Update the PR's test-plan block and post its evidence comment."
637
683
  ```
638
684
 
@@ -652,13 +698,27 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
652
698
 
653
699
  ### Feature Knowledge Write-Back (Conditional)
654
700
 
655
- Resolve the worktree root using the `devflow:worktree-support` algorithm (use WORKTREE_PATH if provided, otherwise cwd). All paths below are relative to `{worktree}`.
701
+ Resolve `{worktree}` as the checkout's toplevel, because feature knowledge bases are committed with the branch (D-PROMPT-ROOT): from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`) — run
702
+
703
+ ```bash
704
+ git -C "{start}" rev-parse --show-toplevel
705
+ ```
656
706
 
657
- **Step 1 — Check the opt-out gate:**
707
+ and use its one-line output. If the command fails (outside a git repository), `{worktree}` is the start directory itself. All paths below are relative to `{worktree}`.
658
708
 
659
- Read `~/.devflow/manifest.json`. If `features.knowledge` is `false`, skip write-back entirely — the user disabled knowledge bases for every project (`devflow init --no-knowledge` or `devflow knowledge --disable`). The project's `.devflow/config.json` is not a gate: knowledge is switched machine-wide only.
709
+ **Step 1 — Check the opt-out gate, with `{root}` = `{worktree}`:**
660
710
 
661
- A missing file or a missing field means write-back is allowed (default is enabled).
711
+ **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:
712
+
713
+ ```bash
714
+ node "$HOME/.devflow/scripts/resolve-settings.cjs" "{root}" 2>/dev/null; echo "exit=$?"
715
+ ```
716
+
717
+ 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.
718
+
719
+ 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.
720
+
721
+ If the settings line says `KNOWLEDGE=off`, skip write-back entirely. The machine switch (`devflow knowledge --disable`), the repository and the personal settings can each turn knowledge off, and none can turn it back on (D-FEATURES-NARROW-ONLY). The fail-closed line says `KNOWLEDGE=off` too, so an unresolvable line skips write-back.
662
722
 
663
723
  **Step 2 — Evaluate whether write-back is warranted:**
664
724
 
@@ -697,6 +757,10 @@ The frontmatter in KNOWLEDGE.md is the source of truth — index.md is only a ca
697
757
  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."
698
758
  ```
699
759
 
760
+ **Step 4 — Surface an uncommitted knowledge base:**
761
+
762
+ When the Knowledge agent reports `KB_COMMIT: skipped (detached HEAD)`, the files were written but deliberately not committed — a commit on a detached HEAD becomes unreachable once HEAD moves. Tell the user in the workflow's final report, in one line, that the knowledge base was written but not committed, and name the uncommitted paths the agent listed, so they can commit them on a branch before the worktree is removed. Never commit them yourself.
763
+
700
764
  **Failure handling**: Non-blocking. If the Knowledge agent fails, log the failure and continue — the workflow outcome is not affected by write-back success.
701
765
 
702
766
  ## Architecture
@@ -121,18 +121,38 @@ Run rskim on source directories (NOT repo root) to identify:
121
121
  Return codebase context for requirements analysis."
122
122
  ```
123
123
 
124
+ **Docs root (D-DOCS-ROOT).** Every `.devflow/docs/` path this command reads or writes lives at the checkout's toplevel, never under the directory the session started in. Resolve `{worktree}` from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`) — by running
125
+
126
+ ```bash
127
+ git -C "{start}" rev-parse --show-toplevel
128
+ ```
129
+
130
+ and using its one-line output. If the command fails (outside a git repository), `{worktree}` is the start directory itself. Every docs path below is written `{worktree}/.devflow/docs/…`; a repo-relative docs path handed to an agent always travels with a `WORKTREE_PATH` naming the checkout it is relative to.
131
+
124
132
  ### Load DECISIONS_CONTEXT
125
133
 
126
- Resolve the worktree root using the `devflow:worktree-support` algorithm (use WORKTREE_PATH if provided, otherwise cwd). All paths below are relative to `{worktree}`.
134
+ The decisions ledger belongs to the repository, not to one checkout: in a linked worktree it lives in the main worktree, and a session started in a subdirectory reads the copy at the repository root. Locate it with ONE git call, run from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`):
135
+
136
+ ```bash
137
+ git -C "{start}" rev-parse --path-format=absolute --show-toplevel --git-common-dir
138
+ ```
139
+
140
+ Line 1 is the checkout's toplevel, line 2 the repository's common git directory. A git older than 2.31 echoes `--path-format=absolute` back as a line of its own first. `{ledger}` is the first of these that applies:
141
+
142
+ 1. **The main worktree** — line 2 without its trailing `/.git`, when the output is exactly two lines each beginning with `/`, line 2 ends in `/.git`, and the directory left once it is removed is not your home directory and contains a `.devflow/` directory.
143
+ 2. **The toplevel** — line 1, or on an older git the line after the echoed flag.
144
+ 3. **The start directory itself** — when the command failed or printed no absolute toplevel (outside a git repository).
145
+
146
+ This is the rule the learning hooks apply (D-LEDGER-MAIN-WORKTREE, D-PROMPT-ROOT), so you read the index the Learning agent writes.
127
147
 
128
148
  **Step 1 — Read the pre-rendered index:**
129
149
 
130
- Attempt to read `{worktree}/.devflow/learning/index.md`.
150
+ Attempt to read `{ledger}/.devflow/learning/index.md`.
131
151
 
132
152
  - If the file exists and contains non-empty content: use that content as `DECISIONS_CONTEXT`.
133
153
  - If the file is absent or empty: set `DECISIONS_CONTEXT` to `(none)`.
134
154
 
135
- **No subprocess, no `.cjs` script.** This is a single direct file read — the index is written at render time by `render-decisions.cjs` alongside `decisions.md`/`pitfalls.md`.
155
+ The index is one direct file read, written at render time by `render-decisions.cjs` alongside `decisions.md`/`pitfalls.md` — no `.cjs` script runs here, and the index's own footer names the files that hold each entry's full body.
136
156
 
137
157
  **Step 2 — Apply decisions using `devflow:apply-decisions`:**
138
158
 
@@ -142,7 +162,13 @@ This produces a compact index of active ADR/PF entries. Pass Skim agent context
142
162
 
143
163
  ### Load Feature Knowledge
144
164
 
145
- Resolve the worktree root using the `devflow:worktree-support` algorithm (use WORKTREE_PATH if provided, otherwise cwd). All paths below are relative to `{worktree}`.
165
+ Resolve `{worktree}` as the checkout's toplevel, because feature knowledge bases are committed with the branch (D-PROMPT-ROOT): from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`) — run
166
+
167
+ ```bash
168
+ git -C "{start}" rev-parse --show-toplevel
169
+ ```
170
+
171
+ and use its one-line output. If the command fails (outside a git repository), `{worktree}` is the start directory itself. All paths below are relative to `{worktree}`.
146
172
 
147
173
  **Step 1 — Read the index cache:**
148
174
 
@@ -177,7 +203,7 @@ Concatenate the selected KNOWLEDGE.md files under slug headers:
177
203
 
178
204
  If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set `FEATURE_KNOWLEDGE` to `(none)`.
179
205
 
180
- **No subprocess, no git calls, no `.cjs` script.** This entire step is direct file reads — 1 index read (or N frontmatter reads on fallback), bounded by KB count.
206
+ **One git call, then direct file reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), bounded by KB count.
181
207
 
182
208
  Pass `FEATURE_KNOWLEDGE` alongside `DECISIONS_CONTEXT` to Explore and Design agents.
183
209
 
@@ -216,12 +242,26 @@ Combine into: user needs, similar features, constraints, failure modes"
216
242
 
217
243
  #### Phase 5: Gap Analysis (Parallel)
218
244
 
219
- **Produces:** GAP_OUTPUTS, COMPLIANCE_SKILL_INSTALLED
245
+ **Produces:** GAP_OUTPUTS, COMPLIANCE_ACTIVE, COMPLIANCE_FRAMEWORKS
220
246
  **Requires:** EXPLORATION_SYNTHESIS, SKIM_CONTEXT, DECISIONS_CONTEXT
221
247
 
222
- **Resolve `COMPLIANCE_SKILL_INSTALLED` once per run:** Check whether `~/.claude/skills/devflow:compliance/SKILL.md` exists (one file-existence check, read-only, silent). Set `COMPLIANCE_SKILL_INSTALLED = true` if the file exists, `false` otherwise.
248
+ **Resolve the compliance lens** for each worktree root, from its settings line (every framework reference is installed on every machine, so no file check decides it):
249
+
250
+ **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:
251
+
252
+ ```bash
253
+ node "$HOME/.devflow/scripts/resolve-settings.cjs" "{root}" 2>/dev/null; echo "exit=$?"
254
+ ```
255
+
256
+ 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.
257
+
258
+ 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.
259
+
260
+ **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.
261
+
262
+ `COMPLIANCE_ACTIVE` is `true` unless `COMPLIANCE_FRAMEWORKS` is `off`.
223
263
 
224
- **Single-issue**: Spawn 4 Design agents **in a single message** (**5 when COMPLIANCE_SKILL_INSTALLED**):
264
+ **Single-issue**: Spawn 4 Design agents **in a single message** (**5 when COMPLIANCE_ACTIVE**):
225
265
 
226
266
  | Focus | What it checks |
227
267
  |-------|----------------|
@@ -229,9 +269,9 @@ Combine into: user needs, similar features, constraints, failure modes"
229
269
  | architecture | Pattern violations, missing integration points, layering issues |
230
270
  | security | Auth gaps, input validation, secret handling, OWASP |
231
271
  | performance | N+1 patterns, missing caching, concurrency, query patterns |
232
- | compliance | Regulatory gaps security doesn't cover: retention/erasure, audit-trail completeness, segregation of duties, IaC exposure (only when COMPLIANCE_SKILL_INSTALLED) |
272
+ | compliance | Regulatory gaps security doesn't cover: retention/erasure, audit-trail completeness, segregation of duties, IaC exposure (only when COMPLIANCE_ACTIVE) |
233
273
 
234
- **Multi-issue**: Spawn 6 Design agents **in a single message** (**7 when COMPLIANCE_SKILL_INSTALLED**; same 4/5 plus):
274
+ **Multi-issue**: Spawn 6 Design agents **in a single message** (**7 when COMPLIANCE_ACTIVE**; same 4/5 plus):
235
275
 
236
276
  | Focus | What it checks |
237
277
  |-------|----------------|
@@ -244,6 +284,7 @@ Each Design agent receives:
244
284
  - Exploration synthesis from Phase 4
245
285
  - Skim agent context from Phase 2
246
286
  - `DECISIONS_CONTEXT` (index from Phase 2)
287
+ - `COMPLIANCE_FRAMEWORKS` (compliance focus only)
247
288
  - Multi-issue: all issue bodies
248
289
 
249
290
  ```
@@ -252,6 +293,7 @@ Agent(subagent_type="Design"):
252
293
  Focus: {completeness|architecture|security|performance|compliance|consistency|dependencies}
253
294
  DECISIONS_CONTEXT: {decisions_context}
254
295
  FEATURE_KNOWLEDGE: {feature_knowledge}
296
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS} (compliance focus only)
255
297
  Artifacts:
256
298
  Feature/Issues: {feature description or issue bodies}
257
299
  Exploration synthesis: {Phase 4 output}
@@ -438,9 +480,9 @@ User can:
438
480
  **Store design artifact:**
439
481
 
440
482
  **Pre-compute the artifact path** from the slug (it never changes after this):
441
- - If one issue: `.devflow/docs/design/{ISSUE_ID}-{topic-slug}.{YYYY-MM-DD_HHMM}.md` (the `docs-framework` skill's design-document pattern, e.g. `42-jwt-auth.2026-04-07_1430.md`)
442
- - If multi-issue: `.devflow/docs/design/multi-{topic-slug}.{YYYY-MM-DD_HHMM}.md`, frontmatter `issue: pending` — a batch fetch returns no issue ID to name it by
443
- - If no issue: `.devflow/docs/design/{topic-slug}.{YYYY-MM-DD_HHMM}.md`
483
+ - If one issue: `{worktree}/.devflow/docs/design/{ISSUE_ID}-{topic-slug}.{YYYY-MM-DD_HHMM}.md` (the `docs-framework` skill's design-document pattern, e.g. `42-jwt-auth.2026-04-07_1430.md`)
484
+ - If multi-issue: `{worktree}/.devflow/docs/design/multi-{topic-slug}.{YYYY-MM-DD_HHMM}.md`, frontmatter `issue: pending` — a batch fetch returns no issue ID to name it by
485
+ - If no issue: `{worktree}/.devflow/docs/design/{topic-slug}.{YYYY-MM-DD_HHMM}.md`
444
486
 
445
487
  Create parent directory if needed.
446
488
 
@@ -503,7 +545,7 @@ Under `github`, `{ISSUE_REF}` is `#`-prefixed, so that line renders `Closes #{n}
503
545
  **Check the test plan before the artifact exists:** place the `## Test Plan` section's lines in a fresh temp file and run:
504
546
 
505
547
  ```bash
506
- node "${DEVFLOW_DIR:-$HOME/.devflow}/scripts/verify-evidence.cjs" check tp <that file>; echo "exit=$?"
548
+ node "$HOME/.devflow/scripts/verify-evidence.cjs" check tp <that file>; echo "exit=$?"
507
549
  ```
508
550
 
509
551
  `exit=0` passes. On any other result, correct the lines once — the script names the failing line and its code on stderr — and check again. Still failing ⇒ keep the section as it stands and say so in the report: `/implement` re-checks it before any Code spawn.
@@ -513,7 +555,7 @@ node "${DEVFLOW_DIR:-$HOME/.devflow}/scripts/verify-evidence.cjs" check tp <that
513
555
  **Resolve the evidence policy once per run**, from the repository root, before any step reads the values:
514
556
 
515
557
  ```bash
516
- node "${DEVFLOW_DIR:-$HOME/.devflow}/scripts/resolve-evidence-policy.cjs" 2>/dev/null; echo "exit=$?"
558
+ node "$HOME/.devflow/scripts/resolve-evidence-policy.cjs" 2>/dev/null; echo "exit=$?"
517
559
  ```
518
560
 
519
561
  Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `EVIDENCE_POLICY=<required|standard> SOURCE=<file|worktree|default|invalid|error> REF=<branch|none>[ WARN=<remote-unavailable|invalid-file|raised-by-compliance|pr-changes-policy>[,…]] ISSUE_REQUIRED=<true|false> APPLY_CONVENTIONS=<true|false> REQUIRE_NON_AUTHOR_APPROVAL=<true|false>` — these fields, in this order, nothing else, where `<branch>` is a branch name such as `main`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `EVIDENCE_POLICY=required SOURCE=error REF=none ISSUE_REQUIRED=true APPLY_CONVENTIONS=true REQUIRE_NON_AUTHOR_APPROVAL=true` instead.
@@ -535,7 +577,8 @@ ISSUE_INPUT: {the raw candidate token from $ARGUMENTS if /plan was invoked with
535
577
  TASK_DESCRIPTION: {Gate 0 confirmed scope — one-line title}
536
578
  INITIAL_REQUEST: {the Gate 0 confirmed scope statement}
537
579
  REQUIREMENTS: {discovered requirements summary from Phase 6 gap synthesis}
538
- PLAN_ARTIFACT_PATH: {the design artifact path written above}
580
+ PLAN_ARTIFACT_PATH: {the design artifact path written above, relative to {worktree} — never absolute}
581
+ WORKTREE_PATH: {worktree}
539
582
  LABELS: feature
540
583
  The Git agent will create a tracker issue (or enrich an existing one) using the D3 template,
541
584
  post the design artifact as a collapsed details comment, and link it from the Implementation Plan section.
@@ -584,7 +627,7 @@ Display completion summary:
584
627
  │ │ ├─ Design agent: architecture
585
628
  │ │ ├─ Design agent: security
586
629
  │ │ ├─ Design agent: performance
587
- │ │ ├─ Design agent: compliance (only when COMPLIANCE_SKILL_INSTALLED)
630
+ │ │ ├─ Design agent: compliance (only when COMPLIANCE_ACTIVE)
588
631
  │ │ ├─ Design agent: consistency (multi-issue only)
589
632
  │ │ └─ Design agent: dependencies (multi-issue only)
590
633
  │ └─ Phase 6: Synthesize Gap Analysis
@@ -617,7 +660,7 @@ Display completion summary:
617
660
  │
618
661
  ├─ Block 6: Output
619
662
  │ └─ Phase 14: Output
620
- │ ├─ Store design artifact (.devflow/docs/design/)
663
+ │ ├─ Store design artifact ({worktree}/.devflow/docs/design/)
621
664
  │ ├─ Create tracker issue (optional)
622
665
  │ └─ Report summary + next step
623
666
  │
@@ -638,4 +681,4 @@ Display completion summary:
638
681
  - If any agent fails, report the phase, agent type, and error
639
682
  - If user selects "Revise" at Gate 2, loop back to Phase 10 with user's constraints
640
683
  - If user selects "Cancel" at any gate, stop gracefully without writing artifact
641
- - If `.devflow/docs/design/` does not exist, create it in Phase 14
684
+ - If `{worktree}/.devflow/docs/design/` does not exist, create it in Phase 14
@@ -61,7 +61,7 @@ Pass both to all subsequent agents via their input contracts.
61
61
  **Resolve the evidence policy once per run**, from the repository root, before any step reads the values:
62
62
 
63
63
  ```bash
64
- node "${DEVFLOW_DIR:-$HOME/.devflow}/scripts/resolve-evidence-policy.cjs" 2>/dev/null; echo "exit=$?"
64
+ node "$HOME/.devflow/scripts/resolve-evidence-policy.cjs" 2>/dev/null; echo "exit=$?"
65
65
  ```
66
66
 
67
67
  Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `EVIDENCE_POLICY=<required|standard> SOURCE=<file|worktree|default|invalid|error> REF=<branch|none>[ WARN=<remote-unavailable|invalid-file|raised-by-compliance|pr-changes-policy>[,…]] ISSUE_REQUIRED=<true|false> APPLY_CONVENTIONS=<true|false> REQUIRE_NON_AUTHOR_APPROVAL=<true|false>` — these fields, in this order, nothing else, where `<branch>` is a branch name such as `main`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `EVIDENCE_POLICY=required SOURCE=error REF=none ISSUE_REQUIRED=true APPLY_CONVENTIONS=true REQUIRE_NON_AUTHOR_APPROVAL=true` instead.
@@ -106,7 +106,7 @@ Lazy-init `.release/` directory. Create `.release/.gitignore` with `.progress.js
106
106
  **Version determination** (in order):
107
107
  1. Explicit version from args → use directly
108
108
  2. Bump type from args → compute from current version
109
- 3. `semver-auto` strategy → analyze commits since the last release tag: the tag that `node "${DEVFLOW_DIR:-$HOME/.devflow}/scripts/release-trace.cjs" last-tag`, run from the repository root, prints as `LAST_TAG <tag>` (`LAST_TAG none` ⇒ the initial commit) — never `git describe`, which can return a local marker tag
109
+ 3. `semver-auto` strategy → analyze commits since the last release tag: the tag that `node "$HOME/.devflow/scripts/release-trace.cjs" last-tag`, run from the repository root, prints as `LAST_TAG <tag>` (`LAST_TAG none` ⇒ the initial commit) — never `git describe`, which can return a local marker tag
110
110
  4. None → use AskUserQuestion
111
111
 
112
112
  Pre-release checks: