@cbartens/bkit 5.2.3 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/.bkit/README.md +29 -12
  2. package/.bkit/core/.agents/context.md +1 -1
  3. package/.bkit/core/.agents/docs.md +1 -1
  4. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +1 -1
  5. package/.bkit/core/.agents/rules.md +11 -0
  6. package/.bkit/core/.bkit/README.md +28 -11
  7. package/.bkit/core/.bkit/cloud.md +9 -8
  8. package/.bkit/core/.bkit/comparison.md +68 -345
  9. package/.bkit/core/.bkit/install.md +15 -9
  10. package/.bkit/core/.bkit/lite.md +73 -0
  11. package/.bkit/core/.bkit/pipeline.md +345 -0
  12. package/.bkit/core/.bkit/prompts.md +88 -73
  13. package/.bkit/core/.bkit/providers.md +41 -22
  14. package/.bkit/core/.bkit/templates.md +125 -18
  15. package/.bkit/core/.bkit/trackers.md +47 -1
  16. package/.bkit/core/.bkit/workflows.md +51 -45
  17. package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +1 -1
  18. package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +7 -4
  19. package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +8 -5
  20. package/.bkit/core/docs/templates/bkit-audit-accessibility.md +9 -1
  21. package/.bkit/core/docs/templates/bkit-audit-adoption.md +10 -2
  22. package/.bkit/core/docs/templates/bkit-audit-agents.md +9 -1
  23. package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +9 -1
  24. package/.bkit/core/docs/templates/bkit-audit-analytics.md +9 -1
  25. package/.bkit/core/docs/templates/bkit-audit-annotations.md +10 -2
  26. package/.bkit/core/docs/templates/bkit-audit-app-performance.md +9 -1
  27. package/.bkit/core/docs/templates/bkit-audit-app-store.md +9 -1
  28. package/.bkit/core/docs/templates/bkit-audit-architecture.md +9 -1
  29. package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +9 -1
  30. package/.bkit/core/docs/templates/bkit-audit-config.md +9 -1
  31. package/.bkit/core/docs/templates/bkit-audit-cost.md +10 -2
  32. package/.bkit/core/docs/templates/bkit-audit-coverage.md +9 -1
  33. package/.bkit/core/docs/templates/bkit-audit-database.md +9 -1
  34. package/.bkit/core/docs/templates/bkit-audit-dead-code.md +9 -1
  35. package/.bkit/core/docs/templates/bkit-audit-deferrals.md +9 -1
  36. package/.bkit/core/docs/templates/bkit-audit-dependencies.md +22 -10
  37. package/.bkit/core/docs/templates/bkit-audit-documentation.md +9 -1
  38. package/.bkit/core/docs/templates/bkit-audit-duplication.md +9 -1
  39. package/.bkit/core/docs/templates/bkit-audit-failures.md +9 -1
  40. package/.bkit/core/docs/templates/bkit-audit-flakes.md +10 -2
  41. package/.bkit/core/docs/templates/bkit-audit-gates.md +9 -1
  42. package/.bkit/core/docs/templates/bkit-audit-issues.md +9 -1
  43. package/.bkit/core/docs/templates/bkit-audit-llm.md +29 -15
  44. package/.bkit/core/docs/templates/bkit-audit-logs.md +10 -2
  45. package/.bkit/core/docs/templates/bkit-audit-models.md +9 -1
  46. package/.bkit/core/docs/templates/bkit-audit-privacy.md +9 -1
  47. package/.bkit/core/docs/templates/bkit-audit-prompts.md +11 -3
  48. package/.bkit/core/docs/templates/bkit-audit-red-team.md +19 -9
  49. package/.bkit/core/docs/templates/bkit-audit-reliability.md +9 -1
  50. package/.bkit/core/docs/templates/bkit-audit-repo.md +10 -2
  51. package/.bkit/core/docs/templates/bkit-audit-security.md +13 -5
  52. package/.bkit/core/docs/templates/bkit-audit-slop.md +9 -1
  53. package/.bkit/core/docs/templates/bkit-audit-testing.md +14 -5
  54. package/.bkit/core/docs/templates/bkit-audit-usability.md +9 -1
  55. package/.bkit/core/docs/templates/bkit-plan.md +8 -6
  56. package/.bkit/core/engine/checks/after/auth.ts +9 -9
  57. package/.bkit/core/engine/checks/after/ci-yml.ts +14 -12
  58. package/.bkit/core/engine/checks/after/github.ts +29 -120
  59. package/.bkit/core/engine/checks/after/index.ts +2 -2
  60. package/.bkit/core/engine/checks/after/managed.ts +8 -28
  61. package/.bkit/core/engine/checks/after/tools.ts +3 -15
  62. package/.bkit/core/engine/checks/before/context-fetch.ts +1 -21
  63. package/.bkit/core/engine/checks/before/index.ts +7 -43
  64. package/.bkit/core/engine/checks/before/mcp.ts +17 -8
  65. package/.bkit/core/engine/checks/before/repo.ts +9 -12
  66. package/.bkit/core/engine/checks/status-holes.ts +4 -5
  67. package/.bkit/core/engine/checks/tips/catalogue.ts +70 -24
  68. package/.bkit/core/engine/checks/tips/detect.ts +45 -2
  69. package/.bkit/core/engine/checks/tips/index.ts +37 -8
  70. package/.bkit/core/engine/cli.ts +39 -16
  71. package/.bkit/core/engine/commands/analysis.ts +36 -26
  72. package/.bkit/core/engine/commands/comply.ts +17 -16
  73. package/.bkit/core/engine/commands/harvest.ts +12 -12
  74. package/.bkit/core/engine/commands/install/doctor.ts +57 -28
  75. package/.bkit/core/engine/commands/install/install.ts +62 -126
  76. package/.bkit/core/engine/commands/install/uninstall.ts +191 -33
  77. package/.bkit/core/engine/commands/install/upgrade.ts +58 -53
  78. package/.bkit/core/engine/commands/lib.ts +35 -10
  79. package/.bkit/core/engine/commands/tips.ts +8 -5
  80. package/.bkit/core/engine/commands/workflow/branches.ts +65 -11
  81. package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
  82. package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
  83. package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
  84. package/.bkit/core/engine/commands/workflow/prs.ts +4 -2
  85. package/.bkit/core/engine/commands/workflow/repo.ts +18 -4
  86. package/.bkit/core/engine/commands/workflow/roadmap.ts +4 -3
  87. package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
  88. package/.bkit/core/engine/commands/workflow/steps.ts +1 -0
  89. package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
  90. package/.bkit/core/engine/commands/workflow/workflows.ts +19 -17
  91. package/.bkit/core/engine/commands/workflow/workstreams.ts +2 -1
  92. package/.bkit/core/engine/commands/workflow/worktrees.ts +13 -5
  93. package/.bkit/core/engine/install/cloud-env.ts +10 -31
  94. package/.bkit/core/engine/install/manifest.ts +14 -7
  95. package/.bkit/core/engine/install/modules/antigravity.ts +15 -26
  96. package/.bkit/core/engine/install/modules/claude.ts +20 -28
  97. package/.bkit/core/engine/install/modules/cloud.ts +5 -2
  98. package/.bkit/core/engine/install/modules/codex.ts +15 -29
  99. package/.bkit/core/engine/install/modules/core.ts +91 -70
  100. package/.bkit/core/engine/install/modules/cursor.ts +6 -20
  101. package/.bkit/core/engine/install/modules/index.ts +7 -1
  102. package/.bkit/core/engine/install/modules/opencode.ts +48 -70
  103. package/.bkit/core/engine/install/network-allowlist.ts +73 -0
  104. package/.bkit/core/engine/install/placeholders.ts +3 -18
  105. package/.bkit/core/engine/install/write.ts +59 -12
  106. package/.bkit/core/engine/ledgers/telemetry.ts +6 -4
  107. package/.bkit/core/engine/render/hosts.ts +47 -67
  108. package/.bkit/core/engine/render/models.ts +29 -11
  109. package/.bkit/core/engine/shared/bkit-latest.ts +164 -0
  110. package/.bkit/core/engine/shared/branches.ts +13 -0
  111. package/.bkit/core/engine/shared/egress.ts +3 -3
  112. package/.bkit/core/engine/shared/json.ts +18 -1
  113. package/.bkit/core/engine/shared/package-json.ts +63 -0
  114. package/.bkit/core/engine/shared/package-roots.ts +0 -10
  115. package/.bkit/core/engine/shared/protected-paths.ts +5 -130
  116. package/.bkit/core/engine/shared/settings.ts +36 -0
  117. package/.bkit/core/engine/shared/timeouts.ts +6 -0
  118. package/.bkit/core/hooks/antigravity-hook.js +1 -0
  119. package/.bkit/core/hooks/guardrails-shell.js +186 -40
  120. package/.bkit/core/hooks/guardrails-tiers.js +5 -78
  121. package/.bkit/core/prompts/bkit-audit-generate.md +65 -10
  122. package/.bkit/core/prompts/bkit-build-challenge-1.md +1 -1
  123. package/.bkit/core/prompts/bkit-build-challenge-2.md +1 -1
  124. package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +1 -1
  125. package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -1
  126. package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -1
  127. package/.bkit/core/prompts/bkit-build-install-skills.md +1 -1
  128. package/.bkit/core/prompts/bkit-build-plan-current.md +1 -1
  129. package/.bkit/core/prompts/bkit-build-plan-execute.md +4 -4
  130. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
  131. package/.bkit/core/prompts/bkit-build-plan-verify.md +2 -2
  132. package/.bkit/core/prompts/bkit-debug-abort-handover.md +1 -1
  133. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +1 -1
  134. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
  135. package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +78 -0
  136. package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
  137. package/.bkit/core/prompts/bkit-debug-summary.md +3 -3
  138. package/.bkit/core/prompts/bkit-design-spike.md +1 -1
  139. package/.bkit/core/prompts/bkit-design-summary.md +2 -2
  140. package/.bkit/core/prompts/bkit-design-update.md +1 -1
  141. package/.bkit/core/prompts/bkit-plan-complexity-check.md +1 -1
  142. package/.bkit/core/prompts/bkit-plan-generate.md +1 -1
  143. package/.bkit/core/prompts/bkit-plan-scope-check-1.md +1 -1
  144. package/.bkit/core/prompts/bkit-plan-scope-check-2.md +1 -1
  145. package/.bkit/core/prompts/bkit-plan-summary.md +1 -1
  146. package/.bkit/core/prompts/bkit-plan-update.md +1 -1
  147. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
  148. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +1 -1
  149. package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
  150. package/.bkit/core/prompts/bkit-utility-update-decisions.md +9 -2
  151. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +9 -2
  152. package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
  153. package/.bkit/core/prompts/bkit-utility-update-failures.md +9 -2
  154. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +9 -2
  155. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +11 -4
  156. package/.bkit/core/workflows/bkit-build.md +4 -4
  157. package/.bkit/core/workflows/bkit-debug.md +70 -34
  158. package/.bkit/core/workflows/bkit-design.md +3 -3
  159. package/.bkit/core/workflows/bkit-plan.md +12 -5
  160. package/.bkit/core/workflows/bkit-ship.md +6 -6
  161. package/.bkit/shared/.claude/bkit-cloud.md +46 -13
  162. package/.bkit/shared/.claude/settings.json +18 -0
  163. package/.bkit/shared/.cursor/mcp.json +2 -1
  164. package/.bkit/shared/.opencode/opencode.json +19 -1
  165. package/.bkit/shared/docs/deployments.md +20 -4
  166. package/.bkit/shared/docs/security.md +8 -6
  167. package/.bkit/shared/docs/testing.md +9 -5
  168. package/.bkit/templates/.cursor/Dockerfile +30 -16
  169. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +78 -0
  170. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +91 -0
  171. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +56 -0
  172. package/.bkit/templates/.github/renovate.json5 +91 -12
  173. package/.bkit/templates/.github/workflows/bkit-ci.yml +66 -53
  174. package/.bkit/templates/.github/workflows/bkit-cloud.yml +3 -1
  175. package/.bkit/templates/.github/workflows/bkit-renovate.yml +8 -1
  176. package/.bkit/templates/.github/workflows/bkit-trivy.yml +67 -0
  177. package/.bkit/templates/.husky/pre-push +15 -3
  178. package/.bkit/templates/.oxlintrc.json +21 -0
  179. package/.bkit/templates/docs/capabilities.md +1 -1
  180. package/.bkit/templates/scripts/ci/check-capstone.mjs +176 -0
  181. package/.bkit/templates/scripts/ci/check-capstone.test.mjs +311 -0
  182. package/.bkit/templates/scripts/cleanup/bkit-tmp-prune.mjs +115 -0
  183. package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +2 -2
  184. package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +43 -20
  185. package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +33 -11
  186. package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -2
  187. package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +5 -5
  188. package/.bkit/templates/scripts/graphify/bkit-graphify.sh +79 -19
  189. package/CHANGELOG.md +67 -3
  190. package/README.md +258 -129
  191. package/dist/checks/after/auth.js +10 -11
  192. package/dist/checks/after/ci-yml.js +11 -14
  193. package/dist/checks/after/github.js +32 -125
  194. package/dist/checks/after/index.js +3 -2
  195. package/dist/checks/after/managed.js +8 -24
  196. package/dist/checks/after/tools.js +3 -16
  197. package/dist/checks/before/context-fetch.js +1 -21
  198. package/dist/checks/before/index.js +6 -42
  199. package/dist/checks/before/mcp.js +14 -9
  200. package/dist/checks/before/repo.js +8 -11
  201. package/dist/checks/status-holes.js +5 -6
  202. package/dist/checks/tips/catalogue.js +60 -18
  203. package/dist/checks/tips/detect.js +41 -2
  204. package/dist/checks/tips/index.js +25 -5
  205. package/dist/cli.js +34 -14
  206. package/dist/commands/analysis.js +21 -5
  207. package/dist/commands/comply.js +20 -18
  208. package/dist/commands/harvest.js +12 -13
  209. package/dist/commands/install/doctor.js +55 -23
  210. package/dist/commands/install/install.js +62 -118
  211. package/dist/commands/install/uninstall.js +165 -31
  212. package/dist/commands/install/upgrade.js +55 -49
  213. package/dist/commands/lib.js +32 -10
  214. package/dist/commands/tips.js +6 -3
  215. package/dist/commands/workflow/branches.js +57 -13
  216. package/dist/commands/workflow/counters.js +17 -7
  217. package/dist/commands/workflow/fids.js +39 -0
  218. package/dist/commands/workflow/ledgers.js +3 -1
  219. package/dist/commands/workflow/prs.js +3 -3
  220. package/dist/commands/workflow/repo.js +16 -4
  221. package/dist/commands/workflow/roadmap.js +4 -4
  222. package/dist/commands/workflow/runs.js +5 -5
  223. package/dist/commands/workflow/steps.js +1 -0
  224. package/dist/commands/workflow/tests.js +16 -3
  225. package/dist/commands/workflow/workflows.js +19 -18
  226. package/dist/commands/workflow/workstreams.js +2 -1
  227. package/dist/commands/workflow/worktrees.js +4 -5
  228. package/dist/install/cloud-env.js +10 -23
  229. package/dist/install/manifest.js +14 -7
  230. package/dist/install/modules/antigravity.js +15 -26
  231. package/dist/install/modules/claude.js +17 -21
  232. package/dist/install/modules/cloud.js +6 -2
  233. package/dist/install/modules/codex.js +15 -29
  234. package/dist/install/modules/core.js +82 -63
  235. package/dist/install/modules/cursor.js +6 -9
  236. package/dist/install/modules/index.js +6 -1
  237. package/dist/install/modules/opencode.js +41 -72
  238. package/dist/install/network-allowlist.js +62 -0
  239. package/dist/install/placeholders.js +3 -16
  240. package/dist/install/write.js +55 -15
  241. package/dist/ledgers/telemetry.js +5 -4
  242. package/dist/render/hosts.js +30 -55
  243. package/dist/render/models.js +20 -9
  244. package/dist/shared/bkit-latest.js +150 -0
  245. package/dist/shared/branches.js +11 -0
  246. package/dist/shared/egress.js +0 -2
  247. package/dist/shared/json.js +14 -0
  248. package/dist/shared/package-json.js +61 -0
  249. package/dist/shared/package-roots.js +0 -8
  250. package/dist/shared/protected-paths.js +5 -122
  251. package/dist/shared/settings.js +18 -1
  252. package/dist/shared/timeouts.js +6 -0
  253. package/package.json +21 -17
  254. package/.bkit/core/.agents/shortcuts.md +0 -73
