@artifactshare/cli 0.20.1 → 0.20.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to `@artifactshare/cli` are documented here.
4
4
  For user-facing announcements, see https://artifactshare.com/updates?product=cli.
5
5
 
6
+ ## 0.20.2 - 2026-10-28
7
+
8
+ - Preserve newer managed skills during install unless force explicitly requests a downgrade.
9
+ - Skip unmanaged folders with protected-path links during update and removal (`skipped_unmanaged`), without reading their referents or reporting a list/doctor conflict.
10
+ - Preserve user-added skill links and report them in list/doctor; isolate protected-link conflicts so other selected targets finish.
11
+ - Never recommend downgrading newer installed skills; require explicit force and describe the downgrade.
12
+ - Clarify Japanese interrupted-update cleanup guidance and skill JSON partial failures.
13
+
6
14
  ## 0.20.1 - 2026-10-28
7
15
 
8
16
  - Support skill folder and ancestor directory symlinks, deduplicate shared destinations, and expose selected aliases and resolved folder paths in JSON. Internal file and directory links remain refused, including SKILL.md.
package/README.md CHANGED
@@ -82,29 +82,29 @@ project's Slack channel must be reauthorized.
82
82
 
83
83
  ## Commands
84
84
 
85
- | Command | What it does |
86
- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
87
- | `open <target>` | First command for agents opening a share or artifactshareusercontent.com execution URL; ensures skills, then reads or suggests download |
88
- | `share <path>` | Share a file or folder as a new shared file (`--project`, `--home`, `--visibility`, `--key`, link expiry options) |
89
- | `update <target> <path>` | Add a new version to an existing file (ID or share URL); optional `--label` adds a version note |
90
- | `append <target> <path>` | Append a non-empty UTF-8 file without a separator: at Markdown source end or before `</body>` in HTML, falling back to source end |
91
- | `edit <target>` | Change title, sharing, link expiry, explicit viewers, or project placement |
92
- | `delete <target>` | Permanently delete a file you shared |
93
- | `artifacts delete <target>` | Alias of delete; permanently delete a file you shared |
94
- | `resolve <value>` | Find files by URL, ID, title, or project name |
95
- | `artifacts get <target>` | Read a file's content and metadata back |
96
- | `download <target>` | Save a file or a whole static site locally |
97
- | `comments list / post / edit / resolve / reopen / delete <target>` | Read, write, edit, resolve, reopen, and permanently delete comments |
98
- | `projects list / create / edit` | List eligible project destinations; create and edit projects and audience |
99
- | `move <target>` | Move an existing file into a project or back home; `edit` is preferred for new automation |
100
- | `preview <file>` (alias of `preview start`) | Serve a local Markdown or HTML file with the product viewer look for browser annotation; local only, no sign-in, nothing uploaded |
101
- | `preview next` / `preview done` / `preview reply` / `preview stop` | Agent loop for a live preview: poll submitted annotation batches, report fixed/skipped outcomes from stdin, reply into a thread, and stop the session |
102
- | `login` / `logout` / `whoami` | Sign in, revoke a device-login credential before removing it locally, and check who you are |
103
- | `doctor` | Diagnose token storage, auth, destination, network, and upload readiness — tells you the next command to run |
104
- | `changelog` | Show the installed version, this release's notes, and the public updates page |
105
- | `profiles list / use / import-token / delete` | Switch between local account profiles, import an issued token from stdin, and delete profile entries |
106
- | `init` | Set up this directory: detect Claude Code, Codex, or Cursor and install the full skill folder in user scope (migrating managed legacy Cursor project rules), then show next steps; or save defaults with `--profile` / `--project-id` |
107
- | `skills ensure / install / list / update / remove` | Install or update the bundled usage guide; shared directory aliases are handled once, internal links are refused; Claude user scope follows CLAUDE_CONFIG_DIR (blank values are unavailable) |
85
+ | Command | What it does |
86
+ | ------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
87
+ | `open <target>` | First command for agents opening a share or artifactshareusercontent.com execution URL; ensures skills, then reads or suggests download |
88
+ | `share <path>` | Share a file or folder as a new shared file (`--project`, `--home`, `--visibility`, `--key`, link expiry options) |
89
+ | `update <target> <path>` | Add a new version to an existing file (ID or share URL); optional `--label` adds a version note |
90
+ | `append <target> <path>` | Append a non-empty UTF-8 file without a separator: at Markdown source end or before `</body>` in HTML, falling back to source end |
91
+ | `edit <target>` | Change title, sharing, link expiry, explicit viewers, or project placement |
92
+ | `delete <target>` | Permanently delete a file you shared |
93
+ | `artifacts delete <target>` | Alias of delete; permanently delete a file you shared |
94
+ | `resolve <value>` | Find files by URL, ID, title, or project name |
95
+ | `artifacts get <target>` | Read a file's content and metadata back |
96
+ | `download <target>` | Save a file or a whole static site locally |
97
+ | `comments list / post / edit / resolve / reopen / delete <target>` | Read, write, edit, resolve, reopen, and permanently delete comments |
98
+ | `projects list / create / edit` | List eligible project destinations; create and edit projects and audience |
99
+ | `move <target>` | Move an existing file into a project or back home; `edit` is preferred for new automation |
100
+ | `preview <file>` (alias of `preview start`) | Serve a local Markdown or HTML file with the product viewer look for browser annotation; local only, no sign-in, nothing uploaded |
101
+ | `preview next` / `preview done` / `preview reply` / `preview stop` | Agent loop for a live preview: poll submitted annotation batches, report fixed/skipped outcomes from stdin, reply into a thread, and stop the session |
102
+ | `login` / `logout` / `whoami` | Sign in, revoke a device-login credential before removing it locally, and check who you are |
103
+ | `doctor` | Diagnose token storage, auth, destination, network, and upload readiness — tells you the next command to run |
104
+ | `changelog` | Show the installed version, this release's notes, and the public updates page |
105
+ | `profiles list / use / import-token / delete` | Switch between local account profiles, import an issued token from stdin, and delete profile entries |
106
+ | `init` | Set up this directory: detect Claude Code, Codex, or Cursor and install the full skill folder in user scope (migrating managed legacy Cursor project rules), then show next steps; or save defaults with `--profile` / `--project-id` |
107
+ | `skills ensure / install / list / update / remove` | Install or update the bundled usage guide; shared directory aliases are handled once, unmanaged folders are skipped, protected links refused for mutations, and newer installed versions preserved unless forced; Claude user scope follows CLAUDE_CONFIG_DIR (blank values are unavailable) |
108
108
 
