@dommaker/harness 1.16.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/agents/lifecycle.d.ts.map +1 -1
- package/dist/agents/lifecycle.js +3 -6
- package/dist/agents/lifecycle.js.map +1 -1
- package/dist/cli/command-contract.d.ts +6 -9
- package/dist/cli/command-contract.d.ts.map +1 -1
- package/dist/cli/command-contract.js +6 -0
- package/dist/cli/command-contract.js.map +1 -1
- package/dist/cli/commands/acceptance.d.ts.map +1 -1
- package/dist/cli/commands/acceptance.js +8 -7
- package/dist/cli/commands/acceptance.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +2 -1
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/contract.d.ts.map +1 -1
- package/dist/cli/commands/contract.js +20 -10
- package/dist/cli/commands/contract.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +13 -12
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/init/ci-platform.d.ts +35 -0
- package/dist/cli/commands/init/ci-platform.d.ts.map +1 -0
- package/dist/cli/commands/init/ci-platform.js +59 -0
- package/dist/cli/commands/init/ci-platform.js.map +1 -0
- package/dist/cli/commands/init/ci-wiring.d.ts +20 -0
- package/dist/cli/commands/init/ci-wiring.d.ts.map +1 -0
- package/dist/cli/commands/init/ci-wiring.js +72 -0
- package/dist/cli/commands/init/ci-wiring.js.map +1 -0
- package/dist/cli/commands/init/git-hooks.d.ts +15 -0
- package/dist/cli/commands/init/git-hooks.d.ts.map +1 -0
- package/dist/cli/commands/init/git-hooks.js +64 -0
- package/dist/cli/commands/init/git-hooks.js.map +1 -0
- package/dist/cli/commands/init/governance.d.ts +14 -0
- package/dist/cli/commands/init/governance.d.ts.map +1 -0
- package/dist/cli/commands/init/governance.js +132 -0
- package/dist/cli/commands/init/governance.js.map +1 -0
- package/dist/cli/commands/{init.d.ts → init/index.d.ts} +13 -14
- package/dist/cli/commands/init/index.d.ts.map +1 -0
- package/dist/cli/commands/init/index.js +148 -0
- package/dist/cli/commands/init/index.js.map +1 -0
- package/dist/cli/commands/init/output-style.d.ts +19 -0
- package/dist/cli/commands/init/output-style.d.ts.map +1 -0
- package/dist/cli/commands/init/output-style.js +110 -0
- package/dist/cli/commands/init/output-style.js.map +1 -0
- package/dist/cli/commands/init/presets.d.ts +26 -0
- package/dist/cli/commands/init/presets.d.ts.map +1 -0
- package/dist/cli/commands/init/presets.js +104 -0
- package/dist/cli/commands/init/presets.js.map +1 -0
- package/dist/cli/commands/init/snippets.d.ts +18 -0
- package/dist/cli/commands/init/snippets.d.ts.map +1 -0
- package/dist/cli/commands/init/snippets.js +49 -0
- package/dist/cli/commands/init/snippets.js.map +1 -0
- package/dist/cli/commands/knowledge/audit.d.ts +30 -0
- package/dist/cli/commands/knowledge/audit.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/audit.js +114 -0
- package/dist/cli/commands/knowledge/audit.js.map +1 -0
- package/dist/cli/commands/knowledge/decay.d.ts +19 -0
- package/dist/cli/commands/knowledge/decay.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/decay.js +48 -0
- package/dist/cli/commands/knowledge/decay.js.map +1 -0
- package/dist/cli/commands/knowledge/health.d.ts +36 -0
- package/dist/cli/commands/knowledge/health.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/health.js +172 -0
- package/dist/cli/commands/knowledge/health.js.map +1 -0
- package/dist/cli/commands/knowledge/import.d.ts +26 -0
- package/dist/cli/commands/knowledge/import.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/import.js +63 -0
- package/dist/cli/commands/knowledge/import.js.map +1 -0
- package/dist/cli/commands/knowledge/index.d.ts +25 -0
- package/dist/cli/commands/knowledge/index.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/index.js +84 -0
- package/dist/cli/commands/knowledge/index.js.map +1 -0
- package/dist/cli/commands/knowledge/list.d.ts +25 -0
- package/dist/cli/commands/knowledge/list.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/list.js +60 -0
- package/dist/cli/commands/knowledge/list.js.map +1 -0
- package/dist/cli/commands/knowledge/migrate.d.ts +21 -0
- package/dist/cli/commands/knowledge/migrate.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/migrate.js +48 -0
- package/dist/cli/commands/knowledge/migrate.js.map +1 -0
- package/dist/cli/commands/knowledge/search.d.ts +32 -0
- package/dist/cli/commands/knowledge/search.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/search.js +73 -0
- package/dist/cli/commands/knowledge/search.js.map +1 -0
- package/dist/cli/commands/knowledge/shared.d.ts +14 -0
- package/dist/cli/commands/knowledge/shared.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/shared.js +6 -0
- package/dist/cli/commands/knowledge/shared.js.map +1 -0
- package/dist/cli/commands/knowledge/snapshot.d.ts +18 -0
- package/dist/cli/commands/knowledge/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/snapshot.js +34 -0
- package/dist/cli/commands/knowledge/snapshot.js.map +1 -0
- package/dist/cli/commands/knowledge/stats.d.ts +26 -0
- package/dist/cli/commands/knowledge/stats.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/stats.js +132 -0
- package/dist/cli/commands/knowledge/stats.js.map +1 -0
- package/dist/cli/commands/knowledge/sync-rag.d.ts +19 -0
- package/dist/cli/commands/knowledge/sync-rag.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/sync-rag.js +77 -0
- package/dist/cli/commands/knowledge/sync-rag.js.map +1 -0
- package/dist/cli/commands/knowledge-view.d.ts +2 -1
- package/dist/cli/commands/knowledge-view.d.ts.map +1 -1
- package/dist/cli/commands/knowledge-view.js +2 -2
- package/dist/cli/commands/knowledge-view.js.map +1 -1
- package/dist/cli/commands/passes-gate.d.ts.map +1 -1
- package/dist/cli/commands/passes-gate.js +12 -2
- package/dist/cli/commands/passes-gate.js.map +1 -1
- package/dist/cli/commands/performance.js.map +1 -1
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +13 -41
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/review.d.ts.map +1 -1
- package/dist/cli/commands/review.js +3 -2
- package/dist/cli/commands/review.js.map +1 -1
- package/dist/cli/commands/security.d.ts.map +1 -1
- package/dist/cli/commands/security.js +7 -8
- package/dist/cli/commands/security.js.map +1 -1
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +6 -5
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.js +31 -55
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +18 -12
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/compact.d.ts +9 -0
- package/dist/cli/commands/sync-docs/compact.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/compact.js +73 -0
- package/dist/cli/commands/sync-docs/compact.js.map +1 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +17 -36
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/gate.d.ts +27 -0
- package/dist/cli/commands/sync-docs/gate.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/gate.js +72 -0
- package/dist/cli/commands/sync-docs/gate.js.map +1 -0
- package/dist/cli/commands/sync-docs/index.d.ts +13 -27
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +19 -529
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/main-flow.d.ts +37 -0
- package/dist/cli/commands/sync-docs/main-flow.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/main-flow.js +485 -0
- package/dist/cli/commands/sync-docs/main-flow.js.map +1 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js +16 -25
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/gate-command.d.ts +1 -1
- package/dist/cli/gate-command.d.ts.map +1 -1
- package/dist/context/index.d.ts +1 -3
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +2 -5
- package/dist/context/index.js.map +1 -1
- package/dist/context/session-manager.d.ts +2 -2
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +31 -52
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +2 -2
- package/dist/context/types.d.ts.map +1 -1
- package/dist/core/constraint-lifecycle.d.ts +1 -1
- package/dist/core/constraint-lifecycle.d.ts.map +1 -1
- package/dist/core/constraint-lifecycle.js +1 -1
- package/dist/core/constraint-lifecycle.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +2 -1
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +4 -6
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.js +1 -0
- package/dist/core/constraints/checkers/templated/exec.js.map +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +13 -34
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
- package/dist/core/constraints/definitions/guidelines.js +18 -0
- package/dist/core/constraints/definitions/guidelines.js.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.js +0 -16
- package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +192 -223
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/git-evidence.d.ts.map +1 -1
- package/dist/core/constraints/git-evidence.js +2 -0
- package/dist/core/constraints/git-evidence.js.map +1 -1
- package/dist/core/constraints/injection-writer.d.ts +1 -0
- package/dist/core/constraints/injection-writer.d.ts.map +1 -1
- package/dist/core/constraints/injection-writer.js +3 -6
- package/dist/core/constraints/injection-writer.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +3 -1
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +6 -6
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/spec/validator.d.ts +1 -1
- package/dist/core/spec/validator.d.ts.map +1 -1
- package/dist/core/spec/validator.js +41 -36
- package/dist/core/spec/validator.js.map +1 -1
- package/dist/core/validators/check-handlers/command.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/command.js +7 -4
- package/dist/core/validators/check-handlers/command.js.map +1 -1
- package/dist/core/validators/check-handlers/http.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/http.js +6 -4
- package/dist/core/validators/check-handlers/http.js.map +1 -1
- package/dist/core/validators/check-handlers/output.d.ts +1 -1
- package/dist/core/validators/check-handlers/output.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/output.js +2 -1
- package/dist/core/validators/check-handlers/output.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +2 -1
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +25 -30
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/gates/acceptance.d.ts +37 -18
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +129 -97
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/command.d.ts +1 -1
- package/dist/gates/contract.d.ts +11 -2
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +57 -62
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/performance.d.ts +1 -1
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +18 -8
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/registry.d.ts.map +1 -1
- package/dist/gates/registry.js +6 -2
- package/dist/gates/registry.js.map +1 -1
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +16 -2
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/security.d.ts +5 -1
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +57 -63
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +11 -78
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/gates/types.js +5 -1
- package/dist/gates/types.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit-dimensions.d.ts +45 -0
- package/dist/knowledge/audit-dimensions.d.ts.map +1 -0
- package/dist/knowledge/audit-dimensions.js +144 -0
- package/dist/knowledge/audit-dimensions.js.map +1 -0
- package/dist/knowledge/audit-rules.d.ts +41 -0
- package/dist/knowledge/audit-rules.d.ts.map +1 -0
- package/dist/knowledge/audit-rules.js +269 -0
- package/dist/knowledge/audit-rules.js.map +1 -0
- package/dist/knowledge/audit-scoring.d.ts +6 -60
- package/dist/knowledge/audit-scoring.d.ts.map +1 -1
- package/dist/knowledge/audit-scoring.js +8 -391
- package/dist/knowledge/audit-scoring.js.map +1 -1
- package/dist/knowledge/audit.d.ts +6 -3
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/audit.js +9 -6
- package/dist/knowledge/audit.js.map +1 -1
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/import.js +5 -4
- package/dist/knowledge/import.js.map +1 -1
- package/dist/knowledge/index-generator.d.ts +2 -0
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +43 -50
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/index.d.ts +4 -2
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +2 -1
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/ingest.d.ts +21 -5
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +12 -9
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lifecycle.d.ts.map +1 -1
- package/dist/knowledge/lifecycle.js +17 -22
- package/dist/knowledge/lifecycle.js.map +1 -1
- package/dist/knowledge/query.d.ts +1 -1
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js +7 -7
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/reference-tracker.d.ts.map +1 -1
- package/dist/knowledge/reference-tracker.js +14 -17
- package/dist/knowledge/reference-tracker.js.map +1 -1
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +17 -36
- package/dist/knowledge/store.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +2 -2
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +9 -7
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +6 -4
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/pretool-use-hook.d.ts +1 -1
- package/dist/pretool-use-hook.d.ts.map +1 -1
- package/dist/pretool-use-hook.js +12 -19
- package/dist/pretool-use-hook.js.map +1 -1
- package/dist/release/integrity.d.ts.map +1 -1
- package/dist/release/integrity.js +8 -8
- package/dist/release/integrity.js.map +1 -1
- package/dist/sdd/index-generator.d.ts.map +1 -1
- package/dist/sdd/index-generator.js +4 -0
- package/dist/sdd/index-generator.js.map +1 -1
- package/dist/types/checkpoint.d.ts +8 -8
- package/dist/types/checkpoint.d.ts.map +1 -1
- package/dist/types/command-io.d.ts +19 -0
- package/dist/types/command-io.d.ts.map +1 -0
- package/dist/types/command-io.js +3 -0
- package/dist/types/command-io.js.map +1 -0
- package/dist/types/gate.d.ts +72 -0
- package/dist/types/gate.d.ts.map +1 -0
- package/dist/types/gate.js +13 -0
- package/dist/types/gate.js.map +1 -0
- package/dist/utils/attempt.d.ts +22 -0
- package/dist/utils/attempt.d.ts.map +1 -0
- package/dist/utils/attempt.js +40 -0
- package/dist/utils/attempt.js.map +1 -0
- package/dist/utils/detect-source-roots.d.ts.map +1 -1
- package/dist/utils/detect-source-roots.js +42 -51
- package/dist/utils/detect-source-roots.js.map +1 -1
- package/dist/utils/file-walk.d.ts +2 -1
- package/dist/utils/file-walk.d.ts.map +1 -1
- package/dist/utils/file-walk.js +3 -8
- package/dist/utils/file-walk.js.map +1 -1
- package/dist/utils/package-json.d.ts +49 -0
- package/dist/utils/package-json.d.ts.map +1 -0
- package/dist/utils/package-json.js +78 -0
- package/dist/utils/package-json.js.map +1 -0
- package/dist/utils/package-version.d.ts +5 -2
- package/dist/utils/package-version.d.ts.map +1 -1
- package/dist/utils/package-version.js +8 -11
- package/dist/utils/package-version.js.map +1 -1
- package/package.json +1 -6
- package/src/CONTEXT.md +5 -4
- package/src/__tests__/acceptance-gate.test.ts +23 -51
- package/src/__tests__/contract-gate.test.ts +1 -1
- package/src/__tests__/install-precommit-hook.test.ts +61 -0
- package/src/__tests__/iron-laws.test.ts +5 -5
- package/src/__tests__/layering.test.ts +1 -1
- package/src/__tests__/public-exports.test.ts +1 -1
- package/src/__tests__/public-type-surface.test.ts +9 -19
- package/src/__tests__/public-value-surface.test.ts +9 -17
- package/src/__tests__/skip-semantics.test.ts +5 -4
- package/src/agents/lifecycle.ts +3 -5
- package/src/cli/__tests__/command-contract.test.ts +18 -0
- package/src/cli/command-contract.ts +8 -5
- package/src/cli/commands/CONTEXT.md +10 -10
- package/src/cli/commands/__tests__/check.test.ts +1 -1
- package/src/cli/commands/__tests__/constraints-retire.test.ts +5 -3
- package/src/cli/commands/__tests__/init-governance-io.test.ts +7 -2
- package/src/cli/commands/__tests__/init.test.ts +1 -1
- package/src/cli/commands/__tests__/knowledge-audit-threshold.test.ts +14 -8
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +2 -1
- package/src/cli/commands/__tests__/knowledge-view.test.ts +28 -18
- package/src/cli/commands/__tests__/knowledge.test.ts +6 -2
- package/src/cli/commands/__tests__/numeric-flag-assembly.test.ts +1 -1
- package/src/cli/commands/__tests__/passes-gate.test.ts +100 -24
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +3 -6
- package/src/cli/commands/__tests__/registry.test.ts +3 -2
- package/src/cli/commands/__tests__/release.test.ts +24 -2
- package/src/cli/commands/__tests__/report-false-green.test.ts +10 -6
- package/src/cli/commands/acceptance.ts +10 -9
- package/src/cli/commands/command.ts +1 -1
- package/src/cli/commands/constraints-retire.ts +3 -2
- package/src/cli/commands/contract.ts +29 -14
- package/src/cli/commands/definitions.ts +13 -12
- package/src/cli/commands/init/ci-platform.ts +66 -0
- package/src/cli/commands/init/ci-wiring.ts +48 -0
- package/src/cli/commands/init/git-hooks.ts +31 -0
- package/src/cli/commands/init/governance.ts +127 -0
- package/src/cli/commands/init/index.ts +156 -0
- package/src/cli/commands/init/output-style.ts +82 -0
- package/src/cli/commands/init/presets.ts +105 -0
- package/src/cli/commands/init/snippets.ts +57 -0
- package/src/cli/commands/knowledge/audit.ts +155 -0
- package/src/cli/commands/knowledge/decay.ts +57 -0
- package/src/cli/commands/knowledge/health.ts +176 -0
- package/src/cli/commands/knowledge/import.ts +82 -0
- package/src/cli/commands/knowledge/index.ts +60 -0
- package/src/cli/commands/knowledge/list.ts +73 -0
- package/src/cli/commands/knowledge/migrate.ts +61 -0
- package/src/cli/commands/knowledge/search.ts +93 -0
- package/src/cli/commands/knowledge/shared.ts +13 -0
- package/src/cli/commands/knowledge/snapshot.ts +38 -0
- package/src/cli/commands/knowledge/stats.ts +112 -0
- package/src/cli/commands/knowledge/sync-rag.ts +48 -0
- package/src/cli/commands/knowledge-view.ts +3 -2
- package/src/cli/commands/passes-gate.ts +14 -2
- package/src/cli/commands/performance.ts +2 -2
- package/src/cli/commands/release.ts +14 -9
- package/src/cli/commands/review.ts +5 -4
- package/src/cli/commands/security.ts +10 -11
- package/src/cli/commands/spec-baseline-check.ts +6 -7
- package/src/cli/commands/status.ts +2 -2
- package/src/cli/commands/sync-docs/agents-syncer.ts +28 -47
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +18 -11
- package/src/cli/commands/sync-docs/compact.ts +35 -0
- package/src/cli/commands/sync-docs/context-syncer.ts +15 -31
- package/src/cli/commands/sync-docs/gate.ts +78 -0
- package/src/cli/commands/sync-docs/index.ts +21 -585
- package/src/cli/commands/sync-docs/main-flow.ts +549 -0
- package/src/cli/commands/sync-docs/project-reader.ts +21 -24
- package/src/cli/gate-command.ts +1 -1
- package/src/context/CONTEXT.md +4 -4
- package/src/context/__tests__/session-manager.test.ts +18 -0
- package/src/context/index.ts +1 -5
- package/src/context/session-manager.ts +34 -50
- package/src/context/types.ts +2 -2
- package/src/core/CONTEXT.md +2 -2
- package/src/core/constraint-lifecycle.ts +2 -2
- package/src/core/constraints/capabilities-parser.ts +4 -6
- package/src/core/constraints/checkers/templated/exec.ts +1 -0
- package/src/core/constraints/checkers/templated/file-exists.ts +1 -1
- package/src/core/constraints/context-builder.ts +11 -28
- package/src/core/constraints/definitions/guidelines.ts +19 -0
- package/src/core/constraints/definitions/iron-laws.ts +0 -17
- package/src/core/constraints/doc-freshness/runner.ts +220 -244
- package/src/core/constraints/git-evidence.ts +2 -0
- package/src/core/constraints/injection-writer.ts +3 -6
- package/src/core/project-config-loader.ts +6 -5
- package/src/core/spec/__tests__/validator.test.ts +65 -13
- package/src/core/spec/validator.ts +50 -40
- package/src/core/validators/__tests__/passes-gate-counts.test.ts +52 -0
- package/src/core/validators/check-handlers/command.ts +9 -6
- package/src/core/validators/check-handlers/http.ts +8 -6
- package/src/core/validators/check-handlers/output.ts +7 -6
- package/src/core/validators/passes-gate.ts +31 -32
- package/src/gates/CONTEXT.md +7 -6
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +16 -14
- package/src/gates/__tests__/acceptance.test.ts +69 -94
- package/src/gates/__tests__/command-single-predicate.test.ts +1 -1
- package/src/gates/__tests__/command.test.ts +23 -12
- package/src/gates/__tests__/gate-interface.test.ts +2 -5
- package/src/gates/__tests__/performance.test.ts +3 -3
- package/src/gates/__tests__/security.test.ts +7 -19
- package/src/gates/acceptance.ts +176 -131
- package/src/gates/command.ts +1 -1
- package/src/gates/contract.ts +86 -79
- package/src/gates/performance.ts +35 -19
- package/src/gates/registry.ts +6 -3
- package/src/gates/review.ts +38 -10
- package/src/gates/security.ts +94 -81
- package/src/gates/types.ts +22 -84
- package/src/index.ts +8 -4
- package/src/knowledge/CONTEXT.md +9 -7
- package/src/knowledge/__tests__/audit-labels.test.ts +3 -3
- package/src/knowledge/__tests__/audit-scoring.test.ts +9 -7
- package/src/knowledge/__tests__/ingest.test.ts +17 -17
- package/src/knowledge/__tests__/store.test.ts +4 -6
- package/src/knowledge/audit-dimensions.ts +190 -0
- package/src/knowledge/audit-rules.ts +335 -0
- package/src/knowledge/audit-scoring.ts +7 -495
- package/src/knowledge/audit.ts +9 -11
- package/src/knowledge/import.ts +7 -6
- package/src/knowledge/index-generator.ts +48 -53
- package/src/knowledge/index.ts +4 -2
- package/src/knowledge/ingest.ts +27 -12
- package/src/knowledge/lifecycle.ts +17 -19
- package/src/knowledge/query.ts +7 -6
- package/src/knowledge/reference-tracker.ts +14 -16
- package/src/knowledge/store.ts +17 -32
- package/src/monitoring/trace-analyzer.ts +12 -9
- package/src/monitoring/traces.ts +8 -6
- package/src/pretool-use-hook.ts +26 -21
- package/src/release/CONTEXT.md +1 -1
- package/src/release/__tests__/integrity.test.ts +0 -2
- package/src/release/integrity.ts +8 -9
- package/src/sdd/index-generator.ts +4 -0
- package/src/types/checkpoint.ts +8 -8
- package/src/types/command-io.ts +14 -0
- package/src/types/gate.ts +77 -0
- package/src/utils/__tests__/attempt.test.ts +94 -0
- package/src/utils/__tests__/package-json.test.ts +58 -0
- package/src/utils/__tests__/package-version.test.ts +21 -2
- package/src/utils/attempt.ts +35 -0
- package/src/utils/detect-source-roots.ts +38 -44
- package/src/utils/file-walk.ts +3 -7
- package/src/utils/package-json.ts +61 -0
- package/src/utils/package-version.ts +8 -10
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/init.js +0 -502
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/knowledge.d.ts +0 -169
- package/dist/cli/commands/knowledge.d.ts.map +0 -1
- package/dist/cli/commands/knowledge.js +0 -700
- package/dist/cli/commands/knowledge.js.map +0 -1
- package/dist/context/knowledge-injector.d.ts +0 -51
- package/dist/context/knowledge-injector.d.ts.map +0 -1
- package/dist/context/knowledge-injector.js +0 -128
- package/dist/context/knowledge-injector.js.map +0 -1
- package/dist/gates/index.d.ts +0 -10
- package/dist/gates/index.d.ts.map +0 -1
- package/dist/gates/index.js +0 -11
- package/dist/gates/index.js.map +0 -1
- package/src/cli/commands/init.ts +0 -590
- package/src/cli/commands/knowledge.ts +0 -820
- package/src/context/__tests__/knowledge-injector.test.ts +0 -197
- package/src/context/knowledge-injector.ts +0 -174
- package/src/gates/index.ts +0 -11
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* KnowledgeInjector 测试
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { KnowledgeInjector } from '../knowledge-injector';
|
|
6
|
-
import { KnowledgeQuery } from '../../knowledge/query';
|
|
7
|
-
import { FileKnowledgeStore as KnowledgeStore } from '../../knowledge/store';
|
|
8
|
-
import * as fs from 'fs';
|
|
9
|
-
import * as path from 'path';
|
|
10
|
-
import * as os from 'os';
|
|
11
|
-
|
|
12
|
-
describe('KnowledgeInjector', () => {
|
|
13
|
-
let store: KnowledgeStore;
|
|
14
|
-
let query: KnowledgeQuery;
|
|
15
|
-
let injector: KnowledgeInjector;
|
|
16
|
-
let tmpDir: string;
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'injector-test-'));
|
|
20
|
-
store = new KnowledgeStore({ baseDir: path.join(tmpDir, 'knowledge') });
|
|
21
|
-
query = new KnowledgeQuery(store);
|
|
22
|
-
injector = new KnowledgeInjector(query);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
afterEach(() => {
|
|
26
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
function saveEntry(overrides: any = {}) {
|
|
30
|
-
store.save({
|
|
31
|
-
id: overrides.id || `test-${Math.random().toString(36).slice(2, 6)}`,
|
|
32
|
-
type: 'decision',
|
|
33
|
-
title: 'Test Decision',
|
|
34
|
-
content: 'Some content for testing',
|
|
35
|
-
maturity: 'verified',
|
|
36
|
-
layer: 'project',
|
|
37
|
-
created: new Date().toISOString(),
|
|
38
|
-
lastReferenced: new Date().toISOString(),
|
|
39
|
-
contributors: [],
|
|
40
|
-
projects: [],
|
|
41
|
-
tags: [],
|
|
42
|
-
applicablePhases: [],
|
|
43
|
-
sourceReferences: [],
|
|
44
|
-
referencedBy: [],
|
|
45
|
-
executionResults: [],
|
|
46
|
-
consumptionMode: 'reference',
|
|
47
|
-
origin: 'agent',
|
|
48
|
-
...overrides,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
describe('inject', () => {
|
|
53
|
-
it('应该返回空结果当无知识条目', () => {
|
|
54
|
-
const result = injector.inject({ budget: 800 });
|
|
55
|
-
expect(result.sources.length).toBe(0);
|
|
56
|
-
expect(result.entriesIncluded).toBe(0);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('应该注入知识条目为 ContextSource', () => {
|
|
60
|
-
saveEntry({ id: 'dec-001', title: 'Use TypeScript', content: 'Always use TS' });
|
|
61
|
-
const result = injector.inject({ budget: 8000 });
|
|
62
|
-
expect(result.sources.length).toBe(1);
|
|
63
|
-
expect(result.sources[0].type).toBe('knowledge');
|
|
64
|
-
expect(result.sources[0].priority).toBe(3);
|
|
65
|
-
expect(result.sources[0].content).toContain('Use TypeScript');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('应该按预算裁剪', () => {
|
|
69
|
-
saveEntry({ id: 'a', title: 'A', content: 'x'.repeat(5000) });
|
|
70
|
-
saveEntry({ id: 'b', title: 'B', content: 'y'.repeat(5000) });
|
|
71
|
-
const result = injector.inject({ budget: 500 });
|
|
72
|
-
// 只能容纳部分
|
|
73
|
-
expect(result.entriesIncluded).toBeLessThan(2);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('应该降级为摘要当完整条目超出预算', () => {
|
|
77
|
-
saveEntry({ id: 'big-1', title: 'Big Entry', content: 'x'.repeat(5000) });
|
|
78
|
-
// 单尺子口径(harness#197,query.estimateTokens 逐字符):查询取回条目约 1253 token,
|
|
79
|
-
// 完整格式化注入约 1275 token;预算 1260 够查询返回、不够注入完整内容
|
|
80
|
-
const result = injector.inject({ budget: 1260 });
|
|
81
|
-
expect(result.entriesIncluded).toBe(0);
|
|
82
|
-
expect(result.entriesSummarized).toBe(1);
|
|
83
|
-
expect(result.sources.some(s => s.id === 'knowledge-summary-big-1')).toBe(true);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('应该排除已注入的条目', () => {
|
|
87
|
-
saveEntry({ id: 'ex-1', title: 'Excluded' });
|
|
88
|
-
const result = injector.inject({ budget: 8000, exclude: ['ex-1'] });
|
|
89
|
-
expect(result.entriesExcluded).toBe(1);
|
|
90
|
-
expect(result.entriesIncluded).toBe(0);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('应该为已排除条目注入摘要', () => {
|
|
94
|
-
saveEntry({ id: 'ex-2', title: 'Excluded', content: 'Some long content here' });
|
|
95
|
-
const result = injector.inject({
|
|
96
|
-
budget: 8000,
|
|
97
|
-
exclude: ['ex-2'],
|
|
98
|
-
injectSummaryForExcluded: true,
|
|
99
|
-
});
|
|
100
|
-
expect(result.entriesSummarized).toBe(1);
|
|
101
|
-
expect(result.sources.some(s => s.id === 'knowledge-summary-ex-2')).toBe(true);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('应该不注入摘要当配置关闭', () => {
|
|
105
|
-
saveEntry({ id: 'ex-3', title: 'Excluded' });
|
|
106
|
-
const result = injector.inject({
|
|
107
|
-
budget: 8000,
|
|
108
|
-
exclude: ['ex-3'],
|
|
109
|
-
injectSummaryForExcluded: false,
|
|
110
|
-
});
|
|
111
|
-
expect(result.entriesSummarized).toBe(0);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
describe('formatEntry', () => {
|
|
116
|
-
it('应该格式化完整条目', () => {
|
|
117
|
-
saveEntry({ id: 'fmt-1', title: 'My Decision', type: 'decision', maturity: 'proven', tags: ['auth', 'api'] });
|
|
118
|
-
const entry = store.get('fmt-1')!;
|
|
119
|
-
const formatted = injector.formatEntry(entry);
|
|
120
|
-
expect(formatted).toContain('[DECISION]');
|
|
121
|
-
expect(formatted).toContain('My Decision');
|
|
122
|
-
expect(formatted).toContain('proven');
|
|
123
|
-
expect(formatted).toContain('auth, api');
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe('formatEntrySummary', () => {
|
|
128
|
-
it('应该生成一行摘要', () => {
|
|
129
|
-
saveEntry({ id: 'sum-1', title: 'Short', content: 'Brief content' });
|
|
130
|
-
const entry = store.get('sum-1')!;
|
|
131
|
-
const summary = injector.formatEntrySummary(entry);
|
|
132
|
-
expect(summary).toContain('[sum-1]');
|
|
133
|
-
expect(summary).toContain('Short');
|
|
134
|
-
expect(summary).toContain('verified');
|
|
135
|
-
expect(summary.split('\n').length).toBe(1);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('应该截断长内容', () => {
|
|
139
|
-
saveEntry({ id: 'sum-2', title: 'Long', content: 'x'.repeat(200) });
|
|
140
|
-
const entry = store.get('sum-2')!;
|
|
141
|
-
const summary = injector.formatEntrySummary(entry);
|
|
142
|
-
expect(summary).toContain('...');
|
|
143
|
-
expect(summary.length).toBeLessThan(200);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
describe('外部内容 retrieval marking(harness#161 三层防御第二层接线)', () => {
|
|
148
|
-
it('origin: external 条目注入时 prompt 带来源标记,metadata 含 origin', () => {
|
|
149
|
-
saveEntry({ id: 'ext-1', title: 'External Tip', origin: 'external' });
|
|
150
|
-
const result = injector.inject({ budget: 8000 });
|
|
151
|
-
expect(result.sources).toHaveLength(1);
|
|
152
|
-
expect(result.sources[0].content).toContain('[External Source — verify before acting]');
|
|
153
|
-
expect(result.sources[0].metadata).toMatchObject({ entryId: 'ext-1', origin: 'external' });
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('非 external 条目不带来源标记,metadata 仍带 origin', () => {
|
|
157
|
-
saveEntry({ id: 'int-1', title: 'Internal', origin: 'agent' });
|
|
158
|
-
const result = injector.inject({ budget: 8000 });
|
|
159
|
-
expect(result.sources).toHaveLength(1);
|
|
160
|
-
expect(result.sources[0].content).not.toContain('[External Source — verify before acting]');
|
|
161
|
-
expect(result.sources[0].metadata).toMatchObject({ origin: 'agent' });
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('external 条目的摘要注入同样带来源标记与 origin metadata', () => {
|
|
165
|
-
saveEntry({ id: 'ext-2', title: 'Ext', origin: 'external' });
|
|
166
|
-
const result = injector.inject({ budget: 8000, exclude: ['ext-2'] });
|
|
167
|
-
const summary = result.sources.find(s => s.id === 'knowledge-summary-ext-2');
|
|
168
|
-
expect(summary).toBeDefined();
|
|
169
|
-
expect(summary!.content).toContain('[External Source — verify before acting]');
|
|
170
|
-
expect(summary!.metadata).toMatchObject({ origin: 'external' });
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
describe('token 估算单尺子(harness#197)', () => {
|
|
175
|
-
it('完整注入路径 tokensUsed 等于 query.estimateTokens 对注入内容求和', () => {
|
|
176
|
-
saveEntry({ id: 'mix-1', title: '混合条目', content: '你好世界 hello world 混合内容 mixed content' });
|
|
177
|
-
const result = injector.inject({ budget: 8000 });
|
|
178
|
-
expect(result.sources).toHaveLength(1);
|
|
179
|
-
const expected = result.sources.reduce((sum, s) => sum + query.estimateTokens(s.content), 0);
|
|
180
|
-
expect(result.tokensUsed).toBe(expected);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('摘要注入路径 tokensUsed 同样按 query.estimateTokens 计量', () => {
|
|
184
|
-
saveEntry({ id: 'mix-2', title: '排除条目', content: '你好世界 mixed 内容' });
|
|
185
|
-
const result = injector.inject({ budget: 8000, exclude: ['mix-2'] });
|
|
186
|
-
expect(result.entriesSummarized).toBe(1);
|
|
187
|
-
const expected = result.sources.reduce((sum, s) => sum + query.estimateTokens(s.content), 0);
|
|
188
|
-
expect(result.tokensUsed).toBe(expected);
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
describe('getQuery', () => {
|
|
193
|
-
it('应该返回查询引擎', () => {
|
|
194
|
-
expect(injector.getQuery()).toBe(query);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
});
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 知识注入器
|
|
3
|
-
*
|
|
4
|
-
* 将知识条目转换为 ContextSource,供上层上下文组装消费
|
|
5
|
-
* 支持按阶段预算、类型过滤、去重
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { KnowledgeQuery, EXTERNAL_SOURCE_MARKER } from '../knowledge/query';
|
|
9
|
-
import type { KnowledgeEntry, KnowledgeSubsystem } from '../knowledge/types';
|
|
10
|
-
import type { ContextSource } from './types';
|
|
11
|
-
|
|
12
|
-
export interface InjectionConfig {
|
|
13
|
-
/** Token 预算(默认 800) */
|
|
14
|
-
budget: number;
|
|
15
|
-
/** 关注的知识类型 */
|
|
16
|
-
focusTypes?: KnowledgeSubsystem[];
|
|
17
|
-
/** 当前阶段 */
|
|
18
|
-
phase?: string;
|
|
19
|
-
/** 已注入的条目 ID(去重) */
|
|
20
|
-
exclude?: string[];
|
|
21
|
-
/** 是否注入摘要版本(已注入的条目) */
|
|
22
|
-
injectSummaryForExcluded?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface InjectionResult {
|
|
26
|
-
sources: ContextSource[];
|
|
27
|
-
tokensUsed: number;
|
|
28
|
-
entriesIncluded: number;
|
|
29
|
-
entriesExcluded: number;
|
|
30
|
-
entriesSummarized: number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class KnowledgeInjector {
|
|
34
|
-
private query: KnowledgeQuery;
|
|
35
|
-
|
|
36
|
-
constructor(query: KnowledgeQuery) {
|
|
37
|
-
this.query = query;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 注入知识到上下文
|
|
42
|
-
*/
|
|
43
|
-
inject(config: InjectionConfig): InjectionResult {
|
|
44
|
-
const {
|
|
45
|
-
budget,
|
|
46
|
-
focusTypes,
|
|
47
|
-
phase,
|
|
48
|
-
exclude = [],
|
|
49
|
-
injectSummaryForExcluded = true,
|
|
50
|
-
} = config;
|
|
51
|
-
|
|
52
|
-
// 查询知识
|
|
53
|
-
const queryResult = this.query.query({
|
|
54
|
-
phase: phase || 'default',
|
|
55
|
-
maxTokens: budget,
|
|
56
|
-
maxEntries: 20,
|
|
57
|
-
focusTypes: focusTypes || [],
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const sources: ContextSource[] = [];
|
|
61
|
-
let tokensUsed = 0;
|
|
62
|
-
let entriesIncluded = 0;
|
|
63
|
-
let entriesExcluded = 0;
|
|
64
|
-
let entriesSummarized = 0;
|
|
65
|
-
|
|
66
|
-
const excludeSet = new Set(exclude);
|
|
67
|
-
|
|
68
|
-
for (const entry of queryResult.entries) {
|
|
69
|
-
if (excludeSet.has(entry.id)) {
|
|
70
|
-
entriesExcluded++;
|
|
71
|
-
|
|
72
|
-
// 注入摘要版本
|
|
73
|
-
if (injectSummaryForExcluded) {
|
|
74
|
-
const summary = this.formatEntrySummary(entry);
|
|
75
|
-
const summaryTokens = this.query.estimateTokens(summary);
|
|
76
|
-
|
|
77
|
-
if (tokensUsed + summaryTokens <= budget) {
|
|
78
|
-
sources.push({
|
|
79
|
-
type: 'knowledge',
|
|
80
|
-
id: `knowledge-summary-${entry.id}`,
|
|
81
|
-
content: summary,
|
|
82
|
-
priority: 3,
|
|
83
|
-
metadata: { entryId: entry.id, isSummary: true, origin: entry.origin },
|
|
84
|
-
});
|
|
85
|
-
tokensUsed += summaryTokens;
|
|
86
|
-
entriesSummarized++;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// 注入完整版本
|
|
94
|
-
const formatted = this.formatEntry(entry);
|
|
95
|
-
const entryTokens = this.query.estimateTokens(formatted);
|
|
96
|
-
|
|
97
|
-
if (tokensUsed + entryTokens <= budget) {
|
|
98
|
-
sources.push({
|
|
99
|
-
type: 'knowledge',
|
|
100
|
-
id: `knowledge-${entry.id}`,
|
|
101
|
-
content: formatted,
|
|
102
|
-
priority: 3,
|
|
103
|
-
metadata: { entryId: entry.id, maturity: entry.maturity, origin: entry.origin },
|
|
104
|
-
});
|
|
105
|
-
tokensUsed += entryTokens;
|
|
106
|
-
entriesIncluded++;
|
|
107
|
-
} else {
|
|
108
|
-
// 预算不足,尝试注入摘要
|
|
109
|
-
const summary = this.formatEntrySummary(entry);
|
|
110
|
-
const summaryTokens = this.query.estimateTokens(summary);
|
|
111
|
-
|
|
112
|
-
if (tokensUsed + summaryTokens <= budget) {
|
|
113
|
-
sources.push({
|
|
114
|
-
type: 'knowledge',
|
|
115
|
-
id: `knowledge-summary-${entry.id}`,
|
|
116
|
-
content: summary,
|
|
117
|
-
priority: 3,
|
|
118
|
-
metadata: { entryId: entry.id, isSummary: true, origin: entry.origin },
|
|
119
|
-
});
|
|
120
|
-
tokensUsed += summaryTokens;
|
|
121
|
-
entriesSummarized++;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
sources,
|
|
128
|
-
tokensUsed,
|
|
129
|
-
entriesIncluded,
|
|
130
|
-
entriesExcluded,
|
|
131
|
-
entriesSummarized,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 将知识条目格式化为上下文内容。
|
|
137
|
-
* 外部来源条目带 EXTERNAL_SOURCE_MARKER 前缀(harness#161:
|
|
138
|
-
* 三层防御第二层 retrieval marking 的正本接线,标记唯一来源是 knowledge/query)。
|
|
139
|
-
*/
|
|
140
|
-
formatEntry(entry: KnowledgeEntry): string {
|
|
141
|
-
const parts: string[] = [];
|
|
142
|
-
|
|
143
|
-
if (entry.origin === 'external') {
|
|
144
|
-
parts.push(EXTERNAL_SOURCE_MARKER);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
parts.push(`## [${entry.type.toUpperCase()}] ${entry.title}`);
|
|
148
|
-
parts.push(`ID: ${entry.id} | 成熟度: ${entry.maturity} | 层级: ${entry.layer}`);
|
|
149
|
-
|
|
150
|
-
if (entry.tags.length > 0) {
|
|
151
|
-
parts.push(`标签: ${entry.tags.join(', ')}`);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
parts.push('');
|
|
155
|
-
parts.push(entry.content);
|
|
156
|
-
|
|
157
|
-
return parts.join('\n');
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* 将知识条目格式化为摘要(一行);外部来源条目同样带来源标记前缀
|
|
162
|
-
*/
|
|
163
|
-
formatEntrySummary(entry: KnowledgeEntry): string {
|
|
164
|
-
const prefix = entry.origin === 'external' ? `${EXTERNAL_SOURCE_MARKER} ` : '';
|
|
165
|
-
return `${prefix}[${entry.id}] ${entry.title} (${entry.maturity}) — ${entry.content.slice(0, 100)}${entry.content.length > 100 ? '...' : ''}`;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* 获取查询引擎
|
|
170
|
-
*/
|
|
171
|
-
getQuery(): KnowledgeQuery {
|
|
172
|
-
return this.query;
|
|
173
|
-
}
|
|
174
|
-
}
|
package/src/gates/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 门禁系统子路径入口(./gates)
|
|
3
|
-
*
|
|
4
|
-
* 公共面已随 #199(ADR-0038「CLI 可达 ≠ 导出理由」)整体收回:本层符号只被
|
|
5
|
-
* 本仓 CLI 经实现文件直引消费,双仓无编程消费者。入口本身保留(package.json
|
|
6
|
-
* exports 不动),是否摘除由 maintainer 裁决。
|
|
7
|
-
* 决策契约(deny 单调 / ask fail-closed / 决策浅冻结)正本见本目录 CONTEXT.md。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// 空面入口:保持模块身份(值面/类型面冻结闸与 tsc 以模块口径加载本文件)
|
|
11
|
-
export {};
|