@dommaker/harness 1.15.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 +28 -0
- package/bin/harness.js +6 -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 +10 -13
- 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/command.d.ts.map +1 -1
- package/dist/cli/commands/command.js +5 -5
- package/dist/cli/commands/command.js.map +1 -1
- package/dist/cli/commands/constraints-disable.d.ts +7 -11
- package/dist/cli/commands/constraints-disable.d.ts.map +1 -1
- package/dist/cli/commands/constraints-disable.js +8 -80
- package/dist/cli/commands/constraints-disable.js.map +1 -1
- package/dist/cli/commands/constraints-pack-proposal.d.ts +7 -20
- package/dist/cli/commands/constraints-pack-proposal.d.ts.map +1 -1
- package/dist/cli/commands/constraints-pack-proposal.js +21 -129
- package/dist/cli/commands/constraints-pack-proposal.js.map +1 -1
- package/dist/cli/commands/constraints-reactivate.d.ts +8 -20
- package/dist/cli/commands/constraints-reactivate.d.ts.map +1 -1
- package/dist/cli/commands/constraints-reactivate.js +11 -105
- package/dist/cli/commands/constraints-reactivate.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +11 -67
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +20 -196
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/constraints.d.ts +6 -9
- package/dist/cli/commands/constraints.d.ts.map +1 -1
- package/dist/cli/commands/constraints.js +7 -21
- package/dist/cli/commands/constraints.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/{tools/paths.js → cli/commands/init/git-hooks.js} +25 -12
- 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 +2 -2
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +15 -43
- 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/scaffold-templates.d.ts +7 -0
- package/dist/cli/commands/scaffold-templates.d.ts.map +1 -1
- package/dist/cli/commands/scaffold-templates.js +21 -1
- package/dist/cli/commands/scaffold-templates.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 +13 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +40 -29
- 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 -503
- 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 +6 -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/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +7 -0
- package/dist/cli/commands/validate.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/cli/gate-command.js +1 -1
- package/dist/cli/gate-command.js.map +1 -1
- package/dist/completion-checkers/glob-match.d.ts +1 -1
- package/dist/completion-checkers/glob-match.d.ts.map +1 -1
- package/dist/completion-checkers/glob-match.js +3 -38
- package/dist/completion-checkers/glob-match.js.map +1 -1
- package/dist/context/index.d.ts +2 -5
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +2 -9
- package/dist/context/index.js.map +1 -1
- package/dist/context/session-manager.d.ts +2 -8
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +31 -61
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +2 -26
- package/dist/context/types.d.ts.map +1 -1
- package/dist/core/config-files.d.ts +21 -0
- package/dist/core/config-files.d.ts.map +1 -0
- package/dist/core/config-files.js +75 -0
- package/dist/core/config-files.js.map +1 -0
- package/dist/core/constraint-lifecycle.d.ts +127 -0
- package/dist/core/constraint-lifecycle.d.ts.map +1 -0
- package/dist/core/constraint-lifecycle.js +306 -0
- package/dist/core/constraint-lifecycle.js.map +1 -0
- 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/checker.d.ts +9 -1
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +18 -0
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.d.ts +6 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.js +17 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.js.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts +0 -2
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js +0 -5
- package/dist/core/constraints/checkers/no-hardcoded-credentials.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 +2 -2
- package/dist/core/constraints/checkers/templated/file-exists.js.map +1 -1
- package/dist/core/constraints/checkers/templated/glob.d.ts +2 -3
- package/dist/core/constraints/checkers/templated/glob.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/glob.js +4 -40
- package/dist/core/constraints/checkers/templated/glob.js.map +1 -1
- package/dist/core/constraints/construction-sites.d.ts +56 -0
- package/dist/core/constraints/construction-sites.d.ts.map +1 -0
- package/dist/core/constraints/construction-sites.js +75 -0
- package/dist/core/constraints/construction-sites.js.map +1 -0
- 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 -221
- 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/index.d.ts +0 -2
- 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/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/constraints/meta.d.ts +18 -0
- package/dist/core/constraints/meta.d.ts.map +1 -0
- package/dist/core/constraints/meta.js +31 -0
- package/dist/core/constraints/meta.js.map +1 -0
- package/dist/core/constraints/pack-proposal.d.ts +66 -0
- package/dist/core/constraints/pack-proposal.d.ts.map +1 -0
- package/dist/core/constraints/pack-proposal.js +181 -0
- package/dist/core/constraints/pack-proposal.js.map +1 -0
- package/dist/core/constraints/usage-report.d.ts +3 -1
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +3 -1
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/effective-constraints.d.ts +6 -6
- package/dist/core/effective-constraints.d.ts.map +1 -1
- package/dist/core/effective-constraints.js +6 -6
- package/dist/core/effective-constraints.js.map +1 -1
- package/dist/core/index.d.ts +3 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -6
- package/dist/core/index.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 +49 -8
- 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/checker-gate.d.ts +2 -1
- package/dist/gates/checker-gate.d.ts.map +1 -1
- package/dist/gates/checker-gate.js +2 -1
- package/dist/gates/checker-gate.js.map +1 -1
- package/dist/gates/command.d.ts +3 -20
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +2 -35
- package/dist/gates/command.js.map +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/definitions.d.ts +1 -1
- package/dist/gates/definitions.d.ts.map +1 -1
- package/dist/gates/definitions.js +1 -1
- package/dist/gates/definitions.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 +7 -3
- 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 +12 -72
- 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 +23 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -65
- 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 +5 -5
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +4 -5
- 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 +2 -2
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js +19 -22
- 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/knowledge/token-estimate.d.ts +14 -0
- package/dist/knowledge/token-estimate.d.ts.map +1 -0
- package/dist/knowledge/token-estimate.js +31 -0
- package/dist/knowledge/token-estimate.js.map +1 -0
- package/dist/monitoring/analyzer-base.d.ts +0 -8
- package/dist/monitoring/analyzer-base.d.ts.map +1 -1
- package/dist/monitoring/analyzer-base.js +0 -20
- package/dist/monitoring/analyzer-base.js.map +1 -1
- package/dist/monitoring/index.d.ts +2 -7
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/index.js +2 -9
- package/dist/monitoring/index.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +2 -6
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +9 -16
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +14 -10
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +47 -49
- 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 +14 -21
- package/dist/pretool-use-hook.js.map +1 -1
- package/dist/release/integrity.d.ts.map +1 -1
- package/dist/release/integrity.js +8 -10
- 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/test-setup/jsonl-fake-fs.d.ts +1 -1
- package/dist/test-setup/jsonl-fake-fs.js +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/glob-match.d.ts +10 -0
- package/dist/utils/glob-match.d.ts.map +1 -0
- package/dist/utils/glob-match.js +47 -0
- package/dist/utils/glob-match.js.map +1 -0
- package/dist/utils/jsonl.d.ts +1 -1
- package/dist/utils/jsonl.js +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/dist/utils/yaml-edit.d.ts +26 -0
- package/dist/utils/yaml-edit.d.ts.map +1 -0
- package/dist/utils/yaml-edit.js +98 -0
- package/dist/utils/yaml-edit.js.map +1 -0
- package/package.json +2 -7
- package/src/CONTEXT.md +14 -6
- package/src/__tests__/acceptance-gate.test.ts +25 -55
- package/src/__tests__/contract-gate.test.ts +1 -1
- package/src/__tests__/effective-constraints.test.ts +16 -0
- 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 +3 -4
- package/src/__tests__/no-studio-references.test.ts +13 -5
- package/src/__tests__/pretool-use-hook.test.ts +3 -3
- package/src/__tests__/public-exports.test.ts +196 -42
- package/src/__tests__/public-type-surface.test.ts +22 -72
- package/src/__tests__/public-value-surface.test.ts +7 -38
- package/src/__tests__/skip-semantics.test.ts +5 -4
- package/src/__tests__/trace-analyzer-extra.test.ts +1 -13
- package/src/agents/CONTEXT.md +4 -4
- package/src/agents/lifecycle.ts +3 -5
- package/src/cli/__tests__/command-contract.test.ts +18 -0
- package/src/cli/__tests__/gate-command.test.ts +1 -1
- package/src/cli/command-contract.ts +12 -9
- package/src/cli/commands/CONTEXT.md +13 -13
- package/src/cli/commands/__tests__/check.test.ts +1 -1
- package/src/cli/commands/__tests__/command.test.ts +2 -2
- 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 +29 -19
- 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__/project-path-convention.test.ts +3 -35
- 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/__tests__/sync-docs-construction-sites.test.ts +175 -0
- package/src/cli/commands/__tests__/validate.test.ts +49 -0
- package/src/cli/commands/acceptance.ts +10 -9
- package/src/cli/commands/command.ts +2 -1
- package/src/cli/commands/constraints-disable.ts +8 -59
- package/src/cli/commands/constraints-pack-proposal.ts +26 -121
- package/src/cli/commands/constraints-reactivate.ts +22 -113
- package/src/cli/commands/constraints-retire.ts +32 -271
- package/src/cli/commands/constraints.ts +6 -30
- 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 +16 -11
- package/src/cli/commands/review.ts +5 -4
- package/src/cli/commands/scaffold-templates.ts +23 -0
- package/src/cli/commands/security.ts +11 -12
- package/src/cli/commands/spec-baseline-check.ts +6 -7
- package/src/cli/commands/status.ts +2 -2
- package/src/cli/commands/sync-docs/__tests__/construction-site-count.test.ts +49 -0
- 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 +52 -26
- package/src/cli/commands/sync-docs/gate.ts +78 -0
- package/src/cli/commands/sync-docs/index.ts +21 -549
- package/src/cli/commands/sync-docs/main-flow.ts +549 -0
- package/src/cli/commands/sync-docs/project-reader.ts +26 -24
- package/src/cli/commands/validate.ts +7 -0
- package/src/cli/gate-command.ts +2 -2
- package/src/completion-checkers/CONTEXT.md +3 -3
- package/src/completion-checkers/glob-match.ts +3 -35
- package/src/context/CONTEXT.md +7 -10
- package/src/context/__tests__/session-manager.test.ts +18 -7
- package/src/context/index.ts +1 -9
- package/src/context/session-manager.ts +34 -60
- package/src/context/types.ts +2 -22
- package/src/core/CONTEXT.md +10 -5
- package/src/core/__tests__/config-files.test.ts +88 -0
- package/src/core/__tests__/constraint-lifecycle.test.ts +255 -0
- package/src/core/__tests__/constraints-meta.test.ts +26 -0
- package/src/core/__tests__/pack-proposal.test.ts +95 -0
- package/src/core/config-files.ts +39 -0
- package/src/core/constraint-lifecycle.ts +435 -0
- package/src/core/constraints/__tests__/check-cache.test.ts +0 -7
- package/src/core/constraints/__tests__/collect-constraints.test.ts +25 -0
- package/src/core/constraints/__tests__/construction-sites.test.ts +147 -0
- package/src/core/constraints/__tests__/context-reconcile.test.ts +16 -16
- package/src/core/constraints/__tests__/trace-injection.test.ts +14 -15
- package/src/core/constraints/__tests__/usage-report.test.ts +9 -0
- package/src/core/constraints/capabilities-parser.ts +4 -6
- package/src/core/constraints/checker.ts +20 -1
- package/src/core/constraints/checkers/__tests__/no-completion-without-verification.test.ts +22 -3
- package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +56 -41
- package/src/core/constraints/checkers/no-completion-without-verification.ts +16 -1
- package/src/core/constraints/checkers/no-hardcoded-credentials.ts +0 -5
- package/src/core/constraints/checkers/templated/exec.ts +1 -0
- package/src/core/constraints/checkers/templated/file-exists.ts +2 -2
- package/src/core/constraints/checkers/templated/glob.ts +3 -36
- package/src/core/constraints/construction-sites.ts +95 -0
- 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 +221 -242
- package/src/core/constraints/git-evidence.ts +2 -0
- package/src/core/constraints/index.ts +0 -4
- package/src/core/constraints/injection-writer.ts +3 -6
- package/src/core/constraints/meta.ts +40 -0
- package/src/core/constraints/pack-proposal.ts +179 -0
- package/src/core/constraints/usage-report.ts +3 -1
- package/src/core/effective-constraints.ts +6 -6
- package/src/core/index.ts +0 -15
- 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__/command-success-output.test.ts +56 -0
- package/src/core/validators/__tests__/passes-gate-counts.test.ts +52 -0
- package/src/core/validators/check-handlers/command.ts +53 -10
- 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 +22 -14
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +22 -19
- package/src/gates/__tests__/acceptance.test.ts +72 -99
- package/src/gates/__tests__/command-single-predicate.test.ts +1 -1
- package/src/gates/__tests__/command.test.ts +24 -25
- package/src/gates/__tests__/decision.test.ts +35 -0
- 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/checker-gate.ts +2 -1
- package/src/gates/command.ts +4 -38
- package/src/gates/contract.ts +86 -79
- package/src/gates/definitions.ts +2 -2
- package/src/gates/performance.ts +35 -19
- package/src/gates/registry.ts +7 -4
- package/src/gates/review.ts +38 -10
- package/src/gates/security.ts +94 -81
- package/src/gates/types.ts +23 -77
- package/src/hooks/CONTEXT.md +1 -1
- package/src/index.ts +57 -98
- package/src/knowledge/CONTEXT.md +14 -10
- 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/__tests__/token-estimate.test.ts +54 -0
- 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 +5 -5
- package/src/knowledge/ingest.ts +27 -12
- package/src/knowledge/lifecycle.ts +17 -19
- package/src/knowledge/query.ts +20 -20
- package/src/knowledge/reference-tracker.ts +14 -16
- package/src/knowledge/store.ts +17 -32
- package/src/knowledge/token-estimate.ts +27 -0
- package/src/monitoring/CONTEXT.md +6 -8
- package/src/monitoring/__tests__/prune-trace-logs.test.ts +76 -0
- package/src/monitoring/__tests__/traces.test.ts +1 -17
- package/src/monitoring/analyzer-base.ts +0 -18
- package/src/monitoring/index.ts +2 -7
- package/src/monitoring/trace-analyzer.ts +12 -17
- package/src/monitoring/traces.ts +59 -57
- package/src/pretool-use-hook.ts +28 -23
- package/src/release/CONTEXT.md +2 -2
- package/src/release/__tests__/integrity.test.ts +3 -7
- package/src/release/integrity.ts +8 -11
- package/src/sdd/index-generator.ts +4 -0
- package/src/test-setup/jsonl-fake-fs.ts +1 -1
- 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__/glob-match.test.ts +52 -0
- package/src/utils/__tests__/jsonl-skip-disposition.test.ts +0 -1
- package/src/utils/__tests__/package-json.test.ts +58 -0
- package/src/utils/__tests__/package-version.test.ts +21 -2
- package/src/utils/__tests__/yaml-edit.test.ts +62 -0
- 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/glob-match.ts +41 -0
- package/src/utils/jsonl.ts +1 -1
- package/src/utils/package-json.ts +61 -0
- package/src/utils/package-version.ts +8 -10
- package/src/utils/yaml-edit.ts +67 -0
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/init.js +0 -517
- 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 -129
- package/dist/context/knowledge-injector.js.map +0 -1
- package/dist/context/token-budget.d.ts +0 -115
- package/dist/context/token-budget.d.ts.map +0 -1
- package/dist/context/token-budget.js +0 -200
- package/dist/context/token-budget.js.map +0 -1
- package/dist/gates/index.d.ts +0 -44
- package/dist/gates/index.d.ts.map +0 -1
- package/dist/gates/index.js +0 -85
- package/dist/gates/index.js.map +0 -1
- package/dist/gates/runner.d.ts +0 -30
- package/dist/gates/runner.d.ts.map +0 -1
- package/dist/gates/runner.js +0 -38
- package/dist/gates/runner.js.map +0 -1
- package/dist/knowledge/primitives/code-structure.d.ts +0 -37
- package/dist/knowledge/primitives/code-structure.d.ts.map +0 -1
- package/dist/knowledge/primitives/code-structure.js +0 -185
- package/dist/knowledge/primitives/code-structure.js.map +0 -1
- package/dist/monitoring/context-tracker.d.ts +0 -38
- package/dist/monitoring/context-tracker.d.ts.map +0 -1
- package/dist/monitoring/context-tracker.js +0 -153
- package/dist/monitoring/context-tracker.js.map +0 -1
- package/dist/tools/definitions/core/code/fingerprint.sh +0 -273
- package/dist/tools/definitions/core/code/fingerprint.yml +0 -72
- package/dist/tools/definitions/core/code/parse.yml +0 -68
- package/dist/tools/definitions/core/code/register-language.sh +0 -475
- package/dist/tools/definitions/core/code/register-language.yml +0 -74
- package/dist/tools/definitions/core/docker/build.yml +0 -73
- package/dist/tools/definitions/core/docker/run.yml +0 -81
- package/dist/tools/definitions/core/file/copy.yml +0 -88
- package/dist/tools/definitions/core/file/read.yml +0 -69
- package/dist/tools/definitions/core/file/write.yml +0 -75
- package/dist/tools/definitions/core/git/branch.yml +0 -61
- package/dist/tools/definitions/core/git/cleanup-worktree.yml +0 -50
- package/dist/tools/definitions/core/git/clone.yml +0 -69
- package/dist/tools/definitions/core/git/commit.yml +0 -65
- package/dist/tools/definitions/core/git/push.yml +0 -79
- package/dist/tools/definitions/core/git/worktree.yml +0 -96
- package/dist/tools/definitions/core/notification/notify.sh +0 -152
- package/dist/tools/definitions/core/notification/notify.yml +0 -59
- package/dist/tools/definitions/core/npm/build.yml +0 -75
- package/dist/tools/definitions/core/npm/install.yml +0 -58
- package/dist/tools/definitions/core/npm/test.yml +0 -75
- package/dist/tools/definitions/core/validation/check-reuse.yml +0 -170
- package/dist/tools/definitions/core/validation/validate-handlers.yml +0 -118
- package/dist/tools/definitions/core/validation/validate-readme-stats.yml +0 -155
- package/dist/tools/definitions/core/validation/validate-yaml-syntax.yml +0 -134
- package/dist/tools/definitions/ext/browser/browser-automate.sh +0 -255
- package/dist/tools/definitions/ext/browser/browser-automate.yml +0 -166
- package/dist/tools/definitions/ext/browser/browser-close.sh +0 -104
- package/dist/tools/definitions/ext/browser/browser-close.yml +0 -54
- package/dist/tools/definitions/ext/browser/browser-mcp-debug.sh +0 -682
- package/dist/tools/definitions/ext/browser/browser-mcp-debug.yml +0 -167
- package/dist/tools/definitions/ext/browser/browser-start.sh +0 -101
- package/dist/tools/definitions/ext/browser/browser-start.yml +0 -61
- package/dist/tools/definitions/registry.json +0 -795
- package/dist/tools/definitions/std/README.md +0 -350
- package/dist/tools/definitions/std/analysis/analyze-codebase.yml +0 -72
- package/dist/tools/definitions/std/analysis/analyze-diff.yml +0 -182
- package/dist/tools/definitions/std/analysis/analyze-git-diff.yml +0 -70
- package/dist/tools/definitions/std/analysis/analyze-impact.yml +0 -78
- package/dist/tools/definitions/std/analysis/analyze-requirements.yml +0 -105
- package/dist/tools/definitions/std/analysis/brainstorm-options.yml +0 -106
- package/dist/tools/definitions/std/analysis/build-graph.yml +0 -154
- package/dist/tools/definitions/std/analysis/clarify-requirements.yml +0 -90
- package/dist/tools/definitions/std/analysis/detect-context.yml +0 -109
- package/dist/tools/definitions/std/analysis/detect-layers.yml +0 -125
- package/dist/tools/definitions/std/analysis/generate-tour.yml +0 -102
- package/dist/tools/definitions/std/analysis/search-enhance.yml +0 -105
- package/dist/tools/definitions/std/backlog/add.yml +0 -51
- package/dist/tools/definitions/std/backlog/decide.yml +0 -39
- package/dist/tools/definitions/std/backlog/github-sync.yml +0 -161
- package/dist/tools/definitions/std/backlog/list.yml +0 -53
- package/dist/tools/definitions/std/backlog/load.yml +0 -46
- package/dist/tools/definitions/std/backlog/resolve.yml +0 -37
- package/dist/tools/definitions/std/backlog/update.yml +0 -42
- package/dist/tools/definitions/std/bugfix/diagnose.yml +0 -68
- package/dist/tools/definitions/std/bugfix/fix.yml +0 -66
- package/dist/tools/definitions/std/bugfix/verify.yml +0 -69
- package/dist/tools/definitions/std/constraint/check-decomposition.yml +0 -103
- package/dist/tools/definitions/std/constraint/check-feature-list.yml +0 -77
- package/dist/tools/definitions/std/constraint/check-progress.yml +0 -97
- package/dist/tools/definitions/std/constraint/generate-report.yml +0 -147
- package/dist/tools/definitions/std/deploy/commit-push.yml +0 -33
- package/dist/tools/definitions/std/deploy/deploy-backend.yml +0 -37
- package/dist/tools/definitions/std/deploy/deploy-frontend.yml +0 -37
- package/dist/tools/definitions/std/deploy/rollback.yml +0 -148
- package/dist/tools/definitions/std/design/analyze-architecture-impact.yml +0 -113
- package/dist/tools/definitions/std/design/design-api.yml +0 -55
- package/dist/tools/definitions/std/design/design-architecture.yml +0 -97
- package/dist/tools/definitions/std/design/design-db.yml +0 -81
- package/dist/tools/definitions/std/design/generate-spec.yml +0 -182
- package/dist/tools/definitions/std/development/develop-api.yml +0 -85
- package/dist/tools/definitions/std/development/develop-backend.yml +0 -88
- package/dist/tools/definitions/std/development/develop-frontend.yml +0 -87
- package/dist/tools/definitions/std/development/develop-shared-types.yml +0 -74
- package/dist/tools/definitions/std/development/develop-task.yml +0 -122
- package/dist/tools/definitions/std/development/develop-tests.yml +0 -76
- package/dist/tools/definitions/std/development/execute-batch.yml +0 -152
- package/dist/tools/definitions/std/development/fix-issues.yml +0 -100
- package/dist/tools/definitions/std/development/implement-task.yml +0 -124
- package/dist/tools/definitions/std/development/review-fix-cycle.yml +0 -232
- package/dist/tools/definitions/std/evolution/implement.yml +0 -124
- package/dist/tools/definitions/std/evolution/prioritize.yml +0 -111
- package/dist/tools/definitions/std/evolution/report-gap.yml +0 -165
- package/dist/tools/definitions/std/file/read.yml +0 -21
- package/dist/tools/definitions/std/governance/aggregate-opinions.sh +0 -201
- package/dist/tools/definitions/std/governance/aggregate-opinions.yml +0 -78
- package/dist/tools/definitions/std/governance/audit-task.yml +0 -177
- package/dist/tools/definitions/std/governance/cast-vote.yml +0 -128
- package/dist/tools/definitions/std/governance/collect-issues.yml +0 -16
- package/dist/tools/definitions/std/governance/create-signed-document.yml +0 -23
- package/dist/tools/definitions/std/governance/create-voting-session.yml +0 -100
- package/dist/tools/definitions/std/governance/define-stance.sh +0 -243
- package/dist/tools/definitions/std/governance/define-stance.yml +0 -81
- package/dist/tools/definitions/std/governance/generate-review-report.yml +0 -23
- package/dist/tools/definitions/std/governance/impeach.yml +0 -178
- package/dist/tools/definitions/std/governance/multi-stance-review.yml +0 -153
- package/dist/tools/definitions/std/governance/prepare-artifact.yml +0 -20
- package/dist/tools/definitions/std/governance/review-spec-approval.yml +0 -262
- package/dist/tools/definitions/std/governance/rollback.yml +0 -185
- package/dist/tools/definitions/std/governance/stance-review.yml +0 -148
- package/dist/tools/definitions/std/governance/track-effect.yml +0 -198
- package/dist/tools/definitions/std/governance/vote-tally.yml +0 -143
- package/dist/tools/definitions/std/patch/execute.yml +0 -51
- package/dist/tools/definitions/std/planning/generate-tasks.yml +0 -36
- package/dist/tools/definitions/std/planning/load-tasks.yml +0 -44
- package/dist/tools/definitions/std/planning/split-batch.yml +0 -480
- package/dist/tools/definitions/std/planning/split-tasks.yml +0 -358
- package/dist/tools/definitions/std/planning/update-tasks.yml +0 -51
- package/dist/tools/definitions/std/planning/validate-tasks.yml +0 -46
- package/dist/tools/definitions/std/project/decide-next-workflow.yml +0 -38
- package/dist/tools/definitions/std/project/load-state.yml +0 -31
- package/dist/tools/definitions/std/project/save-state.yml +0 -32
- package/dist/tools/definitions/std/quality/check-quality.yml +0 -241
- package/dist/tools/definitions/std/quality/debug-systematic.yml +0 -163
- package/dist/tools/definitions/std/quality/handle-feedback.yml +0 -108
- package/dist/tools/definitions/std/quality/review-code.yml +0 -128
- package/dist/tools/definitions/std/quality/review-spec.yml +0 -140
- package/dist/tools/definitions/std/quality/review-task.yml +0 -190
- package/dist/tools/definitions/std/quality/run-tests.yml +0 -80
- package/dist/tools/definitions/std/quick/analyze.yml +0 -56
- package/dist/tools/definitions/std/quick/implement.yml +0 -67
- package/dist/tools/definitions/std/quick/verify.yml +0 -71
- package/dist/tools/definitions/std/verification/verify_completion.yml +0 -113
- package/dist/tools/definitions/std/verification/wait-condition.yml +0 -107
- package/dist/tools/index.d.ts +0 -5
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -10
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/paths.d.ts +0 -9
- package/dist/tools/paths.d.ts.map +0 -1
- package/dist/tools/paths.js.map +0 -1
- package/src/__tests__/token-budget.test.ts +0 -252
- package/src/cli/commands/init.ts +0 -604
- package/src/cli/commands/knowledge.ts +0 -820
- package/src/context/__tests__/knowledge-injector.test.ts +0 -178
- package/src/context/__tests__/token-budget.test.ts +0 -258
- package/src/context/knowledge-injector.ts +0 -175
- package/src/context/token-budget.ts +0 -222
- package/src/gates/__tests__/runner.test.ts +0 -81
- package/src/gates/index.ts +0 -98
- package/src/gates/runner.ts +0 -57
- package/src/knowledge/primitives/__tests__/code-structure-degrade.test.ts +0 -24
- package/src/knowledge/primitives/__tests__/code-structure.test.ts +0 -120
- package/src/knowledge/primitives/code-structure.ts +0 -185
- package/src/monitoring/__tests__/context-tracker.test.ts +0 -180
- package/src/monitoring/context-tracker.ts +0 -136
- package/src/tools/CONTEXT.md +0 -24
- package/src/tools/__tests__/registry.test.ts +0 -221
- package/src/tools/definitions/core/code/fingerprint.sh +0 -273
- package/src/tools/definitions/core/code/fingerprint.yml +0 -72
- package/src/tools/definitions/core/code/parse.yml +0 -68
- package/src/tools/definitions/core/code/register-language.sh +0 -475
- package/src/tools/definitions/core/code/register-language.yml +0 -74
- package/src/tools/definitions/core/docker/build.yml +0 -73
- package/src/tools/definitions/core/docker/run.yml +0 -81
- package/src/tools/definitions/core/file/copy.yml +0 -88
- package/src/tools/definitions/core/file/read.yml +0 -69
- package/src/tools/definitions/core/file/write.yml +0 -75
- package/src/tools/definitions/core/git/branch.yml +0 -61
- package/src/tools/definitions/core/git/cleanup-worktree.yml +0 -50
- package/src/tools/definitions/core/git/clone.yml +0 -69
- package/src/tools/definitions/core/git/commit.yml +0 -65
- package/src/tools/definitions/core/git/push.yml +0 -79
- package/src/tools/definitions/core/git/worktree.yml +0 -96
- package/src/tools/definitions/core/notification/notify.sh +0 -152
- package/src/tools/definitions/core/notification/notify.yml +0 -59
- package/src/tools/definitions/core/npm/build.yml +0 -75
- package/src/tools/definitions/core/npm/install.yml +0 -58
- package/src/tools/definitions/core/npm/test.yml +0 -75
- package/src/tools/definitions/core/validation/check-reuse.yml +0 -170
- package/src/tools/definitions/core/validation/validate-handlers.yml +0 -118
- package/src/tools/definitions/core/validation/validate-readme-stats.yml +0 -155
- package/src/tools/definitions/core/validation/validate-yaml-syntax.yml +0 -134
- package/src/tools/definitions/ext/browser/browser-automate.sh +0 -255
- package/src/tools/definitions/ext/browser/browser-automate.yml +0 -166
- package/src/tools/definitions/ext/browser/browser-close.sh +0 -104
- package/src/tools/definitions/ext/browser/browser-close.yml +0 -54
- package/src/tools/definitions/ext/browser/browser-mcp-debug.sh +0 -682
- package/src/tools/definitions/ext/browser/browser-mcp-debug.yml +0 -167
- package/src/tools/definitions/ext/browser/browser-start.sh +0 -101
- package/src/tools/definitions/ext/browser/browser-start.yml +0 -61
- package/src/tools/definitions/registry.json +0 -795
- package/src/tools/definitions/std/README.md +0 -350
- package/src/tools/definitions/std/analysis/analyze-codebase.yml +0 -72
- package/src/tools/definitions/std/analysis/analyze-diff.yml +0 -182
- package/src/tools/definitions/std/analysis/analyze-git-diff.yml +0 -70
- package/src/tools/definitions/std/analysis/analyze-impact.yml +0 -78
- package/src/tools/definitions/std/analysis/analyze-requirements.yml +0 -105
- package/src/tools/definitions/std/analysis/brainstorm-options.yml +0 -106
- package/src/tools/definitions/std/analysis/build-graph.yml +0 -154
- package/src/tools/definitions/std/analysis/clarify-requirements.yml +0 -90
- package/src/tools/definitions/std/analysis/detect-context.yml +0 -109
- package/src/tools/definitions/std/analysis/detect-layers.yml +0 -125
- package/src/tools/definitions/std/analysis/generate-tour.yml +0 -102
- package/src/tools/definitions/std/analysis/search-enhance.yml +0 -105
- package/src/tools/definitions/std/backlog/add.yml +0 -51
- package/src/tools/definitions/std/backlog/decide.yml +0 -39
- package/src/tools/definitions/std/backlog/github-sync.yml +0 -161
- package/src/tools/definitions/std/backlog/list.yml +0 -53
- package/src/tools/definitions/std/backlog/load.yml +0 -46
- package/src/tools/definitions/std/backlog/resolve.yml +0 -37
- package/src/tools/definitions/std/backlog/update.yml +0 -42
- package/src/tools/definitions/std/bugfix/diagnose.yml +0 -68
- package/src/tools/definitions/std/bugfix/fix.yml +0 -66
- package/src/tools/definitions/std/bugfix/verify.yml +0 -69
- package/src/tools/definitions/std/constraint/check-decomposition.yml +0 -103
- package/src/tools/definitions/std/constraint/check-feature-list.yml +0 -77
- package/src/tools/definitions/std/constraint/check-progress.yml +0 -97
- package/src/tools/definitions/std/constraint/generate-report.yml +0 -147
- package/src/tools/definitions/std/deploy/commit-push.yml +0 -33
- package/src/tools/definitions/std/deploy/deploy-backend.yml +0 -37
- package/src/tools/definitions/std/deploy/deploy-frontend.yml +0 -37
- package/src/tools/definitions/std/deploy/rollback.yml +0 -148
- package/src/tools/definitions/std/design/analyze-architecture-impact.yml +0 -113
- package/src/tools/definitions/std/design/design-api.yml +0 -55
- package/src/tools/definitions/std/design/design-architecture.yml +0 -97
- package/src/tools/definitions/std/design/design-db.yml +0 -81
- package/src/tools/definitions/std/design/generate-spec.yml +0 -182
- package/src/tools/definitions/std/development/develop-api.yml +0 -85
- package/src/tools/definitions/std/development/develop-backend.yml +0 -88
- package/src/tools/definitions/std/development/develop-frontend.yml +0 -87
- package/src/tools/definitions/std/development/develop-shared-types.yml +0 -74
- package/src/tools/definitions/std/development/develop-task.yml +0 -122
- package/src/tools/definitions/std/development/develop-tests.yml +0 -76
- package/src/tools/definitions/std/development/execute-batch.yml +0 -152
- package/src/tools/definitions/std/development/fix-issues.yml +0 -100
- package/src/tools/definitions/std/development/implement-task.yml +0 -124
- package/src/tools/definitions/std/development/review-fix-cycle.yml +0 -232
- package/src/tools/definitions/std/evolution/implement.yml +0 -124
- package/src/tools/definitions/std/evolution/prioritize.yml +0 -111
- package/src/tools/definitions/std/evolution/report-gap.yml +0 -165
- package/src/tools/definitions/std/file/read.yml +0 -21
- package/src/tools/definitions/std/governance/aggregate-opinions.sh +0 -201
- package/src/tools/definitions/std/governance/aggregate-opinions.yml +0 -78
- package/src/tools/definitions/std/governance/audit-task.yml +0 -177
- package/src/tools/definitions/std/governance/cast-vote.yml +0 -128
- package/src/tools/definitions/std/governance/collect-issues.yml +0 -16
- package/src/tools/definitions/std/governance/create-signed-document.yml +0 -23
- package/src/tools/definitions/std/governance/create-voting-session.yml +0 -100
- package/src/tools/definitions/std/governance/define-stance.sh +0 -243
- package/src/tools/definitions/std/governance/define-stance.yml +0 -81
- package/src/tools/definitions/std/governance/generate-review-report.yml +0 -23
- package/src/tools/definitions/std/governance/impeach.yml +0 -178
- package/src/tools/definitions/std/governance/multi-stance-review.yml +0 -153
- package/src/tools/definitions/std/governance/prepare-artifact.yml +0 -20
- package/src/tools/definitions/std/governance/review-spec-approval.yml +0 -262
- package/src/tools/definitions/std/governance/rollback.yml +0 -185
- package/src/tools/definitions/std/governance/stance-review.yml +0 -148
- package/src/tools/definitions/std/governance/track-effect.yml +0 -198
- package/src/tools/definitions/std/governance/vote-tally.yml +0 -143
- package/src/tools/definitions/std/patch/execute.yml +0 -51
- package/src/tools/definitions/std/planning/generate-tasks.yml +0 -36
- package/src/tools/definitions/std/planning/load-tasks.yml +0 -44
- package/src/tools/definitions/std/planning/split-batch.yml +0 -480
- package/src/tools/definitions/std/planning/split-tasks.yml +0 -358
- package/src/tools/definitions/std/planning/update-tasks.yml +0 -51
- package/src/tools/definitions/std/planning/validate-tasks.yml +0 -46
- package/src/tools/definitions/std/project/decide-next-workflow.yml +0 -38
- package/src/tools/definitions/std/project/load-state.yml +0 -31
- package/src/tools/definitions/std/project/save-state.yml +0 -32
- package/src/tools/definitions/std/quality/check-quality.yml +0 -241
- package/src/tools/definitions/std/quality/debug-systematic.yml +0 -163
- package/src/tools/definitions/std/quality/handle-feedback.yml +0 -108
- package/src/tools/definitions/std/quality/review-code.yml +0 -128
- package/src/tools/definitions/std/quality/review-spec.yml +0 -140
- package/src/tools/definitions/std/quality/review-task.yml +0 -190
- package/src/tools/definitions/std/quality/run-tests.yml +0 -80
- package/src/tools/definitions/std/quick/analyze.yml +0 -56
- package/src/tools/definitions/std/quick/implement.yml +0 -67
- package/src/tools/definitions/std/quick/verify.yml +0 -71
- package/src/tools/definitions/std/verification/verify_completion.yml +0 -113
- package/src/tools/definitions/std/verification/wait-condition.yml +0 -107
- package/src/tools/index.ts +0 -5
- package/src/tools/paths.ts +0 -15
|
@@ -1,820 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* harness knowledge 命令
|
|
3
|
-
*
|
|
4
|
-
* 知识库管理 11 子操作(list/search/import/decay/stats/sync-rag/audit/snapshot/migrate/index/health)。
|
|
5
|
-
* 本文件只做「取数 + 声明两投影」:json 面正本在 `data`,人读排版在 `human()` 的
|
|
6
|
-
* display model。上色、label 映射、json/人读分派、退出码、路径解析与 store 构造
|
|
7
|
-
* 统一在 knowledge-view.ts(harness#133,架构评审候选4)。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import * as fs from 'fs';
|
|
11
|
-
import * as path from 'path';
|
|
12
|
-
import { KnowledgeQuery } from '../../knowledge/query';
|
|
13
|
-
import { KnowledgeLifecycle } from '../../knowledge/lifecycle';
|
|
14
|
-
import { ColdStartImporter } from '../../knowledge/import';
|
|
15
|
-
import { KnowledgeAudit } from '../../knowledge/audit';
|
|
16
|
-
import type { AuditReport, AuditRuleName, DimensionMetrics } from '../../knowledge/audit-scoring';
|
|
17
|
-
import { evaluateFlywheel } from '../../knowledge/flywheel-metrics';
|
|
18
|
-
import { migrateKnowledgeEntries } from '../../knowledge/migration';
|
|
19
|
-
import { KnowledgeIndexGenerator } from '../../knowledge/index-generator';
|
|
20
|
-
import type { KnowledgeEntry, KnowledgeSubsystem, MaturityChange, MaturityLevel, QueryFilter } from '../../knowledge/types';
|
|
21
|
-
import { logError, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
22
|
-
import { numericFlagMessage, parseNumericFlag } from '../../utils/numeric-flag';
|
|
23
|
-
import {
|
|
24
|
-
announce,
|
|
25
|
-
blankLine,
|
|
26
|
-
dimensionLabel,
|
|
27
|
-
emitKnowledgeView,
|
|
28
|
-
openKnowledgeStore,
|
|
29
|
-
resolveKnowledgeBaseDir,
|
|
30
|
-
ruleLabel,
|
|
31
|
-
toneForMaturity,
|
|
32
|
-
toneForScore,
|
|
33
|
-
toneForSeverity,
|
|
34
|
-
type DisplayModel,
|
|
35
|
-
type DisplayRow,
|
|
36
|
-
type DisplaySection,
|
|
37
|
-
type KnowledgeView,
|
|
38
|
-
} from './knowledge-view';
|
|
39
|
-
|
|
40
|
-
export interface KnowledgeOptions {
|
|
41
|
-
/** 项目路径 */
|
|
42
|
-
projectPath?: string;
|
|
43
|
-
/** 输出 JSON 格式 */
|
|
44
|
-
json?: boolean;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** 子操作共用的入参面:知识库目录覆盖(audit/snapshot/migrate/index/health 收) */
|
|
48
|
-
type KnowledgeDirOption = { dir?: string };
|
|
49
|
-
|
|
50
|
-
// ========================================
|
|
51
|
-
// list
|
|
52
|
-
// ========================================
|
|
53
|
-
|
|
54
|
-
function listFilter(options: KnowledgeListOptions): QueryFilter {
|
|
55
|
-
const filter: QueryFilter = { excludeArchived: false };
|
|
56
|
-
if (options.type) filter.types = options.type.split(',') as KnowledgeSubsystem[];
|
|
57
|
-
if (options.maturity) filter.maturity = options.maturity.split(',') as MaturityLevel[];
|
|
58
|
-
if (options.tag) filter.tags = options.tag.split(',');
|
|
59
|
-
return filter;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface KnowledgeListOptions extends KnowledgeOptions {
|
|
63
|
-
type?: string;
|
|
64
|
-
maturity?: string;
|
|
65
|
-
tag?: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function knowledgeListView(options: KnowledgeListOptions, io: CommandIO) {
|
|
69
|
-
const entries = openKnowledgeStore(options, io).list(listFilter(options));
|
|
70
|
-
const data = { total: entries.length, entries };
|
|
71
|
-
|
|
72
|
-
return { data, human: (): DisplayModel => ({ sections: [{ rows: listRows(entries) }] }) };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function listRows(entries: KnowledgeEntry[]): DisplayRow[] {
|
|
76
|
-
if (entries.length === 0) {
|
|
77
|
-
return [{ cells: [{ label: '知识库为空', tone: 'warn' }] }];
|
|
78
|
-
}
|
|
79
|
-
const rows: DisplayRow[] = [
|
|
80
|
-
{ cells: [
|
|
81
|
-
{ label: '📚 知识库 (', tone: 'heading' },
|
|
82
|
-
{ field: 'total', text: String(entries.length), tone: 'heading' },
|
|
83
|
-
{ label: ' 条)', tone: 'heading' },
|
|
84
|
-
] },
|
|
85
|
-
blankLine(),
|
|
86
|
-
];
|
|
87
|
-
entries.forEach((entry, i) => {
|
|
88
|
-
rows.push({ cells: [
|
|
89
|
-
{ field: `entries.${i}.maturity`, text: ` [${entry.maturity}]`, tone: toneForMaturity(entry.maturity) },
|
|
90
|
-
{ field: `entries.${i}.title`, text: ` ${entry.title}`, tone: 'emph' },
|
|
91
|
-
] });
|
|
92
|
-
rows.push({ cells: [
|
|
93
|
-
{ field: `entries.${i}.id`, text: ` id: ${entry.id}`, tone: 'muted' },
|
|
94
|
-
{ field: `entries.${i}.type`, text: ` | type: ${entry.type}`, tone: 'muted' },
|
|
95
|
-
{ field: `entries.${i}.layer`, text: ` | layer: ${entry.layer}`, tone: 'muted' },
|
|
96
|
-
] });
|
|
97
|
-
if (entry.tags.length > 0) {
|
|
98
|
-
rows.push({ cells: [{ field: `entries.${i}.tags`, text: ` tags: ${entry.tags.join(', ')}`, tone: 'muted' }] });
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
return rows;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export async function knowledgeList(options: KnowledgeListOptions, io: CommandIO = processIO): Promise<CommandResult> {
|
|
105
|
-
return emitKnowledgeView(io, options, knowledgeListView(options, io));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ========================================
|
|
109
|
-
// search
|
|
110
|
-
// ========================================
|
|
111
|
-
|
|
112
|
-
export function knowledgeSearchView(
|
|
113
|
-
query: string,
|
|
114
|
-
options: KnowledgeOptions & { limit?: number },
|
|
115
|
-
io: CommandIO,
|
|
116
|
-
) {
|
|
117
|
-
const store = openKnowledgeStore(options, io);
|
|
118
|
-
const matched = new KnowledgeQuery(store).search(query, { limit: options.limit ?? 20 });
|
|
119
|
-
const data = { query, total: matched.length, entries: matched };
|
|
120
|
-
|
|
121
|
-
return { data, human: (): DisplayModel => ({ sections: [{ rows: searchRows(query, matched) }] }) };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function searchRows(query: string, matched: KnowledgeEntry[]): DisplayRow[] {
|
|
125
|
-
if (matched.length === 0) {
|
|
126
|
-
return [{ cells: [{ label: `未找到匹配 "${query}" 的知识条目`, tone: 'warn' }] }];
|
|
127
|
-
}
|
|
128
|
-
const rows: DisplayRow[] = [
|
|
129
|
-
{ cells: [
|
|
130
|
-
{ label: '🔍 搜索 "', tone: 'heading' },
|
|
131
|
-
{ field: 'query', text: query, tone: 'heading' },
|
|
132
|
-
{ label: '" (', tone: 'heading' },
|
|
133
|
-
{ field: 'total', text: String(matched.length), tone: 'heading' },
|
|
134
|
-
{ label: ' 条结果)', tone: 'heading' },
|
|
135
|
-
] },
|
|
136
|
-
blankLine(),
|
|
137
|
-
];
|
|
138
|
-
matched.forEach((entry, i) => {
|
|
139
|
-
const preview = entry.content.slice(0, 100).replace(/\n/g, ' ') + (entry.content.length > 100 ? '...' : '');
|
|
140
|
-
rows.push({ cells: [
|
|
141
|
-
{ field: `entries.${i}.title`, text: ` ${entry.title}`, tone: 'emph' },
|
|
142
|
-
{ field: `entries.${i}.maturity`, text: ` [${entry.maturity}]`, tone: 'muted' },
|
|
143
|
-
] });
|
|
144
|
-
rows.push({ cells: [{ field: `entries.${i}.content`, text: ` ${preview}`, tone: 'muted' }] });
|
|
145
|
-
});
|
|
146
|
-
return rows;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export async function knowledgeSearch(
|
|
150
|
-
query: string,
|
|
151
|
-
options: KnowledgeOptions & { limit?: number },
|
|
152
|
-
io: CommandIO = processIO,
|
|
153
|
-
): Promise<CommandResult> {
|
|
154
|
-
return emitKnowledgeView(io, options, knowledgeSearchView(query, options, io));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* knowledge search 子命令入口(候选7):缺参闸门 + limit 装配窄化,
|
|
159
|
-
* 自 definitions.ts 的 args 复印块移回命令模块(interface/测试面所在)。
|
|
160
|
-
* `--limit` 给到的恒是字符串(缺省 '20' 也是),脏输入 fail-loud(harness#154,
|
|
161
|
-
* 原先 parseInt 出 NaN 被下游 `|| 20` 静默兜成缺省量)。
|
|
162
|
-
*/
|
|
163
|
-
export async function knowledgeSearchCommand(
|
|
164
|
-
positionals: (string | undefined)[],
|
|
165
|
-
options: Record<string, unknown>,
|
|
166
|
-
io: CommandIO = processIO,
|
|
167
|
-
): Promise<CommandResult> {
|
|
168
|
-
const query = positionals[0];
|
|
169
|
-
if (!query) {
|
|
170
|
-
logError(io, '请提供搜索关键词');
|
|
171
|
-
return { kind: 'usage-error', reason: 'knowledge search 缺少关键词位置参数' };
|
|
172
|
-
}
|
|
173
|
-
const limit = parseNumericFlag(options.limit as string | undefined, 'int');
|
|
174
|
-
if (!limit.ok) {
|
|
175
|
-
logError(io, numericFlagMessage('--limit', limit.raw, 'int'));
|
|
176
|
-
return { kind: 'usage-error', reason: `knowledge search --limit 非法限制: "${limit.raw}"` };
|
|
177
|
-
}
|
|
178
|
-
return knowledgeSearch(String(query), {
|
|
179
|
-
projectPath: options.projectPath as string | undefined,
|
|
180
|
-
json: options.json as boolean | undefined,
|
|
181
|
-
limit: limit.value,
|
|
182
|
-
}, io);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// ========================================
|
|
186
|
-
// import(冷启动)
|
|
187
|
-
// ========================================
|
|
188
|
-
|
|
189
|
-
export async function knowledgeImportView(
|
|
190
|
-
options: KnowledgeOptions & { sources?: string; reset?: boolean },
|
|
191
|
-
io: CommandIO,
|
|
192
|
-
) {
|
|
193
|
-
const projectPath = options.projectPath || process.cwd();
|
|
194
|
-
const store = openKnowledgeStore(options, io);
|
|
195
|
-
const sources = options.sources
|
|
196
|
-
? options.sources.split(',') as Array<'code' | 'git' | 'docs' | 'manual'>
|
|
197
|
-
: ['code', 'git', 'docs'] as Array<'code' | 'git' | 'docs'>;
|
|
198
|
-
|
|
199
|
-
const importer = new ColdStartImporter({ projectRoot: projectPath, store, sources });
|
|
200
|
-
|
|
201
|
-
if (options.reset) {
|
|
202
|
-
importer.resetState();
|
|
203
|
-
announce(io, options.json, '🔄 已重置导入状态', 'warn');
|
|
204
|
-
}
|
|
205
|
-
announce(io, options.json, `📥 开始导入知识 (源: ${sources.join(', ')})...`);
|
|
206
|
-
|
|
207
|
-
const results = await importer.importAll();
|
|
208
|
-
const data = {
|
|
209
|
-
totalImported: results.reduce((sum, r) => sum + r.entries.length, 0),
|
|
210
|
-
totalErrors: results.reduce((sum, r) => sum + r.errors.length, 0),
|
|
211
|
-
results,
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
return { data, human: (): DisplayModel => ({ sections: [{ rows: importRows(data) }] }) };
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
type ImportOutcome = Awaited<ReturnType<ColdStartImporter['importAll']>>;
|
|
218
|
-
|
|
219
|
-
function importRows(data: { totalImported: number; totalErrors: number; results: ImportOutcome }): DisplayRow[] {
|
|
220
|
-
const rows: DisplayRow[] = [];
|
|
221
|
-
data.results.forEach((result, i) => {
|
|
222
|
-
if (result.entries.length > 0) {
|
|
223
|
-
rows.push({ cells: [
|
|
224
|
-
{ field: `results.${i}.source.type`, text: ` ✅ ${result.source.type}: `, tone: 'ok' },
|
|
225
|
-
{ field: `results.${i}.entries.length`, text: `${result.entries.length} 条`, tone: 'ok' },
|
|
226
|
-
] });
|
|
227
|
-
}
|
|
228
|
-
result.errors.forEach((err, j) => {
|
|
229
|
-
rows.push({ cells: [
|
|
230
|
-
{ field: `results.${i}.source.type`, text: ` ❌ ${result.source.type}: `, tone: 'error' },
|
|
231
|
-
{ field: `results.${i}.errors.${j}.message`, text: err.message, tone: 'error' },
|
|
232
|
-
] });
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
rows.push(blankLine(), { cells: [
|
|
236
|
-
{ label: '✅ 导入完成: ', tone: 'ok' },
|
|
237
|
-
{ field: 'totalImported', text: String(data.totalImported), tone: 'ok' },
|
|
238
|
-
{ label: ' 条,', tone: 'ok' },
|
|
239
|
-
{ field: 'totalErrors', text: String(data.totalErrors), tone: 'ok' },
|
|
240
|
-
{ label: ' 个错误', tone: 'ok' },
|
|
241
|
-
] });
|
|
242
|
-
return rows;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export async function knowledgeImport(
|
|
246
|
-
options: KnowledgeOptions & { sources?: string; reset?: boolean },
|
|
247
|
-
io: CommandIO = processIO,
|
|
248
|
-
): Promise<CommandResult> {
|
|
249
|
-
return emitKnowledgeView(io, options, await knowledgeImportView(options, io));
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// ========================================
|
|
253
|
-
// decay
|
|
254
|
-
// ========================================
|
|
255
|
-
|
|
256
|
-
export function knowledgeDecayView(options: KnowledgeOptions, io: CommandIO) {
|
|
257
|
-
const lifecycle = new KnowledgeLifecycle(openKnowledgeStore(options, io));
|
|
258
|
-
announce(io, options.json, '🔄 运行衰减周期...');
|
|
259
|
-
const changes = lifecycle.runDecayCycle();
|
|
260
|
-
const data = { changes };
|
|
261
|
-
|
|
262
|
-
return { data, human: (): DisplayModel => ({ sections: [{ rows: decayRows(changes) }] }) };
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function decayRows(changes: MaturityChange[]): DisplayRow[] {
|
|
266
|
-
if (changes.length === 0) {
|
|
267
|
-
return [{ cells: [{ label: '✅ 没有需要衰减的知识条目', tone: 'ok' }] }];
|
|
268
|
-
}
|
|
269
|
-
const rows: DisplayRow[] = [
|
|
270
|
-
{ cells: [
|
|
271
|
-
{ label: '📉 ', tone: 'warn' },
|
|
272
|
-
{ field: 'changes.length', text: String(changes.length), tone: 'warn' },
|
|
273
|
-
{ label: ' 条知识发生衰减:', tone: 'warn' },
|
|
274
|
-
] },
|
|
275
|
-
blankLine(),
|
|
276
|
-
];
|
|
277
|
-
changes.forEach((change, i) => {
|
|
278
|
-
rows.push({ cells: [
|
|
279
|
-
{ field: `changes.${i}.entryId`, text: ` ${change.entryId}: ` },
|
|
280
|
-
{ field: `changes.${i}.from`, text: change.from, tone: 'error' },
|
|
281
|
-
{ label: ' → ' },
|
|
282
|
-
{ field: `changes.${i}.to`, text: change.to, tone: 'ok' },
|
|
283
|
-
] });
|
|
284
|
-
rows.push({ cells: [{ field: `changes.${i}.reason`, text: ` ${change.reason}`, tone: 'muted' }] });
|
|
285
|
-
});
|
|
286
|
-
return rows;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export async function knowledgeDecay(options: KnowledgeOptions, io: CommandIO = processIO): Promise<CommandResult> {
|
|
290
|
-
return emitKnowledgeView(io, options, knowledgeDecayView(options, io));
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// ========================================
|
|
294
|
-
// stats
|
|
295
|
-
// ========================================
|
|
296
|
-
|
|
297
|
-
export function knowledgeStatsView(options: KnowledgeOptions, io: CommandIO) {
|
|
298
|
-
const store = openKnowledgeStore(options, io);
|
|
299
|
-
const entries = store.list({ excludeArchived: false });
|
|
300
|
-
const active = entries.filter(e => e.maturity !== 'archived');
|
|
301
|
-
|
|
302
|
-
const byType: Record<string, number> = {};
|
|
303
|
-
const byMaturity: Record<string, number> = {};
|
|
304
|
-
const byLayer: Record<string, number> = {};
|
|
305
|
-
for (const entry of entries) {
|
|
306
|
-
byType[entry.type] = (byType[entry.type] || 0) + 1;
|
|
307
|
-
byMaturity[entry.maturity] = (byMaturity[entry.maturity] || 0) + 1;
|
|
308
|
-
byLayer[entry.layer] = (byLayer[entry.layer] || 0) + 1;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// 飞轮指标:计算唯一实现在 knowledge/flywheel-metrics,此处只做 fs 读取 + 展示层单位映射
|
|
312
|
-
let dailyConsumptionEvents = 0;
|
|
313
|
-
try {
|
|
314
|
-
const statsPath = path.join(store.getBaseDir(), '.consumption-stats.json');
|
|
315
|
-
if (fs.existsSync(statsPath)) {
|
|
316
|
-
const stats = JSON.parse(fs.readFileSync(statsPath, 'utf-8'));
|
|
317
|
-
dailyConsumptionEvents = stats.dailyEvents || 0;
|
|
318
|
-
}
|
|
319
|
-
} catch { /* best-effort */ }
|
|
320
|
-
|
|
321
|
-
const metrics = evaluateFlywheel({ entries: active, dailyConsumptionEvents });
|
|
322
|
-
const flywheel = {
|
|
323
|
-
refCoverage: Math.round(metrics.refCoverage * 100),
|
|
324
|
-
avgRefs: Math.round(metrics.avgRefs * 10) / 10,
|
|
325
|
-
consumptionHitRate: Math.round(metrics.consumptionHitRate * 100),
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
const data = { total: entries.length, byType, byMaturity, byLayer, flywheel };
|
|
329
|
-
const activeCount = active.length;
|
|
330
|
-
|
|
331
|
-
return {
|
|
332
|
-
data,
|
|
333
|
-
human: (): DisplayModel => ({
|
|
334
|
-
sections: [
|
|
335
|
-
{
|
|
336
|
-
rows: [
|
|
337
|
-
{ cells: [{ label: '📊 知识库统计', tone: 'heading' }] },
|
|
338
|
-
blankLine(),
|
|
339
|
-
{
|
|
340
|
-
cells: [
|
|
341
|
-
{ label: ' 总计: ', tone: 'emph' },
|
|
342
|
-
{ field: 'total', text: String(data.total), tone: 'emph' },
|
|
343
|
-
{ label: ' 条 (活跃: ', tone: 'emph' },
|
|
344
|
-
{ derived: 'activeCount', text: String(activeCount), tone: 'emph' },
|
|
345
|
-
{ label: ')', tone: 'emph' },
|
|
346
|
-
],
|
|
347
|
-
},
|
|
348
|
-
blankLine(),
|
|
349
|
-
],
|
|
350
|
-
},
|
|
351
|
-
{ title: ' 按类型:', rows: [...countRows('byType', byType), blankLine()] },
|
|
352
|
-
{
|
|
353
|
-
title: ' 按成熟度:',
|
|
354
|
-
rows: [...Object.entries(byMaturity).map(([maturity, count]) => ({
|
|
355
|
-
cells: [
|
|
356
|
-
{ field: `byMaturity.${maturity}`, text: ` ${maturity}`, tone: toneForMaturity(maturity as MaturityLevel) },
|
|
357
|
-
{ field: `byMaturity.${maturity}`, text: `: ${count}` },
|
|
358
|
-
],
|
|
359
|
-
})), blankLine()],
|
|
360
|
-
},
|
|
361
|
-
{ title: ' 按层级:', rows: [...countRows('byLayer', byLayer), blankLine()] },
|
|
362
|
-
{
|
|
363
|
-
title: ' 飞轮指标:',
|
|
364
|
-
rows: [
|
|
365
|
-
{ cells: [{ label: ' 引用覆盖: ' }, { field: 'flywheel.refCoverage', text: `${flywheel.refCoverage}%` }] },
|
|
366
|
-
{ cells: [{ label: ' 平均引用: ' }, { field: 'flywheel.avgRefs', text: String(flywheel.avgRefs) }] },
|
|
367
|
-
{ cells: [{ label: ' 消费命中率: ' }, { field: 'flywheel.consumptionHitRate', text: `${flywheel.consumptionHitRate}%` }] },
|
|
368
|
-
],
|
|
369
|
-
},
|
|
370
|
-
],
|
|
371
|
-
}),
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
function countRows(field: string, counts: Record<string, number>): DisplayRow[] {
|
|
376
|
-
return Object.entries(counts).map(([key, count]) => ({
|
|
377
|
-
cells: [
|
|
378
|
-
{ label: ' ' },
|
|
379
|
-
{ field: `${field}.${key}`, text: `${key}: ${count}` },
|
|
380
|
-
],
|
|
381
|
-
}));
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
export async function knowledgeStats(options: KnowledgeOptions, io: CommandIO = processIO): Promise<CommandResult> {
|
|
385
|
-
return emitKnowledgeView(io, options, knowledgeStatsView(options, io));
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// ========================================
|
|
389
|
-
// sync-rag
|
|
390
|
-
// ========================================
|
|
391
|
-
|
|
392
|
-
export function knowledgeSyncRagView(options: KnowledgeOptions) {
|
|
393
|
-
const projectPath = options.projectPath || process.cwd();
|
|
394
|
-
const docsDir = `${projectPath}/.harness/knowledge-docs`;
|
|
395
|
-
const docsPresent = fs.existsSync(docsDir);
|
|
396
|
-
const files = docsPresent ? fs.readdirSync(docsDir).filter(f => f.endsWith('.md')) : [];
|
|
397
|
-
const data = { directory: docsDir, files };
|
|
398
|
-
|
|
399
|
-
return { data, human: (): DisplayModel => ({ sections: [{ rows: syncRagRows(docsPresent, docsDir, files) }] }) };
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
function syncRagRows(docsPresent: boolean, docsDir: string, files: string[]): DisplayRow[] {
|
|
403
|
-
if (!docsPresent) return [{ cells: [{ label: 'No .harness/knowledge-docs/ directory', tone: 'warn' }] }];
|
|
404
|
-
if (files.length === 0) return [{ cells: [{ label: 'No knowledge docs found', tone: 'muted' }] }];
|
|
405
|
-
return [
|
|
406
|
-
{ cells: [
|
|
407
|
-
{ label: '📄 RAG sync candidates: ', tone: 'heading' },
|
|
408
|
-
{ field: 'files.length', text: String(files.length), tone: 'heading' },
|
|
409
|
-
{ label: ' files in ', tone: 'heading' },
|
|
410
|
-
{ field: 'directory', text: docsDir, tone: 'heading' },
|
|
411
|
-
] },
|
|
412
|
-
blankLine(),
|
|
413
|
-
...files.map((file, i) => ({ cells: [{ field: `files.${i}`, text: ` ${file}`, tone: 'accent' as const }] })),
|
|
414
|
-
blankLine(),
|
|
415
|
-
{ cells: [{ label: 'Run `mcp__local-rag__ingest_file` for each to sync to RAG', tone: 'muted' }] },
|
|
416
|
-
];
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
export async function knowledgeSyncRag(options: KnowledgeOptions, io: CommandIO = processIO): Promise<CommandResult> {
|
|
420
|
-
return emitKnowledgeView(io, options, knowledgeSyncRagView(options));
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
// ========================================
|
|
424
|
-
// audit(知识库质量审计)
|
|
425
|
-
// ========================================
|
|
426
|
-
|
|
427
|
-
export type KnowledgeAuditOptions = KnowledgeOptions & KnowledgeDirOption & {
|
|
428
|
-
fix?: boolean;
|
|
429
|
-
dryRun?: boolean;
|
|
430
|
-
/**
|
|
431
|
-
* `--threshold <n>` 的 commander 原值。旗帜给到的恒是字符串(缺省 '50' 也是),
|
|
432
|
-
* 声明跟着运行时走(harness#152);窄化在 `knowledgeAudit` 装配点做一次。
|
|
433
|
-
*/
|
|
434
|
-
threshold?: string;
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
/** `knowledgeAuditView` 的入参面:threshold 已过装配窄化,引擎槽位要的是数值 */
|
|
438
|
-
export type KnowledgeAuditViewOptions = Omit<KnowledgeAuditOptions, 'threshold'> & {
|
|
439
|
-
threshold?: number;
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
/** 阈值装配结果:`ok: false` = 脏输入,由命令入口 fail-loud(不得往判定槽塞 NaN) */
|
|
443
|
-
type ThresholdAssembly = { ok: true; value?: number } | { ok: false; raw: string };
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* `--threshold` 的装配点窄化(harness#152):非负整数字符串 → 数值,转不出来即脏输入。
|
|
447
|
-
* `undefined` = 未传,落引擎缺省(50);`'0'` 是显式零值,不当「未传」兜掉。
|
|
448
|
-
* 判定规则正本是 `parseNumericFlag`(harness#154 统一解析器),此处保留 #152 的
|
|
449
|
-
* 函数面与报错文案(冻结测试钉死),只做委派。
|
|
450
|
-
*/
|
|
451
|
-
function assembleShortContentThreshold(raw: string | undefined): ThresholdAssembly {
|
|
452
|
-
return parseNumericFlag(raw, 'int');
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
export function knowledgeAuditView(options: KnowledgeAuditViewOptions, io: CommandIO) {
|
|
456
|
-
const audit = new KnowledgeAudit(openKnowledgeStore(options, io), {
|
|
457
|
-
shortContentThreshold: options.threshold,
|
|
458
|
-
});
|
|
459
|
-
const isDryRun = options.dryRun && !options.fix;
|
|
460
|
-
if (!isDryRun) announce(io, options.json, '🔍 知识库质量审计...\n');
|
|
461
|
-
const report = audit.run({ autoFix: options.fix && !isDryRun });
|
|
462
|
-
const showFixHint = !options.fix && report.issues.length > 0;
|
|
463
|
-
|
|
464
|
-
return {
|
|
465
|
-
data: report,
|
|
466
|
-
human: (): DisplayModel => ({ sections: auditSections(report, showFixHint) }),
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
function auditSections(report: AuditReport, showFixHint: boolean): DisplaySection[] {
|
|
471
|
-
const sections: DisplaySection[] = [{
|
|
472
|
-
rows: [
|
|
473
|
-
{ cells: [{ label: ' 总条目: ', tone: 'emph' }, { field: 'totalEntries', text: String(report.totalEntries), tone: 'emph' }] },
|
|
474
|
-
{ cells: [{ label: ' 健康分: ', tone: 'emph' }, { field: 'healthScore.before', text: `${report.healthScore.before}/100`, tone: 'emph' }] },
|
|
475
|
-
],
|
|
476
|
-
}];
|
|
477
|
-
|
|
478
|
-
if (report.autoFixed > 0) {
|
|
479
|
-
sections[0].rows.push(
|
|
480
|
-
{ cells: [{ label: ' 自动修复: ', tone: 'ok' }, { field: 'autoFixed', text: String(report.autoFixed), tone: 'ok' }] },
|
|
481
|
-
{ cells: [{ label: ' 修复后: ', tone: 'emph' }, { field: 'healthScore.after', text: `${report.healthScore.after}/100`, tone: 'emph' }] },
|
|
482
|
-
);
|
|
483
|
-
}
|
|
484
|
-
sections[0].rows.push(blankLine());
|
|
485
|
-
|
|
486
|
-
const dimensions: DisplayRow[] = [];
|
|
487
|
-
for (const [key, dim] of Object.entries(report.dimensions) as Array<[keyof AuditReport['dimensions'], DimensionMetrics]>) {
|
|
488
|
-
dimensions.push({ cells: [
|
|
489
|
-
{ field: `dimensions.${key}`, text: ` ${dimensionLabel(key)}: ` },
|
|
490
|
-
{ field: `dimensions.${key}.score`, text: `${dim.score}/100`, tone: toneForScore(dim.score) },
|
|
491
|
-
{ field: `dimensions.${key}.issues`, text: ` (${dim.issues} 问题)` },
|
|
492
|
-
] });
|
|
493
|
-
}
|
|
494
|
-
dimensions.push(blankLine());
|
|
495
|
-
sections.push({ title: ' 维度评分:', rows: dimensions });
|
|
496
|
-
|
|
497
|
-
// 规则 label 正本在 audit.ts 的规则定义上(#109 编译期闭环经 ruleLabel 转发)
|
|
498
|
-
const rules: DisplayRow[] = [];
|
|
499
|
-
for (const [rule, count] of Object.entries(report.summary) as Array<[AuditRuleName, number]>) {
|
|
500
|
-
if (count === 0) continue;
|
|
501
|
-
rules.push({ cells: [{ field: `summary.${rule}`, text: ` ${ruleLabel(rule)}: ${count}`, tone: 'error' }] });
|
|
502
|
-
}
|
|
503
|
-
if (report.issues.length > 0) {
|
|
504
|
-
rules.push(blankLine()); // 「问题详情」标题前的空行(原排版是 `\n` 前缀)
|
|
505
|
-
}
|
|
506
|
-
sections.push({ rows: rules });
|
|
507
|
-
|
|
508
|
-
if (report.issues.length > 0) {
|
|
509
|
-
const issues: DisplayRow[] = [blankLine()];
|
|
510
|
-
for (const [i, issue] of report.issues.slice(0, 20).entries()) {
|
|
511
|
-
issues.push({ cells: [
|
|
512
|
-
{ field: `issues.${i}.severity`, text: ` [${issue.severity}]`, tone: toneForSeverity(issue.severity) },
|
|
513
|
-
{ field: `issues.${i}.entryId`, text: ` ${issue.entryId}: ` },
|
|
514
|
-
{ field: `issues.${i}.title`, text: issue.title },
|
|
515
|
-
] });
|
|
516
|
-
issues.push({ cells: [
|
|
517
|
-
{ field: `issues.${i}.detail`, text: ` ${issue.detail}`, tone: 'muted' },
|
|
518
|
-
{ label: ' → ' },
|
|
519
|
-
{ field: `issues.${i}.action`, text: issue.action },
|
|
520
|
-
] });
|
|
521
|
-
}
|
|
522
|
-
if (report.issues.length > 20) {
|
|
523
|
-
issues.push(blankLine(), { cells: [
|
|
524
|
-
{ label: ' ... 还有 ', tone: 'muted' },
|
|
525
|
-
{ field: 'issues.length', text: String(report.issues.length - 20), tone: 'muted' },
|
|
526
|
-
{ label: ' 条', tone: 'muted' },
|
|
527
|
-
] });
|
|
528
|
-
}
|
|
529
|
-
sections.push({ title: ' 问题详情 (前 20 条):', rows: issues });
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if (showFixHint) {
|
|
533
|
-
sections.push({ rows: [blankLine(), { cells: [{ label: ' 使用 --fix 自动修复', tone: 'warn' }] }] });
|
|
534
|
-
}
|
|
535
|
-
return sections;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
export async function knowledgeAudit(options: KnowledgeAuditOptions, io: CommandIO = processIO): Promise<CommandResult> {
|
|
539
|
-
const threshold = assembleShortContentThreshold(options.threshold);
|
|
540
|
-
if (!threshold.ok) {
|
|
541
|
-
logError(io, `错误:--threshold 需要非负整数阈值(字符数),收到 "${threshold.raw}";短内容判定未执行`);
|
|
542
|
-
return { kind: 'usage-error', reason: `knowledge audit --threshold 非法阈值: "${threshold.raw}"` };
|
|
543
|
-
}
|
|
544
|
-
const result = emitKnowledgeView(io, options, knowledgeAuditView({ ...options, threshold: threshold.value }, io));
|
|
545
|
-
// 审计可能改文件,人读路径收尾重建索引;--json 保持不写盘(现状冻结,#133 不动这条策略)
|
|
546
|
-
if (!options.json) {
|
|
547
|
-
new KnowledgeIndexGenerator(resolveKnowledgeBaseDir(options, io)).regenerate();
|
|
548
|
-
announce(io, options.json, ' 📇 索引已重建', 'muted');
|
|
549
|
-
}
|
|
550
|
-
return result;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
// ========================================
|
|
554
|
-
// snapshot(KR4 存活率追踪)
|
|
555
|
-
// ========================================
|
|
556
|
-
|
|
557
|
-
export function knowledgeSnapshotView(options: KnowledgeOptions & KnowledgeDirOption, io: CommandIO) {
|
|
558
|
-
const snapshotPath = openKnowledgeStore(options, io).snapshot();
|
|
559
|
-
const data = { snapshotPath };
|
|
560
|
-
|
|
561
|
-
return {
|
|
562
|
-
data,
|
|
563
|
-
human: (): DisplayModel => ({
|
|
564
|
-
sections: [{
|
|
565
|
-
rows: [{
|
|
566
|
-
cells: [
|
|
567
|
-
{ label: '✅ 快照已保存: ', tone: 'ok' },
|
|
568
|
-
{ field: 'snapshotPath', text: snapshotPath, tone: 'ok' },
|
|
569
|
-
],
|
|
570
|
-
}],
|
|
571
|
-
}],
|
|
572
|
-
}),
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
export function knowledgeSnapshot(options: KnowledgeOptions & KnowledgeDirOption, io: CommandIO = processIO): CommandResult {
|
|
577
|
-
return emitKnowledgeView(io, options, knowledgeSnapshotView(options, io));
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// ========================================
|
|
581
|
-
// migrate(为现有条目补 AS-021 新字段)
|
|
582
|
-
// ========================================
|
|
583
|
-
|
|
584
|
-
/** migrateKnowledgeEntries 的返回面 = migrate 的 json 正本(该类型未从 knowledge/migration 导出,此处同构声明) */
|
|
585
|
-
type MigrateResult = { total: number; migrated: number; skipped: number; errors: string[] };
|
|
586
|
-
|
|
587
|
-
export function knowledgeMigrateView(options: KnowledgeOptions & KnowledgeDirOption, io: CommandIO): KnowledgeView<MigrateResult> {
|
|
588
|
-
const result = migrateKnowledgeEntries(resolveKnowledgeBaseDir(options, io));
|
|
589
|
-
|
|
590
|
-
return {
|
|
591
|
-
data: result,
|
|
592
|
-
human: (): DisplayModel => ({ sections: [{ rows: migrateRows(result) }] }),
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
function migrateRows(result: MigrateResult): DisplayRow[] {
|
|
597
|
-
const rows: DisplayRow[] = [
|
|
598
|
-
{ cells: [{ label: '🔄 迁移知识条目(添加 consumptionMode/origin 字段)', tone: 'heading' }] },
|
|
599
|
-
blankLine(),
|
|
600
|
-
{ cells: [{ label: ' 总计: ', tone: 'ok' }, { field: 'total', text: String(result.total), tone: 'ok' }, { label: ' 条', tone: 'ok' }] },
|
|
601
|
-
{ cells: [{ label: ' 已迁移: ', tone: 'ok' }, { field: 'migrated', text: String(result.migrated), tone: 'ok' }, { label: ' 条', tone: 'ok' }] },
|
|
602
|
-
{ cells: [{ label: ' 已跳过: ', tone: 'muted' }, { field: 'skipped', text: String(result.skipped), tone: 'muted' }, { label: ' 条', tone: 'muted' }] },
|
|
603
|
-
];
|
|
604
|
-
if (result.errors.length > 0) {
|
|
605
|
-
rows.push(
|
|
606
|
-
blankLine(),
|
|
607
|
-
{ cells: [{ label: ' 错误: ', tone: 'error' }, { field: 'errors.length', text: String(result.errors.length), tone: 'error' }, { label: ' 条', tone: 'error' }] },
|
|
608
|
-
);
|
|
609
|
-
result.errors.slice(0, 5).forEach((err, i) => {
|
|
610
|
-
rows.push({ cells: [{ label: ' ' }, { field: `errors.${i}`, text: err, tone: 'error' }] });
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
// 两种收尾语各自带一个前导空行;migrated=0 且有错误时历史上两句都不打
|
|
614
|
-
if (result.migrated === 0 && result.errors.length === 0) {
|
|
615
|
-
rows.push(blankLine(), { cells: [{ label: '✅ 所有条目已是最新,无需迁移', tone: 'ok' }] });
|
|
616
|
-
} else if (result.migrated > 0) {
|
|
617
|
-
rows.push(blankLine(), { cells: [{ label: '✅ 迁移完成', tone: 'ok' }] });
|
|
618
|
-
}
|
|
619
|
-
return rows;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
export function knowledgeMigrate(options: KnowledgeOptions & KnowledgeDirOption, io: CommandIO = processIO): CommandResult {
|
|
623
|
-
return emitKnowledgeView(io, options, knowledgeMigrateView(options, io));
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// ========================================
|
|
627
|
-
// index(重建 _index.md 供 Agent grep,并同步 index.json)
|
|
628
|
-
// ========================================
|
|
629
|
-
|
|
630
|
-
export function knowledgeIndexView(options: KnowledgeOptions & KnowledgeDirOption, io: CommandIO) {
|
|
631
|
-
const baseDir = resolveKnowledgeBaseDir(options, io);
|
|
632
|
-
const indexPath = path.join(baseDir, '_index.md');
|
|
633
|
-
const beforeSize = fs.existsSync(indexPath) ? fs.statSync(indexPath).size : 0;
|
|
634
|
-
|
|
635
|
-
const output = new KnowledgeIndexGenerator(baseDir).regenerate();
|
|
636
|
-
// Sync index.json from disk files (removes ghost entries from manual mv/rm)
|
|
637
|
-
openKnowledgeStore({ dir: baseDir }, io).rebuildIndex();
|
|
638
|
-
|
|
639
|
-
const afterSize = Buffer.byteLength(output, 'utf-8');
|
|
640
|
-
const lineCount = output.split('\n').filter(l => !l.startsWith('#')).length;
|
|
641
|
-
const data = { path: indexPath, entries: lineCount, size: afterSize, previousSize: beforeSize };
|
|
642
|
-
|
|
643
|
-
return {
|
|
644
|
-
data,
|
|
645
|
-
human: (): DisplayModel => ({ sections: [{ rows: indexRows({ indexPath, afterSize, lineCount, beforeSize }) }] }),
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
function indexRows(shape: { indexPath: string; afterSize: number; lineCount: number; beforeSize: number }): DisplayRow[] {
|
|
650
|
-
const rows: DisplayRow[] = [
|
|
651
|
-
{ cells: [{ label: '📇 索引已重建', tone: 'heading' }] },
|
|
652
|
-
{ cells: [{ label: ' 路径: ', tone: 'muted' }, { field: 'path', text: shape.indexPath, tone: 'muted' }] },
|
|
653
|
-
{ cells: [{ label: ' 条目: ', tone: 'ok' }, { field: 'entries', text: String(shape.lineCount), tone: 'ok' }] },
|
|
654
|
-
{ cells: [{ label: ' 大小: ', tone: 'ok' }, { field: 'size', text: `${(shape.afterSize / 1024).toFixed(1)} KB`, tone: 'ok' }] },
|
|
655
|
-
];
|
|
656
|
-
if (shape.beforeSize > 0) {
|
|
657
|
-
rows.push({ cells: [{ label: ' 旧大小: ', tone: 'muted' }, { field: 'previousSize', text: `${(shape.beforeSize / 1024).toFixed(1)} KB`, tone: 'muted' }] });
|
|
658
|
-
}
|
|
659
|
-
return rows;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
export function knowledgeIndex(options: KnowledgeOptions & KnowledgeDirOption, io: CommandIO = processIO): CommandResult {
|
|
663
|
-
return emitKnowledgeView(io, options, knowledgeIndexView(options, io));
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
// ========================================
|
|
667
|
-
// health(飞轮健康检查 — 零 token 检测数据流状态)
|
|
668
|
-
// ========================================
|
|
669
|
-
|
|
670
|
-
interface HealthIssue {
|
|
671
|
-
severity: 'error' | 'warn' | 'info';
|
|
672
|
-
entry: string;
|
|
673
|
-
detail: string;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
/** health 的 json 面正本(字段清单冻结在 __tests__/knowledge-view.test.ts) */
|
|
677
|
-
interface HealthData {
|
|
678
|
-
healthScore: number;
|
|
679
|
-
summary: {
|
|
680
|
-
total: number;
|
|
681
|
-
lowRefEntries: number;
|
|
682
|
-
staleEntries: number;
|
|
683
|
-
consumptionData: boolean;
|
|
684
|
-
refCoverage: number;
|
|
685
|
-
avgRefs: number;
|
|
686
|
-
};
|
|
687
|
-
issues: HealthIssue[];
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
export function knowledgeHealthView(options: KnowledgeOptions & KnowledgeDirOption, io: CommandIO) {
|
|
691
|
-
const store = openKnowledgeStore(options, io);
|
|
692
|
-
const baseDir = store.getBaseDir();
|
|
693
|
-
const entries = store.list({ excludeArchived: true });
|
|
694
|
-
|
|
695
|
-
const issues: HealthIssue[] = [];
|
|
696
|
-
|
|
697
|
-
// D1: 引用密度检查(低引用 = 可能孤立)
|
|
698
|
-
let lowRefEntries = 0;
|
|
699
|
-
for (const entry of entries) {
|
|
700
|
-
if (entry.referencedBy.length === 0 && entry.maturity === 'verified') {
|
|
701
|
-
lowRefEntries++;
|
|
702
|
-
issues.push({ severity: 'info', entry: entry.id, detail: `verified 条目零引用(可能孤立)` });
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
// D2: 新鲜度检查
|
|
707
|
-
const now = Date.now();
|
|
708
|
-
const staleThreshold = 90 * 24 * 60 * 60 * 1000; // 90 days
|
|
709
|
-
let staleEntries = 0;
|
|
710
|
-
for (const entry of entries) {
|
|
711
|
-
const created = new Date(entry.created).getTime();
|
|
712
|
-
if (now - created > staleThreshold && entry.maturity === 'draft') {
|
|
713
|
-
staleEntries++;
|
|
714
|
-
issues.push({ severity: 'warn', entry: entry.id, detail: `draft 超过 90 天未推进` });
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
// D3: 消费数据检查
|
|
719
|
-
const statsPath = path.join(baseDir, '.consumption-stats.json');
|
|
720
|
-
const consumptionData = fs.existsSync(statsPath);
|
|
721
|
-
if (!consumptionData) {
|
|
722
|
-
issues.push({ severity: 'info', entry: '-', detail: `消费追踪数据不存在(${statsPath})` });
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
// D4: 飞轮指标(计算唯一实现在 knowledge/flywheel-metrics;人口为本命令的 excludeArchived 切片)
|
|
726
|
-
const metrics = evaluateFlywheel({ entries });
|
|
727
|
-
const refCoverage = Math.round(metrics.refCoverage * 100);
|
|
728
|
-
const avgRefs = Math.round(metrics.avgRefs * 10) / 10;
|
|
729
|
-
|
|
730
|
-
const totalIssues = issues.filter(i => i.severity === 'error').length * 3
|
|
731
|
-
+ issues.filter(i => i.severity === 'warn').length * 1;
|
|
732
|
-
const healthScore = Math.max(0, 100 - totalIssues);
|
|
733
|
-
|
|
734
|
-
const data: HealthData = {
|
|
735
|
-
healthScore,
|
|
736
|
-
summary: { total: entries.length, lowRefEntries, staleEntries, consumptionData, refCoverage, avgRefs },
|
|
737
|
-
issues: issues.slice(0, 50),
|
|
738
|
-
};
|
|
739
|
-
|
|
740
|
-
return { data, human: (): DisplayModel => ({ sections: healthSections(data) }) };
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
function healthSections(data: HealthData): DisplaySection[] {
|
|
744
|
-
const { healthScore, summary, issues } = data;
|
|
745
|
-
const scoreTone = toneForScore(healthScore);
|
|
746
|
-
return [
|
|
747
|
-
{
|
|
748
|
-
rows: [
|
|
749
|
-
{ cells: [{ label: '🏥 飞轮健康检查', tone: 'heading' }] },
|
|
750
|
-
blankLine(),
|
|
751
|
-
{ cells: [
|
|
752
|
-
{ label: ' 健康分: ', tone: 'emph' },
|
|
753
|
-
{ field: 'healthScore', text: String(healthScore), tone: scoreTone },
|
|
754
|
-
{ label: '/100', tone: 'emph' },
|
|
755
|
-
] },
|
|
756
|
-
{ cells: [
|
|
757
|
-
{ label: ' 活跃条目: ', tone: 'emph' },
|
|
758
|
-
{ field: 'summary.total', text: String(summary.total), tone: 'emph' },
|
|
759
|
-
] },
|
|
760
|
-
blankLine(),
|
|
761
|
-
],
|
|
762
|
-
},
|
|
763
|
-
{
|
|
764
|
-
title: ' 数据流状态:',
|
|
765
|
-
rows: [
|
|
766
|
-
densityRow(' 引用密度: ', 'summary.lowRefEntries', summary.lowRefEntries, ' 个零引用 verified'),
|
|
767
|
-
densityRow(' 新鲜度: ', 'summary.staleEntries', summary.staleEntries, ' 个过期 draft'),
|
|
768
|
-
{ cells: [
|
|
769
|
-
{ label: ' 消费追踪: ' },
|
|
770
|
-
summary.consumptionData
|
|
771
|
-
? { label: '✓', tone: 'ok' }
|
|
772
|
-
: { field: 'summary.consumptionData', text: '○ 未启用', tone: 'muted' },
|
|
773
|
-
] },
|
|
774
|
-
blankLine(),
|
|
775
|
-
],
|
|
776
|
-
},
|
|
777
|
-
{
|
|
778
|
-
title: ' 飞轮指标:',
|
|
779
|
-
rows: [
|
|
780
|
-
{ cells: [{ label: ' 引用覆盖: ' }, { field: 'summary.refCoverage', text: `${summary.refCoverage}%` }] },
|
|
781
|
-
{ cells: [{ label: ' 平均引用: ' }, { field: 'summary.avgRefs', text: String(summary.avgRefs) }] },
|
|
782
|
-
blankLine(),
|
|
783
|
-
],
|
|
784
|
-
},
|
|
785
|
-
{
|
|
786
|
-
title: ' 问题 (前 20):',
|
|
787
|
-
rows: issues.length === 0
|
|
788
|
-
? [{ cells: [{ label: ' ✓ 无问题', tone: 'ok' }] }]
|
|
789
|
-
: [
|
|
790
|
-
...issues.slice(0, 20).map((issue, i) => ({
|
|
791
|
-
cells: [
|
|
792
|
-
{ field: `issues.${i}.severity`, text: ` [${issue.severity}]`, tone: toneForSeverity(issue.severity) },
|
|
793
|
-
{ field: `issues.${i}.entry`, text: ` ${issue.entry}: ` },
|
|
794
|
-
{ field: `issues.${i}.detail`, text: issue.detail },
|
|
795
|
-
],
|
|
796
|
-
})),
|
|
797
|
-
// 溢出计数取全量数组,而 json 面的 issues 已截 50 条 → 无字段可锚,登记派生量
|
|
798
|
-
...(issues.length > 20
|
|
799
|
-
? [{ cells: [{ derived: 'healthIssuesOverflow', text: ` ... 还有 ${issues.length - 20} 条`, tone: 'muted' as const }] }]
|
|
800
|
-
: []),
|
|
801
|
-
],
|
|
802
|
-
},
|
|
803
|
-
];
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
function densityRow(prefix: string, field: string, count: number, suffix: string): DisplayRow {
|
|
807
|
-
if (count === 0) return { cells: [{ label: prefix }, { label: '✓', tone: 'ok' }] };
|
|
808
|
-
return {
|
|
809
|
-
cells: [
|
|
810
|
-
{ label: prefix },
|
|
811
|
-
{ label: '⚠ ', tone: 'warn' },
|
|
812
|
-
{ field, text: String(count), tone: 'warn' },
|
|
813
|
-
{ label: suffix, tone: 'warn' },
|
|
814
|
-
],
|
|
815
|
-
};
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
export async function knowledgeHealth(options: KnowledgeOptions & KnowledgeDirOption, io: CommandIO = processIO): Promise<CommandResult> {
|
|
819
|
-
return emitKnowledgeView(io, options, knowledgeHealthView(options, io));
|
|
820
|
-
}
|