@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
@@ -0,0 +1,495 @@
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
+ filterNodesByQueryParts,
14
+ load2 as load,
15
+ lstat,
16
+ mountSkill,
17
+ norm,
18
+ packageKey,
19
+ readMounts,
20
+ realOr,
21
+ samePath,
22
+ skillsDirs,
23
+ unmountSkill,
24
+ unshare
25
+ } from "./chunk-2U4PVHP4.js";
26
+ import "./chunk-SMXXFQPI.js";
27
+ import "./chunk-C6ZVVEFV.js";
28
+ import {
29
+ splitDepID
30
+ } from "./chunk-F7NPYSI2.js";
31
+ import "./chunk-LUVDMEW4.js";
32
+ import "./chunk-HTOTG4TS.js";
33
+ import "./chunk-G3FZ2ZJK.js";
34
+ import "./chunk-B6RIGNEO.js";
35
+ import "./chunk-XNLSTHDK.js";
36
+ import "./chunk-Y5PA7DVK.js";
37
+ import {
38
+ parse
39
+ } from "./chunk-6LZM3I4Q.js";
40
+ import "./chunk-WZWDS3W4.js";
41
+ import "./chunk-PZLD7RTK.js";
42
+
43
+ // ../../src/graph/src/skills/index.ts
44
+ import { existsSync } from "node:fs";
45
+
46
+ // ../../src/graph/src/skills/discover.ts
47
+ import { readdirSync, readFileSync } from "node:fs";
48
+ import { resolve } from "node:path";
49
+ var skillDirName = /^[a-z0-9][a-z0-9._-]*$/i;
50
+ var specName = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
51
+ var topKey = /^([A-Za-z0-9_-]+):/;
52
+ var blockIndicator = /^[>|][-+1-9]*$/;
53
+ var fold = (inline, more) => {
54
+ let value = [blockIndicator.test(inline) ? "" : inline, ...more].filter(Boolean).join(" ");
55
+ const q = value[0];
56
+ if (value.length > 1 && (q === '"' || q === "'") && value.endsWith(q)) {
57
+ value = value.slice(1, -1).trim();
58
+ }
59
+ return value || void 0;
60
+ };
61
+ var readFrontmatter = (file) => {
62
+ let text;
63
+ try {
64
+ text = readFileSync(file, "utf8");
65
+ } catch {
66
+ return {};
67
+ }
68
+ const lines = text.split(/\r?\n/);
69
+ if (lines[0]?.trim() !== "---") return {};
70
+ const end = lines.findIndex((l, i) => i > 0 && l.trim() === "---");
71
+ if (end === -1) return {};
72
+ const fm = {};
73
+ let key;
74
+ let inline = "";
75
+ let more = [];
76
+ const flush = () => {
77
+ if (key) fm[key] = fold(inline, more);
78
+ key = void 0;
79
+ };
80
+ for (const line of lines.slice(1, end)) {
81
+ if (!line.trim()) continue;
82
+ const m = topKey.exec(line);
83
+ if (m) {
84
+ flush();
85
+ const k = m[1];
86
+ if (k === "name" || k === "description") {
87
+ key = k;
88
+ inline = line.slice(k.length + 1).trim();
89
+ const hash = inline.search(/(?:^|\s)#/);
90
+ if (hash !== -1 && !/^["']/.test(inline)) {
91
+ inline = inline.slice(0, hash).trim();
92
+ }
93
+ more = [];
94
+ }
95
+ } else if (/^\s/.test(line)) {
96
+ if (key) more.push(line.trim());
97
+ } else {
98
+ flush();
99
+ }
100
+ }
101
+ flush();
102
+ return fm;
103
+ };
104
+ var sanitize = (s) => {
105
+ const clean = s?.replace(/\p{Cc}/gu, " ").replace(/\s+/g, " ").trim();
106
+ return clean ? clean.slice(0, 1024) : void 0;
107
+ };
108
+ var lc = (s) => s.toLowerCase();
109
+ var isDir = (path) => !!lstat(path)?.isDirectory();
110
+ var isFile = (path) => !!lstat(path)?.isFile();
111
+ var isSkillMd = (name) => name.toLowerCase() === "skill.md";
112
+ var shipDirs = ["skills", "dist/skills", ".agents/skills"];
113
+ var subdir = (dir, sub) => {
114
+ let path = dir;
115
+ for (const seg of sub.split("/")) {
116
+ path = resolve(path, seg);
117
+ if (!isDir(path)) return void 0;
118
+ }
119
+ return path;
120
+ };
121
+ var scan = (dir, pkgName) => {
122
+ const found = [];
123
+ const has = (skill) => found.some((f) => lc(f.skill) === lc(skill));
124
+ const root = resolve(dir, "SKILL.md");
125
+ if (isFile(root)) {
126
+ const { name, description } = readFrontmatter(root);
127
+ const skill = name && name.length <= 64 && specName.test(name) ? name : pkgName.slice(pkgName.lastIndexOf("/") + 1);
128
+ if (skillDirName.test(skill) && !isSkillMd(skill)) {
129
+ found.push({ skill, path: dir, name, description });
130
+ }
131
+ }
132
+ for (const sub of shipDirs) {
133
+ const skillsDir = subdir(dir, sub);
134
+ if (!skillsDir) continue;
135
+ for (const d of readdirSync(skillsDir).sort()) {
136
+ if (!skillDirName.test(d) || isSkillMd(d) || has(d)) continue;
137
+ const path = resolve(skillsDir, d);
138
+ const file = resolve(path, "SKILL.md");
139
+ if (!isDir(path) || !isFile(file)) continue;
140
+ const { name, description } = readFrontmatter(file);
141
+ found.push({ skill: d, path, name, description });
142
+ }
143
+ }
144
+ return found;
145
+ };
146
+ var rank = (node) => {
147
+ let r = 2;
148
+ for (const { from } of node.edgesIn) {
149
+ if (from.mainImporter) return 0;
150
+ if (from.importer) r = 1;
151
+ }
152
+ return r;
153
+ };
154
+ var ver = (node) => node.version ? parse(node.version) : void 0;
155
+ var byVersion = (a, b) => {
156
+ const va = ver(a);
157
+ const vb = ver(b);
158
+ return va && vb ? vb.compare(va) : 0;
159
+ };
160
+ var compare = (a, b) => rank(a) - rank(b) || byVersion(a, b) || a.id.localeCompare(b.id, "en");
161
+ var aliasOf = (node) => {
162
+ const edges = [...node.edgesIn];
163
+ const n = (edges.find((e) => e.from.mainImporter) ?? edges.find((e) => e.from.importer))?.name;
164
+ return n === node.name ? void 0 : n;
165
+ };
166
+ var scannable = (node) => !node.importer && node.inVltStore() && splitDepID(node.id)[0] !== "file";
167
+ var shipsSkills = (node) => scannable(node) && scan(realOr(resolve(node.projectRoot, node.location)), node.name).length > 0;
168
+ var discoverSkills = (nodes, scurry, mounts = []) => {
169
+ const key = (name, path) => `${lc(name)}\0${norm(path)}`;
170
+ const linkedIn = /* @__PURE__ */ new Map();
171
+ for (const m of mounts) {
172
+ const k = key(m.name, realOr(m.target));
173
+ const dirs = linkedIn.get(k) ?? [];
174
+ if (!dirs.includes(m.dir.dir)) dirs.push(m.dir.dir);
175
+ linkedIn.set(k, dirs);
176
+ }
177
+ const scanned = /* @__PURE__ */ new Map();
178
+ const byPkg = /* @__PURE__ */ new Map();
179
+ for (const node of nodes) {
180
+ if (!scannable(node)) continue;
181
+ const found = scan(
182
+ realOr(node.resolvedLocation(scurry)),
183
+ node.name
184
+ );
185
+ scanned.set(
186
+ node.id,
187
+ found.map(({ skill, path }) => ({ skill, path }))
188
+ );
189
+ const key2 = packageKey(node.id);
190
+ const list = byPkg.get(key2) ?? [];
191
+ list.push({ node, found });
192
+ byPkg.set(key2, list);
193
+ }
194
+ const rows = [];
195
+ for (const list of byPkg.values()) {
196
+ const { node, found } = list.reduce(
197
+ (a, b) => compare(a.node, b.node) <= 0 ? a : b
198
+ );
199
+ for (const { skill, path, name, description } of found) {
200
+ const fm = sanitize(name);
201
+ rows.push([
202
+ {
203
+ name: node.name,
204
+ alias: aliasOf(node),
205
+ version: node.version,
206
+ id: node.id,
207
+ skill,
208
+ ...fm && lc(fm) !== lc(skill) && { frontmatterName: fm },
209
+ description: sanitize(description),
210
+ path,
211
+ linked: linkedIn.get(key(skill, path)) ?? []
212
+ },
213
+ rank(node)
214
+ ]);
215
+ }
216
+ }
217
+ const skills = rows.sort(
218
+ ([a, ra], [b, rb]) => lc(a.skill).localeCompare(lc(b.skill), "en") || ra - rb || a.id.localeCompare(b.id, "en")
219
+ ).map(([s]) => s);
220
+ return { skills, scanned };
221
+ };
222
+
223
+ // ../../src/graph/src/skills/gitignore.ts
224
+ import { lstatSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
225
+ import { join } from "node:path";
226
+ var GITIGNORE_BEGIN = "# >>> vlt agent skills (links into node_modules)";
227
+ var GITIGNORE_END = "# <<< vlt agent skills";
228
+ var sorted = (names) => [...names].sort((a, b) => a.localeCompare(b, "en")).map((n) => `/${n}`);
229
+ var update = (file, { add, remove }) => {
230
+ const st = lstatSync(file, { throwIfNoEntry: false });
231
+ if (st && !st.isFile()) return "refused";
232
+ const text = st ? readFileSync2(file, "utf8") : "";
233
+ const eol = text.includes("\r\n") ? "\r\n" : "\n";
234
+ const lines = text.split(eol);
235
+ const begin = lines.findIndex((l) => l.trim() === GITIGNORE_BEGIN);
236
+ const end = lines.findIndex(
237
+ (l, i) => begin !== -1 && i > begin && l.trim() === GITIGNORE_END
238
+ );
239
+ let out;
240
+ if (end === -1) {
241
+ if (!add.length) return "ok";
242
+ out = (text && !text.endsWith(eol) ? text + eol : text) + [GITIGNORE_BEGIN, ...sorted(add), GITIGNORE_END].join(eol) + eol;
243
+ } else {
244
+ const rm = new Set(sorted(remove));
245
+ const block = lines.slice(begin + 1, end).filter((l) => !rm.has(l.trim()));
246
+ const have = new Set(block.map((l) => l.trim()));
247
+ lines.splice(
248
+ begin + 1,
249
+ end - begin - 1,
250
+ ...block,
251
+ ...sorted(add).filter((l) => !have.has(l))
252
+ );
253
+ out = lines.join(eol);
254
+ }
255
+ if (out !== text) writeFileSync(file, out);
256
+ return "ok";
257
+ };
258
+ var editGitignore = (dir, edit) => {
259
+ try {
260
+ return update(join(dir, ".gitignore"), edit);
261
+ } catch {
262
+ return "refused";
263
+ }
264
+ };
265
+
266
+ // ../../src/graph/src/skills/mask.ts
267
+ var escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
268
+ var globRegExp = (pattern) => new RegExp(`^${pattern.split("*").map(escape).join(".*")}$`, "i");
269
+ var matches = (re, s) => re.test(s.skill) || !!s.frontmatterName && re.test(s.frontmatterName);
270
+ var maskSkills = (skills, parts) => {
271
+ const compiled = parts.map((p) => ({
272
+ keys: new Set([...p.ids].map(packageKey)),
273
+ patterns: p.patterns?.map((pattern) => ({
274
+ pattern,
275
+ re: globRegExp(pattern)
276
+ }))
277
+ }));
278
+ const picked = skills.filter(
279
+ (s) => compiled.some(
280
+ (p) => p.keys.has(packageKey(s.id)) && (!p.patterns || p.patterns.some(({ re }) => matches(re, s)))
281
+ )
282
+ );
283
+ const unmatched = [];
284
+ for (const p of compiled) {
285
+ if (!p.patterns) continue;
286
+ const own = skills.filter((s) => p.keys.has(packageKey(s.id)));
287
+ for (const { pattern, re } of p.patterns) {
288
+ if (own.some((s) => matches(re, s))) continue;
289
+ unmatched.push({
290
+ pattern,
291
+ ...p.keys.size > 0 && {
292
+ skills: [...new Set(own.map((s) => s.skill))].sort(
293
+ (a, b) => a.localeCompare(b, "en")
294
+ )
295
+ }
296
+ });
297
+ }
298
+ }
299
+ return { skills: picked, unmatched };
300
+ };
301
+
302
+ // ../../src/graph/src/skills/index.ts
303
+ var lc2 = (s) => s.toLowerCase();
304
+ var selectNodes = async (o) => {
305
+ const graph = o.graph ?? load({ ...o, loadManifests: true });
306
+ const { ids, parts, unscanned } = await filterNodesByQueryParts(
307
+ graph,
308
+ o.target ?? "*"
309
+ );
310
+ const nodes = [...graph.nodes.values()].filter((n) => ids.has(n.id));
311
+ return { graph, nodes, parts, unscanned };
312
+ };
313
+ var dirsOf = (o, create = false) => skillsDirs({
314
+ projectRoot: o.projectRoot,
315
+ configured: o.skillsDirs,
316
+ env: o.env,
317
+ create
318
+ });
319
+ var liveOwners = (mounts) => mounts.flatMap(
320
+ (m) => m.owner && existsSync(m.target) ? [m.owner] : []
321
+ );
322
+ var unshareSkills = async (graph, ids, scurry) => {
323
+ for (const id of new Set(ids)) {
324
+ const node = graph.nodes.get(id);
325
+ if (node?.inVltStore())
326
+ await unshare(node.resolvedLocation(scurry));
327
+ }
328
+ };
329
+ var label = (s) => {
330
+ const pkg = s.version ? `${s.name}@${s.version}` : s.name;
331
+ return s.alias ? `${s.alias} (${pkg})` : pkg;
332
+ };
333
+ var pick = (found, parts, unscanned) => {
334
+ const { skills: masked, unmatched } = maskSkills(found, parts);
335
+ const ok = (s) => !unscanned?.ids.has(s.id);
336
+ const picked = masked.filter(ok);
337
+ const names = new Set(picked.map((s) => lc2(s.skill)));
338
+ const dropped = masked.filter(
339
+ (s) => !ok(s) && !names.has(lc2(s.skill))
340
+ );
341
+ return { skills: found.filter(ok), picked, unmatched, dropped };
342
+ };
343
+ var report = (dropped, unscanned) => unscanned && dropped.length ? {
344
+ unscanned: dropped.map((s) => `${s.skill} (${label(s)})`),
345
+ unscannedReason: unscanned.reason
346
+ } : {};
347
+ var listSkills = async (o) => {
348
+ const { graph, nodes, parts, unscanned } = await selectNodes(o);
349
+ const { targets, scan: scan2, skipped } = dirsOf(o);
350
+ const { skills } = discoverSkills(nodes, o.scurry, readMounts(scan2));
351
+ const { picked, dropped } = pick(skills, parts, unscanned);
352
+ return {
353
+ project: graph.mainImporter.name,
354
+ graph,
355
+ skills: picked,
356
+ dirs: targets.map((d) => d.dir),
357
+ ...skipped.length ? { skipped } : null,
358
+ ...report(dropped, unscanned)
359
+ };
360
+ };
361
+ var linkSkills = async (o) => {
362
+ const { graph, nodes, parts, unscanned } = await selectNodes(o);
363
+ const { skills: found, scanned } = discoverSkills(nodes, o.scurry);
364
+ const { skills, picked, unmatched, dropped } = pick(
365
+ found,
366
+ parts,
367
+ unscanned
368
+ );
369
+ const inMask = new Set(picked);
370
+ const { targets, scan: scan2, skipped } = dirsOf(o, picked.length > 0);
371
+ const res = {
372
+ linked: [],
373
+ unchanged: [],
374
+ removed: [],
375
+ conflicts: [],
376
+ dirs: targets.map((d) => d.dir)
377
+ };
378
+ const mounts = readMounts(scan2);
379
+ const byName = new Map(
380
+ mounts.map((m) => [`${m.dir.dir}\0${lc2(m.name)}`, m])
381
+ );
382
+ const stale = (m) => !m.owner || !graph.nodes.has(m.owner) || !existsSync(m.target) || scanned.get(m.owner)?.some(
383
+ (f) => lc2(f.skill) === lc2(m.name) && samePath(f.path, m.target)
384
+ ) === false;
385
+ const groups = /* @__PURE__ */ new Map();
386
+ for (const s of skills) {
387
+ const k = lc2(s.skill);
388
+ groups.set(k, [...groups.get(k) ?? [], s]);
389
+ }
390
+ const at = (dir, k, group) => {
391
+ const m = byName.get(`${dir.dir}\0${k}`);
392
+ const key = m?.owner && packageKey(m.owner);
393
+ return { m, own: group.find((s) => packageKey(s.id) === key) };
394
+ };
395
+ const cands = (group) => group.filter((s) => inMask.has(s));
396
+ const first = new Map(
397
+ [...groups].map(([k, group]) => {
398
+ const c = cands(group);
399
+ return [
400
+ k,
401
+ targets.map((d) => at(d, k, c).own).find((s) => !!s) ?? c[0]
402
+ ];
403
+ })
404
+ );
405
+ const isTarget = new Set(targets);
406
+ const picks = [];
407
+ for (const dir of scan2) {
408
+ for (const [k, group] of groups) {
409
+ const { m, own } = at(dir, k, group);
410
+ if (isTarget.has(dir)) {
411
+ const winner = o.apply ? first.get(k) : own ?? (m && !stale(m) ? void 0 : first.get(k));
412
+ picks.push({
413
+ dir,
414
+ winner,
415
+ losers: cands(group).filter((s) => s !== winner),
416
+ m
417
+ });
418
+ } else if (own && !o.apply) {
419
+ picks.push({ dir, winner: own, losers: [], m });
420
+ }
421
+ }
422
+ }
423
+ await unshareSkills(
424
+ graph,
425
+ [
426
+ ...picks.flatMap(({ winner }) => winner ? [winner.id] : []),
427
+ ...liveOwners(mounts)
428
+ ],
429
+ o.scurry
430
+ );
431
+ const gone = [];
432
+ const foreign = [];
433
+ const kept = /* @__PURE__ */ new Set();
434
+ const where = /* @__PURE__ */ new Map();
435
+ for (const { dir, winner, losers, m } of picks) {
436
+ if (winner) {
437
+ if (m && m.name !== winner.skill) {
438
+ unmountSkill(m);
439
+ gone.push(m);
440
+ }
441
+ const mount = `${dir.dir}/${winner.skill}`;
442
+ const r = mountSkill(winner, dir);
443
+ if (r === "conflict") {
444
+ res.conflicts.push(mount);
445
+ foreign.push({ dir, name: winner.skill });
446
+ } else {
447
+ const k = `${winner.id}\0${winner.skill}`;
448
+ const linked = where.get(k) ?? [];
449
+ linked.push(dir.dir);
450
+ where.set(k, linked);
451
+ res[r].push({ ...winner, linked, dir: dir.dir, mount });
452
+ kept.add(mount);
453
+ }
454
+ }
455
+ for (const s of losers)
456
+ res.conflicts.push(`${dir.dir}/${s.skill} (${label(s)})`);
457
+ }
458
+ const after = readMounts(scan2);
459
+ const present = [];
460
+ for (const m of after) {
461
+ if (o.apply ? kept.has(m.mount) : !stale(m)) {
462
+ present.push(m);
463
+ continue;
464
+ }
465
+ unmountSkill(m);
466
+ gone.push(m);
467
+ res.removed.push(m.mount);
468
+ }
469
+ const gitignore = [];
470
+ for (const dir of scan2) {
471
+ const add = present.filter((m) => m.dir === dir).map((m) => m.name);
472
+ const remove = [...gone, ...foreign].filter((m) => m.dir === dir && !add.includes(m.name)).map((m) => m.name);
473
+ if ((add.length || remove.length) && editGitignore(dir.real, { add, remove }) === "refused") {
474
+ gitignore.push(`${dir.dir}/.gitignore`);
475
+ }
476
+ }
477
+ if (skipped.length) res.skipped = skipped;
478
+ if (gitignore.length) res.gitignore = gitignore;
479
+ if (unmatched.length) res.unmatched = unmatched;
480
+ const left = dropped.filter(
481
+ (s) => !targets.every(
482
+ (d) => present.some(
483
+ (m) => m.dir === d && m.owner === s.id && lc2(m.name) === lc2(s.skill)
484
+ )
485
+ )
486
+ );
487
+ return Object.assign(res, report(left, unscanned));
488
+ };
489
+ export {
490
+ discoverSkills,
491
+ linkSkills,
492
+ listSkills,
493
+ readFrontmatter,
494
+ shipsSkills
495
+ };
@@ -11,42 +11,47 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  loadCommand
14
- } from "./chunk-4JAZZRKR.js";
14
+ } from "./chunk-T2VBCUF5.js";
15
15
  import {
16
16
  flushAndExit,
17
17
  indent,
18
18
  outputCommand,
19
19
  stderr,
20
20
  stdout
21
- } from "./chunk-XDSZO74H.js";
21
+ } from "./chunk-WHWPAYZY.js";
22
22
  import {
23
23
  loadPackageJson
24
- } from "./chunk-KMOOTBHM.js";
25
- import "./chunk-G2YT2GWF.js";
24
+ } from "./chunk-X6JKMIOU.js";
26
25
  import {
27
- asRootError
28
- } from "./chunk-IHXJVKAE.js";
26
+ asRootError,
27
+ findRootError
28
+ } from "./chunk-4TSHLSRK.js";
29
29
  import {
30
30
  Config
31
- } from "./chunk-43HNQWPQ.js";
32
- import "./chunk-DL3H4EMY.js";
31
+ } from "./chunk-XCQCYB6G.js";
32
+ import "./chunk-VR7NRWAD.js";
33
33
  import "./chunk-SRWDPPLX.js";