@@ -3,7 +3,8 @@
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
5
  import { execSync } from "node:child_process";
6
- import { readConsumerCloudAgents } from "./github.js";
6
+ import { readJsonFile } from "../../shared/json.js";
7
+ import { readBkitConfig } from "../../shared/settings.js";
7
8
  /**
8
9
  * Detect whether BKIT_GH_TOKEN is set in the shell environment. Distinguishes
9
10
  * empty from unset so action text can guide the user precisely. Never reads the
@@ -29,15 +30,13 @@ export function hasGithubMcpServer(cwd) {
29
30
  const p = path.join(cwd, rel);
30
31
  if (!fs.existsSync(p))
31
32
  continue;
32
- try {
33
- const cfg = JSON.parse(fs.readFileSync(p, "utf-8"));
34
- const servers = cfg.mcpServers;
35
- if (servers?.github)
36
- return true;
37
- }
38
- catch {
39
- // Malformed config — ignore; a JSON-drift advisory covers that separately.
40
- }
33
+ // Malformed config — ignore; a JSON-drift advisory covers that separately.
34
+ const cfg = readJsonFile(p);
35
+ if (!cfg.ok || typeof cfg.value !== "object" || cfg.value === null)
36
+ continue;
37
+ const servers = cfg.value.mcpServers;
38
+ if (servers?.github)
39
+ return true;
41
40
  }
42
41
  return false;
43
42
  }
@@ -109,7 +108,7 @@ export function buildCloudDashboardsAdvisory(cwd) {
109
108
  // cloud=claude path (bkit-cloud.yml): GitHub-tracker only, ANTHROPIC_API_KEY only.
110
109
  // cloud=cursor path (.cursor/): BKIT_LINEAR_API_KEY for Cursor dashboard.
111
110
  // Distinguish by recorded variant; fall back to presence-based detection.
112
- const recordedVariant = readConsumerCloudAgents(cwd);
111
+ const recordedVariant = readBkitConfig(cwd).cloudAgents;
113
112
  const isCursorCloud = recordedVariant === "cursor" || (!hasRouter && hasCursor);
114
113
  const secretList = isCursorCloud ? "`BKIT_LINEAR_API_KEY`" : "`ANTHROPIC_API_KEY`";
115
114
  const ghSetLines = isCursorCloud
@@ -3,6 +3,7 @@
3
3
  // run levels, turbo inputs and the integration env.
4
4
  import * as fs from "node:fs";
5
5
  import * as path from "node:path";
6
+ import { readJsonFile } from "../../shared/json.js";
6
7
  import { readPackageJson } from "../../shared/package-json.js";
7
8
  import { isAdvisorySuppressed } from "./suppression.js";
8
9
  // ---------------------------------------------------------------------------
@@ -372,16 +373,15 @@ export function detectTaggedTestsWithoutCiHome(cwd, onSuppressed) {
372
373
  const pkgScripts = new Map();
373
374
  const declaredScripts = new Set();
374
375
  for (const pj of packageJsons) {
375
- try {
376
- const parsed = JSON.parse(fs.readFileSync(pj, "utf-8"));
377
- const scripts = parsed.scripts ?? {};
378
- pkgScripts.set(pj, scripts);
379
- for (const name of Object.keys(scripts))
380
- declaredScripts.add(name);
381
- }
382
- catch {
376
+ const parsed = readJsonFile(pj);
377
+ if (!parsed.ok || parsed.value === null) {
383
378
  pkgScripts.set(pj, {});
379
+ continue;
384
380
  }
381
+ const scripts = parsed.value.scripts ?? {};
382
+ pkgScripts.set(pj, scripts);
383
+ for (const name of Object.keys(scripts))
384
+ declaredScripts.add(name);
385
385
  }
386
386
  const nearestPkg = (fileDir) => {
387
387
  let dir = fileDir;
@@ -470,13 +470,10 @@ export function detectTurboIntegrationInputs(cwd) {
470
470
  const turboPath = path.join(cwd, "turbo.json");
471
471
  if (!fs.existsSync(turboPath))
472
472
  return findings;
473
- let doc;
474
- try {
475
- doc = JSON.parse(fs.readFileSync(turboPath, "utf-8"));
476
- }
477
- catch {
473
+ const turbo = readJsonFile(turboPath);
474
+ if (!turbo.ok)
478
475
  return findings;
479
- }
476
+ const doc = turbo.value;
480
477
  // turbo v2 → `tasks`; turbo v1 → `pipeline`. Either may be present.
481
478
  const tasks = doc.tasks ?? doc.pipeline ?? {};
482
479
  const externalProxyHints = ["migrations", "fixtures", "seed", ".env"];
@@ -4,7 +4,9 @@
4
4
  import * as fs from "node:fs";
5
5
  import * as path from "node:path";
6
6
  import { execFileSync } from "node:child_process";
7
- import { parseIssueTracker, DEFAULT_ISSUE_TRACKER, parseCloudAgents, DEFAULT_CLOUD_AGENTS, } from "../../install/manifest.js";
7
+ import { MCP_TOOLSETS_HEADER, parseToolsets } from "../../install/write.js";
8
+ import { parseJson, readJsonFile } from "../../shared/json.js";
9
+ import { readBkitConfig } from "../../shared/settings.js";
8
10
  /**
9
11
  * Detect whether branch protection is configured on `main`.
10
12
  * Returns "present" | "missing" | "unknown".
@@ -45,7 +47,10 @@ export function detectActionsWritePermissions() {
45
47
  stdio: ["ignore", "pipe", "pipe"],
46
48
  timeout: 5000,
47
49
  });
48
- const parsed = JSON.parse(out);
50
+ const response = parseJson(out);
51
+ if (!response.ok)
52
+ return "unknown";
53
+ const parsed = response.value;
49
54
  const canWrite = parsed.default_workflow_permissions === "write";
50
55
  const canApprovePrs = parsed.can_approve_pull_request_reviews === true;
51
56
  return canWrite && canApprovePrs ? "present" : "missing";
@@ -54,24 +59,6 @@ export function detectActionsWritePermissions() {
54
59
  return "unknown";
55
60
  }
56
61
  }
57
- /**
58
- * Read `bkit.issueTracker` from the consumer's package.json.
59
- * Returns the tracker value or the default ("none") when absent / unreadable.
60
- */
61
- export function readConsumerIssueTracker(cwd) {
62
- const pkgPath = path.join(cwd, "package.json");
63
- if (!fs.existsSync(pkgPath))
64
- return DEFAULT_ISSUE_TRACKER;
65
- try {
66
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
67
- const bkitField = pkg.bkit;
68
- const parsed = parseIssueTracker(bkitField?.issueTracker);
69
- return parsed ?? DEFAULT_ISSUE_TRACKER;
70
- }
71
- catch {
72
- return DEFAULT_ISSUE_TRACKER;
73
- }
74
- }
75
62
  /**
76
63
  * Emit a tracker-specific setup advisory.
77
64
  *
@@ -86,7 +73,7 @@ export function buildTrackerSetupAdvisory(cwd) {
86
73
  const hasCursor = fs.existsSync(path.join(cwd, ".cursor"));
87
74
  if (!hasClaude && !hasCursor)
88
75
  return null;
89
- const tracker = readConsumerIssueTracker(cwd);
76
+ const { issueTracker: tracker, issueTrackerExplicit } = readBkitConfig(cwd);
90
77
  if (tracker === "github") {
91
78
  return {
92
79
  id: "tracker-setup-github",
@@ -106,7 +93,7 @@ export function buildTrackerSetupAdvisory(cwd) {
106
93
  // tracker === "none". Distinguish opt-out (explicit `bkit.issueTracker: "none"`)
107
94
  // from undecided (field absent). An explicit `none` silences the nudge, as with the
108
95
  // dep-updater advisory.
109
- if (hasExplicitIssueTrackerField(cwd))
96
+ if (issueTrackerExplicit)
110
97
  return null;
111
98
  return {
112
99
  id: "tracker-setup-none",
@@ -115,20 +102,6 @@ export function buildTrackerSetupAdvisory(cwd) {
115
102
  action: 'Optional post-install decision. Run `bkit install --tracker=github` (recommended) or `bkit install --tracker=linear` to enable tracker integration. GitHub tracker requires `BKIT_GH_TOKEN` in `.bkit/.env` (fine-grained PAT for one owner, classic PAT across owners). Linear tracker requires `BKIT_LINEAR_API_KEY` in `.bkit/.env`. To opt out and silence this advisory, set `bkit.issueTracker` to `"none"` in package.json.',
116
103
  };
117
104
  }
118
- /** True when package.json has an explicit `bkit.issueTracker` field (any value). */
119
- function hasExplicitIssueTrackerField(cwd) {
120
- const pkgPath = path.join(cwd, "package.json");
121
- if (!fs.existsSync(pkgPath))
122
- return false;
123
- try {
124
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
125
- const bkitField = pkg.bkit;
126
- return bkitField !== undefined && bkitField.issueTracker !== undefined;
127
- }
128
- catch {
129
- return false;
130
- }
131
- }
132
105
  /**
133
106
  * Classify the `bkit.githubProject` board-sync config in package.json:
134
107
  * - "configured" → object with at least `owner` + `number` (the lookup keys)
@@ -136,25 +109,12 @@ function hasExplicitIssueTrackerField(cwd) {
136
109
  * - "absent" → missing, malformed, or unreadable
137
110
  */
