@boyingliu01/xp-gate 0.36.1 → 0.37.1

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 (123) hide show
  1. package/adapters/cpp.sh +78 -10
  2. package/adapters/csharp.sh +58 -3
  3. package/adapters/gate-3.sh +15 -5
  4. package/adapters/gate-8.sh +131 -9
  5. package/adapters/typescript.sh +32 -8
  6. package/build-integrity/__tests__/import-resolver.test.ts +257 -0
  7. package/build-integrity/__tests__/quote-masker.test.ts +177 -0
  8. package/build-integrity/gate-10.ts +127 -9
  9. package/build-integrity/quote-masker.ts +266 -0
  10. package/gate-10.sh +66 -0
  11. package/gate-12-file-hygiene.sh +15 -7
  12. package/gate-13-compiler-strictness.sh +81 -1
  13. package/gate-3.sh +15 -5
  14. package/gate-6-layers.sh +375 -0
  15. package/gate-8.sh +131 -9
  16. package/hooks/gate-10.sh +66 -0
  17. package/hooks/gate-12-file-hygiene.sh +15 -7
  18. package/hooks/gate-13-compiler-strictness.sh +81 -1
  19. package/hooks/gate-3.sh +15 -5
  20. package/hooks/gate-6-layers.sh +375 -0
  21. package/hooks/gate-8.sh +131 -9
  22. package/hooks/gate-registry.sh +2 -2
  23. package/hooks/hook-module-resolution.sh +1 -1
  24. package/hooks/lib/assertion-quality.sh +8 -2
  25. package/hooks/lib/ccn-ratchet.sh +10 -0
  26. package/hooks/lib/layer-baseline.cjs +88 -0
  27. package/hooks/lib/typecheck.sh +28 -5
  28. package/hooks/pre-commit +376 -53
  29. package/hooks/pre-push +46 -13
  30. package/lib/__tests__/agent-runtime-journal.test.js +1 -1
  31. package/lib/__tests__/arch.test.js +9 -0
  32. package/lib/__tests__/audit-cli-contract.test.ts +1 -1
  33. package/lib/__tests__/check-alignment-reasons.test.mjs +11 -1
  34. package/lib/__tests__/check-all-skip-accounting.test.js +1 -1
  35. package/lib/__tests__/detect-deps-gate-identity.test.js +135 -0
  36. package/lib/__tests__/detect-deps.test.js +2 -1
  37. package/lib/__tests__/doctor-469-hook-env.test.js +7 -1
  38. package/lib/__tests__/doctor-arch-tools.test.js +169 -0
  39. package/lib/__tests__/doctor-delphi.test.js +1 -1
  40. package/lib/__tests__/doctor-drift-round2.test.js +4 -1
  41. package/lib/__tests__/doctor-executed-surface.test.js +45 -24
  42. package/lib/__tests__/doctor-module-drift.test.js +13 -7
  43. package/lib/__tests__/doctor-module-resolution-parity.test.js +74 -2
  44. package/lib/__tests__/doctor-tui-skill-freshness.test.js +21 -6
  45. package/lib/__tests__/doctor.test.js +17 -0
  46. package/lib/__tests__/gate-runner-tsx-invocation.test.js +149 -0
  47. package/lib/__tests__/gate-runner.test.js +23 -7
  48. package/lib/__tests__/init-gitignore.test.js +204 -0
  49. package/lib/__tests__/init.test.js +24 -3
  50. package/lib/__tests__/language-tools-build-file-install.test.js +82 -0
  51. package/lib/__tests__/language-tools-detect.test.js +61 -0
  52. package/lib/__tests__/mirror-sync.test.js +2 -0
  53. package/lib/__tests__/phase-transition.test.js +19 -1
  54. package/lib/__tests__/sprint-status-rework.test.js +32 -12
  55. package/lib/__tests__/test-alignment-range-guard.test.ts +82 -0
  56. package/lib/__tests__/test-alignment.test.ts +13 -3
  57. package/lib/__tests__/update-skill.test.js +2 -2
  58. package/lib/detect-deps.js +7 -1
  59. package/lib/doctor.js +81 -17
  60. package/lib/gate-runner.js +101 -7
  61. package/lib/hook-module-resolution.js +18 -6
  62. package/lib/init.js +136 -1
  63. package/lib/language-tools.js +217 -1
  64. package/lib/layer-baseline.cjs +88 -0
  65. package/lib/mattpocock-license-verdict.json +1 -1
  66. package/lib/principles.js +21 -6
  67. package/lib/test-alignment.ts +452 -55
  68. package/mock-policy/AGENTS.md +1 -1
  69. package/mutation/AGENTS.md +1 -1
  70. package/package.json +2 -1
  71. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  72. package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +34 -24
  73. package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
  74. package/plugins/claude-code/skills/delphi-review/INSTALL.md +29 -1
  75. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
  76. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
  77. package/plugins/dsh/package.json +1 -1
  78. package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +34 -24
  79. package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
  80. package/plugins/dsh/skills/delphi-review/INSTALL.md +29 -1
  81. package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
  82. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
  83. package/plugins/dsh/src/client.test.ts +1 -1
  84. package/plugins/dsh/src/command.test.ts +1 -1
  85. package/plugins/dsh/src/contract.test.ts +1 -1
  86. package/plugins/dsh/src/credentials.test.ts +1 -1
  87. package/plugins/opencode/package.json +1 -1
  88. package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +34 -24
  89. package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
  90. package/plugins/opencode/skills/delphi-review/INSTALL.md +29 -1
  91. package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
  92. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
  93. package/plugins/qoder/plugin.json +1 -1
  94. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +34 -24
  95. package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
  96. package/plugins/qoder/skills/delphi-review/INSTALL.md +29 -1
  97. package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
  98. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
  99. package/principles/AGENTS.md +1 -1
  100. package/principles/__tests__/config-arch-group.test.ts +106 -0
  101. package/principles/__tests__/config-enforcement.test.ts +1 -1
  102. package/principles/adapters/control-nesting.ts +572 -0
  103. package/principles/adapters/csharp.ts +73 -42
  104. package/principles/adapters/java.ts +9 -5
  105. package/principles/adapters/typescript.ts +138 -176
  106. package/principles/config.ts +37 -2
  107. package/principles/index.ts +57 -4
  108. package/principles/reporter.ts +99 -65
  109. package/principles/rules/arch/__tests__/dependency.test.ts +180 -0
  110. package/principles/rules/arch/__tests__/naming.test.ts +133 -0
  111. package/principles/rules/arch/__tests__/shared.test.ts +113 -0
  112. package/principles/rules/arch/dependency.ts +264 -0
  113. package/principles/rules/arch/naming.ts +188 -0
  114. package/principles/rules/arch/shared.ts +169 -0
  115. package/principles/rules/exports.ts +26 -0
  116. package/principles/rules/index.ts +11 -18
  117. package/scripts/__tests__/sync-package-content.test.js +23 -1
  118. package/scripts/sync-package-content.js +8 -2
  119. package/skills/delphi-review/.delphi-config.json.example +34 -24
  120. package/skills/delphi-review/AGENTS.md +1 -1
  121. package/skills/delphi-review/INSTALL.md +29 -1
  122. package/skills/sprint-flow/AGENTS.md +1 -1
  123. package/skills/test-specification-alignment/AGENTS.md +1 -1
