@boyingliu01/xp-gate 0.38.34 → 0.38.36
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/powershell.sh +2 -0
- package/adapters/shell.sh +7 -0
- package/adapters/typescript.sh +51 -1
- package/hooks/gate-entries/gate-2-entry.sh +16 -0
- package/hooks/gate-entries/gate-5-entry.sh +181 -16
- package/hooks/lib/jscpd-run.sh +53 -5
- 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/package.json +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/__tests__/analyzer.test.ts +1 -1
- package/principles/__tests__/config-enforcement.test.ts +1 -1
- package/principles/__tests__/reporter.test.ts +175 -347
- package/principles/__tests__/types.test.ts +1 -1
- package/principles/adapters/base.ts +26 -0
- package/principles/adapters/csharp.ts +7 -0
- package/principles/adapters/java.ts +7 -0
- package/principles/adapters/typescript.ts +7 -0
- package/principles/analyzer.ts +70 -13
- package/principles/reporter.ts +29 -1
- package/principles/rules/__tests__/clean-code/large-file.test.ts +1 -1
- package/principles/types.ts +29 -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
|
@@ -92,7 +92,7 @@ describe('types.ts - Core Interfaces', () => {
|
|
|
92
92
|
extractClasses: () => [],
|
|
93
93
|
extractExports: () => [],
|
|
94
94
|
countLines: () => 0,
|
|
95
|
-
getDuplication: () => ({ percentage: 0, blocks: [] }),
|
|
95
|
+
getDuplication: () => ({ percentage: 0, blocks: [] }), declaresRuleCoverage: true,
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
expect(adapter.detectLanguage).toBeDefined();
|
|
@@ -72,6 +72,32 @@ export abstract class BaseAdapter implements Adapter {
|
|
|
72
72
|
return measureDuplication(this.fileContent);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Does this adapter really support the clean-code rules, or does it only make
|
|
77
|
+
* the language DETECTABLE?
|
|
78
|
+
*
|
|
79
|
+
* `false` is the SAFE default here, and the direction is worth stating plainly
|
|
80
|
+
* because it is the opposite of the usual instinct: `false` makes the gate say
|
|
81
|
+
* "this language was not analysed", which is a loss of claimed coverage, while
|
|
82
|
+
* `true` makes it say "clean", which is a claim about code nobody looked at.
|
|
83
|
+
* The first is a limitation; the second is a lie.
|
|
84
|
+
*
|
|
85
|
+
* So an adapter opts IN by overriding this to return `true` once it implements
|
|
86
|
+
* rules of its own. A new shallow adapter — detect the language, extract
|
|
87
|
+
* functions with a regex — inherits the honest answer without its author
|
|
88
|
+
* needing to know this member exists.
|
|
89
|
+
*
|
|
90
|
+
* Measured before this: a Go file with 6-level nesting produced
|
|
91
|
+
* `✓ No violations found / Files checked: 1 / Rules run: 21`, and all 21 rules
|
|
92
|
+
* ran against a file none of them can read. TypeScript with the same nesting is
|
|
93
|
+
* reported correctly, which is precisely why the gap survived — the gate looked
|
|
94
|
+
* like it worked.
|
|
95
|
+
* - a `readonly` property rather than a method, because the value is a static
|
|
96
|
+
* fact about the adapter and this class already sat at the 15-method
|
|
97
|
+
* God-Class threshold; a 16th method was a genuine warning, not a formality.
|
|
98
|
+
*/
|
|
99
|
+
readonly declaresRuleCoverage: boolean = false;
|
|
100
|
+
|
|
75
101
|
protected readFileContent(filePath: string): string {
|
|
76
102
|
try {
|
|
77
103
|
return readFileSync(filePath, 'utf-8');
|
|
@@ -81,6 +81,13 @@ function countMemberDeclarations(body: string): number {
|
|
|
81
81
|
* problem (braces inside literals/comments) applies verbatim.
|
|
82
82
|
*/
|
|
83
83
|
export class CSharpAdapter extends BaseAdapter implements Adapter {
|
|
84
|
+
/**
|
|
85
|
+
* This adapter implements rules of its own, so the gate may report its files
|
|
86
|
+
* as genuinely examined. Adapters that only make a language detectable leave
|
|
87
|
+
* this at the BaseAdapter default (`false`) and are reported as unanalysed.
|
|
88
|
+
*/
|
|
89
|
+
readonly declaresRuleCoverage: boolean = true;
|
|
90
|
+
|
|
84
91
|
detectLanguage(): string {
|
|
85
92
|
const lower = this.filePath.toLowerCase();
|
|
86
93
|
if (lower.endsWith('.cs') || lower.endsWith('.csx')) {
|
|
@@ -351,6 +351,13 @@ export const javaParse = {
|
|
|
351
351
|
};
|
|
352
352
|
|
|
353
353
|
export class JavaAdapter extends BaseAdapter implements Adapter {
|
|
354
|
+
/**
|
|
355
|
+
* This adapter implements rules of its own, so the gate may report its files
|
|
356
|
+
* as genuinely examined. Adapters that only make a language detectable leave
|
|
357
|
+
* this at the BaseAdapter default (`false`) and are reported as unanalysed.
|
|
358
|
+
*/
|
|
359
|
+
readonly declaresRuleCoverage: boolean = true;
|
|
360
|
+
|
|
354
361
|
detectLanguage(): string {
|
|
355
362
|
const ext = this.filePath.toLowerCase();
|
|
356
363
|
if (ext.endsWith('.java')) {
|
|
@@ -576,6 +576,13 @@ interface FunctionMetrics {
|
|
|
576
576
|
}
|
|
577
577
|
|
|
578
578
|
export class TypeScriptAdapter extends BaseAdapter implements Adapter {
|
|
579
|
+
/**
|
|
580
|
+
* This adapter implements rules of its own, so the gate may report its files
|
|
581
|
+
* as genuinely examined. Adapters that only make a language detectable leave
|
|
582
|
+
* this at the BaseAdapter default (`false`) and are reported as unanalysed.
|
|
583
|
+
*/
|
|
584
|
+
readonly declaresRuleCoverage: boolean = true;
|
|
585
|
+
|
|
579
586
|
detectLanguage(): string {
|
|
580
587
|
const ext = this.filePath.toLowerCase();
|
|
581
588
|
if (ext.endsWith('.ts') || ext.endsWith('.tsx')) {
|
package/principles/analyzer.ts
CHANGED
|
@@ -35,6 +35,22 @@ export interface AnalysisSummary {
|
|
|
35
35
|
infoCount: number;
|
|
36
36
|
filesChecked: number;
|
|
37
37
|
rulesRun: number;
|
|
38
|
+
/**
|
|
39
|
+
* Languages whose files were counted in `filesChecked` but which NO rule can
|
|
40
|
+
* actually examine — the adapter makes them detectable, not analysable.
|
|
41
|
+
*
|
|
42
|
+
* This exists because "no violations found" was being printed for files no
|
|
43
|
+
* rule can read. Measured: a Go file with 6-level nesting reported
|
|
44
|
+
* `✓ No violations found / Files checked: 1 / Rules run: 21`, while the same
|
|
45
|
+
* shape in TypeScript is caught. Without this field a reader cannot tell a
|
|
46
|
+
* clean file from an unexamined one, which is the defect family AGENTS.md
|
|
47
|
+
* names most often: "not checked" must never be indistinguishable from
|
|
48
|
+
* "passed".
|
|
49
|
+
*
|
|
50
|
+
* Empty means every file in the run was genuinely analysable — the output then
|
|
51
|
+
* claims exactly what it did.
|
|
52
|
+
*/
|
|
53
|
+
unanalysedLanguages: string[];
|
|
38
54
|
}
|
|
39
55
|
|
|
40
56
|
export interface AnalysisResult {
|
|
@@ -100,10 +116,56 @@ function resolveAdapter(
|
|
|
100
116
|
return adapterOrFactory;
|
|
101
117
|
}
|
|
102
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Record, once per language, that this adapter cannot actually examine its own
|
|
121
|
+
* files — it makes the language detectable, not analysable.
|
|
122
|
+
*
|
|
123
|
+
* Split out of analyze() so the bookkeeping does not raise that function's
|
|
124
|
+
* cyclomatic complexity. The gate's output then says which languages were not
|
|
125
|
+
* checked instead of printing "✓ No violations found" over them.
|
|
126
|
+
*/
|
|
127
|
+
function recordUnanalysed(adapter: Adapter, into: string[]): void {
|
|
128
|
+
if (adapter.declaresRuleCoverage) return;
|
|
129
|
+
const lang = adapter.detectLanguage();
|
|
130
|
+
if (!into.includes(lang)) into.push(lang);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Run every enabled rule against one file, accumulating into the shared result
|
|
135
|
+
* maps.
|
|
136
|
+
*
|
|
137
|
+
* Split out of analyze() for the same reason recordUnanalysed is: keeping the
|
|
138
|
+
* per-file, per-rule loop inline pushed analyze past the clean-code.long-function
|
|
139
|
+
* limit (56 lines against a maximum of 50), and that is a real signal -- the outer
|
|
140
|
+
* function is about orchestration, this is about one file.
|
|
141
|
+
*/
|
|
142
|
+
function runRulesOnFile(context: {
|
|
143
|
+
file: string;
|
|
144
|
+
adapter: Adapter;
|
|
145
|
+
rules: Rule[];
|
|
146
|
+
violations: Violation[];
|
|
147
|
+
fileResult: FileResult;
|
|
148
|
+
ruleResults: Record<string, RuleResult>;
|
|
149
|
+
errors: string[];
|
|
150
|
+
}): void {
|
|
151
|
+
for (const rule of context.rules) {
|
|
152
|
+
runRuleOnFile({
|
|
153
|
+
file: context.file,
|
|
154
|
+
rule,
|
|
155
|
+
adapter: context.adapter,
|
|
156
|
+
violations: context.violations,
|
|
157
|
+
fileResult: context.fileResult,
|
|
158
|
+
ruleResult: context.ruleResults[rule.id],
|
|
159
|
+
errors: context.errors,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
103
164
|
function computeSummary(
|
|
104
165
|
violations: Violation[],
|
|
105
166
|
fileResults: Record<string, FileResult>,
|
|
106
167
|
rulesToRun: Rule[],
|
|
168
|
+
unanalysedLanguages: string[],
|
|
107
169
|
): AnalysisSummary {
|
|
108
170
|
let errorCount = 0;
|
|
109
171
|
let warningCount = 0;
|
|
@@ -120,6 +182,7 @@ function computeSummary(
|
|
|
120
182
|
infoCount,
|
|
121
183
|
filesChecked: Object.keys(fileResults).length,
|
|
122
184
|
rulesRun: rulesToRun.length,
|
|
185
|
+
unanalysedLanguages,
|
|
123
186
|
};
|
|
124
187
|
}
|
|
125
188
|
|
|
@@ -248,27 +311,21 @@ export async function analyze(
|
|
|
248
311
|
ruleResults[rule.id] = { violationCount: 0, filesChecked: 0 };
|
|
249
312
|
}
|
|
250
313
|
|
|
314
|
+
// Languages an adapter merely makes DETECTABLE: counted in filesChecked, read by
|
|
315
|
+
// no rule. See recordUnanalysed for why this is collected separately.
|
|
316
|
+
const unanalysedLanguages: string[] = [];
|
|
317
|
+
|
|
251
318
|
for (const file of files) {
|
|
252
319
|
const adapter = resolveAdapterReporting(file, adapterOrFactory, errors);
|
|
253
320
|
if (!adapter) continue;
|
|
254
321
|
|
|
322
|
+
recordUnanalysed(adapter, unanalysedLanguages);
|
|
255
323
|
const fileResult: FileResult = { violations: [], ruleIds: [] };
|
|
256
324
|
fileResults[file] = fileResult;
|
|
257
|
-
|
|
258
|
-
for (const rule of rulesToRun) {
|
|
259
|
-
runRuleOnFile({
|
|
260
|
-
file,
|
|
261
|
-
rule,
|
|
262
|
-
adapter,
|
|
263
|
-
violations,
|
|
264
|
-
fileResult,
|
|
265
|
-
ruleResult: ruleResults[rule.id],
|
|
266
|
-
errors,
|
|
267
|
-
});
|
|
268
|
-
}
|
|
325
|
+
runRulesOnFile({ file, adapter, rules: rulesToRun, violations, fileResult, ruleResults, errors });
|
|
269
326
|
}
|
|
270
327
|
|
|
271
|
-
const summary = computeSummary(violations, fileResults, rulesToRun);
|
|
328
|
+
const summary = computeSummary(violations, fileResults, rulesToRun, unanalysedLanguages);
|
|
272
329
|
|
|
273
330
|
return {
|
|
274
331
|
violations,
|
package/principles/reporter.ts
CHANGED
|
@@ -98,7 +98,7 @@ function getRuleLevel(ruleId: string): string {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
function formatEmptyResult(result: AnalysisResult, lines: string[]): string {
|
|
101
|
-
lines.push(
|
|
101
|
+
lines.push(...emptyResultHeadline(result.summary.unanalysedLanguages));
|
|
102
102
|
lines.push('');
|
|
103
103
|
lines.push(`Files checked: ${result.summary.filesChecked}`);
|
|
104
104
|
lines.push(`Rules run: ${result.summary.rulesRun}`);
|
|
@@ -106,6 +106,34 @@ function formatEmptyResult(result: AnalysisResult, lines: string[]): string {
|
|
|
106
106
|
return lines.join('\n');
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* The headline of an empty result, which must not claim more than the run did.
|
|
111
|
+
*
|
|
112
|
+
* When some files belong to languages no rule can read, "✓ No violations found"
|
|
113
|
+
* on its own reads as "examined and clean" for code nobody examined — measured
|
|
114
|
+
* before this existed: a Go file with 6-level nesting produced exactly that line
|
|
115
|
+
* beside "Files checked: 1".
|
|
116
|
+
*
|
|
117
|
+
* The count stays visible either way, because the file WAS read and its language
|
|
118
|
+
* WAS identified; what has to change is the implication that rules looked at it.
|
|
119
|
+
*
|
|
120
|
+
* Split out of formatEmptyResult so the branch does not raise that function's
|
|
121
|
+
* cyclomatic complexity: it is a formatting decision, not an additional path
|
|
122
|
+
* through the reporting.
|
|
123
|
+
*/
|
|
124
|
+
function emptyResultHeadline(unanalysed: string[]): string[] {
|
|
125
|
+
if (unanalysed.length > 0) {
|
|
126
|
+
return [
|
|
127
|
+
'✓ No violations found in the files that were analysed',
|
|
128
|
+
'',
|
|
129
|
+
`⚠️ NOT ANALYSED: ${unanalysed.join(', ')} — an adapter exists (the language ` +
|
|
130
|
+
'is detected and counted below) but no clean-code rule can read it. These ' +
|
|
131
|
+
'files were not checked; their absence from the list above is not a pass.',
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
return ['✓ No violations found'];
|
|
135
|
+
}
|
|
136
|
+
|
|
109
137
|
function formatViolationLines(violation: Violation): string[] {
|
|
110
138
|
const severityIcon = violation.severity === 'error' ? '✗' :
|
|
111
139
|
violation.severity === 'warning' ? '⚠' : 'ℹ';
|
|
@@ -9,7 +9,7 @@ const mockAdapter = {
|
|
|
9
9
|
extractClasses: () => [],
|
|
10
10
|
extractExports: () => [],
|
|
11
11
|
countLines: (_fileName: string) => 10, // Default to small file
|
|
12
|
-
getDuplication: () => ({ percentage: 0, blocks: [] })
|
|
12
|
+
getDuplication: () => ({ percentage: 0, blocks: [] }), declaresRuleCoverage: true
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
describe('largeFileRule', () => {
|
package/principles/types.ts
CHANGED
|
@@ -78,4 +78,33 @@ export interface Adapter {
|
|
|
78
78
|
* not default into silence.
|
|
79
79
|
*/
|
|
80
80
|
getDuplication: () => DuplicationReport;
|
|
81
|
+
/**
|
|
82
|
+
* Can this adapter actually support the clean-code rules, or does it only make
|
|
83
|
+
* the language DETECTABLE?
|
|
84
|
+
*
|
|
85
|
+
* Per `src/principles/AGENTS.md` the two are not the same and the difference is
|
|
86
|
+
* deliberate: this engine covers languages it can parse meaningfully, while the
|
|
87
|
+
* shell adapters cover languages it can lint or test. An adapter with no
|
|
88
|
+
* TS-side rule support is not a bug — but reporting its files as "✓ No
|
|
89
|
+
* violations found" is, because that reads as "examined and clean".
|
|
90
|
+
*
|
|
91
|
+
* Measured before this member existed: a Go file with 6-level nesting produced
|
|
92
|
+
* `✓ No violations found / Files checked: 1 / Rules run: 21`. All 21 rules ran
|
|
93
|
+
* against a file none of them can read. The same content in TypeScript is
|
|
94
|
+
* reported correctly, which is what made it invisible.
|
|
95
|
+
*
|
|
96
|
+
* REQUIRED, for the same reason `getDuplication` is: an optional member plus an
|
|
97
|
+
* `undefined`-means-analysed branch would reproduce the defect it fixes.
|
|
98
|
+
*
|
|
99
|
+
* The default lives in `BaseAdapter` and must be the SAFE side. Safe here is the
|
|
100
|
+
* opposite of instinct: `false` makes the gate say "not analysed", which is a
|
|
101
|
+
* loss of claimed coverage; `true` would make it say "clean", which is a claim
|
|
102
|
+
* about code nobody read. An adapter that genuinely implements rules opts in.
|
|
103
|
+
*
|
|
104
|
+
* A boolean property rather than a method — the value is a static fact about the
|
|
105
|
+
* adapter, not something that varies per call, and `BaseAdapter` already sat at
|
|
106
|
+
* the 15-method God-Class threshold, so a 16th method was a real warning rather
|
|
107
|
+
* than a formality.
|
|
108
|
+
*/
|
|
109
|
+
declaresRuleCoverage: boolean;
|
|
81
110
|
}
|
|
@@ -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.36.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.36.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.36.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
|