zion 4.3.0 → 4.3.2

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 (2) hide show
  1. package/dist/cli.js +121 -125
  2. 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 path16 from "path";
8
+ import path17 from "path";
9
9
 
10
10
  // package.json
11
- var version = "4.3.0";
11
+ var version = "4.3.2";
12
12
 
13
13
  // src/lib/theme.ts
14
14
  import { Chalk, supportsColor, supportsColorStderr } from "chalk";
@@ -585,6 +585,9 @@ var CardCommand = class {
585
585
  }
586
586
  };
587
587
 
588
+ // src/commands/dotfiles/DotfilesCommand.ts
589
+ import path4 from "path";
590
+
588
591
  // src/lib/format.ts
589
592
  var shortCommit = (commit) => commit.slice(0, 7);
590
593
  function plural(count, noun) {
@@ -1129,10 +1132,18 @@ function tildify(input2) {
1129
1132
  return input2.startsWith(home + path.sep) ? `~${input2.slice(home.length)}` : input2;
1130
1133
  }
1131
1134
 
1135
+ // src/services/xdg.ts
1136
+ import os2 from "os";
1137
+ import path2 from "path";
1138
+ function stateHome(env) {
1139
+ const base = env.XDG_STATE_HOME;
1140
+ return base && path2.isAbsolute(base) ? base : path2.join(os2.homedir(), ".local", "state");
1141
+ }
1142
+
1132
1143
  // src/commands/dotfiles/DotfilesRepository.ts
1133
1144
  import { constants } from "fs";
1134
1145
  import fs from "fs/promises";
1135
- import path2 from "path";
1146
+ import path3 from "path";
1136
1147
  var NotACloneError = class extends CliError {
1137
1148
  constructor(dir, slug) {
1138
1149
  super(
@@ -1157,7 +1168,7 @@ var DotfilesRepository = class {
1157
1168
  } catch {
1158
1169
  return null;
1159
1170
  }
1160
- const suffix = path2.sep + path2.normalize(this.source.installer);
1171
+ const suffix = path3.sep + path3.normalize(this.source.installer);
1161
1172
  if (!target.endsWith(suffix)) return null;
1162
1173
  const location = await this.inspect(target.slice(0, -suffix.length));
1163
1174
  return location.state === "clone" ? location : null;
@@ -1169,7 +1180,7 @@ var DotfilesRepository = class {
1169
1180
  async sync({ dir, state }, { update, signal }) {
1170
1181
  if (state === "foreign") throw new NotACloneError(dir, this.source.slug);
1171
1182
  if (state === "clone") return this.update(dir, update, signal);
1172
- await fs.mkdir(path2.dirname(dir), { recursive: true });
1183
+ await fs.mkdir(path3.dirname(dir), { recursive: true });
1173
1184
  try {
1174
1185
  await this.git.clone(this.source.url, dir, signal);
1175
1186
  } catch (error62) {
@@ -1182,7 +1193,7 @@ var DotfilesRepository = class {
1182
1193
  return { kind: "cloned", commit: await this.head(dir) };
1183
1194
  }
1184
1195
  async installerPath(dir) {
1185
- const installer = path2.join(dir, this.source.installer);
1196
+ const installer = path3.join(dir, this.source.installer);
1186
1197
  try {
1187
1198
  await fs.access(installer, constants.R_OK);
1188
1199
  } catch {
@@ -1338,7 +1349,7 @@ function parseDotfilesOptions(args, bin) {
1338
1349
 
1339
1350
  // src/commands/dotfiles/DotfilesCommand.ts
1340
1351
  var DIR_ENV = "ZION_DOTFILES_DIR";
1341
- var DEFAULT_DIR = "~/.dotfiles";
1352
+ var defaultDir = (env) => tildify(path4.join(stateHome(env), "zion", "dotfiles"));
1342
1353
  var SUPPORTED_PLATFORMS = { darwin: "macOS", linux: "Linux" };
1343
1354
  var DotfilesCommand = class {
1344
1355
  constructor(deps) {
@@ -1346,10 +1357,10 @@ var DotfilesCommand = class {
1346
1357
  const { slug } = deps.repository.source;
1347
1358
  this.help = {
1348
1359
  usage: "[action] [options]",
1349
- description: `Clones github.com/${slug} (or updates an existing clone) and runs its dot installer. Without an action, you choose one interactively. The clone lives in --dir, $${DIR_ENV}, the clone an earlier install was made from, or ${DEFAULT_DIR}, in that order.`,
1360
+ description: `Clones github.com/${slug} (or updates an existing clone) and runs its dot installer. Without an action, you choose one interactively. The clone lives in --dir, $${DIR_ENV}, the clone an earlier install was made from, or ${defaultDir(this.deps.env)}, in that order.`,
1350
1361
  arguments: { title: "Actions", rows: DOT_ACTIONS.map((action) => [action.id, action.hint]) },
1351
1362
  options: [
1352
- ["-d, --dir <path>", `where the dotfiles live (default: ${DEFAULT_DIR})`],
1363
+ ["-d, --dir <path>", `where the dotfiles live (default: ${defaultDir(this.deps.env)})`],
1353
1364
  ["-y, --yes", "answer yes to every prompt, including uninstall"],
1354
1365
  ["-n, --dry-run", "show what would happen, change nothing"],
1355
1366
  ["--no-update", "use an existing clone as is, without pulling"]
@@ -1431,7 +1442,7 @@ var DotfilesCommand = class {
1431
1442
  let checked;
1432
1443
  const answer = await ui.text({
1433
1444
  message: "Where should your dotfiles live?",
1434
- defaultValue: DEFAULT_DIR,
1445
+ defaultValue: defaultDir(env),
1435
1446
  validate: async (value) => {
1436
1447
  checked = await repository.inspect(expandHome(value));
1437
1448
  return checked.state === "foreign" ? new NotACloneError(checked.dir, repository.source.slug).message : void 0;
@@ -2326,10 +2337,10 @@ function mergeDefs(...defs) {
2326
2337
  function cloneDef(schema) {
2327
2338
  return mergeDefs(schema._zod.def);
2328
2339
  }
2329
- function getElementAtPath(obj, path17) {
2330
- if (!path17)
2340
+ function getElementAtPath(obj, path18) {
2341
+ if (!path18)
2331
2342
  return obj;
2332
- return path17.reduce((acc, key) => acc?.[key], obj);
2343
+ return path18.reduce((acc, key) => acc?.[key], obj);
2333
2344
  }
2334
2345
  function promiseAllObject(promisesObj) {
2335
2346
  const keys = Object.keys(promisesObj);
@@ -2669,11 +2680,11 @@ function explicitlyAborted(x, startIndex = 0) {
2669
2680
  }
2670
2681
  return false;
2671
2682
  }
2672
- function prefixIssues(path17, issues) {
2683
+ function prefixIssues(path18, issues) {
2673
2684
  return issues.map((iss) => {
2674
2685
  var _a3;
2675
2686
  (_a3 = iss).path ?? (_a3.path = []);
2676
- iss.path.unshift(path17);
2687
+ iss.path.unshift(path18);
2677
2688
  return iss;
2678
2689
  });
2679
2690
  }
@@ -3135,16 +3146,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
3135
3146
  }
3136
3147
  function formatError2(error62, mapper = (issue2) => issue2.message) {
3137
3148
  const fieldErrors = { _errors: [] };
3138
- const processError = (error63, path17 = []) => {
3149
+ const processError = (error63, path18 = []) => {
3139
3150
  for (const issue2 of error63.issues) {
3140
3151
  if (issue2.code === "invalid_union" && issue2.errors.length) {
3141
- issue2.errors.map((issues) => processError({ issues }, [...path17, ...issue2.path]));
3152
+ issue2.errors.map((issues) => processError({ issues }, [...path18, ...issue2.path]));
3142
3153
  } else if (issue2.code === "invalid_key") {
3143
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
3154
+ processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
3144
3155
  } else if (issue2.code === "invalid_element") {
3145
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
3156
+ processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
3146
3157
  } else {
3147
- const fullpath = [...path17, ...issue2.path];
3158
+ const fullpath = [...path18, ...issue2.path];
3148
3159
  if (fullpath.length === 0) {
3149
3160
  fieldErrors._errors.push(mapper(issue2));
3150
3161
  } else {
@@ -3183,17 +3194,17 @@ function formatError2(error62, mapper = (issue2) => issue2.message) {
3183
3194
  }
3184
3195
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
3185
3196
  const result = { errors: [] };
3186
- const processError = (error63, path17 = []) => {
3197
+ const processError = (error63, path18 = []) => {
3187
3198
  var _a3;
3188
3199
  for (const issue2 of error63.issues) {
3189
3200
  if (issue2.code === "invalid_union" && issue2.errors.length) {
3190
- issue2.errors.map((issues) => processError({ issues }, [...path17, ...issue2.path]));
3201
+ issue2.errors.map((issues) => processError({ issues }, [...path18, ...issue2.path]));
3191
3202
  } else if (issue2.code === "invalid_key") {
3192
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
3203
+ processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
3193
3204
  } else if (issue2.code === "invalid_element") {
3194
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
3205
+ processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
3195
3206
  } else {
3196
- const fullpath = [...path17, ...issue2.path];
3207
+ const fullpath = [...path18, ...issue2.path];
3197
3208
  if (fullpath.length === 0) {
3198
3209
  result.errors.push(mapper(issue2));
3199
3210
  continue;
@@ -3232,8 +3243,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
3232
3243
  }
3233
3244
  function toDotPath(_path) {
3234
3245
  const segs = [];
3235
- const path17 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
3236
- for (const seg of path17) {
3246
+ const path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
3247
+ for (const seg of path18) {
3237
3248
  if (typeof seg === "number")
3238
3249
  segs.push(`[${seg}]`);
3239
3250
  else if (typeof seg === "symbol")
@@ -20371,13 +20382,13 @@ function resolveRef(ref, ctx) {
20371
20382
  if (!ref.startsWith("#")) {
20372
20383
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
20373
20384
  }
20374
- const path17 = ref.slice(1).split("/").filter(Boolean);
20375
- if (path17.length === 0) {
20385
+ const path18 = ref.slice(1).split("/").filter(Boolean);
20386
+ if (path18.length === 0) {
20376
20387
  return ctx.rootSchema;
20377
20388
  }
20378
20389
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
20379
- if (path17[0] === defsKey) {
20380
- const key = path17[1] === void 0 ? void 0 : decodeJSONPointerSegment(path17[1]);
20390
+ if (path18[0] === defsKey) {
20391
+ const key = path18[1] === void 0 ? void 0 : decodeJSONPointerSegment(path18[1]);
20381
20392
  if (!key || !ctx.defs[key]) {
20382
20393
  throw new Error(`Reference not found: ${ref}`);
20383
20394
  }
@@ -21497,7 +21508,7 @@ function parseNowOptions(args, bin) {
21497
21508
 
21498
21509
  // src/commands/skills/GitExclude.ts
21499
21510
  import fs2 from "fs/promises";
21500
- import path3 from "path";
21511
+ import path5 from "path";
21501
21512
  var START = "# >>> zion skills (private)";
21502
21513
  var END = "# <<< zion skills (private)";
21503
21514
  var GitExclude = class {
@@ -21517,9 +21528,9 @@ var GitExclude = class {
21517
21528
  throw new CliError("This folder is not in a git repository", "private skills need one");
21518
21529
  }
21519
21530
  const { file: file2, root } = located;
21520
- const prefix = path3.relative(root, await fs2.realpath(this.dir));
21531
+ const prefix = path5.relative(root, await fs2.realpath(this.dir));
21521
21532
  const lines = paths.map(
21522
- (target) => `/${path3.join(prefix, path3.relative(this.dir, target)).split(path3.sep).join("/")}`
21533
+ (target) => `/${path5.join(prefix, path5.relative(this.dir, target)).split(path5.sep).join("/")}`
21523
21534
  );
21524
21535
  const current = await fs2.readFile(file2, "utf8").catch((error62) => {
21525
21536
  if (errorCode(error62) === "ENOENT") return "";
@@ -21528,13 +21539,13 @@ var GitExclude = class {
21528
21539
  const kept = withoutBlock(current.split("\n"));
21529
21540
  while (kept.at(-1) === "") kept.pop();
21530
21541
  const next = [...kept, ...lines.length > 0 ? [START, ...lines, END] : []];
21531
- await fs2.mkdir(path3.dirname(file2), { recursive: true });
21542
+ await fs2.mkdir(path5.dirname(file2), { recursive: true });
21532
21543
  await fs2.writeFile(file2, next.length > 0 ? `${next.join("\n")}
21533
21544
  ` : "");
21534
- const relative2 = paths.map((target) => path3.relative(this.dir, target));
21545
+ const relative2 = paths.map((target) => path5.relative(this.dir, target));
21535
21546
  const files = await this.git.tracked(this.dir, relative2);
21536
21547
  return paths.filter(
21537
- (_, i) => files.some((tracked) => tracked === relative2[i] || tracked.startsWith(`${relative2[i]}${path3.sep}`))
21548
+ (_, i) => files.some((tracked) => tracked === relative2[i] || tracked.startsWith(`${relative2[i]}${path5.sep}`))
21538
21549
  );
21539
21550
  }
21540
21551
  };
@@ -21625,12 +21636,12 @@ var HttpSkillsApi = class {
21625
21636
  if (error62 instanceof HttpStatusError && error62.status === 404) throw new SkillNotFoundError(name);
21626
21637
  throw error62;
21627
21638
  }
21628
- const files = body.files.map(({ path: path17, sha, executable, content }) => {
21639
+ const files = body.files.map(({ path: path18, sha, executable, content }) => {
21629
21640
  const bytes = Buffer.from(content, "base64");
21630
21641
  if (gitBlobSha(bytes) !== sha) {
21631
- throw new CliError(`${this.host} sent a damaged copy of ${name}/${path17}`, "try again in a moment");
21642
+ throw new CliError(`${this.host} sent a damaged copy of ${name}/${path18}`, "try again in a moment");
21632
21643
  }
21633
- return { path: path17, sha, executable, content: bytes };
21644
+ return { path: path18, sha, executable, content: bytes };
21634
21645
  });
21635
21646
  return { name, commit: body.commit, tree: gitTreeShaOfFiles(files), files };
21636
21647
  }
@@ -21717,8 +21728,8 @@ var GithubSkillsApi = class {
21717
21728
  return latest?.sha ?? null;
21718
21729
  }
21719
21730
  /** `unreachable` says a 404 means the repository itself can't be read, not just the thing asked for. */
21720
- async read(path17, schema, failure2, signal, unreachable = false) {
21721
- const url2 = new URL(`https://api.github.com/repos/${this.repo}${path17}`);
21731
+ async read(path18, schema, failure2, signal, unreachable = false) {
21732
+ const url2 = new URL(`https://api.github.com/repos/${this.repo}${path18}`);
21722
21733
  try {
21723
21734
  return await getJson(this.fetchImpl, {
21724
21735
  url: url2,
@@ -21784,7 +21795,7 @@ async function inBatches(items, work, size = 8) {
21784
21795
 
21785
21796
  // src/commands/skills/SkillFiles.ts
21786
21797
  import fs3 from "fs/promises";
21787
- import path4 from "path";
21798
+ import path6 from "path";
21788
21799
  var NOISE = /* @__PURE__ */ new Set([".DS_Store"]);
21789
21800
  var NodeSkillFiles = class {
21790
21801
  async exists(dir) {
@@ -21802,7 +21813,7 @@ var NodeSkillFiles = class {
21802
21813
  await fs3.rm(dir, { recursive: true, force: true });
21803
21814
  for (const [i, file2] of files.entries()) {
21804
21815
  const target = targets[i];
21805
- await fs3.mkdir(path4.dirname(target), { recursive: true });
21816
+ await fs3.mkdir(path6.dirname(target), { recursive: true });
21806
21817
  await fs3.writeFile(target, file2.content, { mode: file2.executable ? 493 : 420 });
21807
21818
  }
21808
21819
  }
@@ -21811,9 +21822,9 @@ var NodeSkillFiles = class {
21811
21822
  }
21812
21823
  async link(dir, target) {
21813
21824
  await fs3.rm(dir, { recursive: true, force: true });
21814
- await fs3.mkdir(path4.dirname(dir), { recursive: true });
21825
+ await fs3.mkdir(path6.dirname(dir), { recursive: true });
21815
21826
  const windows = process.platform === "win32";
21816
- await fs3.symlink(windows ? target : path4.relative(path4.dirname(dir), target), dir, windows ? "junction" : "dir");
21827
+ await fs3.symlink(windows ? target : path6.relative(path6.dirname(dir), target), dir, windows ? "junction" : "dir");
21817
21828
  }
21818
21829
  };
21819
21830
  var UNREADABLE = "unreadable";
@@ -21821,7 +21832,7 @@ async function hashDirectory(dir) {
21821
21832
  const entries = [];
21822
21833
  for (const entry of await fs3.readdir(dir, { withFileTypes: true })) {
21823
21834
  if (NOISE.has(entry.name)) continue;
21824
- const absolute = path4.join(dir, entry.name);
21835
+ const absolute = path6.join(dir, entry.name);
21825
21836
  if (entry.isDirectory()) {
21826
21837
  const sha = await hashDirectory(absolute);
21827
21838
  if (sha) entries.push({ name: entry.name, mode: DIRECTORY_MODE, sha });
@@ -21839,18 +21850,18 @@ async function hashDirectory(dir) {
21839
21850
  return entries.length > 0 ? gitTreeSha(entries) : null;
21840
21851
  }
21841
21852
  function inside(dir, relative2) {
21842
- const target = path4.resolve(dir, relative2);
21843
- if (relative2.includes("\0") || path4.isAbsolute(relative2) || !target.startsWith(path4.resolve(dir) + path4.sep)) {
21853
+ const target = path6.resolve(dir, relative2);
21854
+ if (relative2.includes("\0") || path6.isAbsolute(relative2) || !target.startsWith(path6.resolve(dir) + path6.sep)) {
21844
21855
  throw new CliError(`Refusing to write ${relative2}`, `it would land outside ${tildify(dir)}`);
21845
21856
  }
21846
21857
  return target;
21847
21858
  }
21848
21859
 
21849
21860
  // src/commands/skills/SkillsCommand.ts
21850
- import path11 from "path";
21861
+ import path13 from "path";
21851
21862
 
21852
21863
  // src/commands/skills/InstallFlow.ts
21853
- import path8 from "path";
21864
+ import path10 from "path";
21854
21865
 
21855
21866
  // src/commands/skills/chooseMode.ts
21856
21867
  async function chooseLink(ui, { store }, given, linked = false) {
@@ -21867,13 +21878,13 @@ async function chooseLink(ui, { store }, given, linked = false) {
21867
21878
  }
21868
21879
 
21869
21880
  // src/commands/skills/chooseTargets.ts
21870
- import path6 from "path";
21881
+ import path8 from "path";
21871
21882
 
21872
21883
  // src/commands/skills/copies.ts
21873
- import path5 from "path";
21884
+ import path7 from "path";
21874
21885
  var EDITED = "edited since zion installed it";
21875
21886
  async function installedDirs({ files, targets }, name) {
21876
- const dirs = targets.map((target) => path5.join(target.dir, name));
21887
+ const dirs = targets.map((target) => path7.join(target.dir, name));
21877
21888
  const present = await Promise.all(dirs.map((dir) => files.exists(dir)));
21878
21889
  return dirs.filter((_, i) => present[i]);
21879
21890
  }
@@ -21911,7 +21922,7 @@ async function confirmConflicts(ui, copies, { yes: yes2, retry }) {
21911
21922
  async function writeCopies({ files, lockfile, store }, skills, copies, hidden = /* @__PURE__ */ new Map()) {
21912
21923
  for (const skill of skills) {
21913
21924
  const mine = copiesOf(skill, copies);
21914
- const home = path5.join(store, skill.name);
21925
+ const home = path7.join(store, skill.name);
21915
21926
  if (mine.some((copy) => copy.link)) await files.write(home, skill.files);
21916
21927
  for (const copy of mine) {
21917
21928
  if (copy.link) await files.link(copy.dir, home);
@@ -21945,7 +21956,7 @@ function copiesOf(skill, copies) {
21945
21956
  return copies.filter((copy) => copy.skill === skill);
21946
21957
  }
21947
21958
  function describeDirs(dirs) {
21948
- return dirs.map((dir) => tildify(path5.dirname(dir))).join(", ");
21959
+ return dirs.map((dir) => tildify(path7.dirname(dir))).join(", ");
21949
21960
  }
21950
21961
  function isNewer(latest, locked) {
21951
21962
  return Boolean(latest && locked && latest.commit !== locked.commit);
@@ -21963,7 +21974,7 @@ async function chooseTargets(ui, deps, given, lock) {
21963
21974
  return chosen;
21964
21975
  }
21965
21976
  const installed = await Promise.all(Object.keys(lock.skills).map((name) => installedDirs(deps, name)));
21966
- const used = new Set(installed.flat().map((dir) => path6.dirname(dir)));
21977
+ const used = new Set(installed.flat().map((dir) => path8.dirname(dir)));
21967
21978
  let suggested = targets.filter((target) => used.has(target.dir));
21968
21979
  if (suggested.length === 0) {
21969
21980
  const present = await Promise.all(targets.map((target) => files.exists(target.home)));
@@ -21977,12 +21988,12 @@ async function chooseTargets(ui, deps, given, lock) {
21977
21988
  });
21978
21989
  }
21979
21990
  function shown(dir) {
21980
- const relative2 = path6.relative(process.cwd(), dir);
21981
- return relative2.startsWith("..") || path6.isAbsolute(relative2) ? tildify(dir) : `./${relative2}`;
21991
+ const relative2 = path8.relative(process.cwd(), dir);
21992
+ return relative2.startsWith("..") || path8.isAbsolute(relative2) ? tildify(dir) : `./${relative2}`;
21982
21993
  }
21983
21994
 
21984
21995
  // src/commands/skills/privacy.ts
21985
- import path7 from "path";
21996
+ import path9 from "path";
21986
21997
  async function syncExclude(deps) {
21987
21998
  const { exclude, lockfile, store } = deps;
21988
21999
  if (!exclude) return [];
@@ -21990,16 +22001,16 @@ async function syncExclude(deps) {
21990
22001
  const names = Object.keys(skills);
21991
22002
  const hidden = names.filter((name) => skills[name].private);
21992
22003
  const paths = (await Promise.all(hidden.map((name) => installedDirs(deps, name)))).flat();
21993
- if (hidden.length > 0 && hidden.length === names.length) paths.push(path7.dirname(lockfile.path));
22004
+ if (hidden.length > 0 && hidden.length === names.length) paths.push(path9.dirname(lockfile.path));
21994
22005
  else {
21995
- paths.push(...hidden.filter((name) => skills[name].link).map((name) => path7.join(store, name)));
22006
+ paths.push(...hidden.filter((name) => skills[name].link).map((name) => path9.join(store, name)));
21996
22007
  if (hidden.length > 0 && lockfile.hiddenPath) paths.push(lockfile.hiddenPath);
21997
22008
  }
21998
22009
  return exclude.write(paths);
21999
22010
  }
22000
22011
  function warnTracked(ui, tracked) {
22001
22012
  if (tracked.length === 0) return;
22002
- const shown2 = tracked.map((target) => path7.relative(process.cwd(), target) || ".");
22013
+ const shown2 = tracked.map((target) => path9.relative(process.cwd(), target) || ".");
22003
22014
  ui.step({
22004
22015
  title: `${plural(tracked.length, "path")} already tracked by git`,
22005
22016
  tone: "warning",
@@ -22059,7 +22070,7 @@ var InstallFlow = class {
22059
22070
  this.deps,
22060
22071
  skill,
22061
22072
  lock.skills[skill.name],
22062
- dirs.map((dir) => path8.join(dir, skill.name)),
22073
+ dirs.map((dir) => path10.join(dir, skill.name)),
22063
22074
  link
22064
22075
  )
22065
22076
  )
@@ -22146,15 +22157,15 @@ var InstallFlow = class {
22146
22157
  };
22147
22158
 
22148
22159
  // src/commands/skills/ManageFlow.ts
22149
- import path10 from "path";
22160
+ import path12 from "path";
22150
22161
 
22151
22162
  // src/commands/skills/removals.ts
22152
- import path9 from "path";
22163
+ import path11 from "path";
22153
22164
  async function planRemovals(deps, lock, names, only) {
22154
22165
  const removals = [];
22155
22166
  for (const name of names) {
22156
22167
  for (const dir of await installedDirs(deps, name)) {
22157
- if (only && !only.has(path9.dirname(dir))) continue;
22168
+ if (only && !only.has(path11.dirname(dir))) continue;
22158
22169
  removals.push({ name, dir, edited: !isUnchanged(await deps.files.treeSha(dir), lock.skills[name].tree) });
22159
22170
  }
22160
22171
  }
@@ -22164,7 +22175,7 @@ async function applyRemovals(deps, names, removals) {
22164
22175
  for (const removal of removals) await deps.files.remove(removal.dir);
22165
22176
  for (const name of names) {
22166
22177
  if ((await installedDirs(deps, name)).length > 0) continue;
22167
- await deps.files.remove(path9.join(deps.store, name));
22178
+ await deps.files.remove(path11.join(deps.store, name));
22168
22179
  await deps.lockfile.update((data) => {
22169
22180
  delete data.skills[name];
22170
22181
  });
@@ -22238,7 +22249,7 @@ var ManageFlow = class {
22238
22249
  this.deps,
22239
22250
  skill,
22240
22251
  void 0,
22241
- targets.map((target) => path10.join(target.dir, skill.name)),
22252
+ targets.map((target) => path12.join(target.dir, skill.name)),
22242
22253
  link
22243
22254
  )
22244
22255
  )
@@ -22426,7 +22437,11 @@ var UpdateFlow = class {
22426
22437
  if (installed.length === 0) {
22427
22438
  ui.outro("No skills are installed.", {
22428
22439
  tone: "muted",
22429
- lines: [`Install some with ${ctx.bin} skills install.`]
22440
+ lines: [
22441
+ `Install some with ${ctx.bin} skills install.`,
22442
+ // Without --project or --global, this was only the project's skills.
22443
+ ...options.scope ? [] : [`Add -g to update your global skills instead.`]
22444
+ ]
22430
22445
  });
22431
22446
  return 0;
22432
22447
  }
@@ -22434,18 +22449,17 @@ var UpdateFlow = class {
22434
22449
  if (missing)
22435
22450
  throw new CliError(`${missing} isn't installed`, `install it with ${ctx.bin} skills install ${missing}`);
22436
22451
  const names = options.names.length > 0 ? [...new Set(options.names)] : installed;
22437
- const pick2 = ctx.interactive && options.names.length === 0 && !options.yes;
22438
22452
  const checks = await ui.task(
22439
22453
  `Checking ${plural(names.length, "skill")} for updates`,
22440
22454
  (signal) => this.check(names, lock.skills, signal),
22441
- (checks2) => describeChecks(ctx.paint.stderr, checks2, { listUpdates: !pick2 })
22455
+ (checks2) => describeChecks(ctx.paint.stderr, checks2)
22442
22456
  );
22443
22457
  const outdated = checks.filter(isOutdated);
22444
22458
  if (outdated.length === 0) {
22445
22459
  ui.outro(names.length === 1 ? `${names[0]} is up to date.` : "Everything is up to date.");
22446
22460
  return 0;
22447
22461
  }
22448
- const chosen = pick2 ? await this.chooseUpdates(ui, outdated) : outdated.map((check2) => check2.latest);
22462
+ const chosen = outdated.map((check2) => check2.latest);
22449
22463
  const copies = (await Promise.all(chosen.map((skill) => planCopies(this.deps, skill, lock.skills[skill.name], [])))).flat();
22450
22464
  const retry = `${ctx.bin} skills update ${options.names.join(" ")}`.trimEnd();
22451
22465
  if (!await confirmConflicts(ui, copies, { yes: options.yes, retry })) {
@@ -22477,27 +22491,15 @@ var UpdateFlow = class {
22477
22491
  })
22478
22492
  );
22479
22493
  }
22480
- async chooseUpdates(ui, outdated) {
22481
- const width = Math.max(...outdated.map((check2) => shortCommit(check2.locked.commit).length));
22482
- return ui.multiselect({
22483
- message: "Update which?",
22484
- options: outdated.map((check2) => ({
22485
- value: check2.latest,
22486
- label: check2.name,
22487
- hint: describeChange(check2.locked, check2.latest).padStart(width)
22488
- })),
22489
- initialValues: outdated.map((check2) => check2.latest)
22490
- });
22491
- }
22492
22494
  };
22493
22495
  function isOutdated(check2) {
22494
22496
  return isNewer(check2.latest, check2.locked);
22495
22497
  }
22496
- function describeChecks(paint, checks, { listUpdates }) {
22498
+ function describeChecks(paint, checks) {
22497
22499
  const updates = checks.filter(isOutdated);
22498
22500
  const gone = checks.filter((check2) => check2.gone);
22499
22501
  if (updates.length === 0 && gone.length === 0) return { title: "Up to date" };
22500
- const shown2 = [...listUpdates ? updates : [], ...gone];
22502
+ const shown2 = [...updates, ...gone];
22501
22503
  const width = Math.max(0, ...shown2.map((check2) => check2.name.length));
22502
22504
  return {
22503
22505
  title: updates.length > 0 ? `${plural(updates.length, "update")} available` : `${plural(gone.length, "skill")} no longer available`,
@@ -22511,7 +22513,7 @@ function describeChecks(paint, checks, { listUpdates }) {
22511
22513
  // src/commands/skills/actions.ts
22512
22514
  var SKILLS_ACTIONS = [
22513
22515
  { id: "install", aliases: ["add"], hint: "choose skills and where they go" },
22514
- { id: "update", aliases: ["upgrade"], hint: "get newer versions of installed skills" },
22516
+ { id: "update", aliases: ["upgrade"], hint: "update every installed skill in this project (-g for global)" },
22515
22517
  { id: "remove", aliases: ["rm", "uninstall"], hint: "delete skills zion installed" },
22516
22518
  { id: "list", aliases: ["ls"], hint: "print every skill and where it is installed" },
22517
22519
  { id: "show", aliases: [], hint: "print a skill's SKILL.md" }
@@ -22649,7 +22651,7 @@ async function showSkill({ api }, ctx, name) {
22649
22651
 
22650
22652
  // src/commands/skills/SkillsCommand.ts
22651
22653
  function relative(file2) {
22652
- return `./${path11.relative(process.cwd(), file2)}`;
22654
+ return `./${path13.relative(process.cwd(), file2)}`;
22653
22655
  }
22654
22656
  var SkillsCommand = class {
22655
22657
  constructor(base) {
@@ -22658,7 +22660,7 @@ var SkillsCommand = class {
22658
22660
  const { targets, lockfile, store } = scopes.global;
22659
22661
  this.help = {
22660
22662
  usage: "[action] [skill...] [options]",
22661
- description: `Downloads skills from ${api.host} into the folders your agents load them from, replacing each skill folder whole, or symlinking it to a copy zion keeps in its own folder. 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)} (${relative(
22663
+ description: `Downloads skills from ${api.host} into the folders your agents load them from, replacing each skill folder whole, or symlinking it to a copy zion keeps in its own folder. 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, except update, which takes this project unless you pass --global. zion records what it installed in ${tildify(lockfile.path)} (${relative(
22662
22664
  scopes.project.lockfile.path
22663
22665
  )} 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. Press p in the list to mark a skill private in a git project; zion then excludes it, and zion's whole folder once all are. Linked skills are kept in ${tildify(store)} (${tildify(scopes.project.store)} with --project).`,
22664
22666
  arguments: {
@@ -22670,7 +22672,7 @@ var SkillsCommand = class {
22670
22672
  },
22671
22673
  options: [
22672
22674
  ["-p, --project", `work in this folder, recorded in ${relative(scopes.project.lockfile.path)}`],
22673
- ["-g, --global", "work in your home directory (the default without a terminal)"],
22675
+ ["-g, --global", "work in your home directory (the default without a terminal, except for update)"],
22674
22676
  ["-t, --target <name>", `${targets.map((t) => t.id).join(" or ")}; repeat for both`],
22675
22677
  ["-l, --link", "symlink to a copy zion keeps, instead of copying into each folder (install)"],
22676
22678
  ["--copy", "copy into each folder without asking (install)"],
@@ -22678,7 +22680,7 @@ var SkillsCommand = class {
22678
22680
  ["--public", "do not keep them out of git, without asking (install)"],
22679
22681
  [
22680
22682
  "--sudo",
22681
- `read skills straight from the private ${sudoApi.host} repo, listing every folder in it, instead of from ${api.host}; needs a GitHub login that can read it`
22683
+ `read skills straight from the private ${sudoApi.host} repo, listing every skill in it, instead of from ${api.host}; needs a GitHub login that can read it`
22682
22684
  ],
22683
22685
  ["-a, --all", "every skill (install and remove)"],
22684
22686
  ["-y, --yes", "say yes to every confirmation, including replacing edited folders"],
@@ -22692,6 +22694,8 @@ var SkillsCommand = class {
22692
22694
  "skills list --sudo",
22693
22695
  "skills install --all -t agents -t claude --yes",
22694
22696
  "skills update",
22697
+ "skills update -g",
22698
+ "skills update --sudo",
22695
22699
  "skills list --json",
22696
22700
  "skills show commit | less",
22697
22701
  "skills remove commit --yes"
@@ -22717,7 +22721,7 @@ var SkillsCommand = class {
22717
22721
  const ui = base.createPrompter(ctx);
22718
22722
  return runSession(ui, async () => {
22719
22723
  ui.intro("skills", base.api.host);
22720
- const scope = options.scope ?? await this.chooseScope(ui);
22724
+ const scope = options.scope ?? (given === "update" ? "project" : await this.chooseScope(ui));
22721
22725
  const deps = this.depsFor(base, scope);
22722
22726
  const flows = { install: InstallFlow, update: UpdateFlow, remove: RemoveFlow };
22723
22727
  return given ? new flows[given](deps).run(ui, options, ctx) : new ManageFlow(deps).run(ui, ctx);
@@ -22740,26 +22744,26 @@ var SkillsCommand = class {
22740
22744
  };
22741
22745
 
22742
22746
  // src/commands/skills/targets.ts
22743
- import path12 from "path";
22747
+ import path14 from "path";
22744
22748
  function skillTargets(homedir) {
22745
22749
  return [
22746
22750
  {
22747
22751
  id: "agents",
22748
- dir: path12.join(homedir, ".agents", "skills"),
22749
- home: path12.join(homedir, ".agents"),
22752
+ dir: path14.join(homedir, ".agents", "skills"),
22753
+ home: path14.join(homedir, ".agents"),
22750
22754
  name: "Universal"
22751
22755
  },
22752
22756
  {
22753
22757
  id: "claude",
22754
- dir: path12.join(homedir, ".claude", "skills"),
22755
- home: path12.join(homedir, ".claude"),
22758
+ dir: path14.join(homedir, ".claude", "skills"),
22759
+ home: path14.join(homedir, ".claude"),
22756
22760
  name: "Claude Code"
22757
22761
  }
22758
22762
  ];
22759
22763
  }
22760
22764
 
22761
22765
  // src/services/Git.ts
22762
- import path13 from "path";
22766
+ import path15 from "path";
22763
22767
  var GitError = class extends Error {
22764
22768
  constructor(args, stderr) {
22765
22769
  super(stderr.split("\n").pop() || `git ${args.join(" ")} failed`);
@@ -22787,7 +22791,7 @@ var CliGit = class {
22787
22791
  async excludeFile(dir) {
22788
22792
  const root = await this.topLevel(dir);
22789
22793
  const file2 = root && await this.query(["-C", dir, "rev-parse", "--git-path", "info/exclude"]);
22790
- return root && file2 ? { file: path13.resolve(dir, file2), root } : null;
22794
+ return root && file2 ? { file: path15.resolve(dir, file2), root } : null;
22791
22795
  }
22792
22796
  async tracked(dir, paths) {
22793
22797
  if (paths.length === 0) return [];
@@ -22831,7 +22835,7 @@ var CliGit = class {
22831
22835
 
22832
22836
  // src/services/Lockfile.ts
22833
22837
  import fs4 from "fs/promises";
22834
- import path14 from "path";
22838
+ import path16 from "path";
22835
22839
  var VERSION = 2;
22836
22840
  var LockedSkill = external_exports.looseObject({
22837
22841
  /** The last commit in zion-off/skills that changed this skill. */
@@ -22850,8 +22854,8 @@ var LockData = external_exports.looseObject({
22850
22854
  });
22851
22855
  var Versioned = jsonText(external_exports.looseObject({ version: external_exports.number() }));
22852
22856
  var JsonLockfile = class {
22853
- constructor(path17) {
22854
- this.path = path17;
22857
+ constructor(path18) {
22858
+ this.path = path18;
22855
22859
  }
22856
22860
  path;
22857
22861
  async read() {
@@ -22883,7 +22887,7 @@ var JsonLockfile = class {
22883
22887
  return data.data;
22884
22888
  }
22885
22889
  async write(data) {
22886
- await fs4.mkdir(path14.dirname(this.path), { recursive: true });
22890
+ await fs4.mkdir(path16.dirname(this.path), { recursive: true });
22887
22891
  const temporary = `${this.path}.${process.pid}.tmp`;
22888
22892
  try {
22889
22893
  await fs4.writeFile(temporary, JSON.stringify(data, null, 2) + "\n");
@@ -22900,16 +22904,16 @@ var JsonLockfile = class {
22900
22904
  );
22901
22905
  }
22902
22906
  };
22903
- function describeIssue({ path: path17, code }) {
22904
- if (path17.length === 0) return code === "custom" ? "it is not valid JSON" : "it is not an object";
22905
- if (path17[0] === "version") return `its version isn't ${VERSION}`;
22906
- return `"${path17.join(".")}" is not valid`;
22907
+ function describeIssue({ path: path18, code }) {
22908
+ if (path18.length === 0) return code === "custom" ? "it is not valid JSON" : "it is not an object";
22909
+ if (path18[0] === "version") return `its version isn't ${VERSION}`;
22910
+ return `"${path18.join(".")}" is not valid`;
22907
22911
  }
22908
22912
  var SplitLockfile = class {
22909
- constructor(path17, hiddenPath) {
22910
- this.path = path17;
22913
+ constructor(path18, hiddenPath) {
22914
+ this.path = path18;
22911
22915
  this.hiddenPath = hiddenPath;
22912
- this.shared = new JsonLockfile(path17);
22916
+ this.shared = new JsonLockfile(path18);
22913
22917
  this.local = new JsonLockfile(hiddenPath);
22914
22918
  }
22915
22919
  path;
@@ -22989,14 +22993,6 @@ var NodeProcessRunner = class {
22989
22993
  }
22990
22994
  };
22991
22995
 
22992
- // src/services/xdg.ts
22993
- import os2 from "os";
22994
- import path15 from "path";
22995
- function stateHome(env) {
22996
- const base = env.XDG_STATE_HOME;
22997
- return base && path15.isAbsolute(base) ? base : path15.join(os2.homedir(), ".local", "state");
22998
- }
22999
-
23000
22996
  // src/cli.tsx
23001
22997
  for (const stream of [process.stdout, process.stderr]) {
23002
22998
  stream.on("error", (error62) => {
@@ -23012,7 +23008,7 @@ var registry2 = new CommandRegistry().register(
23012
23008
  slug: "zion-off/dotfiles",
23013
23009
  url: "https://github.com/zion-off/dotfiles.git",
23014
23010
  installer: "bin/dot",
23015
- installerLink: path16.join(os3.homedir(), ".local", "bin", "dot")
23011
+ installerLink: path17.join(os3.homedir(), ".local", "bin", "dot")
23016
23012
  }),
23017
23013
  git,
23018
23014
  runner,
@@ -23028,17 +23024,17 @@ var registry2 = new CommandRegistry().register(
23028
23024
  files: new NodeSkillFiles(),
23029
23025
  scopes: {
23030
23026
  global: {
23031
- lockfile: new JsonLockfile(path16.join(stateHome(process.env), "zion", "zion.json")),
23027
+ lockfile: new JsonLockfile(path17.join(stateHome(process.env), "zion", "zion.json")),
23032
23028
  targets: skillTargets(os3.homedir()),
23033
- store: path16.join(stateHome(process.env), "zion", "skills")
23029
+ store: path17.join(stateHome(process.env), "zion", "skills")
23034
23030
  },
23035
23031
  project: {
23036
23032
  lockfile: new SplitLockfile(
23037
- path16.join(process.cwd(), ".zion", "zion.json"),
23038
- path16.join(process.cwd(), ".zion", "private.json")
23033
+ path17.join(process.cwd(), ".zion", "zion.json"),
23034
+ path17.join(process.cwd(), ".zion", "private.json")
23039
23035
  ),
23040
23036
  targets: skillTargets(process.cwd()),
23041
- store: path16.join(process.cwd(), ".zion", "skills"),
23037
+ store: path17.join(process.cwd(), ".zion", "skills"),
23042
23038
  exclude: new GitExclude(git, process.cwd())
23043
23039
  }
23044
23040
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zion",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "description": "my site, dotfiles, agent skills and more, in your terminal",
5
5
  "license": "MIT",
6
6
  "repository": {