@dommaker/harness 1.15.0 → 1.16.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 +12 -0
- package/bin/harness.js +6 -0
- package/dist/cli/command-contract.d.ts +4 -4
- package/dist/cli/command-contract.d.ts.map +1 -1
- package/dist/cli/commands/command.d.ts.map +1 -1
- package/dist/cli/commands/command.js +5 -5
- package/dist/cli/commands/command.js.map +1 -1
- package/dist/cli/commands/constraints-disable.d.ts +7 -11
- package/dist/cli/commands/constraints-disable.d.ts.map +1 -1
- package/dist/cli/commands/constraints-disable.js +8 -80
- package/dist/cli/commands/constraints-disable.js.map +1 -1
- package/dist/cli/commands/constraints-pack-proposal.d.ts +7 -20
- package/dist/cli/commands/constraints-pack-proposal.d.ts.map +1 -1
- package/dist/cli/commands/constraints-pack-proposal.js +21 -129
- package/dist/cli/commands/constraints-pack-proposal.js.map +1 -1
- package/dist/cli/commands/constraints-reactivate.d.ts +8 -20
- package/dist/cli/commands/constraints-reactivate.d.ts.map +1 -1
- package/dist/cli/commands/constraints-reactivate.js +11 -105
- package/dist/cli/commands/constraints-reactivate.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +11 -67
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +18 -195
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/constraints.d.ts +6 -9
- package/dist/cli/commands/constraints.d.ts.map +1 -1
- package/dist/cli/commands/constraints.js +7 -21
- package/dist/cli/commands/constraints.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +4 -19
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/knowledge.js +1 -1
- package/dist/cli/commands/knowledge.js.map +1 -1
- package/dist/cli/commands/release.d.ts +2 -2
- package/dist/cli/commands/release.js +2 -2
- package/dist/cli/commands/scaffold-templates.d.ts +7 -0
- package/dist/cli/commands/scaffold-templates.d.ts.map +1 -1
- package/dist/cli/commands/scaffold-templates.js +21 -1
- package/dist/cli/commands/scaffold-templates.js.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.d.ts +13 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +30 -0
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +30 -4
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts +5 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +7 -0
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/gate-command.js +1 -1
- package/dist/cli/gate-command.js.map +1 -1
- package/dist/completion-checkers/glob-match.d.ts +1 -1
- package/dist/completion-checkers/glob-match.d.ts.map +1 -1
- package/dist/completion-checkers/glob-match.js +3 -38
- package/dist/completion-checkers/glob-match.js.map +1 -1
- package/dist/context/index.d.ts +2 -3
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +2 -6
- package/dist/context/index.js.map +1 -1
- package/dist/context/knowledge-injector.d.ts.map +1 -1
- package/dist/context/knowledge-injector.js +3 -4
- package/dist/context/knowledge-injector.js.map +1 -1
- package/dist/context/session-manager.d.ts +0 -6
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +0 -9
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +0 -24
- package/dist/context/types.d.ts.map +1 -1
- package/dist/core/config-files.d.ts +21 -0
- package/dist/core/config-files.d.ts.map +1 -0
- package/dist/core/config-files.js +75 -0
- package/dist/core/config-files.js.map +1 -0
- package/dist/core/constraint-lifecycle.d.ts +127 -0
- package/dist/core/constraint-lifecycle.d.ts.map +1 -0
- package/dist/core/constraint-lifecycle.js +306 -0
- package/dist/core/constraint-lifecycle.js.map +1 -0
- package/dist/core/constraints/checker.d.ts +9 -1
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +18 -0
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.d.ts +6 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.js +17 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.js.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts +0 -2
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js +0 -5
- package/dist/core/constraints/checkers/no-hardcoded-credentials.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/checkers/templated/glob.d.ts +2 -3
- package/dist/core/constraints/checkers/templated/glob.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/glob.js +4 -40
- package/dist/core/constraints/checkers/templated/glob.js.map +1 -1
- package/dist/core/constraints/construction-sites.d.ts +56 -0
- package/dist/core/constraints/construction-sites.d.ts.map +1 -0
- package/dist/core/constraints/construction-sites.js +75 -0
- package/dist/core/constraints/construction-sites.js.map +1 -0
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +3 -1
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/index.d.ts +0 -2
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +1 -4
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/meta.d.ts +18 -0
- package/dist/core/constraints/meta.d.ts.map +1 -0
- package/dist/core/constraints/meta.js +31 -0
- package/dist/core/constraints/meta.js.map +1 -0
- package/dist/core/constraints/pack-proposal.d.ts +66 -0
- package/dist/core/constraints/pack-proposal.d.ts.map +1 -0
- package/dist/core/constraints/pack-proposal.js +181 -0
- package/dist/core/constraints/pack-proposal.js.map +1 -0
- package/dist/core/constraints/usage-report.d.ts +3 -1
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +3 -1
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/effective-constraints.d.ts +6 -6
- package/dist/core/effective-constraints.d.ts.map +1 -1
- package/dist/core/effective-constraints.js +6 -6
- package/dist/core/effective-constraints.js.map +1 -1
- package/dist/core/index.d.ts +3 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -6
- package/dist/core/index.js.map +1 -1
- package/dist/core/validators/check-handlers/command.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/command.js +42 -4
- package/dist/core/validators/check-handlers/command.js.map +1 -1
- package/dist/gates/checker-gate.d.ts +2 -1
- package/dist/gates/checker-gate.d.ts.map +1 -1
- package/dist/gates/checker-gate.js +2 -1
- package/dist/gates/checker-gate.js.map +1 -1
- package/dist/gates/command.d.ts +3 -20
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +2 -35
- package/dist/gates/command.js.map +1 -1
- package/dist/gates/definitions.d.ts +1 -1
- package/dist/gates/definitions.d.ts.map +1 -1
- package/dist/gates/definitions.js +1 -1
- package/dist/gates/definitions.js.map +1 -1
- package/dist/gates/index.d.ts +6 -40
- package/dist/gates/index.d.ts.map +1 -1
- package/dist/gates/index.js +5 -79
- package/dist/gates/index.js.map +1 -1
- package/dist/gates/registry.js +1 -1
- package/dist/gates/registry.js.map +1 -1
- package/dist/gates/types.d.ts +10 -3
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/index.d.ts +16 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -64
- package/dist/index.js.map +1 -1
- package/dist/knowledge/index.d.ts +1 -3
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +3 -5
- package/dist/knowledge/index.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 +12 -15
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/token-estimate.d.ts +14 -0
- package/dist/knowledge/token-estimate.d.ts.map +1 -0
- package/dist/knowledge/token-estimate.js +31 -0
- package/dist/knowledge/token-estimate.js.map +1 -0
- package/dist/monitoring/analyzer-base.d.ts +0 -8
- package/dist/monitoring/analyzer-base.d.ts.map +1 -1
- package/dist/monitoring/analyzer-base.js +0 -20
- package/dist/monitoring/analyzer-base.js.map +1 -1
- package/dist/monitoring/index.d.ts +2 -7
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/index.js +2 -9
- package/dist/monitoring/index.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +0 -4
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +0 -9
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +14 -10
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +41 -45
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/pretool-use-hook.js +2 -2
- package/dist/release/integrity.d.ts.map +1 -1
- package/dist/release/integrity.js +0 -2
- package/dist/release/integrity.js.map +1 -1
- package/dist/test-setup/jsonl-fake-fs.d.ts +1 -1
- package/dist/test-setup/jsonl-fake-fs.js +1 -1
- package/dist/utils/glob-match.d.ts +10 -0
- package/dist/utils/glob-match.d.ts.map +1 -0
- package/dist/utils/glob-match.js +47 -0
- package/dist/utils/glob-match.js.map +1 -0
- package/dist/utils/jsonl.d.ts +1 -1
- package/dist/utils/jsonl.js +1 -1
- package/dist/utils/yaml-edit.d.ts +26 -0
- package/dist/utils/yaml-edit.d.ts.map +1 -0
- package/dist/utils/yaml-edit.js +98 -0
- package/dist/utils/yaml-edit.js.map +1 -0
- package/package.json +2 -2
- package/src/CONTEXT.md +13 -6
- package/src/__tests__/acceptance-gate.test.ts +2 -4
- package/src/__tests__/effective-constraints.test.ts +16 -0
- package/src/__tests__/layering.test.ts +2 -3
- package/src/__tests__/no-studio-references.test.ts +13 -5
- package/src/__tests__/pretool-use-hook.test.ts +3 -3
- package/src/__tests__/public-exports.test.ts +195 -41
- package/src/__tests__/public-type-surface.test.ts +25 -65
- package/src/__tests__/public-value-surface.test.ts +13 -36
- package/src/__tests__/trace-analyzer-extra.test.ts +1 -13
- package/src/agents/CONTEXT.md +4 -4
- package/src/cli/__tests__/gate-command.test.ts +1 -1
- package/src/cli/command-contract.ts +4 -4
- package/src/cli/commands/CONTEXT.md +4 -4
- package/src/cli/commands/__tests__/command.test.ts +2 -2
- package/src/cli/commands/__tests__/knowledge-view.test.ts +1 -1
- package/src/cli/commands/__tests__/project-path-convention.test.ts +3 -35
- package/src/cli/commands/__tests__/sync-docs-construction-sites.test.ts +175 -0
- package/src/cli/commands/__tests__/validate.test.ts +49 -0
- package/src/cli/commands/command.ts +2 -1
- package/src/cli/commands/constraints-disable.ts +8 -59
- package/src/cli/commands/constraints-pack-proposal.ts +26 -121
- package/src/cli/commands/constraints-reactivate.ts +22 -113
- package/src/cli/commands/constraints-retire.ts +29 -269
- package/src/cli/commands/constraints.ts +6 -30
- package/src/cli/commands/init.ts +5 -19
- package/src/cli/commands/knowledge.ts +1 -1
- package/src/cli/commands/release.ts +2 -2
- package/src/cli/commands/scaffold-templates.ts +23 -0
- package/src/cli/commands/security.ts +1 -1
- package/src/cli/commands/sync-docs/__tests__/construction-site-count.test.ts +49 -0
- package/src/cli/commands/sync-docs/context-syncer.ts +43 -1
- package/src/cli/commands/sync-docs/index.ts +41 -5
- package/src/cli/commands/sync-docs/project-reader.ts +5 -0
- package/src/cli/commands/validate.ts +7 -0
- package/src/cli/gate-command.ts +1 -1
- package/src/completion-checkers/CONTEXT.md +3 -3
- package/src/completion-checkers/glob-match.ts +3 -35
- package/src/context/CONTEXT.md +5 -8
- package/src/context/__tests__/knowledge-injector.test.ts +21 -2
- package/src/context/__tests__/session-manager.test.ts +0 -7
- package/src/context/index.ts +1 -5
- package/src/context/knowledge-injector.ts +3 -4
- package/src/context/session-manager.ts +0 -10
- package/src/context/types.ts +0 -20
- package/src/core/CONTEXT.md +10 -5
- package/src/core/__tests__/config-files.test.ts +88 -0
- package/src/core/__tests__/constraint-lifecycle.test.ts +255 -0
- package/src/core/__tests__/constraints-meta.test.ts +26 -0
- package/src/core/__tests__/pack-proposal.test.ts +95 -0
- package/src/core/config-files.ts +39 -0
- package/src/core/constraint-lifecycle.ts +435 -0
- package/src/core/constraints/__tests__/check-cache.test.ts +0 -7
- package/src/core/constraints/__tests__/collect-constraints.test.ts +25 -0
- package/src/core/constraints/__tests__/construction-sites.test.ts +147 -0
- package/src/core/constraints/__tests__/context-reconcile.test.ts +16 -16
- package/src/core/constraints/__tests__/trace-injection.test.ts +14 -15
- package/src/core/constraints/__tests__/usage-report.test.ts +9 -0
- package/src/core/constraints/checker.ts +20 -1
- package/src/core/constraints/checkers/__tests__/no-completion-without-verification.test.ts +22 -3
- package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +56 -41
- package/src/core/constraints/checkers/no-completion-without-verification.ts +16 -1
- package/src/core/constraints/checkers/no-hardcoded-credentials.ts +0 -5
- package/src/core/constraints/checkers/templated/file-exists.ts +1 -1
- package/src/core/constraints/checkers/templated/glob.ts +3 -36
- package/src/core/constraints/construction-sites.ts +95 -0
- package/src/core/constraints/doc-freshness/runner.ts +4 -1
- package/src/core/constraints/index.ts +0 -4
- package/src/core/constraints/meta.ts +40 -0
- package/src/core/constraints/pack-proposal.ts +179 -0
- package/src/core/constraints/usage-report.ts +3 -1
- package/src/core/effective-constraints.ts +6 -6
- package/src/core/index.ts +0 -15
- package/src/core/validators/__tests__/command-success-output.test.ts +56 -0
- package/src/core/validators/check-handlers/command.ts +44 -4
- package/src/gates/CONTEXT.md +20 -13
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +7 -6
- package/src/gates/__tests__/acceptance.test.ts +3 -5
- package/src/gates/__tests__/command.test.ts +1 -13
- package/src/gates/__tests__/decision.test.ts +35 -0
- package/src/gates/checker-gate.ts +2 -1
- package/src/gates/command.ts +4 -38
- package/src/gates/definitions.ts +2 -2
- package/src/gates/index.ts +8 -95
- package/src/gates/registry.ts +1 -1
- package/src/gates/types.ts +11 -3
- package/src/hooks/CONTEXT.md +1 -1
- package/src/index.ts +50 -95
- package/src/knowledge/CONTEXT.md +6 -4
- package/src/knowledge/__tests__/token-estimate.test.ts +54 -0
- package/src/knowledge/index.ts +1 -3
- package/src/knowledge/query.ts +13 -14
- package/src/knowledge/token-estimate.ts +27 -0
- package/src/monitoring/CONTEXT.md +6 -8
- package/src/monitoring/__tests__/prune-trace-logs.test.ts +76 -0
- package/src/monitoring/__tests__/traces.test.ts +1 -17
- package/src/monitoring/analyzer-base.ts +0 -18
- package/src/monitoring/index.ts +2 -7
- package/src/monitoring/trace-analyzer.ts +0 -8
- package/src/monitoring/traces.ts +51 -51
- package/src/pretool-use-hook.ts +2 -2
- package/src/release/CONTEXT.md +1 -1
- package/src/release/__tests__/integrity.test.ts +3 -5
- package/src/release/integrity.ts +0 -2
- package/src/test-setup/jsonl-fake-fs.ts +1 -1
- package/src/utils/__tests__/glob-match.test.ts +52 -0
- package/src/utils/__tests__/jsonl-skip-disposition.test.ts +0 -1
- package/src/utils/__tests__/yaml-edit.test.ts +62 -0
- package/src/utils/glob-match.ts +41 -0
- package/src/utils/jsonl.ts +1 -1
- package/src/utils/yaml-edit.ts +67 -0
- package/dist/context/token-budget.d.ts +0 -115
- package/dist/context/token-budget.d.ts.map +0 -1
- package/dist/context/token-budget.js +0 -200
- package/dist/context/token-budget.js.map +0 -1
- package/dist/gates/runner.d.ts +0 -30
- package/dist/gates/runner.d.ts.map +0 -1
- package/dist/gates/runner.js +0 -38
- package/dist/gates/runner.js.map +0 -1
- package/dist/knowledge/primitives/code-structure.d.ts +0 -37
- package/dist/knowledge/primitives/code-structure.d.ts.map +0 -1
- package/dist/knowledge/primitives/code-structure.js +0 -185
- package/dist/knowledge/primitives/code-structure.js.map +0 -1
- package/dist/monitoring/context-tracker.d.ts +0 -38
- package/dist/monitoring/context-tracker.d.ts.map +0 -1
- package/dist/monitoring/context-tracker.js +0 -153
- package/dist/monitoring/context-tracker.js.map +0 -1
- package/dist/tools/definitions/core/code/fingerprint.sh +0 -273
- package/dist/tools/definitions/core/code/fingerprint.yml +0 -72
- package/dist/tools/definitions/core/code/parse.yml +0 -68
- package/dist/tools/definitions/core/code/register-language.sh +0 -475
- package/dist/tools/definitions/core/code/register-language.yml +0 -74
- package/dist/tools/definitions/core/docker/build.yml +0 -73
- package/dist/tools/definitions/core/docker/run.yml +0 -81
- package/dist/tools/definitions/core/file/copy.yml +0 -88
- package/dist/tools/definitions/core/file/read.yml +0 -69
- package/dist/tools/definitions/core/file/write.yml +0 -75
- package/dist/tools/definitions/core/git/branch.yml +0 -61
- package/dist/tools/definitions/core/git/cleanup-worktree.yml +0 -50
- package/dist/tools/definitions/core/git/clone.yml +0 -69
- package/dist/tools/definitions/core/git/commit.yml +0 -65
- package/dist/tools/definitions/core/git/push.yml +0 -79
- package/dist/tools/definitions/core/git/worktree.yml +0 -96
- package/dist/tools/definitions/core/notification/notify.sh +0 -152
- package/dist/tools/definitions/core/notification/notify.yml +0 -59
- package/dist/tools/definitions/core/npm/build.yml +0 -75
- package/dist/tools/definitions/core/npm/install.yml +0 -58
- package/dist/tools/definitions/core/npm/test.yml +0 -75
- package/dist/tools/definitions/core/validation/check-reuse.yml +0 -170
- package/dist/tools/definitions/core/validation/validate-handlers.yml +0 -118
- package/dist/tools/definitions/core/validation/validate-readme-stats.yml +0 -155
- package/dist/tools/definitions/core/validation/validate-yaml-syntax.yml +0 -134
- package/dist/tools/definitions/ext/browser/browser-automate.sh +0 -255
- package/dist/tools/definitions/ext/browser/browser-automate.yml +0 -166
- package/dist/tools/definitions/ext/browser/browser-close.sh +0 -104
- package/dist/tools/definitions/ext/browser/browser-close.yml +0 -54
- package/dist/tools/definitions/ext/browser/browser-mcp-debug.sh +0 -682
- package/dist/tools/definitions/ext/browser/browser-mcp-debug.yml +0 -167
- package/dist/tools/definitions/ext/browser/browser-start.sh +0 -101
- package/dist/tools/definitions/ext/browser/browser-start.yml +0 -61
- package/dist/tools/definitions/registry.json +0 -795
- package/dist/tools/definitions/std/README.md +0 -350
- package/dist/tools/definitions/std/analysis/analyze-codebase.yml +0 -72
- package/dist/tools/definitions/std/analysis/analyze-diff.yml +0 -182
- package/dist/tools/definitions/std/analysis/analyze-git-diff.yml +0 -70
- package/dist/tools/definitions/std/analysis/analyze-impact.yml +0 -78
- package/dist/tools/definitions/std/analysis/analyze-requirements.yml +0 -105
- package/dist/tools/definitions/std/analysis/brainstorm-options.yml +0 -106
- package/dist/tools/definitions/std/analysis/build-graph.yml +0 -154
- package/dist/tools/definitions/std/analysis/clarify-requirements.yml +0 -90
- package/dist/tools/definitions/std/analysis/detect-context.yml +0 -109
- package/dist/tools/definitions/std/analysis/detect-layers.yml +0 -125
- package/dist/tools/definitions/std/analysis/generate-tour.yml +0 -102
- package/dist/tools/definitions/std/analysis/search-enhance.yml +0 -105
- package/dist/tools/definitions/std/backlog/add.yml +0 -51
- package/dist/tools/definitions/std/backlog/decide.yml +0 -39
- package/dist/tools/definitions/std/backlog/github-sync.yml +0 -161
- package/dist/tools/definitions/std/backlog/list.yml +0 -53
- package/dist/tools/definitions/std/backlog/load.yml +0 -46
- package/dist/tools/definitions/std/backlog/resolve.yml +0 -37
- package/dist/tools/definitions/std/backlog/update.yml +0 -42
- package/dist/tools/definitions/std/bugfix/diagnose.yml +0 -68
- package/dist/tools/definitions/std/bugfix/fix.yml +0 -66
- package/dist/tools/definitions/std/bugfix/verify.yml +0 -69
- package/dist/tools/definitions/std/constraint/check-decomposition.yml +0 -103
- package/dist/tools/definitions/std/constraint/check-feature-list.yml +0 -77
- package/dist/tools/definitions/std/constraint/check-progress.yml +0 -97
- package/dist/tools/definitions/std/constraint/generate-report.yml +0 -147
- package/dist/tools/definitions/std/deploy/commit-push.yml +0 -33
- package/dist/tools/definitions/std/deploy/deploy-backend.yml +0 -37
- package/dist/tools/definitions/std/deploy/deploy-frontend.yml +0 -37
- package/dist/tools/definitions/std/deploy/rollback.yml +0 -148
- package/dist/tools/definitions/std/design/analyze-architecture-impact.yml +0 -113
- package/dist/tools/definitions/std/design/design-api.yml +0 -55
- package/dist/tools/definitions/std/design/design-architecture.yml +0 -97
- package/dist/tools/definitions/std/design/design-db.yml +0 -81
- package/dist/tools/definitions/std/design/generate-spec.yml +0 -182
- package/dist/tools/definitions/std/development/develop-api.yml +0 -85
- package/dist/tools/definitions/std/development/develop-backend.yml +0 -88
- package/dist/tools/definitions/std/development/develop-frontend.yml +0 -87
- package/dist/tools/definitions/std/development/develop-shared-types.yml +0 -74
- package/dist/tools/definitions/std/development/develop-task.yml +0 -122
- package/dist/tools/definitions/std/development/develop-tests.yml +0 -76
- package/dist/tools/definitions/std/development/execute-batch.yml +0 -152
- package/dist/tools/definitions/std/development/fix-issues.yml +0 -100
- package/dist/tools/definitions/std/development/implement-task.yml +0 -124
- package/dist/tools/definitions/std/development/review-fix-cycle.yml +0 -232
- package/dist/tools/definitions/std/evolution/implement.yml +0 -124
- package/dist/tools/definitions/std/evolution/prioritize.yml +0 -111
- package/dist/tools/definitions/std/evolution/report-gap.yml +0 -165
- package/dist/tools/definitions/std/file/read.yml +0 -21
- package/dist/tools/definitions/std/governance/aggregate-opinions.sh +0 -201
- package/dist/tools/definitions/std/governance/aggregate-opinions.yml +0 -78
- package/dist/tools/definitions/std/governance/audit-task.yml +0 -177
- package/dist/tools/definitions/std/governance/cast-vote.yml +0 -128
- package/dist/tools/definitions/std/governance/collect-issues.yml +0 -16
- package/dist/tools/definitions/std/governance/create-signed-document.yml +0 -23
- package/dist/tools/definitions/std/governance/create-voting-session.yml +0 -100
- package/dist/tools/definitions/std/governance/define-stance.sh +0 -243
- package/dist/tools/definitions/std/governance/define-stance.yml +0 -81
- package/dist/tools/definitions/std/governance/generate-review-report.yml +0 -23
- package/dist/tools/definitions/std/governance/impeach.yml +0 -178
- package/dist/tools/definitions/std/governance/multi-stance-review.yml +0 -153
- package/dist/tools/definitions/std/governance/prepare-artifact.yml +0 -20
- package/dist/tools/definitions/std/governance/review-spec-approval.yml +0 -262
- package/dist/tools/definitions/std/governance/rollback.yml +0 -185
- package/dist/tools/definitions/std/governance/stance-review.yml +0 -148
- package/dist/tools/definitions/std/governance/track-effect.yml +0 -198
- package/dist/tools/definitions/std/governance/vote-tally.yml +0 -143
- package/dist/tools/definitions/std/patch/execute.yml +0 -51
- package/dist/tools/definitions/std/planning/generate-tasks.yml +0 -36
- package/dist/tools/definitions/std/planning/load-tasks.yml +0 -44
- package/dist/tools/definitions/std/planning/split-batch.yml +0 -480
- package/dist/tools/definitions/std/planning/split-tasks.yml +0 -358
- package/dist/tools/definitions/std/planning/update-tasks.yml +0 -51
- package/dist/tools/definitions/std/planning/validate-tasks.yml +0 -46
- package/dist/tools/definitions/std/project/decide-next-workflow.yml +0 -38
- package/dist/tools/definitions/std/project/load-state.yml +0 -31
- package/dist/tools/definitions/std/project/save-state.yml +0 -32
- package/dist/tools/definitions/std/quality/check-quality.yml +0 -241
- package/dist/tools/definitions/std/quality/debug-systematic.yml +0 -163
- package/dist/tools/definitions/std/quality/handle-feedback.yml +0 -108
- package/dist/tools/definitions/std/quality/review-code.yml +0 -128
- package/dist/tools/definitions/std/quality/review-spec.yml +0 -140
- package/dist/tools/definitions/std/quality/review-task.yml +0 -190
- package/dist/tools/definitions/std/quality/run-tests.yml +0 -80
- package/dist/tools/definitions/std/quick/analyze.yml +0 -56
- package/dist/tools/definitions/std/quick/implement.yml +0 -67
- package/dist/tools/definitions/std/quick/verify.yml +0 -71
- package/dist/tools/definitions/std/verification/verify_completion.yml +0 -113
- package/dist/tools/definitions/std/verification/wait-condition.yml +0 -107
- package/dist/tools/index.d.ts +0 -5
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -10
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/paths.d.ts +0 -9
- package/dist/tools/paths.d.ts.map +0 -1
- package/dist/tools/paths.js +0 -51
- package/dist/tools/paths.js.map +0 -1
- package/src/__tests__/token-budget.test.ts +0 -252
- package/src/context/__tests__/token-budget.test.ts +0 -258
- package/src/context/token-budget.ts +0 -222
- package/src/gates/__tests__/runner.test.ts +0 -81
- package/src/gates/runner.ts +0 -57
- package/src/knowledge/primitives/__tests__/code-structure-degrade.test.ts +0 -24
- package/src/knowledge/primitives/__tests__/code-structure.test.ts +0 -120
- package/src/knowledge/primitives/code-structure.ts +0 -185
- package/src/monitoring/__tests__/context-tracker.test.ts +0 -180
- package/src/monitoring/context-tracker.ts +0 -136
- package/src/tools/CONTEXT.md +0 -24
- package/src/tools/__tests__/registry.test.ts +0 -221
- package/src/tools/definitions/core/code/fingerprint.sh +0 -273
- package/src/tools/definitions/core/code/fingerprint.yml +0 -72
- package/src/tools/definitions/core/code/parse.yml +0 -68
- package/src/tools/definitions/core/code/register-language.sh +0 -475
- package/src/tools/definitions/core/code/register-language.yml +0 -74
- package/src/tools/definitions/core/docker/build.yml +0 -73
- package/src/tools/definitions/core/docker/run.yml +0 -81
- package/src/tools/definitions/core/file/copy.yml +0 -88
- package/src/tools/definitions/core/file/read.yml +0 -69
- package/src/tools/definitions/core/file/write.yml +0 -75
- package/src/tools/definitions/core/git/branch.yml +0 -61
- package/src/tools/definitions/core/git/cleanup-worktree.yml +0 -50
- package/src/tools/definitions/core/git/clone.yml +0 -69
- package/src/tools/definitions/core/git/commit.yml +0 -65
- package/src/tools/definitions/core/git/push.yml +0 -79
- package/src/tools/definitions/core/git/worktree.yml +0 -96
- package/src/tools/definitions/core/notification/notify.sh +0 -152
- package/src/tools/definitions/core/notification/notify.yml +0 -59
- package/src/tools/definitions/core/npm/build.yml +0 -75
- package/src/tools/definitions/core/npm/install.yml +0 -58
- package/src/tools/definitions/core/npm/test.yml +0 -75
- package/src/tools/definitions/core/validation/check-reuse.yml +0 -170
- package/src/tools/definitions/core/validation/validate-handlers.yml +0 -118
- package/src/tools/definitions/core/validation/validate-readme-stats.yml +0 -155
- package/src/tools/definitions/core/validation/validate-yaml-syntax.yml +0 -134
- package/src/tools/definitions/ext/browser/browser-automate.sh +0 -255
- package/src/tools/definitions/ext/browser/browser-automate.yml +0 -166
- package/src/tools/definitions/ext/browser/browser-close.sh +0 -104
- package/src/tools/definitions/ext/browser/browser-close.yml +0 -54
- package/src/tools/definitions/ext/browser/browser-mcp-debug.sh +0 -682
- package/src/tools/definitions/ext/browser/browser-mcp-debug.yml +0 -167
- package/src/tools/definitions/ext/browser/browser-start.sh +0 -101
- package/src/tools/definitions/ext/browser/browser-start.yml +0 -61
- package/src/tools/definitions/registry.json +0 -795
- package/src/tools/definitions/std/README.md +0 -350
- package/src/tools/definitions/std/analysis/analyze-codebase.yml +0 -72
- package/src/tools/definitions/std/analysis/analyze-diff.yml +0 -182
- package/src/tools/definitions/std/analysis/analyze-git-diff.yml +0 -70
- package/src/tools/definitions/std/analysis/analyze-impact.yml +0 -78
- package/src/tools/definitions/std/analysis/analyze-requirements.yml +0 -105
- package/src/tools/definitions/std/analysis/brainstorm-options.yml +0 -106
- package/src/tools/definitions/std/analysis/build-graph.yml +0 -154
- package/src/tools/definitions/std/analysis/clarify-requirements.yml +0 -90
- package/src/tools/definitions/std/analysis/detect-context.yml +0 -109
- package/src/tools/definitions/std/analysis/detect-layers.yml +0 -125
- package/src/tools/definitions/std/analysis/generate-tour.yml +0 -102
- package/src/tools/definitions/std/analysis/search-enhance.yml +0 -105
- package/src/tools/definitions/std/backlog/add.yml +0 -51
- package/src/tools/definitions/std/backlog/decide.yml +0 -39
- package/src/tools/definitions/std/backlog/github-sync.yml +0 -161
- package/src/tools/definitions/std/backlog/list.yml +0 -53
- package/src/tools/definitions/std/backlog/load.yml +0 -46
- package/src/tools/definitions/std/backlog/resolve.yml +0 -37
- package/src/tools/definitions/std/backlog/update.yml +0 -42
- package/src/tools/definitions/std/bugfix/diagnose.yml +0 -68
- package/src/tools/definitions/std/bugfix/fix.yml +0 -66
- package/src/tools/definitions/std/bugfix/verify.yml +0 -69
- package/src/tools/definitions/std/constraint/check-decomposition.yml +0 -103
- package/src/tools/definitions/std/constraint/check-feature-list.yml +0 -77
- package/src/tools/definitions/std/constraint/check-progress.yml +0 -97
- package/src/tools/definitions/std/constraint/generate-report.yml +0 -147
- package/src/tools/definitions/std/deploy/commit-push.yml +0 -33
- package/src/tools/definitions/std/deploy/deploy-backend.yml +0 -37
- package/src/tools/definitions/std/deploy/deploy-frontend.yml +0 -37
- package/src/tools/definitions/std/deploy/rollback.yml +0 -148
- package/src/tools/definitions/std/design/analyze-architecture-impact.yml +0 -113
- package/src/tools/definitions/std/design/design-api.yml +0 -55
- package/src/tools/definitions/std/design/design-architecture.yml +0 -97
- package/src/tools/definitions/std/design/design-db.yml +0 -81
- package/src/tools/definitions/std/design/generate-spec.yml +0 -182
- package/src/tools/definitions/std/development/develop-api.yml +0 -85
- package/src/tools/definitions/std/development/develop-backend.yml +0 -88
- package/src/tools/definitions/std/development/develop-frontend.yml +0 -87
- package/src/tools/definitions/std/development/develop-shared-types.yml +0 -74
- package/src/tools/definitions/std/development/develop-task.yml +0 -122
- package/src/tools/definitions/std/development/develop-tests.yml +0 -76
- package/src/tools/definitions/std/development/execute-batch.yml +0 -152
- package/src/tools/definitions/std/development/fix-issues.yml +0 -100
- package/src/tools/definitions/std/development/implement-task.yml +0 -124
- package/src/tools/definitions/std/development/review-fix-cycle.yml +0 -232
- package/src/tools/definitions/std/evolution/implement.yml +0 -124
- package/src/tools/definitions/std/evolution/prioritize.yml +0 -111
- package/src/tools/definitions/std/evolution/report-gap.yml +0 -165
- package/src/tools/definitions/std/file/read.yml +0 -21
- package/src/tools/definitions/std/governance/aggregate-opinions.sh +0 -201
- package/src/tools/definitions/std/governance/aggregate-opinions.yml +0 -78
- package/src/tools/definitions/std/governance/audit-task.yml +0 -177
- package/src/tools/definitions/std/governance/cast-vote.yml +0 -128
- package/src/tools/definitions/std/governance/collect-issues.yml +0 -16
- package/src/tools/definitions/std/governance/create-signed-document.yml +0 -23
- package/src/tools/definitions/std/governance/create-voting-session.yml +0 -100
- package/src/tools/definitions/std/governance/define-stance.sh +0 -243
- package/src/tools/definitions/std/governance/define-stance.yml +0 -81
- package/src/tools/definitions/std/governance/generate-review-report.yml +0 -23
- package/src/tools/definitions/std/governance/impeach.yml +0 -178
- package/src/tools/definitions/std/governance/multi-stance-review.yml +0 -153
- package/src/tools/definitions/std/governance/prepare-artifact.yml +0 -20
- package/src/tools/definitions/std/governance/review-spec-approval.yml +0 -262
- package/src/tools/definitions/std/governance/rollback.yml +0 -185
- package/src/tools/definitions/std/governance/stance-review.yml +0 -148
- package/src/tools/definitions/std/governance/track-effect.yml +0 -198
- package/src/tools/definitions/std/governance/vote-tally.yml +0 -143
- package/src/tools/definitions/std/patch/execute.yml +0 -51
- package/src/tools/definitions/std/planning/generate-tasks.yml +0 -36
- package/src/tools/definitions/std/planning/load-tasks.yml +0 -44
- package/src/tools/definitions/std/planning/split-batch.yml +0 -480
- package/src/tools/definitions/std/planning/split-tasks.yml +0 -358
- package/src/tools/definitions/std/planning/update-tasks.yml +0 -51
- package/src/tools/definitions/std/planning/validate-tasks.yml +0 -46
- package/src/tools/definitions/std/project/decide-next-workflow.yml +0 -38
- package/src/tools/definitions/std/project/load-state.yml +0 -31
- package/src/tools/definitions/std/project/save-state.yml +0 -32
- package/src/tools/definitions/std/quality/check-quality.yml +0 -241
- package/src/tools/definitions/std/quality/debug-systematic.yml +0 -163
- package/src/tools/definitions/std/quality/handle-feedback.yml +0 -108
- package/src/tools/definitions/std/quality/review-code.yml +0 -128
- package/src/tools/definitions/std/quality/review-spec.yml +0 -140
- package/src/tools/definitions/std/quality/review-task.yml +0 -190
- package/src/tools/definitions/std/quality/run-tests.yml +0 -80
- package/src/tools/definitions/std/quick/analyze.yml +0 -56
- package/src/tools/definitions/std/quick/implement.yml +0 -67
- package/src/tools/definitions/std/quick/verify.yml +0 -71
- package/src/tools/definitions/std/verification/verify_completion.yml +0 -113
- package/src/tools/definitions/std/verification/wait-condition.yml +0 -107
- package/src/tools/index.ts +0 -5
- package/src/tools/paths.ts +0 -15
|
@@ -143,22 +143,22 @@ describe('parseExportStatements — 源码导出面解析口径', () => {
|
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
describe('reconcileContext — 幽灵方向(文档→代码)', () => {
|
|
146
|
-
const doc = contextDoc(['- `TraceCollector` — 收集', '- `
|
|
146
|
+
const doc = contextDoc(['- `TraceCollector` — 收集', '- `SessionManager` — 会话'].join('\n'));
|
|
147
147
|
|
|
148
148
|
it('声明的符号在导出面中不存在 → 报幽灵并指名符号', () => {
|
|
149
149
|
const v = reconcileContext({
|
|
150
150
|
contextMdContent: doc,
|
|
151
151
|
exportSurface: ['TraceCollector'],
|
|
152
152
|
});
|
|
153
|
-
expect(v.declaredSymbols).toEqual(['TraceCollector', '
|
|
154
|
-
expect(v.ghosts).toEqual(['
|
|
153
|
+
expect(v.declaredSymbols).toEqual(['TraceCollector', 'SessionManager']);
|
|
154
|
+
expect(v.ghosts).toEqual(['SessionManager']);
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
it('导出面含同名符号(含类型符号)→ 零幽灵', () => {
|
|
158
158
|
expect(
|
|
159
159
|
reconcileContext({
|
|
160
160
|
contextMdContent: doc,
|
|
161
|
-
exportSurface: ['TraceCollector', '
|
|
161
|
+
exportSurface: ['TraceCollector', 'SessionManager'],
|
|
162
162
|
}).ghosts
|
|
163
163
|
).toEqual([]);
|
|
164
164
|
});
|
|
@@ -179,17 +179,17 @@ describe('reconcileContext — 覆盖方向(代码→文档,barrel 值符号
|
|
|
179
179
|
const doc = contextDoc(
|
|
180
180
|
[
|
|
181
181
|
'- `TraceCollector` — 执行追踪收集(`readReport(filter?)`)',
|
|
182
|
-
'- `TraceAnalyzer` — 统计分析,另有 `
|
|
182
|
+
'- `TraceAnalyzer` — 统计分析,另有 `pruneTraceLogs` GC 入口',
|
|
183
183
|
].join('\n')
|
|
184
184
|
);
|
|
185
185
|
|
|
186
186
|
it('barrel 再导出的值符号未出现在「核心导出」节 → 未登记;inline 提及即算登记', () => {
|
|
187
187
|
const v = reconcileContext({
|
|
188
188
|
contextMdContent: doc,
|
|
189
|
-
exportSurface: ['TraceCollector', 'TraceAnalyzer', '
|
|
190
|
-
barrelExports: ['TraceCollector', 'TraceAnalyzer', '
|
|
189
|
+
exportSurface: ['TraceCollector', 'TraceAnalyzer', 'pruneTraceLogs', 'KnowledgeInjector'],
|
|
190
|
+
barrelExports: ['TraceCollector', 'TraceAnalyzer', 'pruneTraceLogs', 'KnowledgeInjector'],
|
|
191
191
|
});
|
|
192
|
-
expect(v.unlistedBarrelExports).toEqual(['
|
|
192
|
+
expect(v.unlistedBarrelExports).toEqual(['KnowledgeInjector']);
|
|
193
193
|
});
|
|
194
194
|
|
|
195
195
|
it('无 barrel 的目录(barrelExports 不传/空)跳过覆盖方向', () => {
|
|
@@ -212,11 +212,11 @@ describe('reconcileContext — 覆盖方向(代码→文档,barrel 值符号
|
|
|
212
212
|
|
|
213
213
|
it('节外正文(其它 ## 节)里的同名句子不救 barrel 未登记', () => {
|
|
214
214
|
const v = reconcileContext({
|
|
215
|
-
contextMdContent: contextDoc('- `TraceCollector` — 收集', '## 约定\n- `
|
|
216
|
-
exportSurface: ['TraceCollector', '
|
|
217
|
-
barrelExports: ['TraceCollector', '
|
|
215
|
+
contextMdContent: contextDoc('- `TraceCollector` — 收集', '## 约定\n- `KnowledgeInjector` 只在组合根用\n'),
|
|
216
|
+
exportSurface: ['TraceCollector', 'KnowledgeInjector'],
|
|
217
|
+
barrelExports: ['TraceCollector', 'KnowledgeInjector'],
|
|
218
218
|
});
|
|
219
|
-
expect(v.unlistedBarrelExports).toEqual(['
|
|
219
|
+
expect(v.unlistedBarrelExports).toEqual(['KnowledgeInjector']);
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
222
|
|
|
@@ -225,7 +225,7 @@ describe('reconcileContext — 两方向同输入对撞', () => {
|
|
|
225
225
|
const doc = contextDoc('- `TraceCollector` — 收集\n');
|
|
226
226
|
const v = reconcileContext({
|
|
227
227
|
contextMdContent: doc,
|
|
228
|
-
exportSurface: ['TraceSink', '
|
|
228
|
+
exportSurface: ['TraceSink', 'KnowledgeInjector'],
|
|
229
229
|
barrelExports: ['TraceSink'],
|
|
230
230
|
});
|
|
231
231
|
expect(v.ghosts).toEqual(['TraceCollector']);
|
|
@@ -233,11 +233,11 @@ describe('reconcileContext — 两方向同输入对撞', () => {
|
|
|
233
233
|
});
|
|
234
234
|
|
|
235
235
|
it('两侧一致 → 干净(判定不制造存量噪音)', () => {
|
|
236
|
-
const doc = contextDoc('- `TraceCollector` — 收集\n- `
|
|
236
|
+
const doc = contextDoc('- `TraceCollector` — 收集\n- `KnowledgeInjector` — 知识注入\n');
|
|
237
237
|
const v = reconcileContext({
|
|
238
238
|
contextMdContent: doc,
|
|
239
|
-
exportSurface: ['TraceCollector', '
|
|
240
|
-
barrelExports: ['TraceCollector', '
|
|
239
|
+
exportSurface: ['TraceCollector', 'KnowledgeInjector'],
|
|
240
|
+
barrelExports: ['TraceCollector', 'KnowledgeInjector'],
|
|
241
241
|
});
|
|
242
242
|
expect(v.ghosts).toEqual([]);
|
|
243
243
|
expect(v.unlistedBarrelExports).toEqual([]);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* trace 记录器注入(工单 15 decycle 收尾 / harness#88)
|
|
3
3
|
*
|
|
4
|
-
* 原状态:checker 值导入 monitoring
|
|
4
|
+
* 原状态:checker 值导入 monitoring 的全局单例收集器,并在首次记录时惰性接线
|
|
5
5
|
* (ADR-0003),`setTraceRecorder` 退化成只有测试在用的假 seam。
|
|
6
6
|
* 现在:记录器经**构造参数**注入;未注入 = no-op(core 零上行依赖,默认无副作用),
|
|
7
|
-
* 真实收集器由组合根(CLI 命令 / bootstrap)接线。
|
|
7
|
+
* 真实收集器由组合根(CLI 命令 / bootstrap)接线。monitoring 侧的单例出口
|
|
8
|
+
* (getTraceCollector/configureTraceCollector)已随 #199 删除,「checker 不碰
|
|
9
|
+
* monitoring 值面」由本文件的源码扫描断言直接钉住。
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
12
|
import * as fs from 'fs';
|
|
@@ -13,16 +15,6 @@ import * as path from 'path';
|
|
|
13
15
|
import { ConstraintChecker } from '../checker';
|
|
14
16
|
import type { ExecutionTrace } from '../../../types/trace';
|
|
15
17
|
|
|
16
|
-
jest.mock('../../../monitoring/traces', () => ({
|
|
17
|
-
getTraceCollector: jest.fn(() => ({ record: jest.fn() })),
|
|
18
|
-
TraceCollector: jest.fn(),
|
|
19
|
-
configureTraceCollector: jest.fn(),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
/** 替身收集器工厂(core 侧连测试也不值导入 monitoring,方向由 #88 规则锁) */
|
|
23
|
-
const getTraceCollector = jest.requireMock('../../../monitoring/traces')
|
|
24
|
-
.getTraceCollector as jest.Mock;
|
|
25
|
-
|
|
26
18
|
describe('trace 记录器构造注入(harness#88)', () => {
|
|
27
19
|
let projectDir: string;
|
|
28
20
|
/**
|
|
@@ -39,7 +31,6 @@ describe('trace 记录器构造注入(harness#88)', () => {
|
|
|
39
31
|
projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-trace-injection-'));
|
|
40
32
|
fs.mkdirSync(path.join(projectDir, '.harness', 'evidence'), { recursive: true });
|
|
41
33
|
fs.writeFileSync(path.join(projectDir, '.harness', 'evidence', 'test.log'), 'ok');
|
|
42
|
-
getTraceCollector.mockClear();
|
|
43
34
|
});
|
|
44
35
|
|
|
45
36
|
afterAll(() => {
|
|
@@ -67,11 +58,19 @@ describe('trace 记录器构造注入(harness#88)', () => {
|
|
|
67
58
|
expect((checker as any).setTraceRecorder).toBeUndefined();
|
|
68
59
|
});
|
|
69
60
|
|
|
70
|
-
it('
|
|
61
|
+
it('未注入记录器时检查照常执行(no-op 默认,core 零上行依赖)', async () => {
|
|
71
62
|
const unwired = new ConstraintChecker();
|
|
72
63
|
|
|
73
64
|
await unwired.checkConstraints(context());
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('checker 对 monitoring 零值导入(单例出口删除后不可能再反向取全局收集器,#199)', () => {
|
|
68
|
+
const source = fs.readFileSync(path.join(__dirname, '..', 'checker.ts'), 'utf-8');
|
|
69
|
+
const monitoringValueImports = source
|
|
70
|
+
.split('\n')
|
|
71
|
+
.filter(line => /^\s*import\s/.test(line) && !/^\s*import\s+type\b/.test(line))
|
|
72
|
+
.filter(line => line.includes('monitoring'));
|
|
74
73
|
|
|
75
|
-
expect(
|
|
74
|
+
expect(monitoringValueImports).toEqual([]);
|
|
76
75
|
});
|
|
77
76
|
});
|
|
@@ -172,4 +172,13 @@ describe('应用层约束进候选诊断(ADR-0033 块 3 子项 3)', () => {
|
|
|
172
172
|
expect(report.stats.some(s => s.id === 'app_no_internal_url')).toBe(false);
|
|
173
173
|
expect(report.candidates.some(c => c.id === 'app_no_internal_url')).toBe(false);
|
|
174
174
|
});
|
|
175
|
+
|
|
176
|
+
it('buildConstraintsUsageReport 根参数必传(harness#201,同族同形)', () => {
|
|
177
|
+
// 永不执行:只钉签名形状——不传根在类型层即被拒绝,无 process.cwd() 缺省
|
|
178
|
+
const neverCalled = (): void => {
|
|
179
|
+
// @ts-expect-error 根参数必传(harness#201)
|
|
180
|
+
buildConstraintsUsageReport();
|
|
181
|
+
};
|
|
182
|
+
void neverCalled;
|
|
183
|
+
});
|
|
175
184
|
});
|
|
@@ -31,7 +31,7 @@ import { createRunEnv, type RunEnv } from './run-env';
|
|
|
31
31
|
*
|
|
32
32
|
* core 不上行依赖 monitoring:记录器经**构造参数**注入,未注入 = no-op
|
|
33
33
|
* (默认无副作用)。真实收集器由组合根接线——CLI check/report 与 bootstrap
|
|
34
|
-
* 各自 `new ConstraintChecker(
|
|
34
|
+
* 各自 `new ConstraintChecker(new TraceCollector({ projectPath }))`。
|
|
35
35
|
*/
|
|
36
36
|
export interface TraceRecorder {
|
|
37
37
|
record(trace: ExecutionTrace): void;
|
|
@@ -422,6 +422,25 @@ export async function checkConstraints(
|
|
|
422
422
|
return result;
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
+
/**
|
|
426
|
+
* 快捷函数:收集模式执行约束检查(不抛出口,harness#194)
|
|
427
|
+
*
|
|
428
|
+
* 与 checkConstraints 共享同一检查体、同一 options 签名,唯一差别是不 throw:
|
|
429
|
+
* error 级违规照进 result.errors、passed=false,后续 error 与 warning 级照常执行。
|
|
430
|
+
* 报告类 / HTTP 端点类消费方拿全量视图;阻断语义只属于 checkConstraints。
|
|
431
|
+
*/
|
|
432
|
+
export async function collectConstraints(
|
|
433
|
+
context: ConstraintContext,
|
|
434
|
+
options?: CheckConstraintsOptions
|
|
435
|
+
): Promise<ConstraintCheckResult> {
|
|
436
|
+
const result = await ConstraintChecker.getInstance().collectConstraints(context, options?.customConfig ?? null);
|
|
437
|
+
if (options?.onTrace) {
|
|
438
|
+
for (const r of result.errors) options.onTrace(r);
|
|
439
|
+
for (const r of result.warnings) options.onTrace(r);
|
|
440
|
+
}
|
|
441
|
+
return result;
|
|
442
|
+
}
|
|
443
|
+
|
|
425
444
|
/**
|
|
426
445
|
* 快捷函数:执行前检查
|
|
427
446
|
*
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* - 证据源 = `.harness/evidence/`(独立链路写入:PassesGate.runTests 真实跑测试
|
|
8
8
|
* 命令落盘,或消费方外部验证事件),与 traces.log 彻底脱钩
|
|
9
|
-
* - 新鲜度 = 最新证据 mtime
|
|
9
|
+
* - 新鲜度 = 最新证据 mtime 严格晚于全部可读变更文件(验证跑在最新变更之后);
|
|
10
|
+
* 同刻等值 = 时钟精度内先后不可判(harness#195)→ 显式降级 skip,不放行也不违规
|
|
10
11
|
* - 缺失/空目录 → fail;过期 → fail(点名晚于证据的变更文件);
|
|
11
12
|
* 证据位不可读 / 新鲜度不可判定 → 带原因的显式降级 skip(不静默)
|
|
12
13
|
*
|
|
@@ -74,13 +75,31 @@ describe('no_completion_without_verification(harness#183 证据源重构)',
|
|
|
74
75
|
expect(result.satisfied).toBe(true);
|
|
75
76
|
});
|
|
76
77
|
|
|
77
|
-
it('
|
|
78
|
+
it('证据与最新变更同一时刻(等值不可判,harness#195)→ 显式降级 skip,不放行也不违规', async () => {
|
|
78
79
|
writeChangedFile('src/a.ts', T_OLD);
|
|
79
80
|
writeEvidence('test-same-instant.log', T_OLD);
|
|
80
81
|
|
|
81
82
|
const result = await checker.check(LAW, contextOf(['src/a.ts']));
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
// 时钟精度内「同刻」物理上无法区分先后:判 pass 是假绿灯,判 fail 又可能误杀
|
|
85
|
+
// 正常时序(改完立刻验证落进同一毫秒)——不可判定态走显式降级,与「变更清单
|
|
86
|
+
// 未接线」「mtime 均不可读」同一出口
|
|
87
|
+
expect(result.skipped).toBe(true);
|
|
88
|
+
expect(result.satisfied).toBe(true); // skip 不产生违规
|
|
89
|
+
expect(result.skipReason).toContain('同刻');
|
|
90
|
+
expect(result.skipReason).toContain('src/a.ts');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('严格晚于证据的变更与同刻变更并存 → fail 优先(证据确定过期,不因同刻降级)', async () => {
|
|
94
|
+
writeChangedFile('src/a.ts', T_OLD);
|
|
95
|
+
writeChangedFile('src/b.ts', T_NEW);
|
|
96
|
+
writeEvidence('test-same-instant.log', T_OLD);
|
|
97
|
+
|
|
98
|
+
const result = await checker.check(LAW, contextOf(['src/a.ts', 'src/b.ts']));
|
|
99
|
+
|
|
100
|
+
expect(result.skipped).toBeUndefined();
|
|
101
|
+
expect(result.satisfied).toBe(false);
|
|
102
|
+
expect(result.evidence?.join('\n')).toContain('src/b.ts');
|
|
84
103
|
});
|
|
85
104
|
|
|
86
105
|
it('changedFiles 为 undefined(调用方未接线变更清单)→ 显式降级 skip,不放行', async () => {
|
|
@@ -12,7 +12,6 @@ import { join } from 'path';
|
|
|
12
12
|
import { describe, it, expect, afterAll } from '@jest/globals';
|
|
13
13
|
import {
|
|
14
14
|
noHardcodedCredentials,
|
|
15
|
-
containsHardcodedCredential,
|
|
16
15
|
} from '../no-hardcoded-credentials';
|
|
17
16
|
import type { CheckEnv } from '../types';
|
|
18
17
|
import { createRunEnv } from '../../run-env';
|
|
@@ -33,97 +32,113 @@ const PASSWORD_ASSIGN = 'const dbPass' + 'word = "sup3r-s3cret-value";';
|
|
|
33
32
|
const JWT =
|
|
34
33
|
'eyJ' + 'hbGciOiJIUzI1NiJ9.' + 'eyJ' + 'zdWIiOiIxMjM0NTY3ODkwIn0.' + 'dozjgNryP4J3jVmNHl0w5N_XgL0n';
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
/** 经生产入口判定一段文本是否命中凭证:写入临时文件,走「变更文件内容扫描」路径 */
|
|
36
|
+
const scanDir = mkdtempSync(join(tmpdir(), 'harness-cred-scan-'));
|
|
37
|
+
afterAll(() => rmSync(scanDir, { recursive: true, force: true }));
|
|
38
|
+
|
|
39
|
+
async function textHitsCredential(text: string): Promise<boolean> {
|
|
40
|
+
writeFileSync(join(scanDir, 'probe.ts'), text + '\n');
|
|
41
|
+
const env: CheckEnv = {
|
|
42
|
+
...createRunEnv(scanDir),
|
|
43
|
+
context: { operation: 'commit', projectPath: scanDir, changedFiles: ['probe.ts'] },
|
|
44
|
+
stagedDiff: async () => '',
|
|
45
|
+
stagedDiffNames: async () => '',
|
|
46
|
+
srcScan: () => [],
|
|
47
|
+
};
|
|
48
|
+
return (await noHardcodedCredentials.evaluate(env)) !== true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('文本命中判定(经生产入口 evaluate 的变更文件扫描路径)', () => {
|
|
52
|
+
it('命中 PEM 私钥头', async () => {
|
|
53
|
+
expect(await textHitsCredential(PEM_HEADER + '\nMIIE...')).toBe(true);
|
|
39
54
|
});
|
|
40
55
|
|
|
41
|
-
it('命中 AWS Access Key', () => {
|
|
42
|
-
expect(
|
|
56
|
+
it('命中 AWS Access Key', async () => {
|
|
57
|
+
expect(await textHitsCredential(`const key = "${AWS_KEY}";`)).toBe(true);
|
|
43
58
|
});
|
|
44
59
|
|
|
45
|
-
it('命中硬编码 password 赋值', () => {
|
|
46
|
-
expect(
|
|
60
|
+
it('命中硬编码 password 赋值', async () => {
|
|
61
|
+
expect(await textHitsCredential(PASSWORD_ASSIGN)).toBe(true);
|
|
47
62
|
});
|
|
48
63
|
|
|
49
|
-
it('命中硬编码 api_key 赋值', () => {
|
|
50
|
-
expect(
|
|
64
|
+
it('命中硬编码 api_key 赋值', async () => {
|
|
65
|
+
expect(await textHitsCredential('api' + '_key: "abcdef123456789"')).toBe(true);
|
|
51
66
|
});
|
|
52
67
|
|
|
53
|
-
it('命中 .env 裸值(无引号赋值)', () => {
|
|
54
|
-
expect(
|
|
68
|
+
it('命中 .env 裸值(无引号赋值)', async () => {
|
|
69
|
+
expect(await textHitsCredential('DB_TO' + 'KEN=abc123def456ghi')).toBe(true);
|
|
55
70
|
});
|
|
56
71
|
|
|
57
|
-
it('命中无引号 YAML 值', () => {
|
|
58
|
-
expect(
|
|
72
|
+
it('命中无引号 YAML 值', async () => {
|
|
73
|
+
expect(await textHitsCredential('pass' + 'word: secret123')).toBe(true);
|
|
59
74
|
});
|
|
60
75
|
|
|
61
|
-
it('命中 URL 内嵌凭证', () => {
|
|
62
|
-
expect(
|
|
76
|
+
it('命中 URL 内嵌凭证', async () => {
|
|
77
|
+
expect(await textHitsCredential('const url = "postgres:/' + '/user:pw12345@db.host/app";')).toBe(true);
|
|
63
78
|
});
|
|
64
79
|
|
|
65
|
-
it('命中 JSON 带引号键', () => {
|
|
66
|
-
expect(
|
|
80
|
+
it('命中 JSON 带引号键', async () => {
|
|
81
|
+
expect(await textHitsCredential('"pass' + 'word": "realvalue123"')).toBe(true);
|
|
67
82
|
});
|
|
68
83
|
|
|
69
|
-
it('命中非清单变量名 credential/privateKey/signingKey', () => {
|
|
70
|
-
expect(
|
|
71
|
-
expect(
|
|
72
|
-
expect(
|
|
84
|
+
it('命中非清单变量名 credential/privateKey/signingKey', async () => {
|
|
85
|
+
expect(await textHitsCredential('cred' + 'ential = "realvalue123";')).toBe(true);
|
|
86
|
+
expect(await textHitsCredential('private' + 'Key = "realvalue123";')).toBe(true);
|
|
87
|
+
expect(await textHitsCredential('signing' + '_key: realvalue123')).toBe(true);
|
|
73
88
|
});
|
|
74
89
|
|
|
75
|
-
it('命中 JWT', () => {
|
|
76
|
-
expect(
|
|
90
|
+
it('命中 JWT', async () => {
|
|
91
|
+
expect(await textHitsCredential(`const tok = "${JWT}";`)).toBe(true);
|
|
77
92
|
});
|
|
78
93
|
|
|
79
|
-
it('行内出现 test 不再整行豁免真实值', () => {
|
|
94
|
+
it('行内出现 test 不再整行豁免真实值', async () => {
|
|
80
95
|
expect(
|
|
81
|
-
|
|
96
|
+
await textHitsCredential('const pass' + 'word = "realvalue123"; // test fixture')
|
|
82
97
|
).toBe(true);
|
|
83
98
|
});
|
|
84
99
|
|
|
85
|
-
it('豁免环境变量引用', () => {
|
|
100
|
+
it('豁免环境变量引用', async () => {
|
|
86
101
|
expect(
|
|
87
|
-
|
|
102
|
+
await textHitsCredential('const pass' + 'word = process.env.DB_PASSWORD;')
|
|
88
103
|
).toBe(false);
|
|
89
104
|
});
|
|
90
105
|
|
|
91
|
-
it('豁免占位符值', () => {
|
|
106
|
+
it('豁免占位符值', async () => {
|
|
92
107
|
expect(
|
|
93
|
-
|
|
108
|
+
await textHitsCredential('const pass' + 'word = "your-password-here";')
|
|
94
109
|
).toBe(false);
|
|
95
110
|
});
|
|
96
111
|
|
|
97
|
-
it('豁免 TS 类型注解(值是类型名而非字面量)', () => {
|
|
98
|
-
expect(
|
|
112
|
+
it('豁免 TS 类型注解(值是类型名而非字面量)', async () => {
|
|
113
|
+
expect(await textHitsCredential('api' + 'Key: string|undefined;')).toBe(false);
|
|
99
114
|
});
|
|
100
115
|
|
|
101
|
-
it('豁免 URL 中的变量插值占位', () => {
|
|
116
|
+
it('豁免 URL 中的变量插值占位', async () => {
|
|
102
117
|
expect(
|
|
103
|
-
|
|
118
|
+
await textHitsCredential('postgres://user:' + '${' + 'DB_PASS}@host/db')
|
|
104
119
|
).toBe(false);
|
|
105
120
|
});
|
|
106
121
|
|
|
107
|
-
it('普通代码不误报', () => {
|
|
122
|
+
it('普通代码不误报', async () => {
|
|
108
123
|
expect(
|
|
109
|
-
|
|
124
|
+
await textHitsCredential('export function add(a: number, b: number) { return a + b; }')
|
|
110
125
|
).toBe(false);
|
|
111
126
|
});
|
|
112
127
|
|
|
113
|
-
it('豁免右值为代码表达式的赋值(#184 收窄正则版假灯回归)', () => {
|
|
128
|
+
it('豁免右值为代码表达式的赋值(#184 收窄正则版假灯回归)', async () => {
|
|
114
129
|
// 现场复现:交付链 2026-09-24 一次采纳 1.14.0 时,业务仓的 React useCallback
|
|
115
130
|
// 赋值被无引号分支判成「口令类赋值」——右值是代码而非字面量。
|
|
116
131
|
expect(
|
|
117
|
-
|
|
132
|
+
await textHitsCredential('const insertPmoTok' + 'en = useCallback((candidate: string) => {')
|
|
118
133
|
).toBe(false);
|
|
119
134
|
expect(
|
|
120
|
-
|
|
135
|
+
await textHitsCredential('const refreshTok' + 'en = getTokenFromStor' + 'age();')
|
|
121
136
|
).toBe(false);
|
|
122
137
|
expect(
|
|
123
|
-
|
|
138
|
+
await textHitsCredential('const refreshTok' + 'en = req.cookies.refre' + 'sh;')
|
|
124
139
|
).toBe(false);
|
|
125
140
|
expect(
|
|
126
|
-
|
|
141
|
+
await textHitsCredential('api' + '_key: make' + 'Key("abc123456789"),')
|
|
127
142
|
).toBe(false);
|
|
128
143
|
});
|
|
129
144
|
});
|
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
* (PassesGate.runTests 真实跑项目声明的验证命令后落盘;消费方外部验证事件
|
|
8
8
|
* 也写这里),判定与约束检查自身的 trace 彻底脱钩。
|
|
9
9
|
*
|
|
10
|
-
* 新鲜度口径:最新证据文件的 mtime
|
|
10
|
+
* 新鲜度口径:最新证据文件的 mtime 严格晚于全部可读变更文件的 mtime
|
|
11
11
|
* (验证跑在最新变更之后)。不用固定时间窗——与本次变更的因果关系才是口径。
|
|
12
|
+
* 同刻等值(harness#195):文件系统时间戳粒度有限,等值在物理上无法区分先后,
|
|
13
|
+
* 属不可判定态——判 pass 是假绿灯(同毫秒「先证据后变更」会被放行),判 fail 又
|
|
14
|
+
* 误杀正常时序(改完立刻验证落进同一毫秒),故等值走显式降级 skip,不放行也不违规。
|
|
12
15
|
* 已知边界(保守方向,不修复):git checkout 等刷新工作区 mtime 会误杀真证据
|
|
13
16
|
* (误判过期 → fail,要求重跑验证);证据只核存在性与时间,不读内容——防伪
|
|
14
17
|
* 非本票口径(旧机制是自我指认,更弱)。
|
|
@@ -19,6 +22,8 @@
|
|
|
19
22
|
* 判定(显式三态,harness#182 语义):
|
|
20
23
|
* - 证据目录缺失/为空 → fail(从未验证)
|
|
21
24
|
* - 证据旧于最新变更 → fail(证据过期,点名晚于证据的变更文件)
|
|
25
|
+
* - 证据与变更文件同刻等值 → 带原因的 CheckSkip(harness#195:等值不可判定,
|
|
26
|
+
* 不放行也不违规;严格晚于证据的变更并存时 fail 优先,证据确定过期不降级)
|
|
22
27
|
* - 新鲜 → pass
|
|
23
28
|
* - changedFiles 为 undefined(调用方未接线变更清单,如生产侧直调)→ 带原因的
|
|
24
29
|
* CheckSkip:新鲜度无所依不能放行(空数组 = 真无变更,不在此列,有证据即过)
|
|
@@ -96,11 +101,13 @@ export const noCompletionWithoutVerification: ConstraintCheck = {
|
|
|
96
101
|
// 全部不可读才无法判定 → 显式降级
|
|
97
102
|
let readable = 0;
|
|
98
103
|
const laterThanEvidence: string[] = [];
|
|
104
|
+
const sameAsEvidence: string[] = [];
|
|
99
105
|
for (const file of changed) {
|
|
100
106
|
try {
|
|
101
107
|
const mtime = fs.statSync(path.join(env.projectPath, file)).mtimeMs;
|
|
102
108
|
readable++;
|
|
103
109
|
if (mtime > evidence.mtime) laterThanEvidence.push(file);
|
|
110
|
+
else if (mtime === evidence.mtime) sameAsEvidence.push(file);
|
|
104
111
|
} catch {
|
|
105
112
|
// 变更文件不可读(如已删除):不参与新鲜度判定
|
|
106
113
|
}
|
|
@@ -121,6 +128,14 @@ export const noCompletionWithoutVerification: ConstraintCheck = {
|
|
|
121
128
|
),
|
|
122
129
|
};
|
|
123
130
|
}
|
|
131
|
+
// 同刻等值 = 时钟精度内先后不可判(harness#195):不放行也不违规,显式降级。
|
|
132
|
+
// 置于 fail 之后:严格晚于证据的变更并存时证据确定过期,不因同刻降级
|
|
133
|
+
if (sameAsEvidence.length > 0) {
|
|
134
|
+
return {
|
|
135
|
+
skip: true,
|
|
136
|
+
reason: `证据与变更文件同刻(mtime 等值,时钟精度内无法区分先后):${sameAsEvidence.join(', ')},无法判定证据新鲜度,本次未评估`,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
124
139
|
return true;
|
|
125
140
|
},
|
|
126
141
|
};
|
|
@@ -120,11 +120,6 @@ function scanText(text: string, file: string): Hit[] {
|
|
|
120
120
|
return hits;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
/** 判定一段文本是否包含硬编码凭证 */
|
|
124
|
-
export function containsHardcodedCredential(text: string): boolean {
|
|
125
|
-
return scanText(text, '(text)').length > 0;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
123
|
interface AddedLine {
|
|
129
124
|
file: string;
|
|
130
125
|
lineNo: number;
|
|
@@ -47,7 +47,7 @@ export const fileExists: TemplatedCheckerFactory = {
|
|
|
47
47
|
evaluate(env) {
|
|
48
48
|
const pathHit = rel !== undefined && existsSync(join(env.projectPath, rel));
|
|
49
49
|
const globHits = globPattern !== undefined
|
|
50
|
-
? glob.sync(globPattern, { cwd: env.projectPath, dot: true, onlyFiles: false })
|
|
50
|
+
? glob.sync(globPattern, { cwd: env.projectPath, dot: true, onlyFiles: false, ignore: ['node_modules/**'] })
|
|
51
51
|
: [];
|
|
52
52
|
|
|
53
53
|
if (mustExist) {
|
|
@@ -1,44 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 模板侧轻量 glob 匹配(支持 `**`、`*`、`?`,纯字符串判定,不碰文件系统)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* 参数匹配不住 completion-checkers 的 commits 分类模块。
|
|
4
|
+
* glob→正则正本在 `utils/glob-match.ts`(与 completion-checkers 同一匹配语义,
|
|
5
|
+
* utils 下游白名单内,分层守卫(harness#88)不违)。
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
return s.replace(/[.+^${}()|[\]\\]/g, '\\$&');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** glob → 锚定正则。前缀 `**` + `/` 匹配零或多段路径;`*` 不跨 `/`;`?` 匹配单个非 `/` 字符 */
|
|
14
|
-
function globToRegExp(glob: string): RegExp {
|
|
15
|
-
let re = '';
|
|
16
|
-
let i = 0;
|
|
17
|
-
while (i < glob.length) {
|
|
18
|
-
const c = glob[i];
|
|
19
|
-
if (c === '*') {
|
|
20
|
-
if (glob[i + 1] === '*') {
|
|
21
|
-
if (glob[i + 2] === '/') {
|
|
22
|
-
re += '(?:[^/]+/)*';
|
|
23
|
-
i += 3;
|
|
24
|
-
} else {
|
|
25
|
-
re += '.*';
|
|
26
|
-
i += 2;
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
re += '[^/]*';
|
|
30
|
-
i += 1;
|
|
31
|
-
}
|
|
32
|
-
} else if (c === '?') {
|
|
33
|
-
re += '[^/]';
|
|
34
|
-
i += 1;
|
|
35
|
-
} else {
|
|
36
|
-
re += escapeRegExp(c);
|
|
37
|
-
i += 1;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return new RegExp('^' + re + '$');
|
|
41
|
-
}
|
|
8
|
+
import { globToRegExp } from '../../../../utils/glob-match';
|
|
42
9
|
|
|
43
10
|
/** 单 glob 匹配(相对路径正斜杠口径) */
|
|
44
11
|
export function matchGlob(file: string, glob: string): boolean {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CONTEXT.md 构造点计数标记判定(harness#202 / ADR-0039)
|
|
3
|
+
*
|
|
4
|
+
* ADR-0025 的判定面只钉「核心导出」节符号面,散文机械不可判。本模块是
|
|
5
|
+
* 判定面的**标记化扩展**:文档在散文陈述旁附机器可读标记
|
|
6
|
+
* `<!-- sync-docs:construction-sites X = N -->`(可选 `include: tests`),
|
|
7
|
+
* 声明「类 X 的仓内直构造点恰为 N 处」;无标记的散文维持现状不判。
|
|
8
|
+
*
|
|
9
|
+
* 纯判定 module:标记解析、`new X(` 计数口径、期望/实际对撞全在此,
|
|
10
|
+
* 不吃 fs——文件遍历与正文读取在调用方(cli 侧 sync-docs/context-syncer),
|
|
11
|
+
* 与 context-reconcile 同一套「判定不吃 fs、清单由调用方组装」形状。
|
|
12
|
+
*
|
|
13
|
+
* 计数口径:
|
|
14
|
+
* - 只数 `new X(` 直构造(含一层泛型实参 `new Map<string, boolean>()`);
|
|
15
|
+
* 工厂封装调用点(`openKnowledgeStore()` 等)不算构造点。
|
|
16
|
+
* - 排除范围由采集侧按 DEFAULT_SKIP_DIRS 执行(node_modules/__tests__/dist),
|
|
17
|
+
* 标记带 `include: tests` 时测试目录计入。
|
|
18
|
+
* - 已知限度:正则解析源文本,嵌套泛型实参与字符串/注释里的 `new X(`
|
|
19
|
+
* 字面出现都会计入(登记在 ADR-0039,不掩盖)。
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** 构造点标记:`<!-- sync-docs:construction-sites X = N -->`,可带 `include: tests` */
|
|
23
|
+
const MARKER_REGEX =
|
|
24
|
+
/<!--\s*sync-docs:construction-sites\s+([A-Za-z_$][\w$]*)\s*=\s*(\d+)(\s+include\s*:\s*tests)?\s*-->/g;
|
|
25
|
+
|
|
26
|
+
/** 直构造:`new X(` / `new X<T>(`(泛型实参只认一层,不嵌套) */
|
|
27
|
+
const CONSTRUCTION_REGEX = /new\s+([A-Za-z_$][\w$]*)\s*(?:<[^<>]*>)?\s*\(/g;
|
|
28
|
+
|
|
29
|
+
export interface ConstructionSiteMarker {
|
|
30
|
+
/** 被计数的类名 */
|
|
31
|
+
className: string;
|
|
32
|
+
/** 文档声明的期望构造点数 */
|
|
33
|
+
expected: number;
|
|
34
|
+
/** 是否把测试目录计入(标记带 `include: tests`) */
|
|
35
|
+
includeTests: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ConstructionSiteDrift {
|
|
39
|
+
className: string;
|
|
40
|
+
expected: number;
|
|
41
|
+
/** 采集到的实际构造点数 */
|
|
42
|
+
actual: number;
|
|
43
|
+
includeTests: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 解析文档中的构造点标记;无标记的散文与普通注释不判,
|
|
48
|
+
* 畸形标记(缺数字/缺类名/未知选项)整条跳过(不判优于误判)。
|
|
49
|
+
*/
|
|
50
|
+
export function parseConstructionSiteMarkers(content: string): ConstructionSiteMarker[] {
|
|
51
|
+
const markers: ConstructionSiteMarker[] = [];
|
|
52
|
+
for (const match of content.matchAll(MARKER_REGEX)) {
|
|
53
|
+
markers.push({
|
|
54
|
+
className: match[1],
|
|
55
|
+
expected: Number(match[2]),
|
|
56
|
+
includeTests: Boolean(match[3]),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return markers;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 单份源文本的直构造计数(口径正本):类名 → 出现次数。
|
|
64
|
+
* 采集侧逐文件调用后累加;测试与采集共用此函数,check/fix 口径必然一致。
|
|
65
|
+
*/
|
|
66
|
+
export function tallyConstructionSites(source: string): Map<string, number> {
|
|
67
|
+
const tally = new Map<string, number>();
|
|
68
|
+
for (const match of source.matchAll(CONSTRUCTION_REGEX)) {
|
|
69
|
+
tally.set(match[1], (tally.get(match[1]) ?? 0) + 1);
|
|
70
|
+
}
|
|
71
|
+
return tally;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 标记与采集计数的对撞判定:期望 ≠ 实际即漂移,点名类名/期望/实际。
|
|
76
|
+
* countFor 由调用方组装(fs 采集在那侧),按标记的 includeTests 口径取数。
|
|
77
|
+
*/
|
|
78
|
+
export function reconcileConstructionSites(input: {
|
|
79
|
+
markers: ConstructionSiteMarker[];
|
|
80
|
+
countFor: (className: string, includeTests: boolean) => number;
|
|
81
|
+
}): { drift: ConstructionSiteDrift[] } {
|
|
82
|
+
const drift: ConstructionSiteDrift[] = [];
|
|
83
|
+
for (const marker of input.markers) {
|
|
84
|
+
const actual = input.countFor(marker.className, marker.includeTests);
|
|
85
|
+
if (actual !== marker.expected) {
|
|
86
|
+
drift.push({
|
|
87
|
+
className: marker.className,
|
|
88
|
+
expected: marker.expected,
|
|
89
|
+
actual,
|
|
90
|
+
includeTests: marker.includeTests,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { drift };
|
|
95
|
+
}
|
|
@@ -469,6 +469,9 @@ export class FreshnessRunner {
|
|
|
469
469
|
|
|
470
470
|
const entries = readdirSync(searchDir, { withFileTypes: true });
|
|
471
471
|
|
|
472
|
+
// 正则提出循环:String.match 带 g flag 时不携带 lastIndex 状态(每次调用内部归零),复用安全
|
|
473
|
+
const matchRe = new RegExp(pattern, 'g');
|
|
474
|
+
|
|
472
475
|
let count = 0;
|
|
473
476
|
for (const entry of entries) {
|
|
474
477
|
if (!entry.isFile()) continue;
|
|
@@ -476,7 +479,7 @@ export class FreshnessRunner {
|
|
|
476
479
|
|
|
477
480
|
try {
|
|
478
481
|
const content = readFileSync(join(searchDir, entry.name), 'utf-8');
|
|
479
|
-
const matches = content.match(
|
|
482
|
+
const matches = content.match(matchRe);
|
|
480
483
|
if (matches) {
|
|
481
484
|
count += matches.length;
|
|
482
485
|
}
|