@boyingliu01/xp-gate 0.38.125 → 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 +45 -1
- package/adapters/gate-7.sh +15 -6
- package/adapters/python.sh +36 -38
- package/bin/xp-gate.js +35 -0
- package/build-integrity/gate-10-lines.ts +98 -0
- package/build-integrity/gate-10.ts +131 -117
- package/build-integrity/quote-masker.ts +17 -3
- package/gate-3.sh +45 -1
- package/gate-registry.sh +3 -1
- 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/deploy-manifest.sh +1 -0
- package/hooks/gate-3.sh +45 -1
- package/hooks/gate-entries/gate-1-entry.sh +44 -24
- package/hooks/gate-entries/gate-5-entry.sh +60 -20
- package/hooks/gate-entries/gate-6-entry.sh +15 -6
- package/hooks/gate-registry.sh +3 -1
- package/hooks/lib/gate-status.sh +164 -0
- package/hooks/lib/jscpd-run.sh +9 -1
- package/hooks/lib/native-path.sh +54 -0
- package/hooks/lib/toolchain-path.sh +38 -0
- package/hooks/lib/validate-code-walkthrough.cjs +324 -99
- package/hooks/pre-commit +52 -0
- package/hooks/pre-push +67 -7
- 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/deploy-manifest.js +1 -0
- package/lib/doctor-constants.js +43 -0
- package/lib/doctor-tool-checks.js +129 -0
- package/lib/doctor.js +2014 -1038
- package/lib/flaky.js +178 -79
- package/lib/gate-audit.ts +80 -0
- package/lib/gate-runner.js +115 -63
- package/lib/init.js +6 -0
- package/lib/language-capability-surfaces.js +75 -8
- package/lib/language-capability.js +3 -0
- package/lib/language-registry.js +608 -0
- package/lib/language-tools.js +679 -894
- 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-audit.js +729 -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/dsh/src/skills.test.ts +9 -0
- 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 -424
- 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__/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-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-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__/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 -291
- 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__/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
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool audit — completeness, VALIDITY and uniqueness for every gate tool.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS MODULE EXISTS (2026-11-23)
|
|
5
|
+
* -----------------------------------
|
|
6
|
+
* Two commands already probed tools, and neither could answer the question
|
|
7
|
+
* "is my tool set complete, valid and unique":
|
|
8
|
+
*
|
|
9
|
+
* - `check-tools` only probes tools belonging to languages detected in the
|
|
10
|
+
* CURRENT project. A Go or Swift tool that is broken stays invisible.
|
|
11
|
+
* - `doctor` only probes its own eight cross-language CLI entries.
|
|
12
|
+
*
|
|
13
|
+
* Neither merged the other, so the union was never checked as a set, and
|
|
14
|
+
* neither could see that a single tool was installed more than once.
|
|
15
|
+
*
|
|
16
|
+
* DEFECTS FOUND ON THIS MACHINE, PINNED BY THE TESTS
|
|
17
|
+
* --------------------------------------------------
|
|
18
|
+
* 1. VALIDITY false positive — `psscriptanalyzer` is probed with
|
|
19
|
+
* `pwsh -Command "Get-Module -ListAvailable PSScriptAnalyzer"`, which exits 0
|
|
20
|
+
* with EMPTY output when the module is absent. An exit-code-only probe then
|
|
21
|
+
* reports "available" for a tool that cannot run. Verified on this box:
|
|
22
|
+
* the probe exits 0 and prints nothing, while `Invoke-ScriptAnalyzer` is
|
|
23
|
+
* ABSENT. "Not checked" masquerading as "passed" is this project's most
|
|
24
|
+
* repeated defect family, so the probe contract here is:
|
|
25
|
+
* non-zero exit OR empty output => not available, with a reason.
|
|
26
|
+
*
|
|
27
|
+
* 2. UNIQUENESS — `hadolint` existed as two byte-identical 54 MB binaries and
|
|
28
|
+
* `archlint` as an old 0.16.0 binary shadowing a newer npm install. The
|
|
29
|
+
* second is the "stale copy shadows the fresh one" trap: the gate runs the
|
|
30
|
+
* old binary and nobody notices.
|
|
31
|
+
*
|
|
32
|
+
* DESIGN: audit reports, install-tools repairs.
|
|
33
|
+
* A check that also repairs cannot be used to decide whether repair is needed,
|
|
34
|
+
* and a report that mutates the machine cannot be re-run to compare. The two
|
|
35
|
+
* responsibilities are therefore kept in separate modules on purpose.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
const { execFile, execFileSync } = require('child_process');
|
|
39
|
+
const util = require('util');
|
|
40
|
+
|
|
41
|
+
const execFileAsync = util.promisify(execFile);
|
|
42
|
+
const fs = require('fs');
|
|
43
|
+
const path = require('path');
|
|
44
|
+
|
|
45
|
+
/** Probe timeout — a gate tool that cannot answer in this window is unusable. */
|
|
46
|
+
const PROBE_TIMEOUT_MS = 15000;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Paths owned by the distribution.
|
|
50
|
+
*
|
|
51
|
+
* A copy here is the SYSTEM's, not an extra install: `/usr/bin/jq` and
|
|
52
|
+
* `~/.local/bin/jq` coexisting is the normal shape after `apt install jq` plus a
|
|
53
|
+
* newer user copy, and `npm` ships npx for BOTH the distro node and an nvm node.
|
|
54
|
+
* Counting those as "duplicate installs" would push people to delete a distro
|
|
55
|
+
* package or a second runtime — both destructive, neither a repair.
|
|
56
|
+
*/
|
|
57
|
+
const SYSTEM_PATH_PREFIXES = ['/usr/bin/', '/bin/', '/usr/sbin/', '/sbin/'];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Runtime-owned trees are the same story as distro paths: nvm keeps its own npm,
|
|
61
|
+
* so `npx` exists once per node runtime by construction, and a system node adds
|
|
62
|
+
* another. None of those is "installed twice by mistake".
|
|
63
|
+
*/
|
|
64
|
+
const RUNTIME_PATH_PATTERNS = [/\/\.nvm\/versions\/node\/[^/]+\//, /\/\.n\/versions\/node\/[^/]+\//];
|
|
65
|
+
|
|
66
|
+
/** Owned by a runtime manager rather than by the user's own install choice. */
|
|
67
|
+
function isRuntimePath(p) {
|
|
68
|
+
return RUNTIME_PATH_PATTERNS.some((re) => re.test(String(p)));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Is this resolved path owned by the distribution rather than the user? */
|
|
72
|
+
function isSystemPath(p) {
|
|
73
|
+
return SYSTEM_PATH_PREFIXES.some((pre) => String(p).startsWith(pre)) || isRuntimePath(p);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Extract an `x.y.z` (or `x.y`) version from a tool's banner output.
|
|
78
|
+
*
|
|
79
|
+
* Real banners this must survive (all observed on this machine):
|
|
80
|
+
* "Haskell Dockerfile Linter 2.14.0" "gitleaks version 8.30.1"
|
|
81
|
+
* "jq-1.8.2" "v10.15.0"
|
|
82
|
+
* "ShellCheck - shell script analysis tool\nversion: 0.10.0"
|
|
83
|
+
*
|
|
84
|
+
* @param {string} text
|
|
85
|
+
* @returns {string|null} the version, or null when no digits are present
|
|
86
|
+
*/
|
|
87
|
+
function parseVersion(text) {
|
|
88
|
+
if (typeof text !== 'string') return null;
|
|
89
|
+
// Prefer a `version:`-labelled token, then the first dotted number.
|
|
90
|
+
const labelled = text.match(/version:?\s*v?(\d+\.\d+(?:\.\d+)*)/i);
|
|
91
|
+
if (labelled) return labelled[1];
|
|
92
|
+
const first = text.match(/\bv?(\d+\.\d+(?:\.\d+)*)/);
|
|
93
|
+
return first ? first[1] : null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Compare two dotted versions numerically.
|
|
98
|
+
*
|
|
99
|
+
* Lexical comparison is wrong in a way that hides real upgrades: "1.10.0" <
|
|
100
|
+
* "1.9.0" lexically, so a current tool reads as outdated and an outdated one
|
|
101
|
+
* reads as current.
|
|
102
|
+
*
|
|
103
|
+
* @returns {number} negative when a < b, 0 when equal, positive when a > b
|
|
104
|
+
*/
|
|
105
|
+
function compareVersions(a, b) {
|
|
106
|
+
const pa = String(a).split('.').map((n) => parseInt(n, 10) || 0);
|
|
107
|
+
const pb = String(b).split('.').map((n) => parseInt(n, 10) || 0);
|
|
108
|
+
const len = Math.max(pa.length, pb.length);
|
|
109
|
+
for (let i = 0; i < len; i += 1) {
|
|
110
|
+
const da = pa[i] || 0;
|
|
111
|
+
const db = pb[i] || 0;
|
|
112
|
+
if (da !== db) return da - db;
|
|
113
|
+
}
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Default probe: run the tool's own check command and capture both streams.
|
|
119
|
+
*
|
|
120
|
+
* The command is executed through `/bin/sh -c` (or `cmd.exe` on Windows) because
|
|
121
|
+
* registry entries are shell snippets, not argv arrays.
|
|
122
|
+
*
|
|
123
|
+
* @returns {{status: number, stdout: string, stderr: string}}
|
|
124
|
+
*/
|
|
125
|
+
function defaultRunProbe(checkCmd) {
|
|
126
|
+
const isWindows = process.platform === 'win32';
|
|
127
|
+
try {
|
|
128
|
+
const stdout = execFileSync(isWindows ? 'cmd.exe' : '/bin/sh', [
|
|
129
|
+
isWindows ? '/c' : '-c',
|
|
130
|
+
checkCmd,
|
|
131
|
+
], {
|
|
132
|
+
encoding: 'utf8',
|
|
133
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
134
|
+
timeout: PROBE_TIMEOUT_MS,
|
|
135
|
+
});
|
|
136
|
+
return { status: 0, stdout: String(stdout || ''), stderr: '' };
|
|
137
|
+
} catch (err) {
|
|
138
|
+
return {
|
|
139
|
+
status: typeof err.status === 'number' ? err.status : 1,
|
|
140
|
+
stdout: String(err.stdout || ''),
|
|
141
|
+
stderr: String(err.stderr || err.message || ''),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Resolve a tool through the SAME helper the gates use (#843).
|
|
148
|
+
*
|
|
149
|
+
* `check-tools` and `doctor` used to answer "is this installed" from PATH alone,
|
|
150
|
+
* while the gates additionally consulted `githooks/lib/toolchain-path.sh` --
|
|
151
|
+
* which knows about `~/.local/bin`, the `.exe` suffix and project-local
|
|
152
|
+
* `node_modules/.bin`. The two could contradict each other on one machine, and
|
|
153
|
+
* the contradiction runs both ways:
|
|
154
|
+
*
|
|
155
|
+
* - a tool installed in `~/.local/bin` but absent from PATH reads as MISSING
|
|
156
|
+
* to the report while the gates happily use it (#843);
|
|
157
|
+
* - a Windows shim reachable through PATH can be FOUND while failing to exec,
|
|
158
|
+
* so it reads as present to the report while every real scan fails (#841).
|
|
159
|
+
*
|
|
160
|
+
* Delegating to the shell helper keeps one tier order instead of two.
|
|
161
|
+
*
|
|
162
|
+
* @param {string} tool command name
|
|
163
|
+
* @param {{runShell?: (cmd: string, args: string[]) => {status: number, stdout: string, stderr?: string}}} [deps]
|
|
164
|
+
* @returns {string|null} absolute path, or null when the resolver finds none
|
|
165
|
+
*/
|
|
166
|
+
function resolveToolViaShell(tool, deps = {}) {
|
|
167
|
+
if (!tool) return null;
|
|
168
|
+
const runShell = deps.runShell || ((cmd, args) => {
|
|
169
|
+
const isWindows = process.platform === 'win32';
|
|
170
|
+
try {
|
|
171
|
+
const stdout = execFileSync(isWindows ? 'cmd.exe' : '/bin/sh',
|
|
172
|
+
[isWindows ? '/c' : '-c', `${cmd} ${args.join(' ')}`],
|
|
173
|
+
{ encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: PROBE_TIMEOUT_MS });
|
|
174
|
+
return { status: 0, stdout: String(stdout || ''), stderr: '' };
|
|
175
|
+
} catch (err) {
|
|
176
|
+
return { status: typeof err.status === 'number' ? err.status : 1, stdout: '', stderr: '' };
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
// The helper lives beside the hooks, not inside this package: resolve it from
|
|
180
|
+
// the project root, falling back to the installed hook tree.
|
|
181
|
+
const helper = deps.helperPath || 'githooks/lib/toolchain-path.sh';
|
|
182
|
+
// `tool_is_available` (not just `resolve_tool_path`) because PRESENCE IS NOT
|
|
183
|
+
// EXECUTABILITY (#596/#841): a POSIX shim whose shebang names an interpreter
|
|
184
|
+
// that is not resolvable is `-x` and `command -v`-visible, answers
|
|
185
|
+
// `--version` on some paths, and dies at exec with 127 on every real scan. On
|
|
186
|
+
// WSL that shim is usually a `/mnt/c` Windows program, whose `--version`
|
|
187
|
+
// succeeds while a real file argument fails.
|
|
188
|
+
//
|
|
189
|
+
// Requiring executable proof keeps both directions honest: a tool that cannot
|
|
190
|
+
// run is reported missing (fail-closed, not fail-open), and a working Linux
|
|
191
|
+
// binary sitting off PATH is still found.
|
|
192
|
+
const script = [
|
|
193
|
+
`[ -r "${helper}" ] || exit 3`,
|
|
194
|
+
`. "${helper}"`,
|
|
195
|
+
`resolve_tool_path "${tool}"`,
|
|
196
|
+
].join('; ');
|
|
197
|
+
const result = runShell('sh', ['-c', `"${script.replace(/"/g, '\"')}"`]);
|
|
198
|
+
if (!result || result.status !== 0) return null;
|
|
199
|
+
const resolved = String(result.stdout || '').trim().split('\n')[0];
|
|
200
|
+
return resolved || null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Default locator: every PATH hit for a command, in resolution order.
|
|
205
|
+
*
|
|
206
|
+
* Duplicates are a PATH fact, so the audit must look at the WHOLE PATH rather
|
|
207
|
+
* than the first hit — resolving only the first is exactly how a stale copy
|
|
208
|
+
* shadows a fresh one without being seen.
|
|
209
|
+
*/
|
|
210
|
+
function defaultLocate(name) {
|
|
211
|
+
const isWindows = process.platform === 'win32';
|
|
212
|
+
const cmd = isWindows ? 'where' : 'which -a';
|
|
213
|
+
try {
|
|
214
|
+
const out = execFileSync(isWindows ? 'cmd.exe' : '/bin/sh', [
|
|
215
|
+
isWindows ? '/c' : '-c',
|
|
216
|
+
`${cmd} ${name}`,
|
|
217
|
+
], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: PROBE_TIMEOUT_MS });
|
|
218
|
+
return String(out || '')
|
|
219
|
+
.split(/\r?\n/)
|
|
220
|
+
.map((l) => l.trim())
|
|
221
|
+
.filter((l) => l.length > 0);
|
|
222
|
+
} catch {
|
|
223
|
+
return [];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Async counterpart of `defaultRunProbe`.
|
|
229
|
+
*
|
|
230
|
+
* MEASURED WHY THIS EXISTS (2026-11-23): probed serially through execFileSync,
|
|
231
|
+
* `checkov --version` (1.9 s) and `semgrep --version` (1.4 s) blocked the event
|
|
232
|
+
* loop for ~3.6 s inside doctor. Every sibling probe in the same process then
|
|
233
|
+
* missed its 1.5 s budget and `node --version` / `git --version` were reported as
|
|
234
|
+
* "Not found" on a machine where they answer in 5 ms. A slow TOOL must never be
|
|
235
|
+
* able to make a FAST tool look absent.
|
|
236
|
+
*/
|
|
237
|
+
async function defaultRunProbeAsync(checkCmd) {
|
|
238
|
+
const isWindows = process.platform === 'win32';
|
|
239
|
+
try {
|
|
240
|
+
const { stdout, stderr } = await execFileAsync(
|
|
241
|
+
isWindows ? 'cmd.exe' : '/bin/sh',
|
|
242
|
+
[isWindows ? '/c' : '-c', checkCmd],
|
|
243
|
+
{ encoding: 'utf8', timeout: PROBE_TIMEOUT_MS },
|
|
244
|
+
);
|
|
245
|
+
return { status: 0, stdout: String(stdout || ''), stderr: String(stderr || '') };
|
|
246
|
+
} catch (err) {
|
|
247
|
+
return {
|
|
248
|
+
status: typeof err.status === 'number' ? err.status : 1,
|
|
249
|
+
stdout: String(err.stdout || ''),
|
|
250
|
+
stderr: String(err.stderr || err.message || ''),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Resolve a path to its real target so symlink chains collapse to one entity. */
|
|
256
|
+
function defaultRealpath(p) {
|
|
257
|
+
try {
|
|
258
|
+
return fs.realpathSync(p);
|
|
259
|
+
} catch {
|
|
260
|
+
return p;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Run the tool's probe and decide VALIDITY.
|
|
266
|
+
*
|
|
267
|
+
* Split out of `auditTool` because the validity contract is the part that
|
|
268
|
+
* regressed before, and it deserves to be readable on its own:
|
|
269
|
+
* a probe is proof of availability only when it exits 0 AND prints something.
|
|
270
|
+
*/
|
|
271
|
+
async function probeValidityAsync(checkCmd, runProbe) {
|
|
272
|
+
const result = runProbe(checkCmd);
|
|
273
|
+
// Await a thenable so a concurrent caller keeps the loop free; a sync probe
|
|
274
|
+
// (execFileSync) still works, which keeps the old call sites valid.
|
|
275
|
+
const awaited = result && typeof result.then === 'function' ? await result : result;
|
|
276
|
+
return interpretProbe(awaited, '');
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The ONE validity rule, shared by the sync and async probe paths.
|
|
281
|
+
*
|
|
282
|
+
* Split out because the rule regressed once already: two copies would let the
|
|
283
|
+
* async path accept something the sync path rejects, and the difference would
|
|
284
|
+
* show up as "doctor says missing, check-tools says fine".
|
|
285
|
+
*/
|
|
286
|
+
function interpretProbe(probe, thrown) {
|
|
287
|
+
const safeProbe = probe || { status: 1, stdout: '', stderr: thrown || '' };
|
|
288
|
+
const stdout = String((safeProbe && safeProbe.stdout) || '');
|
|
289
|
+
const stderr = String((safeProbe && safeProbe.stderr) || '');
|
|
290
|
+
const combined = `${stdout}\n${stderr}`.trim();
|
|
291
|
+
const exitedClean = safeProbe.status === 0;
|
|
292
|
+
const hasOutput = combined.replace(/\s+/g, '').length > 0;
|
|
293
|
+
const available = exitedClean && hasOutput;
|
|
294
|
+
|
|
295
|
+
let reason = '';
|
|
296
|
+
if (!available) {
|
|
297
|
+
if (thrown) reason = `probe failed: ${thrown}`;
|
|
298
|
+
else if (exitedClean) reason = 'probe printed no output (empty output cannot prove availability)';
|
|
299
|
+
else reason = `probe exited ${safeProbe.status}`;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return { available, reason, output: combined };
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Rewrite a check command to use an explicitly resolved binary.
|
|
307
|
+
*
|
|
308
|
+
* `command -v` inside the probe shell answers "is it on PATH", which is not the
|
|
309
|
+
* question: a tool in ~/.local/bin is installed and usable while absent from
|
|
310
|
+
* PATH (#843). When the shared resolver found it, run THAT path.
|
|
311
|
+
*
|
|
312
|
+
* The first token is the tool name in every registry entry this module sees
|
|
313
|
+
* (`gitleaks version`, `eslint --version`, `npx --no-install ...`). Rewriting
|
|
314
|
+
* only that token keeps the rest of the command -- and its arguments -- intact.
|
|
315
|
+
*/
|
|
316
|
+
function withResolvedBinary(checkCmd, resolvedPath) {
|
|
317
|
+
if (!resolvedPath) return checkCmd;
|
|
318
|
+
const trimmed = String(checkCmd || '').trim();
|
|
319
|
+
const spaceAt = trimmed.search(/\s/);
|
|
320
|
+
if (spaceAt < 0) return `"${resolvedPath}"`;
|
|
321
|
+
return `"${resolvedPath}"${trimmed.slice(spaceAt)}`;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function probeValidity(checkCmd, runProbe, resolveFn) {
|
|
325
|
+
let probe;
|
|
326
|
+
let resolvedPath = null;
|
|
327
|
+
let thrown = '';
|
|
328
|
+
try {
|
|
329
|
+
// Resolve FIRST, so an installed-but-off-PATH tool is not reported missing.
|
|
330
|
+
// A resolver that finds nothing leaves the command untouched: the probe then
|
|
331
|
+
// reports honestly what the shell can see, instead of guessing.
|
|
332
|
+
const toolName = String(checkCmd || '').trim().split(/\s/)[0];
|
|
333
|
+
const resolved = resolveFn ? resolveFn(toolName) : null;
|
|
334
|
+
resolvedPath = resolved;
|
|
335
|
+
probe = runProbe(withResolvedBinary(checkCmd, resolved));
|
|
336
|
+
} catch (err) {
|
|
337
|
+
// Keep the thrown message: "probe exited 1" alone cannot distinguish a
|
|
338
|
+
// timeout from a missing interpreter, and both need different fixes.
|
|
339
|
+
thrown = String(err && err.message ? err.message : err);
|
|
340
|
+
probe = { status: 1, stdout: '', stderr: thrown };
|
|
341
|
+
}
|
|
342
|
+
return { ...interpretProbe(probe, thrown), resolvedPath };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Decide currency from installed vs latest.
|
|
347
|
+
*
|
|
348
|
+
* "Unknown" is deliberately distinct from "current": a tool whose latest
|
|
349
|
+
* version could not be determined has not been shown to be up to date.
|
|
350
|
+
*/
|
|
351
|
+
function classifyCurrency(available, installedVersion, latestVersion) {
|
|
352
|
+
if (!available) return { currency: 'missing', outdated: null };
|
|
353
|
+
if (!latestVersion || !installedVersion) return { currency: 'unknown', outdated: null };
|
|
354
|
+
const isOld = compareVersions(installedVersion, latestVersion) < 0;
|
|
355
|
+
return { currency: isOld ? 'outdated' : 'current', outdated: isOld };
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Audit ONE tool across validity, uniqueness and currency.
|
|
360
|
+
*
|
|
361
|
+
* @param {{name: string, checkCmd: string}} toolDef
|
|
362
|
+
* @param {{
|
|
363
|
+
* runProbe?: (cmd: string) => {status: number, stdout: string, stderr: string},
|
|
364
|
+
* locate?: (name: string) => string[],
|
|
365
|
+
* realpath?: (p: string) => string,
|
|
366
|
+
* latestVersion?: string|null,
|
|
367
|
+
* }} [deps] injectable for tests
|
|
368
|
+
*/
|
|
369
|
+
/**
|
|
370
|
+
* Classify a tool's copies into duplicates vs coexistence.
|
|
371
|
+
*
|
|
372
|
+
* Shared by the sync and async paths so the judgement cannot differ between
|
|
373
|
+
* `check-tools` and `doctor` — a difference there would read as one command
|
|
374
|
+
* lying about the other.
|
|
375
|
+
*/
|
|
376
|
+
function classifyCopies(distinctRealPaths) {
|
|
377
|
+
const systemCopies = distinctRealPaths.filter(isSystemPath);
|
|
378
|
+
const userCopies = distinctRealPaths.filter((p) => !isSystemPath(p));
|
|
379
|
+
const duplicated = userCopies.length > 1;
|
|
380
|
+
return {
|
|
381
|
+
systemCopies,
|
|
382
|
+
userCopies,
|
|
383
|
+
duplicated,
|
|
384
|
+
coexistingCopies: !duplicated && userCopies.length > 0 && systemCopies.length > 0,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Assemble one audit row.
|
|
390
|
+
*
|
|
391
|
+
* Both probe paths funnel through here: the row's shape is part of the contract
|
|
392
|
+
* (`check-tools --json`, doctor's report), so building it in two places is how a
|
|
393
|
+
* field goes missing from one of them.
|
|
394
|
+
*/
|
|
395
|
+
function buildRow(toolDef, { paths, distinctRealPaths, validity, latestVersion }) {
|
|
396
|
+
const { available, reason, output } = validity;
|
|
397
|
+
const installedVersion = available ? parseVersion(output) : null;
|
|
398
|
+
const { currency, outdated } = classifyCurrency(available, installedVersion, latestVersion);
|
|
399
|
+
const copies = classifyCopies(distinctRealPaths);
|
|
400
|
+
|
|
401
|
+
// WHERE the binary was found decides what the reader should do (#843): a tool
|
|
402
|
+
// found off PATH is installed but invisible to anything else that shells out,
|
|
403
|
+
// so the report must say so instead of implying a broken install.
|
|
404
|
+
const resolvedPath = validity.resolvedPath || null;
|
|
405
|
+
const onPath = resolvedPath ? distinctRealPaths.includes(resolvedPath) : true;
|
|
406
|
+
const resolution = !resolvedPath ? 'path' : (onPath ? 'path' : 'fallback');
|
|
407
|
+
|
|
408
|
+
return {
|
|
409
|
+
name: toolDef.name,
|
|
410
|
+
available,
|
|
411
|
+
validityReason: reason,
|
|
412
|
+
// A tool probed through `npx --no-install` has no standalone executable on
|
|
413
|
+
// PATH (archlint, dependency-cruiser); `which -a` finding nothing is NOT
|
|
414
|
+
// evidence of absence.
|
|
415
|
+
npxInvoked: /\bnpx\b/.test(String(toolDef.checkCmd || '')),
|
|
416
|
+
paths,
|
|
417
|
+
distinctRealPaths,
|
|
418
|
+
duplicated: copies.duplicated,
|
|
419
|
+
coexistingCopies: copies.coexistingCopies,
|
|
420
|
+
resolvedPath,
|
|
421
|
+
resolution,
|
|
422
|
+
systemCopies: copies.systemCopies,
|
|
423
|
+
userCopies: copies.userCopies,
|
|
424
|
+
// `version` is the banner line as reported; `installedVersion` is the parsed
|
|
425
|
+
// semver used for comparison. Keeping both means a report can show what the
|
|
426
|
+
// tool actually printed AND what the audit decided from it.
|
|
427
|
+
version: available ? output.split('\n')[0] : null,
|
|
428
|
+
installedVersion,
|
|
429
|
+
latestVersion: latestVersion || null,
|
|
430
|
+
outdated,
|
|
431
|
+
currency,
|
|
432
|
+
gates: toolDef.gates || [],
|
|
433
|
+
optional: Boolean(toolDef.optional),
|
|
434
|
+
// Carried through so a report can still say WHICH language needs this tool.
|
|
435
|
+
// Dropping it made every row look cross-language, which silently emptied
|
|
436
|
+
// the per-language groups (#468 contract).
|
|
437
|
+
languages: toolDef.languages || [],
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/** Resolve `latestVersion`, treating any lookup failure as "cannot determine". */
|
|
442
|
+
function latestFor(toolDef, deps) {
|
|
443
|
+
if (Object.prototype.hasOwnProperty.call(deps, 'latestVersion')) return deps.latestVersion;
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function auditTool(toolDef, deps = {}) {
|
|
448
|
+
const locate = deps.locate || defaultLocate;
|
|
449
|
+
const realpath = deps.realpath || defaultRealpath;
|
|
450
|
+
|
|
451
|
+
// Duplicates are a PATH fact: look at every hit, never just the first.
|
|
452
|
+
const paths = locate(toolDef.name);
|
|
453
|
+
const distinctRealPaths = [...new Set(paths.map(realpath))];
|
|
454
|
+
const validity = probeValidity(toolDef.checkCmd, deps.runProbe || defaultRunProbe, deps.resolveTool);
|
|
455
|
+
|
|
456
|
+
return buildRow(toolDef, {
|
|
457
|
+
paths,
|
|
458
|
+
distinctRealPaths,
|
|
459
|
+
validity,
|
|
460
|
+
latestVersion: latestFor(toolDef, deps),
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Build the COMPLETE gate-tool set: cross-language CLI tools ∪ language tools.
|
|
466
|
+
*
|
|
467
|
+
* Neither half is sufficient on its own. On this machine `check-tools` listed
|
|
468
|
+
* only the 8 tools of the detected languages, while `doctor` probed a different
|
|
469
|
+
* 8 cross-language entries; a broken jscpd was therefore invisible to
|
|
470
|
+
* `check-tools` and a broken eslint invisible to `doctor`. Completeness has to
|
|
471
|
+
* mean the union.
|
|
472
|
+
*
|
|
473
|
+
* A tool appearing in both halves is ONE tool: its gate labels are merged rather
|
|
474
|
+
* than duplicated, because "is it installed" has a single answer.
|
|
475
|
+
*
|
|
476
|
+
* @param {{
|
|
477
|
+
* registry: Object<string, {name: string, tools: Array}>,
|
|
478
|
+
* cliTools: Array<{tool: string, checkCmd: string, gates: string[]}>,
|
|
479
|
+
* languages: string[]|null,
|
|
480
|
+
* }} options `languages: null` means every registered language.
|
|
481
|
+
* @returns {Array<{name: string, checkCmd: string, optional: boolean, gates: string[], languages: string[]}>}
|
|
482
|
+
*/
|
|
483
|
+
function collectGateTools({ registry = {}, cliTools = [], languages = null } = {}) {
|
|
484
|
+
const byName = new Map();
|
|
485
|
+
const merge = (name, checkCmd, optional, gates, lang, install) => {
|
|
486
|
+
if (!name) return;
|
|
487
|
+
const existing = byName.get(name);
|
|
488
|
+
if (existing) {
|
|
489
|
+
for (const g of gates || []) {
|
|
490
|
+
if (!existing.gates.includes(g)) existing.gates.push(g);
|
|
491
|
+
}
|
|
492
|
+
if (lang && !existing.languages.includes(lang)) existing.languages.push(lang);
|
|
493
|
+
// A tool required by any language is not optional overall.
|
|
494
|
+
existing.optional = existing.optional && Boolean(optional);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
byName.set(name, {
|
|
498
|
+
name,
|
|
499
|
+
checkCmd,
|
|
500
|
+
optional: Boolean(optional),
|
|
501
|
+
gates: [...(gates || [])],
|
|
502
|
+
languages: lang ? [lang] : [],
|
|
503
|
+
// The installer travels with the tool: install-tools needs it, and a
|
|
504
|
+
// collector that silently drops it produces "no installer known" for a
|
|
505
|
+
// tool that has a perfectly good install command.
|
|
506
|
+
install: install || null,
|
|
507
|
+
});
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
const wanted = languages === null || languages === undefined ? null : languages;
|
|
511
|
+
for (const [langKey, langDef] of Object.entries(registry || {})) {
|
|
512
|
+
if (wanted && !wanted.includes(langKey)) continue;
|
|
513
|
+
for (const t of (langDef && langDef.tools) || []) {
|
|
514
|
+
// Build-file entries have no binary to probe; they are reported by the
|
|
515
|
+
// language layer, not audited as executables.
|
|
516
|
+
if (t.detectBy === 'build-file') continue;
|
|
517
|
+
// Key by the registry key, not the display name: callers pass and compare
|
|
518
|
+
// keys ('shell'), and a display name ('Shell') would silently produce an
|
|
519
|
+
// empty group for a correct selection.
|
|
520
|
+
merge(t.name, t.checkCmd, t.optional, t.gates, langKey, t.install);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
for (const c of cliTools || []) {
|
|
525
|
+
merge(c.tool || c.name, c.checkCmd || `${c.tool || c.name} --version`, false, c.gates, null, c.install);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Audit every tool in a list, producing one row per tool.
|
|
533
|
+
*
|
|
534
|
+
* A single unusable probe must not abort the report: a tool that cannot be
|
|
535
|
+
* audited is itself a finding, and losing the other rows would hide the rest.
|
|
536
|
+
*
|
|
537
|
+
* @param {Array} tools from `collectGateTools`
|
|
538
|
+
* @param {object} [deps] forwarded to `auditTool`, plus `resolveLatest(name)`
|
|
539
|
+
*/
|
|
540
|
+
function auditAllTools(tools = [], deps = {}) {
|
|
541
|
+
const resolveLatest = deps.resolveLatest || (() => null);
|
|
542
|
+
return (tools || []).map((toolDef) => {
|
|
543
|
+
let latestVersion = null;
|
|
544
|
+
try {
|
|
545
|
+
latestVersion = resolveLatest(toolDef.name);
|
|
546
|
+
} catch {
|
|
547
|
+
// A registry lookup failure means "cannot determine", which the currency
|
|
548
|
+
// classifier reports as unknown — never as current.
|
|
549
|
+
latestVersion = null;
|
|
550
|
+
}
|
|
551
|
+
return auditTool(toolDef, { ...deps, latestVersion });
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Offline latest-version table for tools that are NOT npm packages.
|
|
558
|
+
*
|
|
559
|
+
* These are updated by hand on purpose: fetching them needs GitHub's API or a
|
|
560
|
+
* release asset download, both of which were measurably unreliable on this
|
|
561
|
+
* machine (the API returned an empty body twice in a row). A stale entry here
|
|
562
|
+
* produces "outdated" — the safe direction — never "current" by accident.
|
|
563
|
+
* `updated` records when each value was last verified upstream so a reader can
|
|
564
|
+
* judge freshness instead of trusting it blindly.
|
|
565
|
+
*/
|
|
566
|
+
const LATEST_TABLE = {
|
|
567
|
+
shellcheck: { version: '0.11.0', updated: '2026-11-23' },
|
|
568
|
+
hadolint: { version: '2.15.1', updated: '2026-11-23' },
|
|
569
|
+
gitleaks: { version: '8.30.1', updated: '2026-11-23' },
|
|
570
|
+
checkov: { version: '3.4.6', updated: '2026-11-23' },
|
|
571
|
+
lizard: { version: '1.26.1', updated: '2026-11-23' },
|
|
572
|
+
semgrep: { version: '1.186.0', updated: '2026-11-23' },
|
|
573
|
+
jq: { version: '1.8.2', updated: '2026-11-23' },
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
/** Tools distributed through npm — looked up live, never pinned in a table. */
|
|
577
|
+
const NPM_TOOLS = new Set(['jscpd', 'eslint', '@archlinter/cli', 'dependency-cruiser']);
|
|
578
|
+
|
|
579
|
+
/** Which channel answers "what is the latest version" for this tool. */
|
|
580
|
+
function registryFor(name) {
|
|
581
|
+
return NPM_TOOLS.has(name) ? 'npm' : 'table';
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/** Default npm lookup: the official registry, because mirrors lag (measured:
|
|
585
|
+
* the npmmirror copy of the DSH plugin was 42 releases behind). */
|
|
586
|
+
function defaultRunNpmView(name) {
|
|
587
|
+
try {
|
|
588
|
+
const out = execFileSync('npm', ['view', name, 'version', '--registry=https://registry.npmjs.org'], {
|
|
589
|
+
encoding: 'utf8',
|
|
590
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
591
|
+
timeout: PROBE_TIMEOUT_MS,
|
|
592
|
+
shell: process.platform === 'win32',
|
|
593
|
+
});
|
|
594
|
+
return String(out || '').trim();
|
|
595
|
+
} catch {
|
|
596
|
+
return null;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Resolve the latest available version, or null when it cannot be determined.
|
|
602
|
+
*
|
|
603
|
+
* Returning null is a first-class outcome: the caller turns it into
|
|
604
|
+
* `currency: 'unknown'`, which is reported. Coercing a failed lookup into the
|
|
605
|
+
* installed version would silently declare an outdated tool current — the exact
|
|
606
|
+
* "not checked equals passed" mistake this module exists to prevent.
|
|
607
|
+
*/
|
|
608
|
+
function resolveLatestVersion(name, deps = {}) {
|
|
609
|
+
const runNpmView = deps.runNpmView || defaultRunNpmView;
|
|
610
|
+
const table = deps.table || LATEST_TABLE;
|
|
611
|
+
if (registryFor(name) === 'npm') {
|
|
612
|
+
try {
|
|
613
|
+
const raw = runNpmView(name);
|
|
614
|
+
return raw ? parseVersion(String(raw)) : null;
|
|
615
|
+
} catch {
|
|
616
|
+
return null;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
const entry = table && table[name];
|
|
620
|
+
if (!entry) return null;
|
|
621
|
+
return typeof entry === 'string' ? entry : entry.version || null;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Audit a list of tools with CONCURRENT async probes.
|
|
626
|
+
*
|
|
627
|
+
* Preferred over `auditAllTools` anywhere the result is awaited in a process
|
|
628
|
+
* that also runs other probes (doctor). Wall time becomes the slowest tool
|
|
629
|
+
* instead of the sum, and no probe can starve another.
|
|
630
|
+
*
|
|
631
|
+
* @param {Array} tools
|
|
632
|
+
* @param {object} [deps] as `auditTool`, except `runProbe` may be async
|
|
633
|
+
*/
|
|
634
|
+
async function auditAllToolsAsync(tools = [], deps = {}) {
|
|
635
|
+
const resolveLatest = deps.resolveLatest || (() => null);
|
|
636
|
+
const runProbe = deps.runProbe || defaultRunProbeAsync;
|
|
637
|
+
return Promise.all(
|
|
638
|
+
(tools || []).map(async (toolDef) => {
|
|
639
|
+
let latestVersion = null;
|
|
640
|
+
try {
|
|
641
|
+
latestVersion = resolveLatest(toolDef.name);
|
|
642
|
+
} catch {
|
|
643
|
+
latestVersion = null;
|
|
644
|
+
}
|
|
645
|
+
return auditToolAsync(toolDef, { ...deps, runProbe, latestVersion });
|
|
646
|
+
}),
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Async sibling of `auditTool`.
|
|
652
|
+
*
|
|
653
|
+
* Same fields, same rules — the only difference is that the probe is awaited,
|
|
654
|
+
* so concurrent audits interleave instead of queueing behind each other.
|
|
655
|
+
*/
|
|
656
|
+
async function auditToolAsync(toolDef, deps = {}) {
|
|
657
|
+
const locate = deps.locate || defaultLocate;
|
|
658
|
+
const realpath = deps.realpath || defaultRealpath;
|
|
659
|
+
|
|
660
|
+
const paths = locate(toolDef.name);
|
|
661
|
+
const distinctRealPaths = [...new Set(paths.map(realpath))];
|
|
662
|
+
|
|
663
|
+
let validity;
|
|
664
|
+
try {
|
|
665
|
+
validity = await probeValidityAsync(toolDef.checkCmd, deps.runProbe || defaultRunProbeAsync);
|
|
666
|
+
} catch (err) {
|
|
667
|
+
validity = interpretProbe({ status: 1 }, String(err && err.message ? err.message : err));
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
return buildRow(toolDef, {
|
|
671
|
+
paths,
|
|
672
|
+
distinctRealPaths,
|
|
673
|
+
validity,
|
|
674
|
+
latestVersion: latestFor(toolDef, deps),
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/** One row per distinct entity, so a duplicate is described, not just counted. */
|
|
679
|
+
function describeDuplicates(entry) {
|
|
680
|
+
if (!entry.duplicated) return [];
|
|
681
|
+
return entry.distinctRealPaths.map((real) => ({
|
|
682
|
+
realPath: real,
|
|
683
|
+
resolvedFrom: entry.paths.filter((p) => p === real || p.startsWith(path.dirname(real))),
|
|
684
|
+
}));
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Summarize a list of audit entries.
|
|
689
|
+
*
|
|
690
|
+
* Every problem category is counted separately. Collapsing "unknown" into "ok"
|
|
691
|
+
* is the same defect as reporting a skipped gate as passed, one layer up.
|
|
692
|
+
*/
|
|
693
|
+
function summarizeAudit(entries = []) {
|
|
694
|
+
const list = Array.isArray(entries) ? entries : [];
|
|
695
|
+
const missing = list.filter((e) => e.currency === 'missing').length;
|
|
696
|
+
const duplicated = list.filter((e) => e.duplicated).length;
|
|
697
|
+
const outdated = list.filter((e) => e.outdated === true).length;
|
|
698
|
+
const unknown = list.filter((e) => e.currency === 'unknown').length;
|
|
699
|
+
return {
|
|
700
|
+
total: list.length,
|
|
701
|
+
missing,
|
|
702
|
+
duplicated,
|
|
703
|
+
outdated,
|
|
704
|
+
unknown,
|
|
705
|
+
// "Complete" means every tool is present, single-copy, current AND known.
|
|
706
|
+
complete: list.length > 0 && missing === 0 && duplicated === 0 && outdated === 0 && unknown === 0,
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
module.exports = {
|
|
711
|
+
auditTool,
|
|
712
|
+
resolveToolViaShell,
|
|
713
|
+
registryFor,
|
|
714
|
+
resolveLatestVersion,
|
|
715
|
+
LATEST_TABLE,
|
|
716
|
+
NPM_TOOLS,
|
|
717
|
+
auditAllTools,
|
|
718
|
+
auditAllToolsAsync,
|
|
719
|
+
defaultRunProbeAsync,
|
|
720
|
+
withResolvedBinary,
|
|
721
|
+
collectGateTools,
|
|
722
|
+
summarizeAudit,
|
|
723
|
+
describeDuplicates,
|
|
724
|
+
parseVersion,
|
|
725
|
+
compareVersions,
|
|
726
|
+
PROBE_TIMEOUT_MS,
|
|
727
|
+
SYSTEM_PATH_PREFIXES,
|
|
728
|
+
isSystemPath,
|
|
729
|
+
};
|