@boyingliu01/xp-gate 0.41.9 → 0.41.52
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/adapters/gate-3.sh +28 -1
- package/adapters/gate-6-layers.sh +18 -1
- package/bin/xp-gate.js +13 -0
- package/gate-3.sh +28 -1
- package/gate-6-layers.sh +18 -1
- package/gates/python-health.ts +74 -26
- package/gates/test-layers.ts +94 -9
- package/hooks/gate-3.sh +28 -1
- package/hooks/gate-6-layers.sh +18 -1
- package/hooks/gate-entries/gate-11-entry.sh +21 -0
- package/hooks/gate-entries/gate-2-entry.sh +15 -0
- package/hooks/install.sh +15 -3
- package/hooks/pre-commit +90 -13
- package/hooks/pre-push +10 -1
- package/hooks/sprint-gate.sh +101 -13
- package/lib/check-alignment-runner.cjs +97 -0
- package/lib/check.js +6 -0
- package/lib/crap-cli.js +14 -6
- package/lib/delphi-setup.js +13 -0
- package/lib/doctor-tui.js +205 -102
- package/lib/doctor.js +146 -7
- package/lib/gate-runner.js +14 -3
- package/lib/init-install.js +299 -0
- package/lib/init-languages.js +158 -0
- package/lib/init-manifest.js +165 -0
- package/lib/init-md-injection.js +58 -0
- package/lib/init.js +134 -500
- package/lib/install-skill.js +66 -1
- package/lib/layer-baseline.cjs +94 -0
- package/lib/mattpocock-license-verdict.json +7 -0
- package/lib/uninstall-skills.js +140 -0
- package/lib/uninstall.js +41 -100
- package/lib/update-skill.js +9 -1
- package/package.json +3 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/delphi-review/INSTALL.md +22 -3
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/claude-code/skills/sprint-flow/references/definition-of-done.md +2 -2
- package/plugins/claude-code/skills/sprint-flow/references/phase-3-build.md +1 -1
- package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +2 -2
- package/plugins/claude-code/skills/sprint-flow/references/phase-6-close.md +17 -0
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/lib/delphi-evidence.d.ts +59 -0
- package/plugins/dsh/lib/delphi-evidence.d.ts.map +1 -0
- package/plugins/dsh/lib/delphi-evidence.js +128 -0
- package/plugins/dsh/lib/delphi-finding.d.ts +123 -0
- package/plugins/dsh/lib/delphi-finding.d.ts.map +1 -0
- package/plugins/dsh/lib/delphi-finding.js +332 -0
- package/plugins/dsh/lib/delphi-findings-parse.d.ts +29 -0
- package/plugins/dsh/lib/delphi-findings-parse.d.ts.map +1 -0
- package/plugins/dsh/lib/delphi-findings-parse.js +138 -0
- package/plugins/dsh/lib/delphi-ledger.d.ts +55 -0
- package/plugins/dsh/lib/delphi-ledger.d.ts.map +1 -0
- package/plugins/dsh/lib/delphi-ledger.js +124 -0
- package/plugins/dsh/lib/delphi-run.d.ts +7 -0
- package/plugins/dsh/lib/delphi-run.d.ts.map +1 -1
- package/plugins/dsh/lib/delphi-run.js +48 -18
- package/plugins/dsh/lib/delphi-seats.d.ts +34 -0
- package/plugins/dsh/lib/delphi-seats.d.ts.map +1 -0
- package/plugins/dsh/lib/delphi-seats.js +40 -0
- package/plugins/dsh/lib/evidence.d.ts +21 -0
- package/plugins/dsh/lib/evidence.d.ts.map +1 -1
- package/plugins/dsh/lib/evidence.js +3 -0
- package/plugins/dsh/lib/index.d.ts.map +1 -1
- package/plugins/dsh/lib/index.js +12 -0
- package/plugins/dsh/package.json +1 -1
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/delphi-review/INSTALL.md +22 -3
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/sprint-flow/references/definition-of-done.md +2 -2
- package/plugins/dsh/skills/sprint-flow/references/phase-3-build.md +1 -1
- package/plugins/dsh/skills/sprint-flow/references/phase-4-verify.md +2 -2
- package/plugins/dsh/skills/sprint-flow/references/phase-6-close.md +17 -0
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/src/delphi-evidence.test.ts +100 -0
- package/plugins/dsh/src/delphi-evidence.ts +201 -0
- package/plugins/dsh/src/delphi-finding.test.ts +333 -0
- package/plugins/dsh/src/delphi-finding.ts +446 -0
- package/plugins/dsh/src/delphi-findings-parse.test.ts +100 -0
- package/plugins/dsh/src/delphi-findings-parse.ts +158 -0
- package/plugins/dsh/src/delphi-findings.test.ts +4 -0
- package/plugins/dsh/src/delphi-ledger.test.ts +210 -0
- package/plugins/dsh/src/delphi-ledger.ts +158 -0
- package/plugins/dsh/src/delphi-run.test.ts +71 -68
- package/plugins/dsh/src/delphi-run.ts +80 -24
- package/plugins/dsh/src/delphi-seats.test.ts +117 -0
- package/plugins/dsh/src/delphi-seats.ts +50 -0
- package/plugins/dsh/src/evidence-findings.test.ts +75 -0
- package/plugins/dsh/src/evidence.ts +25 -0
- package/plugins/dsh/src/index.ts +14 -0
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/delphi-review/INSTALL.md +22 -3
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/sprint-flow/references/definition-of-done.md +2 -2
- package/plugins/opencode/skills/sprint-flow/references/phase-3-build.md +1 -1
- package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +2 -2
- package/plugins/opencode/skills/sprint-flow/references/phase-6-close.md +17 -0
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/delphi-review/INSTALL.md +22 -3
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/qoder/skills/sprint-flow/references/definition-of-done.md +2 -2
- package/plugins/qoder/skills/sprint-flow/references/phase-3-build.md +1 -1
- package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +2 -2
- package/plugins/qoder/skills/sprint-flow/references/phase-6-close.md +17 -0
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
- package/principles/index.ts +50 -1
- package/scripts/delphi-config-read.cjs +43 -6
- package/scripts/delphi-external-review.cjs +69 -12
- package/scripts/delphi-prompts.cjs +47 -1
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/delphi-review/INSTALL.md +22 -3
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/sprint-flow/references/definition-of-done.md +2 -2
- package/skills/sprint-flow/references/phase-3-build.md +1 -1
- package/skills/sprint-flow/references/phase-4-verify.md +2 -2
- package/skills/sprint-flow/references/phase-6-close.md +17 -0
- package/skills/test-specification-alignment/AGENTS.md +1 -1
- package/sprint-gate.sh +101 -13
- package/mutation/stryker-types.ts +0 -14
package/lib/doctor-tui.js
CHANGED
|
@@ -12,8 +12,36 @@ const PKG_DIR = path.dirname(__dirname);
|
|
|
12
12
|
/**
|
|
13
13
|
* TUI registration path and expected plugin entry.
|
|
14
14
|
*/
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const OPENCODE_DIR = path.join(HOME_DIR, '.config', 'opencode');
|
|
16
|
+
const TUI_JSON_PATH = path.join(OPENCODE_DIR, 'tui.json');
|
|
17
|
+
/**
|
|
18
|
+
* The plugin entry to register.
|
|
19
|
+
*
|
|
20
|
+
* #839: this used to be `@boyingliu01/opencode-plugin/tui`, a subpath the published
|
|
21
|
+
* package has NEVER exported -- the plugin's own README says the TUI panel was
|
|
22
|
+
* abandoned in v0.13.0 and the subpath export was removed in 0.35.15, because v2's
|
|
23
|
+
* installer treats the whole string as a package name and fails with
|
|
24
|
+
* NpmInstallFailedError. `doctor` was writing that broken reference, reporting it as
|
|
25
|
+
* `✓ registered`, and `doctor --fix` would CREATE the fault.
|
|
26
|
+
*
|
|
27
|
+
* A failing check is information. A check that confirms a broken state is a lie that
|
|
28
|
+
* happens to be green, and this one hid the fact that the TUI side never loaded.
|
|
29
|
+
*
|
|
30
|
+
* The bare package name is what the README tells users to register, and it is what
|
|
31
|
+
* the manifest exports as ".".
|
|
32
|
+
*/
|
|
33
|
+
const TUI_PLUGIN_ENTRY = '@boyingliu01/opencode-plugin';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Entries an older version wrote that no longer resolve.
|
|
37
|
+
*
|
|
38
|
+
* Reported rather than ignored: the user's config still contains them, OpenCode
|
|
39
|
+
* still trips over them at startup, and silently accepting the file would leave
|
|
40
|
+
* `doctor` green about a config that fails to load.
|
|
41
|
+
*/
|
|
42
|
+
const TUI_LEGACY_BROKEN_ENTRIES = [
|
|
43
|
+
'@boyingliu01/opencode-plugin/tui',
|
|
44
|
+
];
|
|
17
45
|
|
|
18
46
|
/**
|
|
19
47
|
* Read and parse tui.json, returning { data, error }.
|
|
@@ -42,19 +70,64 @@ function diagnoseTuiRegistration(checks) {
|
|
|
42
70
|
return 1;
|
|
43
71
|
}
|
|
44
72
|
|
|
73
|
+
// #840: "no OpenCode config directory" is not "the user failed to configure it".
|
|
74
|
+
//
|
|
75
|
+
// The missing directory means there is nothing to register a TUI INTO, and no
|
|
76
|
+
// OpenCode-specific check should exist on that machine. Reporting FAIL made
|
|
77
|
+
// `doctor` exit 1 on every box that has never had OpenCode -- while the
|
|
78
|
+
// neighbouring OpenCode check on the same machine already said
|
|
79
|
+
// `[SKIP] opencode plugin: 未检测到 OpenCode`. One check disagreeing with the
|
|
80
|
+
// policy the rest of the file follows.
|
|
81
|
+
//
|
|
82
|
+
// A PRESENT directory with no registration stays FAIL below: that is the
|
|
83
|
+
// auto-registration not happening, which is exactly what this check is for.
|
|
84
|
+
if (!fs.existsSync(OPENCODE_DIR)) {
|
|
85
|
+
checks.push({
|
|
86
|
+
name: 'TUI registration',
|
|
87
|
+
status: 'SKIP',
|
|
88
|
+
detail: 'Not installed: no ~/.config/opencode on this machine',
|
|
89
|
+
});
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
45
93
|
if (data === null) {
|
|
46
94
|
checks.push({ name: 'TUI registration', status: 'FAIL', detail: 'Not registered' });
|
|
47
95
|
return 1;
|
|
48
96
|
}
|
|
49
97
|
|
|
50
98
|
const plugins = Array.isArray(data.plugin) ? data.plugin : [];
|
|
99
|
+
const verdict = judgePluginList(plugins);
|
|
100
|
+
checks.push({ name: 'TUI registration', ...verdict });
|
|
101
|
+
return verdict.status === 'PASS' ? 0 : 1;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The verdict for a plugin list, without the check plumbing.
|
|
106
|
+
*
|
|
107
|
+
* Split out because `diagnoseTuiRegistration` crossed 50 lines as four returns
|
|
108
|
+
* accumulated -- one per reason it can decline. Those reasons are about the LIST,
|
|
109
|
+
* not about reading files, so they read better on their own.
|
|
110
|
+
*
|
|
111
|
+
* @param {string[]} plugins
|
|
112
|
+
* @returns {{status: string, detail: string}}
|
|
113
|
+
*/
|
|
114
|
+
function judgePluginList(plugins) {
|
|
115
|
+
// #839: an entry an older version wrote, which resolves to nothing. Reported
|
|
116
|
+
// separately from "not registered" because the repair is different -- this one
|
|
117
|
+
// has to be REMOVED, and leaving it makes OpenCode fail on every startup.
|
|
118
|
+
const broken = plugins.filter((p) => TUI_LEGACY_BROKEN_ENTRIES.includes(p));
|
|
119
|
+
if (broken.length > 0) {
|
|
120
|
+
return {
|
|
121
|
+
status: 'FAIL',
|
|
122
|
+
detail: `${broken.join(', ')} does not exist in the published plugin (no /tui export) and breaks OpenCode startup — remove it from tui.json`,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
51
126
|
if (plugins.includes(TUI_PLUGIN_ENTRY)) {
|
|
52
|
-
|
|
53
|
-
return 0;
|
|
127
|
+
return { status: 'PASS', detail: `${TUI_PLUGIN_ENTRY} registered` };
|
|
54
128
|
}
|
|
55
129
|
|
|
56
|
-
|
|
57
|
-
return 1;
|
|
130
|
+
return { status: 'FAIL', detail: 'Not registered' };
|
|
58
131
|
}
|
|
59
132
|
|
|
60
133
|
/**
|
|
@@ -181,6 +254,29 @@ function listInstalledSkillNames(dir) {
|
|
|
181
254
|
* @param {Array} checks
|
|
182
255
|
* @returns {number} issue count
|
|
183
256
|
*/
|
|
257
|
+
/**
|
|
258
|
+
* Check a NAMED set of skills in every platform directory that has them (#755).
|
|
259
|
+
*
|
|
260
|
+
* The explicit `installedSkills` list names which skills, not which directories. It used
|
|
261
|
+
* to narrow the check to the current platform's directory, so a corrupted copy elsewhere
|
|
262
|
+
* reported `✓ Up to date` -- and the list is written by `install-skill`, not only by
|
|
263
|
+
* `init`, so real installs take this branch.
|
|
264
|
+
*
|
|
265
|
+
* @param {string[]} names skills to check
|
|
266
|
+
* @param {Array<{platform: string, dir: string}>} targets every known platform directory
|
|
267
|
+
* @param {string} bundledSkillsDir this package's own skills
|
|
268
|
+
* @param {Array} checks collector
|
|
269
|
+
* @returns {number} issue count
|
|
270
|
+
*/
|
|
271
|
+
function checkNamedSkillsEverywhere(names, targets, bundledSkillsDir, checks) {
|
|
272
|
+
let issues = 0;
|
|
273
|
+
for (const target of targets) {
|
|
274
|
+
if (!fs.existsSync(target.dir)) continue;
|
|
275
|
+
issues += diagnoseSkillsInDir(names, target.dir, bundledSkillsDir, checks, target.platform);
|
|
276
|
+
}
|
|
277
|
+
return issues;
|
|
278
|
+
}
|
|
279
|
+
|
|
184
280
|
function diagnoseInstalledSkills(config, checks) {
|
|
185
281
|
const bundledSkillsDir = path.join(PKG_DIR, 'skills');
|
|
186
282
|
if (!fs.existsSync(bundledSkillsDir)) {
|
|
@@ -191,19 +287,22 @@ function diagnoseInstalledSkills(config, checks) {
|
|
|
191
287
|
const explicit = config && config.installedSkills ? Object.keys(config.installedSkills) : [];
|
|
192
288
|
const targets = skillsDeployTargets();
|
|
193
289
|
|
|
194
|
-
// An explicit `installedSkills` list
|
|
195
|
-
//
|
|
196
|
-
//
|
|
290
|
+
// An explicit `installedSkills` list names WHICH SKILLS to check. It says nothing
|
|
291
|
+
// about which DIRECTORIES they live in.
|
|
292
|
+
//
|
|
293
|
+
// #755: this branch used to read it as a scope narrowing and check only the current
|
|
294
|
+
// platform's directory. Measured on 0.36.0 with the opencode copy deliberately broken:
|
|
295
|
+
// doctor reported `✓ Skill: delphi-review: Up to date` -- because it had checked the
|
|
296
|
+
// qoder copy and nothing else. Removing `installedSkills` from the config made the same
|
|
297
|
+
// corruption appear immediately across four platforms.
|
|
197
298
|
//
|
|
198
|
-
// The
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
const platform = detectPlatform();
|
|
299
|
+
// The old comment justified the asymmetry with "`xp-gate init` never writes this field".
|
|
300
|
+
// That is true of `init` and false of the product: `install-skill` writes it (see
|
|
301
|
+
// install-skill.js), so any user who has installed a single skill by name gets the
|
|
302
|
+
// narrowed branch -- and loses multi-platform drift detection, which is precisely what
|
|
303
|
+
// doctor is for.
|
|
204
304
|
if (explicit.length > 0) {
|
|
205
|
-
|
|
206
|
-
return diagnoseSkillsInDir(explicit, match.dir, bundledSkillsDir, checks, null);
|
|
305
|
+
return checkNamedSkillsEverywhere(explicit, targets, bundledSkillsDir, checks);
|
|
207
306
|
}
|
|
208
307
|
|
|
209
308
|
// No explicit list: verify every directory that actually has skills deployed.
|
|
@@ -241,96 +340,99 @@ function diagnoseSkillsInDir(skillNames, userSkillsDir, bundledSkillsDir, checks
|
|
|
241
340
|
|
|
242
341
|
let issues = 0;
|
|
243
342
|
for (const name of skillNames) {
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (
|
|
248
|
-
if (!fs.existsSync(userSkillMd)) {
|
|
249
|
-
checks.push({ name: label(name), status: 'FAIL', detail: 'Installed SKILL.md missing' });
|
|
250
|
-
issues++;
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const bundledContent = fs.readFileSync(bundledSkillMd, 'utf8');
|
|
255
|
-
const userContent = fs.readFileSync(userSkillMd, 'utf8');
|
|
256
|
-
|
|
257
|
-
// Try semver comparison if both SKILL.md files have version frontmatter
|
|
258
|
-
const bundledVersion = extractSkillVersion(bundledContent);
|
|
259
|
-
const userVersion = extractSkillVersion(userContent);
|
|
260
|
-
|
|
261
|
-
if (bundledVersion !== undefined && userVersion !== undefined) {
|
|
262
|
-
const cmp = compareSemver(userVersion, bundledVersion);
|
|
263
|
-
if (cmp === undefined) {
|
|
264
|
-
// Version strings not valid semver — fall back to content comparison
|
|
265
|
-
if (!sameContentIgnoringLineEndings(bundledContent, userContent)) {
|
|
266
|
-
checks.push({
|
|
267
|
-
name: label(name),
|
|
268
|
-
status: 'WARN',
|
|
269
|
-
detail: `Outdated — run xp-gate update-skill --all (installed: ${userVersion}, bundled: ${bundledVersion})`,
|
|
270
|
-
});
|
|
271
|
-
issues++;
|
|
272
|
-
} else {
|
|
273
|
-
checks.push({ name: label(name), status: 'PASS', detail: 'Up to date' });
|
|
274
|
-
}
|
|
275
|
-
} else if (cmp < 0) {
|
|
276
|
-
checks.push({
|
|
277
|
-
name: label(name),
|
|
278
|
-
status: 'WARN',
|
|
279
|
-
detail: `Outdated — run xp-gate update-skill --all (installed: ${userVersion}, bundled: ${bundledVersion})`,
|
|
280
|
-
});
|
|
281
|
-
issues++;
|
|
282
|
-
} else {
|
|
283
|
-
// cmp >= 0: installed version is same or newer than bundled.
|
|
284
|
-
//
|
|
285
|
-
// #681: an EQUAL version is a claim, not a fact. A skill that gained a
|
|
286
|
-
// whole chapter without a version bump reported "Up to date" while the
|
|
287
|
-
// installed copy was ~20k characters behind, and `update-skill` agreed.
|
|
288
|
-
// So when the versions tie, still compare the bodies — and do NOT
|
|
289
|
-
// prescribe `update-skill` on a difference: the installed copy may be
|
|
290
|
-
// NEWER than main (the same asymmetry the versionless branch below
|
|
291
|
-
// already respects), so the advice is "compare manually".
|
|
292
|
-
const sameBody = sameContentIgnoringLineEndings(
|
|
293
|
-
withoutVersionLine(bundledContent),
|
|
294
|
-
withoutVersionLine(userContent)
|
|
295
|
-
);
|
|
296
|
-
if (!sameBody) {
|
|
297
|
-
checks.push({
|
|
298
|
-
name: label(name),
|
|
299
|
-
status: 'WARN',
|
|
300
|
-
detail: `Content differs at the same version ${userVersion} — the version was not bumped when the skill changed; compare manually before running update-skill`,
|
|
301
|
-
});
|
|
302
|
-
issues++;
|
|
303
|
-
} else {
|
|
304
|
-
checks.push({ name: label(name), status: 'PASS', detail: 'Up to date' });
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
} else {
|
|
308
|
-
// No version in at least one file — compare content, but not byte-for-byte:
|
|
309
|
-
// line endings alone are not evidence of staleness (#439). And without a
|
|
310
|
-
// version we cannot call it "Outdated": update-skill pulls from main,
|
|
311
|
-
// which may be OLDER than what the user has installed, so the advice is
|
|
312
|
-
// "compare manually", never the destructive update command (#439). The
|
|
313
|
-
// version line itself is excluded from the comparison -- metadata, not
|
|
314
|
-
// content.
|
|
315
|
-
if (!sameContentIgnoringLineEndings(
|
|
316
|
-
withoutVersionLine(bundledContent),
|
|
317
|
-
withoutVersionLine(userContent)
|
|
318
|
-
)) {
|
|
319
|
-
checks.push({
|
|
320
|
-
name: label(name),
|
|
321
|
-
status: 'WARN',
|
|
322
|
-
detail: 'Content differs and version cannot be determined (missing version frontmatter) — compare manually before running update-skill (it pulls from main, which may be older than the installed copy)',
|
|
323
|
-
});
|
|
324
|
-
issues++;
|
|
325
|
-
} else {
|
|
326
|
-
checks.push({ name: label(name), status: 'PASS', detail: 'Up to date' });
|
|
327
|
-
}
|
|
328
|
-
}
|
|
343
|
+
const verdict = diagnoseOneSkill(name, userSkillsDir, bundledSkillsDir);
|
|
344
|
+
if (verdict === null) continue;
|
|
345
|
+
checks.push({ ...verdict, name: label(name) });
|
|
346
|
+
if (verdict.status !== 'PASS') issues++;
|
|
329
347
|
}
|
|
330
348
|
|
|
331
349
|
return issues;
|
|
332
350
|
}
|
|
333
351
|
|
|
352
|
+
/**
|
|
353
|
+
* Read a skill file, or null when it is absent.
|
|
354
|
+
*
|
|
355
|
+
* Guarded because a missing file is a NORMAL outcome here (the caller distinguishes
|
|
356
|
+
* "not installed" from "differs"), and an unguarded read turns that into an
|
|
357
|
+
* exception that aborts the whole doctor run.
|
|
358
|
+
*/
|
|
359
|
+
function readSkillOrNull(filePath) {
|
|
360
|
+
try {
|
|
361
|
+
return fs.readFileSync(filePath, 'utf8');
|
|
362
|
+
} catch {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* The verdict for one skill, or null when it does not need reporting.
|
|
369
|
+
*
|
|
370
|
+
* Extracted from `diagnoseSkillsInDir`, which read at 94 lines with five levels of
|
|
371
|
+
* nesting: the file's own "too long / too deep / unguarded IO" findings all pointed
|
|
372
|
+
* at the same function, and all three were the SHAPE of the loop rather than
|
|
373
|
+
* anything about a skill. Splitting the per-skill decision out lets each branch be
|
|
374
|
+
* read on its own.
|
|
375
|
+
*
|
|
376
|
+
* @returns {{status: string, detail: string} | null}
|
|
377
|
+
*/
|
|
378
|
+
function diagnoseOneSkill(name, userSkillsDir, bundledSkillsDir) {
|
|
379
|
+
const bundledContent = readSkillOrNull(path.join(bundledSkillsDir, name, 'SKILL.md'));
|
|
380
|
+
if (bundledContent === null) return null;
|
|
381
|
+
|
|
382
|
+
const userContent = readSkillOrNull(path.join(userSkillsDir, name, 'SKILL.md'));
|
|
383
|
+
if (userContent === null) {
|
|
384
|
+
return { status: 'FAIL', detail: 'Installed SKILL.md missing' };
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const bundledVersion = extractSkillVersion(bundledContent);
|
|
388
|
+
const userVersion = extractSkillVersion(userContent);
|
|
389
|
+
if (bundledVersion === undefined || userVersion === undefined) {
|
|
390
|
+
return compareBodies(bundledContent, userContent, null, null);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const cmp = compareSemver(userVersion, bundledVersion);
|
|
394
|
+
if (cmp === undefined || cmp < 0) {
|
|
395
|
+
// An unparseable pair falls back to the same content comparison, and both
|
|
396
|
+
// cases prescribe update-skill: a lower installed version is genuinely behind.
|
|
397
|
+
const verdict = compareBodies(bundledContent, userContent, userVersion, bundledVersion);
|
|
398
|
+
return verdict.status === 'WARN' && cmp !== undefined
|
|
399
|
+
? { status: 'WARN', detail: `Outdated — run xp-gate update-skill --all (installed: ${userVersion}, bundled: ${bundledVersion})` }
|
|
400
|
+
: verdict;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return compareBodies(bundledContent, userContent, userVersion, bundledVersion);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Compare skill bodies when the version cannot decide it.
|
|
408
|
+
*
|
|
409
|
+
* Three situations reach here, and the ADVICE differs between them:
|
|
410
|
+
* - equal semver: the version did not get bumped, so "compare manually" (#681)
|
|
411
|
+
* - unparseable: same advice
|
|
412
|
+
* - no version: same advice, never `update-skill`, which pulls from main and
|
|
413
|
+
* may be OLDER than the installed copy (#439)
|
|
414
|
+
*
|
|
415
|
+
* The version line itself is excluded: it is metadata, not content.
|
|
416
|
+
*/
|
|
417
|
+
function compareBodies(bundledContent, userContent, userVersion, bundledVersion) {
|
|
418
|
+
const same = sameContentIgnoringLineEndings(
|
|
419
|
+
withoutVersionLine(bundledContent),
|
|
420
|
+
withoutVersionLine(userContent),
|
|
421
|
+
);
|
|
422
|
+
if (same) return { status: 'PASS', detail: 'Up to date' };
|
|
423
|
+
|
|
424
|
+
if (userVersion && bundledVersion) {
|
|
425
|
+
return {
|
|
426
|
+
status: 'WARN',
|
|
427
|
+
detail: `Content differs at the same version ${userVersion} — the version was not bumped when the skill changed; compare manually before running update-skill`,
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
return {
|
|
431
|
+
status: 'WARN',
|
|
432
|
+
detail: 'Content differs and version cannot be determined (missing version frontmatter) — compare manually before running update-skill (it pulls from main, which may be older than the installed copy)',
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
|
|
334
436
|
/**
|
|
335
437
|
* Fix TUI registration: ensure @boyingliu01/opencode-plugin/tui is in tui.json.
|
|
336
438
|
* Uses atomic write (tmp + renameSync) for JSON safety.
|
|
@@ -404,6 +506,7 @@ function ensureTuiRegistration() {
|
|
|
404
506
|
module.exports = {
|
|
405
507
|
TUI_JSON_PATH,
|
|
406
508
|
TUI_PLUGIN_ENTRY,
|
|
509
|
+
TUI_LEGACY_BROKEN_ENTRIES,
|
|
407
510
|
readTuiJson,
|
|
408
511
|
diagnoseTuiRegistration,
|
|
409
512
|
diagnoseInstalledSkills,
|
package/lib/doctor.js
CHANGED
|
@@ -125,6 +125,35 @@ const EXEC_TIMEOUT_MS = 1500;
|
|
|
125
125
|
*/
|
|
126
126
|
const GLOBAL_DIAGNOSIS_TIMEOUT_MS = 10000;
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* The surfaces a full diagnosis reports, as patterns over REAL check names.
|
|
130
|
+
*
|
|
131
|
+
* #777: the timeout notice used to name a hardcoded list
|
|
132
|
+
* (`['Hooks', 'Adapters', 'Skills', 'Gate env', 'OpenCode TUI']`) and NONE of those is
|
|
133
|
+
* a check name. `Hooks` is a LABEL handed to `checkSingleHook`, the adapters check is
|
|
134
|
+
* recorded as `Adapters directory`, and `Gate env` / `OpenCode TUI` appear nowhere. A
|
|
135
|
+
* name that is never in `reported` is always "pending", so the notice named all five
|
|
136
|
+
* every time -- including in the same output where `✓ Adapters directory: 24 file(s)`
|
|
137
|
+
* and twelve `✓ Skill: ...` lines had just succeeded.
|
|
138
|
+
*
|
|
139
|
+
* Patterns rather than a literal list because half these checks are named at runtime:
|
|
140
|
+
* the hook checks are `pre-commit` / `pre-push` / ..., and skills are
|
|
141
|
+
* `Skill: <name>` per installed skill. A literal list cannot cover them and would
|
|
142
|
+
* drift again the next time one is added.
|
|
143
|
+
*
|
|
144
|
+
* When a new check starts reporting a surface nobody listed here, the omission shows
|
|
145
|
+
* up as that surface never being named as pending -- which is the quiet direction. The
|
|
146
|
+
* loud direction (naming a surface that DID report) is what was broken, and patterns
|
|
147
|
+
* make that impossible.
|
|
148
|
+
*/
|
|
149
|
+
const REPORTED_SURFACE_PATTERNS = [
|
|
150
|
+
/^pre-commit$/, /^pre-push$/, /^post-merge$/, /^post-commit$/,
|
|
151
|
+
/^Adapters directory$/,
|
|
152
|
+
/^Skill: /,
|
|
153
|
+
/^Gate scripts$/,
|
|
154
|
+
/^TUI registration$/,
|
|
155
|
+
];
|
|
156
|
+
|
|
128
157
|
/**
|
|
129
158
|
* Merge a timed-out partial diagnosis into one honest verdict (#629).
|
|
130
159
|
*
|
|
@@ -144,7 +173,29 @@ const GLOBAL_DIAGNOSIS_TIMEOUT_MS = 10000;
|
|
|
144
173
|
function mergeTimedOutDiagnosis(partial, pending) {
|
|
145
174
|
const completed = (partial && Array.isArray(partial.checks)) ? partial.checks : [];
|
|
146
175
|
const inherited = (partial && Number.isFinite(partial.issues)) ? partial.issues : 0;
|
|
147
|
-
|
|
176
|
+
// #777: drop anything the run DID report, whatever the caller passed. The caller is
|
|
177
|
+
// the only place that knows what it expected, but only this function knows what
|
|
178
|
+
// actually arrived -- and naming a completed check as pending is the defect, so the
|
|
179
|
+
// filter belongs on the side that has the evidence.
|
|
180
|
+
const reportedNames = completed.map((c) => c && c.name).filter(Boolean);
|
|
181
|
+
const pendingNames = (Array.isArray(pending) ? pending.filter(Boolean) : [])
|
|
182
|
+
.filter((name) => !reportedNames.includes(name))
|
|
183
|
+
// A surface is satisfied when ANY reported name carries it as a word-boundary
|
|
184
|
+
// prefix, in either direction. `Adapters` is satisfied by `Adapters directory`
|
|
185
|
+
// (the reported name is longer), and `Skill: delphi-review` satisfies `Skills`
|
|
186
|
+
// through its `Skill` stem. Matching whole strings was the original bug in a
|
|
187
|
+
// different shape: the label and the check name differ, and an exact test can
|
|
188
|
+
// never reconcile them.
|
|
189
|
+
.filter((name) => {
|
|
190
|
+
// Strip a trailing plural `s` as well: `Skills` (the label) against `Skill: x`
|
|
191
|
+
// (the check) differ by one letter, and that one letter is why the pair never
|
|
192
|
+
// matched.
|
|
193
|
+
const stem = name.toLowerCase().replace(/[^a-z0-9]+/g, '').replace(/s$/, '');
|
|
194
|
+
return !reportedNames.some((reported) => {
|
|
195
|
+
const other = reported.toLowerCase().replace(/[^a-z0-9]+/g, '').replace(/s$/, '');
|
|
196
|
+
return other.startsWith(stem) || stem.startsWith(other);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
148
199
|
const detail = pendingNames.length > 0
|
|
149
200
|
? `Timed out after ${GLOBAL_DIAGNOSIS_TIMEOUT_MS / 1000}s — did not report in time: ${pendingNames.join(', ')}`
|
|
150
201
|
: `Timed out after ${GLOBAL_DIAGNOSIS_TIMEOUT_MS / 1000}s — some checks incomplete`;
|
|
@@ -3891,9 +3942,14 @@ async function raceDiagnosis(refreshEnv) {
|
|
|
3891
3942
|
const timeoutPromise = new Promise((resolve) => {
|
|
3892
3943
|
timer = setTimeout(() => {
|
|
3893
3944
|
const completed = Array.isArray(progress.checks) ? progress.checks : [];
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3945
|
+
// #777: derive the pending set from the surface PATTERNS above, matched against
|
|
3946
|
+
// the names this run actually recorded. The previous form listed five labels and
|
|
3947
|
+
// none of them is a check name, so all five were reported missing every time --
|
|
3948
|
+
// next to the very lines showing them succeeding.
|
|
3949
|
+
const reported = completed.map((c) => c && c.name).filter(Boolean);
|
|
3950
|
+
const pending = REPORTED_SURFACE_PATTERNS
|
|
3951
|
+
.filter((re) => !reported.some((name) => re.test(name)))
|
|
3952
|
+
.map((re) => re.source.replace(/^\^|\$$/g, '').replace(/\\/g, ''));
|
|
3897
3953
|
resolve(mergeTimedOutDiagnosis(
|
|
3898
3954
|
{ checks: completed, issues: progress.getIssues() },
|
|
3899
3955
|
pending,
|
|
@@ -4133,6 +4189,46 @@ function formatDoctorJson(checks, issues) {
|
|
|
4133
4189
|
* agentsSource: string, agentDetails: string[]}} `channelResolution` is returned so
|
|
4134
4190
|
* the SKIP detail can name the channels and where they came from.
|
|
4135
4191
|
*/
|
|
4192
|
+
/**
|
|
4193
|
+
* The verdict for the native path when the channels preference switched it off (#711).
|
|
4194
|
+
*
|
|
4195
|
+
* A SKIP alone could not tell "switched off cleanly" from "switched off but the files
|
|
4196
|
+
* are still there". The difference matters: Qoder still loads leftover `delphi-*.md` as
|
|
4197
|
+
* custom agents, and the repair is one command. So leftovers WARN.
|
|
4198
|
+
*
|
|
4199
|
+
* @param {string} agentsDir directory that may hold `delphi-*.md`
|
|
4200
|
+
* @param {{channels: string[], source: string}} channelResolution how channels resolved
|
|
4201
|
+
* @returns {[string, string]} status and detail
|
|
4202
|
+
*/
|
|
4203
|
+
function disabledBindingVerdict(agentsDir, channelResolution) {
|
|
4204
|
+
const leftover = countNativeAgentFiles(agentsDir);
|
|
4205
|
+
const head = `native channel disabled (channels=${channelResolution.channels.join(',')} `
|
|
4206
|
+
+ `via ${channelResolution.source}) — `;
|
|
4207
|
+
if (leftover > 0) {
|
|
4208
|
+
return ['WARN', head + `${leftover} native agent file(s) still present in ${agentsDir}; they are `
|
|
4209
|
+
+ 'not used but Qoder still loads them — run `xp-gate delphi-setup --uninstall`'];
|
|
4210
|
+
}
|
|
4211
|
+
return ['SKIP', head + 'Delphi review runs through the external provider'];
|
|
4212
|
+
}
|
|
4213
|
+
|
|
4214
|
+
/**
|
|
4215
|
+
* How many native Delphi agent files exist in `agentsDir` (#711).
|
|
4216
|
+
*
|
|
4217
|
+
* Used only to tell "disabled cleanly" from "disabled with leftovers" -- a distinction
|
|
4218
|
+
* the SKIP line could not express, and one that matters because Qoder still loads the
|
|
4219
|
+
* files as custom agents.
|
|
4220
|
+
*
|
|
4221
|
+
* @param {string} agentsDir directory that may hold `delphi-*.md`
|
|
4222
|
+
* @returns {number} matching file count, 0 when unreadable
|
|
4223
|
+
*/
|
|
4224
|
+
function countNativeAgentFiles(agentsDir) {
|
|
4225
|
+
try {
|
|
4226
|
+
return fs.readdirSync(agentsDir).filter((f) => /^delphi-.*\.md$/.test(f)).length;
|
|
4227
|
+
} catch {
|
|
4228
|
+
return 0;
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
|
|
4136
4232
|
function resolveAgentTarget(options) {
|
|
4137
4233
|
const delphiChannel = require('./delphi-channel.js');
|
|
4138
4234
|
const channelHome = process.env.XDG_CONFIG_HOME
|
|
@@ -4215,9 +4311,7 @@ function checkDelphiAgentBindings(add, options) {
|
|
|
4215
4311
|
// by configuration there is nothing to keep healthy, and reporting its absence as
|
|
4216
4312
|
// FAIL told users their working setup was broken.
|
|
4217
4313
|
if (nativeDisabled) {
|
|
4218
|
-
add('Qoder Delphi agent bindings',
|
|
4219
|
-
`native channel disabled (channels=${channelResolution.channels.join(',')} via ${channelResolution.source}) — `
|
|
4220
|
-
+ 'Delphi review runs through the external provider');
|
|
4314
|
+
add('Qoder Delphi agent bindings', ...disabledBindingVerdict(agentsDir, channelResolution));
|
|
4221
4315
|
}
|
|
4222
4316
|
for (const role of nativeDisabled ? [] : DELPHI_ROLES) {
|
|
4223
4317
|
const outcome = inspectAgentBinding(role, agentsDir, readQoderModelId);
|
|
@@ -4466,6 +4560,34 @@ async function checkDelphiVersionConsistency(add, options, npmLatest) {
|
|
|
4466
4560
|
*
|
|
4467
4561
|
* @param {(name: string, status: string, detail?: string) => void} add
|
|
4468
4562
|
*/
|
|
4563
|
+
/**
|
|
4564
|
+
* The per-profile configuration layers under a DSH home, if any.
|
|
4565
|
+
*
|
|
4566
|
+
* DSH stores configuration as a loader patch layer per profile:
|
|
4567
|
+
* `profiles/<profile>/cordis.patch.yml`. An empty `[]` is a layer that adds nothing,
|
|
4568
|
+
* which is a valid configuration, so existence alone is what this reports -- parsing
|
|
4569
|
+
* the YAML to look for a seat override would tie this check to a schema it does not own.
|
|
4570
|
+
*
|
|
4571
|
+
* @param {string} dshHome the resolved `~/.dsh`
|
|
4572
|
+
* @returns {string[]} absolute paths to the layers found
|
|
4573
|
+
*/
|
|
4574
|
+
function listDshProfileConfigs(dshHome) {
|
|
4575
|
+
const profilesDir = path.join(dshHome, 'profiles');
|
|
4576
|
+
let entries;
|
|
4577
|
+
try {
|
|
4578
|
+
entries = fs.readdirSync(profilesDir, { withFileTypes: true });
|
|
4579
|
+
} catch {
|
|
4580
|
+
return [];
|
|
4581
|
+
}
|
|
4582
|
+
const found = [];
|
|
4583
|
+
for (const entry of entries) {
|
|
4584
|
+
if (!entry.isDirectory() || entry.name.endsWith('.bak') || entry.name.includes('.bak-')) continue;
|
|
4585
|
+
const layer = path.join(profilesDir, entry.name, 'cordis.patch.yml');
|
|
4586
|
+
if (fs.existsSync(layer)) found.push(layer);
|
|
4587
|
+
}
|
|
4588
|
+
return found;
|
|
4589
|
+
}
|
|
4590
|
+
|
|
4469
4591
|
function checkDshChannelReadiness(add) {
|
|
4470
4592
|
// 7. DSH native-channel readiness (#443 REQ-6): only meaningful when a DSH home
|
|
4471
4593
|
// exists. The two-layer switch (preset capability + host setting) defaults to
|
|
@@ -4485,6 +4607,22 @@ function checkDshChannelReadiness(add) {
|
|
|
4485
4607
|
];
|
|
4486
4608
|
const settingsFile = settingsCandidates.find((p) => fs.existsSync(p));
|
|
4487
4609
|
if (!settingsFile) {
|
|
4610
|
+
// #812: the three names above are not where DSH keeps its configuration. Measured
|
|
4611
|
+
// on this machine: `~/.dsh/profiles/<profile>/cordis.patch.yml` -- `headless` holds
|
|
4612
|
+
// an empty `[]`, `web` holds 628 lines. The directory existed, the configuration
|
|
4613
|
+
// existed, and this check called it absent while asserting a CONSEQUENCE
|
|
4614
|
+
// ("defaults to disabled") about a setting it had never looked at.
|
|
4615
|
+
const profileFiles = listDshProfileConfigs(dshHome);
|
|
4616
|
+
if (profileFiles.length > 0) {
|
|
4617
|
+
// A profile layer that does not mention subagents is the PLATFORM DEFAULT, not a
|
|
4618
|
+
// misconfiguration. Saying FAIL here told a working setup it was broken, which is
|
|
4619
|
+
// the same bug family as #646 one level down: "not mentioned" is not "disabled".
|
|
4620
|
+
add(label, 'SKIP',
|
|
4621
|
+
`${profileFiles.length} DSH profile layer(s) present and no seat override in them `
|
|
4622
|
+
+ `(e.g. ${path.relative(dshHome, profileFiles[0])}) — subagent model selection `
|
|
4623
|
+
+ 'is at its platform default, which is not a defect (#812)');
|
|
4624
|
+
return;
|
|
4625
|
+
}
|
|
4488
4626
|
add(label, 'FAIL',
|
|
4489
4627
|
`${dshHome} exists but no settings file found — subagent model selection defaults to disabled (#443)`);
|
|
4490
4628
|
return;
|
|
@@ -4836,6 +4974,7 @@ function collectSkillDrift(skillDir, bundledFiles, bundledSkillDir, sha256) {
|
|
|
4836
4974
|
}
|
|
4837
4975
|
|
|
4838
4976
|
module.exports = {
|
|
4977
|
+
checkDshChannelReadiness,
|
|
4839
4978
|
reportUnreadablePath, reportStalePath, reportSyncResult,
|
|
4840
4979
|
runHookAndModuleSync, staleSyncEntries,
|
|
4841
4980
|
planStaleHookSync, reportBlockedHookSync, refreshSafeHooks,
|
package/lib/gate-runner.js
CHANGED
|
@@ -437,7 +437,9 @@ const TSX_SEARCH_DEPTH = 4;
|
|
|
437
437
|
* @param {string} [cwd] directory to start from; defaults to process.cwd()
|
|
438
438
|
* @returns {string|null}
|
|
439
439
|
*/
|
|
440
|
-
function findTsxCli(cwd = process.cwd()) {
|
|
440
|
+
function findTsxCli(cwd = process.cwd(), ignoreOwnInstall = false) {
|
|
441
|
+
// The PROJECT's copy wins: a consumer may pin a different tsx, and silently using ours
|
|
442
|
+
// would be a different bug in the opposite direction.
|
|
441
443
|
let dir = path.resolve(cwd);
|
|
442
444
|
for (let depth = 0; depth < TSX_SEARCH_DEPTH; depth += 1) {
|
|
443
445
|
const candidate = path.join(dir, 'node_modules', 'tsx', 'dist', 'cli.mjs');
|
|
@@ -446,7 +448,16 @@ function findTsxCli(cwd = process.cwd()) {
|
|
|
446
448
|
if (parent === dir) break;
|
|
447
449
|
dir = parent;
|
|
448
450
|
}
|
|
449
|
-
|
|
451
|
+
// #782: then OUR copy. This package depends on tsx, so one is always beside this
|
|
452
|
+
// file -- and running it needs no npm cache at all.
|
|
453
|
+
//
|
|
454
|
+
// Without this the search fell through to `npx`, which writes a temp file under
|
|
455
|
+
// $npm_config_cache on every run, even when tsx is fully unpacked under `_npx/`. In a
|
|
456
|
+
// workspace-write sandbox where the cache lives outside the workspace that is EPERM,
|
|
457
|
+
// and the EPERM was reported as GATE FAILED -- a verdict on code that was fine.
|
|
458
|
+
if (ignoreOwnInstall) return null;
|
|
459
|
+
const own = path.join(__dirname, '..', '..', '..', 'node_modules', 'tsx', 'dist', 'cli.mjs');
|
|
460
|
+
return fs.existsSync(own) ? own : null;
|
|
450
461
|
}
|
|
451
462
|
|
|
452
463
|
/**
|
|
@@ -466,7 +477,7 @@ function findTsxCli(cwd = process.cwd()) {
|
|
|
466
477
|
* @returns {{command: string, args: string[], viaNpx: boolean}}
|
|
467
478
|
*/
|
|
468
479
|
function resolveTsxInvocation(args, opts = {}) {
|
|
469
|
-
const tsxCli = findTsxCli(opts.cwd);
|
|
480
|
+
const tsxCli = findTsxCli(opts.cwd, opts.ignoreOwnInstall === true);
|
|
470
481
|
if (tsxCli) return { command: process.execPath, args: [tsxCli, ...args], viaNpx: false };
|
|
471
482
|
const [command, argv] = resolveNpxInvocation(['-y', 'tsx', ...args]);
|
|
472
483
|
return { command, args: argv, viaNpx: true };
|