@vltpkg/cli-js 1.3.8 → 1.5.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 (99) hide show
  1. package/{access-WLKANIOE.js → access-QPX4QXV4.js} +13 -12
  2. package/{bugs-5Q3QSTWP.js → bugs-TLOECXEM.js} +28 -25
  3. package/{build-XSFR63AW.js → build-IQOS3LKO.js} +28 -19
  4. package/{cache-UVPK5J5A.js → cache-O5IBYYSB.js} +35 -23
  5. package/cache-unzip-src-unzip.js +56 -12
  6. package/{chunk-NWHKSRO3.js → chunk-2U4PVHP4.js} +5270 -10837
  7. package/{chunk-5KOLUYXH.js → chunk-35EG6T3J.js} +61 -15
  8. package/{chunk-PJJCFMLW.js → chunk-3S3W7QEM.js} +7 -5
  9. package/chunk-43EJ4Q42.js +57 -0
  10. package/{chunk-IHXJVKAE.js → chunk-4TSHLSRK.js} +2 -1
  11. package/chunk-4UH3KMTD.js +6444 -0
  12. package/{chunk-6D54UN4T.js → chunk-5KW6AOTT.js} +1 -1
  13. package/chunk-6IF3RJND.js +81 -0
  14. package/{chunk-IBGFQR23.js → chunk-6LZM3I4Q.js} +56 -11
  15. package/{chunk-FIUUAQGC.js → chunk-6W5XMVIZ.js} +29 -22
  16. package/{chunk-OWMR2EDW.js → chunk-7UWRR6EE.js} +2 -2
  17. package/{chunk-WHLYMMI2.js → chunk-ARE7FKDG.js} +6 -4
  18. package/chunk-B6RIGNEO.js +626 -0
  19. package/{chunk-CB65DPZ2.js → chunk-C6ZVVEFV.js} +239 -1190
  20. package/{chunk-SE2FSMBR.js → chunk-CMLDLZZ3.js} +73 -11
  21. package/{chunk-6P5CFJR7.js → chunk-CS6AYPY5.js} +6 -6
  22. package/{chunk-TLY4VGMH.js → chunk-CW56EJIL.js} +1 -1
  23. package/{chunk-SV4WK3KX.js → chunk-F7NPYSI2.js} +3 -2
  24. package/{chunk-6BQKR2FM.js → chunk-G3FZ2ZJK.js} +1 -1
  25. package/chunk-GUP55DM6.js +59 -0
  26. package/chunk-HOF7LEIC.js +24 -0
  27. package/chunk-IFEZ6BFV.js +1111 -0
  28. package/{chunk-3U6QWN62.js → chunk-IJUVVD7E.js} +1 -1
  29. package/{chunk-H77JYU7F.js → chunk-ISAMD2FE.js} +12 -3
  30. package/{chunk-WKA5UYNA.js → chunk-LH7J5BDU.js} +5 -5
  31. package/{chunk-GZ5MYMBT.js → chunk-LUVDMEW4.js} +1 -1
  32. package/{chunk-OAP2ROTL.js → chunk-MYX4JCIJ.js} +1 -1
  33. package/{chunk-APMYKJI2.js → chunk-QNHBAGXQ.js} +1 -1
  34. package/{chunk-XCDLOQZZ.js → chunk-SMXXFQPI.js} +80 -29
  35. package/chunk-SUU2WETN.js +268 -0
  36. package/chunk-T2VBCUF5.js +77 -0
  37. package/{chunk-EL4GVZK5.js → chunk-T5EP7QEF.js} +2 -2
  38. package/{chunk-A2TSRXZD.js → chunk-UZ6ICZE3.js} +1 -1
  39. package/{chunk-DL3H4EMY.js → chunk-VR7NRWAD.js} +29 -20
  40. package/chunk-W4T5CGCO.js +52 -0
  41. package/{chunk-XDSZO74H.js → chunk-WHWPAYZY.js} +118 -20
  42. package/{chunk-KMOOTBHM.js → chunk-X6JKMIOU.js} +5 -1
  43. package/{chunk-43HNQWPQ.js → chunk-XCQCYB6G.js} +78 -13
  44. package/{chunk-IUL6MPP6.js → chunk-XCSNI6AO.js} +4 -4
  45. package/{chunk-BGA3WB7H.js → chunk-XD5KUDXX.js} +7 -7
  46. package/{chunk-QNDM4DVO.js → chunk-Z5D5KODU.js} +1 -1
  47. package/{ci-EDRETPUF.js → ci-ESVUMOZO.js} +31 -13
  48. package/cli-package.json +1 -1
  49. package/{config-MVNXGEOQ.js → config-TMB2X6DW.js} +12 -9
  50. package/{config-OKBXU7TU.js → config-ZVVLFKR7.js} +16 -13
  51. package/{create-R7BXYJSU.js → create-BLTNKSBQ.js} +28 -25
  52. package/{deprecate-YSUKBKQM.js → deprecate-VA6PGHYL.js} +17 -15
  53. package/{dist-tag-MIGYSR4F.js → dist-tag-OYJREFO2.js} +13 -12
  54. package/{docs-4WVIN75H.js → docs-6OC3OQNM.js} +28 -25
  55. package/{exec-IXHDQLAM.js → exec-AZPGFVRY.js} +28 -25
  56. package/{exec-cache-EA7GHIK7.js → exec-cache-D75UY2WI.js} +24 -22
  57. package/{exec-local-GM4LH56M.js → exec-local-E2JKB4X4.js} +22 -19
  58. package/{help-TCXGBICU.js → help-UPW77X5N.js} +5 -5
  59. package/{init-MWZDWQHM.js → init-SNO6QL7C.js} +14 -11
  60. package/{install-HPI5HU3C.js → install-TEJM2YVX.js} +165 -26
  61. package/{list-2CX6REPJ.js → list-NHCC2RNB.js} +33 -27
  62. package/{login-RAY23CVG.js → login-XNZXCGFD.js} +19 -16
  63. package/{logout-ICB5OMGY.js → logout-YCM7O36Q.js} +13 -12
  64. package/{outdated-FYHPXRMT.js → outdated-4LA7N63W.js} +26 -22
  65. package/{pack-E5MNPQXK.js → pack-RC4CZSWF.js} +25 -18
  66. package/package.json +1 -1
  67. package/{ping-REQ2KSAR.js → ping-RLVAZGDL.js} +13 -12
  68. package/{pkg-YB4GSRII.js → pkg-FED5C6TP.js} +23 -14
  69. package/{profile-GKBW6GRI.js → profile-DJZNLQPG.js} +13 -12
  70. package/{publish-4ZQJYYLF.js → publish-54AMVMTQ.js} +61 -45
  71. package/{query-SKXBF3MJ.js → query-ZQLMSJ7O.js} +35 -29
  72. package/{registry-MQJJCWJY.js → registry-6HKQYSZX.js} +7 -7
  73. package/registry-client-src-revalidate.js +110 -20
  74. package/{repo-ACPTZI2C.js → repo-ITA4BLZ4.js} +28 -25
  75. package/{reporter-4KK2JNGO.js → reporter-UYVR2WMB.js} +73 -14
  76. package/{run-YW3ITX2A.js → run-TP2HTJRN.js} +22 -19
  77. package/{run-exec-7VQX3OFG.js → run-exec-UGCC53DV.js} +22 -19
  78. package/security-archive-src-update-expired.js +88 -28
  79. package/{setup-PLEKCMXN.js → setup-XPAM5U3Z.js} +23 -21
  80. package/skills-LR6GXW3X.js +413 -0
  81. package/skills-YD2TB2VD.js +495 -0
  82. package/{src-XQ7KVUVN.js → src-34D4DOOH.js} +37 -27
  83. package/{src-PXDFMQ6W.js → src-H6DFCAPH.js} +9 -8
  84. package/{src-GP7VLT7P.js → src-LHDC4NJO.js} +58 -9
  85. package/{token-GB7RPE5J.js → token-OF63PFTQ.js} +13 -12
  86. package/{uninstall-RLCECX37.js → uninstall-B54FQ5KQ.js} +20 -15
  87. package/{unpublish-3ZXEAVHF.js → unpublish-CSHIGMDQ.js} +31 -16
  88. package/{update-VDZP6EZN.js → update-HS4VJ5ZG.js} +51 -25
  89. package/{version-MRELJPOK.js → version-L7S3DHUS.js} +24 -14
  90. package/{view-LCXMTGCJ.js → view-NWKKWFVA.js} +17 -15
  91. package/vlr.js +1 -1
  92. package/vlrx.js +1 -1
  93. package/vlt.js +1 -1
  94. package/vlx.js +1 -1
  95. package/vlxl.js +1 -1
  96. package/{whoami-PNRDBS45.js → whoami-65K35VGW.js} +13 -12
  97. package/chunk-4JAZZRKR.js +0 -76
  98. package/chunk-G2YT2GWF.js +0 -120
  99. package/chunk-U7TEQCBN.js +0 -880
