@boyingliu01/xp-gate 0.41.68 → 0.41.69
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/bin/xp-gate.js +52 -34
- package/lib/mattpocock-license-verdict.json +1 -1
- package/lib/test-alignment.ts +165 -133
- 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/plugin.json +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/skills/delphi-review/AGENTS.md +1 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/test-specification-alignment/AGENTS.md +1 -1
package/bin/xp-gate.js
CHANGED
|
@@ -144,36 +144,60 @@ function runAlignmentViaNpx(runnerPath, specPath, testDirs, outputPath, jsonMode
|
|
|
144
144
|
return result.status === 0 ? 0 : 1;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Parse check-alignment's flags.
|
|
149
|
+
*
|
|
150
|
+
* Extracted from runAlignmentCheck, which measured 63 lines against a 50-line
|
|
151
|
+
* rule. The flags are one independent question; the injection guard and the
|
|
152
|
+
* loader dance are two more.
|
|
153
|
+
*
|
|
154
|
+
* @param {string[]} subargs
|
|
155
|
+
* @returns {{specPath: string, testDirs: string[]|undefined, outputPath: string|undefined, jsonMode: boolean}}
|
|
156
|
+
*/
|
|
157
|
+
function parseAlignmentArgs(subargs) {
|
|
158
|
+
const pick = (flag) => {
|
|
159
|
+
const i = subargs.indexOf(flag);
|
|
160
|
+
return i >= 0 ? subargs[i + 1] : undefined;
|
|
161
|
+
};
|
|
162
|
+
const testsValue = pick('--tests');
|
|
163
|
+
return {
|
|
164
|
+
specPath: pick('--spec') ?? path.join(process.cwd(), 'specification.yaml'),
|
|
165
|
+
testDirs: testsValue === undefined ? undefined : [testsValue],
|
|
166
|
+
outputPath: pick('--output'),
|
|
167
|
+
jsonMode: subargs.includes('--json'),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
158
170
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Refuse a path containing a shell metacharacter (#392-#6 / Delphi R1 MJ-02).
|
|
173
|
+
*
|
|
174
|
+
* Runs BEFORE any launcher, including the in-process fast path, so both
|
|
175
|
+
* platforms refuse identically. Behavioural, not shape-only.
|
|
176
|
+
*
|
|
177
|
+
* @param {{specPath: string, testDirs?: string[], outputPath?: string}} args
|
|
178
|
+
* @returns {1|null} exit code when refused
|
|
179
|
+
*/
|
|
180
|
+
function refuseUnsafeAlignmentPath({ specPath, testDirs, outputPath }) {
|
|
181
|
+
for (const value of [specPath, ...(testDirs || []), outputPath].filter((v) => v !== undefined)) {
|
|
163
182
|
const unsafe = firstUnsafeArg([value]);
|
|
164
183
|
if (unsafe) {
|
|
165
184
|
console.error(`check-alignment: refusing path containing a shell metacharacter: ${unsafe}`);
|
|
166
185
|
return 1;
|
|
167
186
|
}
|
|
168
187
|
}
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function runAlignmentCheck(subargs) {
|
|
192
|
+
const args = parseAlignmentArgs(subargs);
|
|
193
|
+
const refused = refuseUnsafeAlignmentPath(args);
|
|
194
|
+
if (refused !== null) return refused;
|
|
169
195
|
|
|
170
196
|
const runnerPath = path.join(__dirname, '..', 'lib', 'check-alignment-runner.cjs');
|
|
171
197
|
|
|
172
|
-
// #894: the runner is referenced by PATH, so a packaging mistake
|
|
173
|
-
// command into a bare ERR_MODULE_NOT_FOUND stack trace
|
|
174
|
-
//
|
|
175
|
-
// same voice as the others: what is missing, and what the operator can do about
|
|
176
|
-
// it. "Cannot find module" from inside a tsx loader names neither.
|
|
198
|
+
// #894: the runner is referenced by PATH, so a packaging mistake turned this
|
|
199
|
+
// command into a bare ERR_MODULE_NOT_FOUND stack trace, shipped in every
|
|
200
|
+
// version before 0.41.10. A gate that cannot start must say what is missing.
|
|
177
201
|
if (!require('node:fs').existsSync(runnerPath)) {
|
|
178
202
|
console.error('❌ BLOCKED - check-alignment: the alignment runner is missing from this install.');
|
|
179
203
|
console.error(` Expected: ${runnerPath}`);
|
|
@@ -182,19 +206,13 @@ async function runAlignmentCheck(subargs) {
|
|
|
182
206
|
return 1;
|
|
183
207
|
}
|
|
184
208
|
|
|
185
|
-
// Primary: run the engine in-process via tsx/cjs (fast path, works in-repo
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
// ships zero runtime deps per the zero-install contract). npx self-provisions
|
|
189
|
-
// tsx on demand, so the published command stays functional without adding a dep.
|
|
209
|
+
// Primary: run the engine in-process via tsx/cjs (fast path, works in-repo).
|
|
210
|
+
// Fall back to `npx -y tsx` when tsx is not resolvable, which is the published
|
|
211
|
+
// global install (the package ships zero runtime deps).
|
|
190
212
|
//
|
|
191
|
-
// The try guards ONLY the
|
|
192
|
-
//
|
|
193
|
-
//
|
|
194
|
-
// Delphi walkthrough R2 CI-02: require('../lib/test-alignment.ts') also needs
|
|
195
|
-
// the loader, so it belongs INSIDE the guard — if the .ts file itself cannot
|
|
196
|
-
// load, the npx fallback re-attempts it under a provisioned tsx instead of
|
|
197
|
-
// crashing with an unhandled exception. Engine EXECUTION stays outside.
|
|
213
|
+
// The try guards ONLY the module-LOAD step. The engine call sits outside it: an
|
|
214
|
+
// engine-level failure is a real bug that must surface, not be misattributed to
|
|
215
|
+
// "tsx unavailable" (Delphi R2 CI-02).
|
|
198
216
|
let runFullAlignment;
|
|
199
217
|
try {
|
|
200
218
|
require('tsx/cjs');
|
|
@@ -203,9 +221,9 @@ async function runAlignmentCheck(subargs) {
|
|
|
203
221
|
if (!err || (err.code !== 'MODULE_NOT_FOUND' && !/Cannot find module/.test(String(err && err.message)))) {
|
|
204
222
|
throw err;
|
|
205
223
|
}
|
|
206
|
-
return runAlignmentViaNpx(runnerPath, specPath, testDirs, outputPath, jsonMode);
|
|
224
|
+
return runAlignmentViaNpx(runnerPath, args.specPath, args.testDirs, args.outputPath, args.jsonMode);
|
|
207
225
|
}
|
|
208
|
-
return runAlignmentInProcess(specPath, testDirs, outputPath, jsonMode, runFullAlignment);
|
|
226
|
+
return runAlignmentInProcess(args.specPath, args.testDirs, args.outputPath, args.jsonMode, runFullAlignment);
|
|
209
227
|
}
|
|
210
228
|
|
|
211
229
|
const COMMANDS = {
|
package/lib/test-alignment.ts
CHANGED
|
@@ -798,144 +798,14 @@ export function parseTestFiles(testPaths: string[]): TestMap {
|
|
|
798
798
|
|
|
799
799
|
for (const testPath of testPaths) {
|
|
800
800
|
if (!fs.existsSync(testPath)) continue;
|
|
801
|
-
|
|
802
801
|
// Normalise CRLF before parsing. This repo checks out with `core.autocrlf`
|
|
803
802
|
// on Windows, so a `.bats` header ends its lines with `\r\n`; the `#`-block
|
|
804
803
|
// matcher then stopped after the shebang and every such file parsed as
|
|
805
804
|
// unannotated. Line-oriented regexes must see one line ending, not two.
|
|
806
805
|
const content = fs.readFileSync(testPath, 'utf8').replace(/\r\n/g, '\n');
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
// repo's own script tests (44 and 2 files). They were in neither the
|
|
811
|
-
// supported nor the unsupported list, so those files were dropped without a
|
|
812
|
-
// trace -- a test file the checker cannot see is indistinguishable from a
|
|
813
|
-
// test that does not exist.
|
|
814
|
-
const isJSLike = ['.ts', '.tsx', '.js', '.jsx', '.cjs', '.mjs'].includes(ext);
|
|
815
|
-
if (isJSLike) {
|
|
816
|
-
const matches = extractJSDocBeforeTest(content, testPath);
|
|
817
|
-
|
|
818
|
-
for (const m of matches) {
|
|
819
|
-
// Five files in this repo fold the rationale into the `@test` line as
|
|
820
|
-
// `@test REQ-X intent: ...` instead of using a separate `@intent` tag.
|
|
821
|
-
// Without this fallback they were reported as having no intent at all.
|
|
822
|
-
const inlineIntent = m.jsdoc.match(/@test[^\n]*?\bintent:\s*([^\n]*(?:\n[ \t]*[^\n*@][^\n]*)*)/);
|
|
823
|
-
const intentValue = extractAllTags(m.jsdoc, 'intent').join(' ').trim()
|
|
824
|
-
|| (inlineIntent ? inlineIntent[1]!.replace(/\s*\n\s*/g, ' ').trim() : '');
|
|
825
|
-
const coversRaw = extractAllTags(m.jsdoc, 'covers');
|
|
826
|
-
const covers = expandAcCovers(coversRaw);
|
|
827
|
-
|
|
828
|
-
// A block may name several requirements (`@test REQ-705, REQ-707`).
|
|
829
|
-
// Taking only the first left every other REQ in the list looking
|
|
830
|
-
// untested even though the same code was covered by the same tests.
|
|
831
|
-
const reqIds = Array.from(
|
|
832
|
-
new Set((m.jsdoc.match(/@test\s+([^\n*]+)/)?.[1] || '').match(/REQ-[A-Z0-9]+(?:-[A-Z0-9]+)*/g) || []),
|
|
833
|
-
);
|
|
834
|
-
|
|
835
|
-
const assertions = countAssertions(m.testBody);
|
|
836
|
-
totalAssertionsObj.value += assertions;
|
|
837
|
-
|
|
838
|
-
for (const reqId of reqIds.length ? reqIds : [undefined]) {
|
|
839
|
-
tests.push({
|
|
840
|
-
name: m.testName,
|
|
841
|
-
file: testPath,
|
|
842
|
-
requirementId: reqId,
|
|
843
|
-
intent: intentValue || undefined,
|
|
844
|
-
covers,
|
|
845
|
-
edgeCases: [],
|
|
846
|
-
assertions,
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
} else if (ext === '.py') {
|
|
851
|
-
const pyTestPattern = /(# @test\s+(REQ-[A-Z0-9]+(?:-[A-Z0-9]+)*)[\s\S]*?)(?:# @intent\s+(.+?)\n)?def\s+(test_\w+)/g;
|
|
852
|
-
let m: RegExpExecArray | null;
|
|
853
|
-
while ((m = pyTestPattern.exec(content)) !== null) {
|
|
854
|
-
const body = extractPythonTestBody(content, m.index + m[0].lastIndexOf('def '));
|
|
855
|
-
pushTestWithCovers(tests, testPath, m[4]!, m[2]!, m[3]?.trim(), content, body, totalAssertionsObj);
|
|
856
|
-
}
|
|
857
|
-
} else if (ext === '.go') {
|
|
858
|
-
const goTestPattern = /(\/\/ @test\s+(REQ-[A-Z0-9]+(?:-[A-Z0-9]+)*))\s*[\s\S]*?func\s+(Test_\w+)/g;
|
|
859
|
-
let m: RegExpExecArray | null;
|
|
860
|
-
while ((m = goTestPattern.exec(content)) !== null) {
|
|
861
|
-
const block = content.slice(Math.max(0, m.index - 500), m.index);
|
|
862
|
-
const intentMatch = block.match(/\/\/ @intent\s+(.+)/);
|
|
863
|
-
const funcStart = m.index + m[0].lastIndexOf('func ');
|
|
864
|
-
const body = extractGoTestBody(content, funcStart);
|
|
865
|
-
pushTestWithCovers(tests, testPath, m[3]!, m[2]!, intentMatch?.[1]?.trim(), content, body, totalAssertionsObj);
|
|
866
|
-
}
|
|
867
|
-
} else if (ext === '.java') {
|
|
868
|
-
// #702: JUnit 5 annotations are matched against the Javadoc block that
|
|
869
|
-
// precedes the method, because that is where this project's @test/@intent
|
|
870
|
-
// contract lives.
|
|
871
|
-
//
|
|
872
|
-
// Two phases rather than one regex, because the Javadoc may sit above the
|
|
873
|
-
// class declaration (`class Foo { @Test void a() {...} }`) or directly
|
|
874
|
-
// above the method. Scanning forward from the end of each Javadoc for the
|
|
875
|
-
// first `@Test` and then for the method name handles both without the
|
|
876
|
-
// fragile "skip N tokens" shape that a single expression needs.
|
|
877
|
-
const javaDocPattern = /\/\*\*([\s\S]*?)\*\//g;
|
|
878
|
-
let docMatch: RegExpExecArray | null;
|
|
879
|
-
while ((docMatch = javaDocPattern.exec(content)) !== null) {
|
|
880
|
-
const docBlock = docMatch[1]!;
|
|
881
|
-
const reqMatch = docBlock.match(/@test\s+(REQ-[A-Z0-9]+(?:-[A-Z0-9]+)*)/);
|
|
882
|
-
// Without a requirement tag this is not an annotated test in this
|
|
883
|
-
// project's sense; skip it rather than inventing a TestCase.
|
|
884
|
-
if (!reqMatch) continue;
|
|
885
|
-
|
|
886
|
-
const afterDoc = docMatch.index + docMatch[0].length;
|
|
887
|
-
const rest = content.slice(afterDoc);
|
|
888
|
-
const testAnnotation = rest.match(/@Test\b/);
|
|
889
|
-
if (!testAnnotation) continue;
|
|
890
|
-
|
|
891
|
-
// Method name = the identifier right before the first `(` after @Test.
|
|
892
|
-
const afterAnnotation = rest.slice(testAnnotation.index! + '@Test'.length);
|
|
893
|
-
const nameMatch = afterAnnotation.match(/\b(\w+)\s*\(/);
|
|
894
|
-
if (!nameMatch) continue;
|
|
895
|
-
|
|
896
|
-
const intentMatch = docBlock.match(/@intent\s+(.+)/);
|
|
897
|
-
const methodStart = afterDoc + testAnnotation.index! + afterAnnotation.indexOf(nameMatch[1]!);
|
|
898
|
-
const body = extractJavaTestBody(content, methodStart);
|
|
899
|
-
pushTestWithCovers(
|
|
900
|
-
tests, testPath, nameMatch[1]!, reqMatch[1]!, intentMatch?.[1]?.trim(),
|
|
901
|
-
content, body, totalAssertionsObj,
|
|
902
|
-
);
|
|
903
|
-
}
|
|
904
|
-
} else if (ext === '.bats' || ext === '.sh') {
|
|
905
|
-
// BATS bodies are shell; the annotation contract is the same `# @test` /
|
|
906
|
-
// `# @intent` / `# @covers` header used everywhere else in this repo.
|
|
907
|
-
const batsDoc = extractFileLevelJsdoc(content);
|
|
908
|
-
if (batsDoc) {
|
|
909
|
-
const header = batsDoc;
|
|
910
|
-
const reqMatch = header.match(/@test\s+(REQ-[A-Z0-9]+(?:-[A-Z0-9]+)*)/);
|
|
911
|
-
const intentMatch = header.match(/@intent\s+([\s\S]*?)(?=\n[ \t]*#?[ \t]*@|$)/);
|
|
912
|
-
// Same inline form as the JS branch: `# @test REQ-X intent: ...`.
|
|
913
|
-
const inlineIntent = header.match(/@test[^\n]*?\bintent:\s*([\s\S]*?)(?=\n[ \t]*#?[ \t]*@|\n[ \t]*#\s*$|$)/);
|
|
914
|
-
const intentValue = (intentMatch ? intentMatch[1]!.replace(/\n[ \t]*#?/g, ' ').trim() : '')
|
|
915
|
-
|| (inlineIntent ? inlineIntent[1]!.replace(/\n[ \t]*#?/g, ' ').trim() : '');
|
|
916
|
-
const coversRaw = extractAllTags(header, 'covers');
|
|
917
|
-
|
|
918
|
-
if (reqMatch) {
|
|
919
|
-
const covers = expandAcCovers(coversRaw);
|
|
920
|
-
const assertions = countBashAssertions(content);
|
|
921
|
-
totalAssertionsObj.value += assertions;
|
|
922
|
-
tests.push({
|
|
923
|
-
name: testPath,
|
|
924
|
-
file: testPath,
|
|
925
|
-
requirementId: reqMatch[1],
|
|
926
|
-
intent: intentValue || undefined,
|
|
927
|
-
covers,
|
|
928
|
-
edgeCases: [],
|
|
929
|
-
assertions,
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
} else if (UNSUPPORTED_TEST_EXTENSIONS.includes(ext)) {
|
|
934
|
-
// Recognised as a test file, but no parser exists. Recording it is the
|
|
935
|
-
// whole point: previously this arm did not exist, so the file vanished
|
|
936
|
-
// and the caller could not tell "no tests" from "tests I could not read".
|
|
937
|
-
unsupportedFiles.push(testPath);
|
|
938
|
-
}
|
|
806
|
+
const parsed = parseOneTestFile(testPath, content, totalAssertionsObj);
|
|
807
|
+
if (parsed.unsupported) unsupportedFiles.push(testPath);
|
|
808
|
+
tests.push(...parsed.tests);
|
|
939
809
|
}
|
|
940
810
|
|
|
941
811
|
return {
|
|
@@ -946,6 +816,168 @@ export function parseTestFiles(testPaths: string[]): TestMap {
|
|
|
946
816
|
};
|
|
947
817
|
}
|
|
948
818
|
|
|
819
|
+
/**
|
|
820
|
+
* Parse one test file, dispatching on its extension.
|
|
821
|
+
*
|
|
822
|
+
* Split out of `parseTestFiles`, which measured 154 lines with 8 levels of
|
|
823
|
+
* nesting against a 50-line / 4-level rule. Each extension is a self-contained
|
|
824
|
+
* grammar with its own comment syntax; keeping them as sibling functions makes
|
|
825
|
+
* that visible while the shared contract (annotation tags, assertion counting)
|
|
826
|
+
* stays in one place.
|
|
827
|
+
*
|
|
828
|
+
* @returns the parsed cases, and whether the file was recognised-but-unparsed
|
|
829
|
+
*/
|
|
830
|
+
function parseOneTestFile(
|
|
831
|
+
testPath: string,
|
|
832
|
+
content: string,
|
|
833
|
+
totalAssertionsObj: { value: number },
|
|
834
|
+
): { tests: TestCase[]; unsupported: boolean } {
|
|
835
|
+
const ext = path.extname(testPath);
|
|
836
|
+
// `.cjs` / `.mjs` carry the same syntax as `.js` and are used by this repo's
|
|
837
|
+
// own script tests. They were in neither the supported nor the unsupported
|
|
838
|
+
// list, so those files were dropped without a trace -- a test file the checker
|
|
839
|
+
// cannot see is indistinguishable from a test that does not exist.
|
|
840
|
+
if (['.ts', '.tsx', '.js', '.jsx', '.cjs', '.mjs'].includes(ext)) {
|
|
841
|
+
return { tests: parseJsLikeTests(testPath, content, totalAssertionsObj), unsupported: false };
|
|
842
|
+
}
|
|
843
|
+
if (ext === '.py') return { tests: parsePythonTests(testPath, content, totalAssertionsObj), unsupported: false };
|
|
844
|
+
if (ext === '.go') return { tests: parseGoTests(testPath, content, totalAssertionsObj), unsupported: false };
|
|
845
|
+
if (ext === '.java') return { tests: parseJavaTests(testPath, content, totalAssertionsObj), unsupported: false };
|
|
846
|
+
if (ext === '.bats' || ext === '.sh') {
|
|
847
|
+
return { tests: parseBatsTests(testPath, content, totalAssertionsObj), unsupported: false };
|
|
848
|
+
}
|
|
849
|
+
// Recognised as a test file, but no parser exists. Recording it is the whole
|
|
850
|
+
// point: previously this arm did not exist, so the file vanished and the
|
|
851
|
+
// caller could not tell "no tests" from "tests I could not read".
|
|
852
|
+
return { tests: [], unsupported: UNSUPPORTED_TEST_EXTENSIONS.includes(ext) };
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/** JSDoc-headed tests in any JS-like source (.ts/.tsx/.js/.jsx/.cjs/.mjs). */
|
|
856
|
+
function parseJsLikeTests(
|
|
857
|
+
testPath: string,
|
|
858
|
+
content: string,
|
|
859
|
+
totalAssertionsObj: { value: number },
|
|
860
|
+
): TestCase[] {
|
|
861
|
+
const out: TestCase[] = [];
|
|
862
|
+
for (const m of extractJSDocBeforeTest(content, testPath)) {
|
|
863
|
+
// Five files in this repo fold the rationale into the `@test` line as
|
|
864
|
+
// `@test REQ-X intent: ...` instead of using a separate `@intent` tag.
|
|
865
|
+
// Without this fallback they were reported as having no intent at all.
|
|
866
|
+
const inlineIntent = m.jsdoc.match(/@test[^\n]*?\bintent:\s*([^\n]*(?:\n[ \t]*[^\n*@][^\n]*)*)/);
|
|
867
|
+
const intentValue = extractAllTags(m.jsdoc, 'intent').join(' ').trim()
|
|
868
|
+
|| (inlineIntent ? inlineIntent[1]!.replace(/\s*\n\s*/g, ' ').trim() : '');
|
|
869
|
+
const covers = expandAcCovers(extractAllTags(m.jsdoc, 'covers'));
|
|
870
|
+
// A block may name several requirements (`@test REQ-705, REQ-707`).
|
|
871
|
+
// Taking only the first left every other REQ in the list looking untested
|
|
872
|
+
// even though the same code was covered by the same tests.
|
|
873
|
+
const reqIds = Array.from(
|
|
874
|
+
new Set((m.jsdoc.match(/@test\s+([^\n*]+)/)?.[1] || '').match(/REQ-[A-Z0-9]+(?:-[A-Z0-9]+)*/g) || []),
|
|
875
|
+
);
|
|
876
|
+
const assertions = countAssertions(m.testBody);
|
|
877
|
+
totalAssertionsObj.value += assertions;
|
|
878
|
+
for (const reqId of reqIds.length ? reqIds : [undefined]) {
|
|
879
|
+
out.push({
|
|
880
|
+
name: m.testName,
|
|
881
|
+
file: testPath,
|
|
882
|
+
requirementId: reqId,
|
|
883
|
+
intent: intentValue || undefined,
|
|
884
|
+
covers,
|
|
885
|
+
edgeCases: [],
|
|
886
|
+
assertions,
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return out;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** `# @test` headers on `def test_*` functions. */
|
|
894
|
+
function parsePythonTests(testPath: string, content: string, totalAssertionsObj: { value: number }): TestCase[] {
|
|
895
|
+
const out: TestCase[] = [];
|
|
896
|
+
const pattern = /(# @test\s+(REQ-[A-Z0-9]+(?:-[A-Z0-9]+)*)[\s\S]*?)(?:# @intent\s+(.+?)\n)?def\s+(test_\w+)/g;
|
|
897
|
+
let m: RegExpExecArray | null;
|
|
898
|
+
while ((m = pattern.exec(content)) !== null) {
|
|
899
|
+
const body = extractPythonTestBody(content, m.index + m[0].lastIndexOf('def '));
|
|
900
|
+
pushTestWithCovers(out, testPath, m[4]!, m[2]!, m[3]?.trim(), content, body, totalAssertionsObj);
|
|
901
|
+
}
|
|
902
|
+
return out;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/** `// @test` comments above `func Test_*`. */
|
|
906
|
+
function parseGoTests(testPath: string, content: string, totalAssertionsObj: { value: number }): TestCase[] {
|
|
907
|
+
const out: TestCase[] = [];
|
|
908
|
+
const pattern = /(\/\/ @test\s+(REQ-[A-Z0-9]+(?:-[A-Z0-9]+)*))\s*[\s\S]*?func\s+(Test_\w+)/g;
|
|
909
|
+
let m: RegExpExecArray | null;
|
|
910
|
+
while ((m = pattern.exec(content)) !== null) {
|
|
911
|
+
const block = content.slice(Math.max(0, m.index - 500), m.index);
|
|
912
|
+
const intentMatch = block.match(/\/\/ @intent\s+(.+)/);
|
|
913
|
+
const funcStart = m.index + m[0].lastIndexOf('func ');
|
|
914
|
+
const body = extractGoTestBody(content, funcStart);
|
|
915
|
+
pushTestWithCovers(out, testPath, m[3]!, m[2]!, intentMatch?.[1]?.trim(), content, body, totalAssertionsObj);
|
|
916
|
+
}
|
|
917
|
+
return out;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* JUnit 5 methods headed by a Javadoc carrying `@test` (#702).
|
|
922
|
+
*
|
|
923
|
+
* Two phases rather than one regex, because the Javadoc may sit above the class
|
|
924
|
+
* declaration or directly above the method. Scanning forward from the end of
|
|
925
|
+
* each Javadoc for the first `@Test` and then for the method name handles both
|
|
926
|
+
* without the fragile "skip N tokens" shape a single expression needs.
|
|
927
|
+
*/
|
|
928
|
+
function parseJavaTests(testPath: string, content: string, totalAssertionsObj: { value: number }): TestCase[] {
|
|
929
|
+
const out: TestCase[] = [];
|
|
930
|
+
const docPattern = /\/\*\*([\s\S]*?)\*\//g;
|
|
931
|
+
let docMatch: RegExpExecArray | null;
|
|
932
|
+
while ((docMatch = docPattern.exec(content)) !== null) {
|
|
933
|
+
const docBlock = docMatch[1]!;
|
|
934
|
+
const reqMatch = docBlock.match(/@test\s+(REQ-[A-Z0-9]+(?:-[A-Z0-9]+)*)/);
|
|
935
|
+
// Without a requirement tag this is not an annotated test in this project's
|
|
936
|
+
// sense; skip it rather than inventing a TestCase.
|
|
937
|
+
if (!reqMatch) continue;
|
|
938
|
+
const afterDoc = docMatch.index + docMatch[0].length;
|
|
939
|
+
const rest = content.slice(afterDoc);
|
|
940
|
+
const testAnnotation = rest.match(/@Test\b/);
|
|
941
|
+
if (!testAnnotation) continue;
|
|
942
|
+
const afterAnnotation = rest.slice(testAnnotation.index! + '@Test'.length);
|
|
943
|
+
const nameMatch = afterAnnotation.match(/\b(\w+)\s*\(/);
|
|
944
|
+
if (!nameMatch) continue;
|
|
945
|
+
const intentMatch = docBlock.match(/@intent\s+(.+)/);
|
|
946
|
+
const methodStart = afterDoc + testAnnotation.index! + afterAnnotation.indexOf(nameMatch[1]!);
|
|
947
|
+
const body = extractJavaTestBody(content, methodStart);
|
|
948
|
+
pushTestWithCovers(
|
|
949
|
+
out, testPath, nameMatch[1]!, reqMatch[1]!, intentMatch?.[1]?.trim(),
|
|
950
|
+
content, body, totalAssertionsObj,
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
return out;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/** File-level `# @test` header used by BATS and shell suites. */
|
|
957
|
+
function parseBatsTests(testPath: string, content: string, totalAssertionsObj: { value: number }): TestCase[] {
|
|
958
|
+
const header = extractFileLevelJsdoc(content);
|
|
959
|
+
if (!header) return [];
|
|
960
|
+
const reqMatch = header.match(/@test\s+(REQ-[A-Z0-9]+(?:-[A-Z0-9]+)*)/);
|
|
961
|
+
if (!reqMatch) return [];
|
|
962
|
+
const intentMatch = header.match(/@intent\s+([\s\S]*?)(?=\n[ \t]*#?[ \t]*@|$)/);
|
|
963
|
+
// Same inline form as the JS branch: `# @test REQ-X intent: ...`.
|
|
964
|
+
const inlineIntent = header.match(/@test[^\n]*?\bintent:\s*([\s\S]*?)(?=\n[ \t]*#?[ \t]*@|\n[ \t]*#\s*$|$)/);
|
|
965
|
+
const intentValue = (intentMatch ? intentMatch[1]!.replace(/\n[ \t]*#?/g, ' ').trim() : '')
|
|
966
|
+
|| (inlineIntent ? inlineIntent[1]!.replace(/\n[ \t]*#?/g, ' ').trim() : '');
|
|
967
|
+
const covers = expandAcCovers(extractAllTags(header, 'covers'));
|
|
968
|
+
const assertions = countBashAssertions(content);
|
|
969
|
+
totalAssertionsObj.value += assertions;
|
|
970
|
+
return [{
|
|
971
|
+
name: testPath,
|
|
972
|
+
file: testPath,
|
|
973
|
+
requirementId: reqMatch[1],
|
|
974
|
+
intent: intentValue || undefined,
|
|
975
|
+
covers,
|
|
976
|
+
edgeCases: [],
|
|
977
|
+
assertions,
|
|
978
|
+
}];
|
|
979
|
+
}
|
|
980
|
+
|
|
949
981
|
// ============================================================================
|
|
950
982
|
// Step 3: verifyAlignment()
|
|
951
983
|
// ============================================================================
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boyingliu01/xp-gate",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.69",
|
|
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"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xp-gate",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.69",
|
|
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.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
|
package/plugins/dsh/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boyingliu01/dsh-plugin-xp-gate",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.69",
|
|
4
4
|
"description": "XP-Gate deterministic quality gates + AI workflow skills as a DeepSeek Harness (DSH) native plugin: gate-check / gate-principles / gate-arch tools + 12 SKILL.md skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -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.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xp-gate",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.69",
|
|
4
4
|
"displayName": "XP-Gate",
|
|
5
5
|
"description": "Extreme Programming quality gates + AI workflow skills for Qoder. 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.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.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.41.
|
|
6
|
+
**Version:** 0.41.69.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
|