@artifactshare/cli 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to `@artifactshare/cli` are documented here.
|
|
4
4
|
For user-facing announcements, see https://artifactshare.com/updates?product=cli.
|
|
5
5
|
|
|
6
|
+
## 0.20.1 - 2026-10-28
|
|
7
|
+
|
|
8
|
+
- 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.
|
|
9
|
+
- Prefer sibling staging for skill writes, falling back to private staging inside the skill folder when permissions or filesystem boundaries require it. Clean reserved debris only after ten minutes, including on no-op updates. Preserve configured links on removal and roll back failed writes.
|
|
10
|
+
- Skip absent skills beneath dangling ancestor links without blocking other targets. Recommend force updates for managed edits, and show repair hints without force commands for unsafe links or layouts.
|
|
11
|
+
- Preserve edits to retained managed files during normal updates; explicit `skills update --force` can replace those edits. User additions remain protected.
|
|
12
|
+
- Clarify bundled setup guidance for shared skill folder links and edited files, and bump the skill marker version so existing installations update automatically.
|
|
13
|
+
|
|
6
14
|
## 0.20.0 - 2026-10-28
|
|
7
15
|
|
|
8
16
|
- Shorten the bundled skill entrypoint and load task-specific details from directly linked references.
|
package/README.md
CHANGED
|
@@ -104,7 +104,7 @@ project's Slack channel must be reauthorized.
|
|
|
104
104
|
| `changelog` | Show the installed version, this release's notes, and the public updates page |
|
|
105
105
|
| `profiles list / use / import-token / delete` | Switch between local account profiles, import an issued token from stdin, and delete profile entries |
|
|
106
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
|
|
107
|
+
| `skills ensure / install / list / update / remove` | Install or update the bundled usage guide; shared directory aliases are handled once, internal links are refused; Claude user scope follows CLAUDE_CONFIG_DIR (blank values are unavailable) |
|
|
108
108
|
|
|
109
109
|
Public command paths covered by this reference:
|
|
110
110
|
|
|
@@ -501,10 +501,14 @@ Local HTML and Markdown previews run scripts inside a frame with `sandbox="allow
|
|
|
501
501
|
|
|
502
502
|
Local preview and share-dialog HTTP routes still lack per-session authentication. Loopback binding, Host checks and fixed mutation headers do not authenticate other local clients. Do not treat knowledge of the local port as an access-control boundary. Session authentication and private browser launchers are deferred; the existing ready `url` and `--no-open` behavior are unchanged.
|
|
503
503
|
|
|
504
|
-
Skills are installed as folders: `.claude/skills/artifactshare/`, `.agents/skills/artifactshare/`, and `.cursor/skills/artifactshare/` at project or user scope (Claude user scope honors CLAUDE_CONFIG_DIR). Each folder contains SKILL.md and the bundled references tree. `.artifactshare-managed.json` records owned paths and SHA-256 hashes. Updates repair missing
|
|
504
|
+
Skills are installed as folders: `.claude/skills/artifactshare/`, `.agents/skills/artifactshare/`, and `.cursor/skills/artifactshare/` at project or user scope (Claude user scope honors CLAUDE_CONFIG_DIR). Each folder contains SKILL.md and the bundled references tree. `.artifactshare-managed.json` records owned paths and SHA-256 hashes. Updates repair missing owned files and retire unchanged owned files. User additions and hash-detected edits, including retained bundled paths, are preserved unless an explicit force operation authorizes replacement. Use `skills update --force` to replace edited managed files. Unowned path collisions require explicit `skills install --force`; `skills update --force` never takes over an unmanaged entry. Invalid ownership metadata requires inspection before reinstalling.
|
|
505
505
|
|
|
506
|
-
Writes stage files
|
|
506
|
+
Writes stage files in a private directory, replace references, retire owned files, commit the manifest, then replace SKILL.md last. Readers may briefly see mixed references during this bounded operation. Interrupted manifest/version mismatches are conflicts. Removal deletes only owned files and prunes empty directories.
|
|
507
507
|
|
|
508
508
|
`skills list --json` and `doctor --json` retain entry-file `path` and add `folder_path`, `complete`, `current`, `older_version`, sorted `missing_files`, `different_files`, `modified_files`, and `ownership_manifest` (valid/absent/invalid). Missing/different paths compare the current bundle; modified paths compare installed manifest hashes. Complete means every bundled file is regular. Current also requires matching managed version, bytes, and a valid manifest. Missing folders report all bundled paths missing; unavailable targets have null folder paths, false booleans and empty arrays. Unverified ownership has an empty modified list. Existing update_available retains version comparison semantics.
|
|
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
|
+
|
|
512
|
+
Skill folders and their configured ancestors may be directory symlinks. The CLI resolves the folder with realpath and handles each shared destination once, in Codex, Claude, Cursor order (project before user); the first selected alias supplies the legacy fields. JSON target rows include `aliases` (tool, scope, path, folder_path) and `resolved_folder_path`. Explicit filters include only selected aliases. Internal links, including SKILL.md, references and the manifest, are refused even with force. Restore dangling links to a directory; preserve edits and replace internal links with ordinary content before retrying. A missing skill beneath a dangling ancestor is reported as not installed, with the broken ancestor path, and does not block other targets. Link and layout conflicts provide repair hints without a force command. Removal preserves configured links and their destination directory.
|
|
513
|
+
|
|
514
|
+
Writes prefer a private sibling `.artifactshare-staging-<uuid>` directory. If the parent is not writable or a commit crosses filesystems, the CLI stages inside the skill folder instead and still commits files by rename. Real install, update, ensure and automatic updates clean reserved staging directories and exact UUID-shaped `.artifactshare-<uuid>.tmp` regular files only when their modification times are more than ten minutes old before checking conflicts, including no-op selections. Diagnostics and dry runs never clean files. Unrelated names and symlink referents are never deleted. Failed writes roll back committed paths and remove staging; interrupted processes leave debris for the next mutation.
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import { generate } from "gunshi/generator";
|
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { execFile, spawn } from "node:child_process";
|
|
8
8
|
import * as fs from "node:fs/promises";
|
|
9
|
-
import { chmod, lstat, mkdir, readFile, readdir, realpath, rename, rmdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
9
|
+
import { chmod, lstat, mkdir, readFile, readdir, realpath, rename, rm, rmdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
10
10
|
import { arch, homedir, platform } from "node:os";
|
|
11
11
|
import path, { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
12
12
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -716,7 +716,17 @@ const SkillLegacyDiagnosticSchema = z.object({
|
|
|
716
716
|
coexistence: z.boolean(),
|
|
717
717
|
hint: z.string().nullable()
|
|
718
718
|
});
|
|
719
|
+
const SkillTargetIdentityShape = {
|
|
720
|
+
aliases: z.array(z.object({
|
|
721
|
+
tool: z.string(),
|
|
722
|
+
scope: z.string(),
|
|
723
|
+
path: z.string().nullable(),
|
|
724
|
+
folder_path: z.string().nullable()
|
|
725
|
+
})).optional(),
|
|
726
|
+
resolved_folder_path: z.string().nullable().optional()
|
|
727
|
+
};
|
|
719
728
|
const LocalSkillTargetSchema = z.object({
|
|
729
|
+
...SkillTargetIdentityShape,
|
|
720
730
|
folder_path: z.string().nullable(),
|
|
721
731
|
complete: z.boolean(),
|
|
722
732
|
current: z.boolean(),
|
|
@@ -724,6 +734,7 @@ const LocalSkillTargetSchema = z.object({
|
|
|
724
734
|
missing_files: z.array(z.string()),
|
|
725
735
|
different_files: z.array(z.string()),
|
|
726
736
|
modified_files: z.array(z.string()),
|
|
737
|
+
interrupted_update: z.boolean().optional(),
|
|
727
738
|
ownership_manifest: z.enum([
|
|
728
739
|
"valid",
|
|
729
740
|
"absent",
|
|
@@ -763,6 +774,7 @@ const SkillLegacyActionSchema = z.object({
|
|
|
763
774
|
hint: z.string().optional()
|
|
764
775
|
});
|
|
765
776
|
const SkillsActionTargetSchema = z.object({
|
|
777
|
+
...SkillTargetIdentityShape,
|
|
766
778
|
tool: z.string(),
|
|
767
779
|
scope: z.string(),
|
|
768
780
|
path: z.string().nullable(),
|
|
@@ -786,6 +798,16 @@ z.object({
|
|
|
786
798
|
dry_run: z.boolean(),
|
|
787
799
|
targets: z.array(SkillsActionTargetSchema)
|
|
788
800
|
});
|
|
801
|
+
const SkillAutoUpdateTargetSchema = SkillsActionTargetSchema.extend({
|
|
802
|
+
path: z.string(),
|
|
803
|
+
folder_path: z.string(),
|
|
804
|
+
scope: z.enum(["user", "project"]),
|
|
805
|
+
action: z.enum(["updated", "update_recommended"]),
|
|
806
|
+
installed_version: z.number().nullable(),
|
|
807
|
+
bundled_version: z.number()
|
|
808
|
+
});
|
|
809
|
+
const SkillAutoUpdateDataSchema = z.object({ targets: z.array(SkillAutoUpdateTargetSchema) });
|
|
810
|
+
z.object({ skills: z.object({ auto_update: SkillAutoUpdateDataSchema.optional() }).optional() });
|
|
789
811
|
//#endregion
|
|
790
812
|
//#region src/constants.ts
|
|
791
813
|
const DEFAULT_BASE_URL = "https://artifactshare.com";
|
|
@@ -2147,8 +2169,11 @@ function skillAutoUpdateHumanOutput(data) {
|
|
|
2147
2169
|
const autoUpdate = skills.auto_update;
|
|
2148
2170
|
if (!isRecord$1(autoUpdate) || !Array.isArray(autoUpdate.targets)) return "";
|
|
2149
2171
|
const lines = autoUpdate.targets.filter(isRecord$1).map((target) => {
|
|
2150
|
-
const label = typeof target.tool === "string" && typeof target.scope === "string" ? `${target.tool}:${target.scope}` : "unknown";
|
|
2151
|
-
if (target.action === "update_recommended"
|
|
2172
|
+
const label = Array.isArray(target.aliases) ? target.aliases.filter(isRecord$1).map((alias) => `${alias.tool}:${alias.scope}`).join(", ") : typeof target.tool === "string" && typeof target.scope === "string" ? `${target.tool}:${target.scope}` : "unknown";
|
|
2173
|
+
if (target.action === "update_recommended") {
|
|
2174
|
+
const advice = [target.update_command, target.hint].filter((value) => typeof value === "string").join("; ");
|
|
2175
|
+
return `Skill update recommended: ${label}${advice ? ` (${advice})` : ""}`;
|
|
2176
|
+
}
|
|
2152
2177
|
return `Skill updated: ${label}`;
|
|
2153
2178
|
});
|
|
2154
2179
|
return lines.length > 0 ? `${lines.join("\n")}\n` : "";
|
|
@@ -4224,6 +4249,7 @@ async function runArtifactsList(parsed, mode) {
|
|
|
4224
4249
|
//#endregion
|
|
4225
4250
|
//#region src/command-runners/skill-folder.ts
|
|
4226
4251
|
const MANIFEST = ".artifactshare-managed.json";
|
|
4252
|
+
const PENDING = ".artifactshare-pending.json";
|
|
4227
4253
|
function managedState(content) {
|
|
4228
4254
|
if (content === null) return { kind: "missing" };
|
|
4229
4255
|
if (!content.includes("artifactshare-skill")) return { kind: "unmanaged" };
|
|
@@ -4245,10 +4271,65 @@ async function info(path) {
|
|
|
4245
4271
|
throw error;
|
|
4246
4272
|
}
|
|
4247
4273
|
}
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4274
|
+
var SkillFolderResolutionError = class extends Error {
|
|
4275
|
+
missingAncestor;
|
|
4276
|
+
constructor(path, missingAncestor = false) {
|
|
4277
|
+
super(`${missingAncestor ? "Skill not installed; dangling ancestor link" : "Unsafe skill folder"}: ${path}. Restore or repoint the link to a directory, or replace it with a real directory, then retry.`);
|
|
4278
|
+
this.missingAncestor = missingAncestor;
|
|
4279
|
+
}
|
|
4280
|
+
};
|
|
4281
|
+
function resolveSkillFolder(entry) {
|
|
4282
|
+
const resolveDirectory = async (path) => {
|
|
4283
|
+
let item;
|
|
4284
|
+
try {
|
|
4285
|
+
item = await info(path);
|
|
4286
|
+
if (!item) return join(await resolveDirectory(dirname(path)), basename(path));
|
|
4287
|
+
const canonical = await realpath(path);
|
|
4288
|
+
if (!(await lstat(canonical)).isDirectory()) throw new Error("Not a directory");
|
|
4289
|
+
return canonical;
|
|
4290
|
+
} catch (error) {
|
|
4291
|
+
if (error instanceof SkillFolderResolutionError) throw error;
|
|
4292
|
+
throw new SkillFolderResolutionError(path, item?.isSymbolicLink() === true && error.code === "ENOENT");
|
|
4293
|
+
}
|
|
4294
|
+
};
|
|
4295
|
+
return resolveDirectory(dirname(entry));
|
|
4296
|
+
}
|
|
4297
|
+
const rootFor = resolveSkillFolder;
|
|
4298
|
+
const uuid = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
4299
|
+
const legacyTemp = new RegExp(`^\\.artifactshare-${uuid}\\.tmp$`, "i");
|
|
4300
|
+
const stagingName = new RegExp(`^\\.artifactshare-staging-${uuid}$`, "i");
|
|
4301
|
+
const stale = (item) => item.mtimeMs < Date.now() - 6e5;
|
|
4302
|
+
async function inspectTree(root, cleanup = false, folderRoot = root) {
|
|
4303
|
+
if (!await info(root)) return;
|
|
4304
|
+
for (const name of await readdir(root)) {
|
|
4305
|
+
const path = join(root, name);
|
|
4306
|
+
const item = await lstat(path);
|
|
4307
|
+
if (item.isSymbolicLink()) throw new Error(`Unsafe skill path (link): ${path}. Preserve edits and replace the internal link with ordinary bundled content, then retry.`);
|
|
4308
|
+
if (item.isDirectory() && root === folderRoot && stagingName.test(name)) {
|
|
4309
|
+
if (cleanup && stale(item)) await rm(path, {
|
|
4310
|
+
recursive: true,
|
|
4311
|
+
force: true
|
|
4312
|
+
});
|
|
4313
|
+
} else if (item.isDirectory()) await inspectTree(path, cleanup, folderRoot);
|
|
4314
|
+
else if (cleanup && item.isFile() && legacyTemp.test(name) && stale(item)) await unlink(path);
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
async function cleanupSkillFolder(entry, bundle) {
|
|
4318
|
+
const root = await rootFor(entry);
|
|
4319
|
+
if (bundle) {
|
|
4320
|
+
const pending = await ownership(root, await stateAt(root), PENDING);
|
|
4321
|
+
if (pending.manifest && pending.manifest.version > bundle.version) throw new Error(newerIntentHint(pending.manifest.version));
|
|
4322
|
+
}
|
|
4323
|
+
await inspectTree(root, true);
|
|
4324
|
+
const parent = dirname(root);
|
|
4325
|
+
if (await info(parent)) for (const name of await readdir(parent)) {
|
|
4326
|
+
if (!stagingName.test(name)) continue;
|
|
4327
|
+
const item = await lstat(join(parent, name));
|
|
4328
|
+
if (item.isDirectory() && stale(item)) await rm(join(parent, name), {
|
|
4329
|
+
recursive: true,
|
|
4330
|
+
force: true
|
|
4331
|
+
});
|
|
4332
|
+
}
|
|
4252
4333
|
}
|
|
4253
4334
|
async function safe(root, relative, retiredAncestors = /* @__PURE__ */ new Set(), replacedDirectories = /* @__PURE__ */ new Set()) {
|
|
4254
4335
|
const parts = [
|
|
@@ -4260,7 +4341,7 @@ async function safe(root, relative, retiredAncestors = /* @__PURE__ */ new Set()
|
|
|
4260
4341
|
const item = await info(parts[i]);
|
|
4261
4342
|
if (i < parts.length - 1 && item?.isFile() && retiredAncestors.has(parts[i])) return;
|
|
4262
4343
|
if (i === parts.length - 1 && item?.isDirectory() && replacedDirectories.has(parts[i])) continue;
|
|
4263
|
-
if (item && (item.isSymbolicLink() || (i === parts.length - 1 ? !item.isFile() : !item.isDirectory()))) throw new Error(`Unsafe skill path (type change or link): ${parts[i]}.
|
|
4344
|
+
if (item && (item.isSymbolicLink() || (i === parts.length - 1 ? !item.isFile() : !item.isDirectory()))) throw new Error(`Unsafe skill path (type change or link): ${parts[i]}. Preserve edits and replace internal links with ordinary bundled content, then retry.`);
|
|
4264
4345
|
}
|
|
4265
4346
|
}
|
|
4266
4347
|
async function bytesAt(root, path) {
|
|
@@ -4281,7 +4362,15 @@ async function stateAt(root) {
|
|
|
4281
4362
|
}
|
|
4282
4363
|
}
|
|
4283
4364
|
async function readSkillState(entry) {
|
|
4284
|
-
|
|
4365
|
+
try {
|
|
4366
|
+
return await stateAt(await rootFor(entry));
|
|
4367
|
+
} catch (error) {
|
|
4368
|
+
if (error instanceof SkillFolderResolutionError && error.missingAncestor) return {
|
|
4369
|
+
kind: "missing",
|
|
4370
|
+
hint: error.message
|
|
4371
|
+
};
|
|
4372
|
+
return { kind: "broken" };
|
|
4373
|
+
}
|
|
4285
4374
|
}
|
|
4286
4375
|
async function loadSkillBundle(root) {
|
|
4287
4376
|
const files = {};
|
|
@@ -4303,14 +4392,17 @@ async function loadSkillBundle(root) {
|
|
|
4303
4392
|
version: state.version
|
|
4304
4393
|
};
|
|
4305
4394
|
}
|
|
4306
|
-
async function ownership(root, state) {
|
|
4395
|
+
async function ownership(root, state, record = MANIFEST, pending) {
|
|
4307
4396
|
try {
|
|
4308
|
-
const text = await textAt(root,
|
|
4397
|
+
const text = await textAt(root, record);
|
|
4309
4398
|
if (text === null) return { status: "absent" };
|
|
4310
4399
|
const value = JSON.parse(text);
|
|
4311
|
-
if (state.kind
|
|
4312
|
-
const
|
|
4313
|
-
|
|
4400
|
+
if (value.schema_version !== 1 || !Number.isSafeInteger(value.version) || value.version < 0 || record === MANIFEST && (state.kind === "managed" ? value.version !== state.version && value.version !== pending?.version : state.kind !== "missing" || !pending) || !value.files || typeof value.files !== "object" || Array.isArray(value.files) || !Object.hasOwn(value.files, "SKILL.md")) return { status: "invalid" };
|
|
4401
|
+
for (const files of [value.files, ...value.previous_files === void 0 ? [] : [value.previous_files]]) {
|
|
4402
|
+
if (!files || typeof files !== "object" || Array.isArray(files)) return { status: "invalid" };
|
|
4403
|
+
const paths = Object.keys(files);
|
|
4404
|
+
if (new Set(paths.map((path) => path.toLowerCase())).size !== paths.length || !paths.every((path) => validPath(path) && typeof files[path] === "string" && /^[a-f0-9]{64}$/.test(files[path]))) return { status: "invalid" };
|
|
4405
|
+
}
|
|
4314
4406
|
return {
|
|
4315
4407
|
status: "valid",
|
|
4316
4408
|
manifest: value
|
|
@@ -4319,45 +4411,99 @@ async function ownership(root, state) {
|
|
|
4319
4411
|
return { status: "invalid" };
|
|
4320
4412
|
}
|
|
4321
4413
|
}
|
|
4414
|
+
async function recoveryOwnership(root, state) {
|
|
4415
|
+
const pending = await ownership(root, state, PENDING);
|
|
4416
|
+
const owned = await ownership(root, state, MANIFEST, pending.manifest);
|
|
4417
|
+
const recorded = { ...owned.manifest?.files ?? (state.kind === "managed" && pending.status === "absent" ? { "SKILL.md": hash(await bytesAt(root, "SKILL.md")) } : {}) };
|
|
4418
|
+
for (const [path, expected] of Object.entries(pending.manifest?.previous_files ?? {})) {
|
|
4419
|
+
const bytes = await bytesAt(root, path).catch(() => null);
|
|
4420
|
+
if (bytes !== null && hash(bytes) === expected) recorded[path] = expected;
|
|
4421
|
+
}
|
|
4422
|
+
for (const [path, expected] of Object.entries(pending.manifest?.files ?? {})) {
|
|
4423
|
+
const bytes = await bytesAt(root, path).catch(() => null);
|
|
4424
|
+
if (bytes !== null && hash(bytes) === expected) recorded[path] = expected;
|
|
4425
|
+
}
|
|
4426
|
+
for (const [path, expected] of Object.entries(pending.manifest?.files ?? {})) {
|
|
4427
|
+
const bytes = await bytesAt(root, path).catch(() => null);
|
|
4428
|
+
if (bytes !== null && hash(bytes) === expected) {
|
|
4429
|
+
for (const old of Object.keys(recorded)) if (old.startsWith(`${path}/`)) delete recorded[old];
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
for (const path of Object.keys(recorded)) if ((await info(join(root, path)).catch(() => null))?.isDirectory() && Object.keys(pending.manifest?.files ?? {}).some((next) => next.startsWith(`${path}/`))) delete recorded[path];
|
|
4433
|
+
return {
|
|
4434
|
+
owned,
|
|
4435
|
+
pending,
|
|
4436
|
+
recorded
|
|
4437
|
+
};
|
|
4438
|
+
}
|
|
4322
4439
|
async function folderDiagnostics(entry, bundle) {
|
|
4323
|
-
|
|
4440
|
+
let root = null;
|
|
4441
|
+
try {
|
|
4442
|
+
root = await rootFor(entry);
|
|
4443
|
+
await inspectTree(root);
|
|
4444
|
+
} catch (error) {
|
|
4445
|
+
return {
|
|
4446
|
+
folder_path: dirname(entry),
|
|
4447
|
+
resolved_folder_path: root,
|
|
4448
|
+
complete: false,
|
|
4449
|
+
current: false,
|
|
4450
|
+
older_version: false,
|
|
4451
|
+
missing_files: [],
|
|
4452
|
+
different_files: [],
|
|
4453
|
+
modified_files: [],
|
|
4454
|
+
...error instanceof SkillFolderResolutionError && error.missingAncestor ? { ownership_manifest: "absent" } : {
|
|
4455
|
+
ownership_manifest: "invalid",
|
|
4456
|
+
code: "skill_update_conflict"
|
|
4457
|
+
},
|
|
4458
|
+
hint: error.message
|
|
4459
|
+
};
|
|
4460
|
+
}
|
|
4324
4461
|
const state = await stateAt(root);
|
|
4325
|
-
const owned = await
|
|
4462
|
+
const { owned, pending, recorded } = await recoveryOwnership(root, state);
|
|
4463
|
+
const newerIntent = pending.manifest && pending.manifest.version > bundle.version;
|
|
4326
4464
|
const missing_files = [], different_files = [], modified_files = [];
|
|
4327
4465
|
for (const path of Object.keys(bundle.files).sort()) {
|
|
4328
4466
|
const text = await bytesAt(root, path).catch(() => null);
|
|
4329
4467
|
if (text === null) missing_files.push(path);
|
|
4330
4468
|
else if (!text.equals(Buffer.from(bundle.files[path]))) different_files.push(path);
|
|
4331
4469
|
}
|
|
4332
|
-
|
|
4470
|
+
for (const [path, expected] of Object.entries(recorded).sort()) {
|
|
4333
4471
|
const text = await bytesAt(root, path).catch(() => null);
|
|
4334
|
-
if (text === null
|
|
4472
|
+
if (expected && (text === null ? pending.status === "absent" : hash(text) !== expected)) modified_files.push(path);
|
|
4335
4473
|
}
|
|
4336
4474
|
const manifestMatches = owned.manifest !== void 0 && Object.keys(owned.manifest.files).length === Object.keys(bundle.files).length && Object.entries(bundle.files).every(([path, text]) => owned.manifest?.files[path] === hash(text));
|
|
4337
4475
|
return {
|
|
4338
4476
|
folder_path: dirname(entry),
|
|
4477
|
+
resolved_folder_path: root,
|
|
4339
4478
|
complete: missing_files.length === 0,
|
|
4340
|
-
current: state.kind === "managed" && state.version === bundle.version && !missing_files.length && !different_files.length && owned.status === "valid" && manifestMatches,
|
|
4479
|
+
current: state.kind === "managed" && state.version === bundle.version && !missing_files.length && !different_files.length && owned.status === "valid" && manifestMatches && pending.status === "absent",
|
|
4480
|
+
...pending.status !== "absent" ? { interrupted_update: true } : {},
|
|
4341
4481
|
older_version: state.kind === "managed" && state.version < bundle.version,
|
|
4342
4482
|
missing_files,
|
|
4343
4483
|
different_files,
|
|
4344
4484
|
modified_files,
|
|
4345
|
-
ownership_manifest: owned.status
|
|
4485
|
+
ownership_manifest: owned.status,
|
|
4486
|
+
...newerIntent ? { hint: newerIntentHint(pending.manifest.version) } : {}
|
|
4346
4487
|
};
|
|
4347
4488
|
}
|
|
4489
|
+
function newerIntentHint(version) {
|
|
4490
|
+
return `Interrupted skill update requires a newer CLI with bundled skill version ${version} or later. Upgrade the CLI, then retry.`;
|
|
4491
|
+
}
|
|
4348
4492
|
async function preflightFolder(entry, bundle, force = false, forceRetirement = force) {
|
|
4349
4493
|
const root = await rootFor(entry);
|
|
4350
4494
|
const state = await stateAt(root);
|
|
4495
|
+
await inspectTree(root);
|
|
4351
4496
|
await safe(root, "SKILL.md");
|
|
4352
|
-
const owned = await
|
|
4353
|
-
if (
|
|
4354
|
-
|
|
4497
|
+
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));
|
|
4499
|
+
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
|
+
const previous = recorded;
|
|
4501
|
+
await safe(root, PENDING);
|
|
4355
4502
|
await safe(root, MANIFEST);
|
|
4356
4503
|
for (const path of Object.keys(previous)) await safe(root, path);
|
|
4357
4504
|
if (!forceRetirement) for (const [path, expected] of Object.entries(previous)) {
|
|
4358
|
-
if (bundle && Object.hasOwn(bundle.files, path)) continue;
|
|
4359
4505
|
const bytes = await bytesAt(root, path);
|
|
4360
|
-
if (expected && bytes !== null && hash(bytes) !== expected) throw new Error(`Modified skill file: ${path}. Preserve your edits before removing
|
|
4506
|
+
if (expected && bytes !== null && hash(bytes) !== expected) throw new Error(`Modified skill file: ${path}. Preserve your edits before removing this file, or use skills update --force to replace edited managed files.`);
|
|
4361
4507
|
}
|
|
4362
4508
|
const blockers = Object.keys(previous).filter((path) => bundle && !Object.hasOwn(bundle.files, path) && Object.keys(bundle.files).some((next) => next.startsWith(`${path}/`)));
|
|
4363
4509
|
const retiredAncestors = new Set(blockers.map((path) => join(root, path)));
|
|
@@ -4367,6 +4513,10 @@ async function preflightFolder(entry, bundle, force = false, forceRetirement = f
|
|
|
4367
4513
|
for (const name of await readdir(join(root, relative))) {
|
|
4368
4514
|
const child = `${relative}/${name}`;
|
|
4369
4515
|
const item = await info(join(root, child));
|
|
4516
|
+
if (item?.isFile() && legacyTemp.test(name)) {
|
|
4517
|
+
if (stale(item)) continue;
|
|
4518
|
+
throw new Error(`Recent skill temporary file: ${child}. Retry after the active update has finished and temporary files are older than ten minutes.`);
|
|
4519
|
+
}
|
|
4370
4520
|
if (item?.isDirectory()) await checkDirectory(child);
|
|
4371
4521
|
else if (!item?.isFile() || !Object.hasOwn(previous, child)) throw new Error(`Unowned skill file or type change: ${child}. Preserve or move this entry before updating.`);
|
|
4372
4522
|
}
|
|
@@ -4398,7 +4548,8 @@ async function prune(root, paths) {
|
|
|
4398
4548
|
}
|
|
4399
4549
|
for (const dir of [...dirs].sort((a, b) => b.length - a.length)) await rmdir(dir).catch(() => {});
|
|
4400
4550
|
}
|
|
4401
|
-
async function writeSkillFolder(entry, bundle, force = false, forceRetirement = force) {
|
|
4551
|
+
async function writeSkillFolder(entry, bundle, force = false, forceRetirement = force, cleanup = true) {
|
|
4552
|
+
if (cleanup) await cleanupSkillFolder(entry, bundle);
|
|
4402
4553
|
const { root, previous, blockers, replacedDirectories } = await preflightFolder(entry, bundle, force, forceRetirement);
|
|
4403
4554
|
const files = {
|
|
4404
4555
|
...bundle.files,
|
|
@@ -4408,6 +4559,8 @@ async function writeSkillFolder(entry, bundle, force = false, forceRetirement =
|
|
|
4408
4559
|
files: Object.fromEntries(Object.entries(bundle.files).map(([path, text]) => [path, hash(text)]))
|
|
4409
4560
|
}, null, 2) + "\n"
|
|
4410
4561
|
};
|
|
4562
|
+
const stagingDirectories = [];
|
|
4563
|
+
let internalStaging = false;
|
|
4411
4564
|
const staged = /* @__PURE__ */ new Map();
|
|
4412
4565
|
const backups = /* @__PURE__ */ new Map();
|
|
4413
4566
|
const changed = /* @__PURE__ */ new Set();
|
|
@@ -4419,10 +4572,37 @@ async function writeSkillFolder(entry, bundle, force = false, forceRetirement =
|
|
|
4419
4572
|
await mkdir(path);
|
|
4420
4573
|
createdDirectories.push(path);
|
|
4421
4574
|
};
|
|
4422
|
-
for (const path of /* @__PURE__ */ new Set([
|
|
4575
|
+
for (const path of /* @__PURE__ */ new Set([
|
|
4576
|
+
...Object.keys(previous),
|
|
4577
|
+
...Object.keys(files),
|
|
4578
|
+
PENDING
|
|
4579
|
+
])) {
|
|
4423
4580
|
const blocked = blockers.some((ancestor) => path.startsWith(`${ancestor}/`));
|
|
4424
4581
|
backups.set(path, !blocked && (await info(join(root, path)))?.isFile() ? await readFile(join(root, path)) : null);
|
|
4425
4582
|
}
|
|
4583
|
+
const intent = JSON.stringify({
|
|
4584
|
+
...JSON.parse(files[MANIFEST]),
|
|
4585
|
+
previous_files: previous
|
|
4586
|
+
}) + "\n";
|
|
4587
|
+
const stage = async (parent) => {
|
|
4588
|
+
await ensureDirectory(parent);
|
|
4589
|
+
const stagingDir = join(parent, `.artifactshare-staging-${randomUUID()}`);
|
|
4590
|
+
await mkdir(stagingDir, { mode: 448 });
|
|
4591
|
+
stagingDirectories.push(stagingDir);
|
|
4592
|
+
for (const [path, text] of Object.entries({
|
|
4593
|
+
...files,
|
|
4594
|
+
[PENDING]: intent
|
|
4595
|
+
})) {
|
|
4596
|
+
const temp = join(stagingDir, basename(path) === "SKILL.md" ? `${randomUUID()}.tmp` : path);
|
|
4597
|
+
await mkdir(dirname(temp), { recursive: true });
|
|
4598
|
+
await writeFile(temp, text, { flag: "wx" });
|
|
4599
|
+
staged.set(path, temp);
|
|
4600
|
+
}
|
|
4601
|
+
};
|
|
4602
|
+
const stageInside = async () => {
|
|
4603
|
+
internalStaging = true;
|
|
4604
|
+
await stage(root);
|
|
4605
|
+
};
|
|
4426
4606
|
const retire = async (path) => {
|
|
4427
4607
|
if (backups.get(path) !== null) {
|
|
4428
4608
|
await unlink(join(root, path));
|
|
@@ -4431,18 +4611,27 @@ async function writeSkillFolder(entry, bundle, force = false, forceRetirement =
|
|
|
4431
4611
|
};
|
|
4432
4612
|
const commit = async (path) => {
|
|
4433
4613
|
await ensureDirectory(dirname(join(root, path)));
|
|
4434
|
-
|
|
4614
|
+
try {
|
|
4615
|
+
await rename(staged.get(path), join(root, path));
|
|
4616
|
+
} catch (error) {
|
|
4617
|
+
if (internalStaging || error.code !== "EXDEV") throw error;
|
|
4618
|
+
await stageInside();
|
|
4619
|
+
await rename(staged.get(path), join(root, path));
|
|
4620
|
+
}
|
|
4435
4621
|
changed.add(path);
|
|
4436
4622
|
};
|
|
4437
4623
|
try {
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4624
|
+
try {
|
|
4625
|
+
await stage(dirname(root));
|
|
4626
|
+
} catch (error) {
|
|
4627
|
+
if (stagingDirectories.length !== 0 || ![
|
|
4628
|
+
"EACCES",
|
|
4629
|
+
"EPERM",
|
|
4630
|
+
"EROFS"
|
|
4631
|
+
].includes(error.code ?? "")) throw error;
|
|
4632
|
+
await stageInside();
|
|
4633
|
+
}
|
|
4634
|
+
await commit(PENDING);
|
|
4446
4635
|
const retired = Object.keys(previous).filter((path) => !Object.hasOwn(bundle.files, path));
|
|
4447
4636
|
const earlyRetired = new Set(retired.filter((path) => blockers.includes(path) || [...replacedDirectories].some((dir) => join(root, path).startsWith(`${dir}${sep}`))));
|
|
4448
4637
|
for (const path of earlyRetired) await retire(path);
|
|
@@ -4454,32 +4643,57 @@ async function writeSkillFolder(entry, bundle, force = false, forceRetirement =
|
|
|
4454
4643
|
for (const path of retired) if (!earlyRetired.has(path)) await retire(path);
|
|
4455
4644
|
await commit(MANIFEST);
|
|
4456
4645
|
await commit("SKILL.md");
|
|
4646
|
+
await unlink(join(root, PENDING));
|
|
4457
4647
|
await prune(root, retired);
|
|
4458
4648
|
} catch (error) {
|
|
4459
|
-
for (const path of [...changed].reverse())
|
|
4649
|
+
for (const path of [...changed].reverse()) {
|
|
4650
|
+
if (path === PENDING) continue;
|
|
4651
|
+
if ((await info(join(root, path)))?.isFile()) await unlink(join(root, path));
|
|
4652
|
+
}
|
|
4460
4653
|
for (const dir of [...createdDirectories].reverse()) await rmdir(dir).catch(() => {});
|
|
4461
4654
|
for (const dir of removedDirectories.reverse()) await mkdir(dir, { recursive: true });
|
|
4462
4655
|
for (const path of changed) {
|
|
4656
|
+
if (path === PENDING) continue;
|
|
4463
4657
|
const bytes = backups.get(path);
|
|
4464
4658
|
if (bytes !== null && bytes !== void 0) {
|
|
4465
4659
|
await mkdir(dirname(join(root, path)), { recursive: true });
|
|
4466
4660
|
await writeFile(join(root, path), bytes);
|
|
4467
4661
|
}
|
|
4468
4662
|
}
|
|
4663
|
+
if (changed.has(PENDING)) {
|
|
4664
|
+
const previousIntent = backups.get(PENDING);
|
|
4665
|
+
if (previousIntent) await writeFile(join(root, PENDING), previousIntent);
|
|
4666
|
+
else await unlink(join(root, PENDING));
|
|
4667
|
+
}
|
|
4469
4668
|
throw error;
|
|
4470
4669
|
} finally {
|
|
4471
|
-
for (const
|
|
4670
|
+
for (const dir of stagingDirectories) await rm(dir, {
|
|
4671
|
+
recursive: true,
|
|
4672
|
+
force: true
|
|
4673
|
+
});
|
|
4472
4674
|
for (const dir of [...createdDirectories].reverse()) await rmdir(dir).catch(() => {});
|
|
4473
4675
|
}
|
|
4474
4676
|
}
|
|
4475
|
-
async function removeSkillFolder(entry) {
|
|
4677
|
+
async function removeSkillFolder(entry, retainRoot = false) {
|
|
4476
4678
|
const { root, previous } = await preflightFolder(entry);
|
|
4477
|
-
for (const path of [
|
|
4679
|
+
for (const path of [
|
|
4680
|
+
...Object.keys(previous),
|
|
4681
|
+
MANIFEST,
|
|
4682
|
+
PENDING
|
|
4683
|
+
]) await unlink(join(root, path)).catch((error) => {
|
|
4478
4684
|
if (error.code !== "ENOENT") throw error;
|
|
4479
4685
|
});
|
|
4480
4686
|
await prune(root, Object.keys(previous));
|
|
4481
|
-
|
|
4482
|
-
|
|
4687
|
+
let path = dirname(entry);
|
|
4688
|
+
while (path !== dirname(path)) {
|
|
4689
|
+
if ((await info(path))?.isSymbolicLink()) retainRoot = true;
|
|
4690
|
+
if (path === dirname(dirname(dirname(entry)))) break;
|
|
4691
|
+
path = dirname(path);
|
|
4692
|
+
}
|
|
4693
|
+
if (!retainRoot) {
|
|
4694
|
+
await rmdir(root).catch(() => {});
|
|
4695
|
+
await rmdir(dirname(root)).catch(() => {});
|
|
4696
|
+
}
|
|
4483
4697
|
}
|
|
4484
4698
|
//#endregion
|
|
4485
4699
|
//#region src/command-runners/skills.ts
|
|
@@ -4509,6 +4723,57 @@ function scopeTargetConfig(tool, _scope) {
|
|
|
4509
4723
|
pruneDirs: ["artifactshare", "skills"]
|
|
4510
4724
|
};
|
|
4511
4725
|
}
|
|
4726
|
+
function aliases(target) {
|
|
4727
|
+
return "aliases" in target && target.aliases || [{
|
|
4728
|
+
tool: target.tool,
|
|
4729
|
+
scope: target.scope,
|
|
4730
|
+
path: target.path,
|
|
4731
|
+
folder_path: target.path === null ? null : dirname(target.path)
|
|
4732
|
+
}];
|
|
4733
|
+
}
|
|
4734
|
+
function identity(target) {
|
|
4735
|
+
return {
|
|
4736
|
+
aliases: aliases(target),
|
|
4737
|
+
resolved_folder_path: "resolved_folder_path" in target ? target.resolved_folder_path ?? null : null
|
|
4738
|
+
};
|
|
4739
|
+
}
|
|
4740
|
+
function targetOrder(a, b) {
|
|
4741
|
+
return SKILL_TOOLS.indexOf(a.tool) - SKILL_TOOLS.indexOf(b.tool) || (a.scope === b.scope ? 0 : a.scope === "project" ? -1 : 1);
|
|
4742
|
+
}
|
|
4743
|
+
async function cleanupTarget(target, bundled) {
|
|
4744
|
+
if (target.cleaned) return;
|
|
4745
|
+
await cleanupSkillFolder(target.absolutePath, bundled);
|
|
4746
|
+
target.cleaned = true;
|
|
4747
|
+
}
|
|
4748
|
+
async function groupTargets(targets) {
|
|
4749
|
+
const groups = /* @__PURE__ */ new Map();
|
|
4750
|
+
const result = [];
|
|
4751
|
+
for (const target of [...targets].sort((a, b) => targetOrder(aliases(a)[0], aliases(b)[0]))) {
|
|
4752
|
+
if (!availableTarget(target)) {
|
|
4753
|
+
result.push(target);
|
|
4754
|
+
continue;
|
|
4755
|
+
}
|
|
4756
|
+
const key = await resolveSkillFolder(target.absolutePath).catch(() => null);
|
|
4757
|
+
target.resolved_folder_path = key;
|
|
4758
|
+
const existing = key === null ? void 0 : groups.get(key);
|
|
4759
|
+
if (existing && availableTarget(existing)) existing.aliases = [...aliases(existing), ...aliases(target)];
|
|
4760
|
+
else {
|
|
4761
|
+
target.aliases = aliases(target);
|
|
4762
|
+
result.push(target);
|
|
4763
|
+
if (key !== null) groups.set(key, target);
|
|
4764
|
+
}
|
|
4765
|
+
}
|
|
4766
|
+
return result;
|
|
4767
|
+
}
|
|
4768
|
+
async function conflictFor(target) {
|
|
4769
|
+
const error = skillUpdateConflictError(target.path);
|
|
4770
|
+
try {
|
|
4771
|
+
await preflightFolder(target.absolutePath);
|
|
4772
|
+
} catch (cause) {
|
|
4773
|
+
error.hint = cause.message;
|
|
4774
|
+
}
|
|
4775
|
+
return error;
|
|
4776
|
+
}
|
|
4512
4777
|
const CLAUDE_CONFIG_HINT = "Set CLAUDE_CONFIG_DIR to a non-empty path or unset it to use ~/.claude.";
|
|
4513
4778
|
function claudeUserRoot() {
|
|
4514
4779
|
const value = process.env.CLAUDE_CONFIG_DIR;
|
|
@@ -4529,6 +4794,7 @@ function availableTarget(target) {
|
|
|
4529
4794
|
}
|
|
4530
4795
|
function unavailableState(target) {
|
|
4531
4796
|
return {
|
|
4797
|
+
...identity(target),
|
|
4532
4798
|
tool: target.tool,
|
|
4533
4799
|
scope: target.scope,
|
|
4534
4800
|
path: null,
|
|
@@ -4592,8 +4858,12 @@ function readTarget(target) {
|
|
|
4592
4858
|
function loadBundledSkills() {
|
|
4593
4859
|
return loadSkillBundle(fileURLToPath(new URL("../skills/artifactshare/", import.meta.url)));
|
|
4594
4860
|
}
|
|
4861
|
+
function cursorProjectAlias(target) {
|
|
4862
|
+
return aliases(target).find((alias) => alias.tool === "cursor" && alias.scope === "project");
|
|
4863
|
+
}
|
|
4595
4864
|
async function legacyRule(target) {
|
|
4596
|
-
|
|
4865
|
+
const cursor = cursorProjectAlias(target);
|
|
4866
|
+
if (!cursor) return void 0;
|
|
4597
4867
|
const path = join(".cursor", "rules", "artifactshare.mdc");
|
|
4598
4868
|
const info = await lstat(path).catch(() => null);
|
|
4599
4869
|
const parent = await lstat(dirname(path)).catch(() => null);
|
|
@@ -4604,7 +4874,7 @@ async function legacyRule(target) {
|
|
|
4604
4874
|
path,
|
|
4605
4875
|
present,
|
|
4606
4876
|
managed,
|
|
4607
|
-
coexistence: present && await lstat(
|
|
4877
|
+
coexistence: present && await lstat(resolve(cursor.path)).catch(() => null) !== null,
|
|
4608
4878
|
hint: present && !managed ? "Inspect the legacy Cursor rule and manually remove it if the skill folder replaces it." : null
|
|
4609
4879
|
};
|
|
4610
4880
|
}
|
|
@@ -4615,10 +4885,11 @@ async function legacyManagedVersion(target) {
|
|
|
4615
4885
|
return state.kind === "managed" ? state.version : void 0;
|
|
4616
4886
|
}
|
|
4617
4887
|
async function diagnostic(target, bundle) {
|
|
4888
|
+
const legacy = await legacyRule(target);
|
|
4618
4889
|
return {
|
|
4619
4890
|
...await folderDiagnostics(target.absolutePath, bundle),
|
|
4620
4891
|
folder_path: dirname(target.path),
|
|
4621
|
-
...
|
|
4892
|
+
...legacy ? { legacy_rule: legacy } : {}
|
|
4622
4893
|
};
|
|
4623
4894
|
}
|
|
4624
4895
|
async function isCurrent(target, bundle) {
|
|
@@ -4713,9 +4984,10 @@ async function autoTargets(scope) {
|
|
|
4713
4984
|
};
|
|
4714
4985
|
}
|
|
4715
4986
|
function targetPathKey(target) {
|
|
4716
|
-
return
|
|
4987
|
+
return resolveSkillFolder(target.absolutePath).catch(() => target.absolutePath);
|
|
4717
4988
|
}
|
|
4718
4989
|
async function prepareAction(item, dryRun) {
|
|
4990
|
+
if (!dryRun && (item.content || item.action === "unchanged")) await cleanupTarget(item.target, item.content ?? await loadBundledSkills());
|
|
4719
4991
|
if (item.content) {
|
|
4720
4992
|
if (item.automatic) {
|
|
4721
4993
|
const details = await diagnostic(item.target, item.content);
|
|
@@ -4742,8 +5014,8 @@ async function prepareAction(item, dryRun) {
|
|
|
4742
5014
|
}
|
|
4743
5015
|
}
|
|
4744
5016
|
async function applyAction(item) {
|
|
4745
|
-
if (item.content) await writeSkillFolder(item.target.absolutePath, item.content, item.force, item.forceRetirement);
|
|
4746
|
-
if (item.action === "removed") await removeSkillFolder(item.target.absolutePath);
|
|
5017
|
+
if (item.content) await writeSkillFolder(item.target.absolutePath, item.content, item.force, item.forceRetirement, false);
|
|
5018
|
+
if (item.action === "removed") await removeSkillFolder(item.target.absolutePath, aliases(item.target).length > 1);
|
|
4747
5019
|
if (item.legacy?.action === "removed") try {
|
|
4748
5020
|
await unlink(item.legacy.path);
|
|
4749
5021
|
} catch {
|
|
@@ -4757,11 +5029,47 @@ async function applyAction(item) {
|
|
|
4757
5029
|
function skillUpdateCommand(target) {
|
|
4758
5030
|
return `${CLI_INVOCATION} skills update --tool ${target.tool} --scope ${target.scope} --json`;
|
|
4759
5031
|
}
|
|
5032
|
+
async function recoveryRecommendation(target, bundled) {
|
|
5033
|
+
const details = await diagnostic(target, bundled);
|
|
5034
|
+
let update_command = skillUpdateCommand(target);
|
|
5035
|
+
try {
|
|
5036
|
+
await preflightFolder(target.absolutePath, bundled);
|
|
5037
|
+
} catch {
|
|
5038
|
+
try {
|
|
5039
|
+
await preflightFolder(target.absolutePath, bundled, false, true);
|
|
5040
|
+
update_command = update_command.replace(" --json", " --force --json");
|
|
5041
|
+
} catch {
|
|
5042
|
+
try {
|
|
5043
|
+
await preflightFolder(target.absolutePath, bundled, true);
|
|
5044
|
+
update_command = `${CLI_INVOCATION} skills install --tool ${target.tool} --scope ${target.scope} --force --json`;
|
|
5045
|
+
} catch (error) {
|
|
5046
|
+
return {
|
|
5047
|
+
hint: error.message,
|
|
5048
|
+
...details.modified_files.length ? { modified_files: details.modified_files } : {}
|
|
5049
|
+
};
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
5053
|
+
return {
|
|
5054
|
+
update_command,
|
|
5055
|
+
...details.modified_files.length ? {
|
|
5056
|
+
modified_files: details.modified_files,
|
|
5057
|
+
hint: `Modified skill files: ${details.modified_files.join(", ")}. Preserve your edits before running the recommended command.`
|
|
5058
|
+
} : {}
|
|
5059
|
+
};
|
|
5060
|
+
}
|
|
5061
|
+
async function skipAutomaticTarget(target, state) {
|
|
5062
|
+
if (await legacyManagedVersion(target) !== void 0) return false;
|
|
5063
|
+
if (state.kind === "unmanaged") return true;
|
|
5064
|
+
return state.kind === "missing" && !await lstat(join(dirname(target.absolutePath), ".artifactshare-pending.json")).catch(() => null);
|
|
5065
|
+
}
|
|
4760
5066
|
async function finishActions(command, planned, dryRun, mode) {
|
|
5067
|
+
planned.sort((a, b) => targetOrder(aliases(a.target)[0], aliases(b.target)[0]));
|
|
4761
5068
|
for (const item of planned) try {
|
|
4762
5069
|
await prepareAction(item, dryRun);
|
|
4763
5070
|
} catch (error) {
|
|
4764
5071
|
if (item.fallbackAction) {
|
|
5072
|
+
item.hint = error.message;
|
|
4765
5073
|
item.action = item.fallbackAction;
|
|
4766
5074
|
delete item.content;
|
|
4767
5075
|
continue;
|
|
@@ -4773,14 +5081,14 @@ async function finishActions(command, planned, dryRun, mode) {
|
|
|
4773
5081
|
}
|
|
4774
5082
|
const completed = [...planned];
|
|
4775
5083
|
if (!dryRun) for (const [index, item] of planned.entries()) try {
|
|
4776
|
-
await prepareAction(item, false);
|
|
4777
5084
|
await applyAction(item);
|
|
4778
5085
|
completed[index] = item;
|
|
4779
5086
|
} catch (error) {
|
|
4780
5087
|
if (item.fallbackAction) {
|
|
4781
5088
|
completed[index] = {
|
|
4782
5089
|
target: item.target,
|
|
4783
|
-
action: item.fallbackAction
|
|
5090
|
+
action: item.fallbackAction,
|
|
5091
|
+
hint: error.message
|
|
4784
5092
|
};
|
|
4785
5093
|
continue;
|
|
4786
5094
|
}
|
|
@@ -4789,15 +5097,17 @@ async function finishActions(command, planned, dryRun, mode) {
|
|
|
4789
5097
|
}
|
|
4790
5098
|
return {
|
|
4791
5099
|
dry_run: dryRun,
|
|
4792
|
-
targets: completed.map(({ target, action, legacy }) => ({
|
|
5100
|
+
targets: await Promise.all(completed.map(async ({ target, action, legacy, hint }) => ({
|
|
5101
|
+
...hint ? { hint } : {},
|
|
4793
5102
|
tool: target.tool,
|
|
4794
5103
|
scope: target.scope,
|
|
4795
5104
|
path: target.path,
|
|
5105
|
+
...identity(target),
|
|
4796
5106
|
folder_path: dirname(target.path),
|
|
4797
5107
|
...legacy ? { legacy_rule: legacy } : {},
|
|
4798
5108
|
action,
|
|
4799
|
-
...action === "update_recommended" ?
|
|
4800
|
-
}))
|
|
5109
|
+
...action === "update_recommended" ? await recoveryRecommendation(target, await loadBundledSkills()) : {}
|
|
5110
|
+
})))
|
|
4801
5111
|
};
|
|
4802
5112
|
}
|
|
4803
5113
|
async function runActions(command, planned, dryRun, mode, unavailableTargets = []) {
|
|
@@ -4807,6 +5117,7 @@ async function runActions(command, planned, dryRun, mode, unavailableTargets = [
|
|
|
4807
5117
|
tool: target.tool,
|
|
4808
5118
|
scope: target.scope,
|
|
4809
5119
|
path: null,
|
|
5120
|
+
...identity(target),
|
|
4810
5121
|
folder_path: null,
|
|
4811
5122
|
action: "skipped",
|
|
4812
5123
|
code: target.error.code,
|
|
@@ -4834,11 +5145,10 @@ async function runSkillsInstall(parsed, mode) {
|
|
|
4834
5145
|
const bundled = await bundledOrFailure(command, mode);
|
|
4835
5146
|
if (!bundled) return;
|
|
4836
5147
|
const planned = [];
|
|
4837
|
-
for (const
|
|
4838
|
-
const target = skillTarget(tool, scope);
|
|
5148
|
+
for (const target of await groupTargets(allTargets().filter((candidate) => tools.includes(candidate.tool) && candidate.scope === scope))) {
|
|
4839
5149
|
if (!availableTarget(target)) return writeFailure(command, target.error, mode, 1);
|
|
4840
5150
|
const state = await readTarget(target);
|
|
4841
|
-
if ((state.kind === "unmanaged" || state.kind === "broken") && !force) return writeFailure(command,
|
|
5151
|
+
if ((state.kind === "unmanaged" || state.kind === "broken") && !force) return writeFailure(command, await conflictFor(target), mode, 1);
|
|
4842
5152
|
if (state.kind === "managed" && await isCurrent(target, bundled) && !force) {
|
|
4843
5153
|
planned.push({
|
|
4844
5154
|
target,
|
|
@@ -4875,14 +5185,24 @@ async function ensureSkills(parsed, mode, options = {}) {
|
|
|
4875
5185
|
if (!bundled) return void 0;
|
|
4876
5186
|
const targets = (filters.auto ? await autoTargets(filters.scope) : void 0)?.targets ?? filteredTargets(filters.tools, filters.scope ?? "project");
|
|
4877
5187
|
const planned = [];
|
|
4878
|
-
for (const target of targets) {
|
|
5188
|
+
for (const target of await groupTargets(targets)) {
|
|
4879
5189
|
const state = await readTarget(target);
|
|
4880
5190
|
if (state.kind === "unmanaged" || state.kind === "broken") {
|
|
4881
|
-
if (options.skipBrokenUserSkills && state.kind === "broken")
|
|
4882
|
-
|
|
5191
|
+
if (options.skipBrokenUserSkills && state.kind === "broken") {
|
|
5192
|
+
const details = await diagnostic(target, bundled);
|
|
5193
|
+
if (details.hint) planned.push({
|
|
5194
|
+
target,
|
|
5195
|
+
action: "update_recommended",
|
|
5196
|
+
hint: details.hint,
|
|
5197
|
+
fallbackAction: "update_recommended"
|
|
5198
|
+
});
|
|
5199
|
+
continue;
|
|
5200
|
+
}
|
|
5201
|
+
writeFailure(command, await conflictFor(target), mode, 1);
|
|
4883
5202
|
return;
|
|
4884
5203
|
}
|
|
4885
5204
|
const automaticUpdate = filters.auto || options.command === "init" || options.command === "open";
|
|
5205
|
+
if (automaticUpdate && state.kind === "missing" && state.hint) continue;
|
|
4886
5206
|
if (automaticUpdate && state.kind === "managed" && state.version > bundled.version) continue;
|
|
4887
5207
|
const details = await diagnostic(target, bundled);
|
|
4888
5208
|
if (automaticUpdate && state.kind === "managed" && details.modified_files.length) {
|
|
@@ -4892,10 +5212,11 @@ async function ensureSkills(parsed, mode, options = {}) {
|
|
|
4892
5212
|
});
|
|
4893
5213
|
continue;
|
|
4894
5214
|
}
|
|
4895
|
-
const unchanged = state.kind === "managed" && (state.version >= bundled.version && automaticUpdate || state.version > bundled.version || details.current);
|
|
5215
|
+
const unchanged = state.kind === "managed" && (state.version >= bundled.version && !details.interrupted_update && automaticUpdate || state.version > bundled.version || details.current);
|
|
4896
5216
|
planned.push(unchanged ? {
|
|
4897
5217
|
target,
|
|
4898
|
-
action: "unchanged"
|
|
5218
|
+
action: "unchanged",
|
|
5219
|
+
...automaticUpdate ? { fallbackAction: "update_recommended" } : {}
|
|
4899
5220
|
} : {
|
|
4900
5221
|
target,
|
|
4901
5222
|
action: state.kind === "missing" ? "installed" : "updated",
|
|
@@ -4906,10 +5227,33 @@ async function ensureSkills(parsed, mode, options = {}) {
|
|
|
4906
5227
|
}
|
|
4907
5228
|
if (options.autoUpdateUserManaged || filters.auto) {
|
|
4908
5229
|
const plannedPaths = new Set(await Promise.all(planned.map((action) => targetPathKey(action.target))));
|
|
4909
|
-
for (const target of await automaticTargets(bundled)) {
|
|
4910
|
-
if (plannedPaths.has(await targetPathKey(target)))
|
|
5230
|
+
for (const target of await groupTargets(await automaticTargets(bundled))) {
|
|
5231
|
+
if (plannedPaths.has(await targetPathKey(target))) {
|
|
5232
|
+
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
|
+
if (existing) {
|
|
5234
|
+
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
|
+
const primary = existing.target.aliases[0];
|
|
5236
|
+
existing.target.tool = primary.tool;
|
|
5237
|
+
existing.target.scope = primary.scope;
|
|
5238
|
+
existing.target.path = primary.path;
|
|
5239
|
+
existing.target.absolutePath = resolve(primary.path);
|
|
5240
|
+
}
|
|
5241
|
+
continue;
|
|
5242
|
+
}
|
|
4911
5243
|
const state = await readTarget(target);
|
|
5244
|
+
if (await skipAutomaticTarget(target, state)) continue;
|
|
4912
5245
|
if (state.kind === "managed" && state.version > bundled.version) continue;
|
|
5246
|
+
if (parsed.options.dryRun !== true) try {
|
|
5247
|
+
await cleanupTarget(target, bundled);
|
|
5248
|
+
} catch (error) {
|
|
5249
|
+
planned.push({
|
|
5250
|
+
target,
|
|
5251
|
+
action: "update_recommended",
|
|
5252
|
+
hint: error.message,
|
|
5253
|
+
fallbackAction: "update_recommended"
|
|
5254
|
+
});
|
|
5255
|
+
continue;
|
|
5256
|
+
}
|
|
4913
5257
|
const details = await diagnostic(target, bundled);
|
|
4914
5258
|
if (state.kind === "managed" && details.modified_files.length) {
|
|
4915
5259
|
planned.push({
|
|
@@ -4919,11 +5263,11 @@ async function ensureSkills(parsed, mode, options = {}) {
|
|
|
4919
5263
|
});
|
|
4920
5264
|
continue;
|
|
4921
5265
|
}
|
|
4922
|
-
if (target.
|
|
5266
|
+
if (!cursorProjectAlias(target) && (state.kind !== "managed" && !(state.kind === "missing" && details.interrupted_update) || state.kind === "managed" && state.version >= bundled.version && !details.interrupted_update || await isCurrent(target, bundled))) continue;
|
|
4923
5267
|
planned.push({
|
|
4924
5268
|
target,
|
|
4925
|
-
action: state.kind === "managed" && state.version >= bundled.version ? "unchanged" : "updated",
|
|
4926
|
-
...state.kind === "managed" && state.version >= bundled.version ? {} : { content: bundled },
|
|
5269
|
+
action: state.kind === "managed" && state.version >= bundled.version && !details.interrupted_update ? "unchanged" : "updated",
|
|
5270
|
+
...state.kind === "managed" && state.version >= bundled.version && !details.interrupted_update ? {} : { content: bundled },
|
|
4927
5271
|
automatic: true,
|
|
4928
5272
|
fallbackAction: "update_recommended"
|
|
4929
5273
|
});
|
|
@@ -4944,10 +5288,32 @@ async function autoUpdateUserManagedSkills() {
|
|
|
4944
5288
|
try {
|
|
4945
5289
|
const bundled = await loadBundledSkills();
|
|
4946
5290
|
const planned = [];
|
|
4947
|
-
for (const target of await automaticTargets(bundled)) {
|
|
5291
|
+
for (const target of await groupTargets(await automaticTargets(bundled))) {
|
|
4948
5292
|
const state = await readTarget(target);
|
|
5293
|
+
if (await skipAutomaticTarget(target, state)) continue;
|
|
4949
5294
|
if (state.kind === "managed" && state.version > bundled.version) continue;
|
|
5295
|
+
try {
|
|
5296
|
+
await cleanupTarget(target, bundled);
|
|
5297
|
+
} catch (error) {
|
|
5298
|
+
planned.push({
|
|
5299
|
+
target,
|
|
5300
|
+
action: "update_recommended",
|
|
5301
|
+
hint: error.message,
|
|
5302
|
+
...state.kind === "managed" ? { installedVersion: state.version } : {}
|
|
5303
|
+
});
|
|
5304
|
+
continue;
|
|
5305
|
+
}
|
|
4950
5306
|
const details = await diagnostic(target, bundled);
|
|
5307
|
+
if (details.hint) {
|
|
5308
|
+
planned.push({
|
|
5309
|
+
target,
|
|
5310
|
+
action: "update_recommended",
|
|
5311
|
+
hint: details.hint,
|
|
5312
|
+
fallbackAction: "update_recommended",
|
|
5313
|
+
...state.kind === "managed" ? { installedVersion: state.version } : {}
|
|
5314
|
+
});
|
|
5315
|
+
continue;
|
|
5316
|
+
}
|
|
4951
5317
|
if (state.kind === "managed" && details.modified_files.length) {
|
|
4952
5318
|
planned.push({
|
|
4953
5319
|
target,
|
|
@@ -4956,14 +5322,14 @@ async function autoUpdateUserManagedSkills() {
|
|
|
4956
5322
|
});
|
|
4957
5323
|
continue;
|
|
4958
5324
|
}
|
|
4959
|
-
if (target.
|
|
5325
|
+
if (!cursorProjectAlias(target) && (state.kind !== "managed" && !(state.kind === "missing" && details.interrupted_update) || state.kind === "managed" && state.version >= bundled.version && !details.interrupted_update || await isCurrent(target, bundled))) continue;
|
|
4960
5326
|
planned.push({
|
|
4961
5327
|
target,
|
|
4962
|
-
action: state.kind === "managed" && state.version >= bundled.version ? "unchanged" : "updated",
|
|
4963
|
-
...state.kind === "managed" && state.version >= bundled.version ? {} : { content: bundled },
|
|
5328
|
+
action: state.kind === "managed" && state.version >= bundled.version && !details.interrupted_update ? "unchanged" : "updated",
|
|
5329
|
+
...state.kind === "managed" && state.version >= bundled.version && !details.interrupted_update ? {} : { content: bundled },
|
|
4964
5330
|
automatic: true,
|
|
4965
5331
|
fallbackAction: "update_recommended",
|
|
4966
|
-
installedVersion: state.kind === "managed" ? state.version : await legacyManagedVersion(target) ??
|
|
5332
|
+
installedVersion: state.kind === "managed" ? state.version : await legacyManagedVersion(target) ?? null
|
|
4967
5333
|
});
|
|
4968
5334
|
}
|
|
4969
5335
|
if (planned.length === 0) return void 0;
|
|
@@ -4972,24 +5338,27 @@ async function autoUpdateUserManagedSkills() {
|
|
|
4972
5338
|
await prepareAction(item, false);
|
|
4973
5339
|
await applyAction(item);
|
|
4974
5340
|
completed[index] = item;
|
|
4975
|
-
} catch {
|
|
5341
|
+
} catch (error) {
|
|
4976
5342
|
completed[index] = {
|
|
5343
|
+
hint: error.message,
|
|
4977
5344
|
target: item.target,
|
|
4978
5345
|
action: "update_recommended",
|
|
4979
5346
|
...item.installedVersion !== void 0 ? { installedVersion: item.installedVersion } : {}
|
|
4980
5347
|
};
|
|
4981
5348
|
}
|
|
4982
|
-
return { targets: completed.map(({ target, action, installedVersion, legacy }) => ({
|
|
5349
|
+
return { targets: await Promise.all(completed.map(async ({ target, action, installedVersion, legacy, hint }) => ({
|
|
5350
|
+
...hint ? { hint } : {},
|
|
4983
5351
|
tool: target.tool,
|
|
4984
5352
|
scope: target.scope,
|
|
4985
5353
|
path: target.path,
|
|
5354
|
+
...identity(target),
|
|
4986
5355
|
folder_path: dirname(target.path),
|
|
4987
5356
|
...legacy ? { legacy_rule: legacy } : {},
|
|
4988
5357
|
action: action === "update_recommended" ? "update_recommended" : "updated",
|
|
4989
|
-
installed_version: installedVersion ?? bundled.version,
|
|
5358
|
+
installed_version: action === "update_recommended" ? installedVersion ?? null : installedVersion ?? bundled.version,
|
|
4990
5359
|
bundled_version: bundled.version,
|
|
4991
|
-
...action === "update_recommended" ?
|
|
4992
|
-
})) };
|
|
5360
|
+
...action === "update_recommended" ? await recoveryRecommendation(target, bundled) : {}
|
|
5361
|
+
}))) };
|
|
4993
5362
|
} catch {
|
|
4994
5363
|
return;
|
|
4995
5364
|
}
|
|
@@ -5002,7 +5371,7 @@ async function runSkillsList(parsed, mode) {
|
|
|
5002
5371
|
const bundled = await bundledOrFailure("skills list", mode);
|
|
5003
5372
|
if (!bundled) return;
|
|
5004
5373
|
const targets = [];
|
|
5005
|
-
for (const target of allTargets()) {
|
|
5374
|
+
for (const target of await groupTargets(allTargets())) {
|
|
5006
5375
|
if (!availableTarget(target)) {
|
|
5007
5376
|
targets.push({
|
|
5008
5377
|
...unavailableState(target),
|
|
@@ -5015,8 +5384,9 @@ async function runSkillsList(parsed, mode) {
|
|
|
5015
5384
|
tool: target.tool,
|
|
5016
5385
|
scope: target.scope,
|
|
5017
5386
|
path: target.path,
|
|
5387
|
+
...identity(target),
|
|
5018
5388
|
...await diagnostic(target, bundled),
|
|
5019
|
-
detected: await
|
|
5389
|
+
detected: (await Promise.all(aliases(target).map((alias) => isToolDetected(alias.tool, alias.scope)))).some(Boolean),
|
|
5020
5390
|
installed: state.kind !== "missing",
|
|
5021
5391
|
managed: state.kind === "managed",
|
|
5022
5392
|
installed_version: state.kind === "managed" ? state.version : null,
|
|
@@ -5031,7 +5401,7 @@ async function runSkillsList(parsed, mode) {
|
|
|
5031
5401
|
async function skillDiagnostics() {
|
|
5032
5402
|
const bundled = await loadBundledSkills();
|
|
5033
5403
|
const targets = [];
|
|
5034
|
-
for (const target of allTargets()) {
|
|
5404
|
+
for (const target of await groupTargets(allTargets())) {
|
|
5035
5405
|
if (!availableTarget(target)) {
|
|
5036
5406
|
targets.push({
|
|
5037
5407
|
...unavailableState(target),
|
|
@@ -5042,12 +5412,8 @@ async function skillDiagnostics() {
|
|
|
5042
5412
|
const state = await readTarget(target);
|
|
5043
5413
|
const details = await diagnostic(target, bundled);
|
|
5044
5414
|
const updateAvailable = state.kind === "managed" && state.version !== bundled.version;
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
await preflightFolder(target.absolutePath, bundled);
|
|
5048
|
-
} catch {
|
|
5049
|
-
recoveryCommand = `${CLI_INVOCATION} skills install --tool ${target.tool} --scope ${target.scope} --force --json`;
|
|
5050
|
-
}
|
|
5415
|
+
const recommendation = await recoveryRecommendation(target, bundled);
|
|
5416
|
+
const recoveryCommand = recommendation.update_command ?? null;
|
|
5051
5417
|
targets.push({
|
|
5052
5418
|
tool: target.tool,
|
|
5053
5419
|
scope: target.scope,
|
|
@@ -5056,15 +5422,19 @@ async function skillDiagnostics() {
|
|
|
5056
5422
|
managed: state.kind === "managed",
|
|
5057
5423
|
installed_version: state.kind === "managed" ? state.version : null,
|
|
5058
5424
|
update_available: updateAvailable,
|
|
5425
|
+
...identity(target),
|
|
5059
5426
|
...details,
|
|
5060
|
-
|
|
5427
|
+
...!recoveryCommand && recommendation.hint ? { hint: recommendation.hint } : {},
|
|
5428
|
+
update_command: details.hint ? null : updateAvailable || details.interrupted_update || state.kind === "managed" && !details.current ? recoveryCommand : null
|
|
5061
5429
|
});
|
|
5062
5430
|
}
|
|
5063
5431
|
const updateTargets = targets.filter((target) => target.update_command !== null);
|
|
5432
|
+
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);
|
|
5064
5434
|
return {
|
|
5065
5435
|
bundled_version: bundled.version,
|
|
5066
5436
|
update_available: targets.some((target) => target.update_available),
|
|
5067
|
-
update_command: updateTargets.length
|
|
5437
|
+
update_command: updateTargets.length === 0 ? null : canUpdateTogether && (updateTargets.length > 1 || !commonCommand?.includes(" --force")) ? commonCommand : updateTargets.map((target) => target.update_command).join(" && "),
|
|
5068
5438
|
targets
|
|
5069
5439
|
};
|
|
5070
5440
|
}
|
|
@@ -5078,18 +5448,27 @@ async function runSkillsUpdate(parsed, mode) {
|
|
|
5078
5448
|
const bundled = await bundledOrFailure(command, mode);
|
|
5079
5449
|
if (!bundled) return;
|
|
5080
5450
|
const planned = [];
|
|
5081
|
-
for (const target of filteredTargets(filters.tools, filters.scope)) {
|
|
5451
|
+
for (const target of await groupTargets(filteredTargets(filters.tools, filters.scope))) {
|
|
5082
5452
|
const state = await readTarget(target);
|
|
5083
|
-
if (state.kind === "broken") return writeFailure(command,
|
|
5084
|
-
if (state.kind === "missing")
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5453
|
+
if (state.kind === "broken") return writeFailure(command, await conflictFor(target), mode, 1);
|
|
5454
|
+
if (state.kind === "missing") {
|
|
5455
|
+
if (state.hint) {
|
|
5456
|
+
planned.push({
|
|
5457
|
+
target,
|
|
5458
|
+
action: "not_installed",
|
|
5459
|
+
hint: state.hint
|
|
5460
|
+
});
|
|
5461
|
+
continue;
|
|
5462
|
+
}
|
|
5463
|
+
planned.push((await legacyRule(target))?.managed || (await diagnostic(target, bundled)).interrupted_update ? {
|
|
5464
|
+
target,
|
|
5465
|
+
action: "installed",
|
|
5466
|
+
content: bundled
|
|
5467
|
+
} : {
|
|
5468
|
+
target,
|
|
5469
|
+
action: "not_installed"
|
|
5470
|
+
});
|
|
5471
|
+
} else if (state.kind === "unmanaged") planned.push({
|
|
5093
5472
|
target,
|
|
5094
5473
|
action: "skipped_unmanaged"
|
|
5095
5474
|
});
|
|
@@ -5113,11 +5492,19 @@ async function runSkillsRemove(parsed, mode) {
|
|
|
5113
5492
|
const unavailable = unavailableSelection(filters.tools, filters.scope);
|
|
5114
5493
|
if (unavailable) return writeFailure(command, unavailable, mode, 1);
|
|
5115
5494
|
const planned = [];
|
|
5116
|
-
for (const target of filteredTargets(filters.tools, filters.scope)) {
|
|
5495
|
+
for (const target of await groupTargets(filteredTargets(filters.tools, filters.scope))) {
|
|
5117
5496
|
const state = await readTarget(target);
|
|
5118
|
-
if (state.kind === "broken") return writeFailure(command,
|
|
5497
|
+
if (state.kind === "broken") return writeFailure(command, await conflictFor(target), mode, 1);
|
|
5498
|
+
if (state.kind === "missing" && state.hint) {
|
|
5499
|
+
planned.push({
|
|
5500
|
+
target,
|
|
5501
|
+
action: "not_installed",
|
|
5502
|
+
hint: state.hint
|
|
5503
|
+
});
|
|
5504
|
+
continue;
|
|
5505
|
+
}
|
|
5119
5506
|
const managedLegacy = (await legacyRule(target))?.managed === true;
|
|
5120
|
-
const action = state.kind === "missing" ? managedLegacy ? "removed" : "not_installed" : state.kind === "managed" ? "removed" : "skipped_unmanaged";
|
|
5507
|
+
const action = state.kind === "missing" ? managedLegacy || (await diagnostic(target, await loadBundledSkills())).interrupted_update ? "removed" : "not_installed" : state.kind === "managed" ? "removed" : "skipped_unmanaged";
|
|
5121
5508
|
planned.push({
|
|
5122
5509
|
target,
|
|
5123
5510
|
action,
|
|
@@ -16334,7 +16721,8 @@ const skillsListDefinition = define({
|
|
|
16334
16721
|
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills list --json
|
|
16335
16722
|
|
|
16336
16723
|
Reports each tool and scope with detection, version, completeness, missing/differing files,
|
|
16337
|
-
ownership metadata, and legacy Cursor rule coexistence.
|
|
16724
|
+
ownership metadata, and legacy Cursor rule coexistence. Shared folders appear once with aliases
|
|
16725
|
+
and resolved_folder_path; broken links include repair hints.
|
|
16338
16726
|
Runs locally; no network or authentication is used.`
|
|
16339
16727
|
});
|
|
16340
16728
|
const skillsUpdateDefinition = define({
|
|
@@ -16353,7 +16741,10 @@ const skillsUpdateDefinition = define({
|
|
|
16353
16741
|
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills update --json
|
|
16354
16742
|
npm exec --yes --package=@artifactshare/cli -- artifactshare skills update --tool codex --scope user --json
|
|
16355
16743
|
|
|
16356
|
-
Updates managed folders
|
|
16744
|
+
Updates managed folders and repairs missing files. Edited owned files require --force; user additions are preserved.
|
|
16745
|
+
Folder and ancestor directory symlinks are resolved; internal links are refused even with --force.
|
|
16746
|
+
Shared folders are written once. JSON rows include aliases and resolved_folder_path.
|
|
16747
|
+
Real mutations clean reserved stale staging and UUID temporary files; dry runs do not.
|
|
16357
16748
|
Managed legacy Cursor rules migrate after the new project folder is ready.
|
|
16358
16749
|
|
|
16359
16750
|
Common failures:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artifactshare/cli",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.1",
|
|
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": {
|
|
@@ -67,6 +67,10 @@ npm exec --yes --package=@artifactshare/cli -- artifactshare skills list --json
|
|
|
67
67
|
- `skills ensure --tool auto` accepts omitted `--scope` or `--scope user`;
|
|
68
68
|
`--scope project` fails with `validation_failed`. Project-scope skills are
|
|
69
69
|
opt-in via `skills install --tool <tool> --scope project`.
|
|
70
|
-
- `skills update` updates installed managed skills to the bundled version.
|
|
70
|
+
- `skills update` updates installed managed skills to the bundled version. Edits to owned files require `skills update --force`; additions are preserved.
|
|
71
71
|
- `--force` overwrites an unmanaged file on install.
|
|
72
72
|
- Run `skills --help` for all subcommands.
|
|
73
|
+
|
|
74
|
+
Skill folders and their configured ancestors may be directory symlinks. The CLI resolves the folder with realpath and handles each shared destination once, in Codex, Claude, Cursor order (project before user); the first selected alias supplies the legacy fields. JSON target rows include `aliases` (tool, scope, path, folder_path) and `resolved_folder_path`. Explicit filters include only selected aliases. Internal links, including SKILL.md, references and the manifest, are refused even with force. Restore dangling links to a directory; preserve edits and replace internal links with ordinary content before retrying. A missing skill beneath a dangling ancestor is reported as not installed, with the broken ancestor path, and does not block other targets. Link and layout conflicts provide repair hints without a force command. Removal preserves configured links and their destination directory.
|
|
75
|
+
|
|
76
|
+
Writes prefer a private sibling `.artifactshare-staging-<uuid>` directory. If the parent is not writable or a commit crosses filesystems, the CLI stages inside the skill folder instead and still commits files by rename. Real install, update, ensure and automatic updates clean reserved staging directories and exact UUID-shaped `.artifactshare-<uuid>.tmp` regular files only when their modification times are more than ten minutes old before checking conflicts, including no-op selections. Diagnostics and dry runs never clean files. Unrelated names and symlink referents are never deleted. Failed writes roll back committed paths and remove staging; interrupted processes leave debris for the next mutation.
|