skillfit 0.9.0 → 0.10.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 +41 -15
- package/README.zh-CN.md +41 -15
- package/benches/README.md +23 -0
- package/benches/contrib/README.md +1 -0
- package/benches/contrib/oss-skill-independent/README.md +60 -0
- package/benches/contrib/oss-skill-independent/bench.json +79 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/Readme.md +1015 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/esm.mjs +15 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/index.js +27 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/argument.js +147 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/command.js +1944 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/error.js +45 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/help.js +396 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/option.js +208 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/suggestSimilar.js +100 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/package.json +63 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/typings/index.d.ts +774 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/typings/index.test-d.ts +416 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/upstream-package.json +69 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/Readme.md +1149 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/esm.mjs +16 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/index.js +24 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/argument.js +149 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/command.js +2662 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/error.js +39 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/help.js +713 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/option.js +367 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/suggestSimilar.js +101 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/package.json +71 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/esm.d.mts +3 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/index.d.ts +1045 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/index.test-d.ts +737 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/upstream-package.json +82 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/index.d.ts +40 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/index.js +68 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/package.json +54 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/readme.md +99 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/upstream-package.json +54 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/index.js +67 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/package.json +46 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/index.js +132 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/package.json +57 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/readme.md +181 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/upstream-package.json +58 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/index.js +84 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/package.json +48 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/index.js +116 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/package.json +60 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/readme.md +170 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/upstream-package.json +60 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/index.d.ts +149 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/index.js +93 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/package.json +52 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/readme.md +192 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/upstream-package.json +52 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/index.js +114 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/package.json +48 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/readme.md +158 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/upstream-package.json +48 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/index.js +122 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/package.json +50 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/readme.md +190 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/upstream-package.json +50 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/Readme.md +1015 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/esm.mjs +15 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/index.js +27 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/argument.js +147 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/command.js +1948 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/error.js +45 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/help.js +396 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/option.js +208 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/suggestSimilar.js +100 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/package.json +63 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/typings/index.d.ts +774 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/typings/index.test-d.ts +416 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/upstream-package.json +69 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/Readme.md +1149 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/esm.mjs +16 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/index.js +24 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/argument.js +149 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/command.js +2666 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/error.js +39 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/help.js +713 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/option.js +367 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/suggestSimilar.js +101 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/package.json +71 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/esm.d.mts +3 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/index.d.ts +1045 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/index.test-d.ts +737 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/upstream-package.json +82 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/async-hooks-stub.js +15 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/index.d.ts +40 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/index.js +71 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/package.json +61 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/readme.md +99 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/regression.test.mjs +6 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/upstream-package.json +54 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/index.js +67 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/package.json +46 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/index.js +148 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/package.json +57 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/readme.md +181 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/upstream-package.json +58 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/index.js +84 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/package.json +48 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-commander-async-listener-order.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-commander-output-isolation.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-limit-async-context.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-limit-map-iteration-rejection.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-throttle-sync-throw.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-custom-timers.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-infinity-abort.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-rejection-listener.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/index.js +121 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/package.json +60 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/readme.md +170 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/regression.test.mjs +6 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/upstream-package.json +60 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/index.d.ts +149 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/index.js +95 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/package.json +52 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/readme.md +192 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/upstream-package.json +52 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/index.js +114 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/package.json +48 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/readme.md +158 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/upstream-package.json +48 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/index.js +122 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/package.json +50 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/readme.md +190 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/upstream-package.json +50 -0
- package/benches/contrib/oss-skill-independent/prompts/commander-async-listener-order.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/commander-output-isolation.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/limit-async-context.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/limit-map-iteration-rejection.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/throttle-sync-throw.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/timeout-custom-timers.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/timeout-infinity-abort.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/timeout-rejection-listener.md +3 -0
- package/benches/contrib/oss-skill-independent/provenance.json +1903 -0
- package/benches/contrib/oss-skill-independent/task-specs.json +63 -0
- package/benches/contrib/oss-skill-independent/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/verifiers/cases.mjs +197 -0
- package/benches/contrib/oss-skill-independent/verifiers/commander-async-listener-order.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/commander-output-isolation.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/grade.mjs +48 -0
- package/benches/contrib/oss-skill-independent/verifiers/limit-async-context.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/limit-map-iteration-rejection.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/probe.mjs +16 -0
- package/benches/contrib/oss-skill-independent/verifiers/regression-evidence.mjs +105 -0
- package/benches/contrib/oss-skill-independent/verifiers/test-reporter.mjs +29 -0
- package/benches/contrib/oss-skill-independent/verifiers/throttle-sync-throw.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/timeout-custom-timers.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/timeout-infinity-abort.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/timeout-rejection-listener.mjs +1 -0
- package/dist/cli.js +166 -53
- package/dist/commands/bench-check-json.test.js +221 -0
- package/dist/commands/bench-check-report.js +48 -0
- package/dist/commands/bench-command-template.js +129 -0
- package/dist/commands/bench-manage.js +91 -0
- package/dist/commands/bench-manage.test.js +87 -0
- package/dist/commands/bench.js +68 -38
- package/dist/commands/bench.test.js +101 -0
- package/dist/commands/eval-component.js +17 -0
- package/dist/commands/eval-export.js +152 -0
- package/dist/commands/eval-export.test.js +122 -0
- package/dist/commands/eval.js +14 -3
- package/dist/commands/eval.test.js +58 -1
- package/dist/harness/bench.js +21 -2
- package/dist/harness/eval-audit.js +42 -4
- package/dist/harness/eval-budget.js +51 -0
- package/dist/harness/eval-budget.test.js +210 -0
- package/dist/harness/eval-component.test.js +36 -0
- package/dist/harness/eval-contract.js +5 -1
- package/dist/harness/replay-package.js +85 -0
- package/dist/harness/runner.js +22 -1
- package/docs/bench-authoring.md +40 -0
- package/docs/bench-check-json.md +115 -0
- package/docs/case-management.md +65 -0
- package/docs/eval-component.md +60 -49
- package/docs/examples/check-receiver-mechanism-proposal.mjs +124 -0
- package/docs/examples/prepare-native-diff-probe.mjs +75 -0
- package/docs/examples/reproduce-independent-comparison-budget.mjs +73 -0
- package/docs/first-real-eval.md +6 -0
- package/docs/growth-roadmap-2026-10.md +57 -93
- package/docs/metrics.md +21 -0
- package/docs/plans/2026-10-14-evidence-and-release-sequence.md +30 -13
- package/docs/plans/2026-10-15-independent-comparison-budget.json +1769 -0
- package/docs/plans/2026-10-15-independent-comparison-inputs.json +373 -0
- package/docs/plans/2026-10-15-independent-comparison-proposal.md +177 -0
- package/docs/plans/2026-10-15-native-diff-mechanism.md +105 -0
- package/docs/plans/2026-10-15-receiver-mechanism-proposal.json +342 -0
- package/docs/plans/2026-10-15-receiver-mechanism-proposal.md +146 -0
- package/docs/plans/2026-10-15-receiver-mechanism-verification.json +105 -0
- package/docs/plans/2026-10-16-case-workflow-and-release.md +30 -0
- package/docs/releases/0.10.0.md +45 -0
- package/docs/releases/0.9.0-verification.json +38 -0
- package/docs/releases/0.9.0.md +20 -3
- package/docs/releases/0.9.1-first-publication.json +249 -0
- package/docs/releases/0.9.1-verification.json +122 -0
- package/docs/releases/0.9.1.md +65 -0
- package/docs/releases/trusted-publishing.md +114 -0
- package/docs/replay-packages.md +88 -0
- package/docs/schemas/bench-check.schema.json +109 -0
- package/docs/schemas/eval-request.schema.json +12 -0
- package/docs/sharing-results.md +6 -0
- package/docs/skill-evaluation-evidence.md +52 -0
- package/evidence/2026-10-15-diagnosing-receiver-correction.md +140 -0
- package/evidence/2026-10-15-independent-comparison-regression-stop.md +162 -0
- package/evidence/2026-10-15-independent-offline-readiness.md +144 -0
- package/evidence/2026-10-15-native-diff-mechanism.md +196 -0
- package/evidence/2026-10-15-receiver-mechanism-stop.md +154 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/README.md +35 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/expected.json +577 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/receiver-contract.test.mjs +138 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/replay.mjs +127 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/verification.json +105 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/README.md +32 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/checks.json +32 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/verification.json +25 -0
- package/evidence/artifacts/2026-10-15-independent-offline-readiness/README.md +17 -0
- package/evidence/artifacts/2026-10-15-independent-offline-readiness/verification.json +1548 -0
- package/evidence/artifacts/2026-10-15-native-diff-mechanism/README.md +48 -0
- package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/README.md +38 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/checks.json +118 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/verification.json +36 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/LICENSE +21 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/SKILL.md +51 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/agents/openai.yaml +3 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/scripts/hitl-loop.template.sh +44 -0
- package/package.json +3 -3
- package/skills/skillfit/SKILL.md +17 -5
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CommanderError class
|
|
5
|
+
* @class
|
|
6
|
+
*/
|
|
7
|
+
class CommanderError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Constructs the CommanderError class
|
|
10
|
+
* @param {number} exitCode suggested exit code which could be used with process.exit
|
|
11
|
+
* @param {string} code an id string representing the error
|
|
12
|
+
* @param {string} message human-readable description of the error
|
|
13
|
+
* @constructor
|
|
14
|
+
*/
|
|
15
|
+
constructor(exitCode, code, message) {
|
|
16
|
+
super(message);
|
|
17
|
+
// properly capture stack trace in Node.js
|
|
18
|
+
Error.captureStackTrace(this, this.constructor);
|
|
19
|
+
this.name = this.constructor.name;
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.exitCode = exitCode;
|
|
22
|
+
this.nestedError = undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* InvalidArgumentError class
|
|
28
|
+
* @class
|
|
29
|
+
*/
|
|
30
|
+
class InvalidArgumentError extends CommanderError {
|
|
31
|
+
/**
|
|
32
|
+
* Constructs the InvalidArgumentError class
|
|
33
|
+
* @param {string} [message] explanation of why argument is invalid
|
|
34
|
+
* @constructor
|
|
35
|
+
*/
|
|
36
|
+
constructor(message) {
|
|
37
|
+
super(1, 'commander.invalidArgument', message);
|
|
38
|
+
// properly capture stack trace in Node.js
|
|
39
|
+
Error.captureStackTrace(this, this.constructor);
|
|
40
|
+
this.name = this.constructor.name;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.CommanderError = CommanderError;
|
|
45
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
const { humanReadableArgName } = require('./argument.js');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TypeScript import types for JSDoc, used by Visual Studio Code IntelliSense and `npm run typescript-checkJS`
|
|
5
|
+
* https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import-types
|
|
6
|
+
* @typedef { import("./argument.js").Argument } Argument
|
|
7
|
+
* @typedef { import("./command.js").Command } Command
|
|
8
|
+
* @typedef { import("./option.js").Option } Option
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// @ts-check
|
|
12
|
+
|
|
13
|
+
// Although this is a class, methods are static in style to allow override using subclass or just functions.
|
|
14
|
+
class Help {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.helpWidth = undefined;
|
|
17
|
+
this.sortSubcommands = false;
|
|
18
|
+
this.sortOptions = false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
|
|
23
|
+
*
|
|
24
|
+
* @param {Command} cmd
|
|
25
|
+
* @returns {Command[]}
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
visibleCommands(cmd) {
|
|
29
|
+
const visibleCommands = cmd.commands.filter(cmd => !cmd._hidden);
|
|
30
|
+
if (cmd._hasImplicitHelpCommand()) {
|
|
31
|
+
// Create a command matching the implicit help command.
|
|
32
|
+
const [, helpName, helpArgs] = cmd._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
|
|
33
|
+
const helpCommand = cmd.createCommand(helpName)
|
|
34
|
+
.helpOption(false);
|
|
35
|
+
helpCommand.description(cmd._helpCommandDescription);
|
|
36
|
+
if (helpArgs) helpCommand.arguments(helpArgs);
|
|
37
|
+
visibleCommands.push(helpCommand);
|
|
38
|
+
}
|
|
39
|
+
if (this.sortSubcommands) {
|
|
40
|
+
visibleCommands.sort((a, b) => {
|
|
41
|
+
// @ts-ignore: overloaded return type
|
|
42
|
+
return a.name().localeCompare(b.name());
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return visibleCommands;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
|
|
50
|
+
*
|
|
51
|
+
* @param {Command} cmd
|
|
52
|
+
* @returns {Option[]}
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
visibleOptions(cmd) {
|
|
56
|
+
const visibleOptions = cmd.options.filter((option) => !option.hidden);
|
|
57
|
+
// Implicit help
|
|
58
|
+
const showShortHelpFlag = cmd._hasHelpOption && cmd._helpShortFlag && !cmd._findOption(cmd._helpShortFlag);
|
|
59
|
+
const showLongHelpFlag = cmd._hasHelpOption && !cmd._findOption(cmd._helpLongFlag);
|
|
60
|
+
if (showShortHelpFlag || showLongHelpFlag) {
|
|
61
|
+
let helpOption;
|
|
62
|
+
if (!showShortHelpFlag) {
|
|
63
|
+
helpOption = cmd.createOption(cmd._helpLongFlag, cmd._helpDescription);
|
|
64
|
+
} else if (!showLongHelpFlag) {
|
|
65
|
+
helpOption = cmd.createOption(cmd._helpShortFlag, cmd._helpDescription);
|
|
66
|
+
} else {
|
|
67
|
+
helpOption = cmd.createOption(cmd._helpFlags, cmd._helpDescription);
|
|
68
|
+
}
|
|
69
|
+
visibleOptions.push(helpOption);
|
|
70
|
+
}
|
|
71
|
+
if (this.sortOptions) {
|
|
72
|
+
const getSortKey = (option) => {
|
|
73
|
+
// WYSIWYG for order displayed in help with short before long, no special handling for negated.
|
|
74
|
+
return option.short ? option.short.replace(/^-/, '') : option.long.replace(/^--/, '');
|
|
75
|
+
};
|
|
76
|
+
visibleOptions.sort((a, b) => {
|
|
77
|
+
return getSortKey(a).localeCompare(getSortKey(b));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return visibleOptions;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get an array of the arguments if any have a description.
|
|
85
|
+
*
|
|
86
|
+
* @param {Command} cmd
|
|
87
|
+
* @returns {Argument[]}
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
visibleArguments(cmd) {
|
|
91
|
+
// Side effect! Apply the legacy descriptions before the arguments are displayed.
|
|
92
|
+
if (cmd._argsDescription) {
|
|
93
|
+
cmd._args.forEach(argument => {
|
|
94
|
+
argument.description = argument.description || cmd._argsDescription[argument.name()] || '';
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// If there are any arguments with a description then return all the arguments.
|
|
99
|
+
if (cmd._args.find(argument => argument.description)) {
|
|
100
|
+
return cmd._args;
|
|
101
|
+
};
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get the command term to show in the list of subcommands.
|
|
107
|
+
*
|
|
108
|
+
* @param {Command} cmd
|
|
109
|
+
* @returns {string}
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
subcommandTerm(cmd) {
|
|
113
|
+
// Legacy. Ignores custom usage string, and nested commands.
|
|
114
|
+
const args = cmd._args.map(arg => humanReadableArgName(arg)).join(' ');
|
|
115
|
+
return cmd._name +
|
|
116
|
+
(cmd._aliases[0] ? '|' + cmd._aliases[0] : '') +
|
|
117
|
+
(cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option
|
|
118
|
+
(args ? ' ' + args : '');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Get the option term to show in the list of options.
|
|
123
|
+
*
|
|
124
|
+
* @param {Option} option
|
|
125
|
+
* @returns {string}
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
optionTerm(option) {
|
|
129
|
+
return option.flags;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Get the argument term to show in the list of arguments.
|
|
134
|
+
*
|
|
135
|
+
* @param {Argument} argument
|
|
136
|
+
* @returns {string}
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
argumentTerm(argument) {
|
|
140
|
+
return argument.name();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get the longest command term length.
|
|
145
|
+
*
|
|
146
|
+
* @param {Command} cmd
|
|
147
|
+
* @param {Help} helper
|
|
148
|
+
* @returns {number}
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
longestSubcommandTermLength(cmd, helper) {
|
|
152
|
+
return helper.visibleCommands(cmd).reduce((max, command) => {
|
|
153
|
+
return Math.max(max, helper.subcommandTerm(command).length);
|
|
154
|
+
}, 0);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Get the longest option term length.
|
|
159
|
+
*
|
|
160
|
+
* @param {Command} cmd
|
|
161
|
+
* @param {Help} helper
|
|
162
|
+
* @returns {number}
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
longestOptionTermLength(cmd, helper) {
|
|
166
|
+
return helper.visibleOptions(cmd).reduce((max, option) => {
|
|
167
|
+
return Math.max(max, helper.optionTerm(option).length);
|
|
168
|
+
}, 0);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get the longest argument term length.
|
|
173
|
+
*
|
|
174
|
+
* @param {Command} cmd
|
|
175
|
+
* @param {Help} helper
|
|
176
|
+
* @returns {number}
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
longestArgumentTermLength(cmd, helper) {
|
|
180
|
+
return helper.visibleArguments(cmd).reduce((max, argument) => {
|
|
181
|
+
return Math.max(max, helper.argumentTerm(argument).length);
|
|
182
|
+
}, 0);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Get the command usage to be displayed at the top of the built-in help.
|
|
187
|
+
*
|
|
188
|
+
* @param {Command} cmd
|
|
189
|
+
* @returns {string}
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
commandUsage(cmd) {
|
|
193
|
+
// Usage
|
|
194
|
+
let cmdName = cmd._name;
|
|
195
|
+
if (cmd._aliases[0]) {
|
|
196
|
+
cmdName = cmdName + '|' + cmd._aliases[0];
|
|
197
|
+
}
|
|
198
|
+
let parentCmdNames = '';
|
|
199
|
+
for (let parentCmd = cmd.parent; parentCmd; parentCmd = parentCmd.parent) {
|
|
200
|
+
parentCmdNames = parentCmd.name() + ' ' + parentCmdNames;
|
|
201
|
+
}
|
|
202
|
+
return parentCmdNames + cmdName + ' ' + cmd.usage();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Get the description for the command.
|
|
207
|
+
*
|
|
208
|
+
* @param {Command} cmd
|
|
209
|
+
* @returns {string}
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
commandDescription(cmd) {
|
|
213
|
+
// @ts-ignore: overloaded return type
|
|
214
|
+
return cmd.description();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Get the command description to show in the list of subcommands.
|
|
219
|
+
*
|
|
220
|
+
* @param {Command} cmd
|
|
221
|
+
* @returns {string}
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
subcommandDescription(cmd) {
|
|
225
|
+
// @ts-ignore: overloaded return type
|
|
226
|
+
return cmd.description();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Get the option description to show in the list of options.
|
|
231
|
+
*
|
|
232
|
+
* @param {Option} option
|
|
233
|
+
* @return {string}
|
|
234
|
+
*/
|
|
235
|
+
|
|
236
|
+
optionDescription(option) {
|
|
237
|
+
const extraInfo = [];
|
|
238
|
+
// Some of these do not make sense for negated boolean and suppress for backwards compatibility.
|
|
239
|
+
|
|
240
|
+
if (option.argChoices && !option.negate) {
|
|
241
|
+
extraInfo.push(
|
|
242
|
+
// use stringify to match the display of the default value
|
|
243
|
+
`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`);
|
|
244
|
+
}
|
|
245
|
+
if (option.defaultValue !== undefined && !option.negate) {
|
|
246
|
+
extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
|
|
247
|
+
}
|
|
248
|
+
if (option.envVar !== undefined) {
|
|
249
|
+
extraInfo.push(`env: ${option.envVar}`);
|
|
250
|
+
}
|
|
251
|
+
if (extraInfo.length > 0) {
|
|
252
|
+
return `${option.description} (${extraInfo.join(', ')})`;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return option.description;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Get the argument description to show in the list of arguments.
|
|
260
|
+
*
|
|
261
|
+
* @param {Argument} argument
|
|
262
|
+
* @return {string}
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
argumentDescription(argument) {
|
|
266
|
+
const extraInfo = [];
|
|
267
|
+
if (argument.argChoices) {
|
|
268
|
+
extraInfo.push(
|
|
269
|
+
// use stringify to match the display of the default value
|
|
270
|
+
`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`);
|
|
271
|
+
}
|
|
272
|
+
if (argument.defaultValue !== undefined) {
|
|
273
|
+
extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
|
|
274
|
+
}
|
|
275
|
+
if (extraInfo.length > 0) {
|
|
276
|
+
const extraDescripton = `(${extraInfo.join(', ')})`;
|
|
277
|
+
if (argument.description) {
|
|
278
|
+
return `${argument.description} ${extraDescripton}`;
|
|
279
|
+
}
|
|
280
|
+
return extraDescripton;
|
|
281
|
+
}
|
|
282
|
+
return argument.description;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Generate the built-in help text.
|
|
287
|
+
*
|
|
288
|
+
* @param {Command} cmd
|
|
289
|
+
* @param {Help} helper
|
|
290
|
+
* @returns {string}
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
formatHelp(cmd, helper) {
|
|
294
|
+
const termWidth = helper.padWidth(cmd, helper);
|
|
295
|
+
const helpWidth = helper.helpWidth || 80;
|
|
296
|
+
const itemIndentWidth = 2;
|
|
297
|
+
const itemSeparatorWidth = 2; // between term and description
|
|
298
|
+
function formatItem(term, description) {
|
|
299
|
+
if (description) {
|
|
300
|
+
const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
|
|
301
|
+
return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
|
|
302
|
+
}
|
|
303
|
+
return term;
|
|
304
|
+
};
|
|
305
|
+
function formatList(textArray) {
|
|
306
|
+
return textArray.join('\n').replace(/^/gm, ' '.repeat(itemIndentWidth));
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Usage
|
|
310
|
+
let output = [`Usage: ${helper.commandUsage(cmd)}`, ''];
|
|
311
|
+
|
|
312
|
+
// Description
|
|
313
|
+
const commandDescription = helper.commandDescription(cmd);
|
|
314
|
+
if (commandDescription.length > 0) {
|
|
315
|
+
output = output.concat([commandDescription, '']);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Arguments
|
|
319
|
+
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
|
320
|
+
return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
|
|
321
|
+
});
|
|
322
|
+
if (argumentList.length > 0) {
|
|
323
|
+
output = output.concat(['Arguments:', formatList(argumentList), '']);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Options
|
|
327
|
+
const optionList = helper.visibleOptions(cmd).map((option) => {
|
|
328
|
+
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
|
|
329
|
+
});
|
|
330
|
+
if (optionList.length > 0) {
|
|
331
|
+
output = output.concat(['Options:', formatList(optionList), '']);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Commands
|
|
335
|
+
const commandList = helper.visibleCommands(cmd).map((cmd) => {
|
|
336
|
+
return formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd));
|
|
337
|
+
});
|
|
338
|
+
if (commandList.length > 0) {
|
|
339
|
+
output = output.concat(['Commands:', formatList(commandList), '']);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return output.join('\n');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Calculate the pad width from the maximum term length.
|
|
347
|
+
*
|
|
348
|
+
* @param {Command} cmd
|
|
349
|
+
* @param {Help} helper
|
|
350
|
+
* @returns {number}
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
padWidth(cmd, helper) {
|
|
354
|
+
return Math.max(
|
|
355
|
+
helper.longestOptionTermLength(cmd, helper),
|
|
356
|
+
helper.longestSubcommandTermLength(cmd, helper),
|
|
357
|
+
helper.longestArgumentTermLength(cmd, helper)
|
|
358
|
+
);
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Wrap the given string to width characters per line, with lines after the first indented.
|
|
363
|
+
* Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
|
|
364
|
+
*
|
|
365
|
+
* @param {string} str
|
|
366
|
+
* @param {number} width
|
|
367
|
+
* @param {number} indent
|
|
368
|
+
* @param {number} [minColumnWidth=40]
|
|
369
|
+
* @return {string}
|
|
370
|
+
*
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
wrap(str, width, indent, minColumnWidth = 40) {
|
|
374
|
+
// Detect manually wrapped and indented strings by searching for line breaks
|
|
375
|
+
// followed by multiple spaces/tabs.
|
|
376
|
+
if (str.match(/[\n]\s+/)) return str;
|
|
377
|
+
// Do not wrap if not enough room for a wrapped column of text (as could end up with a word per line).
|
|
378
|
+
const columnWidth = width - indent;
|
|
379
|
+
if (columnWidth < minColumnWidth) return str;
|
|
380
|
+
|
|
381
|
+
const leadingStr = str.substr(0, indent);
|
|
382
|
+
const columnText = str.substr(indent);
|
|
383
|
+
|
|
384
|
+
const indentString = ' '.repeat(indent);
|
|
385
|
+
const regex = new RegExp('.{1,' + (columnWidth - 1) + '}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)', 'g');
|
|
386
|
+
const lines = columnText.match(regex) || [];
|
|
387
|
+
return leadingStr + lines.map((line, i) => {
|
|
388
|
+
if (line.slice(-1) === '\n') {
|
|
389
|
+
line = line.slice(0, line.length - 1);
|
|
390
|
+
}
|
|
391
|
+
return ((i > 0) ? indentString : '') + line.trimRight();
|
|
392
|
+
}).join('\n');
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
exports.Help = Help;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
const { InvalidArgumentError } = require('./error.js');
|
|
2
|
+
|
|
3
|
+
// @ts-check
|
|
4
|
+
|
|
5
|
+
class Option {
|
|
6
|
+
/**
|
|
7
|
+
* Initialize a new `Option` with the given `flags` and `description`.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} flags
|
|
10
|
+
* @param {string} [description]
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
constructor(flags, description) {
|
|
14
|
+
this.flags = flags;
|
|
15
|
+
this.description = description || '';
|
|
16
|
+
|
|
17
|
+
this.required = flags.includes('<'); // A value must be supplied when the option is specified.
|
|
18
|
+
this.optional = flags.includes('['); // A value is optional when the option is specified.
|
|
19
|
+
// variadic test ignores <value,...> et al which might be used to describe custom splitting of single argument
|
|
20
|
+
this.variadic = /\w\.\.\.[>\]]$/.test(flags); // The option can take multiple values.
|
|
21
|
+
this.mandatory = false; // The option must have a value after parsing, which usually means it must be specified on command line.
|
|
22
|
+
const optionFlags = splitOptionFlags(flags);
|
|
23
|
+
this.short = optionFlags.shortFlag;
|
|
24
|
+
this.long = optionFlags.longFlag;
|
|
25
|
+
this.negate = false;
|
|
26
|
+
if (this.long) {
|
|
27
|
+
this.negate = this.long.startsWith('--no-');
|
|
28
|
+
}
|
|
29
|
+
this.defaultValue = undefined;
|
|
30
|
+
this.defaultValueDescription = undefined;
|
|
31
|
+
this.envVar = undefined;
|
|
32
|
+
this.parseArg = undefined;
|
|
33
|
+
this.hidden = false;
|
|
34
|
+
this.argChoices = undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
39
|
+
*
|
|
40
|
+
* @param {any} value
|
|
41
|
+
* @param {string} [description]
|
|
42
|
+
* @return {Option}
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
default(value, description) {
|
|
46
|
+
this.defaultValue = value;
|
|
47
|
+
this.defaultValueDescription = description;
|
|
48
|
+
return this;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Set environment variable to check for option value.
|
|
53
|
+
* Priority order of option values is default < env < cli
|
|
54
|
+
*
|
|
55
|
+
* @param {string} name
|
|
56
|
+
* @return {Option}
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
env(name) {
|
|
60
|
+
this.envVar = name;
|
|
61
|
+
return this;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Set the custom handler for processing CLI option arguments into option values.
|
|
66
|
+
*
|
|
67
|
+
* @param {Function} [fn]
|
|
68
|
+
* @return {Option}
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
argParser(fn) {
|
|
72
|
+
this.parseArg = fn;
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Whether the option is mandatory and must have a value after parsing.
|
|
78
|
+
*
|
|
79
|
+
* @param {boolean} [mandatory=true]
|
|
80
|
+
* @return {Option}
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
makeOptionMandatory(mandatory = true) {
|
|
84
|
+
this.mandatory = !!mandatory;
|
|
85
|
+
return this;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Hide option in help.
|
|
90
|
+
*
|
|
91
|
+
* @param {boolean} [hide=true]
|
|
92
|
+
* @return {Option}
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
hideHelp(hide = true) {
|
|
96
|
+
this.hidden = !!hide;
|
|
97
|
+
return this;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @api private
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
_concatValue(value, previous) {
|
|
105
|
+
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
106
|
+
return [value];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return previous.concat(value);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Only allow option value to be one of choices.
|
|
114
|
+
*
|
|
115
|
+
* @param {string[]} values
|
|
116
|
+
* @return {Option}
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
choices(values) {
|
|
120
|
+
this.argChoices = values;
|
|
121
|
+
this.parseArg = (arg, previous) => {
|
|
122
|
+
if (!values.includes(arg)) {
|
|
123
|
+
throw new InvalidArgumentError(`Allowed choices are ${values.join(', ')}.`);
|
|
124
|
+
}
|
|
125
|
+
if (this.variadic) {
|
|
126
|
+
return this._concatValue(arg, previous);
|
|
127
|
+
}
|
|
128
|
+
return arg;
|
|
129
|
+
};
|
|
130
|
+
return this;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Return option name.
|
|
135
|
+
*
|
|
136
|
+
* @return {string}
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
name() {
|
|
140
|
+
if (this.long) {
|
|
141
|
+
return this.long.replace(/^--/, '');
|
|
142
|
+
}
|
|
143
|
+
return this.short.replace(/^-/, '');
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Return option name, in a camelcase format that can be used
|
|
148
|
+
* as a object attribute key.
|
|
149
|
+
*
|
|
150
|
+
* @return {string}
|
|
151
|
+
* @api private
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
attributeName() {
|
|
155
|
+
return camelcase(this.name().replace(/^no-/, ''));
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Check if `arg` matches the short or long flag.
|
|
160
|
+
*
|
|
161
|
+
* @param {string} arg
|
|
162
|
+
* @return {boolean}
|
|
163
|
+
* @api private
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
is(arg) {
|
|
167
|
+
return this.short === arg || this.long === arg;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Convert string from kebab-case to camelCase.
|
|
173
|
+
*
|
|
174
|
+
* @param {string} str
|
|
175
|
+
* @return {string}
|
|
176
|
+
* @api private
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
function camelcase(str) {
|
|
180
|
+
return str.split('-').reduce((str, word) => {
|
|
181
|
+
return str + word[0].toUpperCase() + word.slice(1);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Split the short and long flag out of something like '-m,--mixed <value>'
|
|
187
|
+
*
|
|
188
|
+
* @api private
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
function splitOptionFlags(flags) {
|
|
192
|
+
let shortFlag;
|
|
193
|
+
let longFlag;
|
|
194
|
+
// Use original very loose parsing to maintain backwards compatibility for now,
|
|
195
|
+
// which allowed for example unintended `-sw, --short-word` [sic].
|
|
196
|
+
const flagParts = flags.split(/[ |,]+/);
|
|
197
|
+
if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) shortFlag = flagParts.shift();
|
|
198
|
+
longFlag = flagParts.shift();
|
|
199
|
+
// Add support for lone short flag without significantly changing parsing!
|
|
200
|
+
if (!shortFlag && /^-[^-]$/.test(longFlag)) {
|
|
201
|
+
shortFlag = longFlag;
|
|
202
|
+
longFlag = undefined;
|
|
203
|
+
}
|
|
204
|
+
return { shortFlag, longFlag };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
exports.Option = Option;
|
|
208
|
+
exports.splitOptionFlags = splitOptionFlags;
|