@lifeaitools/rdc-skills 0.20.3 → 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/git-sha.json
CHANGED
|
@@ -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,
|