zion 4.1.1 → 4.2.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.
- package/dist/cli.js +312 -281
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
|
|
6
6
|
// src/cli.tsx
|
|
7
7
|
import os3 from "os";
|
|
8
|
-
import
|
|
8
|
+
import path13 from "path";
|
|
9
9
|
|
|
10
10
|
// package.json
|
|
11
|
-
var version = "4.
|
|
11
|
+
var version = "4.2.0";
|
|
12
12
|
|
|
13
13
|
// src/lib/theme.ts
|
|
14
14
|
import { Chalk, supportsColor, supportsColorStderr } from "chalk";
|
|
@@ -23,8 +23,8 @@ var symbols = {
|
|
|
23
23
|
start: "\u250C",
|
|
24
24
|
bar: "\u2502",
|
|
25
25
|
end: "\u2514",
|
|
26
|
-
active: "\
|
|
27
|
-
done: "\
|
|
26
|
+
active: "\u25CF",
|
|
27
|
+
done: "\u25CF",
|
|
28
28
|
warning: "\u25B2",
|
|
29
29
|
error: "\u25A0",
|
|
30
30
|
radioOn: "\u25CF",
|
|
@@ -63,6 +63,9 @@ function paintFor(stream, { color, env }) {
|
|
|
63
63
|
function toneColor(paint) {
|
|
64
64
|
return { success: paint.success, warning: paint.warning, error: paint.error, info: paint.accent, muted: paint.muted };
|
|
65
65
|
}
|
|
66
|
+
function stepColor(paint, tone) {
|
|
67
|
+
return tone === "warning" || tone === "error" ? toneColor(paint)[tone] : paint.muted;
|
|
68
|
+
}
|
|
66
69
|
var stepSymbol = {
|
|
67
70
|
success: symbols.done,
|
|
68
71
|
warning: symbols.warning,
|
|
@@ -77,11 +80,12 @@ var finalSymbol = {
|
|
|
77
80
|
info: symbols.radioOn,
|
|
78
81
|
muted: symbols.error
|
|
79
82
|
};
|
|
83
|
+
var MARGIN = " ";
|
|
80
84
|
function bar(paint) {
|
|
81
85
|
return paint.muted(symbols.bar);
|
|
82
86
|
}
|
|
83
87
|
function join(lines) {
|
|
84
|
-
return lines.filter((line) => typeof line === "string").join("\n");
|
|
88
|
+
return lines.filter((line) => typeof line === "string").map((line) => line ? `${MARGIN}${line}` : line).join("\n");
|
|
85
89
|
}
|
|
86
90
|
function detail(paint, line, tone) {
|
|
87
91
|
return tone === "warning" || tone === "error" ? toneColor(paint)[tone](line) : paint.dim(line);
|
|
@@ -96,7 +100,7 @@ function formatIntro(paint, title, subtitle) {
|
|
|
96
100
|
function formatStep(paint, { title, lines = [], tone = "success" }) {
|
|
97
101
|
return join([
|
|
98
102
|
bar(paint),
|
|
99
|
-
`${
|
|
103
|
+
`${stepColor(paint, tone)(stepSymbol[tone])} ${title}`,
|
|
100
104
|
...lines.map((line) => `${bar(paint)} ${detail(paint, line, tone)}`)
|
|
101
105
|
]);
|
|
102
106
|
}
|
|
@@ -481,13 +485,13 @@ var BORDER = "#4d4a44";
|
|
|
481
485
|
var GRAIN = 14;
|
|
482
486
|
var WIDTH = 52;
|
|
483
487
|
var HEIGHT = 13;
|
|
484
|
-
var
|
|
488
|
+
var MARGIN2 = " ";
|
|
485
489
|
function renderCard(paint, columns = Infinity) {
|
|
486
490
|
const email3 = { text: "contact@zzzzion.com", color: SOFT, link: "mailto:contact@zzzzion.com" };
|
|
487
491
|
const name = { text: spaced("ATIB JAWAD ZION"), color: INK };
|
|
488
|
-
if (columns < WIDTH +
|
|
492
|
+
if (columns < WIDTH + MARGIN2.length) {
|
|
489
493
|
return `
|
|
490
|
-
${[name, null, email3].map((segment) => segment ? `${
|
|
494
|
+
${[name, null, email3].map((segment) => segment ? `${MARGIN2}${draw(paint, segment)}` : "").join("\n")}
|
|
491
495
|
|
|
492
496
|
`;
|
|
493
497
|
}
|
|
@@ -509,7 +513,7 @@ ${[
|
|
|
509
513
|
edge(`\u250C${"\u2500".repeat(inner)}\u2510`),
|
|
510
514
|
...rows.map((row) => `${edge("\u2502")}${row}${edge("\u2502")}`),
|
|
511
515
|
edge(`\u2514${"\u2500".repeat(inner)}\u2518`)
|
|
512
|
-
].map((line) => `${
|
|
516
|
+
].map((line) => `${MARGIN2}${line}`).join("\n")}
|
|
513
517
|
|
|
514
518
|
`;
|
|
515
519
|
}
|
|
@@ -529,7 +533,7 @@ function stock(paint, inner, lines) {
|
|
|
529
533
|
const beside = segment && x >= start - 1 && x <= start + segment.text.length;
|
|
530
534
|
row += beside ? " " : fiber(paint, x, y);
|
|
531
535
|
}
|
|
532
|
-
return `${
|
|
536
|
+
return `${MARGIN2}${ground(row)}`;
|
|
533
537
|
});
|
|
534
538
|
}
|
|
535
539
|
var FIBERS = ["\xB7", "\u02D9", ".", ",", "'", "`", "\xB8", "\u02DB"];
|
|
@@ -2286,10 +2290,10 @@ function mergeDefs(...defs) {
|
|
|
2286
2290
|
function cloneDef(schema) {
|
|
2287
2291
|
return mergeDefs(schema._zod.def);
|
|
2288
2292
|
}
|
|
2289
|
-
function getElementAtPath(obj,
|
|
2290
|
-
if (!
|
|
2293
|
+
function getElementAtPath(obj, path14) {
|
|
2294
|
+
if (!path14)
|
|
2291
2295
|
return obj;
|
|
2292
|
-
return
|
|
2296
|
+
return path14.reduce((acc, key) => acc?.[key], obj);
|
|
2293
2297
|
}
|
|
2294
2298
|
function promiseAllObject(promisesObj) {
|
|
2295
2299
|
const keys = Object.keys(promisesObj);
|
|
@@ -2629,11 +2633,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
2629
2633
|
}
|
|
2630
2634
|
return false;
|
|
2631
2635
|
}
|
|
2632
|
-
function prefixIssues(
|
|
2636
|
+
function prefixIssues(path14, issues) {
|
|
2633
2637
|
return issues.map((iss) => {
|
|
2634
2638
|
var _a3;
|
|
2635
2639
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
2636
|
-
iss.path.unshift(
|
|
2640
|
+
iss.path.unshift(path14);
|
|
2637
2641
|
return iss;
|
|
2638
2642
|
});
|
|
2639
2643
|
}
|
|
@@ -3095,16 +3099,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
|
3095
3099
|
}
|
|
3096
3100
|
function formatError2(error62, mapper = (issue2) => issue2.message) {
|
|
3097
3101
|
const fieldErrors = { _errors: [] };
|
|
3098
|
-
const processError = (error63,
|
|
3102
|
+
const processError = (error63, path14 = []) => {
|
|
3099
3103
|
for (const issue2 of error63.issues) {
|
|
3100
3104
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
3101
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
3105
|
+
issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
|
|
3102
3106
|
} else if (issue2.code === "invalid_key") {
|
|
3103
|
-
processError({ issues: issue2.issues }, [...
|
|
3107
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
3104
3108
|
} else if (issue2.code === "invalid_element") {
|
|
3105
|
-
processError({ issues: issue2.issues }, [...
|
|
3109
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
3106
3110
|
} else {
|
|
3107
|
-
const fullpath = [...
|
|
3111
|
+
const fullpath = [...path14, ...issue2.path];
|
|
3108
3112
|
if (fullpath.length === 0) {
|
|
3109
3113
|
fieldErrors._errors.push(mapper(issue2));
|
|
3110
3114
|
} else {
|
|
@@ -3143,17 +3147,17 @@ function formatError2(error62, mapper = (issue2) => issue2.message) {
|
|
|
3143
3147
|
}
|
|
3144
3148
|
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
3145
3149
|
const result = { errors: [] };
|
|
3146
|
-
const processError = (error63,
|
|
3150
|
+
const processError = (error63, path14 = []) => {
|
|
3147
3151
|
var _a3;
|
|
3148
3152
|
for (const issue2 of error63.issues) {
|
|
3149
3153
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
3150
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
3154
|
+
issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
|
|
3151
3155
|
} else if (issue2.code === "invalid_key") {
|
|
3152
|
-
processError({ issues: issue2.issues }, [...
|
|
3156
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
3153
3157
|
} else if (issue2.code === "invalid_element") {
|
|
3154
|
-
processError({ issues: issue2.issues }, [...
|
|
3158
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
3155
3159
|
} else {
|
|
3156
|
-
const fullpath = [...
|
|
3160
|
+
const fullpath = [...path14, ...issue2.path];
|
|
3157
3161
|
if (fullpath.length === 0) {
|
|
3158
3162
|
result.errors.push(mapper(issue2));
|
|
3159
3163
|
continue;
|
|
@@ -3192,8 +3196,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
|
3192
3196
|
}
|
|
3193
3197
|
function toDotPath(_path) {
|
|
3194
3198
|
const segs = [];
|
|
3195
|
-
const
|
|
3196
|
-
for (const seg of
|
|
3199
|
+
const path14 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
3200
|
+
for (const seg of path14) {
|
|
3197
3201
|
if (typeof seg === "number")
|
|
3198
3202
|
segs.push(`[${seg}]`);
|
|
3199
3203
|
else if (typeof seg === "symbol")
|
|
@@ -20331,13 +20335,13 @@ function resolveRef(ref, ctx) {
|
|
|
20331
20335
|
if (!ref.startsWith("#")) {
|
|
20332
20336
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
20333
20337
|
}
|
|
20334
|
-
const
|
|
20335
|
-
if (
|
|
20338
|
+
const path14 = ref.slice(1).split("/").filter(Boolean);
|
|
20339
|
+
if (path14.length === 0) {
|
|
20336
20340
|
return ctx.rootSchema;
|
|
20337
20341
|
}
|
|
20338
20342
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
20339
|
-
if (
|
|
20340
|
-
const key =
|
|
20343
|
+
if (path14[0] === defsKey) {
|
|
20344
|
+
const key = path14[1] === void 0 ? void 0 : decodeJSONPointerSegment(path14[1]);
|
|
20341
20345
|
if (!key || !ctx.defs[key]) {
|
|
20342
20346
|
throw new Error(`Reference not found: ${ref}`);
|
|
20343
20347
|
}
|
|
@@ -21461,6 +21465,25 @@ import { createHash } from "crypto";
|
|
|
21461
21465
|
function gitBlobSha(content) {
|
|
21462
21466
|
return createHash("sha1").update(`blob ${content.length}\0`).update(content).digest("hex");
|
|
21463
21467
|
}
|
|
21468
|
+
var DIRECTORY_MODE = "40000";
|
|
21469
|
+
function gitTreeSha(entries) {
|
|
21470
|
+
const key = (entry) => Buffer.from(entry.mode === DIRECTORY_MODE ? `${entry.name}/` : entry.name);
|
|
21471
|
+
const body = Buffer.concat(
|
|
21472
|
+
[...entries].sort((a, b) => Buffer.compare(key(a), key(b))).map((entry) => Buffer.concat([Buffer.from(`${entry.mode} ${entry.name}\0`), Buffer.from(entry.sha, "hex")]))
|
|
21473
|
+
);
|
|
21474
|
+
return createHash("sha1").update(`tree ${body.length}\0`).update(body).digest("hex");
|
|
21475
|
+
}
|
|
21476
|
+
function gitTreeShaOfFiles(files) {
|
|
21477
|
+
const here = [];
|
|
21478
|
+
const nested = /* @__PURE__ */ new Map();
|
|
21479
|
+
for (const file2 of files) {
|
|
21480
|
+
const [first, ...rest] = file2.path.split("/");
|
|
21481
|
+
if (rest.length === 0) here.push({ name: first, mode: file2.executable ? "100755" : "100644", sha: file2.sha });
|
|
21482
|
+
else nested.set(first, [...nested.get(first) ?? [], { ...file2, path: rest.join("/") }]);
|
|
21483
|
+
}
|
|
21484
|
+
for (const [name, children] of nested) here.push({ name, mode: DIRECTORY_MODE, sha: gitTreeShaOfFiles(children) });
|
|
21485
|
+
return gitTreeSha(here);
|
|
21486
|
+
}
|
|
21464
21487
|
|
|
21465
21488
|
// src/commands/skills/SkillFiles.ts
|
|
21466
21489
|
var NOISE = /* @__PURE__ */ new Set([".DS_Store"]);
|
|
@@ -21468,62 +21491,45 @@ var NodeSkillFiles = class {
|
|
|
21468
21491
|
async exists(dir) {
|
|
21469
21492
|
return (await fs2.stat(dir).catch(() => null))?.isDirectory() ?? false;
|
|
21470
21493
|
}
|
|
21471
|
-
async
|
|
21472
|
-
if (!await fs2.lstat(dir).catch(() => null)) return
|
|
21473
|
-
|
|
21474
|
-
await
|
|
21475
|
-
actual.set(relative, isFile ? gitBlobSha(await fs2.readFile(absolute)) : null);
|
|
21476
|
-
}).catch(() => {
|
|
21477
|
-
});
|
|
21478
|
-
return {
|
|
21479
|
-
exists: true,
|
|
21480
|
-
changed: Object.keys(expected).filter((file2) => actual.has(file2) && actual.get(file2) !== expected[file2]),
|
|
21481
|
-
missing: Object.keys(expected).filter((file2) => !actual.has(file2)),
|
|
21482
|
-
extra: [...actual.keys()].filter((file2) => !(file2 in expected))
|
|
21483
|
-
};
|
|
21494
|
+
async treeSha(dir) {
|
|
21495
|
+
if (!await fs2.lstat(dir).catch(() => null)) return null;
|
|
21496
|
+
if (!await this.exists(dir)) return UNREADABLE;
|
|
21497
|
+
return await hashDirectory(dir).catch(() => UNREADABLE) ?? gitTreeSha([]);
|
|
21484
21498
|
}
|
|
21485
|
-
async write(dir, files
|
|
21486
|
-
|
|
21487
|
-
|
|
21499
|
+
async write(dir, files) {
|
|
21500
|
+
const targets = files.map((file2) => inside(dir, file2.path));
|
|
21501
|
+
await fs2.rm(dir, { recursive: true, force: true });
|
|
21502
|
+
for (const [i, file2] of files.entries()) {
|
|
21503
|
+
const target = targets[i];
|
|
21488
21504
|
await fs2.mkdir(path3.dirname(target), { recursive: true });
|
|
21489
|
-
await fs2.rm(target, { force: true });
|
|
21490
21505
|
await fs2.writeFile(target, file2.content, { mode: file2.executable ? 493 : 420 });
|
|
21491
21506
|
}
|
|
21492
|
-
await this.delete(dir, stale);
|
|
21493
|
-
}
|
|
21494
|
-
async remove(dir, files) {
|
|
21495
|
-
await this.delete(dir, files);
|
|
21496
|
-
const left = [];
|
|
21497
|
-
await walk(dir, async (relative) => {
|
|
21498
|
-
left.push(relative);
|
|
21499
|
-
}).catch(() => {
|
|
21500
|
-
});
|
|
21501
|
-
if (left.length === 0) await fs2.rm(dir, { recursive: true, force: true });
|
|
21502
|
-
return left;
|
|
21503
21507
|
}
|
|
21504
|
-
async
|
|
21505
|
-
|
|
21506
|
-
const target = inside(dir, file2);
|
|
21507
|
-
await fs2.rm(target, { force: true });
|
|
21508
|
-
await pruneEmpty(path3.dirname(target), dir);
|
|
21509
|
-
}
|
|
21508
|
+
async remove(dir) {
|
|
21509
|
+
await fs2.rm(dir, { recursive: true, force: true });
|
|
21510
21510
|
}
|
|
21511
21511
|
};
|
|
21512
|
-
|
|
21512
|
+
var UNREADABLE = "unreadable";
|
|
21513
|
+
async function hashDirectory(dir) {
|
|
21514
|
+
const entries = [];
|
|
21513
21515
|
for (const entry of await fs2.readdir(dir, { withFileTypes: true })) {
|
|
21514
21516
|
if (NOISE.has(entry.name)) continue;
|
|
21515
21517
|
const absolute = path3.join(dir, entry.name);
|
|
21516
|
-
|
|
21517
|
-
|
|
21518
|
-
|
|
21519
|
-
|
|
21520
|
-
}
|
|
21521
|
-
|
|
21522
|
-
|
|
21523
|
-
|
|
21524
|
-
|
|
21525
|
-
|
|
21518
|
+
if (entry.isDirectory()) {
|
|
21519
|
+
const sha = await hashDirectory(absolute);
|
|
21520
|
+
if (sha) entries.push({ name: entry.name, mode: DIRECTORY_MODE, sha });
|
|
21521
|
+
} else if (entry.isSymbolicLink()) {
|
|
21522
|
+
entries.push({ name: entry.name, mode: "120000", sha: gitBlobSha(Buffer.from(await fs2.readlink(absolute))) });
|
|
21523
|
+
} else if (entry.isFile()) {
|
|
21524
|
+
const executable = ((await fs2.stat(absolute)).mode & 73) !== 0;
|
|
21525
|
+
entries.push({
|
|
21526
|
+
name: entry.name,
|
|
21527
|
+
mode: executable ? "100755" : "100644",
|
|
21528
|
+
sha: gitBlobSha(await fs2.readFile(absolute))
|
|
21529
|
+
});
|
|
21530
|
+
}
|
|
21526
21531
|
}
|
|
21532
|
+
return entries.length > 0 ? gitTreeSha(entries) : null;
|
|
21527
21533
|
}
|
|
21528
21534
|
function inside(dir, relative) {
|
|
21529
21535
|
const target = path3.resolve(dir, relative);
|
|
@@ -21535,10 +21541,11 @@ function inside(dir, relative) {
|
|
|
21535
21541
|
|
|
21536
21542
|
// src/commands/skills/SkillsApi.ts
|
|
21537
21543
|
var SKILL_NAME = /^\w[\w.-]*$/;
|
|
21538
|
-
var SkillList = external_exports.object({
|
|
21544
|
+
var SkillList = external_exports.object({
|
|
21545
|
+
skills: external_exports.array(external_exports.object({ name: external_exports.string().regex(SKILL_NAME), commit: external_exports.string().nullable().optional() }))
|
|
21546
|
+
});
|
|
21539
21547
|
var SkillBody = external_exports.object({
|
|
21540
21548
|
commit: external_exports.string(),
|
|
21541
|
-
updatedAt: external_exports.string(),
|
|
21542
21549
|
files: external_exports.array(external_exports.object({ path: external_exports.string(), sha: external_exports.string(), executable: external_exports.boolean(), content: external_exports.string() }))
|
|
21543
21550
|
});
|
|
21544
21551
|
var SkillNotFoundError = class extends CliError {
|
|
@@ -21560,10 +21567,18 @@ var HttpSkillsApi = class {
|
|
|
21560
21567
|
return this.base.host;
|
|
21561
21568
|
}
|
|
21562
21569
|
async list({ include = [], signal } = {}) {
|
|
21570
|
+
return (await this.listWithCommits(include, signal)).map((skill) => skill.name);
|
|
21571
|
+
}
|
|
21572
|
+
async latestCommits(names, signal) {
|
|
21573
|
+
const wanted = new Set(names);
|
|
21574
|
+
const skills = await this.listWithCommits(names, signal);
|
|
21575
|
+
return new Map(skills.filter((skill) => wanted.has(skill.name)).map((skill) => [skill.name, skill.commit ?? null]));
|
|
21576
|
+
}
|
|
21577
|
+
async listWithCommits(include, signal) {
|
|
21563
21578
|
const url2 = new URL(this.base);
|
|
21564
21579
|
if (include.length > 0) url2.searchParams.set("include", include.join(","));
|
|
21565
21580
|
const { skills } = await getJson(this.fetchImpl, { url: url2, schema: SkillList, failure: "send the skills", signal });
|
|
21566
|
-
return skills
|
|
21581
|
+
return skills;
|
|
21567
21582
|
}
|
|
21568
21583
|
async get(name, signal) {
|
|
21569
21584
|
if (!SKILL_NAME.test(name)) throw new SkillNotFoundError(name);
|
|
@@ -21575,73 +21590,54 @@ var HttpSkillsApi = class {
|
|
|
21575
21590
|
if (error62 instanceof HttpStatusError && error62.status === 404) throw new SkillNotFoundError(name);
|
|
21576
21591
|
throw error62;
|
|
21577
21592
|
}
|
|
21578
|
-
|
|
21579
|
-
|
|
21580
|
-
|
|
21581
|
-
|
|
21582
|
-
|
|
21583
|
-
|
|
21584
|
-
|
|
21585
|
-
|
|
21586
|
-
}
|
|
21587
|
-
return { path: path13, sha, executable, content: bytes };
|
|
21588
|
-
})
|
|
21589
|
-
};
|
|
21593
|
+
const files = body.files.map(({ path: path14, sha, executable, content }) => {
|
|
21594
|
+
const bytes = Buffer.from(content, "base64");
|
|
21595
|
+
if (gitBlobSha(bytes) !== sha) {
|
|
21596
|
+
throw new CliError(`${this.host} sent a damaged copy of ${name}/${path14}`, "try again in a moment");
|
|
21597
|
+
}
|
|
21598
|
+
return { path: path14, sha, executable, content: bytes };
|
|
21599
|
+
});
|
|
21600
|
+
return { name, commit: body.commit, tree: gitTreeShaOfFiles(files), files };
|
|
21590
21601
|
}
|
|
21591
21602
|
};
|
|
21592
21603
|
|
|
21604
|
+
// src/commands/skills/SkillsCommand.ts
|
|
21605
|
+
import path9 from "path";
|
|
21606
|
+
|
|
21593
21607
|
// src/commands/skills/InstallFlow.ts
|
|
21594
21608
|
import path6 from "path";
|
|
21595
21609
|
|
|
21596
21610
|
// src/commands/skills/chooseTargets.ts
|
|
21597
|
-
import
|
|
21598
|
-
async function chooseTargets(ui, { targets, files }, given, lock) {
|
|
21599
|
-
if (given.length > 0) {
|
|
21600
|
-
const chosen = targets.filter((target) => given.includes(target.id));
|
|
21601
|
-
ui.step({ title: "Install into", lines: [chosen.map((target) => tildify(target.dir)).join(", ")] });
|
|
21602
|
-
return chosen;
|
|
21603
|
-
}
|
|
21604
|
-
const used = new Set(Object.values(lock.skills).flatMap((skill) => skill.paths.map((dir) => path4.dirname(dir))));
|
|
21605
|
-
let suggested = targets.filter((target) => used.has(target.dir));
|
|
21606
|
-
if (suggested.length === 0) {
|
|
21607
|
-
const present = await Promise.all(targets.map((target) => files.exists(target.home)));
|
|
21608
|
-
suggested = targets.filter((_, i) => present[i]);
|
|
21609
|
-
}
|
|
21610
|
-
return ui.multiselect({
|
|
21611
|
-
message: "Install into",
|
|
21612
|
-
options: targets.map((target) => ({ value: target, label: tildify(target.dir), hint: target.hint })),
|
|
21613
|
-
initialValues: suggested,
|
|
21614
|
-
nonInteractiveHint: `pass --target (${targets.map((target) => target.id).join(", ")}), e.g. -t ${targets[0].id}`
|
|
21615
|
-
});
|
|
21616
|
-
}
|
|
21611
|
+
import path5 from "path";
|
|
21617
21612
|
|
|
21618
21613
|
// src/commands/skills/copies.ts
|
|
21619
|
-
import
|
|
21620
|
-
|
|
21621
|
-
|
|
21622
|
-
|
|
21623
|
-
|
|
21624
|
-
|
|
21625
|
-
|
|
21626
|
-
|
|
21627
|
-
|
|
21628
|
-
|
|
21629
|
-
|
|
21630
|
-
|
|
21631
|
-
skill
|
|
21632
|
-
|
|
21633
|
-
|
|
21634
|
-
|
|
21635
|
-
|
|
21636
|
-
|
|
21637
|
-
|
|
21614
|
+
import path4 from "path";
|
|
21615
|
+
var EDITED = "edited since zion installed it";
|
|
21616
|
+
async function installedDirs({ files, targets }, name) {
|
|
21617
|
+
const dirs = targets.map((target) => path4.join(target.dir, name));
|
|
21618
|
+
const present = await Promise.all(dirs.map((dir) => files.exists(dir)));
|
|
21619
|
+
return dirs.filter((_, i) => present[i]);
|
|
21620
|
+
}
|
|
21621
|
+
async function planCopies(deps, skill, locked, chosen) {
|
|
21622
|
+
const dirs = /* @__PURE__ */ new Set([...chosen, ...locked ? await installedDirs(deps, skill.name) : []]);
|
|
21623
|
+
return Promise.all(
|
|
21624
|
+
[...dirs].map(async (dir) => {
|
|
21625
|
+
const tree = await deps.files.treeSha(dir);
|
|
21626
|
+
const edited = tree !== null && tree !== skill.tree && tree !== locked?.tree;
|
|
21627
|
+
return {
|
|
21628
|
+
skill,
|
|
21629
|
+
dir,
|
|
21630
|
+
problem: edited ? locked ? EDITED : "not installed by zion" : void 0
|
|
21631
|
+
};
|
|
21632
|
+
})
|
|
21633
|
+
);
|
|
21638
21634
|
}
|
|
21639
21635
|
async function confirmConflicts(ui, copies, { yes: yes2, retry }) {
|
|
21640
21636
|
const conflicts = copies.filter((copy) => copy.problem);
|
|
21641
21637
|
if (conflicts.length === 0) return true;
|
|
21642
21638
|
const width = Math.max(...conflicts.map((copy) => tildify(copy.dir).length));
|
|
21643
21639
|
ui.step({
|
|
21644
|
-
title: conflicts.length
|
|
21640
|
+
title: `${plural(conflicts.length, "folder")} with local changes`,
|
|
21645
21641
|
tone: "warning",
|
|
21646
21642
|
lines: conflicts.map((copy) => `${tildify(copy.dir).padEnd(width)} ${copy.problem}`)
|
|
21647
21643
|
});
|
|
@@ -21652,23 +21648,13 @@ async function confirmConflicts(ui, copies, { yes: yes2, retry }) {
|
|
|
21652
21648
|
nonInteractiveHint: `pass --yes to replace: ${retry} --yes`
|
|
21653
21649
|
});
|
|
21654
21650
|
}
|
|
21655
|
-
async function writeCopies({ files, lockfile
|
|
21651
|
+
async function writeCopies({ files, lockfile }, skills, copies) {
|
|
21656
21652
|
for (const skill of skills) {
|
|
21657
21653
|
const mine = copiesOf(skill, copies);
|
|
21658
|
-
for (const copy of mine) await files.write(copy.dir, skill.files
|
|
21654
|
+
for (const copy of mine) await files.write(copy.dir, skill.files);
|
|
21659
21655
|
await lockfile.update((data) => {
|
|
21660
|
-
|
|
21661
|
-
|
|
21662
|
-
delete data.skills[skill.name];
|
|
21663
|
-
return;
|
|
21664
|
-
}
|
|
21665
|
-
data.skills[skill.name] = {
|
|
21666
|
-
commit: skill.commit,
|
|
21667
|
-
updatedAt: skill.updatedAt,
|
|
21668
|
-
installedAt: previous?.installedAt ?? now().toISOString(),
|
|
21669
|
-
paths: mine.map((copy) => copy.dir),
|
|
21670
|
-
files: fileHashes(skill)
|
|
21671
|
-
};
|
|
21656
|
+
if (mine.length === 0) delete data.skills[skill.name];
|
|
21657
|
+
else data.skills[skill.name] = { commit: skill.commit, tree: skill.tree };
|
|
21672
21658
|
});
|
|
21673
21659
|
}
|
|
21674
21660
|
}
|
|
@@ -21686,22 +21672,36 @@ function copiesOf(skill, copies) {
|
|
|
21686
21672
|
return copies.filter((copy) => copy.skill === skill);
|
|
21687
21673
|
}
|
|
21688
21674
|
function describeDirs(dirs) {
|
|
21689
|
-
return dirs.map((dir) => tildify(
|
|
21675
|
+
return dirs.map((dir) => tildify(path4.dirname(dir))).join(", ");
|
|
21690
21676
|
}
|
|
21691
21677
|
function isNewer(latest, locked) {
|
|
21692
21678
|
return Boolean(latest && locked && latest.commit !== locked.commit);
|
|
21693
21679
|
}
|
|
21694
21680
|
function describeChange(locked, latest) {
|
|
21695
|
-
|
|
21696
|
-
|
|
21697
|
-
|
|
21698
|
-
|
|
21699
|
-
|
|
21700
|
-
|
|
21701
|
-
|
|
21702
|
-
|
|
21703
|
-
|
|
21704
|
-
|
|
21681
|
+
return `${shortCommit(locked.commit)} \u2192 ${shortCommit(latest.commit)}`;
|
|
21682
|
+
}
|
|
21683
|
+
|
|
21684
|
+
// src/commands/skills/chooseTargets.ts
|
|
21685
|
+
async function chooseTargets(ui, deps, given, lock) {
|
|
21686
|
+
const { targets, files } = deps;
|
|
21687
|
+
if (given.length > 0) {
|
|
21688
|
+
const chosen = targets.filter((target) => given.includes(target.id));
|
|
21689
|
+
ui.step({ title: "Install into", lines: [chosen.map((target) => tildify(target.dir)).join(", ")] });
|
|
21690
|
+
return chosen;
|
|
21691
|
+
}
|
|
21692
|
+
const installed = await Promise.all(Object.keys(lock.skills).map((name) => installedDirs(deps, name)));
|
|
21693
|
+
const used = new Set(installed.flat().map((dir) => path5.dirname(dir)));
|
|
21694
|
+
let suggested = targets.filter((target) => used.has(target.dir));
|
|
21695
|
+
if (suggested.length === 0) {
|
|
21696
|
+
const present = await Promise.all(targets.map((target) => files.exists(target.home)));
|
|
21697
|
+
suggested = targets.filter((_, i) => present[i]);
|
|
21698
|
+
}
|
|
21699
|
+
return ui.multiselect({
|
|
21700
|
+
message: "Install into",
|
|
21701
|
+
options: targets.map((target) => ({ value: target, label: tildify(target.dir), hint: target.hint })),
|
|
21702
|
+
initialValues: suggested,
|
|
21703
|
+
nonInteractiveHint: `pass --target (${targets.map((target) => target.id).join(", ")}), e.g. -t ${targets[0].id}`
|
|
21704
|
+
});
|
|
21705
21705
|
}
|
|
21706
21706
|
|
|
21707
21707
|
// src/commands/skills/InstallFlow.ts
|
|
@@ -21760,19 +21760,19 @@ var InstallFlow = class {
|
|
|
21760
21760
|
() => describeCopies(ctx.paint.stderr, "Installed", skills, copies)
|
|
21761
21761
|
);
|
|
21762
21762
|
ui.outro(`Installed ${plural(skills.length, "skill")}.`, {
|
|
21763
|
-
lines: ["Start a new agent session to use them.", `Run ${ctx.bin} skills update to get
|
|
21763
|
+
lines: ["Start a new agent session to use them.", `Run ${ctx.bin} skills update later to get newer versions.`]
|
|
21764
21764
|
});
|
|
21765
21765
|
return 0;
|
|
21766
21766
|
}
|
|
21767
21767
|
async chooseSkills(ui, options, ctx, lock) {
|
|
21768
21768
|
if (options.names.length > 0) {
|
|
21769
21769
|
const names = [...new Set(options.names)];
|
|
21770
|
-
ui.step({ title: "
|
|
21770
|
+
ui.step({ title: "To install", lines: [names.join(", ")] });
|
|
21771
21771
|
return names;
|
|
21772
21772
|
}
|
|
21773
21773
|
const { api } = this.deps;
|
|
21774
21774
|
const available = await ui.task(
|
|
21775
|
-
"Fetching
|
|
21775
|
+
"Fetching skills",
|
|
21776
21776
|
(signal) => api.list({ signal }),
|
|
21777
21777
|
(names) => ({ title: `${plural(names.length, "skill")} available` })
|
|
21778
21778
|
);
|
|
@@ -21795,36 +21795,25 @@ import path8 from "path";
|
|
|
21795
21795
|
|
|
21796
21796
|
// src/commands/skills/removals.ts
|
|
21797
21797
|
import path7 from "path";
|
|
21798
|
-
async function planRemovals(
|
|
21798
|
+
async function planRemovals(deps, lock, names, only) {
|
|
21799
21799
|
const removals = [];
|
|
21800
21800
|
for (const name of names) {
|
|
21801
|
-
const
|
|
21802
|
-
|
|
21803
|
-
|
|
21804
|
-
removals.push({ name, dir, exists, edited: exists && changed.length > 0 });
|
|
21801
|
+
for (const dir of await installedDirs(deps, name)) {
|
|
21802
|
+
if (only && !only.has(path7.dirname(dir))) continue;
|
|
21803
|
+
removals.push({ name, dir, edited: await deps.files.treeSha(dir) !== lock.skills[name].tree });
|
|
21805
21804
|
}
|
|
21806
21805
|
}
|
|
21807
21806
|
return removals;
|
|
21808
21807
|
}
|
|
21809
|
-
async function applyRemovals(
|
|
21810
|
-
const
|
|
21811
|
-
for (const
|
|
21812
|
-
|
|
21813
|
-
|
|
21814
|
-
|
|
21815
|
-
await lockfile.update((data) => {
|
|
21816
|
-
const entry = data.skills[removal.name];
|
|
21817
|
-
if (!entry) return;
|
|
21818
|
-
entry.paths = entry.paths.filter((dir) => dir !== removal.dir);
|
|
21819
|
-
if (entry.paths.length === 0) delete data.skills[removal.name];
|
|
21808
|
+
async function applyRemovals(deps, names, removals) {
|
|
21809
|
+
for (const removal of removals) await deps.files.remove(removal.dir);
|
|
21810
|
+
for (const name of names) {
|
|
21811
|
+
if ((await installedDirs(deps, name)).length > 0) continue;
|
|
21812
|
+
await deps.lockfile.update((data) => {
|
|
21813
|
+
delete data.skills[name];
|
|
21820
21814
|
});
|
|
21821
21815
|
}
|
|
21822
|
-
return kept;
|
|
21823
21816
|
}
|
|
21824
|
-
function describeKept(kept, removed) {
|
|
21825
|
-
return kept.length > 0 ? { title: "Removed, but kept", tone: "warning", lines: kept } : { title: "Removed", lines: [removed.join(", ")] };
|
|
21826
|
-
}
|
|
21827
|
-
var KEPT_ADVICE = "Delete what was kept yourself if you no longer need it.";
|
|
21828
21817
|
|
|
21829
21818
|
// src/commands/skills/ManageFlow.ts
|
|
21830
21819
|
var ManageFlow = class {
|
|
@@ -21836,21 +21825,24 @@ var ManageFlow = class {
|
|
|
21836
21825
|
const { api, lockfile } = this.deps;
|
|
21837
21826
|
const lock = await lockfile.read();
|
|
21838
21827
|
const installed = Object.keys(lock.skills);
|
|
21828
|
+
const where = new Map(
|
|
21829
|
+
await Promise.all(installed.map(async (name) => [name, await installedDirs(this.deps, name)]))
|
|
21830
|
+
);
|
|
21839
21831
|
const { available, latest } = await ui.task(
|
|
21840
21832
|
"Fetching skills",
|
|
21841
21833
|
(signal) => this.fetchCatalog(lock, signal),
|
|
21842
21834
|
({ available: available2, latest: latest2 }) => {
|
|
21843
21835
|
const updates = installed.filter((name) => isNewer(latest2.get(name), lock.skills[name])).length;
|
|
21844
21836
|
return {
|
|
21845
|
-
title: [plural(available2.length, "skill")
|
|
21837
|
+
title: [`${plural(available2.length, "skill")} available`, updates > 0 && plural(updates, "update")].filter(Boolean).join(" \xB7 ")
|
|
21846
21838
|
};
|
|
21847
21839
|
}
|
|
21848
21840
|
);
|
|
21849
21841
|
const names = [.../* @__PURE__ */ new Set([...available, ...installed])].sort();
|
|
21850
21842
|
const ticked = new Set(
|
|
21851
21843
|
await ui.multiselect({
|
|
21852
|
-
message: "
|
|
21853
|
-
options: names.map((name) => ({ value: name, label: name, hint: this.hint(lock, name, latest) })),
|
|
21844
|
+
message: "Skills",
|
|
21845
|
+
options: names.map((name) => ({ value: name, label: name, hint: this.hint(lock, name, latest, where) })),
|
|
21854
21846
|
initialValues: installed,
|
|
21855
21847
|
required: false
|
|
21856
21848
|
})
|
|
@@ -21885,20 +21877,20 @@ var ManageFlow = class {
|
|
|
21885
21877
|
...(await Promise.all(updated.map((skill) => planCopies(this.deps, skill, lock.skills[skill.name], [])))).flat()
|
|
21886
21878
|
];
|
|
21887
21879
|
const removals = await planRemovals(this.deps, lock, removing);
|
|
21888
|
-
this.summarise(ui, ctx.paint.stderr, lock, { added, updated, removing, copies, removals });
|
|
21880
|
+
this.summarise(ui, ctx.paint.stderr, lock, where, { added, updated, removing, copies, removals });
|
|
21889
21881
|
const risky = copies.some((copy) => copy.problem) || removals.some((removal) => removal.edited);
|
|
21890
21882
|
const total = added.length + updated.length + removing.length;
|
|
21891
21883
|
if (!await ui.confirm({ message: `Apply ${plural(total, "change")}?`, defaultValue: !risky })) {
|
|
21892
21884
|
ui.outro("Left everything as it was.", { tone: "muted" });
|
|
21893
21885
|
return 0;
|
|
21894
21886
|
}
|
|
21895
|
-
|
|
21896
|
-
"Applying",
|
|
21887
|
+
await ui.task(
|
|
21888
|
+
"Applying changes",
|
|
21897
21889
|
async () => {
|
|
21898
21890
|
await writeCopies(this.deps, [...added, ...updated], copies);
|
|
21899
|
-
|
|
21891
|
+
await applyRemovals(this.deps, removing, removals);
|
|
21900
21892
|
},
|
|
21901
|
-
(
|
|
21893
|
+
() => ({ title: "Changes applied" })
|
|
21902
21894
|
);
|
|
21903
21895
|
const [first, ...rest] = [
|
|
21904
21896
|
["installed", added.length],
|
|
@@ -21908,10 +21900,7 @@ var ManageFlow = class {
|
|
|
21908
21900
|
const message = [`${first[0]} ${plural(first[1], "skill")}`, ...rest.map(([verb, count]) => `${verb} ${count}`)];
|
|
21909
21901
|
const sentence = message.join(", ");
|
|
21910
21902
|
ui.outro(`${sentence[0].toUpperCase()}${sentence.slice(1)}.`, {
|
|
21911
|
-
lines: [
|
|
21912
|
-
...added.length + updated.length > 0 ? ["Start a new agent session to use them."] : [],
|
|
21913
|
-
...kept.length > 0 ? [KEPT_ADVICE] : []
|
|
21914
|
-
]
|
|
21903
|
+
lines: added.length + updated.length > 0 ? ["Start a new agent session to use them."] : []
|
|
21915
21904
|
});
|
|
21916
21905
|
return 0;
|
|
21917
21906
|
}
|
|
@@ -21932,21 +21921,21 @@ var ManageFlow = class {
|
|
|
21932
21921
|
]);
|
|
21933
21922
|
return { available, latest: new Map(installed.map((name, i) => [name, versions[i]])) };
|
|
21934
21923
|
}
|
|
21935
|
-
hint(lock, name, latest) {
|
|
21924
|
+
hint(lock, name, latest, dirs) {
|
|
21936
21925
|
const entry = lock.skills[name];
|
|
21937
21926
|
if (!entry) return void 0;
|
|
21938
|
-
const where = describeDirs(
|
|
21927
|
+
const where = describeDirs(dirs.get(name) ?? []);
|
|
21939
21928
|
const version3 = latest.get(name);
|
|
21940
21929
|
if (version3 === null) return `${where} \xB7 no longer available`;
|
|
21941
21930
|
return isNewer(version3, entry) ? `${where} \xB7 update available` : where;
|
|
21942
21931
|
}
|
|
21943
|
-
summarise(ui, paint, lock, { added, updated, removing, copies, removals }) {
|
|
21932
|
+
summarise(ui, paint, lock, where, { added, updated, removing, copies, removals }) {
|
|
21944
21933
|
const rows = [
|
|
21945
21934
|
...added.map(
|
|
21946
21935
|
(skill) => [paint.success("+"), skill.name, describeDirs(copiesOf(skill, copies).map((copy) => copy.dir))]
|
|
21947
21936
|
),
|
|
21948
21937
|
...updated.map((skill) => [paint.accent("\u2191"), skill.name, describeChange(lock.skills[skill.name], skill)]),
|
|
21949
|
-
...removing.map((name) => [paint.error("\u2212"), name, describeDirs(
|
|
21938
|
+
...removing.map((name) => [paint.error("\u2212"), name, describeDirs(where.get(name) ?? [])])
|
|
21950
21939
|
];
|
|
21951
21940
|
const width = Math.max(...rows.map(([, name]) => name.length));
|
|
21952
21941
|
ui.step({
|
|
@@ -21955,12 +21944,12 @@ var ManageFlow = class {
|
|
|
21955
21944
|
});
|
|
21956
21945
|
const warnings = [
|
|
21957
21946
|
...copies.flatMap((copy) => copy.problem ? [[tildify(copy.dir), copy.problem]] : []),
|
|
21958
|
-
...removals.flatMap((removal) => removal.edited ? [[tildify(removal.dir),
|
|
21947
|
+
...removals.flatMap((removal) => removal.edited ? [[tildify(removal.dir), EDITED]] : [])
|
|
21959
21948
|
];
|
|
21960
21949
|
if (warnings.length > 0) {
|
|
21961
21950
|
const dirWidth = Math.max(...warnings.map(([dir]) => dir.length));
|
|
21962
21951
|
ui.step({
|
|
21963
|
-
title: warnings.length
|
|
21952
|
+
title: `${plural(warnings.length, "folder")} with local changes`,
|
|
21964
21953
|
tone: "warning",
|
|
21965
21954
|
lines: warnings.map(([dir, problem]) => `${dir.padEnd(dirWidth)} ${problem}`)
|
|
21966
21955
|
});
|
|
@@ -21985,15 +21974,20 @@ var RemoveFlow = class {
|
|
|
21985
21974
|
const names = await this.chooseSkills(ui, options, ctx, installed, lock);
|
|
21986
21975
|
const only = options.targets.length ? new Set(targets.filter((target) => options.targets.includes(target.id)).map((target) => target.dir)) : null;
|
|
21987
21976
|
const removals = await planRemovals(this.deps, lock, names, only ?? void 0);
|
|
21988
|
-
if (removals.length === 0)
|
|
21989
|
-
|
|
21977
|
+
if (removals.length === 0) {
|
|
21978
|
+
if (only)
|
|
21979
|
+
throw new CliError("Those skills aren't installed there", `run ${ctx.bin} skills list to see where they are`);
|
|
21980
|
+
await applyRemovals(this.deps, names, []);
|
|
21981
|
+
ui.outro(`Stopped tracking ${names.join(", ")}.`, { tone: "muted", lines: ["Their folders were already gone."] });
|
|
21982
|
+
return 0;
|
|
21983
|
+
}
|
|
21990
21984
|
const width = Math.max(...removals.map((removal) => tildify(removal.dir).length));
|
|
21991
21985
|
const edited = removals.some((removal) => removal.edited);
|
|
21992
21986
|
ui.step({
|
|
21993
21987
|
title: "To remove",
|
|
21994
21988
|
tone: edited ? "warning" : "success",
|
|
21995
21989
|
lines: removals.map(
|
|
21996
|
-
(removal) => removal.edited ? `${tildify(removal.dir).padEnd(width)}
|
|
21990
|
+
(removal) => removal.edited ? `${tildify(removal.dir).padEnd(width)} ${EDITED}` : tildify(removal.dir)
|
|
21997
21991
|
)
|
|
21998
21992
|
});
|
|
21999
21993
|
const confirmed = options.yes || await ui.confirm({
|
|
@@ -22005,14 +21999,12 @@ var RemoveFlow = class {
|
|
|
22005
21999
|
ui.outro("Left everything as it was.", { tone: "muted" });
|
|
22006
22000
|
return 0;
|
|
22007
22001
|
}
|
|
22008
|
-
|
|
22002
|
+
await ui.task(
|
|
22009
22003
|
"Removing",
|
|
22010
|
-
() => applyRemovals(this.deps,
|
|
22011
|
-
(
|
|
22004
|
+
() => applyRemovals(this.deps, names, removals),
|
|
22005
|
+
() => ({ title: "Removed", lines: [names.join(", ")] })
|
|
22012
22006
|
);
|
|
22013
|
-
ui.outro(`Removed ${plural(names.length, "skill")}
|
|
22014
|
-
lines: kept.length > 0 ? [KEPT_ADVICE] : []
|
|
22015
|
-
});
|
|
22007
|
+
ui.outro(`Removed ${plural(names.length, "skill")}.`);
|
|
22016
22008
|
return 0;
|
|
22017
22009
|
}
|
|
22018
22010
|
async chooseSkills(ui, options, ctx, installed, lock) {
|
|
@@ -22022,12 +22014,13 @@ var RemoveFlow = class {
|
|
|
22022
22014
|
if (missing) throw new CliError(`${missing} isn't installed`, `run ${ctx.bin} skills list to see what is`);
|
|
22023
22015
|
return [...new Set(options.names)];
|
|
22024
22016
|
}
|
|
22017
|
+
const dirs = await Promise.all(installed.map((name) => installedDirs(this.deps, name)));
|
|
22025
22018
|
return ui.multiselect({
|
|
22026
22019
|
message: "Which skills?",
|
|
22027
|
-
options: installed.map((name) => ({
|
|
22020
|
+
options: installed.map((name, i) => ({
|
|
22028
22021
|
value: name,
|
|
22029
22022
|
label: name,
|
|
22030
|
-
hint: describeDirs(
|
|
22023
|
+
hint: describeDirs(dirs[i])
|
|
22031
22024
|
})),
|
|
22032
22025
|
nonInteractiveHint: `name them, e.g. ${ctx.bin} skills remove ${installed[0]} --yes, or pass --all`
|
|
22033
22026
|
});
|
|
@@ -22041,11 +22034,11 @@ var UpdateFlow = class {
|
|
|
22041
22034
|
}
|
|
22042
22035
|
deps;
|
|
22043
22036
|
async run(ui, options, ctx) {
|
|
22044
|
-
const {
|
|
22037
|
+
const { lockfile } = this.deps;
|
|
22045
22038
|
const lock = await lockfile.read();
|
|
22046
22039
|
const installed = Object.keys(lock.skills).sort();
|
|
22047
22040
|
if (installed.length === 0) {
|
|
22048
|
-
ui.outro("No skills are installed
|
|
22041
|
+
ui.outro("No skills are installed.", {
|
|
22049
22042
|
tone: "muted",
|
|
22050
22043
|
lines: [`Install some with ${ctx.bin} skills install.`]
|
|
22051
22044
|
});
|
|
@@ -22058,17 +22051,7 @@ var UpdateFlow = class {
|
|
|
22058
22051
|
const pick2 = ctx.interactive && options.names.length === 0 && !options.yes;
|
|
22059
22052
|
const checks = await ui.task(
|
|
22060
22053
|
`Checking ${plural(names.length, "skill")} for updates`,
|
|
22061
|
-
(signal) =>
|
|
22062
|
-
names.map(async (name) => {
|
|
22063
|
-
const locked = lock.skills[name];
|
|
22064
|
-
try {
|
|
22065
|
-
return { name, locked, latest: await api.get(name, signal) };
|
|
22066
|
-
} catch (error62) {
|
|
22067
|
-
if (error62 instanceof SkillNotFoundError) return { name, locked, latest: null };
|
|
22068
|
-
throw error62;
|
|
22069
|
-
}
|
|
22070
|
-
})
|
|
22071
|
-
),
|
|
22054
|
+
(signal) => this.check(names, lock.skills, signal),
|
|
22072
22055
|
(checks2) => describeChecks(ctx.paint.stderr, checks2, { listUpdates: !pick2 })
|
|
22073
22056
|
);
|
|
22074
22057
|
const outdated = checks.filter(isOutdated);
|
|
@@ -22091,6 +22074,23 @@ var UpdateFlow = class {
|
|
|
22091
22074
|
ui.outro(`Updated ${plural(chosen.length, "skill")}.`, { lines: ["Start a new agent session to use them."] });
|
|
22092
22075
|
return 0;
|
|
22093
22076
|
}
|
|
22077
|
+
// Only skills whose commit differs from the locked one are downloaded.
|
|
22078
|
+
async check(names, locks, signal) {
|
|
22079
|
+
const commits = await this.deps.api.latestCommits(names, signal);
|
|
22080
|
+
return Promise.all(
|
|
22081
|
+
names.map(async (name) => {
|
|
22082
|
+
const locked = locks[name];
|
|
22083
|
+
if (commits.has(name) && commits.get(name) === locked.commit)
|
|
22084
|
+
return { name, locked, latest: null, gone: false };
|
|
22085
|
+
try {
|
|
22086
|
+
return { name, locked, latest: await this.deps.api.get(name, signal), gone: false };
|
|
22087
|
+
} catch (error62) {
|
|
22088
|
+
if (error62 instanceof SkillNotFoundError) return { name, locked, latest: null, gone: true };
|
|
22089
|
+
throw error62;
|
|
22090
|
+
}
|
|
22091
|
+
})
|
|
22092
|
+
);
|
|
22093
|
+
}
|
|
22094
22094
|
async chooseUpdates(ui, outdated) {
|
|
22095
22095
|
const width = Math.max(...outdated.map((check2) => shortCommit(check2.locked.commit).length));
|
|
22096
22096
|
return ui.multiselect({
|
|
@@ -22109,7 +22109,7 @@ function isOutdated(check2) {
|
|
|
22109
22109
|
}
|
|
22110
22110
|
function describeChecks(paint, checks, { listUpdates }) {
|
|
22111
22111
|
const updates = checks.filter(isOutdated);
|
|
22112
|
-
const gone = checks.filter((check2) =>
|
|
22112
|
+
const gone = checks.filter((check2) => check2.gone);
|
|
22113
22113
|
if (updates.length === 0 && gone.length === 0) return { title: "Up to date" };
|
|
22114
22114
|
const shown = [...listUpdates ? updates : [], ...gone];
|
|
22115
22115
|
const width = Math.max(0, ...shown.map((check2) => check2.name.length));
|
|
@@ -22117,7 +22117,7 @@ function describeChecks(paint, checks, { listUpdates }) {
|
|
|
22117
22117
|
title: updates.length > 0 ? `${plural(updates.length, "update")} available` : `${plural(gone.length, "skill")} no longer available`,
|
|
22118
22118
|
tone: gone.length > 0 ? "warning" : "success",
|
|
22119
22119
|
lines: shown.map(
|
|
22120
|
-
(check2) => `${check2.name.padEnd(width)} ${isOutdated(check2) ? paint.muted(describeChange(check2.locked, check2.latest)) : "no longer available,
|
|
22120
|
+
(check2) => `${check2.name.padEnd(width)} ${isOutdated(check2) ? paint.muted(describeChange(check2.locked, check2.latest)) : "no longer available, kept as is"}`
|
|
22121
22121
|
)
|
|
22122
22122
|
};
|
|
22123
22123
|
}
|
|
@@ -22125,7 +22125,7 @@ function describeChecks(paint, checks, { listUpdates }) {
|
|
|
22125
22125
|
// src/commands/skills/actions.ts
|
|
22126
22126
|
var SKILLS_ACTIONS = [
|
|
22127
22127
|
{ id: "install", aliases: ["add"], hint: "choose skills and where they go" },
|
|
22128
|
-
{ id: "update", aliases: ["upgrade"], hint: "get
|
|
22128
|
+
{ id: "update", aliases: ["upgrade"], hint: "get newer versions of installed skills" },
|
|
22129
22129
|
{ id: "remove", aliases: ["rm", "uninstall"], hint: "delete skills zion installed" },
|
|
22130
22130
|
{ id: "list", aliases: ["ls"], hint: "print every skill and where it is installed" },
|
|
22131
22131
|
{ id: "show", aliases: [], hint: "print a skill's SKILL.md" }
|
|
@@ -22146,6 +22146,8 @@ function parseSkillsOptions(args, bin, targetIds) {
|
|
|
22146
22146
|
strict: true,
|
|
22147
22147
|
options: {
|
|
22148
22148
|
target: { type: "string", short: "t", multiple: true, default: [] },
|
|
22149
|
+
project: { type: "boolean", short: "p", default: false },
|
|
22150
|
+
global: { type: "boolean", short: "g", default: false },
|
|
22149
22151
|
all: { type: "boolean", short: "a", default: false },
|
|
22150
22152
|
yes: { type: "boolean", short: "y", default: false },
|
|
22151
22153
|
json: { type: "boolean", default: false }
|
|
@@ -22169,11 +22171,14 @@ function parseSkillsOptions(args, bin, targetIds) {
|
|
|
22169
22171
|
throw new UsageError(`unknown target "${unknown2}"`, `choose one of: ${targetIds.join(", ")}`);
|
|
22170
22172
|
}
|
|
22171
22173
|
const targets = given.filter(isTarget);
|
|
22174
|
+
if (values.project && values.global) throw new UsageError("pass --project or --global, not both", usageHint);
|
|
22175
|
+
const scope = values.project ? "project" : values.global ? "global" : void 0;
|
|
22172
22176
|
const id = action?.id;
|
|
22173
22177
|
const only = (flag, allowed) => {
|
|
22174
22178
|
if (!id || !allowed.includes(id)) throw new UsageError(`${flag} works with: ${allowed.join(", ")}`, usageHint);
|
|
22175
22179
|
};
|
|
22176
22180
|
if (targets.length > 0) only("--target", ["install", "remove"]);
|
|
22181
|
+
if (scope && id === "show") throw new UsageError("--project and --global don't apply to show", usageHint);
|
|
22177
22182
|
if (values.all) only("--all", ["install", "remove"]);
|
|
22178
22183
|
if (values.yes) only("--yes", ["install", "update", "remove"]);
|
|
22179
22184
|
if (values.json) only("--json", ["list"]);
|
|
@@ -22182,23 +22187,26 @@ function parseSkillsOptions(args, bin, targetIds) {
|
|
|
22182
22187
|
if (id === "show" && names.length !== 1) {
|
|
22183
22188
|
throw new UsageError("show takes exactly one skill name", `e.g. ${bin} skills show commit`);
|
|
22184
22189
|
}
|
|
22185
|
-
return { action: id, names, targets, all: values.all, yes: values.yes, json: values.json };
|
|
22190
|
+
return { action: id, names, targets, scope, all: values.all, yes: values.yes, json: values.json };
|
|
22186
22191
|
}
|
|
22187
22192
|
|
|
22188
22193
|
// src/commands/skills/output.ts
|
|
22189
|
-
async function listSkills(
|
|
22194
|
+
async function listSkills(deps, ctx, json2) {
|
|
22195
|
+
const { api, lockfile } = deps;
|
|
22190
22196
|
const lock = await lockfile.read();
|
|
22191
22197
|
const installed = Object.keys(lock.skills);
|
|
22192
22198
|
const available = await api.list({ include: installed });
|
|
22193
22199
|
const names = [.../* @__PURE__ */ new Set([...available, ...installed])].sort();
|
|
22194
|
-
const rows =
|
|
22195
|
-
|
|
22196
|
-
|
|
22197
|
-
|
|
22198
|
-
|
|
22199
|
-
|
|
22200
|
-
|
|
22201
|
-
|
|
22200
|
+
const rows = await Promise.all(
|
|
22201
|
+
names.map(async (name) => {
|
|
22202
|
+
const entry = lock.skills[name];
|
|
22203
|
+
return {
|
|
22204
|
+
name,
|
|
22205
|
+
available: available.includes(name),
|
|
22206
|
+
installed: entry ? { commit: entry.commit, paths: await installedDirs(deps, name) } : null
|
|
22207
|
+
};
|
|
22208
|
+
})
|
|
22209
|
+
);
|
|
22202
22210
|
if (json2) {
|
|
22203
22211
|
ctx.stdout.write(`${JSON.stringify({ skills: rows }, null, 2)}
|
|
22204
22212
|
`);
|
|
@@ -22233,12 +22241,15 @@ async function showSkill({ api }, ctx, name) {
|
|
|
22233
22241
|
|
|
22234
22242
|
// src/commands/skills/SkillsCommand.ts
|
|
22235
22243
|
var SkillsCommand = class {
|
|
22236
|
-
constructor(
|
|
22237
|
-
this.
|
|
22238
|
-
const {
|
|
22244
|
+
constructor(base) {
|
|
22245
|
+
this.base = base;
|
|
22246
|
+
const { scopes, api } = base;
|
|
22247
|
+
const { targets, lockfile } = scopes.global;
|
|
22239
22248
|
this.help = {
|
|
22240
22249
|
usage: "[action] [skill...] [options]",
|
|
22241
|
-
description: `Downloads skills from ${api.host} into the
|
|
22250
|
+
description: `Downloads skills from ${api.host} into the folders your agents load them from, replacing each skill folder whole. Without an action, it shows every skill as a checklist where ticked means installed: tick to install, untick to remove, and installed skills with a newer version are updated too. When not in a terminal, it prints the list instead. It asks whether to work in this project or your home directory unless you pass --project or --global. zion records what it installed in ${tildify(lockfile.path)} (./${path9.basename(
|
|
22251
|
+
scopes.project.lockfile.path
|
|
22252
|
+
)} with --project), and asks before replacing or deleting a skill folder that differs from what it installed. Targets: ${targets.map((t) => `${t.id} is ${tildify(t.dir)}`).join(", ")}; with --project, the same paths under the current folder.`,
|
|
22242
22253
|
arguments: {
|
|
22243
22254
|
title: "Actions",
|
|
22244
22255
|
rows: SKILLS_ACTIONS.map((action) => [
|
|
@@ -22247,10 +22258,12 @@ var SkillsCommand = class {
|
|
|
22247
22258
|
])
|
|
22248
22259
|
},
|
|
22249
22260
|
options: [
|
|
22250
|
-
["-
|
|
22251
|
-
["-
|
|
22252
|
-
["-
|
|
22253
|
-
["--
|
|
22261
|
+
["-p, --project", `work in this folder, recorded in ./${path9.basename(scopes.project.lockfile.path)}`],
|
|
22262
|
+
["-g, --global", "work in your home directory (the default without a terminal)"],
|
|
22263
|
+
["-t, --target <name>", `${targets.map((t) => t.id).join(" or ")}; repeat for both`],
|
|
22264
|
+
["-a, --all", "every skill (install and remove)"],
|
|
22265
|
+
["-y, --yes", "say yes to every confirmation, including replacing edited folders"],
|
|
22266
|
+
["--json", "print the list as JSON"]
|
|
22254
22267
|
],
|
|
22255
22268
|
examples: [
|
|
22256
22269
|
"skills",
|
|
@@ -22263,7 +22276,7 @@ var SkillsCommand = class {
|
|
|
22263
22276
|
]
|
|
22264
22277
|
};
|
|
22265
22278
|
}
|
|
22266
|
-
|
|
22279
|
+
base;
|
|
22267
22280
|
name = "skills";
|
|
22268
22281
|
summary = "install my agent skills";
|
|
22269
22282
|
group = "work";
|
|
@@ -22272,35 +22285,51 @@ var SkillsCommand = class {
|
|
|
22272
22285
|
const options = parseSkillsOptions(
|
|
22273
22286
|
args,
|
|
22274
22287
|
ctx.bin,
|
|
22275
|
-
this.
|
|
22288
|
+
this.base.scopes.global.targets.map((target) => target.id)
|
|
22276
22289
|
);
|
|
22277
|
-
if (options.action === "list") return listSkills(this.
|
|
22278
|
-
if (options.action === "show") return showSkill(this.
|
|
22290
|
+
if (options.action === "list") return listSkills(this.depsFor(options.scope ?? "global"), ctx, options.json);
|
|
22291
|
+
if (options.action === "show") return showSkill(this.base, ctx, options.names[0]);
|
|
22279
22292
|
const given = options.action;
|
|
22280
|
-
if (!given && !ctx.interactive) return listSkills(this.
|
|
22281
|
-
const ui = this.
|
|
22293
|
+
if (!given && !ctx.interactive) return listSkills(this.depsFor(options.scope ?? "global"), ctx, false);
|
|
22294
|
+
const ui = this.base.createPrompter(ctx);
|
|
22282
22295
|
return runSession(ui, async () => {
|
|
22283
|
-
ui.intro("skills", this.
|
|
22296
|
+
ui.intro("skills", this.base.api.host);
|
|
22297
|
+
const scope = options.scope ?? await this.chooseScope(ui);
|
|
22298
|
+
const deps = this.depsFor(scope);
|
|
22284
22299
|
const flows = { install: InstallFlow, update: UpdateFlow, remove: RemoveFlow };
|
|
22285
|
-
return given ? new flows[given](
|
|
22300
|
+
return given ? new flows[given](deps).run(ui, options, ctx) : new ManageFlow(deps).run(ui, ctx);
|
|
22301
|
+
});
|
|
22302
|
+
}
|
|
22303
|
+
depsFor(scope) {
|
|
22304
|
+
return { ...this.base, ...this.base.scopes[scope] };
|
|
22305
|
+
}
|
|
22306
|
+
chooseScope(ui) {
|
|
22307
|
+
const { project, global } = this.base.scopes;
|
|
22308
|
+
return ui.select({
|
|
22309
|
+
message: "Scope",
|
|
22310
|
+
options: [
|
|
22311
|
+
{ value: "project", label: "Locally", hint: `tracked in ./${path9.basename(project.lockfile.path)}` },
|
|
22312
|
+
{ value: "global", label: "Globally", hint: `tracked in ${tildify(global.lockfile.path)}` }
|
|
22313
|
+
],
|
|
22314
|
+
initialValue: "global"
|
|
22286
22315
|
});
|
|
22287
22316
|
}
|
|
22288
22317
|
};
|
|
22289
22318
|
|
|
22290
22319
|
// src/commands/skills/targets.ts
|
|
22291
|
-
import
|
|
22320
|
+
import path10 from "path";
|
|
22292
22321
|
function skillTargets(homedir) {
|
|
22293
22322
|
return [
|
|
22294
22323
|
{
|
|
22295
22324
|
id: "agents",
|
|
22296
|
-
dir:
|
|
22297
|
-
home:
|
|
22325
|
+
dir: path10.join(homedir, ".agents", "skills"),
|
|
22326
|
+
home: path10.join(homedir, ".agents"),
|
|
22298
22327
|
hint: "Copilot and other agents"
|
|
22299
22328
|
},
|
|
22300
22329
|
{
|
|
22301
22330
|
id: "claude",
|
|
22302
|
-
dir:
|
|
22303
|
-
home:
|
|
22331
|
+
dir: path10.join(homedir, ".claude", "skills"),
|
|
22332
|
+
home: path10.join(homedir, ".claude"),
|
|
22304
22333
|
hint: "Claude Code"
|
|
22305
22334
|
}
|
|
22306
22335
|
];
|
|
@@ -22368,28 +22397,23 @@ var CliGit = class {
|
|
|
22368
22397
|
|
|
22369
22398
|
// src/services/Lockfile.ts
|
|
22370
22399
|
import fs3 from "fs/promises";
|
|
22371
|
-
import
|
|
22372
|
-
var VERSION =
|
|
22400
|
+
import path11 from "path";
|
|
22401
|
+
var VERSION = 2;
|
|
22373
22402
|
var LockedSkill = external_exports.looseObject({
|
|
22374
22403
|
/** The last commit in zion-off/skills that changed this skill. */
|
|
22375
22404
|
commit: external_exports.string(),
|
|
22376
|
-
/**
|
|
22377
|
-
|
|
22378
|
-
installedAt: external_exports.string(),
|
|
22379
|
-
/** Every directory this skill was installed into. */
|
|
22380
|
-
paths: external_exports.array(external_exports.string()),
|
|
22381
|
-
/** Git blob hash of each installed file, keyed by its path inside the skill, to spot local edits. */
|
|
22382
|
-
files: external_exports.record(external_exports.string(), external_exports.string())
|
|
22405
|
+
/** Git tree hash of the skill as installed, to spot local edits. */
|
|
22406
|
+
tree: external_exports.string()
|
|
22383
22407
|
});
|
|
22384
22408
|
var LockData = external_exports.looseObject({
|
|
22385
22409
|
version: external_exports.literal(VERSION),
|
|
22386
22410
|
/** Installed skills by name. */
|
|
22387
|
-
skills: external_exports.record(external_exports.string(), LockedSkill).default({})
|
|
22411
|
+
skills: external_exports.record(external_exports.string().regex(SKILL_NAME), LockedSkill).default({})
|
|
22388
22412
|
});
|
|
22389
22413
|
var Versioned = jsonText(external_exports.looseObject({ version: external_exports.number() }));
|
|
22390
22414
|
var JsonLockfile = class {
|
|
22391
|
-
constructor(
|
|
22392
|
-
this.path =
|
|
22415
|
+
constructor(path14) {
|
|
22416
|
+
this.path = path14;
|
|
22393
22417
|
}
|
|
22394
22418
|
path;
|
|
22395
22419
|
async read() {
|
|
@@ -22421,7 +22445,7 @@ var JsonLockfile = class {
|
|
|
22421
22445
|
return data.data;
|
|
22422
22446
|
}
|
|
22423
22447
|
async write(data) {
|
|
22424
|
-
await fs3.mkdir(
|
|
22448
|
+
await fs3.mkdir(path11.dirname(this.path), { recursive: true });
|
|
22425
22449
|
const temporary = `${this.path}.${process.pid}.tmp`;
|
|
22426
22450
|
try {
|
|
22427
22451
|
await fs3.writeFile(temporary, JSON.stringify(data, null, 2) + "\n");
|
|
@@ -22438,10 +22462,10 @@ var JsonLockfile = class {
|
|
|
22438
22462
|
);
|
|
22439
22463
|
}
|
|
22440
22464
|
};
|
|
22441
|
-
function describeIssue({ path:
|
|
22442
|
-
if (
|
|
22443
|
-
if (
|
|
22444
|
-
return `"${
|
|
22465
|
+
function describeIssue({ path: path14, code }) {
|
|
22466
|
+
if (path14.length === 0) return code === "custom" ? "it is not valid JSON" : "it is not an object";
|
|
22467
|
+
if (path14[0] === "version") return `its version isn't ${VERSION}`;
|
|
22468
|
+
return `"${path14.join(".")}" is not valid`;
|
|
22445
22469
|
}
|
|
22446
22470
|
|
|
22447
22471
|
// src/services/ProcessRunner.ts
|
|
@@ -22492,10 +22516,10 @@ var NodeProcessRunner = class {
|
|
|
22492
22516
|
|
|
22493
22517
|
// src/services/xdg.ts
|
|
22494
22518
|
import os2 from "os";
|
|
22495
|
-
import
|
|
22519
|
+
import path12 from "path";
|
|
22496
22520
|
function stateHome(env) {
|
|
22497
22521
|
const base = env.XDG_STATE_HOME;
|
|
22498
|
-
return base &&
|
|
22522
|
+
return base && path12.isAbsolute(base) ? base : path12.join(os2.homedir(), ".local", "state");
|
|
22499
22523
|
}
|
|
22500
22524
|
|
|
22501
22525
|
// src/cli.tsx
|
|
@@ -22513,7 +22537,7 @@ var registry2 = new CommandRegistry().register(
|
|
|
22513
22537
|
slug: "zion-off/dotfiles",
|
|
22514
22538
|
url: "https://github.com/zion-off/dotfiles.git",
|
|
22515
22539
|
installer: "bin/dot",
|
|
22516
|
-
installerLink:
|
|
22540
|
+
installerLink: path13.join(os3.homedir(), ".local", "bin", "dot")
|
|
22517
22541
|
}),
|
|
22518
22542
|
git,
|
|
22519
22543
|
runner,
|
|
@@ -22526,10 +22550,17 @@ var registry2 = new CommandRegistry().register(
|
|
|
22526
22550
|
new SkillsCommand({
|
|
22527
22551
|
api: new HttpSkillsApi(process.env.ZION_SKILLS_URL || "https://zzzzion.com/api/skills"),
|
|
22528
22552
|
files: new NodeSkillFiles(),
|
|
22529
|
-
|
|
22530
|
-
|
|
22531
|
-
|
|
22532
|
-
|
|
22553
|
+
scopes: {
|
|
22554
|
+
global: {
|
|
22555
|
+
lockfile: new JsonLockfile(path13.join(stateHome(process.env), "zion.json")),
|
|
22556
|
+
targets: skillTargets(os3.homedir())
|
|
22557
|
+
},
|
|
22558
|
+
project: {
|
|
22559
|
+
lockfile: new JsonLockfile(path13.join(process.cwd(), "zion.json")),
|
|
22560
|
+
targets: skillTargets(process.cwd())
|
|
22561
|
+
}
|
|
22562
|
+
},
|
|
22563
|
+
createPrompter
|
|
22533
22564
|
})
|
|
22534
22565
|
).register(new TuiCommand()).register(new CardCommand()).register(
|
|
22535
22566
|
new NowCommand({
|