@lifeaitools/rdc-skills 0.20.2 → 0.20.4
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/.claude-plugin/plugin.json +1 -1
- package/bin/rdc-skills-mcp.mjs +25 -1
- package/git-sha.json +3 -0
- package/hooks/check-rdc-environment.js +164 -0
- package/package.json +2 -2
- package/scripts/install-rdc-skills.js +1 -0
- package/scripts/prepack.mjs +32 -0
- package/scripts/self-test.mjs +9 -1
- package/scripts/stamp-git-sha.mjs +29 -0
package/bin/rdc-skills-mcp.mjs
CHANGED
|
@@ -39,6 +39,7 @@ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/
|
|
|
39
39
|
import fs from 'node:fs';
|
|
40
40
|
import path from 'node:path';
|
|
41
41
|
import { fileURLToPath } from 'node:url';
|
|
42
|
+
import { execFileSync } from 'node:child_process';
|
|
42
43
|
|
|
43
44
|
import {
|
|
44
45
|
listSkills,
|
|
@@ -62,6 +63,29 @@ function pkgVersion() {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
// Commit the running process actually LOADED — resolved ONCE at startup, never
|
|
67
|
+
// per-request, so /health reports a PROVABLE commit. Resolution order:
|
|
68
|
+
// 1. git-sha.json — baked at pack/publish (scripts/stamp-git-sha.mjs). This is
|
|
69
|
+
// the PRODUCTION path: the process runs from the npm install (no .git), so
|
|
70
|
+
// runtime rev-parse can't work — the stamped file is the source of truth.
|
|
71
|
+
// 2. runtime `git rev-parse` — the DEV path (running straight from the checkout).
|
|
72
|
+
// 3. env override, then 'unknown'.
|
|
73
|
+
const GIT_SHA = (() => {
|
|
74
|
+
try {
|
|
75
|
+
const stamped = JSON.parse(fs.readFileSync(path.join(REPO_ROOT, 'git-sha.json'), 'utf8')).sha;
|
|
76
|
+
if (stamped && stamped !== 'unknown') return stamped;
|
|
77
|
+
} catch { /* not stamped — fall through to runtime/dev resolution */ }
|
|
78
|
+
try {
|
|
79
|
+
return execFileSync('git', ['rev-parse', 'HEAD'], {
|
|
80
|
+
cwd: REPO_ROOT,
|
|
81
|
+
encoding: 'utf8',
|
|
82
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
83
|
+
}).trim();
|
|
84
|
+
} catch {
|
|
85
|
+
return process.env.RDC_SKILLS_GIT_SHA || 'unknown';
|
|
86
|
+
}
|
|
87
|
+
})();
|
|
88
|
+
|
|
65
89
|
// Soft process-wide default variant, updated whenever a client initializes.
|
|
66
90
|
let lastDetectedVariant = 'cloud';
|
|
67
91
|
|
|
@@ -188,7 +212,7 @@ function startHttp() {
|
|
|
188
212
|
} catch {
|
|
189
213
|
skills = 0;
|
|
190
214
|
}
|
|
191
|
-
res.json({ status: 'ok', service: 'rdc-skills-mcp', version: pkgVersion(), skills });
|
|
215
|
+
res.json({ status: 'ok', service: 'rdc-skills-mcp', version: pkgVersion(), git_sha: GIT_SHA, skills });
|
|
192
216
|
});
|
|
193
217
|
|
|
194
218
|
// Block OAuth discovery so connectors skip OAuth and connect direct — /mcp is open.
|
package/git-sha.json
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* SessionStart hook — hard gate for the RDC skills runtime.
|
|
4
|
+
*
|
|
5
|
+
* This hook repairs the approved install path when it can do so safely:
|
|
6
|
+
* npm install -g @lifeaitools/rdc-skills@latest
|
|
7
|
+
* rdc-skills-install --profile lifeai --project-root <repo> --write-startup-blocks
|
|
8
|
+
*
|
|
9
|
+
* It then verifies that the local MCP server answers /health and sees a real
|
|
10
|
+
* skills catalog. If repair fails, startup is blocked before agents trust stale
|
|
11
|
+
* copied skill files.
|
|
12
|
+
*/
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const os = require('os');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const { execFileSync, execSync } = require('child_process');
|
|
19
|
+
const hookLog = require('./hook-logger');
|
|
20
|
+
|
|
21
|
+
const MIN_SKILLS = 20;
|
|
22
|
+
const MCP_HEALTH = 'http://127.0.0.1:3110/health';
|
|
23
|
+
const PACKAGE = '@lifeaitools/rdc-skills';
|
|
24
|
+
const stampPath = path.join(os.tmpdir(), 'rdc-skills-environment-last-repair.json');
|
|
25
|
+
|
|
26
|
+
function q(value) {
|
|
27
|
+
return `"${String(value).replace(/"/g, '\\"')}"`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function run(command, args, opts = {}) {
|
|
31
|
+
return execFileSync(command, args, {
|
|
32
|
+
encoding: 'utf8',
|
|
33
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
34
|
+
timeout: opts.timeout || 30000,
|
|
35
|
+
cwd: opts.cwd || process.cwd(),
|
|
36
|
+
env: { ...process.env, ...(opts.env || {}) },
|
|
37
|
+
}).trim();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function shell(command, opts = {}) {
|
|
41
|
+
return execSync(command, {
|
|
42
|
+
encoding: 'utf8',
|
|
43
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
44
|
+
timeout: opts.timeout || 30000,
|
|
45
|
+
cwd: opts.cwd || process.cwd(),
|
|
46
|
+
env: { ...process.env, ...(opts.env || {}) },
|
|
47
|
+
}).trim();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function commandExists(name) {
|
|
51
|
+
try {
|
|
52
|
+
if (process.platform === 'win32') run('where.exe', [name], { timeout: 5000 });
|
|
53
|
+
else run('which', [name], { timeout: 5000 });
|
|
54
|
+
return true;
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function projectRoot() {
|
|
61
|
+
try {
|
|
62
|
+
return shell('git rev-parse --show-toplevel', { timeout: 5000 });
|
|
63
|
+
} catch {
|
|
64
|
+
return process.cwd();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function globalPackageJson() {
|
|
69
|
+
try {
|
|
70
|
+
const root = shell('npm root -g', { timeout: 10000 });
|
|
71
|
+
const pkg = path.join(root, '@lifeaitools', 'rdc-skills', 'package.json');
|
|
72
|
+
if (!fs.existsSync(pkg)) return null;
|
|
73
|
+
return JSON.parse(fs.readFileSync(pkg, 'utf8'));
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function health() {
|
|
80
|
+
try {
|
|
81
|
+
const res = await fetch(MCP_HEALTH, { signal: AbortSignal.timeout(4000) });
|
|
82
|
+
if (!res.ok) return null;
|
|
83
|
+
return await res.json();
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function recentlyRepaired() {
|
|
90
|
+
try {
|
|
91
|
+
const data = JSON.parse(fs.readFileSync(stampPath, 'utf8'));
|
|
92
|
+
return Date.now() - Date.parse(data.ts) < 10 * 60 * 1000;
|
|
93
|
+
} catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function markRepaired(reason) {
|
|
99
|
+
try {
|
|
100
|
+
fs.writeFileSync(stampPath, JSON.stringify({ ts: new Date().toISOString(), reason }, null, 2));
|
|
101
|
+
} catch {
|
|
102
|
+
/* best effort */
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function repair(reason) {
|
|
107
|
+
hookLog('check-rdc-environment', 'SessionStart', 'repair', { reason });
|
|
108
|
+
shell(`npm install -g ${q(`${PACKAGE}@latest`)}`, { timeout: 120000 });
|
|
109
|
+
shell(`rdc-skills-install --profile lifeai --project-root ${q(projectRoot())} --write-startup-blocks`, { timeout: 180000 });
|
|
110
|
+
markRepaired(reason);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function block(message, details = {}) {
|
|
114
|
+
hookLog('check-rdc-environment', 'SessionStart', 'block', { message, ...details });
|
|
115
|
+
process.stdout.write(JSON.stringify({
|
|
116
|
+
systemMessage:
|
|
117
|
+
`HARD BLOCK — RDC skills environment is not healthy.\n\n` +
|
|
118
|
+
`${message}\n\n` +
|
|
119
|
+
`Do not proceed with RDC work until the approved install path is repaired:\n` +
|
|
120
|
+
`npm install -g @lifeaitools/rdc-skills@latest\n` +
|
|
121
|
+
`rdc-skills-install --profile lifeai --project-root ${projectRoot()} --write-startup-blocks`
|
|
122
|
+
}));
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function main() {
|
|
127
|
+
const initialPkg = globalPackageJson();
|
|
128
|
+
const initialHealth = await health();
|
|
129
|
+
const reasons = [];
|
|
130
|
+
|
|
131
|
+
if (!initialPkg) reasons.push('global package missing');
|
|
132
|
+
if (!commandExists('rdc-skills-install')) reasons.push('installer command missing');
|
|
133
|
+
if (!initialHealth || initialHealth.status !== 'ok' || Number(initialHealth.skills || 0) < MIN_SKILLS) {
|
|
134
|
+
reasons.push('local MCP health/catalog invalid');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (reasons.length) {
|
|
138
|
+
if (recentlyRepaired()) {
|
|
139
|
+
block(`RDC skills still unhealthy after a recent repair attempt: ${reasons.join(', ')}`);
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
repair(reasons.join(', '));
|
|
143
|
+
} catch (err) {
|
|
144
|
+
block(`Automatic RDC skills repair failed: ${err.message}`, { reasons });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const finalPkg = globalPackageJson();
|
|
149
|
+
const finalHealth = await health();
|
|
150
|
+
if (!finalPkg) block('Global @lifeaitools/rdc-skills package is missing after repair.');
|
|
151
|
+
if (!commandExists('rdc-skills-install')) block('rdc-skills-install is missing after repair.');
|
|
152
|
+
if (!finalHealth || finalHealth.status !== 'ok' || Number(finalHealth.skills || 0) < MIN_SKILLS) {
|
|
153
|
+
block(`rdc-skills MCP is unhealthy after repair. Health: ${JSON.stringify(finalHealth)}`);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
hookLog('check-rdc-environment', 'SessionStart', 'pass', {
|
|
157
|
+
version: finalPkg.version,
|
|
158
|
+
mcpVersion: finalHealth.version,
|
|
159
|
+
skills: finalHealth.skills,
|
|
160
|
+
});
|
|
161
|
+
process.exit(0);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
main().catch((err) => block(`RDC skills environment check crashed: ${err.message}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifeaitools/rdc-skills",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.4",
|
|
4
4
|
"description": "RDC typed-agent dispatch skill suite for Claude Code - plan, build, review, overnight builds",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"test:mcp:remote": "node tests/mcp.test.mjs --remote",
|
|
39
39
|
"mcp": "node bin/rdc-skills-mcp.mjs",
|
|
40
40
|
"rebuild-mcp": "node scripts/rebuild-mcp.mjs",
|
|
41
|
-
"prepack": "node scripts/
|
|
41
|
+
"prepack": "node scripts/prepack.mjs"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
@@ -707,6 +707,7 @@ function buildHooksConfig(hooksDir, profile = 'core') {
|
|
|
707
707
|
|
|
708
708
|
if (profile === 'lifeai') {
|
|
709
709
|
config.SessionStart = [{ hooks: [
|
|
710
|
+
cmd('check-rdc-environment.js', 'Checking RDC skills runtime...'),
|
|
710
711
|
cmd('check-cwd.js'),
|
|
711
712
|
cmd('check-stale-work-items.js', 'Checking for stale work items...'),
|
|
712
713
|
]}];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Cross-platform prepack steps.
|
|
4
|
+
*
|
|
5
|
+
* The validators are advisory in package builds; they report drift in the
|
|
6
|
+
* LIFEAI publishing corpus, but they must not make `npm pack` fail on Windows
|
|
7
|
+
* because cmd.exe does not provide a POSIX `true` command (the old
|
|
8
|
+
* `... || true && ...` chain silently short-circuited under cmd.exe).
|
|
9
|
+
*
|
|
10
|
+
* stamp-git-sha bakes the current HEAD into git-sha.json so the MCP server can
|
|
11
|
+
* report a PROVABLE running commit on /health even when it runs from the npm
|
|
12
|
+
* install (no .git at runtime). It runs LAST and is required, not advisory.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { spawnSync } from 'node:child_process';
|
|
16
|
+
|
|
17
|
+
const advisory = [
|
|
18
|
+
['scripts/validate-publish-manifests.js', '--mode', 'warn'],
|
|
19
|
+
['scripts/validate-place-histories.js', '--mode', 'warn'],
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
for (const args of advisory) {
|
|
23
|
+
const result = spawnSync(process.execPath, args, { stdio: 'inherit' });
|
|
24
|
+
if (result.error) {
|
|
25
|
+
console.warn(`[prepack] advisory check failed to launch: ${args[0]}: ${result.error.message}`);
|
|
26
|
+
} else if (result.status !== 0) {
|
|
27
|
+
console.warn(`[prepack] advisory check exited ${result.status}: ${args[0]}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Required: stamp the git SHA (never fails the build — writes 'unknown' if git is unavailable).
|
|
32
|
+
spawnSync(process.execPath, ['scripts/stamp-git-sha.mjs'], { stdio: 'inherit' });
|
package/scripts/self-test.mjs
CHANGED
|
@@ -331,6 +331,14 @@ function expectedSkillName(dirOrFile) {
|
|
|
331
331
|
return "rdc:" + base;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
+
function expectedFrontmatterName(dirOrFile, frontmatterName) {
|
|
335
|
+
const base = basename(dirOrFile, ".md");
|
|
336
|
+
if (frontmatterName && frontmatterName.startsWith("rdc:")) {
|
|
337
|
+
return expectedSkillName(dirOrFile);
|
|
338
|
+
}
|
|
339
|
+
return base;
|
|
340
|
+
}
|
|
341
|
+
|
|
334
342
|
function findReferencedFiles(body) {
|
|
335
343
|
const refs = [];
|
|
336
344
|
const guideRe = /(?:^|[\s(`'"/])(?:\.rdc\/)?guides\/([\w/-]+\.md)/g;
|
|
@@ -473,7 +481,7 @@ function auditSkill(filepath) {
|
|
|
473
481
|
}
|
|
474
482
|
}
|
|
475
483
|
|
|
476
|
-
const expected =
|
|
484
|
+
const expected = expectedFrontmatterName(skillDirOrFile, fm.name);
|
|
477
485
|
if (expected && fm.name !== expected) {
|
|
478
486
|
addFinding(
|
|
479
487
|
result,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* stamp-git-sha.mjs — bake the current git HEAD into git-sha.json at pack/publish
|
|
4
|
+
* time. The MCP server runs from the npm-installed copy (no .git), so it cannot
|
|
5
|
+
* `git rev-parse` at runtime; this build-time stamp is how /health reports a
|
|
6
|
+
* PROVABLE commit ("running artifact == this exact published commit"). Run from
|
|
7
|
+
* `prepack`, so `npm pack`/`npm publish` (incl. the publish.yml CI job at the
|
|
8
|
+
* tagged commit) embeds the right SHA. Never fails the build — writes 'unknown'
|
|
9
|
+
* if git is unavailable (e.g. a tarball-only checkout).
|
|
10
|
+
*/
|
|
11
|
+
import { execFileSync } from 'node:child_process';
|
|
12
|
+
import { writeFileSync } from 'node:fs';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
|
|
16
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
17
|
+
let sha = 'unknown';
|
|
18
|
+
try {
|
|
19
|
+
sha = execFileSync('git', ['rev-parse', 'HEAD'], {
|
|
20
|
+
cwd: root,
|
|
21
|
+
encoding: 'utf8',
|
|
22
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
23
|
+
}).trim();
|
|
24
|
+
} catch {
|
|
25
|
+
sha = process.env.RDC_SKILLS_GIT_SHA || 'unknown';
|
|
26
|
+
}
|
|
27
|
+
const out = path.join(root, 'git-sha.json');
|
|
28
|
+
writeFileSync(out, JSON.stringify({ sha }, null, 2) + '\n');
|
|
29
|
+
console.error(`[stamp-git-sha] wrote ${out} sha=${sha}`);
|