@lifeaitools/rdc-skills 0.35.15 → 0.35.16

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rdc",
3
- "version": "0.35.15",
3
+ "version": "0.35.16",
4
4
  "description": "RDC typed-agent dispatch skill suite for Claude Code — plan, build, review, overnight unattended builds with work-item tracking and TDD enforcement.",
5
5
  "author": {
6
6
  "name": "LIFEAI",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifeaitools/rdc-skills",
3
- "version": "0.35.15",
3
+ "version": "0.35.16",
4
4
  "description": "RDC typed-agent dispatch skill suite for Claude Code - plan, build, review, overnight builds",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -45,7 +45,7 @@
45
45
  "rdc-design": "node scripts/rdc-design-cli.mjs",
46
46
  "test:hooks": "node scripts/test-rdc-hooks.mjs",
47
47
  "test:truth-gate": "node tests/run-evidence-gate.test.mjs && node tests/work-item-exit-gate-l2.test.mjs && node tests/work-item-exit-gate-l3.test.mjs && node tests/require-work-item-on-commit.test.mjs && node tests/harness-gates.test.mjs && node tests/foreground-process-gate.test.mjs",
48
- "test:acceptance": "node tests/acceptance.test.mjs && node tests/install-rdc-skills.test.mjs && node tests/help-surface.test.mjs && node tests/manifest-contract-fields.test.mjs && node tests/plugin-namespace-names.test.mjs && node tests/skill-test-matrix.test.mjs && node tests/completion-gate-supervisor-admission.test.mjs && node tests/curl-surface.test.mjs && node tests/clauth-plugin-postinstall.test.mjs",
48
+ "test:acceptance": "node tests/acceptance.test.mjs && node tests/install-rdc-skills.test.mjs && node tests/help-surface.test.mjs && node tests/manifest-contract-fields.test.mjs && node tests/plugin-namespace-names.test.mjs && node tests/skill-test-matrix.test.mjs && node tests/completion-gate-supervisor-admission.test.mjs && node tests/curl-surface.test.mjs && node tests/clauth-plugin-postinstall.test.mjs && node tests/install-duplicate-purge.test.mjs",
49
49
  "acceptance": "node scripts/acceptance.mjs --changed",
50
50
  "test:mcp": "node tests/mcp.test.mjs",
51
51
  "test:mcp:remote": "node tests/mcp.test.mjs --remote",
@@ -369,11 +369,96 @@ function buildPluginCache(cacheDir, version, gitSha) {
369
369
  }
370
370
  }
371
371
 
