@dommaker/harness 0.16.6 → 0.16.8
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 +15 -0
- package/README.md +54 -14
- package/bin/harness.js +56 -96
- package/dist/architecture/constraint-engine.d.ts.map +1 -1
- package/dist/architecture/constraint-engine.js +0 -4
- package/dist/architecture/constraint-engine.js.map +1 -1
- package/dist/architecture/cross-project-checker.d.ts.map +1 -1
- package/dist/architecture/cross-project-checker.js +5 -25
- package/dist/architecture/cross-project-checker.js.map +1 -1
- package/dist/cli/commands/analyze-sessions.d.ts +2 -0
- package/dist/cli/commands/analyze-sessions.d.ts.map +1 -1
- package/dist/cli/commands/analyze-sessions.js +25 -181
- package/dist/cli/commands/analyze-sessions.js.map +1 -1
- package/dist/cli/commands/check.d.ts +1 -0
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +24 -216
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/doc-freshness-check.d.ts.map +1 -1
- package/dist/cli/commands/doc-freshness-check.js +14 -28
- package/dist/cli/commands/doc-freshness-check.js.map +1 -1
- package/dist/cli/commands/flow.d.ts.map +1 -1
- package/dist/cli/commands/flow.js +2 -1
- package/dist/cli/commands/flow.js.map +1 -1
- package/dist/cli/commands/init.js +2 -2
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/posteval-plan.d.ts.map +1 -1
- package/dist/cli/commands/posteval-plan.js +0 -1
- package/dist/cli/commands/posteval-plan.js.map +1 -1
- package/dist/cli/commands/release.js +1 -1
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/report.d.ts.map +1 -1
- package/dist/cli/commands/report.js +2 -0
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +12 -23
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.d.ts +19 -0
- package/dist/cli/commands/sync-docs/agents-syncer.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/agents-syncer.js +288 -0
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -0
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +37 -0
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +235 -0
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts +17 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/context-syncer.js +143 -0
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -0
- package/dist/cli/commands/{sync-docs.d.ts → sync-docs/index.d.ts} +9 -2
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/index.js +338 -0
- package/dist/cli/commands/sync-docs/index.js.map +1 -0
- package/dist/cli/commands/sync-docs/preserve-block.d.ts +24 -0
- package/dist/cli/commands/sync-docs/preserve-block.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/preserve-block.js +55 -0
- package/dist/cli/commands/sync-docs/preserve-block.js.map +1 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts +41 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/project-reader.js +183 -0
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -0
- package/dist/cli/commands/update-user-model.d.ts +2 -0
- package/dist/cli/commands/update-user-model.d.ts.map +1 -1
- package/dist/cli/commands/update-user-model.js +19 -90
- package/dist/cli/commands/update-user-model.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +3 -0
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +6 -39
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/session-mining/corrections.d.ts +17 -0
- package/dist/cli/session-mining/corrections.d.ts.map +1 -0
- package/dist/cli/session-mining/corrections.js +58 -0
- package/dist/cli/session-mining/corrections.js.map +1 -0
- package/dist/cli/session-mining/index.d.ts +13 -0
- package/dist/cli/session-mining/index.d.ts.map +1 -0
- package/dist/{core/spec → cli/session-mining}/index.js +9 -3
- package/dist/cli/session-mining/index.js.map +1 -0
- package/dist/cli/session-mining/text.d.ts +31 -0
- package/dist/cli/session-mining/text.d.ts.map +1 -0
- package/dist/cli/session-mining/text.js +126 -0
- package/dist/cli/session-mining/text.js.map +1 -0
- package/dist/cli/session-mining/transcript.d.ts +28 -0
- package/dist/cli/session-mining/transcript.d.ts.map +1 -0
- package/dist/cli/session-mining/transcript.js +123 -0
- package/dist/cli/session-mining/transcript.js.map +1 -0
- package/dist/constraints/lifecycle-runner.d.ts +1 -1
- package/dist/constraints/lifecycle-runner.d.ts.map +1 -1
- package/dist/context/compaction.d.ts.map +1 -1
- package/dist/context/compaction.js +2 -3
- package/dist/context/compaction.js.map +1 -1
- package/dist/context/knowledge-injector.d.ts.map +1 -1
- package/dist/context/tool-output-budget.d.ts +1 -1
- package/dist/context/tool-output-budget.d.ts.map +1 -1
- package/dist/context/tool-output-budget.js +1 -1
- package/dist/context/tool-output-budget.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +24 -0
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -0
- package/dist/core/constraints/capabilities-parser.js +95 -0
- package/dist/core/constraints/capabilities-parser.js.map +1 -0
- package/dist/core/constraints/checker.d.ts +37 -100
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +150 -737
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/always-pass.d.ts +17 -0
- package/dist/core/constraints/checkers/always-pass.d.ts.map +1 -0
- package/dist/core/constraints/checkers/always-pass.js +23 -0
- package/dist/core/constraints/checkers/always-pass.js.map +1 -0
- package/dist/core/constraints/checkers/capability-sync.d.ts +10 -0
- package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -0
- package/dist/core/constraints/checkers/capability-sync.js +60 -0
- package/dist/core/constraints/checkers/capability-sync.js.map +1 -0
- package/dist/core/constraints/checkers/context-doc-sync.d.ts +6 -0
- package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -0
- package/dist/core/constraints/checkers/context-doc-sync.js +35 -0
- package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -0
- package/dist/core/constraints/checkers/docs-freshness.d.ts +10 -0
- package/dist/core/constraints/checkers/docs-freshness.d.ts.map +1 -0
- package/dist/core/constraints/checkers/docs-freshness.js +111 -0
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -0
- package/dist/core/constraints/checkers/guideline-flags.d.ts +9 -0
- package/dist/core/constraints/checkers/guideline-flags.d.ts.map +1 -0
- package/dist/core/constraints/checkers/guideline-flags.js +13 -0
- package/dist/core/constraints/checkers/guideline-flags.js.map +1 -0
- package/dist/core/constraints/checkers/index.d.ts +17 -0
- package/dist/core/constraints/checkers/index.d.ts.map +1 -0
- package/dist/core/constraints/checkers/index.js +82 -0
- package/dist/core/constraints/checkers/index.js.map +1 -0
- package/dist/core/constraints/checkers/iron-flags.d.ts +14 -0
- package/dist/core/constraints/checkers/iron-flags.d.ts.map +1 -0
- package/dist/core/constraints/checkers/iron-flags.js +24 -0
- package/dist/core/constraints/checkers/iron-flags.js.map +1 -0
- package/dist/core/constraints/checkers/no-any-type.d.ts +6 -0
- package/dist/core/constraints/checkers/no-any-type.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-any-type.js +42 -0
- package/dist/core/constraints/checkers/no-any-type.js.map +1 -0
- package/dist/core/constraints/checkers/no-bypass-checkpoint.d.ts +6 -0
- package/dist/core/constraints/checkers/no-bypass-checkpoint.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-bypass-checkpoint.js +40 -0
- package/dist/core/constraints/checkers/no-bypass-checkpoint.js.map +1 -0
- package/dist/core/constraints/checkers/no-excuse-patterns.d.ts +6 -0
- package/dist/core/constraints/checkers/no-excuse-patterns.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-excuse-patterns.js +25 -0
- package/dist/core/constraints/checkers/no-excuse-patterns.js.map +1 -0
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.d.ts +6 -0
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.js +34 -0
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.js.map +1 -0
- package/dist/core/constraints/checkers/no-performative-agreement.d.ts +8 -0
- package/dist/core/constraints/checkers/no-performative-agreement.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-performative-agreement.js +23 -0
- package/dist/core/constraints/checkers/no-performative-agreement.js.map +1 -0
- package/dist/core/constraints/checkers/no-simplification-without-approval.d.ts +6 -0
- package/dist/core/constraints/checkers/no-simplification-without-approval.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-simplification-without-approval.js +30 -0
- package/dist/core/constraints/checkers/no-simplification-without-approval.js.map +1 -0
- package/dist/core/constraints/checkers/no-test-simplification.d.ts +6 -0
- package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-test-simplification.js +29 -0
- package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -0
- package/dist/core/constraints/checkers/test-coverage.d.ts +6 -0
- package/dist/core/constraints/checkers/test-coverage.d.ts.map +1 -0
- package/dist/core/constraints/checkers/test-coverage.js +33 -0
- package/dist/core/constraints/checkers/test-coverage.js.map +1 -0
- package/dist/core/constraints/checkers/types.d.ts +43 -0
- package/dist/core/constraints/checkers/types.d.ts.map +1 -0
- package/dist/core/constraints/checkers/types.js +23 -0
- package/dist/core/constraints/checkers/types.js.map +1 -0
- package/dist/core/constraints/checkers/yagni.d.ts +8 -0
- package/dist/core/constraints/checkers/yagni.d.ts.map +1 -0
- package/dist/core/constraints/checkers/yagni.js +96 -0
- package/dist/core/constraints/checkers/yagni.js.map +1 -0
- package/dist/core/constraints/context-builder.d.ts +67 -0
- package/dist/core/constraints/context-builder.d.ts.map +1 -0
- package/dist/core/constraints/context-builder.js +294 -0
- package/dist/core/constraints/context-builder.js.map +1 -0
- package/dist/core/constraints/definitions/guidelines.d.ts +7 -0
- package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -0
- package/dist/core/constraints/definitions/guidelines.js +641 -0
- package/dist/core/constraints/definitions/guidelines.js.map +1 -0
- package/dist/core/constraints/definitions/iron-laws.d.ts +7 -0
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -0
- package/dist/core/constraints/definitions/iron-laws.js +322 -0
- package/dist/core/constraints/definitions/iron-laws.js.map +1 -0
- package/dist/core/constraints/definitions/tips.d.ts +7 -0
- package/dist/core/constraints/definitions/tips.d.ts.map +1 -0
- package/dist/core/constraints/definitions/tips.js +62 -0
- package/dist/core/constraints/definitions/tips.js.map +1 -0
- package/dist/core/constraints/definitions.d.ts +8 -21
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +15 -1048
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +0 -1
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/index.d.ts +4 -5
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +1 -16
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/interceptor.d.ts.map +1 -1
- package/dist/core/constraints/interceptor.js.map +1 -1
- package/dist/core/index.js +0 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +6 -4
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +46 -13
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/validators/check-handlers/command.d.ts +7 -0
- package/dist/core/validators/check-handlers/command.d.ts.map +1 -0
- package/dist/core/validators/check-handlers/command.js +58 -0
- package/dist/core/validators/check-handlers/command.js.map +1 -0
- package/dist/core/validators/check-handlers/file.d.ts +10 -0
- package/dist/core/validators/check-handlers/file.d.ts.map +1 -0
- package/dist/core/validators/check-handlers/file.js +128 -0
- package/dist/core/validators/check-handlers/file.js.map +1 -0
- package/dist/core/validators/check-handlers/http.d.ts +7 -0
- package/dist/core/validators/check-handlers/http.d.ts.map +1 -0
- package/dist/core/validators/check-handlers/http.js +88 -0
- package/dist/core/validators/check-handlers/http.js.map +1 -0
- package/dist/core/validators/check-handlers/output.d.ts +15 -0
- package/dist/core/validators/check-handlers/output.d.ts.map +1 -0
- package/dist/core/validators/check-handlers/output.js +152 -0
- package/dist/core/validators/check-handlers/output.js.map +1 -0
- package/dist/core/validators/checkpoint.d.ts +4 -72
- package/dist/core/validators/checkpoint.d.ts.map +1 -1
- package/dist/core/validators/checkpoint.js +21 -400
- package/dist/core/validators/checkpoint.js.map +1 -1
- package/dist/core/validators/cso.js +1 -1
- package/dist/core/validators/cso.js.map +1 -1
- package/dist/core/validators/passes-gate.js +2 -2
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/dashboard/stats.d.ts.map +1 -1
- package/dist/dashboard/types.d.ts.map +1 -1
- package/dist/evolution/auto-evolve.d.ts +1 -2
- package/dist/evolution/auto-evolve.d.ts.map +1 -1
- package/dist/evolution/auto-evolve.js +2 -1
- package/dist/evolution/auto-evolve.js.map +1 -1
- package/dist/failure/types.d.ts +5 -85
- package/dist/failure/types.d.ts.map +1 -1
- package/dist/failure/types.js +19 -115
- package/dist/failure/types.js.map +1 -1
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/index.d.ts.map +1 -1
- package/dist/gates/index.js.map +1 -1
- package/dist/gates/performance.js +1 -1
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +1 -1
- package/dist/gates/security.js.map +1 -1
- package/dist/hooks/bootstrap.d.ts.map +1 -1
- package/dist/hooks/bootstrap.js +6 -48
- package/dist/hooks/bootstrap.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/doctor.d.ts.map +1 -1
- package/dist/knowledge/doctor.js.map +1 -1
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/import.js +1 -1
- package/dist/knowledge/import.js.map +1 -1
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +0 -1
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +1 -1
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lint.d.ts +1 -1
- package/dist/knowledge/lint.d.ts.map +1 -1
- package/dist/knowledge/lint.js +2 -2
- package/dist/knowledge/lint.js.map +1 -1
- package/dist/knowledge/primitives/code-structure.d.ts.map +1 -1
- package/dist/knowledge/primitives/code-structure.js +29 -12
- package/dist/knowledge/primitives/code-structure.js.map +1 -1
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/llm/adapter.d.ts +3 -3
- package/dist/llm/adapter.d.ts.map +1 -1
- package/dist/llm/adapter.js +3 -3
- package/dist/llm/adapter.js.map +1 -1
- package/dist/monitoring/analyzer-base.d.ts +50 -0
- package/dist/monitoring/analyzer-base.d.ts.map +1 -0
- package/dist/monitoring/analyzer-base.js +146 -0
- package/dist/monitoring/analyzer-base.js.map +1 -0
- package/dist/monitoring/constraint-doctor.d.ts +3 -46
- package/dist/monitoring/constraint-doctor.d.ts.map +1 -1
- package/dist/monitoring/constraint-doctor.js +11 -113
- package/dist/monitoring/constraint-doctor.js.map +1 -1
- package/dist/monitoring/constraint-evolver.d.ts +9 -63
- package/dist/monitoring/constraint-evolver.d.ts.map +1 -1
- package/dist/monitoring/constraint-evolver.js +8 -10
- package/dist/monitoring/constraint-evolver.js.map +1 -1
- package/dist/monitoring/diagnosis-rules.d.ts +18 -0
- package/dist/monitoring/diagnosis-rules.d.ts.map +1 -0
- package/dist/monitoring/diagnosis-rules.js +119 -0
- package/dist/monitoring/diagnosis-rules.js.map +1 -0
- package/dist/monitoring/knowledge-doctor.d.ts.map +1 -1
- package/dist/monitoring/knowledge-doctor.js.map +1 -1
- package/dist/monitoring/performance-analyzer.d.ts +0 -12
- package/dist/monitoring/performance-analyzer.d.ts.map +1 -1
- package/dist/monitoring/performance-analyzer.js +13 -93
- package/dist/monitoring/performance-analyzer.js.map +1 -1
- package/dist/monitoring/performance-collector.d.ts +0 -8
- package/dist/monitoring/performance-collector.d.ts.map +1 -1
- package/dist/monitoring/performance-collector.js +0 -21
- package/dist/monitoring/performance-collector.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +0 -8
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +9 -91
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/presets/index.d.ts +1 -1
- package/dist/presets/index.d.ts.map +1 -1
- package/dist/presets/index.js +1 -4
- package/dist/presets/index.js.map +1 -1
- package/dist/presets/standard.d.ts +0 -9
- package/dist/presets/standard.d.ts.map +1 -1
- package/dist/presets/standard.js +1 -16
- package/dist/presets/standard.js.map +1 -1
- package/dist/safety/output-guardrail.d.ts +0 -1
- package/dist/safety/output-guardrail.d.ts.map +1 -1
- package/dist/safety/output-guardrail.js +0 -3
- package/dist/safety/output-guardrail.js.map +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/types/constraint.d.ts +5 -59
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js +1 -39
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/failure.d.ts +89 -0
- package/dist/types/failure.d.ts.map +1 -0
- package/dist/types/failure.js +121 -0
- package/dist/types/failure.js.map +1 -0
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +7 -6
- package/dist/types/index.js.map +1 -1
- package/dist/types/monitoring-types.d.ts +114 -0
- package/dist/types/monitoring-types.d.ts.map +1 -0
- package/dist/types/monitoring-types.js +10 -0
- package/dist/types/monitoring-types.js.map +1 -0
- package/dist/utils/detect-source-roots.js.map +1 -1
- package/dist/utils/file-walk.d.ts +33 -0
- package/dist/utils/file-walk.d.ts.map +1 -0
- package/dist/utils/file-walk.js +89 -0
- package/dist/utils/file-walk.js.map +1 -0
- package/dist/verification/rules-based.d.ts.map +1 -1
- package/dist/verification/rules-based.js.map +1 -1
- package/package.json +3 -7
- package/src/__tests__/checker-extra.test.ts +0 -30
- package/src/__tests__/checker.test.ts +0 -33
- package/src/__tests__/checkpoint.test.ts +46 -46
- package/src/__tests__/constraint-evolver.test.ts +22 -21
- package/src/__tests__/doctor-evolver.test.ts +3 -3
- package/src/__tests__/iron-laws.test.ts +0 -27
- package/src/__tests__/presets.test.ts +1 -40
- package/src/architecture/constraint-engine.ts +0 -5
- package/src/architecture/cross-project-checker.ts +6 -24
- package/src/cli/commands/__tests__/check.test.ts +3 -1
- package/src/cli/commands/__tests__/sync-docs.test.ts +77 -0
- package/src/cli/commands/__tests__/validate.test.ts +5 -0
- package/src/cli/commands/analyze-sessions.ts +31 -185
- package/src/cli/commands/check.ts +26 -225
- package/src/cli/commands/doc-freshness-check.ts +14 -25
- package/src/cli/commands/flow.ts +5 -3
- package/src/cli/commands/init.ts +3 -3
- package/src/cli/commands/posteval-plan.ts +0 -1
- package/src/cli/commands/release.ts +1 -1
- package/src/cli/commands/report.ts +2 -0
- package/src/cli/commands/spec-baseline-check.ts +12 -19
- package/src/cli/commands/sync-docs/agents-syncer.ts +280 -0
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +229 -0
- package/src/cli/commands/sync-docs/context-syncer.ts +108 -0
- package/src/cli/commands/sync-docs/index.ts +355 -0
- package/src/cli/commands/sync-docs/preserve-block.ts +59 -0
- package/src/cli/commands/sync-docs/project-reader.ts +163 -0
- package/src/cli/commands/update-user-model.ts +23 -87
- package/src/cli/commands/validate.ts +6 -40
- package/src/cli/session-mining/corrections.ts +56 -0
- package/src/cli/session-mining/index.ts +13 -0
- package/src/cli/session-mining/text.ts +117 -0
- package/src/cli/session-mining/transcript.ts +107 -0
- package/src/constraints/__tests__/lifecycle-runner.test.ts +1 -1
- package/src/constraints/lifecycle-runner.ts +1 -1
- package/src/context/compaction.ts +2 -3
- package/src/context/knowledge-injector.ts +1 -1
- package/src/context/tool-output-budget.ts +1 -1
- package/src/core/constraints/capabilities-parser.ts +70 -0
- package/src/core/constraints/checker.ts +170 -779
- package/src/core/constraints/checkers/always-pass.ts +22 -0
- package/src/core/constraints/checkers/capability-sync.ts +71 -0
- package/src/core/constraints/checkers/context-doc-sync.ts +36 -0
- package/src/core/constraints/checkers/docs-freshness.ts +116 -0
- package/src/core/constraints/checkers/guideline-flags.ts +30 -0
- package/src/core/constraints/checkers/index.ts +114 -0
- package/src/core/constraints/checkers/iron-flags.ts +62 -0
- package/src/core/constraints/checkers/no-any-type.ts +42 -0
- package/src/core/constraints/checkers/no-bypass-checkpoint.ts +40 -0
- package/src/core/constraints/checkers/no-excuse-patterns.ts +24 -0
- package/src/core/constraints/checkers/no-fuzzy-completion-claim.ts +33 -0
- package/src/core/constraints/checkers/no-performative-agreement.ts +22 -0
- package/src/core/constraints/checkers/no-simplification-without-approval.ts +29 -0
- package/src/core/constraints/checkers/no-test-simplification.ts +28 -0
- package/src/core/constraints/checkers/test-coverage.ts +35 -0
- package/src/core/constraints/checkers/types.ts +54 -0
- package/src/core/constraints/checkers/yagni.ts +65 -0
- package/src/core/constraints/context-builder.ts +262 -0
- package/src/core/constraints/definitions/guidelines.ts +668 -0
- package/src/core/constraints/definitions/iron-laws.ts +333 -0
- package/src/core/constraints/definitions/tips.ts +63 -0
- package/src/core/constraints/definitions.ts +9 -1086
- package/src/core/constraints/doc-freshness/runner.ts +2 -3
- package/src/core/constraints/index.ts +1 -27
- package/src/core/constraints/interceptor.ts +0 -2
- package/src/core/index.ts +1 -1
- package/src/core/project-config-loader.ts +49 -13
- package/src/core/validators/check-handlers/command.ts +58 -0
- package/src/core/validators/check-handlers/file.ts +104 -0
- package/src/core/validators/check-handlers/http.ts +88 -0
- package/src/core/validators/check-handlers/output.ts +165 -0
- package/src/core/validators/checkpoint.ts +32 -407
- package/src/core/validators/cso.ts +1 -1
- package/src/core/validators/passes-gate.ts +2 -2
- package/src/dashboard/stats.ts +1 -1
- package/src/dashboard/types.ts +1 -1
- package/src/evolution/__tests__/auto-evolve.test.ts +1 -2
- package/src/evolution/auto-evolve.ts +3 -3
- package/src/failure/types.ts +5 -161
- package/src/gates/contract.ts +0 -1
- package/src/gates/index.ts +0 -2
- package/src/gates/performance.ts +1 -1
- package/src/gates/security.ts +1 -3
- package/src/hooks/bootstrap.ts +6 -16
- package/src/index.ts +4 -1
- package/src/knowledge/__tests__/lifecycle.test.ts +4 -1
- package/src/knowledge/audit.ts +1 -1
- package/src/knowledge/doctor.ts +0 -1
- package/src/knowledge/import.ts +2 -2
- package/src/knowledge/index-generator.ts +0 -1
- package/src/knowledge/ingest.ts +1 -2
- package/src/knowledge/lint.ts +2 -2
- package/src/knowledge/primitives/__tests__/code-structure-degrade.test.ts +24 -0
- package/src/knowledge/primitives/code-structure.ts +36 -12
- package/src/knowledge/query.ts +0 -3
- package/src/knowledge/store.ts +1 -1
- package/src/llm/adapter.ts +3 -3
- package/src/monitoring/analyzer-base.ts +112 -0
- package/src/monitoring/constraint-doctor.ts +14 -175
- package/src/monitoring/constraint-evolver.ts +20 -92
- package/src/monitoring/diagnosis-rules.ts +132 -0
- package/src/monitoring/knowledge-doctor.ts +0 -1
- package/src/monitoring/performance-analyzer.ts +22 -72
- package/src/monitoring/performance-collector.ts +0 -22
- package/src/monitoring/trace-analyzer.ts +17 -73
- package/src/presets/__tests__/standard.test.ts +2 -17
- package/src/presets/index.ts +1 -3
- package/src/presets/standard.ts +1 -26
- package/src/safety/output-guardrail.ts +0 -4
- package/src/tools/registry.ts +1 -1
- package/src/types/__tests__/types.test.ts +1 -33
- package/src/types/constraint.ts +6 -75
- package/src/types/failure.ts +165 -0
- package/src/types/index.ts +7 -5
- package/src/types/monitoring-types.ts +150 -0
- package/src/utils/detect-source-roots.ts +1 -1
- package/src/utils/file-walk.ts +78 -0
- package/src/verification/rules-based.ts +0 -1
- package/bin/harness-knowledge-capture.js +0 -99
- package/bin/harness-knowledge-check.js +0 -164
- package/bin/harness-knowledge-track.js +0 -118
- package/dist/cli/commands/sync-docs.d.ts.map +0 -1
- package/dist/cli/commands/sync-docs.js +0 -1074
- package/dist/cli/commands/sync-docs.js.map +0 -1
- package/dist/constraints/index.d.ts +0 -4
- package/dist/constraints/index.d.ts.map +0 -1
- package/dist/constraints/index.js +0 -20
- package/dist/constraints/index.js.map +0 -1
- package/dist/core/constraints/doc-freshness/auto-fix.d.ts +0 -23
- package/dist/core/constraints/doc-freshness/auto-fix.d.ts.map +0 -1
- package/dist/core/constraints/doc-freshness/auto-fix.js +0 -59
- package/dist/core/constraints/doc-freshness/auto-fix.js.map +0 -1
- package/dist/core/constraints/prompt-injection.d.ts +0 -16
- package/dist/core/constraints/prompt-injection.d.ts.map +0 -1
- package/dist/core/constraints/prompt-injection.js +0 -69
- package/dist/core/constraints/prompt-injection.js.map +0 -1
- package/dist/core/spec/index.d.ts +0 -7
- package/dist/core/spec/index.d.ts.map +0 -1
- package/dist/core/spec/index.js.map +0 -1
- package/dist/governance/executor.d.ts +0 -45
- package/dist/governance/executor.d.ts.map +0 -1
- package/dist/governance/executor.js +0 -243
- package/dist/governance/executor.js.map +0 -1
- package/dist/governance/index.d.ts +0 -9
- package/dist/governance/index.d.ts.map +0 -1
- package/dist/governance/index.js +0 -13
- package/dist/governance/index.js.map +0 -1
- package/dist/governance/types.d.ts +0 -46
- package/dist/governance/types.d.ts.map +0 -1
- package/dist/governance/types.js +0 -9
- package/dist/governance/types.js.map +0 -1
- package/dist/tools/definitions/definitions/core/code/fingerprint.sh +0 -273
- package/dist/tools/definitions/definitions/core/code/fingerprint.yml +0 -72
- package/dist/tools/definitions/definitions/core/code/parse.yml +0 -68
- package/dist/tools/definitions/definitions/core/code/register-language.sh +0 -475
- package/dist/tools/definitions/definitions/core/code/register-language.yml +0 -74
- package/dist/tools/definitions/definitions/core/docker/build.yml +0 -73
- package/dist/tools/definitions/definitions/core/docker/run.yml +0 -81
- package/dist/tools/definitions/definitions/core/file/copy.yml +0 -88
- package/dist/tools/definitions/definitions/core/file/read.yml +0 -69
- package/dist/tools/definitions/definitions/core/file/write.yml +0 -75
- package/dist/tools/definitions/definitions/core/git/branch.yml +0 -61
- package/dist/tools/definitions/definitions/core/git/cleanup-worktree.yml +0 -50
- package/dist/tools/definitions/definitions/core/git/clone.yml +0 -69
- package/dist/tools/definitions/definitions/core/git/commit.yml +0 -65
- package/dist/tools/definitions/definitions/core/git/push.yml +0 -79
- package/dist/tools/definitions/definitions/core/git/worktree.yml +0 -96
- package/dist/tools/definitions/definitions/core/notification/notify.sh +0 -152
- package/dist/tools/definitions/definitions/core/notification/notify.yml +0 -60
- package/dist/tools/definitions/definitions/core/npm/build.yml +0 -75
- package/dist/tools/definitions/definitions/core/npm/install.yml +0 -58
- package/dist/tools/definitions/definitions/core/npm/test.yml +0 -75
- package/dist/tools/definitions/definitions/core/validation/check-reuse.yml +0 -170
- package/dist/tools/definitions/definitions/core/validation/validate-handlers.yml +0 -118
- package/dist/tools/definitions/definitions/core/validation/validate-readme-stats.yml +0 -155
- package/dist/tools/definitions/definitions/core/validation/validate-yaml-syntax.yml +0 -134
- package/dist/tools/definitions/definitions/ext/browser/browser-automate.sh +0 -255
- package/dist/tools/definitions/definitions/ext/browser/browser-automate.yml +0 -166
- package/dist/tools/definitions/definitions/ext/browser/browser-close.sh +0 -104
- package/dist/tools/definitions/definitions/ext/browser/browser-close.yml +0 -55
- package/dist/tools/definitions/definitions/ext/browser/browser-mcp-debug.sh +0 -682
- package/dist/tools/definitions/definitions/ext/browser/browser-mcp-debug.yml +0 -167
- package/dist/tools/definitions/definitions/ext/browser/browser-start.sh +0 -101
- package/dist/tools/definitions/definitions/ext/browser/browser-start.yml +0 -62
- package/dist/tools/definitions/definitions/registry.json +0 -795
- package/dist/tools/definitions/definitions/std/README.md +0 -350
- package/dist/tools/definitions/definitions/std/analysis/analyze-codebase.yml +0 -72
- package/dist/tools/definitions/definitions/std/analysis/analyze-diff.yml +0 -182
- package/dist/tools/definitions/definitions/std/analysis/analyze-git-diff.yml +0 -70
- package/dist/tools/definitions/definitions/std/analysis/analyze-impact.yml +0 -78
- package/dist/tools/definitions/definitions/std/analysis/analyze-requirements.yml +0 -105
- package/dist/tools/definitions/definitions/std/analysis/brainstorm-options.yml +0 -106
- package/dist/tools/definitions/definitions/std/analysis/build-graph.yml +0 -154
- package/dist/tools/definitions/definitions/std/analysis/clarify-requirements.yml +0 -90
- package/dist/tools/definitions/definitions/std/analysis/detect-context.yml +0 -109
- package/dist/tools/definitions/definitions/std/analysis/detect-layers.yml +0 -125
- package/dist/tools/definitions/definitions/std/analysis/generate-tour.yml +0 -102
- package/dist/tools/definitions/definitions/std/analysis/search-enhance.yml +0 -105
- package/dist/tools/definitions/definitions/std/backlog/add.yml +0 -51
- package/dist/tools/definitions/definitions/std/backlog/decide.yml +0 -39
- package/dist/tools/definitions/definitions/std/backlog/github-sync.yml +0 -161
- package/dist/tools/definitions/definitions/std/backlog/list.yml +0 -53
- package/dist/tools/definitions/definitions/std/backlog/load.yml +0 -46
- package/dist/tools/definitions/definitions/std/backlog/resolve.yml +0 -37
- package/dist/tools/definitions/definitions/std/backlog/update.yml +0 -42
- package/dist/tools/definitions/definitions/std/bugfix/diagnose.yml +0 -68
- package/dist/tools/definitions/definitions/std/bugfix/fix.yml +0 -66
- package/dist/tools/definitions/definitions/std/bugfix/verify.yml +0 -69
- package/dist/tools/definitions/definitions/std/constraint/check-decomposition.yml +0 -103
- package/dist/tools/definitions/definitions/std/constraint/check-feature-list.yml +0 -77
- package/dist/tools/definitions/definitions/std/constraint/check-progress.yml +0 -97
- package/dist/tools/definitions/definitions/std/constraint/generate-report.yml +0 -147
- package/dist/tools/definitions/definitions/std/deploy/commit-push.yml +0 -33
- package/dist/tools/definitions/definitions/std/deploy/deploy-backend.yml +0 -37
- package/dist/tools/definitions/definitions/std/deploy/deploy-frontend.yml +0 -37
- package/dist/tools/definitions/definitions/std/deploy/rollback.yml +0 -148
- package/dist/tools/definitions/definitions/std/design/analyze-architecture-impact.yml +0 -113
- package/dist/tools/definitions/definitions/std/design/design-api.yml +0 -55
- package/dist/tools/definitions/definitions/std/design/design-architecture.yml +0 -97
- package/dist/tools/definitions/definitions/std/design/design-db.yml +0 -81
- package/dist/tools/definitions/definitions/std/design/generate-spec.yml +0 -182
- package/dist/tools/definitions/definitions/std/development/develop-api.yml +0 -85
- package/dist/tools/definitions/definitions/std/development/develop-backend.yml +0 -88
- package/dist/tools/definitions/definitions/std/development/develop-frontend.yml +0 -87
- package/dist/tools/definitions/definitions/std/development/develop-shared-types.yml +0 -74
- package/dist/tools/definitions/definitions/std/development/develop-task.yml +0 -122
- package/dist/tools/definitions/definitions/std/development/develop-tests.yml +0 -76
- package/dist/tools/definitions/definitions/std/development/execute-batch.yml +0 -152
- package/dist/tools/definitions/definitions/std/development/fix-issues.yml +0 -100
- package/dist/tools/definitions/definitions/std/development/implement-task.yml +0 -124
- package/dist/tools/definitions/definitions/std/development/review-fix-cycle.yml +0 -232
- package/dist/tools/definitions/definitions/std/evolution/implement.yml +0 -125
- package/dist/tools/definitions/definitions/std/evolution/prioritize.yml +0 -112
- package/dist/tools/definitions/definitions/std/evolution/report-gap.yml +0 -166
- package/dist/tools/definitions/definitions/std/file/read.yml +0 -21
- package/dist/tools/definitions/definitions/std/governance/aggregate-opinions.sh +0 -201
- package/dist/tools/definitions/definitions/std/governance/aggregate-opinions.yml +0 -79
- package/dist/tools/definitions/definitions/std/governance/audit-task.yml +0 -178
- package/dist/tools/definitions/definitions/std/governance/cast-vote.yml +0 -129
- package/dist/tools/definitions/definitions/std/governance/collect-issues.yml +0 -16
- package/dist/tools/definitions/definitions/std/governance/create-signed-document.yml +0 -23
- package/dist/tools/definitions/definitions/std/governance/create-voting-session.yml +0 -101
- package/dist/tools/definitions/definitions/std/governance/define-stance.sh +0 -243
- package/dist/tools/definitions/definitions/std/governance/define-stance.yml +0 -82
- package/dist/tools/definitions/definitions/std/governance/generate-review-report.yml +0 -23
- package/dist/tools/definitions/definitions/std/governance/impeach.yml +0 -179
- package/dist/tools/definitions/definitions/std/governance/multi-stance-review.yml +0 -154
- package/dist/tools/definitions/definitions/std/governance/prepare-artifact.yml +0 -20
- package/dist/tools/definitions/definitions/std/governance/review-spec-approval.yml +0 -262
- package/dist/tools/definitions/definitions/std/governance/rollback.yml +0 -186
- package/dist/tools/definitions/definitions/std/governance/stance-review.yml +0 -149
- package/dist/tools/definitions/definitions/std/governance/track-effect.yml +0 -199
- package/dist/tools/definitions/definitions/std/governance/vote-tally.yml +0 -144
- package/dist/tools/definitions/definitions/std/patch/execute.yml +0 -51
- package/dist/tools/definitions/definitions/std/planning/generate-tasks.yml +0 -36
- package/dist/tools/definitions/definitions/std/planning/load-tasks.yml +0 -44
- package/dist/tools/definitions/definitions/std/planning/split-batch.yml +0 -481
- package/dist/tools/definitions/definitions/std/planning/split-tasks.yml +0 -359
- package/dist/tools/definitions/definitions/std/planning/update-tasks.yml +0 -51
- package/dist/tools/definitions/definitions/std/planning/validate-tasks.yml +0 -46
- package/dist/tools/definitions/definitions/std/project/decide-next-workflow.yml +0 -38
- package/dist/tools/definitions/definitions/std/project/load-state.yml +0 -31
- package/dist/tools/definitions/definitions/std/project/save-state.yml +0 -32
- package/dist/tools/definitions/definitions/std/quality/check-quality.yml +0 -241
- package/dist/tools/definitions/definitions/std/quality/debug-systematic.yml +0 -163
- package/dist/tools/definitions/definitions/std/quality/handle-feedback.yml +0 -108
- package/dist/tools/definitions/definitions/std/quality/review-code.yml +0 -128
- package/dist/tools/definitions/definitions/std/quality/review-spec.yml +0 -140
- package/dist/tools/definitions/definitions/std/quality/review-task.yml +0 -190
- package/dist/tools/definitions/definitions/std/quality/run-tests.yml +0 -80
- package/dist/tools/definitions/definitions/std/quick/analyze.yml +0 -56
- package/dist/tools/definitions/definitions/std/quick/implement.yml +0 -67
- package/dist/tools/definitions/definitions/std/quick/verify.yml +0 -71
- package/dist/tools/definitions/definitions/std/verification/verify_completion.yml +0 -113
- package/dist/tools/definitions/definitions/std/verification/wait-condition.yml +0 -107
- package/dist/types/iron-law.d.ts +0 -25
- package/dist/types/iron-law.d.ts.map +0 -1
- package/dist/types/iron-law.js +0 -16
- package/dist/types/iron-law.js.map +0 -1
- package/src/cli/commands/sync-docs.ts +0 -1175
- package/src/constraints/index.ts +0 -3
- package/src/core/constraints/__tests__/prompt-injection.test.ts +0 -89
- package/src/core/constraints/doc-freshness/auto-fix.ts +0 -69
- package/src/core/constraints/prompt-injection.ts +0 -73
- package/src/core/spec/index.ts +0 -7
- package/src/governance/CONTEXT.md +0 -22
- package/src/governance/__tests__/executor.test.ts +0 -249
- package/src/governance/executor.ts +0 -229
- package/src/governance/index.ts +0 -13
- package/src/governance/types.ts +0 -53
- package/src/tools/core/package.json +0 -7
- package/src/tools/core/pnpm-lock.yaml +0 -232
- package/src/types/iron-law.ts +0 -50
|
@@ -7,58 +7,20 @@
|
|
|
7
7
|
* - Guidelines:检查失败记录警告
|
|
8
8
|
* - Tips:检查失败记录提示
|
|
9
9
|
*/
|
|
10
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}) : (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
o[k2] = m[k];
|
|
20
|
-
}));
|
|
21
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
-
}) : function(o, v) {
|
|
24
|
-
o["default"] = v;
|
|
25
|
-
});
|
|
26
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
-
var ownKeys = function(o) {
|
|
28
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
-
var ar = [];
|
|
30
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
return ownKeys(o);
|
|
34
|
-
};
|
|
35
|
-
return function (mod) {
|
|
36
|
-
if (mod && mod.__esModule) return mod;
|
|
37
|
-
var result = {};
|
|
38
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
-
__setModuleDefault(result, mod);
|
|
40
|
-
return result;
|
|
41
|
-
};
|
|
42
|
-
})();
|
|
43
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.
|
|
11
|
+
exports.constraintChecker = exports.ConstraintChecker = void 0;
|
|
45
12
|
exports.checkConstraint = checkConstraint;
|
|
46
13
|
exports.checkConstraints = checkConstraints;
|
|
47
14
|
exports.checkConstraintsSafe = checkConstraintsSafe;
|
|
48
15
|
exports.checkBeforeExecution = checkBeforeExecution;
|
|
49
|
-
exports.checkIronLaw = checkIronLaw;
|
|
50
|
-
exports.checkAllIronLaws = checkAllIronLaws;
|
|
51
16
|
const constraint_1 = require("../../types/constraint");
|
|
52
|
-
const traces_1 = require("../../monitoring/traces");
|
|
53
17
|
const definitions_1 = require("./definitions");
|
|
54
|
-
const runner_1 = require("./doc-freshness/runner");
|
|
55
18
|
const exec_1 = require("../../utils/exec");
|
|
56
19
|
const exec_2 = require("../../utils/exec");
|
|
57
|
-
const fs_1 = require("fs");
|
|
58
20
|
const path_1 = require("path");
|
|
59
|
-
const yaml = __importStar(require("js-yaml"));
|
|
60
21
|
const check_cache_1 = require("./check-cache");
|
|
61
|
-
const
|
|
22
|
+
const file_walk_1 = require("../../utils/file-walk");
|
|
23
|
+
const checkers_1 = require("./checkers");
|
|
62
24
|
/**
|
|
63
25
|
* 例外名称 → ConstraintContext 中布尔字段的映射
|
|
64
26
|
*/
|
|
@@ -88,6 +50,7 @@ const EXCEPTION_FIELD_MAP = {
|
|
|
88
50
|
emergency_fix: 'isEmergencyFix',
|
|
89
51
|
existing_design: 'isExistingDesign',
|
|
90
52
|
};
|
|
53
|
+
const NOOP_TRACE_RECORDER = { record: () => undefined };
|
|
91
54
|
/**
|
|
92
55
|
* 约束检查器
|
|
93
56
|
*/
|
|
@@ -95,9 +58,41 @@ class ConstraintChecker {
|
|
|
95
58
|
static instance;
|
|
96
59
|
/** 自定义约束配置(项目级) */
|
|
97
60
|
customConfig = null;
|
|
98
|
-
/** 检查结果缓存(S7
|
|
61
|
+
/** 检查结果缓存(S7:src 扫描等重复 I/O,TTL=1s 防跨测试污染) */
|
|
99
62
|
cache = new check_cache_1.CheckCache({ ttlMs: 1000 });
|
|
63
|
+
/**
|
|
64
|
+
* run 级 memo(工单 18):一次 checkConstraints/checkConstraintsSafe 内
|
|
65
|
+
* git diff 等命令只执行一次;run 外直接调用私有检查方法时不 memo(恒新鲜)。
|
|
66
|
+
*/
|
|
67
|
+
runCache = null;
|
|
68
|
+
/** trace 记录器(注入式,默认 no-op;生产入口经 setTraceRecorder 接入真实收集器) */
|
|
69
|
+
traceRecorder = NOOP_TRACE_RECORDER;
|
|
100
70
|
constructor() { }
|
|
71
|
+
/**
|
|
72
|
+
* run 内 memoize;无活动 run 时直接执行(工单 18)
|
|
73
|
+
*/
|
|
74
|
+
memoRun(key, fn) {
|
|
75
|
+
if (!this.runCache)
|
|
76
|
+
return fn();
|
|
77
|
+
let pending = this.runCache.get(key);
|
|
78
|
+
if (!pending) {
|
|
79
|
+
pending = fn();
|
|
80
|
+
this.runCache.set(key, pending);
|
|
81
|
+
}
|
|
82
|
+
return pending;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* staged 全量 diff(同一次 run 内只执行一次 git 命令,工单 18)
|
|
86
|
+
*/
|
|
87
|
+
getStagedDiff(projectPath) {
|
|
88
|
+
return this.memoRun(`git_diff_staged:${projectPath}`, () => (0, exec_2.runCommand)('git diff --cached', projectPath));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* staged 变更文件名列表(同一次 run 内只执行一次 git 命令,工单 18)
|
|
92
|
+
*/
|
|
93
|
+
getStagedDiffNames(projectPath) {
|
|
94
|
+
return this.memoRun(`git_diff_staged_names:${projectPath}`, () => (0, exec_2.runCommand)('git diff --cached --name-only', projectPath));
|
|
95
|
+
}
|
|
101
96
|
/**
|
|
102
97
|
* 获取单例实例
|
|
103
98
|
*/
|
|
@@ -107,6 +102,12 @@ class ConstraintChecker {
|
|
|
107
102
|
}
|
|
108
103
|
return ConstraintChecker.instance;
|
|
109
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* 注入 trace 记录器(工单 15:解耦 core 对 monitoring 的值依赖)
|
|
107
|
+
*/
|
|
108
|
+
setTraceRecorder(recorder) {
|
|
109
|
+
this.traceRecorder = recorder;
|
|
110
|
+
}
|
|
110
111
|
/**
|
|
111
112
|
* 设置项目级约束配置
|
|
112
113
|
*
|
|
@@ -213,603 +214,23 @@ class ConstraintChecker {
|
|
|
213
214
|
});
|
|
214
215
|
}
|
|
215
216
|
/**
|
|
216
|
-
*
|
|
217
|
-
*/
|
|
218
|
-
async checkPrecondition(constraint, context) {
|
|
219
|
-
const projectPath = context.projectPath || process.cwd();
|
|
220
|
-
switch (constraint.id) {
|
|
221
|
-
// Iron Laws
|
|
222
|
-
case 'no_bypass_checkpoint':
|
|
223
|
-
// 检查代码中是否有 skip/bypass 关键词
|
|
224
|
-
return await this.checkNoBypassCheckpoint(context);
|
|
225
|
-
case 'no_self_approval':
|
|
226
|
-
// 检查是否有测试证据
|
|
227
|
-
return context.hasTest === true;
|
|
228
|
-
case 'no_completion_without_verification':
|
|
229
|
-
// 检查是否有验证证据
|
|
230
|
-
return context.hasVerificationEvidence === true;
|
|
231
|
-
case 'no_test_simplification':
|
|
232
|
-
// 检查是否删除了测试
|
|
233
|
-
return await this.checkNoTestSimplification(projectPath);
|
|
234
|
-
case 'incremental_progress':
|
|
235
|
-
// 检查是否一次做多个任务(需要 context 提供信息)
|
|
236
|
-
// undefined = 未验证 → Iron Law 必须显式确认
|
|
237
|
-
return context.hasSingleTask === true;
|
|
238
|
-
case 'verify_external_capability':
|
|
239
|
-
// 检查是否已验证外部能力
|
|
240
|
-
// undefined = 未验证 → Iron Law 必须显式确认
|
|
241
|
-
return context.hasExternalCapabilityVerification === true;
|
|
242
|
-
case 'no_implementation_without_requirement_review':
|
|
243
|
-
// 检查实现后是否对比需求验证
|
|
244
|
-
return context.hasRequirementReview === true;
|
|
245
|
-
case 'no_implementation_without_requirement':
|
|
246
|
-
// 检查是否有需求文档
|
|
247
|
-
return context.hasRequirement === true;
|
|
248
|
-
case 'prefer_worktree':
|
|
249
|
-
// 检查是否在 worktree 中执行
|
|
250
|
-
return context.hasWorktree === true;
|
|
251
|
-
case 'no_fuzzy_completion_claim':
|
|
252
|
-
// 检查完成声明是否包含模糊词(含"我记得""之前说""大部分"等无验证模式)
|
|
253
|
-
return this.checkNoFuzzyWords(context.completionClaimText || '');
|
|
254
|
-
case 'no_claim_without_evidence':
|
|
255
|
-
// 检查是否提供了验证证据(test output / file check / spec AC matrix)
|
|
256
|
-
return context.hasVerificationEvidence === true ||
|
|
257
|
-
(context.taskDescription || '').includes('test') ||
|
|
258
|
-
context.hasTest === true;
|
|
259
|
-
case 'no_delete_without_context':
|
|
260
|
-
// 检查删除前是否审查了设计文档
|
|
261
|
-
return context.hasRequirementReview === true ||
|
|
262
|
-
context.hasRequirement === true ||
|
|
263
|
-
context.isExistingDesign === true;
|
|
264
|
-
case 'no_performative_agreement':
|
|
265
|
-
// 检查是否有表演性同意(主要由 promptInjection 驱动,这里做辅助检查)
|
|
266
|
-
return this.checkNoPerformativePatterns(context.taskDescription || '');
|
|
267
|
-
case 'two_stage_review_required':
|
|
268
|
-
// 检查是否完成两阶段审查
|
|
269
|
-
return context.hasTwoStageReview === true;
|
|
270
|
-
// Guidelines
|
|
271
|
-
case 'no_fix_without_root_cause':
|
|
272
|
-
// 检查是否有根本原因调查
|
|
273
|
-
return context.hasRootCauseInvestigation === true;
|
|
274
|
-
case 'no_code_without_test':
|
|
275
|
-
// 检查是否有失败的测试
|
|
276
|
-
return context.hasFailingTest === true;
|
|
277
|
-
case 'no_any_type':
|
|
278
|
-
// 检查代码中是否有 any 类型
|
|
279
|
-
return await this.checkNoAnyType(projectPath, context.changedFiles);
|
|
280
|
-
case 'simplest_solution_first':
|
|
281
|
-
// 检查是否已检查本地数据源
|
|
282
|
-
return context.hasReuseCheck === true;
|
|
283
|
-
case 'no_creation_without_reuse_check':
|
|
284
|
-
// 检查是否已进行复用检查
|
|
285
|
-
return context.hasReuseCheck === true;
|
|
286
|
-
case 'capability_sync':
|
|
287
|
-
// 检查 CAPABILITIES.md 是否更新
|
|
288
|
-
return await this.checkCapabilitySync(projectPath);
|
|
289
|
-
case 'no_simplification_without_approval':
|
|
290
|
-
// 检查是否简化了逻辑
|
|
291
|
-
return await this.checkNoSimplificationWithoutApproval(projectPath);
|
|
292
|
-
case 'no_skill_without_test':
|
|
293
|
-
// 检查是否有测试
|
|
294
|
-
return context.hasTest === true;
|
|
295
|
-
case 'test_coverage_required':
|
|
296
|
-
// 检查测试覆盖率
|
|
297
|
-
return await this.checkTestCoverage(projectPath);
|
|
298
|
-
case 'context_doc_sync':
|
|
299
|
-
return await this.checkContextDocSync(projectPath);
|
|
300
|
-
case 'docs_freshness':
|
|
301
|
-
return await this.checkDocsFreshness(projectPath);
|
|
302
|
-
case 'no_excuse_patterns':
|
|
303
|
-
// 检查是否使用了借口模式
|
|
304
|
-
return this.checkNoExcusePatterns(context.completionClaimText || context.taskDescription || '');
|
|
305
|
-
case 'yagni_check':
|
|
306
|
-
// 检查是否有过度设计(主要由 promptInjection 驱动)
|
|
307
|
-
return this.checkYagni(projectPath, context.changedFiles);
|
|
308
|
-
// Mnilax guidelines + first-principles (injectPrompt=true, behavior-level, always pass — post-checked)
|
|
309
|
-
case 'surgical_changes_only':
|
|
310
|
-
case 'no_model_for_deterministic':
|
|
311
|
-
case 'no_conflict_blending':
|
|
312
|
-
case 'read_before_write':
|
|
313
|
-
case 'follow_conventions':
|
|
314
|
-
case 'first_principles_first':
|
|
315
|
-
case 'fix_the_problem_not_the_gate':
|
|
316
|
-
case 'diagnosis_to_fix_gate':
|
|
317
|
-
// Guideline: behavior constraints, enforced via promptInjection + post-check
|
|
318
|
-
return true;
|
|
319
|
-
// Tips - 总是返回 true(仅提示)
|
|
320
|
-
case 'readme_required':
|
|
321
|
-
return true;
|
|
322
|
-
case 'doc_required_for_public_api':
|
|
323
|
-
return true;
|
|
324
|
-
default:
|
|
325
|
-
// 未知约束,默认通过
|
|
326
|
-
return true;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* 检查文本中是否包含模糊词
|
|
331
|
-
*/
|
|
332
|
-
checkNoFuzzyWords(text) {
|
|
333
|
-
if (!text)
|
|
334
|
-
return true; // 没有文本时默认通过(由其他检查覆盖)
|
|
335
|
-
const fuzzyPatterns = [
|
|
336
|
-
/应该没问题/,
|
|
337
|
-
/应该可以/,
|
|
338
|
-
/大概/,
|
|
339
|
-
/可能/,
|
|
340
|
-
/好像/,
|
|
341
|
-
/似乎/,
|
|
342
|
-
/差不多/,
|
|
343
|
-
/基本完成/,
|
|
344
|
-
/大部分/,
|
|
345
|
-
// audit-learned (2026-05-18): unverified completion claims
|
|
346
|
-
/我记得删[过掉]了/,
|
|
347
|
-
/之前说删了/,
|
|
348
|
-
/已删除.*但/,
|
|
349
|
-
/大部分实现/,
|
|
350
|
-
/大部分完成/,
|
|
351
|
-
/已修复.*但/,
|
|
352
|
-
];
|
|
353
|
-
return !fuzzyPatterns.some(p => p.test(text));
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* 检查文本中是否包含表演性同意模式
|
|
357
|
-
*/
|
|
358
|
-
checkNoPerformativePatterns(text) {
|
|
359
|
-
if (!text)
|
|
360
|
-
return true;
|
|
361
|
-
// 检查是否只有"好的/明白了"等同意词,没有后续分析
|
|
362
|
-
const performativeStart = /^(好的[,,]*\s*我[来去]做|明白了[,,]*|没问题[,,]*|ok[,,]*\s*i.?ll)/i;
|
|
363
|
-
// 如果以表演性模式开头,且总长度很短(< 50 字符),视为表演性同意
|
|
364
|
-
if (performativeStart.test(text) && text.length < 100) {
|
|
365
|
-
return false;
|
|
366
|
-
}
|
|
367
|
-
return true;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* 检查文本中是否包含借口模式
|
|
371
|
-
*/
|
|
372
|
-
checkNoExcusePatterns(text) {
|
|
373
|
-
if (!text)
|
|
374
|
-
return true;
|
|
375
|
-
const excusePatterns = [
|
|
376
|
-
/稍后修复/,
|
|
377
|
-
/小问题/,
|
|
378
|
-
/不影响功能/,
|
|
379
|
-
/以后再说/,
|
|
380
|
-
/先这样/,
|
|
381
|
-
/临时方案/,
|
|
382
|
-
/暂时这样/,
|
|
383
|
-
];
|
|
384
|
-
return !excusePatterns.some(p => p.test(text));
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* 检查 YAGNI:过度设计信号
|
|
388
|
-
*
|
|
389
|
-
* 检查是否存在只有一个实现的 interface/abstract class。
|
|
390
|
-
* 主要由 promptInjection 驱动,这里是辅助检查。
|
|
391
|
-
*/
|
|
392
|
-
async checkYagni(projectPath, changedFiles) {
|
|
393
|
-
// 无上下文时默认通过(主要由 promptInjection 驱动)
|
|
394
|
-
if (!projectPath || !changedFiles || changedFiles.length === 0)
|
|
395
|
-
return true;
|
|
396
|
-
try {
|
|
397
|
-
const path = await Promise.resolve().then(() => __importStar(require('path')));
|
|
398
|
-
const fs = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
399
|
-
for (const file of changedFiles) {
|
|
400
|
-
if (!file.endsWith('.ts') && !file.endsWith('.tsx'))
|
|
401
|
-
continue;
|
|
402
|
-
const filePath = path.join(projectPath, file);
|
|
403
|
-
if (!fs.existsSync(filePath))
|
|
404
|
-
continue;
|
|
405
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
406
|
-
// 检查是否有 export interface/abstract class
|
|
407
|
-
const hasInterface = /export\s+(?:default\s+)?interface\s+(\w+)/g;
|
|
408
|
-
const hasAbstract = /export\s+(?:default\s+)?abstract\s+class\s+(\w+)/g;
|
|
409
|
-
const interfaces = [...content.matchAll(hasInterface)].map(m => m[1]);
|
|
410
|
-
const abstracts = [...content.matchAll(hasAbstract)].map(m => m[1]);
|
|
411
|
-
const exportedTypes = [...interfaces, ...abstracts];
|
|
412
|
-
for (const typeName of exportedTypes) {
|
|
413
|
-
// 检查同一个 typeName 的 implements/extends 出现次数
|
|
414
|
-
const implPattern = new RegExp(`(?:implements|extends)\\s+${typeName}\\b`, 'g');
|
|
415
|
-
// 在整个项目中搜索(简化版:只在 changedFiles 中搜索)
|
|
416
|
-
let implCount = 0;
|
|
417
|
-
for (const f of changedFiles) {
|
|
418
|
-
if (!f.endsWith('.ts') && !f.endsWith('.tsx'))
|
|
419
|
-
continue;
|
|
420
|
-
const fp = path.join(projectPath, f);
|
|
421
|
-
if (!fs.existsSync(fp))
|
|
422
|
-
continue;
|
|
423
|
-
const fc = fs.readFileSync(fp, 'utf-8');
|
|
424
|
-
const matches = fc.match(implPattern);
|
|
425
|
-
if (matches)
|
|
426
|
-
implCount += matches.length;
|
|
427
|
-
}
|
|
428
|
-
// 只有一个实现者 → YAGNI 违规
|
|
429
|
-
if (implCount <= 1) {
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
catch {
|
|
436
|
-
// 文件读取失败,默认通过
|
|
437
|
-
return true;
|
|
438
|
-
}
|
|
439
|
-
return true;
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* 检查 no_bypass_checkpoint:检查代码中是否有 skip/bypass 关键词
|
|
443
|
-
*/
|
|
444
|
-
async checkNoBypassCheckpoint(context) {
|
|
445
|
-
const changedFiles = context.changedFiles || [];
|
|
446
|
-
if (changedFiles.length === 0) {
|
|
447
|
-
return true; // 无变更文件,默认通过
|
|
448
|
-
}
|
|
449
|
-
// 检查文件内容是否有 skip/bypass 关键词
|
|
450
|
-
const bypassPatterns = [
|
|
451
|
-
/\.skip\(/, // Jest/Vitest skip
|
|
452
|
-
/\.bypass\s*=/, // bypass flag
|
|
453
|
-
/skip:\s*true/, // skip option
|
|
454
|
-
/bypass\s*checkpoint/, // explicit bypass
|
|
455
|
-
/\/\/\s*skip/, // comment skip
|
|
456
|
-
];
|
|
457
|
-
for (const file of changedFiles) {
|
|
458
|
-
if (!(0, fs_1.existsSync)(file))
|
|
459
|
-
continue;
|
|
460
|
-
try {
|
|
461
|
-
const content = (0, fs_1.readFileSync)(file, 'utf-8');
|
|
462
|
-
for (const pattern of bypassPatterns) {
|
|
463
|
-
if (pattern.test(content)) {
|
|
464
|
-
return false; // 发现 bypass 关键词
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
catch {
|
|
469
|
-
// 文件读取失败,忽略
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
return true;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* 检查 no_test_simplification:检查 git diff 是否删除了测试
|
|
476
|
-
*/
|
|
477
|
-
async checkNoTestSimplification(projectPath) {
|
|
478
|
-
try {
|
|
479
|
-
// 检查是否有删除测试的 diff
|
|
480
|
-
const diff = await (0, exec_2.runCommand)('git diff --cached', projectPath);
|
|
481
|
-
// 检查是否删除了测试行
|
|
482
|
-
const deletedTestPatterns = [
|
|
483
|
-
/^-\s*(test|it|describe)\s*\(/, // 删除 test/it/describe
|
|
484
|
-
/^-\s*expect\s*\(/, // 删除 expect
|
|
485
|
-
/^-\s*\/\/\s*test/, // 删除注释的 test
|
|
486
|
-
];
|
|
487
|
-
for (const pattern of deletedTestPatterns) {
|
|
488
|
-
if (pattern.test(diff)) {
|
|
489
|
-
return false; // 发现删除测试
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
return true;
|
|
493
|
-
}
|
|
494
|
-
catch {
|
|
495
|
-
return true; // git 命令失败,默认通过
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* 检查 no_any_type:grep any 类型
|
|
500
|
-
*/
|
|
501
|
-
async checkNoAnyType(projectPath, changedFiles) {
|
|
502
|
-
try {
|
|
503
|
-
const filesToCheck = changedFiles && changedFiles.length > 0
|
|
504
|
-
? changedFiles.filter(f => f.endsWith('.ts') || f.endsWith('.tsx'))
|
|
505
|
-
: [];
|
|
506
|
-
if (filesToCheck.length === 0) {
|
|
507
|
-
return true; // 无 TS 文件变更
|
|
508
|
-
}
|
|
509
|
-
// 检查是否有 : any 类型
|
|
510
|
-
for (const file of filesToCheck) {
|
|
511
|
-
if (!(0, fs_1.existsSync)(file))
|
|
512
|
-
continue;
|
|
513
|
-
try {
|
|
514
|
-
const content = (0, fs_1.readFileSync)(file, 'utf-8');
|
|
515
|
-
// 检查 : any(排除注释和字符串)
|
|
516
|
-
const lines = content.split('\n');
|
|
517
|
-
for (const line of lines) {
|
|
518
|
-
// 跳过注释和字符串
|
|
519
|
-
if (line.trim().startsWith('//') || line.trim().startsWith('*'))
|
|
520
|
-
continue;
|
|
521
|
-
if (line.includes(': any') && !line.includes('// ') && !line.includes('/*')) {
|
|
522
|
-
return false; // 发现 any 类型
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
catch {
|
|
527
|
-
// 文件读取失败,忽略
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
return true;
|
|
531
|
-
}
|
|
532
|
-
catch {
|
|
533
|
-
return true; // 检查失败,默认通过
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* 检查 capability_sync:检查 CAPABILITIES.md 是否与代码同步
|
|
217
|
+
* 检查约束前置条件(工单 21:分发至 checkers/ 注册表)
|
|
538
218
|
*
|
|
539
|
-
*
|
|
540
|
-
* 1. Git diff 检查 — 当前变更的非测试文件是否在文档中有记录(增量检查)
|
|
541
|
-
* 2. 全量扫描 — src/ 下的所有源文件是否都在 CAPABILITIES.md 中(完整性检查)
|
|
219
|
+
* 未注册的约束默认通过(保持历史 default 分支语义)。
|
|
542
220
|
*/
|
|
543
|
-
async
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
if (!(0, fs_1.existsSync)(capabilitiesPath)) {
|
|
547
|
-
// 检查是否有代码变更,无变更则跳过
|
|
548
|
-
const diff = await (0, exec_2.runCommand)('git diff --cached --name-only', projectPath);
|
|
549
|
-
const changedCodeFiles = diff.split('\n').filter((f) => f.endsWith('.ts') || f.endsWith('.tsx') || f.endsWith('.js'));
|
|
550
|
-
return changedCodeFiles.length === 0;
|
|
551
|
-
}
|
|
552
|
-
const listedFiles = this.parseCapabilitiesFiles(capabilitiesPath);
|
|
553
|
-
// ── Step 1: Git diff 增量检查 ──
|
|
554
|
-
const diff = await (0, exec_2.runCommand)('git diff --cached --name-only', projectPath);
|
|
555
|
-
const changedCodeFiles = diff.split('\n').filter((f) => f.endsWith('.ts') || f.endsWith('.tsx') || f.endsWith('.js'));
|
|
556
|
-
if (changedCodeFiles.length > 0 && listedFiles.length > 0) {
|
|
557
|
-
const significantChanges = changedCodeFiles.filter((f) => !f.includes('__tests__') && !f.includes('.test.') && !f.includes('.spec.'));
|
|
558
|
-
if (significantChanges.length > 0) {
|
|
559
|
-
const covered = significantChanges.some((changed) => listedFiles.some((listed) => changed.endsWith(listed) || changed.includes(listed)));
|
|
560
|
-
if (!covered)
|
|
561
|
-
return false;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
// ── Step 2: 全量 src/ 扫描(T-058 修复核心)──
|
|
565
|
-
// 检查是否有 src/ 下的源文件未在 CAPABILITIES.md 中记录
|
|
566
|
-
if (listedFiles.length > 0) {
|
|
567
|
-
const sourceRoots = (0, detect_source_roots_1.detectSourceRoots)(projectPath);
|
|
568
|
-
for (const root of sourceRoots) {
|
|
569
|
-
const srcDir = (0, path_1.join)(projectPath, root);
|
|
570
|
-
if ((0, fs_1.existsSync)(srcDir)) {
|
|
571
|
-
const actualFiles = this.cache.getSync(`src_scan_${root}`, projectPath, () => this.findSourceFiles(srcDir, projectPath));
|
|
572
|
-
for (const file of actualFiles) {
|
|
573
|
-
if (!listedFiles.includes(file)) {
|
|
574
|
-
return false;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
return true;
|
|
581
|
-
}
|
|
582
|
-
catch {
|
|
583
|
-
return true; // 检查失败,默认通过
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* 解析 CAPABILITIES.md 中表格的文件路径列
|
|
588
|
-
*/
|
|
589
|
-
parseCapabilitiesFiles(capabilitiesPath) {
|
|
590
|
-
try {
|
|
591
|
-
const content = (0, fs_1.readFileSync)(capabilitiesPath, 'utf-8');
|
|
592
|
-
const files = [];
|
|
593
|
-
// 匹配 markdown 表格行中的 .ts/.tsx/.js/.jsx 文件路径(第二列)
|
|
594
|
-
const tableRowRegex = /^\|[^|]+\|\s*([^|]+?\.(?:ts|tsx|js|jsx))\s*\|/gm;
|
|
595
|
-
let match;
|
|
596
|
-
while ((match = tableRowRegex.exec(content)) !== null) {
|
|
597
|
-
files.push(match[1].trim());
|
|
598
|
-
}
|
|
599
|
-
return files;
|
|
600
|
-
}
|
|
601
|
-
catch {
|
|
602
|
-
return [];
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
/**
|
|
606
|
-
* 检查 no_simplification_without_approval:检查简化关键词
|
|
607
|
-
*/
|
|
608
|
-
async checkNoSimplificationWithoutApproval(projectPath) {
|
|
609
|
-
try {
|
|
610
|
-
const diff = await (0, exec_2.runCommand)('git diff --cached', projectPath);
|
|
611
|
-
// 检查是否有简化关键词
|
|
612
|
-
const simplificationPatterns = [
|
|
613
|
-
/removed\s*test/i,
|
|
614
|
-
/simplified\s*logic/i,
|
|
615
|
-
/removed\s*validation/i,
|
|
616
|
-
/skip\s*check/i,
|
|
617
|
-
];
|
|
618
|
-
for (const pattern of simplificationPatterns) {
|
|
619
|
-
if (pattern.test(diff)) {
|
|
620
|
-
return false; // 发现简化关键词
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
return true;
|
|
624
|
-
}
|
|
625
|
-
catch {
|
|
626
|
-
return true; // 检查失败,默认通过
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* 检查 test_coverage_required:读取 coverage 报告
|
|
631
|
-
*/
|
|
632
|
-
async checkTestCoverage(projectPath) {
|
|
633
|
-
try {
|
|
634
|
-
// 检查 coverage 报告文件
|
|
635
|
-
const coverageJsonPath = (0, path_1.join)(projectPath, 'coverage', 'coverage-final.json');
|
|
636
|
-
const coverageSummaryPath = (0, path_1.join)(projectPath, 'coverage', 'coverage-summary.json');
|
|
637
|
-
if (!(0, fs_1.existsSync)(coverageJsonPath) && !(0, fs_1.existsSync)(coverageSummaryPath)) {
|
|
638
|
-
return true; // 无 coverage 报告,默认通过
|
|
639
|
-
}
|
|
640
|
-
// 尝试读取 coverage-summary.json
|
|
641
|
-
if ((0, fs_1.existsSync)(coverageSummaryPath)) {
|
|
642
|
-
const summary = JSON.parse((0, fs_1.readFileSync)(coverageSummaryPath, 'utf-8'));
|
|
643
|
-
const total = summary.total || {};
|
|
644
|
-
const linesCoverage = total.lines?.pct || 0;
|
|
645
|
-
// 默认要求 50% 覆盖率(可配置)
|
|
646
|
-
return linesCoverage >= 50;
|
|
647
|
-
}
|
|
648
|
-
return true;
|
|
649
|
-
}
|
|
650
|
-
catch {
|
|
651
|
-
return true; // 检查失败,默认通过
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
/**
|
|
655
|
-
* 检查 context_doc_sync:关键目录是否有 CONTEXT.md
|
|
656
|
-
*/
|
|
657
|
-
async checkContextDocSync(projectPath) {
|
|
658
|
-
try {
|
|
659
|
-
const configPath = (0, path_1.join)(projectPath, '.harness', 'config.yml');
|
|
660
|
-
const configContent = (0, fs_1.readFileSync)(configPath, 'utf-8');
|
|
661
|
-
const config = yaml.load(configContent);
|
|
662
|
-
const governance = config.governance;
|
|
663
|
-
const contextFiles = governance?.context_files;
|
|
664
|
-
if (!contextFiles?.enabled || !Array.isArray(contextFiles.required_dirs)) {
|
|
665
|
-
return true; // 未配置,跳过
|
|
666
|
-
}
|
|
667
|
-
const requiredDirs = contextFiles.required_dirs;
|
|
668
|
-
for (const dir of requiredDirs) {
|
|
669
|
-
const contextPath = (0, path_1.join)(projectPath, dir, 'CONTEXT.md');
|
|
670
|
-
if (!(0, fs_1.existsSync)(contextPath)) {
|
|
671
|
-
return false;
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
return true;
|
|
675
|
-
}
|
|
676
|
-
catch {
|
|
677
|
-
return true; // 配置不存在或解析失败,跳过
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* 检查 docs_freshness:CAPABILITIES.md 文件表 + 能力清单格式 + CLAUDE.md + CHANGELOG
|
|
682
|
-
*
|
|
683
|
-
* 1. 文件表格式:检查 CAPABILITIES.md 中列出的文件是否存在(防过期引用)
|
|
684
|
-
* 2. 能力清单格式:通过 FreshnessRunner 配置驱动检查计数/目录
|
|
685
|
-
* 3. 无配置时注入内置默认配置(等价旧硬编码行为)
|
|
686
|
-
*/
|
|
687
|
-
async checkDocsFreshness(projectPath) {
|
|
688
|
-
// Step 1: 文件表格式 — 检查列出的文件是否还存在
|
|
689
|
-
const fileTableResult = await this.checkCapabilitiesFreshness(projectPath);
|
|
690
|
-
if (!fileTableResult)
|
|
691
|
-
return false;
|
|
692
|
-
// Step 2: 能力清单格式 + CLAUDE.md + CHANGELOG — 通过 FreshnessRunner
|
|
693
|
-
try {
|
|
694
|
-
const configPath = (0, path_1.join)(projectPath, '.harness', 'config.yml');
|
|
695
|
-
let freshnessConfig;
|
|
696
|
-
let requiredDirs;
|
|
697
|
-
if ((0, fs_1.existsSync)(configPath)) {
|
|
698
|
-
try {
|
|
699
|
-
const raw = yaml.load((0, fs_1.readFileSync)(configPath, 'utf-8'));
|
|
700
|
-
const governance = raw.governance;
|
|
701
|
-
freshnessConfig = governance?.doc_freshness;
|
|
702
|
-
const contextFiles = governance?.context_files;
|
|
703
|
-
if (contextFiles?.enabled && Array.isArray(contextFiles.required_dirs)) {
|
|
704
|
-
requiredDirs = contextFiles.required_dirs;
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
catch {
|
|
708
|
-
// 配置解析失败,使用默认
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
const runner = new runner_1.FreshnessRunner();
|
|
712
|
-
let results;
|
|
713
|
-
if (freshnessConfig?.checks && freshnessConfig.checks.length > 0) {
|
|
714
|
-
results = runner.runAll(freshnessConfig, projectPath, { requiredDirs });
|
|
715
|
-
}
|
|
716
|
-
else {
|
|
717
|
-
const builtIn = this.getBuiltInDocFreshnessConfig(requiredDirs);
|
|
718
|
-
results = runner.runAll({ checks: builtIn }, projectPath, { requiredDirs });
|
|
719
|
-
}
|
|
720
|
-
if (!results.every(r => r.pass))
|
|
721
|
-
return false;
|
|
722
|
-
}
|
|
723
|
-
catch {
|
|
724
|
-
// FreshnessRunner 失败不影响整体
|
|
725
|
-
}
|
|
726
|
-
return true;
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* 获取内置默认文档新鲜度检查配置
|
|
730
|
-
*
|
|
731
|
-
* 等价旧硬编码的 checkCapabilitiesFreshness + checkClaudeMdFreshness 行为。
|
|
732
|
-
* 仅当项目未提供 governance.doc_freshness 配置时使用。
|
|
733
|
-
*/
|
|
734
|
-
getBuiltInDocFreshnessConfig(_requiredDirs) {
|
|
735
|
-
return [
|
|
736
|
-
// CONTEXT.md 存在性 — key directories must have CONTEXT.md
|
|
737
|
-
{ type: 'context_docs' },
|
|
738
|
-
// CHANGELOG 版本 vs package.json 版本 — prevents version drift
|
|
739
|
-
{ type: 'changelog_version' },
|
|
740
|
-
];
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* 检查 CAPABILITIES.md 是否与源码同步(文件表格式)
|
|
744
|
-
*
|
|
745
|
-
* 检查 CAPABILITIES.md 中列出的文件路径是否仍然存在于磁盘上(防过期引用)。
|
|
746
|
-
* 多根查找:支持不同项目的源码根(harness=src/, studio=apps/api/src/ 等)。
|
|
747
|
-
* 无表格行(能力清单格式)时跳过。
|
|
748
|
-
*/
|
|
749
|
-
async checkCapabilitiesFreshness(projectPath) {
|
|
750
|
-
try {
|
|
751
|
-
const capabilitiesPath = (0, path_1.join)(projectPath, 'CAPABILITIES.md');
|
|
752
|
-
if (!(0, fs_1.existsSync)(capabilitiesPath))
|
|
753
|
-
return true;
|
|
754
|
-
const content = (0, fs_1.readFileSync)(capabilitiesPath, 'utf-8');
|
|
755
|
-
const listedFiles = [];
|
|
756
|
-
const tableRowRegex = /^\|[^|]+\|\s*([^|]+?\.(?:ts|tsx|js|jsx))\s*\|/gm;
|
|
757
|
-
let match;
|
|
758
|
-
while ((match = tableRowRegex.exec(content)) !== null) {
|
|
759
|
-
listedFiles.push(match[1].trim());
|
|
760
|
-
}
|
|
761
|
-
if (listedFiles.length === 0)
|
|
762
|
-
return true;
|
|
763
|
-
const sourceRoots = (0, detect_source_roots_1.detectSourceRoots)(projectPath);
|
|
764
|
-
const fileExists = (file) => {
|
|
765
|
-
if ((0, fs_1.existsSync)((0, path_1.join)(projectPath, file)))
|
|
766
|
-
return true;
|
|
767
|
-
for (const root of sourceRoots) {
|
|
768
|
-
if ((0, fs_1.existsSync)((0, path_1.join)(projectPath, root, file)))
|
|
769
|
-
return true;
|
|
770
|
-
}
|
|
771
|
-
return false;
|
|
772
|
-
};
|
|
773
|
-
for (const file of listedFiles) {
|
|
774
|
-
if (!fileExists(file))
|
|
775
|
-
return false;
|
|
776
|
-
}
|
|
777
|
-
return true;
|
|
778
|
-
}
|
|
779
|
-
catch {
|
|
221
|
+
async checkPrecondition(constraint, context) {
|
|
222
|
+
const impl = (0, checkers_1.getConstraintCheck)(constraint.id);
|
|
223
|
+
if (!impl)
|
|
780
224
|
return true;
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
entries = (0, fs_1.readdirSync)(dir);
|
|
791
|
-
}
|
|
792
|
-
catch {
|
|
793
|
-
return [];
|
|
794
|
-
}
|
|
795
|
-
for (const entry of entries) {
|
|
796
|
-
if (entry === 'node_modules' || entry === '__tests__' || entry === 'dist')
|
|
797
|
-
continue;
|
|
798
|
-
const entryPath = (0, path_1.join)(dir, entry);
|
|
799
|
-
try {
|
|
800
|
-
const stat = (0, fs_1.statSync)(entryPath);
|
|
801
|
-
if (stat.isDirectory()) {
|
|
802
|
-
results.push(...this.findSourceFiles(entryPath, projectPath));
|
|
803
|
-
}
|
|
804
|
-
else if (entry.endsWith('.ts') && !entry.endsWith('.d.ts') && entry !== 'index.ts') {
|
|
805
|
-
results.push((0, path_1.relative)(projectPath, entryPath));
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
catch {
|
|
809
|
-
// ignore
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
return results;
|
|
225
|
+
const projectPath = context.projectPath || process.cwd();
|
|
226
|
+
const env = {
|
|
227
|
+
context,
|
|
228
|
+
projectPath,
|
|
229
|
+
stagedDiff: () => this.getStagedDiff(projectPath),
|
|
230
|
+
stagedDiffNames: () => this.getStagedDiffNames(projectPath),
|
|
231
|
+
srcScan: (root) => this.cache.getSync(`src_scan_${root}`, projectPath, () => (0, file_walk_1.findTsSourceFiles)((0, path_1.join)(projectPath, root), { skipIndex: true }).map((f) => (0, path_1.relative)(projectPath, f))),
|
|
232
|
+
};
|
|
233
|
+
return await impl.evaluate(env);
|
|
813
234
|
}
|
|
814
235
|
/**
|
|
815
236
|
* 查找适用于当前操作的约束
|
|
@@ -845,51 +266,59 @@ class ConstraintChecker {
|
|
|
845
266
|
* @param customConfig 可选,per-request 自定义配置(避免多请求间的单例状态污染)
|
|
846
267
|
*/
|
|
847
268
|
async checkConstraints(context, customConfig) {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
269
|
+
// run 起始:重置 run 级缓存;run 结束(含铁律提前抛出)清空(工单 18)
|
|
270
|
+
this.cache.invalidate();
|
|
271
|
+
this.runCache = new Map();
|
|
272
|
+
try {
|
|
273
|
+
const result = {
|
|
274
|
+
ironLaws: [],
|
|
275
|
+
guidelines: [],
|
|
276
|
+
tips: [],
|
|
277
|
+
passed: true,
|
|
278
|
+
warningCount: 0,
|
|
279
|
+
tipCount: 0,
|
|
280
|
+
};
|
|
281
|
+
const traceCollector = this.traceRecorder;
|
|
282
|
+
const constraints = this.getConstraints(customConfig);
|
|
283
|
+
// 1. Iron Laws: 必须全部通过
|
|
284
|
+
for (const constraint of Object.values(constraints.ironLaws)) {
|
|
285
|
+
if (!this.matchesTrigger(constraint, context.operation))
|
|
286
|
+
continue;
|
|
287
|
+
const checkResult = await this.check(constraint, context);
|
|
288
|
+
result.ironLaws.push(checkResult);
|
|
289
|
+
this.recordTrace(traceCollector, constraint, checkResult, context);
|
|
290
|
+
if (!checkResult.satisfied) {
|
|
291
|
+
result.passed = false;
|
|
292
|
+
throw new constraint_1.ConstraintViolationError(checkResult);
|
|
293
|
+
}
|
|
868
294
|
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
295
|
+
// 2. Guidelines: 记录警告
|
|
296
|
+
for (const constraint of Object.values(constraints.guidelines)) {
|
|
297
|
+
if (!this.matchesTrigger(constraint, context.operation))
|
|
298
|
+
continue;
|
|
299
|
+
const checkResult = await this.check(constraint, context);
|
|
300
|
+
result.guidelines.push(checkResult);
|
|
301
|
+
this.recordTrace(traceCollector, constraint, checkResult, context);
|
|
302
|
+
if (!checkResult.satisfied) {
|
|
303
|
+
result.warningCount++;
|
|
304
|
+
}
|
|
879
305
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
306
|
+
// 3. Tips: 仅记录
|
|
307
|
+
for (const constraint of Object.values(constraints.tips)) {
|
|
308
|
+
if (!this.matchesTrigger(constraint, context.operation))
|
|
309
|
+
continue;
|
|
310
|
+
const checkResult = await this.check(constraint, context);
|
|
311
|
+
result.tips.push(checkResult);
|
|
312
|
+
this.recordTrace(traceCollector, constraint, checkResult, context);
|
|
313
|
+
if (!checkResult.satisfied) {
|
|
314
|
+
result.tipCount++;
|
|
315
|
+
}
|
|
890
316
|
}
|
|
317
|
+
return result;
|
|
318
|
+
}
|
|
319
|
+
finally {
|
|
320
|
+
this.runCache = null;
|
|
891
321
|
}
|
|
892
|
-
return result;
|
|
893
322
|
}
|
|
894
323
|
/**
|
|
895
324
|
* S11: 安全全量检查 — 全部三层约束检查,不抛异常
|
|
@@ -898,44 +327,52 @@ class ConstraintChecker {
|
|
|
898
327
|
* 调用方通过 result.passed + result.warningCount 判断状态。
|
|
899
328
|
*/
|
|
900
329
|
async checkConstraintsSafe(context, customConfig) {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
const
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
330
|
+
// run 起始:重置 run 级缓存(工单 18)
|
|
331
|
+
this.cache.invalidate();
|
|
332
|
+
this.runCache = new Map();
|
|
333
|
+
try {
|
|
334
|
+
const result = {
|
|
335
|
+
ironLaws: [],
|
|
336
|
+
guidelines: [],
|
|
337
|
+
tips: [],
|
|
338
|
+
passed: true,
|
|
339
|
+
warningCount: 0,
|
|
340
|
+
tipCount: 0,
|
|
341
|
+
};
|
|
342
|
+
const traceCollector = this.traceRecorder;
|
|
343
|
+
const constraints = this.getConstraints(customConfig);
|
|
344
|
+
for (const constraint of Object.values(constraints.ironLaws)) {
|
|
345
|
+
if (!this.matchesTrigger(constraint, context.operation))
|
|
346
|
+
continue;
|
|
347
|
+
const checkResult = await this.check(constraint, context);
|
|
348
|
+
result.ironLaws.push(checkResult);
|
|
349
|
+
this.recordTrace(traceCollector, constraint, checkResult, context);
|
|
350
|
+
if (!checkResult.satisfied)
|
|
351
|
+
result.passed = false;
|
|
352
|
+
}
|
|
353
|
+
for (const constraint of Object.values(constraints.guidelines)) {
|
|
354
|
+
if (!this.matchesTrigger(constraint, context.operation))
|
|
355
|
+
continue;
|
|
356
|
+
const checkResult = await this.check(constraint, context);
|
|
357
|
+
result.guidelines.push(checkResult);
|
|
358
|
+
this.recordTrace(traceCollector, constraint, checkResult, context);
|
|
359
|
+
if (!checkResult.satisfied)
|
|
360
|
+
result.warningCount++;
|
|
361
|
+
}
|
|
362
|
+
for (const constraint of Object.values(constraints.tips)) {
|
|
363
|
+
if (!this.matchesTrigger(constraint, context.operation))
|
|
364
|
+
continue;
|
|
365
|
+
const checkResult = await this.check(constraint, context);
|
|
366
|
+
result.tips.push(checkResult);
|
|
367
|
+
this.recordTrace(traceCollector, constraint, checkResult, context);
|
|
368
|
+
if (!checkResult.satisfied)
|
|
369
|
+
result.tipCount++;
|
|
370
|
+
}
|
|
371
|
+
return result;
|
|
928
372
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
continue;
|
|
932
|
-
const checkResult = await this.check(constraint, context);
|
|
933
|
-
result.tips.push(checkResult);
|
|
934
|
-
this.recordTrace(traceCollector, constraint, checkResult, context);
|
|
935
|
-
if (!checkResult.satisfied)
|
|
936
|
-
result.tipCount++;
|
|
373
|
+
finally {
|
|
374
|
+
this.runCache = null;
|
|
937
375
|
}
|
|
938
|
-
return result;
|
|
939
376
|
}
|
|
940
377
|
/**
|
|
941
378
|
* 执行前检查(仅检查 Iron Laws)
|
|
@@ -1007,28 +444,4 @@ async function checkBeforeExecution(context, customConfig) {
|
|
|
1007
444
|
}
|
|
1008
445
|
// 导出单例
|
|
1009
446
|
exports.constraintChecker = ConstraintChecker.getInstance();
|
|
1010
|
-
// ========================================
|
|
1011
|
-
// 向后兼容的类和函数
|
|
1012
|
-
// ========================================
|
|
1013
|
-
/**
|
|
1014
|
-
* @deprecated 使用 ConstraintChecker 代替
|
|
1015
|
-
*/
|
|
1016
|
-
exports.IronLawChecker = ConstraintChecker;
|
|
1017
|
-
/**
|
|
1018
|
-
* @deprecated 使用 checkConstraint 代替
|
|
1019
|
-
*/
|
|
1020
|
-
async function checkIronLaw(lawId, context) {
|
|
1021
|
-
return checkConstraint(lawId, context);
|
|
1022
|
-
}
|
|
1023
|
-
/**
|
|
1024
|
-
* @deprecated 使用 checkConstraints 代替
|
|
1025
|
-
*/
|
|
1026
|
-
async function checkAllIronLaws(context) {
|
|
1027
|
-
const result = await checkConstraints(context);
|
|
1028
|
-
return [...result.ironLaws, ...result.guidelines, ...result.tips];
|
|
1029
|
-
}
|
|
1030
|
-
/**
|
|
1031
|
-
* @deprecated 使用 constraintChecker 代替
|
|
1032
|
-
*/
|
|
1033
|
-
exports.ironLawChecker = exports.constraintChecker;
|
|
1034
447
|
//# sourceMappingURL=checker.js.map
|