@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
@@ -22,7 +22,7 @@
22
22
  import * as fs from "node:fs";
23
23
  import * as path from "node:path";
24
24
  import * as readline from "node:readline";
25
- import type { JsonValue, WriteSet } from "../../install/write.js";
25
+ import { isJsonObject, type JsonValue, type WriteSet } from "../../install/write.js";
26
26
  import { stripManagedBlock, detectMarkerStyle } from "../../install/managed-block.js";
27
27
  import { readTemplate } from "../../render/parts.js";
28
28
  import {
@@ -33,20 +33,34 @@ import {
33
33
  ISSUE_TRACKERS,
34
34
  } from "../../install/manifest.js";
35
35
  import { OPENCODE_PROVIDERS } from "../../shared/egress.js";
36
+ import { parseJson } from "../../shared/json.js";
36
37
  import {
38
+ hashFile,
37
39
  isConsumerModified,
38
40
  mergeCanonicalHashes,
39
41
  readBkitVersion,
40
42
  writeBkitVersion,
41
43
  } from "../../install/version-file.js";
42
44
  import {
45
+ getBkitDocsRoot,
43
46
  getPkgRoot,
44
47
  getSharedRoot,
45
48
  findTemplateSource,
46
49
  TEMPLATE_COPIES_DIR,
47
50
  } from "../../shared/package-roots.js";
48
51
  import { PAYLOAD_LINKS } from "../../install/payload-links.js";
49
- import { removeOpencodeProviderBlock, renderOpencodeJson } from "../../install/modules/opencode.js";
52
+ import {
53
+ removeOpencodeProviderBlock,
54
+ renderOpencodeAgentsCommands,
55
+ renderOpencodeJson,
56
+ } from "../../install/modules/opencode.js";
57
+ import {
58
+ applyModelOverrides,
59
+ buildOpencodeModelLookup,
60
+ parseEffortMap,
61
+ } from "../../render/models.js";
62
+ import { readInstallingVersion } from "../../shared/package-json.js";
63
+ import { readBkitConfig } from "../../shared/settings.js";
50
64
  import {
51
65
  CLAUDE_CLOUD_RELPATH,
52
66
  CURSOR_CLOUD_RELPATH,
@@ -54,6 +68,7 @@ import {
54
68
  } from "../../install/cloud-env.js";
55
69
  import type { ModuleFlag, UninstallFlags } from "../../cli.js";
56
70
  import { LOG_PREFIX, setLogPrefix } from "../../shared/log-prefix.js";
71
+ import { type McpServerMapKey, unusedTrackerMcpServers } from "../../checks/before/mcp.js";
57
72
 
58
73
  // ---------------------------------------------------------------------------
59
74
  // Types
@@ -136,15 +151,8 @@ export function stripOpencodeJsonScope(
136
151
  cwd: string,
137
152
  ): Record<string, JsonValue> {
138
153
  const render = (tracker: IssueTracker, provider: string): Record<string, JsonValue> =>
139
- JSON.parse(renderOpencodeJson(templatePath, tracker, provider, cwd)) as Record<
140
- string,
141
- JsonValue
142
- >;
143
- const ownedMcp: Record<string, JsonValue> = {};
144
- for (const tracker of ISSUE_TRACKERS) {
145
- const { mcp } = render(tracker, OPENCODE_PROVIDERS[0]);
146
- if (isJsonObject(mcp)) Object.assign(ownedMcp, mcp);
147
- }
154
+ renderOpencodeDoc(templatePath, tracker, provider, cwd);
155
+ const ownedMcp = ownedOpencodeMcpEntries(templatePath, cwd);
148
156
  const ownedProviders: Record<string, JsonValue> = {};
149
157
  for (const provider of OPENCODE_PROVIDERS) {
150
158
  const rendered = render("none", provider).provider;
@@ -160,6 +168,28 @@ export function stripOpencodeJsonScope(
160
168
  return stripTier2JsonScope(out, rest);
161
169
  }
162
170
 
171
+ function renderOpencodeDoc(
172
+ templatePath: string,
173
+ tracker: IssueTracker,
174
+ provider: string,
175
+ cwd: string,
176
+ ): Record<string, JsonValue> {
177
+ return JSON.parse(renderOpencodeJson(templatePath, tracker, provider, cwd)) as Record<
178
+ string,
179
+ JsonValue
180
+ >;
181
+ }
182
+
183
+ /** Every tracker's `mcp` entry exactly as bkit renders it into `.opencode/opencode.json`. */
184
+ function ownedOpencodeMcpEntries(templatePath: string, cwd: string): Record<string, JsonValue> {
185
+ const owned: Record<string, JsonValue> = {};
186
+ for (const tracker of ISSUE_TRACKERS) {
187
+ const { mcp } = renderOpencodeDoc(templatePath, tracker, OPENCODE_PROVIDERS[0], cwd);
188
+ if (isJsonObject(mcp)) Object.assign(owned, mcp);
189
+ }
190
+ return owned;
191
+ }
192
+
163
193
  export function stripTier2JsonScope(
164
194
  consumerDoc: Record<string, JsonValue>,
165
195
  templateDoc: Record<string, JsonValue>,
@@ -237,23 +267,96 @@ export function stripMcpTrackerEntries(
237
267
 
238
268
  /**
239
269
  * Delete each entry of `doc[key]` identical to the same-named entry in `owned`, then drop
240
- * `doc[key]` once empty. Entries that differ, and names `owned` lacks, stay. Mutates `doc`.
270
+ * `doc[key]` once empty (unless `dropEmpty` is false). Entries that differ, and names `owned`
271
+ * lacks, stay. Mutates `doc`; returns the names deleted.
241
272
  */
242
273
  function removeOwnedEntries(
243
274
  doc: Record<string, JsonValue>,
244
275
  key: string,
245
276
  owned: Record<string, JsonValue>,
246
- ): void {
277
+ dropEmpty = true,
278
+ ): string[] {
247
279
  const entries = doc[key];
248
- if (!isJsonObject(entries)) return;
280
+ if (!isJsonObject(entries)) return [];
281
+ const removed: string[] = [];
249
282
  for (const [name, entry] of Object.entries(owned)) {
250
- if (JSON.stringify(entries[name]) === JSON.stringify(entry)) delete entries[name];
283
+ if (name in entries && JSON.stringify(entries[name]) === JSON.stringify(entry)) {
284
+ delete entries[name];
285
+ removed.push(name);
286
+ }
251
287
  }
252
- if (Object.keys(entries).length === 0) delete doc[key];
288
+ if (dropEmpty && Object.keys(entries).length === 0) delete doc[key];
289
+ return removed;
253
290
  }
254
291
 
255
- function isJsonObject(v: JsonValue | undefined): v is Record<string, JsonValue> {
256
- return v !== null && typeof v === "object" && !Array.isArray(v);
292
+ /** The files bkit writes a tracker MCP entry into, and the key of each one's server map. */
293
+ const TRACKER_MCP_FILES: ReadonlyArray<{ relPath: string; mapKey: McpServerMapKey }> = [
294
+ { relPath: ".mcp.json", mapKey: "mcpServers" },
295
+ { relPath: path.join(".cursor", "mcp.json"), mapKey: "mcpServers" },
296
+ { relPath: path.join(".opencode", "opencode.json"), mapKey: "mcp" },
297
+ ];
298
+
299
+ /**
300
+ * Tracker switch: remove each `unusedTrackerMcpServers(tracker)` entry from `.mcp.json`,
301
+ * `.cursor/mcp.json` and `.opencode/opencode.json` while it still equals bkit's template entry
302
+ * — the rule uninstall applies (`removeOwnedEntries`). An entry the consumer edited stays and
303
+ * is named in a warning. `.mcp.json` / `.cursor/mcp.json` keep an emptied `mcpServers` (the
304
+ * tracker-`none` render); `.opencode/opencode.json` drops an emptied `mcp`, as its render does.
305
+ * Absent and malformed files are skipped (the host module reports malformed JSON). Pushes each
306
+ * rewritten file onto `ws` and returns its path.
307
+ */
308
+ export function removeUnusedTrackerMcpEntries(
309
+ cwd: string,
310
+ tracker: IssueTracker,
311
+ dryRun: boolean,
312
+ ws: WriteSet,
313
+ logPrefix: string,
314
+ ): string[] {
315
+ const unused = unusedTrackerMcpServers(tracker);
316
+ const written: string[] = [];
317
+ for (const { relPath, mapKey } of TRACKER_MCP_FILES) {
318
+ const absPath = path.join(cwd, relPath);
319
+ const templatePath = findTemplateSource(relPath);
320
+ if (unused.length === 0 || templatePath === null || !fs.existsSync(absPath)) continue;
321
+ const parsed = parseJson(fs.readFileSync(absPath, "utf-8"));
322
+ const doc = parsed.ok ? (parsed.value as JsonValue) : null;
323
+ if (!isJsonObject(doc)) continue;
324
+ const servers = doc[mapKey];
325
+ if (!isJsonObject(servers)) continue;
326
+
327
+ let templateEntries: JsonValue | undefined;
328
+ if (mapKey === "mcp") {
329
+ templateEntries = ownedOpencodeMcpEntries(templatePath, cwd);
330
+ } else {
331
+ const template = parseJson(fs.readFileSync(templatePath, "utf-8"));
332
+ const templateDoc = template.ok ? (template.value as JsonValue) : null;
333
+ templateEntries = isJsonObject(templateDoc) ? templateDoc[mapKey] : undefined;
334
+ }
335
+ if (!isJsonObject(templateEntries)) continue;
336
+ const owned: Record<string, JsonValue> = {};
337
+ for (const name of unused) {
338
+ if (name in servers && name in templateEntries) owned[name] = templateEntries[name];
339
+ }
340
+
341
+ const removed = removeOwnedEntries(doc, mapKey, owned, mapKey === "mcp");
342
+ for (const name of Object.keys(owned).filter((n) => !removed.includes(n))) {
343
+ console.warn(
344
+ `${logPrefix} kept ${relPath} ${mapKey}.${name}: edited since bkit wrote it, and the ` +
345
+ `${tracker} tracker does not use it — remove it by hand if unneeded.`,
346
+ );
347
+ }
348
+ if (removed.length === 0) continue;
349
+ if (!dryRun) fs.writeFileSync(absPath, JSON.stringify(doc, null, 2) + "\n", "utf-8");
350
+ ws.writes.push({ path: absPath, action: "update" });
351
+ written.push(absPath);
352
+ for (const name of removed) {
353
+ console.log(
354
+ `${logPrefix} ${dryRun ? "[dry-run] " : ""}removed ${relPath} ${mapKey}.${name} ` +
355
+ `(the ${tracker} tracker does not use it)`,
356
+ );
357
+ }
358
+ }
359
+ return written;
257
360
  }
258
361
 
259
362
  // ---------------------------------------------------------------------------
@@ -273,8 +376,9 @@ const CORE_TEMPLATE_DOCTRINE: ManifestEntry[] = [
273
376
  { path: ".agents/context.md", format: "markered-text", module: "core" },
274
377
  { path: ".agents/docs.md", format: "markered-text", module: "core" },
275
378
  { path: ".agents/rules.md", format: "markered-text", module: "core" },
276
- { path: ".agents/shortcuts.md", format: "markered-text", module: "core" },
277
379
  { path: ".agents/skills.md", format: "markered-text", module: "core" },
380
+ // Retired path of `.bkit/lite.md` (5.1.0 – 5.2.4), for an install never upgraded since.
381
+ { path: ".agents/shortcuts.md", format: "markered-text", module: "core" },
278
382
  ];
279
383
 
280
384
  /**
@@ -604,12 +708,16 @@ export async function runUninstall(
604
708
  break;
605
709
  }
606
710
  const raw = fs.readFileSync(absPath, "utf-8");
607
- const consumerDoc = JSON.parse(raw) as Record<string, JsonValue>;
711
+ const consumerParsed = parseJson(raw);
712
+ if (!consumerParsed.ok) throw new Error(`${summary.file} is not valid JSON`);
713
+ const consumerDoc = consumerParsed.value as Record<string, JsonValue>;
608
714
  const templateRaw = fs.readFileSync(templatePath, "utf-8");
609
715
  // opencode.json ships `@@OPENCODE_*@@` sentinel KEYS; stripOpencodeJsonScope
610
716
  // renders them for every tracker and provider bkit can have written.
611
717
  const isOpencodeJson = templateRaw.includes("@@OPENCODE_TRACKER_MCP@@");
612
- const templateDoc = JSON.parse(templateRaw) as Record<string, JsonValue>;
718
+ const templateParsed = parseJson(templateRaw);
719
+ if (!templateParsed.ok) throw new Error(`${templatePath} is not valid JSON`);
720
+ const templateDoc = templateParsed.value as Record<string, JsonValue>;
613
721
  // `.claude/settings.json` is not written verbatim: after rendering the
614
722
  // template, install appends one `WebFetch(domain:<d>)` grant per entry in
615
723
  // the resolved network allowlist and `mcp__…` grants per declared MCP
@@ -959,13 +1067,8 @@ export async function runSurgicalOpencodeUninstall(
959
1067
 
960
1068
  if (fs.existsSync(pkgPath)) {
961
1069
  const raw = fs.readFileSync(pkgPath, "utf-8");
962
- // Parse-or-sentinel idiom: keep the early-return outside the catch body.
963
- let pkg: Record<string, unknown> | null = null;
964
- try {
965
- pkg = JSON.parse(raw) as Record<string, unknown>;
966
- } catch {
967
- pkg = null;
968
- }
1070
+ const parsed = parseJson(raw);
1071
+ const pkg = parsed.ok ? (parsed.value as Record<string, unknown> | null) : null;
969
1072
  if (pkg === null) {
970
1073
  console.warn(`${LOG_PREFIX} package.json is malformed — skipping bkit section update`);
971
1074
  return;
@@ -1016,13 +1119,68 @@ export async function runSurgicalOpencodeUninstall(
1016
1119
  return;
1017
1120
  }
1018
1121
 
1019
- // 4. If was active → emit advisory (re-rendering agents requires full ModuleContext)
1122
+ // 4. If was active → re-render the agent pins for the new active provider, so `bkit check`
1123
+ // finds the mirrors in sync right after.
1020
1124
  if (wasActive && newActive !== null) {
1021
- console.log(
1022
- `${LOG_PREFIX}${tag} active provider switched to "${newActive}". ` +
1023
- `Run \`bkit install --opencode=${newActive}\` or \`bkit upgrade\` to re-render agent frontmatter.`,
1024
- );
1125
+ if (dryRun) {
1126
+ console.log(
1127
+ `${LOG_PREFIX}${tag} active provider would switch to "${newActive}" — .opencode/agents/ ` +
1128
+ `would be re-rendered to its model pins.`,
1129
+ );
1130
+ return;
1131
+ }
1132
+ const previousCwd = process.cwd();
1133
+ process.chdir(cwd);
1134
+ try {
1135
+ const written = rerenderOpencodeMirrors(newActive, LOG_PREFIX);
1136
+ console.log(
1137
+ `${LOG_PREFIX} active provider switched to "${newActive}" — re-rendered ` +
1138
+ `${written.length} .opencode/ agent/command file(s) to its model pins.`,
1139
+ );
1140
+ } finally {
1141
+ process.chdir(previousCwd);
1142
+ }
1143
+ }
1144
+ }
1145
+
1146
+ /**
1147
+ * Re-render `.opencode/agents/` + `.opencode/commands/` for `provider` — the per-agent model
1148
+ * pins `bkit check` expects once `provider` is the active one, consumer `.bkit/prompts.md`
1149
+ * § Model Overrides applied — and refresh their `.bkit/version` hashes. Renders into
1150
+ * process.cwd(), as the host renderers resolve consumer paths from it. Returns the paths written.
1151
+ */
1152
+ function rerenderOpencodeMirrors(provider: string, logPrefix: string): string[] {
1153
+ const cwd = process.cwd();
1154
+ const promptsMd = path.join(getBkitDocsRoot(), "prompts.md");
1155
+ const opencodeModelLookup = buildOpencodeModelLookup(promptsMd, provider);
1156
+ applyModelOverrides(opencodeModelLookup, provider, path.join(cwd, ".bkit", "prompts.md"));
1157
+ const written = renderOpencodeAgentsCommands({
1158
+ dryRun: false,
1159
+ tokens: { DEFAULT_BRANCH: "", PROJECT_NAME: "", REPO_SLUG: "" },
1160
+ modelLookup: new Map(),
1161
+ opencodeModelLookup,
1162
+ effortMap: parseEffortMap(promptsMd),
1163
+ opencodeProvider: provider,
1164
+ advisories: [],
1165
+ ws: { writes: [] },
1166
+ logPrefix,
1167
+ postDispatch: [],
1168
+ issueTracker: readBkitConfig(cwd).issueTracker,
1169
+ version: readInstallingVersion(),
1170
+ });
1171
+
1172
+ const versionFile = path.join(cwd, ".bkit", "version");
1173
+ const existing = readBkitVersion(versionFile);
1174
+ if (existing && written.length > 0) {
1175
+ const fresh: Record<string, string> = {};
1176
+ for (const rel of written) {
1177
+ const hash = hashFile(path.join(cwd, rel));
1178
+ if (hash) fresh[rel] = hash;
1179
+ }
1180
+ const { canonicalHashes } = mergeCanonicalHashes(cwd, existing.canonicalHashes, fresh);
1181
+ writeBkitVersion(versionFile, { ...existing, canonicalHashes });
1025
1182
  }
1183
+ return written;
1026
1184
  }
1027
1185
 
1028
1186
  export async function runUninstallCommand(
@@ -39,26 +39,25 @@ import {
39
39
  getCoreRoot,
40
40
  getSharedRoot,
41
41
  getBkitDocsRoot,
42
- getPkgRoot,
43
42
  } from "../../shared/package-roots.js";
44
- import type { ModuleFlag, UpgradeFlags } from "../../cli.js";
43
+ import { readDependencySpec, readInstallingVersion } from "../../shared/package-json.js";
44
+ import type { UpgradeFlags } from "../../cli.js";
45
45
  import {
46
- getInstallingVersion,
47
46
  requireOpencodeProvider,
48
47
  detectOpencodeProviders,
49
48
  runUpgradeAdvisories,
50
49
  } from "./install.js";
51
50
  import { setLogPrefix } from "../../shared/log-prefix.js";
52
51
  import { BKIT_PACKAGE, lookupLatestPublished } from "../../shared/bkit-latest.js";
52
+ import { PACKAGE_RUNNER } from "../../shared/package-manager.js";
53
53
  import {
54
54
  getInstallManifest,
55
55
  getModuleManifest,
56
56
  type ModuleName,
57
57
  type IssueTracker,
58
- DEFAULT_ISSUE_TRACKER,
59
- parseIssueTracker,
60
58
  } from "../../install/manifest.js";
61
59
  import { OPTIN_MODULES } from "../../install/manifest.js";
60
+ import { readBkitConfig } from "../../shared/settings.js";
62
61
  import { detectInstalledHostModules } from "../../install/hosts.js";
63
62
  import { detectInstalledModules } from "./check.js";
64
63
  import { remapTemplateDest } from "../../install/template-copies.js";
@@ -67,7 +66,6 @@ import {
67
66
  CURSOR_CLOUD_RELPATH,
68
67
  writeClaudeCloudDoc,
69
68
  writeCursorCloudDoc,
70
- writeNetworkAllowlistArtifact,
71
69
  writeCursorCliPermissionsArtifact,
72
70
  } from "../../install/cloud-env.js";
73
71
  import { syncTemplateCopies, formatTemplateChanges } from "../../install/template-copies.js";
@@ -108,18 +106,36 @@ export type SelfBumpPlan =
108
106
  | { kind: "invalid"; message: string }
109
107
  /** Already at the target → caller falls through to a normal in-place re-render. */
110
108
  | { kind: "noop"; target: string }
111
- /** Install `target`, then re-exec the new binary to re-render + re-pin. */
112
- | { kind: "bump"; target: string };
109
+ /**
110
+ * Install `target`, then re-exec the new binary to re-render + re-pin. `fromSpec` names the
111
+ * non-registry spec being replaced when the installed version already equals `target`.
112
+ */
113
+ | { kind: "bump"; target: string; fromSpec?: string };
114
+
115
+ /**
116
+ * True when a `package.json` dependency spec resolves from the registry: a version, range or
117
+ * dist-tag. `file:` / `link:` / `workspace:` / `npm:` alias / git / URL / path specs are not.
118
+ */
119
+ export function isRegistrySpec(spec: string): boolean {
120
+ const s = spec.trim();
121
+ return !/[:/\\]/.test(s) && !s.startsWith(".");
122
+ }
113
123
 
114
124
  /**
115
125
  * Resolve the self-bump target and decide the action. `resolveLatest` is only
116
126
  * invoked for `--latest` (it shells out to the registry in production); injected
117
127
  * so tests stay offline. A leading `v` is tolerated on either source.
128
+ *
129
+ * `installedSpec` is the consumer `package.json` spec for @cbartens/bkit (`null` when
130
+ * undeclared). A matching version string is a no-op only when that spec resolves from the
131
+ * registry: a `file:` tarball or other non-registry install at the same version still bumps,
132
+ * so `pnpm add` replaces it with the published package.
118
133
  */
119
134
  export function planSelfBump(
120
135
  installed: string,
121
136
  flags: { toVersion: string | null; latest: boolean },
122
137
  resolveLatest: () => string,
138
+ installedSpec: string | null = null,
123
139
  ): SelfBumpPlan {
124
140
  let target: string;
125
141
  if (flags.toVersion !== null) {
@@ -141,8 +157,9 @@ export function planSelfBump(
141
157
  };
142
158
  }
143
159
  }
144
- if (target === installed.trim().replace(/^v/, "")) return { kind: "noop", target };
145
- return { kind: "bump", target };
160
+ if (target !== installed.trim().replace(/^v/, "")) return { kind: "bump", target };
161
+ if (installedSpec === null || isRegistrySpec(installedSpec)) return { kind: "noop", target };
162
+ return { kind: "bump", target, fromSpec: installedSpec };
146
163
  }
147
164
 
148
165
  export const LOG_PREFIX = "[bkit-upgrade]";
@@ -482,7 +499,7 @@ export function updateCanonicalHashesAfterUpgrade(
482
499
 
483
500
  const fresh: Record<string, string> = {};
484
501
  for (const relPath of seedablePaths) {
485
- // Exclude .agents/ internal files (docs.md, friction.md, rules.md, shortcuts.md,
502
+ // Exclude .agents/ internal files (docs.md, rules.md,
486
503
  // skills.md, .env.example etc.) from canonicalHashes — they are not consumer-facing files
487
504
  // whose hashes bkit uses for drift detection. Mirrors the same filter applied
488
505
  // in the install path (install/modules/index.ts postDispatch). Template copies carry no
@@ -561,13 +578,14 @@ function resolveLatestPublishedVersion(cwd: string): string {
561
578
  * caller falls through to a normal in-place re-render.
562
579
  */
563
580
  export async function runSelfBump(flags: UpgradeFlags, cwd: string): Promise<boolean> {
564
- const installed = getInstallingVersion();
581
+ const installed = readInstallingVersion();
565
582
  // Resolve the latest first (only when asked), then feed planSelfBump a constant.
566
583
  const latestVersion = flags.latest ? resolveLatestPublishedVersion(cwd) : "";
567
584
  const resolvedPlan = planSelfBump(
568
585
  installed,
569
586
  { toVersion: flags.toVersion, latest: flags.latest },
570
587
  () => latestVersion,
588
+ readDependencySpec(cwd, BKIT_PACKAGE),
571
589
  );
572
590
 
573
591
  if (resolvedPlan.kind === "invalid") {
@@ -596,10 +614,11 @@ export async function runSelfBump(flags: UpgradeFlags, cwd: string): Promise<boo
596
614
  ...(inWorkspaceRoot ? ["-w"] : []),
597
615
  `@cbartens/bkit@${resolvedPlan.target}`,
598
616
  ];
599
- const addCmd = `pnpm ${addArgs.join(" ")}`;
617
+ const addCmd = [PACKAGE_RUNNER, ...addArgs].join(" ");
618
+ const from = resolvedPlan.fromSpec ? `${installed} (${resolvedPlan.fromSpec})` : installed;
600
619
  if (flags.dryRun) {
601
620
  console.log(
602
- `${LOG_PREFIX} [dry-run] would bump @cbartens/bkit ${installed} -> ${resolvedPlan.target} ` +
621
+ `${LOG_PREFIX} [dry-run] would bump @cbartens/bkit ${from} -> ${resolvedPlan.target} ` +
603
622
  `(${addCmd}), then re-render + re-pin via the ` +
604
623
  `freshly-installed binary. No changes made.`,
605
624
  );
@@ -607,8 +626,8 @@ export async function runSelfBump(flags: UpgradeFlags, cwd: string): Promise<boo
607
626
  }
608
627
 
609
628
  const { spawnSync } = await import("node:child_process");
610
- console.log(`${LOG_PREFIX} bumping @cbartens/bkit ${installed} -> ${resolvedPlan.target} ...`);
611
- const add = spawnSync("pnpm", addArgs, {
629
+ console.log(`${LOG_PREFIX} bumping @cbartens/bkit ${from} -> ${resolvedPlan.target} ...`);
630
+ const add = spawnSync(PACKAGE_RUNNER, addArgs, {
612
631
  cwd,
613
632
  stdio: "inherit",
614
633
  });
@@ -624,7 +643,7 @@ export async function runSelfBump(flags: UpgradeFlags, cwd: string): Promise<boo
624
643
  console.log(`${LOG_PREFIX} re-rendering with @cbartens/bkit@${resolvedPlan.target} ...`);
625
644
  const reArgs = ["exec", "bkit", "upgrade"];
626
645
  if (flags.nonInteractive) reArgs.push("--auto-apply");
627
- const re = spawnSync("pnpm", reArgs, { cwd, stdio: "inherit" });
646
+ const re = spawnSync(PACKAGE_RUNNER, reArgs, { cwd, stdio: "inherit" });
628
647
  process.exit(re.status ?? 1);
629
648
  }
630
649
 
@@ -641,6 +660,9 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
641
660
  if (handled) return;
642
661
  }
643
662
 
663
+ // Read before any write: a damaged bkit package stops the run with nothing changed.
664
+ const installingVersion = readInstallingVersion();
665
+
644
666
  console.log(
645
667
  `${LOG_PREFIX} Running upgrade${upgradeFlags.dryRun ? " (dry-run)" : ""}${upgradeFlags.nonInteractive ? " (non-interactive)" : ""}`,
646
668
  );
@@ -686,16 +708,7 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
686
708
 
687
709
  // Resolve the consumer's tracker so upgrade renders tracker-conditional files
688
710
  // (opencode.json, the mcp.json files) the same way install does.
689
- let upgradeTracker: IssueTracker = DEFAULT_ISSUE_TRACKER;
690
- try {
691
- const pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), "package.json"), "utf-8")) as {
692
- bkit?: { issueTracker?: unknown };
693
- };
694
- const stored = parseIssueTracker(pkg.bkit?.issueTracker);
695
- if (stored !== null) upgradeTracker = stored;
696
- } catch {
697
- // package.json absent/unparseable — default tracker
698
- }
711
+ const upgradeTracker: IssueTracker = readBkitConfig(process.cwd()).issueTracker;
699
712
 
700
713
  // opencode.json is provider/tracker-templated on install (renderOpencodeJson resolves the
701
714
  // `@@OPENCODE_*@@` sentinels). Upgrade renders it the same way, with the installed
@@ -901,7 +914,7 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
901
914
  cloudVariant: null,
902
915
  // Re-stamp every rendered agent + command at the version we are upgrading TO,
903
916
  // so a clean upgrade refreshes the managed-version marker and `bkit check` stays green.
904
- version: getInstallingVersion(),
917
+ version: installingVersion,
905
918
  // The detected host set — read by the Antigravity module for the Codex-overlap advisory.
906
919
  installedModules: renderModules,
907
920
  };
@@ -960,22 +973,17 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
960
973
  }
961
974
 
962
975
  // Network allowlist + MCP allows — OpenCode from renderOpencodeJson; Claude enrich
963
- // below; Cursor `.cursor/allowlist.json` + `.cursor/cli.json` only when cursor
964
- // module installed. Written artifacts get their canonicalHashes refreshed below.
976
+ // below; `.bkit/allowlist.json` in renderManagedOutputs above; Cursor
977
+ // `.cursor/cli.json` only when cursor module installed. Written artifacts get their
978
+ // canonicalHashes refreshed below.
965
979
  const artifactWrites: string[] = [];
966
980
  {
967
981
  const cwd = process.cwd();
968
982
  if (renderModules.has("cursor")) {
969
- for (const art of [
970
- writeNetworkAllowlistArtifact(cwd, upgradeFlags.dryRun),
971
- writeCursorCliPermissionsArtifact(cwd, upgradeFlags.dryRun),
972
- ]) {
973
- if (art.wrote) {
974
- artifactWrites.push(art.path);
975
- console.log(
976
- `${LOG_PREFIX}${upgradeFlags.dryRun ? " [dry-run]" : ""} upgrade: ${art.path}`,
977
- );
978
- }
983
+ const art = writeCursorCliPermissionsArtifact(cwd, upgradeFlags.dryRun);
984
+ if (art.wrote) {
985
+ artifactWrites.push(art.path);
986
+ console.log(`${LOG_PREFIX}${upgradeFlags.dryRun ? " [dry-run]" : ""} upgrade: ${art.path}`);
979
987
  }
980
988
  }
981
989
  if (renderModules.has("claude") && fs.existsSync(path.join(cwd, ".claude", "settings.json"))) {
@@ -1002,8 +1010,6 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
1002
1010
  // exit), so feed those writes into canonicalHashes — keeping install/upgrade `.bkit/version`
1003
1011
  // parity.
1004
1012
  if (!upgradeFlags.dryRun) {
1005
- const pkgVersion = JSON.parse(fs.readFileSync(path.join(getPkgRoot(), "package.json"), "utf-8"))
1006
- .version as string;
1007
1013
  const renderedDocPaths = renderWs.writes.map((w) =>
1008
1014
  path.relative(
1009
1015
  process.cwd(),
@@ -1025,7 +1031,7 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
1025
1031
  {
1026
1032
  dryRun: false,
1027
1033
  cwd: process.cwd(),
1028
- pinnedVersion: pkgVersion,
1034
+ pinnedVersion: installingVersion,
1029
1035
  claudeAllowDerived: upgradeClaudeAllowDerived,
1030
1036
  },
1031
1037
  );