@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
package/lib/sprint-status.js
CHANGED
|
@@ -9,6 +9,18 @@
|
|
|
9
9
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
|
+
const { statusIcon, formatDuration: formatDurationShared } = require('./sprint-format.js');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A list row shows nothing for an unmeasured duration: "instantaneous" and "not
|
|
16
|
+
* measured" must not look alike, and neither should take visual weight.
|
|
17
|
+
*
|
|
18
|
+
* @param {number|null|undefined} seconds
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
function formatDuration(seconds) {
|
|
22
|
+
return formatDurationShared(seconds);
|
|
23
|
+
}
|
|
12
24
|
const { execFileSync } = require('child_process');
|
|
13
25
|
const { discoverActiveSprints } = require('./sprint-discovery');
|
|
14
26
|
const { SprintStateManager } = require('./sprint-state-manager');
|
|
@@ -44,7 +56,7 @@ function getLatestTimestamp(state) {
|
|
|
44
56
|
function isStale(state) {
|
|
45
57
|
if (!state || !state.started_at) return false;
|
|
46
58
|
const latest = getLatestTimestamp(state);
|
|
47
|
-
return latest > 0 && Date.now() - latest >
|
|
59
|
+
return latest > 0 && Date.now() - latest > STALE_AFTER_MS;
|
|
48
60
|
}
|
|
49
61
|
|
|
50
62
|
/**
|
|
@@ -62,33 +74,7 @@ function readSprintState(dir) {
|
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
76
|
|
|
65
|
-
/**
|
|
66
|
-
* Get a phase's status icon.
|
|
67
|
-
* @param {'completed'|'in_progress'|'pending'|string} status
|
|
68
|
-
* @returns {string} Icon character
|
|
69
|
-
*/
|
|
70
|
-
function statusIcon(status) {
|
|
71
|
-
switch (status) {
|
|
72
|
-
case 'completed': return '✅';
|
|
73
|
-
case 'in_progress': return '🔄';
|
|
74
|
-
case 'skipped': return '⏭️';
|
|
75
|
-
default: return '⏳';
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
77
|
|
|
79
|
-
/**
|
|
80
|
-
* Format a duration in seconds to a human-readable string.
|
|
81
|
-
* @param {number|null} seconds
|
|
82
|
-
* @returns {string}
|
|
83
|
-
*/
|
|
84
|
-
function formatDuration(seconds) {
|
|
85
|
-
if (seconds == null || seconds === 0) return '';
|
|
86
|
-
if (seconds < 60) return `${seconds}s`;
|
|
87
|
-
const mins = Math.floor(seconds / 60);
|
|
88
|
-
if (mins < 60) return `${mins}m`;
|
|
89
|
-
const hrs = Math.floor(mins / 60);
|
|
90
|
-
return `${hrs}h ${mins % 60}m`;
|
|
91
|
-
}
|
|
92
78
|
|
|
93
79
|
/**
|
|
94
80
|
* Format the sprint header lines (task description, ID, branch).
|
|
@@ -196,7 +182,7 @@ function formatSprintTable(state) {
|
|
|
196
182
|
if (name.length > maxNameLen) maxNameLen = name.length;
|
|
197
183
|
}
|
|
198
184
|
|
|
199
|
-
const sep = '─'.repeat(maxNameLen +
|
|
185
|
+
const sep = '─'.repeat(maxNameLen + TABLE_SIDE_PADDING);
|
|
200
186
|
lines.push(sep);
|
|
201
187
|
|
|
202
188
|
for (const key of PHASE_ORDER) {
|
|
@@ -218,7 +204,7 @@ function jsonMode(state) {
|
|
|
218
204
|
}
|
|
219
205
|
|
|
220
206
|
// #369: fix commit matching — conventional commits + keyword boundary
|
|
221
|
-
const FIX_RE = /^(fix(\(.+\))?:)|\b(fix|bugfix|hotfix|patch
|
|
207
|
+
const FIX_RE = /^(fix(\(.+\))?:)|\b(fix|bugfix|hotfix|patch)\b|修复/i;
|
|
222
208
|
|
|
223
209
|
/**
|
|
224
210
|
* Git env with every repo-redirecting variable stripped, so `cwd` is the only
|
|
@@ -289,42 +275,125 @@ function getWindowCommitCounts(repoDir, sinceDate, untilDate) {
|
|
|
289
275
|
* @param {number} windowDays - Window in days after completed_at
|
|
290
276
|
* @returns {Promise<number>} Exit code
|
|
291
277
|
*/
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
278
|
+
/** A sprint whose state file has not changed for an hour is reported as stale. */
|
|
279
|
+
const STALE_AFTER_MS = 3600000;
|
|
280
|
+
/** Characters a table rule adds around the widest name: two of margin per side. */
|
|
281
|
+
const TABLE_SIDE_PADDING = 40;
|
|
282
|
+
/** `fs.watchFile` polls; five seconds is frequent enough to feel live, cheap enough to ignore. */
|
|
283
|
+
const WATCH_POLL_INTERVAL_MS = 5000;
|
|
296
284
|
|
|
285
|
+
/** One day in milliseconds -- the unit the rework window is expressed in. */
|
|
286
|
+
const MS_PER_DAY = 86400000;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Every sprint that closed within the last `windowDays`, newest data included.
|
|
290
|
+
*
|
|
291
|
+
* A sprint counts only if it has `metrics.completed_at`: the rework rate is
|
|
292
|
+
* computed over a finished sprint's own window, so an open sprint has nothing to
|
|
293
|
+
* measure. Malformed files are skipped rather than aborting the report -- one
|
|
294
|
+
* corrupt history entry must not hide the other sprints.
|
|
295
|
+
*
|
|
296
|
+
* @param {{sprintStateFile: string, historyDir: string}} paths
|
|
297
|
+
* @param {number} windowDays
|
|
298
|
+
* @returns {Array<{id: string, state: object, file: string}>}
|
|
299
|
+
*/
|
|
300
|
+
function collectClosedSprints(paths, windowDays) {
|
|
301
|
+
const { sprintStateFile, historyDir } = paths;
|
|
297
302
|
const sprints = [];
|
|
298
303
|
|
|
299
|
-
|
|
300
|
-
if (fs.existsSync(sprintStateFile)) {
|
|
304
|
+
const addIfClosed = (file, fallbackId) => {
|
|
301
305
|
try {
|
|
302
|
-
const state = JSON.parse(fs.readFileSync(
|
|
306
|
+
const state = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
303
307
|
if (state.metrics && state.metrics.completed_at) {
|
|
304
|
-
sprints.push({ id: state.id ||
|
|
308
|
+
sprints.push({ id: state.id || fallbackId, state, file });
|
|
305
309
|
}
|
|
306
|
-
} catch {
|
|
307
|
-
|
|
310
|
+
} catch {
|
|
311
|
+
// A malformed entry is skipped; one bad file must not hide the others.
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
if (fs.existsSync(sprintStateFile)) addIfClosed(sprintStateFile, 'unknown');
|
|
308
316
|
|
|
309
|
-
// History files
|
|
310
317
|
if (fs.existsSync(historyDir)) {
|
|
311
|
-
for (const
|
|
312
|
-
|
|
313
|
-
const fp = path.join(historyDir, f);
|
|
314
|
-
const state = JSON.parse(fs.readFileSync(fp, 'utf8'));
|
|
315
|
-
if (state.metrics && state.metrics.completed_at) {
|
|
316
|
-
sprints.push({ id: state.id || f.replace('.json', ''), state, file: fp });
|
|
317
|
-
}
|
|
318
|
-
} catch { /* skip malformed */ }
|
|
318
|
+
for (const name of fs.readdirSync(historyDir).filter((f) => f.endsWith('.json'))) {
|
|
319
|
+
addIfClosed(path.join(historyDir, name), name.replace('.json', ''));
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
const now = Date.now();
|
|
323
|
-
const windowMs = windowDays *
|
|
324
|
-
|
|
324
|
+
const windowMs = windowDays * MS_PER_DAY;
|
|
325
|
+
return sprints.filter((s) => {
|
|
325
326
|
const t = new Date(s.state.metrics.completed_at).getTime();
|
|
326
327
|
return !isNaN(t) && (now - t) <= windowMs;
|
|
327
328
|
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Rework rate above this is an alert. 30% of a sprint's commits being fixes is
|
|
333
|
+
* the point at which the sprint was not really building the thing.
|
|
334
|
+
*/
|
|
335
|
+
const REWORK_ALERT_THRESHOLD = 0.30;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Measure one sprint's rework rate over its own window, and report it.
|
|
339
|
+
*
|
|
340
|
+
* #704: the window is the sprint itself (start -> completion), and both counts
|
|
341
|
+
* come from one `git log` over it. Previously the total came from a field nothing
|
|
342
|
+
* wrote and the `--since` bound was the sprint's END, so both numbers were
|
|
343
|
+
* structurally 0 and the rate could only be 0 -- while the summary still said
|
|
344
|
+
* "within acceptable rate".
|
|
345
|
+
*
|
|
346
|
+
* No commits in the window means the rate is UNDEFINED, not zero. Reporting 0.0%
|
|
347
|
+
* would rebuild the same false reassurance one level down, so the sprint is
|
|
348
|
+
* surfaced as unmeasurable and never counts as within threshold.
|
|
349
|
+
*
|
|
350
|
+
* @param {string} searchDir
|
|
351
|
+
* @param {string} id
|
|
352
|
+
* @param {object} state
|
|
353
|
+
* @param {string} file
|
|
354
|
+
* @returns {{unmeasurable: boolean, alert: boolean}}
|
|
355
|
+
*/
|
|
356
|
+
function measureSprint(searchDir, id, state, file) {
|
|
357
|
+
const { fix: fixCommits, total: totalCommits } = getWindowCommitCounts(
|
|
358
|
+
searchDir,
|
|
359
|
+
state.started_at,
|
|
360
|
+
state.metrics.completed_at,
|
|
361
|
+
);
|
|
362
|
+
|
|
363
|
+
if (totalCommits === 0) {
|
|
364
|
+
console.log(` ${id}: 0 fix / 0 total commits — NOT MEASURABLE (no commits in sprint window)`);
|
|
365
|
+
return { unmeasurable: true, alert: false };
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const rate = fixCommits / totalCommits;
|
|
369
|
+
|
|
370
|
+
// Persist what was actually measured, denominator included: the previous code
|
|
371
|
+
// wrote the rate unconditionally, so a transposed 0 could overwrite a value a
|
|
372
|
+
// human had corrected.
|
|
373
|
+
state.metrics.rework_rate = rate;
|
|
374
|
+
state.metrics.total_sprint_commits = totalCommits;
|
|
375
|
+
state.metrics.fix_sprint_commits = fixCommits;
|
|
376
|
+
try {
|
|
377
|
+
fs.writeFileSync(file, JSON.stringify(state, null, 2));
|
|
378
|
+
} catch {
|
|
379
|
+
// Non-fatal: the report is still printable from the measured values.
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const pct = (rate * 100).toFixed(1);
|
|
383
|
+
console.log(` ${id}: ${pct}% (${fixCommits} fix / ${totalCommits} total commits)`);
|
|
384
|
+
if (rate > REWORK_ALERT_THRESHOLD) {
|
|
385
|
+
console.log(` ⚠️ ${id}: ${pct}% rework — exceeds ${REWORK_ALERT_THRESHOLD * 100}% threshold`);
|
|
386
|
+
return { unmeasurable: false, alert: true };
|
|
387
|
+
}
|
|
388
|
+
return { unmeasurable: false, alert: false };
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
async function handleReworkCheck(searchDir, windowDays) {
|
|
392
|
+
const stateDir = path.join(searchDir, '.sprint-state');
|
|
393
|
+
const historyDir = path.join(stateDir, 'sprint-history');
|
|
394
|
+
const sprintStateFile = path.join(stateDir, 'sprint-state.json');
|
|
395
|
+
|
|
396
|
+
const inWindow = collectClosedSprints({ sprintStateFile, historyDir }, windowDays);
|
|
328
397
|
|
|
329
398
|
if (inWindow.length === 0) {
|
|
330
399
|
console.log(`No closed sprints within ${windowDays} day${windowDays === 1 ? '' : 's'}`);
|
|
@@ -337,45 +406,9 @@ async function handleReworkCheck(searchDir, windowDays) {
|
|
|
337
406
|
let hasAlert = false;
|
|
338
407
|
let hasUnmeasurable = false;
|
|
339
408
|
for (const { id, state, file } of inWindow) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
// the sprint, so both numbers were structurally 0 and the rate could only
|
|
344
|
-
// ever be 0 — while the summary line still said "within acceptable rate".
|
|
345
|
-
const { fix: fixCommits, total: totalCommits } = getWindowCommitCounts(
|
|
346
|
-
searchDir,
|
|
347
|
-
state.started_at,
|
|
348
|
-
state.metrics.completed_at,
|
|
349
|
-
);
|
|
350
|
-
|
|
351
|
-
// No commits in the window means the rate is undefined, not zero. Reporting
|
|
352
|
-
// 0.0% here would rebuild the same false reassurance one level down, so the
|
|
353
|
-
// sprint is surfaced as unmeasurable and never counts as "within threshold".
|
|
354
|
-
if (totalCommits === 0) {
|
|
355
|
-
hasUnmeasurable = true;
|
|
356
|
-
console.log(` ${id}: 0 fix / 0 total commits — NOT MEASURABLE (no commits in sprint window)`);
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
const rate = fixCommits / totalCommits;
|
|
361
|
-
|
|
362
|
-
// Persist what was actually measured. The previous code wrote the rate
|
|
363
|
-
// unconditionally, which meant a transposed 0 could overwrite a value a
|
|
364
|
-
// human had already corrected; now the denominator is persisted alongside
|
|
365
|
-
// it so the next run can be checked against its own evidence.
|
|
366
|
-
state.metrics.rework_rate = rate;
|
|
367
|
-
state.metrics.total_sprint_commits = totalCommits;
|
|
368
|
-
state.metrics.fix_sprint_commits = fixCommits;
|
|
369
|
-
try {
|
|
370
|
-
fs.writeFileSync(file, JSON.stringify(state, null, 2));
|
|
371
|
-
} catch { /* non-fatal */ }
|
|
372
|
-
|
|
373
|
-
const pct = (rate * 100).toFixed(1);
|
|
374
|
-
console.log(` ${id}: ${pct}% (${fixCommits} fix / ${totalCommits} total commits)`);
|
|
375
|
-
if (rate > 0.30) {
|
|
376
|
-
console.log(` ⚠️ ${id}: ${pct}% rework — exceeds 30% threshold`);
|
|
377
|
-
hasAlert = true;
|
|
378
|
-
}
|
|
409
|
+
const outcome = measureSprint(searchDir, id, state, file);
|
|
410
|
+
if (outcome.unmeasurable) hasUnmeasurable = true;
|
|
411
|
+
if (outcome.alert) hasAlert = true;
|
|
379
412
|
}
|
|
380
413
|
|
|
381
414
|
console.log('─'.repeat(60));
|
|
@@ -515,7 +548,7 @@ function watchMode(stateFile) {
|
|
|
515
548
|
} catch {
|
|
516
549
|
// Fallback to fs.watchFile
|
|
517
550
|
try {
|
|
518
|
-
fs.watchFile(stateFile, { interval:
|
|
551
|
+
fs.watchFile(stateFile, { interval: WATCH_POLL_INTERVAL_MS }, () => {
|
|
519
552
|
const state = readSprintState(path.dirname(dir));
|
|
520
553
|
if (state) {
|
|
521
554
|
console.clear();
|
|
@@ -558,4 +591,15 @@ module.exports = {
|
|
|
558
591
|
// the CLI, so the only way to test it was to shell out and parse console
|
|
559
592
|
// output. A function nobody can call directly is a function nobody can pin.
|
|
560
593
|
handleReworkCheck,
|
|
594
|
+
// Pure display/parse helpers, exported so they can be pinned without rendering a
|
|
595
|
+
// whole table through the CLI.
|
|
596
|
+
parseTime,
|
|
597
|
+
getLatestTimestamp,
|
|
598
|
+
statusIcon,
|
|
599
|
+
formatDuration,
|
|
600
|
+
buildMetricsLine,
|
|
601
|
+
formatReqLines,
|
|
602
|
+
formatPhaseLine,
|
|
603
|
+
getWindowCommitCounts,
|
|
604
|
+
measureSprint,
|
|
561
605
|
};
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @test Issues #871 make the project discoverable from the CLI itself
|
|
3
|
+
* @intent A user who already trusts the tool is the one best placed to point
|
|
4
|
+
* others at it, so the invitation belongs where that trust is formed:
|
|
5
|
+
* --version, a finished `init`, and a clean `check`.
|
|
6
|
+
* @covers #871
|
|
7
|
+
*
|
|
8
|
+
* Restraint is part of the contract, not a courtesy. The module is silent on
|
|
9
|
+
* CI, silent when stdout is not a TTY, and repeats at most once a day. If the
|
|
10
|
+
* "already shown" timestamp cannot be persisted, the notice stays silent for
|
|
11
|
+
* the rest of the process rather than printing on every invocation -- a
|
|
12
|
+
* failure to record is never allowed to turn into nagging.
|
|
13
|
+
*/
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const os = require('os');
|
|
16
|
+
|
|
17
|
+
const { CONFIG_FILE } = require('./shared-paths.js');
|
|
18
|
+
|
|
19
|
+
const REPO_URL = 'https://github.com/boyingliu01/xp-gate';
|
|
20
|
+
const NOTICE_TEXT = `⭐ If XP-Gate saves you time, a star helps others find it: ${REPO_URL}`;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* README badge markup offered once a project's gates come back clean.
|
|
24
|
+
*
|
|
25
|
+
* A badge is the cheapest honest claim a project can make about itself: it
|
|
26
|
+
* shows a passing gate, not a promise. That is why it is offered only after a
|
|
27
|
+
* run where nothing failed -- the markup would be false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
const BADGE_SHIELD_URL = 'https://img.shields.io/badge/gated%20by-XP--Gate-blueviolet';
|
|
30
|
+
const BADGE_MARKDOWN = `[](${REPO_URL})`;
|
|
31
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* How long a dismissal lasts, in days.
|
|
35
|
+
*
|
|
36
|
+
* `xp-gate star-notice --off` writes this window, so the promised "ask us to
|
|
37
|
+
* stop and we stop" has an actual entry point rather than a hand-edited JSON.
|
|
38
|
+
*/
|
|
39
|
+
const DISMISS_DAYS = 30;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* In-process guard: set for the lifetime of the process.
|
|
43
|
+
*
|
|
44
|
+
* When the config cannot be written, the on-disk throttle is unavailable, so
|
|
45
|
+
* without this the notice would print on every call in a loop. One process
|
|
46
|
+
* printing it once is the most we can honestly promise in that state.
|
|
47
|
+
*/
|
|
48
|
+
let shownInThisProcess = false;
|
|
49
|
+
|
|
50
|
+
/** Reset the in-process guard. Tests need a clean slate per case. */
|
|
51
|
+
function resetProcessGuard() {
|
|
52
|
+
shownInThisProcess = false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Decide whether the star invitation may be shown right now.
|
|
57
|
+
*
|
|
58
|
+
* Pure: every input is a parameter. It reads no ambient state, so the policy
|
|
59
|
+
* is testable without faking a terminal.
|
|
60
|
+
*
|
|
61
|
+
* A `lastShownAt` in the future (clock rollback, a restored backup, a shared
|
|
62
|
+
* home across timezones with skewed clocks) is treated as "not yet shown"
|
|
63
|
+
* rather than "shown forever": a stale future timestamp must not silence the
|
|
64
|
+
* notice permanently.
|
|
65
|
+
*
|
|
66
|
+
* @param {{isTTY?: boolean, env?: Record<string, string|undefined>, config?: object, now?: number}} ctx
|
|
67
|
+
* @returns {boolean}
|
|
68
|
+
*/
|
|
69
|
+
function shouldShowNotice({ isTTY, env = {}, config = {}, now = Date.now() } = {}) {
|
|
70
|
+
if (!isTTY) return false;
|
|
71
|
+
if (env.CI) return false;
|
|
72
|
+
if (env.NO_UPDATE_NOTIFIER) return false;
|
|
73
|
+
if (env.XP_GATE_NO_NOTICE) return false;
|
|
74
|
+
|
|
75
|
+
const notice = config.starNotice;
|
|
76
|
+
if (!notice || typeof notice !== 'object') return true;
|
|
77
|
+
|
|
78
|
+
if (notice.dismissedUntil && now < notice.dismissedUntil) return false;
|
|
79
|
+
|
|
80
|
+
if (notice.lastShownAt) {
|
|
81
|
+
const elapsed = now - notice.lastShownAt;
|
|
82
|
+
// Negative elapsed means the clock moved backwards; let the notice resume.
|
|
83
|
+
if (elapsed >= 0 && elapsed < DAY_MS) return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The config file this module reads and writes.
|
|
91
|
+
*
|
|
92
|
+
* Delegates to the canonical GLOBAL_DIRS.CONFIG_FILE so the notice's state
|
|
93
|
+
* lives beside the tool's other settings instead of in a second, silently
|
|
94
|
+
* diverging file.
|
|
95
|
+
*
|
|
96
|
+
* @returns {string}
|
|
97
|
+
*/
|
|
98
|
+
function configFileFor() {
|
|
99
|
+
return CONFIG_FILE;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Read the config, tolerating a missing or corrupt file.
|
|
104
|
+
*
|
|
105
|
+
* A broken config must never turn into an uncaught throw on a `--version`
|
|
106
|
+
* call, so every failure here degrades to "no config" (which shows the
|
|
107
|
+
* notice at most daily).
|
|
108
|
+
*
|
|
109
|
+
* @param {string} [configFile]
|
|
110
|
+
* @returns {object}
|
|
111
|
+
*/
|
|
112
|
+
function readConfig(configFile = configFileFor()) {
|
|
113
|
+
try {
|
|
114
|
+
const parsed = JSON.parse(fs.readFileSync(configFile, 'utf8'));
|
|
115
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
116
|
+
} catch {
|
|
117
|
+
return {};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Persist the config.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} configFile
|
|
125
|
+
* @param {object} config
|
|
126
|
+
* @returns {boolean} whether the write succeeded
|
|
127
|
+
*/
|
|
128
|
+
function writeConfig(configFile, config) {
|
|
129
|
+
try {
|
|
130
|
+
fs.mkdirSync(require('path').dirname(configFile), { recursive: true });
|
|
131
|
+
fs.writeFileSync(configFile, `${JSON.stringify(config, null, 2)}\n`);
|
|
132
|
+
return true;
|
|
133
|
+
} catch {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Record a dismissal so the notice stays silent for DISMISS_DAYS.
|
|
140
|
+
*
|
|
141
|
+
* @param {{configFile?: string, now?: number}} [opts]
|
|
142
|
+
* @returns {boolean} whether the dismissal was persisted
|
|
143
|
+
*/
|
|
144
|
+
function dismiss({ configFile = configFileFor(), now = Date.now() } = {}) {
|
|
145
|
+
const config = readConfig(configFile);
|
|
146
|
+
config.starNotice = { ...(config.starNotice || {}), dismissedUntil: now + DISMISS_DAYS * DAY_MS };
|
|
147
|
+
return writeConfig(configFile, config);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Print the invitation at most once a day, then record that we did.
|
|
152
|
+
*
|
|
153
|
+
* @param {{
|
|
154
|
+
* configFile?: string,
|
|
155
|
+
* force?: boolean,
|
|
156
|
+
* log?: (s: string) => void,
|
|
157
|
+
* env?: Record<string, string|undefined>,
|
|
158
|
+
* isTTY?: boolean,
|
|
159
|
+
* now?: number,
|
|
160
|
+
* }} [opts]
|
|
161
|
+
* @returns {boolean} whether the notice was printed
|
|
162
|
+
*/
|
|
163
|
+
function maybeShowStarNotice(opts = {}) {
|
|
164
|
+
const {
|
|
165
|
+
configFile = configFileFor(),
|
|
166
|
+
force = false,
|
|
167
|
+
log = (s) => console.log(s),
|
|
168
|
+
env = process.env,
|
|
169
|
+
isTTY = process.stdout.isTTY,
|
|
170
|
+
now = Date.now(),
|
|
171
|
+
} = opts;
|
|
172
|
+
|
|
173
|
+
// `force` bypasses the frequency and freshness checks and nothing else. It
|
|
174
|
+
// must still honour an explicit opt-out (`--off`, the env switches) and the
|
|
175
|
+
// guards that keep the notice out of logs: a user who asked us to stop has
|
|
176
|
+
// asked regardless of who is forcing.
|
|
177
|
+
const config = readConfig(configFile);
|
|
178
|
+
const optedOut = Boolean(env.CI || env.NO_UPDATE_NOTIFIER || env.XP_GATE_NO_NOTICE)
|
|
179
|
+
|| Boolean(config.starNotice && config.starNotice.dismissedUntil && now < config.starNotice.dismissedUntil);
|
|
180
|
+
const eligible = force ? Boolean(isTTY) && !optedOut : shouldShowNotice({ isTTY, env, config, now });
|
|
181
|
+
|
|
182
|
+
if (!eligible || shownInThisProcess) return false;
|
|
183
|
+
|
|
184
|
+
log('');
|
|
185
|
+
log(NOTICE_TEXT);
|
|
186
|
+
shownInThisProcess = true;
|
|
187
|
+
|
|
188
|
+
config.starNotice = { ...(config.starNotice || {}), lastShownAt: now };
|
|
189
|
+
if (!writeConfig(configFile, config)) {
|
|
190
|
+
// The in-process guard alone now holds the promise: it is the only state
|
|
191
|
+
// we can keep for certain, so no further notice appears this run.
|
|
192
|
+
log(`(could not record the notice in ${configFile}; it will not repeat in this run)`);
|
|
193
|
+
}
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Offer the README badge after a run where every gate passed.
|
|
199
|
+
*
|
|
200
|
+
* Deliberately silent in more places than the star notice is:
|
|
201
|
+
*
|
|
202
|
+
* - never on a failing run (the markup would be a false claim)
|
|
203
|
+
* - never when the project already carries the badge (it is advice, not news)
|
|
204
|
+
* - never in CI or a pipe, same as the notice
|
|
205
|
+
* - at most once per badge-offer day, tracked separately from the notice, so
|
|
206
|
+
* accepting one does not silence the other
|
|
207
|
+
*
|
|
208
|
+
* @param {{
|
|
209
|
+
* projectRoot?: string,
|
|
210
|
+
* configFile?: string,
|
|
211
|
+
* force?: boolean,
|
|
212
|
+
* log?: (s: string) => void,
|
|
213
|
+
* env?: Record<string, string|undefined>,
|
|
214
|
+
* isTTY?: boolean,
|
|
215
|
+
* now?: number,
|
|
216
|
+
* }} [opts]
|
|
217
|
+
* @returns {boolean} whether the badge was offered
|
|
218
|
+
*/
|
|
219
|
+
function maybeOfferBadge(opts = {}) {
|
|
220
|
+
const {
|
|
221
|
+
projectRoot = process.cwd(),
|
|
222
|
+
configFile = configFileFor(),
|
|
223
|
+
force = false,
|
|
224
|
+
log = (s) => console.log(s),
|
|
225
|
+
env = process.env,
|
|
226
|
+
isTTY = process.stdout.isTTY,
|
|
227
|
+
now = Date.now(),
|
|
228
|
+
} = opts;
|
|
229
|
+
|
|
230
|
+
const config = readConfig(configFile);
|
|
231
|
+
const badgeNotice = config.badgeOffer || {};
|
|
232
|
+
|
|
233
|
+
// The badge keeps its OWN clock. Reusing shouldShowNotice would read
|
|
234
|
+
// `starNotice.lastShownAt` -- which the star invitation writes moments earlier
|
|
235
|
+
// in the same run -- and conclude the badge had already been offered. Measured
|
|
236
|
+
// 2026-11-26: the badge never printed after a clean check for exactly this
|
|
237
|
+
// reason, while the star line did.
|
|
238
|
+
//
|
|
239
|
+
// Only the dismiss window is shared: a user who ran `--off` has asked for
|
|
240
|
+
// silence about the project, and that covers both.
|
|
241
|
+
const dismissed = Boolean(config.starNotice
|
|
242
|
+
&& config.starNotice.dismissedUntil
|
|
243
|
+
&& now < config.starNotice.dismissedUntil);
|
|
244
|
+
const optedOut = Boolean(env.CI || env.NO_UPDATE_NOTIFIER || env.XP_GATE_NO_NOTICE) || dismissed;
|
|
245
|
+
|
|
246
|
+
// `force` bypasses the frequency and freshness checks and nothing else. It
|
|
247
|
+
// must still honour an explicit opt-out and the "already carries it" check:
|
|
248
|
+
// telling someone to claim what they have already claimed is not advice, and
|
|
249
|
+
// forcing it into CI puts the markup in a log nobody reads.
|
|
250
|
+
const eligible = Boolean(isTTY) && !optedOut;
|
|
251
|
+
if (!eligible) return false;
|
|
252
|
+
if (alreadyBadged(projectRoot)) return false;
|
|
253
|
+
|
|
254
|
+
// The frequency check must come BEFORE the first log line: printing and then
|
|
255
|
+
// deciding not to record would show the advice on every run.
|
|
256
|
+
if (!force && badgeNotice.lastShownAt && now - badgeNotice.lastShownAt < DAY_MS) return false;
|
|
257
|
+
|
|
258
|
+
log('');
|
|
259
|
+
log('✅ Every gate passed. Claim it in your README:');
|
|
260
|
+
log(` ${BADGE_MARKDOWN}`);
|
|
261
|
+
|
|
262
|
+
config.badgeOffer = { ...badgeNotice, lastShownAt: now };
|
|
263
|
+
writeConfig(configFile, config);
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Whether the project's README already carries the badge.
|
|
269
|
+
*
|
|
270
|
+
* A missing or unreadable README is not an error -- it just means the project
|
|
271
|
+
* has not made the claim, so the offer stands.
|
|
272
|
+
*
|
|
273
|
+
* @param {string} projectRoot
|
|
274
|
+
* @returns {boolean}
|
|
275
|
+
*/
|
|
276
|
+
function alreadyBadged(projectRoot) {
|
|
277
|
+
let readme;
|
|
278
|
+
try {
|
|
279
|
+
readme = fs.readFileSync(require('path').join(projectRoot, 'README.md'), 'utf8');
|
|
280
|
+
} catch {
|
|
281
|
+
// A missing README means the project has not made the claim, so the offer
|
|
282
|
+
// stands. An unreadable one (permissions, I/O) is deliberately treated the
|
|
283
|
+
// same: the alternative is to nag forever when the file cannot be read, and
|
|
284
|
+
// the offer is harmless -- it only prints the markup for a human to paste.
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
// Match the BADGE, not the project. An earlier draft used
|
|
288
|
+
// `readme.includes('boyingliu01/xp-gate')`, which is true of any README that
|
|
289
|
+
// mentions the repo in prose -- "built on boyingliu01/xp-gate", a credits
|
|
290
|
+
// line, a link-back. Those projects were silently treated as already badged
|
|
291
|
+
// and never told how to make the claim they could honestly make.
|
|
292
|
+
//
|
|
293
|
+
// The distinguishing part is the SHIELD IMAGE URL: prose never contains it.
|
|
294
|
+
return readme.includes(BADGE_SHIELD_URL) || readme.includes(BADGE_MARKDOWN);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Handle the `star-notice` CLI subcommand.
|
|
299
|
+
*
|
|
300
|
+
* @param {string[]} args
|
|
301
|
+
* @returns {number} exit code
|
|
302
|
+
*/
|
|
303
|
+
function cli(args = []) {
|
|
304
|
+
if (args.includes('--off')) {
|
|
305
|
+
const ok = dismiss();
|
|
306
|
+
if (ok) {
|
|
307
|
+
console.log(`Star notice disabled for ${DISMISS_DAYS} days.`);
|
|
308
|
+
console.log(`Re-enable any time by deleting starNotice from ${configFileFor()}`);
|
|
309
|
+
return 0;
|
|
310
|
+
}
|
|
311
|
+
console.error(`Could not write ${configFileFor()}`);
|
|
312
|
+
return 1;
|
|
313
|
+
}
|
|
314
|
+
if (args.includes('--status')) {
|
|
315
|
+
const { starNotice = {} } = readConfig();
|
|
316
|
+
const now = Date.now();
|
|
317
|
+
const dismissed = starNotice.dismissedUntil && now < starNotice.dismissedUntil;
|
|
318
|
+
console.log(`Config file: ${configFileFor()}`);
|
|
319
|
+
console.log(`Last shown: ${starNotice.lastShownAt ? new Date(starNotice.lastShownAt).toISOString() : 'never'}`);
|
|
320
|
+
console.log(`Dismissed until: ${dismissed ? new Date(starNotice.dismissedUntil).toISOString() : 'not dismissed'}`);
|
|
321
|
+
return 0;
|
|
322
|
+
}
|
|
323
|
+
console.log('Usage: xp-gate star-notice [--off | --status]');
|
|
324
|
+
console.log(' --off Stop the star invitation for 30 days');
|
|
325
|
+
console.log(' --status Show when it was last shown and whether it is dismissed');
|
|
326
|
+
return 0;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
module.exports = {
|
|
330
|
+
REPO_URL,
|
|
331
|
+
NOTICE_TEXT,
|
|
332
|
+
DAY_MS,
|
|
333
|
+
DISMISS_DAYS,
|
|
334
|
+
shouldShowNotice,
|
|
335
|
+
configFileFor,
|
|
336
|
+
readConfig,
|
|
337
|
+
writeConfig,
|
|
338
|
+
dismiss,
|
|
339
|
+
maybeShowStarNotice,
|
|
340
|
+
maybeOfferBadge,
|
|
341
|
+
alreadyBadged,
|
|
342
|
+
BADGE_MARKDOWN,
|
|
343
|
+
BADGE_SHIELD_URL,
|
|
344
|
+
resetProcessGuard,
|
|
345
|
+
cli,
|
|
346
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* How one audited tool is shown: its status word, its glyph, and its qualifiers.
|
|
4
|
+
*
|
|
5
|
+
* Split out of `language-tools.js` when that file crossed its line ceiling. The
|
|
6
|
+
* behaviour moved unchanged -- these are pure readers of a row -- and the reasons
|
|
7
|
+
* they exist moved with them.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Handle check-tools CLI command.
|
|
12
|
+
* @param {string[]} args - Command arguments
|
|
13
|
+
* @returns {Promise<number>} Exit code
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Render one audit row as the status the CLI contract uses.
|
|
17
|
+
*
|
|
18
|
+
* A row is unusable for two different reasons and they must not be merged:
|
|
19
|
+
* the probe failed (missing/broken), or the probe could not be interpreted.
|
|
20
|
+
* Both are "not usable", but only the first is "not installed".
|
|
21
|
+
*/
|
|
22
|
+
function statusOfRow(row) {
|
|
23
|
+
return row.available ? 'available' : 'missing';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Icon for a row: present, present-but-flagged, or absent. */
|
|
27
|
+
function iconOfRow(row) {
|
|
28
|
+
if (!row.available) return '✗';
|
|
29
|
+
if (row.duplicated || row.outdated) return '⚠';
|
|
30
|
+
return '✓';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Extra qualifiers appended to a human line, e.g. "duplicate ×2, 2.14.0 → 2.15.1". */
|
|
34
|
+
function qualifiersOfRow(row) {
|
|
35
|
+
const parts = [];
|
|
36
|
+
if (row.duplicated) parts.push(`DUPLICATE ×${row.distinctRealPaths.length}`);
|
|
37
|
+
if (row.outdated && row.installedVersion && row.latestVersion) {
|
|
38
|
+
parts.push(`${row.installedVersion} → ${row.latestVersion} available`);
|
|
39
|
+
} else if (row.currency === 'unknown') {
|
|
40
|
+
parts.push('version currency unknown');
|
|
41
|
+
}
|
|
42
|
+
// #843: say WHERE the binary was found. "Installed but not on PATH" and
|
|
43
|
+
// "not installed" look identical in a pass/fail column and call for opposite
|
|
44
|
+
// actions -- add it to PATH (or symlink it), versus install it.
|
|
45
|
+
if (row.available && row.resolution === 'fallback' && row.resolvedPath) {
|
|
46
|
+
parts.push(`found at ${row.resolvedPath} (not on PATH)`);
|
|
47
|
+
}
|
|
48
|
+
if (!row.available && row.validityReason) parts.push(row.validityReason);
|
|
49
|
+
return parts.join('; ');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = { statusOfRow, iconOfRow, qualifiersOfRow };
|