oh-my-knowledge 0.29.0 → 0.31.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/README.md +204 -25
- package/README.zh.md +204 -25
- package/dist/src/analysis/report-diagnostics.js +2 -0
- package/dist/src/analysis/report-diagnostics.js.map +1 -1
- package/dist/src/authoring/evolver.d.ts +32 -2
- package/dist/src/authoring/evolver.d.ts.map +1 -1
- package/dist/src/authoring/evolver.js +416 -52
- package/dist/src/authoring/evolver.js.map +1 -1
- package/dist/src/authoring/generator.d.ts +24 -23
- package/dist/src/authoring/generator.d.ts.map +1 -1
- package/dist/src/authoring/generator.js +637 -40
- package/dist/src/authoring/generator.js.map +1 -1
- package/dist/src/authoring/sample-fixer.d.ts +51 -0
- package/dist/src/authoring/sample-fixer.d.ts.map +1 -0
- package/dist/src/authoring/sample-fixer.js +213 -0
- package/dist/src/authoring/sample-fixer.js.map +1 -0
- package/dist/src/cli/commands/doctor.d.ts +25 -1
- package/dist/src/cli/commands/doctor.d.ts.map +1 -1
- package/dist/src/cli/commands/doctor.js +233 -124
- package/dist/src/cli/commands/doctor.js.map +1 -1
- package/dist/src/cli/commands/eval/gold/compare.d.ts +17 -0
- package/dist/src/cli/commands/eval/gold/compare.d.ts.map +1 -0
- package/dist/src/cli/commands/eval/gold/compare.js +91 -0
- package/dist/src/cli/commands/eval/gold/compare.js.map +1 -0
- package/dist/src/cli/commands/eval/gold/index.d.ts +9 -0
- package/dist/src/cli/commands/eval/gold/index.d.ts.map +1 -0
- package/dist/src/cli/commands/eval/gold/index.js +34 -0
- package/dist/src/cli/commands/eval/gold/index.js.map +1 -0
- package/dist/src/cli/commands/eval/gold/init.d.ts +11 -0
- package/dist/src/cli/commands/eval/gold/init.d.ts.map +1 -0
- package/dist/src/cli/commands/eval/gold/init.js +51 -0
- package/dist/src/cli/commands/eval/gold/init.js.map +1 -0
- package/dist/src/cli/commands/eval/gold/validate.d.ts +12 -0
- package/dist/src/cli/commands/eval/gold/validate.d.ts.map +1 -0
- package/dist/src/cli/commands/eval/gold/validate.js +46 -0
- package/dist/src/cli/commands/eval/gold/validate.js.map +1 -0
- package/dist/src/cli/commands/eval/index.d.ts +54 -0
- package/dist/src/cli/commands/eval/index.d.ts.map +1 -0
- package/dist/src/cli/commands/{eval-runner.js → eval/index.js} +216 -50
- package/dist/src/cli/commands/eval/index.js.map +1 -0
- package/dist/src/cli/commands/evolve.d.ts +36 -1
- package/dist/src/cli/commands/evolve.d.ts.map +1 -1
- package/dist/src/cli/commands/evolve.js +202 -41
- package/dist/src/cli/commands/evolve.js.map +1 -1
- package/dist/src/cli/commands/init.d.ts +15 -1
- package/dist/src/cli/commands/init.d.ts.map +1 -1
- package/dist/src/cli/commands/init.js +70 -28
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/observe/inbox.d.ts +23 -0
- package/dist/src/cli/commands/observe/inbox.d.ts.map +1 -0
- package/dist/src/cli/commands/observe/inbox.js +258 -0
- package/dist/src/cli/commands/observe/inbox.js.map +1 -0
- package/dist/src/cli/commands/observe/index.d.ts +22 -0
- package/dist/src/cli/commands/observe/index.d.ts.map +1 -0
- package/dist/src/cli/commands/observe/index.js +118 -0
- package/dist/src/cli/commands/observe/index.js.map +1 -0
- package/dist/src/cli/commands/observe/ingest.d.ts +13 -0
- package/dist/src/cli/commands/observe/ingest.d.ts.map +1 -0
- package/dist/src/cli/commands/observe/ingest.js +69 -0
- package/dist/src/cli/commands/observe/ingest.js.map +1 -0
- package/dist/src/cli/commands/observe/show.d.ts +13 -0
- package/dist/src/cli/commands/observe/show.d.ts.map +1 -0
- package/dist/src/cli/commands/observe/show.js +49 -0
- package/dist/src/cli/commands/observe/show.js.map +1 -0
- package/dist/src/cli/commands/sample.d.ts +37 -1
- package/dist/src/cli/commands/sample.d.ts.map +1 -1
- package/dist/src/cli/commands/sample.js +402 -35
- package/dist/src/cli/commands/sample.js.map +1 -1
- package/dist/src/cli/commands/skill-extract.d.ts +20 -0
- package/dist/src/cli/commands/skill-extract.d.ts.map +1 -0
- package/dist/src/cli/commands/skill-extract.js +84 -0
- package/dist/src/cli/commands/skill-extract.js.map +1 -0
- package/dist/src/cli/commands/studio.d.ts +22 -1
- package/dist/src/cli/commands/studio.d.ts.map +1 -1
- package/dist/src/cli/commands/studio.js +111 -37
- package/dist/src/cli/commands/studio.js.map +1 -1
- package/dist/src/cli/index.js +15 -47
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/lib/cli-exit.d.ts +16 -0
- package/dist/src/cli/lib/cli-exit.d.ts.map +1 -0
- package/dist/src/cli/lib/cli-exit.js +20 -0
- package/dist/src/cli/lib/cli-exit.js.map +1 -0
- package/dist/src/cli/lib/cmd-flags.d.ts +236 -0
- package/dist/src/cli/lib/cmd-flags.d.ts.map +1 -0
- package/dist/src/cli/lib/cmd-flags.js +46 -0
- package/dist/src/cli/lib/cmd-flags.js.map +1 -0
- package/dist/src/cli/{i18n-dict.d.ts → lib/i18n-dict.d.ts} +1 -1
- package/dist/src/cli/lib/i18n-dict.d.ts.map +1 -0
- package/dist/src/cli/{i18n-dict.js → lib/i18n-dict.js} +93 -260
- package/dist/src/cli/lib/i18n-dict.js.map +1 -0
- package/dist/src/cli/{i18n.d.ts → lib/i18n.d.ts} +11 -6
- package/dist/src/cli/lib/i18n.d.ts.map +1 -0
- package/dist/src/cli/{i18n.js → lib/i18n.js} +12 -7
- package/dist/src/cli/lib/i18n.js.map +1 -0
- package/dist/src/cli/{parse-run-config.d.ts → lib/parse-run-config.d.ts} +19 -8
- package/dist/src/cli/lib/parse-run-config.d.ts.map +1 -0
- package/dist/src/cli/{parse-run-config.js → lib/parse-run-config.js} +60 -58
- package/dist/src/cli/lib/parse-run-config.js.map +1 -0
- package/dist/src/cli/lib/progress.d.ts.map +1 -0
- package/dist/src/cli/lib/progress.js.map +1 -0
- package/dist/src/cli/{run-tally.d.ts → lib/run-tally.d.ts} +1 -1
- package/dist/src/cli/lib/run-tally.d.ts.map +1 -0
- package/dist/src/cli/lib/run-tally.js.map +1 -0
- package/dist/src/cli/{commands/_shared.d.ts → lib/shared.d.ts} +2 -2
- package/dist/src/cli/lib/shared.d.ts.map +1 -0
- package/dist/src/cli/{commands/_shared.js → lib/shared.js} +3 -3
- package/dist/src/cli/lib/shared.js.map +1 -0
- package/dist/src/cli/lib/update-check.d.ts.map +1 -0
- package/dist/src/cli/lib/update-check.js.map +1 -0
- package/dist/src/cli/oclif/base-command.d.ts +8 -0
- package/dist/src/cli/oclif/base-command.d.ts.map +1 -0
- package/dist/src/cli/oclif/base-command.js +27 -0
- package/dist/src/cli/oclif/base-command.js.map +1 -0
- package/dist/src/cli/oclif/help.d.ts +16 -0
- package/dist/src/cli/oclif/help.d.ts.map +1 -0
- package/dist/src/cli/oclif/help.js +33 -0
- package/dist/src/cli/oclif/help.js.map +1 -0
- package/dist/src/cli/oclif/i18n.d.ts +16 -0
- package/dist/src/cli/oclif/i18n.d.ts.map +1 -0
- package/dist/src/cli/oclif/i18n.js +62 -0
- package/dist/src/cli/oclif/i18n.js.map +1 -0
- package/dist/src/cli/oclif/parsers.d.ts +10 -0
- package/dist/src/cli/oclif/parsers.d.ts.map +1 -0
- package/dist/src/cli/oclif/parsers.js +102 -0
- package/dist/src/cli/oclif/parsers.js.map +1 -0
- package/dist/src/cli/oclif/projection.d.ts +23 -0
- package/dist/src/cli/oclif/projection.d.ts.map +1 -0
- package/dist/src/cli/oclif/projection.js +52 -0
- package/dist/src/cli/oclif/projection.js.map +1 -0
- package/dist/src/cli/oclif/run.d.ts +2 -0
- package/dist/src/cli/oclif/run.d.ts.map +1 -0
- package/dist/src/cli/oclif/run.js +11 -0
- package/dist/src/cli/oclif/run.js.map +1 -0
- package/dist/src/diagnosis/observe-mapper.d.ts +68 -0
- package/dist/src/diagnosis/observe-mapper.d.ts.map +1 -0
- package/dist/src/diagnosis/observe-mapper.js +276 -0
- package/dist/src/diagnosis/observe-mapper.js.map +1 -0
- package/dist/src/diagnosis/observe-producer.d.ts +9 -0
- package/dist/src/diagnosis/observe-producer.d.ts.map +1 -0
- package/dist/src/diagnosis/observe-producer.js +197 -0
- package/dist/src/diagnosis/observe-producer.js.map +1 -0
- package/dist/src/diagnosis/studio-projection.d.ts +14 -0
- package/dist/src/diagnosis/studio-projection.d.ts.map +1 -0
- package/dist/src/diagnosis/studio-projection.js +84 -0
- package/dist/src/diagnosis/studio-projection.js.map +1 -0
- package/dist/src/diagnosis/types.d.ts +79 -0
- package/dist/src/diagnosis/types.d.ts.map +1 -0
- package/dist/src/diagnosis/types.js +20 -0
- package/dist/src/diagnosis/types.js.map +1 -0
- package/dist/src/doctor/fixer.d.ts +12 -0
- package/dist/src/doctor/fixer.d.ts.map +1 -0
- package/dist/src/doctor/fixer.js +326 -0
- package/dist/src/doctor/fixer.js.map +1 -0
- package/dist/src/doctor/health/builtin-dimensions.d.ts.map +1 -1
- package/dist/src/doctor/health/builtin-dimensions.js +20 -23
- package/dist/src/doctor/health/builtin-dimensions.js.map +1 -1
- package/dist/src/doctor/health/composer.d.ts.map +1 -1
- package/dist/src/doctor/health/composer.js +14 -7
- package/dist/src/doctor/health/composer.js.map +1 -1
- package/dist/src/doctor/health/dimension-spec.d.ts +1 -0
- package/dist/src/doctor/health/dimension-spec.d.ts.map +1 -1
- package/dist/src/doctor/health/parser.d.ts +0 -1
- package/dist/src/doctor/health/parser.d.ts.map +1 -1
- package/dist/src/doctor/health/parser.js +38 -0
- package/dist/src/doctor/health/parser.js.map +1 -1
- package/dist/src/doctor/health/prompt-builder.d.ts +2 -21
- package/dist/src/doctor/health/prompt-builder.d.ts.map +1 -1
- package/dist/src/doctor/health/prompt-builder.js +1 -161
- package/dist/src/doctor/health/prompt-builder.js.map +1 -1
- package/dist/src/doctor/html-renderer.d.ts +1 -1
- package/dist/src/doctor/html-renderer.d.ts.map +1 -1
- package/dist/src/doctor/html-renderer.js +78 -68
- package/dist/src/doctor/html-renderer.js.map +1 -1
- package/dist/src/doctor/index.d.ts.map +1 -1
- package/dist/src/doctor/index.js +1 -0
- package/dist/src/doctor/index.js.map +1 -1
- package/dist/src/doctor/renderer.d.ts +1 -1
- package/dist/src/doctor/renderer.d.ts.map +1 -1
- package/dist/src/doctor/renderer.js +2 -2
- package/dist/src/doctor/renderer.js.map +1 -1
- package/dist/src/doctor/rules.d.ts.map +1 -1
- package/dist/src/doctor/rules.js +33 -1
- package/dist/src/doctor/rules.js.map +1 -1
- package/dist/src/eval-core/cache.d.ts +16 -2
- package/dist/src/eval-core/cache.d.ts.map +1 -1
- package/dist/src/eval-core/cache.js +86 -15
- package/dist/src/eval-core/cache.js.map +1 -1
- package/dist/src/eval-core/evaluation-execution.d.ts +11 -1
- package/dist/src/eval-core/evaluation-execution.d.ts.map +1 -1
- package/dist/src/eval-core/evaluation-execution.js +78 -6
- package/dist/src/eval-core/evaluation-execution.js.map +1 -1
- package/dist/src/eval-core/evaluation-job.d.ts +2 -1
- package/dist/src/eval-core/evaluation-job.d.ts.map +1 -1
- package/dist/src/eval-core/evaluation-job.js +2 -1
- package/dist/src/eval-core/evaluation-job.js.map +1 -1
- package/dist/src/eval-core/evaluation-reporting.d.ts +7 -0
- package/dist/src/eval-core/evaluation-reporting.d.ts.map +1 -1
- package/dist/src/eval-core/evaluation-reporting.js +19 -2
- package/dist/src/eval-core/evaluation-reporting.js.map +1 -1
- package/dist/src/eval-core/execution-strategy.d.ts +1 -1
- package/dist/src/eval-core/execution-strategy.d.ts.map +1 -1
- package/dist/src/eval-core/execution-strategy.js +12 -1
- package/dist/src/eval-core/execution-strategy.js.map +1 -1
- package/dist/src/eval-core/mock-hook.cjs +215 -0
- package/dist/src/eval-core/mocks-runtime.d.ts +100 -0
- package/dist/src/eval-core/mocks-runtime.d.ts.map +1 -0
- package/dist/src/eval-core/mocks-runtime.js +559 -0
- package/dist/src/eval-core/mocks-runtime.js.map +1 -0
- package/dist/src/eval-core/schema.d.ts.map +1 -1
- package/dist/src/eval-core/schema.js +18 -5
- package/dist/src/eval-core/schema.js.map +1 -1
- package/dist/src/eval-core/task-planner.d.ts +9 -1
- package/dist/src/eval-core/task-planner.d.ts.map +1 -1
- package/dist/src/eval-core/task-planner.js +40 -1
- package/dist/src/eval-core/task-planner.js.map +1 -1
- package/dist/src/eval-workflows/batch-evaluation-workflow.d.ts +5 -1
- package/dist/src/eval-workflows/batch-evaluation-workflow.d.ts.map +1 -1
- package/dist/src/eval-workflows/batch-evaluation-workflow.js +2 -1
- package/dist/src/eval-workflows/batch-evaluation-workflow.js.map +1 -1
- package/dist/src/eval-workflows/evaluation-pipeline.d.ts +23 -2
- package/dist/src/eval-workflows/evaluation-pipeline.d.ts.map +1 -1
- package/dist/src/eval-workflows/evaluation-pipeline.js +40 -13
- package/dist/src/eval-workflows/evaluation-pipeline.js.map +1 -1
- package/dist/src/eval-workflows/evaluation-preparation.d.ts +5 -0
- package/dist/src/eval-workflows/evaluation-preparation.d.ts.map +1 -1
- package/dist/src/eval-workflows/evaluation-preparation.js +3 -1
- package/dist/src/eval-workflows/evaluation-preparation.js.map +1 -1
- package/dist/src/eval-workflows/run-evaluation.d.ts +12 -2
- package/dist/src/eval-workflows/run-evaluation.d.ts.map +1 -1
- package/dist/src/eval-workflows/run-evaluation.js +18 -6
- package/dist/src/eval-workflows/run-evaluation.js.map +1 -1
- package/dist/src/executors/claude-cli.d.ts +1 -1
- package/dist/src/executors/claude-cli.d.ts.map +1 -1
- package/dist/src/executors/claude-cli.js +59 -6
- package/dist/src/executors/claude-cli.js.map +1 -1
- package/dist/src/executors/claude-sdk-trace.d.ts.map +1 -1
- package/dist/src/executors/claude-sdk-trace.js +10 -4
- package/dist/src/executors/claude-sdk-trace.js.map +1 -1
- package/dist/src/executors/claude-sdk.d.ts +1 -1
- package/dist/src/executors/claude-sdk.d.ts.map +1 -1
- package/dist/src/executors/claude-sdk.js +25 -2
- package/dist/src/executors/claude-sdk.js.map +1 -1
- package/dist/src/executors/shared.d.ts +1 -1
- package/dist/src/executors/shared.d.ts.map +1 -1
- package/dist/src/executors/shared.js +6 -1
- package/dist/src/executors/shared.js.map +1 -1
- package/dist/src/grading/assertions.d.ts +5 -0
- package/dist/src/grading/assertions.d.ts.map +1 -1
- package/dist/src/grading/assertions.js +27 -1
- package/dist/src/grading/assertions.js.map +1 -1
- package/dist/src/grading/diagnostic.d.ts +40 -0
- package/dist/src/grading/diagnostic.d.ts.map +1 -0
- package/dist/src/grading/diagnostic.js +450 -0
- package/dist/src/grading/diagnostic.js.map +1 -0
- package/dist/src/grading/index.d.ts +5 -0
- package/dist/src/grading/index.d.ts.map +1 -1
- package/dist/src/grading/judge.d.ts.map +1 -1
- package/dist/src/grading/judge.js +54 -2
- package/dist/src/grading/judge.js.map +1 -1
- package/dist/src/grading/layered-scores.d.ts.map +1 -1
- package/dist/src/grading/layered-scores.js +1 -0
- package/dist/src/grading/layered-scores.js.map +1 -1
- package/dist/src/inputs/eval-config.js +19 -0
- package/dist/src/inputs/eval-config.js.map +1 -1
- package/dist/src/inputs/load-samples.d.ts +22 -2
- package/dist/src/inputs/load-samples.d.ts.map +1 -1
- package/dist/src/inputs/load-samples.js +193 -22
- package/dist/src/inputs/load-samples.js.map +1 -1
- package/dist/src/inputs/skill-loader.d.ts.map +1 -1
- package/dist/src/inputs/skill-loader.js +11 -3
- package/dist/src/inputs/skill-loader.js.map +1 -1
- package/dist/src/observability/experience.d.ts +441 -0
- package/dist/src/observability/experience.d.ts.map +1 -0
- package/dist/src/observability/experience.js +2400 -0
- package/dist/src/observability/experience.js.map +1 -0
- package/dist/src/observability/inbox-view-model.d.ts +14 -1
- package/dist/src/observability/inbox-view-model.d.ts.map +1 -1
- package/dist/src/observability/inbox-view-model.js +85 -3
- package/dist/src/observability/inbox-view-model.js.map +1 -1
- package/dist/src/observability/inbox.d.ts +29 -2
- package/dist/src/observability/inbox.d.ts.map +1 -1
- package/dist/src/observability/inbox.js +62 -10
- package/dist/src/observability/inbox.js.map +1 -1
- package/dist/src/observability/problem-patterns.d.ts +52 -0
- package/dist/src/observability/problem-patterns.d.ts.map +1 -0
- package/dist/src/observability/problem-patterns.js +205 -0
- package/dist/src/observability/problem-patterns.js.map +1 -0
- package/dist/src/observability/resolved-review.d.ts +25 -0
- package/dist/src/observability/resolved-review.d.ts.map +1 -0
- package/dist/src/observability/resolved-review.js +231 -0
- package/dist/src/observability/resolved-review.js.map +1 -0
- package/dist/src/observability/review-state.d.ts +61 -0
- package/dist/src/observability/review-state.d.ts.map +1 -0
- package/dist/src/observability/review-state.js +169 -0
- package/dist/src/observability/review-state.js.map +1 -0
- package/dist/src/observability/skill-chain-advisories.d.ts +25 -0
- package/dist/src/observability/skill-chain-advisories.d.ts.map +1 -0
- package/dist/src/observability/skill-chain-advisories.js +69 -0
- package/dist/src/observability/skill-chain-advisories.js.map +1 -0
- package/dist/src/observability/skill-chain.d.ts +62 -0
- package/dist/src/observability/skill-chain.d.ts.map +1 -0
- package/dist/src/observability/skill-chain.js +270 -0
- package/dist/src/observability/skill-chain.js.map +1 -0
- package/dist/src/observability/soft-standards.d.ts +130 -0
- package/dist/src/observability/soft-standards.d.ts.map +1 -0
- package/dist/src/observability/soft-standards.js +426 -0
- package/dist/src/observability/soft-standards.js.map +1 -0
- package/dist/src/observability/text-signals.d.ts +14 -0
- package/dist/src/observability/text-signals.d.ts.map +1 -0
- package/dist/src/observability/text-signals.js +106 -0
- package/dist/src/observability/text-signals.js.map +1 -0
- package/dist/src/observability/trace-adapter.d.ts +1 -1
- package/dist/src/observability/trace-adapter.d.ts.map +1 -1
- package/dist/src/observability/trace-adapter.js +1 -1
- package/dist/src/observability/trace-adapter.js.map +1 -1
- package/dist/src/observability/trace-attribution.d.ts +29 -1
- package/dist/src/observability/trace-attribution.d.ts.map +1 -1
- package/dist/src/observability/trace-attribution.js +106 -10
- package/dist/src/observability/trace-attribution.js.map +1 -1
- package/dist/src/observability/trace-segmenter.d.ts +11 -1
- package/dist/src/observability/trace-segmenter.d.ts.map +1 -1
- package/dist/src/observability/trace-segmenter.js +121 -30
- package/dist/src/observability/trace-segmenter.js.map +1 -1
- package/dist/src/observability/trace-source.d.ts +28 -1
- package/dist/src/observability/trace-source.d.ts.map +1 -1
- package/dist/src/observability/trace-source.js +366 -6
- package/dist/src/observability/trace-source.js.map +1 -1
- package/dist/src/renderer/html-renderer.d.ts.map +1 -1
- package/dist/src/renderer/html-renderer.js +229 -171
- package/dist/src/renderer/html-renderer.js.map +1 -1
- package/dist/src/renderer/layout.d.ts.map +1 -1
- package/dist/src/renderer/layout.js +108 -61
- package/dist/src/renderer/layout.js.map +1 -1
- package/dist/src/renderer/observation-inbox-renderer.d.ts.map +1 -1
- package/dist/src/renderer/observation-inbox-renderer.js +9551 -85
- package/dist/src/renderer/observation-inbox-renderer.js.map +1 -1
- package/dist/src/renderer/skill-detail-renderer.d.ts +15 -0
- package/dist/src/renderer/skill-detail-renderer.d.ts.map +1 -0
- package/dist/src/renderer/skill-detail-renderer.js +1244 -0
- package/dist/src/renderer/skill-detail-renderer.js.map +1 -0
- package/dist/src/renderer/skill-list-renderer.d.ts +4 -0
- package/dist/src/renderer/skill-list-renderer.d.ts.map +1 -0
- package/dist/src/renderer/skill-list-renderer.js +334 -0
- package/dist/src/renderer/skill-list-renderer.js.map +1 -0
- package/dist/src/renderer/summary.d.ts.map +1 -1
- package/dist/src/renderer/summary.js +78 -50
- package/dist/src/renderer/summary.js.map +1 -1
- package/dist/src/renderer/table.d.ts.map +1 -1
- package/dist/src/renderer/table.js +213 -167
- package/dist/src/renderer/table.js.map +1 -1
- package/dist/src/renderer/test-view.d.ts +66 -0
- package/dist/src/renderer/test-view.d.ts.map +1 -0
- package/dist/src/renderer/test-view.js +905 -0
- package/dist/src/renderer/test-view.js.map +1 -0
- package/dist/src/server/report-server.d.ts +4 -1
- package/dist/src/server/report-server.d.ts.map +1 -1
- package/dist/src/server/report-server.js +242 -4
- package/dist/src/server/report-server.js.map +1 -1
- package/dist/src/server/report-store.d.ts.map +1 -1
- package/dist/src/server/report-store.js +33 -1
- package/dist/src/server/report-store.js.map +1 -1
- package/dist/src/server/skill-index.d.ts +81 -0
- package/dist/src/server/skill-index.d.ts.map +1 -0
- package/dist/src/server/skill-index.js +377 -0
- package/dist/src/server/skill-index.js.map +1 -0
- package/dist/src/server/skill-insights.d.ts +101 -0
- package/dist/src/server/skill-insights.d.ts.map +1 -0
- package/dist/src/server/skill-insights.js +788 -0
- package/dist/src/server/skill-insights.js.map +1 -0
- package/dist/src/shared/hard-rules.d.ts +42 -0
- package/dist/src/shared/hard-rules.d.ts.map +1 -0
- package/dist/src/shared/hard-rules.js +242 -0
- package/dist/src/shared/hard-rules.js.map +1 -0
- package/dist/src/shared/llm-prompts/index.d.ts +14 -0
- package/dist/src/shared/llm-prompts/index.d.ts.map +1 -0
- package/dist/src/shared/llm-prompts/index.js +35 -0
- package/dist/src/shared/llm-prompts/index.js.map +1 -0
- package/dist/src/shared/llm-prompts/skill-health.d.ts +22 -0
- package/dist/src/shared/llm-prompts/skill-health.d.ts.map +1 -0
- package/dist/src/shared/llm-prompts/skill-health.js +170 -0
- package/dist/src/shared/llm-prompts/skill-health.js.map +1 -0
- package/dist/src/shared/time.d.ts +2 -0
- package/dist/src/shared/time.d.ts.map +1 -0
- package/dist/src/shared/time.js +10 -0
- package/dist/src/shared/time.js.map +1 -0
- package/dist/src/types/doctor.d.ts +2 -0
- package/dist/src/types/doctor.d.ts.map +1 -1
- package/dist/src/types/eval.d.ts +88 -0
- package/dist/src/types/eval.d.ts.map +1 -1
- package/dist/src/types/executor.d.ts +43 -0
- package/dist/src/types/executor.d.ts.map +1 -1
- package/dist/src/types/judge.d.ts +76 -0
- package/dist/src/types/judge.d.ts.map +1 -1
- package/dist/src/types/judge.js +3 -1
- package/dist/src/types/judge.js.map +1 -1
- package/dist/src/types/report.d.ts +69 -3
- package/dist/src/types/report.d.ts.map +1 -1
- package/dist/src/util/safe-slice.d.ts +23 -0
- package/dist/src/util/safe-slice.d.ts.map +1 -0
- package/dist/src/util/safe-slice.js +33 -0
- package/dist/src/util/safe-slice.js.map +1 -0
- package/docs/prompts/llm-enhanced-review.prompt.md +111 -0
- package/package.json +33 -7
- package/dist/src/cli/cli-exit.d.ts +0 -15
- package/dist/src/cli/cli-exit.d.ts.map +0 -1
- package/dist/src/cli/cli-exit.js +0 -19
- package/dist/src/cli/cli-exit.js.map +0 -1
- package/dist/src/cli/commands/_shared.d.ts.map +0 -1
- package/dist/src/cli/commands/_shared.js.map +0 -1
- package/dist/src/cli/commands/eval-gold.d.ts +0 -2
- package/dist/src/cli/commands/eval-gold.d.ts.map +0 -1
- package/dist/src/cli/commands/eval-gold.js +0 -137
- package/dist/src/cli/commands/eval-gold.js.map +0 -1
- package/dist/src/cli/commands/eval-runner.d.ts +0 -2
- package/dist/src/cli/commands/eval-runner.d.ts.map +0 -1
- package/dist/src/cli/commands/eval-runner.js.map +0 -1
- package/dist/src/cli/commands/eval.d.ts +0 -2
- package/dist/src/cli/commands/eval.d.ts.map +0 -1
- package/dist/src/cli/commands/eval.js +0 -11
- package/dist/src/cli/commands/eval.js.map +0 -1
- package/dist/src/cli/commands/observe.d.ts +0 -2
- package/dist/src/cli/commands/observe.d.ts.map +0 -1
- package/dist/src/cli/commands/observe.js +0 -246
- package/dist/src/cli/commands/observe.js.map +0 -1
- package/dist/src/cli/commands/registry.d.ts +0 -11
- package/dist/src/cli/commands/registry.d.ts.map +0 -1
- package/dist/src/cli/commands/registry.js +0 -32
- package/dist/src/cli/commands/registry.js.map +0 -1
- package/dist/src/cli/i18n-dict.d.ts.map +0 -1
- package/dist/src/cli/i18n-dict.js.map +0 -1
- package/dist/src/cli/i18n.d.ts.map +0 -1
- package/dist/src/cli/i18n.js.map +0 -1
- package/dist/src/cli/parse-run-config.d.ts.map +0 -1
- package/dist/src/cli/parse-run-config.js.map +0 -1
- package/dist/src/cli/parse-strict.d.ts +0 -7
- package/dist/src/cli/parse-strict.d.ts.map +0 -1
- package/dist/src/cli/parse-strict.js +0 -26
- package/dist/src/cli/parse-strict.js.map +0 -1
- package/dist/src/cli/progress.d.ts.map +0 -1
- package/dist/src/cli/progress.js.map +0 -1
- package/dist/src/cli/run-tally.d.ts.map +0 -1
- package/dist/src/cli/run-tally.js.map +0 -1
- package/dist/src/cli/update-check.d.ts.map +0 -1
- package/dist/src/cli/update-check.js.map +0 -1
- /package/dist/src/cli/{progress.d.ts → lib/progress.d.ts} +0 -0
- /package/dist/src/cli/{progress.js → lib/progress.js} +0 -0
- /package/dist/src/cli/{run-tally.js → lib/run-tally.js} +0 -0
- /package/dist/src/cli/{update-check.d.ts → lib/update-check.d.ts} +0 -0
- /package/dist/src/cli/{update-check.js → lib/update-check.js} +0 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock runtime — Sample.mocks 落地的核心逻辑。
|
|
3
|
+
*
|
|
4
|
+
* 两条路径:
|
|
5
|
+
* 1) `buildSdkHookCallback(mocks, baseDir)`
|
|
6
|
+
* → 给 claude-sdk executor 用,返回 in-process PreToolUse HookCallback。
|
|
7
|
+
* 纯内存,零 IO,零 spawn 开销。
|
|
8
|
+
*
|
|
9
|
+
* 2) `materializeForCliConfigDir(mocks, baseDir)`
|
|
10
|
+
* → 给 claude-cli executor 用,mktemp 一个临时 CLAUDE_CONFIG_DIR,
|
|
11
|
+
* 在里面写 settings.json + on-disk hook 脚本 + mocks.json,返回 cleanup。
|
|
12
|
+
* claude 子进程退出后(成功/失败/超时/SIGINT),cleanup 必删整个临时目录。
|
|
13
|
+
*
|
|
14
|
+
* 共用核心:`matchMock(mocks, toolName, toolInput, callCounter)` 命中规则评估。
|
|
15
|
+
*/
|
|
16
|
+
import { mkdtempSync, rmSync, writeFileSync, mkdirSync, readFileSync, existsSync } from 'node:fs';
|
|
17
|
+
import { homedir, tmpdir } from 'node:os';
|
|
18
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
19
|
+
import { fileURLToPath } from 'node:url';
|
|
20
|
+
// ─── Match logic ────────────────────────────────────────────────────────────
|
|
21
|
+
function expandHome(p) {
|
|
22
|
+
if (p.startsWith('~/'))
|
|
23
|
+
return join(homedir(), p.slice(2));
|
|
24
|
+
if (p === '~')
|
|
25
|
+
return homedir();
|
|
26
|
+
return p;
|
|
27
|
+
}
|
|
28
|
+
/** file_path 后缀匹配:actual 完全等于 suffix,或 actual 在 path-separator 后以 suffix 结尾。
|
|
29
|
+
* 避免 'state.json' 误匹配 'bad-state.json'。两端都先 expandHome。
|
|
30
|
+
* 例:suffix='tasks/foo/state.json' 命中 'tasks/foo/state.json' / '/abs/x/tasks/foo/state.json' /
|
|
31
|
+
* 'C:\\proj\\tasks\\foo\\state.json' (Windows backslash 也接受)。 */
|
|
32
|
+
function matchesFilePathSuffix(actualRaw, suffixRaw) {
|
|
33
|
+
const actual = expandHome(actualRaw);
|
|
34
|
+
const suffix = expandHome(suffixRaw);
|
|
35
|
+
if (actual === suffix)
|
|
36
|
+
return true;
|
|
37
|
+
if (!actual.endsWith(suffix))
|
|
38
|
+
return false;
|
|
39
|
+
const boundaryIdx = actual.length - suffix.length - 1;
|
|
40
|
+
const sep = actual.charAt(boundaryIdx);
|
|
41
|
+
return sep === '/' || sep === '\\';
|
|
42
|
+
}
|
|
43
|
+
/** glob 匹配(只支持 `*` 通配,不支持 `**` / `?` / `[...]`,够用且无依赖)。
|
|
44
|
+
* 使用 dotAll 标志(`s`),让 `*` 也能跨换行匹配 — LLM 经常用反斜杠续行写多行 bash,
|
|
45
|
+
* 不带 `s` 时单行 glob 会全部漏掉(integration-tool-deploy eval 上首次发现这个坑)。 */
|
|
46
|
+
function globMatch(pattern, value) {
|
|
47
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
|
|
48
|
+
const re = new RegExp('^' + escaped.replace(/\*/g, '.*') + '$', 's');
|
|
49
|
+
return re.test(value);
|
|
50
|
+
}
|
|
51
|
+
/** deep equal 子集匹配:expected 的每个 key/value 在 actual 中存在且相等(actual 可有更多字段)。 */
|
|
52
|
+
/** 数组 deep-equal:长度相等 + 每个元素递归比较(支持嵌套数组 / object)。 */
|
|
53
|
+
function arraysDeepEqual(a, b) {
|
|
54
|
+
if (a.length !== b.length)
|
|
55
|
+
return false;
|
|
56
|
+
for (let i = 0; i < a.length; i++) {
|
|
57
|
+
if (!deepEqual(a[i], b[i]))
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
function deepEqual(a, b) {
|
|
63
|
+
if (a === b)
|
|
64
|
+
return true;
|
|
65
|
+
if (Array.isArray(a) && Array.isArray(b))
|
|
66
|
+
return arraysDeepEqual(a, b);
|
|
67
|
+
if (typeof a === 'object' && a !== null && typeof b === 'object' && b !== null
|
|
68
|
+
&& !Array.isArray(a) && !Array.isArray(b)) {
|
|
69
|
+
const ao = a;
|
|
70
|
+
const bo = b;
|
|
71
|
+
const ak = Object.keys(ao);
|
|
72
|
+
const bk = Object.keys(bo);
|
|
73
|
+
if (ak.length !== bk.length)
|
|
74
|
+
return false;
|
|
75
|
+
for (const k of ak) {
|
|
76
|
+
if (!deepEqual(ao[k], bo[k]))
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
function matchesInputSubset(expected, actual) {
|
|
84
|
+
if (typeof actual !== 'object' || actual === null)
|
|
85
|
+
return false;
|
|
86
|
+
const a = actual;
|
|
87
|
+
for (const [k, v] of Object.entries(expected)) {
|
|
88
|
+
if (Array.isArray(v)) {
|
|
89
|
+
// 数组 deep-equal,不要靠 === 引用比较 — 不同 sample 实例的同样数组永远不会等
|
|
90
|
+
if (!Array.isArray(a[k]) || !arraysDeepEqual(v, a[k]))
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
else if (typeof v === 'object' && v !== null) {
|
|
94
|
+
if (!matchesInputSubset(v, a[k]))
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
else if (a[k] !== v) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
function anyStringContains(obj, needle) {
|
|
104
|
+
if (typeof obj === 'string')
|
|
105
|
+
return obj.toLowerCase().includes(needle);
|
|
106
|
+
if (Array.isArray(obj))
|
|
107
|
+
return obj.some((item) => anyStringContains(item, needle));
|
|
108
|
+
if (typeof obj === 'object' && obj !== null)
|
|
109
|
+
return Object.values(obj).some((v) => anyStringContains(v, needle));
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
/** 单条 mock 是否命中给定 tool 调用。 */
|
|
113
|
+
export function isMockHit(mock, toolName, toolInput) {
|
|
114
|
+
if (mock.tool !== '*' && mock.tool !== toolName)
|
|
115
|
+
return false;
|
|
116
|
+
const m = mock.match;
|
|
117
|
+
if (!m)
|
|
118
|
+
return true;
|
|
119
|
+
const ti = (toolInput || {});
|
|
120
|
+
if (m.file_path !== undefined) {
|
|
121
|
+
if (typeof ti.file_path !== 'string')
|
|
122
|
+
return false;
|
|
123
|
+
if (expandHome(ti.file_path) !== expandHome(m.file_path))
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (m.file_path_endswith !== undefined) {
|
|
127
|
+
if (typeof ti.file_path !== 'string')
|
|
128
|
+
return false;
|
|
129
|
+
if (!matchesFilePathSuffix(ti.file_path, m.file_path_endswith))
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
if (m.url !== undefined) {
|
|
133
|
+
if (ti.url !== m.url)
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (m.url_glob !== undefined) {
|
|
137
|
+
if (typeof ti.url !== 'string' || !globMatch(m.url_glob, ti.url))
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
if (m.command_glob !== undefined) {
|
|
141
|
+
if (typeof ti.command !== 'string' || !globMatch(m.command_glob, ti.command))
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
if (m.input !== undefined) {
|
|
145
|
+
if (!matchesInputSubset(m.input, toolInput))
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if (m.input_contains !== undefined) {
|
|
149
|
+
if (!anyStringContains(toolInput, m.input_contains.toLowerCase()))
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
// ─── Return resolution ──────────────────────────────────────────────────────
|
|
155
|
+
/** 把 mock 的 return / return_file / return_seq 解析成可序列化字符串(LLM 看到的 tool_result)。 */
|
|
156
|
+
export function resolveMockReturn(mock, hitCount, baseDir) {
|
|
157
|
+
// return_seq 优先,按 hit 序号取(超出长度 fallback 到 return / return_file)
|
|
158
|
+
if (mock.return_seq && hitCount < mock.return_seq.length) {
|
|
159
|
+
return stringifyReturn(mock.return_seq[hitCount]);
|
|
160
|
+
}
|
|
161
|
+
if (mock.return !== undefined) {
|
|
162
|
+
return stringifyReturn(mock.return);
|
|
163
|
+
}
|
|
164
|
+
if (mock.return_file) {
|
|
165
|
+
const fpath = isAbsolute(mock.return_file)
|
|
166
|
+
? mock.return_file
|
|
167
|
+
: resolve(baseDir || process.cwd(), mock.return_file);
|
|
168
|
+
if (!existsSync(fpath)) {
|
|
169
|
+
return `[omk-mock-error] return_file not found: ${fpath}`;
|
|
170
|
+
}
|
|
171
|
+
return readFileSync(fpath, 'utf8');
|
|
172
|
+
}
|
|
173
|
+
return ''; // 没配 return,给空串(LLM 收到空 tool_result)
|
|
174
|
+
}
|
|
175
|
+
function stringifyReturn(r) {
|
|
176
|
+
if (typeof r === 'string')
|
|
177
|
+
return r;
|
|
178
|
+
// Bash 风格对象:exit !=0 时格式化成 LLM 能理解的"失败"输出
|
|
179
|
+
// 这里统一序列化成 JSON,LLM 能从结构化字段读到 stdout/stderr/exit
|
|
180
|
+
return JSON.stringify(r);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* 把 mocks 转成 SDK in-process PreToolUse hook callback。
|
|
184
|
+
*
|
|
185
|
+
* 命中策略:strict 模式下不命中的工具调用直接 deny(防意外真调)。
|
|
186
|
+
* 默认非 strict:不命中放行(原生工具继续真跑)— 适合"部分 mock,部分真跑"场景。
|
|
187
|
+
*
|
|
188
|
+
* @param mocks Sample.mocks 数组
|
|
189
|
+
* @param baseDir 解析 mock.return_file 的相对路径锚点
|
|
190
|
+
* @param strict true → 不命中 deny;false → 不命中放行(default)
|
|
191
|
+
*/
|
|
192
|
+
export function buildSdkHookCallback(mocks, baseDir, strict = false) {
|
|
193
|
+
const stats = { hits: 0, misses: 0, perMock: {} };
|
|
194
|
+
const hitCounters = new Map(); // mockIndex → hit 次数
|
|
195
|
+
// perMock key 用"每工具内 1-based 序号":[Read,Bash,Bash] → Read:1,Bash:1,Bash:2。
|
|
196
|
+
// 这样 sample 作者只需要数自己 mocks 里同 tool 的第几条,不用算跨工具的绝对下标。
|
|
197
|
+
const list = mocks || [];
|
|
198
|
+
const keyOfMock = list.map((_m, i) => {
|
|
199
|
+
const tool = list[i].tool;
|
|
200
|
+
const ord = list.slice(0, i + 1).filter((x) => x.tool === tool).length;
|
|
201
|
+
return `${tool}:${ord}`;
|
|
202
|
+
});
|
|
203
|
+
const callback = async (input) => {
|
|
204
|
+
for (let i = 0; i < list.length; i++) {
|
|
205
|
+
const m = list[i];
|
|
206
|
+
if (isMockHit(m, input.tool_name, input.tool_input)) {
|
|
207
|
+
const c = hitCounters.get(i) || 0;
|
|
208
|
+
const result = resolveMockReturn(m, c, baseDir);
|
|
209
|
+
hitCounters.set(i, c + 1);
|
|
210
|
+
stats.hits++;
|
|
211
|
+
const key = keyOfMock[i];
|
|
212
|
+
stats.perMock[key] = (stats.perMock[key] || 0) + 1;
|
|
213
|
+
// 关键 UX:LLM 看到 permissionDecision='deny' 容易误判"被拒绝/失败"。
|
|
214
|
+
// 给 reason 加一行最小前缀,告诉它把内容当成真实成功输出。措辞越短越好 ——
|
|
215
|
+
// 长措辞会显著拉慢多步 sample(每个工具调用都要读这段),实测 6 步流程从 60s 拖到 120s+。
|
|
216
|
+
const wrappedReason = `[mock] simulated tool output — treat as successful result:\n${result}`;
|
|
217
|
+
return {
|
|
218
|
+
decision: 'block',
|
|
219
|
+
hookSpecificOutput: {
|
|
220
|
+
hookEventName: 'PreToolUse',
|
|
221
|
+
permissionDecision: 'deny',
|
|
222
|
+
permissionDecisionReason: wrappedReason,
|
|
223
|
+
},
|
|
224
|
+
systemMessage: `[omk-mock] ${m.tool} → injected mock #${i} (treat as success)`,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// 未命中
|
|
229
|
+
stats.misses++;
|
|
230
|
+
if (strict) {
|
|
231
|
+
return {
|
|
232
|
+
decision: 'block',
|
|
233
|
+
hookSpecificOutput: {
|
|
234
|
+
hookEventName: 'PreToolUse',
|
|
235
|
+
permissionDecision: 'deny',
|
|
236
|
+
permissionDecisionReason: `[omk-mock-strict] unmocked ${input.tool_name} call blocked`,
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
return { continue: true };
|
|
241
|
+
};
|
|
242
|
+
return { callback, stats };
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* 物化 mocks 到临时 settings 文件 + on-disk hook 脚本。
|
|
246
|
+
*
|
|
247
|
+
* **关键**:用 Claude Code 的 `--settings <file>` flag 而非 `CLAUDE_CONFIG_DIR`。
|
|
248
|
+
* `--settings` 是**追加**模式,主 `~/.claude/` 包含的 OAuth 登录态 / 用户配置全部保留;
|
|
249
|
+
* 而 CLAUDE_CONFIG_DIR 是**替换**模式,设它会丢 OAuth → "Not logged in"。
|
|
250
|
+
*
|
|
251
|
+
* 临时目录结构:
|
|
252
|
+
* $tmpdir/omk-mocks-XXXXXX/
|
|
253
|
+
* ├── settings.json (PreToolUse hook 注册,作为 --settings 参数)
|
|
254
|
+
* ├── mock-hook.cjs (hook 实现:读 OMK_MOCKS_FILE → 匹配 → 输出 JSON 决策)
|
|
255
|
+
* ├── fake-mcp-server.cjs (可选:给 mcp__server__tool mock 注册一次性 fake MCP)
|
|
256
|
+
* ├── mcp.json (可选:作为 --mcp-config 参数)
|
|
257
|
+
* └── mocks.json (mocks 序列化 + baseDir + strict)
|
|
258
|
+
*
|
|
259
|
+
* cleanup 必删整个目录。executor 用 try / finally 保证执行。
|
|
260
|
+
*/
|
|
261
|
+
export function materializeForCliConfigDir(mocks, baseDir, strict = false) {
|
|
262
|
+
if (!mocks || mocks.length === 0)
|
|
263
|
+
return null;
|
|
264
|
+
const configDir = mkdtempSync(join(tmpdir(), 'omk-mocks-'));
|
|
265
|
+
const mocksFile = join(configDir, 'mocks.json');
|
|
266
|
+
const settingsFile = join(configDir, 'settings.json');
|
|
267
|
+
const hookScript = join(configDir, 'mock-hook.cjs');
|
|
268
|
+
const mcpServerScript = join(configDir, 'fake-mcp-server.cjs');
|
|
269
|
+
const mcpConfigFile = join(configDir, 'mcp.json');
|
|
270
|
+
const hookSource = readMockHookTemplate();
|
|
271
|
+
writeFileSync(hookScript, hookSource, 'utf8');
|
|
272
|
+
writeFileSync(mocksFile, JSON.stringify({ mocks, baseDir, strict }, null, 2));
|
|
273
|
+
const settings = {
|
|
274
|
+
hooks: {
|
|
275
|
+
PreToolUse: [
|
|
276
|
+
{
|
|
277
|
+
matcher: '.*',
|
|
278
|
+
hooks: [
|
|
279
|
+
{ type: 'command', command: `node ${hookScript}` },
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
writeFileSync(settingsFile, JSON.stringify(settings, null, 2));
|
|
286
|
+
const fakeMcpServers = collectFakeMcpServers(mocks);
|
|
287
|
+
const hasFakeMcp = fakeMcpServers.size > 0;
|
|
288
|
+
if (hasFakeMcp) {
|
|
289
|
+
writeFileSync(mcpServerScript, fakeMcpServerSource(), 'utf8');
|
|
290
|
+
const mcpServers = {};
|
|
291
|
+
for (const serverName of fakeMcpServers.keys()) {
|
|
292
|
+
mcpServers[serverName] = {
|
|
293
|
+
command: 'node',
|
|
294
|
+
args: [mcpServerScript, serverName],
|
|
295
|
+
env: { OMK_MOCKS_FILE: mocksFile },
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
writeFileSync(mcpConfigFile, JSON.stringify({ mcpServers }, null, 2));
|
|
299
|
+
}
|
|
300
|
+
const statsFile = join(configDir, 'hits.json');
|
|
301
|
+
const readStats = () => {
|
|
302
|
+
if (!existsSync(statsFile)) {
|
|
303
|
+
return { hits: 0, misses: 0, perMock: {} };
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
const raw = JSON.parse(readFileSync(statsFile, 'utf8'));
|
|
307
|
+
return {
|
|
308
|
+
hits: raw.hits_total || 0,
|
|
309
|
+
misses: raw.misses_total || 0,
|
|
310
|
+
perMock: raw.perMock || {},
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
return { hits: 0, misses: 0, perMock: {} };
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
const cleanup = () => {
|
|
318
|
+
try {
|
|
319
|
+
rmSync(configDir, { recursive: true, force: true });
|
|
320
|
+
}
|
|
321
|
+
catch { /* swallow — best effort */ }
|
|
322
|
+
};
|
|
323
|
+
return {
|
|
324
|
+
settingsFile,
|
|
325
|
+
...(hasFakeMcp && { mcpConfigFile }),
|
|
326
|
+
env: { OMK_MOCKS_FILE: mocksFile },
|
|
327
|
+
readStats,
|
|
328
|
+
cleanup,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function parseMcpToolName(toolName) {
|
|
332
|
+
if (!toolName.startsWith('mcp__'))
|
|
333
|
+
return null;
|
|
334
|
+
const rest = toolName.slice('mcp__'.length);
|
|
335
|
+
const sep = rest.lastIndexOf('__');
|
|
336
|
+
if (sep <= 0 || sep === rest.length - 2)
|
|
337
|
+
return null;
|
|
338
|
+
return { serverName: rest.slice(0, sep), toolName: rest.slice(sep + 2) };
|
|
339
|
+
}
|
|
340
|
+
function collectFakeMcpServers(mocks) {
|
|
341
|
+
const servers = new Map();
|
|
342
|
+
for (const mock of mocks) {
|
|
343
|
+
const parsed = parseMcpToolName(mock.tool);
|
|
344
|
+
if (!parsed)
|
|
345
|
+
continue;
|
|
346
|
+
const tools = servers.get(parsed.serverName) ?? new Set();
|
|
347
|
+
tools.add(parsed.toolName);
|
|
348
|
+
servers.set(parsed.serverName, tools);
|
|
349
|
+
}
|
|
350
|
+
return servers;
|
|
351
|
+
}
|
|
352
|
+
function fakeMcpServerSource() {
|
|
353
|
+
return `#!/usr/bin/env node
|
|
354
|
+
const fs = require('fs');
|
|
355
|
+
const path = require('path');
|
|
356
|
+
const readline = require('readline');
|
|
357
|
+
const serverName = process.argv[2];
|
|
358
|
+
const mocksFile = process.env.OMK_MOCKS_FILE;
|
|
359
|
+
const rl = readline.createInterface({ input: process.stdin });
|
|
360
|
+
|
|
361
|
+
function send(obj) { process.stdout.write(JSON.stringify(obj) + '\\n'); }
|
|
362
|
+
function globMatch(pattern, value) {
|
|
363
|
+
const escaped = pattern.replace(/[.+?^\${}()|[\\]\\\\]/g, '\\\\$&');
|
|
364
|
+
return new RegExp('^' + escaped.replace(/\\*/g, '.*') + '$', 's').test(value);
|
|
365
|
+
}
|
|
366
|
+
function arraysDeepEqual(a, b) {
|
|
367
|
+
if (a.length !== b.length) return false;
|
|
368
|
+
for (let i = 0; i < a.length; i++) if (!deepEqual(a[i], b[i])) return false;
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
function deepEqual(a, b) {
|
|
372
|
+
if (a === b) return true;
|
|
373
|
+
if (Array.isArray(a) && Array.isArray(b)) return arraysDeepEqual(a, b);
|
|
374
|
+
if (typeof a === 'object' && a !== null && typeof b === 'object' && b !== null && !Array.isArray(a) && !Array.isArray(b)) {
|
|
375
|
+
const ak = Object.keys(a), bk = Object.keys(b);
|
|
376
|
+
if (ak.length !== bk.length) return false;
|
|
377
|
+
for (const k of ak) if (!deepEqual(a[k], b[k])) return false;
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
function matchesInputSubset(expected, actual) {
|
|
383
|
+
if (typeof actual !== 'object' || actual === null) return false;
|
|
384
|
+
for (const k of Object.keys(expected)) {
|
|
385
|
+
const v = expected[k];
|
|
386
|
+
if (Array.isArray(v)) {
|
|
387
|
+
if (!Array.isArray(actual[k]) || !arraysDeepEqual(v, actual[k])) return false;
|
|
388
|
+
} else if (typeof v === 'object' && v !== null) {
|
|
389
|
+
if (!matchesInputSubset(v, actual[k])) return false;
|
|
390
|
+
} else if (actual[k] !== v) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
function anyStringContains(obj, needle) {
|
|
397
|
+
if (typeof obj === 'string') return obj.toLowerCase().includes(needle);
|
|
398
|
+
if (Array.isArray(obj)) return obj.some((item) => anyStringContains(item, needle));
|
|
399
|
+
if (typeof obj === 'object' && obj !== null) return Object.values(obj).some((v) => anyStringContains(v, needle));
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
function isMockHit(mock, toolName, toolInput) {
|
|
403
|
+
if (mock.tool !== '*' && mock.tool !== toolName) return false;
|
|
404
|
+
const m = mock.match;
|
|
405
|
+
if (!m) return true;
|
|
406
|
+
const ti = toolInput || {};
|
|
407
|
+
if (m.input !== undefined && !matchesInputSubset(m.input, toolInput)) return false;
|
|
408
|
+
if (m.input_contains !== undefined && !anyStringContains(toolInput, String(m.input_contains).toLowerCase())) return false;
|
|
409
|
+
if (m.command_glob !== undefined && (typeof ti.command !== 'string' || !globMatch(m.command_glob, ti.command))) return false;
|
|
410
|
+
if (m.url !== undefined && ti.url !== m.url) return false;
|
|
411
|
+
if (m.url_glob !== undefined && (typeof ti.url !== 'string' || !globMatch(m.url_glob, ti.url))) return false;
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
function stringifyReturn(r) { return typeof r === 'string' ? r : JSON.stringify(r); }
|
|
415
|
+
function resolveMockReturn(mock, hitCount, baseDir) {
|
|
416
|
+
if (mock.return_seq && hitCount < mock.return_seq.length) return stringifyReturn(mock.return_seq[hitCount]);
|
|
417
|
+
if (mock.return !== undefined) return stringifyReturn(mock.return);
|
|
418
|
+
if (mock.return_file) {
|
|
419
|
+
const fpath = path.isAbsolute(mock.return_file) ? mock.return_file : path.resolve(baseDir || process.cwd(), mock.return_file);
|
|
420
|
+
if (!fs.existsSync(fpath)) return '[omk-mock-error] return_file not found: ' + fpath;
|
|
421
|
+
return fs.readFileSync(fpath, 'utf8');
|
|
422
|
+
}
|
|
423
|
+
return '';
|
|
424
|
+
}
|
|
425
|
+
function loadConfig() {
|
|
426
|
+
if (!mocksFile || !fs.existsSync(mocksFile)) return { mocks: [], strict: false };
|
|
427
|
+
return JSON.parse(fs.readFileSync(mocksFile, 'utf8'));
|
|
428
|
+
}
|
|
429
|
+
function toolNameFromFullName(fullName) {
|
|
430
|
+
const prefix = 'mcp__' + serverName + '__';
|
|
431
|
+
return fullName.startsWith(prefix) ? fullName.slice(prefix.length) : null;
|
|
432
|
+
}
|
|
433
|
+
function inferJsonSchema(value) {
|
|
434
|
+
if (typeof value === 'boolean') return { type: 'boolean' };
|
|
435
|
+
if (typeof value === 'number') return { type: 'number' };
|
|
436
|
+
if (Array.isArray(value)) return { type: 'array' };
|
|
437
|
+
if (typeof value === 'object' && value !== null) return { type: 'object', additionalProperties: true };
|
|
438
|
+
return { type: 'string' };
|
|
439
|
+
}
|
|
440
|
+
function schemaForTool(name, mocks) {
|
|
441
|
+
const properties = {};
|
|
442
|
+
const required = [];
|
|
443
|
+
for (const m of mocks) {
|
|
444
|
+
if (toolNameFromFullName(m.tool) !== name) continue;
|
|
445
|
+
const input = m.match && m.match.input;
|
|
446
|
+
if (typeof input !== 'object' || input === null || Array.isArray(input)) continue;
|
|
447
|
+
for (const k of Object.keys(input)) {
|
|
448
|
+
properties[k] = inferJsonSchema(input[k]);
|
|
449
|
+
if (!required.includes(k)) required.push(k);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (name === 'message') {
|
|
453
|
+
for (const k of ['action', 'channel', 'target', 'message']) {
|
|
454
|
+
if (!properties[k]) properties[k] = { type: 'string' };
|
|
455
|
+
if (!required.includes(k)) required.push(k);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return { type: 'object', properties, required, additionalProperties: true };
|
|
459
|
+
}
|
|
460
|
+
function listTools() {
|
|
461
|
+
const cfg = loadConfig();
|
|
462
|
+
const names = new Set();
|
|
463
|
+
const mocks = cfg.mocks || [];
|
|
464
|
+
for (const m of mocks) {
|
|
465
|
+
const n = toolNameFromFullName(m.tool);
|
|
466
|
+
if (n) names.add(n);
|
|
467
|
+
}
|
|
468
|
+
return Array.from(names).map((name) => ({
|
|
469
|
+
name,
|
|
470
|
+
description: 'omk fake MCP tool for ' + serverName + '/' + name,
|
|
471
|
+
inputSchema: schemaForTool(name, mocks),
|
|
472
|
+
}));
|
|
473
|
+
}
|
|
474
|
+
function recordHit(mockKey) {
|
|
475
|
+
if (!mocksFile) return;
|
|
476
|
+
const statsFile = path.join(path.dirname(mocksFile), 'hits.json');
|
|
477
|
+
let stats = { perMock: {}, hits_total: 0, misses_total: 0 };
|
|
478
|
+
try { if (fs.existsSync(statsFile)) stats = JSON.parse(fs.readFileSync(statsFile, 'utf8')); } catch {}
|
|
479
|
+
if (!stats.perMock) stats.perMock = {};
|
|
480
|
+
stats.perMock[mockKey] = (stats.perMock[mockKey] || 0) + 1;
|
|
481
|
+
stats.hits_total = (stats.hits_total || 0) + 1;
|
|
482
|
+
fs.writeFileSync(statsFile, JSON.stringify(stats));
|
|
483
|
+
}
|
|
484
|
+
function recordMiss() {
|
|
485
|
+
if (!mocksFile) return;
|
|
486
|
+
const statsFile = path.join(path.dirname(mocksFile), 'hits.json');
|
|
487
|
+
let stats = { perMock: {}, hits_total: 0, misses_total: 0 };
|
|
488
|
+
try { if (fs.existsSync(statsFile)) stats = JSON.parse(fs.readFileSync(statsFile, 'utf8')); } catch {}
|
|
489
|
+
stats.misses_total = (stats.misses_total || 0) + 1;
|
|
490
|
+
fs.writeFileSync(statsFile, JSON.stringify(stats));
|
|
491
|
+
}
|
|
492
|
+
const hitCounters = new Map();
|
|
493
|
+
function callTool(name, args) {
|
|
494
|
+
const cfg = loadConfig();
|
|
495
|
+
const fullName = 'mcp__' + serverName + '__' + name;
|
|
496
|
+
const mocks = cfg.mocks || [];
|
|
497
|
+
const baseDir = cfg.baseDir;
|
|
498
|
+
const ord = new Map();
|
|
499
|
+
for (const m of mocks) ord.set(m.tool, 0);
|
|
500
|
+
for (let i = 0; i < mocks.length; i++) {
|
|
501
|
+
const m = mocks[i];
|
|
502
|
+
ord.set(m.tool, (ord.get(m.tool) || 0) + 1);
|
|
503
|
+
if (isMockHit(m, fullName, args || {})) {
|
|
504
|
+
const key = fullName + ':' + ord.get(m.tool);
|
|
505
|
+
recordHit(key);
|
|
506
|
+
const c = hitCounters.get(i) || 0;
|
|
507
|
+
const result = resolveMockReturn(m, c, baseDir);
|
|
508
|
+
hitCounters.set(i, c + 1);
|
|
509
|
+
return result;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
recordMiss();
|
|
513
|
+
if (cfg.strict) return '[omk-mock-strict] unmocked ' + fullName + ' call blocked';
|
|
514
|
+
return '';
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
rl.on('line', (line) => {
|
|
518
|
+
let msg;
|
|
519
|
+
try { msg = JSON.parse(line); } catch { return; }
|
|
520
|
+
const id = msg.id;
|
|
521
|
+
if (msg.method === 'initialize') {
|
|
522
|
+
send({ jsonrpc: '2.0', id, result: { protocolVersion: '2024-11-05', capabilities: { tools: {} }, serverInfo: { name: 'omk-fake-' + serverName, version: '0.0.1' } } });
|
|
523
|
+
} else if (msg.method === 'notifications/initialized') {
|
|
524
|
+
} else if (msg.method === 'tools/list') {
|
|
525
|
+
send({ jsonrpc: '2.0', id, result: { tools: listTools() } });
|
|
526
|
+
} else if (msg.method === 'tools/call') {
|
|
527
|
+
const result = callTool(msg.params && msg.params.name, msg.params && msg.params.arguments);
|
|
528
|
+
send({ jsonrpc: '2.0', id, result: { content: [{ type: 'text', text: result }] } });
|
|
529
|
+
} else if (id !== undefined) {
|
|
530
|
+
send({ jsonrpc: '2.0', id, result: {} });
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
`;
|
|
534
|
+
}
|
|
535
|
+
let _hookTemplate = null;
|
|
536
|
+
function readMockHookTemplate() {
|
|
537
|
+
if (_hookTemplate)
|
|
538
|
+
return _hookTemplate;
|
|
539
|
+
// hook 跟本文件共置在 src/eval-core/(开发模式)或 dist/src/eval-core/(npm 安装模式),
|
|
540
|
+
// build script 把 mock-hook.cjs 复制到 dist/。读 sibling 路径就行,不再依赖外层 assets/。
|
|
541
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
542
|
+
const hookPath = resolve(here, 'mock-hook.cjs');
|
|
543
|
+
if (!existsSync(hookPath)) {
|
|
544
|
+
throw new Error(`omk-mock: mock-hook.cjs not found at ${hookPath}. ` +
|
|
545
|
+
`如果是从源码运行,确认 src/eval-core/mock-hook.cjs 存在;如果是 npm 安装,` +
|
|
546
|
+
`package 漏发了 hook,提 issue 并附 omk 版本。`);
|
|
547
|
+
}
|
|
548
|
+
_hookTemplate = readFileSync(hookPath, 'utf8');
|
|
549
|
+
return _hookTemplate;
|
|
550
|
+
}
|
|
551
|
+
// 测试用 export:供 packaging smoke test 验证 hook 能被解析
|
|
552
|
+
export const _readMockHookTemplateForTest = readMockHookTemplate;
|
|
553
|
+
// ─── 工具:在不影响主目录的前提下创建临时 dir(测试也要)─────────────
|
|
554
|
+
export function _testMakeTempConfigDir() {
|
|
555
|
+
const dir = mkdtempSync(join(tmpdir(), 'omk-mocks-test-'));
|
|
556
|
+
mkdirSync(dir, { recursive: true });
|
|
557
|
+
return dir;
|
|
558
|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ema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAe,aAAa,EAAE,cAAc,EAA0B,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/eval-core/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAe,aAAa,EAAE,cAAc,EAA0B,MAAM,mBAAmB,CAAC;AA4BrI;;GAEG;AACH,UAAU,mBAAmB;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CACvK;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,aAAa,CA8FxI;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,cAAc,CAsH5E"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Single source of truth for object structures used across runner, renderer, and server.
|
|
4
4
|
*/
|
|
5
5
|
import { computeJudgeAgreement } from '../grading/judge.js';
|
|
6
|
+
import { safeSliceForJson } from '../util/safe-slice.js';
|
|
6
7
|
function ratioToScore(ratio) {
|
|
7
8
|
return Number((1 + ratio * 4).toFixed(2));
|
|
8
9
|
}
|
|
@@ -11,15 +12,15 @@ const MAX_TOOL_OUTPUT = 1000;
|
|
|
11
12
|
function truncateTurns(turns) {
|
|
12
13
|
return turns.map((t) => ({
|
|
13
14
|
...t,
|
|
14
|
-
content: t.content
|
|
15
|
+
content: safeSliceForJson(t.content, MAX_TURN_CONTENT),
|
|
15
16
|
...(t.toolCalls && { toolCalls: truncateToolCalls(t.toolCalls) }),
|
|
16
17
|
}));
|
|
17
18
|
}
|
|
18
19
|
function truncateToolCalls(toolCalls) {
|
|
19
20
|
return toolCalls.map((tc) => ({
|
|
20
21
|
...tc,
|
|
21
|
-
output: typeof tc.output === 'string'
|
|
22
|
-
? tc.output
|
|
22
|
+
output: typeof tc.output === 'string'
|
|
23
|
+
? safeSliceForJson(tc.output, MAX_TOOL_OUTPUT)
|
|
23
24
|
: tc.output,
|
|
24
25
|
}));
|
|
25
26
|
}
|
|
@@ -49,7 +50,11 @@ export function buildVariantResult(execResult, gradeResult, options) {
|
|
|
49
50
|
cacheCreationTokens: execResult.cacheCreationTokens,
|
|
50
51
|
execCostUSD,
|
|
51
52
|
judgeCostUSD,
|
|
52
|
-
|
|
53
|
+
// 初值 = exec + judge。diagnostic 在 evaluation-execution.ts 跑完后会把
|
|
54
|
+
// diagnostic.costUSD 加回 `variantResult.costUSD` 并写入 `diagnosticCostUSD` —
|
|
55
|
+
// 让 per-sample budget 检查跟 summary.totalCostUSD 都按"三段合计"语义工作。
|
|
56
|
+
// 没有 failed assertion 的 sample 不触发 diagnostic,这里就是最终值。
|
|
57
|
+
costUSD: execCostUSD + judgeCostUSD,
|
|
53
58
|
// 透传 executor 是否报告了 cost。undefined 当 reported(向后兼容)。
|
|
54
59
|
// false 时 renderer 应显示「—」而不是 $0.0000;codex 0.125 binary 不报 cost。
|
|
55
60
|
...(execResult.costReportedByExecutor === false && { costReportedByExecutor: false }),
|
|
@@ -103,10 +108,11 @@ export function buildVariantResult(execResult, gradeResult, options) {
|
|
|
103
108
|
};
|
|
104
109
|
})()),
|
|
105
110
|
...(options?.factCheck && options.factCheck.totalCount > 0 && { factCheck: options.factCheck }),
|
|
106
|
-
outputPreview: execResult.output ? execResult.output
|
|
111
|
+
outputPreview: execResult.output ? safeSliceForJson(execResult.output, 200, '') : null,
|
|
107
112
|
...(execResult.output && { fullOutput: execResult.output }),
|
|
108
113
|
...(execResult.turns && execResult.turns.length > 0 && { turns: truncateTurns(execResult.turns) }),
|
|
109
114
|
...(execResult.toolCalls && execResult.toolCalls.length > 0 && { toolCalls: truncateToolCalls(execResult.toolCalls) }),
|
|
115
|
+
...(execResult.mockStats && { mockStats: execResult.mockStats }),
|
|
110
116
|
timing: { execMs, gradeMs, totalMs: execMs + gradeMs },
|
|
111
117
|
};
|
|
112
118
|
}
|
|
@@ -131,6 +137,13 @@ export function buildVariantSummary(entries) {
|
|
|
131
137
|
totalCostUSD: ok.reduce((s, e) => s + (e.costUSD || 0), 0),
|
|
132
138
|
totalExecCostUSD: ok.reduce((s, e) => s + (e.execCostUSD || 0), 0),
|
|
133
139
|
totalJudgeCostUSD: ok.reduce((s, e) => s + (e.judgeCostUSD || 0), 0),
|
|
140
|
+
// diagnostic 触发概率 = 有 failed assertion 的 sample 比例,大多数 ok variant 是 0。
|
|
141
|
+
// 把字段做成 optional + "全是 0 时省略" 是为了让旧 report-roundtrip 测试 / 报告 diff
|
|
142
|
+
// 在没 diagnostic 的运行下看不到新字段,跨版本对比器不需要兼容 "0 vs missing"。
|
|
143
|
+
...(() => {
|
|
144
|
+
const total = ok.reduce((s, e) => s + (e.diagnosticCostUSD || 0), 0);
|
|
145
|
+
return total > 0 ? { totalDiagnosticCostUSD: Number(total.toFixed(6)) } : {};
|
|
146
|
+
})(),
|
|
134
147
|
avgCostPerSample: ok.length > 0 ? Number((ok.reduce((s, e) => s + (e.costUSD || 0), 0) / ok.length).toFixed(6)) : 0,
|
|
135
148
|
// 任一 sample(含失败 sample)exec cost 未报告 → variant 整体标 false。
|
|
136
149
|
// 用 entries 而不是 ok:codex 全 error 的场景 ok=[],但 entries 里 every 个都是
|