@cbartens/bkit 6.0.0 → 6.1.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 (375) hide show
  1. package/.bkit/README.md +154 -151
  2. package/.bkit/core/.agents/context.md +95 -29
  3. package/.bkit/core/.agents/docs.md +17 -15
  4. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +1 -0
  5. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +6 -5
  6. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-readguard.cjs +1 -0
  7. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-rules.cjs +65 -0
  8. package/.bkit/core/.agents/rules.md +108 -107
  9. package/.bkit/core/.agents/skills.md +63 -15
  10. package/.bkit/core/.bkit/README.md +154 -151
  11. package/.bkit/core/.bkit/authoring.md +714 -84
  12. package/.bkit/core/.bkit/cli.md +407 -0
  13. package/.bkit/core/.bkit/cloud.md +281 -193
  14. package/.bkit/core/.bkit/comparison.md +43 -41
  15. package/.bkit/core/.bkit/install.md +154 -84
  16. package/.bkit/core/.bkit/jsonl.md +193 -130
  17. package/.bkit/core/.bkit/pipeline.md +114 -114
  18. package/.bkit/core/.bkit/prompts.md +272 -165
  19. package/.bkit/core/.bkit/providers.md +457 -271
  20. package/.bkit/core/.bkit/router.md +69 -0
  21. package/.bkit/core/.bkit/templates.md +529 -256
  22. package/.bkit/core/.bkit/trackers.md +80 -52
  23. package/.bkit/core/.bkit/workflows.md +589 -504
  24. package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +2 -2
  25. package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +3 -3
  26. package/.bkit/core/.claude/hooks/bkit-preflight.sh +45 -14
  27. package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +3 -3
  28. package/.bkit/core/.codex/hooks/bkit-rules.cjs +57 -0
  29. package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +7 -7
  30. package/.bkit/core/.cursor/hooks/bkit-preflight.sh +47 -12
  31. package/.bkit/core/.opencode/plugin/bkit-rules.js +89 -0
  32. package/.bkit/core/AGENTS.md +5 -73
  33. package/.bkit/core/docs/templates/bkit-audit-accessibility.md +127 -105
  34. package/.bkit/core/docs/templates/bkit-audit-adoption.md +104 -70
  35. package/.bkit/core/docs/templates/bkit-audit-agents.md +94 -72
  36. package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +99 -78
  37. package/.bkit/core/docs/templates/bkit-audit-analytics.md +140 -82
  38. package/.bkit/core/docs/templates/bkit-audit-annotations.md +98 -72
  39. package/.bkit/core/docs/templates/bkit-audit-app-performance.md +121 -96
  40. package/.bkit/core/docs/templates/bkit-audit-app-store.md +157 -76
  41. package/.bkit/core/docs/templates/bkit-audit-architecture.md +113 -71
  42. package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +75 -72
  43. package/.bkit/core/docs/templates/bkit-audit-config.md +122 -76
  44. package/.bkit/core/docs/templates/bkit-audit-cost.md +85 -74
  45. package/.bkit/core/docs/templates/bkit-audit-coverage.md +75 -68
  46. package/.bkit/core/docs/templates/bkit-audit-database.md +101 -70
  47. package/.bkit/core/docs/templates/bkit-audit-dead-code.md +164 -83
  48. package/.bkit/core/docs/templates/bkit-audit-deferrals.md +115 -86
  49. package/.bkit/core/docs/templates/bkit-audit-dependencies.md +264 -88
  50. package/.bkit/core/docs/templates/bkit-audit-documentation.md +118 -93
  51. package/.bkit/core/docs/templates/bkit-audit-duplication.md +139 -86
  52. package/.bkit/core/docs/templates/bkit-audit-failures.md +110 -81
  53. package/.bkit/core/docs/templates/bkit-audit-flakes.md +99 -74
  54. package/.bkit/core/docs/templates/bkit-audit-gates.md +105 -77
  55. package/.bkit/core/docs/templates/bkit-audit-issues.md +104 -80
  56. package/.bkit/core/docs/templates/bkit-audit-llm.md +131 -58
  57. package/.bkit/core/docs/templates/bkit-audit-logs.md +123 -100
  58. package/.bkit/core/docs/templates/bkit-audit-models.md +98 -53
  59. package/.bkit/core/docs/templates/bkit-audit-privacy.md +56 -52
  60. package/.bkit/core/docs/templates/bkit-audit-prompts.md +63 -54
  61. package/.bkit/core/docs/templates/bkit-audit-red-team.md +124 -68
  62. package/.bkit/core/docs/templates/bkit-audit-reliability.md +95 -70
  63. package/.bkit/core/docs/templates/bkit-audit-repo.md +169 -73
  64. package/.bkit/core/docs/templates/bkit-audit-security.md +206 -96
  65. package/.bkit/core/docs/templates/bkit-audit-slop.md +77 -70
  66. package/.bkit/core/docs/templates/bkit-audit-testing.md +162 -114
  67. package/.bkit/core/docs/templates/bkit-audit-usability.md +113 -71
  68. package/.bkit/core/docs/templates/bkit-plan.md +138 -132
  69. package/.bkit/core/engine/checks/after/auth.ts +40 -37
  70. package/.bkit/core/engine/checks/after/ci-yml.ts +65 -2
  71. package/.bkit/core/engine/checks/after/index.ts +12 -2
  72. package/.bkit/core/engine/checks/after/tools.ts +80 -33
  73. package/.bkit/core/engine/checks/before/context-fetch.ts +227 -33
  74. package/.bkit/core/engine/checks/before/env.ts +1 -1
  75. package/.bkit/core/engine/checks/before/index.ts +7 -0
  76. package/.bkit/core/engine/checks/before/repo.ts +40 -0
  77. package/.bkit/core/engine/checks/status-holes.ts +916 -123
  78. package/.bkit/core/engine/checks/tips/catalogue.ts +68 -17
  79. package/.bkit/core/engine/checks/tips/detect.ts +32 -0
  80. package/.bkit/core/engine/checks/tips/index.ts +47 -6
  81. package/.bkit/core/engine/cli.ts +238 -84
  82. package/.bkit/core/engine/commands/analysis.ts +128 -76
  83. package/.bkit/core/engine/commands/ci/ci.ts +363 -29
  84. package/.bkit/core/engine/commands/ci/pins.ts +172 -0
  85. package/.bkit/core/engine/commands/ci/push-gate.ts +223 -0
  86. package/.bkit/core/engine/commands/install/uninstall.ts +21 -27
  87. package/.bkit/core/engine/commands/install/upgrade.ts +32 -15
  88. package/.bkit/core/engine/commands/land.ts +126 -11
  89. package/.bkit/core/engine/commands/lib.ts +303 -6
  90. package/.bkit/core/engine/commands/registry.ts +6 -2
  91. package/.bkit/core/engine/commands/setup/setup.ts +1 -0
  92. package/.bkit/core/engine/commands/stats.ts +91 -35
  93. package/.bkit/core/engine/commands/workflow/branches.ts +1477 -117
  94. package/.bkit/core/engine/commands/workflow/challenge.ts +114 -39
  95. package/.bkit/core/engine/commands/workflow/completeness.ts +109 -0
  96. package/.bkit/core/engine/commands/workflow/context.ts +433 -55
  97. package/.bkit/core/engine/commands/workflow/counters.ts +244 -39
  98. package/.bkit/core/engine/commands/workflow/decisions.ts +61 -17
  99. package/.bkit/core/engine/commands/workflow/disk.ts +237 -55
  100. package/.bkit/core/engine/commands/workflow/fids.ts +19 -1
  101. package/.bkit/core/engine/commands/workflow/issues.ts +6 -0
  102. package/.bkit/core/engine/commands/workflow/ledgers.ts +458 -18
  103. package/.bkit/core/engine/commands/workflow/locks.ts +2 -0
  104. package/.bkit/core/engine/commands/workflow/plan-blocks.ts +124 -15
  105. package/.bkit/core/engine/commands/workflow/plans.ts +257 -0
  106. package/.bkit/core/engine/commands/workflow/prs.ts +12 -3
  107. package/.bkit/core/engine/commands/workflow/repo.ts +8 -0
  108. package/.bkit/core/engine/commands/workflow/roadmap.ts +56 -15
  109. package/.bkit/core/engine/commands/workflow/run-facts.ts +22 -31
  110. package/.bkit/core/engine/commands/workflow/runs.ts +652 -34
  111. package/.bkit/core/engine/commands/workflow/runtime.ts +3 -0
  112. package/.bkit/core/engine/commands/workflow/skills.ts +1 -0
  113. package/.bkit/core/engine/commands/workflow/status.ts +200 -17
  114. package/.bkit/core/engine/commands/workflow/step-table.ts +75 -33
  115. package/.bkit/core/engine/commands/workflow/steps.ts +635 -24
  116. package/.bkit/core/engine/commands/workflow/summary-findings.ts +177 -0
  117. package/.bkit/core/engine/commands/workflow/summary.ts +192 -46
  118. package/.bkit/core/engine/commands/workflow/tasks.ts +409 -0
  119. package/.bkit/core/engine/commands/workflow/test-blocks.ts +254 -0
  120. package/.bkit/core/engine/commands/workflow/tests-changed.ts +201 -0
  121. package/.bkit/core/engine/commands/workflow/tests.ts +1285 -356
  122. package/.bkit/core/engine/commands/workflow/workflows.ts +228 -43
  123. package/.bkit/core/engine/commands/workflow/worktrees.ts +389 -47
  124. package/.bkit/core/engine/install/cloud-env.ts +251 -121
  125. package/.bkit/core/engine/install/context-ci-workflow.ts +102 -0
  126. package/.bkit/core/engine/install/manifest.ts +60 -12
  127. package/.bkit/core/engine/install/modules/antigravity.ts +3 -2
  128. package/.bkit/core/engine/install/modules/cloud.ts +3 -3
  129. package/.bkit/core/engine/install/modules/codex.ts +15 -2
  130. package/.bkit/core/engine/install/modules/core.ts +956 -52
  131. package/.bkit/core/engine/install/modules/cursor.ts +6 -6
  132. package/.bkit/core/engine/install/modules/opencode.ts +16 -4
  133. package/.bkit/core/engine/install/template-notes.ts +130 -0
  134. package/.bkit/core/engine/install/version-file.ts +3 -2
  135. package/.bkit/core/engine/install/write.ts +5 -0
  136. package/.bkit/core/engine/ledgers/compact.ts +124 -0
  137. package/.bkit/core/engine/ledgers/journal.ts +291 -0
  138. package/.bkit/core/engine/ledgers/status.ts +160 -9
  139. package/.bkit/core/engine/ledgers/telemetry.ts +158 -21
  140. package/.bkit/core/engine/render/hosts.ts +114 -14
  141. package/.bkit/core/engine/shared/bkit-latest.ts +26 -4
  142. package/.bkit/core/engine/shared/dep-updater.ts +60 -0
  143. package/.bkit/core/engine/shared/egress.ts +1 -1
  144. package/.bkit/core/engine/shared/package-manager.ts +9 -0
  145. package/.bkit/core/engine/shared/settings.ts +92 -17
  146. package/.bkit/core/engine/shared/timeouts.ts +2 -0
  147. package/.bkit/core/engine/tools/cli-doc.ts +111 -0
  148. package/.bkit/core/engine/tools/grammar-density.ts +1 -1
  149. package/.bkit/core/engine/tools/instructions-sources.ts +15 -17
  150. package/.bkit/core/engine/tools/instructions.ts +94 -43
  151. package/.bkit/core/hooks/antigravity-hook.js +25 -10
  152. package/.bkit/core/hooks/gateguard-engine.js +53 -29
  153. package/.bkit/core/hooks/guardrails-shell.js +4 -4
  154. package/.bkit/core/hooks/guardrails-tiers.js +3 -3
  155. package/.bkit/core/hooks/preflight-linear.sh +9 -9
  156. package/.bkit/core/hooks/preflight-rules.sh +8 -0
  157. package/.bkit/core/hooks/readguard-engine.js +29 -10
  158. package/.bkit/core/hooks/session-rules-advisory.js +61 -0
  159. package/.bkit/core/prompts/bkit-audit-generate.md +187 -116
  160. package/.bkit/core/prompts/bkit-build-challenge-1.md +56 -37
  161. package/.bkit/core/prompts/bkit-build-challenge-2.md +65 -45
  162. package/.bkit/core/prompts/bkit-build-install-skills.md +38 -29
  163. package/.bkit/core/prompts/bkit-build-plan-convert.md +43 -32
  164. package/.bkit/core/prompts/bkit-build-plan-current.md +49 -39
  165. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +79 -55
  166. package/.bkit/core/prompts/bkit-build-plan-tasks.md +149 -0
  167. package/.bkit/core/prompts/bkit-build-plan-tests.md +120 -0
  168. package/.bkit/core/prompts/bkit-build-plan-verify.md +87 -50
  169. package/.bkit/core/prompts/bkit-debug-abort-handover.md +36 -35
  170. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +96 -64
  171. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +54 -45
  172. package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +42 -33
  173. package/.bkit/core/prompts/bkit-debug-failure-soak.md +53 -37
  174. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +35 -30
  175. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +34 -29
  176. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +32 -28
  177. package/.bkit/core/prompts/bkit-design-generate.md +68 -52
  178. package/.bkit/core/prompts/bkit-design-organise.md +73 -35
  179. package/.bkit/core/prompts/bkit-design-review-1.md +58 -54
  180. package/.bkit/core/prompts/bkit-design-review-2.md +54 -50
  181. package/.bkit/core/prompts/bkit-design-spike.md +54 -47
  182. package/.bkit/core/prompts/bkit-design-update.md +42 -31
  183. package/.bkit/core/prompts/bkit-plan-generate.md +76 -58
  184. package/.bkit/core/prompts/bkit-plan-review-1.md +63 -49
  185. package/.bkit/core/prompts/bkit-plan-review-2.md +60 -48
  186. package/.bkit/core/prompts/bkit-plan-scope-check.md +53 -46
  187. package/.bkit/core/prompts/bkit-plan-update.md +70 -52
  188. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +82 -50
  189. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +80 -45
  190. package/.bkit/core/prompts/bkit-ship-update-docs.md +35 -29
  191. package/.bkit/core/prompts/bkit-utility-compress-markdown.md +55 -49
  192. package/.bkit/core/prompts/bkit-utility-update-decisions.md +76 -49
  193. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +70 -41
  194. package/.bkit/core/prompts/bkit-utility-update-documentation.md +33 -30
  195. package/.bkit/core/prompts/bkit-utility-update-failures.md +73 -43
  196. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +77 -50
  197. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +77 -45
  198. package/.bkit/core/prompts/bkit-utility-update-tracker.md +144 -68
  199. package/.bkit/core/workflows/bkit-auto.md +53 -30
  200. package/.bkit/core/workflows/bkit-build.md +635 -304
  201. package/.bkit/core/workflows/bkit-debug.md +301 -148
  202. package/.bkit/core/workflows/bkit-design.md +167 -95
  203. package/.bkit/core/workflows/bkit-plan.md +172 -84
  204. package/.bkit/core/workflows/bkit-ship.md +299 -152
  205. package/.bkit/shared/.agents/plugins/bkit/hooks.json +10 -0
  206. package/.bkit/shared/.claude/bkit-cloud.md +12 -10
  207. package/.bkit/shared/.claude/settings.json +3 -0
  208. package/.bkit/shared/.codex/bkit-cloud.md +98 -0
  209. package/.bkit/shared/.codex/hooks.json +20 -0
  210. package/.bkit/shared/.cursor/bkit-cloud.md +3 -3
  211. package/.bkit/shared/.opencode/opencode.json +1 -1
  212. package/.bkit/shared/CLAUDE.md +5 -1
  213. package/.bkit/shared/GEMINI.md +4 -1
  214. package/.bkit/shared/docs/architecture.md +4 -7
  215. package/.bkit/shared/docs/data-schema.md +4 -7
  216. package/.bkit/shared/docs/deployments.md +239 -166
  217. package/.bkit/shared/docs/design.md +11 -12
  218. package/.bkit/shared/docs/noise.md +8 -7
  219. package/.bkit/shared/docs/observability.md +5 -8
  220. package/.bkit/shared/docs/security.md +35 -17
  221. package/.bkit/shared/docs/setup.md +29 -18
  222. package/.bkit/shared/docs/technology.md +3 -6
  223. package/.bkit/shared/docs/testing.md +282 -176
  224. package/.bkit/shared/gitignore +6 -2
  225. package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +15 -16
  226. package/.bkit/templates/.cursor/Dockerfile +12 -8
  227. package/.bkit/templates/.cursor/environment.json +1 -1
  228. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +10 -8
  229. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +24 -12
  230. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +3 -3
  231. package/.bkit/templates/.github/renovate.json5 +34 -6
  232. package/.bkit/templates/.github/workflows/bkit-ci.yml +53 -50
  233. package/.bkit/templates/.github/workflows/bkit-cloud.yml +13 -14
  234. package/.bkit/templates/.github/workflows/bkit-health.yml +97 -0
  235. package/.bkit/templates/.github/workflows/bkit-renovate.yml +5 -4
  236. package/.bkit/templates/.github/workflows/bkit-trivy.yml +5 -4
  237. package/.bkit/templates/.husky/pre-commit +2 -2
  238. package/.bkit/templates/.husky/pre-push +95 -35
  239. package/.bkit/templates/.prettierignore +6 -7
  240. package/.bkit/templates/.vale.ini +27 -27
  241. package/.bkit/templates/context/bkit-cloudrun.md +23 -15
  242. package/.bkit/templates/context/bkit-expo.md +70 -52
  243. package/.bkit/templates/context/bkit-github.md +93 -56
  244. package/.bkit/templates/context/bkit-inngest.md +21 -15
  245. package/.bkit/templates/context/bkit-maestro.md +22 -16
  246. package/.bkit/templates/context/bkit-playwright.md +23 -17
  247. package/.bkit/templates/context/bkit-resend.md +12 -10
  248. package/.bkit/templates/context/bkit-sentry.md +30 -20
  249. package/.bkit/templates/context/bkit-serena.md +8 -7
  250. package/.bkit/templates/context/bkit-stripe.md +14 -13
  251. package/.bkit/templates/context/bkit-supabase.md +16 -13
  252. package/.bkit/templates/context/bkit-tavily.md +14 -11
  253. package/.bkit/templates/context/bkit-vercel.md +27 -18
  254. package/.bkit/templates/docs/capabilities.md +15 -14
  255. package/.bkit/templates/scripts/ci/{check-accepted-divergences.mjs → bkit-check-accepted-divergences.mjs} +6 -3
  256. package/.bkit/templates/scripts/ci/{check-accepted-divergences.test.mjs → bkit-check-accepted-divergences.test.mjs} +3 -3
  257. package/.bkit/templates/scripts/ci/{check-capstone.mjs → bkit-check-capstone.mjs} +2 -2
  258. package/.bkit/templates/scripts/ci/{check-capstone.test.mjs → bkit-check-capstone.test.mjs} +4 -4
  259. package/.bkit/templates/scripts/ci/{check-dependency-audit.mjs → bkit-check-dependency-audit.mjs} +103 -18
  260. package/.bkit/templates/scripts/ci/{check-dependency-audit.test.mjs → bkit-check-dependency-audit.test.mjs} +31 -3
  261. package/.bkit/templates/scripts/ci/bkit-machine-lock.sh +387 -0
  262. package/.bkit/templates/scripts/ci/bkit-test-awake.mjs +75 -0
  263. package/.bkit/templates/scripts/ci/bkit-test-awake.test.mjs +160 -0
  264. package/.bkit/templates/scripts/ci/lanes/{resolve-push-base.mjs → bkit-resolve-push-base.mjs} +3 -3
  265. package/.bkit/templates/scripts/ci/lanes/{resolve-push-base.test.mjs → bkit-resolve-push-base.test.mjs} +4 -4
  266. package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +9 -1
  267. package/.bkit/templates/scripts/graphify/bkit-graph-drift.py +1 -1
  268. package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +3 -3
  269. package/.bkit/templates/scripts/graphify/bkit-graph-embed.py +63 -0
  270. package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +2 -2
  271. package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +69 -18
  272. package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -3
  273. package/.bkit/templates/scripts/graphify/bkit-graph-surface.py +1 -1
  274. package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +1 -1
  275. package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +197 -126
  276. package/.bkit/templates/scripts/graphify/bkit-graphify.sh +64 -41
  277. package/.bkit/templates/scripts/slop/bkit-slop-type-suppression.mjs +23 -7
  278. package/.bkit/templates/slop-scan.config.json +9 -2
  279. package/CHANGELOG.md +119 -0
  280. package/README.md +250 -76
  281. package/dist/checks/after/auth.js +36 -33
  282. package/dist/checks/after/ci-yml.js +52 -2
  283. package/dist/checks/after/index.js +12 -4
  284. package/dist/checks/after/tools.js +73 -33
  285. package/dist/checks/before/context-fetch.js +218 -33
  286. package/dist/checks/before/env.js +1 -1
  287. package/dist/checks/before/index.js +6 -2
  288. package/dist/checks/before/repo.js +35 -1
  289. package/dist/checks/status-holes.js +739 -114
  290. package/dist/checks/tips/catalogue.js +59 -17
  291. package/dist/checks/tips/detect.js +30 -0
  292. package/dist/checks/tips/index.js +48 -6
  293. package/dist/cli.js +222 -84
  294. package/dist/commands/analysis.js +77 -53
  295. package/dist/commands/ci/ci.js +302 -25
  296. package/dist/commands/ci/pins.js +142 -0
  297. package/dist/commands/ci/push-gate.js +194 -0
  298. package/dist/commands/install/uninstall.js +23 -27
  299. package/dist/commands/install/upgrade.js +21 -11
  300. package/dist/commands/land.js +126 -10
  301. package/dist/commands/lib.js +244 -5
  302. package/dist/commands/registry.js +6 -2
  303. package/dist/commands/setup/setup.js +1 -0
  304. package/dist/commands/stats.js +69 -30
  305. package/dist/commands/workflow/branches.js +1232 -111
  306. package/dist/commands/workflow/challenge.js +90 -37
  307. package/dist/commands/workflow/completeness.js +97 -0
  308. package/dist/commands/workflow/context.js +371 -51
  309. package/dist/commands/workflow/counters.js +206 -40
  310. package/dist/commands/workflow/decisions.js +60 -17
  311. package/dist/commands/workflow/disk.js +213 -55
  312. package/dist/commands/workflow/fids.js +18 -1
  313. package/dist/commands/workflow/issues.js +6 -0
  314. package/dist/commands/workflow/ledgers.js +372 -21
  315. package/dist/commands/workflow/locks.js +2 -0
  316. package/dist/commands/workflow/plan-blocks.js +78 -14
  317. package/dist/commands/workflow/plans.js +205 -0
  318. package/dist/commands/workflow/prs.js +12 -3
  319. package/dist/commands/workflow/repo.js +6 -0
  320. package/dist/commands/workflow/roadmap.js +50 -17
  321. package/dist/commands/workflow/run-facts.js +23 -28
  322. package/dist/commands/workflow/runs.js +530 -33
  323. package/dist/commands/workflow/runtime.js +3 -0
  324. package/dist/commands/workflow/skills.js +1 -0
  325. package/dist/commands/workflow/status.js +166 -19
  326. package/dist/commands/workflow/step-table.js +61 -29
  327. package/dist/commands/workflow/steps.js +542 -26
  328. package/dist/commands/workflow/summary-findings.js +117 -0
  329. package/dist/commands/workflow/summary.js +154 -41
  330. package/dist/commands/workflow/tasks.js +378 -0
  331. package/dist/commands/workflow/test-blocks.js +231 -0
  332. package/dist/commands/workflow/tests-changed.js +172 -0
  333. package/dist/commands/workflow/tests.js +1013 -321
  334. package/dist/commands/workflow/workflows.js +191 -38
  335. package/dist/commands/workflow/worktrees.js +310 -42
  336. package/dist/install/cloud-env.js +233 -99
  337. package/dist/install/context-ci-workflow.js +85 -0
  338. package/dist/install/manifest.js +57 -12
  339. package/dist/install/modules/antigravity.js +3 -2
  340. package/dist/install/modules/cloud.js +3 -3
  341. package/dist/install/modules/codex.js +12 -2
  342. package/dist/install/modules/core.js +851 -53
  343. package/dist/install/modules/cursor.js +6 -6
  344. package/dist/install/modules/opencode.js +11 -5
  345. package/dist/install/template-notes.js +116 -0
  346. package/dist/install/version-file.js +3 -2
  347. package/dist/ledgers/compact.js +87 -0
  348. package/dist/ledgers/journal.js +233 -0
  349. package/dist/ledgers/status.js +115 -5
  350. package/dist/ledgers/telemetry.js +121 -17
  351. package/dist/render/hosts.js +100 -14
  352. package/dist/shared/bkit-latest.js +26 -4
  353. package/dist/shared/dep-updater.js +49 -0
  354. package/dist/shared/egress.js +1 -1
  355. package/dist/shared/package-manager.js +6 -0
  356. package/dist/shared/settings.js +59 -10
  357. package/dist/shared/timeouts.js +2 -0
  358. package/dist/tools/cli-doc.js +97 -0
  359. package/dist/tools/grammar-density.js +1 -1
  360. package/dist/tools/instructions-sources.js +15 -16
  361. package/dist/tools/instructions.js +83 -39
  362. package/package.json +58 -42
  363. package/.bkit/core/.bkit/lite.md +0 -73
  364. package/.bkit/core/engine/commands/workflow/workstreams.ts +0 -172
  365. package/.bkit/core/prompts/bkit-build-plan-execute.md +0 -124
  366. package/.bkit/templates/scripts/ci/bkit-local-stack-lock.sh +0 -194
  367. package/dist/commands/workflow/workstreams.js +0 -149
  368. /package/.bkit/templates/.vale/styles/{House → Bkit}/Filler.yml +0 -0
  369. /package/.bkit/templates/.vale/styles/{House → Bkit}/Hedging.yml +0 -0
  370. /package/.bkit/templates/.vale/styles/{House → Bkit}/LLMSlop.yml +0 -0
  371. /package/.bkit/templates/.vale/styles/{House → Bkit}/Verbose.yml +0 -0
  372. /package/.bkit/templates/scripts/ci/{accepted-advisories.json → bkit-accepted-advisories.json} +0 -0
  373. /package/.bkit/templates/scripts/ci/{accepted-divergences.json → bkit-accepted-divergences.json} +0 -0
  374. /package/.bkit/templates/scripts/launchd/{launchd.env.example → bkit-launchd.env.example} +0 -0
  375. /package/.bkit/templates/scripts/launchd/{ai.bkit.launchd.plist → bkit-launchd.plist} +0 -0
