akm-cli 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/package.json +8 -8
  2. package/dist/tests/add-website-source.test.js +0 -119
  3. package/dist/tests/agent/agent-config-loader.test.js +0 -70
  4. package/dist/tests/agent/agent-config.test.js +0 -221
  5. package/dist/tests/agent/agent-detect.test.js +0 -100
  6. package/dist/tests/agent/agent-spawn.test.js +0 -234
  7. package/dist/tests/agent-output.test.js +0 -186
  8. package/dist/tests/architecture/agent-no-llm-sdk-guard.test.js +0 -103
  9. package/dist/tests/architecture/agent-spawn-seam.test.js +0 -193
  10. package/dist/tests/architecture/llm-stateless-seam.test.js +0 -112
  11. package/dist/tests/asset-ref.test.js +0 -192
  12. package/dist/tests/asset-registry.test.js +0 -103
  13. package/dist/tests/asset-spec.test.js +0 -241
  14. package/dist/tests/bench/attribution.test.js +0 -996
  15. package/dist/tests/bench/cleanup-sigint.test.js +0 -83
  16. package/dist/tests/bench/cleanup.js +0 -234
  17. package/dist/tests/bench/cleanup.test.js +0 -166
  18. package/dist/tests/bench/cli.js +0 -1018
  19. package/dist/tests/bench/cli.test.js +0 -445
  20. package/dist/tests/bench/compare.test.js +0 -556
  21. package/dist/tests/bench/corpus.js +0 -317
  22. package/dist/tests/bench/corpus.test.js +0 -258
  23. package/dist/tests/bench/doctor.js +0 -525
  24. package/dist/tests/bench/driver.js +0 -401
  25. package/dist/tests/bench/driver.test.js +0 -584
  26. package/dist/tests/bench/environment.js +0 -233
  27. package/dist/tests/bench/environment.test.js +0 -199
  28. package/dist/tests/bench/evolve-metrics.js +0 -179
  29. package/dist/tests/bench/evolve-metrics.test.js +0 -187
  30. package/dist/tests/bench/evolve.js +0 -647
  31. package/dist/tests/bench/evolve.test.js +0 -624
  32. package/dist/tests/bench/failure-modes.test.js +0 -349
  33. package/dist/tests/bench/feedback-integrity.test.js +0 -457
  34. package/dist/tests/bench/leakage.test.js +0 -228
  35. package/dist/tests/bench/learning-curve.test.js +0 -134
  36. package/dist/tests/bench/metrics.js +0 -2395
  37. package/dist/tests/bench/metrics.test.js +0 -1150
  38. package/dist/tests/bench/no-os-tmpdir-invariant.test.js +0 -43
  39. package/dist/tests/bench/opencode-config.js +0 -194
  40. package/dist/tests/bench/opencode-config.test.js +0 -370
  41. package/dist/tests/bench/report.js +0 -1885
  42. package/dist/tests/bench/report.test.js +0 -1038
  43. package/dist/tests/bench/run-config.js +0 -355
  44. package/dist/tests/bench/run-config.test.js +0 -298
  45. package/dist/tests/bench/run-curate-test.js +0 -32
  46. package/dist/tests/bench/run-failing-tasks.js +0 -56
  47. package/dist/tests/bench/run-full-bench.js +0 -51
  48. package/dist/tests/bench/run-items36-targeted.js +0 -69
  49. package/dist/tests/bench/run-nano-quick.js +0 -42
  50. package/dist/tests/bench/run-waveg-targeted.js +0 -62
  51. package/dist/tests/bench/runner.js +0 -699
  52. package/dist/tests/bench/runner.test.js +0 -958
  53. package/dist/tests/bench/search-bridge.test.js +0 -331
  54. package/dist/tests/bench/tmp.js +0 -131
  55. package/dist/tests/bench/trajectory.js +0 -116
  56. package/dist/tests/bench/trajectory.test.js +0 -127
  57. package/dist/tests/bench/verifier.js +0 -114
  58. package/dist/tests/bench/verifier.test.js +0 -118
  59. package/dist/tests/bench/workflow-evaluator.js +0 -557
  60. package/dist/tests/bench/workflow-evaluator.test.js +0 -421
  61. package/dist/tests/bench/workflow-spec.js +0 -345
  62. package/dist/tests/bench/workflow-spec.test.js +0 -363
  63. package/dist/tests/bench/workflow-trace.js +0 -472
  64. package/dist/tests/bench/workflow-trace.test.js +0 -254
  65. package/dist/tests/benchmark-search-quality.js +0 -536
  66. package/dist/tests/benchmark-suite.js +0 -1441
  67. package/dist/tests/capture-cli.test.js +0 -112
  68. package/dist/tests/cli-errors.test.js +0 -204
  69. package/dist/tests/commands/events.test.js +0 -370
  70. package/dist/tests/commands/history.test.js +0 -418
  71. package/dist/tests/commands/import.test.js +0 -103
  72. package/dist/tests/commands/proposal-cli.test.js +0 -209
  73. package/dist/tests/commands/reflect-propose-cli.test.js +0 -333
  74. package/dist/tests/commands/remember.test.js +0 -97
  75. package/dist/tests/commands/scope-flags.test.js +0 -300
  76. package/dist/tests/commands/search.test.js +0 -537
  77. package/dist/tests/commands/show-indexer-parity.test.js +0 -117
  78. package/dist/tests/commands/show.test.js +0 -294
  79. package/dist/tests/common.test.js +0 -266
  80. package/dist/tests/completions.test.js +0 -142
  81. package/dist/tests/config-cli.test.js +0 -193
  82. package/dist/tests/config-llm-features.test.js +0 -139
  83. package/dist/tests/config.test.js +0 -569
  84. package/dist/tests/contracts/migration-baseline.test.js +0 -43
  85. package/dist/tests/contracts/reflect-propose-envelope.test.js +0 -139
  86. package/dist/tests/contracts/spec-helpers.js +0 -46
  87. package/dist/tests/contracts/v1-spec-section-11-proposal-queue.test.js +0 -228
  88. package/dist/tests/contracts/v1-spec-section-12-agent-config.test.js +0 -56
  89. package/dist/tests/contracts/v1-spec-section-13-lesson-type.test.js +0 -34
  90. package/dist/tests/contracts/v1-spec-section-14-llm-features.test.js +0 -94
  91. package/dist/tests/contracts/v1-spec-section-4-1-asset-types.test.js +0 -39
  92. package/dist/tests/contracts/v1-spec-section-4-2-quality-rules.test.js +0 -44
  93. package/dist/tests/contracts/v1-spec-section-5-configuration.test.js +0 -47
  94. package/dist/tests/contracts/v1-spec-section-6-orchestration.test.js +0 -40
  95. package/dist/tests/contracts/v1-spec-section-7-module-layout.test.js +0 -58
  96. package/dist/tests/contracts/v1-spec-section-8-extension-points.test.js +0 -34
  97. package/dist/tests/contracts/v1-spec-section-9-4-cli-surface.test.js +0 -75
  98. package/dist/tests/contracts/v1-spec-section-9-7-llm-agent-boundary.test.js +0 -36
  99. package/dist/tests/core/write-source.test.js +0 -366
  100. package/dist/tests/curate-command.test.js +0 -87
  101. package/dist/tests/db-scoring.test.js +0 -201
  102. package/dist/tests/db.test.js +0 -654
  103. package/dist/tests/distill-cli-flag.test.js +0 -208
  104. package/dist/tests/distill.test.js +0 -515
  105. package/dist/tests/docker-install.test.js +0 -120
  106. package/dist/tests/e2e.test.js +0 -1419
  107. package/dist/tests/embedder.test.js +0 -340
  108. package/dist/tests/embedding-model-config.test.js +0 -379
  109. package/dist/tests/feedback-command.test.js +0 -172
  110. package/dist/tests/file-context.test.js +0 -552
  111. package/dist/tests/fixtures/scripts/git/summarize-diff.js +0 -9
  112. package/dist/tests/fixtures/scripts/lint/eslint-check.js +0 -7
  113. package/dist/tests/fixtures/stashes/load.js +0 -166
  114. package/dist/tests/fixtures/stashes/load.test.js +0 -97
  115. package/dist/tests/fixtures/stashes/ranking-baseline/scripts/mem0-search.js +0 -12
  116. package/dist/tests/frontmatter.test.js +0 -190
  117. package/dist/tests/fts-field-weighting.test.js +0 -254
  118. package/dist/tests/fuzzy-search.test.js +0 -230
  119. package/dist/tests/git-provider-clone.test.js +0 -45
  120. package/dist/tests/github.test.js +0 -161
  121. package/dist/tests/graph-boost-ranking.test.js +0 -305
  122. package/dist/tests/graph-extraction.test.js +0 -282
  123. package/dist/tests/helpers/usage-events.js +0 -8
  124. package/dist/tests/index-pass-llm.test.js +0 -161
  125. package/dist/tests/indexer.test.js +0 -570
  126. package/dist/tests/info-command.test.js +0 -166
  127. package/dist/tests/init.test.js +0 -69
  128. package/dist/tests/install-script.test.js +0 -246
  129. package/dist/tests/integration/agent-real-profile.test.js +0 -94
  130. package/dist/tests/issue-36-repro.test.js +0 -304
  131. package/dist/tests/issues-191-194.test.js +0 -160
  132. package/dist/tests/lesson-lint.test.js +0 -111
  133. package/dist/tests/llm-client.test.js +0 -115
  134. package/dist/tests/llm-feature-gate.test.js +0 -151
  135. package/dist/tests/llm.test.js +0 -139
  136. package/dist/tests/lockfile.test.js +0 -216
  137. package/dist/tests/manifest.test.js +0 -205
  138. package/dist/tests/markdown.test.js +0 -126
  139. package/dist/tests/matchers-unit.test.js +0 -189
  140. package/dist/tests/memory-inference.test.js +0 -299
  141. package/dist/tests/merge-scoring.test.js +0 -136
  142. package/dist/tests/metadata.test.js +0 -313
  143. package/dist/tests/migration-help.test.js +0 -89
  144. package/dist/tests/origin-resolve.test.js +0 -124
  145. package/dist/tests/output-baseline.test.js +0 -218
  146. package/dist/tests/output-shapes-unit.test.js +0 -478
  147. package/dist/tests/parallel-search.test.js +0 -272
  148. package/dist/tests/parameter-metadata.test.js +0 -365
  149. package/dist/tests/paths.test.js +0 -177
  150. package/dist/tests/progressive-disclosure.test.js +0 -280
  151. package/dist/tests/proposals.test.js +0 -279
  152. package/dist/tests/proposed-quality.test.js +0 -271
  153. package/dist/tests/provider-registry.test.js +0 -32
  154. package/dist/tests/ranking-regression.test.js +0 -548
  155. package/dist/tests/reflect-propose.test.js +0 -455
  156. package/dist/tests/registry-build-index.test.js +0 -394
  157. package/dist/tests/registry-cli.test.js +0 -290
  158. package/dist/tests/registry-index-v2.test.js +0 -430
  159. package/dist/tests/registry-install.test.js +0 -728
  160. package/dist/tests/registry-providers/parity.test.js +0 -189
  161. package/dist/tests/registry-providers/skills-sh.test.js +0 -309
  162. package/dist/tests/registry-providers/static-index.test.js +0 -238
  163. package/dist/tests/registry-resolve.test.js +0 -126
  164. package/dist/tests/registry-search.test.js +0 -923
  165. package/dist/tests/remember-frontmatter.test.js +0 -378
  166. package/dist/tests/remember-unit.test.js +0 -123
  167. package/dist/tests/ripgrep-install.test.js +0 -251
  168. package/dist/tests/ripgrep-resolve.test.js +0 -108
  169. package/dist/tests/ripgrep.test.js +0 -163
  170. package/dist/tests/save-command.test.js +0 -94
  171. package/dist/tests/save-trust-qa-fixes.test.js +0 -270
  172. package/dist/tests/scoring-pipeline.test.js +0 -648
  173. package/dist/tests/search-include-proposed-cli.test.js +0 -118
  174. package/dist/tests/self-update.test.js +0 -442
  175. package/dist/tests/semantic-search-e2e.test.js +0 -512
  176. package/dist/tests/semantic-status.test.js +0 -471
  177. package/dist/tests/setup-run.integration.js +0 -877
  178. package/dist/tests/setup-wizard.test.js +0 -198
  179. package/dist/tests/setup.test.js +0 -131
  180. package/dist/tests/source-add.test.js +0 -11
  181. package/dist/tests/source-clone.test.js +0 -254
  182. package/dist/tests/source-manage.test.js +0 -366
  183. package/dist/tests/source-providers/filesystem.test.js +0 -82
  184. package/dist/tests/source-providers/git.test.js +0 -252
  185. package/dist/tests/source-providers/website.test.js +0 -128
  186. package/dist/tests/source-qa-fixes.test.js +0 -286
  187. package/dist/tests/source-registry.test.js +0 -350
  188. package/dist/tests/source-resolve.test.js +0 -100
  189. package/dist/tests/source-source.test.js +0 -281
  190. package/dist/tests/source.test.js +0 -533
  191. package/dist/tests/tar-utils-scan.test.js +0 -73
  192. package/dist/tests/toggle-components.test.js +0 -73
  193. package/dist/tests/usage-telemetry.test.js +0 -265
  194. package/dist/tests/utility-scoring.test.js +0 -558
  195. package/dist/tests/vault-load-error.test.js +0 -78
  196. package/dist/tests/vault-qa-fixes.test.js +0 -194
  197. package/dist/tests/vault.test.js +0 -429
  198. package/dist/tests/vector-search.test.js +0 -608
  199. package/dist/tests/walker.test.js +0 -252
  200. package/dist/tests/wave2-cluster-bc.test.js +0 -228
  201. package/dist/tests/wave2-cluster-d.test.js +0 -180
  202. package/dist/tests/wave2-cluster-e.test.js +0 -179
  203. package/dist/tests/wiki-qa-fixes.test.js +0 -270
  204. package/dist/tests/wiki.test.js +0 -529
  205. package/dist/tests/workflow-cli.test.js +0 -271
  206. package/dist/tests/workflow-markdown.test.js +0 -171
  207. package/dist/tests/workflow-path-escape.test.js +0 -132
  208. package/dist/tests/workflow-qa-fixes.test.js +0 -395
  209. package/dist/tests/workflows/indexer-rejection.test.js +0 -213
  210. /package/dist/{src/cli.js → cli.js} +0 -0
  211. /package/dist/{src/commands → commands}/completions.js +0 -0
  212. /package/dist/{src/commands → commands}/config-cli.js +0 -0
  213. /package/dist/{src/commands → commands}/curate.js +0 -0
  214. /package/dist/{src/commands → commands}/distill.js +0 -0
  215. /package/dist/{src/commands → commands}/events.js +0 -0
  216. /package/dist/{src/commands → commands}/history.js +0 -0
  217. /package/dist/{src/commands → commands}/info.js +0 -0
  218. /package/dist/{src/commands → commands}/init.js +0 -0
  219. /package/dist/{src/commands → commands}/install-audit.js +0 -0
  220. /package/dist/{src/commands → commands}/installed-stashes.js +0 -0
  221. /package/dist/{src/commands → commands}/migration-help.js +0 -0
  222. /package/dist/{src/commands → commands}/proposal.js +0 -0
  223. /package/dist/{src/commands → commands}/propose.js +0 -0
  224. /package/dist/{src/commands → commands}/reflect.js +0 -0
  225. /package/dist/{src/commands → commands}/registry-search.js +0 -0
  226. /package/dist/{src/commands → commands}/remember.js +0 -0
  227. /package/dist/{src/commands → commands}/search.js +0 -0
  228. /package/dist/{src/commands → commands}/self-update.js +0 -0
  229. /package/dist/{src/commands → commands}/show.js +0 -0
  230. /package/dist/{src/commands → commands}/source-add.js +0 -0
  231. /package/dist/{src/commands → commands}/source-clone.js +0 -0
  232. /package/dist/{src/commands → commands}/source-manage.js +0 -0
  233. /package/dist/{src/commands → commands}/vault.js +0 -0
  234. /package/dist/{src/core → core}/asset-ref.js +0 -0
  235. /package/dist/{src/core → core}/asset-registry.js +0 -0
  236. /package/dist/{src/core → core}/asset-spec.js +0 -0
  237. /package/dist/{src/core → core}/common.js +0 -0
  238. /package/dist/{src/core → core}/config.js +0 -0
  239. /package/dist/{src/core → core}/errors.js +0 -0
  240. /package/dist/{src/core → core}/events.js +0 -0
  241. /package/dist/{src/core → core}/frontmatter.js +0 -0
  242. /package/dist/{src/core → core}/lesson-lint.js +0 -0
  243. /package/dist/{src/core → core}/markdown.js +0 -0
  244. /package/dist/{src/core → core}/paths.js +0 -0
  245. /package/dist/{src/core → core}/proposals.js +0 -0
  246. /package/dist/{src/core → core}/warn.js +0 -0
  247. /package/dist/{src/core → core}/write-source.js +0 -0
  248. /package/dist/{src/indexer → indexer}/db-search.js +0 -0
  249. /package/dist/{src/indexer → indexer}/db.js +0 -0
  250. /package/dist/{src/indexer → indexer}/file-context.js +0 -0
  251. /package/dist/{src/indexer → indexer}/graph-boost.js +0 -0
  252. /package/dist/{src/indexer → indexer}/graph-extraction.js +0 -0
  253. /package/dist/{src/indexer → indexer}/indexer.js +0 -0
  254. /package/dist/{src/indexer → indexer}/manifest.js +0 -0
  255. /package/dist/{src/indexer → indexer}/matchers.js +0 -0
  256. /package/dist/{src/indexer → indexer}/memory-inference.js +0 -0
  257. /package/dist/{src/indexer → indexer}/metadata.js +0 -0
  258. /package/dist/{src/indexer → indexer}/search-fields.js +0 -0
  259. /package/dist/{src/indexer → indexer}/search-source.js +0 -0
  260. /package/dist/{src/indexer → indexer}/semantic-status.js +0 -0
  261. /package/dist/{src/indexer → indexer}/usage-events.js +0 -0
  262. /package/dist/{src/indexer → indexer}/walker.js +0 -0
  263. /package/dist/{src/integrations → integrations}/agent/config.js +0 -0
  264. /package/dist/{src/integrations → integrations}/agent/detect.js +0 -0
  265. /package/dist/{src/integrations → integrations}/agent/index.js +0 -0
  266. /package/dist/{src/integrations → integrations}/agent/profiles.js +0 -0
  267. /package/dist/{src/integrations → integrations}/agent/prompts.js +0 -0
  268. /package/dist/{src/integrations → integrations}/agent/spawn.js +0 -0
  269. /package/dist/{src/integrations → integrations}/github.js +0 -0
  270. /package/dist/{src/integrations → integrations}/lockfile.js +0 -0
  271. /package/dist/{src/llm → llm}/client.js +0 -0
  272. /package/dist/{src/llm → llm}/embedder.js +0 -0
  273. /package/dist/{src/llm → llm}/embedders/cache.js +0 -0
  274. /package/dist/{src/llm → llm}/embedders/local.js +0 -0
  275. /package/dist/{src/llm → llm}/embedders/remote.js +0 -0
  276. /package/dist/{src/llm → llm}/embedders/types.js +0 -0
  277. /package/dist/{src/llm → llm}/feature-gate.js +0 -0
  278. /package/dist/{src/llm → llm}/graph-extract.js +0 -0
  279. /package/dist/{src/llm → llm}/index-passes.js +0 -0
  280. /package/dist/{src/llm → llm}/memory-infer.js +0 -0
  281. /package/dist/{src/llm → llm}/metadata-enhance.js +0 -0
  282. /package/dist/{src/output → output}/cli-hints.js +0 -0
  283. /package/dist/{src/output → output}/context.js +0 -0
  284. /package/dist/{src/output → output}/renderers.js +0 -0
  285. /package/dist/{src/output → output}/shapes.js +0 -0
  286. /package/dist/{src/output → output}/text.js +0 -0
  287. /package/dist/{src/registry → registry}/build-index.js +0 -0
  288. /package/dist/{src/registry → registry}/create-provider-registry.js +0 -0
  289. /package/dist/{src/registry → registry}/factory.js +0 -0
  290. /package/dist/{src/registry → registry}/origin-resolve.js +0 -0
  291. /package/dist/{src/registry → registry}/providers/index.js +0 -0
  292. /package/dist/{src/registry → registry}/providers/skills-sh.js +0 -0
  293. /package/dist/{src/registry → registry}/providers/static-index.js +0 -0
  294. /package/dist/{src/registry → registry}/providers/types.js +0 -0
  295. /package/dist/{src/registry → registry}/resolve.js +0 -0
  296. /package/dist/{src/registry → registry}/types.js +0 -0
  297. /package/dist/{src/setup → setup}/detect.js +0 -0
  298. /package/dist/{src/setup → setup}/ripgrep-install.js +0 -0
  299. /package/dist/{src/setup → setup}/ripgrep-resolve.js +0 -0
  300. /package/dist/{src/setup → setup}/setup.js +0 -0
  301. /package/dist/{src/setup → setup}/steps.js +0 -0
  302. /package/dist/{src/sources → sources}/include.js +0 -0
  303. /package/dist/{src/sources → sources}/provider-factory.js +0 -0
  304. /package/dist/{src/sources → sources}/provider.js +0 -0
  305. /package/dist/{src/sources → sources}/providers/filesystem.js +0 -0
  306. /package/dist/{src/sources → sources}/providers/git.js +0 -0
  307. /package/dist/{src/sources → sources}/providers/index.js +0 -0
  308. /package/dist/{src/sources → sources}/providers/install-types.js +0 -0
  309. /package/dist/{src/sources → sources}/providers/npm.js +0 -0
  310. /package/dist/{src/sources → sources}/providers/provider-utils.js +0 -0
  311. /package/dist/{src/sources → sources}/providers/sync-from-ref.js +0 -0
  312. /package/dist/{src/sources → sources}/providers/tar-utils.js +0 -0
  313. /package/dist/{src/sources → sources}/providers/website.js +0 -0
  314. /package/dist/{src/sources → sources}/resolve.js +0 -0
  315. /package/dist/{src/sources → sources}/types.js +0 -0
  316. /package/dist/{src/templates → templates}/wiki-templates.js +0 -0
  317. /package/dist/{src/version.js → version.js} +0 -0
  318. /package/dist/{src/wiki → wiki}/wiki.js +0 -0
  319. /package/dist/{src/workflows → workflows}/authoring.js +0 -0
  320. /package/dist/{src/workflows → workflows}/cli.js +0 -0
  321. /package/dist/{src/workflows → workflows}/db.js +0 -0
  322. /package/dist/{src/workflows → workflows}/document-cache.js +0 -0
  323. /package/dist/{src/workflows → workflows}/parser.js +0 -0
  324. /package/dist/{src/workflows → workflows}/renderer.js +0 -0
  325. /package/dist/{src/workflows → workflows}/runs.js +0 -0
  326. /package/dist/{src/workflows → workflows}/schema.js +0 -0
  327. /package/dist/{src/workflows → workflows}/validator.js +0 -0
