@rig-c/core 3.0.1 → 3.1.0
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/docs/AUTHORING.md +23 -5
- package/package.json +1 -1
- package/skills/rigc/SKILL.md +23 -5
- package/src/cli/core_commands.ts +228 -18
- package/src/cli/shared.ts +41 -22
package/docs/AUTHORING.md
CHANGED
|
@@ -139,7 +139,7 @@ commands take it and what its default is.
|
|
|
139
139
|
| `check --candidate <dir> --frames <dir> [--out <dir>]` | the candidate against reference pictures — the only instrument here that can see a *wrong animation*. `--out` also writes, for every frame the table lists, the picture its figures came from: reference, candidate, difference and overlay at native size <a id="cmd-check"></a> |
|
|
140
140
|
| `bench <rung> --candidate <dir>` | one rung of the benchmark ladder <a id="cmd-bench"></a> |
|
|
141
141
|
| `guide <RULE>` / `guide §<n>[.<m>[.<k>]] [--all]` | the guide's row for the rule a failure line names — every `FAIL` line, `vote --record` refusal, `ingest` finding and coded compile error ends with ` (see rigc guide <RULE>)`; only legacy uncoded library errors point at `§5.1` — or a section's heading, own prose and subsection index, read from the installed `docs/AUTHORING.md` when it runs. `--all` includes the subsection bodies; a leaf prints its full text either way. Sizes describe full ledger spans. `--all` with a rule is refused, exit 2; an unknown name is refused with the nearest real ones, exit 1 <a id="cmd-guide"></a> |
|
|
142
|
-
| `skills install [--dir …] [--copy]` | links every agent skill
|
|
142
|
+
| `skills install [--dir …] [--copy]` | links every agent skill this package and any installed `@rig-c/*` or rig-c alias package ship (`PACKAGE_ROOT/skills` and every `node_modules/@rig-c/*/skills/<name>/SKILL.md` and alias reachable from the project's `node_modules`) into `.agents/skills` (or `--dir`) as relative symlinks, or copies them with `--copy` — where Codex, Gemini CLI and Antigravity look — reporting which package each skill came from (`[<package>]`). In a consumer without `@rig-c/core` installed, reach the installer with `bunx @rig-c/core skills install`. A second run has nothing to do; an entry already there that is not this command's, or a duplicate skill name across two distinct packages (an alias or symlink resolving to the same `realpathSync` folder is deduplicated), is refused by name and nothing is written <a id="cmd-skills-install"></a> |
|
|
143
143
|
| `review <dir> […]` | the human review of a build, handed to the `rig-review` bin of `@rig-c/review` installed beside the package; rigc does not depend on it and never installs it. `rigc review <dir> [--reference <video>] [--animation <name>] [--compare <dir>]` is `rig-review open <dir> …` with those flags 1:1 and prints the loopback URL to give a person; a first argument that is one of review's own words (`open`, `check`, `feedback`, `control`, `strip`, `compare`) or starts with `-` (`--help`, `--`) is handed over untouched. stdout is review's byte for byte, stderr review's plus the launcher's own refusals, the exit code review's. Refused by name, exit 2, before the bin starts: `REVIEW_OUTPUT_MISSING <path>` (the target is not a directory); `REVIEW_NOT_INSTALLED` with two lines, `bun add -d @rig-c/review` and `bunx @rig-c/review open <dir> …` carrying the flags given — the same on a terminal and off, with nothing installed or written; `REVIEW_BUN_TOO_OLD: Bun <found>, @rig-c/review needs <required>`, the floor read off the installed package's `engines.bun`; and an empty argument (`""`) under a Bun that drops one (Bun 1.2.0, measured by a probe), `rigc review: argument N is empty, and Bun <version>, the Bun running this, drops an empty argument when it starts a process — …`. docs/AUTHORING.md lists every line <a id="cmd-review"></a> |
|
|
144
144
|
|
|
145
145
|
`diff`, `bonedist`, `check` and `bench` measure against something you were given; the
|
|
@@ -405,7 +405,7 @@ What the flags mean:
|
|
|
405
405
|
| `--min-visible` | `chainfit` only: below this share of a part surviving the parts drawn over it, the placement is refused `occluded` instead of reported flat (default `0.25`) — §12.4 |
|
|
406
406
|
| `--passes` | `chainfit` only: how many times the occluder masks are rebuilt from the answers and the fit rerun (default `2`) — §12.4 |
|
|
407
407
|
| `--anchor-residual` | `chainfit` only: the residual a `pose` placement must be within to anchor a chain (default `0.16`) — §12.2 |
|
|
408
|
-
| `--dir` | `skills install` only: the directory to install the agent skills into, resolved against your working directory (default `.agents/skills`, which Codex, Gemini CLI and Antigravity read). The skills are the `skills/` directory of the package the command runs from
|
|
408
|
+
| `--dir` | `skills install` only: the directory to install the agent skills into, resolved against your working directory (default `.agents/skills`, which Codex, Gemini CLI and Antigravity read). The skills are scanned from the `skills/` directory of the package the command runs from and every `@rig-c/*` and rig-c alias package in the project's `node_modules`, never a loose `skills/` in the working directory |
|
|
409
409
|
| `--copy` | `skills install` only: copy each skill folder instead of writing a relative symlink to it. A copy is not reached by an upgrade of the package; one that is no longer the package's bytes is refused on the next run, naming the first file that differs |
|
|
410
410
|
|
|
411
411
|
`render` also takes `--fps <n>` (the rate it samples at, default 12 — the same
|
|
@@ -438,10 +438,28 @@ each under `sets[].dir` — read the folder from there, not from the animation's
|
|
|
438
438
|
the subsections' bodies. A leaf prints its full text either way — §5 says when to reach for it.
|
|
439
439
|
|
|
440
440
|
`skills install` is the other command that is not about a rig: it puts the agent
|
|
441
|
-
skills
|
|
441
|
+
skills this package and every installed `@rig-c/*` or rig-c alias package ship where
|
|
442
|
+
an agent host looks for them, scanning `PACKAGE_ROOT/skills` and every
|
|
443
|
+
`node_modules/@rig-c/*/skills/<name>/SKILL.md` (and any unscoped alias package
|
|
444
|
+
shipping `skills/<name>/SKILL.md` that resolves by `realpathSync` into `@rig-c/*` or
|
|
445
|
+
declares a `github.com/rig-c/` `repository` in `package.json` — never by directory
|
|
446
|
+
name alone) reachable from the project's `node_modules`, and
|
|
447
|
+
reporting `[<package>]` on each line. Run it through the
|
|
442
448
|
project's own install — `bun rigc skills install` — so the links point into that
|
|
443
|
-
project's `node_modules/rig-c/skills
|
|
444
|
-
|
|
449
|
+
project's `node_modules/rig-c/skills/` (or `node_modules/@rig-c/core/skills/`) and
|
|
450
|
+
its sibling packages; in a
|
|
451
|
+
consumer without `@rig-c/core` installed (for example, a project with only
|
|
452
|
+
`@rig-c/play` or a host adapter), run `bunx @rig-c/core skills install --copy`
|
|
453
|
+
so every skill is written as a plain folder instead of linking `@rig-c/core`'s
|
|
454
|
+
skills into a temporary `.bunx` cache that can be emptied. A second run has nothing to do and
|
|
455
|
+
exits 0. An alias or symlink that resolves (`realpathSync`) to a skill folder
|
|
456
|
+
already discovered is deduplicated; two copies of the same product (`rig-c` ↔
|
|
457
|
+
`@rig-c/core`, `rig-<name>` ↔ `@rig-c/<name>`, or a project copy beside the running
|
|
458
|
+
package) choose the copy inside the project's `node_modules` first and the scoped
|
|
459
|
+
package (`@rig-c/*`) over the unscoped alias (`rig-*`), printing which copy was
|
|
460
|
+
chosen; two different products shipping the same skill
|
|
461
|
+
name refuse the call, exit 1, naming both sources (`<n> duplicate skill name(s)
|
|
462
|
+
across packages, and nothing was written:`). An entry already at `<dir>/<name>` that is not a link to the same folder
|
|
445
463
|
(or, under `--copy`, not the same bytes) is refused, exit 1, and **nothing is
|
|
446
464
|
written** — every such entry is named with what is there and what was required:
|
|
447
465
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rig-c/core",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "AI-authored 2D rigging and animation, verified before it is written. rigc compiles a rig spec into skeleton data in the Spine 4.3 format, gates it with named assertions held to a spine-core round trip's verdicts, and emits nothing that fails. Ships as an agent skill.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/skills/rigc/SKILL.md
CHANGED
|
@@ -46,14 +46,20 @@ index within that same limit; only legacy uncoded library errors point at `§5.1
|
|
|
46
46
|
## Install
|
|
47
47
|
|
|
48
48
|
```shell
|
|
49
|
-
bunx @rig-c/core --help
|
|
50
|
-
bun add -d @rig-c/core
|
|
51
|
-
bun rigc skills install
|
|
49
|
+
bunx @rig-c/core --help # run it without installing
|
|
50
|
+
bun add -d @rig-c/core # or pin it in the project; the command is `rigc`
|
|
51
|
+
bun rigc skills install # link this package's and every installed @rig-c/* package's skills into .agents/skills
|
|
52
|
+
bunx @rig-c/core skills install --copy # in a consumer without @rig-c/core installed (for example, only @rig-c/play)
|
|
52
53
|
```
|
|
53
54
|
|
|
54
55
|
Codex, Gemini CLI and Antigravity read skills from `.agents/skills/` in the
|
|
55
|
-
workspace and none of them reads `node_modules`; `rigc skills install`
|
|
56
|
-
|
|
56
|
+
workspace and none of them reads `node_modules`; `rigc skills install` scans this
|
|
57
|
+
package's `skills/` and every `node_modules/@rig-c/*/skills/<name>/SKILL.md` (and
|
|
58
|
+
rig-c alias package) in the project, and `rigc skills --help` says what it refuses.
|
|
59
|
+
In a consumer without `@rig-c/core` installed, run `bunx @rig-c/core skills install --copy`:
|
|
60
|
+
it reaches the project's `node_modules` from the working directory and writes plain
|
|
61
|
+
folders instead of linking `@rig-c/core`'s own skills into a temporary `.bunx` cache
|
|
62
|
+
that can be emptied.
|
|
57
63
|
|
|
58
64
|
The package links no Spine runtime. `build` writes `skeleton.json`,
|
|
59
65
|
`skeleton.atlas` and `skeleton.model.json`. `preview`, `vote`, `bench` and `bonedist`
|
|
@@ -158,6 +164,18 @@ spec files field by field, the emission rules, the loop, and the failure map. Th
|
|
|
158
164
|
| a **skeleton.json somebody else authored** — read it, repair it, extend it | [INGEST.md](https://github.com/rig-c/core/blob/main/docs/INGEST.md) | `rigc-ingest` |
|
|
159
165
|
| you are the **person operating** the agent rather than the agent | [PROMPTING.md](https://github.com/rig-c/core/blob/main/docs/PROMPTING.md) | — |
|
|
160
166
|
|
|
167
|
+
Other `@rig-c/*` packages ship their own agent skills (`node_modules/@rig-c/<pkg>/skills/<skill>/SKILL.md`), which `rigc skills install` links beside these; load that skill for its tool's flags and rules:
|
|
168
|
+
|
|
169
|
+
| The request is… | Tool | Skill |
|
|
170
|
+
| --- | --- | --- |
|
|
171
|
+
| Turn one anime character painting and its See-through layer decomposition into a verified 2D character rig — measured parts, weighted meshes, bone chains and a looping idle | `@rig-c/parts` (`rig-parts`) | `rig-parts` |
|
|
172
|
+
| Clean and retarget a body-18 (or COCO-17) pose sequence onto a rig built by `rigc` or `@rig-c/parts` — bone rotate keys, hip translate keys, leg foreshortening, alternate-drawing switches and skirt-physics fitting | `@rig-c/pose` (`rig-pose`) | `rig-pose` |
|
|
173
|
+
| Hand a rig build or `rig-parts`/`rig-pose` output to a person for local inspection in a browser workspace (`rig-review open`) and retrieve their structured feedback (`rig-review feedback`), validate the delivery package (`rig-review check`), or export frame strips (`rig-review strip`) | `@rig-c/review` (`rig-review`) | `rig-review` |
|
|
174
|
+
| Play a rig built by `rigc` (`skeleton.model.json`) on a web page as plain DOM or a standalone `<canvas>`, with multi-track playback, attachment sets, wind and gravity physics, bone adjustments and live-frame borrowing | `@rig-c/play` (`rig-play`) | `rig-play` |
|
|
175
|
+
| Play a rig built by `rigc` (`skeleton.model.json`) inside a PixiJS 8 scene graph (`PixiRig` and `PixiRenderer`), posed through `@rig-c/play` with no Spine runtime | `@rig-c/pixi` | `rig-pixi` |
|
|
176
|
+
| Play a rig built by `rigc` (`skeleton.model.json`) inside a Phaser 4.2+ WebGL scene (`PhaserRig` and `PhaserRenderer`), posed through `@rig-c/play` with shared GPU page textures and no Spine runtime | `@rig-c/phaser` | `rig-phaser` |
|
|
177
|
+
| Play a rig built by `rigc` (`skeleton.model.json`) inside a native Three.js WebGL2 scene (`ThreeRig` and `ThreeRenderer`), posed through `@rig-c/play` under an orthographic or perspective camera with no Spine runtime | `@rig-c/three` | `rig-three` |
|
|
178
|
+
|
|
161
179
|
Every guide linked here is in the installed package at `node_modules/@rig-c/core/docs/`,
|
|
162
180
|
which is the copy that matches the rigc you run; the links go to the repository's
|
|
163
181
|
`main`. Inside the Claude Code plugin the same files are at `${CLAUDE_PLUGIN_ROOT}/docs/`.
|
package/src/cli/core_commands.ts
CHANGED
|
@@ -2211,19 +2211,163 @@ interface SkillsInstallEntry {
|
|
|
2211
2211
|
target: string;
|
|
2212
2212
|
/** `<package>/skills/<name>`. */
|
|
2213
2213
|
source: string;
|
|
2214
|
+
/** Which package the skill came from (`package.json` `name`, or its `node_modules` directory name). */
|
|
2215
|
+
packageName: string;
|
|
2214
2216
|
action: SkillsInstallAction;
|
|
2215
2217
|
/** The link text, relative to the directory it sits in, when the entry is a link. */
|
|
2216
2218
|
link: string;
|
|
2219
|
+
/** Other copies of the same product that this copy was chosen over, when more than one copy was present. */
|
|
2220
|
+
chosenOver?: Array<{ packageName: string; source: string }>;
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
export interface DiscoveredSkillSource {
|
|
2224
|
+
packageName: string;
|
|
2225
|
+
skillsDir: string;
|
|
2226
|
+
/** Whether this source lives inside a `node_modules` tree reached walking up from `process.cwd()`. */
|
|
2227
|
+
inProjectNodeModules?: boolean;
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
/**
|
|
2231
|
+
* Canonical product identity for a package name (issue #1672):
|
|
2232
|
+
* `rig-c`, `spine-rigc` and `@rig-c/core` are the same product (`@rig-c/core`), and each unscoped convenience
|
|
2233
|
+
* alias `rig-<name>` is the same product as `@rig-c/<name>`.
|
|
2234
|
+
*/
|
|
2235
|
+
function canonicalProduct(packageName: string): string {
|
|
2236
|
+
if (packageName === 'rig-c' || packageName === 'spine-rigc' || packageName === '@rig-c/core') {
|
|
2237
|
+
return '@rig-c/core';
|
|
2238
|
+
}
|
|
2239
|
+
if (packageName.startsWith('rig-')) {
|
|
2240
|
+
return `@rig-c/${packageName.slice('rig-'.length)}`;
|
|
2241
|
+
}
|
|
2242
|
+
return packageName;
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
function isDirectoryThere(path: string): boolean {
|
|
2246
|
+
try {
|
|
2247
|
+
return existsSync(path) && statSync(path).isDirectory();
|
|
2248
|
+
} catch {
|
|
2249
|
+
return false;
|
|
2250
|
+
}
|
|
2217
2251
|
}
|
|
2218
2252
|
|
|
2219
2253
|
/** Every `<name>/` under `source` that holds a `SKILL.md`, in name order, so two runs print the same lines. */
|
|
2220
2254
|
function shippedSkills(source: string): string[] {
|
|
2221
|
-
if (!
|
|
2255
|
+
if (!isDirectoryThere(source)) return [];
|
|
2222
2256
|
return readdirSync(source)
|
|
2223
|
-
.filter((name) =>
|
|
2257
|
+
.filter((name) => isDirectoryThere(join(source, name)) && existsSync(join(source, name, 'SKILL.md')))
|
|
2224
2258
|
.sort();
|
|
2225
2259
|
}
|
|
2226
2260
|
|
|
2261
|
+
/** Read `<pkgDir>/package.json`'s `name` when present and non-empty, falling back to `fallback`. */
|
|
2262
|
+
function readPackageName(pkgDir: string, fallback: string): string {
|
|
2263
|
+
const manifestPath = join(pkgDir, 'package.json');
|
|
2264
|
+
if (!existsSync(manifestPath)) return fallback;
|
|
2265
|
+
try {
|
|
2266
|
+
const raw = JSON.parse(readFileSync(manifestPath, 'utf8')) as { name?: unknown };
|
|
2267
|
+
return typeof raw.name === 'string' && raw.name.trim() !== '' ? raw.name.trim() : fallback;
|
|
2268
|
+
} catch {
|
|
2269
|
+
return fallback;
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
/**
|
|
2274
|
+
* Whether an unscoped `<node_modules>/<entry>` directory is a rig-c alias package (issue #1672):
|
|
2275
|
+
* 1. it resolves (`realpathSync`) into a `@rig-c/*` directory, or
|
|
2276
|
+
* 2. its `package.json` `repository` (string or `{url}`) points at `github.com/rig-c/`.
|
|
2277
|
+
* A directory or package name alone never qualifies, because any third party can publish an unscoped `rig-<anything>`
|
|
2278
|
+
* package.
|
|
2279
|
+
*/
|
|
2280
|
+
function isRigcAliasDir(pkgDir: string): boolean {
|
|
2281
|
+
try {
|
|
2282
|
+
if (realpathSync(pkgDir).replaceAll('\\', '/').includes('/@rig-c/')) return true;
|
|
2283
|
+
} catch {
|
|
2284
|
+
return false;
|
|
2285
|
+
}
|
|
2286
|
+
const manifestPath = join(pkgDir, 'package.json');
|
|
2287
|
+
if (!existsSync(manifestPath)) return false;
|
|
2288
|
+
try {
|
|
2289
|
+
const raw = JSON.parse(readFileSync(manifestPath, 'utf8')) as { repository?: unknown };
|
|
2290
|
+
const repo =
|
|
2291
|
+
typeof raw.repository === 'string'
|
|
2292
|
+
? raw.repository.trim()
|
|
2293
|
+
: typeof raw.repository === 'object' && raw.repository !== null && typeof (raw.repository as { url?: unknown }).url === 'string'
|
|
2294
|
+
? (raw.repository as { url: string }).url.trim()
|
|
2295
|
+
: '';
|
|
2296
|
+
return /^(?:(?:git\+)?https?:\/\/|(?:git\+)?ssh:\/\/git@|git:\/\/)?github\.com[:/]rig-c\/[A-Za-z0-9._-]+(?:\.git)?\/?$/.test(repo);
|
|
2297
|
+
} catch {
|
|
2298
|
+
return false;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
/**
|
|
2303
|
+
* Every `node_modules` directory reachable from `cwd` (walking up `<dir>/node_modules`) and from an installed
|
|
2304
|
+
* `packageRoot` (every ancestor directory named `node_modules`, which covers flat `@rig-c/core`, unscoped `rig-c`, and
|
|
2305
|
+
* isolated `node_modules/.bun/.../node_modules/@rig-c/core` layouts), deduplicated by `realpathSync`.
|
|
2306
|
+
*/
|
|
2307
|
+
function nodeModulesRoots(cwd: string, packageRoot: string): string[] {
|
|
2308
|
+
const out: string[] = [];
|
|
2309
|
+
const seen = new Set<string>();
|
|
2310
|
+
const add = (nm: string): void => {
|
|
2311
|
+
if (!isDirectoryThere(nm)) return;
|
|
2312
|
+
const real = realpathSync(nm);
|
|
2313
|
+
if (seen.has(real)) return;
|
|
2314
|
+
seen.add(real);
|
|
2315
|
+
out.push(nm);
|
|
2316
|
+
};
|
|
2317
|
+
for (let dir = resolve(cwd); ; dir = dirname(dir)) {
|
|
2318
|
+
add(join(dir, 'node_modules'));
|
|
2319
|
+
if (dirname(dir) === dir) break;
|
|
2320
|
+
}
|
|
2321
|
+
for (let dir = dirname(resolve(packageRoot)); dirname(dir) !== dir; dir = dirname(dir)) {
|
|
2322
|
+
if (basename(dir) === 'node_modules') add(dir);
|
|
2323
|
+
}
|
|
2324
|
+
return out;
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
/**
|
|
2328
|
+
* Every skill-shipping package source `rigc skills install` scans (issue #1672):
|
|
2329
|
+
* 1. `join(packageRoot, 'skills')` — the package this command ran from, always first;
|
|
2330
|
+
* 2. every `node_modules/@rig-c/<pkg>/skills` and every rig-c alias package's `skills/` reachable from the project's
|
|
2331
|
+
* `node_modules`, in deterministic sorted order.
|
|
2332
|
+
*/
|
|
2333
|
+
export function discoverSkillSources(cwd: string, packageRoot: string): DiscoveredSkillSource[] {
|
|
2334
|
+
const projectNmReals = new Set<string>();
|
|
2335
|
+
for (let dir = resolve(cwd); ; dir = dirname(dir)) {
|
|
2336
|
+
const nm = join(dir, 'node_modules');
|
|
2337
|
+
if (isDirectoryThere(nm)) projectNmReals.add(realpathSync(nm));
|
|
2338
|
+
if (dirname(dir) === dir) break;
|
|
2339
|
+
}
|
|
2340
|
+
const sources: DiscoveredSkillSource[] = [
|
|
2341
|
+
{
|
|
2342
|
+
packageName: readPackageName(packageRoot, basename(packageRoot)),
|
|
2343
|
+
skillsDir: join(packageRoot, 'skills'),
|
|
2344
|
+
inProjectNodeModules: false,
|
|
2345
|
+
},
|
|
2346
|
+
];
|
|
2347
|
+
for (const nm of nodeModulesRoots(cwd, packageRoot)) {
|
|
2348
|
+
const inProjectNodeModules = projectNmReals.has(realpathSync(nm));
|
|
2349
|
+
const scopeDir = join(nm, '@rig-c');
|
|
2350
|
+
if (isDirectoryThere(scopeDir)) {
|
|
2351
|
+
for (const sub of readdirSync(scopeDir).sort()) {
|
|
2352
|
+
const pkgDir = join(scopeDir, sub);
|
|
2353
|
+
const skillsDir = join(pkgDir, 'skills');
|
|
2354
|
+
if (isDirectoryThere(pkgDir) && shippedSkills(skillsDir).length > 0) {
|
|
2355
|
+
sources.push({ packageName: readPackageName(pkgDir, `@rig-c/${sub}`), skillsDir, inProjectNodeModules });
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
for (const entry of readdirSync(nm).sort()) {
|
|
2360
|
+
if (entry.startsWith('@') || entry.startsWith('.')) continue;
|
|
2361
|
+
const pkgDir = join(nm, entry);
|
|
2362
|
+
const skillsDir = join(pkgDir, 'skills');
|
|
2363
|
+
if (isDirectoryThere(pkgDir) && isRigcAliasDir(pkgDir) && shippedSkills(skillsDir).length > 0) {
|
|
2364
|
+
sources.push({ packageName: readPackageName(pkgDir, entry), skillsDir, inProjectNodeModules });
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
return sources;
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2227
2371
|
/**
|
|
2228
2372
|
* The real path of `path` whether or not it exists yet: the real path of its
|
|
2229
2373
|
* nearest existing ancestor with the rest appended. A relative link has to be
|
|
@@ -2266,30 +2410,90 @@ function firstDifference(copy: string, original: string): string | null {
|
|
|
2266
2410
|
}
|
|
2267
2411
|
|
|
2268
2412
|
/**
|
|
2269
|
-
* Install every
|
|
2413
|
+
* Install every discovered skill into `dir`, or refuse and write nothing.
|
|
2270
2414
|
*
|
|
2271
|
-
* The plan is made in full before the first write:
|
|
2272
|
-
*
|
|
2273
|
-
*
|
|
2415
|
+
* The plan is made in full before the first write:
|
|
2416
|
+
* - two sources that resolve (`realpathSync`) to the same skill folder are one skill (an alias or symlink reached
|
|
2417
|
+
* twice is deduplicated);
|
|
2418
|
+
* - two copies of the same product (`rig-c` ↔ `@rig-c/core`, `rig-<name>` ↔ `@rig-c/<name>`, or a project copy beside
|
|
2419
|
+
* the running package) are not a collision: the copy in the project's `node_modules` wins over the running package,
|
|
2420
|
+
* and between two project copies the scoped package (`@rig-c/*`) wins over the unscoped alias (`rig-*`), with the
|
|
2421
|
+
* chosen copy reported on its line;
|
|
2422
|
+
* - two different products shipping the same skill name refuse the call naming both sources and write nothing;
|
|
2423
|
+
* - every target is classified as absent, already this command's, or in the way, and one entry in the way refuses the
|
|
2424
|
+
* whole call with every such entry named.
|
|
2274
2425
|
*/
|
|
2275
|
-
function installSkills(
|
|
2276
|
-
const
|
|
2277
|
-
if (
|
|
2426
|
+
function installSkills(sources: readonly DiscoveredSkillSource[], dir: string, copy: boolean): SkillsInstallEntry[] {
|
|
2427
|
+
const own = sources[0];
|
|
2428
|
+
if (own === undefined || shippedSkills(own.skillsDir).length === 0) {
|
|
2429
|
+
const ownSource = own?.skillsDir ?? join(PACKAGE_ROOT, 'skills');
|
|
2278
2430
|
throw new SkillsInstallError(
|
|
2279
|
-
`no skill to install: ${
|
|
2431
|
+
`no skill to install: ${ownSource} ${existsSync(ownSource) ? 'holds no <name>/SKILL.md' : 'is not there'}, and it is ` +
|
|
2280
2432
|
'the skills/ directory of the package this command ran from; nothing was written',
|
|
2281
2433
|
);
|
|
2282
2434
|
}
|
|
2435
|
+
interface CandidateSkill {
|
|
2436
|
+
name: string;
|
|
2437
|
+
packageName: string;
|
|
2438
|
+
product: string;
|
|
2439
|
+
source: string;
|
|
2440
|
+
realFrom: string;
|
|
2441
|
+
inProjectNodeModules: boolean;
|
|
2442
|
+
isScoped: boolean;
|
|
2443
|
+
chosenOver?: Array<{ packageName: string; source: string }>;
|
|
2444
|
+
}
|
|
2445
|
+
const byName = new Map<string, CandidateSkill[]>();
|
|
2446
|
+
for (const src of sources) {
|
|
2447
|
+
const inProject = Boolean(src.inProjectNodeModules);
|
|
2448
|
+
const product = canonicalProduct(src.packageName);
|
|
2449
|
+
const isScoped = src.packageName.startsWith('@rig-c/');
|
|
2450
|
+
for (const name of shippedSkills(src.skillsDir)) {
|
|
2451
|
+
const from = join(src.skillsDir, name);
|
|
2452
|
+
const realFrom = realpathSync(from);
|
|
2453
|
+
const list = byName.get(name) ?? [];
|
|
2454
|
+
if (list.some((item) => item.realFrom === realFrom)) {
|
|
2455
|
+
const existing = list.find((item) => item.realFrom === realFrom);
|
|
2456
|
+
if (existing !== undefined && inProject) existing.inProjectNodeModules = true;
|
|
2457
|
+
continue;
|
|
2458
|
+
}
|
|
2459
|
+
list.push({ name, packageName: src.packageName, product, source: from, realFrom, inProjectNodeModules: inProject, isScoped });
|
|
2460
|
+
byName.set(name, list);
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
const collisions = [...byName.entries()]
|
|
2464
|
+
.filter(([, list]) => new Set(list.map((item) => item.product)).size > 1)
|
|
2465
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
2466
|
+
if (collisions.length > 0) {
|
|
2467
|
+
throw new SkillsInstallError(
|
|
2468
|
+
`${collisions.length} duplicate skill name(s) across packages, and nothing was written:\n` +
|
|
2469
|
+
collisions
|
|
2470
|
+
.map(([name, list]) => ` ${name} is shipped by ${list.map((item) => `${item.packageName} (${item.source})`).join(' and ')}`)
|
|
2471
|
+
.join('\n'),
|
|
2472
|
+
);
|
|
2473
|
+
}
|
|
2283
2474
|
if (existsSync(dir) && !statSync(dir).isDirectory()) {
|
|
2284
2475
|
throw new SkillsInstallError(`${dir} exists and is not a directory, so no skill can be installed into it; nothing was written`);
|
|
2285
2476
|
}
|
|
2477
|
+
const discovered = [...byName.values()]
|
|
2478
|
+
.map((list) => {
|
|
2479
|
+
if (list.length === 1) return list[0];
|
|
2480
|
+
const ranked = [...list].sort((a, b) => {
|
|
2481
|
+
if (a.inProjectNodeModules !== b.inProjectNodeModules) return a.inProjectNodeModules ? -1 : 1;
|
|
2482
|
+
if (a.isScoped !== b.isScoped) return a.isScoped ? -1 : 1;
|
|
2483
|
+
return 0;
|
|
2484
|
+
});
|
|
2485
|
+
return {
|
|
2486
|
+
...ranked[0],
|
|
2487
|
+
chosenOver: ranked.slice(1).map((item) => ({ packageName: item.packageName, source: item.source })),
|
|
2488
|
+
};
|
|
2489
|
+
})
|
|
2490
|
+
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
2286
2491
|
const realDir = realpathAhead(dir);
|
|
2287
2492
|
const planned: SkillsInstallEntry[] = [];
|
|
2288
2493
|
const refused: string[] = [];
|
|
2289
|
-
for (const
|
|
2494
|
+
for (const item of discovered) {
|
|
2495
|
+
const { name, packageName, source: from, realFrom, chosenOver } = item;
|
|
2290
2496
|
const target = join(dir, name);
|
|
2291
|
-
const from = join(source, name);
|
|
2292
|
-
const realFrom = realpathSync(from);
|
|
2293
2497
|
const link = relative(realDir, realFrom);
|
|
2294
2498
|
let action: SkillsInstallAction = copy ? 'copied' : 'linked';
|
|
2295
2499
|
let found: string | null = null;
|
|
@@ -2312,11 +2516,11 @@ function installSkills(source: string, dir: string, copy: boolean): SkillsInstal
|
|
|
2312
2516
|
found = 'a plain file';
|
|
2313
2517
|
}
|
|
2314
2518
|
if (found !== null) refused.push(`${target} is ${found}; ${copy ? `a copy of ${from}` : `a symlink to ${link}`} was required`);
|
|
2315
|
-
else planned.push({ target, source: from, action, link });
|
|
2519
|
+
else planned.push({ target, source: from, packageName, action, link, chosenOver });
|
|
2316
2520
|
}
|
|
2317
2521
|
if (refused.length > 0) {
|
|
2318
2522
|
throw new SkillsInstallError(
|
|
2319
|
-
`${refused.length} of the ${
|
|
2523
|
+
`${refused.length} of the ${discovered.length} skill(s) cannot be installed into ${dir}, and nothing was written:\n` +
|
|
2320
2524
|
refused.map((line) => ` ${line}`).join('\n') +
|
|
2321
2525
|
'\nRemove the entries named above, or pass --dir to install somewhere else.',
|
|
2322
2526
|
);
|
|
@@ -2343,7 +2547,7 @@ export function cmdSkills(flags: Record<string, string>, positional: string[]):
|
|
|
2343
2547
|
if (sub === undefined) {
|
|
2344
2548
|
throw new UsageError(
|
|
2345
2549
|
`skills takes a subcommand: ${SKILLS_SUBCOMMANDS.join(', ')} — \`rigc skills install\` links every skill this ` +
|
|
2346
|
-
`package
|
|
2550
|
+
`package and any installed @rig-c/* or alias package ship into ${DEFAULT_SKILLS_DIR}`,
|
|
2347
2551
|
);
|
|
2348
2552
|
}
|
|
2349
2553
|
if (!SKILLS_SUBCOMMANDS.includes(sub)) {
|
|
@@ -2364,9 +2568,15 @@ export function cmdSkills(flags: Record<string, string>, positional: string[]):
|
|
|
2364
2568
|
}
|
|
2365
2569
|
const copy = flags.copy !== undefined;
|
|
2366
2570
|
const dir = resolve(process.cwd(), flags.dir ?? DEFAULT_SKILLS_DIR);
|
|
2367
|
-
const entries = installSkills(
|
|
2571
|
+
const entries = installSkills(discoverSkillSources(process.cwd(), PACKAGE_ROOT), dir, copy);
|
|
2368
2572
|
for (const entry of entries) {
|
|
2369
|
-
const
|
|
2573
|
+
const choiceNote =
|
|
2574
|
+
entry.chosenOver !== undefined && entry.chosenOver.length > 0
|
|
2575
|
+
? ` (chose ${entry.packageName} at ${entry.source} over ${entry.chosenOver.map((o) => `${o.packageName} at ${o.source}`).join(', ')})`
|
|
2576
|
+
: '';
|
|
2577
|
+
const ends = entry.action.endsWith('linked')
|
|
2578
|
+
? `${entry.target} -> ${entry.link} (${entry.source}) [${entry.packageName}]${choiceNote}`
|
|
2579
|
+
: `${entry.target} <- ${entry.source} [${entry.packageName}]${choiceNote}`;
|
|
2370
2580
|
console.log(` ${entry.action.padEnd(14)} ${ends}`);
|
|
2371
2581
|
}
|
|
2372
2582
|
const wrote = entries.filter((entry) => entry.action === 'linked' || entry.action === 'copied').length;
|
package/src/cli/shared.ts
CHANGED
|
@@ -933,20 +933,26 @@ export const DEFAULT_BALLOT = 'ballot.html';
|
|
|
933
933
|
export const DEFAULT_LEDGER = 'votes.jsonl';
|
|
934
934
|
|
|
935
935
|
// ---------------------------------------------------------------------------
|
|
936
|
-
// skills install — put the shipped skills where an agent host looks (
|
|
936
|
+
// skills install — put the shipped skills where an agent host looks (issues #831, #1672)
|
|
937
937
|
// ---------------------------------------------------------------------------
|
|
938
938
|
//
|
|
939
|
-
// After `bun add -d rig-c`
|
|
940
|
-
//
|
|
941
|
-
//
|
|
942
|
-
//
|
|
943
|
-
//
|
|
939
|
+
// After `bun add -d @rig-c/core` (and sibling packages such as `@rig-c/parts` or
|
|
940
|
+
// `@rig-c/play`) the skills sit at `node_modules/@rig-c/*/skills/`, which no
|
|
941
|
+
// host reads. Codex, Gemini CLI and Antigravity all read
|
|
942
|
+
// `<workspace>/.agents/skills/<name>/`, so this links every `skills/<name>/` this
|
|
943
|
+
// package and every installed `@rig-c/*` or rig-c alias package ship into one
|
|
944
|
+
// directory — `.agents/skills` under the working directory unless `--dir` says
|
|
945
|
+
// otherwise.
|
|
944
946
|
//
|
|
945
|
-
// ⭐ The skills are found from
|
|
946
|
-
//
|
|
947
|
-
//
|
|
948
|
-
//
|
|
949
|
-
//
|
|
947
|
+
// ⭐ The skills are found from `PACKAGE_ROOT/skills` and every `node_modules/@rig-c/*`
|
|
948
|
+
// and rig-c alias package reachable from the working directory's and `PACKAGE_ROOT`'s
|
|
949
|
+
// `node_modules` — never a loose `skills/` in the working directory itself. Two
|
|
950
|
+
// paths that resolve (`realpathSync`) to the same skill folder are deduplicated;
|
|
951
|
+
// two copies of the same product (`rig-c` ↔ `@rig-c/core`, `rig-<name>` ↔ `@rig-c/<name>`)
|
|
952
|
+
// choose the project's `node_modules` copy over the running package and the scoped
|
|
953
|
+
// package over the unscoped alias, printing which copy was chosen; two different
|
|
954
|
+
// products shipping the same skill name refuse the call naming both sources and
|
|
955
|
+
// write nothing.
|
|
950
956
|
//
|
|
951
957
|
// A RELATIVE symlink by default, so the directory survives the project being
|
|
952
958
|
// moved or cloned elsewhere and an upgrade of the package is seen with no second
|
|
@@ -1986,15 +1992,26 @@ export const COMMANDS: CommandDoc[] = [
|
|
|
1986
1992
|
name: 'skills',
|
|
1987
1993
|
runtime: false,
|
|
1988
1994
|
spineFormat: false,
|
|
1989
|
-
usage: [`rigc skills install [--dir ${DEFAULT_SKILLS_DIR}] [--copy] (every skill this package
|
|
1995
|
+
usage: [`rigc skills install [--dir ${DEFAULT_SKILLS_DIR}] [--copy] (every skill this package and any installed rig-c package ship, where an agent host looks)`],
|
|
1990
1996
|
flags: ['dir', 'copy'],
|
|
1991
1997
|
notes: [
|
|
1992
|
-
'
|
|
1993
|
-
'
|
|
1994
|
-
'
|
|
1995
|
-
'
|
|
1996
|
-
'
|
|
1997
|
-
'
|
|
1998
|
+
'scans the skills/ directory of the package this command runs from and every',
|
|
1999
|
+
'node_modules/@rig-c/*/skills/<name>/SKILL.md and rig-c alias package (resolving by',
|
|
2000
|
+
'realpathSync into @rig-c/* or declaring a github.com/rig-c/ repository in',
|
|
2001
|
+
'package.json, never by directory name alone) reachable',
|
|
2002
|
+
'from the project\'s node_modules (never a loose skills/ in the working directory),',
|
|
2003
|
+
'reporting which package each skill came from. An alias or symlink that resolves',
|
|
2004
|
+
'(realpathSync) to the same skill folder is deduplicated; two copies of the same',
|
|
2005
|
+
'product (rig-c ↔ @rig-c/core, rig-<name> ↔ @rig-c/<name>) choose the project\'s',
|
|
2006
|
+
'node_modules copy first and the scoped package over the alias, printing which copy',
|
|
2007
|
+
'was chosen; two different products shipping the same skill name refuse the call',
|
|
2008
|
+
'naming both sources and write nothing. Each skill becomes <dir>/<name>: a relative',
|
|
2009
|
+
'symlink into that folder, or with --copy a copy of it (use `bunx @rig-c/core skills',
|
|
2010
|
+
'install --copy` in a project without @rig-c/core installed so no link points into a',
|
|
2011
|
+
'temporary .bunx cache). An entry already there that is not a link to the same folder',
|
|
2012
|
+
'— or, with --copy, not the same bytes — is refused by name, exit 1, and nothing is',
|
|
2013
|
+
'written; a run over only what this command made has nothing to do and exits 0. Codex,',
|
|
2014
|
+
'Gemini CLI and Antigravity read',
|
|
1998
2015
|
`<workspace>/${DEFAULT_SKILLS_DIR}; Claude Code installs the plugin instead (README,`,
|
|
1999
2016
|
'"Install it into your agent").',
|
|
2000
2017
|
],
|
|
@@ -2172,12 +2189,14 @@ const USAGE_PARAGRAPHS: ReadonlyArray<{ about: readonly string[] | { flag: strin
|
|
|
2172
2189
|
{
|
|
2173
2190
|
about: ['skills'],
|
|
2174
2191
|
lines: () => [
|
|
2175
|
-
'skills install puts the agent skills this package
|
|
2176
|
-
'for them, since none
|
|
2192
|
+
'skills install puts the agent skills this package and every installed @rig-c/* or',
|
|
2193
|
+
'alias package ship where an agent host looks for them, since none reads node_modules:',
|
|
2177
2194
|
` rigc skills install relative links in ${DEFAULT_SKILLS_DIR}, which Codex, Gemini CLI`,
|
|
2178
2195
|
' and Antigravity read; --copy writes the folders instead',
|
|
2179
|
-
'
|
|
2180
|
-
'
|
|
2196
|
+
'Two copies of the same product choose the project copy first and the scoped package',
|
|
2197
|
+
'over the alias; an entry already there that this command did not make, or a duplicate',
|
|
2198
|
+
'skill name across two different products, is refused by name and nothing is written.',
|
|
2199
|
+
'See `rigc skills --help`.',
|
|
2181
2200
|
],
|
|
2182
2201
|
},
|
|
2183
2202
|
{
|