@cbartens/bkit 5.2.3 → 5.3.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 (254) hide show
  1. package/.bkit/README.md +29 -12
  2. package/.bkit/core/.agents/context.md +1 -1
  3. package/.bkit/core/.agents/docs.md +1 -1
  4. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +1 -1
  5. package/.bkit/core/.agents/rules.md +11 -0
  6. package/.bkit/core/.bkit/README.md +28 -11
  7. package/.bkit/core/.bkit/cloud.md +9 -8
  8. package/.bkit/core/.bkit/comparison.md +68 -345
  9. package/.bkit/core/.bkit/install.md +15 -9
  10. package/.bkit/core/.bkit/lite.md +73 -0
  11. package/.bkit/core/.bkit/pipeline.md +345 -0
  12. package/.bkit/core/.bkit/prompts.md +88 -73
  13. package/.bkit/core/.bkit/providers.md +41 -22
  14. package/.bkit/core/.bkit/templates.md +125 -18
  15. package/.bkit/core/.bkit/trackers.md +47 -1
  16. package/.bkit/core/.bkit/workflows.md +51 -45
  17. package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +1 -1
  18. package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +7 -4
  19. package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +8 -5
  20. package/.bkit/core/docs/templates/bkit-audit-accessibility.md +9 -1
  21. package/.bkit/core/docs/templates/bkit-audit-adoption.md +10 -2
  22. package/.bkit/core/docs/templates/bkit-audit-agents.md +9 -1
  23. package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +9 -1
  24. package/.bkit/core/docs/templates/bkit-audit-analytics.md +9 -1
  25. package/.bkit/core/docs/templates/bkit-audit-annotations.md +10 -2
  26. package/.bkit/core/docs/templates/bkit-audit-app-performance.md +9 -1
  27. package/.bkit/core/docs/templates/bkit-audit-app-store.md +9 -1
  28. package/.bkit/core/docs/templates/bkit-audit-architecture.md +9 -1
  29. package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +9 -1
  30. package/.bkit/core/docs/templates/bkit-audit-config.md +9 -1
  31. package/.bkit/core/docs/templates/bkit-audit-cost.md +10 -2
  32. package/.bkit/core/docs/templates/bkit-audit-coverage.md +9 -1
  33. package/.bkit/core/docs/templates/bkit-audit-database.md +9 -1
  34. package/.bkit/core/docs/templates/bkit-audit-dead-code.md +9 -1
  35. package/.bkit/core/docs/templates/bkit-audit-deferrals.md +9 -1
  36. package/.bkit/core/docs/templates/bkit-audit-dependencies.md +22 -10
  37. package/.bkit/core/docs/templates/bkit-audit-documentation.md +9 -1
  38. package/.bkit/core/docs/templates/bkit-audit-duplication.md +9 -1
  39. package/.bkit/core/docs/templates/bkit-audit-failures.md +9 -1
  40. package/.bkit/core/docs/templates/bkit-audit-flakes.md +10 -2
  41. package/.bkit/core/docs/templates/bkit-audit-gates.md +9 -1
  42. package/.bkit/core/docs/templates/bkit-audit-issues.md +9 -1
  43. package/.bkit/core/docs/templates/bkit-audit-llm.md +29 -15
  44. package/.bkit/core/docs/templates/bkit-audit-logs.md +10 -2
  45. package/.bkit/core/docs/templates/bkit-audit-models.md +9 -1
  46. package/.bkit/core/docs/templates/bkit-audit-privacy.md +9 -1
  47. package/.bkit/core/docs/templates/bkit-audit-prompts.md +11 -3
  48. package/.bkit/core/docs/templates/bkit-audit-red-team.md +19 -9
  49. package/.bkit/core/docs/templates/bkit-audit-reliability.md +9 -1
  50. package/.bkit/core/docs/templates/bkit-audit-repo.md +10 -2
  51. package/.bkit/core/docs/templates/bkit-audit-security.md +13 -5
  52. package/.bkit/core/docs/templates/bkit-audit-slop.md +9 -1
  53. package/.bkit/core/docs/templates/bkit-audit-testing.md +14 -5
  54. package/.bkit/core/docs/templates/bkit-audit-usability.md +9 -1
  55. package/.bkit/core/docs/templates/bkit-plan.md +8 -6
  56. package/.bkit/core/engine/checks/after/auth.ts +9 -9
  57. package/.bkit/core/engine/checks/after/ci-yml.ts +14 -12
  58. package/.bkit/core/engine/checks/after/github.ts +29 -120
  59. package/.bkit/core/engine/checks/after/index.ts +2 -2
  60. package/.bkit/core/engine/checks/after/managed.ts +8 -28
  61. package/.bkit/core/engine/checks/after/tools.ts +3 -15
  62. package/.bkit/core/engine/checks/before/context-fetch.ts +1 -21
  63. package/.bkit/core/engine/checks/before/index.ts +7 -43
  64. package/.bkit/core/engine/checks/before/mcp.ts +17 -8
  65. package/.bkit/core/engine/checks/before/repo.ts +9 -12
  66. package/.bkit/core/engine/checks/status-holes.ts +4 -5
  67. package/.bkit/core/engine/checks/tips/catalogue.ts +70 -24
  68. package/.bkit/core/engine/checks/tips/detect.ts +45 -2
  69. package/.bkit/core/engine/checks/tips/index.ts +37 -8
  70. package/.bkit/core/engine/cli.ts +39 -16
  71. package/.bkit/core/engine/commands/analysis.ts +36 -26
  72. package/.bkit/core/engine/commands/comply.ts +17 -16
  73. package/.bkit/core/engine/commands/harvest.ts +12 -12
  74. package/.bkit/core/engine/commands/install/doctor.ts +57 -28
  75. package/.bkit/core/engine/commands/install/install.ts +62 -126
  76. package/.bkit/core/engine/commands/install/uninstall.ts +191 -33
  77. package/.bkit/core/engine/commands/install/upgrade.ts +58 -53
  78. package/.bkit/core/engine/commands/lib.ts +35 -10
  79. package/.bkit/core/engine/commands/tips.ts +8 -5
  80. package/.bkit/core/engine/commands/workflow/branches.ts +65 -11
  81. package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
  82. package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
  83. package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
  84. package/.bkit/core/engine/commands/workflow/prs.ts +4 -2
  85. package/.bkit/core/engine/commands/workflow/repo.ts +18 -4
  86. package/.bkit/core/engine/commands/workflow/roadmap.ts +4 -3
  87. package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
  88. package/.bkit/core/engine/commands/workflow/steps.ts +1 -0
  89. package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
  90. package/.bkit/core/engine/commands/workflow/workflows.ts +19 -17
  91. package/.bkit/core/engine/commands/workflow/workstreams.ts +2 -1
  92. package/.bkit/core/engine/commands/workflow/worktrees.ts +13 -5
  93. package/.bkit/core/engine/install/cloud-env.ts +10 -31
  94. package/.bkit/core/engine/install/manifest.ts +14 -7
  95. package/.bkit/core/engine/install/modules/antigravity.ts +15 -26
  96. package/.bkit/core/engine/install/modules/claude.ts +20 -28
  97. package/.bkit/core/engine/install/modules/cloud.ts +5 -2
  98. package/.bkit/core/engine/install/modules/codex.ts +15 -29
  99. package/.bkit/core/engine/install/modules/core.ts +91 -70
  100. package/.bkit/core/engine/install/modules/cursor.ts +6 -20
  101. package/.bkit/core/engine/install/modules/index.ts +7 -1
  102. package/.bkit/core/engine/install/modules/opencode.ts +48 -70
  103. package/.bkit/core/engine/install/network-allowlist.ts +73 -0
  104. package/.bkit/core/engine/install/placeholders.ts +3 -18
  105. package/.bkit/core/engine/install/write.ts +59 -12
  106. package/.bkit/core/engine/ledgers/telemetry.ts +6 -4
  107. package/.bkit/core/engine/render/hosts.ts +47 -67
  108. package/.bkit/core/engine/render/models.ts +29 -11
  109. package/.bkit/core/engine/shared/bkit-latest.ts +164 -0
  110. package/.bkit/core/engine/shared/branches.ts +13 -0
  111. package/.bkit/core/engine/shared/egress.ts +3 -3
  112. package/.bkit/core/engine/shared/json.ts +18 -1
  113. package/.bkit/core/engine/shared/package-json.ts +63 -0
  114. package/.bkit/core/engine/shared/package-roots.ts +0 -10
  115. package/.bkit/core/engine/shared/protected-paths.ts +5 -130
  116. package/.bkit/core/engine/shared/settings.ts +36 -0
  117. package/.bkit/core/engine/shared/timeouts.ts +6 -0
  118. package/.bkit/core/hooks/antigravity-hook.js +1 -0
  119. package/.bkit/core/hooks/guardrails-shell.js +186 -40
  120. package/.bkit/core/hooks/guardrails-tiers.js +5 -78
  121. package/.bkit/core/prompts/bkit-audit-generate.md +65 -10
  122. package/.bkit/core/prompts/bkit-build-challenge-1.md +1 -1
  123. package/.bkit/core/prompts/bkit-build-challenge-2.md +1 -1
  124. package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +1 -1
  125. package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -1
  126. package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -1
  127. package/.bkit/core/prompts/bkit-build-install-skills.md +1 -1
  128. package/.bkit/core/prompts/bkit-build-plan-current.md +1 -1
  129. package/.bkit/core/prompts/bkit-build-plan-execute.md +4 -4
  130. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
  131. package/.bkit/core/prompts/bkit-build-plan-verify.md +2 -2
  132. package/.bkit/core/prompts/bkit-debug-abort-handover.md +1 -1
  133. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +1 -1
  134. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
  135. package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +78 -0
  136. package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
  137. package/.bkit/core/prompts/bkit-debug-summary.md +3 -3
  138. package/.bkit/core/prompts/bkit-design-spike.md +1 -1
  139. package/.bkit/core/prompts/bkit-design-summary.md +2 -2
  140. package/.bkit/core/prompts/bkit-design-update.md +1 -1
  141. package/.bkit/core/prompts/bkit-plan-complexity-check.md +1 -1
  142. package/.bkit/core/prompts/bkit-plan-generate.md +1 -1
  143. package/.bkit/core/prompts/bkit-plan-scope-check-1.md +1 -1
  144. package/.bkit/core/prompts/bkit-plan-scope-check-2.md +1 -1
  145. package/.bkit/core/prompts/bkit-plan-summary.md +1 -1
  146. package/.bkit/core/prompts/bkit-plan-update.md +1 -1
  147. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
  148. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +1 -1
  149. package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
  150. package/.bkit/core/prompts/bkit-utility-update-decisions.md +9 -2
  151. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +9 -2
  152. package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
  153. package/.bkit/core/prompts/bkit-utility-update-failures.md +9 -2
  154. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +9 -2
  155. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +11 -4
  156. package/.bkit/core/workflows/bkit-build.md +4 -4
  157. package/.bkit/core/workflows/bkit-debug.md +70 -34
  158. package/.bkit/core/workflows/bkit-design.md +3 -3
  159. package/.bkit/core/workflows/bkit-plan.md +12 -5
  160. package/.bkit/core/workflows/bkit-ship.md +6 -6
  161. package/.bkit/shared/.claude/bkit-cloud.md +46 -13
  162. package/.bkit/shared/.claude/settings.json +18 -0
  163. package/.bkit/shared/.cursor/mcp.json +2 -1
  164. package/.bkit/shared/.opencode/opencode.json +19 -1
  165. package/.bkit/shared/docs/deployments.md +20 -4
  166. package/.bkit/shared/docs/security.md +8 -6
  167. package/.bkit/shared/docs/testing.md +9 -5
  168. package/.bkit/templates/.cursor/Dockerfile +30 -16
  169. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +78 -0
  170. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +91 -0
  171. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +56 -0
  172. package/.bkit/templates/.github/renovate.json5 +91 -12
  173. package/.bkit/templates/.github/workflows/bkit-ci.yml +66 -53
  174. package/.bkit/templates/.github/workflows/bkit-cloud.yml +3 -1
  175. package/.bkit/templates/.github/workflows/bkit-renovate.yml +8 -1
  176. package/.bkit/templates/.github/workflows/bkit-trivy.yml +67 -0
  177. package/.bkit/templates/.husky/pre-push +15 -3
  178. package/.bkit/templates/.oxlintrc.json +21 -0
  179. package/.bkit/templates/docs/capabilities.md +1 -1
  180. package/.bkit/templates/scripts/ci/check-capstone.mjs +176 -0
  181. package/.bkit/templates/scripts/ci/check-capstone.test.mjs +311 -0
  182. package/.bkit/templates/scripts/cleanup/bkit-tmp-prune.mjs +115 -0
  183. package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +2 -2
  184. package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +43 -20
  185. package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +33 -11
  186. package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -2
  187. package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +5 -5
  188. package/.bkit/templates/scripts/graphify/bkit-graphify.sh +79 -19
  189. package/CHANGELOG.md +67 -3
  190. package/README.md +258 -129
  191. package/dist/checks/after/auth.js +10 -11
  192. package/dist/checks/after/ci-yml.js +11 -14
  193. package/dist/checks/after/github.js +32 -125
  194. package/dist/checks/after/index.js +3 -2
  195. package/dist/checks/after/managed.js +8 -24
  196. package/dist/checks/after/tools.js +3 -16
  197. package/dist/checks/before/context-fetch.js +1 -21
  198. package/dist/checks/before/index.js +6 -42
  199. package/dist/checks/before/mcp.js +14 -9
  200. package/dist/checks/before/repo.js +8 -11
  201. package/dist/checks/status-holes.js +5 -6
  202. package/dist/checks/tips/catalogue.js +60 -18
  203. package/dist/checks/tips/detect.js +41 -2
  204. package/dist/checks/tips/index.js +25 -5
  205. package/dist/cli.js +34 -14
  206. package/dist/commands/analysis.js +21 -5
  207. package/dist/commands/comply.js +20 -18
  208. package/dist/commands/harvest.js +12 -13
  209. package/dist/commands/install/doctor.js +55 -23
  210. package/dist/commands/install/install.js +62 -118
  211. package/dist/commands/install/uninstall.js +165 -31
  212. package/dist/commands/install/upgrade.js +55 -49
  213. package/dist/commands/lib.js +32 -10
  214. package/dist/commands/tips.js +6 -3
  215. package/dist/commands/workflow/branches.js +57 -13
  216. package/dist/commands/workflow/counters.js +17 -7
  217. package/dist/commands/workflow/fids.js +39 -0
  218. package/dist/commands/workflow/ledgers.js +3 -1
  219. package/dist/commands/workflow/prs.js +3 -3
  220. package/dist/commands/workflow/repo.js +16 -4
  221. package/dist/commands/workflow/roadmap.js +4 -4
  222. package/dist/commands/workflow/runs.js +5 -5
  223. package/dist/commands/workflow/steps.js +1 -0
  224. package/dist/commands/workflow/tests.js +16 -3
  225. package/dist/commands/workflow/workflows.js +19 -18
  226. package/dist/commands/workflow/workstreams.js +2 -1
  227. package/dist/commands/workflow/worktrees.js +4 -5
  228. package/dist/install/cloud-env.js +10 -23
  229. package/dist/install/manifest.js +14 -7
  230. package/dist/install/modules/antigravity.js +15 -26
  231. package/dist/install/modules/claude.js +17 -21
  232. package/dist/install/modules/cloud.js +6 -2
  233. package/dist/install/modules/codex.js +15 -29
  234. package/dist/install/modules/core.js +82 -63
  235. package/dist/install/modules/cursor.js +6 -9
  236. package/dist/install/modules/index.js +6 -1
  237. package/dist/install/modules/opencode.js +41 -72
  238. package/dist/install/network-allowlist.js +62 -0
  239. package/dist/install/placeholders.js +3 -16
  240. package/dist/install/write.js +55 -15
  241. package/dist/ledgers/telemetry.js +5 -4
  242. package/dist/render/hosts.js +30 -55
  243. package/dist/render/models.js +20 -9
  244. package/dist/shared/bkit-latest.js +150 -0
  245. package/dist/shared/branches.js +11 -0
  246. package/dist/shared/egress.js +0 -2
  247. package/dist/shared/json.js +14 -0
  248. package/dist/shared/package-json.js +61 -0
  249. package/dist/shared/package-roots.js +0 -8
  250. package/dist/shared/protected-paths.js +5 -122
  251. package/dist/shared/settings.js +18 -1
  252. package/dist/shared/timeouts.js +6 -0
  253. package/package.json +21 -17
  254. package/.bkit/core/.agents/shortcuts.md +0 -73