@@ -251,7 +251,27 @@ import {
251
251
  import { inspect } from "node:util";
252
252
 
253
253
  // ../../src/fast-split/src/index.ts
254
+ var splitTwo = (str, delim) => {
255
+ const a = str.indexOf(delim);
256
+ return a === -1 ? [str] : [str.substring(0, a), str.substring(a + delim.length)];
257
+ };
258
+ var splitThree = (str, delim) => {
259
+ const a = str.indexOf(delim);
260
+ if (a === -1) return [str];
261
+ const l = delim.length;
262
+ const b = str.indexOf(delim, a + l);
263
+ return b === -1 ? [str.substring(0, a), str.substring(a + l)] : [
264
+ str.substring(0, a),
265
+ str.substring(a + l, b),
266
+ str.substring(b + l)
267
+ ];
268
+ };
254
269
  function fastSplit(str, delim, limit = -1, onPart) {
270
+ if (onPart === void 0) {
271
+ if (limit === 2) return splitTwo(str, delim);
272
+ if (limit === 3)
273
+ return splitThree(str, delim);
274
+ }
255
275
  let i = 0;
256
276
  let p = 0;
257
277
  const l = delim.length;
@@ -1292,9 +1312,10 @@ var gitHostWebsites = {
1292
1312
  gitlab: "https://gitlab.com/"
1293
1313
  };
1294
1314
  var getOptions = (options) => ({
1295
- catalog: {},
1296
1315
  catalogs: {},
1297
1316
  ...options,
1317
+ // after spread: explicit `catalog: undefined` gets default too
1318
+ catalog: options?.catalog ?? {},
1298
1319
  // built-in aliases are user/service-overridable: user config wins
1299
1320
  "jsr-registries": {
1300
1321
  ...defaultJsrRegistries,
@@ -1471,19 +1492,25 @@ var Spec = class _Spec {
1471
1492
  }
1472
1493
  if (this.bareSpec.startsWith("catalog:")) {
1473
1494
  this.catalog = this.bareSpec.substring("catalog:".length);
1474
- const catalog = this.catalog ? this.options.catalogs?.[this.catalog] : this.options.catalog;
1495
+ const { catalog: defaultCatalog, catalogs = {} } = this.options;
1496
+ const catalog = this.catalog ? Object.hasOwn(catalogs, this.catalog) ? catalogs[this.catalog] : void 0 : Object.keys(defaultCatalog).length ? defaultCatalog : void 0;
1475
1497
  if (!catalog) {
1476
- throw this.#error("Named catalog not found", {
1477
- name: this.catalog,
1478
- validOptions: this.options.catalogs && Object.keys(this.options.catalogs)
1479
- });
1498
+ throw this.#catalogError(
1499
+ this.catalog ? `Catalog "${this.catalog}" not found for ${this.spec}` : `Default catalog not found for ${this.spec}`
1500
+ );
1480
1501
  }
1481
- const sub = catalog[this.name];
1502
+ const catalogName = this.catalog ? `catalog "${this.catalog}"` : "default catalog";
1503
+ const sub = Object.hasOwn(catalog, this.name) ? catalog[this.name] : void 0;
1482
1504
  if (!sub) {
1483
- throw this.#error("Name not found in catalog", {
1484
- name: this.name,
1485
- validOptions: Object.keys(catalog)
1486
- });
1505
+ throw this.#catalogError(
1506
+ `Package "${this.name}" not found in ${catalogName}`
1507
+ );
1508
+ }
1509
+ if (sub.startsWith("catalog:")) {
1510
+ throw this.#error(
1511
+ `Catalog entry "${this.name}" in ${catalogName} cannot be a catalog: spec`,
1512
+ { code: "ECONFIG", found: sub }
1513
+ );
1487
1514
  }
