@dommaker/harness 1.16.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/agents/lifecycle.d.ts.map +1 -1
- package/dist/agents/lifecycle.js +3 -6
- package/dist/agents/lifecycle.js.map +1 -1
- package/dist/cli/command-contract.d.ts +6 -9
- package/dist/cli/command-contract.d.ts.map +1 -1
- package/dist/cli/command-contract.js +6 -0
- package/dist/cli/command-contract.js.map +1 -1
- package/dist/cli/commands/acceptance.d.ts.map +1 -1
- package/dist/cli/commands/acceptance.js +8 -7
- package/dist/cli/commands/acceptance.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +2 -1
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/contract.d.ts.map +1 -1
- package/dist/cli/commands/contract.js +20 -10
- package/dist/cli/commands/contract.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +13 -12
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/init/ci-platform.d.ts +35 -0
- package/dist/cli/commands/init/ci-platform.d.ts.map +1 -0
- package/dist/cli/commands/init/ci-platform.js +59 -0
- package/dist/cli/commands/init/ci-platform.js.map +1 -0
- package/dist/cli/commands/init/ci-wiring.d.ts +20 -0
- package/dist/cli/commands/init/ci-wiring.d.ts.map +1 -0
- package/dist/cli/commands/init/ci-wiring.js +72 -0
- package/dist/cli/commands/init/ci-wiring.js.map +1 -0
- package/dist/cli/commands/init/git-hooks.d.ts +15 -0
- package/dist/cli/commands/init/git-hooks.d.ts.map +1 -0
- package/dist/cli/commands/init/git-hooks.js +64 -0
- package/dist/cli/commands/init/git-hooks.js.map +1 -0
- package/dist/cli/commands/init/governance.d.ts +14 -0
- package/dist/cli/commands/init/governance.d.ts.map +1 -0
- package/dist/cli/commands/init/governance.js +132 -0
- package/dist/cli/commands/init/governance.js.map +1 -0
- package/dist/cli/commands/{init.d.ts → init/index.d.ts} +13 -14
- package/dist/cli/commands/init/index.d.ts.map +1 -0
- package/dist/cli/commands/init/index.js +148 -0
- package/dist/cli/commands/init/index.js.map +1 -0
- package/dist/cli/commands/init/output-style.d.ts +19 -0
- package/dist/cli/commands/init/output-style.d.ts.map +1 -0
- package/dist/cli/commands/init/output-style.js +110 -0
- package/dist/cli/commands/init/output-style.js.map +1 -0
- package/dist/cli/commands/init/presets.d.ts +26 -0
- package/dist/cli/commands/init/presets.d.ts.map +1 -0
- package/dist/cli/commands/init/presets.js +104 -0
- package/dist/cli/commands/init/presets.js.map +1 -0
- package/dist/cli/commands/init/snippets.d.ts +18 -0
- package/dist/cli/commands/init/snippets.d.ts.map +1 -0
- package/dist/cli/commands/init/snippets.js +49 -0
- package/dist/cli/commands/init/snippets.js.map +1 -0
- package/dist/cli/commands/knowledge/audit.d.ts +30 -0
- package/dist/cli/commands/knowledge/audit.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/audit.js +114 -0
- package/dist/cli/commands/knowledge/audit.js.map +1 -0
- package/dist/cli/commands/knowledge/decay.d.ts +19 -0
- package/dist/cli/commands/knowledge/decay.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/decay.js +48 -0
- package/dist/cli/commands/knowledge/decay.js.map +1 -0
- package/dist/cli/commands/knowledge/health.d.ts +36 -0
- package/dist/cli/commands/knowledge/health.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/health.js +172 -0
- package/dist/cli/commands/knowledge/health.js.map +1 -0
- package/dist/cli/commands/knowledge/import.d.ts +26 -0
- package/dist/cli/commands/knowledge/import.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/import.js +63 -0
- package/dist/cli/commands/knowledge/import.js.map +1 -0
- package/dist/cli/commands/knowledge/index.d.ts +25 -0
- package/dist/cli/commands/knowledge/index.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/index.js +84 -0
- package/dist/cli/commands/knowledge/index.js.map +1 -0
- package/dist/cli/commands/knowledge/list.d.ts +25 -0
- package/dist/cli/commands/knowledge/list.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/list.js +60 -0
- package/dist/cli/commands/knowledge/list.js.map +1 -0
- package/dist/cli/commands/knowledge/migrate.d.ts +21 -0
- package/dist/cli/commands/knowledge/migrate.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/migrate.js +48 -0
- package/dist/cli/commands/knowledge/migrate.js.map +1 -0
- package/dist/cli/commands/knowledge/search.d.ts +32 -0
- package/dist/cli/commands/knowledge/search.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/search.js +73 -0
- package/dist/cli/commands/knowledge/search.js.map +1 -0
- package/dist/cli/commands/knowledge/shared.d.ts +14 -0
- package/dist/cli/commands/knowledge/shared.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/shared.js +6 -0
- package/dist/cli/commands/knowledge/shared.js.map +1 -0
- package/dist/cli/commands/knowledge/snapshot.d.ts +18 -0
- package/dist/cli/commands/knowledge/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/snapshot.js +34 -0
- package/dist/cli/commands/knowledge/snapshot.js.map +1 -0
- package/dist/cli/commands/knowledge/stats.d.ts +26 -0
- package/dist/cli/commands/knowledge/stats.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/stats.js +132 -0
- package/dist/cli/commands/knowledge/stats.js.map +1 -0
- package/dist/cli/commands/knowledge/sync-rag.d.ts +19 -0
- package/dist/cli/commands/knowledge/sync-rag.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/sync-rag.js +77 -0
- package/dist/cli/commands/knowledge/sync-rag.js.map +1 -0
- package/dist/cli/commands/knowledge-view.d.ts +2 -1
- package/dist/cli/commands/knowledge-view.d.ts.map +1 -1
- package/dist/cli/commands/knowledge-view.js +2 -2
- package/dist/cli/commands/knowledge-view.js.map +1 -1
- package/dist/cli/commands/passes-gate.d.ts.map +1 -1
- package/dist/cli/commands/passes-gate.js +12 -2
- package/dist/cli/commands/passes-gate.js.map +1 -1
- package/dist/cli/commands/performance.js.map +1 -1
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +13 -41
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/review.d.ts.map +1 -1
- package/dist/cli/commands/review.js +3 -2
- package/dist/cli/commands/review.js.map +1 -1
- package/dist/cli/commands/security.d.ts.map +1 -1
- package/dist/cli/commands/security.js +7 -8
- package/dist/cli/commands/security.js.map +1 -1
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +6 -5
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.js +31 -55
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +18 -12
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/compact.d.ts +9 -0
- package/dist/cli/commands/sync-docs/compact.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/compact.js +73 -0
- package/dist/cli/commands/sync-docs/compact.js.map +1 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +17 -36
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/gate.d.ts +27 -0
- package/dist/cli/commands/sync-docs/gate.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/gate.js +72 -0
- package/dist/cli/commands/sync-docs/gate.js.map +1 -0
- package/dist/cli/commands/sync-docs/index.d.ts +13 -27
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +19 -529
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/main-flow.d.ts +37 -0
- package/dist/cli/commands/sync-docs/main-flow.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/main-flow.js +485 -0
- package/dist/cli/commands/sync-docs/main-flow.js.map +1 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js +16 -25
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/gate-command.d.ts +1 -1
- package/dist/cli/gate-command.d.ts.map +1 -1
- package/dist/context/index.d.ts +1 -3
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +2 -5
- package/dist/context/index.js.map +1 -1
- package/dist/context/session-manager.d.ts +2 -2
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +31 -52
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +2 -2
- package/dist/context/types.d.ts.map +1 -1
- package/dist/core/constraint-lifecycle.d.ts +1 -1
- package/dist/core/constraint-lifecycle.d.ts.map +1 -1
- package/dist/core/constraint-lifecycle.js +1 -1
- package/dist/core/constraint-lifecycle.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +2 -1
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +4 -6
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.js +1 -0
- package/dist/core/constraints/checkers/templated/exec.js.map +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +13 -34
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
- package/dist/core/constraints/definitions/guidelines.js +18 -0
- package/dist/core/constraints/definitions/guidelines.js.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.js +0 -16
- package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +192 -223
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/git-evidence.d.ts.map +1 -1
- package/dist/core/constraints/git-evidence.js +2 -0
- package/dist/core/constraints/git-evidence.js.map +1 -1
- package/dist/core/constraints/injection-writer.d.ts +1 -0
- package/dist/core/constraints/injection-writer.d.ts.map +1 -1
- package/dist/core/constraints/injection-writer.js +3 -6
- package/dist/core/constraints/injection-writer.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +3 -1
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +6 -6
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/spec/validator.d.ts +1 -1
- package/dist/core/spec/validator.d.ts.map +1 -1
- package/dist/core/spec/validator.js +41 -36
- package/dist/core/spec/validator.js.map +1 -1
- package/dist/core/validators/check-handlers/command.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/command.js +7 -4
- package/dist/core/validators/check-handlers/command.js.map +1 -1
- package/dist/core/validators/check-handlers/http.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/http.js +6 -4
- package/dist/core/validators/check-handlers/http.js.map +1 -1
- package/dist/core/validators/check-handlers/output.d.ts +1 -1
- package/dist/core/validators/check-handlers/output.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/output.js +2 -1
- package/dist/core/validators/check-handlers/output.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +2 -1
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +25 -30
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/gates/acceptance.d.ts +37 -18
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +129 -97
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/command.d.ts +1 -1
- package/dist/gates/contract.d.ts +11 -2
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +57 -62
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/performance.d.ts +1 -1
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +18 -8
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/registry.d.ts.map +1 -1
- package/dist/gates/registry.js +6 -2
- package/dist/gates/registry.js.map +1 -1
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +16 -2
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/security.d.ts +5 -1
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +57 -63
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +11 -78
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/gates/types.js +5 -1
- package/dist/gates/types.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit-dimensions.d.ts +45 -0
- package/dist/knowledge/audit-dimensions.d.ts.map +1 -0
- package/dist/knowledge/audit-dimensions.js +144 -0
- package/dist/knowledge/audit-dimensions.js.map +1 -0
- package/dist/knowledge/audit-rules.d.ts +41 -0
- package/dist/knowledge/audit-rules.d.ts.map +1 -0
- package/dist/knowledge/audit-rules.js +269 -0
- package/dist/knowledge/audit-rules.js.map +1 -0
- package/dist/knowledge/audit-scoring.d.ts +6 -60
- package/dist/knowledge/audit-scoring.d.ts.map +1 -1
- package/dist/knowledge/audit-scoring.js +8 -391
- package/dist/knowledge/audit-scoring.js.map +1 -1
- package/dist/knowledge/audit.d.ts +6 -3
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/audit.js +9 -6
- package/dist/knowledge/audit.js.map +1 -1
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/import.js +5 -4
- package/dist/knowledge/import.js.map +1 -1
- package/dist/knowledge/index-generator.d.ts +2 -0
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +43 -50
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/index.d.ts +4 -2
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +2 -1
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/ingest.d.ts +21 -5
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +12 -9
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lifecycle.d.ts.map +1 -1
- package/dist/knowledge/lifecycle.js +17 -22
- package/dist/knowledge/lifecycle.js.map +1 -1
- package/dist/knowledge/query.d.ts +1 -1
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js +7 -7
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/reference-tracker.d.ts.map +1 -1
- package/dist/knowledge/reference-tracker.js +14 -17
- package/dist/knowledge/reference-tracker.js.map +1 -1
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +17 -36
- package/dist/knowledge/store.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +2 -2
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +9 -7
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +6 -4
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/pretool-use-hook.d.ts +1 -1
- package/dist/pretool-use-hook.d.ts.map +1 -1
- package/dist/pretool-use-hook.js +12 -19
- package/dist/pretool-use-hook.js.map +1 -1
- package/dist/release/integrity.d.ts.map +1 -1
- package/dist/release/integrity.js +8 -8
- package/dist/release/integrity.js.map +1 -1
- package/dist/sdd/index-generator.d.ts.map +1 -1
- package/dist/sdd/index-generator.js +4 -0
- package/dist/sdd/index-generator.js.map +1 -1
- package/dist/types/checkpoint.d.ts +8 -8
- package/dist/types/checkpoint.d.ts.map +1 -1
- package/dist/types/command-io.d.ts +19 -0
- package/dist/types/command-io.d.ts.map +1 -0
- package/dist/types/command-io.js +3 -0
- package/dist/types/command-io.js.map +1 -0
- package/dist/types/gate.d.ts +72 -0
- package/dist/types/gate.d.ts.map +1 -0
- package/dist/types/gate.js +13 -0
- package/dist/types/gate.js.map +1 -0
- package/dist/utils/attempt.d.ts +22 -0
- package/dist/utils/attempt.d.ts.map +1 -0
- package/dist/utils/attempt.js +40 -0
- package/dist/utils/attempt.js.map +1 -0
- package/dist/utils/detect-source-roots.d.ts.map +1 -1
- package/dist/utils/detect-source-roots.js +42 -51
- package/dist/utils/detect-source-roots.js.map +1 -1
- package/dist/utils/file-walk.d.ts +2 -1
- package/dist/utils/file-walk.d.ts.map +1 -1
- package/dist/utils/file-walk.js +3 -8
- package/dist/utils/file-walk.js.map +1 -1
- package/dist/utils/package-json.d.ts +49 -0
- package/dist/utils/package-json.d.ts.map +1 -0
- package/dist/utils/package-json.js +78 -0
- package/dist/utils/package-json.js.map +1 -0
- package/dist/utils/package-version.d.ts +5 -2
- package/dist/utils/package-version.d.ts.map +1 -1
- package/dist/utils/package-version.js +8 -11
- package/dist/utils/package-version.js.map +1 -1
- package/package.json +1 -6
- package/src/CONTEXT.md +5 -4
- package/src/__tests__/acceptance-gate.test.ts +23 -51
- package/src/__tests__/contract-gate.test.ts +1 -1
- package/src/__tests__/install-precommit-hook.test.ts +61 -0
- package/src/__tests__/iron-laws.test.ts +5 -5
- package/src/__tests__/layering.test.ts +1 -1
- package/src/__tests__/public-exports.test.ts +1 -1
- package/src/__tests__/public-type-surface.test.ts +9 -19
- package/src/__tests__/public-value-surface.test.ts +9 -17
- package/src/__tests__/skip-semantics.test.ts +5 -4
- package/src/agents/lifecycle.ts +3 -5
- package/src/cli/__tests__/command-contract.test.ts +18 -0
- package/src/cli/command-contract.ts +8 -5
- package/src/cli/commands/CONTEXT.md +10 -10
- package/src/cli/commands/__tests__/check.test.ts +1 -1
- package/src/cli/commands/__tests__/constraints-retire.test.ts +5 -3
- package/src/cli/commands/__tests__/init-governance-io.test.ts +7 -2
- package/src/cli/commands/__tests__/init.test.ts +1 -1
- package/src/cli/commands/__tests__/knowledge-audit-threshold.test.ts +14 -8
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +2 -1
- package/src/cli/commands/__tests__/knowledge-view.test.ts +28 -18
- package/src/cli/commands/__tests__/knowledge.test.ts +6 -2
- package/src/cli/commands/__tests__/numeric-flag-assembly.test.ts +1 -1
- package/src/cli/commands/__tests__/passes-gate.test.ts +100 -24
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +3 -6
- package/src/cli/commands/__tests__/registry.test.ts +3 -2
- package/src/cli/commands/__tests__/release.test.ts +24 -2
- package/src/cli/commands/__tests__/report-false-green.test.ts +10 -6
- package/src/cli/commands/acceptance.ts +10 -9
- package/src/cli/commands/command.ts +1 -1
- package/src/cli/commands/constraints-retire.ts +3 -2
- package/src/cli/commands/contract.ts +29 -14
- package/src/cli/commands/definitions.ts +13 -12
- package/src/cli/commands/init/ci-platform.ts +66 -0
- package/src/cli/commands/init/ci-wiring.ts +48 -0
- package/src/cli/commands/init/git-hooks.ts +31 -0
- package/src/cli/commands/init/governance.ts +127 -0
- package/src/cli/commands/init/index.ts +156 -0
- package/src/cli/commands/init/output-style.ts +82 -0
- package/src/cli/commands/init/presets.ts +105 -0
- package/src/cli/commands/init/snippets.ts +57 -0
- package/src/cli/commands/knowledge/audit.ts +155 -0
- package/src/cli/commands/knowledge/decay.ts +57 -0
- package/src/cli/commands/knowledge/health.ts +176 -0
- package/src/cli/commands/knowledge/import.ts +82 -0
- package/src/cli/commands/knowledge/index.ts +60 -0
- package/src/cli/commands/knowledge/list.ts +73 -0
- package/src/cli/commands/knowledge/migrate.ts +61 -0
- package/src/cli/commands/knowledge/search.ts +93 -0
- package/src/cli/commands/knowledge/shared.ts +13 -0
- package/src/cli/commands/knowledge/snapshot.ts +38 -0
- package/src/cli/commands/knowledge/stats.ts +112 -0
- package/src/cli/commands/knowledge/sync-rag.ts +48 -0
- package/src/cli/commands/knowledge-view.ts +3 -2
- package/src/cli/commands/passes-gate.ts +14 -2
- package/src/cli/commands/performance.ts +2 -2
- package/src/cli/commands/release.ts +14 -9
- package/src/cli/commands/review.ts +5 -4
- package/src/cli/commands/security.ts +10 -11
- package/src/cli/commands/spec-baseline-check.ts +6 -7
- package/src/cli/commands/status.ts +2 -2
- package/src/cli/commands/sync-docs/agents-syncer.ts +28 -47
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +18 -11
- package/src/cli/commands/sync-docs/compact.ts +35 -0
- package/src/cli/commands/sync-docs/context-syncer.ts +15 -31
- package/src/cli/commands/sync-docs/gate.ts +78 -0
- package/src/cli/commands/sync-docs/index.ts +21 -585
- package/src/cli/commands/sync-docs/main-flow.ts +549 -0
- package/src/cli/commands/sync-docs/project-reader.ts +21 -24
- package/src/cli/gate-command.ts +1 -1
- package/src/context/CONTEXT.md +4 -4
- package/src/context/__tests__/session-manager.test.ts +18 -0
- package/src/context/index.ts +1 -5
- package/src/context/session-manager.ts +34 -50
- package/src/context/types.ts +2 -2
- package/src/core/CONTEXT.md +2 -2
- package/src/core/constraint-lifecycle.ts +2 -2
- package/src/core/constraints/capabilities-parser.ts +4 -6
- package/src/core/constraints/checkers/templated/exec.ts +1 -0
- package/src/core/constraints/checkers/templated/file-exists.ts +1 -1
- package/src/core/constraints/context-builder.ts +11 -28
- package/src/core/constraints/definitions/guidelines.ts +19 -0
- package/src/core/constraints/definitions/iron-laws.ts +0 -17
- package/src/core/constraints/doc-freshness/runner.ts +220 -244
- package/src/core/constraints/git-evidence.ts +2 -0
- package/src/core/constraints/injection-writer.ts +3 -6
- package/src/core/project-config-loader.ts +6 -5
- package/src/core/spec/__tests__/validator.test.ts +65 -13
- package/src/core/spec/validator.ts +50 -40
- package/src/core/validators/__tests__/passes-gate-counts.test.ts +52 -0
- package/src/core/validators/check-handlers/command.ts +9 -6
- package/src/core/validators/check-handlers/http.ts +8 -6
- package/src/core/validators/check-handlers/output.ts +7 -6
- package/src/core/validators/passes-gate.ts +31 -32
- package/src/gates/CONTEXT.md +7 -6
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +16 -14
- package/src/gates/__tests__/acceptance.test.ts +69 -94
- package/src/gates/__tests__/command-single-predicate.test.ts +1 -1
- package/src/gates/__tests__/command.test.ts +23 -12
- package/src/gates/__tests__/gate-interface.test.ts +2 -5
- package/src/gates/__tests__/performance.test.ts +3 -3
- package/src/gates/__tests__/security.test.ts +7 -19
- package/src/gates/acceptance.ts +176 -131
- package/src/gates/command.ts +1 -1
- package/src/gates/contract.ts +86 -79
- package/src/gates/performance.ts +35 -19
- package/src/gates/registry.ts +6 -3
- package/src/gates/review.ts +38 -10
- package/src/gates/security.ts +94 -81
- package/src/gates/types.ts +22 -84
- package/src/index.ts +8 -4
- package/src/knowledge/CONTEXT.md +9 -7
- package/src/knowledge/__tests__/audit-labels.test.ts +3 -3
- package/src/knowledge/__tests__/audit-scoring.test.ts +9 -7
- package/src/knowledge/__tests__/ingest.test.ts +17 -17
- package/src/knowledge/__tests__/store.test.ts +4 -6
- package/src/knowledge/audit-dimensions.ts +190 -0
- package/src/knowledge/audit-rules.ts +335 -0
- package/src/knowledge/audit-scoring.ts +7 -495
- package/src/knowledge/audit.ts +9 -11
- package/src/knowledge/import.ts +7 -6
- package/src/knowledge/index-generator.ts +48 -53
- package/src/knowledge/index.ts +4 -2
- package/src/knowledge/ingest.ts +27 -12
- package/src/knowledge/lifecycle.ts +17 -19
- package/src/knowledge/query.ts +7 -6
- package/src/knowledge/reference-tracker.ts +14 -16
- package/src/knowledge/store.ts +17 -32
- package/src/monitoring/trace-analyzer.ts +12 -9
- package/src/monitoring/traces.ts +8 -6
- package/src/pretool-use-hook.ts +26 -21
- package/src/release/CONTEXT.md +1 -1
- package/src/release/__tests__/integrity.test.ts +0 -2
- package/src/release/integrity.ts +8 -9
- package/src/sdd/index-generator.ts +4 -0
- package/src/types/checkpoint.ts +8 -8
- package/src/types/command-io.ts +14 -0
- package/src/types/gate.ts +77 -0
- package/src/utils/__tests__/attempt.test.ts +94 -0
- package/src/utils/__tests__/package-json.test.ts +58 -0
- package/src/utils/__tests__/package-version.test.ts +21 -2
- package/src/utils/attempt.ts +35 -0
- package/src/utils/detect-source-roots.ts +38 -44
- package/src/utils/file-walk.ts +3 -7
- package/src/utils/package-json.ts +61 -0
- package/src/utils/package-version.ts +8 -10
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/init.js +0 -502
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/knowledge.d.ts +0 -169
- package/dist/cli/commands/knowledge.d.ts.map +0 -1
- package/dist/cli/commands/knowledge.js +0 -700
- package/dist/cli/commands/knowledge.js.map +0 -1
- package/dist/context/knowledge-injector.d.ts +0 -51
- package/dist/context/knowledge-injector.d.ts.map +0 -1
- package/dist/context/knowledge-injector.js +0 -128
- package/dist/context/knowledge-injector.js.map +0 -1
- package/dist/gates/index.d.ts +0 -10
- package/dist/gates/index.d.ts.map +0 -1
- package/dist/gates/index.js +0 -11
- package/dist/gates/index.js.map +0 -1
- package/src/cli/commands/init.ts +0 -590
- package/src/cli/commands/knowledge.ts +0 -820
- package/src/context/__tests__/knowledge-injector.test.ts +0 -197
- package/src/context/knowledge-injector.ts +0 -174
- package/src/gates/index.ts +0 -11
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* harness knowledge stats 子命令(Phase 3 自 knowledge.ts 拆出,纯移位)
|
|
3
|
+
*
|
|
4
|
+
* 本文件只做「取数 + 声明两投影」:json 面正本在 `data`,人读排版在 `human()` 的
|
|
5
|
+
* display model。上色、label 映射、json/人读分派、退出码、路径解析与 store 构造
|
|
6
|
+
* 统一在 knowledge-view.ts(harness#133,架构评审候选4)。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as fs from 'fs';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
import { evaluateFlywheel } from '../../../knowledge/flywheel-metrics';
|
|
12
|
+
import type { MaturityLevel } from '../../../knowledge/types';
|
|
13
|
+
import { processIO, type CommandIO, type CommandResult } from '../../command-contract';
|
|
14
|
+
import {
|
|
15
|
+
blankLine,
|
|
16
|
+
emitKnowledgeView,
|
|
17
|
+
openKnowledgeStore,
|
|
18
|
+
toneForMaturity,
|
|
19
|
+
type DisplayModel,
|
|
20
|
+
type DisplayRow,
|
|
21
|
+
} from '../knowledge-view';
|
|
22
|
+
import type { KnowledgeOptions } from './shared';
|
|
23
|
+
|
|
24
|
+
export function knowledgeStatsView(options: KnowledgeOptions, io: CommandIO) {
|
|
25
|
+
const store = openKnowledgeStore(options, io);
|
|
26
|
+
const entries = store.list({ excludeArchived: false });
|
|
27
|
+
const active = entries.filter(e => e.maturity !== 'archived');
|
|
28
|
+
|
|
29
|
+
const byType: Record<string, number> = {};
|
|
30
|
+
const byMaturity: Record<string, number> = {};
|
|
31
|
+
const byLayer: Record<string, number> = {};
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
byType[entry.type] = (byType[entry.type] || 0) + 1;
|
|
34
|
+
byMaturity[entry.maturity] = (byMaturity[entry.maturity] || 0) + 1;
|
|
35
|
+
byLayer[entry.layer] = (byLayer[entry.layer] || 0) + 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 飞轮指标:计算唯一实现在 knowledge/flywheel-metrics,此处只做 fs 读取 + 展示层单位映射
|
|
39
|
+
// fail-fast:统计文件在场但损坏直接抛(existsSync 判缺失,不吞解析错误)
|
|
40
|
+
let dailyConsumptionEvents = 0;
|
|
41
|
+
const statsPath = path.join(store.getBaseDir(), '.consumption-stats.json');
|
|
42
|
+
if (fs.existsSync(statsPath)) {
|
|
43
|
+
const stats = JSON.parse(fs.readFileSync(statsPath, 'utf-8'));
|
|
44
|
+
dailyConsumptionEvents = stats.dailyEvents || 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const metrics = evaluateFlywheel({ entries: active, dailyConsumptionEvents });
|
|
48
|
+
const flywheel = {
|
|
49
|
+
refCoverage: Math.round(metrics.refCoverage * 100),
|
|
50
|
+
avgRefs: Math.round(metrics.avgRefs * 10) / 10,
|
|
51
|
+
consumptionHitRate: Math.round(metrics.consumptionHitRate * 100),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const data = { total: entries.length, byType, byMaturity, byLayer, flywheel };
|
|
55
|
+
const activeCount = active.length;
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
data,
|
|
59
|
+
human: (): DisplayModel => ({
|
|
60
|
+
sections: [
|
|
61
|
+
{
|
|
62
|
+
rows: [
|
|
63
|
+
{ cells: [{ label: '📊 知识库统计', tone: 'heading' }] },
|
|
64
|
+
blankLine(),
|
|
65
|
+
{
|
|
66
|
+
cells: [
|
|
67
|
+
{ label: ' 总计: ', tone: 'emph' },
|
|
68
|
+
{ field: 'total', text: String(data.total), tone: 'emph' },
|
|
69
|
+
{ label: ' 条 (活跃: ', tone: 'emph' },
|
|
70
|
+
{ derived: 'activeCount', text: String(activeCount), tone: 'emph' },
|
|
71
|
+
{ label: ')', tone: 'emph' },
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
blankLine(),
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{ title: ' 按类型:', rows: [...countRows('byType', byType), blankLine()] },
|
|
78
|
+
{
|
|
79
|
+
title: ' 按成熟度:',
|
|
80
|
+
rows: [...Object.entries(byMaturity).map(([maturity, count]) => ({
|
|
81
|
+
cells: [
|
|
82
|
+
{ field: `byMaturity.${maturity}`, text: ` ${maturity}`, tone: toneForMaturity(maturity as MaturityLevel) },
|
|
83
|
+
{ field: `byMaturity.${maturity}`, text: `: ${count}` },
|
|
84
|
+
],
|
|
85
|
+
})), blankLine()],
|
|
86
|
+
},
|
|
87
|
+
{ title: ' 按层级:', rows: [...countRows('byLayer', byLayer), blankLine()] },
|
|
88
|
+
{
|
|
89
|
+
title: ' 飞轮指标:',
|
|
90
|
+
rows: [
|
|
91
|
+
{ cells: [{ label: ' 引用覆盖: ' }, { field: 'flywheel.refCoverage', text: `${flywheel.refCoverage}%` }] },
|
|
92
|
+
{ cells: [{ label: ' 平均引用: ' }, { field: 'flywheel.avgRefs', text: String(flywheel.avgRefs) }] },
|
|
93
|
+
{ cells: [{ label: ' 消费命中率: ' }, { field: 'flywheel.consumptionHitRate', text: `${flywheel.consumptionHitRate}%` }] },
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function countRows(field: string, counts: Record<string, number>): DisplayRow[] {
|
|
102
|
+
return Object.entries(counts).map(([key, count]) => ({
|
|
103
|
+
cells: [
|
|
104
|
+
{ label: ' ' },
|
|
105
|
+
{ field: `${field}.${key}`, text: `${key}: ${count}` },
|
|
106
|
+
],
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export async function knowledgeStats(options: KnowledgeOptions, io: CommandIO = processIO): Promise<CommandResult> {
|
|
111
|
+
return emitKnowledgeView(io, options, knowledgeStatsView(options, io));
|
|
112
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* harness knowledge sync-rag 子命令(Phase 3 自 knowledge.ts 拆出,纯移位)
|
|
3
|
+
*
|
|
4
|
+
* 本文件只做「取数 + 声明两投影」:json 面正本在 `data`,人读排版在 `human()` 的
|
|
5
|
+
* display model。上色、label 映射、json/人读分派、退出码统一在 knowledge-view.ts
|
|
6
|
+
* (harness#133,架构评审候选4)。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as fs from 'fs';
|
|
10
|
+
import { processIO, type CommandIO, type CommandResult } from '../../command-contract';
|
|
11
|
+
import {
|
|
12
|
+
blankLine,
|
|
13
|
+
emitKnowledgeView,
|
|
14
|
+
type DisplayModel,
|
|
15
|
+
type DisplayRow,
|
|
16
|
+
} from '../knowledge-view';
|
|
17
|
+
import type { KnowledgeOptions } from './shared';
|
|
18
|
+
|
|
19
|
+
export function knowledgeSyncRagView(options: KnowledgeOptions) {
|
|
20
|
+
const projectPath = options.projectPath || process.cwd();
|
|
21
|
+
const docsDir = `${projectPath}/.harness/knowledge-docs`;
|
|
22
|
+
const docsPresent = fs.existsSync(docsDir);
|
|
23
|
+
const files = docsPresent ? fs.readdirSync(docsDir).filter(f => f.endsWith('.md')) : [];
|
|
24
|
+
const data = { directory: docsDir, files };
|
|
25
|
+
|
|
26
|
+
return { data, human: (): DisplayModel => ({ sections: [{ rows: syncRagRows(docsPresent, docsDir, files) }] }) };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function syncRagRows(docsPresent: boolean, docsDir: string, files: string[]): DisplayRow[] {
|
|
30
|
+
if (!docsPresent) return [{ cells: [{ label: 'No .harness/knowledge-docs/ directory', tone: 'warn' }] }];
|
|
31
|
+
if (files.length === 0) return [{ cells: [{ label: 'No knowledge docs found', tone: 'muted' }] }];
|
|
32
|
+
return [
|
|
33
|
+
{ cells: [
|
|
34
|
+
{ label: '📄 RAG sync candidates: ', tone: 'heading' },
|
|
35
|
+
{ field: 'files.length', text: String(files.length), tone: 'heading' },
|
|
36
|
+
{ label: ' files in ', tone: 'heading' },
|
|
37
|
+
{ field: 'directory', text: docsDir, tone: 'heading' },
|
|
38
|
+
] },
|
|
39
|
+
blankLine(),
|
|
40
|
+
...files.map((file, i) => ({ cells: [{ field: `files.${i}`, text: ` ${file}`, tone: 'accent' as const }] })),
|
|
41
|
+
blankLine(),
|
|
42
|
+
{ cells: [{ label: 'Ingest each file into your own knowledge-base backend to sync to RAG', tone: 'muted' }] },
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function knowledgeSyncRag(options: KnowledgeOptions, io: CommandIO = processIO): Promise<CommandResult> {
|
|
47
|
+
return emitKnowledgeView(io, options, knowledgeSyncRagView(options));
|
|
48
|
+
}
|
|
@@ -17,8 +17,9 @@ import chalk from 'chalk';
|
|
|
17
17
|
import * as os from 'os';
|
|
18
18
|
import * as path from 'path';
|
|
19
19
|
import { FileKnowledgeStore } from '../../knowledge/store';
|
|
20
|
-
import { AUDIT_RULE_LABELS } from '../../knowledge/audit-
|
|
21
|
-
import type { AuditIssue,
|
|
20
|
+
import { AUDIT_RULE_LABELS } from '../../knowledge/audit-rules';
|
|
21
|
+
import type { AuditIssue, AuditRuleName } from '../../knowledge/audit-rules';
|
|
22
|
+
import type { AuditReport } from '../../knowledge/audit-dimensions';
|
|
22
23
|
import type { MaturityLevel } from '../../knowledge/types';
|
|
23
24
|
import { log, type CommandIO, type CommandResult } from '../command-contract';
|
|
24
25
|
|
|
@@ -64,7 +64,11 @@ export async function runPassesGate(
|
|
|
64
64
|
log(io);
|
|
65
65
|
log(io, chalk.gray('测试结果:'));
|
|
66
66
|
log(io, chalk.gray(` 通过: ${result.passedTests}/${result.totalTests}`));
|
|
67
|
-
log(io, chalk.gray(
|
|
67
|
+
log(io, chalk.gray(
|
|
68
|
+
result.failedTests === null
|
|
69
|
+
? ' 失败: 未取到计数(命令判负,但输出里没有失败计数行:进程被杀 / 无汇总 / 输出溢出这类,不代表「有几个用例红」)'
|
|
70
|
+
: ` 失败: ${result.failedTests}/${result.totalTests}`
|
|
71
|
+
));
|
|
68
72
|
log(io, chalk.gray(` 耗时: ${result.duration}ms`));
|
|
69
73
|
|
|
70
74
|
if (result.passed) {
|
|
@@ -75,6 +79,9 @@ export async function runPassesGate(
|
|
|
75
79
|
log(io);
|
|
76
80
|
log(io, chalk.red('❌ 测试门控未通过'));
|
|
77
81
|
log(io, chalk.red(' task.passes = false'));
|
|
82
|
+
if (result.message && result.message !== '测试失败') {
|
|
83
|
+
log(io, chalk.gray(` 原因: ${result.message}`));
|
|
84
|
+
}
|
|
78
85
|
|
|
79
86
|
if (result.failures && result.failures.length > 0) {
|
|
80
87
|
log(io, chalk.red('\n失败的测试:'));
|
|
@@ -83,7 +90,12 @@ export async function runPassesGate(
|
|
|
83
90
|
});
|
|
84
91
|
}
|
|
85
92
|
|
|
86
|
-
return {
|
|
93
|
+
return {
|
|
94
|
+
kind: 'fail',
|
|
95
|
+
reason: result.failedTests === null
|
|
96
|
+
? `passes-gate denied: 未取到失败计数(命令判负且输出无汇总行)${result.message ? `|${result.message}` : ''}`
|
|
97
|
+
: `passes-gate denied: ${result.failedTests}/${result.totalTests} 个测试失败`,
|
|
98
|
+
};
|
|
87
99
|
}
|
|
88
100
|
return { kind: 'ok' };
|
|
89
101
|
} catch (error) {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import { PerformanceGate, type ExtendedPerformanceGateConfig } from '../../gates/performance';
|
|
9
|
-
import type { PerformanceThresholds } from '../../
|
|
9
|
+
import type { PerformanceThresholds } from '../../types/gate';
|
|
10
10
|
import { log, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
11
11
|
import { reportGateDecision, reportGateError } from '../gate-command';
|
|
12
12
|
|
|
@@ -64,7 +64,7 @@ export async function performance(
|
|
|
64
64
|
label: '性能门控',
|
|
65
65
|
onPass: (r) => {
|
|
66
66
|
if (!r.details?.metrics) return [];
|
|
67
|
-
const metrics = r.details.metrics as
|
|
67
|
+
const metrics = r.details.metrics as { coverage?: number; bundleSize?: number };
|
|
68
68
|
const lines = ['', chalk.gray('性能指标:')];
|
|
69
69
|
|
|
70
70
|
if (metrics.coverage !== undefined) {
|
|
@@ -22,10 +22,9 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { execSync } from 'child_process';
|
|
25
|
-
import * as fs from 'fs';
|
|
26
|
-
import * as path from 'path';
|
|
27
25
|
import chalk from 'chalk';
|
|
28
26
|
import { verifyReleaseArtifacts } from '../../release';
|
|
27
|
+
import { readPackageJson } from '../../utils/package-json';
|
|
29
28
|
import { log, logError, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
30
29
|
|
|
31
30
|
export interface ReleaseOptions {
|
|
@@ -37,10 +36,13 @@ async function run(cmd: string, cwd: string, timeout = 60_000): Promise<{ stdout
|
|
|
37
36
|
try {
|
|
38
37
|
const stdout = execSync(cmd, { cwd, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'], timeout });
|
|
39
38
|
return { stdout: stdout.trim(), stderr: '' };
|
|
40
|
-
} catch (e
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
39
|
+
} catch (e) {
|
|
40
|
+
// execSync 非零退出:rejection 形状 Error & { stdout?, stderr? },逐字段窄化取数
|
|
41
|
+
const err = e as { stdout?: unknown; stderr?: unknown };
|
|
42
|
+
const chunk = (v: unknown): string => (typeof v === 'string' ? v : v != null ? String(v) : '');
|
|
43
|
+
const stderr = chunk(err.stderr);
|
|
44
|
+
const stdout = chunk(err.stdout);
|
|
45
|
+
return { stdout: stdout.trim(), stderr: stderr.trim() || (e instanceof Error ? e.message : String(e)) };
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -55,14 +57,17 @@ export async function release(options: ReleaseOptions, io: CommandIO = processIO
|
|
|
55
57
|
const dryRun = options.dryRun === 'true';
|
|
56
58
|
|
|
57
59
|
// ── 1. Verify package ──
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
60
|
+
const pkgJson = readPackageJson(pkgPath);
|
|
61
|
+
if (!pkgJson) {
|
|
60
62
|
logError(io, chalk.red(`❌ Not a package: ${pkgPath}`));
|
|
61
63
|
return gateFail('package', `not a package: ${pkgPath}`);
|
|
62
64
|
}
|
|
63
|
-
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
|
|
64
65
|
const pkgName = pkgJson.name;
|
|
65
66
|
const oldVersion = pkgJson.version;
|
|
67
|
+
if (typeof oldVersion !== 'string' || !oldVersion) {
|
|
68
|
+
logError(io, chalk.red('❌ package.json 缺少 version 字段'));
|
|
69
|
+
return gateFail('version-field', 'package.json missing version field');
|
|
70
|
+
}
|
|
66
71
|
log(io, chalk.cyan(`📦 ${pkgName}@${oldVersion}`));
|
|
67
72
|
log(io, chalk.cyan(` bump: ${bumpType}${dryRun ? ' (dry-run)' : ''}`));
|
|
68
73
|
|
|
@@ -104,7 +104,7 @@ export async function reviewStatus(
|
|
|
104
104
|
if (pr.reviews && pr.reviews.length > 0) {
|
|
105
105
|
log(io);
|
|
106
106
|
log(io, chalk.gray('审查历史:'));
|
|
107
|
-
pr.reviews.forEach((r
|
|
107
|
+
(pr.reviews as Array<{ state?: string; author?: { login?: string } }>).forEach((r) => {
|
|
108
108
|
const statusColor = r.state === 'APPROVED' ? chalk.green :
|
|
109
109
|
r.state === 'CHANGES_REQUESTED' ? chalk.red : chalk.gray;
|
|
110
110
|
log(io, statusColor(` - ${r.author?.login || 'unknown'}: ${r.state}`));
|
|
@@ -115,8 +115,9 @@ export async function reviewStatus(
|
|
|
115
115
|
log(io, chalk.gray(' 使用 gh pr create 创建 PR'));
|
|
116
116
|
}
|
|
117
117
|
return { kind: 'ok' };
|
|
118
|
-
} catch (error:
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
} catch (error: unknown) {
|
|
119
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
120
|
+
log(io, chalk.red(`❌ 获取审查状态失败: ${message}`));
|
|
121
|
+
return { kind: 'skip', reason: `获取审查状态失败: ${message}` };
|
|
121
122
|
}
|
|
122
123
|
}
|
|
@@ -11,7 +11,7 @@ import * as path from 'path';
|
|
|
11
11
|
import { SecurityGate } from '../../gates/security';
|
|
12
12
|
import { execAsync } from '../../utils/exec';
|
|
13
13
|
import { log, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
14
|
-
import { reportGateDecision } from '../gate-command';
|
|
14
|
+
import { reportGateDecision, reportGateError } from '../gate-command';
|
|
15
15
|
|
|
16
16
|
export interface SecurityOptions {
|
|
17
17
|
/** 项目路径 */
|
|
@@ -72,9 +72,7 @@ export async function security(
|
|
|
72
72
|
decision
|
|
73
73
|
);
|
|
74
74
|
} catch (error) {
|
|
75
|
-
|
|
76
|
-
log(io, chalk.red(`❌ 安全检查异常: ${error instanceof Error ? error.message : String(error)}`));
|
|
77
|
-
return { kind: 'fail', reason: `security scan error: ${error instanceof Error ? error.message : String(error)}` };
|
|
75
|
+
return reportGateError(io, 'security', '安全门控', error);
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
|
|
@@ -141,9 +139,12 @@ export async function secretsScan(
|
|
|
141
139
|
`gitleaks git --report-format json --report-path "${reportPath}" "${repoRoot}"`,
|
|
142
140
|
{ cwd: repoRoot, maxBuffer: 10 * 1024 * 1024 },
|
|
143
141
|
);
|
|
144
|
-
} catch (error:
|
|
142
|
+
} catch (error: unknown) {
|
|
145
143
|
// gitleaks 退出码:0 = 干净,1 = 发现泄露(报告已落盘);127 = 二进制不存在
|
|
146
|
-
|
|
144
|
+
const code = typeof error === 'object' && error !== null
|
|
145
|
+
? (error as { code?: unknown }).code
|
|
146
|
+
: undefined;
|
|
147
|
+
exitCode = typeof code === 'number' ? code : -1;
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
if (exitCode === 127) {
|
|
@@ -215,8 +216,8 @@ export async function auditDetails(
|
|
|
215
216
|
return { kind: 'ok' };
|
|
216
217
|
}
|
|
217
218
|
|
|
218
|
-
const details = result.details as
|
|
219
|
-
if (details?.vulnerabilities?.length
|
|
219
|
+
const details = result.details as { total?: number; vulnerabilities?: Array<{ name: string; severity: string; via: string }> } | undefined;
|
|
220
|
+
if (details?.vulnerabilities?.length) {
|
|
220
221
|
log(io, chalk.yellow(`发现 ${details.total} 个漏洞:\n`));
|
|
221
222
|
for (const v of details.vulnerabilities) {
|
|
222
223
|
const severityColor = getSeverityColor(v.severity);
|
|
@@ -227,8 +228,6 @@ export async function auditDetails(
|
|
|
227
228
|
}
|
|
228
229
|
return { kind: 'ok' };
|
|
229
230
|
} catch (error) {
|
|
230
|
-
|
|
231
|
-
log(io, chalk.red(`❌ 安全审计异常: ${error instanceof Error ? error.message : String(error)}`));
|
|
232
|
-
return { kind: 'fail', reason: `security audit error: ${error instanceof Error ? error.message : String(error)}` };
|
|
231
|
+
return reportGateError(io, 'security', '安全审计', error);
|
|
233
232
|
}
|
|
234
233
|
}
|
|
@@ -10,6 +10,7 @@ import * as fs from 'fs';
|
|
|
10
10
|
import * as path from 'path';
|
|
11
11
|
import { log, logError, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
12
12
|
import { walkFiles } from '../../utils/file-walk';
|
|
13
|
+
import { readPackageJson } from '../../utils/package-json';
|
|
13
14
|
|
|
14
15
|
export interface SpecBaselineCheckOptions {
|
|
15
16
|
/** 项目路径 */
|
|
@@ -184,14 +185,12 @@ export function createBaselineIndex(
|
|
|
184
185
|
dependencies() {
|
|
185
186
|
if (!dependencySnapshot) {
|
|
186
187
|
try {
|
|
187
|
-
const pkgJson =
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
ok: true,
|
|
192
|
-
deps: { ...pkgJson.dependencies, ...pkgJson.devDependencies },
|
|
193
|
-
};
|
|
188
|
+
const pkgJson = readPackageJson(projectPath);
|
|
189
|
+
dependencySnapshot = pkgJson
|
|
190
|
+
? { ok: true, deps: { ...pkgJson.dependencies, ...pkgJson.devDependencies } }
|
|
191
|
+
: { ok: false };
|
|
194
192
|
} catch {
|
|
193
|
+
// #146:读取失败态(含损坏清单)同样入库,不逐条重试
|
|
195
194
|
dependencySnapshot = { ok: false };
|
|
196
195
|
}
|
|
197
196
|
}
|
|
@@ -93,8 +93,8 @@ export async function status(options: StatusOptions, io: CommandIO = processIO):
|
|
|
93
93
|
anomalies.forEach((a: TraceAnomaly) => {
|
|
94
94
|
log(io, chalk.yellow(` ${a.constraintId}`));
|
|
95
95
|
log(io, chalk.gray(` 类型: ${a.type}`));
|
|
96
|
-
log(io, chalk.gray(` 当前值: ${a.data
|
|
97
|
-
log(io, chalk.gray(` 阈值: ${a.data
|
|
96
|
+
log(io, chalk.gray(` 当前值: ${a.data.currentRate}`));
|
|
97
|
+
log(io, chalk.gray(` 阈值: ${a.data.threshold}`));
|
|
98
98
|
log(io);
|
|
99
99
|
});
|
|
100
100
|
|
|
@@ -145,12 +145,8 @@ async function getTopLevelDirEntries(
|
|
|
145
145
|
projectPath: string,
|
|
146
146
|
srcDirs: string[]
|
|
147
147
|
): Promise<Array<{ dir: string; role: string }>> {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
dirents = await fs.readdir(projectPath, { withFileTypes: true });
|
|
151
|
-
} catch {
|
|
152
|
-
return [];
|
|
153
|
-
}
|
|
148
|
+
// fail-fast:项目根都 readdir 不出来是环境事故,抛出不装空
|
|
149
|
+
const dirents = await fs.readdir(projectPath, { withFileTypes: true });
|
|
154
150
|
|
|
155
151
|
const entries: Array<{ dir: string; role: string }> = [];
|
|
156
152
|
for (const d of dirents) {
|
|
@@ -185,43 +181,36 @@ async function describeTopLevelDir(projectPath: string, dir: string, srcDirs: st
|
|
|
185
181
|
return '—';
|
|
186
182
|
}
|
|
187
183
|
|
|
188
|
-
/** 列出 monorepo 工作区成员(含 package.json
|
|
184
|
+
/** 列出 monorepo 工作区成员(含 package.json 的子目录名,排序;dir 不存在 → 空) */
|
|
189
185
|
async function listWorkspaceMembers(dir: string): Promise<string[]> {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
186
|
+
if (!existsSync(dir)) return [];
|
|
187
|
+
const dirents = await fs.readdir(dir, { withFileTypes: true });
|
|
188
|
+
const members: string[] = [];
|
|
189
|
+
for (const d of dirents) {
|
|
190
|
+
if (!d.isDirectory() || d.name.startsWith('.')) continue;
|
|
191
|
+
if (existsSync(path.join(dir, d.name, 'package.json'))) {
|
|
192
|
+
members.push(d.name);
|
|
198
193
|
}
|
|
199
|
-
return members.sort();
|
|
200
|
-
} catch {
|
|
201
|
-
return [];
|
|
202
194
|
}
|
|
195
|
+
return members.sort();
|
|
203
196
|
}
|
|
204
197
|
|
|
205
198
|
/** 收集治理信息:.harness/config.yml 与 CLAUDE.md 治理块 */
|
|
206
199
|
async function getGovernanceInfo(projectPath: string): Promise<GovernanceInfo> {
|
|
207
200
|
const info: GovernanceInfo = { hasConfig: false, hasClaudeGovernance: false };
|
|
208
201
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
} catch {
|
|
216
|
-
// 配置不存在
|
|
202
|
+
// loadRawProjectConfig:文件缺失 → undefined;YAML 损坏 → 抛出(fail-fast,不装未配置)
|
|
203
|
+
const config = loadRawProjectConfig(projectPath);
|
|
204
|
+
info.hasConfig = config !== undefined;
|
|
205
|
+
if (config && typeof config.preset === 'string') {
|
|
206
|
+
info.preset = config.preset;
|
|
217
207
|
}
|
|
218
208
|
|
|
219
|
-
|
|
220
|
-
|
|
209
|
+
const claudePath = path.join(projectPath, 'CLAUDE.md');
|
|
210
|
+
if (existsSync(claudePath)) {
|
|
211
|
+
const claude = await fs.readFile(claudePath, 'utf-8');
|
|
221
212
|
// 契约在场判定收口 injection-writer.hasGovernanceContract(#83,与 presence 同谓词)
|
|
222
213
|
info.hasClaudeGovernance = hasGovernanceContract(claude);
|
|
223
|
-
} catch {
|
|
224
|
-
// CLAUDE.md 不存在
|
|
225
214
|
}
|
|
226
215
|
|
|
227
216
|
return info;
|
|
@@ -229,11 +218,8 @@ async function getGovernanceInfo(projectPath: string): Promise<GovernanceInfo> {
|
|
|
229
218
|
|
|
230
219
|
/** 判断 .harness/knowledge 目录是否存在(只判存在性,不统计条数——条数易变,见 buildAgentsMd 注释) */
|
|
231
220
|
async function hasKnowledgeDir(projectPath: string): Promise<boolean> {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
} catch {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
221
|
+
const dir = path.join(projectPath, '.harness', 'knowledge');
|
|
222
|
+
return existsSync(dir) && (await fs.stat(dir)).isDirectory();
|
|
237
223
|
}
|
|
238
224
|
|
|
239
225
|
/** 模块上下文正本候选路径(相对项目根) */
|
|
@@ -249,12 +235,9 @@ const CONTEXT_DOC_PATHS: string[][] = [
|
|
|
249
235
|
*/
|
|
250
236
|
async function findCanonicalContextDoc(projectPath: string): Promise<string | null> {
|
|
251
237
|
for (const segments of CONTEXT_DOC_PATHS) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
} catch {
|
|
257
|
-
// 该候选不存在,看下一个
|
|
238
|
+
const candidate = path.join(projectPath, ...segments);
|
|
239
|
+
if (existsSync(candidate) && (await fs.stat(candidate)).isFile()) {
|
|
240
|
+
return segments.join('/');
|
|
258
241
|
}
|
|
259
242
|
}
|
|
260
243
|
return null;
|
|
@@ -265,12 +248,8 @@ async function countContextDocs(projectPath: string, srcDirs: string[]): Promise
|
|
|
265
248
|
const found = new Set<string>();
|
|
266
249
|
|
|
267
250
|
async function scan(dir: string): Promise<void> {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
271
|
-
} catch {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
251
|
+
// fail-fast:目录不可读直接抛——CONTEXT.md 计数缺一块而无声,比报错更难查
|
|
252
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
274
253
|
for (const entry of entries) {
|
|
275
254
|
if (!entry.isDirectory()) continue;
|
|
276
255
|
if (DEFAULT_SKIP_DIRS.includes(entry.name)) continue;
|
|
@@ -284,6 +263,8 @@ async function countContextDocs(projectPath: string, srcDirs: string[]): Promise
|
|
|
284
263
|
|
|
285
264
|
for (const root of srcDirs) {
|
|
286
265
|
const rootPath = path.join(projectPath, root);
|
|
266
|
+
// 源码根不在场无可统计(缺失判定归 sync-docs 主流程),跳过
|
|
267
|
+
if (!existsSync(rootPath)) continue;
|
|
287
268
|
if (existsSync(path.join(rootPath, 'CONTEXT.md'))) {
|
|
288
269
|
found.add(rootPath);
|
|
289
270
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import * as fs from 'fs/promises';
|
|
9
|
+
import { existsSync } from 'fs';
|
|
9
10
|
import * as path from 'path';
|
|
10
11
|
import { readCapabilitiesEntries } from '../../../core/constraints/capabilities-parser';
|
|
11
12
|
import type { CapabilitiesMode } from '../../../core/project-config-loader';
|
|
@@ -23,7 +24,9 @@ export async function parseCapabilitiesFiles(capabilitiesPath: string): Promise<
|
|
|
23
24
|
const entries = readCapabilitiesEntries(capabilitiesPath, { includeDirs: true });
|
|
24
25
|
const files: string[] = [];
|
|
25
26
|
for (const entry of entries) {
|
|
26
|
-
|
|
27
|
+
// split('/') 恒产出 ≥1 段,末段索引恒有值
|
|
28
|
+
const segments = entry.split('/');
|
|
29
|
+
const value = entry.endsWith('/') ? entry : segments[segments.length - 1];
|
|
27
30
|
if (!files.includes(value)) files.push(value);
|
|
28
31
|
}
|
|
29
32
|
return files;
|
|
@@ -42,15 +45,14 @@ export async function updateCapabilitiesFile(
|
|
|
42
45
|
result: SyncResult,
|
|
43
46
|
mode: CapabilitiesMode = 'file',
|
|
44
47
|
): Promise<void> {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
content = generateCapabilitiesContent(currentModules, mode);
|
|
51
|
-
await fs.writeFile(capabilitiesPath, content, 'utf-8');
|
|
48
|
+
// 文件不存在 → 创建新的(module 模式生成按目录聚合的模板);
|
|
49
|
+
// 存在但读失败 → 抛出(fail-fast,不把 IO 故障当「不存在」覆盖重建)
|
|
50
|
+
if (!existsSync(capabilitiesPath)) {
|
|
51
|
+
const fresh = generateCapabilitiesContent(currentModules, mode);
|
|
52
|
+
await fs.writeFile(capabilitiesPath, fresh, 'utf-8');
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
55
|
+
let content = await fs.readFile(capabilitiesPath, 'utf-8');
|
|
54
56
|
|
|
55
57
|
// 如果有表格行,更新表格
|
|
56
58
|
if (existingFiles.length > 0) {
|
|
@@ -74,7 +76,10 @@ export async function updateCapabilitiesFile(
|
|
|
74
76
|
|
|
75
77
|
// 添加新文件的行(在最后一个表格行之后);module 模式跳过
|
|
76
78
|
if (mode !== 'module' && result.added.length > 0) {
|
|
77
|
-
const getBasenameLocal = (f: string) =>
|
|
79
|
+
const getBasenameLocal = (f: string) => {
|
|
80
|
+
const segments = f.split('/');
|
|
81
|
+
return segments[segments.length - 1];
|
|
82
|
+
};
|
|
78
83
|
const addedModules = currentModules.filter(m => result.added.includes(getBasenameLocal(m.file)));
|
|
79
84
|
const tableEndRegex = /(^\|[^|]+\|[^|]+\|[^|]+\|\s*$)/gm;
|
|
80
85
|
let lastTableRow = '';
|
|
@@ -273,7 +278,8 @@ function generateDirTable(modules: ModuleInfo[]): string {
|
|
|
273
278
|
}
|
|
274
279
|
|
|
275
280
|
const rows = dirs.map(d => {
|
|
276
|
-
const
|
|
281
|
+
const segments = d.replace(/\/$/, '').split('/');
|
|
282
|
+
const name = segments[segments.length - 1];
|
|
277
283
|
return `| ${name} | ${d} | ${name} |`;
|
|
278
284
|
}).join('\n');
|
|
279
285
|
|
|
@@ -316,7 +322,8 @@ export function compactCapabilitiesContent(content: string): string {
|
|
|
316
322
|
const deleteLines = new Set<number>();
|
|
317
323
|
for (const [dir, rows] of groups) {
|
|
318
324
|
if (rows.length < 2) continue;
|
|
319
|
-
const
|
|
325
|
+
const segments = dir.split('/');
|
|
326
|
+
const name = segments[segments.length - 1];
|
|
320
327
|
const desc = rows[0].desc || name;
|
|
321
328
|
lines[rows[0].lineIndex] = `| ${name} | ${dir}/ | ${desc} |`;
|
|
322
329
|
for (const row of rows.slice(1)) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sync-docs 的 --compact 形态(Phase 3 自 index.ts 拆出,纯移位)
|
|
3
|
+
*
|
|
4
|
+
* 一次性迁移:将 CAPABILITIES.md 文件表格折叠为目录条目后直接返回,
|
|
5
|
+
* 不进主流程的扫描/判定/写入管线。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import * as fs from 'fs/promises';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
import { compactCapabilitiesContent } from './capabilities-syncer';
|
|
12
|
+
import { log, type CommandIO, type CommandResult } from '../../command-contract';
|
|
13
|
+
|
|
14
|
+
export async function runCompactSync(
|
|
15
|
+
projectPath: string,
|
|
16
|
+
isJson: boolean,
|
|
17
|
+
drift: (reason: string) => CommandResult,
|
|
18
|
+
io: CommandIO,
|
|
19
|
+
): Promise<CommandResult> {
|
|
20
|
+
const capsPath = path.join(projectPath, 'CAPABILITIES.md');
|
|
21
|
+
try {
|
|
22
|
+
const content = await fs.readFile(capsPath, 'utf-8');
|
|
23
|
+
const compacted = compactCapabilitiesContent(content);
|
|
24
|
+
if (compacted !== content) {
|
|
25
|
+
await fs.writeFile(capsPath, compacted, 'utf-8');
|
|
26
|
+
if (!isJson) log(io, chalk.green('✅ 已将 CAPABILITIES.md 文件表格折叠为目录条目'));
|
|
27
|
+
} else {
|
|
28
|
+
if (!isJson) log(io, chalk.green('✅ CAPABILITIES.md 无需折叠'));
|
|
29
|
+
}
|
|
30
|
+
return { kind: 'ok' };
|
|
31
|
+
} catch {
|
|
32
|
+
if (!isJson) log(io, chalk.red('❌ CAPABILITIES.md 不存在,无法折叠'));
|
|
33
|
+
return drift('CAPABILITIES.md 不存在,无法折叠');
|
|
34
|
+
}
|
|
35
|
+
}
|