@dommaker/harness 1.3.0 → 1.4.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 +8 -0
- package/README.md +0 -2
- package/bin/harness.js +86 -32
- package/dist/cli/command-contract.d.ts +83 -0
- package/dist/cli/command-contract.d.ts.map +1 -0
- package/dist/cli/command-contract.js +66 -0
- package/dist/cli/command-contract.js.map +1 -0
- package/dist/cli/commands/acceptance.d.ts +3 -2
- package/dist/cli/commands/acceptance.d.ts.map +1 -1
- package/dist/cli/commands/acceptance.js +28 -24
- package/dist/cli/commands/acceptance.js.map +1 -1
- package/dist/cli/commands/analyze-sessions.d.ts +2 -1
- package/dist/cli/commands/analyze-sessions.d.ts.map +1 -1
- package/dist/cli/commands/analyze-sessions.js +25 -24
- package/dist/cli/commands/analyze-sessions.js.map +1 -1
- package/dist/cli/commands/check.d.ts +14 -2
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +76 -61
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/command.d.ts +5 -1
- package/dist/cli/commands/command.d.ts.map +1 -1
- package/dist/cli/commands/command.js +26 -17
- package/dist/cli/commands/command.js.map +1 -1
- package/dist/cli/commands/constraints-report.d.ts +2 -1
- package/dist/cli/commands/constraints-report.d.ts.map +1 -1
- package/dist/cli/commands/constraints-report.js +37 -33
- package/dist/cli/commands/constraints-report.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +6 -5
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +50 -52
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/constraints.d.ts +2 -1
- package/dist/cli/commands/constraints.d.ts.map +1 -1
- package/dist/cli/commands/constraints.js +10 -27
- package/dist/cli/commands/constraints.js.map +1 -1
- package/dist/cli/commands/contract.d.ts +3 -2
- package/dist/cli/commands/contract.d.ts.map +1 -1
- package/dist/cli/commands/contract.js +45 -42
- package/dist/cli/commands/contract.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts +11 -11
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +29 -214
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/failure.d.ts +5 -4
- package/dist/cli/commands/failure.d.ts.map +1 -1
- package/dist/cli/commands/failure.js +31 -25
- package/dist/cli/commands/failure.js.map +1 -1
- package/dist/cli/commands/init.d.ts +7 -5
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +147 -211
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/knowledge.d.ts +21 -15
- package/dist/cli/commands/knowledge.d.ts.map +1 -1
- package/dist/cli/commands/knowledge.js +214 -199
- package/dist/cli/commands/knowledge.js.map +1 -1
- package/dist/cli/commands/passes-gate.d.ts +8 -2
- package/dist/cli/commands/passes-gate.d.ts.map +1 -1
- package/dist/cli/commands/passes-gate.js +44 -66
- package/dist/cli/commands/passes-gate.js.map +1 -1
- package/dist/cli/commands/performance.d.ts +2 -1
- package/dist/cli/commands/performance.d.ts.map +1 -1
- package/dist/cli/commands/performance.js +20 -18
- package/dist/cli/commands/performance.js.map +1 -1
- package/dist/cli/commands/posteval-plan.d.ts +5 -1
- package/dist/cli/commands/posteval-plan.d.ts.map +1 -1
- package/dist/cli/commands/posteval-plan.js +26 -15
- package/dist/cli/commands/posteval-plan.js.map +1 -1
- package/dist/cli/commands/release.d.ts +6 -1
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +69 -59
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/report.d.ts +2 -1
- package/dist/cli/commands/report.d.ts.map +1 -1
- package/dist/cli/commands/report.js +9 -5
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/review.d.ts +3 -2
- package/dist/cli/commands/review.d.ts.map +1 -1
- package/dist/cli/commands/review.js +33 -29
- package/dist/cli/commands/review.js.map +1 -1
- package/dist/cli/commands/sdd.d.ts +2 -1
- package/dist/cli/commands/sdd.d.ts.map +1 -1
- package/dist/cli/commands/sdd.js +7 -5
- package/dist/cli/commands/sdd.js.map +1 -1
- package/dist/cli/commands/security.d.ts +3 -2
- package/dist/cli/commands/security.d.ts.map +1 -1
- package/dist/cli/commands/security.js +29 -26
- package/dist/cli/commands/security.js.map +1 -1
- package/dist/cli/commands/spec-baseline-check.d.ts +2 -1
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +15 -11
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/spec.d.ts +7 -2
- package/dist/cli/commands/spec.d.ts.map +1 -1
- package/dist/cli/commands/spec.js +61 -51
- package/dist/cli/commands/spec.js.map +1 -1
- package/dist/cli/commands/status.d.ts +2 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +57 -53
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.js +5 -2
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +3 -2
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts +2 -1
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +68 -88
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts +6 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js +14 -16
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/commands/update-user-model.d.ts +2 -1
- package/dist/cli/commands/update-user-model.d.ts.map +1 -1
- package/dist/cli/commands/update-user-model.js +31 -45
- package/dist/cli/commands/update-user-model.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +4 -3
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +28 -26
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/session-mining/transcript.d.ts +7 -1
- package/dist/cli/session-mining/transcript.d.ts.map +1 -1
- package/dist/cli/session-mining/transcript.js +21 -14
- package/dist/cli/session-mining/transcript.js.map +1 -1
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +19 -32
- package/dist/context/session-manager.js.map +1 -1
- package/dist/core/constraints/agent-prompt-renderer.d.ts.map +1 -1
- package/dist/core/constraints/agent-prompt-renderer.js +1 -4
- package/dist/core/constraints/agent-prompt-renderer.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +24 -7
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +32 -28
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/capabilities-reconcile.d.ts +67 -0
- package/dist/core/constraints/capabilities-reconcile.d.ts.map +1 -0
- package/dist/core/constraints/capabilities-reconcile.js +105 -0
- package/dist/core/constraints/capabilities-reconcile.js.map +1 -0
- package/dist/core/constraints/checker.d.ts +21 -43
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +64 -115
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.d.ts +4 -3
- package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.js +29 -69
- package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.d.ts +4 -2
- package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.js +13 -22
- package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.d.ts.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.js +37 -63
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.d.ts +2 -2
- package/dist/core/constraints/checkers/governance-presence.d.ts.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.js +7 -28
- package/dist/core/constraints/checkers/governance-presence.js.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.js +4 -3
- package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
- package/dist/core/constraints/checkers/types.d.ts +2 -2
- package/dist/core/constraints/context-builder.d.ts +15 -14
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +32 -96
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +2 -1
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/git-evidence.d.ts +60 -0
- package/dist/core/constraints/git-evidence.d.ts.map +1 -0
- package/dist/core/constraints/git-evidence.js +88 -0
- package/dist/core/constraints/git-evidence.js.map +1 -0
- package/dist/core/constraints/injection-drift.d.ts +3 -20
- package/dist/core/constraints/injection-drift.d.ts.map +1 -1
- package/dist/core/constraints/injection-drift.js +10 -57
- package/dist/core/constraints/injection-drift.js.map +1 -1
- package/dist/core/constraints/injection-writer.d.ts +113 -0
- package/dist/core/constraints/injection-writer.d.ts.map +1 -0
- package/dist/core/constraints/injection-writer.js +228 -0
- package/dist/core/constraints/injection-writer.js.map +1 -0
- package/dist/core/constraints/usage-report.d.ts +22 -1
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +27 -20
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +32 -1
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +39 -9
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +15 -64
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +84 -222
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/core/validators/test-output.d.ts +58 -0
- package/dist/core/validators/test-output.d.ts.map +1 -0
- package/dist/core/validators/test-output.js +109 -0
- package/dist/core/validators/test-output.js.map +1 -0
- package/dist/failure/recorder.d.ts +6 -0
- package/dist/failure/recorder.d.ts.map +1 -1
- package/dist/failure/recorder.js +12 -8
- package/dist/failure/recorder.js.map +1 -1
- package/dist/gates/acceptance.d.ts +1 -48
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +6 -38
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/checker-gate.d.ts.map +1 -1
- package/dist/gates/checker-gate.js +6 -11
- package/dist/gates/checker-gate.js.map +1 -1
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +10 -22
- package/dist/gates/command.js.map +1 -1
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +22 -61
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +13 -31
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +21 -53
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +14 -32
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +28 -5
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/gates/types.js +38 -1
- package/dist/gates/types.js.map +1 -1
- package/dist/hooks/bootstrap.d.ts +2 -0
- package/dist/hooks/bootstrap.d.ts.map +1 -1
- package/dist/hooks/bootstrap.js +5 -2
- package/dist/hooks/bootstrap.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit.d.ts +7 -2
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/audit.js +59 -79
- package/dist/knowledge/audit.js.map +1 -1
- package/dist/knowledge/flywheel-metrics.d.ts +39 -0
- package/dist/knowledge/flywheel-metrics.d.ts.map +1 -0
- package/dist/knowledge/flywheel-metrics.js +47 -0
- package/dist/knowledge/flywheel-metrics.js.map +1 -0
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/import.js +4 -14
- package/dist/knowledge/import.js.map +1 -1
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +17 -14
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +9 -4
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/migration.d.ts.map +1 -1
- package/dist/knowledge/migration.js +11 -8
- package/dist/knowledge/migration.js.map +1 -1
- package/dist/knowledge/reference-tracker.d.ts.map +1 -1
- package/dist/knowledge/reference-tracker.js +12 -9
- package/dist/knowledge/reference-tracker.js.map +1 -1
- package/dist/knowledge/store.d.ts +15 -0
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +59 -10
- package/dist/knowledge/store.js.map +1 -1
- package/dist/monitoring/context-tracker.d.ts.map +1 -1
- package/dist/monitoring/context-tracker.js +11 -20
- package/dist/monitoring/context-tracker.js.map +1 -1
- package/dist/monitoring/index.d.ts +1 -1
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/index.js +1 -2
- package/dist/monitoring/index.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +15 -0
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +19 -2
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +21 -2
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +38 -29
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/release/index.d.ts +2 -2
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +1 -5
- package/dist/release/index.js.map +1 -1
- package/dist/sdd/index-generator.js +10 -11
- package/dist/sdd/index-generator.js.map +1 -1
- package/dist/test-setup/project-fixture.d.ts +48 -0
- package/dist/test-setup/project-fixture.d.ts.map +1 -0
- package/dist/test-setup/project-fixture.js +106 -0
- package/dist/test-setup/project-fixture.js.map +1 -0
- package/dist/types/constraint.d.ts +0 -18
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/passes-gate.d.ts +10 -25
- package/dist/types/passes-gate.d.ts.map +1 -1
- package/dist/types/project-config.d.ts +1 -1
- package/dist/types/session.d.ts +6 -5
- package/dist/types/session.d.ts.map +1 -1
- package/dist/utils/exec.d.ts +10 -0
- package/dist/utils/exec.d.ts.map +1 -1
- package/dist/utils/exec.js +12 -0
- package/dist/utils/exec.js.map +1 -1
- package/dist/utils/file-walk.d.ts +9 -1
- package/dist/utils/file-walk.d.ts.map +1 -1
- package/dist/utils/file-walk.js +10 -1
- package/dist/utils/file-walk.js.map +1 -1
- package/dist/utils/frontmatter.d.ts +73 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +141 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/jsonl.d.ts +92 -0
- package/dist/utils/jsonl.d.ts.map +1 -0
- package/dist/utils/jsonl.js +166 -0
- package/dist/utils/jsonl.js.map +1 -0
- package/dist/utils/package-version.d.ts +16 -0
- package/dist/utils/package-version.d.ts.map +1 -0
- package/dist/utils/package-version.js +63 -0
- package/dist/utils/package-version.js.map +1 -0
- package/package.json +1 -1
- package/src/CONTEXT.md +7 -2
- package/src/__tests__/acceptance-gate.test.ts +3 -1
- package/src/__tests__/checker-extra.test.ts +7 -1218
- package/src/__tests__/context-files-resolution.test.ts +116 -0
- package/src/__tests__/effective-constraints.test.ts +10 -13
- package/src/__tests__/exec.test.ts +35 -1
- package/src/__tests__/layering.test.ts +152 -0
- package/src/__tests__/passes-gate-extra.test.ts +0 -145
- package/src/__tests__/passes-gate.test.ts +142 -106
- package/src/__tests__/skip-semantics.test.ts +5 -9
- package/src/cli/__tests__/command-contract.test.ts +170 -0
- package/src/cli/command-contract.ts +108 -0
- package/src/cli/commands/CONTEXT.md +22 -7
- package/src/cli/commands/__tests__/acceptance.test.ts +40 -33
- package/src/cli/commands/__tests__/analyze-sessions.test.ts +35 -29
- package/src/cli/commands/__tests__/bin-exit-mapping.test.ts +101 -0
- package/src/cli/commands/__tests__/check-drift.test.ts +27 -34
- package/src/cli/commands/__tests__/check-skip-output.test.ts +21 -24
- package/src/cli/commands/__tests__/check.test.ts +378 -382
- package/src/cli/commands/__tests__/command.test.ts +85 -70
- package/src/cli/commands/__tests__/constraints-report.test.ts +100 -71
- package/src/cli/commands/__tests__/constraints-retire.test.ts +152 -95
- package/src/cli/commands/__tests__/contract.test.ts +27 -34
- package/src/cli/commands/__tests__/failure.test.ts +31 -34
- package/src/cli/commands/__tests__/init-injection.test.ts +58 -28
- package/src/cli/commands/__tests__/init.test.ts +77 -48
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +108 -0
- package/src/cli/commands/__tests__/knowledge.test.ts +69 -43
- package/src/cli/commands/__tests__/passes-gate.test.ts +43 -45
- package/src/cli/commands/__tests__/performance.test.ts +22 -23
- package/src/cli/commands/__tests__/posteval-plan.test.ts +39 -38
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +157 -0
- package/src/cli/commands/__tests__/project-path-convention.test.ts +169 -0
- package/src/cli/commands/__tests__/registry.test.ts +69 -35
- package/src/cli/commands/__tests__/release.test.ts +209 -80
- package/src/cli/commands/__tests__/report-extra.test.ts +16 -16
- package/src/cli/commands/__tests__/report.test.ts +25 -25
- package/src/cli/commands/__tests__/review.test.ts +33 -31
- package/src/cli/commands/__tests__/security.test.ts +23 -27
- package/src/cli/commands/__tests__/spec-baseline-check.test.ts +20 -20
- package/src/cli/commands/__tests__/spec.test.ts +41 -29
- package/src/cli/commands/__tests__/status-extra.test.ts +18 -18
- package/src/cli/commands/__tests__/status-skipped-lines.test.ts +72 -0
- package/src/cli/commands/__tests__/status.test.ts +34 -34
- package/src/cli/commands/__tests__/sync-docs-agents.test.ts +77 -78
- package/src/cli/commands/__tests__/sync-docs.test.ts +72 -74
- package/src/cli/commands/__tests__/update-user-model.test.ts +62 -33
- package/src/cli/commands/__tests__/validate.test.ts +27 -29
- package/src/cli/commands/acceptance.ts +35 -24
- package/src/cli/commands/analyze-sessions.ts +25 -24
- package/src/cli/commands/check.ts +88 -65
- package/src/cli/commands/command.ts +30 -17
- package/src/cli/commands/constraints-report.ts +37 -34
- package/src/cli/commands/constraints-retire.ts +58 -55
- package/src/cli/commands/constraints.ts +10 -27
- package/src/cli/commands/contract.ts +51 -42
- package/src/cli/commands/definitions.ts +36 -222
- package/src/cli/commands/failure.ts +33 -26
- package/src/cli/commands/init.ts +166 -220
- package/src/cli/commands/knowledge.ts +225 -203
- package/src/cli/commands/passes-gate.ts +58 -68
- package/src/cli/commands/performance.ts +23 -18
- package/src/cli/commands/posteval-plan.ts +29 -15
- package/src/cli/commands/release.ts +70 -59
- package/src/cli/commands/report.ts +9 -5
- package/src/cli/commands/review.ts +39 -29
- package/src/cli/commands/sdd.ts +7 -5
- package/src/cli/commands/security.ts +35 -26
- package/src/cli/commands/spec-baseline-check.ts +16 -11
- package/src/cli/commands/spec.ts +66 -53
- package/src/cli/commands/status.ts +59 -53
- package/src/cli/commands/sync-docs/agents-syncer.ts +5 -2
- package/src/cli/commands/sync-docs/context-syncer.ts +3 -2
- package/src/cli/commands/sync-docs/index.ts +73 -100
- package/src/cli/commands/sync-docs/project-reader.ts +17 -18
- package/src/cli/commands/update-user-model.ts +33 -45
- package/src/cli/commands/validate.ts +31 -25
- package/src/cli/session-mining/__tests__/transcript.test.ts +118 -0
- package/src/cli/session-mining/transcript.ts +26 -8
- package/src/context/session-manager.ts +19 -33
- package/src/core/CONTEXT.md +9 -6
- package/src/core/constraints/__tests__/capabilities-reconcile.test.ts +200 -0
- package/src/core/constraints/__tests__/capability-counts.test.ts +94 -0
- package/src/core/constraints/__tests__/git-evidence.test.ts +208 -0
- package/src/core/constraints/__tests__/injection-drift.test.ts +3 -10
- package/src/core/constraints/__tests__/injection-writer.test.ts +231 -0
- package/src/core/constraints/__tests__/trace-injection.test.ts +71 -0
- package/src/core/constraints/__tests__/usage-report.test.ts +112 -0
- package/src/core/constraints/agent-prompt-renderer.ts +2 -6
- package/src/core/constraints/capabilities-parser.ts +53 -35
- package/src/core/constraints/capabilities-reconcile.ts +166 -0
- package/src/core/constraints/checker.ts +75 -130
- package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +214 -0
- package/src/core/constraints/checkers/__tests__/context-doc-sync.test.ts +77 -0
- package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +117 -0
- package/src/{__tests__ → core/constraints/checkers/__tests__}/governance-presence.test.ts +83 -9
- package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +50 -0
- package/src/core/constraints/checkers/__tests__/no-bypass-checkpoint.test.ts +76 -0
- package/src/{__tests__ → core/constraints/checkers/__tests__}/no-hardcoded-credentials.test.ts +4 -3
- package/src/core/constraints/checkers/__tests__/no-test-simplification.test.ts +58 -0
- package/src/core/constraints/checkers/__tests__/three-state-consistency.test.ts +145 -0
- package/src/core/constraints/checkers/capability-sync.ts +29 -88
- package/src/core/constraints/checkers/context-doc-sync.ts +15 -25
- package/src/core/constraints/checkers/docs-freshness.ts +40 -69
- package/src/core/constraints/checkers/governance-presence.ts +7 -25
- package/src/core/constraints/checkers/no-test-simplification.ts +4 -3
- package/src/core/constraints/checkers/types.ts +2 -2
- package/src/core/constraints/context-builder.ts +39 -91
- package/src/core/constraints/doc-freshness/runner.ts +2 -1
- package/src/core/constraints/git-evidence.ts +120 -0
- package/src/core/constraints/injection-drift.ts +13 -60
- package/src/core/constraints/injection-writer.ts +212 -0
- package/src/core/constraints/usage-report.ts +36 -17
- package/src/core/index.ts +4 -2
- package/src/core/project-config-loader.ts +49 -9
- package/src/core/validators/__tests__/passes-gate.test.ts +2 -56
- package/src/core/validators/__tests__/test-output.test.ts +372 -0
- package/src/core/validators/passes-gate.ts +86 -248
- package/src/core/validators/test-output.ts +128 -0
- package/src/failure/__tests__/recorder.test.ts +168 -0
- package/src/failure/recorder.ts +12 -10
- package/src/gates/CONTEXT.md +6 -3
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +68 -0
- package/src/gates/__tests__/acceptance.test.ts +4 -86
- package/src/gates/__tests__/effective-gates.test.ts +3 -8
- package/src/gates/__tests__/test-verdict-consistency.test.ts +140 -0
- package/src/gates/acceptance.ts +19 -84
- package/src/gates/checker-gate.ts +8 -7
- package/src/gates/command.ts +10 -16
- package/src/gates/contract.ts +22 -61
- package/src/gates/performance.ts +10 -22
- package/src/gates/review.ts +21 -41
- package/src/gates/security.ts +10 -22
- package/src/gates/types.ts +70 -5
- package/src/hooks/CONTEXT.md +1 -1
- package/src/hooks/bootstrap.ts +5 -2
- package/src/index.ts +0 -4
- package/src/knowledge/CONTEXT.md +8 -3
- package/src/knowledge/__tests__/audit-labels.test.ts +44 -0
- package/src/knowledge/__tests__/flywheel-metrics.test.ts +135 -0
- package/src/knowledge/__tests__/import.test.ts +44 -0
- package/src/knowledge/__tests__/index-generator.test.ts +53 -0
- package/src/knowledge/__tests__/ingest.test.ts +85 -0
- package/src/knowledge/__tests__/migration.test.ts +47 -0
- package/src/knowledge/__tests__/reference-tracker.test.ts +16 -0
- package/src/knowledge/__tests__/store.test.ts +194 -0
- package/src/knowledge/audit.ts +67 -71
- package/src/knowledge/flywheel-metrics.ts +71 -0
- package/src/knowledge/import.ts +4 -18
- package/src/knowledge/index-generator.ts +19 -14
- package/src/knowledge/ingest.ts +9 -4
- package/src/knowledge/migration.ts +11 -8
- package/src/knowledge/reference-tracker.ts +12 -8
- package/src/knowledge/store.ts +64 -11
- package/src/monitoring/CONTEXT.md +8 -3
- package/src/monitoring/__tests__/skipped-lines-report.test.ts +178 -0
- package/src/monitoring/__tests__/traces.test.ts +57 -0
- package/src/monitoring/context-tracker.ts +11 -23
- package/src/monitoring/index.ts +1 -1
- package/src/monitoring/trace-analyzer.ts +21 -2
- package/src/monitoring/traces.ts +39 -36
- package/src/release/CONTEXT.md +1 -0
- package/src/release/__tests__/barrel.test.ts +60 -0
- package/src/release/index.ts +2 -13
- package/src/sdd/__tests__/index-generator.test.ts +71 -0
- package/src/sdd/index-generator.ts +9 -9
- package/src/test-setup/__tests__/project-fixture.test.ts +178 -0
- package/src/test-setup/project-fixture.ts +87 -0
- package/src/tools/CONTEXT.md +6 -0
- package/src/tools/__tests__/registry.test.ts +221 -0
- package/src/types/__tests__/types.test.ts +4 -5
- package/src/types/constraint.ts +0 -25
- package/src/types/passes-gate.ts +10 -30
- package/src/types/project-config.ts +1 -1
- package/src/types/session.ts +5 -5
- package/src/utils/__tests__/frontmatter.test.ts +206 -0
- package/src/utils/__tests__/jsonl-skip-disposition.test.ts +175 -0
- package/src/utils/__tests__/jsonl.test.ts +187 -0
- package/src/utils/__tests__/package-version.test.ts +97 -0
- package/src/utils/exec.ts +15 -0
- package/src/utils/file-walk.ts +11 -2
- package/src/utils/frontmatter.ts +121 -0
- package/src/utils/jsonl.ts +167 -0
- package/src/utils/package-version.ts +27 -0
- package/dist/cli/commands/doc-freshness-check.d.ts +0 -53
- package/dist/cli/commands/doc-freshness-check.d.ts.map +0 -1
- package/dist/cli/commands/doc-freshness-check.js +0 -352
- package/dist/cli/commands/doc-freshness-check.js.map +0 -1
- package/dist/types/index.d.ts +0 -14
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -39
- package/dist/types/index.js.map +0 -1
- package/src/__tests__/long-running.test.ts +0 -17
- package/src/__tests__/passes-gate-extension.test.ts +0 -151
- package/src/cli/commands/__tests__/doc-freshness-check.test.ts +0 -168
- package/src/cli/commands/doc-freshness-check.ts +0 -386
- package/src/spec/CONTEXT.md +0 -11
- package/src/types/index.ts +0 -47
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* capabilities-reconcile 纯判定测试(ADR-0009)
|
|
3
|
+
*
|
|
4
|
+
* interface 即测试面:喂文档内容与文件清单,断言判定结果;无 fs/git fixture。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
reconcileCapabilities,
|
|
9
|
+
significantCodeChanges,
|
|
10
|
+
collectSourceFiles,
|
|
11
|
+
} from '../capabilities-reconcile';
|
|
12
|
+
|
|
13
|
+
const TABLE = [
|
|
14
|
+
'| 模块 | 文件 | 说明 |',
|
|
15
|
+
'|------|------|------|',
|
|
16
|
+
'| Core | src/core/checker.ts | 引擎 |',
|
|
17
|
+
'| Gates | src/gates/ | 门禁目录 |',
|
|
18
|
+
].join('\n');
|
|
19
|
+
|
|
20
|
+
function withExtras(extraLines: string[]): string {
|
|
21
|
+
return [TABLE, ...extraLines].join('\n');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('reconcileCapabilities — 解析口径', () => {
|
|
25
|
+
it('收集所有单元格的文件与目录条目,不再只看第二列', () => {
|
|
26
|
+
const content = withExtras(['| src/utils/helper.ts | 名字在首列 | x |']);
|
|
27
|
+
const v = reconcileCapabilities({
|
|
28
|
+
content,
|
|
29
|
+
populationFiles: [],
|
|
30
|
+
});
|
|
31
|
+
expect(v.fileEntries).toContain('src/core/checker.ts');
|
|
32
|
+
expect(v.fileEntries).toContain('src/utils/helper.ts');
|
|
33
|
+
expect(v.dirEntries).toEqual(['src/gates/']);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('hasTable 区分散文文档与有表格零条目;listingFormat 识别计数行', () => {
|
|
37
|
+
expect(reconcileCapabilities({ content: '随便写点什么', populationFiles: [] }).hasTable).toBe(false);
|
|
38
|
+
const emptyTable = '| 模块 | 文件 |\n|---|---|';
|
|
39
|
+
expect(reconcileCapabilities({ content: emptyTable, populationFiles: [] }).hasTable).toBe(true);
|
|
40
|
+
const listing = '# 能力\nCLI Commands (9)\nIron Laws (3)';
|
|
41
|
+
expect(reconcileCapabilities({ content: listing, populationFiles: [] }).listingFormat).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('reconcileCapabilities — 代码→文档(漏登记)', () => {
|
|
46
|
+
const population = ['src/core/checker.ts', 'src/gates/command.ts', 'src/knowledge/store.ts'];
|
|
47
|
+
|
|
48
|
+
it('module 模式:目录条目参与覆盖,未覆盖文件聚合为目录', () => {
|
|
49
|
+
const v = reconcileCapabilities({
|
|
50
|
+
content: TABLE,
|
|
51
|
+
populationFiles: population,
|
|
52
|
+
sourceRoots: ['src'],
|
|
53
|
+
});
|
|
54
|
+
expect(v.uncoveredFiles).toEqual(['src/knowledge/store.ts']);
|
|
55
|
+
expect(v.uncoveredDirs).toEqual(['src/knowledge/']);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('目录条目恒参与覆盖(check/fix 同规则),mode 只是调用方取哪份输出形状', () => {
|
|
59
|
+
const v = reconcileCapabilities({
|
|
60
|
+
content: TABLE,
|
|
61
|
+
populationFiles: population,
|
|
62
|
+
sourceRoots: ['src'],
|
|
63
|
+
});
|
|
64
|
+
expect(v.coverageEntries).toContain('src/gates/');
|
|
65
|
+
expect(v.uncoveredFiles).toEqual(['src/knowledge/store.ts']);
|
|
66
|
+
// file 模式调用方读 uncoveredFiles;module 模式读 uncoveredDirs——同一判定两种投影
|
|
67
|
+
expect(v.uncoveredDirs).toEqual(['src/knowledge/']);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('文件条目路径边界后缀匹配:兼容 basename 登记但拒绝模糊碰撞', () => {
|
|
71
|
+
const content = withExtras(['| 局部 | core/checker.ts | 相对路径条目 |']);
|
|
72
|
+
const v = reconcileCapabilities({
|
|
73
|
+
content,
|
|
74
|
+
populationFiles: ['src/core/checker.ts', 'src/otherchecker.ts', 'src/docs/src/checked.ts'],
|
|
75
|
+
});
|
|
76
|
+
expect(v.uncoveredFiles).toEqual(['src/otherchecker.ts', 'src/docs/src/checked.ts']);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('增量判定独立于全量:changedFiles 未被覆盖的进入 uncoveredChanges', () => {
|
|
80
|
+
const v = reconcileCapabilities({
|
|
81
|
+
content: TABLE,
|
|
82
|
+
populationFiles: population,
|
|
83
|
+
changedFiles: ['src/core/checker.ts', 'src/knowledge/store.ts'],
|
|
84
|
+
sourceRoots: ['src'],
|
|
85
|
+
});
|
|
86
|
+
expect(v.uncoveredChanges).toEqual(['src/knowledge/store.ts']);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('reconcileCapabilities — 文档→代码(幽灵)', () => {
|
|
91
|
+
it('文件条目多根相对路径:项目根或任一源码根下存在即算活', () => {
|
|
92
|
+
const content = '| 模块 | 文件 | 说明 |\n|---|---|---|\n| API | apps/routes.ts | studio 式多根 |';
|
|
93
|
+
const v = reconcileCapabilities({
|
|
94
|
+
content,
|
|
95
|
+
populationFiles: [],
|
|
96
|
+
sourceRoots: ['src', 'apps/api'],
|
|
97
|
+
fileExists: (rel) => rel === 'apps/api/apps/routes.ts',
|
|
98
|
+
});
|
|
99
|
+
expect(v.deadEntries).toEqual([]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('目录条目也查幽灵(口径从严,Q6a):磁盘不存在且实况无文件才算死', () => {
|
|
103
|
+
const v = reconcileCapabilities({
|
|
104
|
+
content: TABLE,
|
|
105
|
+
populationFiles: ['src/core/checker.ts'],
|
|
106
|
+
fileExists: (rel) => !rel.startsWith('src/gates'),
|
|
107
|
+
});
|
|
108
|
+
expect(v.deadEntries).toEqual(['src/gates/']);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('目录条目实况有文件即活(oracle 缺省的纯清单场景)', () => {
|
|
112
|
+
const v = reconcileCapabilities({
|
|
113
|
+
content: TABLE,
|
|
114
|
+
populationFiles: ['src/core/checker.ts', 'src/gates/command.ts'],
|
|
115
|
+
});
|
|
116
|
+
expect(v.deadEntries).toEqual([]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('裸文件名条目按实况兜底:无任何文件命中才算幽灵', () => {
|
|
120
|
+
const content = withExtras(['| 别名 | routes.ts | 裸 basename |']);
|
|
121
|
+
const v = reconcileCapabilities({
|
|
122
|
+
content,
|
|
123
|
+
populationFiles: [
|
|
124
|
+
'src/core/checker.ts',
|
|
125
|
+
'src/gates/command.ts',
|
|
126
|
+
'src/agent-configs/routes.ts',
|
|
127
|
+
],
|
|
128
|
+
});
|
|
129
|
+
expect(v.deadEntries).toEqual([]);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it(' basename 碰撞场景:全路径幽灵即使同名文件存活仍被报出(2026-08-08 事故回归)', () => {
|
|
133
|
+
const content = withExtras(['| 旧 | src/agent-configs/routes.ts | 已删 |']);
|
|
134
|
+
const v = reconcileCapabilities({
|
|
135
|
+
content,
|
|
136
|
+
populationFiles: ['src/agents/routes.ts'],
|
|
137
|
+
fileExists: () => false,
|
|
138
|
+
});
|
|
139
|
+
expect(v.deadEntries).toContain('src/agent-configs/routes.ts');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('significantCodeChanges', () => {
|
|
144
|
+
it('只留有意义的代码变更:扩展名过滤 + 排除测试文件', () => {
|
|
145
|
+
const names = [
|
|
146
|
+
'src/core/checker.ts',
|
|
147
|
+
'src/web/App.tsx',
|
|
148
|
+
'scripts/run.js',
|
|
149
|
+
'src/__tests__/checker-extra.test.ts',
|
|
150
|
+
'src/core/checker.test.ts',
|
|
151
|
+
'src/core/checker.spec.ts',
|
|
152
|
+
'docs/readme.md',
|
|
153
|
+
'package.json',
|
|
154
|
+
];
|
|
155
|
+
expect(significantCodeChanges(names)).toEqual([
|
|
156
|
+
'src/core/checker.ts',
|
|
157
|
+
'src/web/App.tsx',
|
|
158
|
+
'scripts/run.js',
|
|
159
|
+
]);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('collectSourceFiles', () => {
|
|
164
|
+
const fs = require('fs') as typeof import('fs');
|
|
165
|
+
const os = require('os') as typeof import('os');
|
|
166
|
+
const path = require('path') as typeof import('path');
|
|
167
|
+
|
|
168
|
+
let tmpDir: string;
|
|
169
|
+
|
|
170
|
+
beforeEach(() => {
|
|
171
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'reconcile-scan-'));
|
|
172
|
+
fs.mkdirSync(path.join(tmpDir, 'src/core'), { recursive: true });
|
|
173
|
+
fs.mkdirSync(path.join(tmpDir, 'src/__tests__'), { recursive: true });
|
|
174
|
+
fs.writeFileSync(path.join(tmpDir, 'src/core/index.ts'), '');
|
|
175
|
+
fs.writeFileSync(path.join(tmpDir, 'src/core/foo.ts'), '');
|
|
176
|
+
fs.writeFileSync(path.join(tmpDir, 'src/core/types.d.ts'), '');
|
|
177
|
+
fs.writeFileSync(path.join(tmpDir, 'src/core/App.tsx'), '');
|
|
178
|
+
fs.writeFileSync(path.join(tmpDir, 'src/__tests__/foo.test.ts'), '');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('返回项目相对路径;跳过 barrel/声明文件/测试目录;默认不含 tsx', () => {
|
|
182
|
+
expect(collectSourceFiles(tmpDir, ['src']).sort()).toEqual(['src/core/foo.ts']);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('includeTsx 时纳入 .tsx', () => {
|
|
186
|
+
expect(collectSourceFiles(tmpDir, ['src'], { includeTsx: true }).sort()).toEqual([
|
|
187
|
+
'src/core/App.tsx',
|
|
188
|
+
'src/core/foo.ts',
|
|
189
|
+
]);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('多根收集并集', () => {
|
|
193
|
+
fs.mkdirSync(path.join(tmpDir, 'apps/api/src'), { recursive: true });
|
|
194
|
+
fs.writeFileSync(path.join(tmpDir, 'apps/api/src/main.ts'), '');
|
|
195
|
+
expect(collectSourceFiles(tmpDir, ['src', 'apps/api/src']).sort()).toEqual([
|
|
196
|
+
'apps/api/src/main.ts',
|
|
197
|
+
'src/core/foo.ts',
|
|
198
|
+
]);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 能力清单计数注入测试(架构评审 2026-09-02 · 候选9 / harness#88)
|
|
3
|
+
*
|
|
4
|
+
* capabilities-parser 属 core,此前**值导入** cli/commands/definitions 与
|
|
5
|
+
* gates/definitions 来数命令数——core 向上的运行时依赖。现在计数所需的定义
|
|
6
|
+
* 由调用方(cli 侧)注入,core 只消费最小形状(命令条目集合 + 门禁的 cli 字段)。
|
|
7
|
+
*
|
|
8
|
+
* 断言口径:计数由注入源推导,与宿主仓真实定义表无关。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as fs from 'fs';
|
|
12
|
+
import * as os from 'os';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { IRON_LAWS, GUIDELINES } from '../definitions';
|
|
15
|
+
import {
|
|
16
|
+
checkCapabilityCounts,
|
|
17
|
+
updateCapabilityCounts,
|
|
18
|
+
type CapabilityDefinitionSource,
|
|
19
|
+
} from '../capabilities-parser';
|
|
20
|
+
|
|
21
|
+
/** 3 条非门禁命令 + 4 条门禁(其中 2 条带 cli 元数据)→ CLI Commands = 5 */
|
|
22
|
+
const SOURCE: CapabilityDefinitionSource = {
|
|
23
|
+
commands: [{}, {}, {}],
|
|
24
|
+
gates: [{}, { cli: {} }, { cli: {} }, {}],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe('能力清单计数(注入定义源,harness#88)', () => {
|
|
28
|
+
let projectDir: string;
|
|
29
|
+
|
|
30
|
+
beforeAll(() => {
|
|
31
|
+
projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-capability-counts-'));
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterAll(() => {
|
|
35
|
+
try {
|
|
36
|
+
fs.rmSync(projectDir, { recursive: true, force: true });
|
|
37
|
+
} catch {
|
|
38
|
+
// ignore
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
function writeCapabilities(content: string): string {
|
|
43
|
+
const dir = fs.mkdtempSync(path.join(projectDir, 'case-'));
|
|
44
|
+
fs.writeFileSync(path.join(dir, 'CAPABILITIES.md'), content, 'utf-8');
|
|
45
|
+
return dir;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe('updateCapabilityCounts', () => {
|
|
49
|
+
it('CLI Commands 计数 = 注入命令数 + 带 cli 的门禁数', () => {
|
|
50
|
+
const out = updateCapabilityCounts('## CLI Commands (999)\n', SOURCE);
|
|
51
|
+
expect(out).toContain('CLI Commands (5)');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('Quality Gates 计数 = 注入门禁总数(不看 cli 字段)', () => {
|
|
55
|
+
const out = updateCapabilityCounts('## Quality Gates (999)\n', SOURCE);
|
|
56
|
+
expect(out).toContain('Quality Gates (4)');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('Iron Laws / Guidelines 计数仍来自 core 自身定义表(同层,不注入)', () => {
|
|
60
|
+
const out = updateCapabilityCounts('Iron Laws (999)\nGuidelines (999)\n', SOURCE);
|
|
61
|
+
expect(out).toContain(`Iron Laws (${Object.keys(IRON_LAWS).length})`);
|
|
62
|
+
expect(out).toContain(`Guidelines (${Object.keys(GUIDELINES).length})`);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('不触碰文档中不存在的计数行', () => {
|
|
66
|
+
const out = updateCapabilityCounts('# Harness Capabilities\n\n无计数行\n', SOURCE);
|
|
67
|
+
expect(out).toBe('# Harness Capabilities\n\n无计数行\n');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('同一注入源下写回幂等', () => {
|
|
71
|
+
const once = updateCapabilityCounts('CLI Commands (0)\nQuality Gates (0)\n', SOURCE);
|
|
72
|
+
expect(updateCapabilityCounts(once, SOURCE)).toBe(once);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('checkCapabilityCounts', () => {
|
|
77
|
+
it('计数与注入源一致 → match', () => {
|
|
78
|
+
const dir = writeCapabilities('## CLI Commands (5)\n## Quality Gates (4)\n');
|
|
79
|
+
expect(checkCapabilityCounts(dir, SOURCE)).toEqual({ match: true, mismatches: [] });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('计数漂移 → match=false 并报出注入源的 actual', () => {
|
|
83
|
+
const dir = writeCapabilities('## CLI Commands (999)\n## Quality Gates (4)\n');
|
|
84
|
+
const { match, mismatches } = checkCapabilityCounts(dir, SOURCE);
|
|
85
|
+
expect(match).toBe(false);
|
|
86
|
+
expect(mismatches.join('\n')).toContain('CLI Commands: 文档 999 → 实际 5');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('CAPABILITIES.md 不存在 → 跳过(无 mismatch)', () => {
|
|
90
|
+
const dir = fs.mkdtempSync(path.join(projectDir, 'empty-'));
|
|
91
|
+
expect(checkCapabilityCounts(dir, SOURCE)).toEqual({ match: true, mismatches: [] });
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git 证据适配器测试(架构评审 #87)
|
|
3
|
+
*
|
|
4
|
+
* 覆盖:
|
|
5
|
+
* - 真 git adapter 在三类证据(staged diff / 变更名 / HEAD 目录)上的取证正确性
|
|
6
|
+
* - 命令失败语义:diff → ''、ls-tree → null(全部视为新目录)
|
|
7
|
+
* - memo 落在实例层:同一实例内每条 git 命令至多执行一次
|
|
8
|
+
* - context-builder 与 checker 共用同一实例 → 一次 run 内无重复 git 命令
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as fs from 'fs';
|
|
12
|
+
import * as os from 'os';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { execSync } from 'child_process';
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
createGitEvidence,
|
|
18
|
+
parseHeadDirs,
|
|
19
|
+
realGitCommandRunner,
|
|
20
|
+
type GitCommandRunner,
|
|
21
|
+
type GitEvidence,
|
|
22
|
+
} from '../git-evidence';
|
|
23
|
+
import { buildConstraintContext } from '../context-builder';
|
|
24
|
+
import { ConstraintChecker } from '../checker';
|
|
25
|
+
import { GUIDELINES } from '../definitions';
|
|
26
|
+
import type { MergedConstraintsConfig } from '../../../types/project-config';
|
|
27
|
+
|
|
28
|
+
/** 建一个真 git fixture:committed src/existing.ts + 一个 staged 修改 */
|
|
29
|
+
function makeRepo(options: { stagedChange?: boolean } = {}): string {
|
|
30
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-git-evidence-'));
|
|
31
|
+
execSync('git init -q', { cwd: dir, stdio: 'pipe' });
|
|
32
|
+
execSync('git config user.email "test@example.com"', { cwd: dir, stdio: 'pipe' });
|
|
33
|
+
execSync('git config user.name "Test"', { cwd: dir, stdio: 'pipe' });
|
|
34
|
+
fs.mkdirSync(path.join(dir, 'src', 'nested'), { recursive: true });
|
|
35
|
+
fs.writeFileSync(path.join(dir, 'src', 'existing.ts'), 'export const a = 1;\n');
|
|
36
|
+
fs.writeFileSync(path.join(dir, 'src', 'nested', 'deep.ts'), 'export const b = 1;\n');
|
|
37
|
+
fs.writeFileSync(path.join(dir, 'README.md'), '# fixture\n');
|
|
38
|
+
execSync('git add .', { cwd: dir, stdio: 'pipe' });
|
|
39
|
+
execSync('git commit -q -m init', { cwd: dir, stdio: 'pipe' });
|
|
40
|
+
if (options.stagedChange !== false) {
|
|
41
|
+
fs.writeFileSync(path.join(dir, 'src', 'existing.ts'), 'export const a = 2;\n');
|
|
42
|
+
execSync('git add src/existing.ts', { cwd: dir, stdio: 'pipe' });
|
|
43
|
+
}
|
|
44
|
+
return dir;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** 记录每条实际执行的 git 命令,执行本身委托真 adapter */
|
|
48
|
+
function countingRunner(): { runner: GitCommandRunner; commands: string[] } {
|
|
49
|
+
const commands: string[] = [];
|
|
50
|
+
return {
|
|
51
|
+
commands,
|
|
52
|
+
runner: (command, cwd) => {
|
|
53
|
+
commands.push(command);
|
|
54
|
+
return realGitCommandRunner(command, cwd);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** 包住一份证据实例,记录「哪个 phase 调了哪个证据方法」(取证是否同源的可观测面) */
|
|
60
|
+
function recordingEvidence(
|
|
61
|
+
source: GitEvidence,
|
|
62
|
+
phase: () => string,
|
|
63
|
+
calls: string[]
|
|
64
|
+
): GitEvidence {
|
|
65
|
+
return {
|
|
66
|
+
projectPath: source.projectPath,
|
|
67
|
+
stagedDiff: () => {
|
|
68
|
+
calls.push(`${phase()}:stagedDiff`);
|
|
69
|
+
return source.stagedDiff();
|
|
70
|
+
},
|
|
71
|
+
changedFileNames: (staged: boolean) => {
|
|
72
|
+
calls.push(`${phase()}:changedFileNames`);
|
|
73
|
+
return source.changedFileNames(staged);
|
|
74
|
+
},
|
|
75
|
+
headDirs: () => {
|
|
76
|
+
calls.push(`${phase()}:headDirs`);
|
|
77
|
+
return source.headDirs();
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
describe('git 证据适配器(#87)', () => {
|
|
83
|
+
describe('真 git adapter 取证', () => {
|
|
84
|
+
it('stagedDiff 返回 staged 全量 diff;changedFileNames 按 staged 选择命令', () => {
|
|
85
|
+
const dir = makeRepo();
|
|
86
|
+
const evidence = createGitEvidence(dir);
|
|
87
|
+
|
|
88
|
+
expect(evidence.stagedDiff()).toContain('+export const a = 2;');
|
|
89
|
+
expect(evidence.changedFileNames(true)).toBe('src/existing.ts');
|
|
90
|
+
// 无未暂存变更 → unstaged diff 为空
|
|
91
|
+
expect(evidence.changedFileNames(false)).toBe('');
|
|
92
|
+
|
|
93
|
+
fs.writeFileSync(path.join(dir, 'src', 'existing.ts'), 'export const a = 3;\n');
|
|
94
|
+
expect(evidence.changedFileNames(false)).toBe(''); // 实例已 memo,取同一快照
|
|
95
|
+
expect(createGitEvidence(dir).changedFileNames(false)).toBe('src/existing.ts');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('headDirs 覆盖已提交目录,未提交目录不在集合内', () => {
|
|
99
|
+
const dir = makeRepo();
|
|
100
|
+
const dirs = createGitEvidence(dir).headDirs();
|
|
101
|
+
|
|
102
|
+
expect(dirs).not.toBeNull();
|
|
103
|
+
expect(dirs!.has('src')).toBe(true);
|
|
104
|
+
expect(dirs!.has('src/nested')).toBe(true);
|
|
105
|
+
fs.mkdirSync(path.join(dir, 'src', 'brand-new'), { recursive: true });
|
|
106
|
+
expect(createGitEvidence(dir).headDirs()!.has('src/brand-new')).toBe(false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('非 git 目录:diff 类证据为空串,headDirs 为 null(不重试、不抛错)', () => {
|
|
110
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-git-evidence-'));
|
|
111
|
+
const { runner, commands } = countingRunner();
|
|
112
|
+
const evidence = createGitEvidence(dir, runner);
|
|
113
|
+
|
|
114
|
+
expect(evidence.stagedDiff()).toBe('');
|
|
115
|
+
expect(evidence.changedFileNames(true)).toBe('');
|
|
116
|
+
expect(evidence.headDirs()).toBeNull();
|
|
117
|
+
// 失败结果同样 memo:重复调用不再 spawn
|
|
118
|
+
expect(evidence.headDirs()).toBeNull();
|
|
119
|
+
expect(evidence.changedFileNames(true)).toBe('');
|
|
120
|
+
expect(commands.length).toBe(3);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('parseHeadDirs', () => {
|
|
125
|
+
it('逐层展开文件路径的父目录', () => {
|
|
126
|
+
const dirs = parseHeadDirs('src/a/b.ts\nREADME.md\n');
|
|
127
|
+
expect([...dirs].sort()).toEqual(['src', 'src/a']);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe('memo 落在实例层', () => {
|
|
132
|
+
it('同一实例内同类 git 命令至多执行一次', () => {
|
|
133
|
+
const dir = makeRepo();
|
|
134
|
+
const { runner, commands } = countingRunner();
|
|
135
|
+
const evidence = createGitEvidence(dir, runner);
|
|
136
|
+
|
|
137
|
+
const first = evidence.stagedDiff();
|
|
138
|
+
const stagedNames = evidence.changedFileNames(true);
|
|
139
|
+
const unstagedNames = evidence.changedFileNames(false);
|
|
140
|
+
const dirs = evidence.headDirs();
|
|
141
|
+
|
|
142
|
+
expect(evidence.stagedDiff()).toBe(first);
|
|
143
|
+
expect(evidence.changedFileNames(true)).toBe(stagedNames);
|
|
144
|
+
expect(evidence.changedFileNames(false)).toBe(unstagedNames);
|
|
145
|
+
expect(evidence.headDirs()).toEqual(dirs);
|
|
146
|
+
|
|
147
|
+
expect(commands).toEqual([
|
|
148
|
+
'git diff --cached',
|
|
149
|
+
'git diff --cached --name-only',
|
|
150
|
+
'git diff --name-only',
|
|
151
|
+
'git ls-tree -r --name-only HEAD',
|
|
152
|
+
]);
|
|
153
|
+
expect(new Set(commands).size).toBe(commands.length);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('两个实例 = 两次取证(memo 不是隐式全局)', () => {
|
|
157
|
+
const dir = makeRepo();
|
|
158
|
+
const { runner, commands } = countingRunner();
|
|
159
|
+
|
|
160
|
+
createGitEvidence(dir, runner).stagedDiff();
|
|
161
|
+
createGitEvidence(dir, runner).stagedDiff();
|
|
162
|
+
|
|
163
|
+
expect(commands.filter(c => c === 'git diff --cached')).toHaveLength(2);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe('context-builder 与 checker 共用同一证据来源(#87 验收)', () => {
|
|
168
|
+
it('一次 check run 内同类 git 命令至多执行一次', async () => {
|
|
169
|
+
const dir = makeRepo();
|
|
170
|
+
fs.writeFileSync(
|
|
171
|
+
path.join(dir, 'CAPABILITIES.md'),
|
|
172
|
+
'# Capabilities\n\n| 模块 | 文件 | 说明 |\n|------|------|------|\n| existing | src/existing.ts | 条目 |\n'
|
|
173
|
+
);
|
|
174
|
+
const { runner, commands } = countingRunner();
|
|
175
|
+
const shared = createGitEvidence(dir, runner);
|
|
176
|
+
// 记录器:哪个消费者(phase)调了哪个证据方法
|
|
177
|
+
const phase = { current: 'context' };
|
|
178
|
+
const calls: string[] = [];
|
|
179
|
+
const evidence = recordingEvidence(shared, () => phase.current, calls);
|
|
180
|
+
|
|
181
|
+
const context = await buildConstraintContext({ projectPath: dir, staged: true, evidence });
|
|
182
|
+
// capability_sync 经 CheckEnv.stagedDiffNames() 取同一份 git 证据
|
|
183
|
+
const merged: MergedConstraintsConfig = {
|
|
184
|
+
ironLaws: {},
|
|
185
|
+
guidelines: { capability_sync: GUIDELINES['capability_sync'] },
|
|
186
|
+
prompts: {},
|
|
187
|
+
custom: [],
|
|
188
|
+
disabled: [],
|
|
189
|
+
unknownIds: [],
|
|
190
|
+
};
|
|
191
|
+
const checker = new ConstraintChecker({ record: () => undefined });
|
|
192
|
+
phase.current = 'checker';
|
|
193
|
+
const runResult = await checker.checkConstraints(context, merged, evidence);
|
|
194
|
+
|
|
195
|
+
// capability_sync 确实被评估(非 skip)→ 它经 env.stagedDiffNames() 取过证据
|
|
196
|
+
expect(runResult.guidelines.map(r => r.id)).toEqual(['capability_sync']);
|
|
197
|
+
expect(runResult.guidelines[0].skipped).toBeUndefined();
|
|
198
|
+
// 两个消费者都从注入的这一份实例取证据(checker 没有另起炉灶)
|
|
199
|
+
expect(calls).toContain('context:changedFileNames');
|
|
200
|
+
expect(calls).toContain('checker:changedFileNames');
|
|
201
|
+
// 两侧各自需要同一份 staged 名单,合计只 spawn 一次
|
|
202
|
+
expect(commands).toEqual([
|
|
203
|
+
'git diff --cached --name-only',
|
|
204
|
+
'git ls-tree -r --name-only HEAD',
|
|
205
|
+
]);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
});
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import * as fs from 'fs';
|
|
14
|
-
import * as os from 'os';
|
|
15
14
|
import * as path from 'path';
|
|
16
15
|
import { detectInjectionDrift, INJECTION_DRIFT_FIX_HINT } from '../injection-drift';
|
|
17
16
|
import {
|
|
@@ -19,12 +18,11 @@ import {
|
|
|
19
18
|
CONSTRAINTS_START_MARKER,
|
|
20
19
|
} from '../injection-renderer';
|
|
21
20
|
import { getEffectiveConstraints } from '../../effective-constraints';
|
|
21
|
+
import { createProjectFixture, writeProjectConfig } from '../../../test-setup/project-fixture';
|
|
22
22
|
|
|
23
23
|
const TEST_VERSION = '9.9.9-test';
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
return fs.mkdtempSync(path.join(os.tmpdir(), 'harness-drift-test-'));
|
|
27
|
-
}
|
|
25
|
+
const makeTmpProject = (): string => createProjectFixture({ name: 'harness-drift-test' });
|
|
28
26
|
|
|
29
27
|
/** 写入与当前生效集完全一致的注入段(版本 TEST_VERSION) */
|
|
30
28
|
function writeSyncedClaudeMd(root: string, extra = ''): string {
|
|
@@ -102,12 +100,7 @@ describe('detectInjectionDrift', () => {
|
|
|
102
100
|
const root = makeTmpProject();
|
|
103
101
|
writeSyncedClaudeMd(root);
|
|
104
102
|
// 注入后禁用一条 prompt,但不重跑 init
|
|
105
|
-
|
|
106
|
-
fs.writeFileSync(
|
|
107
|
-
path.join(root, '.harness', 'config.yml'),
|
|
108
|
-
'constraints:\n no_fuzzy_completion_claim:\n enabled: false\n',
|
|
109
|
-
'utf-8'
|
|
110
|
-
);
|
|
103
|
+
writeProjectConfig(root, 'constraints:\n no_fuzzy_completion_claim:\n enabled: false\n');
|
|
111
104
|
|
|
112
105
|
const drift = detectInjectionDrift(root, TEST_VERSION);
|
|
113
106
|
|