109
109
  Public command paths covered by this reference:
110
110
 
@@ -509,6 +509,10 @@ Writes stage files in a private directory, replace references, retire owned file
509
509
 
510
510
  Project Cursor targets also report `legacy_rule` with path, present, managed, coexistence and hint. Managed `.cursor/rules/artifactshare.mdc` files migrate only after the skill folder succeeds, including during automatic setup/update. This is the only project-scope automatic migration; a user-owned rule never authorizes installation. User-owned rules remain with inspection/manual-removal guidance. Actions add folder_path and optional legacy_rule action (removed/would_remove/kept_unmanaged/remove_failed). Dry runs do not write; failed cleanup includes retry guidance. Project removal handles both managed forms.
511
511
 
512
- Skill folders and their configured ancestors may be directory symlinks. The CLI resolves the folder with realpath and handles each shared destination once, in Codex, Claude, Cursor order (project before user); the first selected alias supplies the legacy fields. JSON target rows include `aliases` (tool, scope, path, folder_path) and `resolved_folder_path`. Explicit filters include only selected aliases. Internal links, including SKILL.md, references and the manifest, are refused even with force. Restore dangling links to a directory; preserve edits and replace internal links with ordinary content before retrying. A missing skill beneath a dangling ancestor is reported as not installed, with the broken ancestor path, and does not block other targets. Link and layout conflicts provide repair hints without a force command. Removal preserves configured links and their destination directory.
512
+ Skill folders and their configured ancestors may be directory symlinks. The CLI resolves the folder with realpath and handles each shared destination once, in Codex, Claude, Cursor order (project before user); the first selected alias supplies the legacy fields. JSON target rows include `aliases` (tool, scope, path, folder_path) and `resolved_folder_path`. Explicit filters include only selected aliases. User-added links outside bundled, manifest-listed, pending-intent-listed and reserved CLI paths are ignored without following them; doctor and skills list report their sorted folder-relative paths in `user_links`. For managed folders and forced installs, links at protected paths, including SKILL.md, references and CLI metadata, are refused even with force. Folders without ownership records or a managed skill or legacy rule remain unmanaged: update and remove report `skipped_unmanaged`, even with SKILL.md or references links. List and doctor report them as unmanaged without reading link referents. Replace the named link with a regular file or directory or remove it before retrying. A missing skill beneath a dangling ancestor is reported as not installed, with the broken ancestor path, and does not block other targets. Link and layout conflicts provide repair hints without a force command. Removal preserves configured links, ignored user links and their containing directory.
513
513
 