1488
1515
  this.subspec = _Spec.parse(this.name, sub, this.options);
1489
1516
  this.type = "catalog";
@@ -1799,6 +1826,23 @@ var Spec = class _Spec {
1799
1826
  ].map((p) => `${p}:`)
1800
1827
  });
1801
1828
  }
1829
+ /** ECONFIG error listing defined catalogs & ones defining this dep */
1830
+ #catalogError(message) {
1831
+ const { catalog, catalogs = {} } = this.options;
1832
+ const defined = [
1833
+ ...Object.keys(catalog).length ? [["", catalog]] : [],
1834
+ ...Object.entries(catalogs)
1835
+ ];
1836
+ const validOptions = defined.map(([n]) => `catalog:${n}`);
1837
+ const wanted = defined.filter(
1838
+ ([, c]) => Object.hasOwn(c, this.name) && !!c[this.name]
1839
+ ).map(([n]) => `catalog:${n}`);
1840
+ return this.#error(message, {
1841
+ code: "ECONFIG",
1842
+ ...validOptions.length ? { validOptions } : {},
1843
+ ...wanted.length ? { wanted } : {}
1844
+ });
1845
+ }
1802
1846
  #error(message, extra = {}) {
1803
1847
  return error(message, { spec: this.spec, ...extra }, this.#error);
1804
1848
  }
