skill-land 1.5.0 → 1.7.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/README.md +24 -0
- package/package.json +1 -1
- package/skill-land.mjs +142 -17
package/README.md
CHANGED
|
@@ -134,6 +134,21 @@ Where an agent has several directories it reads, `--verify` counts the skill as
|
|
|
134
134
|
it is **complete in any one of them**. Requiring every fallback to hold a copy reports
|
|
135
135
|
working installs as broken.
|
|
136
136
|
|
|
137
|
+
### Leftover files
|
|
138
|
+
|
|
139
|
+
Installing copies over the top and never deletes, so a file dropped from a skill stays on disk
|
|
140
|
+
after a reinstall. `--verify` lists anything in the installed directory that the source does not
|
|
141
|
+
have:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
OK ~/.codex/skills/pack 3/3 files (verify only)
|
|
145
|
+
WARN ~/.codex/skills/pack 1 leftover file not in the source: scripts/old.sh
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
This is a warning and does not change the exit code, because an installed directory can also hold
|
|
149
|
+
files a person or the agent added, and nothing here can tell those from stale ones. `skill-land`
|
|
150
|
+
never deletes them. It is skipped for a raw `.md` source, which only knows about `SKILL.md`.
|
|
151
|
+
|
|
137
152
|
### Does the agent actually load it? `--discover`
|
|
138
153
|
|
|
139
154
|
Everything above proves the bytes are on disk. It does not prove the agent loads them: it may
|
|
@@ -167,6 +182,11 @@ Verification assumes the installer **copied**. Some installers **rewrite** on in
|
|
|
167
182
|
still report `content matches source` failures, because they genuinely differ from the source.
|
|
168
183
|
`skill-land` reports the difference and does not guess which side is right.
|
|
169
184
|
|
|
185
|
+
**Renamed and removed skills are not detected.** `skill-land` keeps no record of what it installed,
|
|
186
|
+
and the install directory comes from the skill's `name`. After a rename the old directory stays
|
|
187
|
+
next to the new one, and `--verify` only looks at the new one. A skill removed from its source is
|
|
188
|
+
never looked at. There is no uninstall command, so delete the old directory by hand.
|
|
189
|
+
|
|
170
190
|
Tested against: truncated file, wrong skill in the right place, missing file,
|
|
171
191
|
unwritable destination, and a real `npx skills add` install (correctly reported FAIL).
|
|
172
192
|
|
|
@@ -364,3 +384,7 @@ global install, which is what drives the warning note.
|
|
|
364
384
|
Install and verify only. No registry, no publishing, no per-platform content
|
|
365
385
|
transforms. One `SKILL.md` works across all of these agents; the failure mode here is
|
|
366
386
|
a wrong-path bug, not a content-format problem.
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
Made by [@magithar](https://x.com/magithar). Follow along for new skills and tools.
|
package/package.json
CHANGED
package/skill-land.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { execFileSync } from "child_process";
|
|
|
13
13
|
import { createHash } from "crypto";
|
|
14
14
|
import {
|
|
15
15
|
cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync,
|
|
16
|
-
readFileSync, realpathSync, rmSync, statSync,
|
|
16
|
+
readFileSync, realpathSync, rmSync, statSync, writeFileSync,
|
|
17
17
|
} from "fs";
|
|
18
18
|
import { homedir, tmpdir } from "os";
|
|
19
19
|
import { basename, dirname, join, relative, resolve } from "path";
|
|
@@ -28,6 +28,18 @@ const fmtBytes = (n) => n < 1024 ? `${n} B`
|
|
|
28
28
|
: n < 1024 * 1024 ? `${(n / 1024).toFixed(1)} kB` : `${(n / 1024 / 1024).toFixed(1)} MB`;
|
|
29
29
|
const die = (msg) => { console.error(`\n error ${msg}\n`); process.exit(1); };
|
|
30
30
|
|
|
31
|
+
// Status words in color for a person at a terminal; piped output and tests get
|
|
32
|
+
// the plain text, so anything matching on "OK" or "FAIL" is unaffected.
|
|
33
|
+
const COLOR = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
34
|
+
const TRUECOLOR = /truecolor|24bit/i.test(process.env.COLORTERM || "");
|
|
35
|
+
const paintIf = (code) => (s) => COLOR ? `\x1b[${code}m${s}\x1b[0m` : s;
|
|
36
|
+
const emerald = paintIf(TRUECOLOR ? "38;2;89;195;120" : "38;5;78"); // brand emerald #59C378
|
|
37
|
+
const red = paintIf(TRUECOLOR ? "38;2;239;83;80" : "38;5;203");
|
|
38
|
+
const amber = paintIf(TRUECOLOR ? "38;2;230;170;60" : "38;5;179");
|
|
39
|
+
const status = (ok) => ok ? emerald("OK ") : red("FAIL");
|
|
40
|
+
// Paths under the home directory read as ~/..., the way people type them.
|
|
41
|
+
const tilde = (p) => p === homedir() || p.startsWith(homedir() + "/") ? "~" + p.slice(homedir().length) : p;
|
|
42
|
+
|
|
31
43
|
// ---------------------------------------------------------------- source
|
|
32
44
|
|
|
33
45
|
// Accepts: owner/repo | https://github.com/owner/repo | raw .md URL | local path
|
|
@@ -328,6 +340,26 @@ function verify(target, expected) {
|
|
|
328
340
|
return checks;
|
|
329
341
|
}
|
|
330
342
|
|
|
343
|
+
// Reading back the source's files cannot see a file the source no longer has:
|
|
344
|
+
// reinstalling copies over the top and never deletes, so a script dropped from a
|
|
345
|
+
// skill stays on disk and the install still reads as verified.
|
|
346
|
+
//
|
|
347
|
+
// A warning, not a failure, and never a delete: an installed directory can hold
|
|
348
|
+
// files a person or the agent added, and nothing here can tell those from stale
|
|
349
|
+
// ones. A raw .md source knows only SKILL.md, so it cannot judge the rest at all.
|
|
350
|
+
function findLeftovers(destDir, files) {
|
|
351
|
+
if (src.kind === "raw") return [];
|
|
352
|
+
const known = new Set(files.map((f) => f.rel));
|
|
353
|
+
return collectSkillFiles(destDir, "SKILL.md").filter((rel) => !known.has(rel));
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// Names the files as well as the count: a warning you have to re-run to act on
|
|
357
|
+
// is not much of a warning.
|
|
358
|
+
function leftoverLine(destDir, extras) {
|
|
359
|
+
const more = extras.length > 3 ? ` +${extras.length - 3} more` : "";
|
|
360
|
+
return `${tilde(destDir)} ${extras.length} leftover file${extras.length === 1 ? "" : "s"} not in the source: ${extras.slice(0, 3).join(", ")}${more}`;
|
|
361
|
+
}
|
|
362
|
+
|
|
331
363
|
// ---------------------------------------------------------------- per skill
|
|
332
364
|
|
|
333
365
|
// One skill, every target path: scan, disclose, write, read back. Factored out
|
|
@@ -377,7 +409,7 @@ function runSkill(skillPath, root, quiet) {
|
|
|
377
409
|
if (quiet) {
|
|
378
410
|
process.stdout.write(` ${(fm.name || basename(dirname(skillPath))).slice(0, 28).padEnd(30)}`);
|
|
379
411
|
} else {
|
|
380
|
-
console.log(`\n source ${src.label}`);
|
|
412
|
+
console.log(`\n source ${tilde(src.label)}`);
|
|
381
413
|
console.log(` skill ${fm.name || "(no frontmatter name)"} [${files.length} file${files.length === 1 ? "" : "s"}, ${fmtBytes(totalBytes)}, SKILL.md sha ${files[0].hash.slice(0,12)}]`);
|
|
382
414
|
console.log(` from ${skillPath.replace(root, ".")}`);
|
|
383
415
|
}
|
|
@@ -426,7 +458,7 @@ function runSkill(skillPath, root, quiet) {
|
|
|
426
458
|
targetCount++;
|
|
427
459
|
if (dryRun) {
|
|
428
460
|
if (quiet) continue;
|
|
429
|
-
console.log(` would write ${destDir} (${files.length} file${files.length === 1 ? "" : "s"}, ${fmtBytes(totalBytes)})`);
|
|
461
|
+
console.log(` would write ${tilde(destDir)} (${files.length} file${files.length === 1 ? "" : "s"}, ${fmtBytes(totalBytes)})`);
|
|
430
462
|
continue;
|
|
431
463
|
}
|
|
432
464
|
|
|
@@ -456,8 +488,9 @@ function runSkill(skillPath, root, quiet) {
|
|
|
456
488
|
|
|
457
489
|
const absent = badFiles.length === files.length
|
|
458
490
|
&& badFiles.every((b) => b.checks.some((c) => c.name === "file exists" && !c.pass));
|
|
459
|
-
|
|
460
|
-
|
|
491
|
+
const extras = verifyOnly ? findLeftovers(destDir, files) : [];
|
|
492
|
+
baseResults.push({ destDir, badFiles, passed: badFiles.length === 0, absent, extras });
|
|
493
|
+
baseSummaries.push({ destDir, passed: badFiles.length === 0, absent, extras,
|
|
461
494
|
n: files.length - badFiles.length });
|
|
462
495
|
}
|
|
463
496
|
|
|
@@ -477,19 +510,24 @@ function runSkill(skillPath, root, quiet) {
|
|
|
477
510
|
if (!quiet) {
|
|
478
511
|
for (const r of baseResults) {
|
|
479
512
|
const n = files.length - r.badFiles.length;
|
|
513
|
+
const warnLeftovers = () => {
|
|
514
|
+
if (r.extras.length) console.log(` ${amber("WARN")} ${leftoverLine(r.destDir, r.extras)}`);
|
|
515
|
+
};
|
|
480
516
|
// Nothing present at all is one fact, not N failures. Listing every
|
|
481
517
|
// absent file buries the directories that are partially installed,
|
|
482
518
|
// which are the ones worth looking at.
|
|
483
519
|
if (r.absent) {
|
|
484
|
-
console.log(` FAIL ${r.destDir} not installed${verifyOnly ? " (verify only)" : ""}`);
|
|
520
|
+
console.log(` ${red("FAIL")} ${tilde(r.destDir)} not installed${verifyOnly ? " (verify only)" : ""}`);
|
|
521
|
+
warnLeftovers();
|
|
485
522
|
continue;
|
|
486
523
|
}
|
|
487
|
-
console.log(` ${r.passed
|
|
524
|
+
console.log(` ${status(r.passed)} ${tilde(r.destDir)} ${n}/${files.length} file${files.length === 1 ? "" : "s"}${verifyOnly ? " (verify only)" : ""}`);
|
|
488
525
|
for (const b of r.badFiles.slice(0, 10)) {
|
|
489
526
|
console.log(` x ${b.rel}`);
|
|
490
527
|
for (const c of b.checks) if (!c.pass) console.log(` ${c.name}: ${c.detail}`);
|
|
491
528
|
}
|
|
492
529
|
if (r.badFiles.length > 10) console.log(` ... and ${r.badFiles.length - 10} more file(s)`);
|
|
530
|
+
warnLeftovers();
|
|
493
531
|
}
|
|
494
532
|
if (verifyOnly && agentPassed && baseResults.some((r) => !r.passed))
|
|
495
533
|
console.log(` note complete in at least one directory ${a.display} reads; that is an install`);
|
|
@@ -507,14 +545,18 @@ function runSkill(skillPath, root, quiet) {
|
|
|
507
545
|
if (quiet) {
|
|
508
546
|
const nf = `${files.length} file${files.length === 1 ? "" : "s"}`;
|
|
509
547
|
if (dryRun) console.log(`-- ${targetCount} target${targetCount === 1 ? "" : "s"}, ${nf} (dry run)`);
|
|
510
|
-
else console.log(`${skillFailed
|
|
548
|
+
else console.log(`${status(!skillFailed)} ${nf}`);
|
|
511
549
|
// Per directory, not per file. Flattening 3 paths x 148 files into one list
|
|
512
550
|
// buries the only thing that is actionable: which directory is wrong, and how.
|
|
513
551
|
for (const b of baseSummaries.filter((x) => !x.passed)) {
|
|
514
|
-
console.log(` x ${b.destDir} ${b.absent ? "not installed" : `${b.n}/${files.length} files`}`);
|
|
552
|
+
console.log(` x ${tilde(b.destDir)} ${b.absent ? "not installed" : `${b.n}/${files.length} files`}`);
|
|
553
|
+
}
|
|
554
|
+
for (const b of baseSummaries.filter((x) => x.extras.length)) {
|
|
555
|
+
console.log(` ! ${leftoverLine(b.destDir, b.extras)}`);
|
|
515
556
|
}
|
|
516
557
|
}
|
|
517
|
-
|
|
558
|
+
const leftovers = baseSummaries.reduce((n, b) => n + b.extras.length, 0);
|
|
559
|
+
return { name: skillName, fmName: fm.name, failed: skillFailed, skipped: skillSkipped, leftovers };
|
|
518
560
|
}
|
|
519
561
|
|
|
520
562
|
// ---------------------------------------------------------------- discover
|
|
@@ -558,7 +600,7 @@ function discover(agent, names) {
|
|
|
558
600
|
const disabled = found && new RegExp(`(^|\\s)${n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")} \\[Disabled\\]`, "m").test(out);
|
|
559
601
|
const ok = found && !disabled;
|
|
560
602
|
if (!ok) missing++;
|
|
561
|
-
console.log(` ${ok
|
|
603
|
+
console.log(` ${status(ok)} ${n} ${disabled ? "listed but disabled" : found ? "listed" : "not in the skill list of a fresh session"}`);
|
|
562
604
|
}
|
|
563
605
|
if (!a.discover.deterministic)
|
|
564
606
|
console.log(` note ${a.display} has no plain skill listing; this asks the model, so treat a FAIL as a lead, not proof`);
|
|
@@ -567,10 +609,75 @@ function discover(agent, names) {
|
|
|
567
609
|
return missing;
|
|
568
610
|
}
|
|
569
611
|
|
|
612
|
+
// ---------------------------------------------------------------- first run
|
|
613
|
+
|
|
614
|
+
// Shown once per machine, only to a person at a terminal: piped output, CI logs
|
|
615
|
+
// and the test harness never see it. The marker lives beside nothing else we
|
|
616
|
+
// write, and failing to write it never fails an install.
|
|
617
|
+
// Capitals drawn as scanlines: each "▀" is a bar with a dark gap under it.
|
|
618
|
+
const WORDMARK = [
|
|
619
|
+
"▀▀▀▀▀▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀▀▀▀ ▀▀▀ ▀▀ ▀▀▀▀▀▀",
|
|
620
|
+
"▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀▀▀ ▀▀ ▀▀ ▀▀",
|
|
621
|
+
"▀▀▀▀▀▀▀ ▀▀▀▀▀ ▀▀ ▀▀ ▀▀ ▀▀▀▀▀ ▀▀ ▀▀▀▀▀▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀",
|
|
622
|
+
" ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀",
|
|
623
|
+
"▀▀▀▀▀▀▀ ▀▀ ▀▀ ▀▀ ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀ ▀▀ ▀▀ ▀▀ ▀▀▀▀ ▀▀▀▀▀▀",
|
|
624
|
+
];
|
|
625
|
+
|
|
626
|
+
function firstRunBanner() {
|
|
627
|
+
if (!process.stdout.isTTY || process.env.CI) return;
|
|
628
|
+
const dir = join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "skill-land");
|
|
629
|
+
const marker = join(dir, "welcomed");
|
|
630
|
+
if (existsSync(marker)) return;
|
|
631
|
+
try { mkdirSync(dir, { recursive: true }); writeFileSync(marker, new Date().toISOString() + "\n"); }
|
|
632
|
+
catch { return; } // can't remember we showed it, so don't show it on every run
|
|
633
|
+
const color = !process.env.NO_COLOR;
|
|
634
|
+
const fit = (process.stdout.columns || 80) >= 80;
|
|
635
|
+
// Rows fade from light mint at the top to brand emerald #59C378 at the bottom.
|
|
636
|
+
// Without 24-bit color (macOS Terminal sets no COLORTERM) the same fade uses
|
|
637
|
+
// the nearest 256-color steps, ending on 78 (#5FD787).
|
|
638
|
+
const truecolor = /truecolor|24bit/i.test(process.env.COLORTERM || "");
|
|
639
|
+
const TOP = [200, 245, 214], EMERALD = [89, 195, 120];
|
|
640
|
+
const FADE_256 = [194, 158, 121, 114, 78];
|
|
641
|
+
const shade = (r) => !truecolor ? `38;5;${FADE_256[r]}`
|
|
642
|
+
: "38;2;" + TOP.map((t, i) => Math.round(t + (EMERALD[i] - t) * r / (WORDMARK.length - 1))).join(";");
|
|
643
|
+
const paint = (code, s) => color ? `\x1b[${code}m${s}\x1b[0m` : s;
|
|
644
|
+
const green = (s) => paint(shade(WORDMARK.length - 1), s);
|
|
645
|
+
// Tagline in muted off-white (#B4B4AC; 256-color 249) so it reads on dark backgrounds.
|
|
646
|
+
const muted = (s) => paint(truecolor ? "38;2;180;180;172" : "38;5;249", s);
|
|
647
|
+
const dim = (s) => paint("2;" + shade(WORDMARK.length - 1), s);
|
|
648
|
+
const { version } = JSON.parse(readFileSync(join(HERE, "package.json"), "utf-8"));
|
|
649
|
+
console.log();
|
|
650
|
+
if (fit) WORDMARK.forEach((row, r) => console.log(" " + paint(shade(r), row)));
|
|
651
|
+
else console.log(" " + green("SKILL-LAND"));
|
|
652
|
+
console.log("\n " + muted("install skills · where they belong · ") + dim(`v${version}`));
|
|
653
|
+
// Full https:// URL so every terminal, macOS Terminal included, makes it clickable.
|
|
654
|
+
console.log("\n " + muted("made by ") + green("magithar"));
|
|
655
|
+
console.log(" " + muted("contact ") + green("https://x.com/magithar"));
|
|
656
|
+
}
|
|
657
|
+
|
|
570
658
|
// ---------------------------------------------------------------- main
|
|
571
659
|
|
|
572
660
|
const argv = process.argv.slice(2);
|
|
573
|
-
|
|
661
|
+
firstRunBanner();
|
|
662
|
+
// Bare `skill-land` is what a newcomer types first: show the three commands that
|
|
663
|
+
// matter, not the whole option reference.
|
|
664
|
+
if (!argv.length) {
|
|
665
|
+
console.log(`
|
|
666
|
+
Get started
|
|
667
|
+
|
|
668
|
+
1. Pick your agent skill-land --list
|
|
669
|
+
2. Install a skill skill-land owner/repo --for claude-code
|
|
670
|
+
3. Check it landed skill-land owner/repo --for claude-code --verify
|
|
671
|
+
|
|
672
|
+
Every file is copied, then read back. If anything didn't land,
|
|
673
|
+
skill-land says so and exits with an error.
|
|
674
|
+
|
|
675
|
+
All options: skill-land --help
|
|
676
|
+
`);
|
|
677
|
+
process.exit(0);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
if (argv.includes("-h") || argv.includes("--help")) {
|
|
574
681
|
console.log(`
|
|
575
682
|
skill-land <source> --for <agent> [options]
|
|
576
683
|
|
|
@@ -597,12 +704,13 @@ if (!argv.length || argv.includes("-h") || argv.includes("--help")) {
|
|
|
597
704
|
}
|
|
598
705
|
|
|
599
706
|
if (argv.includes("--list")) {
|
|
600
|
-
console.log("\n agent directory
|
|
707
|
+
console.log("\n agent skills directory npx skills");
|
|
601
708
|
console.log(" " + "-".repeat(70));
|
|
602
709
|
for (const [k, a] of Object.entries(AGENTS)) {
|
|
603
|
-
console.log(` ${k.padEnd(17)} ${a.global.padEnd(38)} ${a.broken ? "
|
|
710
|
+
console.log(` ${k.padEnd(17)} ${a.global.padEnd(38)} ${a.broken ? "wrong dir" : "ok"}`);
|
|
604
711
|
}
|
|
605
|
-
console.log();
|
|
712
|
+
console.log("\n wrong dir `npx skills add -a <agent> -g` writes to ~/.agents/skills, which");
|
|
713
|
+
console.log(" this agent never reads. skill-land installs to the directory above.\n");
|
|
606
714
|
process.exit(0);
|
|
607
715
|
}
|
|
608
716
|
|
|
@@ -636,6 +744,7 @@ if (allSkills && values("--skill").length)
|
|
|
636
744
|
const src = resolveSource(source);
|
|
637
745
|
const tmp = mkdtempSync(join(tmpdir(), "skill-install-"));
|
|
638
746
|
let failed = 0;
|
|
747
|
+
let leftovers = 0;
|
|
639
748
|
const skipped = [];
|
|
640
749
|
const landed = [];
|
|
641
750
|
|
|
@@ -651,6 +760,7 @@ try {
|
|
|
651
760
|
for (const skillPath of skillPaths) {
|
|
652
761
|
const r = runSkill(skillPath, root, quiet);
|
|
653
762
|
failed += r.failed;
|
|
763
|
+
leftovers += r.leftovers || 0;
|
|
654
764
|
if (r.skipped) skipped.push(r.name);
|
|
655
765
|
else if (!r.failed) landed.push(r.fmName || r.name);
|
|
656
766
|
}
|
|
@@ -676,8 +786,23 @@ if (discoverFlag && !dryRun) {
|
|
|
676
786
|
}
|
|
677
787
|
}
|
|
678
788
|
|
|
789
|
+
// Printed before the verdict so a green "verified" is not the last word on a
|
|
790
|
+
// directory that holds more than the source does.
|
|
791
|
+
if (leftovers) {
|
|
792
|
+
console.log(` ${amber("warn")} ${leftovers} leftover file${leftovers === 1 ? "" : "s"} not in the source. They may be stale, or added by you or the agent.`);
|
|
793
|
+
console.log(` The agent can still read them. Nothing was removed; review and delete by hand.\n`);
|
|
794
|
+
}
|
|
795
|
+
|
|
679
796
|
if (failed) {
|
|
680
|
-
console.error(` ${failed} install(s) failed verification\n`);
|
|
797
|
+
console.error(` ${red(`✗ ${failed} install(s) failed verification`)}\n`);
|
|
681
798
|
process.exit(1);
|
|
682
799
|
}
|
|
683
|
-
|
|
800
|
+
// Close on the outcome in plain words: what is ready, and for which agent.
|
|
801
|
+
if (!dryRun) {
|
|
802
|
+
const verdict = verifyOnly ? "verified existing install" : "verified";
|
|
803
|
+
const who = targets.map((t) => AGENTS[t].display).join(", ");
|
|
804
|
+
const what = landed.length === 1 ? `${landed[0]} is` : `${landed.length} skills are`;
|
|
805
|
+
console.log(landed.length
|
|
806
|
+
? ` ${emerald(`✓ ${verdict}`)} ${what} ${verifyOnly ? "installed" : "ready"} for ${who}\n`
|
|
807
|
+
: ` ${verdict}\n`);
|
|
808
|
+
}
|