@@ -10,20 +10,32 @@ import {
10
10
  writeBkitVersion,
11
11
  hashFile,
12
12
  mergeCanonicalHashes,
13
+ sha256,
13
14
  } from "../version-file.js";
14
- import { extractManagedBlock, stripManagedBlock } from "../managed-block.js";
15
+ import {
16
+ extractManagedBlock,
17
+ findLineAnchoredMarkers,
18
+ selectMarkers,
19
+ stripManagedBlock,
20
+ } from "../managed-block.js";
15
21
  import type { TokenMap } from "../placeholders.js";
16
22
  import { listFilesRecursive, syncTemplateCopies } from "../template-copies.js";
17
23
  import { PAYLOAD_LINK_RELPATHS, syncPayloadLinks } from "../payload-links.js";
18
24
  import { writeNetworkAllowlist } from "../network-allowlist.js";
25
+ import { migrateContextCiWorkflow } from "../context-ci-workflow.js";
26
+ import { migrateTemplateNotes } from "../template-notes.js";
19
27
  import type { PreflightFinding } from "../../checks/before/index.js";
28
+ import { isAdvisorySuppressed } from "../../checks/after/suppression.js";
20
29
  import { parseJson, readJsonFile } from "../../shared/json.js";
21
30
  import { readInstallingVersion } from "../../shared/package-json.js";
