@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
@@ -47,9 +47,8 @@ export interface DriftItem {
47
47
  }
48
48
 
49
49
  export interface RuleEntry {
50
+ /** The `### {name}` heading: the rule's ID, unique across `## Rules` and `## Project Rules`. */
50
51
  name: string;
51
- /** `R{nn}` (bkit block) or `P{nn}` (Project Rules). */
52
- id: string;
53
52
  text: string;
54
53
  retired: string[];
55
54
  refs: RuleRef[];
@@ -74,6 +73,9 @@ export const CARRIER_SURFACES = [
74
73
  "permission",
75
74
  ];
76
75
 
76
+ /** A rule's `### {name}`, which tags, clause `- rule:` / `- tags:` lines and prose cite it by. */
77
+ export const RULE_NAME = /^[a-z0-9][a-z0-9-]*/;
78
+
77
79
  const CITES = /^((?:`[^`:]+:\d+`(?:, )?)+): ?(.*)$/;
78
80
 
79
81
  /** One drift item line (` - ` dropped) with its `kept` reason. */
@@ -114,8 +116,8 @@ export interface RuleMasters {
114
116
  }
115
117
 
116
118
  const RULE_SECTIONS = [
117
- { heading: "Rules", prefix: "R", region: "bkit" },
118
- { heading: "Project Rules", prefix: "P", region: "project" },
119
+ { heading: "Rules", region: "bkit" },
120
+ { heading: "Project Rules", region: "project" },
119
121
  ] as const;
120
122
 
121
123
  /** Top-level `- ` bullets of the bkit block, or of `## Project Rules` below `bkit:end`, in file order. */
@@ -143,7 +145,6 @@ export function parseRuleEntries(md: string, heading: "Rules" | "Project Rules")
143
145
  .slice(1)
144
146
  .map((section) => {
145
147
  const name = section.slice(0, section.indexOf("\n")).trim();
146
- const id = /^- rule: ([RP]\d+)/m.exec(section)?.[1] ?? "";
147
148
  const block = (kind: string) =>
148
149
  [...section.matchAll(new RegExp(`^\`\`\`${kind}\\n([\\s\\S]*?)^\`\`\`$`, "gm"))].flatMap(
149
150
  (m) => m[1]!.split("\n").filter((l) => l.trim() !== ""),
@@ -185,7 +186,6 @@ export function parseRuleEntries(md: string, heading: "Rules" | "Project Rules")
185
186
  }
186
187
  return {
187
188
  name,
188
- id,
189
189
  text: block("text").join("\n"),
190
190
  retired: block("retired"),
191
191
  refs,
@@ -230,20 +230,22 @@ export function checkRules(
230
230
  exists: (ref: string, section?: string) => boolean,
231
231
  ): string[] {
232
232
  const out: string[] = [];
233
+ const seen = new Set<string>();
233
234
  for (const s of RULE_SECTIONS) {
234
235
  const entries = parseRuleEntries(store, s.heading);
235
236
  const bullets = ruleBullets(masters[s.region], s.region);
236
237
  const n = Math.max(entries.length, bullets.length);
237
238
  for (let i = 0; i < n; i++) {
238
- const want = `${s.prefix}${String(i + 1).padStart(2, "0")}`;
239
239
  const e = entries[i];
240
240
  const bullet = bullets[i];
241
241
  if (!e) {
242
- out.push(`${want}: rules.md bullet has no \`## ${s.heading}\` entry — ${bullet}`);
242
+ out.push(`${s.heading} bullet ${i + 1} of rules.md has no entry — ${bullet}`);
243
243
  continue;
244
244
  }
245
- const tag = `${e.id || want} \`${e.name}\``;
246
- if (e.id !== want) out.push(`${tag}: id should be ${want} (file order of rules.md)`);
245
+ const tag = `\`${e.name}\``;
246
+ if (RULE_NAME.exec(e.name)?.[0] !== e.name) out.push(`${tag}: name must be kebab-case`);
247
+ if (seen.has(e.name)) out.push(`${tag}: name used by another rule; names are rule IDs`);
248
+ seen.add(e.name);
247
249
  if (bullet === undefined) {
248
250
  out.push(`${tag}: no rules.md bullet at position ${i + 1}`);
249
251
  continue;
@@ -590,15 +592,11 @@ export function checkPermissions(
590
592
  }
591
593
 
592
594
  // ---------------------------------------------------------------------------
593
- // Special Behaviors ← `.bkit/core/.bkit/prompts.md`; Authoring Rules ← `authoring.md`, `workflows.md`
595
+ // Special Behaviors ← `.bkit/core/.bkit/prompts.md`; Authoring Rules ← `workflows.md`
594
596
  // ---------------------------------------------------------------------------
595
597
 
596
- /** Catalog files the two sections copy. */
597
- export const CATALOG_SOURCES = [
598
- ".bkit/core/.bkit/prompts.md",
599
- ".bkit/core/.bkit/workflows.md",
600
- ".bkit/core/.bkit/authoring.md",
601
- ];
598
+ /** Catalog files the two sections copy. `authoring.md` is read in place, never copied. */
599
+ export const CATALOG_SOURCES = [".bkit/core/.bkit/prompts.md", ".bkit/core/.bkit/workflows.md"];
602
600
 
603
601
  const FENCE_OPEN = /^(`{3,})/;
604
602
 
@@ -22,6 +22,7 @@ import {
22
22
  checkSources,
23
23
  parseDriftItem,
24
24
  parseRuleEntries,
25
+ RULE_NAME,
25
26
  sectionOf,
26
27
  syncSources,
27
28
  type RuleEntry,
@@ -61,7 +62,7 @@ export interface Clause {
61
62
  position?: Position;
62
63
  /** Slotted clause only: a line holding the fixed text before the first slot must match one of the templates. */
63
64
  anchored: boolean;
64
- /** `R{nn}` of the `.agents/rules.md` rule the clause carries. */
65
+ /** `### {name}` of the `## Rules` entry whose text the clause carries. */
65
66
  rule?: string;
66
67
  /** Rules the clause condenses, specialises, applies or cites (`- tags:`). */
67
68
  tags?: string[];
@@ -89,7 +90,7 @@ export const NEAR_COPY = 0.8;
89
90
  export const SHARED_MIN: Partial<Record<Surface, number>> = {
90
91
  prompt: 2,
91
92
  workflow: 2,
92
- audit: 5,
93
+ audit: 2,
93
94
  doc: 2,
94
95
  };
95
96
 
@@ -192,7 +193,7 @@ export function parseClauses(md: string): Clause[] {
192
193
  } else if (key === "retired") {
193
194
  clause.fullyRetired = value === "yes";
194
195
  } else if (key === "rule") {
195
- clause.rule = /^[RP]\d+/.exec(value)?.[0];
196
+ clause.rule = RULE_NAME.exec(value)?.[0];
196
197
  } else if (key === "tags") {
197
198
  clause.tags = value.split(",").map((t) => t.trim());
198
199
  } else if (key === "carriers" || key === "distinct-from") {
@@ -347,6 +348,29 @@ export function loadCorpus(root: string): CorpusFile[] {
347
348
  * to check or rewrite.
348
349
  */
349
350
  export function proseLineIndexes(file: CorpusFile): number[] {
351
+ return memoLines(proseCache, file, computeProseLineIndexes);
352
+ }
353
+
354
+ /** Line-index memo keyed by surface and content; every clause asks for the same file's lines. */
355
+ function memoLines(
356
+ cache: Map<string, number[]>,
357
+ file: CorpusFile,
358
+ compute: (file: CorpusFile) => number[],
359
+ ): number[] {
360
+ const key = `${file.surface}\u0000${file.content}`;
361
+ let hit = cache.get(key);
362
+ if (!hit) {
363
+ if (cache.size > 5_000) cache.clear();
364
+ hit = compute(file);
365
+ cache.set(key, hit);
366
+ }
367
+ return hit;
368
+ }
369
+
370
+ const proseCache = new Map<string, number[]>();
371
+ const clauseLineCache = new Map<string, number[]>();
372
+
373
+ function computeProseLineIndexes(file: CorpusFile): number[] {
350
374
  const lines = file.content.split("\n");
351
375
  let from = 0;
352
376
  let to = lines.length;
@@ -384,9 +408,11 @@ export function proseLineIndexes(file: CorpusFile): number[] {
384
408
  * `**Rules:**` block, whose lines are rules.md copies the `- carry:` check owns.
385
409
  */
386
410
  export function clauseLineIndexes(file: CorpusFile): number[] {
387
- const prose = proseLineIndexes(file);
388
- const block = file.surface === "prompt" ? ruleBlock(file.content.split("\n")) : undefined;
389
- return block ? prose.filter((i) => i < block.from || i >= block.to) : prose;
411
+ return memoLines(clauseLineCache, file, (f) => {
412
+ const prose = proseLineIndexes(f);
413
+ const block = f.surface === "prompt" ? ruleBlock(f.content.split("\n")) : undefined;
414
+ return block ? prose.filter((i) => i < block.from || i >= block.to) : prose;
415
+ });
390
416
  }
391
417
 
392
418
  /** Lines a clause is matched against: a `block: rules` clause also sees the prompt's `**Rules:**` block it sits in. */
@@ -488,6 +514,8 @@ interface Compiled {
488
514
  slots: string[];
489
515
  /** Fixed text before the first slot; the whole text when unslotted. */
490
516
  prefix: string;
517
+ /** Longest fixed segment every match contains verbatim: a substring check before the regex runs. */
518
+ literal: string;
491
519
  slotted: boolean;
492
520
  }
493
521
 
@@ -497,29 +525,36 @@ export function compileText(text: string): Compiled {
497
525
  const hit = compiledCache.get(text);
498
526
  if (hit) return hit;
499
527
  const slots: string[] = [];
528
+ const literals: string[] = [];
500
529
  let source = "";
501
530
  let last = 0;
502
531
  for (const m of text.matchAll(SLOT)) {
503
- source += escapeRe(text.slice(last, m.index));
532
+ const segment = text.slice(last, m.index);
533
+ literals.push(segment);
534
+ source += escapeRe(segment);
504
535
  source += m[2] ? "(.*?)" : "(.+?)";
505
536
  slots.push(m[1]!);
506
537
  last = m.index! + m[0].length;
507
538
  }
508
539
  const tail = text.slice(last);
509
540
  // A closing `.` also matches `;`: the line continues the sentence with local text.
510
- source += tail.endsWith(".") ? `${escapeRe(tail.slice(0, -1))}[.;]` : escapeRe(tail);
541
+ const tailLiteral = tail.endsWith(".") ? tail.slice(0, -1) : tail;
542
+ literals.push(tailLiteral);
543
+ source += tail.endsWith(".") ? `${escapeRe(tailLiteral)}[.;]` : escapeRe(tail);
511
544
  const first = text.search(SLOT);
512
545
  const compiled = {
513
546
  re: new RegExp(source, "g"),
514
547
  slots,
515
548
  prefix: first === -1 ? text : text.slice(0, first),
549
+ literal: literals.reduce((a, b) => (b.length > a.length ? b : a), ""),
516
550
  slotted: slots.length > 0,
517
551
  };
518
552
  compiledCache.set(text, compiled);
519
553
  return compiled;
520
554
  }
521
555
 
522
- const countIn = (line: string, c: Compiled) => [...line.matchAll(c.re)].length;
556
+ const countIn = (line: string, c: Compiled) =>
557
+ line.includes(c.literal) ? [...line.matchAll(c.re)].length : 0;
523
558
 
524
559
  /** Drop the blockquote, list marker, step number, or checkbox in front of a line's text. */
525
560
  export const stripLinePrefix = (line: string) =>
@@ -653,12 +688,15 @@ function nearCopies(
653
688
  if (!canonical.startsWith("**")) window = window.replace(LABEL, "");
654
689
  // A clause can close a sentence that opens with local text (`**If** {cond} → {clause}`): also compare the tail.
655
690
  const words = window.split(/\s+/);
656
- const candidates = [window];
691
+ const candidates: [string, string[]][] = [[window, words]];
657
692
  for (const n of [cw - 1, cw, cw + 1]) {
658
- if (n > 0 && n < words.length) candidates.push(words.slice(-n).join(" "));
693
+ if (n > 0 && n < words.length) {
694
+ const tail = words.slice(-n);
695
+ candidates.push([tail.join(" "), tail]);
696
+ }
659
697
  }
660
- for (const found of candidates) {
661
- if (allTexts.has(found) || !nearCandidate(found.split(/\s+/), canonicalWords)) continue;
698
+ for (const [found, foundWords] of candidates) {
699
+ if (allTexts.has(found) || !nearCandidate(foundWords, canonicalWords, counts)) continue;
662
700
  const score = similarity(found, canonical);
663
701
  if (score >= NEAR_COPY && (!best || score > best.score)) best = { found, size, score };
664
702
  }
@@ -843,18 +881,21 @@ export function checkClauses(clauses: Clause[], files: CorpusFile[]): Finding[]
843
881
  }
844
882
 
845
883
  /** Could two sentences be NEAR_COPY-similar? Cheap word-count and shared-word bounds before `similarity`. */
846
- function nearCandidate(a: string[], b: string[]): boolean {
884
+ function nearCandidate(a: string[], b: string[], bCounts?: Map<string, number>): boolean {
847
885
  const longer = Math.max(a.length, b.length);
848
886
  const need = Math.ceil(NEAR_COPY * longer);
849
887
  if (Math.min(a.length, b.length) < need) return false;
850
- const pool = new Map<string, number>();
851
- for (const w of b) pool.set(w, (pool.get(w) ?? 0) + 1);
888
+ // `bCounts` is read-only (a caller's memoised counts): track the words of `b` used up so far.
889
+ const counts = bCounts ?? wordCounts(b);
890
+ const used = new Map<string, number>();
852
891
  let shared = 0;
853
892
  for (const w of a) {
854
- const n = pool.get(w) ?? 0;
855
- if (n > 0) {
893
+ const n = counts.get(w);
894
+ if (n === undefined) continue;
895
+ const u = used.get(w) ?? 0;
896
+ if (u < n) {
856
897
  shared++;
857
- pool.set(w, n - 1);
898
+ used.set(w, u + 1);
858
899
  }
859
900
  }
860
901
  return shared >= need;
@@ -901,6 +942,7 @@ function sharedGroups(
901
942
  noun: string,
902
943
  ): Finding[] {
903
944
  const words = new Map([...seen.keys()].map((s) => [s, s.split(/\s+/)]));
945
+ const counts = new Map([...words].map(([s, w]) => [s, wordCounts(w)]));
904
946
  const reported = new Set<string>();
905
947
  const findings: Finding[] = [];
906
948
  // Seeds: every sentence, widest first, so a group is reported once under its most-copied wording.
@@ -912,7 +954,7 @@ function sharedGroups(
912
954
  (s) =>
913
955
  s !== seed &&
914
956
  !reported.has(s) &&
915
- nearCandidate(words.get(seed)!, words.get(s)!) &&
957
+ nearCandidate(words.get(seed)!, words.get(s)!, counts.get(s)!) &&
916
958
  similarity(seed, s) >= NEAR_COPY,
917
959
  );
918
960
  const group = new Set([...ids.keys(), ...near.flatMap((s) => [...seen.get(s)!.keys()])]);
@@ -1112,7 +1154,7 @@ export interface LocalEntry {
1112
1154
  file?: string;
1113
1155
  /** `- carriers:` value (shared lines). */
1114
1156
  carriers?: string;
1115
- /** `R{nn}` / `P{nn}` of the rule the line carries. */
1157
+ /** `### {name}` of each rule the line carries. */
1116
1158
  tags: string[];
1117
1159
  /** `fit `{target}` {score}`: the closest rule or clause the line could be reworded to. */
1118
1160
  fit?: string;
@@ -1123,9 +1165,9 @@ export interface LocalEntry {
1123
1165
  at: number;
1124
1166
  }
1125
1167
 
1126
- const LOCAL_TAG = /^(?:[RP]\d+|fit `[^`]+` [\d.]+)$/;
1168
+ const LOCAL_TAG = /^(?:[a-z0-9][a-z0-9-]*|fit `[^`]+` [\d.]+)$/;
1127
1169
 
1128
- /** `[R01; fit `x` 0.8; keep: {reason}] {text}`; a bracket holding anything but tags stays text. */
1170
+ /** `[scope-discipline; fit `x` 0.8; keep: {reason}] {text}`; a bracket holding anything but tags stays text. */
1129
1171
  export function parseLocalLine(line: string): Pick<LocalEntry, "tags" | "fit" | "keep" | "text"> {
1130
1172
  const m = /^\[([^\]]+)\] (.+)$/.exec(line);
1131
1173
  if (m) {
@@ -1287,7 +1329,7 @@ function ruleCarriers(
1287
1329
  for (const n of expandNames(c.names, ix.namesOf(surface))) {
1288
1330
  const file = ix.byName(surface, n);
1289
1331
  if (file) found.push({ relation: c.relation, file });
1290
- else out?.push(`${r.id} \`${r.name}\`: ${c.relation} carrier \`${n}\` is no ${surface} file`);
1332
+ else out?.push(`\`${r.name}\`: ${c.relation} carrier \`${n}\` is no ${surface} file`);
1291
1333
  }
1292
1334
  }
1293
1335
  return found;
@@ -1361,6 +1403,19 @@ export function checkCoverage(store: string, corpus: CorpusFile[]): string[] {
1361
1403
  }
1362
1404
  }
1363
1405
 
1406
+ // Every rule name a tag or clause cites is a rule.
1407
+ const ruleNames = new Set(ix.rules.map((r) => r.name));
1408
+ for (const e of ix.local) {
1409
+ for (const t of e.tags.filter((t) => !ruleNames.has(t))) {
1410
+ out.push(`${e.file ?? `shared (${e.carriers})`}: tag \`${t}\` names no rule: ${e.text}`);
1411
+ }
1412
+ }
1413
+ for (const c of ix.clauses) {
1414
+ for (const t of [c.rule ?? [], c.tags ?? []].flat().filter((t) => !ruleNames.has(t))) {
1415
+ out.push(`clause \`${c.name}\`: \`${t}\` names no rule`);
1416
+ }
1417
+ }
1418
+
1364
1419
  // Nothing extra: rule carriers.
1365
1420
  for (const r of ix.rules) {
1366
1421
  const sentences = splitSentences(r.text);
@@ -1371,8 +1426,8 @@ export function checkCoverage(store: string, corpus: CorpusFile[]): string[] {
1371
1426
  out,
1372
1427
  )) {
1373
1428
  const prose = ix.prose.get(file.id)!;
1374
- const tag = `${r.id} \`${r.name}\``;
1375
- const linked = ix.clauses.filter((c) => c.rule === r.id || c.name === r.clause);
1429
+ const tag = `\`${r.name}\``;
1430
+ const linked = ix.clauses.filter((c) => c.rule === r.name || c.name === r.clause);
1376
1431
  const viaClause = linked.some((c) =>
1377
1432
  c.texts.some((t) => prose.some((l) => plain(compileText(t).re).test(l))),
1378
1433
  );
@@ -1388,15 +1443,15 @@ export function checkCoverage(store: string, corpus: CorpusFile[]): string[] {
1388
1443
  }
1389
1444
  continue;
1390
1445
  }
1391
- const tagged = (localOf.get(file.id) ?? []).some((e) => e.tags.includes(r.id));
1446
+ const tagged = (localOf.get(file.id) ?? []).some((e) => e.tags.includes(r.name));
1392
1447
  const viaTaggedClause = ix.clauses.some(
1393
1448
  (c) =>
1394
- c.tags?.includes(r.id) &&
1449
+ c.tags?.includes(r.name) &&
1395
1450
  c.texts.some((t) => prose.some((l) => plain(compileText(t).re).test(l))),
1396
1451
  );
1397
1452
  if (!tagged && !viaClause && !viaTaggedClause) {
1398
1453
  out.push(
1399
- `${tag}: ${relation} carrier \`${file.name}\` has no local line or clause tagged ${r.id}`,
1454
+ `${tag}: ${relation} carrier \`${file.name}\` has no local line or clause tagged \`${r.name}\``,
1400
1455
  );
1401
1456
  }
1402
1457
  }
@@ -1409,24 +1464,22 @@ export function checkCoverage(store: string, corpus: CorpusFile[]): string[] {
1409
1464
  if (
1410
1465
  !new RegExp(`^### ${escapeRe(entry[2]!)}$`, "m").test(sectionOf(store, heading) ?? "")
1411
1466
  ) {
1412
- out.push(`${r.id} \`${r.name}\`: drift names no \`## ${heading}\` entry \`${entry[2]}\``);
1467
+ out.push(`\`${r.name}\`: drift names no \`## ${heading}\` entry \`${entry[2]}\``);
1413
1468
  }
1414
1469
  continue;
1415
1470
  }
1416
1471
  if (d.cites.length === 0 || d.excerpt === undefined) {
1417
1472
  out.push(
1418
- `${r.id} \`${r.name}\`: drift item needs \`{file}:{line}\` cites and a "quoted excerpt": ${d.raw}`,
1473
+ `\`${r.name}\`: drift item needs \`{file}:{line}\` cites and a "quoted excerpt": ${d.raw}`,
1419
1474
  );
1420
1475
  continue;
1421
1476
  }
1422
1477
  for (const c of d.cites) {
1423
1478
  const candidates = citeFiles(ix, c.name);
1424
1479
  if (candidates.length === 0)
1425
- out.push(`${r.id} \`${r.name}\`: drift \`${c.name}:${c.line}\` names no file`);
1480
+ out.push(`\`${r.name}\`: drift \`${c.name}:${c.line}\` names no file`);
1426
1481
  else if (!candidates.some((f) => lineHolds(f, c.line, d.excerpt!))) {
1427
- out.push(
1428
- `${r.id} \`${r.name}\`: drift \`${c.name}:${c.line}\` does not hold "${d.excerpt}"`,
1429
- );
1482
+ out.push(`\`${r.name}\`: drift \`${c.name}:${c.line}\` does not hold "${d.excerpt}"`);
1430
1483
  }
1431
1484
  }
1432
1485
  }
@@ -1444,8 +1497,7 @@ export function openFits(store: string): string[] {
1444
1497
  /** Drift items with no `kept` reason. */
1445
1498
  export function openDrift(store: string): string[] {
1446
1499
  return [...parseRuleEntries(store, "Rules"), ...parseRuleEntries(store, "Project Rules")].flatMap(
1447
- (r) =>
1448
- r.drift.filter((d) => d.kept === undefined).map((d) => `${r.id} \`${r.name}\`: ${d.raw}`),
1500
+ (r) => r.drift.filter((d) => d.kept === undefined).map((d) => `\`${r.name}\`: ${d.raw}`),
1449
1501
  );
1450
1502
  }
1451
1503
 
@@ -1483,7 +1535,7 @@ export function checkRuleCopies(store: string, corpus: CorpusFile[]): string[] {
1483
1535
  );
1484
1536
  if (rule) {
1485
1537
  out.push(
1486
- `${rule.id} \`${rule.name}\`: \`${f.id}:${i + 1}\` copies the rule in its ${BLOCK_LABEL[b]} block; it belongs in the ${RULES_BLOCK} block`,
1538
+ `\`${rule.name}\`: \`${f.id}:${i + 1}\` copies the rule in its ${BLOCK_LABEL[b]} block; it belongs in the ${RULES_BLOCK} block`,
1487
1539
  );
1488
1540
  }
1489
1541
  }
@@ -1515,15 +1567,13 @@ export function checkCarry(
1515
1567
  for (const n of named) {
1516
1568
  carried.add(n);
1517
1569
  if (!standing.get(n)?.some((l) => l.text === r.text)) {
1518
- missing.push(`${r.id} \`${r.name}\`: carry \`${n}\` lacks the whole rule bullet`);
1570
+ missing.push(`\`${r.name}\`: carry \`${n}\` lacks the whole rule bullet`);
1519
1571
  }
1520
1572
  }
1521
1573
  if (!bkit.includes(r)) continue;
1522
1574
  for (const f of prompts) {
1523
1575
  if (!named.has(f.name) && standing.get(f.name)!.some((l) => l.text.includes(r.text))) {
1524
- undeclared.push(
1525
- `${r.id} \`${r.name}\`: \`${f.name}\` holds the rule but no carry line names it`,
1526
- );
1576
+ undeclared.push(`\`${r.name}\`: \`${f.name}\` holds the rule but no carry line names it`);
1527
1577
  }
1528
1578
  }
1529
1579
  }
@@ -1585,11 +1635,12 @@ export function similarEntries(store: string): string[] {
1585
1635
  }
1586
1636
  const out: string[] = [];
1587
1637
  const words = entries.map((e) => e.text.split(/\s+/));
1638
+ const counts = words.map(wordCounts);
1588
1639
  for (let i = 0; i < entries.length; i++) {
1589
1640
  for (let j = i + 1; j < entries.length; j++) {
1590
1641
  const [a, b] = [entries[i]!, entries[j]!];
1591
1642
  if (a.name === b.name || a.distinct.has(b.name) || b.distinct.has(a.name)) continue;
1592
- if (!nearCandidate(words[i]!, words[j]!)) continue;
1643
+ if (!nearCandidate(words[i]!, words[j]!, counts[j]!)) continue;
1593
1644
  const score = similarity(a.text, b.text);
1594
1645
  if (score >= NEAR_COPY) {
1595
1646
  out.push(
@@ -1,6 +1,6 @@
1
1
  // --- Antigravity hook contract: identical in bkit's three Antigravity hooks (bkit renders
2
- // it from one source). Needs `fs`, `os` and `path` in scope; the host's own code above
3
- // declares them.
2
+ // it from one source). Needs `fs`, `os`, `path` and `crypto` in scope; the host's own code
3
+ // above declares them.
4
4
  //
5
5
  // Live-verified on the agy CLI: PreToolUse stdin is `{ conversationId, toolCall: { name,
6
6
  // args }, workspacePaths, stepIdx, ... }` — no tool_name / tool_input / session_id / cwd.
@@ -41,28 +41,43 @@ function agCallSignature(toolName, input) {
41
41
  }
42
42
 
43
43
  // One record per (hook, conversation): two hooks on the same call each let its retry through.
44
+ // Per user: on a temp dir users share (Linux `/tmp`) another user's copy cannot be written.
44
45
  function agRetryFile(hook, sessionId) {
45
46
  const safe =
46
47
  typeof sessionId === "string" ? sessionId.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 128) : "";
47
- return path.join(os.tmpdir(), "bkit-antigravity-retry", `${hook}.${safe || "no-session"}.json`);
48
+ const user = typeof process.getuid === "function" ? `-${process.getuid()}` : "";
49
+ return path.join(
50
+ os.tmpdir(),
51
+ `bkit-antigravity-retry${user}`,
52
+ `${hook}.${safe || "no-session"}.json`,
53
+ );
48
54
  }
49
55
 
50
56
  /**
51
57
  * Delivers an advisory the only way Antigravity shows one to the model: deny the call
52
58
  * with the advisory as the reason, once. The identical call right after is the agent's
53
- * retry and is allowed.
59
+ * retry and is allowed. Fail-open: a retry-store error allows the call — each call is
60
+ * its own process, so a deny it cannot record would block every retry.
54
61
  */
55
62
  function adviseOnce(hook, sessionId, signature, advisory) {
56
63
  const file = agRetryFile(hook, sessionId);
57
- const last = fs.existsSync(file) ? fs.readFileSync(file, "utf-8") : "";
58
- if (last === signature) {
59
- fs.rmSync(file, { force: true });
64
+ // One-way digest of the call signature: the retry store is world-readable and has no
65
+ // TTL, so no tool argument (a shell command line with an inline secret, a file path)
66
+ // may rest on disk in cleartext.
67
+ const digest = crypto.createHash("sha256").update(signature).digest("hex");
68
+ try {
69
+ const last = fs.existsSync(file) ? fs.readFileSync(file, "utf-8") : "";
70
+ if (last === digest) {
71
+ fs.rmSync(file, { force: true });
72
+ return { decision: "allow" };
73
+ }
74
+ fs.mkdirSync(path.dirname(file), { recursive: true });
75
+ fs.writeFileSync(file, digest, "utf-8");
76
+ } catch {
60
77
  return { decision: "allow" };
61
78
  }
62
- fs.mkdirSync(path.dirname(file), { recursive: true });
63
- fs.writeFileSync(file, signature, "utf-8");
64
79
  return {
65
80
  decision: "deny",
66
- reason: `${advisory}\nBlocked once so you see this; repeat the same call to proceed.`,
81
+ reason: `${advisory}\nThis call was held once so you see this advisory. Repeat the same call to proceed.`,
67
82
  };
68
83
  }
@@ -59,28 +59,29 @@ function isGateConfig(filePath) {
59
59
  function investigationChecklist(filePath) {
60
60
  const base = path.basename(filePath);
61
61
  return (
62
- `[bkit GateGuard] First edit to \`${base}\` this session — confirm the following, and investigate anything you cannot answer before editing:\n` +
63
- `- Confirm you read this file and the exact symbols / lines you are about to change.\n` +
64
- `- Confirm the precise field names, types and signatures being changed.\n` +
65
- `- Confirm the callers / importers the change affects: search code / read source, do not assume.\n` +
66
- `- Confirm the symbols / flags / configs the change requires exist: search code / read source, do not assume.\n` +
67
- `- Confirm the external data contracts (DB schemas, APIs / SDKs) the change affects: verify the actual shape, do not assume.\n` +
68
- `- Confirm the change follows the patterns / conventions already in this file / its neighbours where feasible: read source, do not assume.\n` +
69
- `- Confirm the user instructions or plan tasks the change serves: quote them, do not trust memory.\n` +
70
- `Advisory — proceed once satisfied.`
62
+ `[bkit GateGuard] First edit to \`${base}\` this session. Before you edit, confirm each point below, and investigate any you cannot answer:\n` +
63
+ `- Confirm you read this file and the exact symbols and lines you are about to change.\n` +
64
+ `- Confirm the exact field names, types and signatures you are changing.\n` +
65
+ `- Confirm the callers and importers the change affects, by searching or reading the code.\n` +
66
+ `- Confirm the symbols, flags and configs the change needs exist, by searching or reading the code.\n` +
67
+ `- Confirm the external data contracts (database schemas, APIs and SDKs) the change affects, by checking their actual shape.\n` +
68
+ `- Confirm the change follows the patterns and conventions already in this file or its neighbours where feasible, by reading the code.\n` +
69
+ `- Confirm the user instructions or plan tasks the change serves, by quoting them, not from memory.\n` +
70
+ `Advisory: proceed once satisfied.`
71
71
  );
72
72
  }
73
73
 
74
74
  function reuseChecklist(filePath) {
75
75
  const base = path.basename(filePath);
76
76
  return (
77
- `[bkit GateGuard] New file \`${base}\` this session — confirm the following, and investigate anything you cannot answer before adding:\n` +
78
- `- Confirm existing code does not already provide the capability: search code / read source, do not assume.\n` +
79
- `- Confirm existing code cannot be reused / extended to provide the capability: search code / read source, do not assume.\n` +
80
- `- Confirm anything the new code supersedes is deleted, not left as duplicate work: verify the removal, do not assume.\n` +
81
- `- Confirm the location / naming fits the project architecture / topology / standards: search code / read source, do not assume.\n` +
82
- `- Confirm the structures / patterns / conventions follow the closest equivalent files where feasible: read source, do not assume.\n` +
83
- `Evolve existing code first. Advisory — proceed once satisfied.`
77
+ `[bkit GateGuard] New file \`${base}\` this session. Before you add it, confirm each point below, and investigate any you cannot answer:\n` +
78
+ `- Confirm existing code does not already provide the capability, by searching or reading the code.\n` +
79
+ `- Confirm existing code cannot be reused or extended to provide the capability, by searching or reading the code.\n` +
80
+ `- Confirm anything the new code supersedes is deleted rather than left as duplicate work, by checking the removal.\n` +
81
+ `- Confirm the location and naming fit the project's architecture, topology and standards, by searching or reading the code.\n` +
82
+ `- Confirm the structures, patterns and conventions follow the closest equivalent files where feasible, by reading the code.\n` +
83
+ `Evolve existing code first.\n` +
84
+ `Advisory: proceed once satisfied.`
84
85
  );
85
86
  }
86
87
 
@@ -99,28 +100,42 @@ function isDocsPath(filePath) {
99
100
  function docAuthoringAdvisory() {
100
101
  return (
101
102
  `[bkit GateGuard] docs/*.md authoring:\n` +
102
- `- Read this file's header block and follow its purpose and rules if present.\n` +
103
- `- Check the .agents/docs.md index first and confirm the topic belongs in this doc, not another.\n` +
104
- `- Use dense token-efficient phrasing; no filler / hedging / restating; tables > prose, bullets > paragraphs.\n` +
105
- `- Describe current state / rules, not reasons / history; state what to do, not why. only exceptions: docs where purpose is the record.\n` +
106
- `Advisory — proceed once satisfied.`
103
+ `- Read this file's \`> [!CAUTION]\` header and follow its \`Purpose\` and \`Rules\`.\n` +
104
+ `- Find the topic's home in the \`.agents/docs.md\` index first, and confirm that it is this doc.\n` +
105
+ `- Follow \`.bkit/authoring.md\` § All Agent-Read Files and § Docs.\n` +
106
+ `Advisory: proceed once satisfied.`
107
107
  );
108
108
  }
109
109
 
110
110
  function configAdvisory(filePath) {
111
111
  const base = path.basename(filePath);
112
112
  return (
113
- `[bkit GateGuard] \`${base}\` quality-gate config (lint / format / types / test / slop):\n` +
114
- `- Prefer fixing code over weakening any gate.\n` +
115
- `- If a change is genuinely warranted, use targeted per-file / per-rule opt-outs over a blanket disable.\n` +
113
+ `[bkit GateGuard] \`${base}\` quality-gate config (lint, format, types, tests or slop):\n` +
114
+ `- Prefer fixing the code over weakening any gate.\n` +
115
+ `- If a change is genuinely warranted, use targeted opt-outs per file or per rule rather than a blanket disable.\n` +
116
116
  `- ALWAYS get explicit human sign-off for any quality-gate config change.\n` +
117
- `- Inside \`/bkit-*\` workflows no sign-off is available: record the block and continue; NEVER self-approve the opt-out.\n` +
118
- `Set BKIT_ALLOW_CONFIG_EDIT=1 to silence this. Advisory — proceed once satisfied.`
117
+ `- If you are inside a \`/bkit-*\` workflow, where no sign-off is available:\n` +
118
+ ` - Record the block and continue.\n` +
119
+ ` - NEVER self-approve the opt-out.\n` +
120
+ `With BKIT_ALLOW_CONFIG_EDIT=1 set, this file gets the normal first-edit or new-file checklist instead.\n` +
121
+ `Advisory: proceed once satisfied.`
119
122
  );
120
123
  }
121
124
 
125
+ // Per user: on a temp dir users share (Linux `/tmp`) another user's copy cannot be written.
122
126
  function stateDir() {
123
- return path.join(os.tmpdir(), "bkit-gateguard");
127
+ return path.join(
128
+ os.tmpdir(),
129
+ typeof process.getuid === "function" ? `bkit-gateguard-${process.getuid()}` : "bkit-gateguard",
130
+ );
131
+ }
132
+
133
+ // (session, file) warnings this process could not write to its state file, standing in
134
+ // for it for the process's life.
135
+ const warnedInProcess = new Set();
136
+
137
+ function inProcessKey(sessionId, filePath) {
138
+ return JSON.stringify([sessionId, filePath]);
124
139
  }
125
140
 
126
141
  // Dedup scope: the session, narrowed to one agent when the host names it. A Claude Code
@@ -149,6 +164,7 @@ function readState(sessionId) {
149
164
  }
150
165
 
151
166
  function alreadyWarned(sessionId, filePath) {
167
+ if (warnedInProcess.has(inProcessKey(sessionId, filePath))) return true;
152
168
  return Boolean(readState(sessionId).files[filePath]);
153
169
  }
154
170
 
@@ -177,6 +193,9 @@ function gcOldState() {
177
193
  // The advisory for the first touch of `filePath` this session, or null when GateGuard
178
194
  // is off, the path is unusable, or this session was already warned about it. Records
179
195
  // the touch. `isNewFile` picks the reuse checklist over the read-this-file checklist.
196
+ // Fail-open: a state-file write error still returns the checklist and the process
197
+ // remembers it, as advisory only — a deny no later call can see was given would block
198
+ // every retry of the edit.
180
199
  function firstTouchAdvice(filePath, sessionId, isNewFile) {
181
200
  const mode = process.env.BKIT_GATEGUARD;
182
201
  if (mode === "off") return null;
@@ -197,8 +216,13 @@ function firstTouchAdvice(filePath, sessionId, isNewFile) {
197
216
  ? `${baseContext}\n\n${docAuthoringAdvisory()}`
198
217
  : baseContext;
199
218
 
200
- markWarned(sid, filePath);
201
- gcOldState();
219
+ try {
220
+ markWarned(sid, filePath);
221
+ gcOldState();
222
+ } catch {
223
+ warnedInProcess.add(inProcessKey(sid, filePath));
224
+ return { mode: "advisory", context };
225
+ }
202
226
 
203
227
  return { mode: mode === "deny" ? "deny" : "advisory", context };
204
228
  }
@@ -189,10 +189,10 @@ function shellEditTargets(cmd) {
189
189
  /** Shared advisory string, identical on every host. */
190
190
  function shellEditAdvisory(hits) {
191
191
  return (
192
- `bkit guardrails: this command edits files through the shell (${hits.join("; ")}). ` +
193
- "Pre-edit gates only see edit/write tools, so a shell rewrite bypasses every one of them. " +
194
- "Use the edit/write tool instead unless this is one of the sanctioned exceptions in .agents/rules.md (generating files from a script, a bulk mechanical rewrite, or appending a log line to your own step output file). " +
195
- "Not blocked — proceed if it is."
192
+ `bkit guardrails: this command edits files through the shell (${hits.join("; ")}). The command is allowed. ` +
193
+ "Pre-edit gates see only the edit and write tools, so a shell edit gets past every one of them.\n" +
194
+ "Use the edit or write tool instead.\n" +
195
+ "If this is one of the exceptions in .agents/rules.md (generating files from a script, a bulk mechanical rewrite, or appending a log line to your own step output file with `>>`), proceed."
196
196
  );
197
197
  }
198
198