@boyingliu01/xp-gate 0.8.9 → 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 (132) hide show
  1. package/lib/init.js +36 -0
  2. package/mock-policy/AGENTS.md +94 -0
  3. package/mock-policy/__tests__/config.test.ts +292 -0
  4. package/mock-policy/__tests__/integration.test.ts +600 -0
  5. package/mock-policy/__tests__/mock-decision-engine.test.ts +231 -0
  6. package/mock-policy/__tests__/scope-scanner.test.ts +535 -0
  7. package/mock-policy/config.ts +106 -0
  8. package/mock-policy/gate-m3.ts +233 -0
  9. package/mock-policy/mock-decision-engine.ts +155 -0
  10. package/mock-policy/schema.ts +22 -0
  11. package/mock-policy/scope-scanner.ts +288 -0
  12. package/mock-policy/types.ts +65 -0
  13. package/mutation/AGENTS.md +73 -0
  14. package/mutation/__tests__/detect-ai-test.test.ts +152 -0
  15. package/mutation/__tests__/gate-m.test.ts +194 -0
  16. package/mutation/detect-ai-test.ts +128 -0
  17. package/mutation/gate-m.ts +619 -0
  18. package/mutation/init-baseline.ts +192 -0
  19. package/mutation/stryker-types.ts +14 -0
  20. package/mutation/types.ts +70 -0
  21. package/mutation/update-baseline.ts +160 -0
  22. package/package.json +5 -2
  23. package/plugins/claude-code/.claude-plugin/plugin.json +2 -2
  24. package/plugins/claude-code/skills/delphi-review/AGENTS.md +7 -7
  25. package/plugins/claude-code/skills/delphi-review/INSTALL.md +1 -1
  26. package/plugins/claude-code/skills/delphi-review/SKILL.md +12 -12
  27. package/plugins/claude-code/skills/delphi-review/references/code-walkthrough.md +1 -1
  28. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +7 -7
  29. package/plugins/claude-code/skills/sprint-flow/SKILL.md +1 -1
  30. package/plugins/claude-code/skills/sprint-flow/references/force-levels.md +1 -1
  31. package/plugins/claude-code/skills/sprint-flow/references/phase-3-review.md +2 -2
  32. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  33. package/plugins/opencode/package.json +1 -1
  34. package/plugins/opencode/skills/delphi-review/AGENTS.md +7 -7
  35. package/plugins/opencode/skills/delphi-review/INSTALL.md +1 -1
  36. package/plugins/opencode/skills/delphi-review/SKILL.md +12 -12
  37. package/plugins/opencode/skills/delphi-review/references/code-walkthrough.md +1 -1
  38. package/plugins/opencode/skills/sprint-flow/AGENTS.md +7 -7
  39. package/plugins/opencode/skills/sprint-flow/SKILL.md +1 -1
  40. package/plugins/opencode/skills/sprint-flow/references/force-levels.md +1 -1
  41. package/plugins/opencode/skills/sprint-flow/references/phase-3-review.md +2 -2
  42. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  43. package/plugins/qoder/plugin.json +1 -1
  44. package/plugins/qoder/skills/delphi-review/AGENTS.md +7 -7
  45. package/plugins/qoder/skills/delphi-review/INSTALL.md +1 -1
  46. package/plugins/qoder/skills/delphi-review/SKILL.md +12 -12
  47. package/plugins/qoder/skills/delphi-review/references/code-walkthrough.md +1 -1
  48. package/plugins/qoder/skills/sprint-flow/AGENTS.md +7 -7
  49. package/plugins/qoder/skills/sprint-flow/SKILL.md +51 -1
  50. package/plugins/qoder/skills/sprint-flow/references/force-levels.md +1 -1
  51. package/plugins/qoder/skills/sprint-flow/references/phase-3-review.md +2 -2
  52. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  53. package/principles/AGENTS.md +111 -0
  54. package/principles/__tests__/analyzer.test.ts +343 -0
  55. package/principles/__tests__/baseline-storage.test.ts +187 -0
  56. package/principles/__tests__/baseline.test.ts +328 -0
  57. package/principles/__tests__/boy-scout-integration.test.ts +264 -0
  58. package/principles/__tests__/boy-scout.test.ts +646 -0
  59. package/principles/__tests__/config.test.ts +78 -0
  60. package/principles/__tests__/index.test.ts +81 -0
  61. package/principles/__tests__/lint-baseline.test.ts +314 -0
  62. package/principles/__tests__/reporter.test.ts +832 -0
  63. package/principles/__tests__/types.test.ts +101 -0
  64. package/principles/adapters/__tests__/base.test.ts +95 -0
  65. package/principles/adapters/__tests__/cpp.test.ts +290 -0
  66. package/principles/adapters/__tests__/dart.test.ts +84 -0
  67. package/principles/adapters/__tests__/go.test.ts +68 -0
  68. package/principles/adapters/__tests__/java.test.ts +68 -0
  69. package/principles/adapters/__tests__/kotlin.test.ts +76 -0
  70. package/principles/adapters/__tests__/objectivec.test.ts +453 -0
  71. package/principles/adapters/__tests__/python.test.ts +84 -0
  72. package/principles/adapters/__tests__/swift.test.ts +68 -0
  73. package/principles/adapters/__tests__/typescript.test.ts +116 -0
  74. package/principles/adapters/base.ts +124 -0
  75. package/principles/adapters/cpp.ts +115 -0
  76. package/principles/adapters/dart.ts +44 -0
  77. package/principles/adapters/go.ts +55 -0
  78. package/principles/adapters/java.ts +56 -0
  79. package/principles/adapters/kotlin.ts +54 -0
  80. package/principles/adapters/objectivec.ts +82 -0
  81. package/principles/adapters/python.ts +83 -0
  82. package/principles/adapters/swift.ts +40 -0
  83. package/principles/adapters/typescript.ts +66 -0
  84. package/principles/analyzer.ts +190 -0
  85. package/principles/baseline.ts +273 -0
  86. package/principles/boy-scout.ts +416 -0
  87. package/principles/config.ts +118 -0
  88. package/principles/index.ts +87 -0
  89. package/principles/lint-baseline.ts +385 -0
  90. package/principles/reporter.ts +188 -0
  91. package/principles/rules/__tests__/clean-code/code-duplication.test.ts +84 -0
  92. package/principles/rules/__tests__/clean-code/deep-nesting.test.ts +74 -0
  93. package/principles/rules/__tests__/clean-code/god-class.test.ts +111 -0
  94. package/principles/rules/__tests__/clean-code/large-file.test.ts +73 -0
  95. package/principles/rules/__tests__/clean-code/long-function.test.ts +83 -0
  96. package/principles/rules/__tests__/clean-code/magic-numbers.test.ts +68 -0
  97. package/principles/rules/__tests__/clean-code/many-exports.test.ts +118 -0
  98. package/principles/rules/__tests__/clean-code/missing-error-handling.test.ts +173 -0
  99. package/principles/rules/__tests__/clean-code/too-many-params.test.ts +60 -0
  100. package/principles/rules/__tests__/clean-code/unused-imports.test.ts +107 -0
  101. package/principles/rules/__tests__/index.test.ts +49 -0
  102. package/principles/rules/__tests__/solid/dip.test.ts +121 -0
  103. package/principles/rules/__tests__/solid/isp.test.ts +60 -0
  104. package/principles/rules/__tests__/solid/lsp.test.ts +184 -0
  105. package/principles/rules/__tests__/solid/ocp.test.ts +69 -0
  106. package/principles/rules/__tests__/solid/srp.test.ts +89 -0
  107. package/principles/rules/clean-code/code-duplication.ts +31 -0
  108. package/principles/rules/clean-code/deep-nesting.ts +38 -0
  109. package/principles/rules/clean-code/god-class.ts +54 -0
  110. package/principles/rules/clean-code/large-file.ts +34 -0
  111. package/principles/rules/clean-code/long-function.ts +47 -0
  112. package/principles/rules/clean-code/magic-numbers.ts +59 -0
  113. package/principles/rules/clean-code/many-exports.ts +40 -0
  114. package/principles/rules/clean-code/missing-error-handling.ts +33 -0
  115. package/principles/rules/clean-code/too-many-params.ts +35 -0
  116. package/principles/rules/clean-code/unused-imports.ts +33 -0
  117. package/principles/rules/index.ts +61 -0
  118. package/principles/rules/solid/dip.ts +47 -0
  119. package/principles/rules/solid/isp.ts +37 -0
  120. package/principles/rules/solid/lsp.ts +79 -0
  121. package/principles/rules/solid/ocp.ts +40 -0
  122. package/principles/rules/solid/srp.ts +44 -0
  123. package/principles/types.ts +27 -0
  124. package/skills/delphi-review/AGENTS.md +7 -7
  125. package/skills/delphi-review/INSTALL.md +1 -1
  126. package/skills/delphi-review/SKILL.md +12 -12
  127. package/skills/delphi-review/references/code-walkthrough.md +1 -1
  128. package/skills/sprint-flow/AGENTS.md +7 -7
  129. package/skills/sprint-flow/SKILL.md +1 -1
  130. package/skills/sprint-flow/references/force-levels.md +1 -1
  131. package/skills/sprint-flow/references/phase-3-review.md +2 -2
  132. package/skills/test-specification-alignment/AGENTS.md +3 -3
