@cbartens/bkit 6.1.1 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/.bkit/README.md +14 -12
  2. package/.bkit/core/.agents/docs.md +1 -11
  3. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +30 -9
  4. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +25 -27
  5. package/.bkit/core/.agents/rules.md +22 -9
  6. package/.bkit/core/.bkit/README.md +13 -11
  7. package/.bkit/core/.bkit/authoring.md +58 -13
  8. package/.bkit/core/.bkit/cli.md +42 -32
  9. package/.bkit/core/.bkit/cloud.md +93 -30
  10. package/.bkit/core/.bkit/install.md +55 -16
  11. package/.bkit/core/.bkit/jsonl.md +24 -7
  12. package/.bkit/core/.bkit/pipeline.md +8 -8
  13. package/.bkit/core/.bkit/prompts.md +160 -43
  14. package/.bkit/core/.bkit/providers.md +97 -36
  15. package/.bkit/core/.bkit/templates.md +162 -34
  16. package/.bkit/core/.bkit/trackers.md +39 -6
  17. package/.bkit/core/.bkit/workflows.md +344 -136
  18. package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +50 -27
  19. package/.bkit/core/.claude/hooks/bkit-preflight.sh +11 -11
  20. package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +13 -8
  21. package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +14 -25
  22. package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +20 -9
  23. package/.bkit/core/.cursor/hooks/bkit-preflight.sh +8 -8
  24. package/.bkit/core/.opencode/plugin/bkit-gateguard.js +14 -4
  25. package/.bkit/core/.opencode/plugin/bkit-guardrails.js +114 -0
  26. package/.bkit/core/docs/templates/bkit-audit-accessibility.md +1 -1
  27. package/.bkit/core/docs/templates/bkit-audit-adoption.md +30 -6
  28. package/.bkit/core/docs/templates/bkit-audit-agents.md +1 -1
  29. package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +1 -1
  30. package/.bkit/core/docs/templates/bkit-audit-analytics.md +1 -1
  31. package/.bkit/core/docs/templates/bkit-audit-annotations.md +1 -1
  32. package/.bkit/core/docs/templates/bkit-audit-app-performance.md +1 -1
  33. package/.bkit/core/docs/templates/bkit-audit-app-store.md +1 -1
  34. package/.bkit/core/docs/templates/bkit-audit-architecture.md +1 -1
  35. package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +2 -2
  36. package/.bkit/core/docs/templates/bkit-audit-config.md +3 -2
  37. package/.bkit/core/docs/templates/bkit-audit-cost.md +1 -1
  38. package/.bkit/core/docs/templates/bkit-audit-coverage.md +1 -1
  39. package/.bkit/core/docs/templates/bkit-audit-database.md +3 -3
  40. package/.bkit/core/docs/templates/bkit-audit-dead-code.md +1 -1
  41. package/.bkit/core/docs/templates/bkit-audit-deferrals.md +1 -1
  42. package/.bkit/core/docs/templates/bkit-audit-dependencies.md +3 -3
  43. package/.bkit/core/docs/templates/bkit-audit-documentation.md +32 -2
  44. package/.bkit/core/docs/templates/bkit-audit-duplication.md +1 -1
  45. package/.bkit/core/docs/templates/bkit-audit-failures.md +1 -1
  46. package/.bkit/core/docs/templates/bkit-audit-flakes.md +2 -2
  47. package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -3
  48. package/.bkit/core/docs/templates/bkit-audit-issues.md +1 -1
  49. package/.bkit/core/docs/templates/bkit-audit-llm.md +2 -2
  50. package/.bkit/core/docs/templates/bkit-audit-logs.md +1 -1
  51. package/.bkit/core/docs/templates/bkit-audit-models.md +2 -2
  52. package/.bkit/core/docs/templates/bkit-audit-privacy.md +1 -1
  53. package/.bkit/core/docs/templates/bkit-audit-prompts.md +1 -1
  54. package/.bkit/core/docs/templates/bkit-audit-red-team.md +2 -2
  55. package/.bkit/core/docs/templates/bkit-audit-reliability.md +3 -2
  56. package/.bkit/core/docs/templates/bkit-audit-repo.md +1 -1
  57. package/.bkit/core/docs/templates/bkit-audit-security.md +1 -1
  58. package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
  59. package/.bkit/core/docs/templates/bkit-audit-testing.md +3 -2
  60. package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
  61. package/.bkit/core/docs/templates/bkit-plan.md +38 -8
  62. package/.bkit/core/engine/checks/after/auth.ts +118 -47
  63. package/.bkit/core/engine/checks/after/github.ts +89 -37
  64. package/.bkit/core/engine/checks/after/index.ts +15 -3
  65. package/.bkit/core/engine/checks/after/tools.ts +245 -1
  66. package/.bkit/core/engine/checks/before/files.ts +59 -1
  67. package/.bkit/core/engine/checks/before/index.ts +8 -0
  68. package/.bkit/core/engine/checks/status-holes.ts +20 -26
  69. package/.bkit/core/engine/checks/tips/catalogue.ts +107 -10
  70. package/.bkit/core/engine/checks/tips/detect.ts +36 -3
  71. package/.bkit/core/engine/checks/tips/index.ts +1 -1
  72. package/.bkit/core/engine/cli.ts +13 -13
  73. package/.bkit/core/engine/commands/ci/ci.ts +64 -11
  74. package/.bkit/core/engine/commands/ci/push-gate.ts +101 -43
  75. package/.bkit/core/engine/commands/install/install.ts +28 -25
  76. package/.bkit/core/engine/commands/install/uninstall.ts +42 -30
  77. package/.bkit/core/engine/commands/install/upgrade.ts +14 -2
  78. package/.bkit/core/engine/commands/land.ts +2 -3
  79. package/.bkit/core/engine/commands/lib.ts +394 -39
  80. package/.bkit/core/engine/commands/registry.ts +1 -1
  81. package/.bkit/core/engine/commands/workflow/branches.ts +351 -78
  82. package/.bkit/core/engine/commands/workflow/challenge.ts +63 -14
  83. package/.bkit/core/engine/commands/workflow/context.ts +71 -10
  84. package/.bkit/core/engine/commands/workflow/counters.ts +298 -23
  85. package/.bkit/core/engine/commands/workflow/decisions.ts +260 -125
  86. package/.bkit/core/engine/commands/workflow/disk.ts +2 -1
  87. package/.bkit/core/engine/commands/workflow/feature-base.ts +66 -0
  88. package/.bkit/core/engine/commands/workflow/issues.ts +312 -17
  89. package/.bkit/core/engine/commands/workflow/junit.ts +204 -0
  90. package/.bkit/core/engine/commands/workflow/ledgers.ts +904 -99
  91. package/.bkit/core/engine/commands/workflow/locks.ts +186 -29
  92. package/.bkit/core/engine/commands/workflow/loops.ts +87 -0
  93. package/.bkit/core/engine/commands/workflow/open-decision.ts +251 -0
  94. package/.bkit/core/engine/commands/workflow/plan-blocks.ts +8 -0
  95. package/.bkit/core/engine/commands/workflow/plans.ts +1 -1
  96. package/.bkit/core/engine/commands/workflow/prs.ts +311 -16
  97. package/.bkit/core/engine/commands/workflow/repo.ts +1 -1
  98. package/.bkit/core/engine/commands/workflow/run-facts.ts +6 -0
  99. package/.bkit/core/engine/commands/workflow/runs.ts +877 -174
  100. package/.bkit/core/engine/commands/workflow/runtime.ts +12 -4
  101. package/.bkit/core/engine/commands/workflow/status.ts +324 -11
  102. package/.bkit/core/engine/commands/workflow/step-table.ts +41 -15
  103. package/.bkit/core/engine/commands/workflow/steps.ts +604 -29
  104. package/.bkit/core/engine/commands/workflow/summary-findings.ts +1 -1
  105. package/.bkit/core/engine/commands/workflow/summary.ts +314 -8
  106. package/.bkit/core/engine/commands/workflow/tasks.ts +400 -27
  107. package/.bkit/core/engine/commands/workflow/tests-base.ts +319 -0
  108. package/.bkit/core/engine/commands/workflow/tests-changed.ts +138 -74
  109. package/.bkit/core/engine/commands/workflow/tests-jump.ts +93 -0
  110. package/.bkit/core/engine/commands/workflow/tests.ts +815 -182
  111. package/.bkit/core/engine/commands/workflow/tracker.ts +1134 -137
  112. package/.bkit/core/engine/commands/workflow/workflows.ts +100 -72
  113. package/.bkit/core/engine/commands/workflow/worktrees.ts +421 -57
  114. package/.bkit/core/engine/install/cloud-env.ts +38 -10
  115. package/.bkit/core/engine/install/managed-block.ts +105 -0
  116. package/.bkit/core/engine/install/manifest.ts +7 -1
  117. package/.bkit/core/engine/install/modules/claude.ts +6 -2
  118. package/.bkit/core/engine/install/modules/cloud.ts +84 -95
  119. package/.bkit/core/engine/install/modules/codex.ts +10 -2
  120. package/.bkit/core/engine/install/modules/core.ts +148 -14
  121. package/.bkit/core/engine/install/modules/opencode.ts +18 -23
  122. package/.bkit/core/engine/install/network-allowlist.ts +8 -3
  123. package/.bkit/core/engine/install/project-docs.ts +650 -0
  124. package/.bkit/core/engine/install/template-copies.ts +58 -5
  125. package/.bkit/core/engine/install/write.ts +128 -7
  126. package/.bkit/core/engine/ledgers/journal.ts +18 -10
  127. package/.bkit/core/engine/ledgers/migrate.ts +20 -8
  128. package/.bkit/core/engine/ledgers/status.ts +604 -8
  129. package/.bkit/core/engine/ledgers/telemetry.ts +115 -13
  130. package/.bkit/core/engine/render/trackers.ts +3 -1
  131. package/.bkit/core/engine/shared/package-manager.ts +7 -3
  132. package/.bkit/core/engine/shared/settings.ts +12 -1
  133. package/.bkit/core/engine/shared/text.ts +14 -0
  134. package/.bkit/core/engine/tools/instructions-sources.ts +1 -0
  135. package/.bkit/core/engine/tools/instructions.ts +116 -20
  136. package/.bkit/core/hooks/antigravity-hook.js +20 -4
  137. package/.bkit/core/hooks/gateguard-edit-payload.js +8 -5
  138. package/.bkit/core/hooks/gateguard-engine.js +249 -23
  139. package/.bkit/core/hooks/guardrails-deny.js +167 -0
  140. package/.bkit/core/hooks/guardrails-read.js +3 -3
  141. package/.bkit/core/hooks/guardrails-shell.js +1122 -167
  142. package/.bkit/core/hooks/guardrails-tiers.js +247 -176
  143. package/.bkit/core/hooks/preflight-tracker.sh +219 -0
  144. package/.bkit/core/prompts/bkit-audit-generate.md +23 -6
  145. package/.bkit/core/prompts/bkit-build-challenge-1.md +5 -4
  146. package/.bkit/core/prompts/bkit-build-challenge-2.md +6 -5
  147. package/.bkit/core/prompts/bkit-build-install-skills.md +2 -2
  148. package/.bkit/core/prompts/bkit-build-plan-convert.md +21 -7
  149. package/.bkit/core/prompts/bkit-build-plan-current.md +5 -4
  150. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +22 -17
  151. package/.bkit/core/prompts/bkit-build-plan-tasks.md +16 -12
  152. package/.bkit/core/prompts/bkit-build-plan-tests.md +14 -10
  153. package/.bkit/core/prompts/bkit-build-plan-verify.md +21 -8
  154. package/.bkit/core/prompts/bkit-debug-abort-handover.md +10 -5
  155. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +22 -6
  156. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +19 -3
  157. package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +22 -6
  158. package/.bkit/core/prompts/bkit-debug-failure-soak.md +10 -7
  159. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +3 -3
  160. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +4 -4
  161. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +3 -3
  162. package/.bkit/core/prompts/bkit-design-generate.md +6 -4
  163. package/.bkit/core/prompts/bkit-design-organise.md +4 -3
  164. package/.bkit/core/prompts/bkit-design-review-1.md +5 -4
  165. package/.bkit/core/prompts/bkit-design-review-2.md +6 -5
  166. package/.bkit/core/prompts/bkit-design-spike.md +4 -3
  167. package/.bkit/core/prompts/bkit-design-update.md +6 -4
  168. package/.bkit/core/prompts/bkit-plan-generate.md +35 -14
  169. package/.bkit/core/prompts/bkit-plan-review-1.md +9 -7
  170. package/.bkit/core/prompts/bkit-plan-review-2.md +9 -7
  171. package/.bkit/core/prompts/bkit-plan-scope-check.md +8 -6
  172. package/.bkit/core/prompts/bkit-plan-update.md +22 -8
  173. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +11 -8
  174. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +9 -5
  175. package/.bkit/core/prompts/bkit-ship-update-docs.md +26 -4
  176. package/.bkit/core/prompts/bkit-utility-compress-markdown.md +3 -3
  177. package/.bkit/core/prompts/bkit-utility-update-decisions.md +10 -7
  178. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +8 -5
  179. package/.bkit/core/prompts/bkit-utility-update-documentation.md +31 -7
  180. package/.bkit/core/prompts/bkit-utility-update-failures.md +8 -5
  181. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +10 -7
  182. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +4 -4
  183. package/.bkit/core/prompts/bkit-utility-update-tracker.md +4 -4
  184. package/.bkit/core/workflows/bkit-auto.md +23 -11
  185. package/.bkit/core/workflows/bkit-build.md +331 -100
  186. package/.bkit/core/workflows/bkit-debug.md +135 -64
  187. package/.bkit/core/workflows/bkit-design.md +58 -32
  188. package/.bkit/core/workflows/bkit-plan.md +73 -45
  189. package/.bkit/core/workflows/bkit-ship.md +233 -167
  190. package/.bkit/shared/.agents/plugins/bkit/hooks.json +1 -1
  191. package/.bkit/shared/.bkit/.env.example +5 -0
  192. package/.bkit/shared/.claude/bkit-cloud.md +7 -7
  193. package/.bkit/shared/.claude/settings.json +5 -1
  194. package/.bkit/shared/.cursor/bkit-cloud.md +1 -1
  195. package/.bkit/shared/.cursor/hooks.json +1 -1
  196. package/.bkit/shared/.opencode/opencode.json +11 -2
  197. package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +27 -0
  198. package/.bkit/templates/.cursor/Dockerfile +7 -7
  199. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +1 -1
  200. package/.bkit/templates/.github/dependabot.yml +5 -0
  201. package/.bkit/templates/.github/renovate.json5 +5 -3
  202. package/.bkit/templates/.github/workflows/bkit-ci.yml +11 -11
  203. package/.bkit/templates/.github/workflows/bkit-cloud.yml +525 -161
  204. package/.bkit/templates/.github/workflows/bkit-renovate.yml +2 -2
  205. package/.bkit/templates/.husky/pre-push +123 -6
  206. package/.bkit/templates/context/bkit-serena.md +1 -1
  207. package/.bkit/templates/docs/architecture.md +98 -0
  208. package/.bkit/templates/docs/capabilities.md +33 -37
  209. package/.bkit/templates/docs/components.md +142 -0
  210. package/.bkit/templates/docs/data-schema.md +87 -0
  211. package/.bkit/{shared → templates}/docs/deployments.md +128 -142
  212. package/.bkit/templates/docs/design.md +117 -0
  213. package/.bkit/templates/docs/noise.md +54 -0
  214. package/.bkit/templates/docs/observability.md +99 -0
  215. package/.bkit/templates/docs/security.md +137 -0
  216. package/.bkit/templates/docs/setup.md +93 -0
  217. package/.bkit/templates/docs/technology.md +70 -0
  218. package/.bkit/{shared → templates}/docs/testing.md +200 -87
  219. package/.bkit/templates/scripts/ci/bkit-machine-lock.sh +511 -103
  220. package/.bkit/templates/scripts/ci/bkit-test-awake.mjs +228 -35
  221. package/.bkit/templates/scripts/ci/bkit-test-awake.test.mjs +270 -2
  222. package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +1 -1
  223. package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +92 -63
  224. package/.bkit/templates/scripts/graphify/bkit-graphify.sh +59 -11
  225. package/.bkit/templates/slop-scan.config.json +2 -0
  226. package/CHANGELOG.md +64 -0
  227. package/DETAILS.md +24 -19
  228. package/README.md +1 -1
  229. package/dist/checks/after/auth.js +114 -46
  230. package/dist/checks/after/github.js +77 -35
  231. package/dist/checks/after/index.js +12 -3
  232. package/dist/checks/after/tools.js +224 -1
  233. package/dist/checks/before/files.js +59 -1
  234. package/dist/checks/before/index.js +7 -1
  235. package/dist/checks/status-holes.js +20 -21
  236. package/dist/checks/tips/catalogue.js +99 -10
  237. package/dist/checks/tips/detect.js +35 -3
  238. package/dist/checks/tips/index.js +1 -1
  239. package/dist/cli.js +13 -13
  240. package/dist/commands/ci/ci.js +56 -12
  241. package/dist/commands/ci/push-gate.js +79 -44
  242. package/dist/commands/install/install.js +23 -22
  243. package/dist/commands/install/uninstall.js +36 -30
  244. package/dist/commands/install/upgrade.js +10 -2
  245. package/dist/commands/land.js +2 -3
  246. package/dist/commands/lib.js +323 -25
  247. package/dist/commands/workflow/branches.js +312 -72
  248. package/dist/commands/workflow/challenge.js +66 -13
  249. package/dist/commands/workflow/context.js +46 -10
  250. package/dist/commands/workflow/counters.js +231 -23
  251. package/dist/commands/workflow/decisions.js +221 -106
  252. package/dist/commands/workflow/disk.js +2 -1
  253. package/dist/commands/workflow/feature-base.js +60 -0
  254. package/dist/commands/workflow/issues.js +243 -15
  255. package/dist/commands/workflow/junit.js +137 -0
  256. package/dist/commands/workflow/ledgers.js +726 -112
  257. package/dist/commands/workflow/locks.js +150 -29
  258. package/dist/commands/workflow/loops.js +67 -0
  259. package/dist/commands/workflow/open-decision.js +199 -0
  260. package/dist/commands/workflow/plan-blocks.js +6 -0
  261. package/dist/commands/workflow/plans.js +1 -1
  262. package/dist/commands/workflow/prs.js +272 -16
  263. package/dist/commands/workflow/repo.js +1 -1
  264. package/dist/commands/workflow/run-facts.js +6 -0
  265. package/dist/commands/workflow/runs.js +747 -155
  266. package/dist/commands/workflow/runtime.js +8 -4
  267. package/dist/commands/workflow/status.js +259 -13
  268. package/dist/commands/workflow/step-table.js +41 -15
  269. package/dist/commands/workflow/steps.js +530 -26
  270. package/dist/commands/workflow/summary-findings.js +1 -1
  271. package/dist/commands/workflow/summary.js +289 -8
  272. package/dist/commands/workflow/tasks.js +294 -27
  273. package/dist/commands/workflow/tests-base.js +266 -0
  274. package/dist/commands/workflow/tests-changed.js +130 -56
  275. package/dist/commands/workflow/tests-jump.js +77 -0
  276. package/dist/commands/workflow/tests.js +608 -131
  277. package/dist/commands/workflow/tracker.js +920 -112
  278. package/dist/commands/workflow/workflows.js +80 -59
  279. package/dist/commands/workflow/worktrees.js +387 -58
  280. package/dist/install/cloud-env.js +32 -10
  281. package/dist/install/managed-block.js +101 -0
  282. package/dist/install/manifest.js +7 -1
  283. package/dist/install/modules/claude.js +6 -2
  284. package/dist/install/modules/cloud.js +73 -86
  285. package/dist/install/modules/codex.js +9 -2
  286. package/dist/install/modules/core.js +133 -14
  287. package/dist/install/modules/opencode.js +18 -23
  288. package/dist/install/network-allowlist.js +8 -3
  289. package/dist/install/project-docs.js +551 -0
  290. package/dist/install/template-copies.js +55 -5
  291. package/dist/install/write.js +117 -5
  292. package/dist/ledgers/journal.js +10 -8
  293. package/dist/ledgers/migrate.js +20 -9
  294. package/dist/ledgers/status.js +461 -8
  295. package/dist/ledgers/telemetry.js +71 -13
  296. package/dist/render/trackers.js +3 -1
  297. package/dist/shared/package-manager.js +7 -2
  298. package/dist/shared/settings.js +8 -0
  299. package/dist/shared/text.js +13 -0
  300. package/dist/tools/instructions-sources.js +1 -0
  301. package/dist/tools/instructions.js +97 -24
  302. package/package.json +22 -15
  303. package/.bkit/core/hooks/preflight-linear.sh +0 -73
  304. package/.bkit/shared/docs/architecture.md +0 -16
  305. package/.bkit/shared/docs/data-schema.md +0 -16
  306. package/.bkit/shared/docs/design.md +0 -38
  307. package/.bkit/shared/docs/noise.md +0 -20
  308. package/.bkit/shared/docs/observability.md +0 -22
  309. package/.bkit/shared/docs/security.md +0 -62
  310. package/.bkit/shared/docs/setup.md +0 -52
  311. package/.bkit/shared/docs/technology.md +0 -15
  312. /package/.bkit/templates/{.lintstagedrc.json → lintstagedrc.example.json} +0 -0
  313. /package/.bkit/templates/{.prettierignore → prettierignore.example} +0 -0
