@boyingliu01/xp-gate 0.37.3 → 0.38.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 (116) hide show
  1. package/adapter-common.sh +12 -2
  2. package/adapters/csharp.sh +73 -2
  3. package/adapters/dart.sh +13 -0
  4. package/adapters/go.sh +5 -0
  5. package/adapters/iac.sh +46 -3
  6. package/adapters/java.sh +6 -0
  7. package/adapters/kotlin.sh +6 -0
  8. package/adapters/shell.sh +119 -34
  9. package/adapters/swift.sh +6 -0
  10. package/adapters/typescript.sh +98 -34
  11. package/bin/xp-gate.js +48 -2
  12. package/gate-10.sh +99 -26
  13. package/gate-12-file-hygiene.sh +13 -1
  14. package/gate-registry.sh +197 -0
  15. package/gates/python-health.ts +67 -29
  16. package/hooks/adapter-common.sh +12 -2
  17. package/hooks/deploy-manifest.sh +100 -0
  18. package/hooks/gate-10.sh +99 -26
  19. package/hooks/gate-12-file-hygiene.sh +13 -1
  20. package/hooks/gate-driver.sh +120 -0
  21. package/hooks/gate-entries/gate-0-entry.sh +825 -0
  22. package/hooks/gate-entries/gate-1-entry.sh +767 -0
  23. package/hooks/gate-entries/gate-10-entry.sh +52 -0
  24. package/hooks/gate-entries/gate-11-entry.sh +120 -0
  25. package/hooks/gate-entries/gate-12-entry.sh +44 -0
  26. package/hooks/gate-entries/gate-12b-entry.sh +178 -0
  27. package/hooks/gate-entries/gate-12c-entry.sh +80 -0
  28. package/hooks/gate-entries/gate-13-entry.sh +584 -0
  29. package/hooks/gate-entries/gate-2-entry.sh +199 -0
  30. package/hooks/gate-entries/gate-3-entry.sh +53 -0
  31. package/hooks/gate-entries/gate-4-entry.sh +46 -0
  32. package/hooks/gate-entries/gate-5-entry.sh +1729 -0
  33. package/hooks/gate-entries/gate-6-entry.sh +658 -0
  34. package/hooks/gate-entries/gate-7-entry.sh +41 -0
  35. package/hooks/gate-entries/gate-8-entry.sh +33 -0
  36. package/hooks/gate-entries/gate-9-entry.sh +307 -0
  37. package/hooks/gate-entries/subdir-restore.sh +27 -0
  38. package/hooks/gate-registry.sh +51 -15
  39. package/hooks/hook-module-resolution.sh +73 -0
  40. package/hooks/install.sh +135 -0
  41. package/hooks/lib/now-ms.sh +55 -19
  42. package/hooks/lib/toolchain-path.sh +50 -6
  43. package/hooks/pre-commit +256 -5091
  44. package/hooks/pre-push +212 -25
  45. package/lib/__tests__/arch-config-template.test.js +190 -0
  46. package/lib/__tests__/baseline-shell-scope.test.js +60 -0
  47. package/lib/__tests__/crap-cli.test.js +14 -3
  48. package/lib/__tests__/deploy-manifest-check-wired.test.js +138 -0
  49. package/lib/__tests__/deploy-manifest-completeness.test.js +151 -0
  50. package/lib/__tests__/deploy-manifest-consumers-adapter-uninstall.test.js +40 -0
  51. package/lib/__tests__/deploy-manifest-consumers-no-private-lists.test.js +74 -0
  52. package/lib/__tests__/deploy-manifest-projection.test.js +66 -0
  53. package/lib/__tests__/deploy-manifest-shell-parity.test.js +108 -0
  54. package/lib/__tests__/deploy-manifest.test.js +97 -0
  55. package/lib/__tests__/doctor.test.js +51 -7
  56. package/lib/__tests__/gate-coverage.test.js +79 -12
  57. package/lib/__tests__/gate-numbering.test.js +28 -1
  58. package/lib/__tests__/install-sh-deploy-manifest.test.js +80 -0
  59. package/lib/__tests__/mirror-sync.test.js +45 -3
  60. package/lib/__tests__/npm-package.test.js +10 -7
  61. package/lib/__tests__/sastd-client.test.js +514 -0
  62. package/lib/__tests__/shared-utils-copyHooks-manifest.test.js +69 -0
  63. package/lib/__tests__/sprint-status-rework.test.js +1 -0
  64. package/lib/arch-config-template.js +87 -0
  65. package/lib/baseline.js +54 -2
  66. package/lib/deploy-manifest.js +174 -0
  67. package/lib/doctor.js +46 -14
  68. package/lib/gate-capability.js +291 -0
  69. package/lib/gate-coverage.js +194 -74
  70. package/lib/gate-identity.js +349 -0
  71. package/lib/gate-runner.js +11 -1
  72. package/lib/hook-module-resolution.js +27 -0
  73. package/lib/init.js +72 -5
  74. package/lib/mattpocock-license-verdict.json +1 -1
  75. package/lib/sastd-client.js +572 -0
  76. package/lib/shared-utils.js +31 -9
  77. package/lib/uninstall.js +10 -7
  78. package/lib/update-hooks.js +27 -18
  79. package/mock-policy/AGENTS.md +1 -1
  80. package/mutation/AGENTS.md +1 -1
  81. package/package.json +3 -1
  82. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  83. package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
  84. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
  85. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
  86. package/plugins/dsh/package.json +1 -1
  87. package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
  88. package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
  89. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
  90. package/plugins/opencode/package.json +1 -1
  91. package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
  92. package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
  93. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
  94. package/plugins/qoder/plugin.json +1 -1
  95. package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
  96. package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
  97. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
  98. package/principles/AGENTS.md +1 -1
  99. package/principles/__tests__/analyzer.test.ts +2 -1
  100. package/principles/__tests__/config-enforcement.test.ts +1 -0
  101. package/principles/__tests__/types.test.ts +1 -0
  102. package/principles/adapters/base.ts +14 -1
  103. package/principles/adapters/duplication.ts +134 -0
  104. package/principles/rules/__tests__/clean-code/large-file.test.ts +2 -1
  105. package/principles/rules/clean-code/code-duplication.ts +75 -9
  106. package/principles/types.ts +39 -0
  107. package/scripts/__tests__/check-mattpocock-license.test.js +36 -3
  108. package/scripts/__tests__/sync-package-content.test.js +12 -2
  109. package/scripts/generate-mirrors.cjs +125 -0
  110. package/scripts/sync-package-content.js +64 -20
  111. package/skills/delphi-review/AGENTS.md +1 -1
  112. package/skills/sprint-flow/AGENTS.md +1 -1
  113. package/skills/test-specification-alignment/AGENTS.md +1 -1
  114. package/adapters/gate-9.sh +0 -245
  115. package/gate-9.sh +0 -245
  116. package/hooks/gate-9.sh +0 -245