34
- import "./chunk-WGDTG44V.js";
35
- import "./chunk-A2TSRXZD.js";
36
- import "./chunk-CB65DPZ2.js";
34
+ import "./chunk-IFEZ6BFV.js";
35
+ import {
36
+ setVltJsonOnly
37
+ } from "./chunk-C6ZVVEFV.js";
37
38
  import "./chunk-4KCU2KZL.js";
38
- import "./chunk-SV4WK3KX.js";
39
- import "./chunk-GZ5MYMBT.js";
39
+ import "./chunk-WGDTG44V.js";
40
+ import "./chunk-UZ6ICZE3.js";
40
41
  import {
41
42
  getSortedCliOptions,
42
43
  getSortedKeys
43
- } from "./chunk-SE2FSMBR.js";
44
+ } from "./chunk-CMLDLZZ3.js";
45
+ import "./chunk-F7NPYSI2.js";
46
+ import "./chunk-LUVDMEW4.js";
44
47
  import "./chunk-HTOTG4TS.js";
45
- import "./chunk-6D54UN4T.js";
46
- import "./chunk-U7TEQCBN.js";
48
+ import "./chunk-5KW6AOTT.js";
49
+ import "./chunk-SUU2WETN.js";
50
+ import "./chunk-B6RIGNEO.js";
47
51
  import "./chunk-XNLSTHDK.js";
