@dommaker/harness 1.16.0 → 2.0.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/CHANGELOG.md +16 -0
- package/dist/agents/lifecycle.d.ts.map +1 -1
- package/dist/agents/lifecycle.js +3 -6
- package/dist/agents/lifecycle.js.map +1 -1
- package/dist/cli/command-contract.d.ts +6 -9
- package/dist/cli/command-contract.d.ts.map +1 -1
- package/dist/cli/command-contract.js +6 -0
- package/dist/cli/command-contract.js.map +1 -1
- package/dist/cli/commands/acceptance.d.ts.map +1 -1
- package/dist/cli/commands/acceptance.js +8 -7
- package/dist/cli/commands/acceptance.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +2 -1
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/contract.d.ts.map +1 -1
- package/dist/cli/commands/contract.js +20 -10
- package/dist/cli/commands/contract.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +13 -12
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/init/ci-platform.d.ts +35 -0
- package/dist/cli/commands/init/ci-platform.d.ts.map +1 -0
- package/dist/cli/commands/init/ci-platform.js +59 -0
- package/dist/cli/commands/init/ci-platform.js.map +1 -0
- package/dist/cli/commands/init/ci-wiring.d.ts +20 -0
- package/dist/cli/commands/init/ci-wiring.d.ts.map +1 -0
- package/dist/cli/commands/init/ci-wiring.js +72 -0
- package/dist/cli/commands/init/ci-wiring.js.map +1 -0
- package/dist/cli/commands/init/git-hooks.d.ts +15 -0
- package/dist/cli/commands/init/git-hooks.d.ts.map +1 -0
- package/dist/cli/commands/init/git-hooks.js +64 -0
- package/dist/cli/commands/init/git-hooks.js.map +1 -0
- package/dist/cli/commands/init/governance.d.ts +14 -0
- package/dist/cli/commands/init/governance.d.ts.map +1 -0
- package/dist/cli/commands/init/governance.js +132 -0
- package/dist/cli/commands/init/governance.js.map +1 -0
- package/dist/cli/commands/{init.d.ts → init/index.d.ts} +13 -14
- package/dist/cli/commands/init/index.d.ts.map +1 -0
- package/dist/cli/commands/init/index.js +148 -0
- package/dist/cli/commands/init/index.js.map +1 -0
- package/dist/cli/commands/init/output-style.d.ts +19 -0
- package/dist/cli/commands/init/output-style.d.ts.map +1 -0
- package/dist/cli/commands/init/output-style.js +110 -0
- package/dist/cli/commands/init/output-style.js.map +1 -0
- package/dist/cli/commands/init/presets.d.ts +26 -0
- package/dist/cli/commands/init/presets.d.ts.map +1 -0
- package/dist/cli/commands/init/presets.js +104 -0
- package/dist/cli/commands/init/presets.js.map +1 -0
- package/dist/cli/commands/init/snippets.d.ts +18 -0
- package/dist/cli/commands/init/snippets.d.ts.map +1 -0
- package/dist/cli/commands/init/snippets.js +49 -0
- package/dist/cli/commands/init/snippets.js.map +1 -0
- package/dist/cli/commands/knowledge/audit.d.ts +30 -0
- package/dist/cli/commands/knowledge/audit.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/audit.js +114 -0
- package/dist/cli/commands/knowledge/audit.js.map +1 -0
- package/dist/cli/commands/knowledge/decay.d.ts +19 -0
- package/dist/cli/commands/knowledge/decay.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/decay.js +48 -0
- package/dist/cli/commands/knowledge/decay.js.map +1 -0
- package/dist/cli/commands/knowledge/health.d.ts +36 -0
- package/dist/cli/commands/knowledge/health.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/health.js +172 -0
- package/dist/cli/commands/knowledge/health.js.map +1 -0
- package/dist/cli/commands/knowledge/import.d.ts +26 -0
- package/dist/cli/commands/knowledge/import.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/import.js +63 -0
- package/dist/cli/commands/knowledge/import.js.map +1 -0
- package/dist/cli/commands/knowledge/index.d.ts +25 -0
- package/dist/cli/commands/knowledge/index.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/index.js +84 -0
- package/dist/cli/commands/knowledge/index.js.map +1 -0
- package/dist/cli/commands/knowledge/list.d.ts +25 -0
- package/dist/cli/commands/knowledge/list.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/list.js +60 -0
- package/dist/cli/commands/knowledge/list.js.map +1 -0
- package/dist/cli/commands/knowledge/migrate.d.ts +21 -0
- package/dist/cli/commands/knowledge/migrate.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/migrate.js +48 -0
- package/dist/cli/commands/knowledge/migrate.js.map +1 -0
- package/dist/cli/commands/knowledge/search.d.ts +32 -0
- package/dist/cli/commands/knowledge/search.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/search.js +73 -0
- package/dist/cli/commands/knowledge/search.js.map +1 -0
- package/dist/cli/commands/knowledge/shared.d.ts +14 -0
- package/dist/cli/commands/knowledge/shared.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/shared.js +6 -0
- package/dist/cli/commands/knowledge/shared.js.map +1 -0
- package/dist/cli/commands/knowledge/snapshot.d.ts +18 -0
- package/dist/cli/commands/knowledge/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/snapshot.js +34 -0
- package/dist/cli/commands/knowledge/snapshot.js.map +1 -0
- package/dist/cli/commands/knowledge/stats.d.ts +26 -0
- package/dist/cli/commands/knowledge/stats.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/stats.js +132 -0
- package/dist/cli/commands/knowledge/stats.js.map +1 -0
- package/dist/cli/commands/knowledge/sync-rag.d.ts +19 -0
- package/dist/cli/commands/knowledge/sync-rag.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/sync-rag.js +77 -0
- package/dist/cli/commands/knowledge/sync-rag.js.map +1 -0
- package/dist/cli/commands/knowledge-view.d.ts +2 -1
- package/dist/cli/commands/knowledge-view.d.ts.map +1 -1
- package/dist/cli/commands/knowledge-view.js +2 -2
- package/dist/cli/commands/knowledge-view.js.map +1 -1
- package/dist/cli/commands/passes-gate.d.ts.map +1 -1
- package/dist/cli/commands/passes-gate.js +12 -2
- package/dist/cli/commands/passes-gate.js.map +1 -1
- package/dist/cli/commands/performance.js.map +1 -1
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +13 -41
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/review.d.ts.map +1 -1
- package/dist/cli/commands/review.js +3 -2
- package/dist/cli/commands/review.js.map +1 -1
- package/dist/cli/commands/security.d.ts.map +1 -1
- package/dist/cli/commands/security.js +7 -8
- package/dist/cli/commands/security.js.map +1 -1
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +6 -5
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.js +31 -55
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +18 -12
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/compact.d.ts +9 -0
- package/dist/cli/commands/sync-docs/compact.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/compact.js +73 -0
- package/dist/cli/commands/sync-docs/compact.js.map +1 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +17 -36
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/gate.d.ts +27 -0
- package/dist/cli/commands/sync-docs/gate.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/gate.js +72 -0
- package/dist/cli/commands/sync-docs/gate.js.map +1 -0
- package/dist/cli/commands/sync-docs/index.d.ts +13 -27
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +19 -529
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/main-flow.d.ts +37 -0
- package/dist/cli/commands/sync-docs/main-flow.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/main-flow.js +485 -0
- package/dist/cli/commands/sync-docs/main-flow.js.map +1 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js +16 -25
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/gate-command.d.ts +1 -1
- package/dist/cli/gate-command.d.ts.map +1 -1
- package/dist/context/index.d.ts +1 -3
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +2 -5
- package/dist/context/index.js.map +1 -1
- package/dist/context/session-manager.d.ts +2 -2
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +31 -52
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +2 -2
- package/dist/context/types.d.ts.map +1 -1
- package/dist/core/constraint-lifecycle.d.ts +1 -1
- package/dist/core/constraint-lifecycle.d.ts.map +1 -1
- package/dist/core/constraint-lifecycle.js +1 -1
- package/dist/core/constraint-lifecycle.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +2 -1
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +4 -6
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.js +1 -0
- package/dist/core/constraints/checkers/templated/exec.js.map +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +13 -34
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
- package/dist/core/constraints/definitions/guidelines.js +18 -0
- package/dist/core/constraints/definitions/guidelines.js.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.js +0 -16
- package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +192 -223
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/git-evidence.d.ts.map +1 -1
- package/dist/core/constraints/git-evidence.js +2 -0
- package/dist/core/constraints/git-evidence.js.map +1 -1
- package/dist/core/constraints/injection-writer.d.ts +1 -0
- package/dist/core/constraints/injection-writer.d.ts.map +1 -1
- package/dist/core/constraints/injection-writer.js +3 -6
- package/dist/core/constraints/injection-writer.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +3 -1
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +6 -6
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/spec/validator.d.ts +1 -1
- package/dist/core/spec/validator.d.ts.map +1 -1
- package/dist/core/spec/validator.js +41 -36
- package/dist/core/spec/validator.js.map +1 -1
- package/dist/core/validators/check-handlers/command.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/command.js +7 -4
- package/dist/core/validators/check-handlers/command.js.map +1 -1
- package/dist/core/validators/check-handlers/http.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/http.js +6 -4
- package/dist/core/validators/check-handlers/http.js.map +1 -1
- package/dist/core/validators/check-handlers/output.d.ts +1 -1
- package/dist/core/validators/check-handlers/output.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/output.js +2 -1
- package/dist/core/validators/check-handlers/output.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +2 -1
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +25 -30
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/gates/acceptance.d.ts +37 -18
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +129 -97
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/command.d.ts +1 -1
- package/dist/gates/contract.d.ts +11 -2
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +57 -62
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/performance.d.ts +1 -1
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +18 -8
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/registry.d.ts.map +1 -1
- package/dist/gates/registry.js +6 -2
- package/dist/gates/registry.js.map +1 -1
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +16 -2
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/security.d.ts +5 -1
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +57 -63
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +11 -78
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/gates/types.js +5 -1
- package/dist/gates/types.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit-dimensions.d.ts +45 -0
- package/dist/knowledge/audit-dimensions.d.ts.map +1 -0
- package/dist/knowledge/audit-dimensions.js +144 -0
- package/dist/knowledge/audit-dimensions.js.map +1 -0
- package/dist/knowledge/audit-rules.d.ts +41 -0
- package/dist/knowledge/audit-rules.d.ts.map +1 -0
- package/dist/knowledge/audit-rules.js +269 -0
- package/dist/knowledge/audit-rules.js.map +1 -0
- package/dist/knowledge/audit-scoring.d.ts +6 -60
- package/dist/knowledge/audit-scoring.d.ts.map +1 -1
- package/dist/knowledge/audit-scoring.js +8 -391
- package/dist/knowledge/audit-scoring.js.map +1 -1
- package/dist/knowledge/audit.d.ts +6 -3
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/audit.js +9 -6
- package/dist/knowledge/audit.js.map +1 -1
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/import.js +5 -4
- package/dist/knowledge/import.js.map +1 -1
- package/dist/knowledge/index-generator.d.ts +2 -0
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +43 -50
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/index.d.ts +4 -2
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +2 -1
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/ingest.d.ts +21 -5
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +12 -9
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lifecycle.d.ts.map +1 -1
- package/dist/knowledge/lifecycle.js +17 -22
- package/dist/knowledge/lifecycle.js.map +1 -1
- package/dist/knowledge/query.d.ts +1 -1
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js +7 -7
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/reference-tracker.d.ts.map +1 -1
- package/dist/knowledge/reference-tracker.js +14 -17
- package/dist/knowledge/reference-tracker.js.map +1 -1
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +17 -36
- package/dist/knowledge/store.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +2 -2
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +9 -7
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +6 -4
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/pretool-use-hook.d.ts +1 -1
- package/dist/pretool-use-hook.d.ts.map +1 -1
- package/dist/pretool-use-hook.js +12 -19
- package/dist/pretool-use-hook.js.map +1 -1
- package/dist/release/integrity.d.ts.map +1 -1
- package/dist/release/integrity.js +8 -8
- package/dist/release/integrity.js.map +1 -1
- package/dist/sdd/index-generator.d.ts.map +1 -1
- package/dist/sdd/index-generator.js +4 -0
- package/dist/sdd/index-generator.js.map +1 -1
- package/dist/types/checkpoint.d.ts +8 -8
- package/dist/types/checkpoint.d.ts.map +1 -1
- package/dist/types/command-io.d.ts +19 -0
- package/dist/types/command-io.d.ts.map +1 -0
- package/dist/types/command-io.js +3 -0
- package/dist/types/command-io.js.map +1 -0
- package/dist/types/gate.d.ts +72 -0
- package/dist/types/gate.d.ts.map +1 -0
- package/dist/types/gate.js +13 -0
- package/dist/types/gate.js.map +1 -0
- package/dist/utils/attempt.d.ts +22 -0
- package/dist/utils/attempt.d.ts.map +1 -0
- package/dist/utils/attempt.js +40 -0
- package/dist/utils/attempt.js.map +1 -0
- package/dist/utils/detect-source-roots.d.ts.map +1 -1
- package/dist/utils/detect-source-roots.js +42 -51
- package/dist/utils/detect-source-roots.js.map +1 -1
- package/dist/utils/file-walk.d.ts +2 -1
- package/dist/utils/file-walk.d.ts.map +1 -1
- package/dist/utils/file-walk.js +3 -8
- package/dist/utils/file-walk.js.map +1 -1
- package/dist/utils/package-json.d.ts +49 -0
- package/dist/utils/package-json.d.ts.map +1 -0
- package/dist/utils/package-json.js +78 -0
- package/dist/utils/package-json.js.map +1 -0
- package/dist/utils/package-version.d.ts +5 -2
- package/dist/utils/package-version.d.ts.map +1 -1
- package/dist/utils/package-version.js +8 -11
- package/dist/utils/package-version.js.map +1 -1
- package/package.json +1 -6
- package/src/CONTEXT.md +5 -4
- package/src/__tests__/acceptance-gate.test.ts +23 -51
- package/src/__tests__/contract-gate.test.ts +1 -1
- package/src/__tests__/install-precommit-hook.test.ts +61 -0
- package/src/__tests__/iron-laws.test.ts +5 -5
- package/src/__tests__/layering.test.ts +1 -1
- package/src/__tests__/public-exports.test.ts +1 -1
- package/src/__tests__/public-type-surface.test.ts +9 -19
- package/src/__tests__/public-value-surface.test.ts +9 -17
- package/src/__tests__/skip-semantics.test.ts +5 -4
- package/src/agents/lifecycle.ts +3 -5
- package/src/cli/__tests__/command-contract.test.ts +18 -0
- package/src/cli/command-contract.ts +8 -5
- package/src/cli/commands/CONTEXT.md +10 -10
- package/src/cli/commands/__tests__/check.test.ts +1 -1
- package/src/cli/commands/__tests__/constraints-retire.test.ts +5 -3
- package/src/cli/commands/__tests__/init-governance-io.test.ts +7 -2
- package/src/cli/commands/__tests__/init.test.ts +1 -1
- package/src/cli/commands/__tests__/knowledge-audit-threshold.test.ts +14 -8
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +2 -1
- package/src/cli/commands/__tests__/knowledge-view.test.ts +28 -18
- package/src/cli/commands/__tests__/knowledge.test.ts +6 -2
- package/src/cli/commands/__tests__/numeric-flag-assembly.test.ts +1 -1
- package/src/cli/commands/__tests__/passes-gate.test.ts +100 -24
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +3 -6
- package/src/cli/commands/__tests__/registry.test.ts +3 -2
- package/src/cli/commands/__tests__/release.test.ts +24 -2
- package/src/cli/commands/__tests__/report-false-green.test.ts +10 -6
- package/src/cli/commands/acceptance.ts +10 -9
- package/src/cli/commands/command.ts +1 -1
- package/src/cli/commands/constraints-retire.ts +3 -2
- package/src/cli/commands/contract.ts +29 -14
- package/src/cli/commands/definitions.ts +13 -12
- package/src/cli/commands/init/ci-platform.ts +66 -0
- package/src/cli/commands/init/ci-wiring.ts +48 -0
- package/src/cli/commands/init/git-hooks.ts +31 -0
- package/src/cli/commands/init/governance.ts +127 -0
- package/src/cli/commands/init/index.ts +156 -0
- package/src/cli/commands/init/output-style.ts +82 -0
- package/src/cli/commands/init/presets.ts +105 -0
- package/src/cli/commands/init/snippets.ts +57 -0
- package/src/cli/commands/knowledge/audit.ts +155 -0
- package/src/cli/commands/knowledge/decay.ts +57 -0
- package/src/cli/commands/knowledge/health.ts +176 -0
- package/src/cli/commands/knowledge/import.ts +82 -0
- package/src/cli/commands/knowledge/index.ts +60 -0
- package/src/cli/commands/knowledge/list.ts +73 -0
- package/src/cli/commands/knowledge/migrate.ts +61 -0
- package/src/cli/commands/knowledge/search.ts +93 -0
- package/src/cli/commands/knowledge/shared.ts +13 -0
- package/src/cli/commands/knowledge/snapshot.ts +38 -0
- package/src/cli/commands/knowledge/stats.ts +112 -0
- package/src/cli/commands/knowledge/sync-rag.ts +48 -0
- package/src/cli/commands/knowledge-view.ts +3 -2
- package/src/cli/commands/passes-gate.ts +14 -2
- package/src/cli/commands/performance.ts +2 -2
- package/src/cli/commands/release.ts +14 -9
- package/src/cli/commands/review.ts +5 -4
- package/src/cli/commands/security.ts +10 -11
- package/src/cli/commands/spec-baseline-check.ts +6 -7
- package/src/cli/commands/status.ts +2 -2
- package/src/cli/commands/sync-docs/agents-syncer.ts +28 -47
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +18 -11
- package/src/cli/commands/sync-docs/compact.ts +35 -0
- package/src/cli/commands/sync-docs/context-syncer.ts +15 -31
- package/src/cli/commands/sync-docs/gate.ts +78 -0
- package/src/cli/commands/sync-docs/index.ts +21 -585
- package/src/cli/commands/sync-docs/main-flow.ts +549 -0
- package/src/cli/commands/sync-docs/project-reader.ts +21 -24
- package/src/cli/gate-command.ts +1 -1
- package/src/context/CONTEXT.md +4 -4
- package/src/context/__tests__/session-manager.test.ts +18 -0
- package/src/context/index.ts +1 -5
- package/src/context/session-manager.ts +34 -50
- package/src/context/types.ts +2 -2
- package/src/core/CONTEXT.md +2 -2
- package/src/core/constraint-lifecycle.ts +2 -2
- package/src/core/constraints/capabilities-parser.ts +4 -6
- package/src/core/constraints/checkers/templated/exec.ts +1 -0
- package/src/core/constraints/checkers/templated/file-exists.ts +1 -1
- package/src/core/constraints/context-builder.ts +11 -28
- package/src/core/constraints/definitions/guidelines.ts +19 -0
- package/src/core/constraints/definitions/iron-laws.ts +0 -17
- package/src/core/constraints/doc-freshness/runner.ts +220 -244
- package/src/core/constraints/git-evidence.ts +2 -0
- package/src/core/constraints/injection-writer.ts +3 -6
- package/src/core/project-config-loader.ts +6 -5
- package/src/core/spec/__tests__/validator.test.ts +65 -13
- package/src/core/spec/validator.ts +50 -40
- package/src/core/validators/__tests__/passes-gate-counts.test.ts +52 -0
- package/src/core/validators/check-handlers/command.ts +9 -6
- package/src/core/validators/check-handlers/http.ts +8 -6
- package/src/core/validators/check-handlers/output.ts +7 -6
- package/src/core/validators/passes-gate.ts +31 -32
- package/src/gates/CONTEXT.md +7 -6
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +16 -14
- package/src/gates/__tests__/acceptance.test.ts +69 -94
- package/src/gates/__tests__/command-single-predicate.test.ts +1 -1
- package/src/gates/__tests__/command.test.ts +23 -12
- package/src/gates/__tests__/gate-interface.test.ts +2 -5
- package/src/gates/__tests__/performance.test.ts +3 -3
- package/src/gates/__tests__/security.test.ts +7 -19
- package/src/gates/acceptance.ts +176 -131
- package/src/gates/command.ts +1 -1
- package/src/gates/contract.ts +86 -79
- package/src/gates/performance.ts +35 -19
- package/src/gates/registry.ts +6 -3
- package/src/gates/review.ts +38 -10
- package/src/gates/security.ts +94 -81
- package/src/gates/types.ts +22 -84
- package/src/index.ts +8 -4
- package/src/knowledge/CONTEXT.md +9 -7
- package/src/knowledge/__tests__/audit-labels.test.ts +3 -3
- package/src/knowledge/__tests__/audit-scoring.test.ts +9 -7
- package/src/knowledge/__tests__/ingest.test.ts +17 -17
- package/src/knowledge/__tests__/store.test.ts +4 -6
- package/src/knowledge/audit-dimensions.ts +190 -0
- package/src/knowledge/audit-rules.ts +335 -0
- package/src/knowledge/audit-scoring.ts +7 -495
- package/src/knowledge/audit.ts +9 -11
- package/src/knowledge/import.ts +7 -6
- package/src/knowledge/index-generator.ts +48 -53
- package/src/knowledge/index.ts +4 -2
- package/src/knowledge/ingest.ts +27 -12
- package/src/knowledge/lifecycle.ts +17 -19
- package/src/knowledge/query.ts +7 -6
- package/src/knowledge/reference-tracker.ts +14 -16
- package/src/knowledge/store.ts +17 -32
- package/src/monitoring/trace-analyzer.ts +12 -9
- package/src/monitoring/traces.ts +8 -6
- package/src/pretool-use-hook.ts +26 -21
- package/src/release/CONTEXT.md +1 -1
- package/src/release/__tests__/integrity.test.ts +0 -2
- package/src/release/integrity.ts +8 -9
- package/src/sdd/index-generator.ts +4 -0
- package/src/types/checkpoint.ts +8 -8
- package/src/types/command-io.ts +14 -0
- package/src/types/gate.ts +77 -0
- package/src/utils/__tests__/attempt.test.ts +94 -0
- package/src/utils/__tests__/package-json.test.ts +58 -0
- package/src/utils/__tests__/package-version.test.ts +21 -2
- package/src/utils/attempt.ts +35 -0
- package/src/utils/detect-source-roots.ts +38 -44
- package/src/utils/file-walk.ts +3 -7
- package/src/utils/package-json.ts +61 -0
- package/src/utils/package-version.ts +8 -10
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/init.js +0 -502
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/knowledge.d.ts +0 -169
- package/dist/cli/commands/knowledge.d.ts.map +0 -1
- package/dist/cli/commands/knowledge.js +0 -700
- package/dist/cli/commands/knowledge.js.map +0 -1
- package/dist/context/knowledge-injector.d.ts +0 -51
- package/dist/context/knowledge-injector.d.ts.map +0 -1
- package/dist/context/knowledge-injector.js +0 -128
- package/dist/context/knowledge-injector.js.map +0 -1
- package/dist/gates/index.d.ts +0 -10
- package/dist/gates/index.d.ts.map +0 -1
- package/dist/gates/index.js +0 -11
- package/dist/gates/index.js.map +0 -1
- package/src/cli/commands/init.ts +0 -590
- package/src/cli/commands/knowledge.ts +0 -820
- package/src/context/__tests__/knowledge-injector.test.ts +0 -197
- package/src/context/knowledge-injector.ts +0 -174
- package/src/gates/index.ts +0 -11
|
@@ -120,7 +120,11 @@ describe('SpecValidator', () => {
|
|
|
120
120
|
|
|
121
121
|
describe('validateFile() with YAML', () => {
|
|
122
122
|
it('should validate valid YAML file', async () => {
|
|
123
|
-
mockFs.access.
|
|
123
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
124
|
+
String(p).includes('schemas')
|
|
125
|
+
? Promise.reject(new Error('no schema'))
|
|
126
|
+
: Promise.resolve(undefined)
|
|
127
|
+
);
|
|
124
128
|
mockFs.readFile.mockResolvedValue('name: test\nversion: 1');
|
|
125
129
|
|
|
126
130
|
const result = await validator.validateFile('specs/test.yml');
|
|
@@ -129,7 +133,11 @@ describe('SpecValidator', () => {
|
|
|
129
133
|
});
|
|
130
134
|
|
|
131
135
|
it('should detect invalid YAML', async () => {
|
|
132
|
-
mockFs.access.
|
|
136
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
137
|
+
String(p).includes('schemas')
|
|
138
|
+
? Promise.reject(new Error('no schema'))
|
|
139
|
+
: Promise.resolve(undefined)
|
|
140
|
+
);
|
|
133
141
|
mockFs.readFile.mockResolvedValue('invalid: yaml: content:');
|
|
134
142
|
|
|
135
143
|
const result = await validator.validateFile('specs/bad.yml');
|
|
@@ -140,7 +148,11 @@ describe('SpecValidator', () => {
|
|
|
140
148
|
|
|
141
149
|
describe('validateFile() with ARCHITECTURE.md', () => {
|
|
142
150
|
it('should validate valid ARCHITECTURE.md', async () => {
|
|
143
|
-
mockFs.access.
|
|
151
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
152
|
+
String(p).includes('schemas')
|
|
153
|
+
? Promise.reject(new Error('no schema'))
|
|
154
|
+
: Promise.resolve(undefined)
|
|
155
|
+
);
|
|
144
156
|
mockFs.readFile.mockResolvedValue('# Architecture\n\n## Module A\n\nContent...');
|
|
145
157
|
|
|
146
158
|
const result = await validator.validateFile('ARCHITECTURE.md');
|
|
@@ -149,7 +161,11 @@ describe('SpecValidator', () => {
|
|
|
149
161
|
});
|
|
150
162
|
|
|
151
163
|
it('should warn on missing headers', async () => {
|
|
152
|
-
mockFs.access.
|
|
164
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
165
|
+
String(p).includes('schemas')
|
|
166
|
+
? Promise.reject(new Error('no schema'))
|
|
167
|
+
: Promise.resolve(undefined)
|
|
168
|
+
);
|
|
153
169
|
mockFs.readFile.mockResolvedValue('Just plain text without headers');
|
|
154
170
|
|
|
155
171
|
const result = await validator.validateFile('ARCHITECTURE.md');
|
|
@@ -169,7 +185,11 @@ describe('SpecValidator', () => {
|
|
|
169
185
|
|
|
170
186
|
it('should identify specs directory files', async () => {
|
|
171
187
|
// specs/ 下的文件应该被识别
|
|
172
|
-
mockFs.access.
|
|
188
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
189
|
+
String(p).includes('schemas')
|
|
190
|
+
? Promise.reject(new Error('no schema'))
|
|
191
|
+
: Promise.resolve(undefined)
|
|
192
|
+
);
|
|
173
193
|
mockFs.readFile.mockResolvedValue('# Test\n\nContent');
|
|
174
194
|
const result = await validator.validateFile('specs/modules/test.md');
|
|
175
195
|
expect(result.file).toBe('specs/modules/test.md');
|
|
@@ -178,7 +198,11 @@ describe('SpecValidator', () => {
|
|
|
178
198
|
|
|
179
199
|
describe('basicValidation()', () => {
|
|
180
200
|
it('should return valid for empty content', async () => {
|
|
181
|
-
mockFs.access.
|
|
201
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
202
|
+
String(p).includes('schemas')
|
|
203
|
+
? Promise.reject(new Error('no schema'))
|
|
204
|
+
: Promise.resolve(undefined)
|
|
205
|
+
);
|
|
182
206
|
mockFs.readFile.mockResolvedValue('');
|
|
183
207
|
|
|
184
208
|
const result = await validator.validateFile('specs/empty.yml');
|
|
@@ -190,7 +214,11 @@ describe('SpecValidator', () => {
|
|
|
190
214
|
|
|
191
215
|
describe('fileExists()', () => {
|
|
192
216
|
it('should return true for existing file', async () => {
|
|
193
|
-
mockFs.access.
|
|
217
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
218
|
+
String(p).includes('schemas')
|
|
219
|
+
? Promise.reject(new Error('no schema'))
|
|
220
|
+
: Promise.resolve(undefined)
|
|
221
|
+
);
|
|
194
222
|
mockFs.readFile.mockResolvedValue('test');
|
|
195
223
|
|
|
196
224
|
const result = await validator.validateFile('specs/existing.yml');
|
|
@@ -291,7 +319,11 @@ describe('SpecValidator', () => {
|
|
|
291
319
|
|
|
292
320
|
describe('validate with custom schema', () => {
|
|
293
321
|
it('should use provided schema', async () => {
|
|
294
|
-
mockFs.access.
|
|
322
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
323
|
+
String(p).includes('schemas')
|
|
324
|
+
? Promise.reject(new Error('no schema'))
|
|
325
|
+
: Promise.resolve(undefined)
|
|
326
|
+
);
|
|
295
327
|
mockFs.readFile.mockResolvedValue('custom content');
|
|
296
328
|
|
|
297
329
|
const customSchema = {
|
|
@@ -311,7 +343,11 @@ describe('SpecValidator', () => {
|
|
|
311
343
|
});
|
|
312
344
|
|
|
313
345
|
it('should handle schema validation errors', async () => {
|
|
314
|
-
mockFs.access.
|
|
346
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
347
|
+
String(p).includes('schemas')
|
|
348
|
+
? Promise.reject(new Error('no schema'))
|
|
349
|
+
: Promise.resolve(undefined)
|
|
350
|
+
);
|
|
315
351
|
mockFs.readFile.mockResolvedValue('bad content');
|
|
316
352
|
|
|
317
353
|
const failingSchema = {
|
|
@@ -332,7 +368,11 @@ describe('SpecValidator', () => {
|
|
|
332
368
|
});
|
|
333
369
|
|
|
334
370
|
it('should handle schema throwing exception', async () => {
|
|
335
|
-
mockFs.access.
|
|
371
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
372
|
+
String(p).includes('schemas')
|
|
373
|
+
? Promise.reject(new Error('no schema'))
|
|
374
|
+
: Promise.resolve(undefined)
|
|
375
|
+
);
|
|
336
376
|
mockFs.readFile.mockResolvedValue('content');
|
|
337
377
|
|
|
338
378
|
const throwingSchema = {
|
|
@@ -351,7 +391,11 @@ describe('SpecValidator', () => {
|
|
|
351
391
|
|
|
352
392
|
describe('validateFile() without schema', () => {
|
|
353
393
|
it('should use basicValidation when no schema provided', async () => {
|
|
354
|
-
mockFs.access.
|
|
394
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
395
|
+
String(p).includes('schemas')
|
|
396
|
+
? Promise.reject(new Error('no schema'))
|
|
397
|
+
: Promise.resolve(undefined)
|
|
398
|
+
);
|
|
355
399
|
mockFs.readFile.mockResolvedValue('# Title\n\n## Section\n\nContent');
|
|
356
400
|
|
|
357
401
|
const result = await validator.validateFile('ARCHITECTURE.md');
|
|
@@ -361,7 +405,11 @@ describe('SpecValidator', () => {
|
|
|
361
405
|
});
|
|
362
406
|
|
|
363
407
|
it('should detect missing headers in architecture file', async () => {
|
|
364
|
-
mockFs.access.
|
|
408
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
409
|
+
String(p).includes('schemas')
|
|
410
|
+
? Promise.reject(new Error('no schema'))
|
|
411
|
+
: Promise.resolve(undefined)
|
|
412
|
+
);
|
|
365
413
|
mockFs.readFile.mockResolvedValue('Plain text without any headers');
|
|
366
414
|
|
|
367
415
|
const result = await validator.validateFile('ARCHITECTURE.md');
|
|
@@ -375,7 +423,11 @@ describe('SpecValidator', () => {
|
|
|
375
423
|
|
|
376
424
|
describe('convenience functions', () => {
|
|
377
425
|
it('validateSpec should work without schemaPath', async () => {
|
|
378
|
-
mockFs.access.
|
|
426
|
+
mockFs.access.mockImplementation((p: any) =>
|
|
427
|
+
String(p).includes('schemas')
|
|
428
|
+
? Promise.reject(new Error('no schema'))
|
|
429
|
+
: Promise.resolve(undefined)
|
|
430
|
+
);
|
|
379
431
|
mockFs.readFile.mockResolvedValue('content');
|
|
380
432
|
|
|
381
433
|
const result = await validateSpec('specs/test.yml');
|
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
BatchSpecValidationResult,
|
|
20
20
|
SpecSchemaDefinition,
|
|
21
21
|
SpecType,
|
|
22
|
+
SpecValidationError,
|
|
22
23
|
} from '../../types/spec';
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -31,6 +32,19 @@ const DEFAULT_CONFIG: SpecValidatorConfig = {
|
|
|
31
32
|
failureLevel: 'error',
|
|
32
33
|
};
|
|
33
34
|
|
|
35
|
+
/**
|
|
36
|
+
* 动态导入的 Schema 模块形状守卫:只认「带 validate 函数的对象」,
|
|
37
|
+
* name/version 是否合法字符串由调用点各自窄化(坏形状按「无 Schema」处理,不 any 穿透)
|
|
38
|
+
*/
|
|
39
|
+
function isSchemaModule(m: unknown): m is { name?: unknown; version?: unknown; validate: SpecSchemaDefinition['validate'] } {
|
|
40
|
+
return (
|
|
41
|
+
typeof m === 'object' &&
|
|
42
|
+
m !== null &&
|
|
43
|
+
'validate' in m &&
|
|
44
|
+
typeof (m as { validate?: unknown }).validate === 'function'
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
34
48
|
/**
|
|
35
49
|
* Spec 验证器
|
|
36
50
|
*/
|
|
@@ -74,38 +88,36 @@ export class SpecValidator {
|
|
|
74
88
|
|
|
75
89
|
const absolutePath = path.resolve(schemaPath);
|
|
76
90
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (schemaModule && schemaModule.validate) {
|
|
95
|
-
const schema: SpecSchemaDefinition = {
|
|
96
|
-
name: schemaModule.name || 'custom',
|
|
97
|
-
version: schemaModule.version,
|
|
98
|
-
validate: schemaModule.validate,
|
|
99
|
-
};
|
|
100
|
-
this.schemaCache.set(schemaPath, schema);
|
|
101
|
-
return schema;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return null;
|
|
105
|
-
} catch (error) {
|
|
106
|
-
// Schema 加载失败是正常的(项目可能没有自定义 Schema)
|
|
91
|
+
// 无自定义 Schema 是正常情况(三个候选都不在场 → null);
|
|
92
|
+
// 候选在场但加载/解析失败 → 抛出(fail-fast:坏 Schema 不装成「没有 Schema」)
|
|
93
|
+
const indexPath = path.join(absolutePath, 'index.ts');
|
|
94
|
+
const indexPathJs = path.join(absolutePath, 'index.js');
|
|
95
|
+
|
|
96
|
+
let schemaModule: unknown;
|
|
97
|
+
|
|
98
|
+
if (await this.fileExists(indexPath)) {
|
|
99
|
+
// 动态导入 TypeScript 模块(需要 tsx 或编译后的 .js)
|
|
100
|
+
schemaModule = await this.dynamicImport(indexPath);
|
|
101
|
+
} else if (await this.fileExists(indexPathJs)) {
|
|
102
|
+
schemaModule = await this.dynamicImport(indexPathJs);
|
|
103
|
+
} else if (await this.fileExists(absolutePath)) {
|
|
104
|
+
// 尝试直接加载指定文件
|
|
105
|
+
schemaModule = await this.dynamicImport(absolutePath);
|
|
106
|
+
} else {
|
|
107
107
|
return null;
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
if (isSchemaModule(schemaModule)) {
|
|
111
|
+
const schema: SpecSchemaDefinition = {
|
|
112
|
+
name: typeof schemaModule.name === 'string' ? schemaModule.name : 'custom',
|
|
113
|
+
version: typeof schemaModule.version === 'string' ? schemaModule.version : undefined,
|
|
114
|
+
validate: schemaModule.validate,
|
|
115
|
+
};
|
|
116
|
+
this.schemaCache.set(schemaPath, schema);
|
|
117
|
+
return schema;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return null;
|
|
109
121
|
}
|
|
110
122
|
|
|
111
123
|
/**
|
|
@@ -188,8 +200,8 @@ export class SpecValidator {
|
|
|
188
200
|
private async basicValidation(filePath: string, specType: SpecType): Promise<SpecValidationResult> {
|
|
189
201
|
const absolutePath = path.resolve(filePath);
|
|
190
202
|
const content = await fs.readFile(absolutePath, 'utf-8');
|
|
191
|
-
const errors:
|
|
192
|
-
const warnings:
|
|
203
|
+
const errors: SpecValidationError[] = [];
|
|
204
|
+
const warnings: SpecValidationError[] = [];
|
|
193
205
|
|
|
194
206
|
// ARCHITECTURE.md 基础检查
|
|
195
207
|
if (specType === 'architecture') {
|
|
@@ -337,23 +349,21 @@ export class SpecValidator {
|
|
|
337
349
|
}
|
|
338
350
|
|
|
339
351
|
/**
|
|
340
|
-
*
|
|
352
|
+
* 动态导入模块(fail-fast:导入失败抛出;唯一回退 = .ts 导入失败试编译后的同名 .js)
|
|
341
353
|
*/
|
|
342
|
-
private async dynamicImport(modulePath: string): Promise<
|
|
354
|
+
private async dynamicImport(modulePath: string): Promise<unknown> {
|
|
343
355
|
try {
|
|
344
356
|
// 尝试直接导入
|
|
345
357
|
return await import(modulePath);
|
|
346
|
-
} catch {
|
|
358
|
+
} catch (err) {
|
|
347
359
|
// 如果是 TypeScript 文件,尝试加载编译后的 JS
|
|
348
360
|
if (modulePath.endsWith('.ts')) {
|
|
349
361
|
const jsPath = modulePath.replace(/\.ts$/, '.js');
|
|
350
|
-
|
|
351
|
-
return
|
|
352
|
-
} catch {
|
|
353
|
-
return null;
|
|
362
|
+
if (await this.fileExists(jsPath)) {
|
|
363
|
+
return import(jsPath);
|
|
354
364
|
}
|
|
355
365
|
}
|
|
356
|
-
|
|
366
|
+
throw err;
|
|
357
367
|
}
|
|
358
368
|
}
|
|
359
369
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runTests 的计数解析(2026-09-30)
|
|
3
|
+
*
|
|
4
|
+
* 判负时若输出里读不到失败计数,`failedTests` 给 null 而不是写死 1。旧写法把「命令没跑成」
|
|
5
|
+
* (进程被杀 / 输出溢出 / 无汇总行)显示成「1 个用例失败」,实发一次把人引去查并不存在的红用例。
|
|
6
|
+
* 这里跑真子进程(快、无 I/O 依赖),钉住三态:读到数值 / 判负读不到 / 判过无失败。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
|
|
10
|
+
import * as fs from 'fs';
|
|
11
|
+
import * as os from 'os';
|
|
12
|
+
import * as path from 'path';
|
|
13
|
+
import { PassesGate } from '../passes-gate';
|
|
14
|
+
|
|
15
|
+
describe('PassesGate.runTests 的失败计数', () => {
|
|
16
|
+
// runTest 会把证据落到 workDir/.harness/evidence —— 用临时目录,不污染本仓(既有 runTests
|
|
17
|
+
// 用例正因这层 I/O 被跳过,本组要钉的恰是 exec 之后的计数,绕不开真子进程)
|
|
18
|
+
let workDir: string;
|
|
19
|
+
|
|
20
|
+
beforeAll(() => {
|
|
21
|
+
workDir = fs.mkdtempSync(path.join(os.tmpdir(), 'passes-gate-counts-'));
|
|
22
|
+
fs.mkdirSync(path.join(workDir, '.harness'), { recursive: true });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterAll(() => { fs.rmSync(workDir, { recursive: true, force: true }); });
|
|
26
|
+
|
|
27
|
+
const gate = (testCommand: string) => new PassesGate({ testCommand });
|
|
28
|
+
|
|
29
|
+
it('输出里有失败计数 → 如实取数', async () => {
|
|
30
|
+
const result = await gate(`sh -c 'echo "Tests: 3 passed, 1 failed, 4 total"; exit 1'`).runTests(workDir);
|
|
31
|
+
|
|
32
|
+
expect(result.passed).toBe(false);
|
|
33
|
+
expect(result.failedTests).toBe(1);
|
|
34
|
+
expect(result.passedTests).toBe(3);
|
|
35
|
+
expect(result.totalTests).toBe(4);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('判负但输出无失败计数行 → failedTests 为 null,不编造成 1', async () => {
|
|
39
|
+
const result = await gate(`sh -c 'echo some noise; exit 3'`).runTests(workDir);
|
|
40
|
+
|
|
41
|
+
expect(result.passed).toBe(false);
|
|
42
|
+
expect(result.failedTests).toBeNull();
|
|
43
|
+
expect(result.totalTests).toBe(0);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('判过且无失败字样 → failedTests 为 0(null 只留给「判负且读不到」)', async () => {
|
|
47
|
+
const result = await gate(`sh -c 'echo all good; exit 0'`).runTests(workDir);
|
|
48
|
+
|
|
49
|
+
expect(result.passed).toBe(true);
|
|
50
|
+
expect(result.failedTests).toBe(0);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -57,14 +57,16 @@ export async function checkCommandSuccess(check: CheckpointCheck, context: Check
|
|
|
57
57
|
expected: 'exit code 0',
|
|
58
58
|
error: tail ? `输出末段:\n${tail}` : `exit code ${code}`,
|
|
59
59
|
};
|
|
60
|
-
} catch (error
|
|
60
|
+
} catch (error) {
|
|
61
|
+
// spawn 自身失败(如 shell 不可用):文本即诊断,判失败回带
|
|
62
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
61
63
|
return {
|
|
62
64
|
checkId: check.id,
|
|
63
65
|
passed: false,
|
|
64
66
|
message: `命令执行失败: ${command}`,
|
|
65
|
-
actual:
|
|
67
|
+
actual: detail,
|
|
66
68
|
expected: 'exit code 0',
|
|
67
|
-
error:
|
|
69
|
+
error: detail,
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
72
|
}
|
|
@@ -85,14 +87,15 @@ export async function checkCommandOutput(check: CheckpointCheck, context: Checkp
|
|
|
85
87
|
actual,
|
|
86
88
|
expected,
|
|
87
89
|
};
|
|
88
|
-
} catch (error
|
|
90
|
+
} catch (error) {
|
|
91
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
89
92
|
return {
|
|
90
93
|
checkId: check.id,
|
|
91
94
|
passed: false,
|
|
92
95
|
message: `命令执行失败: ${command}`,
|
|
93
|
-
actual:
|
|
96
|
+
actual: detail,
|
|
94
97
|
expected,
|
|
95
|
-
error:
|
|
98
|
+
error: detail,
|
|
96
99
|
};
|
|
97
100
|
}
|
|
98
101
|
}
|
|
@@ -53,14 +53,15 @@ export async function checkHttpStatus(check: CheckpointCheck, context: Checkpoin
|
|
|
53
53
|
actual,
|
|
54
54
|
expected,
|
|
55
55
|
};
|
|
56
|
-
} catch (error
|
|
56
|
+
} catch (error) {
|
|
57
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
57
58
|
return {
|
|
58
59
|
checkId: check.id,
|
|
59
60
|
passed: false,
|
|
60
61
|
message: `HTTP 请求失败: ${url}`,
|
|
61
|
-
actual:
|
|
62
|
+
actual: detail,
|
|
62
63
|
expected,
|
|
63
|
-
error:
|
|
64
|
+
error: detail,
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
67
|
}
|
|
@@ -86,14 +87,15 @@ export async function checkHttpBody(check: CheckpointCheck, context: CheckpointC
|
|
|
86
87
|
actual,
|
|
87
88
|
expected,
|
|
88
89
|
};
|
|
89
|
-
} catch (error
|
|
90
|
+
} catch (error) {
|
|
91
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
90
92
|
return {
|
|
91
93
|
checkId: check.id,
|
|
92
94
|
passed: false,
|
|
93
95
|
message: `HTTP 请求失败: ${url}`,
|
|
94
|
-
actual:
|
|
96
|
+
actual: detail,
|
|
95
97
|
expected,
|
|
96
|
-
error:
|
|
98
|
+
error: detail,
|
|
97
99
|
};
|
|
98
100
|
}
|
|
99
101
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { execAsync } from '../../../utils/exec';
|
|
11
11
|
import type { CheckpointCheck, CheckResult, CheckpointContext } from '../../../types/checkpoint';
|
|
12
12
|
|
|
13
|
-
export function stringifyOutput(output:
|
|
13
|
+
export function stringifyOutput(output: unknown): string {
|
|
14
14
|
if (typeof output === 'string') {
|
|
15
15
|
return output;
|
|
16
16
|
}
|
|
@@ -36,8 +36,9 @@ async function resolveOutput(
|
|
|
36
36
|
try {
|
|
37
37
|
const { stdout } = await execAsync(command, { cwd: context.workdir });
|
|
38
38
|
return { output: stdout };
|
|
39
|
-
} catch (error
|
|
40
|
-
|
|
39
|
+
} catch (error) {
|
|
40
|
+
// 命令不存在/启动失败:错误文本即诊断信息,落 commandError 由调用族判失败
|
|
41
|
+
return { output: '', commandError: error instanceof Error ? error.message : String(error) };
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
return { output: '' };
|
|
@@ -125,7 +126,7 @@ export async function checkJsonPath(check: CheckpointCheck, context: CheckpointC
|
|
|
125
126
|
const jsonPath = check.config.jsonPath || '';
|
|
126
127
|
const expected = check.config.expected;
|
|
127
128
|
|
|
128
|
-
let actual:
|
|
129
|
+
let actual: unknown;
|
|
129
130
|
try {
|
|
130
131
|
actual = getJsonValue(context.output, jsonPath);
|
|
131
132
|
} catch (error) {
|
|
@@ -150,7 +151,7 @@ export async function checkJsonPath(check: CheckpointCheck, context: CheckpointC
|
|
|
150
151
|
};
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
function getJsonValue(obj:
|
|
154
|
+
function getJsonValue(obj: unknown, jsonPath: string): unknown {
|
|
154
155
|
const parts = jsonPath.split('.');
|
|
155
156
|
let current = obj;
|
|
156
157
|
|
|
@@ -158,7 +159,7 @@ function getJsonValue(obj: any, jsonPath: string): any {
|
|
|
158
159
|
if (current === null || current === undefined) {
|
|
159
160
|
return undefined;
|
|
160
161
|
}
|
|
161
|
-
current = current[part];
|
|
162
|
+
current = (current as Record<string, unknown>)[part];
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
return current;
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
import { execAsync } from '../../utils/exec';
|
|
11
11
|
import { judgeTestRun } from './test-output';
|
|
12
|
+
import { readPackageJson } from '../../utils/package-json';
|
|
12
13
|
import * as fs from 'fs/promises';
|
|
14
|
+
import { existsSync } from 'fs';
|
|
13
15
|
import * as path from 'path';
|
|
14
16
|
import { EVIDENCE_DIR_REL } from '../../types/passes-gate';
|
|
15
17
|
import type {
|
|
@@ -39,10 +41,9 @@ const DEFAULT_CONFIG: Required<PassesGateConfig> = {
|
|
|
39
41
|
* 探不到返回 undefined,兜底策略归调用方(CLI 映射为 skip;PassesGate 内部 fail-closed)。
|
|
40
42
|
*/
|
|
41
43
|
export async function detectTestCommand(projectPath: string): Promise<string | undefined> {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// package.json 缺失 = 非 Node 项目(继续探测其余类型);在场但 JSON 损坏 → 抛出(fail-fast)
|
|
45
|
+
const pkg = readPackageJson(projectPath);
|
|
46
|
+
if (pkg) {
|
|
46
47
|
if (pkg.scripts?.['test:ci']) {
|
|
47
48
|
return 'npm run test:ci';
|
|
48
49
|
}
|
|
@@ -55,23 +56,19 @@ export async function detectTestCommand(projectPath: string): Promise<string | u
|
|
|
55
56
|
if (pkg.scripts?.['test:coverage']) {
|
|
56
57
|
return 'npm run test:coverage';
|
|
57
58
|
}
|
|
58
|
-
} catch {
|
|
59
|
-
// 没有 package.json,继续探测其他项目类型
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
// Python 项目:pyproject.toml 或 pytest.ini 任一命中
|
|
63
62
|
for (const marker of ['pyproject.toml', 'pytest.ini']) {
|
|
64
|
-
|
|
65
|
-
await fs.access(path.join(projectPath, marker));
|
|
63
|
+
if (existsSync(path.join(projectPath, marker))) {
|
|
66
64
|
return 'pytest';
|
|
67
|
-
}
|
|
65
|
+
}
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
// Go 项目
|
|
71
|
-
|
|
72
|
-
await fs.access(path.join(projectPath, 'go.mod'));
|
|
69
|
+
if (existsSync(path.join(projectPath, 'go.mod'))) {
|
|
73
70
|
return 'go test ./...';
|
|
74
|
-
}
|
|
71
|
+
}
|
|
75
72
|
|
|
76
73
|
return undefined;
|
|
77
74
|
}
|
|
@@ -161,7 +158,8 @@ export class PassesGate {
|
|
|
161
158
|
async runTests(workDir: string): Promise<{
|
|
162
159
|
passed: boolean;
|
|
163
160
|
passedTests: number;
|
|
164
|
-
|
|
161
|
+
/** 失败用例数;`null` = 命令判负但输出里读不到失败计数(进程被杀 / 输出无汇总行 / buffer 溢出等),不编造成 1 */
|
|
162
|
+
failedTests: number | null;
|
|
165
163
|
totalTests: number;
|
|
166
164
|
duration: number;
|
|
167
165
|
failures?: { name: string; message: string }[];
|
|
@@ -192,25 +190,28 @@ export class PassesGate {
|
|
|
192
190
|
const failedMatch = output.match(/(\d+) failed/i);
|
|
193
191
|
|
|
194
192
|
const passedTests = passedMatch?.[1] ? parseInt(passedMatch[1], 10) : (result.passed ? 1 : 0);
|
|
195
|
-
|
|
193
|
+
// 判负但输出里读不到失败计数 → 如实给 null。旧写法在这里写死 1,于是「命令没跑成」
|
|
194
|
+
// (进程被杀 / 输出溢出 / 无汇总行)在屏幕上长成「1 个用例失败」,把人往查测试上引
|
|
195
|
+
// (2026-09-30 实发:一次非零退出被显示成 201/202 失败 1,实际没有任何用例红)。
|
|
196
|
+
const failedTests = failedMatch?.[1] ? parseInt(failedMatch[1], 10) : (result.passed ? 0 : null);
|
|
196
197
|
|
|
197
198
|
return {
|
|
198
199
|
passed: result.passed,
|
|
199
200
|
passedTests,
|
|
200
201
|
failedTests,
|
|
201
|
-
totalTests: passedTests + failedTests,
|
|
202
|
+
totalTests: passedTests + (failedTests ?? 0),
|
|
202
203
|
duration,
|
|
203
204
|
failures: result.failures?.map(f => ({ name: f, message: f })),
|
|
204
205
|
message: result.passed ? '测试通过' : '测试失败',
|
|
205
206
|
};
|
|
206
|
-
} catch (error
|
|
207
|
+
} catch (error) {
|
|
207
208
|
return {
|
|
208
209
|
passed: false,
|
|
209
210
|
passedTests: 0,
|
|
210
|
-
failedTests:
|
|
211
|
-
totalTests:
|
|
211
|
+
failedTests: null,
|
|
212
|
+
totalTests: 0,
|
|
212
213
|
duration: Date.now() - startTime,
|
|
213
|
-
message: error.message,
|
|
214
|
+
message: error instanceof Error ? error.message : String(error),
|
|
214
215
|
};
|
|
215
216
|
}
|
|
216
217
|
}
|
|
@@ -241,10 +242,13 @@ export class PassesGate {
|
|
|
241
242
|
maxBuffer: 10 * 1024 * 1024, // 10MB buffer
|
|
242
243
|
});
|
|
243
244
|
output = result.stdout + result.stderr;
|
|
244
|
-
} catch (error
|
|
245
|
-
// 非零退出(超时 / buffer
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
} catch (error) {
|
|
246
|
+
// 非零退出(超时 / buffer 溢出等执行失败也落这里):判定依据就是退出码,文本不参与。
|
|
247
|
+
// exec 的 rejection 形状是 Error & { code?, stdout?, stderr? },逐字段窄化取数
|
|
248
|
+
const execError = error as { code?: unknown; stdout?: unknown; stderr?: unknown };
|
|
249
|
+
exitCode = typeof execError.code === 'number' ? execError.code : 1;
|
|
250
|
+
output = (typeof execError.stdout === 'string' ? execError.stdout : '')
|
|
251
|
+
+ '\n' + (typeof execError.stderr === 'string' ? execError.stderr : '');
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
const { passed, failures } = judgeTestRun({
|
|
@@ -282,15 +286,10 @@ export class PassesGate {
|
|
|
282
286
|
* 验证证据存在
|
|
283
287
|
*/
|
|
284
288
|
private async verifyEvidence(evidencePath: string, workDir: string): Promise<boolean> {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
await fs.access(fullPath);
|
|
290
|
-
return true;
|
|
291
|
-
} catch {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
289
|
+
const fullPath = path.isAbsolute(evidencePath)
|
|
290
|
+
? evidencePath
|
|
291
|
+
: path.join(workDir, evidencePath);
|
|
292
|
+
return existsSync(fullPath);
|
|
294
293
|
}
|
|
295
294
|
|
|
296
295
|
}
|