@cbartens/bkit 5.2.4 → 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 (221) hide show
  1. package/.bkit/README.md +26 -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 +11 -0
  6. package/.bkit/core/.bkit/README.md +25 -10
  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 +12 -6
  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 +106 -17
  15. package/.bkit/core/.bkit/trackers.md +47 -1
  16. package/.bkit/core/.bkit/workflows.md +44 -43
  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-adoption.md +1 -1
  21. package/.bkit/core/docs/templates/bkit-audit-dependencies.md +14 -10
  22. package/.bkit/core/docs/templates/bkit-audit-llm.md +20 -14
  23. package/.bkit/core/docs/templates/bkit-audit-prompts.md +2 -2
  24. package/.bkit/core/docs/templates/bkit-audit-red-team.md +10 -8
  25. package/.bkit/core/docs/templates/bkit-audit-security.md +3 -3
  26. package/.bkit/core/docs/templates/bkit-audit-testing.md +4 -3
  27. package/.bkit/core/docs/templates/bkit-plan.md +8 -6
  28. package/.bkit/core/engine/checks/after/auth.ts +9 -9
  29. package/.bkit/core/engine/checks/after/ci-yml.ts +14 -12
  30. package/.bkit/core/engine/checks/after/github.ts +29 -120
  31. package/.bkit/core/engine/checks/after/index.ts +2 -2
  32. package/.bkit/core/engine/checks/after/managed.ts +8 -28
  33. package/.bkit/core/engine/checks/after/tools.ts +3 -15
  34. package/.bkit/core/engine/checks/before/context-fetch.ts +1 -21
  35. package/.bkit/core/engine/checks/before/index.ts +7 -43
  36. package/.bkit/core/engine/checks/before/mcp.ts +17 -8
  37. package/.bkit/core/engine/checks/before/repo.ts +9 -12
  38. package/.bkit/core/engine/checks/status-holes.ts +4 -5
  39. package/.bkit/core/engine/checks/tips/catalogue.ts +60 -24
  40. package/.bkit/core/engine/checks/tips/detect.ts +45 -2
  41. package/.bkit/core/engine/checks/tips/index.ts +37 -8
  42. package/.bkit/core/engine/cli.ts +39 -16
  43. package/.bkit/core/engine/commands/analysis.ts +36 -26
  44. package/.bkit/core/engine/commands/comply.ts +17 -16
  45. package/.bkit/core/engine/commands/harvest.ts +12 -12
  46. package/.bkit/core/engine/commands/install/doctor.ts +57 -28
  47. package/.bkit/core/engine/commands/install/install.ts +62 -126
  48. package/.bkit/core/engine/commands/install/uninstall.ts +191 -33
  49. package/.bkit/core/engine/commands/install/upgrade.ts +49 -43
  50. package/.bkit/core/engine/commands/lib.ts +35 -10
  51. package/.bkit/core/engine/commands/tips.ts +8 -5
  52. package/.bkit/core/engine/commands/workflow/branches.ts +4 -4
  53. package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
  54. package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
  55. package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
  56. package/.bkit/core/engine/commands/workflow/prs.ts +4 -2
  57. package/.bkit/core/engine/commands/workflow/repo.ts +2 -2
  58. package/.bkit/core/engine/commands/workflow/roadmap.ts +4 -3
  59. package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
  60. package/.bkit/core/engine/commands/workflow/steps.ts +1 -0
  61. package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
  62. package/.bkit/core/engine/commands/workflow/workflows.ts +15 -14
  63. package/.bkit/core/engine/commands/workflow/workstreams.ts +2 -1
  64. package/.bkit/core/engine/commands/workflow/worktrees.ts +13 -5
  65. package/.bkit/core/engine/install/cloud-env.ts +10 -31
  66. package/.bkit/core/engine/install/manifest.ts +14 -7
  67. package/.bkit/core/engine/install/modules/antigravity.ts +15 -26
  68. package/.bkit/core/engine/install/modules/claude.ts +20 -28
  69. package/.bkit/core/engine/install/modules/cloud.ts +5 -2
  70. package/.bkit/core/engine/install/modules/codex.ts +15 -29
  71. package/.bkit/core/engine/install/modules/core.ts +91 -70
  72. package/.bkit/core/engine/install/modules/cursor.ts +6 -20
  73. package/.bkit/core/engine/install/modules/index.ts +7 -1
  74. package/.bkit/core/engine/install/modules/opencode.ts +48 -70
  75. package/.bkit/core/engine/install/network-allowlist.ts +73 -0
  76. package/.bkit/core/engine/install/placeholders.ts +3 -18
  77. package/.bkit/core/engine/install/write.ts +59 -12
  78. package/.bkit/core/engine/ledgers/telemetry.ts +6 -4
  79. package/.bkit/core/engine/render/hosts.ts +47 -67
  80. package/.bkit/core/engine/render/models.ts +29 -11
  81. package/.bkit/core/engine/shared/branches.ts +13 -0
  82. package/.bkit/core/engine/shared/egress.ts +3 -3
  83. package/.bkit/core/engine/shared/json.ts +18 -1
  84. package/.bkit/core/engine/shared/package-json.ts +63 -0
  85. package/.bkit/core/engine/shared/package-roots.ts +0 -10
  86. package/.bkit/core/engine/shared/protected-paths.ts +5 -130
  87. package/.bkit/core/engine/shared/settings.ts +36 -0
  88. package/.bkit/core/hooks/antigravity-hook.js +1 -0
  89. package/.bkit/core/hooks/guardrails-shell.js +186 -40
  90. package/.bkit/core/hooks/guardrails-tiers.js +5 -78
  91. package/.bkit/core/prompts/bkit-audit-generate.md +60 -7
  92. package/.bkit/core/prompts/bkit-build-challenge-1.md +1 -1
  93. package/.bkit/core/prompts/bkit-build-challenge-2.md +1 -1
  94. package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +1 -1
  95. package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -1
  96. package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -1
  97. package/.bkit/core/prompts/bkit-build-install-skills.md +1 -1
  98. package/.bkit/core/prompts/bkit-build-plan-current.md +1 -1
  99. package/.bkit/core/prompts/bkit-build-plan-execute.md +4 -4
  100. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
  101. package/.bkit/core/prompts/bkit-build-plan-verify.md +2 -2
  102. package/.bkit/core/prompts/bkit-debug-abort-handover.md +1 -1
  103. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +1 -1
  104. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
  105. package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +78 -0
  106. package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
  107. package/.bkit/core/prompts/bkit-debug-summary.md +3 -3
  108. package/.bkit/core/prompts/bkit-design-spike.md +1 -1
  109. package/.bkit/core/prompts/bkit-design-summary.md +2 -2
  110. package/.bkit/core/prompts/bkit-design-update.md +1 -1
  111. package/.bkit/core/prompts/bkit-plan-complexity-check.md +1 -1
  112. package/.bkit/core/prompts/bkit-plan-generate.md +1 -1
  113. package/.bkit/core/prompts/bkit-plan-scope-check-1.md +1 -1
  114. package/.bkit/core/prompts/bkit-plan-scope-check-2.md +1 -1
  115. package/.bkit/core/prompts/bkit-plan-summary.md +1 -1
  116. package/.bkit/core/prompts/bkit-plan-update.md +1 -1
  117. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
  118. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +1 -1
  119. package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
  120. package/.bkit/core/prompts/bkit-utility-update-decisions.md +9 -2
  121. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +9 -2
  122. package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
  123. package/.bkit/core/prompts/bkit-utility-update-failures.md +9 -2
  124. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +9 -2
  125. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +11 -4
  126. package/.bkit/core/workflows/bkit-build.md +3 -3
  127. package/.bkit/core/workflows/bkit-debug.md +69 -33
  128. package/.bkit/core/workflows/bkit-design.md +2 -2
  129. package/.bkit/core/workflows/bkit-plan.md +11 -4
  130. package/.bkit/core/workflows/bkit-ship.md +5 -5
  131. package/.bkit/shared/.claude/bkit-cloud.md +46 -13
  132. package/.bkit/shared/.claude/settings.json +18 -0
  133. package/.bkit/shared/.cursor/mcp.json +2 -1
  134. package/.bkit/shared/.opencode/opencode.json +19 -1
  135. package/.bkit/shared/docs/deployments.md +20 -4
  136. package/.bkit/shared/docs/security.md +8 -6
  137. package/.bkit/shared/docs/testing.md +9 -5
  138. package/.bkit/templates/.cursor/Dockerfile +30 -16
  139. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +78 -0
  140. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +91 -0
  141. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +56 -0
  142. package/.bkit/templates/.github/renovate.json5 +91 -12
  143. package/.bkit/templates/.github/workflows/bkit-ci.yml +66 -53
  144. package/.bkit/templates/.github/workflows/bkit-cloud.yml +3 -1
  145. package/.bkit/templates/.github/workflows/bkit-renovate.yml +8 -1
  146. package/.bkit/templates/.github/workflows/bkit-trivy.yml +67 -0
  147. package/.bkit/templates/.husky/pre-push +8 -3
  148. package/.bkit/templates/.oxlintrc.json +21 -0
  149. package/.bkit/templates/docs/capabilities.md +1 -1
  150. package/.bkit/templates/scripts/ci/check-capstone.mjs +176 -0
  151. package/.bkit/templates/scripts/ci/check-capstone.test.mjs +311 -0
  152. package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +2 -2
  153. package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +43 -20
  154. package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +33 -11
  155. package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -2
  156. package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +5 -5
  157. package/.bkit/templates/scripts/graphify/bkit-graphify.sh +79 -19
  158. package/CHANGELOG.md +50 -3
  159. package/README.md +258 -129
  160. package/dist/checks/after/auth.js +10 -11
  161. package/dist/checks/after/ci-yml.js +11 -14
  162. package/dist/checks/after/github.js +32 -125
  163. package/dist/checks/after/index.js +3 -2
  164. package/dist/checks/after/managed.js +8 -24
  165. package/dist/checks/after/tools.js +3 -16
  166. package/dist/checks/before/context-fetch.js +1 -21
  167. package/dist/checks/before/index.js +6 -42
  168. package/dist/checks/before/mcp.js +14 -9
  169. package/dist/checks/before/repo.js +8 -11
  170. package/dist/checks/status-holes.js +5 -6
  171. package/dist/checks/tips/catalogue.js +51 -18
  172. package/dist/checks/tips/detect.js +41 -2
  173. package/dist/checks/tips/index.js +25 -5
  174. package/dist/cli.js +34 -14
  175. package/dist/commands/analysis.js +21 -5
  176. package/dist/commands/comply.js +20 -18
  177. package/dist/commands/harvest.js +12 -13
  178. package/dist/commands/install/doctor.js +55 -23
  179. package/dist/commands/install/install.js +62 -118
  180. package/dist/commands/install/uninstall.js +165 -31
  181. package/dist/commands/install/upgrade.js +46 -39
  182. package/dist/commands/lib.js +32 -10
  183. package/dist/commands/tips.js +6 -3
  184. package/dist/commands/workflow/branches.js +3 -5
  185. package/dist/commands/workflow/counters.js +17 -7
  186. package/dist/commands/workflow/fids.js +39 -0
  187. package/dist/commands/workflow/ledgers.js +3 -1
  188. package/dist/commands/workflow/prs.js +3 -3
  189. package/dist/commands/workflow/repo.js +2 -2
  190. package/dist/commands/workflow/roadmap.js +4 -4
  191. package/dist/commands/workflow/runs.js +5 -5
  192. package/dist/commands/workflow/steps.js +1 -0
  193. package/dist/commands/workflow/tests.js +16 -3
  194. package/dist/commands/workflow/workflows.js +15 -15
  195. package/dist/commands/workflow/workstreams.js +2 -1
  196. package/dist/commands/workflow/worktrees.js +4 -5
  197. package/dist/install/cloud-env.js +10 -23
  198. package/dist/install/manifest.js +14 -7
  199. package/dist/install/modules/antigravity.js +15 -26
  200. package/dist/install/modules/claude.js +17 -21
  201. package/dist/install/modules/cloud.js +6 -2
  202. package/dist/install/modules/codex.js +15 -29
  203. package/dist/install/modules/core.js +82 -63
  204. package/dist/install/modules/cursor.js +6 -9
  205. package/dist/install/modules/index.js +6 -1
  206. package/dist/install/modules/opencode.js +41 -72
  207. package/dist/install/network-allowlist.js +62 -0
  208. package/dist/install/placeholders.js +3 -16
  209. package/dist/install/write.js +55 -15
  210. package/dist/ledgers/telemetry.js +5 -4
  211. package/dist/render/hosts.js +30 -55
  212. package/dist/render/models.js +20 -9
  213. package/dist/shared/branches.js +11 -0
  214. package/dist/shared/egress.js +0 -2
  215. package/dist/shared/json.js +14 -0
  216. package/dist/shared/package-json.js +61 -0
  217. package/dist/shared/package-roots.js +0 -8
  218. package/dist/shared/protected-paths.js +5 -122
  219. package/dist/shared/settings.js +18 -1
  220. package/package.json +21 -17
  221. package/.bkit/core/.agents/shortcuts.md +0 -73
