@boyingliu01/xp-gate 0.8.8 → 0.8.10

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.
Files changed (141) hide show
  1. package/bin/xp-gate.js +18 -0
  2. package/hooks/pre-commit +565 -120
  3. package/lib/arch.js +49 -0
  4. package/lib/check.js +50 -0
  5. package/lib/init.js +36 -0
  6. package/lib/principles.js +48 -0
  7. package/mock-policy/AGENTS.md +94 -0
  8. package/mock-policy/__tests__/config.test.ts +292 -0
  9. package/mock-policy/__tests__/integration.test.ts +600 -0
  10. package/mock-policy/__tests__/mock-decision-engine.test.ts +231 -0
  11. package/mock-policy/__tests__/scope-scanner.test.ts +535 -0
  12. package/mock-policy/config.ts +106 -0
  13. package/mock-policy/gate-m3.ts +233 -0
  14. package/mock-policy/mock-decision-engine.ts +155 -0
  15. package/mock-policy/schema.ts +22 -0
  16. package/mock-policy/scope-scanner.ts +288 -0
  17. package/mock-policy/types.ts +65 -0
  18. package/mutation/AGENTS.md +73 -0
  19. package/mutation/__tests__/detect-ai-test.test.ts +152 -0
  20. package/mutation/__tests__/gate-m.test.ts +194 -0
  21. package/mutation/detect-ai-test.ts +128 -0
  22. package/mutation/gate-m.ts +619 -0
  23. package/mutation/init-baseline.ts +192 -0
  24. package/mutation/stryker-types.ts +14 -0
  25. package/mutation/types.ts +70 -0
  26. package/mutation/update-baseline.ts +160 -0
  27. package/package.json +5 -2
  28. package/plugins/claude-code/.claude-plugin/plugin.json +2 -2
  29. package/plugins/claude-code/skills/delphi-review/AGENTS.md +7 -7
  30. package/plugins/claude-code/skills/delphi-review/INSTALL.md +1 -1
  31. package/plugins/claude-code/skills/delphi-review/SKILL.md +12 -12
  32. package/plugins/claude-code/skills/delphi-review/references/code-walkthrough.md +1 -1
  33. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +83 -36
  34. package/plugins/claude-code/skills/sprint-flow/SKILL.md +1 -1
  35. package/plugins/claude-code/skills/sprint-flow/references/force-levels.md +1 -1
  36. package/plugins/claude-code/skills/sprint-flow/references/phase-3-review.md +2 -2
  37. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  38. package/plugins/opencode/README.md +23 -7
  39. package/plugins/opencode/index.ts +36 -21
  40. package/plugins/opencode/package.json +1 -1
  41. package/plugins/opencode/skills/delphi-review/AGENTS.md +7 -7
  42. package/plugins/opencode/skills/delphi-review/INSTALL.md +1 -1
  43. package/plugins/opencode/skills/delphi-review/SKILL.md +12 -12
  44. package/plugins/opencode/skills/delphi-review/references/code-walkthrough.md +1 -1
  45. package/plugins/opencode/skills/sprint-flow/AGENTS.md +83 -36
  46. package/plugins/opencode/skills/sprint-flow/SKILL.md +1 -1
  47. package/plugins/opencode/skills/sprint-flow/references/force-levels.md +1 -1
  48. package/plugins/opencode/skills/sprint-flow/references/phase-3-review.md +2 -2
  49. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  50. package/plugins/qoder/plugin.json +20 -0
  51. package/plugins/qoder/skills/delphi-review/AGENTS.md +7 -7
  52. package/plugins/qoder/skills/delphi-review/INSTALL.md +1 -1
  53. package/plugins/qoder/skills/delphi-review/SKILL.md +12 -12
  54. package/plugins/qoder/skills/delphi-review/references/code-walkthrough.md +1 -1
  55. package/plugins/qoder/skills/sprint-flow/AGENTS.md +83 -36
  56. package/plugins/qoder/skills/sprint-flow/SKILL.md +51 -1
  57. package/plugins/qoder/skills/sprint-flow/references/force-levels.md +1 -1
  58. package/plugins/qoder/skills/sprint-flow/references/phase-3-review.md +2 -2
  59. package/plugins/qoder/skills/test-driven-development/SKILL.md +371 -0
  60. package/plugins/qoder/skills/test-driven-development/testing-anti-patterns.md +299 -0
  61. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  62. package/principles/AGENTS.md +111 -0
  63. package/principles/__tests__/analyzer.test.ts +343 -0
  64. package/principles/__tests__/baseline-storage.test.ts +187 -0
  65. package/principles/__tests__/baseline.test.ts +328 -0
  66. package/principles/__tests__/boy-scout-integration.test.ts +264 -0
  67. package/principles/__tests__/boy-scout.test.ts +646 -0
  68. package/principles/__tests__/config.test.ts +78 -0
  69. package/principles/__tests__/index.test.ts +81 -0
  70. package/principles/__tests__/lint-baseline.test.ts +314 -0
  71. package/principles/__tests__/reporter.test.ts +832 -0
  72. package/principles/__tests__/types.test.ts +101 -0
  73. package/principles/adapters/__tests__/base.test.ts +95 -0
  74. package/principles/adapters/__tests__/cpp.test.ts +290 -0
  75. package/principles/adapters/__tests__/dart.test.ts +84 -0
  76. package/principles/adapters/__tests__/go.test.ts +68 -0
  77. package/principles/adapters/__tests__/java.test.ts +68 -0
  78. package/principles/adapters/__tests__/kotlin.test.ts +76 -0
  79. package/principles/adapters/__tests__/objectivec.test.ts +453 -0
  80. package/principles/adapters/__tests__/python.test.ts +84 -0
  81. package/principles/adapters/__tests__/swift.test.ts +68 -0
  82. package/principles/adapters/__tests__/typescript.test.ts +116 -0
  83. package/principles/adapters/base.ts +124 -0
  84. package/principles/adapters/cpp.ts +115 -0
  85. package/principles/adapters/dart.ts +44 -0
  86. package/principles/adapters/go.ts +55 -0
  87. package/principles/adapters/java.ts +56 -0
  88. package/principles/adapters/kotlin.ts +54 -0
  89. package/principles/adapters/objectivec.ts +82 -0
  90. package/principles/adapters/python.ts +83 -0
  91. package/principles/adapters/swift.ts +40 -0
  92. package/principles/adapters/typescript.ts +66 -0
  93. package/principles/analyzer.ts +190 -0
  94. package/principles/baseline.ts +273 -0
  95. package/principles/boy-scout.ts +416 -0
  96. package/principles/config.ts +118 -0
  97. package/principles/index.ts +87 -0
  98. package/principles/lint-baseline.ts +385 -0
  99. package/principles/reporter.ts +188 -0
  100. package/principles/rules/__tests__/clean-code/code-duplication.test.ts +84 -0
  101. package/principles/rules/__tests__/clean-code/deep-nesting.test.ts +74 -0
  102. package/principles/rules/__tests__/clean-code/god-class.test.ts +111 -0
  103. package/principles/rules/__tests__/clean-code/large-file.test.ts +73 -0
  104. package/principles/rules/__tests__/clean-code/long-function.test.ts +83 -0
  105. package/principles/rules/__tests__/clean-code/magic-numbers.test.ts +68 -0
  106. package/principles/rules/__tests__/clean-code/many-exports.test.ts +118 -0
  107. package/principles/rules/__tests__/clean-code/missing-error-handling.test.ts +173 -0
  108. package/principles/rules/__tests__/clean-code/too-many-params.test.ts +60 -0
  109. package/principles/rules/__tests__/clean-code/unused-imports.test.ts +107 -0
  110. package/principles/rules/__tests__/index.test.ts +49 -0
  111. package/principles/rules/__tests__/solid/dip.test.ts +121 -0
  112. package/principles/rules/__tests__/solid/isp.test.ts +60 -0
  113. package/principles/rules/__tests__/solid/lsp.test.ts +184 -0
  114. package/principles/rules/__tests__/solid/ocp.test.ts +69 -0
  115. package/principles/rules/__tests__/solid/srp.test.ts +89 -0
  116. package/principles/rules/clean-code/code-duplication.ts +31 -0
  117. package/principles/rules/clean-code/deep-nesting.ts +38 -0
  118. package/principles/rules/clean-code/god-class.ts +54 -0
  119. package/principles/rules/clean-code/large-file.ts +34 -0
  120. package/principles/rules/clean-code/long-function.ts +47 -0
  121. package/principles/rules/clean-code/magic-numbers.ts +59 -0
  122. package/principles/rules/clean-code/many-exports.ts +40 -0
  123. package/principles/rules/clean-code/missing-error-handling.ts +33 -0
  124. package/principles/rules/clean-code/too-many-params.ts +35 -0
  125. package/principles/rules/clean-code/unused-imports.ts +33 -0
  126. package/principles/rules/index.ts +61 -0
  127. package/principles/rules/solid/dip.ts +47 -0
  128. package/principles/rules/solid/isp.ts +37 -0
  129. package/principles/rules/solid/lsp.ts +79 -0
  130. package/principles/rules/solid/ocp.ts +40 -0
  131. package/principles/rules/solid/srp.ts +44 -0
  132. package/principles/types.ts +27 -0
  133. package/skills/delphi-review/AGENTS.md +7 -7
  134. package/skills/delphi-review/INSTALL.md +1 -1
  135. package/skills/delphi-review/SKILL.md +12 -12
  136. package/skills/delphi-review/references/code-walkthrough.md +1 -1
  137. package/skills/sprint-flow/AGENTS.md +83 -36
  138. package/skills/sprint-flow/SKILL.md +1 -1
  139. package/skills/sprint-flow/references/force-levels.md +1 -1
  140. package/skills/sprint-flow/references/phase-3-review.md +2 -2
  141. package/skills/test-specification-alignment/AGENTS.md +3 -3