138
111
  function readGithubProjectConfig(cwd) {
139
- const pkgPath = path.join(cwd, "package.json");
140
- if (!fs.existsSync(pkgPath))
141
- return "absent";
142
- try {
143
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
144
- const bkitField = pkg.bkit;
145
- const gp = bkitField?.githubProject;
146
- if (gp === false)
147
- return "opted-out";
148
- if (gp && typeof gp === "object" && !Array.isArray(gp)) {
149
- const obj = gp;
150
- if (obj.owner !== undefined && obj.number !== undefined)
151
- return "configured";
152
- }
153
- return "absent";
154
- }
155
- catch {
156
- return "absent";
157
- }
112
+ const gp = readBkitConfig(cwd).githubProject;
113
+ if (gp === false)
114
+ return "opted-out";
115
+ if (gp !== null && gp.owner !== undefined && gp.number !== undefined)
116
+ return "configured";
117
+ return "absent";
158
118
  }
159
119
  /**
160
120
  * Inspect the root `.mcp.json` github server's `X-MCP-Toolsets` header for the
@@ -164,30 +124,22 @@ function readGithubProjectConfig(cwd) {
164
124
  * (installs predating the toolset addition)
165
125
  * - "unknown" → no `.mcp.json`, no github server, or no header (can't judge)
166
126
  *
167
- * Scoped to root `.mcp.json` only — bkit omits the header from `.cursor/mcp.json`.
127
+ * Scoped to root `.mcp.json` only.
168
128
  */