@@ -6,13 +6,14 @@ import * as path from "node:path";
6
6
  import { writeTier1, writeTier2, ensurePackageJsonScripts } from "../write.js";
7
7
  import { readBkitVersion, writeBkitVersion, hashFile, mergeCanonicalHashes, sha256, } from "../version-file.js";
8
8
  import { extractManagedBlock, findLineAnchoredMarkers, selectMarkers, stripManagedBlock, } from "../managed-block.js";
9
- import { listFilesRecursive, syncTemplateCopies } from "../template-copies.js";
9
+ import { listFilesRecursive, warnMissingLintStagedConfig, syncTemplateCopies, } from "../template-copies.js";
10
10
  import { PAYLOAD_LINK_RELPATHS, syncPayloadLinks } from "../payload-links.js";
11
11
  import { writeNetworkAllowlist } from "../network-allowlist.js";
12
12
  import { migrateContextCiWorkflow } from "../context-ci-workflow.js";
13
13
  import { migrateTemplateNotes } from "../template-notes.js";
14
14
  import { isAdvisorySuppressed } from "../../checks/after/suppression.js";
15
15
  import { parseJson, readJsonFile } from "../../shared/json.js";
16
+ import { compareSemver } from "../../shared/bkit-latest.js";
16
17
  import { readInstallingVersion } from "../../shared/package-json.js";
