@boyingliu01/xp-gate 0.38.126 → 0.39.0
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/README.md +93 -0
- package/adapters/gate-3.sh +13 -2
- package/adapters/python.sh +36 -38
- package/bin/xp-gate.js +11 -0
- package/build-integrity/gate-10-lines.ts +98 -0
- package/build-integrity/gate-10.ts +98 -109
- package/build-integrity/quote-masker.ts +17 -3
- package/gate-3.sh +13 -2
- package/gates/common-process.ts +116 -34
- package/gates/common.ts +51 -15
- package/gates/gate-3.ts +166 -61
- package/gates/gate-8.ts +76 -24
- package/gates/gate-9.ts +276 -82
- package/gates/pbt-detect.ts +70 -39
- package/gates/python-health.ts +236 -98
- package/gates/test-layers.ts +103 -30
- package/hooks/gate-3.sh +13 -2
- package/hooks/gate-entries/gate-1-entry.sh +10 -1
- package/hooks/gate-entries/gate-5-entry.sh +5 -1
- package/hooks/lib/validate-code-walkthrough.cjs +324 -99
- package/hooks/pre-commit +52 -0
- package/hooks/pre-push +54 -3
- package/lib/agent-runtime-journal.js +104 -37
- package/lib/arch.js +6 -0
- package/lib/baseline.js +329 -201
- package/lib/check.js +38 -2
- package/lib/doctor-constants.js +43 -0
- package/lib/doctor.js +2008 -1001
- package/lib/flaky.js +178 -79
- package/lib/gate-runner.js +110 -63
- package/lib/init.js +6 -0
- package/lib/language-capability-surfaces.js +5 -2
- package/lib/language-registry.js +608 -0
- package/lib/language-tools.js +487 -1018
- package/lib/phase-transition.js +646 -446
- package/lib/prepush-evidence.js +174 -0
- package/lib/sprint-audit.js +52 -22
- package/lib/sprint-discovery.js +66 -35
- package/lib/sprint-format.js +114 -0
- package/lib/sprint-init.js +372 -118
- package/lib/sprint-status.js +134 -90
- package/lib/star-notice.js +346 -0
- package/lib/tool-display.js +52 -0
- package/lib/tool-install.js +179 -0
- package/lib/uninstall.js +331 -188
- package/mock-policy/gate-m3.ts +74 -23
- package/mock-policy/mock-decision-engine.ts +21 -7
- package/mock-policy/scope-scanner.ts +128 -69
- package/mutation/detect-ai-test.ts +20 -12
- package/mutation/gate-m.ts +6 -2
- package/mutation/init-baseline.ts +49 -13
- package/mutation/runners/go-mutant-runner.ts +7 -49
- package/mutation/runners/gremlins-runner.ts +53 -18
- package/mutation/runners/mutmut-runner.ts +455 -163
- package/mutation/runners/pitest-runner.ts +85 -131
- package/mutation/runners/spawn-with-capture.ts +304 -0
- package/mutation/runners/stryker-runner.ts +14 -55
- package/mutation/update-baseline.ts +25 -18
- package/package.json +20 -8
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/bin/delphi-review-guard.sh +12 -61
- package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +6 -11
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/reinstall-xp-gate/.architecture-skip +8 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/.github/workflows/test.yml +106 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/CHANGELOG.md +379 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/LICENSE +21 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/QUALITY-OVERVIEW.md +173 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/README.md +167 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/SKILL.md +271 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/TODO.md +253 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/VERSION +1 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/package.json +28 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/audit.mjs +193 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/coverage.mjs +140 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/hp-gate.mjs +175 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/install.mjs +64 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/agent-paths.mjs +67 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/agents.mjs +247 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/backups.mjs +96 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/baseline.mjs +101 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/ccn.mjs +124 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/delphi.mjs +61 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/fs-tree.mjs +108 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/gatecheck.mjs +290 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/json-file.mjs +37 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/mutations.mjs +154 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/platform.mjs +92 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/probes.mjs +102 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/proc.mjs +33 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/report.mjs +29 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/residue.mjs +188 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/selfsync.mjs +75 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/skills.mjs +121 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/spawn.mjs +161 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/testreport.mjs +26 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/tools.mjs +238 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/util.mjs +33 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/verdict.mjs +45 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/version.mjs +29 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/xp-cli.mjs +66 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/mutation.mjs +132 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/preflight.mjs +75 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/reinstall.mjs +297 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/setup-wsl.sh +633 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/verify.mjs +222 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/agents.test.mjs +168 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/baseline.test.mjs +104 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/ccn.test.mjs +87 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/cleanup.test.mjs +128 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/coverage.test.mjs +69 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/delphi.test.mjs +78 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/fixtures.mjs +61 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/gatecheck-audit.test.mjs +157 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/gatecheck.test.mjs +57 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/mutation-anchors.test.mjs +49 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/proc-contract.test.mjs +58 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/proc.test.mjs +243 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/report.test.mjs +66 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/residue.test.mjs +278 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/selfsync.test.mjs +70 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/skills.test.mjs +171 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/testreport.test.mjs +40 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/timeout-budgets.test.mjs +38 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools-leaf.test.mjs +323 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools-probe.test.mjs +350 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools.test.mjs +131 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/util.test.mjs +154 -0
- 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/scripts/prepack.cjs +43 -18
- package/plugins/dsh/scripts/verify-skill-provider.mjs +39 -14
- package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +6 -11
- 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/index.ts +337 -123
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/scripts/prepack.cjs +41 -16
- package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +6 -11
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/reinstall-xp-gate/.architecture-skip +8 -0
- package/plugins/opencode/skills/reinstall-xp-gate/.github/workflows/test.yml +106 -0
- package/plugins/opencode/skills/reinstall-xp-gate/CHANGELOG.md +379 -0
- package/plugins/opencode/skills/reinstall-xp-gate/LICENSE +21 -0
- package/plugins/opencode/skills/reinstall-xp-gate/QUALITY-OVERVIEW.md +173 -0
- package/plugins/opencode/skills/reinstall-xp-gate/README.md +167 -0
- package/plugins/opencode/skills/reinstall-xp-gate/SKILL.md +271 -0
- package/plugins/opencode/skills/reinstall-xp-gate/TODO.md +253 -0
- package/plugins/opencode/skills/reinstall-xp-gate/VERSION +1 -0
- package/plugins/opencode/skills/reinstall-xp-gate/package.json +28 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/audit.mjs +193 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/coverage.mjs +140 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/hp-gate.mjs +175 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/install.mjs +64 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/agent-paths.mjs +67 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/agents.mjs +247 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/backups.mjs +96 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/baseline.mjs +101 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/ccn.mjs +124 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/delphi.mjs +61 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/fs-tree.mjs +108 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/gatecheck.mjs +290 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/json-file.mjs +37 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/mutations.mjs +154 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/platform.mjs +92 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/probes.mjs +102 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/proc.mjs +33 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/report.mjs +29 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/residue.mjs +188 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/selfsync.mjs +75 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/skills.mjs +121 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/spawn.mjs +161 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/testreport.mjs +26 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/tools.mjs +238 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/util.mjs +33 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/verdict.mjs +45 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/version.mjs +29 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/xp-cli.mjs +66 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/mutation.mjs +132 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/preflight.mjs +75 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/reinstall.mjs +297 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/setup-wsl.sh +633 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/verify.mjs +222 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/agents.test.mjs +168 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/baseline.test.mjs +104 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/ccn.test.mjs +87 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/cleanup.test.mjs +128 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/coverage.test.mjs +69 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/delphi.test.mjs +78 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/fixtures.mjs +61 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/gatecheck-audit.test.mjs +157 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/gatecheck.test.mjs +57 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/mutation-anchors.test.mjs +49 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/proc-contract.test.mjs +58 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/proc.test.mjs +243 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/report.test.mjs +66 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/residue.test.mjs +278 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/selfsync.test.mjs +70 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/skills.test.mjs +171 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/testreport.test.mjs +40 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/timeout-budgets.test.mjs +38 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/tools-leaf.test.mjs +323 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/tools-probe.test.mjs +350 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/tools.test.mjs +131 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/util.test.mjs +154 -0
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/bin/sprint-flow-guard.sh +12 -60
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +6 -11
- 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/plugins/shared/README.md +3 -0
- package/plugins/shared/bin/delphi-review-guard.sh +68 -0
- package/principles/adapters/control-nesting.ts +481 -168
- package/principles/adapters/cpp.ts +61 -22
- package/principles/adapters/csharp.ts +183 -66
- package/principles/adapters/dart.ts +11 -1
- package/principles/adapters/duplication.ts +49 -16
- package/principles/adapters/import-clause.ts +62 -15
- package/principles/adapters/java.ts +199 -70
- package/principles/adapters/line-comment.ts +18 -0
- package/principles/adapters/member-scan.ts +50 -8
- package/principles/adapters/php.ts +232 -103
- package/principles/adapters/python.ts +25 -18
- package/principles/adapters/quote-state.ts +21 -8
- package/principles/adapters/typescript-mask.ts +276 -0
- package/principles/adapters/typescript.ts +206 -200
- package/principles/analyzer.ts +16 -6
- package/principles/baseline-prune.ts +18 -8
- package/principles/baseline.ts +28 -11
- package/principles/boy-scout-usage.ts +26 -0
- package/principles/boy-scout.ts +261 -180
- package/principles/config.ts +183 -57
- package/principles/direct-execution.ts +24 -12
- package/principles/lint-baseline.ts +235 -122
- package/principles/rules/arch/dependency.ts +34 -25
- package/principles/rules/arch/shared.ts +24 -20
- package/principles/rules/clean-code/deep-nesting.ts +23 -13
- package/principles/rules/clean-code/god-class.ts +67 -41
- package/principles/rules/clean-code/large-file.ts +30 -23
- package/principles/rules/clean-code/long-function.ts +51 -37
- package/principles/rules/clean-code/magic-numbers.ts +51 -36
- package/principles/rules/clean-code/many-exports.ts +46 -29
- package/principles/rules/clean-code/missing-error-handling.ts +38 -20
- package/principles/rules/clean-code/too-many-params.ts +41 -22
- package/principles/rules/function-source.ts +62 -0
- package/principles/rules/solid/dip.ts +10 -6
- package/principles/rules/solid/isp.ts +64 -24
- package/principles/rules/solid/lsp.ts +66 -18
- package/principles/rules/solid/ocp.ts +29 -13
- package/principles/rules/solid/srp.ts +34 -18
- package/principles/warnings-count.ts +43 -0
- package/scripts/__tests__/prepush-source-classification.test.js +129 -0
- package/scripts/delphi-config-read.cjs +245 -0
- package/scripts/delphi-external-review.cjs +410 -585
- package/scripts/delphi-json-extract.cjs +108 -0
- package/scripts/delphi-model-validation.cjs +297 -0
- package/scripts/delphi-prompts.cjs +55 -0
- package/scripts/delphi-repo-tools.cjs +273 -0
- package/scripts/delphi-seat-calibration.cjs +204 -0
- package/scripts/run-bats-ci.cjs +240 -97
- package/scripts/sync-package-content.js +18 -2
- package/skills/delphi-review/.delphi-config.json.example +6 -11
- 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/lib/__tests__/agent-runtime-journal.test.js +0 -326
- package/lib/__tests__/arch-config-template.test.js +0 -190
- package/lib/__tests__/arch.test.js +0 -430
- package/lib/__tests__/assertion-debt.test.js +0 -99
- package/lib/__tests__/audit-cli-contract.test.ts +0 -117
- package/lib/__tests__/audit-log.test.ts +0 -107
- package/lib/__tests__/audit-skip-reasons.test.ts +0 -143
- package/lib/__tests__/baseline-completeness.test.js +0 -264
- package/lib/__tests__/baseline-shell-scope.test.js +0 -60
- package/lib/__tests__/baseline-unevaluated.test.js +0 -142
- package/lib/__tests__/baseline.test.js +0 -212
- package/lib/__tests__/bootstrap.test.js +0 -60
- package/lib/__tests__/check-alignment-cli.test.mjs +0 -94
- package/lib/__tests__/check-alignment-reasons.test.mjs +0 -101
- package/lib/__tests__/check-all-skip-accounting.test.js +0 -171
- package/lib/__tests__/check-changed-brief.test.js +0 -63
- package/lib/__tests__/check-normalize-exit.test.js +0 -24
- package/lib/__tests__/check-single-file.test.js +0 -114
- package/lib/__tests__/check-tools-list.test.js +0 -155
- package/lib/__tests__/check-version.test.js +0 -463
- package/lib/__tests__/coverage-scope.test.js +0 -140
- package/lib/__tests__/coverage-threshold.test.js +0 -80
- package/lib/__tests__/crap-cli.test.js +0 -87
- package/lib/__tests__/crap.test.js +0 -494
- package/lib/__tests__/debt-classify.test.js +0 -78
- package/lib/__tests__/delphi-channel-doctor.test.js +0 -116
- package/lib/__tests__/delphi-channel-uninstall.test.js +0 -128
- package/lib/__tests__/delphi-channel.test.js +0 -109
- package/lib/__tests__/delphi-setup.test.js +0 -203
- package/lib/__tests__/deploy-manifest-check-wired.test.js +0 -138
- package/lib/__tests__/deploy-manifest-completeness.test.js +0 -151
- package/lib/__tests__/deploy-manifest-consumers-adapter-uninstall.test.js +0 -40
- package/lib/__tests__/deploy-manifest-consumers-no-private-lists.test.js +0 -74
- package/lib/__tests__/deploy-manifest-projection.test.js +0 -66
- package/lib/__tests__/deploy-manifest-shell-parity.test.js +0 -108
- package/lib/__tests__/deploy-manifest.test.js +0 -97
- package/lib/__tests__/detect-deps-dsh-profile.test.js +0 -323
- package/lib/__tests__/detect-deps-gate-identity.test.js +0 -135
- package/lib/__tests__/detect-deps.test.js +0 -655
- package/lib/__tests__/doctor-469-hook-env.test.js +0 -211
- package/lib/__tests__/doctor-arch-tools.test.js +0 -169
- package/lib/__tests__/doctor-audit-ledger.test.js +0 -61
- package/lib/__tests__/doctor-brief.test.js +0 -59
- package/lib/__tests__/doctor-delphi.test.js +0 -628
- package/lib/__tests__/doctor-drift-direction.test.js +0 -104
- package/lib/__tests__/doctor-drift-round2.test.js +0 -215
- package/lib/__tests__/doctor-exec-retry.test.js +0 -162
- package/lib/__tests__/doctor-executed-surface.test.js +0 -230
- package/lib/__tests__/doctor-helpers.test.js +0 -139
- package/lib/__tests__/doctor-hook-drift.test.js +0 -329
- package/lib/__tests__/doctor-hook-signatures.test.js +0 -65
- package/lib/__tests__/doctor-machine-mutation.test.js +0 -116
- package/lib/__tests__/doctor-module-drift.test.js +0 -212
- package/lib/__tests__/doctor-module-resolution-parity.test.js +0 -463
- package/lib/__tests__/doctor-path-equivalence.test.js +0 -70
- package/lib/__tests__/doctor-repair-boundary.test.js +0 -52
- package/lib/__tests__/doctor-signature-stability.test.js +0 -55
- package/lib/__tests__/doctor-spawn-capability.test.js +0 -116
- package/lib/__tests__/doctor-timeout-partial.test.js +0 -79
- package/lib/__tests__/doctor-tool-delegation.test.js +0 -156
- package/lib/__tests__/doctor-tui-skill-freshness.test.js +0 -385
- package/lib/__tests__/doctor.test.js +0 -1320
- package/lib/__tests__/find-bash-wsl.test.js +0 -121
- package/lib/__tests__/flaky.test.js +0 -128
- package/lib/__tests__/foreign-hooks-global.test.js +0 -125
- package/lib/__tests__/gate-audit-skip.test.ts +0 -81
- package/lib/__tests__/gate-audit.test.ts +0 -440
- package/lib/__tests__/gate-coverage-hook-floor.test.js +0 -94
- package/lib/__tests__/gate-coverage.test.js +0 -204
- package/lib/__tests__/gate-entry-provenance.test.js +0 -71
- package/lib/__tests__/gate-numbering.test.js +0 -79
- package/lib/__tests__/gate-rules.test.js +0 -58
- package/lib/__tests__/gate-runner-tsx-invocation.test.js +0 -149
- package/lib/__tests__/gate-runner-verdict.test.js +0 -105
- package/lib/__tests__/gate-runner.test.js +0 -371
- package/lib/__tests__/gate2-verdict.test.js +0 -183
- package/lib/__tests__/helpers/lib-sandbox.cjs +0 -55
- package/lib/__tests__/hook-health-path.test.js +0 -109
- package/lib/__tests__/hook-health.test.js +0 -85
- package/lib/__tests__/init-gitignore.test.js +0 -204
- package/lib/__tests__/init-gitleaks-notice.test.js +0 -57
- package/lib/__tests__/init.test.js +0 -530
- package/lib/__tests__/install-cmd.test.js +0 -6
- package/lib/__tests__/install-sh-deploy-manifest.test.js +0 -80
- package/lib/__tests__/install-skill-full-dir.test.js +0 -194
- package/lib/__tests__/install-skill.test.js +0 -416
- package/lib/__tests__/install-tools-repair.test.js +0 -263
- package/lib/__tests__/issue-519-phase-transition-guard.test.js +0 -233
- package/lib/__tests__/issue-566-sync-hooks-backup.test.js +0 -228
- package/lib/__tests__/issue-583-hook-deploy-log.test.js +0 -121
- package/lib/__tests__/issue-586-principles-cmdline.test.js +0 -218
- package/lib/__tests__/issue-589-check-all-gate3.test.js +0 -190
- package/lib/__tests__/issue-590-archlint-vacuous-pass.test.js +0 -138
- package/lib/__tests__/issue-618-gate-not-run.test.js +0 -100
- package/lib/__tests__/jscpd-entry-resolution.test.js +0 -143
- package/lib/__tests__/language-capability.test.js +0 -318
- package/lib/__tests__/language-tools-build-file-install.test.js +0 -82
- package/lib/__tests__/language-tools-detect.test.js +0 -301
- package/lib/__tests__/migrate.test.js +0 -232
- package/lib/__tests__/mirror-manifest.test.js +0 -64
- package/lib/__tests__/mirror-sync.test.js +0 -803
- package/lib/__tests__/next-sprint.test.js +0 -231
- package/lib/__tests__/npm-package.test.js +0 -140
- package/lib/__tests__/phase-transition.test.js +0 -1136
- package/lib/__tests__/principles-csharp-coverage.test.js +0 -227
- package/lib/__tests__/principles-directory.test.js +0 -87
- package/lib/__tests__/qoder-delphi-agents.test.js +0 -316
- package/lib/__tests__/retro-gate-m.test.js +0 -144
- package/lib/__tests__/retro.test.js +0 -131
- package/lib/__tests__/rework.test.js +0 -127
- package/lib/__tests__/rollback.test.js +0 -183
- package/lib/__tests__/runtime-journal.test.js +0 -164
- package/lib/__tests__/sastd-client.test.js +0 -514
- package/lib/__tests__/shared-paths-lazy-home.test.js +0 -67
- package/lib/__tests__/shared-paths.test.js +0 -130
- package/lib/__tests__/shared-utils-copyHooks-manifest.test.js +0 -69
- package/lib/__tests__/shared-utils.test.js +0 -180
- package/lib/__tests__/skill-flags.test.js +0 -48
- package/lib/__tests__/slo.test.js +0 -89
- package/lib/__tests__/sprint-audit.test.js +0 -207
- package/lib/__tests__/sprint-discovery.test.ts +0 -366
- package/lib/__tests__/sprint-state-manager.test.js +0 -310
- package/lib/__tests__/sprint-status-rework-704.test.js +0 -149
- package/lib/__tests__/sprint-status-rework.test.js +0 -329
- package/lib/__tests__/sprint-status.test.js +0 -193
- package/lib/__tests__/sprint-status.test.ts +0 -213
- package/lib/__tests__/test-alignment-java-702.test.ts +0 -177
- package/lib/__tests__/test-alignment-range-guard.test.ts +0 -82
- package/lib/__tests__/test-alignment.test.ts +0 -853
- package/lib/__tests__/tool-audit-collect.test.js +0 -184
- package/lib/__tests__/tool-audit-fixtures.js +0 -87
- package/lib/__tests__/tool-audit-latest.test.js +0 -84
- package/lib/__tests__/tool-audit.test.js +0 -428
- package/lib/__tests__/tsconfig.json +0 -8
- package/lib/__tests__/tsx-resolution.test.js +0 -89
- package/lib/__tests__/ui-detector.test.ts +0 -459
- package/lib/__tests__/ui-review.test.ts +0 -132
- package/lib/__tests__/uninstall-global-residue.test.js +0 -545
- package/lib/__tests__/uninstall-skill.test.js +0 -189
- package/lib/__tests__/uninstall.test.js +0 -717
- package/lib/__tests__/update-hooks.test.js +0 -737
- package/lib/__tests__/update-skill-flags.test.js +0 -78
- package/lib/__tests__/update-skill.test.js +0 -644
- package/lib/__tests__/upgrade-exec.test.js +0 -273
- package/lib/__tests__/upgrade-skill-sync.test.js +0 -65
- package/lib/__tests__/upgrade.test.js +0 -78
- package/lib/__tests__/windows-bash-probe.test.js +0 -123
- package/lib/check-alignment-runner.cjs +0 -97
- package/lib/coverage-total.sh +0 -92
- package/lib/layer-baseline.cjs +0 -94
- package/lib/mattpocock-license-verdict.json +0 -7
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test REQ-568 `check --all` must not count a gate it never ran as passed
|
|
3
|
-
* @intent Gate 5's own output already distinguishes four states — PASS, WARN,
|
|
4
|
-
* SKIP and FAIL — and `xp-gate check --all` collapses them into two:
|
|
5
|
-
* `code !== 0` is a failure, everything else is a pass. A gate whose
|
|
6
|
-
* registry entry is `preCommitOnly` prints
|
|
7
|
-
*
|
|
8
|
-
* ⏭️ SKIPPED - <reason>
|
|
9
|
-
* return 0;
|
|
10
|
-
*
|
|
11
|
-
* and that 0 is counted as a pass, so 15 registered gates report as
|
|
12
|
-
* `10/10 gate(s) passed` with exit 0. Measured on the registry:
|
|
13
|
-
*
|
|
14
|
-
* total gates : 15
|
|
15
|
-
* preCommitOnly : 5 (ids 0, 1, 5, 10, 11)
|
|
16
|
-
* check --all runs : 10
|
|
17
|
-
*
|
|
18
|
-
* The user-visible number is therefore true about the ten gates that
|
|
19
|
-
* ran and silent about the five that did not. `verdict: PARTIAL` in the
|
|
20
|
-
* hook's own report exists for the same reason; the CLI had no such
|
|
21
|
-
* notion. This is report §5 phase-0 action 0.2.
|
|
22
|
-
* @covers AC-568-01, AC-568-02, AC-568-03, AC-568-04
|
|
23
|
-
*/
|
|
24
|
-
const gateRunner = require('../gate-runner.js');
|
|
25
|
-
const { checkAllGates, formatGateTally } = require('../check.js');
|
|
26
|
-
|
|
27
|
-
const { GATE_REGISTRY } = gateRunner;
|
|
28
|
-
|
|
29
|
-
/** Original registry contents, restored after every test. */
|
|
30
|
-
let ORIGINAL_REGISTRY;
|
|
31
|
-
|
|
32
|
-
// Gate ids the CLI's `check --all` path should never treat as "passed" without
|
|
33
|
-
// saying so. The five real preCommitOnly ids from the shipped registry.
|
|
34
|
-
const PRECOMMIT_ONLY = ['0', '1', '5', '10', '11'];
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Swap every key in GATE_REGISTRY for the supplied object's keys.
|
|
38
|
-
* @param {object} next - registry contents to install
|
|
39
|
-
*/
|
|
40
|
-
function replaceRegistry(next) {
|
|
41
|
-
for (const id of Object.keys(GATE_REGISTRY)) delete GATE_REGISTRY[id];
|
|
42
|
-
for (const [id, info] of Object.entries(next)) GATE_REGISTRY[id] = info;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Replace the registry with a controlled set of stub gates.
|
|
47
|
-
*
|
|
48
|
-
* The registry is swapped WHOLESALE, not added to: `getAllGates()` maps every
|
|
49
|
-
* entry, so leaving the real fifteen in place would run them too — they spawn
|
|
50
|
-
* processes and take minutes — and the tally would be about the shipped
|
|
51
|
-
* registry rather than the fixture. Measured: the first draft of this test ran
|
|
52
|
-
* the real gates and reported "8 passed / 2 failed / 5 skipped / 15 total".
|
|
53
|
-
*
|
|
54
|
-
* @param {Array<{id: string, preCommitOnly?: boolean, code?: number}>} specs
|
|
55
|
-
* @returns {Function} cleanup that restores the original registry
|
|
56
|
-
*/
|
|
57
|
-
function installGates(specs) {
|
|
58
|
-
const stubs = {};
|
|
59
|
-
for (const spec of specs) {
|
|
60
|
-
stubs[spec.id] = spec.preCommitOnly
|
|
61
|
-
? {
|
|
62
|
-
name: `Stub ${spec.id}`,
|
|
63
|
-
description: 'test double',
|
|
64
|
-
aliases: [],
|
|
65
|
-
preCommitOnly: true,
|
|
66
|
-
reason: 'runs during commit',
|
|
67
|
-
}
|
|
68
|
-
: {
|
|
69
|
-
name: `Stub ${spec.id}`,
|
|
70
|
-
description: 'test double',
|
|
71
|
-
aliases: [],
|
|
72
|
-
run: () => (typeof spec.code === 'number' ? spec.code : 0),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
replaceRegistry(stubs);
|
|
76
|
-
return () => replaceRegistry(ORIGINAL_REGISTRY);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
let cleanup = null;
|
|
80
|
-
let logSpy;
|
|
81
|
-
|
|
82
|
-
beforeAll(() => {
|
|
83
|
-
ORIGINAL_REGISTRY = { ...GATE_REGISTRY };
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
beforeEach(() => {
|
|
87
|
-
logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
88
|
-
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
afterEach(() => {
|
|
92
|
-
if (cleanup) {
|
|
93
|
-
cleanup();
|
|
94
|
-
cleanup = null;
|
|
95
|
-
}
|
|
96
|
-
vi.restoreAllMocks();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Read everything the CLI printed during the run.
|
|
101
|
-
* @returns {string} joined output
|
|
102
|
-
*/
|
|
103
|
-
function printed() {
|
|
104
|
-
return logSpy.mock.calls.map(args => args.join(' ')).join('\n');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
describe('check --all skip accounting', () => {
|
|
108
|
-
test('AC-568-01: a preCommitOnly gate is reported as skipped, not passed', async () => {
|
|
109
|
-
cleanup = installGates([
|
|
110
|
-
...PRECOMMIT_ONLY.map(id => ({ id, preCommitOnly: true })),
|
|
111
|
-
{ id: '2', code: 0 },
|
|
112
|
-
{ id: '3', code: 0 },
|
|
113
|
-
]);
|
|
114
|
-
|
|
115
|
-
const code = await checkAllGates('.');
|
|
116
|
-
|
|
117
|
-
const out = printed();
|
|
118
|
-
// The summary must name the skips and must not claim a bare N/N.
|
|
119
|
-
expect(out, 'the tally must distinguish skipped from passed').toMatch(/skipped/i);
|
|
120
|
-
expect(out).toMatch(/2 passed/);
|
|
121
|
-
expect(out).toMatch(/5 skipped/);
|
|
122
|
-
// A clean run with skips still exits 0 — skips are not failures.
|
|
123
|
-
expect(code).toBe(0);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test('AC-568-02: skipped gates never inflate the passed count', async () => {
|
|
127
|
-
// The defect in one assertion: before the fix this printed "2/2 gate(s)
|
|
128
|
-
// passed" for a run where zero gates were actually executed.
|
|
129
|
-
cleanup = installGates([...PRECOMMIT_ONLY.map(id => ({ id, preCommitOnly: true }))]);
|
|
130
|
-
|
|
131
|
-
await checkAllGates('.');
|
|
132
|
-
|
|
133
|
-
const out = printed();
|
|
134
|
-
expect(out).not.toMatch(/5\/5/);
|
|
135
|
-
expect(out).toMatch(/0 passed/);
|
|
136
|
-
expect(out).toMatch(/5 skipped/);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test('AC-568-03: a real failure still fails the run and is counted apart from skips', async () => {
|
|
140
|
-
// Anti-vacuity: the tally must not have been made honest by making it
|
|
141
|
-
// never fail. One failing gate among skips and passes fails the run.
|
|
142
|
-
cleanup = installGates([
|
|
143
|
-
{ id: '0', preCommitOnly: true },
|
|
144
|
-
{ id: '1', preCommitOnly: true },
|
|
145
|
-
{ id: '2', code: 0 },
|
|
146
|
-
{ id: '3', code: 1 },
|
|
147
|
-
]);
|
|
148
|
-
|
|
149
|
-
const code = await checkAllGates('.');
|
|
150
|
-
|
|
151
|
-
const out = printed();
|
|
152
|
-
expect(code, 'a failing gate must still exit non-zero').toBe(1);
|
|
153
|
-
expect(out).toMatch(/1 passed/);
|
|
154
|
-
expect(out).toMatch(/1 failed/);
|
|
155
|
-
expect(out).toMatch(/2 skipped/);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test('AC-568-04: formatGateTally renders all four states without loss', () => {
|
|
159
|
-
// The pure formatter, exercised directly so the wording contract is pinned
|
|
160
|
-
// independently of the gate loop.
|
|
161
|
-
expect(formatGateTally({ passed: 3, skipped: 4, failed: 0, warned: 0, total: 7 })).toBe(
|
|
162
|
-
'3 passed / 4 skipped / 7 total'
|
|
163
|
-
);
|
|
164
|
-
expect(formatGateTally({ passed: 2, skipped: 1, failed: 1, warned: 0, total: 4 })).toBe(
|
|
165
|
-
'2 passed / 1 failed / 1 skipped / 4 total'
|
|
166
|
-
);
|
|
167
|
-
expect(formatGateTally({ passed: 1, skipped: 0, failed: 0, warned: 2, total: 3 })).toBe(
|
|
168
|
-
'1 passed / 2 warned / 3 total'
|
|
169
|
-
);
|
|
170
|
-
});
|
|
171
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test check-changed-brief
|
|
3
|
-
* @intent Prove `xp-gate check --changed --brief` scopes to the current diff, prints one honest verdict per gate, and never reports a gate as PASS when it did not run
|
|
4
|
-
* @covers AC-DSH-019
|
|
5
|
-
*/
|
|
6
|
-
const { fileExtension, printBriefSummary } = require('../check.js');
|
|
7
|
-
|
|
8
|
-
describe('check --changed --brief helpers', () => {
|
|
9
|
-
describe('fileExtension', () => {
|
|
10
|
-
it('returns the lowercased extension without the dot', () => {
|
|
11
|
-
expect(fileExtension('src/a/B.TS')).toBe('ts');
|
|
12
|
-
expect(fileExtension('x/y/z.mjs')).toBe('mjs');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('returns empty string for a path without an extension', () => {
|
|
16
|
-
expect(fileExtension('Makefile')).toBe('');
|
|
17
|
-
expect(fileExtension('docs/README')).toBe('');
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe('printBriefSummary', () => {
|
|
22
|
-
function capture(fn) {
|
|
23
|
-
const lines = [];
|
|
24
|
-
const spy = vi.spyOn(console, 'log').mockImplementation((...a) => lines.push(a.join(' ')));
|
|
25
|
-
const ret = fn();
|
|
26
|
-
spy.mockRestore();
|
|
27
|
-
return { out: lines.join('\n'), ret };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
it('reports one PASS line per passing gate and returns 0 failures', () => {
|
|
31
|
-
const { out, ret } = capture(() =>
|
|
32
|
-
printBriefSummary(['a.ts'], ['a.ts'], [{ id: '3', code: 0 }, { id: '4', code: 0 }], 12),
|
|
33
|
-
);
|
|
34
|
-
expect(out).toMatch(/Gate 3 Complexity\s+PASS/);
|
|
35
|
-
expect(out).toMatch(/Gate 4 Principles\s+PASS/);
|
|
36
|
-
expect(out).toMatch(/✅ clear/);
|
|
37
|
-
expect(ret).toBe(0);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('reports BLOCK and counts failures when a gate fails', () => {
|
|
41
|
-
const { out, ret } = capture(() =>
|
|
42
|
-
printBriefSummary(['a.ts'], ['a.ts'], [{ id: '3', code: 0 }, { id: '4', code: 1 }], 12),
|
|
43
|
-
);
|
|
44
|
-
expect(out).toMatch(/Gate 4 Principles\s+BLOCK/);
|
|
45
|
-
expect(out).toMatch(/❌ 1 blocking/);
|
|
46
|
-
expect(ret).toBe(1);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('never prints PASS for a gate that did not run (NOT_RUN -> SKIP)', () => {
|
|
50
|
-
const { out, ret } = capture(() =>
|
|
51
|
-
printBriefSummary(['a.ts'], ['a.ts'], [{ id: '3', code: 'NOT_RUN' }], 5),
|
|
52
|
-
);
|
|
53
|
-
expect(out).toMatch(/Gate 3 Complexity\s+SKIP/);
|
|
54
|
-
expect(out).not.toMatch(/Gate 3 Complexity\s+PASS/);
|
|
55
|
-
expect(ret).toBe(0);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('states docs/config-only diffs apply no blocking source gate', () => {
|
|
59
|
-
const { out } = capture(() => printBriefSummary(['README.md'], [], [], 3));
|
|
60
|
-
expect(out).toMatch(/No source files changed/);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test check-normalize-exit
|
|
3
|
-
* @intent Prove the CLI never hands a non-numeric verdict to process.exit (the #657 crash) and that ONLY the GATE_NOT_RUN sentinel is coerced to 0
|
|
4
|
-
* @covers AC-DSH-019
|
|
5
|
-
*/
|
|
6
|
-
const { normalizeGateExit } = require('../check.js');
|
|
7
|
-
|
|
8
|
-
describe('normalizeGateExit (#657)', () => {
|
|
9
|
-
it('coerces the GATE_NOT_RUN string sentinel to 0 (honest skip, not a crash)', () => {
|
|
10
|
-
expect(normalizeGateExit('NOT_RUN')).toBe(0);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('passes real numeric verdicts through unchanged', () => {
|
|
14
|
-
expect(normalizeGateExit(0)).toBe(0);
|
|
15
|
-
expect(normalizeGateExit(1)).toBe(1);
|
|
16
|
-
expect(normalizeGateExit(2)).toBe(2);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('never returns a non-number for any input', () => {
|
|
20
|
-
for (const v of ['NOT_RUN', 0, 1, undefined, null]) {
|
|
21
|
-
expect(typeof normalizeGateExit(v)).toBe('number');
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test REQ-653 `check --gates` 单文件自检必须真的跑起来,且 < 2 秒
|
|
3
|
-
* @intent #653 要求提供一条"提交前自检"的快速路径,目标是让模型在写完代码后立刻
|
|
4
|
-
* 自查,而不是等一轮完整 pre-commit(Gate 5 单项就 32.5s)。
|
|
5
|
-
*
|
|
6
|
-
* 实现过程中挖出两个真 bug,它们都属于同一类:**工具没跑起来,却被报成
|
|
7
|
-
* "你的代码有问题"**。
|
|
8
|
-
*
|
|
9
|
-
* 1. `xp-gate check <file>` 把文件路径直接当成 spawnSync 的 `cwd`。cwd 必须是
|
|
10
|
-
* 目录,指向文件时 spawnSync 返回裸 ENOENT,上层打印
|
|
11
|
-
* "Gate 3: failed to run npx tsx" 然后计作 FAIL。
|
|
12
|
-
* 2. Windows 上曾用 `shell: true` 解析 npx.cmd,但 node 把 argv 拼成一整条
|
|
13
|
-
* 未转义的命令行(DEP0190),路径里有反斜杠或空格就会变形;改调 npx.cmd
|
|
14
|
-
* 本身又撞上 CVE-2024-27980 的 EINVAL 加固。
|
|
15
|
-
*
|
|
16
|
-
* 两个修复都要求"文件路径能跑通",而不是"错误信息更好看"。所以断言打在
|
|
17
|
-
* 真实的 passed 计数与退出码上。
|
|
18
|
-
* @covers AC-653-04, AC-653-05
|
|
19
|
-
*/
|
|
20
|
-
'use strict';
|
|
21
|
-
|
|
22
|
-
const { execFileSync } = require('node:child_process');
|
|
23
|
-
const path = require('node:path');
|
|
24
|
-
const fs = require('node:fs');
|
|
25
|
-
|
|
26
|
-
const CLI = path.join(__dirname, '..', '..', 'bin', 'xp-gate.js');
|
|
27
|
-
const REPO = path.join(__dirname, '..', '..', '..', '..');
|
|
28
|
-
|
|
29
|
-
function runCheck(relPath) {
|
|
30
|
-
const started = Date.now();
|
|
31
|
-
let stdout = '';
|
|
32
|
-
let status = 0;
|
|
33
|
-
try {
|
|
34
|
-
stdout = execFileSync(process.execPath, [CLI, 'check', relPath, '--gates', 'principles'], {
|
|
35
|
-
cwd: REPO,
|
|
36
|
-
encoding: 'utf8',
|
|
37
|
-
timeout: 120000,
|
|
38
|
-
});
|
|
39
|
-
} catch (err) {
|
|
40
|
-
stdout = `${err.stdout || ''}${err.stderr || ''}`;
|
|
41
|
-
status = err.status || 1;
|
|
42
|
-
}
|
|
43
|
-
return { stdout, status, elapsed: Date.now() - started };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 量一次「同一 CLI 做最少的事」要多久——只解析参数并打印版本,不跑任何 gate。
|
|
48
|
-
* 用作 AC-653-05 的相对基线:Node 启动 + bin 模块加载 + 依赖解析的固有成本,
|
|
49
|
-
* 这部分与机器负载同步伸缩,减掉它才能量出 check 自己的开销。
|
|
50
|
-
*
|
|
51
|
-
* 取三次的最小值:最小值受负载尖峰影响最小,比平均值稳定得多。
|
|
52
|
-
*/
|
|
53
|
-
function measure(args) {
|
|
54
|
-
let best = Infinity;
|
|
55
|
-
for (let i = 0; i < 3; i += 1) {
|
|
56
|
-
const started = Date.now();
|
|
57
|
-
try {
|
|
58
|
-
execFileSync(process.execPath, [CLI, ...args], {
|
|
59
|
-
cwd: REPO,
|
|
60
|
-
encoding: 'utf8',
|
|
61
|
-
timeout: 120000,
|
|
62
|
-
stdio: 'pipe',
|
|
63
|
-
});
|
|
64
|
-
} catch {
|
|
65
|
-
// --version 不该失败;真失败时这一次不计入,别把错误吞成 0ms。
|
|
66
|
-
}
|
|
67
|
-
best = Math.min(best, Date.now() - started);
|
|
68
|
-
}
|
|
69
|
-
return best;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
describe('check --gates 单文件自检 (#653)', () => {
|
|
73
|
-
it('AC-653-04: 传文件路径时 gate 真的执行,而不是报 spawn 失败', () => {
|
|
74
|
-
const target = 'src/npm-package/lib/doctor-brief.js';
|
|
75
|
-
expect(fs.existsSync(path.join(REPO, target))).toBe(true);
|
|
76
|
-
const { stdout } = runCheck(target);
|
|
77
|
-
// The pre-fix symptom was exactly this string followed by a FAIL verdict.
|
|
78
|
-
expect(stdout).not.toMatch(/failed to run npx tsx/);
|
|
79
|
-
expect(stdout).not.toMatch(/ENOENT|EINVAL/);
|
|
80
|
-
expect(stdout).toMatch(/principles/i);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('AC-653-05: 单文件自检的增量开销远小于一次完整 pre-commit', () => {
|
|
84
|
-
// #653 的价值主张:提交前自检要快过等一轮完整 pre-commit(几分钟)。
|
|
85
|
-
// "快路径"如果慢就不叫快路径。
|
|
86
|
-
//
|
|
87
|
-
// 但这里不能用绝对墙钟阈值。原实现写 `elapsed < 2000`,实测同一台机器:
|
|
88
|
-
// 裸跑 `node bin/xp-gate.js check ...` 654–822ms(远快于阈值)
|
|
89
|
-
// 在 vitest 里跑同一命令 2191–2352ms(偶尔超阈值)
|
|
90
|
-
// 它测的是「机器此刻有多空」,不是「这个功能够不够快」——并行跑测试时翻红、
|
|
91
|
-
// 空闲时变绿,红绿与功能无关(#722)。一个随负载漂移的断言,既不能证明快,
|
|
92
|
-
// 也不能证明慢。
|
|
93
|
-
//
|
|
94
|
-
// 改成相对判定:先用 `--version` 量出「同一 CLI、同一 Node 启动、同一份模块
|
|
95
|
-
// 加载」的固有成本,再看 check 是它的几倍。两者对机器快慢同步伸缩,比值因此
|
|
96
|
-
// 稳定。实测:
|
|
97
|
-
// 空闲 check 852ms / base 172ms = 4.95x
|
|
98
|
-
// 重负载 check 2563ms / base 445ms = 5.76x (4 个 CPU 密集进程并行)
|
|
99
|
-
// 比值只涨 16%,而绝对时间涨 3 倍——所以比值才是与负载无关的那个量。
|
|
100
|
-
//
|
|
101
|
-
// 门槛取 12x:它意味着 check 花的时间不超过「启动 CLI 本身」的一打倍——
|
|
102
|
-
// 一次完整 pre-commit 是分钟级,12x 启动成本仍是亚秒到一秒级,离「慢」很远;
|
|
103
|
-
// 同时留足余量,不会因为机器一时抖动就翻红。
|
|
104
|
-
const baseline = measure(['--version']);
|
|
105
|
-
const { elapsed } = runCheck('src/npm-package/lib/doctor-brief.js');
|
|
106
|
-
const ratio = elapsed / baseline;
|
|
107
|
-
|
|
108
|
-
expect(ratio).toBeLessThan(12);
|
|
109
|
-
// 翻红时把三个数字一起打出来,能立刻分辨是「基线被拖慢」还是「check 真变慢」。
|
|
110
|
-
expect(
|
|
111
|
-
`${elapsed}ms / ${baseline}ms = ${ratio.toFixed(1)}x`,
|
|
112
|
-
).toMatch(/^\d+ms \/ \d+ms = [\d.]+x$/);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `xp-gate check-tools` must answer three questions in ONE list:
|
|
3
|
-
* completeness (is anything missing), validity (does it actually run) and
|
|
4
|
-
* uniqueness (is there exactly one copy), plus currency (is it the latest).
|
|
5
|
-
*
|
|
6
|
-
* Before this change the command answered none of them reliably:
|
|
7
|
-
* - it only walked languages detected in the current project, so a cross-
|
|
8
|
-
* language tool (jscpd, checkov) that was broken never appeared;
|
|
9
|
-
* - validity was an exit-code check, which reported `psscriptanalyzer` as
|
|
10
|
-
* available while `Invoke-ScriptAnalyzer` did not exist (measured);
|
|
11
|
-
* - duplicates were invisible: two byte-identical hadolint binaries and an
|
|
12
|
-
* old archlint shadowing a newer npm install both passed unnoticed.
|
|
13
|
-
*
|
|
14
|
-
* These tests drive the command through its handler with an injected audit so
|
|
15
|
-
* they never touch the network or the real toolchain.
|
|
16
|
-
*/
|
|
17
|
-
const fs = require('fs');
|
|
18
|
-
const os = require('os');
|
|
19
|
-
const path = require('path');
|
|
20
|
-
|
|
21
|
-
const { handleCheckTools } = require('../language-tools.js');
|
|
22
|
-
const { capture, auditRow: row, tmpProject, writeFixture } = require('./tool-audit-fixtures.js');
|
|
23
|
-
|
|
24
|
-
describe('check-tools: the list itself', () => {
|
|
25
|
-
/**
|
|
26
|
-
* @test REQ-TOOLS-010
|
|
27
|
-
* @intent 清单必须包含跨语言 CLI 工具,不能只看项目语言
|
|
28
|
-
* @covers AC-TOOLS-010-01
|
|
29
|
-
*/
|
|
30
|
-
it('lists cross-language CLI tools even when no language uses them', async () => {
|
|
31
|
-
const dir = tmpProject();
|
|
32
|
-
writeFixture(dir, 'package.json', '{}');
|
|
33
|
-
const rows = [row('eslint'), row('jscpd'), row('checkov')];
|
|
34
|
-
const { code, out } = await capture(() =>
|
|
35
|
-
handleCheckTools(['--json', '--flat'], { projectRoot: dir, audit: () => rows }),
|
|
36
|
-
);
|
|
37
|
-
expect(code).toBe(0);
|
|
38
|
-
const parsed = JSON.parse(out);
|
|
39
|
-
const names = parsed.tools.map((t) => t.name);
|
|
40
|
-
expect(names).toEqual(expect.arrayContaining(['jscpd', 'checkov']));
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @test REQ-TOOLS-010
|
|
45
|
-
* @intent 有效性:探针无输出判为不可用并给出原因(psscriptanalyzer 实况)
|
|
46
|
-
* @covers AC-TOOLS-010-02
|
|
47
|
-
*/
|
|
48
|
-
it('reports an empty-output probe as unavailable WITH a reason', async () => {
|
|
49
|
-
const dir = tmpProject();
|
|
50
|
-
const rows = [
|
|
51
|
-
row('psscriptanalyzer', {
|
|
52
|
-
available: false,
|
|
53
|
-
version: null,
|
|
54
|
-
installedVersion: null,
|
|
55
|
-
currency: 'missing',
|
|
56
|
-
validityReason: 'probe printed no output (empty output cannot prove availability)',
|
|
57
|
-
optional: true,
|
|
58
|
-
}),
|
|
59
|
-
];
|
|
60
|
-
const { out } = await capture(() =>
|
|
61
|
-
handleCheckTools(['--json', '--flat'], { projectRoot: dir, audit: () => rows, languages: [] }),
|
|
62
|
-
);
|
|
63
|
-
const t = JSON.parse(out).tools.find((x) => x.name === 'psscriptanalyzer');
|
|
64
|
-
expect(t.status).toBe('missing');
|
|
65
|
-
expect(t.reason).toMatch(/no output/i);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @test REQ-TOOLS-010
|
|
70
|
-
* @intent 唯一性:重复安装必须在清单里显式标出,并列出全部副本
|
|
71
|
-
* @covers AC-TOOLS-010-03
|
|
72
|
-
*/
|
|
73
|
-
it('marks a tool installed twice and lists every copy', async () => {
|
|
74
|
-
const dir = tmpProject();
|
|
75
|
-
const rows = [
|
|
76
|
-
row('hadolint', {
|
|
77
|
-
duplicated: true,
|
|
78
|
-
paths: ['/home/u/.local/bin/hadolint', '/home/u/.npm-global/bin/hadolint'],
|
|
79
|
-
distinctRealPaths: ['/home/u/.local/bin/hadolint', '/home/u/.npm-global/bin/hadolint'],
|
|
80
|
-
}),
|
|
81
|
-
];
|
|
82
|
-
const { out } = await capture(() =>
|
|
83
|
-
handleCheckTools(['--json', '--flat'], { projectRoot: dir, audit: () => rows, languages: [] }),
|
|
84
|
-
);
|
|
85
|
-
const t = JSON.parse(out).tools.find((x) => x.name === 'hadolint');
|
|
86
|
-
expect(t.duplicated).toBe(true);
|
|
87
|
-
expect(t.paths).toHaveLength(2);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* @test REQ-TOOLS-010
|
|
92
|
-
* @intent 汇总必须同时给出缺失/重复/过期/未知四类计数,且 complete 只在全清时为真
|
|
93
|
-
* @covers AC-TOOLS-010-04
|
|
94
|
-
*/
|
|
95
|
-
it('summarizes every problem category and withholds complete until all are clear', async () => {
|
|
96
|
-
const dir = tmpProject();
|
|
97
|
-
const rows = [
|
|
98
|
-
row('ok1'),
|
|
99
|
-
row('dup1', { duplicated: true }),
|
|
100
|
-
row('old1', { outdated: true, currency: 'outdated', latestVersion: '2.0.0' }),
|
|
101
|
-
row('gone1', { available: false, currency: 'missing', installedVersion: null }),
|
|
102
|
-
row('unk1', { currency: 'unknown', outdated: null, latestVersion: null }),
|
|
103
|
-
];
|
|
104
|
-
const { out } = await capture(() =>
|
|
105
|
-
handleCheckTools(['--json', '--flat'], { projectRoot: dir, audit: () => rows, languages: [] }),
|
|
106
|
-
);
|
|
107
|
-
const s = JSON.parse(out).summary;
|
|
108
|
-
expect(s.missing).toBe(1);
|
|
109
|
-
expect(s.duplicated).toBe(1);
|
|
110
|
-
expect(s.outdated).toBe(1);
|
|
111
|
-
expect(s.unknown).toBe(1);
|
|
112
|
-
expect(s.complete).toBe(false);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @test REQ-TOOLS-010
|
|
117
|
-
* @intent 非 JSON 输出也要能同时看出三类问题,不能只打"available/missing"
|
|
118
|
-
* @covers AC-TOOLS-010-05
|
|
119
|
-
*/
|
|
120
|
-
it('prints duplicates and outdated versions in human output too', async () => {
|
|
121
|
-
const dir = tmpProject();
|
|
122
|
-
const rows = [
|
|
123
|
-
row('hadolint', {
|
|
124
|
-
outdated: true,
|
|
125
|
-
currency: 'outdated',
|
|
126
|
-
installedVersion: '2.14.0',
|
|
127
|
-
latestVersion: '2.15.1',
|
|
128
|
-
duplicated: true,
|
|
129
|
-
paths: ['/a/hadolint', '/b/hadolint'],
|
|
130
|
-
distinctRealPaths: ['/a/hadolint', '/b/hadolint'],
|
|
131
|
-
}),
|
|
132
|
-
];
|
|
133
|
-
const { out } = await capture(() =>
|
|
134
|
-
handleCheckTools([], { projectRoot: dir, audit: () => rows, languages: [] }),
|
|
135
|
-
);
|
|
136
|
-
expect(out).toMatch(/2\.14\.0/);
|
|
137
|
-
expect(out).toMatch(/2\.15\.1/);
|
|
138
|
-
expect(out.toLowerCase()).toMatch(/duplicate|重复/);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* @test REQ-TOOLS-010
|
|
143
|
-
* @intent 可选的缺失工具不应让命令以失败退出,但必须仍然列出
|
|
144
|
-
* @covers AC-TOOLS-010-06
|
|
145
|
-
*/
|
|
146
|
-
it('does not fail the command for a missing OPTIONAL tool, but still lists it', async () => {
|
|
147
|
-
const dir = tmpProject();
|
|
148
|
-
const rows = [row('terraform', { available: false, currency: 'missing', installedVersion: null, optional: true })];
|
|
149
|
-
const { code, out } = await capture(() =>
|
|
150
|
-
handleCheckTools(['--json', '--flat'], { projectRoot: dir, audit: () => rows, languages: [] }),
|
|
151
|
-
);
|
|
152
|
-
expect(code).toBe(0);
|
|
153
|
-
expect(JSON.parse(out).tools).toHaveLength(1);
|
|
154
|
-
});
|
|
155
|
-
});
|