@@ -0,0 +1,192 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { exec } from 'child_process';
4
+ import { promisify } from 'util';
5
+
6
+ const execAsync = promisify(exec);
7
+
8
+ interface MutantStatus {
9
+ id: string;
10
+ mutatorName: string;
11
+ replacement: string;
12
+ location: {
13
+ start: { line: number; column: number };
14
+ end: { line: number; column: number };
15
+ };
16
+ status: string;
17
+ }
18
+
19
+ interface StrykerFileReport {
20
+ source: string;
21
+ mutants: MutantStatus[];
22
+ }
23
+
24
+ interface StrykerReport {
25
+ schemaVersion: string;
26
+ thresholds: {
27
+ high: number;
28
+ low: number;
29
+ break: number | null;
30
+ };
31
+ files: Record<string, StrykerFileReport>;
32
+ }
33
+
34
+ interface MutationScoreEntry {
35
+ score: number;
36
+ mutants: number;
37
+ killed: number;
38
+ survived: number;
39
+ }
40
+
41
+ interface MutationBaseline {
42
+ version: string;
43
+ generatedAt: string;
44
+ source: 'local' | 'ci';
45
+ scores: Record<string, MutationScoreEntry>;
46
+ }
47
+
48
+ function parseArgs(): { filesPattern: string; source: 'local' | 'ci' } {
49
+ const args = process.argv.slice(2);
50
+ let filesPattern = 'src/**/*.ts';
51
+ let source: 'local' | 'ci' = 'local';
52
+
53
+ for (let i = 0; i < args.length; i++) {
54
+ if (args[i] === '--files' && args[i + 1]) {
55
+ filesPattern = args[i + 1];
56
+ i++;
57
+ }
58
+ if (args[i] === '--source' && args[i + 1]) {
59
+ source = args[i + 1] as 'local' | 'ci';
60
+ i++;
61
+ }
62
+ }
63
+
64
+ return { filesPattern, source };
65
+ }
66
+
67
+ async function scanFiles(dir: string, results: string[], basePath: string): Promise<void> {
68
+ const entries = await fs.readdir(dir, { withFileTypes: true });
69
+
70
+ for (const entry of entries) {
71
+ const fullPath = path.join(dir, entry.name);
72
+ const relativePath = path.relative(basePath, fullPath);
73
+
74
+ if (entry.isDirectory()) {
75
+ await scanFiles(fullPath, results, basePath);
76
+ } else if (entry.isFile()) {
77
+ results.push(relativePath);
78
+ }
79
+ }
80
+ }
81
+
82
+ async function getSourceFiles(pattern: string): Promise<string[]> {
83
+ const baseDir = process.cwd();
84
+ const allFiles: string[] = [];
85
+
86
+ const patternParts = pattern.split('/');
87
+ const baseSearchDir = path.join(baseDir, patternParts[0]);
88
+
89
+ await scanFiles(baseSearchDir, allFiles, baseDir);
90
+
91
+ return allFiles.filter(file => {
92
+ return (
93
+ file.endsWith('.ts') &&
94
+ !file.endsWith('.d.ts') &&
95
+ !file.endsWith('.test.ts') &&
96
+ !file.includes('/__tests__/') &&
97
+ !file.includes('/adapters/')
98
+ );
99
+ });
100
+ }
101
+
102
+ async function runStryker(): Promise<void> {
103
+ console.log('Running Stryker mutation testing...');
104
+ try {
105
+ const { stdout, stderr } = await execAsync('npx stryker run', {
106
+ cwd: process.cwd(),
107
+ timeout: 600000
108
+ });
109
+ console.log(stdout);
110
+ if (stderr) {
111
+ console.error(stderr);
112
+ }
113
+ } catch {
114
+ console.log('Stryker finished (possible threshold violations).');
115
+ }
116
+ }
117
+
118
+ async function parseStrykerReport(reportPath: string): Promise<StrykerReport> {
119
+ const reportContent = await fs.readFile(reportPath, 'utf-8');
120
+ return JSON.parse(reportContent) as StrykerReport;
121
+ }
122
+
123
+ function calculateScore(entry: StrykerFileReport): MutationScoreEntry {
124
+ const total = entry.mutants.length;
125
+ const killed = entry.mutants.filter(m => m.status === 'Killed').length;
126
+ const survived = entry.mutants.filter(m => m.status === 'Survived').length;
127
+
128
+ return {
129
+ score: total > 0 ? parseFloat(((killed / total) * 100).toFixed(1)) : 100,
130
+ mutants: total,
131
+ killed,
132
+ survived
133
+ };
134
+ }
135
+
136
+ function buildBaseline(
137
+ report: StrykerReport,
138
+ sourceFiles: string[],
139
+ source: 'local' | 'ci'
140
+ ): MutationBaseline {
141
+ const scores: Record<string, MutationScoreEntry> = {};
142
+
143
+ for (const [filePath, fileReport] of Object.entries(report.files)) {
144
+ const relativePath = filePath.replace(/^\//, '');
145
+ if (sourceFiles.includes(relativePath) || sourceFiles.some(sf => relativePath.endsWith(sf))) {
146
+ scores[relativePath] = calculateScore(fileReport);
147
+ }
148
+ }
149
+
150
+ return {
151
+ version: '1.0',
152
+ generatedAt: new Date().toISOString(),
153
+ source,
154
+ scores
155
+ };
156
+ }
157
+
158
+ async function saveBaseline(baseline: MutationBaseline, outputPath: string): Promise<void> {
159
+ await fs.writeFile(outputPath, JSON.stringify(baseline, null, 2));
160
+ }
161
+
162
+ async function main(): Promise<void> {
163
+ const { filesPattern, source } = parseArgs();
164
+
165
+ console.log(`Scanning source files with pattern: ${filesPattern}`);
166
+ const sourceFiles = await getSourceFiles(filesPattern);
167
+ console.log(`Found ${sourceFiles.length} source files`);
168
+
169
+ await runStryker();
170
+
171
+ const reportPath = path.join(process.cwd(), 'reports', 'mutation', 'report.json');
172
+ console.log(`Parsing Stryker report: ${reportPath}`);
173
+
174
+ const report = await parseStrykerReport(reportPath);
175
+ const baseline = buildBaseline(report, sourceFiles, source);
176
+
177
+ const outputPath = path.join(process.cwd(), '.mutation-baseline.json');
178
+ await saveBaseline(baseline, outputPath);
179
+
180
+ console.log(`Mutation baseline saved to ${outputPath}`);
181
+ console.log(`Total files: ${Object.keys(baseline.scores).length}`);
182
+ console.log(`Average score: ${
183
+ Object.values(baseline.scores).reduce((sum, e) => sum + e.score, 0) /
184
+ (Object.keys(baseline.scores).length || 1)
185
+ }%`);
186
+ }
187
+
188
+ main().catch((error: unknown) => {
189
+ const message = error instanceof Error ? error.message : 'Unknown error';
190
+ console.error(`Failed to initialize mutation baseline: ${message}`);
191
+ process.exit(1);
192
+ });
@@ -0,0 +1,14 @@
1
+ export interface StrykerFileReport {
2
+ mutationScore: number;
3
+ nrOfMutants: number;
4
+ nrOfKilledMutants: number;
5
+ nrOfSurvivedMutants: number;
6
+ }
7
+
8
+ export interface StrykerReport {
9
+ mutationScore: number;
10
+ nrOfMutants: number;
11
+ nrOfKilledMutants: number;
12
+ nrOfSurvivedMutants: number;
13
+ files?: Record<string, StrykerFileReport>;
14
+ }
@@ -0,0 +1,70 @@
1
+ export interface MutationScore {
2
+ score: number;
3
+ mutants: number;
4
+ killed: number;
5
+ survived: number;
6
+ }
7
+
8
+ export interface MutationBaseline {
9
+ version: string;
10
+ generatedAt: string;
11
+ source: 'local' | 'ci';
12
+ scores: Record<string, MutationScore>;
13
+ }
14
+
15
+ export interface GateMOptions {
16
+ changedFiles: string[];
17
+ baselinePath: string;
18
+ criticalPathsPath: string;
19
+ timeoutMs: number;
20
+ }
21
+
22
+ export type GateMStatus = 'pass' | 'block' | 'skip' | 'timeout';
23
+
24
+ export interface GateMResult {
25
+ exitCode: number;
26
+ status: GateMStatus;
27
+ filesChecked: number;
28
+ scores: Record<string, MutationScore>;
29
+ warnings: string[];
30
+ errors: string[];
31
+ }
32
+
33
+ export type TestLayer = 'unit' | 'integration' | 'e2e' | 'unknown';
34
+
35
+ export interface AITestDetectionResult {
36
+ isAiGenerated: boolean;
37
+ mockDensity: number;
38
+ layer: TestLayer;
39
+ explicitThreshold?: number;
40
+ annotations: {
41
+ hasTest: boolean;
42
+ hasIntent: boolean;
43
+ hasCovers: boolean;
44
+ };
45
+ }
46
+
47
+ export interface TestIntentCheckResult {
48
+ sourceFile: string;
49
+ testFile: string | null;
50
+ hasTestAnnotation: boolean;
51
+ hasIntentAnnotation: boolean;
52
+ hasCoversAnnotation: boolean;
53
+ missingAnnotations: string[];
54
+ }
55
+
56
+ export interface FileThreshold {
57
+ file: string;
58
+ threshold: number;
59
+ isCriticalPath: boolean;
60
+ explicitThreshold?: number;
61
+ }
62
+
63
+ export interface ScoreEvaluation {
64
+ file: string;
65
+ score: number;
66
+ threshold: number;
67
+ baselineScore?: number;
68
+ passed: boolean;
69
+ isRegression: boolean;
70
+ }
@@ -0,0 +1,160 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+
4
+ interface MutationScoreEntry {
5
+ score: number;
6
+ mutants: number;
7
+ killed: number;
8
+ survived: number;
9
+ }
10
+
11
+ interface MutationBaseline {
12
+ version: string;
13
+ generatedAt: string;
14
+ source: 'local' | 'ci';
15
+ scores: Record<string, MutationScoreEntry>;
16
+ }
17
+
18
+ interface ParsedScoreInput {
19
+ filePath: string;
20
+ score: number;
21
+ }
22
+
23
+ function parseArgs(): { scores: ParsedScoreInput[] } {
24
+ const args = process.argv.slice(2);
25
+ let scoresInput = '';
26
+
27
+ for (let i = 0; i < args.length; i++) {
28
+ if (args[i] === '--scores' && args[i + 1]) {
29
+ scoresInput = args[i + 1];
30
+ i++;
31
+ }
32
+ }
33
+
34
+ if (!scoresInput) {
35
+ throw new Error('Missing required argument: --scores "file1.ts:65.2,file2.ts:58.0"');
36
+ }
37
+
38
+ const scores: ParsedScoreInput[] = [];
39
+ const entries = scoresInput.split(',');
40
+
41
+ for (const entry of entries) {
42
+ const parts = entry.split(':');
43
+ if (parts.length !== 2) {
44
+ throw new Error(`Invalid score format: ${entry}. Expected "file.ts:score"`);
45
+ }
46
+
47
+ const [filePath, scoreStr] = parts;
48
+ const score = parseFloat(scoreStr);
49
+
50
+ if (Number.isNaN(score) || score < 0 || score > 100) {
51
+ throw new Error(`Invalid score value for ${filePath}: ${scoreStr}. Must be between 0 and 100.`);
52
+ }
53
+
54
+ scores.push({ filePath: filePath.trim(), score });
55
+ }
56
+
57
+ return { scores };
58
+ }
59
+
60
+ async function readBaseline(baselinePath: string): Promise<MutationBaseline> {
61
+ try {
62
+ const content = await fs.readFile(baselinePath, 'utf-8');
63
+ return JSON.parse(content) as MutationBaseline;
64
+ } catch (error: unknown) {
65
+ throw new Error(
66
+ `Failed to read baseline file at ${baselinePath}: ${error instanceof Error ? error.message : 'Unknown error'}`
67
+ );
68
+ }
69
+ }
70
+
71
+ async function fileExists(filePath: string): Promise<boolean> {
72
+ try {
73
+ await fs.access(filePath);
74
+ return true;
75
+ } catch {
76
+ return false;
77
+ }
78
+ }
79
+
80
+ function updateBaseline(
81
+ baseline: MutationBaseline,
82
+ newScores: ParsedScoreInput[]
83
+ ): MutationBaseline {
84
+ const updatedScores: Record<string, MutationScoreEntry> = { ...baseline.scores };
85
+
86
+ for (const { filePath, score } of newScores) {
87
+ const existing = updatedScores[filePath];
88
+
89
+ if (existing) {
90
+ updatedScores[filePath] = {
91
+ ...existing,
92
+ score: parseFloat(score.toFixed(1))
93
+ };
94
+ } else {
95
+ updatedScores[filePath] = {
96
+ score: parseFloat(score.toFixed(1)),
97
+ mutants: 0,
98
+ killed: 0,
99
+ survived: 0
100
+ };
101
+ }
102
+ }
103
+
104
+ return {
105
+ ...baseline,
106
+ generatedAt: new Date().toISOString(),
107
+ scores: updatedScores
108
+ };
109
+ }
110
+
111
+ async function removeDeletedFiles(baseline: MutationBaseline): Promise<MutationBaseline> {
112
+ const validScores: Record<string, MutationScoreEntry> = {};
113
+
114
+ for (const [filePath, entry] of Object.entries(baseline.scores)) {
115
+ const absolutePath = path.resolve(process.cwd(), filePath);
116
+ if (await fileExists(absolutePath)) {
117
+ validScores[filePath] = entry;
118
+ } else {
119
+ console.log(`Removing deleted file from baseline: ${filePath}`);
120
+ }
121
+ }
122
+
123
+ return {
124
+ ...baseline,
125
+ scores: validScores
126
+ };
127
+ }
128
+
129
+ async function saveBaseline(baseline: MutationBaseline, baselinePath: string): Promise<void> {
130
+ await fs.writeFile(baselinePath, JSON.stringify(baseline, null, 2));
131
+ }
132
+
133
+ async function main(): Promise<void> {
134
+ const { scores } = parseArgs();
135
+ const baselinePath = path.join(process.cwd(), '.mutation-baseline.json');
136
+
137
+ console.log('Reading existing mutation baseline...');
138
+ const baseline = await readBaseline(baselinePath);
139
+
140
+ console.log(`Updating ${scores.length} file score(s)...`);
141
+ let updatedBaseline = updateBaseline(baseline, scores);
142
+
143
+ console.log('Checking for deleted files...');
144
+ updatedBaseline = await removeDeletedFiles(updatedBaseline);
145
+
146
+ await saveBaseline(updatedBaseline, baselinePath);
147
+
148
+ console.log(`Mutation baseline updated and saved to ${baselinePath}`);
149
+ console.log(`Total files: ${Object.keys(updatedBaseline.scores).length}`);
150
+
151
+ for (const { filePath, score } of scores) {
152
+ console.log(` ${filePath}: ${score}%`);
153
+ }
154
+ }
155
+
156
+ main().catch((error: unknown) => {
157
+ const message = error instanceof Error ? error.message : 'Unknown error';
158
+ console.error(`Failed to update mutation baseline: ${message}`);
159
+ process.exit(1);
160
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.8.8",
3
+ "version": "0.8.10",
4
4
  "description": "AI-driven development workflow: 6 quality gates + Delphi review + Sprint Flow",
5
5
  "bin": {
6
6
  "xp-gate": "./bin/xp-gate.js"
@@ -12,7 +12,10 @@
12
12
  "lib/",
13
13
  "skills/",
14
14
  "plugins/",
15
- "adapter-common.sh"
15
+ "adapter-common.sh",
16
+ "principles/",
17
+ "mutation/",
18
+ "mock-policy/"
16
19
  ],
17
20
  "repository": {
18
21
  "type": "git",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.8.8",
3
+ "version": "0.8.10",
4
4
  "displayName": "XP-Gate",
5
- "description": "Extreme Programming quality gates + AI workflow skills for Claude Code. Includes 6 quality gates, Sprint Flow, and Delphi multi-expert review.",
5
+ "description": "Extreme Programming quality gates + AI workflow skills for Claude Code. Includes 10 quality gates (Gate 0-9), Sprint Flow (11 phases), and Delphi multi-expert review (>=90% consensus).",
6
6
  "author": {
7
7
  "name": "boyingliu01"
8
8
  },
@@ -1,12 +1,12 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-05-30
4
- **Commit:** 4517f2b
3
+ **Generated:** 2026-06-14
4
+ **Commit:** e215a50
5
5
  **Branch:** main
6
- **Version:** v0.8.1
6
+ **Version:** 0.8.10.0
7
7
 
8
8
  ## OVERVIEW
9
- Delphi Consensus Review — multi-round anonymous expert review (≥91% threshold, 3 experts from ≥2 providers, domestic models only). Supports design + code-walkthrough modes.
9
+ Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, 3 experts from ≥2 providers, domestic models only). Supports design + code-walkthrough modes.
10
10
 
11
11
  ## STRUCTURE
12
12
  ```
@@ -30,7 +30,7 @@ skills/delphi-review/
30
30
 
31
31
  ## CONVENTIONS
32
32
  - 3 experts anonymous in Round 1 (no cross-expert bias)
33
- - ≥91% consensus threshold (was 95%, lowered to 91%)
33
+ - ≥90% consensus threshold (was 95%, now unified to 90%)
34
34
  - Max 5 rounds before forcing decision
35
35
  - Cross-provider required: experts from ≥2 different providers
36
36
  - Domestic models only: glm, kimi, minimax, qwen, deepseek
@@ -39,7 +39,7 @@ skills/delphi-review/
39
39
  - Code-walkthrough skipped on main/master pushes (by design)
40
40
 
41
41
  ## ANTI-PATTERNS (THIS PROJECT)
42
- - Do NOT terminate before achieving true consensus (≥91%)
42
+ - Do NOT terminate before achieving true consensus (≥90%)
43
43
  - Do NOT reveal other experts' opinions during Round 1
44
44
  - Do NOT accept partial agreement without resolution
45
45
  - Do NOT skip code-walkthrough when over thresholds (BLOCK + user decision)
@@ -49,7 +49,7 @@ skills/delphi-review/
49
49
 
50
50
  ## UNIQUE STYLES
51
51
  - Anonymous expert reviews (Round 1)
52
- - Statistical consensus measurement (≥91% threshold)
52
+ - Statistical consensus measurement (≥90% threshold)
53
53
  - Two modes: design review + code-walkthrough
54
54
  - Pre-push integration: .code-walkthrough-result.json stores commit hash + verdict
55
55
  - Delphi guard in claude-code plugin: blocks Edit/Write before APPROVAL
@@ -96,7 +96,7 @@ The skill requires at least 2 experts for code changes, 3 for architecture decis
96
96
  | `experts.architecture` | Architecture reviewer configuration | Required |
97
97
  | `experts.technical` | Technical reviewer configuration | Required |
98
98
  | `experts.feasibility` | Feasibility reviewer configuration | Required for 3-expert mode |
99
- | `consensus.threshold_percent` | Agreement threshold | 95 |
99
+ | `consensus.threshold_percent` | Agreement threshold | 90 |
100
100
  | `consensus.max_review_rounds` | Maximum review rounds | 5 |
101
101
  | `consensus.cross_provider_required` | Require different providers | true |
102
102
 
@@ -9,7 +9,7 @@ description: "Use when asked to review a design, plan, or architecture; before i
9
9
 
10
10
  **In Scope:**
11
11
  - Multi-round anonymous expert consensus review (design + code-walkthrough modes)
12
- - 2-3 experts from different providers with statistical consensus (>= 91%)
12
+ - 2-3 experts from different providers with statistical consensus (>= 90%)
13
13
  - Structured verdict: APPROVED / PASS_WITH_CAVEATS / REQUEST_CHANGES
14
14
  - Domestic models only (no Anthropic/OpenAI/Google)
15
15
 
@@ -27,7 +27,7 @@ description: "Use when asked to review a design, plan, or architecture; before i
27
27
  1. **匿名性** — Round 1 专家互不知道对方意见
28
28
  2. **迭代** — 多轮直到共识,不是固定轮数
29
29
  3. **受控反馈** — 每轮看到其他专家意见
30
- 4. **统计共识** — >=91% 一致才算共识
30
+ 4. **统计共识** — >=90% 一致才算共识
31
31
 
32
32
  ### 质量优先
33
33
 
@@ -95,7 +95,7 @@ description: "Use when asked to review a design, plan, or architecture; before i
95
95
 
96
96
  | 阈值 | 说明 |
97
97
  |------|------|
98
- | **>=91%** | 推荐默认 |
98
+ | **>=90%** | 推荐默认 |
99
99
  | 100% | 完全一致(更严格) |
100
100
 
101
101
  ---
@@ -105,14 +105,14 @@ description: "Use when asked to review a design, plan, or architecture; before i
105
105
  ```
106
106
  Phase 0: 准备 → Round 1: 匿名独立评审 → 共识检查
107
107
 
108
- ├─ 一致 + >=91% + APPROVED → ✅ 完成
108
+ ├─ 一致 + >=90% + APPROVED → ✅ 完成
109
109
 
110
- └─ 不一致 或 <91% 或 REQUEST_CHANGES
110
+ └─ 不一致 或 <90% 或 REQUEST_CHANGES
111
111
 
112
112
 
113
113
  Round 2: 交换意见 → 共识检查
114
114
 
115
- ├─ 一致 + >=91% + APPROVED → ✅ 完成
115
+ ├─ 一致 + >=90% + APPROVED → ✅ 完成
116
116
 
117
117
  └─ 仍分歧 或 REQUEST_CHANGES
118
118
 
@@ -248,11 +248,11 @@ This skill activates on any request for multi-expert review. Common triggers:
248
248
  2. **Dispatch anonymous experts** - 2-3 experts from ≥2 different domestic model providers
249
249
  3. **Collect Round 1 independent reviews** - Anonymous, no cross-expert bias
250
250
  4. **Synthesize feedback** - Measure consensus, identify disagreements
251
- 5. **Run Round 2+ until consensus** - Exchange opinions, iterate until ≥91% agreement
251
+ 5. **Run Round 2+ until consensus** - Exchange opinions, iterate until ≥90% agreement
252
252
  6. **Block on unresolved Critical/Major** - Zero-tolerance: all Critical/Major must be resolved
253
253
  7. **Emit verdict** - APPROVED (with specification.yaml) or REQUEST_CHANGES (fix + re-review)
254
254
 
255
- **Consensus threshold:** ≥91% (project standard for Delphi review approval)
255
+ **Consensus threshold:** ≥90% (project standard for Delphi review approval)
256
256
  **Model policy:** Domestic models only (DeepSeek, Qwen, Kimi, GLM, MiniMax). Foreign models (Anthropic/OpenAI/Google) forbidden.
257
257
 
258
258
  ---
@@ -340,7 +340,7 @@ Every review round output MUST follow this exact JSON structure for design mode:
340
340
  - [ ] Round 2+ 完成(交换意见 / 最终立场)
341
341
 
342
342
  **CRITICAL — 共识验证:**
343
- - [ ] 问题共识比例 >=91%
343
+ - [ ] 问题共识比例 >=90%
344
344
  - [ ] 所有 Critical Issues 已解决
345
345
  - [ ] 所有 Major Concerns 已处理
346
346
 
@@ -422,7 +422,7 @@ Every review round output MUST follow this exact JSON structure for design mode:
422
422
  | 只处理 Critical,忽略 Major | 零容忍:Critical/Major 全部必须处理,不可跳过或降级 |
423
423
  | 单专家自评 | 至少 2 位不同 provider 的专家 |
424
424
  | 用户说"时间紧急"就跳过 | 评审是投资不是开销,跳过后期返工成本更高 |
425
- | "专家几乎一致"就通过 | "几乎" = 不一致,继续到 >=91% |
425
+ | "专家几乎一致"就通过 | "几乎" = 不一致,继续到 >=90% |
426
426
  | 使用 Anthropic/GPT/Gemini 等国外昂贵模型 | 必须使用国产开源模型(DeepSeek, Qwen, Kimi, GLM, MiniMax) |
427
427
  | 三个专家使用同一厂家模型 | 必须来自至少 2 家不同厂家 |
428
428
 
@@ -437,7 +437,7 @@ Every review round output MUST follow this exact JSON structure for design mode:
437
437
  | "这只是小变更" | 所有变更都需要评审 |
438
438
  | "Round 1 就够了" | 不够,必须多轮直到共识 |
439
439
  | "生成报告就完成了" | APPROVED 才算完成 |
440
- | "2/3 同意就是共识" | 还要检查问题共识比例 >=91% |
440
+ | "2/3 同意就是共识" | 还要检查问题共识比例 >=90% |
441
441
 
442
442
  ---
443
443
 
@@ -445,7 +445,7 @@ Every review round output MUST follow this exact JSON structure for design mode:
445
445
 
446
446
  **Delphi 评审完成的唯一标准:**
447
447
  1. ✅ 所有专家裁决 APPROVED
448
- 2. ✅ 问题共识 >=91%
448
+ 2. ✅ 问题共识 >=90%
449
449
  3. ✅ 所有 Critical Issues 已修复验证
450
450
  4. ✅ 所有 Major Concerns 已处理
451
451
  5. ✅ 共识报告已生成
@@ -393,7 +393,7 @@ IF 任何检查失败:
393
393
  | `confidence` | number | 整体置信度 (1-10) |
394
394
  | `experts` | array | 专家评审结果 |
395
395
  | `issues` | array | 未解决的问题(如有) |
396
- | `consensus_ratio` | number | 问题共识比例 (≥0.95 为共识) |
396
+ | `consensus_ratio` | number | 问题共识比例 (≥0.90 为共识) |
397
397
 
398
398
  **有效期机制**:
399
399