@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
@@ -1,7 +1,7 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
- import { execSync } from "node:child_process";
4
- import { getPkgRoot } from "../shared/package-roots.js";
3
+ import { spawnSync } from "node:child_process";
4
+ import { readInstallingVersion } from "../shared/package-json.js";
5
5
  import { managedVersionMarker } from "./version-file.js";
6
6
  import { gitEnv, resolveRepoSlug } from "../ledgers/telemetry.js";
7
7
 
@@ -18,38 +18,19 @@ export interface TokenMap {
18
18
  BKIT_VERSION?: string;
19
19
  }
20
20
 
21
- // Read the INSTALLING bkit version from the package root (NOT the consumer's
22
- // package.json — that is a different version). Mirrors readInstallingVersion
23
- // (install/modules/index.ts) / readPkgVersion (checks/after/index.ts); kept local to avoid a
24
- // tokens → modules import cycle. "0.0.0" on any read failure.
25
- function readInstallingBkitVersion(): string {
26
- try {
27
- const pkg = JSON.parse(fs.readFileSync(path.join(getPkgRoot(), "package.json"), "utf-8")) as {
28
- version?: string;
29
- };
30
- return pkg.version ?? "0.0.0";
31
- } catch {
32
- return "0.0.0";
33
- }
34
- }
35
-
36
- // Resolve DEFAULT_BRANCH: git symbolic-ref refs/remotes/origin/HEAD → "main"
21
+ // Resolve DEFAULT_BRANCH, the production branch: refs/remotes/origin/HEAD, else "main".
22
+ // `dev` is bkit's integration branch, never production, so a remote whose default is `dev`
23
+ // also gets "main" — and renders the same bytes as a checkout with no origin/HEAD.
37
24
  function resolveDefaultBranch(cwd: string): string {
38
- try {
39
- const raw = execSync("git symbolic-ref refs/remotes/origin/HEAD", {
40
- cwd,
41
- encoding: "utf-8",
42
- stdio: ["ignore", "pipe", "ignore"],
43
- env: gitEnv(),
44
- }).trim();
45
- // raw is like "refs/remotes/origin/main"
46
- const parts = raw.split("/");
47
- const branch = parts[parts.length - 1];
48
- if (branch) return branch;
49
- } catch {
50
- // not a git repo or no remote HEAD configured — fall back
51
- }
52
- return "main";
25
+ const res = spawnSync("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], {
26
+ cwd,
27
+ encoding: "utf-8",
28
+ stdio: ["ignore", "pipe", "ignore"],
29
+ env: gitEnv(),
30
+ });
31
+ // stdout is like "refs/remotes/origin/main"; empty when not a git repo or no remote HEAD.
32
+ const branch = res.status === 0 ? res.stdout.trim().replace(/^refs\/remotes\/origin\//, "") : "";
33
+ return branch === "" || branch === "dev" ? "main" : branch;
53
34
  }
54
35
 
55
36
  // Read and parse package.json from cwd. Throws if absent.
@@ -78,7 +59,7 @@ export async function resolveTokens(cwd: string): Promise<TokenMap> {
78
59
  DEFAULT_BRANCH: resolveDefaultBranch(cwd),
79
60
  PROJECT_NAME: name.trim(),
80
61
  REPO_SLUG: resolveRepoSlug(cwd),
81
- BKIT_VERSION: readInstallingBkitVersion(),
62
+ BKIT_VERSION: readInstallingVersion(),
82
63
  };
83
64
  }
84
65
 