514
- Writes prefer a private sibling `.artifactshare-staging-<uuid>` directory. If the parent is not writable or a commit crosses filesystems, the CLI stages inside the skill folder instead and still commits files by rename. Real install, update, ensure and automatic updates clean reserved staging directories and exact UUID-shaped `.artifactshare-<uuid>.tmp` regular files only when their modification times are more than ten minutes old before checking conflicts, including no-op selections. Diagnostics and dry runs never clean files. Unrelated names and symlink referents are never deleted. Failed writes roll back committed paths and remove staging; interrupted processes leave debris for the next mutation.
514
+ Without tool filters, update/remove continue healthy targets after a conflict. Partial failures keep the `ok: true` stdout envelope with `data.targets`, report `action: "failed"`, `code: "skill_update_conflict"` and `hint` for the failed target, and exit with status 1. Explicit unsafe target selections retain the `ok: false` error envelope.
515
+
516
+ When a newer CLI installed the managed version, list/doctor report `update_available: false` and a `hint` containing "A newer CLI installed", with no update recommendation. Unforced skills install and skills update preserve the entire target, including temporary files and legacy rules. Explicit `--force` permits a downgrade, reported with both versions in `hint`; `--dry-run --force` reports the same intent without writing. Protected links and newer pending intents still refuse force.
517
+
518
+ Writes prefer a private sibling `.artifactshare-staging-<uuid>` directory. If the parent is not writable or a commit crosses filesystems, the CLI stages inside the skill folder instead and still commits files by rename. Real install, update, ensure and automatic updates clean reserved staging directories and exact UUID-shaped `.artifactshare-<uuid>.tmp` regular files only when their modification times are more than ten minutes old before checking conflicts, including no-op selections except newer installed versions skipped by skills install or skills update. Diagnostics and dry runs never clean files. Unrelated names and symlink referents are never deleted. Failed writes roll back committed paths and remove staging; interrupted processes leave debris for the next mutation.
package/dist/cli.js CHANGED
@@ -734,6 +734,7 @@ const LocalSkillTargetSchema = z.object({
734
734
  missing_files: z.array(z.string()),
735
735
  different_files: z.array(z.string()),
736
736
  modified_files: z.array(z.string()),
737
+ user_links: z.array(z.string()).optional(),
737
738
  interrupted_update: z.boolean().optional(),
738
739
  ownership_manifest: z.enum([
739
740
  "valid",
@@ -787,6 +788,7 @@ const SkillsActionTargetSchema = z.object({
787
788
  "removed",
788
789
  "not_installed",
789
790
  "skipped_unmanaged",
791
+ "failed",
790
792
  "skipped"
791
793
  ]),
792
794
  update_command: z.string().optional(),
@@ -4299,20 +4301,63 @@ const uuid = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
4299
4301
  const legacyTemp = new RegExp(`^\\.artifactshare-${uuid}\\.tmp$`, "i");
4300
4302
  const stagingName = new RegExp(`^\\.artifactshare-staging-${uuid}$`, "i");
4301
4303
  const stale = (item) => item.mtimeMs < Date.now() - 6e5;
4302
- async function inspectTree(root, cleanup = false, folderRoot = root) {
4303
- if (!await info(root)) return;
4304
- for (const name of await readdir(root)) {
4304
+ async function protectedPaths(root, bundle) {
4305
+ await safe(root, MANIFEST);
4306
+ await safe(root, PENDING);
4307
+ const state = await stateAt(root);
4308
+ const pending = await ownership(root, state, PENDING);
4309
+ const owned = await ownership(root, state, MANIFEST, pending.manifest);
4310
+ const paths = /* @__PURE__ */ new Set([
4311
+ "SKILL.md",
4312
+ "references",
4313
+ MANIFEST,
4314
+ PENDING
4315
+ ]);
4316
+ for (const path of [
4317
+ ...Object.keys(bundle?.files ?? {}),
4318
+ ...Object.keys(owned.manifest?.files ?? {}),
4319
+ ...Object.keys(pending.manifest?.files ?? {}),
4320
+ ...Object.keys(pending.manifest?.previous_files ?? {})
4321
+ ]) {
4322
+ const parts = path.split("/");
4323
+ for (let i = 1; i <= parts.length; i++) paths.add(parts.slice(0, i).join("/"));
4324
+ }
4325
+ return paths;
4326
+ }
4327
+ async function isProtectedLink(root, item, protectedEntries, lookup = info) {
4328
+ for (const entry of protectedEntries) {
4329
+ let path = root;
4330
+ for (const part of entry.split("/")) {
4331
+ path = join(path, part);
4332
+ const candidate = await lookup(path);
4333
+ if (!candidate) break;
4334
+ if (candidate.dev === item.dev && candidate.ino === item.ino) return true;
4335
+ if (!candidate.isDirectory()) break;
4336
+ }
4337
+ }
4338
+ return false;
4339
+ }
4340
+ async function inspectTree(root, cleanup = false, folderRoot = root, protectedEntries, userLinks = []) {
4341
+ if (!await info(root)) return userLinks;
4342
+ for (const name of (await readdir(root)).sort()) {
4305
4343
  const path = join(root, name);
4306
4344
  const item = await lstat(path);
4307
- if (item.isSymbolicLink()) throw new Error(`Unsafe skill path (link): ${path}. Preserve edits and replace the internal link with ordinary bundled content, then retry.`);
4345
+ if (item.isSymbolicLink()) {
4346
+ const entry = relative(folderRoot, path).split(sep).join("/");
4347
+ if (protectedEntries && (protectedEntries.has(entry) || await isProtectedLink(folderRoot, item, protectedEntries) || name === MANIFEST || name === PENDING || stagingName.test(name) || legacyTemp.test(name))) throw new Error(`Unsafe skill path (link): ${entry}. Replace the link with a regular file or directory or remove it, then retry.`);
4348
+ userLinks.push(entry);
4349
+ continue;
4350
+ }
4308
4351
  if (item.isDirectory() && root === folderRoot && stagingName.test(name)) {
4309
- if (cleanup && stale(item)) await rm(path, {
4352
+ await inspectTree(path, false, folderRoot, protectedEntries, userLinks);
4353
+ if (cleanup && stale(item) && !userLinks.some((link) => link.startsWith(`${name}/`))) await rm(path, {
4310
4354
  recursive: true,
4311
4355
  force: true
4312
4356
  });
4313
- } else if (item.isDirectory()) await inspectTree(path, cleanup, folderRoot);
4357
+ } else if (item.isDirectory()) await inspectTree(path, cleanup, folderRoot, protectedEntries, userLinks);
4314
4358
  else if (cleanup && item.isFile() && legacyTemp.test(name) && stale(item)) await unlink(path);
4315
4359
  }
4360
+ return userLinks.sort();
4316
4361
  }
4317
4362
  async function cleanupSkillFolder(entry, bundle) {
4318
4363
  const root = await rootFor(entry);
@@ -4320,7 +4365,9 @@ async function cleanupSkillFolder(entry, bundle) {
4320
4365
  const pending = await ownership(root, await stateAt(root), PENDING);
4321
4366
  if (pending.manifest && pending.manifest.version > bundle.version) throw new Error(newerIntentHint(pending.manifest.version));
4322
4367
  }
4323
- await inspectTree(root, true);
4368
+ const protection = await protectedPaths(root, bundle);
4369
+ await inspectTree(root, false, root, protection);
4370
+ await inspectTree(root, true, root, protection);
4324
4371
  const parent = dirname(root);
4325
4372
  if (await info(parent)) for (const name of await readdir(parent)) {
4326
4373
  if (!stagingName.test(name)) continue;
@@ -4341,7 +4388,7 @@ async function safe(root, relative, retiredAncestors = /* @__PURE__ */ new Set()
4341
4388
  const item = await info(parts[i]);
4342
4389
  if (i < parts.length - 1 && item?.isFile() && retiredAncestors.has(parts[i])) return;
4343
4390
  if (i === parts.length - 1 && item?.isDirectory() && replacedDirectories.has(parts[i])) continue;
4344
- if (item && (item.isSymbolicLink() || (i === parts.length - 1 ? !item.isFile() : !item.isDirectory()))) throw new Error(`Unsafe skill path (type change or link): ${parts[i]}. Preserve edits and replace internal links with ordinary bundled content, then retry.`);
4391
+ if (item && (item.isSymbolicLink() || (i === parts.length - 1 ? !item.isFile() : !item.isDirectory()))) throw new Error(`Unsafe skill path (type change or link): ${parts[i]}. Replace the link with a regular file or directory or remove it, then retry.`);
4345
4392
  }
4346
4393
  }
4347
4394
  async function bytesAt(root, path) {
@@ -4354,8 +4401,26 @@ async function bytesAt(root, path) {
4354
4401
  async function textAt(root, path) {
4355
4402
  return (await bytesAt(root, path))?.toString("utf8") ?? null;
4356
4403
  }
4404
+ async function recordsAbsent(root) {
4405
+ return !await info(join(root, MANIFEST)) && !await info(join(root, PENDING));
4406
+ }
4407
+ async function unownedAt(root) {
4408
+ if (!await recordsAbsent(root)) return false;
4409
+ const entry = await info(join(root, "SKILL.md"));
4410
+ if (!entry || entry.isSymbolicLink()) return true;
4411
+ return (await stateAt(root)).kind === "unmanaged";
4412
+ }
4413
+ async function isUnownedFolder(entry, managedLegacy = false) {
4414
+ if (managedLegacy) return false;
4415
+ try {
4416
+ return await unownedAt(await rootFor(entry));
4417
+ } catch {
4418
+ return false;
4419
+ }
4420
+ }
4357
4421
  async function stateAt(root) {
4358
4422
  try {
4423
+ if ((await info(join(root, "SKILL.md")))?.isSymbolicLink() && await recordsAbsent(root)) return { kind: "unmanaged" };
4359
4424
  return managedState(await textAt(root, "SKILL.md"));
4360
4425
  } catch {
4361
4426
  return { kind: "broken" };
@@ -4436,11 +4501,12 @@ async function recoveryOwnership(root, state) {
4436
4501
  recorded
4437
4502
  };
4438
4503
  }
4439
- async function folderDiagnostics(entry, bundle) {
4504
+ async function folderDiagnostics(entry, bundle, managedLegacy = false) {
4440
4505
  let root = null;
4506
+ let user_links = [];
4441
4507
  try {
4442
4508
  root = await rootFor(entry);
4443
- await inspectTree(root);
4509
+ user_links = await inspectTree(root, false, root, !managedLegacy && await unownedAt(root) ? void 0 : await protectedPaths(root, bundle));
4444
4510
  } catch (error) {
4445
4511
  return {
4446
4512
  folder_path: dirname(entry),
@@ -4479,6 +4545,7 @@ async function folderDiagnostics(entry, bundle) {
4479
4545
  current: state.kind === "managed" && state.version === bundle.version && !missing_files.length && !different_files.length && owned.status === "valid" && manifestMatches && pending.status === "absent",
4480
4546
  ...pending.status !== "absent" ? { interrupted_update: true } : {},
4481
4547
  older_version: state.kind === "managed" && state.version < bundle.version,
4548
+ user_links,
4482
4549
  missing_files,
4483
4550
  different_files,
4484
4551
  modified_files,
@@ -4489,13 +4556,13 @@ async function folderDiagnostics(entry, bundle) {
4489
4556
  function newerIntentHint(version) {
4490
4557
  return `Interrupted skill update requires a newer CLI with bundled skill version ${version} or later. Upgrade the CLI, then retry.`;
4491
4558
  }
4492
- async function preflightFolder(entry, bundle, force = false, forceRetirement = force) {
4559
+ async function preflightFolder(entry, bundle, force = false, forceRetirement = force, removing = false) {
4493
4560
  const root = await rootFor(entry);
4494
4561
  const state = await stateAt(root);
4495
- await inspectTree(root);
4562
+ await inspectTree(root, false, root, await protectedPaths(root, bundle));
4496
4563
  await safe(root, "SKILL.md");
4497
4564
  const { owned, pending, recorded } = await recoveryOwnership(root, state);
4498
- if (bundle && pending.manifest && pending.manifest.version > bundle.version) throw new Error(newerIntentHint(pending.manifest.version));
4565
+ if (!removing && bundle && pending.manifest && pending.manifest.version > bundle.version) throw new Error(newerIntentHint(pending.manifest.version));
4499
4566
  if ((owned.status === "invalid" || pending.status === "invalid") && !force || !force && state.kind !== "managed" && state.kind !== "missing") throw new Error(`Skill ownership conflict: ${join(root, state.kind === "managed" ? MANIFEST : "SKILL.md")} (${state.kind === "managed" ? "invalid ownership metadata" : "user-edited file"}). Inspect the folder and use skills install --force to reinstall bundled paths.`);
4500
4567
  const previous = recorded;
4501
4568
  await safe(root, PENDING);
@@ -4522,7 +4589,7 @@ async function preflightFolder(entry, bundle, force = false, forceRetirement = f
4522
4589
  }
4523
4590
  replacedDirectories.add(join(root, relative));
4524
4591
  };
4525
- for (const path of Object.keys(bundle?.files ?? {})) {
4592
+ for (const path of Object.keys(removing ? {} : bundle?.files ?? {})) {
4526
4593
  if (!blockers.some((ancestor) => path.startsWith(`${ancestor}/`))) {
4527
4594
  await safe(root, path, retiredAncestors, /* @__PURE__ */ new Set([join(root, path)]));
4528
4595
  if ((await info(join(root, path)))?.isDirectory()) await checkDirectory(path);
@@ -4674,8 +4741,8 @@ async function writeSkillFolder(entry, bundle, force = false, forceRetirement =
4674
4741
  for (const dir of [...createdDirectories].reverse()) await rmdir(dir).catch(() => {});
4675
4742
  }
4676
4743
  }
4677
- async function removeSkillFolder(entry, retainRoot = false) {
4678
- const { root, previous } = await preflightFolder(entry);
4744
+ async function removeSkillFolder(entry, retainRoot = false, bundle) {
4745
+ const { root, previous } = await preflightFolder(entry, bundle, false, false, true);
4679
4746
  for (const path of [
4680
4747
  ...Object.keys(previous),
4681
4748
  MANIFEST,
@@ -4765,10 +4832,10 @@ async function groupTargets(targets) {
4765
4832
  }
4766
4833
  return result;
4767
4834
  }
4768
- async function conflictFor(target) {
4835
+ async function conflictFor(target, removing = false) {
4769
4836
  const error = skillUpdateConflictError(target.path);
4770
4837
  try {
4771
- await preflightFolder(target.absolutePath);
4838
+ await preflightFolder(target.absolutePath, await loadBundledSkills(), false, false, removing);
4772
4839
  } catch (cause) {
4773
4840
  error.hint = cause.message;
4774
4841
  }
@@ -4884,11 +4951,23 @@ async function legacyManagedVersion(target) {
4884
4951
  const state = managedState(await readFile(legacy.path, "utf8"));
4885
4952
  return state.kind === "managed" ? state.version : void 0;
4886
4953
  }
4954
+ function isNewer(state, bundle) {
4955
+ return state.kind === "managed" && state.version > bundle.version;
4956
+ }
4957
+ function newerCliHint(installed, bundled) {
4958
+ return `A newer CLI installed skill version ${installed}; this CLI bundles version ${bundled}. Keeping the installed version. Use --force only for an intentional downgrade.`;
4959
+ }
4960
+ function downgradeHint(installed, bundled) {
4961
+ return `Intentional downgrade from skill version ${installed} to bundled version ${bundled}.`;
4962
+ }
4887
4963
  async function diagnostic(target, bundle) {
4888
4964
  const legacy = await legacyRule(target);
4965
+ const state = await readTarget(target);
4966
+ const details = await folderDiagnostics(target.absolutePath, bundle, legacy?.managed);
4889
4967
  return {
4890
- ...await folderDiagnostics(target.absolutePath, bundle),
4968
+ ...details,
4891
4969
  folder_path: dirname(target.path),
4970
+ ...isNewer(state, bundle) ? { hint: [details.hint, newerCliHint(state.version, bundle.version)].filter(Boolean).join(" ") } : {},
4892
4971
  ...legacy ? { legacy_rule: legacy } : {}
4893
4972
  };
4894
4973
  }
@@ -4987,6 +5066,7 @@ function targetPathKey(target) {
4987
5066
  return resolveSkillFolder(target.absolutePath).catch(() => target.absolutePath);
4988
5067
  }
4989
5068
  async function prepareAction(item, dryRun) {
5069
+ if (item.preserve || item.action === "failed") return;
4990
5070
  if (!dryRun && (item.content || item.action === "unchanged")) await cleanupTarget(item.target, item.content ?? await loadBundledSkills());
4991
5071
  if (item.content) {
4992
5072
  if (item.automatic) {
@@ -4995,7 +5075,7 @@ async function prepareAction(item, dryRun) {
4995
5075
  }
4996
5076
  await preflightFolder(item.target.absolutePath, item.content, item.force, item.forceRetirement);
4997
5077
  }
4998
- if (item.action === "removed") await preflightFolder(item.target.absolutePath);
5078
+ if (item.action === "removed") await preflightFolder(item.target.absolutePath, await loadBundledSkills(), false, false, true);
4999
5079
  const legacy = await legacyRule(item.target);
5000
5080
  if (legacy?.managed && item.action === "unchanged" && !await isCurrent(item.target, await loadBundledSkills())) {
5001
5081
  item.action = "update_recommended";
@@ -5014,8 +5094,9 @@ async function prepareAction(item, dryRun) {
5014
5094
  }
5015
5095
  }
5016
5096
  async function applyAction(item) {
5097
+ if (item.preserve || item.action === "failed") return;
5017
5098
  if (item.content) await writeSkillFolder(item.target.absolutePath, item.content, item.force, item.forceRetirement, false);
5018
- if (item.action === "removed") await removeSkillFolder(item.target.absolutePath, aliases(item.target).length > 1);
5099
+ if (item.action === "removed") await removeSkillFolder(item.target.absolutePath, aliases(item.target).length > 1, await loadBundledSkills());
5019
5100
  if (item.legacy?.action === "removed") try {
5020
5101
  await unlink(item.legacy.path);
5021
5102
  } catch {
@@ -5030,7 +5111,10 @@ function skillUpdateCommand(target) {
5030
5111
  return `${CLI_INVOCATION} skills update --tool ${target.tool} --scope ${target.scope} --json`;
5031
5112
  }
5032
5113
  async function recoveryRecommendation(target, bundled) {
5114
+ const state = await readTarget(target);
5033
5115
  const details = await diagnostic(target, bundled);
5116
+ if (await isUnownedFolder(target.absolutePath, details.legacy_rule?.managed)) return {};
5117
+ if (isNewer(state, bundled)) return { hint: details.hint ?? newerCliHint(state.version, bundled.version) };
5034
5118
  let update_command = skillUpdateCommand(target);
5035
5119
  try {
5036
5120
  await preflightFolder(target.absolutePath, bundled);
@@ -5072,6 +5156,7 @@ async function finishActions(command, planned, dryRun, mode) {
5072
5156
  item.hint = error.message;
5073
5157
  item.action = item.fallbackAction;
5074
5158
  delete item.content;
5159
+ delete item.legacy;
5075
5160
  continue;
5076
5161
  }
5077
5162
  const conflict = skillUpdateConflictError(item.target.path);
@@ -5106,6 +5191,7 @@ async function finishActions(command, planned, dryRun, mode) {
5106
5191
  folder_path: dirname(target.path),
5107
5192
  ...legacy ? { legacy_rule: legacy } : {},
5108
5193
  action,
5194
+ ...action === "failed" ? { code: "skill_update_conflict" } : {},
5109
5195
  ...action === "update_recommended" ? await recoveryRecommendation(target, await loadBundledSkills()) : {}
5110
5196
  })))
5111
5197
  };
@@ -5124,6 +5210,7 @@ async function runActions(command, planned, dryRun, mode, unavailableTargets = [
5124
5210
  hint: target.error.hint
5125
5211
  })));
5126
5212
  writeSuccess(command, data, mode);
5213
+ if (data.targets.some((target) => target.action === "failed")) process.exitCode = 1;
5127
5214
  }
5128
5215
  }
5129
5216
  async function bundledOrFailure(command, mode) {
@@ -5149,7 +5236,22 @@ async function runSkillsInstall(parsed, mode) {
5149
5236
  if (!availableTarget(target)) return writeFailure(command, target.error, mode, 1);
5150
5237
  const state = await readTarget(target);
5151
5238
  if ((state.kind === "unmanaged" || state.kind === "broken") && !force) return writeFailure(command, await conflictFor(target), mode, 1);
5152
- if (state.kind === "managed" && await isCurrent(target, bundled) && !force) {
5239
+ if (isNewer(state, bundled) && !force) {
5240
+ planned.push({
5241
+ target,
5242
+ action: "unchanged",
5243
+ preserve: true,
5244
+ hint: newerCliHint(state.version, bundled.version)
5245
+ });
5246
+ continue;
5247
+ }
5248
+ const details = await diagnostic(target, bundled);
5249
+ if (details.code === "skill_update_conflict") {
5250
+ const conflict = skillUpdateConflictError(target.path);
5251
+ conflict.hint = details.hint ?? conflict.hint;
5252
+ return writeFailure(command, conflict, mode, 1);
5253
+ }
5254
+ if (state.kind === "managed" && details.current && !force) {
5153
5255
  planned.push({
5154
5256
  target,
5155
5257
  action: "unchanged"
@@ -5160,7 +5262,8 @@ async function runSkillsInstall(parsed, mode) {
5160
5262
  target,
5161
5263
  action: state.kind === "missing" ? "installed" : "updated",
5162
5264
  content: bundled,
5163
- force
5265
+ force,
5266
+ ...isNewer(state, bundled) ? { hint: downgradeHint(state.version, bundled.version) } : {}
5164
5267
  });
5165
5268
  }
5166
5269
  await runActions(command, planned, parsed.options.dryRun === true, mode);
@@ -5187,8 +5290,28 @@ async function ensureSkills(parsed, mode, options = {}) {
5187
5290
  const planned = [];
5188
5291
  for (const target of await groupTargets(targets)) {
5189
5292
  const state = await readTarget(target);
5293
+ const linkedSkill = state.kind === "unmanaged" && (filters.auto || options.skipBrokenUserSkills) && (await lstat(target.absolutePath).catch(() => null))?.isSymbolicLink();
5294
+ if (linkedSkill && await isUnownedFolder(target.absolutePath, (await legacyRule(target))?.managed)) {
5295
+ if (filters.auto) planned.push({
5296
+ target,
5297
+ action: "skipped_unmanaged"
5298
+ });
5299
+ continue;
5300
+ }
5301
+ const conflicted = state.kind === "broken" || linkedSkill;
5302
+ if (filters.auto && command === "skills ensure" && conflicted) {
5303
+ const details = await diagnostic(target, bundled);
5304
+ if (details.code === "skill_update_conflict") {
5305
+ planned.push({
5306
+ target,
5307
+ action: "failed",
5308
+ hint: details.hint ?? skillUpdateConflictError(target.path).hint
5309
+ });
5310
+ continue;
5311
+ }
5312
+ }
5190
5313
  if (state.kind === "unmanaged" || state.kind === "broken") {
5191
- if (options.skipBrokenUserSkills && state.kind === "broken") {
5314
+ if (options.skipBrokenUserSkills && conflicted) {
5192
5315
  const details = await diagnostic(target, bundled);
5193
5316
  if (details.hint) planned.push({
5194
5317
  target,
@@ -5365,7 +5488,10 @@ async function autoUpdateUserManagedSkills() {
5365
5488
  }
5366
5489
  async function runSkillsEnsure(parsed, mode) {
5367
5490
  const data = await ensureSkills(parsed, mode);
5368
- if (data) writeSuccess("skills ensure", data, mode);
5491
+ if (data) {
5492
+ writeSuccess("skills ensure", data, mode);
5493
+ if (data.targets.some((target) => target.action === "failed")) process.exitCode = 1;
5494
+ }
5369
5495
  }
5370
5496
  async function runSkillsList(parsed, mode) {
5371
5497
  const bundled = await bundledOrFailure("skills list", mode);
@@ -5390,7 +5516,7 @@ async function runSkillsList(parsed, mode) {
5390
5516
  installed: state.kind !== "missing",
5391
5517
  managed: state.kind === "managed",
5392
5518
  installed_version: state.kind === "managed" ? state.version : null,
5393
- update_available: state.kind === "managed" && state.version !== bundled.version
5519
+ update_available: state.kind === "managed" && state.version < bundled.version
5394
5520
  });
5395
5521
  }
5396
5522
  return writeSuccess("skills list", {
@@ -5411,7 +5537,7 @@ async function skillDiagnostics() {
5411
5537
  }
5412
5538
  const state = await readTarget(target);
5413
5539
  const details = await diagnostic(target, bundled);
5414
- const updateAvailable = state.kind === "managed" && state.version !== bundled.version;
5540
+ const updateAvailable = state.kind === "managed" && state.version < bundled.version;
5415
5541
  const recommendation = await recoveryRecommendation(target, bundled);
5416
5542
  const recoveryCommand = recommendation.update_command ?? null;
5417
5543
  targets.push({
@@ -5450,7 +5576,28 @@ async function runSkillsUpdate(parsed, mode) {
5450
5576
  const planned = [];
5451
5577
  for (const target of await groupTargets(filteredTargets(filters.tools, filters.scope))) {
5452
5578
  const state = await readTarget(target);
5579
+ const details = await diagnostic(target, bundled);
5580
+ if (details.code === "skill_update_conflict") {
5581
+ const conflict = skillUpdateConflictError(target.path);
5582
+ conflict.hint = details.hint ?? conflict.hint;
5583
+ if (filters.tools.length) return writeFailure(command, conflict, mode, 1);
5584
+ planned.push({
5585
+ target,
5586
+ action: "failed",
5587
+ hint: conflict.hint
5588
+ });
5589
+ continue;
5590
+ }
5453
5591
  if (state.kind === "broken") return writeFailure(command, await conflictFor(target), mode, 1);
5592
+ if (isNewer(state, bundled) && !force) {
5593
+ planned.push({
5594
+ target,
5595
+ action: "unchanged",
5596
+ preserve: true,
5597
+ hint: newerCliHint(state.version, bundled.version)
5598
+ });
5599
+ continue;
5600
+ }
5454
5601
  if (state.kind === "missing") {
5455
5602
  if (state.hint) {
5456
5603
  planned.push({
@@ -5476,13 +5623,15 @@ async function runSkillsUpdate(parsed, mode) {
5476
5623
  target,
5477
5624
  action: "updated",
5478
5625
  content: bundled,
5479
- forceRetirement: force
5626
+ forceRetirement: force,
5627
+ ...isNewer(state, bundled) ? { hint: downgradeHint(state.version, bundled.version) } : {}
5480
5628
  });
5481
5629
  else planned.push({
5482
5630
  target,
5483
5631
  action: "unchanged"
5484
5632
  });
5485
5633
  }
5634
+ if (!filters.tools.length) for (const item of planned) item.fallbackAction = "failed";
5486
5635
  await runActions(command, planned, parsed.options.dryRun === true, mode, unavailableActionTargets(filters.tools, filters.scope));
5487
5636
  }
5488
5637
  async function runSkillsRemove(parsed, mode) {
@@ -5494,7 +5643,19 @@ async function runSkillsRemove(parsed, mode) {
5494
5643
  const planned = [];
5495
5644
  for (const target of await groupTargets(filteredTargets(filters.tools, filters.scope))) {
5496
5645
  const state = await readTarget(target);
5497
- if (state.kind === "broken") return writeFailure(command, await conflictFor(target), mode, 1);
5646
+ const details = await diagnostic(target, await loadBundledSkills());
5647
+ if (details.code === "skill_update_conflict") {
5648
+ const conflict = skillUpdateConflictError(target.path);
5649
+ conflict.hint = details.hint ?? conflict.hint;
5650
+ if (filters.tools.length) return writeFailure(command, conflict, mode, 1);
5651
+ planned.push({
5652
+ target,
5653
+ action: "failed",
5654
+ hint: conflict.hint
5655
+ });
5656
+ continue;
5657
+ }
5658
+ if (state.kind === "broken") return writeFailure(command, await conflictFor(target, true), mode, 1);
5498
5659
  if (state.kind === "missing" && state.hint) {
5499
5660
  planned.push({
5500
5661
  target,
@@ -5511,6 +5672,7 @@ async function runSkillsRemove(parsed, mode) {
5511
5672
  removeLegacy: true
5512
5673
  });
5513
5674
  }
5675
+ if (!filters.tools.length) for (const item of planned) item.fallbackAction = "failed";
5514
5676
  await runActions(command, planned, parsed.options.dryRun === true, mode, unavailableActionTargets(filters.tools, filters.scope));
5515
5677
  }
5516
5678
  //#endregion
@@ -16693,7 +16855,7 @@ const skillsInstallDefinition = define({
16693
16855
  force: {
16694
16856
  type: "boolean",
16695
16857
  toKebab: true,
16696
- description: "Take over bundled paths only; preserve user additions"
16858
+ description: "Take over bundled paths or intentionally downgrade; preserve user additions"
16697
16859
  }
16698
16860
  },
16699
16861
  examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills install --tool codex --scope project --json
@@ -16702,6 +16864,7 @@ npm exec --yes --package=@artifactshare/cli -- artifactshare skills install --to
16702
16864
  Writes SKILL.md and bundled references into skills/artifactshare/ for every tool and scope.
16703
16865
  Project Cursor uses .cursor/skills/artifactshare/. A manifest tracks owned files.
16704
16866
  Files without the Artifact Share managed marker are never overwritten without --force.
16867
+ Newer installed versions are unchanged with a newer-CLI hint unless --force requests an intentional downgrade; dry runs report the same plan.
16705
16868
 
16706
16869
  Claude Code user skills go to $CLAUDE_CONFIG_DIR/skills when set, otherwise
16707
16870
  ~/.claude/skills. Relative paths resolve against cwd without tilde expansion.
@@ -16735,14 +16898,17 @@ const skillsUpdateDefinition = define({
16735
16898
  force: {
16736
16899
  type: "boolean",
16737
16900
  toKebab: true,
16738
- description: "Rewrite managed folder files; never take over an unmanaged entry"
16901
+ description: "Rewrite managed folder files, allowing an explicit downgrade; never take over an unmanaged entry"
16739
16902
  }
16740
16903
  },
16741
16904
  examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills update --json
16742
16905
  npm exec --yes --package=@artifactshare/cli -- artifactshare skills update --tool codex --scope user --json
16743
16906
 
16744
16907
  Updates managed folders and repairs missing files. Edited owned files require --force; user additions are preserved.
16745
- Folder and ancestor directory symlinks are resolved; internal links are refused even with --force.
16908
+ Folder and ancestor directory symlinks are resolved. User links outside bundled, owned, pending and reserved CLI paths are ignored and listed in user_links; protected links in managed folders are refused even with --force.
16909
+ Unmanaged folders without ownership records or a managed legacy rule are skipped_unmanaged, including protected-path links; link referents are never read.
16910
+ Newer installed versions are preserved without cleanup unless --force requests an explicit downgrade.
16911
+ Unfiltered update/remove continue other targets on conflict: ok: true stdout includes failed target rows with code and hint; exit status is 1.
16746
16912
  Shared folders are written once. JSON rows include aliases and resolved_folder_path.
16747
16913
  Real mutations clean reserved stale staging and UUID temporary files; dry runs do not.
16748
16914
  Managed legacy Cursor rules migrate after the new project folder is ready.
@@ -16797,6 +16963,7 @@ const skillsRemoveDefinition = define({
16797
16963
  npm exec --yes --package=@artifactshare/cli -- artifactshare skills remove --tool cursor --json
16798
16964
 
16799
16965
  Only manifest-owned files (or a legacy managed SKILL.md) are deleted; user files are preserved.
16966
+ Unmanaged folders are skipped_unmanaged, including protected-path links when no ownership records or managed legacy rule exist.
16800
16967
  Project Cursor removal also cleans managed legacy rules.`
16801
16968
  });
16802
16969
  const skillsDefinition = define({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artifactshare/cli",
3
- "version": "0.20.1",
3
+ "version": "0.20.2",
4
4
  "description": "Upload and share HTML, Markdown, folders, and static sites from terminals, AI agents, automation, and CI.",
5
5
  "homepage": "https://artifactshare.com/connect",
6
6
  "repository": {
@@ -4,7 +4,7 @@ description: Share, publish, upload, host, update, open, or read back existing f
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 49
7
+ version: 50
8
8
  managed: true
9
9
  -->
10
10
 
@@ -236,7 +236,7 @@ access, expiry, retention, deletion, or persistent defaults. Delete only on expl
236
236
  ## Skills and profiles
237
237
 
238
238
  `skills ensure --tool auto --json` prepares user-scope skills;
239
- `skills update --json` updates managed installations. Project installation is opt-in.
239
+ `skills update --json` updates managed installations, preserving versions installed by a newer CLI unless `--force` explicitly requests a downgrade. User-added links are ignored; protected-path links are refused. Project installation is opt-in.
240
240
  `profiles list --json` shows saved profiles; `profiles use <name> --json` switches
241
241
  selection. Use `logout --profile <name> --json` to revoke a device-login credential.
242
242
  The authentication, profiles and skills reference above covers tools, scopes, storage,
@@ -71,6 +71,10 @@ npm exec --yes --package=@artifactshare/cli -- artifactshare skills list --json
71
71
  - `--force` overwrites an unmanaged file on install.
72
72
  - Run `skills --help` for all subcommands.
73
73
 
74
- Skill folders and their configured ancestors may be directory symlinks. The CLI resolves the folder with realpath and handles each shared destination once, in Codex, Claude, Cursor order (project before user); the first selected alias supplies the legacy fields. JSON target rows include `aliases` (tool, scope, path, folder_path) and `resolved_folder_path`. Explicit filters include only selected aliases. Internal links, including SKILL.md, references and the manifest, are refused even with force. Restore dangling links to a directory; preserve edits and replace internal links with ordinary content before retrying. A missing skill beneath a dangling ancestor is reported as not installed, with the broken ancestor path, and does not block other targets. Link and layout conflicts provide repair hints without a force command. Removal preserves configured links and their destination directory.
74
+ Skill folders and their configured ancestors may be directory symlinks. The CLI resolves the folder with realpath and handles each shared destination once, in Codex, Claude, Cursor order (project before user); the first selected alias supplies the legacy fields. JSON target rows include `aliases` (tool, scope, path, folder_path) and `resolved_folder_path`. Explicit filters include only selected aliases. User-added links outside bundled, manifest-listed, pending-intent-listed and reserved CLI paths are ignored without following them; doctor and skills list report their sorted folder-relative paths in `user_links`. For managed folders and forced installs, links at protected paths, including SKILL.md, references and CLI metadata, are refused even with force. Folders without ownership records or a managed skill or legacy rule remain unmanaged: update and remove report `skipped_unmanaged`, even with SKILL.md or references links. List and doctor report them as unmanaged without reading link referents. Replace the named link with a regular file or directory or remove it before retrying. A missing skill beneath a dangling ancestor is reported as not installed, with the broken ancestor path, and does not block other targets. Link and layout conflicts provide repair hints without a force command. Removal preserves configured links, ignored user links and their containing directory.
75
75
 
76
- Writes prefer a private sibling `.artifactshare-staging-<uuid>` directory. If the parent is not writable or a commit crosses filesystems, the CLI stages inside the skill folder instead and still commits files by rename. Real install, update, ensure and automatic updates clean reserved staging directories and exact UUID-shaped `.artifactshare-<uuid>.tmp` regular files only when their modification times are more than ten minutes old before checking conflicts, including no-op selections. Diagnostics and dry runs never clean files. Unrelated names and symlink referents are never deleted. Failed writes roll back committed paths and remove staging; interrupted processes leave debris for the next mutation.
76
+ Without tool filters, update/remove continue healthy targets after a conflict. Partial failures keep the `ok: true` stdout envelope with `data.targets`, report `action: "failed"`, `code: "skill_update_conflict"` and `hint` for the failed target, and exit with status 1. Explicit unsafe target selections retain the `ok: false` error envelope.
77
+
78
+ When a newer CLI installed the managed version, list/doctor report `update_available: false` and a `hint` containing "A newer CLI installed", with no update recommendation. Unforced skills install and skills update preserve the entire target, including temporary files and legacy rules. Explicit `--force` permits a downgrade, reported with both versions in `hint`; `--dry-run --force` reports the same intent without writing. Protected links and newer pending intents still refuse force.
79
+
80
+ Writes prefer a private sibling `.artifactshare-staging-<uuid>` directory. If the parent is not writable or a commit crosses filesystems, the CLI stages inside the skill folder instead and still commits files by rename. Real install, update, ensure and automatic updates clean reserved staging directories and exact UUID-shaped `.artifactshare-<uuid>.tmp` regular files only when their modification times are more than ten minutes old before checking conflicts, including no-op selections except newer installed versions skipped by skills install or skills update. Diagnostics and dry runs never clean files. Unrelated names and symlink referents are never deleted. Failed writes roll back committed paths and remove staging; interrupted processes leave debris for the next mutation.