@cbartens/bkit 5.2.4 → 5.4.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 (271) hide show
  1. package/.bkit/README.md +27 -11
  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 +18 -1
  6. package/.bkit/core/.bkit/README.md +26 -10
  7. package/.bkit/core/.bkit/cloud.md +40 -39
  8. package/.bkit/core/.bkit/comparison.md +68 -345
  9. package/.bkit/core/.bkit/install.md +16 -9
  10. package/.bkit/core/.bkit/lite.md +73 -0
  11. package/.bkit/core/.bkit/pipeline.md +346 -0
  12. package/.bkit/core/.bkit/prompts.md +90 -74
  13. package/.bkit/core/.bkit/providers.md +42 -23
  14. package/.bkit/core/.bkit/templates.md +138 -19
  15. package/.bkit/core/.bkit/trackers.md +49 -4
  16. package/.bkit/core/.bkit/workflows.md +144 -123
  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 +3 -2
  21. package/.bkit/core/docs/templates/bkit-audit-adoption.md +2 -2
  22. package/.bkit/core/docs/templates/bkit-audit-agents.md +1 -1
  23. package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +1 -1
  24. package/.bkit/core/docs/templates/bkit-audit-analytics.md +1 -1
  25. package/.bkit/core/docs/templates/bkit-audit-annotations.md +1 -1
  26. package/.bkit/core/docs/templates/bkit-audit-app-performance.md +1 -1
  27. package/.bkit/core/docs/templates/bkit-audit-app-store.md +1 -1
  28. package/.bkit/core/docs/templates/bkit-audit-architecture.md +1 -1
  29. package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +4 -2
  30. package/.bkit/core/docs/templates/bkit-audit-config.md +3 -2
  31. package/.bkit/core/docs/templates/bkit-audit-cost.md +3 -2
  32. package/.bkit/core/docs/templates/bkit-audit-coverage.md +1 -1
  33. package/.bkit/core/docs/templates/bkit-audit-database.md +3 -2
  34. package/.bkit/core/docs/templates/bkit-audit-dead-code.md +5 -5
  35. package/.bkit/core/docs/templates/bkit-audit-deferrals.md +1 -1
  36. package/.bkit/core/docs/templates/bkit-audit-dependencies.md +26 -21
  37. package/.bkit/core/docs/templates/bkit-audit-documentation.md +1 -1
  38. package/.bkit/core/docs/templates/bkit-audit-duplication.md +2 -2
  39. package/.bkit/core/docs/templates/bkit-audit-failures.md +1 -1
  40. package/.bkit/core/docs/templates/bkit-audit-flakes.md +3 -2
  41. package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -2
  42. package/.bkit/core/docs/templates/bkit-audit-issues.md +3 -2
  43. package/.bkit/core/docs/templates/bkit-audit-llm.md +22 -15
  44. package/.bkit/core/docs/templates/bkit-audit-logs.md +10 -6
  45. package/.bkit/core/docs/templates/bkit-audit-models.md +1 -1
  46. package/.bkit/core/docs/templates/bkit-audit-privacy.md +1 -1
  47. package/.bkit/core/docs/templates/bkit-audit-prompts.md +7 -7
  48. package/.bkit/core/docs/templates/bkit-audit-red-team.md +12 -9
  49. package/.bkit/core/docs/templates/bkit-audit-reliability.md +3 -2
  50. package/.bkit/core/docs/templates/bkit-audit-repo.md +1 -1
  51. package/.bkit/core/docs/templates/bkit-audit-security.md +14 -12
  52. package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
  53. package/.bkit/core/docs/templates/bkit-audit-testing.md +10 -8
  54. package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -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 -6
  67. package/.bkit/core/engine/checks/tips/catalogue.ts +76 -24
  68. package/.bkit/core/engine/checks/tips/detect.ts +45 -2
  69. package/.bkit/core/engine/checks/tips/index.ts +77 -26
  70. package/.bkit/core/engine/cli.ts +57 -27
  71. package/.bkit/core/engine/commands/analysis.ts +36 -26
  72. package/.bkit/core/engine/commands/comply.ts +42 -32
  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 +73 -130
  76. package/.bkit/core/engine/commands/install/uninstall.ts +191 -33
  77. package/.bkit/core/engine/commands/install/upgrade.ts +49 -43
  78. package/.bkit/core/engine/commands/land.ts +156 -0
  79. package/.bkit/core/engine/commands/lib.ts +45 -18
  80. package/.bkit/core/engine/commands/registry.ts +2 -0
  81. package/.bkit/core/engine/commands/tips.ts +12 -5
  82. package/.bkit/core/engine/commands/workflow/branches.ts +386 -286
  83. package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
  84. package/.bkit/core/engine/commands/workflow/disk.ts +556 -0
  85. package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
  86. package/.bkit/core/engine/commands/workflow/issues.ts +73 -28
  87. package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
  88. package/.bkit/core/engine/commands/workflow/locks.ts +38 -152
  89. package/.bkit/core/engine/commands/workflow/prs.ts +15 -4
  90. package/.bkit/core/engine/commands/workflow/repo.ts +2 -2
  91. package/.bkit/core/engine/commands/workflow/roadmap.ts +49 -53
  92. package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
  93. package/.bkit/core/engine/commands/workflow/runtime.ts +3 -2
  94. package/.bkit/core/engine/commands/workflow/status.ts +33 -11
  95. package/.bkit/core/engine/commands/workflow/steps.ts +25 -15
  96. package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
  97. package/.bkit/core/engine/commands/workflow/workflows.ts +436 -267
  98. package/.bkit/core/engine/commands/workflow/workstreams.ts +4 -2
  99. package/.bkit/core/engine/commands/workflow/worktrees.ts +24 -6
  100. package/.bkit/core/engine/install/cloud-env.ts +10 -31
  101. package/.bkit/core/engine/install/manifest.ts +14 -7
  102. package/.bkit/core/engine/install/modules/antigravity.ts +15 -26
  103. package/.bkit/core/engine/install/modules/claude.ts +20 -28
  104. package/.bkit/core/engine/install/modules/cloud.ts +5 -2
  105. package/.bkit/core/engine/install/modules/codex.ts +15 -29
  106. package/.bkit/core/engine/install/modules/core.ts +106 -70
  107. package/.bkit/core/engine/install/modules/cursor.ts +6 -20
  108. package/.bkit/core/engine/install/modules/index.ts +7 -1
  109. package/.bkit/core/engine/install/modules/opencode.ts +48 -70
  110. package/.bkit/core/engine/install/network-allowlist.ts +73 -0
  111. package/.bkit/core/engine/install/placeholders.ts +16 -35
  112. package/.bkit/core/engine/install/write.ts +59 -12
  113. package/.bkit/core/engine/ledgers/telemetry.ts +6 -4
  114. package/.bkit/core/engine/render/hosts.ts +47 -67
  115. package/.bkit/core/engine/render/models.ts +29 -11
  116. package/.bkit/core/engine/shared/branches.ts +13 -0
  117. package/.bkit/core/engine/shared/egress.ts +3 -3
  118. package/.bkit/core/engine/shared/json.ts +18 -1
  119. package/.bkit/core/engine/shared/package-json.ts +63 -0
  120. package/.bkit/core/engine/shared/package-roots.ts +0 -10
  121. package/.bkit/core/engine/shared/protected-paths.ts +5 -130
  122. package/.bkit/core/engine/shared/settings.ts +44 -0
  123. package/.bkit/core/engine/shared/timeouts.ts +8 -7
  124. package/.bkit/core/hooks/antigravity-hook.js +1 -0
  125. package/.bkit/core/hooks/guardrails-shell.js +186 -40
  126. package/.bkit/core/hooks/guardrails-tiers.js +5 -78
  127. package/.bkit/core/prompts/bkit-audit-generate.md +103 -7
  128. package/.bkit/core/prompts/bkit-build-challenge-1.md +1 -1
  129. package/.bkit/core/prompts/bkit-build-challenge-2.md +1 -1
  130. package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +1 -1
  131. package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -1
  132. package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -1
  133. package/.bkit/core/prompts/bkit-build-install-skills.md +1 -1
  134. package/.bkit/core/prompts/bkit-build-plan-current.md +1 -1
  135. package/.bkit/core/prompts/bkit-build-plan-execute.md +4 -4
  136. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
  137. package/.bkit/core/prompts/bkit-build-plan-verify.md +2 -2
  138. package/.bkit/core/prompts/bkit-debug-abort-handover.md +1 -1
  139. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +1 -1
  140. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
  141. package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +78 -0
  142. package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
  143. package/.bkit/core/prompts/bkit-debug-summary.md +3 -3
  144. package/.bkit/core/prompts/bkit-design-spike.md +1 -1
  145. package/.bkit/core/prompts/bkit-design-summary.md +2 -2
  146. package/.bkit/core/prompts/bkit-design-update.md +1 -1
  147. package/.bkit/core/prompts/bkit-plan-complexity-check.md +1 -1
  148. package/.bkit/core/prompts/bkit-plan-generate.md +1 -1
  149. package/.bkit/core/prompts/bkit-plan-scope-check-1.md +1 -1
  150. package/.bkit/core/prompts/bkit-plan-scope-check-2.md +1 -1
  151. package/.bkit/core/prompts/bkit-plan-summary.md +1 -1
  152. package/.bkit/core/prompts/bkit-plan-update.md +1 -1
  153. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
  154. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +1 -1
  155. package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
  156. package/.bkit/core/prompts/bkit-utility-update-decisions.md +9 -2
  157. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +9 -2
  158. package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
  159. package/.bkit/core/prompts/bkit-utility-update-failures.md +9 -2
  160. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +9 -2
  161. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +11 -4
  162. package/.bkit/core/workflows/bkit-auto.md +2 -2
  163. package/.bkit/core/workflows/bkit-build.md +10 -10
  164. package/.bkit/core/workflows/bkit-debug.md +80 -44
  165. package/.bkit/core/workflows/bkit-design.md +22 -13
  166. package/.bkit/core/workflows/bkit-plan.md +33 -16
  167. package/.bkit/core/workflows/bkit-ship.md +87 -98
  168. package/.bkit/shared/.claude/bkit-cloud.md +58 -25
  169. package/.bkit/shared/.claude/settings.json +19 -0
  170. package/.bkit/shared/.cursor/mcp.json +2 -1
  171. package/.bkit/shared/.opencode/opencode.json +19 -1
  172. package/.bkit/shared/docs/deployments.md +49 -29
  173. package/.bkit/shared/docs/security.md +8 -6
  174. package/.bkit/shared/docs/testing.md +9 -5
  175. package/.bkit/shared/gitignore +1 -2
  176. package/.bkit/templates/.cursor/Dockerfile +30 -16
  177. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +78 -0
  178. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +91 -0
  179. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +56 -0
  180. package/.bkit/templates/.github/renovate.json5 +91 -12
  181. package/.bkit/templates/.github/workflows/bkit-ci.yml +73 -55
  182. package/.bkit/templates/.github/workflows/bkit-cloud.yml +3 -1
  183. package/.bkit/templates/.github/workflows/bkit-renovate.yml +8 -1
  184. package/.bkit/templates/.github/workflows/bkit-trivy.yml +67 -0
  185. package/.bkit/templates/.husky/pre-commit +6 -0
  186. package/.bkit/templates/.husky/pre-push +15 -3
  187. package/.bkit/templates/.lintstagedrc.json +5 -1
  188. package/.bkit/templates/.oxlintrc.json +21 -0
  189. package/.bkit/templates/docs/capabilities.md +1 -1
  190. package/.bkit/templates/scripts/ci/check-capstone.mjs +176 -0
  191. package/.bkit/templates/scripts/ci/check-capstone.test.mjs +311 -0
  192. package/.bkit/templates/scripts/cleanup/bkit-disk-prune.machine.mjs +197 -0
  193. package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +164 -0
  194. package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +2 -2
  195. package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +43 -20
  196. package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +33 -11
  197. package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -2
  198. package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +5 -5
  199. package/.bkit/templates/scripts/graphify/bkit-graphify.sh +79 -19
  200. package/CHANGELOG.md +98 -3
  201. package/README.md +252 -122
  202. package/dist/checks/after/auth.js +10 -11
  203. package/dist/checks/after/ci-yml.js +11 -14
  204. package/dist/checks/after/github.js +32 -125
  205. package/dist/checks/after/index.js +3 -2
  206. package/dist/checks/after/managed.js +8 -24
  207. package/dist/checks/after/tools.js +3 -16
  208. package/dist/checks/before/context-fetch.js +1 -21
  209. package/dist/checks/before/index.js +6 -42
  210. package/dist/checks/before/mcp.js +14 -9
  211. package/dist/checks/before/repo.js +8 -11
  212. package/dist/checks/status-holes.js +5 -7
  213. package/dist/checks/tips/catalogue.js +65 -18
  214. package/dist/checks/tips/detect.js +41 -2
  215. package/dist/checks/tips/index.js +61 -25
  216. package/dist/cli.js +52 -26
  217. package/dist/commands/analysis.js +21 -5
  218. package/dist/commands/comply.js +40 -31
  219. package/dist/commands/harvest.js +12 -13
  220. package/dist/commands/install/doctor.js +55 -23
  221. package/dist/commands/install/install.js +72 -122
  222. package/dist/commands/install/uninstall.js +165 -31
  223. package/dist/commands/install/upgrade.js +46 -39
  224. package/dist/commands/land.js +129 -0
  225. package/dist/commands/lib.js +41 -16
  226. package/dist/commands/registry.js +2 -0
  227. package/dist/commands/tips.js +10 -3
  228. package/dist/commands/workflow/branches.js +303 -248
  229. package/dist/commands/workflow/counters.js +17 -7
  230. package/dist/commands/workflow/disk.js +452 -0
  231. package/dist/commands/workflow/fids.js +39 -0
  232. package/dist/commands/workflow/issues.js +63 -27
  233. package/dist/commands/workflow/ledgers.js +3 -1
  234. package/dist/commands/workflow/locks.js +35 -130
  235. package/dist/commands/workflow/prs.js +8 -5
  236. package/dist/commands/workflow/repo.js +2 -2
  237. package/dist/commands/workflow/roadmap.js +50 -57
  238. package/dist/commands/workflow/runs.js +5 -5
  239. package/dist/commands/workflow/runtime.js +3 -2
  240. package/dist/commands/workflow/status.js +32 -12
  241. package/dist/commands/workflow/steps.js +19 -11
  242. package/dist/commands/workflow/tests.js +16 -3
  243. package/dist/commands/workflow/workflows.js +390 -249
  244. package/dist/commands/workflow/workstreams.js +4 -2
  245. package/dist/commands/workflow/worktrees.js +15 -6
  246. package/dist/install/cloud-env.js +10 -23
  247. package/dist/install/manifest.js +14 -7
  248. package/dist/install/modules/antigravity.js +15 -26
  249. package/dist/install/modules/claude.js +17 -21
  250. package/dist/install/modules/cloud.js +6 -2
  251. package/dist/install/modules/codex.js +15 -29
  252. package/dist/install/modules/core.js +95 -63
  253. package/dist/install/modules/cursor.js +6 -9
  254. package/dist/install/modules/index.js +6 -1
  255. package/dist/install/modules/opencode.js +41 -72
  256. package/dist/install/network-allowlist.js +62 -0
  257. package/dist/install/placeholders.js +16 -35
  258. package/dist/install/write.js +55 -15
  259. package/dist/ledgers/telemetry.js +5 -4
  260. package/dist/render/hosts.js +30 -55
  261. package/dist/render/models.js +20 -9
  262. package/dist/shared/branches.js +11 -0
  263. package/dist/shared/egress.js +0 -2
  264. package/dist/shared/json.js +14 -0
  265. package/dist/shared/package-json.js +61 -0
  266. package/dist/shared/package-roots.js +0 -8
  267. package/dist/shared/protected-paths.js +5 -122
  268. package/dist/shared/settings.js +23 -1
  269. package/dist/shared/timeouts.js +8 -7
  270. package/package.json +21 -17
  271. package/.bkit/core/.agents/shortcuts.md +0 -73