17
18
  import { detectDepUpdater } from "../../shared/dep-updater.js";
18
19
  import { ASK_POINTS, CONFIG_DEFAULTS, ciWorkflowPath, limitKey } from "../../shared/settings.js";
@@ -145,8 +146,8 @@ export function listCoreTemplateFiles(root = getCoreRoot()) {
145
146
  }
146
147
  /**
147
148
  * The shared payload files core writes, sourced from `root` (defaults to the
148
- * resolved shared root): the `docs/*.md` managed blocks and the two shared-root
149
- * files the core manifest owns.
149
+ * resolved shared root): the two shared-root files the core manifest owns. The ten project
150
+ * documents are copy-and-own starters under `templates/docs/`, never written here.
150
151
  */
151
152
  export function listSharedTemplateFiles(root = getSharedRoot()) {
152
153
  const out = [];
@@ -155,14 +156,6 @@ export function listSharedTemplateFiles(root = getSharedRoot()) {
155
156
  if (fs.existsSync(src))
156
157
  out.push({ src, dst, scope: "block", marker: "html-comment" });
157
158
  }
158
- for (const name of listMdFiles(path.join(root, "docs"))) {
159
- out.push({
160
- src: path.join(root, "docs", name),
161
- dst: path.join("docs", name),
162
- scope: "block",
163
- marker: "html-comment",
164
- });
165
- }
166
159
  return out;
167
160
  }