52
+ import "./chunk-6IF3RJND.js";
48
53
  import "./chunk-Y5PA7DVK.js";
49
- import "./chunk-IBGFQR23.js";
54
+ import "./chunk-6LZM3I4Q.js";
50
55
  import "./chunk-WZWDS3W4.js";
51
56
  import "./chunk-PZLD7RTK.js";
52
57
 
@@ -60,11 +65,12 @@ var loadVlt = async (cwd, argv) => {
60
65
  try {
61
66
  return await Config.load(cwd, argv);
62
67
  } catch (e) {
63
- const err = asRootError(e, { code: "JACKSPEAK" });
68
+ const code = findRootError(e, { code: "ECONFIG" }) ? "ECONFIG" : "JACKSPEAK";
69
+ const err = asRootError(e, { code });
64
70
  const { found, path, wanted, name } = err.cause;
65
71
  const isConfigFile = typeof path === "string";
66
- const msg = isConfigFile ? `Problem in Config File ${path}` : "Invalid Option Flag";
67
- const validOptions = wanted ? void 0 : isConfigFile ? getSortedKeys() : getSortedCliOptions();
72
+ const msg = isConfigFile ? `Problem in Config File ${path}` : code === "ECONFIG" ? "Config Error" : "Invalid Option Flag";
73
+ const validOptions = wanted || code === "ECONFIG" ? void 0 : isConfigFile ? getSortedKeys() : getSortedCliOptions();
68
74
  stderr(msg);
69
75
  stderr(err.message);
70
76
  if (name) stderr(indent(`Field: ${format(name)}`));
@@ -80,11 +86,13 @@ var loadVlt = async (cwd, argv) => {
80
86
  stderr(indent("Valid Options:"));
81
87
  stderr(indent(validOptions.join("\n"), 4));
82
88
  }
83
- stderr(
84
- indent(
85
- `Run 'vlt help' for more information about available options.`
86
- )
87
- );
89
+ if (code !== "ECONFIG") {
90
+ stderr(
91
+ indent(
92
+ `Run 'vlt help' for more information about available options.`
93
+ )
94
+ );
95
+ }
88
96
  return flushAndExit(process.exitCode || 1);
89
97
  }
90
98
  };
