@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
@@ -1,15 +1,14 @@
1
1
  // Local full-gate receipts, shared by linked worktrees and bound to committed trees.
2
- import { spawnSync } from "node:child_process";
3
2
  import { createHash, randomUUID } from "node:crypto";
4
3
  import * as fs from "node:fs";
5
- import * as os from "node:os";
6
4
  import * as path from "node:path";
7
5
  import { gitEnv } from "../../ledgers/telemetry.js";
8
6
  import { parseJson, readJsonFile } from "../../shared/json.js";
9
7
  import { readPackageJson } from "../../shared/package-json.js";
10
- import { scriptCommand, testCommand } from "../../shared/package-manager.js";
11
- import { EXIT, git, outboxRoot, runGit } from "../lib.js";
12
- import { changedOutside } from "../workflow/ledgers.js";
8
+ import { scriptCommand } from "../../shared/package-manager.js";
9
+ import { EXIT, git, LOCK_STATUS_FILE_ENV, outboxRoot, runGit } from "../lib.js";
10
+ import { pidAlive } from "../workflow/disk.js";
11
+ import { type LockedRun, runGateUnderLock } from "../workflow/junit.js";
13
12
 
14
13
  const UNIT = "bkit:gate:static-unit";
15
14
  const INTEGRATION = "bkit:gate:static-unit-integration";
@@ -44,29 +43,58 @@ const receiptPath = (cwd: string, sha: string): string | null => {
44
43
  return outbox ? path.join(outbox, "push-gates", `${sha}.json`) : null;
45
44
  };
46
45
 
