@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
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
import * as fs from 'fs';
|
|
15
15
|
import * as path from 'path';
|
|
16
|
+
import { execSync } from 'child_process';
|
|
16
17
|
import { readPackageJson } from '../utils/package-json';
|
|
18
|
+
import { attempt } from '../utils/attempt';
|
|
17
19
|
import type { KnowledgeEntry, KnowledgeSubsystem, StorageLayer } from './types';
|
|
18
20
|
import type { KnowledgeStore } from './store';
|
|
19
21
|
|
|
@@ -35,7 +37,6 @@ export interface ImportResult {
|
|
|
35
37
|
export interface ImportError {
|
|
36
38
|
source: ImportSource;
|
|
37
39
|
message: string;
|
|
38
|
-
recoverable: boolean;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
// ── 导入状态 ─────────────────────────────────────────────
|
|
@@ -45,7 +46,6 @@ export interface ImportState {
|
|
|
45
46
|
startedAt: string;
|
|
46
47
|
lastUpdated: string;
|
|
47
48
|
completedSources: string[];
|
|
48
|
-
pendingSources: string[];
|
|
49
49
|
totalImported: number;
|
|
50
50
|
totalErrors: number;
|
|
51
51
|
}
|
|
@@ -94,29 +94,19 @@ export class ColdStartImporter {
|
|
|
94
94
|
continue;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
break;
|
|
106
|
-
case 'docs':
|
|
107
|
-
result = await this.importFromDocs();
|
|
108
|
-
break;
|
|
109
|
-
case 'manual':
|
|
110
|
-
result = await this.importManual();
|
|
111
|
-
break;
|
|
112
|
-
default:
|
|
113
|
-
// sourceType 静态收窄为 never(switch 已穷尽四源);分支防的是运行时脏配置
|
|
114
|
-
result = {
|
|
97
|
+
// 降级记名(attempt,fail-open):单源失败记进 result.errors——CLI 输出面露出错误行
|
|
98
|
+
// 与错误计数——并继续后续源,不拖死整批冷启动导入;非静默吞错
|
|
99
|
+
const result = attempt(
|
|
100
|
+
() => this.dispatchSource(sourceType),
|
|
101
|
+
(err): ImportResult => ({
|
|
102
|
+
source: { type: sourceType },
|
|
103
|
+
entries: [],
|
|
104
|
+
errors: [{
|
|
115
105
|
source: { type: sourceType },
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
message: `${sourceType} 导入失败: ${err instanceof Error ? err.message : String(err)}`,
|
|
107
|
+
}],
|
|
108
|
+
})
|
|
109
|
+
);
|
|
120
110
|
|
|
121
111
|
results.push(result);
|
|
122
112
|
|
|
@@ -131,126 +121,121 @@ export class ColdStartImporter {
|
|
|
131
121
|
return results;
|
|
132
122
|
}
|
|
133
123
|
|
|
124
|
+
private dispatchSource(sourceType: ImportSource['type']): ImportResult {
|
|
125
|
+
switch (sourceType) {
|
|
126
|
+
case 'code':
|
|
127
|
+
return this.importFromCode();
|
|
128
|
+
case 'git':
|
|
129
|
+
return this.importFromGit();
|
|
130
|
+
case 'docs':
|
|
131
|
+
return this.importFromDocs();
|
|
132
|
+
case 'manual':
|
|
133
|
+
return this.importManual();
|
|
134
|
+
default:
|
|
135
|
+
// sourceType 静态收窄为 never(switch 已穷尽四源);分支防的是运行时脏配置
|
|
136
|
+
throw new Error(`未知源类型: ${String(sourceType)}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
134
140
|
/**
|
|
135
141
|
* 从代码仓库扫描提取知识
|
|
136
142
|
*/
|
|
137
|
-
private
|
|
143
|
+
private importFromCode(): ImportResult {
|
|
138
144
|
const entries: KnowledgeEntry[] = [];
|
|
139
|
-
const errors: ImportError[] = [];
|
|
140
145
|
const source: ImportSource = { type: 'code', path: this.config.projectRoot };
|
|
141
146
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
147
|
+
// 扫描 package.json 获取技术栈(缺失 → 无条目;损坏 → 抛出,由 importAll 记名降级为错误行)
|
|
148
|
+
const pkg = readPackageJson(this.config.projectRoot);
|
|
149
|
+
if (pkg) {
|
|
150
|
+
entries.push(this.createEntry({
|
|
151
|
+
title: `技术栈: ${pkg.name || 'unknown'}`,
|
|
152
|
+
content: this.formatPackageInfo(pkg),
|
|
153
|
+
type: 'model',
|
|
154
|
+
tags: ['tech-stack', 'auto-import'],
|
|
155
|
+
layer: 'project',
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
154
158
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
// 扫描 tsconfig.json
|
|
160
|
+
const tsconfigPath = path.join(this.config.projectRoot, 'tsconfig.json');
|
|
161
|
+
if (fs.existsSync(tsconfigPath)) {
|
|
162
|
+
entries.push(this.createEntry({
|
|
163
|
+
title: 'TypeScript 配置',
|
|
164
|
+
content: fs.readFileSync(tsconfigPath, 'utf-8'),
|
|
165
|
+
type: 'model',
|
|
166
|
+
tags: ['typescript', 'config', 'auto-import'],
|
|
167
|
+
layer: 'project',
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
166
170
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
} catch (error) {
|
|
179
|
-
errors.push({
|
|
180
|
-
source,
|
|
181
|
-
message: `代码扫描失败: ${error instanceof Error ? error.message : String(error)}`,
|
|
182
|
-
recoverable: true,
|
|
183
|
-
});
|
|
171
|
+
// 扫描目录结构
|
|
172
|
+
const dirs = this.scanDirectoryStructure(this.config.projectRoot);
|
|
173
|
+
if (dirs.length > 0) {
|
|
174
|
+
entries.push(this.createEntry({
|
|
175
|
+
title: '项目目录结构',
|
|
176
|
+
content: dirs.join('\n'),
|
|
177
|
+
type: 'model',
|
|
178
|
+
tags: ['architecture', 'auto-import'],
|
|
179
|
+
layer: 'project',
|
|
180
|
+
}));
|
|
184
181
|
}
|
|
185
182
|
|
|
186
183
|
// 写入知识库
|
|
187
184
|
this.config.store.saveAll(entries);
|
|
188
185
|
|
|
189
|
-
return { source, entries, errors };
|
|
186
|
+
return { source, entries, errors: [] };
|
|
190
187
|
}
|
|
191
188
|
|
|
192
189
|
/**
|
|
193
190
|
* 从 Git 历史分析提取知识
|
|
194
191
|
*/
|
|
195
|
-
private
|
|
192
|
+
private importFromGit(): ImportResult {
|
|
196
193
|
const entries: KnowledgeEntry[] = [];
|
|
197
|
-
const errors: ImportError[] = [];
|
|
198
194
|
const source: ImportSource = { type: 'git', path: this.config.projectRoot };
|
|
195
|
+
const cwd = this.config.projectRoot;
|
|
196
|
+
|
|
197
|
+
// 查找 fix/hotfix 相关提交
|
|
198
|
+
const fixCommits = execSync(
|
|
199
|
+
'git log --oneline --grep="fix\\|hotfix\\|bug" --since="6 months ago" | head -20',
|
|
200
|
+
{ cwd, encoding: 'utf-8', timeout: 10000 },
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
if (fixCommits.trim()) {
|
|
204
|
+
entries.push(this.createEntry({
|
|
205
|
+
title: '近期 Bug 修复记录',
|
|
206
|
+
content: fixCommits.trim(),
|
|
207
|
+
type: 'pitfall',
|
|
208
|
+
tags: ['git-history', 'bug-fix', 'auto-import'],
|
|
209
|
+
layer: 'project',
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
199
212
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
type: 'pitfall',
|
|
215
|
-
tags: ['git-history', 'bug-fix', 'auto-import'],
|
|
216
|
-
layer: 'project',
|
|
217
|
-
}));
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// 查找 refactor 相关提交
|
|
221
|
-
const refactorCommits = execSync(
|
|
222
|
-
'git log --oneline --grep="refactor\\|重构" --since="6 months ago" | head -20',
|
|
223
|
-
{ cwd, encoding: 'utf-8', timeout: 10000 },
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
if (refactorCommits.trim()) {
|
|
227
|
-
entries.push(this.createEntry({
|
|
228
|
-
title: '近期重构记录',
|
|
229
|
-
content: refactorCommits.trim(),
|
|
230
|
-
type: 'decision',
|
|
231
|
-
tags: ['git-history', 'refactor', 'auto-import'],
|
|
232
|
-
layer: 'project',
|
|
233
|
-
}));
|
|
234
|
-
}
|
|
235
|
-
} catch (error) {
|
|
236
|
-
errors.push({
|
|
237
|
-
source,
|
|
238
|
-
message: `Git 分析失败: ${error instanceof Error ? error.message : String(error)}`,
|
|
239
|
-
recoverable: true,
|
|
240
|
-
});
|
|
213
|
+
// 查找 refactor 相关提交
|
|
214
|
+
const refactorCommits = execSync(
|
|
215
|
+
'git log --oneline --grep="refactor\\|重构" --since="6 months ago" | head -20',
|
|
216
|
+
{ cwd, encoding: 'utf-8', timeout: 10000 },
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
if (refactorCommits.trim()) {
|
|
220
|
+
entries.push(this.createEntry({
|
|
221
|
+
title: '近期重构记录',
|
|
222
|
+
content: refactorCommits.trim(),
|
|
223
|
+
type: 'decision',
|
|
224
|
+
tags: ['git-history', 'refactor', 'auto-import'],
|
|
225
|
+
layer: 'project',
|
|
226
|
+
}));
|
|
241
227
|
}
|
|
242
228
|
|
|
243
229
|
this.config.store.saveAll(entries);
|
|
244
230
|
|
|
245
|
-
return { source, entries, errors };
|
|
231
|
+
return { source, entries, errors: [] };
|
|
246
232
|
}
|
|
247
233
|
|
|
248
234
|
/**
|
|
249
235
|
* 从文档导入
|
|
250
236
|
*/
|
|
251
|
-
private
|
|
237
|
+
private importFromDocs(): ImportResult {
|
|
252
238
|
const entries: KnowledgeEntry[] = [];
|
|
253
|
-
const errors: ImportError[] = [];
|
|
254
239
|
const source: ImportSource = { type: 'docs' };
|
|
255
240
|
|
|
256
241
|
const docPaths = this.config.docPaths ?? [
|
|
@@ -262,92 +247,70 @@ export class ColdStartImporter {
|
|
|
262
247
|
|
|
263
248
|
for (const docPath of docPaths) {
|
|
264
249
|
const fullPath = path.join(this.config.projectRoot, docPath);
|
|
250
|
+
if (!fs.existsSync(fullPath)) continue;
|
|
265
251
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
for (const file of files) {
|
|
280
|
-
const filePath = path.join(fullPath, file);
|
|
281
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
282
|
-
if (content.length > 0) {
|
|
283
|
-
entries.push(this.createEntry({
|
|
284
|
-
title: `文档: ${docPath}${file}`,
|
|
285
|
-
content: content.slice(0, 5000), // 限制大小
|
|
286
|
-
type: 'guideline',
|
|
287
|
-
tags: ['docs', 'auto-import'],
|
|
288
|
-
layer: 'project',
|
|
289
|
-
}));
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
} else {
|
|
293
|
-
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
252
|
+
const stat = fs.statSync(fullPath);
|
|
253
|
+
|
|
254
|
+
if (stat.isDirectory()) {
|
|
255
|
+
// 扫描目录下的 markdown 文件
|
|
256
|
+
// 口径记名(harness#134):本 walker 吃的是**项目文档树**(README/docs/),不是知识库树,
|
|
257
|
+
// 故不适用 tree-walker 的条目排除口径——知识树的 `_index.md`/`.snapshots` 在这里没有对应物。
|
|
258
|
+
const files = fs.readdirSync(fullPath)
|
|
259
|
+
.filter(f => f.endsWith('.md'))
|
|
260
|
+
.slice(0, 10); // 最多 10 个
|
|
261
|
+
|
|
262
|
+
for (const file of files) {
|
|
263
|
+
const filePath = path.join(fullPath, file);
|
|
264
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
294
265
|
if (content.length > 0) {
|
|
295
266
|
entries.push(this.createEntry({
|
|
296
|
-
title: `文档: ${docPath}`,
|
|
297
|
-
content: content.slice(0, 5000),
|
|
267
|
+
title: `文档: ${docPath}${file}`,
|
|
268
|
+
content: content.slice(0, 5000), // 限制大小
|
|
298
269
|
type: 'guideline',
|
|
299
270
|
tags: ['docs', 'auto-import'],
|
|
300
271
|
layer: 'project',
|
|
301
272
|
}));
|
|
302
273
|
}
|
|
303
274
|
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
275
|
+
} else {
|
|
276
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
277
|
+
if (content.length > 0) {
|
|
278
|
+
entries.push(this.createEntry({
|
|
279
|
+
title: `文档: ${docPath}`,
|
|
280
|
+
content: content.slice(0, 5000),
|
|
281
|
+
type: 'guideline',
|
|
282
|
+
tags: ['docs', 'auto-import'],
|
|
283
|
+
layer: 'project',
|
|
284
|
+
}));
|
|
285
|
+
}
|
|
310
286
|
}
|
|
311
287
|
}
|
|
312
288
|
|
|
313
289
|
this.config.store.saveAll(entries);
|
|
314
290
|
|
|
315
|
-
return { source, entries, errors };
|
|
291
|
+
return { source, entries, errors: [] };
|
|
316
292
|
}
|
|
317
293
|
|
|
318
294
|
/**
|
|
319
295
|
* 口述录入
|
|
320
296
|
*/
|
|
321
|
-
private
|
|
297
|
+
private importManual(): ImportResult {
|
|
322
298
|
const entries: KnowledgeEntry[] = [];
|
|
323
|
-
const errors: ImportError[] = [];
|
|
324
299
|
const source: ImportSource = { type: 'manual' };
|
|
325
300
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
content: item.content,
|
|
335
|
-
type: item.type,
|
|
336
|
-
tags: [...(item.tags ?? []), 'manual-import'],
|
|
337
|
-
layer: 'project',
|
|
338
|
-
}));
|
|
339
|
-
} catch (error) {
|
|
340
|
-
errors.push({
|
|
341
|
-
source,
|
|
342
|
-
message: `口述录入失败: ${error instanceof Error ? error.message : String(error)}`,
|
|
343
|
-
recoverable: true,
|
|
344
|
-
});
|
|
345
|
-
}
|
|
301
|
+
for (const item of this.config.manualEntries ?? []) {
|
|
302
|
+
entries.push(this.createEntry({
|
|
303
|
+
title: item.title,
|
|
304
|
+
content: item.content,
|
|
305
|
+
type: item.type,
|
|
306
|
+
tags: [...(item.tags ?? []), 'manual-import'],
|
|
307
|
+
layer: 'project',
|
|
308
|
+
}));
|
|
346
309
|
}
|
|
347
310
|
|
|
348
311
|
this.config.store.saveAll(entries);
|
|
349
312
|
|
|
350
|
-
return { source, entries, errors };
|
|
313
|
+
return { source, entries, errors: [] };
|
|
351
314
|
}
|
|
352
315
|
|
|
353
316
|
// ── 辅助方法 ───────────────────────────────────────────
|
|
@@ -423,18 +386,16 @@ export class ColdStartImporter {
|
|
|
423
386
|
const scan = (dir: string, depth: number) => {
|
|
424
387
|
if (depth > maxDepth) return;
|
|
425
388
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
389
|
+
// 目录不可读(权限等)直抛,由 importAll 的记名降级露成错误行——
|
|
390
|
+
// 静默跳过会让「目录结构」条目悄悄缺胳膊少腿
|
|
391
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
392
|
+
for (const entry of entries) {
|
|
393
|
+
if (ignore.has(entry.name)) continue;
|
|
394
|
+
if (!entry.isDirectory()) continue;
|
|
431
395
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
436
|
-
} catch {
|
|
437
|
-
// skip unreadable directories
|
|
396
|
+
const relative = path.relative(root, path.join(dir, entry.name));
|
|
397
|
+
dirs.push(relative || entry.name);
|
|
398
|
+
scan(path.join(dir, entry.name), depth + 1);
|
|
438
399
|
}
|
|
439
400
|
};
|
|
440
401
|
|
|
@@ -445,11 +406,9 @@ export class ColdStartImporter {
|
|
|
445
406
|
private loadState(): ImportState {
|
|
446
407
|
const statePath = path.join(this.config.projectRoot, STATE_FILE);
|
|
447
408
|
if (fs.existsSync(statePath)) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
// corrupt state, start fresh
|
|
452
|
-
}
|
|
409
|
+
// fail-fast:状态文件在场但损坏直接抛(对齐 store.ts「损坏 ≠ 缺失」口径)——
|
|
410
|
+
// 静默重置会把已完成源再导入一遍,重复条目落库
|
|
411
|
+
return JSON.parse(fs.readFileSync(statePath, 'utf-8')) as ImportState;
|
|
453
412
|
}
|
|
454
413
|
|
|
455
414
|
return {
|
|
@@ -457,7 +416,6 @@ export class ColdStartImporter {
|
|
|
457
416
|
startedAt: new Date().toISOString(),
|
|
458
417
|
lastUpdated: new Date().toISOString(),
|
|
459
418
|
completedSources: [],
|
|
460
|
-
pendingSources: [...this.config.sources],
|
|
461
419
|
totalImported: 0,
|
|
462
420
|
totalErrors: 0,
|
|
463
421
|
};
|
|
@@ -488,7 +446,6 @@ export class ColdStartImporter {
|
|
|
488
446
|
startedAt: new Date().toISOString(),
|
|
489
447
|
lastUpdated: new Date().toISOString(),
|
|
490
448
|
completedSources: [],
|
|
491
|
-
pendingSources: [...this.config.sources],
|
|
492
449
|
totalImported: 0,
|
|
493
450
|
totalErrors: 0,
|
|
494
451
|
};
|
package/src/knowledge/index.ts
CHANGED
|
@@ -14,17 +14,12 @@ export type {
|
|
|
14
14
|
KnowledgeEntry,
|
|
15
15
|
SourceRef,
|
|
16
16
|
ExecutionResult,
|
|
17
|
-
KnowledgeReference,
|
|
18
17
|
QueryBudget,
|
|
19
18
|
QueryResult,
|
|
20
19
|
QueryFilter,
|
|
21
|
-
LintIssueType,
|
|
22
|
-
LintIssue,
|
|
23
20
|
IngestOptions,
|
|
24
21
|
MaturityChange,
|
|
25
22
|
DecayConfig,
|
|
26
|
-
DecisionRecord,
|
|
27
|
-
ReferenceRecord,
|
|
28
23
|
IndexEntry,
|
|
29
24
|
SnapshotSurvival,
|
|
30
25
|
ConsumptionStats,
|
|
@@ -37,10 +32,8 @@ export { estimateTokens } from './token-estimate';
|
|
|
37
32
|
export { KnowledgeLifecycle } from './lifecycle';
|
|
38
33
|
export type { ConsumptionEvent } from './lifecycle';
|
|
39
34
|
export { KnowledgeIngest, sanitizeExternalContent } from './ingest';
|
|
40
|
-
export {
|
|
41
|
-
export {
|
|
42
|
-
export { ColdStartImporter } from './import';
|
|
43
|
-
export { KnowledgeHealthScorer } from './doctor';
|
|
35
|
+
export type { IngestValidationIssue } from './ingest';
|
|
36
|
+
export { ColdStartImporter } from './cold-start';
|
|
44
37
|
export { KnowledgeAudit } from './audit';
|
|
45
38
|
export type { AuditRuleName, AuditAction, AuditIssue } from './audit-rules';
|
|
46
39
|
export type { AuditOptions } from './audit-scoring';
|
package/src/knowledge/ingest.ts
CHANGED
|
@@ -11,13 +11,24 @@ import type {
|
|
|
11
11
|
IngestOptions,
|
|
12
12
|
SourceRef,
|
|
13
13
|
} from './types';
|
|
14
|
+
import { MATURITY_LEVELS, STORAGE_LAYERS } from './types';
|
|
14
15
|
import type { KnowledgeStore } from './store';
|
|
15
16
|
import { KnowledgeAudit } from './audit';
|
|
17
|
+
import { MAX_SOURCE_REFS } from './audit-rules';
|
|
16
18
|
import { splitFrontmatter } from '../utils/frontmatter';
|
|
17
19
|
|
|
18
|
-
const MAX_SOURCE_REFS = 20;
|
|
19
20
|
const MAX_EXTERNAL_CONTENT_LENGTH = 5000;
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* `validateEntry` 的一条摄入前校验问题(lint.ts 删除后的保种落点,ADR-0040 Phase 4)。
|
|
24
|
+
* severity='high' 按阻断处理(拒收),其余为提示。
|
|
25
|
+
*/
|
|
26
|
+
export interface IngestValidationIssue {
|
|
27
|
+
severity: 'low' | 'medium' | 'high';
|
|
28
|
+
description: string;
|
|
29
|
+
suggestion: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
/**
|
|
22
33
|
* `ingestEntry` / `ingestBatch` / `ingestExternal` 的返回(判别联合):
|
|
23
34
|
* - `accepted`:已落盘(新建或去重合并),`entry` 为最终形态
|
|
@@ -154,6 +165,103 @@ export class KnowledgeIngest {
|
|
|
154
165
|
);
|
|
155
166
|
}
|
|
156
167
|
|
|
168
|
+
/**
|
|
169
|
+
* 摄入前单条校验(KnowledgeLinter.validateEntry 的保种落点,ADR-0040 Phase 4;
|
|
170
|
+
* 原 lint.ts 随 audit 正本收口删除)。返回空数组 = 可摄入。
|
|
171
|
+
*
|
|
172
|
+
* 检查项:
|
|
173
|
+
* - maturity/layer 未声明枚举值 → high(字段缺省跳过,兼容只传四字段的
|
|
174
|
+
* pre-ingest 调用方;存量枚举扫描由 audit 覆盖)
|
|
175
|
+
* - content < 20 字符 → high(疑似 LLM 幻觉,拒收)
|
|
176
|
+
* - title 过于宽泛(只有症状词)→ medium
|
|
177
|
+
* - 与同 type、共享 ≥2 tag 的 proven 条目矛盾风险 → high
|
|
178
|
+
* - 与存量条目标题精确重复 / 互相包含 → medium / low
|
|
179
|
+
*/
|
|
180
|
+
validateEntry(entry: { title: string; content: string; tags: string[]; type: string; maturity?: string; layer?: string }): IngestValidationIssue[] {
|
|
181
|
+
const issues: IngestValidationIssue[] = [];
|
|
182
|
+
|
|
183
|
+
// 未声明枚举值(字段缺省跳过)
|
|
184
|
+
if (entry.maturity !== undefined && !(MATURITY_LEVELS as readonly string[]).includes(entry.maturity)) {
|
|
185
|
+
issues.push({
|
|
186
|
+
severity: 'high',
|
|
187
|
+
description: `maturity "${entry.maturity}" is not a declared value (${MATURITY_LEVELS.join(' | ')}).`,
|
|
188
|
+
suggestion: 'Map to a declared maturity (e.g. pending → draft) before writing; the store write gate rejects undeclared values.',
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (entry.layer !== undefined && !(STORAGE_LAYERS as readonly string[]).includes(entry.layer)) {
|
|
192
|
+
issues.push({
|
|
193
|
+
severity: 'high',
|
|
194
|
+
description: `layer "${entry.layer}" is not a declared value (${STORAGE_LAYERS.join(' | ')}).`,
|
|
195
|
+
suggestion: 'Map to a declared layer or drop the field; the store write gate rejects undeclared values.',
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Content too short
|
|
200
|
+
if ((entry.content || '').length < 20) {
|
|
201
|
+
issues.push({
|
|
202
|
+
severity: 'high',
|
|
203
|
+
description: `Content too short (${entry.content.length} chars). LLM may have hallucinated.`,
|
|
204
|
+
suggestion: 'Reject — re-extract with better prompt or discard.',
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Title too vague
|
|
209
|
+
const vaguePatterns = /^(错误|失败|问题|异常|bug|error|fail|issue|problem|unknown|untitled)$/i;
|
|
210
|
+
if (vaguePatterns.test(entry.title.trim())) {
|
|
211
|
+
issues.push({
|
|
212
|
+
severity: 'medium',
|
|
213
|
+
description: `Title "${entry.title}" is too vague to be useful.`,
|
|
214
|
+
suggestion: 'Re-extract with root cause in title, not symptom.',
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Contradicts proven entry with same tags
|
|
219
|
+
if (entry.tags && entry.tags.length > 0) {
|
|
220
|
+
const allEntries = this.store.list({ excludeArchived: false });
|
|
221
|
+
for (const existing of allEntries) {
|
|
222
|
+
if (existing.maturity !== 'proven') continue;
|
|
223
|
+
if (existing.type !== entry.type) continue;
|
|
224
|
+
const sharedTags = entry.tags.filter(t => existing.tags.includes(t));
|
|
225
|
+
if (sharedTags.length >= 2) {
|
|
226
|
+
issues.push({
|
|
227
|
+
severity: 'high',
|
|
228
|
+
description: `New entry "${entry.title}" shares tags [${sharedTags.join(', ')}] with proven entry "${existing.title}" (${existing.id}). Contradiction risk.`,
|
|
229
|
+
suggestion: `Review against ${existing.id}. If aligned, merge. If contradictory, flag for human review.`,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Near-duplicate title check (simple: case-insensitive substring match)
|
|
236
|
+
if (entry.title.length > 10) {
|
|
237
|
+
const allEntries = this.store.list({ excludeArchived: false });
|
|
238
|
+
for (const existing of allEntries) {
|
|
239
|
+
if (existing.id === entry.title) continue; // not same entry (entry doesn't have id yet)
|
|
240
|
+
const existingTitle = (existing.title || '').toLowerCase();
|
|
241
|
+
const newTitle = (entry.title || '').toLowerCase();
|
|
242
|
+
if (existingTitle === newTitle) {
|
|
243
|
+
issues.push({
|
|
244
|
+
severity: 'medium',
|
|
245
|
+
description: `Exact title match with existing entry "${existing.title}" (${existing.id}).`,
|
|
246
|
+
suggestion: `Merge into ${existing.id} instead of creating duplicate.`,
|
|
247
|
+
});
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
// Check high similarity (either title contains the other)
|
|
251
|
+
if (existingTitle.includes(newTitle) || newTitle.includes(existingTitle)) {
|
|
252
|
+
issues.push({
|
|
253
|
+
severity: 'low',
|
|
254
|
+
description: `Title similarity with existing "${existing.title}" (${existing.id}).`,
|
|
255
|
+
suggestion: `Consider merging with ${existing.id}.`,
|
|
256
|
+
});
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return issues;
|
|
263
|
+
}
|
|
264
|
+
|
|
157
265
|
// ── Internal ───────────────────────────────────────────────
|
|
158
266
|
|
|
159
267
|
private buildEntry(
|
|
@@ -161,7 +269,7 @@ export class KnowledgeIngest {
|
|
|
161
269
|
options: IngestOptions,
|
|
162
270
|
): KnowledgeEntry {
|
|
163
271
|
const now = new Date().toISOString();
|
|
164
|
-
const type = partial.type ||
|
|
272
|
+
const type = partial.type || 'guideline';
|
|
165
273
|
const id = partial.id || this.generateId(type);
|
|
166
274
|
|
|
167
275
|
return {
|
|
@@ -197,11 +305,6 @@ export class KnowledgeIngest {
|
|
|
197
305
|
return `${prefix}-${seq}`;
|
|
198
306
|
}
|
|
199
307
|
|
|
200
|
-
private inferType(_options: IngestOptions): KnowledgeSubsystem {
|
|
201
|
-
// Default to 'guideline' if type can't be inferred
|
|
202
|
-
return 'guideline';
|
|
203
|
-
}
|
|
204
|
-
|
|
205
308
|
private findDuplicate(title: string, content: string, type: KnowledgeSubsystem): KnowledgeEntry | undefined {
|
|
206
309
|
// A1: Read from disk directly to avoid stale index causing dedup failure
|
|
207
310
|
const all = this.store.readEntriesFromDisk().filter(e => e.type === type);
|