skillfit 0.0.0-stage → 0.8.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.
Files changed (371) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +226 -2
  3. package/README.zh-CN.md +224 -0
  4. package/benches/README.md +172 -0
  5. package/benches/code-review/bench.json +57 -0
  6. package/benches/code-review/fixtures/explain-x1/.skillfit-mock.json +10 -0
  7. package/benches/code-review/fixtures/explain-x1/SPEC.md +16 -0
  8. package/benches/code-review/fixtures/explain-x1/src/compact.js +18 -0
  9. package/benches/code-review/fixtures/explain-x1/tests/compact.test.js +18 -0
  10. package/benches/code-review/fixtures/review-r1/.skillfit-mock.json +10 -0
  11. package/benches/code-review/fixtures/review-r1/CHANGES.diff +42 -0
  12. package/benches/code-review/fixtures/review-r1/SPEC.md +16 -0
  13. package/benches/code-review/fixtures/review-r1/src/errors.js +7 -0
  14. package/benches/code-review/fixtures/review-r1/src/money.js +3 -0
  15. package/benches/code-review/fixtures/review-r1/src/order.js +13 -0
  16. package/benches/code-review/fixtures/review-r1/tests/order.test.js +17 -0
  17. package/benches/code-review/fixtures/review-r2/.skillfit-mock.json +10 -0
  18. package/benches/code-review/fixtures/review-r2/CHANGES.diff +81 -0
  19. package/benches/code-review/fixtures/review-r2/SPEC.md +25 -0
  20. package/benches/code-review/fixtures/review-r2/src/errors.js +7 -0
  21. package/benches/code-review/fixtures/review-r2/src/invoice.js +9 -0
  22. package/benches/code-review/fixtures/review-r2/src/money.js +3 -0
  23. package/benches/code-review/fixtures/review-r2/tests/invoice.test.js +13 -0
  24. package/benches/code-review/fixtures/review-r3/.skillfit-mock.json +10 -0
  25. package/benches/code-review/fixtures/review-r3/CHANGES.diff +76 -0
  26. package/benches/code-review/fixtures/review-r3/SPEC.md +24 -0
  27. package/benches/code-review/fixtures/review-r3/src/errors.js +7 -0
  28. package/benches/code-review/fixtures/review-r3/src/money.js +3 -0
  29. package/benches/code-review/fixtures/review-r3/src/pricing.js +20 -0
  30. package/benches/code-review/fixtures/review-r3/tests/pricing.test.js +15 -0
  31. package/benches/code-review/fixtures/summarize-s1/.skillfit-mock.json +16 -0
  32. package/benches/code-review/fixtures/summarize-s1/CHANGES.diff +27 -0
  33. package/benches/code-review/fixtures/summarize-s1/SPEC.md +15 -0
  34. package/benches/code-review/fixtures/summarize-s1/src/discount.js +20 -0
  35. package/benches/code-review/fixtures/summarize-s1/src/errors.js +7 -0
  36. package/benches/code-review/fixtures/summarize-s1/src/money.js +7 -0
  37. package/benches/code-review/ground-truth/oracle-r1.mjs +21 -0
  38. package/benches/code-review/ground-truth/oracle-r2.mjs +21 -0
  39. package/benches/code-review/ground-truth/oracle-r3.mjs +20 -0
  40. package/benches/code-review/ground-truth/oracle-summarize-s1.mjs +21 -0
  41. package/benches/code-review/ground-truth/oracle-x1.mjs +18 -0
  42. package/benches/code-review/ground-truth/r1.md +22 -0
  43. package/benches/code-review/ground-truth/r2.md +21 -0
  44. package/benches/code-review/ground-truth/r3.md +18 -0
  45. package/benches/code-review/ground-truth/summarize-s1.md +26 -0
  46. package/benches/code-review/ground-truth/x1.md +7 -0
  47. package/benches/code-review/prompts/explain-x1.md +5 -0
  48. package/benches/code-review/prompts/explain-x1.trigger.md +5 -0
  49. package/benches/code-review/prompts/review-r1.md +7 -0
  50. package/benches/code-review/prompts/review-r1.trigger.md +7 -0
  51. package/benches/code-review/prompts/review-r2.md +7 -0
  52. package/benches/code-review/prompts/review-r2.trigger.md +7 -0
  53. package/benches/code-review/prompts/review-r3.md +7 -0
  54. package/benches/code-review/prompts/review-r3.trigger.md +7 -0
  55. package/benches/code-review/prompts/summarize-s1.md +9 -0
  56. package/benches/code-review/prompts/summarize-s1.trigger.md +9 -0
  57. package/benches/code-review/verifiers/explain-x1.mjs +30 -0
  58. package/benches/code-review/verifiers/review-r2.mjs +66 -0
  59. package/benches/code-review/verifiers/review-r3.mjs +60 -0
  60. package/benches/code-review/verifiers/seeded-bugs.mjs +74 -0
  61. package/benches/code-review/verifiers/summarize-s1.mjs +80 -0
  62. package/benches/contrib/README.md +42 -0
  63. package/benches/contrib/oss-lru-cache/README.md +24 -0
  64. package/benches/contrib/oss-lru-cache/bench.json +37 -0
  65. package/benches/contrib/oss-lru-cache/fixtures/fetch-abort/LICENSE +15 -0
  66. package/benches/contrib/oss-lru-cache/fixtures/fetch-abort/README.md +3 -0
  67. package/benches/contrib/oss-lru-cache/fixtures/fetch-abort/index.js +1044 -0
  68. package/benches/contrib/oss-lru-cache/fixtures/fetch-abort/package.json +11 -0
  69. package/benches/contrib/oss-lru-cache/fixtures/fetch-abort/runtime.mjs +22 -0
  70. package/benches/contrib/oss-lru-cache/fixtures/fetch-abort/test.mjs +11 -0
  71. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/LICENSE.md +55 -0
  72. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/README.md +3 -0
  73. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/package.json +11 -0
  74. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/runtime.mjs +22 -0
  75. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/src/diagnostics-channel-browser.ts +11 -0
  76. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/src/diagnostics-channel-cjs.cts +11 -0
  77. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/src/diagnostics-channel-esm.mts +29 -0
  78. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/src/diagnostics-channel-node.ts +7 -0
  79. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/src/diagnostics-channel.ts +6 -0
  80. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/src/index.ts +3148 -0
  81. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/src/perf.ts +17 -0
  82. package/benches/contrib/oss-lru-cache/fixtures/fetch-lifecycle/test.mjs +11 -0
  83. package/benches/contrib/oss-lru-cache/fixtures/fetch-size/LICENSE +15 -0
  84. package/benches/contrib/oss-lru-cache/fixtures/fetch-size/README.md +3 -0
  85. package/benches/contrib/oss-lru-cache/fixtures/fetch-size/index.js +1028 -0
  86. package/benches/contrib/oss-lru-cache/fixtures/fetch-size/package.json +11 -0
  87. package/benches/contrib/oss-lru-cache/fixtures/fetch-size/runtime.mjs +22 -0
  88. package/benches/contrib/oss-lru-cache/fixtures/fetch-size/test.mjs +11 -0
  89. package/benches/contrib/oss-lru-cache/ground-truth/fetch-abort/LICENSE +15 -0
  90. package/benches/contrib/oss-lru-cache/ground-truth/fetch-abort/index.js +1053 -0
  91. package/benches/contrib/oss-lru-cache/ground-truth/fetch-abort.md +11 -0
  92. package/benches/contrib/oss-lru-cache/ground-truth/fetch-lifecycle/LICENSE.md +55 -0
  93. package/benches/contrib/oss-lru-cache/ground-truth/fetch-lifecycle/src/diagnostics-channel-browser.ts +11 -0
  94. package/benches/contrib/oss-lru-cache/ground-truth/fetch-lifecycle/src/diagnostics-channel-cjs.cts +11 -0
  95. package/benches/contrib/oss-lru-cache/ground-truth/fetch-lifecycle/src/diagnostics-channel-esm.mts +29 -0
  96. package/benches/contrib/oss-lru-cache/ground-truth/fetch-lifecycle/src/diagnostics-channel-node.ts +7 -0
  97. package/benches/contrib/oss-lru-cache/ground-truth/fetch-lifecycle/src/diagnostics-channel.ts +6 -0
  98. package/benches/contrib/oss-lru-cache/ground-truth/fetch-lifecycle/src/index.ts +3174 -0
  99. package/benches/contrib/oss-lru-cache/ground-truth/fetch-lifecycle/src/perf.ts +17 -0
  100. package/benches/contrib/oss-lru-cache/ground-truth/fetch-lifecycle.md +11 -0
  101. package/benches/contrib/oss-lru-cache/ground-truth/fetch-size/LICENSE +15 -0
  102. package/benches/contrib/oss-lru-cache/ground-truth/fetch-size/index.js +1028 -0
  103. package/benches/contrib/oss-lru-cache/ground-truth/fetch-size.md +11 -0
  104. package/benches/contrib/oss-lru-cache/ground-truth/oracle-fetch-abort.mjs +8 -0
  105. package/benches/contrib/oss-lru-cache/ground-truth/oracle-fetch-lifecycle.mjs +7 -0
  106. package/benches/contrib/oss-lru-cache/ground-truth/oracle-fetch-size.mjs +7 -0
  107. package/benches/contrib/oss-lru-cache/ground-truth/oracle.mjs +9 -0
  108. package/benches/contrib/oss-lru-cache/prompts/fetch-abort.md +5 -0
  109. package/benches/contrib/oss-lru-cache/prompts/fetch-lifecycle.md +5 -0
  110. package/benches/contrib/oss-lru-cache/prompts/fetch-size.md +5 -0
  111. package/benches/contrib/oss-lru-cache/provenance.json +62 -0
  112. package/benches/contrib/oss-lru-cache/runtime.mjs +22 -0
  113. package/benches/contrib/oss-lru-cache/verifiers/cases.mjs +74 -0
  114. package/benches/contrib/oss-lru-cache/verifiers/fetch-abort.mjs +3 -0
  115. package/benches/contrib/oss-lru-cache/verifiers/fetch-lifecycle.mjs +3 -0
  116. package/benches/contrib/oss-lru-cache/verifiers/fetch-size.mjs +3 -0
  117. package/benches/contrib/oss-lru-cache/verifiers/probe.mjs +14 -0
  118. package/benches/contrib/oss-lru-cache/verifiers/shared.mjs +130 -0
  119. package/benches/contrib/oss-lru-cache/verifiers/test-reporter.mjs +29 -0
  120. package/benches/contrib/oss-mcp-use-utf8/LICENSE.upstream +21 -0
  121. package/benches/contrib/oss-mcp-use-utf8/README.md +56 -0
  122. package/benches/contrib/oss-mcp-use-utf8/bench.json +16 -0
  123. package/benches/contrib/oss-mcp-use-utf8/fixtures/view-utf8/LICENSE +21 -0
  124. package/benches/contrib/oss-mcp-use-utf8/fixtures/view-utf8/package.json +3 -0
  125. package/benches/contrib/oss-mcp-use-utf8/fixtures/view-utf8/src/ext-apps-bridge.js +3 -0
  126. package/benches/contrib/oss-mcp-use-utf8/fixtures/view-utf8/src/resolve-view-resource.ts +96 -0
  127. package/benches/contrib/oss-mcp-use-utf8/fixtures/view-utf8/test/basic.test.mjs +13 -0
  128. package/benches/contrib/oss-mcp-use-utf8/ground-truth/README.md +5 -0
  129. package/benches/contrib/oss-mcp-use-utf8/ground-truth/oracle-view-utf8.mjs +11 -0
  130. package/benches/contrib/oss-mcp-use-utf8/ground-truth/solutions/view-utf8/src/resolve-view-resource.ts +96 -0
  131. package/benches/contrib/oss-mcp-use-utf8/ground-truth/solutions/view-utf8/test/utf8.regression.test.mjs +14 -0
  132. package/benches/contrib/oss-mcp-use-utf8/prompts/view-utf8.md +8 -0
  133. package/benches/contrib/oss-mcp-use-utf8/verifiers/view-utf8.mjs +120 -0
  134. package/benches/contrib/waza-behavior/LICENSE.upstream +21 -0
  135. package/benches/contrib/waza-behavior/README.md +31 -0
  136. package/benches/contrib/waza-behavior/bench.json +10 -0
  137. package/benches/contrib/waza-behavior/fixtures/explicit-hold/README.md +1 -0
  138. package/benches/contrib/waza-behavior/fixtures/explicit-hold/notes.txt +1 -0
  139. package/benches/contrib/waza-behavior/fixtures/receipt-current/README.md +1 -0
  140. package/benches/contrib/waza-behavior/fixtures/receipt-current/docs/guide.md +2 -0
  141. package/benches/contrib/waza-behavior/fixtures/receipt-current/notes.txt +1 -0
  142. package/benches/contrib/waza-behavior/fixtures/receipt-current/scripts/check-links.mjs +16 -0
  143. package/benches/contrib/waza-behavior/fixtures/receipt-current/validation-receipt.json +10 -0
  144. package/benches/contrib/waza-behavior/fixtures/receipt-stale/README.md +1 -0
  145. package/benches/contrib/waza-behavior/fixtures/receipt-stale/docs/guide.md +3 -0
  146. package/benches/contrib/waza-behavior/fixtures/receipt-stale/notes.txt +1 -0
  147. package/benches/contrib/waza-behavior/fixtures/receipt-stale/scripts/check-links.mjs +16 -0
  148. package/benches/contrib/waza-behavior/fixtures/receipt-stale/validation-receipt.json +10 -0
  149. package/benches/contrib/waza-behavior/ground-truth/oracle.mjs +24 -0
  150. package/benches/contrib/waza-behavior/prompts/explicit-hold.md +1 -0
  151. package/benches/contrib/waza-behavior/prompts/receipt-current.md +1 -0
  152. package/benches/contrib/waza-behavior/prompts/receipt-stale.md +1 -0
  153. package/benches/contrib/waza-behavior/verifiers/behavior.mjs +59 -0
  154. package/benches/debugging/bench.json +93 -0
  155. package/benches/debugging/fixtures/async-queue/src/task-queue.mjs +50 -0
  156. package/benches/debugging/fixtures/async-queue/test/basic.test.mjs +18 -0
  157. package/benches/debugging/fixtures/chunked-decoder/src/frame-decoder.mjs +39 -0
  158. package/benches/debugging/fixtures/chunked-decoder/test/basic.test.mjs +17 -0
  159. package/benches/debugging/fixtures/debug-redaction/src/debug-redaction.mjs +33 -0
  160. package/benches/debugging/fixtures/debug-redaction/test/basic.test.mjs +26 -0
  161. package/benches/debugging/fixtures/document-queue/.skillfit-mock.json +16 -0
  162. package/benches/debugging/fixtures/document-queue/src/task-queue.mjs +52 -0
  163. package/benches/debugging/fixtures/document-queue/test/basic.test.mjs +23 -0
  164. package/benches/debugging/fixtures/explain-cache/.skillfit-mock.json +16 -0
  165. package/benches/debugging/fixtures/explain-cache/src/ttl-cache.mjs +31 -0
  166. package/benches/debugging/fixtures/explain-cache/test/basic.test.mjs +28 -0
  167. package/benches/debugging/fixtures/feat-slug/test/slug.test.mjs +15 -0
  168. package/benches/debugging/fixtures/range-parser/src/range-parser.mjs +9 -0
  169. package/benches/debugging/fixtures/range-parser/test/basic.test.mjs +8 -0
  170. package/benches/debugging/fixtures/ttl-cache/src/ttl-cache.mjs +30 -0
  171. package/benches/debugging/fixtures/ttl-cache/test/basic.test.mjs +11 -0
  172. package/benches/debugging/ground-truth/async-queue.md +81 -0
  173. package/benches/debugging/ground-truth/chunked-decoder.md +91 -0
  174. package/benches/debugging/ground-truth/debug-redaction.md +113 -0
  175. package/benches/debugging/ground-truth/document-queue.md +24 -0
  176. package/benches/debugging/ground-truth/explain-cache.md +22 -0
  177. package/benches/debugging/ground-truth/feat-slug.md +45 -0
  178. package/benches/debugging/ground-truth/oracle-async-queue.mjs +14 -0
  179. package/benches/debugging/ground-truth/oracle-chunked-decoder.mjs +14 -0
  180. package/benches/debugging/ground-truth/oracle-debug-redaction.mjs +30 -0
  181. package/benches/debugging/ground-truth/oracle-document-queue.mjs +27 -0
  182. package/benches/debugging/ground-truth/oracle-explain-cache.mjs +28 -0
  183. package/benches/debugging/ground-truth/oracle-feat-slug.mjs +13 -0
  184. package/benches/debugging/ground-truth/oracle-range-parser.mjs +14 -0
  185. package/benches/debugging/ground-truth/oracle-ttl-cache.mjs +14 -0
  186. package/benches/debugging/ground-truth/range-parser.md +121 -0
  187. package/benches/debugging/ground-truth/solutions/async-queue/src/task-queue.mjs +52 -0
  188. package/benches/debugging/ground-truth/solutions/chunked-decoder/src/frame-decoder.mjs +50 -0
  189. package/benches/debugging/ground-truth/solutions/debug-redaction/src/debug-redaction.mjs +27 -0
  190. package/benches/debugging/ground-truth/solutions/debug-redaction/test/debug-leak.regression.test.mjs +27 -0
  191. package/benches/debugging/ground-truth/solutions/feat-slug/src/slug.mjs +6 -0
  192. package/benches/debugging/ground-truth/solutions/range-parser/src/range-parser.mjs +34 -0
  193. package/benches/debugging/ground-truth/solutions/range-parser/test/basic.test.mjs +26 -0
  194. package/benches/debugging/ground-truth/solutions/ttl-cache/src/ttl-cache.mjs +31 -0
  195. package/benches/debugging/ground-truth/ttl-cache.md +69 -0
  196. package/benches/debugging/prompts/async-queue.md +13 -0
  197. package/benches/debugging/prompts/async-queue.trigger.md +13 -0
  198. package/benches/debugging/prompts/chunked-decoder.md +13 -0
  199. package/benches/debugging/prompts/chunked-decoder.trigger.md +13 -0
  200. package/benches/debugging/prompts/debug-redaction.md +23 -0
  201. package/benches/debugging/prompts/debug-redaction.trigger.md +23 -0
  202. package/benches/debugging/prompts/document-queue.md +10 -0
  203. package/benches/debugging/prompts/document-queue.trigger.md +10 -0
  204. package/benches/debugging/prompts/explain-cache.md +10 -0
  205. package/benches/debugging/prompts/explain-cache.trigger.md +10 -0
  206. package/benches/debugging/prompts/feat-slug.md +3 -0
  207. package/benches/debugging/prompts/feat-slug.trigger.md +5 -0
  208. package/benches/debugging/prompts/range-parser.md +15 -0
  209. package/benches/debugging/prompts/range-parser.trigger.md +15 -0
  210. package/benches/debugging/prompts/ttl-cache.md +18 -0
  211. package/benches/debugging/prompts/ttl-cache.trigger.md +18 -0
  212. package/benches/debugging/verifiers/async-queue.mjs +221 -0
  213. package/benches/debugging/verifiers/chunked-decoder.mjs +208 -0
  214. package/benches/debugging/verifiers/debug-redaction.mjs +283 -0
  215. package/benches/debugging/verifiers/document-queue.mjs +52 -0
  216. package/benches/debugging/verifiers/explain-cache.mjs +62 -0
  217. package/benches/debugging/verifiers/feat-slug.mjs +127 -0
  218. package/benches/debugging/verifiers/range-parser.mjs +146 -0
  219. package/benches/debugging/verifiers/ttl-cache.mjs +111 -0
  220. package/dist/agents.js +26 -0
  221. package/dist/cli.js +310 -0
  222. package/dist/cli.test.js +76 -0
  223. package/dist/commands/bench.js +1035 -0
  224. package/dist/commands/bench.test.js +1061 -0
  225. package/dist/commands/bundle.js +334 -0
  226. package/dist/commands/bundle.test.js +142 -0
  227. package/dist/commands/confirm.js +39 -0
  228. package/dist/commands/doctor.js +399 -0
  229. package/dist/commands/doctor.test.js +280 -0
  230. package/dist/commands/eval-report.js +485 -0
  231. package/dist/commands/eval-report.test.js +306 -0
  232. package/dist/commands/eval.js +391 -0
  233. package/dist/commands/eval.test.js +446 -0
  234. package/dist/commands/install.js +653 -0
  235. package/dist/commands/install.test.js +555 -0
  236. package/dist/commands/mcp.js +20 -0
  237. package/dist/commands/report.js +78 -0
  238. package/dist/commands/report.test.js +110 -0
  239. package/dist/commands/setup.js +95 -0
  240. package/dist/commands/setup.test.js +150 -0
  241. package/dist/commands/upstream.js +210 -0
  242. package/dist/commands/upstream.test.js +139 -0
  243. package/dist/docs.test.js +154 -0
  244. package/dist/frontmatter.js +53 -0
  245. package/dist/frontmatter.test.js +49 -0
  246. package/dist/harness/bench.js +134 -0
  247. package/dist/harness/bench.test.js +109 -0
  248. package/dist/harness/bundle.js +46 -0
  249. package/dist/harness/bundle.test.js +71 -0
  250. package/dist/harness/constants.js +2 -0
  251. package/dist/harness/executors/api.js +68 -0
  252. package/dist/harness/executors/api.test.js +75 -0
  253. package/dist/harness/executors/cli.js +348 -0
  254. package/dist/harness/executors/cli.test.js +402 -0
  255. package/dist/harness/executors/mock.js +34 -0
  256. package/dist/harness/executors/mock.test.js +43 -0
  257. package/dist/harness/experiment-session.js +345 -0
  258. package/dist/harness/experiment-session.test.js +223 -0
  259. package/dist/harness/hash.js +29 -0
  260. package/dist/harness/installed-skill.js +78 -0
  261. package/dist/harness/installed-skill.test.js +162 -0
  262. package/dist/harness/judge.js +108 -0
  263. package/dist/harness/judge.test.js +181 -0
  264. package/dist/harness/kill-tree.js +43 -0
  265. package/dist/harness/kimi-usage.js +94 -0
  266. package/dist/harness/kimi-usage.test.js +62 -0
  267. package/dist/harness/oss-lru-cache.test.js +79 -0
  268. package/dist/harness/oss-regression-witness.test.js +89 -0
  269. package/dist/harness/prompt.js +57 -0
  270. package/dist/harness/prompt.test.js +48 -0
  271. package/dist/harness/receipts.js +297 -0
  272. package/dist/harness/receipts.test.js +148 -0
  273. package/dist/harness/report.js +225 -0
  274. package/dist/harness/report.test.js +297 -0
  275. package/dist/harness/runner.js +629 -0
  276. package/dist/harness/runner.test.js +555 -0
  277. package/dist/harness/stats.js +93 -0
  278. package/dist/harness/stats.test.js +124 -0
  279. package/dist/harness/target.js +90 -0
  280. package/dist/harness/target.test.js +60 -0
  281. package/dist/harness/trigger.js +368 -0
  282. package/dist/harness/trigger.test.js +249 -0
  283. package/dist/harness/types.js +1 -0
  284. package/dist/harness/verifier-summary.js +59 -0
  285. package/dist/harness/verifier-summary.test.js +99 -0
  286. package/dist/harness/waza-behavior.test.js +139 -0
  287. package/dist/invocation.js +21 -0
  288. package/dist/matrix/agents.json +200 -0
  289. package/dist/matrix/agents.schema.json +152 -0
  290. package/dist/mcp/probe.js +317 -0
  291. package/dist/mcp/probe.test.js +87 -0
  292. package/dist/version.js +4 -0
  293. package/docs/assets/skillfit-flow.en.svg +47 -0
  294. package/docs/assets/skillfit-flow.zh-CN.svg +47 -0
  295. package/docs/assets/skillfit-mark.svg +9 -0
  296. package/docs/audit-2026-09-24-triage.md +231 -0
  297. package/docs/audit-2026-09-24.md +876 -0
  298. package/docs/bench-authoring.md +407 -0
  299. package/docs/codex-upstream-audit.md +41 -0
  300. package/docs/config-experiments.md +119 -0
  301. package/docs/examples/bench-check.yml +32 -0
  302. package/docs/examples/eval-manifest.synthetic.json +61 -0
  303. package/docs/experiment-workflow.md +15 -0
  304. package/docs/first-real-eval.md +90 -0
  305. package/docs/growth-roadmap-2026-10.md +100 -0
  306. package/docs/installed-skill-evaluation.md +77 -0
  307. package/docs/metrics.md +318 -0
  308. package/docs/oss-task-evaluation.md +139 -0
  309. package/docs/plans/2026-10-01-oss-task-evaluation.md +73 -0
  310. package/docs/plans/2026-10-09-experiment-workflow.md +18 -0
  311. package/docs/plans/2026-10-09-grader-calibration-audit.md +13 -0
  312. package/docs/plans/2026-10-09-waza-resource-evaluation.md +46 -0
  313. package/docs/portable-codex.md +31 -0
  314. package/docs/reproducible-offline-example.md +29 -0
  315. package/docs/selectable-codex.md +41 -0
  316. package/docs/sharing-results.md +53 -0
  317. package/evidence/2026-07-skill-baseline.md +34 -0
  318. package/evidence/2026-09-22-codex-trigger-capture.md +36 -0
  319. package/evidence/2026-09-bench-calibration.md +46 -0
  320. package/evidence/2026-09-debugging-bench-exploratory.md +55 -0
  321. package/evidence/2026-09-debugging-hardening.md +42 -0
  322. package/evidence/2026-09-ocr-vs-code-review.md +31 -0
  323. package/evidence/2026-09-trigger-snapshot-correction.md +48 -0
  324. package/evidence/2026-10-01-codex-diagnosing-bugs-pilot.md +58 -0
  325. package/evidence/2026-10-01-oss-case-selection.md +42 -0
  326. package/evidence/2026-10-01-oss-workspace-smoke.md +110 -0
  327. package/evidence/README.md +47 -0
  328. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/README.md +27 -0
  329. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/artifact-index.json +118 -0
  330. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/baseline/output.md +5 -0
  331. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/baseline/prompt.txt +14 -0
  332. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/baseline/result.json +65 -0
  333. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/baseline/verifier.txt +2 -0
  334. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/baseline/workspace/LICENSE +21 -0
  335. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/baseline/workspace/package.json +3 -0
  336. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/baseline/workspace/src/ext-apps-bridge.js +3 -0
  337. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/baseline/workspace/src/resolve-view-resource.ts +100 -0
  338. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/baseline/workspace/test/basic.test.mjs +13 -0
  339. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/baseline/workspace/test/resolve-view-resource.test.mjs +102 -0
  340. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/manifest.json +206 -0
  341. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/original-console.txt +44 -0
  342. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/report.md +67 -0
  343. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/treatment/output.md +5 -0
  344. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/treatment/prompt.txt +163 -0
  345. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/treatment/result.json +65 -0
  346. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/treatment/verifier.txt +2 -0
  347. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/treatment/workspace/LICENSE +21 -0
  348. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/treatment/workspace/package.json +3 -0
  349. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/treatment/workspace/src/ext-apps-bridge.js +3 -0
  350. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/treatment/workspace/src/resolve-view-resource.ts +100 -0
  351. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/treatment/workspace/test/basic.test.mjs +13 -0
  352. package/evidence/artifacts/2026-10-01-oss-workspace-smoke/treatment/workspace/test/resolve-view-resource.test.mjs +136 -0
  353. package/evidence/inputs/README.md +15 -0
  354. package/evidence/inputs/diagnosing-bugs/LICENSE +21 -0
  355. package/evidence/inputs/diagnosing-bugs/SKILL.md +138 -0
  356. package/evidence/inputs/diagnosing-bugs/agents/openai.yaml +3 -0
  357. package/evidence/inputs/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
  358. package/evidence/plans/2026-10-01-oss-workspace-smoke.json +29 -0
  359. package/package.json +47 -4
  360. package/profiles/codex-curated/catalog.json +28 -0
  361. package/profiles/codex-curated/profile.json +282 -0
  362. package/profiles/codex-curated/rules/global.md +12 -0
  363. package/profiles/codex-curated/skills/autonomous-iteration/SKILL.md +75 -0
  364. package/profiles/codex-curated/skills/autonomous-iteration/agents/openai.yaml +4 -0
  365. package/profiles/codex-curated/skills/vibe-coding/SKILL.md +45 -0
  366. package/profiles/codex-curated/skills/vibe-coding/agents/openai.yaml +4 -0
  367. package/profiles/codex-upstream-sources.json +2980 -0
  368. package/profiles/recommended/profile.json +12 -0
  369. package/profiles/recommended/rules/core-workflow.md +41 -0
  370. package/profiles/recommended/skills/commit-message/SKILL.md +18 -0
  371. package/skills/skillfit/SKILL.md +60 -0
