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,555 @@
1
+ import assert from 'node:assert/strict';
2
+ import { spawnSync } from 'node:child_process';
3
+ import { promises as fs } from 'node:fs';
4
+ import * as os from 'node:os';
5
+ import * as path from 'node:path';
6
+ import test from 'node:test';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { parseFrontmatter } from '../frontmatter.js';
9
+ import { BACKUP_SUFFIX, LOCKFILE_NAME, MARKER_END, MARKER_START, loadProfile, renderManagedBlock, runInstall, upsertManagedBlock, } from './install.js';
10
+ const PROFILES_DIR = fileURLToPath(new URL('../../profiles/', import.meta.url));
11
+ const CLI_PATH = fileURLToPath(new URL('../../dist/cli.js', import.meta.url));
12
+ async function tempDirs(t) {
13
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), 'skillfit-install-'));
14
+ t.after(async () => { await fs.rm(root, { recursive: true, force: true }); });
15
+ const home = path.join(root, 'home');
16
+ const project = path.join(root, 'project');
17
+ await fs.mkdir(home, { recursive: true });
18
+ await fs.mkdir(project, { recursive: true });
19
+ return { home, project };
20
+ }
21
+ function makeOpts(home, project, extra = {}) {
22
+ return {
23
+ profile: 'recommended',
24
+ homeDir: home,
25
+ projectDir: project,
26
+ profilesDir: PROFILES_DIR,
27
+ env: { PATH: '' },
28
+ yes: true,
29
+ log: () => { },
30
+ ...extra,
31
+ };
32
+ }
33
+ function captureLogs() {
34
+ const lines = [];
35
+ return { lines, log: (line) => { lines.push(line); } };
36
+ }
37
+ async function exists(p) {
38
+ try {
39
+ await fs.access(p);
40
+ return true;
41
+ }
42
+ catch {
43
+ return false;
44
+ }
45
+ }
46
+ async function snapshot(root) {
47
+ const out = {};
48
+ async function walk(dir) {
49
+ for (const entry of await fs.readdir(dir, { withFileTypes: true })) {
50
+ const full = path.join(dir, entry.name);
51
+ if (entry.isDirectory())
52
+ await walk(full);
53
+ else if (entry.isFile())
54
+ out[path.relative(root, full)] = await fs.readFile(full, 'utf8');
55
+ }
56
+ }
57
+ await walk(root);
58
+ return out;
59
+ }
60
+ async function readLock(dir) {
61
+ return JSON.parse(await fs.readFile(path.join(dir, LOCKFILE_NAME), 'utf8'));
62
+ }
63
+ test('installs rules and skill for codex at user scope', async (t) => {
64
+ const { home, project } = await tempDirs(t);
65
+ await runInstall(makeOpts(home, project, { agent: 'codex' }));
66
+ const agentsMd = await fs.readFile(path.join(home, '.codex', 'AGENTS.md'), 'utf8');
67
+ assert.ok(agentsMd.includes(MARKER_START));
68
+ assert.ok(agentsMd.includes(MARKER_END));
69
+ assert.match(agentsMd, /red-green-refactor/);
70
+ const skillMd = await fs.readFile(path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md'), 'utf8');
71
+ const fm = parseFrontmatter(skillMd);
72
+ assert.equal(fm?.name, 'commit-message');
73
+ assert.ok(fm?.description);
74
+ const lock = await readLock(home);
75
+ assert.equal(lock.version, 1);
76
+ assert.deepEqual(Object.keys(lock.entries).sort(), ['codex:rules', 'codex:skill:commit-message']);
77
+ const rulesEntry = lock.entries['codex:rules'];
78
+ assert.ok(rulesEntry);
79
+ assert.equal(rulesEntry.profileVersion, '1.0.0');
80
+ assert.match(rulesEntry.sha256, /^[0-9a-f]{64}$/);
81
+ assert.ok(rulesEntry.installedAt);
82
+ });
83
+ test('uses CODEX_HOME for global Codex rules while keeping user skills under home', async (t) => {
84
+ const { home, project } = await tempDirs(t);
85
+ const codexHome = path.join(home, 'alternate-codex');
86
+ await runInstall(makeOpts(home, project, {
87
+ agent: 'codex',
88
+ env: { PATH: '', CODEX_HOME: codexHome },
89
+ }));
90
+ assert.ok(await exists(path.join(codexHome, 'AGENTS.md')));
91
+ assert.ok(await exists(path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md')));
92
+ assert.equal(await exists(path.join(home, '.codex', 'AGENTS.md')), false);
93
+ });
94
+ test('refuses a Codex global rules install shadowed by AGENTS.override.md', async (t) => {
95
+ const { home, project } = await tempDirs(t);
96
+ const codexHome = path.join(home, '.codex');
97
+ await fs.mkdir(codexHome, { recursive: true });
98
+ await fs.writeFile(path.join(codexHome, 'AGENTS.override.md'), '# Active override\n');
99
+ const { lines, log } = captureLogs();
100
+ await assert.rejects(runInstall(makeOpts(home, project, {
101
+ agent: 'codex', log,
102
+ })), /conflict/i);
103
+ assert.match(lines.join('\n'), /AGENTS\.override\.md.*shadows/);
104
+ assert.equal(await exists(path.join(home, '.agents', 'skills', 'commit-message')), false);
105
+ });
106
+ test('installs a profile supplied by directory and preserves binary skill assets', async (t) => {
107
+ const { home, project } = await tempDirs(t);
108
+ const profile = path.join(project, 'portable');
109
+ const skillDir = path.join(profile, 'skills', 'example');
110
+ await fs.mkdir(skillDir, { recursive: true });
111
+ await fs.writeFile(path.join(profile, 'profile.json'), JSON.stringify({
112
+ name: 'portable', version: '1.0.0', agents: ['codex'],
113
+ skills: [{ name: 'example', source: 'skills/example' }],
114
+ }));
115
+ await fs.writeFile(path.join(skillDir, 'SKILL.md'), '---\nname: example\ndescription: Example skill.\n---\nUse it.\n');
116
+ const image = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x00, 0xff, 0x80]);
117
+ await fs.writeFile(path.join(skillDir, 'icon.png'), image);
118
+ await runInstall(makeOpts(home, project, { agent: 'codex', profilePath: profile }));
119
+ assert.deepEqual(await fs.readFile(path.join(home, '.agents', 'skills', 'example', 'icon.png')), image);
120
+ });
121
+ test('refuses to replace a symlinked rules file', async (t) => {
122
+ const { home, project } = await tempDirs(t);
123
+ const target = path.join(home, '.codex', 'AGENTS.md');
124
+ const real = path.join(project, 'real-agents.md');
125
+ await fs.mkdir(path.dirname(target), { recursive: true });
126
+ await fs.writeFile(real, '# original\n');
127
+ try {
128
+ await fs.symlink(real, target);
129
+ }
130
+ catch (error) {
131
+ if (error.code === 'EPERM')
132
+ return t.skip('symlinks unavailable');
133
+ throw error;
134
+ }
135
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /symlink/i);
136
+ assert.equal(await fs.readFile(real, 'utf8'), '# original\n');
137
+ });
138
+ test('rejects a portable profile whose skill path is a symlink outside the profile', async (t) => {
139
+ const { home, project } = await tempDirs(t);
140
+ const profile = path.join(project, 'portable');
141
+ const outside = path.join(project, 'outside');
142
+ await fs.mkdir(path.join(profile, 'skills'), { recursive: true });
143
+ await fs.mkdir(outside);
144
+ await fs.writeFile(path.join(outside, 'SKILL.md'), '---\nname: example\ndescription: Example.\n---\n');
145
+ await fs.writeFile(path.join(profile, 'profile.json'), JSON.stringify({
146
+ name: 'portable', version: '1.0.0', agents: ['codex'],
147
+ skills: [{ name: 'example', source: 'skills/example' }],
148
+ }));
149
+ try {
150
+ await fs.symlink(outside, path.join(profile, 'skills', 'example'), 'junction');
151
+ }
152
+ catch (error) {
153
+ if (error.code === 'EPERM')
154
+ return t.skip('symlinks unavailable');
155
+ throw error;
156
+ }
157
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex', profilePath: profile })), /symlink/i);
158
+ assert.equal(await exists(path.join(home, '.agents', 'skills', 'example')), false);
159
+ });
160
+ test('rejects duplicate skills in a portable profile before staging files', async (t) => {
161
+ const { home, project } = await tempDirs(t);
162
+ const profile = path.join(project, 'portable');
163
+ const skillDir = path.join(profile, 'skills', 'example');
164
+ await fs.mkdir(skillDir, { recursive: true });
165
+ await fs.writeFile(path.join(skillDir, 'SKILL.md'), '---\nname: example\ndescription: Example.\n---\n');
166
+ await fs.writeFile(path.join(profile, 'profile.json'), JSON.stringify({
167
+ name: 'portable', version: '1.0.0', agents: ['codex'],
168
+ skills: [
169
+ { name: 'example', source: 'skills/example' },
170
+ { name: 'example', source: 'skills/example' },
171
+ ],
172
+ }));
173
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex', profilePath: profile })), /duplicate skill/i);
174
+ assert.equal(await exists(path.join(home, '.agents', 'skills', 'example')), false);
175
+ });
176
+ test('second run skips unchanged items and writes nothing', async (t) => {
177
+ const { home, project } = await tempDirs(t);
178
+ await runInstall(makeOpts(home, project, { agent: 'codex' }));
179
+ const before = await snapshot(home);
180
+ const { lines, log } = captureLogs();
181
+ await runInstall(makeOpts(home, project, { agent: 'codex', log }));
182
+ assert.deepEqual(await snapshot(home), before);
183
+ assert.ok(lines.some((l) => l.includes('SKIP')));
184
+ assert.ok(lines.some((l) => l.includes('up to date')));
185
+ });
186
+ test('preserves existing content outside markers and backs up the original', async (t) => {
187
+ const { home, project } = await tempDirs(t);
188
+ const target = path.join(home, '.codex', 'AGENTS.md');
189
+ await fs.mkdir(path.dirname(target), { recursive: true });
190
+ const original = '# My own rules\n\nAlways be terse.\n';
191
+ await fs.writeFile(target, original);
192
+ await runInstall(makeOpts(home, project, { agent: 'codex' }));
193
+ const content = await fs.readFile(target, 'utf8');
194
+ assert.ok(content.startsWith(original));
195
+ assert.ok(content.includes(MARKER_START));
196
+ assert.equal(await fs.readFile(target + BACKUP_SUFFIX, 'utf8'), original);
197
+ });
198
+ test('rewrites a stale managed block while keeping outside edits', async (t) => {
199
+ const { home, project } = await tempDirs(t);
200
+ await runInstall(makeOpts(home, project, { agent: 'codex' }));
201
+ const target = path.join(home, '.codex', 'AGENTS.md');
202
+ const stale = (await fs.readFile(target, 'utf8')).replace(MARKER_END, `stale line\n${MARKER_END}`);
203
+ await fs.writeFile(target, `${stale}\nUser appendix.\n`);
204
+ const { lines, log } = captureLogs();
205
+ await runInstall(makeOpts(home, project, { agent: 'codex', log }));
206
+ const content = await fs.readFile(target, 'utf8');
207
+ assert.ok(!content.includes('stale line'));
208
+ assert.ok(content.includes('User appendix.'));
209
+ assert.ok(lines.some((l) => l.includes('UPDATE')));
210
+ assert.equal(await fs.readFile(target + BACKUP_SUFFIX, 'utf8'), `${stale}\nUser appendix.\n`);
211
+ });
212
+ test('claude-code project scope installs AGENTS.md plus an @AGENTS.md bridge in CLAUDE.md', async (t) => {
213
+ const { home, project } = await tempDirs(t);
214
+ await runInstall(makeOpts(home, project, { agent: 'claude-code', project: true }));
215
+ const agentsMd = await fs.readFile(path.join(project, 'AGENTS.md'), 'utf8');
216
+ assert.ok(agentsMd.includes(MARKER_START));
217
+ assert.match(agentsMd, /red-green-refactor/);
218
+ const claudeMd = await fs.readFile(path.join(project, 'CLAUDE.md'), 'utf8');
219
+ assert.ok(claudeMd.includes(MARKER_START));
220
+ assert.ok(claudeMd.split('\n').some((line) => line.trim() === '@AGENTS.md'));
221
+ assert.ok(await exists(path.join(project, '.claude', 'skills', 'commit-message', 'SKILL.md')));
222
+ const lock = await readLock(project);
223
+ assert.deepEqual(Object.keys(lock.entries).sort(), ['claude-code:bridge', 'claude-code:rules', 'claude-code:skill:commit-message']);
224
+ });
225
+ test('does not add a managed bridge when CLAUDE.md already imports AGENTS.md', async (t) => {
226
+ const { home, project } = await tempDirs(t);
227
+ const claudePath = path.join(project, 'CLAUDE.md');
228
+ const original = '# Project notes\n\n@AGENTS.md\n';
229
+ await fs.writeFile(claudePath, original);
230
+ const { lines, log } = captureLogs();
231
+ await runInstall(makeOpts(home, project, { agent: 'claude-code', project: true, log }));
232
+ assert.equal(await fs.readFile(claudePath, 'utf8'), original);
233
+ assert.ok(lines.some((l) => l.includes('already present')));
234
+ });
235
+ test('kimi-code project scope uses the shared .agents/skills directory', async (t) => {
236
+ const { home, project } = await tempDirs(t);
237
+ await runInstall(makeOpts(home, project, { agent: 'kimi-code', project: true }));
238
+ assert.ok(await exists(path.join(project, '.agents', 'skills', 'commit-message', 'SKILL.md')));
239
+ assert.ok(await exists(path.join(project, 'AGENTS.md')));
240
+ });
241
+ test('conflicting foreign skill content aborts the whole install without writes', async (t) => {
242
+ const { home, project } = await tempDirs(t);
243
+ const skillTarget = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
244
+ await fs.mkdir(path.dirname(skillTarget), { recursive: true });
245
+ const foreign = '---\nname: commit-message\ndescription: hand-written\n---\nmine\n';
246
+ await fs.writeFile(skillTarget, foreign);
247
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /conflict/i);
248
+ assert.equal(await fs.readFile(skillTarget, 'utf8'), foreign);
249
+ assert.ok(!(await exists(path.join(home, '.codex', 'AGENTS.md'))));
250
+ assert.ok(!(await exists(path.join(home, LOCKFILE_NAME))));
251
+ });
252
+ test('modifying an installed skill turns the next run into a conflict', async (t) => {
253
+ const { home, project } = await tempDirs(t);
254
+ await runInstall(makeOpts(home, project, { agent: 'codex' }));
255
+ const skillTarget = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
256
+ await fs.writeFile(skillTarget, 'user edits\n');
257
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /conflict/i);
258
+ assert.equal(await fs.readFile(skillTarget, 'utf8'), 'user edits\n');
259
+ });
260
+ async function foreignSkill(home) {
261
+ const skillDir = path.join(home, '.agents', 'skills', 'commit-message');
262
+ await fs.mkdir(skillDir, { recursive: true });
263
+ await fs.writeFile(path.join(skillDir, 'SKILL.md'), '---\nname: commit-message\ndescription: written by someone else\n---\nforeign body\n');
264
+ }
265
+ test('install --dry-run reports conflicts and returns instead of throwing', async (t) => {
266
+ const { home, project } = await tempDirs(t);
267
+ await foreignSkill(home);
268
+ const { lines, log } = captureLogs();
269
+ // A dry run is a question, not an attempt. Before this it exited non-zero, so CI that ran
270
+ // --dry-run as a pre-flight check failed on the very condition the check exists to surface.
271
+ await runInstall(makeOpts(home, project, { agent: 'codex', dryRun: true, yes: false, log }));
272
+ const output = lines.join('\n');
273
+ assert.match(output, /CONFLICT/);
274
+ assert.match(output, /conflict\(s\) would block this install/);
275
+ assert.match(output, /pass --strict to make them fail/);
276
+ assert.equal(await exists(path.join(home, '.codex', 'AGENTS.md')), false, 'a dry run still writes nothing');
277
+ });
278
+ test('install --dry-run --strict throws on conflicts', async (t) => {
279
+ const { home, project } = await tempDirs(t);
280
+ await foreignSkill(home);
281
+ const { lines, log } = captureLogs();
282
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex', dryRun: true, strict: true, yes: false, log })), /conflict\(s\) found/);
283
+ assert.equal(await exists(path.join(home, '.codex', 'AGENTS.md')), false);
284
+ });
285
+ test('a skill update from the same profile overwrites a pristine install', async (t) => {
286
+ const { home, project } = await tempDirs(t);
287
+ await runInstall(makeOpts(home, project, { agent: 'codex' }));
288
+ const profilesCopy = path.join(project, 'profiles-copy');
289
+ await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
290
+ const skillSrc = path.join(profilesCopy, 'recommended', 'skills', 'commit-message', 'SKILL.md');
291
+ await fs.writeFile(skillSrc, '---\nname: commit-message\ndescription: v2 improved\n---\nnew body\n');
292
+ const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
293
+ const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
294
+ manifest.version = '1.1.0';
295
+ await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
296
+ await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
297
+ const installed = await fs.readFile(path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md'), 'utf8');
298
+ assert.match(installed, /v2 improved/);
299
+ const lock = await readLock(home);
300
+ assert.equal(lock.entries['codex:skill:commit-message']?.profileVersion, '1.1.0');
301
+ });
302
+ test('a second update preserves the first backup instead of clobbering it', async (t) => {
303
+ const { home, project } = await tempDirs(t);
304
+ const profilesCopy = path.join(project, 'profiles-copy');
305
+ await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
306
+ const skillSrc = path.join(profilesCopy, 'recommended', 'skills', 'commit-message', 'SKILL.md');
307
+ const skillTarget = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
308
+ const backup = skillTarget + BACKUP_SUFFIX;
309
+ const installVersion = async (body) => {
310
+ await fs.writeFile(skillSrc, `---\nname: commit-message\ndescription: ${body}\n---\n${body}\n`);
311
+ await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
312
+ };
313
+ await installVersion('v1 body');
314
+ assert.equal(await exists(backup), false, 'a first install creates nothing to back up');
315
+ await installVersion('v2 body');
316
+ assert.match(await fs.readFile(skillTarget, 'utf8'), /v2 body/);
317
+ assert.match(await fs.readFile(backup, 'utf8'), /v1 body/, 'the first update backs up v1');
318
+ await installVersion('v3 body');
319
+ assert.match(await fs.readFile(skillTarget, 'utf8'), /v3 body/);
320
+ // The backup exists so a user can get their pre-skillfit file back. Overwriting it on every update
321
+ // means the second update destroys the only copy of the original.
322
+ assert.match(await fs.readFile(backup, 'utf8'), /v1 body/, 'the original must survive later updates');
323
+ });
324
+ test('a staging failure applies nothing, not even the items staged before it', async (t) => {
325
+ const { home, project } = await tempDirs(t);
326
+ const profilesCopy = path.join(project, 'profiles-copy');
327
+ await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
328
+ const agentsMd = path.join(home, '.codex', 'AGENTS.md');
329
+ const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
330
+ const lockPath = path.join(home, LOCKFILE_NAME);
331
+ // Block the skill write after planning, so the failure lands inside the write phase —
332
+ // after the rules item has already been staged.
333
+ await fs.mkdir(path.join(home, '.agents', 'skills'), { recursive: true });
334
+ // Bump the profile version so the rules block changes and the rules item is a real write.
335
+ const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
336
+ manifest.version = '1.1.0';
337
+ await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
338
+ await assert.rejects(runInstall(makeOpts(home, project, {
339
+ agent: 'codex', profilesDir: profilesCopy, yes: false,
340
+ confirm: async () => {
341
+ await fs.writeFile(path.join(home, '.agents', 'skills', 'commit-message'), 'not a directory\n');
342
+ return true;
343
+ },
344
+ })), 'the failure must surface, not be swallowed');
345
+ assert.equal(await exists(agentsMd), false, 'the rules file must not be written when a later item fails');
346
+ assert.equal(await exists(lockPath), false, 'the lockfile must not record an install that did not happen');
347
+ });
348
+ test('a rename failure after the first file does not leave a partial install', async (t) => {
349
+ const { home, project } = await tempDirs(t);
350
+ const rulesTarget = path.join(home, '.codex', 'AGENTS.md');
351
+ const skillTarget = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
352
+ const realRename = fs.rename.bind(fs);
353
+ t.mock.method(fs, 'rename', async (source, target) => {
354
+ if (target === skillTarget && source.includes('.skillfit-staged')) {
355
+ throw Object.assign(new Error('injected rename failure'), { code: 'EACCES' });
356
+ }
357
+ return realRename(source, target);
358
+ });
359
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /injected rename failure/);
360
+ assert.equal(await exists(rulesTarget), false, 'the earlier rules write must be rolled back');
361
+ assert.equal(await exists(skillTarget), false);
362
+ assert.equal(await exists(path.join(home, LOCKFILE_NAME)), false);
363
+ });
364
+ test('a lockfile rename failure restores updated content and the old lockfile', async (t) => {
365
+ const { home, project } = await tempDirs(t);
366
+ await runInstall(makeOpts(home, project, { agent: 'codex' }));
367
+ const rulesTarget = path.join(home, '.codex', 'AGENTS.md');
368
+ const skillTarget = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
369
+ const lockTarget = path.join(home, LOCKFILE_NAME);
370
+ const originalRules = await fs.readFile(rulesTarget, 'utf8');
371
+ const originalSkill = await fs.readFile(skillTarget, 'utf8');
372
+ const originalLock = await fs.readFile(lockTarget, 'utf8');
373
+ const profilesCopy = path.join(project, 'profiles-copy');
374
+ await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
375
+ const skillSrc = path.join(profilesCopy, 'recommended', 'skills', 'commit-message', 'SKILL.md');
376
+ await fs.writeFile(skillSrc, '---\nname: commit-message\ndescription: v2\n---\nv2 body\n');
377
+ const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
378
+ const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
379
+ manifest.version = '1.1.0';
380
+ await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
381
+ const realRename = fs.rename.bind(fs);
382
+ t.mock.method(fs, 'rename', async (source, target) => {
383
+ if (target === lockTarget && source.includes('.skillfit-staged')) {
384
+ throw Object.assign(new Error('injected lockfile rename failure'), { code: 'EACCES' });
385
+ }
386
+ return realRename(source, target);
387
+ });
388
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy })), /injected lockfile rename failure/);
389
+ assert.equal(await fs.readFile(rulesTarget, 'utf8'), originalRules);
390
+ assert.equal(await fs.readFile(skillTarget, 'utf8'), originalSkill);
391
+ assert.equal(await fs.readFile(lockTarget, 'utf8'), originalLock);
392
+ assert.equal(await fs.readFile(lockTarget + BACKUP_SUFFIX, 'utf8'), originalLock);
393
+ const files = Object.keys(await snapshot(home));
394
+ assert.ok(!files.some((name) => name.includes('.skillfit-staged') || name.includes('.skillfit-restore')));
395
+ });
396
+ test('an unreadable existing skill path stops planning before any write', async (t) => {
397
+ const { home, project } = await tempDirs(t);
398
+ const skillFile = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
399
+ await fs.mkdir(skillFile, { recursive: true });
400
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), (error) => ['EISDIR', 'EPERM', 'EACCES'].includes(error.code ?? ''));
401
+ assert.equal(await exists(path.join(home, '.codex', 'AGENTS.md')), false);
402
+ });
403
+ test('removed profile files cause a conflict rather than leaving an obsolete skill asset silently', async (t) => {
404
+ const { home, project } = await tempDirs(t);
405
+ const profilesCopy = path.join(project, 'profiles-copy');
406
+ await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
407
+ const skillDir = path.join(profilesCopy, 'recommended', 'skills', 'commit-message');
408
+ const oldSource = path.join(skillDir, 'scripts', 'old.mjs');
409
+ await fs.mkdir(path.dirname(oldSource), { recursive: true });
410
+ await fs.writeFile(oldSource, 'export const old = true;\n');
411
+ await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
412
+ await fs.rm(oldSource);
413
+ const { lines, log } = captureLogs();
414
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy, dryRun: true, strict: true, log })), /conflict/);
415
+ assert.match(lines.join('\n'), /existing files absent from profile: scripts\/old\.mjs/);
416
+ assert.equal(await fs.readFile(path.join(home, '.agents', 'skills', 'commit-message', 'scripts', 'old.mjs'), 'utf8'), 'export const old = true;\n');
417
+ });
418
+ test('a stale lockfile entry reconciles on the next successful run', async (t) => {
419
+ const { home, project } = await tempDirs(t);
420
+ const profilesCopy = path.join(project, 'profiles-copy');
421
+ await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
422
+ const skillSrc = path.join(profilesCopy, 'recommended', 'skills', 'commit-message', 'SKILL.md');
423
+ const lockPath = path.join(home, LOCKFILE_NAME);
424
+ await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
425
+ // Simulate what an older partial run left behind: the rules file on disk is current, but the
426
+ // lockfile entry describing it is stale. Nothing rewrites a skipped item, so without a reconcile
427
+ // step this record stays wrong forever.
428
+ const stale = JSON.parse(await fs.readFile(lockPath, 'utf8'));
429
+ const rulesEntry = stale.entries['codex:rules'];
430
+ assert.ok(rulesEntry);
431
+ rulesEntry.profileVersion = '0.0.1';
432
+ rulesEntry.sha256 = 'deadbeef';
433
+ await fs.writeFile(lockPath, JSON.stringify(stale, null, 2));
434
+ // The skill changes, so this run has something to write and reaches the recording step.
435
+ await fs.writeFile(skillSrc, '---\nname: commit-message\ndescription: v2\n---\nv2 body\n');
436
+ const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
437
+ const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
438
+ manifest.version = '1.1.0';
439
+ await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
440
+ await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
441
+ const lock = await readLock(home);
442
+ assert.equal(lock.entries['codex:rules']?.profileVersion, '1.1.0', 'the skipped item is reconciled');
443
+ assert.match(lock.entries['codex:rules']?.sha256 ?? '', /^[0-9a-f]{64}$/, 'and its hash is restored');
444
+ assert.equal(lock.entries['codex:skill:commit-message']?.profileVersion, '1.1.0');
445
+ });
446
+ test('the lockfile is backed up before it is rewritten', async (t) => {
447
+ const { home, project } = await tempDirs(t);
448
+ await runInstall(makeOpts(home, project, { agent: 'codex' }));
449
+ const lockPath = path.join(home, LOCKFILE_NAME);
450
+ const before = await fs.readFile(lockPath, 'utf8');
451
+ const profilesCopy = path.join(project, 'profiles-copy');
452
+ await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
453
+ const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
454
+ const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
455
+ manifest.version = '1.1.0';
456
+ await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
457
+ await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
458
+ assert.equal(await fs.readFile(lockPath + BACKUP_SUFFIX, 'utf8'), before, 'the previous lockfile survives');
459
+ assert.match(await fs.readFile(lockPath, 'utf8'), /1\.1\.0/);
460
+ });
461
+ test('install fails fast when stdin closes without an answer', async (t) => {
462
+ const { project } = await tempDirs(t);
463
+ // Runs the real readline path in a child process: the defect is stdin closing without ever
464
+ // delivering a line, which an injected `confirm` stub cannot reproduce. --project keeps every
465
+ // write inside the temp directory.
466
+ const result = spawnSync(process.execPath, [CLI_PATH, 'install', '--project', '--agent', 'codex'], { cwd: project, encoding: 'utf8', input: '', timeout: 30_000 });
467
+ assert.equal(result.signal, null, 'must not hang until the timeout');
468
+ assert.notEqual(result.status, 0, 'closed non-TTY stdin must fail, not exit 0 having written nothing');
469
+ assert.match(result.stderr, /--yes/);
470
+ assert.equal(await exists(path.join(project, LOCKFILE_NAME)), false, 'nothing was written');
471
+ });
472
+ test('dry-run prints the plan and writes nothing', async (t) => {
473
+ const { home, project } = await tempDirs(t);
474
+ const { lines, log } = captureLogs();
475
+ await runInstall(makeOpts(home, project, { agent: 'codex', dryRun: true, yes: false, log }));
476
+ assert.ok(lines.some((l) => l.includes('CREATE')));
477
+ assert.ok(lines.some((l) => /dry run/i.test(l)));
478
+ assert.deepEqual(await fs.readdir(home), []);
479
+ });
480
+ test('interactive install asks for confirmation and honors a no', async (t) => {
481
+ const { home, project } = await tempDirs(t);
482
+ let asked = 0;
483
+ const confirm = async () => { asked += 1; return false; };
484
+ await runInstall(makeOpts(home, project, { agent: 'codex', yes: false, confirm }));
485
+ assert.equal(asked, 1);
486
+ assert.deepEqual(await fs.readdir(home), []);
487
+ });
488
+ test('interactive install proceeds on yes', async (t) => {
489
+ const { home, project } = await tempDirs(t);
490
+ const confirm = async () => true;
491
+ await runInstall(makeOpts(home, project, { agent: 'codex', yes: false, confirm }));
492
+ assert.ok(await exists(path.join(home, '.codex', 'AGENTS.md')));
493
+ });
494
+ test('rejects unknown agents, bad profile names and missing profiles', async (t) => {
495
+ const { home, project } = await tempDirs(t);
496
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'nope' })), /Unknown agent/);
497
+ await assert.rejects(runInstall(makeOpts(home, project, { profile: '../evil' })), /Invalid profile name/);
498
+ await assert.rejects(runInstall(makeOpts(home, project, { profile: 'missing' })), /not found/);
499
+ });
500
+ test('rejects an agent the profile does not target', async (t) => {
501
+ const { home, project } = await tempDirs(t);
502
+ const profilesCopy = path.join(project, 'profiles-copy');
503
+ await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
504
+ const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
505
+ const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
506
+ manifest.agents = ['codex'];
507
+ await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
508
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'kimi-code', profilesDir: profilesCopy })), /does not target/);
509
+ });
510
+ test('without --agent installs only for detected agents', async (t) => {
511
+ const { home, project } = await tempDirs(t);
512
+ await fs.mkdir(path.join(home, '.codex'), { recursive: true });
513
+ await fs.mkdir(path.join(home, '.claude'), { recursive: true });
514
+ await runInstall(makeOpts(home, project));
515
+ assert.ok(await exists(path.join(home, '.codex', 'AGENTS.md')));
516
+ assert.ok(await exists(path.join(home, '.claude', 'AGENTS.md')));
517
+ assert.ok(await exists(path.join(home, '.claude', 'CLAUDE.md')));
518
+ assert.ok(!(await exists(path.join(home, '.kimi-code'))));
519
+ });
520
+ test('without --agent and nothing detected, fails with guidance', async (t) => {
521
+ const { home, project } = await tempDirs(t);
522
+ await assert.rejects(runInstall(makeOpts(home, project)), /No target agents detected/);
523
+ });
524
+ test('refuses to touch a file with malformed markers', async (t) => {
525
+ const { home, project } = await tempDirs(t);
526
+ const target = path.join(home, '.codex', 'AGENTS.md');
527
+ await fs.mkdir(path.dirname(target), { recursive: true });
528
+ await fs.writeFile(target, `broken ${MARKER_START} only\n`);
529
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /malformed/i);
530
+ assert.equal(await fs.readFile(target, 'utf8'), `broken ${MARKER_START} only\n`);
531
+ });
532
+ test('a corrupt lockfile fails loudly', async (t) => {
533
+ const { home, project } = await tempDirs(t);
534
+ await runInstall(makeOpts(home, project, { agent: 'codex' }));
535
+ await fs.writeFile(path.join(home, LOCKFILE_NAME), '{oops');
536
+ await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /not valid JSON/);
537
+ });
538
+ test('the bundled recommended profile passes validation', async () => {
539
+ const { manifest } = await loadProfile(PROFILES_DIR, 'recommended');
540
+ assert.equal(manifest.name, 'recommended');
541
+ assert.deepEqual([...manifest.agents].sort(), ['claude-code', 'codex', 'kimi-code']);
542
+ });
543
+ // parseFrontmatter's own tests live in src/frontmatter.test.ts, next to the single implementation
544
+ // doctor and install now share.
545
+ test('upsertManagedBlock creates, appends and replaces', () => {
546
+ const block = renderManagedBlock('body', 'p', '1.0.0');
547
+ assert.equal(upsertManagedBlock(null, block), `${block}\n`);
548
+ assert.equal(upsertManagedBlock(' \n', block), `${block}\n`);
549
+ const appended = upsertManagedBlock('user text\n', block);
550
+ assert.ok(appended.startsWith('user text\n'));
551
+ assert.ok(appended.includes(block));
552
+ const replaced = upsertManagedBlock(`pre ${MARKER_START}\nold\n${MARKER_END} post`, block);
553
+ assert.equal(replaced, `pre ${block} post`);
554
+ assert.throws(() => upsertManagedBlock(`x ${MARKER_START} y`, block), /malformed/i);
555
+ });
@@ -0,0 +1,20 @@
1
+ import { loadMcpProbeSpec, probeMcpStdio, renderMcpProbe } from '../mcp/probe.js';
2
+ export async function runMcpCheck(options) {
3
+ const log = options.log ?? ((message) => console.log(message));
4
+ const spec = loadMcpProbeSpec(options.specPath);
5
+ if (options.dryRun) {
6
+ log([
7
+ 'MCP check plan (dry run)',
8
+ `Server : ${spec.name}`,
9
+ `Transport: stdio`,
10
+ `Command : ${spec.command} (${spec.args.length} argument(s); values withheld)`,
11
+ 'Checks : initialize handshake, capabilities, tools/list, unique names, descriptions, input schemas, annotations',
12
+ 'Tool calls: none',
13
+ 'Dry run — the server was not started.',
14
+ ].join('\n'));
15
+ return null;
16
+ }
17
+ const result = await probeMcpStdio(spec);
18
+ log(renderMcpProbe(result));
19
+ return result;
20
+ }
@@ -0,0 +1,78 @@
1
+ import { collectReceipts } from '../harness/receipts.js';
2
+ function pad(text, width) {
3
+ return text.length >= width ? text : text + ' '.repeat(width - text.length);
4
+ }
5
+ function day(epochMs) {
6
+ return epochMs === null ? '—' : new Date(epochMs).toISOString().slice(0, 10);
7
+ }
8
+ function renderAgent(receipt, lines) {
9
+ if (!receipt.sessionsDir) {
10
+ lines.push(`${receipt.agentId}: skipped — no verified skill-invocation signal in its session format yet`);
11
+ return;
12
+ }
13
+ if (!receipt.present) {
14
+ lines.push(`${receipt.agentId}: no session history found at ${receipt.sessionsDir}`);
15
+ if (receipt.installedCount > 0) {
16
+ lines.push(` (${receipt.installedCount} skill(s) installed; nothing measured)`);
17
+ }
18
+ return;
19
+ }
20
+ lines.push(`${receipt.agentId} — ${receipt.sessionsFound} session(s), ${receipt.transcriptsRead} transcript(s)`);
21
+ if (receipt.skills.length > 0) {
22
+ const nameWidth = Math.max(5, ...receipt.skills.map((s) => s.name.length));
23
+ lines.push(`${pad(' skill', nameWidth + 2)} FIRES SESSIONS LAST SEEN`);
24
+ for (const skill of receipt.skills) {
25
+ lines.push(` ${pad(skill.name, nameWidth)} ${pad(String(skill.fires), 5)} ${pad(String(skill.sessionCount), 8)} ${day(skill.lastSeen)}`);
26
+ }
27
+ }
28
+ else {
29
+ lines.push(' (no skill invocations found)');
30
+ }
31
+ const installed = new Set(receipt.installed);
32
+ const installedFired = receipt.skills.filter((skill) => installed.has(skill.name));
33
+ lines.push(` installed: ${receipt.installedCount}, observed firing: ${installedFired.length}, no observed fire: ${receipt.neverFired.length}`);
34
+ if (receipt.neverFired.length > 0) {
35
+ lines.push(` no observed fire in retained history: ${receipt.neverFired.join(', ')}`);
36
+ }
37
+ if (receipt.tax.descTokensTotal > 0) {
38
+ const heaviest = receipt.tax.heaviest
39
+ .map((entry) => `${entry.name} (${entry.descTokens} tok)`)
40
+ .join(', ');
41
+ lines.push(` catalog size (raw estimate): ~${receipt.tax.descTokensTotal.toLocaleString('en-US')} description tokens before agent-side limits, truncation, or omission; median skill body ~${receipt.tax.bodyTokensMedian.toLocaleString('en-US')} tokens when fired${heaviest ? `; heaviest: ${heaviest}` : ''}`);
42
+ }
43
+ }
44
+ export function renderReceipts(receipts) {
45
+ const lines = [];
46
+ lines.push('skillfit report — skill usage receipts (read-only; local session history, no model calls)');
47
+ lines.push('');
48
+ for (const receipt of receipts) {
49
+ renderAgent(receipt, lines);
50
+ lines.push('');
51
+ }
52
+ // One population: distinct installed skill names. `installed` was already deduped across agents
53
+ // while `fired` and `never` were per-agent sums, so a skill installed for three agents counted once
54
+ // in the first figure and up to three times in the other two, `fired` could exceed `installed`, and
55
+ // the three numbers never added up. Both are now restricted to the installed set, so
56
+ // installed = fired + never holds exactly, and a skill that fired but has since been uninstalled
57
+ // does not inflate the count.
58
+ const installed = new Set(receipts.flatMap((r) => r.installed));
59
+ const firedNames = new Set(receipts.flatMap((r) => r.skills.map((s) => s.name)));
60
+ const fired = [...installed].filter((name) => firedNames.has(name)).sort();
61
+ const never = [...installed].filter((name) => !firedNames.has(name)).sort();
62
+ lines.push(`Overall: ${installed.size} installed skill(s), ${fired.length} observed firing, ${never.length} with no observed fire in retained history.`);
63
+ if (never.length > 0) {
64
+ lines.push('Treat this as a prioritization signal, not proof of uselessness: install dates are unavailable. Verify candidates with: skillfit eval <skill> --mode trigger');
65
+ }
66
+ return lines.join('\n');
67
+ }
68
+ export async function runReport(options) {
69
+ const log = options.log ?? ((msg) => console.log(msg));
70
+ const receipts = await collectReceipts({ agent: options.agent, homeDir: options.homeDir });
71
+ if (options.json) {
72
+ log(JSON.stringify(receipts, null, 2));
73
+ }
74
+ else {
75
+ log(renderReceipts(receipts));
76
+ }
77
+ return receipts;
78
+ }