@@ -2146,7 +2190,7 @@ var baseDepID = (id) => {
2146
2190
  var package_default = {
2147
2191
  name: "@vltpkg/user-agent",
2148
2192
  description: "The User-Agent string that vlt sends with every outbound request",
2149
- version: "1.3.8",
2193
+ version: "1.5.0",
2150
2194
  repository: {
2151
2195
  type: "git",
2152
2196
  url: "git+https://github.com/vltpkg/vltpkg.git",
@@ -2223,13 +2267,35 @@ var asPackageReportData = (o) => {
2223
2267
  }
2224
2268
  return o;
2225
2269
  };
2270
+ var getItemScore = (data) => {
2271
+ if (data._type || !data.score) return void 0;
2272
+ const {
2273
+ license,
2274
+ maintenance,
2275
+ quality,
2276
+ supplyChain,
2277
+ vulnerability
2278
+ } = data.score;
2279
+ const scoreComponents = [
2280
+ license,
2281
+ maintenance,
2282
+ quality,
2283
+ supplyChain,
2284
+ vulnerability
2285
+ ];
2286
+ const overall = Number(
2287
+ (scoreComponents.reduce((sum, score) => sum + score, 0) / scoreComponents.length).toFixed(2)
2288
+ );
2289
+ return { ...data.score, overall };
2290
+ };
2226
2291
 
2227
2292
  // ../../src/security-archive/src/update-expired.ts
2228
2293
  var __CODE_SPLIT_SCRIPT_NAME = import.meta.filename;
2229
2294
  var SOCKET_API_V0_URL = "https://api.socket.dev/v0/purl?alerts=true";
2230
2295
  var SOCKET_PUBLIC_API_TOKEN = "sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api";
2231
2296
  var isMain = (path) => path === __CODE_SPLIT_SCRIPT_NAME || path === pathToFileURL(__CODE_SPLIT_SCRIPT_NAME).toString();
2232
- var retrieveRemoteData = async (queue, retries) => {
2297
+ var retrieveRemoteData = async (queue, retries, timeout) => {
2298
+ const signal = AbortSignal.timeout(timeout);
2233
2299
  return pRetry(
2234
2300
  async () => {
2235
2301
  const req = await fetch(SOCKET_API_V0_URL, {
@@ -2240,7 +2306,8 @@ var retrieveRemoteData = async (queue, retries) => {
2240
2306
  },
2241
2307
  body: JSON.stringify({
2242
2308
  components: Array.from(queue)
2243
- })
2309
+ }),
2310
+ signal
2244
2311
  });
2245
2312
  if (req.status === 404) {
2246
2313
  throw new AbortError("Missing API");
@@ -2253,7 +2320,7 @@ var retrieveRemoteData = async (queue, retries) => {
2253
2320
  const str = await req.text();
2254
2321
  return str.trim() + "\n";
2255
2322
  },
2256
- { retries }
2323
+ { retries, signal }
2257
2324
  );
2258
2325
  };
2259
2326
  var main = async (input = process.stdin) => {
@@ -2276,7 +2343,7 @@ var main = async (input = process.stdin) => {
2276
2343
  input.on("error", reject);
2277
2344
  }
2278
2345
  );
2279
- const { dbPath, retries, ttl, expired } = payload;
2346
+ const { dbPath, retries, timeout, ttl, expired } = payload;
2280
2347
  if (!expired.length) {
2281
2348
  return false;
2282
2349
  }
@@ -2287,13 +2354,14 @@ var main = async (input = process.stdin) => {
2287
2354
  expiredQueue.add({ purl });
2288
2355
  entryByNameVersion.set(`${entry.name}@${entry.version}`, entry);
2289
2356
  }
2290
- const res = await retrieveRemoteData(expiredQueue, retries);
2357
+ const res = await retrieveRemoteData(expiredQueue, retries, timeout);
2291
2358
  const now = Date.now();
2292
2359
  const results = [];
2293
2360
  const json = res.split("}\n");
2294
2361
  for (const line of json) {
2295
2362
  if (!line.trim()) continue;
2296
2363
  const data = JSON.parse(line + "}");
2364
+ if (data._type) continue;
2297
2365
  const scope = data.namespace ? `${data.namespace}/` : "";
2298
2366
  const name = `${scope}${data.name}`;
2299
2367
  const key = `${name}@${data.version}`;
@@ -2304,19 +2372,11 @@ var main = async (input = process.stdin) => {
2304
2372
  );
2305
2373
  continue;
2306
2374
  }
2307
- const scoreComponents = [
2308
- data.score.license,
2309
- data.score.maintenance,
2310
- data.score.quality,
2311
- data.score.supplyChain,
2312
- data.score.vulnerability
2313
- ];
2314
- const newAverageScore = Number(
2315
- (scoreComponents.reduce((sum, score) => sum + score, 0) / scoreComponents.length).toFixed(2)
2316
- );
2375
+ const score = getItemScore(data);
2376
+ if (!score) continue;
2317
2377
  const reportData = asPackageReportData({
2318
2378
  ...data,
2319
- score: { ...data.score, overall: newAverageScore }
2379
+ score
2320
2380
  });
2321
2381
  results.push({
2322
2382
  depID: baseDepID(asDepID(entry.depID)),
@@ -11,39 +11,41 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  stdout
14
- } from "./chunk-XDSZO74H.js";
15
- import "./chunk-KMOOTBHM.js";
16
- import "./chunk-G2YT2GWF.js";
17
- import "./chunk-IHXJVKAE.js";
14
+ } from "./chunk-WHWPAYZY.js";
15
+ import "./chunk-X6JKMIOU.js";
16
+ import "./chunk-4TSHLSRK.js";
17
+ import {
18
+ commandUsage
19
+ } from "./chunk-CW56EJIL.js";
18
20
  import {
19
21
  configWriteTarget,
20
22
  registrySelectionFields
21
- } from "./chunk-43HNQWPQ.js";
22
- import "./chunk-DL3H4EMY.js";
23
+ } from "./chunk-XCQCYB6G.js";
24
+ import "./chunk-VR7NRWAD.js";
23
25
  import "./chunk-SRWDPPLX.js";
26
+ import "./chunk-IFEZ6BFV.js";
27
+ import "./chunk-C6ZVVEFV.js";
28
+ import "./chunk-4KCU2KZL.js";
24
29
  import "./chunk-WGDTG44V.js";
25
30
  import {
26
31
  normalizeRegistryURL
27
- } from "./chunk-A2TSRXZD.js";
28
- import {
29
- commandUsage
30
- } from "./chunk-TLY4VGMH.js";
31
- import "./chunk-CB65DPZ2.js";
32
- import "./chunk-4KCU2KZL.js";
33
- import "./chunk-SV4WK3KX.js";
34
- import "./chunk-GZ5MYMBT.js";
35
- import "./chunk-SE2FSMBR.js";
32
+ } from "./chunk-UZ6ICZE3.js";
33
+ import "./chunk-CMLDLZZ3.js";
34
+ import "./chunk-F7NPYSI2.js";
35
+ import "./chunk-LUVDMEW4.js";
36
36
  import "./chunk-HTOTG4TS.js";
37
37
  import {
38
38
  RegistryClient,
39
39
  getKC,
40
40
  normalizeRegistryKey
41
- } from "./chunk-5KOLUYXH.js";
42
- import "./chunk-APMYKJI2.js";
43
- import "./chunk-6D54UN4T.js";
44
- import "./chunk-6BQKR2FM.js";
45
- import "./chunk-U7TEQCBN.js";
41
+ } from "./chunk-35EG6T3J.js";
42
+ import "./chunk-QNHBAGXQ.js";
43
+ import "./chunk-G3FZ2ZJK.js";
44
+ import "./chunk-5KW6AOTT.js";
45
+ import "./chunk-SUU2WETN.js";
46
+ import "./chunk-B6RIGNEO.js";
46
47
  import "./chunk-XNLSTHDK.js";
