@dommaker/harness 0.16.6 → 0.16.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +54 -14
- package/bin/harness.js +56 -96
- package/dist/architecture/constraint-engine.d.ts.map +1 -1
- package/dist/architecture/constraint-engine.js +0 -4
- package/dist/architecture/constraint-engine.js.map +1 -1
- package/dist/architecture/cross-project-checker.d.ts.map +1 -1
- package/dist/architecture/cross-project-checker.js +5 -25
- package/dist/architecture/cross-project-checker.js.map +1 -1
- package/dist/cli/commands/analyze-sessions.d.ts +2 -0
- package/dist/cli/commands/analyze-sessions.d.ts.map +1 -1
- package/dist/cli/commands/analyze-sessions.js +25 -181
- package/dist/cli/commands/analyze-sessions.js.map +1 -1
- package/dist/cli/commands/check.d.ts +1 -0
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +24 -216
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/doc-freshness-check.d.ts.map +1 -1
- package/dist/cli/commands/doc-freshness-check.js +14 -28
- package/dist/cli/commands/doc-freshness-check.js.map +1 -1
- package/dist/cli/commands/flow.d.ts.map +1 -1
- package/dist/cli/commands/flow.js +2 -1
- package/dist/cli/commands/flow.js.map +1 -1
- package/dist/cli/commands/init.js +2 -2
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/posteval-plan.d.ts.map +1 -1
- package/dist/cli/commands/posteval-plan.js +0 -1
- package/dist/cli/commands/posteval-plan.js.map +1 -1
- package/dist/cli/commands/release.js +1 -1
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/report.d.ts.map +1 -1
- package/dist/cli/commands/report.js +2 -0
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +12 -23
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.d.ts +19 -0
- package/dist/cli/commands/sync-docs/agents-syncer.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/agents-syncer.js +288 -0
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -0
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +37 -0
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +235 -0
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts +17 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/context-syncer.js +143 -0
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -0
- package/dist/cli/commands/{sync-docs.d.ts → sync-docs/index.d.ts} +9 -2
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/index.js +338 -0
- package/dist/cli/commands/sync-docs/index.js.map +1 -0
- package/dist/cli/commands/sync-docs/preserve-block.d.ts +24 -0
- package/dist/cli/commands/sync-docs/preserve-block.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/preserve-block.js +55 -0
- package/dist/cli/commands/sync-docs/preserve-block.js.map +1 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts +41 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/project-reader.js +183 -0
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -0
- package/dist/cli/commands/update-user-model.d.ts +2 -0
- package/dist/cli/commands/update-user-model.d.ts.map +1 -1
- package/dist/cli/commands/update-user-model.js +19 -90
- package/dist/cli/commands/update-user-model.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +3 -0
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +6 -39
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/session-mining/corrections.d.ts +17 -0
- package/dist/cli/session-mining/corrections.d.ts.map +1 -0
- package/dist/cli/session-mining/corrections.js +58 -0
- package/dist/cli/session-mining/corrections.js.map +1 -0
- package/dist/cli/session-mining/index.d.ts +13 -0
- package/dist/cli/session-mining/index.d.ts.map +1 -0
- package/dist/{core/spec → cli/session-mining}/index.js +9 -3
- package/dist/cli/session-mining/index.js.map +1 -0
- package/dist/cli/session-mining/text.d.ts +31 -0
- package/dist/cli/session-mining/text.d.ts.map +1 -0
- package/dist/cli/session-mining/text.js +126 -0
- package/dist/cli/session-mining/text.js.map +1 -0
- package/dist/cli/session-mining/transcript.d.ts +28 -0
- package/dist/cli/session-mining/transcript.d.ts.map +1 -0
- package/dist/cli/session-mining/transcript.js +123 -0
- package/dist/cli/session-mining/transcript.js.map +1 -0
- package/dist/constraints/lifecycle-runner.d.ts +1 -1
- package/dist/constraints/lifecycle-runner.d.ts.map +1 -1
- package/dist/context/compaction.d.ts.map +1 -1
- package/dist/context/compaction.js +2 -3
- package/dist/context/compaction.js.map +1 -1
- package/dist/context/knowledge-injector.d.ts.map +1 -1
- package/dist/context/tool-output-budget.d.ts +1 -1
- package/dist/context/tool-output-budget.d.ts.map +1 -1
- package/dist/context/tool-output-budget.js +1 -1
- package/dist/context/tool-output-budget.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +24 -0
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -0
- package/dist/core/constraints/capabilities-parser.js +95 -0
- package/dist/core/constraints/capabilities-parser.js.map +1 -0
- package/dist/core/constraints/checker.d.ts +37 -100
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +150 -737
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/always-pass.d.ts +17 -0
- package/dist/core/constraints/checkers/always-pass.d.ts.map +1 -0
- package/dist/core/constraints/checkers/always-pass.js +23 -0
- package/dist/core/constraints/checkers/always-pass.js.map +1 -0
- package/dist/core/constraints/checkers/capability-sync.d.ts +10 -0
- package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -0
- package/dist/core/constraints/checkers/capability-sync.js +60 -0
- package/dist/core/constraints/checkers/capability-sync.js.map +1 -0
- package/dist/core/constraints/checkers/context-doc-sync.d.ts +6 -0
- package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -0
- package/dist/core/constraints/checkers/context-doc-sync.js +35 -0
- package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -0
- package/dist/core/constraints/checkers/docs-freshness.d.ts +10 -0
- package/dist/core/constraints/checkers/docs-freshness.d.ts.map +1 -0
- package/dist/core/constraints/checkers/docs-freshness.js +111 -0
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -0
- package/dist/core/constraints/checkers/guideline-flags.d.ts +9 -0
- package/dist/core/constraints/checkers/guideline-flags.d.ts.map +1 -0
- package/dist/core/constraints/checkers/guideline-flags.js +13 -0
- package/dist/core/constraints/checkers/guideline-flags.js.map +1 -0
- package/dist/core/constraints/checkers/index.d.ts +17 -0
- package/dist/core/constraints/checkers/index.d.ts.map +1 -0
- package/dist/core/constraints/checkers/index.js +82 -0
- package/dist/core/constraints/checkers/index.js.map +1 -0
- package/dist/core/constraints/checkers/iron-flags.d.ts +14 -0
- package/dist/core/constraints/checkers/iron-flags.d.ts.map +1 -0
- package/dist/core/constraints/checkers/iron-flags.js +24 -0
- package/dist/core/constraints/checkers/iron-flags.js.map +1 -0
- package/dist/core/constraints/checkers/no-any-type.d.ts +6 -0
- package/dist/core/constraints/checkers/no-any-type.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-any-type.js +42 -0
- package/dist/core/constraints/checkers/no-any-type.js.map +1 -0
- package/dist/core/constraints/checkers/no-bypass-checkpoint.d.ts +6 -0
- package/dist/core/constraints/checkers/no-bypass-checkpoint.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-bypass-checkpoint.js +40 -0
- package/dist/core/constraints/checkers/no-bypass-checkpoint.js.map +1 -0
- package/dist/core/constraints/checkers/no-excuse-patterns.d.ts +6 -0
- package/dist/core/constraints/checkers/no-excuse-patterns.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-excuse-patterns.js +25 -0
- package/dist/core/constraints/checkers/no-excuse-patterns.js.map +1 -0
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.d.ts +6 -0
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.js +34 -0
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.js.map +1 -0
- package/dist/core/constraints/checkers/no-performative-agreement.d.ts +8 -0
- package/dist/core/constraints/checkers/no-performative-agreement.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-performative-agreement.js +23 -0
- package/dist/core/constraints/checkers/no-performative-agreement.js.map +1 -0
- package/dist/core/constraints/checkers/no-simplification-without-approval.d.ts +6 -0
- package/dist/core/constraints/checkers/no-simplification-without-approval.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-simplification-without-approval.js +30 -0
- package/dist/core/constraints/checkers/no-simplification-without-approval.js.map +1 -0
- package/dist/core/constraints/checkers/no-test-simplification.d.ts +6 -0
- package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-test-simplification.js +29 -0
- package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -0
- package/dist/core/constraints/checkers/test-coverage.d.ts +6 -0
- package/dist/core/constraints/checkers/test-coverage.d.ts.map +1 -0
- package/dist/core/constraints/checkers/test-coverage.js +33 -0
- package/dist/core/constraints/checkers/test-coverage.js.map +1 -0
- package/dist/core/constraints/checkers/types.d.ts +43 -0
- package/dist/core/constraints/checkers/types.d.ts.map +1 -0
- package/dist/core/constraints/checkers/types.js +23 -0
- package/dist/core/constraints/checkers/types.js.map +1 -0
- package/dist/core/constraints/checkers/yagni.d.ts +8 -0
- package/dist/core/constraints/checkers/yagni.d.ts.map +1 -0
- package/dist/core/constraints/checkers/yagni.js +96 -0
- package/dist/core/constraints/checkers/yagni.js.map +1 -0
- package/dist/core/constraints/context-builder.d.ts +67 -0
- package/dist/core/constraints/context-builder.d.ts.map +1 -0
- package/dist/core/constraints/context-builder.js +294 -0
- package/dist/core/constraints/context-builder.js.map +1 -0
- package/dist/core/constraints/definitions/guidelines.d.ts +7 -0
- package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -0
- package/dist/core/constraints/definitions/guidelines.js +641 -0
- package/dist/core/constraints/definitions/guidelines.js.map +1 -0
- package/dist/core/constraints/definitions/iron-laws.d.ts +7 -0
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -0
- package/dist/core/constraints/definitions/iron-laws.js +322 -0
- package/dist/core/constraints/definitions/iron-laws.js.map +1 -0
- package/dist/core/constraints/definitions/tips.d.ts +7 -0
- package/dist/core/constraints/definitions/tips.d.ts.map +1 -0
- package/dist/core/constraints/definitions/tips.js +62 -0
- package/dist/core/constraints/definitions/tips.js.map +1 -0
- package/dist/core/constraints/definitions.d.ts +8 -21
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +15 -1048
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +0 -1
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/index.d.ts +4 -5
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +1 -16
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/interceptor.d.ts.map +1 -1
- package/dist/core/constraints/interceptor.js.map +1 -1
- package/dist/core/index.js +0 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +6 -4
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +46 -13
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/validators/check-handlers/command.d.ts +7 -0
- package/dist/core/validators/check-handlers/command.d.ts.map +1 -0
- package/dist/core/validators/check-handlers/command.js +58 -0
- package/dist/core/validators/check-handlers/command.js.map +1 -0
- package/dist/core/validators/check-handlers/file.d.ts +10 -0
- package/dist/core/validators/check-handlers/file.d.ts.map +1 -0
- package/dist/core/validators/check-handlers/file.js +128 -0
- package/dist/core/validators/check-handlers/file.js.map +1 -0
- package/dist/core/validators/check-handlers/http.d.ts +7 -0
- package/dist/core/validators/check-handlers/http.d.ts.map +1 -0
- package/dist/core/validators/check-handlers/http.js +88 -0
- package/dist/core/validators/check-handlers/http.js.map +1 -0
- package/dist/core/validators/check-handlers/output.d.ts +15 -0
- package/dist/core/validators/check-handlers/output.d.ts.map +1 -0
- package/dist/core/validators/check-handlers/output.js +152 -0
- package/dist/core/validators/check-handlers/output.js.map +1 -0
- package/dist/core/validators/checkpoint.d.ts +4 -72
- package/dist/core/validators/checkpoint.d.ts.map +1 -1
- package/dist/core/validators/checkpoint.js +21 -400
- package/dist/core/validators/checkpoint.js.map +1 -1
- package/dist/core/validators/cso.js +1 -1
- package/dist/core/validators/cso.js.map +1 -1
- package/dist/core/validators/passes-gate.js +2 -2
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/dashboard/stats.d.ts.map +1 -1
- package/dist/dashboard/types.d.ts.map +1 -1
- package/dist/evolution/auto-evolve.d.ts +1 -2
- package/dist/evolution/auto-evolve.d.ts.map +1 -1
- package/dist/evolution/auto-evolve.js +2 -1
- package/dist/evolution/auto-evolve.js.map +1 -1
- package/dist/failure/types.d.ts +5 -85
- package/dist/failure/types.d.ts.map +1 -1
- package/dist/failure/types.js +19 -115
- package/dist/failure/types.js.map +1 -1
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/index.d.ts.map +1 -1
- package/dist/gates/index.js.map +1 -1
- package/dist/gates/performance.js +1 -1
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +1 -1
- package/dist/gates/security.js.map +1 -1
- package/dist/hooks/bootstrap.d.ts.map +1 -1
- package/dist/hooks/bootstrap.js +6 -48
- package/dist/hooks/bootstrap.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/doctor.d.ts.map +1 -1
- package/dist/knowledge/doctor.js.map +1 -1
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/import.js +1 -1
- package/dist/knowledge/import.js.map +1 -1
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +0 -1
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +1 -1
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lint.d.ts +1 -1
- package/dist/knowledge/lint.d.ts.map +1 -1
- package/dist/knowledge/lint.js +2 -2
- package/dist/knowledge/lint.js.map +1 -1
- package/dist/knowledge/primitives/code-structure.d.ts.map +1 -1
- package/dist/knowledge/primitives/code-structure.js +29 -12
- package/dist/knowledge/primitives/code-structure.js.map +1 -1
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/llm/adapter.d.ts +3 -3
- package/dist/llm/adapter.d.ts.map +1 -1
- package/dist/llm/adapter.js +3 -3
- package/dist/llm/adapter.js.map +1 -1
- package/dist/monitoring/analyzer-base.d.ts +50 -0
- package/dist/monitoring/analyzer-base.d.ts.map +1 -0
- package/dist/monitoring/analyzer-base.js +146 -0
- package/dist/monitoring/analyzer-base.js.map +1 -0
- package/dist/monitoring/constraint-doctor.d.ts +3 -46
- package/dist/monitoring/constraint-doctor.d.ts.map +1 -1
- package/dist/monitoring/constraint-doctor.js +11 -113
- package/dist/monitoring/constraint-doctor.js.map +1 -1
- package/dist/monitoring/constraint-evolver.d.ts +9 -63
- package/dist/monitoring/constraint-evolver.d.ts.map +1 -1
- package/dist/monitoring/constraint-evolver.js +8 -10
- package/dist/monitoring/constraint-evolver.js.map +1 -1
- package/dist/monitoring/diagnosis-rules.d.ts +18 -0
- package/dist/monitoring/diagnosis-rules.d.ts.map +1 -0
- package/dist/monitoring/diagnosis-rules.js +119 -0
- package/dist/monitoring/diagnosis-rules.js.map +1 -0
- package/dist/monitoring/knowledge-doctor.d.ts.map +1 -1
- package/dist/monitoring/knowledge-doctor.js.map +1 -1
- package/dist/monitoring/performance-analyzer.d.ts +0 -12
- package/dist/monitoring/performance-analyzer.d.ts.map +1 -1
- package/dist/monitoring/performance-analyzer.js +13 -93
- package/dist/monitoring/performance-analyzer.js.map +1 -1
- package/dist/monitoring/performance-collector.d.ts +0 -8
- package/dist/monitoring/performance-collector.d.ts.map +1 -1
- package/dist/monitoring/performance-collector.js +0 -21
- package/dist/monitoring/performance-collector.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +0 -8
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +9 -91
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/presets/index.d.ts +1 -1
- package/dist/presets/index.d.ts.map +1 -1
- package/dist/presets/index.js +1 -4
- package/dist/presets/index.js.map +1 -1
- package/dist/presets/standard.d.ts +0 -9
- package/dist/presets/standard.d.ts.map +1 -1
- package/dist/presets/standard.js +1 -16
- package/dist/presets/standard.js.map +1 -1
- package/dist/safety/output-guardrail.d.ts +0 -1
- package/dist/safety/output-guardrail.d.ts.map +1 -1
- package/dist/safety/output-guardrail.js +0 -3
- package/dist/safety/output-guardrail.js.map +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/types/constraint.d.ts +5 -59
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js +1 -39
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/failure.d.ts +89 -0
- package/dist/types/failure.d.ts.map +1 -0
- package/dist/types/failure.js +121 -0
- package/dist/types/failure.js.map +1 -0
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +7 -6
- package/dist/types/index.js.map +1 -1
- package/dist/types/monitoring-types.d.ts +114 -0
- package/dist/types/monitoring-types.d.ts.map +1 -0
- package/dist/types/monitoring-types.js +10 -0
- package/dist/types/monitoring-types.js.map +1 -0
- package/dist/utils/detect-source-roots.js.map +1 -1
- package/dist/utils/file-walk.d.ts +33 -0
- package/dist/utils/file-walk.d.ts.map +1 -0
- package/dist/utils/file-walk.js +89 -0
- package/dist/utils/file-walk.js.map +1 -0
- package/dist/verification/rules-based.d.ts.map +1 -1
- package/dist/verification/rules-based.js.map +1 -1
- package/package.json +3 -7
- package/src/__tests__/checker-extra.test.ts +0 -30
- package/src/__tests__/checker.test.ts +0 -33
- package/src/__tests__/checkpoint.test.ts +46 -46
- package/src/__tests__/constraint-evolver.test.ts +22 -21
- package/src/__tests__/doctor-evolver.test.ts +3 -3
- package/src/__tests__/iron-laws.test.ts +0 -27
- package/src/__tests__/presets.test.ts +1 -40
- package/src/architecture/constraint-engine.ts +0 -5
- package/src/architecture/cross-project-checker.ts +6 -24
- package/src/cli/commands/__tests__/check.test.ts +3 -1
- package/src/cli/commands/__tests__/sync-docs.test.ts +77 -0
- package/src/cli/commands/__tests__/validate.test.ts +5 -0
- package/src/cli/commands/analyze-sessions.ts +31 -185
- package/src/cli/commands/check.ts +26 -225
- package/src/cli/commands/doc-freshness-check.ts +14 -25
- package/src/cli/commands/flow.ts +5 -3
- package/src/cli/commands/init.ts +3 -3
- package/src/cli/commands/posteval-plan.ts +0 -1
- package/src/cli/commands/release.ts +1 -1
- package/src/cli/commands/report.ts +2 -0
- package/src/cli/commands/spec-baseline-check.ts +12 -19
- package/src/cli/commands/sync-docs/agents-syncer.ts +280 -0
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +229 -0
- package/src/cli/commands/sync-docs/context-syncer.ts +108 -0
- package/src/cli/commands/sync-docs/index.ts +355 -0
- package/src/cli/commands/sync-docs/preserve-block.ts +59 -0
- package/src/cli/commands/sync-docs/project-reader.ts +163 -0
- package/src/cli/commands/update-user-model.ts +23 -87
- package/src/cli/commands/validate.ts +6 -40
- package/src/cli/session-mining/corrections.ts +56 -0
- package/src/cli/session-mining/index.ts +13 -0
- package/src/cli/session-mining/text.ts +117 -0
- package/src/cli/session-mining/transcript.ts +107 -0
- package/src/constraints/__tests__/lifecycle-runner.test.ts +1 -1
- package/src/constraints/lifecycle-runner.ts +1 -1
- package/src/context/compaction.ts +2 -3
- package/src/context/knowledge-injector.ts +1 -1
- package/src/context/tool-output-budget.ts +1 -1
- package/src/core/constraints/capabilities-parser.ts +70 -0
- package/src/core/constraints/checker.ts +170 -779
- package/src/core/constraints/checkers/always-pass.ts +22 -0
- package/src/core/constraints/checkers/capability-sync.ts +71 -0
- package/src/core/constraints/checkers/context-doc-sync.ts +36 -0
- package/src/core/constraints/checkers/docs-freshness.ts +116 -0
- package/src/core/constraints/checkers/guideline-flags.ts +30 -0
- package/src/core/constraints/checkers/index.ts +114 -0
- package/src/core/constraints/checkers/iron-flags.ts +62 -0
- package/src/core/constraints/checkers/no-any-type.ts +42 -0
- package/src/core/constraints/checkers/no-bypass-checkpoint.ts +40 -0
- package/src/core/constraints/checkers/no-excuse-patterns.ts +24 -0
- package/src/core/constraints/checkers/no-fuzzy-completion-claim.ts +33 -0
- package/src/core/constraints/checkers/no-performative-agreement.ts +22 -0
- package/src/core/constraints/checkers/no-simplification-without-approval.ts +29 -0
- package/src/core/constraints/checkers/no-test-simplification.ts +28 -0
- package/src/core/constraints/checkers/test-coverage.ts +35 -0
- package/src/core/constraints/checkers/types.ts +54 -0
- package/src/core/constraints/checkers/yagni.ts +65 -0
- package/src/core/constraints/context-builder.ts +262 -0
- package/src/core/constraints/definitions/guidelines.ts +668 -0
- package/src/core/constraints/definitions/iron-laws.ts +333 -0
- package/src/core/constraints/definitions/tips.ts +63 -0
- package/src/core/constraints/definitions.ts +9 -1086
- package/src/core/constraints/doc-freshness/runner.ts +2 -3
- package/src/core/constraints/index.ts +1 -27
- package/src/core/constraints/interceptor.ts +0 -2
- package/src/core/index.ts +1 -1
- package/src/core/project-config-loader.ts +49 -13
- package/src/core/validators/check-handlers/command.ts +58 -0
- package/src/core/validators/check-handlers/file.ts +104 -0
- package/src/core/validators/check-handlers/http.ts +88 -0
- package/src/core/validators/check-handlers/output.ts +165 -0
- package/src/core/validators/checkpoint.ts +32 -407
- package/src/core/validators/cso.ts +1 -1
- package/src/core/validators/passes-gate.ts +2 -2
- package/src/dashboard/stats.ts +1 -1
- package/src/dashboard/types.ts +1 -1
- package/src/evolution/__tests__/auto-evolve.test.ts +1 -2
- package/src/evolution/auto-evolve.ts +3 -3
- package/src/failure/types.ts +5 -161
- package/src/gates/contract.ts +0 -1
- package/src/gates/index.ts +0 -2
- package/src/gates/performance.ts +1 -1
- package/src/gates/security.ts +1 -3
- package/src/hooks/bootstrap.ts +6 -16
- package/src/index.ts +4 -1
- package/src/knowledge/__tests__/lifecycle.test.ts +4 -1
- package/src/knowledge/audit.ts +1 -1
- package/src/knowledge/doctor.ts +0 -1
- package/src/knowledge/import.ts +2 -2
- package/src/knowledge/index-generator.ts +0 -1
- package/src/knowledge/ingest.ts +1 -2
- package/src/knowledge/lint.ts +2 -2
- package/src/knowledge/primitives/__tests__/code-structure-degrade.test.ts +24 -0
- package/src/knowledge/primitives/code-structure.ts +36 -12
- package/src/knowledge/query.ts +0 -3
- package/src/knowledge/store.ts +1 -1
- package/src/llm/adapter.ts +3 -3
- package/src/monitoring/analyzer-base.ts +112 -0
- package/src/monitoring/constraint-doctor.ts +14 -175
- package/src/monitoring/constraint-evolver.ts +20 -92
- package/src/monitoring/diagnosis-rules.ts +132 -0
- package/src/monitoring/knowledge-doctor.ts +0 -1
- package/src/monitoring/performance-analyzer.ts +22 -72
- package/src/monitoring/performance-collector.ts +0 -22
- package/src/monitoring/trace-analyzer.ts +17 -73
- package/src/presets/__tests__/standard.test.ts +2 -17
- package/src/presets/index.ts +1 -3
- package/src/presets/standard.ts +1 -26
- package/src/safety/output-guardrail.ts +0 -4
- package/src/tools/registry.ts +1 -1
- package/src/types/__tests__/types.test.ts +1 -33
- package/src/types/constraint.ts +6 -75
- package/src/types/failure.ts +165 -0
- package/src/types/index.ts +7 -5
- package/src/types/monitoring-types.ts +150 -0
- package/src/utils/detect-source-roots.ts +1 -1
- package/src/utils/file-walk.ts +78 -0
- package/src/verification/rules-based.ts +0 -1
- package/bin/harness-knowledge-capture.js +0 -99
- package/bin/harness-knowledge-check.js +0 -164
- package/bin/harness-knowledge-track.js +0 -118
- package/dist/cli/commands/sync-docs.d.ts.map +0 -1
- package/dist/cli/commands/sync-docs.js +0 -1074
- package/dist/cli/commands/sync-docs.js.map +0 -1
- package/dist/constraints/index.d.ts +0 -4
- package/dist/constraints/index.d.ts.map +0 -1
- package/dist/constraints/index.js +0 -20
- package/dist/constraints/index.js.map +0 -1
- package/dist/core/constraints/doc-freshness/auto-fix.d.ts +0 -23
- package/dist/core/constraints/doc-freshness/auto-fix.d.ts.map +0 -1
- package/dist/core/constraints/doc-freshness/auto-fix.js +0 -59
- package/dist/core/constraints/doc-freshness/auto-fix.js.map +0 -1
- package/dist/core/constraints/prompt-injection.d.ts +0 -16
- package/dist/core/constraints/prompt-injection.d.ts.map +0 -1
- package/dist/core/constraints/prompt-injection.js +0 -69
- package/dist/core/constraints/prompt-injection.js.map +0 -1
- package/dist/core/spec/index.d.ts +0 -7
- package/dist/core/spec/index.d.ts.map +0 -1
- package/dist/core/spec/index.js.map +0 -1
- package/dist/governance/executor.d.ts +0 -45
- package/dist/governance/executor.d.ts.map +0 -1
- package/dist/governance/executor.js +0 -243
- package/dist/governance/executor.js.map +0 -1
- package/dist/governance/index.d.ts +0 -9
- package/dist/governance/index.d.ts.map +0 -1
- package/dist/governance/index.js +0 -13
- package/dist/governance/index.js.map +0 -1
- package/dist/governance/types.d.ts +0 -46
- package/dist/governance/types.d.ts.map +0 -1
- package/dist/governance/types.js +0 -9
- package/dist/governance/types.js.map +0 -1
- package/dist/tools/definitions/definitions/core/code/fingerprint.sh +0 -273
- package/dist/tools/definitions/definitions/core/code/fingerprint.yml +0 -72
- package/dist/tools/definitions/definitions/core/code/parse.yml +0 -68
- package/dist/tools/definitions/definitions/core/code/register-language.sh +0 -475
- package/dist/tools/definitions/definitions/core/code/register-language.yml +0 -74
- package/dist/tools/definitions/definitions/core/docker/build.yml +0 -73
- package/dist/tools/definitions/definitions/core/docker/run.yml +0 -81
- package/dist/tools/definitions/definitions/core/file/copy.yml +0 -88
- package/dist/tools/definitions/definitions/core/file/read.yml +0 -69
- package/dist/tools/definitions/definitions/core/file/write.yml +0 -75
- package/dist/tools/definitions/definitions/core/git/branch.yml +0 -61
- package/dist/tools/definitions/definitions/core/git/cleanup-worktree.yml +0 -50
- package/dist/tools/definitions/definitions/core/git/clone.yml +0 -69
- package/dist/tools/definitions/definitions/core/git/commit.yml +0 -65
- package/dist/tools/definitions/definitions/core/git/push.yml +0 -79
- package/dist/tools/definitions/definitions/core/git/worktree.yml +0 -96
- package/dist/tools/definitions/definitions/core/notification/notify.sh +0 -152
- package/dist/tools/definitions/definitions/core/notification/notify.yml +0 -60
- package/dist/tools/definitions/definitions/core/npm/build.yml +0 -75
- package/dist/tools/definitions/definitions/core/npm/install.yml +0 -58
- package/dist/tools/definitions/definitions/core/npm/test.yml +0 -75
- package/dist/tools/definitions/definitions/core/validation/check-reuse.yml +0 -170
- package/dist/tools/definitions/definitions/core/validation/validate-handlers.yml +0 -118
- package/dist/tools/definitions/definitions/core/validation/validate-readme-stats.yml +0 -155
- package/dist/tools/definitions/definitions/core/validation/validate-yaml-syntax.yml +0 -134
- package/dist/tools/definitions/definitions/ext/browser/browser-automate.sh +0 -255
- package/dist/tools/definitions/definitions/ext/browser/browser-automate.yml +0 -166
- package/dist/tools/definitions/definitions/ext/browser/browser-close.sh +0 -104
- package/dist/tools/definitions/definitions/ext/browser/browser-close.yml +0 -55
- package/dist/tools/definitions/definitions/ext/browser/browser-mcp-debug.sh +0 -682
- package/dist/tools/definitions/definitions/ext/browser/browser-mcp-debug.yml +0 -167
- package/dist/tools/definitions/definitions/ext/browser/browser-start.sh +0 -101
- package/dist/tools/definitions/definitions/ext/browser/browser-start.yml +0 -62
- package/dist/tools/definitions/definitions/registry.json +0 -795
- package/dist/tools/definitions/definitions/std/README.md +0 -350
- package/dist/tools/definitions/definitions/std/analysis/analyze-codebase.yml +0 -72
- package/dist/tools/definitions/definitions/std/analysis/analyze-diff.yml +0 -182
- package/dist/tools/definitions/definitions/std/analysis/analyze-git-diff.yml +0 -70
- package/dist/tools/definitions/definitions/std/analysis/analyze-impact.yml +0 -78
- package/dist/tools/definitions/definitions/std/analysis/analyze-requirements.yml +0 -105
- package/dist/tools/definitions/definitions/std/analysis/brainstorm-options.yml +0 -106
- package/dist/tools/definitions/definitions/std/analysis/build-graph.yml +0 -154
- package/dist/tools/definitions/definitions/std/analysis/clarify-requirements.yml +0 -90
- package/dist/tools/definitions/definitions/std/analysis/detect-context.yml +0 -109
- package/dist/tools/definitions/definitions/std/analysis/detect-layers.yml +0 -125
- package/dist/tools/definitions/definitions/std/analysis/generate-tour.yml +0 -102
- package/dist/tools/definitions/definitions/std/analysis/search-enhance.yml +0 -105
- package/dist/tools/definitions/definitions/std/backlog/add.yml +0 -51
- package/dist/tools/definitions/definitions/std/backlog/decide.yml +0 -39
- package/dist/tools/definitions/definitions/std/backlog/github-sync.yml +0 -161
- package/dist/tools/definitions/definitions/std/backlog/list.yml +0 -53
- package/dist/tools/definitions/definitions/std/backlog/load.yml +0 -46
- package/dist/tools/definitions/definitions/std/backlog/resolve.yml +0 -37
- package/dist/tools/definitions/definitions/std/backlog/update.yml +0 -42
- package/dist/tools/definitions/definitions/std/bugfix/diagnose.yml +0 -68
- package/dist/tools/definitions/definitions/std/bugfix/fix.yml +0 -66
- package/dist/tools/definitions/definitions/std/bugfix/verify.yml +0 -69
- package/dist/tools/definitions/definitions/std/constraint/check-decomposition.yml +0 -103
- package/dist/tools/definitions/definitions/std/constraint/check-feature-list.yml +0 -77
- package/dist/tools/definitions/definitions/std/constraint/check-progress.yml +0 -97
- package/dist/tools/definitions/definitions/std/constraint/generate-report.yml +0 -147
- package/dist/tools/definitions/definitions/std/deploy/commit-push.yml +0 -33
- package/dist/tools/definitions/definitions/std/deploy/deploy-backend.yml +0 -37
- package/dist/tools/definitions/definitions/std/deploy/deploy-frontend.yml +0 -37
- package/dist/tools/definitions/definitions/std/deploy/rollback.yml +0 -148
- package/dist/tools/definitions/definitions/std/design/analyze-architecture-impact.yml +0 -113
- package/dist/tools/definitions/definitions/std/design/design-api.yml +0 -55
- package/dist/tools/definitions/definitions/std/design/design-architecture.yml +0 -97
- package/dist/tools/definitions/definitions/std/design/design-db.yml +0 -81
- package/dist/tools/definitions/definitions/std/design/generate-spec.yml +0 -182
- package/dist/tools/definitions/definitions/std/development/develop-api.yml +0 -85
- package/dist/tools/definitions/definitions/std/development/develop-backend.yml +0 -88
- package/dist/tools/definitions/definitions/std/development/develop-frontend.yml +0 -87
- package/dist/tools/definitions/definitions/std/development/develop-shared-types.yml +0 -74
- package/dist/tools/definitions/definitions/std/development/develop-task.yml +0 -122
- package/dist/tools/definitions/definitions/std/development/develop-tests.yml +0 -76
- package/dist/tools/definitions/definitions/std/development/execute-batch.yml +0 -152
- package/dist/tools/definitions/definitions/std/development/fix-issues.yml +0 -100
- package/dist/tools/definitions/definitions/std/development/implement-task.yml +0 -124
- package/dist/tools/definitions/definitions/std/development/review-fix-cycle.yml +0 -232
- package/dist/tools/definitions/definitions/std/evolution/implement.yml +0 -125
- package/dist/tools/definitions/definitions/std/evolution/prioritize.yml +0 -112
- package/dist/tools/definitions/definitions/std/evolution/report-gap.yml +0 -166
- package/dist/tools/definitions/definitions/std/file/read.yml +0 -21
- package/dist/tools/definitions/definitions/std/governance/aggregate-opinions.sh +0 -201
- package/dist/tools/definitions/definitions/std/governance/aggregate-opinions.yml +0 -79
- package/dist/tools/definitions/definitions/std/governance/audit-task.yml +0 -178
- package/dist/tools/definitions/definitions/std/governance/cast-vote.yml +0 -129
- package/dist/tools/definitions/definitions/std/governance/collect-issues.yml +0 -16
- package/dist/tools/definitions/definitions/std/governance/create-signed-document.yml +0 -23
- package/dist/tools/definitions/definitions/std/governance/create-voting-session.yml +0 -101
- package/dist/tools/definitions/definitions/std/governance/define-stance.sh +0 -243
- package/dist/tools/definitions/definitions/std/governance/define-stance.yml +0 -82
- package/dist/tools/definitions/definitions/std/governance/generate-review-report.yml +0 -23
- package/dist/tools/definitions/definitions/std/governance/impeach.yml +0 -179
- package/dist/tools/definitions/definitions/std/governance/multi-stance-review.yml +0 -154
- package/dist/tools/definitions/definitions/std/governance/prepare-artifact.yml +0 -20
- package/dist/tools/definitions/definitions/std/governance/review-spec-approval.yml +0 -262
- package/dist/tools/definitions/definitions/std/governance/rollback.yml +0 -186
- package/dist/tools/definitions/definitions/std/governance/stance-review.yml +0 -149
- package/dist/tools/definitions/definitions/std/governance/track-effect.yml +0 -199
- package/dist/tools/definitions/definitions/std/governance/vote-tally.yml +0 -144
- package/dist/tools/definitions/definitions/std/patch/execute.yml +0 -51
- package/dist/tools/definitions/definitions/std/planning/generate-tasks.yml +0 -36
- package/dist/tools/definitions/definitions/std/planning/load-tasks.yml +0 -44
- package/dist/tools/definitions/definitions/std/planning/split-batch.yml +0 -481
- package/dist/tools/definitions/definitions/std/planning/split-tasks.yml +0 -359
- package/dist/tools/definitions/definitions/std/planning/update-tasks.yml +0 -51
- package/dist/tools/definitions/definitions/std/planning/validate-tasks.yml +0 -46
- package/dist/tools/definitions/definitions/std/project/decide-next-workflow.yml +0 -38
- package/dist/tools/definitions/definitions/std/project/load-state.yml +0 -31
- package/dist/tools/definitions/definitions/std/project/save-state.yml +0 -32
- package/dist/tools/definitions/definitions/std/quality/check-quality.yml +0 -241
- package/dist/tools/definitions/definitions/std/quality/debug-systematic.yml +0 -163
- package/dist/tools/definitions/definitions/std/quality/handle-feedback.yml +0 -108
- package/dist/tools/definitions/definitions/std/quality/review-code.yml +0 -128
- package/dist/tools/definitions/definitions/std/quality/review-spec.yml +0 -140
- package/dist/tools/definitions/definitions/std/quality/review-task.yml +0 -190
- package/dist/tools/definitions/definitions/std/quality/run-tests.yml +0 -80
- package/dist/tools/definitions/definitions/std/quick/analyze.yml +0 -56
- package/dist/tools/definitions/definitions/std/quick/implement.yml +0 -67
- package/dist/tools/definitions/definitions/std/quick/verify.yml +0 -71
- package/dist/tools/definitions/definitions/std/verification/verify_completion.yml +0 -113
- package/dist/tools/definitions/definitions/std/verification/wait-condition.yml +0 -107
- package/dist/types/iron-law.d.ts +0 -25
- package/dist/types/iron-law.d.ts.map +0 -1
- package/dist/types/iron-law.js +0 -16
- package/dist/types/iron-law.js.map +0 -1
- package/src/cli/commands/sync-docs.ts +0 -1175
- package/src/constraints/index.ts +0 -3
- package/src/core/constraints/__tests__/prompt-injection.test.ts +0 -89
- package/src/core/constraints/doc-freshness/auto-fix.ts +0 -69
- package/src/core/constraints/prompt-injection.ts +0 -73
- package/src/core/spec/index.ts +0 -7
- package/src/governance/CONTEXT.md +0 -22
- package/src/governance/__tests__/executor.test.ts +0 -249
- package/src/governance/executor.ts +0 -229
- package/src/governance/index.ts +0 -13
- package/src/governance/types.ts +0 -53
- package/src/tools/core/package.json +0 -7
- package/src/tools/core/pnpm-lock.yaml +0 -232
- package/src/types/iron-law.ts +0 -50
|
@@ -12,12 +12,20 @@
|
|
|
12
12
|
*
|
|
13
13
|
* 模型状态: ~/.claude/user-model-state.json
|
|
14
14
|
* 画像输出: ~/.claude/projects/-root-projects/memory/user_profile.md
|
|
15
|
+
*
|
|
16
|
+
* 工单 19-C:transcript 解析/纠正模式/相似度收敛至 cli/session-mining/。
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
19
|
import chalk from 'chalk';
|
|
18
20
|
import * as fs from 'fs';
|
|
19
21
|
import * as path from 'path';
|
|
20
22
|
import * as os from 'os';
|
|
23
|
+
import {
|
|
24
|
+
readTranscriptSessions,
|
|
25
|
+
extractCorrectionMatches,
|
|
26
|
+
cleanCorrectionConcept,
|
|
27
|
+
jaccardChinese,
|
|
28
|
+
} from '../session-mining';
|
|
21
29
|
|
|
22
30
|
export interface UpdateUserModelOptions {
|
|
23
31
|
json?: boolean;
|
|
@@ -130,56 +138,17 @@ interface SimpleSession {
|
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
function findNewSessions(dir: string, processed: string[]): SimpleSession[] {
|
|
133
|
-
const sessions
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const toolCalls: string[] = [];
|
|
145
|
-
|
|
146
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
147
|
-
for (const line of content.split('\n')) {
|
|
148
|
-
if (!line.trim()) continue;
|
|
149
|
-
try {
|
|
150
|
-
const entry = JSON.parse(line);
|
|
151
|
-
const msg = entry.message;
|
|
152
|
-
if (msg?.role && msg.content) {
|
|
153
|
-
const text = typeof msg.content === 'string'
|
|
154
|
-
? msg.content
|
|
155
|
-
: Array.isArray(msg.content)
|
|
156
|
-
? msg.content.filter((b: any) => b.type === 'text').map((b: any) => b.text).join(' ')
|
|
157
|
-
: '';
|
|
158
|
-
turns.push({ role: msg.role, content: text });
|
|
159
|
-
}
|
|
160
|
-
// Track tool calls from assistant messages
|
|
161
|
-
if (msg?.role === 'assistant' && Array.isArray(msg.content)) {
|
|
162
|
-
for (const block of msg.content) {
|
|
163
|
-
if (block.type === 'tool_use' && block.name) {
|
|
164
|
-
toolCalls.push(block.name);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
} catch {}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (turns.length > 0) {
|
|
172
|
-
sessions.push({
|
|
173
|
-
id: sessionId.slice(0, 40),
|
|
174
|
-
date: stat.mtime.toISOString().slice(0, 10),
|
|
175
|
-
userText: turns.filter(t => t.role === 'user').map(t => t.content).join('\n'),
|
|
176
|
-
assistantText: turns.filter(t => t.role === 'assistant').map(t => t.content).join('\n'),
|
|
177
|
-
toolCalls: [...new Set(toolCalls)],
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
} catch {}
|
|
182
|
-
return sessions.sort((a, b) => a.date.localeCompare(b.date));
|
|
141
|
+
const sessions = readTranscriptSessions(dir)
|
|
142
|
+
.filter(s => !processed.includes(s.id))
|
|
143
|
+
.sort((a, b) => a.date.localeCompare(b.date));
|
|
144
|
+
|
|
145
|
+
return sessions.map(s => ({
|
|
146
|
+
id: s.id,
|
|
147
|
+
date: s.date,
|
|
148
|
+
userText: s.turns.filter(t => t.role === 'user').map(t => t.content).join('\n'),
|
|
149
|
+
assistantText: s.turns.filter(t => t.role === 'assistant').map(t => t.content).join('\n'),
|
|
150
|
+
toolCalls: s.toolCalls,
|
|
151
|
+
}));
|
|
183
152
|
}
|
|
184
153
|
|
|
185
154
|
// ── Signal extraction ──
|
|
@@ -196,33 +165,11 @@ interface SessionSignals {
|
|
|
196
165
|
knowledgeCaptured: boolean; // Write to knowledge-docs
|
|
197
166
|
}
|
|
198
167
|
|
|
199
|
-
// ── Correction clustering (from analyze-sessions) ──
|
|
200
|
-
|
|
201
168
|
function extractCorrectionConcepts(userText: string): string[] {
|
|
202
|
-
const correctionPatterns = [
|
|
203
|
-
/你(?:又|还是)(?:在)?(?:犯|忘|没|不).{0,30}?[了]?/g,
|
|
204
|
-
/我不是(?:说|让|让做|讲)[了过]?.{0,50}?[了吗??]?/g,
|
|
205
|
-
/怎么(?:又|还|老)(?:是|在)?.{0,30}?[了]?/g,
|
|
206
|
-
/我(?:一直|反复|总是)(?:在|说|强调)?.{0,30}?[了]?/g,
|
|
207
|
-
/老(?:是|在|犯|忘)(?:了)?.{0,20}?[了]?/g,
|
|
208
|
-
/这(?:个|种)(?:问题|模式|错误).{0,20}?/g,
|
|
209
|
-
/(?:补上|加上|记上|修复).{0,10}?[了吗??]?/g,
|
|
210
|
-
/(?:沉淀|监控|日志|记录).{0,5}?[了吗??]?/g,
|
|
211
|
-
];
|
|
212
169
|
const concepts: string[] = [];
|
|
213
|
-
for (const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
while ((m = pat.exec(userText)) !== null) {
|
|
217
|
-
const cleaned = m[0]
|
|
218
|
-
.replace(/你(?:又|还是)(?:在)?(?:犯|忘|没|不)/g, '')
|
|
219
|
-
.replace(/我不是(?:说|让|让做|讲)[了过]?/g, '')
|
|
220
|
-
.replace(/怎么(?:又|还|老)(?:是|在)?/g, '')
|
|
221
|
-
.replace(/我(?:一直|反复|总是)(?:在|说|强调)?/g, '')
|
|
222
|
-
.replace(/[,。!?、;:""''()\s]+/g, '')
|
|
223
|
-
.trim();
|
|
224
|
-
if (cleaned.length >= 4 && cleaned.length <= 60) concepts.push(cleaned);
|
|
225
|
-
}
|
|
170
|
+
for (const sentence of extractCorrectionMatches(userText)) {
|
|
171
|
+
const cleaned = cleanCorrectionConcept(sentence);
|
|
172
|
+
if (cleaned.length >= 4 && cleaned.length <= 60) concepts.push(cleaned);
|
|
226
173
|
}
|
|
227
174
|
return [...new Set(concepts)];
|
|
228
175
|
}
|
|
@@ -265,17 +212,6 @@ function clusterConcepts(
|
|
|
265
212
|
return merged;
|
|
266
213
|
}
|
|
267
214
|
|
|
268
|
-
function jaccardChinese(a: string, b: string): number {
|
|
269
|
-
const charsA = new Set(a.split('').filter(c => /[\u4e00-\u9fff]/.test(c)));
|
|
270
|
-
const charsB = new Set(b.split('').filter(c => /[\u4e00-\u9fff]/.test(c)));
|
|
271
|
-
if (charsA.size === 0 || charsB.size === 0) return 0;
|
|
272
|
-
const intersection = new Set([...charsA].filter(x => charsB.has(x)));
|
|
273
|
-
const union = new Set([...charsA, ...charsB]);
|
|
274
|
-
return intersection.size / union.size;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// ── Old ──
|
|
278
|
-
|
|
279
215
|
function extractSignals(sessions: SimpleSession[]): SessionSignals[] {
|
|
280
216
|
return sessions.map(s => {
|
|
281
217
|
const correctionPhrases = extractCorrectionConcepts(s.userText);
|
|
@@ -430,7 +366,7 @@ function applySignals(state: ModelState, signals: SessionSignals[], mergedConcep
|
|
|
430
366
|
}
|
|
431
367
|
|
|
432
368
|
// Detect falling/stable shifts
|
|
433
|
-
for (const [
|
|
369
|
+
for (const [, p] of Object.entries(state.patterns)) {
|
|
434
370
|
if (p.trend === 'stable' && p.lastSeen < new Date(Date.now() - 7 * 86400000).toISOString().slice(0, 10)) {
|
|
435
371
|
p.trend = 'falling';
|
|
436
372
|
}
|
|
@@ -10,7 +10,6 @@ import * as path from 'path';
|
|
|
10
10
|
import * as yaml from 'js-yaml';
|
|
11
11
|
import { CheckpointValidator } from '../../core/validators/checkpoint';
|
|
12
12
|
import type { Checkpoint, CheckpointContext } from '../../types/checkpoint';
|
|
13
|
-
import { detectSourceRoots } from '../../utils/detect-source-roots';
|
|
14
13
|
|
|
15
14
|
export interface ValidateOptions {
|
|
16
15
|
/** 检查点文件路径 */
|
|
@@ -96,9 +95,8 @@ export async function validate(options: ValidateOptions): Promise<void> {
|
|
|
96
95
|
|
|
97
96
|
if (failed > 0) {
|
|
98
97
|
console.log(chalk.red(`\n🛑 ${failed} 个检查点未通过`));
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
98
|
+
// 工单 23:门控语义——检查点失败一律非零退出(此前仅 --strict 退出,钩子/CI 形同虚设)
|
|
99
|
+
process.exit(1);
|
|
102
100
|
} else {
|
|
103
101
|
console.log(chalk.green('\n✅ 所有检查点验证通过'));
|
|
104
102
|
}
|
|
@@ -106,6 +104,9 @@ export async function validate(options: ValidateOptions): Promise<void> {
|
|
|
106
104
|
|
|
107
105
|
/**
|
|
108
106
|
* 默认检查点列表(供 init 和 upgrade 共用)
|
|
107
|
+
*
|
|
108
|
+
* 注:no-console 检查点已移除(工单 23/24)——CLI 产品 src/ 必然有合法 console 输出,
|
|
109
|
+
* 且旧配置 expected:'' 语义恒错;output_* 族修复为真正执行 config.command 后该检查会恒失败。
|
|
109
110
|
*/
|
|
110
111
|
export const DEFAULT_CHECKPOINTS: Checkpoint[] = [
|
|
111
112
|
{
|
|
@@ -132,21 +133,6 @@ export const DEFAULT_CHECKPOINTS: Checkpoint[] = [
|
|
|
132
133
|
},
|
|
133
134
|
],
|
|
134
135
|
},
|
|
135
|
-
{
|
|
136
|
-
id: 'no-console',
|
|
137
|
-
name: '无 console.log',
|
|
138
|
-
checks: [
|
|
139
|
-
{
|
|
140
|
-
id: 'check-console',
|
|
141
|
-
type: 'output_not_contains',
|
|
142
|
-
config: {
|
|
143
|
-
command: 'grep -r "console.log" src/ || true',
|
|
144
|
-
expected: '',
|
|
145
|
-
},
|
|
146
|
-
message: '源代码中不应包含 console.log',
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
},
|
|
150
136
|
];
|
|
151
137
|
|
|
152
138
|
/**
|
|
@@ -167,27 +153,7 @@ export async function createExampleCheckpoint(projectPath: string): Promise<void
|
|
|
167
153
|
|
|
168
154
|
await fs.mkdir(dir, { recursive: true });
|
|
169
155
|
|
|
170
|
-
|
|
171
|
-
const roots = detectSourceRoots(projectPath);
|
|
172
|
-
let checkpoints = DEFAULT_CHECKPOINTS;
|
|
173
|
-
if (roots.length > 0) {
|
|
174
|
-
checkpoints = DEFAULT_CHECKPOINTS.map(cp => {
|
|
175
|
-
if (cp.id === 'no-console') {
|
|
176
|
-
return {
|
|
177
|
-
...cp,
|
|
178
|
-
checks: cp.checks.map(c => {
|
|
179
|
-
if (c.id === 'check-console') {
|
|
180
|
-
return { ...c, config: { command: `grep -r "console.log" ${roots.join(' ')} || true` } };
|
|
181
|
-
}
|
|
182
|
-
return c;
|
|
183
|
-
}),
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
return cp;
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const content = yaml.dump({ checkpoints }, { indent: 2 });
|
|
156
|
+
const content = yaml.dump({ checkpoints: DEFAULT_CHECKPOINTS }, { indent: 2 });
|
|
191
157
|
await fs.writeFile(filePath, content, 'utf-8');
|
|
192
158
|
|
|
193
159
|
console.log(chalk.green(`✅ 已创建示例检查点文件: ${filePath}`));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 纠正信号模式表与概念清洗(工单 19-C)
|
|
3
|
+
*
|
|
4
|
+
* 合并 analyze-sessions 与 update-user-model 两份几乎相同的模式表,
|
|
5
|
+
* 采用较宽窗口(update-user-model 版本)作为唯一实现。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** 用户纠正/重复强调语句的匹配模式(两命令合并后的超集,取较宽窗口) */
|
|
9
|
+
export const CORRECTION_PATTERNS: RegExp[] = [
|
|
10
|
+
/你(?:又|还是)(?:在)?(?:犯|忘|没|不).{0,30}?[了]?/g,
|
|
11
|
+
/我不是(?:说|让|让做|讲)[了过]?.{0,50}?[了吗??]?/g,
|
|
12
|
+
/怎么(?:又|还|老)(?:是|在)?.{0,30}?[了]?/g,
|
|
13
|
+
/我(?:一直|反复|总是)(?:在|说|强调)?.{0,30}?[了]?/g,
|
|
14
|
+
/老(?:是|在|犯|忘)(?:了)?.{0,20}?[了]?/g,
|
|
15
|
+
/这(?:个|种)(?:问题|模式|错误).{0,20}?[.。!]?/g,
|
|
16
|
+
/(?:第[一二三四五六七八九十\d]+次|反复|重复)(?:说|提醒|强调).{0,20}?/g,
|
|
17
|
+
/不(?:要|能|想|愿意).{0,20}?老.{0,10}?[了]?/g,
|
|
18
|
+
/(?:补上|加上|记上|修复).{0,10}?[了吗??]?/g,
|
|
19
|
+
/(?:沉淀|监控|日志|记录).{0,5}?[了吗??]?/g,
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
/** 纠正语句前缀(提取概念时剥离) */
|
|
23
|
+
const CORRECTION_PREFIX_STRIP: RegExp[] = [
|
|
24
|
+
/你(?:又|还是)(?:在)?(?:犯|忘|没|不)/g,
|
|
25
|
+
/我不是(?:说|让|让做|讲)[了过]?/g,
|
|
26
|
+
/怎么(?:又|还|老)(?:是|在)?/g,
|
|
27
|
+
/我(?:一直|反复|总是)(?:在|说|强调)?/g,
|
|
28
|
+
/老(?:是|在|犯|忘)(?:了)?/g,
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 从纠正语句中提取概念:剥离纠正前缀与标点
|
|
33
|
+
*/
|
|
34
|
+
export function cleanCorrectionConcept(sentence: string): string {
|
|
35
|
+
let cleaned = sentence;
|
|
36
|
+
for (const re of CORRECTION_PREFIX_STRIP) {
|
|
37
|
+
re.lastIndex = 0;
|
|
38
|
+
cleaned = cleaned.replace(re, '');
|
|
39
|
+
}
|
|
40
|
+
return cleaned.replace(/[,。!?、;:""''()\s]+/g, '').trim();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 用模式表在文本中抽取纠正语句(去重)
|
|
45
|
+
*/
|
|
46
|
+
export function extractCorrectionMatches(text: string): string[] {
|
|
47
|
+
const matches: string[] = [];
|
|
48
|
+
for (const pattern of CORRECTION_PATTERNS) {
|
|
49
|
+
pattern.lastIndex = 0;
|
|
50
|
+
let match: RegExpExecArray | null;
|
|
51
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
52
|
+
matches.push(match[0].trim());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return matches;
|
|
56
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 会话挖掘共享层(工单 19-C)
|
|
3
|
+
*
|
|
4
|
+
* update-user-model 与 analyze-sessions 两个命令此前各自维护一份
|
|
5
|
+
* transcript 解析 / 纠正模式 / 分词与相似度实现,收敛到本目录:
|
|
6
|
+
* - transcript.ts Claude Code transcript(.jsonl)读取
|
|
7
|
+
* - corrections.ts 纠正信号模式表与概念清洗
|
|
8
|
+
* - text.ts 分词 / 停用词 / Jaccard / 文本清洗
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export * from './transcript';
|
|
12
|
+
export * from './corrections';
|
|
13
|
+
export * from './text';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 分词 / 停用词 / 相似度 / 文本清洗(工单 19-C)
|
|
3
|
+
*
|
|
4
|
+
* 合并 analyze-sessions 与 update-user-model 的重复实现。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** N-gram 停用词表(中英) */
|
|
8
|
+
export const STOP_WORDS = new Set([
|
|
9
|
+
'的', '了', '在', '是', '我', '有', '和', '就', '不', '人', '都', '一',
|
|
10
|
+
'一个', '上', '也', '很', '到', '说', '要', '去', '你', '会', '着',
|
|
11
|
+
'没有', '看', '好', '自己', '这', '他', '她', '它', '们', '那',
|
|
12
|
+
'the', 'a', 'an', 'is', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
13
|
+
'have', 'has', 'had', 'do', 'does', 'did', 'will', 'would', 'could',
|
|
14
|
+
'should', 'may', 'might', 'can', 'shall', 'to', 'of', 'in', 'for',
|
|
15
|
+
'on', 'with', 'at', 'by', 'from', 'as', 'into', 'through', 'during',
|
|
16
|
+
'before', 'after', 'above', 'below', 'between', 'under', 'again',
|
|
17
|
+
'further', 'then', 'once', 'here', 'there', 'when', 'where', 'why',
|
|
18
|
+
'how', 'all', 'both', 'each', 'few', 'more', 'most', 'other', 'some',
|
|
19
|
+
'such', 'only', 'own', 'same', 'so', 'than', 'too', 'very', 'just',
|
|
20
|
+
'因为', '所以', '但是', '而且', '如果', '虽然', '可以', '这个', '那个',
|
|
21
|
+
'什么', '怎么', '哪', '吗', '吧', '呢', '啊', '嗯', '哦',
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const CN_CHAR = /[\u4e00-\u9fff\u3400-\u4dbf]/;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 中英文混合分词:中文产出 bigram/trigram(短序列保留整体),
|
|
28
|
+
* 连续的拉丁/数字/路径字符作为整体 token。
|
|
29
|
+
*/
|
|
30
|
+
export function tokenize(text: string): string[] {
|
|
31
|
+
const tokens: string[] = [];
|
|
32
|
+
let current = '';
|
|
33
|
+
|
|
34
|
+
for (const char of text) {
|
|
35
|
+
if (CN_CHAR.test(char)) {
|
|
36
|
+
current += char;
|
|
37
|
+
} else if (/[a-zA-Z0-9_\-/.]/.test(char)) {
|
|
38
|
+
current += char;
|
|
39
|
+
} else {
|
|
40
|
+
pushToken(current, tokens);
|
|
41
|
+
current = '';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
pushToken(current, tokens);
|
|
45
|
+
|
|
46
|
+
return tokens;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function pushToken(current: string, tokens: string[]): void {
|
|
50
|
+
if (current.length < 2) return;
|
|
51
|
+
if (CN_CHAR.test(current)) {
|
|
52
|
+
for (let i = 0; i <= current.length - 2; i++) {
|
|
53
|
+
tokens.push(current.slice(i, i + 2));
|
|
54
|
+
}
|
|
55
|
+
for (let i = 0; i <= current.length - 3; i++) {
|
|
56
|
+
tokens.push(current.slice(i, i + 3));
|
|
57
|
+
}
|
|
58
|
+
if (current.length <= 6) tokens.push(current);
|
|
59
|
+
} else {
|
|
60
|
+
tokens.push(current);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 基于 tokenize 的 Jaccard 相似度
|
|
66
|
+
*/
|
|
67
|
+
export function jaccardSimilarity(a: string, b: string): number {
|
|
68
|
+
const setA = new Set(tokenize(a));
|
|
69
|
+
const setB = new Set(tokenize(b));
|
|
70
|
+
const intersection = new Set([...setA].filter(x => setB.has(x)));
|
|
71
|
+
const union = new Set([...setA, ...setB]);
|
|
72
|
+
return union.size === 0 ? 0 : intersection.size / union.size;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 仅取汉字字符集的 Jaccard 相似度(概念聚类用)
|
|
77
|
+
*/
|
|
78
|
+
export function jaccardChinese(a: string, b: string): number {
|
|
79
|
+
const charsA = new Set(a.split('').filter(c => /[\u4e00-\u9fff]/.test(c)));
|
|
80
|
+
const charsB = new Set(b.split('').filter(c => /[\u4e00-\u9fff]/.test(c)));
|
|
81
|
+
if (charsA.size === 0 || charsB.size === 0) return 0;
|
|
82
|
+
const intersection = new Set([...charsA].filter(x => charsB.has(x)));
|
|
83
|
+
const union = new Set([...charsA, ...charsB]);
|
|
84
|
+
return intersection.size / union.size;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 剥离代码块 / 行内代码 / JSON 片段,保留自然语言
|
|
89
|
+
*/
|
|
90
|
+
export function stripCodeBlocks(text: string): string {
|
|
91
|
+
return text
|
|
92
|
+
.replace(/```[\s\S]*?```/g, '')
|
|
93
|
+
.replace(/`[^`]+`/g, '')
|
|
94
|
+
.replace(/\{[^{}]*"[^"]+"\s*:\s*"[^"]*"[^}]*\}/g, '')
|
|
95
|
+
.replace(/\[[\s\S]*?\]/g, '')
|
|
96
|
+
.replace(/\\n/g, ' ')
|
|
97
|
+
.replace(/[{}[\]"':,\\]+/g, ' ');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** 是否纯标点/空白 */
|
|
101
|
+
export function isPunctuation(str: string): boolean {
|
|
102
|
+
return /^[,。!?、;:""''()\[\]【】「」『』《》〈〉\s]+$/.test(str);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** 是否含语义内容(汉字,或 ≥7 字符的合法英文标识词) */
|
|
106
|
+
export function hasSemanticContent(phrase: string): boolean {
|
|
107
|
+
if (/[\u4e00-\u9fff]/.test(phrase)) return true;
|
|
108
|
+
if (phrase.length >= 7 && /^[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z]$/.test(phrase)) return true;
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** 是否代码噪声(短拉丁片段 / 常见 JSON 字段名碎片) */
|
|
113
|
+
export function isCodeNoise(phrase: string): boolean {
|
|
114
|
+
if (!/[\u4e00-\u9fff]/.test(phrase) && phrase.length <= 6) return true;
|
|
115
|
+
if (/^(?:clla|cood|odde|oppe|laaw|peen|enne|ennc|ddec|deco|ecod|code|type|role|name|text|file|path|tool|user|session)$/i.test(phrase)) return true;
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code transcript(.jsonl)读取(工单 19-C)
|
|
3
|
+
*
|
|
4
|
+
* 原 analyze-sessions.findSessions 与 update-user-model.findNewSessions
|
|
5
|
+
* 各持一份解析逻辑,收敛于此。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
|
|
11
|
+
export interface MinedTurn {
|
|
12
|
+
role: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface MinedSession {
|
|
17
|
+
/** 会话 ID(文件名去掉 .jsonl,截断至 40 字符) */
|
|
18
|
+
id: string;
|
|
19
|
+
/** 文件修改日期(YYYY-MM-DD) */
|
|
20
|
+
date: string;
|
|
21
|
+
/** 修改时间戳(毫秒) */
|
|
22
|
+
mtimeMs: number;
|
|
23
|
+
turns: MinedTurn[];
|
|
24
|
+
/** 出现过的工具调用名(去重,保持出现顺序) */
|
|
25
|
+
toolCalls: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function extractText(content: unknown): string {
|
|
29
|
+
if (typeof content === 'string') return content;
|
|
30
|
+
if (Array.isArray(content)) {
|
|
31
|
+
return content
|
|
32
|
+
.filter((b: any) => b.type === 'text')
|
|
33
|
+
.map((b: any) => b.text)
|
|
34
|
+
.join(' ');
|
|
35
|
+
}
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 扫描目录下的 .jsonl transcript 文件
|
|
41
|
+
*
|
|
42
|
+
* 不可读/损坏的行静默跳过(与原实现一致)。
|
|
43
|
+
*/
|
|
44
|
+
export function readTranscriptSessions(dir: string): MinedSession[] {
|
|
45
|
+
const sessions: MinedSession[] = [];
|
|
46
|
+
|
|
47
|
+
let files: string[];
|
|
48
|
+
try {
|
|
49
|
+
files = fs.readdirSync(dir);
|
|
50
|
+
} catch {
|
|
51
|
+
return sessions;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const file of files) {
|
|
55
|
+
if (!file.endsWith('.jsonl')) continue;
|
|
56
|
+
const filePath = path.join(dir, file);
|
|
57
|
+
|
|
58
|
+
let stat: fs.Stats;
|
|
59
|
+
try {
|
|
60
|
+
stat = fs.statSync(filePath);
|
|
61
|
+
} catch {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const turns: MinedTurn[] = [];
|
|
66
|
+
const toolCalls: string[] = [];
|
|
67
|
+
|
|
68
|
+
let content: string;
|
|
69
|
+
try {
|
|
70
|
+
content = fs.readFileSync(filePath, 'utf-8');
|
|
71
|
+
} catch {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
for (const line of content.split('\n')) {
|
|
76
|
+
if (!line.trim()) continue;
|
|
77
|
+
try {
|
|
78
|
+
const entry = JSON.parse(line);
|
|
79
|
+
const msg = entry.message;
|
|
80
|
+
if (msg?.role && (msg.content || entry.type === 'user')) {
|
|
81
|
+
turns.push({ role: msg.role, content: extractText(msg.content) });
|
|
82
|
+
}
|
|
83
|
+
if (msg?.role === 'assistant' && Array.isArray(msg.content)) {
|
|
84
|
+
for (const block of msg.content) {
|
|
85
|
+
if (block.type === 'tool_use' && block.name) {
|
|
86
|
+
toolCalls.push(block.name);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
// 损坏行跳过
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (turns.length > 0) {
|
|
96
|
+
sessions.push({
|
|
97
|
+
id: file.replace('.jsonl', '').slice(0, 40),
|
|
98
|
+
date: stat.mtime.toISOString().slice(0, 10),
|
|
99
|
+
mtimeMs: stat.mtimeMs,
|
|
100
|
+
turns,
|
|
101
|
+
toolCalls: [...new Set(toolCalls)],
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return sessions;
|
|
107
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { describe, it, expect, beforeEach } from '@jest/globals';
|
|
6
6
|
import { ConstraintLifecycleRunner, type ExecutionResult } from '../lifecycle-runner';
|
|
7
7
|
import { ConstraintRegistry } from '../registry';
|
|
8
|
-
import type { ConstraintProposal } from '../../monitoring
|
|
8
|
+
import type { ConstraintProposal } from '../../types/monitoring-types';
|
|
9
9
|
|
|
10
10
|
function makeProposal(overrides: Partial<ConstraintProposal> = {}): ConstraintProposal {
|
|
11
11
|
return {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { ConstraintRegistry } from './registry';
|
|
9
|
-
import type { ConstraintProposal } from '../monitoring
|
|
9
|
+
import type { ConstraintProposal } from '../types/monitoring-types';
|
|
10
10
|
import type { ConstraintLevel } from '../types/constraint';
|
|
11
11
|
import type { DeprecationSchedule } from './types';
|
|
12
12
|
|
|
@@ -81,7 +81,7 @@ export class SessionCompaction {
|
|
|
81
81
|
/**
|
|
82
82
|
* 中等压缩:结构化总结 + 保留最近 N 轮
|
|
83
83
|
*/
|
|
84
|
-
private summaryCompact(messages: SessionMessage[],
|
|
84
|
+
private summaryCompact(messages: SessionMessage[], _budget: number, originalTokens: number): CompactionResult {
|
|
85
85
|
const recentCount = Math.min(6, messages.length); // 保留最近 6 条
|
|
86
86
|
const recent = messages.slice(-recentCount);
|
|
87
87
|
const older = messages.slice(0, -recentCount);
|
|
@@ -111,7 +111,7 @@ export class SessionCompaction {
|
|
|
111
111
|
/**
|
|
112
112
|
* 重型压缩:checkpoint + 清空历史
|
|
113
113
|
*/
|
|
114
|
-
private checkpointCompact(messages: SessionMessage[],
|
|
114
|
+
private checkpointCompact(messages: SessionMessage[], _budget: number, originalTokens: number): CompactionResult {
|
|
115
115
|
const summary = this.generateStructuredSummary(messages);
|
|
116
116
|
|
|
117
117
|
const checkpointSessionMessage: SessionMessage = {
|
|
@@ -169,7 +169,6 @@ export class SessionCompaction {
|
|
|
169
169
|
* 如果 tool 结果被保留,对应的 tool 调用也要保留
|
|
170
170
|
*/
|
|
171
171
|
private preserveToolCallPairs(all: SessionMessage[], compacted: SessionMessage[]): SessionMessage[] {
|
|
172
|
-
const compactedIds = new Set(compacted.map(m => m.toolCallId).filter(Boolean));
|
|
173
172
|
const result: SessionMessage[] = [];
|
|
174
173
|
|
|
175
174
|
for (const msg of compacted) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { KnowledgeQuery } from '../knowledge/query';
|
|
9
9
|
import { TokenEstimator } from './token-budget';
|
|
10
|
-
import type { KnowledgeEntry,
|
|
10
|
+
import type { KnowledgeEntry, KnowledgeType } from '../knowledge/types';
|
|
11
11
|
import type { ContextSource } from './types';
|
|
12
12
|
|
|
13
13
|
export interface InjectionConfig {
|
|
@@ -77,7 +77,7 @@ export class ToolOutputBudget {
|
|
|
77
77
|
/**
|
|
78
78
|
* 应用预算策略
|
|
79
79
|
*/
|
|
80
|
-
applyBudget(output: string, strategy: OutputStrategy,
|
|
80
|
+
applyBudget(output: string, strategy: OutputStrategy, _totalBudget?: number): OutputApplyResult {
|
|
81
81
|
const originalTokens = TokenEstimator.estimateText(output);
|
|
82
82
|
|
|
83
83
|
switch (strategy) {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CAPABILITIES.md 表格解析(工单 19-B)
|
|
3
|
+
*
|
|
4
|
+
* 此前 checker.parseCapabilitiesFiles 与 sync-docs.parseCapabilitiesFiles
|
|
5
|
+
* 各持一份正则,收敛到此处。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
|
|
10
|
+
/** 匹配表格单元格中的源码文件条目(如 `src/foo.ts`、`foo.tsx`) */
|
|
11
|
+
const FILE_CELL_REGEX = /\|\s*([^|]+?\.(?:ts|tsx|js|jsx))\s*\|/g;
|
|
12
|
+
|
|
13
|
+
/** 仅匹配表格第二列的文件条目(checker 的历史语义:第一列为模块名,第二列为文件) */
|
|
14
|
+
const FILE_SECOND_COLUMN_REGEX = /^\|[^|]+\|\s*([^|]+?\.(?:ts|tsx|js|jsx))\s*\|/gm;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 匹配表格单元格中的目录条目(如 `agents/`)。
|
|
18
|
+
*
|
|
19
|
+
* 仅匹配纯路径样式的单元格(字母/数字/._/-/@ 与 / 组成、以 / 结尾),
|
|
20
|
+
* 否则以 / 结尾的散文描述(如 JSDoc 首行在 "gitRepo /" 处换行)会被误判为
|
|
21
|
+
* 目录条目,导致 --check 永远报「包含已删除的模块」不收敛(2026-08-04 studio PR #44)
|
|
22
|
+
*/
|
|
23
|
+
const DIR_CELL_REGEX = /\|\s*([\w][\w@./-]*\/)\s*\|/g;
|
|
24
|
+
|
|
25
|
+
export interface CapabilitiesParseOptions {
|
|
26
|
+
/** 是否同时收集目录条目(sync-docs 需要;checker 只做文件覆盖比对,不需要) */
|
|
27
|
+
includeDirs?: boolean;
|
|
28
|
+
/** 只取表格第二列的文件条目(checker 的历史严格语义),默认 false */
|
|
29
|
+
secondColumnOnly?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 从 CAPABILITIES.md 内容中提取表格列出的条目
|
|
34
|
+
*
|
|
35
|
+
* @param content markdown 内容
|
|
36
|
+
* @returns 文件路径原样 + (可选)目录条目,按出现顺序去重
|
|
37
|
+
*/
|
|
38
|
+
export function parseCapabilitiesEntries(content: string, options: CapabilitiesParseOptions = {}): string[] {
|
|
39
|
+
const { includeDirs = false, secondColumnOnly = false } = options;
|
|
40
|
+
const entries: string[] = [];
|
|
41
|
+
|
|
42
|
+
const fileRegex = secondColumnOnly ? FILE_SECOND_COLUMN_REGEX : FILE_CELL_REGEX;
|
|
43
|
+
let match: RegExpExecArray | null;
|
|
44
|
+
fileRegex.lastIndex = 0;
|
|
45
|
+
while ((match = fileRegex.exec(content)) !== null) {
|
|
46
|
+
const raw = match[1].trim();
|
|
47
|
+
if (!entries.includes(raw)) entries.push(raw);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (includeDirs) {
|
|
51
|
+
DIR_CELL_REGEX.lastIndex = 0;
|
|
52
|
+
while ((match = DIR_CELL_REGEX.exec(content)) !== null) {
|
|
53
|
+
const dir = match[1].trim();
|
|
54
|
+
if (!entries.includes(dir)) entries.push(dir);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return entries;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 读取并解析 CAPABILITIES.md;文件缺失/不可读时返回 []
|
|
63
|
+
*/
|
|
64
|
+
export function readCapabilitiesEntries(capabilitiesPath: string, options: CapabilitiesParseOptions = {}): string[] {
|
|
65
|
+
try {
|
|
66
|
+
return parseCapabilitiesEntries(fs.readFileSync(capabilitiesPath, 'utf-8'), options);
|
|
67
|
+
} catch {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
}
|