skillfit 0.9.1 → 0.10.1

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.
Files changed (332) hide show
  1. package/README.md +48 -14
  2. package/README.zh-CN.md +48 -14
  3. package/benches/README.md +23 -0
  4. package/benches/contrib/README.md +1 -0
  5. package/benches/contrib/oss-skill-independent/README.md +60 -0
  6. package/benches/contrib/oss-skill-independent/bench.json +79 -0
  7. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/LICENSE +22 -0
  8. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/Readme.md +1015 -0
  9. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/esm.mjs +15 -0
  10. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/index.js +27 -0
  11. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/argument.js +147 -0
  12. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/command.js +1944 -0
  13. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/error.js +45 -0
  14. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/help.js +396 -0
  15. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/option.js +208 -0
  16. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/suggestSimilar.js +100 -0
  17. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/package-support.json +16 -0
  18. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/package.json +63 -0
  19. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/test-clock.mjs +65 -0
  20. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/test.mjs +4 -0
  21. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/typings/index.d.ts +774 -0
  22. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/typings/index.test-d.ts +416 -0
  23. package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/upstream-package.json +69 -0
  24. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/LICENSE +22 -0
  25. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/Readme.md +1149 -0
  26. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/esm.mjs +16 -0
  27. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/index.js +24 -0
  28. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/argument.js +149 -0
  29. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/command.js +2662 -0
  30. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/error.js +39 -0
  31. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/help.js +713 -0
  32. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/option.js +367 -0
  33. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/suggestSimilar.js +101 -0
  34. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/package-support.json +16 -0
  35. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/package.json +71 -0
  36. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/test-clock.mjs +65 -0
  37. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/test.mjs +4 -0
  38. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/esm.d.mts +3 -0
  39. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/index.d.ts +1045 -0
  40. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/index.test-d.ts +737 -0
  41. package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/upstream-package.json +82 -0
  42. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/index.d.ts +40 -0
  43. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/index.js +68 -0
  44. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/license +9 -0
  45. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/package.json +54 -0
  46. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/readme.md +99 -0
  47. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/test-clock.mjs +65 -0
  48. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/test.mjs +4 -0
  49. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/upstream-package.json +54 -0
  50. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/index.js +67 -0
  51. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/license +9 -0
  52. package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/package.json +46 -0
  53. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/index.d.ts +136 -0
  54. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/index.js +132 -0
  55. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/license +9 -0
  56. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/package.json +57 -0
  57. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/readme.md +181 -0
  58. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/test-clock.mjs +65 -0
  59. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/test.mjs +4 -0
  60. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/upstream-package.json +58 -0
  61. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/index.js +84 -0
  62. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/license +9 -0
  63. package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/package.json +48 -0
  64. package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/index.d.ts +136 -0
  65. package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/index.js +116 -0
  66. package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/license +9 -0
  67. package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/package.json +60 -0
  68. package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/readme.md +170 -0
  69. package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/test-clock.mjs +65 -0
  70. package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/test.mjs +4 -0
  71. package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/upstream-package.json +60 -0
  72. package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/index.d.ts +149 -0
  73. package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/index.js +93 -0
  74. package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/license +9 -0
  75. package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/package.json +52 -0
  76. package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/readme.md +192 -0
  77. package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/test-clock.mjs +65 -0
  78. package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/test.mjs +4 -0
  79. package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/upstream-package.json +52 -0
  80. package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/index.d.ts +151 -0
  81. package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/index.js +114 -0
  82. package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/license +9 -0
  83. package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/package.json +48 -0
  84. package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/readme.md +158 -0
  85. package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/test-clock.mjs +65 -0
  86. package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/test.mjs +4 -0
  87. package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/upstream-package.json +48 -0
  88. package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/index.d.ts +151 -0
  89. package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/index.js +122 -0
  90. package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/license +9 -0
  91. package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/package.json +50 -0
  92. package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/readme.md +190 -0
  93. package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/test-clock.mjs +65 -0
  94. package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/test.mjs +4 -0
  95. package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/upstream-package.json +50 -0
  96. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/LICENSE +22 -0
  97. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/Readme.md +1015 -0
  98. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/esm.mjs +15 -0
  99. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/index.js +27 -0
  100. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/argument.js +147 -0
  101. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/command.js +1948 -0
  102. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/error.js +45 -0
  103. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/help.js +396 -0
  104. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/option.js +208 -0
  105. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/suggestSimilar.js +100 -0
  106. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/package-support.json +16 -0
  107. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/package.json +63 -0
  108. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/regression.test.mjs +5 -0
  109. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/test-clock.mjs +65 -0
  110. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/test.mjs +4 -0
  111. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/typings/index.d.ts +774 -0
  112. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/typings/index.test-d.ts +416 -0
  113. package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/upstream-package.json +69 -0
  114. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/LICENSE +22 -0
  115. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/Readme.md +1149 -0
  116. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/esm.mjs +16 -0
  117. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/index.js +24 -0
  118. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/argument.js +149 -0
  119. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/command.js +2666 -0
  120. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/error.js +39 -0
  121. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/help.js +713 -0
  122. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/option.js +367 -0
  123. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/suggestSimilar.js +101 -0
  124. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/package-support.json +16 -0
  125. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/package.json +71 -0
  126. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/regression.test.mjs +5 -0
  127. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/test-clock.mjs +65 -0
  128. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/test.mjs +4 -0
  129. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/esm.d.mts +3 -0
  130. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/index.d.ts +1045 -0
  131. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/index.test-d.ts +737 -0
  132. package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/upstream-package.json +82 -0
  133. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/async-hooks-stub.js +15 -0
  134. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/index.d.ts +40 -0
  135. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/index.js +71 -0
  136. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/license +9 -0
  137. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/package.json +61 -0
  138. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/readme.md +99 -0
  139. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/regression.test.mjs +6 -0
  140. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/test-clock.mjs +65 -0
  141. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/test.mjs +4 -0
  142. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/upstream-package.json +54 -0
  143. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/index.js +67 -0
  144. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/license +9 -0
  145. package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/package.json +46 -0
  146. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/index.d.ts +136 -0
  147. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/index.js +148 -0
  148. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/license +9 -0
  149. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/package.json +57 -0
  150. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/readme.md +181 -0
  151. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/regression.test.mjs +5 -0
  152. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/test-clock.mjs +65 -0
  153. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/test.mjs +4 -0
  154. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/upstream-package.json +58 -0
  155. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/index.js +84 -0
  156. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/license +9 -0
  157. package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/package.json +48 -0
  158. package/benches/contrib/oss-skill-independent/ground-truth/oracle-commander-async-listener-order.mjs +1 -0
  159. package/benches/contrib/oss-skill-independent/ground-truth/oracle-commander-output-isolation.mjs +1 -0
  160. package/benches/contrib/oss-skill-independent/ground-truth/oracle-limit-async-context.mjs +1 -0
  161. package/benches/contrib/oss-skill-independent/ground-truth/oracle-limit-map-iteration-rejection.mjs +1 -0
  162. package/benches/contrib/oss-skill-independent/ground-truth/oracle-throttle-sync-throw.mjs +1 -0
  163. package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-custom-timers.mjs +1 -0
  164. package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-infinity-abort.mjs +1 -0
  165. package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-rejection-listener.mjs +1 -0
  166. package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/index.d.ts +136 -0
  167. package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/index.js +121 -0
  168. package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/license +9 -0
  169. package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/package.json +60 -0
  170. package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/readme.md +170 -0
  171. package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/regression.test.mjs +6 -0
  172. package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/test-clock.mjs +65 -0
  173. package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/test.mjs +4 -0
  174. package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/upstream-package.json +60 -0
  175. package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/index.d.ts +149 -0
  176. package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/index.js +95 -0
  177. package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/license +9 -0
  178. package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/package.json +52 -0
  179. package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/readme.md +192 -0
  180. package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/regression.test.mjs +5 -0
  181. package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/test-clock.mjs +65 -0
  182. package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/test.mjs +4 -0
  183. package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/upstream-package.json +52 -0
  184. package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/index.d.ts +151 -0
  185. package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/index.js +114 -0
  186. package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/license +9 -0
  187. package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/package.json +48 -0
  188. package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/readme.md +158 -0
  189. package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/regression.test.mjs +5 -0
  190. package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/test-clock.mjs +65 -0
  191. package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/test.mjs +4 -0
  192. package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/upstream-package.json +48 -0
  193. package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/index.d.ts +151 -0
  194. package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/index.js +122 -0
  195. package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/license +9 -0
  196. package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/package.json +50 -0
  197. package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/readme.md +190 -0
  198. package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/regression.test.mjs +5 -0
  199. package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/test-clock.mjs +65 -0
  200. package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/test.mjs +4 -0
  201. package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/upstream-package.json +50 -0
  202. package/benches/contrib/oss-skill-independent/prompts/commander-async-listener-order.md +3 -0
  203. package/benches/contrib/oss-skill-independent/prompts/commander-output-isolation.md +3 -0
  204. package/benches/contrib/oss-skill-independent/prompts/limit-async-context.md +3 -0
  205. package/benches/contrib/oss-skill-independent/prompts/limit-map-iteration-rejection.md +3 -0
  206. package/benches/contrib/oss-skill-independent/prompts/throttle-sync-throw.md +3 -0
  207. package/benches/contrib/oss-skill-independent/prompts/timeout-custom-timers.md +3 -0
  208. package/benches/contrib/oss-skill-independent/prompts/timeout-infinity-abort.md +3 -0
  209. package/benches/contrib/oss-skill-independent/prompts/timeout-rejection-listener.md +3 -0
  210. package/benches/contrib/oss-skill-independent/provenance.json +1903 -0
  211. package/benches/contrib/oss-skill-independent/task-specs.json +63 -0
  212. package/benches/contrib/oss-skill-independent/test-clock.mjs +65 -0
  213. package/benches/contrib/oss-skill-independent/verifiers/cases.mjs +197 -0
  214. package/benches/contrib/oss-skill-independent/verifiers/commander-async-listener-order.mjs +1 -0
  215. package/benches/contrib/oss-skill-independent/verifiers/commander-output-isolation.mjs +1 -0
  216. package/benches/contrib/oss-skill-independent/verifiers/grade.mjs +48 -0
  217. package/benches/contrib/oss-skill-independent/verifiers/limit-async-context.mjs +1 -0
  218. package/benches/contrib/oss-skill-independent/verifiers/limit-map-iteration-rejection.mjs +1 -0
  219. package/benches/contrib/oss-skill-independent/verifiers/probe.mjs +16 -0
  220. package/benches/contrib/oss-skill-independent/verifiers/regression-evidence.mjs +105 -0
  221. package/benches/contrib/oss-skill-independent/verifiers/test-reporter.mjs +29 -0
  222. package/benches/contrib/oss-skill-independent/verifiers/throttle-sync-throw.mjs +1 -0
  223. package/benches/contrib/oss-skill-independent/verifiers/timeout-custom-timers.mjs +1 -0
  224. package/benches/contrib/oss-skill-independent/verifiers/timeout-infinity-abort.mjs +1 -0
  225. package/benches/contrib/oss-skill-independent/verifiers/timeout-rejection-listener.mjs +1 -0
  226. package/dist/cli.js +183 -64
  227. package/dist/commands/bench-check-json.test.js +221 -0
  228. package/dist/commands/bench-check-report.js +48 -0
  229. package/dist/commands/bench-command-template.js +129 -0
  230. package/dist/commands/bench-manage.js +91 -0
  231. package/dist/commands/bench-manage.test.js +87 -0
  232. package/dist/commands/bench.js +166 -128
  233. package/dist/commands/bench.test.js +101 -0
  234. package/dist/commands/eval-component.js +25 -1
  235. package/dist/commands/eval-export.js +178 -0
  236. package/dist/commands/eval-export.test.js +279 -0
  237. package/dist/commands/eval-interruption.test.js +238 -0
  238. package/dist/commands/eval-preflight.js +61 -0
  239. package/dist/commands/eval-preflight.test.js +239 -0
  240. package/dist/commands/eval-report.js +44 -13
  241. package/dist/commands/eval-report.test.js +2 -2
  242. package/dist/commands/eval.js +94 -61
  243. package/dist/commands/eval.test.js +58 -1
  244. package/dist/harness/bench.js +21 -2
  245. package/dist/harness/eval-audit.js +45 -5
  246. package/dist/harness/eval-budget.js +51 -0
  247. package/dist/harness/eval-budget.test.js +212 -0
  248. package/dist/harness/eval-component.test.js +36 -0
  249. package/dist/harness/eval-contract.js +5 -1
  250. package/dist/harness/executors/api.js +10 -1
  251. package/dist/harness/executors/api.test.js +43 -0
  252. package/dist/harness/executors/cli.js +24 -3
  253. package/dist/harness/experiment-session.js +60 -9
  254. package/dist/harness/experiment-session.test.js +43 -1
  255. package/dist/harness/input-snapshot.js +150 -0
  256. package/dist/harness/interruption.js +48 -0
  257. package/dist/harness/interruption.test.js +31 -0
  258. package/dist/harness/replay-package.js +85 -0
  259. package/dist/harness/runner.js +74 -15
  260. package/dist/harness/trigger.js +20 -4
  261. package/docs/bench-authoring.md +40 -0
  262. package/docs/bench-check-json.md +122 -0
  263. package/docs/case-management.md +65 -0
  264. package/docs/eval-case-preflight.md +110 -0
  265. package/docs/eval-component.md +88 -49
  266. package/docs/eval-costs.md +9 -0
  267. package/docs/evaluation-input-snapshots.md +124 -0
  268. package/docs/evaluation-interruption.md +89 -0
  269. package/docs/evaluation-reports.md +49 -0
  270. package/docs/examples/check-receiver-mechanism-proposal.mjs +124 -0
  271. package/docs/examples/prepare-native-diff-probe.mjs +75 -0
  272. package/docs/examples/reproduce-independent-comparison-budget.mjs +73 -0
  273. package/docs/experiment-workflow.md +9 -2
  274. package/docs/first-real-eval.md +10 -1
  275. package/docs/growth-roadmap-2026-10.md +62 -93
  276. package/docs/metrics.md +52 -0
  277. package/docs/plans/2026-10-14-evidence-and-release-sequence.md +29 -12
  278. package/docs/plans/2026-10-15-independent-comparison-budget.json +1769 -0
  279. package/docs/plans/2026-10-15-independent-comparison-inputs.json +373 -0
  280. package/docs/plans/2026-10-15-independent-comparison-proposal.md +177 -0
  281. package/docs/plans/2026-10-15-native-diff-mechanism.md +105 -0
  282. package/docs/plans/2026-10-15-receiver-mechanism-proposal.json +342 -0
  283. package/docs/plans/2026-10-15-receiver-mechanism-proposal.md +146 -0
  284. package/docs/plans/2026-10-15-receiver-mechanism-verification.json +105 -0
  285. package/docs/plans/2026-10-16-case-workflow-and-release.md +49 -0
  286. package/docs/releases/0.10.0-ci-registry-install.json +140 -0
  287. package/docs/releases/0.10.0-feature-smoke.json +22 -0
  288. package/docs/releases/0.10.0-feature-smoke.mjs +62 -0
  289. package/docs/releases/0.10.0-signatures.txt +7 -0
  290. package/docs/releases/0.10.0-verification.json +76 -0
  291. package/docs/releases/0.10.0.md +81 -0
  292. package/docs/releases/0.10.1-feature-smoke.mjs +95 -0
  293. package/docs/releases/0.10.1.md +38 -0
  294. package/docs/releases/0.9.1-first-publication.json +249 -0
  295. package/docs/releases/0.9.1-verification.json +122 -0
  296. package/docs/releases/0.9.1.md +33 -1
  297. package/docs/releases/trusted-publishing.md +61 -0
  298. package/docs/replay-packages.md +97 -0
  299. package/docs/schemas/bench-check.schema.json +109 -0
  300. package/docs/schemas/eval-preflight.schema.json +57 -0
  301. package/docs/schemas/eval-request.schema.json +12 -0
  302. package/docs/schemas/eval-result.schema.json +11 -0
  303. package/docs/sharing-results.md +11 -2
  304. package/docs/skill-evaluation-evidence.md +52 -0
  305. package/evidence/2026-10-15-diagnosing-receiver-correction.md +140 -0
  306. package/evidence/2026-10-15-independent-comparison-regression-stop.md +162 -0
  307. package/evidence/2026-10-15-independent-offline-readiness.md +144 -0
  308. package/evidence/2026-10-15-native-diff-mechanism.md +196 -0
  309. package/evidence/2026-10-15-receiver-mechanism-stop.md +154 -0
  310. package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/README.md +35 -0
  311. package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/expected.json +577 -0
  312. package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/receiver-contract.test.mjs +138 -0
  313. package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/replay.mjs +127 -0
  314. package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/verification.json +105 -0
  315. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/README.md +32 -0
  316. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/checks.json +32 -0
  317. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
  318. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/verification.json +25 -0
  319. package/evidence/artifacts/2026-10-15-independent-offline-readiness/README.md +17 -0
  320. package/evidence/artifacts/2026-10-15-independent-offline-readiness/verification.json +1548 -0
  321. package/evidence/artifacts/2026-10-15-native-diff-mechanism/README.md +48 -0
  322. package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
  323. package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/README.md +38 -0
  324. package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/checks.json +118 -0
  325. package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
  326. package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/verification.json +36 -0
  327. package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/LICENSE +21 -0
  328. package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/SKILL.md +51 -0
  329. package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/agents/openai.yaml +3 -0
  330. package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/scripts/hitl-loop.template.sh +44 -0
  331. package/package.json +1 -1
  332. package/skills/skillfit/SKILL.md +17 -5