169
129
  export function detectProjectsToolset(cwd) {
170
130
  const mcpPath = path.join(cwd, ".mcp.json");
171
131
  if (!fs.existsSync(mcpPath))
172
132
  return "unknown";
173
- try {
174
- const cfg = JSON.parse(fs.readFileSync(mcpPath, "utf-8"));
175
- const servers = cfg.mcpServers;
176
- const gh = servers?.github;
177
- const headers = gh?.headers;
178
- const toolsets = headers?.["X-MCP-Toolsets"];
179
- if (typeof toolsets !== "string")
180
- return "unknown";
181
- return toolsets
182
- .split(",")
183
- .map((s) => s.trim())
184
- .includes("projects")
185
- ? "present"
186
- : "missing";
187
- }
188
- catch {
133
+ const cfg = readJsonFile(mcpPath);
134
+ if (!cfg.ok || typeof cfg.value !== "object" || cfg.value === null)
189
135
  return "unknown";
190
- }
136
+ const servers = cfg.value.mcpServers;
137
+ const gh = servers?.github;
138
+ const headers = gh?.headers;
139
+ const toolsets = headers?.[MCP_TOOLSETS_HEADER];
140
+ if (typeof toolsets !== "string")
141
+ return "unknown";
142
+ return parseToolsets(toolsets).includes("projects") ? "present" : "missing";
191
143
  }