@@ -0,0 +1,35 @@
1
+ import { Rule, Violation, Severity } from '../../types';
2
+ import { getDefaultConfig } from '../../config';
3
+
4
+ const config = getDefaultConfig();
5
+
6
+ export const tooManyParamsRule: Rule = {
7
+ id: 'clean-code.too-many-params',
8
+ name: 'Too Many Parameters Rule',
9
+ threshold: config.rules['clean-code']['too-many-params'].threshold ?? 7,
10
+ severity: config.rules['clean-code']['too-many-params'].severity as Severity,
11
+ check: (file: string, adapter: unknown): Violation[] => {
12
+ const violations: Violation[] = [];
13
+
14
+ try {
15
+ const typedAdapter = adapter as { extractFunctions?: () => Array<{name?: string; startLine?: number; line?: number; paramCount?: number;}> | undefined };
16
+ const functions = typedAdapter.extractFunctions?.() || [];
17
+
18
+ for (const func of functions) {
19
+ if (func.paramCount && func.paramCount > (config.rules['clean-code']['too-many-params'].threshold as number)) {
20
+ violations.push({
21
+ file,
22
+ line: func.startLine ?? func.line ?? 1,
23
+ ruleId: 'clean-code.too-many-params',
24
+ message: `Function "${func.name}" has too many parameters: ${func.paramCount} (maximum: ${
25
+ config.rules['clean-code']['too-many-params'].threshold
26
+ })`,
27
+ severity: config.rules['clean-code']['too-many-params'].severity as Severity
28
+ });
29
+ }
30
+ }
31
+ } catch { }
32
+
33
+ return violations;
34
+ }
35
+ };
@@ -0,0 +1,33 @@
1
+ import { Rule, Violation, Severity } from '../../types';
2
+ import { getDefaultConfig } from '../../config';
3
+
4
+ const config = getDefaultConfig();
5
+
6
+ export const unusedImportsRule: Rule = {
7
+ id: 'clean-code.unused-imports',
8
+ name: 'Unused Imports Rule',
9
+ threshold: 1,
10
+ severity: config.rules['clean-code']['unused-imports'].severity as Severity,
11
+ check: (file: string, adapter: unknown): Violation[] => {
12
+ const violations: Violation[] = [];
13
+
14
+ try {
15
+ const typedAdapter = adapter as { imports?: Array<{name?: string; line?: number; used?: boolean; type?: string;}> | undefined };
16
+ const imports = typedAdapter.imports || [];
17
+
18
+ for (const imp of imports) {
19
+ if (!imp.used && imp.type !== 'type') {
20
+ violations.push({
21
+ file,
22
+ line: imp.line ?? 1,
23
+ ruleId: 'clean-code.unused-imports',
24
+ message: `Unused import "${imp.name}" - consider removing`,
25
+ severity: config.rules['clean-code']['unused-imports'].severity as Severity
26
+ });
27
+ }
28
+ }
29
+ } catch { }
30
+
31
+ return violations;
32
+ }
33
+ };
@@ -0,0 +1,61 @@
1
+ import { Rule } from '../types';
2
+ import { longFunctionRule } from './clean-code/long-function';
3
+ import { largeFileRule } from './clean-code/large-file';
4
+ import { magicNumbersRule } from './clean-code/magic-numbers';
5
+ import { godClassRule } from './clean-code/god-class';
6
+ import { deepNestingRule } from './clean-code/deep-nesting';
7
+ import { tooManyParamsRule } from './clean-code/too-many-params';
8
+ import { missingErrorHandlingRule } from './clean-code/missing-error-handling';
9
+ import { unusedImportsRule } from './clean-code/unused-imports';
10
+ import { codeDuplicationRule } from './clean-code/code-duplication';
11
+ import { manyExportsRule } from './clean-code/many-exports';
12
+ import { srpRule } from './solid/srp';
13
+ import { ocpRule } from './solid/ocp';
14
+ import { lspRule } from './solid/lsp';
15
+ import { ispRule } from './solid/isp';
16
+ import { dipRule } from './solid/dip';
17
+
18
+ export {
19
+ longFunctionRule,
20
+ largeFileRule,
21
+ magicNumbersRule,
22
+ godClassRule,
23
+ deepNestingRule,
24
+ tooManyParamsRule,
25
+ missingErrorHandlingRule,
26
+ unusedImportsRule,
27
+ codeDuplicationRule,
28
+ manyExportsRule,
29
+ srpRule,
30
+ ocpRule,
31
+ lspRule,
32
+ ispRule,
33
+ dipRule,
34
+ };
35
+
36
+ const CLEAN_CODE_RULES: Rule[] = [
37
+ longFunctionRule,
38
+ largeFileRule,
39
+ magicNumbersRule,
40
+ godClassRule,
41
+ deepNestingRule,
42
+ tooManyParamsRule,
43
+ missingErrorHandlingRule,
44
+ unusedImportsRule,
45
+ codeDuplicationRule,
46
+ manyExportsRule,
47
+ ];
48
+
49
+ const SOLID_RULES: Rule[] = [srpRule, ocpRule, lspRule, ispRule, dipRule];
50
+
51
+ export function getAllPrincipleRules(): Rule[] {
52
+ return [...CLEAN_CODE_RULES, ...SOLID_RULES];
53
+ }
54
+
55
+ export function getCleanCodeRules(): Rule[] {
56
+ return [...CLEAN_CODE_RULES];
57
+ }
58
+
59
+ export function getSolidRules(): Rule[] {
60
+ return [...SOLID_RULES];
61
+ }
@@ -0,0 +1,47 @@
1
+ import { Rule, Violation } from '../../types';
2
+ import { getDefaultConfig } from '../../config';
3
+
4
+ const config = getDefaultConfig();
5
+ const { severity } = config.rules['solid']['dip'];
6
+ const EXCLUDED_CLASSES = config.rules['solid']['dip'].exclude || [
7
+ 'Date', 'Map', 'Set', 'Error', 'Array', 'Object', 'Promise'
8
+ ];
9
+
10
+ function shouldSkipInstantiation(className: string): boolean {
11
+ if (EXCLUDED_CLASSES.includes(className)) return true;
12
+ if (className.endsWith('Factory') || className.endsWith('Builder')) return true;
13
+ return false;
14
+ }
15
+
16
+ export const dipRule: Rule = {
17
+ id: 'solid.dip',
18
+ name: 'Dependency Inversion Principle Rule',
19
+ threshold: 0,
20
+ severity: severity as 'error' | 'warning' | 'info',
21
+ check: (file: string, adapter: import('../../types').Adapter): Violation[] => {
22
+ const violations: Violation[] = [];
23
+
24
+ try {
25
+ for (const cls_any of adapter.extractClasses() || []) {
26
+ const cls = cls_any as {code?: string; line?: number};
27
+ const code = cls.code;
28
+ if (!code) continue;
29
+
30
+ const newMatches = code.match(/new\s+(\w+)\s*\(/g) || [];
31
+ for (const match of newMatches) {
32
+ const className = match.replace(/new\s+/, '').replace(/\s*\(/, '');
33
+ if (shouldSkipInstantiation(className)) continue;
34
+
35
+ violations.push({
36
+ file,
37
+ line: cls.line || 0,
38
+ ruleId: 'solid.dip',
39
+ severity: severity as 'error' | 'warning' | 'info',
40
+ message: `Direct instantiation detected: new ${className}(). Prefer dependency injection for flexibility.`,
41
+ });
42
+ }
43
+ }
44
+ } catch { }
45
+ return violations;
46
+ }
47
+ };
@@ -0,0 +1,37 @@
1
+ import { Rule, Violation } from '../../types';
2
+ import { getDefaultConfig } from '../../config';
3
+
4
+ const config = getDefaultConfig();
5
+
6
+ export const ispRule: Rule = {
7
+ id: 'solid.isp',
8
+ name: 'Interface Segregation Principle Rule',
9
+ threshold: config.rules['solid']['isp'].methodThreshold ?? 10,
10
+ severity: config.rules['solid']['isp'].severity as 'error' | 'warning' | 'info',
11
+ check: (file: string, adapter: import('../../types').Adapter): Violation[] => {
12
+ const violations: Violation[] = [];
13
+
14
+ try {
15
+ const typedAdapter = adapter as { extractInterfaces?: () => Array<{name?: string; line?: number; methodCount?: number;}> | undefined };
16
+ const interfaces = typedAdapter.extractInterfaces?.() || [];
17
+
18
+ for (const iface of interfaces) {
19
+ const methodCount = iface.methodCount || 0;
20
+
21
+ if (methodCount > (config.rules['solid']['isp'].methodThreshold as number)) {
22
+ violations.push({
23
+ file,
24
+ line: iface.line ?? 1,
25
+ ruleId: 'solid.isp',
26
+ message: `Interface "${iface.name}" has too many methods: ${methodCount} (maximum: ${
27
+ config.rules['solid']['isp'].methodThreshold
28
+ }). Consider splitting into focused interfaces.`,
29
+ severity: config.rules['solid']['isp'].severity as "error" | "warning" | "info"
30
+ });
31
+ }
32
+ }
33
+ } catch { }
34
+
35
+ return violations;
36
+ }
37
+ };
@@ -0,0 +1,79 @@
1
+ import { Rule, Violation, Adapter } from '../../types';
2
+ import { getDefaultConfig } from '../../config';
3
+
4
+ const config = getDefaultConfig();
5
+ const severity = config.rules['solid']['lsp'].severity as 'error' | 'warning' | 'info';
6
+ const PRIMITIVE_TYPES = new Set([
7
+ 'string', 'number', 'boolean', 'any', 'void', 'null', 'undefined', 'Object', 'Array',
8
+ ]);
9
+
10
+ interface ClassInfo {
11
+ code?: string;
12
+ line?: number;
13
+ name?: string;
14
+ }
15
+
16
+ function extractParamType(param: string): string | null {
17
+ if (!param.includes(':')) return null;
18
+ const typeMatch = param.match(/:\s*(\w+)/);
19
+ return typeMatch ? typeMatch[1] : null;
20
+ }
21
+
22
+ function isCompatibleParamType(paramType: string, className: string | undefined): boolean {
23
+ if (PRIMITIVE_TYPES.has(paramType)) return true;
24
+ if (className && paramType.startsWith(className)) return true;
25
+ return false;
26
+ }
27
+
28
+ function collectMethodParamTypes(methodSignature: string): string[] {
29
+ const paramsMatch = methodSignature.match(/\(([^)]+)\)/);
30
+ if (!paramsMatch) return [];
31
+ const types: string[] = [];
32
+ for (const param of paramsMatch[1].split(',').map((p) => p.trim())) {
33
+ const paramType = extractParamType(param);
34
+ if (paramType) types.push(paramType);
35
+ }
36
+ return types;
37
+ }
38
+
39
+ function buildViolation(file: string, cls: ClassInfo, paramType: string): Violation {
40
+ return {
41
+ file,
42
+ line: cls.line ?? 0,
43
+ ruleId: 'solid.lsp',
44
+ message: `Possible LSP violation in "${cls.name}". Parameter type "${paramType}" may not be compatible with base class contract.`,
45
+ severity,
46
+ };
47
+ }
48
+
49
+ function checkClass(file: string, cls: ClassInfo): Violation[] {
50
+ if (!cls.code || !cls.code.includes('extends')) return [];
51
+
52
+ const violations: Violation[] = [];
53
+ const methodSignatures = cls.code.match(/\w+\s*\(([^)]+)\)/g) || [];
54
+
55
+ for (const methodSignature of methodSignatures) {
56
+ for (const paramType of collectMethodParamTypes(methodSignature)) {
57
+ if (!isCompatibleParamType(paramType, cls.name)) {
58
+ violations.push(buildViolation(file, cls, paramType));
59
+ }
60
+ }
61
+ }
62
+
63
+ return violations;
64
+ }
65
+
66
+ export const lspRule: Rule = {
67
+ id: 'solid.lsp',
68
+ name: 'Liskov Substitution Principle Rule',
69
+ threshold: 0,
70
+ severity,
71
+ check: (file: string, adapter: Adapter): Violation[] => {
72
+ try {
73
+ const classes = (adapter.extractClasses() || []) as ClassInfo[];
74
+ return classes.flatMap((cls) => checkClass(file, cls));
75
+ } catch {
76
+ return [];
77
+ }
78
+ },
79
+ };
@@ -0,0 +1,40 @@
1
+ import { Rule, Violation } from '../../types';
2
+ import { getDefaultConfig } from '../../config';
3
+
4
+ const config = getDefaultConfig();
5
+
6
+ export const ocpRule: Rule = {
7
+ id: 'solid.ocp',
8
+ name: 'Open/Closed Principle Rule',
9
+ threshold: 0,
10
+ severity: config.rules['solid']['ocp'].severity as "error" | "warning" | "info",
11
+ check: (file: string, adapter: import('../../types').Adapter): Violation[] => {
12
+ const violations: Violation[] = [];
13
+
14
+ try {
15
+ const classes = adapter.extractClasses() || [];
16
+
17
+ for (const raw of classes) {
18
+ const cls = raw as { code?: string; line?: number; name?: string };
19
+ if (!cls.code) continue;
20
+
21
+ const extendsMatch = cls.code.match(/extends\s+(\w+)/);
22
+ if (extendsMatch) {
23
+ const baseClass = extendsMatch[1];
24
+
25
+ if (cls.code.includes(`class ${baseClass}`)) {
26
+ violations.push({
27
+ file,
28
+ line: cls.line ?? 1,
29
+ ruleId: 'solid.ocp',
30
+ message: `Possible modification of base class "${baseClass}" while extending. Extension should not require modifying the base.`,
31
+ severity: config.rules['solid']['ocp'].severity as "error" | "warning" | "info"
32
+ });
33
+ }
34
+ }
35
+ }
36
+ } catch { }
37
+
38
+ return violations;
39
+ }
40
+ };
@@ -0,0 +1,44 @@
1
+ import { Rule, Violation } from '../../types';
2
+ import { getDefaultConfig } from '../../config';
3
+
4
+ const config = getDefaultConfig();
5
+ const { methodThreshold, severity } = config.rules['solid']['srp'];
6
+
7
+ export const srpRule: Rule = {
8
+ id: 'solid.srp',
9
+ name: 'Single Responsibility Principle Rule',
10
+ threshold: methodThreshold as number,
11
+ severity: severity as "error" | "warning" | "info",
12
+ check: (file: string, adapter: import('../../types').Adapter): Violation[] => {
13
+ const violations: Violation[] = [];
14
+
15
+ try {
16
+ const classes = adapter.extractClasses() || [];
17
+ const maxMethods = methodThreshold as number;
18
+ const sev = severity as "error" | "warning" | "info";
19
+
20
+ for (const raw of classes) {
21
+ const cls = raw as { code?: string; line?: number; name?: string; methodCount?: number; imports?: Record<string, unknown> };
22
+ const methodCount = cls.methodCount || 0;
23
+ const importCategories = cls.imports ? Object.keys(cls.imports).length : 0;
24
+ const line = cls.line ?? 1;
25
+
26
+ if (methodCount > maxMethods) {
27
+ violations.push({
28
+ file, line, ruleId: 'solid.srp', severity: sev,
29
+ message: `Class "${cls.name}" has too many methods: ${methodCount} (maximum: ${maxMethods}). Consider splitting into focused classes.`,
30
+ });
31
+ }
32
+
33
+ if (importCategories > 3) {
34
+ violations.push({
35
+ file, line, ruleId: 'solid.srp', severity: sev,
36
+ message: `Class "${cls.name}" imports from ${importCategories} different domains. Each class should focus on one responsibility.`,
37
+ });
38
+ }
39
+ }
40
+ } catch { }
41
+
42
+ return violations;
43
+ },
44
+ };
@@ -0,0 +1,27 @@
1
+ export type Severity = 'error' | 'warning' | 'info';
2
+
3
+ export interface Rule {
4
+ id: string;
5
+ name: string;
6
+ threshold: number;
7
+ severity: Severity;
8
+ check: (file: string, adapter: Adapter) => Violation[];
9
+ }
10
+
11
+ export interface Violation {
12
+ file: string;
13
+ line: number;
14
+ column?: number;
15
+ ruleId: string;
16
+ message: string;
17
+ severity: Severity;
18
+ }
19
+
20
+ export interface Adapter {
21
+ detectLanguage: () => string;
22
+ parseAST: () => unknown;
23
+ extractFunctions: () => unknown[];
24
+ extractClasses: () => unknown[];
25
+ extractExports: () => unknown[];
26
+ countLines: () => number;
27
+ }
@@ -1,12 +1,12 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-11
4
- **Commit:** c18f82b
3
+ **Generated:** 2026-06-14
4
+ **Commit:** e215a50
5
5
  **Branch:** main
