@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-init.js
CHANGED
|
@@ -50,10 +50,15 @@ function detectBranch(cwd) {
|
|
|
50
50
|
function generateSprintId() {
|
|
51
51
|
const now = new Date();
|
|
52
52
|
const dateStr = now.toISOString().slice(0, 10).replace(/-/g, '');
|
|
53
|
-
const seq = String(Math.floor(Math.random() *
|
|
53
|
+
const seq = String(Math.floor(Math.random() * MAX_SPRINT_SEQUENCE) + 1).padStart(2, '0');
|
|
54
54
|
return `sprint-${dateStr}-${seq}`;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/** Sprint ids are `sprint-YYYYMMDD-NN`; the sequence is 1-99. */
|
|
58
|
+
const MAX_SPRINT_SEQUENCE = 99;
|
|
59
|
+
/** `YYYY-MM-DDTHH:MM:SS` is 19 characters once the separators are normalised. */
|
|
60
|
+
const TIMESTAMP_SECONDS_LENGTH = 19;
|
|
61
|
+
|
|
57
62
|
/**
|
|
58
63
|
* Backup existing sprint state to .sprint-history/.
|
|
59
64
|
* @param {string} projectRoot - Project root directory
|
|
@@ -61,12 +66,18 @@ function generateSprintId() {
|
|
|
61
66
|
*/
|
|
62
67
|
function backupSprintState(projectRoot, state) {
|
|
63
68
|
const historyDir = path.join(projectRoot, '.sprint-history');
|
|
64
|
-
|
|
65
|
-
fs.mkdirSync(historyDir, { recursive: true });
|
|
66
|
-
}
|
|
67
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
69
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, TIMESTAMP_SECONDS_LENGTH);
|
|
68
70
|
const backupFile = path.join(historyDir, `sprint-state-${state.id || 'unknown'}-${timestamp}.json`);
|
|
69
|
-
|
|
71
|
+
try {
|
|
72
|
+
if (!fs.existsSync(historyDir)) {
|
|
73
|
+
fs.mkdirSync(historyDir, { recursive: true });
|
|
74
|
+
}
|
|
75
|
+
fs.writeFileSync(backupFile, JSON.stringify(state, null, 2), 'utf8');
|
|
76
|
+
} catch (err) {
|
|
77
|
+
// A backup that silently fails is worse than none: `--force` then overwrites
|
|
78
|
+
// state the operator believed was preserved.
|
|
79
|
+
throw new Error(`cannot back up sprint state to ${backupFile}: ${err.message}`);
|
|
80
|
+
}
|
|
70
81
|
return backupFile;
|
|
71
82
|
}
|
|
72
83
|
|
|
@@ -75,134 +86,269 @@ function backupSprintState(projectRoot, state) {
|
|
|
75
86
|
* @param {string[]} args - CLI arguments
|
|
76
87
|
* @returns {Promise<number>} Exit code
|
|
77
88
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Parse `sprint-init` arguments.
|
|
91
|
+
*
|
|
92
|
+
* Extracted from `handleSprintInit` (CCN 31), and it fixes a latent defect while
|
|
93
|
+
* doing so. The task description used to be "the first argument that is not a
|
|
94
|
+
* flag and is not equal to the --dir/--issues VALUES". That comparison is by
|
|
95
|
+
* value, so a task describing the very directory it targets --
|
|
96
|
+
*
|
|
97
|
+
* xp-gate sprint-init "./src" --dir ./src
|
|
98
|
+
*
|
|
99
|
+
* -- found no task at all and failed with "Missing task_description". The flags
|
|
100
|
+
* are now consumed positionally: a flag takes the next token as its value, and
|
|
101
|
+
* the first token NOT consumed that way is the description.
|
|
102
|
+
*
|
|
103
|
+
* @param {string[]} args
|
|
104
|
+
* @returns {{forceFlag?: boolean, dryRunFlag?: boolean, projectDir?: string,
|
|
105
|
+
* issues?: string, taskDescription?: string, error?: string}}
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* The first argument that is neither a flag nor a value consumed by one.
|
|
109
|
+
*
|
|
110
|
+
* A value is skipped via `consumed` rather than by inspecting its shape: `--issues
|
|
111
|
+
* "#1,#2"` looks nothing like a flag, and treating it as the task description would
|
|
112
|
+
* silently swap the two.
|
|
113
|
+
*
|
|
114
|
+
* @param {string[]} args
|
|
115
|
+
* @param {Set<number>} consumed indices already claimed by a flag
|
|
116
|
+
* @returns {string|undefined}
|
|
117
|
+
*/
|
|
118
|
+
function firstPositional(args, consumed) {
|
|
119
|
+
const index = args.findIndex((arg, i) => !consumed.has(i) && !arg.startsWith('--'));
|
|
120
|
+
return index >= 0 ? args[index] : undefined;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The exit code for a request that never reaches sprint creation: `--help`, or a
|
|
125
|
+
* missing task description.
|
|
126
|
+
*
|
|
127
|
+
* @param {object} parsed
|
|
128
|
+
* @returns {number|null} null when the caller should continue
|
|
129
|
+
*/
|
|
130
|
+
function earlyExitFor(parsed) {
|
|
131
|
+
if (parsed.helpFlag) {
|
|
132
|
+
printSprintInitUsage();
|
|
94
133
|
return 0;
|
|
95
134
|
}
|
|
135
|
+
if (parsed.error) {
|
|
136
|
+
console.error(`Error: ${parsed.error}`);
|
|
137
|
+
return 1;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
96
141
|
|
|
97
|
-
|
|
142
|
+
function parseSprintInitArgs(args) {
|
|
143
|
+
const helpFlag = args.includes('--help');
|
|
98
144
|
const forceFlag = args.includes('--force');
|
|
99
145
|
const dryRunFlag = args.includes('--dry-run');
|
|
100
|
-
const dirIdx = args.indexOf('--dir');
|
|
101
|
-
const projectDir = dirIdx >= 0 ? args[dirIdx + 1] : process.cwd();
|
|
102
|
-
const issuesIdx = args.indexOf('--issues');
|
|
103
|
-
const issues = issuesIdx >= 0 ? args[issuesIdx + 1] : '';
|
|
104
146
|
|
|
105
|
-
|
|
106
|
-
const
|
|
147
|
+
const consumed = new Set();
|
|
148
|
+
const takeValue = (flag) => {
|
|
149
|
+
const i = args.indexOf(flag);
|
|
150
|
+
if (i < 0 || i + 1 >= args.length) return null;
|
|
151
|
+
consumed.add(i + 1);
|
|
152
|
+
return args[i + 1];
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const dirValue = takeValue('--dir');
|
|
156
|
+
const issuesValue = takeValue('--issues');
|
|
157
|
+
const projectDir = dirValue === null ? process.cwd() : dirValue;
|
|
158
|
+
const issues = issuesValue === null ? '' : issuesValue;
|
|
159
|
+
|
|
160
|
+
const taskDescription = firstPositional(args, consumed);
|
|
107
161
|
if (!taskDescription) {
|
|
108
|
-
|
|
109
|
-
return 1;
|
|
162
|
+
return { helpFlag, error: 'Missing task_description. Usage: xp-gate sprint-init "<task_description>"' };
|
|
110
163
|
}
|
|
164
|
+
return { helpFlag, forceFlag, dryRunFlag, projectDir, issues, taskDescription };
|
|
165
|
+
}
|
|
111
166
|
|
|
112
|
-
|
|
113
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Deal with a sprint that is already on disk: idempotent call, conflict, or
|
|
169
|
+
* forced override.
|
|
170
|
+
*
|
|
171
|
+
* The three outcomes are one decision because they share a single precondition
|
|
172
|
+
* (there IS existing state) and differ only in what the caller asked for. Split
|
|
173
|
+
* out of `handleSprintInit` (162 lines), which read as a sequence of unrelated
|
|
174
|
+
* blocks.
|
|
175
|
+
*
|
|
176
|
+
* The idempotent case is deliberately narrow: same task AND same branch AND not
|
|
177
|
+
* detached. A detached HEAD has no branch identity to compare, so treating it as
|
|
178
|
+
* a match would silently accept a second sprint on the same task.
|
|
179
|
+
*
|
|
180
|
+
* @param {object} manager SprintStateManager
|
|
181
|
+
* @param {string} projectDir
|
|
182
|
+
* @param {{taskDescription: string, branch: string, forceFlag: boolean, dryRunFlag: boolean}} opts
|
|
183
|
+
* @returns {{exitCode?: number, existingState: object|null}}
|
|
184
|
+
*/
|
|
185
|
+
function handleExistingSprint(manager, projectDir, opts) {
|
|
186
|
+
const existingState = readExistingState(manager);
|
|
187
|
+
if (!existingState) return { existingState: null };
|
|
188
|
+
|
|
189
|
+
const same = identityOf(existingState, opts);
|
|
190
|
+
if (isIdempotentCall(same, opts.branch)) return reportIdempotent(existingState);
|
|
114
191
|
|
|
115
|
-
|
|
116
|
-
|
|
192
|
+
if (!opts.forceFlag) return refuseOverride(existingState, same, opts.dryRunFlag);
|
|
193
|
+
|
|
194
|
+
return forceOverride(projectDir, existingState);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Read the current state, treating a corrupted file as absent.
|
|
199
|
+
*
|
|
200
|
+
* Overwriting a corrupt state is the only way out of it, so "unreadable" must mean
|
|
201
|
+
* the same thing here as "not there".
|
|
202
|
+
*
|
|
203
|
+
* @param {object} manager SprintStateManager
|
|
204
|
+
* @returns {object|null}
|
|
205
|
+
*/
|
|
206
|
+
function readExistingState(manager) {
|
|
117
207
|
try {
|
|
118
|
-
|
|
208
|
+
return manager.read();
|
|
119
209
|
} catch {
|
|
120
|
-
|
|
121
|
-
existingState = null;
|
|
210
|
+
return null;
|
|
122
211
|
}
|
|
212
|
+
}
|
|
123
213
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
214
|
+
/**
|
|
215
|
+
* The normalised facts that decide whether this is the same sprint.
|
|
216
|
+
*
|
|
217
|
+
* @param {object} state
|
|
218
|
+
* @param {{taskDescription: string}} opts
|
|
219
|
+
* @returns {{task: string, branch: string}}
|
|
220
|
+
*/
|
|
221
|
+
function identityOf(state, opts) {
|
|
222
|
+
return {
|
|
223
|
+
task: (state.task_description || '').trim(),
|
|
224
|
+
branch: state.isolation?.branch || '',
|
|
225
|
+
newTask: opts.taskDescription.trim(),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
136
228
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return 1;
|
|
152
|
-
}
|
|
229
|
+
/**
|
|
230
|
+
* Whether the call is a repeat of the sprint already on disk.
|
|
231
|
+
*
|
|
232
|
+
* `detached` is excluded on purpose: a detached HEAD has no branch identity to
|
|
233
|
+
* compare, so treating it as a match would silently accept a second sprint on the
|
|
234
|
+
* same task.
|
|
235
|
+
*
|
|
236
|
+
* @param {{task: string, branch: string, newTask: string}} same
|
|
237
|
+
* @param {string} branch
|
|
238
|
+
* @returns {boolean}
|
|
239
|
+
*/
|
|
240
|
+
function isIdempotentCall(same, branch) {
|
|
241
|
+
return same.task === same.newTask && same.branch === branch && branch !== 'detached';
|
|
242
|
+
}
|
|
153
243
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
244
|
+
/** Report that the sprint is already initialised and show it. */
|
|
245
|
+
function reportIdempotent(existingState) {
|
|
246
|
+
console.log('ℹ️ Sprint already initialized (idempotent call). Current state:');
|
|
247
|
+
console.log('');
|
|
248
|
+
console.log(renderDashboard(existingState));
|
|
249
|
+
return { exitCode: 0, existingState };
|
|
250
|
+
}
|
|
158
251
|
|
|
252
|
+
/**
|
|
253
|
+
* Refuse to replace an active sprint without `--force`.
|
|
254
|
+
*
|
|
255
|
+
* A dry run reports the same decision as JSON instead of failing, so a caller can
|
|
256
|
+
* check for a conflict without handling a non-zero exit.
|
|
257
|
+
*/
|
|
258
|
+
function refuseOverride(existingState, same, dryRunFlag) {
|
|
159
259
|
if (dryRunFlag) {
|
|
160
260
|
console.log(JSON.stringify({
|
|
161
|
-
decision: '
|
|
162
|
-
reason:
|
|
163
|
-
|
|
164
|
-
task_description: taskDescription.trim(),
|
|
261
|
+
decision: 'deny',
|
|
262
|
+
reason: `Active sprint "${existingState.id}" exists (task: "${same.task}")`,
|
|
263
|
+
hint: 'Use --force to override (backs up old state)',
|
|
165
264
|
}));
|
|
166
|
-
return 0;
|
|
265
|
+
return { exitCode: 0, existingState };
|
|
167
266
|
}
|
|
267
|
+
console.error(`Error: Active sprint "${existingState.id}" already exists.`);
|
|
268
|
+
console.error(` Task: "${same.task}"`);
|
|
269
|
+
console.error(` Branch: ${same.branch}`);
|
|
270
|
+
console.error(' Use --force to override (backs up old state to .sprint-history/)');
|
|
271
|
+
return { exitCode: 1, existingState };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Replace the existing sprint, after taking a backup. */
|
|
275
|
+
function forceOverride(projectDir, existingState) {
|
|
276
|
+
const backupPath = backupSprintState(projectDir, existingState);
|
|
277
|
+
console.log(`📦 Backed up existing sprint to: ${backupPath}`);
|
|
278
|
+
return { existingState };
|
|
279
|
+
}
|
|
168
280
|
|
|
169
|
-
|
|
281
|
+
/**
|
|
282
|
+
* The most recent sprint's retro data, or null.
|
|
283
|
+
*
|
|
284
|
+
* Best effort by design: retro data only pre-populates fields, so a missing or
|
|
285
|
+
* unparseable file must not stop a sprint from starting. Only the newest
|
|
286
|
+
* `.sprint-history` entry is consulted -- carrying forward a retro from three
|
|
287
|
+
* sprints ago would be worse than carrying none.
|
|
288
|
+
*
|
|
289
|
+
* @param {string} projectDir
|
|
290
|
+
* @returns {object|null}
|
|
291
|
+
*/
|
|
292
|
+
/** Whether a history entry is a RETRO rather than a state snapshot. */
|
|
293
|
+
function isRetroFile(name) {
|
|
294
|
+
// `sprint-state-*.json` is a state snapshot, not a retro; only a retro file carries
|
|
295
|
+
// the fields this feeds.
|
|
296
|
+
return !name.endsWith('.json') || name.includes('retro');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** The newest `sprint-*` entry in the history directory, or null. */
|
|
300
|
+
function newestHistoryEntry(historyDir) {
|
|
301
|
+
const entries = fs.readdirSync(historyDir).filter((f) => f.startsWith('sprint-')).sort().reverse();
|
|
302
|
+
return entries[0] || null;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function readPreviousRetro(projectDir) {
|
|
170
306
|
const historyDir = path.join(projectDir, '.sprint-history');
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
break;
|
|
182
|
-
} catch {
|
|
183
|
-
// Skip unparseable files
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
break; // Only check the most recent sprint
|
|
187
|
-
}
|
|
307
|
+
if (!fs.existsSync(historyDir)) return null;
|
|
308
|
+
|
|
309
|
+
const newest = newestHistoryEntry(historyDir);
|
|
310
|
+
if (!newest || !isRetroFile(newest)) return null;
|
|
311
|
+
|
|
312
|
+
try {
|
|
313
|
+
return JSON.parse(fs.readFileSync(path.join(historyDir, newest), 'utf8'));
|
|
314
|
+
} catch {
|
|
315
|
+
// An unparseable retro carries nothing worth failing a sprint start over.
|
|
316
|
+
return null;
|
|
188
317
|
}
|
|
318
|
+
}
|
|
189
319
|
|
|
190
|
-
|
|
320
|
+
/**
|
|
321
|
+
* The initial state for a new sprint.
|
|
322
|
+
*
|
|
323
|
+
* `evidence_schema_version: 2` is what turns Gate 5c's warnings into BLOCKs for
|
|
324
|
+
* this sprint: a sprint created under the new rules is held to them. That is why
|
|
325
|
+
* it is set here rather than inherited -- an old sprint keeps its leniency, a new
|
|
326
|
+
* one gets none.
|
|
327
|
+
*
|
|
328
|
+
* Phase 6 / D7: the previous sprint's retro values are carried into `metrics`
|
|
329
|
+
* so the new sprint starts with last sprint's rework rate and duration visible.
|
|
330
|
+
*
|
|
331
|
+
* @param {{projectDir: string, branch: string, taskDescription: string, issues: string, previousRetro: object|null}} opts
|
|
332
|
+
* @returns {{sprintId: string, newState: object}}
|
|
333
|
+
*/
|
|
334
|
+
function buildSprintState(opts) {
|
|
335
|
+
const { projectDir, branch, taskDescription, issues, previousRetro } = opts;
|
|
191
336
|
const sprintId = generateSprintId();
|
|
337
|
+
const startedAt = new Date().toISOString();
|
|
192
338
|
const newState = {
|
|
193
339
|
_schema_version: 1,
|
|
194
|
-
evidence_schema_version: 2,
|
|
340
|
+
evidence_schema_version: 2,
|
|
195
341
|
id: sprintId,
|
|
196
342
|
task_description: taskDescription.trim(),
|
|
197
343
|
phase: 1,
|
|
198
344
|
status: 'in_progress',
|
|
199
|
-
started_at:
|
|
345
|
+
started_at: startedAt,
|
|
200
346
|
phase_history: [
|
|
201
347
|
{
|
|
202
348
|
phase: 1,
|
|
203
349
|
name: 'PREP',
|
|
204
350
|
status: 'in_progress',
|
|
205
|
-
started_at:
|
|
351
|
+
started_at: startedAt,
|
|
206
352
|
},
|
|
207
353
|
],
|
|
208
354
|
isolation: {
|
|
@@ -213,26 +359,136 @@ async function handleSprintInit(args = []) {
|
|
|
213
359
|
metrics: {},
|
|
214
360
|
};
|
|
215
361
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
362
|
+
applyPreviousRetro(newState, previousRetro);
|
|
363
|
+
return { sprintId, newState };
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Copy the previous sprint's headline metrics into the new sprint.
|
|
368
|
+
*
|
|
369
|
+
* Only the three values that describe how the last sprint WENT -- not its task,
|
|
370
|
+
* branch or phase. Each is copied only when present, so a retro that predates a
|
|
371
|
+
* field does not write a null.
|
|
372
|
+
*
|
|
373
|
+
* @param {object} newState mutated in place
|
|
374
|
+
* @param {object|null} retro
|
|
375
|
+
*/
|
|
376
|
+
/** The retro fields carried into the next sprint's metrics, and their source names. */
|
|
377
|
+
const CARRIED_RETRO_FIELDS = {
|
|
378
|
+
previous_rework_rate: 'rework_rate',
|
|
379
|
+
previous_evidence_skips: 'evidence_skips',
|
|
380
|
+
previous_duration_seconds: 'duration_seconds',
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Copy the previous sprint's headline metrics into the new one.
|
|
385
|
+
*
|
|
386
|
+
* Only values that are PRESENT are copied: a retro written before a field existed
|
|
387
|
+
* must not write `null` into the new sprint's metrics, because a null reads as
|
|
388
|
+
* "measured at nothing".
|
|
389
|
+
*
|
|
390
|
+
* @param {object} newState mutated in place
|
|
391
|
+
* @param {object|null} retro
|
|
392
|
+
*/
|
|
393
|
+
function applyPreviousRetro(newState, retro) {
|
|
394
|
+
if (!retro) return;
|
|
395
|
+
for (const [target, source] of Object.entries(CARRIED_RETRO_FIELDS)) {
|
|
396
|
+
if (retro[source] != null) newState.metrics[target] = retro[source];
|
|
233
397
|
}
|
|
398
|
+
announceCarriedMetrics(newState.metrics);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Print the metrics just carried forward, if any.
|
|
403
|
+
*
|
|
404
|
+
* @param {object} metrics
|
|
405
|
+
*/
|
|
406
|
+
function announceCarriedMetrics(metrics) {
|
|
407
|
+
const entries = Object.entries(metrics);
|
|
408
|
+
if (entries.length === 0) return;
|
|
409
|
+
console.log('📊 Auto-populated from previous sprint retro data:');
|
|
410
|
+
for (const [key, value] of entries) console.log(` ${key}: ${value}`);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/** Print the sprint-init usage text. */
|
|
414
|
+
function printSprintInitUsage() {
|
|
415
|
+
console.log('Usage: xp-gate sprint-init "<task_description>" [options]');
|
|
416
|
+
console.log('');
|
|
417
|
+
console.log('Arguments:');
|
|
418
|
+
console.log(' task_description Sprint task description (required)');
|
|
419
|
+
console.log('');
|
|
420
|
+
console.log('Options:');
|
|
421
|
+
console.log(' --issues <list> Comma-separated issue numbers (e.g. "#123,#456")');
|
|
422
|
+
console.log(' --force Override existing active sprint (backs up old state)');
|
|
423
|
+
console.log(' --dry-run Pre-check conflicts without writing');
|
|
424
|
+
console.log(' --dir <path> Project directory (default: cwd)');
|
|
425
|
+
console.log('');
|
|
426
|
+
console.log('Examples:');
|
|
427
|
+
console.log(' xp-gate sprint-init "Implement user auth"');
|
|
428
|
+
console.log(' xp-gate sprint-init "Fix #366" --issues "#366" --force');
|
|
429
|
+
return 0;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
async function handleSprintInit(args = []) {
|
|
433
|
+
const parsed = parseSprintInitArgs(args);
|
|
434
|
+
const early = earlyExitFor(parsed);
|
|
435
|
+
if (early !== null) return early;
|
|
436
|
+
|
|
437
|
+
const { forceFlag, dryRunFlag, projectDir, issues, taskDescription } = parsed;
|
|
438
|
+
|
|
439
|
+
const manager = new SprintStateManager(projectDir);
|
|
440
|
+
const branch = detectBranch(projectDir);
|
|
441
|
+
|
|
442
|
+
const existing = handleExistingSprint(manager, projectDir, {
|
|
443
|
+
taskDescription, branch, forceFlag, dryRunFlag,
|
|
444
|
+
});
|
|
445
|
+
// An exitCode means the existing-sprint handler already decided the outcome.
|
|
446
|
+
if (existing.exitCode !== undefined) return existing.exitCode;
|
|
447
|
+
|
|
448
|
+
if (dryRunFlag) {
|
|
449
|
+
reportDryRunAllow(existing.existingState, branch, taskDescription);
|
|
450
|
+
return 0;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
createAndAnnounce(manager, { projectDir, branch, taskDescription, issues });
|
|
454
|
+
return 0;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* A dry run's "would proceed" answer, as JSON.
|
|
459
|
+
*
|
|
460
|
+
* It says WHY it would proceed -- overriding an existing sprint is a different
|
|
461
|
+
* situation from starting a fresh one, and a caller checking the answer needs that.
|
|
462
|
+
*
|
|
463
|
+
* @param {object|null} existingState
|
|
464
|
+
* @param {string} branch
|
|
465
|
+
* @param {string} taskDescription
|
|
466
|
+
*/
|
|
467
|
+
function reportDryRunAllow(existingState, branch, taskDescription) {
|
|
468
|
+
console.log(JSON.stringify({
|
|
469
|
+
decision: 'allow',
|
|
470
|
+
reason: existingState ? 'Would override existing sprint (--force)' : 'No existing sprint',
|
|
471
|
+
branch,
|
|
472
|
+
task_description: taskDescription.trim(),
|
|
473
|
+
}));
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Build the state, write it, and show it.
|
|
478
|
+
*
|
|
479
|
+
* The dashboard is printed from the object that was WRITTEN, not from a re-read:
|
|
480
|
+
* re-reading would show what the filesystem kept, which is a different claim from
|
|
481
|
+
* what this command decided.
|
|
482
|
+
*
|
|
483
|
+
* @param {object} manager SprintStateManager
|
|
484
|
+
* @param {{projectDir: string, branch: string, taskDescription: string, issues: string}} ctx
|
|
485
|
+
*/
|
|
486
|
+
function createAndAnnounce(manager, ctx) {
|
|
487
|
+
const { projectDir, branch, taskDescription, issues } = ctx;
|
|
488
|
+
const { sprintId, newState } = buildSprintState({
|
|
489
|
+
projectDir, branch, taskDescription, issues, previousRetro: readPreviousRetro(projectDir),
|
|
490
|
+
});
|
|
234
491
|
|
|
235
|
-
// Write state atomically
|
|
236
492
|
manager.write(newState);
|
|
237
493
|
|
|
238
494
|
console.log(`✅ Sprint initialized: ${sprintId}`);
|
|
@@ -241,8 +497,6 @@ async function handleSprintInit(args = []) {
|
|
|
241
497
|
if (issues) console.log(` Issues: ${issues}`);
|
|
242
498
|
console.log('');
|
|
243
499
|
console.log(renderDashboard(newState));
|
|
244
|
-
|
|
245
|
-
return 0;
|
|
246
500
|
}
|
|
247
501
|
|
|
248
|
-
module.exports = { handleSprintInit, detectBranch, generateSprintId, backupSprintState };
|
|
502
|
+
module.exports = { handleSprintInit, detectBranch, generateSprintId, backupSprintState, parseSprintInitArgs };
|