@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
|
@@ -96,13 +96,16 @@ export class FreshnessRunner {
|
|
|
96
96
|
return this.checkDocDir(check, context);
|
|
97
97
|
case 'doc_regex_count':
|
|
98
98
|
return this.checkDocRegexCount(check, context);
|
|
99
|
-
default:
|
|
99
|
+
default: {
|
|
100
|
+
// 运行时可达(check 来自 yml 反序列化,未登记类型漏过校验):窄化取 type 上报
|
|
101
|
+
const raw = check as { type?: string };
|
|
100
102
|
return {
|
|
101
|
-
type:
|
|
103
|
+
type: raw.type || 'unknown',
|
|
102
104
|
label: 'Unknown',
|
|
103
105
|
pass: true,
|
|
104
|
-
message: `未知的检查类型: ${
|
|
106
|
+
message: `未知的检查类型: ${raw.type}`,
|
|
105
107
|
};
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -115,37 +118,36 @@ export class FreshnessRunner {
|
|
|
115
118
|
const changelogPath = join(ctx.projectPath, check.changelog || 'CHANGELOG.md');
|
|
116
119
|
const pkgPath = join(ctx.projectPath, check.package_json || 'package.json');
|
|
117
120
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const versionMatch = changelogContent.match(/##\s*\[(\d+\.\d+\.\d+)\]/);
|
|
125
|
-
if (!versionMatch) {
|
|
126
|
-
return { type: 'changelog_version', label: 'CHANGELOG Version', pass: true };
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const changelogVersion = versionMatch[1];
|
|
121
|
+
// fail-fast:缺文件/缺版本行是「无检查对象」按 pass 跳过(下方显式分支);
|
|
122
|
+
// 读失败、package.json 损坏等真异常直接抛,由 checker 层按可见降级处理,
|
|
123
|
+
// 不再 catch 成静默 pass(吞错会把解析 bug 变成「永远通过」,harness#119)
|
|
124
|
+
if (!existsSync(changelogPath)) {
|
|
125
|
+
return { type: 'changelog_version', label: 'CHANGELOG Version', pass: true };
|
|
126
|
+
}
|
|
130
127
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
128
|
+
const changelogContent = readFileSync(changelogPath, 'utf-8');
|
|
129
|
+
const versionMatch = changelogContent.match(/##\s*\[(\d+\.\d+\.\d+)\]/);
|
|
130
|
+
if (!versionMatch) {
|
|
131
|
+
return { type: 'changelog_version', label: 'CHANGELOG Version', pass: true };
|
|
132
|
+
}
|
|
134
133
|
|
|
135
|
-
|
|
136
|
-
const pkgVersion = pkg.version as string;
|
|
134
|
+
const changelogVersion = versionMatch[1];
|
|
137
135
|
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
type: 'changelog_version',
|
|
141
|
-
label: 'CHANGELOG Version',
|
|
142
|
-
pass,
|
|
143
|
-
message: pass ? undefined : `CHANGELOG.md 版本 ${changelogVersion} !== package.json 版本 ${pkgVersion}`,
|
|
144
|
-
detail: { changelogVersion, pkgVersion },
|
|
145
|
-
};
|
|
146
|
-
} catch {
|
|
136
|
+
if (!existsSync(pkgPath)) {
|
|
147
137
|
return { type: 'changelog_version', label: 'CHANGELOG Version', pass: true };
|
|
148
138
|
}
|
|
139
|
+
|
|
140
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
141
|
+
const pkgVersion = pkg.version as string;
|
|
142
|
+
|
|
143
|
+
const pass = changelogVersion === pkgVersion;
|
|
144
|
+
return {
|
|
145
|
+
type: 'changelog_version',
|
|
146
|
+
label: 'CHANGELOG Version',
|
|
147
|
+
pass,
|
|
148
|
+
message: pass ? undefined : `CHANGELOG.md 版本 ${changelogVersion} !== package.json 版本 ${pkgVersion}`,
|
|
149
|
+
detail: { changelogVersion, pkgVersion },
|
|
150
|
+
};
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
// ── context_docs ─────────────────────────────────────────────────
|
|
@@ -185,113 +187,103 @@ export class FreshnessRunner {
|
|
|
185
187
|
check: DocDirCheck,
|
|
186
188
|
ctx: RunContext
|
|
187
189
|
): FreshnessCheckResult {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
}
|
|
190
|
+
// fail-fast:doc 缺失/章节缺失/无目录引用是「无检查对象」按显式分支跳过;
|
|
191
|
+
// 读失败、正则构造错误等真异常直接抛(原整体 catch 成静默 pass,harness#119 同族)
|
|
192
|
+
const docPath = join(ctx.projectPath, check.doc);
|
|
193
|
+
if (!existsSync(docPath)) {
|
|
194
|
+
return {
|
|
195
|
+
type: 'doc_dir_check',
|
|
196
|
+
label: `${check.doc} / ${check.section}`,
|
|
197
|
+
pass: true,
|
|
198
|
+
message: `${check.doc} 不存在,跳过检查`,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
198
201
|
|
|
199
|
-
|
|
202
|
+
const content = readFileSync(docPath, 'utf-8');
|
|
200
203
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
204
|
+
// 提取目标章节($ 不要求末尾有 \n,适配无 trailing newline 的内容)
|
|
205
|
+
const sectionRegex = new RegExp(
|
|
206
|
+
`## ${this.escapeRegExp(check.section)}\\s*\\n([\\s\\S]*?)(?=\\n## |\\n---|$)`
|
|
207
|
+
);
|
|
208
|
+
const sectionMatch = content.match(sectionRegex);
|
|
209
|
+
if (!sectionMatch) {
|
|
210
|
+
return {
|
|
211
|
+
type: 'doc_dir_check',
|
|
212
|
+
label: `${check.doc} / ${check.section}`,
|
|
213
|
+
pass: true,
|
|
214
|
+
message: `未找到 "${check.section}" 章节`,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
214
217
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
218
|
+
const section = sectionMatch[1];
|
|
219
|
+
|
|
220
|
+
// 提取目录
|
|
221
|
+
const dirPattern = check.dir_pattern || '`([^`]+)`';
|
|
222
|
+
const dirRegex = new RegExp(dirPattern, 'g');
|
|
223
|
+
const docDirs = new Set<string>();
|
|
224
|
+
let match;
|
|
225
|
+
while ((match = dirRegex.exec(section)) !== null) {
|
|
226
|
+
const dirPath = match[1].replace(/\/$/, '').trim();
|
|
227
|
+
// 只收集看起来像目录的路径(包含 / 或以特定前缀开头)
|
|
228
|
+
// 宽松匹配:任何非空字符串
|
|
229
|
+
if (dirPath.length > 0) {
|
|
230
|
+
docDirs.add(dirPath);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
230
233
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
if (docDirs.size === 0) {
|
|
235
|
+
return {
|
|
236
|
+
type: 'doc_dir_check',
|
|
237
|
+
label: `${check.doc} / ${check.section}`,
|
|
238
|
+
pass: true,
|
|
239
|
+
message: `"${check.section}" 章节中未找到目录引用`,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
239
242
|
|
|
240
|
-
|
|
243
|
+
const failures: string[] = [];
|
|
241
244
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
// 1. doc → fs: 文档中每个目录必须实际存在于磁盘
|
|
246
|
+
for (const dir of docDirs) {
|
|
247
|
+
if (!existsSync(join(ctx.projectPath, dir))) {
|
|
248
|
+
failures.push(`文档引用但不存在: ${dir}`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// 2. fs → doc: 每个实际目录必须在文档中被覆盖
|
|
253
|
+
if (!check.skip_reverse_check) {
|
|
254
|
+
// 从文档目录中推断要扫描的根目录集
|
|
255
|
+
const rootDirs = this.inferRootDirs(docDirs, ctx);
|
|
256
|
+
const excludeSet = new Set(check.exclude || DEFAULT_SKIP_DIRS);
|
|
248
257
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const actualDir = `${rootDir}/${entry.name}`;
|
|
267
|
-
// 直接匹配 or 任何文档条目是该目录的子目录
|
|
268
|
-
if (docDirs.has(actualDir)) continue;
|
|
269
|
-
const covered = [...docDirs].some(d => d.startsWith(actualDir + '/'));
|
|
270
|
-
if (!covered) {
|
|
271
|
-
failures.push(`存在但未在文档中覆盖: ${actualDir}`);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
} catch {
|
|
275
|
-
// 扫描失败,跳过
|
|
276
|
-
}
|
|
258
|
+
for (const rootDir of rootDirs) {
|
|
259
|
+
const absRoot = join(ctx.projectPath, rootDir);
|
|
260
|
+
if (!existsSync(absRoot)) continue;
|
|
261
|
+
|
|
262
|
+
const entries = readdirSync(absRoot, { withFileTypes: true });
|
|
263
|
+
for (const entry of entries) {
|
|
264
|
+
if (!entry.isDirectory()) continue;
|
|
265
|
+
if (excludeSet.has(entry.name)) continue;
|
|
266
|
+
if (entry.name.startsWith('__') || entry.name.startsWith('.')) continue;
|
|
267
|
+
|
|
268
|
+
const actualDir = `${rootDir}/${entry.name}`;
|
|
269
|
+
// 直接匹配 or 任何文档条目是该目录的子目录
|
|
270
|
+
if (docDirs.has(actualDir)) continue;
|
|
271
|
+
const covered = [...docDirs].some(d => d.startsWith(actualDir + '/'));
|
|
272
|
+
if (!covered) {
|
|
273
|
+
failures.push(`存在但未在文档中覆盖: ${actualDir}`);
|
|
277
274
|
}
|
|
278
275
|
}
|
|
279
|
-
|
|
280
|
-
const pass = failures.length === 0;
|
|
281
|
-
return {
|
|
282
|
-
type: 'doc_dir_check',
|
|
283
|
-
label: `${check.doc} / ${check.section}`,
|
|
284
|
-
pass,
|
|
285
|
-
message: pass ? undefined : failures.join('; '),
|
|
286
|
-
detail: { docDirs: [...docDirs], failures },
|
|
287
|
-
};
|
|
288
|
-
} catch {
|
|
289
|
-
return {
|
|
290
|
-
type: 'doc_dir_check',
|
|
291
|
-
label: `${check.doc} / ${check.section}`,
|
|
292
|
-
pass: true,
|
|
293
|
-
};
|
|
294
276
|
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const pass = failures.length === 0;
|
|
280
|
+
return {
|
|
281
|
+
type: 'doc_dir_check',
|
|
282
|
+
label: `${check.doc} / ${check.section}`,
|
|
283
|
+
pass,
|
|
284
|
+
message: pass ? undefined : failures.join('; '),
|
|
285
|
+
detail: { docDirs: [...docDirs], failures },
|
|
286
|
+
};
|
|
295
287
|
}
|
|
296
288
|
|
|
297
289
|
/**
|
|
@@ -302,29 +294,29 @@ export class FreshnessRunner {
|
|
|
302
294
|
const roots = new Set<string>();
|
|
303
295
|
|
|
304
296
|
for (const dir of docDirs) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
297
|
+
// 取第一个路径段之前的公共部分
|
|
298
|
+
const parts = dir.split('/');
|
|
299
|
+
// 收集可能的根(单段目录如 "src/xxx" → 根是 "src")
|
|
300
|
+
if (parts.length >= 2) {
|
|
301
|
+
roots.add(parts.slice(0, parts.length - 1).join('/') || parts[0]);
|
|
302
|
+
}
|
|
311
303
|
}
|
|
312
304
|
|
|
313
305
|
// 合并为最小公共根集
|
|
314
306
|
// 简单策略:如果有 "src/a" 和 "src/b",则根是 "src"
|
|
315
307
|
const merged = new Set<string>();
|
|
316
308
|
for (const root of roots) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
if (!isSubsumed) {
|
|
325
|
-
merged.add(root);
|
|
309
|
+
let isSubsumed = false;
|
|
310
|
+
for (const other of roots) {
|
|
311
|
+
if (root !== other && root.startsWith(other + '/')) {
|
|
312
|
+
isSubsumed = true;
|
|
313
|
+
break;
|
|
326
314
|
}
|
|
327
315
|
}
|
|
316
|
+
if (!isSubsumed) {
|
|
317
|
+
merged.add(root);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
328
320
|
|
|
329
321
|
if (merged.size > 0) return [...merged];
|
|
330
322
|
// 兜底 = 文档一个目录条目都没登记:按项目实际源码根全量比对(删掉它等于静默放行空文档)。
|
|
@@ -338,74 +330,67 @@ export class FreshnessRunner {
|
|
|
338
330
|
check: DocRegexCountCheck,
|
|
339
331
|
ctx: RunContext
|
|
340
332
|
): FreshnessCheckResult {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
const content = readFileSync(docPath, 'utf-8');
|
|
353
|
-
|
|
354
|
-
// 从文档中提取声明的计数
|
|
355
|
-
const countRegex = new RegExp(check.pattern);
|
|
356
|
-
const countMatch = content.match(countRegex);
|
|
357
|
-
if (!countMatch || countMatch[1] === undefined) {
|
|
358
|
-
return {
|
|
359
|
-
type: 'doc_regex_count',
|
|
360
|
-
label: `${check.doc} / ${check.label}`,
|
|
361
|
-
pass: true,
|
|
362
|
-
message: `未在 ${check.doc} 中找到匹配 "${check.label}" 的计数行`,
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
const docCount = parseInt(countMatch[1], 10);
|
|
367
|
-
if (isNaN(docCount)) {
|
|
368
|
-
return {
|
|
369
|
-
type: 'doc_regex_count',
|
|
370
|
-
label: `${check.doc} / ${check.label}`,
|
|
371
|
-
pass: true,
|
|
372
|
-
message: `计数解析失败: ${countMatch[1]}`,
|
|
373
|
-
};
|
|
374
|
-
}
|
|
333
|
+
// fail-fast:doc 缺失/无计数行/计数解析失败按显式分支跳过;其余异常抛出(同 checkDocDir)
|
|
334
|
+
const docPath = join(ctx.projectPath, check.doc);
|
|
335
|
+
if (!existsSync(docPath)) {
|
|
336
|
+
return {
|
|
337
|
+
type: 'doc_regex_count',
|
|
338
|
+
label: `${check.doc} / ${check.label}`,
|
|
339
|
+
pass: true,
|
|
340
|
+
message: `${check.doc} 不存在,跳过检查`,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
375
343
|
|
|
376
|
-
|
|
377
|
-
let actualCount: number;
|
|
378
|
-
if (check.actual.kind === 'dir_count') {
|
|
379
|
-
actualCount = this.countFromDir(check.actual.path, check.actual.extension || '.ts', check.actual.exclude || [], ctx.projectPath);
|
|
380
|
-
} else if (check.actual.kind === 'grep_count') {
|
|
381
|
-
actualCount = this.countFromGrep(ctx.projectPath, check.actual.glob, check.actual.pattern);
|
|
382
|
-
} else {
|
|
383
|
-
actualCount = check.actual.value;
|
|
384
|
-
}
|
|
344
|
+
const content = readFileSync(docPath, 'utf-8');
|
|
385
345
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
346
|
+
// 从文档中提取声明的计数
|
|
347
|
+
const countRegex = new RegExp(check.pattern);
|
|
348
|
+
const countMatch = content.match(countRegex);
|
|
349
|
+
if (!countMatch || countMatch[1] === undefined) {
|
|
350
|
+
return {
|
|
351
|
+
type: 'doc_regex_count',
|
|
352
|
+
label: `${check.doc} / ${check.label}`,
|
|
353
|
+
pass: true,
|
|
354
|
+
message: `未在 ${check.doc} 中找到匹配 "${check.label}" 的计数行`,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
393
357
|
|
|
394
|
-
|
|
358
|
+
const docCount = parseInt(countMatch[1], 10);
|
|
359
|
+
if (isNaN(docCount)) {
|
|
395
360
|
return {
|
|
396
361
|
type: 'doc_regex_count',
|
|
397
362
|
label: `${check.doc} / ${check.label}`,
|
|
398
|
-
pass,
|
|
399
|
-
message:
|
|
400
|
-
detail: { docCount, actualCount },
|
|
363
|
+
pass: true,
|
|
364
|
+
message: `计数解析失败: ${countMatch[1]}`,
|
|
401
365
|
};
|
|
402
|
-
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// 获取实际计数
|
|
369
|
+
let actualCount: number;
|
|
370
|
+
if (check.actual.kind === 'dir_count') {
|
|
371
|
+
actualCount = this.countFromDir(check.actual.path, check.actual.extension || '.ts', check.actual.exclude || [], ctx.projectPath);
|
|
372
|
+
} else if (check.actual.kind === 'grep_count') {
|
|
373
|
+
actualCount = this.countFromGrep(ctx.projectPath, check.actual.glob, check.actual.pattern);
|
|
374
|
+
} else {
|
|
375
|
+
actualCount = check.actual.value;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (actualCount < 0) {
|
|
403
379
|
return {
|
|
404
380
|
type: 'doc_regex_count',
|
|
405
381
|
label: `${check.doc} / ${check.label}`,
|
|
406
382
|
pass: true,
|
|
407
383
|
};
|
|
408
384
|
}
|
|
385
|
+
|
|
386
|
+
const pass = docCount === actualCount;
|
|
387
|
+
return {
|
|
388
|
+
type: 'doc_regex_count',
|
|
389
|
+
label: `${check.doc} / ${check.label}`,
|
|
390
|
+
pass,
|
|
391
|
+
message: pass ? undefined : `${check.label}: 文档 ${docCount} → 实际 ${actualCount}`,
|
|
392
|
+
detail: { docCount, actualCount },
|
|
393
|
+
};
|
|
409
394
|
}
|
|
410
395
|
|
|
411
396
|
/**
|
|
@@ -420,29 +405,26 @@ export class FreshnessRunner {
|
|
|
420
405
|
const absDir = join(projectPath, dirPath);
|
|
421
406
|
if (!existsSync(absDir)) return -1;
|
|
422
407
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
408
|
+
// existsSync 过了却读不出 = 真 IO 故障 → 抛出(fail-fast),不再吞成 -1 假 pass
|
|
409
|
+
const entries = readdirSync(absDir, { withFileTypes: true });
|
|
410
|
+
const excludeSet = new Set(exclude);
|
|
426
411
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
412
|
+
let count = 0;
|
|
413
|
+
for (const entry of entries) {
|
|
414
|
+
if (excludeSet.has(entry.name)) continue;
|
|
430
415
|
|
|
431
|
-
|
|
432
|
-
|
|
416
|
+
if (entry.isDirectory() && !entry.name.startsWith('__') && !entry.name.startsWith('.')) {
|
|
417
|
+
// 目录:计 1(.ts 过滤不适用于目录)
|
|
418
|
+
count++;
|
|
419
|
+
} else if (entry.isFile() && entry.name.endsWith(extension)) {
|
|
420
|
+
// 排除 .d.ts
|
|
421
|
+
if (!entry.name.endsWith('.d.ts')) {
|
|
433
422
|
count++;
|
|
434
|
-
} else if (entry.isFile() && entry.name.endsWith(extension)) {
|
|
435
|
-
// 排除 .d.ts
|
|
436
|
-
if (!entry.name.endsWith('.d.ts')) {
|
|
437
|
-
count++;
|
|
438
|
-
}
|
|
439
423
|
}
|
|
440
424
|
}
|
|
441
|
-
|
|
442
|
-
return count;
|
|
443
|
-
} catch {
|
|
444
|
-
return -1;
|
|
445
425
|
}
|
|
426
|
+
|
|
427
|
+
return count;
|
|
446
428
|
}
|
|
447
429
|
|
|
448
430
|
/**
|
|
@@ -453,45 +435,39 @@ export class FreshnessRunner {
|
|
|
453
435
|
globPattern: string,
|
|
454
436
|
pattern: string
|
|
455
437
|
): number {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
const absGlob = join(projectPath, globPattern);
|
|
438
|
+
// globPattern 如 "src/gates/*.ts"
|
|
439
|
+
const absGlob = join(projectPath, globPattern);
|
|
459
440
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
441
|
+
// 分离目录和文件名模式
|
|
442
|
+
const lastSlash = absGlob.lastIndexOf('/');
|
|
443
|
+
const searchDir = absGlob.substring(0, lastSlash);
|
|
444
|
+
const filePattern = absGlob.substring(lastSlash + 1);
|
|
464
445
|
|
|
465
|
-
|
|
446
|
+
if (!existsSync(searchDir)) return -1;
|
|
466
447
|
|
|
467
|
-
|
|
468
|
-
|
|
448
|
+
// 将 glob * 转换为简单的 endsWith 检查
|
|
449
|
+
const suffix = filePattern.replace(/\*/g, '');
|
|
469
450
|
|
|
470
|
-
|
|
451
|
+
// fail-fast:目录在而读不出、文件扫描中途不可读、pattern 非法等真异常直接抛,
|
|
452
|
+
// 不再吞成 -1(-1 在调用方 = 静默 pass,会把计数 bug 变成「永远通过」)
|
|
453
|
+
const entries = readdirSync(searchDir, { withFileTypes: true });
|
|
471
454
|
|
|
472
|
-
|
|
473
|
-
|
|
455
|
+
// 正则提出循环:String.match 带 g flag 时不携带 lastIndex 状态(每次调用内部归零),复用安全
|
|
456
|
+
const matchRe = new RegExp(pattern, 'g');
|
|
474
457
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
try {
|
|
481
|
-
const content = readFileSync(join(searchDir, entry.name), 'utf-8');
|
|
482
|
-
const matches = content.match(matchRe);
|
|
483
|
-
if (matches) {
|
|
484
|
-
count += matches.length;
|
|
485
|
-
}
|
|
486
|
-
} catch {
|
|
487
|
-
// skip
|
|
488
|
-
}
|
|
489
|
-
}
|
|
458
|
+
let count = 0;
|
|
459
|
+
for (const entry of entries) {
|
|
460
|
+
if (!entry.isFile()) continue;
|
|
461
|
+
if (!entry.name.endsWith(suffix)) continue;
|
|
490
462
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
463
|
+
const content = readFileSync(join(searchDir, entry.name), 'utf-8');
|
|
464
|
+
const matches = content.match(matchRe);
|
|
465
|
+
if (matches) {
|
|
466
|
+
count += matches.length;
|
|
467
|
+
}
|
|
494
468
|
}
|
|
469
|
+
|
|
470
|
+
return count;
|
|
495
471
|
}
|
|
496
472
|
|
|
497
473
|
// ── helpers ──────────────────────────────────────────────────────
|
|
@@ -108,6 +108,8 @@ export function createGitEvidence(
|
|
|
108
108
|
try {
|
|
109
109
|
result = { ok: true, stdout: run(command, projectPath) };
|
|
110
110
|
} catch {
|
|
111
|
+
// 协议语义(非吞错):git 命令失败 → 结构化 {ok:false},消费方经
|
|
112
|
+
// stagedDiffAvailable / headDirs===null 各自判定降级方向,此处不抛不藏
|
|
111
113
|
result = { ok: false, stdout: '' };
|
|
112
114
|
}
|
|
113
115
|
memo.set(command, result);
|
|
@@ -36,13 +36,10 @@ export interface MarkerBlock {
|
|
|
36
36
|
after: string;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** 读文件内容;不存在返回 null(在调用方语义里是「无注入对象」),读失败抛出 */
|
|
39
40
|
export function readIfExists(filePath: string): string | null {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return typeof content === 'string' ? content : null;
|
|
43
|
-
} catch {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
41
|
+
if (!fs.existsSync(filePath)) return null;
|
|
42
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
/** 定位完整标记对:两标记俱在且顺序正确 */
|
|
@@ -19,6 +19,7 @@ import { PRESETS_BY_NAME, STANDARD_PRESET } from '../presets';
|
|
|
19
19
|
import { filterEnabledEntries } from './effective-set';
|
|
20
20
|
import { loadAppConstraints } from './app-constraints-loader';
|
|
21
21
|
import { resolveRunEnv, type RunEnv, type RunTarget } from './constraints/run-env';
|
|
22
|
+
import { attempt } from '../utils/attempt';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* 默认配置
|
|
@@ -49,18 +50,18 @@ export type CapabilitiesMode = NonNullable<CapabilitiesConfig['mode']>;
|
|
|
49
50
|
/**
|
|
50
51
|
* 读取 governance 段(全仓唯一手写钻取点,工单 84)
|
|
51
52
|
*
|
|
52
|
-
* 配置缺失 /
|
|
53
|
+
* 配置缺失 / 形状不符时返回 undefined,由调用方按未配置处理。
|
|
54
|
+
* 解析失败经 attempt 显式降级为 undefined(工单 84 triage 裁决口径:解析失败 = 约定未采用,
|
|
55
|
+
* 访问器不替调用方决定要不要炸;执法面要感知脏配置请用 loadRawProjectConfig 直读)。
|
|
53
56
|
* 入参形状见 loadRawProjectConfig:传 RunEnv 即与本 run 其余消费方共用同一份 config.yml 读取。
|
|
54
57
|
*/
|
|
55
58
|
export function getGovernanceConfig(target: RunTarget): GovernanceConfig | undefined {
|
|
56
|
-
|
|
59
|
+
return attempt(() => {
|
|
57
60
|
const raw = loadRawProjectConfig(target);
|
|
58
61
|
const governance = raw?.governance;
|
|
59
62
|
if (governance === null || typeof governance !== 'object') return undefined;
|
|
60
63
|
return governance as GovernanceConfig;
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
+
}, () => undefined);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
/**
|