@boyingliu01/xp-gate 0.14.10 → 0.14.12
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/bin/xp-gate.js +13 -2
- package/gate-8.sh +1 -1
- package/hooks/pre-commit +56 -1
- package/lib/__tests__/doctor.test.js +73 -7
- package/lib/__tests__/install-skill.test.js +2 -2
- package/lib/__tests__/sprint-discovery.test.ts +1 -1
- package/lib/__tests__/ui-detector.test.ts +1 -0
- package/lib/__tests__/update-hooks.test.js +6 -1
- package/lib/check.js +59 -18
- package/lib/doctor.js +281 -54
- package/lib/gate-runner.js +46 -1
- package/lib/install-skill.js +2 -0
- package/mock-policy/AGENTS.md +3 -3
- package/mutation/AGENTS.md +3 -3
- package/package.json +1 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
- package/principles/AGENTS.md +3 -3
- package/skills/delphi-review/AGENTS.md +3 -3
- package/skills/sprint-flow/AGENTS.md +3 -3
- package/skills/test-specification-alignment/AGENTS.md +3 -3
package/lib/doctor.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { execSync } = require('child_process');
|
|
4
|
+
const { exec } = require('child_process');
|
|
5
|
+
const util = require('util');
|
|
6
|
+
const execAsync = util.promisify(exec);
|
|
4
7
|
const {
|
|
5
8
|
HOME_DIR,
|
|
6
9
|
CONFIG_DIR,
|
|
@@ -38,6 +41,29 @@ const SIGNATURES = {
|
|
|
38
41
|
'adapter-common.sh': 'detect_project_lang()'
|
|
39
42
|
};
|
|
40
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Hard timeout for all execSync calls in doctor diagnostics.
|
|
46
|
+
* Prevents hanging subprocesses (e.g., missing CLI tools on Windows)
|
|
47
|
+
* from blocking the entire doctor run.
|
|
48
|
+
*/
|
|
49
|
+
const EXEC_TIMEOUT_MS = 3000;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Execute a command with a hard timeout using async exec.
|
|
53
|
+
* Returns { stdout, stderr } on success, null on failure/timeout.
|
|
54
|
+
*/
|
|
55
|
+
async function execWithTimeout(cmd, opts = {}) {
|
|
56
|
+
try {
|
|
57
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
58
|
+
...opts,
|
|
59
|
+
timeout: opts.timeout || EXEC_TIMEOUT_MS,
|
|
60
|
+
});
|
|
61
|
+
return { stdout: stdout.trim(), stderr: stderr.trim() };
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
41
67
|
function isXpGateFile(filePath, signature) {
|
|
42
68
|
if (!fs.existsSync(filePath)) return false;
|
|
43
69
|
try {
|
|
@@ -61,45 +87,83 @@ function saveConfig(config) {
|
|
|
61
87
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
62
88
|
}
|
|
63
89
|
|
|
64
|
-
function getGitDir() {
|
|
90
|
+
async function getGitDir() {
|
|
65
91
|
try {
|
|
66
|
-
|
|
92
|
+
const result = await execWithTimeout('git rev-parse --git-dir');
|
|
93
|
+
return result ? result.stdout : null;
|
|
67
94
|
} catch {
|
|
68
95
|
return null;
|
|
69
96
|
}
|
|
70
97
|
}
|
|
71
98
|
|
|
72
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Synchronous version for --fix code path (runs before async diagnosis).
|
|
101
|
+
* Always includes a 3-second timeout.
|
|
102
|
+
*/
|
|
103
|
+
function getGitDirSync() {
|
|
73
104
|
try {
|
|
74
|
-
|
|
105
|
+
return execSync('git rev-parse --git-dir', {
|
|
75
106
|
encoding: 'utf8',
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
107
|
+
timeout: EXEC_TIMEOUT_MS,
|
|
108
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
109
|
+
}).trim();
|
|
110
|
+
} catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function getCurrentHooksPath() {
|
|
116
|
+
const result = await execWithTimeout('git config --global core.hooksPath', {
|
|
117
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
118
|
+
});
|
|
119
|
+
return result ? result.stdout : null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Synchronous version for --fix code path (runs before async diagnosis).
|
|
124
|
+
* Always includes a 3-second timeout.
|
|
125
|
+
*/
|
|
126
|
+
function getCurrentHooksPathSync() {
|
|
127
|
+
try {
|
|
128
|
+
return execSync('git config --global core.hooksPath', {
|
|
129
|
+
encoding: 'utf8',
|
|
130
|
+
timeout: EXEC_TIMEOUT_MS,
|
|
131
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
132
|
+
}).trim();
|
|
79
133
|
} catch {
|
|
80
134
|
return null;
|
|
81
135
|
}
|
|
82
136
|
}
|
|
83
137
|
|
|
84
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Check environment dependencies — runs all checks IN PARALLEL.
|
|
140
|
+
* @param {Array} checks — mutated with results
|
|
141
|
+
* @returns {Promise<boolean>} all ok
|
|
142
|
+
*/
|
|
143
|
+
async function checkEnv(checks) {
|
|
85
144
|
const envChecks = [
|
|
86
|
-
{ name: 'Node.js', cmd: 'node --version'
|
|
87
|
-
{ name: 'Git', cmd: 'git --version'
|
|
88
|
-
{ name: 'Bash', cmd: 'bash --version'
|
|
145
|
+
{ name: 'Node.js', cmd: 'node --version' },
|
|
146
|
+
{ name: 'Git', cmd: 'git --version' },
|
|
147
|
+
{ name: 'Bash', cmd: 'bash --version' }
|
|
89
148
|
];
|
|
90
149
|
|
|
150
|
+
const results = await Promise.allSettled(
|
|
151
|
+
envChecks.map(async (env) => {
|
|
152
|
+
const result = await execWithTimeout(env.cmd, { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
153
|
+
return { name: env.name, result };
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
|
|
91
157
|
let allOk = true;
|
|
92
|
-
for (const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
checks.push({ name: `Environment: ${
|
|
101
|
-
} catch {
|
|
102
|
-
checks.push({ name: `Environment: ${env.name}`, status: 'FAIL', detail: 'Not found' });
|
|
158
|
+
for (const entry of envChecks) {
|
|
159
|
+
const settled = results.find(r => r.value && r.value.name === entry.name);
|
|
160
|
+
const version = settled && settled.value && settled.value.result
|
|
161
|
+
? settled.value.result.stdout.split('\n')[0]
|
|
162
|
+
: null;
|
|
163
|
+
if (version) {
|
|
164
|
+
checks.push({ name: `Environment: ${entry.name}`, status: 'PASS', detail: version });
|
|
165
|
+
} else {
|
|
166
|
+
checks.push({ name: `Environment: ${entry.name}`, status: 'FAIL', detail: 'Not found' });
|
|
103
167
|
allOk = false;
|
|
104
168
|
}
|
|
105
169
|
}
|
|
@@ -132,9 +196,9 @@ function checkConfig() {
|
|
|
132
196
|
], issues: 0 };
|
|
133
197
|
}
|
|
134
198
|
|
|
135
|
-
function checkLocalHooks(checks) {
|
|
199
|
+
async function checkLocalHooks(checks) {
|
|
136
200
|
let issues = 0;
|
|
137
|
-
const gitDir = getGitDir();
|
|
201
|
+
const gitDir = await getGitDir();
|
|
138
202
|
if (!gitDir) {
|
|
139
203
|
checks.push({ name: 'Git repository', status: 'FAIL', detail: 'Not in a git repo' });
|
|
140
204
|
return 1;
|
|
@@ -145,12 +209,12 @@ function checkLocalHooks(checks) {
|
|
|
145
209
|
return issues;
|
|
146
210
|
}
|
|
147
211
|
|
|
148
|
-
function checkGlobalHooks(checks) {
|
|
212
|
+
async function checkGlobalHooks(checks) {
|
|
149
213
|
let issues = 0;
|
|
150
214
|
issues += checkSingleHook(GLOBAL_HOOKS_DIR, 'pre-commit', SIGNATURES['pre-commit'], 'Global hooks', checks);
|
|
151
215
|
issues += checkSingleHook(GLOBAL_HOOKS_DIR, 'pre-push', SIGNATURES['pre-push'], 'Global hooks', checks);
|
|
152
216
|
|
|
153
|
-
const hooksPath = getCurrentHooksPath();
|
|
217
|
+
const hooksPath = await getCurrentHooksPath();
|
|
154
218
|
if (hooksPath === null || hooksPath === '') {
|
|
155
219
|
checks.push({ name: 'Git core.hooksPath', status: 'FAIL', detail: 'Not set' });
|
|
156
220
|
issues++;
|
|
@@ -188,7 +252,8 @@ const EXPECTED_GATE_SCRIPTS = [
|
|
|
188
252
|
'gate-9.sh',
|
|
189
253
|
];
|
|
190
254
|
|
|
191
|
-
function checkAdapters(checks, mode,
|
|
255
|
+
async function checkAdapters(checks, mode, gitDirPromise) {
|
|
256
|
+
const gitDir = typeof gitDirPromise === 'string' ? gitDirPromise : await gitDirPromise;
|
|
192
257
|
let issues = 0;
|
|
193
258
|
const adaptersDir = mode === 'local'
|
|
194
259
|
? path.join(path.dirname(gitDir || ''), 'githooks', 'adapters')
|
|
@@ -224,12 +289,20 @@ function checkAdapters(checks, mode, gitDir) {
|
|
|
224
289
|
/**
|
|
225
290
|
* Build check report for the doctor.
|
|
226
291
|
* Returns { checks: Array<{name, status, detail}>, issues: number }
|
|
292
|
+
*
|
|
293
|
+
* Uses Promise.allSettled to run independent checks in parallel.
|
|
294
|
+
* Check groups:
|
|
295
|
+
* A) Config-dependent (config, version, templateDir) — sequential (data deps)
|
|
296
|
+
* B) Hooks — depends on config.mode + gitDir
|
|
297
|
+
* C) Adapters — depends on config.mode
|
|
298
|
+
* D) Env + CLI tools — fully independent, run IN PARALLEL
|
|
299
|
+
* E) TUI + Skills — independent, run IN PARALLEL
|
|
227
300
|
*/
|
|
228
|
-
function
|
|
301
|
+
async function diagnoseAsync() {
|
|
229
302
|
const checks = [];
|
|
230
303
|
let issues = 0;
|
|
231
304
|
|
|
232
|
-
// ---
|
|
305
|
+
// --- Phase 1: Config-dependent checks (sequential, data dependencies) ---
|
|
233
306
|
const configResult = checkConfig();
|
|
234
307
|
if (configResult.config === null) {
|
|
235
308
|
return { checks: configResult.checks, issues: configResult.issues };
|
|
@@ -238,35 +311,188 @@ function diagnose() {
|
|
|
238
311
|
checks.push(...configResult.checks);
|
|
239
312
|
issues += configResult.issues;
|
|
240
313
|
|
|
241
|
-
//
|
|
314
|
+
// Version check (sync, no I/O)
|
|
242
315
|
issues += diagnoseVersion(config, getPackageVersion(), checks);
|
|
243
|
-
|
|
244
|
-
// --- Check 3: templateDir validation ---
|
|
316
|
+
// TemplateDir check (sync, no I/O)
|
|
245
317
|
issues += diagnoseTemplateDir(config, checks);
|
|
246
318
|
|
|
247
|
-
// ---
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
319
|
+
// --- Phase 2: Fetch gitDir early (needed by hooks and adapters) ---
|
|
320
|
+
const gitDirPromise = getGitDir();
|
|
321
|
+
|
|
322
|
+
// --- Phase 3: Run independent groups in parallel ---
|
|
323
|
+
// Group A: Hooks (needs config.mode + gitDir)
|
|
324
|
+
const hooksPromise = (async () => {
|
|
325
|
+
if (config.mode === 'local') {
|
|
326
|
+
return checkLocalHooks(checks);
|
|
327
|
+
}
|
|
328
|
+
return checkGlobalHooks(checks);
|
|
329
|
+
})();
|
|
330
|
+
|
|
331
|
+
// Group B: Adapters (needs config.mode + gitDir)
|
|
332
|
+
const adaptersPromise = checkAdapters(checks, config.mode, gitDirPromise);
|
|
333
|
+
|
|
334
|
+
// Group C: Environment checks + CLI tools — fully parallel
|
|
335
|
+
const envPromise = checkEnv(checks);
|
|
336
|
+
const cliToolsPromise = diagnoseCliToolsAsync(checks);
|
|
337
|
+
|
|
338
|
+
// Group D: TUI + Skills (independent)
|
|
339
|
+
const tuiPromise = diagnoseTuiRegistration(checks);
|
|
340
|
+
const skillsPromise = diagnoseInstalledSkills(config, checks);
|
|
341
|
+
|
|
342
|
+
// Wait for ALL parallel groups
|
|
343
|
+
const results = await Promise.allSettled([
|
|
344
|
+
hooksPromise,
|
|
345
|
+
adaptersPromise,
|
|
346
|
+
envPromise,
|
|
347
|
+
cliToolsPromise,
|
|
348
|
+
tuiPromise,
|
|
349
|
+
skillsPromise,
|
|
350
|
+
]);
|
|
351
|
+
|
|
352
|
+
// Collect issue counts from settled promises
|
|
353
|
+
for (const result of results) {
|
|
354
|
+
if (result.status === 'fulfilled' && typeof result.value === 'number') {
|
|
355
|
+
issues += result.value;
|
|
356
|
+
}
|
|
252
357
|
}
|
|
253
358
|
|
|
254
|
-
|
|
255
|
-
|
|
359
|
+
return { checks, issues };
|
|
360
|
+
}
|
|
256
361
|
|
|
257
|
-
|
|
258
|
-
|
|
362
|
+
/**
|
|
363
|
+
* Async CLI tools check — runs each tool detection with a 3-second timeout
|
|
364
|
+
* using async exec. Tools are checked IN PARALLEL via Promise.allSettled.
|
|
365
|
+
* This mirrors checkCliTool logic but uses async exec for parallelization.
|
|
366
|
+
*
|
|
367
|
+
* @param {Array} checks
|
|
368
|
+
* @returns {Promise<number>} issue count
|
|
369
|
+
*/
|
|
370
|
+
async function diagnoseCliToolsAsync(checks) {
|
|
371
|
+
let issues = 0;
|
|
372
|
+
const platform = process.platform;
|
|
373
|
+
const isWindows = platform === 'win32';
|
|
374
|
+
|
|
375
|
+
// Build parallel checks for each tool
|
|
376
|
+
const toolChecks = GATE_CLI_TOOLS.map(async (entry) => {
|
|
377
|
+
const toolName = entry.tool;
|
|
378
|
+
const result = await detectCliToolAsync(toolName, isWindows);
|
|
379
|
+
return { entry, toolName, result };
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// Run ALL tool checks in parallel
|
|
383
|
+
const results = await Promise.allSettled(toolChecks);
|
|
384
|
+
|
|
385
|
+
// Collect results (maintain original order)
|
|
386
|
+
for (const settled of results) {
|
|
387
|
+
if (settled.status === 'rejected') continue;
|
|
388
|
+
const { entry, result } = settled.value;
|
|
389
|
+
const gateLabels = entry.gates.join(', ');
|
|
259
390
|
|
|
260
|
-
|
|
261
|
-
|
|
391
|
+
if (result.available) {
|
|
392
|
+
checks.push({
|
|
393
|
+
name: `CLI tool: ${entry.tool} (${gateLabels})`,
|
|
394
|
+
status: 'PASS',
|
|
395
|
+
detail: result.version || 'available',
|
|
396
|
+
});
|
|
397
|
+
} else {
|
|
398
|
+
const installCmd = getToolInstallCmd(entry, platform);
|
|
399
|
+
checks.push({
|
|
400
|
+
name: `CLI tool: ${entry.tool} (${gateLabels})`,
|
|
401
|
+
status: 'WARN',
|
|
402
|
+
detail: `Not found — install with: ${installCmd}`,
|
|
403
|
+
});
|
|
404
|
+
issues++;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
262
407
|
|
|
263
|
-
|
|
264
|
-
|
|
408
|
+
return issues;
|
|
409
|
+
}
|
|
265
410
|
|
|
266
|
-
|
|
267
|
-
|
|
411
|
+
/**
|
|
412
|
+
* Async CLI tool detection — mirrors checkCliTool but uses async exec
|
|
413
|
+
* with a hard 3-second timeout per subprocess call.
|
|
414
|
+
*
|
|
415
|
+
* @param {string} toolName
|
|
416
|
+
* @param {boolean} isWindows
|
|
417
|
+
* @returns {Promise<{available: boolean, version?: string, path?: string}>}
|
|
418
|
+
*/
|
|
419
|
+
async function detectCliToolAsync(toolName, isWindows) {
|
|
420
|
+
const shell = isWindows ? 'cmd.exe' : '/bin/sh';
|
|
421
|
+
const execOpts = { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'], shell, timeout: EXEC_TIMEOUT_MS };
|
|
422
|
+
|
|
423
|
+
// Step 1: Locate tool via which/where (async, 3s timeout)
|
|
424
|
+
const locator = isWindows ? 'where' : 'which';
|
|
425
|
+
const locatorResult = await execWithTimeout(`${locator} ${toolName}`, execOpts);
|
|
426
|
+
if (locatorResult && locatorResult.stdout) {
|
|
427
|
+
const resolvedPath = locatorResult.stdout.split('\n')[0].trim();
|
|
428
|
+
if (resolvedPath) {
|
|
429
|
+
const version = await getVersionAsync(resolvedPath, isWindows);
|
|
430
|
+
return { available: true, path: resolvedPath, version };
|
|
431
|
+
}
|
|
432
|
+
}
|
|
268
433
|
|
|
269
|
-
|
|
434
|
+
// Step 2: Direct exec fallback (async, 3s timeout)
|
|
435
|
+
const fallbackCmd = isWindows
|
|
436
|
+
? `${toolName} --version`
|
|
437
|
+
: `${toolName} --version 2>/dev/null || ${toolName} -v 2>/dev/null`;
|
|
438
|
+
const fallbackResult = await execWithTimeout(fallbackCmd, execOpts);
|
|
439
|
+
if (fallbackResult && fallbackResult.stdout) {
|
|
440
|
+
return { available: true, path: toolName, version: fallbackResult.stdout.split('\n')[0] };
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// Step 3: Check local fallback paths (sync fs, no exec)
|
|
444
|
+
const localPaths = getLocalFallbackPathsSync(toolName, isWindows);
|
|
445
|
+
for (const localPath of localPaths) {
|
|
446
|
+
if (!fs.existsSync(localPath)) continue;
|
|
447
|
+
const version = await getVersionAsync(localPath, isWindows);
|
|
448
|
+
if (version) {
|
|
449
|
+
return { available: true, path: localPath, version };
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return { available: false };
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Get version string from a tool path using async exec with 3s timeout.
|
|
458
|
+
*/
|
|
459
|
+
async function getVersionAsync(execPath, isWindows) {
|
|
460
|
+
const fallbackCmd = isWindows
|
|
461
|
+
? `"${execPath}" --version`
|
|
462
|
+
: `"${execPath}" --version 2>/dev/null || "${execPath}" -v 2>/dev/null`;
|
|
463
|
+
const result = await execWithTimeout(fallbackCmd);
|
|
464
|
+
return result && result.stdout ? result.stdout.split('\n')[0] : undefined;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Get local fallback paths for CLI tool (sync, no exec).
|
|
469
|
+
* Mirrors getLocalFallbackPaths from detect-deps.js.
|
|
470
|
+
*/
|
|
471
|
+
function getLocalFallbackPathsSync(toolName, isWindows) {
|
|
472
|
+
const os = require('os');
|
|
473
|
+
const home = os.homedir();
|
|
474
|
+
const paths = [path.join(home, '.local', 'bin', toolName)];
|
|
475
|
+
|
|
476
|
+
if (isWindows) {
|
|
477
|
+
const appData = process.env.APPDATA || path.join(home, 'AppData', 'Roaming');
|
|
478
|
+
const localAppData = process.env.LOCALAPPDATA || path.join(home, 'AppData', 'Local');
|
|
479
|
+
paths.push(
|
|
480
|
+
path.join(appData, 'npm', `${toolName}.cmd`),
|
|
481
|
+
path.join(home, '.local', 'bin', `${toolName}.exe`),
|
|
482
|
+
);
|
|
483
|
+
const pythonBase = path.join(localAppData, 'Programs', 'Python');
|
|
484
|
+
if (fs.existsSync(pythonBase)) {
|
|
485
|
+
try {
|
|
486
|
+
for (const entry of fs.readdirSync(pythonBase)) {
|
|
487
|
+
if (entry.startsWith('Python')) {
|
|
488
|
+
paths.push(path.join(pythonBase, entry, 'Scripts', `${toolName}.exe`));
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
} catch { /* skip */ }
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return paths;
|
|
270
496
|
}
|
|
271
497
|
|
|
272
498
|
/**
|
|
@@ -426,7 +652,8 @@ function fixMissingHooks(mode, srcDir, hooksDir) {
|
|
|
426
652
|
function fixCoreHooksPath(globalHooksDir) {
|
|
427
653
|
try {
|
|
428
654
|
execSync(`git config --global core.hooksPath "${globalHooksDir}"`, {
|
|
429
|
-
stdio: ['pipe', 'pipe', 'pipe']
|
|
655
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
656
|
+
timeout: EXEC_TIMEOUT_MS,
|
|
430
657
|
});
|
|
431
658
|
console.log(` ✓ Set core.hooksPath to ${globalHooksDir}`);
|
|
432
659
|
return true;
|
|
@@ -500,7 +727,7 @@ function fixConfigMismatches(config) {
|
|
|
500
727
|
function fixHooksByMode(config, srcDir) {
|
|
501
728
|
let fixed = false;
|
|
502
729
|
if (config.mode === 'local') {
|
|
503
|
-
const gitDir =
|
|
730
|
+
const gitDir = getGitDirSync();
|
|
504
731
|
if (gitDir) {
|
|
505
732
|
const hooksDir = path.join(gitDir, 'hooks');
|
|
506
733
|
fixed = fixMissingHooks('local', srcDir, hooksDir) || fixed;
|
|
@@ -513,7 +740,7 @@ function fixHooksByMode(config, srcDir) {
|
|
|
513
740
|
|
|
514
741
|
function fixGlobalHooksPath(config) {
|
|
515
742
|
if (config.mode !== 'global') return false;
|
|
516
|
-
const hooksPath =
|
|
743
|
+
const hooksPath = getCurrentHooksPathSync();
|
|
517
744
|
if (hooksPath !== GLOBAL_HOOKS_DIR) {
|
|
518
745
|
return fixCoreHooksPath(GLOBAL_HOOKS_DIR);
|
|
519
746
|
}
|
|
@@ -522,7 +749,7 @@ function fixGlobalHooksPath(config) {
|
|
|
522
749
|
|
|
523
750
|
function getAdaptersDirByMode(config) {
|
|
524
751
|
return config.mode === 'local'
|
|
525
|
-
? path.join(path.dirname(
|
|
752
|
+
? path.join(path.dirname(getGitDirSync() || ''), 'githooks', 'adapters')
|
|
526
753
|
: GLOBAL_ADAPTERS_DIR;
|
|
527
754
|
}
|
|
528
755
|
|
|
@@ -842,7 +1069,7 @@ async function doctor(args) {
|
|
|
842
1069
|
fixIssues(null, config);
|
|
843
1070
|
}
|
|
844
1071
|
|
|
845
|
-
const { checks, issues: diagnosedIssues } =
|
|
1072
|
+
const { checks, issues: diagnosedIssues } = await diagnoseAsync();
|
|
846
1073
|
let issues = diagnosedIssues;
|
|
847
1074
|
|
|
848
1075
|
printReport(checks);
|
|
@@ -860,7 +1087,7 @@ async function doctor(args) {
|
|
|
860
1087
|
// Re-run diagnosis after fix to report updated status
|
|
861
1088
|
if (fixMode && isActiveMode(config)) {
|
|
862
1089
|
console.log('\nRe-running diagnosis after fix...');
|
|
863
|
-
const { checks: postChecks } =
|
|
1090
|
+
const { checks: postChecks } = await diagnoseAsync();
|
|
864
1091
|
printReport(postChecks);
|
|
865
1092
|
}
|
|
866
1093
|
|
package/lib/gate-runner.js
CHANGED
|
@@ -11,18 +11,21 @@ const GATE_REGISTRY = {
|
|
|
11
11
|
'0': {
|
|
12
12
|
name: 'Version Consistency',
|
|
13
13
|
description: 'Check VERSION file matches all package.json versions',
|
|
14
|
+
aliases: ['version', '0'],
|
|
14
15
|
preCommitOnly: true,
|
|
15
16
|
reason: 'Requires git-staged context to compare VERSION with package.json files',
|
|
16
17
|
},
|
|
17
18
|
'1': {
|
|
18
19
|
name: 'Code Quality',
|
|
19
20
|
description: 'Language-specific static analysis and linting (ESLint, Ruff, govet, etc.)',
|
|
21
|
+
aliases: ['lint', '1'],
|
|
20
22
|
preCommitOnly: true,
|
|
21
23
|
reason: 'Requires language detection from changed files and adapter routing',
|
|
22
24
|
},
|
|
23
25
|
'2': {
|
|
24
26
|
name: 'Duplicate Code',
|
|
25
27
|
description: 'jscpd duplicate code detection',
|
|
28
|
+
aliases: ['duplicates', 'dup', '2'],
|
|
26
29
|
run: (targetPath) => {
|
|
27
30
|
const jscpdConfig = findConfig(targetPath, 'jscpd.conf.json');
|
|
28
31
|
const args = [targetPath || '.'];
|
|
@@ -33,6 +36,7 @@ const GATE_REGISTRY = {
|
|
|
33
36
|
'3': {
|
|
34
37
|
name: 'Cyclomatic Complexity',
|
|
35
38
|
description: 'lizard cyclomatic complexity analysis',
|
|
39
|
+
aliases: ['complexity', 'ccn', '3'],
|
|
36
40
|
run: (targetPath) => {
|
|
37
41
|
const script = resolveGateScript('3');
|
|
38
42
|
if (script) {
|
|
@@ -47,6 +51,7 @@ const GATE_REGISTRY = {
|
|
|
47
51
|
'4': {
|
|
48
52
|
name: 'Clean Code + SOLID Principles',
|
|
49
53
|
description: '14 Clean Code/SOLID rules across 9 languages',
|
|
54
|
+
aliases: ['principles', 'principle', '4'],
|
|
50
55
|
run: (targetPath) => {
|
|
51
56
|
const { principles } = require('./principles.js');
|
|
52
57
|
return principles([targetPath || '.']);
|
|
@@ -55,12 +60,14 @@ const GATE_REGISTRY = {
|
|
|
55
60
|
'5': {
|
|
56
61
|
name: 'Tests + Coverage',
|
|
57
62
|
description: 'Unit test execution and code coverage enforcement (≥80%)',
|
|
63
|
+
aliases: ['tests', 'test', '5'],
|
|
58
64
|
preCommitOnly: true,
|
|
59
65
|
reason: 'Requires language detection and adapter-sourced test execution with coverage reports',
|
|
60
66
|
},
|
|
61
67
|
'6': {
|
|
62
68
|
name: 'Architecture + Boy Scout Rule',
|
|
63
69
|
description: 'Architecture layer boundary validation and warning baseline enforcement',
|
|
70
|
+
aliases: ['architecture', 'arch', '6'],
|
|
64
71
|
run: (targetPath) => {
|
|
65
72
|
const { arch } = require('./arch.js');
|
|
66
73
|
return arch([]);
|
|
@@ -69,6 +76,7 @@ const GATE_REGISTRY = {
|
|
|
69
76
|
'7': {
|
|
70
77
|
name: 'IaC Security',
|
|
71
78
|
description: 'Infrastructure-as-Code security scanning (checkov, hadolint, kube-score, tflint)',
|
|
79
|
+
aliases: ['iac', 'infra', '7'],
|
|
72
80
|
run: (targetPath) => {
|
|
73
81
|
const script = resolveGateScript('7');
|
|
74
82
|
if (script) {
|
|
@@ -82,6 +90,7 @@ const GATE_REGISTRY = {
|
|
|
82
90
|
'8': {
|
|
83
91
|
name: 'Secret Scanning',
|
|
84
92
|
description: 'gitleaks secret and credential detection',
|
|
93
|
+
aliases: ['secrets', 'secret', '8'],
|
|
85
94
|
run: (targetPath) => {
|
|
86
95
|
const script = resolveGateScript('8');
|
|
87
96
|
if (script) {
|
|
@@ -95,6 +104,7 @@ const GATE_REGISTRY = {
|
|
|
95
104
|
'9': {
|
|
96
105
|
name: 'SAST Security',
|
|
97
106
|
description: 'semgrep static application security testing',
|
|
107
|
+
aliases: ['sast', 'semgrep', '9'],
|
|
98
108
|
run: (targetPath) => {
|
|
99
109
|
const script = resolveGateScript('9');
|
|
100
110
|
if (script) {
|
|
@@ -108,17 +118,51 @@ const GATE_REGISTRY = {
|
|
|
108
118
|
'10': {
|
|
109
119
|
name: 'Build Integrity',
|
|
110
120
|
description: 'TypeScript compilation, npm pack, and import validation',
|
|
121
|
+
aliases: ['build', '10'],
|
|
111
122
|
preCommitOnly: true,
|
|
112
123
|
reason: 'Build integrity checks require language detection and build tool context',
|
|
113
124
|
},
|
|
114
125
|
'11': {
|
|
115
126
|
name: 'Sprint Flow Enforcement',
|
|
116
127
|
description: 'Sprint state and delphi-review validation',
|
|
128
|
+
aliases: ['sprint', '11'],
|
|
117
129
|
preCommitOnly: true,
|
|
118
130
|
reason: 'Requires sprint state (.sprint-state/) and git branch context',
|
|
119
131
|
},
|
|
120
132
|
};
|
|
121
133
|
|
|
134
|
+
// Reverse-lookup: alias → gate ID (built once at module load)
|
|
135
|
+
const ALIAS_MAP = {};
|
|
136
|
+
(function buildAliasMap() {
|
|
137
|
+
for (const [id, info] of Object.entries(GATE_REGISTRY)) {
|
|
138
|
+
const aliases = Array.isArray(info.aliases) ? info.aliases : [];
|
|
139
|
+
for (const alias of aliases) {
|
|
140
|
+
ALIAS_MAP[String(alias).toLowerCase()] = id;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
})();
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Resolve a gate alias (name or number string) to its canonical gate ID.
|
|
147
|
+
* Returns null if no match.
|
|
148
|
+
*/
|
|
149
|
+
function resolveAlias(maybeAlias) {
|
|
150
|
+
if (maybeAlias == null) return null;
|
|
151
|
+
const key = String(maybeAlias).toLowerCase();
|
|
152
|
+
// Direct numeric ID lookup
|
|
153
|
+
if (GATE_REGISTRY[key]) return key;
|
|
154
|
+
// Alias lookup
|
|
155
|
+
return ALIAS_MAP[key] || null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Get all aliases for a given gate ID, or empty array.
|
|
160
|
+
*/
|
|
161
|
+
function getAliases(gateId) {
|
|
162
|
+
const info = GATE_REGISTRY[String(gateId)];
|
|
163
|
+
return info && Array.isArray(info.aliases) ? info.aliases : [];
|
|
164
|
+
}
|
|
165
|
+
|
|
122
166
|
function findConfig(basePath, fileName) {
|
|
123
167
|
const candidates = [
|
|
124
168
|
path.join(basePath || '.', fileName),
|
|
@@ -167,6 +211,7 @@ function getAllGates() {
|
|
|
167
211
|
id,
|
|
168
212
|
name: info.name,
|
|
169
213
|
description: info.description,
|
|
214
|
+
aliases: Array.isArray(info.aliases) ? info.aliases : [],
|
|
170
215
|
preCommitOnly: info.preCommitOnly || false,
|
|
171
216
|
reason: info.reason || null,
|
|
172
217
|
}));
|
|
@@ -206,4 +251,4 @@ async function runGate(gateId, targetPath) {
|
|
|
206
251
|
return 1;
|
|
207
252
|
}
|
|
208
253
|
|
|
209
|
-
module.exports = { GATE_REGISTRY, getGateInfo, getAllGates, runGate };
|
|
254
|
+
module.exports = { GATE_REGISTRY, getGateInfo, getAllGates, runGate, resolveAlias, getAliases };
|
package/lib/install-skill.js
CHANGED
|
@@ -101,6 +101,8 @@ function backupExisting(targetDir, installId, backupDir) {
|
|
|
101
101
|
if (fs.existsSync(targetDir)) {
|
|
102
102
|
fs.mkdirSync(backupDir, { recursive: true });
|
|
103
103
|
copyDirRecursive(targetDir, backupDir);
|
|
104
|
+
// CRITICAL: remove original BEFORE fresh install so old reference/ files don't leak through
|
|
105
|
+
fs.rmSync(targetDir, { recursive: true, force: true });
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
|
package/mock-policy/AGENTS.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# SRC/MOCK-POLICY KNOWLEDGE BASE
|
|
2
2
|
|
|
3
3
|
**Generated:** 2026-07-16
|
|
4
|
-
**Commit:**
|
|
5
|
-
**Branch:**
|
|
6
|
-
**Version:** 0.14.
|
|
4
|
+
**Commit:** 2f70dd5
|
|
5
|
+
**Branch:** main
|
|
6
|
+
**Version:** 0.14.11.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Mock layering policy enforcement — Gate M3 of pre-push hook. Ensures integration tests use real implementations for internal dependencies, mock external dependencies, and annotate pending mocks with removal plans. Combines project scope scanning, mock decision engine, and per-file validation into a single pipeline.
|
package/mutation/AGENTS.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# SRC/MUTATION KNOWLEDGE BASE
|
|
2
2
|
|
|
3
3
|
**Generated:** 2026-07-16
|
|
4
|
-
**Commit:**
|
|
5
|
-
**Branch:**
|
|
6
|
-
**Version:** 0.14.
|
|
4
|
+
**Commit:** 2f70dd5
|
|
5
|
+
**Branch:** main
|
|
6
|
+
**Version:** 0.14.11.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
**Gate M** (incremental mutation testing) + **Gate M2** helpers (test-layer detection used by `src/mock-policy/`). Pre-push quality gate. TypeScript-only; uses Stryker.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xp-gate",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.11",
|
|
4
4
|
"displayName": "XP-Gate",
|
|
5
5
|
"description": "Extreme Programming quality gates + AI workflow skills for Claude Code. Includes 10 quality gates (Gate 0-9), Sprint Flow (11 phases), and Delphi multi-expert review (>=90% consensus).",
|
|
6
6
|
"author": {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
|
|
2
2
|
|
|
3
3
|
**Generated:** 2026-07-16
|
|
4
|
-
**Commit:**
|
|
5
|
-
**Branch:**
|
|
6
|
-
**Version:** 0.14.
|
|
4
|
+
**Commit:** 2f70dd5
|
|
5
|
+
**Branch:** main
|
|
6
|
+
**Version:** 0.14.11.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, 3 experts from ≥2 providers, domestic models only). Supports design + code-walkthrough modes.
|