@vltpkg/cli-js 1.4.0 → 1.6.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 (105) hide show
  1. package/{access-422UGEWN.js → access-AJ654YKY.js} +13 -12
  2. package/{bugs-RED7Y33Q.js → bugs-N73DVYHD.js} +32 -25
  3. package/{build-IHMPBWRO.js → build-VZ3EZKMM.js} +65 -21
  4. package/{cache-FJP2RZJX.js → cache-VROEWG2C.js} +20 -17
  5. package/cache-unzip-src-unzip.js +58 -15
  6. package/{chunk-TPRK6IDA.js → chunk-22LZBDEC.js} +2 -2
  7. package/chunk-36UIE654.js +6248 -0
  8. package/{chunk-UGCKF5ZE.js → chunk-3JIN46K5.js} +1 -1
  9. package/{chunk-OAJ3PO3Z.js → chunk-44AWMA4F.js} +25 -13
  10. package/chunk-4E65BBTM.js +77 -0
  11. package/{chunk-SR2VOY5J.js → chunk-4GMNWW4C.js} +1 -1
  12. package/{chunk-5IJTPZXP.js → chunk-6D3QAFNZ.js} +1 -1
  13. package/{chunk-X4FVR4R5.js → chunk-75HGJVNG.js} +12 -10
  14. package/{chunk-THSYN5EK.js → chunk-7M2VTFLP.js} +12 -1
  15. package/{chunk-2AMOC4DN.js → chunk-ANW36H4T.js} +4 -4
  16. package/chunk-B6RIGNEO.js +626 -0
  17. package/{chunk-FLH4YC6W.js → chunk-BF5DRGRZ.js} +60 -15
  18. package/chunk-BH5CVXNY.js +115 -0
  19. package/{chunk-PLG3OYCX.js → chunk-CAV7FKWQ.js} +3 -2
  20. package/{chunk-C23TDXRG.js → chunk-CYK6I4M6.js} +1 -1
  21. package/chunk-DXED4ARV.js +436 -0
  22. package/chunk-E74WGW5C.js +49 -0
  23. package/{chunk-WF6KLKRN.js → chunk-EFHOWRKU.js} +103 -1
  24. package/chunk-EMTGRCSE.js +1111 -0
  25. package/{chunk-5Y4SYLJ2.js → chunk-EYGOEAJM.js} +1 -1
  26. package/{chunk-OVPHE4O7.js → chunk-F5LZMLAQ.js} +5335 -10902
  27. package/{chunk-HZXJ423P.js → chunk-FXD3IV2S.js} +4 -2
  28. package/chunk-GCTREKA4.js +115 -0
  29. package/{chunk-ZJMJ7MCT.js → chunk-GEQFMH5M.js} +1 -1
  30. package/{chunk-ISE4IRHF.js → chunk-GZVI75KX.js} +7 -14
  31. package/chunk-HOF7LEIC.js +24 -0
  32. package/{chunk-LHPEBLOU.js → chunk-HT6FS4VB.js} +1 -1
  33. package/{chunk-PHJJPY5G.js → chunk-IXAMCWIT.js} +5 -5
  34. package/{chunk-ASLX43R3.js → chunk-JCNI6ZHH.js} +7 -5
  35. package/chunk-JV5XR5JQ.js +349 -0
  36. package/{chunk-7T3XAYP4.js → chunk-KD5ZK72K.js} +1 -1
  37. package/{chunk-FZUYGJZU.js → chunk-KVWGMSPW.js} +137 -19
  38. package/{chunk-TO23PR7J.js → chunk-LCLRP64K.js} +14 -12
  39. package/{chunk-QCSUWACA.js → chunk-LGQVZTYR.js} +8 -36
  40. package/{chunk-5RHABCYI.js → chunk-LP3ORD3D.js} +143 -17
  41. package/chunk-MCDLJZXT.js +82 -0
  42. package/{chunk-DNRR3XMG.js → chunk-N6HV7JWC.js} +1 -1
  43. package/chunk-O6MQ7NN6.js +1155 -0
  44. package/{chunk-GIIAODRI.js → chunk-PC2HOBAQ.js} +7 -5
  45. package/{chunk-APMYKJI2.js → chunk-QNHBAGXQ.js} +1 -1
  46. package/chunk-RBQO54TG.js +59 -0
  47. package/chunk-SUU2WETN.js +268 -0
  48. package/{chunk-I7UMHYZX.js → chunk-TQQO2F56.js} +113 -1187
  49. package/{chunk-4UCADW6S.js → chunk-TWDSXQPN.js} +9 -7
  50. package/{chunk-MKWPTN3C.js → chunk-VLVMLSIF.js} +2 -2
  51. package/chunk-W4T5CGCO.js +52 -0
  52. package/{chunk-5TNXLRW2.js → chunk-YTDABXPD.js} +50 -12
  53. package/{ci-YSKNNO5M.js → ci-3BVMVQIT.js} +35 -13
  54. package/cli-package.json +3 -1
  55. package/{config-HO7GY3QT.js → config-2KQV7N5A.js} +16 -13
  56. package/{config-CSPCDMR3.js → config-EKHBW6I5.js} +12 -9
  57. package/{create-2TJT3AHJ.js → create-QVHNOIV3.js} +35 -29
  58. package/{deprecate-7FRJI2RL.js → deprecate-E254QBH6.js} +17 -15
  59. package/{dist-tag-WCFF5OEG.js → dist-tag-SITRFD7O.js} +13 -12
  60. package/{docs-JMBPTU23.js → docs-IDL2P7CA.js} +32 -25
  61. package/{exec-FBOUKZZ2.js → exec-7BK2W2WL.js} +35 -29
  62. package/{exec-cache-X3ZWM5S3.js → exec-cache-VY46L7DR.js} +27 -21
  63. package/{exec-local-Y3KQC22N.js → exec-local-D7R5T3DF.js} +26 -20
  64. package/{help-PUKVH5X7.js → help-RMRIEJQL.js} +6 -5
  65. package/{init-GOKAQXXZ.js → init-BGW4HJ6V.js} +15 -11
  66. package/{install-XFN4UFOC.js → install-U5GATZ2N.js} +144 -49
  67. package/{list-43JFFG5D.js → list-3VG4M2XL.js} +41 -28
  68. package/{login-RSTZKNKN.js → login-PHQWI6S6.js} +19 -16
  69. package/{logout-4576FFXZ.js → logout-DJCOGRFF.js} +13 -12
  70. package/{outdated-ACQ5A2Y7.js → outdated-JH3O6R3Y.js} +27 -22
  71. package/{pack-QQVJ3G25.js → pack-U5W5YWHK.js} +23 -18
  72. package/package.json +1 -1
  73. package/{ping-QCDQQRO5.js → ping-EKX43AOW.js} +13 -12
  74. package/{pkg-CSOJV7UC.js → pkg-SW5GMERT.js} +19 -14
  75. package/{profile-VL4HPW3N.js → profile-UGDRDMQ6.js} +13 -12
  76. package/{publish-2YBO6ZXE.js → publish-HTWKK3NN.js} +60 -45
  77. package/{query-IHHFMJRT.js → query-YE3FUVGG.js} +43 -30
  78. package/{registry-W7BRZZZ2.js → registry-ZGGWVLBM.js} +7 -7
  79. package/registry-client-src-revalidate.js +76 -22
  80. package/{repo-L3BXAAWS.js → repo-WDOCU6SE.js} +32 -25
  81. package/{reporter-5NYOHBO7.js → reporter-N5PAXB26.js} +121 -17
  82. package/{run-AMUUVLTI.js → run-IPARVIIQ.js} +26 -20
  83. package/{run-exec-5W3XWQZA.js → run-exec-C4RTREEW.js} +26 -20
  84. package/security-archive-src-update-expired.js +66 -21
  85. package/{setup-TFM4GJF7.js → setup-SYYUEHZL.js} +212 -32
  86. package/skills-KA2VR5Q5.js +480 -0
  87. package/skills-UBBMSBDQ.js +416 -0
  88. package/{src-4CYCUWZL.js → src-FUSTSM4J.js} +33 -22
  89. package/{src-I3GMULFP.js → src-QO5G2S4O.js} +11 -8
  90. package/{src-LUTN2ODD.js → src-W2VQULRG.js} +2 -2
  91. package/{token-OANOBE3G.js → token-UQNABECH.js} +15 -13
  92. package/{uninstall-YXTQ4AIZ.js → uninstall-FHBJ3OUV.js} +59 -18
  93. package/{unpublish-SZXYMYIU.js → unpublish-APJTEUBA.js} +31 -16
  94. package/{update-FHLMWGIM.js → update-NWZTL4S7.js} +52 -25
  95. package/{version-ZWFCTU5V.js → version-EMKKTL77.js} +20 -14
  96. package/{view-NFNJXMLV.js → view-BUUI33RV.js} +17 -15
  97. package/vlr.js +1 -1
  98. package/vlrx.js +1 -1
  99. package/vlt.js +1 -1
  100. package/vlx.js +1 -1
  101. package/vlxl.js +1 -1
  102. package/{whoami-O7GOSGCI.js → whoami-F6BSXGQ2.js} +13 -12
  103. package/chunk-G2YT2GWF.js +0 -120
  104. package/chunk-T6FBP4OU.js +0 -76
  105. package/chunk-U7TEQCBN.js +0 -880