372
+ // ── Is this entry a duplicate of a skill WE ship? ─────────────────────────────
373
+ //
374
+ // THE PREDICATE THIS REPLACES WAS DEAD. It removed an entry only when its
375
+ // frontmatter name startsWith('rdc:'). Skills were later renamed to bare names
376
+ // (`name: build`, not `name: rdc:build`) — the same rename the marketplace-sync
377
+ // comment below refers to when it describes "/rdc:rdc:plan" appearing beside
378
+ // "/rdc:plan". Measured 2026-08-30: 0 of 44 shipped skills carry an rdc: prefix.
379
+ // So the purge matched nothing, removed nothing, and reported 0 while duplicate
380
+ // registrations kept accumulating. Nothing failed loudly, because a purge that
381
+ // finds nothing and a purge that cannot match anything print the same number.
382
+ //
383
+ // The replacement never keys on a prefix. It asks three independent questions,
384
+ // any one of which is sufficient:
385
+ //
386
+ // 1. LEGACY NAME — the old rdc: prefix, kept so pre-rename installs still get
387
+ // cleaned. Dropping it would strand exactly the machines this function was
388
+ // written for.
389
+ // 2. SYMLINK INTO OUR OWN PACKAGE — if the entry resolves to a file inside this
390
+ // package's skills/ tree, it IS our file, wearing a second name. That is
391
+ // unambiguous and survives any future rename.
392
+ // 3. SHIPPED NAME + OUR MARKER — the name matches one we ship AND the body
393
+ // carries the output-contract line every rdc skill opens with. Name alone
394
+ // is deliberately NOT enough: a user skill legitimately called "build" must
395
+ // survive, and on this machine ~/.claude/skills holds clauth, coolify-*,
396
+ // leaflet-maps and notebooklm — none of which may ever be touched.
397
+ //
398
+ // Signal 3 covers 43 of 44 shipped skills; behavior-audit lacks the marker and
399
+ // is caught by signal 2 when symlinked. A skill that is neither symlinked nor
400
+ // marked is deliberately left alone — under-removing is recoverable, deleting a
401
+ // user's own work is not.
402
+ let _shippedSkillNames = null;
403
+ function shippedSkillNames() {
404
+ if (_shippedSkillNames) return _shippedSkillNames;
405
+ _shippedSkillNames = new Set();
406
+ const dir = path.join(repoRoot, 'skills');
407
+ try {
408
+ for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
409
+ if (!e.isDirectory()) continue;
410
+ _shippedSkillNames.add(e.name);
411
+ for (const sf of ['SKILL.md', 'skill.md']) {
412
+ const p = path.join(dir, e.name, sf);
413
+ if (fs.existsSync(p)) {
414
+ const fm = readFrontmatter(p);
415
+ if (fm.name) _shippedSkillNames.add(fm.name);
416
+ break;
417
+ }
418
+ }
419
+ }
420
+ } catch { /* no skills/ dir — every check below simply returns false */ }
421
+ return _shippedSkillNames;
422
+ }
423
+
424
+ const RDC_SKILL_MARKER = 'guides/output-contract.md';
425
+
426
+ function resolvesInsideOurSkills(candidate) {
427
+ try {
428
+ const real = fs.realpathSync(candidate);
429
+ const ours = fs.realpathSync(path.join(repoRoot, 'skills'));
430
+ const rel = path.relative(ours, real);
431
+ return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
432
+ } catch {
433
+ return false;
434
+ }
435
+ }
436
+
437
+ function isRdcSkillDuplicate(candidate, skillFile) {
438
+ const fm = readFrontmatter(skillFile);
439
+
440
+ // 1. legacy rdc: prefix — pre-rename installs
441
+ if (fm.name && fm.name.startsWith('rdc:')) return true;
442
+
443
+ // 2. it literally is our file, reached by another path
444
+ if (resolvesInsideOurSkills(candidate)) return true;
445
+
446
+ // 3. our name AND our marker — both, never name alone
447
+ if (fm.name && shippedSkillNames().has(fm.name)) {
448
+ try {
449
+ if (fs.readFileSync(skillFile, 'utf8').includes(RDC_SKILL_MARKER)) return true;
450
+ } catch { /* unreadable → not a duplicate we are confident about */ }
451
+ }
452
+
453
+ return false;
454
+ }
455
+
372
456
  // ── User-skills cleanup ───────────────────────────────────────────────────────
373
457
  // Older installer versions wrote skill files directly to ~/.claude/skills/user/.
374
458
  // Claude Code loads that directory AND the plugin cache, so any rdc skills left
375
459
  // there produce duplicate registrations and break the resolver.
376
- // This function nukes any entry whose frontmatter name starts with "rdc:".
460
+ // It delegates to isRdcSkillDuplicate() above a prefix test alone has not
461
+ // matched anything since skills were renamed to bare names.
377
462
  // Scans BOTH the immediate dir and nested .md files (e.g. `user/skill.md`,
378
463
  // `user/rdc-build/SKILL.md`) so pre-plugin orphans are caught regardless of
379
464
  // naming convention.
@@ -390,8 +475,7 @@ function cleanUserSkills(userSkillsDir) {
390
475
  if (fs.existsSync(p)) { skillFile = p; break; }
391
476
  }