@@ -47,6 +47,23 @@ export function logged(root, issue) {
47
47
  }
48
48
  return [...found].sort();
49
49
  }
50
+ /**
51
+ * The canonical design doc for a feature, `docs/plans/{YYYYMM}/{fid}-design.md`: the
52
+ * `month` bucket first, else the newest bucket holding one. null when none exists.
53
+ */
54
+ export function designDoc(root, fid, month) {
55
+ const plans = path.join(root, "docs", "plans");
56
+ if (!fs.existsSync(plans))
57
+ return null;
58
+ const at = (m) => fs.existsSync(path.join(plans, m, `${fid}-design.md`));
59
+ const months = fs
60
+ .readdirSync(plans)
61
+ .filter((m) => /^[0-9]{6}$/.test(m))
62
+ .sort()
63
+ .reverse();
64
+ const hit = month !== undefined && months.includes(month) && at(month) ? month : months.find(at);
65
+ return hit === undefined ? null : { month: hit, path: `docs/plans/${hit}/${fid}-design.md` };
66
+ }
50
67
  /** `package.json` `bkit.issueTracker` at the main checkout (cwd outside git); default `none`. */
51
68
  export function readIssueTracker(cwd) {
52
69
  const common = git(cwd, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
@@ -195,6 +212,28 @@ export const fidsCommand = {
195
212
  return EXIT.OK;
196
213
  },
197
214
  },
215
+ design: {
216
+ summary: "The feature's own design doc, docs/plans/{YYYYMM}/{FID}-design.md: exit 0 found, exit 1 none.",
217
+ flags: [
218
+ { name: "fid", type: "string", required: true, help: "feature id" },
219
+ {
220
+ name: "month",
221
+ type: "string",
222
+ help: "YYYYMM bucket checked first; else the newest bucket holding the doc",
223
+ },
224
+ ],
225
+ output: {
226
+ fid: "the FID when its design doc exists, else null",
227
+ month: "the bucket holding it, else null",
228
+ path: "repo-relative path, else null",
229
+ },
230
+ run: (ctx) => {
231
+ const fid = String(ctx.flags.fid);
232
+ const hit = designDoc(repoRoot(ctx.cwd), fid, str(ctx.flags.month));
233
+ ctx.emit(hit ? { fid, month: hit.month, path: hit.path } : { fid: null, month: null, path: null });
234
+ return hit ? EXIT.OK : EXIT.NO;
235
+ },
236
+ },
198
237
  find: {
199
238
  summary: "The feature already logged for an issue: exit 0 one, exit 1 none, exit 4 several.",
200
239
  flags: [
@@ -68,7 +68,9 @@ function gitRaw(cwd, args) {
68
68
  env: gitEnv(),
69
69
  maxBuffer: 1 << 28,
70
70
  });
71
- return { status: res.status, stdout: res.stdout ?? "", stderr: (res.stderr ?? "").trim() };
71
+ // A spawn error is never a success: the child can exit 0 before ENOBUFS kills it.
72
+ const status = res.error && res.status === 0 ? 1 : res.status;
73
+ return { status, stdout: res.stdout ?? "", stderr: (res.stderr ?? "").trim() };
72
74
  }
73
75
  const nulList = (out) => out.split("\0").filter((p) => p !== "");
74
76
  function requireRepo(root) {
@@ -10,7 +10,7 @@ import * as fs from "node:fs";
10
10
  import * as path from "node:path";
11
11
  import { readBkitConfig } from "../../shared/settings.js";
12
12
  import { appendLine, statusTimestamp } from "../../ledgers/status.js";
13
- import { bodySkipToken, CommandError, EXIT, ghUnavailable, git, parseJson, repoRoot, runGh, runGit, SKIP_CI_TOKEN, } from "../lib.js";
13
+ import { bodySkipToken, CommandError, DEV, EXIT, ghUnavailable, git, isSharedBranch, parseJson, repoRoot, runGh, runGit, SKIP_CI_TOKEN, } from "../lib.js";
14
14
  import { AUTO_LABEL, AUTO_ROUTE_SUFFIX } from "./issues.js";
15
15
  import { EXIT_NO_STATUS, FILE_FLAG, readStatusRows, statusFile, str } from "./status.js";
16
16
  // ---------------------------------------------------------------------------
@@ -161,9 +161,9 @@ export function openPrFor(cwd, o, log) {
161
161
  log(`refusing: PR title carries the CI-suppressing token ${token[0]} — CI would never run`);
162
162
  return { code: EXIT_SKIP_CI_TITLE, out: null };
163
163
  }
164
- const base = refFlag(o.base ?? "dev", "base");
164
+ const base = refFlag(o.base ?? DEV, "base");
165
165
  const head = o.head === undefined ? currentBranch(cwd) : refFlag(o.head, "head");
166
- if (head === base || head === "dev" || head === "main") {
166
+ if (head === base || isSharedBranch(head)) {
167
167
  throw new CommandError(EXIT.USAGE, `refusing to open a PR from "${head}" into "${base}"`);
168
168
  }
169
169
  let plan = o.plan;
@@ -9,7 +9,7 @@
9
9
  import * as fs from "node:fs";
10
10
  import * as path from "node:path";
11
11
  import { parseRemoteUrlToSlug } from "../../ledgers/telemetry.js";
12
- import { EXIT, git, repoRoot, runGit, runTool } from "../lib.js";
12
+ import { DEV, EXIT, git, repoRoot, runGit, runTool } from "../lib.js";
13
13
  import { bkitVersionStatus } from "../../shared/bkit-latest.js";
14
14
  /** Exit code: neither gh nor the origin remote named an owner/repo. */
15
15
  export const EXIT_NO_REPO = 3;
@@ -119,7 +119,7 @@ export const repoCommand = {
119
119
  },
120
120
  run: (ctx) => {
121
121
  if (ctx.flags.fetch === true) {
122
- const res = runGit(ctx.cwd, ["fetch", "origin", "dev"]);
122
+ const res = runGit(ctx.cwd, ["fetch", "origin", DEV]);
123
123
  if (!res.ok)
124
124
  ctx.log(`git fetch origin dev failed — behindDev is as of the last fetch: ${res.stderr}`);
125
125
  }
@@ -18,7 +18,7 @@ import * as fs from "node:fs";
18
18
  import * as path from "node:path";
19
19
  import { compareTs, parse, resolveRepoSlug, validate } from "../../ledgers/telemetry.js";
20
20
  import { readBkitVersion } from "../../install/version-file.js";
21
- import { CommandError, EXIT, git, parseJson, repoRoot, runGit, } from "../lib.js";
21
+ import { CommandError, DEV, EXIT, git, parseJson, repoRoot, runGit, } from "../lib.js";
22
22
  import { acquireDevLock, releaseLock } from "./locks.js";
23
23
  import { str } from "./status.js";
24
24
  /** Roadmap status each workflow's close moves the feature to. */
@@ -374,8 +374,8 @@ async function mirror(ctx) {
374
374
  }
375
375
  try {
376
376
  const prior = git(root, ["branch", "--show-current"]) ?? "";
377
- if (!runGit(root, ["checkout", "dev"]).ok ||
378
- !runGit(root, ["pull", "--ff-only", "origin", "dev"]).ok) {
377
+ if (!runGit(root, ["checkout", DEV]).ok ||
378
+ !runGit(root, ["pull", "--ff-only", "origin", DEV]).ok) {
379
379
  if (prior)
380
380
  runGit(root, ["checkout", prior]);
381
381
  return done(false, "dev checkout / pull failed");
@@ -392,7 +392,7 @@ async function mirror(ctx) {
392
392
  "--",
393
393
  ...ROADMAP_FILES,
394
394
  ]);
395
- const pushed = runGit(root, ["push", "origin", "dev"]).ok;
395
+ const pushed = runGit(root, ["push", "origin", DEV]).ok;
396
396
  if (!pushed)
397
397
  ctx.log("dev push failed — feat-side row already written");
398
398
  if (prior)
@@ -22,7 +22,7 @@
22
22
  import * as fs from "node:fs";
23
23
  import * as path from "node:path";
24
24
  import { statusTimestamp } from "../../ledgers/status.js";
25
- import { bodySkipToken, commitMessage, CommandError, EXIT, git, parseJson, runGh, runGit, SKIP_CI_TOKEN, } from "../lib.js";
25
+ import { bodySkipToken, commitMessage, CommandError, DEV, EXIT, git, isSharedBranch, parseJson, runGh, runGit, SKIP_CI_TOKEN, } from "../lib.js";
26
26
  import { readBkitConfig } from "../../shared/settings.js";
27
27
  import { TIMEOUTS } from "../../shared/timeouts.js";
28
28
  import { FID_PATTERNS, fromBranch, fromMarker, issueIdOf, readIssueTracker } from "./fids.js";
@@ -171,7 +171,7 @@ function currentPr(cwd, gh) {
171
171
  const branch = git(cwd, ["branch", "--show-current"]);
172
172
  if (!branch)
173
173
  return { pr: null, missing: false };
174
- const res = gh(["pr", "list", "--head", branch, "--base", "dev", "--json", "number"]);
174
+ const res = gh(["pr", "list", "--head", branch, "--base", DEV, "--json", "number"]);
175
175
  if (res.missing)
176
176
  return { pr: null, missing: true };
177
177
  const n = obj(arr(res.ok ? jsonOrUndefined(res.stdout) : undefined)[0]).number;
@@ -184,7 +184,7 @@ function pushCurrentBranch(cwd) {
184
184
  if (!branch)
185
185
  return false;
186
186
  // Shared branches never force; a feature branch is rewritten only by this run.
187
- const args = branch === "dev" || branch === "main"
187
+ const args = isSharedBranch(branch)
188
188
  ? ["push", "origin", branch]
189
189
  : ["push", "--force-with-lease", "origin", branch];
190
190
  return runGit(cwd, args).ok;
@@ -1324,7 +1324,7 @@ async function runContext(ctx) {
1324
1324
  mode: "CI_DEV",
1325
1325
  fid: arg,
1326
1326
  issueId: tracker === "none" ? null : issueIdOf(arg, "any"),
1327
- branch: "dev",
1327
+ branch: DEV,
1328
1328
  headSha: git(ctx.cwd, ["rev-parse", "origin/dev"]) ?? "",
1329
1329
  });
1330
1330
  return EXIT.OK;
@@ -1395,7 +1395,7 @@ async function runContext(ctx) {
1395
1395
  async function runMirror(ctx) {
1396
1396
  const f = ctx.flags;
1397
1397
  const head = String(f.head);
1398
- const branch = str(f.branch) ?? "dev";
1398
+ const branch = str(f.branch) ?? DEV;
1399
1399
  if (!branch)
1400
1400
  throw new CommandError(EXIT.USAGE, "--branch must not be empty");
1401
1401
  const o = {
@@ -242,6 +242,7 @@ export const ROW_FIELDS = {
242
242
  "build/build-summary": ["attempt"],
243
243
  "debug/debug-run-tests": ["attempt", "scope"],
244
244
  "debug/context-fetch": ["attempt"],
245
+ "debug/debug-failure-reproduce": ["attempt"],
245
246
  "debug/debug-failure-diagnose": ["attempt", "strategy"],
246
247
  "debug/debug-failure-remediate": ["attempt", "strategy"],
247
248
  "debug/debug-failure-soak": ["attempt"],
@@ -491,6 +491,11 @@ export const testsCommand = {
491
491
  repeatable: true,
492
492
  help: "candidate plan file; the first that exists is audited",
493
493
  },
494
+ {
495
+ name: "brief",
496
+ type: "string",
497
+ help: "the build input, audited when no plan file exists and it carries `**Task N:**` lines with `Test first:`",
498
+ },
494
499
  {
495
500
  name: "log",
496
501
  type: "string",
@@ -501,7 +506,7 @@ export const testsCommand = {
501
506
  output: {
502
507
  enforced: "false when there is nothing to audit (reason says why)",
503
508
  reason: "why test-first is not enforced",
504
- plan: "the plan file audited",
509
+ plan: "the plan file audited (the brief when no plan file exists and it carries Test first lines)",
505
510
  gaps: "[{task, kind, detail}]: no-test-first | test-first-malformed | no-red | red-mismatch | red-evidence-missing | test-changed | not-green",
506
511
  log: "where the report was written (as given)",
507
512
  },
@@ -516,14 +521,22 @@ export const testsCommand = {
516
521
  throw new CommandError(EXIT.USAGE, "--log must be non-empty");
517
522
  const log = path.resolve(ctx.cwd, logArg);
518
523
  const top = toplevel(ctx.cwd);
519
- const plan = ctx.flags.plan.find((p) => fs.existsSync(path.resolve(ctx.cwd, p)));
524
+ const exists = (p) => fs.existsSync(path.resolve(ctx.cwd, p));
525
+ const planFile = ctx.flags.plan.find(exists);
526
+ const briefArg = str(ctx.flags.brief);
527
+ const brief = planFile === undefined && briefArg !== undefined && exists(briefArg)
528
+ ? briefArg
529
+ : undefined;
530
+ const plan = planFile ?? brief;
520
531
  const specs = plan
521
532
  ? readTestFirst(fs.readFileSync(path.resolve(ctx.cwd, plan), "utf-8"))
522
533
  : [];
523
534
  const reason = plan === undefined
524
535
  ? "no plan file — the build runs from its brief"
525
536
  : !specs.some((s) => s.kind !== "missing")
526
- ? "the plan has no `Test first:` lines"
537
+ ? brief !== undefined
538
+ ? "no plan file, and the brief has no `**Task N:**` lines with `Test first:`"
539
+ : "the plan has no `Test first:` lines"
527
540
  : resolveGate(top, [BKIT_TEST_FILE_SCRIPT]) === null
528
541
  ? `\`${BKIT_TEST_FILE_SCRIPT}\` is not declared in package.json`
529
542
  : undefined;
@@ -24,7 +24,7 @@ import { appendLine as telemetryLine, foldFrom, resolveRepoSlug, validate, workf
24
24
  import { readBkitVersion } from "../../install/version-file.js";
25
25
  import { TIMEOUTS } from "../../shared/timeouts.js";
26
26
  import { gradeCompliance } from "../comply.js";
27
- import { CommandError, EXIT, git, parseJson, repoRoot, runGh, runGit, statusLocation, statusRelPath, } from "../lib.js";
27
+ import { CommandError, DEV, EXIT, git, parseJson, repoRoot, runGh, runGit, statusLocation, statusRelPath, } from "../lib.js";
28
28
  import { anchorBkitStatus, pushBranch, readAnchor, stampAnchor } from "./branches.js";
29
29
  import { AUTO_LABEL, AUTO_ROUTE_SUFFIX, buildComment, linearState, transitionLabels, } from "./issues.js";
30
30
  import { EXIT_EMPTY, commitBookkeeping, unionLedgers } from "./ledgers.js";
@@ -261,15 +261,15 @@ async function shipFlush(ctx, o) {
261
261
  return { code: EXIT.OK, pushed: false, ref: null, skipped: "dev-lock-busy" };
262
262
  }
263
263
  release = () => releaseLock(lock.path, { workflow: "ship", fid: o.fid, token: lock.token });
264
- runGit(root, ["checkout", "dev"]);
265
- if (git(root, ["branch", "--show-current"]) !== "dev") {
264
+ runGit(root, ["checkout", DEV]);
265
+ if (git(root, ["branch", "--show-current"]) !== DEV) {
266
266
  release();
267
267
  ctx.log(`not on dev after checkout — FAILED bookkeeping left uncommitted in ${bookRoot}`);
268
268
  return { code: EXIT_FLUSH_FAILED, pushed: false, ref: null, skipped: null };
269
269
  }
270
- runGit(root, ["pull", "--ff-only", "origin", "dev"]);
270
+ runGit(root, ["pull", "--ff-only", "origin", DEV]);
271
271
  wt = root;
272
- target = "dev";
272
+ target = DEV;
273
273
  }
274
274
  else {
275
275
  ctx.log("RUNTIME_DEVPUSHES=false — the FAILED record commits on the current branch");
@@ -615,7 +615,7 @@ export function closeWorkflow(cwd, o, log) {
615
615
  : ["[bkit-telemetry] stats.jsonl not found — no telemetry rows yet"];
616
616
  const ref = o.ref ??
617
617
  (["design", "plan", "ship"].includes(workflow)
618
- ? "dev"
618
+ ? DEV
619
619
  : (git(cwd, ["branch", "--show-current"]) ?? "HEAD"));
620
620
  const artifacts = artifactLinks(where.root, ref, where.month, o.fid, workflow, o.ownerRepo ?? repo);
621
621
  let comment = null;
@@ -698,8 +698,8 @@ async function shipClose(ctx, o, token) {
698
698
  try {
699
699
  let wt;
700
700
  if (o.devPushes) {
701
- runGit(root, ["checkout", "dev"]);
702
- if (git(root, ["branch", "--show-current"]) !== "dev")
701
+ runGit(root, ["checkout", DEV]);
702
+ if (git(root, ["branch", "--show-current"]) !== DEV)
703
703
  return fail("not on dev after checkout — aborting dev ops");
704
704
  wt = root;
705
705
  }
@@ -712,7 +712,7 @@ async function shipClose(ctx, o, token) {
712
712
  closeRoot = wt;
713
713
  }
714
714
  else {
715
- if (!runGit(wt, ["fetch", "origin", "dev"]).ok)
715
+ if (!runGit(wt, ["fetch", "origin", DEV]).ok)
716
716
  return fail(`fetch origin dev failed — close bookkeeping left uncommitted in ${wt}`);
717
717
  closeRoot = path.join(outbox, "close");
718
718
  if (fs.existsSync(closeRoot))
@@ -734,11 +734,11 @@ async function shipClose(ctx, o, token) {
734
734
  if (released.removeFailed)
735
735
  return fail("Lock removal failed");
736
736
  if (o.devPushes) {
737
- if (!runGit(closeRoot, ["push", "origin", "dev"]).ok) {
737
+ if (!runGit(closeRoot, ["push", "origin", DEV]).ok) {
738
738
  ctx.log("dev push failed");
739
739
  return { code: EXIT_PUSH_FAILED, out };
740
740
  }
741
- landed = { ref: "dev", via: "dev-push" };
741
+ landed = { ref: DEV, via: "dev-push" };
742
742
  }
743
743
  }
744
744
  finally {
@@ -746,7 +746,7 @@ async function shipClose(ctx, o, token) {
746
746
  }
747
747
  if (!o.devPushes) {
748
748
  if (runGit(closeRoot, ["push", "origin", "HEAD:dev"]).ok) {
749
- landed = { ref: "dev", via: "head-push" };
749
+ landed = { ref: DEV, via: "head-push" };
750
750
  }
751
751
  else {
752
752
  // dev refused the push: publish the close commit through its own PR.
@@ -758,7 +758,7 @@ async function shipClose(ctx, o, token) {
758
758
  "pr",
759
759
  "create",
760
760
  "--base",
761
- "dev",
761
+ DEV,
762
762
  "--head",
763
763
  branch,
764
764
  "--title",
@@ -768,7 +768,7 @@ async function shipClose(ctx, o, token) {
768
768
  ]);
769
769
  if (!created.ok)
770
770
  return fail(`gh pr create failed: ${created.stderr}`);
771
- const pr = probePr(closeRoot, { head: branch, base: "dev", state: "open" });
771
+ const pr = probePr(closeRoot, { head: branch, base: DEV, state: "open" });
772
772
  const number = pr.kind === "ok" ? pr.pr?.number : undefined;
773
773
  if (number === undefined)
774
774
  return fail(`close PR not found for ${branch}`);
@@ -1317,7 +1317,7 @@ export const workflowsCommand = {
1317
1317
  const fid = String(ctx.flags.fid);
1318
1318
  const root = repoRoot(ctx.cwd);
1319
1319
  const month = resolveMonth(root, fid, str(ctx.flags.month));
1320
- const artifacts = artifactLinks(root, str(ctx.flags.ref) ?? "dev", month, fid, workflow, str(ctx.flags.ownerRepo) ?? (resolveRepoSlug(root) || "unknown/repo"));
1320
+ const artifacts = artifactLinks(root, str(ctx.flags.ref) ?? DEV, month, fid, workflow, str(ctx.flags.ownerRepo) ?? (resolveRepoSlug(root) || "unknown/repo"));
1321
1321
  let comment = null;
1322
1322
  const outbox = str(ctx.flags.outbox);
1323
1323
  if (outbox !== undefined) {
@@ -70,7 +70,7 @@ 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
76
  return [
@@ -78,6 +78,7 @@ export function commentBody(ws, opts) {
78
78
  "### Step 11 — Suggested Workstreams",
79
79
  "Advisory only. NEVER auto-trigger.",
80
80
  ...ws.map((w) => `- ${w.id}: ${w.name}. Requires: ${requiresList(w)}`),
81
+ `Filing one issue per workstream: put \`**Parent design:** [${opts.fid}-design.md](${doc})\` in its body, and list the issues it requires in a blocked-by block (.bkit/trackers.md § Issue shapes).`,
81
82
  `[${doc}](https://github.com/${opts.ownerRepo}/blob/dev/${doc})`,
82
83
  ].join("\n");
83
84
  }
@@ -15,11 +15,10 @@ 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
19
  import { detect } from "./runtime.js";
20
20
  import { WORKFLOW_FLAG } from "./status.js";
21
21
  const WORKFLOWS = ["design", "plan", "build", "debug", "ship"];
22
- const DEV = "dev";
23
22
  const ORIGIN_DEV = `origin/${DEV}`;
24
23
  export const EXIT_REBASE_CONFLICT = 3;
25
24
  export const EXIT_FETCH = 4;
@@ -90,7 +89,7 @@ function shipBranch(root, fid, named, session) {
90
89
  const feat = `feat/${fid}`;
91
90
  if (hasLocal(root, feat) || remoteHas(root, feat) === "yes")
92
91
  return feat;
93
- return session === DEV || session === "main" || session === "" ? feat : session;
92
+ return isSharedBranch(session) || session === "" ? feat : session;
94
93
  }
95
94
  /**
96
95
  * `git worktree add` for `branch`: the local branch, else a tracking branch off
@@ -215,7 +214,7 @@ function deleteBranch(root, branch, log) {
215
214
  * worktree holds it. Throws EXIT_REMOVE when `git worktree remove` fails.
216
215
  */
217
216
  export function removeWorktree(cwd, fid, branch, log) {
218
- if (branch !== undefined && (branch === DEV || branch === "main")) {
217
+ if (branch !== undefined && isSharedBranch(branch)) {
219
218
  throw new CommandError(EXIT.USAGE, `refusing to delete branch ${branch}`);
220
219
  }
221
220
  const root = repoRoot(cwd);
@@ -328,7 +327,7 @@ export const worktreesCommand = {
328
327
  throw new CommandError(EXIT_REFUSED, "detached HEAD — check out a branch before debugging");
329
328
  }
330
329
  const target = workflow === "ship" ? shipBranch(root, fid, named, session) : `feat/${fid}`;
331
- if (target === DEV || target === "main") {
330
+ if (isSharedBranch(target)) {
332
331
  throw new CommandError(EXIT_REFUSED, `refusing to ship ${target} as a feature branch`);
333
332
  }
334
333
  // Ship mints only when the session is not already on the branch it ships:
@@ -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;