@@ -0,0 +1,436 @@
1
+ var global = globalThis;
2
+ import {Buffer} from "node:buffer";
3
+ import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
4
+ globalThis.setTimeout = _vlt_setTimeout;
5
+ globalThis.clearTimeout = _vlt_clearTimeout;
6
+ globalThis.setImmediate = _vlt_setImmediate;
7
+ globalThis.clearImmediate = _vlt_clearImmediate;
8
+ globalThis.setInterval = _vlt_setInterval;
9
+ globalThis.clearInterval = _vlt_clearInterval;
10
+ import {createRequire as _vlt_createRequire} from "node:module";
11
+ var require = _vlt_createRequire(import.meta.filename);
12
+ import {
13
+ findSelf,
14
+ globalSpec,
15
+ writeInstallReceipt
16
+ } from "./chunk-O6MQ7NN6.js";
17
+ import {
18
+ prettyPath
19
+ } from "./chunk-BH5CVXNY.js";
20
+ import {
21
+ findCmdShimIfExists
22
+ } from "./chunk-JV5XR5JQ.js";
23
+ import {
24
+ loadPackageJson
25
+ } from "./chunk-E74WGW5C.js";
26
+ import {
27
+ readGlobalState,
28
+ updateGlobalState
29
+ } from "./chunk-GCTREKA4.js";
30
+ import {
31
+ globalWorkspacePath,
32
+ isInside,
33
+ samePath
34
+ } from "./chunk-MCDLJZXT.js";
35
+ import {
36
+ parseSpecArg
37
+ } from "./chunk-7M2VTFLP.js";
38
+ import {
39
+ isDepID
40
+ } from "./chunk-CAV7FKWQ.js";
41
+ import {
42
+ Spec
43
+ } from "./chunk-6D3QAFNZ.js";
44
+ import {
45
+ which
46
+ } from "./chunk-SUU2WETN.js";
47
+ import {
48
+ lt,
49
+ valid
50
+ } from "./chunk-BF5DRGRZ.js";
51
+ import {
52
+ error
53
+ } from "./chunk-WZWDS3W4.js";
54
+
55
+ // ../../src/cli-sdk/src/self-update.ts
56
+ import { spawn } from "node:child_process";
57
+ import { createHash } from "node:crypto";
58
+ import { constants, existsSync } from "node:fs";
59
+ import {
60
+ access,
61
+ chmod,
62
+ lstat,
63
+ readFile,
64
+ realpath,
65
+ rename,
66
+ rm,
67
+ stat
68
+ } from "node:fs/promises";
69
+ import {
70
+ basename,
71
+ dirname,
72
+ extname,
73
+ join,
74
+ relative,
75
+ resolve,
76
+ sep
77
+ } from "node:path";
78
+ var { version: running } = loadPackageJson(
79
+ import.meta.filename,
80
+ "cli-package.json"
81
+ );
82
+ var installerLine = "Re-run the installer to update vlt:\n curl -fsSL https://install.vlt.sh | bash";
83
+ var writable = (dir) => access(dir, constants.W_OK).then(
84
+ () => true,
85
+ () => false
86
+ );
87
+ var refuse = (self, message) => {
88
+ process.exitCode = 1;
89
+ return { status: "refused", from: running, dir: self.dir, message };
90
+ };
91
+ var isFile = (f) => stat(f).then(
92
+ (s) => s.isFile(),
93
+ () => false
94
+ );
95
+ var cellars = () => [
96
+ process.env.HOMEBREW_CELLAR,
97
+ "/opt/homebrew/Cellar",
98
+ "/usr/local/Cellar",
99
+ "/home/linuxbrew/.linuxbrew/Cellar"
100
+ ].filter((c) => !!c);
101
+ var whichNpm = async () => {
102
+ try {
103
+ const found = await which("npm", { nothrow: true });
104
+ if (!found) return;
105
+ const real = await realpath(
106
+ (await findCmdShimIfExists(found))?.[1] ?? found
107
+ );
108
+ return basename(real) === "npm-cli.js" ? real : void 0;
109
+ } catch {
110
+ }
111
+ };
112
+ var findNpm = async (self) => {
113
+ const i = self.target.lastIndexOf(
114
+ `${sep}node_modules${sep}vlt${sep}`
115
+ );
116
+ if (i === -1) return;
117
+ const nm = self.target.slice(0, i) + sep + "node_modules";
118
+ const win32 = process.platform === "win32";
119
+ const up = dirname(nm);
120
+ const prefix = win32 ? (
121
+ // vlt.cmd is in the prefix
122
+ samePath(up, self.dir) && up
123
+ ) : basename(up) === "lib" && dirname(up);
124
+ if (!prefix) return;
125
+ const node = dirname(process.execPath);
126
+ const candidates = [
127
+ join(nm, "npm/bin/npm-cli.js"),
128
+ win32 ? join(node, "node_modules/npm/bin/npm-cli.js") : join(dirname(node), "lib/node_modules/npm/bin/npm-cli.js")
129
+ ];
130
+ for (const c of candidates) {
131
+ if (await isFile(c)) return { npmCli: c, prefix };
132
+ }
133
+ const npmCli = await whichNpm();
134
+ return npmCli && { npmCli, prefix };
135
+ };
136
+ var classify = async (self, root) => {
137
+ const g = await realpath(root).catch(() => resolve(root));
138
+ if (isInside(g, self.target)) return { kind: "global-project" };
139
+ const { receipt } = self;
140
+ if (receipt?.data.method === "standalone") {
141
+ if (self.standalone)
142
+ return { kind: "standalone-receipt", receipt };
143
+ } else if (receipt) {
144
+ const npm2 = receipt.data.method === "npm" && await findNpm(self);
145
+ return npm2 ? { kind: "npm", ...npm2, receipt } : { kind: "installer" };
146
+ }
147
+ if (cellars().some((c) => isInside(c, self.target))) {
148
+ return { kind: "homebrew" };
149
+ }
150
+ if (self.standalone) return { kind: "standalone" };
151
+ const npm = await findNpm(self);
152
+ return npm ? { kind: "npm", ...npm } : { kind: "unknown" };
153
+ };
154
+ var sha512 = async (file) => `sha512-${createHash("sha512").update(await readFile(file)).digest("base64")}`;
155
+ var safeBin = (b) => /^[a-z0-9][\w.-]*$/i.test(b);
156
+ var updateStandalone = async (self, receipt, to, fetchRelease) => {
157
+ const { target, channel, binaries = [] } = receipt.data;
158
+ if (!fetchRelease || !target) return installerLine;
159
+ const win32 = process.platform === "win32";
160
+ const at = prettyPath(self.dir);
161
+ if (!win32 && (await stat(self.found)).uid === 0 && process.getuid?.() !== 0) {
162
+ return `vlt at ${at} is owned by root. Update it the way you installed it, or run this as root.`;
163
+ }
164
+ if (!await writable(self.dir)) {
165
+ return `vlt at ${at} is not writable. Update it the way you installed it.`;
166
+ }
167
+ const ext = extname(self.found).toLowerCase() === ".exe" ? ".exe" : "";
168
+ const entries = [];
169
+ for (const bin of new Set(binaries)) {
170
+ if (bin === "vlt" || !safeBin(bin)) continue;
171
+ const file = join(self.dir, bin + ext);
172
+ const st = await lstat(file).catch(() => void 0);
173
+ if (st && !st.isSymbolicLink()) entries.push({ bin, file });
174
+ }
175
+ entries.push({
176
+ bin: "vlt",
177
+ file: join(self.dir, basename(self.found))
178
+ });
179
+ const tmps = [];
180
+ const cleanup = () => Promise.all(tmps.map((f) => rm(f, { force: true })));
181
+ const ready = [];
182
+ try {
183
+ for (const { bin, file } of entries) {
184
+ if (win32)
185
+ await rm(`${file}.old`, { force: true }).catch(() => {
186
+ });
187
+ const dest = join(self.dir, `.${bin}-${to}.tmp`);
188
+ tmps.push(dest);
189
+ const { checksum } = await fetchRelease({
190
+ version: to,
191
+ target,
192
+ channel,
193
+ bin,
194
+ dest
195
+ });
196
+ const found = await sha512(dest);
197
+ if (found !== checksum) {
198
+ throw error(`Checksum mismatch for ${bin} ${to}`, {
199
+ code: "EINTEGRITY",
200
+ wanted: checksum,
201
+ found
202
+ });
203
+ }
204
+ await chmod(dest, (await stat(file)).mode & 511);
205
+ ready.push({ file, dest });
206
+ }
207
+ } catch (er) {
208
+ await cleanup();
209
+ throw er;
210
+ }
211
+ for (const { file, dest } of ready) {
212
+ try {
213
+ if (win32) {
214
+ await rename(file, `${file}.old`);
215
+ await rename(dest, file).catch(async (er) => {
216
+ await rename(`${file}.old`, file).catch(() => {
217
+ });
218
+ throw er;
219
+ });
220
+ } else {
221
+ await rename(dest, file);
222
+ }
223
+ } catch (cause) {
224
+ await cleanup();
225
+ throw error(
226
+ `Could not replace ${file}. Close other vlt processes and editors, and check permissions.`,
227
+ { path: file, cause }
228
+ );
229
+ }
230
+ }
231
+ };
232
+ var runNpm = (npmCli, prefix, arg) => new Promise((res, rej) => {
233
+ const child = spawn(
234
+ process.execPath,
235
+ [npmCli, "install", "--global", "--prefix", prefix, arg],
236
+ { stdio: ["inherit", 2, 2] }
237
+ );
238
+ child.on("error", rej);
239
+ child.on("close", (code) => res(code ?? 1));
240
+ });
241
+ var rewriteReceipt = (receipt, to) => receipt && writeInstallReceipt(receipt.file, { version: to }).catch(() => {
242
+ });
243
+ var vltArg = /^vlt(@|$)|(^|[/\\:])vlt-\d[^/\\]*\.tgz$/;
244
+ var isSelfUpdateArgs = (conf) => conf.command === "install" && !!conf.globalRoot && conf.positionals.some((p) => vltArg.test(p));
245
+ var selfUpdate = async (conf, { fetchRelease } = {}) => {
246
+ const { globalRoot, positionals } = conf;
247
+ if (!globalRoot || !positionals.length) return;
248
+ const specs = await Promise.all(
249
+ positionals.map((p) => globalSpec(p, conf))
250
+ );
251
+ const [spec] = specs;
252
+ if (!spec || !specs.some((s) => s.name === "vlt")) return;
253
+ if (specs.length > 1) {
254
+ throw error("Update vlt on its own, without other packages", {
255
+ code: "EUSAGE",
256
+ found: positionals.join(" ")
257
+ });
258
+ }
259
+ const self = await findSelf();
260
+ if (!self) {
261
+ throw error(
262
+ `Can't tell which vlt to update: run the vlt on your PATH, not ${process.argv[1] ?? process.execPath}`,
263
+ { code: "EUSAGE" }
264
+ );
265
+ }
266
+ const owner = await classify(self, globalRoot);
267
+ const at = prettyPath(self.dir);
268
+ const foreign = `vlt at ${at} is not managed by vlt or npm. Update it the way you installed it.`;
269
+ if (owner.kind === "installer") {
270
+ return { done: refuse(self, installerLine) };
271
+ }
272
+ if (owner.kind === "homebrew") {
273
+ return {
274
+ done: refuse(
275
+ self,
276
+ `vlt at ${at} was installed by Homebrew. Run \`brew upgrade vlt\`.`
277
+ )
278
+ };
279
+ }
280
+ if (owner.kind === "standalone") {
281
+ return { done: refuse(self, foreign) };
282
+ }
283
+ const bootstrap = (owner.kind === "npm" || owner.kind === "unknown") && !await writable(self.dir);
284
+ if (owner.kind === "unknown" && !bootstrap) {
285
+ return { done: refuse(self, foreign) };
286
+ }
287
+ const raw = String(positionals[0]);
288
+ const implicit = !parseSpecArg(raw, conf.options).bareSpec;
289
+ const receipt = "receipt" in owner ? owner.receipt : void 0;
290
+ const channel = receipt?.data.channel;
291
+ const tag = channel ?? conf.options.tag;
292
+ const { name, version: to } = await conf.options.packageInfo.manifest(
293
+ implicit && channel ? Spec.parse("vlt", tag, conf.options) : spec
294
+ );
295
+ if (name !== "vlt" || !to) {
296
+ throw error(`${raw} is not a version of vlt`, {
297
+ code: "EUSAGE",
298
+ found: name
299
+ });
300
+ }
301
+ const kind = bootstrap ? "bootstrap" : owner.kind === "standalone-receipt" ? "standalone" : owner.kind === "npm" ? "npm" : "global-project";
302
+ const base = { case: kind, from: running, to, dir: self.dir };
303
+ if (to === running)
304
+ return { done: { ...base, status: "up-to-date" } };
305
+ if (implicit && lt(to, running)) {
306
+ return { done: { ...base, status: "newer-running", tag } };
307
+ }
308
+ const registry = spec.final.type === "registry";
309
+ if (owner.kind === "standalone-receipt") {
310
+ if (!registry || !valid(to)) {
311
+ throw error(`${raw} is not a vlt release`, {
312
+ code: "EUSAGE",
313
+ found: raw
314
+ });
315
+ }
316
+ const refused = await updateStandalone(
317
+ self,
318
+ owner.receipt,
319
+ to,
320
+ fetchRelease
321
+ );
322
+ if (refused) return { done: refuse(self, refused) };
323
+ await rewriteReceipt(owner.receipt, to);
324
+ return { done: { ...base, status: "updated" } };
325
+ }
326
+ if (owner.kind === "npm" && !bootstrap) {
327
+ const code = await runNpm(
328
+ owner.npmCli,
329
+ owner.prefix,
330
+ registry ? `vlt@${to}` : `vlt@${spec.bareSpec}`
331
+ );
332
+ if (code !== 0) {
333
+ process.exitCode = code;
334
+ return { done: { ...base, status: "failed" } };
335
+ }
336
+ await rewriteReceipt(receipt, to);
337
+ return { done: { ...base, status: "updated" } };
338
+ }
339
+ if (registry) conf.positionals = [`vlt@${to}`];
340
+ return {
341
+ selfUnwritable: bootstrap,
342
+ finish: async (global) => {
343
+ const u = {
344
+ ...base,
345
+ status: "updated",
346
+ dir: global?.binDir ?? self.dir,
347
+ ...bootstrap ? { notWritable: self.dir } : {}
348
+ };
349
+ if (bootstrap && global?.inPath && global.bins.includes("vlt")) {
350
+ const now = await which("vlt", { nothrow: true }).catch(
351
+ () => null
352
+ );
353
+ const first = now && dirname(now);
354
+ if (first && !samePath(
355
+ await realpath(first).catch(() => first),
356
+ global.binDir
357
+ )) {
358
+ u.shadowedBy = first;
359
+ }
360
+ }
361
+ return u;
362
+ }
363
+ };
364
+ };
365
+ var refuseSelfUninstall = async (conf) => {
366
+ const { globalRoot, positionals } = conf;
367
+ if (!globalRoot || !positionals.includes("vlt")) return;
368
+ const ws = resolve(globalRoot, globalWorkspacePath("vlt"));
369
+ if (existsSync(resolve(ws, "package.json"))) return;
370
+ const self = await findSelf();
371
+ if (!self) return;
372
+ const { kind } = await classify(self, globalRoot);
373
+ return refuse(
374
+ self,
375
+ kind === "npm" ? "vlt was installed by npm. Run `npm uninstall -g vlt` to remove it." : kind === "homebrew" ? "vlt was installed by Homebrew. Run `brew uninstall vlt` to remove it." : `vlt at ${prettyPath(self.dir)} is not managed by vlt. Remove it the way you installed it.`
376
+ );
377
+ };
378
+ var runningStoreDep = async (root) => {
379
+ const script = process.argv[1];
380
+ if (!script) return;
381
+ try {
382
+ const [real, store] = await Promise.all([
383
+ realpath(script),
384
+ realpath(resolve(root, "node_modules/.vlt"))
385
+ ]);
386
+ const [id] = relative(store, real).split(sep);
387
+ return isDepID(id) ? id : void 0;
388
+ } catch {
389
+ }
390
+ };
391
+ var deferSelfRemove = async (root, graph, keep) => {
392
+ const store = resolve(await realpath(root), "node_modules/.vlt");
393
+ const add = keep && !graph.nodes.has(keep) ? [resolve(store, keep)] : [];
394
+ const { pendingRemove = [] } = await readGlobalState(root);
395
+ const kept = pendingRemove.filter((p) => {
396
+ const id = basename(p);
397
+ return !(isDepID(id) && graph.nodes.has(id));
398
+ });
399
+ if (!add.length && kept.length === pendingRemove.length) return;
400
+ await updateGlobalState(root, (s) => ({
401
+ ...s,
402
+ pendingRemove: [.../* @__PURE__ */ new Set([...kept, ...add])]
403
+ }));
404
+ };
405
+ var selfUpdateLines = (s) => {
406
+ if (s.status === "refused") return [s.message];
407
+ if (s.status === "up-to-date") {
408
+ return [`\u2705 vlt ${s.to} is already up to date`];
409
+ }
410
+ if (s.status === "newer-running") {
411
+ return [
412
+ `\u2139\uFE0F vlt ${s.from} is running but "${s.tag}" is ${s.to}; run \`vlt i -g vlt@${s.tag}\` to downgrade`
413
+ ];
414
+ }
415
+ if (s.status === "failed") return [];
416
+ if (s.case === "bootstrap") {
417
+ return [
418
+ `\u2139\uFE0F ${prettyPath(s.notWritable ?? s.dir)} is not writable, so vlt ${s.to} was installed as a global package.`,
419
+ ...s.shadowedBy ? [
420
+ `\u26A0\uFE0F ${prettyPath(s.shadowedBy)} is earlier in your PATH, so \`vlt\` still runs vlt ${s.from}.`
421
+ ] : []
422
+ ];
423
+ }
424
+ return [
425
+ `\u2B06\uFE0F Updated vlt ${s.from} \u2192 ${s.to} in ${prettyPath(s.dir)}${s.case === "npm" ? " (via npm)" : ""}`
426
+ ];
427
+ };
428
+
429
+ export {
430
+ isSelfUpdateArgs,
431
+ selfUpdate,
432
+ refuseSelfUninstall,
433
+ runningStoreDep,
434
+ deferSelfRemove,
435
+ selfUpdateLines
436
+ };
@@ -0,0 +1,49 @@
1
+ var global = globalThis;
2
+ import {Buffer} from "node:buffer";
3
+ import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
4
+ globalThis.setTimeout = _vlt_setTimeout;
5
+ globalThis.clearTimeout = _vlt_clearTimeout;
6
+ globalThis.setImmediate = _vlt_setImmediate;
7
+ globalThis.clearImmediate = _vlt_clearImmediate;
8
+ globalThis.setInterval = _vlt_setInterval;
9
+ globalThis.clearInterval = _vlt_clearInterval;
10
+ import {createRequire as _vlt_createRequire} from "node:module";
11
+ var require = _vlt_createRequire(import.meta.filename);
12
+
13
+ // ../../node_modules/.vlt/~npm~package-json-from-dist@1.0.1/node_modules/package-json-from-dist/dist/esm/index.js
14
+ import { readFileSync } from "node:fs";
15
+ import { dirname, resolve, sep } from "node:path";
16
+ import { fileURLToPath } from "node:url";
17
+ var NM = `${sep}node_modules${sep}`;
18
+ var STORE = `.store${sep}`;
19
+ var PKG = `${sep}package${sep}`;
20
+ var DIST = `${sep}dist${sep}`;
21
+ var findPackageJson = (from, pathFromSrc = "../package.json") => {
22
+ const f = typeof from === "object" || from.startsWith("file://") ? fileURLToPath(from) : from;
23
+ const __dirname = dirname(f);
24
+ const nms = __dirname.lastIndexOf(NM);
25
+ if (nms !== -1) {
26
+ const nm = __dirname.substring(0, nms + NM.length);
27
+ const pkgDir = __dirname.substring(nms + NM.length);
28
+ if (pkgDir.startsWith(STORE)) {
29
+ const pkg = pkgDir.indexOf(PKG, STORE.length);
30
+ if (pkg) {
31
+ return resolve(nm, pkgDir.substring(0, pkg + PKG.length), "package.json");
32
+ }
33
+ }
34
+ const pkgName = pkgDir.startsWith("@") ? pkgDir.split(sep, 2).join(sep) : String(pkgDir.split(sep)[0]);
35
+ return resolve(nm, pkgName, "package.json");
36
+ } else {
37
+ const d = __dirname.lastIndexOf(DIST);
38
+ if (d !== -1) {
39
+ return resolve(__dirname.substring(0, d), "package.json");
40
+ } else {
41
+ return resolve(__dirname, pathFromSrc);
42
+ }
43
+ }
44
+ };
45
+ var loadPackageJson = (from, pathFromSrc = "../package.json") => JSON.parse(readFileSync(findPackageJson(from, pathFromSrc), "utf8"));
46
+
47
+ export {
48
+ loadPackageJson
49
+ };
@@ -1108,6 +1108,7 @@ var canonicalCommands = {
1108
1108
  "run-exec": "run-exec",
1109
1109
  run: "run",
1110
1110
  setup: "setup",
1111
+ skills: "skills",
1111
1112
  token: "token",
1112
1113
  uninstall: "uninstall",
1113
1114
  unpublish: "unpublish",
@@ -1517,6 +1518,62 @@ var definition = j2.heading("Configuration").description(
1517
1518
  description: `Specify named workspace group names to load and operate on
1518
1519
  when doing recursive operations on workspaces.`
1519
1520
  }
1521
+ }).flag({
1522
+ global: {
1523
+ short: "g",
1524
+ description: `Operate on the global project instead of the current
1525
+ one. Supported by \`install\`, \`uninstall\`, \`list\`,
1526
+ \`query\` and \`build\`.
1527
+
1528
+ Each global package is installed in its own workspace of
1529
+ the project in \`--global-dir\`, and its bins are linked
1530
+ into \`--global-bin-dir\`.`
1531
+ }
1532
+ }).opt({
1533
+ "global-dir": {
1534
+ hint: "path",
1535
+ default: xdg.data("global"),
1536
+ description: `Location of the global project used by \`--global\`.
1537
+ Defaults to \`vlt/global\` in the XDG data directory.
1538
+
1539
+ Only read from the command line, environment or the user
1540
+ config, never from a project \`vlt.json\`. A leading
1541
+ \`~\` is the home directory. Must be absolute in the
1542
+ user config.`
1543
+ }
1544
+ }).opt({
1545
+ "global-bin-dir": {
1546
+ hint: "path",
1547
+ description: `Folder where bins of global packages are linked.
1548
+
1549
+ Defaults to the folder of the \`vlt\` found in your
1550
+ \`PATH\` when it is writable, so bins run right away.
1551
+ If it is not writable, \`~/.local/bin\` is used when
1552
+ it is in your \`PATH\` (not on Windows). Otherwise
1553
+ \`<global-dir>/bin\`.
1554
+
1555
+ Only read from the command line, environment or the
1556
+ user config, never from a project \`vlt.json\`. A
1557
+ leading \`~\` is the home directory. Must be absolute
1558
+ in the user config.`
1559
+ }
1560
+ }).flag({
1561
+ path: {
1562
+ description: `With \`vlt setup\`, add the global bin folder
1563
+ (\`--global-bin-dir\`) to your \`PATH\` by editing
1564
+ your shell config (your user \`Path\` on Windows).
1565
+ Asks first, unless \`--yes\`. Command line only.`
1566
+ },
1567
+ "no-modify-path": {
1568
+ description: `Never edit shell config files (or the user
1569
+ \`Path\` on Windows) to add a folder to your
1570
+ \`PATH\`: turns off \`vlt setup --path\` edits
1571
+ and the \`vlt install -g\` offer (printing the line
1572
+ to add instead), and the \`vlt setup\` PATH prompt.
1573
+ Set \`VLT_NO_MODIFY_PATH=1\` (any value but \`0\`)
1574
+ in images or on machines whose dotfiles are
1575
+ managed elsewhere.`
1576
+ }
1520
1577
  }).opt({
1521
1578
  scope: {
1522
1579
  short: "s",
@@ -1565,7 +1622,9 @@ var definition = j2.heading("Configuration").description(
1565
1622
  config: {
1566
1623
  hint: "all | user | project",
1567
1624
  description: `Specify which configuration to show or operate on when running
1568
- \`vlt config\` commands. For read operations (get, pick, list):
1625
+ \`vlt config\` commands, and which file
1626
+ \`vlt skills link\` saves \`allow-skills\` to. For read
1627
+ operations (get, pick, list):
1569
1628
  \`all\` shows merged configuration from both user and project
1570
1629
  files (default). For write operations (set, delete, edit):
1571
1630
  defaults to \`project\`. \`user\` shows/modifies only user-level
@@ -1761,6 +1820,17 @@ var definition = j2.heading("Configuration").description(
1761
1820
  \`--config=user\`) after a successful \`install\`,
1762
1821
  \`add\` or \`update\`. Values a config file already
1763
1822
  has are left alone.`
1823
+ },
1824
+ "migrate-workspaces": {
1825
+ description: `Save workspaces read from the \`workspaces\` field of
1826
+ the root \`package.json\` or from
1827
+ \`pnpm-workspace.yaml\` to the project \`vlt.json\` on
1828
+ \`vlt install\`. \`vlt.json\` then takes precedence.
1829
+
1830
+ Set \`--no-migrate-workspaces\` to skip this; an
1831
+ already saved \`workspaces\` field stays until
1832
+ removed.`,
1833
+ default: true
1764
1834
  }
1765
1835
  }).opt({
1766
1836
  "save-prefix": {
@@ -1825,6 +1895,38 @@ var definition = j2.heading("Configuration").description(
1825
1895
  Runs scripts only for direct dependencies of the current project and any occurrences
1826
1896
  of a specific dependency with the name "my-package" anywhere in the dependency graph.`
1827
1897
  }
1898
+ }).opt({
1899
+ "allow-skills": {
1900
+ hint: "query",
1901
+ description: `Link the agent skills (folders with a \`SKILL.md\`) shipped by
1902
+ installed packages matching this DSS query into
1903
+ the project's agent skill dirs (see \`skills-dir\`)
1904
+ after \`install\`, \`ci\`, \`update\` or
1905
+ \`uninstall\`. End a selector with
1906
+ \`:skill(<name>, \u2026)\` to pick single skills (\`*\`
1907
+ globs, double-quoted names). Unset (the default) or
1908
+ \`:not(*)\` links nothing and skips all skills work.
1909
+
1910
+ \`vlt install --allow-skills=<query>\` saves the query
1911
+ to the project \`vlt.json\`; \`vlt skills link
1912
+ [<query>]\` sets, saves and applies it.
1913
+
1914
+ Example: --allow-skills="#agent-browser:skill(agent-browser)"
1915
+ Links the agent-browser skill from a package with the same name.`
1916
+ }
1917
+ }).optList({
1918
+ "skills-dir": {
1919
+ hint: "path",
1920
+ description: `Dirs to link agent skills into (see \`allow-skills\`),
1921
+ relative to the project root. Replaces detection:
1922
+ \`.agents/skills\`, plus \`<folder>/skills\` for each
1923
+ agent folder at the project root (e.g. \`.claude/\`),
1924
+ \`.claude/skills\` inside Claude Code, and existing
1925
+ \`.<name>/skills\` dirs. An empty list (\`[]\` in
1926
+ vlt.json, or \`--skills-dir=\`) links nothing. Each
1927
+ dir must be inside the project, not in
1928
+ node_modules.`
1929
+ }
1828
1930
  }).opt({
1829
1931
  access: {
1830
1932
  description: "Set the access level of the package",