192
144
  /**
193
145
  * GitHub Projects v2 board-sync prerequisite advisory. Board status sync needs
@@ -206,7 +158,7 @@ export function buildGithubProjectAdvisory(cwd) {
206
158
  const hasCursor = fs.existsSync(path.join(cwd, ".cursor"));
207
159
  if (!hasClaude && !hasCursor)
208
160
  return null;
209
- if (readConsumerIssueTracker(cwd) !== "github")
161
+ if (readBkitConfig(cwd).issueTracker !== "github")
210
162
  return null;
211
163
  const configState = readGithubProjectConfig(cwd);
212
164
  if (configState === "opted-out")
@@ -242,7 +194,7 @@ export function buildGithubProjectAdvisory(cwd) {
242
194
  "and must NOT be used for `statusFieldId` — `projects_write` rejects it with " +
243
195
  "`updated_field.id: value must be a number`.\n\n" +
244
196
  "2. Ensure the root `.mcp.json` github server enables the `projects` toolset:\n\n" +
245
- ' "X-MCP-Toolsets": "context,issues,pull_requests,repos,users,projects"\n\n' +
197
+ ' "X-MCP-Toolsets": "context,issues,pull_requests,repos,users,projects,actions"\n\n' +
246
198
  "3. The `BKIT_GH_TOKEN` PAT needs organization-scoped Projects read & write (repo scope is not enough).\n\n" +
247
199
  "To opt out and silence this advisory, set `bkit.githubProject` to `false` in package.json.",
248
200
  };
@@ -265,22 +217,9 @@ export function detectGithubProjectFieldIdFormat(cwd) {
265
217
  const hasCursor = fs.existsSync(path.join(cwd, ".cursor"));
266
218
  if (!hasClaude && !hasCursor)
267
219
  return null;
268
- if (readConsumerIssueTracker(cwd) !== "github")
220
+ const { issueTracker, githubProject: gp } = readBkitConfig(cwd);
221
+ if (issueTracker !== "github")
269
222
  return null;
270
- const pkgPath = path.join(cwd, "package.json");
271
- if (!fs.existsSync(pkgPath))
272
- return null;
273
- let gp;
274
- try {
275
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
276
- const bkitField = pkg.bkit;
277
- const raw = bkitField?.githubProject;
278
- if (raw && typeof raw === "object" && !Array.isArray(raw))
279
- gp = raw;
280
- }
281
- catch {
282
- return null;
283
- }
284
223
  // Only judge a board that is otherwise configured (owner + number present) and
285
224
  // has a statusFieldId set — absent statusFieldId is handled by the setup advisory.
286
225
  if (!gp || gp.owner === undefined || gp.number === undefined)
@@ -305,38 +244,6 @@ export function detectGithubProjectFieldIdFormat(cwd) {
305
244
  "`id` is the GraphQL node id (`PVTSSF_…`) and must NOT be used for `statusFieldId`.",
306
245
  };
307
246
  }
308
- /**
309
- * Read `bkit.cloudAgents` from the consumer's package.json. Returns the value
310
- * or the default ("none") when absent / unreadable.
311
- */
312
- export function readConsumerCloudAgents(cwd) {
313
- const pkgPath = path.join(cwd, "package.json");
314
- if (!fs.existsSync(pkgPath))
315
- return DEFAULT_CLOUD_AGENTS;
316
- try {
317
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
318
- const bkitField = pkg.bkit;
319
- const parsed = parseCloudAgents(bkitField?.cloudAgents);
320
- return parsed ?? DEFAULT_CLOUD_AGENTS;
321
- }
322
- catch {
323
- return DEFAULT_CLOUD_AGENTS;
324
- }
325
- }
326
- /** True when package.json has an explicit `bkit.cloudAgents` field (any value). */
327
- function hasExplicitCloudAgentsField(cwd) {
328
- const pkgPath = path.join(cwd, "package.json");
329
- if (!fs.existsSync(pkgPath))
330
- return false;
331
- try {
332
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
333
- const bkitField = pkg.bkit;
334
- return bkitField !== undefined && bkitField.cloudAgents !== undefined;
335
- }
336
- catch {
337
- return false;
338
- }
339
- }
340
247
  /**
341
248
  * Emit a cloud-agents setup advisory (parity with the tracker / dep-updater
342
249
  * advisories). Post-CI auto-routing (`bkit-cloud.yml`) is opt-in via
@@ -363,8 +270,7 @@ export function buildCloudSetupAdvisory(cwd) {
363
270
  // Config-consistency assertion: cloud=claude requires id-token: write.
364
271
  // If the recorded variant is "claude" and the workflow file lacks id-token: write,
365
272
  // surface a consistency finding.
366
- const recordedVariant = readConsumerCloudAgents(cwd);
367
- if (recordedVariant === "claude") {
273
+ if (readBkitConfig(cwd).cloudAgents === "claude") {
368
274
  const workflowContent = fs.readFileSync(routerPath, "utf-8");
369
275
  if (!workflowContent.includes("id-token: write")) {
370
276
  return {
@@ -383,7 +289,8 @@ export function buildCloudSetupAdvisory(cwd) {
383
289
  };
384
290
  }
385
291
  // No router present — distinguish opt-out from undecided.
386
- if (readConsumerCloudAgents(cwd) === "none" && hasExplicitCloudAgentsField(cwd)) {
292
+ const { cloudAgents, cloudAgentsExplicit } = readBkitConfig(cwd);
293
+ if (cloudAgents === "none" && cloudAgentsExplicit) {
387
294
  return null; // consumer explicitly chose `none` — stay quiet
388
295
  }
389
296
  // Only nudge if there's a workflows dir for the router to wake on.
@@ -6,10 +6,11 @@ import * as path from "node:path";
6
6
  import { dedupeById } from "../before/index.js";
7
7
  import { detectMissingDotenv, detectBlankDotenvKeys, detectDirenvMissing, detectDirenvNotAllowed, } from "../before/env.js";
8
8
  import { getPkgRoot } from "../../shared/package-roots.js";
9
+ import { readBkitConfig } from "../../shared/settings.js";
9
10
  import { detectOpencodeYmlProviderDrift } from "../../install/modules/opencode.js";
10
11
  import { detectManagedDuplicate, detectManagedStale } from "./managed.js";
11
12
  import { buildCloudDashboardsAdvisory, detectCiRouterSecrets, detectGhMcpToken } from "./auth.js";
12
- import { buildCloudSetupAdvisory, buildGithubProjectAdvisory, buildTrackerSetupAdvisory, detectActionsWritePermissions, detectGithubProjectFieldIdFormat, detectMainBranchProtection, readConsumerIssueTracker, } from "./github.js";
13
+ import { buildCloudSetupAdvisory, buildGithubProjectAdvisory, buildTrackerSetupAdvisory, detectActionsWritePermissions, detectGithubProjectFieldIdFormat, detectMainBranchProtection, } from "./github.js";
13
14
  import { buildDepUpdaterSetupAdvisory, detectBkitStubs, detectValePackageNotSynced, detectWorkflowLintToolsMissing, } from "./tools.js";
14
15
  import { detectBkitCloudYmlAlwaysTrueGate, detectCiYmlCapstoneContractDrift, detectCiYmlMissingActionlint, detectCiYmlRunInjection, detectGhaFloatingTags, detectRunLevelsNotComposed, detectTaggedTestsWithoutCiHome, detectTestIntegrationEnv, detectTurboIntegrationInputs, } from "./ci-yml.js";
15
16
  import { dropTipSilencedAdvisories, setupTipsChecklistLines, setupTipsMarkdownLines, } from "../tips/index.js";
@@ -389,7 +390,7 @@ export function runPostInstallCheck(preflightAdvisories, cwd = process.cwd(), su
389
390
  // writes, so Phase 1 cannot see it on first install.
390
391
  // Pass the consumer's tracker so the mcp-env prose omits BKIT_LINEAR_API_KEY on github/none
391
392
  // repos.
392
- const mcpEnvTracker = readConsumerIssueTracker(cwd);
393
+ const mcpEnvTracker = readBkitConfig(cwd).issueTracker;
393
394
  const missingDotenv = detectMissingDotenv(cwd, mcpEnvTracker);
394
395
  if (missingDotenv)
395
396
  phase3.push(missingDotenv);
@@ -5,26 +5,11 @@ import * as path from "node:path";
5
5
  import { spawnSync } from "node:child_process";
6
6
  import { getModuleManifest } from "../../install/manifest.js";
7
7
  import { readManagedVersion } from "../../install/version-file.js";
8
- import { getPkgRoot } from "../../shared/package-roots.js";
8
+ import { isSharedBranch } from "../../shared/branches.js";
9
+ import { readInstallingVersion } from "../../shared/package-json.js";
9
10
  import { detectMarkerStyle, extractManagedBlock, findLineAnchoredMarkers, findUnmarkedCopy, selectMarkers, stripManagedBlock, } from "../../install/managed-block.js";
10
11
  import { listStampedFiles } from "../../install/modules/index.js";
11
- // ---------------------------------------------------------------------------
12
- // detectManagedStale — managed-version marker gate over every stamped file
13
- // ---------------------------------------------------------------------------
14
- /**
15
- * Best-effort read of the installing bkit version from the package root.
16
- * Mirrors getInstallingVersion (commands/install/install.ts) / readInstallingVersion
17
- * (install/modules/index.ts); kept local to avoid a postinstall → install/modules import.
18
- */
19
- function readPkgVersion() {
20
- try {
21
- const pkg = JSON.parse(fs.readFileSync(path.join(getPkgRoot(), "package.json"), "utf-8"));
22
- return pkg.version ?? "0.0.0";
23
- }
24
- catch {
25
- return "0.0.0";
26
- }
27
- }
12
+ import { gitEnv } from "../../ledgers/telemetry.js";
28
13
  // ---------------------------------------------------------------------------
