@zabuti/tools 0.1.9 → 0.1.10

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.
@@ -19,9 +19,11 @@ const USAGE = `zabuti-tools: install the licensed Zabuti developer tools
19
19
  Files you have changed are never overwritten: an update keeps yours and saves the new
20
20
  version to ~/.zabuti/updates/<skill>/ with a prompt for Claude Code to merge it.
21
21
 
22
- Options: --dry-run (show what would change, write nothing), --out=<folder> (install there instead),
22
+ Options: --dry-run (add/update: show what would change, write nothing)
23
+ --out=<folder> (add: install there instead)
23
24
  --overwrite (add/update: take the new versions even where you changed a file;
24
- the copy it replaces is kept for rollback)`;
25
+ the copy it replaces is kept for rollback)
26
+ An option a command doesn't take stops it before anything is written.`;
25
27
  function die(msg) {
26
28
  console.error(`zabuti-tools: ${msg}`);
27
29
  process.exit(1);
@@ -31,6 +33,25 @@ const flags = new Set(args.filter((a) => a.startsWith("--")));
31
33
  const outDir = args.find((a) => a.startsWith("--out="))?.slice(6);
32
34
  const positionals = args.filter((a) => !a.startsWith("--"));
33
35
  const [command, name] = positionals;
36
+ // Flags each command understands. Anything else stops the run, so a misspelled or
37
+ // unsupported flag (say --dry-run where it isn't supported) never goes ignored while
38
+ // the command writes.
39
+ const ALLOWED = {
40
+ login: [],
41
+ add: ["--dry-run", "--out=", "--overwrite"],
42
+ update: ["--dry-run", "--overwrite"],
43
+ rollback: [],
44
+ status: [],
45
+ help: [],
46
+ };
47
+ const known = command === undefined ? ["--version", "--help"] : ALLOWED[command];
48
+ if (known) {
49
+ const bad = args.filter((a) => a.startsWith("--") && !known.some((k) => (k.endsWith("=") ? a.startsWith(k) && a.length > k.length : a === k)));
50
+ if (bad.length) {
51
+ const label = command ?? "zabuti-tools";
52
+ die(`${label}: ${bad.map((b) => `"${b}"`).join(", ")} ${bad.length > 1 ? "aren't options" : "isn't an option"} here; nothing was changed.${known.length ? ` ${label} takes: ${known.map((k) => (k.endsWith("=") ? `${k}<folder>` : k)).join(", ")}.` : ""}`);
53
+ }
54
+ }
34
55
  try {
35
56
  switch (command) {
36
57
  case "login":
@@ -46,7 +67,7 @@ try {
46
67
  if ((name && !SKILL_NAMES.includes(name)) || positionals.length > 2) {
47
68
  die(`update: name one skill (${SKILL_NAMES.join(" or ")}) or none to update all installed ones.`);
48
69
  }
49
- await cmdUpdate(name, flags.has("--overwrite"));
70
+ await cmdUpdate(name, flags.has("--overwrite"), flags.has("--dry-run"));
50
71
  break;
51
72
  case "rollback":
52
73
  if (!name || !SKILL_NAMES.includes(name) || positionals.length > 2) {
@@ -228,7 +228,7 @@ async function updateAvailable(name, m, token) {
228
228
  }
229
229
  }
230
230
  /** Update the named skill, or every installed one, only where zabuti.com has a newer copy. */
231
- export async function cmdUpdate(name, overwrite = false) {
231
+ export async function cmdUpdate(name, overwrite = false, dryRun = false) {
232
232
  const token = storedToken();
233
233
  if (!token)
234
234
  throw new Error("not signed in. Make a token at zabuti.com/account, then run `zabuti-tools login <token>`.");
@@ -237,9 +237,12 @@ export async function cmdUpdate(name, overwrite = false) {
237
237
  console.log("No Zabuti skills are installed. Install one with `zabuti-tools add <skill>`.");
238
238
  return;
239
239
  }
240
+ if (dryRun)
241
+ console.log("Dry run: nothing will be written.");
240
242
  for (const n of names) {
241
243
  const root = skillRoot(n);
242
- migrateLegacyBackup(root, previousDir(root, n));
244
+ if (!dryRun)
245
+ migrateLegacyBackup(root, previousDir(root, n));
243
246
  const m = readManifest(root);
244
247
  const avail = m ? await updateAvailable(n, m, token) : true;
245
248
  if (avail === false)
@@ -247,8 +250,10 @@ export async function cmdUpdate(name, overwrite = false) {
247
250
  else if (typeof avail === "string")
248
251
  console.log(`${n}: skipped (${avail}).`);
249
252
  else
250
- await cmdAddSkill(n, false, undefined, overwrite);
253
+ await cmdAddSkill(n, dryRun, undefined, overwrite);
251
254
  }
255
+ if (dryRun)
256
+ console.log("Dry run: nothing was written. Run the same command without --dry-run to apply it.");
252
257
  }
253
258
  /** Swap the installed copy with the kept previous one. Running it again swaps back. */
254
259
  export function cmdRollback(name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zabuti/tools",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Installs the licensed Zabuti developer tools (Logic Map, Logic Optimizer, Deadlock Map, Resource Drain Map) as Claude Code skills. Needs a license and a download token from zabuti.com.",
5
5
  "homepage": "https://zabuti.com",
6
6
  "license": "MIT",