@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/install-skill.js
CHANGED
|
@@ -147,6 +147,9 @@ async function installSkill(name, options = {}) {
|
|
|
147
147
|
const installId = `${name}-${Date.now()}-${platformTag}`;
|
|
148
148
|
const backupDir = path.join(CONFIG_DIR, 'backup', installId);
|
|
149
149
|
backupExisting(targetDir, installId, backupDir);
|
|
150
|
+
// #756: called AFTER the new backup exists, so the newest copy is never a candidate for
|
|
151
|
+
// removal. See pruneSkillBackups for why the newest copies are the ones to keep.
|
|
152
|
+
pruneSkillBackups();
|
|
150
153
|
|
|
151
154
|
try {
|
|
152
155
|
if (verbose && finalTargets.length > 1) console.log(`Target: ${targetDir}`);
|
|
@@ -229,4 +232,66 @@ function updateConfig(updates) {
|
|
|
229
232
|
fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
|
|
230
233
|
}
|
|
231
234
|
|
|
232
|
-
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* How many skill backups to keep.
|
|
238
|
+
*
|
|
239
|
+
* One per platform per install, so 8 covers two full installs of all four platforms -- still
|
|
240
|
+
* enough to roll back the change you just made, which is the only thing a backup is for.
|
|
241
|
+
*/
|
|
242
|
+
const BACKUP_KEEP = 8;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Remove the OLDEST skill backups, keeping the newest `keep` (#756).
|
|
246
|
+
*
|
|
247
|
+
* `~/.config/xp-gate/backup/` only grew: every `install-skill` left one full copy per
|
|
248
|
+
* platform, `update-skill` reuses that path, and nothing ever pruned. Measured on the
|
|
249
|
+
* author's machine while writing this: 174 directories, 11 MB, growing linearly with
|
|
250
|
+
* installs.
|
|
251
|
+
*
|
|
252
|
+
* The newest copies are the ones that matter: a rollback restores the state before the MOST
|
|
253
|
+
* RECENT install, so older copies have no use -- and a rollback the user cannot perform is
|
|
254
|
+
* worse than the disk they would reclaim.
|
|
255
|
+
*
|
|
256
|
+
* @param {number} [keep] how many directories to leave; defaults to BACKUP_KEEP
|
|
257
|
+
* @param {string} [configDir] config root; defaults to CONFIG_DIR
|
|
258
|
+
* @returns {number} how many were removed
|
|
259
|
+
*/
|
|
260
|
+
function pruneSkillBackups(keep = BACKUP_KEEP, configDir = CONFIG_DIR) {
|
|
261
|
+
const backupRoot = path.join(configDir, 'backup');
|
|
262
|
+
let entries;
|
|
263
|
+
try {
|
|
264
|
+
entries = fs.readdirSync(backupRoot, { withFileTypes: true })
|
|
265
|
+
.filter((e) => e.isDirectory())
|
|
266
|
+
.map((e) => e.name);
|
|
267
|
+
} catch {
|
|
268
|
+
// No backup directory yet: every fresh install lands here, and it is not an error.
|
|
269
|
+
return 0;
|
|
270
|
+
}
|
|
271
|
+
if (entries.length <= keep) return 0;
|
|
272
|
+
|
|
273
|
+
// The install id is `<skill>-<Date.now()>-<platform>`, so ordering by the embedded
|
|
274
|
+
// timestamp is more faithful than mtime -- a restore or a copy can rewrite mtime.
|
|
275
|
+
const stamp = (name) => {
|
|
276
|
+
// `\d+` rather than `\d{10,}`: the real ids carry a Date.now() value, but a shorter
|
|
277
|
+
// one must still order correctly rather than collapsing to 0 and being sorted as
|
|
278
|
+
// "oldest" -- which would delete the newest copies in exactly the case this protects.
|
|
279
|
+
const m = /-(\d+)-/.exec(name);
|
|
280
|
+
return m ? Number(m[1]) : 0;
|
|
281
|
+
};
|
|
282
|
+
entries.sort((a, b) => stamp(a) - stamp(b));
|
|
283
|
+
|
|
284
|
+
let removed = 0;
|
|
285
|
+
for (const name of entries.slice(0, entries.length - keep)) {
|
|
286
|
+
try {
|
|
287
|
+
fs.rmSync(path.join(backupRoot, name), { recursive: true, force: true });
|
|
288
|
+
removed += 1;
|
|
289
|
+
} catch {
|
|
290
|
+
// A backup that cannot be removed is not worth failing an install over; the next run
|
|
291
|
+
// tries again.
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return removed;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
module.exports = { installSkill, pruneSkillBackups };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Layer-baseline comparison for Gate 6's layer check.
|
|
4
|
+
*
|
|
5
|
+
* Reads findings on stdin (one per line, fields separated by real TABs) and a
|
|
6
|
+
* JSON ledger as argv[2], and writes the findings that are NOT in the ledger.
|
|
7
|
+
*
|
|
8
|
+
* Exit 4 when the ledger exists but cannot be parsed. The caller treats that as
|
|
9
|
+
* BLOCK (fail-closed): a ledger that silently reads as empty would turn every
|
|
10
|
+
* accepted violation back into a new one, and the next natural response — re-run
|
|
11
|
+
* with a bigger baseline — quietly launders the debt.
|
|
12
|
+
*
|
|
13
|
+
* Why this is a file and not an inline `node -e`: the first version embedded
|
|
14
|
+
* this in bash single quotes, and the TAB separators ended up inside a JSON
|
|
15
|
+
* string literal, which JSON.parse rejects (raw control character). The error
|
|
16
|
+
* was then swallowed by `2>/dev/null`, so the ratchet silently reset on every
|
|
17
|
+
* run. Three levels of quoting is where that hid; one level is enough.
|
|
18
|
+
*
|
|
19
|
+
* Ledger shape:
|
|
20
|
+
* { "accepted": [ { "file", "from", "to", "imports" }, ... ] }
|
|
21
|
+
*
|
|
22
|
+
* A plain tab-joined string is also accepted for entries, so hand-written and
|
|
23
|
+
* generated ledgers both work.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
'use strict';
|
|
27
|
+
|
|
28
|
+
const fs = require('fs');
|
|
29
|
+
|
|
30
|
+
const SEVERITY_EXIT_UNREADABLE = 4;
|
|
31
|
+
|
|
32
|
+
/** Normalise one ledger entry to the tab-joined form used on stdin. */
|
|
33
|
+
function toKey(entry) {
|
|
34
|
+
if (typeof entry === 'string') {
|
|
35
|
+
return entry;
|
|
36
|
+
}
|
|
37
|
+
if (entry && typeof entry === 'object') {
|
|
38
|
+
return [entry.file, entry.from, entry.to, entry.imports].join('\t');
|
|
39
|
+
}
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Read and validate the ledger. Throws when it cannot be used. */
|
|
44
|
+
function readLedger(path) {
|
|
45
|
+
const raw = fs.readFileSync(path, 'utf8');
|
|
46
|
+
const parsed = JSON.parse(raw);
|
|
47
|
+
const accepted = Array.isArray(parsed.accepted) ? parsed.accepted : [];
|
|
48
|
+
return new Set(accepted.map(toKey).filter(Boolean));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Split stdin into findings and drop the baselined ones. */
|
|
52
|
+
function filterFindings(raw, known) {
|
|
53
|
+
return raw
|
|
54
|
+
.split('\n')
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
// A finding may carry a 5th diagnostic field (`forbidden`, added when
|
|
57
|
+
// forbiddenImports became enforced). A ledger records WHERE the edge is, not
|
|
58
|
+
// WHY it was reported, so the key is the first four fields only. Comparing
|
|
59
|
+
// whole lines made every ledgered entry stop matching the moment the 5th
|
|
60
|
+
// column appeared, silently turning accepted debt back into blocking
|
|
61
|
+
// violations -- caught as two red tests, not by reading the code.
|
|
62
|
+
.filter((line) => !known.has(line.split('\t').slice(0, 4).join('\t')));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function main() {
|
|
66
|
+
const ledgerPath = process.argv[2];
|
|
67
|
+
if (!ledgerPath) {
|
|
68
|
+
process.stderr.write('usage: layer-baseline.cjs <ledger.json> < findings\n');
|
|
69
|
+
process.exit(SEVERITY_EXIT_UNREADABLE);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let known;
|
|
74
|
+
try {
|
|
75
|
+
known = readLedger(ledgerPath);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
process.stderr.write(`layer-baseline unreadable: ${err.message}\n`);
|
|
78
|
+
process.exit(SEVERITY_EXIT_UNREADABLE);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let raw = '';
|
|
83
|
+
process.stdin.setEncoding('utf8');
|
|
84
|
+
process.stdin.on('data', chunk => {
|
|
85
|
+
raw += chunk;
|
|
86
|
+
});
|
|
87
|
+
process.stdin.on('end', () => {
|
|
88
|
+
process.stdout.write(filterFindings(raw, known).join('\n'));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
main();
|
|
93
|
+
|
|
94
|
+
module.exports = { toKey, readLedger, filterFindings };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which installed skill directories an uninstall may remove (#741, #663).
|
|
3
|
+
*
|
|
4
|
+
* Split out of uninstall.js, which was at its 1050-line bound: this is a self-contained
|
|
5
|
+
* decision -- read the bundled tree, compare each installed copy, return what is safe --
|
|
6
|
+
* and it needs nothing from the rest of the uninstaller.
|
|
7
|
+
*
|
|
8
|
+
* Both halves of this used to exist WITHOUT RUNNING. `globalSkillRoots()` had no call
|
|
9
|
+
* site and threw on first use (`HOME_DIR` is a lazy getter, not a function), and
|
|
10
|
+
* `planSkillRemovals()` was exported only so tests could reach it. An uninstall
|
|
11
|
+
* therefore printed "Uninstall complete" while all 36 directories -- 12 skills across
|
|
12
|
+
* Qoder, Claude Code and OpenCode -- stayed on disk and kept being loaded.
|
|
13
|
+
*/
|
|
14
|
+
'use strict';
|
|
15
|
+
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
|
|
19
|
+
const { HOME_DIR } = require('./shared-paths.js');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Skill directory roots the CLI installs into, per platform (mirror of the
|
|
23
|
+
* installers in install-skill.js). Read at call time so a test can point HOME at a
|
|
24
|
+
* throwaway tree.
|
|
25
|
+
*/
|
|
26
|
+
function globalSkillRoots() {
|
|
27
|
+
// #741: HOME_DIR is a LAZY GETTER, not a function. Calling it threw TypeError on
|
|
28
|
+
// first use, which is why this helper had no call site and the skills always stayed.
|
|
29
|
+
return [
|
|
30
|
+
path.join(HOME_DIR, '.qoder', 'skills'),
|
|
31
|
+
path.join(HOME_DIR, '.config', 'opencode', 'skills'),
|
|
32
|
+
path.join(HOME_DIR, '.claude', 'skills'),
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The skill names this package ships -- read from the bundled tree, because
|
|
37
|
+
* `installedSkills` is empty on a fully deployed machine (#682).
|
|
38
|
+
*/
|
|
39
|
+
function bundledSkillNames(bundledRoot) {
|
|
40
|
+
try {
|
|
41
|
+
return fs.readdirSync(bundledRoot, { withFileTypes: true })
|
|
42
|
+
.filter((e) => e.isDirectory()).map((e) => e.name);
|
|
43
|
+
} catch {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Decide which installed skill directories an uninstall may remove (#663).
|
|
49
|
+
*
|
|
50
|
+
* `uninstall` never touched skills at all, so 12 of them stayed in
|
|
51
|
+
* ~/.qoder/skills/ and ~/.config/opencode/skills/ after `uninstall --global`, and
|
|
52
|
+
* the next `init` treated them as already installed.
|
|
53
|
+
*
|
|
54
|
+
* Safety rule from the issue: only remove a directory whose content still matches
|
|
55
|
+
* the bundled copy. A user's edits are not residue, and deleting them is a far
|
|
56
|
+
* worse outcome than leaving a stale skill behind -- the user can always delete a
|
|
57
|
+
* leftover, but cannot recover an edit we removed.
|
|
58
|
+
*
|
|
59
|
+
* Returns [{ path, label }] for the directories that are safe to delete.
|
|
60
|
+
*/
|
|
61
|
+
function planSkillRemovals(skillNames, installedRoot, bundledRoot) {
|
|
62
|
+
const removals = [];
|
|
63
|
+
if (!Array.isArray(skillNames)) return removals;
|
|
64
|
+
|
|
65
|
+
for (const name of skillNames) {
|
|
66
|
+
if (typeof name !== 'string' || !name) continue;
|
|
67
|
+
const installedDir = path.join(installedRoot, name);
|
|
68
|
+
const bundledDir = path.join(bundledRoot, name);
|
|
69
|
+
if (!fs.existsSync(installedDir)) continue;
|
|
70
|
+
// No bundled copy to compare against -> cannot prove it is untouched, so keep it.
|
|
71
|
+
if (!fs.existsSync(bundledDir)) continue;
|
|
72
|
+
if (directoryContentMatches(installedDir, bundledDir)) {
|
|
73
|
+
removals.push({ path: installedDir, label: `${installedRoot}/${name}/` });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return removals;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Add the installed skill directories this package may remove (#741).
|
|
80
|
+
*
|
|
81
|
+
* Both halves existed and neither ran, so an uninstall printed "Uninstall complete"
|
|
82
|
+
* while 36 directories stayed loaded. Planned per SKILL, not per platform root: the
|
|
83
|
+
* safety rule keeps a modified copy, and collapsing them would delete the neighbours.
|
|
84
|
+
*/
|
|
85
|
+
function planGlobalSkillRemovalsInto(plan) {
|
|
86
|
+
const bundledSkills = path.join(__dirname, '..', 'skills');
|
|
87
|
+
const names = bundledSkillNames(bundledSkills);
|
|
88
|
+
for (const root of globalSkillRoots()) {
|
|
89
|
+
for (const removal of planSkillRemovals(names, root, bundledSkills)) {
|
|
90
|
+
plan.push({ type: 'dir', path: removal.path, label: removal.label });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* True when two directory trees hold the same files with the same bytes.
|
|
97
|
+
* Skips `.git` and node_modules, which are never part of a skill bundle.
|
|
98
|
+
*/
|
|
99
|
+
function directoryContentMatches(a, b) {
|
|
100
|
+
const filesA = listFilesRelative(a);
|
|
101
|
+
const filesB = listFilesRelative(b);
|
|
102
|
+
if (filesA.length !== filesB.length) return false;
|
|
103
|
+
for (let i = 0; i < filesA.length; i++) {
|
|
104
|
+
if (filesA[i] !== filesB[i]) return false;
|
|
105
|
+
try {
|
|
106
|
+
if (!fs.readFileSync(path.join(a, filesA[i])).equals(fs.readFileSync(path.join(b, filesB[i])))) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
} catch {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Sorted relative file paths under a directory. */
|
|
117
|
+
function listFilesRelative(root) {
|
|
118
|
+
const out = [];
|
|
119
|
+
const walk = (dir, prefix) => {
|
|
120
|
+
let entries;
|
|
121
|
+
try {
|
|
122
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
123
|
+
} catch {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
for (const entry of entries) {
|
|
127
|
+
if (entry.name === '.git' || entry.name === 'node_modules') continue;
|
|
128
|
+
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
129
|
+
if (entry.isDirectory()) {
|
|
130
|
+
walk(path.join(dir, entry.name), rel);
|
|
131
|
+
} else {
|
|
132
|
+
out.push(rel);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
walk(root, '');
|
|
137
|
+
return out.sort();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
module.exports = { globalSkillRoots, planSkillRemovals, planGlobalSkillRemovalsInto, bundledSkillNames };
|
package/lib/uninstall.js
CHANGED
|
@@ -14,18 +14,6 @@ const { HOOK_FILES } = require('./deploy-manifest.js');
|
|
|
14
14
|
|
|
15
15
|
const BACKUP_DIR = path.join(CONFIG_DIR, '.uninstall-backup');
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Skill directory roots the CLI installs into, per platform (mirror of the
|
|
19
|
-
* installers in install-skill.js). Read at call time so a test can point HOME at a
|
|
20
|
-
* throwaway tree.
|
|
21
|
-
*/
|
|
22
|
-
function globalSkillRoots() {
|
|
23
|
-
return [
|
|
24
|
-
path.join(HOME_DIR(), '.qoder', 'skills'),
|
|
25
|
-
path.join(HOME_DIR(), '.config', 'opencode', 'skills'),
|
|
26
|
-
path.join(HOME_DIR(), '.claude', 'skills'),
|
|
27
|
-
];
|
|
28
|
-
}
|
|
29
17
|
|
|
30
18
|
/**
|
|
31
19
|
* Directories and files inside ~/.config/xp-gate/ that `setup-global` creates
|
|
@@ -457,6 +445,8 @@ function buildGlobalPlanInto(plan, manifest) {
|
|
|
457
445
|
});
|
|
458
446
|
}
|
|
459
447
|
}
|
|
448
|
+
|
|
449
|
+
require('./uninstall-skills.js').planGlobalSkillRemovalsInto(plan);
|
|
460
450
|
}
|
|
461
451
|
|
|
462
452
|
function buildPlan(mode) {
|
|
@@ -486,7 +476,7 @@ function buildPlan(mode) {
|
|
|
486
476
|
* Remove a single file item with ownership verification.
|
|
487
477
|
* @returns {boolean} true on success, false on skip (not xp-gate owned)
|
|
488
478
|
*/
|
|
489
|
-
function removeFile(item, config) {
|
|
479
|
+
function removeFile(item, config, state) {
|
|
490
480
|
// #714: `ownedByPath` entries are files the installer writes at a fixed path
|
|
491
481
|
// inside our own ~/.config/xp-gate/ directory, so ownership is established by
|
|
492
482
|
// the path itself. Without this branch the residue files fell through to
|
|
@@ -502,6 +492,7 @@ function removeFile(item, config) {
|
|
|
502
492
|
// Report a failure AS a failure: printing "Removed" for a file still on disk
|
|
503
493
|
// is the residue problem this command exists to end.
|
|
504
494
|
console.error(` ✗ Could not remove ${item.label}: ${err.message}`);
|
|
495
|
+
if (state) state.any = true;
|
|
505
496
|
return false;
|
|
506
497
|
}
|
|
507
498
|
console.log(` Removed ${item.label}`);
|
|
@@ -515,6 +506,7 @@ function removeFile(item, config) {
|
|
|
515
506
|
if (!verifyFileOwnership(item.path, manifestEntry, item.signature)) {
|
|
516
507
|
if (fs.existsSync(item.path)) {
|
|
517
508
|
console.warn(` Warning: ${item.label} does not contain xp-gate signature — skipping`);
|
|
509
|
+
if (state) state.kept += 1;
|
|
518
510
|
}
|
|
519
511
|
return false;
|
|
520
512
|
}
|
|
@@ -528,7 +520,7 @@ function removeFile(item, config) {
|
|
|
528
520
|
* Remove a directory item.
|
|
529
521
|
* @returns {boolean} true if dir existed and was removed, false otherwise
|
|
530
522
|
*/
|
|
531
|
-
function removeDir(item) {
|
|
523
|
+
function removeDir(item, config, state) {
|
|
532
524
|
if (!fs.existsSync(item.path)) return false;
|
|
533
525
|
|
|
534
526
|
// #664: the global `core.hooksPath` is a SHARED directory -- `git lfs install`
|
|
@@ -540,7 +532,11 @@ function removeDir(item) {
|
|
|
540
532
|
// adapters dir are wholly xp-gate-owned (the template legitimately contains an
|
|
541
533
|
// `adapters/` subdir, which would otherwise be read as foreign), so only a path
|
|
542
534
|
// that looks like a hooks root gets the conservative treatment.
|
|
543
|
-
|
|
535
|
+
// #770: the label check was `label.includes('hooks/')`, which matches
|
|
536
|
+
// `githooks/adapters/` -- so the adapters directory was classified as a hooks dir and
|
|
537
|
+
// its own `.sh` files were then read as foreign. The PATH is the only reliable signal;
|
|
538
|
+
// a label is prose written for humans.
|
|
539
|
+
const isHooksDir = /(^|[\/])hooks[\/]?$/.test(item.path);
|
|
544
540
|
const removal = isHooksDir ? planHooksDirRemoval(item.path) : { action: 'remove-all' };
|
|
545
541
|
if (removal.action === 'remove-owned-only') {
|
|
546
542
|
for (const name of removal.owned) {
|
|
@@ -551,6 +547,7 @@ function removeDir(item) {
|
|
|
551
547
|
console.log(` Removed xp-gate hooks from ${item.label}`);
|
|
552
548
|
console.log(` ⚠️ Kept ${removal.foreign.length} file(s) that are not xp-gate's: ${sources.join(', ')}`);
|
|
553
549
|
console.log(' The global core.hooksPath is a shared directory; other tools (e.g. git lfs) install here.');
|
|
550
|
+
if (state && removal.foreign.length > 0) state.kept += 1;
|
|
554
551
|
return true;
|
|
555
552
|
}
|
|
556
553
|
|
|
@@ -602,9 +599,9 @@ function sameHooksPath(a, b) {
|
|
|
602
599
|
* Execute a single plan item (file/dir/gitconfig).
|
|
603
600
|
* @returns {boolean} true on success, false on skip/failure
|
|
604
601
|
*/
|
|
605
|
-
function executePlanItem(item, config) {
|
|
606
|
-
if (item.type === 'file') return removeFile(item, config);
|
|
607
|
-
if (item.type === 'dir') return removeDir(item);
|
|
602
|
+
function executePlanItem(item, config, state) {
|
|
603
|
+
if (item.type === 'file') return removeFile(item, config, state);
|
|
604
|
+
if (item.type === 'dir') return removeDir(item, config, state);
|
|
608
605
|
if (item.type === 'gitconfig' && item.action === 'unset-hooks-path') return unsetGitConfigIfMatch(item);
|
|
609
606
|
return false;
|
|
610
607
|
}
|
|
@@ -711,14 +708,18 @@ function executeUninstallPlan(plan, config, purgeDirs, options) {
|
|
|
711
708
|
// §4.12 Execute operations in order (non-destructive first, then destructive)
|
|
712
709
|
let hadErrors = false;
|
|
713
710
|
|
|
711
|
+
// #771: `false` means SKIP as often as FAILURE -- absent file, or kept on purpose
|
|
712
|
+
// (#770). Only removeFile knows which happened, so it sets the flag there.
|
|
713
|
+
const state = { any: false, kept: 0 };
|
|
714
714
|
for (const item of plan) {
|
|
715
715
|
try {
|
|
716
|
-
|
|
716
|
+
executePlanItem(item, config, state);
|
|
717
717
|
} catch (e) {
|
|
718
718
|
console.warn(` Warning: Could not remove ${item.label}: ${e.message}`);
|
|
719
|
-
|
|
719
|
+
state.any = true;
|
|
720
720
|
}
|
|
721
721
|
}
|
|
722
|
+
hadErrors = state.any;
|
|
722
723
|
|
|
723
724
|
const purgeErrors = options.purge ? runPurge(purgeDirs, options) : false;
|
|
724
725
|
|
|
@@ -737,7 +738,9 @@ function executeUninstallPlan(plan, config, purgeDirs, options) {
|
|
|
737
738
|
}
|
|
738
739
|
|
|
739
740
|
// §4.12 Step 11: Clean up backup on success
|
|
740
|
-
|
|
741
|
+
// #771: a kept file still needs a rollback, so it holds the snapshot open even
|
|
742
|
+
// though keeping it is correct behaviour (#770) and not an error (#724).
|
|
743
|
+
if (!hadErrors && state.kept === 0) {
|
|
741
744
|
cleanupBackup(backupMeta);
|
|
742
745
|
}
|
|
743
746
|
return { hadErrors: hadErrors || purgeErrors, backupMeta };
|
|
@@ -860,9 +863,7 @@ async function uninstall(args) {
|
|
|
860
863
|
const retained = printUninstallPlan(mode, plan, purgeDirs, options);
|
|
861
864
|
if (options.dryRun) return reportDryRun();
|
|
862
865
|
|
|
863
|
-
// §4.3 Step 6: Confirm
|
|
864
|
-
// Skipped in test environment since we use --force or non-interactive
|
|
865
|
-
// In real usage with TTY, would prompt here
|
|
866
|
+
// §4.3 Step 6: Confirm -- skipped with --force / non-interactive; a TTY would prompt.
|
|
866
867
|
|
|
867
868
|
const { hadErrors, backupMeta } = executeUninstallPlan(plan, config, purgeDirs, options);
|
|
868
869
|
|
|
@@ -882,87 +883,18 @@ async function uninstall(args) {
|
|
|
882
883
|
}
|
|
883
884
|
if (hadErrors) {
|
|
884
885
|
console.log('Some items could not be removed. Run doctor for diagnostics.');
|
|
886
|
+
return 1; // #771: do not claim success while leaving failures unnamed and unreported
|
|
885
887
|
}
|
|
886
888
|
|
|
887
889
|
return 0;
|
|
888
890
|
}
|
|
889
891
|
|
|
890
|
-
/**
|
|
891
|
-
* Decide which installed skill directories an uninstall may remove (#663).
|
|
892
|
-
*
|
|
893
|
-
* `uninstall` never touched skills at all, so 12 of them stayed in
|
|
894
|
-
* ~/.qoder/skills/ and ~/.config/opencode/skills/ after `uninstall --global`, and
|
|
895
|
-
* the next `init` treated them as already installed.
|
|
896
|
-
*
|
|
897
|
-
* Safety rule from the issue: only remove a directory whose content still matches
|
|
898
|
-
* the bundled copy. A user's edits are not residue, and deleting them is a far
|
|
899
|
-
* worse outcome than leaving a stale skill behind -- the user can always delete a
|
|
900
|
-
* leftover, but cannot recover an edit we removed.
|
|
901
|
-
*
|
|
902
|
-
* Returns [{ path, label }] for the directories that are safe to delete.
|
|
903
|
-
*/
|
|
904
|
-
function planSkillRemovals(skillNames, installedRoot, bundledRoot) {
|
|
905
|
-
const removals = [];
|
|
906
|
-
if (!Array.isArray(skillNames)) return removals;
|
|
907
|
-
|
|
908
|
-
for (const name of skillNames) {
|
|
909
|
-
if (typeof name !== 'string' || !name) continue;
|
|
910
|
-
const installedDir = path.join(installedRoot, name);
|
|
911
|
-
const bundledDir = path.join(bundledRoot, name);
|
|
912
|
-
if (!fs.existsSync(installedDir)) continue;
|
|
913
|
-
// No bundled copy to compare against -> cannot prove it is untouched, so keep it.
|
|
914
|
-
if (!fs.existsSync(bundledDir)) continue;
|
|
915
|
-
if (directoryContentMatches(installedDir, bundledDir)) {
|
|
916
|
-
removals.push({ path: installedDir, label: `${installedRoot}/${name}/` });
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
return removals;
|
|
920
|
-
}
|
|
921
892
|
|
|
922
|
-
/**
|
|
923
|
-
* True when two directory trees hold the same files with the same bytes.
|
|
924
|
-
* Skips `.git` and node_modules, which are never part of a skill bundle.
|
|
925
|
-
*/
|
|
926
|
-
function directoryContentMatches(a, b) {
|
|
927
|
-
const filesA = listFilesRelative(a);
|
|
928
|
-
const filesB = listFilesRelative(b);
|
|
929
|
-
if (filesA.length !== filesB.length) return false;
|
|
930
|
-
for (let i = 0; i < filesA.length; i++) {
|
|
931
|
-
if (filesA[i] !== filesB[i]) return false;
|
|
932
|
-
try {
|
|
933
|
-
if (!fs.readFileSync(path.join(a, filesA[i])).equals(fs.readFileSync(path.join(b, filesB[i])))) {
|
|
934
|
-
return false;
|
|
935
|
-
}
|
|
936
|
-
} catch {
|
|
937
|
-
return false;
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
return true;
|
|
941
|
-
}
|
|
942
893
|
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
let entries;
|
|
948
|
-
try {
|
|
949
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
950
|
-
} catch {
|
|
951
|
-
return;
|
|
952
|
-
}
|
|
953
|
-
for (const entry of entries) {
|
|
954
|
-
if (entry.name === '.git' || entry.name === 'node_modules') continue;
|
|
955
|
-
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
956
|
-
if (entry.isDirectory()) {
|
|
957
|
-
walk(path.join(dir, entry.name), rel);
|
|
958
|
-
} else {
|
|
959
|
-
out.push(rel);
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
};
|
|
963
|
-
walk(root, '');
|
|
964
|
-
return out.sort();
|
|
965
|
-
}
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
966
898
|
|
|
967
899
|
/**
|
|
968
900
|
* Decide how a hooks directory may be removed (#664).
|
|
@@ -994,7 +926,14 @@ function planHooksDirRemoval(hooksDir) {
|
|
|
994
926
|
for (const entry of entries) {
|
|
995
927
|
const name = entry.name;
|
|
996
928
|
// xp-gate's own hook entry points and support files.
|
|
997
|
-
|
|
929
|
+
// #770: ownership is IDENTITY, not file extension. The rule used to accept any `.sh`
|
|
930
|
+
// as xp-gate's, so a user's own `my-custom.sh` in this SHARED directory was deleted --
|
|
931
|
+
// and the prior deletion preview did not list it, so the loss was silent as well.
|
|
932
|
+
//
|
|
933
|
+
// `.sh` says what a file IS, not who wrote it. `OWNED_HOOK_NAMES` is already the exact
|
|
934
|
+
// enumeration of this package's entry points, and `lib` is a directory it owns
|
|
935
|
+
// wholesale -- those two are the whole rule.
|
|
936
|
+
if (OWNED_HOOK_NAMES.includes(name) || name === 'lib') {
|
|
998
937
|
owned.push(name);
|
|
999
938
|
} else {
|
|
1000
939
|
foreign.push({ name, source: foreignHookSource(path.join(hooksDir, name)) });
|
|
@@ -1029,4 +968,6 @@ function foreignHookSource(filePath) {
|
|
|
1029
968
|
}
|
|
1030
969
|
}
|
|
1031
970
|
|
|
1032
|
-
|
|
971
|
+
// #741: planSkillRemovals now lives in uninstall-skills.js; re-exported so existing
|
|
972
|
+
// callers (and the tests written for it) keep working.
|
|
973
|
+
module.exports = { uninstall, isXpGateFile, SIGNATURES, buildPlan, planHookDirRemoval: planHooksDirRemoval, planHooksDirRemoval, planSkillRemovals: require('./uninstall-skills.js').planSkillRemovals };
|
package/lib/update-skill.js
CHANGED
|
@@ -292,7 +292,15 @@ async function handleAllMode(verbose) {
|
|
|
292
292
|
let hasErrors = false;
|
|
293
293
|
for (const skillName of names) {
|
|
294
294
|
try {
|
|
295
|
-
|
|
295
|
+
// #773: `installSkill()` expresses a refusal by RETURNING 1 (a missing
|
|
296
|
+
// superpowers/gstack dependency), not by throwing. Discarding the value meant
|
|
297
|
+
// twelve refusals summed to exit 0 while the single-skill form exited 1 for the
|
|
298
|
+
// same refusal -- the pair disagreed, and that disagreement was the bug.
|
|
299
|
+
//
|
|
300
|
+
// A thrown error still counts as well: both shapes mean "this skill did not
|
|
301
|
+
// update", and the exit code is about the outcome, not the mechanism.
|
|
302
|
+
const result = await updateSingleSkill(skillName, verbose);
|
|
303
|
+
if (typeof result === 'number' && result !== 0) hasErrors = true;
|
|
296
304
|
} catch (err) {
|
|
297
305
|
console.error(`Failed to update ${skillName}: ${err.message}`);
|
|
298
306
|
hasErrors = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boyingliu01/xp-gate",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.56",
|
|
4
4
|
"description": "Deterministic quality gates for AI-generated code: 15 gates, Delphi review, sprint flow. Works with Claude Code, OpenCode, Qoder.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"xp-gate": "bin/xp-gate.js"
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"hooks/",
|
|
12
12
|
"adapters/",
|
|
13
13
|
"lib/*.js",
|
|
14
|
+
"lib/*.cjs",
|
|
14
15
|
"lib/*.ts",
|
|
16
|
+
"lib/*.json",
|
|
15
17
|
"gates/",
|
|
16
18
|
"skills/",
|
|
17
19
|
"plugins/",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xp-gate",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.56",
|
|
4
4
|
"displayName": "XP-Gate",
|
|
5
5
|
"description": "Extreme Programming quality gates + AI workflow skills for Claude Code. Includes 12 pre-commit gates (Gate 0-11), 8 pre-push gates, Sprint Flow (6 phases), and Delphi multi-expert review (>=90% consensus).",
|
|
6
6
|
"author": {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
**Generated:** 2026-11-04
|
|
4
4
|
**Commit:** eb2097b0
|
|
5
5
|
**Branch:** sprint/2026-11-03-02
|
|
6
|
-
**Version:** 0.41.
|
|
6
|
+
**Version:** 0.41.56.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
|
|
@@ -12,15 +12,34 @@ This guide walks you through setting up the Delphi consensus review skill in you
|
|
|
12
12
|
|
|
13
13
|
## Quick Setup (3 steps)
|
|
14
14
|
|
|
15
|
-
### Step 1:
|
|
15
|
+
### Step 1: Create ONE configuration, machine-wide by default
|
|
16
|
+
|
|
17
|
+
Two locations are read, and **a project-root file always wins over the machine-wide
|
|
18
|
+
one**. That precedence is the single most important thing on this page:
|
|
19
|
+
|
|
20
|
+
| Location | Scope | When to use it |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| `~/.config/xp-gate/.delphi-config.json` | every project on this machine | **the normal choice** |
|
|
23
|
+
| `<repo>/.delphi-config.json` | that repo only, and it **overrides** the above | only to pin different seats for one repo |
|
|
16
24
|
|
|
17
25
|
```bash
|
|
18
|
-
#
|
|
19
|
-
|
|
26
|
+
# Recommended: one config for the whole machine.
|
|
27
|
+
mkdir -p ~/.config/xp-gate
|
|
28
|
+
cp skills/delphi-review/.delphi-config.json.example ~/.config/xp-gate/.delphi-config.json
|
|
20
29
|
```
|
|
21
30
|
|
|
31
|
+
> **If you copy it into the repo root instead, every later edit to the machine-wide
|
|
32
|
+
> config becomes a no-op for that repo.** `xp-gate doctor delphi` reports this as
|
|
33
|
+
> `Delphi config shadow (#541)`; deleting the repo-root copy makes it go away. Do not
|
|
34
|
+
> put a copy in every project "to be safe" — that is what creates the shadow. Measured
|
|
35
|
+
> 2026-11-17: a consumer followed the old version of this page, then fixed the global
|
|
36
|
+
> seats and kept getting the old ones, because the repo copy silently won.
|
|
37
|
+
|
|
22
38
|
This file maps abstract expert roles to agent names. You typically don't need to edit this unless you want custom agent names.
|
|
23
39
|
|
|
40
|
+
Pass `--config <path>` to point at a specific file for one run; a relative path that
|
|
41
|
+
does not exist in the current directory falls back to the machine-wide config.
|
|
42
|
+
|
|
24
43
|
### Step 2: Add agent definitions to opencode.json
|
|
25
44
|
|
|
26
45
|
Copy the `agent` block from `skills/delphi-review/opencode.json.delphi.example` into your `opencode.json`.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
**Generated:** 2026-11-04
|
|
4
4
|
**Commit:** eb2097b0
|
|
5
5
|
**Branch:** sprint/2026-11-03-02
|
|
6
|
-
**Version:** 0.41.
|
|
6
|
+
**Version:** 0.41.56.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
**6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
|