29
14
  // Branch-scoped severity for the stale gates
30
15
  //
@@ -32,8 +17,6 @@ function readPkgVersion() {
32
17
  // and a non-blocking ADVISORY everywhere else (still shown in the checklist). A PR
33
18
  // INTO main/dev re-asserts the blocker (via GITHUB_BASE_REF).
34
19
  // ---------------------------------------------------------------------------
35
- /** Branches where a stale managed-version marker is a hard blocker, not a warning. */
36
- const PROTECTED_BRANCHES = new Set(["main", "dev"]);
37
20
  /**
38
21
  * Resolve the branch the check is effectively gating, preferring the CI signal:
39
22
  * 1. `GITHUB_BASE_REF` — set on `pull_request` events to the MERGE TARGET. A PR
@@ -53,6 +36,7 @@ function currentBranch(cwd) {
53
36
  // not a thrown error needing a swallowing catch — null then means "undeterminable".
54
37
  const r = spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
55
38
  cwd,
39
+ env: gitEnv(),
56
40
  encoding: "utf-8",
57
41
  stdio: ["ignore", "pipe", "ignore"],
58
42
  });
@@ -68,7 +52,7 @@ export function isOnProtectedBranch(cwd = process.cwd()) {
68
52
  const b = currentBranch(cwd);
69
53
  if (b === null)
70
54
  return true; // undeterminable → fail safe to blocker
71
- return PROTECTED_BRANCHES.has(b);
55
+ return isSharedBranch(b);
72
56
  }
73
57
  /**
74
58
  * Version of the managed-version marker inside a file's first `bkit:start`…`bkit:end`
@@ -106,14 +90,14 @@ export function readManagedBlockVersion(content) {
106
90
  *
107
91
  * A block-scoped file without a bkit block is the consumer's (they dropped the block, or
108
92
  * never had bkit's) and is skipped; a whole file without a marker is stale. Files absent
109
- * on disk are skipped. A dev tree without a readable package version (`0.0.0` / empty)
93
+ * on disk are skipped. An installing version of `0.0.0` or empty (an unreleased tree)
110
94
  * yields null, as does a repo with nothing stamped.
111
95
  *
112
- * Severity is branch-scoped (see PROTECTED_BRANCHES): a `blocker` on main/dev (or a PR
96
+ * Severity is branch-scoped (see isSharedBranch): a `blocker` on main/dev (or a PR
113
97
  * into them), an `advisory` on feature branches. `installingVersion` and
114
98
  * `onProtectedBranch` are injected for testability.
115
99
  */
116
- export function detectManagedStale(cwd, installingVersion = readPkgVersion(), onProtectedBranch = isOnProtectedBranch(cwd)) {
100
+ export function detectManagedStale(cwd, installingVersion = readInstallingVersion(), onProtectedBranch = isOnProtectedBranch(cwd)) {
117
101
  if (!installingVersion || installingVersion === "0.0.0")
118
102
  return null;
119
103
  const stale = [];
@@ -3,6 +3,7 @@
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
5
  import { spawnSync } from "node:child_process";
6
+ import { readBkitConfig } from "../../shared/settings.js";
6
7
  /** True when `cmd --version` runs (binary on PATH, exits 0). */
7
8
  function toolVersionRuns(cmd) {
8
9
  const res = spawnSync(cmd, ["--version"], {
@@ -105,7 +106,7 @@ const BKIT_STUBS = [
105
106
  {
106
107
  id: "coverage",
107
108
  file: ".github/workflows/bkit-ci.yml",
108
- description: "Report vitest coverage on PRs via davelosert/vitest-coverage-report-action (free, runs inside Actions with GITHUB_TOKEN — no third-party service, safe for private repos). PER-TIER: unit and integration are measured and commented SEPARATELY (a single merged number lets integration mask a hollow unit suite — coverage is a union). Report-only by default: nothing fails the build until a threshold is set. Enabling (documented in the stub header): (1) add `@vitest/coverage-v8` (pinned to your vitest major) plus a vitest.config coverage block with `reporter: ['text','json-summary','json']` and `reportOnFailure: true` — json-summary + json are load-bearing (the action reads coverage-summary.json and coverage-final.json); (2) run coverage TWICE into separate dirs — unit → coverage/unit (exclude integration files), integration → coverage/integration — so each tier gets its own honest number (avoids the last-writer-wins clobber a second same-dir run would cause); (3) add a JOB-LEVEL permissions block to bkit-tests-unit with `actions: read` + `contents: read` + `pull-requests: write` — job-level REPLACES the workflow-level block (not additive) and the Check SHA Cache step needs `actions: read`, so omitting it breaks the cache step; (4) two report steps with distinct `name:` (unit / integration) pointing at each dir's coverage-summary.json + coverage-final.json. SEPARATE LANES (one job per tier): put the integration run + report + its OWN pull-requests: write block in bkit-tests-integration, not bkit-tests-unit — each lane posts its own comment. Thresholds are opt-in and PER TIER: UNIT is the gate — pass `--coverage.thresholds.branches` as a CLI flag on the unit run ONLY (vitest coverage is per-RUN/root config, NOT per-project — `projects` does not scope it and a config `thresholds` block reds BOTH runs; a per-run flag cannot leak to integration; branches is the meaningful floor, set to current and ratchet up). INTEGRATION is REPORT-ONLY — gate it on EXECUTION (the capstone's integration_ran > 0), not a %: a whole-repo integration % is denominator-noise (it covers boundaries/flows, not pure logic). For a real integration %, add `--coverage.include=src/server/**` on the integration run (same CLI-flag idiom as --exclude) then set a floor, or ratchet from current — never a picked number. Fork PRs: GITHUB_TOKEN is read-only, so keep the `head.repo == repo` guard on the steps (or use the action's workflow_run two-workflow pattern). Guard the integration report on `hashFiles('coverage/integration/coverage-summary.json') != ''` so a repo with no integration tier skips it cleanly.",
109
+ description: "Report vitest coverage on PRs and in every run's job summary via davelosert/vitest-coverage-report-action (free, runs inside Actions with GITHUB_TOKEN — no third-party service, safe for private repos). PER-TIER: unit and integration are measured and commented SEPARATELY (a single merged number lets integration mask a hollow unit suite — coverage is a union). Report-only by default: nothing fails the build until a threshold is set. Enabling (documented in the stub header): (1) add `@vitest/coverage-v8` (pinned to your vitest major) plus a vitest.config coverage block with `reporter: ['text','json-summary','json']` and `reportOnFailure: true` — json-summary + json are load-bearing (the action reads coverage-summary.json and coverage-final.json); (2) run coverage TWICE into separate dirs — unit → coverage/unit (exclude integration files), integration → coverage/integration — so each tier gets its own honest number (avoids the last-writer-wins clobber a second same-dir run would cause); (3) add a JOB-LEVEL permissions block to bkit-tests-unit with `actions: read` + `contents: read` + `pull-requests: write` — job-level REPLACES the workflow-level block (not additive) and the Check SHA Cache step needs `actions: read`, so omitting it breaks the cache step; (4) two report steps with distinct `name:` (unit / integration) pointing at each dir's coverage-summary.json + coverage-final.json; the unit step runs on every event (`if: !cancelled()` plus a `hashFiles` guard on its summary), sets `vite-config-path: vitest.unit.config.ts` so the job summary and PR comment show the floor as the target, and comments only on same-repo PRs (`comment-on: pr`, else `none`). SEPARATE LANES (one job per tier): put the integration run + report + its OWN pull-requests: write block in bkit-tests-integration, not bkit-tests-unit — each lane posts its own comment. Thresholds are opt-in and PER TIER: UNIT is the gate — put `coverage.thresholds.branches` in a `vitest.unit.config.ts` (`mergeConfig` over vitest.config) that ONLY the unit run loads via `-c` (vitest coverage is per-RUN/root config, NOT per-project — `projects` does not scope it and a `thresholds` block in vitest.config reds BOTH runs; the report action reads the same file as raw text, so keep the floor on one unquoted `branches: <n>` line and no other metric name + colon + number in it; branches is the meaningful floor, set to current and ratchet up). INTEGRATION is REPORT-ONLY — gate it on EXECUTION (the capstone's integration_ran > 0), not a %: a whole-repo integration % is denominator-noise (it covers boundaries/flows, not pure logic). For a real integration %, add `--coverage.include=src/server/**` on the integration run (same CLI-flag idiom as --exclude) then set a floor, or ratchet from current — never a picked number. Fork PRs: GITHUB_TOKEN is read-only, so the unit step sets `comment-on: none` there (its job summary still lands) and the integration step keeps the `head.repo == repo` guard (or use the action's workflow_run two-workflow pattern). Guard the integration report on `hashFiles('coverage/integration/coverage-summary.json') != ''` so a repo with no integration tier skips it cleanly.",
109
110
  },
110
111
  {
111
112
  id: "e2e-coverage",
@@ -303,20 +304,6 @@ function updaterConfigPaths(cwd) {
303
304
  : null;
304
305
  return { renovate, dependabot };
305
306
  }
306
- /** `bkit.depUpdater: "none"` silences the missing-updater suggestion. Other values are ignored. */
307
- function depUpdaterOptOut(cwd) {
308
- const pkgPath = path.join(cwd, "package.json");
309
- if (!fs.existsSync(pkgPath))
310
- return false;
311
- try {
312
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
313
- const bkitField = pkg.bkit;
314
- return bkitField?.depUpdater === "none";
315
- }
316
- catch {
317
- return false;
318
- }
319
- }
320
307
  /**
321
308
  * Read-only dependency-updater check.
322
309
  *
@@ -336,7 +323,7 @@ export function buildDepUpdaterSetupAdvisory(cwd) {
336
323
  }
337
324
  if (renovate || dependabot)
338
325
  return null;
339
- if (depUpdaterOptOut(cwd))
326
+ if (readBkitConfig(cwd).depUpdaterOptOut)
340
327
  return null;
341
328
  if (!fs.existsSync(path.join(cwd, ".github", "workflows")))
342
329
  return null;
@@ -3,7 +3,7 @@
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
5
  import { getTemplatesRoot } from "../../shared/package-roots.js";
6
- import { readPackageJson } from "../../shared/package-json.js";
6
+ import { readDependencyNames } from "../../shared/package-json.js";
7
7
  /**
8
8
  * Line-anchored consumer opt-out marker for the context-fetch advisories. A repo
9
9
  * that legitimately enables no runtime-log source places this below
@@ -96,26 +96,6 @@ const CONTEXT_FETCH_BACKEND_EVIDENCE = {
96
96
  fs.existsSync(path.join(cwd, ".vercel")) ||
97
97
  readDependencyNames(cwd).includes("vercel"),
98
98
  };
99
- /** Every dependency name across the four package.json dependency fields. */
100
- function readDependencyNames(cwd) {
101
- const read = readPackageJson(cwd);
102
- if (!read.ok)
103
- return [];
104
- const pkg = read.pkg;
105
- const names = [];
106
- for (const field of [
107
- "dependencies",
108
- "devDependencies",
109
- "optionalDependencies",
110
- "peerDependencies",
111
- ]) {
112
- const deps = pkg[field];
113
- if (deps && typeof deps === "object") {
114
- names.push(...Object.keys(deps));
115
- }
116
- }
117
- return names;
118
- }
119
99
  /**
120
100
  * Advisory: consumer's `.agents/context.md` has the bkit-managed block but no
121
101
  * `<!-- context-fetch:start <name> --> ... <!-- context-fetch:end -->` block AFTER
@@ -7,12 +7,11 @@
7
7
  // deepContains — from install/write.ts (JSON containment primitive)
8
8
  // extractManagedBlock — from install/managed-block.ts (marker block extraction)
9
9
  // findTemplateSource — from shared/package-roots.ts (dest → payload source, the dotfile remap)
10
- // parseIssueTracker — from install/manifest.ts (pure data, no cycle)
10
+ // readBkitConfig — from shared/settings.ts (the consumer's `bkit` settings)
11
+ // readInstallingVersion — from shared/package-json.ts (the version of the bkit doing the install)
11
12
  // readTemplate — from render/parts.ts (template with its shared parts spliced in)
12
- import * as fs from "node:fs";
13
- import * as path from "node:path";
14
- import { getPkgRoot } from "../../shared/package-roots.js";
15
- import { parseIssueTracker, DEFAULT_ISSUE_TRACKER, } from "../../install/manifest.js";
13
+ import { readInstallingVersion } from "../../shared/package-json.js";
14
+ import { readBkitConfig } from "../../shared/settings.js";
16
15
  import { detectBkitNotOnPath, detectMalformedPackageJson, detectNoPackageJson, detectNotGitRepo, } from "./repo.js";
17
16
  import { MARKERED_TEXT_DRIFT_PATHS, detectGitignoreBlockDuplicates, detectPlaywrightReporterHostile, detectTier2JsonDrift, detectTier2TextDrift, } from "./files.js";
18
17
  import { detectBkitVersionMajorDowngrade, detectBkitVersionPinStale } from "./version.js";
@@ -34,25 +33,6 @@ export function dedupeById(findings) {
34
33
  // ---------------------------------------------------------------------------
35
34
  // runPreflight — main Phase 1 entry point
36
35
  // ---------------------------------------------------------------------------
37
- /**
38
- * Read `bkit.issueTracker` from the consumer's package.json.
39
- * Returns the tracker value or the default ("none") when absent / unreadable.
40
- * Internal helper — not exported; use runPreflight's `issueTracker` param.
41
- */
42
- function readConsumerIssueTrackerForPreflight(cwd) {
43
- const pkgPath = path.join(cwd, "package.json");
44
- if (!fs.existsSync(pkgPath))
45
- return DEFAULT_ISSUE_TRACKER;
46
- try {
47
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
48
- const bkitField = pkg.bkit;
49
- const parsed = parseIssueTracker(bkitField?.issueTracker);
50
- return parsed ?? DEFAULT_ISSUE_TRACKER;
51
- }
52
- catch {
53
- return DEFAULT_ISSUE_TRACKER;
54
- }
55
- }
56
36
  /**
57
37
  * Run all Phase 1 (read-only) detectors.
58
38
  * Returns deduplicated { blockers, advisories } — intra-phase dedup by id,
@@ -68,27 +48,11 @@ function readConsumerIssueTrackerForPreflight(cwd) {
68
48
  * gate is a no-op — the GitHub gate is enforced by workflow Step 1 via MCP.
69
49
  */
70
50
  export function runPreflight(modules, cwd = process.cwd(), installingVersion, issueTracker) {
71
- // Resolve installing version if not provided
72
- let version = installingVersion;
73
- if (!version) {
74
- try {
75
- const pkgJsonPath = path.join(getPkgRoot(), "package.json");
76
- if (fs.existsSync(pkgJsonPath)) {
77
- const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
78
- version = pkg.version ?? "0.0.0";
79
- }
80
- else {
81
- version = "0.0.0";
82
- }
83
- }
84
- catch {
85
- version = "0.0.0";
86
- }
87
- }
51
+ const version = installingVersion || readInstallingVersion();
88
52
  // Resolve issueTracker: use provided value or read from consumer package.json.
89
53
  // GitHub tracker gate: when issueTracker === "github", Linear preflight is a no-op
90
54
  // (the GitHub gate is enforced by workflow Step 1 via MCP — hook is no-op).
91
- const resolvedTracker = issueTracker ?? readConsumerIssueTrackerForPreflight(cwd);
55
+ const resolvedTracker = issueTracker ?? readBkitConfig(cwd).issueTracker;
92
56
  const blockers = [];
93
57
  const advisories = [];
94
58
  // --- Blocker detectors ---
@@ -70,15 +70,23 @@ export function detectMissingMcpServers(cwd, relPath, issueTracker) {
70
70
  }
71
71
  return findings;
72
72
  }
73
+ /**
74
+ * The bkit-written MCP servers `tracker` has no use for: `BKIT_MCP_SERVERS` minus the
75
+ * tracker's own server and `TRACKER_INDEPENDENT_MCP_SERVERS`. What `detectExtraMcpServers`
76
+ * flags, and what a tracker switch removes while the entry still equals bkit's template.
77
+ */
78
+ export function unusedTrackerMcpServers(tracker) {
79
+ const allowed = requiredMcpServersForTracker(tracker);
80
+ return BKIT_MCP_SERVERS.filter((key) => !allowed.includes(key) && !TRACKER_INDEPENDENT_MCP_SERVERS.includes(key));
81
+ }
73
82
  /**
74
83
  * Advisory: one finding per bkit-written MCP server that is present in the file but NOT
75
84
  * required by the resolved tracker (the symmetric counterpart to `detectMissingMcpServers`).
76
- * Catches the stale-leftover case — e.g. a repo switched to `--tracker=github` but still
77
- * carrying the `linear` entry.
85
+ * Catches a leftover a tracker switch kept because the consumer edited it — e.g. a repo
86
+ * switched to `--tracker=github` still carrying a customised `linear` entry.
78
87
  *
79
- * Only flags tracker-only servers bkit itself writes (`BKIT_MCP_SERVERS` minus
80
- * `TRACKER_INDEPENDENT_MCP_SERVERS`). Consumer-added MCP servers (custom tooling, other
81
- * providers) are never flagged for removal.
88
+ * Only flags `unusedTrackerMcpServers(tracker)`. Consumer-added MCP servers (custom tooling,
89
+ * other providers) are never flagged for removal.
82
90
  *
83
91
  * `mapKey` names the server map: `mcpServers` (`.mcp.json`, `.cursor/mcp.json`) or `mcp`
84
92
  * (`.opencode/opencode.json`).
@@ -93,11 +101,8 @@ export function detectExtraMcpServers(cwd, relPath, issueTracker, mapKey = "mcpS
93
101
  const servers = readMcpServerMap(cwd, relPath, mapKey);
94
102
  if (!servers)
95
103
  return [];
96
- const allowed = requiredMcpServersForTracker(issueTracker);
97
104
  const findings = [];
98
- for (const key of BKIT_MCP_SERVERS) {
99
- if (allowed.includes(key) || TRACKER_INDEPENDENT_MCP_SERVERS.includes(key))
100
- continue;
105
+ for (const key of unusedTrackerMcpServers(issueTracker)) {
101
106
  if (!Object.prototype.hasOwnProperty.call(servers, key))
102
107
  continue;
103
108
  findings.push({