@@ -0,0 +1,124 @@
1
+ import assert from 'node:assert/strict';
2
+ import { test } from 'node:test';
3
+ import { MIN_DISCORDANT_FOR_SIGNIFICANCE, mcnemarExactP, pairedDeltaBootstrapCI, pairedScoreBootstrapCI, wilson95, } from './stats.js';
4
+ test('mcnemarExactP matches reference values', () => {
5
+ assert.equal(mcnemarExactP(6, 0), 0.03125);
6
+ assert.equal(mcnemarExactP(5, 0), 0.0625);
7
+ assert.equal(mcnemarExactP(9, 0), 0.00390625);
8
+ assert.equal(mcnemarExactP(3, 3), 1);
9
+ assert.equal(mcnemarExactP(0, 0), 1);
10
+ });
11
+ test('mcnemarExactP never increases as discordance grows more one-sided', () => {
12
+ let previous = 1;
13
+ for (let k = 1; k <= 15; k++) {
14
+ const p = mcnemarExactP(k, 0);
15
+ assert.ok(p <= previous, `p(${k},0)=${p} exceeds p(${k - 1},0)=${previous}`);
16
+ assert.equal(mcnemarExactP(0, k), p);
17
+ previous = p;
18
+ }
19
+ });
20
+ test('MIN_DISCORDANT_FOR_SIGNIFICANCE is the first discordant count reaching p < 0.05', () => {
21
+ assert.equal(MIN_DISCORDANT_FOR_SIGNIFICANCE, 6);
22
+ assert.ok(mcnemarExactP(MIN_DISCORDANT_FOR_SIGNIFICANCE, 0) < 0.05);
23
+ assert.ok(mcnemarExactP(MIN_DISCORDANT_FOR_SIGNIFICANCE - 1, 0) >= 0.05);
24
+ });
25
+ function task(baseline, treatment) {
26
+ return { baseline, treatment };
27
+ }
28
+ function scoreTask(baseline, treatment) {
29
+ return { baseline, treatment };
30
+ }
31
+ const SAMPLE_TASKS = [
32
+ task([true, false, true, false, true], [true, true, true, false, true]),
33
+ task([false, false, true, false, false], [true, false, true, true, false]),
34
+ task([true, true, false, true, false], [true, true, true, true, true]),
35
+ task([false, true, false, false, true], [false, true, true, false, true]),
36
+ task([true, false, false, false, false], [true, false, true, false, true]),
37
+ task([false, false, false, true, false], [true, false, false, true, true]),
38
+ task([true, true, true, false, false], [true, true, false, true, true]),
39
+ task([false, false, false, false, false], [false, true, false, false, true]),
40
+ ];
41
+ test('pairedDeltaBootstrapCI is deterministic for a fixed seed', () => {
42
+ const first = pairedDeltaBootstrapCI(SAMPLE_TASKS);
43
+ const second = pairedDeltaBootstrapCI(SAMPLE_TASKS);
44
+ assert.deepEqual(first, second);
45
+ });
46
+ test('pairedDeltaBootstrapCI brackets the pooled delta', () => {
47
+ const result = pairedDeltaBootstrapCI(SAMPLE_TASKS, { resamples: 500 });
48
+ assert.ok(result !== null);
49
+ assert.equal(result.resamples, 500);
50
+ assert.equal(result.point, 27 / 40 - 14 / 40);
51
+ assert.ok(result.lo <= result.point);
52
+ assert.ok(result.point <= result.hi);
53
+ });
54
+ test('pairedDeltaBootstrapCI returns a positive lower bound when treatment always wins', () => {
55
+ const tasks = Array.from({ length: 8 }, () => task([false, false, false], [true, true, true]));
56
+ const result = pairedDeltaBootstrapCI(tasks);
57
+ assert.ok(result !== null);
58
+ assert.equal(result.point, 1);
59
+ assert.ok(result.lo > 0);
60
+ });
61
+ test('pairedDeltaBootstrapCI returns null when there are no trials', () => {
62
+ assert.equal(pairedDeltaBootstrapCI([]), null);
63
+ assert.equal(pairedDeltaBootstrapCI([task([], [])]), null);
64
+ });
65
+ test('pairedDeltaBootstrapCI stays finite when some tasks have no graded survivors', () => {
66
+ const graded = task([false, true], [true, true]);
67
+ const empty = task([], []);
68
+ for (let seed = 1; seed <= 40; seed++) {
69
+ const mixed = pairedDeltaBootstrapCI([empty, graded], { seed, resamples: 300 });
70
+ const only = pairedDeltaBootstrapCI([graded], { seed, resamples: 300 });
71
+ assert.ok(mixed);
72
+ assert.ok(only);
73
+ assert.equal(Number.isFinite(mixed.lo) && Number.isFinite(mixed.hi), true);
74
+ assert.equal(mixed.point, only.point);
75
+ }
76
+ });
77
+ test('wilson95 handles empty and saturated arms', () => {
78
+ assert.deepEqual(wilson95(0, 0), { lo: 0, hi: 1 });
79
+ const zero = wilson95(0, 3);
80
+ assert.equal(zero.lo, 0);
81
+ assert.ok(zero.hi > 0.4 && zero.hi < 0.7, `hi=${zero.hi}`);
82
+ const full = wilson95(3, 3);
83
+ assert.ok(full.lo > 0.3 && full.lo < 0.6, `lo=${full.lo}`);
84
+ assert.equal(full.hi, 1);
85
+ });
86
+ const SAMPLE_SCORE_TASKS = [
87
+ scoreTask([0.5, 0.75], [1, 1]),
88
+ scoreTask([0.25, 0.5], [0.75, 1]),
89
+ scoreTask([1, 0.5], [1, 1]),
90
+ scoreTask([0, 0.25], [0.5, 0.75]),
91
+ ];
92
+ test('pairedScoreBootstrapCI is deterministic for a fixed seed', () => {
93
+ const first = pairedScoreBootstrapCI(SAMPLE_SCORE_TASKS);
94
+ const second = pairedScoreBootstrapCI(SAMPLE_SCORE_TASKS);
95
+ assert.deepEqual(first, second);
96
+ });
97
+ test('pairedScoreBootstrapCI brackets the pooled score delta', () => {
98
+ const result = pairedScoreBootstrapCI(SAMPLE_SCORE_TASKS, { resamples: 500 });
99
+ assert.ok(result !== null);
100
+ assert.equal(result.resamples, 500);
101
+ const baselineMean = (0.5 + 0.75 + 0.25 + 0.5 + 1 + 0.5 + 0 + 0.25) / 8;
102
+ const treatmentMean = (1 + 1 + 0.75 + 1 + 1 + 1 + 0.5 + 0.75) / 8;
103
+ assert.equal(result.point, treatmentMean - baselineMean);
104
+ assert.ok(result.lo <= result.point);
105
+ assert.ok(result.point <= result.hi);
106
+ });
107
+ test('pairedScoreBootstrapCI returns a positive lower bound when treatment always outscores', () => {
108
+ const tasks = Array.from({ length: 8 }, () => scoreTask([0.2, 0.4], [0.8, 1]));
109
+ const result = pairedScoreBootstrapCI(tasks);
110
+ assert.ok(result !== null);
111
+ assert.ok(result.point > 0);
112
+ assert.ok(result.lo > 0);
113
+ });
114
+ test('pairedScoreBootstrapCI matches pairedDeltaBootstrapCI on 0/1 inputs', () => {
115
+ const asScores = SAMPLE_TASKS.map((t) => ({
116
+ baseline: t.baseline.map((pass) => (pass ? 1 : 0)),
117
+ treatment: t.treatment.map((pass) => (pass ? 1 : 0)),
118
+ }));
119
+ assert.deepEqual(pairedScoreBootstrapCI(asScores), pairedDeltaBootstrapCI(SAMPLE_TASKS));
120
+ });
121
+ test('pairedScoreBootstrapCI returns null when there are no scored trials', () => {
122
+ assert.equal(pairedScoreBootstrapCI([]), null);
123
+ assert.equal(pairedScoreBootstrapCI([scoreTask([], [])]), null);
124
+ });
@@ -0,0 +1,90 @@
1
+ import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
2
+ import { basename, isAbsolute, join, relative, resolve, sep } from 'node:path';
3
+ import { collectSkillBundle } from './bundle.js';
4
+ import { hashFileSet, listFilesRecursive } from './hash.js';
5
+ export const EXPERIMENT_FILE = 'skillfit-experiment.json';
6
+ function parseExperimentFile(path) {
7
+ let value;
8
+ try {
9
+ value = JSON.parse(readFileSync(path, 'utf8'));
10
+ }
11
+ catch (error) {
12
+ throw new Error(`Invalid ${EXPERIMENT_FILE}: ${error.message}`);
13
+ }
14
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
15
+ throw new Error(`${EXPERIMENT_FILE} must contain a JSON object`);
16
+ }
17
+ const record = value;
18
+ if (record['schemaVersion'] !== 1) {
19
+ throw new Error(`${EXPERIMENT_FILE} schemaVersion must be 1`);
20
+ }
21
+ if (record['kind'] !== 'rules' && record['kind'] !== 'mcp') {
22
+ throw new Error(`${EXPERIMENT_FILE} kind must be "rules" or "mcp"`);
23
+ }
24
+ if (typeof record['treatment'] !== 'string' || record['treatment'].trim() === '') {
25
+ throw new Error(`${EXPERIMENT_FILE} treatment must name a non-empty overlay directory`);
26
+ }
27
+ if (record['baseline'] !== undefined && (typeof record['baseline'] !== 'string' || record['baseline'].trim() === '')) {
28
+ throw new Error(`${EXPERIMENT_FILE} baseline must be a non-empty overlay directory when present`);
29
+ }
30
+ if (record['name'] !== undefined && (typeof record['name'] !== 'string' || record['name'].trim() === '')) {
31
+ throw new Error(`${EXPERIMENT_FILE} name must be a non-empty string when present`);
32
+ }
33
+ return record;
34
+ }
35
+ function resolveOverlay(root, value, label) {
36
+ if (isAbsolute(value)) {
37
+ throw new Error(`${EXPERIMENT_FILE} ${label} must be relative to the experiment directory`);
38
+ }
39
+ const path = resolve(root, value);
40
+ const rel = relative(root, path);
41
+ if (rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
42
+ throw new Error(`${EXPERIMENT_FILE} ${label} escapes the experiment directory`);
43
+ }
44
+ if (!existsSync(path) || !statSync(path).isDirectory()) {
45
+ throw new Error(`${EXPERIMENT_FILE} ${label} overlay is not a directory: ${path}`);
46
+ }
47
+ const realRoot = realpathSync(root);
48
+ const realPath = realpathSync(path);
49
+ const realRel = relative(realRoot, realPath);
50
+ if (realRel === '' || realRel === '..' || realRel.startsWith(`..${sep}`) || isAbsolute(realRel)) {
51
+ throw new Error(`${EXPERIMENT_FILE} ${label} escapes or aliases the experiment directory`);
52
+ }
53
+ return path;
54
+ }
55
+ export function collectEvaluationTarget(targetPath) {
56
+ const sourceDir = resolve(targetPath);
57
+ if (!existsSync(sourceDir) || !statSync(sourceDir).isDirectory()) {
58
+ throw new Error(`Evaluation target is not a directory: ${sourceDir}`);
59
+ }
60
+ const manifestPath = join(sourceDir, EXPERIMENT_FILE);
61
+ if (!existsSync(manifestPath)) {
62
+ return collectSkillBundle(sourceDir);
63
+ }
64
+ const spec = parseExperimentFile(manifestPath);
65
+ const treatmentOverlay = resolveOverlay(sourceDir, spec.treatment, 'treatment');
66
+ const overlays = { treatment: treatmentOverlay };
67
+ if (spec.baseline)
68
+ overlays.baseline = resolveOverlay(sourceDir, spec.baseline, 'baseline');
69
+ const prefixedFiles = [EXPERIMENT_FILE];
70
+ for (const condition of ['baseline', 'treatment']) {
71
+ const overlay = overlays[condition];
72
+ if (!overlay)
73
+ continue;
74
+ const prefix = relative(sourceDir, overlay).split(sep).join('/');
75
+ for (const file of listFilesRecursive(overlay))
76
+ prefixedFiles.push(`${prefix}/${file}`);
77
+ }
78
+ if (listFilesRecursive(treatmentOverlay).length === 0) {
79
+ throw new Error(`${EXPERIMENT_FILE} treatment overlay must contain at least one file`);
80
+ }
81
+ return {
82
+ kind: spec.kind,
83
+ name: spec.name?.trim() || basename(sourceDir),
84
+ sourceDir,
85
+ files: prefixedFiles.sort(),
86
+ sha256: hashFileSet(sourceDir, prefixedFiles),
87
+ payload: null,
88
+ overlays,
89
+ };
90
+ }
@@ -0,0 +1,60 @@
1
+ import assert from 'node:assert/strict';
2
+ import { mkdtempSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { test } from 'node:test';
6
+ import { collectEvaluationTarget, EXPERIMENT_FILE } from './target.js';
7
+ function tmp(t) {
8
+ const dir = mkdtempSync(join(tmpdir(), 'skillfit-target-'));
9
+ t.after(() => rmSync(dir, { recursive: true, force: true }));
10
+ return dir;
11
+ }
12
+ test('collectEvaluationTarget keeps ordinary directories as skill targets', (t) => {
13
+ const dir = tmp(t);
14
+ writeFileSync(join(dir, 'SKILL.md'), '# demo\n');
15
+ const target = collectEvaluationTarget(dir);
16
+ assert.equal(target.kind, 'skill');
17
+ assert.match(target.payload ?? '', /<skill/);
18
+ assert.deepEqual(target.overlays, {});
19
+ });
20
+ test('collectEvaluationTarget loads a rules or MCP workspace experiment', (t) => {
21
+ const dir = tmp(t);
22
+ mkdirSync(join(dir, 'baseline', '.codex'), { recursive: true });
23
+ mkdirSync(join(dir, 'treatment', '.codex'), { recursive: true });
24
+ writeFileSync(join(dir, 'baseline', '.codex', 'config.toml'), '# no server\n');
25
+ writeFileSync(join(dir, 'treatment', '.codex', 'config.toml'), '[mcp_servers.context7]\n');
26
+ writeFileSync(join(dir, EXPERIMENT_FILE), JSON.stringify({ schemaVersion: 1, name: 'context7', kind: 'mcp', baseline: 'baseline', treatment: 'treatment' }));
27
+ const target = collectEvaluationTarget(dir);
28
+ assert.equal(target.kind, 'mcp');
29
+ assert.equal(target.name, 'context7');
30
+ assert.equal(target.payload, null);
31
+ assert.ok(target.overlays.baseline?.endsWith('baseline'));
32
+ assert.ok(target.overlays.treatment?.endsWith('treatment'));
33
+ assert.deepEqual(target.files, [
34
+ 'baseline/.codex/config.toml',
35
+ 'skillfit-experiment.json',
36
+ 'treatment/.codex/config.toml',
37
+ ]);
38
+ assert.equal(target.sha256.length, 64);
39
+ });
40
+ test('collectEvaluationTarget rejects traversal and empty treatment overlays', (t) => {
41
+ const dir = tmp(t);
42
+ writeFileSync(join(dir, EXPERIMENT_FILE), JSON.stringify({ schemaVersion: 1, kind: 'mcp', treatment: '..' }));
43
+ assert.throws(() => collectEvaluationTarget(dir), /escapes the experiment directory/);
44
+ mkdirSync(join(dir, 'empty'));
45
+ writeFileSync(join(dir, EXPERIMENT_FILE), JSON.stringify({ schemaVersion: 1, kind: 'rules', treatment: 'empty' }));
46
+ assert.throws(() => collectEvaluationTarget(dir), /must contain at least one file/);
47
+ });
48
+ test('collectEvaluationTarget rejects overlays that leave the experiment through a symlink', (t) => {
49
+ const dir = tmp(t);
50
+ const outside = tmp(t);
51
+ writeFileSync(join(outside, 'AGENTS.md'), '# outside\n');
52
+ symlinkSync(outside, join(dir, 'treatment'), 'junction');
53
+ writeFileSync(join(dir, EXPERIMENT_FILE), JSON.stringify({ schemaVersion: 1, kind: 'rules', treatment: 'treatment' }));
54
+ assert.throws(() => collectEvaluationTarget(dir), /escapes or aliases the experiment directory/);
55
+ });
56
+ test('collectEvaluationTarget rejects an overlay that aliases the experiment root', (t) => {
57
+ const dir = tmp(t);
58
+ writeFileSync(join(dir, EXPERIMENT_FILE), JSON.stringify({ schemaVersion: 1, kind: 'rules', treatment: '.' }));
59
+ assert.throws(() => collectEvaluationTarget(dir), /escapes or aliases the experiment directory/);
60
+ });
@@ -0,0 +1,368 @@
1
+ import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { dirname, join, resolve } from 'node:path';
3
+ import { MOCK_MARKER_FILE, RUN_GROUP_PATTERN } from './constants.js';
4
+ import { collectInstalledSkillFingerprint, collectSkillBundle } from './bundle.js';
5
+ import { OUTPUT_CONTRACT } from './prompt.js';
6
+ import { engagementError, gitInit, runVerifier, verifierFailure, verifierLogFor } from './runner.js';
7
+ import { wilson95 } from './stats.js';
8
+ import { verdictFromOutput } from './verifier-summary.js';
9
+ async function runTriggerTrial(plan, taskId, trial, installedSkill) {
10
+ const task = plan.bench.tasks.find((t) => t.id === taskId);
11
+ if (!task)
12
+ throw new Error(`Unknown task: ${taskId}`);
13
+ const runDir = join(plan.runsRoot, plan.runGroup, task.id, 'installed', `trial-${trial}`);
14
+ if (existsSync(runDir)) {
15
+ throw new Error(`Run directory already exists: ${runDir}`);
16
+ }
17
+ mkdirSync(runDir, { recursive: true });
18
+ cpSync(join(plan.bench.dir, task.fixture), runDir, { recursive: true });
19
+ rmSync(join(runDir, MOCK_MARKER_FILE), { force: true });
20
+ const gitInitialized = await gitInit(runDir);
21
+ const taskPromptText = readFileSync(join(plan.bench.dir, task.promptTrigger ?? task.prompt), 'utf8');
22
+ const prompt = `${[taskPromptText.trimEnd(), OUTPUT_CONTRACT].join('\n\n')}\n`;
23
+ writeFileSync(join(runDir, '_prompt.txt'), prompt, 'utf8');
24
+ const skillDest = join(runDir, plan.skillInstallDir, plan.skill.name);
25
+ mkdirSync(dirname(skillDest), { recursive: true });
26
+ cpSync(realpathSync(plan.skill.sourceDir), skillDest, { recursive: true });
27
+ const observedSkill = collectInstalledSkillFingerprint(skillDest);
28
+ if (observedSkill.sha256 !== installedSkill.sha256) {
29
+ throw new Error(`Installed Skill content does not match the planned fingerprint for ${taskId} / trial ${trial}; keep the Skill input unchanged and remove any conflicting fixture Skill files.`);
30
+ }
31
+ for (const competitor of plan.competitors ?? []) {
32
+ const dest = join(runDir, plan.skillInstallDir, competitor.name);
33
+ if (existsSync(dest))
34
+ throw new Error(`Competing Skill collides with an existing directory: ${dest}`);
35
+ mkdirSync(dirname(dest), { recursive: true });
36
+ cpSync(realpathSync(competitor.sourceDir), dest, { recursive: true });
37
+ if (collectInstalledSkillFingerprint(dest).sha256 !== competitor.sha256) {
38
+ throw new Error(`Competing Skill "${competitor.name}" changed after planning; remove it from the run and start again.`);
39
+ }
40
+ }
41
+ const started = new Date();
42
+ let output = '';
43
+ let rawOutput = null;
44
+ let error = null;
45
+ let tokens = null;
46
+ let triggered = null;
47
+ try {
48
+ if (!gitInitialized && task.verifierKind === 'command') {
49
+ throw new Error('Benchmark Git initialization or reflog verification failed; trigger task was not executed.');
50
+ }
51
+ const result = await plan.executor.run(prompt, runDir);
52
+ output = result.output;
53
+ rawOutput = result.rawOutput ?? null;
54
+ tokens = result.tokens ?? null;
55
+ triggered = result.skillTriggered ?? null;
56
+ error = result.guardError ?? null;
57
+ }
58
+ catch (executorError) {
59
+ error = executorError.message;
60
+ }
61
+ if (error === null) {
62
+ error = await engagementError(output, task.verifierKind, runDir, gitInitialized);
63
+ }
64
+ const finished = new Date();
65
+ writeFileSync(join(runDir, '_output.md'), output, 'utf8');
66
+ if (rawOutput !== null) {
67
+ writeFileSync(join(runDir, '_transcript.jsonl'), rawOutput, 'utf8');
68
+ }
69
+ let passed = false;
70
+ let score = null;
71
+ let checks = null;
72
+ if (error === null) {
73
+ const verifier = await runVerifier(plan.bench.dir, task.verifier, runDir);
74
+ writeFileSync(join(runDir, '_verifier.txt'), verifierLogFor(verifier), 'utf8');
75
+ if (verifier.exitCode === null) {
76
+ error = verifierFailure('verifier', task.verifier, verifier.error);
77
+ }
78
+ else {
79
+ passed = verifier.exitCode === 0;
80
+ const verdict = verdictFromOutput(verifier.output);
81
+ if (verdict) {
82
+ checks = verdict.checks;
83
+ score = verdict.score;
84
+ }
85
+ }
86
+ }
87
+ else {
88
+ writeFileSync(join(runDir, '_executor-error.txt'), error, 'utf8');
89
+ }
90
+ const record = {
91
+ taskId,
92
+ trial,
93
+ runDir,
94
+ startedAt: started.toISOString(),
95
+ finishedAt: finished.toISOString(),
96
+ durationSeconds: Math.round(((finished.getTime() - started.getTime()) / 1000) * 1000) / 1000,
97
+ triggered,
98
+ passed,
99
+ score,
100
+ checks,
101
+ error,
102
+ tokens,
103
+ };
104
+ writeFileSync(join(runDir, '_result.json'), `${JSON.stringify({
105
+ schemaVersion: 1,
106
+ ...record,
107
+ runGroup: plan.runGroup,
108
+ skillBundleSha256: plan.skill.sha256,
109
+ skillInstalledSha256: observedSkill.sha256,
110
+ skillInstalledFiles: observedSkill.files,
111
+ skillInstalledAt: join(plan.skillInstallDir, plan.skill.name),
112
+ gitInitialized,
113
+ executor: plan.executor.describe(),
114
+ }, null, 2)}\n`, 'utf8');
115
+ return record;
116
+ }
117
+ function summarizeTriggerTask(taskId, shouldTrigger, triggerClass, records) {
118
+ let input = 0;
119
+ let output = 0;
120
+ let seenTokens = false;
121
+ for (const record of records) {
122
+ if (!record.tokens)
123
+ continue;
124
+ seenTokens = true;
125
+ input += record.tokens.input ?? 0;
126
+ output += record.tokens.output ?? 0;
127
+ }
128
+ return {
129
+ id: taskId,
130
+ shouldTrigger,
131
+ ...(triggerClass ? { triggerClass } : {}),
132
+ runs: records.filter((r) => r.error === null && r.triggered !== null).length,
133
+ fired: records.filter((r) => r.error === null && r.triggered === true).length,
134
+ unknown: records.filter((r) => r.error === null && r.triggered === null).length,
135
+ errors: records.filter((r) => r.error !== null).length,
136
+ passes: records.filter((r) => r.passed).length,
137
+ tokens: seenTokens ? { input, output } : null,
138
+ };
139
+ }
140
+ export function triggerMetrics(tasks) {
141
+ const positives = tasks.filter((t) => t.shouldTrigger);
142
+ const negatives = tasks.filter((t) => !t.shouldTrigger);
143
+ const posFired = positives.reduce((sum, t) => sum + t.fired, 0);
144
+ const posRuns = positives.reduce((sum, t) => sum + t.runs, 0);
145
+ const negFired = negatives.reduce((sum, t) => sum + t.fired, 0);
146
+ const negRuns = negatives.reduce((sum, t) => sum + t.runs, 0);
147
+ const recall = posRuns > 0 ? posFired / posRuns : null;
148
+ const falseTriggerRate = negRuns > 0 ? negFired / negRuns : null;
149
+ const firedTotal = posFired + negFired;
150
+ const precision = firedTotal > 0 ? posFired / firedTotal : null;
151
+ const f1 = recall !== null && precision !== null && recall + precision > 0
152
+ ? (2 * precision * recall) / (precision + recall)
153
+ : null;
154
+ let input = 0;
155
+ let output = 0;
156
+ let seenTokens = false;
157
+ for (const task of tasks) {
158
+ if (!task.tokens)
159
+ continue;
160
+ seenTokens = true;
161
+ input += task.tokens.input;
162
+ output += task.tokens.output;
163
+ }
164
+ return {
165
+ recall,
166
+ recallCi95: posRuns > 0 ? wilson95(posFired, posRuns) : null,
167
+ falseTriggerRate,
168
+ falseTriggerRateCi95: negRuns > 0 ? wilson95(negFired, negRuns) : null,
169
+ precision,
170
+ precisionCi95: firedTotal > 0 ? wilson95(posFired, firedTotal) : null,
171
+ f1,
172
+ positives: { fired: posFired, runs: posRuns },
173
+ negatives: { fired: negFired, runs: negRuns },
174
+ classRecall: classRecall(positives),
175
+ tokens: seenTokens ? { input, output } : null,
176
+ };
177
+ }
178
+ function classRecall(positives) {
179
+ const out = {};
180
+ for (const name of ['explicit', 'implicit', 'contextual']) {
181
+ const rows = positives.filter((task) => task.triggerClass === name);
182
+ const runs = rows.reduce((sum, task) => sum + task.runs, 0);
183
+ if (runs === 0)
184
+ continue;
185
+ const fired = rows.reduce((sum, task) => sum + task.fired, 0);
186
+ out[name] = { fired, runs, recall: fired / runs, recallCi95: wilson95(fired, runs) };
187
+ }
188
+ return Object.keys(out).length === 0 ? undefined : out;
189
+ }
190
+ function buildTriggerWarnings(manifest) {
191
+ const warnings = [];
192
+ if (manifest.metrics.negatives.runs === 0) {
193
+ warnings.push('No shouldTrigger:false tasks in this bench — the false-trigger rate is unmeasurable. Add negative-control tasks.');
194
+ }
195
+ const unknown = manifest.tasks.reduce((sum, t) => sum + t.unknown, 0);
196
+ if (unknown > 0) {
197
+ warnings.push(`${unknown} run(s) had transcripts where trigger detection was impossible — excluded from recall/precision rates.`);
198
+ }
199
+ const errors = manifest.tasks.reduce((sum, t) => sum + t.errors, 0);
200
+ if (errors > 0) {
201
+ warnings.push(`${errors} run(s) hit an executor, verifier, or engagement error — excluded from rates.`);
202
+ }
203
+ const competing = manifest.competition?.mode === 'installed' ? manifest.competition.skills : [];
204
+ if (competing.length === 0) {
205
+ warnings.push('Recall is an upper bound: the Skill under test was installed alone, with no other user Skills competing.');
206
+ }
207
+ else {
208
+ warnings.push(`Recall faced ${competing.length} other user Skill(s): ${competing.map((skill) => skill.name).join(', ')}. System Skills and plugins outside the matrix user directories were not copied.`);
209
+ }
210
+ if (manifest.detection === 'skill-read') {
211
+ warnings.push('Trigger detection counted a SKILL.md read, not a Skill-invocation event.');
212
+ }
213
+ if (manifest.tasks.some((task) => task.shouldTrigger) && !manifest.tasks.some((task) => task.triggerClass)) {
214
+ warnings.push('Positive tasks have no triggerClass, so explicit, implicit, and contextual requests stay pooled.');
215
+ }
216
+ if (manifest.tasks.some((task) => task.shouldTrigger && !task.triggerClass) && manifest.tasks.some((task) => task.triggerClass)) {
217
+ warnings.push('Some positive tasks have no triggerClass and stay in the pooled recall only.');
218
+ }
219
+ return warnings;
220
+ }
221
+ export async function runTriggerExperiment(plan) {
222
+ if (!RUN_GROUP_PATTERN.test(plan.runGroup)) {
223
+ throw new Error(`Invalid run group "${plan.runGroup}": must match ${RUN_GROUP_PATTERN} (got characters outside [A-Za-z0-9._-] or a leading dot/hyphen)`);
224
+ }
225
+ if (!Number.isInteger(plan.trials) || plan.trials < 1 || plan.trials > 20) {
226
+ throw new Error(`trials must be an integer between 1 and 20, got ${plan.trials}`);
227
+ }
228
+ if (plan.executor.describe().kind === 'mock') {
229
+ throw new Error('Trigger mode requires a real CLI executor with trigger detection; the mock executor cannot invoke skills.');
230
+ }
231
+ const groupDir = join(plan.runsRoot, plan.runGroup);
232
+ if (existsSync(groupDir) && !(plan.session?.groupDir === resolve(groupDir) &&
233
+ readdirSync(groupDir).join() === '_plan.json')) {
234
+ throw new Error(`Run group directory already exists: ${groupDir}`);
235
+ }
236
+ const installedSkill = collectInstalledSkillFingerprint(plan.skill.sourceDir);
237
+ if (collectSkillBundle(plan.skill.sourceDir, plan.skill.name).sha256 !== plan.skill.sha256) {
238
+ throw new Error('Skill input changed after planning; collect a new Skill bundle before starting the trigger experiment.');
239
+ }
240
+ mkdirSync(groupDir, { recursive: true });
241
+ const eligible = plan.bench.tasks.filter((task) => task.shouldTrigger !== undefined);
242
+ const skipped = plan.bench.tasks.length - eligible.length;
243
+ if (skipped > 0) {
244
+ plan.log?.(`Skipping ${skipped} task(s) without a shouldTrigger label.`);
245
+ }
246
+ const taskSummaries = [];
247
+ for (const task of eligible) {
248
+ const records = [];
249
+ for (let trial = 1; trial <= plan.trials; trial++) {
250
+ plan.log?.(`Running ${task.id} / installed / trial ${trial}…`);
251
+ records.push(await runTriggerTrial(plan, task.id, trial, installedSkill));
252
+ }
253
+ taskSummaries.push(summarizeTriggerTask(task.id, task.shouldTrigger ?? false, task.triggerClass, records));
254
+ }
255
+ plan.session?.settle();
256
+ const manifestWithoutWarnings = {
257
+ schemaVersion: 1,
258
+ mode: 'trigger',
259
+ ...(plan.session ? { experiment: plan.session.summary() } : {}),
260
+ runGroup: plan.runGroup,
261
+ createdAt: new Date().toISOString(),
262
+ skill: {
263
+ name: plan.skill.name,
264
+ sourceDir: plan.skill.sourceDir,
265
+ bundleSha256: plan.skill.sha256,
266
+ files: plan.skill.files,
267
+ installedSha256: installedSkill.sha256,
268
+ installedFiles: installedSkill.files,
269
+ },
270
+ bench: {
271
+ name: plan.bench.name,
272
+ dir: plan.bench.dir,
273
+ contentSha256: plan.bench.contentSha256,
274
+ taskCount: eligible.length,
275
+ },
276
+ executor: plan.executor.describe(),
277
+ trials: plan.trials,
278
+ skillInstallDir: plan.skillInstallDir,
279
+ competition: {
280
+ mode: (plan.competitors?.length ?? 0) > 0 ? 'installed' : 'alone',
281
+ skills: (plan.competitors ?? []).map((skill) => ({ name: skill.name, sha256: skill.sha256 })),
282
+ },
283
+ detection: plan.detection ?? 'unrecorded',
284
+ tasks: taskSummaries,
285
+ metrics: triggerMetrics(taskSummaries),
286
+ };
287
+ const manifest = {
288
+ ...manifestWithoutWarnings,
289
+ warnings: buildTriggerWarnings(manifestWithoutWarnings),
290
+ };
291
+ writeFileSync(join(groupDir, 'manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`, 'utf8');
292
+ return manifest;
293
+ }
294
+ function pad(text, width) {
295
+ return text.length >= width ? text : text + ' '.repeat(width - text.length);
296
+ }
297
+ function pct(value) {
298
+ return `${Math.round(value * 100)}%`;
299
+ }
300
+ function rateWithCi(fired, runs, ci) {
301
+ if (runs === 0)
302
+ return 'n/a (no runs)';
303
+ const base = `${fired}/${runs} (${pct(fired / runs)})`;
304
+ return ci ? `${base} [95% CI ${pct(ci.lo)}–${pct(ci.hi)}]` : base;
305
+ }
306
+ export function renderTriggerSummary(manifest, manifestPath) {
307
+ const lines = [];
308
+ lines.push(`Skill : ${manifest.skill.name} (injectable bundle sha256 ${manifest.skill.bundleSha256.slice(0, 12)}…, ${manifest.skill.files.length} injectable files)`);
309
+ lines.push(manifest.skill.installedSha256 && manifest.skill.installedFiles
310
+ ? `Installed: sha256 ${manifest.skill.installedSha256.slice(0, 12)}…, ${manifest.skill.installedFiles.length} files (before execution)`
311
+ : 'Installed: not recorded (legacy manifest; injectable hash does not identify all installed resources)');
312
+ lines.push(`Bench : ${manifest.bench.name} (${manifest.bench.taskCount} task(s), content sha256 ${manifest.bench.contentSha256.slice(0, 12)}…)`);
313
+ lines.push(`Executor : ${manifest.executor.kind} (${manifest.executor.model})${manifest.executor.detail ? ` — ${manifest.executor.detail}` : ''}`);
314
+ lines.push(`Mode : trigger — skill installed into ${manifest.skillInstallDir}, not injected into the prompt`);
315
+ const competing = manifest.competition?.skills ?? [];
316
+ lines.push(competing.length === 0
317
+ ? 'Compete : alone (recall is an upper bound)'
318
+ : `Compete : ${competing.length} other user Skill(s): ${competing.map((skill) => skill.name).join(', ')}`);
319
+ if (manifest.detection === 'skill-read')
320
+ lines.push('Detect : SKILL.md read, not a Skill-invocation event');
321
+ lines.push(`Trials : ${manifest.trials} per task`);
322
+ lines.push('');
323
+ const idWidth = Math.max(7, ...manifest.tasks.map((t) => t.id.length));
324
+ lines.push(`${pad('TASK', idWidth)} FIRE? FIRED UNKNOWN ERRORS PASS`);
325
+ for (const task of manifest.tasks) {
326
+ const total = task.runs + task.unknown + task.errors;
327
+ lines.push(`${pad(task.id, idWidth)} ${pad(task.shouldTrigger ? 'yes' : 'no', 5)} ${pad(`${task.fired}/${total}`, 8)} ${pad(String(task.unknown), 7)} ${pad(String(task.errors), 6)} ${task.passes}/${total}`);
328
+ }
329
+ lines.push('');
330
+ const m = manifest.metrics;
331
+ lines.push(`Trigger recall : ${rateWithCi(m.positives.fired, m.positives.runs, m.recallCi95)}`);
332
+ for (const name of ['explicit', 'implicit', 'contextual']) {
333
+ const row = m.classRecall?.[name];
334
+ if (row)
335
+ lines.push(` ${name.padEnd(18)}: ${rateWithCi(row.fired, row.runs, row.recallCi95)}`);
336
+ }
337
+ lines.push(`False-trigger rate : ${rateWithCi(m.negatives.fired, m.negatives.runs, m.falseTriggerRateCi95)}`);
338
+ const firedTotal = m.positives.fired + m.negatives.fired;
339
+ lines.push(`Precision : ${firedTotal === 0 ? 'n/a (nothing fired)' : rateWithCi(m.positives.fired, firedTotal, m.precisionCi95)}`);
340
+ lines.push(`F1 : ${m.f1 === null ? 'n/a' : `${m.f1.toFixed(2)} (no CI: a harmonic mean of two proportions has no closed-form binomial interval)`}`);
341
+ const tokenLines = manifest.tasks
342
+ .filter((task) => task.tokens !== null)
343
+ .map((task) => {
344
+ const tokens = task.tokens;
345
+ return tokens ? `- ${task.id}: input ${tokens.input}, output ${tokens.output}` : null;
346
+ })
347
+ .filter((line) => line !== null);
348
+ if (tokenLines.length > 0) {
349
+ lines.push('');
350
+ lines.push('Tokens used (per task):');
351
+ lines.push(...tokenLines);
352
+ if (m.tokens) {
353
+ lines.push(`- total: input ${m.tokens.input}, output ${m.tokens.output}`);
354
+ }
355
+ }
356
+ lines.push('');
357
+ lines.push('Warnings:');
358
+ if (manifest.warnings.length === 0) {
359
+ lines.push('- none');
360
+ }
361
+ else {
362
+ for (const warning of manifest.warnings)
363
+ lines.push(`- ${warning}`);
364
+ }
365
+ lines.push('');
366
+ lines.push(`Manifest: ${manifestPath}`);
367
+ return lines.join('\n');
368
+ }