@dommaker/harness 1.2.3 → 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 +15 -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 +30 -215
- 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 +33 -26
- 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 +237 -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 +73 -77
- 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 +31 -16
- 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/completion-checkers/index.d.ts +3 -3
- package/dist/completion-checkers/index.js +3 -3
- package/dist/completion-checkers/phase-format.d.ts +1 -1
- package/dist/completion-checkers/phase-format.js +2 -2
- package/dist/completion-checkers/phase-format.js.map +1 -1
- package/dist/completion-checkers/tdd-chain.d.ts +1 -1
- package/dist/completion-checkers/tdd-chain.js +2 -2
- package/dist/completion-checkers/tdd-chain.js.map +1 -1
- package/dist/completion-checkers/types.d.ts +5 -5
- package/dist/completion-checkers/types.d.ts.map +1 -1
- package/dist/completion-checkers/types.js +2 -2
- 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 +7 -1
- package/dist/failure/recorder.d.ts.map +1 -1
- package/dist/failure/recorder.js +13 -9
- 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 +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -4
- 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 +18 -15
- 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 +3 -0
- package/dist/release/index.d.ts.map +1 -0
- package/dist/release/index.js +7 -0
- package/dist/release/index.js.map +1 -0
- package/dist/release/integrity.d.ts +65 -0
- package/dist/release/integrity.d.ts.map +1 -0
- package/dist/release/integrity.js +151 -0
- package/dist/release/integrity.js.map +1 -0
- 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/failure.d.ts +7 -0
- package/dist/types/failure.d.ts.map +1 -1
- package/dist/types/failure.js +8 -1
- package/dist/types/failure.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__/failure-recorder.test.ts +9 -0
- 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__/public-exports.test.ts +3 -0
- 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 +96 -38
- 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 +224 -74
- 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 +108 -86
- 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 +37 -223
- package/src/cli/commands/failure.ts +35 -27
- package/src/cli/commands/init.ts +166 -220
- package/src/cli/commands/knowledge.ts +250 -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 +75 -78
- 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 +31 -15
- 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/completion-checkers/CONTEXT.md +1 -1
- package/src/completion-checkers/__tests__/contract-presence.test.ts +1 -1
- package/src/completion-checkers/__tests__/phase-format.test.ts +1 -1
- package/src/completion-checkers/__tests__/tdd-chain.test.ts +2 -2
- package/src/completion-checkers/index.ts +3 -3
- package/src/completion-checkers/phase-format.ts +2 -2
- package/src/completion-checkers/tdd-chain.ts +2 -2
- package/src/completion-checkers/types.ts +5 -5
- 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 +13 -11
- 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 +11 -6
- 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 +55 -2
- 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 +20 -15
- 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 +24 -0
- package/src/release/__tests__/barrel.test.ts +60 -0
- package/src/release/__tests__/integrity.test.ts +157 -0
- package/src/release/index.ts +2 -0
- package/src/release/integrity.ts +141 -0
- 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/failure.ts +8 -0
- 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
|
@@ -8,6 +8,7 @@ import chalk from 'chalk';
|
|
|
8
8
|
import * as fs from 'fs/promises';
|
|
9
9
|
import * as path from 'path';
|
|
10
10
|
import { ContractGate } from '../../gates/contract';
|
|
11
|
+
import { log, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
11
12
|
|
|
12
13
|
export interface ContractOptions {
|
|
13
14
|
/** 项目路径 */
|
|
@@ -23,8 +24,11 @@ export interface ContractOptions {
|
|
|
23
24
|
/**
|
|
24
25
|
* 执行契约门控
|
|
25
26
|
*/
|
|
26
|
-
export async function contract(
|
|
27
|
-
|
|
27
|
+
export async function contract(
|
|
28
|
+
options: ContractOptions,
|
|
29
|
+
io: CommandIO = processIO,
|
|
30
|
+
): Promise<CommandResult> {
|
|
31
|
+
log(io, chalk.blue('📜 API 契约门控检查...'));
|
|
28
32
|
|
|
29
33
|
const projectPath = options.projectPath || process.cwd();
|
|
30
34
|
const contractPath = options.contractPath || 'openapi.yaml';
|
|
@@ -34,10 +38,10 @@ export async function contract(options: ContractOptions): Promise<void> {
|
|
|
34
38
|
try {
|
|
35
39
|
await fs.access(fullPath);
|
|
36
40
|
} catch {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
log(io);
|
|
42
|
+
log(io, chalk.red('❌ 契约文件不存在'));
|
|
43
|
+
log(io, chalk.red(` ${fullPath}`));
|
|
44
|
+
return { kind: 'fail', reason: `contract file not found: ${fullPath}` };
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
// 创建契约门控实例
|
|
@@ -53,57 +57,61 @@ export async function contract(options: ContractOptions): Promise<void> {
|
|
|
53
57
|
} as any);
|
|
54
58
|
|
|
55
59
|
if (result.passed) {
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
log(io);
|
|
61
|
+
log(io, chalk.green('✅ 契约门控检查通过'));
|
|
58
62
|
|
|
59
63
|
if (result.details) {
|
|
60
|
-
|
|
64
|
+
log(io, chalk.gray(` Schema 有效: ✅`));
|
|
61
65
|
if (result.details.endpoints) {
|
|
62
|
-
|
|
66
|
+
log(io, chalk.gray(` 端点数: ${result.details.endpoints}`));
|
|
63
67
|
}
|
|
64
68
|
if (result.details.breakingChanges === false) {
|
|
65
|
-
|
|
69
|
+
log(io, chalk.gray(` 破坏性变更: 无`));
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
} else {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
log(io);
|
|
74
|
+
log(io, chalk.red('❌ 契约门控检查失败'));
|
|
75
|
+
log(io, chalk.red(` ${result.message}`));
|
|
72
76
|
|
|
73
77
|
if (result.details?.errors) {
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
log(io);
|
|
79
|
+
log(io, chalk.red('验证错误:'));
|
|
76
80
|
(result.details.errors as string[]).forEach((error: string) => {
|
|
77
|
-
|
|
81
|
+
log(io, chalk.red(` - ${error}`));
|
|
78
82
|
});
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
if (result.details?.breakingChanges) {
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
log(io);
|
|
87
|
+
log(io, chalk.red('破坏性变更:'));
|
|
84
88
|
(result.details.breakingChanges as any[]).forEach((change: any) => {
|
|
85
|
-
|
|
89
|
+
log(io, chalk.red(` - ${change.type}: ${change.path}`));
|
|
86
90
|
if (change.description) {
|
|
87
|
-
|
|
91
|
+
log(io, chalk.gray(` ${change.description}`));
|
|
88
92
|
}
|
|
89
93
|
});
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
|
|
96
|
+
return { kind: 'fail', reason: `contract gate denied: ${result.message}` };
|
|
93
97
|
}
|
|
98
|
+
return { kind: 'ok' };
|
|
94
99
|
} catch (error: any) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
log(io);
|
|
101
|
+
log(io, chalk.red('❌ 契约门控检查出错'));
|
|
102
|
+
log(io, chalk.red(` ${error.message}`));
|
|
103
|
+
return { kind: 'fail', reason: `contract gate error: ${error.message}` };
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
/**
|
|
103
108
|
* 验证 OpenAPI Schema 语法
|
|
104
109
|
*/
|
|
105
|
-
export async function validateSchema(
|
|
106
|
-
|
|
110
|
+
export async function validateSchema(
|
|
111
|
+
options: ContractOptions,
|
|
112
|
+
io: CommandIO = processIO,
|
|
113
|
+
): Promise<CommandResult> {
|
|
114
|
+
log(io, chalk.blue('📜 验证 OpenAPI Schema...\n'));
|
|
107
115
|
|
|
108
116
|
const projectPath = options.projectPath || process.cwd();
|
|
109
117
|
const contractPath = options.contractPath || 'openapi.yaml';
|
|
@@ -118,8 +126,8 @@ export async function validateSchema(options: ContractOptions): Promise<void> {
|
|
|
118
126
|
try {
|
|
119
127
|
schema = yaml.load(content);
|
|
120
128
|
} catch (e: any) {
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
log(io, chalk.red(`❌ YAML 解析错误: ${e.message}`));
|
|
130
|
+
return { kind: 'fail', reason: `contract YAML parse error: ${e.message}` };
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
// 基本验证
|
|
@@ -143,26 +151,27 @@ export async function validateSchema(options: ContractOptions): Promise<void> {
|
|
|
143
151
|
}
|
|
144
152
|
|
|
145
153
|
if (errors.length > 0) {
|
|
146
|
-
|
|
147
|
-
errors.forEach(err =>
|
|
148
|
-
|
|
154
|
+
log(io, chalk.red('❌ Schema 验证失败:\n'));
|
|
155
|
+
errors.forEach(err => log(io, chalk.red(` - ${err}`)));
|
|
156
|
+
return { kind: 'fail', reason: `contract schema invalid: ${errors.join('; ')}` };
|
|
149
157
|
}
|
|
150
158
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
log(io, chalk.green('✅ Schema 验证通过'));
|
|
160
|
+
log(io);
|
|
161
|
+
log(io, chalk.gray('Schema 信息:'));
|
|
162
|
+
log(io, chalk.gray(` 版本: ${schema.openapi}`));
|
|
163
|
+
log(io, chalk.gray(` 标题: ${schema.info.title}`));
|
|
164
|
+
log(io, chalk.gray(` API 版本: ${schema.info.version}`));
|
|
157
165
|
|
|
158
166
|
if (schema.paths) {
|
|
159
167
|
const endpoints = Object.keys(schema.paths).flatMap(path =>
|
|
160
168
|
Object.keys(schema.paths[path]).map(method => `${method.toUpperCase()} ${path}`)
|
|
161
169
|
);
|
|
162
|
-
|
|
170
|
+
log(io, chalk.gray(` 端点数: ${endpoints.length}`));
|
|
163
171
|
}
|
|
172
|
+
return { kind: 'ok' };
|
|
164
173
|
} catch (error: any) {
|
|
165
|
-
|
|
166
|
-
|
|
174
|
+
log(io, chalk.red(`❌ 验证失败: ${error.message}`));
|
|
175
|
+
return { kind: 'fail', reason: `contract schema read error: ${error.message}` };
|
|
167
176
|
}
|
|
168
177
|
}
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* - 每个实现引用(CommandImplRef)标注实现文件与导出名;bin 按需
|
|
8
8
|
* per-command 懒加载(O2):只在 action 执行时 require 对应命令模块,
|
|
9
9
|
* 不再经单一 barrel 加载全部命令实现。
|
|
10
|
-
* -
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* - 本模块是纯数据模块(候选7 后零闭包):禁止 import 任何命令实现,
|
|
11
|
+
* 子命令别名是数据(aliases),实参编组归各命令模块的具名导出
|
|
12
|
+
* (那才是它的 interface/测试面);保证 --help/--version 懒加载不被破坏;
|
|
13
|
+
* 注册表完整性断言(引用实现可解析)在 __tests__/registry.test.ts 构建/测试期校验。
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -35,18 +36,21 @@ export interface CommandImplRef {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
|
-
*
|
|
39
|
+
* 子命令条目:主名 → 实现(别名经 aliases 一名多注册,架构评审候选7)
|
|
39
40
|
*/
|
|
40
41
|
export interface CommandSubcommand {
|
|
41
42
|
/** 实现引用 */
|
|
42
43
|
impl: CommandImplRef;
|
|
43
|
-
/**
|
|
44
|
-
|
|
44
|
+
/** 别名:与主名解析到同一实现(不再整块复印 args 闭包) */
|
|
45
|
+
aliases?: string[];
|
|
46
|
+
/** true = 实现签名 (positionals, options)(需要位置参数的命令,如 knowledge search);缺省 (options) */
|
|
47
|
+
withPositionals?: boolean;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
/**
|
|
48
51
|
* 选项条件路由(如 check --list):选项值匹配时以路由替代默认 action;
|
|
49
|
-
*
|
|
52
|
+
* 同一选项可挂多条路由(按序执行,如 passes-gate --coverage)。
|
|
53
|
+
* 实现一律以 (options) 调用;需编组/取值的指向命令模块内的具名包装导出。
|
|
50
54
|
*/
|
|
51
55
|
export interface CommandOptionRoute {
|
|
52
56
|
/** 触发选项键(commander options 对象键名,如 'list') */
|
|
@@ -55,8 +59,6 @@ export interface CommandOptionRoute {
|
|
|
55
59
|
when: unknown;
|
|
56
60
|
/** 实现引用 */
|
|
57
61
|
impl: CommandImplRef;
|
|
58
|
-
/** 实参构造(缺省为 [options]) */
|
|
59
|
-
args?: (positionals: (string | undefined)[], options: Record<string, unknown>) => unknown[];
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
/**
|
|
@@ -87,8 +89,6 @@ export interface CommandDefinition {
|
|
|
87
89
|
optionRoutes?: CommandOptionRoute[];
|
|
88
90
|
/** 默认 action 实参构造(缺省为 [options]) */
|
|
89
91
|
mapActionArgs?: (positionals: (string | undefined)[], options: Record<string, unknown>) => unknown[];
|
|
90
|
-
/** action 完成后处理(接收返回值,如 sync-docs --check 失败 exit(1)) */
|
|
91
|
-
afterRun?: (result: unknown, options: Record<string, unknown>) => void;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -107,7 +107,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
107
107
|
],
|
|
108
108
|
action: { module: 'check', export: 'check' },
|
|
109
109
|
optionRoutes: [
|
|
110
|
-
{ flag: 'list', when: true, impl: { module: 'check', export: 'listLaws' }
|
|
110
|
+
{ flag: 'list', when: true, impl: { module: 'check', export: 'listLaws' } },
|
|
111
111
|
],
|
|
112
112
|
},
|
|
113
113
|
{
|
|
@@ -135,15 +135,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
135
135
|
action: { module: 'passes-gate', export: 'runPassesGate' },
|
|
136
136
|
optionRoutes: [
|
|
137
137
|
{ flag: 'coverage', when: true, impl: { module: 'passes-gate', export: 'runPassesGate' } },
|
|
138
|
-
{
|
|
139
|
-
flag: 'coverage',
|
|
140
|
-
when: true,
|
|
141
|
-
impl: { module: 'passes-gate', export: 'checkCoverage' },
|
|
142
|
-
args: (_pos, options) => [
|
|
143
|
-
options.projectPath || process.cwd(),
|
|
144
|
-
parseInt(String(options.coverageThreshold), 10),
|
|
145
|
-
],
|
|
146
|
-
},
|
|
138
|
+
{ flag: 'coverage', when: true, impl: { module: 'passes-gate', export: 'coverageCheck' } },
|
|
147
139
|
],
|
|
148
140
|
},
|
|
149
141
|
{
|
|
@@ -202,7 +194,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
202
194
|
],
|
|
203
195
|
action: { module: 'spec', export: 'specValidate' },
|
|
204
196
|
subcommands: {
|
|
205
|
-
list: { impl: { module: 'spec', export: 'listSpecTypes' }
|
|
197
|
+
list: { impl: { module: 'spec', export: 'listSpecTypes' } },
|
|
206
198
|
},
|
|
207
199
|
// 未知位置参数按文件路径落回默认 action(spec foo.yaml 合法用法)
|
|
208
200
|
subcommandStrict: false,
|
|
@@ -227,12 +219,8 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
227
219
|
{ flags: '--agents', description: '同步 AGENTS.md(agent 导读;PRESERVE 标记段重新生成时保留)', defaultValue: false },
|
|
228
220
|
{ flags: '--compact', description: '一次性迁移:将 CAPABILITIES.md 文件表格折叠为目录条目', defaultValue: false },
|
|
229
221
|
],
|
|
222
|
+
// --check 下的漂移由实现返回 fail(候选7:退出码映射只在 bin 一处),故无需 afterRun
|
|
230
223
|
action: { module: 'sync-docs', export: 'syncDocs' },
|
|
231
|
-
afterRun: (ok, options) => {
|
|
232
|
-
if (!ok && options.check) {
|
|
233
|
-
process.exit(1);
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
224
|
},
|
|
237
225
|
{
|
|
238
226
|
command: 'knowledge',
|
|
@@ -251,7 +239,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
251
239
|
{ flags: '--title <title>', description: '知识标题(用于 upsert)' },
|
|
252
240
|
{ flags: '--content <content>', description: '知识内容 Markdown(用于 upsert)' },
|
|
253
241
|
{ flags: '--file <path>', description: '从文件读取内容(用于 upsert)' },
|
|
254
|
-
{ flags: '--source <source>', description: '知识来源 (
|
|
242
|
+
{ flags: '--source <source>', description: '知识来源 (cli/design)', defaultValue: 'cli' },
|
|
255
243
|
{ flags: '--fix', description: '自动修复(用于 audit)', defaultValue: false },
|
|
256
244
|
{ flags: '--dry-run', description: '只输出报告不修改(用于 audit)', defaultValue: false },
|
|
257
245
|
{ flags: '--threshold <n>', description: '短内容阈值(字符数,用于 audit)', defaultValue: '50' },
|
|
@@ -259,150 +247,24 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
259
247
|
{ flags: '--json', description: 'JSON 格式输出', defaultValue: false },
|
|
260
248
|
],
|
|
261
249
|
subcommands: {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
args: (_pos, options) => [{
|
|
265
|
-
projectPath: options.projectPath, json: options.json,
|
|
266
|
-
type: options.type, maturity: options.maturity, tag: options.tag,
|
|
267
|
-
}],
|
|
268
|
-
},
|
|
269
|
-
ls: {
|
|
270
|
-
impl: { module: 'knowledge', export: 'knowledgeList' },
|
|
271
|
-
args: (_pos, options) => [{
|
|
272
|
-
projectPath: options.projectPath, json: options.json,
|
|
273
|
-
type: options.type, maturity: options.maturity, tag: options.tag,
|
|
274
|
-
}],
|
|
275
|
-
},
|
|
250
|
+
// 纯投影条目:commander options 与处理器参数同名,原样传入(编组归命令模块)
|
|
251
|
+
list: { impl: { module: 'knowledge', export: 'knowledgeList' }, aliases: ['ls'] },
|
|
276
252
|
search: {
|
|
277
|
-
impl: { module: 'knowledge', export: '
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (!positionals[0]) {
|
|
293
|
-
console.error('请提供搜索关键词');
|
|
294
|
-
process.exit(1);
|
|
295
|
-
}
|
|
296
|
-
return [positionals[0], {
|
|
297
|
-
projectPath: options.projectPath, json: options.json,
|
|
298
|
-
limit: parseInt(String(options.limit), 10),
|
|
299
|
-
}];
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
import: {
|
|
303
|
-
impl: { module: 'knowledge', export: 'knowledgeImport' },
|
|
304
|
-
args: (_pos, options) => [{
|
|
305
|
-
projectPath: options.projectPath, json: options.json,
|
|
306
|
-
sources: options.sources, reset: options.reset,
|
|
307
|
-
}],
|
|
308
|
-
},
|
|
309
|
-
i: {
|
|
310
|
-
impl: { module: 'knowledge', export: 'knowledgeImport' },
|
|
311
|
-
args: (_pos, options) => [{
|
|
312
|
-
projectPath: options.projectPath, json: options.json,
|
|
313
|
-
sources: options.sources, reset: options.reset,
|
|
314
|
-
}],
|
|
315
|
-
},
|
|
316
|
-
decay: {
|
|
317
|
-
impl: { module: 'knowledge', export: 'knowledgeDecay' },
|
|
318
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
|
|
319
|
-
},
|
|
320
|
-
d: {
|
|
321
|
-
impl: { module: 'knowledge', export: 'knowledgeDecay' },
|
|
322
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
|
|
323
|
-
},
|
|
324
|
-
stats: {
|
|
325
|
-
impl: { module: 'knowledge', export: 'knowledgeStats' },
|
|
326
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
|
|
327
|
-
},
|
|
328
|
-
st: {
|
|
329
|
-
impl: { module: 'knowledge', export: 'knowledgeStats' },
|
|
330
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
|
|
331
|
-
},
|
|
332
|
-
'sync-rag': {
|
|
333
|
-
impl: { module: 'knowledge', export: 'knowledgeSyncRag' },
|
|
334
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
|
|
335
|
-
},
|
|
336
|
-
'sync-status': {
|
|
337
|
-
impl: { module: 'knowledge', export: 'knowledgeSyncStatus' },
|
|
338
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
|
|
339
|
-
},
|
|
340
|
-
sync: {
|
|
341
|
-
impl: { module: 'knowledge', export: 'knowledgeSyncStatus' },
|
|
342
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
|
|
343
|
-
},
|
|
344
|
-
upsert: {
|
|
345
|
-
impl: { module: 'knowledge', export: 'knowledgeUpsert' },
|
|
346
|
-
args: (_pos, options) => [{
|
|
347
|
-
scope: options.scope || '',
|
|
348
|
-
title: options.title || '',
|
|
349
|
-
content: options.content || '',
|
|
350
|
-
file: options.file || '',
|
|
351
|
-
type: options.type || 'architecture',
|
|
352
|
-
source: options.source || 'cli',
|
|
353
|
-
}],
|
|
354
|
-
},
|
|
355
|
-
up: {
|
|
356
|
-
impl: { module: 'knowledge', export: 'knowledgeUpsert' },
|
|
357
|
-
args: (_pos, options) => [{
|
|
358
|
-
scope: options.scope || '',
|
|
359
|
-
title: options.title || '',
|
|
360
|
-
content: options.content || '',
|
|
361
|
-
file: options.file || '',
|
|
362
|
-
type: options.type || 'architecture',
|
|
363
|
-
source: options.source || 'cli',
|
|
364
|
-
}],
|
|
365
|
-
},
|
|
366
|
-
audit: {
|
|
367
|
-
impl: { module: 'knowledge', export: 'knowledgeAudit' },
|
|
368
|
-
args: (_pos, options) => [{
|
|
369
|
-
projectPath: options.projectPath, json: options.json,
|
|
370
|
-
fix: options.fix, dryRun: options.dryRun,
|
|
371
|
-
threshold: options.threshold, dir: options.dir,
|
|
372
|
-
}],
|
|
373
|
-
},
|
|
374
|
-
a: {
|
|
375
|
-
impl: { module: 'knowledge', export: 'knowledgeAudit' },
|
|
376
|
-
args: (_pos, options) => [{
|
|
377
|
-
projectPath: options.projectPath, json: options.json,
|
|
378
|
-
fix: options.fix, dryRun: options.dryRun,
|
|
379
|
-
threshold: options.threshold, dir: options.dir,
|
|
380
|
-
}],
|
|
381
|
-
},
|
|
382
|
-
snapshot: {
|
|
383
|
-
impl: { module: 'knowledge', export: 'knowledgeSnapshot' },
|
|
384
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
|
|
385
|
-
},
|
|
386
|
-
migrate: {
|
|
387
|
-
impl: { module: 'knowledge', export: 'knowledgeMigrate' },
|
|
388
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
|
|
389
|
-
},
|
|
390
|
-
index: {
|
|
391
|
-
impl: { module: 'knowledge', export: 'knowledgeIndex' },
|
|
392
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
|
|
393
|
-
},
|
|
394
|
-
idx: {
|
|
395
|
-
impl: { module: 'knowledge', export: 'knowledgeIndex' },
|
|
396
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
|
|
397
|
-
},
|
|
398
|
-
health: {
|
|
399
|
-
impl: { module: 'knowledge', export: 'knowledgeHealth' },
|
|
400
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
|
|
401
|
-
},
|
|
402
|
-
h: {
|
|
403
|
-
impl: { module: 'knowledge', export: 'knowledgeHealth' },
|
|
404
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
|
|
405
|
-
},
|
|
253
|
+
impl: { module: 'knowledge', export: 'knowledgeSearchCommand' },
|
|
254
|
+
aliases: ['s'],
|
|
255
|
+
withPositionals: true,
|
|
256
|
+
},
|
|
257
|
+
import: { impl: { module: 'knowledge', export: 'knowledgeImport' }, aliases: ['i'] },
|
|
258
|
+
decay: { impl: { module: 'knowledge', export: 'knowledgeDecay' }, aliases: ['d'] },
|
|
259
|
+
stats: { impl: { module: 'knowledge', export: 'knowledgeStats' }, aliases: ['st'] },
|
|
260
|
+
'sync-rag': { impl: { module: 'knowledge', export: 'knowledgeSyncRag' } },
|
|
261
|
+
'sync-status': { impl: { module: 'knowledge', export: 'knowledgeSyncStatus' }, aliases: ['sync'] },
|
|
262
|
+
upsert: { impl: { module: 'knowledge', export: 'knowledgeUpsert' }, aliases: ['up'] },
|
|
263
|
+
audit: { impl: { module: 'knowledge', export: 'knowledgeAudit' }, aliases: ['a'] },
|
|
264
|
+
snapshot: { impl: { module: 'knowledge', export: 'knowledgeSnapshot' } },
|
|
265
|
+
migrate: { impl: { module: 'knowledge', export: 'knowledgeMigrate' } },
|
|
266
|
+
index: { impl: { module: 'knowledge', export: 'knowledgeIndex' }, aliases: ['idx'] },
|
|
267
|
+
health: { impl: { module: 'knowledge', export: 'knowledgeHealth' }, aliases: ['h'] },
|
|
406
268
|
},
|
|
407
269
|
},
|
|
408
270
|
{
|
|
@@ -415,14 +277,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
415
277
|
{ flags: '--json', description: 'JSON 输出' },
|
|
416
278
|
],
|
|
417
279
|
subcommands: {
|
|
418
|
-
index: {
|
|
419
|
-
impl: { module: 'sdd', export: 'sddIndex' },
|
|
420
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
|
|
421
|
-
},
|
|
422
|
-
idx: {
|
|
423
|
-
impl: { module: 'sdd', export: 'sddIndex' },
|
|
424
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
|
|
425
|
-
},
|
|
280
|
+
index: { impl: { module: 'sdd', export: 'sddIndex' }, aliases: ['idx'] },
|
|
426
281
|
},
|
|
427
282
|
},
|
|
428
283
|
{
|
|
@@ -437,34 +292,9 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
437
292
|
{ flags: '--json', description: 'JSON 格式输出', defaultValue: false },
|
|
438
293
|
],
|
|
439
294
|
subcommands: {
|
|
440
|
-
list: {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
projectPath: options.projectPath, json: options.json,
|
|
444
|
-
limit: parseInt(String(options.limit), 10),
|
|
445
|
-
type: options.type, level: options.level,
|
|
446
|
-
}],
|
|
447
|
-
},
|
|
448
|
-
ls: {
|
|
449
|
-
impl: { module: 'failure', export: 'failureList' },
|
|
450
|
-
args: (_pos, options) => [{
|
|
451
|
-
projectPath: options.projectPath, json: options.json,
|
|
452
|
-
limit: parseInt(String(options.limit), 10),
|
|
453
|
-
type: options.type, level: options.level,
|
|
454
|
-
}],
|
|
455
|
-
},
|
|
456
|
-
stats: {
|
|
457
|
-
impl: { module: 'failure', export: 'failureStats' },
|
|
458
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
|
|
459
|
-
},
|
|
460
|
-
st: {
|
|
461
|
-
impl: { module: 'failure', export: 'failureStats' },
|
|
462
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
|
|
463
|
-
},
|
|
464
|
-
clear: {
|
|
465
|
-
impl: { module: 'failure', export: 'failureClear' },
|
|
466
|
-
args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
|
|
467
|
-
},
|
|
295
|
+
list: { impl: { module: 'failure', export: 'failureList' }, aliases: ['ls'] },
|
|
296
|
+
stats: { impl: { module: 'failure', export: 'failureStats' }, aliases: ['st'] },
|
|
297
|
+
clear: { impl: { module: 'failure', export: 'failureClear' } },
|
|
468
298
|
},
|
|
469
299
|
},
|
|
470
300
|
{
|
|
@@ -562,22 +392,6 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
562
392
|
},
|
|
563
393
|
],
|
|
564
394
|
},
|
|
565
|
-
{
|
|
566
|
-
command: 'doc-freshness-check',
|
|
567
|
-
argument: '<docPath>',
|
|
568
|
-
description: '检查文档声明的新鲜度:提取可验证声明,与代码对照',
|
|
569
|
-
options: [
|
|
570
|
-
{ flags: '--changed-files <list>', description: '变更文件列表(逗号分隔)' },
|
|
571
|
-
{ flags: '--format <format>', description: '输出格式 (table/json)', defaultValue: 'table' },
|
|
572
|
-
{ flags: '-p, --project-path <path>', description: '项目路径' },
|
|
573
|
-
],
|
|
574
|
-
action: { module: 'doc-freshness-check', export: 'docFreshnessCheck' },
|
|
575
|
-
mapActionArgs: (positionals, options) => [positionals[0], {
|
|
576
|
-
changedFiles: options.changedFiles,
|
|
577
|
-
format: options.format,
|
|
578
|
-
projectPath: options.projectPath,
|
|
579
|
-
}],
|
|
580
|
-
},
|
|
581
395
|
{
|
|
582
396
|
command: 'spec-baseline-check',
|
|
583
397
|
argument: '<specPath>',
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import * as path from 'path';
|
|
9
9
|
import { FailureRecorder } from '../../failure/recorder';
|
|
10
|
+
import { DEFAULT_FAILURE_LOG_FILE } from '../../types/failure';
|
|
11
|
+
import { log, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
10
12
|
|
|
11
13
|
export interface FailureOptions {
|
|
12
14
|
/** 项目路径 */
|
|
@@ -21,7 +23,7 @@ export interface FailureOptions {
|
|
|
21
23
|
function getRecorder(projectPath?: string): FailureRecorder {
|
|
22
24
|
const base = projectPath || process.cwd();
|
|
23
25
|
return new FailureRecorder({
|
|
24
|
-
logFile: path.join(base,
|
|
26
|
+
logFile: path.join(base, DEFAULT_FAILURE_LOG_FILE),
|
|
25
27
|
});
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -29,8 +31,9 @@ function getRecorder(projectPath?: string): FailureRecorder {
|
|
|
29
31
|
* 失败记录列表
|
|
30
32
|
*/
|
|
31
33
|
export async function failureList(
|
|
32
|
-
options: FailureOptions & { limit?: number; type?: string; level?: string },
|
|
33
|
-
|
|
34
|
+
options: FailureOptions & { limit?: number | string; type?: string; level?: string },
|
|
35
|
+
io: CommandIO = processIO,
|
|
36
|
+
): Promise<CommandResult> {
|
|
34
37
|
const recorder = getRecorder(options.projectPath);
|
|
35
38
|
|
|
36
39
|
let records = await recorder.getHistory();
|
|
@@ -41,77 +44,82 @@ export async function failureList(
|
|
|
41
44
|
if (options.level) {
|
|
42
45
|
records = records.filter(r => r.level === options.level);
|
|
43
46
|
}
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
// CLI 直传时 limit 为 commander 字符串值;程序内调用传 number(候选7:编组在命令函数)
|
|
48
|
+
const limit = typeof options.limit === 'string' ? parseInt(options.limit, 10) : options.limit;
|
|
49
|
+
if (limit && limit > 0) {
|
|
50
|
+
records = records.slice(-limit);
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
if (options.json) {
|
|
49
|
-
|
|
50
|
-
return;
|
|
54
|
+
log(io, JSON.stringify({ total: records.length, records }, null, 2));
|
|
55
|
+
return { kind: 'ok' };
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
if (records.length === 0) {
|
|
54
|
-
|
|
55
|
-
return;
|
|
59
|
+
log(io, chalk.yellow('没有失败记录'));
|
|
60
|
+
return { kind: 'ok' };
|
|
56
61
|
}
|
|
57
62
|
|
|
58
|
-
|
|
63
|
+
log(io, chalk.red(`📋 失败记录 (${records.length} 条)\n`));
|
|
59
64
|
for (const record of records) {
|
|
60
65
|
const levelColor = record.level === 'L4' ? chalk.red
|
|
61
66
|
: record.level === 'L3' ? chalk.yellow
|
|
62
67
|
: record.level === 'L2' ? chalk.cyan
|
|
63
68
|
: chalk.gray;
|
|
64
69
|
const time = new Date(record.timestamp).toLocaleString();
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
log(io, ` ${levelColor(`[${record.level}]`)} ${chalk.bold(record.type)} ${chalk.gray(time)}`);
|
|
71
|
+
log(io, ` ${record.message}`);
|
|
67
72
|
}
|
|
73
|
+
return { kind: 'ok' };
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
/**
|
|
71
77
|
* 失败记录统计
|
|
72
78
|
*/
|
|
73
|
-
export async function failureStats(options: FailureOptions): Promise<
|
|
79
|
+
export async function failureStats(options: FailureOptions, io: CommandIO = processIO): Promise<CommandResult> {
|
|
74
80
|
const recorder = getRecorder(options.projectPath);
|
|
75
81
|
const stats = await recorder.getStats();
|
|
76
82
|
|
|
77
83
|
if (options.json) {
|
|
78
|
-
|
|
79
|
-
return;
|
|
84
|
+
log(io, JSON.stringify(stats, null, 2));
|
|
85
|
+
return { kind: 'ok' };
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
if (stats.total === 0) {
|
|
83
|
-
|
|
84
|
-
return;
|
|
89
|
+
log(io, chalk.green('✅ 没有失败记录'));
|
|
90
|
+
return { kind: 'ok' };
|
|
85
91
|
}
|
|
86
92
|
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
log(io, chalk.red(`📊 失败统计\n`));
|
|
94
|
+
log(io, chalk.bold(` 总计: ${stats.total} 条\n`));
|
|
89
95
|
|
|
90
|
-
|
|
96
|
+
log(io, chalk.bold(' 按类型:'));
|
|
91
97
|
for (const [type, count] of Object.entries(stats.byType)) {
|
|
92
|
-
|
|
98
|
+
log(io, ` ${type}: ${count}`);
|
|
93
99
|
}
|
|
94
100
|
|
|
95
|
-
|
|
101
|
+
log(io, chalk.bold('\n 按等级:'));
|
|
96
102
|
for (const [level, count] of Object.entries(stats.byLevel)) {
|
|
97
103
|
const color = level === 'L4' ? chalk.red : level === 'L3' ? chalk.yellow : chalk.gray;
|
|
98
|
-
|
|
104
|
+
log(io, ` ${color(level)}: ${count}`);
|
|
99
105
|
}
|
|
106
|
+
return { kind: 'ok' };
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
/**
|
|
103
110
|
* 清空失败记录
|
|
104
111
|
*/
|
|
105
|
-
export async function failureClear(options: FailureOptions): Promise<
|
|
112
|
+
export async function failureClear(options: FailureOptions, io: CommandIO = processIO): Promise<CommandResult> {
|
|
106
113
|
const recorder = getRecorder(options.projectPath);
|
|
107
114
|
const stats = await recorder.getStats();
|
|
108
115
|
|
|
109
116
|
await recorder.clear();
|
|
110
117
|
|
|
111
118
|
if (options.json) {
|
|
112
|
-
|
|
113
|
-
return;
|
|
119
|
+
log(io, JSON.stringify({ cleared: stats.total }));
|
|
120
|
+
return { kind: 'ok' };
|
|
114
121
|
}
|
|
115
122
|
|
|
116
|
-
|
|
123
|
+
log(io, chalk.green(`✅ 已清空 ${stats.total} 条失败记录`));
|
|
124
|
+
return { kind: 'ok' };
|
|
117
125
|
}
|