@@ -99,7 +80,7 @@ export function applyTokens(content: string, tokens: TokenMap): string {
99
80
  // so `# {{BKIT_MANAGED_MARKER}}` yields the hash form. The version is read from the
100
81
  // package only when the token is present and the TokenMap omits BKIT_VERSION.
101
82
  if (out.includes("{{BKIT_MANAGED_MARKER}}")) {
102
- const version = tokens.BKIT_VERSION ?? readInstallingBkitVersion();
83
+ const version = tokens.BKIT_VERSION ?? readInstallingVersion();
103
84
  out = out
104
85
  .replace(/^\/\/ \{\{BKIT_MANAGED_MARKER\}\}/gm, () => managedVersionMarker(version, "slash"))
105
86
  .replace(/\{\{BKIT_MANAGED_MARKER\}\}/g, () => managedVersionMarker(version, "html"));
@@ -10,6 +10,7 @@ import {
10
10
  type MarkerStyle,
11
11
  } from "./managed-block.js";
12
12
  import { readTemplate } from "../render/parts.js";
13
+ import { parseJson } from "../shared/json.js";
13
14
  import { applyTokens, type TokenMap } from "./placeholders.js";
14
15
  import { sha256 } from "./version-file.js";
15
16
 
@@ -196,6 +197,55 @@ export function deepMergeJson(base: JsonValue, override: JsonValue): JsonValue {
196
197
  return result;
197
198
  }
198
199
 
200
+ // ---------------------------------------------------------------------------
201
+ // MCP tracker entry — bkit owns the template's parts of the entry, not the whole entry (#613)
202
+ //
203
+ // - every key the template sets is reset to the template's value
204
+ // - `headers["X-MCP-Toolsets"]` keeps the consumer's list and appends any template toolset
205
+ // it lacks, so a consumer can enable extra toolsets and a toolset bkit adds still lands
206
+ // - every other consumer key, header and toolset is kept
207
+ // ---------------------------------------------------------------------------
208
+
209
+ export const MCP_TOOLSETS_HEADER = "X-MCP-Toolsets";
210
+
211
+ /** Split an `X-MCP-Toolsets` value into toolset names (trimmed, empties dropped). */
212
+ export function parseToolsets(value: string): string[] {
213
+ return value
214
+ .split(",")
215
+ .map((s) => s.trim())
216
+ .filter((s) => s !== "");
217
+ }
218
+
219
+ /** True for a JSON object (not null, not an array). */
220
+ export function isJsonObject(v: JsonValue | undefined): v is { [k: string]: JsonValue } {
221
+ return v !== null && typeof v === "object" && !Array.isArray(v);
222
+ }
223
+
224
+ /** Merge bkit's tracker entry `owned` into the consumer's `existing` entry (rules above). */
225
+ export function mergeTrackerEntry(existing: JsonValue | undefined, owned: JsonValue): JsonValue {
226
+ if (!isJsonObject(existing) || !isJsonObject(owned)) return owned;
227
+ const merged = deepMergeJson(existing, owned) as { [k: string]: JsonValue };
228
+ const ownedHeaders = owned.headers;
229
+ const existingHeaders = existing.headers;
230
+ if (isJsonObject(ownedHeaders) && isJsonObject(existingHeaders)) {
231
+ const ownedSets = ownedHeaders[MCP_TOOLSETS_HEADER];
232
+ const existingSets = existingHeaders[MCP_TOOLSETS_HEADER];
233
+ if (typeof ownedSets === "string" && typeof existingSets === "string") {
234
+ const have = parseToolsets(existingSets);
235
+ const missing = parseToolsets(ownedSets).filter((t) => !have.includes(t));
236
+ (merged.headers as { [k: string]: JsonValue })[MCP_TOOLSETS_HEADER] =
237
+ missing.length === 0 ? existingSets : [...have, ...missing].join(",");
238
+ }
239
+ }
240
+ return merged;
241
+ }
242
+
243
+ /** True when `existing` already holds everything `mergeTrackerEntry` would write. */
244
+ export function trackerEntryInSync(existing: JsonValue | undefined, owned: JsonValue): boolean {
245
+ if (existing === undefined) return false;
246
+ return deepContains(mergeTrackerEntry(existing, owned), existing).ok;
247
+ }
248
+
199
249
  // ---------------------------------------------------------------------------
200
250
  // writeTier2JsonContained — deep-containment JSON helper (BAR-167 Phase 1)
201
251
  //
@@ -215,12 +265,11 @@ export function writeTier2JsonContained(
215
265
  ws: WriteSet,
216
266
  ): void {
217
267
  const srcRaw = fs.readFileSync(srcPath, "utf-8");
218
- let template: Record<string, JsonValue>;
219
- try {
220
- template = JSON.parse(srcRaw) as Record<string, JsonValue>;
221
- } catch {
268
+ const templateRead = parseJson(srcRaw);
269
+ if (!templateRead.ok) {
222
270
  throw new Error(`writeTier2JsonContained: template at ${srcPath} is not valid JSON`);
223
271
  }
272
+ const template = templateRead.value as Record<string, JsonValue>;
224
273
 
225
274
  if (!fs.existsSync(dstPath)) {
226
275
  // First install — write template as-is
@@ -236,15 +285,14 @@ export function writeTier2JsonContained(
236
285
 
237
286
  // dest exists — read and check containment
238
287
  const dstRaw = fs.readFileSync(dstPath, "utf-8");
239
- let existing: Record<string, JsonValue>;
240
- try {
241
- existing = JSON.parse(dstRaw) as Record<string, JsonValue>;
242
- } catch {
288
+ const existingRead = parseJson(dstRaw);
289
+ if (!existingRead.ok) {
243
290
  // Malformed destination — refuse to overwrite; require manual fix (matches malformed-package-json blocker discipline)
244
291
  throw new Error(
245
292
  `[bkit] ${dstPath} is malformed JSON — fix manually before running bkit install`,
246
293
  );
247
294
  }
295
+ const existing = existingRead.value as Record<string, JsonValue>;
248
296
 
249
297
  // Check if existing already contains the template
250
298
  const containsResult = deepContains(template as JsonValue, existing as JsonValue);
@@ -485,12 +533,11 @@ export function ensurePackageJsonScripts(
485
533
  return { added: [], preserved: [], missingPkg: true, malformed: false };
486
534
  }
487
535
  const raw = fs.readFileSync(pkgPath, "utf-8");
488
- let pkg: Record<string, unknown>;
489
- try {
490
- pkg = JSON.parse(raw) as Record<string, unknown>;
491
- } catch {
536
+ const parsed = parseJson(raw);
537
+ if (!parsed.ok) {
492
538
  return { added: [], preserved: [], missingPkg: false, malformed: true };
493
539
  }
540
+ const pkg = parsed.value as Record<string, unknown>;
494
541
 
495
542
  let pkgScripts = (pkg.scripts as Record<string, string> | undefined) ?? undefined;
496
543
  const added: string[] = [];
@@ -20,6 +20,8 @@
20
20
  import { spawnSync } from "node:child_process";
21
21
  import * as fs from "node:fs";
22
22
 
23
+ import { parseJson } from "../shared/json.js";
24
+
23
25
  // ---------------------------------------------------------------------------
24
26
  // Constants
25
27
  // ---------------------------------------------------------------------------
@@ -814,10 +816,10 @@ export function parse(raw: string): ParseResult {
814
816
  for (const line of lines) {
815
817
  const trimmed = line.trim();
816
818
  if (trimmed === "") continue;
817
- try {
818
- const obj = JSON.parse(trimmed);
819
- result.events.push(obj as TelemetryEvent);
820
- } catch {
819
+ const obj = parseJson(trimmed);
820
+ if (obj.ok) {
821
+ result.events.push(obj.value as TelemetryEvent);
822
+ } else {
821
823
  result.malformedLineCount++;
822
824
  }
823
825
  }
@@ -105,24 +105,9 @@ export function applyOpencodeAgent(
105
105
  effortMap?: EffortMap,
106
106
  provider?: string,
107
107
  ): string {
108
- const fmMatch = content.match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/);
109
- if (!fmMatch) return content;
110
-
111
- const fmBlock = fmMatch[2];
112
- const afterFm = content.slice(fmMatch[0].length);
113
- const parsed = parseFrontmatter(fmBlock);
114
-
115
- const name = parsed.get("name") ?? "";
116
- if (!name) {
117
- console.error(`${LOG_PREFIX} Subagent frontmatter missing 'name' field`);
118
- process.exit(1);
119
- }
120
-
121
- const opencodeModel = opencodeModelLookup.get(name);
122
- if (!opencodeModel) {
123
- console.error(`${LOG_PREFIX} Missing opencode model lookup for ${name}`);
124
- process.exit(1);
125
- }
108
+ const subagent = requireSubagentModel(content, opencodeModelLookup, "opencode");
109
+ if (!subagent) return content;
110
+ const { fmBlock, afterFm, parsed, name, model: opencodeModel } = subagent;
126
111
 
127
112
  const description = parsed.get("description") ?? "";
128
113
  const effort = parsed.get("effort");
@@ -212,24 +197,10 @@ export function applyCodexAgent(
212
197
  codexModelLookup: Map<string, string>,
213
198
  effortMap?: EffortMap,
214
199
  ): string {
215
- const fmMatch = content.match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/);
216
- if (!fmMatch) return content;
217
-
218
- const fmBlock = fmMatch[2];
219
- const body = content.slice(fmMatch[0].length).trim();
220
- const parsed = parseFrontmatter(fmBlock);
221
-
222
- const name = parsed.get("name") ?? "";
223
- if (!name) {
224
- console.error(`${LOG_PREFIX} Subagent frontmatter missing 'name' field`);
225
- process.exit(1);
226
- }
227
-
228
- const model = codexModelLookup.get(name);
229
- if (!model) {
230
- console.error(`${LOG_PREFIX} Missing codex model lookup for ${name}`);
231
- process.exit(1);
232
- }
200
+ const subagent = requireSubagentModel(content, codexModelLookup, "codex");
201
+ if (!subagent) return content;
202
+ const { afterFm, parsed, name, model } = subagent;
203
+ const body = afterFm.trim();
233
204
 
234
205
  const effort = parsed.get("effort");
235
206
  let out = "";
@@ -371,20 +342,28 @@ function extractFrontmatterField(fmBlock: string, field: string): string | null
371
342
  return m ? m[1] : null;
372
343
  }
373
344
 
374
- // T3: Cursor subagent frontmatter rewrite.
375
- // Emits: name, description, model, tools (passthrough — Cursor 2.4+ accepts identical tool names per BAR-113),
376
- // effort (from prompts.md Cursor column). Drops: permissionMode, maxTurns, readonly, is_background.
377
- // Hard-fails with non-zero exit if model lookup missing for name.
378
- export function applyT3(
345
+ interface SubagentModel {
346
+ fmBlock: string;
347
+ /** Everything after the closing `---`. */
348
+ afterFm: string;
349
+ parsed: Map<string, string>;
350
+ name: string;
351
+ model: string;
352
+ }
353
+
354
+ // Shared opening of the subagent renderers: split off the frontmatter, require `name`, look
355
+ // the model up. Returns null when `content` has no frontmatter (the renderer passes it
356
+ // through); exits 1 when `name` or the model is missing. `host` qualifies the model-lookup
357
+ // message ("" for the unqualified Cursor message).
358
+ function requireSubagentModel(
379
359
  content: string,
380
- modelLookup: Map<string, string>,
381
- effortMap?: EffortMap,
382
- ): string {
360
+ lookup: Map<string, string>,
361
+ host: "opencode" | "codex" | "antigravity" | "",
362
+ ): SubagentModel | null {
383
363
  const fmMatch = content.match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/);
384
- if (!fmMatch) return content;
364
+ if (!fmMatch) return null;
385
365
 
386
366
  const fmBlock = fmMatch[2];
387
- const afterFm = content.slice(fmMatch[0].length);
388
367
  const parsed = parseFrontmatter(fmBlock);
389
368
 
390
369
  const name = parsed.get("name") ?? "";
@@ -393,12 +372,28 @@ export function applyT3(
393
372
  process.exit(1);
394
373
  }
395
374
 
396
- const cursorModel = modelLookup.get(name);
397
- if (!cursorModel) {
398
- console.error(`${LOG_PREFIX} Missing model lookup for ${name}`);
375
+ const model = lookup.get(name);
376
+ if (!model) {
377
+ console.error(`${LOG_PREFIX} Missing ${host ? `${host} ` : ""}model lookup for ${name}`);
399
378
  process.exit(1);
400
379
  }
401
380
 
381
+ return { fmBlock, afterFm: content.slice(fmMatch[0].length), parsed, name, model };
382
+ }
383
+
384
+ // T3: Cursor subagent frontmatter rewrite.
385
+ // Emits: name, description, model, tools (passthrough — Cursor 2.4+ accepts identical tool names per BAR-113),
386
+ // effort (from prompts.md Cursor column). Drops: permissionMode, maxTurns, readonly, is_background.
387
+ // Hard-fails with non-zero exit if model lookup missing for name.
388
+ export function applyT3(
389
+ content: string,
390
+ modelLookup: Map<string, string>,
391
+ effortMap?: EffortMap,
392
+ ): string {
393
+ const subagent = requireSubagentModel(content, modelLookup, "");
394
+ if (!subagent) return content;
395
+ const { fmBlock, afterFm, parsed, name, model: cursorModel } = subagent;
396
+
402
397
  const description = parsed.get("description") ?? "";
403
398
  const effort = parsed.get("effort");
404
399
  const toolsBlock = extractFrontmatterField(fmBlock, "tools");
@@ -477,24 +472,9 @@ export function applyAntigravityPrompt(
477
472
  modelLookup: Map<string, string>,
478
473
  effortMap?: EffortMap,
479
474
  ): string {
480
- const fmMatch = content.match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/);
481
- if (!fmMatch) return content;
482
-
483
- const fmBlock = fmMatch[2];
484
- const afterFm = content.slice(fmMatch[0].length);
485
- const parsed = parseFrontmatter(fmBlock);
486
-
487
- const name = parsed.get("name") ?? "";
488
- if (!name) {
489
- console.error(`${LOG_PREFIX} Subagent frontmatter missing 'name' field`);
490
- process.exit(1);
491
- }
492
-
493
- const model = modelLookup.get(name);
494
- if (!model) {
495
- console.error(`${LOG_PREFIX} Missing antigravity model lookup for ${name}`);
496
- process.exit(1);
497
- }
475
+ const subagent = requireSubagentModel(content, modelLookup, "antigravity");
476
+ if (!subagent) return content;
477
+ const { fmBlock, afterFm, parsed, name, model } = subagent;
498
478
 
499
479
  const description = parsed.get("description") ?? "";
500
480
  const effort = parsed.get("effort");
@@ -4,7 +4,11 @@
4
4
  import * as fs from "node:fs";
5
5
  import { findLineAnchoredMarkers, selectMarkers } from "../install/managed-block.js";
6
6
  import { LOG_PREFIX } from "../shared/log-prefix.js";
7
- import { OPENCODE_PROVIDER_DEFAULTS } from "../shared/egress.js";
7
+ import {
8
+ OPENCODE_PROVIDERS,
9
+ OPENCODE_PROVIDER_DEFAULTS,
10
+ type OpencodeProvider,
11
+ } from "../shared/egress.js";
8
12
 
9
13
  /**
10
14
  * Parse .bkit/prompts.md § Models table → Map<name, columnValue>.
@@ -97,8 +101,11 @@ export function parseModelLookup(subagentsMdPath: string): Map<string, string> {
97
101
  *
98
102
  * Cells hold the BARE, gateway-scoped model id. Any prefix a program's config format needs
99
103
  * is added at render time by formatModelPin — never stored in the table.
104
+ *
105
+ * Every allowlisted opencode provider MUST have an entry; the `satisfies Record<OpencodeProvider | …>`
106
+ * check fails tsc when one is missing.
100
107
  */
101
- const GATEWAY_COLUMN: Record<string, string> = {
108
+ const GATEWAY_COLUMN = {
102
109
  anthropic: "Anthropic",
103
110
  cursor: "Cursor",
104
111
  openrouter: "OpenRouter",
@@ -107,7 +114,13 @@ const GATEWAY_COLUMN: Record<string, string> = {
107
114
  "opencode-go": "OpenCode Go",
108
115
  openai: "OpenAI",
109
116
  google: "Google",
110
- };
117
+ } satisfies Record<OpencodeProvider | "anthropic" | "cursor" | "openai" | "google", string>;
118
+
119
+ type GatewayKey = keyof typeof GATEWAY_COLUMN;
120
+
121
+ function isGatewayKey(value: string): value is GatewayKey {
122
+ return Object.hasOwn(GATEWAY_COLUMN, value);
123
+ }
111
124
 
112
125
  /**
113
126
  * Spell a model pin the way a program's config file expects it.
@@ -125,22 +138,21 @@ export function formatModelPin(program: string, gateway: string, bareModel: stri
125
138
  }
126
139
 
127
140
  /**
128
- * Build the per-agent opencode model lookup for the selected provider.
129
- * Source of truth = prompts.md § Models, which carries one curated column per
130
- * provider ("OpenRouter", "Ollama"). Header-addressed. Every allowlisted provider
131
- * ships a column; an absent one throws.
141
+ * Build the per-agent model lookup for one gateway: an opencode provider, or the Codex
142
+ * "openai" column. Source of truth = prompts.md § Models, which carries one curated column per
143
+ * gateway ("OpenRouter", "Ollama", "OpenAI"). Header-addressed. Every key of GATEWAY_COLUMN
144
+ * ships a column; any other key throws.
132
145
  */
133
146
  export function buildOpencodeModelLookup(
134
147
  subagentsMdPath: string,
135
148
  provider: string,
136
149
  ): Map<string, string> {
137
- const header = GATEWAY_COLUMN[provider];
138
- if (!header) {
150
+ if (!isGatewayKey(provider)) {
139
151
  throw new Error(
140
152
  `buildOpencodeModelLookup: no prompts.md § Models column for provider ${JSON.stringify(provider)}`,
141
153
  );
142
154
  }
143
- return parseModelLookupForColumn(subagentsMdPath, header);
155
+ return parseModelLookupForColumn(subagentsMdPath, GATEWAY_COLUMN[provider]);
144
156
  }
145
157
 
146
158
  /**
@@ -329,5 +341,11 @@ export function lookupEffort(effortMap: EffortMap, program: string, sourceEffort
329
341
  * keys pass through unchanged.
330
342
  */
331
343
  export function opencodeProviderId(providerKey: string): string {
332
- return OPENCODE_PROVIDER_DEFAULTS[providerKey]?.providerId ?? providerKey;
344
+ if (!isOpencodeProvider(providerKey)) return providerKey;
345
+ return OPENCODE_PROVIDER_DEFAULTS[providerKey].providerId ?? providerKey;
346
+ }
347
+
348
+ /** Narrow a raw string to the opencode provider allowlist. */
349
+ export function isOpencodeProvider(value: string): value is OpencodeProvider {
350
+ return OPENCODE_PROVIDERS.some((provider) => provider === value);
333
351
  }
@@ -0,0 +1,13 @@
1
+ // shared/branches.ts — which branches are shared, so nobody works on them directly.
2
+ //
3
+ // `dev` is the integration branch; `dev` and `main` are the shared branches. The workflow
4
+ // commands (`commands/lib.ts` re-exports these) and the managed-version check both read
5
+ // this one rule.
6
+
7
+ /** The integration branch feature work lands on. */
8
+ export const DEV = "dev";
9
+
10
+ /** True for `dev` and `main`: no feature work happens on them, no force-push touches them. */
11
+ export function isSharedBranch(branch: string): boolean {
12
+ return branch === DEV || branch === "main";
13
+ }
@@ -4,8 +4,6 @@
4
4
  /**
5
5
  * Providers bkit supports for the opencode host. `--opencode=<provider>` accepts
6
6
  * ONLY these — anything else is rejected (no generic/arbitrary-endpoint fallback).
7
- * Keep in sync with OPENCODE_PROVIDER_DEFAULTS (below) and
8
- * GATEWAY_COLUMN (render/models.ts § Models lookup).
9
7
  */
10
8
  export const OPENCODE_PROVIDERS = [
11
9
  // OpenAI-compatible npm driver — endpoint + key per provider.
@@ -18,6 +16,8 @@ export const OPENCODE_PROVIDERS = [
18
16
  "opencode-go",
19
17
  ] as const;
20
18
 
19
+ export type OpencodeProvider = (typeof OPENCODE_PROVIDERS)[number];
20
+
21
21
  /**
22
22
  * One egress source: a bkit-shipped surface that an agent session reaches over the
23
23
  * network. `hosts` are the exact hostnames contacted. `bases` are the registrable
@@ -47,7 +47,7 @@ export interface EgressSource {
47
47
  // These are sane defaults; consumers tune after install.
48
48
  // npmPackage: set for custom OpenAI-compatible providers that use npm-based AI SDK driver.
49
49
  export const OPENCODE_PROVIDER_DEFAULTS: Record<
50
- string,
50
+ OpencodeProvider,
51
51
  {
52
52
  envVar: string;
53
53
  baseURL: string;
@@ -4,9 +4,14 @@
4
4
  // .bkit/version) must fail open into a result the caller reports in its own terms,
5
5
  // never abort install, upgrade or `bkit check`. One shape, one catch — so the
6
6
  // defensive-slop gate reads a single documented fallback instead of one per caller.
7
+ // `audits/repo/json-parse-owner.test.ts` fails on a `JSON.parse` inside a `try` anywhere else.
8
+
9
+ import * as fs from "node:fs";
10
+
11
+ export type JsonRead = { ok: true; value: unknown } | { ok: false };
7
12
 
8
13
  /** `JSON.parse(raw)` as a result: `{ ok: true, value }`, or `{ ok: false }` when not JSON. */
9
- export function parseJson(raw: string): { ok: true; value: unknown } | { ok: false } {
14
+ export function parseJson(raw: string): JsonRead {
10
15
  try {
11
16
  return { ok: true, value: JSON.parse(raw) as unknown };
12
17
  } catch {
@@ -14,3 +19,15 @@ export function parseJson(raw: string): { ok: true; value: unknown } | { ok: fal
14
19
  return { ok: false };
15
20
  }
16
21
  }
22
+
23
+ /** `parseJson` over the file at `file`; `{ ok: false }` also when the file cannot be read. */
24
+ export function readJsonFile(file: string): JsonRead {
25
+ let raw: string;
26
+ try {
27
+ raw = fs.readFileSync(file, "utf-8");
28
+ } catch {
29
+ // Missing, unreadable or a directory: the result says so, like malformed JSON.
30
+ return { ok: false };
31
+ }
32
+ return parseJson(raw);
33
+ }
@@ -3,11 +3,14 @@
3
3
  // Commands that look up a script or a `bkit` setting need to tell "no file" and
4
4
  // "file is not JSON" apart from "key absent", so a broken manifest is named in the
5
5
  // message instead of reading as an empty one.
6
+ //
7
+ // `readInstallingVersion` reads the same file for the bkit package doing the install.
6
8
 
7
9
  import * as fs from "node:fs";
8
10
  import * as path from "node:path";
9
11
 
10
12
  import { parseJson } from "./json.js";
13
+ import { getPkgRoot } from "./package-roots.js";
11
14
 
12
15
  export type PackageJsonRead =
13
16
  { ok: true; pkg: Record<string, unknown> } | { ok: false; reason: "missing" | "unparseable" };
@@ -27,3 +30,63 @@ export function readPackageJson(dir: string): PackageJsonRead {
27
30
  }
28
31
  return { ok: true, pkg: parsed.value as Record<string, unknown> };
29
32
  }
33
+
34
+ /** Every dependency name across the four `package.json` dependency fields; `[]` when unreadable. */
35
+ export function readDependencyNames(cwd: string): string[] {
36
+ const read = readPackageJson(cwd);
37
+ if (!read.ok) return [];
38
+ const names: string[] = [];
39
+ for (const field of [
40
+ "dependencies",
41
+ "devDependencies",
42
+ "optionalDependencies",
43
+ "peerDependencies",
44
+ ]) {
45
+ const deps = read.pkg[field];
46
+ if (deps && typeof deps === "object") {
47
+ names.push(...Object.keys(deps as Record<string, unknown>));
48
+ }
49
+ }
50
+ return names;
51
+ }
52
+
53
+ /**
54
+ * The spec `package.json` declares for dependency `name` (`"^5.2.0"`, `"file:../x.tgz"`, …),
55
+ * from `dependencies`, `devDependencies` or `optionalDependencies`; `null` when undeclared or
56
+ * the file is unreadable.
57
+ */
58
+ export function readDependencySpec(cwd: string, name: string): string | null {
59
+ const read = readPackageJson(cwd);
60
+ if (!read.ok) return null;
61
+ for (const field of ["dependencies", "devDependencies", "optionalDependencies"]) {
62
+ const deps = read.pkg[field];
63
+ if (deps && typeof deps === "object") {
64
+ const spec = (deps as Record<string, unknown>)[name];
65
+ if (typeof spec === "string") return spec;
66
+ }
67
+ }
68
+ return null;
69
+ }
70
+
71
+ /**
72
+ * The version of the bkit package doing the install, read from that package's own
73
+ * `package.json` (`root` defaults to the package root; never the consumer's file).
74
+ * Throws when the file is missing, is not a JSON object, or has no non-empty string
75
+ * `version`: the value is stamped into every managed file and the `.bkit/version` pin,
76
+ * so a damaged package stops the command instead of writing a guessed version.
77
+ */
78
+ export function readInstallingVersion(root: string = getPkgRoot()): string {
79
+ const file = path.join(root, "package.json");
80
+ const read = readPackageJson(root);
81
+ if (!read.ok) {
82
+ const state = read.reason === "missing" ? "is missing" : "is not a JSON object";
83
+ throw new Error(`bkit's own package.json ${state} (${file}); reinstall @cbartens/bkit.`);
84
+ }
85
+ const version = read.pkg["version"];
86
+ if (typeof version !== "string" || version === "") {
87
+ throw new Error(
88
+ `bkit's own package.json has no string "version" (${file}); reinstall @cbartens/bkit.`,
89
+ );
90
+ }
91
+ return version;
92
+ }
@@ -149,13 +149,3 @@ export function getHooksRoot(): string {
149
149
  export function getBkitDocsRoot(): string {
150
150
  return path.join(getCoreRoot(), ".bkit");
151
151
  }
152
-
153
- // ---------------------------------------------------------------------------
154
- // isDogfood — true when bkit is running inside its own repo (in-repo install).
155
- // In this case the source tree IS the consumer's .agents/ directory, so any
156
- // payload copy would overwrite the source with itself.
157
- // ---------------------------------------------------------------------------
158
-
159
- export function isDogfood(): boolean {
160
- return getPkgRoot() === process.cwd();
161
- }