6
- **Version:** 0.8.9.0
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
 
@@ -1,12 +1,12 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-11
4
- **Commit:** c18f82b
3
+ **Generated:** 2026-06-14
4
+ **Commit:** e215a50
5
5
  **Branch:** main
6
- **Version:** 0.8.9.0
6
+ **Version:** 0.8.10.0
7
7
 
8
8
  ## OVERVIEW
9
- **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → USER ACCEPTANCE → FEEDBACK → SHIP → LAND → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: design must pass Delphi review (≥91% consensus) before any coding.
9
+ **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → USER ACCEPTANCE → FEEDBACK → SHIP → LAND → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: design must pass Delphi review (≥90% consensus) before any coding.
10
10
 
11
11
  > **Doc drift**: README/CAPABILITIES still describe a "7-phase" pipeline. The canonical 11-phase model lives in `SKILL.md` and is what actually executes. See root `AGENTS.md` → "Known Drift" #4.
12
12
 
@@ -58,7 +58,7 @@ skills/sprint-flow/
58
58
  | -1 | ISOLATE | Isolate working tree / worktree creation | — |
59
59
  | -0.5 | AUTO-ESTIMATE | Sizing pass; emits estimate template | — |
60
60
  | 0 | THINK | brainstorming → CONTEXT.md + ADR | — |
