@artifactshare/cli 0.20.2 → 0.20.3

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 (3) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/cli.js +182 -109
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,11 @@
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.3 - 2026-10-28
7
+
8
+ - Preserve newer managed legacy Cursor rules during install, update and ensure unless force explicitly requests a downgrade, and keep doctor from recommending a combined forced update that would downgrade them.
9
+ - Restore forced-install recovery commands and collision hints for unowned skill folders blocked by regular files or directories, while keeping user links untouched.
10
+
6
11
  ## 0.20.2 - 2026-10-28
7
12
 
8
13
  - Preserve newer managed skills during install unless force explicitly requests a downgrade.
package/dist/cli.js CHANGED
@@ -4301,10 +4301,10 @@ const uuid = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
4301
4301
  const legacyTemp = new RegExp(`^\\.artifactshare-${uuid}\\.tmp$`, "i");
4302
4302
  const stagingName = new RegExp(`^\\.artifactshare-staging-${uuid}$`, "i");
4303
4303
  const stale = (item) => item.mtimeMs < Date.now() - 6e5;
4304
- async function protectedPaths(root, bundle) {
4304
+ async function protectedPaths(root, bundle, observedState) {
4305
4305
  await safe(root, MANIFEST);
4306
4306
  await safe(root, PENDING);
4307
- const state = await stateAt(root);
4307
+ const state = observedState ?? await stateAt(root);
4308
4308
  const pending = await ownership(root, state, PENDING);
4309
4309
  const owned = await ownership(root, state, MANIFEST, pending.manifest);
4310
4310
  const paths = /* @__PURE__ */ new Set([
@@ -4337,6 +4337,13 @@ async function isProtectedLink(root, item, protectedEntries, lookup = info) {
4337
4337
  }
4338
4338
  return false;
4339
4339
  }
4340
+ var SkillPathError = class extends Error {
4341
+ isLink;
4342
+ constructor(message, isLink) {
4343
+ super(message);
4344
+ this.isLink = isLink;
4345
+ }
4346
+ };
4340
4347
  async function inspectTree(root, cleanup = false, folderRoot = root, protectedEntries, userLinks = []) {
4341
4348
  if (!await info(root)) return userLinks;
4342
4349
  for (const name of (await readdir(root)).sort()) {
@@ -4344,7 +4351,7 @@ async function inspectTree(root, cleanup = false, folderRoot = root, protectedEn
4344
4351
  const item = await lstat(path);
4345
4352
  if (item.isSymbolicLink()) {
4346
4353
  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.`);
4354
+ if (protectedEntries && (protectedEntries.has(entry) || await isProtectedLink(folderRoot, item, protectedEntries) || name === MANIFEST || name === PENDING || stagingName.test(name) || legacyTemp.test(name))) throw new SkillPathError(`Unsafe skill path (link): ${entry}. Replace the link with a regular file or directory or remove it, then retry.`, true);
4348
4355
  userLinks.push(entry);
4349
4356
  continue;
4350
4357
  }
@@ -4388,7 +4395,7 @@ async function safe(root, relative, retiredAncestors = /* @__PURE__ */ new Set()
4388
4395
  const item = await info(parts[i]);
4389
4396
  if (i < parts.length - 1 && item?.isFile() && retiredAncestors.has(parts[i])) return;
4390
4397
  if (i === parts.length - 1 && item?.isDirectory() && replacedDirectories.has(parts[i])) continue;
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.`);
4398
+ if (item && (item.isSymbolicLink() || (i === parts.length - 1 ? !item.isFile() : !item.isDirectory()))) throw new SkillPathError(`Unsafe skill path (type change or link): ${parts[i]}. Replace the link with a regular file or directory or remove it, then retry.`, item.isSymbolicLink());
4392
4399
  }
4393
4400
  }
4394
4401
  async function bytesAt(root, path) {
@@ -4401,39 +4408,50 @@ async function bytesAt(root, path) {
4401
4408
  async function textAt(root, path) {
4402
4409
  return (await bytesAt(root, path))?.toString("utf8") ?? null;
4403
4410
  }
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;
4411
+ async function inspectAt(root, managedLegacy) {
4409
4412
  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;
4413
+ const recordsAbsent = !await info(join(root, MANIFEST)) && !await info(join(root, PENDING));
4414
+ const linkedEntry = entry?.isSymbolicLink() === true;
4415
+ let state;
4415
4416
  try {
4416
- return await unownedAt(await rootFor(entry));
4417
+ state = linkedEntry && recordsAbsent ? { kind: "unmanaged" } : managedState(await textAt(root, "SKILL.md"));
4417
4418
  } catch {
4418
- return false;
4419
- }
4420
- }
4421
- async function stateAt(root) {
4422
- try {
4423
- if ((await info(join(root, "SKILL.md")))?.isSymbolicLink() && await recordsAbsent(root)) return { kind: "unmanaged" };
4424
- return managedState(await textAt(root, "SKILL.md"));
4425
- } catch {
4426
- return { kind: "broken" };
4419
+ state = { kind: "broken" };
4427
4420
  }
4421
+ return {
4422
+ root,
4423
+ state,
4424
+ linkedEntry,
4425
+ unowned: !managedLegacy && recordsAbsent && (!entry || linkedEntry || state.kind === "unmanaged")
4426
+ };
4428
4427
  }
4429
- async function readSkillState(entry) {
4428
+ async function inspectSkillFolder(entry, managedLegacy) {
4429
+ const failed = (root, state, error) => ({
4430
+ root,
4431
+ state,
4432
+ unowned: false,
4433
+ linkedEntry: false,
4434
+ error
4435
+ });
4436
+ let root;
4430
4437
  try {
4431
- return await stateAt(await rootFor(entry));
4438
+ root = await rootFor(entry);
4432
4439
  } catch (error) {
4433
- if (error instanceof SkillFolderResolutionError && error.missingAncestor) return {
4440
+ return failed(null, error instanceof SkillFolderResolutionError && error.missingAncestor ? {
4434
4441
  kind: "missing",
4435
4442
  hint: error.message
4436
- };
4443
+ } : { kind: "broken" }, error);
4444
+ }
4445
+ try {
4446
+ return await inspectAt(root, managedLegacy);
4447
+ } catch (error) {
4448
+ return failed(root, { kind: "broken" }, error);
4449
+ }
4450
+ }
4451
+ async function stateAt(root) {
4452
+ try {
4453
+ return (await inspectAt(root, false)).state;
4454
+ } catch {
4437
4455
  return { kind: "broken" };
4438
4456
  }
4439
4457
  }
@@ -4501,12 +4519,14 @@ async function recoveryOwnership(root, state) {
4501
4519
  recorded
4502
4520
  };
4503
4521
  }
4504
- async function folderDiagnostics(entry, bundle, managedLegacy = false) {
4505
- let root = null;
4522
+ async function folderDiagnostics(entry, bundle, context = false) {
4523
+ const inspection = typeof context === "boolean" ? await inspectSkillFolder(entry, context) : context;
4524
+ let root = inspection.root;
4506
4525
  let user_links = [];
4507
4526
  try {
4508
- root = await rootFor(entry);
4509
- user_links = await inspectTree(root, false, root, !managedLegacy && await unownedAt(root) ? void 0 : await protectedPaths(root, bundle));
4527
+ if (inspection.error) throw inspection.error;
4528
+ root = inspection.root;
4529
+ user_links = await inspectTree(root, false, root, inspection.unowned ? void 0 : await protectedPaths(root, bundle, inspection.state));
4510
4530
  } catch (error) {
4511
4531
  return {
4512
4532
  folder_path: dirname(entry),
@@ -4524,7 +4544,7 @@ async function folderDiagnostics(entry, bundle, managedLegacy = false) {
4524
4544
  hint: error.message
4525
4545
  };
4526
4546
  }
4527
- const state = await stateAt(root);
4547
+ const state = inspection.state;
4528
4548
  const { owned, pending, recorded } = await recoveryOwnership(root, state);
4529
4549
  const newerIntent = pending.manifest && pending.manifest.version > bundle.version;
4530
4550
  const missing_files = [], different_files = [], modified_files = [];
@@ -4809,8 +4829,12 @@ function targetOrder(a, b) {
4809
4829
  }
4810
4830
  async function cleanupTarget(target, bundled) {
4811
4831
  if (target.cleaned) return;
4812
- await cleanupSkillFolder(target.absolutePath, bundled);
4813
- target.cleaned = true;
4832
+ try {
4833
+ await cleanupSkillFolder(target.absolutePath, bundled);
4834
+ target.cleaned = true;
4835
+ } finally {
4836
+ delete target.inspection;
4837
+ }
4814
4838
  }
4815
4839
  async function groupTargets(targets) {
4816
4840
  const groups = /* @__PURE__ */ new Map();
@@ -4823,8 +4847,10 @@ async function groupTargets(targets) {
4823
4847
  const key = await resolveSkillFolder(target.absolutePath).catch(() => null);
4824
4848
  target.resolved_folder_path = key;
4825
4849
  const existing = key === null ? void 0 : groups.get(key);
4826
- if (existing && availableTarget(existing)) existing.aliases = [...aliases(existing), ...aliases(target)];
4827
- else {
4850
+ if (existing && availableTarget(existing)) {
4851
+ existing.aliases = [...aliases(existing), ...aliases(target)];
4852
+ delete existing.inspection;
4853
+ } else {
4828
4854
  target.aliases = aliases(target);
4829
4855
  result.push(target);
4830
4856
  if (key !== null) groups.set(key, target);
@@ -4919,8 +4945,23 @@ function skillTarget(tool, scope) {
4919
4945
  function allTargets() {
4920
4946
  return SKILL_TOOLS.flatMap((tool) => TOOL_CONFIG[tool].scopes.map((scope) => skillTarget(tool, scope)));
4921
4947
  }
4922
- function readTarget(target) {
4923
- return readSkillState(target.absolutePath);
4948
+ async function inspectTarget(target) {
4949
+ const legacy = await legacyRule(target);
4950
+ return {
4951
+ folder: await inspectSkillFolder(target.absolutePath, legacy?.managed === true),
4952
+ legacy
4953
+ };
4954
+ }
4955
+ function targetInspection(target) {
4956
+ return target.inspection ??= inspectTarget(target);
4957
+ }
4958
+ async function readTarget(target) {
4959
+ return (await targetInspection(target)).folder.state;
4960
+ }
4961
+ async function newerInstalledVersion(target, bundle) {
4962
+ const { folder, legacy } = await targetInspection(target);
4963
+ const version = folder.state.kind === "managed" ? folder.state.version : folder.state.kind === "missing" ? legacy?.version : void 0;
4964
+ return version !== void 0 && version > bundle.version ? version : void 0;
4924
4965
  }
4925
4966
  function loadBundledSkills() {
4926
4967
  return loadSkillBundle(fileURLToPath(new URL("../skills/artifactshare/", import.meta.url)));
@@ -4936,23 +4977,23 @@ async function legacyRule(target) {
4936
4977
  const parent = await lstat(dirname(path)).catch(() => null);
4937
4978
  const content = info?.isFile() && !parent?.isSymbolicLink() ? await readFile(path, "utf8").catch(() => null) : null;
4938
4979
  const present = info !== null;
4939
- const managed = managedState(content).kind === "managed";
4980
+ const state = managedState(content);
4981
+ const managed = state.kind === "managed";
4982
+ const coexistence = present && await lstat(resolve(cursor.path)).catch(() => null) !== null;
4940
4983
  return {
4941
4984
  path,
4942
4985
  present,
4943
4986
  managed,
4944
- coexistence: present && await lstat(resolve(cursor.path)).catch(() => null) !== null,
4987
+ ...state.kind === "managed" ? { version: state.version } : {},
4988
+ coexistence,
4945
4989
  hint: present && !managed ? "Inspect the legacy Cursor rule and manually remove it if the skill folder replaces it." : null
4946
4990
  };
4947
4991
  }
4948
- async function legacyManagedVersion(target) {
4949
- const legacy = await legacyRule(target);
4950
- if (!legacy?.managed) return void 0;
4951
- const state = managedState(await readFile(legacy.path, "utf8"));
4952
- return state.kind === "managed" ? state.version : void 0;
4992
+ function legacyRuleOutput({ version: _version, ...rule }) {
4993
+ return rule;
4953
4994
  }
4954
- function isNewer(state, bundle) {
4955
- return state.kind === "managed" && state.version > bundle.version;
4995
+ async function legacyManagedVersion(target) {
4996
+ return (await legacyRule(target))?.version;
4956
4997
  }
4957
4998
  function newerCliHint(installed, bundled) {
4958
4999
  return `A newer CLI installed skill version ${installed}; this CLI bundles version ${bundled}. Keeping the installed version. Use --force only for an intentional downgrade.`;
@@ -4961,18 +5002,18 @@ function downgradeHint(installed, bundled) {
4961
5002
  return `Intentional downgrade from skill version ${installed} to bundled version ${bundled}.`;
4962
5003
  }
4963
5004
  async function diagnostic(target, bundle) {
4964
- const legacy = await legacyRule(target);
4965
- const state = await readTarget(target);
4966
- const details = await folderDiagnostics(target.absolutePath, bundle, legacy?.managed);
5005
+ const { folder, legacy } = await targetInspection(target);
5006
+ const version = await newerInstalledVersion(target, bundle);
5007
+ const details = await folderDiagnostics(target.absolutePath, bundle, folder);
4967
5008
  return {
4968
5009
  ...details,
4969
5010
  folder_path: dirname(target.path),
4970
- ...isNewer(state, bundle) ? { hint: [details.hint, newerCliHint(state.version, bundle.version)].filter(Boolean).join(" ") } : {},
4971
- ...legacy ? { legacy_rule: legacy } : {}
5011
+ ...version !== void 0 ? { hint: [details.hint, newerCliHint(version, bundle.version)].filter(Boolean).join(" ") } : {},
5012
+ ...legacy ? { legacy_rule: legacyRuleOutput(legacy) } : {}
4972
5013
  };
4973
5014
  }
4974
5015
  async function isCurrent(target, bundle) {
4975
- return (await folderDiagnostics(target.absolutePath, bundle)).current;
5016
+ return (await diagnostic(target, bundle)).current;
4976
5017
  }
4977
5018
  function parseTools(value, options = {}) {
4978
5019
  const raws = arrayOption(value);
@@ -5095,30 +5136,35 @@ async function prepareAction(item, dryRun) {
5095
5136
  }
5096
5137
  async function applyAction(item) {
5097
5138
  if (item.preserve || item.action === "failed") return;
5098
- if (item.content) await writeSkillFolder(item.target.absolutePath, item.content, item.force, item.forceRetirement, false);
5099
- if (item.action === "removed") await removeSkillFolder(item.target.absolutePath, aliases(item.target).length > 1, await loadBundledSkills());
5100
- if (item.legacy?.action === "removed") try {
5101
- await unlink(item.legacy.path);
5102
- } catch {
5103
- item.legacy = {
5104
- path: item.legacy.path,
5105
- action: "remove_failed",
5106
- hint: "Retry skills update --tool cursor --scope project --json to remove the legacy rule."
5107
- };
5139
+ try {
5140
+ if (item.content) await writeSkillFolder(item.target.absolutePath, item.content, item.force, item.forceRetirement, false);
5141
+ if (item.action === "removed") await removeSkillFolder(item.target.absolutePath, aliases(item.target).length > 1, await loadBundledSkills());
5142
+ if (item.legacy?.action === "removed") try {
5143
+ await unlink(item.legacy.path);
5144
+ } catch {
5145
+ item.legacy = {
5146
+ path: item.legacy.path,
5147
+ action: "remove_failed",
5148
+ hint: "Retry skills update --tool cursor --scope project --json to remove the legacy rule."
5149
+ };
5150
+ }
5151
+ } finally {
5152
+ delete item.target.inspection;
5108
5153
  }
5109
5154
  }
5110
5155
  function skillUpdateCommand(target) {
5111
5156
  return `${CLI_INVOCATION} skills update --tool ${target.tool} --scope ${target.scope} --json`;
5112
5157
  }
5113
5158
  async function recoveryRecommendation(target, bundled) {
5114
- const state = await readTarget(target);
5115
5159
  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) };
5160
+ const { folder } = await targetInspection(target);
5161
+ const version = await newerInstalledVersion(target, bundled);
5162
+ if (version !== void 0) return { hint: details.hint ?? newerCliHint(version, bundled.version) };
5118
5163
  let update_command = skillUpdateCommand(target);
5164
+ let collision;
5119
5165
  try {
5120
5166
  await preflightFolder(target.absolutePath, bundled);
5121
- } catch {
5167
+ } catch (first) {
5122
5168
  try {
5123
5169
  await preflightFolder(target.absolutePath, bundled, false, true);
5124
5170
  update_command = update_command.replace(" --json", " --force --json");
@@ -5126,7 +5172,9 @@ async function recoveryRecommendation(target, bundled) {
5126
5172
  try {
5127
5173
  await preflightFolder(target.absolutePath, bundled, true);
5128
5174
  update_command = `${CLI_INVOCATION} skills install --tool ${target.tool} --scope ${target.scope} --force --json`;
5175
+ if (folder.unowned) collision = first.message;
5129
5176
  } catch (error) {
5177
+ if (folder.unowned && error instanceof SkillPathError && error.isLink) return { suppressHint: true };
5130
5178
  return {
5131
5179
  hint: error.message,
5132
5180
  ...details.modified_files.length ? { modified_files: details.modified_files } : {}
@@ -5136,6 +5184,7 @@ async function recoveryRecommendation(target, bundled) {
5136
5184
  }
5137
5185
  return {
5138
5186
  update_command,
5187
+ ...collision ? { hint: collision } : {},
5139
5188
  ...details.modified_files.length ? {
5140
5189
  modified_files: details.modified_files,
5141
5190
  hint: `Modified skill files: ${details.modified_files.join(", ")}. Preserve your edits before running the recommended command.`
@@ -5182,18 +5231,21 @@ async function finishActions(command, planned, dryRun, mode) {
5182
5231
  }
5183
5232
  return {
5184
5233
  dry_run: dryRun,
5185
- targets: await Promise.all(completed.map(async ({ target, action, legacy, hint }) => ({
5186
- ...hint ? { hint } : {},
5187
- tool: target.tool,
5188
- scope: target.scope,
5189
- path: target.path,
5190
- ...identity(target),
5191
- folder_path: dirname(target.path),
5192
- ...legacy ? { legacy_rule: legacy } : {},
5193
- action,
5194
- ...action === "failed" ? { code: "skill_update_conflict" } : {},
5195
- ...action === "update_recommended" ? await recoveryRecommendation(target, await loadBundledSkills()) : {}
5196
- })))
5234
+ targets: await Promise.all(completed.map(async ({ target, action, legacy, hint }) => {
5235
+ const { suppressHint, ...recommendation } = action === "update_recommended" ? await recoveryRecommendation(target, await loadBundledSkills()) : {};
5236
+ return {
5237
+ ...hint && !suppressHint ? { hint } : {},
5238
+ tool: target.tool,
5239
+ scope: target.scope,
5240
+ path: target.path,
5241
+ ...identity(target),
5242
+ folder_path: dirname(target.path),
5243
+ ...legacy ? { legacy_rule: legacy } : {},
5244
+ action,
5245
+ ...action === "failed" ? { code: "skill_update_conflict" } : {},
5246
+ ...recommendation
5247
+ };
5248
+ }))
5197
5249
  };
5198
5250
  }
5199
5251
  async function runActions(command, planned, dryRun, mode, unavailableTargets = []) {
@@ -5236,12 +5288,13 @@ async function runSkillsInstall(parsed, mode) {
5236
5288
  if (!availableTarget(target)) return writeFailure(command, target.error, mode, 1);
5237
5289
  const state = await readTarget(target);
5238
5290
  if ((state.kind === "unmanaged" || state.kind === "broken") && !force) return writeFailure(command, await conflictFor(target), mode, 1);
5239
- if (isNewer(state, bundled) && !force) {
5291
+ const version = await newerInstalledVersion(target, bundled);
5292
+ if (version !== void 0 && !force) {
5240
5293
  planned.push({
5241
5294
  target,
5242
5295
  action: "unchanged",
5243
5296
  preserve: true,
5244
- hint: newerCliHint(state.version, bundled.version)
5297
+ hint: newerCliHint(version, bundled.version)
5245
5298
  });
5246
5299
  continue;
5247
5300
  }
@@ -5263,7 +5316,7 @@ async function runSkillsInstall(parsed, mode) {
5263
5316
  action: state.kind === "missing" ? "installed" : "updated",
5264
5317
  content: bundled,
5265
5318
  force,
5266
- ...isNewer(state, bundled) ? { hint: downgradeHint(state.version, bundled.version) } : {}
5319
+ ...version !== void 0 ? { hint: downgradeHint(version, bundled.version) } : {}
5267
5320
  });
5268
5321
  }
5269
5322
  await runActions(command, planned, parsed.options.dryRun === true, mode);
@@ -5289,9 +5342,10 @@ async function ensureSkills(parsed, mode, options = {}) {
5289
5342
  const targets = (filters.auto ? await autoTargets(filters.scope) : void 0)?.targets ?? filteredTargets(filters.tools, filters.scope ?? "project");
5290
5343
  const planned = [];
5291
5344
  for (const target of await groupTargets(targets)) {
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)) {
5345
+ const { folder } = await targetInspection(target);
5346
+ const state = folder.state;
5347
+ const linkedSkill = state.kind === "unmanaged" && (filters.auto || options.skipBrokenUserSkills) && folder.linkedEntry;
5348
+ if (linkedSkill && folder.unowned) {
5295
5349
  if (filters.auto) planned.push({
5296
5350
  target,
5297
5351
  action: "skipped_unmanaged"
@@ -5326,7 +5380,17 @@ async function ensureSkills(parsed, mode, options = {}) {
5326
5380
  }
5327
5381
  const automaticUpdate = filters.auto || options.command === "init" || options.command === "open";
5328
5382
  if (automaticUpdate && state.kind === "missing" && state.hint) continue;
5329
- if (automaticUpdate && state.kind === "managed" && state.version > bundled.version) continue;
5383
+ const newer = await newerInstalledVersion(target, bundled);
5384
+ if (automaticUpdate && newer !== void 0) continue;
5385
+ if (state.kind === "missing" && newer !== void 0) {
5386
+ planned.push({
5387
+ target,
5388
+ action: "unchanged",
5389
+ preserve: true,
5390
+ hint: newerCliHint(newer, bundled.version)
5391
+ });
5392
+ continue;
5393
+ }
5330
5394
  const details = await diagnostic(target, bundled);
5331
5395
  if (automaticUpdate && state.kind === "managed" && details.modified_files.length) {
5332
5396
  planned.push({
@@ -5354,6 +5418,7 @@ async function ensureSkills(parsed, mode, options = {}) {
5354
5418
  if (plannedPaths.has(await targetPathKey(target))) {
5355
5419
  const existing = planned.find((item) => target.resolved_folder_path !== null ? item.target.resolved_folder_path === target.resolved_folder_path : item.target.absolutePath === target.absolutePath);
5356
5420
  if (existing) {
5421
+ delete existing.target.inspection;
5357
5422
  existing.target.aliases = [...aliases(existing.target), ...aliases(target).filter((alias) => !aliases(existing.target).some((old) => old.tool === alias.tool && old.scope === alias.scope))].sort(targetOrder);
5358
5423
  const primary = existing.target.aliases[0];
5359
5424
  existing.target.tool = primary.tool;
@@ -5469,19 +5534,22 @@ async function autoUpdateUserManagedSkills() {
5469
5534
  ...item.installedVersion !== void 0 ? { installedVersion: item.installedVersion } : {}
5470
5535
  };
5471
5536
  }
5472
- return { targets: await Promise.all(completed.map(async ({ target, action, installedVersion, legacy, hint }) => ({
5473
- ...hint ? { hint } : {},
5474
- tool: target.tool,
5475
- scope: target.scope,
5476
- path: target.path,
5477
- ...identity(target),
5478
- folder_path: dirname(target.path),
5479
- ...legacy ? { legacy_rule: legacy } : {},
5480
- action: action === "update_recommended" ? "update_recommended" : "updated",
5481
- installed_version: action === "update_recommended" ? installedVersion ?? null : installedVersion ?? bundled.version,
5482
- bundled_version: bundled.version,
5483
- ...action === "update_recommended" ? await recoveryRecommendation(target, bundled) : {}
5484
- }))) };
5537
+ return { targets: await Promise.all(completed.map(async ({ target, action, installedVersion, legacy, hint }) => {
5538
+ const { suppressHint, ...recommendation } = action === "update_recommended" ? await recoveryRecommendation(target, bundled) : {};
5539
+ return {
5540
+ ...hint && !suppressHint ? { hint } : {},
5541
+ tool: target.tool,
5542
+ scope: target.scope,
5543
+ path: target.path,
5544
+ ...identity(target),
5545
+ folder_path: dirname(target.path),
5546
+ ...legacy ? { legacy_rule: legacy } : {},
5547
+ action: action === "update_recommended" ? "update_recommended" : "updated",
5548
+ installed_version: action === "update_recommended" ? installedVersion ?? null : installedVersion ?? bundled.version,
5549
+ bundled_version: bundled.version,
5550
+ ...recommendation
5551
+ };
5552
+ })) };
5485
5553
  } catch {
5486
5554
  return;
5487
5555
  }
@@ -5527,6 +5595,7 @@ async function runSkillsList(parsed, mode) {
5527
5595
  async function skillDiagnostics() {
5528
5596
  const bundled = await loadBundledSkills();
5529
5597
  const targets = [];
5598
+ let newerLegacyOnly = false;
5530
5599
  for (const target of await groupTargets(allTargets())) {
5531
5600
  if (!availableTarget(target)) {
5532
5601
  targets.push({
@@ -5540,6 +5609,8 @@ async function skillDiagnostics() {
5540
5609
  const updateAvailable = state.kind === "managed" && state.version < bundled.version;
5541
5610
  const recommendation = await recoveryRecommendation(target, bundled);
5542
5611
  const recoveryCommand = recommendation.update_command ?? null;
5612
+ if (state.kind === "missing" && await newerInstalledVersion(target, bundled) !== void 0) newerLegacyOnly = true;
5613
+ const update_command = details.hint ? null : updateAvailable || details.interrupted_update || state.kind === "managed" && !details.current ? recoveryCommand : null;
5543
5614
  targets.push({
5544
5615
  tool: target.tool,
5545
5616
  scope: target.scope,
@@ -5550,13 +5621,13 @@ async function skillDiagnostics() {
5550
5621
  update_available: updateAvailable,
5551
5622
  ...identity(target),
5552
5623
  ...details,
5553
- ...!recoveryCommand && recommendation.hint ? { hint: recommendation.hint } : {},
5554
- update_command: details.hint ? null : updateAvailable || details.interrupted_update || state.kind === "managed" && !details.current ? recoveryCommand : null
5624
+ ...(!recoveryCommand || !update_command && !details.hint) && recommendation.hint ? { hint: recommendation.hint } : {},
5625
+ update_command
5555
5626
  });
5556
5627
  }
5557
5628
  const updateTargets = targets.filter((target) => target.update_command !== null);
5558
5629
  const commonCommand = updateTargets[0]?.update_command?.replace(/ --tool \S+ --scope \S+/, "");
5559
- const canUpdateTogether = commonCommand?.includes(" skills update ") && updateTargets.every((target) => target.update_command?.replace(/ --tool \S+ --scope \S+/, "") === commonCommand) && !targets.some((target) => target.path !== null && (target.installed || "interrupted_update" in target && target.interrupted_update) && target.hint);
5630
+ const canUpdateTogether = commonCommand?.includes(" skills update ") && updateTargets.every((target) => target.update_command?.replace(/ --tool \S+ --scope \S+/, "") === commonCommand) && !targets.some((target) => target.path !== null && (target.installed || "interrupted_update" in target && target.interrupted_update) && target.hint) && !(newerLegacyOnly && commonCommand.includes(" --force"));
5560
5631
  return {
5561
5632
  bundled_version: bundled.version,
5562
5633
  update_available: targets.some((target) => target.update_available),
@@ -5589,12 +5660,13 @@ async function runSkillsUpdate(parsed, mode) {
5589
5660
  continue;
5590
5661
  }
5591
5662
  if (state.kind === "broken") return writeFailure(command, await conflictFor(target), mode, 1);
5592
- if (isNewer(state, bundled) && !force) {
5663
+ const version = await newerInstalledVersion(target, bundled);
5664
+ if (version !== void 0 && !force) {
5593
5665
  planned.push({
5594
5666
  target,
5595
5667
  action: "unchanged",
5596
5668
  preserve: true,
5597
- hint: newerCliHint(state.version, bundled.version)
5669
+ hint: newerCliHint(version, bundled.version)
5598
5670
  });
5599
5671
  continue;
5600
5672
  }
@@ -5607,10 +5679,11 @@ async function runSkillsUpdate(parsed, mode) {
5607
5679
  });
5608
5680
  continue;
5609
5681
  }
5610
- planned.push((await legacyRule(target))?.managed || (await diagnostic(target, bundled)).interrupted_update ? {
5682
+ planned.push((await targetInspection(target)).legacy?.managed || (await diagnostic(target, bundled)).interrupted_update ? {
5611
5683
  target,
5612
5684
  action: "installed",
5613
- content: bundled
5685
+ content: bundled,
5686
+ ...version !== void 0 ? { hint: downgradeHint(version, bundled.version) } : {}
5614
5687
  } : {
5615
5688
  target,
5616
5689
  action: "not_installed"
@@ -5624,7 +5697,7 @@ async function runSkillsUpdate(parsed, mode) {
5624
5697
  action: "updated",
5625
5698
  content: bundled,
5626
5699
  forceRetirement: force,
5627
- ...isNewer(state, bundled) ? { hint: downgradeHint(state.version, bundled.version) } : {}
5700
+ ...version !== void 0 ? { hint: downgradeHint(version, bundled.version) } : {}
5628
5701
  });
5629
5702
  else planned.push({
5630
5703
  target,
@@ -5664,7 +5737,7 @@ async function runSkillsRemove(parsed, mode) {
5664
5737
  });
5665
5738
  continue;
5666
5739
  }
5667
- const managedLegacy = (await legacyRule(target))?.managed === true;
5740
+ const managedLegacy = (await targetInspection(target)).legacy?.managed === true;
5668
5741
  const action = state.kind === "missing" ? managedLegacy || (await diagnostic(target, await loadBundledSkills())).interrupted_update ? "removed" : "not_installed" : state.kind === "managed" ? "removed" : "skipped_unmanaged";
5669
5742
  planned.push({
5670
5743
  target,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artifactshare/cli",
3
- "version": "0.20.2",
3
+ "version": "0.20.3",
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": {