@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.
- package/adapter-common.sh +12 -2
- package/adapters/csharp.sh +73 -2
- package/adapters/dart.sh +13 -0
- package/adapters/go.sh +5 -0
- package/adapters/iac.sh +46 -3
- package/adapters/java.sh +6 -0
- package/adapters/kotlin.sh +6 -0
- package/adapters/shell.sh +119 -34
- package/adapters/swift.sh +6 -0
- package/adapters/typescript.sh +98 -34
- package/bin/xp-gate.js +48 -2
- package/gate-10.sh +99 -26
- package/gate-12-file-hygiene.sh +13 -1
- package/gate-registry.sh +197 -0
- package/gates/python-health.ts +67 -29
- package/hooks/adapter-common.sh +12 -2
- package/hooks/deploy-manifest.sh +100 -0
- package/hooks/gate-10.sh +99 -26
- package/hooks/gate-12-file-hygiene.sh +13 -1
- package/hooks/gate-driver.sh +120 -0
- package/hooks/gate-entries/gate-0-entry.sh +825 -0
- package/hooks/gate-entries/gate-1-entry.sh +767 -0
- package/hooks/gate-entries/gate-10-entry.sh +52 -0
- package/hooks/gate-entries/gate-11-entry.sh +120 -0
- package/hooks/gate-entries/gate-12-entry.sh +44 -0
- package/hooks/gate-entries/gate-12b-entry.sh +178 -0
- package/hooks/gate-entries/gate-12c-entry.sh +80 -0
- package/hooks/gate-entries/gate-13-entry.sh +584 -0
- package/hooks/gate-entries/gate-2-entry.sh +199 -0
- package/hooks/gate-entries/gate-3-entry.sh +53 -0
- package/hooks/gate-entries/gate-4-entry.sh +46 -0
- package/hooks/gate-entries/gate-5-entry.sh +1729 -0
- package/hooks/gate-entries/gate-6-entry.sh +658 -0
- package/hooks/gate-entries/gate-7-entry.sh +41 -0
- package/hooks/gate-entries/gate-8-entry.sh +33 -0
- package/hooks/gate-entries/gate-9-entry.sh +307 -0
- package/hooks/gate-entries/subdir-restore.sh +27 -0
- package/hooks/gate-registry.sh +51 -15
- package/hooks/hook-module-resolution.sh +73 -0
- package/hooks/install.sh +135 -0
- package/hooks/lib/now-ms.sh +55 -19
- package/hooks/lib/toolchain-path.sh +50 -6
- package/hooks/pre-commit +256 -5091
- package/hooks/pre-push +212 -25
- package/lib/__tests__/arch-config-template.test.js +190 -0
- package/lib/__tests__/baseline-shell-scope.test.js +60 -0
- package/lib/__tests__/crap-cli.test.js +14 -3
- package/lib/__tests__/deploy-manifest-check-wired.test.js +138 -0
- package/lib/__tests__/deploy-manifest-completeness.test.js +151 -0
- package/lib/__tests__/deploy-manifest-consumers-adapter-uninstall.test.js +40 -0
- package/lib/__tests__/deploy-manifest-consumers-no-private-lists.test.js +74 -0
- package/lib/__tests__/deploy-manifest-projection.test.js +66 -0
- package/lib/__tests__/deploy-manifest-shell-parity.test.js +108 -0
- package/lib/__tests__/deploy-manifest.test.js +97 -0
- package/lib/__tests__/doctor.test.js +51 -7
- package/lib/__tests__/gate-coverage.test.js +79 -12
- package/lib/__tests__/gate-numbering.test.js +28 -1
- package/lib/__tests__/install-sh-deploy-manifest.test.js +80 -0
- package/lib/__tests__/mirror-sync.test.js +45 -3
- package/lib/__tests__/npm-package.test.js +10 -7
- package/lib/__tests__/sastd-client.test.js +514 -0
- package/lib/__tests__/shared-utils-copyHooks-manifest.test.js +69 -0
- package/lib/__tests__/sprint-status-rework.test.js +1 -0
- package/lib/arch-config-template.js +87 -0
- package/lib/baseline.js +54 -2
- package/lib/deploy-manifest.js +174 -0
- package/lib/doctor.js +46 -14
- package/lib/gate-capability.js +291 -0
- package/lib/gate-coverage.js +194 -74
- package/lib/gate-identity.js +349 -0
- package/lib/gate-runner.js +11 -1
- package/lib/hook-module-resolution.js +27 -0
- package/lib/init.js +72 -5
- package/lib/mattpocock-license-verdict.json +1 -1
- package/lib/sastd-client.js +572 -0
- package/lib/shared-utils.js +31 -9
- package/lib/uninstall.js +10 -7
- package/lib/update-hooks.js +27 -18
- package/mock-policy/AGENTS.md +1 -1
- package/mutation/AGENTS.md +1 -1
- package/package.json +3 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/package.json +1 -1
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
- package/principles/AGENTS.md +1 -1
- package/principles/__tests__/analyzer.test.ts +2 -1
- package/principles/__tests__/config-enforcement.test.ts +1 -0
- package/principles/__tests__/types.test.ts +1 -0
- package/principles/adapters/base.ts +14 -1
- package/principles/adapters/duplication.ts +134 -0
- package/principles/rules/__tests__/clean-code/large-file.test.ts +2 -1
- package/principles/rules/clean-code/code-duplication.ts +75 -9
- package/principles/types.ts +39 -0
- package/scripts/__tests__/check-mattpocock-license.test.js +36 -3
- package/scripts/__tests__/sync-package-content.test.js +12 -2
- package/scripts/generate-mirrors.cjs +125 -0
- package/scripts/sync-package-content.js +64 -20
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/test-specification-alignment/AGENTS.md +1 -1
- package/adapters/gate-9.sh +0 -245
- package/gate-9.sh +0 -245
- package/hooks/gate-9.sh +0 -245
package/lib/gate-runner.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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 = {
|
|
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
|
+
};
|