61
- | 1 | PLAN | autoplan → delphi-review → specification.yaml | **HARD-GATE**: design must reach ≥91% Delphi consensus |
61
+ | 1 | PLAN | autoplan → delphi-review → specification.yaml | **HARD-GATE**: design must reach ≥90% Delphi consensus |
62
62
  | 2 | BUILD | ralph-loop (REQ-level, default) + TDD + test-spec-alignment | — |
63
63
  | 3 | REVIEW | code-walkthrough + QA + benchmark | — |
64
64
  | 4 | USER ACCEPTANCE | Manual verification | — |
@@ -69,7 +69,7 @@ skills/sprint-flow/
69
69
 
70
70
  ## CONVENTIONS
71
71
  - **ralph-loop is Phase 2 default**. Each REQ runs in a clean context (no linear accumulation), saving 40-67% tokens vs parallel mode.
72
- - **delphi-review HARD-GATE in Phase 1**: design must reach ≥91% consensus across ≥2 model providers, domestic models only. Unapproved → BLOCK coding.
72
+ - **delphi-review HARD-GATE in Phase 1**: design must reach ≥90% consensus across ≥2 model providers, domestic models only. Unapproved → BLOCK coding.
73
73
  - **`learn` is called twice**: once per REQ in Phase 2 (ralph-loop internal, `progress.log` permanent/contextual classification) and once in Phase 5 (Sprint-level retro).