168
161
  function runCoreTemplates(dryRun, tokens, ws, logPrefix) {
@@ -259,6 +252,7 @@ export function runBkitDocs(dryRun, tokens, ws, logPrefix) {
259
252
  migrateTemplateNotes(dryRun, ws, logPrefix);
260
253
  migrateContextCiWorkflow(dryRun, ws, logPrefix);
261
254
  migrateSlopTypeSuppression(dryRun, ws, logPrefix);
255
+ migrateMachineLockCopy(dryRun, ws, logPrefix);
262
256
  const renames = migrateBrandedTemplateFiles(dryRun, ws, logPrefix);
263
257
  migrateBrandedFileTokens(dryRun, ws, logPrefix, renames);
264
258
  migrateBrandedCheckNames(dryRun, ws, logPrefix, tokens.DEFAULT_BRANCH);
@@ -477,6 +471,9 @@ export function seedCorePackageJsonScripts(ctx) {
477
471
  if (pruneMinPushPaths(dryRun, ws, logPrefix) && !written.includes("package.json")) {
478
472
  written.push("package.json");
479
473
  }
474
+ if (lowerVerifyMaxAttempts(dryRun, ws, logPrefix) && !written.includes("package.json")) {
475
+ written.push("package.json");
476
+ }
480
477
  if (seedBkitDefaults(dryRun, ws, logPrefix) && !written.includes("package.json")) {
481
478
  written.push("package.json");
482
479
  }
@@ -512,7 +509,7 @@ export const SEEDED_BKIT_DEFAULTS = {
512
509
  cloud: { agent: "" },
513
510
  providers: { opencode: { default: "", installed: [] } },
514
511
  testing: {
515
- // What bkit writes (ship's bookkeeping allow-list, the plans tree) is always a min push;
512
+ // What bkit writes (ship's bookkeeping allow-list, the plans tree, docs/audits/**) is always a min push;
516
513
  // the seed adds nothing, because a project doc can be a test's input.
517
514
  minPushPaths: [...CONFIG_DEFAULTS.minPushPaths],
518
515
  ciWorkflow: CONFIG_DEFAULTS.ciWorkflow,
@@ -692,6 +689,89 @@ function migrateSlopTypeSuppression(dryRun, ws, logPrefix) {
692
689
  ws.writes.push({ path: file, action: "update", unhashed: true });
693
690
  console.log(`${logPrefix} ${tag}core: ${file} — slop plugin updated`);
694
691
  }
692
+ // sha256 of every released scripts/ci/bkit-machine-lock.sh text older than the current template (6.1.0, 6.1.1).
693
+ const SHIPPED_MACHINE_LOCK_HASHES = [
694
+ "63ee5873795fd06b60e1f13c238c9e3c44d9f6dc76a50fe271793de6ad284e87",
695
+ ];
696
+ // Migration (6.1.0-6.2.x installs, docs/migrations.md): replace an unedited adopted machine-lock
697
+ // copy with the current template; warn about an edited copy that lacks the queue, never writes
698
+ // the status file or has no hold limit. A copy that starts bkit-test-awake.mjs gets that file
699
+ // beside it (see `migrateHoldSupervisor`).
700
+ function migrateMachineLockCopy(dryRun, ws, logPrefix) {
701
+ const file = path.join("scripts", "ci", "bkit-machine-lock.sh");
702
+ const stat = fs.lstatSync(file, { throwIfNoEntry: false });
703
+ if (!stat)
704
+ return;
705
+ const tag = dryRun ? "[dry-run] " : "";
706
+ const templatePath = ".bkit/templates/scripts/ci/bkit-machine-lock.sh";
707
+ const outOfOrder = "waiting runs take the lock out of arrival order";
708
+ const manual = (reason, until = outOfOrder) => {
709
+ console.warn(`${logPrefix} ${tag}core: ${file} left unchanged (${reason}); merge ${templatePath} by hand, until then ${until}`);
710
+ };
711
+ if (linkedPath(file) || !stat.isFile()) {
712
+ manual("the path is not a regular file or sits under a symlink");
713
+ return;
714
+ }
715
+ const current = fs.readFileSync(file);
716
+ const template = fs.readFileSync(path.join(getTemplatesRoot(), "scripts", "ci", "bkit-machine-lock.sh"));
717
+ const text = current.toString("utf8");
718
+ if (current.equals(template)) {
719
+ migrateHoldSupervisor(dryRun, ws, logPrefix);
720
+ return;
721
+ }
722
+ if (SHIPPED_MACHINE_LOCK_HASHES.includes(sha256(current))) {
723
+ if (!dryRun)
724
+ fs.writeFileSync(file, template);
725
+ ws.writes.push({ path: file, action: "update", unhashed: true });
726
+ console.log(`${logPrefix} ${tag}core: ${file} — machine lock updated to the current template`);
727
+ migrateHoldSupervisor(dryRun, ws, logPrefix);
728
+ return;
729
+ }
730
+ if (text.includes("bkit-test-awake.mjs"))
731
+ migrateHoldSupervisor(dryRun, ws, logPrefix);
732
+ if (!text.includes(".queue"))
733
+ manual("the copy differs from the shipped version");
734
+ if (!text.includes("LOCAL_STACK_LOCK_STATUS_FILE"))
735
+ manual("the copy never writes LOCAL_STACK_LOCK_STATUS_FILE", "a lock wait that gives up reads as a gate failure (exit 1) instead of exit 81");
736
+ if (!text.includes("LOCAL_STACK_LOCK_HOLD_S"))
737
+ manual("the copy has no LOCAL_STACK_LOCK_HOLD_S hold limit", "a hung run holds the tests lock until someone stops it by hand");
738
+ }
739
+ // sha256 of every scripts/ci/bkit-test-awake.mjs template text in history older than the current one.
740
+ const SHIPPED_AWAKE_HASHES = [
741
+ "d218439bd4d65b57732a96aaea7bb678f9ebf95a6247f5e6b899d6ef26a59cb5",
742
+ "a686bf75700f2ff54de2cedd3b7afc943774da40a68c243b9911bc435742f434",
743
+ "0842c2e2789a1c77935655130de5b8cf253bfe0655407834f23a6abaaf1b0bb1",
744
+ "0dce1b50638cd609183a871ed8d0d9e3d20c545073f0a32f18526d6f38b5b748",
745
+ ];
746
+ // The machine-lock script runs a command holding its own tests lock under
747
+ // scripts/ci/bkit-test-awake.mjs --hold-s: write the template there when the file is missing,
748
+ // replace an unedited shipped copy, and warn about an edited copy without --hold-s, since the
749
+ // lock script refuses every such run with exit 73.
750
+ function migrateHoldSupervisor(dryRun, ws, logPrefix) {
751
+ const file = path.join("scripts", "ci", "bkit-test-awake.mjs");
752
+ const tag = dryRun ? "[dry-run] " : "";
753
+ const template = path.join(getTemplatesRoot(), "scripts", "ci", "bkit-test-awake.mjs");
754
+ if (!fs.lstatSync(file, { throwIfNoEntry: false })) {
755
+ if (!dryRun)
756
+ fs.copyFileSync(template, file);
757
+ ws.writes.push({ path: file, action: "write", unhashed: true });
758
+ console.log(`${logPrefix} ${tag}core: ${file} — added beside the machine lock, which runs its hold limit`);
759
+ return;
760
+ }
761
+ const stat = fs.statSync(file, { throwIfNoEntry: false });
762
+ if (stat?.isFile() &&
763
+ !linkedPath(file) &&
764
+ SHIPPED_AWAKE_HASHES.includes(sha256(fs.readFileSync(file)))) {
765
+ if (!dryRun)
766
+ fs.copyFileSync(template, file);
767
+ ws.writes.push({ path: file, action: "update", unhashed: true });
768
+ console.log(`${logPrefix} ${tag}core: ${file} — test sleep prevention updated to the current template`);
769
+ return;
770
+ }
771
+ if (stat?.isFile() && fs.readFileSync(file, "utf8").includes("--hold-s"))
772
+ return;
773
+ console.warn(`${logPrefix} ${tag}core: ${file} left unchanged (it has no --hold-s hold limit); merge .bkit/templates/scripts/ci/bkit-test-awake.mjs by hand, until then every run that holds the tests lock is refused with exit 73`);
774
+ }
695
775
  // Every `.github/workflows/*.yml` / `*.yaml` regular file outside `skip`.
696
776
  function otherWorkflows(skip) {
697
777
  const dir = path.join(".github", "workflows");
@@ -1332,7 +1412,7 @@ export const BKIT_LAYOUT_MOVES = [
1332
1412
  ];
1333
1413
  // Migration (up to 6.0.x installs, `docs/migrations.md`): `bkit.testing.minPushPaths` was the
1334
1414
  // whole min-push list, so installs seeded and repos restated what bkit itself writes. The
1335
- // engine now always allows that floor (ship's bookkeeping allow-list, `docs/plans/**`) and
1415
+ // engine now always allows that floor (ship's bookkeeping allow-list, `docs/plans/**`, `docs/audits/**`) and
1336
1416
  // `bkit.testing.ciSkipPaths`; the setting only adds. Entries the floor already covers are
1337
1417
  // dropped from the list. Returns true when package.json changed.
1338
1418
  export const MIN_PUSH_FLOOR_ENTRIES = [
@@ -1367,6 +1447,44 @@ export function pruneMinPushPaths(dryRun, ws, logPrefix) {
1367
1447
  console.log(`${logPrefix} ${dryRun ? "[dry-run] " : ""}core: dropped [${dropped.join(", ")}] from bkit.testing.minPushPaths in package.json — bkit always allows what it writes, and ciSkipPaths counts`);
1368
1448
  return true;
1369
1449
  }
1450
+ const LAST_RELEASE_WITHOUT_VERIFY_CAP = "6.1.1";
1451
+ // Migration (up to 6.1.x installs, `docs/migrations.md`): `bkit.workflows.build.verify.maxAttempts`
1452
+ // is one non-resetting allowance per run, and every build limit is 2. A value above 2 is
1453
+ // lowered to 2 once, on the upgrade from an install that predates this release (no recorded
1454
+ // version, an unreadable one, or an older one); 2 or less is left alone, and a value set after
1455
+ // that upgrade is the consumer's. Returns true when package.json changed.
1456
+ export function lowerVerifyMaxAttempts(dryRun, ws, logPrefix) {
1457
+ const pkgPath = "package.json";
1458
+ if (!fs.existsSync(pkgPath))
1459
+ return false;
1460
+ const recorded = readBkitVersion(path.join(".bkit", "version"))?.pinnedVersion ?? "";
1461
+ // Skip a re-run of the same version, and any install recorded after the last release without
1462
+ // this migration, so a value set after the upgrade to this release is never lowered again.
1463
+ const order = compareSemver(recorded, readInstallingVersion());
1464
+ if (order === 0 || order === 1)
1465
+ return false;
1466
+ if (compareSemver(recorded, LAST_RELEASE_WITHOUT_VERIFY_CAP) === 1)
1467
+ return false;
1468
+ const raw = fs.readFileSync(pkgPath, "utf-8");
1469
+ const parsed = parseJson(raw);
1470
+ if (!parsed.ok)
1471
+ return false;
1472
+ const pkg = parsed.value;
1473
+ if (!plainObject(pkg.bkit) || !plainObject(pkg.bkit.workflows))
1474
+ return false;
1475
+ const build = pkg.bkit.workflows.build;
1476
+ if (!plainObject(build) || !plainObject(build.verify))
1477
+ return false;
1478
+ const old = build.verify.maxAttempts;
1479
+ if (typeof old !== "number" || old <= 2)
1480
+ return false;
1481
+ build.verify.maxAttempts = 2;
1482
+ ws.writes.push({ path: pkgPath, action: "update" });
1483
+ if (!dryRun)
1484
+ writePackageJsonLike(raw, pkg);
1485
+ console.log(`${logPrefix} ${dryRun ? "[dry-run] " : ""}core: lowered bkit.workflows.build.verify.maxAttempts from ${old} to 2 in package.json — the holistic allowance is one per run`);
1486
+ return true;
1487
+ }
1370
1488
  // Fill `into` with each `from` key it lacks, descending into blocks both sides hold.
1371
1489
  function mergeMissing(into, from) {
1372
1490
  for (const [k, v] of Object.entries(from)) {
@@ -1608,7 +1726,7 @@ export function detectGateAdvisories(cwd) {
1608
1726
  id: "test-file-script-missing",
1609
1727
  severity: "advisory",
1610
1728
  detect: `package.json does not declare \`${BKIT_TEST_FILE_SCRIPT}\`, so \`/bkit-build\` cannot check that each task's tests fail before its code is written.`,
1611
- 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.`,
1729
+ 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\njest reads a bare path as a regex, so a folder such as \`(tabs)\` matches no file: pass \`--runTestsByPath\`. Call 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.`,
1612
1730
  });
1613
1731
  }
1614
1732
  // A red recorded before the linter sees the test: a lint rewrite after it reads as an
@@ -1702,6 +1820,7 @@ export function runCoreModule(ctx) {
1702
1820
  console.log(`${logPrefix} ${tag}template ${verb}: ${path.join(TEMPLATE_COPIES_DIR, p)}`);
1703
1821
  }
1704
1822
  }
1823
+ warnMissingLintStagedConfig(cwd, logPrefix);
1705
1824
  // 3b3. Payload view links — `.bkit/core` + `.bkit/shared` symlinks into the
1706
1825
  // installed package (browse-only, gitignored; no-op in dogfood). A real
1707
1826
  // directory or file at either path is never clobbered (advisory); a platform
@@ -116,8 +116,9 @@ export function opencodeProviderEnvVar(providerKey) {
116
116
  * secret `env:` var. `bkit install --opencode=<provider>` rewrites neither; this advisory names
117
117
  * the hand-edit.
118
118
  *
119
- * bkit-cloud.yml runs `opencode run` against the committed `.opencode/` config and fans one
120
- * `OPENCODE_PROVIDER_KEY` secret out to every provider env var, so it is not checked.
119
+ * bkit-cloud.yml runs `opencode run` against the committed `.opencode/` config and passes
120
+ * the provider's `BKIT_` secret (`BKIT_OPENCODE_API_KEY`, `BKIT_OPENROUTER_API_KEY` or
121
+ * `BKIT_OLLAMA_API_KEY`) under its own env var name, so it is not checked.
121
122
  *
122
123
  * No-op when opencode.yml is absent. No equivalent check for claude.yml (provider-fixed to
123
124
  * Claude). Severity "advisory": never gates `bkit check`; surfaces on both check and postinstall.
@@ -174,7 +175,7 @@ export function detectOpencodeYmlProviderDrift(cwd) {
174
175
  " model: " +
175
176
  expectedPrefix +
176
177
  "/<model> # a model your provider serves (see .opencode/opencode.json)\n\n" +
177
- "Keep opencode.yml in sync with .opencode/opencode.json on every provider switch. (bkit-cloud.yml needs no such edit: it reads .opencode/ and fans OPENCODE_PROVIDER_KEY out to every provider env var.)",
178
+ "Keep opencode.yml in sync with .opencode/opencode.json on every provider switch. (bkit-cloud.yml needs no such edit: it reads .opencode/ and passes the provider's BKIT_ secret under its own name.)",
178
179
  };
179
180
  }
180
181
  // Sentinel values used in the opencode.json template for tracker-filtered mcp injection.
@@ -188,10 +189,8 @@ const OPENCODE_PROVIDER_BASE_URL_SENTINEL = "@@OPENCODE_PROVIDER_BASE_URL@@";
188
189
  * and fills in provider-specific fields.
189
190
  *
190
191
  * Also injects derived **allow** rules for {@link resolveNetworkAllowlist} so
191
- * context-fetch / provider hosts do not prompt on either fetch surface: `curl *{domain}*` /
192
- * `wget *{domain}*` after the template's `curl *` / `wget *` ask (OpenCode bash is
193
- * last-match-wins), and `*{domain}*` into the `permission.webfetch` URL map (after its
194
- * `"*": "ask"`). Adds `<server>_*` allows for the consumer's `mcp-servers` block.
192
+ * context-fetch / provider hosts do not prompt on the fetch tool: `*{domain}*` into the
193
+ * `permission.webfetch` URL map (after its `"*": "ask"`); shell fetches keep asking. Adds `<server>_*` allows for the consumer's `mcp-servers` block.
195
194
  */
196
195
  export function renderOpencodeJson(templatePath, tracker, provider, cwd = process.cwd()) {
197
196
  const raw = fs.readFileSync(templatePath, "utf-8");
@@ -280,12 +279,10 @@ export function renderOpencodeJson(templatePath, tracker, provider, cwd = proces
280
279
  * last-match-wins), and one `<server>_*` allow per declared MCP server — opencode names
281
280
  * MCP tools `<server>_<tool>` and matches permission keys as globs against the tool name.
282
281
  *
283
- * The allowlist is applied to BOTH fetch surfaces, so an allowlisted host does not prompt
284
- * whichever path the agent takes:
285
- * - fetch tool — `permission.webfetch` is a URL-keyed map (`{ "*": "ask" }` from the
286
- * template); opencode matches the resource against the URL, so `*{base}*` allows it;
287
- * - shell fetch — `permission.bash` gains `curl *{base}*` / `wget *{base}*` after the
288
- * template's `curl *` / `wget *` ask.
282
+ * Only the fetch tool gets derived allows: `permission.webfetch` is a URL-keyed map
283
+ * (`{ "*": "ask" }` from the template); opencode matches the resource against the URL, so
284
+ * `*{base}*` allows it (accepted risk, decision 551). Shell `curl` / `wget` keep the
285
+ * template's ask, because a glob over the command string also matches a host in a query.
289
286
  */
290
287
  function injectOpencodeDerivedAllows(parsed, cwd) {
291
288
  const permission = parsed.permission;
@@ -295,13 +292,6 @@ function injectOpencodeDerivedAllows(parsed, cwd) {
295
292
  permission[`${server}_*`] = "allow";
296
293
  }
297
294
  const bases = networkAllowlistBases(resolveNetworkAllowlist(cwd));
298
- if (typeof permission.bash === "object" && permission.bash !== null) {
299
- const bash = permission.bash;
300
- for (const base of bases) {
301
- bash[`curl *${base}*`] = "allow";
302
- bash[`wget *${base}*`] = "allow";
303
- }
304
- }
305
295
  // Fetch tool — opencode matches the webfetch resource against the requested URL.
306
296
  if (typeof permission.webfetch === "object" && permission.webfetch !== null) {
307
297
  const webfetch = permission.webfetch;
@@ -450,9 +440,14 @@ export function runOpencodeModule(ctx) {
450
440
  }
451
441
  }
452
442
  }
453
- // --- bkit-gateguard.js / bkit-readguard.js / bkit-rules.js — Tier-2 markered-text
454
- // (slash-comment); see install/manifest.ts ---
455
- for (const plugin of ["bkit-gateguard.js", "bkit-readguard.js", "bkit-rules.js"]) {
443
+ // --- bkit-gateguard.js / bkit-readguard.js / bkit-rules.js / bkit-guardrails.js — Tier-2
444
+ // markered-text (slash-comment); see install/manifest.ts ---
445
+ for (const plugin of [
446
+ "bkit-gateguard.js",
447
+ "bkit-readguard.js",
448
+ "bkit-rules.js",
449
+ "bkit-guardrails.js",
450
+ ]) {
456
451
  const opencodeCore = path.join(getCoreRoot(), ".opencode", "plugin");
457
452
  const pluginSrc = path.join(opencodeCore, plugin);
458
453
  const pluginDst = `.opencode/plugin/${plugin}`;
@@ -5,15 +5,20 @@
5
5
  // it exists for every host that reads it and `bkit check` reports it missing or stale.
6
6
  import * as fs from "node:fs";
7
7
  import * as path from "node:path";
8
- import { resolveNetworkAllowlist } from "./cloud-env.js";
8
+ import { egressFingerprint, resolveNetworkAllowlist } from "./cloud-env.js";
9
9
  import { readBkitVersion } from "./version-file.js";
10
10
  /** Consumer-relative path of the install-written curl/wget allowlist. */
11
11
  export const NETWORK_ALLOWLIST_RELPATH = path.join(".bkit", "allowlist.json");
12
12
  /** Where the cursor module wrote the allowlist up to 5.2.4 (migrated away). */
13
13
  export const RETIRED_NETWORK_ALLOWLIST_RELPATH = path.join(".cursor", "allowlist.json");
14
- /** The allowlist file body: `{ domains }`, apex + `*.` wildcard per base, sorted. */
14
+ /**
15
+ * The allowlist file body: `{ domains, fingerprint }` — `domains` is apex + `*.` wildcard
16
+ * per base, sorted; `fingerprint` is the 8-hex stamp of that list, which the cloud
17
+ * bootstrap compares with `BKIT_CLOUD_ALLOWLIST_FINGERPRINT`.
18
+ */
15
19
  export function renderNetworkAllowlist(cwd) {
16
- return JSON.stringify({ domains: resolveNetworkAllowlist(cwd) }, null, 2) + "\n";
20
+ const domains = resolveNetworkAllowlist(cwd);
21
+ return JSON.stringify({ domains, fingerprint: egressFingerprint(domains) }, null, 2) + "\n";
17
22
  }
18
23
  /**
19
24
  * Write `.bkit/allowlist.json` whole (hand edits do not survive — `allowed-domains` in