@boyingliu01/xp-gate 0.41.10 → 0.41.56
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 +283 -31
- 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,
|