@@ -95,6 +103,7 @@ var run = async () => {
95
103
  if (vlt.get("version")) {
96
104
  return stdout(version);
97
105
  }
106
+ setVltJsonOnly(vlt.command === "ci");
98
107
  const { monorepo } = vlt.options;
99
108
  if (vlt.get("workspace") === void 0) {
100
109
  const ws = monorepo?.get(cwd);
@@ -104,8 +113,9 @@ var run = async () => {
104
113
  }
105
114
  }
106
115
  if (vlt.command !== "init" && (vlt.get("workspace") || vlt.get("workspace-group")) && ![...monorepo?.values() ?? []].length) {
116
+ const where = vlt.command === "ci" ? "the vlt.json config (vlt ci ignores package.json and pnpm-workspace.yaml)" : 'the vlt.json config, the "workspaces" field of the root package.json, or the "packages" list of pnpm-workspace.yaml';
107
117
  stderr(
108
- `Error: No matching workspaces found. Make sure the vlt.json config, or the "workspaces" field of the root package.json, contains the correct workspaces.`
118
+ `Error: No matching workspaces found. Make sure ${where} contains the correct workspaces.`
109
119
  );
110
120
  if (vlt.get("workspace")) {
111
121
  stderr(indent(`Workspace: ${format(vlt.get("workspace"))}`));
@@ -120,7 +130,7 @@ var run = async () => {
120
130
  return flushAndExit(process.exitCode || 1);
121
131
  }
122
132
  if (vlt.command === "registry") {
123
- const { dispatchRegistry } = await import("./registry-MQJJCWJY.js");
133
+ const { dispatchRegistry } = await import("./registry-6HKQYSZX.js");
124
134
  await dispatchRegistry(vlt);
125
135
  }
126
136
  const command = await loadCommand(vlt.command);
@@ -28,22 +28,23 @@ import {
28
28
  runtimeTokens,
29
29
  setRuntimeToken,
30
30
  setToken
31
- } from "./chunk-5KOLUYXH.js";
32
- import "./chunk-APMYKJI2.js";
31
+ } from "./chunk-35EG6T3J.js";
32
+ import "./chunk-QNHBAGXQ.js";
33
+ import {
34
+ userAgent
35
+ } from "./chunk-G3FZ2ZJK.js";
33
36
  import {
34
37
  assertOk,
35
38
  registryErrorMessage,
36
39
  requestError,
37
40
  storeRoot
38
- } from "./chunk-6D54UN4T.js";
39
- import {
40
- userAgent
41
- } from "./chunk-6BQKR2FM.js";
42
- import "./chunk-U7TEQCBN.js";
41
+ } from "./chunk-5KW6AOTT.js";
42
+ import "./chunk-SUU2WETN.js";
43
+ import "./chunk-B6RIGNEO.js";
43
44
  import "./chunk-XNLSTHDK.js";
44
45
  import "./chunk-PDWPFR5T.js";
45
46
  import "./chunk-Y5PA7DVK.js";
46
- import "./chunk-IBGFQR23.js";
47
+ import "./chunk-6LZM3I4Q.js";
47
48
  import "./chunk-WZWDS3W4.js";
48
49
  import "./chunk-PZLD7RTK.js";
49
50
  export {