@dommaker/harness 1.16.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/agents/lifecycle.d.ts.map +1 -1
- package/dist/agents/lifecycle.js +3 -6
- package/dist/agents/lifecycle.js.map +1 -1
- package/dist/cli/command-contract.d.ts +6 -9
- package/dist/cli/command-contract.d.ts.map +1 -1
- package/dist/cli/command-contract.js +6 -0
- package/dist/cli/command-contract.js.map +1 -1
- package/dist/cli/commands/acceptance.d.ts.map +1 -1
- package/dist/cli/commands/acceptance.js +8 -7
- package/dist/cli/commands/acceptance.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +2 -1
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/contract.d.ts.map +1 -1
- package/dist/cli/commands/contract.js +20 -10
- package/dist/cli/commands/contract.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +13 -12
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/init/ci-platform.d.ts +35 -0
- package/dist/cli/commands/init/ci-platform.d.ts.map +1 -0
- package/dist/cli/commands/init/ci-platform.js +59 -0
- package/dist/cli/commands/init/ci-platform.js.map +1 -0
- package/dist/cli/commands/init/ci-wiring.d.ts +20 -0
- package/dist/cli/commands/init/ci-wiring.d.ts.map +1 -0
- package/dist/cli/commands/init/ci-wiring.js +72 -0
- package/dist/cli/commands/init/ci-wiring.js.map +1 -0
- package/dist/cli/commands/init/git-hooks.d.ts +15 -0
- package/dist/cli/commands/init/git-hooks.d.ts.map +1 -0
- package/dist/cli/commands/init/git-hooks.js +64 -0
- package/dist/cli/commands/init/git-hooks.js.map +1 -0
- package/dist/cli/commands/init/governance.d.ts +14 -0
- package/dist/cli/commands/init/governance.d.ts.map +1 -0
- package/dist/cli/commands/init/governance.js +132 -0
- package/dist/cli/commands/init/governance.js.map +1 -0
- package/dist/cli/commands/{init.d.ts → init/index.d.ts} +13 -14
- package/dist/cli/commands/init/index.d.ts.map +1 -0
- package/dist/cli/commands/init/index.js +148 -0
- package/dist/cli/commands/init/index.js.map +1 -0
- package/dist/cli/commands/init/output-style.d.ts +19 -0
- package/dist/cli/commands/init/output-style.d.ts.map +1 -0
- package/dist/cli/commands/init/output-style.js +110 -0
- package/dist/cli/commands/init/output-style.js.map +1 -0
- package/dist/cli/commands/init/presets.d.ts +26 -0
- package/dist/cli/commands/init/presets.d.ts.map +1 -0
- package/dist/cli/commands/init/presets.js +104 -0
- package/dist/cli/commands/init/presets.js.map +1 -0
- package/dist/cli/commands/init/snippets.d.ts +18 -0
- package/dist/cli/commands/init/snippets.d.ts.map +1 -0
- package/dist/cli/commands/init/snippets.js +49 -0
- package/dist/cli/commands/init/snippets.js.map +1 -0
- package/dist/cli/commands/knowledge/audit.d.ts +30 -0
- package/dist/cli/commands/knowledge/audit.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/audit.js +114 -0
- package/dist/cli/commands/knowledge/audit.js.map +1 -0
- package/dist/cli/commands/knowledge/decay.d.ts +19 -0
- package/dist/cli/commands/knowledge/decay.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/decay.js +48 -0
- package/dist/cli/commands/knowledge/decay.js.map +1 -0
- package/dist/cli/commands/knowledge/health.d.ts +36 -0
- package/dist/cli/commands/knowledge/health.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/health.js +172 -0
- package/dist/cli/commands/knowledge/health.js.map +1 -0
- package/dist/cli/commands/knowledge/import.d.ts +26 -0
- package/dist/cli/commands/knowledge/import.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/import.js +63 -0
- package/dist/cli/commands/knowledge/import.js.map +1 -0
- package/dist/cli/commands/knowledge/index.d.ts +25 -0
- package/dist/cli/commands/knowledge/index.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/index.js +84 -0
- package/dist/cli/commands/knowledge/index.js.map +1 -0
- package/dist/cli/commands/knowledge/list.d.ts +25 -0
- package/dist/cli/commands/knowledge/list.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/list.js +60 -0
- package/dist/cli/commands/knowledge/list.js.map +1 -0
- package/dist/cli/commands/knowledge/migrate.d.ts +21 -0
- package/dist/cli/commands/knowledge/migrate.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/migrate.js +48 -0
- package/dist/cli/commands/knowledge/migrate.js.map +1 -0
- package/dist/cli/commands/knowledge/search.d.ts +32 -0
- package/dist/cli/commands/knowledge/search.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/search.js +73 -0
- package/dist/cli/commands/knowledge/search.js.map +1 -0
- package/dist/cli/commands/knowledge/shared.d.ts +14 -0
- package/dist/cli/commands/knowledge/shared.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/shared.js +6 -0
- package/dist/cli/commands/knowledge/shared.js.map +1 -0
- package/dist/cli/commands/knowledge/snapshot.d.ts +18 -0
- package/dist/cli/commands/knowledge/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/snapshot.js +34 -0
- package/dist/cli/commands/knowledge/snapshot.js.map +1 -0
- package/dist/cli/commands/knowledge/stats.d.ts +26 -0
- package/dist/cli/commands/knowledge/stats.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/stats.js +132 -0
- package/dist/cli/commands/knowledge/stats.js.map +1 -0
- package/dist/cli/commands/knowledge/sync-rag.d.ts +19 -0
- package/dist/cli/commands/knowledge/sync-rag.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/sync-rag.js +77 -0
- package/dist/cli/commands/knowledge/sync-rag.js.map +1 -0
- package/dist/cli/commands/knowledge-view.d.ts +2 -1
- package/dist/cli/commands/knowledge-view.d.ts.map +1 -1
- package/dist/cli/commands/knowledge-view.js +2 -2
- package/dist/cli/commands/knowledge-view.js.map +1 -1
- package/dist/cli/commands/passes-gate.d.ts.map +1 -1
- package/dist/cli/commands/passes-gate.js +12 -2
- package/dist/cli/commands/passes-gate.js.map +1 -1
- package/dist/cli/commands/performance.js.map +1 -1
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +13 -41
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/review.d.ts.map +1 -1
- package/dist/cli/commands/review.js +3 -2
- package/dist/cli/commands/review.js.map +1 -1
- package/dist/cli/commands/security.d.ts.map +1 -1
- package/dist/cli/commands/security.js +7 -8
- package/dist/cli/commands/security.js.map +1 -1
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +6 -5
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.js +31 -55
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +18 -12
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/compact.d.ts +9 -0
- package/dist/cli/commands/sync-docs/compact.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/compact.js +73 -0
- package/dist/cli/commands/sync-docs/compact.js.map +1 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +17 -36
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/gate.d.ts +27 -0
- package/dist/cli/commands/sync-docs/gate.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/gate.js +72 -0
- package/dist/cli/commands/sync-docs/gate.js.map +1 -0
- package/dist/cli/commands/sync-docs/index.d.ts +13 -27
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +19 -529
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/main-flow.d.ts +37 -0
- package/dist/cli/commands/sync-docs/main-flow.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/main-flow.js +485 -0
- package/dist/cli/commands/sync-docs/main-flow.js.map +1 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js +16 -25
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/gate-command.d.ts +1 -1
- package/dist/cli/gate-command.d.ts.map +1 -1
- package/dist/context/index.d.ts +1 -3
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +2 -5
- package/dist/context/index.js.map +1 -1
- package/dist/context/session-manager.d.ts +2 -2
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +31 -52
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +2 -2
- package/dist/context/types.d.ts.map +1 -1
- package/dist/core/constraint-lifecycle.d.ts +1 -1
- package/dist/core/constraint-lifecycle.d.ts.map +1 -1
- package/dist/core/constraint-lifecycle.js +1 -1
- package/dist/core/constraint-lifecycle.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +2 -1
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +4 -6
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.js +1 -0
- package/dist/core/constraints/checkers/templated/exec.js.map +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +13 -34
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
- package/dist/core/constraints/definitions/guidelines.js +18 -0
- package/dist/core/constraints/definitions/guidelines.js.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.js +0 -16
- package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +192 -223
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/git-evidence.d.ts.map +1 -1
- package/dist/core/constraints/git-evidence.js +2 -0
- package/dist/core/constraints/git-evidence.js.map +1 -1
- package/dist/core/constraints/injection-writer.d.ts +1 -0
- package/dist/core/constraints/injection-writer.d.ts.map +1 -1
- package/dist/core/constraints/injection-writer.js +3 -6
- package/dist/core/constraints/injection-writer.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +3 -1
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +6 -6
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/spec/validator.d.ts +1 -1
- package/dist/core/spec/validator.d.ts.map +1 -1
- package/dist/core/spec/validator.js +41 -36
- package/dist/core/spec/validator.js.map +1 -1
- package/dist/core/validators/check-handlers/command.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/command.js +7 -4
- package/dist/core/validators/check-handlers/command.js.map +1 -1
- package/dist/core/validators/check-handlers/http.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/http.js +6 -4
- package/dist/core/validators/check-handlers/http.js.map +1 -1
- package/dist/core/validators/check-handlers/output.d.ts +1 -1
- package/dist/core/validators/check-handlers/output.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/output.js +2 -1
- package/dist/core/validators/check-handlers/output.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +2 -1
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +25 -30
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/gates/acceptance.d.ts +37 -18
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +129 -97
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/command.d.ts +1 -1
- package/dist/gates/contract.d.ts +11 -2
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +57 -62
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/performance.d.ts +1 -1
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +18 -8
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/registry.d.ts.map +1 -1
- package/dist/gates/registry.js +6 -2
- package/dist/gates/registry.js.map +1 -1
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +16 -2
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/security.d.ts +5 -1
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +57 -63
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +11 -78
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/gates/types.js +5 -1
- package/dist/gates/types.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit-dimensions.d.ts +45 -0
- package/dist/knowledge/audit-dimensions.d.ts.map +1 -0
- package/dist/knowledge/audit-dimensions.js +144 -0
- package/dist/knowledge/audit-dimensions.js.map +1 -0
- package/dist/knowledge/audit-rules.d.ts +41 -0
- package/dist/knowledge/audit-rules.d.ts.map +1 -0
- package/dist/knowledge/audit-rules.js +269 -0
- package/dist/knowledge/audit-rules.js.map +1 -0
- package/dist/knowledge/audit-scoring.d.ts +6 -60
- package/dist/knowledge/audit-scoring.d.ts.map +1 -1
- package/dist/knowledge/audit-scoring.js +8 -391
- package/dist/knowledge/audit-scoring.js.map +1 -1
- package/dist/knowledge/audit.d.ts +6 -3
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/audit.js +9 -6
- package/dist/knowledge/audit.js.map +1 -1
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/import.js +5 -4
- package/dist/knowledge/import.js.map +1 -1
- package/dist/knowledge/index-generator.d.ts +2 -0
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +43 -50
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/index.d.ts +4 -2
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +2 -1
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/ingest.d.ts +21 -5
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +12 -9
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lifecycle.d.ts.map +1 -1
- package/dist/knowledge/lifecycle.js +17 -22
- package/dist/knowledge/lifecycle.js.map +1 -1
- package/dist/knowledge/query.d.ts +1 -1
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js +7 -7
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/reference-tracker.d.ts.map +1 -1
- package/dist/knowledge/reference-tracker.js +14 -17
- package/dist/knowledge/reference-tracker.js.map +1 -1
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +17 -36
- package/dist/knowledge/store.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +2 -2
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +9 -7
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +6 -4
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/pretool-use-hook.d.ts +1 -1
- package/dist/pretool-use-hook.d.ts.map +1 -1
- package/dist/pretool-use-hook.js +12 -19
- package/dist/pretool-use-hook.js.map +1 -1
- package/dist/release/integrity.d.ts.map +1 -1
- package/dist/release/integrity.js +8 -8
- package/dist/release/integrity.js.map +1 -1
- package/dist/sdd/index-generator.d.ts.map +1 -1
- package/dist/sdd/index-generator.js +4 -0
- package/dist/sdd/index-generator.js.map +1 -1
- package/dist/types/checkpoint.d.ts +8 -8
- package/dist/types/checkpoint.d.ts.map +1 -1
- package/dist/types/command-io.d.ts +19 -0
- package/dist/types/command-io.d.ts.map +1 -0
- package/dist/types/command-io.js +3 -0
- package/dist/types/command-io.js.map +1 -0
- package/dist/types/gate.d.ts +72 -0
- package/dist/types/gate.d.ts.map +1 -0
- package/dist/types/gate.js +13 -0
- package/dist/types/gate.js.map +1 -0
- package/dist/utils/attempt.d.ts +22 -0
- package/dist/utils/attempt.d.ts.map +1 -0
- package/dist/utils/attempt.js +40 -0
- package/dist/utils/attempt.js.map +1 -0
- package/dist/utils/detect-source-roots.d.ts.map +1 -1
- package/dist/utils/detect-source-roots.js +42 -51
- package/dist/utils/detect-source-roots.js.map +1 -1
- package/dist/utils/file-walk.d.ts +2 -1
- package/dist/utils/file-walk.d.ts.map +1 -1
- package/dist/utils/file-walk.js +3 -8
- package/dist/utils/file-walk.js.map +1 -1
- package/dist/utils/package-json.d.ts +49 -0
- package/dist/utils/package-json.d.ts.map +1 -0
- package/dist/utils/package-json.js +78 -0
- package/dist/utils/package-json.js.map +1 -0
- package/dist/utils/package-version.d.ts +5 -2
- package/dist/utils/package-version.d.ts.map +1 -1
- package/dist/utils/package-version.js +8 -11
- package/dist/utils/package-version.js.map +1 -1
- package/package.json +1 -6
- package/src/CONTEXT.md +5 -4
- package/src/__tests__/acceptance-gate.test.ts +23 -51
- package/src/__tests__/contract-gate.test.ts +1 -1
- package/src/__tests__/install-precommit-hook.test.ts +61 -0
- package/src/__tests__/iron-laws.test.ts +5 -5
- package/src/__tests__/layering.test.ts +1 -1
- package/src/__tests__/public-exports.test.ts +1 -1
- package/src/__tests__/public-type-surface.test.ts +9 -19
- package/src/__tests__/public-value-surface.test.ts +9 -17
- package/src/__tests__/skip-semantics.test.ts +5 -4
- package/src/agents/lifecycle.ts +3 -5
- package/src/cli/__tests__/command-contract.test.ts +18 -0
- package/src/cli/command-contract.ts +8 -5
- package/src/cli/commands/CONTEXT.md +10 -10
- package/src/cli/commands/__tests__/check.test.ts +1 -1
- package/src/cli/commands/__tests__/constraints-retire.test.ts +5 -3
- package/src/cli/commands/__tests__/init-governance-io.test.ts +7 -2
- package/src/cli/commands/__tests__/init.test.ts +1 -1
- package/src/cli/commands/__tests__/knowledge-audit-threshold.test.ts +14 -8
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +2 -1
- package/src/cli/commands/__tests__/knowledge-view.test.ts +28 -18
- package/src/cli/commands/__tests__/knowledge.test.ts +6 -2
- package/src/cli/commands/__tests__/numeric-flag-assembly.test.ts +1 -1
- package/src/cli/commands/__tests__/passes-gate.test.ts +100 -24
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +3 -6
- package/src/cli/commands/__tests__/registry.test.ts +3 -2
- package/src/cli/commands/__tests__/release.test.ts +24 -2
- package/src/cli/commands/__tests__/report-false-green.test.ts +10 -6
- package/src/cli/commands/acceptance.ts +10 -9
- package/src/cli/commands/command.ts +1 -1
- package/src/cli/commands/constraints-retire.ts +3 -2
- package/src/cli/commands/contract.ts +29 -14
- package/src/cli/commands/definitions.ts +13 -12
- package/src/cli/commands/init/ci-platform.ts +66 -0
- package/src/cli/commands/init/ci-wiring.ts +48 -0
- package/src/cli/commands/init/git-hooks.ts +31 -0
- package/src/cli/commands/init/governance.ts +127 -0
- package/src/cli/commands/init/index.ts +156 -0
- package/src/cli/commands/init/output-style.ts +82 -0
- package/src/cli/commands/init/presets.ts +105 -0
- package/src/cli/commands/init/snippets.ts +57 -0
- package/src/cli/commands/knowledge/audit.ts +155 -0
- package/src/cli/commands/knowledge/decay.ts +57 -0
- package/src/cli/commands/knowledge/health.ts +176 -0
- package/src/cli/commands/knowledge/import.ts +82 -0
- package/src/cli/commands/knowledge/index.ts +60 -0
- package/src/cli/commands/knowledge/list.ts +73 -0
- package/src/cli/commands/knowledge/migrate.ts +61 -0
- package/src/cli/commands/knowledge/search.ts +93 -0
- package/src/cli/commands/knowledge/shared.ts +13 -0
- package/src/cli/commands/knowledge/snapshot.ts +38 -0
- package/src/cli/commands/knowledge/stats.ts +112 -0
- package/src/cli/commands/knowledge/sync-rag.ts +48 -0
- package/src/cli/commands/knowledge-view.ts +3 -2
- package/src/cli/commands/passes-gate.ts +14 -2
- package/src/cli/commands/performance.ts +2 -2
- package/src/cli/commands/release.ts +14 -9
- package/src/cli/commands/review.ts +5 -4
- package/src/cli/commands/security.ts +10 -11
- package/src/cli/commands/spec-baseline-check.ts +6 -7
- package/src/cli/commands/status.ts +2 -2
- package/src/cli/commands/sync-docs/agents-syncer.ts +28 -47
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +18 -11
- package/src/cli/commands/sync-docs/compact.ts +35 -0
- package/src/cli/commands/sync-docs/context-syncer.ts +15 -31
- package/src/cli/commands/sync-docs/gate.ts +78 -0
- package/src/cli/commands/sync-docs/index.ts +21 -585
- package/src/cli/commands/sync-docs/main-flow.ts +549 -0
- package/src/cli/commands/sync-docs/project-reader.ts +21 -24
- package/src/cli/gate-command.ts +1 -1
- package/src/context/CONTEXT.md +4 -4
- package/src/context/__tests__/session-manager.test.ts +18 -0
- package/src/context/index.ts +1 -5
- package/src/context/session-manager.ts +34 -50
- package/src/context/types.ts +2 -2
- package/src/core/CONTEXT.md +2 -2
- package/src/core/constraint-lifecycle.ts +2 -2
- package/src/core/constraints/capabilities-parser.ts +4 -6
- package/src/core/constraints/checkers/templated/exec.ts +1 -0
- package/src/core/constraints/checkers/templated/file-exists.ts +1 -1
- package/src/core/constraints/context-builder.ts +11 -28
- package/src/core/constraints/definitions/guidelines.ts +19 -0
- package/src/core/constraints/definitions/iron-laws.ts +0 -17
- package/src/core/constraints/doc-freshness/runner.ts +220 -244
- package/src/core/constraints/git-evidence.ts +2 -0
- package/src/core/constraints/injection-writer.ts +3 -6
- package/src/core/project-config-loader.ts +6 -5
- package/src/core/spec/__tests__/validator.test.ts +65 -13
- package/src/core/spec/validator.ts +50 -40
- package/src/core/validators/__tests__/passes-gate-counts.test.ts +52 -0
- package/src/core/validators/check-handlers/command.ts +9 -6
- package/src/core/validators/check-handlers/http.ts +8 -6
- package/src/core/validators/check-handlers/output.ts +7 -6
- package/src/core/validators/passes-gate.ts +31 -32
- package/src/gates/CONTEXT.md +7 -6
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +16 -14
- package/src/gates/__tests__/acceptance.test.ts +69 -94
- package/src/gates/__tests__/command-single-predicate.test.ts +1 -1
- package/src/gates/__tests__/command.test.ts +23 -12
- package/src/gates/__tests__/gate-interface.test.ts +2 -5
- package/src/gates/__tests__/performance.test.ts +3 -3
- package/src/gates/__tests__/security.test.ts +7 -19
- package/src/gates/acceptance.ts +176 -131
- package/src/gates/command.ts +1 -1
- package/src/gates/contract.ts +86 -79
- package/src/gates/performance.ts +35 -19
- package/src/gates/registry.ts +6 -3
- package/src/gates/review.ts +38 -10
- package/src/gates/security.ts +94 -81
- package/src/gates/types.ts +22 -84
- package/src/index.ts +8 -4
- package/src/knowledge/CONTEXT.md +9 -7
- package/src/knowledge/__tests__/audit-labels.test.ts +3 -3
- package/src/knowledge/__tests__/audit-scoring.test.ts +9 -7
- package/src/knowledge/__tests__/ingest.test.ts +17 -17
- package/src/knowledge/__tests__/store.test.ts +4 -6
- package/src/knowledge/audit-dimensions.ts +190 -0
- package/src/knowledge/audit-rules.ts +335 -0
- package/src/knowledge/audit-scoring.ts +7 -495
- package/src/knowledge/audit.ts +9 -11
- package/src/knowledge/import.ts +7 -6
- package/src/knowledge/index-generator.ts +48 -53
- package/src/knowledge/index.ts +4 -2
- package/src/knowledge/ingest.ts +27 -12
- package/src/knowledge/lifecycle.ts +17 -19
- package/src/knowledge/query.ts +7 -6
- package/src/knowledge/reference-tracker.ts +14 -16
- package/src/knowledge/store.ts +17 -32
- package/src/monitoring/trace-analyzer.ts +12 -9
- package/src/monitoring/traces.ts +8 -6
- package/src/pretool-use-hook.ts +26 -21
- package/src/release/CONTEXT.md +1 -1
- package/src/release/__tests__/integrity.test.ts +0 -2
- package/src/release/integrity.ts +8 -9
- package/src/sdd/index-generator.ts +4 -0
- package/src/types/checkpoint.ts +8 -8
- package/src/types/command-io.ts +14 -0
- package/src/types/gate.ts +77 -0
- package/src/utils/__tests__/attempt.test.ts +94 -0
- package/src/utils/__tests__/package-json.test.ts +58 -0
- package/src/utils/__tests__/package-version.test.ts +21 -2
- package/src/utils/attempt.ts +35 -0
- package/src/utils/detect-source-roots.ts +38 -44
- package/src/utils/file-walk.ts +3 -7
- package/src/utils/package-json.ts +61 -0
- package/src/utils/package-version.ts +8 -10
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/init.js +0 -502
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/knowledge.d.ts +0 -169
- package/dist/cli/commands/knowledge.d.ts.map +0 -1
- package/dist/cli/commands/knowledge.js +0 -700
- package/dist/cli/commands/knowledge.js.map +0 -1
- package/dist/context/knowledge-injector.d.ts +0 -51
- package/dist/context/knowledge-injector.d.ts.map +0 -1
- package/dist/context/knowledge-injector.js +0 -128
- package/dist/context/knowledge-injector.js.map +0 -1
- package/dist/gates/index.d.ts +0 -10
- package/dist/gates/index.d.ts.map +0 -1
- package/dist/gates/index.js +0 -11
- package/dist/gates/index.js.map +0 -1
- package/src/cli/commands/init.ts +0 -590
- package/src/cli/commands/knowledge.ts +0 -820
- package/src/context/__tests__/knowledge-injector.test.ts +0 -197
- package/src/context/knowledge-injector.ts +0 -174
- package/src/gates/index.ts +0 -11
|
@@ -4,91 +4,26 @@
|
|
|
4
4
|
* 自动同步项目文档:CAPABILITIES.md、CONTEXT.md 检查、CHANGELOG 辅助
|
|
5
5
|
* --check 模式输出结构化信息,供 LLM 或 CI 消费
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
7
|
+
* 实现拆分(Phase 3:原 index.ts 611 行单函数按三互斥形态拆开):
|
|
8
|
+
* - index.ts(本文件) 入口装配:--gate 前置校验 → --compact 分派 → 主流程
|
|
9
|
+
* - main-flow.ts 主流程(扫描/判定/json 与人读报告/写入自愈)+ SyncDocsOptions + 计数源装配
|
|
10
|
+
* - gate.ts --gate 形态:前置用法校验 + vs HEAD 漂移判定尾部(harness#189)
|
|
11
|
+
* - compact.ts --compact 形态:CAPABILITIES.md 文件表格折叠为目录条目
|
|
12
|
+
* - project-reader.ts 项目信息读取(package.json/config.yml/源码扫描)
|
|
13
|
+
* - capabilities-syncer.ts CAPABILITIES.md 文件表格格式的对比与维护(能力清单格式解析/计数走 core/constraints/capabilities-parser)
|
|
14
|
+
* - context-syncer.ts CONTEXT.md 模板生成/发现/过时判定 + 目录导出面采集(harness#142)+ 构造点计数采集(harness#202)
|
|
15
|
+
* - agents-syncer.ts AGENTS.md 生成
|
|
16
|
+
* - preserve-block.ts PRESERVE 标记块提取与组合
|
|
17
|
+
* - head-gate.ts --gate 的 vs HEAD 漂移判定(harness#189)
|
|
14
18
|
*/
|
|
15
19
|
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
isCapabilityListingFormat,
|
|
22
|
-
checkCapabilityCounts,
|
|
23
|
-
updateCapabilityCounts,
|
|
24
|
-
type CapabilityDefinitionSource,
|
|
25
|
-
} from '../../../core/constraints/capabilities-parser';
|
|
26
|
-
import { COMMAND_DEFINITIONS } from '../definitions';
|
|
27
|
-
import { GATE_DEFINITIONS } from '../../../gates/definitions';
|
|
28
|
-
import { reconcileCapabilities } from '../../../core/constraints/capabilities-reconcile';
|
|
29
|
-
import { reconcileContext } from '../../../core/constraints/context-reconcile';
|
|
30
|
-
import {
|
|
31
|
-
parseConstructionSiteMarkers,
|
|
32
|
-
reconcileConstructionSites,
|
|
33
|
-
} from '../../../core/constraints/construction-sites';
|
|
34
|
-
import { detectSourceRoots } from '../../../utils/detect-source-roots';
|
|
35
|
-
import { getCapabilitiesMode } from '../../../core/project-config-loader';
|
|
36
|
-
import { getSourceDirs, scanSourceModules, getRequiredContextDirs } from './project-reader';
|
|
37
|
-
import type { ModuleInfo, SyncResult } from './project-reader';
|
|
38
|
-
import {
|
|
39
|
-
parseCapabilitiesFiles,
|
|
40
|
-
updateCapabilitiesFile,
|
|
41
|
-
compactCapabilitiesContent,
|
|
42
|
-
normalizeCapabilitiesTableLayout,
|
|
43
|
-
} from './capabilities-syncer';
|
|
44
|
-
import {
|
|
45
|
-
createContextMd,
|
|
46
|
-
findExistingContextFiles,
|
|
47
|
-
getLatestTsMtime,
|
|
48
|
-
collectContextExportSurface,
|
|
49
|
-
createConstructionSiteCounter,
|
|
50
|
-
type ConstructionSiteCounter,
|
|
51
|
-
} from './context-syncer';
|
|
52
|
-
import { buildAgentsMd } from './agents-syncer';
|
|
53
|
-
import { extractPreserveBlocks, composeAgentsMd } from './preserve-block';
|
|
54
|
-
import {
|
|
55
|
-
assertHeadGateEnv,
|
|
56
|
-
diffManagedDocsAgainstHead,
|
|
57
|
-
missingRegistrationNames,
|
|
58
|
-
} from './head-gate';
|
|
59
|
-
import { log, processIO, type CommandIO, type CommandResult } from '../../command-contract';
|
|
20
|
+
import { processIO, type CommandIO, type CommandResult } from '../../command-contract';
|
|
21
|
+
import { assertGateUsage } from './gate';
|
|
22
|
+
import { runCompactSync } from './compact';
|
|
23
|
+
import { driftOutcome, runMainSyncFlow } from './main-flow';
|
|
24
|
+
import type { SyncDocsOptions } from './main-flow';
|
|
60
25
|
|
|
61
|
-
export
|
|
62
|
-
/** 项目路径 */
|
|
63
|
-
projectPath?: string;
|
|
64
|
-
/** 只检查,不写入(CI 模式) */
|
|
65
|
-
check?: boolean;
|
|
66
|
-
/** 是否生成 CHANGELOG 条目 */
|
|
67
|
-
changelog?: boolean;
|
|
68
|
-
/** 输出 JSON 格式(供 LLM 消费) */
|
|
69
|
-
json?: boolean;
|
|
70
|
-
/** 同步 AGENTS.md(agent 导读);PRESERVE 标记段在重新生成时原样保留 */
|
|
71
|
-
agents?: boolean;
|
|
72
|
-
/** 一次性迁移:将 CAPABILITIES.md 文件表格折叠为目录条目 */
|
|
73
|
-
compact?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* 门禁模式(harness#189):照常自愈写入后,判定被管理文档相对 HEAD 是否有
|
|
76
|
-
* diff——有 diff 判 fail 且点名缺登记文件,无 diff 判 ok。语义等价原流水线
|
|
77
|
-
* 内联 `git diff --exit-code` 门;与 --check/--json/--compact 互斥。
|
|
78
|
-
*/
|
|
79
|
-
gate?: boolean;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 能力清单计数源(harness#88)
|
|
84
|
-
*
|
|
85
|
-
* core 的 capabilities-parser 不再值导入定义表(单向分层),命令/门禁计数由
|
|
86
|
-
* cli 侧在此组装后注入;两张表都是纯数据模块(ADR-0002 命令形状单一来源)。
|
|
87
|
-
*/
|
|
88
|
-
const CAPABILITY_DEFINITIONS: CapabilityDefinitionSource = {
|
|
89
|
-
commands: COMMAND_DEFINITIONS,
|
|
90
|
-
gates: GATE_DEFINITIONS,
|
|
91
|
-
};
|
|
26
|
+
export type { SyncDocsOptions } from './main-flow';
|
|
92
27
|
|
|
93
28
|
/**
|
|
94
29
|
* 同步文档
|
|
@@ -99,518 +34,19 @@ export async function syncDocs(
|
|
|
99
34
|
): Promise<CommandResult> {
|
|
100
35
|
const projectPath = options.projectPath || process.cwd();
|
|
101
36
|
const isCheck = options.check === true;
|
|
102
|
-
// 漂移译成 kind:--check 下判定失败;写入模式下漂移已被修掉 → 退出码面不变(历史行为)
|
|
103
|
-
const drift = (reason: string): CommandResult => (isCheck ? { kind: 'fail', reason } : { kind: 'ok' });
|
|
104
37
|
const isJson = options.json === true;
|
|
105
|
-
const capsMode = getCapabilitiesMode(projectPath);
|
|
106
38
|
|
|
107
39
|
// --gate(harness#189):自愈写入 + vs HEAD 漂移判定。与只读/迁移形态互斥
|
|
108
40
|
// (不猜意图);前置校验先于任何写入(脏用法零落盘)。
|
|
109
41
|
if (options.gate) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
kind: 'usage-error',
|
|
113
|
-
reason: '--gate 与 --check/--json/--compact 互斥(gate = 自愈写入 + vs HEAD 漂移判定)',
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
try {
|
|
117
|
-
assertHeadGateEnv(projectPath);
|
|
118
|
-
} catch (err) {
|
|
119
|
-
return { kind: 'usage-error', reason: (err as Error).message };
|
|
120
|
-
}
|
|
42
|
+
const usageError = assertGateUsage(options, projectPath);
|
|
43
|
+
if (usageError) return usageError;
|
|
121
44
|
}
|
|
122
45
|
|
|
123
46
|
// --compact:一次性迁移,将文件表格折叠为目录条目后直接返回
|
|
124
47
|
if (options.compact) {
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
const content = await fs.readFile(capsPath, 'utf-8');
|
|
128
|
-
const compacted = compactCapabilitiesContent(content);
|
|
129
|
-
if (compacted !== content) {
|
|
130
|
-
await fs.writeFile(capsPath, compacted, 'utf-8');
|
|
131
|
-
if (!isJson) log(io, chalk.green('✅ 已将 CAPABILITIES.md 文件表格折叠为目录条目'));
|
|
132
|
-
} else {
|
|
133
|
-
if (!isJson) log(io, chalk.green('✅ CAPABILITIES.md 无需折叠'));
|
|
134
|
-
}
|
|
135
|
-
return { kind: 'ok' };
|
|
136
|
-
} catch {
|
|
137
|
-
if (!isJson) log(io, chalk.red('❌ CAPABILITIES.md 不存在,无法折叠'));
|
|
138
|
-
return drift('CAPABILITIES.md 不存在,无法折叠');
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (!isJson) {
|
|
143
|
-
if (isCheck) {
|
|
144
|
-
log(io, chalk.blue('🔍 检查文档新鲜度...'));
|
|
145
|
-
} else {
|
|
146
|
-
log(io, chalk.blue('📝 同步文档...'));
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const result: SyncResult = {
|
|
151
|
-
added: [],
|
|
152
|
-
removed: [],
|
|
153
|
-
contextMissing: [],
|
|
154
|
-
contextStale: [],
|
|
155
|
-
contextContentDrift: [],
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
// 1. 先判定本次运行需要什么:源码目录列表 + 现有 CAPABILITIES.md 的格式
|
|
159
|
-
// (格式判定必须在扫描之前——它决定下面那份清单要不要去取)
|
|
160
|
-
const srcDirs = await getSourceDirs(projectPath);
|
|
161
|
-
const capabilitiesPath = path.join(projectPath, 'CAPABILITIES.md');
|
|
162
|
-
let existingFiles: string[] = [];
|
|
163
|
-
let capsContent = '';
|
|
164
|
-
let capsIsCapabilityListing = false;
|
|
165
|
-
try {
|
|
166
|
-
capsContent = await fs.readFile(capabilitiesPath, 'utf-8');
|
|
167
|
-
// mode=listing 是清单格式的显式声明,与嗅探结果等价
|
|
168
|
-
if (capsMode === 'listing' || isCapabilityListingFormat(capsContent)) {
|
|
169
|
-
capsIsCapabilityListing = true;
|
|
170
|
-
} else {
|
|
171
|
-
existingFiles = await parseCapabilitiesFiles(capabilitiesPath);
|
|
172
|
-
}
|
|
173
|
-
} catch {
|
|
174
|
-
// CAPABILITIES.md 不存在,将创建
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// 2. 扫描源码模块(从 governance config 读取目录列表,默认 src/)
|
|
178
|
-
// capability-listing 格式不做条目级比对(计数才是判定面),模块清单在本次运行里无人
|
|
179
|
-
// 消费 → 整树一份 .ts 内容都不读(harness#147;改造前是无条件全树逐文件读首行注释)。
|
|
180
|
-
const currentModules: ModuleInfo[] = [];
|
|
181
|
-
if (!capsIsCapabilityListing) {
|
|
182
|
-
for (const srcDir of srcDirs) {
|
|
183
|
-
try {
|
|
184
|
-
const modules = await scanSourceModules(path.join(projectPath, srcDir), projectPath);
|
|
185
|
-
currentModules.push(...modules);
|
|
186
|
-
} catch {
|
|
187
|
-
if (!isJson) {
|
|
188
|
-
log(io, chalk.yellow(`⚠️ 未找到 ${srcDir} 目录,跳过`));
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// 3. 对比差异(分两种格式)
|
|
195
|
-
let capCountMismatches: string[] = [];
|
|
196
|
-
|
|
197
|
-
if (capsIsCapabilityListing) {
|
|
198
|
-
// 能力清单格式:委托 FreshnessRunner 对比计数
|
|
199
|
-
const countCheck = checkCapabilityCounts(projectPath, CAPABILITY_DEFINITIONS);
|
|
200
|
-
capCountMismatches = countCheck.mismatches;
|
|
201
|
-
// 不填充 result.added/removed(文件级对比不适用于此格式)
|
|
202
|
-
} else {
|
|
203
|
-
// 传统的文件表格格式:覆盖/幽灵判定统一走 capabilities-reconcile(ADR-0009),
|
|
204
|
-
// 与 capability_sync / docs_freshness 检查器共享同一份规则,check 与 fix 口径必然一致
|
|
205
|
-
const getBasename = (f: string) => {
|
|
206
|
-
const clean = f.endsWith('/') ? f.slice(0, -1) : f;
|
|
207
|
-
return clean.split('/').pop()!;
|
|
208
|
-
};
|
|
209
|
-
const verdict = reconcileCapabilities({
|
|
210
|
-
content: capsContent,
|
|
211
|
-
populationFiles: currentModules.map((m) => m.file),
|
|
212
|
-
fileExists: (rel) => existsSync(path.join(projectPath, rel)),
|
|
213
|
-
sourceRoots: detectSourceRoots(projectPath),
|
|
214
|
-
});
|
|
215
|
-
if (capsMode === 'module') {
|
|
216
|
-
// module 模式:added 为聚合后的「未覆盖目录」,需人工登记目录条目
|
|
217
|
-
result.added = verdict.uncoveredDirs;
|
|
218
|
-
} else {
|
|
219
|
-
result.added = verdict.uncoveredFiles.map((f) => getBasename(f));
|
|
220
|
-
}
|
|
221
|
-
// removed:文件与目录条目一起查(幽灵目录行若不清除,docs_freshness 从严后
|
|
222
|
-
// check 会持续报失败而 fix 修不掉——check/fix 必须同规则才能收敛)
|
|
223
|
-
result.removed = verdict.deadEntries;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// 4. 检查 CONTEXT.md(缺失 + 内容漂移 + mtime 提示)
|
|
227
|
-
// CI 标志:CI runner 上是全新 checkout,mtime 由 clone 顺序决定(同目录 CONTEXT.md 排序
|
|
228
|
-
// 恒先于 .ts),比出来的「过时」是假灯(harness#142 实测证据)→ 连提示都不给。
|
|
229
|
-
const isCi = Boolean(process.env.CI) && process.env.CI !== 'false';
|
|
230
|
-
|
|
231
|
-
// 4a. 配置中要求的目录:检查缺失
|
|
232
|
-
const contextDirs = await getRequiredContextDirs(projectPath);
|
|
233
|
-
for (const dir of contextDirs) {
|
|
234
|
-
const contextPath = path.join(projectPath, dir, 'CONTEXT.md');
|
|
235
|
-
try {
|
|
236
|
-
await fs.access(contextPath);
|
|
237
|
-
} catch {
|
|
238
|
-
result.contextMissing.push(dir);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// 4b. 自动发现已有的 CONTEXT.md:内容判定(漂移 = 判定面)+ mtime(仅本地提示)
|
|
243
|
-
// 构造点计数器懒建(harness#202):全仓走一遍不便宜,只在某份文档真带
|
|
244
|
-
// construction-sites 标记时才采集,一次运行内按口径 memo 共用。
|
|
245
|
-
let constructionCounter: ConstructionSiteCounter | null = null;
|
|
246
|
-
const existingContextFiles = await findExistingContextFiles(projectPath, srcDirs);
|
|
247
|
-
for (const dir of existingContextFiles) {
|
|
248
|
-
const contextPath = path.join(projectPath, dir, 'CONTEXT.md');
|
|
249
|
-
try {
|
|
250
|
-
const contextMd = await fs.readFile(contextPath, 'utf-8');
|
|
251
|
-
const { surface, barrelExports } = await collectContextExportSurface(
|
|
252
|
-
path.join(projectPath, dir),
|
|
253
|
-
projectPath
|
|
254
|
-
);
|
|
255
|
-
const verdict = reconcileContext({
|
|
256
|
-
contextMdContent: contextMd,
|
|
257
|
-
exportSurface: surface,
|
|
258
|
-
barrelExports,
|
|
259
|
-
});
|
|
260
|
-
// 构造点计数标记(ADR-0039):无标记的散文维持现状不判
|
|
261
|
-
const markers = parseConstructionSiteMarkers(contextMd);
|
|
262
|
-
const siteDrift = markers.length > 0
|
|
263
|
-
? reconcileConstructionSites({
|
|
264
|
-
markers,
|
|
265
|
-
countFor: (constructionCounter ??= createConstructionSiteCounter(projectPath)),
|
|
266
|
-
}).drift
|
|
267
|
-
: [];
|
|
268
|
-
if (
|
|
269
|
-
verdict.ghosts.length > 0 ||
|
|
270
|
-
verdict.unlistedBarrelExports.length > 0 ||
|
|
271
|
-
siteDrift.length > 0
|
|
272
|
-
) {
|
|
273
|
-
result.contextContentDrift.push({
|
|
274
|
-
dir,
|
|
275
|
-
ghosts: verdict.ghosts,
|
|
276
|
-
unlisted: verdict.unlistedBarrelExports,
|
|
277
|
-
...(siteDrift.length > 0 ? { constructionSites: siteDrift } : {}),
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (!isCi) {
|
|
282
|
-
const contextStat = await fs.stat(contextPath);
|
|
283
|
-
const latestTsMtime = await getLatestTsMtime(path.join(projectPath, dir));
|
|
284
|
-
if (latestTsMtime && latestTsMtime > contextStat.mtimeMs) {
|
|
285
|
-
result.contextStale.push(dir);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
} catch {
|
|
289
|
-
// 目录不存在或无法访问,跳过
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// 4c. AGENTS.md(--agents 启用):缺失或内容漂移
|
|
294
|
-
// 漂移比对基于"生成内容 + 既有 PRESERVE 标记块"的组合结果:
|
|
295
|
-
// PRESERVE 块原样穿过,块内手改不报漂移;块外手改/仓库状态变化报漂移。
|
|
296
|
-
let agentsMdExpected: string | null = null;
|
|
297
|
-
let agentsMdExists = false;
|
|
298
|
-
let agentsMdStale = false;
|
|
299
|
-
let agentsMdMalformedPreserve: string[] = [];
|
|
300
|
-
if (options.agents) {
|
|
301
|
-
const generated = await buildAgentsMd(projectPath, srcDirs);
|
|
302
|
-
let existing: string | null = null;
|
|
303
|
-
try {
|
|
304
|
-
existing = await fs.readFile(path.join(projectPath, 'AGENTS.md'), 'utf-8');
|
|
305
|
-
agentsMdExists = true;
|
|
306
|
-
} catch {
|
|
307
|
-
// 缺失视为漂移
|
|
308
|
-
}
|
|
309
|
-
const { blocks, malformed } = existing !== null
|
|
310
|
-
? extractPreserveBlocks(existing)
|
|
311
|
-
: { blocks: [] as string[], malformed: [] as string[] };
|
|
312
|
-
agentsMdMalformedPreserve = malformed;
|
|
313
|
-
agentsMdExpected = composeAgentsMd(generated, blocks);
|
|
314
|
-
agentsMdStale = existing !== agentsMdExpected;
|
|
315
|
-
}
|
|
316
|
-
const hasAgentsIssues = options.agents === true && agentsMdStale;
|
|
317
|
-
|
|
318
|
-
// 表格排版脏行(#171):撤登记时残留的空行会把 CAPABILITIES.md 的表格切断。
|
|
319
|
-
// 判定与修复共用 normalizeCapabilitiesTableLayout 正本——同一份规则,check 报的 fix 必清得掉。
|
|
320
|
-
const tableLayout = capsIsCapabilityListing
|
|
321
|
-
? { blankLines: 0, emptyTables: 0 }
|
|
322
|
-
: normalizeCapabilitiesTableLayout(capsContent);
|
|
323
|
-
const hasTableLayoutIssues = tableLayout.blankLines > 0 || tableLayout.emptyTables > 0;
|
|
324
|
-
|
|
325
|
-
const hasTableEntryIssues = result.added.length > 0 || result.removed.length > 0;
|
|
326
|
-
const hasTableIssues = hasTableEntryIssues || hasTableLayoutIssues;
|
|
327
|
-
const hasCapIssues = capCountMismatches.length > 0;
|
|
328
|
-
// mtime 只作提示,不参与判定(harness#142):判定面是内容漂移与缺失
|
|
329
|
-
const hasContextIssues = result.contextMissing.length > 0 || result.contextContentDrift.length > 0;
|
|
330
|
-
const hasIssues = hasTableIssues || hasCapIssues || hasContextIssues || hasAgentsIssues;
|
|
331
|
-
const contextDriftReason = result.contextContentDrift
|
|
332
|
-
.map((d) => {
|
|
333
|
-
const sites = (d.constructionSites ?? [])
|
|
334
|
-
.map((s) => `${s.className} 期望 ${s.expected} 实际 ${s.actual}`)
|
|
335
|
-
.join(', ');
|
|
336
|
-
return (
|
|
337
|
-
`${d.dir}/CONTEXT.md(幽灵符号: ${d.ghosts.join(', ') || '无'};` +
|
|
338
|
-
`barrel 未登记: ${d.unlisted.join(', ') || '无'}` +
|
|
339
|
-
(sites ? `;构造点漂移: ${sites}` : '') +
|
|
340
|
-
')'
|
|
341
|
-
);
|
|
342
|
-
})
|
|
343
|
-
.join('、');
|
|
344
|
-
|
|
345
|
-
// 5. JSON 输出模式:结构化输出供 LLM 消费
|
|
346
|
-
if (isJson) {
|
|
347
|
-
const jsonOutput: Record<string, unknown> = {
|
|
348
|
-
stale: hasIssues,
|
|
349
|
-
format: capsIsCapabilityListing ? 'capability-listing' : 'file-table',
|
|
350
|
-
summary: {
|
|
351
|
-
added: result.added.length,
|
|
352
|
-
removed: result.removed.length,
|
|
353
|
-
capCountMismatches: capCountMismatches.length,
|
|
354
|
-
contextMissing: result.contextMissing.length,
|
|
355
|
-
contextStale: result.contextStale.length,
|
|
356
|
-
contextContentDrift: result.contextContentDrift.length,
|
|
357
|
-
tableLayoutDirty: hasTableLayoutIssues,
|
|
358
|
-
},
|
|
359
|
-
contextMissing: result.contextMissing.map(d => ({
|
|
360
|
-
dir: d,
|
|
361
|
-
file: `${d}/CONTEXT.md`,
|
|
362
|
-
})),
|
|
363
|
-
contextStale: result.contextStale.map(d => ({
|
|
364
|
-
dir: d,
|
|
365
|
-
file: `${d}/CONTEXT.md`,
|
|
366
|
-
})),
|
|
367
|
-
contentDrift: result.contextContentDrift.map((d) => ({
|
|
368
|
-
dir: d.dir,
|
|
369
|
-
file: `${d.dir}/CONTEXT.md`,
|
|
370
|
-
ghosts: d.ghosts,
|
|
371
|
-
unlisted: d.unlisted,
|
|
372
|
-
...(d.constructionSites ? { constructionSites: d.constructionSites } : {}),
|
|
373
|
-
})),
|
|
374
|
-
resolution: [] as Array<Record<string, unknown>>,
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
if (capsIsCapabilityListing && hasCapIssues) {
|
|
378
|
-
jsonOutput.capCountMismatches = capCountMismatches.map(m => ({ mismatch: m }));
|
|
379
|
-
(jsonOutput.resolution as Array<Record<string, unknown>>).push({
|
|
380
|
-
action: 'sync-capability-counts',
|
|
381
|
-
command: 'harness sync-docs',
|
|
382
|
-
details: 'CAPABILITIES.md 计数与代码不一致,运行 harness sync-docs 自动更新',
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
if (!capsIsCapabilityListing && hasTableEntryIssues) {
|
|
387
|
-
if (capsMode === 'module') {
|
|
388
|
-
// module 模式:added 为聚合后的未覆盖目录,需人工登记目录条目
|
|
389
|
-
jsonOutput.added = result.added.map(d => ({ dir: d }));
|
|
390
|
-
jsonOutput.removed = result.removed.map(f => ({ file: f }));
|
|
391
|
-
(jsonOutput.resolution as Array<Record<string, unknown>>).push({
|
|
392
|
-
action: 'register-capability-dirs',
|
|
393
|
-
details:
|
|
394
|
-
'在 CAPABILITIES.md 中为这些目录登记一行目录条目(如 `| 模块名 | src/xxx/ | 说明 |`)',
|
|
395
|
-
dirs: result.added,
|
|
396
|
-
});
|
|
397
|
-
} else {
|
|
398
|
-
jsonOutput.added = result.added.map(f => {
|
|
399
|
-
const getBasenameLocal = (s: string) => s.split('/').pop()!;
|
|
400
|
-
return {
|
|
401
|
-
file: f,
|
|
402
|
-
module: currentModules.find(m => getBasenameLocal(m.file) === f),
|
|
403
|
-
};
|
|
404
|
-
});
|
|
405
|
-
jsonOutput.removed = result.removed.map(f => ({ file: f }));
|
|
406
|
-
(jsonOutput.resolution as Array<Record<string, unknown>>).push({
|
|
407
|
-
action: 'sync-capabilities',
|
|
408
|
-
command: 'harness sync-docs',
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
if (hasTableLayoutIssues) {
|
|
414
|
-
jsonOutput.tableLayout = {
|
|
415
|
-
blankLines: tableLayout.blankLines,
|
|
416
|
-
emptyTables: tableLayout.emptyTables,
|
|
417
|
-
};
|
|
418
|
-
(jsonOutput.resolution as Array<Record<string, unknown>>).push({
|
|
419
|
-
action: 'sync-capabilities-table-layout',
|
|
420
|
-
command: 'harness sync-docs',
|
|
421
|
-
details:
|
|
422
|
-
'CAPABILITIES.md 的表格被空行切断、或残留无数据行的空表头,运行 harness sync-docs 收拢',
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (hasContextIssues) {
|
|
427
|
-
(jsonOutput.resolution as Array<Record<string, unknown>>).push(
|
|
428
|
-
...(result.contextMissing.length > 0
|
|
429
|
-
? [{ action: 'create-context-md', command: 'harness sync-docs', dirs: result.contextMissing }]
|
|
430
|
-
: []),
|
|
431
|
-
...(result.contextContentDrift.length > 0
|
|
432
|
-
? [{
|
|
433
|
-
action: 'fix-context-content-drift',
|
|
434
|
-
details:
|
|
435
|
-
'CONTEXT.md「核心导出」节与目录导出面不一致:要么按实现改文档,要么在票面记录'
|
|
436
|
-
+ '「文档正确、代码待改」;散文不可机械生成,sync-docs 不改写 CONTEXT.md',
|
|
437
|
-
drift: result.contextContentDrift,
|
|
438
|
-
}]
|
|
439
|
-
: []),
|
|
440
|
-
...(result.contextStale.length > 0
|
|
441
|
-
? [{ action: 'update-context-md', command: 'harness sync-docs', dirs: result.contextStale }]
|
|
442
|
-
: []),
|
|
443
|
-
);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
if (options.agents) {
|
|
447
|
-
jsonOutput.agentsMd = { file: 'AGENTS.md', exists: agentsMdExists, stale: agentsMdStale };
|
|
448
|
-
if (agentsMdStale) {
|
|
449
|
-
(jsonOutput.resolution as Array<Record<string, unknown>>).push({
|
|
450
|
-
action: 'sync-agents-md',
|
|
451
|
-
command: 'harness sync-docs --agents',
|
|
452
|
-
details: '生成/更新 AGENTS.md(agent 导读)',
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
log(io, JSON.stringify(jsonOutput, null, 2));
|
|
458
|
-
return hasIssues ? drift('文档不是最新的(详见 --json 输出 issues 字段)') : { kind: 'ok' };
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// 6. 人读输出模式
|
|
462
|
-
if (capsIsCapabilityListing && hasCapIssues) {
|
|
463
|
-
log(io, chalk.yellow(`\n📊 CAPABILITIES.md 计数不一致:`));
|
|
464
|
-
capCountMismatches.forEach(m => log(io, chalk.gray(` - ${m}`)));
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if (result.added.length > 0) {
|
|
468
|
-
if (capsMode === 'module') {
|
|
469
|
-
log(io, chalk.yellow(`\n📄 CAPABILITIES.md 未登记以下模块(目录):`));
|
|
470
|
-
result.added.forEach(d => log(io, chalk.gray(` + ${d}`)));
|
|
471
|
-
log(io,
|
|
472
|
-
chalk.gray(' 请在 CAPABILITIES.md 中为这些目录登记一行目录条目(如 `| 模块名 | src/xxx/ | 说明 |`)')
|
|
473
|
-
);
|
|
474
|
-
} else {
|
|
475
|
-
log(io, chalk.yellow(`\n📄 CAPABILITIES.md 缺少以下模块:`));
|
|
476
|
-
result.added.forEach(f => log(io, chalk.gray(` + ${f}`)));
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
if (result.removed.length > 0) {
|
|
481
|
-
log(io, chalk.yellow(`\n📄 CAPABILITIES.md 包含已删除的模块:`));
|
|
482
|
-
result.removed.forEach(f => log(io, chalk.gray(` - ${f}`)));
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
if (hasTableLayoutIssues) {
|
|
486
|
-
log(io, chalk.yellow(`\n🧹 CAPABILITIES.md 表格排版待收拢:`));
|
|
487
|
-
if (tableLayout.blankLines > 0) {
|
|
488
|
-
log(io, chalk.gray(` - 表格内空行 ${tableLayout.blankLines} 处(CommonMark 会在此把表格切断)`));
|
|
489
|
-
}
|
|
490
|
-
if (tableLayout.emptyTables > 0) {
|
|
491
|
-
log(io, chalk.gray(` - 无数据行的空表 ${tableLayout.emptyTables} 张(连表头/分隔行一起收掉)`));
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
if (result.contextMissing.length > 0) {
|
|
496
|
-
log(io, chalk.yellow(`\n📋 缺少 CONTEXT.md:`));
|
|
497
|
-
result.contextMissing.forEach(d => log(io, chalk.gray(` - ${d}/CONTEXT.md`)));
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (result.contextContentDrift.length > 0) {
|
|
501
|
-
log(io, chalk.yellow(`\n📋 CONTEXT.md 与实现漂移(「核心导出」节 vs 目录导出面):`));
|
|
502
|
-
result.contextContentDrift.forEach((d) => {
|
|
503
|
-
log(io, chalk.gray(` - ${d.dir}/CONTEXT.md`));
|
|
504
|
-
if (d.ghosts.length > 0) {
|
|
505
|
-
log(io, chalk.gray(` 幽灵符号(文档声明、导出面已无): ${d.ghosts.join(', ')}`));
|
|
506
|
-
}
|
|
507
|
-
if (d.unlisted.length > 0) {
|
|
508
|
-
log(io, chalk.gray(` barrel 未登记(公开值符号未进「核心导出」节): ${d.unlisted.join(', ')}`));
|
|
509
|
-
}
|
|
510
|
-
for (const s of d.constructionSites ?? []) {
|
|
511
|
-
log(io,
|
|
512
|
-
chalk.gray(` 构造点漂移(标记声明 ${s.className} = ${s.expected},实况 ${s.actual} 处)`)
|
|
513
|
-
);
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
log(io, chalk.gray(' 散文不可机械生成:按实现改文档,或在票面记录「文档正确、代码待改」'));
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
if (result.contextStale.length > 0) {
|
|
520
|
-
log(io, chalk.gray(`\n💡 提示:以下 CONTEXT.md 的源码比文档新(仅提示,不判失败):`));
|
|
521
|
-
result.contextStale.forEach(d => log(io, chalk.gray(` - ${d}/CONTEXT.md`)));
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
if (hasAgentsIssues) {
|
|
525
|
-
log(io,
|
|
526
|
-
chalk.yellow(agentsMdExists
|
|
527
|
-
? `\n🤖 AGENTS.md 与当前项目状态不一致:`
|
|
528
|
-
: `\n🤖 缺少 AGENTS.md(agent 导读):`)
|
|
529
|
-
);
|
|
530
|
-
log(io, chalk.gray(` - AGENTS.md`));
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
if (agentsMdMalformedPreserve.length > 0) {
|
|
534
|
-
log(io,
|
|
535
|
-
chalk.yellow(
|
|
536
|
-
`\n⚠️ AGENTS.md 中 PRESERVE 标记块未闭合(不予保留,重新生成将丢弃): ${agentsMdMalformedPreserve.join(', ')}`
|
|
537
|
-
)
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// --gate 时无「无需写入即返回」捷径:sync-docs 查不出的未提交手改也是 vs HEAD 漂移,
|
|
542
|
-
// 必须落到末尾的 gate 判定(票面契约:有 diff 即 fail,不问 diff 来源)。
|
|
543
|
-
if (!hasIssues && !options.gate) {
|
|
544
|
-
log(io, chalk.green('✅ 所有文档都是最新的'));
|
|
545
|
-
return { kind: 'ok' };
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
// 7. 检查模式:只报告,不修改
|
|
549
|
-
if (isCheck) {
|
|
550
|
-
log(io, chalk.red('\n❌ 文档不是最新的,请运行 harness sync-docs 更新'));
|
|
551
|
-
// reason 必须可定位(harness#142):CI 判红时要直接拿到文件与符号,不靠翻 stdout
|
|
552
|
-
const tableLayoutReason = hasTableLayoutIssues
|
|
553
|
-
? `;CAPABILITIES.md 表格排版待收拢(表格内空行 ${tableLayout.blankLines} 处、`
|
|
554
|
-
+ `空表 ${tableLayout.emptyTables} 张)`
|
|
555
|
-
: '';
|
|
556
|
-
return drift(
|
|
557
|
-
contextDriftReason
|
|
558
|
-
? `文档不是最新的(CONTEXT.md 与实现漂移:${contextDriftReason})${tableLayoutReason}`
|
|
559
|
-
: `文档不是最新的,请运行 harness sync-docs 更新${tableLayoutReason}`
|
|
560
|
-
);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// 8. 写入模式:更新文档
|
|
564
|
-
if (capsIsCapabilityListing && hasCapIssues) {
|
|
565
|
-
capsContent = updateCapabilityCounts(capsContent, CAPABILITY_DEFINITIONS);
|
|
566
|
-
await fs.writeFile(capabilitiesPath, capsContent, 'utf-8');
|
|
567
|
-
log(io, chalk.green(`\n✅ 已更新 CAPABILITIES.md 计数`));
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if (!capsIsCapabilityListing && hasTableIssues) {
|
|
571
|
-
await updateCapabilitiesFile(capabilitiesPath, currentModules, existingFiles, result, capsMode);
|
|
572
|
-
log(io, chalk.green(`\n✅ 已更新 CAPABILITIES.md`));
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
for (const dir of result.contextMissing) {
|
|
576
|
-
await createContextMd(projectPath, dir, io);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
if (hasAgentsIssues && agentsMdExpected !== null) {
|
|
580
|
-
await fs.writeFile(path.join(projectPath, 'AGENTS.md'), agentsMdExpected, 'utf-8');
|
|
581
|
-
log(io, chalk.green(agentsMdExists ? `✅ 已更新 AGENTS.md` : `✅ 已生成 AGENTS.md`));
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// --gate(harness#189):写入完成后判定被管理文档相对 HEAD 的漂移。
|
|
585
|
-
// 自愈顺序不变(写入永远在校验之前);「需要自愈」本身成为失败,
|
|
586
|
-
// diff 新增行即缺登记名单(不退回裸 check 式不点名的红)。
|
|
587
|
-
if (options.gate) {
|
|
588
|
-
const managedFiles = [
|
|
589
|
-
'CAPABILITIES.md',
|
|
590
|
-
...(options.agents ? ['AGENTS.md'] : []),
|
|
591
|
-
...result.contextMissing.map((d) => `${d}/CONTEXT.md`),
|
|
592
|
-
];
|
|
593
|
-
const gateDrift = diffManagedDocsAgainstHead(projectPath, managedFiles);
|
|
594
|
-
if (gateDrift.files.length === 0) {
|
|
595
|
-
log(io, chalk.green('\n✅ 被管理文档与 HEAD 一致'));
|
|
596
|
-
return { kind: 'ok' };
|
|
597
|
-
}
|
|
598
|
-
log(io, chalk.red('\n❌ 被管理文档相对 HEAD 已过期(自愈写入已落盘,需提交):'));
|
|
599
|
-
gateDrift.files.forEach((f) => log(io, chalk.gray(` - ${f}`)));
|
|
600
|
-
if (gateDrift.capAdded.length > 0) {
|
|
601
|
-
log(io, chalk.yellow(' 缺登记/新增(diff 新增行即名单):'));
|
|
602
|
-
gateDrift.capAdded.forEach((l) => log(io, chalk.gray(` + ${l}`)));
|
|
603
|
-
}
|
|
604
|
-
if (gateDrift.capRemoved.length > 0) {
|
|
605
|
-
log(io, chalk.yellow(' 撤登记/删除(diff 删除行):'));
|
|
606
|
-
gateDrift.capRemoved.forEach((l) => log(io, chalk.gray(` - ${l}`)));
|
|
607
|
-
}
|
|
608
|
-
log(io, chalk.gray(' 请本地运行 harness sync-docs 并提交结果。'));
|
|
609
|
-
const names = missingRegistrationNames(gateDrift.capAdded);
|
|
610
|
-
const reason = `被管理文档相对 HEAD 已过期:${gateDrift.files.join('、')}`
|
|
611
|
-
+ (names.length > 0 ? `;缺登记:${names.join('、')}` : '');
|
|
612
|
-
return { kind: 'fail', reason };
|
|
48
|
+
return runCompactSync(projectPath, isJson, driftOutcome(isCheck), io);
|
|
613
49
|
}
|
|
614
50
|
|
|
615
|
-
return
|
|
51
|
+
return runMainSyncFlow(options, io);
|
|
616
52
|
}
|