@vibesdotdev/plugins 0.0.0-stage → 1.0.0-rc.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 (330) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +54 -2
  3. package/VIBES.md +165 -0
  4. package/dist/ai/index.d.ts +4 -0
  5. package/dist/ai/index.d.ts.map +1 -0
  6. package/dist/ai/index.js +3 -0
  7. package/dist/ai/index.js.map +1 -0
  8. package/dist/ai/plugin.impl.cloud.d.ts +4 -0
  9. package/dist/ai/plugin.impl.cloud.d.ts.map +1 -0
  10. package/dist/ai/plugin.impl.cloud.js +32 -0
  11. package/dist/ai/plugin.impl.cloud.js.map +1 -0
  12. package/dist/ai/plugin.impl.consumer.d.ts +7 -0
  13. package/dist/ai/plugin.impl.consumer.d.ts.map +1 -0
  14. package/dist/ai/plugin.impl.consumer.js +222 -0
  15. package/dist/ai/plugin.impl.consumer.js.map +1 -0
  16. package/dist/auth/consumer.plugin.d.ts +3 -0
  17. package/dist/auth/consumer.plugin.d.ts.map +1 -0
  18. package/dist/auth/consumer.plugin.js +105 -0
  19. package/dist/auth/consumer.plugin.js.map +1 -0
  20. package/dist/auth/index.d.ts +2 -0
  21. package/dist/auth/index.d.ts.map +1 -0
  22. package/dist/auth/index.js +2 -0
  23. package/dist/auth/index.js.map +1 -0
  24. package/dist/auth/plugin.d.ts +4 -0
  25. package/dist/auth/plugin.d.ts.map +1 -0
  26. package/dist/auth/plugin.js +33 -0
  27. package/dist/auth/plugin.js.map +1 -0
  28. package/dist/automation/consumer.plugin.d.ts +3 -0
  29. package/dist/automation/consumer.plugin.d.ts.map +1 -0
  30. package/dist/automation/consumer.plugin.js +92 -0
  31. package/dist/automation/consumer.plugin.js.map +1 -0
  32. package/dist/automation/index.d.ts +2 -0
  33. package/dist/automation/index.d.ts.map +1 -0
  34. package/dist/automation/index.js +2 -0
  35. package/dist/automation/index.js.map +1 -0
  36. package/dist/automation/plugin.d.ts +4 -0
  37. package/dist/automation/plugin.d.ts.map +1 -0
  38. package/dist/automation/plugin.js +30 -0
  39. package/dist/automation/plugin.js.map +1 -0
  40. package/dist/bun/host.d.ts +44 -0
  41. package/dist/bun/host.d.ts.map +1 -0
  42. package/dist/bun/host.js +71 -0
  43. package/dist/bun/host.js.map +1 -0
  44. package/dist/cli/child-failure.d.ts +37 -0
  45. package/dist/cli/child-failure.d.ts.map +1 -0
  46. package/dist/cli/child-failure.js +86 -0
  47. package/dist/cli/child-failure.js.map +1 -0
  48. package/dist/cli/context.d.ts +12 -0
  49. package/dist/cli/context.d.ts.map +1 -0
  50. package/dist/cli/context.js +11 -0
  51. package/dist/cli/context.js.map +1 -0
  52. package/dist/cli/execution.d.ts +10 -0
  53. package/dist/cli/execution.d.ts.map +1 -0
  54. package/dist/cli/execution.js +20 -0
  55. package/dist/cli/execution.js.map +1 -0
  56. package/dist/cli/failure-facts.d.ts +16 -0
  57. package/dist/cli/failure-facts.d.ts.map +1 -0
  58. package/dist/cli/failure-facts.js +39 -0
  59. package/dist/cli/failure-facts.js.map +1 -0
  60. package/dist/cli/package-manager.consumer.d.ts +106 -0
  61. package/dist/cli/package-manager.consumer.d.ts.map +1 -0
  62. package/dist/cli/package-manager.consumer.js +258 -0
  63. package/dist/cli/package-manager.consumer.js.map +1 -0
  64. package/dist/cli/plugin.d.ts +9 -0
  65. package/dist/cli/plugin.d.ts.map +1 -0
  66. package/dist/cli/plugin.js +34 -0
  67. package/dist/cli/plugin.js.map +1 -0
  68. package/dist/cli/plugins.add.cli-command.descriptor.d.ts +36 -0
  69. package/dist/cli/plugins.add.cli-command.descriptor.d.ts.map +1 -0
  70. package/dist/cli/plugins.add.cli-command.descriptor.js +31 -0
  71. package/dist/cli/plugins.add.cli-command.descriptor.js.map +1 -0
  72. package/dist/cli/plugins.add.cli-command.impl.consumer.d.ts +63 -0
  73. package/dist/cli/plugins.add.cli-command.impl.consumer.d.ts.map +1 -0
  74. package/dist/cli/plugins.add.cli-command.impl.consumer.js +206 -0
  75. package/dist/cli/plugins.add.cli-command.impl.consumer.js.map +1 -0
  76. package/dist/cli/plugins.cli-group.descriptor.d.ts +4 -0
  77. package/dist/cli/plugins.cli-group.descriptor.d.ts.map +1 -0
  78. package/dist/cli/plugins.cli-group.descriptor.js +10 -0
  79. package/dist/cli/plugins.cli-group.descriptor.js.map +1 -0
  80. package/dist/cli/plugins.host.cli-command.descriptor.d.ts +31 -0
  81. package/dist/cli/plugins.host.cli-command.descriptor.d.ts.map +1 -0
  82. package/dist/cli/plugins.host.cli-command.descriptor.js +37 -0
  83. package/dist/cli/plugins.host.cli-command.descriptor.js.map +1 -0
  84. package/dist/cli/plugins.host.cli-command.impl.consumer.d.ts +29 -0
  85. package/dist/cli/plugins.host.cli-command.impl.consumer.d.ts.map +1 -0
  86. package/dist/cli/plugins.host.cli-command.impl.consumer.js +109 -0
  87. package/dist/cli/plugins.host.cli-command.impl.consumer.js.map +1 -0
  88. package/dist/cli/plugins.link.cli-command.descriptor.d.ts +35 -0
  89. package/dist/cli/plugins.link.cli-command.descriptor.d.ts.map +1 -0
  90. package/dist/cli/plugins.link.cli-command.descriptor.js +32 -0
  91. package/dist/cli/plugins.link.cli-command.descriptor.js.map +1 -0
  92. package/dist/cli/plugins.link.cli-command.impl.consumer.d.ts +31 -0
  93. package/dist/cli/plugins.link.cli-command.impl.consumer.d.ts.map +1 -0
  94. package/dist/cli/plugins.link.cli-command.impl.consumer.js +104 -0
  95. package/dist/cli/plugins.link.cli-command.impl.consumer.js.map +1 -0
  96. package/dist/cli/plugins.list.cli-command.descriptor.d.ts +26 -0
  97. package/dist/cli/plugins.list.cli-command.descriptor.d.ts.map +1 -0
  98. package/dist/cli/plugins.list.cli-command.descriptor.js +22 -0
  99. package/dist/cli/plugins.list.cli-command.descriptor.js.map +1 -0
  100. package/dist/cli/plugins.list.cli-command.impl.consumer.d.ts +116 -0
  101. package/dist/cli/plugins.list.cli-command.impl.consumer.d.ts.map +1 -0
  102. package/dist/cli/plugins.list.cli-command.impl.consumer.js +343 -0
  103. package/dist/cli/plugins.list.cli-command.impl.consumer.js.map +1 -0
  104. package/dist/cli/plugins.remove.cli-command.descriptor.d.ts +31 -0
  105. package/dist/cli/plugins.remove.cli-command.descriptor.d.ts.map +1 -0
  106. package/dist/cli/plugins.remove.cli-command.descriptor.js +26 -0
  107. package/dist/cli/plugins.remove.cli-command.descriptor.js.map +1 -0
  108. package/dist/cli/plugins.remove.cli-command.impl.consumer.d.ts +30 -0
  109. package/dist/cli/plugins.remove.cli-command.impl.consumer.d.ts.map +1 -0
  110. package/dist/cli/plugins.remove.cli-command.impl.consumer.js +80 -0
  111. package/dist/cli/plugins.remove.cli-command.impl.consumer.js.map +1 -0
  112. package/dist/cli/plugins.unlink.cli-command.descriptor.d.ts +31 -0
  113. package/dist/cli/plugins.unlink.cli-command.descriptor.d.ts.map +1 -0
  114. package/dist/cli/plugins.unlink.cli-command.descriptor.js +21 -0
  115. package/dist/cli/plugins.unlink.cli-command.descriptor.js.map +1 -0
  116. package/dist/cli/plugins.unlink.cli-command.impl.consumer.d.ts +76 -0
  117. package/dist/cli/plugins.unlink.cli-command.impl.consumer.d.ts.map +1 -0
  118. package/dist/cli/plugins.unlink.cli-command.impl.consumer.js +190 -0
  119. package/dist/cli/plugins.unlink.cli-command.impl.consumer.js.map +1 -0
  120. package/dist/cli/registry-sign-in.consumer.d.ts +80 -0
  121. package/dist/cli/registry-sign-in.consumer.d.ts.map +1 -0
  122. package/dist/cli/registry-sign-in.consumer.js +199 -0
  123. package/dist/cli/registry-sign-in.consumer.js.map +1 -0
  124. package/dist/cli/roll.d.ts +230 -0
  125. package/dist/cli/roll.d.ts.map +1 -0
  126. package/dist/cli/roll.js +569 -0
  127. package/dist/cli/roll.js.map +1 -0
  128. package/dist/cli/schemas/context.d.ts +10 -0
  129. package/dist/cli/schemas/context.d.ts.map +1 -0
  130. package/dist/cli/schemas/context.js +3 -0
  131. package/dist/cli/schemas/context.js.map +1 -0
  132. package/dist/cli/schemas/scopes.d.ts +37 -0
  133. package/dist/cli/schemas/scopes.d.ts.map +1 -0
  134. package/dist/cli/schemas/scopes.js +11 -0
  135. package/dist/cli/schemas/scopes.js.map +1 -0
  136. package/dist/cli/schemas/unlink.d.ts +18 -0
  137. package/dist/cli/schemas/unlink.d.ts.map +1 -0
  138. package/dist/cli/schemas/unlink.js +3 -0
  139. package/dist/cli/schemas/unlink.js.map +1 -0
  140. package/dist/cli/schemas/update.d.ts +77 -0
  141. package/dist/cli/schemas/update.d.ts.map +1 -0
  142. package/dist/cli/schemas/update.js +3 -0
  143. package/dist/cli/schemas/update.js.map +1 -0
  144. package/dist/cli/scopes.d.ts +50 -0
  145. package/dist/cli/scopes.d.ts.map +1 -0
  146. package/dist/cli/scopes.js +90 -0
  147. package/dist/cli/scopes.js.map +1 -0
  148. package/dist/cli/seed.d.ts +232 -0
  149. package/dist/cli/seed.d.ts.map +1 -0
  150. package/dist/cli/seed.js +590 -0
  151. package/dist/cli/seed.js.map +1 -0
  152. package/dist/cli/self-update.d.ts +120 -0
  153. package/dist/cli/self-update.d.ts.map +1 -0
  154. package/dist/cli/self-update.js +274 -0
  155. package/dist/cli/self-update.js.map +1 -0
  156. package/dist/cli/update.cli-command.descriptor.d.ts +62 -0
  157. package/dist/cli/update.cli-command.descriptor.d.ts.map +1 -0
  158. package/dist/cli/update.cli-command.descriptor.js +49 -0
  159. package/dist/cli/update.cli-command.descriptor.js.map +1 -0
  160. package/dist/cli/update.cli-command.impl.consumer.d.ts +178 -0
  161. package/dist/cli/update.cli-command.impl.consumer.d.ts.map +1 -0
  162. package/dist/cli/update.cli-command.impl.consumer.js +750 -0
  163. package/dist/cli/update.cli-command.impl.consumer.js.map +1 -0
  164. package/dist/comms/consumer.plugin.d.ts +3 -0
  165. package/dist/comms/consumer.plugin.d.ts.map +1 -0
  166. package/dist/comms/consumer.plugin.js +108 -0
  167. package/dist/comms/consumer.plugin.js.map +1 -0
  168. package/dist/comms/index.d.ts +2 -0
  169. package/dist/comms/index.d.ts.map +1 -0
  170. package/dist/comms/index.js +2 -0
  171. package/dist/comms/index.js.map +1 -0
  172. package/dist/comms/plugin.d.ts +4 -0
  173. package/dist/comms/plugin.d.ts.map +1 -0
  174. package/dist/comms/plugin.js +30 -0
  175. package/dist/comms/plugin.js.map +1 -0
  176. package/dist/consumer.d.ts +3 -0
  177. package/dist/consumer.d.ts.map +1 -0
  178. package/dist/consumer.js +3 -0
  179. package/dist/consumer.js.map +1 -0
  180. package/dist/consumer.plugin.d.ts +63 -0
  181. package/dist/consumer.plugin.d.ts.map +1 -0
  182. package/dist/consumer.plugin.js +89 -0
  183. package/dist/consumer.plugin.js.map +1 -0
  184. package/dist/core/consumer.plugin.d.ts +4 -0
  185. package/dist/core/consumer.plugin.d.ts.map +1 -0
  186. package/dist/core/consumer.plugin.js +358 -0
  187. package/dist/core/consumer.plugin.js.map +1 -0
  188. package/dist/core/index.d.ts +2 -0
  189. package/dist/core/index.d.ts.map +1 -0
  190. package/dist/core/index.js +2 -0
  191. package/dist/core/index.js.map +1 -0
  192. package/dist/core/optional-member.d.ts +11 -0
  193. package/dist/core/optional-member.d.ts.map +1 -0
  194. package/dist/core/optional-member.js +68 -0
  195. package/dist/core/optional-member.js.map +1 -0
  196. package/dist/core/optional-plugin.d.ts +40 -0
  197. package/dist/core/optional-plugin.d.ts.map +1 -0
  198. package/dist/core/optional-plugin.js +107 -0
  199. package/dist/core/optional-plugin.js.map +1 -0
  200. package/dist/core/plugin.d.ts +10 -0
  201. package/dist/core/plugin.d.ts.map +1 -0
  202. package/dist/core/plugin.js +64 -0
  203. package/dist/core/plugin.js.map +1 -0
  204. package/dist/core/setup-requirements.descriptors.d.ts +7 -0
  205. package/dist/core/setup-requirements.descriptors.d.ts.map +1 -0
  206. package/dist/core/setup-requirements.descriptors.js +117 -0
  207. package/dist/core/setup-requirements.descriptors.js.map +1 -0
  208. package/dist/data/consumer.plugin.d.ts +3 -0
  209. package/dist/data/consumer.plugin.d.ts.map +1 -0
  210. package/dist/data/consumer.plugin.js +99 -0
  211. package/dist/data/consumer.plugin.js.map +1 -0
  212. package/dist/data/index.d.ts +2 -0
  213. package/dist/data/index.d.ts.map +1 -0
  214. package/dist/data/index.js +2 -0
  215. package/dist/data/index.js.map +1 -0
  216. package/dist/data/plugin.d.ts +4 -0
  217. package/dist/data/plugin.d.ts.map +1 -0
  218. package/dist/data/plugin.js +37 -0
  219. package/dist/data/plugin.js.map +1 -0
  220. package/dist/devtools/consumer.plugin.d.ts +3 -0
  221. package/dist/devtools/consumer.plugin.d.ts.map +1 -0
  222. package/dist/devtools/consumer.plugin.js +323 -0
  223. package/dist/devtools/consumer.plugin.js.map +1 -0
  224. package/dist/devtools/index.d.ts +2 -0
  225. package/dist/devtools/index.d.ts.map +1 -0
  226. package/dist/devtools/index.js +2 -0
  227. package/dist/devtools/index.js.map +1 -0
  228. package/dist/devtools/plugin.d.ts +4 -0
  229. package/dist/devtools/plugin.d.ts.map +1 -0
  230. package/dist/devtools/plugin.js +34 -0
  231. package/dist/devtools/plugin.js.map +1 -0
  232. package/dist/filesystem/index.d.ts +2 -0
  233. package/dist/filesystem/index.d.ts.map +1 -0
  234. package/dist/filesystem/index.js +2 -0
  235. package/dist/filesystem/index.js.map +1 -0
  236. package/dist/filesystem/plugin.d.ts +4 -0
  237. package/dist/filesystem/plugin.d.ts.map +1 -0
  238. package/dist/filesystem/plugin.js +21 -0
  239. package/dist/filesystem/plugin.js.map +1 -0
  240. package/dist/index.d.ts +3 -0
  241. package/dist/index.d.ts.map +1 -0
  242. package/dist/index.js +4 -0
  243. package/dist/index.js.map +1 -0
  244. package/dist/plugin.d.ts +7 -0
  245. package/dist/plugin.d.ts.map +1 -0
  246. package/dist/plugin.js +16 -0
  247. package/dist/plugin.js.map +1 -0
  248. package/dist/schemas/ai.d.ts +119 -0
  249. package/dist/schemas/ai.d.ts.map +1 -0
  250. package/dist/schemas/ai.js +84 -0
  251. package/dist/schemas/ai.js.map +1 -0
  252. package/dist/schemas/auth.d.ts +15 -0
  253. package/dist/schemas/auth.d.ts.map +1 -0
  254. package/dist/schemas/auth.js +19 -0
  255. package/dist/schemas/auth.js.map +1 -0
  256. package/dist/schemas/automation.d.ts +66 -0
  257. package/dist/schemas/automation.d.ts.map +1 -0
  258. package/dist/schemas/automation.js +36 -0
  259. package/dist/schemas/automation.js.map +1 -0
  260. package/dist/schemas/comms.d.ts +13 -0
  261. package/dist/schemas/comms.d.ts.map +1 -0
  262. package/dist/schemas/comms.js +27 -0
  263. package/dist/schemas/comms.js.map +1 -0
  264. package/dist/schemas/core.d.ts +102 -0
  265. package/dist/schemas/core.d.ts.map +1 -0
  266. package/dist/schemas/core.js +124 -0
  267. package/dist/schemas/core.js.map +1 -0
  268. package/dist/schemas/data.d.ts +13 -0
  269. package/dist/schemas/data.d.ts.map +1 -0
  270. package/dist/schemas/data.js +25 -0
  271. package/dist/schemas/data.js.map +1 -0
  272. package/dist/schemas/devtools.d.ts +33 -0
  273. package/dist/schemas/devtools.d.ts.map +1 -0
  274. package/dist/schemas/devtools.js +56 -0
  275. package/dist/schemas/devtools.js.map +1 -0
  276. package/dist/schemas/family.d.ts +11 -0
  277. package/dist/schemas/family.d.ts.map +1 -0
  278. package/dist/schemas/family.js +21 -0
  279. package/dist/schemas/family.js.map +1 -0
  280. package/dist/schemas/filesystem.d.ts +25 -0
  281. package/dist/schemas/filesystem.d.ts.map +1 -0
  282. package/dist/schemas/filesystem.js +24 -0
  283. package/dist/schemas/filesystem.js.map +1 -0
  284. package/dist/schemas/host.d.ts +10 -0
  285. package/dist/schemas/host.d.ts.map +1 -0
  286. package/dist/schemas/host.js +2 -0
  287. package/dist/schemas/host.js.map +1 -0
  288. package/dist/schemas/optional-member.d.ts +67 -0
  289. package/dist/schemas/optional-member.d.ts.map +1 -0
  290. package/dist/schemas/optional-member.js +31 -0
  291. package/dist/schemas/optional-member.js.map +1 -0
  292. package/dist/schemas/roll.d.ts +47 -0
  293. package/dist/schemas/roll.d.ts.map +1 -0
  294. package/dist/schemas/roll.js +18 -0
  295. package/dist/schemas/roll.js.map +1 -0
  296. package/dist/schemas/tui.d.ts +33 -0
  297. package/dist/schemas/tui.d.ts.map +1 -0
  298. package/dist/schemas/tui.js +95 -0
  299. package/dist/schemas/tui.js.map +1 -0
  300. package/dist/schemas/ui.d.ts +15 -0
  301. package/dist/schemas/ui.d.ts.map +1 -0
  302. package/dist/schemas/ui.js +45 -0
  303. package/dist/schemas/ui.js.map +1 -0
  304. package/dist/tui/code-sessions-tui-plugin-shim.d.ts +7 -0
  305. package/dist/tui/code-sessions-tui-plugin-shim.d.ts.map +1 -0
  306. package/dist/tui/code-sessions-tui-plugin-shim.js +2 -0
  307. package/dist/tui/code-sessions-tui-plugin-shim.js.map +1 -0
  308. package/dist/tui/index.d.ts +8 -0
  309. package/dist/tui/index.d.ts.map +1 -0
  310. package/dist/tui/index.js +8 -0
  311. package/dist/tui/index.js.map +1 -0
  312. package/dist/tui/plugin.d.ts +53 -0
  313. package/dist/tui/plugin.d.ts.map +1 -0
  314. package/dist/tui/plugin.js +350 -0
  315. package/dist/tui/plugin.js.map +1 -0
  316. package/dist/ui/consumer.plugin.d.ts +3 -0
  317. package/dist/ui/consumer.plugin.d.ts.map +1 -0
  318. package/dist/ui/consumer.plugin.js +75 -0
  319. package/dist/ui/consumer.plugin.js.map +1 -0
  320. package/dist/ui/index.d.ts +2 -0
  321. package/dist/ui/index.d.ts.map +1 -0
  322. package/dist/ui/index.js +2 -0
  323. package/dist/ui/index.js.map +1 -0
  324. package/dist/ui/plugin.d.ts +4 -0
  325. package/dist/ui/plugin.d.ts.map +1 -0
  326. package/dist/ui/plugin.js +35 -0
  327. package/dist/ui/plugin.js.map +1 -0
  328. package/host-start.mjs +39 -0
  329. package/host.mjs +24 -0
  330. package/package.json +437 -4