@@ -1,445 +0,0 @@
1
- /**
2
- * Unit tests for the bench CLI dispatcher.
3
- *
4
- * We exercise the binary by spawning it with various argv permutations.
5
- * Real opencode is never invoked — the corpus tasks each fail at the
6
- * agent-spawn step (no `opencode` on PATH in CI), and that is exactly the
7
- * failure mode we want to verify produces a valid §13.3 envelope.
8
- */
9
- import { describe, expect, test } from "bun:test";
10
- import fs from "node:fs";
11
- import path from "node:path";
12
- const REPO_ROOT = path.resolve(__dirname, "..", "..");
13
- const CLI = path.join(REPO_ROOT, "tests", "bench", "cli.ts");
14
- function run(args, env = {}) {
15
- const result = Bun.spawnSync({
16
- cmd: ["bun", "run", CLI, ...args],
17
- cwd: REPO_ROOT,
18
- env: { ...process.env, ...env },
19
- stdout: "pipe",
20
- stderr: "pipe",
21
- });
22
- return {
23
- exitCode: result.exitCode ?? -1,
24
- stdout: new TextDecoder().decode(result.stdout ?? new Uint8Array()),
25
- stderr: new TextDecoder().decode(result.stderr ?? new Uint8Array()),
26
- };
27
- }
28
- describe("bench CLI", () => {
29
- test("`help` subcommand exits 0 and lists the five subcommands", () => {
30
- const r = run(["help"]);
31
- expect(r.exitCode).toBe(0);
32
- expect(r.stdout).toContain("utility");
33
- expect(r.stdout).toContain("evolve");
34
- expect(r.stdout).toContain("compare");
35
- expect(r.stdout).toContain("attribute");
36
- expect(r.stdout).toContain("clean");
37
- });
38
- test("`clean` subcommand exits 0 and removes bench tmp root", () => {
39
- const r = run(["clean"]);
40
- expect(r.exitCode).toBe(0);
41
- expect(r.stderr).toContain("bench clean:");
42
- });
43
- test("utility without BENCH_OPENCODE_MODEL exits 2 when no providers file supplies defaultModel", () => {
44
- // When BENCH_OPENCODE_MODEL is unset AND the providers file has no
45
- // defaultModel, exit 2 fires. We supply a minimal no-defaultModel file
46
- // via --opencode-config to prevent the committed fixture's defaultModel
47
- // from satisfying the model requirement.
48
- const tmpDir = fs.mkdtempSync("/tmp/bench-cli-nomodel-test-");
49
- const noModelPath = path.join(tmpDir, "no-default.json");
50
- try {
51
- fs.writeFileSync(noModelPath, JSON.stringify({ schemaVersion: 1, providers: { p: { npm: "@ai-sdk/openai-compatible" } } }));
52
- const r = run(["utility", "--tasks", "train", "--opencode-config", noModelPath], {
53
- BENCH_OPENCODE_MODEL: "",
54
- });
55
- expect(r.exitCode).toBe(2);
56
- expect(r.stderr).toContain("BENCH_OPENCODE_MODEL");
57
- }
58
- finally {
59
- fs.rmSync(tmpDir, { recursive: true, force: true });
60
- }
61
- });
62
- test("evolve without --tasks exits 2 with usage error", () => {
63
- const r = run(["evolve"], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
64
- expect(r.exitCode).toBe(2);
65
- expect(r.stderr).toContain("--tasks");
66
- });
67
- test("evolve without BENCH_OPENCODE_MODEL exits 2 when no providers file supplies defaultModel", () => {
68
- // Same pattern as utility: supply a no-defaultModel providers file so the
69
- // model-required check fires.
70
- const tmpDir = fs.mkdtempSync("/tmp/bench-cli-nomodel-evolve-test-");
71
- const noModelPath = path.join(tmpDir, "no-default.json");
72
- try {
73
- fs.writeFileSync(noModelPath, JSON.stringify({ schemaVersion: 1, providers: { p: { npm: "@ai-sdk/openai-compatible" } } }));
74
- const r = run(["evolve", "--tasks", "docker-homelab", "--opencode-config", noModelPath], {
75
- BENCH_OPENCODE_MODEL: "",
76
- });
77
- expect(r.exitCode).toBe(2);
78
- expect(r.stderr).toContain("BENCH_OPENCODE_MODEL");
79
- }
80
- finally {
81
- fs.rmSync(tmpDir, { recursive: true, force: true });
82
- }
83
- });
84
- test("attribute without --base exits 2", () => {
85
- const r = run(["attribute"]);
86
- expect(r.exitCode).toBe(2);
87
- expect(r.stderr).toContain("--base");
88
- });
89
- test("attribute with missing --base file exits 2", () => {
90
- const r = run(["attribute", "--base", "/nonexistent/run.json"]);
91
- expect(r.exitCode).toBe(2);
92
- expect(r.stderr).toContain("not found");
93
- });
94
- test("utility --tasks train --seeds 1 --json produces a §13.3 envelope", () => {
95
- const r = run(["utility", "--tasks", "train", "--seeds", "1", "--budget-tokens", "1000", "--budget-wall-ms", "1000", "--json"], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
96
- expect(r.exitCode).toBe(0);
97
- // Stdout should be valid JSON.
98
- let parsed;
99
- expect(() => {
100
- parsed = JSON.parse(r.stdout);
101
- }).not.toThrow();
102
- parsed = JSON.parse(r.stdout);
103
- expect(parsed.schemaVersion).toBe(1);
104
- expect(parsed.track).toBe("utility");
105
- expect(parsed.agent.model).toBe("anthropic/claude-opus-4-7");
106
- const corpus = parsed.corpus;
107
- expect(corpus.slice).toBe("train");
108
- expect(corpus.seedsPerArm).toBe(1);
109
- expect(typeof corpus.tasks).toBe("number");
110
- expect(corpus.tasks > 0).toBe(true);
111
- expect(Array.isArray(parsed.tasks)).toBe(true);
112
- expect(Array.isArray(parsed.warnings)).toBe(true);
113
- // Aggregate must have all three sections.
114
- const aggregate = parsed.aggregate;
115
- expect(aggregate.noakm).toBeDefined();
116
- expect(aggregate.akm).toBeDefined();
117
- expect(aggregate.delta).toBeDefined();
118
- // Trajectory.akm must have both fields.
119
- const trajectory = parsed.trajectory.akm;
120
- expect("correct_asset_loaded" in trajectory).toBe(true);
121
- expect("feedback_recorded" in trajectory).toBe(true);
122
- }, 60_000);
123
- test("utility --tasks eval filters to eval slice", () => {
124
- const trainR = run(["utility", "--tasks", "train", "--seeds", "1", "--budget-tokens", "100", "--budget-wall-ms", "100", "--json"], { BENCH_OPENCODE_MODEL: "test-model" });
125
- const evalR = run(["utility", "--tasks", "eval", "--seeds", "1", "--budget-tokens", "100", "--budget-wall-ms", "100", "--json"], { BENCH_OPENCODE_MODEL: "test-model" });
126
- expect(trainR.exitCode).toBe(0);
127
- expect(evalR.exitCode).toBe(0);
128
- const trainCorpus = JSON.parse(trainR.stdout).corpus;
129
- const evalCorpus = JSON.parse(evalR.stdout).corpus;
130
- // The two slices partition the corpus; together they should account for every non-_example task.
131
- expect(trainCorpus.tasks + evalCorpus.tasks).toBeGreaterThanOrEqual(1);
132
- }, 60_000);
133
- test("unknown subcommand exits 2 and prints help", () => {
134
- const r = run(["bogus"]);
135
- expect(r.exitCode).toBe(2);
136
- expect(r.stderr).toContain("unknown subcommand");
137
- });
138
- test("unknown --tasks value exits 2 with a clear error (no silent coerce to all)", () => {
139
- const r = run(["utility", "--tasks", "bogus"], { BENCH_OPENCODE_MODEL: "test-model" });
140
- expect(r.exitCode).toBe(2);
141
- expect(r.stderr).toContain("invalid --tasks");
142
- expect(r.stderr).toContain("bogus");
143
- expect(r.stderr).toContain("all");
144
- expect(r.stderr).toContain("train");
145
- expect(r.stderr).toContain("eval");
146
- });
147
- test("without --json: JSON still goes to stdout, markdown summary goes to stderr", () => {
148
- const r = run(
149
- // --no-noakm to keep run count at 1 arm (faster), since this test is
150
- // about the stdout/stderr contract, not the noakm arm.
151
- [
152
- "utility",
153
- "--tasks",
154
- "train",
155
- "--seeds",
156
- "1",
157
- "--budget-tokens",
158
- "1000",
159
- "--budget-wall-ms",
160
- "1000",
161
- "--no-noakm",
162
- ], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
163
- expect(r.exitCode).toBe(0);
164
- // stdout MUST be valid JSON (the bench's machine-readable contract).
165
- let parsed;
166
- expect(() => {
167
- parsed = JSON.parse(r.stdout);
168
- }).not.toThrow();
169
- expect(parsed?.schemaVersion).toBe(1);
170
- expect(parsed?.track).toBe("utility");
171
- // stderr MUST contain the human-friendly markdown summary.
172
- expect(r.stderr).toContain("# akm-bench utility");
173
- expect(r.stderr).toContain("## Aggregate");
174
- expect(r.stderr).toContain("tasks discovered:");
175
- }, 60_000);
176
- // ── C2: noakm arm now default-on; --no-noakm opts out ────────────────────
177
- test("utility help mentions --no-noakm flag", () => {
178
- const r = run(["help"]);
179
- expect(r.exitCode).toBe(0);
180
- expect(r.stdout).toContain("--no-noakm");
181
- });
182
- test("utility default: aggregate includes noakm arm", () => {
183
- const r = run(["utility", "--tasks", "train", "--seeds", "1", "--budget-tokens", "1000", "--budget-wall-ms", "1000", "--json"], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
184
- expect(r.exitCode).toBe(0);
185
- const parsed = JSON.parse(r.stdout);
186
- const aggregate = parsed.aggregate;
187
- expect(aggregate.noakm).toBeDefined();
188
- expect(aggregate.akm).toBeDefined();
189
- expect(aggregate.delta).toBeDefined();
190
- }, 60_000);
191
- test("utility --no-noakm: envelope is valid and contains akm arm", () => {
192
- // When --no-noakm is passed the noakm arm does not run. The JSON envelope
193
- // is still valid (aggregate.noakm exists but reflects zero runs); akm
194
- // is present with real run data. Exit 0.
195
- const r = run([
196
- "utility",
197
- "--tasks",
198
- "train",
199
- "--seeds",
200
- "1",
201
- "--budget-tokens",
202
- "1000",
203
- "--budget-wall-ms",
204
- "1000",
205
- "--no-noakm",
206
- "--json",
207
- ], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
208
- expect(r.exitCode).toBe(0);
209
- const parsed = JSON.parse(r.stdout);
210
- expect(parsed.schemaVersion).toBe(1);
211
- const aggregate = parsed.aggregate;
212
- expect(aggregate.akm).toBeDefined();
213
- }, 60_000);
214
- // ── #261: --include-synthetic flag ─────────────────────────────────────────
215
- test("utility help mentions --include-synthetic flag", () => {
216
- const r = run(["help"]);
217
- expect(r.exitCode).toBe(0);
218
- expect(r.stdout).toContain("--include-synthetic");
219
- });
220
- test("utility --include-synthetic adds aggregate.synthetic + akm_over_synthetic_lift", () => {
221
- const r = run([
222
- "utility",
223
- "--tasks",
224
- "train",
225
- "--seeds",
226
- "1",
227
- "--budget-tokens",
228
- "1000",
229
- "--budget-wall-ms",
230
- "1000",
231
- "--no-noakm", // isolate: test is about the synthetic arm, not noakm
232
- "--include-synthetic",
233
- "--json",
234
- ], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
235
- expect(r.exitCode).toBe(0);
236
- const parsed = JSON.parse(r.stdout);
237
- const aggregate = parsed.aggregate;
238
- expect(aggregate.synthetic).toBeDefined();
239
- expect("akm_over_synthetic_lift" in aggregate).toBe(true);
240
- }, 60_000);
241
- test("utility WITHOUT --include-synthetic: aggregate has no synthetic / akm_over_synthetic_lift", () => {
242
- // Byte-identical default contract: no spurious 'synthetic' keys when the
243
- // flag is absent. Use --no-noakm for speed — this test is about synthetic, not noakm.
244
- const r = run([
245
- "utility",
246
- "--tasks",
247
- "train",
248
- "--seeds",
249
- "1",
250
- "--budget-tokens",
251
- "1000",
252
- "--budget-wall-ms",
253
- "1000",
254
- "--no-noakm",
255
- "--json",
256
- ], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
257
- expect(r.exitCode).toBe(0);
258
- const parsed = JSON.parse(r.stdout);
259
- const aggregate = parsed.aggregate;
260
- expect(aggregate.synthetic).toBeUndefined();
261
- expect("akm_over_synthetic_lift" in aggregate).toBe(false);
262
- }, 60_000);
263
- test("with --json: stderr carries no markdown summary", () => {
264
- const r = run(
265
- // --no-noakm for speed — this test is about the json/stderr contract, not noakm.
266
- [
267
- "utility",
268
- "--tasks",
269
- "train",
270
- "--seeds",
271
- "1",
272
- "--budget-tokens",
273
- "1000",
274
- "--budget-wall-ms",
275
- "1000",
276
- "--no-noakm",
277
- "--json",
278
- ], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
279
- expect(r.exitCode).toBe(0);
280
- // stdout is still JSON.
281
- expect(() => JSON.parse(r.stdout)).not.toThrow();
282
- // stderr MUST NOT contain the markdown summary headings.
283
- expect(r.stderr).not.toContain("# akm-bench utility");
284
- expect(r.stderr).not.toContain("## Aggregate");
285
- // The minor trace line is fine.
286
- expect(r.stderr).toContain("tasks discovered:");
287
- }, 60_000);
288
- // ── --opencode-config tests ───────────────────────────────────────────────
289
- test("utility help mentions --opencode-config and BENCH_OPENCODE_CONFIG", () => {
290
- const r = run(["help"]);
291
- expect(r.exitCode).toBe(0);
292
- expect(r.stdout).toContain("--opencode-config");
293
- expect(r.stdout).toContain("BENCH_OPENCODE_CONFIG");
294
- });
295
- test("--opencode-config <missing path> exits 2 (usage error — file not found)", () => {
296
- const r = run(["utility", "--tasks", "train", "--opencode-config", "/nonexistent/providers.json"], {
297
- BENCH_OPENCODE_MODEL: "test-model",
298
- });
299
- expect(r.exitCode).toBe(2);
300
- expect(r.stderr).toContain("not found");
301
- });
302
- test("--opencode-config <invalid JSON file> exits 78 (config error)", () => {
303
- // Write a temp file with bad JSON then pass its path.
304
- const tmpDir = fs.mkdtempSync("/tmp/bench-cli-test-");
305
- const badJsonPath = path.join(tmpDir, "bad.json");
306
- try {
307
- fs.writeFileSync(badJsonPath, "{ this is not valid json }");
308
- const r = run(["utility", "--tasks", "train", "--opencode-config", badJsonPath], {
309
- BENCH_OPENCODE_MODEL: "test-model",
310
- });
311
- expect(r.exitCode).toBe(78);
312
- expect(r.stderr).toContain("JSON parse error");
313
- }
314
- finally {
315
- fs.rmSync(tmpDir, { recursive: true, force: true });
316
- }
317
- });
318
- test("BENCH_OPENCODE_CONFIG env var pointing to missing file exits 2", () => {
319
- const r = run(["utility", "--tasks", "train"], {
320
- BENCH_OPENCODE_MODEL: "test-model",
321
- BENCH_OPENCODE_CONFIG: "/nonexistent/path.json",
322
- });
323
- expect(r.exitCode).toBe(2);
324
- });
325
- test("auto-discovers committed fixture when no flag or env var is set", () => {
326
- // The committed fixture exists at tests/fixtures/bench/opencode-providers.json.
327
- // With no --opencode-config and no BENCH_OPENCODE_CONFIG, the CLI should
328
- // auto-discover it and NOT fail on provider loading. The model must match
329
- // the fixture's provider prefix or we'd get a materialise error at runtime;
330
- // but here we use a tiny budget so it all goes through harness_error anyway.
331
- // The point is: exit code 0 (not 78) when the default fixture is auto-discovered.
332
- const r = run(["utility", "--tasks", "train", "--seeds", "1", "--budget-tokens", "100", "--budget-wall-ms", "100", "--json"], {
333
- BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7",
334
- BENCH_OPENCODE_CONFIG: "", // blank — let auto-discovery run
335
- });
336
- // Should exit 0 — the auto-discovered fixture is valid.
337
- expect(r.exitCode).toBe(0);
338
- }, 60_000);
339
- });
340
- describe("bench CLI — config-file dispatch", () => {
341
- test("config-file dispatch loads tests/bench/configs/nano-quick.json and runs end-to-end", () => {
342
- // Same structure as the legacy auto-discovery test above — the in-tree
343
- // committed fixture supplies providers so this works without
344
- // BENCH_OPENCODE_CONFIG set. We constrain to one task with the --tasks
345
- // override and shrink the budget so failures terminate quickly.
346
- const r = run([
347
- "tests/bench/configs/nano-quick.json",
348
- "--tasks",
349
- "drillbit/backup-policy",
350
- "--seeds",
351
- "1",
352
- "--parallel",
353
- "1",
354
- "--json",
355
- ], {
356
- BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7",
357
- });
358
- expect(r.exitCode).toBe(0);
359
- // JSON envelope carries the corpus block and the per-task array.
360
- const envelope = JSON.parse(r.stdout);
361
- expect(envelope.corpus).toBeDefined();
362
- expect(Array.isArray(envelope.tasks)).toBe(true);
363
- // Stderr trace line confirms the config-mode dispatch ran.
364
- expect(r.stderr).toContain("config=nano-quick");
365
- // No obsolete warnings — the new path doesn't trip them.
366
- expect(r.stderr).not.toContain("[obsolete]");
367
- }, 60_000);
368
- test("config-file dispatch surfaces baseline_by_task_id when the config carries `baseline`", () => {
369
- const r = run([
370
- "tests/bench/configs/failing-tasks.json",
371
- "--tasks",
372
- "drillbit/backup-policy",
373
- "--seeds",
374
- "1",
375
- "--parallel",
376
- "1",
377
- "--json",
378
- ], {
379
- BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7",
380
- });
381
- expect(r.exitCode).toBe(0);
382
- const envelope = JSON.parse(r.stdout);
383
- expect(envelope.baseline_by_task_id).toBeDefined();
384
- expect(typeof envelope.baseline_by_task_id["drillbit/backup-policy"]).toBe("number");
385
- }, 60_000);
386
- test("config-file dispatch with bogus --tasks override exits 2", () => {
387
- const r = run(["tests/bench/configs/nano-quick.json", "--tasks", "drillbit/no-such-task", "--seeds", "1", "--json"], {
388
- BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7",
389
- });
390
- expect(r.exitCode).toBe(2);
391
- expect(r.stderr).toContain("--tasks");
392
- });
393
- test("nonexistent config file falls through to subcommand parser", () => {
394
- // A path that doesn't exist isn't routed to config mode — the subcommand
395
- // parser sees an unknown name and exits 2.
396
- const r = run(["does-not-exist.json"], {
397
- BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7",
398
- });
399
- expect(r.exitCode).toBe(2);
400
- expect(r.stderr).toContain("unknown subcommand");
401
- });
402
- });
403
- describe("bench CLI — obsolete flag warnings", () => {
404
- test("--no-noakm in subcommand mode emits exactly one [obsolete] line for that flag", () => {
405
- const r = run([
406
- "utility",
407
- "--tasks",
408
- "train",
409
- "--seeds",
410
- "1",
411
- "--budget-tokens",
412
- "100",
413
- "--budget-wall-ms",
414
- "100",
415
- "--no-noakm",
416
- "--json",
417
- ], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
418
- expect(r.exitCode).toBe(0);
419
- // The invocation also uses --budget-tokens / --budget-wall-ms which fire
420
- // their own obsolete warnings; this test only asserts that --no-noakm
421
- // emits exactly one line and is deduped.
422
- const noNoakmLines = r.stderr.split("\n").filter((l) => l.includes("[obsolete] --no-noakm"));
423
- expect(noNoakmLines.length).toBe(1);
424
- }, 60_000);
425
- test("--budget-tokens emits an [obsolete] warning that points at budgetTokens", () => {
426
- const r = run(["utility", "--tasks", "train", "--seeds", "1", "--budget-tokens", "100", "--budget-wall-ms", "100", "--json"], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
427
- expect(r.exitCode).toBe(0);
428
- expect(r.stderr).toContain("[obsolete] --budget-tokens");
429
- expect(r.stderr).toContain("budgetTokens");
430
- }, 60_000);
431
- test("config-file dispatch never emits obsolete warnings", () => {
432
- const r = run([
433
- "tests/bench/configs/nano-quick.json",
434
- "--tasks",
435
- "drillbit/backup-policy",
436
- "--seeds",
437
- "1",
438
- "--parallel",
439
- "1",
440
- "--json",
441
- ], { BENCH_OPENCODE_MODEL: "anthropic/claude-opus-4-7" });
442
- expect(r.exitCode).toBe(0);
443
- expect(r.stderr).not.toContain("[obsolete]");
444
- }, 60_000);
445
- });