@@ -70,15 +70,17 @@ export function parseWorkstreams(md) {
70
70
  }
71
71
  /** `[]` or `[WS-1, WS-2]`. */
72
72
  export const requiresList = (w) => `[${w.requires.join(", ")}]`;
73
- /** The Step 11 comment: one line per workstream, then the design doc link. */
73
+ /** The Step 11 comment: one line per workstream, the issue-body line, then the design doc link. */
74
74
  export function commentBody(ws, opts) {
75
75
  const doc = `docs/plans/${opts.month}/${opts.fid}-design.md`;
76
+ const url = `https://github.com/${opts.ownerRepo}/blob/dev/${doc}`;
76
77
  return [
77
78
  "###### bkit:generated",
78
79
  "### Step 11 — Suggested Workstreams",
79
80
  "Advisory only. NEVER auto-trigger.",
80
81
  ...ws.map((w) => `- ${w.id}: ${w.name}. Requires: ${requiresList(w)}`),
81
- `[${doc}](https://github.com/${opts.ownerRepo}/blob/dev/${doc})`,
82
+ `Filing one issue per workstream: put \`**Parent design:** [${opts.fid}-design.md](${url})\` in its body, and list the issues it requires in a blocked-by block (.bkit/trackers.md § Issue shapes).`,
83
+ `[${doc}](${url})`,
82
84
  ].join("\n");
83
85
  }