@@ -0,0 +1,590 @@
1
+ /**
2
+ * Seed / repair primitive for the global plugin scope (`$VIBES_HOME`).
3
+ *
4
+ * ONE implementation, shared by `vibes update --global [--repair]`, `vibes
5
+ * plugins add|link|host --global`. Every file operation goes through the
6
+ * handed runtime's filesystem adapter. (An earlier draft also served a
7
+ * compiled-shim `--seed-global` fast path and was kept dependency-free for it;
8
+ * no shim imports this module, so that contract is retired with its reason.)
9
+ *
10
+ * What it guarantees:
11
+ *
12
+ * - **Absent manifest → write the seed.** `{ name: 'vibes-global', private:
13
+ * true, vibes: { plugins: [] } }` plus, only if absent, a `bunfig.toml`
14
+ * carrying the registry URL, the measured linker and a `$VIBES_REGISTRY_TOKEN`
15
+ * REFERENCE for the `@vibesdotdev` scope. Never a credential VALUE: this
16
+ * module neither reads nor writes one. Bun does not merge bunfig files and
17
+ * sends scope auth only when the scope names a token, so the reference is
18
+ * what lets the token Secrets hands an install process reach the registry
19
+ * (anonymous when no token is handed). An existing scope entry that names no
20
+ * token is repaired to carry the reference, backed up first.
21
+ * - **`--repair` on an existing manifest → nothing is merged silently and
22
+ * nothing is deleted without a backup line.** The original `package.json`
23
+ * and `bun.lock` are copied to `*.fossil-<stamp>` first, then the manifest is
24
+ * rewritten from the KEPT set and the caller prints `kept | dropped`.
25
+ *
26
+ * ### The linker is `hoisted`, and that is a measured decision (plan §5.1)
27
+ *
28
+ * The first draft seeded `linker = "isolated"`. Measured on this fleet with
29
+ * Bun 1.4.0 against a real `$VIBES_HOME` + provider fixture:
30
+ *
31
+ * | probe | hoisted | isolated |
32
+ * | --- | --- | --- |
33
+ * | `workspaces` glob member NOT declared in `dependencies` | linked into `<home>/node_modules` | **not linked** |
34
+ * | transitive dep of an installed package (`debug` → `ms`) | sibling at `<home>/node_modules/ms` | only inside `.bun/debug@…/node_modules` |
35
+ * | installed package realpath | `<home>/node_modules/<pkg>` | `<home>/node_modules/.bun/<pkg>@<hash>/node_modules/<pkg>` |
36
+ *
37
+ * Row 1 is P6 and it is fatal for this program: `vibes plugins link <glob>` is
38
+ * the whole of Drew's requirement 2, and under `isolated` a linked provider is
39
+ * invisible to `$VIBES_HOME/node_modules` until something declares it. Row 2
40
+ * decides whether an installed `@vibesdotdev/plugins` can reach a name it does
41
+ * not itself declare. Row 3 changes every plugin realpath on every version
42
+ * bump, which is what the ONE-GRAPH ancestor walk and the `linked` predicate
43
+ * (`realpath outside node_modules/.bun/`) read. Independently, the isolated
44
+ * linker has already RSS-bombed this fleet once; hoisted was the fix.
45
+ *
46
+ * The decision is recorded in the manifest (`vibes.seed.linker`) so a home can
47
+ * be audited without re-deriving it, and `bunfig.toml` is only ever written
48
+ * when absent — a user who chose otherwise keeps their choice.
49
+ */
50
+ import { resolveFileSystemAdapter } from '@vibesdotdev/filesystem/client/resolve-adapter';
51
+ import { CapabilityError, settle, settleNow } from '@vibesdotdev/kernel';
52
+ import { WorkspaceDiscoveryIgnoreListSchema } from '@vibesdotdev/kernel/schemas/package-plugins';
53
+ import { z } from 'zod/v4';
54
+ import { resolveVibesEnvironment } from '@vibesdotdev/config/environment/resolve-app-origin';
55
+ import { errnoOf } from "./failure-facts.js";
56
+ /** The manifest name that marks `$VIBES_HOME/package.json` as vibes-owned. */
57
+ export const GLOBAL_MANIFEST_NAME = 'vibes-global';
58
+ /** Package whose presence under R makes a directory a host root. */
59
+ export const HOST_PACKAGE_NAME = '@vibesdotdev/plugins';
60
+ /**
61
+ * Range a seed or repair declares for a package the scope needs but does not
62
+ * yet declare. Explicit semver range (`^1.0.0-rc.0`) rather than a floating
63
+ * `latest` dist-tag so fresh seeds and repairs resolve deterministically.
64
+ * `vibes update --global` advances and owns the range from there on.
65
+ */
66
+ export const SEED_DEPENDENCY_RANGE = '^1.0.0-rc.0';
67
+ /** Measured winner of the hoisted-vs-isolated probe above. */
68
+ export const SEED_LINKER = 'hoisted';
69
+ /** Registry the `@vibesdotdev` scope resolves from. URL only — never auth. */
70
+ export async function resolveSeedRegistryUrl(runtime, registryUrl, environmentId) {
71
+ const environment = registryUrl === undefined
72
+ ? await resolveVibesEnvironment(environmentId ? { environmentId } : {}, runtime)
73
+ : null;
74
+ const origin = registryUrl ?? environment?.apps.registry;
75
+ if (!origin) {
76
+ throw new CapabilityError('The selected environment does not declare a registry origin.', 'NOT_FOUND', {
77
+ reason: 'service-undeclared',
78
+ details: { serviceId: 'registry', environmentId: environmentId ?? environment?.id ?? null }
79
+ });
80
+ }
81
+ return new URL(z.url().parse(origin)).href;
82
+ }
83
+ /** Reason per dropped entry, keyed by the entry itself. */
84
+ const RepairReasonsSchema = z.record(z.string(), z.string());
85
+ function globalManifestPath(fs, home) {
86
+ return fs.join(fs.resolve(home), 'package.json');
87
+ }
88
+ function bunfigPath(fs, home) {
89
+ return fs.join(fs.resolve(home), 'bunfig.toml');
90
+ }
91
+ /** A file's text, or `null` when it does not exist (`ENOENT`); any other read failure propagates. */
92
+ async function readTextIfPresent(fs, path) {
93
+ const read = await settle(() => fs.readFile(path, 'utf8'));
94
+ if (!read.ok) {
95
+ if (errnoOf(read.cause) === 'ENOENT')
96
+ return null;
97
+ throw read.cause;
98
+ }
99
+ return read.value instanceof Uint8Array ? new TextDecoder().decode(read.value) : read.value;
100
+ }
101
+ /** Env var the seeded scope REFERENCES: the name Secrets hands an install process, never a value. */
102
+ export const SEED_TOKEN_ENV_VAR = 'VIBES_REGISTRY_TOKEN';
103
+ /**
104
+ * The seeded `bunfig.toml`: registry URL, linker, and a `$VAR` REFERENCE to the
105
+ * env var an install process receives the scope's token in.
106
+ *
107
+ * Measured (bun 1.4): a URL-only scope sends no Authorization header even when
108
+ * the token is in the install's environment, so every credentialed install
109
+ * 404s on a registry that hides unauthenticated reads; with the reference the
110
+ * header is present, and with the variable unset the request is anonymous.
111
+ */
112
+ export function renderSeedBunfig(input) {
113
+ const linker = input.linker ?? SEED_LINKER;
114
+ return [
115
+ '# Written by `vibes update --global` (or the shim seed) when absent.',
116
+ '# Your edits win. The only line vibes ever repairs is a @vibesdotdev',
117
+ '# scope entry that names no token (it cannot authenticate).',
118
+ '#',
119
+ '# linker = "hoisted" is a measured decision, not a default. Under',
120
+ '# "isolated" a `workspaces` glob member that is not also declared in',
121
+ '# dependencies is NOT linked into node_modules, which silently breaks',
122
+ '# `vibes plugins link <glob>`.',
123
+ '#',
124
+ '# Bunfig files do NOT merge, and bun sends scope auth only when the scope',
125
+ '# names a token. The value below is the NAME of an environment variable,',
126
+ '# never a secret: vibes hands your signed-in credential to bun in it for',
127
+ '# one install. Unset, the request is anonymous.',
128
+ '',
129
+ '[install]',
130
+ `linker = "${linker}"`,
131
+ 'auto = "disable"',
132
+ '',
133
+ '[install.scopes]',
134
+ seedScopeLine(input.registryUrl),
135
+ ''
136
+ ].join('\n');
137
+ }
138
+ /** The one scope line the seed owns inside a user-editable `bunfig.toml`. */
139
+ export function seedScopeLine(registryUrl) {
140
+ return `"@vibesdotdev" = { url = "${registryUrl}", token = "$${SEED_TOKEN_ENV_VAR}" }`;
141
+ }
142
+ /**
143
+ * Give an existing `bunfig.toml` a usable `@vibesdotdev` scope, or return null
144
+ * when it already names a token for the scope. Only the scope entry is
145
+ * touched; an entry that names ANY token, literal or reference, is the user's.
146
+ */
147
+ export function migrateBunfigScope(text, registryUrl) {
148
+ const lines = text.split('\n');
149
+ const scopeIndex = lines.findIndex((line) => !line.trim().startsWith('#') && /^\s*"?@vibesdotdev"?\s*=/.test(line));
150
+ if (scopeIndex >= 0) {
151
+ if (/\b(?:token|_authToken|password)\s*=/.test(lines[scopeIndex] ?? ''))
152
+ return null;
153
+ lines[scopeIndex] = seedScopeLine(registryUrl);
154
+ return lines.join('\n');
155
+ }
156
+ const tableIndex = lines.findIndex((line) => line.trim() === '[install.scopes]');
157
+ if (tableIndex >= 0) {
158
+ lines.splice(tableIndex + 1, 0, seedScopeLine(registryUrl));
159
+ return lines.join('\n');
160
+ }
161
+ const trimmed = text.replace(/\s+$/, '');
162
+ return `${trimmed}${trimmed ? '\n\n' : ''}[install.scopes]\n${seedScopeLine(registryUrl)}\n`;
163
+ }
164
+ /**
165
+ * Write the seed `bunfig.toml` when absent, or give an existing one's scope the
166
+ * token reference. A migrated file is backed up to `bunfig.toml.fossil-<stamp>` first.
167
+ */
168
+ async function ensureSeedBunfig(fs, path, options) {
169
+ const existing = await readTextIfPresent(fs, path);
170
+ if (existing === null) {
171
+ if (!options.dryRun)
172
+ await fs.writeFile(path, renderSeedBunfig(seedBunfigInput(options.registryUrl)), 'utf8');
173
+ return { wrote: true, migrated: false };
174
+ }
175
+ const next = migrateBunfigScope(existing, options.registryUrl);
176
+ if (next === null)
177
+ return { wrote: false, migrated: false };
178
+ if (!options.dryRun) {
179
+ await fs.writeFile(`${path}.fossil-${fossilStamp(options.now)}`, existing, 'utf8');
180
+ await fs.writeFile(path, next, 'utf8');
181
+ }
182
+ return { wrote: false, migrated: true };
183
+ }
184
+ /** `renderSeedBunfig`'s input, with the URL only when one was given. */
185
+ function seedBunfigInput(registryUrl) {
186
+ return { registryUrl };
187
+ }
188
+ /**
189
+ * The fields of an existing `$VIBES_HOME/package.json` repair reads, each
190
+ * parsed on its own: a malformed field reads as absent and never hides the
191
+ * others.
192
+ */
193
+ const ExistingManifestSchema = z.object({
194
+ name: z.string().optional().catch(undefined),
195
+ workspaces: z.array(z.unknown()).optional().catch(undefined),
196
+ dependencies: z.record(z.string(), z.unknown()).optional().catch(undefined),
197
+ vibes: z
198
+ .object({
199
+ plugins: z.array(z.unknown()).optional().catch(undefined),
200
+ hostWorkspace: z.string().optional().catch(undefined),
201
+ // Read raw: repair admits it through the kernel's own schema and names a malformed list.
202
+ ignoreWorkspaceDiscovery: z.unknown().optional()
203
+ })
204
+ .optional()
205
+ .catch(undefined)
206
+ });
207
+ /**
208
+ * The existing manifest: its fields, `null` when it is not JSON (malformed
209
+ * JSON is the repair input: `--repair` fossils it and reseeds), or `undefined`
210
+ * when it does not exist. A read that fails for any other reason (`EACCES`,
211
+ * `EISDIR`, `EIO`) propagates: a file this command could not read is never
212
+ * treated as one it may rewrite.
213
+ */
214
+ async function readExistingManifest(fs, path) {
215
+ const text = await readTextIfPresent(fs, path);
216
+ if (text === null)
217
+ return undefined;
218
+ const json = settleNow(() => JSON.parse(text));
219
+ if (!json.ok) {
220
+ // A syntax error is the explicit repair input; unreadable files never reach this branch.
221
+ if (json.cause instanceof SyntaxError)
222
+ return null;
223
+ throw json.cause;
224
+ }
225
+ const parsed = ExistingManifestSchema.safeParse(json.value);
226
+ return parsed.success ? parsed.data : null;
227
+ }
228
+ async function writeJsonAtomic(fs, path, value) {
229
+ const temporary = `${path}.${crypto.randomUUID()}.tmp`;
230
+ await fs.writeFile(temporary, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
231
+ await fs.rename(temporary, path);
232
+ }
233
+ /** `2026-08-30T134500Z` — filesystem-safe, sorts chronologically. */
234
+ export function fossilStamp(now = new Date()) {
235
+ return now.toISOString().replace(/[:.]/g, '').replace(/\d{3}Z$/, 'Z');
236
+ }
237
+ /** The provenance a seed or repair records: linker, registry, writer when known, and when. */
238
+ function seedProvenance(options, registryUrl) {
239
+ const provenance = {
240
+ linker: SEED_LINKER,
241
+ registry: registryUrl,
242
+ at: (options.now ?? new Date()).toISOString()
243
+ };
244
+ if (options.writer)
245
+ provenance.writer = options.writer;
246
+ return provenance;
247
+ }
248
+ function emptySeedManifest(options, registryUrl) {
249
+ const manifest = { name: GLOBAL_MANIFEST_NAME, private: true, vibes: { plugins: [], seed: seedProvenance(options, registryUrl) } };
250
+ if (options.hostWorkspace)
251
+ manifest.vibes.hostWorkspace = options.hostWorkspace;
252
+ return manifest;
253
+ }
254
+ /** What a seed reports for a manifest that already exists: its own fields, never a fabricated seed. */
255
+ function existingAsSeedManifest(existing, options, registryUrl) {
256
+ if (existing === null)
257
+ return emptySeedManifest(options, registryUrl);
258
+ const manifest = {
259
+ name: existing.name ?? GLOBAL_MANIFEST_NAME,
260
+ private: true,
261
+ vibes: { plugins: stringArray(existing.vibes?.plugins) }
262
+ };
263
+ if (existing.vibes?.hostWorkspace)
264
+ manifest.vibes.hostWorkspace = existing.vibes.hostWorkspace;
265
+ const ignore = WorkspaceDiscoveryIgnoreListSchema.safeParse(existing.vibes?.ignoreWorkspaceDiscovery);
266
+ if (ignore.success && ignore.data.length)
267
+ manifest.vibes.ignoreWorkspaceDiscovery = ignore.data;
268
+ return manifest;
269
+ }
270
+ /**
271
+ * Write the `vibes-global` seed when `$VIBES_HOME/package.json` is absent, and
272
+ * `bunfig.toml` when IT is absent. Never touches an existing file — repairing
273
+ * one is `repairGlobalScope`'s job, and it backs up first.
274
+ */
275
+ export async function seedGlobalScope(runtime, options) {
276
+ const registryUrl = await resolveSeedRegistryUrl(runtime, options.registryUrl, options.environmentId);
277
+ const fs = await resolveFileSystemAdapter(runtime, { binding: false });
278
+ const home = fs.resolve(options.home);
279
+ const manifestPath = globalManifestPath(fs, home);
280
+ const bunfig = bunfigPath(fs, home);
281
+ const existing = await readExistingManifest(fs, manifestPath);
282
+ const existingManifest = existing !== undefined;
283
+ const manifest = existing === undefined ? emptySeedManifest(options, registryUrl) : existingAsSeedManifest(existing, options, registryUrl);
284
+ const bunfigText = renderSeedBunfig(seedBunfigInput(registryUrl));
285
+ if (!options.dryRun) {
286
+ await fs.mkdir(home, { recursive: true });
287
+ if (!existingManifest)
288
+ await writeJsonAtomic(fs, manifestPath, manifest);
289
+ }
290
+ const bunfigOutcome = await ensureSeedBunfig(fs, bunfig, { ...options, registryUrl });
291
+ return {
292
+ manifestPath,
293
+ bunfigPath: bunfig,
294
+ wroteManifest: !existingManifest,
295
+ wroteBunfig: bunfigOutcome.wrote,
296
+ migratedBunfig: bunfigOutcome.migrated,
297
+ manifest,
298
+ bunfig: bunfigText
299
+ };
300
+ }
301
+ /** The static parent of a bun `workspaces` glob — the directory that must exist. */
302
+ export function workspaceGlobParent(paths, glob, root) {
303
+ const segments = glob.replace(/\\/g, '/').split('/');
304
+ const firstGlob = segments.findIndex((segment) => /[*?[\]{}]/.test(segment));
305
+ const parent = firstGlob === -1
306
+ ? glob
307
+ : segments.slice(0, firstGlob).join('/') || (paths.isAbsolute(glob) ? '/' : '.');
308
+ return paths.resolve(paths.isAbsolute(parent) ? parent : paths.resolve(root, parent));
309
+ }
310
+ function packageNameOf(specifier) {
311
+ if (specifier.startsWith('@')) {
312
+ const [scope, name] = specifier.split('/');
313
+ return scope && name ? `${scope}/${name}` : specifier;
314
+ }
315
+ return specifier.split('/')[0] ?? specifier;
316
+ }
317
+ /** The text entries of a parsed list; anything else in it is not an entry. */
318
+ function stringArray(value) {
319
+ const entries = [];
320
+ for (const entry of value ?? []) {
321
+ const text = z.string().safeParse(entry);
322
+ if (text.success)
323
+ entries.push(text.data);
324
+ }
325
+ return entries;
326
+ }
327
+ /**
328
+ * Repair `$VIBES_HOME/package.json` in place, with a backup and a receipt.
329
+ *
330
+ * KEPT: `@vibesdotdev/plugins`, every dependency named by an enabled
331
+ * `vibes.plugins` specifier, `vibes.hostWorkspace`, and every `workspaces`
332
+ * glob whose static parent exists on disk. DROPPED: everything else, each with
333
+ * a reason. The original `package.json` (and `bun.lock`, when present) is
334
+ * copied to `*.fossil-<stamp>` BEFORE the write, and the paths are returned so
335
+ * the caller can print them — a deletion the user cannot undo is not a repair.
336
+ *
337
+ * ### A `workspace:` dependency nothing supplies is DROPPED, with its plugins
338
+ *
339
+ * bun refuses to install a `workspace:*` range no `workspaces` glob expands to
340
+ * (`error: Workspace dependency "<name>" not found`), so a home in that shape
341
+ * cannot be installed, updated, or repaired — the last-resort command failed
342
+ * on exactly the manifest it exists for. Repair now drops such a dependency
343
+ * (`options.workspaceMembers` decides which names survive; with no glob left
344
+ * the answer needs no expansion) and every `vibes.plugins` specifier it
345
+ * supplied, each with its own reason line, after the backup.
346
+ */
347
+ export async function repairGlobalScope(runtime, options) {
348
+ const registryUrl = await resolveSeedRegistryUrl(runtime, options.registryUrl, options.environmentId);
349
+ const fs = await resolveFileSystemAdapter(runtime, { binding: false });
350
+ const home = fs.resolve(options.home);
351
+ const manifestPath = globalManifestPath(fs, home);
352
+ const stamp = options.stamp ?? fossilStamp(options.now);
353
+ const empty = () => ({ dependencies: [], workspaces: [], plugins: [] });
354
+ // Every input is parsed before any destructive step: an unreadable manifest refuses here, untouched.
355
+ const raw = await readExistingManifest(fs, manifestPath);
356
+ if (raw === undefined) {
357
+ const seeded = await seedGlobalScope(runtime, { ...options, registryUrl });
358
+ return {
359
+ manifestPath,
360
+ backups: [],
361
+ kept: empty(),
362
+ dropped: empty(),
363
+ added: [],
364
+ reasons: {},
365
+ manifest: seeded.manifest,
366
+ seeded: true,
367
+ previousName: null
368
+ };
369
+ }
370
+ const previousName = raw?.name ?? null;
371
+ const kept = empty();
372
+ const dropped = empty();
373
+ const reasons = {};
374
+ const declaredPlugins = stringArray(raw?.vibes?.plugins).map((entry) => entry.trim()).filter(Boolean);
375
+ const hostWorkspace = raw?.vibes?.hostWorkspace?.trim() || options.hostWorkspace;
376
+ // The globs are decided FIRST: a `workspace:` dependency is only satisfiable
377
+ // while some surviving glob supplies that member, so the kept glob set is an
378
+ // input to the dependency decision, not a peer of it.
379
+ // A delegated home owns no list and no globs (schema rule); dropping them is
380
+ // the repair, and each one still gets its reason.
381
+ const nextWorkspaces = [];
382
+ for (const glob of stringArray(raw?.workspaces)) {
383
+ if (hostWorkspace) {
384
+ dropped.workspaces.push(glob);
385
+ reasons[glob] = 'hostWorkspace delegates this scope';
386
+ continue;
387
+ }
388
+ const parent = workspaceGlobParent(fs, glob, home);
389
+ if (await fs.exists(parent)) {
390
+ nextWorkspaces.push(glob);
391
+ kept.workspaces.push(glob);
392
+ }
393
+ else {
394
+ dropped.workspaces.push(glob);
395
+ reasons[glob] = `static parent missing (${parent})`;
396
+ }
397
+ }
398
+ // Can this repair PROVE a `workspace:` name is unsupplied? With no surviving
399
+ // glob, yes, and without expanding anything. With globs but no injected
400
+ // expander, no — and a repair that dropped a dependency it could not prove
401
+ // dangling would be the silent edit this kernel exists to avoid.
402
+ const supplied = new Set();
403
+ let suppliesUnknown = false;
404
+ if (nextWorkspaces.length > 0) {
405
+ if (options.workspaceMembers) {
406
+ for (const name of options.workspaceMembers(home, nextWorkspaces))
407
+ supplied.add(name);
408
+ }
409
+ else {
410
+ suppliesUnknown = true;
411
+ }
412
+ }
413
+ const dependencies = raw?.dependencies ?? {};
414
+ const neededPackages = new Set(hostWorkspace ? [] : [HOST_PACKAGE_NAME, ...declaredPlugins.map(packageNameOf)]);
415
+ /** Names dropped because nothing supplies them — their plugins go too. */
416
+ const unsupplied = new Set();
417
+ const nextDependencies = {};
418
+ for (const [name, declared] of Object.entries(dependencies)) {
419
+ const parsedRange = z.string().safeParse(declared);
420
+ if (!parsedRange.success) {
421
+ dropped.dependencies.push(name);
422
+ reasons[name] = 'version range is not a string';
423
+ continue;
424
+ }
425
+ const range = parsedRange.data;
426
+ // Measured: `vibes plugins unlink` used to drop a glob and leave this
427
+ // behind, and `bun install` then failed with `Workspace dependency
428
+ // "<name>" not found` — for `vibes update`, for `--repair`, forever. The
429
+ // last-resort repair has to be able to repair it.
430
+ if (!hostWorkspace &&
431
+ range.startsWith('workspace:') &&
432
+ !suppliesUnknown &&
433
+ !supplied.has(name)) {
434
+ dropped.dependencies.push(name);
435
+ unsupplied.add(name);
436
+ reasons[name] = nextWorkspaces.length
437
+ ? `'${range}' but no workspaces glob supplies it`
438
+ : `'${range}' but this scope links no workspaces glob`;
439
+ continue;
440
+ }
441
+ if (neededPackages.has(name)) {
442
+ nextDependencies[name] = range;
443
+ kept.dependencies.push(name);
444
+ continue;
445
+ }
446
+ dropped.dependencies.push(name);
447
+ reasons[name] = hostWorkspace
448
+ ? 'hostWorkspace delegates this scope'
449
+ : 'no enabled vibes.plugins specifier names it';
450
+ }
451
+ const nextPlugins = [];
452
+ for (const specifier of declaredPlugins) {
453
+ if (hostWorkspace) {
454
+ dropped.plugins.push(specifier);
455
+ reasons[specifier] = 'hostWorkspace delegates this scope';
456
+ continue;
457
+ }
458
+ // Keeping a specifier whose package was just dropped writes a manifest
459
+ // that fails `plugin-not-declared` on the next boot: half a repair.
460
+ const packageName = packageNameOf(specifier);
461
+ if (unsupplied.has(packageName)) {
462
+ dropped.plugins.push(specifier);
463
+ reasons[specifier] = `its package '${packageName}' is supplied by no workspaces glob`;
464
+ continue;
465
+ }
466
+ nextPlugins.push(specifier);
467
+ kept.plugins.push(specifier);
468
+ }
469
+ // A kept specifier whose package is undeclared installs nothing, and the
470
+ // next boot refuses it with this repair as the remedy: a loop. Declare every
471
+ // package the kept set needs, the host included, so one repair always yields
472
+ // an installable scope. A scope that keeps no plugin still declares nothing.
473
+ const added = [];
474
+ if (!hostWorkspace && nextPlugins.length > 0) {
475
+ for (const name of [HOST_PACKAGE_NAME, ...nextPlugins.map(packageNameOf)]) {
476
+ if (Object.hasOwn(nextDependencies, name))
477
+ continue;
478
+ nextDependencies[name] = SEED_DEPENDENCY_RANGE;
479
+ added.push(name);
480
+ }
481
+ }
482
+ const manifest = { name: GLOBAL_MANIFEST_NAME, private: true, vibes: { plugins: nextPlugins, seed: seedProvenance(options, registryUrl) } };
483
+ if (nextWorkspaces.length)
484
+ manifest.workspaces = nextWorkspaces;
485
+ if (Object.keys(nextDependencies).length)
486
+ manifest.dependencies = nextDependencies;
487
+ if (hostWorkspace)
488
+ manifest.vibes.hostWorkspace = hostWorkspace;
489
+ // The internal org's discovery roots are the user's own setting: kept when
490
+ // the kernel schema admits them, dropped with the schema's reason otherwise.
491
+ const declaredIgnore = raw?.vibes?.ignoreWorkspaceDiscovery;
492
+ if (declaredIgnore !== undefined) {
493
+ const ignore = WorkspaceDiscoveryIgnoreListSchema.safeParse(declaredIgnore);
494
+ if (ignore.success) {
495
+ if (ignore.data.length)
496
+ manifest.vibes.ignoreWorkspaceDiscovery = ignore.data;
497
+ }
498
+ else {
499
+ reasons['vibes.ignoreWorkspaceDiscovery'] = `malformed (${ignore.error.issues
500
+ .map((issue) => `[${issue.path.join('.')}] ${issue.message}`)
501
+ .join('; ')}); re-run the internal org setup to write it again`;
502
+ }
503
+ }
504
+ const backups = [];
505
+ // A lock is only retired when the repaired manifest declares NOTHING for it
506
+ // to describe. Removing it whenever a repair runs would throw away the
507
+ // certified resolution of every package the repair KEPT, which is the one
508
+ // thing a lockfile exists to hold.
509
+ const retiresLock = Object.keys(manifest.dependencies ?? {}).length === 0 &&
510
+ (manifest.workspaces ?? []).length === 0;
511
+ let removedLock;
512
+ let retiredNodeModules;
513
+ if (!options.dryRun) {
514
+ const manifestFossil = `${manifestPath}.fossil-${stamp}`;
515
+ await fs.copy(manifestPath, manifestFossil);
516
+ backups.push(manifestFossil);
517
+ const lock = fs.join(home, 'bun.lock');
518
+ if (await fs.exists(lock)) {
519
+ const lockFossil = `${lock}.fossil-${stamp}`;
520
+ await fs.copy(lock, lockFossil);
521
+ backups.push(lockFossil);
522
+ if (retiresLock) {
523
+ // The fossil copy exists and its path is printed, so this deletes
524
+ // no information. It DOES stop a lock that resolves 28
525
+ // dependencies of a retired monorepo from sitting next to a
526
+ // manifest that declares none — the next raw `bun install` here
527
+ // would read it, and a delegated home is supposed to own no
528
+ // installation state at all (plan §8 item 3: "No deps, no globs,
529
+ // no node_modules, no lock").
530
+ await fs.remove(lock);
531
+ removedLock = lock;
532
+ }
533
+ }
534
+ // The installation tree goes with the lock: a home that declares nothing
535
+ // owns no installed packages, and a leftover tree is still reachable by
536
+ // path lookups (it once served a stale @vibesdotdev closure beside a
537
+ // delegated home). Renamed, not deleted, so nothing is lost.
538
+ if (retiresLock) {
539
+ const installed = fs.join(home, 'node_modules');
540
+ if (await fs.exists(installed)) {
541
+ const fossil = `${installed}.fossil-${stamp}`;
542
+ await fs.rename(installed, fossil);
543
+ retiredNodeModules = { from: installed, to: fossil };
544
+ }
545
+ }
546
+ await writeJsonAtomic(fs, manifestPath, manifest);
547
+ await ensureSeedBunfig(fs, bunfigPath(fs, home), { ...options, registryUrl });
548
+ }
549
+ const result = { manifestPath, backups, kept, dropped, added, reasons, manifest, seeded: false, previousName };
550
+ if (removedLock)
551
+ result.removedLock = removedLock;
552
+ if (retiredNodeModules)
553
+ result.retiredNodeModules = retiredNodeModules;
554
+ return result;
555
+ }
556
+ /** One-line-per-fact `kept | dropped` receipt (plan §9 step 1 prints this). */
557
+ export function formatRepairReceipt(result) {
558
+ if (result.seeded)
559
+ return [`seeded ${result.manifestPath} (no manifest existed)`];
560
+ const lines = [];
561
+ for (const path of result.backups)
562
+ lines.push(`backup ${path}`);
563
+ if (result.removedLock) {
564
+ lines.push(`retired ${result.removedLock} — the repaired manifest declares no dependencies and no workspaces globs (restore it from the backup above)`);
565
+ }
566
+ if (result.retiredNodeModules) {
567
+ lines.push(`retired ${result.retiredNodeModules.from} → ${result.retiredNodeModules.to} — the repaired manifest declares nothing for it to hold`);
568
+ }
569
+ const counts = (set) => [
570
+ `${set.plugins.length} plugin(s)`,
571
+ `${set.dependencies.length} dependency/ies`,
572
+ `${set.workspaces.length} workspaces glob(s)`
573
+ ].join(', ');
574
+ lines.push(`kept: ${counts(result.kept)}`);
575
+ if (result.added.length > 0) {
576
+ lines.push(`added: ${result.added.length} dependency/ies at ${SEED_DEPENDENCY_RANGE}`);
577
+ for (const name of result.added)
578
+ lines.push(` + ${name} — a kept plugin needs its package`);
579
+ }
580
+ lines.push(`dropped: ${counts(result.dropped)}`);
581
+ for (const entry of [
582
+ ...result.dropped.plugins,
583
+ ...result.dropped.dependencies,
584
+ ...result.dropped.workspaces
585
+ ]) {
586
+ lines.push(` - ${entry} — ${result.reasons[entry] ?? 'not retained'}`);
587
+ }
588
+ return lines;
589
+ }
590
+ //# sourceMappingURL=seed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.js","sourceRoot":"","sources":["../../src/cli/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,CAAC,EAAE,MAA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