@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
@@ -34,6 +34,10 @@ export const SESSION_HIJACK_KEYS = [
34
34
  "BKIT_ANTHROPIC_API_KEY",
35
35
  "ANTHROPIC_AUTH_TOKEN",
36
36
  ];
37
+ // Router-only keys: used by a router job as a repo Actions secret, never by a cloud agent
38
+ // session. Pasting them would hand a paid key to every session that reads untrusted issue /
39
+ // PR text. Always dropped from the paste block.
40
+ export const ROUTER_ONLY_KEYS = ["BKIT_OPENAI_API_KEY"];
37
41
  // bkit baseline env-var NAMES every cloud environment needs, whatever the tracker:
38
42
  // `gh` and the GitHub MCP server read BKIT_GH_TOKEN on every host. Emitted as a
39
43
  // placeholder ONLY when absent from the resolved `.envrc` set — a present value keeps
@@ -111,6 +115,7 @@ export function resolveCloudEnvVars(cwd) {
111
115
  included: [],
112
116
  unset: [],
113
117
  hijackDropped: [],
118
+ routerOnlyDropped: [],
114
119
  emptySkipped: [],
115
120
  placeholders: [],
116
121
  sources: [],
@@ -151,6 +156,13 @@ export function resolveCloudEnvVars(cwd) {
151
156
  map.delete(k);
152
157
  }
153
158
  }
159
+ // Drop router-only keys.
160
+ for (const k of ROUTER_ONLY_KEYS) {
161
+ if (map.has(k)) {
162
+ res.routerOnlyDropped.push(k);
163
+ map.delete(k);
164
+ }
165
+ }
154
166
  // Partition non-empty (included) vs empty (skipped).