@@ -0,0 +1,713 @@
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
+ // Although this is a class, methods are static in style to allow override using subclass or just functions.
12
+ class Help {
13
+ constructor() {
14
+ this.helpWidth = undefined;
15
+ this.minWidthToWrap = 40;
16
+ this.sortSubcommands = false;
17
+ this.sortOptions = false;
18
+ this.showGlobalOptions = false;
19
+ }
20
+
21
+ /**
22
+ * prepareContext is called by Commander after applying overrides from `Command.configureHelp()`
23
+ * and just before calling `formatHelp()`.
24
+ *
25
+ * Commander just uses the helpWidth and the rest is provided for optional use by more complex subclasses.
26
+ *
27
+ * @param {{ error?: boolean, helpWidth?: number, outputHasColors?: boolean }} contextOptions
28
+ */
29
+ prepareContext(contextOptions) {
30
+ this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
31
+ }
32
+
33
+ /**
34
+ * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
35
+ *
36
+ * @param {Command} cmd
37
+ * @returns {Command[]}
38
+ */
39
+
40
+ visibleCommands(cmd) {
41
+ const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
42
+ const helpCommand = cmd._getHelpCommand();
43
+ if (helpCommand && !helpCommand._hidden) {
44
+ visibleCommands.push(helpCommand);
45
+ }
46
+ if (this.sortSubcommands) {
47
+ visibleCommands.sort((a, b) => {
48
+ // @ts-ignore: because overloaded return type
49
+ return a.name().localeCompare(b.name());
50
+ });
51
+ }
52
+ return visibleCommands;
53
+ }
54
+
55
+ /**
56
+ * Compare options for sort.
57
+ *
58
+ * @param {Option} a
59
+ * @param {Option} b
60
+ * @returns {number}
61
+ */
62
+ compareOptions(a, b) {
63
+ const getSortKey = (option) => {
64
+ // WYSIWYG for order displayed in help. Short used for comparison if present. No special handling for negated.
65
+ return option.short
66
+ ? option.short.replace(/^-/, '')
67
+ : option.long.replace(/^--/, '');
68
+ };
69
+ return getSortKey(a).localeCompare(getSortKey(b));
70
+ }
71
+
72
+ /**
73
+ * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
74
+ *
75
+ * @param {Command} cmd
76
+ * @returns {Option[]}
77
+ */
78
+
79
+ visibleOptions(cmd) {
80
+ const visibleOptions = cmd.options.filter((option) => !option.hidden);
81
+ // Built-in help option.
82
+ const helpOption = cmd._getHelpOption();
83
+ if (helpOption && !helpOption.hidden) {
84
+ // Automatically hide conflicting flags. Bit dubious but a historical behaviour that is convenient for single-command programs.
85
+ const removeShort = helpOption.short && cmd._findOption(helpOption.short);
86
+ const removeLong = helpOption.long && cmd._findOption(helpOption.long);
87
+ if (!removeShort && !removeLong) {
88
+ visibleOptions.push(helpOption); // no changes needed
89
+ } else if (helpOption.long && !removeLong) {
90
+ visibleOptions.push(
91
+ cmd.createOption(helpOption.long, helpOption.description),
92
+ );
93
+ } else if (helpOption.short && !removeShort) {
94
+ visibleOptions.push(
95
+ cmd.createOption(helpOption.short, helpOption.description),
96
+ );
97
+ }
98
+ }
99
+ if (this.sortOptions) {
100
+ visibleOptions.sort(this.compareOptions);
101
+ }
102
+ return visibleOptions;
103
+ }
104
+
105
+ /**
106
+ * Get an array of the visible global options. (Not including help.)
107
+ *
108
+ * @param {Command} cmd
109
+ * @returns {Option[]}
110
+ */
111
+
112
+ visibleGlobalOptions(cmd) {
113
+ if (!this.showGlobalOptions) return [];
114
+
115
+ const globalOptions = [];
116
+ for (
117
+ let ancestorCmd = cmd.parent;
118
+ ancestorCmd;
119
+ ancestorCmd = ancestorCmd.parent
120
+ ) {
121
+ const visibleOptions = ancestorCmd.options.filter(
122
+ (option) => !option.hidden,
123
+ );
124
+ globalOptions.push(...visibleOptions);
125
+ }
126
+ if (this.sortOptions) {
127
+ globalOptions.sort(this.compareOptions);
128
+ }
129
+ return globalOptions;
130
+ }
131
+
132
+ /**
133
+ * Get an array of the arguments if any have a description.
134
+ *
135
+ * @param {Command} cmd
136
+ * @returns {Argument[]}
137
+ */
138
+
139
+ visibleArguments(cmd) {
140
+ // Side effect! Apply the legacy descriptions before the arguments are displayed.
141
+ if (cmd._argsDescription) {
142
+ cmd.registeredArguments.forEach((argument) => {
143
+ argument.description =
144
+ argument.description || cmd._argsDescription[argument.name()] || '';
145
+ });
146
+ }
147
+
148
+ // If there are any arguments with a description then return all the arguments.
149
+ if (cmd.registeredArguments.find((argument) => argument.description)) {
150
+ return cmd.registeredArguments;
151
+ }
152
+ return [];
153
+ }
154
+
155
+ /**
156
+ * Get the command term to show in the list of subcommands.
157
+ *
158
+ * @param {Command} cmd
159
+ * @returns {string}
160
+ */
161
+
162
+ subcommandTerm(cmd) {
163
+ // Legacy. Ignores custom usage string, and nested commands.
164
+ const args = cmd.registeredArguments
165
+ .map((arg) => humanReadableArgName(arg))
166
+ .join(' ');
167
+ return (
168
+ cmd._name +
169
+ (cmd._aliases[0] ? '|' + cmd._aliases[0] : '') +
170
+ (cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option
171
+ (args ? ' ' + args : '')
172
+ );
173
+ }
174
+
175
+ /**
176
+ * Get the option term to show in the list of options.
177
+ *
178
+ * @param {Option} option
179
+ * @returns {string}
180
+ */
181
+
182
+ optionTerm(option) {
183
+ return option.flags;
184
+ }
185
+
186
+ /**
187
+ * Get the argument term to show in the list of arguments.
188
+ *
189
+ * @param {Argument} argument
190
+ * @returns {string}
191
+ */
192
+
193
+ argumentTerm(argument) {
194
+ return argument.name();
195
+ }
196
+
197
+ /**
198
+ * Get the longest command term length.
199
+ *
200
+ * @param {Command} cmd
201
+ * @param {Help} helper
202
+ * @returns {number}
203
+ */
204
+
205
+ longestSubcommandTermLength(cmd, helper) {
206
+ return helper.visibleCommands(cmd).reduce((max, command) => {
207
+ return Math.max(
208
+ max,
209
+ this.displayWidth(
210
+ helper.styleSubcommandTerm(helper.subcommandTerm(command)),
211
+ ),
212
+ );
213
+ }, 0);
214
+ }
215
+
216
+ /**
217
+ * Get the longest option term length.
218
+ *
219
+ * @param {Command} cmd
220
+ * @param {Help} helper
221
+ * @returns {number}
222
+ */
223
+
224
+ longestOptionTermLength(cmd, helper) {
225
+ return helper.visibleOptions(cmd).reduce((max, option) => {
226
+ return Math.max(
227
+ max,
228
+ this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))),
229
+ );
230
+ }, 0);
231
+ }
232
+
233
+ /**
234
+ * Get the longest global option term length.
235
+ *
236
+ * @param {Command} cmd
237
+ * @param {Help} helper
238
+ * @returns {number}
239
+ */
240
+
241
+ longestGlobalOptionTermLength(cmd, helper) {
242
+ return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
243
+ return Math.max(
244
+ max,
245
+ this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))),
246
+ );
247
+ }, 0);
248
+ }
249
+
250
+ /**
251
+ * Get the longest argument term length.
252
+ *
253
+ * @param {Command} cmd
254
+ * @param {Help} helper
255
+ * @returns {number}
256
+ */
257
+
258
+ longestArgumentTermLength(cmd, helper) {
259
+ return helper.visibleArguments(cmd).reduce((max, argument) => {
260
+ return Math.max(
261
+ max,
262
+ this.displayWidth(
263
+ helper.styleArgumentTerm(helper.argumentTerm(argument)),
264
+ ),
265
+ );
266
+ }, 0);
267
+ }
268
+
269
+ /**
270
+ * Get the command usage to be displayed at the top of the built-in help.
271
+ *
272
+ * @param {Command} cmd
273
+ * @returns {string}
274
+ */
275
+
276
+ commandUsage(cmd) {
277
+ // Usage
278
+ let cmdName = cmd._name;
279
+ if (cmd._aliases[0]) {
280
+ cmdName = cmdName + '|' + cmd._aliases[0];
281
+ }
282
+ let ancestorCmdNames = '';
283
+ for (
284
+ let ancestorCmd = cmd.parent;
285
+ ancestorCmd;
286
+ ancestorCmd = ancestorCmd.parent
287
+ ) {
288
+ ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;
289
+ }
290
+ return ancestorCmdNames + cmdName + ' ' + cmd.usage();
291
+ }
292
+
293
+ /**
294
+ * Get the description for the command.
295
+ *
296
+ * @param {Command} cmd
297
+ * @returns {string}
298
+ */
299
+
300
+ commandDescription(cmd) {
301
+ // @ts-ignore: because overloaded return type
302
+ return cmd.description();
303
+ }
304
+
305
+ /**
306
+ * Get the subcommand summary to show in the list of subcommands.
307
+ * (Fallback to description for backwards compatibility.)
308
+ *
309
+ * @param {Command} cmd
310
+ * @returns {string}
311
+ */
312
+
313
+ subcommandDescription(cmd) {
314
+ // @ts-ignore: because overloaded return type
315
+ return cmd.summary() || cmd.description();
316
+ }
317
+
318
+ /**
319
+ * Get the option description to show in the list of options.
320
+ *
321
+ * @param {Option} option
322
+ * @return {string}
323
+ */
324
+
325
+ optionDescription(option) {
326
+ const extraInfo = [];
327
+
328
+ if (option.argChoices) {
329
+ extraInfo.push(
330
+ // use stringify to match the display of the default value
331
+ `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
332
+ );
333
+ }
334
+ if (option.defaultValue !== undefined) {
335
+ // default for boolean and negated more for programmer than end user,
336
+ // but show true/false for boolean option as may be for hand-rolled env or config processing.
337
+ const showDefault =
338
+ option.required ||
339
+ option.optional ||
340
+ (option.isBoolean() && typeof option.defaultValue === 'boolean');
341
+ if (showDefault) {
342
+ extraInfo.push(
343
+ `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`,
344
+ );
345
+ }
346
+ }
347
+ // preset for boolean and negated are more for programmer than end user
348
+ if (option.presetArg !== undefined && option.optional) {
349
+ extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
350
+ }
351
+ if (option.envVar !== undefined) {
352
+ extraInfo.push(`env: ${option.envVar}`);
353
+ }
354
+ if (extraInfo.length > 0) {
355
+ const extraDescription = `(${extraInfo.join(', ')})`;
356
+ if (option.description) {
357
+ return `${option.description} ${extraDescription}`;
358
+ }
359
+ return extraDescription;
360
+ }
361
+
362
+ return option.description;
363
+ }
364
+
365
+ /**
366
+ * Get the argument description to show in the list of arguments.
367
+ *
368
+ * @param {Argument} argument
369
+ * @return {string}
370
+ */
371
+
372
+ argumentDescription(argument) {
373
+ const extraInfo = [];
374
+ if (argument.argChoices) {
375
+ extraInfo.push(
376
+ // use stringify to match the display of the default value
377
+ `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
378
+ );
379
+ }
380
+ if (argument.defaultValue !== undefined) {
381
+ extraInfo.push(
382
+ `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`,
383
+ );
384
+ }
385
+ if (extraInfo.length > 0) {
386
+ const extraDescription = `(${extraInfo.join(', ')})`;
387
+ if (argument.description) {
388
+ return `${argument.description} ${extraDescription}`;
389
+ }
390
+ return extraDescription;
391
+ }
392
+ return argument.description;
393
+ }
394
+
395
+ /**
396
+ * Generate the built-in help text.
397
+ *
398
+ * @param {Command} cmd
399
+ * @param {Help} helper
400
+ * @returns {string}
401
+ */
402
+
403
+ formatHelp(cmd, helper) {
404
+ const termWidth = helper.padWidth(cmd, helper);
405
+ const helpWidth = helper.helpWidth ?? 80; // in case prepareContext() was not called
406
+
407
+ function callFormatItem(term, description) {
408
+ return helper.formatItem(term, termWidth, description, helper);
409
+ }
410
+
411
+ // Usage
412
+ let output = [
413
+ `${helper.styleTitle('Usage:')} ${helper.styleUsage(helper.commandUsage(cmd))}`,
414
+ '',
415
+ ];
416
+
417
+ // Description
418
+ const commandDescription = helper.commandDescription(cmd);
419
+ if (commandDescription.length > 0) {
420
+ output = output.concat([
421
+ helper.boxWrap(
422
+ helper.styleCommandDescription(commandDescription),
423
+ helpWidth,
424
+ ),
425
+ '',
426
+ ]);
427
+ }
428
+
429
+ // Arguments
430
+ const argumentList = helper.visibleArguments(cmd).map((argument) => {
431
+ return callFormatItem(
432
+ helper.styleArgumentTerm(helper.argumentTerm(argument)),
433
+ helper.styleArgumentDescription(helper.argumentDescription(argument)),
434
+ );
435
+ });
436
+ if (argumentList.length > 0) {
437
+ output = output.concat([
438
+ helper.styleTitle('Arguments:'),
439
+ ...argumentList,
440
+ '',
441
+ ]);
442
+ }
443
+
444
+ // Options
445
+ const optionList = helper.visibleOptions(cmd).map((option) => {
446
+ return callFormatItem(
447
+ helper.styleOptionTerm(helper.optionTerm(option)),
448
+ helper.styleOptionDescription(helper.optionDescription(option)),
449
+ );
450
+ });
451
+ if (optionList.length > 0) {
452
+ output = output.concat([
453
+ helper.styleTitle('Options:'),
454
+ ...optionList,
455
+ '',
456
+ ]);
457
+ }
458
+
459
+ if (helper.showGlobalOptions) {
460
+ const globalOptionList = helper
461
+ .visibleGlobalOptions(cmd)
462
+ .map((option) => {
463
+ return callFormatItem(
464
+ helper.styleOptionTerm(helper.optionTerm(option)),
465
+ helper.styleOptionDescription(helper.optionDescription(option)),
466
+ );
467
+ });
468
+ if (globalOptionList.length > 0) {
469
+ output = output.concat([
470
+ helper.styleTitle('Global Options:'),
471
+ ...globalOptionList,
472
+ '',
473
+ ]);
474
+ }
475
+ }
476
+
477
+ // Commands
478
+ const commandList = helper.visibleCommands(cmd).map((cmd) => {
479
+ return callFormatItem(
480
+ helper.styleSubcommandTerm(helper.subcommandTerm(cmd)),
481
+ helper.styleSubcommandDescription(helper.subcommandDescription(cmd)),
482
+ );
483
+ });
484
+ if (commandList.length > 0) {
485
+ output = output.concat([
486
+ helper.styleTitle('Commands:'),
487
+ ...commandList,
488
+ '',
489
+ ]);
490
+ }
491
+
492
+ return output.join('\n');
493
+ }
494
+
495
+ /**
496
+ * Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.
497
+ *
498
+ * @param {string} str
499
+ * @returns {number}
500
+ */
501
+ displayWidth(str) {
502
+ return stripColor(str).length;
503
+ }
504
+
505
+ /**
506
+ * Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
507
+ *
508
+ * @param {string} str
509
+ * @returns {string}
510
+ */
511
+ styleTitle(str) {
512
+ return str;
513
+ }
514
+
515
+ styleUsage(str) {
516
+ // Usage has lots of parts the user might like to color separately! Assume default usage string which is formed like:
517
+ // command subcommand [options] [command] <foo> [bar]
518
+ return str
519
+ .split(' ')
520
+ .map((word) => {
521
+ if (word === '[options]') return this.styleOptionText(word);
522
+ if (word === '[command]') return this.styleSubcommandText(word);
523
+ if (word[0] === '[' || word[0] === '<')
524
+ return this.styleArgumentText(word);
525
+ return this.styleCommandText(word); // Restrict to initial words?
526
+ })
527
+ .join(' ');
528
+ }
529
+ styleCommandDescription(str) {
530
+ return this.styleDescriptionText(str);
531
+ }
532
+ styleOptionDescription(str) {
533
+ return this.styleDescriptionText(str);
534
+ }
535
+ styleSubcommandDescription(str) {
536
+ return this.styleDescriptionText(str);
537
+ }
538
+ styleArgumentDescription(str) {
539
+ return this.styleDescriptionText(str);
540
+ }
541
+ styleDescriptionText(str) {
542
+ return str;
543
+ }
544
+ styleOptionTerm(str) {
545
+ return this.styleOptionText(str);
546
+ }
547
+ styleSubcommandTerm(str) {
548
+ // This is very like usage with lots of parts! Assume default string which is formed like:
549
+ // subcommand [options] <foo> [bar]
550
+ return str
551
+ .split(' ')
552
+ .map((word) => {
553
+ if (word === '[options]') return this.styleOptionText(word);
554
+ if (word[0] === '[' || word[0] === '<')
555
+ return this.styleArgumentText(word);
556
+ return this.styleSubcommandText(word); // Restrict to initial words?
557
+ })
558
+ .join(' ');
559
+ }
560
+ styleArgumentTerm(str) {
561
+ return this.styleArgumentText(str);
562
+ }
563
+ styleOptionText(str) {
564
+ return str;
565
+ }
566
+ styleArgumentText(str) {
567
+ return str;
568
+ }
569
+ styleSubcommandText(str) {
570
+ return str;
571
+ }
572
+ styleCommandText(str) {
573
+ return str;
574
+ }
575
+
576
+ /**
577
+ * Calculate the pad width from the maximum term length.
578
+ *
579
+ * @param {Command} cmd
580
+ * @param {Help} helper
581
+ * @returns {number}
582
+ */
583
+
584
+ padWidth(cmd, helper) {
585
+ return Math.max(
586
+ helper.longestOptionTermLength(cmd, helper),
587
+ helper.longestGlobalOptionTermLength(cmd, helper),
588
+ helper.longestSubcommandTermLength(cmd, helper),
589
+ helper.longestArgumentTermLength(cmd, helper),
590
+ );
591
+ }
592
+
593
+ /**
594
+ * Detect manually wrapped and indented strings by checking for line break followed by whitespace.
595
+ *
596
+ * @param {string} str
597
+ * @returns {boolean}
598
+ */
599
+ preformatted(str) {
600
+ return /\n[^\S\r\n]/.test(str);
601
+ }
602
+
603
+ /**
604
+ * Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
605
+ *
606
+ * So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
607
+ * TTT DDD DDDD
608
+ * DD DDD
609
+ *
610
+ * @param {string} term
611
+ * @param {number} termWidth
612
+ * @param {string} description
613
+ * @param {Help} helper
614
+ * @returns {string}
615
+ */
616
+ formatItem(term, termWidth, description, helper) {
617
+ const itemIndent = 2;
618
+ const itemIndentStr = ' '.repeat(itemIndent);
619
+ if (!description) return itemIndentStr + term;
620
+
621
+ // Pad the term out to a consistent width, so descriptions are aligned.
622
+ const paddedTerm = term.padEnd(
623
+ termWidth + term.length - helper.displayWidth(term),
624
+ );
625
+
626
+ // Format the description.
627
+ const spacerWidth = 2; // between term and description
628
+ const helpWidth = this.helpWidth ?? 80; // in case prepareContext() was not called
629
+ const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
630
+ let formattedDescription;
631
+ if (
632
+ remainingWidth < this.minWidthToWrap ||
633
+ helper.preformatted(description)
634
+ ) {
635
+ formattedDescription = description;
636
+ } else {
637
+ const wrappedDescription = helper.boxWrap(description, remainingWidth);
638
+ formattedDescription = wrappedDescription.replace(
639
+ /\n/g,
640
+ '\n' + ' '.repeat(termWidth + spacerWidth),
641
+ );
642
+ }
643
+
644
+ // Construct and overall indent.
645
+ return (
646
+ itemIndentStr +
647
+ paddedTerm +
648
+ ' '.repeat(spacerWidth) +
649
+ formattedDescription.replace(/\n/g, `\n${itemIndentStr}`)
650
+ );
651
+ }
652
+
653
+ /**
654
+ * Wrap a string at whitespace, preserving existing line breaks.
655
+ * Wrapping is skipped if the width is less than `minWidthToWrap`.
656
+ *
657
+ * @param {string} str
658
+ * @param {number} width
659
+ * @returns {string}
660
+ */
661
+ boxWrap(str, width) {
662
+ if (width < this.minWidthToWrap) return str;
663
+
664
+ const rawLines = str.split(/\r\n|\n/);
665
+ // split up text by whitespace
666
+ const chunkPattern = /[\s]*[^\s]+/g;
667
+ const wrappedLines = [];
668
+ rawLines.forEach((line) => {
669
+ const chunks = line.match(chunkPattern);
670
+ if (chunks === null) {
671
+ wrappedLines.push('');
672
+ return;
673
+ }
674
+
675
+ let sumChunks = [chunks.shift()];
676
+ let sumWidth = this.displayWidth(sumChunks[0]);
677
+ chunks.forEach((chunk) => {
678
+ const visibleWidth = this.displayWidth(chunk);
679
+ // Accumulate chunks while they fit into width.
680
+ if (sumWidth + visibleWidth <= width) {
681
+ sumChunks.push(chunk);
682
+ sumWidth += visibleWidth;
683
+ return;
684
+ }
685
+ wrappedLines.push(sumChunks.join(''));
686
+
687
+ const nextChunk = chunk.trimStart(); // trim space at line break
688
+ sumChunks = [nextChunk];
689
+ sumWidth = this.displayWidth(nextChunk);
690
+ });
691
+ wrappedLines.push(sumChunks.join(''));
692
+ });
693
+
694
+ return wrappedLines.join('\n');
695
+ }
696
+ }
697
+
698
+ /**
699
+ * Strip style ANSI escape sequences from the string. In particular, SGR (Select Graphic Rendition) codes.
700
+ *
701
+ * @param {string} str
702
+ * @returns {string}
703
+ * @package
704
+ */
705
+
706
+ function stripColor(str) {
707
+ // eslint-disable-next-line no-control-regex
708
+ const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
709
+ return str.replace(sgrPattern, '');
710
+ }
711
+
712
+ exports.Help = Help;
713
+ exports.stripColor = stripColor;