@dommaker/harness 2.0.0 → 3.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 +19 -0
- package/README.md +7 -7
- package/dist/agents/index.d.ts +1 -2
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/lifecycle.d.ts +2 -34
- package/dist/agents/lifecycle.d.ts.map +1 -1
- package/dist/agents/lifecycle.js +1 -100
- package/dist/agents/lifecycle.js.map +1 -1
- package/dist/agents/types.d.ts +1 -19
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/{hooks → bootstrap}/bootstrap.d.ts +9 -3
- package/dist/bootstrap/bootstrap.d.ts.map +1 -0
- package/dist/{hooks → bootstrap}/bootstrap.js +26 -30
- package/dist/bootstrap/bootstrap.js.map +1 -0
- package/dist/{hooks → bootstrap}/index.d.ts +3 -2
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/{hooks → bootstrap}/index.js +3 -2
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/cli/commands/acceptance.d.ts.map +1 -1
- package/dist/cli/commands/acceptance.js +1 -1
- package/dist/cli/commands/acceptance.js.map +1 -1
- package/dist/cli/commands/check.d.ts +1 -1
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +12 -5
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/command.d.ts.map +1 -1
- package/dist/cli/commands/command.js +9 -5
- package/dist/cli/commands/command.js.map +1 -1
- package/dist/cli/commands/constraints-pack-proposal.d.ts.map +1 -1
- package/dist/cli/commands/constraints-pack-proposal.js +11 -8
- package/dist/cli/commands/constraints-pack-proposal.js.map +1 -1
- package/dist/cli/commands/constraints-reactivate.d.ts +10 -2
- package/dist/cli/commands/constraints-reactivate.d.ts.map +1 -1
- package/dist/cli/commands/constraints-reactivate.js +2 -6
- package/dist/cli/commands/constraints-reactivate.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +23 -5
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +17 -8
- 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 +4 -6
- package/dist/cli/commands/contract.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts +2 -73
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +2 -7
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/failure.d.ts.map +1 -1
- package/dist/cli/commands/failure.js +5 -6
- package/dist/cli/commands/failure.js.map +1 -1
- package/dist/cli/commands/knowledge/health.d.ts +4 -2
- package/dist/cli/commands/knowledge/health.d.ts.map +1 -1
- package/dist/cli/commands/knowledge/health.js +25 -19
- package/dist/cli/commands/knowledge/health.js.map +1 -1
- package/dist/cli/commands/knowledge/import.d.ts +1 -1
- package/dist/cli/commands/knowledge/import.js +2 -2
- package/dist/cli/commands/knowledge/import.js.map +1 -1
- package/dist/cli/commands/knowledge/search.d.ts.map +1 -1
- package/dist/cli/commands/knowledge/search.js +1 -2
- package/dist/cli/commands/knowledge/search.js.map +1 -1
- package/dist/cli/commands/knowledge/store-access.d.ts +25 -0
- package/dist/cli/commands/knowledge/store-access.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/store-access.js +69 -0
- package/dist/cli/commands/knowledge/store-access.js.map +1 -0
- package/dist/cli/commands/knowledge-view.d.ts +6 -18
- package/dist/cli/commands/knowledge-view.d.ts.map +1 -1
- package/dist/cli/commands/knowledge-view.js +10 -61
- 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 +7 -6
- package/dist/cli/commands/passes-gate.js.map +1 -1
- package/dist/cli/commands/release.d.ts +1 -1
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +12 -18
- 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 +15 -4
- 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 +6 -0
- package/dist/cli/commands/security.js.map +1 -1
- package/dist/{core → cli/commands}/spec/validator.d.ts +9 -18
- package/dist/cli/commands/spec/validator.d.ts.map +1 -0
- package/dist/{core → cli/commands}/spec/validator.js +11 -42
- package/dist/cli/commands/spec/validator.js.map +1 -0
- package/dist/cli/commands/spec-baseline-check.d.ts +8 -41
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +31 -238
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/spec.d.ts +1 -1
- package/dist/cli/commands/spec.d.ts.map +1 -1
- package/dist/cli/commands/spec.js +14 -11
- package/dist/cli/commands/spec.js.map +1 -1
- package/dist/cli/commands/status.d.ts +0 -2
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +3 -9
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/compact.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/compact.js +15 -15
- package/dist/cli/commands/sync-docs/compact.js.map +1 -1
- package/dist/cli/commands/sync-docs/main-flow.d.ts +7 -23
- package/dist/cli/commands/sync-docs/main-flow.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/main-flow.js +27 -419
- package/dist/cli/commands/sync-docs/main-flow.js.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js +2 -1
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/commands/sync-docs/sync-output.d.ts +15 -0
- package/dist/cli/commands/sync-docs/sync-output.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/sync-output.js +217 -0
- package/dist/cli/commands/sync-docs/sync-output.js.map +1 -0
- package/dist/cli/commands/sync-docs/sync-state.d.ts +71 -0
- package/dist/cli/commands/sync-docs/sync-state.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/sync-state.js +274 -0
- package/dist/cli/commands/sync-docs/sync-state.js.map +1 -0
- package/dist/cli/commands/sync-docs/sync-writes.d.ts +12 -0
- package/dist/cli/commands/sync-docs/sync-writes.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/sync-writes.js +72 -0
- package/dist/cli/commands/sync-docs/sync-writes.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +0 -2
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +13 -6
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/session-manager.d.ts +0 -4
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +0 -36
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +2 -24
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/types.js +2 -1
- package/dist/context/types.js.map +1 -1
- package/dist/core/app-constraints-loader.d.ts +1 -1
- package/dist/core/app-constraints-loader.d.ts.map +1 -1
- package/dist/core/app-constraints-loader.js +6 -23
- package/dist/core/app-constraints-loader.js.map +1 -1
- package/dist/core/constraint-lifecycle.d.ts +3 -8
- package/dist/core/constraint-lifecycle.d.ts.map +1 -1
- package/dist/core/constraint-lifecycle.js +26 -30
- package/dist/core/constraint-lifecycle.js.map +1 -1
- package/dist/core/constraints/check-cache.d.ts +4 -43
- package/dist/core/constraints/check-cache.d.ts.map +1 -1
- package/dist/core/constraints/check-cache.js +6 -51
- package/dist/core/constraints/check-cache.js.map +1 -1
- package/dist/core/constraints/checker.d.ts +0 -16
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +23 -64
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.js +3 -3
- package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.js +2 -2
- package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.js +5 -5
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
- package/dist/core/constraints/checkers/index.d.ts +17 -3
- package/dist/core/constraints/checkers/index.d.ts.map +1 -1
- package/dist/core/constraints/checkers/index.js +22 -10
- package/dist/core/constraints/checkers/index.js.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js +5 -34
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.js +11 -33
- package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.js +3 -8
- package/dist/core/constraints/checkers/templated/exec.js.map +1 -1
- package/dist/core/constraints/checkers/templated/regex-scan.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/regex-scan.js +8 -26
- package/dist/core/constraints/checkers/templated/regex-scan.js.map +1 -1
- package/dist/core/constraints/checkers/types.d.ts +10 -33
- package/dist/core/constraints/checkers/types.d.ts.map +1 -1
- package/dist/core/constraints/checkers/types.js +6 -46
- package/dist/core/constraints/checkers/types.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts +8 -26
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +9 -81
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/definitions/{iron-laws.d.ts → errors.d.ts} +1 -2
- package/dist/core/constraints/definitions/errors.d.ts.map +1 -0
- package/dist/core/constraints/definitions/{iron-laws.js → errors.js} +1 -5
- package/dist/core/constraints/definitions/errors.js.map +1 -0
- package/dist/core/constraints/definitions/{guidelines.d.ts → warnings.d.ts} +1 -2
- package/dist/core/constraints/definitions/warnings.d.ts.map +1 -0
- package/dist/core/constraints/definitions/{guidelines.js → warnings.js} +1 -6
- package/dist/core/constraints/definitions/warnings.js.map +1 -0
- package/dist/core/constraints/definitions.d.ts +2 -1
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +6 -5
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts +0 -9
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +0 -1
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/find-constraint.d.ts +14 -0
- package/dist/core/constraints/find-constraint.d.ts.map +1 -0
- package/dist/core/constraints/find-constraint.js +25 -0
- package/dist/core/constraints/find-constraint.js.map +1 -0
- package/dist/core/constraints/governance-accessors.d.ts +54 -0
- package/dist/core/constraints/governance-accessors.d.ts.map +1 -0
- package/dist/core/constraints/governance-accessors.js +62 -0
- package/dist/core/constraints/governance-accessors.js.map +1 -0
- package/dist/core/constraints/index.d.ts +4 -4
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +1 -4
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/pack-proposal.d.ts.map +1 -1
- package/dist/core/constraints/pack-proposal.js +3 -14
- package/dist/core/constraints/pack-proposal.js.map +1 -1
- package/dist/core/constraints/run-env.d.ts +1 -13
- package/dist/core/constraints/run-env.d.ts.map +1 -1
- package/dist/core/constraints/run-env.js +2 -23
- package/dist/core/constraints/run-env.js.map +1 -1
- package/dist/core/constraints/triggers.d.ts +10 -6
- package/dist/core/constraints/triggers.d.ts.map +1 -1
- package/dist/core/constraints/triggers.js +11 -5
- package/dist/core/constraints/triggers.js.map +1 -1
- package/dist/core/constraints/usage-report.d.ts +0 -6
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +0 -9
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/index.d.ts +5 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +7 -8
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +5 -43
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +4 -49
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/spec/baseline-check.d.ts +54 -0
- package/dist/core/spec/baseline-check.d.ts.map +1 -0
- package/dist/core/spec/baseline-check.js +261 -0
- package/dist/core/spec/baseline-check.js.map +1 -0
- package/dist/core/validators/check-handlers/file.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/file.js +49 -5
- package/dist/core/validators/check-handlers/file.js.map +1 -1
- package/dist/core/validators/checkpoint.d.ts +5 -13
- package/dist/core/validators/checkpoint.d.ts.map +1 -1
- package/dist/core/validators/checkpoint.js +53 -80
- package/dist/core/validators/checkpoint.js.map +1 -1
- package/dist/core/validators/cso.d.ts +1 -4
- package/dist/core/validators/cso.d.ts.map +1 -1
- package/dist/core/validators/cso.js +1 -9
- package/dist/core/validators/cso.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +0 -4
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +0 -9
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/failure/classifier.d.ts +2 -21
- package/dist/failure/classifier.d.ts.map +1 -1
- package/dist/failure/classifier.js +7 -42
- package/dist/failure/classifier.js.map +1 -1
- package/dist/failure/error-types.d.ts +48 -0
- package/dist/failure/error-types.d.ts.map +1 -0
- package/dist/failure/error-types.js +122 -0
- package/dist/failure/error-types.js.map +1 -0
- package/dist/failure/index.d.ts +4 -3
- package/dist/failure/index.d.ts.map +1 -1
- package/dist/failure/index.js +8 -10
- package/dist/failure/index.js.map +1 -1
- package/dist/failure/recorder.d.ts +7 -27
- package/dist/failure/recorder.d.ts.map +1 -1
- package/dist/failure/recorder.js +11 -64
- package/dist/failure/recorder.js.map +1 -1
- package/dist/gates/acceptance.d.ts +7 -2
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +30 -36
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/command.d.ts +0 -16
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +0 -29
- package/dist/gates/command.js.map +1 -1
- package/dist/gates/contract.d.ts +0 -8
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +3 -17
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/definitions.d.ts +1 -1
- package/dist/gates/performance.d.ts +1 -15
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +0 -19
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/registry.d.ts.map +1 -1
- package/dist/gates/registry.js +2 -5
- package/dist/gates/registry.js.map +1 -1
- package/dist/gates/review.d.ts +1 -9
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +22 -19
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/security.d.ts +2 -9
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +7 -35
- package/dist/gates/security.js.map +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -16
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit-rules.d.ts +2 -0
- package/dist/knowledge/audit-rules.d.ts.map +1 -1
- package/dist/knowledge/audit-rules.js +10 -7
- package/dist/knowledge/audit-rules.js.map +1 -1
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/audit.js +3 -1
- package/dist/knowledge/audit.js.map +1 -1
- package/dist/knowledge/{import.d.ts → cold-start.d.ts} +2 -3
- package/dist/knowledge/cold-start.d.ts.map +1 -0
- package/dist/knowledge/{import.js → cold-start.js} +135 -182
- package/dist/knowledge/cold-start.js.map +1 -0
- package/dist/knowledge/index.d.ts +3 -5
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +3 -9
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/ingest.d.ts +29 -1
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +97 -7
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lifecycle.d.ts +0 -5
- package/dist/knowledge/lifecycle.d.ts.map +1 -1
- package/dist/knowledge/lifecycle.js +12 -19
- package/dist/knowledge/lifecycle.js.map +1 -1
- package/dist/knowledge/query.js +1 -1
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/store.d.ts +4 -7
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +9 -27
- package/dist/knowledge/store.js.map +1 -1
- package/dist/knowledge/types.d.ts +2 -36
- package/dist/knowledge/types.d.ts.map +1 -1
- package/dist/knowledge/types.js +2 -3
- package/dist/knowledge/types.js.map +1 -1
- package/dist/monitoring/analyzer-base.d.ts +1 -10
- package/dist/monitoring/analyzer-base.d.ts.map +1 -1
- package/dist/monitoring/analyzer-base.js +1 -58
- package/dist/monitoring/analyzer-base.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +1 -52
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +2 -131
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +1 -14
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +3 -25
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/types/command-definition.d.ts +81 -0
- package/dist/types/command-definition.d.ts.map +1 -0
- package/dist/types/command-definition.js +10 -0
- package/dist/types/command-definition.js.map +1 -0
- package/dist/types/constraint.d.ts +3 -24
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/failure.d.ts +6 -39
- package/dist/types/failure.d.ts.map +1 -1
- package/dist/types/failure.js +6 -112
- package/dist/types/failure.js.map +1 -1
- package/dist/types/spec.d.ts +0 -4
- package/dist/types/spec.d.ts.map +1 -1
- package/dist/types/trace.d.ts +0 -4
- package/dist/types/trace.d.ts.map +1 -1
- package/dist/utils/clip.d.ts +8 -0
- package/dist/utils/clip.d.ts.map +1 -0
- package/dist/utils/clip.js +15 -0
- package/dist/utils/clip.js.map +1 -0
- package/dist/utils/diff-parse.d.ts +31 -0
- package/dist/utils/diff-parse.d.ts.map +1 -0
- package/dist/utils/diff-parse.js +72 -0
- package/dist/utils/diff-parse.js.map +1 -0
- package/dist/utils/guards.d.ts +6 -0
- package/dist/utils/guards.d.ts.map +1 -0
- package/dist/utils/guards.js +11 -0
- package/dist/utils/guards.js.map +1 -0
- package/dist/utils/jsonl.d.ts +0 -12
- package/dist/utils/jsonl.d.ts.map +1 -1
- package/dist/utils/jsonl.js +0 -12
- package/dist/utils/jsonl.js.map +1 -1
- package/dist/utils/log-rotate.d.ts +14 -0
- package/dist/utils/log-rotate.d.ts.map +1 -0
- package/dist/utils/log-rotate.js +74 -0
- package/dist/utils/log-rotate.js.map +1 -0
- package/dist/utils/numeric-flag.d.ts +10 -2
- package/dist/utils/numeric-flag.d.ts.map +1 -1
- package/dist/utils/numeric-flag.js +17 -2
- package/dist/utils/numeric-flag.js.map +1 -1
- package/dist/utils/package-json.d.ts +1 -1
- package/dist/utils/package-json.js +1 -1
- package/package.json +1 -1
- package/src/CONTEXT.md +9 -9
- package/src/__tests__/app-constraints-loader.test.ts +5 -7
- package/src/__tests__/checker-extra.test.ts +12 -80
- package/src/__tests__/checker-primitives-sdk.test.ts +3 -18
- package/src/__tests__/checker.test.ts +5 -7
- package/src/__tests__/checkpoint.test.ts +45 -59
- package/src/__tests__/context-files-resolution.test.ts +3 -2
- package/src/__tests__/contract-gate.test.ts +0 -32
- package/src/__tests__/cso-validator.test.ts +1 -9
- package/src/__tests__/effective-constraints.test.ts +1 -3
- package/src/__tests__/error-classifier.test.ts +1 -42
- package/src/__tests__/failure-recorder.test.ts +45 -114
- package/src/__tests__/iron-laws.test.ts +9 -16
- package/src/__tests__/layering.test.ts +3 -3
- package/src/__tests__/project-config-loader.test.ts +2 -1
- package/src/__tests__/public-exports.test.ts +4 -15
- package/src/__tests__/public-type-surface.test.ts +1 -22
- package/src/__tests__/public-value-surface.test.ts +0 -3
- package/src/__tests__/review-gate.test.ts +0 -17
- package/src/__tests__/security-gate.test.ts +0 -18
- package/src/__tests__/skip-semantics.test.ts +4 -7
- package/src/__tests__/trace-analyzer-extra.test.ts +13 -129
- package/src/__tests__/trace-analyzer.test.ts +7 -7
- package/src/__tests__/trace-collector.test.ts +0 -43
- package/src/__tests__/traces.test.ts +7 -39
- package/src/agents/CONTEXT.md +2 -4
- package/src/agents/__tests__/lifecycle.test.ts +4 -155
- package/src/agents/index.ts +0 -3
- package/src/agents/lifecycle.ts +1 -114
- package/src/agents/types.ts +1 -21
- package/src/{hooks → bootstrap}/CONTEXT.md +5 -5
- package/src/{hooks → bootstrap}/bootstrap.ts +32 -39
- package/src/{hooks → bootstrap}/index.ts +3 -2
- package/src/cli/commands/CONTEXT.md +11 -11
- package/src/cli/commands/__tests__/check-read-count.test.ts +4 -7
- package/src/cli/commands/__tests__/check-skip-output.test.ts +0 -1
- package/src/cli/commands/__tests__/command-gate-dead-options.test.ts +7 -5
- package/src/cli/commands/__tests__/constraints-pack-proposal.test.ts +0 -1
- package/src/cli/commands/__tests__/constraints-report.test.ts +2 -2
- package/src/cli/commands/__tests__/contract.test.ts +11 -4
- package/src/cli/commands/__tests__/failure.test.ts +9 -9
- package/src/cli/commands/__tests__/knowledge-view.test.ts +28 -158
- package/src/cli/commands/__tests__/knowledge.test.ts +24 -4
- package/src/cli/commands/__tests__/numeric-flag-assembly.test.ts +2 -1
- package/src/cli/commands/__tests__/passes-gate.test.ts +5 -5
- package/src/cli/commands/__tests__/project-path-convention.test.ts +4 -21
- package/src/cli/commands/__tests__/registry.test.ts +2 -0
- package/src/cli/commands/__tests__/release.test.ts +1 -1
- package/src/cli/commands/__tests__/review.test.ts +20 -6
- package/src/cli/commands/__tests__/security.test.ts +14 -0
- package/src/cli/commands/__tests__/spec-baseline-read-count.test.ts +2 -2
- package/src/cli/commands/__tests__/spec.test.ts +33 -23
- package/src/cli/commands/__tests__/validate.test.ts +32 -15
- package/src/cli/commands/acceptance.ts +1 -1
- package/src/cli/commands/check.ts +12 -6
- package/src/cli/commands/command.ts +7 -6
- package/src/cli/commands/constraints-pack-proposal.ts +10 -8
- package/src/cli/commands/constraints-reactivate.ts +13 -9
- package/src/cli/commands/constraints-retire.ts +30 -10
- package/src/cli/commands/contract.ts +4 -6
- package/src/cli/commands/definitions.ts +12 -84
- package/src/cli/commands/failure.ts +7 -8
- package/src/cli/commands/knowledge/health.ts +25 -21
- package/src/cli/commands/knowledge/import.ts +1 -1
- package/src/cli/commands/knowledge/search.ts +2 -3
- package/src/cli/commands/knowledge/store-access.ts +40 -0
- package/src/cli/commands/knowledge-view.ts +8 -32
- package/src/cli/commands/passes-gate.ts +9 -8
- package/src/cli/commands/release.ts +12 -13
- package/src/cli/commands/review.ts +15 -4
- package/src/cli/commands/security.ts +7 -0
- package/src/{core → cli/commands}/spec/__tests__/validator.test.ts +15 -53
- package/src/{core → cli/commands}/spec/validator.ts +15 -54
- package/src/cli/commands/spec-baseline-check.ts +36 -313
- package/src/cli/commands/spec.ts +15 -11
- package/src/cli/commands/status.ts +0 -2
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +4 -10
- package/src/cli/commands/sync-docs/compact.ts +12 -11
- package/src/cli/commands/sync-docs/main-flow.ts +32 -472
- package/src/cli/commands/sync-docs/project-reader.ts +2 -1
- package/src/cli/commands/sync-docs/sync-output.ts +218 -0
- package/src/cli/commands/sync-docs/sync-state.ts +327 -0
- package/src/cli/commands/sync-docs/sync-writes.ts +49 -0
- package/src/cli/commands/validate.ts +13 -8
- package/src/context/CONTEXT.md +2 -2
- package/src/context/__tests__/session-manager.test.ts +1 -59
- package/src/context/index.ts +0 -5
- package/src/context/session-manager.ts +0 -44
- package/src/context/types.ts +2 -37
- package/src/core/CONTEXT.md +9 -9
- package/src/core/app-constraints-loader.ts +5 -23
- package/src/core/constraint-lifecycle.ts +30 -39
- package/src/core/constraints/__tests__/check-cache.test.ts +2 -124
- package/src/core/constraints/__tests__/collect-constraints.test.ts +0 -6
- package/src/core/constraints/__tests__/run-env.test.ts +26 -114
- package/src/core/constraints/__tests__/triggers.test.ts +3 -2
- package/src/core/constraints/__tests__/usage-report.test.ts +3 -6
- package/src/core/constraints/check-cache.ts +4 -70
- package/src/core/constraints/checker.ts +25 -75
- package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +1 -0
- package/src/core/constraints/checkers/__tests__/check-outcome.test.ts +0 -1
- package/src/core/constraints/checkers/__tests__/docs-freshness-degraded.test.ts +2 -0
- package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +1 -0
- package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +1 -0
- package/src/core/constraints/checkers/__tests__/input-contract.test.ts +1 -25
- package/src/core/constraints/checkers/__tests__/no-completion-without-verification.test.ts +3 -2
- package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +3 -0
- package/src/core/constraints/checkers/__tests__/no-test-simplification.test.ts +1 -0
- package/src/core/constraints/checkers/__tests__/templated-checkers.test.ts +1 -0
- package/src/core/constraints/checkers/__tests__/templates-registry.test.ts +0 -2
- package/src/core/constraints/checkers/__tests__/three-state-consistency.test.ts +1 -0
- package/src/core/constraints/checkers/capability-sync.ts +2 -2
- package/src/core/constraints/checkers/context-doc-sync.ts +1 -1
- package/src/core/constraints/checkers/docs-freshness.ts +1 -1
- package/src/core/constraints/checkers/index.ts +21 -8
- package/src/core/constraints/checkers/no-hardcoded-credentials.ts +5 -32
- package/src/core/constraints/checkers/no-test-simplification.ts +10 -32
- package/src/core/constraints/checkers/templated/exec.ts +1 -7
- package/src/core/constraints/checkers/templated/regex-scan.ts +6 -25
- package/src/core/constraints/checkers/types.ts +12 -65
- package/src/core/constraints/context-builder.ts +11 -85
- package/src/core/constraints/definitions/{iron-laws.ts → errors.ts} +0 -4
- package/src/core/constraints/definitions/{guidelines.ts → warnings.ts} +0 -5
- package/src/core/constraints/definitions.ts +4 -3
- package/src/core/constraints/doc-freshness/runner.ts +63 -70
- package/src/core/constraints/find-constraint.ts +24 -0
- package/src/core/constraints/governance-accessors.ts +74 -0
- package/src/core/constraints/index.ts +0 -5
- package/src/core/constraints/pack-proposal.ts +4 -15
- package/src/core/constraints/run-env.ts +1 -26
- package/src/core/constraints/triggers.ts +11 -6
- package/src/core/constraints/usage-report.ts +0 -9
- package/src/core/index.ts +5 -10
- package/src/core/project-config-loader.ts +5 -68
- package/src/core/spec/baseline-check.ts +300 -0
- package/src/core/validators/__tests__/http-retry-sleep.test.ts +1 -1
- package/src/core/validators/check-handlers/file.ts +48 -5
- package/src/core/validators/checkpoint.ts +52 -85
- package/src/core/validators/cso.ts +1 -12
- package/src/core/validators/passes-gate.ts +0 -10
- package/src/failure/CONTEXT.md +1 -1
- package/src/failure/__tests__/recorder.test.ts +2 -1
- package/src/failure/classifier.ts +2 -42
- package/src/failure/error-types.ts +122 -0
- package/src/failure/index.ts +9 -9
- package/src/failure/recorder.ts +12 -77
- package/src/gates/CONTEXT.md +2 -4
- package/src/gates/__tests__/command-single-predicate.test.ts +15 -60
- package/src/gates/__tests__/command.test.ts +0 -13
- package/src/gates/__tests__/gate-interface.test.ts +3 -5
- package/src/gates/__tests__/performance.test.ts +5 -51
- package/src/gates/__tests__/review.test.ts +27 -50
- package/src/gates/__tests__/security-default-scan.test.ts +6 -3
- package/src/gates/__tests__/security.test.ts +25 -44
- package/src/gates/acceptance.ts +31 -33
- package/src/gates/command.ts +0 -33
- package/src/gates/contract.ts +1 -18
- package/src/gates/definitions.ts +1 -1
- package/src/gates/performance.ts +0 -23
- package/src/gates/registry.ts +2 -4
- package/src/gates/review.ts +30 -21
- package/src/gates/security.ts +4 -44
- package/src/index.ts +3 -28
- package/src/knowledge/CONTEXT.md +14 -20
- package/src/knowledge/__tests__/audit.test.ts +1 -1
- package/src/knowledge/__tests__/import.test.ts +1 -1
- package/src/knowledge/__tests__/ingest-validate-entry.test.ts +235 -0
- package/src/knowledge/__tests__/ingest.test.ts +2 -3
- package/src/knowledge/__tests__/store.test.ts +2 -4
- package/src/knowledge/__tests__/tree-walker.test.ts +5 -13
- package/src/knowledge/audit-rules.ts +10 -6
- package/src/knowledge/audit.ts +3 -1
- package/src/knowledge/{import.ts → cold-start.ts} +148 -191
- package/src/knowledge/index.ts +2 -9
- package/src/knowledge/ingest.ts +110 -7
- package/src/knowledge/lifecycle.ts +11 -19
- package/src/knowledge/query.ts +1 -1
- package/src/knowledge/store.ts +12 -34
- package/src/knowledge/types.ts +2 -48
- package/src/monitoring/CONTEXT.md +3 -3
- package/src/monitoring/__tests__/skipped-lines-report.test.ts +3 -16
- package/src/monitoring/__tests__/traces.test.ts +1 -27
- package/src/monitoring/analyzer-base.ts +1 -28
- package/src/monitoring/trace-analyzer.ts +2 -161
- package/src/monitoring/traces.ts +3 -29
- package/src/types/command-definition.ts +85 -0
- package/src/types/constraint.ts +3 -32
- package/src/types/failure.ts +7 -113
- package/src/types/spec.ts +0 -4
- package/src/types/trace.ts +0 -6
- package/src/utils/__tests__/jsonl-skip-disposition.test.ts +4 -7
- package/src/utils/clip.ts +12 -0
- package/src/utils/diff-parse.ts +80 -0
- package/src/utils/guards.ts +8 -0
- package/src/utils/jsonl.ts +0 -30
- package/src/utils/log-rotate.ts +43 -0
- package/src/utils/numeric-flag.ts +24 -2
- package/src/utils/package-json.ts +1 -1
- package/dist/cli/commands/knowledge/migrate.d.ts +0 -21
- package/dist/cli/commands/knowledge/migrate.d.ts.map +0 -1
- package/dist/cli/commands/knowledge/migrate.js +0 -48
- package/dist/cli/commands/knowledge/migrate.js.map +0 -1
- package/dist/cli/commands/knowledge/sync-rag.d.ts +0 -19
- package/dist/cli/commands/knowledge/sync-rag.d.ts.map +0 -1
- package/dist/cli/commands/knowledge/sync-rag.js +0 -77
- package/dist/cli/commands/knowledge/sync-rag.js.map +0 -1
- package/dist/core/constraints/checkers/templates-registry.d.ts +0 -18
- package/dist/core/constraints/checkers/templates-registry.d.ts.map +0 -1
- package/dist/core/constraints/checkers/templates-registry.js +0 -25
- package/dist/core/constraints/checkers/templates-registry.js.map +0 -1
- package/dist/core/constraints/definitions/guidelines.d.ts.map +0 -1
- package/dist/core/constraints/definitions/guidelines.js.map +0 -1
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +0 -1
- package/dist/core/constraints/definitions/iron-laws.js.map +0 -1
- package/dist/core/spec/validator.d.ts.map +0 -1
- package/dist/core/spec/validator.js.map +0 -1
- package/dist/gates/checker-gate.d.ts +0 -27
- package/dist/gates/checker-gate.d.ts.map +0 -1
- package/dist/gates/checker-gate.js +0 -52
- package/dist/gates/checker-gate.js.map +0 -1
- package/dist/hooks/bootstrap.d.ts.map +0 -1
- package/dist/hooks/bootstrap.js.map +0 -1
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/knowledge/doctor.d.ts +0 -37
- package/dist/knowledge/doctor.d.ts.map +0 -1
- package/dist/knowledge/doctor.js +0 -81
- package/dist/knowledge/doctor.js.map +0 -1
- package/dist/knowledge/import.d.ts.map +0 -1
- package/dist/knowledge/import.js.map +0 -1
- package/dist/knowledge/lint.d.ts +0 -90
- package/dist/knowledge/lint.d.ts.map +0 -1
- package/dist/knowledge/lint.js +0 -412
- package/dist/knowledge/lint.js.map +0 -1
- package/dist/knowledge/migration.d.ts +0 -28
- package/dist/knowledge/migration.d.ts.map +0 -1
- package/dist/knowledge/migration.js +0 -105
- package/dist/knowledge/migration.js.map +0 -1
- package/dist/knowledge/reference-tracker.d.ts +0 -31
- package/dist/knowledge/reference-tracker.d.ts.map +0 -1
- package/dist/knowledge/reference-tracker.js +0 -122
- package/dist/knowledge/reference-tracker.js.map +0 -1
- package/src/__tests__/spec-validator.test.ts +0 -58
- package/src/cli/commands/knowledge/migrate.ts +0 -61
- package/src/cli/commands/knowledge/sync-rag.ts +0 -48
- package/src/core/constraints/checkers/templates-registry.ts +0 -24
- package/src/gates/__tests__/checker-gate.test.ts +0 -86
- package/src/gates/checker-gate.ts +0 -52
- package/src/knowledge/__tests__/doctor.test.ts +0 -300
- package/src/knowledge/__tests__/lint.test.ts +0 -536
- package/src/knowledge/__tests__/migration.test.ts +0 -185
- package/src/knowledge/__tests__/reference-tracker.test.ts +0 -169
- package/src/knowledge/doctor.ts +0 -103
- package/src/knowledge/lint.ts +0 -460
- package/src/knowledge/migration.ts +0 -82
- package/src/knowledge/reference-tracker.ts +0 -99
- /package/src/{hooks → bootstrap}/__tests__/bootstrap.test.ts +0 -0
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* SpecValidator 测试
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { SpecValidator
|
|
6
|
-
import type { GitCommandRunner } from '
|
|
5
|
+
import { SpecValidator } from '../validator';
|
|
6
|
+
import type { GitCommandRunner } from '../../../../core/constraints/git-evidence';
|
|
7
7
|
import * as fs from 'fs/promises';
|
|
8
8
|
|
|
9
9
|
// Mock fs
|
|
@@ -21,32 +21,16 @@ describe('SpecValidator', () => {
|
|
|
21
21
|
|
|
22
22
|
beforeEach(() => {
|
|
23
23
|
jest.clearAllMocks();
|
|
24
|
-
|
|
25
|
-
(SpecValidator as any).instance = undefined;
|
|
26
|
-
validator = SpecValidator.getInstance();
|
|
24
|
+
validator = new SpecValidator();
|
|
27
25
|
});
|
|
28
26
|
|
|
29
|
-
describe('
|
|
30
|
-
it('should return singleton instance', () => {
|
|
31
|
-
const v1 = SpecValidator.getInstance();
|
|
32
|
-
const v2 = SpecValidator.getInstance();
|
|
33
|
-
expect(v1).toBe(v2);
|
|
34
|
-
});
|
|
35
|
-
|
|
27
|
+
describe('constructor', () => {
|
|
36
28
|
it('should accept custom config', () => {
|
|
37
|
-
(
|
|
38
|
-
const v = SpecValidator.getInstance({ enabled: false });
|
|
29
|
+
const v = new SpecValidator({ schemaPath: './custom/schemas' });
|
|
39
30
|
expect(v).toBeDefined();
|
|
40
31
|
});
|
|
41
32
|
});
|
|
42
33
|
|
|
43
|
-
describe('setConfig()', () => {
|
|
44
|
-
it('should update config', () => {
|
|
45
|
-
validator.setConfig({ enabled: false });
|
|
46
|
-
expect(validator).toBeDefined();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
34
|
describe('detectSpecType()', () => {
|
|
51
35
|
it('should detect architecture type', () => {
|
|
52
36
|
const type = validator.detectSpecType('ARCHITECTURE.md');
|
|
@@ -258,12 +242,6 @@ describe('SpecValidator', () => {
|
|
|
258
242
|
expect(schema1).toBeNull();
|
|
259
243
|
expect(schema2).toBeNull();
|
|
260
244
|
});
|
|
261
|
-
|
|
262
|
-
it('should clear cache on setConfig', () => {
|
|
263
|
-
validator.setConfig({ schemaPath: './new/path' });
|
|
264
|
-
// Cache should be cleared
|
|
265
|
-
expect(validator).toBeDefined();
|
|
266
|
-
});
|
|
267
245
|
});
|
|
268
246
|
|
|
269
247
|
describe('detectSpecType() edge cases', () => {
|
|
@@ -421,35 +399,19 @@ describe('SpecValidator', () => {
|
|
|
421
399
|
});
|
|
422
400
|
});
|
|
423
401
|
|
|
424
|
-
describe('
|
|
425
|
-
it('
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
const result = await validateSpec('specs/test.yml');
|
|
434
|
-
expect(result).toBeDefined();
|
|
435
|
-
expect(result.file).toBe('specs/test.yml');
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
it('validateSpec should work with schemaPath', async () => {
|
|
402
|
+
describe('schemaPath 锚定(#95 同型病灶修复)', () => {
|
|
403
|
+
it('validateAll 的 schema 与 spec 文件同锚 projectPath(相对 schemaPath 按项目根解析)', async () => {
|
|
404
|
+
const seen: string[] = [];
|
|
405
|
+
const v = new SpecValidator({ schemaPath: './my-schemas' });
|
|
406
|
+
jest.spyOn(v, 'loadSchema').mockImplementation(async (p: string) => {
|
|
407
|
+
seen.push(p);
|
|
408
|
+
return null;
|
|
409
|
+
});
|
|
439
410
|
mockFs.access.mockRejectedValue(new Error('Not found'));
|
|
440
411
|
|
|
441
|
-
|
|
442
|
-
expect(result).toBeDefined();
|
|
443
|
-
});
|
|
412
|
+
await v.validateAll('/test/project');
|
|
444
413
|
|
|
445
|
-
|
|
446
|
-
mockFs.access.mockRejectedValue(new Error('Not found'));
|
|
447
|
-
|
|
448
|
-
const result = await validateAllSpecs('/test/project');
|
|
449
|
-
expect(result).toBeDefined();
|
|
450
|
-
expect(typeof result.total).toBe('number');
|
|
451
|
-
expect(typeof result.passed).toBe('number');
|
|
452
|
-
expect(typeof result.failed).toBe('number');
|
|
414
|
+
expect(seen).toEqual(['/test/project/my-schemas']);
|
|
453
415
|
});
|
|
454
416
|
});
|
|
455
417
|
});
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Spec
|
|
3
|
-
*
|
|
2
|
+
* Spec 验证器(ADR-0040 Phase 4 自 core/spec 迁入 cli spec 域:唯一消费方是
|
|
3
|
+
* `spec` CLI 命令,类壳是采集+IO 形态,非纯判定)
|
|
4
|
+
*
|
|
4
5
|
* 框架提供验证机制,项目定义自己的 Spec Schema
|
|
5
|
-
*
|
|
6
|
+
*
|
|
6
7
|
* 设计原则:
|
|
7
8
|
* - 框架不包含具体 Schema 定义
|
|
8
9
|
* - 动态加载项目的 Schema
|
|
9
10
|
* - 支持 Zod / JSON Schema / 自定义验证器
|
|
11
|
+
*
|
|
12
|
+
* schemaPath 锚定(#95 同型病灶修复):`validateAll(projectPath)` 的 schema 与
|
|
13
|
+
* spec 文件同锚 projectPath,不再按 process.cwd() 找;`validateFile` 无根形参,
|
|
14
|
+
* 相对 schemaPath 由调用方在构造时锚好(CLI 组合根恒传绝对路径)。
|
|
10
15
|
*/
|
|
11
16
|
|
|
12
17
|
import * as fs from 'fs/promises';
|
|
13
18
|
import * as path from 'path';
|
|
14
19
|
import * as glob from 'fast-glob';
|
|
15
|
-
import
|
|
20
|
+
import * as yaml from 'js-yaml';
|
|
21
|
+
import { createGitEvidence, splitFileNames, type GitCommandRunner } from '../../../core/constraints/git-evidence';
|
|
16
22
|
import type {
|
|
17
23
|
SpecValidatorConfig,
|
|
18
24
|
SpecValidationResult,
|
|
@@ -20,16 +26,14 @@ import type {
|
|
|
20
26
|
SpecSchemaDefinition,
|
|
21
27
|
SpecType,
|
|
22
28
|
SpecValidationError,
|
|
23
|
-
} from '
|
|
29
|
+
} from '../../../types/spec';
|
|
24
30
|
|
|
25
31
|
/**
|
|
26
32
|
* 默认配置
|
|
27
33
|
*/
|
|
28
34
|
const DEFAULT_CONFIG: SpecValidatorConfig = {
|
|
29
|
-
enabled: true,
|
|
30
35
|
schemaPath: './specs/schemas',
|
|
31
36
|
files: ['ARCHITECTURE.md', 'specs/**/*.yml', 'specs/**/*.yaml'],
|
|
32
|
-
failureLevel: 'error',
|
|
33
37
|
};
|
|
34
38
|
|
|
35
39
|
/**
|
|
@@ -46,35 +50,16 @@ function isSchemaModule(m: unknown): m is { name?: unknown; version?: unknown; v
|
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
/**
|
|
49
|
-
* Spec
|
|
53
|
+
* Spec 验证器(构造器直建——getInstance/setConfig 全局可变状态已随 ADR-0040 Phase 4 删除)
|
|
50
54
|
*/
|
|
51
55
|
export class SpecValidator {
|
|
52
|
-
private static instance: SpecValidator;
|
|
53
56
|
private config: SpecValidatorConfig;
|
|
54
57
|
private schemaCache: Map<string, SpecSchemaDefinition> = new Map();
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
constructor(config?: Partial<SpecValidatorConfig>) {
|
|
57
60
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
/**
|
|
61
|
-
* 获取单例实例
|
|
62
|
-
*/
|
|
63
|
-
static getInstance(config?: Partial<SpecValidatorConfig>): SpecValidator {
|
|
64
|
-
if (!SpecValidator.instance) {
|
|
65
|
-
SpecValidator.instance = new SpecValidator(config);
|
|
66
|
-
}
|
|
67
|
-
return SpecValidator.instance;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 更新配置
|
|
72
|
-
*/
|
|
73
|
-
setConfig(config: Partial<SpecValidatorConfig>): void {
|
|
74
|
-
this.config = { ...this.config, ...config };
|
|
75
|
-
this.schemaCache.clear();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
63
|
/**
|
|
79
64
|
* 加载项目的 Schema
|
|
80
65
|
*
|
|
@@ -217,7 +202,6 @@ export class SpecValidator {
|
|
|
217
202
|
// YAML 文件基础检查
|
|
218
203
|
if (filePath.endsWith('.yml') || filePath.endsWith('.yaml')) {
|
|
219
204
|
try {
|
|
220
|
-
const yaml = await import('js-yaml');
|
|
221
205
|
yaml.load(content);
|
|
222
206
|
} catch (e) {
|
|
223
207
|
errors.push({
|
|
@@ -247,8 +231,8 @@ export class SpecValidator {
|
|
|
247
231
|
const cwd = projectPath || process.cwd();
|
|
248
232
|
const results: SpecValidationResult[] = [];
|
|
249
233
|
|
|
250
|
-
// 加载项目的 Schema
|
|
251
|
-
const loadedSchema = await this.loadSchema(this.config.schemaPath);
|
|
234
|
+
// 加载项目的 Schema(与 spec 文件同锚 projectPath,不按进程 cwd 找)
|
|
235
|
+
const loadedSchema = await this.loadSchema(path.resolve(cwd, this.config.schemaPath));
|
|
252
236
|
const schema = loadedSchema ?? undefined;
|
|
253
237
|
|
|
254
238
|
// 获取要验证的文件
|
|
@@ -367,26 +351,3 @@ export class SpecValidator {
|
|
|
367
351
|
}
|
|
368
352
|
}
|
|
369
353
|
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* 便捷函数
|
|
373
|
-
*/
|
|
374
|
-
export async function validateSpec(
|
|
375
|
-
filePath: string,
|
|
376
|
-
schemaPath?: string
|
|
377
|
-
): Promise<SpecValidationResult> {
|
|
378
|
-
const validator = SpecValidator.getInstance();
|
|
379
|
-
if (schemaPath) {
|
|
380
|
-
const loadedSchema = await validator.loadSchema(schemaPath);
|
|
381
|
-
return validator.validateFile(filePath, loadedSchema ?? undefined);
|
|
382
|
-
}
|
|
383
|
-
return validator.validateFile(filePath);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
export async function validateAllSpecs(
|
|
387
|
-
projectPath?: string,
|
|
388
|
-
staged?: boolean
|
|
389
|
-
): Promise<BatchSpecValidationResult> {
|
|
390
|
-
const validator = SpecValidator.getInstance();
|
|
391
|
-
return validator.validateAll(projectPath, staged);
|
|
392
|
-
}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 验证 spec 文件的前置条件(Baseline / 前置条件)是否满足。
|
|
5
5
|
* 纯代码操作,零 LLM 调用。
|
|
6
|
+
*
|
|
7
|
+
* ADR-0020/0025 格局(ADR-0040 Phase 3):判定纯函数(extractBaselineSection /
|
|
8
|
+
* verifyPrerequisite / PrerequisiteResult / BaselineIndex 取数面接口)住
|
|
9
|
+
* `core/spec/baseline-check`;本模块只剩采集(BaselineIndex 实现 = 全仓扫描 /
|
|
10
|
+
* package.json 解析 / stat 探测)与输出(表格 / JSON / 退出码)。
|
|
6
11
|
*/
|
|
7
12
|
|
|
8
13
|
import chalk from 'chalk';
|
|
@@ -11,6 +16,16 @@ import * as path from 'path';
|
|
|
11
16
|
import { log, logError, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
12
17
|
import { walkFiles } from '../../utils/file-walk';
|
|
13
18
|
import { readPackageJson } from '../../utils/package-json';
|
|
19
|
+
import {
|
|
20
|
+
extractBaselineSection,
|
|
21
|
+
verifyPrerequisite,
|
|
22
|
+
type BaselineIndex,
|
|
23
|
+
type DependencySnapshot,
|
|
24
|
+
type PrerequisiteResult,
|
|
25
|
+
} from '../../core/spec/baseline-check';
|
|
26
|
+
|
|
27
|
+
export type { PrerequisiteResult } from '../../core/spec/baseline-check';
|
|
28
|
+
export { extractBaselineSection } from '../../core/spec/baseline-check';
|
|
14
29
|
|
|
15
30
|
export interface SpecBaselineCheckOptions {
|
|
16
31
|
/** 项目路径 */
|
|
@@ -19,76 +34,10 @@ export interface SpecBaselineCheckOptions {
|
|
|
19
34
|
json?: boolean;
|
|
20
35
|
}
|
|
21
36
|
|
|
22
|
-
/** 前置条件验证结果 */
|
|
23
|
-
export interface PrerequisiteResult {
|
|
24
|
-
/** 前置条件描述 */
|
|
25
|
-
prerequisite: string;
|
|
26
|
-
/** 是否满足 */
|
|
27
|
-
satisfied: boolean;
|
|
28
|
-
/** 证据 */
|
|
29
|
-
evidence: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
37
|
// ============================================
|
|
33
|
-
//
|
|
38
|
+
// 命令级共享索引(采集)
|
|
34
39
|
// ============================================
|
|
35
40
|
|
|
36
|
-
/**
|
|
37
|
-
* 从 spec 内容中提取 Baseline/前置条件 section
|
|
38
|
-
*/
|
|
39
|
-
export function extractBaselineSection(content: string): string[] {
|
|
40
|
-
const lines = content.split('\n');
|
|
41
|
-
const prerequisites: string[] = [];
|
|
42
|
-
|
|
43
|
-
// 查找 ## Baseline 或 ## 前置条件 section
|
|
44
|
-
let inSection = false;
|
|
45
|
-
let sectionLevel = 0;
|
|
46
|
-
|
|
47
|
-
for (const line of lines) {
|
|
48
|
-
const headerMatch = line.match(/^(#{1,6})\s+(.+)/);
|
|
49
|
-
|
|
50
|
-
if (headerMatch) {
|
|
51
|
-
const level = headerMatch[1].length;
|
|
52
|
-
const title = headerMatch[2].trim();
|
|
53
|
-
|
|
54
|
-
// 检查是否是目标 section
|
|
55
|
-
if (/^(Baseline|前置条件|Prerequisites|Prereqs)$/i.test(title)) {
|
|
56
|
-
inSection = true;
|
|
57
|
-
sectionLevel = level;
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 同级或更高级的标题结束 section
|
|
62
|
-
if (inSection && level <= sectionLevel) {
|
|
63
|
-
inSection = false;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// 在 section 中提取列表项
|
|
69
|
-
if (inSection) {
|
|
70
|
-
const listMatch = line.match(/^\s*[-*+]\s+(.+)/);
|
|
71
|
-
if (listMatch) {
|
|
72
|
-
prerequisites.push(listMatch[1].trim());
|
|
73
|
-
}
|
|
74
|
-
// 也支持编号列表
|
|
75
|
-
const numberedMatch = line.match(/^\s*\d+\.\s+(.+)/);
|
|
76
|
-
if (numberedMatch) {
|
|
77
|
-
prerequisites.push(numberedMatch[1].trim());
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return prerequisites;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// ============================================
|
|
86
|
-
// 命令级共享索引
|
|
87
|
-
// ============================================
|
|
88
|
-
|
|
89
|
-
/** package.json 依赖面的一次解析结果(失败态同样入库,不重试) */
|
|
90
|
-
type DependencySnapshot = { ok: true; deps: Record<string, string> } | { ok: false };
|
|
91
|
-
|
|
92
41
|
/**
|
|
93
42
|
* 共享索引的驻留上限(#162,统一复审遗留项 3):
|
|
94
43
|
* #146 把全仓源文件内容常驻一个 Map,排除面只有 node_modules/dist/隐藏目录与后缀,
|
|
@@ -105,27 +54,6 @@ export interface SourceIndexLimits {
|
|
|
105
54
|
maxBytes: number;
|
|
106
55
|
}
|
|
107
56
|
|
|
108
|
-
/**
|
|
109
|
-
* 一次 spec-baseline-check 运行内的取数面(工单 #146,母票 #140 A 票):
|
|
110
|
-
* 全仓内容扫描、`package.json` 解析、同一落点的存在性探测各至多一遍,
|
|
111
|
-
* 逐条前置只在索引上重放判定——此前是「前置条件数 × 关键词数 × 源文件数」的逐条重扫。
|
|
112
|
-
*
|
|
113
|
-
* 懒建:没有任何前置需要某类数据时,该类读取一次都不发生(口径与改前一致)。
|
|
114
|
-
* 运行结束即弃,不跨命令、不扩 `RunEnv` 公共面(#140 triage 裁决 5)。
|
|
115
|
-
*/
|
|
116
|
-
interface BaselineIndex {
|
|
117
|
-
/**
|
|
118
|
-
* 内容含 keyword 的源文件数。上限内走驻留索引重放(一次运行全仓至多读一遍);
|
|
119
|
-
* 超 SOURCE_INDEX_MAX_ENTRIES / SOURCE_INDEX_MAX_BYTES 即放弃驻留,
|
|
120
|
-
* 每个关键词回落逐文件流式读(#162:驻留条目数有上界,峰值 O(单文件))。
|
|
121
|
-
*/
|
|
122
|
-
countFilesContaining(keyword: string): number;
|
|
123
|
-
/** package.json 的 dependencies + devDependencies 合并面 */
|
|
124
|
-
dependencies(): DependencySnapshot;
|
|
125
|
-
/** 绝对路径是否在世(同一落点一次运行内只 stat 一次) */
|
|
126
|
-
exists(fullPath: string): boolean;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
57
|
export function createBaselineIndex(
|
|
130
58
|
projectPath: string,
|
|
131
59
|
limits: SourceIndexLimits = { maxEntries: SOURCE_INDEX_MAX_ENTRIES, maxBytes: SOURCE_INDEX_MAX_BYTES }
|
|
@@ -184,15 +112,11 @@ export function createBaselineIndex(
|
|
|
184
112
|
},
|
|
185
113
|
dependencies() {
|
|
186
114
|
if (!dependencySnapshot) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
} catch {
|
|
193
|
-
// #146:读取失败态(含损坏清单)同样入库,不逐条重试
|
|
194
|
-
dependencySnapshot = { ok: false };
|
|
195
|
-
}
|
|
115
|
+
// 缺失 = 合法空(ok:false);损坏 = readPackageJson 抛出(fail-fast,不入库不重试)
|
|
116
|
+
const pkgJson = readPackageJson(projectPath);
|
|
117
|
+
dependencySnapshot = pkgJson
|
|
118
|
+
? { ok: true, deps: { ...pkgJson.dependencies, ...pkgJson.devDependencies } }
|
|
119
|
+
: { ok: false };
|
|
196
120
|
}
|
|
197
121
|
return dependencySnapshot;
|
|
198
122
|
},
|
|
@@ -207,215 +131,6 @@ export function createBaselineIndex(
|
|
|
207
131
|
};
|
|
208
132
|
}
|
|
209
133
|
|
|
210
|
-
// ============================================
|
|
211
|
-
// 验证器
|
|
212
|
-
// ============================================
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* 检查文件/目录是否存在
|
|
216
|
-
*/
|
|
217
|
-
function checkFileExists(
|
|
218
|
-
pattern: string,
|
|
219
|
-
projectPath: string,
|
|
220
|
-
index: BaselineIndex
|
|
221
|
-
): { exists: boolean; evidence: string } {
|
|
222
|
-
// 提取路径引用(反引号中的路径、引号中的路径、或直接的路径模式)
|
|
223
|
-
const pathPatterns = [
|
|
224
|
-
/`([^`]+\.[a-z]+)`/g, // `src/foo.ts`
|
|
225
|
-
/["']([^"']+\.[a-z]+)["']/g, // "src/foo.ts"
|
|
226
|
-
/`([^`]+\/)`/g, // `src/foo/`
|
|
227
|
-
/(\S+\/\S+\.[a-z]+)/g, // src/foo.ts
|
|
228
|
-
];
|
|
229
|
-
|
|
230
|
-
const paths: string[] = [];
|
|
231
|
-
for (const p of pathPatterns) {
|
|
232
|
-
p.lastIndex = 0;
|
|
233
|
-
let m;
|
|
234
|
-
while ((m = p.exec(pattern)) !== null) {
|
|
235
|
-
paths.push(m[1]);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (paths.length === 0) {
|
|
240
|
-
return { exists: false, evidence: '无法从描述中提取路径' };
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const found: string[] = [];
|
|
244
|
-
const missing: string[] = [];
|
|
245
|
-
|
|
246
|
-
for (const p of paths) {
|
|
247
|
-
const fullPath = path.resolve(projectPath, p);
|
|
248
|
-
if (index.exists(fullPath)) {
|
|
249
|
-
found.push(p);
|
|
250
|
-
} else {
|
|
251
|
-
missing.push(p);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (missing.length === 0 && found.length > 0) {
|
|
256
|
-
return { exists: true, evidence: `文件存在: ${found.join(', ')}` };
|
|
257
|
-
}
|
|
258
|
-
if (found.length > 0) {
|
|
259
|
-
return { exists: false, evidence: `部分存在: ${found.join(', ')}; 缺失: ${missing.join(', ')}` };
|
|
260
|
-
}
|
|
261
|
-
return { exists: false, evidence: `文件不存在: ${missing.join(', ')}` };
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* 检查代码中是否存在特定模式
|
|
266
|
-
*/
|
|
267
|
-
function checkCodePattern(pattern: string, index: BaselineIndex): { exists: boolean; evidence: string } {
|
|
268
|
-
// 从描述中提取关键词
|
|
269
|
-
const keywords: string[] = [];
|
|
270
|
-
|
|
271
|
-
// 提取反引号中的代码
|
|
272
|
-
const codePatterns = pattern.match(/`([^`]+)`/g);
|
|
273
|
-
if (codePatterns) {
|
|
274
|
-
for (const cp of codePatterns) {
|
|
275
|
-
const inner = cp.slice(1, -1);
|
|
276
|
-
if (inner.length >= 2) {
|
|
277
|
-
keywords.push(inner);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// 提取 "implemented" / "exists" / "已实现" 等关键词后的内容
|
|
283
|
-
const implMatch = pattern.match(/(?:implemented|exists|已实现|已完成|已存在)[\s::]+(.+)/i);
|
|
284
|
-
if (implMatch) {
|
|
285
|
-
keywords.push(implMatch[1].trim());
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (keywords.length === 0) {
|
|
289
|
-
return { exists: false, evidence: '无法从描述中提取搜索关键词' };
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const found: string[] = [];
|
|
293
|
-
const notFound: string[] = [];
|
|
294
|
-
|
|
295
|
-
// 一次运行一份索引:全仓扫描与内容读取已在索引里发生一遍(超上限则回落流式),这里只做匹配
|
|
296
|
-
for (const kw of keywords) {
|
|
297
|
-
const count = index.countFilesContaining(kw);
|
|
298
|
-
if (count > 0) {
|
|
299
|
-
found.push(`${kw} (${count} files)`);
|
|
300
|
-
} else {
|
|
301
|
-
notFound.push(kw);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (notFound.length === 0 && found.length > 0) {
|
|
306
|
-
return { exists: true, evidence: `代码中找到: ${found.join(', ')}` };
|
|
307
|
-
}
|
|
308
|
-
if (found.length > 0) {
|
|
309
|
-
return { exists: false, evidence: `找到: ${found.join(', ')}; 未找到: ${notFound.join(', ')}` };
|
|
310
|
-
}
|
|
311
|
-
return { exists: false, evidence: `代码中未找到: ${notFound.join(', ')}` };
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* 检查包依赖是否安装
|
|
316
|
-
*/
|
|
317
|
-
function checkDependency(
|
|
318
|
-
pattern: string,
|
|
319
|
-
projectPath: string,
|
|
320
|
-
index: BaselineIndex
|
|
321
|
-
): { exists: boolean; evidence: string } {
|
|
322
|
-
// 提取包名
|
|
323
|
-
const pkgPatterns = [
|
|
324
|
-
/`(@?[\w-]+\/[\w-]+)`/g, // `@scope/pkg` or `pkg-name`
|
|
325
|
-
/`([\w-]+)`/g, // `pkg`
|
|
326
|
-
/install(?:ed)?\s+(\S+)/gi, // installed pkg-name
|
|
327
|
-
];
|
|
328
|
-
|
|
329
|
-
const packages: string[] = [];
|
|
330
|
-
for (const p of pkgPatterns) {
|
|
331
|
-
p.lastIndex = 0;
|
|
332
|
-
let m;
|
|
333
|
-
while ((m = p.exec(pattern)) !== null) {
|
|
334
|
-
const pkg = m[1];
|
|
335
|
-
if (pkg.length >= 2 && !pkg.includes('/') && !pkg.includes('.')) {
|
|
336
|
-
packages.push(pkg);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
if (packages.length === 0) {
|
|
342
|
-
return { exists: false, evidence: '无法从描述中提取包名' };
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const found: string[] = [];
|
|
346
|
-
const missing: string[] = [];
|
|
347
|
-
|
|
348
|
-
// 一次运行只读解析一遍 package.json(失败态同样入库)
|
|
349
|
-
const snapshot = index.dependencies();
|
|
350
|
-
if (!snapshot.ok) {
|
|
351
|
-
return { exists: false, evidence: '无法读取 package.json' };
|
|
352
|
-
}
|
|
353
|
-
const deps = snapshot.deps;
|
|
354
|
-
|
|
355
|
-
for (const pkg of packages) {
|
|
356
|
-
if (deps[pkg] || deps[`@types/${pkg}`]) {
|
|
357
|
-
found.push(pkg);
|
|
358
|
-
} else {
|
|
359
|
-
// 检查 node_modules
|
|
360
|
-
const nmPath = path.join(projectPath, 'node_modules', pkg);
|
|
361
|
-
if (index.exists(nmPath)) {
|
|
362
|
-
found.push(pkg);
|
|
363
|
-
} else {
|
|
364
|
-
missing.push(pkg);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (missing.length === 0 && found.length > 0) {
|
|
370
|
-
return { exists: true, evidence: `依赖已安装: ${found.join(', ')}` };
|
|
371
|
-
}
|
|
372
|
-
if (found.length > 0) {
|
|
373
|
-
return { exists: false, evidence: `已安装: ${found.join(', ')}; 缺失: ${missing.join(', ')}` };
|
|
374
|
-
}
|
|
375
|
-
return { exists: false, evidence: `依赖缺失: ${missing.join(', ')}` };
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* 综合验证一条前置条件(取数一律经命令级共享索引 `index`)
|
|
380
|
-
*/
|
|
381
|
-
function verifyPrerequisite(
|
|
382
|
-
prereq: string,
|
|
383
|
-
projectPath: string,
|
|
384
|
-
index: BaselineIndex
|
|
385
|
-
): PrerequisiteResult {
|
|
386
|
-
const lower = prereq.toLowerCase();
|
|
387
|
-
|
|
388
|
-
// 路径/文件存在性检查
|
|
389
|
-
if (lower.includes('文件') || lower.includes('file') || lower.includes('目录') || lower.includes('directory')
|
|
390
|
-
|| /`[^`]+\.[a-z]+`/.test(prereq) || /\//.test(prereq)) {
|
|
391
|
-
const { exists, evidence } = checkFileExists(prereq, projectPath, index);
|
|
392
|
-
if (exists || evidence.includes('文件不存在')) {
|
|
393
|
-
return { prerequisite: prereq, satisfied: exists, evidence };
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// 依赖检查
|
|
398
|
-
if (lower.includes('依赖') || lower.includes('install') || lower.includes('package') || lower.includes('npm')) {
|
|
399
|
-
const { exists, evidence } = checkDependency(prereq, projectPath, index);
|
|
400
|
-
return { prerequisite: prereq, satisfied: exists, evidence };
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// 代码模式检查
|
|
404
|
-
if (lower.includes('实现') || lower.includes('implement') || lower.includes('exist')
|
|
405
|
-
|| lower.includes('已') || lower.includes('必须')
|
|
406
|
-
|| /`[^`]+`/.test(prereq)) {
|
|
407
|
-
const { exists, evidence } = checkCodePattern(prereq, index);
|
|
408
|
-
return { prerequisite: prereq, satisfied: exists, evidence };
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// 默认:无法自动验证
|
|
412
|
-
return {
|
|
413
|
-
prerequisite: prereq,
|
|
414
|
-
satisfied: true,
|
|
415
|
-
evidence: '无法自动验证(需人工确认)',
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
|
|
419
134
|
// ============================================
|
|
420
135
|
// 输出格式化
|
|
421
136
|
// ============================================
|
|
@@ -427,17 +142,23 @@ function formatTable(results: PrerequisiteResult[]): string {
|
|
|
427
142
|
lines.push(chalk.blue(`前置条件检查 (${results.length} 条)\n`));
|
|
428
143
|
|
|
429
144
|
const satisfied = results.filter(r => r.satisfied).length;
|
|
430
|
-
const
|
|
145
|
+
const undetermined = results.filter(r => r.undetermined);
|
|
146
|
+
const failed = results.filter(r => !r.satisfied && !r.undetermined);
|
|
431
147
|
|
|
432
148
|
lines.push(chalk.bold(` 满足: ${satisfied}/${results.length}`));
|
|
433
149
|
if (failed.length > 0) {
|
|
434
|
-
lines.push(chalk.red(` 未满足: ${failed.length}
|
|
435
|
-
}
|
|
436
|
-
|
|
150
|
+
lines.push(chalk.red(` 未满足: ${failed.length}`));
|
|
151
|
+
}
|
|
152
|
+
if (undetermined.length > 0) {
|
|
153
|
+
lines.push(chalk.yellow(` 无法判定: ${undetermined.length}(按未满足处理)`));
|
|
154
|
+
}
|
|
155
|
+
if (failed.length === 0 && undetermined.length === 0) {
|
|
156
|
+
lines.push(chalk.green(' 全部满足'));
|
|
437
157
|
}
|
|
158
|
+
lines.push('');
|
|
438
159
|
|
|
439
160
|
for (const r of results) {
|
|
440
|
-
const icon = r.satisfied ? chalk.green('✓') : chalk.red('✗');
|
|
161
|
+
const icon = r.satisfied ? chalk.green('✓') : r.undetermined ? chalk.yellow('?') : chalk.red('✗');
|
|
441
162
|
lines.push(` ${icon} ${r.prerequisite}`);
|
|
442
163
|
if (!r.satisfied) {
|
|
443
164
|
lines.push(` ${chalk.yellow(r.evidence)}`);
|
|
@@ -494,12 +215,14 @@ export async function specBaselineCheck(
|
|
|
494
215
|
log(io, formatTable(results));
|
|
495
216
|
}
|
|
496
217
|
|
|
497
|
-
//
|
|
218
|
+
// 有未满足或无法判定的前置条件时非零退出(无法判定不假绿放过)
|
|
498
219
|
const failed = results.filter(r => !r.satisfied);
|
|
499
220
|
if (failed.length > 0) {
|
|
221
|
+
const undeterminedCount = results.filter(r => r.undetermined).length;
|
|
222
|
+
const suffix = undeterminedCount > 0 ? `(含 ${undeterminedCount} 条无法判定)` : '';
|
|
500
223
|
return {
|
|
501
224
|
kind: 'fail',
|
|
502
|
-
reason: `${failed.length}
|
|
225
|
+
reason: `${failed.length} 条前置条件未满足${suffix}: ${failed.map(f => f.prerequisite).join('; ')}`,
|
|
503
226
|
};
|
|
504
227
|
}
|
|
505
228
|
return { kind: 'ok' };
|