@ichintansoni/skills-master 0.1.3 → 0.1.5
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/dist/bin.js +107 -36
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
// src/bin.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
|
|
6
|
+
// package.json
|
|
7
|
+
var version = "0.1.5";
|
|
8
|
+
|
|
6
9
|
// src/types.ts
|
|
7
10
|
var ALL_TARGETS = ["claude", "cursor", "copilot", "agents"];
|
|
8
11
|
var RESOURCE_FILES = {
|
|
@@ -520,7 +523,7 @@ function loadSkill(dir, skillsRoot) {
|
|
|
520
523
|
}
|
|
521
524
|
|
|
522
525
|
// src/core/registry-build.ts
|
|
523
|
-
function buildRegistry(skillsRoot,
|
|
526
|
+
function buildRegistry(skillsRoot, version2 = "0.1.0") {
|
|
524
527
|
const dirs = findSkillDirs(skillsRoot);
|
|
525
528
|
const skills = dirs.map((dir) => {
|
|
526
529
|
const s = loadSkill(dir, skillsRoot);
|
|
@@ -547,7 +550,7 @@ function buildRegistry(skillsRoot, version = "0.1.0") {
|
|
|
547
550
|
skills.sort((a, b) => a.name.localeCompare(b.name));
|
|
548
551
|
return {
|
|
549
552
|
$schema: "https://skills-master.dev/schema/registry.json",
|
|
550
|
-
version,
|
|
553
|
+
version: version2,
|
|
551
554
|
skills
|
|
552
555
|
};
|
|
553
556
|
}
|
|
@@ -649,8 +652,8 @@ var PREFIX = "skills-master";
|
|
|
649
652
|
function escapeRe(s) {
|
|
650
653
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
651
654
|
}
|
|
652
|
-
function beginMarker(id,
|
|
653
|
-
return
|
|
655
|
+
function beginMarker(id, version2) {
|
|
656
|
+
return version2 ? `<!-- BEGIN ${PREFIX}:${id} v${version2} -->` : `<!-- BEGIN ${PREFIX}:${id} -->`;
|
|
654
657
|
}
|
|
655
658
|
function endMarker(id) {
|
|
656
659
|
return `<!-- END ${PREFIX}:${id} -->`;
|
|
@@ -661,16 +664,16 @@ function blockRegex(id) {
|
|
|
661
664
|
`[ \\t]*<!-- BEGIN ${PREFIX}:${esc}(?: v[^>]*)? -->[\\s\\S]*?<!-- END ${PREFIX}:${esc} -->`
|
|
662
665
|
);
|
|
663
666
|
}
|
|
664
|
-
function renderBlock(id, body,
|
|
665
|
-
return `${beginMarker(id,
|
|
667
|
+
function renderBlock(id, body, version2) {
|
|
668
|
+
return `${beginMarker(id, version2)}
|
|
666
669
|
${body.trim()}
|
|
667
670
|
${endMarker(id)}`;
|
|
668
671
|
}
|
|
669
672
|
function hasBlock(file, id) {
|
|
670
673
|
return blockRegex(id).test(file);
|
|
671
674
|
}
|
|
672
|
-
function upsertBlock(file, id, body,
|
|
673
|
-
const block = renderBlock(id, body,
|
|
675
|
+
function upsertBlock(file, id, body, version2) {
|
|
676
|
+
const block = renderBlock(id, body, version2);
|
|
674
677
|
const re = blockRegex(id);
|
|
675
678
|
if (re.test(file)) {
|
|
676
679
|
return file.replace(re, block);
|
|
@@ -820,12 +823,12 @@ function installSkill(projectRoot, skill, targets, paths, opts = {}) {
|
|
|
820
823
|
const hash = opts.dryRun ? sha256("dry-run", ...whole) : diskHash(projectRoot, whole);
|
|
821
824
|
emitted[c.target] = { files: whole, ...block ? { block } : {}, hash };
|
|
822
825
|
}
|
|
823
|
-
const
|
|
826
|
+
const version2 = skill.frontmatter["x-skills-master"].version;
|
|
824
827
|
return {
|
|
825
828
|
name: skill.name,
|
|
826
|
-
version,
|
|
829
|
+
version: version2,
|
|
827
830
|
results,
|
|
828
|
-
locked: { version, sourceHash: sourceHashOf(skill), emitted }
|
|
831
|
+
locked: { version: version2, sourceHash: sourceHashOf(skill), emitted }
|
|
829
832
|
};
|
|
830
833
|
}
|
|
831
834
|
|
|
@@ -1355,8 +1358,8 @@ async function registryBuildCommand(opts) {
|
|
|
1355
1358
|
}
|
|
1356
1359
|
|
|
1357
1360
|
// src/commands/marketplace.ts
|
|
1358
|
-
import {
|
|
1359
|
-
import { dirname as dirname2, join as join11, resolve as resolve2 } from "path";
|
|
1361
|
+
import { existsSync as existsSync11, readdirSync as readdirSync3, readFileSync as readFileSync9, rmSync as rmSync2 } from "fs";
|
|
1362
|
+
import { dirname as dirname2, join as join11, resolve as resolve2, sep } from "path";
|
|
1360
1363
|
var CLASS_LABEL = {
|
|
1361
1364
|
code: "code skills (frameworks & APIs)",
|
|
1362
1365
|
design: "design-review skills",
|
|
@@ -1369,6 +1372,8 @@ var CLASS_CATEGORY = {
|
|
|
1369
1372
|
"lang-tooling": "development",
|
|
1370
1373
|
overview: "development"
|
|
1371
1374
|
};
|
|
1375
|
+
var PLUGINS_DIR = "plugins";
|
|
1376
|
+
var MARKETPLACE_JSON = ".claude-plugin/marketplace.json";
|
|
1372
1377
|
function pluginName(domain, cls) {
|
|
1373
1378
|
const clsSeg = cls === "overview" ? "overviews" : cls;
|
|
1374
1379
|
return `skills-master-${domain}-${clsSeg}`;
|
|
@@ -1376,10 +1381,20 @@ function pluginName(domain, cls) {
|
|
|
1376
1381
|
function titleCase(s) {
|
|
1377
1382
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
1378
1383
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1384
|
+
function toPosix(p) {
|
|
1385
|
+
return p.split(sep).join("/");
|
|
1386
|
+
}
|
|
1387
|
+
function listFiles(root, dir, acc = []) {
|
|
1388
|
+
const abs = join11(root, dir);
|
|
1389
|
+
if (!existsSync11(abs)) return acc;
|
|
1390
|
+
for (const entry of readdirSync3(abs, { withFileTypes: true })) {
|
|
1391
|
+
const rel = `${dir}/${entry.name}`;
|
|
1392
|
+
if (entry.isDirectory()) listFiles(root, rel, acc);
|
|
1393
|
+
else acc.push(rel);
|
|
1394
|
+
}
|
|
1395
|
+
return acc;
|
|
1396
|
+
}
|
|
1397
|
+
function buildOutputs(content, out, version2) {
|
|
1383
1398
|
const groups = /* @__PURE__ */ new Map();
|
|
1384
1399
|
for (const dir of content.skillDirs()) {
|
|
1385
1400
|
const skill = content.loadSkill(dir.split(/[\\/]/).pop());
|
|
@@ -1389,7 +1404,7 @@ async function marketplaceBuildCommand(opts) {
|
|
|
1389
1404
|
const ctx = {
|
|
1390
1405
|
projectRoot: out,
|
|
1391
1406
|
paths: {
|
|
1392
|
-
claude:
|
|
1407
|
+
claude: `${PLUGINS_DIR}/${name}/skills`,
|
|
1393
1408
|
cursor: "",
|
|
1394
1409
|
copilot: "",
|
|
1395
1410
|
agents: ""
|
|
@@ -1401,38 +1416,87 @@ async function marketplaceBuildCommand(opts) {
|
|
|
1401
1416
|
g.count += 1;
|
|
1402
1417
|
groups.set(key, g);
|
|
1403
1418
|
}
|
|
1419
|
+
const outFiles = /* @__PURE__ */ new Map();
|
|
1420
|
+
const counts = [];
|
|
1404
1421
|
const plugins = [];
|
|
1405
1422
|
for (const { domain, cls, files, count } of groups.values()) {
|
|
1406
1423
|
const name = pluginName(domain, cls);
|
|
1407
|
-
|
|
1424
|
+
for (const f of files) outFiles.set(toPosix(f.path), f.contents);
|
|
1408
1425
|
const description = `${titleCase(domain)} ${CLASS_LABEL[cls]}.`;
|
|
1409
|
-
const pluginDir = join11(out, "plugins", name, ".claude-plugin");
|
|
1410
|
-
mkdirSync2(pluginDir, { recursive: true });
|
|
1411
1426
|
const manifest = {
|
|
1412
1427
|
name,
|
|
1413
|
-
version,
|
|
1428
|
+
version: version2,
|
|
1414
1429
|
description,
|
|
1415
1430
|
author: { name: "skills-master contributors" }
|
|
1416
1431
|
};
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1432
|
+
outFiles.set(
|
|
1433
|
+
`${PLUGINS_DIR}/${name}/.claude-plugin/plugin.json`,
|
|
1434
|
+
JSON.stringify(manifest, null, 2) + "\n"
|
|
1435
|
+
);
|
|
1436
|
+
plugins.push({ name, source: `./${PLUGINS_DIR}/${name}`, description, version: version2, category: CLASS_CATEGORY[cls] });
|
|
1437
|
+
counts.push({ name, count });
|
|
1420
1438
|
}
|
|
1421
1439
|
plugins.sort((a, b) => a.name.localeCompare(b.name));
|
|
1440
|
+
counts.sort((a, b) => a.name.localeCompare(b.name));
|
|
1422
1441
|
const marketplace2 = {
|
|
1423
1442
|
$schema: "https://www.schemastore.org/claude-code-marketplace.json",
|
|
1424
1443
|
name: "skills-master",
|
|
1425
1444
|
owner: { name: "skills-master contributors" },
|
|
1426
1445
|
plugins
|
|
1427
1446
|
};
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1447
|
+
outFiles.set(MARKETPLACE_JSON, JSON.stringify(marketplace2, null, 2) + "\n");
|
|
1448
|
+
return { files: outFiles, counts, pluginCount: plugins.length };
|
|
1449
|
+
}
|
|
1450
|
+
async function marketplaceBuildCommand(opts) {
|
|
1451
|
+
const content = await resolveContent({ content: opts.content, cwd: opts.cwd });
|
|
1452
|
+
const out = resolve2(opts.out ?? dirname2(content.root));
|
|
1453
|
+
const version2 = opts.version ?? "0.1.0";
|
|
1454
|
+
const { files, counts, pluginCount } = buildOutputs(content, out, version2);
|
|
1455
|
+
const onDisk = new Set(listFiles(out, PLUGINS_DIR));
|
|
1456
|
+
if (existsSync11(join11(out, MARKETPLACE_JSON))) onDisk.add(MARKETPLACE_JSON);
|
|
1457
|
+
if (opts.check) {
|
|
1458
|
+
const missing = [];
|
|
1459
|
+
const differing = [];
|
|
1460
|
+
for (const [rel, contents] of files) {
|
|
1461
|
+
if (!onDisk.has(rel)) {
|
|
1462
|
+
missing.push(rel);
|
|
1463
|
+
continue;
|
|
1464
|
+
}
|
|
1465
|
+
if (readFileSync9(join11(out, rel), "utf8") !== contents) differing.push(rel);
|
|
1466
|
+
}
|
|
1467
|
+
const stale2 = [...onDisk].filter((rel) => !files.has(rel)).sort();
|
|
1468
|
+
if (missing.length || differing.length || stale2.length) {
|
|
1469
|
+
log.error(
|
|
1470
|
+
`Marketplace output is out of date (${missing.length} missing, ${differing.length} changed, ${stale2.length} stale) \u2014 run \`pnpm skills:marketplace\` and commit the result.`
|
|
1471
|
+
);
|
|
1472
|
+
for (const rel of missing.sort().slice(0, 10)) log.error(` missing: ${rel}`);
|
|
1473
|
+
for (const rel of differing.sort().slice(0, 10)) log.error(` changed: ${rel}`);
|
|
1474
|
+
for (const rel of stale2.slice(0, 10)) log.error(` stale: ${rel}`);
|
|
1475
|
+
return false;
|
|
1476
|
+
}
|
|
1477
|
+
log.success(`Marketplace output is up to date (${pluginCount} plugins, ${files.size} files).`);
|
|
1478
|
+
return true;
|
|
1479
|
+
}
|
|
1480
|
+
const stale = [...onDisk].filter((rel) => !files.has(rel)).sort();
|
|
1481
|
+
for (const rel of stale) rmSync2(join11(out, rel), { force: true });
|
|
1482
|
+
pruneEmptyDirsUnder(join11(out, PLUGINS_DIR));
|
|
1483
|
+
const emitted = [...files].map(([path, contents]) => ({ path, contents, mode: "whole" }));
|
|
1484
|
+
applyFiles(out, emitted, { overwrite: true });
|
|
1485
|
+
for (const { name, count } of counts) log.info(`Built ${name} (${count} skills).`);
|
|
1486
|
+
if (stale.length) log.info(`Removed ${stale.length} stale file(s).`);
|
|
1487
|
+
log.success(`Wrote ${MARKETPLACE_JSON} (${pluginCount} plugins, ${files.size} files).`);
|
|
1488
|
+
return true;
|
|
1489
|
+
}
|
|
1490
|
+
function pruneEmptyDirsUnder(root) {
|
|
1491
|
+
if (!existsSync11(root)) return;
|
|
1492
|
+
for (const entry of readdirSync3(root, { withFileTypes: true })) {
|
|
1493
|
+
if (entry.isDirectory()) pruneEmptyDirsUnder(join11(root, entry.name));
|
|
1494
|
+
}
|
|
1495
|
+
if (readdirSync3(root).length === 0) rmSync2(root, { recursive: true, force: true });
|
|
1432
1496
|
}
|
|
1433
1497
|
|
|
1434
1498
|
// src/commands/new.ts
|
|
1435
|
-
import { existsSync as
|
|
1499
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
1436
1500
|
import { join as join12 } from "path";
|
|
1437
1501
|
function template(domain, cls, category, name) {
|
|
1438
1502
|
const today2 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
@@ -1494,11 +1558,11 @@ async function newSkillCommand(opts) {
|
|
|
1494
1558
|
const content = await resolveContent({ content: opts.content, cwd: opts.cwd });
|
|
1495
1559
|
const dir = join12(content.root, domain, CLASS_DIR[cls], ...parts.slice(2));
|
|
1496
1560
|
const skillMd = join12(dir, "SKILL.md");
|
|
1497
|
-
if (
|
|
1561
|
+
if (existsSync12(skillMd) && !opts.force) {
|
|
1498
1562
|
throw new Error(`Skill already exists at ${skillMd} (use --force to overwrite).`);
|
|
1499
1563
|
}
|
|
1500
|
-
|
|
1501
|
-
|
|
1564
|
+
mkdirSync2(dir, { recursive: true });
|
|
1565
|
+
writeFileSync5(skillMd, template(domain, cls, category, name), "utf8");
|
|
1502
1566
|
log.success(`Created ${skillMd}`);
|
|
1503
1567
|
return skillMd;
|
|
1504
1568
|
}
|
|
@@ -1526,7 +1590,7 @@ async function run(fn, exitOnFalse = false) {
|
|
|
1526
1590
|
}
|
|
1527
1591
|
}
|
|
1528
1592
|
var program = new Command();
|
|
1529
|
-
program.name("skills-master").description("Install tool-agnostic Apple development skills into any AI coding tool.").version(
|
|
1593
|
+
program.name("skills-master").description("Install tool-agnostic Apple & Android development skills into any AI coding tool.").version(version);
|
|
1530
1594
|
program.command("init").description("Detect tools and write skills-master.json").option("--target <list>", "comma list or 'all'").option("--ref <ref>", "content git ref").option("--no-commit", "gitignore generated files instead of committing them").option("--force", "overwrite an existing config").action(
|
|
1531
1595
|
(opts) => run(
|
|
1532
1596
|
() => initCommand({
|
|
@@ -1604,9 +1668,16 @@ registry.command("build").description("Generate registry.json from the skill tre
|
|
|
1604
1668
|
)
|
|
1605
1669
|
);
|
|
1606
1670
|
var marketplace = program.command("marketplace").description("Claude marketplace maintenance");
|
|
1607
|
-
marketplace.command("build").description("Generate .claude-plugin/marketplace.json and per-class plugins").option("--content <dir>").option("--out <dir>", "output root").option("--version <v>").action(
|
|
1671
|
+
marketplace.command("build").description("Generate .claude-plugin/marketplace.json and per-class plugins").option("--content <dir>").option("--out <dir>", "output root").option("--check", "verify the committed marketplace output is current (CI)").option("--version <v>").action(
|
|
1608
1672
|
(opts) => run(
|
|
1609
|
-
() => marketplaceBuildCommand({
|
|
1673
|
+
() => marketplaceBuildCommand({
|
|
1674
|
+
cwd: process.cwd(),
|
|
1675
|
+
content: opts.content,
|
|
1676
|
+
out: opts.out,
|
|
1677
|
+
check: opts.check,
|
|
1678
|
+
version: opts.version
|
|
1679
|
+
}),
|
|
1680
|
+
true
|
|
1610
1681
|
)
|
|
1611
1682
|
);
|
|
1612
1683
|
program.parseAsync(process.argv);
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bin.ts","../src/types.ts","../src/schema/projectConfig.ts","../src/core/yaml.ts","../src/emitters/util.ts","../src/emitters/claude.ts","../src/core/condense.ts","../src/emitters/cursor.ts","../src/emitters/copilot.ts","../src/emitters/agents.ts","../src/emitters/index.ts","../src/core/project.ts","../src/schema/lockfile.ts","../src/util/log.ts","../src/commands/init.ts","../src/content/source.ts","../src/core/discover.ts","../src/core/parse.ts","../src/schema/frontmatter.ts","../src/core/registry-build.ts","../src/core/install.ts","../src/core/compile.ts","../src/core/writer.ts","../src/core/markers.ts","../src/core/hash.ts","../src/core/gitignore.ts","../src/commands/add.ts","../src/commands/update.ts","../src/commands/remove.ts","../src/commands/doctor.ts","../src/commands/catalog.ts","../src/core/lint.ts","../src/commands/lint.ts","../src/commands/registry.ts","../src/schema/registry.ts","../src/commands/marketplace.ts","../src/commands/new.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { ALL_TARGETS, type TargetId } from \"./types\";\nimport { initCommand } from \"./commands/init\";\nimport { addCommand } from \"./commands/add\";\nimport { updateCommand } from \"./commands/update\";\nimport { removeCommand } from \"./commands/remove\";\nimport { doctorCommand } from \"./commands/doctor\";\nimport { listCommand, searchCommand, viewCommand } from \"./commands/catalog\";\nimport { lintCommand } from \"./commands/lint\";\nimport { registryBuildCommand } from \"./commands/registry\";\nimport { marketplaceBuildCommand } from \"./commands/marketplace\";\nimport { newSkillCommand } from \"./commands/new\";\nimport { log } from \"./util/log\";\n\nconst VALID = new Set<string>(ALL_TARGETS);\n\nfunction parseTargets(value?: string): TargetId[] | undefined {\n if (!value) return undefined;\n if (value === \"all\") return ALL_TARGETS;\n const ids = value.split(\",\").map((s) => s.trim()).filter(Boolean);\n for (const id of ids) {\n if (!VALID.has(id)) {\n throw new Error(`Unknown target \"${id}\". Valid: ${[...VALID, \"all\"].join(\", \")}.`);\n }\n }\n return ids as TargetId[];\n}\n\nasync function run(fn: () => Promise<unknown> | unknown, exitOnFalse = false): Promise<void> {\n try {\n const result = await fn();\n if (exitOnFalse && result === false) process.exitCode = 1;\n } catch (err) {\n log.error(err instanceof Error ? err.message : String(err));\n process.exitCode = 1;\n }\n}\n\nconst program = new Command();\nprogram\n .name(\"skills-master\")\n .description(\"Install tool-agnostic Apple development skills into any AI coding tool.\")\n .version(\"0.1.0\");\n\nprogram\n .command(\"init\")\n .description(\"Detect tools and write skills-master.json\")\n .option(\"--target <list>\", \"comma list or 'all'\")\n .option(\"--ref <ref>\", \"content git ref\")\n .option(\"--no-commit\", \"gitignore generated files instead of committing them\")\n .option(\"--force\", \"overwrite an existing config\")\n .action((opts) =>\n run(() =>\n initCommand({\n cwd: process.cwd(),\n targets: parseTargets(opts.target),\n commit: opts.commit,\n contentRef: opts.ref,\n force: opts.force,\n }),\n ),\n );\n\nprogram\n .command(\"list\")\n .description(\"List available skills\")\n .option(\"--domain <domain>\", \"e.g. apple, android\")\n .option(\"--class <class>\")\n .option(\"--category <category>\")\n .option(\"--platform <platform>\")\n .option(\"--json\")\n .option(\"--content <dir>\", \"local skills directory\")\n .option(\"--ref <ref>\")\n .action((opts) =>\n run(() =>\n listCommand({\n cwd: process.cwd(),\n domain: opts.domain,\n class: opts.class,\n category: opts.category,\n platform: opts.platform,\n json: opts.json,\n content: opts.content,\n ref: opts.ref,\n }),\n ),\n );\n\nprogram\n .command(\"search <query>\")\n .description(\"Search skills by name, description, tags\")\n .option(\"--content <dir>\")\n .option(\"--ref <ref>\")\n .action((query, opts) =>\n run(() => searchCommand({ cwd: process.cwd(), query, content: opts.content, ref: opts.ref })),\n );\n\nprogram\n .command(\"view <name>\")\n .description(\"Show a skill's metadata and body\")\n .option(\"--raw\", \"print the raw SKILL.md body\")\n .option(\"--content <dir>\")\n .option(\"--ref <ref>\")\n .action((name, opts) =>\n run(() =>\n viewCommand({ cwd: process.cwd(), name, raw: opts.raw, content: opts.content, ref: opts.ref }),\n ),\n );\n\nprogram\n .command(\"add <names...>\")\n .description(\"Install skills (by name, category, or class) into your tools\")\n .option(\"--target <list>\", \"comma list or 'all'\")\n .option(\"--with-pairs\", \"also install paired (code<->design) skills\")\n .option(\"--dry-run\", \"preview without writing\")\n .option(\"--overwrite\", \"overwrite changed files without asking\")\n .option(\"--content <dir>\")\n .option(\"--ref <ref>\")\n .action((names, opts) =>\n run(() =>\n addCommand({\n cwd: process.cwd(),\n names,\n targets: parseTargets(opts.target),\n withPairs: opts.withPairs,\n dryRun: opts.dryRun,\n overwrite: opts.overwrite,\n content: opts.content,\n ref: opts.ref,\n }),\n ),\n );\n\nprogram\n .command(\"update [names...]\")\n .description(\"Re-install skills whose content changed\")\n .option(\"--dry-run\")\n .option(\"--overwrite\", \"force re-install, replacing local edits\")\n .option(\"--content <dir>\")\n .option(\"--ref <ref>\")\n .action((names, opts) =>\n run(() =>\n updateCommand({\n cwd: process.cwd(),\n names,\n dryRun: opts.dryRun,\n overwrite: opts.overwrite,\n content: opts.content,\n ref: opts.ref,\n }),\n ),\n );\n\nprogram\n .command(\"remove <names...>\")\n .description(\"Remove installed skills\")\n .option(\"--target <list>\", \"comma list or 'all'\")\n .option(\"--dry-run\")\n .action((names, opts) =>\n run(() =>\n removeCommand({ cwd: process.cwd(), names, targets: parseTargets(opts.target), dryRun: opts.dryRun }),\n ),\n );\n\nprogram\n .command(\"doctor\")\n .description(\"Check installed skills for drift and missing files\")\n .action(() => run(() => doctorCommand({ cwd: process.cwd() })));\n\nprogram\n .command(\"lint\")\n .description(\"Validate the skill library (maintainer command)\")\n .option(\"--content <dir>\")\n .action((opts) => run(() => lintCommand({ cwd: process.cwd(), content: opts.content }), true));\n\nprogram\n .command(\"new <spec>\")\n .description(\"Scaffold a new skill: class/category/name (maintainer command)\")\n .option(\"--content <dir>\")\n .option(\"--force\")\n .action((spec, opts) =>\n run(() => newSkillCommand({ cwd: process.cwd(), spec, content: opts.content, force: opts.force })),\n );\n\nconst registry = program.command(\"registry\").description(\"Registry maintenance\");\nregistry\n .command(\"build\")\n .description(\"Generate registry.json from the skill tree\")\n .option(\"--content <dir>\")\n .option(\"--check\", \"verify the committed registry.json is current (CI)\")\n .option(\"--version <v>\")\n .action((opts) =>\n run(\n () => registryBuildCommand({ cwd: process.cwd(), content: opts.content, check: opts.check, version: opts.version }),\n true,\n ),\n );\n\nconst marketplace = program.command(\"marketplace\").description(\"Claude marketplace maintenance\");\nmarketplace\n .command(\"build\")\n .description(\"Generate .claude-plugin/marketplace.json and per-class plugins\")\n .option(\"--content <dir>\")\n .option(\"--out <dir>\", \"output root\")\n .option(\"--version <v>\")\n .action((opts) =>\n run(() =>\n marketplaceBuildCommand({ cwd: process.cwd(), content: opts.content, out: opts.out, version: opts.version }),\n ),\n );\n\nprogram.parseAsync(process.argv);\n","/**\n * Shared types for the skills-master compiler.\n *\n * The canonical authored unit is a *skill*: a directory containing a `SKILL.md`\n * (frontmatter + body) plus optional on-demand resource files. An *emitter*\n * projects a parsed skill into the files a particular AI tool expects.\n */\n\nimport type { Frontmatter } from \"./schema/frontmatter\";\n\nexport type { Frontmatter } from \"./schema/frontmatter\";\n\n/** The four AI-tool targets shipped at launch. */\nexport type TargetId = \"claude\" | \"cursor\" | \"copilot\" | \"agents\";\n\nexport const ALL_TARGETS: TargetId[] = [\"claude\", \"cursor\", \"copilot\", \"agents\"];\n\n/** On-demand \"Level 3\" resource files that may sit beside a SKILL.md. */\nexport interface SkillResources {\n reference?: string;\n examples?: string;\n checklist?: string;\n}\n\nexport const RESOURCE_FILES = {\n reference: \"reference.md\",\n examples: \"examples.md\",\n checklist: \"checklist.md\",\n} as const;\n\nexport type ResourceKey = keyof typeof RESOURCE_FILES;\n\n/** A skill after its SKILL.md and resource files have been read and validated. */\nexport interface ParsedSkill {\n /** kebab-case name; equals the leaf folder name. */\n name: string;\n /** absolute path to the skill's source directory. */\n dir: string;\n /** path relative to the skills root, e.g. `code/app-frameworks/swiftdata-modeling`. */\n relPath: string;\n /** validated, normalized frontmatter. */\n frontmatter: Frontmatter;\n /** markdown body (everything after the frontmatter). */\n body: string;\n /** raw text of any present resource files. */\n resources: SkillResources;\n}\n\n/**\n * Output file modes:\n * - `whole` — the emitter owns the entire file (overwrite as a unit).\n * - `block` — the emitter owns only a marked region inside a shared file.\n */\nexport type FileMode = \"whole\" | \"block\";\n\nexport interface EmittedFile {\n /** path relative to the consuming project root. */\n path: string;\n /** for `whole`: the full file contents. for `block`: the managed region body. */\n contents: string;\n mode: FileMode;\n /** required for `block` mode — identifies the managed region (usually the skill name). */\n blockId?: string;\n /** for `block` mode — written into the BEGIN marker for drift detection. */\n blockVersion?: string;\n}\n\nexport interface EmitContext {\n /** absolute path to the consuming project root. */\n projectRoot: string;\n /** effective per-target output paths (already merged with defaults). */\n paths: Record<TargetId, string>;\n}\n\nexport interface Emitter {\n id: TargetId | (string & {});\n /** human label for logs. */\n label: string;\n /** detect whether this tool is present in a project (used by auto-detect). */\n detect(projectRoot: string): boolean;\n /** project a skill into target files. */\n emit(skill: ParsedSkill, ctx: EmitContext): EmittedFile[];\n}\n\n/** Result of applying a single EmittedFile to disk. */\nexport type WriteAction = \"created\" | \"updated\" | \"unchanged\" | \"skipped\";\n\nexport interface WriteResult {\n path: string;\n mode: FileMode;\n blockId?: string;\n action: WriteAction;\n}\n","import { z } from \"zod\";\nimport type { TargetId } from \"../types\";\n\nexport const TargetIdSchema = z.enum([\"claude\", \"cursor\", \"copilot\", \"agents\"]);\n\n/** Default output location per target, relative to the project root. */\nexport const DEFAULT_PATHS: Record<TargetId, string> = {\n claude: \".claude/skills\",\n cursor: \".cursor/rules\",\n copilot: \".github\",\n agents: \"AGENTS.md\",\n};\n\nexport const ProjectConfigSchema = z\n .object({\n $schema: z.string().optional(),\n /** Git ref of the content repo to install from (tag/branch/sha). */\n contentRef: z.string().default(\"main\"),\n /**\n * Targets to emit. Empty array means \"auto-detect on every run\".\n */\n targets: z.array(TargetIdSchema).default([]),\n /** Per-target output path overrides (merged over DEFAULT_PATHS). */\n paths: z\n .object({\n claude: z.string(),\n cursor: z.string(),\n copilot: z.string(),\n agents: z.string(),\n })\n .partial()\n .default({}),\n scope: z.enum([\"project\"]).default(\"project\"),\n /** true = commit generated files; false = add them to .gitignore. */\n commit: z.boolean().default(true),\n })\n .strict();\n\nexport type ProjectConfig = z.infer<typeof ProjectConfigSchema>;\n\nexport const CONFIG_FILENAME = \"skills-master.json\";\nexport const LOCKFILE_NAME = \"skills-master.lock.json\";\n\n/** Resolve effective output paths by merging overrides over the defaults. */\nexport function resolvePaths(cfg: ProjectConfig): Record<TargetId, string> {\n return { ...DEFAULT_PATHS, ...cfg.paths } as Record<TargetId, string>;\n}\n","import YAML from \"yaml\";\n\n/**\n * Serialize a frontmatter object to a deterministic YAML block (no `---` fences).\n * Insertion order of keys is preserved, so emitters control field order.\n * Long strings are not wrapped (lineWidth: 0), keeping descriptions on one line.\n */\nexport function toYaml(obj: Record<string, unknown>): string {\n return YAML.stringify(obj, { lineWidth: 0 }).trimEnd();\n}\n\n/** Wrap a YAML block in `---` fences for embedding at the top of a Markdown file. */\nexport function frontmatterBlock(obj: Record<string, unknown>): string {\n return `---\\n${toYaml(obj)}\\n---`;\n}\n\n/**\n * Build a full Markdown document from a frontmatter object and a body.\n * Guarantees exactly one blank line between the frontmatter and the body.\n */\nexport function withFrontmatter(obj: Record<string, unknown>, body: string): string {\n return `${frontmatterBlock(obj)}\\n\\n${body.trim()}\\n`;\n}\n","import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { Frontmatter } from \"../schema/frontmatter\";\n\n/** True when `rel` exists under the project root (used for tool auto-detection). */\nexport function existsRel(root: string, rel: string): boolean {\n return existsSync(join(root, rel));\n}\n\nconst ACRONYMS: Record<string, string> = {\n hig: \"HIG\",\n ui: \"UI\",\n ml: \"ML\",\n ar: \"AR\",\n av: \"AV\",\n os: \"OS\",\n ci: \"CI\",\n cd: \"CD\",\n url: \"URL\",\n api: \"API\",\n sf: \"SF\",\n spm: \"SPM\",\n ios: \"iOS\",\n ipados: \"iPadOS\",\n macos: \"macOS\",\n tvos: \"tvOS\",\n visionos: \"visionOS\",\n watchos: \"watchOS\",\n};\n\n/** Human title derived from a kebab-case skill name (e.g. \"hig-sheets\" → \"HIG Sheets\"). */\nexport function titleFromName(name: string): string {\n return name\n .split(\"-\")\n .filter(Boolean)\n .map((w) => ACRONYMS[w] ?? w.charAt(0).toUpperCase() + w.slice(1))\n .join(\" \");\n}\n\n/** Comma-join a skill's globs, or undefined if it declares none. */\nexport function globsToString(fm: Frontmatter): string | undefined {\n const g = fm.globs;\n if (!g || g.length === 0) return undefined;\n return g.join(\",\");\n}\n\n/** True when the skill ships any on-demand resource files. */\nexport function hasResources(resources: {\n reference?: string;\n examples?: string;\n checklist?: string;\n}): boolean {\n return Boolean(resources.reference || resources.examples || resources.checklist);\n}\n","import { RESOURCE_FILES, type Emitter, type EmittedFile, type ResourceKey } from \"../types\";\nimport { withFrontmatter } from \"../core/yaml\";\nimport { existsRel } from \"./util\";\n\n/**\n * Claude Code emitter — the lossless, native projection.\n * Writes `.claude/skills/<name>/SKILL.md` plus verbatim copies of any resource\n * files, preserving progressive disclosure. The `x-skills-master` block is\n * dropped; the body (including links to resource files, which are co-located)\n * is kept exactly.\n */\nexport const claudeEmitter: Emitter = {\n id: \"claude\",\n label: \"Claude Code\",\n detect: (root) => existsRel(root, \".claude\"),\n emit(skill, ctx): EmittedFile[] {\n const dir = `${ctx.paths.claude}/${skill.name}`;\n const fm = {\n name: skill.frontmatter.name,\n description: skill.frontmatter.description,\n };\n const files: EmittedFile[] = [\n {\n path: `${dir}/SKILL.md`,\n contents: withFrontmatter(fm, skill.body),\n mode: \"whole\",\n },\n ];\n for (const key of Object.keys(RESOURCE_FILES) as ResourceKey[]) {\n const text = skill.resources[key];\n if (text) {\n files.push({\n path: `${dir}/${RESOURCE_FILES[key]}`,\n contents: text.trimEnd() + \"\\n\",\n mode: \"whole\",\n });\n }\n }\n return files;\n },\n};\n","/**\n * Condense a canonical SKILL.md body for single-file targets (Cursor, Copilot,\n * AGENTS.md) that cannot carry on-demand resource files.\n *\n * - Links to reference.md / examples.md / checklist.md are flattened to plain\n * text and a one-line pointer to the full skill is appended (\"drop-and-note\").\n * - The `## Open question` section can optionally be summarized to a single\n * tradeoff line for terse targets.\n */\n\n// The character classes deliberately exclude their own delimiters and newlines.\n// A link-text class of [^\\]]+ can match \"[\", which makes every \"[\" an overlapping\n// restart position and the whole scan quadratic on adversarial input\n// (CodeQL js/polynomial-redos). Excluding \"[\" keeps restarts disjoint, so\n// matching stays linear. Markdown link text may not span lines here either.\nconst L3_LINK_RE =\n /\\[([^\\][\\n]+)\\]\\((?:\\.\\/)?(reference|examples|checklist)\\.md(?:#[^()\\n]*)?\\)/g;\n\nexport interface CondenseOptions {\n /** \"keep\" (default) leaves the section intact; \"summarize\" collapses it. */\n openQuestion?: \"keep\" | \"summarize\";\n /** whether the source skill had any resource files (drives the pointer note). */\n hadResources?: boolean;\n /** how to refer to the full skill in the appended note. */\n fullSkillNote?: string;\n}\n\nconst DEFAULT_NOTE =\n \"Extended reference and worked examples are available in the full Claude Code skill for this topic.\";\n\nexport function condenseBody(body: string, opts: CondenseOptions = {}): string {\n let out = body;\n let strippedLink = false;\n\n out = out.replace(L3_LINK_RE, (_m, text: string) => {\n strippedLink = true;\n return text;\n });\n\n if (opts.openQuestion === \"summarize\") {\n out = summarizeOpenQuestion(out);\n }\n\n out = out.replace(/\\n{3,}/g, \"\\n\\n\").trim();\n\n if (opts.hadResources || strippedLink) {\n out += `\\n\\n> ${opts.fullSkillNote ?? DEFAULT_NOTE}`;\n }\n\n return out + \"\\n\";\n}\n\nfunction summarizeOpenQuestion(body: string): string {\n const re = /^## Open question[ \\t]*\\n([\\s\\S]*?)(?=\\n## |\\s*$)/m;\n return body.replace(re, (_m, section: string) => {\n const firstPara = section.trim().split(/\\n\\s*\\n/)[0]?.replace(/\\s+/g, \" \").trim() ?? \"\";\n return `## Open question\\n\\nTradeoff: ${firstPara}\\n`;\n });\n}\n","import { type Emitter, type EmittedFile } from \"../types\";\nimport { withFrontmatter } from \"../core/yaml\";\nimport { condenseBody } from \"../core/condense\";\nimport { existsRel, globsToString, hasResources } from \"./util\";\n\n/**\n * Cursor emitter — `.cursor/rules/<name>.mdc`, a single file.\n * Frontmatter is exactly the three fields Cursor understands:\n * - `globs` present → Auto-Attached rule\n * - `globs` absent → Agent-Requested rule (description-driven)\n * A skills library never sets `alwaysApply: true` (that would inject every\n * skill into every chat).\n */\nexport const cursorEmitter: Emitter = {\n id: \"cursor\",\n label: \"Cursor\",\n detect: (root) => existsRel(root, \".cursor\"),\n emit(skill, ctx): EmittedFile[] {\n const globs = globsToString(skill.frontmatter);\n const fm: Record<string, unknown> = {\n description: skill.frontmatter.description,\n };\n if (globs) fm.globs = globs;\n fm.alwaysApply = false;\n\n const body = condenseBody(skill.body, {\n openQuestion: \"keep\",\n hadResources: hasResources(skill.resources),\n });\n\n return [\n {\n path: `${ctx.paths.cursor}/${skill.name}.mdc`,\n contents: withFrontmatter(fm, body),\n mode: \"whole\",\n },\n ];\n },\n};\n","import { type Emitter, type EmittedFile } from \"../types\";\nimport { withFrontmatter } from \"../core/yaml\";\nimport { condenseBody } from \"../core/condense\";\nimport { existsRel, globsToString, hasResources, titleFromName } from \"./util\";\n\n/**\n * GitHub Copilot emitter — two outputs:\n * 1. `.github/instructions/<name>.instructions.md` (whole file) with the\n * required `applyTo` glob and the condensed body.\n * 2. a one-line pointer block in `.github/copilot-instructions.md` (managed\n * via sentinel markers) so the always-loaded root file stays small.\n */\nexport const copilotEmitter: Emitter = {\n id: \"copilot\",\n label: \"GitHub Copilot\",\n detect: (root) => existsRel(root, \".github\"),\n emit(skill, ctx): EmittedFile[] {\n const base = ctx.paths.copilot; // e.g. \".github\"\n const instructionsPath = `${base}/instructions/${skill.name}.instructions.md`;\n const applyTo = globsToString(skill.frontmatter) ?? \"**\";\n\n const fm = {\n applyTo,\n description: skill.frontmatter.description,\n };\n const body = condenseBody(skill.body, {\n openQuestion: \"keep\",\n hadResources: hasResources(skill.resources),\n });\n\n const pointer = `For ${titleFromName(skill.name)} guidance, see \\`${instructionsPath}\\`.`;\n\n return [\n {\n path: instructionsPath,\n contents: withFrontmatter(fm, body),\n mode: \"whole\",\n },\n {\n path: `${base}/copilot-instructions.md`,\n contents: pointer,\n mode: \"block\",\n blockId: skill.name,\n blockVersion: skill.frontmatter[\"x-skills-master\"].version,\n },\n ];\n },\n};\n","import { type Emitter, type EmittedFile } from \"../types\";\nimport { condenseBody } from \"../core/condense\";\nimport { existsRel, hasResources, titleFromName } from \"./util\";\n\n/**\n * AGENTS.md emitter — the broad cross-tool standard. Plain Markdown, no\n * frontmatter (per the spec). Each skill becomes a `###` section inside a\n * sentinel-managed block so installs compose and updates stay surgical.\n * Bodies are summarized aggressively (this file is read in full by many tools).\n */\nexport const agentsEmitter: Emitter = {\n id: \"agents\",\n label: \"AGENTS.md\",\n detect: (root) => existsRel(root, \"AGENTS.md\"),\n emit(skill, ctx): EmittedFile[] {\n const body = condenseBody(skill.body, {\n openQuestion: \"summarize\",\n hadResources: hasResources(skill.resources),\n });\n const section = `### ${titleFromName(skill.name)}\\n\\n${body.trim()}`;\n return [\n {\n path: ctx.paths.agents,\n contents: section,\n mode: \"block\",\n blockId: skill.name,\n blockVersion: skill.frontmatter[\"x-skills-master\"].version,\n },\n ];\n },\n};\n","import type { Emitter, TargetId } from \"../types\";\nimport { claudeEmitter } from \"./claude\";\nimport { cursorEmitter } from \"./cursor\";\nimport { copilotEmitter } from \"./copilot\";\nimport { agentsEmitter } from \"./agents\";\n\n/**\n * The emitter registry. Adding support for a new tool (Windsurf, Cline, …) is a\n * one-line change here plus a new emitter file — the rest of the pipeline is\n * generic over the `Emitter` interface.\n */\nexport const EMITTERS: Emitter[] = [\n claudeEmitter,\n cursorEmitter,\n copilotEmitter,\n agentsEmitter,\n];\n\nconst BY_ID = new Map<string, Emitter>(EMITTERS.map((e) => [e.id, e]));\n\nexport function getEmitter(id: string): Emitter | undefined {\n return BY_ID.get(id);\n}\n\n/** Detect which targets are present in a project. */\nexport function detectTargets(projectRoot: string): TargetId[] {\n return EMITTERS.filter((e) => e.detect(projectRoot)).map((e) => e.id as TargetId);\n}\n\nexport { claudeEmitter, cursorEmitter, copilotEmitter, agentsEmitter };\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n CONFIG_FILENAME,\n LOCKFILE_NAME,\n ProjectConfigSchema,\n type ProjectConfig,\n} from \"../schema/projectConfig\";\nimport { LockfileSchema, emptyLockfile, type Lockfile } from \"../schema/lockfile\";\n\nexport function configPath(root: string): string {\n return join(root, CONFIG_FILENAME);\n}\nexport function lockfilePath(root: string): string {\n return join(root, LOCKFILE_NAME);\n}\n\nexport function loadConfig(root: string): ProjectConfig | null {\n const p = configPath(root);\n if (!existsSync(p)) return null;\n return ProjectConfigSchema.parse(JSON.parse(readFileSync(p, \"utf8\")));\n}\n\n/** Load config, or return parsed defaults if none exists. */\nexport function loadConfigOrDefault(root: string): ProjectConfig {\n return loadConfig(root) ?? ProjectConfigSchema.parse({});\n}\n\nexport function saveConfig(root: string, cfg: ProjectConfig): void {\n const withSchema = { $schema: \"https://skills-master.dev/schema/config.json\", ...cfg };\n writeFileSync(configPath(root), JSON.stringify(withSchema, null, 2) + \"\\n\", \"utf8\");\n}\n\nexport function loadLockfile(root: string): Lockfile {\n const p = lockfilePath(root);\n if (!existsSync(p)) return emptyLockfile();\n return LockfileSchema.parse(JSON.parse(readFileSync(p, \"utf8\")));\n}\n\nexport function saveLockfile(root: string, lock: Lockfile): void {\n writeFileSync(lockfilePath(root), JSON.stringify(lock, null, 2) + \"\\n\", \"utf8\");\n}\n","import { z } from \"zod\";\n\n/** Records, per target, which files an install produced and their content hash. */\nexport const EmittedTargetSchema = z.object({\n /** whole-file outputs owned by this target for this skill. */\n files: z.array(z.string()).default([]),\n /** shared file this skill writes a managed block into (block-mode targets). */\n block: z.string().optional(),\n /** sha256 of the concatenated emitted contents, for drift detection. */\n hash: z.string(),\n});\n\nexport const LockedSkillSchema = z.object({\n /** resolved skill version at install time. */\n version: z.string(),\n /** sha256 of the canonical SKILL.md + resource files at install time. */\n sourceHash: z.string(),\n /** targets this skill was emitted to. */\n emitted: z.record(z.string(), EmittedTargetSchema),\n});\n\nexport const LockfileSchema = z.object({\n lockfileVersion: z.literal(1).default(1),\n contentRef: z.string().default(\"main\"),\n skills: z.record(z.string(), LockedSkillSchema).default({}),\n});\n\nexport type EmittedTarget = z.infer<typeof EmittedTargetSchema>;\nexport type LockedSkill = z.infer<typeof LockedSkillSchema>;\nexport type Lockfile = z.infer<typeof LockfileSchema>;\n\nexport function emptyLockfile(contentRef = \"main\"): Lockfile {\n return { lockfileVersion: 1, contentRef, skills: {} };\n}\n","/* Minimal, dependency-free logger so core modules don't couple to a prompt lib. */\n\nlet quiet = false;\nexport function setQuiet(v: boolean): void {\n quiet = v;\n}\n\nconst sym = {\n info: \"•\",\n ok: \"✓\",\n warn: \"!\",\n err: \"✗\",\n};\n\nexport const log = {\n plain(msg: string): void {\n if (!quiet) console.log(msg);\n },\n info(msg: string): void {\n if (!quiet) console.log(`${sym.info} ${msg}`);\n },\n success(msg: string): void {\n if (!quiet) console.log(`${sym.ok} ${msg}`);\n },\n warn(msg: string): void {\n if (!quiet) console.warn(`${sym.warn} ${msg}`);\n },\n error(msg: string): void {\n console.error(`${sym.err} ${msg}`);\n },\n};\n","import { ProjectConfigSchema, type ProjectConfig } from \"../schema/projectConfig\";\nimport { ALL_TARGETS, type TargetId } from \"../types\";\nimport { detectTargets } from \"../emitters\";\nimport { loadConfig, saveConfig } from \"../core/project\";\nimport { log } from \"../util/log\";\n\nexport interface InitOptions {\n cwd: string;\n /** explicit target set; if omitted, auto-detect (falling back to all). */\n targets?: TargetId[];\n commit?: boolean;\n contentRef?: string;\n force?: boolean;\n}\n\nexport function initCommand(opts: InitOptions): ProjectConfig {\n const existing = loadConfig(opts.cwd);\n if (existing && !opts.force) {\n log.warn(`skills-master.json already exists — leaving it untouched (use --force to overwrite).`);\n return existing;\n }\n\n let targets = opts.targets;\n if (!targets || targets.length === 0) {\n const detected = detectTargets(opts.cwd);\n if (detected.length > 0) {\n targets = detected;\n log.info(`Detected tools: ${detected.join(\", \")}`);\n } else {\n targets = ALL_TARGETS;\n log.info(`No tools detected — defaulting to all targets (${ALL_TARGETS.join(\", \")}).`);\n }\n }\n\n const cfg = ProjectConfigSchema.parse({\n contentRef: opts.contentRef ?? \"main\",\n targets,\n commit: opts.commit ?? true,\n });\n saveConfig(opts.cwd, cfg);\n log.success(`Wrote skills-master.json (targets: ${targets.join(\", \")}, commit: ${cfg.commit}).`);\n return cfg;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { basename, isAbsolute, join, resolve } from \"node:path\";\nimport { findSkillDirs } from \"../core/discover\";\nimport { loadSkill } from \"../core/parse\";\nimport { buildRegistry } from \"../core/registry-build\";\nimport type { Registry } from \"../schema/registry\";\nimport type { ParsedSkill } from \"../types\";\n\n/** Default content repo (override with SKILLS_MASTER_REPO). */\nconst DEFAULT_REPO = \"github:iChintanSoni/skills-master\";\n\n/** package.json `name` that identifies the skills-master content repo (dev checkout). */\nconst CONTENT_REPO_PACKAGE = \"skills-master-monorepo\";\n\n/** A resolved, on-disk skills tree the CLI reads from. */\nexport class ContentSource {\n constructor(public readonly root: string) {}\n\n skillDirs(): string[] {\n return findSkillDirs(this.root);\n }\n\n findDir(name: string): string | undefined {\n const dirs = this.skillDirs();\n return dirs.find((d) => basename(d) === name) ?? dirs.find((d) => safeName(d, this.root) === name);\n }\n\n loadSkill(name: string): ParsedSkill {\n const dir = this.findDir(name);\n if (!dir) throw new Error(`Skill \"${name}\" not found in content at ${this.root}`);\n return loadSkill(dir, this.root);\n }\n\n registry(): Registry {\n return buildRegistry(this.root);\n }\n}\n\nfunction safeName(dir: string, root: string): string {\n try {\n return loadSkill(dir, root).name;\n } catch {\n return \"\";\n }\n}\n\nexport interface ResolveContentOptions {\n /** explicit path to a local skills directory. */\n content?: string;\n /** git ref for remote fetch. */\n ref?: string;\n /** start dir for the upward repo search. */\n cwd?: string;\n}\n\n/**\n * Resolve where skill content lives, in priority order:\n * 1. explicit `--content <dir>`\n * 2. SKILLS_MASTER_CONTENT env var\n * 3. the skills-master content repo, if running inside it (dev convenience, searched upward)\n * 4. remote fetch via giget (published content)\n */\nexport async function resolveContent(opts: ResolveContentOptions = {}): Promise<ContentSource> {\n if (opts.content) {\n const root = isAbsolute(opts.content) ? opts.content : resolve(process.cwd(), opts.content);\n return new ContentSource(root);\n }\n const env = process.env.SKILLS_MASTER_CONTENT;\n if (env) return new ContentSource(resolve(env));\n\n const local = findLocalSkillsDir(opts.cwd ?? process.cwd());\n if (local) return new ContentSource(local);\n\n return new ContentSource(await fetchRemote(opts.ref ?? \"main\"));\n}\n\n/**\n * Walk upward looking for the skills-master content repo: a root whose\n * `package.json` name is {@link CONTENT_REPO_PACKAGE} and that has a `skills/`\n * subtree. Keying on the package name (not just any pnpm workspace with a\n * `skills/` dir) keeps an unrelated monorepo from hijacking content resolution.\n */\nfunction findLocalSkillsDir(start: string): string | null {\n let dir = resolve(start);\n for (let i = 0; i < 8; i++) {\n const candidate = join(dir, \"skills\");\n if (existsSync(candidate) && isContentRepoRoot(dir)) return candidate;\n const parent = resolve(dir, \"..\");\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/** True when `dir` is the skills-master monorepo root (by package.json name). */\nfunction isContentRepoRoot(dir: string): boolean {\n try {\n const pkg = JSON.parse(readFileSync(join(dir, \"package.json\"), \"utf8\")) as { name?: string };\n return pkg.name === CONTENT_REPO_PACKAGE;\n } catch {\n return false;\n }\n}\n\n/** Download the `skills/` subtree of the content repo to a local cache. */\nasync function fetchRemote(ref: string): Promise<string> {\n const repo = process.env.SKILLS_MASTER_REPO ?? DEFAULT_REPO;\n const cacheDir = join(homedir(), \".skills-master-cache\", ref.replace(/[^\\w.-]/g, \"_\"));\n const { downloadTemplate } = await import(\"giget\");\n const { dir } = await downloadTemplate(`${repo}/skills#${ref}`, {\n dir: cacheDir,\n force: true,\n forceClean: true,\n });\n return dir;\n}\n","import { existsSync, readdirSync, statSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\n\nconst SKILL_FILE = \"SKILL.md\";\nconst IGNORE = new Set([\"node_modules\", \".git\", \"dist\", \".cache\"]);\n\n/**\n * Recursively find every directory under `skillsRoot` that contains a SKILL.md.\n * Returns absolute directory paths, sorted for deterministic output.\n */\nexport function findSkillDirs(skillsRoot: string): string[] {\n const found: string[] = [];\n if (!existsSync(skillsRoot)) return found;\n\n const walk = (dir: string): void => {\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n if (entries.includes(SKILL_FILE)) found.push(dir);\n for (const entry of entries) {\n if (IGNORE.has(entry) || entry.startsWith(\".\")) continue;\n const full = join(dir, entry);\n let isDir = false;\n try {\n isDir = statSync(full).isDirectory();\n } catch {\n isDir = false;\n }\n if (isDir) walk(full);\n }\n };\n\n walk(skillsRoot);\n return found.sort();\n}\n\n/** Path of a skill dir relative to the skills root (uses forward slashes). */\nexport function relPathOf(skillsRoot: string, dir: string): string {\n return relative(skillsRoot, dir).split(/[\\\\/]/).join(\"/\");\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport matter from \"gray-matter\";\nimport { FrontmatterSchema, type Frontmatter } from \"../schema/frontmatter\";\nimport {\n RESOURCE_FILES,\n type ParsedSkill,\n type ResourceKey,\n type SkillResources,\n} from \"../types\";\nimport { relPathOf } from \"./discover\";\n\nexport interface RawSkill {\n dir: string;\n relPath: string;\n /** leaf folder name (the expected `name`). */\n folderName: string;\n /** unvalidated frontmatter object. */\n data: Record<string, unknown>;\n body: string;\n resources: SkillResources;\n skillMdPath: string;\n /** full unparsed SKILL.md text (used for YAML-hazard linting). */\n rawText: string;\n}\n\n/** Read a skill directory's SKILL.md and resource files without validating. */\nexport function loadRawSkill(dir: string, skillsRoot: string): RawSkill {\n const skillMdPath = join(dir, \"SKILL.md\");\n const rawText = readFileSync(skillMdPath, \"utf8\");\n const parsed = matter(rawText);\n\n const resources: SkillResources = {};\n for (const key of Object.keys(RESOURCE_FILES) as ResourceKey[]) {\n const p = join(dir, RESOURCE_FILES[key]);\n if (existsSync(p)) resources[key] = readFileSync(p, \"utf8\");\n }\n\n return {\n dir,\n relPath: relPathOf(skillsRoot, dir),\n folderName: basename(dir),\n data: parsed.data as Record<string, unknown>,\n body: parsed.content.replace(/^\\n+/, \"\").trimEnd(),\n resources,\n skillMdPath,\n rawText,\n };\n}\n\nexport class SkillValidationError extends Error {\n constructor(\n public readonly relPath: string,\n public readonly issues: string[],\n ) {\n super(`Invalid skill \"${relPath}\":\\n - ${issues.join(\"\\n - \")}`);\n this.name = \"SkillValidationError\";\n }\n}\n\n/** Validate raw frontmatter; returns the typed frontmatter or a list of issues. */\nexport function validateFrontmatter(\n data: Record<string, unknown>,\n): { ok: true; value: Frontmatter } | { ok: false; issues: string[] } {\n const result = FrontmatterSchema.safeParse(data);\n if (result.success) return { ok: true, value: result.data };\n const issues = result.error.issues.map((i) => {\n const path = i.path.join(\".\");\n return path ? `${path}: ${i.message}` : i.message;\n });\n return { ok: false, issues };\n}\n\n/** Load and validate a skill directory into a ParsedSkill (throws on failure). */\nexport function loadSkill(dir: string, skillsRoot: string): ParsedSkill {\n const raw = loadRawSkill(dir, skillsRoot);\n const validated = validateFrontmatter(raw.data);\n if (!validated.ok) throw new SkillValidationError(raw.relPath, validated.issues);\n return {\n name: validated.value.name,\n dir: raw.dir,\n relPath: raw.relPath,\n frontmatter: validated.value,\n body: raw.body,\n resources: raw.resources,\n };\n}\n","import { z } from \"zod\";\nimport semver from \"semver\";\n\n/** kebab-case, used for skill `name` and `pairs_with` references. */\nexport const NAME_RE = /^[a-z0-9-]{1,64}$/;\nexport const ISO_DATE_RE = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nexport const StabilitySchema = z.enum([\"stable\", \"emerging\", \"contested\"]);\nexport type Stability = z.infer<typeof StabilitySchema>;\n\n/**\n * Skill classes are reusable across domains (Apple, Android, web, …):\n * - code → produces compilable code\n * - design → produces UX/design critique (e.g. Apple HIG, Material)\n * - lang-tooling → cross-cutting language/build/test/ship guidance\n * - overview → decision-guidance routers\n */\nexport const SkillClassSchema = z.enum([\n \"code\",\n \"design\",\n \"lang-tooling\",\n \"overview\",\n]);\nexport type SkillClass = z.infer<typeof SkillClassSchema>;\n\n/** Maps a skill `class` to its directory name within a domain in `skills/<domain>/`. */\nexport const CLASS_DIR: Record<SkillClass, string> = {\n code: \"code\",\n design: \"design\",\n \"lang-tooling\": \"lang-tooling\",\n overview: \"overviews\",\n};\n\n/**\n * Our private metadata block. Stripped from every projected output.\n * Domain-agnostic by design: `domain` namespaces a technology ecosystem\n * (apple, android, web, …); `platforms` and `requires` are free-form so each\n * domain defines its own vocabulary (ios/android/wear-os; {ios:\"17\"} / {android:\"14\"}).\n */\nexport const XSkillsMasterSchema = z\n .object({\n domain: z.string().min(1),\n class: SkillClassSchema,\n category: z.string().min(1),\n platforms: z.array(z.string().min(1)).min(1),\n /** domain-defined version requirements, e.g. { ios: \"17\", swift: \"6.0\" }. */\n requires: z.record(z.string(), z.string()).optional(),\n pairs_with: z.array(z.string().regex(NAME_RE)).default([]),\n /** citation URLs to canonical docs — never verbatim content. */\n sources: z.array(z.string().url()).default([]),\n snapshot_date: z.string().regex(ISO_DATE_RE, \"must be an ISO date (YYYY-MM-DD)\"),\n stability: StabilitySchema,\n version: z\n .string()\n .refine((v) => semver.valid(v) != null, \"must be a valid semver version\"),\n })\n .strict();\nexport type XSkillsMaster = z.infer<typeof XSkillsMasterSchema>;\n\n/** `globs` may be authored as a string or array; normalized to an array. */\nconst GlobsSchema = z\n .union([z.string(), z.array(z.string())])\n .transform((g) => (Array.isArray(g) ? g : [g]))\n .optional();\n\nexport const FrontmatterSchema = z\n .object({\n name: z.string().regex(NAME_RE, \"must be kebab-case ([a-z0-9-], <=64 chars)\"),\n description: z\n .string()\n .min(1, \"description is required\")\n .max(1024, \"description must be <= 1024 characters\"),\n globs: GlobsSchema,\n tags: z.array(z.string()).default([]),\n \"x-skills-master\": XSkillsMasterSchema,\n })\n // Tolerate tool-native extras (e.g. allowed-tools) without failing validation.\n .passthrough();\nexport type Frontmatter = z.infer<typeof FrontmatterSchema>;\n","import { findSkillDirs } from \"./discover\";\nimport { loadSkill } from \"./parse\";\nimport type { Registry, RegistryEntry } from \"../schema/registry\";\n\n/**\n * Build the catalog from the skill tree. Output is deterministic (no timestamp)\n * so a committed `registry.json` can be drift-checked in CI.\n */\nexport function buildRegistry(skillsRoot: string, version = \"0.1.0\"): Registry {\n const dirs = findSkillDirs(skillsRoot);\n const skills: RegistryEntry[] = dirs.map((dir) => {\n const s = loadSkill(dir, skillsRoot);\n const xm = s.frontmatter[\"x-skills-master\"];\n return {\n name: s.name,\n domain: xm.domain,\n class: xm.class,\n category: xm.category,\n description: s.frontmatter.description,\n platforms: xm.platforms,\n stability: xm.stability,\n version: xm.version,\n tags: s.frontmatter.tags ?? [],\n pairs_with: xm.pairs_with,\n path: s.relPath,\n resources: {\n reference: Boolean(s.resources.reference),\n examples: Boolean(s.resources.examples),\n checklist: Boolean(s.resources.checklist),\n },\n };\n });\n skills.sort((a, b) => a.name.localeCompare(b.name));\n return {\n $schema: \"https://skills-master.dev/schema/registry.json\",\n version,\n skills,\n };\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ParsedSkill, TargetId } from \"../types\";\nimport type { LockedSkill } from \"../schema/lockfile\";\nimport { compileSkill } from \"./compile\";\nimport { applyFiles, type ApplyOptions, type DetailedWriteResult } from \"./writer\";\nimport { sha256 } from \"./hash\";\n\nexport interface InstallResult {\n name: string;\n version: string;\n results: DetailedWriteResult[];\n locked: LockedSkill;\n}\n\n/** Hash a skill's canonical source for drift detection. */\nexport function sourceHashOf(skill: ParsedSkill): string {\n const xm = skill.frontmatter[\"x-skills-master\"];\n return sha256(\n skill.relPath,\n xm.version,\n skill.frontmatter.description,\n skill.body,\n skill.resources.reference ?? \"\",\n skill.resources.examples ?? \"\",\n skill.resources.checklist ?? \"\",\n );\n}\n\n/**\n * Hash the given whole-file outputs as they currently exist on disk. Both the\n * lockfile (at install time) and the `update`/`doctor` drift checks use this\n * one function, so a clean install always reconciles.\n */\nexport function diskHash(projectRoot: string, relPaths: string[]): string {\n const sorted = [...relPaths].sort((a, b) => a.localeCompare(b));\n const parts: string[] = [];\n for (const p of sorted) {\n const abs = join(projectRoot, p);\n const contents = existsSync(abs) ? readFileSync(abs, \"utf8\") : \"<<missing>>\";\n parts.push(p, contents);\n }\n return sha256(...parts);\n}\n\n/** Compile a skill to the given targets and write the outputs to a project. */\nexport function installSkill(\n projectRoot: string,\n skill: ParsedSkill,\n targets: TargetId[],\n paths: Record<TargetId, string>,\n opts: ApplyOptions = {},\n): InstallResult {\n const compiled = compileSkill(skill, targets, { projectRoot, paths });\n const allFiles = compiled.flatMap((c) => c.files);\n const results = applyFiles(projectRoot, allFiles, opts);\n\n const emitted: LockedSkill[\"emitted\"] = {};\n for (const c of compiled) {\n const whole = c.files.filter((f) => f.mode === \"whole\").map((f) => f.path);\n const block = c.files.find((f) => f.mode === \"block\")?.path;\n // Hash covers only whole-file outputs (block files are marker-managed and\n // safe to reconcile). Computed from disk after writing so the lockfile\n // records what actually landed; in dry-run nothing is written or saved.\n const hash = opts.dryRun ? sha256(\"dry-run\", ...whole) : diskHash(projectRoot, whole);\n emitted[c.target] = { files: whole, ...(block ? { block } : {}), hash };\n }\n\n const version = skill.frontmatter[\"x-skills-master\"].version;\n return {\n name: skill.name,\n version,\n results,\n locked: { version, sourceHash: sourceHashOf(skill), emitted },\n };\n}\n","import type { EmitContext, EmittedFile, ParsedSkill, TargetId } from \"../types\";\nimport { getEmitter } from \"../emitters\";\n\nexport interface CompiledTarget {\n target: TargetId;\n files: EmittedFile[];\n}\n\n/** Run the emitters for the requested targets over a single skill. */\nexport function compileSkill(\n skill: ParsedSkill,\n targets: TargetId[],\n ctx: EmitContext,\n): CompiledTarget[] {\n const out: CompiledTarget[] = [];\n for (const target of targets) {\n const emitter = getEmitter(target);\n if (!emitter) throw new Error(`Unknown target: ${target}`);\n out.push({ target, files: emitter.emit(skill, ctx) });\n }\n return out;\n}\n","import { existsSync, mkdirSync, readdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { EmittedFile, WriteAction, WriteResult } from \"../types\";\nimport { hasBlock, removeBlock, upsertBlock } from \"./markers\";\n\nexport type ConflictChoice = \"overwrite\" | \"skip\";\n\nexport interface ApplyOptions {\n dryRun?: boolean;\n /** force-overwrite changed whole-files without asking. */\n overwrite?: boolean;\n /** called for a changed whole-file when neither overwrite nor dryRun is set. */\n onConflict?: (path: string) => ConflictChoice;\n}\n\nexport interface DetailedWriteResult extends WriteResult {\n /** previous file contents (whole-file) when it changed — for diff previews. */\n before?: string;\n /** new file contents (whole-file) when it changed. */\n after?: string;\n}\n\nfunction ensureDir(absPath: string): void {\n mkdirSync(dirname(absPath), { recursive: true });\n}\n\nfunction applyWhole(\n projectRoot: string,\n file: EmittedFile,\n opts: ApplyOptions,\n): DetailedWriteResult {\n const abs = join(projectRoot, file.path);\n const exists = existsSync(abs);\n const next = file.contents;\n\n if (!exists) {\n if (!opts.dryRun) {\n ensureDir(abs);\n writeFileSync(abs, next, \"utf8\");\n }\n return { path: file.path, mode: \"whole\", action: \"created\", after: next };\n }\n\n const current = readFileSync(abs, \"utf8\");\n if (current === next) {\n return { path: file.path, mode: \"whole\", action: \"unchanged\" };\n }\n\n // changed\n let choice: ConflictChoice = \"overwrite\";\n if (!opts.overwrite) {\n choice = opts.onConflict ? opts.onConflict(file.path) : opts.dryRun ? \"overwrite\" : \"skip\";\n }\n if (choice === \"skip\") {\n return { path: file.path, mode: \"whole\", action: \"skipped\", before: current, after: next };\n }\n if (!opts.dryRun) writeFileSync(abs, next, \"utf8\");\n return { path: file.path, mode: \"whole\", action: \"updated\", before: current, after: next };\n}\n\nfunction applyBlock(\n projectRoot: string,\n file: EmittedFile,\n opts: ApplyOptions,\n): DetailedWriteResult {\n const abs = join(projectRoot, file.path);\n const exists = existsSync(abs);\n const current = exists ? readFileSync(abs, \"utf8\") : \"\";\n const blockId = file.blockId!;\n const next = upsertBlock(current, blockId, file.contents, file.blockVersion);\n\n let action: WriteAction;\n if (current === next) action = \"unchanged\";\n else if (!exists || !hasBlock(current, blockId)) action = \"created\";\n else action = \"updated\";\n\n if (action !== \"unchanged\" && !opts.dryRun) {\n ensureDir(abs);\n writeFileSync(abs, next, \"utf8\");\n }\n return { path: file.path, mode: \"block\", blockId, action };\n}\n\n/** Apply a batch of emitted files to a project. */\nexport function applyFiles(\n projectRoot: string,\n files: EmittedFile[],\n opts: ApplyOptions = {},\n): DetailedWriteResult[] {\n return files.map((f) =>\n f.mode === \"block\" ? applyBlock(projectRoot, f, opts) : applyWhole(projectRoot, f, opts),\n );\n}\n\n/** Remove now-empty ancestor directories of the given files, up to (not incl.) the project root. */\nexport function pruneEmptyDirs(projectRoot: string, relFilePaths: string[], dryRun = false): void {\n if (dryRun) return;\n const seen = new Set<string>();\n for (const rel of relFilePaths) {\n let dir = dirname(join(projectRoot, rel));\n while (dir.startsWith(projectRoot) && dir !== projectRoot && !seen.has(dir)) {\n seen.add(dir);\n try {\n if (existsSync(dir) && readdirSync(dir).length === 0) {\n rmdirSync(dir);\n dir = dirname(dir);\n } else break;\n } catch {\n break;\n }\n }\n }\n}\n\n/** Remove a whole-file output. */\nexport function removeWholeFile(projectRoot: string, relPath: string, dryRun = false): boolean {\n const abs = join(projectRoot, relPath);\n if (!existsSync(abs)) return false;\n if (!dryRun) rmSync(abs);\n return true;\n}\n\n/**\n * Remove a managed block from a shared file. Deletes the file if it becomes\n * empty. Returns true if anything changed.\n */\nexport function removeBlockFromFile(\n projectRoot: string,\n relPath: string,\n blockId: string,\n dryRun = false,\n): boolean {\n const abs = join(projectRoot, relPath);\n if (!existsSync(abs)) return false;\n const current = readFileSync(abs, \"utf8\");\n if (!hasBlock(current, blockId)) return false;\n const next = removeBlock(current, blockId);\n if (!dryRun) {\n if (next.trim().length === 0) rmSync(abs);\n else writeFileSync(abs, next, \"utf8\");\n }\n return true;\n}\n","/**\n * Sentinel-marker management for shared files (AGENTS.md, copilot-instructions.md).\n *\n * A managed region looks like:\n *\n * <!-- BEGIN skills-master:<id> v<version> -->\n * ...generated content...\n * <!-- END skills-master:<id> -->\n *\n * Only the bytes between (and including) the markers are ever touched, so any\n * hand-written content elsewhere in the file is preserved.\n */\n\nconst PREFIX = \"skills-master\";\n\nfunction escapeRe(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nexport function beginMarker(id: string, version?: string): string {\n return version\n ? `<!-- BEGIN ${PREFIX}:${id} v${version} -->`\n : `<!-- BEGIN ${PREFIX}:${id} -->`;\n}\n\nexport function endMarker(id: string): string {\n return `<!-- END ${PREFIX}:${id} -->`;\n}\n\nfunction blockRegex(id: string): RegExp {\n const esc = escapeRe(id);\n return new RegExp(\n `[ \\\\t]*<!-- BEGIN ${PREFIX}:${esc}(?: v[^>]*)? -->[\\\\s\\\\S]*?<!-- END ${PREFIX}:${esc} -->`,\n );\n}\n\n/** Build a complete managed block (markers + body). */\nexport function renderBlock(id: string, body: string, version?: string): string {\n return `${beginMarker(id, version)}\\n${body.trim()}\\n${endMarker(id)}`;\n}\n\nexport function hasBlock(file: string, id: string): boolean {\n return blockRegex(id).test(file);\n}\n\n/** Read the inner body of a managed block, or null if absent. */\nexport function readBlock(file: string, id: string): string | null {\n const m = blockRegex(id).exec(file);\n if (!m) return null;\n const inner = m[0]\n .replace(new RegExp(`^[ \\\\t]*<!-- BEGIN ${PREFIX}:${escapeRe(id)}(?: v[^>]*)? -->\\\\n?`), \"\")\n .replace(new RegExp(`\\\\n?<!-- END ${PREFIX}:${escapeRe(id)} -->$`), \"\");\n return inner;\n}\n\n/** Read the version recorded in a block's BEGIN marker, or null. */\nexport function readBlockVersion(file: string, id: string): string | null {\n const m = new RegExp(\n `<!-- BEGIN ${PREFIX}:${escapeRe(id)} v([^\\\\s>]+) -->`,\n ).exec(file);\n return m && m[1] ? m[1] : null;\n}\n\n/**\n * Insert or replace a managed block. Returns the new file contents.\n * If the block is absent it is appended, separated by a blank line.\n */\nexport function upsertBlock(\n file: string,\n id: string,\n body: string,\n version?: string,\n): string {\n const block = renderBlock(id, body, version);\n const re = blockRegex(id);\n if (re.test(file)) {\n return file.replace(re, block);\n }\n const base = file.replace(/\\s+$/, \"\");\n if (base.length === 0) return block + \"\\n\";\n return `${base}\\n\\n${block}\\n`;\n}\n\n/**\n * Remove a managed block (and a trailing blank line). Returns the new contents.\n * If the file becomes empty (only whitespace), returns the empty string so the\n * caller can delete it.\n */\nexport function removeBlock(file: string, id: string): string {\n const re = new RegExp(blockRegex(id).source + `\\\\n?\\\\n?`);\n const next = file.replace(re, \"\");\n return next.trim().length === 0 ? \"\" : next.replace(/\\n{3,}/g, \"\\n\\n\").trimEnd() + \"\\n\";\n}\n","import { createHash } from \"node:crypto\";\n\n/** Deterministic sha256 of one or more strings, prefixed `sha256:`. */\nexport function sha256(...parts: string[]): string {\n const h = createHash(\"sha256\");\n for (const p of parts) {\n h.update(p, \"utf8\");\n h.update(\"\u0000\"); // domain separator between parts\n }\n return \"sha256:\" + h.digest(\"hex\");\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n/** Ensure each entry appears in the project's .gitignore (idempotent). */\nexport function ensureGitignored(root: string, entries: string[]): void {\n const p = join(root, \".gitignore\");\n const current = existsSync(p) ? readFileSync(p, \"utf8\") : \"\";\n const lines = new Set(current.split(\"\\n\").map((l) => l.trim()));\n const missing = entries.filter((e) => !lines.has(e));\n if (missing.length === 0) return;\n const header = current.includes(\"# skills-master\") ? \"\" : \"\\n# skills-master generated outputs\\n\";\n const next = current.replace(/\\s*$/, \"\") + header + missing.join(\"\\n\") + \"\\n\";\n writeFileSync(p, next, \"utf8\");\n}\n","import { resolvePaths } from \"../schema/projectConfig\";\nimport { ALL_TARGETS, type TargetId } from \"../types\";\nimport { detectTargets } from \"../emitters\";\nimport { resolveContent } from \"../content/source\";\nimport { installSkill } from \"../core/install\";\nimport {\n loadConfig,\n loadConfigOrDefault,\n loadLockfile,\n saveConfig,\n saveLockfile,\n} from \"../core/project\";\nimport { ensureGitignored } from \"../core/gitignore\";\nimport type { ConflictChoice } from \"../core/writer\";\nimport { log } from \"../util/log\";\n\nexport interface AddOptions {\n cwd: string;\n /** skill names, category names, or class names to install. */\n names: string[];\n targets?: TargetId[];\n content?: string;\n ref?: string;\n withPairs?: boolean;\n dryRun?: boolean;\n overwrite?: boolean;\n /** interactive conflict resolver (bin supplies this on a TTY). */\n onConflict?: (path: string) => ConflictChoice;\n}\n\nexport interface AddResult {\n targets: TargetId[];\n installed: { name: string; version: string }[];\n skipped: string[];\n}\n\nexport async function addCommand(opts: AddOptions): Promise<AddResult> {\n const cfg = loadConfigOrDefault(opts.cwd);\n const hadConfig = loadConfig(opts.cwd) != null;\n\n let targets = opts.targets?.length ? opts.targets : cfg.targets;\n if (!targets.length) targets = detectTargets(opts.cwd);\n if (!targets.length) targets = ALL_TARGETS;\n\n const content = await resolveContent({\n content: opts.content,\n ref: opts.ref ?? cfg.contentRef,\n cwd: opts.cwd,\n });\n const registry = content.registry();\n const byName = new Map(registry.skills.map((s) => [s.name, s]));\n\n // Resolve tokens → concrete skill names (name > category > class).\n const selected = new Set<string>();\n const skipped: string[] = [];\n for (const token of opts.names) {\n if (byName.has(token)) {\n selected.add(token);\n continue;\n }\n const byCategory = registry.skills.filter((s) => s.category === token);\n const byClass = registry.skills.filter((s) => s.class === token);\n const group = byCategory.length ? byCategory : byClass;\n if (group.length) {\n group.forEach((s) => selected.add(s.name));\n } else {\n log.warn(`No skill, category, or class matches \"${token}\".`);\n skipped.push(token);\n }\n }\n\n if (opts.withPairs) {\n for (const name of [...selected]) {\n for (const pair of byName.get(name)?.pairs_with ?? []) {\n if (byName.has(pair)) selected.add(pair);\n else log.warn(`Paired skill \"${pair}\" (from \"${name}\") is not in the registry.`);\n }\n }\n }\n\n if (selected.size === 0) {\n log.error(\"Nothing to install.\");\n return { targets, installed: [], skipped };\n }\n\n const paths = resolvePaths(cfg);\n const lock = loadLockfile(opts.cwd);\n lock.contentRef = opts.ref ?? cfg.contentRef;\n const installed: { name: string; version: string }[] = [];\n\n const prefix = opts.dryRun ? \"[dry-run] \" : \"\";\n for (const name of [...selected].sort()) {\n const skill = content.loadSkill(name);\n const result = installSkill(opts.cwd, skill, targets, paths, {\n dryRun: opts.dryRun,\n overwrite: opts.overwrite,\n onConflict: opts.onConflict,\n });\n if (!opts.dryRun) lock.skills[name] = result.locked;\n installed.push({ name, version: result.version });\n\n for (const r of result.results) {\n const tag = r.mode === \"block\" ? `${r.path} [${r.blockId}]` : r.path;\n log.info(`${prefix}${r.action.padEnd(9)} ${tag}`);\n }\n }\n\n if (!opts.dryRun) {\n saveLockfile(opts.cwd, lock);\n if (!hadConfig) {\n saveConfig(opts.cwd, { ...cfg, targets });\n log.info(\"Wrote skills-master.json.\");\n }\n if (!cfg.commit) {\n const outs = targets.map((t) => paths[t]);\n ensureGitignored(opts.cwd, outs);\n }\n }\n\n log.success(\n `${prefix}Installed ${installed.length} skill(s) into ${targets.length} target(s): ${targets.join(\", \")}.`,\n );\n return { targets, installed, skipped };\n}\n","import { resolvePaths } from \"../schema/projectConfig\";\nimport type { TargetId } from \"../types\";\nimport { resolveContent } from \"../content/source\";\nimport { diskHash, installSkill, sourceHashOf } from \"../core/install\";\nimport { loadConfigOrDefault, loadLockfile, saveLockfile } from \"../core/project\";\nimport type { ConflictChoice } from \"../core/writer\";\nimport { log } from \"../util/log\";\n\nexport interface UpdateOptions {\n cwd: string;\n names?: string[];\n content?: string;\n ref?: string;\n dryRun?: boolean;\n overwrite?: boolean;\n onConflict?: (path: string) => ConflictChoice;\n}\n\nexport interface UpdateResult {\n updated: string[];\n upToDate: string[];\n skipped: string[];\n}\n\nexport async function updateCommand(opts: UpdateOptions): Promise<UpdateResult> {\n const cfg = loadConfigOrDefault(opts.cwd);\n const lock = loadLockfile(opts.cwd);\n const ref = opts.ref ?? cfg.contentRef;\n const updated: string[] = [];\n const upToDate: string[] = [];\n const skipped: string[] = [];\n\n const names = opts.names?.length ? opts.names : Object.keys(lock.skills);\n if (names.length === 0) {\n log.info(\"No installed skills to update.\");\n return { updated, upToDate, skipped };\n }\n\n const content = await resolveContent({ content: opts.content, ref, cwd: opts.cwd });\n const paths = resolvePaths(cfg);\n const prefix = opts.dryRun ? \"[dry-run] \" : \"\";\n\n for (const name of names.sort()) {\n const locked = lock.skills[name];\n if (!locked) {\n log.warn(`\"${name}\" is not installed — run \\`add\\` first.`);\n skipped.push(name);\n continue;\n }\n\n let skill;\n try {\n skill = content.loadSkill(name);\n } catch {\n log.warn(`\"${name}\" no longer exists in the content library.`);\n skipped.push(name);\n continue;\n }\n\n const refChanged = lock.contentRef !== ref;\n const sourceChanged = locked.sourceHash !== sourceHashOf(skill);\n if (!opts.overwrite && !sourceChanged && !refChanged) {\n upToDate.push(name);\n continue;\n }\n\n // Re-emit to exactly the targets this skill was installed to.\n const targets = Object.keys(locked.emitted) as TargetId[];\n\n // Detect user edits to owned whole-files since install.\n const userEdited = targets.some((t) => {\n const e = locked.emitted[t];\n return e && diskHash(opts.cwd, e.files) !== e.hash;\n });\n if (userEdited && !opts.overwrite && !opts.onConflict) {\n log.warn(`${prefix}\"${name}\" has local edits — skipping (use --overwrite to replace).`);\n skipped.push(name);\n continue;\n }\n\n const result = installSkill(opts.cwd, skill, targets, paths, {\n dryRun: opts.dryRun,\n overwrite: opts.overwrite || !userEdited,\n onConflict: opts.onConflict,\n });\n if (!opts.dryRun) lock.skills[name] = result.locked;\n updated.push(name);\n for (const r of result.results) {\n if (r.action === \"unchanged\") continue;\n const tag = r.mode === \"block\" ? `${r.path} [${r.blockId}]` : r.path;\n log.info(`${prefix}${r.action.padEnd(9)} ${tag}`);\n }\n }\n\n if (!opts.dryRun) {\n lock.contentRef = ref;\n saveLockfile(opts.cwd, lock);\n }\n\n log.success(\n `${prefix}Updated ${updated.length}, up-to-date ${upToDate.length}, skipped ${skipped.length}.`,\n );\n return { updated, upToDate, skipped };\n}\n","import type { TargetId } from \"../types\";\nimport { loadLockfile, saveLockfile } from \"../core/project\";\nimport { pruneEmptyDirs, removeBlockFromFile, removeWholeFile } from \"../core/writer\";\nimport { log } from \"../util/log\";\n\nexport interface RemoveOptions {\n cwd: string;\n names: string[];\n /** restrict removal to specific targets; default = every target the skill was installed to. */\n targets?: TargetId[];\n dryRun?: boolean;\n}\n\nexport interface RemoveResult {\n removed: string[];\n missing: string[];\n}\n\nexport function removeCommand(opts: RemoveOptions): RemoveResult {\n const lock = loadLockfile(opts.cwd);\n const removed: string[] = [];\n const missing: string[] = [];\n const prefix = opts.dryRun ? \"[dry-run] \" : \"\";\n\n for (const name of opts.names) {\n const locked = lock.skills[name];\n if (!locked) {\n log.warn(`\"${name}\" is not installed.`);\n missing.push(name);\n continue;\n }\n\n const targets = (opts.targets?.length\n ? opts.targets\n : (Object.keys(locked.emitted) as TargetId[])\n ).filter((t) => locked.emitted[t]);\n\n const wholeRemoved: string[] = [];\n for (const t of targets) {\n const e = locked.emitted[t]!;\n for (const file of e.files) {\n if (removeWholeFile(opts.cwd, file, opts.dryRun)) {\n wholeRemoved.push(file);\n log.info(`${prefix}removed ${file}`);\n }\n }\n if (e.block && removeBlockFromFile(opts.cwd, e.block, name, opts.dryRun)) {\n log.info(`${prefix}unblocked ${e.block} [${name}]`);\n }\n if (!opts.dryRun) delete locked.emitted[t];\n }\n pruneEmptyDirs(opts.cwd, wholeRemoved, opts.dryRun);\n\n if (!opts.dryRun) {\n if (Object.keys(locked.emitted).length === 0) delete lock.skills[name];\n }\n removed.push(name);\n }\n\n if (!opts.dryRun) saveLockfile(opts.cwd, lock);\n log.success(`${prefix}Removed ${removed.length} skill(s).`);\n return { removed, missing };\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { diskHash } from \"../core/install\";\nimport { loadConfig, loadLockfile } from \"../core/project\";\nimport { hasBlock } from \"../core/markers\";\nimport { log } from \"../util/log\";\n\nexport interface DoctorOptions {\n cwd: string;\n}\n\nexport interface DoctorReport {\n problems: string[];\n ok: boolean;\n}\n\nexport function doctorCommand(opts: DoctorOptions): DoctorReport {\n const problems: string[] = [];\n const note = (msg: string) => problems.push(msg);\n\n const cfg = loadConfig(opts.cwd);\n if (!cfg) {\n log.warn(\"No skills-master.json found — run `skills-master init`.\");\n } else {\n log.info(`Config targets: ${cfg.targets.length ? cfg.targets.join(\", \") : \"(auto-detect)\"}`);\n }\n\n const lock = loadLockfile(opts.cwd);\n const names = Object.keys(lock.skills);\n if (names.length === 0) {\n log.info(\"No skills installed.\");\n return { problems, ok: true };\n }\n\n for (const name of names) {\n const locked = lock.skills[name]!;\n for (const [target, e] of Object.entries(locked.emitted)) {\n for (const file of e.files) {\n if (!existsSync(join(opts.cwd, file))) note(`${name}: missing ${target} file ${file}`);\n }\n if (e.files.every((f) => existsSync(join(opts.cwd, f)))) {\n if (diskHash(opts.cwd, e.files) !== e.hash) {\n note(`${name}: local edits to ${target} output(s) (run \\`update --overwrite\\` to reset)`);\n }\n }\n if (e.block) {\n const abs = join(opts.cwd, e.block);\n if (!existsSync(abs) || !hasBlock(readFileSync(abs, \"utf8\"), name)) {\n note(`${name}: missing managed block in ${e.block}`);\n }\n }\n }\n }\n\n if (problems.length === 0) {\n log.success(`All ${names.length} installed skill(s) look healthy.`);\n } else {\n for (const p of problems) log.warn(p);\n log.plain(`\\n${problems.length} problem(s) found.`);\n }\n return { problems, ok: problems.length === 0 };\n}\n","import { resolveContent } from \"../content/source\";\nimport type { Registry, RegistryEntry } from \"../schema/registry\";\nimport { log } from \"../util/log\";\n\nexport interface CatalogQuery {\n content?: string;\n ref?: string;\n cwd?: string;\n}\n\nasync function registryOf(q: CatalogQuery): Promise<Registry> {\n const content = await resolveContent({ content: q.content, ref: q.ref, cwd: q.cwd });\n return content.registry();\n}\n\nexport interface ListOptions extends CatalogQuery {\n domain?: string;\n class?: string;\n category?: string;\n platform?: string;\n json?: boolean;\n}\n\nexport async function listCommand(opts: ListOptions): Promise<RegistryEntry[]> {\n const reg = await registryOf(opts);\n let skills = reg.skills;\n if (opts.domain) skills = skills.filter((s) => s.domain === opts.domain);\n if (opts.class) skills = skills.filter((s) => s.class === opts.class);\n if (opts.category) skills = skills.filter((s) => s.category === opts.category);\n if (opts.platform) {\n const platform = opts.platform;\n skills = skills.filter((s) => s.platforms.includes(platform));\n }\n\n if (opts.json) {\n log.plain(JSON.stringify(skills, null, 2));\n return skills;\n }\n\n if (skills.length === 0) {\n log.info(\"No skills match.\");\n return skills;\n }\n\n const groups = new Map<string, RegistryEntry[]>();\n for (const s of skills) {\n const key = `${s.domain}/${s.class}/${s.category}`;\n (groups.get(key) ?? groups.set(key, []).get(key)!).push(s);\n }\n for (const [group, entries] of [...groups].sort()) {\n log.plain(`\\n${group}`);\n for (const s of entries) {\n const flag = s.stability === \"stable\" ? \"\" : ` (${s.stability})`;\n log.plain(` ${s.name} v${s.version}${flag}`);\n log.plain(` ${truncate(s.description, 96)}`);\n }\n }\n log.plain(`\\n${skills.length} skill(s).`);\n return skills;\n}\n\nexport interface SearchOptions extends CatalogQuery {\n query: string;\n}\n\nexport async function searchCommand(opts: SearchOptions): Promise<RegistryEntry[]> {\n const reg = await registryOf(opts);\n const q = opts.query.toLowerCase();\n const hits = reg.skills.filter((s) =>\n [s.name, s.description, s.domain, s.category, s.class, ...s.tags]\n .join(\" \")\n .toLowerCase()\n .includes(q),\n );\n if (hits.length === 0) {\n log.info(`No matches for \"${opts.query}\".`);\n return hits;\n }\n for (const s of hits) {\n log.plain(`${s.name} (${s.class}/${s.category}) v${s.version}`);\n log.plain(` ${truncate(s.description, 96)}`);\n }\n log.plain(`\\n${hits.length} match(es).`);\n return hits;\n}\n\nexport interface ViewOptions extends CatalogQuery {\n name: string;\n raw?: boolean;\n}\n\nexport async function viewCommand(opts: ViewOptions): Promise<void> {\n const content = await resolveContent({ content: opts.content, ref: opts.ref, cwd: opts.cwd });\n const skill = content.loadSkill(opts.name);\n const xm = skill.frontmatter[\"x-skills-master\"];\n if (opts.raw) {\n log.plain(skill.body);\n return;\n }\n log.plain(`${skill.name} v${xm.version} [${xm.domain}/${xm.class}/${xm.category}] ${xm.stability}`);\n log.plain(`platforms: ${xm.platforms.join(\", \")}`);\n if (xm.requires) {\n log.plain(`requires: ${Object.entries(xm.requires).map(([k, v]) => `${k} ${v}`).join(\", \")}`);\n }\n if (xm.pairs_with.length) log.plain(`pairs with: ${xm.pairs_with.join(\", \")}`);\n log.plain(`\\n${skill.frontmatter.description}\\n`);\n log.plain(`sources:`);\n for (const url of xm.sources) log.plain(` ${url}`);\n const res = Object.entries(skill.resources).filter(([, v]) => v).map(([k]) => k);\n if (res.length) log.plain(`\\nresource files: ${res.join(\", \")}`);\n}\n\nfunction truncate(s: string, n: number): string {\n return s.length <= n ? s : s.slice(0, n - 1) + \"…\";\n}\n","import type { Frontmatter } from \"../schema/frontmatter\";\nimport { findSkillDirs, relPathOf } from \"./discover\";\nimport { loadRawSkill, validateFrontmatter } from \"./parse\";\n\nexport type DiagnosticLevel = \"error\" | \"warn\";\n\nexport interface Diagnostic {\n relPath: string;\n level: DiagnosticLevel;\n message: string;\n}\n\nexport interface LintResult {\n diagnostics: Diagnostic[];\n skillCount: number;\n errorCount: number;\n warnCount: number;\n}\n\nconst CANONICAL_HEADINGS = [\n \"## When to use\",\n \"## Core guidance\",\n \"## Pitfalls\",\n \"## References\",\n \"## See also\",\n];\nconst MAX_BODY_LINES = 500;\nconst WARN_BODY_LINES = 450;\n\nfunction today(): string {\n return new Date().toISOString().slice(0, 10);\n}\n\ninterface Loaded {\n relPath: string;\n folderName: string;\n fm?: Frontmatter;\n body: string;\n}\n\nexport function lintSkills(skillsRoot: string): LintResult {\n const dirs = findSkillDirs(skillsRoot);\n const diagnostics: Diagnostic[] = [];\n const loaded: Loaded[] = [];\n const byName = new Map<string, Frontmatter>();\n\n for (const dir of dirs) {\n let raw;\n try {\n raw = loadRawSkill(dir, skillsRoot);\n } catch (err) {\n diagnostics.push({\n relPath: relPathOf(skillsRoot, dir),\n level: \"error\",\n message: `failed to parse SKILL.md: ${err instanceof Error ? err.message.split(\"\\n\")[0] : String(err)}`,\n });\n continue;\n }\n\n // YAML hazard: an unquoted scalar containing \" #\" is silently truncated as\n // a comment (e.g. \"@Test, #expect\" loses everything from \"#expect\" on).\n for (const line of raw.rawText.split(\"\\n\")) {\n const m = /^(\\s*)(name|description|category):\\s+(?![\"'])(.*\\s#.*)$/.exec(line);\n if (m) {\n diagnostics.push({\n relPath: raw.relPath,\n level: \"warn\",\n message: `frontmatter \"${m[2]}\" contains \" #\", which YAML reads as a comment — quote the value`,\n });\n }\n }\n\n const v = validateFrontmatter(raw.data);\n if (!v.ok) {\n for (const issue of v.issues) {\n diagnostics.push({ relPath: raw.relPath, level: \"error\", message: issue });\n }\n loaded.push({ relPath: raw.relPath, folderName: raw.folderName, body: raw.body });\n continue;\n }\n loaded.push({ relPath: raw.relPath, folderName: raw.folderName, fm: v.value, body: raw.body });\n byName.set(v.value.name, v.value);\n }\n\n // Skill names must be globally unique (the registry and `add` key on name).\n const nameDirs = new Map<string, string[]>();\n for (const s of loaded) {\n const n = s.fm?.name ?? s.folderName;\n (nameDirs.get(n) ?? nameDirs.set(n, []).get(n)!).push(s.relPath);\n }\n for (const [name, paths] of nameDirs) {\n if (paths.length > 1) {\n for (const p of paths) {\n diagnostics.push({ relPath: p, level: \"error\", message: `duplicate skill name \"${name}\" (also at ${paths.filter((x) => x !== p).join(\", \")})` });\n }\n }\n }\n\n const todayStr = today();\n\n for (const s of loaded) {\n const push = (level: DiagnosticLevel, message: string) =>\n diagnostics.push({ relPath: s.relPath, level, message });\n if (!s.fm) continue;\n const fm = s.fm;\n const xm = fm[\"x-skills-master\"];\n\n // name == folder name\n if (fm.name !== s.folderName) {\n push(\"error\", `name \"${fm.name}\" must equal the folder name \"${s.folderName}\"`);\n }\n\n // description shape (soft)\n if (!/use when/i.test(fm.description)) {\n push(\"warn\", `description should include a \"Use when ...\" trigger clause`);\n }\n\n // snapshot_date not in the future\n if (xm.snapshot_date > todayStr) {\n push(\"error\", `snapshot_date ${xm.snapshot_date} is in the future`);\n }\n\n // contested ⇒ Open question section\n if (xm.stability === \"contested\" && !/^## Open question\\b/m.test(s.body)) {\n push(\"error\", `stability is \"contested\" but no \"## Open question\" section is present`);\n }\n\n // body length\n const lineCount = s.body.split(\"\\n\").length;\n if (lineCount > MAX_BODY_LINES) {\n push(\"error\", `SKILL.md body is ${lineCount} lines (max ${MAX_BODY_LINES}); move depth into reference.md/examples.md`);\n } else if (lineCount > WARN_BODY_LINES) {\n push(\"warn\", `SKILL.md body is ${lineCount} lines (approaching the ${MAX_BODY_LINES}-line cap)`);\n }\n\n // domain should match the top path segment\n if (!s.relPath.startsWith(`${xm.domain}/`)) {\n push(\"warn\", `domain \"${xm.domain}\" does not match the top folder of \"${s.relPath}\"`);\n }\n\n // sources should be present and be https documentation URLs\n if (xm.sources.length === 0) {\n push(\"warn\", `no sources — add at least one canonical documentation URL`);\n }\n for (const url of xm.sources) {\n if (!/^https:\\/\\//.test(url)) {\n push(\"warn\", `sources entry should be an https URL: ${url}`);\n }\n }\n\n // canonical headings\n for (const heading of CANONICAL_HEADINGS) {\n if (!s.body.includes(heading)) {\n push(\"warn\", `missing recommended section \"${heading}\"`);\n }\n }\n\n // pairs_with referential integrity (bidirectional)\n for (const partner of xm.pairs_with) {\n const partnerFm = byName.get(partner);\n if (!partnerFm) {\n push(\"error\", `pairs_with references unknown skill \"${partner}\"`);\n continue;\n }\n if (!partnerFm[\"x-skills-master\"].pairs_with.includes(fm.name)) {\n push(\"error\", `pairs_with \"${partner}\" is not reciprocated (add \"${fm.name}\" to its pairs_with)`);\n }\n }\n }\n\n const errorCount = diagnostics.filter((d) => d.level === \"error\").length;\n const warnCount = diagnostics.filter((d) => d.level === \"warn\").length;\n return { diagnostics, skillCount: dirs.length, errorCount, warnCount };\n}\n","import { resolveContent } from \"../content/source\";\nimport { lintSkills } from \"../core/lint\";\nimport { log } from \"../util/log\";\n\nexport interface LintCmdOptions {\n content?: string;\n cwd?: string;\n}\n\n/** Lint the skill library. Returns true when there are no errors. */\nexport async function lintCommand(opts: LintCmdOptions): Promise<boolean> {\n const content = await resolveContent({ content: opts.content, cwd: opts.cwd });\n const result = lintSkills(content.root);\n\n for (const d of result.diagnostics) {\n const line = `${d.level === \"error\" ? \"✗\" : \"!\"} ${d.relPath}: ${d.message}`;\n if (d.level === \"error\") log.error(line);\n else log.warn(line);\n }\n\n log.plain(\n `\\nLinted ${result.skillCount} skill(s): ${result.errorCount} error(s), ${result.warnCount} warning(s).`,\n );\n return result.errorCount === 0;\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { resolveContent } from \"../content/source\";\nimport { buildRegistry } from \"../core/registry-build\";\nimport { REGISTRY_FILENAME } from \"../schema/registry\";\nimport { log } from \"../util/log\";\n\nexport interface RegistryBuildOptions {\n content?: string;\n cwd?: string;\n /** when true, verify the committed registry.json is up to date (CI mode). */\n check?: boolean;\n version?: string;\n}\n\n/** Build (or verify) registry.json from the skill tree. Returns true on success. */\nexport async function registryBuildCommand(opts: RegistryBuildOptions): Promise<boolean> {\n const content = await resolveContent({ content: opts.content, cwd: opts.cwd });\n const registry = buildRegistry(content.root, opts.version ?? \"0.1.0\");\n const json = JSON.stringify(registry, null, 2) + \"\\n\";\n const outPath = join(content.root, REGISTRY_FILENAME);\n\n if (opts.check) {\n const current = existsSync(outPath) ? readFileSync(outPath, \"utf8\") : \"\";\n if (current !== json) {\n log.error(`registry.json is out of date — run \\`registry build\\` and commit the result.`);\n return false;\n }\n log.success(`registry.json is up to date (${registry.skills.length} skills).`);\n return true;\n }\n\n writeFileSync(outPath, json, \"utf8\");\n log.success(`Wrote ${REGISTRY_FILENAME} (${registry.skills.length} skills).`);\n return true;\n}\n","import { z } from \"zod\";\nimport { SkillClassSchema, StabilitySchema } from \"./frontmatter\";\n\n/** One catalog entry. Generated from the skill tree by `registry build`. */\nexport const RegistryEntrySchema = z.object({\n name: z.string(),\n domain: z.string(),\n class: SkillClassSchema,\n category: z.string(),\n description: z.string(),\n platforms: z.array(z.string()),\n stability: StabilitySchema,\n version: z.string(),\n tags: z.array(z.string()).default([]),\n pairs_with: z.array(z.string()).default([]),\n /** path relative to the skills root. */\n path: z.string(),\n /** which on-demand resource files exist. */\n resources: z.object({\n reference: z.boolean(),\n examples: z.boolean(),\n checklist: z.boolean(),\n }),\n});\n\nexport const RegistrySchema = z.object({\n $schema: z.string().optional(),\n /** aggregate library version (bumped on release). */\n version: z.string().default(\"0.1.0\"),\n generatedAt: z.string().optional(),\n skills: z.array(RegistryEntrySchema).default([]),\n});\n\nexport type RegistryEntry = z.infer<typeof RegistryEntrySchema>;\nexport type Registry = z.infer<typeof RegistrySchema>;\n\nexport const REGISTRY_FILENAME = \"registry.json\";\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { resolveContent } from \"../content/source\";\nimport { claudeEmitter } from \"../emitters\";\nimport { applyFiles } from \"../core/writer\";\nimport type { EmitContext, EmittedFile, TargetId } from \"../types\";\nimport type { SkillClass } from \"../schema/frontmatter\";\nimport { log } from \"../util/log\";\n\nconst CLASS_LABEL: Record<SkillClass, string> = {\n code: \"code skills (frameworks & APIs)\",\n design: \"design-review skills\",\n \"lang-tooling\": \"language, build, test & ship skills\",\n overview: \"decision-guidance routers\",\n};\n\nconst CLASS_CATEGORY: Record<SkillClass, string> = {\n code: \"development\",\n design: \"design\",\n \"lang-tooling\": \"development\",\n overview: \"development\",\n};\n\nfunction pluginName(domain: string, cls: SkillClass): string {\n const clsSeg = cls === \"overview\" ? \"overviews\" : cls;\n return `skills-master-${domain}-${clsSeg}`;\n}\n\nfunction titleCase(s: string): string {\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\nexport interface MarketplaceBuildOptions {\n content?: string;\n cwd?: string;\n /** output root for .claude-plugin/ and plugins/ (defaults to the repo root above skills/). */\n out?: string;\n version?: string;\n}\n\nexport async function marketplaceBuildCommand(opts: MarketplaceBuildOptions): Promise<void> {\n const content = await resolveContent({ content: opts.content, cwd: opts.cwd });\n const out = resolve(opts.out ?? dirname(content.root));\n const version = opts.version ?? \"0.1.0\";\n\n // Group emitted files by (domain, class).\n const groups = new Map<string, { domain: string; cls: SkillClass; files: EmittedFile[]; count: number }>();\n\n for (const dir of content.skillDirs()) {\n const skill = content.loadSkill(dir.split(/[\\\\/]/).pop()!);\n const xm = skill.frontmatter[\"x-skills-master\"];\n const key = `${xm.domain}:${xm.class}`;\n const name = pluginName(xm.domain, xm.class);\n const ctx: EmitContext = {\n projectRoot: out,\n paths: {\n claude: `plugins/${name}/skills`,\n cursor: \"\",\n copilot: \"\",\n agents: \"\",\n } as Record<TargetId, string>,\n };\n const files = claudeEmitter.emit(skill, ctx);\n const g = groups.get(key) ?? { domain: xm.domain, cls: xm.class, files: [], count: 0 };\n g.files.push(...files);\n g.count += 1;\n groups.set(key, g);\n }\n\n const plugins: {\n name: string;\n source: string;\n description: string;\n version: string;\n category: string;\n }[] = [];\n\n for (const { domain, cls, files, count } of groups.values()) {\n const name = pluginName(domain, cls);\n applyFiles(out, files, { overwrite: true });\n\n const description = `${titleCase(domain)} ${CLASS_LABEL[cls]}.`;\n const pluginDir = join(out, \"plugins\", name, \".claude-plugin\");\n mkdirSync(pluginDir, { recursive: true });\n const manifest = {\n name,\n version,\n description,\n author: { name: \"skills-master contributors\" },\n };\n writeFileSync(join(pluginDir, \"plugin.json\"), JSON.stringify(manifest, null, 2) + \"\\n\", \"utf8\");\n\n plugins.push({ name, source: `./plugins/${name}`, description, version, category: CLASS_CATEGORY[cls] });\n log.info(`Built ${name} (${count} skills).`);\n }\n\n plugins.sort((a, b) => a.name.localeCompare(b.name));\n const marketplace = {\n $schema: \"https://www.schemastore.org/claude-code-marketplace.json\",\n name: \"skills-master\",\n owner: { name: \"skills-master contributors\" },\n plugins,\n };\n const mpDir = join(out, \".claude-plugin\");\n mkdirSync(mpDir, { recursive: true });\n writeFileSync(join(mpDir, \"marketplace.json\"), JSON.stringify(marketplace, null, 2) + \"\\n\", \"utf8\");\n log.success(`Wrote .claude-plugin/marketplace.json (${plugins.length} plugins).`);\n}\n","import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { resolveContent } from \"../content/source\";\nimport { CLASS_DIR, SkillClassSchema, type SkillClass } from \"../schema/frontmatter\";\nimport { log } from \"../util/log\";\n\nexport interface NewSkillOptions {\n /** \"domain/class/category/name\", e.g. \"apple/code/app-frameworks/swiftui-foo\". */\n spec: string;\n content?: string;\n cwd?: string;\n force?: boolean;\n}\n\nfunction template(domain: string, cls: SkillClass, category: string, name: string): string {\n const today = new Date().toISOString().slice(0, 10);\n return `---\nname: ${name}\ndescription: TODO — one-line, third person. Use when <triggers go here>.\nglobs:\n - \"**/*\"\ntags: []\nx-skills-master:\n domain: ${domain}\n class: ${cls}\n category: ${category}\n platforms: [${domain}]\n requires: {}\n pairs_with: []\n sources: []\n snapshot_date: \"${today}\"\n stability: emerging\n version: 0.1.0\n---\n\n## When to use\n\nTODO — when should an agent reach for this skill?\n\n## Core guidance\n\nTODO — the do/don't, idioms, and best practices (original prose, no copied docs).\n\n## Platform notes\n\nTODO — platform-specific caveats.\n\n## Pitfalls\n\nTODO — common mistakes.\n\n## References\n\n- **Documentation:** [TODO](https://developer.apple.com/documentation/...)\n- **Human Interface Guidelines:** [TODO](https://developer.apple.com/design/human-interface-guidelines/...)\n- **WWDC:** [TODO](https://developer.apple.com/videos/...)\n\n## See also\n\nTODO — paired skills referenced by name.\n`;\n}\n\nexport async function newSkillCommand(opts: NewSkillOptions): Promise<string> {\n const parts = opts.spec.split(\"/\").filter(Boolean);\n if (parts.length < 4) {\n throw new Error(`Expected \"domain/class/category/name\", got \"${opts.spec}\".`);\n }\n const domain = parts[0]!;\n const cls = SkillClassSchema.parse(parts[1]);\n const category = parts[2]!;\n const name = parts[parts.length - 1]!;\n\n const content = await resolveContent({ content: opts.content, cwd: opts.cwd });\n const dir = join(content.root, domain, CLASS_DIR[cls], ...parts.slice(2));\n const skillMd = join(dir, \"SKILL.md\");\n\n if (existsSync(skillMd) && !opts.force) {\n throw new Error(`Skill already exists at ${skillMd} (use --force to overwrite).`);\n }\n mkdirSync(dir, { recursive: true });\n writeFileSync(skillMd, template(domain, cls, category, name), \"utf8\");\n log.success(`Created ${skillMd}`);\n return skillMd;\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACejB,IAAM,cAA0B,CAAC,UAAU,UAAU,WAAW,QAAQ;AASxE,IAAM,iBAAiB;AAAA,EAC5B,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AACb;;;AC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AC7D,OAAO,iBAAiB,EACxB,OAAO,CAAC,SAAS,IAAI,MAAM,YAAY,EAAE,KAAK,QAAQ,IAAI,GAAG,SAAS,KAAK,QAAQ,CAAC,GAAG,IAAI,CAAC;AAE/F,QACG,QAAQ,YAAY,EACpB,YAAY,gEAAgE,EAC5E,OAAO,iBAAiB,EACxB,OAAO,SAAS,EAChB;AAAA,EAAO,CAAC,MAAM,SACb,IAAI,MAAM,gBAAgB,EAAE,KAAK,QAAQ,IAAI,GAAG,MAAM,SAAS,KAAK,SAAS,OAAO,KAAK,MAAM,CAAC,CAAC;AACnG;AAEF,IAAM,WAAW,QAAQ,QAAQ,UAAU,EAAE,YAAY,sBAAsB;AAC/E,SACG,QAAQ,OAAO,EACf,YAAY,4CAA4C,EACxD,OAAO,iBAAiB,EACxB,OAAO,WAAW,oDAAoD,EACtE,OAAO,eAAe,EACtB;AAAA,EAAO,CAAC,SACP;AAAA,IACE,MAAM,qBAAqB,EAAE,KAAK,QAAQ,IAAI,GAAG,SAAS,KAAK,SAAS,OAAO,KAAK,OAAO,SAAS,KAAK,QAAQ,CAAC;AAAA,IAClH;AAAA,EACF;AACF;AAEF,IAAM,cAAc,QAAQ,QAAQ,aAAa,EAAE,YAAY,gCAAgC;AAC/F,YACG,QAAQ,OAAO,EACf,YAAY,gEAAgE,EAC5E,OAAO,iBAAiB,EACxB,OAAO,eAAe,aAAa,EACnC,OAAO,eAAe,EACtB;AAAA,EAAO,CAAC,SACP;AAAA,IAAI,MACF,wBAAwB,EAAE,KAAK,QAAQ,IAAI,GAAG,SAAS,KAAK,SAAS,KAAK,KAAK,KAAK,SAAS,KAAK,QAAQ,CAAC;AAAA,EAC7G;AACF;AAEF,QAAQ,WAAW,QAAQ,IAAI;","names":["existsSync","join","z","join","existsSync","existsSync","readFileSync","basename","join","existsSync","join","existsSync","readFileSync","join","z","join","readFileSync","existsSync","basename","join","existsSync","readFileSync","existsSync","readFileSync","join","existsSync","readdirSync","readFileSync","writeFileSync","join","join","existsSync","writeFileSync","readFileSync","readdirSync","join","existsSync","readFileSync","existsSync","readFileSync","writeFileSync","join","registry","existsSync","readFileSync","join","existsSync","join","readFileSync","existsSync","readFileSync","writeFileSync","join","z","z","registry","join","existsSync","readFileSync","writeFileSync","mkdirSync","writeFileSync","dirname","join","resolve","resolve","dirname","join","mkdirSync","writeFileSync","marketplace","existsSync","mkdirSync","writeFileSync","join","today","join","existsSync","mkdirSync","writeFileSync"]}
|
|
1
|
+
{"version":3,"sources":["../src/bin.ts","../package.json","../src/types.ts","../src/schema/projectConfig.ts","../src/core/yaml.ts","../src/emitters/util.ts","../src/emitters/claude.ts","../src/core/condense.ts","../src/emitters/cursor.ts","../src/emitters/copilot.ts","../src/emitters/agents.ts","../src/emitters/index.ts","../src/core/project.ts","../src/schema/lockfile.ts","../src/util/log.ts","../src/commands/init.ts","../src/content/source.ts","../src/core/discover.ts","../src/core/parse.ts","../src/schema/frontmatter.ts","../src/core/registry-build.ts","../src/core/install.ts","../src/core/compile.ts","../src/core/writer.ts","../src/core/markers.ts","../src/core/hash.ts","../src/core/gitignore.ts","../src/commands/add.ts","../src/commands/update.ts","../src/commands/remove.ts","../src/commands/doctor.ts","../src/commands/catalog.ts","../src/core/lint.ts","../src/commands/lint.ts","../src/commands/registry.ts","../src/schema/registry.ts","../src/commands/marketplace.ts","../src/commands/new.ts"],"sourcesContent":["import { Command } from \"commander\";\n// Single source of truth for the version. release.yml rewrites this\n// package.json before running the build, so the bundle carries the\n// released version; a literal here would silently report a stale one.\nimport { version } from \"../package.json\";\nimport { ALL_TARGETS, type TargetId } from \"./types\";\nimport { initCommand } from \"./commands/init\";\nimport { addCommand } from \"./commands/add\";\nimport { updateCommand } from \"./commands/update\";\nimport { removeCommand } from \"./commands/remove\";\nimport { doctorCommand } from \"./commands/doctor\";\nimport { listCommand, searchCommand, viewCommand } from \"./commands/catalog\";\nimport { lintCommand } from \"./commands/lint\";\nimport { registryBuildCommand } from \"./commands/registry\";\nimport { marketplaceBuildCommand } from \"./commands/marketplace\";\nimport { newSkillCommand } from \"./commands/new\";\nimport { log } from \"./util/log\";\n\nconst VALID = new Set<string>(ALL_TARGETS);\n\nfunction parseTargets(value?: string): TargetId[] | undefined {\n if (!value) return undefined;\n if (value === \"all\") return ALL_TARGETS;\n const ids = value.split(\",\").map((s) => s.trim()).filter(Boolean);\n for (const id of ids) {\n if (!VALID.has(id)) {\n throw new Error(`Unknown target \"${id}\". Valid: ${[...VALID, \"all\"].join(\", \")}.`);\n }\n }\n return ids as TargetId[];\n}\n\nasync function run(fn: () => Promise<unknown> | unknown, exitOnFalse = false): Promise<void> {\n try {\n const result = await fn();\n if (exitOnFalse && result === false) process.exitCode = 1;\n } catch (err) {\n log.error(err instanceof Error ? err.message : String(err));\n process.exitCode = 1;\n }\n}\n\nconst program = new Command();\nprogram\n .name(\"skills-master\")\n .description(\"Install tool-agnostic Apple & Android development skills into any AI coding tool.\")\n .version(version);\n\nprogram\n .command(\"init\")\n .description(\"Detect tools and write skills-master.json\")\n .option(\"--target <list>\", \"comma list or 'all'\")\n .option(\"--ref <ref>\", \"content git ref\")\n .option(\"--no-commit\", \"gitignore generated files instead of committing them\")\n .option(\"--force\", \"overwrite an existing config\")\n .action((opts) =>\n run(() =>\n initCommand({\n cwd: process.cwd(),\n targets: parseTargets(opts.target),\n commit: opts.commit,\n contentRef: opts.ref,\n force: opts.force,\n }),\n ),\n );\n\nprogram\n .command(\"list\")\n .description(\"List available skills\")\n .option(\"--domain <domain>\", \"e.g. apple, android\")\n .option(\"--class <class>\")\n .option(\"--category <category>\")\n .option(\"--platform <platform>\")\n .option(\"--json\")\n .option(\"--content <dir>\", \"local skills directory\")\n .option(\"--ref <ref>\")\n .action((opts) =>\n run(() =>\n listCommand({\n cwd: process.cwd(),\n domain: opts.domain,\n class: opts.class,\n category: opts.category,\n platform: opts.platform,\n json: opts.json,\n content: opts.content,\n ref: opts.ref,\n }),\n ),\n );\n\nprogram\n .command(\"search <query>\")\n .description(\"Search skills by name, description, tags\")\n .option(\"--content <dir>\")\n .option(\"--ref <ref>\")\n .action((query, opts) =>\n run(() => searchCommand({ cwd: process.cwd(), query, content: opts.content, ref: opts.ref })),\n );\n\nprogram\n .command(\"view <name>\")\n .description(\"Show a skill's metadata and body\")\n .option(\"--raw\", \"print the raw SKILL.md body\")\n .option(\"--content <dir>\")\n .option(\"--ref <ref>\")\n .action((name, opts) =>\n run(() =>\n viewCommand({ cwd: process.cwd(), name, raw: opts.raw, content: opts.content, ref: opts.ref }),\n ),\n );\n\nprogram\n .command(\"add <names...>\")\n .description(\"Install skills (by name, category, or class) into your tools\")\n .option(\"--target <list>\", \"comma list or 'all'\")\n .option(\"--with-pairs\", \"also install paired (code<->design) skills\")\n .option(\"--dry-run\", \"preview without writing\")\n .option(\"--overwrite\", \"overwrite changed files without asking\")\n .option(\"--content <dir>\")\n .option(\"--ref <ref>\")\n .action((names, opts) =>\n run(() =>\n addCommand({\n cwd: process.cwd(),\n names,\n targets: parseTargets(opts.target),\n withPairs: opts.withPairs,\n dryRun: opts.dryRun,\n overwrite: opts.overwrite,\n content: opts.content,\n ref: opts.ref,\n }),\n ),\n );\n\nprogram\n .command(\"update [names...]\")\n .description(\"Re-install skills whose content changed\")\n .option(\"--dry-run\")\n .option(\"--overwrite\", \"force re-install, replacing local edits\")\n .option(\"--content <dir>\")\n .option(\"--ref <ref>\")\n .action((names, opts) =>\n run(() =>\n updateCommand({\n cwd: process.cwd(),\n names,\n dryRun: opts.dryRun,\n overwrite: opts.overwrite,\n content: opts.content,\n ref: opts.ref,\n }),\n ),\n );\n\nprogram\n .command(\"remove <names...>\")\n .description(\"Remove installed skills\")\n .option(\"--target <list>\", \"comma list or 'all'\")\n .option(\"--dry-run\")\n .action((names, opts) =>\n run(() =>\n removeCommand({ cwd: process.cwd(), names, targets: parseTargets(opts.target), dryRun: opts.dryRun }),\n ),\n );\n\nprogram\n .command(\"doctor\")\n .description(\"Check installed skills for drift and missing files\")\n .action(() => run(() => doctorCommand({ cwd: process.cwd() })));\n\nprogram\n .command(\"lint\")\n .description(\"Validate the skill library (maintainer command)\")\n .option(\"--content <dir>\")\n .action((opts) => run(() => lintCommand({ cwd: process.cwd(), content: opts.content }), true));\n\nprogram\n .command(\"new <spec>\")\n .description(\"Scaffold a new skill: class/category/name (maintainer command)\")\n .option(\"--content <dir>\")\n .option(\"--force\")\n .action((spec, opts) =>\n run(() => newSkillCommand({ cwd: process.cwd(), spec, content: opts.content, force: opts.force })),\n );\n\nconst registry = program.command(\"registry\").description(\"Registry maintenance\");\nregistry\n .command(\"build\")\n .description(\"Generate registry.json from the skill tree\")\n .option(\"--content <dir>\")\n .option(\"--check\", \"verify the committed registry.json is current (CI)\")\n .option(\"--version <v>\")\n .action((opts) =>\n run(\n () => registryBuildCommand({ cwd: process.cwd(), content: opts.content, check: opts.check, version: opts.version }),\n true,\n ),\n );\n\nconst marketplace = program.command(\"marketplace\").description(\"Claude marketplace maintenance\");\nmarketplace\n .command(\"build\")\n .description(\"Generate .claude-plugin/marketplace.json and per-class plugins\")\n .option(\"--content <dir>\")\n .option(\"--out <dir>\", \"output root\")\n .option(\"--check\", \"verify the committed marketplace output is current (CI)\")\n .option(\"--version <v>\")\n .action((opts) =>\n run(\n () =>\n marketplaceBuildCommand({\n cwd: process.cwd(),\n content: opts.content,\n out: opts.out,\n check: opts.check,\n version: opts.version,\n }),\n true,\n ),\n );\n\nprogram.parseAsync(process.argv);\n","{\n \"name\": \"@ichintansoni/skills-master\",\n \"version\": \"0.1.5\",\n \"description\": \"Install tool-agnostic Apple & Android development skills into any AI coding tool (Claude Code, Cursor, Copilot, AGENTS.md).\",\n \"keywords\": [\n \"skills\",\n \"apple\",\n \"swift\",\n \"swiftui\",\n \"android\",\n \"kotlin\",\n \"jetpack-compose\",\n \"material3\",\n \"claude\",\n \"cursor\",\n \"copilot\",\n \"agents.md\",\n \"ai\",\n \"agent\"\n ],\n \"license\": \"MIT\",\n \"author\": \"Chintan Soni\",\n \"homepage\": \"https://github.com/iChintanSoni/skills-master#readme\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/iChintanSoni/skills-master.git\",\n \"directory\": \"packages/cli\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/iChintanSoni/skills-master/issues\"\n },\n \"type\": \"module\",\n \"bin\": {\n \"skills-master\": \"./dist/bin.js\"\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsx src/bin.ts\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublishOnly\": \"tsup\"\n },\n \"dependencies\": {\n \"commander\": \"^15.0.0\",\n \"giget\": \"^3.3.1\",\n \"gray-matter\": \"^4.0.3\",\n \"semver\": \"^7.8.5\",\n \"yaml\": \"^2.5.1\",\n \"zod\": \"^4.4.3\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^26.1.0\",\n \"@types/semver\": \"^7.8.0\",\n \"tsup\": \"^8.3.0\",\n \"tsx\": \"^4.23.7\",\n \"typescript\": \"^6.0.3\",\n \"vitest\": \"^4.1.10\"\n }\n}\n","/**\n * Shared types for the skills-master compiler.\n *\n * The canonical authored unit is a *skill*: a directory containing a `SKILL.md`\n * (frontmatter + body) plus optional on-demand resource files. An *emitter*\n * projects a parsed skill into the files a particular AI tool expects.\n */\n\nimport type { Frontmatter } from \"./schema/frontmatter\";\n\nexport type { Frontmatter } from \"./schema/frontmatter\";\n\n/** The four AI-tool targets shipped at launch. */\nexport type TargetId = \"claude\" | \"cursor\" | \"copilot\" | \"agents\";\n\nexport const ALL_TARGETS: TargetId[] = [\"claude\", \"cursor\", \"copilot\", \"agents\"];\n\n/** On-demand \"Level 3\" resource files that may sit beside a SKILL.md. */\nexport interface SkillResources {\n reference?: string;\n examples?: string;\n checklist?: string;\n}\n\nexport const RESOURCE_FILES = {\n reference: \"reference.md\",\n examples: \"examples.md\",\n checklist: \"checklist.md\",\n} as const;\n\nexport type ResourceKey = keyof typeof RESOURCE_FILES;\n\n/** A skill after its SKILL.md and resource files have been read and validated. */\nexport interface ParsedSkill {\n /** kebab-case name; equals the leaf folder name. */\n name: string;\n /** absolute path to the skill's source directory. */\n dir: string;\n /** path relative to the skills root, e.g. `code/app-frameworks/swiftdata-modeling`. */\n relPath: string;\n /** validated, normalized frontmatter. */\n frontmatter: Frontmatter;\n /** markdown body (everything after the frontmatter). */\n body: string;\n /** raw text of any present resource files. */\n resources: SkillResources;\n}\n\n/**\n * Output file modes:\n * - `whole` — the emitter owns the entire file (overwrite as a unit).\n * - `block` — the emitter owns only a marked region inside a shared file.\n */\nexport type FileMode = \"whole\" | \"block\";\n\nexport interface EmittedFile {\n /** path relative to the consuming project root. */\n path: string;\n /** for `whole`: the full file contents. for `block`: the managed region body. */\n contents: string;\n mode: FileMode;\n /** required for `block` mode — identifies the managed region (usually the skill name). */\n blockId?: string;\n /** for `block` mode — written into the BEGIN marker for drift detection. */\n blockVersion?: string;\n}\n\nexport interface EmitContext {\n /** absolute path to the consuming project root. */\n projectRoot: string;\n /** effective per-target output paths (already merged with defaults). */\n paths: Record<TargetId, string>;\n}\n\nexport interface Emitter {\n id: TargetId | (string & {});\n /** human label for logs. */\n label: string;\n /** detect whether this tool is present in a project (used by auto-detect). */\n detect(projectRoot: string): boolean;\n /** project a skill into target files. */\n emit(skill: ParsedSkill, ctx: EmitContext): EmittedFile[];\n}\n\n/** Result of applying a single EmittedFile to disk. */\nexport type WriteAction = \"created\" | \"updated\" | \"unchanged\" | \"skipped\";\n\nexport interface WriteResult {\n path: string;\n mode: FileMode;\n blockId?: string;\n action: WriteAction;\n}\n","import { z } from \"zod\";\nimport type { TargetId } from \"../types\";\n\nexport const TargetIdSchema = z.enum([\"claude\", \"cursor\", \"copilot\", \"agents\"]);\n\n/** Default output location per target, relative to the project root. */\nexport const DEFAULT_PATHS: Record<TargetId, string> = {\n claude: \".claude/skills\",\n cursor: \".cursor/rules\",\n copilot: \".github\",\n agents: \"AGENTS.md\",\n};\n\nexport const ProjectConfigSchema = z\n .object({\n $schema: z.string().optional(),\n /** Git ref of the content repo to install from (tag/branch/sha). */\n contentRef: z.string().default(\"main\"),\n /**\n * Targets to emit. Empty array means \"auto-detect on every run\".\n */\n targets: z.array(TargetIdSchema).default([]),\n /** Per-target output path overrides (merged over DEFAULT_PATHS). */\n paths: z\n .object({\n claude: z.string(),\n cursor: z.string(),\n copilot: z.string(),\n agents: z.string(),\n })\n .partial()\n .default({}),\n scope: z.enum([\"project\"]).default(\"project\"),\n /** true = commit generated files; false = add them to .gitignore. */\n commit: z.boolean().default(true),\n })\n .strict();\n\nexport type ProjectConfig = z.infer<typeof ProjectConfigSchema>;\n\nexport const CONFIG_FILENAME = \"skills-master.json\";\nexport const LOCKFILE_NAME = \"skills-master.lock.json\";\n\n/** Resolve effective output paths by merging overrides over the defaults. */\nexport function resolvePaths(cfg: ProjectConfig): Record<TargetId, string> {\n return { ...DEFAULT_PATHS, ...cfg.paths } as Record<TargetId, string>;\n}\n","import YAML from \"yaml\";\n\n/**\n * Serialize a frontmatter object to a deterministic YAML block (no `---` fences).\n * Insertion order of keys is preserved, so emitters control field order.\n * Long strings are not wrapped (lineWidth: 0), keeping descriptions on one line.\n */\nexport function toYaml(obj: Record<string, unknown>): string {\n return YAML.stringify(obj, { lineWidth: 0 }).trimEnd();\n}\n\n/** Wrap a YAML block in `---` fences for embedding at the top of a Markdown file. */\nexport function frontmatterBlock(obj: Record<string, unknown>): string {\n return `---\\n${toYaml(obj)}\\n---`;\n}\n\n/**\n * Build a full Markdown document from a frontmatter object and a body.\n * Guarantees exactly one blank line between the frontmatter and the body.\n */\nexport function withFrontmatter(obj: Record<string, unknown>, body: string): string {\n return `${frontmatterBlock(obj)}\\n\\n${body.trim()}\\n`;\n}\n","import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { Frontmatter } from \"../schema/frontmatter\";\n\n/** True when `rel` exists under the project root (used for tool auto-detection). */\nexport function existsRel(root: string, rel: string): boolean {\n return existsSync(join(root, rel));\n}\n\nconst ACRONYMS: Record<string, string> = {\n hig: \"HIG\",\n ui: \"UI\",\n ml: \"ML\",\n ar: \"AR\",\n av: \"AV\",\n os: \"OS\",\n ci: \"CI\",\n cd: \"CD\",\n url: \"URL\",\n api: \"API\",\n sf: \"SF\",\n spm: \"SPM\",\n ios: \"iOS\",\n ipados: \"iPadOS\",\n macos: \"macOS\",\n tvos: \"tvOS\",\n visionos: \"visionOS\",\n watchos: \"watchOS\",\n};\n\n/** Human title derived from a kebab-case skill name (e.g. \"hig-sheets\" → \"HIG Sheets\"). */\nexport function titleFromName(name: string): string {\n return name\n .split(\"-\")\n .filter(Boolean)\n .map((w) => ACRONYMS[w] ?? w.charAt(0).toUpperCase() + w.slice(1))\n .join(\" \");\n}\n\n/** Comma-join a skill's globs, or undefined if it declares none. */\nexport function globsToString(fm: Frontmatter): string | undefined {\n const g = fm.globs;\n if (!g || g.length === 0) return undefined;\n return g.join(\",\");\n}\n\n/** True when the skill ships any on-demand resource files. */\nexport function hasResources(resources: {\n reference?: string;\n examples?: string;\n checklist?: string;\n}): boolean {\n return Boolean(resources.reference || resources.examples || resources.checklist);\n}\n","import { RESOURCE_FILES, type Emitter, type EmittedFile, type ResourceKey } from \"../types\";\nimport { withFrontmatter } from \"../core/yaml\";\nimport { existsRel } from \"./util\";\n\n/**\n * Claude Code emitter — the lossless, native projection.\n * Writes `.claude/skills/<name>/SKILL.md` plus verbatim copies of any resource\n * files, preserving progressive disclosure. The `x-skills-master` block is\n * dropped; the body (including links to resource files, which are co-located)\n * is kept exactly.\n */\nexport const claudeEmitter: Emitter = {\n id: \"claude\",\n label: \"Claude Code\",\n detect: (root) => existsRel(root, \".claude\"),\n emit(skill, ctx): EmittedFile[] {\n const dir = `${ctx.paths.claude}/${skill.name}`;\n const fm = {\n name: skill.frontmatter.name,\n description: skill.frontmatter.description,\n };\n const files: EmittedFile[] = [\n {\n path: `${dir}/SKILL.md`,\n contents: withFrontmatter(fm, skill.body),\n mode: \"whole\",\n },\n ];\n for (const key of Object.keys(RESOURCE_FILES) as ResourceKey[]) {\n const text = skill.resources[key];\n if (text) {\n files.push({\n path: `${dir}/${RESOURCE_FILES[key]}`,\n contents: text.trimEnd() + \"\\n\",\n mode: \"whole\",\n });\n }\n }\n return files;\n },\n};\n","/**\n * Condense a canonical SKILL.md body for single-file targets (Cursor, Copilot,\n * AGENTS.md) that cannot carry on-demand resource files.\n *\n * - Links to reference.md / examples.md / checklist.md are flattened to plain\n * text and a one-line pointer to the full skill is appended (\"drop-and-note\").\n * - The `## Open question` section can optionally be summarized to a single\n * tradeoff line for terse targets.\n */\n\n// The character classes deliberately exclude their own delimiters and newlines.\n// A link-text class of [^\\]]+ can match \"[\", which makes every \"[\" an overlapping\n// restart position and the whole scan quadratic on adversarial input\n// (CodeQL js/polynomial-redos). Excluding \"[\" keeps restarts disjoint, so\n// matching stays linear. Markdown link text may not span lines here either.\nconst L3_LINK_RE =\n /\\[([^\\][\\n]+)\\]\\((?:\\.\\/)?(reference|examples|checklist)\\.md(?:#[^()\\n]*)?\\)/g;\n\nexport interface CondenseOptions {\n /** \"keep\" (default) leaves the section intact; \"summarize\" collapses it. */\n openQuestion?: \"keep\" | \"summarize\";\n /** whether the source skill had any resource files (drives the pointer note). */\n hadResources?: boolean;\n /** how to refer to the full skill in the appended note. */\n fullSkillNote?: string;\n}\n\nconst DEFAULT_NOTE =\n \"Extended reference and worked examples are available in the full Claude Code skill for this topic.\";\n\nexport function condenseBody(body: string, opts: CondenseOptions = {}): string {\n let out = body;\n let strippedLink = false;\n\n out = out.replace(L3_LINK_RE, (_m, text: string) => {\n strippedLink = true;\n return text;\n });\n\n if (opts.openQuestion === \"summarize\") {\n out = summarizeOpenQuestion(out);\n }\n\n out = out.replace(/\\n{3,}/g, \"\\n\\n\").trim();\n\n if (opts.hadResources || strippedLink) {\n out += `\\n\\n> ${opts.fullSkillNote ?? DEFAULT_NOTE}`;\n }\n\n return out + \"\\n\";\n}\n\nfunction summarizeOpenQuestion(body: string): string {\n const re = /^## Open question[ \\t]*\\n([\\s\\S]*?)(?=\\n## |\\s*$)/m;\n return body.replace(re, (_m, section: string) => {\n const firstPara = section.trim().split(/\\n\\s*\\n/)[0]?.replace(/\\s+/g, \" \").trim() ?? \"\";\n return `## Open question\\n\\nTradeoff: ${firstPara}\\n`;\n });\n}\n","import { type Emitter, type EmittedFile } from \"../types\";\nimport { withFrontmatter } from \"../core/yaml\";\nimport { condenseBody } from \"../core/condense\";\nimport { existsRel, globsToString, hasResources } from \"./util\";\n\n/**\n * Cursor emitter — `.cursor/rules/<name>.mdc`, a single file.\n * Frontmatter is exactly the three fields Cursor understands:\n * - `globs` present → Auto-Attached rule\n * - `globs` absent → Agent-Requested rule (description-driven)\n * A skills library never sets `alwaysApply: true` (that would inject every\n * skill into every chat).\n */\nexport const cursorEmitter: Emitter = {\n id: \"cursor\",\n label: \"Cursor\",\n detect: (root) => existsRel(root, \".cursor\"),\n emit(skill, ctx): EmittedFile[] {\n const globs = globsToString(skill.frontmatter);\n const fm: Record<string, unknown> = {\n description: skill.frontmatter.description,\n };\n if (globs) fm.globs = globs;\n fm.alwaysApply = false;\n\n const body = condenseBody(skill.body, {\n openQuestion: \"keep\",\n hadResources: hasResources(skill.resources),\n });\n\n return [\n {\n path: `${ctx.paths.cursor}/${skill.name}.mdc`,\n contents: withFrontmatter(fm, body),\n mode: \"whole\",\n },\n ];\n },\n};\n","import { type Emitter, type EmittedFile } from \"../types\";\nimport { withFrontmatter } from \"../core/yaml\";\nimport { condenseBody } from \"../core/condense\";\nimport { existsRel, globsToString, hasResources, titleFromName } from \"./util\";\n\n/**\n * GitHub Copilot emitter — two outputs:\n * 1. `.github/instructions/<name>.instructions.md` (whole file) with the\n * required `applyTo` glob and the condensed body.\n * 2. a one-line pointer block in `.github/copilot-instructions.md` (managed\n * via sentinel markers) so the always-loaded root file stays small.\n */\nexport const copilotEmitter: Emitter = {\n id: \"copilot\",\n label: \"GitHub Copilot\",\n detect: (root) => existsRel(root, \".github\"),\n emit(skill, ctx): EmittedFile[] {\n const base = ctx.paths.copilot; // e.g. \".github\"\n const instructionsPath = `${base}/instructions/${skill.name}.instructions.md`;\n const applyTo = globsToString(skill.frontmatter) ?? \"**\";\n\n const fm = {\n applyTo,\n description: skill.frontmatter.description,\n };\n const body = condenseBody(skill.body, {\n openQuestion: \"keep\",\n hadResources: hasResources(skill.resources),\n });\n\n const pointer = `For ${titleFromName(skill.name)} guidance, see \\`${instructionsPath}\\`.`;\n\n return [\n {\n path: instructionsPath,\n contents: withFrontmatter(fm, body),\n mode: \"whole\",\n },\n {\n path: `${base}/copilot-instructions.md`,\n contents: pointer,\n mode: \"block\",\n blockId: skill.name,\n blockVersion: skill.frontmatter[\"x-skills-master\"].version,\n },\n ];\n },\n};\n","import { type Emitter, type EmittedFile } from \"../types\";\nimport { condenseBody } from \"../core/condense\";\nimport { existsRel, hasResources, titleFromName } from \"./util\";\n\n/**\n * AGENTS.md emitter — the broad cross-tool standard. Plain Markdown, no\n * frontmatter (per the spec). Each skill becomes a `###` section inside a\n * sentinel-managed block so installs compose and updates stay surgical.\n * Bodies are summarized aggressively (this file is read in full by many tools).\n */\nexport const agentsEmitter: Emitter = {\n id: \"agents\",\n label: \"AGENTS.md\",\n detect: (root) => existsRel(root, \"AGENTS.md\"),\n emit(skill, ctx): EmittedFile[] {\n const body = condenseBody(skill.body, {\n openQuestion: \"summarize\",\n hadResources: hasResources(skill.resources),\n });\n const section = `### ${titleFromName(skill.name)}\\n\\n${body.trim()}`;\n return [\n {\n path: ctx.paths.agents,\n contents: section,\n mode: \"block\",\n blockId: skill.name,\n blockVersion: skill.frontmatter[\"x-skills-master\"].version,\n },\n ];\n },\n};\n","import type { Emitter, TargetId } from \"../types\";\nimport { claudeEmitter } from \"./claude\";\nimport { cursorEmitter } from \"./cursor\";\nimport { copilotEmitter } from \"./copilot\";\nimport { agentsEmitter } from \"./agents\";\n\n/**\n * The emitter registry. Adding support for a new tool (Windsurf, Cline, …) is a\n * one-line change here plus a new emitter file — the rest of the pipeline is\n * generic over the `Emitter` interface.\n */\nexport const EMITTERS: Emitter[] = [\n claudeEmitter,\n cursorEmitter,\n copilotEmitter,\n agentsEmitter,\n];\n\nconst BY_ID = new Map<string, Emitter>(EMITTERS.map((e) => [e.id, e]));\n\nexport function getEmitter(id: string): Emitter | undefined {\n return BY_ID.get(id);\n}\n\n/** Detect which targets are present in a project. */\nexport function detectTargets(projectRoot: string): TargetId[] {\n return EMITTERS.filter((e) => e.detect(projectRoot)).map((e) => e.id as TargetId);\n}\n\nexport { claudeEmitter, cursorEmitter, copilotEmitter, agentsEmitter };\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n CONFIG_FILENAME,\n LOCKFILE_NAME,\n ProjectConfigSchema,\n type ProjectConfig,\n} from \"../schema/projectConfig\";\nimport { LockfileSchema, emptyLockfile, type Lockfile } from \"../schema/lockfile\";\n\nexport function configPath(root: string): string {\n return join(root, CONFIG_FILENAME);\n}\nexport function lockfilePath(root: string): string {\n return join(root, LOCKFILE_NAME);\n}\n\nexport function loadConfig(root: string): ProjectConfig | null {\n const p = configPath(root);\n if (!existsSync(p)) return null;\n return ProjectConfigSchema.parse(JSON.parse(readFileSync(p, \"utf8\")));\n}\n\n/** Load config, or return parsed defaults if none exists. */\nexport function loadConfigOrDefault(root: string): ProjectConfig {\n return loadConfig(root) ?? ProjectConfigSchema.parse({});\n}\n\nexport function saveConfig(root: string, cfg: ProjectConfig): void {\n const withSchema = { $schema: \"https://skills-master.dev/schema/config.json\", ...cfg };\n writeFileSync(configPath(root), JSON.stringify(withSchema, null, 2) + \"\\n\", \"utf8\");\n}\n\nexport function loadLockfile(root: string): Lockfile {\n const p = lockfilePath(root);\n if (!existsSync(p)) return emptyLockfile();\n return LockfileSchema.parse(JSON.parse(readFileSync(p, \"utf8\")));\n}\n\nexport function saveLockfile(root: string, lock: Lockfile): void {\n writeFileSync(lockfilePath(root), JSON.stringify(lock, null, 2) + \"\\n\", \"utf8\");\n}\n","import { z } from \"zod\";\n\n/** Records, per target, which files an install produced and their content hash. */\nexport const EmittedTargetSchema = z.object({\n /** whole-file outputs owned by this target for this skill. */\n files: z.array(z.string()).default([]),\n /** shared file this skill writes a managed block into (block-mode targets). */\n block: z.string().optional(),\n /** sha256 of the concatenated emitted contents, for drift detection. */\n hash: z.string(),\n});\n\nexport const LockedSkillSchema = z.object({\n /** resolved skill version at install time. */\n version: z.string(),\n /** sha256 of the canonical SKILL.md + resource files at install time. */\n sourceHash: z.string(),\n /** targets this skill was emitted to. */\n emitted: z.record(z.string(), EmittedTargetSchema),\n});\n\nexport const LockfileSchema = z.object({\n lockfileVersion: z.literal(1).default(1),\n contentRef: z.string().default(\"main\"),\n skills: z.record(z.string(), LockedSkillSchema).default({}),\n});\n\nexport type EmittedTarget = z.infer<typeof EmittedTargetSchema>;\nexport type LockedSkill = z.infer<typeof LockedSkillSchema>;\nexport type Lockfile = z.infer<typeof LockfileSchema>;\n\nexport function emptyLockfile(contentRef = \"main\"): Lockfile {\n return { lockfileVersion: 1, contentRef, skills: {} };\n}\n","/* Minimal, dependency-free logger so core modules don't couple to a prompt lib. */\n\nlet quiet = false;\nexport function setQuiet(v: boolean): void {\n quiet = v;\n}\n\nconst sym = {\n info: \"•\",\n ok: \"✓\",\n warn: \"!\",\n err: \"✗\",\n};\n\nexport const log = {\n plain(msg: string): void {\n if (!quiet) console.log(msg);\n },\n info(msg: string): void {\n if (!quiet) console.log(`${sym.info} ${msg}`);\n },\n success(msg: string): void {\n if (!quiet) console.log(`${sym.ok} ${msg}`);\n },\n warn(msg: string): void {\n if (!quiet) console.warn(`${sym.warn} ${msg}`);\n },\n error(msg: string): void {\n console.error(`${sym.err} ${msg}`);\n },\n};\n","import { ProjectConfigSchema, type ProjectConfig } from \"../schema/projectConfig\";\nimport { ALL_TARGETS, type TargetId } from \"../types\";\nimport { detectTargets } from \"../emitters\";\nimport { loadConfig, saveConfig } from \"../core/project\";\nimport { log } from \"../util/log\";\n\nexport interface InitOptions {\n cwd: string;\n /** explicit target set; if omitted, auto-detect (falling back to all). */\n targets?: TargetId[];\n commit?: boolean;\n contentRef?: string;\n force?: boolean;\n}\n\nexport function initCommand(opts: InitOptions): ProjectConfig {\n const existing = loadConfig(opts.cwd);\n if (existing && !opts.force) {\n log.warn(`skills-master.json already exists — leaving it untouched (use --force to overwrite).`);\n return existing;\n }\n\n let targets = opts.targets;\n if (!targets || targets.length === 0) {\n const detected = detectTargets(opts.cwd);\n if (detected.length > 0) {\n targets = detected;\n log.info(`Detected tools: ${detected.join(\", \")}`);\n } else {\n targets = ALL_TARGETS;\n log.info(`No tools detected — defaulting to all targets (${ALL_TARGETS.join(\", \")}).`);\n }\n }\n\n const cfg = ProjectConfigSchema.parse({\n contentRef: opts.contentRef ?? \"main\",\n targets,\n commit: opts.commit ?? true,\n });\n saveConfig(opts.cwd, cfg);\n log.success(`Wrote skills-master.json (targets: ${targets.join(\", \")}, commit: ${cfg.commit}).`);\n return cfg;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { basename, isAbsolute, join, resolve } from \"node:path\";\nimport { findSkillDirs } from \"../core/discover\";\nimport { loadSkill } from \"../core/parse\";\nimport { buildRegistry } from \"../core/registry-build\";\nimport type { Registry } from \"../schema/registry\";\nimport type { ParsedSkill } from \"../types\";\n\n/** Default content repo (override with SKILLS_MASTER_REPO). */\nconst DEFAULT_REPO = \"github:iChintanSoni/skills-master\";\n\n/** package.json `name` that identifies the skills-master content repo (dev checkout). */\nconst CONTENT_REPO_PACKAGE = \"skills-master-monorepo\";\n\n/** A resolved, on-disk skills tree the CLI reads from. */\nexport class ContentSource {\n constructor(public readonly root: string) {}\n\n skillDirs(): string[] {\n return findSkillDirs(this.root);\n }\n\n findDir(name: string): string | undefined {\n const dirs = this.skillDirs();\n return dirs.find((d) => basename(d) === name) ?? dirs.find((d) => safeName(d, this.root) === name);\n }\n\n loadSkill(name: string): ParsedSkill {\n const dir = this.findDir(name);\n if (!dir) throw new Error(`Skill \"${name}\" not found in content at ${this.root}`);\n return loadSkill(dir, this.root);\n }\n\n registry(): Registry {\n return buildRegistry(this.root);\n }\n}\n\nfunction safeName(dir: string, root: string): string {\n try {\n return loadSkill(dir, root).name;\n } catch {\n return \"\";\n }\n}\n\nexport interface ResolveContentOptions {\n /** explicit path to a local skills directory. */\n content?: string;\n /** git ref for remote fetch. */\n ref?: string;\n /** start dir for the upward repo search. */\n cwd?: string;\n}\n\n/**\n * Resolve where skill content lives, in priority order:\n * 1. explicit `--content <dir>`\n * 2. SKILLS_MASTER_CONTENT env var\n * 3. the skills-master content repo, if running inside it (dev convenience, searched upward)\n * 4. remote fetch via giget (published content)\n */\nexport async function resolveContent(opts: ResolveContentOptions = {}): Promise<ContentSource> {\n if (opts.content) {\n const root = isAbsolute(opts.content) ? opts.content : resolve(process.cwd(), opts.content);\n return new ContentSource(root);\n }\n const env = process.env.SKILLS_MASTER_CONTENT;\n if (env) return new ContentSource(resolve(env));\n\n const local = findLocalSkillsDir(opts.cwd ?? process.cwd());\n if (local) return new ContentSource(local);\n\n return new ContentSource(await fetchRemote(opts.ref ?? \"main\"));\n}\n\n/**\n * Walk upward looking for the skills-master content repo: a root whose\n * `package.json` name is {@link CONTENT_REPO_PACKAGE} and that has a `skills/`\n * subtree. Keying on the package name (not just any pnpm workspace with a\n * `skills/` dir) keeps an unrelated monorepo from hijacking content resolution.\n */\nfunction findLocalSkillsDir(start: string): string | null {\n let dir = resolve(start);\n for (let i = 0; i < 8; i++) {\n const candidate = join(dir, \"skills\");\n if (existsSync(candidate) && isContentRepoRoot(dir)) return candidate;\n const parent = resolve(dir, \"..\");\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/** True when `dir` is the skills-master monorepo root (by package.json name). */\nfunction isContentRepoRoot(dir: string): boolean {\n try {\n const pkg = JSON.parse(readFileSync(join(dir, \"package.json\"), \"utf8\")) as { name?: string };\n return pkg.name === CONTENT_REPO_PACKAGE;\n } catch {\n return false;\n }\n}\n\n/** Download the `skills/` subtree of the content repo to a local cache. */\nasync function fetchRemote(ref: string): Promise<string> {\n const repo = process.env.SKILLS_MASTER_REPO ?? DEFAULT_REPO;\n const cacheDir = join(homedir(), \".skills-master-cache\", ref.replace(/[^\\w.-]/g, \"_\"));\n const { downloadTemplate } = await import(\"giget\");\n const { dir } = await downloadTemplate(`${repo}/skills#${ref}`, {\n dir: cacheDir,\n force: true,\n forceClean: true,\n });\n return dir;\n}\n","import { existsSync, readdirSync, statSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\n\nconst SKILL_FILE = \"SKILL.md\";\nconst IGNORE = new Set([\"node_modules\", \".git\", \"dist\", \".cache\"]);\n\n/**\n * Recursively find every directory under `skillsRoot` that contains a SKILL.md.\n * Returns absolute directory paths, sorted for deterministic output.\n */\nexport function findSkillDirs(skillsRoot: string): string[] {\n const found: string[] = [];\n if (!existsSync(skillsRoot)) return found;\n\n const walk = (dir: string): void => {\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n if (entries.includes(SKILL_FILE)) found.push(dir);\n for (const entry of entries) {\n if (IGNORE.has(entry) || entry.startsWith(\".\")) continue;\n const full = join(dir, entry);\n let isDir = false;\n try {\n isDir = statSync(full).isDirectory();\n } catch {\n isDir = false;\n }\n if (isDir) walk(full);\n }\n };\n\n walk(skillsRoot);\n return found.sort();\n}\n\n/** Path of a skill dir relative to the skills root (uses forward slashes). */\nexport function relPathOf(skillsRoot: string, dir: string): string {\n return relative(skillsRoot, dir).split(/[\\\\/]/).join(\"/\");\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport matter from \"gray-matter\";\nimport { FrontmatterSchema, type Frontmatter } from \"../schema/frontmatter\";\nimport {\n RESOURCE_FILES,\n type ParsedSkill,\n type ResourceKey,\n type SkillResources,\n} from \"../types\";\nimport { relPathOf } from \"./discover\";\n\nexport interface RawSkill {\n dir: string;\n relPath: string;\n /** leaf folder name (the expected `name`). */\n folderName: string;\n /** unvalidated frontmatter object. */\n data: Record<string, unknown>;\n body: string;\n resources: SkillResources;\n skillMdPath: string;\n /** full unparsed SKILL.md text (used for YAML-hazard linting). */\n rawText: string;\n}\n\n/** Read a skill directory's SKILL.md and resource files without validating. */\nexport function loadRawSkill(dir: string, skillsRoot: string): RawSkill {\n const skillMdPath = join(dir, \"SKILL.md\");\n const rawText = readFileSync(skillMdPath, \"utf8\");\n const parsed = matter(rawText);\n\n const resources: SkillResources = {};\n for (const key of Object.keys(RESOURCE_FILES) as ResourceKey[]) {\n const p = join(dir, RESOURCE_FILES[key]);\n if (existsSync(p)) resources[key] = readFileSync(p, \"utf8\");\n }\n\n return {\n dir,\n relPath: relPathOf(skillsRoot, dir),\n folderName: basename(dir),\n data: parsed.data as Record<string, unknown>,\n body: parsed.content.replace(/^\\n+/, \"\").trimEnd(),\n resources,\n skillMdPath,\n rawText,\n };\n}\n\nexport class SkillValidationError extends Error {\n constructor(\n public readonly relPath: string,\n public readonly issues: string[],\n ) {\n super(`Invalid skill \"${relPath}\":\\n - ${issues.join(\"\\n - \")}`);\n this.name = \"SkillValidationError\";\n }\n}\n\n/** Validate raw frontmatter; returns the typed frontmatter or a list of issues. */\nexport function validateFrontmatter(\n data: Record<string, unknown>,\n): { ok: true; value: Frontmatter } | { ok: false; issues: string[] } {\n const result = FrontmatterSchema.safeParse(data);\n if (result.success) return { ok: true, value: result.data };\n const issues = result.error.issues.map((i) => {\n const path = i.path.join(\".\");\n return path ? `${path}: ${i.message}` : i.message;\n });\n return { ok: false, issues };\n}\n\n/** Load and validate a skill directory into a ParsedSkill (throws on failure). */\nexport function loadSkill(dir: string, skillsRoot: string): ParsedSkill {\n const raw = loadRawSkill(dir, skillsRoot);\n const validated = validateFrontmatter(raw.data);\n if (!validated.ok) throw new SkillValidationError(raw.relPath, validated.issues);\n return {\n name: validated.value.name,\n dir: raw.dir,\n relPath: raw.relPath,\n frontmatter: validated.value,\n body: raw.body,\n resources: raw.resources,\n };\n}\n","import { z } from \"zod\";\nimport semver from \"semver\";\n\n/** kebab-case, used for skill `name` and `pairs_with` references. */\nexport const NAME_RE = /^[a-z0-9-]{1,64}$/;\nexport const ISO_DATE_RE = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nexport const StabilitySchema = z.enum([\"stable\", \"emerging\", \"contested\"]);\nexport type Stability = z.infer<typeof StabilitySchema>;\n\n/**\n * Skill classes are reusable across domains (Apple, Android, web, …):\n * - code → produces compilable code\n * - design → produces UX/design critique (e.g. Apple HIG, Material)\n * - lang-tooling → cross-cutting language/build/test/ship guidance\n * - overview → decision-guidance routers\n */\nexport const SkillClassSchema = z.enum([\n \"code\",\n \"design\",\n \"lang-tooling\",\n \"overview\",\n]);\nexport type SkillClass = z.infer<typeof SkillClassSchema>;\n\n/** Maps a skill `class` to its directory name within a domain in `skills/<domain>/`. */\nexport const CLASS_DIR: Record<SkillClass, string> = {\n code: \"code\",\n design: \"design\",\n \"lang-tooling\": \"lang-tooling\",\n overview: \"overviews\",\n};\n\n/**\n * Our private metadata block. Stripped from every projected output.\n * Domain-agnostic by design: `domain` namespaces a technology ecosystem\n * (apple, android, web, …); `platforms` and `requires` are free-form so each\n * domain defines its own vocabulary (ios/android/wear-os; {ios:\"17\"} / {android:\"14\"}).\n */\nexport const XSkillsMasterSchema = z\n .object({\n domain: z.string().min(1),\n class: SkillClassSchema,\n category: z.string().min(1),\n platforms: z.array(z.string().min(1)).min(1),\n /** domain-defined version requirements, e.g. { ios: \"17\", swift: \"6.0\" }. */\n requires: z.record(z.string(), z.string()).optional(),\n pairs_with: z.array(z.string().regex(NAME_RE)).default([]),\n /** citation URLs to canonical docs — never verbatim content. */\n sources: z.array(z.string().url()).default([]),\n snapshot_date: z.string().regex(ISO_DATE_RE, \"must be an ISO date (YYYY-MM-DD)\"),\n stability: StabilitySchema,\n version: z\n .string()\n .refine((v) => semver.valid(v) != null, \"must be a valid semver version\"),\n })\n .strict();\nexport type XSkillsMaster = z.infer<typeof XSkillsMasterSchema>;\n\n/** `globs` may be authored as a string or array; normalized to an array. */\nconst GlobsSchema = z\n .union([z.string(), z.array(z.string())])\n .transform((g) => (Array.isArray(g) ? g : [g]))\n .optional();\n\nexport const FrontmatterSchema = z\n .object({\n name: z.string().regex(NAME_RE, \"must be kebab-case ([a-z0-9-], <=64 chars)\"),\n description: z\n .string()\n .min(1, \"description is required\")\n .max(1024, \"description must be <= 1024 characters\"),\n globs: GlobsSchema,\n tags: z.array(z.string()).default([]),\n \"x-skills-master\": XSkillsMasterSchema,\n })\n // Tolerate tool-native extras (e.g. allowed-tools) without failing validation.\n .passthrough();\nexport type Frontmatter = z.infer<typeof FrontmatterSchema>;\n","import { findSkillDirs } from \"./discover\";\nimport { loadSkill } from \"./parse\";\nimport type { Registry, RegistryEntry } from \"../schema/registry\";\n\n/**\n * Build the catalog from the skill tree. Output is deterministic (no timestamp)\n * so a committed `registry.json` can be drift-checked in CI.\n */\nexport function buildRegistry(skillsRoot: string, version = \"0.1.0\"): Registry {\n const dirs = findSkillDirs(skillsRoot);\n const skills: RegistryEntry[] = dirs.map((dir) => {\n const s = loadSkill(dir, skillsRoot);\n const xm = s.frontmatter[\"x-skills-master\"];\n return {\n name: s.name,\n domain: xm.domain,\n class: xm.class,\n category: xm.category,\n description: s.frontmatter.description,\n platforms: xm.platforms,\n stability: xm.stability,\n version: xm.version,\n tags: s.frontmatter.tags ?? [],\n pairs_with: xm.pairs_with,\n path: s.relPath,\n resources: {\n reference: Boolean(s.resources.reference),\n examples: Boolean(s.resources.examples),\n checklist: Boolean(s.resources.checklist),\n },\n };\n });\n skills.sort((a, b) => a.name.localeCompare(b.name));\n return {\n $schema: \"https://skills-master.dev/schema/registry.json\",\n version,\n skills,\n };\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ParsedSkill, TargetId } from \"../types\";\nimport type { LockedSkill } from \"../schema/lockfile\";\nimport { compileSkill } from \"./compile\";\nimport { applyFiles, type ApplyOptions, type DetailedWriteResult } from \"./writer\";\nimport { sha256 } from \"./hash\";\n\nexport interface InstallResult {\n name: string;\n version: string;\n results: DetailedWriteResult[];\n locked: LockedSkill;\n}\n\n/** Hash a skill's canonical source for drift detection. */\nexport function sourceHashOf(skill: ParsedSkill): string {\n const xm = skill.frontmatter[\"x-skills-master\"];\n return sha256(\n skill.relPath,\n xm.version,\n skill.frontmatter.description,\n skill.body,\n skill.resources.reference ?? \"\",\n skill.resources.examples ?? \"\",\n skill.resources.checklist ?? \"\",\n );\n}\n\n/**\n * Hash the given whole-file outputs as they currently exist on disk. Both the\n * lockfile (at install time) and the `update`/`doctor` drift checks use this\n * one function, so a clean install always reconciles.\n */\nexport function diskHash(projectRoot: string, relPaths: string[]): string {\n const sorted = [...relPaths].sort((a, b) => a.localeCompare(b));\n const parts: string[] = [];\n for (const p of sorted) {\n const abs = join(projectRoot, p);\n const contents = existsSync(abs) ? readFileSync(abs, \"utf8\") : \"<<missing>>\";\n parts.push(p, contents);\n }\n return sha256(...parts);\n}\n\n/** Compile a skill to the given targets and write the outputs to a project. */\nexport function installSkill(\n projectRoot: string,\n skill: ParsedSkill,\n targets: TargetId[],\n paths: Record<TargetId, string>,\n opts: ApplyOptions = {},\n): InstallResult {\n const compiled = compileSkill(skill, targets, { projectRoot, paths });\n const allFiles = compiled.flatMap((c) => c.files);\n const results = applyFiles(projectRoot, allFiles, opts);\n\n const emitted: LockedSkill[\"emitted\"] = {};\n for (const c of compiled) {\n const whole = c.files.filter((f) => f.mode === \"whole\").map((f) => f.path);\n const block = c.files.find((f) => f.mode === \"block\")?.path;\n // Hash covers only whole-file outputs (block files are marker-managed and\n // safe to reconcile). Computed from disk after writing so the lockfile\n // records what actually landed; in dry-run nothing is written or saved.\n const hash = opts.dryRun ? sha256(\"dry-run\", ...whole) : diskHash(projectRoot, whole);\n emitted[c.target] = { files: whole, ...(block ? { block } : {}), hash };\n }\n\n const version = skill.frontmatter[\"x-skills-master\"].version;\n return {\n name: skill.name,\n version,\n results,\n locked: { version, sourceHash: sourceHashOf(skill), emitted },\n };\n}\n","import type { EmitContext, EmittedFile, ParsedSkill, TargetId } from \"../types\";\nimport { getEmitter } from \"../emitters\";\n\nexport interface CompiledTarget {\n target: TargetId;\n files: EmittedFile[];\n}\n\n/** Run the emitters for the requested targets over a single skill. */\nexport function compileSkill(\n skill: ParsedSkill,\n targets: TargetId[],\n ctx: EmitContext,\n): CompiledTarget[] {\n const out: CompiledTarget[] = [];\n for (const target of targets) {\n const emitter = getEmitter(target);\n if (!emitter) throw new Error(`Unknown target: ${target}`);\n out.push({ target, files: emitter.emit(skill, ctx) });\n }\n return out;\n}\n","import { existsSync, mkdirSync, readdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { EmittedFile, WriteAction, WriteResult } from \"../types\";\nimport { hasBlock, removeBlock, upsertBlock } from \"./markers\";\n\nexport type ConflictChoice = \"overwrite\" | \"skip\";\n\nexport interface ApplyOptions {\n dryRun?: boolean;\n /** force-overwrite changed whole-files without asking. */\n overwrite?: boolean;\n /** called for a changed whole-file when neither overwrite nor dryRun is set. */\n onConflict?: (path: string) => ConflictChoice;\n}\n\nexport interface DetailedWriteResult extends WriteResult {\n /** previous file contents (whole-file) when it changed — for diff previews. */\n before?: string;\n /** new file contents (whole-file) when it changed. */\n after?: string;\n}\n\nfunction ensureDir(absPath: string): void {\n mkdirSync(dirname(absPath), { recursive: true });\n}\n\nfunction applyWhole(\n projectRoot: string,\n file: EmittedFile,\n opts: ApplyOptions,\n): DetailedWriteResult {\n const abs = join(projectRoot, file.path);\n const exists = existsSync(abs);\n const next = file.contents;\n\n if (!exists) {\n if (!opts.dryRun) {\n ensureDir(abs);\n writeFileSync(abs, next, \"utf8\");\n }\n return { path: file.path, mode: \"whole\", action: \"created\", after: next };\n }\n\n const current = readFileSync(abs, \"utf8\");\n if (current === next) {\n return { path: file.path, mode: \"whole\", action: \"unchanged\" };\n }\n\n // changed\n let choice: ConflictChoice = \"overwrite\";\n if (!opts.overwrite) {\n choice = opts.onConflict ? opts.onConflict(file.path) : opts.dryRun ? \"overwrite\" : \"skip\";\n }\n if (choice === \"skip\") {\n return { path: file.path, mode: \"whole\", action: \"skipped\", before: current, after: next };\n }\n if (!opts.dryRun) writeFileSync(abs, next, \"utf8\");\n return { path: file.path, mode: \"whole\", action: \"updated\", before: current, after: next };\n}\n\nfunction applyBlock(\n projectRoot: string,\n file: EmittedFile,\n opts: ApplyOptions,\n): DetailedWriteResult {\n const abs = join(projectRoot, file.path);\n const exists = existsSync(abs);\n const current = exists ? readFileSync(abs, \"utf8\") : \"\";\n const blockId = file.blockId!;\n const next = upsertBlock(current, blockId, file.contents, file.blockVersion);\n\n let action: WriteAction;\n if (current === next) action = \"unchanged\";\n else if (!exists || !hasBlock(current, blockId)) action = \"created\";\n else action = \"updated\";\n\n if (action !== \"unchanged\" && !opts.dryRun) {\n ensureDir(abs);\n writeFileSync(abs, next, \"utf8\");\n }\n return { path: file.path, mode: \"block\", blockId, action };\n}\n\n/** Apply a batch of emitted files to a project. */\nexport function applyFiles(\n projectRoot: string,\n files: EmittedFile[],\n opts: ApplyOptions = {},\n): DetailedWriteResult[] {\n return files.map((f) =>\n f.mode === \"block\" ? applyBlock(projectRoot, f, opts) : applyWhole(projectRoot, f, opts),\n );\n}\n\n/** Remove now-empty ancestor directories of the given files, up to (not incl.) the project root. */\nexport function pruneEmptyDirs(projectRoot: string, relFilePaths: string[], dryRun = false): void {\n if (dryRun) return;\n const seen = new Set<string>();\n for (const rel of relFilePaths) {\n let dir = dirname(join(projectRoot, rel));\n while (dir.startsWith(projectRoot) && dir !== projectRoot && !seen.has(dir)) {\n seen.add(dir);\n try {\n if (existsSync(dir) && readdirSync(dir).length === 0) {\n rmdirSync(dir);\n dir = dirname(dir);\n } else break;\n } catch {\n break;\n }\n }\n }\n}\n\n/** Remove a whole-file output. */\nexport function removeWholeFile(projectRoot: string, relPath: string, dryRun = false): boolean {\n const abs = join(projectRoot, relPath);\n if (!existsSync(abs)) return false;\n if (!dryRun) rmSync(abs);\n return true;\n}\n\n/**\n * Remove a managed block from a shared file. Deletes the file if it becomes\n * empty. Returns true if anything changed.\n */\nexport function removeBlockFromFile(\n projectRoot: string,\n relPath: string,\n blockId: string,\n dryRun = false,\n): boolean {\n const abs = join(projectRoot, relPath);\n if (!existsSync(abs)) return false;\n const current = readFileSync(abs, \"utf8\");\n if (!hasBlock(current, blockId)) return false;\n const next = removeBlock(current, blockId);\n if (!dryRun) {\n if (next.trim().length === 0) rmSync(abs);\n else writeFileSync(abs, next, \"utf8\");\n }\n return true;\n}\n","/**\n * Sentinel-marker management for shared files (AGENTS.md, copilot-instructions.md).\n *\n * A managed region looks like:\n *\n * <!-- BEGIN skills-master:<id> v<version> -->\n * ...generated content...\n * <!-- END skills-master:<id> -->\n *\n * Only the bytes between (and including) the markers are ever touched, so any\n * hand-written content elsewhere in the file is preserved.\n */\n\nconst PREFIX = \"skills-master\";\n\nfunction escapeRe(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nexport function beginMarker(id: string, version?: string): string {\n return version\n ? `<!-- BEGIN ${PREFIX}:${id} v${version} -->`\n : `<!-- BEGIN ${PREFIX}:${id} -->`;\n}\n\nexport function endMarker(id: string): string {\n return `<!-- END ${PREFIX}:${id} -->`;\n}\n\nfunction blockRegex(id: string): RegExp {\n const esc = escapeRe(id);\n return new RegExp(\n `[ \\\\t]*<!-- BEGIN ${PREFIX}:${esc}(?: v[^>]*)? -->[\\\\s\\\\S]*?<!-- END ${PREFIX}:${esc} -->`,\n );\n}\n\n/** Build a complete managed block (markers + body). */\nexport function renderBlock(id: string, body: string, version?: string): string {\n return `${beginMarker(id, version)}\\n${body.trim()}\\n${endMarker(id)}`;\n}\n\nexport function hasBlock(file: string, id: string): boolean {\n return blockRegex(id).test(file);\n}\n\n/** Read the inner body of a managed block, or null if absent. */\nexport function readBlock(file: string, id: string): string | null {\n const m = blockRegex(id).exec(file);\n if (!m) return null;\n const inner = m[0]\n .replace(new RegExp(`^[ \\\\t]*<!-- BEGIN ${PREFIX}:${escapeRe(id)}(?: v[^>]*)? -->\\\\n?`), \"\")\n .replace(new RegExp(`\\\\n?<!-- END ${PREFIX}:${escapeRe(id)} -->$`), \"\");\n return inner;\n}\n\n/** Read the version recorded in a block's BEGIN marker, or null. */\nexport function readBlockVersion(file: string, id: string): string | null {\n const m = new RegExp(\n `<!-- BEGIN ${PREFIX}:${escapeRe(id)} v([^\\\\s>]+) -->`,\n ).exec(file);\n return m && m[1] ? m[1] : null;\n}\n\n/**\n * Insert or replace a managed block. Returns the new file contents.\n * If the block is absent it is appended, separated by a blank line.\n */\nexport function upsertBlock(\n file: string,\n id: string,\n body: string,\n version?: string,\n): string {\n const block = renderBlock(id, body, version);\n const re = blockRegex(id);\n if (re.test(file)) {\n return file.replace(re, block);\n }\n const base = file.replace(/\\s+$/, \"\");\n if (base.length === 0) return block + \"\\n\";\n return `${base}\\n\\n${block}\\n`;\n}\n\n/**\n * Remove a managed block (and a trailing blank line). Returns the new contents.\n * If the file becomes empty (only whitespace), returns the empty string so the\n * caller can delete it.\n */\nexport function removeBlock(file: string, id: string): string {\n const re = new RegExp(blockRegex(id).source + `\\\\n?\\\\n?`);\n const next = file.replace(re, \"\");\n return next.trim().length === 0 ? \"\" : next.replace(/\\n{3,}/g, \"\\n\\n\").trimEnd() + \"\\n\";\n}\n","import { createHash } from \"node:crypto\";\n\n/** Deterministic sha256 of one or more strings, prefixed `sha256:`. */\nexport function sha256(...parts: string[]): string {\n const h = createHash(\"sha256\");\n for (const p of parts) {\n h.update(p, \"utf8\");\n h.update(\"\u0000\"); // domain separator between parts\n }\n return \"sha256:\" + h.digest(\"hex\");\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n/** Ensure each entry appears in the project's .gitignore (idempotent). */\nexport function ensureGitignored(root: string, entries: string[]): void {\n const p = join(root, \".gitignore\");\n const current = existsSync(p) ? readFileSync(p, \"utf8\") : \"\";\n const lines = new Set(current.split(\"\\n\").map((l) => l.trim()));\n const missing = entries.filter((e) => !lines.has(e));\n if (missing.length === 0) return;\n const header = current.includes(\"# skills-master\") ? \"\" : \"\\n# skills-master generated outputs\\n\";\n const next = current.replace(/\\s*$/, \"\") + header + missing.join(\"\\n\") + \"\\n\";\n writeFileSync(p, next, \"utf8\");\n}\n","import { resolvePaths } from \"../schema/projectConfig\";\nimport { ALL_TARGETS, type TargetId } from \"../types\";\nimport { detectTargets } from \"../emitters\";\nimport { resolveContent } from \"../content/source\";\nimport { installSkill } from \"../core/install\";\nimport {\n loadConfig,\n loadConfigOrDefault,\n loadLockfile,\n saveConfig,\n saveLockfile,\n} from \"../core/project\";\nimport { ensureGitignored } from \"../core/gitignore\";\nimport type { ConflictChoice } from \"../core/writer\";\nimport { log } from \"../util/log\";\n\nexport interface AddOptions {\n cwd: string;\n /** skill names, category names, or class names to install. */\n names: string[];\n targets?: TargetId[];\n content?: string;\n ref?: string;\n withPairs?: boolean;\n dryRun?: boolean;\n overwrite?: boolean;\n /** interactive conflict resolver (bin supplies this on a TTY). */\n onConflict?: (path: string) => ConflictChoice;\n}\n\nexport interface AddResult {\n targets: TargetId[];\n installed: { name: string; version: string }[];\n skipped: string[];\n}\n\nexport async function addCommand(opts: AddOptions): Promise<AddResult> {\n const cfg = loadConfigOrDefault(opts.cwd);\n const hadConfig = loadConfig(opts.cwd) != null;\n\n let targets = opts.targets?.length ? opts.targets : cfg.targets;\n if (!targets.length) targets = detectTargets(opts.cwd);\n if (!targets.length) targets = ALL_TARGETS;\n\n const content = await resolveContent({\n content: opts.content,\n ref: opts.ref ?? cfg.contentRef,\n cwd: opts.cwd,\n });\n const registry = content.registry();\n const byName = new Map(registry.skills.map((s) => [s.name, s]));\n\n // Resolve tokens → concrete skill names (name > category > class).\n const selected = new Set<string>();\n const skipped: string[] = [];\n for (const token of opts.names) {\n if (byName.has(token)) {\n selected.add(token);\n continue;\n }\n const byCategory = registry.skills.filter((s) => s.category === token);\n const byClass = registry.skills.filter((s) => s.class === token);\n const group = byCategory.length ? byCategory : byClass;\n if (group.length) {\n group.forEach((s) => selected.add(s.name));\n } else {\n log.warn(`No skill, category, or class matches \"${token}\".`);\n skipped.push(token);\n }\n }\n\n if (opts.withPairs) {\n for (const name of [...selected]) {\n for (const pair of byName.get(name)?.pairs_with ?? []) {\n if (byName.has(pair)) selected.add(pair);\n else log.warn(`Paired skill \"${pair}\" (from \"${name}\") is not in the registry.`);\n }\n }\n }\n\n if (selected.size === 0) {\n log.error(\"Nothing to install.\");\n return { targets, installed: [], skipped };\n }\n\n const paths = resolvePaths(cfg);\n const lock = loadLockfile(opts.cwd);\n lock.contentRef = opts.ref ?? cfg.contentRef;\n const installed: { name: string; version: string }[] = [];\n\n const prefix = opts.dryRun ? \"[dry-run] \" : \"\";\n for (const name of [...selected].sort()) {\n const skill = content.loadSkill(name);\n const result = installSkill(opts.cwd, skill, targets, paths, {\n dryRun: opts.dryRun,\n overwrite: opts.overwrite,\n onConflict: opts.onConflict,\n });\n if (!opts.dryRun) lock.skills[name] = result.locked;\n installed.push({ name, version: result.version });\n\n for (const r of result.results) {\n const tag = r.mode === \"block\" ? `${r.path} [${r.blockId}]` : r.path;\n log.info(`${prefix}${r.action.padEnd(9)} ${tag}`);\n }\n }\n\n if (!opts.dryRun) {\n saveLockfile(opts.cwd, lock);\n if (!hadConfig) {\n saveConfig(opts.cwd, { ...cfg, targets });\n log.info(\"Wrote skills-master.json.\");\n }\n if (!cfg.commit) {\n const outs = targets.map((t) => paths[t]);\n ensureGitignored(opts.cwd, outs);\n }\n }\n\n log.success(\n `${prefix}Installed ${installed.length} skill(s) into ${targets.length} target(s): ${targets.join(\", \")}.`,\n );\n return { targets, installed, skipped };\n}\n","import { resolvePaths } from \"../schema/projectConfig\";\nimport type { TargetId } from \"../types\";\nimport { resolveContent } from \"../content/source\";\nimport { diskHash, installSkill, sourceHashOf } from \"../core/install\";\nimport { loadConfigOrDefault, loadLockfile, saveLockfile } from \"../core/project\";\nimport type { ConflictChoice } from \"../core/writer\";\nimport { log } from \"../util/log\";\n\nexport interface UpdateOptions {\n cwd: string;\n names?: string[];\n content?: string;\n ref?: string;\n dryRun?: boolean;\n overwrite?: boolean;\n onConflict?: (path: string) => ConflictChoice;\n}\n\nexport interface UpdateResult {\n updated: string[];\n upToDate: string[];\n skipped: string[];\n}\n\nexport async function updateCommand(opts: UpdateOptions): Promise<UpdateResult> {\n const cfg = loadConfigOrDefault(opts.cwd);\n const lock = loadLockfile(opts.cwd);\n const ref = opts.ref ?? cfg.contentRef;\n const updated: string[] = [];\n const upToDate: string[] = [];\n const skipped: string[] = [];\n\n const names = opts.names?.length ? opts.names : Object.keys(lock.skills);\n if (names.length === 0) {\n log.info(\"No installed skills to update.\");\n return { updated, upToDate, skipped };\n }\n\n const content = await resolveContent({ content: opts.content, ref, cwd: opts.cwd });\n const paths = resolvePaths(cfg);\n const prefix = opts.dryRun ? \"[dry-run] \" : \"\";\n\n for (const name of names.sort()) {\n const locked = lock.skills[name];\n if (!locked) {\n log.warn(`\"${name}\" is not installed — run \\`add\\` first.`);\n skipped.push(name);\n continue;\n }\n\n let skill;\n try {\n skill = content.loadSkill(name);\n } catch {\n log.warn(`\"${name}\" no longer exists in the content library.`);\n skipped.push(name);\n continue;\n }\n\n const refChanged = lock.contentRef !== ref;\n const sourceChanged = locked.sourceHash !== sourceHashOf(skill);\n if (!opts.overwrite && !sourceChanged && !refChanged) {\n upToDate.push(name);\n continue;\n }\n\n // Re-emit to exactly the targets this skill was installed to.\n const targets = Object.keys(locked.emitted) as TargetId[];\n\n // Detect user edits to owned whole-files since install.\n const userEdited = targets.some((t) => {\n const e = locked.emitted[t];\n return e && diskHash(opts.cwd, e.files) !== e.hash;\n });\n if (userEdited && !opts.overwrite && !opts.onConflict) {\n log.warn(`${prefix}\"${name}\" has local edits — skipping (use --overwrite to replace).`);\n skipped.push(name);\n continue;\n }\n\n const result = installSkill(opts.cwd, skill, targets, paths, {\n dryRun: opts.dryRun,\n overwrite: opts.overwrite || !userEdited,\n onConflict: opts.onConflict,\n });\n if (!opts.dryRun) lock.skills[name] = result.locked;\n updated.push(name);\n for (const r of result.results) {\n if (r.action === \"unchanged\") continue;\n const tag = r.mode === \"block\" ? `${r.path} [${r.blockId}]` : r.path;\n log.info(`${prefix}${r.action.padEnd(9)} ${tag}`);\n }\n }\n\n if (!opts.dryRun) {\n lock.contentRef = ref;\n saveLockfile(opts.cwd, lock);\n }\n\n log.success(\n `${prefix}Updated ${updated.length}, up-to-date ${upToDate.length}, skipped ${skipped.length}.`,\n );\n return { updated, upToDate, skipped };\n}\n","import type { TargetId } from \"../types\";\nimport { loadLockfile, saveLockfile } from \"../core/project\";\nimport { pruneEmptyDirs, removeBlockFromFile, removeWholeFile } from \"../core/writer\";\nimport { log } from \"../util/log\";\n\nexport interface RemoveOptions {\n cwd: string;\n names: string[];\n /** restrict removal to specific targets; default = every target the skill was installed to. */\n targets?: TargetId[];\n dryRun?: boolean;\n}\n\nexport interface RemoveResult {\n removed: string[];\n missing: string[];\n}\n\nexport function removeCommand(opts: RemoveOptions): RemoveResult {\n const lock = loadLockfile(opts.cwd);\n const removed: string[] = [];\n const missing: string[] = [];\n const prefix = opts.dryRun ? \"[dry-run] \" : \"\";\n\n for (const name of opts.names) {\n const locked = lock.skills[name];\n if (!locked) {\n log.warn(`\"${name}\" is not installed.`);\n missing.push(name);\n continue;\n }\n\n const targets = (opts.targets?.length\n ? opts.targets\n : (Object.keys(locked.emitted) as TargetId[])\n ).filter((t) => locked.emitted[t]);\n\n const wholeRemoved: string[] = [];\n for (const t of targets) {\n const e = locked.emitted[t]!;\n for (const file of e.files) {\n if (removeWholeFile(opts.cwd, file, opts.dryRun)) {\n wholeRemoved.push(file);\n log.info(`${prefix}removed ${file}`);\n }\n }\n if (e.block && removeBlockFromFile(opts.cwd, e.block, name, opts.dryRun)) {\n log.info(`${prefix}unblocked ${e.block} [${name}]`);\n }\n if (!opts.dryRun) delete locked.emitted[t];\n }\n pruneEmptyDirs(opts.cwd, wholeRemoved, opts.dryRun);\n\n if (!opts.dryRun) {\n if (Object.keys(locked.emitted).length === 0) delete lock.skills[name];\n }\n removed.push(name);\n }\n\n if (!opts.dryRun) saveLockfile(opts.cwd, lock);\n log.success(`${prefix}Removed ${removed.length} skill(s).`);\n return { removed, missing };\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { diskHash } from \"../core/install\";\nimport { loadConfig, loadLockfile } from \"../core/project\";\nimport { hasBlock } from \"../core/markers\";\nimport { log } from \"../util/log\";\n\nexport interface DoctorOptions {\n cwd: string;\n}\n\nexport interface DoctorReport {\n problems: string[];\n ok: boolean;\n}\n\nexport function doctorCommand(opts: DoctorOptions): DoctorReport {\n const problems: string[] = [];\n const note = (msg: string) => problems.push(msg);\n\n const cfg = loadConfig(opts.cwd);\n if (!cfg) {\n log.warn(\"No skills-master.json found — run `skills-master init`.\");\n } else {\n log.info(`Config targets: ${cfg.targets.length ? cfg.targets.join(\", \") : \"(auto-detect)\"}`);\n }\n\n const lock = loadLockfile(opts.cwd);\n const names = Object.keys(lock.skills);\n if (names.length === 0) {\n log.info(\"No skills installed.\");\n return { problems, ok: true };\n }\n\n for (const name of names) {\n const locked = lock.skills[name]!;\n for (const [target, e] of Object.entries(locked.emitted)) {\n for (const file of e.files) {\n if (!existsSync(join(opts.cwd, file))) note(`${name}: missing ${target} file ${file}`);\n }\n if (e.files.every((f) => existsSync(join(opts.cwd, f)))) {\n if (diskHash(opts.cwd, e.files) !== e.hash) {\n note(`${name}: local edits to ${target} output(s) (run \\`update --overwrite\\` to reset)`);\n }\n }\n if (e.block) {\n const abs = join(opts.cwd, e.block);\n if (!existsSync(abs) || !hasBlock(readFileSync(abs, \"utf8\"), name)) {\n note(`${name}: missing managed block in ${e.block}`);\n }\n }\n }\n }\n\n if (problems.length === 0) {\n log.success(`All ${names.length} installed skill(s) look healthy.`);\n } else {\n for (const p of problems) log.warn(p);\n log.plain(`\\n${problems.length} problem(s) found.`);\n }\n return { problems, ok: problems.length === 0 };\n}\n","import { resolveContent } from \"../content/source\";\nimport type { Registry, RegistryEntry } from \"../schema/registry\";\nimport { log } from \"../util/log\";\n\nexport interface CatalogQuery {\n content?: string;\n ref?: string;\n cwd?: string;\n}\n\nasync function registryOf(q: CatalogQuery): Promise<Registry> {\n const content = await resolveContent({ content: q.content, ref: q.ref, cwd: q.cwd });\n return content.registry();\n}\n\nexport interface ListOptions extends CatalogQuery {\n domain?: string;\n class?: string;\n category?: string;\n platform?: string;\n json?: boolean;\n}\n\nexport async function listCommand(opts: ListOptions): Promise<RegistryEntry[]> {\n const reg = await registryOf(opts);\n let skills = reg.skills;\n if (opts.domain) skills = skills.filter((s) => s.domain === opts.domain);\n if (opts.class) skills = skills.filter((s) => s.class === opts.class);\n if (opts.category) skills = skills.filter((s) => s.category === opts.category);\n if (opts.platform) {\n const platform = opts.platform;\n skills = skills.filter((s) => s.platforms.includes(platform));\n }\n\n if (opts.json) {\n log.plain(JSON.stringify(skills, null, 2));\n return skills;\n }\n\n if (skills.length === 0) {\n log.info(\"No skills match.\");\n return skills;\n }\n\n const groups = new Map<string, RegistryEntry[]>();\n for (const s of skills) {\n const key = `${s.domain}/${s.class}/${s.category}`;\n (groups.get(key) ?? groups.set(key, []).get(key)!).push(s);\n }\n for (const [group, entries] of [...groups].sort()) {\n log.plain(`\\n${group}`);\n for (const s of entries) {\n const flag = s.stability === \"stable\" ? \"\" : ` (${s.stability})`;\n log.plain(` ${s.name} v${s.version}${flag}`);\n log.plain(` ${truncate(s.description, 96)}`);\n }\n }\n log.plain(`\\n${skills.length} skill(s).`);\n return skills;\n}\n\nexport interface SearchOptions extends CatalogQuery {\n query: string;\n}\n\nexport async function searchCommand(opts: SearchOptions): Promise<RegistryEntry[]> {\n const reg = await registryOf(opts);\n const q = opts.query.toLowerCase();\n const hits = reg.skills.filter((s) =>\n [s.name, s.description, s.domain, s.category, s.class, ...s.tags]\n .join(\" \")\n .toLowerCase()\n .includes(q),\n );\n if (hits.length === 0) {\n log.info(`No matches for \"${opts.query}\".`);\n return hits;\n }\n for (const s of hits) {\n log.plain(`${s.name} (${s.class}/${s.category}) v${s.version}`);\n log.plain(` ${truncate(s.description, 96)}`);\n }\n log.plain(`\\n${hits.length} match(es).`);\n return hits;\n}\n\nexport interface ViewOptions extends CatalogQuery {\n name: string;\n raw?: boolean;\n}\n\nexport async function viewCommand(opts: ViewOptions): Promise<void> {\n const content = await resolveContent({ content: opts.content, ref: opts.ref, cwd: opts.cwd });\n const skill = content.loadSkill(opts.name);\n const xm = skill.frontmatter[\"x-skills-master\"];\n if (opts.raw) {\n log.plain(skill.body);\n return;\n }\n log.plain(`${skill.name} v${xm.version} [${xm.domain}/${xm.class}/${xm.category}] ${xm.stability}`);\n log.plain(`platforms: ${xm.platforms.join(\", \")}`);\n if (xm.requires) {\n log.plain(`requires: ${Object.entries(xm.requires).map(([k, v]) => `${k} ${v}`).join(\", \")}`);\n }\n if (xm.pairs_with.length) log.plain(`pairs with: ${xm.pairs_with.join(\", \")}`);\n log.plain(`\\n${skill.frontmatter.description}\\n`);\n log.plain(`sources:`);\n for (const url of xm.sources) log.plain(` ${url}`);\n const res = Object.entries(skill.resources).filter(([, v]) => v).map(([k]) => k);\n if (res.length) log.plain(`\\nresource files: ${res.join(\", \")}`);\n}\n\nfunction truncate(s: string, n: number): string {\n return s.length <= n ? s : s.slice(0, n - 1) + \"…\";\n}\n","import type { Frontmatter } from \"../schema/frontmatter\";\nimport { findSkillDirs, relPathOf } from \"./discover\";\nimport { loadRawSkill, validateFrontmatter } from \"./parse\";\n\nexport type DiagnosticLevel = \"error\" | \"warn\";\n\nexport interface Diagnostic {\n relPath: string;\n level: DiagnosticLevel;\n message: string;\n}\n\nexport interface LintResult {\n diagnostics: Diagnostic[];\n skillCount: number;\n errorCount: number;\n warnCount: number;\n}\n\nconst CANONICAL_HEADINGS = [\n \"## When to use\",\n \"## Core guidance\",\n \"## Pitfalls\",\n \"## References\",\n \"## See also\",\n];\nconst MAX_BODY_LINES = 500;\nconst WARN_BODY_LINES = 450;\n\nfunction today(): string {\n return new Date().toISOString().slice(0, 10);\n}\n\ninterface Loaded {\n relPath: string;\n folderName: string;\n fm?: Frontmatter;\n body: string;\n}\n\nexport function lintSkills(skillsRoot: string): LintResult {\n const dirs = findSkillDirs(skillsRoot);\n const diagnostics: Diagnostic[] = [];\n const loaded: Loaded[] = [];\n const byName = new Map<string, Frontmatter>();\n\n for (const dir of dirs) {\n let raw;\n try {\n raw = loadRawSkill(dir, skillsRoot);\n } catch (err) {\n diagnostics.push({\n relPath: relPathOf(skillsRoot, dir),\n level: \"error\",\n message: `failed to parse SKILL.md: ${err instanceof Error ? err.message.split(\"\\n\")[0] : String(err)}`,\n });\n continue;\n }\n\n // YAML hazard: an unquoted scalar containing \" #\" is silently truncated as\n // a comment (e.g. \"@Test, #expect\" loses everything from \"#expect\" on).\n for (const line of raw.rawText.split(\"\\n\")) {\n const m = /^(\\s*)(name|description|category):\\s+(?![\"'])(.*\\s#.*)$/.exec(line);\n if (m) {\n diagnostics.push({\n relPath: raw.relPath,\n level: \"warn\",\n message: `frontmatter \"${m[2]}\" contains \" #\", which YAML reads as a comment — quote the value`,\n });\n }\n }\n\n const v = validateFrontmatter(raw.data);\n if (!v.ok) {\n for (const issue of v.issues) {\n diagnostics.push({ relPath: raw.relPath, level: \"error\", message: issue });\n }\n loaded.push({ relPath: raw.relPath, folderName: raw.folderName, body: raw.body });\n continue;\n }\n loaded.push({ relPath: raw.relPath, folderName: raw.folderName, fm: v.value, body: raw.body });\n byName.set(v.value.name, v.value);\n }\n\n // Skill names must be globally unique (the registry and `add` key on name).\n const nameDirs = new Map<string, string[]>();\n for (const s of loaded) {\n const n = s.fm?.name ?? s.folderName;\n (nameDirs.get(n) ?? nameDirs.set(n, []).get(n)!).push(s.relPath);\n }\n for (const [name, paths] of nameDirs) {\n if (paths.length > 1) {\n for (const p of paths) {\n diagnostics.push({ relPath: p, level: \"error\", message: `duplicate skill name \"${name}\" (also at ${paths.filter((x) => x !== p).join(\", \")})` });\n }\n }\n }\n\n const todayStr = today();\n\n for (const s of loaded) {\n const push = (level: DiagnosticLevel, message: string) =>\n diagnostics.push({ relPath: s.relPath, level, message });\n if (!s.fm) continue;\n const fm = s.fm;\n const xm = fm[\"x-skills-master\"];\n\n // name == folder name\n if (fm.name !== s.folderName) {\n push(\"error\", `name \"${fm.name}\" must equal the folder name \"${s.folderName}\"`);\n }\n\n // description shape (soft)\n if (!/use when/i.test(fm.description)) {\n push(\"warn\", `description should include a \"Use when ...\" trigger clause`);\n }\n\n // snapshot_date not in the future\n if (xm.snapshot_date > todayStr) {\n push(\"error\", `snapshot_date ${xm.snapshot_date} is in the future`);\n }\n\n // contested ⇒ Open question section\n if (xm.stability === \"contested\" && !/^## Open question\\b/m.test(s.body)) {\n push(\"error\", `stability is \"contested\" but no \"## Open question\" section is present`);\n }\n\n // body length\n const lineCount = s.body.split(\"\\n\").length;\n if (lineCount > MAX_BODY_LINES) {\n push(\"error\", `SKILL.md body is ${lineCount} lines (max ${MAX_BODY_LINES}); move depth into reference.md/examples.md`);\n } else if (lineCount > WARN_BODY_LINES) {\n push(\"warn\", `SKILL.md body is ${lineCount} lines (approaching the ${MAX_BODY_LINES}-line cap)`);\n }\n\n // domain should match the top path segment\n if (!s.relPath.startsWith(`${xm.domain}/`)) {\n push(\"warn\", `domain \"${xm.domain}\" does not match the top folder of \"${s.relPath}\"`);\n }\n\n // sources should be present and be https documentation URLs\n if (xm.sources.length === 0) {\n push(\"warn\", `no sources — add at least one canonical documentation URL`);\n }\n for (const url of xm.sources) {\n if (!/^https:\\/\\//.test(url)) {\n push(\"warn\", `sources entry should be an https URL: ${url}`);\n }\n }\n\n // canonical headings\n for (const heading of CANONICAL_HEADINGS) {\n if (!s.body.includes(heading)) {\n push(\"warn\", `missing recommended section \"${heading}\"`);\n }\n }\n\n // pairs_with referential integrity (bidirectional)\n for (const partner of xm.pairs_with) {\n const partnerFm = byName.get(partner);\n if (!partnerFm) {\n push(\"error\", `pairs_with references unknown skill \"${partner}\"`);\n continue;\n }\n if (!partnerFm[\"x-skills-master\"].pairs_with.includes(fm.name)) {\n push(\"error\", `pairs_with \"${partner}\" is not reciprocated (add \"${fm.name}\" to its pairs_with)`);\n }\n }\n }\n\n const errorCount = diagnostics.filter((d) => d.level === \"error\").length;\n const warnCount = diagnostics.filter((d) => d.level === \"warn\").length;\n return { diagnostics, skillCount: dirs.length, errorCount, warnCount };\n}\n","import { resolveContent } from \"../content/source\";\nimport { lintSkills } from \"../core/lint\";\nimport { log } from \"../util/log\";\n\nexport interface LintCmdOptions {\n content?: string;\n cwd?: string;\n}\n\n/** Lint the skill library. Returns true when there are no errors. */\nexport async function lintCommand(opts: LintCmdOptions): Promise<boolean> {\n const content = await resolveContent({ content: opts.content, cwd: opts.cwd });\n const result = lintSkills(content.root);\n\n for (const d of result.diagnostics) {\n const line = `${d.level === \"error\" ? \"✗\" : \"!\"} ${d.relPath}: ${d.message}`;\n if (d.level === \"error\") log.error(line);\n else log.warn(line);\n }\n\n log.plain(\n `\\nLinted ${result.skillCount} skill(s): ${result.errorCount} error(s), ${result.warnCount} warning(s).`,\n );\n return result.errorCount === 0;\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { resolveContent } from \"../content/source\";\nimport { buildRegistry } from \"../core/registry-build\";\nimport { REGISTRY_FILENAME } from \"../schema/registry\";\nimport { log } from \"../util/log\";\n\nexport interface RegistryBuildOptions {\n content?: string;\n cwd?: string;\n /** when true, verify the committed registry.json is up to date (CI mode). */\n check?: boolean;\n version?: string;\n}\n\n/** Build (or verify) registry.json from the skill tree. Returns true on success. */\nexport async function registryBuildCommand(opts: RegistryBuildOptions): Promise<boolean> {\n const content = await resolveContent({ content: opts.content, cwd: opts.cwd });\n const registry = buildRegistry(content.root, opts.version ?? \"0.1.0\");\n const json = JSON.stringify(registry, null, 2) + \"\\n\";\n const outPath = join(content.root, REGISTRY_FILENAME);\n\n if (opts.check) {\n const current = existsSync(outPath) ? readFileSync(outPath, \"utf8\") : \"\";\n if (current !== json) {\n log.error(`registry.json is out of date — run \\`registry build\\` and commit the result.`);\n return false;\n }\n log.success(`registry.json is up to date (${registry.skills.length} skills).`);\n return true;\n }\n\n writeFileSync(outPath, json, \"utf8\");\n log.success(`Wrote ${REGISTRY_FILENAME} (${registry.skills.length} skills).`);\n return true;\n}\n","import { z } from \"zod\";\nimport { SkillClassSchema, StabilitySchema } from \"./frontmatter\";\n\n/** One catalog entry. Generated from the skill tree by `registry build`. */\nexport const RegistryEntrySchema = z.object({\n name: z.string(),\n domain: z.string(),\n class: SkillClassSchema,\n category: z.string(),\n description: z.string(),\n platforms: z.array(z.string()),\n stability: StabilitySchema,\n version: z.string(),\n tags: z.array(z.string()).default([]),\n pairs_with: z.array(z.string()).default([]),\n /** path relative to the skills root. */\n path: z.string(),\n /** which on-demand resource files exist. */\n resources: z.object({\n reference: z.boolean(),\n examples: z.boolean(),\n checklist: z.boolean(),\n }),\n});\n\nexport const RegistrySchema = z.object({\n $schema: z.string().optional(),\n /** aggregate library version (bumped on release). */\n version: z.string().default(\"0.1.0\"),\n generatedAt: z.string().optional(),\n skills: z.array(RegistryEntrySchema).default([]),\n});\n\nexport type RegistryEntry = z.infer<typeof RegistryEntrySchema>;\nexport type Registry = z.infer<typeof RegistrySchema>;\n\nexport const REGISTRY_FILENAME = \"registry.json\";\n","import { existsSync, readdirSync, readFileSync, rmSync } from \"node:fs\";\nimport { dirname, join, resolve, sep } from \"node:path\";\nimport { resolveContent, type ContentSource } from \"../content/source\";\nimport { claudeEmitter } from \"../emitters\";\nimport { applyFiles } from \"../core/writer\";\nimport type { EmitContext, EmittedFile, TargetId } from \"../types\";\nimport type { SkillClass } from \"../schema/frontmatter\";\nimport { log } from \"../util/log\";\n\nconst CLASS_LABEL: Record<SkillClass, string> = {\n code: \"code skills (frameworks & APIs)\",\n design: \"design-review skills\",\n \"lang-tooling\": \"language, build, test & ship skills\",\n overview: \"decision-guidance routers\",\n};\n\nconst CLASS_CATEGORY: Record<SkillClass, string> = {\n code: \"development\",\n design: \"design\",\n \"lang-tooling\": \"development\",\n overview: \"development\",\n};\n\n/** Directory holding the generated per-class plugins, relative to the output root. */\nconst PLUGINS_DIR = \"plugins\";\n/** The generated marketplace manifest, relative to the output root. */\nconst MARKETPLACE_JSON = \".claude-plugin/marketplace.json\";\n\nfunction pluginName(domain: string, cls: SkillClass): string {\n const clsSeg = cls === \"overview\" ? \"overviews\" : cls;\n return `skills-master-${domain}-${clsSeg}`;\n}\n\nfunction titleCase(s: string): string {\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\nfunction toPosix(p: string): string {\n return p.split(sep).join(\"/\");\n}\n\n/** Every file under `dir`, as output-root-relative POSIX paths. */\nfunction listFiles(root: string, dir: string, acc: string[] = []): string[] {\n const abs = join(root, dir);\n if (!existsSync(abs)) return acc;\n for (const entry of readdirSync(abs, { withFileTypes: true })) {\n const rel = `${dir}/${entry.name}`;\n if (entry.isDirectory()) listFiles(root, rel, acc);\n else acc.push(rel);\n }\n return acc;\n}\n\nexport interface MarketplaceBuildOptions {\n content?: string;\n cwd?: string;\n /** output root for .claude-plugin/ and plugins/ (defaults to the repo root above skills/). */\n out?: string;\n /** when true, verify the committed marketplace output is up to date (CI mode). */\n check?: boolean;\n version?: string;\n}\n\ninterface MarketplaceOutput {\n /** every generated file, keyed by output-root-relative POSIX path. */\n files: Map<string, string>;\n /** per-plugin skill counts, for logging. */\n counts: { name: string; count: number }[];\n pluginCount: number;\n}\n\n/**\n * Compute the complete marketplace projection in memory. Both the write and the\n * `--check` paths run through this, so CI verifies exactly what `build` writes.\n */\nfunction buildOutputs(content: ContentSource, out: string, version: string): MarketplaceOutput {\n // Group emitted files by (domain, class).\n const groups = new Map<string, { domain: string; cls: SkillClass; files: EmittedFile[]; count: number }>();\n\n for (const dir of content.skillDirs()) {\n const skill = content.loadSkill(dir.split(/[\\\\/]/).pop()!);\n const xm = skill.frontmatter[\"x-skills-master\"];\n const key = `${xm.domain}:${xm.class}`;\n const name = pluginName(xm.domain, xm.class);\n const ctx: EmitContext = {\n projectRoot: out,\n paths: {\n claude: `${PLUGINS_DIR}/${name}/skills`,\n cursor: \"\",\n copilot: \"\",\n agents: \"\",\n } as Record<TargetId, string>,\n };\n const files = claudeEmitter.emit(skill, ctx);\n const g = groups.get(key) ?? { domain: xm.domain, cls: xm.class, files: [], count: 0 };\n g.files.push(...files);\n g.count += 1;\n groups.set(key, g);\n }\n\n const outFiles = new Map<string, string>();\n const counts: { name: string; count: number }[] = [];\n const plugins: {\n name: string;\n source: string;\n description: string;\n version: string;\n category: string;\n }[] = [];\n\n for (const { domain, cls, files, count } of groups.values()) {\n const name = pluginName(domain, cls);\n for (const f of files) outFiles.set(toPosix(f.path), f.contents);\n\n const description = `${titleCase(domain)} ${CLASS_LABEL[cls]}.`;\n const manifest = {\n name,\n version,\n description,\n author: { name: \"skills-master contributors\" },\n };\n outFiles.set(\n `${PLUGINS_DIR}/${name}/.claude-plugin/plugin.json`,\n JSON.stringify(manifest, null, 2) + \"\\n\",\n );\n\n plugins.push({ name, source: `./${PLUGINS_DIR}/${name}`, description, version, category: CLASS_CATEGORY[cls] });\n counts.push({ name, count });\n }\n\n plugins.sort((a, b) => a.name.localeCompare(b.name));\n counts.sort((a, b) => a.name.localeCompare(b.name));\n const marketplace = {\n $schema: \"https://www.schemastore.org/claude-code-marketplace.json\",\n name: \"skills-master\",\n owner: { name: \"skills-master contributors\" },\n plugins,\n };\n outFiles.set(MARKETPLACE_JSON, JSON.stringify(marketplace, null, 2) + \"\\n\");\n\n return { files: outFiles, counts, pluginCount: plugins.length };\n}\n\n/** Build (or verify) the plugin marketplace from the skill tree. Returns true on success. */\nexport async function marketplaceBuildCommand(opts: MarketplaceBuildOptions): Promise<boolean> {\n const content = await resolveContent({ content: opts.content, cwd: opts.cwd });\n const out = resolve(opts.out ?? dirname(content.root));\n const version = opts.version ?? \"0.1.0\";\n\n const { files, counts, pluginCount } = buildOutputs(content, out, version);\n\n // Everything under plugins/ plus the marketplace manifest is generated, so any\n // on-disk file outside the expected set is stale and must not survive a build.\n const onDisk = new Set(listFiles(out, PLUGINS_DIR));\n if (existsSync(join(out, MARKETPLACE_JSON))) onDisk.add(MARKETPLACE_JSON);\n\n if (opts.check) {\n const missing: string[] = [];\n const differing: string[] = [];\n for (const [rel, contents] of files) {\n if (!onDisk.has(rel)) {\n missing.push(rel);\n continue;\n }\n if (readFileSync(join(out, rel), \"utf8\") !== contents) differing.push(rel);\n }\n const stale = [...onDisk].filter((rel) => !files.has(rel)).sort();\n\n if (missing.length || differing.length || stale.length) {\n log.error(\n `Marketplace output is out of date (${missing.length} missing, ${differing.length} changed, ${stale.length} stale) — run \\`pnpm skills:marketplace\\` and commit the result.`,\n );\n for (const rel of missing.sort().slice(0, 10)) log.error(` missing: ${rel}`);\n for (const rel of differing.sort().slice(0, 10)) log.error(` changed: ${rel}`);\n for (const rel of stale.slice(0, 10)) log.error(` stale: ${rel}`);\n return false;\n }\n log.success(`Marketplace output is up to date (${pluginCount} plugins, ${files.size} files).`);\n return true;\n }\n\n // Delete stale output first: a skill that moved to another class, or was\n // renamed or removed, would otherwise keep shipping from its old plugin.\n const stale = [...onDisk].filter((rel) => !files.has(rel)).sort();\n for (const rel of stale) rmSync(join(out, rel), { force: true });\n pruneEmptyDirsUnder(join(out, PLUGINS_DIR));\n\n const emitted: EmittedFile[] = [...files].map(([path, contents]) => ({ path, contents, mode: \"whole\" }));\n applyFiles(out, emitted, { overwrite: true });\n\n for (const { name, count } of counts) log.info(`Built ${name} (${count} skills).`);\n if (stale.length) log.info(`Removed ${stale.length} stale file(s).`);\n log.success(`Wrote ${MARKETPLACE_JSON} (${pluginCount} plugins, ${files.size} files).`);\n return true;\n}\n\n/** Recursively drop directories left empty after stale files were removed. */\nfunction pruneEmptyDirsUnder(root: string): void {\n if (!existsSync(root)) return;\n for (const entry of readdirSync(root, { withFileTypes: true })) {\n if (entry.isDirectory()) pruneEmptyDirsUnder(join(root, entry.name));\n }\n if (readdirSync(root).length === 0) rmSync(root, { recursive: true, force: true });\n}\n","import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { resolveContent } from \"../content/source\";\nimport { CLASS_DIR, SkillClassSchema, type SkillClass } from \"../schema/frontmatter\";\nimport { log } from \"../util/log\";\n\nexport interface NewSkillOptions {\n /** \"domain/class/category/name\", e.g. \"apple/code/app-frameworks/swiftui-foo\". */\n spec: string;\n content?: string;\n cwd?: string;\n force?: boolean;\n}\n\nfunction template(domain: string, cls: SkillClass, category: string, name: string): string {\n const today = new Date().toISOString().slice(0, 10);\n return `---\nname: ${name}\ndescription: TODO — one-line, third person. Use when <triggers go here>.\nglobs:\n - \"**/*\"\ntags: []\nx-skills-master:\n domain: ${domain}\n class: ${cls}\n category: ${category}\n platforms: [${domain}]\n requires: {}\n pairs_with: []\n sources: []\n snapshot_date: \"${today}\"\n stability: emerging\n version: 0.1.0\n---\n\n## When to use\n\nTODO — when should an agent reach for this skill?\n\n## Core guidance\n\nTODO — the do/don't, idioms, and best practices (original prose, no copied docs).\n\n## Platform notes\n\nTODO — platform-specific caveats.\n\n## Pitfalls\n\nTODO — common mistakes.\n\n## References\n\n- **Documentation:** [TODO](https://developer.apple.com/documentation/...)\n- **Human Interface Guidelines:** [TODO](https://developer.apple.com/design/human-interface-guidelines/...)\n- **WWDC:** [TODO](https://developer.apple.com/videos/...)\n\n## See also\n\nTODO — paired skills referenced by name.\n`;\n}\n\nexport async function newSkillCommand(opts: NewSkillOptions): Promise<string> {\n const parts = opts.spec.split(\"/\").filter(Boolean);\n if (parts.length < 4) {\n throw new Error(`Expected \"domain/class/category/name\", got \"${opts.spec}\".`);\n }\n const domain = parts[0]!;\n const cls = SkillClassSchema.parse(parts[1]);\n const category = parts[2]!;\n const name = parts[parts.length - 1]!;\n\n const content = await resolveContent({ content: opts.content, cwd: opts.cwd });\n const dir = join(content.root, domain, CLASS_DIR[cls], ...parts.slice(2));\n const skillMd = join(dir, \"SKILL.md\");\n\n if (existsSync(skillMd) && !opts.force) {\n throw new Error(`Skill already exists at ${skillMd} (use --force to overwrite).`);\n }\n mkdirSync(dir, { recursive: true });\n writeFileSync(skillMd, template(domain, cls, category, name), \"utf8\");\n log.success(`Created ${skillMd}`);\n return skillMd;\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACEtB,cAAW;;;ACaN,IAAM,cAA0B,CAAC,UAAU,UAAU,WAAW,QAAQ;AASxE,IAAM,iBAAiB;AAAA,EAC5B,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AACb;;;AC5BA,SAAS,SAAS;AAGX,IAAM,iBAAiB,EAAE,KAAK,CAAC,UAAU,UAAU,WAAW,QAAQ,CAAC;AAGvE,IAAM,gBAA0C;AAAA,EACrD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AACV;AAEO,IAAM,sBAAsB,EAChC,OAAO;AAAA,EACN,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAE7B,YAAY,EAAE,OAAO,EAAE,QAAQ,MAAM;AAAA;AAAA;AAAA;AAAA,EAIrC,SAAS,EAAE,MAAM,cAAc,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAE3C,OAAO,EACJ,OAAO;AAAA,IACN,QAAQ,EAAE,OAAO;AAAA,IACjB,QAAQ,EAAE,OAAO;AAAA,IACjB,SAAS,EAAE,OAAO;AAAA,IAClB,QAAQ,EAAE,OAAO;AAAA,EACnB,CAAC,EACA,QAAQ,EACR,QAAQ,CAAC,CAAC;AAAA,EACb,OAAO,EAA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,OAAO,EACf,YAAY,4CAA4C,EACxD,OAAO,iBAAiB,EACxB,OAAO,WAAW,oDAAoD,EACtE,OAAO,eAAe,EACtB;AAAA,EAAO,CAAC,SACP;AAAA,IACE,MAAM,qBAAqB,EAAE,KAAK,QAAQ,IAAI,GAAG,SAAS,KAAK,SAAS,OAAO,KAAK,OAAO,SAAS,KAAK,QAAQ,CAAC;AAAA,IAClH;AAAA,EACF;AACF;AAEF,IAAM,cAAc,QAAQ,QAAQ,aAAa,EAAE,YAAY,gCAAgC;AAC/F,YACG,QAAQ,OAAO,EACf,YAAY,gEAAgE,EAC5E,OAAO,iBAAiB,EACxB,OAAO,eAAe,aAAa,EACnC,OAAO,WAAW,yDAAyD,EAC3E,OAAO,eAAe,EACtB;AAAA,EAAO,CAAC,SACP;AAAA,IACE,MACE,wBAAwB;AAAA,MACtB,KAAK,QAAQ,IAAI;AAAA,MACjB,SAAS,KAAK;AAAA,MACd,KAAK,KAAK;AAAA,MACV,OAAO,KAAK;AAAA,MACZ,SAAS,KAAK;AAAA,IAChB,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEF,QAAQ,WAAW,QAAQ,IAAI;","names":["existsSync","join","z","join","existsSync","existsSync","readFileSync","basename","join","existsSync","join","existsSync","readFileSync","join","z","join","readFileSync","existsSync","version","basename","join","existsSync","readFileSync","existsSync","readFileSync","join","existsSync","readdirSync","readFileSync","writeFileSync","join","version","version","join","existsSync","writeFileSync","readFileSync","readdirSync","join","existsSync","readFileSync","version","existsSync","readFileSync","writeFileSync","join","registry","existsSync","readFileSync","join","existsSync","join","readFileSync","existsSync","readFileSync","writeFileSync","join","z","z","registry","join","existsSync","readFileSync","writeFileSync","existsSync","readdirSync","readFileSync","rmSync","dirname","join","resolve","join","existsSync","readdirSync","version","marketplace","resolve","dirname","readFileSync","stale","rmSync","existsSync","mkdirSync","writeFileSync","join","today","join","existsSync","mkdirSync","writeFileSync"]}
|
package/package.json
CHANGED