392
477
  if (!skillFile) continue;
393
- const fm = readFrontmatter(skillFile);
394
- if (fm.name && fm.name.startsWith('rdc:')) {
478
+ if (isRdcSkillDuplicate(candidate, skillFile)) {
395
479
  try { fs.rmSync(candidate, { recursive: true, force: true }); removed++; } catch {}
396
480
  }
397
481
  } else if (entry.isFile() && entry.name.endsWith('.md')) {
@@ -399,8 +483,7 @@ function cleanUserSkills(userSkillsDir) {
399
483
  // if their frontmatter declares an rdc:* skill. A previous version skipped
400
484
  // those names; that left an orphan rdc:build copy at user/skill.md which
401
485
  // registered as a duplicate "user" skill.
402
- const fm = readFrontmatter(candidate);
403
- if (fm.name && fm.name.startsWith('rdc:')) {
486
+ if (isRdcSkillDuplicate(candidate, candidate)) {
404
487
  try { fs.unlinkSync(candidate); removed++; } catch {}
405
488
  }
406
489
  }
@@ -417,8 +500,7 @@ function cleanGlobalSkillsRoot(skillsDir) {
417
500
  if (entry.name === 'user') continue; // handled separately
418
501
  const candidate = path.join(skillsDir, entry.name);
419
502
  if (entry.isFile() && entry.name.endsWith('.md')) {
420
- const fm = readFrontmatter(candidate);
421
- if (fm.name && fm.name.startsWith('rdc:')) {
503
+ if (isRdcSkillDuplicate(candidate, candidate)) {
422
504
  try { fs.unlinkSync(candidate); removed++; } catch {}
423
505
  }
424
506
  }
@@ -797,8 +879,7 @@ function registerCodexTarget(targetDir) {
797
879
  fs.rmSync(candidate, { recursive: true, force: true });
798
880
  removed++;
799
881
  } else {
800
- const fm = readFrontmatter(path.join(candidate, 'SKILL.md'));
801
- if (fm.name && fm.name.startsWith('rdc:')) {
882
+ if (isRdcSkillDuplicate(candidate, path.join(candidate, 'SKILL.md'))) {
802
883
  fs.rmSync(candidate, { recursive: true, force: true });
803
884
  removed++;
804
885
  }
@@ -1331,8 +1412,11 @@ async function main() {
1331
1412
  ? ['SKILL.md','skill.md'].map(s => path.join(p, s)).find(fs.existsSync)
1332
1413
  : (f.endsWith('.md') ? p : null);
1333
1414
  if (!skillFile) return false;
1334
- const fm = readFrontmatter(skillFile);
1335
- return fm.name && fm.name.startsWith('rdc:');
1415
+ // Must use the SAME predicate the purge uses. When this asked a
1416
+ // different (and dead) question, the purge removed nothing and this
1417
+ // confirmed nothing was left — the two agreed, and agreement between
1418
+ // a broken fix and a broken check is indistinguishable from success.
1419
+ return isRdcSkillDuplicate(p, skillFile);
1336
1420
  })
1337
1421
  : [];
1338
1422
  if (stillThere.length === 0) {
@@ -1385,7 +1469,7 @@ async function main() {
1385
1469
  // scripts/probe-installed-hooks.mjs verify the real install path instead of
1386
1470
  // re-implementing it — a probe that copies its own way proves nothing about what
1387
1471
  // ships. Without this guard, requiring the module would run a full install.
1388
- module.exports = { copyHookFiles, assertHooksLoadable, registerCodexTarget, syncMarketplaceCheckout, RDC_ENV_HOOK_TIMEOUT_SEC };
1472
+ module.exports = { copyHookFiles, assertHooksLoadable, registerCodexTarget, syncMarketplaceCheckout, RDC_ENV_HOOK_TIMEOUT_SEC, isRdcSkillDuplicate, cleanUserSkills, cleanGlobalSkillsRoot, shippedSkillNames };
1389
1473
 
1390
1474
  if (require.main === module) {
1391
1475
  main().catch(e => { fail(e.message); process.exit(1); });
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The duplicate-skill purge — the predicate, not the plumbing.
4
+ *
5
+ * cleanUserSkills() and cleanGlobalSkillsRoot() removed an entry only when its
6
+ * frontmatter name startsWith('rdc:'). Skills were later renamed to bare names
7
+ * (`name: build`), and measured 2026-08-30 exactly 0 of 44 shipped skills carry
8
+ * an rdc: prefix. So the purge matched nothing and removed nothing, while
9
+ * reporting 0 — indistinguishable from "there was nothing to remove".
10
+ *
11
+ * The first test below is the one that was failing in production and could not
12
+ * fail here, because nothing asserted the bare-name case. The rest exist so the
13
+ * fix cannot over-reach: a user's own skill must survive even when it shares a
14
+ * name with one we ship.
15
+ */
16
+ import assert from 'node:assert/strict';
17
+ import { createRequire } from 'node:module';
18
+ import { existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
19
+ import { tmpdir } from 'node:os';
20
+ import { dirname, join, resolve } from 'node:path';
21
+ import { fileURLToPath } from 'node:url';
22
+
23
+ const __dirname = dirname(fileURLToPath(import.meta.url));
24
+ const REPO_ROOT = resolve(__dirname, '..');
25
+ const require = createRequire(import.meta.url);
26
+ const { isRdcSkillDuplicate, cleanUserSkills, cleanGlobalSkillsRoot, shippedSkillNames } =
27
+ require(join(REPO_ROOT, 'scripts', 'install-rdc-skills.js'));
28
+
29
+ const MARKER = 'guides/output-contract.md';
30
+ let sandbox;
31
+ function fresh() {
32
+ sandbox = mkdtempSync(join(tmpdir(), 'rdc-purge-'));
33
+ return sandbox;
34
+ }
35
+ function skillDir(root, name, body) {
36
+ const d = join(root, name);
37
+ mkdirSync(d, { recursive: true });
38
+ writeFileSync(join(d, 'SKILL.md'), body);
39
+ return d;
40
+ }
41
+ function fm(name, extra = '') {
42
+ return `---\nname: ${name}\ndescription: test fixture\n---\n\n${extra}\n`;
43
+ }
44
+
45
+ // ── 0. the shipped set is real, not empty ────────────────────────────────────
46
+ // If this is empty every other assertion below passes vacuously.
47
+ const shipped = shippedSkillNames();
48
+ assert.ok(shipped.size > 10, `shippedSkillNames() returned ${shipped.size} — too few to be real`);
49
+ assert.ok(shipped.has('build'), 'expected "build" among shipped skill names');
50
+
51
+ // ── 1. THE REGRESSION: a bare-named copy of a skill we ship is a duplicate ───
52
+ // This is precisely what the old startsWith('rdc:') predicate could not see.
53
+ {
54
+ const root = fresh();
55
+ const d = skillDir(root, 'build', fm('build', `> OUTPUT CONTRACT: \`${MARKER}\``));
56
+ assert.equal(isRdcSkillDuplicate(d, join(d, 'SKILL.md')), true,
57
+ 'a bare-named copy of a shipped skill must be detected as a duplicate');
58
+ const removed = cleanUserSkills(root);
59
+ assert.equal(removed, 1, 'cleanUserSkills should remove exactly the duplicate');
60
+ assert.equal(existsSync(d), false, 'the duplicate directory should be gone');
61
+ rmSync(root, { recursive: true, force: true });
62
+ }
63
+
64
+ // ── 2. legacy rdc:-prefixed entries still get cleaned ────────────────────────
65
+ // Pre-rename installs are the machines this function was originally written for.
66
+ {
67
+ const root = fresh();
68
+ const d = skillDir(root, 'rdc-build', fm('rdc:build'));
69
+ assert.equal(isRdcSkillDuplicate(d, join(d, 'SKILL.md')), true, 'legacy rdc: prefix must still match');
70
+ assert.equal(cleanUserSkills(root), 1);
71
+ assert.equal(existsSync(d), false);
72
+ rmSync(root, { recursive: true, force: true });
73
+ }
74
+
75
+ // ── 3. SAFETY: a user's own skill with an unrelated name survives ────────────
76
+ {
77
+ const root = fresh();
78
+ const d = skillDir(root, 'leaflet-maps', fm('leaflet-maps'));
79
+ assert.equal(isRdcSkillDuplicate(d, join(d, 'SKILL.md')), false);
80
+ assert.equal(cleanUserSkills(root), 0, 'must not touch a user skill');
81
+ assert.equal(existsSync(d), true, "the user's own skill must survive");
82
+ rmSync(root, { recursive: true, force: true });
83
+ }
84
+
85
+ // ── 4. SAFETY: a shipped NAME alone is not enough to delete ──────────────────
86
+ // Someone may legitimately write their own skill called "build". Name plus our
87
+ // marker is required; name alone must never be sufficient.
88
+ {
89
+ const root = fresh();
90
+ const d = skillDir(root, 'build', fm('build', 'my own build skill, nothing to do with rdc'));
91
+ assert.equal(isRdcSkillDuplicate(d, join(d, 'SKILL.md')), false,
92
+ 'shipped name WITHOUT our marker must not be treated as ours');
93
+ assert.equal(cleanUserSkills(root), 0);
94
+ assert.equal(existsSync(d), true);
95
+ rmSync(root, { recursive: true, force: true });
96
+ }
97
+
98
+ // ── 5. a symlink into our own skills/ tree is unambiguously ours ─────────────
99
+ // Skipped where the platform refuses symlink creation without privileges; the
100
+ // skip is loud, so it can never be mistaken for a pass.
101
+ {
102
+ const root = fresh();
103
+ const target = join(REPO_ROOT, 'skills', 'build');
104
+ let made = true;
105
+ try { symlinkSync(target, join(root, 'build'), 'junction'); }
106
+ catch { made = false; }
107
+ if (made) {
108
+ assert.equal(isRdcSkillDuplicate(join(root, 'build'), join(root, 'build', 'SKILL.md')), true,
109
+ 'a symlink resolving inside our skills/ tree must be detected');
110
+ } else {
111
+ console.log(' SKIP symlink case — platform refused symlink creation');
112
+ }
113
+ rmSync(root, { recursive: true, force: true });
114
+ }
115
+
116
+ // ── 6. cleanGlobalSkillsRoot: flat .md orphans at the top level ─────────────
117
+ {
118
+ const root = fresh();
119
+ const flat = join(root, 'build.md');
120
+ writeFileSync(flat, fm('build', `> OUTPUT CONTRACT: \`${MARKER}\``));
121
+ const mine = join(root, 'coolify-verify.md');
122
+ writeFileSync(mine, fm('coolify-verify'));
123
+ const removed = cleanGlobalSkillsRoot(root);
124
+ assert.equal(removed, 1, 'exactly the rdc orphan should go');
125
+ assert.equal(existsSync(flat), false, 'flat rdc orphan should be removed');
126
+ assert.equal(existsSync(mine), true, "the user's own flat skill must survive");
127
+ rmSync(root, { recursive: true, force: true });
128
+ }
129
+
130
+ // ── 7. absent directory is not an error ──────────────────────────────────────
131
+ assert.equal(cleanUserSkills(join(tmpdir(), 'rdc-purge-does-not-exist')), 0);
132
+ assert.equal(cleanGlobalSkillsRoot(join(tmpdir(), 'rdc-purge-does-not-exist')), 0);
133
+
134
+ console.log('install-rdc-skills duplicate-purge test — PASS');