@@ -860,7 +860,17 @@ async function runGate(gateId, targetPath, opts = {}) {
860
860
  console.log(`⏭️ SKIPPED - ${gate.reason}`);
861
861
  console.log(' This gate runs automatically during git commit.');
862
862
  console.log(' Run: git commit to trigger all gates.');
863
- return 0;
863
+ // #778: return the sentinel, NOT 0. This branch used to `return 0` while the
864
+ // branch 340 lines above returns GATE_NOT_RUN for the same meaning ("nothing
865
+ // ran"). bin/xp-gate.js then maps the sentinel to exit 2 precisely so a gate
866
+ // that never executed cannot exit like a gate that ran clean -- and this
867
+ // branch walked straight past that guarantee for seven of the fourteen
868
+ // pre-commit gates. One file, two opposite answers to one question.
869
+ //
870
+ // Callers that legitimately treat "not run" as success (check.js, for a gate
871
+ // with nothing to analyse) already coerce the sentinel explicitly; making the
872
+ // coercion visible at each call site is the point, not an inconvenience.
873
+ return GATE_NOT_RUN;
864
874
  }
865
875
 
866
876
  if (gate.run) {
@@ -131,9 +131,36 @@ const ADAPTER_DIR_ORDER = Object.freeze([
131
131
  */
132
132
  const GATE_PROBE = 'gate-3.sh';
133
133
 
134
+ /**
135
+ * Schema version of this module's contract (REQ-RESOLVE-003, P1-C).
136
+ *
137
+ * WHY A VERSION AND NOT JUST THE DATA
138
+ * -----------------------------------
139
+ * The shell projection used to carry data only: four `HOOK_*` arrays and zero
140
+ * functions. Every consumer therefore wrote its own resolution loop, and
141
+ * pre-push's hand-written loop ordered the tiers GLOBAL-first while
142
+ * ADAPTER_DIR_ORDER says PROJECT-first — the exact defect P1-C exists to fix.
143
+ * Data cannot prevent a second implementation of the traversal; a function can,
144
+ * because there is nothing left to re-implement.
145
+ *
146
+ * Schema 2 adds to schema 1:
147
+ * - `HOOK_RESOLUTION_SCHEMA=<n>` in the projection, so a consumer (or an
148
+ * upgrade path) can detect an old file without guessing at its shape.
149
+ * - `_hook_resolve` — the single traversal implementation.
150
+ * - `_hook_resolve_selfcheck` — a load-time contract check. A file whose
151
+ * syntax is valid and whose function exists but whose behaviour is wrong
152
+ * would otherwise fail mid-push at whatever call site happens to run first;
153
+ * the selfcheck turns that into a deterministic failure at source time.
154
+ *
155
+ * BUMPING THIS IS A BREAKING CHANGE for any consumer holding the old shape.
156
+ * update-hooks/install report an upgrade path for `HOOK_RESOLUTION_SCHEMA < 2`.
157
+ */
158
+ const HOOK_RESOLUTION_SCHEMA = 2;
159
+
134
160
  module.exports = {
135
161
  RESOLUTION_ORDER,
136
162
  GATE_RESOLUTION_ORDER,
137
163
  ADAPTER_DIR_ORDER,
138
164
  GATE_PROBE,
165
+ HOOK_RESOLUTION_SCHEMA,
139
166
  };
package/lib/init.js CHANGED
@@ -3,6 +3,7 @@ const path = require('path');
3
3
  const crypto = require('crypto');
4
4
  const { checkDeps, checkBash, autoInstallDeps, detectPlatform, GATE_CLI_TOOLS, checkCliTool } = require('./detect-deps.js');
5
5
  const { copyHooks, copyAdapters } = require('./shared-utils.js');
6
+ const { ARCH_CONFIG_TEMPLATE, CONFIG_FILENAME: ARCH_CONFIG_FILENAME } = require('./arch-config-template.js');
6
7
  const {
7
8
  HOME_DIR,
8
9
  CONFIG_DIR,
@@ -142,8 +143,10 @@ function generateManifest(srcDir, projectRoot) {
142
143
  const hooksDir = path.join(gitDir, 'hooks');
143
144
  const githooksDir = path.join(projectRoot, 'githooks');
144
145
 
145
- // Hooks
146
- ['pre-commit', 'pre-push', 'post-merge'].forEach(hook => {
146
+ // Hooks. The list is the deploy manifest's (REQ-DEPLOY-001): recording a
147
+ // different set than the installer writes would make the recorded manifest
148
+ // describe a repository that does not exist.
149
+ require('./deploy-manifest.js').HOOK_FILES.forEach(hook => {
147
150
  const hookPath = path.join(hooksDir, hook);
148
151
  if (fs.existsSync(hookPath)) {
149
152
  const stat = fs.statSync(hookPath);
@@ -203,8 +206,8 @@ function generateGlobalManifest(srcDir) {
203
206
  gitConfig: {}
204
207
  };
205
208
 
206
- // Global hooks
207
- ['pre-commit', 'pre-push', 'post-merge'].forEach(hook => {
209
+ // Global hooks (same manifest list as above, REQ-DEPLOY-001)
210
+ require('./deploy-manifest.js').HOOK_FILES.forEach(hook => {
208
211
  const hookPath = path.join(GLOBAL_HOOKS_DIR, hook);
209
212
  if (fs.existsSync(hookPath)) {
210
213
  const stat = fs.statSync(hookPath);
@@ -647,6 +650,50 @@ async function detectAndReportLanguages(projectRoot, autoYes) {
647
650
  console.log(`\n Generated .xp-gate-config.json`);
648
651
  }
649
652
 
653
+ /**
654
+ * Write the default architecture config so Gate 6's precondition holds
655
+ * (REQ-DEPLOY-003).
656
+ *
657
+ * Gate 6 blocks any commit in a project without an architecture config file
658
+ * (githooks/pre-commit:4838), and it decides this purely by file existence —
659
+ * it never parses the contents. Without this step `xp-gate init` installs every
660
+ * gate successfully and then blocks the user's first commit for a reason that
661
+ * has nothing to do with their code.
662
+ *
663
+ * PROJECT-LEVEL ONLY. Global installs must not write this: the file describes a
664
+ * project's own architecture, so putting it in the user's HOME would turn
665
+ * something project-scoped into a machine-wide side effect (user decision,
666
+ * sprint-20261110-33). setupGlobal therefore never calls this.
667
+ *
668
+ * NEVER OVERWRITES. An existing architecture.yaml, .architecturerc or
669
+ * .archlint.yaml means the project already made this decision.
670
+ *
671
+ * @param {string} projectRoot
672
+ */
673
+ function ensureArchConfig(projectRoot) {
674
+ const existing = ['architecture.yaml', '.architecturerc', ARCH_CONFIG_FILENAME]
675
+ .find((name) => fs.existsSync(path.join(projectRoot, name)));
676
+
677
+ if (existing) {
678
+ console.log(` architecture config: kept existing ${existing}`);
679
+ return;
680
+ }
681
+
682
+ const target = path.join(projectRoot, ARCH_CONFIG_FILENAME);
683
+ try {
684
+ fs.writeFileSync(target, ARCH_CONFIG_TEMPLATE, 'utf8');
685
+ // Say what it does and does not do. A file that appears without explanation
686
+ // reads as "architecture is configured" — the exact false confidence this
687
+ // template is written to avoid.
688
+ console.log(` architecture config: created ${ARCH_CONFIG_FILENAME} (no rule overrides — archlint defaults apply)`);
689
+ } catch (err) {
690
+ // Non-fatal: the install itself succeeded. The user can create the file, and
691
+ // Gate 6's own message already tells them how.
692
+ console.warn(` architecture config: could NOT create ${ARCH_CONFIG_FILENAME} (${err.message})`);
693
+ console.warn(` Gate 6 will block commits until an architecture config exists.`);
694
+ }
695
+ }
696
+
650
697
  async function installLocal(args) {
651
698
  const gitDir = getGitDir();
652
699
  if (!gitDir) {
@@ -694,6 +741,7 @@ async function installLocal(args) {
694
741
  const manifest = generateManifest(srcDir, projectRoot);
695
742
  updateConfig({ lastInit: new Date().toISOString(), mode: 'local', templateDir: TEMPLATE_DIR, manifest });
696
743
 
744
+ ensureArchConfig(projectRoot);
697
745
  injectKarpathyPrinciples(projectRoot);
698
746
  configureOpenCodePlugin(srcDir, projectRoot);
699
747
  deployQoderDelphiAgents(srcDir, projectRoot);
@@ -1120,4 +1168,23 @@ function injectKarpathyPrinciples(projectRoot) {
1120
1168
  // setupGlobal is exported so the global-install wiring (agents deployed to the
1121
1169
  // real HOME) can be audited under a sandboxed HOME, not just asserted to exist
1122
1170
  // — the historical miss was "local deployed, global did not" (#417, #429).
1123
- module.exports = { init, promptBootstrap, installModuleRuntimeDeps, deployQoderDelphiAgents, configureQoderDelphiAgents, readQoderModelId, setupGlobal, probeGitleaksNotice, ensureGitignoreEntries, gitignoreEntriesForInit };
1171
+ module.exports = {
1172
+ init,
1173
+ promptBootstrap,
1174
+ installModuleRuntimeDeps,
1175
+ deployQoderDelphiAgents,
1176
+ configureQoderDelphiAgents,
1177
+ readQoderModelId,
1178
+ setupGlobal,
1179
+ probeGitleaksNotice,
1180
+ ensureGitignoreEntries,
1181
+ gitignoreEntriesForInit,
1182
+ // Exported so the install paths can be exercised directly. `init()` spends most
1183
+ // of its time probing and auto-installing CLI tools, which makes an end-to-end
1184
+ // test of WHAT GETS WRITTEN both slow and dependent on the machine's tool set
1185
+ // (demonstrated: `init --core-only --yes` did not finish in 120s on a machine
1186
+ // whose dependency probe was slow). The file-writing contract needs to be
1187
+ // testable without that.
1188
+ installLocal,
1189
+ ensureArchConfig,
1190
+ };
@@ -2,6 +2,6 @@
2
2
  "verdict": "PASS",
3
3
  "license_type": "MIT",
4
4
  "sha256": "0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5",
5
- "checked_at": "2026-11-09T08:46:31.604Z",
5
+ "checked_at": "2026-11-12T06:13:24.150Z",
6
6
  "source": "network"
7
7
  }