@boyingliu01/xp-gate 0.38.32 → 0.38.33
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 +39 -3
- package/adapters/gate-4.sh +1 -1
- package/adapters/php.sh +362 -0
- package/gate-3.sh +39 -3
- package/gate-4.sh +1 -1
- package/hooks/gate-3.sh +39 -3
- package/hooks/gate-4.sh +1 -1
- package/lib/__tests__/language-capability.test.js +291 -0
- package/lib/__tests__/language-tools-detect.test.js +82 -0
- package/lib/language-capability-surfaces.js +315 -0
- package/lib/language-capability.js +474 -0
- package/lib/language-tools.js +107 -0
- package/lib/mattpocock-license-verdict.json +1 -1
- package/package.json +1 -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/sprint-flow/AGENTS.md +1 -1
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
- package/principles/adapters/php.ts +77 -0
- package/principles/analyzer.ts +6 -0
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/test-specification-alignment/AGENTS.md +1 -1
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @module language-capability
|
|
4
|
+
* @test REQ-LANG-CAPABILITY
|
|
5
|
+
* @intent Answer "is language X actually wired into every gate surface?" by
|
|
6
|
+
* DERIVING the answer from the code instead of reading a document.
|
|
7
|
+
*
|
|
8
|
+
* WHY THIS EXISTS. C# support took five separate repair waves across
|
|
9
|
+
* sixteen days (#717, #730, #763, #768, #776, #780, #783, #798), and
|
|
10
|
+
* the consuming project had to build ~400 lines of its own gates to
|
|
11
|
+
* cover what xp-gate did not. None of those waves was "a hard bug":
|
|
12
|
+
* each was ONE SURFACE that had not been wired. The failure mode was
|
|
13
|
+
* always identical -- the gate read an empty file list, took the
|
|
14
|
+
* "no files to check" branch, and printed ✅ PASSED or ⏭️ SKIPPED.
|
|
15
|
+
* Nothing anywhere said "this language is not covered here".
|
|
16
|
+
*
|
|
17
|
+
* The root cause is structural: a language has to be written into
|
|
18
|
+
* SIX independent knowledge surfaces (adapter, Gate 1 verdict arm,
|
|
19
|
+
* Gate 3 lizard population, Gate 4 analyzer map, Gate 5 extensions,
|
|
20
|
+
* Gate 6 architecture arm, Gate 9 build arm, Gate 13 strictness) plus
|
|
21
|
+
* three CLI/CI surfaces, and NONE of them reference each other. Adding
|
|
22
|
+
* a language file without wiring it produces silence, not an error.
|
|
23
|
+
*
|
|
24
|
+
* So this module does not maintain a second list. It READS the same
|
|
25
|
+
* files the gates read and reports what it finds, per surface, in the
|
|
26
|
+
* project's own three-state vocabulary:
|
|
27
|
+
*
|
|
28
|
+
* checked the surface will actually evaluate this language
|
|
29
|
+
* NOT WIRED the surface exists but this language is absent from it
|
|
30
|
+
* not impl. this surface has no arm for the language at all
|
|
31
|
+
*
|
|
32
|
+
* The distinction between the last two is the point. "NOT WIRED" is a
|
|
33
|
+
* one-line fix that someone forgot; "not impl." is a design gap that
|
|
34
|
+
* must be declared. Collapsing them (the way ✅/nothing collapsed them
|
|
35
|
+
* in the hook) is what made the C# gap invisible.
|
|
36
|
+
*
|
|
37
|
+
* WHY DERIVED AND NOT DECLARED. `gate-capability.js` already
|
|
38
|
+
* established the rule for gates: derive from `gate-registry.sh`, never
|
|
39
|
+
* restate. A hand-maintained "language support matrix" is the same
|
|
40
|
+
* defect one level down -- it would be the fourteenth copy of the
|
|
41
|
+
* extension list, written in prose, with no test able to notice it
|
|
42
|
+
* going stale. Derived output cannot drift: it changes when the code
|
|
43
|
+
* changes, which is exactly the property the C# retrofit lacked.
|
|
44
|
+
*
|
|
45
|
+
* @see docs/2026-11-19-csharp-onboarding-retrospective.md
|
|
46
|
+
*/
|
|
47
|
+
'use strict';
|
|
48
|
+
|
|
49
|
+
const fs = require('node:fs');
|
|
50
|
+
const path = require('node:path');
|
|
51
|
+
|
|
52
|
+
/** The three verdicts, closed vocabulary. An open set lets a new state read as fine. */
|
|
53
|
+
const STATE = Object.freeze({
|
|
54
|
+
/** The surface will evaluate this language. */
|
|
55
|
+
CHECKED: 'checked',
|
|
56
|
+
/** The surface exists and supports languages, but this one is absent from it. */
|
|
57
|
+
NOT_WIRED: 'not-wired',
|
|
58
|
+
/** The surface has no arm that could ever handle this language. */
|
|
59
|
+
NOT_IMPLEMENTED: 'not-implemented',
|
|
60
|
+
/** The surface could not be located or parsed — say so, never guess. */
|
|
61
|
+
UNKNOWN: 'unknown',
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/** Display order and human titles for the surfaces, one row per inspection. */
|
|
65
|
+
const SURFACES = Object.freeze([
|
|
66
|
+
{ key: 'adapter', title: 'Adapter (Gate 1/5 runtime)' },
|
|
67
|
+
{ key: 'gate0-detect', title: 'Gate 0 language detection' },
|
|
68
|
+
{ key: 'gate-1', title: 'Gate 1 code quality (verdict arm)' },
|
|
69
|
+
{ key: 'gate-2', title: 'Gate 2 duplicate code' },
|
|
70
|
+
{ key: 'gate-3', title: 'Gate 3 complexity (lizard)' },
|
|
71
|
+
{ key: 'gate-4', title: 'Gate 4 principles (analyzer map)' },
|
|
72
|
+
{ key: 'gate-5', title: 'Gate 5 tests + coverage' },
|
|
73
|
+
{ key: 'gate-6', title: 'Gate 6 architecture' },
|
|
74
|
+
{ key: 'gate-9', title: 'Gate 9 build integrity' },
|
|
75
|
+
{ key: 'gate-10', title: 'Gate 10 SAST ruleset' },
|
|
76
|
+
{ key: 'gate-13', title: 'Gate 13 compiler strictness' },
|
|
77
|
+
{ key: 'cli-registry', title: 'CLI LANGUAGE_REGISTRY' },
|
|
78
|
+
{ key: 'ci-detect', title: 'CI language detection' },
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Languages to inspect and the extensions that identify them.
|
|
83
|
+
*
|
|
84
|
+
* This is the ONE place this module names languages, and it does so only to
|
|
85
|
+
* know which tokens to LOOK FOR in the surfaces below -- it is not a claim
|
|
86
|
+
* about support. Every verdict is read from the named file.
|
|
87
|
+
*
|
|
88
|
+
* Deliberately NOT derived from LANGUAGE_REGISTRY in language-tools.js: that
|
|
89
|
+
* registry is itself one of the surfaces under test (cli-registry below), and
|
|
90
|
+
* using it as the source of truth would mean "a language missing from the
|
|
91
|
+
* registry cannot be reported missing from the registry".
|
|
92
|
+
*/
|
|
93
|
+
const LANGUAGES = Object.freeze({
|
|
94
|
+
typescript: { extensions: ['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs'] },
|
|
95
|
+
python: { extensions: ['py'] },
|
|
96
|
+
go: { extensions: ['go'] },
|
|
97
|
+
java: { extensions: ['java'] },
|
|
98
|
+
kotlin: { extensions: ['kt', 'kts'] },
|
|
99
|
+
csharp: { extensions: ['cs', 'csx'] },
|
|
100
|
+
cpp: { extensions: ['cpp', 'cxx', 'cc', 'c', 'h', 'hpp'] },
|
|
101
|
+
swift: { extensions: ['swift'] },
|
|
102
|
+
objectivec: { extensions: ['m', 'mm'] },
|
|
103
|
+
dart: { extensions: ['dart'] },
|
|
104
|
+
php: { extensions: ['php'] },
|
|
105
|
+
shell: { extensions: ['sh', 'bash'] },
|
|
106
|
+
powershell: { extensions: ['ps1', 'psm1'] },
|
|
107
|
+
iac: { extensions: ['tf'] },
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Languages the `p/security-audit` baseline ruleset can actually analyse.
|
|
112
|
+
*
|
|
113
|
+
* MEASURED, not assumed: the cached ruleset's `languages:` keys count python 77,
|
|
114
|
+
* java 52, go 28, typescript 20, javascript 20, ruby 16, c 9, kt 3, hcl 3. PHP
|
|
115
|
+
* appears only inside OWASP URLs (`.../index.php`) and has ZERO rules, and
|
|
116
|
+
* csharp has zero -- which is why Gate 10 loads `p/csharp` conditionally.
|
|
117
|
+
*
|
|
118
|
+
* This is the one place in this module that encodes MEASURED tool knowledge
|
|
119
|
+
* rather than reading a file, because the cover set lives in a downloaded
|
|
120
|
+
* artifact that is not in the repo. It is kept as a small explicit set so that
|
|
121
|
+
* a language admitted to the baseline later reads as `unknown` (honest) rather
|
|
122
|
+
* than as a defect (a false alarm) until someone re-measures.
|
|
123
|
+
*/
|
|
124
|
+
const SAST_BASELINE_LANGUAGES = new Set([
|
|
125
|
+
'typescript',
|
|
126
|
+
'python',
|
|
127
|
+
'go',
|
|
128
|
+
'java',
|
|
129
|
+
'kotlin',
|
|
130
|
+
'cpp',
|
|
131
|
+
'shell', // via the `generic`/`c` arms; measured indirectly, see docs
|
|
132
|
+
]);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Resolve the repo root that holds `githooks/`.
|
|
136
|
+
*
|
|
137
|
+
* Installed copies live under `<pkg>/lib/`, with the hooks one level up; a
|
|
138
|
+
* source checkout may have this file under `src/npm-package/lib/`. Probe for
|
|
139
|
+
* the marker rather than assuming a depth -- a wrong depth would make every
|
|
140
|
+
* surface report `unknown`, which reads like "not implemented".
|
|
141
|
+
*
|
|
142
|
+
* @param {string} [startDir]
|
|
143
|
+
* @returns {string|null} directory containing `githooks/`, or null
|
|
144
|
+
*/
|
|
145
|
+
function findHooksRoot(startDir = __dirname) {
|
|
146
|
+
let dir = path.resolve(startDir);
|
|
147
|
+
for (let i = 0; i < 8; i += 1) {
|
|
148
|
+
if (fs.existsSync(path.join(dir, 'githooks', 'pre-commit'))) return dir;
|
|
149
|
+
const parent = path.dirname(dir);
|
|
150
|
+
if (parent === dir) break;
|
|
151
|
+
dir = parent;
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @param {string} file
|
|
158
|
+
* @returns {string|null} file contents, or null when it cannot be read
|
|
159
|
+
*/
|
|
160
|
+
function readIfPresent(file) {
|
|
161
|
+
try {
|
|
162
|
+
return fs.readFileSync(file, 'utf8');
|
|
163
|
+
} catch {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Does `ext` appear as a standalone extension token in a `|`-separated list?
|
|
170
|
+
*
|
|
171
|
+
* The source alternations are written `\.(ts|tsx|cs|csx)$`, so the input here
|
|
172
|
+
* is the CONTENT between the parens (`ts|tsx|cs|csx`) already extracted by
|
|
173
|
+
* `extensionAlternation`. A bare `includes('cs')` would match the `cs` inside
|
|
174
|
+
* `csx` -- reporting a language as wired when the list only lists its sibling.
|
|
175
|
+
* Split on `|` and compare whole elements instead: exact, and impossible to
|
|
176
|
+
* fool with a substring.
|
|
177
|
+
*
|
|
178
|
+
* @param {string} alternation e.g. `ts|tsx|js`
|
|
179
|
+
* @param {string} ext e.g. `ts`
|
|
180
|
+
* @returns {boolean}
|
|
181
|
+
*/
|
|
182
|
+
function hasExtensionToken(alternation, ext) {
|
|
183
|
+
if (!alternation) return false;
|
|
184
|
+
return alternation
|
|
185
|
+
.split('|')
|
|
186
|
+
.map((token) => token.trim().replace(/^\\+/, '').replace(/[\\)\$\\]+$/, ''))
|
|
187
|
+
.includes(ext);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Extract the content of every `\.(<alts>)$` alternation in `text`.
|
|
192
|
+
*
|
|
193
|
+
* Written once because the same shape appears in five differently-named
|
|
194
|
+
* variables (`CODE_EXTENSIONS`, `PRINCIPLES_FILES`, `SOURCE_FILES`, `CC_FILES`,
|
|
195
|
+
* the Gate 1 short-circuit). Matching the SHAPE rather than a variable name is
|
|
196
|
+
* what keeps this reader working when someone renames the variable -- and a
|
|
197
|
+
* reader that silently returns '' on a renamed variable would report every
|
|
198
|
+
* language as NOT WIRED, which is the false-alarm direction that gets tools
|
|
199
|
+
* switched off.
|
|
200
|
+
*
|
|
201
|
+
* @param {string} text
|
|
202
|
+
* @returns {string[]} alternation bodies, each like `ts|tsx|js`
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Does `text` name `lang` as a language key (not merely mention the word)?
|
|
207
|
+
*
|
|
208
|
+
* `csharp`, `php`, `go` are short enough that a plain substring search finds
|
|
209
|
+
* them in comments and in unrelated identifiers. Require a quoted or delimited
|
|
210
|
+
* occurrence so a prose mention cannot be read as an implementation.
|
|
211
|
+
*
|
|
212
|
+
* @param {string} text
|
|
213
|
+
* @param {string} lang
|
|
214
|
+
* @returns {boolean}
|
|
215
|
+
*/
|
|
216
|
+
function extensionAlternations(text) {
|
|
217
|
+
if (!text) return [];
|
|
218
|
+
// The source spells the regex as `\.( … )$` inside a single-quoted shell
|
|
219
|
+
// string or a double-quoted JS/TS string. Match the literal backslash-dot,
|
|
220
|
+
// then the parenthesised alternation, then the anchor. `[^)]*` rather than a
|
|
221
|
+
// stricter class because extension lists are the only thing this pattern is
|
|
222
|
+
// asked to match.
|
|
223
|
+
const re = /\\\.\(([^)]*)\)/g;
|
|
224
|
+
const out = [];
|
|
225
|
+
let m;
|
|
226
|
+
while ((m = re.exec(text)) !== null) out.push(m[1]);
|
|
227
|
+
return out;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Does any `\.( … )$` alternation in `text` list one of `exts`?
|
|
232
|
+
* @param {string} text
|
|
233
|
+
* @param {string[]} exts
|
|
234
|
+
* @returns {boolean}
|
|
235
|
+
*/
|
|
236
|
+
function anyAlternationHas(text, exts) {
|
|
237
|
+
const alternations = extensionAlternations(text);
|
|
238
|
+
return exts.some((ext) => alternations.some((alt) => hasExtensionToken(alt, ext)));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Does `text` name `lang` as a language key (not merely mention the word)?
|
|
243
|
+
*
|
|
244
|
+
* `csharp`, `php`, `go` are short enough that a plain substring search finds
|
|
245
|
+
* them in comments and in unrelated identifiers. Require a quoted or delimited
|
|
246
|
+
* occurrence so a prose mention cannot be read as an implementation.
|
|
247
|
+
*
|
|
248
|
+
* @param {string} text
|
|
249
|
+
* @param {string} lang
|
|
250
|
+
* @returns {boolean}
|
|
251
|
+
*/
|
|
252
|
+
function hasLanguageKey(text, lang) {
|
|
253
|
+
if (!text) return false;
|
|
254
|
+
const escaped = lang.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
255
|
+
const patterns = [
|
|
256
|
+
new RegExp(`["'\`]${escaped}["'\`]`),
|
|
257
|
+
new RegExp(`^\\s*${escaped}\\)`, 'm'),
|
|
258
|
+
new RegExp(`\\b${escaped}\\b\\s*(?::|\\))`),
|
|
259
|
+
];
|
|
260
|
+
return patterns.some((re) => re.test(text));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Count function DEFINITIONS and CALLS separately for a shell function name.
|
|
265
|
+
*
|
|
266
|
+
* The C# Gate 13 path shipped a `gate13_run_csharp_analysis()` that nothing
|
|
267
|
+
* called (#717 §8). A surface that is "defined but not invoked" is worse than
|
|
268
|
+
* an absent one: grep finds the name and reads as coverage. These two counts
|
|
269
|
+
* are the difference, so they are counted, not grepped for once.
|
|
270
|
+
*
|
|
271
|
+
* @param {string} text
|
|
272
|
+
* @param {string} fnName
|
|
273
|
+
* @returns {{defined: boolean, called: boolean}}
|
|
274
|
+
*/
|
|
275
|
+
function definitionAndCall(text, fnName) {
|
|
276
|
+
if (!text) return { defined: false, called: false };
|
|
277
|
+
const escaped = fnName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
278
|
+
const defined = new RegExp(`^${escaped}\\s*\\(\\)`, 'm').test(text);
|
|
279
|
+
const called = new RegExp(`(^|[^\\w-])${escaped}(\\s|$|;|&)`, 'm').test(
|
|
280
|
+
text
|
|
281
|
+
.split('\n')
|
|
282
|
+
.filter((line) => !new RegExp(`^\\s*${escaped}\\s*\\(\\)`).test(line))
|
|
283
|
+
.filter((line) => !/^\s*#/.test(line))
|
|
284
|
+
.join('\n'),
|
|
285
|
+
);
|
|
286
|
+
return { defined, called };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Build one result row.
|
|
291
|
+
* @param {string} surface
|
|
292
|
+
* @param {string} language
|
|
293
|
+
* @param {string} state
|
|
294
|
+
* @param {string} evidence
|
|
295
|
+
* @returns {{surface: string, language: string, state: string, evidence: string}}
|
|
296
|
+
*/
|
|
297
|
+
function row(surface, language, state, evidence) {
|
|
298
|
+
return { surface, language, state, evidence };
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Inspect every surface for one language.
|
|
303
|
+
*
|
|
304
|
+
* Each inspector is independent and returns exactly one row. A surface whose
|
|
305
|
+
* inputs are unreadable returns `unknown` with the reason -- never `checked`,
|
|
306
|
+
* because an unreadable file is not evidence of wiring.
|
|
307
|
+
*
|
|
308
|
+
* @param {string} lang
|
|
309
|
+
* @param {{root: string|null, read: (rel: string) => string|null}} ctx
|
|
310
|
+
* @returns {Array<{surface: string, language: string, state: string, evidence: string}>}
|
|
311
|
+
*/
|
|
312
|
+
function inspectLanguage(lang, ctx) {
|
|
313
|
+
// The 13 per-surface inspectors live in language-capability-surfaces.js.
|
|
314
|
+
// They were extracted after Gate 4 measured the single function at 264 lines
|
|
315
|
+
// (clean-code.long-function max 50): a report that cannot pass the gate it
|
|
316
|
+
// explains has no standing to explain it. Behaviour is unchanged -- each
|
|
317
|
+
// helper returns exactly the one row this loop used to push.
|
|
318
|
+
const deps = {
|
|
319
|
+
row,
|
|
320
|
+
STATE,
|
|
321
|
+
hasLanguageKey,
|
|
322
|
+
anyAlternationHas,
|
|
323
|
+
definitionAndCall,
|
|
324
|
+
SAST_BASELINE_LANGUAGES,
|
|
325
|
+
SURFACES,
|
|
326
|
+
LANGUAGES,
|
|
327
|
+
};
|
|
328
|
+
const surfaces = require("./language-capability-surfaces");
|
|
329
|
+
return surfaces.inspectLanguage(deps, lang, ctx);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function inspectAll(options = {}) {
|
|
333
|
+
const root = options.root === undefined ? findHooksRoot() : options.root;
|
|
334
|
+
const ctx = {
|
|
335
|
+
root,
|
|
336
|
+
read: (rel) => (root === null ? null : readIfPresent(path.join(root, rel))),
|
|
337
|
+
};
|
|
338
|
+
const rows = [];
|
|
339
|
+
for (const lang of Object.keys(LANGUAGES)) rows.push(...inspectLanguage(lang, ctx));
|
|
340
|
+
return rows;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** @param {string} state @returns {string} a fixed-width glyph for the console table */
|
|
344
|
+
function glyph(state) {
|
|
345
|
+
switch (state) {
|
|
346
|
+
case STATE.CHECKED:
|
|
347
|
+
return '✅';
|
|
348
|
+
case STATE.NOT_WIRED:
|
|
349
|
+
return '❌';
|
|
350
|
+
case STATE.NOT_IMPLEMENTED:
|
|
351
|
+
return '⬜';
|
|
352
|
+
default:
|
|
353
|
+
return '❔';
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Summarise one language's rows into the sentence a human actually needs.
|
|
359
|
+
*
|
|
360
|
+
* Deliberately counts NOT WIRED and NOT IMPLEMENTED separately. Folding them
|
|
361
|
+
* together is the same conflation that made "not checked" and "passed" look
|
|
362
|
+
* alike in the hook: one is a bug, the other is a declared gap, and they have
|
|
363
|
+
* different owners.
|
|
364
|
+
*
|
|
365
|
+
* @param {Array<object>} rows
|
|
366
|
+
* @returns {{total: number, checked: number, notWired: number, notImplemented: number, unknown: number}}
|
|
367
|
+
*/
|
|
368
|
+
function summarise(rows) {
|
|
369
|
+
const out = { total: rows.length, checked: 0, notWired: 0, notImplemented: 0, unknown: 0 };
|
|
370
|
+
for (const r of rows) {
|
|
371
|
+
if (r.state === STATE.CHECKED) out.checked += 1;
|
|
372
|
+
else if (r.state === STATE.NOT_WIRED) out.notWired += 1;
|
|
373
|
+
else if (r.state === STATE.NOT_IMPLEMENTED) out.notImplemented += 1;
|
|
374
|
+
else out.unknown += 1;
|
|
375
|
+
}
|
|
376
|
+
return out;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Render a human-readable report.
|
|
381
|
+
* @param {Array<object>} rows
|
|
382
|
+
* @param {{lang?: string}} [options]
|
|
383
|
+
* @returns {string}
|
|
384
|
+
*/
|
|
385
|
+
function formatReport(rows, options = {}) {
|
|
386
|
+
const languages = options.lang ? [options.lang] : [...new Set(rows.map((r) => r.language))];
|
|
387
|
+
const lines = [];
|
|
388
|
+
let anyNotWired = false;
|
|
389
|
+
|
|
390
|
+
for (const lang of languages) {
|
|
391
|
+
const mine = rows.filter((r) => r.language === lang);
|
|
392
|
+
if (mine.length === 0) {
|
|
393
|
+
lines.push(`${lang}: unknown language (not in the inspectable set)`);
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const sum = summarise(mine);
|
|
397
|
+
if (sum.notWired > 0) anyNotWired = true;
|
|
398
|
+
lines.push('');
|
|
399
|
+
lines.push(
|
|
400
|
+
`${lang}: ${sum.checked}/${sum.total} surfaces checked` +
|
|
401
|
+
(sum.notWired ? `, ${sum.notWired} NOT WIRED` : '') +
|
|
402
|
+
(sum.notImplemented ? `, ${sum.notImplemented} not implemented` : '') +
|
|
403
|
+
(sum.unknown ? `, ${sum.unknown} unknown` : ''),
|
|
404
|
+
);
|
|
405
|
+
for (const surface of SURFACES) {
|
|
406
|
+
const r = mine.find((x) => x.surface === surface.key);
|
|
407
|
+
if (!r) continue;
|
|
408
|
+
lines.push(` ${glyph(r.state)} ${surface.title.padEnd(38)} ${r.evidence}`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
lines.push('');
|
|
413
|
+
if (anyNotWired) {
|
|
414
|
+
lines.push('❌ NOT WIRED means the surface exists but this language is absent from it —');
|
|
415
|
+
lines.push(' the gate will print PASSED/SKIPPED without evaluating anything.');
|
|
416
|
+
lines.push('⬜ not implemented is a declared gap: fix it or say so in the capability matrix.');
|
|
417
|
+
} else {
|
|
418
|
+
lines.push('✅ every inspectable surface is wired for the languages above.');
|
|
419
|
+
}
|
|
420
|
+
return lines.join('\n');
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Handle `xp-gate language-capability [lang...] [--json]`.
|
|
425
|
+
*
|
|
426
|
+
* Exit code: 0 when every surface is checked or declared-not-implemented;
|
|
427
|
+
* 1 when any surface is NOT WIRED. Exit 1 rather than 0 because this command
|
|
428
|
+
* exists to gate language onboarding — a report that cannot fail is a report
|
|
429
|
+
* nobody reads.
|
|
430
|
+
*
|
|
431
|
+
* @param {string[]} args
|
|
432
|
+
* @returns {number} process exit code
|
|
433
|
+
*/
|
|
434
|
+
function handleLanguageCapability(args = []) {
|
|
435
|
+
const json = args.includes('--json');
|
|
436
|
+
const requested = args.filter((a) => !a.startsWith('--'));
|
|
437
|
+
const unknown = requested.filter((l) => !LANGUAGES[l]);
|
|
438
|
+
if (unknown.length > 0) {
|
|
439
|
+
process.stderr.write(`unknown language(s): ${unknown.join(', ')}\n`);
|
|
440
|
+
process.stderr.write(`known: ${Object.keys(LANGUAGES).join(', ')}\n`);
|
|
441
|
+
return 2;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const all = inspectAll();
|
|
445
|
+
const rows = requested.length === 0 ? all : all.filter((r) => requested.includes(r.language));
|
|
446
|
+
|
|
447
|
+
if (json) {
|
|
448
|
+
const byLanguage = {};
|
|
449
|
+
for (const lang of new Set(rows.map((r) => r.language))) {
|
|
450
|
+
const mine = rows.filter((r) => r.language === lang);
|
|
451
|
+
byLanguage[lang] = { summary: summarise(mine), surfaces: mine };
|
|
452
|
+
}
|
|
453
|
+
process.stdout.write(`${JSON.stringify({ languages: byLanguage }, null, 2)}\n`);
|
|
454
|
+
} else {
|
|
455
|
+
process.stdout.write(`${formatReport(rows, { lang: requested.length === 1 ? requested[0] : undefined })}\n`);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return summarise(rows).notWired > 0 ? 1 : 0;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
module.exports = {
|
|
462
|
+
STATE,
|
|
463
|
+
SURFACES,
|
|
464
|
+
LANGUAGES,
|
|
465
|
+
hasExtensionToken,
|
|
466
|
+
hasLanguageKey,
|
|
467
|
+
definitionAndCall,
|
|
468
|
+
findHooksRoot,
|
|
469
|
+
inspectLanguage,
|
|
470
|
+
inspectAll,
|
|
471
|
+
summarise,
|
|
472
|
+
formatReport,
|
|
473
|
+
handleLanguageCapability,
|
|
474
|
+
};
|
package/lib/language-tools.js
CHANGED
|
@@ -365,6 +365,113 @@ const LANGUAGE_REGISTRY = {
|
|
|
365
365
|
],
|
|
366
366
|
},
|
|
367
367
|
|
|
368
|
+
// #846: Objective-C had a full runtime (githooks/adapters/objectivec.sh) and
|
|
369
|
+
// was recognised by every GATE-layer list -- Gate 1's short-circuit, Gate 3's
|
|
370
|
+
// lizard population, Gate 4's PRINCIPLES_FILES, Gate 5's CODE_EXTENSIONS,
|
|
371
|
+
// Gate 10's SEMGREP_FILES, lib/docs-only.sh -- yet was absent HERE. That is
|
|
372
|
+
// #730's shape exactly: `detect-languages` writes a config without it, the
|
|
373
|
+
// hook trusts that config and does NOT fall back to extension sniffing, so an
|
|
374
|
+
// Objective-C repo was never routed. Registry membership, not gate support, is
|
|
375
|
+
// what makes a language reachable.
|
|
376
|
+
//
|
|
377
|
+
// Detection keys off Xcode manifests and NOT off the `.m`/`.mm` extension.
|
|
378
|
+
// `.m` is also MATLAB's, and `configFiles` is non-empty here on purpose:
|
|
379
|
+
// detectProjectLanguages only consults the extension fallback when
|
|
380
|
+
// `configFiles.length === 0`, so listing a manifest both enables detection and
|
|
381
|
+
// structurally prevents a MATLAB checkout from being reported as Objective-C.
|
|
382
|
+
// `*.pbxproj` is globbed because the project file lives inside
|
|
383
|
+
// `<name>.xcodeproj/`, not at the repo root.
|
|
384
|
+
objectivec: {
|
|
385
|
+
name: 'Objective-C',
|
|
386
|
+
extensions: ['m', 'mm'],
|
|
387
|
+
configFiles: ['Podfile', 'Package.swift', '*.xcodeproj', '*.pbxproj'],
|
|
388
|
+
tools: [
|
|
389
|
+
{
|
|
390
|
+
name: 'clang',
|
|
391
|
+
checkCmd: 'clang --version',
|
|
392
|
+
install: {
|
|
393
|
+
darwin: 'xcode-select --install',
|
|
394
|
+
linux: 'apt install clang',
|
|
395
|
+
win32: 'See https://clang.llvm.org/get_started.html',
|
|
396
|
+
},
|
|
397
|
+
optional: false,
|
|
398
|
+
gates: ['Gate 1 (Build + Quality)'],
|
|
399
|
+
},
|
|
400
|
+
],
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
// #731: PHP. `configFiles` is non-empty on purpose, for the same structural
|
|
404
|
+
// reason as objectivec below -- detectProjectLanguages only consults the
|
|
405
|
+
// extension fallback when `configFiles.length === 0`, so a manifest keeps the
|
|
406
|
+
// signal anchored to a real project rather than to a stray .php file.
|
|
407
|
+
// composer.json is listed first but is NOT treated as exclusive: unlike a
|
|
408
|
+
// .csproj, it coexists happily with package.json in JS repos that shell out for
|
|
409
|
+
// one build step. The Gate 0 detection arm keys off `.php` extensions instead.
|
|
410
|
+
php: {
|
|
411
|
+
name: 'PHP',
|
|
412
|
+
extensions: ['php', 'phtml'],
|
|
413
|
+
configFiles: ['composer.json', 'phpunit.xml', 'phpunit.xml.dist', 'phpstan.neon'],
|
|
414
|
+
tools: [
|
|
415
|
+
{
|
|
416
|
+
name: 'php',
|
|
417
|
+
checkCmd: 'php --version',
|
|
418
|
+
install: {
|
|
419
|
+
darwin: 'brew install php',
|
|
420
|
+
linux: 'sudo apt install php-cli composer',
|
|
421
|
+
win32: 'scoop install php composer',
|
|
422
|
+
},
|
|
423
|
+
optional: false,
|
|
424
|
+
gates: ['Gate 1 (Build + Quality)', 'Gate 5 (Coverage)'],
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
name: 'composer',
|
|
428
|
+
checkCmd: 'composer --version',
|
|
429
|
+
install: {
|
|
430
|
+
darwin: 'brew install composer',
|
|
431
|
+
linux: 'See https://getcomposer.org/download/',
|
|
432
|
+
win32: 'scoop install composer',
|
|
433
|
+
},
|
|
434
|
+
optional: false,
|
|
435
|
+
gates: ['Gate 1 (Build + Quality)'],
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
name: 'phpstan',
|
|
439
|
+
checkCmd: 'php vendor/bin/phpstan --version',
|
|
440
|
+
install: {
|
|
441
|
+
darwin: 'composer require --dev phpstan/phpstan',
|
|
442
|
+
linux: 'composer require --dev phpstan/phpstan',
|
|
443
|
+
win32: 'composer require --dev phpstan/phpstan',
|
|
444
|
+
},
|
|
445
|
+
optional: false,
|
|
446
|
+
gates: ['Gate 1 (Build + Quality)'],
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
name: 'phpcs',
|
|
450
|
+
checkCmd: 'php vendor/bin/phpcs --version',
|
|
451
|
+
install: {
|
|
452
|
+
darwin: 'composer require --dev squizlabs/php_codesniffer',
|
|
453
|
+
linux: 'composer require --dev squizlabs/php_codesniffer',
|
|
454
|
+
win32: 'composer require --dev squizlabs/php_codesniffer',
|
|
455
|
+
},
|
|
456
|
+
optional: false,
|
|
457
|
+
gates: ['Gate 1 (Build + Quality)'],
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
name: 'pcov',
|
|
461
|
+
checkCmd: 'php -r "exit(extension_loaded(\'pcov\')?0:1);"',
|
|
462
|
+
install: {
|
|
463
|
+
darwin: 'pecl install pcov',
|
|
464
|
+
linux: 'pecl install pcov',
|
|
465
|
+
win32: 'php_pcov.dll from https://windows.php.net/downloads/pecl/releases/pcov/ (must match the PHP build: ts vs nts)',
|
|
466
|
+
},
|
|
467
|
+
// Coverage is Gate 5's business; a missing driver makes coverage
|
|
468
|
+
// unmeasurable, which the adapter reports as BLOCK rather than 0%.
|
|
469
|
+
optional: true,
|
|
470
|
+
gates: ['Gate 5 (Coverage)'],
|
|
471
|
+
},
|
|
472
|
+
],
|
|
473
|
+
},
|
|
474
|
+
|
|
368
475
|
dart: {
|
|
369
476
|
name: 'Dart',
|
|
370
477
|
extensions: ['dart'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xp-gate",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.33",
|
|
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.38.
|
|
6
|
+
**Version:** 0.38.33.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.
|
|
@@ -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.38.
|
|
6
|
+
**Version:** 0.38.33.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.
|
|
@@ -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.38.
|
|
6
|
+
**Version:** 0.38.33.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
|
|
@@ -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.38.
|
|
6
|
+
**Version:** 0.38.33.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.
|
|
@@ -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.38.
|
|
6
|
+
**Version:** 0.38.33.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.
|
|
@@ -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.38.
|
|
6
|
+
**Version:** 0.38.33.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
|