48
+ import "./chunk-6IF3RJND.js";
47
49
  import "./chunk-PDWPFR5T.js";
48
50
  import "./chunk-Y5PA7DVK.js";
49
51
  import {
@@ -51,7 +53,7 @@ import {
51
53
  defaultRegistries,
52
54
  isErrorWithCause,
53
55
  isObject
54
- } from "./chunk-IBGFQR23.js";
56
+ } from "./chunk-6LZM3I4Q.js";
55
57
  import {
56
58
  error
57
59
  } from "./chunk-WZWDS3W4.js";
@@ -0,0 +1,413 @@
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
+ mermaidOutput
14
+ } from "./chunk-4UH3KMTD.js";
15
+ import {
16
+ assertQuery,
17
+ linkSkills,
18
+ listSkills
19
+ } from "./chunk-2U4PVHP4.js";
20
+ import "./chunk-SMXXFQPI.js";
21
+ import {
22
+ styleTextStdout
23
+ } from "./chunk-WHWPAYZY.js";
24
+ import "./chunk-X6JKMIOU.js";
25
+ import "./chunk-4TSHLSRK.js";
26
+ import {
27
+ commandUsage
28
+ } from "./chunk-CW56EJIL.js";
29
+ import {
30
+ configLabel,
31
+ savedLine,
32
+ storedAllowSkills,
33
+ unmatchedLines,
34
+ unscannedLines
35
+ } from "./chunk-W4T5CGCO.js";
36
+ import {
37
+ configWriteTarget
38
+ } from "./chunk-XCQCYB6G.js";
39
+ import "./chunk-VR7NRWAD.js";
40
+ import "./chunk-SRWDPPLX.js";
41
+ import "./chunk-IFEZ6BFV.js";
42
+ import "./chunk-C6ZVVEFV.js";
43
+ import "./chunk-4KCU2KZL.js";
44
+ import "./chunk-WGDTG44V.js";
45
+ import "./chunk-UZ6ICZE3.js";
46
+ import "./chunk-CMLDLZZ3.js";
47
+ import "./chunk-F7NPYSI2.js";
48
+ import "./chunk-LUVDMEW4.js";
49
+ import "./chunk-HTOTG4TS.js";
50
+ import "./chunk-G3FZ2ZJK.js";
51
+ import "./chunk-5KW6AOTT.js";
52
+ import "./chunk-SUU2WETN.js";
53
+ import "./chunk-B6RIGNEO.js";
54
+ import "./chunk-XNLSTHDK.js";
55
+ import "./chunk-6IF3RJND.js";
56
+ import "./chunk-PDWPFR5T.js";
57
+ import "./chunk-Y5PA7DVK.js";
58
+ import {
59
+ asError
60
+ } from "./chunk-6LZM3I4Q.js";
61
+ import {
62
+ error
63
+ } from "./chunk-WZWDS3W4.js";
64
+ import "./chunk-PZLD7RTK.js";
65
+
66
+ // ../../src/cli-sdk/src/commands/skills.ts
67
+ import { styleText } from "node:util";
68
+
69
+ // ../../src/cli-sdk/src/skills-prompt.ts
70
+ import { createInterface } from "node:readline/promises";
71
+ var interactive = () => process.stdin.isTTY;
72
+ var open = (s) => {
73
+ const rl = createInterface({
74
+ input: s.input ?? process.stdin,
75
+ output: s.output ?? process.stdout,
76
+ // prefill and line editing
77
+ terminal: true
78
+ });
79
+ rl.on("SIGINT", () => rl.close());
80
+ let done = false;
81
+ const closed = new Promise(
82
+ (r) => rl.once("close", () => {
83
+ done = true;
84
+ r(void 0);
85
+ })
86
+ );
87
+ const ask = async (query, prefill) => {
88
+ if (done) return void 0;
89
+ const q = rl.question(query).catch(() => void 0);
90
+ if (prefill) rl.write(prefill);
91
+ return Promise.race([q, closed]);
92
+ };
93
+ return { rl, ask };
94
+ };
95
+ var confirm = async (question, s = {}) => {
96
+ const { rl, ask } = open(s);
97
+ try {
98
+ const a = await ask(question);
99
+ return a === void 0 ? void 0 : /^y(es)?$/i.test(a.trim());
100
+ } finally {
101
+ rl.close();
102
+ }
103
+ };
104
+ var editQuery = async ({
105
+ current,
106
+ prefill,
107
+ check,
108
+ ...s
109
+ }) => {
110
+ const output = s.output ?? process.stdout;
111
+ if (current !== void 0) {
112
+ output.write(
113
+ "\n\u26A0\uFE0F The new allow-skills replaces the current one. Make sure it still\nselects every skill you want: skills it no longer selects are unlinked.\n\n" + styleTextStdout(
114
+ "yellow",
115
+ `Current allow-skills: ${current}`
116
+ ) + "\n"
117
+ );
118
+ }
119
+ const prompt = styleTextStdout("cyan", "New allow-skills: ");
120
+ const { rl, ask } = open(s);
121
+ try {
122
+ let fill = prefill;
123
+ for (; ; ) {
124
+ const a = (await ask(prompt, fill))?.trim();
125
+ if (!a) return void 0;
126
+ try {
127
+ await check(a);
128
+ return a;
129
+ } catch (e) {
130
+ output.write(`${asError(e).message}
131
+ `);
132
+ fill = a;
133
+ }
134
+ }
135
+ } finally {
136
+ rl.close();
137
+ }
138
+ };
139
+
140
+ // ../../src/cli-sdk/src/commands/skills.ts
141
+ var needsRegistry = true;
142
+ var usage = () => commandUsage({
143
+ command: "skills",
144
+ usage: ["", "list [<query>]", "link [<query>]"],
145
+ description: `Manage the agent skills shipped by installed packages.
146
+
147
+ A skill is a folder with a \`SKILL.md\` file
148
+ (https://agentskills.io/specification). Packages ship them as a
149
+ root \`SKILL.md\`, or at \`<name>/SKILL.md\` in \`skills/\`,
150
+ \`dist/skills/\` or \`.agents/skills/\`: the first skill of a name
151
+ wins.
152
+
153
+ Skills are linked into the project's agent skill dirs:
154
+ \`.agents/skills\`, plus \`<folder>/skills\` for each agent folder
155
+ at the project root (e.g. \`.claude/\`), or the \`skills-dir\`
156
+ config. When packages ship skills with the same name, one is
157
+ linked and the others are reported. Only links made by vlt
158
+ (pointing into \`node_modules/.vlt\`) are ever replaced or
159
+ removed; anything else in the way is skipped.
160
+
161
+ Use --target or a query after the subcommand to select packages
162
+ using DSS query syntax. End a selector with
163
+ \`:skill(<name>, \u2026)\` to pick single skills, e.g.
164
+ \`#skills:skill(find-skills)\`. Use
165
+ \`vlt install --allow-skills=<query>\` to link skills on install.`,
166
+ subcommands: {
167
+ list: {
168
+ usage: "[<query>]",
169
+ description: `List the skills of installed packages. The default.
170
+ Selects all packages (\`*\`) by default. Applies
171
+ \`:skill()\`: preview a query before \`link\` saves
172
+ it.`
173
+ },
174
+ link: {
175
+ usage: "[<query>]",
176
+ description: `Set, save and apply \`allow-skills\`: link what the
177
+ query selects and remove vlt links to other skills.
178
+ With no query: the stored one, or
179
+ \`:not(:malware)\`. Asks before replacing or editing
180
+ a stored query (-y skips). Saves to the project
181
+ vlt.json, or the user one with --config=user.`
182
+ }
183
+ },
184
+ options: {
185
+ target: {
186
+ value: "<query>",
187
+ description: "Query selector to filter packages using DSS syntax."
188
+ },
189
+ yes: {
190
+ description: "Skip the prompts: replace or keep the stored allow-skills without asking."
191
+ },
192
+ config: {
193
+ value: "user|project",
194
+ description: "vlt.json to save allow-skills to (default: project)."
195
+ },
196
+ view: {
197
+ value: "[human | json | mermaid]",
198
+ description: "Output format. mermaid: list only."
199
+ }
200
+ }
201
+ });
202
+ var plural = (n, s) => `${n} ${s}${n === 1 ? "" : "s"}`;
203
+ var lines = (header, items) => [header, ...items.map((i) => ` ${i}`)].join("\n");
204
+ var notes = (r) => [
205
+ ...r.skipped ? [`\u26A0\uFE0F Skipped ${r.skipped.join(", ")}`] : [],
206
+ ...r.gitignore ? [`\u26A0\uFE0F Could not update ${r.gitignore.join(", ")}`] : [],
207
+ ...unscannedLines(r)
208
+ ];
209
+ var pkgLabel = (s) => {
210
+ const pkg = s.version ? `${s.name}@${s.version}` : s.name;
211
+ return s.alias ? `${s.alias} (${pkg})` : pkg;
212
+ };
213
+ var linkedSuffix = (s, dirs) => dirs.length && dirs.every((d) => s.linked.includes(d)) ? " (linked)" : s.linked.length ? ` (linked in ${s.linked.join(", ")})` : "";
214
+ var row = (s, dirs) => `${s.skill} (${pkgLabel(s)})${linkedSuffix(s, dirs)}`;
215
+ var listNotes = (r) => [
216
+ ...!r.dirs.length && !r.skipped ? ["No agent skill dirs: skills-dir is empty"] : [],
217
+ ...notes(r)
218
+ ];
219
+ var humanList = (r, { colors } = {}) => {
220
+ const style = (format) => (s) => colors ? styleText(format, s, { validateStream: false }) : s;
221
+ const yellow = style("yellow");
222
+ const rows = r.skills.map((s) => {
223
+ const x = row(s, r.dirs);
224
+ return s.linked.length ? yellow(x) : x;
225
+ });
226
+ const last = rows.length - 1;
227
+ return [
228
+ ...rows.length ? [
229
+ style("reset")(
230
+ [
231
+ r.project,
232
+ ...rows.map(
233
+ (x, i) => `${i === last ? "\u2514\u2500\u2500" : "\u251C\u2500\u2500"} ${x}`
234
+ )
235
+ ].join("\n")
236
+ )
237
+ ] : ["No agent skills found in installed packages."],
238
+ ...listNotes(r)
239
+ ].join("\n");
240
+ };
241
+ var mermaidList = (r) => {
242
+ const children = /* @__PURE__ */ new Map();
243
+ for (const s of r.skills) {
244
+ const list = children.get(s.id) ?? [];
245
+ list.push({
246
+ edge: pkgLabel(s),
247
+ label: `${s.skill}${linkedSuffix(s, r.dirs)}`
248
+ });
249
+ children.set(s.id, list);
250
+ }
251
+ const { graph } = r;
252
+ return [
253
+ mermaidOutput({
254
+ edges: [],
255
+ importers: /* @__PURE__ */ new Set([graph.mainImporter]),
256
+ nodes: [...graph.nodes.values()].filter(
257
+ (n) => n === graph.mainImporter || children.has(n.id)
258
+ ),
259
+ children
260
+ }),
261
+ ...listNotes(r).map((n) => `%% ${n}`)
262
+ ].join("\n");
263
+ };
264
+ var jsonSkill = ({
265
+ skill,
266
+ name,
267
+ alias,
268
+ version,
269
+ id,
270
+ description,
271
+ ...rest
272
+ }) => ({
273
+ name: skill,
274
+ description,
275
+ "dependency-name": alias ?? name,
276
+ "package-id": id,
277
+ ...rest
278
+ });
279
+ var count = (rows) => new Set(rows.map((r) => `${r.id}\0${r.skill}`)).size;
280
+ var humanLink = (r) => {
281
+ const out = [];
282
+ if (r.linked.length) {
283
+ out.push(
284
+ lines(
285
+ `\u{1F517} Linked ${plural(count(r.linked), "agent skill")}:`,
286
+ r.linked.map((s) => s.mount)
287
+ )
288
+ );
289
+ } else if (r.unchanged.length) {
290
+ out.push(
291
+ `${plural(count(r.unchanged), "agent skill")} already linked.`
292
+ );
293
+ }
294
+ if (r.removed.length) {
295
+ out.push(
296
+ lines(
297
+ `\u{1F9F9} Removed ${plural(r.removed.length, "skill link")}:`,
298
+ r.removed
299
+ )
300
+ );
301
+ }
302
+ if (r.conflicts.length) {
303
+ out.push(
304
+ lines(
305
+ `\u26A0\uFE0F Skipped ${plural(r.conflicts.length, "skill")}, path in use or taken by another package:`,
306
+ r.conflicts
307
+ )
308
+ );
309
+ }
310
+ out.push(...notes(r));
311
+ return out.join("\n") || "No agent skills found to link.";
312
+ };
313
+ var human = (r, o) => r.action === "list" ? humanList(r, o) : r.action === "unchanged" ? "No changes made." : [
314
+ humanLink(r),
315
+ ...unmatchedLines(r.unmatched),
316
+ ...r.saved ? [savedLine(r.query, r.saved)] : []
317
+ ].join("\n");
318
+ var views = {
319
+ human,
320
+ json: (r) => {
321
+ if (r.action !== "list") return r;
322
+ const { project, graph, ...rest } = r;
323
+ return { ...rest, skills: rest.skills.map(jsonSkill) };
324
+ },
325
+ mermaid: (r) => r.action === "list" ? mermaidList(r) : human(r)
326
+ };
327
+ var defaultQuery = ":not(:malware)";
328
+ var where = (which) => which === "user" ? "in the user vlt.json" : "for this project (vlt.json)";
329
+ var pickQuery = async (conf, given) => {
330
+ const check = (q) => assertQuery(q, "allow-skills", ["skill"]);
331
+ const stored = storedAllowSkills(conf);
332
+ const yes = !!conf.get("yes");
333
+ const tty = interactive();
334
+ if (given) {
335
+ await check(given);
336
+ if (!stored || stored.query === given || yes) return given;
337
+ if (!tty) {
338
+ throw error(
339
+ `allow-skills is already set (${configLabel(stored.which)}): "${stored.query}"; pass -y to replace it`,
340
+ { code: "EUSAGE", found: given, wanted: stored.query }
341
+ );
342
+ }
343
+ if (!await confirm(
344
+ `allow-skills is already set ${where(stored.which)}: "${stored.query}". Replace it? [y/N] `
345
+ )) {
346
+ return void 0;
347
+ }
348
+ return editQuery({ current: stored.query, prefill: given, check });
349
+ }
350
+ if (stored) {
351
+ if (yes || !tty) return stored.query;
352
+ const edit = await confirm(
353
+ `allow-skills is set ${where(stored.which)}: "${stored.query}". Edit it? [y/N] `
354
+ );
355
+ if (edit === void 0) return void 0;
356
+ return edit ? editQuery({
357
+ current: stored.query,
358
+ prefill: stored.query,
359
+ check
360
+ }) : stored.query;
361
+ }
362
+ if (yes || !tty) return defaultQuery;
363
+ return editQuery({ prefill: defaultQuery, check });
364
+ };
365
+ var command = async (conf) => {
366
+ const [sub = "list", query] = conf.positionals;
367
+ const target = conf.get("target") || query;
368
+ const opts = {
369
+ ...conf.options,
370
+ projectRoot: conf.projectRoot,
371
+ skillsDirs: conf.get("skills-dir")
372
+ };
373
+ switch (sub) {
374
+ case "list":
375
+ case "ls":
376
+ return {
377
+ action: "list",
378
+ ...await listSkills({ ...opts, target })
379
+ };
380
+ case "link": {
381
+ const query2 = await pickQuery(conf, target);
382
+ if (query2 === void 0) return { action: "unchanged" };
383
+ const res = await linkSkills({
384
+ ...opts,
385
+ target: query2,
386
+ apply: true
387
+ });
388
+ let saved;
389
+ if (storedAllowSkills(conf)?.query !== query2) {
390
+ saved = configWriteTarget(conf, "project");
391
+ await conf.addConfigToFile(saved, { "allow-skills": query2 });
392
+ }
393
+ return {
394
+ action: "link",
395
+ query: query2,
396
+ ...saved && { saved },
397
+ ...res
398
+ };
399
+ }
400
+ default:
401
+ throw error("Unknown skills subcommand", {
402
+ code: "EUSAGE",
403
+ found: sub,
404
+ validOptions: ["list", "ls", "link"]
405
+ });
406
+ }
407
+ };
408
+ export {
409
+ command,
410
+ needsRegistry,
411
+ usage,
412
+ views
413
+ };