47
- function cleanHead(cwd: string): { sha: string; tree: string } | null {
48
- const status = git(cwd, [
49
- "status",
50
- "--porcelain",
51
- "--untracked-files=all",
52
- "--ignore-submodules=none",
53
- ]);
54
- if (status !== "") return null;
46
+ const STATUS = [
47
+ "status",
48
+ "--porcelain",
49
+ "--no-renames",
50
+ "--untracked-files=all",
51
+ "--ignore-submodules=none",
52
+ ];
53
+ const lineCount = (text: string | null): number =>
54
+ text === null ? -1 : text === "" ? 0 : text.split("\n").length;
55
+
56
+ /** HEAD when every uncommitted path lies inside `tolerated` (none given: the tree must be clean). */
57
+ function cleanHead(
58
+ cwd: string,
59
+ tolerated: readonly string[] = [],
60
+ ): { sha: string; tree: string } | null {
61
+ const all = lineCount(git(cwd, STATUS));
62
+ if (all < 0) return null;
63
+ if (all > 0) {
64
+ if (tolerated.length === 0) return null;
65
+ if (lineCount(git(cwd, [...STATUS, "--", ...tolerated])) !== all) return null;
66
+ }
55
67
  const sha = git(cwd, ["rev-parse", "--verify", "HEAD^{commit}"]);
56
68
  const tree = git(cwd, ["rev-parse", "--verify", "HEAD^{tree}"]);
57
69
  return sha && tree ? { sha, tree } : null;
58
70
  }
59
71
 
60
- /** Execute a consumer gate; only a successful deepest full gate on an unchanged clean tree earns proof. */
61
- export function runPushGate(cwd: string, gate: string, log: (message: string) => void): number {
72
+ /** The recorded runner's process id of a `.running` attempt file; null when unreadable. */
73
+ function attemptPid(file: string): number | null {
74
+ const read = readJsonFile(file);
75
+ if (!read.ok || !read.value || typeof read.value !== "object") return null;
76
+ const pid = (read.value as Record<string, unknown>).pid;
77
+ return typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? pid : null;
78
+ }
79
+
80
+ /**
81
+ * Run a gate through `run` and record its receipt: the `.running` marker while it runs, a
82
+ * `.failed` marker when it fails, the before/after HEAD and fingerprint check, and the
83
+ * receipt write. An attempt on the same commit whose runner process is gone counts as a
84
+ * failed run and is cleared. Uncommitted paths in `tolerated` do not block the receipt; a
85
+ * lock wait (`waited`, default never) leaves the receipt and markers as they were.
86
+ */
87
+ export function runWithReceipt(
88
+ cwd: string,
89
+ gate: string,
90
+ tolerated: readonly string[],
91
+ run: () => number,
92
+ log: (message: string) => void,
93
+ waited: (status: number) => boolean = () => false,
94
+ ): number {
62
95
  const pkg = readPackageJson(cwd);
63
- const script = pkg.ok ? scriptsOf(pkg.pkg)?.[gate] : null;
64
- if (typeof script !== "string" || script.trim() === "") {
65
- log(`package.json must declare a non-empty ${gate} script`);
66
- return EXIT.USAGE;
67
- }
68
96
  const definition = pkg.ok ? gateDefinition(pkg.pkg) : null;
69
- const before = cleanHead(cwd);
97
+ const before = cleanHead(cwd, tolerated);
70
98
  const head = git(cwd, ["rev-parse", "--verify", "HEAD^{commit}"]);
71
99
  const file = head ? receiptPath(cwd, head) : null;
72
100
  const attempt =
@@ -81,31 +109,27 @@ export function runPushGate(cwd: string, gate: string, log: (message: string) =>
81
109
  fs.rmSync(file, { force: true });
82
110
  };
83
111
  if (attempt) {
84
- fs.mkdirSync(path.dirname(attempt), { recursive: true });
112
+ const dir = path.dirname(attempt);
113
+ fs.mkdirSync(dir, { recursive: true });
114
+ for (const entry of fs.readdirSync(dir)) {
115
+ const pid = attemptPid(path.join(dir, entry));
116
+ if (pid === null || pidAlive(pid)) continue;
117
+ fs.rmSync(path.join(dir, entry), { force: true });
118
+ fail();
119
+ }
85
120
  fs.writeFileSync(attempt, JSON.stringify({ pid: process.pid, sha: head }) + "\n");
86
- fail();
87
121
  }
88
122
  const finish = (code: number) => {
89
123
  if (attempt) fs.rmSync(attempt, { force: true });
90
124
  return code;
91
125
  };
92
- const argv = testCommand(scriptCommand(gate));
93
- log(`running ${scriptCommand(gate).join(" ")}`);
94
- const result = spawnSync(argv[0]!, argv.slice(1), {
95
- cwd,
96
- env: gitEnv(),
97
- stdio: ["ignore", 2, 2],
98
- });
99
- const status = result.error
100
- ? 127
101
- : (result.status ??
102
- 128 + ((result.signal ? os.constants.signals[result.signal] : undefined) ?? 1));
103
- if (result.error) log(result.error.message);
126
+ const status = run();
127
+ if (waited(status)) return finish(status);
104
128
  if (status !== 0 || !before || definition?.gate !== gate) {
105
129
  fail();
106
130
  return finish(status);
107
131
  }
108
- const after = cleanHead(cwd);
132
+ const after = cleanHead(cwd, tolerated);
109
133
  const afterPkg = readPackageJson(cwd);
110
134
  if (
111
135
  after?.sha !== before.sha ||
@@ -129,6 +153,40 @@ export function runPushGate(cwd: string, gate: string, log: (message: string) =>
129
153
  return finish(status);
130
154
  }
131
155
 
156
+ /**
157
+ * Execute a consumer gate; only a successful deepest full gate on an unchanged clean tree earns
158
+ * proof. A tests-lock wait (the lock wrapper gave up, exit 75) leaves the receipt and its
159
+ * markers as they were, and its status file is handed on to a caller that asked for one.
160
+ */
161
+ export function runPushGate(cwd: string, gate: string, log: (message: string) => void): number {
162
+ const pkg = readPackageJson(cwd);
163
+ const script = pkg.ok ? scriptsOf(pkg.pkg)?.[gate] : null;
164
+ if (typeof script !== "string" || script.trim() === "") {
165
+ log(`package.json must declare a non-empty ${gate} script`);
166
+ return EXIT.USAGE;
167
+ }
168
+ const env = gitEnv();
169
+ const lock: { run?: LockedRun } = {};
170
+ return runWithReceipt(
171
+ cwd,
172
+ gate,
173
+ [],
174
+ () => {
175
+ log(`running ${scriptCommand(gate).join(" ")}`);
176
+ lock.run = runGateUnderLock(
177
+ scriptCommand(gate),
178
+ cwd,
179
+ 2,
180
+ { LOCAL_STACK_LOCK_WHO: env.LOCAL_STACK_LOCK_WHO || `bkit ci push-gate ${gate}` },
181
+ { base: env, forwardStatusTo: env[LOCK_STATUS_FILE_ENV] },
182
+ );
183
+ return lock.run.exitCode;
184
+ },
185
+ log,
186
+ () => lock.run?.lock === "lock-wait",
187
+ );
188
+ }
189
+
132
190
  /** Pending files survive interrupted runners; one read suffices to block earlier proof. */
133
191
  function pendingAttempt(file: string): boolean {
134
192
  const dir = `${file}.running`;
@@ -189,13 +247,13 @@ export function hasVerifiedIncrement(
189
247
  cwd: string,
190
248
  oldSha: string,
191
249
  newSha: string,
192
- paths: string[],
250
+ outsideOf: (from: string, to: string) => { ok: true; outside: string[] } | { ok: false },
193
251
  ): boolean {
252
+ const isNew = /^0+$/.test(oldSha);
194
253
  if (
195
- !SHA.test(oldSha) ||
254
+ (!isNew && !SHA.test(oldSha)) ||
196
255
  !SHA.test(newSha) ||
197
- /^0+$/.test(oldSha) ||
198
- !runGit(cwd, ["merge-base", "--is-ancestor", oldSha, newSha]).ok
256
+ (!isNew && !runGit(cwd, ["merge-base", "--is-ancestor", oldSha, newSha]).ok)
199
257
  )
200
258
  return false;
201
259
  const raw = git(cwd, ["show", `${newSha}:package.json`]);
@@ -208,14 +266,14 @@ export function hasVerifiedIncrement(
208
266
  gateDefinition(localPkg.pkg)?.fingerprint !== definition.fingerprint
209
267
  )
210
268
  return false;
211
- const ancestors = git(cwd, ["rev-list", "--max-count=128", oldSha]);
212
- const firstFile = receiptPath(cwd, oldSha);
269
+ const ancestors = git(cwd, ["rev-list", "--max-count=128", isNew ? newSha : oldSha]);
270
+ const firstFile = receiptPath(cwd, newSha);
213
271
  if (!ancestors || !firstFile) return false;
214
272
  const dir = path.dirname(firstFile);
215
273
  for (const sha of ancestors.split("\n")) {
216
274
  const file = path.join(dir, `${sha}.json`);
217
275
  if (!validReceipt(cwd, file, sha, definition)) continue;
218
- const diff = changedOutside(cwd, sha, newSha, paths);
276
+ const diff = outsideOf(sha, newSha);
219
277
  if (diff.ok && diff.outside.length === 0 && noLaterFailure(cwd, dir, sha, newSha, definition))
220
278
  return true;
221
279
  }
@@ -7,11 +7,7 @@ import { OPENCODE_PROVIDERS } from "../../shared/egress.js";
7
7
  import { type ModuleFlag, type CloudVariant } from "../../cli.js";
8
8
  import { readInstallingVersion } from "../../shared/package-json.js";
9
9
  import { type ModuleContext, dispatchModules } from "../../install/modules/index.js";
10
- import {
11
- type IssueTracker,
12
- DEFAULT_ISSUE_TRACKER,
13
- type ModuleName,
14
- } from "../../install/manifest.js";
10
+ import { type IssueTracker, type ModuleName } from "../../install/manifest.js";
15
11
  import { parseJson, readJsonFile } from "../../shared/json.js";
16
12
  import { readBkitConfig } from "../../shared/settings.js";
17
13
  import { LOG_PREFIX, setLogPrefix } from "../../shared/log-prefix.js";
@@ -28,6 +24,7 @@ import type { SuppressionNote } from "../../checks/after/suppression.js";
28
24
  import { collectTips } from "../../checks/tips/index.js";
29
25
  import { findMissingOwnedHooks, detectOwnedHookMissing } from "../../checks/after/managed.js";
30
26
  import { resolveTokens } from "../../install/placeholders.js";
27
+ import { syncProjectDocs } from "../../install/project-docs.js";
31
28
  import {
32
29
  type EffortMap,
33
30
  parseModelLookup,
@@ -113,27 +110,18 @@ export function modulesToCliFlags(
113
110
  }
114
111
 
115
112
  /**
116
- * Symmetric cloud/tracker constraint (FINAL SCOPE decision 3/4): cloud=claude and
117
- * cloud=opencode both require tracker=github (both use the bkit-cloud.yml template);
118
- * cloud=cursor requires tracker=linear. Mismatch is a hard error — checked BEFORE
119
- * any package.json write so no state is recorded on mismatch ("no files written
120
- * on hard error" invariant). Returns the error message to print, or `null` when
121
- * the tracker matches (or no cloud module/variant is in play).
113
+ * Cloud automation needs a wired tracker. Returns the pre-write error message,
114
+ * or null when a tracker is wired or no cloud module/variant is being installed.
122
115
  */
123
- export function validateCloudTrackerMatch(
116
+ export function validateCloudTrackerWired(
124
117
  cloudVariant: CloudVariant | null,
125
118
  hasCloudModule: boolean,
126
119
  issueTracker: IssueTracker,
127
120
  ): string | null {
128
- if (cloudVariant === null || !hasCloudModule) return null;
129
- const requiredTracker: IssueTracker = cloudVariant === "cursor" ? "linear" : "github";
130
- if (issueTracker === requiredTracker) return null;
121
+ if (cloudVariant === null || !hasCloudModule || issueTracker !== "none") return null;
131
122
  return (
132
- `[bkit] --auto=${cloudVariant} requires tracker=${requiredTracker}, ` +
133
- `but the resolved tracker is "${issueTracker}". ` +
134
- (issueTracker === DEFAULT_ISSUE_TRACKER || issueTracker === "none"
135
- ? `Set the tracker first: bkit install --tracker=${requiredTracker} --auto=${cloudVariant}`
136
- : `Re-run with the matching tracker: bkit install --tracker=${requiredTracker} --auto=${cloudVariant} (tracker switching is free).`)
123
+ `[bkit] --auto=${cloudVariant} needs a wired tracker: ` +
124
+ `bkit install --tracker=<github|linear|jira> --auto=${cloudVariant}`
137
125
  );
138
126
  }
139
127
 
@@ -387,10 +375,8 @@ export async function runInstall(
387
375
 
388
376
  const postDispatch: Array<() => void> = [];
389
377
 
390
- // Symmetric cloud/tracker constraint (FINAL SCOPE decision 3/4) — see
391
- // validateCloudTrackerMatch for the full rationale. Checked BEFORE any
392
- // package.json write so no state is recorded on mismatch.
393
- const cloudTrackerError = validateCloudTrackerMatch(
378
+ // Reject missing tracker wiring before any package.json write.
379
+ const cloudTrackerError = validateCloudTrackerWired(
394
380
  cloudVariant,
395
381
  modules.has("cloud"),
396
382
  issueTracker,
@@ -402,7 +388,11 @@ export async function runInstall(
402
388
  if (cloudVariant !== null && modules.has("cloud")) {
403
389
  // auto=opencode additionally requires the local opencode host to be installed first
404
390
  // (the cloud job runs against the committed .opencode/ — no model is hard-coded in YAML).
405
- if (cloudVariant === "opencode" && !fs.existsSync(path.join(process.cwd(), ".opencode"))) {
391
+ if (
392
+ cloudVariant === "opencode" &&
393
+ !modules.has("opencode") &&
394
+ !fs.existsSync(path.join(process.cwd(), ".opencode"))
395
+ ) {
406
396
  console.error(
407
397
  `[bkit] --auto=opencode requires the local opencode host to be installed first.\n` +
408
398
  `Run: bkit install --opencode=<provider> (e.g. --opencode=opencode-zen)\n` +
@@ -410,6 +400,14 @@ export async function runInstall(
410
400
  );
411
401
  process.exit(1);
412
402
  }
403
+ if (
404
+ cloudVariant === "codex" &&
405
+ !modules.has("codex") &&
406
+ !fs.existsSync(path.join(process.cwd(), ".codex"))
407
+ ) {
408
+ console.error(`[bkit] --auto=codex requires the local Codex host. Run: bkit install --codex`);
409
+ process.exit(1);
410
+ }
413
411
  }
414
412
 
415
413
  // Persist bkit manifest fields to consumer package.json AFTER all hard-error gates pass.
@@ -515,6 +513,11 @@ export async function runInstall(
515
513
  discardAllStaging();
516
514
  }
517
515
 
516
+ // The ten project documents belong to the project: drop a legacy ownership wrapper and list
517
+ // each present document in `Project Documents`. Runs after the managed index is rendered and
518
+ // before the advisories read the result. `check` is read-only, so it never gets here.
519
+ if (!dryRun) syncProjectDocs(process.cwd(), { dryRun: false });
520
+
518
521
  const totalWrites = ws.writes.length;
519
522
 
520
523
  // Done banner first so the line count is easy to find above the checklist.
@@ -7,8 +7,9 @@
7
7
  // - "byte-equal-text" : delete only if unchanged since bkit wrote it (canonicalHashes)
8
8
  // 2. package.json: the `bkit` install-state block (full/core uninstall). Scripts and
9
9
  // devDeps are the consumer's — the bkit:gate:* names included — and are left alone.
10
- // 2b. docs/ (full/core uninstall): bkit's managed block stripped from every installed
11
- // `docs/*.md`, the owned `docs/templates/bkit-*.md` deleted.
10
+ // 2b. docs/ (full/core uninstall): the owned `docs/templates/bkit-*.md` deleted. The ten
11
+ // project documents (`docs/architecture.md` …) and their `Project Documents` index rows
12
+ // belong to the project and stay.
12
13
  // 3. .agents/ mirror files (bkit-prefix .md files in .claude/ .cursor/)
13
14
  //
14
15
  // Flags:
@@ -44,7 +45,6 @@ import {
44
45
  import {
45
46
  getBkitDocsRoot,
46
47
  getPkgRoot,
47
- getSharedRoot,
48
48
  findTemplateSource,
49
49
  TEMPLATE_COPIES_DIR,
50
50
  } from "../../shared/package-roots.js";
@@ -66,10 +66,10 @@ import {
66
66
  CLAUDE_CLOUD_RELPATH,
67
67
  CODEX_CLOUD_RELPATH,
68
68
  CURSOR_CLOUD_RELPATH,
69
- resolveClaudeDerivedAllows,
70
69
  } from "../../install/cloud-env.js";
71
70
  import type { ModuleFlag, UninstallFlags } from "../../cli.js";
72
71
  import { LOG_PREFIX, setLogPrefix } from "../../shared/log-prefix.js";
72
+ import { isOpencodeSubstringFetchKey, redactUrlParts } from "../../checks/before/files.js";
73
73
  import { type McpServerMapKey, unusedTrackerMcpServers } from "../../checks/before/mcp.js";
74
74
 
75
75
  // ---------------------------------------------------------------------------
@@ -385,26 +385,6 @@ const CORE_TEMPLATE_DOCTRINE: ManifestEntry[] = [
385
385
  { path: ".bkit/lite.md", format: "markered-text", module: "core" },
386
386
  ];
387
387
 
388
- /**
389
- * The top-level `docs/*.md` the core payload pass installs: each carries bkit's managed
390
- * block (`bkit:start` / `bkit:end`, managed marker inside), so uninstall strips the block
391
- * and keeps the consumer's content, exactly like `.agents/*.md`. The payload's
392
- * `shared/docs/` holds only these block docs; `docs/capabilities.md` is a template
393
- * (copied, never installed) and is left alone.
394
- */
395
- function coreDocEntries(): ManifestEntry[] {
396
- const dir = path.join(getSharedRoot(), "docs");
397
- if (!fs.existsSync(dir)) return [];
398
- return fs
399
- .readdirSync(dir, { withFileTypes: true })
400
- .filter((e) => e.isFile() && e.name.endsWith(".md"))
401
- .map((e): ManifestEntry => ({
402
- path: path.join("docs", e.name),
403
- format: "markered-text",
404
- module: "core",
405
- }));
406
- }
407
-
408
388
  /** Prefix of the bkit-owned files under `docs/templates/`; uninstall deletes them whole. */
409
389
  const DOCS_TEMPLATES_DIR = path.join("docs", "templates");
410
390
  const isOwnedDocsTemplate = (name: string) => name.startsWith("bkit-") && name.endsWith(".md");
@@ -423,7 +403,7 @@ export function buildDecisionTable(
423
403
 
424
404
  const entries = [
425
405
  ...getInstallManifest(moduleList),
426
- ...(moduleList.includes("core") ? [...CORE_TEMPLATE_DOCTRINE, ...coreDocEntries()] : []),
406
+ ...(moduleList.includes("core") ? CORE_TEMPLATE_DOCTRINE : []),
427
407
  ];
428
408
 
429
409
  // The hash of every owned file as bkit last wrote it.
@@ -649,6 +629,11 @@ export async function runUninstall(
649
629
  }
650
630
  }
651
631
 
632
+ // The grants bkit wrote into `.claude/settings.json`, read before the loop below deletes
633
+ // `.bkit/version` on a full or core uninstall.
634
+ const claudeAllowDerived =
635
+ readBkitVersion(path.join(ctx.cwd, ".bkit", "version"))?.claudeAllowDerived ?? [];
636
+
652
637
  const table = buildDecisionTable(moduleList, ctx);
653
638
  result.decisions = table;
654
639
 
@@ -727,19 +712,18 @@ export async function runUninstall(
727
712
  // the resolved network allowlist and `mcp__…` grants per declared MCP
728
713
  // server (enrichClaudeSettingsAllows). Stripping
729
714
  // against the RAW template leaves those grants behind as if the consumer
730
- // had added them. Recompute the same set — the very function that produced
731
- // them — and treat it as part of the template, exactly as the opencode.json
732
- // sentinel render above does.
715
+ // had added them. `.bkit/version` records exactly the rows install wrote
716
+ // (`claudeAllowDerived`); treat them as part of the template. A derived-looking
717
+ // row the record lacks has unknown ownership: it stays and is listed for review.
733
718
  if (summary.file === path.join(".claude", "settings.json")) {
734
719
  const perms = templateDoc.permissions;
735
720
  if (perms !== null && typeof perms === "object" && !Array.isArray(perms)) {
736
721
  const permsObj = perms as Record<string, JsonValue>;
737
722
  const allow = permsObj.allow;
738
723
  if (Array.isArray(allow)) {
739
- const enriched = resolveClaudeDerivedAllows(ctx.cwd);
740
724
  permsObj.allow = [
741
725
  ...allow,
742
- ...enriched.filter((e) => !allow.includes(e)),
726
+ ...claudeAllowDerived.filter((e) => !allow.includes(e)),
743
727
  ] as JsonValue;
744
728
  }
745
729
  }
@@ -749,6 +733,34 @@ export async function runUninstall(
749
733
  : isOpencodeJson
750
734
  ? stripOpencodeJsonScope(consumerDoc, templatePath, ctx.cwd)
751
735
  : stripTier2JsonScope(consumerDoc, templateDoc);
736
+ if (summary.file === path.join(".claude", "settings.json")) {
737
+ const remaining = (stripped.permissions as { allow?: unknown } | undefined)?.allow;
738
+ if (Array.isArray(remaining)) {
739
+ for (const row of remaining) {
740
+ if (
741
+ typeof row === "string" &&
742
+ /^(WebFetch\(domain:|mcp__)/.test(row) &&
743
+ !claudeAllowDerived.includes(row)
744
+ ) {
745
+ console.log(
746
+ `${ctx.logPrefix} review: ${summary.file} keeps ${row} — .bkit/version does not record it as bkit-written; remove it by hand if bkit added it`,
747
+ );
748
+ }
749
+ }
750
+ }
751
+ }
752
+ if (isOpencodeJson) {
753
+ const bash = (stripped.permission as { bash?: unknown } | undefined)?.bash;
754
+ if (bash !== null && typeof bash === "object" && !Array.isArray(bash)) {
755
+ for (const [key, value] of Object.entries(bash as Record<string, unknown>)) {
756
+ if (value === "allow" && isOpencodeSubstringFetchKey(key)) {
757
+ console.log(
758
+ `${ctx.logPrefix} review: ${summary.file} keeps legacy substring grant \`${redactUrlParts(key)}\` in permission.bash — remove it by hand if you did not add it`,
759
+ );
760
+ }
761
+ }
762
+ }
763
+ }
752
764
  const strippedJson = JSON.stringify(stripped, null, 2) + "\n";
753
765
  if (Object.keys(stripped).length === 0) {
754
766
  // All keys were bkit-owned → delete file
@@ -61,6 +61,7 @@ import { readBkitConfig } from "../../shared/settings.js";
61
61
  import { detectInstalledHostModules } from "../../install/hosts.js";
62
62
  import { detectInstalledModules } from "./check.js";
63
63
  import { remapTemplateDest } from "../../install/template-copies.js";
64
+ import { syncProjectDocs } from "../../install/project-docs.js";
64
65
  import {
65
66
  CLAUDE_CLOUD_RELPATH,
66
67
  CODEX_CLOUD_RELPATH,
@@ -70,7 +71,11 @@ import {
70
71
  writeCursorCloudDoc,
71
72
  writeCursorCliPermissionsArtifact,
72
73
  } from "../../install/cloud-env.js";
73
- import { syncTemplateCopies, formatTemplateChanges } from "../../install/template-copies.js";
74
+ import {
75
+ syncTemplateCopies,
76
+ formatTemplateChanges,
77
+ warnMissingLintStagedConfig,
78
+ } from "../../install/template-copies.js";
74
79
  import { formatPayloadLinkChanges, syncPayloadLinks } from "../../install/payload-links.js";
75
80
  import { renderOpencodeJson, reconcileOpencodeJson } from "../../install/modules/opencode.js";
76
81
  import { type ModuleContext, renderManagedOutputs } from "../../install/modules/index.js";
@@ -811,7 +816,7 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
811
816
  dryRun: upgradeFlags.dryRun,
812
817
  ws: { writes: [] },
813
818
  });
814
- const templateReport = formatTemplateChanges(templateChanges);
819
+ const templateReport = formatTemplateChanges(templateChanges, process.cwd());
815
820
  if (templateReport) console.log(`${LOG_PREFIX} ${templateReport}`);
816
821
 
817
822
  // Payload view links — the same sync install runs (`.bkit/core` + `.bkit/shared`
@@ -1017,6 +1022,11 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
1017
1022
  }
1018
1023
  }
1019
1024
 
1025
+ // Project documents belong to the project: remove a legacy ownership wrapper and register each
1026
+ // present document in `Project Documents` (a dry run only prints the preview). They carry no
1027
+ // hash, so nothing here feeds `.bkit/version`.
1028
+ syncProjectDocs(process.cwd(), { dryRun: upgradeFlags.dryRun });
1029
+
1020
1030
  // Refresh canonicalHashes (from resulting on-disk content) AND bump pinnedVersion
1021
1031
  // to the version we just upgraded TO, so the next `bkit check` has nothing to write.
1022
1032
  // Called unconditionally (non-dry-run) so the pin bumps even when every file was a
@@ -1059,6 +1069,8 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
1059
1069
  );
1060
1070
 
1061
1071
  // `.bkit/advisories.md` describes the upgraded repo, not the last install or check.
1072
+ // A real upgrade prints the missing-lint-staged line through the advisories; a dry run prints it here.
1073
+ if (upgradeFlags.dryRun) warnMissingLintStagedConfig(process.cwd(), LOG_PREFIX);
1062
1074
  if (!upgradeFlags.dryRun) await runUpgradeAdvisories();
1063
1075
 
1064
1076
  // Non-interactive mode: exit non-zero on conflicts
@@ -17,9 +17,8 @@ import { gitEnv } from "../ledgers/telemetry.js";
17
17
  import { readBkitConfig } from "../shared/settings.js";
18
18
  import { readPackageJson } from "../shared/package-json.js";
19
19
  import { installCommand } from "../shared/package-manager.js";
20
- import { minPushPathspecs } from "./ci/ci.js";
20
+ import { minPushOutside, minPushPathspecs } from "./ci/ci.js";
21
21
  import { requiredPushGate, runPushGate } from "./ci/push-gate.js";
22
- import { changedOutside } from "./workflow/ledgers.js";
23
22
 
24
23
  const REMOTE = "origin";
25
24
  const UPSTREAM = `${REMOTE}/${DEV}`;
@@ -195,7 +194,7 @@ function checkLanding(root: string, dir: string, base: string, log: (line: strin
195
194
  throw new CommandError(EXIT.NO, "landing checkout is not clean — nothing pushed");
196
195
  if (!readPackageJson(dir).ok)
197
196
  throw new CommandError(EXIT.NO, "landing package.json is unreadable — nothing pushed");
198
- const diff = changedOutside(dir, base, head!, minPushPathspecs(readBkitConfig(dir)));
197
+ const diff = minPushOutside(dir, base, head!, minPushPathspecs(readBkitConfig(dir)));
199
198
  if (!diff.ok) throw new CommandError(EXIT.NO, `cannot classify landing: ${diff.stderr}`);
200
199
  const gate = diff.outside.length === 0 ? "bkit:gate:min" : requiredPushGate(dir);
201
200
  if (!gate) throw new CommandError(EXIT.NO, "landing has no declared full gate — nothing pushed");