22
- import { ASK_POINTS, CONFIG_DEFAULTS, limitKey } from "../../shared/settings.js";
31
+ import { detectDepUpdater, type DepUpdater } from "../../shared/dep-updater.js";
32
+ import { ASK_POINTS, CONFIG_DEFAULTS, ciWorkflowPath, limitKey } from "../../shared/settings.js";
33
+ import { CI_SCRIPT_UNITS } from "../../checks/after/ci-yml.js";
23
34
  import {
24
35
  getCoreRoot,
25
36
  getSharedRoot,
26
37
  getBkitDocsRoot,
38
+ getTemplatesRoot,
27
39
  TEMPLATE_COPIES_DIR,
28
40
  } from "../../shared/package-roots.js";
29
41
  import {
@@ -31,6 +43,8 @@ import {
31
43
  BKIT_GATE_SCRIPTS,
32
44
  BKIT_OPTIONAL_GATES,
33
45
  BKIT_PUSH_GATES,
46
+ BKIT_GATE_CHANGED_SCRIPT,
47
+ BKIT_LINT_FILE_SCRIPT,
34
48
  BKIT_TEST_FILE_SCRIPT,
35
49
  } from "../manifest.js";
36
50
  import { migrateLedgers } from "../../ledgers/migrate.js";
@@ -256,20 +270,33 @@ function runCoreTemplates(
256
270
  export const BKIT_CANONICAL_DOCS = [
257
271
  "authoring.md",
258
272
  "cloud.md",
273
+ "cli.md",
259
274
  "comparison.md",
260
275
  "install.md",
261
276
  "jsonl.md",
262
277
  "LICENSE.md",
263
- "lite.md",
264
278
  "pipeline.md",
265
279
  "providers.md",
266
280
  "prompts.md",
281
+ "router.md",
267
282
  "templates.md",
268
283
  "trackers.md",
269
284
  "workflows.md",
270
285
  "README.md",
271
286
  ] as const;
272
287
 
288
+ // The token map for `.bkit/*.md` docs: only `{{BKIT_MANAGED_MARKER}}` resolves. The other
289
+ // tokens map to themselves, so a doc that tells the consumer which token to replace in a
290
+ // template (`templates.md`) still names the token.
291
+ export function bkitDocTokens(tokens: TokenMap): TokenMap {
292
+ return {
293
+ ...tokens,
294
+ DEFAULT_BRANCH: "{{DEFAULT_BRANCH}}",
295
+ PROJECT_NAME: "{{PROJECT_NAME}}",
296
+ REPO_SLUG: "{{REPO_SLUG}}",
297
+ };
298
+ }
299
+
273
300
  // Mirror the package's canonical `.bkit/*.md` docs into the consumer's `.bkit/`.
274
301
  // Tier 1 (force-overwrite + ws-tracked for dry-run/install parity). Each source carries
275
302
  // the `{{BKIT_MANAGED_MARKER}}` token. Skipped in dogfood: the consumer destination
@@ -282,6 +309,7 @@ export function runBkitDocs(
282
309
  ): void {
283
310
  const tag = dryRun ? "[dry-run] " : "";
284
311
  const docsRoot = getBkitDocsRoot();
312
+ const docTokens = bkitDocTokens(tokens);
285
313
  // Per-doc write strategy from the manifest: markered-text docs (e.g. prompts.md,
286
314
  // which carries the consumer-owned `## Model Overrides` section below `bkit:end`)
287
315
  // are block-merged so consumer content survives; the rest are force-overwritten.
@@ -294,18 +322,72 @@ export function runBkitDocs(
294
322
  const dstPath = path.join(".bkit", name);
295
323
  const prevLen = ws.writes.length;
296
324
  if (formatByPath.get(path.join(".bkit", name)) === "markered-text") {
297
- writeTier2(srcPath, dstPath, tokens, "html-comment", dryRun, ws);
325
+ writeTier2(srcPath, dstPath, docTokens, "html-comment", dryRun, ws);
298
326
  } else {
299
- writeTier1(srcPath, dstPath, tokens, dryRun, ws);
327
+ writeTier1(srcPath, dstPath, docTokens, dryRun, ws);
300
328
  }
301
329
  if (ws.writes.length > prevLen) {
302
330
  console.log(`${logPrefix} ${tag}core: ${dstPath}`);
303
331
  }
304
332
  }
305
- migrateShortcutsToLite(dryRun, ws, logPrefix);
333
+ migrateRetiredLite(dryRun, ws, logPrefix);
306
334
  migrateRetiredDevLock(dryRun, ws, logPrefix);
307
335
  migrateLedgerSchema(dryRun, ws, logPrefix);
308
336
  migrateJiraKeyName(dryRun, logPrefix);
337
+ migrateModelOverrideAgentNames(dryRun, ws, logPrefix);
338
+ migrateTemplateNotes(dryRun, ws, logPrefix);
339
+ migrateContextCiWorkflow(dryRun, ws, logPrefix);
340
+ migrateSlopTypeSuppression(dryRun, ws, logPrefix);
341
+ const renames = migrateBrandedTemplateFiles(dryRun, ws, logPrefix);
342
+ migrateBrandedFileTokens(dryRun, ws, logPrefix, renames);
343
+ migrateBrandedCheckNames(dryRun, ws, logPrefix, tokens.DEFAULT_BRANCH);
344
+ migrateValeHouseStyle(dryRun, ws, logPrefix);
345
+ }
346
+
347
+ // Migration (installs up to 6.0.x, `docs/migrations.md`): agents renamed since. A
348
+ // consumer's `## Model Overrides` row below `bkit:end` in `.bkit/prompts.md` naming an
349
+ // old agent is renamed in place, provider and model kept, so the override keeps applying
350
+ // (`parseModelOverrides` reports a row naming no agent as unknown and skips it). Runs
351
+ // after the docs loop, which block-merges the file and leaves the consumer region alone.
352
+ // A row already naming the new agent wins: the old row is then left for the unknown
353
+ // report. Recorded in ws as an update; the canonical hash covers the managed block only.
354
+ const PROMPTS_FILE = path.join(".bkit", "prompts.md");
355
+ const MODEL_OVERRIDES_HEADING = "## Model Overrides";
356
+ export const RENAMED_AGENTS: Readonly<Record<string, string>> = {
357
+ "bkit-build-plan-execute": "bkit-build-plan-tasks",
358
+ };
359
+
360
+ export function migrateModelOverrideAgentNames(
361
+ dryRun: boolean,
362
+ ws: WriteSet,
363
+ logPrefix: string,
364
+ ): void {
365
+ if (!fs.existsSync(PROMPTS_FILE)) return;
366
+ const text = fs.readFileSync(PROMPTS_FILE, "utf-8");
367
+ const endIdx = findLineAnchoredMarkers(text, selectMarkers("html-comment")[1])[0];
368
+ if (endIdx === undefined) return;
369
+ const headingAt = text.indexOf(MODEL_OVERRIDES_HEADING, endIdx);
370
+ if (headingAt === -1) return;
371
+ const head = text.slice(0, headingAt);
372
+ const lines = text.slice(headingAt).split("\n");
373
+ // The first cell of a table row, backticks and padding aside.
374
+ const promptCell = (line: string): string | undefined =>
375
+ /^\s*\|/.test(line) ? line.split("|")[1]?.trim().replace(/^`|`$/g, "") : undefined;
376
+ const named = new Set(lines.map(promptCell).filter((c): c is string => c !== undefined));
377
+ const renamed: string[] = [];
378
+ const out = lines.map((line) => {
379
+ const cell = promptCell(line);
380
+ const to = cell === undefined ? undefined : RENAMED_AGENTS[cell];
381
+ if (cell === undefined || to === undefined || named.has(to)) return line;
382
+ renamed.push(`${cell} -> ${to}`);
383
+ return line.replace(cell, to);
384
+ });
385
+ if (renamed.length === 0) return;
386
+ if (!dryRun) fs.writeFileSync(PROMPTS_FILE, head + out.join("\n"), "utf-8");
387
+ ws.writes.push({ path: PROMPTS_FILE, action: "update" });
388
+ console.log(
389
+ `${logPrefix} ${dryRun ? "[dry-run] " : ""}core: ${PROMPTS_FILE} — Model Overrides renamed: ${renamed.join(", ")}`,
390
+ );
309
391
  }
310
392
 
311
393
  // Migration (installs up to 5.5.x, `docs/migrations.md`): the Jira key was
@@ -328,41 +410,86 @@ export function migrateJiraKeyName(dryRun: boolean, logPrefix: string): void {
328
410
  );
329
411
  }
330
412
 
331
- // Migration (5.1.0 – 5.2.4 installs, `docs/migrations.md`): the lite workflows lived at
332
- // `.agents/shortcuts.md`. The consumer's own lines below `bkit:end` (minus the seeded
333
- // heading) move under `.bkit/lite.md`'s consumer section; the old file is deleted. Runs
334
- // after the docs loop, so `.bkit/lite.md` is already written. The delete is recorded in
335
- // ws (as orphan-mirror deletes are) so `bkit check` fails until upgrade runs.
413
+ // Migration (5.1.0 – 6.0.x installs, `docs/migrations.md`): the lite workflows are retired.
414
+ // The managed block of `.bkit/lite.md` (and of its 5.1.0 – 5.2.4 predecessor
415
+ // `.agents/shortcuts.md`) is stripped; the consumer's own lines (minus the seeded headings)
416
+ // land in `.bkit/lite.md` under a sentinel first line, or the file is deleted when none
417
+ // remain. A file holding the sentinel and no managed block is the already-retired stub:
418
+ // silent, no write. A blockless or multi-block `.bkit/lite.md` is left byte-for-byte with
419
+ // a logged fix. Writes are recorded in ws (dry-run parity; `bkit check` fails until upgrade).
420
+ export const RETIRED_LITE_STUB_SENTINEL = "<!-- bkit:retired-lite-stub -->";
336
421
  const RETIRED_SHORTCUTS = path.join(".agents", "shortcuts.md");
337
422
  const RETIRED_SHORTCUTS_HEADING = "## Project Shortcuts";
423
+ const RETIRED_LITE = path.join(".bkit", "lite.md");
424
+ const RETIRED_LITE_HEADING = "## Project Lite Workflows";
425
+
426
+ /** The consumer lines left once the managed block and the given seeded heading are removed. */
427
+ function consumerLines(text: string, heading: string): string {
428
+ const lines = stripManagedBlock(text, "html-comment").split("\n");
429
+ return lines
430
+ .filter((line) => line.trim() !== heading)
431
+ .join("\n")
432
+ .trim();
433
+ }
338
434
 
339
- export function migrateShortcutsToLite(dryRun: boolean, ws: WriteSet, logPrefix: string): void {
340
- if (!fs.existsSync(RETIRED_SHORTCUTS)) return;
341
- if (!fs.existsSync(path.join(getBkitDocsRoot(), "lite.md"))) return;
435
+ export function migrateRetiredLite(dryRun: boolean, ws: WriteSet, logPrefix: string): void {
436
+ const hasShortcuts = fs.existsSync(RETIRED_SHORTCUTS);
437
+ const hasLite = fs.existsSync(RETIRED_LITE);
438
+ if (!hasShortcuts && !hasLite) return;
342
439
  const tag = dryRun ? "[dry-run] " : "";
343
- const dst = path.join(".bkit", "lite.md");
344
- const old = fs.readFileSync(RETIRED_SHORTCUTS, "utf-8");
345
- if (extractManagedBlock(old, "html-comment") === null) {
346
- console.warn(
347
- `${logPrefix} ${RETIRED_SHORTCUTS} has no single bkit managed block — left in place. Move your own lines into ${dst} below \`<!-- bkit:end -->\`, then delete it.`,
348
- );
349
- return;
440
+
441
+ let liteOwn = "";
442
+ let liteIsManaged = false;
443
+ if (hasLite) {
444
+ const lite = fs.readFileSync(RETIRED_LITE, "utf-8");
445
+ if (extractManagedBlock(lite, "html-comment") !== null) {
446
+ liteIsManaged = true;
447
+ liteOwn = consumerLines(lite, RETIRED_LITE_HEADING);
448
+ } else if (lite.split("\n")[0]?.trim() === RETIRED_LITE_STUB_SENTINEL) {
449
+ liteOwn = lite.slice(lite.indexOf("\n") + 1).trim();
450
+ } else {
451
+ console.warn(
452
+ `${logPrefix} ${RETIRED_LITE} has no single bkit managed block — left in place. The lite workflows are retired: keep your own lines in it (or in your own docs) and delete any leftover bkit-managed text.`,
453
+ );
454
+ return;
455
+ }
350
456
  }
351
- const own = stripManagedBlock(old, "html-comment")
352
- .split("\n")
353
- .filter((line) => line.trim() !== RETIRED_SHORTCUTS_HEADING)
354
- .join("\n")
355
- .trim();
356
- if (own.length > 0) {
357
- if (!dryRun) {
358
- const current = fs.readFileSync(dst, "utf-8");
359
- fs.writeFileSync(dst, `${current.replace(/\n*$/, "\n\n")}${own}\n`, "utf-8");
457
+
458
+ let shortcutsOwn = "";
459
+ let shortcutsMovable = false;
460
+ if (hasShortcuts) {
461
+ const old = fs.readFileSync(RETIRED_SHORTCUTS, "utf-8");
462
+ if (extractManagedBlock(old, "html-comment") === null) {
463
+ console.warn(
464
+ `${logPrefix} ${RETIRED_SHORTCUTS} has no single bkit managed block — left in place. Move your own lines into ${RETIRED_LITE}, then delete it.`,
465
+ );
466
+ } else {
467
+ shortcutsMovable = true;
468
+ shortcutsOwn = consumerLines(old, RETIRED_SHORTCUTS_HEADING);
360
469
  }
361
- ws.writes.push({ path: dst, action: "update" });
362
470
  }
363
- if (!dryRun) fs.rmSync(RETIRED_SHORTCUTS);
364
- ws.writes.push({ path: RETIRED_SHORTCUTS, action: "write" });
365
- console.log(`${logPrefix} ${tag}core: moved ${RETIRED_SHORTCUTS} → ${dst}`);
471
+
472
+ const own = [liteOwn, shortcutsOwn].filter((part) => part.length > 0).join("\n\n");
473
+ const stubText = `${RETIRED_LITE_STUB_SENTINEL}\n\n${own}\n`;
474
+ const liteChanges = liteIsManaged || (own.length > 0 && shortcutsOwn.length > 0);
475
+ if (liteChanges) {
476
+ if (own.length > 0) {
477
+ if (!dryRun) {
478
+ fs.mkdirSync(path.dirname(RETIRED_LITE), { recursive: true });
479
+ fs.writeFileSync(RETIRED_LITE, stubText, "utf-8");
480
+ }
481
+ ws.writes.push({ path: RETIRED_LITE, action: hasLite ? "update" : "write" });
482
+ } else if (hasLite) {
483
+ if (!dryRun) fs.rmSync(RETIRED_LITE);
484
+ ws.writes.push({ path: RETIRED_LITE, action: "write" });
485
+ }
486
+ console.log(`${logPrefix} ${tag}core: retired ${RETIRED_LITE}`);
487
+ }
488
+ if (shortcutsMovable) {
489
+ if (!dryRun) fs.rmSync(RETIRED_SHORTCUTS);
490
+ ws.writes.push({ path: RETIRED_SHORTCUTS, action: "write" });
491
+ console.log(`${logPrefix} ${tag}core: retired ${RETIRED_SHORTCUTS}`);
492
+ }
366
493
  }
367
494
 
368
495
  // Migration (installs up to 5.3.x, `docs/migrations.md`): `.bkit/.dev.lock` was the
@@ -427,10 +554,13 @@ export function seedCorePackageJsonScripts(
427
554
  const tag = dryRun ? "[dry-run] " : "";
428
555
  const written: string[] = [];
429
556
 
557
+ if (migrateBrandedScriptNames(dryRun, ws, logPrefix)) written.push("package.json");
430
558
  const gates = ensurePackageJsonScripts({ ...BKIT_GATE_SCRIPTS }, dryRun, ws);
431
559
  if (gates.added.length > 0) {
432
- written.push("package.json");
433
- console.log(`${logPrefix} ${tag}core: package.json scripts added [${gates.added.join(", ")}]`);
560
+ if (!written.includes("package.json")) written.push("package.json");
561
+ console.log(
562
+ `${logPrefix} ${tag}core: package.json scripts added [${gates.added.join(", ")}] — what a gate may run: .bkit/workflows.md § Local gate scripts`,
563
+ );
434
564
  }
435
565
  if (migrateLinearTeamKey(dryRun, ws, logPrefix) && !written.includes("package.json")) {
436
566
  written.push("package.json");
@@ -441,6 +571,9 @@ export function seedCorePackageJsonScripts(
441
571
  if (migrateBkitLayout(dryRun, ws, logPrefix) && !written.includes("package.json")) {
442
572
  written.push("package.json");
443
573
  }
574
+ if (pruneMinPushPaths(dryRun, ws, logPrefix) && !written.includes("package.json")) {
575
+ written.push("package.json");
576
+ }
444
577
  if (seedBkitDefaults(dryRun, ws, logPrefix) && !written.includes("package.json")) {
445
578
  written.push("package.json");
446
579
  }
@@ -450,7 +583,8 @@ export function seedCorePackageJsonScripts(
450
583
  /**
451
584
  * Every `bkit.*` setting, written on every install and upgrade so consumers see them all;
452
585
  * add-if-missing, nested blocks included. A key with a default gets it; a choice not made
453
- * yet is `""` or `[]`, which every reader treats as unset.
586
+ * yet is `""` or `[]`, which every reader treats as unset. `dependencies.updater` is the one
587
+ * choice install makes: `seedBkitDefaults` fills it from the updater config present.
454
588
  */
455
589
  export const SEEDED_BKIT_DEFAULTS: Readonly<Record<string, unknown>> = {
456
590
  tracker: {
@@ -476,16 +610,24 @@ export const SEEDED_BKIT_DEFAULTS: Readonly<Record<string, unknown>> = {
476
610
  cloud: { agent: "" },
477
611
  providers: { opencode: { default: "", installed: [] } },
478
612
  testing: {
613
+ // What bkit writes (ship's bookkeeping allow-list, the plans tree) is always a min push;
614
+ // the seed adds nothing, because a project doc can be a test's input.
615
+ minPushPaths: [...CONFIG_DEFAULTS.minPushPaths],
479
616
  ciWorkflow: CONFIG_DEFAULTS.ciWorkflow,
480
617
  ciCapstone: CONFIG_DEFAULTS.capstoneJob,
481
- shipGate: [...CONFIG_DEFAULTS.shipGateRequiredLanes],
482
- minPushPaths: [...CONFIG_DEFAULTS.minPushPaths],
618
+ ciRequired: [...CONFIG_DEFAULTS.ciRequired],
619
+ // Project docs ship's [skip ci] bookkeeping commit may carry onto the PR untested; a
620
+ // repo names its own (bkit's: CHANGELOG.md, README.md), so the seed is the empty choice.
621
+ ciSkipPaths: [...CONFIG_DEFAULTS.ciSkipPaths],
622
+ // CI steps whose failure bkit:generate fixes, beyond the floor bkit's own template
623
+ // steps form (CI_GENERATED_FLOOR); a repo names its own, so the seed is the empty choice.
624
+ ciGenerated: [...CONFIG_DEFAULTS.ciGenerated],
483
625
  },
484
626
  workflows: {
485
627
  minFreeGb: CONFIG_DEFAULTS.diskMinFreeGb,
486
628
  worktree: { copy: [...CONFIG_DEFAULTS.worktreeCopy], install: CONFIG_DEFAULTS.worktreeInstall },
487
629
  tasks: { ...CONFIG_DEFAULTS.tasks },
488
- ...askBlocks(),
630
+ ...withBuildPublish(askBlocks()),
489
631
  },
490
632
  // bkit-utility-update-roadmap list length; the prompt falls back to 25 too.
491
633
  prompts: { roadmapNext: 25 },
@@ -504,6 +646,13 @@ function askBlocks(): Record<string, Record<string, Record<string, unknown>>> {
504
646
  return out;
505
647
  }
506
648
 
649
+ /** Merge the `build.publish` choice beside the build ask blocks. */
650
+ function withBuildPublish(
651
+ blocks: Record<string, Record<string, Record<string, unknown>>>,
652
+ ): Record<string, Record<string, unknown>> {
653
+ return { ...blocks, build: { ...blocks.build, publish: { remote: true, local: true } } };
654
+ }
655
+
507
656
  const plainObject = (v: unknown): v is Record<string, unknown> =>
508
657
  v !== null && typeof v === "object" && !Array.isArray(v);
509
658
 
@@ -539,16 +688,33 @@ export function seedBkitDefaults(dryRun: boolean, ws: WriteSet, logPrefix: strin
539
688
  const cfg = (pkg.bkit ?? {}) as Record<string, unknown>;
540
689
  const added: string[] = [];
541
690
  addMissingKeys(cfg, SEEDED_BKIT_DEFAULTS, "bkit.", added);
542
- if (added.length === 0) return false;
691
+ const updater = fillDepUpdater(cfg);
692
+ if (added.length === 0 && !updater) return false;
543
693
  pkg.bkit = cfg;
544
694
  ws.writes.push({ path: pkgPath, action: "update" });
545
695
  if (!dryRun) writePackageJsonLike(raw, pkg);
546
- console.log(
547
- `${logPrefix} ${dryRun ? "[dry-run] " : ""}core: added ${added.join(", ")} to package.json`,
548
- );
696
+ const dry = dryRun ? "[dry-run] " : "";
697
+ if (added.length > 0) {
698
+ console.log(`${logPrefix} ${dry}core: added ${added.join(", ")} to package.json`);
699
+ }
700
+ if (updater) {
701
+ console.log(
702
+ `${logPrefix} ${dry}core: set bkit.dependencies.updater to "${updater}" (its config is present)`,
703
+ );
704
+ }
549
705
  return true;
550
706
  }
551
707
 
708
+ // An empty `dependencies.updater` takes the one updater whose config is present; a set value
709
+ // stays. Returns the updater written, else null.
710
+ function fillDepUpdater(cfg: Record<string, unknown>): DepUpdater | null {
711
+ const deps = cfg.dependencies;
712
+ if (!plainObject(deps) || deps.updater !== "") return null;
713
+ const found = detectDepUpdater(".");
714
+ if (found) deps.updater = found;
715
+ return found;
716
+ }
717
+
552
718
  /** Rewrite package.json with `pkg`, keeping the file's indent and trailing newline. */
553
719
  function writePackageJsonLike(raw: string, pkg: unknown): void {
554
720
  const indentMatch = raw.match(/\n([ \t]+)"/);
@@ -557,6 +723,668 @@ function writePackageJsonLike(raw: string, pkg: unknown): void {
557
723
  fs.writeFileSync("package.json", JSON.stringify(pkg, null, indent) + trailingNewline, "utf-8");
558
724
  }
559
725
 
726
+ // Migration (up to 6.0.x installs, `docs/migrations.md`): the package.json scripts bkit runs
727
+ // carry the `bkit:` prefix. Old name -> new name. A `graph*` key moves only when its value
728
+ // runs bkit's graph scripts; any other `graph*` script is the consumer's own.
729
+ export const BKIT_SCRIPT_RENAMES: Readonly<Record<string, string>> = {
730
+ "lint:prose": "bkit:lint:prose",
731
+ "slop:delta": "bkit:slop:delta",
732
+ graph: "bkit:graph",
733
+ ...Object.fromEntries(
734
+ ["check", "clean", "graphml", "refresh", "rollup", "scoped", "tree", "update"].map((verb) => [
735
+ `graph:${verb}`,
736
+ `bkit:graph:${verb}`,
737
+ ]),
738
+ ),
739
+ };
740
+
741
+ const GRAPH_VALUE_GUARD = "scripts/graphify/bkit-";
742
+
743
+ // The pairs a migration acts on. A pair is inactive when `package.json` holds both keys, or
744
+ // when the old key is a `graph*` script whose value is not bkit's; a pair with neither key
745
+ // is active, so its tokens in other values and in default gate chains are rewritten.
746
+ function activeScriptRenames(
747
+ scripts: Record<string, unknown>,
748
+ renames: Readonly<Record<string, string>>,
749
+ ): { active: Record<string, string>; bothPresent: string[] } {
750
+ const has = (k: string): boolean => Object.prototype.hasOwnProperty.call(scripts, k);
751
+ const active: Record<string, string> = {};
752
+ const bothPresent: string[] = [];
753
+ for (const [oldName, newName] of Object.entries(renames)) {
754
+ if (has(oldName) && has(newName)) {
755
+ bothPresent.push(oldName);
756
+ continue;
757
+ }
758
+ const value = scripts[oldName];
759
+ if (
760
+ has(oldName) &&
761
+ oldName.startsWith("graph") &&
762
+ !(typeof value === "string" && value.includes(GRAPH_VALUE_GUARD))
763
+ ) {
764
+ continue;
765
+ }
766
+ active[oldName] = newName;
767
+ }
768
+ return { active, bothPresent };
769
+ }
770
+
771
+ function isLink(p: string): boolean {
772
+ return fs.lstatSync(p, { throwIfNoEntry: false })?.isSymbolicLink() === true;
773
+ }
774
+
775
+ // True when `p` or any directory above it (within the relative path) is a symlink.
776
+ function linkedPath(p: string): boolean {
777
+ const parts = path.normalize(p).split(path.sep);
778
+ for (let i = 1; i <= parts.length; i++) {
779
+ if (isLink(parts.slice(0, i).join(path.sep))) return true;
780
+ }
781
+ return false;
782
+ }
783
+
784
+ // Exact v6.0.0 template bytes, also present immediately before 22d6b75f3.
785
+ const RETIRED_SLOP_PLUGIN_HASH = "3748c27577fb384118c4754378038e3d68d087c28fb314a85b7d427f6093292d";
786
+
787
+ // Migration (up to 6.0.x installs, docs/migrations.md): replace the shipped slop plugin
788
+ // that reports inert skip text. The copy stays consumer-owned; edited copies need a merge.
789
+ function migrateSlopTypeSuppression(dryRun: boolean, ws: WriteSet, logPrefix: string): void {
790
+ const file = path.join("scripts", "slop", "bkit-slop-type-suppression.mjs");
791
+ const stat = fs.lstatSync(file, { throwIfNoEntry: false });
792
+ if (!stat) return;
793
+ const tag = dryRun ? "[dry-run] " : "";
794
+ const manual = (reason: string): void => {
795
+ console.warn(
796
+ `${logPrefix} ${tag}core: ${file} left unchanged (${reason}); merge the corrected .bkit/templates/${file} by hand to avoid false skip/focus findings in inert text`,
797
+ );
798
+ };
799
+ if (linkedPath(file) || !stat.isFile()) {
800
+ manual("the path is not a regular file or sits under a symlink");
801
+ return;
802
+ }
803
+ const current = fs.readFileSync(file);
804
+ const template = fs.readFileSync(path.join(getTemplatesRoot(), file));
805
+ if (current.equals(template)) return;
806
+ if (sha256(current) !== RETIRED_SLOP_PLUGIN_HASH) {
807
+ manual("the copy differs from the shipped version");
808
+ return;
809
+ }
810
+ if (!dryRun) fs.writeFileSync(file, template);
811
+ ws.writes.push({ path: file, action: "update", unhashed: true });
812
+ console.log(`${logPrefix} ${tag}core: ${file} — slop plugin updated`);
813
+ }
814
+
815
+ // Every `.github/workflows/*.yml` / `*.yaml` regular file outside `skip`.
816
+ function otherWorkflows(skip: readonly string[]): string[] {
817
+ const dir = path.join(".github", "workflows");
818
+ if (!fs.lstatSync(dir, { throwIfNoEntry: false })?.isDirectory()) return [];
819
+ const skipped = new Set(skip.map((f) => path.normalize(f)));
820
+ return fs
821
+ .readdirSync(dir)
822
+ .filter((f) => /\.ya?ml$/.test(f))
823
+ .map((f) => path.join(dir, f))
824
+ .filter((f) => !skipped.has(f) && fs.lstatSync(f).isFile());
825
+ }
826
+
827
+ // Every regular `action.yml` / `action.yaml` file under `.github/actions/`, at any depth.
828
+ function compositeActions(): string[] {
829
+ const dir = path.join(".github", "actions");
830
+ if (!fs.lstatSync(dir, { throwIfNoEntry: false })?.isDirectory()) return [];
831
+ const walk = (d: string): string[] =>
832
+ fs.readdirSync(d).flatMap((f) => {
833
+ const p = path.join(d, f);
834
+ const st = fs.lstatSync(p);
835
+ if (st.isDirectory()) return walk(p);
836
+ return st.isFile() && /^action\.ya?ml$/.test(f) ? [p] : [];
837
+ });
838
+ return walk(dir);
839
+ }
840
+
841
+ function escapeRegExp(text: string): string {
842
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
843
+ }
844
+
845
+ /**
846
+ * Rewrites `pnpm [flags] [run] [flags] <old>` to the new name, keeping the flags and `run`.
847
+ * Each flag is a value-less `-x` / `--x[=v]` token, except the package selectors (`-F`, `-C`,
848
+ * `-r`, `--recursive`, `--filter`, `--dir`, `--prefix`), which leave the call alone; `<old>` ends at a character outside
849
+ * `[\w:-]` or at the end of the text. Anything else (`npm run`, `echo`, `--filter web`) stays.
850
+ */
851
+ export function renameScriptTokens(
852
+ text: string,
853
+ renames: Readonly<Record<string, string>>,
854
+ ): string {
855
+ const names = Object.keys(renames).sort((a, b) => b.length - a.length);
856
+ if (names.length === 0) return text;
857
+ const re = new RegExp(
858
+ `\\bpnpm((?:\\s+(?:run|(?!-(?:F|C|r|-filter|-dir|-prefix|-recursive))--?\\w[\\w-]*(?:=\\S*)?))*)(\\s+)(${names.map(escapeRegExp).join("|")})(?![\\w:-])`,
859
+ "g",
860
+ );
861
+ return text.replace(
862
+ re,
863
+ (_m, flags: string, gap: string, old: string) => `pnpm${flags}${gap}${renames[old]}`,
864
+ );
865
+ }
866
+
867
+ /**
868
+ * Each old script name still in `text`, with its 1-based line. A name without `:` (`graph`) is
869
+ * a plain word, so it counts only after `pnpm` / `npm` / `yarn` / `bun` on the same line and
870
+ * before any `#`.
871
+ */
872
+ export function findOldScriptNames(
873
+ text: string,
874
+ renames: Readonly<Record<string, string>>,
875
+ ): { line: number; name: string }[] {
876
+ const found: { line: number; name: string }[] = [];
877
+ const lines = text.split("\n");
878
+ for (const name of Object.keys(renames)) {
879
+ const re = name.includes(":")
880
+ ? new RegExp(`(?<![\\w:./-])${escapeRegExp(name)}(?![\\w:-])`)
881
+ : new RegExp(`\\b(?:pnpm|npm|yarn|bun)\\b[^#\\n]*\\s${escapeRegExp(name)}(?![\\w:./-])`);
882
+ lines.forEach((l, i) => {
883
+ if (re.test(l)) found.push({ line: i + 1, name });
884
+ });
885
+ }
886
+ return found;
887
+ }
888
+
889
+ // Renames the old script keys in place (values kept), rewrites old `pnpm` tokens in every
890
+ // script value, and warns on an old name it cannot reach. Returns true when package.json
891
+ // changed.
892
+ export function migrateBrandedScriptNames(
893
+ dryRun: boolean,
894
+ ws: WriteSet,
895
+ logPrefix: string,
896
+ ): boolean {
897
+ const pkgPath = "package.json";
898
+ if (!fs.existsSync(pkgPath)) return false;
899
+ const raw = fs.readFileSync(pkgPath, "utf-8");
900
+ const parsed = parseJson(raw);
901
+ if (!parsed.ok) {
902
+ console.warn(`${logPrefix} core: package.json is not valid JSON; script names not migrated`);
903
+ return false;
904
+ }
905
+ const pkg = parsed.value as Record<string, unknown>;
906
+ if (!plainObject(pkg.scripts)) return false;
907
+ const scripts = pkg.scripts;
908
+ const { active, bothPresent } = activeScriptRenames(scripts, BKIT_SCRIPT_RENAMES);
909
+ const tag = dryRun ? "[dry-run] " : "";
910
+ for (const oldName of bothPresent) {
911
+ console.warn(
912
+ `${logPrefix} ${tag}core: package.json scripts hold both "${oldName}" and "${BKIT_SCRIPT_RENAMES[oldName]}"; left "${oldName}" in place — remove it once nothing uses it`,
913
+ );
914
+ }
915
+ const next: Record<string, unknown> = {};
916
+ const renamed: string[] = [];
917
+ let changed = false;
918
+ for (const [key, value] of Object.entries(scripts)) {
919
+ const newKey = active[key];
920
+ if (newKey !== undefined) {
921
+ renamed.push(key);
922
+ changed = true;
923
+ }
924
+ let newValue = value;
925
+ if (typeof value === "string") {
926
+ newValue = renameScriptTokens(value, active);
927
+ if (newValue !== value) changed = true;
928
+ }
929
+ next[newKey ?? key] = newValue;
930
+ }
931
+ if (!changed) return false;
932
+ for (const [key, value] of Object.entries(next)) {
933
+ if (typeof value !== "string") continue;
934
+ for (const { name } of findOldScriptNames(value, active)) {
935
+ console.warn(
936
+ `${logPrefix} ${tag}core: package.json script "${key}" still runs the old name "${name}"; rename it to "${active[name]}" by hand`,
937
+ );
938
+ }
939
+ }
940
+ pkg.scripts = next;
941
+ ws.writes.push({ path: pkgPath, action: "update" });
942
+ if (!dryRun) writePackageJsonLike(raw, pkg);
943
+ console.log(
944
+ `${logPrefix} ${tag}core: package.json script names branded${renamed.length > 0 ? ` [${renamed.join(", ")}]` : ""}`,
945
+ );
946
+ return true;
947
+ }
948
+
949
+ // Migration (up to 6.0.x installs, `docs/migrations.md`): the husky hooks and the CI workflow
950
+ // are copy-and-own files that run the old script names. `renameScriptTokens` rewrites them in
951
+ // place, for the pairs `migrateBrandedScriptNames` acts on; a name it cannot reach is
952
+ // warned with file and line. With `pathRenames` (`migrateBrandedTemplateFiles`) the
953
+ // `scripts/ci/<old>` path tokens in those files, `bkit-trivy.yml` and the package.json script
954
+ // values are rewritten too. Absent files are skipped. Writes are `unhashed`: the file stays the
955
+ // consumer's, bkit never records a hash for it.
956
+ export interface PathRename {
957
+ from: string;
958
+ to: string;
959
+ }
960
+
961
+ function renamePathTokens(text: string, pathRenames: readonly PathRename[]): string {
962
+ let out = text;
963
+ for (const { from, to } of pathRenames) {
964
+ out = out.replace(new RegExp(`${escapeRegExp(from)}(?![\\w.-])`, "g"), to);
965
+ }
966
+ return out;
967
+ }
968
+
969
+ export function migrateBrandedFileTokens(
970
+ dryRun: boolean,
971
+ ws: WriteSet,
972
+ logPrefix: string,
973
+ pathRenames: readonly PathRename[] = [],
974
+ ): void {
975
+ const tag = dryRun ? "[dry-run] " : "";
976
+ let scripts: Record<string, unknown> = {};
977
+ let pkgRaw: string | undefined;
978
+ let pkg: Record<string, unknown> | undefined;
979
+ if (fs.existsSync("package.json")) {
980
+ pkgRaw = fs.readFileSync("package.json", "utf-8");
981
+ const parsed = parseJson(pkgRaw);
982
+ if (parsed.ok && plainObject(parsed.value)) {
983
+ pkg = parsed.value;
984
+ if (plainObject(pkg.scripts)) scripts = pkg.scripts;
985
+ }
986
+ }
987
+ const { active } = activeScriptRenames(scripts, BKIT_SCRIPT_RENAMES);
988
+ const tokenFiles = [
989
+ path.join(".husky", "pre-commit"),
990
+ path.join(".husky", "pre-push"),
991
+ ciWorkflowPath("."),
992
+ ];
993
+ const files = [...new Set([...tokenFiles, path.join(".github", "workflows", "bkit-trivy.yml")])];
994
+ for (const file of files) {
995
+ if (!fs.lstatSync(file, { throwIfNoEntry: false })?.isFile()) continue;
996
+ const text = fs.readFileSync(file, "utf-8");
997
+ let next = tokenFiles.includes(file) ? renameScriptTokens(text, active) : text;
998
+ next = renamePathTokens(next, pathRenames);
999
+ if (tokenFiles.includes(file)) {
1000
+ for (const { name, line } of findOldScriptNames(next, active)) {
1001
+ console.warn(
1002
+ `${logPrefix} ${tag}core: ${file}:${line} still runs the old script name "${name}"; rename it to "${active[name]}" by hand`,
1003
+ );
1004
+ }
1005
+ }
1006
+ if (next === text) continue;
1007
+ if (!dryRun) fs.writeFileSync(file, next, "utf-8");
1008
+ ws.writes.push({ path: file, action: "update", unhashed: true });
1009
+ console.log(`${logPrefix} ${tag}core: ${file} — branded script and path names rewritten`);
1010
+ }
1011
+ for (const file of otherWorkflows(files)) {
1012
+ for (const { name, line } of findOldScriptNames(fs.readFileSync(file, "utf-8"), active)) {
1013
+ console.warn(
1014
+ `${logPrefix} ${tag}core: ${file}:${line} still runs the old script name "${name}"; rename it to "${active[name]}" by hand`,
1015
+ );
1016
+ }
1017
+ }
1018
+ if (pkg === undefined || pkgRaw === undefined || pathRenames.length === 0) return;
1019
+ let changed = false;
1020
+ const nextScripts: Record<string, unknown> = {};
1021
+ for (const [key, value] of Object.entries(scripts)) {
1022
+ const nextValue = typeof value === "string" ? renamePathTokens(value, pathRenames) : value;
1023
+ if (nextValue !== value) changed = true;
1024
+ nextScripts[key] = nextValue;
1025
+ }
1026
+ if (!changed) return;
1027
+ pkg.scripts = nextScripts;
1028
+ ws.writes.push({ path: "package.json", action: "update", unhashed: true });
1029
+ if (!dryRun) writePackageJsonLike(pkgRaw, pkg);
1030
+ console.log(`${logPrefix} ${tag}core: package.json — branded CI script paths rewritten`);
1031
+ }
1032
+
1033
+ // sha256 of every distinct release content of the CI script `.mjs` files, per old path, from
1034
+ // each `v*` tag. An unedited copy matches one of them.
1035
+ export const SHIPPED_CI_SCRIPT_HASHES: Readonly<Record<string, readonly string[]>> = {
1036
+ "scripts/ci/check-capstone.mjs": [
1037
+ "3813d9fe3cfae79788990b0a7a4914d18350dde165a3c2fe5940e8348362cea6",
1038
+ "45078e630f5ec9ff4e7704c99ac5f56fd37b9c2e94c052f084c03feddc86ef71",
1039
+ ],
1040
+ "scripts/ci/check-capstone.test.mjs": [
1041
+ "0554d64652dcc32ea368a4791372e860a5e3314ecfb7084256627015333c7afb",
1042
+ "ad58a0095528fdb3fe7310586b4091824f29fda261542df73c324c8dd574a0d6",
1043
+ ],
1044
+ "scripts/ci/check-dependency-audit.mjs": [
1045
+ "b410ab27cdbeed8d659fdf523d1af9b519beb874901186bb59e2889646cdaa19",
1046
+ ],
1047
+ "scripts/ci/check-dependency-audit.test.mjs": [
1048
+ "db3643ae6ef7ad01d628e6110aa2f7b47cdf2423ca07efc1a8bc6176eb98b6a2",
1049
+ ],
1050
+ "scripts/ci/check-accepted-divergences.mjs": [
1051
+ "3b410c53535e66b7a65b54d574ba7f7e47139bfba58a883a60697b8ab44deef4",
1052
+ "66e6f1f9ce22b52afe93454c268613b8f5b03c1c58b5817cac958435fefbe5b1",
1053
+ ],
1054
+ "scripts/ci/check-accepted-divergences.test.mjs": [
1055
+ "743e623f0dcb118a96744d31611fb599e9041a8007a3202fb46c30d72a3e183e",
1056
+ "f130f5784349c21c5ae4f02626243362d9c29f783b9ad4b9c158beeca9bf4107",
1057
+ ],
1058
+ "scripts/ci/lanes/resolve-push-base.mjs": [
1059
+ "016c4dacf34ce6edffcc7c7f666027a0a34669ce299d755679c877540fc751e7",
1060
+ "11930bf63081ca2b5201799e0262acfcfc148e15bce41e17ebead688a94fe8ce",
1061
+ "84acc7ff1596234af0c614236608e2009e794da9549bf77a4cc9560c2784a8f8",
1062
+ ],
1063
+ "scripts/ci/lanes/resolve-push-base.test.mjs": [
1064
+ "1ce7b5fdf1de756f56e6b9710952c1e272c633107b06c0d47780fce36b90d1ad",
1065
+ "32e17be38751f2744d660acdd99c6a08e7f437cdeaeb7075bc876b1cd31f0237",
1066
+ "6883deb2b20f99af68721b085fbf3e2ab14e4b58d17dd676afaf734c75195e96",
1067
+ ],
1068
+ };
1069
+
1070
+ // Migration (up to 6.0.x installs, `docs/migrations.md`): the CI script files carry the
1071
+ // `bkit-` prefix. A unit (script, test and data file, `CI_SCRIPT_UNITS`) moves whole when each
1072
+ // present `.mjs` matches a shipped release and no `bkit-` target exists: the old files go, the
1073
+ // `.mjs` targets come from the shipped templates, the data file moves byte for byte. Any
1074
+ // other unit stays, with a warning naming the manual move (the `ci-scripts-old-names`
1075
+ // advisory lists it too). Returns the renames applied plus those already applied (old absent,
1076
+ // new present), for the path-token rewrite.
1077
+ export function migrateBrandedTemplateFiles(
1078
+ dryRun: boolean,
1079
+ ws: WriteSet,
1080
+ logPrefix: string,
1081
+ ): PathRename[] {
1082
+ const tag = dryRun ? "[dry-run] " : "";
1083
+ const renames: PathRename[] = [];
1084
+ const templates = getTemplatesRoot();
1085
+ for (const unit of CI_SCRIPT_UNITS) {
1086
+ const exists = (p: string): boolean => fs.lstatSync(p, { throwIfNoEntry: false }) !== undefined;
1087
+ const present = unit.filter(([from]) => exists(from));
1088
+ const done = unit.filter(([from, to]) => !exists(from) && exists(to));
1089
+ for (const [from, to] of done) renames.push({ from, to });
1090
+ if (present.length === 0) continue;
1091
+ const linkedTargets = present.map(([, to]) => to).filter((to) => linkedPath(to));
1092
+ const linkedAll = [
1093
+ ...new Set([...present.map(([from]) => from).filter((f) => linkedPath(f)), ...linkedTargets]),
1094
+ ];
1095
+ if (linkedAll.length > 0) {
1096
+ console.warn(
1097
+ `${logPrefix} ${tag}core: ${linkedAll.join(", ")} is a symlink (or sits under one); ${present.map(([from]) => from).join(", ")} not moved to the bkit- names; move them by hand and update every reference`,
1098
+ );
1099
+ continue;
1100
+ }
1101
+ const referenced = [
1102
+ ...otherWorkflows([ciWorkflowPath("."), path.join(".github", "workflows", "bkit-trivy.yml")]),
1103
+ ...compositeActions(),
1104
+ ].flatMap((file) => {
1105
+ const lines = fs.readFileSync(file, "utf-8").split("\n");
1106
+ return present.flatMap(([from]) =>
1107
+ lines.flatMap((l, i) =>
1108
+ new RegExp(`${escapeRegExp(from)}(?![\\w.-])`).test(l)
1109
+ ? [{ file, line: i + 1, from }]
1110
+ : [],
1111
+ ),
1112
+ );
1113
+ });
1114
+ if (referenced.length > 0) {
1115
+ for (const { file, line, from } of referenced) {
1116
+ console.warn(
1117
+ `${logPrefix} ${tag}core: ${file}:${line} still names ${from}; the unit was not moved to the bkit- names — move the files by hand and update that reference`,
1118
+ );
1119
+ }
1120
+ continue;
1121
+ }
1122
+ const edited = present.filter(
1123
+ ([from]) =>
1124
+ from.endsWith(".mjs") &&
1125
+ !SHIPPED_CI_SCRIPT_HASHES[from]?.includes(sha256(fs.readFileSync(from))),
1126
+ );
1127
+ const taken = present.filter(([, to]) => exists(to));
1128
+ const noTemplate = present.filter(
1129
+ ([, to]) => to.endsWith(".mjs") && !fs.existsSync(path.join(templates, to)),
1130
+ );
1131
+ if (edited.length > 0 || taken.length > 0 || noTemplate.length > 0) {
1132
+ const why =
1133
+ edited.length > 0
1134
+ ? `${edited.map(([from]) => from).join(", ")} differs from every shipped release`
1135
+ : taken.length > 0
1136
+ ? `${taken.map(([, to]) => to).join(", ")} already exists`
1137
+ : "the shipped template is missing";
1138
+ console.warn(
1139
+ `${logPrefix} ${tag}core: ${present.map(([from]) => from).join(", ")} not moved to the bkit- names (${why}); move them by hand and update every reference`,
1140
+ );
1141
+ continue;
1142
+ }
1143
+ for (const [from, to] of present) {
1144
+ if (!dryRun) {
1145
+ fs.mkdirSync(path.dirname(to), { recursive: true });
1146
+ if (to.endsWith(".mjs")) fs.copyFileSync(path.join(templates, to), to);
1147
+ else fs.copyFileSync(from, to);
1148
+ fs.rmSync(from);
1149
+ }
1150
+ ws.writes.push({ path: from, action: "write", unhashed: true });
1151
+ ws.writes.push({ path: to, action: "write", unhashed: true });
1152
+ renames.push({ from, to });
1153
+ console.log(`${logPrefix} ${tag}core: ${from} moved to ${to}`);
1154
+ }
1155
+ }
1156
+ return renames;
1157
+ }
1158
+
1159
+ // The old `bkit-stub:health` block, as shipped by every release up to 6.0.x.
1160
+ const OLD_HEALTH_STUB = [
1161
+ "# bkit-stub:health — copy into .github/workflows/health.yml. workflow_run cannot share a file with",
1162
+ "# push / pull_request. WHEN: you have a live URL to smoke after CI. Trigger on CI completed, default",
1163
+ "# branch only, if the CI run succeeded. Then hit the health URL of the deployment this SHA promoted.",
1164
+ "# e.g. poll the host until that deployment is ready, then GET /health. Not a required check.",
1165
+ "# DROP if you have no deployed health URL.",
1166
+ ].join("\n");
1167
+
1168
+ // Exact old workflow `name:` lines the three shipped example workflows carried, with the
1169
+ // branded line and the check each one renames. `job` names the job whose display name the
1170
+ // workflow name branded (the job has no `name:` of its own, so its check showed the bare id).
1171
+ const BRANDED_WORKFLOWS = [
1172
+ { file: "bkit-renovate.yml", oldName: "Renovate", newName: "bkit-renovate", job: "renovate" },
1173
+ { file: "bkit-trivy.yml", oldName: "Trivy", newName: "bkit-trivy", job: "trivy" },
1174
+ ] as const;
1175
+ const CHECK_RENAME_FIX =
1176
+ "update the branch-protection required checks (and any ruleset) to the new name";
1177
+
1178
+ // Migration (up to 6.0.x installs, `docs/migrations.md`): the shipped example workflows and
1179
+ // the health stub in the CI workflow carry bkit- check names. Only the exact shipped old
1180
+ // lines are rewritten, so a customised `name:` stays; the job `name:` is inserted only when
1181
+ // the workflow name was rewritten and the job has none. The health stub block is replaced
1182
+ // by the current one when it is byte-identical to the shipped old one. Writes are `unhashed`:
1183
+ // the files stay the consumer's. One log line per renamed check names old -> new, because
1184
+ // branch protection matches the check name.
1185
+ export function migrateBrandedCheckNames(
1186
+ dryRun: boolean,
1187
+ ws: WriteSet,
1188
+ logPrefix: string,
1189
+ defaultBranch = "main",
1190
+ ): void {
1191
+ const tag = dryRun ? "[dry-run] " : "";
1192
+ const wfDir = path.join(".github", "workflows");
1193
+ const finish = (file: string, text: string, next: string, renamed: string[]): void => {
1194
+ if (next === text) return;
1195
+ if (!dryRun) fs.writeFileSync(file, next, "utf-8");
1196
+ ws.writes.push({ path: file, action: "update", unhashed: true });
1197
+ for (const line of renamed) {
1198
+ console.log(`${logPrefix} ${tag}core: ${file} — check renamed ${line}; ${CHECK_RENAME_FIX}`);
1199
+ }
1200
+ };
1201
+ const readFile = (file: string): string | undefined =>
1202
+ fs.lstatSync(file, { throwIfNoEntry: false })?.isFile()
1203
+ ? fs.readFileSync(file, "utf-8")
1204
+ : undefined;
1205
+
1206
+ const cloud = path.join(wfDir, "bkit-cloud.yml");
1207
+ const cloudText = readFile(cloud);
1208
+ if (cloudText !== undefined) {
1209
+ const renamed: string[] = [];
1210
+ const next = cloudText.replace(
1211
+ /^( {4}name: )(context|claude|opencode)( \(\$\{\{ github\.event_name \}\}\))$/gm,
1212
+ (_m, pre: string, job: string, post: string) => {
1213
+ renamed.push(`bkit-cloud / ${job}${post} -> bkit-cloud / bkit-cloud-${job}${post}`);
1214
+ return `${pre}bkit-cloud-${job}${post}`;
1215
+ },
1216
+ );
1217
+ finish(cloud, cloudText, next, renamed);
1218
+ }
1219
+
1220
+ for (const { file, oldName, newName, job } of BRANDED_WORKFLOWS) {
1221
+ const target = path.join(wfDir, file);
1222
+ const text = readFile(target);
1223
+ if (text === undefined) continue;
1224
+ const nameLine = new RegExp(`^name: ${escapeRegExp(oldName)}$`, "m");
1225
+ if (!nameLine.test(text)) continue;
1226
+ let next = text.replace(nameLine, `name: ${newName}`);
1227
+ const jobStart = new RegExp(`^ {2}${escapeRegExp(job)}:[ \\t]*\\n`, "m").exec(next);
1228
+ if (jobStart !== null) {
1229
+ const bodyStart = jobStart.index + jobStart[0].length;
1230
+ const rest = next.slice(bodyStart);
1231
+ const end = rest.search(/^(?: {2}[^\s#]|[^\s#])/m);
1232
+ const body = end === -1 ? rest : rest.slice(0, end);
1233
+ if (!/^ {4}name:/m.test(body)) {
1234
+ next = `${next.slice(0, bodyStart)} name: ${newName}\n${next.slice(bodyStart)}`;
1235
+ }
1236
+ const after = new RegExp(`^ {2}${escapeRegExp(job)}:[ \\t]*\\n`, "m").exec(next);
1237
+ const afterRest = after === null ? "" : next.slice(after.index + after[0].length);
1238
+ const afterEnd = afterRest.search(/^(?: {2}[^\s#]|[^\s#])/m);
1239
+ const afterBody = afterEnd === -1 ? afterRest : afterRest.slice(0, afterEnd);
1240
+ if ((afterBody.match(/^ {4}name:/gm) ?? []).length > 1) {
1241
+ console.warn(
1242
+ `${logPrefix} ${tag}core: ${target} not renamed (a second job name: would make the workflow invalid YAML); rename by hand: name: ${oldName} -> name: ${newName} and set the ${job} job name: to ${newName}`,
1243
+ );
1244
+ continue;
1245
+ }
1246
+ }
1247
+ finish(target, text, next, [`${oldName} / ${job} -> ${newName} / ${newName}`]);
1248
+ }
1249
+
1250
+ const ci = ciWorkflowPath(".");
1251
+ const ciText = readFile(ci);
1252
+ if (ciText !== undefined && ciText.includes(OLD_HEALTH_STUB)) {
1253
+ const template = readFile(path.join(getTemplatesRoot(), ".github", "workflows", "bkit-ci.yml"));
1254
+ const current = template?.match(
1255
+ /^# bkit-stub:health[^\n]*\n(?:#[^\n]*\n)*?#[^\n]*DROP if you have no deployed health URL\./m,
1256
+ )?.[0];
1257
+ if (current !== undefined) {
1258
+ const next = ciText.replace(OLD_HEALTH_STUB, () =>
1259
+ current.replace(/\{\{DEFAULT_BRANCH\}\}/g, () => defaultBranch),
1260
+ );
1261
+ if (next !== ciText) {
1262
+ if (!dryRun) fs.writeFileSync(ci, next, "utf-8");
1263
+ ws.writes.push({ path: ci, action: "update", unhashed: true });
1264
+ console.log(
1265
+ `${logPrefix} ${tag}core: ${ci} — old bkit-stub:health text replaced by the current block`,
1266
+ );
1267
+ }
1268
+ }
1269
+ }
1270
+ }
1271
+
1272
+ // sha256 of every distinct release content of the four shipped `House` Vale rules, from each
1273
+ // `v*` tag, across `.agents/templates/.vale/styles/House/` and `.bkit/templates/.vale/styles/House/`.
1274
+ // An unedited copy matches one of them. Same shape as `RETIRED_DRIVER_HASHES` (write.ts).
1275
+ export const SHIPPED_HOUSE_RULE_HASHES: Readonly<Record<string, readonly string[]>> = {
1276
+ Filler: [
1277
+ "96139df9ffc61835e23014addac887d9465169d62cd1be24c2f272f838166524",
1278
+ "9b10438de3158a1923c51375fcba56de7a8dd2f17de97d62385407eee2a6e377",
1279
+ "e04e9e76a4857de0d13ff106343e25000418c535a983317f5a2e1710fa68cbc7",
1280
+ ],
1281
+ Hedging: [
1282
+ "7289b6bfe98f48803734c016c6ba49661071b5d8ded0f4678509b37c6ab8aff9",
1283
+ "b7425861cb3085cc798379d8e92f01a0420aa2c40f7be1ba1bbfabd908767a37",
1284
+ "c46cda04406629377555d3add75e56edaad40521864743dbbd47781f2c048ef0",
1285
+ ],
1286
+ LLMSlop: [
1287
+ "17a22ab44f0bd37de4d4c972fbb39a71dc256712ba0cfc39320043381f180a8e",
1288
+ "c39313e229249786ba189bb1abe55728f83e325a54777b41b54e0a1dec47b4f7",
1289
+ "e1ce58da6c86d7bc746698fbf17fd3d0075980ca78f2d8b8c927ea3ddc35094e",
1290
+ ],
1291
+ Verbose: [
1292
+ "8278791997cca85a2df63b2c93decac480e685215e0569e8472aa433e7a27ac8",
1293
+ "bcb18beb903e7bd57780905778ea4d1a4f294589cf191375db144ecb11f4c619",
1294
+ "f7939a5be92562803183108581538a1b4ca73c3b8a1b68ceeb2b2149ba1a4357",
1295
+ ],
1296
+ };
1297
+
1298
+ // Migration (up to 6.0.x installs, `docs/migrations.md`): the shipped Vale style is `Bkit`,
1299
+ // it was `House`. A `House/<rule>.yml` byte-identical to a shipped release moves to
1300
+ // `Bkit/<rule>.yml` when that is absent; an edited rule or a taken target stays with one
1301
+ // warning naming the manual move. In `.vale.ini`, `House.<moved>` becomes `Bkit.<moved>`;
1302
+ // `BasedOnStyles` swaps `House` for `Bkit` once `House/` is empty (the directory goes), else
1303
+ // appends `Bkit`. Own rules in `House/` stay. Writes are `unhashed`.
1304
+ export function migrateValeHouseStyle(dryRun: boolean, ws: WriteSet, logPrefix: string): void {
1305
+ const tag = dryRun ? "[dry-run] " : "";
1306
+ const stylesDir = path.join(".vale", "styles");
1307
+ const houseDir = path.join(stylesDir, "House");
1308
+ const bkitDir = path.join(stylesDir, "Bkit");
1309
+ const linkedVale = [".vale", stylesDir, houseDir, bkitDir].find((p) => isLink(p));
1310
+ if (linkedVale === houseDir || linkedVale === ".vale" || linkedVale === stylesDir) {
1311
+ console.warn(
1312
+ `${logPrefix} ${tag}core: ${linkedVale} is a symlink; the House rules were not moved to the Bkit style — move them by hand: mv .vale/styles/House/<rule>.yml .vale/styles/Bkit/ and rename the House.<rule> toggles in .vale.ini to Bkit.<rule>`,
1313
+ );
1314
+ return;
1315
+ }
1316
+ if (!fs.lstatSync(houseDir, { throwIfNoEntry: false })?.isDirectory()) return;
1317
+ if (linkedVale !== undefined) {
1318
+ console.warn(
1319
+ `${logPrefix} ${tag}core: ${linkedVale} is a symlink; the House rules were not moved to the Bkit style — move them by hand: mv .vale/styles/House/<rule>.yml .vale/styles/Bkit/ and rename the House.<rule> toggles in .vale.ini to Bkit.<rule>`,
1320
+ );
1321
+ return;
1322
+ }
1323
+ const moved: string[] = [];
1324
+ for (const [rule, hashes] of Object.entries(SHIPPED_HOUSE_RULE_HASHES)) {
1325
+ const from = path.join(houseDir, `${rule}.yml`);
1326
+ if (isLink(from)) {
1327
+ console.warn(
1328
+ `${logPrefix} ${tag}core: ${from} is a symlink and was not moved to the Bkit style; move it by hand: mv .vale/styles/House/${rule}.yml .vale/styles/Bkit/ and rename the House.${rule} toggle in .vale.ini to Bkit.${rule}`,
1329
+ );
1330
+ continue;
1331
+ }
1332
+ if (!fs.lstatSync(from, { throwIfNoEntry: false })?.isFile()) continue;
1333
+ const to = path.join(bkitDir, `${rule}.yml`);
1334
+ const stays = !hashes.includes(sha256(fs.readFileSync(from)))
1335
+ ? "differs from every shipped release"
1336
+ : fs.lstatSync(to, { throwIfNoEntry: false }) !== undefined
1337
+ ? `${to} already exists`
1338
+ : undefined;
1339
+ if (stays !== undefined) {
1340
+ console.warn(
1341
+ `${logPrefix} ${tag}core: ${from} not moved to the Bkit style (${stays}); move it by hand: mv .vale/styles/House/${rule}.yml .vale/styles/Bkit/ and rename the House.${rule} toggle in .vale.ini to Bkit.${rule}`,
1342
+ );
1343
+ continue;
1344
+ }
1345
+ if (!dryRun) {
1346
+ fs.mkdirSync(bkitDir, { recursive: true });
1347
+ fs.copyFileSync(from, to);
1348
+ fs.rmSync(from);
1349
+ }
1350
+ ws.writes.push({ path: from, action: "write", unhashed: true });
1351
+ ws.writes.push({ path: to, action: "write", unhashed: true });
1352
+ moved.push(rule);
1353
+ console.log(`${logPrefix} ${tag}core: ${from} moved to ${to}`);
1354
+ }
1355
+ const remaining = fs.readdirSync(houseDir).filter((f) => !moved.some((r) => f === `${r}.yml`));
1356
+ const houseGone = remaining.length === 0;
1357
+ if (houseGone) {
1358
+ if (!dryRun) fs.rmSync(houseDir, { recursive: true });
1359
+ ws.writes.push({ path: houseDir, action: "write", unhashed: true });
1360
+ }
1361
+ if (moved.length === 0 && !houseGone) return;
1362
+ const ini = ".vale.ini";
1363
+ if (!fs.lstatSync(ini, { throwIfNoEntry: false })?.isFile()) return;
1364
+ const text = fs.readFileSync(ini, "utf-8");
1365
+ let next = text;
1366
+ if (moved.length > 0) {
1367
+ next = next.replace(
1368
+ new RegExp(`^(\\s*)House\\.(${moved.join("|")})\\b`, "gm"),
1369
+ (_m, lead: string, rule: string) => `${lead}Bkit.${rule}`,
1370
+ );
1371
+ }
1372
+ if (houseGone) next = next.replace(/^(#.*)\bHouse rules\b/gm, "$1Bkit rules");
1373
+ next = next.replace(/^(BasedOnStyles\s*=\s*)(.*)$/gm, (line, pre: string, list: string) => {
1374
+ const styles = list.split(",").map((s) => s.trim());
1375
+ if (!styles.includes("House")) return line;
1376
+ if (houseGone) {
1377
+ const swapped = styles.map((s) => (s === "House" ? "Bkit" : s));
1378
+ return pre + [...new Set(swapped)].join(", ");
1379
+ }
1380
+ return styles.includes("Bkit") ? line : `${line}, Bkit`;
1381
+ });
1382
+ if (next === text) return;
1383
+ if (!dryRun) fs.writeFileSync(ini, next, "utf-8");
1384
+ ws.writes.push({ path: ini, action: "update", unhashed: true });
1385
+ console.log(`${logPrefix} ${tag}core: ${ini} — House style names rewritten to Bkit`);
1386
+ }
1387
+
560
1388
  // Status option ids of GitHub's Kanban and Team planning board templates; every board
561
1389
  // made from one carries the same ids.
562
1390
  const TEMPLATE_STATUS_OPTIONS: Readonly<Record<string, string>> = {
@@ -638,7 +1466,9 @@ export const BKIT_LAYOUT_MOVES: readonly (readonly [string, string])[] = [
638
1466
  ["minPushPaths", "testing.minPushPaths"],
639
1467
  ["capstoneJob", "testing.ciCapstone"],
640
1468
  ["ciWorkflow", "testing.ciWorkflow"],
641
- ["shipGateRequiredLanes", "testing.shipGate"],
1469
+ ["shipGateRequiredLanes", "testing.ciRequired"],
1470
+ // 6.0.0 installs named the required-lane list `testing.shipGate`.
1471
+ ["testing.shipGate", "testing.ciRequired"],
642
1472
  ["disk.minFreeGb", "workflows.minFreeGb"],
643
1473
  ["worktree", "workflows.worktree"],
644
1474
  ["tasks", "workflows.tasks"],
@@ -647,6 +1477,41 @@ export const BKIT_LAYOUT_MOVES: readonly (readonly [string, string])[] = [
647
1477
  ["ignoreAdvisories", "advisories.ignore"],
648
1478
  ];
649
1479
 
1480
+ // Migration (up to 6.0.x installs, `docs/migrations.md`): `bkit.testing.minPushPaths` was the
1481
+ // whole min-push list, so installs seeded and repos restated what bkit itself writes. The
1482
+ // engine now always allows that floor (ship's bookkeeping allow-list, `docs/plans/**`) and
1483
+ // `bkit.testing.ciSkipPaths`; the setting only adds. Entries the floor already covers are
1484
+ // dropped from the list. Returns true when package.json changed.
1485
+ export const MIN_PUSH_FLOOR_ENTRIES: readonly string[] = [
1486
+ "docs/plans/**",
1487
+ "docs/*.jsonl",
1488
+ ".bkit/*.jsonl",
1489
+ ];
1490
+
1491
+ export function pruneMinPushPaths(dryRun: boolean, ws: WriteSet, logPrefix: string): boolean {
1492
+ const pkgPath = "package.json";
1493
+ if (!fs.existsSync(pkgPath)) return false;
1494
+ const raw = fs.readFileSync(pkgPath, "utf-8");
1495
+ const parsed = parseJson(raw);
1496
+ if (!parsed.ok) return false;
1497
+ const pkg = parsed.value as Record<string, unknown>;
1498
+ if (!plainObject(pkg.bkit) || !plainObject(pkg.bkit.testing)) return false;
1499
+ const testing = pkg.bkit.testing;
1500
+ if (!Array.isArray(testing.minPushPaths)) return false;
1501
+ const skip = Array.isArray(testing.ciSkipPaths) ? testing.ciSkipPaths : [];
1502
+ const covered = new Set<unknown>([...MIN_PUSH_FLOOR_ENTRIES, ...skip]);
1503
+ const kept = testing.minPushPaths.filter((p) => !covered.has(p));
1504
+ if (kept.length === testing.minPushPaths.length) return false;
1505
+ const dropped = testing.minPushPaths.filter((p) => covered.has(p)).map(String);
1506
+ testing.minPushPaths = kept;
1507
+ ws.writes.push({ path: pkgPath, action: "update" });
1508
+ if (!dryRun) writePackageJsonLike(raw, pkg);
1509
+ console.log(
1510
+ `${logPrefix} ${dryRun ? "[dry-run] " : ""}core: dropped [${dropped.join(", ")}] from bkit.testing.minPushPaths in package.json — bkit always allows what it writes, and ciSkipPaths counts`,
1511
+ );
1512
+ return true;
1513
+ }
1514
+
650
1515
  // Fill `into` with each `from` key it lacks, descending into blocks both sides hold.
651
1516
  function mergeMissing(into: Record<string, unknown>, from: Record<string, unknown>): void {
652
1517
  for (const [k, v] of Object.entries(from)) {
@@ -788,11 +1653,19 @@ export function gateLeafScripts(
788
1653
  return leaves;
789
1654
  }
790
1655
 
1656
+ /**
1657
+ * What a gate may run. bkit never reads a gate's value beyond its seeded default, so it
1658
+ * cannot check this; every gate advisory restates it (`.bkit/workflows.md` § Local gate
1659
+ * scripts).
1660
+ */
1661
+ export const GATE_CONTENTS_NOTE =
1662
+ "Gate contents (`.bkit/workflows.md` § Local gate scripts): every gate but `bkit:gate:static-unit-integration-e2e` and `bkit:gate:static-unit-integration-e2e-live` runs on a push or inside `/bkit-build`, so it MUST NOT run tests that need a deployed boundary or remote service; local services (a database in Docker) are fine.";
1663
+
791
1664
  /**
792
1665
  * Advisories for the `bkit:gate:*` scripts: the scripts a still-default gate
793
1666
  * chains that package.json does not declare, the deeper test tiers the repo has
794
- * but no gate runs, a commit gate that repeats the push gate, and a missing
795
- * `bkit:test:file`. Judges the scripts as install
1667
+ * but no gate runs, a commit gate that repeats the push gate, a missing
1668
+ * `bkit:test:file`, and a missing `bkit:gate:changed`. Judges the scripts as install
796
1669
  * leaves them (missing gate names at their seeded defaults), so install, `bkit check`
797
1670
  * and `bkit upgrade` report the same set. Read-only; an absent or unparseable
798
1671
  * package.json yields none.
@@ -823,7 +1696,7 @@ export function detectGateAdvisories(cwd: string): PreflightFinding[] {
823
1696
  id: "gate-missing-called-scripts",
824
1697
  severity: "advisory",
825
1698
  detect: `The bkit:gate scripts call scripts package.json does not declare: ${names.join(", ")}.`,
826
- action: `Every bkit workflow runs a \`bkit:gate*\` script, so a missing link fails the whole gate. Add ${names.join(", ")} to package.json (\`.bkit/templates.md\` lists the tool scripts and the devDeps they need), or edit the \`bkit:gate*\` scripts to drop what this repo does not have.`,
1699
+ action: `Every bkit workflow runs a \`bkit:gate*\` script, so a missing link fails the whole gate. Add ${names.join(", ")} to package.json (\`.bkit/templates.md\` lists the tool scripts and the devDeps they need), or edit the \`bkit:gate*\` scripts to drop what this repo does not have.\n\n${GATE_CONTENTS_NOTE}`,
827
1700
  });
828
1701
  }
829
1702
 
@@ -845,7 +1718,8 @@ export function detectGateAdvisories(cwd: string): PreflightFinding[] {
845
1718
  action:
846
1719
  "Each workflow runs the DEEPEST gate you declare, and `.husky/pre-push` runs `bkit:gate:static-unit-integration` when it is declared; an undeclared one is skipped, never guessed. Add the gates you want the agent loop to run:\n\n" +
847
1720
  unwired.join("\n") +
848
- "\n\nOrder matters — each chains the one above it. Omit a level deliberately to keep it CI-only (E2E in the build loop costs a production build on every remediation attempt). `.bkit/templates.md` lists the tool scripts the gates chain.",
1721
+ "\n\nOrder matters — each chains the one above it. Omit a level deliberately to keep it CI-only (E2E in the build loop costs a production build on every remediation attempt). `.bkit/templates.md` lists the tool scripts the gates chain.\n\n" +
1722
+ GATE_CONTENTS_NOTE,
849
1723
  });
850
1724
  }
851
1725
 
@@ -861,7 +1735,7 @@ export function detectGateAdvisories(cwd: string): PreflightFinding[] {
861
1735
  id: "gate-commit-repeats-push",
862
1736
  severity: "advisory",
863
1737
  detect: `\`bkit:gate:format\` (pre-commit) runs ${names}, which \`${pushGate}\` (pre-push) runs again.`,
864
- action: `Drop ${names} from \`bkit:gate:format\`. The commit gate formats staged files and nothing else; every whole-repo check runs once, at pre-push.`,
1738
+ action: `Drop ${names} from \`bkit:gate:format\`. The commit gate formats staged files and nothing else; every whole-repo check runs once, at pre-push.\n\n${GATE_CONTENTS_NOTE}`,
865
1739
  });
866
1740
  }
867
1741
 
@@ -875,6 +1749,33 @@ export function detectGateAdvisories(cwd: string): PreflightFinding[] {
875
1749
  action: `Add \`${BKIT_TEST_FILE_SCRIPT}\` to package.json: it runs the ONE test file bkit appends as its argument (repo-relative path) and writes a JUnit report to the path in \`$BKIT_TEST_REPORT\`. Vitest example:\n\n "${BKIT_TEST_FILE_SCRIPT}": "vitest run --reporter=default --reporter=junit --outputFile.junit=\\"$BKIT_TEST_REPORT\\""\n\nCall the runner directly, not through a task runner that caches results or runs dependent packages first. A monorepo routes the path to the package and config that own it.`,
876
1750
  });
877
1751
  }
1752
+
1753
+ // A red recorded before the linter sees the test: a lint rewrite after it reads as an
1754
+ // edited test, and no red can be recorded again once the task's code makes it pass.
1755
+ if (BKIT_TEST_FILE_SCRIPT in declared && !(BKIT_LINT_FILE_SCRIPT in declared)) {
1756
+ findings.push({
1757
+ id: "lint-file-script-missing",
1758
+ severity: "advisory",
1759
+ detect: `package.json declares \`${BKIT_TEST_FILE_SCRIPT}\` but not \`${BKIT_LINT_FILE_SCRIPT}\`, so \`/bkit-build\` records a task's red before the linter sees the test; a lint fix after it pauses the build for an owner exception.`,
1760
+ action: `Add \`${BKIT_LINT_FILE_SCRIPT}\` to package.json: it lints the ONE test file bkit appends as its argument (repo-relative path) with the rules your static gate applies, exiting 0 when clean. \`bkit tests red\` runs it before the test and records no red while it fails. Examples:\n\n "${BKIT_LINT_FILE_SCRIPT}": "eslint --max-warnings=0"\n "${BKIT_LINT_FILE_SCRIPT}": "ruff check"\n\nUse the same linter config as the static gate, or the gate can still demand a rewrite after the red.`,
1761
+ });
1762
+ }
1763
+
1764
+ // Build and debug agents check their own change through this script; without it each
1765
+ // one runs a whole gate after every change. bkit cannot seed it: what finds the tests
1766
+ // a file affects is the stack's.
1767
+ const changedId = "gate-changed-script-missing";
1768
+ if (
1769
+ !(BKIT_GATE_CHANGED_SCRIPT in declared) &&
1770
+ !isAdvisorySuppressed(cwd, changedId, "advisory")
1771
+ ) {
1772
+ findings.push({
1773
+ id: changedId,
1774
+ severity: "advisory",
1775
+ detect: `package.json does not declare \`${BKIT_GATE_CHANGED_SCRIPT}\`, so \`/bkit-build\` and \`/bkit-debug\` agents run a whole gate (\`bkit:gate:static\` or \`bkit:gate:static-unit\`) after every change instead of checking only what changed.`,
1776
+ action: `Add \`${BKIT_GATE_CHANGED_SCRIPT}\` to package.json. \`bkit tests changed\` calls it with the changed files as its arguments (repo-relative paths: uncommitted, untracked and committed since the step began; deleted files left out) and never with none. It runs the tests that import those files, the tests that name their paths, and the static checks (lint, format, typecheck) on those files, exiting 0 when clean. Vitest + ESLint example, with \`scripts/gate-changed.sh\` holding \`vitest related --run "$@" && eslint --max-warnings=0 --no-error-on-unmatched-pattern "$@" && prettier --check --ignore-unknown "$@"\`:\n\n "${BKIT_GATE_CHANGED_SCRIPT}": "sh scripts/gate-changed.sh"\n\n\`vitest related\` finds only importers; also run the tests that read a changed file by its path (a text search of the test files for each path). The orchestrator's group gate, pre-push and CI still run the whole gates. To keep the whole gate on every change, add \`${changedId}\` to \`bkit.advisories.ignore\` in package.json.\n\n${GATE_CONTENTS_NOTE}`,
1777
+ });
1778
+ }
878
1779
  return findings;
879
1780
  }
880
1781
 
@@ -912,7 +1813,8 @@ export function detectNoopGates(cwd: string): PreflightFinding[] {
912
1813
  severity: "advisory",
913
1814
  detect: `These bkit:gate scripts are empty or cannot fail, so they check nothing: ${noop.join(", ")}.`,
914
1815
  action:
915
- 'Every bkit workflow and the pre-push hook trust a green `bkit:gate*` script, so a no-op gate passes every agent run and push. Point each at the checks it should run (e.g. `"bkit:gate:static": "pnpm typecheck && pnpm lint"`), or delete it from package.json and run `bkit upgrade` to get bkit\'s default back.',
1816
+ 'Every bkit workflow and the pre-push hook trust a green `bkit:gate*` script, so a no-op gate passes every agent run and push. Point each at the checks it should run (e.g. `"bkit:gate:static": "pnpm typecheck && pnpm lint"`), or delete it from package.json and run `bkit upgrade` to get bkit\'s default back.\n\n' +
1817
+ GATE_CONTENTS_NOTE,
916
1818
  },
917
1819
  ];
918
1820
  }
@@ -1004,6 +1906,8 @@ export function runCoreModule(ctx: ModuleContext): void {
1004
1906
  // Exclude .bkit/version itself and .agents/ internal files (not consumer-facing).
1005
1907
  const newCanonicalEntries: Record<string, string> = {};
1006
1908
  for (const entry of ws.writes) {
1909
+ // Brand-migrated copy-and-own files carry no hash.
1910
+ if (entry.unhashed) continue;
1007
1911
  const absPath = path.isAbsolute(entry.path) ? entry.path : path.resolve(cwd, entry.path);
1008
1912
  const relPath = path.relative(cwd, absPath);
1009
1913
  if (relPath === path.join(".bkit", "version")) continue;
@@ -1062,7 +1966,7 @@ export function runCoreModule(ctx: ModuleContext): void {
1062
1966
  "2. See `.bkit/install.md` for consumer setup and `.bkit/README.md` for ongoing ops.\n\n" +
1063
1967
  "Note: bkit seeded the bkit:gate:* / bkit:deps:* package.json scripts every workflow\n" +
1064
1968
  "runs (existing values are never touched). The tool scripts they chain (typecheck,\n" +
1065
- "lint, format:check, lint:prose, slop:delta) and the devDeps those need are yours to\n" +
1969
+ "lint, format:check, bkit:lint:prose, bkit:slop:delta) and the devDeps those need are yours to\n" +
1066
1970
  "add: see .bkit/templates.md.",
1067
1971
  });
1068
1972
  }