74
74
  - **Phase isolation**: each phase has explicit entry/exit criteria documented in its `references/phase-*.md` file.
75
75
  - **Emergent Requirements** discovered in Phase 4 (USER ACCEPTANCE) are explicitly captured via `templates/emergent-issues-template.md` — never silently merged.
@@ -81,7 +81,7 @@ skills/sprint-flow/
81
81
  - Do NOT enter Phase 1 (PLAN) without completing Phase 0 (THINK).
82
82
  - Do NOT implement before design is APPROVED — Phase 1 must reach Delphi consensus first.
83
83
  - Do NOT merge an Emergent Requirement into the original Sprint silently — capture it via the template.
84
- - Do NOT terminate Delphi review before ≥91% consensus or 5 rounds, whichever first.
84
+ - Do NOT terminate Delphi review before ≥90% consensus or 5 rounds, whichever first.
85
85
 
86
86
  ## UNIQUE STYLES
87
87
  - **11 phases** including negative-numbered pre-phases (-1, -0.5) — intentional, captures the work that happens before "real" coding starts.
@@ -247,7 +247,7 @@ ISOLATE → AUTO-ESTIMATE → THINK → PLAN → [GITHOOKS-GATE] → BUILD → R
247
247
  ```
248
248
 
249
249
  **Hard Gates**:
250
- - **Phase 0→1**: Design must be APPROVED by delphi-review (≥91% consensus)
250
+ - **Phase 0→1**: Design must be APPROVED by delphi-review (≥90% consensus)
251
251
  - **Phase 1→2**: GITHOOKS-GATE (hooks must be installed) + DELPHI-GATE (spec must be APPROVED)
252
252
  - **Phase 4→5**: User acceptance must be completed (mandatory manual step)
253
253
  - **Phase 5→6**: feedback-log.md must exist (HARD-GATE)
@@ -98,7 +98,7 @@ AUTO-ESTIMATE 输出 → Force Levels 执行 → 自动升级机制(如触发
98
98
 
99
99
  | 场景 | DELPHI-GATE | Force Levels |
100
100
  |------|------------|-------------|
101
- | Phase 1 设计评审 | 3 专家、≥95% 共识、生成 specification.yaml | 不适用(设计阶段) |
101
+ | Phase 1 设计评审 | 3 专家、≥90% 共识、生成 specification.yaml | 不适用(设计阶段) |
102
102
  | Phase 2 BUILD 入口 | **必须检查** `.sprint-state/delphi-reviewed.json` 中 `verdict=APPROVED` | 轻量/标准/复杂:通过对应强度的 delphi-review 生成该门禁文件 |
103
103
  | 轻量级评审 | 生成 `delphi-reviewed.json`(2 专家、1 轮、2/2 批准) | 2 专家、1 轮、写入门禁文件 |
104
104
  | 标准级评审 | 生成 `delphi-reviewed.json`(2 专家、最多 2 轮、2/2 批准) | 2 专家、最多 2 轮、写入门禁文件 |
@@ -11,7 +11,7 @@ Web 前端项目额外增加:系统化 QA、视觉审计、性能基线。
11
11
  ## 调用 Skills
12
12
 
13
13
  **所有项目**:
14
- - `delphi-review --mode code-walkthrough` — 多专家匿名代码走查(2-3 domestic models, >=95% consensus)
14
+ - `delphi-review --mode code-walkthrough` — 多专家匿名代码走查(2-3 domestic models, ≥90% consensus)
15
15
  - `test-specification-alignment` — 测试与 Spec 对齐验证
16
16
  - `browse` (gstack) — 浏览器自动化测试
17
17
 
@@ -43,7 +43,7 @@ delphi code-walkthrough 执行:
43
43
  - Round 1: 匿名独立评审(防止 anchoring bias)
44
44
  - Round 2: 交换意见,响应关切
45
45
  - Round 3: 最终立场(如需)
46
- - >=95% 共识 + APPROVED 才通过
46
+ - ≥90% 共识 + APPROVED 才通过
47
47
 
48
48
  **如果 REQUEST_CHANGES**:
49
49
  - ⚠️ 暂停等待用户修复 Critical Issues + 处理 Major Concerns
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-11
4
- **Commit:** c18f82b
3
+ **Generated:** 2026-06-14
4
+ **Commit:** e215a50
5
5
  **Branch:** main
6
- **Version:** 0.8.9.0
6
+ **Version:** 0.8.10.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.