@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
|
@@ -14,6 +14,13 @@ jest.mock('fs/promises', () => ({
|
|
|
14
14
|
access: jest.fn(),
|
|
15
15
|
}));
|
|
16
16
|
|
|
17
|
+
// Mock fs(detectTestCommand 经 utils/package-json 正本读 package.json:
|
|
18
|
+
// readFileSync + ENOENT 判缺失;existsSync 仍供 pyproject/go.mod 等标记探测)
|
|
19
|
+
jest.mock('fs', () => ({
|
|
20
|
+
existsSync: jest.fn(),
|
|
21
|
+
readFileSync: jest.fn(),
|
|
22
|
+
}));
|
|
23
|
+
|
|
17
24
|
// Mock execAsync
|
|
18
25
|
jest.mock('../../../utils/exec', () => ({
|
|
19
26
|
execAsync: jest.fn(),
|
|
@@ -35,31 +42,49 @@ jest.mock('chalk', () => ({
|
|
|
35
42
|
}));
|
|
36
43
|
|
|
37
44
|
const mockFs = fs as jest.Mocked<typeof fs>;
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
46
|
+
const mockExistsSync = (require('fs') as { existsSync: jest.Mock }).existsSync;
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
48
|
+
const mockReadFileSync = (require('fs') as { readFileSync: jest.Mock }).readFileSync;
|
|
38
49
|
const MockPassesGate = PassesGate as jest.MockedClass<typeof PassesGate>;
|
|
39
50
|
const mockExecAsync = execAsync as jest.MockedFunction<typeof execAsync>;
|
|
40
51
|
|
|
41
52
|
describe('passes-gate command', () => {
|
|
42
53
|
let io: CapturingIO;
|
|
54
|
+
/** 当轮 fixture 的 package.json 内容(detectTestCommand 经 readPackageJson 消费) */
|
|
55
|
+
let pkgContent: string;
|
|
43
56
|
|
|
44
57
|
beforeEach(() => {
|
|
45
58
|
|
|
46
59
|
io = captureIO();
|
|
47
60
|
jest.clearAllMocks();
|
|
61
|
+
pkgContent = JSON.stringify({ scripts: { test: 'jest' } });
|
|
62
|
+
// 缺省:package.json 在场(多数用例喂 readFile 脚本表),其余探测标记不在场
|
|
63
|
+
mockExistsSync.mockImplementation((p: string) => String(p).endsWith('package.json'));
|
|
64
|
+
// readPackageJson 口径:单次 readFileSync,ENOENT = 缺失(与真实缺文件行为一致)
|
|
65
|
+
mockReadFileSync.mockImplementation((p: string) => {
|
|
66
|
+
if (!mockExistsSync(p)) {
|
|
67
|
+
const err = new Error(`ENOENT: no such file or directory, open '${p}'`) as NodeJS.ErrnoException;
|
|
68
|
+
err.code = 'ENOENT';
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
return pkgContent;
|
|
72
|
+
});
|
|
48
73
|
});
|
|
49
74
|
|
|
50
75
|
describe('runPassesGate', () => {
|
|
51
76
|
it('应该跳过无测试命令的情况', async () => {
|
|
52
|
-
|
|
53
|
-
|
|
77
|
+
// 任何项目标记都不在场(package.json / pyproject.toml / pytest.ini / go.mod)
|
|
78
|
+
mockExistsSync.mockReturnValue(false);
|
|
54
79
|
|
|
55
80
|
await runPassesGate({}, io);
|
|
56
81
|
expect(io.outText()).toContain('未检测到测试命令');
|
|
57
82
|
});
|
|
58
83
|
|
|
59
84
|
it('应该通过测试门控', async () => {
|
|
60
|
-
|
|
85
|
+
pkgContent = JSON.stringify({
|
|
61
86
|
scripts: { test: 'jest' },
|
|
62
|
-
})
|
|
87
|
+
});
|
|
63
88
|
|
|
64
89
|
const mockRunTests = jest.fn().mockResolvedValue({
|
|
65
90
|
passed: true,
|
|
@@ -78,9 +103,9 @@ describe('passes-gate command', () => {
|
|
|
78
103
|
});
|
|
79
104
|
|
|
80
105
|
it('应该失败测试门控', async () => {
|
|
81
|
-
|
|
106
|
+
pkgContent = JSON.stringify({
|
|
82
107
|
scripts: { test: 'jest' },
|
|
83
|
-
})
|
|
108
|
+
});
|
|
84
109
|
|
|
85
110
|
const mockRunTests = jest.fn().mockResolvedValue({
|
|
86
111
|
passed: false,
|
|
@@ -101,11 +126,63 @@ describe('passes-gate command', () => {
|
|
|
101
126
|
expect(result).toEqual({ kind: 'fail', reason: 'passes-gate denied: 2/10 个测试失败' });
|
|
102
127
|
});
|
|
103
128
|
|
|
104
|
-
it('
|
|
105
|
-
|
|
129
|
+
it('失败计数读不到时如实显示「未取到计数」,不编造成 1 个用例失败', async () => {
|
|
130
|
+
pkgContent = JSON.stringify({
|
|
106
131
|
scripts: { test: 'jest' },
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const mockRunTests = jest.fn().mockResolvedValue({
|
|
135
|
+
passed: false,
|
|
136
|
+
passedTests: 0,
|
|
137
|
+
failedTests: null,
|
|
138
|
+
totalTests: 0,
|
|
139
|
+
duration: 1000,
|
|
140
|
+
failures: [],
|
|
141
|
+
message: '测试命令以退出码 137 终止',
|
|
142
|
+
});
|
|
143
|
+
(MockPassesGate as any).mockImplementation(() => ({
|
|
144
|
+
runTests: mockRunTests,
|
|
107
145
|
}));
|
|
108
146
|
|
|
147
|
+
const result = await runPassesGate({}, io);
|
|
148
|
+
|
|
149
|
+
expect(io.outText()).toContain('未取到计数');
|
|
150
|
+
expect(io.outText()).not.toMatch(/失败: 1\//);
|
|
151
|
+
expect(io.outText()).toContain('测试命令以退出码 137 终止');
|
|
152
|
+
expect(result).toEqual({
|
|
153
|
+
kind: 'fail',
|
|
154
|
+
reason: 'passes-gate denied: 未取到失败计数(命令判负且输出无汇总行)|测试命令以退出码 137 终止',
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('失败计数为 0 但判负(allowPartialPass 之外的形状)仍显示数值而非「未取到」', async () => {
|
|
159
|
+
pkgContent = JSON.stringify({
|
|
160
|
+
scripts: { test: 'jest' },
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const mockRunTests = jest.fn().mockResolvedValue({
|
|
164
|
+
passed: false,
|
|
165
|
+
passedTests: 10,
|
|
166
|
+
failedTests: 0,
|
|
167
|
+
totalTests: 10,
|
|
168
|
+
duration: 1000,
|
|
169
|
+
failures: [],
|
|
170
|
+
});
|
|
171
|
+
(MockPassesGate as any).mockImplementation(() => ({
|
|
172
|
+
runTests: mockRunTests,
|
|
173
|
+
}));
|
|
174
|
+
|
|
175
|
+
await runPassesGate({}, io);
|
|
176
|
+
|
|
177
|
+
expect(io.outText()).toContain('失败: 0/10');
|
|
178
|
+
expect(io.outText()).not.toContain('未取到计数');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('应该处理测试执行错误', async () => {
|
|
182
|
+
pkgContent = JSON.stringify({
|
|
183
|
+
scripts: { test: 'jest' },
|
|
184
|
+
});
|
|
185
|
+
|
|
109
186
|
const mockRunTests = jest.fn().mockRejectedValue(new Error('test failed'));
|
|
110
187
|
(MockPassesGate as any).mockImplementation(() => ({
|
|
111
188
|
runTests: mockRunTests,
|
|
@@ -197,10 +274,8 @@ describe('passes-gate command', () => {
|
|
|
197
274
|
|
|
198
275
|
describe('detectTestCommand', () => {
|
|
199
276
|
it('应该检测 pytest 项目', async () => {
|
|
200
|
-
// package.json
|
|
201
|
-
|
|
202
|
-
// pyproject.toml 存在(Python 标记任一命中即 pytest)
|
|
203
|
-
mockFs.access.mockResolvedValueOnce(undefined); // pyproject.toml
|
|
277
|
+
// package.json 不存在;pyproject.toml 存在(Python 标记任一命中即 pytest)
|
|
278
|
+
mockExistsSync.mockImplementation((p: string) => String(p).endsWith('pyproject.toml'));
|
|
204
279
|
|
|
205
280
|
const mockRunTests = jest.fn().mockResolvedValue({
|
|
206
281
|
passed: true, passedTests: 5, failedTests: 0, totalTests: 5, duration: 500, failures: [],
|
|
@@ -212,13 +287,8 @@ describe('passes-gate command', () => {
|
|
|
212
287
|
});
|
|
213
288
|
|
|
214
289
|
it('应该检测 Go 项目', async () => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
mockFs.access.mockReset();
|
|
218
|
-
mockFs.access
|
|
219
|
-
.mockRejectedValueOnce(new Error('no file')) // pyproject.toml
|
|
220
|
-
.mockRejectedValueOnce(new Error('no file')) // pytest.ini
|
|
221
|
-
.mockResolvedValueOnce(undefined); // go.mod
|
|
290
|
+
// package.json / pyproject.toml / pytest.ini 均不在场,go.mod 在
|
|
291
|
+
mockExistsSync.mockImplementation((p: string) => String(p).endsWith('go.mod'));
|
|
222
292
|
|
|
223
293
|
const mockRunTests = jest.fn().mockResolvedValue({
|
|
224
294
|
passed: true, passedTests: 5, failedTests: 0, totalTests: 5, duration: 500, failures: [],
|
|
@@ -229,10 +299,17 @@ describe('passes-gate command', () => {
|
|
|
229
299
|
expect(MockPassesGate).toHaveBeenCalledWith(expect.objectContaining({ testCommand: 'go test ./...' }));
|
|
230
300
|
});
|
|
231
301
|
|
|
302
|
+
it('package.json 在场但 JSON 损坏 → 抛出(fail-fast,不再吞成「无测试命令」)', async () => {
|
|
303
|
+
mockExistsSync.mockImplementation((p: string) => String(p).endsWith('package.json'));
|
|
304
|
+
pkgContent = 'NOT VALID JSON{{{';
|
|
305
|
+
|
|
306
|
+
await expect(runPassesGate({}, io)).rejects.toThrow(SyntaxError);
|
|
307
|
+
});
|
|
308
|
+
|
|
232
309
|
it('应该检测 test:ci 脚本', async () => {
|
|
233
|
-
|
|
310
|
+
pkgContent = JSON.stringify({
|
|
234
311
|
scripts: { 'test:ci': 'jest --ci' },
|
|
235
|
-
})
|
|
312
|
+
});
|
|
236
313
|
|
|
237
314
|
const mockRunTests = jest.fn().mockResolvedValue({
|
|
238
315
|
passed: true, passedTests: 5, failedTests: 0, totalTests: 5, duration: 500, failures: [],
|
|
@@ -244,10 +321,9 @@ describe('passes-gate command', () => {
|
|
|
244
321
|
});
|
|
245
322
|
|
|
246
323
|
it('应该跳过默认 echo 测试脚本', async () => {
|
|
247
|
-
|
|
248
|
-
mockFs.readFile.mockResolvedValue(JSON.stringify({
|
|
324
|
+
pkgContent = JSON.stringify({
|
|
249
325
|
scripts: { test: 'echo "Error: no test specified"' },
|
|
250
|
-
})
|
|
326
|
+
});
|
|
251
327
|
mockFs.access.mockReset();
|
|
252
328
|
mockFs.access.mockRejectedValue(new Error('no file'));
|
|
253
329
|
|
|
@@ -42,17 +42,14 @@ const PACKAGE_JSON = JSON.stringify({
|
|
|
42
42
|
scripts: { test: 'node ./mark.js' },
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
/**
|
|
45
|
+
/** acceptance 形状:checked 决定判定,两侧只差 checked 值 → 读错文件必然改变结论 */
|
|
46
46
|
function tasksYml(checked: boolean): string {
|
|
47
47
|
return [
|
|
48
48
|
'tasks:',
|
|
49
49
|
' - id: TASK-001',
|
|
50
50
|
' title: 锚定用例',
|
|
51
|
-
'
|
|
52
|
-
' -
|
|
53
|
-
' description: 需要人工确认的验收条件',
|
|
54
|
-
' type: manual',
|
|
55
|
-
' required: true',
|
|
51
|
+
' acceptance:',
|
|
52
|
+
' - description: 需要人工确认的验收条件',
|
|
56
53
|
` checked: ${checked}`,
|
|
57
54
|
'',
|
|
58
55
|
].join('\n');
|
|
@@ -310,9 +310,10 @@ smoke('bin/harness.js 端到端(dist 存在时)', () => {
|
|
|
310
310
|
expect(r.status).toBe(0);
|
|
311
311
|
expect(JSON.parse(r.stdout)).toHaveProperty('total');
|
|
312
312
|
expect(r.implModules).toEqual([
|
|
313
|
-
// #133 起 knowledge
|
|
313
|
+
// #133 起 knowledge 的投影面随命令模块一并懒加载(探针按字典序列出加载项);
|
|
314
|
+
// Phase 3 拆分后子命令实现是 knowledge/ 目录下的一文件一子命令
|
|
314
315
|
expect.stringContaining('/dist/cli/commands/knowledge-view.js'),
|
|
315
|
-
expect.stringContaining('/dist/cli/commands/knowledge.js'),
|
|
316
|
+
expect.stringContaining('/dist/cli/commands/knowledge/list.js'),
|
|
316
317
|
]);
|
|
317
318
|
});
|
|
318
319
|
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Seam:release(options, io) 公开入口。
|
|
5
5
|
* 隔离面:
|
|
6
6
|
* - child_process.execSync → 按命令前缀分发的 fixture(git/npm/tsc 全部 mock,绝不真执行)
|
|
7
|
-
* - fs.existsSync
|
|
7
|
+
* - fs.existsSync → dist 关键文件视为存在;fs.readFileSync → fixture 包 package.json
|
|
8
|
+
* (pkgExists=false 时抛 ENOENT,与真实缺文件行为一致)
|
|
8
9
|
* - 输出 → 注入 captureIO(不再 spyOn(process,'exit') / 断言彩色字符串)
|
|
9
10
|
*
|
|
10
11
|
* 判定结果经返回值外溢:每个前置闸门的失败原因含闸门标识(gate <id>),
|
|
@@ -117,7 +118,18 @@ describe('release command', () => {
|
|
|
117
118
|
if (String(p).endsWith('package.json')) return pkgExists;
|
|
118
119
|
return true; // dist 关键文件视为存在
|
|
119
120
|
});
|
|
120
|
-
mockFs.readFileSync.
|
|
121
|
+
mockFs.readFileSync.mockImplementation(((p: fs.PathOrFileDescriptor) => {
|
|
122
|
+
if (String(p).endsWith('package.json')) {
|
|
123
|
+
if (!pkgExists) {
|
|
124
|
+
// 与真实缺文件行为一致:readFileSync 抛 ENOENT(readPackageJson 据此判缺失)
|
|
125
|
+
const err = new Error(`ENOENT: no such file or directory, open '${String(p)}'`) as NodeJS.ErrnoException;
|
|
126
|
+
err.code = 'ENOENT';
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
return PKG_JSON;
|
|
130
|
+
}
|
|
131
|
+
return PKG_JSON;
|
|
132
|
+
}) as typeof fs.readFileSync);
|
|
121
133
|
|
|
122
134
|
flow();
|
|
123
135
|
});
|
|
@@ -132,6 +144,16 @@ describe('release command', () => {
|
|
|
132
144
|
expect(execCommands()).toEqual([]);
|
|
133
145
|
});
|
|
134
146
|
|
|
147
|
+
test('闸门 1b package.json 缺 version 字段:fail 定位 version-field 闸门,零子进程调用', async () => {
|
|
148
|
+
mockFs.readFileSync.mockImplementation((() => JSON.stringify({ name: '@dommaker/harness' })) as unknown as typeof fs.readFileSync);
|
|
149
|
+
|
|
150
|
+
const result = await release({}, io);
|
|
151
|
+
|
|
152
|
+
expect(result).toEqual(gateFail('version-field'));
|
|
153
|
+
expect(io.errLines().join('\n')).toContain('version');
|
|
154
|
+
expect(execCommands()).toEqual([]);
|
|
155
|
+
});
|
|
156
|
+
|
|
135
157
|
test('闸门 2 非 master/main 分支:fail 定位 branch 闸门,后续闸门不执行', async () => {
|
|
136
158
|
flow([['git rev-parse --abbrev-ref', () => 'feat/x']]);
|
|
137
159
|
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* 铁律违规被报成 violations: [] / passed = 全量(假绿)。
|
|
7
7
|
* 修复后 report 直调 checker.collectConstraints(不抛、全量收集),违规如实上报。
|
|
8
8
|
*
|
|
9
|
-
* fixture:CAPABILITIES.md 登记幽灵文件 → docs_freshness
|
|
10
|
-
*
|
|
9
|
+
* fixture:CAPABILITIES.md 登记幽灵文件 → docs_freshness 必违规
|
|
10
|
+
* (file_modification 触发域内唯一铁律;ADR-0032 起降 warning 级,
|
|
11
|
+
* 违规落 warningViolations/violations,`failed` 只计 error 级)。
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
import { describe, it, expect } from '@jest/globals';
|
|
@@ -28,8 +29,8 @@ function parseJsonReport(output: string) {
|
|
|
28
29
|
return JSON.parse(output.slice(start, end + 1));
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
describe('report
|
|
32
|
-
it('docs_freshness 违规 →
|
|
32
|
+
describe('report 违规如实上报(假绿回归)', () => {
|
|
33
|
+
it('docs_freshness 违规 → warningViolations ≥ 1、violations 点名、passed < total', async () => {
|
|
33
34
|
const root = createProjectFixture({
|
|
34
35
|
name: 'report-false-green',
|
|
35
36
|
files: { 'CAPABILITIES.md': GHOST_CAPABILITIES },
|
|
@@ -39,8 +40,11 @@ describe('report 铁律违规如实上报(假绿回归)', () => {
|
|
|
39
40
|
await report({ format: 'json', projectPath: root }, io);
|
|
40
41
|
|
|
41
42
|
const data = parseJsonReport(io.outText());
|
|
42
|
-
expect(data.constraints.
|
|
43
|
+
expect(data.constraints.warningViolations).toBeGreaterThanOrEqual(1);
|
|
43
44
|
expect(data.constraints.violations.map((v: { id: string }) => v.id)).toContain('docs_freshness');
|
|
44
|
-
|
|
45
|
+
// ADR-0032:docs_freshness 降 warning 级——违规不再计 error 级 failed,
|
|
46
|
+
// report 的 passed 公式(result.passed ? total : total - violations.length)
|
|
47
|
+
// 对纯 warning 违规保持 passed = total,原 passed < total 钉随之失效
|
|
48
|
+
expect(data.constraints.failed).toBe(0);
|
|
45
49
|
});
|
|
46
50
|
});
|
|
@@ -88,9 +88,9 @@ export async function listAcceptanceCriteria(
|
|
|
88
88
|
try {
|
|
89
89
|
const content = await fs.readFile(tasksPath, 'utf-8');
|
|
90
90
|
const yaml = await import('js-yaml');
|
|
91
|
-
const tasks = yaml.load(content)
|
|
91
|
+
const tasks: unknown = yaml.load(content);
|
|
92
92
|
|
|
93
|
-
if (
|
|
93
|
+
if (typeof tasks !== 'object' || tasks === null) {
|
|
94
94
|
log(io, chalk.yellow('⚠️ 未找到任务定义'));
|
|
95
95
|
return { kind: 'skip', reason: `未找到任务定义: ${tasksPath}` };
|
|
96
96
|
}
|
|
@@ -98,10 +98,10 @@ export async function listAcceptanceCriteria(
|
|
|
98
98
|
for (const [taskId, task] of Object.entries(tasks)) {
|
|
99
99
|
if (typeof task === 'object' && task !== null) {
|
|
100
100
|
log(io, chalk.cyan(`${taskId}:`));
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
log(io, chalk.gray(` ${i + 1}. ${
|
|
101
|
+
const criteria = (task as { acceptanceCriteria?: unknown }).acceptanceCriteria;
|
|
102
|
+
if (Array.isArray(criteria)) {
|
|
103
|
+
criteria.forEach((c: unknown, i: number) => {
|
|
104
|
+
log(io, chalk.gray(` ${i + 1}. ${String(c)}`));
|
|
105
105
|
});
|
|
106
106
|
} else {
|
|
107
107
|
log(io, chalk.gray(' (无验收标准)'));
|
|
@@ -110,8 +110,9 @@ export async function listAcceptanceCriteria(
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
return { kind: 'ok' };
|
|
113
|
-
} catch (error:
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
} catch (error: unknown) {
|
|
114
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
115
|
+
log(io, chalk.red(`❌ 读取 tasks.yml 失败: ${message}`));
|
|
116
|
+
return { kind: 'skip', reason: `读取 tasks.yml 失败: ${message}` };
|
|
116
117
|
}
|
|
117
118
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { createCommandGate, DEFAULT_COMMAND_BLACKLIST } from '../../gates/command';
|
|
14
|
-
import type { CommandBlacklistRule } from '../../
|
|
14
|
+
import type { CommandBlacklistRule } from '../../types/gate';
|
|
15
15
|
import { log, logError, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
16
16
|
import { gateCommandResult } from '../gate-command';
|
|
17
17
|
|
|
@@ -157,8 +157,9 @@ export async function runRetireInteractive(
|
|
|
157
157
|
console.error(chalk.yellow(`⚠️ trace 文件有 ${report.skippedLines} 行损坏已跳过,候选只基于其余合法记录`));
|
|
158
158
|
}
|
|
159
159
|
const { ask, close } = createAsk(io);
|
|
160
|
-
// 退役结果打印走注入流(与 readline
|
|
161
|
-
|
|
160
|
+
// 退役结果打印走注入流(与 readline 提示同一去向);
|
|
161
|
+
// WritableStream.write(chunk: any) 结构化满足 CommandIO 的最小可写接口
|
|
162
|
+
const out: CommandIO = { stdout: io.output, stderr: io.output };
|
|
162
163
|
|
|
163
164
|
try {
|
|
164
165
|
let selectedIds: string[] = [];
|
|
@@ -83,7 +83,7 @@ export async function contract(
|
|
|
83
83
|
|
|
84
84
|
if (r.details?.breakingChanges) {
|
|
85
85
|
lines.push('', chalk.red('破坏性变更:'));
|
|
86
|
-
(r.details.breakingChanges as
|
|
86
|
+
(r.details.breakingChanges as Array<{ type: string; path: string; description?: string }>).forEach((change) => {
|
|
87
87
|
lines.push(chalk.red(` - ${change.type}: ${change.path}`));
|
|
88
88
|
if (change.description) {
|
|
89
89
|
lines.push(chalk.gray(` ${change.description}`));
|
|
@@ -119,14 +119,28 @@ export async function validateSchema(
|
|
|
119
119
|
const fullPath = path.join(projectPath, contractPath);
|
|
120
120
|
const content = await fs.readFile(fullPath, 'utf-8');
|
|
121
121
|
|
|
122
|
-
let
|
|
122
|
+
let parsed: unknown;
|
|
123
123
|
try {
|
|
124
|
-
|
|
125
|
-
} catch (e:
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
parsed = yaml.load(content);
|
|
125
|
+
} catch (e: unknown) {
|
|
126
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
127
|
+
log(io, chalk.red(`❌ YAML 解析错误: ${message}`));
|
|
128
|
+
return { kind: 'fail', reason: `contract YAML parse error: ${message}` };
|
|
128
129
|
}
|
|
129
130
|
|
|
131
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
132
|
+
log(io, chalk.red('❌ Schema 验证失败: 契约文件不是 YAML 对象'));
|
|
133
|
+
return { kind: 'fail', reason: 'contract schema invalid: not a YAML object' };
|
|
134
|
+
}
|
|
135
|
+
const schema = parsed as {
|
|
136
|
+
openapi?: string;
|
|
137
|
+
info?: { title?: string; version?: string };
|
|
138
|
+
paths?: Record<string, Record<string, unknown>>;
|
|
139
|
+
};
|
|
140
|
+
// 校验通过后消费的三处字段取本地常量(校验不收窄类型)
|
|
141
|
+
const info = schema.info;
|
|
142
|
+
const paths = schema.paths;
|
|
143
|
+
|
|
130
144
|
// 基本验证
|
|
131
145
|
const errors: string[] = [];
|
|
132
146
|
|
|
@@ -157,18 +171,19 @@ export async function validateSchema(
|
|
|
157
171
|
log(io);
|
|
158
172
|
log(io, chalk.gray('Schema 信息:'));
|
|
159
173
|
log(io, chalk.gray(` 版本: ${schema.openapi}`));
|
|
160
|
-
log(io, chalk.gray(` 标题: ${
|
|
161
|
-
log(io, chalk.gray(` API 版本: ${
|
|
174
|
+
log(io, chalk.gray(` 标题: ${info?.title}`));
|
|
175
|
+
log(io, chalk.gray(` API 版本: ${info?.version}`));
|
|
162
176
|
|
|
163
|
-
if (
|
|
164
|
-
const endpoints = Object.keys(
|
|
165
|
-
Object.keys(
|
|
177
|
+
if (paths) {
|
|
178
|
+
const endpoints = Object.keys(paths).flatMap(path =>
|
|
179
|
+
Object.keys(paths[path]).map(method => `${method.toUpperCase()} ${path}`)
|
|
166
180
|
);
|
|
167
181
|
log(io, chalk.gray(` 端点数: ${endpoints.length}`));
|
|
168
182
|
}
|
|
169
183
|
return { kind: 'ok' };
|
|
170
|
-
} catch (error:
|
|
171
|
-
|
|
172
|
-
|
|
184
|
+
} catch (error: unknown) {
|
|
185
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
186
|
+
log(io, chalk.red(`❌ 验证失败: ${message}`));
|
|
187
|
+
return { kind: 'fail', reason: `contract schema read error: ${message}` };
|
|
173
188
|
}
|
|
174
189
|
}
|
|
@@ -248,22 +248,23 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
248
248
|
{ flags: '--json', description: 'JSON 格式输出', defaultValue: false },
|
|
249
249
|
],
|
|
250
250
|
subcommands: {
|
|
251
|
-
// 纯投影条目:commander options
|
|
252
|
-
|
|
251
|
+
// 纯投影条目:commander options 与处理器参数同名,原样传入(编组归命令模块)。
|
|
252
|
+
// knowledge/ 目录一子命令一文件(Phase 3 拆分,原 knowledge.ts 单文件 820 行)
|
|
253
|
+
list: { impl: { module: 'knowledge/list', export: 'knowledgeList' }, aliases: ['ls'] },
|
|
253
254
|
search: {
|
|
254
|
-
impl: { module: 'knowledge', export: 'knowledgeSearchCommand' },
|
|
255
|
+
impl: { module: 'knowledge/search', export: 'knowledgeSearchCommand' },
|
|
255
256
|
aliases: ['s'],
|
|
256
257
|
withPositionals: true,
|
|
257
258
|
},
|
|
258
|
-
import: { impl: { module: 'knowledge', export: 'knowledgeImport' }, aliases: ['i'] },
|
|
259
|
-
decay: { impl: { module: 'knowledge', export: 'knowledgeDecay' }, aliases: ['d'] },
|
|
260
|
-
stats: { impl: { module: 'knowledge', export: 'knowledgeStats' }, aliases: ['st'] },
|
|
261
|
-
'sync-rag': { impl: { module: 'knowledge', export: 'knowledgeSyncRag' } },
|
|
262
|
-
audit: { impl: { module: 'knowledge', export: 'knowledgeAudit' }, aliases: ['a'] },
|
|
263
|
-
snapshot: { impl: { module: 'knowledge', export: 'knowledgeSnapshot' } },
|
|
264
|
-
migrate: { impl: { module: 'knowledge', export: 'knowledgeMigrate' } },
|
|
265
|
-
index: { impl: { module: 'knowledge', export: 'knowledgeIndex' }, aliases: ['idx'] },
|
|
266
|
-
health: { impl: { module: 'knowledge', export: 'knowledgeHealth' }, aliases: ['h'] },
|
|
259
|
+
import: { impl: { module: 'knowledge/import', export: 'knowledgeImport' }, aliases: ['i'] },
|
|
260
|
+
decay: { impl: { module: 'knowledge/decay', export: 'knowledgeDecay' }, aliases: ['d'] },
|
|
261
|
+
stats: { impl: { module: 'knowledge/stats', export: 'knowledgeStats' }, aliases: ['st'] },
|
|
262
|
+
'sync-rag': { impl: { module: 'knowledge/sync-rag', export: 'knowledgeSyncRag' } },
|
|
263
|
+
audit: { impl: { module: 'knowledge/audit', export: 'knowledgeAudit' }, aliases: ['a'] },
|
|
264
|
+
snapshot: { impl: { module: 'knowledge/snapshot', export: 'knowledgeSnapshot' } },
|
|
265
|
+
migrate: { impl: { module: 'knowledge/migrate', export: 'knowledgeMigrate' } },
|
|
266
|
+
index: { impl: { module: 'knowledge/index', export: 'knowledgeIndex' }, aliases: ['idx'] },
|
|
267
|
+
health: { impl: { module: 'knowledge/health', export: 'knowledgeHealth' }, aliases: ['h'] },
|
|
267
268
|
},
|
|
268
269
|
},
|
|
269
270
|
{
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* init 的 CI 平台解析(harness#143;Phase 3 自 init.ts 拆出,纯移位)
|
|
3
|
+
*
|
|
4
|
+
* 解析链 = flag > config.yml 的 `ci.platform` > `github`。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { attempt } from '../../../utils/attempt';
|
|
8
|
+
import { loadRawProjectConfig } from '../../../core/project-config-loader';
|
|
9
|
+
import type { CiConfig, CiPlatform } from '../../../types/project-config';
|
|
10
|
+
|
|
11
|
+
/** `--ci` 的可取值域(`none` = 不创建任何服务端 CI 文件,治理 CI 面亦不建,即旧 `--no-github-actions`) */
|
|
12
|
+
const CI_FLAG_VALUES: Array<CiPlatform | 'none'> = ['github', 'gitlab', 'none'];
|
|
13
|
+
|
|
14
|
+
/** CI 平台解析结果(`error` 属用法错误,命令层直接非零退出,不落任何文件) */
|
|
15
|
+
export type CiResolution =
|
|
16
|
+
| { kind: 'ok'; platform: CiPlatform | 'none'; warning?: string }
|
|
17
|
+
| { kind: 'error'; reason: string };
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 解析 CI 平台(harness#143 决议 ①④):flag > config.yml 的 `ci.platform` > `github`
|
|
21
|
+
*
|
|
22
|
+
* 不做 remote URL 自动检测:init 常跑在首次 push 之前无 remote 可测,而检测错的代价是
|
|
23
|
+
* 静默写错文件。`--no-github-actions` 保留为 `--ci none` 的废弃别名;它与显式
|
|
24
|
+
* `--ci <非 none>` 同时出现时不猜用户意图,判用法错误。
|
|
25
|
+
*/
|
|
26
|
+
export function resolveCiPlatform(
|
|
27
|
+
options: { ci?: CiPlatform | 'none'; githubActions?: boolean },
|
|
28
|
+
configured: CiPlatform | 'none' | undefined,
|
|
29
|
+
): CiResolution {
|
|
30
|
+
const flag = options.ci;
|
|
31
|
+
if (flag !== undefined && !CI_FLAG_VALUES.includes(flag)) {
|
|
32
|
+
return {
|
|
33
|
+
kind: 'error',
|
|
34
|
+
reason: `--ci 取值非法: ${String(flag)}(可取 ${CI_FLAG_VALUES.join(' | ')})`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (options.githubActions === false) {
|
|
38
|
+
if (flag !== undefined && flag !== 'none') {
|
|
39
|
+
return {
|
|
40
|
+
kind: 'error',
|
|
41
|
+
reason: `--ci ${flag} 与 --no-github-actions(即 --ci none 的废弃别名)冲突,二选一`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
kind: 'ok',
|
|
46
|
+
platform: 'none',
|
|
47
|
+
warning: '⚠️ --no-github-actions 已废弃,请改用 --ci none',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return { kind: 'ok', platform: flag ?? configured ?? 'github' };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 读 config.yml 已持久化的 `ci.platform`(解析链第二级)
|
|
55
|
+
*
|
|
56
|
+
* 缺失 / 形状不符一律按未配置处理;config.yml 解析失败经 attempt 显式降级为未配置——
|
|
57
|
+
* init 是用户首次上手入口,存量脏配置不该炸掉初始化(解析失败会真实抛到用户眼前的
|
|
58
|
+
* 场景是 check/sync-docs 等执法面,那里不兜)。
|
|
59
|
+
*/
|
|
60
|
+
export function readConfiguredCiPlatform(projectPath: string): CiPlatform | 'none' | undefined {
|
|
61
|
+
const raw = attempt(() => loadRawProjectConfig(projectPath), () => undefined);
|
|
62
|
+
const ci = raw?.ci;
|
|
63
|
+
if (ci === null || typeof ci !== 'object') return undefined;
|
|
64
|
+
const platform = (ci as CiConfig).platform;
|
|
65
|
+
return platform !== undefined && CI_FLAG_VALUES.includes(platform) ? platform : undefined;
|
|
66
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* init 的服务端 CI 接线(harness#143 平台维度;Phase 3 自 init.ts 拆出,纯移位)
|
|
3
|
+
*
|
|
4
|
+
* gitlab 只有一个 `.gitlab-ci.yml`(治理任务已在正文里);github 的冲突判定
|
|
5
|
+
* 宽到整个 workflows 目录,需先扫一遍。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as fs from 'fs/promises';
|
|
9
|
+
import { existsSync } from 'fs';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
import type { CiPlatform } from '../../../types/project-config';
|
|
12
|
+
import { type CommandIO } from '../../command-contract';
|
|
13
|
+
import { runPlan, harnessCheckCiFile } from '../scaffold';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 设置服务端 CI 接线(站点形状与冲突面由 scaffold 按平台给)
|
|
17
|
+
*
|
|
18
|
+
* gitlab 只有一个 `.gitlab-ci.yml`,治理任务已在正文里(`governanceLevel` 传给工厂);
|
|
19
|
+
* github 的冲突判定宽到整个 workflows 目录,需先扫一遍。
|
|
20
|
+
*/
|
|
21
|
+
export async function setupCiWiring(
|
|
22
|
+
projectPath: string,
|
|
23
|
+
platform: CiPlatform,
|
|
24
|
+
governanceLevel: string | undefined,
|
|
25
|
+
io: CommandIO,
|
|
26
|
+
): Promise<void> {
|
|
27
|
+
if (platform === 'gitlab') {
|
|
28
|
+
await runPlan([harnessCheckCiFile(projectPath, 'gitlab', [], governanceLevel)], io);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const workflowsDir = path.join(projectPath, '.github', 'workflows');
|
|
32
|
+
await runPlan(
|
|
33
|
+
[harnessCheckCiFile(projectPath, 'github', await findCiWorkflows(workflowsDir))],
|
|
34
|
+
io,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 查找已存在的 CI 工作流文件
|
|
40
|
+
*/
|
|
41
|
+
export async function findCiWorkflows(workflowsDir: string): Promise<string[]> {
|
|
42
|
+
if (!existsSync(workflowsDir)) return [];
|
|
43
|
+
const files = await fs.readdir(workflowsDir);
|
|
44
|
+
// 过滤出可能是 CI 配置的文件
|
|
45
|
+
return files.filter(f =>
|
|
46
|
+
f.endsWith('.yml') || f.endsWith('.yaml')
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* init 的 Git hooks 落盘(Phase 3 自 init.ts 拆出,纯移位)
|
|
3
|
+
*
|
|
4
|
+
* 本地防线两道(harness#144):pre-commit 查暂存的(增量、快反馈),
|
|
5
|
+
* pre-push 查整仓的(全量、兜底)。落盘语义在 scaffold plan。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
import { log, type CommandIO } from '../../command-contract';
|
|
11
|
+
import {
|
|
12
|
+
runPlan,
|
|
13
|
+
nodeScaffoldFs,
|
|
14
|
+
preCommitHookFile,
|
|
15
|
+
prePushHookFile,
|
|
16
|
+
} from '../scaffold';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 设置 Git hooks(无 .git 即整站跳过;落盘语义在 scaffold plan)
|
|
20
|
+
*
|
|
21
|
+
* 两道:pre-commit 查暂存的(增量、快反馈),pre-push 查整仓的(全量、兜底,
|
|
22
|
+
* harness#144)。跳过旗帜 `--no-git-hooks` 在命令层翻成「本站点不进 plan」。
|
|
23
|
+
*/
|
|
24
|
+
export async function setupGitHooks(projectPath: string, io: CommandIO): Promise<void> {
|
|
25
|
+
if (!(await nodeScaffoldFs.exists(path.join(projectPath, '.git')))) {
|
|
26
|
+
log(io, chalk.yellow('⚠️ 未检测到 Git 仓库,跳过 Git hooks'));
|
|
27
|
+
log(io, chalk.gray('💡 初始化 Git 后可运行 npx @dommaker/harness init --print-snippets 查看配置'));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
await runPlan([preCommitHookFile(projectPath), prePushHookFile(projectPath)], io);
|
|
31
|
+
}
|