84
86
  const ARTIFACT_FLAG = {
@@ -15,11 +15,11 @@ import * as path from "node:path";
15
15
  import { gitEnv } from "../../ledgers/telemetry.js";
16
16
  import { readBkitConfig } from "../../shared/settings.js";
17
17
  import { COULD_NOT_RUN_EXIT_CODES, installCommand } from "../../shared/package-manager.js";
18
- import { CommandError, EXIT, git, repoRoot, runGit } from "../lib.js";
18
+ import { CommandError, DEV, EXIT, git, isSharedBranch, repoRoot, runGit, } from "../lib.js";
19
+ import { ensureDiskSpace } from "./disk.js";
19
20
  import { detect } from "./runtime.js";
20
21
  import { WORKFLOW_FLAG } from "./status.js";
21
22
  const WORKFLOWS = ["design", "plan", "build", "debug", "ship"];
22
- const DEV = "dev";
23
23
  const ORIGIN_DEV = `origin/${DEV}`;
24
24
  export const EXIT_REBASE_CONFLICT = 3;
25
25
  export const EXIT_FETCH = 4;
@@ -30,6 +30,7 @@ export const EXIT_WORKTREE_ADD = 8;
30
30
  export const EXIT_REBASE_NOT_STARTED = 9;
31
31
  export const EXIT_NOT_A_WORKTREE = 10;
32
32
  export const EXIT_REMOVE = 11;
33
+ export const EXIT_DISK_FULL = 12;
33
34
  const FID_FLAG = { name: "fid", type: "string", required: true, help: "feature id" };
34
35
  function fidOf(value) {
35
36
  const fid = String(value);
@@ -90,7 +91,7 @@ function shipBranch(root, fid, named, session) {
90
91
  const feat = `feat/${fid}`;
91
92
  if (hasLocal(root, feat) || remoteHas(root, feat) === "yes")
92
93
  return feat;
93
- return session === DEV || session === "main" || session === "" ? feat : session;
94
+ return isSharedBranch(session) || session === "" ? feat : session;
94
95
  }
95
96
  /**
96
97
  * `git worktree add` for `branch`: the local branch, else a tracking branch off
@@ -215,7 +216,7 @@ function deleteBranch(root, branch, log) {
215
216
  * worktree holds it. Throws EXIT_REMOVE when `git worktree remove` fails.
216
217
  */
217
218
  export function removeWorktree(cwd, fid, branch, log) {
218
- if (branch !== undefined && (branch === DEV || branch === "main")) {
219
+ if (branch !== undefined && isSharedBranch(branch)) {
219
220
  throw new CommandError(EXIT.USAGE, `refusing to delete branch ${branch}`);
220
221
  }
221
222
  const root = repoRoot(cwd);
@@ -303,8 +304,9 @@ export const worktreesCommand = {
303
304
  [EXIT_WORKTREE_ADD]: "git worktree add failed",
304
305
  [EXIT_REBASE_NOT_STARTED]: "resume rebase could not start (e.g. uncommitted changes)",
305
306
  [EXIT_NOT_A_WORKTREE]: ".worktrees/{fid} exists but is not a registered git worktree",
307
+ [EXIT_DISK_FULL]: "free disk under bkit.disk.minFreeGb even after your max cleanup steps (`bkit disk prune`); nothing created",
306
308
  },
307
- run: (ctx) => {
309
+ run: async (ctx) => {
308
310
  const f = ctx.flags;
309
311
  const workflow = String(f.workflow);
310
312
  if (!WORKFLOWS.includes(workflow)) {
@@ -328,7 +330,7 @@ export const worktreesCommand = {
328
330
  throw new CommandError(EXIT_REFUSED, "detached HEAD — check out a branch before debugging");
329
331
  }
330
332
  const target = workflow === "ship" ? shipBranch(root, fid, named, session) : `feat/${fid}`;
331
- if (target === DEV || target === "main") {
333
+ if (isSharedBranch(target)) {
332
334
  throw new CommandError(EXIT_REFUSED, `refusing to ship ${target} as a feature branch`);
333
335
  }
334
336
  // Ship mints only when the session is not already on the branch it ships:
@@ -342,6 +344,13 @@ export const worktreesCommand = {
342
344
  const wtDir = worktreeDir(root, fid);
343
345
  let mode = "adopted";
344
346
  if (mint) {
347
+ const full = await ensureDiskSpace({
348
+ cwd: root,
349
+ minFreeGb: config.diskMinFreeGb,
350
+ log: ctx.log,
351
+ });
352
+ if (full !== null)
353
+ throw new CommandError(EXIT_DISK_FULL, full);
345
354
  runGit(root, ["worktree", "prune"]);
346
355
  if (fs.existsSync(wtDir)) {
347
356
  // A plain directory there would resolve to the main checkout's repo,
@@ -12,6 +12,7 @@
12
12
  // BKIT_ANTHROPIC_API_KEY — both derived here without a bespoke key list.
13
13
  import * as fs from "node:fs";
14
14
  import * as path from "node:path";
15
+ import { readJsonFile } from "../shared/json.js";
15
16
  import { getSharedRoot } from "../shared/package-roots.js";
16
17
  import { applyTokens } from "./placeholders.js";
17
18
  import { BKIT_EGRESS_SOURCES } from "../shared/egress.js";
@@ -197,7 +198,8 @@ function fmtList(items) {
197
198
  export function renderCloudEnvNotes(res) {
198
199
  if (!res.hasEnvrc) {
199
200
  return ("_No `.envrc` found — the block above lists only the bkit baseline token names as " +
200
- "placeholders. Add your `.envrc` (`bkit install` seeds one) and re-run to inline real values._");
201
+ "placeholders. Copy `.bkit/templates/.envrc` to the repo root, fill the files it sources, " +
202
+ "and re-run to inline real values._");
201
203
  }
202
204
  const bullets = [];
203
205
  if (res.placeholders.length) {
@@ -217,15 +219,13 @@ export function renderCloudEnvNotes(res) {
217
219
  }
218
220
  /** Parse the pnpm `X.Y.Z` from `package.json` `packageManager` ("" if absent/non-pnpm). */
219
221
  export function resolveConsumerPnpm(cwd) {
220
- try {
221
- const pkg = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf-8"));
222
- const pm = typeof pkg["packageManager"] === "string" ? pkg["packageManager"] : "";
223
- const m = pm.match(/^pnpm@(\d+\.\d+\.\d+)/);
224
- return m?.[1] ?? "";
225
- }
226
- catch {
222
+ const read = readJsonFile(path.join(cwd, "package.json"));
223
+ if (!read.ok || typeof read.value !== "object" || read.value === null)
227
224
  return "";
228
- }
225
+ const pkg = read.value;
226
+ const pm = typeof pkg["packageManager"] === "string" ? pkg["packageManager"] : "";
227
+ const m = pm.match(/^pnpm@(\d+\.\d+\.\d+)/);
228
+ return m?.[1] ?? "";
229
229
  }
230
230
  /**
231
231
  * Render the setup-script corepack line from the consumer's own `packageManager`
@@ -495,25 +495,12 @@ export function resolveClaudeDerivedAllows(cwd) {
495
495
  ...extractMcpServers(cwd).flatMap((s) => [`mcp__${s}__*`, `mcp__claude_ai_${s}__*`]),
496
496
  ];
497
497
  }
498
- /** Cursor-relative path of the install-written curl/wget allowlist (guardrails). */
499
- export const NETWORK_ALLOWLIST_RELPATH = path.join(".cursor", "allowlist.json");
500
- /**
501
- * Write `.cursor/allowlist.json` for Cursor `bkit-guardrails.cjs` (runtime curl/wget host
502
- * checks). Claude/OpenCode bake the same domain set into their own configs at
503
- * install/upgrade — they do not read this file. Call only when the cursor module
504
- * is installed (do not create `.cursor/` for claude-only consumers).
505
- */
506
- export function writeNetworkAllowlistArtifact(cwd, dryRun) {
507
- const domains = resolveNetworkAllowlist(cwd);
508
- const rel = NETWORK_ALLOWLIST_RELPATH;
509
- return { path: rel, domains, wrote: writeGeneratedJson(cwd, rel, { domains }, dryRun) };
510
- }
511
498
  /** Cursor-relative path of the install-written Cursor CLI permissions (MCP allows). */
512
499
  export const CURSOR_CLI_PERMISSIONS_RELPATH = path.join(".cursor", "cli.json");
513
500
  /**
514
501
  * Write `.cursor/cli.json` — the project-level Cursor CLI / cloud-agent permissions —
515
502
  * with one `Mcp(<server>:*)` allow per {@link extractMcpServers} entry. bkit-owned and
516
- * regenerated whole, like `.cursor/allowlist.json`: hand edits do not survive, the
503
+ * regenerated whole, like `.bkit/allowlist.json`: hand edits do not survive, the
517
504
  * `mcp-servers` block is the source. Call only when the cursor module is installed.
518
505
  */
519
506
  export function writeCursorCliPermissionsArtifact(cwd, dryRun) {
@@ -77,10 +77,17 @@ const CORE_MANIFEST = [
77
77
  // their own attributes outside the block, so this is markered-text (not whole-file).
78
78
  { path: ".gitattributes", format: "markered-text", module: "core" },
79
79
  { path: ".bkit/version", format: "byte-equal-text", module: "core" },
80
+ // Curl/wget host allowlist read at runtime by every host's bkit-guardrails.cjs (Claude,
81
+ // Cursor, Codex, Antigravity). No template backs it — `writeNetworkAllowlist`
82
+ // (install/network-allowlist.ts) computes the domain set from the consumer's own config,
83
+ // so it is `generated` and its hash is in `canonicalHashes`. Core-owned: it stays until
84
+ // the last host goes (full/core uninstall).
85
+ { path: ".bkit/allowlist.json", format: "byte-equal-text", module: "core", generated: true },
80
86
  // Canonical bkit-authored reference docs. They live package-side under
81
87
  // `.bkit/core/.bkit/` and are read from there at runtime (getBkitDocsRoot); these
82
88
  // consumer copies are force-overwritten mirrors (writeTier1) so a consumer can read
83
- // them in-repo. Whole file is bkit-owned → byte-equal-text (refreshed every install).
89
+ // them in-repo. Whole file is bkit-owned → byte-equal-text (refreshed every install);
90
+ // prompts.md and lite.md are markered-text, keeping the consumer section below `bkit:end`.
84
91
  { path: ".bkit/cloud.md", format: "byte-equal-text", module: "core" },
85
92
  { path: ".bkit/comparison.md", format: "byte-equal-text", module: "core" },
86
93
  { path: ".bkit/install.md", format: "byte-equal-text", module: "core" },
@@ -88,6 +95,8 @@ const CORE_MANIFEST = [
88
95
  // The MIT notice that travels with the files bkit writes: the full text and copyright
89
96
  // notice. Sourced from `.bkit/core/.bkit/LICENSE.md`.
90
97
  { path: ".bkit/LICENSE.md", format: "byte-equal-text", module: "core" },
98
+ { path: ".bkit/lite.md", format: "markered-text", module: "core" },
99
+ { path: ".bkit/pipeline.md", format: "byte-equal-text", module: "core" },
91
100
  { path: ".bkit/providers.md", format: "byte-equal-text", module: "core" },
92
101
  { path: ".bkit/prompts.md", format: "markered-text", module: "core" },
93
102
  { path: ".bkit/templates.md", format: "byte-equal-text", module: "core" },
@@ -159,7 +168,8 @@ const CLAUDE_MANIFEST = [
159
168
  // `gate-missing-called-scripts` advisory names any that are missing.
160
169
  //
161
170
  // The SAME names are what the git hook templates run (`.husky/pre-commit`,
162
- // `.husky/pre-push`). `bkit-ci.yml` does NOT call the gates; it calls the scripts directly.
171
+ // `.husky/pre-push`). `bkit-ci.yml` does NOT call the gates; it calls the same scripts
172
+ // directly, one step each.
163
173
  //
164
174
  // `lint:slop` is in no gate: `slop-scan scan` is report-only and never fails. The gate
165
175
  // that fails on new findings is `slop:delta`.
@@ -173,7 +183,8 @@ export const BKIT_GATE_SCRIPTS = {
173
183
  // `.husky/pre-commit`: prettier --write over staged files, and nothing else —
174
184
  // seconds, not minutes. Prose is a whole-repo scan, so it gates at pre-push.
175
185
  "bkit:gate:format": "pnpm lint-staged",
176
- // Everything that needs no test runner. Mirrors the bkit-tests-static CI job.
186
+ // Everything that needs no test runner. Every part has a matching step in the
187
+ // bkit-tests-static CI job; audits/templates/template-ci-yml.test.ts fails when one is missing.
177
188
  // Callers: build's plan-execute loop between tasks, and the `.husky/pre-push` revert
178
189
  // path.
179
190
  "bkit:gate:static": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm lint:prose && pnpm slop:delta",
@@ -278,10 +289,6 @@ const CURSOR_MANIFEST = [
278
289
  format: "markered-text",
279
290
  module: "cursor",
280
291
  },
281
- // Curl/wget host allowlist read at runtime by bkit-guardrails.cjs. No template backs it —
282
- // `writeNetworkAllowlistArtifact` (install/cloud-env.ts) computes the domain set from the
283
- // consumer's own config, so it is `generated` and its hash is in `canonicalHashes`.
284
- { path: ".cursor/allowlist.json", format: "byte-equal-text", module: "cursor", generated: true },
285
292
  // Cursor CLI / cloud-agent MCP allows — `writeCursorCliPermissionsArtifact`
286
293
  // (install/cloud-env.ts) renders it from the consumer's `mcp-servers` block; same contract.
287
294
  { path: ".cursor/cli.json", format: "byte-equal-text", module: "cursor", generated: true },
@@ -9,7 +9,8 @@ import { ANTIGRAVITY_AGENTS_DIR, applyAntigravityPrompt, applyAntigravitySkill,
9
9
  import { getCoreRoot, getSharedRoot, getWorkflowsRoot, getPromptsRoot, } from "../../shared/package-roots.js";
10
10
  import { DEFAULT_ISSUE_TRACKER } from "../manifest.js";
11
11
  import { substituteWorkflow } from "../../render/trackers.js";
12
- import { BKIT_PREFIX, installFile, listMdFiles, readInstallingVersion, trackMirrorWrite, } from "./core.js";
12
+ import { readInstallingVersion } from "../../shared/package-json.js";
13
+ import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
13
14
  // ---------------------------------------------------------------------------
14
15
  // runAntigravityModule — Google Antigravity IDE host (opt-in via --antigravity)
15
16
  //
@@ -77,19 +78,12 @@ export function renderAntigravityAgentsSkills(ctx) {
77
78
  trackMirrorWrite(ctx, rel, written);
78
79
  }
79
80
  }
80
- // Orphan sweep is bkit-prefix scoped — the plugin's agents/ is bkit-owned.
81
- if (fs.existsSync(dest)) {
82
- for (const f of fs.readdirSync(dest)) {
83
- if (!f.startsWith(BKIT_PREFIX))
84
- continue;
85
- if (sourceSet.has(f))
86
- continue;
87
- const rel = path.join(dest, f);
88
- if (!dryRun)
89
- fs.rmSync(rel, { force: true });
90
- console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
91
- trackMirrorWrite(ctx, rel, written);
92
- }
81
+ // Orphan sweep is bkit-prefix scoped — the plugin's agents/ is bkit-owned, so every
82
+ // bkit-* entry counts, whatever its extension.
83
+ for (const f of removeOrphans(dest, sourceSet, dryRun, BKIT_PREFIX, { extension: "" })) {
84
+ const rel = path.join(dest, f);
85
+ console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
86
+ trackMirrorWrite(ctx, rel, written);
93
87
  }
94
88
  }
95
89
  // --- Workflow skills: one directory per workflow, each holding SKILL.md ---
@@ -111,18 +105,13 @@ export function renderAntigravityAgentsSkills(ctx) {
111
105
  }
112
106
  }
113
107
  // Prefix-scoped sweep inside the bkit plugin's skills/.
114
- if (fs.existsSync(ANTIGRAVITY_SKILLS_DIR)) {
115
- for (const d of fs.readdirSync(ANTIGRAVITY_SKILLS_DIR)) {
116
- if (!d.startsWith(BKIT_PREFIX))
117
- continue;
118
- if (sourceStems.has(d))
119
- continue;
120
- const rel = path.join(ANTIGRAVITY_SKILLS_DIR, d);
121
- if (!dryRun)
122
- fs.rmSync(rel, { recursive: true, force: true });
123
- console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
124
- trackMirrorWrite(ctx, rel, written);
125
- }
108
+ const orphans = removeOrphans(ANTIGRAVITY_SKILLS_DIR, sourceStems, dryRun, BKIT_PREFIX, {
109
+ wholeFolders: true,
110
+ });
111
+ for (const d of orphans) {
112
+ const rel = path.join(ANTIGRAVITY_SKILLS_DIR, d);
113
+ console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
114
+ trackMirrorWrite(ctx, rel, written);
126
115
  }
127
116
  }
128
117
  return written;
@@ -2,14 +2,16 @@
2
2
  // allows, and the tracker entry in the MCP config files (`.mcp.json`, `.cursor/mcp.json`).
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
- import { writeTier1, writeTier2, writeTier2JsonContained, ensureDir, } from "../write.js";
5
+ import { writeTier1, writeTier2, writeTier2JsonContained, ensureDir, mergeTrackerEntry, trackerEntryInSync, } from "../write.js";
6
6
  import { readBkitVersion, stampManagedVersion } from "../version-file.js";
7
+ import { readJsonFile } from "../../shared/json.js";
7
8
  import { applyEffortRemap } from "../../render/hosts.js";
8
9
  import { getCoreRoot, getSharedRoot, getWorkflowsRoot, getPromptsRoot, } from "../../shared/package-roots.js";
9
10
  import { DEFAULT_ISSUE_TRACKER } from "../manifest.js";
10
11
  import { substituteWorkflow } from "../../render/trackers.js";
11
12
  import { writeClaudeCloudDoc, resolveClaudeDerivedAllows } from "../cloud-env.js";
12
- import { BKIT_PREFIX, installFile, listMdFiles, readInstallingVersion, removeOrphans, trackMirrorWrite, } from "./core.js";
13
+ import { readInstallingVersion } from "../../shared/package-json.js";
14
+ import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
13
15
  export function renderClaudeAgentsCommands(ctx) {
14
16
  const { dryRun, logPrefix, effortMap } = ctx;
15
17
  const tag = dryRun ? "[dry-run] " : "";
@@ -192,13 +194,10 @@ export function runClaudeModule(ctx) {
192
194
  export function enrichClaudeSettingsAllows(settingsDst, cwd, dryRun, ws, advisories) {
193
195
  if (!fs.existsSync(settingsDst))
194
196
  return null;
195
- let doc;
196
- try {
197
- doc = JSON.parse(fs.readFileSync(settingsDst, "utf-8"));
198
- }
199
- catch {
197
+ const settings = readJsonFile(settingsDst);
198
+ if (!settings.ok)
200
199
  return null;
201
- }
200
+ const doc = settings.value;
202
201
  const allow = doc.permissions?.allow;
203
202
  if (!Array.isArray(allow))
204
203
  return null;
@@ -247,12 +246,14 @@ export function buildMcpJson(templatePath, tracker) {
247
246
  }
248
247
  /**
249
248
  * Reconcile bkit's tracker entry into a consumer's `.mcp.json` / `.cursor/mcp.json`. bkit
250
- * owns exactly one key, `mcpServers[<tracker>]`, and sets it to the template's entry; every
249
+ * owns exactly one key, `mcpServers[<tracker>]`, and within it only what the template sets
250
+ * (`mergeTrackerEntry`: extra keys, headers and toolsets stay the consumer's); every
251
251
  * other key and the existing key order stay the consumer's. Absent file → write the
252
252
  * `buildMcpJson` render. Malformed JSON → throw (refuse to merge; the consumer fixes it).
253
253
  * Tracker `none` owns no entry, so a present file is left alone. Writes only on change, so
254
- * dry-run and live compute the identical WriteSet. Another tracker's entry from an earlier
255
- * install is left in place (`detectExtraMcpServers` advises on it).
254
+ * dry-run and live compute the identical WriteSet. Another tracker's entry is not touched
255
+ * here: a `--tracker` switch removes an unedited one first (`removeUnusedTrackerMcpEntries`),
256
+ * and `detectExtraMcpServers` advises on an edited one.
256
257
  */
257
258
  export function reconcileMcpJson(templatePath, relDst, tracker, dryRun, ws) {
258
259
  const rendered = buildMcpJson(templatePath, tracker);
@@ -264,24 +265,19 @@ export function reconcileMcpJson(templatePath, relDst, tracker, dryRun, ws) {
264
265
  ws.writes.push({ path: relDst, action: "write" });
265
266
  return;
266
267
  }
267
- // Parse-or-sentinel idiom (see reconcileOpencodeJson): the throw stays out of the catch.
268
- let existing = null;
269
- try {
270
- existing = JSON.parse(fs.readFileSync(relDst, "utf-8"));
271
- }
272
- catch {
273
- existing = null;
274
- }
268
+ const read = readJsonFile(relDst);
269
+ const existing = read.ok ? read.value : null;
275
270
  if (existing === null || typeof existing !== "object" || Array.isArray(existing)) {
276
271
  throw new Error(`[bkit] ${relDst} is malformed JSON — fix manually before running bkit install`);
277
272
  }
278
273
  const owned = JSON.parse(rendered).mcpServers;
279
274
  const servers = existing.mcpServers;
280
275
  const serversObj = servers !== null && typeof servers === "object" && !Array.isArray(servers) ? servers : {};
281
- const inSync = Object.entries(owned).every(([k, v]) => JSON.stringify(serversObj[k]) === JSON.stringify(v));
276
+ const inSync = Object.entries(owned).every(([k, v]) => trackerEntryInSync(serversObj[k], v));
282
277
  if (inSync)
283
278
  return;
284
- const next = { ...existing, mcpServers: { ...serversObj, ...owned } };
279
+ const merged = Object.fromEntries(Object.entries(owned).map(([k, v]) => [k, mergeTrackerEntry(serversObj[k], v)]));
280
+ const next = { ...existing, mcpServers: { ...serversObj, ...merged } };
285
281
  if (!dryRun)
286
282
  fs.writeFileSync(relDst, JSON.stringify(next, null, 2) + "\n", "utf-8");
287
283
  ws.writes.push({ path: relDst, action: "update" });
@@ -4,6 +4,7 @@
4
4
  // environment) ships as a copy-and-own template.
5
5
  import * as fs from "node:fs";
6
6
  import * as path from "node:path";
7
+ import { parseJson } from "../../shared/json.js";
7
8
  // ---------------------------------------------------------------------------
8
9
  // Helpers
9
10
  // ---------------------------------------------------------------------------
@@ -23,7 +24,10 @@ function setConsumerBkitField(field, value, dryRun) {
23
24
  return;
24
25
  try {
25
26
  const raw = fs.readFileSync(pkgPath, "utf-8");
26
- const pkg = JSON.parse(raw);
27
+ const parsed = parseJson(raw);
28
+ if (!parsed.ok)
29
+ return;
30
+ const pkg = parsed.value;
27
31
  const bkit = (pkg.bkit ?? {});
28
32
  if (bkit[field] === value)
29
33
  return; // already set — avoid a no-op rewrite
@@ -88,7 +92,7 @@ export function runCloudModule(ctx) {
88
92
  " - 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" +
89
93
  "IN CLAUDE APP (claude.ai/code → environment selector → + Add environment):\n" +
90
94
  " - Name: the repo name (e.g. `acme-web`) — one environment per repo, since secrets are per-repo.\n" +
91
- " - Setup script: paste from bkit's `cloud.md` § Setup script (installs vale + gh + corepack-pinned pnpm — exact versions live in cloud.md, not duplicated here).\n" +
95
+ " - 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" +
92
96
  " - Environment variables: `BKIT_GH_TOKEN` (fine-grained for one owner, classic across owners — GitHub MCP).\n" +
93
97
  " - 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" +
94
98
  " - 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.",
@@ -7,7 +7,8 @@ import { applyCodexAgent, parseFrontmatter } from "../../render/hosts.js";
7
7
  import { getCoreRoot, getSharedRoot, getWorkflowsRoot, getPromptsRoot, } from "../../shared/package-roots.js";
8
8
  import { DEFAULT_ISSUE_TRACKER } from "../manifest.js";
9
9
  import { substituteWorkflow } from "../../render/trackers.js";
10
- import { BKIT_PREFIX, installFile, listMdFiles, readInstallingVersion, trackMirrorWrite, } from "./core.js";
10
+ import { readInstallingVersion } from "../../shared/package-json.js";
11
+ import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
11
12
  /**
12
13
  * Convert a workflow orchestrator (`.bkit/core/workflows/*.md`) into a Codex SKILL.md.
13
14
  *
@@ -69,8 +70,8 @@ export function renderCodexAgentsSkills(ctx) {
69
70
  if (!dryRun)
70
71
  ensureDir(dest);
71
72
  const files = listMdFiles(src, BKIT_PREFIX);
72
- // Destination basenames are .toml, so the orphan sweep has to compare on stem.
73
- const sourceStems = new Set(files.map((f) => f.replace(/\.md$/, "")));
73
+ // Destination basenames are .toml, so the orphan sweep compares on the .toml names.
74
+ const sourceNames = new Set(files.map((f) => f.replace(/\.md$/, ".toml")));
74
75
  for (const f of files) {
75
76
  const stem = f.replace(/\.md$/, "");
76
77
  const transform = (c) => `${managedVersionMarker(version, "hash")}\n` +
@@ -81,20 +82,10 @@ export function renderCodexAgentsSkills(ctx) {
81
82
  trackMirrorWrite(ctx, rel, written);
82
83
  }
83
84
  }
84
- if (fs.existsSync(dest)) {
85
- for (const f of fs.readdirSync(dest)) {
86
- if (!f.endsWith(".toml"))
87
- continue;
88
- if (!f.startsWith(BKIT_PREFIX))
89
- continue;
90
- if (!sourceStems.has(f.replace(/\.toml$/, ""))) {
91
- const rel = path.join(dest, f);
92
- if (!dryRun)
93
- fs.rmSync(path.join(dest, f));
94
- console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
95
- trackMirrorWrite(ctx, rel, written);
96
- }
97
- }
85
+ for (const f of removeOrphans(dest, sourceNames, dryRun, BKIT_PREFIX, { extension: ".toml" })) {
86
+ const rel = path.join(dest, f);
87
+ console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
88
+ trackMirrorWrite(ctx, rel, written);
98
89
  }
99
90
  }
100
91
  // --- Workflow skills: one directory per workflow, each holding SKILL.md ---
@@ -120,18 +111,13 @@ export function renderCodexAgentsSkills(ctx) {
120
111
  }
121
112
  // Orphan sweep is bkit-prefix scoped: `.agents/skills/` is SHARED with third-party
122
113
  // skills installed via skills.sh, so anything not named bkit-* is off limits here.
123
- if (fs.existsSync(CODEX_SKILLS_DIR)) {
124
- for (const d of fs.readdirSync(CODEX_SKILLS_DIR)) {
125
- if (!d.startsWith(BKIT_PREFIX))
126
- continue;
127
- if (sourceStems.has(d))
128
- continue;
129
- const rel = path.join(CODEX_SKILLS_DIR, d);
130
- if (!dryRun)
131
- fs.rmSync(rel, { recursive: true, force: true });
132
- console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
133
- trackMirrorWrite(ctx, rel, written);
134
- }
114
+ const orphans = removeOrphans(CODEX_SKILLS_DIR, sourceStems, dryRun, BKIT_PREFIX, {
115
+ wholeFolders: true,
116
+ });
117
+ for (const d of orphans) {
118
+ const rel = path.join(CODEX_SKILLS_DIR, d);
119
+ console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
120
+ trackMirrorWrite(ctx, rel, written);
135
121
  }
136
122
  }
137
123
  return written;