@artifactshare/cli 0.20.1 → 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.
- package/CHANGELOG.md +13 -0
- package/README.md +29 -25
- package/dist/cli.js +339 -99
- package/package.json +1 -1
- package/skills/artifactshare/SKILL.md +2 -2
- package/skills/artifactshare/references/authentication-profiles-skills.md +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
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
|
+
|
|
11
|
+
## 0.20.2 - 2026-10-28
|
|
12
|
+
|
|
13
|
+
- Preserve newer managed skills during install unless force explicitly requests a downgrade.
|
|
14
|
+
- Skip unmanaged folders with protected-path links during update and removal (`skipped_unmanaged`), without reading their referents or reporting a list/doctor conflict.
|
|
15
|
+
- Preserve user-added skill links and report them in list/doctor; isolate protected-link conflicts so other selected targets finish.
|
|
16
|
+
- Never recommend downgrading newer installed skills; require explicit force and describe the downgrade.
|
|
17
|
+
- Clarify Japanese interrupted-update cleanup guidance and skill JSON partial failures.
|
|
18
|
+
|
|
6
19
|
## 0.20.1 - 2026-10-28
|
|
7
20
|
|
|
8
21
|
- 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,
|
|
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.
|
|
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
|
-
|
|
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,70 @@ 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
|
|
4303
|
-
|
|
4304
|
-
|
|
4304
|
+
async function protectedPaths(root, bundle, observedState) {
|
|
4305
|
+
await safe(root, MANIFEST);
|
|
4306
|
+
await safe(root, PENDING);
|
|
4307
|
+
const state = observedState ?? 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
|
+
var SkillPathError = class extends Error {
|
|
4341
|
+
isLink;
|
|
4342
|
+
constructor(message, isLink) {
|
|
4343
|
+
super(message);
|
|
4344
|
+
this.isLink = isLink;
|
|
4345
|
+
}
|
|
4346
|
+
};
|
|
4347
|
+
async function inspectTree(root, cleanup = false, folderRoot = root, protectedEntries, userLinks = []) {
|
|
4348
|
+
if (!await info(root)) return userLinks;
|
|
4349
|
+
for (const name of (await readdir(root)).sort()) {
|
|
4305
4350
|
const path = join(root, name);
|
|
4306
4351
|
const item = await lstat(path);
|
|
4307
|
-
if (item.isSymbolicLink())
|
|
4352
|
+
if (item.isSymbolicLink()) {
|
|
4353
|
+
const entry = relative(folderRoot, path).split(sep).join("/");
|
|
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);
|
|
4355
|
+
userLinks.push(entry);
|
|
4356
|
+
continue;
|
|
4357
|
+
}
|
|
4308
4358
|
if (item.isDirectory() && root === folderRoot && stagingName.test(name)) {
|
|
4309
|
-
|
|
4359
|
+
await inspectTree(path, false, folderRoot, protectedEntries, userLinks);
|
|
4360
|
+
if (cleanup && stale(item) && !userLinks.some((link) => link.startsWith(`${name}/`))) await rm(path, {
|
|
4310
4361
|
recursive: true,
|
|
4311
4362
|
force: true
|
|
4312
4363
|
});
|
|
4313
|
-
} else if (item.isDirectory()) await inspectTree(path, cleanup, folderRoot);
|
|
4364
|
+
} else if (item.isDirectory()) await inspectTree(path, cleanup, folderRoot, protectedEntries, userLinks);
|
|
4314
4365
|
else if (cleanup && item.isFile() && legacyTemp.test(name) && stale(item)) await unlink(path);
|
|
4315
4366
|
}
|
|
4367
|
+
return userLinks.sort();
|
|
4316
4368
|
}
|
|
4317
4369
|
async function cleanupSkillFolder(entry, bundle) {
|
|
4318
4370
|
const root = await rootFor(entry);
|
|
@@ -4320,7 +4372,9 @@ async function cleanupSkillFolder(entry, bundle) {
|
|
|
4320
4372
|
const pending = await ownership(root, await stateAt(root), PENDING);
|
|
4321
4373
|
if (pending.manifest && pending.manifest.version > bundle.version) throw new Error(newerIntentHint(pending.manifest.version));
|
|
4322
4374
|
}
|
|
4323
|
-
await
|
|
4375
|
+
const protection = await protectedPaths(root, bundle);
|
|
4376
|
+
await inspectTree(root, false, root, protection);
|
|
4377
|
+
await inspectTree(root, true, root, protection);
|
|
4324
4378
|
const parent = dirname(root);
|
|
4325
4379
|
if (await info(parent)) for (const name of await readdir(parent)) {
|
|
4326
4380
|
if (!stagingName.test(name)) continue;
|
|
@@ -4341,7 +4395,7 @@ async function safe(root, relative, retiredAncestors = /* @__PURE__ */ new Set()
|
|
|
4341
4395
|
const item = await info(parts[i]);
|
|
4342
4396
|
if (i < parts.length - 1 && item?.isFile() && retiredAncestors.has(parts[i])) return;
|
|
4343
4397
|
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
|
|
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());
|
|
4345
4399
|
}
|
|
4346
4400
|
}
|
|
4347
4401
|
async function bytesAt(root, path) {
|
|
@@ -4354,21 +4408,50 @@ async function bytesAt(root, path) {
|
|
|
4354
4408
|
async function textAt(root, path) {
|
|
4355
4409
|
return (await bytesAt(root, path))?.toString("utf8") ?? null;
|
|
4356
4410
|
}
|
|
4357
|
-
async function
|
|
4411
|
+
async function inspectAt(root, managedLegacy) {
|
|
4412
|
+
const entry = await info(join(root, "SKILL.md"));
|
|
4413
|
+
const recordsAbsent = !await info(join(root, MANIFEST)) && !await info(join(root, PENDING));
|
|
4414
|
+
const linkedEntry = entry?.isSymbolicLink() === true;
|
|
4415
|
+
let state;
|
|
4358
4416
|
try {
|
|
4359
|
-
|
|
4417
|
+
state = linkedEntry && recordsAbsent ? { kind: "unmanaged" } : managedState(await textAt(root, "SKILL.md"));
|
|
4360
4418
|
} catch {
|
|
4361
|
-
|
|
4419
|
+
state = { kind: "broken" };
|
|
4362
4420
|
}
|
|
4421
|
+
return {
|
|
4422
|
+
root,
|
|
4423
|
+
state,
|
|
4424
|
+
linkedEntry,
|
|
4425
|
+
unowned: !managedLegacy && recordsAbsent && (!entry || linkedEntry || state.kind === "unmanaged")
|
|
4426
|
+
};
|
|
4363
4427
|
}
|
|
4364
|
-
async function
|
|
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;
|
|
4365
4437
|
try {
|
|
4366
|
-
|
|
4438
|
+
root = await rootFor(entry);
|
|
4367
4439
|
} catch (error) {
|
|
4368
|
-
|
|
4440
|
+
return failed(null, error instanceof SkillFolderResolutionError && error.missingAncestor ? {
|
|
4369
4441
|
kind: "missing",
|
|
4370
4442
|
hint: error.message
|
|
4371
|
-
};
|
|
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 {
|
|
4372
4455
|
return { kind: "broken" };
|
|
4373
4456
|
}
|
|
4374
4457
|
}
|
|
@@ -4436,11 +4519,14 @@ async function recoveryOwnership(root, state) {
|
|
|
4436
4519
|
recorded
|
|
4437
4520
|
};
|
|
4438
4521
|
}
|
|
4439
|
-
async function folderDiagnostics(entry, bundle) {
|
|
4440
|
-
|
|
4522
|
+
async function folderDiagnostics(entry, bundle, context = false) {
|
|
4523
|
+
const inspection = typeof context === "boolean" ? await inspectSkillFolder(entry, context) : context;
|
|
4524
|
+
let root = inspection.root;
|
|
4525
|
+
let user_links = [];
|
|
4441
4526
|
try {
|
|
4442
|
-
|
|
4443
|
-
|
|
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));
|
|
4444
4530
|
} catch (error) {
|
|
4445
4531
|
return {
|
|
4446
4532
|
folder_path: dirname(entry),
|
|
@@ -4458,7 +4544,7 @@ async function folderDiagnostics(entry, bundle) {
|
|
|
4458
4544
|
hint: error.message
|
|
4459
4545
|
};
|
|
4460
4546
|
}
|
|
4461
|
-
const state =
|
|
4547
|
+
const state = inspection.state;
|
|
4462
4548
|
const { owned, pending, recorded } = await recoveryOwnership(root, state);
|
|
4463
4549
|
const newerIntent = pending.manifest && pending.manifest.version > bundle.version;
|
|
4464
4550
|
const missing_files = [], different_files = [], modified_files = [];
|
|
@@ -4479,6 +4565,7 @@ async function folderDiagnostics(entry, bundle) {
|
|
|
4479
4565
|
current: state.kind === "managed" && state.version === bundle.version && !missing_files.length && !different_files.length && owned.status === "valid" && manifestMatches && pending.status === "absent",
|
|
4480
4566
|
...pending.status !== "absent" ? { interrupted_update: true } : {},
|
|
4481
4567
|
older_version: state.kind === "managed" && state.version < bundle.version,
|
|
4568
|
+
user_links,
|
|
4482
4569
|
missing_files,
|
|
4483
4570
|
different_files,
|
|
4484
4571
|
modified_files,
|
|
@@ -4489,13 +4576,13 @@ async function folderDiagnostics(entry, bundle) {
|
|
|
4489
4576
|
function newerIntentHint(version) {
|
|
4490
4577
|
return `Interrupted skill update requires a newer CLI with bundled skill version ${version} or later. Upgrade the CLI, then retry.`;
|
|
4491
4578
|
}
|
|
4492
|
-
async function preflightFolder(entry, bundle, force = false, forceRetirement = force) {
|
|
4579
|
+
async function preflightFolder(entry, bundle, force = false, forceRetirement = force, removing = false) {
|
|
4493
4580
|
const root = await rootFor(entry);
|
|
4494
4581
|
const state = await stateAt(root);
|
|
4495
|
-
await inspectTree(root);
|
|
4582
|
+
await inspectTree(root, false, root, await protectedPaths(root, bundle));
|
|
4496
4583
|
await safe(root, "SKILL.md");
|
|
4497
4584
|
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));
|
|
4585
|
+
if (!removing && bundle && pending.manifest && pending.manifest.version > bundle.version) throw new Error(newerIntentHint(pending.manifest.version));
|
|
4499
4586
|
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
4587
|
const previous = recorded;
|
|
4501
4588
|
await safe(root, PENDING);
|
|
@@ -4522,7 +4609,7 @@ async function preflightFolder(entry, bundle, force = false, forceRetirement = f
|
|
|
4522
4609
|
}
|
|
4523
4610
|
replacedDirectories.add(join(root, relative));
|
|
4524
4611
|
};
|
|
4525
|
-
for (const path of Object.keys(bundle?.files ?? {})) {
|
|
4612
|
+
for (const path of Object.keys(removing ? {} : bundle?.files ?? {})) {
|
|
4526
4613
|
if (!blockers.some((ancestor) => path.startsWith(`${ancestor}/`))) {
|
|
4527
4614
|
await safe(root, path, retiredAncestors, /* @__PURE__ */ new Set([join(root, path)]));
|
|
4528
4615
|
if ((await info(join(root, path)))?.isDirectory()) await checkDirectory(path);
|
|
@@ -4674,8 +4761,8 @@ async function writeSkillFolder(entry, bundle, force = false, forceRetirement =
|
|
|
4674
4761
|
for (const dir of [...createdDirectories].reverse()) await rmdir(dir).catch(() => {});
|
|
4675
4762
|
}
|
|
4676
4763
|
}
|
|
4677
|
-
async function removeSkillFolder(entry, retainRoot = false) {
|
|
4678
|
-
const { root, previous } = await preflightFolder(entry);
|
|
4764
|
+
async function removeSkillFolder(entry, retainRoot = false, bundle) {
|
|
4765
|
+
const { root, previous } = await preflightFolder(entry, bundle, false, false, true);
|
|
4679
4766
|
for (const path of [
|
|
4680
4767
|
...Object.keys(previous),
|
|
4681
4768
|
MANIFEST,
|
|
@@ -4742,8 +4829,12 @@ function targetOrder(a, b) {
|
|
|
4742
4829
|
}
|
|
4743
4830
|
async function cleanupTarget(target, bundled) {
|
|
4744
4831
|
if (target.cleaned) return;
|
|
4745
|
-
|
|
4746
|
-
|
|
4832
|
+
try {
|
|
4833
|
+
await cleanupSkillFolder(target.absolutePath, bundled);
|
|
4834
|
+
target.cleaned = true;
|
|
4835
|
+
} finally {
|
|
4836
|
+
delete target.inspection;
|
|
4837
|
+
}
|
|
4747
4838
|
}
|
|
4748
4839
|
async function groupTargets(targets) {
|
|
4749
4840
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -4756,8 +4847,10 @@ async function groupTargets(targets) {
|
|
|
4756
4847
|
const key = await resolveSkillFolder(target.absolutePath).catch(() => null);
|
|
4757
4848
|
target.resolved_folder_path = key;
|
|
4758
4849
|
const existing = key === null ? void 0 : groups.get(key);
|
|
4759
|
-
if (existing && availableTarget(existing))
|
|
4760
|
-
|
|
4850
|
+
if (existing && availableTarget(existing)) {
|
|
4851
|
+
existing.aliases = [...aliases(existing), ...aliases(target)];
|
|
4852
|
+
delete existing.inspection;
|
|
4853
|
+
} else {
|
|
4761
4854
|
target.aliases = aliases(target);
|
|
4762
4855
|
result.push(target);
|
|
4763
4856
|
if (key !== null) groups.set(key, target);
|
|
@@ -4765,10 +4858,10 @@ async function groupTargets(targets) {
|
|
|
4765
4858
|
}
|
|
4766
4859
|
return result;
|
|
4767
4860
|
}
|
|
4768
|
-
async function conflictFor(target) {
|
|
4861
|
+
async function conflictFor(target, removing = false) {
|
|
4769
4862
|
const error = skillUpdateConflictError(target.path);
|
|
4770
4863
|
try {
|
|
4771
|
-
await preflightFolder(target.absolutePath);
|
|
4864
|
+
await preflightFolder(target.absolutePath, await loadBundledSkills(), false, false, removing);
|
|
4772
4865
|
} catch (cause) {
|
|
4773
4866
|
error.hint = cause.message;
|
|
4774
4867
|
}
|
|
@@ -4852,8 +4945,23 @@ function skillTarget(tool, scope) {
|
|
|
4852
4945
|
function allTargets() {
|
|
4853
4946
|
return SKILL_TOOLS.flatMap((tool) => TOOL_CONFIG[tool].scopes.map((scope) => skillTarget(tool, scope)));
|
|
4854
4947
|
}
|
|
4855
|
-
function
|
|
4856
|
-
|
|
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;
|
|
4857
4965
|
}
|
|
4858
4966
|
function loadBundledSkills() {
|
|
4859
4967
|
return loadSkillBundle(fileURLToPath(new URL("../skills/artifactshare/", import.meta.url)));
|
|
@@ -4869,31 +4977,43 @@ async function legacyRule(target) {
|
|
|
4869
4977
|
const parent = await lstat(dirname(path)).catch(() => null);
|
|
4870
4978
|
const content = info?.isFile() && !parent?.isSymbolicLink() ? await readFile(path, "utf8").catch(() => null) : null;
|
|
4871
4979
|
const present = info !== null;
|
|
4872
|
-
const
|
|
4980
|
+
const state = managedState(content);
|
|
4981
|
+
const managed = state.kind === "managed";
|
|
4982
|
+
const coexistence = present && await lstat(resolve(cursor.path)).catch(() => null) !== null;
|
|
4873
4983
|
return {
|
|
4874
4984
|
path,
|
|
4875
4985
|
present,
|
|
4876
4986
|
managed,
|
|
4877
|
-
|
|
4987
|
+
...state.kind === "managed" ? { version: state.version } : {},
|
|
4988
|
+
coexistence,
|
|
4878
4989
|
hint: present && !managed ? "Inspect the legacy Cursor rule and manually remove it if the skill folder replaces it." : null
|
|
4879
4990
|
};
|
|
4880
4991
|
}
|
|
4992
|
+
function legacyRuleOutput({ version: _version, ...rule }) {
|
|
4993
|
+
return rule;
|
|
4994
|
+
}
|
|
4881
4995
|
async function legacyManagedVersion(target) {
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
return
|
|
4996
|
+
return (await legacyRule(target))?.version;
|
|
4997
|
+
}
|
|
4998
|
+
function newerCliHint(installed, bundled) {
|
|
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.`;
|
|
5000
|
+
}
|
|
5001
|
+
function downgradeHint(installed, bundled) {
|
|
5002
|
+
return `Intentional downgrade from skill version ${installed} to bundled version ${bundled}.`;
|
|
4886
5003
|
}
|
|
4887
5004
|
async function diagnostic(target, bundle) {
|
|
4888
|
-
const legacy = await
|
|
5005
|
+
const { folder, legacy } = await targetInspection(target);
|
|
5006
|
+
const version = await newerInstalledVersion(target, bundle);
|
|
5007
|
+
const details = await folderDiagnostics(target.absolutePath, bundle, folder);
|
|
4889
5008
|
return {
|
|
4890
|
-
...
|
|
5009
|
+
...details,
|
|
4891
5010
|
folder_path: dirname(target.path),
|
|
4892
|
-
...
|
|
5011
|
+
...version !== void 0 ? { hint: [details.hint, newerCliHint(version, bundle.version)].filter(Boolean).join(" ") } : {},
|
|
5012
|
+
...legacy ? { legacy_rule: legacyRuleOutput(legacy) } : {}
|
|
4893
5013
|
};
|
|
4894
5014
|
}
|
|
4895
5015
|
async function isCurrent(target, bundle) {
|
|
4896
|
-
return (await
|
|
5016
|
+
return (await diagnostic(target, bundle)).current;
|
|
4897
5017
|
}
|
|
4898
5018
|
function parseTools(value, options = {}) {
|
|
4899
5019
|
const raws = arrayOption(value);
|
|
@@ -4987,6 +5107,7 @@ function targetPathKey(target) {
|
|
|
4987
5107
|
return resolveSkillFolder(target.absolutePath).catch(() => target.absolutePath);
|
|
4988
5108
|
}
|
|
4989
5109
|
async function prepareAction(item, dryRun) {
|
|
5110
|
+
if (item.preserve || item.action === "failed") return;
|
|
4990
5111
|
if (!dryRun && (item.content || item.action === "unchanged")) await cleanupTarget(item.target, item.content ?? await loadBundledSkills());
|
|
4991
5112
|
if (item.content) {
|
|
4992
5113
|
if (item.automatic) {
|
|
@@ -4995,7 +5116,7 @@ async function prepareAction(item, dryRun) {
|
|
|
4995
5116
|
}
|
|
4996
5117
|
await preflightFolder(item.target.absolutePath, item.content, item.force, item.forceRetirement);
|
|
4997
5118
|
}
|
|
4998
|
-
if (item.action === "removed") await preflightFolder(item.target.absolutePath);
|
|
5119
|
+
if (item.action === "removed") await preflightFolder(item.target.absolutePath, await loadBundledSkills(), false, false, true);
|
|
4999
5120
|
const legacy = await legacyRule(item.target);
|
|
5000
5121
|
if (legacy?.managed && item.action === "unchanged" && !await isCurrent(item.target, await loadBundledSkills())) {
|
|
5001
5122
|
item.action = "update_recommended";
|
|
@@ -5014,16 +5135,21 @@ async function prepareAction(item, dryRun) {
|
|
|
5014
5135
|
}
|
|
5015
5136
|
}
|
|
5016
5137
|
async function applyAction(item) {
|
|
5017
|
-
if (item.
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
await
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5138
|
+
if (item.preserve || item.action === "failed") return;
|
|
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;
|
|
5027
5153
|
}
|
|
5028
5154
|
}
|
|
5029
5155
|
function skillUpdateCommand(target) {
|
|
@@ -5031,10 +5157,14 @@ function skillUpdateCommand(target) {
|
|
|
5031
5157
|
}
|
|
5032
5158
|
async function recoveryRecommendation(target, bundled) {
|
|
5033
5159
|
const details = await diagnostic(target, bundled);
|
|
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) };
|
|
5034
5163
|
let update_command = skillUpdateCommand(target);
|
|
5164
|
+
let collision;
|
|
5035
5165
|
try {
|
|
5036
5166
|
await preflightFolder(target.absolutePath, bundled);
|
|
5037
|
-
} catch {
|
|
5167
|
+
} catch (first) {
|
|
5038
5168
|
try {
|
|
5039
5169
|
await preflightFolder(target.absolutePath, bundled, false, true);
|
|
5040
5170
|
update_command = update_command.replace(" --json", " --force --json");
|
|
@@ -5042,7 +5172,9 @@ async function recoveryRecommendation(target, bundled) {
|
|
|
5042
5172
|
try {
|
|
5043
5173
|
await preflightFolder(target.absolutePath, bundled, true);
|
|
5044
5174
|
update_command = `${CLI_INVOCATION} skills install --tool ${target.tool} --scope ${target.scope} --force --json`;
|
|
5175
|
+
if (folder.unowned) collision = first.message;
|
|
5045
5176
|
} catch (error) {
|
|
5177
|
+
if (folder.unowned && error instanceof SkillPathError && error.isLink) return { suppressHint: true };
|
|
5046
5178
|
return {
|
|
5047
5179
|
hint: error.message,
|
|
5048
5180
|
...details.modified_files.length ? { modified_files: details.modified_files } : {}
|
|
@@ -5052,6 +5184,7 @@ async function recoveryRecommendation(target, bundled) {
|
|
|
5052
5184
|
}
|
|
5053
5185
|
return {
|
|
5054
5186
|
update_command,
|
|
5187
|
+
...collision ? { hint: collision } : {},
|
|
5055
5188
|
...details.modified_files.length ? {
|
|
5056
5189
|
modified_files: details.modified_files,
|
|
5057
5190
|
hint: `Modified skill files: ${details.modified_files.join(", ")}. Preserve your edits before running the recommended command.`
|
|
@@ -5072,6 +5205,7 @@ async function finishActions(command, planned, dryRun, mode) {
|
|
|
5072
5205
|
item.hint = error.message;
|
|
5073
5206
|
item.action = item.fallbackAction;
|
|
5074
5207
|
delete item.content;
|
|
5208
|
+
delete item.legacy;
|
|
5075
5209
|
continue;
|
|
5076
5210
|
}
|
|
5077
5211
|
const conflict = skillUpdateConflictError(item.target.path);
|
|
@@ -5097,17 +5231,21 @@ async function finishActions(command, planned, dryRun, mode) {
|
|
|
5097
5231
|
}
|
|
5098
5232
|
return {
|
|
5099
5233
|
dry_run: dryRun,
|
|
5100
|
-
targets: await Promise.all(completed.map(async ({ target, action, legacy, hint }) =>
|
|
5101
|
-
...
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
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
|
+
}))
|
|
5111
5249
|
};
|
|
5112
5250
|
}
|
|
5113
5251
|
async function runActions(command, planned, dryRun, mode, unavailableTargets = []) {
|
|
@@ -5124,6 +5262,7 @@ async function runActions(command, planned, dryRun, mode, unavailableTargets = [
|
|
|
5124
5262
|
hint: target.error.hint
|
|
5125
5263
|
})));
|
|
5126
5264
|
writeSuccess(command, data, mode);
|
|
5265
|
+
if (data.targets.some((target) => target.action === "failed")) process.exitCode = 1;
|
|
5127
5266
|
}
|
|
5128
5267
|
}
|
|
5129
5268
|
async function bundledOrFailure(command, mode) {
|
|
@@ -5149,7 +5288,23 @@ async function runSkillsInstall(parsed, mode) {
|
|
|
5149
5288
|
if (!availableTarget(target)) return writeFailure(command, target.error, mode, 1);
|
|
5150
5289
|
const state = await readTarget(target);
|
|
5151
5290
|
if ((state.kind === "unmanaged" || state.kind === "broken") && !force) return writeFailure(command, await conflictFor(target), mode, 1);
|
|
5152
|
-
|
|
5291
|
+
const version = await newerInstalledVersion(target, bundled);
|
|
5292
|
+
if (version !== void 0 && !force) {
|
|
5293
|
+
planned.push({
|
|
5294
|
+
target,
|
|
5295
|
+
action: "unchanged",
|
|
5296
|
+
preserve: true,
|
|
5297
|
+
hint: newerCliHint(version, bundled.version)
|
|
5298
|
+
});
|
|
5299
|
+
continue;
|
|
5300
|
+
}
|
|
5301
|
+
const details = await diagnostic(target, bundled);
|
|
5302
|
+
if (details.code === "skill_update_conflict") {
|
|
5303
|
+
const conflict = skillUpdateConflictError(target.path);
|
|
5304
|
+
conflict.hint = details.hint ?? conflict.hint;
|
|
5305
|
+
return writeFailure(command, conflict, mode, 1);
|
|
5306
|
+
}
|
|
5307
|
+
if (state.kind === "managed" && details.current && !force) {
|
|
5153
5308
|
planned.push({
|
|
5154
5309
|
target,
|
|
5155
5310
|
action: "unchanged"
|
|
@@ -5160,7 +5315,8 @@ async function runSkillsInstall(parsed, mode) {
|
|
|
5160
5315
|
target,
|
|
5161
5316
|
action: state.kind === "missing" ? "installed" : "updated",
|
|
5162
5317
|
content: bundled,
|
|
5163
|
-
force
|
|
5318
|
+
force,
|
|
5319
|
+
...version !== void 0 ? { hint: downgradeHint(version, bundled.version) } : {}
|
|
5164
5320
|
});
|
|
5165
5321
|
}
|
|
5166
5322
|
await runActions(command, planned, parsed.options.dryRun === true, mode);
|
|
@@ -5186,9 +5342,30 @@ async function ensureSkills(parsed, mode, options = {}) {
|
|
|
5186
5342
|
const targets = (filters.auto ? await autoTargets(filters.scope) : void 0)?.targets ?? filteredTargets(filters.tools, filters.scope ?? "project");
|
|
5187
5343
|
const planned = [];
|
|
5188
5344
|
for (const target of await groupTargets(targets)) {
|
|
5189
|
-
const
|
|
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) {
|
|
5349
|
+
if (filters.auto) planned.push({
|
|
5350
|
+
target,
|
|
5351
|
+
action: "skipped_unmanaged"
|
|
5352
|
+
});
|
|
5353
|
+
continue;
|
|
5354
|
+
}
|
|
5355
|
+
const conflicted = state.kind === "broken" || linkedSkill;
|
|
5356
|
+
if (filters.auto && command === "skills ensure" && conflicted) {
|
|
5357
|
+
const details = await diagnostic(target, bundled);
|
|
5358
|
+
if (details.code === "skill_update_conflict") {
|
|
5359
|
+
planned.push({
|
|
5360
|
+
target,
|
|
5361
|
+
action: "failed",
|
|
5362
|
+
hint: details.hint ?? skillUpdateConflictError(target.path).hint
|
|
5363
|
+
});
|
|
5364
|
+
continue;
|
|
5365
|
+
}
|
|
5366
|
+
}
|
|
5190
5367
|
if (state.kind === "unmanaged" || state.kind === "broken") {
|
|
5191
|
-
if (options.skipBrokenUserSkills &&
|
|
5368
|
+
if (options.skipBrokenUserSkills && conflicted) {
|
|
5192
5369
|
const details = await diagnostic(target, bundled);
|
|
5193
5370
|
if (details.hint) planned.push({
|
|
5194
5371
|
target,
|
|
@@ -5203,7 +5380,17 @@ async function ensureSkills(parsed, mode, options = {}) {
|
|
|
5203
5380
|
}
|
|
5204
5381
|
const automaticUpdate = filters.auto || options.command === "init" || options.command === "open";
|
|
5205
5382
|
if (automaticUpdate && state.kind === "missing" && state.hint) continue;
|
|
5206
|
-
|
|
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
|
+
}
|
|
5207
5394
|
const details = await diagnostic(target, bundled);
|
|
5208
5395
|
if (automaticUpdate && state.kind === "managed" && details.modified_files.length) {
|
|
5209
5396
|
planned.push({
|
|
@@ -5231,6 +5418,7 @@ async function ensureSkills(parsed, mode, options = {}) {
|
|
|
5231
5418
|
if (plannedPaths.has(await targetPathKey(target))) {
|
|
5232
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);
|
|
5233
5420
|
if (existing) {
|
|
5421
|
+
delete existing.target.inspection;
|
|
5234
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);
|
|
5235
5423
|
const primary = existing.target.aliases[0];
|
|
5236
5424
|
existing.target.tool = primary.tool;
|
|
@@ -5346,26 +5534,32 @@ async function autoUpdateUserManagedSkills() {
|
|
|
5346
5534
|
...item.installedVersion !== void 0 ? { installedVersion: item.installedVersion } : {}
|
|
5347
5535
|
};
|
|
5348
5536
|
}
|
|
5349
|
-
return { targets: await Promise.all(completed.map(async ({ target, action, installedVersion, legacy, hint }) =>
|
|
5350
|
-
...
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
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
|
+
})) };
|
|
5362
5553
|
} catch {
|
|
5363
5554
|
return;
|
|
5364
5555
|
}
|
|
5365
5556
|
}
|
|
5366
5557
|
async function runSkillsEnsure(parsed, mode) {
|
|
5367
5558
|
const data = await ensureSkills(parsed, mode);
|
|
5368
|
-
if (data)
|
|
5559
|
+
if (data) {
|
|
5560
|
+
writeSuccess("skills ensure", data, mode);
|
|
5561
|
+
if (data.targets.some((target) => target.action === "failed")) process.exitCode = 1;
|
|
5562
|
+
}
|
|
5369
5563
|
}
|
|
5370
5564
|
async function runSkillsList(parsed, mode) {
|
|
5371
5565
|
const bundled = await bundledOrFailure("skills list", mode);
|
|
@@ -5390,7 +5584,7 @@ async function runSkillsList(parsed, mode) {
|
|
|
5390
5584
|
installed: state.kind !== "missing",
|
|
5391
5585
|
managed: state.kind === "managed",
|
|
5392
5586
|
installed_version: state.kind === "managed" ? state.version : null,
|
|
5393
|
-
update_available: state.kind === "managed" && state.version
|
|
5587
|
+
update_available: state.kind === "managed" && state.version < bundled.version
|
|
5394
5588
|
});
|
|
5395
5589
|
}
|
|
5396
5590
|
return writeSuccess("skills list", {
|
|
@@ -5401,6 +5595,7 @@ async function runSkillsList(parsed, mode) {
|
|
|
5401
5595
|
async function skillDiagnostics() {
|
|
5402
5596
|
const bundled = await loadBundledSkills();
|
|
5403
5597
|
const targets = [];
|
|
5598
|
+
let newerLegacyOnly = false;
|
|
5404
5599
|
for (const target of await groupTargets(allTargets())) {
|
|
5405
5600
|
if (!availableTarget(target)) {
|
|
5406
5601
|
targets.push({
|
|
@@ -5411,9 +5606,11 @@ async function skillDiagnostics() {
|
|
|
5411
5606
|
}
|
|
5412
5607
|
const state = await readTarget(target);
|
|
5413
5608
|
const details = await diagnostic(target, bundled);
|
|
5414
|
-
const updateAvailable = state.kind === "managed" && state.version
|
|
5609
|
+
const updateAvailable = state.kind === "managed" && state.version < bundled.version;
|
|
5415
5610
|
const recommendation = await recoveryRecommendation(target, bundled);
|
|
5416
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;
|
|
5417
5614
|
targets.push({
|
|
5418
5615
|
tool: target.tool,
|
|
5419
5616
|
scope: target.scope,
|
|
@@ -5424,13 +5621,13 @@ async function skillDiagnostics() {
|
|
|
5424
5621
|
update_available: updateAvailable,
|
|
5425
5622
|
...identity(target),
|
|
5426
5623
|
...details,
|
|
5427
|
-
|
|
5428
|
-
update_command
|
|
5624
|
+
...(!recoveryCommand || !update_command && !details.hint) && recommendation.hint ? { hint: recommendation.hint } : {},
|
|
5625
|
+
update_command
|
|
5429
5626
|
});
|
|
5430
5627
|
}
|
|
5431
5628
|
const updateTargets = targets.filter((target) => target.update_command !== null);
|
|
5432
5629
|
const commonCommand = updateTargets[0]?.update_command?.replace(/ --tool \S+ --scope \S+/, "");
|
|
5433
|
-
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"));
|
|
5434
5631
|
return {
|
|
5435
5632
|
bundled_version: bundled.version,
|
|
5436
5633
|
update_available: targets.some((target) => target.update_available),
|
|
@@ -5450,7 +5647,29 @@ async function runSkillsUpdate(parsed, mode) {
|
|
|
5450
5647
|
const planned = [];
|
|
5451
5648
|
for (const target of await groupTargets(filteredTargets(filters.tools, filters.scope))) {
|
|
5452
5649
|
const state = await readTarget(target);
|
|
5650
|
+
const details = await diagnostic(target, bundled);
|
|
5651
|
+
if (details.code === "skill_update_conflict") {
|
|
5652
|
+
const conflict = skillUpdateConflictError(target.path);
|
|
5653
|
+
conflict.hint = details.hint ?? conflict.hint;
|
|
5654
|
+
if (filters.tools.length) return writeFailure(command, conflict, mode, 1);
|
|
5655
|
+
planned.push({
|
|
5656
|
+
target,
|
|
5657
|
+
action: "failed",
|
|
5658
|
+
hint: conflict.hint
|
|
5659
|
+
});
|
|
5660
|
+
continue;
|
|
5661
|
+
}
|
|
5453
5662
|
if (state.kind === "broken") return writeFailure(command, await conflictFor(target), mode, 1);
|
|
5663
|
+
const version = await newerInstalledVersion(target, bundled);
|
|
5664
|
+
if (version !== void 0 && !force) {
|
|
5665
|
+
planned.push({
|
|
5666
|
+
target,
|
|
5667
|
+
action: "unchanged",
|
|
5668
|
+
preserve: true,
|
|
5669
|
+
hint: newerCliHint(version, bundled.version)
|
|
5670
|
+
});
|
|
5671
|
+
continue;
|
|
5672
|
+
}
|
|
5454
5673
|
if (state.kind === "missing") {
|
|
5455
5674
|
if (state.hint) {
|
|
5456
5675
|
planned.push({
|
|
@@ -5460,10 +5679,11 @@ async function runSkillsUpdate(parsed, mode) {
|
|
|
5460
5679
|
});
|
|
5461
5680
|
continue;
|
|
5462
5681
|
}
|
|
5463
|
-
planned.push((await
|
|
5682
|
+
planned.push((await targetInspection(target)).legacy?.managed || (await diagnostic(target, bundled)).interrupted_update ? {
|
|
5464
5683
|
target,
|
|
5465
5684
|
action: "installed",
|
|
5466
|
-
content: bundled
|
|
5685
|
+
content: bundled,
|
|
5686
|
+
...version !== void 0 ? { hint: downgradeHint(version, bundled.version) } : {}
|
|
5467
5687
|
} : {
|
|
5468
5688
|
target,
|
|
5469
5689
|
action: "not_installed"
|
|
@@ -5476,13 +5696,15 @@ async function runSkillsUpdate(parsed, mode) {
|
|
|
5476
5696
|
target,
|
|
5477
5697
|
action: "updated",
|
|
5478
5698
|
content: bundled,
|
|
5479
|
-
forceRetirement: force
|
|
5699
|
+
forceRetirement: force,
|
|
5700
|
+
...version !== void 0 ? { hint: downgradeHint(version, bundled.version) } : {}
|
|
5480
5701
|
});
|
|
5481
5702
|
else planned.push({
|
|
5482
5703
|
target,
|
|
5483
5704
|
action: "unchanged"
|
|
5484
5705
|
});
|
|
5485
5706
|
}
|
|
5707
|
+
if (!filters.tools.length) for (const item of planned) item.fallbackAction = "failed";
|
|
5486
5708
|
await runActions(command, planned, parsed.options.dryRun === true, mode, unavailableActionTargets(filters.tools, filters.scope));
|
|
5487
5709
|
}
|
|
5488
5710
|
async function runSkillsRemove(parsed, mode) {
|
|
@@ -5494,7 +5716,19 @@ async function runSkillsRemove(parsed, mode) {
|
|
|
5494
5716
|
const planned = [];
|
|
5495
5717
|
for (const target of await groupTargets(filteredTargets(filters.tools, filters.scope))) {
|
|
5496
5718
|
const state = await readTarget(target);
|
|
5497
|
-
|
|
5719
|
+
const details = await diagnostic(target, await loadBundledSkills());
|
|
5720
|
+
if (details.code === "skill_update_conflict") {
|
|
5721
|
+
const conflict = skillUpdateConflictError(target.path);
|
|
5722
|
+
conflict.hint = details.hint ?? conflict.hint;
|
|
5723
|
+
if (filters.tools.length) return writeFailure(command, conflict, mode, 1);
|
|
5724
|
+
planned.push({
|
|
5725
|
+
target,
|
|
5726
|
+
action: "failed",
|
|
5727
|
+
hint: conflict.hint
|
|
5728
|
+
});
|
|
5729
|
+
continue;
|
|
5730
|
+
}
|
|
5731
|
+
if (state.kind === "broken") return writeFailure(command, await conflictFor(target, true), mode, 1);
|
|
5498
5732
|
if (state.kind === "missing" && state.hint) {
|
|
5499
5733
|
planned.push({
|
|
5500
5734
|
target,
|
|
@@ -5503,7 +5737,7 @@ async function runSkillsRemove(parsed, mode) {
|
|
|
5503
5737
|
});
|
|
5504
5738
|
continue;
|
|
5505
5739
|
}
|
|
5506
|
-
const managedLegacy = (await
|
|
5740
|
+
const managedLegacy = (await targetInspection(target)).legacy?.managed === true;
|
|
5507
5741
|
const action = state.kind === "missing" ? managedLegacy || (await diagnostic(target, await loadBundledSkills())).interrupted_update ? "removed" : "not_installed" : state.kind === "managed" ? "removed" : "skipped_unmanaged";
|
|
5508
5742
|
planned.push({
|
|
5509
5743
|
target,
|
|
@@ -5511,6 +5745,7 @@ async function runSkillsRemove(parsed, mode) {
|
|
|
5511
5745
|
removeLegacy: true
|
|
5512
5746
|
});
|
|
5513
5747
|
}
|
|
5748
|
+
if (!filters.tools.length) for (const item of planned) item.fallbackAction = "failed";
|
|
5514
5749
|
await runActions(command, planned, parsed.options.dryRun === true, mode, unavailableActionTargets(filters.tools, filters.scope));
|
|
5515
5750
|
}
|
|
5516
5751
|
//#endregion
|
|
@@ -16693,7 +16928,7 @@ const skillsInstallDefinition = define({
|
|
|
16693
16928
|
force: {
|
|
16694
16929
|
type: "boolean",
|
|
16695
16930
|
toKebab: true,
|
|
16696
|
-
description: "Take over bundled paths
|
|
16931
|
+
description: "Take over bundled paths or intentionally downgrade; preserve user additions"
|
|
16697
16932
|
}
|
|
16698
16933
|
},
|
|
16699
16934
|
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills install --tool codex --scope project --json
|
|
@@ -16702,6 +16937,7 @@ npm exec --yes --package=@artifactshare/cli -- artifactshare skills install --to
|
|
|
16702
16937
|
Writes SKILL.md and bundled references into skills/artifactshare/ for every tool and scope.
|
|
16703
16938
|
Project Cursor uses .cursor/skills/artifactshare/. A manifest tracks owned files.
|
|
16704
16939
|
Files without the Artifact Share managed marker are never overwritten without --force.
|
|
16940
|
+
Newer installed versions are unchanged with a newer-CLI hint unless --force requests an intentional downgrade; dry runs report the same plan.
|
|
16705
16941
|
|
|
16706
16942
|
Claude Code user skills go to $CLAUDE_CONFIG_DIR/skills when set, otherwise
|
|
16707
16943
|
~/.claude/skills. Relative paths resolve against cwd without tilde expansion.
|
|
@@ -16735,14 +16971,17 @@ const skillsUpdateDefinition = define({
|
|
|
16735
16971
|
force: {
|
|
16736
16972
|
type: "boolean",
|
|
16737
16973
|
toKebab: true,
|
|
16738
|
-
description: "Rewrite managed folder files; never take over an unmanaged entry"
|
|
16974
|
+
description: "Rewrite managed folder files, allowing an explicit downgrade; never take over an unmanaged entry"
|
|
16739
16975
|
}
|
|
16740
16976
|
},
|
|
16741
16977
|
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills update --json
|
|
16742
16978
|
npm exec --yes --package=@artifactshare/cli -- artifactshare skills update --tool codex --scope user --json
|
|
16743
16979
|
|
|
16744
16980
|
Updates managed folders and repairs missing files. Edited owned files require --force; user additions are preserved.
|
|
16745
|
-
Folder and ancestor directory symlinks are resolved;
|
|
16981
|
+
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.
|
|
16982
|
+
Unmanaged folders without ownership records or a managed legacy rule are skipped_unmanaged, including protected-path links; link referents are never read.
|
|
16983
|
+
Newer installed versions are preserved without cleanup unless --force requests an explicit downgrade.
|
|
16984
|
+
Unfiltered update/remove continue other targets on conflict: ok: true stdout includes failed target rows with code and hint; exit status is 1.
|
|
16746
16985
|
Shared folders are written once. JSON rows include aliases and resolved_folder_path.
|
|
16747
16986
|
Real mutations clean reserved stale staging and UUID temporary files; dry runs do not.
|
|
16748
16987
|
Managed legacy Cursor rules migrate after the new project folder is ready.
|
|
@@ -16797,6 +17036,7 @@ const skillsRemoveDefinition = define({
|
|
|
16797
17036
|
npm exec --yes --package=@artifactshare/cli -- artifactshare skills remove --tool cursor --json
|
|
16798
17037
|
|
|
16799
17038
|
Only manifest-owned files (or a legacy managed SKILL.md) are deleted; user files are preserved.
|
|
17039
|
+
Unmanaged folders are skipped_unmanaged, including protected-path links when no ownership records or managed legacy rule exist.
|
|
16800
17040
|
Project Cursor removal also cleans managed legacy rules.`
|
|
16801
17041
|
});
|
|
16802
17042
|
const skillsDefinition = define({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artifactshare/cli",
|
|
3
|
-
"version": "0.20.
|
|
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": {
|
|
@@ -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:
|
|
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.
|
|
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
|
-
|
|
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.
|