@@ -11,12 +11,15 @@ import {
11
11
  hashFile,
12
12
  mergeCanonicalHashes,
13
13
  } from "../version-file.js";
14
+ import { extractManagedBlock, stripManagedBlock } from "../managed-block.js";
14
15
  import type { TokenMap } from "../placeholders.js";
15
16
  import { listFilesRecursive, syncTemplateCopies } from "../template-copies.js";
16
17
  import { PAYLOAD_LINK_RELPATHS, syncPayloadLinks } from "../payload-links.js";
18
+ import { writeNetworkAllowlist } from "../network-allowlist.js";
17
19
  import type { PreflightFinding } from "../../checks/before/index.js";
20
+ import { readJsonFile } from "../../shared/json.js";
21
+ import { readInstallingVersion } from "../../shared/package-json.js";
18
22
  import {
19
- getPkgRoot,
20
23
  getCoreRoot,
21
24
  getSharedRoot,
22
25
  getBkitDocsRoot,
@@ -71,25 +74,46 @@ const ORPHAN_PRUNE_DIRS = [
71
74
  ".claude/commands",
72
75
  ".cursor/agents",
73
76
  ".cursor/commands",
77
+ ".opencode/agents",
78
+ ".opencode/commands",
79
+ ".codex/agents",
80
+ ".agents/skills",
81
+ ".agents/plugins/bkit/agents",
82
+ ".agents/plugins/bkit/skills",
74
83
  ] as const;
75
84
 
85
+ export interface RemoveOrphansOptions {
86
+ /** Entry-name suffix an orphan must carry. Default `.md`; `""` matches every name. */
87
+ extension?: string;
88
+ /** Orphans are whole folders (skill dirs) removed recursively; `extension` is ignored. */
89
+ wholeFolders?: boolean;
90
+ }
91
+
92
+ /**
93
+ * Removes entries of `destDir` that start with `prefix` and are absent from `sourceNames`
94
+ * (entry names as they appear in `destDir`). Returns the removed names; with `dryRun` it
95
+ * reports them without deleting. Throws for any `destDir` outside `ORPHAN_PRUNE_DIRS`.
96
+ */
76
97
  export function removeOrphans(
77
98
  destDir: string,
78
- sourceFiles: Set<string>,
99
+ sourceNames: Set<string>,
79
100
  dryRun: boolean,
80
101
  prefix?: string,
102
+ options: RemoveOrphansOptions = {},
81
103
  ): string[] {
82
104
  const resolved = path.resolve(destDir);
83
105
  if (!ORPHAN_PRUNE_DIRS.some((d) => path.resolve(d) === resolved)) {
84
106
  throw new Error(`removeOrphans: refusing orphan removal outside allowlist: ${destDir}`);
85
107
  }
86
108
  if (!fs.existsSync(destDir)) return [];
109
+ const { extension = ".md", wholeFolders = false } = options;
87
110
  const removed: string[] = [];
88
111
  for (const f of fs.readdirSync(destDir)) {
89
- if (!f.endsWith(".md")) continue;
112
+ if (!wholeFolders && !f.endsWith(extension)) continue;
90
113
  if (prefix && !f.startsWith(prefix)) continue;
91
- if (!sourceFiles.has(f)) {
92
- if (!dryRun) fs.rmSync(path.join(destDir, f));
114
+ if (!sourceNames.has(f)) {
115
+ const target = path.join(destDir, f);
116
+ if (!dryRun) fs.rmSync(target, { recursive: wholeFolders, force: wholeFolders });
93
117
  removed.push(f);
94
118
  }
95
119
  }
@@ -117,13 +141,7 @@ interface CoreTemplateFile {
117
141
  }
118
142
 
119
143
  /** The markered-text `.agents/*.md` blocks core owns. */
120
- const CORE_AGENT_FILES = [
121
- "context.md",
122
- "docs.md",
123
- "rules.md",
124
- "shortcuts.md",
125
- "skills.md",
126
- ] as const;
144
+ const CORE_AGENT_FILES = ["context.md", "docs.md", "rules.md", "skills.md"] as const;
127
145
 
128
146
  // The two shared-root files core writes: stored in `shared/`, owned by the core
129
147
  // manifest, written as html-comment managed blocks.
@@ -228,16 +246,18 @@ function runCoreTemplates(
228
246
  // mirrored into the consumer's `.bkit/` on every install so a consumer can read them
229
247
  // in-repo without spelunking node_modules. Force-overwritten (Tier 1) — bkit owns
230
248
  // them, so a consumer edit is replaced. Source of truth is the package's own
231
- // `.bkit/core/.bkit/<name>`. (`advisories.md` is a regenerated runtime artifact,
232
- // `wording.md` is repo-only tooling and `friction.md` is a consumer-owned seed —
233
- // none belongs here. `LICENSE.md` is the MIT notice that travels with the files bkit
234
- // writes: MIT requires the copyright and permission notice in every copy.)
249
+ // `.bkit/core/.bkit/<name>`. (`advisories.md` is a regenerated runtime artifact and
250
+ // `wording.md` is repo-only tooling — neither belongs here. `LICENSE.md` is the MIT
251
+ // notice that travels with the files bkit writes: MIT requires the copyright and
252
+ // permission notice in every copy.)
235
253
  export const BKIT_CANONICAL_DOCS = [
236
254
  "cloud.md",
237
255
  "comparison.md",
238
256
  "install.md",
239
257
  "jsonl.md",
240
258
  "LICENSE.md",
259
+ "lite.md",
260
+ "pipeline.md",
241
261
  "providers.md",
242
262
  "prompts.md",
243
263
  "templates.md",
@@ -278,6 +298,44 @@ export function runBkitDocs(
278
298
  console.log(`${logPrefix} ${tag}core: ${dstPath}`);
279
299
  }
280
300
  }
301
+ migrateShortcutsToLite(dryRun, ws, logPrefix);
302
+ }
303
+
304
+ // Migration (5.1.0 – 5.2.4 installs, `docs/migrations.md`): the lite workflows lived at
305
+ // `.agents/shortcuts.md`. The consumer's own lines below `bkit:end` (minus the seeded
306
+ // heading) move under `.bkit/lite.md`'s consumer section; the old file is deleted. Runs
307
+ // after the docs loop, so `.bkit/lite.md` is already written. The delete is recorded in
308
+ // ws (as orphan-mirror deletes are) so `bkit check` fails until upgrade runs.
309
+ const RETIRED_SHORTCUTS = path.join(".agents", "shortcuts.md");
310
+ const RETIRED_SHORTCUTS_HEADING = "## Project Shortcuts";
311
+
312
+ export function migrateShortcutsToLite(dryRun: boolean, ws: WriteSet, logPrefix: string): void {
313
+ if (!fs.existsSync(RETIRED_SHORTCUTS)) return;
314
+ if (!fs.existsSync(path.join(getBkitDocsRoot(), "lite.md"))) return;
315
+ const tag = dryRun ? "[dry-run] " : "";
316
+ const dst = path.join(".bkit", "lite.md");
317
+ const old = fs.readFileSync(RETIRED_SHORTCUTS, "utf-8");
318
+ if (extractManagedBlock(old, "html-comment") === null) {
319
+ console.warn(
320
+ `${logPrefix} ${RETIRED_SHORTCUTS} has no single bkit managed block — left in place. Move your own lines into ${dst} below \`<!-- bkit:end -->\`, then delete it.`,
321
+ );
322
+ return;
323
+ }
324
+ const own = stripManagedBlock(old, "html-comment")
325
+ .split("\n")
326
+ .filter((line) => line.trim() !== RETIRED_SHORTCUTS_HEADING)
327
+ .join("\n")
328
+ .trim();
329
+ if (own.length > 0) {
330
+ if (!dryRun) {
331
+ const current = fs.readFileSync(dst, "utf-8");
332
+ fs.writeFileSync(dst, `${current.replace(/\n*$/, "\n\n")}${own}\n`, "utf-8");
333
+ }
334
+ ws.writes.push({ path: dst, action: "update" });
335
+ }
336
+ if (!dryRun) fs.rmSync(RETIRED_SHORTCUTS);
337
+ ws.writes.push({ path: RETIRED_SHORTCUTS, action: "write" });
338
+ console.log(`${logPrefix} ${tag}core: moved ${RETIRED_SHORTCUTS} → ${dst}`);
281
339
  }
282
340
 
283
341
  // ---------------------------------------------------------------------------
@@ -292,29 +350,6 @@ export function runBkitDocs(
292
350
  // the consumer-relative dest paths it wrote (for the upgrade summary).
293
351
  // ---------------------------------------------------------------------------
294
352
 
295
- // ---------------------------------------------------------------------------
296
- // Managed-version stamping. The marker shape (stampManagedVersion + regexes) lives
297
- // in install/version-file.ts, shared by the renderer and the `bkit check` detector. Here we
298
- // only resolve WHICH version to stamp: ctx.version (set by install/upgrade) with a
299
- // package-root fallback.
300
- // ---------------------------------------------------------------------------
301
-
302
- /**
303
- * Best-effort read of the installing bkit version from the package root's
304
- * package.json. Mirrors getInstallingVersion in commands/install/install.ts; duplicated here
305
- * (not imported) to avoid a modules → install dependency cycle. Returns "0.0.0"
306
- * when unreadable — the same non-fatal fallback the install side uses.
307
- */
308
- export function readInstallingVersion(): string {
309
- try {
310
- const pkgPath = path.join(getPkgRoot(), "package.json");
311
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8")) as { version?: string };
312
- return pkg.version ?? "0.0.0";
313
- } catch {
314
- return "0.0.0";
315
- }
316
- }
317
-
318
353
  /** Record a host mirror would-write so `bkit check` exits 1 on content drift. */
319
354
  export function trackMirrorWrite(ctx: ModuleContext, relPath: string, written: string[]): void {
320
355
  written.push(relPath);
@@ -368,17 +403,12 @@ const PNPM_NOT_A_SCRIPT = new Set([
368
403
  * package.json yields none.
369
404
  */
370
405
  export function detectGateAdvisories(cwd: string): PreflightFinding[] {
371
- let declared: Record<string, string>;
372
- try {
373
- const pkg = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf-8")) as {
374
- scripts?: Record<string, string>;
375
- };
376
- declared = { ...BKIT_GATE_SCRIPTS, ...pkg.scripts };
377
- } catch {
378
- // Absent or malformed package.json — preflight's no-package-json /
379
- // malformed-package-json blockers already report it.
380
- return [];
381
- }
406
+ const read = readJsonFile(path.join(cwd, "package.json"));
407
+ // Absent or malformed package.json — preflight's no-package-json /
408
+ // malformed-package-json blockers already report it.
409
+ if (!read.ok || read.value === null) return [];
410
+ const pkg = read.value as { scripts?: Record<string, string> };
411
+ const declared: Record<string, string> = { ...BKIT_GATE_SCRIPTS, ...pkg.scripts };
382
412
  const findings: PreflightFinding[] = [];
383
413
 
384
414
  // Every script a seeded gate default chains MUST exist, or the gate dies on the first
@@ -454,16 +484,11 @@ export function isNoopScript(value: string): boolean {
454
484
  * every branch. Read-only; an absent or unparseable package.json yields none.
455
485
  */
456
486
  export function detectNoopGates(cwd: string): PreflightFinding[] {
457
- let declared: Record<string, unknown>;
458
- try {
459
- const pkg = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf-8")) as {
460
- scripts?: Record<string, unknown>;
461
- };
462
- declared = pkg.scripts ?? {};
463
- } catch {
464
- // Absent or malformed package.json — preflight's blockers already report it.
465
- return [];
466
- }
487
+ const read = readJsonFile(path.join(cwd, "package.json"));
488
+ // Absent or malformed package.json — preflight's blockers already report it.
489
+ if (!read.ok || read.value === null) return [];
490
+ const pkg = read.value as { scripts?: Record<string, unknown> };
491
+ const declared: Record<string, unknown> = pkg.scripts ?? {};
467
492
  const noop = Object.entries(declared)
468
493
  .filter(([name, value]) => name.startsWith("bkit:gate:") && typeof value === "string")
469
494
  .filter(([, value]) => isNoopScript(value as string))
@@ -485,15 +510,7 @@ export function runCoreModule(ctx: ModuleContext): void {
485
510
  const { dryRun, ws, advisories, logPrefix, postDispatch } = ctx;
486
511
  const tag = dryRun ? "[dry-run] " : "";
487
512
  const cwd = process.cwd();
488
- const PKG_ROOT = getPkgRoot();
489
- const PKG_PACKAGE_JSON = path.join(PKG_ROOT, "package.json");
490
-
491
- if (!fs.existsSync(PKG_PACKAGE_JSON)) {
492
- console.error(`${logPrefix} package.json not found at ${PKG_PACKAGE_JSON} — package corrupt?`);
493
- process.exit(1);
494
- }
495
-
496
- const pkgVersion = JSON.parse(fs.readFileSync(PKG_PACKAGE_JSON, "utf-8")).version as string;
513
+ const pkgVersion = readInstallingVersion();
497
514
 
498
515
  // Capture first-install signal NOW (before any writes) — used for the post-install banner.
499
516
  // The .bkit/version write happens in postDispatch, so a mid-install crash in a later
@@ -507,7 +524,7 @@ export function runCoreModule(ctx: ModuleContext): void {
507
524
  runCoreTemplates(dryRun, ctx.tokens, ws, logPrefix);
508
525
 
509
526
  // 3b. bkit canonical docs pass — mirror the package's reference docs
510
- // (cloud/IDEs/prompts/trackers/workflows/README/install/comparison) into the
527
+ // (cloud/IDEs/prompts/trackers/workflows/README/install/comparison/pipeline) into the
511
528
  // consumer's `.bkit/` so they are readable in-repo. Force-overwrite (Tier 1).
512
529
  console.log(`${logPrefix} ${tag}Running bkit docs pass`);
513
530
  runBkitDocs(dryRun, ctx.tokens, ws, logPrefix);
@@ -550,6 +567,10 @@ export function runCoreModule(ctx: ModuleContext): void {
550
567
  });
551
568
  }
552
569
 
570
+ // 3b4. `.bkit/allowlist.json` — the network allowlist every host's guardrails hook
571
+ // reads (writeNetworkAllowlist), plus the move off the retired `.cursor/` copy.
572
+ writeNetworkAllowlist(cwd, dryRun, ws, logPrefix);
573
+
553
574
  // 3c. The bkit:gate:* / bkit:deps:* package.json scripts (add-if-missing). The
554
575
  // advisories read the result.
555
576
  seedCorePackageJsonScripts(ctx);
@@ -13,20 +13,10 @@ import {
13
13
  } from "../../shared/package-roots.js";
14
14
  import { DEFAULT_ISSUE_TRACKER } from "../manifest.js";
15
15
  import { substituteWorkflow } from "../../render/trackers.js";
16
- import {
17
- writeCursorCloudDoc,
18
- writeNetworkAllowlistArtifact,
19
- writeCursorCliPermissionsArtifact,
20
- } from "../cloud-env.js";
16
+ import { writeCursorCloudDoc, writeCursorCliPermissionsArtifact } from "../cloud-env.js";
17
+ import { readInstallingVersion } from "../../shared/package-json.js";
21
18
  import type { ModuleContext } from "./index.js";
22
- import {
23
- BKIT_PREFIX,
24
- installFile,
25
- listMdFiles,
26
- readInstallingVersion,
27
- removeOrphans,
28
- trackMirrorWrite,
29
- } from "./core.js";
19
+ import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
30
20
  import { reconcileMcpJson } from "./claude.js";
31
21
 
32
22
  export function renderCursorAgentsCommands(ctx: ModuleContext): string[] {
@@ -182,15 +172,11 @@ export function runCursorModule(ctx: ModuleContext): void {
182
172
  }
183
173
  }
184
174
 
185
- // Cursor-only runtime curl/wget allowlist (bkit-guardrails.cjs reads `.cursor/allowlist.json`).
186
- // Same domain set as Claude WebFetch / OpenCode bash allows — sourced from tooling
187
- // defaults ∪ consumer `allowed-domains`. Not under `.bkit/` (IDE-scoped artifact).
188
175
  // Cursor CLI / cloud-agent MCP allows (`.cursor/cli.json`) from consumer `mcp-servers` —
189
176
  // same server set as Claude `mcp__…` allows / OpenCode `<server>_*` permission rows.
190
- for (const art of [
191
- writeNetworkAllowlistArtifact(process.cwd(), dryRun),
192
- writeCursorCliPermissionsArtifact(process.cwd(), dryRun),
193
- ]) {
177
+ // The curl/wget allowlist the guardrails hook reads is core's `.bkit/allowlist.json`.
178
+ {
179
+ const art = writeCursorCliPermissionsArtifact(process.cwd(), dryRun);
194
180
  if (art.wrote) {
195
181
  ws.writes.push({ path: art.path, action: "write" });
196
182
  console.log(`${logPrefix} ${tag}cursor: ${art.path}`);
@@ -14,6 +14,7 @@ import type { EffortMap } from "../../render/models.js";
14
14
  import type { PreflightFinding } from "../../checks/before/index.js";
15
15
  import { getCoreRoot, getSharedRoot } from "../../shared/package-roots.js";
16
16
  import { getInstallManifest, type IssueTracker } from "../manifest.js";
17
+ import { writeNetworkAllowlist } from "../network-allowlist.js";
17
18
  import {
18
19
  BKIT_PREFIX,
19
20
  listCoreTemplateFiles,
@@ -115,7 +116,8 @@ export type ModuleFn = (ctx: ModuleContext) => void;
115
116
  // renderManagedOutputs — re-render the bkit-managed OUTPUT files that the
116
117
  // `bkit upgrade` payload walk does NOT cover:
117
118
  // host agents/commands (source-rendered), the `.bkit/*.md` canonical docs
118
- // (runBkitDocs) and core's package.json scripts (seedCorePackageJsonScripts).
119
+ // (runBkitDocs), `.bkit/allowlist.json` (writeNetworkAllowlist) and core's
120
+ // package.json scripts (seedCorePackageJsonScripts).
119
121
  // `.bkit/prompts.md` is markered → runBkitDocs block-merges it (managed block
120
122
  // refreshed, consumer `## Model Overrides` below bkit:end preserved).
121
123
  //
@@ -140,6 +142,10 @@ export function renderManagedOutputs(modules: Set<ModuleFlag>, ctx: ModuleContex
140
142
  written.push(String(ctx.ws.writes[i].path));
141
143
  }
142
144
 
145
+ // `.bkit/allowlist.json` — the same pass install's core module runs (writeNetworkAllowlist
146
+ // records into ctx.ws, so the caller refreshes its canonicalHashes).
147
+ written.push(...writeNetworkAllowlist(process.cwd(), ctx.dryRun, ctx.ws, ctx.logPrefix));
148
+
143
149
  // Core package.json scripts — the same pass install runs, so `bkit check` after a
144
150
  // clean upgrade finds no missing gate name and no superseded script value.
145
151
  written.push(...seedCorePackageJsonScripts(ctx));
@@ -3,7 +3,15 @@
3
3
 
4
4
  import * as fs from "node:fs";
5
5
  import * as path from "node:path";
6
- import { writeTier2, deepMergeJson, ensureDir, type WriteSet, type JsonValue } from "../write.js";
6
+ import {
7
+ writeTier2,
8
+ deepMergeJson,
9
+ ensureDir,
10
+ isJsonObject,
11
+ mergeTrackerEntry,
12
+ type WriteSet,
13
+ type JsonValue,
14
+ } from "../write.js";
7
15
  import { stampManagedVersion } from "../version-file.js";
8
16
  import { applyOpencodeAgent, applyOpencodeCommand } from "../../render/hosts.js";
9
17
  import type { PreflightFinding } from "../../checks/before/index.js";
@@ -17,15 +25,12 @@ import { type IssueTracker, DEFAULT_ISSUE_TRACKER } from "../manifest.js";
17
25
  import { substituteWorkflow } from "../../render/trackers.js";
18
26
  import { resolveNetworkAllowlist, extractMcpServers, networkAllowlistBases } from "../cloud-env.js";
19
27
  import { OPENCODE_PROVIDER_DEFAULTS } from "../../shared/egress.js";
28
+ import { parseJson, readJsonFile } from "../../shared/json.js";
29
+ import { readBkitConfig } from "../../shared/settings.js";
30
+ import { readInstallingVersion } from "../../shared/package-json.js";
20
31
  import type { ModuleContext } from "./index.js";
21
- import {
22
- BKIT_PREFIX,
23
- installFile,
24
- listMdFiles,
25
- readInstallingVersion,
26
- trackMirrorWrite,
27
- } from "./core.js";
28
- import { opencodeProviderId } from "../../render/models.js";
32
+ import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
33
+ import { isOpencodeProvider, opencodeProviderId } from "../../render/models.js";
29
34
 
30
35
  export function renderOpencodeAgentsCommands(ctx: ModuleContext): string[] {
31
36
  const { dryRun, opencodeModelLookup, effortMap, opencodeProvider, logPrefix } = ctx;
@@ -68,20 +73,11 @@ export function renderOpencodeAgentsCommands(ctx: ModuleContext): string[] {
68
73
  }
69
74
  }
70
75
 
71
- // Remove orphan agent files (bkit-prefix only, no allowlist gate needed — .opencode/agents
72
- // is a dynamic mirror dir like .claude/agents and .cursor/agents). dryRun still reports
73
- // would-deletes into ws.writes so `bkit check` fails on stale mirrors.
74
- if (fs.existsSync(dest)) {
75
- for (const f of fs.readdirSync(dest)) {
76
- if (!f.endsWith(".md")) continue;
77
- if (!f.startsWith(BKIT_PREFIX)) continue;
78
- if (!sourceSet.has(f)) {
79
- const rel = path.join(dest, f);
80
- if (!dryRun) fs.rmSync(path.join(dest, f));
81
- console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
82
- trackMirrorWrite(ctx, rel, written);
83
- }
84
- }
76
+ // dryRun still reports would-deletes into ws.writes so `bkit check` fails on stale mirrors.
77
+ for (const f of removeOrphans(dest, sourceSet, dryRun, BKIT_PREFIX)) {
78
+ const rel = path.join(dest, f);
79
+ console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
80
+ trackMirrorWrite(ctx, rel, written);
85
81
  }
86
82
  }
87
83
 
@@ -107,17 +103,10 @@ export function renderOpencodeAgentsCommands(ctx: ModuleContext): string[] {
107
103
  }
108
104
  }
109
105
 
110
- if (fs.existsSync(dest)) {
111
- for (const f of fs.readdirSync(dest)) {
112
- if (!f.endsWith(".md")) continue;
113
- if (!f.startsWith(BKIT_PREFIX)) continue;
114
- if (!sourceSet.has(f)) {
115
- const rel = path.join(dest, f);
116
- if (!dryRun) fs.rmSync(path.join(dest, f));
117
- console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
118
- trackMirrorWrite(ctx, rel, written);
119
- }
120
- }
106
+ for (const f of removeOrphans(dest, sourceSet, dryRun, BKIT_PREFIX)) {
107
+ const rel = path.join(dest, f);
108
+ console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
109
+ trackMirrorWrite(ctx, rel, written);
121
110
  }
122
111
  }
123
112
  return written;
@@ -146,7 +135,7 @@ export function renderOpencodeAgentsCommands(ctx: ModuleContext): string[] {
146
135
  * secret against the installed provider.
147
136
  */
148
137
  export function opencodeProviderEnvVar(providerKey: string): string {
149
- return OPENCODE_PROVIDER_DEFAULTS[providerKey]?.envVar ?? "";
138
+ return isOpencodeProvider(providerKey) ? OPENCODE_PROVIDER_DEFAULTS[providerKey].envVar : "";
150
139
  }
151
140
 
152
141
  /**
@@ -170,19 +159,8 @@ export function detectOpencodeYmlProviderDrift(cwd: string): PreflightFinding |
170
159
  if (!fs.existsSync(ymlPath)) return null;
171
160
 
172
161
  // The installed provider — package.json `bkit.opencodeProvider` is the authoritative record
173
- // written on install. Absent/broken → the null-guard below skips silently.
174
- let provider: string | null = null;
175
- const pkgPath = path.join(cwd, "package.json");
176
- if (fs.existsSync(pkgPath)) {
177
- try {
178
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8")) as {
179
- bkit?: { opencodeProvider?: unknown };
180
- };
181
- if (typeof pkg.bkit?.opencodeProvider === "string") provider = pkg.bkit.opencodeProvider;
182
- } catch {
183
- // Malformed package.json — leave provider null; a JSON-drift advisory covers that separately.
184
- }
185
- }
162
+ // written on install. Absent/broken/unsupported → the null-guard below skips silently.
163
+ const provider = readBkitConfig(cwd).opencodeProvider;
186
164
  if (!provider) return null;
187
165
 
188
166
  const expectedPrefix = opencodeProviderId(provider); // model id form is `<providerId>/<model>`
@@ -266,10 +244,10 @@ export function renderOpencodeJson(
266
244
  const raw = fs.readFileSync(templatePath, "utf-8");
267
245
  // Strict allowlist: provider is gated to OPENCODE_PROVIDERS at the CLI, so it is always
268
246
  // a known key here. An unknown id throws; no substitute provider.
269
- const providerDefaults = OPENCODE_PROVIDER_DEFAULTS[provider];
270
- if (!providerDefaults) {
247
+ if (!isOpencodeProvider(provider)) {
271
248
  throw new Error(`renderOpencodeJson: unknown opencode provider ${JSON.stringify(provider)}`);
272
249
  }
250
+ const providerDefaults = OPENCODE_PROVIDER_DEFAULTS[provider];
273
251
 
274
252
  // Resolve tracker MCP entry
275
253
  // opencode's MCP schema differs from Claude/Cursor: remote servers use type "remote"
@@ -282,7 +260,7 @@ export function renderOpencodeJson(
282
260
  let mcpEntry: string;
283
261
  if (tracker === "github") {
284
262
  mcpEntry =
285
- '"github": { "type": "remote", "url": "https://api.githubcopilot.com/mcp/", "oauth": false, "headers": { "Authorization": "Bearer {env:BKIT_GH_TOKEN}", "X-MCP-Toolsets": "context,issues,pull_requests,repos,users,projects" } }';
263
+ '"github": { "type": "remote", "url": "https://api.githubcopilot.com/mcp/", "oauth": false, "headers": { "Authorization": "Bearer {env:BKIT_GH_TOKEN}", "X-MCP-Toolsets": "context,issues,pull_requests,repos,users,projects,actions" } }';
286
264
  } else if (tracker === "linear") {
287
265
  mcpEntry = '"linear": { "type": "remote", "url": "https://mcp.linear.app/mcp" }';
288
266
  } else {
@@ -296,7 +274,9 @@ export function renderOpencodeJson(
296
274
 
297
275
  // Parse + re-serialize to normalise JSON (removes empty mcp entry if tracker=none)
298
276
  try {
299
- const parsed = JSON.parse(rendered) as Record<string, unknown>;
277
+ const renderedDoc = parseJson(rendered);
278
+ if (!renderedDoc.ok) return rendered;
279
+ const parsed = renderedDoc.value as Record<string, unknown>;
300
280
  // Clean up empty mcp object when tracker=none
301
281
  const mcp = parsed.mcp as Record<string, unknown> | undefined;
302
282
  if (mcp && Object.keys(mcp).length === 0) {
@@ -402,15 +382,9 @@ export function reconcileOpencodeJson(
402
382
  return;
403
383
  }
404
384
 
405
- // Parse into a sentinel and validate AFTER the catch — keeping the throw out of the catch
406
- // body (matches the codebase's parse-or-sentinel idiom; a throw inside catch obscures the
407
- // original error). Malformed consumer JSON is a hard stop: refuse to merge, require a fix.
408
- let existing: Record<string, JsonValue> | null = null;
409
- try {
410
- existing = JSON.parse(fs.readFileSync(relDst, "utf-8")) as Record<string, JsonValue>;
411
- } catch {
412
- existing = null;
413
- }
385
+ // Malformed consumer JSON is a hard stop: refuse to merge, require a fix.
386
+ const read = readJsonFile(relDst);
387
+ const existing = read.ok ? (read.value as Record<string, JsonValue> | null) : null;
414
388
  if (existing === null) {
415
389
  throw new Error(
416
390
  `[bkit] ${relDst} is malformed JSON — fix manually before running bkit install`,
@@ -421,6 +395,15 @@ export function reconcileOpencodeJson(
421
395
  string,
422
396
  JsonValue
423
397
  >;
398
+ // The tracker `mcp` entry keeps the consumer's extra toolsets (`mergeTrackerEntry`), which
399
+ // the plain merge above would overwrite with the template's list.
400
+ const tmplMcp = template.mcp;
401
+ const existingMcp = existing.mcp;
402
+ if (isJsonObject(tmplMcp) && isJsonObject(existingMcp) && isJsonObject(merged.mcp)) {
403
+ for (const [k, v] of Object.entries(tmplMcp)) {
404
+ merged.mcp[k] = mergeTrackerEntry(existingMcp[k], v);
405
+ }
406
+ }
424
407
  // Replace (do not deep-merge) each provider key the template seeds — heals hijacked
425
408
  // npm/baseURL/name while keeping other provider keys additive.
426
409
  //
@@ -473,13 +456,8 @@ export function removeOpencodeProviderBlock(
473
456
  ws: WriteSet,
474
457
  ): void {
475
458
  if (!fs.existsSync(dst)) return;
476
- // Parse-or-sentinel idiom: keep the early-return outside the catch body.
477
- let existing: Record<string, JsonValue> | null = null;
478
- try {
479
- existing = JSON.parse(fs.readFileSync(dst, "utf-8")) as Record<string, JsonValue>;
480
- } catch {
481
- existing = null;
482
- }
459
+ const read = readJsonFile(dst);
460
+ const existing = read.ok ? (read.value as Record<string, JsonValue> | null) : null;
483
461
  if (existing === null) {
484
462
  console.warn(`[bkit] ${dst} is malformed — leaving as-is`);
485
463
  return;
@@ -558,7 +536,7 @@ export function runOpencodeModule(ctx: ModuleContext): void {
558
536
  action:
559
537
  `opencode setup for provider "${provider}":\n\n` +
560
538
  (() => {
561
- const pd = OPENCODE_PROVIDER_DEFAULTS[provider];
539
+ const pd = isOpencodeProvider(provider) ? OPENCODE_PROVIDER_DEFAULTS[provider] : undefined;
562
540
  if (!pd) {
563
541
  return (
564
542
  ` 1. Set ${provider.toUpperCase()}_API_KEY in your environment / .bkit/.env.\n` +
@@ -588,7 +566,7 @@ export function runOpencodeModule(ctx: ModuleContext): void {
588
566
  ` env — {env:KEY} placeholders in opencode.json resolve empty without this. Quit the\n` +
589
567
  ` running app first (a running instance ignores the new env).\n` +
590
568
  ` 4. Model IDs: all four providers (openrouter, ollama, opencode-zen, opencode-go) install ready-to-run curated per-agent pins. ` +
591
- `Re-pin any agent via .bkit/prompts.md § Model Overrides or by probing the provider's live /v1/models — see .bkit/providers.md § Models. NOTE: ollama opus/convergent pins (kimi-k2.7-code, deepseek-v4-pro) need a paid Ollama plan; its sonnet/haiku pins run on the free tier. opencode-go pins (minimax-m3, qwen3.7-plus, deepseek-v4-pro/-flash) — prefer pins that stay within the Go 5h usage window; opencode-zen pins are existence-validated via models.dev (the /zen/v1/models REST probe cannot see Go-only models — models.dev is the source of truth).\n` +
569
+ `Re-pin any agent via .bkit/prompts.md § Model Overrides or by probing the provider's live /v1/models — see .bkit/providers.md § Models. NOTE: every ollama pin (deepseek-v4.1-flash, kimi-k3) needs a paid Ollama plan. opencode-go pins (deepseek-v4.1-flash, kimi-k3) — prefer pins that stay within the Go 5h usage window; opencode-zen pins are existence-validated via models.dev (the /zen/v1/models REST probe cannot see Go-only models — models.dev is the source of truth).\n` +
592
570
  ` 5. Verify with: \`bkit doctor\` (credentials + tools) and \`bkit status\` (installed hosts + providers).`,
593
571
  });
594
572
  }
@@ -0,0 +1,73 @@
1
+ // install/network-allowlist.ts — `.bkit/allowlist.json`, the resolved network allowlist
2
+ // (shipped egress registry ∪ consumer `allowed-domains`) the guardrails hooks of Claude,
3
+ // Cursor, Codex and Antigravity read at runtime to host-check shell curl / wget. Core
4
+ // owns it: install (runCoreModule) and upgrade (renderManagedOutputs) both write it, so
5
+ // it exists for every host that reads it and `bkit check` reports it missing or stale.
6
+
7
+ import * as fs from "node:fs";
8
+ import * as path from "node:path";
9
+ import { resolveNetworkAllowlist } from "./cloud-env.js";
10
+ import { readBkitVersion } from "./version-file.js";
11
+ import type { WriteSet } from "./write.js";
12
+
13
+ /** Consumer-relative path of the install-written curl/wget allowlist. */
14
+ export const NETWORK_ALLOWLIST_RELPATH = path.join(".bkit", "allowlist.json");
15
+
16
+ /** Where the cursor module wrote the allowlist up to 5.2.4 (migrated away). */
17
+ export const RETIRED_NETWORK_ALLOWLIST_RELPATH = path.join(".cursor", "allowlist.json");
18
+
19
+ /** The allowlist file body: `{ domains }`, apex + `*.` wildcard per base, sorted. */
20
+ export function renderNetworkAllowlist(cwd: string): string {
21
+ return JSON.stringify({ domains: resolveNetworkAllowlist(cwd) }, null, 2) + "\n";
22
+ }
23
+
24
+ /**
25
+ * Write `.bkit/allowlist.json` whole (hand edits do not survive — `allowed-domains` in
26
+ * `.agents/context.md` is the source), then migrate the retired copy. Every change is
27
+ * recorded in `ws` under dry-run too, so `bkit check` fails until install / upgrade runs.
28
+ * Returns the consumer-relative paths changed.
29
+ */
30
+ export function writeNetworkAllowlist(
31
+ cwd: string,
32
+ dryRun: boolean,
33
+ ws: WriteSet,
34
+ logPrefix: string,
35
+ ): string[] {
36
+ const tag = dryRun ? "[dry-run] " : "";
37
+ const changed: string[] = [];
38
+ const abs = path.join(cwd, NETWORK_ALLOWLIST_RELPATH);
39
+ const body = renderNetworkAllowlist(cwd);
40
+ const prev = fs.existsSync(abs) ? fs.readFileSync(abs, "utf-8") : null;
41
+ if (prev !== body) {
42
+ if (!dryRun) {
43
+ fs.mkdirSync(path.dirname(abs), { recursive: true });
44
+ fs.writeFileSync(abs, body, "utf-8");
45
+ }
46
+ ws.writes.push({ path: NETWORK_ALLOWLIST_RELPATH, action: prev === null ? "write" : "update" });
47
+ changed.push(NETWORK_ALLOWLIST_RELPATH);
48
+ console.log(`${logPrefix} ${tag}core: ${NETWORK_ALLOWLIST_RELPATH}`);
49
+ }
50
+ if (migrateRetiredNetworkAllowlist(cwd, dryRun)) {
51
+ ws.writes.push({ path: RETIRED_NETWORK_ALLOWLIST_RELPATH, action: "write" });
52
+ changed.push(RETIRED_NETWORK_ALLOWLIST_RELPATH);
53
+ console.log(
54
+ `${logPrefix} ${tag}core: removed ${RETIRED_NETWORK_ALLOWLIST_RELPATH} (moved to ${NETWORK_ALLOWLIST_RELPATH})`,
55
+ );
56
+ }
57
+ return changed;
58
+ }
59
+
60
+ /**
61
+ * Migration (installs up to 5.2.4, `docs/migrations.md`): delete `.cursor/allowlist.json`
62
+ * when `.bkit/version` records its hash — bkit wrote it and owned it whole. A file bkit
63
+ * never recorded is left alone. Returns whether the file is (or, under dry-run, would be)
64
+ * removed. The stale hash entry is pruned by the `.bkit/version` writer.
65
+ */
66
+ function migrateRetiredNetworkAllowlist(cwd: string, dryRun: boolean): boolean {
67
+ const abs = path.join(cwd, RETIRED_NETWORK_ALLOWLIST_RELPATH);
68
+ if (!fs.existsSync(abs)) return false;
69
+ const hashes = readBkitVersion(path.join(cwd, ".bkit", "version"))?.canonicalHashes ?? {};
70
+ if (hashes[RETIRED_NETWORK_ALLOWLIST_RELPATH] === undefined) return false;
71
+ if (!dryRun) fs.rmSync(abs);
72
+ return true;
73
+ }