155
167
  for (const [k, v] of map) {
156
168
  if (v === "")
@@ -200,6 +212,9 @@ export function renderCloudEnvNotes(res) {
200
212
  if (res.hijackDropped.length) {
201
213
  bullets.push(`- **Dropped — session-billing hijack:** ${fmtList(res.hijackDropped)} — would redirect the agent's own model calls onto API-key billing instead of your subscription.`);
202
214
  }
215
+ if (res.routerOnlyDropped.length) {
216
+ bullets.push(`- **Dropped — router-only secret:** ${fmtList(res.routerOnlyDropped)} — set it as a repo Actions secret; no cloud agent session needs it.`);
217
+ }
203
218
  if (res.emptySkipped.length) {
204
219
  bullets.push(`- **Empty in source (skipped):** ${fmtList(res.emptySkipped)}`);
205
220
  }
@@ -567,15 +582,15 @@ function writeGeneratedJson(cwd, rel, doc, dryRun) {
567
582
  return true;
568
583
  }
569
584
  /**
570
- * 8-hex fingerprint of the DERIVED egress set only — bases and hosts, sorted, never
571
- * the consumer union. Hosts are included (the Cursor paste is hosts-only). Editing
572
- * `allowed-domains` never moves it; editing a registry row does.
585
+ * 8-hex fingerprint of an entry list, sorted and de-duplicated. With no argument it
586
+ * covers the DERIVED egress set only — bases and hosts, never the consumer union (the
587
+ * Cursor and Codex paste notes use that); editing `allowed-domains` never moves it,
588
+ * editing a registry row does. Pass the resolved allowlist to cover consumer
589
+ * `allowed-domains` too (the Claude paste list and `.bkit/allowlist.json`).
573
590
  */
574
- export function egressFingerprint() {
575
- const derived = [
576
- ...new Set([...BKIT_SHIPPED_NETWORK_DOMAINS, ...BKIT_SHIPPED_NETWORK_HOSTS]),
577
- ].sort();
578
- return sha256(derived.join("\n")).slice(0, 8);
591
+ export function egressFingerprint(entries) {
592
+ const set = entries ?? [...BKIT_SHIPPED_NETWORK_DOMAINS, ...BKIT_SHIPPED_NETWORK_HOSTS];
593
+ return sha256([...new Set(set)].sort().join("\n")).slice(0, 8);
579
594
  }
580
595
  /**
581
596
  * The "where these came from" clause of a network list's count note. A declared entry
@@ -616,10 +631,17 @@ export function renderCloudNetworkAllowlist(cwd) {
616
631
  "\n```\n\n" +
617
632
  `_${domains.length} entries (${domains.length / 2} domains, each as apex + \`*.\` wildcard): ` +
618
633
  networkSourceCounts(networkAllowlistBases(declared), BKIT_SHIPPED_NETWORK_DOMAINS) +
619
- ". Derived set fingerprint `" +
620
- egressFingerprint() +
634
+ ". Allowlist fingerprint `" +
635
+ egressFingerprint(domains) +
621
636
  "`._" +
622
637
  declaredNote +
638
+ "\n\nThe fingerprint is also recorded in `.bkit/allowlist.json`. After you paste the list, " +
639
+ "set `BKIT_CLOUD_ALLOWLIST_FINGERPRINT` to it in the cloud environment's variables (or " +
640
+ "the setup script); the SessionStart bootstrap compares it with the repo's current " +
641
+ "fingerprint and warns on a mismatch, then continues. The stamp is an operator " +
642
+ "assertion that you pasted this list: the deployed dashboard allowlist stays " +
643
+ "unverified. After any `allowed-domains` change, run `bkit upgrade`, re-paste the list " +
644
+ "and update the variable." +
623
645
  "\n\nUnder **Trusted**, your app domains and most observability / API hosts are\n" +
624
646
  "unreachable, so cloud `/bkit-debug` gets no runtime logs and e2e can't hit your\n" +
625
647
  "deployment. **Full** works too but opens all egress.");
@@ -88,6 +88,20 @@ export function extractManagedBlock(content, markerStyle = "html-comment") {
88
88
  const inner = startLineEnd === -1 ? "" : content.slice(startLineEnd + 1, lineStartOf(content, ends[0]));
89
89
  return inner.replace(/^\n+/, "").replace(/\n+$/, "");
90
90
  }
91
+ // The text from the first byte through the end-marker line (newline included). Null unless
92
+ // the file has exactly one start marker and one end marker, start first. Used to tell a
93
+ // change below the block from a change to the block or the text above it.
94
+ export function managedHead(content, markerStyle = "html-comment") {
95
+ const [startMarker, endMarker] = selectMarkers(markerStyle);
96
+ const starts = findLineAnchoredMarkers(content, startMarker);
97
+ const ends = findLineAnchoredMarkers(content, endMarker);
98
+ if (starts.length !== 1 || ends.length !== 1)
99
+ return null;
100
+ if (starts[0] >= ends[0])
101
+ return null;
102
+ const endLineEnd = content.indexOf("\n", ends[0] + endMarker.length);
103
+ return endLineEnd === -1 ? content : content.slice(0, endLineEnd + 1);
104
+ }
91
105
  // Extract the FULL bkit-managed block INCLUDING marker lines from a file.
92
106
  // markerStyle defaults to "html-comment".
93
107
  // Used to append a fresh block to a destination that has none. Markers may be
@@ -216,3 +230,90 @@ export function updateManagedBlock(filePath, newContent, dryRun = false, markerS
216
230
  fs.writeFileSync(filePath, result.content, "utf-8");
217
231
  return true;
218
232
  }
233
+ // ---------------------------------------------------------------------------
234
+ // Wrapper-only removal — the ownership metadata of a document that becomes the project's own
235
+ // ---------------------------------------------------------------------------
236
+ /** The generated notice line a managed block carries: `<!-- bkit:managed vX — do not edit; … -->`. */
237
+ const MANAGED_NOTICE_RE = /^<!-- bkit:managed v\S+ — (?:.* — )?do (?:not|NOT) edit; run `bkit upgrade` to refresh -->$/;
238
+ /** Lines with their terminators, so removing a line keeps every other byte, CRLF included. */
239
+ function splitKeepingEol(content) {
240
+ return content.match(/[^\n]*\n|[^\n]+$/g) ?? [];
241
+ }
242
+ const bareLine = (line) => line.replace(/\r?\n$/, "");
243
+ /**
244
+ * Remove the ownership wrapper of a markdown document: the one ordered pair of exact
245
+ * `<!-- bkit:start -->` / `<!-- bkit:end -->` lines and the generated `bkit:managed` notice line
246
+ * between them. Every other byte stays, original line endings included. The enclosed text is
247
+ * the project's. When both markers are absent the content is returned as it is. Anything that
248
+ * cannot be told apart from project text (one marker alone, reversed or repeated markers, a
249
+ * marker-looking line inside a Markdown fence, more than one notice) is `ambiguous` and the
250
+ * content is returned unchanged.
251
+ */
252
+ export function stripManagedWrapper(content) {
253
+ const lines = splitKeepingEol(content);
254
+ const starts = [];
255
+ const ends = [];
256
+ const notices = [];
257
+ let fence = null;
258
+ let inFenceHit = false;
259
+ lines.forEach((line, i) => {
260
+ const text = bareLine(line);
261
+ const fenceMatch = /^\s*(`{3,}|~{3,})/.exec(text);
262
+ if (fenceMatch) {
263
+ const mark = fenceMatch[1][0];
264
+ if (fence === null)
265
+ fence = mark;
266
+ else if (fence === mark)
267
+ fence = null;
268
+ return;
269
+ }
270
+ const isStart = text === START_MARKER;
271
+ const isEnd = text === END_MARKER;
272
+ const isNotice = MANAGED_NOTICE_RE.test(text);
273
+ if (fence !== null) {
274
+ if (isStart || isEnd || isNotice)
275
+ inFenceHit = true;
276
+ return;
277
+ }
278
+ if (isStart)
279
+ starts.push(i);
280
+ else if (isEnd)
281
+ ends.push(i);
282
+ else if (isNotice)
283
+ notices.push(i);
284
+ });
285
+ const ambiguous = (problem) => ({
286
+ status: "ambiguous",
287
+ content,
288
+ problem,
289
+ });
290
+ if (inFenceHit)
291
+ return ambiguous("inside-fence");
292
+ if (starts.length === 0 && ends.length === 0)
293
+ return { status: "none", content };
294
+ if (starts.length === 0 || ends.length === 0)
295
+ return ambiguous("missing-partner");
296
+ if (starts.length > 1 || ends.length > 1)
297
+ return ambiguous("multiple");
298
+ const start = starts[0];
299
+ const end = ends[0];
300
+ if (start >= end)
301
+ return ambiguous("inverted");
302
+ const inside = notices.filter((n) => n > start && n < end);
303
+ if (inside.length > 1 || notices.length > inside.length)
304
+ return ambiguous("multiple-notices");
305
+ const drop = new Set([start, end, ...inside]);
306
+ // The writer pads each wrapper line with one blank line (`start`, blank, notice, blank,
307
+ // content, blank, `end`). That padding goes with the wrapper, one line each.
308
+ const isBlank = (i) => i >= 0 && i < lines.length && bareLine(lines[i]) === "";
309
+ for (const i of [start, ...inside])
310
+ if (isBlank(i + 1) && i + 1 < end)
311
+ drop.add(i + 1);
312
+ if (isBlank(end - 1) && end - 1 > start)
313
+ drop.add(end - 1);
314
+ return {
315
+ status: "removed",
316
+ content: lines.filter((_, i) => !drop.has(i)).join(""),
317
+ removedLines: drop.size,
318
+ };
319
+ }
@@ -58,7 +58,7 @@ export function parseIssueTracker(value) {
58
58
  *
59
59
  * Single self-describing field (mirrors `bkit.tracker.default`).
60
60
  */
61
- export const CLOUD_MODES = ["claude", "cursor", "opencode", "none"];
61
+ export const CLOUD_MODES = ["claude", "cursor", "opencode", "codex", "none"];
62
62
  /** Default when consumer manifest has no `bkit.cloud.agent` field (undecided). */
63
63
  export const DEFAULT_CLOUD_AGENTS = "none";
64
64
  /** Narrow an unknown string to `CloudAgents` or return `null` if invalid. */
@@ -371,6 +371,12 @@ export const OPENCODE_MANIFEST = [
371
371
  format: "markered-text",
372
372
  module: "opencode",
373
373
  },
374
+ // bkit-guardrails.js — same split as bkit-gateguard.js. Refuses the shell deny tier.
375
+ {
376
+ path: ".opencode/plugin/bkit-guardrails.js",
377
+ format: "markered-text",
378
+ module: "opencode",
379
+ },
374
380
  // bkit-rules.js — same split as bkit-gateguard.js. Delivers the rules-read advisory
375
381
  // on the session's first tool call (opencode has no session-start event).
376
382
  {
@@ -185,7 +185,9 @@ export function runClaudeModule(ctx) {
185
185
  * never recorded, so it is never touched. An absent or empty record means bkit claims
186
186
  * authorship of nothing and prunes nothing — old consumers converge by addition only.
187
187
  *
188
- * Returns the set to record for next time, or `null` when nothing was determined and
188
+ * Returns the set to record for next time (the grants bkit added on this install and the
189
+ * recorded ones it still derives, never a grant the consumer already had), or `null`
190
+ * when nothing was determined and
189
191
  * the caller must leave the prior record alone: no settings file, unparseable JSON,
190
192
  * a non-array `allow`, or a dry run. `null` is a statement about PROVENANCE, never
191
193
  * about the write set — the `ws.writes` push below still fires under `dryRun`, because
@@ -224,7 +226,9 @@ export function enrichClaudeSettingsAllows(settingsDst, cwd, dryRun, ws, advisor
224
226
  });
225
227
  }
226
228
  }
227
- return dryRun ? null : needed;
229
+ // Record only what bkit wrote: grants it added before and still derives, plus the ones it
230
+ // added now. A grant the consumer already had is never recorded, so uninstall keeps it.
231
+ return dryRun ? null : [...new Set([...recorded.filter((r) => needed.includes(r)), ...add])];
228
232
  }
229
233
  // ---------------------------------------------------------------------------
230
234
  // MCP config — `.mcp.json` (claude) and `.cursor/mcp.json` (cursor). bkit owns only
@@ -5,6 +5,8 @@
5
5
  import * as fs from "node:fs";
6
6
  import * as path from "node:path";
7
7
  import { parseJson } from "../../shared/json.js";
8
+ import { isOpencodeProvider } from "../../render/models.js";
9
+ import { OPENCODE_PROVIDER_DEFAULTS } from "../../shared/egress.js";
8
10
  // ---------------------------------------------------------------------------
9
11
  // Helpers
10
12
  // ---------------------------------------------------------------------------
@@ -52,8 +54,25 @@ function setConsumerBkitField(field, value, dryRun) {
52
54
  }
53
55
  }
54
56
  // The cloud workflow is a template (`.bkit/templates.md`). Shared first step of the
55
- // claude and opencode setup advisories.
56
- const CLOUD_WORKFLOW_ADOPT_STEP = " - Copy `.bkit/templates/.github/workflows/bkit-cloud.yml` to `.github/workflows/bkit-cloud.yml` and own it: bkit never writes or overwrites that file after you copy it. The one exception is a brand migration: `bkit upgrade` rewrites exact shipped old names in it and leaves any edited line. Replace the `{{CLOUD_RUNNER}}` placeholder in both jobs' `runs-on` with a runner label (e.g. `ubuntu-latest`). `.bkit/templates.md` lists every placeholder; on each `bkit upgrade`, diff the refreshed template against your copy.\n";
57
+ // router-backed setup advisories.
58
+ const CLOUD_WORKFLOW_ADOPT_STEP = " - Copy `.bkit/templates/.github/workflows/bkit-cloud.yml` to `.github/workflows/bkit-cloud.yml` and own it: bkit never writes or overwrites that file after you copy it. The one exception is a brand migration: `bkit upgrade` rewrites exact shipped old names in it and leaves any edited line. Replace `{{CLOUD_RUNNER}}` with your runner label and `{{NODE_VERSION}}` with your Node major. `.bkit/templates.md` lists every placeholder; on each `bkit upgrade`, diff the refreshed template against your copy.\n";
59
+ function trackerAdvisoryLines(tracker, variant) {
60
+ const credentials = {
61
+ github: " - Tracker credential (GitHub): set `BKIT_GH_TOKEN` for the cloud environment.\n",
62
+ linear: " - Tracker credential (Linear): set `BKIT_LINEAR_API_KEY` in the cloud environment and as a repo Actions secret for the router. Generate it at https://linear.app/settings/api.\n",
63
+ jira: " - Tracker credential (Jira): set `BKIT_JIRA_API_KEY` in the cloud environment and as a repo Actions secret for the router. Use an Atlassian MCP V2 scoped token; `.bkit/trackers.md` § jira lists its permissions.\n",
64
+ none: " - Wire a tracker with `bkit install --tracker=<github|linear|jira>`.\n",
65
+ };
66
+ const cursorTriggers = {
67
+ github: " - Optional native launch: mention `@cursor` on a GitHub issue or pull request.\n",
68
+ linear: " - Optional native launch: use Cursor's Linear integration.\n",
69
+ jira: " - Launch Cursor manually or through its own GitHub triggers for a Jira issue.\n",
70
+ none: "",
71
+ };
72
+ return (credentials[tracker] +
73
+ " - Label the issue `bkit:auto` in the configured tracker before pushing the build commit.\n" +
74
+ (variant === "cursor" ? cursorTriggers[tracker] : ""));
75
+ }
57
76
  // ---------------------------------------------------------------------------
58
77
  // runCloudModule — opt-in cloud-agent integration
59
78
  // ---------------------------------------------------------------------------
@@ -69,98 +88,66 @@ const CLOUD_WORKFLOW_ADOPT_STEP = " - Copy `.bkit/templates/.github/workflows/b
69
88
  // = hard error). The context's cloudVariant carries the chosen variant.
70
89
  export function runCloudModule(ctx) {
71
90
  const { dryRun, advisories } = ctx;
72
- // Default to "claude" (the Claude/GitHub path) when cloudVariant is not set.
73
- // Callers should always pass cloudVariant.
74
91
  const variant = ctx.cloudVariant ?? "claude";
75
- if (variant === "claude") {
76
- // --- cloud=claude: GitHub-tracker path ---
77
- // Record the variant so the post-install advisory and `bkit check` stay consistent.
78
- setConsumerBkitField("cloud.agent", "claude", dryRun);
79
- // Advisory — cloud=claude setup checklist (App required; id-token: write).
80
- advisories.push({
81
- id: "bkit-cloud-setup",
82
- severity: "advisory",
83
- detect: "Cloud agents (claude) need the unified cloud workflow (claude + opencode jobs, runtime-gated by secret presence), which ships as a template at `.bkit/templates/.github/workflows/bkit-cloud.yml`. The Claude GitHub App is required for `claude-code-action@v1` to authenticate via OIDC.",
84
- action: "Full recipe in bkit's `cloud.md` § Post-CI auto-routing.\n\n" +
85
- "REQUIRED ONE-TIME SETUP:\n" +
86
- CLOUD_WORKFLOW_ADOPT_STEP +
87
- " - Run `/install-github-app` (Claude Code CLI) to install the Claude GitHub App on your repo. This is required — `claude-code-action@v1` authenticates as the App via OIDC (`id-token: write`); without the App it fails at boot with an OIDC error.\n" +
88
- " - GitHub Actions permissions — flip BOTH org AND repo: Settings → Actions → General → Workflow permissions = **Read and write permissions** + tick **Allow GitHub Actions to create and approve pull requests**.\n" +
89
- " - Give `claude-code-action@v1` ONE claude credential (Settings → Secrets and variables → Actions):\n" +
90
- " - the `ANTHROPIC_API_KEY` repo secret (job env keeps this vendor name; local `.bkit/.env` stores it as `BKIT_ANTHROPIC_API_KEY`), or\n" +
91
- " - keyless workload identity federation: Claude Console → Settings → Workload identity → Connect workload → GitHub Actions creates the issuer, service account and federation rule; then set the `ANTHROPIC_FEDERATION_RULE_ID` + `ANTHROPIC_ORGANIZATION_ID` repo variables (optional `ANTHROPIC_SERVICE_ACCOUNT_ID` / `ANTHROPIC_WORKSPACE_ID`). Leave `ANTHROPIC_API_KEY` unset — a set key wins over federation.\n" +
92
- " - Label the issue `bkit:auto` before pushing the build commit — without the label the CI auto-route exits no-op.\n\n" +
93
- "OPTIONAL (manual phase launch): after `/install-github-app`, comment `@claude /bkit-plan` (or any phase) on a GitHub issue/PR to launch it from the tracker UI. The App's generated `claude.yml` triggers on mention events; `bkit-cloud.yml` triggers on CI completion + `workflow_dispatch` — the two coexist.\n\n" +
94
- "Both the CI-driven path and the `@claude` mention path invoke the same `/bkit-auto` orchestrator (mirrored to `.claude/commands/bkit-auto.md` on each `pnpm bkit install`).",
95
- });
96
- // Advisory — cloud env scaffolding (Claude half).
97
- advisories.push({
98
- id: "cloud-env-customize",
99
- severity: "advisory",
100
- detect: "Cloud env config splits across the repo (`.claude/hooks/bkit-cloud-bootstrap.sh`, a copy-and-own template you adopt) and the Claude app dashboard (setup script + env vars + auth tokens, manual).",
101
- action: "Two locations to touch — full recipe in bkit's `cloud.md`.\n\n" +
102
- "IN REPO (copy-and-own; bkit never writes it, apart from brand migrations that rewrite exact shipped old names):\n" +
103
- " - Adopt `.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh` as `.claude/hooks/bkit-cloud-bootstrap.sh` and edit it freely — the baseline runs `pnpm install` / `vale sync` and the gh login on each cloud session; add your own repo-specific steps (Supabase start, turbo prebuild, etc. — examples inlined). The `.claude/settings.json` SessionStart entry runs it only when present (`test -f … || true`).\n\n" +
104
- "IN CLAUDE APP (claude.ai/code → environment selector → + Add environment):\n" +
105
- " - Name: the repo name (e.g. `acme-web`) — one environment per repo, since secrets are per-repo.\n" +
106
- " - Setup script: paste from bkit's `cloud.md` § Setup script (installs Node 24 + vale + gh + jq + corepack-pinned pnpm — exact versions live in cloud.md, not duplicated here).\n" +
107
- " - Environment variables: `BKIT_GH_TOKEN` (fine-grained for one owner, classic across owners — GitHub MCP).\n" +
108
- " - Tracker env vars (GitHub): `BKIT_GH_TOKEN` above is the only tracker credential — the GitHub MCP server sends it on every call, and the bootstrap hook signs `gh` in with it.\n" +
109
- " - Network access: `Trusted` (default). One environment per repo (secrets differ per repo); the setup script + variable *names* are identical across repos, only the values change. See cloud.md § Sharing across repos → Claude.",
110
- });
111
- }
112
- else if (variant === "opencode") {
113
- // --- cloud=opencode: GitHub-tracker path (same bkit-cloud.yml template, no OIDC) ---
114
- // Record the variant.
115
- setConsumerBkitField("cloud.agent", "opencode", dryRun);
116
- // Advisory — cloud=opencode setup checklist.
117
- advisories.push({
118
- id: "bkit-cloud-setup",
119
- severity: "advisory",
120
- detect: "Cloud agents (opencode) need the unified cloud workflow (claude + opencode jobs, runtime-gated by secret presence), which ships as a template at `.bkit/templates/.github/workflows/bkit-cloud.yml`. The opencode job runs when `OPENCODE_PROVIDER_KEY` is set.",
121
- action: "Full recipe in bkit's `cloud.md` § Post-CI auto-routing.\n\n" +
122
- "REQUIRED ONE-TIME SETUP:\n" +
123
- CLOUD_WORKFLOW_ADOPT_STEP +
124
- " - Install the local opencode host first: `bkit install --opencode=<provider>` (e.g. `--opencode=opencode`). The cloud opencode job runs against the committed `.opencode/` config — provider and model pins come from there, not from this YAML.\n" +
125
- " - Add `OPENCODE_PROVIDER_KEY` to repo secrets (Settings → Secrets and variables → Actions). Set it to your configured provider's API key. The workflow fans this one secret out to every supported provider env var name (`BKIT_OPENROUTER_API_KEY`/`BKIT_OLLAMA_API_KEY`/`BKIT_OPENCODE_API_KEY`) so the `.opencode/opencode.json` `{env:VAR}` reference resolves whichever provider you installed.\n" +
126
- " - GitHub Actions permissions — flip BOTH org AND repo: Settings → Actions → General → Workflow permissions = **Read and write permissions** + tick **Allow GitHub Actions to create and approve pull requests**.\n" +
127
- " - The opencode job does NOT use a Claude API key — it runs the opencode runner with your chosen provider key only. If you also install the claude job (separate secret), both jobs coexist on the same event.\n" +
128
- " - Label the issue `bkit:auto` before pushing the build commit — without the label the CI auto-route exits no-op.\n\n" +
129
- "REACTIVE HANDLER (separate, consumer self-installed): the stock `/oc` comment handler (`opencode github install`) is NOT managed by bkit — install it once per repo independently. It mirrors the `@claude`/`claude.yml` stance. `bkit-cloud.yml` handles the CI-driven + `workflow_dispatch` path only.",
130
- });
131
- }
132
- else {
133
- // --- cloud=cursor: Linear-tracker path ---
134
- // Record the variant.
135
- setConsumerBkitField("cloud.agent", "cursor", dryRun);
136
- // Advisory — cloud=cursor setup checklist.
137
- advisories.push({
138
- id: "bkit-cloud-setup",
139
- severity: "advisory",
140
- detect: "Cloud agents (cursor) need the Cursor Background Agent scaffolding, which ships as templates at `.bkit/templates/.cursor/Dockerfile` and `.bkit/templates/.cursor/environment.json`. The Cursor Background Agent trigger is configured in the Cursor cloud agents dashboard — bkit cannot automate that step.",
92
+ const trackerLines = trackerAdvisoryLines(ctx.issueTracker, variant);
93
+ const providerKey = ctx.opencodeProvider && isOpencodeProvider(ctx.opencodeProvider)
94
+ ? OPENCODE_PROVIDER_DEFAULTS[ctx.opencodeProvider].envVar
95
+ : "your configured provider's BKIT_ key";
96
+ const routerSetup = "Full recipe in bkit's `cloud.md` § Post-CI auto-routing.\n\n" +
97
+ "REQUIRED ONE-TIME SETUP:\n" +
98
+ CLOUD_WORKFLOW_ADOPT_STEP +
99
+ " - GitHub Actions permissions — set org and repo Workflow permissions to **Read and write permissions** and tick **Allow GitHub Actions to create and approve pull requests**.\n";
100
+ const variants = {
101
+ claude: {
102
+ detect: "Cloud agents (claude) use the unified cloud workflow. It selects the recorded cloud agent and requires the Claude GitHub App for OIDC authentication.",
103
+ action: routerSetup +
104
+ " - Run `/install-github-app` (Claude Code CLI) to install the Claude GitHub App. The action needs `id-token: write` for OIDC.\n" +
105
+ " - Set the `BKIT_ANTHROPIC_API_KEY` repo secret, or configure keyless workload identity federation with the `ANTHROPIC_FEDERATION_RULE_ID` + `ANTHROPIC_ORGANIZATION_ID` repo variables (optional `ANTHROPIC_SERVICE_ACCOUNT_ID` / `ANTHROPIC_WORKSPACE_ID`). Leave the API key unset to use federation.\n" +
106
+ trackerLines +
107
+ "\nOPTIONAL: after installing the App, mention `@claude /bkit-plan` on a GitHub issue or pull request. Vendor-native handlers are installed separately; bkit does not install them.",
108
+ },
109
+ opencode: {
110
+ detect: "Cloud agents (opencode) use the unified cloud workflow and the provider configured in the committed .opencode/ host.",
111
+ action: routerSetup +
112
+ " - Install the local host: `bkit install --opencode=<provider>` (e.g. `--opencode=openrouter`). Commit its provider and model configuration.\n" +
113
+ ` - Add \`${providerKey}\` to repo Actions secrets for the configured provider.\n` +
114
+ trackerLines +
115
+ "\nThe stock `/oc` comment handler (`opencode github install`) is a separate vendor-native installation; bkit does not install it.",
116
+ },
117
+ codex: {
118
+ detect: "Cloud agents (codex) use the unified cloud workflow and openai/codex-action with the installed Codex host.",
119
+ action: routerSetup +
120
+ " - Install the Codex host first: `bkit install --codex`. Copy the environment setup from `.codex/bkit-cloud.md` (gitignored).\n" +
121
+ " - Add `BKIT_OPENAI_API_KEY` to repo Actions secrets. The router starts the codex job only when codex is the recorded agent and its credential is set.\n" +
122
+ trackerLines +
123
+ "\nVendor-native `@Codex` mentions and Codex for Linear are configured separately; bkit documents them and does not install them.",
124
+ },
125
+ cursor: {
126
+ detect: "Cloud agents (cursor) use the Cursor Cloud Agents dashboard triggers and the .cursor/ scaffolding templates.",
141
127
  action: "Full recipe in bkit's `cloud.md` § Post-CI auto-routing.\n\n" +
142
128
  "IN CURSOR DASHBOARD:\n" +
143
129
  " - Cursor → Cloud Agents dashboard → Triggers → + Add trigger.\n" +
144
130
  " - Event: CI workflow completion. Branch filter: `feat/**`.\n" +
145
- " - Prompt (paste literally, no edits): `/bkit-auto $CI_STATUS $PR_NUMBER`.\n" +
146
- " - Allowed concurrency: latest-supersedes.\n" +
147
- " - Set `BKIT_LINEAR_API_KEY` as a **Runtime Secret** in the Cloud Agents dashboard (https://cursor.com/dashboard/cloud-agents) → your environment → Secrets tab.\n" +
148
- " - Label the issue `bkit:auto` in Linear before pushing the build commit.\n\n" +
149
- "IN REPO (copy each template and own it; bkit never writes or overwrites these files, apart from brand migrations that rewrite exact shipped old names — see `.bkit/templates.md`):\n" +
150
- " - `.bkit/templates/.cursor/Dockerfile` → `.cursor/Dockerfile`: change Node major if `engines.node` differs from 20; add Playwright / Supabase CLI / extra apt deps.\n" +
151
- " - `.bkit/templates/.cursor/environment.json` → `.cursor/environment.json`: set `install` / `start` / `terminals[]` / `env` for your stack.",
152
- });
153
- // Advisory — cloud env scaffolding (Cursor half).
131
+ " - Prompt: `/bkit-auto $CI_STATUS $PR_NUMBER`. Allowed concurrency: latest-supersedes.\n" +
132
+ trackerLines +
133
+ "\nIN REPO (copy each template and own it):\n" +
134
+ " - `.bkit/templates/.cursor/Dockerfile` → `.cursor/Dockerfile`: match your Node major and add your stack's tools.\n" +
135
+ " - `.bkit/templates/.cursor/environment.json` → `.cursor/environment.json`: configure install, start and terminal commands.",
136
+ },
137
+ };
138
+ setConsumerBkitField("cloud.agent", variant, dryRun);
139
+ advisories.push({ id: "bkit-cloud-setup", severity: "advisory", ...variants[variant] });
140
+ if (variant === "claude" || variant === "cursor") {
141
+ const environment = variant === "claude"
142
+ ? "Adopt `.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh` as `.claude/hooks/bkit-cloud-bootstrap.sh`. Configure the setup script and environment in the Claude app dashboard."
143
+ : "Configure the copied .cursor/Dockerfile and .cursor/environment.json, then add each token as a **Runtime Secret** in the Cursor Cloud Agents dashboard.";
154
144
  advisories.push({
155
145
  id: "cloud-env-customize",
156
146
  severity: "advisory",
157
- detect: "Cloud env config splits across the repo (`.cursor/Dockerfile` + `.cursor/environment.json`, copied from `.bkit/templates/.cursor/`) and the Cursor Cloud Agents dashboard (secrets, manual).",
158
- action: "Copy-paste-ready values (resolved from your `.envrc`) are written to `.cursor/bkit-cloud.md` (gitignored) on every install.\n\n" +
159
- "IN THE CLOUD AGENTS DASHBOARD (https://cursor.com/dashboard/cloud-agents → your environment → Secrets tab) — add each as a **Runtime Secret** (loaded as an env var, redacted from the agent's transcript):\n" +
160
- " - `BKIT_GH_TOKEN`.\n" +
161
- " - Tracker secret (Linear): `BKIT_LINEAR_API_KEY` (generate at https://linear.app/settings/api). `LINEAR_ISSUE_ID` is injected per-session — don't hardcode.\n" +
162
- " - First session after Dockerfile changes rebuilds the image; subsequent sessions reuse cached layers.\n\n" +
163
- "Full recipe in bkit's `cloud.md`; the paste-ready block is in `.cursor/bkit-cloud.md`.",
147
+ detect: `Cloud environment setup combines the repo templates and the ${variant} dashboard.`,
148
+ action: environment +
149
+ ` Copy-paste-ready values resolved from your .envrc are in .${variant}/bkit-cloud.md (gitignored).\n` +
150
+ trackerLines,
164
151
  });
165
152
  }
166
153
  }
@@ -10,6 +10,12 @@ import { substituteWorkflow } from "../../render/trackers.js";
10
10
  import { readInstallingVersion } from "../../shared/package-json.js";
11
11
  import { writeCodexCloudDoc } from "../cloud-env.js";
12
12
  import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
13
+ /**
14
+ * Status of the Codex private-key shell-read deny. Set from the recorded real-host result
15
+ * (`tests/experiments/hooks/results/<date>/bkit-codex-key-deny.json`): only an outcome of
16
+ * `denied` allows "denied (verified on codex-cli {version}, {date})".
17
+ */
18
+ const CODEX_KEY_DENY_STATUS = "configured to deny, not verified on a real Codex host";
13
19
  /**
14
20
  * Convert a workflow orchestrator (`.bkit/core/workflows/*.md`) into a Codex SKILL.md.
15
21
  *
@@ -184,9 +190,10 @@ export function runCodexModule(ctx) {
184
190
  id: "codex-setup",
185
191
  severity: "advisory",
186
192
  detect: "codex host installed (.codex/agents + .agents/skills/bkit-*).",
187
- action: "Three things that differ from the other hosts:\n" +
193
+ action: "Four things that differ from the other hosts:\n" +
188
194
  "1. TRUST THE LAYER. Codex loads project-local hooks only once the `.codex/` layer is trusted. Until then GateGuard and ReadGuard are installed and never fire.\n" +
189
195
  "2. Workflows are SKILLS here, not slash commands: invoke `$bkit-design`, not `/bkit-design`.\n" +
190
- "3. Per-agent `tools:` is NOT enforced. Codex has no tool allowlist, so every agent gets the full built-in tool set. See .bkit/providers.md.",
196
+ "3. Per-agent `tools:` is NOT enforced. Codex has no tool allowlist, so every agent gets the full built-in tool set. See .bkit/providers.md.\n" +
197
+ `4. SHELL READS OF SECRET FILES. Private-key shell reads are ${CODEX_KEY_DENY_STATUS}: a command that prints a private key's content or sends it off the machine (\`cat\`, \`head\`, \`grep\`, \`dd if=\`, \`git show HEAD:key.pem\`, \`openssl rsa -in\`, \`curl -d @key.pem\`, \`scp key.pem host:\`) for \`id_rsa\`, \`id_dsa\`, \`id_ecdsa\`, \`id_ed25519\`, \`*.pem\`, \`*.p12\`, \`*.pfx\` or \`*.key\`, or for a glob that can match one (\`~/.ssh/*\`). A command that only uses a key (\`ssh -i\`, \`curl --cacert\`) runs with a note. The rule goes by file name, so a renamed or copied key, a path in a variable, and \`xargs\`, \`find -exec\` or a script language are not caught. To act on it: trust the \`.codex/\` layer (item 1), keep private keys out of the repo, and check the deny on a real Codex host before relying on it: trust the \`.codex/\` layer, write a synthetic \`id_rsa\` containing no real key, ask Codex to run \`cat ./id_rsa\`, and confirm a control that the same hook denies (\`bkit tests jump\`) is also denied; if the control is not denied the hook did not run. \`.env\` shell reads stay advisory: the command runs with a note, so the protection is advisory only. Keep secrets out of reach with direnv (\`.envrc\`) and do not rely on this hook for \`.env\` files.`,
191
198
  });
192
199
  }