@@ -2,10 +2,20 @@
2
2
  "$comment": [
3
3
  "Delphi Review Configuration Template",
4
4
  "======================================",
5
- "Copy this file to .delphi-config.json and fill in your API keys.",
5
+ "Copy this file to .delphi-config.json and fill in your API key.",
6
6
  "Place this file alongside SKILL.md in the delphi-review skill directory.",
7
7
  "Exactly three roles are required, with distinct trimmed executable model IDs.",
8
8
  "",
9
+ "The default profile routes all three seats through one WhaleCloud gateway so a",
10
+ "single token plan covers the review. The three ids are deliberately different",
11
+ "FLASH-tier models (cheap, fast, and good enough for review):",
12
+ " architecture -> s-deepseek-v4.1-flash",
13
+ " technical -> s-glm-5.3-flash",
14
+ " feasibility -> g-ling-3.1-flash",
15
+ "Check that the seat ids resolve to three DISTINCT backend models on your",
16
+ "gateway -- two different ids can be aliased to the same backend, which defeats",
17
+ "the multi-model invariant while still looking correct in the config.",
18
+ "",
9
19
  "Provider and vendor are unrestricted. provider=local is a fallback and cannot count as a successful expert execution.",
10
20
  "cross_provider_required is deprecated and ignored with warning code cross_provider_required_ignored."
11
21
  ],
