@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
|
@@ -24,27 +24,41 @@ describe('ReviewGate', () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
describe('constructor', () => {
|
|
27
|
-
it('should use default config', () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
it('should use default config', async () => {
|
|
28
|
+
// 缺省 minReviewers=1:单个 APPROVED 即通过
|
|
29
|
+
mockExec.mockImplementationOnce((cmd, opts, callback) => {
|
|
30
|
+
callback(null, {
|
|
31
|
+
stdout: JSON.stringify({
|
|
32
|
+
reviews: [{ state: 'APPROVED', author: { login: 'alice' } }],
|
|
33
|
+
state: 'open',
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const result = await gate.check({ ...baseContext, prNumber: 123 });
|
|
39
|
+
expect(result.passed).toBe(true);
|
|
34
40
|
});
|
|
35
41
|
|
|
36
|
-
it('should accept custom config', () => {
|
|
42
|
+
it('should accept custom config', async () => {
|
|
37
43
|
const customGate = new ReviewGate({
|
|
38
44
|
minReviewers: 2,
|
|
39
45
|
requireApproval: false,
|
|
40
46
|
blockOnChangesRequested: false,
|
|
41
47
|
allowedReviewers: ['alice', 'bob'],
|
|
42
48
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
|
|
50
|
+
// minReviewers=2:单个 APPROVED 不够
|
|
51
|
+
mockExec.mockImplementationOnce((cmd, opts, callback) => {
|
|
52
|
+
callback(null, {
|
|
53
|
+
stdout: JSON.stringify({
|
|
54
|
+
reviews: [{ state: 'APPROVED', author: { login: 'alice' } }],
|
|
55
|
+
state: 'open',
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const result = await customGate.check({ ...baseContext, prNumber: 123 });
|
|
61
|
+
expect(result.passed).toBe(false);
|
|
48
62
|
});
|
|
49
63
|
});
|
|
50
64
|
|
|
@@ -231,43 +245,6 @@ describe('ReviewGate', () => {
|
|
|
231
245
|
});
|
|
232
246
|
});
|
|
233
247
|
|
|
234
|
-
describe('setMinReviewers()', () => {
|
|
235
|
-
it('should update minReviewers', () => {
|
|
236
|
-
gate.setMinReviewers(3);
|
|
237
|
-
const config = gate.getConfig();
|
|
238
|
-
expect(config.minReviewers).toBe(3);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it('should affect check result', async () => {
|
|
242
|
-
gate.setMinReviewers(2);
|
|
243
|
-
|
|
244
|
-
mockExec.mockImplementationOnce((cmd, opts, callback) => {
|
|
245
|
-
callback(null, {
|
|
246
|
-
stdout: JSON.stringify({
|
|
247
|
-
reviews: [{ state: 'APPROVED', author: { login: 'alice' } }],
|
|
248
|
-
state: 'open',
|
|
249
|
-
}),
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
const result = await gate.check({
|
|
254
|
-
...baseContext,
|
|
255
|
-
prNumber: 123,
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
expect(result.passed).toBe(false);
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
describe('getConfig()', () => {
|
|
263
|
-
it('should return copy of config', () => {
|
|
264
|
-
const config1 = gate.getConfig();
|
|
265
|
-
const config2 = gate.getConfig();
|
|
266
|
-
expect(config1).toEqual(config2);
|
|
267
|
-
expect(config1).not.toBe(config2);
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
|
|
271
248
|
describe('timing', () => {
|
|
272
249
|
it('should include duration in result', async () => {
|
|
273
250
|
mockExec
|
|
@@ -89,9 +89,12 @@ describe('SecurityGate 缺省扫描命令(#138 断链)', () => {
|
|
|
89
89
|
expect(result.details?.scanCommand).toBe(DETECTED);
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
it('构造器不再出现 scanCommand 的空串缺省', () => {
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
it('构造器不再出现 scanCommand 的空串缺省', async () => {
|
|
93
|
+
// 空串归一为「未提供」:与无配置门禁走同一探测路径(行为钉,替代原 getConfig 形状钉)
|
|
94
|
+
const result = await new SecurityGate().scan({ projectPath });
|
|
95
|
+
|
|
96
|
+
expect(issued()).toEqual([DETECTED]);
|
|
97
|
+
expect(result.details?.scanCommand).toBe(DETECTED);
|
|
95
98
|
});
|
|
96
99
|
});
|
|
97
100
|
});
|
|
@@ -24,22 +24,35 @@ describe('SecurityGate', () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
describe('constructor', () => {
|
|
27
|
-
it('should use default config', () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
it('should use default config', async () => {
|
|
28
|
+
// 缺省 severityThreshold='high':moderate 漏洞默认放行
|
|
29
|
+
mockExec.mockImplementationOnce((cmd, opts, callback) => {
|
|
30
|
+
callback(
|
|
31
|
+
{ stdout: JSON.stringify({ vulnerabilities: { pkg: { severity: 'moderate' } } }) },
|
|
32
|
+
null
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const result = await gate.scan(baseContext);
|
|
37
|
+
expect(result.passed).toBe(true);
|
|
33
38
|
});
|
|
34
39
|
|
|
35
|
-
it('should accept custom config', () => {
|
|
40
|
+
it('should accept custom config', async () => {
|
|
36
41
|
const customGate = new SecurityGate({
|
|
37
42
|
severityThreshold: 'critical',
|
|
38
43
|
ignoreWarnings: true,
|
|
39
44
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
|
|
46
|
+
// critical 阈值下 high 漏洞放行
|
|
47
|
+
mockExec.mockImplementationOnce((cmd, opts, callback) => {
|
|
48
|
+
callback(
|
|
49
|
+
{ stdout: JSON.stringify({ vulnerabilities: { pkg: { severity: 'high' } } }) },
|
|
50
|
+
null
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const result = await customGate.scan(baseContext);
|
|
55
|
+
expect(result.passed).toBe(true);
|
|
43
56
|
});
|
|
44
57
|
});
|
|
45
58
|
|
|
@@ -161,7 +174,7 @@ describe('SecurityGate', () => {
|
|
|
161
174
|
});
|
|
162
175
|
});
|
|
163
176
|
|
|
164
|
-
describe('analyzeResult() - npm audit format', () => { it('
|
|
177
|
+
describe('analyzeResult() - npm audit format', () => { it('npm 6 audit.advisories 旧形状已随其 EOL 删除 → 不计数', async () => {
|
|
165
178
|
mockExec.mockImplementationOnce((cmd, opts, callback) => {
|
|
166
179
|
callback(null, {
|
|
167
180
|
stdout: JSON.stringify({
|
|
@@ -180,7 +193,7 @@ describe('SecurityGate', () => {
|
|
|
180
193
|
|
|
181
194
|
const result = await gate.scan(baseContext);
|
|
182
195
|
|
|
183
|
-
expect(result.details?.
|
|
196
|
+
expect(result.details?.total).toBe(0);
|
|
184
197
|
});
|
|
185
198
|
|
|
186
199
|
it('should parse vulnerabilities format (new npm audit)', async () => {
|
|
@@ -248,38 +261,6 @@ describe('SecurityGate', () => {
|
|
|
248
261
|
});
|
|
249
262
|
});
|
|
250
263
|
|
|
251
|
-
describe('setSeverityThreshold()', () => {
|
|
252
|
-
it('should update threshold', () => {
|
|
253
|
-
gate.setSeverityThreshold('moderate');
|
|
254
|
-
const config = gate.getConfig();
|
|
255
|
-
expect(config.severityThreshold).toBe('moderate');
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('should affect scan result', async () => {
|
|
259
|
-
gate.setSeverityThreshold('moderate');
|
|
260
|
-
|
|
261
|
-
mockExec.mockImplementationOnce((cmd, opts, callback) => {
|
|
262
|
-
callback(
|
|
263
|
-
{ stdout: JSON.stringify({ vulnerabilities: { pkg: { severity: 'moderate' } } }) },
|
|
264
|
-
null
|
|
265
|
-
);
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
const result = await gate.scan(baseContext);
|
|
269
|
-
|
|
270
|
-
expect(result.passed).toBe(false);
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
describe('getConfig()', () => {
|
|
275
|
-
it('should return copy of config', () => {
|
|
276
|
-
const config1 = gate.getConfig();
|
|
277
|
-
const config2 = gate.getConfig();
|
|
278
|
-
expect(config1).toEqual(config2);
|
|
279
|
-
expect(config1).not.toBe(config2); // Different objects
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
|
|
283
264
|
describe('timing', () => {
|
|
284
265
|
it('should include duration in result', async () => {
|
|
285
266
|
mockExec.mockImplementationOnce((cmd, opts, callback) => {
|
package/src/gates/acceptance.ts
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import { execAsync } from '../utils/exec';
|
|
27
|
+
import { isRecord } from '../utils/guards';
|
|
27
28
|
import { judgeTestRun } from '../core/validators/test-output';
|
|
28
29
|
import * as fs from 'fs/promises';
|
|
29
30
|
import * as path from 'path';
|
|
@@ -35,6 +36,7 @@ import type {
|
|
|
35
36
|
SpecAcceptanceGateConfig,
|
|
36
37
|
AcceptanceGateContext,
|
|
37
38
|
} from './types';
|
|
39
|
+
import { gateResult } from './types';
|
|
38
40
|
import { decisionFromResult } from './decision';
|
|
39
41
|
|
|
40
42
|
|
|
@@ -77,13 +79,15 @@ export interface TasksFile {
|
|
|
77
79
|
/**
|
|
78
80
|
* 验收门禁结果 details 负载(type alias 而非 interface:
|
|
79
81
|
* 需要隐式索引签名以直接赋给 GateResult.details 的 Record 形状)
|
|
82
|
+
*
|
|
83
|
+
* totalCriteria/checkedCriteria/uncheckedCriteria 一律按**验收条件**计数
|
|
84
|
+
* (聚合路径逐任务累加,不填任务数)。
|
|
80
85
|
*/
|
|
81
86
|
export type AcceptanceGateDetails = {
|
|
82
87
|
taskId?: string;
|
|
83
88
|
totalCriteria: number;
|
|
84
89
|
checkedCriteria: number;
|
|
85
90
|
uncheckedCriteria: string[];
|
|
86
|
-
missingCriteria: string[];
|
|
87
91
|
e2eTestResults?: E2ETestResult[];
|
|
88
92
|
};
|
|
89
93
|
|
|
@@ -111,11 +115,6 @@ export interface E2ETestResult {
|
|
|
111
115
|
|
|
112
116
|
// ==================== tasks.yml 解析与校验 ====================
|
|
113
117
|
|
|
114
|
-
/** 是 plain object(非 null 非数组) */
|
|
115
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
116
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
118
|
/**
|
|
120
119
|
* yaml.load 结果 → TasksFile:形状非法即抛错(fail-fast,不静默兜底)。
|
|
121
120
|
* 校验只到判定实际读取的字段:tasks 数组、任务 id、acceptance 条目的
|
|
@@ -201,21 +200,19 @@ export class SpecAcceptanceGate implements Gate {
|
|
|
201
200
|
|
|
202
201
|
/**
|
|
203
202
|
* 统一门禁接口(G1):执行细节私有,决策三态由 check() 报告推导。
|
|
204
|
-
* AcceptanceGateResult 无 gate
|
|
203
|
+
* AcceptanceGateResult 无 gate 字段,此处经 gateResult 构造器归一化为 GateResult
|
|
204
|
+
* 报告结构(本层约定不手拼 GateResult 字面量)。
|
|
205
205
|
*/
|
|
206
206
|
async evaluate(context: GateContext): Promise<GateDecision> {
|
|
207
|
+
const startedAt = Date.now();
|
|
207
208
|
const result = await this.check({
|
|
208
209
|
projectPath: context.projectPath,
|
|
209
210
|
taskId: context.taskId,
|
|
210
211
|
tasksPath: context.tasksPath,
|
|
211
212
|
});
|
|
212
|
-
return decisionFromResult(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
message: result.message,
|
|
216
|
-
timestamp: result.timestamp,
|
|
217
|
-
...(result.details ? { details: result.details } : {}),
|
|
218
|
-
});
|
|
213
|
+
return decisionFromResult(
|
|
214
|
+
gateResult('acceptance', result.passed, result.message, startedAt, result.details)
|
|
215
|
+
);
|
|
219
216
|
}
|
|
220
217
|
|
|
221
218
|
/**
|
|
@@ -288,6 +285,23 @@ export class SpecAcceptanceGate implements Gate {
|
|
|
288
285
|
return this.validateTask(task, projectPath);
|
|
289
286
|
}
|
|
290
287
|
|
|
288
|
+
/** 聚合 details:按验收条件计数(逐任务累加),未满足项带任务 id 前缀 */
|
|
289
|
+
private aggregateDetails(results: AcceptanceGateResult[]): AcceptanceGateDetails {
|
|
290
|
+
let totalCriteria = 0;
|
|
291
|
+
const unchecked: string[] = [];
|
|
292
|
+
for (const r of results) {
|
|
293
|
+
totalCriteria += r.details?.totalCriteria ?? 0;
|
|
294
|
+
for (const c of r.details?.uncheckedCriteria ?? []) {
|
|
295
|
+
unchecked.push(`${r.details?.taskId}: ${c}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
totalCriteria,
|
|
300
|
+
checkedCriteria: totalCriteria - unchecked.length,
|
|
301
|
+
uncheckedCriteria: unchecked,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
291
305
|
/**
|
|
292
306
|
* 检查所有任务
|
|
293
307
|
*/
|
|
@@ -308,12 +322,7 @@ export class SpecAcceptanceGate implements Gate {
|
|
|
308
322
|
passed: true,
|
|
309
323
|
message: 'All tasks pass acceptance criteria',
|
|
310
324
|
timestamp: new Date().toISOString(),
|
|
311
|
-
details:
|
|
312
|
-
totalCriteria: results.length,
|
|
313
|
-
checkedCriteria: results.length,
|
|
314
|
-
uncheckedCriteria: [],
|
|
315
|
-
missingCriteria: [],
|
|
316
|
-
},
|
|
325
|
+
details: this.aggregateDetails(results),
|
|
317
326
|
};
|
|
318
327
|
}
|
|
319
328
|
|
|
@@ -321,12 +330,7 @@ export class SpecAcceptanceGate implements Gate {
|
|
|
321
330
|
passed: false,
|
|
322
331
|
message: `${failedTasks.length} task(s) fail acceptance criteria`,
|
|
323
332
|
timestamp: new Date().toISOString(),
|
|
324
|
-
details:
|
|
325
|
-
totalCriteria: results.length,
|
|
326
|
-
checkedCriteria: results.length - failedTasks.length,
|
|
327
|
-
uncheckedCriteria: failedTasks.map(r => r.message),
|
|
328
|
-
missingCriteria: [],
|
|
329
|
-
},
|
|
333
|
+
details: this.aggregateDetails(results),
|
|
330
334
|
};
|
|
331
335
|
}
|
|
332
336
|
|
|
@@ -366,12 +370,7 @@ export class SpecAcceptanceGate implements Gate {
|
|
|
366
370
|
passed: false,
|
|
367
371
|
message: `${failedTasks.length} completed task(s) fail acceptance criteria`,
|
|
368
372
|
timestamp: new Date().toISOString(),
|
|
369
|
-
details:
|
|
370
|
-
totalCriteria: results.length,
|
|
371
|
-
checkedCriteria: results.length - failedTasks.length,
|
|
372
|
-
uncheckedCriteria: failedTasks.map(r => r.message),
|
|
373
|
-
missingCriteria: [],
|
|
374
|
-
},
|
|
373
|
+
details: this.aggregateDetails(results),
|
|
375
374
|
};
|
|
376
375
|
}
|
|
377
376
|
|
|
@@ -420,7 +419,6 @@ export class SpecAcceptanceGate implements Gate {
|
|
|
420
419
|
totalCriteria: conditions.length,
|
|
421
420
|
checkedCriteria: conditions.length - unchecked.length,
|
|
422
421
|
uncheckedCriteria: unchecked,
|
|
423
|
-
missingCriteria: [],
|
|
424
422
|
...(e2eResults.length > 0 ? { e2eTestResults: e2eResults } : {}),
|
|
425
423
|
};
|
|
426
424
|
|
package/src/gates/command.ts
CHANGED
|
@@ -402,39 +402,6 @@ export class CommandGate implements Gate {
|
|
|
402
402
|
getRiskLevel(command: string): 'high' | 'medium' | 'low' {
|
|
403
403
|
return this.judge(command).riskLevel;
|
|
404
404
|
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* 获取黑名单规则
|
|
408
|
-
*/
|
|
409
|
-
getBlacklist(): CommandBlacklistRule[] {
|
|
410
|
-
return [...this.blacklist];
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* 添加自定义规则
|
|
415
|
-
*/
|
|
416
|
-
addRule(rule: CommandBlacklistRule): void {
|
|
417
|
-
this.blacklist.push(rule);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* 移除规则
|
|
422
|
-
*/
|
|
423
|
-
removeRule(id: string): boolean {
|
|
424
|
-
const index = this.blacklist.findIndex(r => r.id === id);
|
|
425
|
-
if (index >= 0) {
|
|
426
|
-
this.blacklist.splice(index, 1);
|
|
427
|
-
return true;
|
|
428
|
-
}
|
|
429
|
-
return false;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* 获取配置
|
|
434
|
-
*/
|
|
435
|
-
getConfig(): Required<CommandGateConfig> {
|
|
436
|
-
return { ...this.config };
|
|
437
|
-
}
|
|
438
405
|
}
|
|
439
406
|
|
|
440
407
|
// ========== 便捷函数 ==========
|
package/src/gates/contract.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import * as fs from 'fs/promises';
|
|
14
14
|
import * as path from 'path';
|
|
15
15
|
import { pass, fail, fromError } from './types';
|
|
16
|
+
import { isRecord } from '../utils/guards';
|
|
16
17
|
import type { GateResult, GateContext, ContractGateConfig, Gate, GateDecision } from './types';
|
|
17
18
|
import { decisionFromResult } from './decision';
|
|
18
19
|
|
|
@@ -31,10 +32,6 @@ export interface BreakingChange {
|
|
|
31
32
|
path: string;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
35
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
35
|
/**
|
|
39
36
|
* 契约门禁
|
|
40
37
|
*/
|
|
@@ -215,18 +212,4 @@ export class ContractGate implements Gate {
|
|
|
215
212
|
|
|
216
213
|
return endpoints;
|
|
217
214
|
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* 设置契约路径
|
|
221
|
-
*/
|
|
222
|
-
setContractPath(path: string): void {
|
|
223
|
-
this.config.contractPath = path;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* 获取配置
|
|
228
|
-
*/
|
|
229
|
-
getConfig(): Required<ContractGateConfig> {
|
|
230
|
-
return { ...this.config };
|
|
231
|
-
}
|
|
232
215
|
}
|
package/src/gates/definitions.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* 纯函数解析器(harness#154 口径条目指名的数值旗帜唯一解析器)。
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type { CommandDefinition } from '../
|
|
18
|
+
import type { CommandDefinition } from '../types/command-definition';
|
|
19
19
|
import { requireNumericFlag } from '../utils/numeric-flag';
|
|
20
20
|
|
|
21
21
|
/**
|
package/src/gates/performance.ts
CHANGED
|
@@ -240,27 +240,4 @@ export class PerformanceGate implements Gate {
|
|
|
240
240
|
if (metrics.bundleSize !== undefined) parts.push(`打包=${metrics.bundleSize}KB`);
|
|
241
241
|
return parts.join(', ') || '无指标';
|
|
242
242
|
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* 设置阈值
|
|
246
|
-
*/
|
|
247
|
-
setThresholds(thresholds: Partial<PerformanceThresholds>): void {
|
|
248
|
-
this.config.thresholds = { ...this.config.thresholds, ...thresholds };
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* 设置超时时间
|
|
253
|
-
*/
|
|
254
|
-
setTimeouts(options: {
|
|
255
|
-
coverage?: number;
|
|
256
|
-
}): void {
|
|
257
|
-
if (options.coverage) this.config.coverageTimeout = options.coverage;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* 获取配置
|
|
262
|
-
*/
|
|
263
|
-
getConfig(): Required<ExtendedPerformanceGateConfig> {
|
|
264
|
-
return { ...this.config };
|
|
265
|
-
}
|
|
266
243
|
}
|
package/src/gates/registry.ts
CHANGED
|
@@ -38,10 +38,8 @@ const registry = new Map<string, Gate>(IMPLEMENTATIONS.map(g => [g.id, g]));
|
|
|
38
38
|
|
|
39
39
|
// 默认 order 以定义表为准(生效集层已删:config.yml 不再有 gates.order 覆盖口,ADR-0002「后续变更」)
|
|
40
40
|
for (const def of GATE_DEFINITIONS) {
|
|
41
|
-
// assertGateRegistryClosed
|
|
42
|
-
|
|
43
|
-
if (!impl) throw new Error(`gate registry: 定义 ${def.id} 无实现(闭环校验后仍缺,不可能路径)`);
|
|
44
|
-
impl.order = def.order;
|
|
41
|
+
// assertGateRegistryClosed 已保证定义必有实现;经闭环访问口取(未注册即抛,见 getGate)
|
|
42
|
+
getGate(def.id).order = def.order;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
/**
|
package/src/gates/review.ts
CHANGED
|
@@ -40,6 +40,21 @@ function parsePrView(stdout: string): GhPrView {
|
|
|
40
40
|
return raw as GhPrView;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* 内层失败上抛时自带报告标签与 details:check() 的 fromError 单点包装原样带出,
|
|
45
|
+
* 内层 catch 只附上下文(标签/建议),不再各自拼报告(原三层 try/catch 合一)
|
|
46
|
+
*/
|
|
47
|
+
class ReviewCheckError extends Error {
|
|
48
|
+
constructor(
|
|
49
|
+
readonly label: string,
|
|
50
|
+
reason: string,
|
|
51
|
+
readonly details?: Record<string, unknown>
|
|
52
|
+
) {
|
|
53
|
+
super(reason);
|
|
54
|
+
this.name = 'ReviewCheckError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
43
58
|
/**
|
|
44
59
|
* 审查门禁
|
|
45
60
|
*/
|
|
@@ -65,7 +80,7 @@ export class ReviewGate implements Gate {
|
|
|
65
80
|
}
|
|
66
81
|
|
|
67
82
|
/**
|
|
68
|
-
*
|
|
83
|
+
* 检查审查状态(异常报告的单点包装:内层抛,这里统一 fromError)
|
|
69
84
|
*/
|
|
70
85
|
async check(context: GateContext): Promise<GateResult> {
|
|
71
86
|
const startTime = Date.now();
|
|
@@ -73,12 +88,15 @@ export class ReviewGate implements Gate {
|
|
|
73
88
|
try {
|
|
74
89
|
// 如果有 PR 号,使用 GitHub API
|
|
75
90
|
if (context.prNumber) {
|
|
76
|
-
return this.checkGitHubPR(context);
|
|
91
|
+
return await this.checkGitHubPR(context);
|
|
77
92
|
}
|
|
78
93
|
|
|
79
94
|
// 否则尝试从 git 获取
|
|
80
|
-
return this.checkLocalGit(context);
|
|
95
|
+
return await this.checkLocalGit(context);
|
|
81
96
|
} catch (error: unknown) {
|
|
97
|
+
if (error instanceof ReviewCheckError) {
|
|
98
|
+
return fromError('review', error.label, error, startTime, error.details);
|
|
99
|
+
}
|
|
82
100
|
return fromError('review', '审查检查失败', error, startTime);
|
|
83
101
|
}
|
|
84
102
|
}
|
|
@@ -125,9 +143,11 @@ export class ReviewGate implements Gate {
|
|
|
125
143
|
);
|
|
126
144
|
} catch (error: unknown) {
|
|
127
145
|
// gh CLI 不可用或 PR 不存在
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
146
|
+
throw new ReviewCheckError(
|
|
147
|
+
'无法获取 PR 状态',
|
|
148
|
+
error instanceof Error ? error.message : String(error),
|
|
149
|
+
{ suggestion: '确保已安装 gh CLI 并配置了 GitHub token' }
|
|
150
|
+
);
|
|
131
151
|
}
|
|
132
152
|
}
|
|
133
153
|
|
|
@@ -167,21 +187,10 @@ export class ReviewGate implements Gate {
|
|
|
167
187
|
}
|
|
168
188
|
);
|
|
169
189
|
} catch (error: unknown) {
|
|
170
|
-
|
|
190
|
+
throw new ReviewCheckError(
|
|
191
|
+
'Git 检查失败',
|
|
192
|
+
error instanceof Error ? error.message : String(error)
|
|
193
|
+
);
|
|
171
194
|
}
|
|
172
195
|
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* 设置最小审批人数
|
|
176
|
-
*/
|
|
177
|
-
setMinReviewers(count: number): void {
|
|
178
|
-
this.config.minReviewers = count;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* 获取配置
|
|
183
|
-
*/
|
|
184
|
-
getConfig(): Required<ReviewGateConfig> {
|
|
185
|
-
return { ...this.config };
|
|
186
|
-
}
|
|
187
196
|
}
|
package/src/gates/security.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { execAsync } from '../utils/exec';
|
|
14
|
+
import { isRecord } from '../utils/guards';
|
|
14
15
|
import { gateResult, fromError } from './types';
|
|
15
16
|
import type { GateResult, GateContext, SecurityGateConfig, Gate, GateDecision } from './types';
|
|
16
17
|
import { decisionFromResult } from './decision';
|
|
@@ -32,14 +33,6 @@ interface VulnerabilityAnalysis {
|
|
|
32
33
|
vulnerabilities: VulnerabilityEntry[];
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
/** npm audit(旧版 audit.advisories 形状)单条 advisory 已读字段 */
|
|
36
|
-
interface NpmAdvisory {
|
|
37
|
-
name?: string;
|
|
38
|
-
severity?: string;
|
|
39
|
-
title?: string;
|
|
40
|
-
via?: Array<{ title?: string } | string>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
36
|
/** npm audit(v7+ vulnerabilities 形状)单条记录已读字段 */
|
|
44
37
|
interface NpmVulnerability {
|
|
45
38
|
name?: string;
|
|
@@ -47,12 +40,8 @@ interface NpmVulnerability {
|
|
|
47
40
|
via?: Array<{ title?: string } | string>;
|
|
48
41
|
}
|
|
49
42
|
|
|
50
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
51
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
43
|
/** via 的首个来源标题(字符串直取,对象取 title) */
|
|
55
|
-
function viaTitle(via:
|
|
44
|
+
function viaTitle(via: NpmVulnerability['via']): string | undefined {
|
|
56
45
|
const first = via?.[0];
|
|
57
46
|
if (typeof first === 'string') return first;
|
|
58
47
|
return first?.title;
|
|
@@ -155,7 +144,8 @@ export class SecurityGate implements Gate {
|
|
|
155
144
|
}
|
|
156
145
|
|
|
157
146
|
/**
|
|
158
|
-
* 分析扫描结果:只认 npm audit
|
|
147
|
+
* 分析扫描结果:只认 npm audit v7+ 的 vulnerabilities 形状(npm 6 的
|
|
148
|
+
* audit.advisories 旧格式分支已随其 EOL 删除)。
|
|
159
149
|
* 输出不是合法 JSON 对象 → 抛错(不再有文本正则兜底)。
|
|
160
150
|
*/
|
|
161
151
|
private analyzeResult(output: string): VulnerabilityAnalysis {
|
|
@@ -179,22 +169,6 @@ export class SecurityGate implements Gate {
|
|
|
179
169
|
throw new Error('安全扫描输出不是 JSON 对象');
|
|
180
170
|
}
|
|
181
171
|
|
|
182
|
-
// npm audit 旧格式
|
|
183
|
-
if (isRecord(raw.audit)) {
|
|
184
|
-
const advisories = isRecord(raw.audit.advisories) ? raw.audit.advisories : {};
|
|
185
|
-
for (const [key, entry] of Object.entries(advisories)) {
|
|
186
|
-
const advisory = (isRecord(entry) ? entry : {}) as NpmAdvisory;
|
|
187
|
-
const severity = advisory.severity?.toLowerCase() ?? 'low';
|
|
188
|
-
count(severity);
|
|
189
|
-
vulnerabilities.push({
|
|
190
|
-
name: advisory.name ?? key,
|
|
191
|
-
severity,
|
|
192
|
-
via: viaTitle(advisory.via) ?? advisory.title ?? 'Unknown',
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// 新版 npm audit 格式
|
|
198
172
|
if (isRecord(raw.vulnerabilities)) {
|
|
199
173
|
for (const [name, entry] of Object.entries(raw.vulnerabilities)) {
|
|
200
174
|
const vuln = (isRecord(entry) ? entry : {}) as NpmVulnerability;
|
|
@@ -234,18 +208,4 @@ export class SecurityGate implements Gate {
|
|
|
234
208
|
return analysis.total === 0;
|
|
235
209
|
}
|
|
236
210
|
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* 设置严重程度阈值
|
|
240
|
-
*/
|
|
241
|
-
setSeverityThreshold(threshold: 'low' | 'moderate' | 'high' | 'critical'): void {
|
|
242
|
-
this.config.severityThreshold = threshold;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* 获取配置
|
|
247
|
-
*/
|
|
248
|
-
getConfig(): SecurityGateConfig {
|
|
249
|
-
return { ...this.config };
|
|
250
|
-
}
|
|
251
211
|
}
|