@@ -15,23 +25,23 @@
15
25
  "profiles": {
16
26
  "default": {
17
27
  "providers": {
18
- "bailian-tp": {
19
- "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
20
- "api_key": "YOUR_API_KEY"
28
+ "whalecloud": {
29
+ "base_url": "https://lab.iwhalecloud.com/gpt-proxy",
30
+ "api_key": "${WHALECLOUD_API_KEY}"
21
31
  }
22
32
  },
23
33
  "experts": {
24
34
  "architecture": {
25
- "provider": "bailian-tp",
26
- "model": "qwen-plus"
35
+ "provider": "whalecloud",
36
+ "model": "s-deepseek-v4.1-flash"
27
37
  },
28
38
  "technical": {
29
- "provider": "bailian-tp",
30
- "model": "deepseek-v3"
39
+ "provider": "whalecloud",
40
+ "model": "s-glm-5.3-flash"
31
41
  },
32
42
  "feasibility": {
33
- "provider": "bailian-tp",
34
- "model": "glm-4.5"
43
+ "provider": "whalecloud",
44
+ "model": "g-ling-3.1-flash"
35
45
  }
36
46
  }
37
47
  },
@@ -39,23 +49,23 @@
39
49
  "starter": {
40
50
  "$comment": "One provider and token plan serving three distinct models",
41
51
  "providers": {
42
- "bailian-tp": {
43
- "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
44
- "api_key": "YOUR_API_KEY"
52
+ "whalecloud": {
53
+ "base_url": "https://lab.iwhalecloud.com/gpt-proxy",
54
+ "api_key": "${WHALECLOUD_API_KEY}"
45
55
  }
46
56
  },
47
57
  "experts": {
48
58
  "architecture": {
49
- "provider": "bailian-tp",
50
- "model": "qwen-plus"
59
+ "provider": "whalecloud",
60
+ "model": "s-deepseek-v4.1-flash"
51
61
  },
52
62
  "technical": {
53
- "provider": "bailian-tp",
54
- "model": "deepseek-v3"
63
+ "provider": "whalecloud",
64
+ "model": "s-glm-5.3-flash"
55
65
  },
56
66
  "feasibility": {
57
- "provider": "bailian-tp",
58
- "model": "glm-4.5"
67
+ "provider": "whalecloud",
68
+ "model": "g-ling-3.1-flash"
59
69
  }
60
70
  }
61
71
  }
@@ -77,14 +87,14 @@
77
87
  "model or gateway changes. See docs/plans/2026-10-14-sprint-c-design.md section 2.",
78
88
  "Example expert entry:",
79
89
  " \"architecture\": {",
80
- " \"provider\": \"bailian-tp\",",
81
- " \"model\": \"qwen-plus\",",
90
+ " \"provider\": \"whalecloud\",",
91
+ " \"model\": \"s-deepseek-v4.1-flash\",",
82
92
  " \"seat_id\": \"architecture\",",
83
93
  " \"max_prompt_bytes\": 26624,",
84
94
  " \"prompt_calibration\": {",
85
- " \"measured_at\": \"2026-10-05\",",
86
- " \"model_id\": \"qwen-plus\",",
87
- " \"gateway\": \"bailian\",",
95
+ " \"measured_at\": \"2026-11-04\",",
96
+ " \"model_id\": \"s-deepseek-v4.1-flash\",",
97
+ " \"gateway\": \"whalecloud\",",
88
98
  " \"last_pass_bytes\": 26624,",
89
99
  " \"last_fail_bytes\": 36897",
90
100
  " }",
@@ -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.36.1.0
6
+ **Version:** 0.37.1.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.
@@ -32,10 +32,38 @@ Then replace the provider/model placeholders:
32
32
  "model": "YOUR_PROVIDER/YOUR_MODEL_A"
33
33
 
34
34
  // After (your config):
35
- "model": "bailian-tp/qwen-plus"
35
+ "model": "whalecloud/s-deepseek-v4.1-flash"
36
36
  // The other two role model fields must be different trimmed IDs.
37
37
  ```
38
38
 
39
+ The shipped `.delphi-config.json.example` defaults to three cheap FLASH-tier
40
+ models on one WhaleCloud gateway, which is what most setups want:
41
+
42
+ | seat | model | purpose |
43
+ |------|-------|---------|
44
+ | architecture | `s-deepseek-v4.1-flash` | structure, boundaries, coupling |
45
+ | technical | `s-glm-5.3-flash` | correctness, implementation risk |
46
+ | feasibility | `g-ling-3.1-flash` | cost, schedule, operability |
47
+
48
+ Before trusting a profile, confirm the three ids resolve to three **distinct
49
+ backend** models on your gateway. Gateway aliases can map two different ids to
50
+ the same backend, which satisfies the "distinct ids" check while actually
51
+ running one model twice:
52
+
53
+ ```bash
54
+ # prints the backend each id really reached
55
+ for m in s-deepseek-v4.1-flash s-glm-5.3-flash g-ling-3.1-flash; do
56
+ curl -s https://YOUR_GATEWAY/v1/chat/completions \
57
+ -H "Authorization: Bearer $WHALECLOUD_API_KEY" -H 'Content-Type: application/json' \
58
+ -d "{\"model\":\"$m\",\"messages\":[{\"role\":\"user\",\"content\":\"hi\"}],\"max_tokens\":5}" \
59
+ | python -c 'import sys,json; print(json.load(sys.stdin).get("model"))'
60
+ done
61
+ ```
62
+
63
+ `xp-gate doctor delphi` reports the configured seats, and every expert result
64
+ records the gateway-reported `resolved_model` so a silent alias collision shows
65
+ up in the review evidence rather than passing unnoticed.
66
+
39
67
  ### Step 3: Ensure provider configuration exists
40
68
 
41
69
  Your `opencode.json` must have the provider definitions. If you're using OpenCode's built-in providers (OpenAI, Anthropic, etc.), you just need API keys set in your environment.
@@ -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.36.1.0
6
+ **Version:** 0.37.1.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, 40-67% token savings vs parallel). 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.36.1.0
6
+ **Version:** 0.37.1.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.36.1.0
6
+ **Version:** 0.37.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Clean Code & SOLID principles checker — **Gate 4** of pre-commit. 14 rules × 9 language adapters, SARIF 2.1.0 output. Houses the **Boy Scout Rule** enforcement engine (Gate 6) and warning-baseline storage.
@@ -0,0 +1,106 @@
1
+ /**
2
+ * @test REQ-726
3
+ * @intent 新增 `arch` 配置分组不得破坏既有用户配置。老项目的 .principlesrc 只写了
4
+ * clean-code / solid 两个键,加载后 arch 必须取默认值而不是报错或变 undefined,
5
+ * 否则升级即崩,用户不会去读变更日志。
6
+ * @covers AC-COMPAT-01 AC-COMPAT-02
7
+ */
8
+ import { describe, it, expect, afterEach } from 'vitest';
9
+ import { mkdtempSync, writeFileSync, rmSync } from 'fs';
10
+ import { tmpdir } from 'os';
11
+ import { join } from 'path';
12
+ import { loadConfig } from '../config';
13
+
14
+ /** Chosen to differ from every built-in default, so "it came from the file" is provable. */
15
+ const CUSTOM_LONG_FUNCTION_THRESHOLD = 80;
16
+ /** Likewise: no built-in large-file threshold is 900. */
17
+ const CUSTOM_LARGE_FILE_THRESHOLD = 900;
18
+
19
+ const dirs: string[] = [];
20
+
21
+ /** Write a `.principlesrc` in a throwaway directory and return its path. */
22
+ function configWith(contents: unknown): string {
23
+ const dir = mkdtempSync(join(tmpdir(), 'xp-gate-arch-cfg-'));
24
+ dirs.push(dir);
25
+ const file = join(dir, '.principlesrc');
26
+ try {
27
+ writeFileSync(file, JSON.stringify(contents), 'utf-8');
28
+ } catch (error) {
29
+ throw new Error(`failed to write fixture .principlesrc: ${String(error)}`);
30
+ }
31
+ return file;
32
+ }
33
+
34
+ // Fixtures are built as named step-wise objects rather than deep inline literals:
35
+ // the `deep-nesting` rule counts every brace, so a 4-level config literal nested
36
+ // inside a call reads as 5 levels.
37
+ const LONG_FUNCTION_OVERRIDE = { threshold: CUSTOM_LONG_FUNCTION_THRESHOLD };
38
+ const LEGACY_ONLY_RULES = { 'clean-code': { 'long-function': LONG_FUNCTION_OVERRIDE } };
39
+
40
+ const UTIL_SERVICE_OVERRIDE = { severity: 'info' };
41
+ const PARTIAL_ARCH_RULES = { arch: { 'util-service': UTIL_SERVICE_OVERRIDE } };
42
+
43
+ const LARGE_FILE_OVERRIDE = { threshold: CUSTOM_LARGE_FILE_THRESHOLD };
44
+ const MISSPELT_GROUP_RULES = {
45
+ archx: { whatever: { severity: 'error' } },
46
+ 'clean-code': { 'large-file': LARGE_FILE_OVERRIDE },
47
+ };
48
+
49
+ /** A config that only touches a pre-existing group, as an old user's file would. */
50
+ function legacyOnlyConfig(): string {
51
+ return configWith({ rules: LEGACY_ONLY_RULES });
52
+ }
53
+
54
+ /** A config whose only arch entry is `util-service`. */
55
+ function partialArchConfig(): string {
56
+ return configWith({ rules: PARTIAL_ARCH_RULES });
57
+ }
58
+
59
+ /** A config with a misspelt group name plus one real clean-code override. */
60
+ function typoGroupConfig(): string {
61
+ return configWith({ rules: MISSPELT_GROUP_RULES });
62
+ }
63
+
64
+ afterEach(() => {
65
+ while (dirs.length > 0) {
66
+ const dir = dirs.pop();
67
+ if (dir) rmSync(dir, { recursive: true, force: true });
68
+ }
69
+ });
70
+
71
+ describe('AC-COMPAT-01 — 老配置(无 arch 键)照样工作', () => {
72
+ it('只含 clean-code / solid 时,arch 分组取默认值且不报错', async () => {
73
+ const config = await loadConfig(legacyOnlyConfig());
74
+
75
+ // The two pre-existing groups keep behaving as before...
76
+ expect(config.rules['clean-code']['long-function'].threshold)
77
+ .toBe(CUSTOM_LONG_FUNCTION_THRESHOLD);
78
+ expect(config.rules['solid'].srp).toBeDefined();
79
+ // ...and the new group is fully populated from defaults.
80
+ expect(config.rules.arch.controller.severity).toBe('error');
81
+ expect(config.rules.arch['util-service'].severity).toBe('warning');
82
+ });
83
+
84
+ it('arch 分组存在但只写了一条时,其余仍取默认值', async () => {
85
+ const config = await loadConfig(partialArchConfig());
86
+
87
+ expect(config.rules.arch['util-service'].severity).toBe('info');
88
+ // Siblings are NOT wiped by the partial block -- that fail-open shape is
89
+ // what mergeGroup exists to prevent.
90
+ expect(config.rules.arch.controller.severity).toBe('error');
91
+ expect(config.rules.arch['dto-layering'].severity).toBe('error');
92
+ });
93
+ });
94
+
95
+ describe('AC-COMPAT-02 — 未知分组不崩溃也不吞掉已知分组', () => {
96
+ it('拼错的分组名(archx)不影响 clean-code / solid / arch 的加载', async () => {
97
+ const config = await loadConfig(typoGroupConfig());
98
+
99
+ // The known groups still load...
100
+ expect(config.rules['clean-code']['large-file'].threshold)
101
+ .toBe(CUSTOM_LARGE_FILE_THRESHOLD);
102
+ expect(config.rules.arch.controller.severity).toBe('error');
103
+ // ...and the typo does not become a real group.
104
+ expect((config.rules as Record<string, unknown>).archx).toBeUndefined();
105
+ });
106
+ });
@@ -4,7 +4,7 @@
4
4
  * modules used to snapshot config at module load, so a project's
5
5
  * threshold was silently ignored and the checker enforced the built-in
6
6
  * default instead -- a fail-open gate.
7
- * @covers AC-457-01, AC-457-02, AC-457-03, AC-457-04, AC-457-05, AC-457-06, AC-457-07, AC-457-14, AC-457-15, AC-457-16
7
+ * @covers AC-457-01, AC-457-02, AC-457-03, AC-457-04, AC-457-05, AC-457-06, AC-457-07, AC-457-14, AC-457-15, AC-457-16, AC-457-10, AC-457-11, AC-457-13
8
8
  *
9
9
  * The pre-existing `config.test.ts` asserted only `expect(config).toBeDefined()`
10
10
  * for `loadConfig`, which is why the defect survived: the loader returned the