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,536 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Search quality benchmark for akm.
4
- *
5
- * Standalone script (NOT a bun:test suite) that:
6
- * 1. Creates a temp stash with ~20 well-defined assets
7
- * 2. Indexes them via akmIndex
8
- * 3. Runs 10 benchmark queries via akmSearch
9
- * 4. Computes MRR, Recall@5, per-query metrics
10
- * 5. Outputs deterministic JSON results
11
- *
12
- * Usage:
13
- * bun run tests/benchmark-search-quality.ts
14
- * bun run tests/benchmark-search-quality.ts --json # machine-readable output only
15
- */
16
- import fs from "node:fs";
17
- import os from "node:os";
18
- import path from "node:path";
19
- import { akmSearch } from "../src/commands/search";
20
- import { saveConfig } from "../src/core/config";
21
- import { akmIndex } from "../src/indexer/indexer";
22
- // ── CLI flags ────────────────────────────────────────────────────────────────
23
- const jsonOnly = process.argv.includes("--json");
24
- // ── Environment isolation ────────────────────────────────────────────────────
25
- const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "akm-bench-"));
26
- const testCacheDir = path.join(tmpRoot, "cache");
27
- const testConfigDir = path.join(tmpRoot, "config");
28
- fs.mkdirSync(testCacheDir, { recursive: true });
29
- fs.mkdirSync(testConfigDir, { recursive: true });
30
- const origXdgCache = process.env.XDG_CACHE_HOME;
31
- const origXdgConfig = process.env.XDG_CONFIG_HOME;
32
- const origStashDir = process.env.AKM_STASH_DIR;
33
- process.env.XDG_CACHE_HOME = testCacheDir;
34
- process.env.XDG_CONFIG_HOME = testConfigDir;
35
- function cleanup() {
36
- if (origXdgCache === undefined)
37
- delete process.env.XDG_CACHE_HOME;
38
- else
39
- process.env.XDG_CACHE_HOME = origXdgCache;
40
- if (origXdgConfig === undefined)
41
- delete process.env.XDG_CONFIG_HOME;
42
- else
43
- process.env.XDG_CONFIG_HOME = origXdgConfig;
44
- if (origStashDir === undefined)
45
- delete process.env.AKM_STASH_DIR;
46
- else
47
- process.env.AKM_STASH_DIR = origStashDir;
48
- fs.rmSync(tmpRoot, { recursive: true, force: true });
49
- }
50
- const ASSETS = [
51
- // ── Skills ──
52
- {
53
- dir: "skills/k8s-deploy",
54
- filename: "SKILL.md",
55
- fileContent: "# Kubernetes Deployment\n\nDeploy applications to Kubernetes clusters using kubectl.\n",
56
- stashEntry: {
57
- name: "k8s-deploy",
58
- type: "skill",
59
- description: "Deploy applications to Kubernetes clusters",
60
- tags: ["kubernetes", "deploy", "k8s", "containers"],
61
- searchHints: ["deploy to kubernetes", "kubectl apply", "container orchestration"],
62
- aliases: ["kube-deploy"],
63
- filename: "SKILL.md",
64
- },
65
- },
66
- {
67
- dir: "skills/code-review",
68
- filename: "SKILL.md",
69
- fileContent: "# Code Review\n\nReview pull requests for code quality and best practices.\n",
70
- stashEntry: {
71
- name: "code-review",
72
- type: "skill",
73
- description: "Review code for quality issues and best practices",
74
- tags: ["review", "quality", "pull-request"],
75
- searchHints: ["review pull request", "check code quality"],
76
- filename: "SKILL.md",
77
- },
78
- },
79
- {
80
- dir: "skills/api-design",
81
- filename: "SKILL.md",
82
- fileContent: "# API Design\n\nDesign RESTful APIs following best practices.\n",
83
- stashEntry: {
84
- name: "api-design",
85
- type: "skill",
86
- description: "Design RESTful APIs with OpenAPI specifications",
87
- tags: ["api", "rest", "openapi", "design"],
88
- searchHints: ["design a REST API", "create API specification"],
89
- filename: "SKILL.md",
90
- },
91
- },
92
- {
93
- dir: "skills/refactor",
94
- filename: "SKILL.md",
95
- fileContent: "# Code Refactoring\n\nRefactor code to improve readability and performance.\n",
96
- stashEntry: {
97
- name: "refactor",
98
- type: "skill",
99
- description: "Refactor code to improve structure and maintainability",
100
- tags: ["refactor", "clean-code", "maintenance"],
101
- searchHints: ["improve code structure", "clean up codebase"],
102
- filename: "SKILL.md",
103
- },
104
- },
105
- {
106
- dir: "skills/security-audit",
107
- filename: "SKILL.md",
108
- fileContent: "# Security Audit\n\nAudit applications for security vulnerabilities.\n",
109
- stashEntry: {
110
- name: "security-audit",
111
- type: "skill",
112
- description: "Audit code and infrastructure for security vulnerabilities",
113
- tags: ["security", "audit", "vulnerability", "pentest"],
114
- searchHints: ["find security vulnerabilities", "security scan"],
115
- filename: "SKILL.md",
116
- },
117
- },
118
- // ── Commands ──
119
- {
120
- dir: "commands",
121
- filename: "test-runner.md",
122
- fileContent: "---\ndescription: Run test suites across the project\n---\n# Test Runner\n\nRun all tests.\n",
123
- stashEntry: {
124
- name: "test-runner",
125
- type: "command",
126
- description: "Run test suites across the project",
127
- tags: ["test", "testing", "ci", "runner"],
128
- searchHints: ["run tests", "execute test suite"],
129
- filename: "test-runner.md",
130
- },
131
- },
132
- {
133
- dir: "commands",
134
- filename: "lint-check.md",
135
- fileContent: "---\ndescription: Run linting checks on the codebase\n---\n# Lint Check\n\nLint code.\n",
136
- stashEntry: {
137
- name: "lint-check",
138
- type: "command",
139
- description: "Run linting checks on the codebase",
140
- tags: ["lint", "eslint", "code-quality"],
141
- searchHints: ["lint code", "check for style issues"],
142
- filename: "lint-check.md",
143
- },
144
- },
145
- {
146
- dir: "commands",
147
- filename: "git-summary.md",
148
- fileContent: "---\ndescription: Summarize recent git changes\n---\n# Git Summary\n\nSummarize git log.\n",
149
- stashEntry: {
150
- name: "git-summary",
151
- type: "command",
152
- description: "Summarize recent git changes and commit history",
153
- tags: ["git", "summary", "changelog"],
154
- searchHints: ["summarize git commits", "show recent changes"],
155
- filename: "git-summary.md",
156
- },
157
- },
158
- {
159
- dir: "commands",
160
- filename: "deploy-status.md",
161
- fileContent: "---\ndescription: Check deployment status\n---\n# Deploy Status\n\nCheck deploy status.\n",
162
- stashEntry: {
163
- name: "deploy-status",
164
- type: "command",
165
- description: "Check the current deployment status of services",
166
- tags: ["deploy", "status", "monitoring"],
167
- searchHints: ["check deployment", "is service deployed"],
168
- filename: "deploy-status.md",
169
- },
170
- },
171
- // ── Scripts ──
172
- {
173
- dir: "scripts/pg-backup",
174
- filename: "pg-backup.sh",
175
- fileContent: "#!/bin/bash\n# Backup PostgreSQL database\npg_dump $DATABASE_URL > backup.sql\n",
176
- stashEntry: {
177
- name: "pg-backup",
178
- type: "script",
179
- description: "Backup PostgreSQL database to a SQL dump file",
180
- tags: ["database", "backup", "postgresql", "postgres"],
181
- searchHints: ["backup database", "export postgres data", "pg_dump"],
182
- filename: "pg-backup.sh",
183
- },
184
- },
185
- {
186
- dir: "scripts/docker-clean",
187
- filename: "docker-clean.sh",
188
- fileContent: "#!/bin/bash\n# Clean up Docker resources\ndocker system prune -af\n",
189
- stashEntry: {
190
- name: "docker-clean",
191
- type: "script",
192
- description: "Clean up unused Docker images, containers, and volumes",
193
- tags: ["docker", "cleanup", "containers"],
194
- searchHints: ["clean docker", "remove unused images"],
195
- filename: "docker-clean.sh",
196
- },
197
- },
198
- {
199
- dir: "scripts/ssl-renew",
200
- filename: "ssl-renew.sh",
201
- fileContent: "#!/bin/bash\n# Renew SSL certificates\ncertbot renew\n",
202
- stashEntry: {
203
- name: "ssl-renew",
204
- type: "script",
205
- description: "Renew SSL/TLS certificates using certbot",
206
- tags: ["ssl", "tls", "certificate", "certbot"],
207
- searchHints: ["renew certificates", "ssl renewal"],
208
- filename: "ssl-renew.sh",
209
- },
210
- },
211
- {
212
- dir: "scripts/log-rotate",
213
- filename: "log-rotate.sh",
214
- fileContent: "#!/bin/bash\n# Rotate application logs\nlogrotate /etc/logrotate.conf\n",
215
- stashEntry: {
216
- name: "log-rotate",
217
- type: "script",
218
- description: "Rotate and compress application log files",
219
- tags: ["logs", "rotation", "maintenance"],
220
- searchHints: ["rotate logs", "compress old logs"],
221
- filename: "log-rotate.sh",
222
- },
223
- },
224
- {
225
- dir: "scripts/env-setup",
226
- filename: "env-setup.sh",
227
- fileContent: "#!/bin/bash\n# Set up development environment\nnpm install && cp .env.example .env\n",
228
- stashEntry: {
229
- name: "env-setup",
230
- type: "script",
231
- description: "Set up local development environment with dependencies",
232
- tags: ["setup", "environment", "development", "onboarding"],
233
- searchHints: ["set up dev environment", "install dependencies"],
234
- filename: "env-setup.sh",
235
- },
236
- },
237
- // ── Knowledge ──
238
- {
239
- dir: "knowledge",
240
- filename: "architecture-guide.md",
241
- fileContent: "---\ndescription: System architecture overview\n---\n# Architecture Guide\n\n## Microservices\n\nOverview of service boundaries.\n\n## Data Flow\n\nHow data moves through the system.\n",
242
- stashEntry: {
243
- name: "architecture-guide",
244
- type: "knowledge",
245
- description: "System architecture overview and design decisions",
246
- tags: ["architecture", "design", "microservices"],
247
- searchHints: ["system architecture", "how the system works"],
248
- filename: "architecture-guide.md",
249
- },
250
- },
251
- {
252
- dir: "knowledge",
253
- filename: "runbook-incidents.md",
254
- fileContent: "---\ndescription: Incident response runbook\n---\n# Incident Runbook\n\n## Severity Levels\n\n## Escalation\n\n## Post-mortem\n",
255
- stashEntry: {
256
- name: "runbook-incidents",
257
- type: "knowledge",
258
- description: "Incident response procedures and escalation paths",
259
- tags: ["incident", "runbook", "on-call", "ops"],
260
- searchHints: ["handle incident", "escalation procedure"],
261
- filename: "runbook-incidents.md",
262
- },
263
- },
264
- {
265
- dir: "knowledge",
266
- filename: "coding-standards.md",
267
- fileContent: "---\ndescription: Team coding standards\n---\n# Coding Standards\n\n## Naming Conventions\n\n## Error Handling\n\n## Testing Requirements\n",
268
- stashEntry: {
269
- name: "coding-standards",
270
- type: "knowledge",
271
- description: "Team coding standards and conventions",
272
- tags: ["standards", "conventions", "style-guide"],
273
- searchHints: ["coding style", "naming conventions"],
274
- filename: "coding-standards.md",
275
- },
276
- },
277
- // ── Agents ──
278
- {
279
- dir: "agents",
280
- filename: "devops-engineer.md",
281
- fileContent: "---\ndescription: DevOps engineering agent\n---\nYou are a DevOps engineer specializing in CI/CD pipelines and infrastructure automation.\n",
282
- stashEntry: {
283
- name: "devops-engineer",
284
- type: "agent",
285
- description: "DevOps engineering agent for CI/CD and infrastructure",
286
- tags: ["devops", "ci-cd", "infrastructure", "automation"],
287
- searchHints: ["automate infrastructure", "CI/CD pipeline"],
288
- filename: "devops-engineer.md",
289
- },
290
- },
291
- {
292
- dir: "agents",
293
- filename: "data-analyst.md",
294
- fileContent: "---\ndescription: Data analysis agent\n---\nYou are a data analyst who helps explore datasets and generate insights.\n",
295
- stashEntry: {
296
- name: "data-analyst",
297
- type: "agent",
298
- description: "Data analysis agent for exploring datasets and generating insights",
299
- tags: ["data", "analysis", "statistics", "insights"],
300
- searchHints: ["analyze data", "generate reports"],
301
- filename: "data-analyst.md",
302
- },
303
- },
304
- {
305
- dir: "agents",
306
- filename: "technical-writer.md",
307
- fileContent: "---\ndescription: Technical writing agent\n---\nYou are a technical writer who creates clear documentation.\n",
308
- stashEntry: {
309
- name: "technical-writer",
310
- type: "agent",
311
- description: "Technical writing agent for creating documentation",
312
- tags: ["documentation", "writing", "technical"],
313
- searchHints: ["write documentation", "create technical docs"],
314
- filename: "technical-writer.md",
315
- },
316
- },
317
- ];
318
- const BENCHMARK_QUERIES = [
319
- {
320
- label: "exact-match-deploy-k8s",
321
- query: "deploy to kubernetes",
322
- expectedName: "k8s-deploy",
323
- expectedType: "skill",
324
- testingAspect: "Exact match on description and searchHints",
325
- },
326
- {
327
- label: "exact-match-database-backup",
328
- query: "database backup",
329
- expectedName: "pg-backup",
330
- expectedType: "script",
331
- testingAspect: "Exact match on tags and description",
332
- },
333
- {
334
- label: "exact-match-run-tests",
335
- query: "run tests",
336
- expectedName: "test-runner",
337
- expectedType: "command",
338
- testingAspect: "Exact match on searchHints",
339
- },
340
- {
341
- label: "prefix-match-kube",
342
- query: "kube",
343
- expectedName: "k8s-deploy",
344
- expectedType: "skill",
345
- testingAspect: "Prefix matching on alias 'kube-deploy'",
346
- },
347
- {
348
- label: "tag-match-docker",
349
- query: "docker",
350
- expectedName: "docker-clean",
351
- expectedType: "script",
352
- testingAspect: "Tag-based matching",
353
- },
354
- {
355
- label: "description-match-incident",
356
- query: "incident response",
357
- expectedName: "runbook-incidents",
358
- expectedType: "knowledge",
359
- testingAspect: "Description matching",
360
- },
361
- {
362
- label: "multi-word-ci-cd-pipeline",
363
- query: "ci cd pipeline",
364
- expectedName: "devops-engineer",
365
- expectedType: "agent",
366
- testingAspect: "Multi-word query matching tags",
367
- },
368
- {
369
- label: "hint-match-analyze-data",
370
- query: "analyze data",
371
- expectedName: "data-analyst",
372
- expectedType: "agent",
373
- testingAspect: "Search hint matching",
374
- },
375
- {
376
- label: "natural-language-ssl-cert",
377
- query: "renew ssl certificate",
378
- expectedName: "ssl-renew",
379
- expectedType: "script",
380
- testingAspect: "Natural language matching description and tags",
381
- },
382
- {
383
- label: "concept-match-code-quality",
384
- query: "code quality",
385
- expectedName: "code-review",
386
- expectedType: "skill",
387
- testingAspect: "Concept matching via tags and description",
388
- },
389
- ];
390
- // ── Stash setup ──────────────────────────────────────────────────────────────
391
- function createBenchmarkStash() {
392
- const stashDir = path.join(tmpRoot, "stash");
393
- for (const sub of ["skills", "commands", "agents", "knowledge", "scripts"]) {
394
- fs.mkdirSync(path.join(stashDir, sub), { recursive: true });
395
- }
396
- for (const asset of ASSETS) {
397
- const dirPath = path.join(stashDir, asset.dir);
398
- fs.mkdirSync(dirPath, { recursive: true });
399
- // Write the asset file
400
- fs.writeFileSync(path.join(dirPath, asset.filename), asset.fileContent);
401
- // Write the .stash.json metadata
402
- const stashJsonPath = path.join(dirPath, ".stash.json");
403
- // For assets in a shared directory (commands, knowledge), we need to
404
- // merge entries into one .stash.json
405
- let entries = [];
406
- if (fs.existsSync(stashJsonPath)) {
407
- const existing = JSON.parse(fs.readFileSync(stashJsonPath, "utf8"));
408
- entries = existing.entries;
409
- }
410
- entries.push(asset.stashEntry);
411
- fs.writeFileSync(stashJsonPath, JSON.stringify({ entries }, null, 2));
412
- }
413
- return stashDir;
414
- }
415
- // ── Git helpers ──────────────────────────────────────────────────────────────
416
- function gitInfo() {
417
- try {
418
- const branch = Bun.spawnSync(["git", "rev-parse", "--abbrev-ref", "HEAD"], {
419
- cwd: import.meta.dir,
420
- })
421
- .stdout.toString()
422
- .trim();
423
- const commit = Bun.spawnSync(["git", "rev-parse", "--short", "HEAD"], {
424
- cwd: import.meta.dir,
425
- })
426
- .stdout.toString()
427
- .trim();
428
- return { branch, commit };
429
- }
430
- catch {
431
- return { branch: "unknown", commit: "unknown" };
432
- }
433
- }
434
- // ── Main benchmark ───────────────────────────────────────────────────────────
435
- async function runBenchmark() {
436
- const { branch, commit } = gitInfo();
437
- // 1. Create the stash and index it
438
- const stashDir = createBenchmarkStash();
439
- process.env.AKM_STASH_DIR = stashDir;
440
- saveConfig({ semanticSearchMode: "off", registries: [] });
441
- if (!jsonOnly) {
442
- process.stderr.write("Indexing benchmark stash...\n");
443
- }
444
- const indexResult = await akmIndex({ stashDir, full: true });
445
- if (!jsonOnly) {
446
- process.stderr.write(` Indexed ${indexResult.totalEntries} entries in ${indexResult.timing?.totalMs ?? "?"}ms\n`);
447
- }
448
- // 2. Run each benchmark query
449
- const queryResults = [];
450
- for (const bq of BENCHMARK_QUERIES) {
451
- if (!jsonOnly) {
452
- process.stderr.write(` Running query: "${bq.query}" ...\n`);
453
- }
454
- const result = await akmSearch({ query: bq.query, source: "stash", limit: 20 });
455
- const hits = result.hits.filter((h) => h.type !== "registry");
456
- // Find rank of expected result
457
- const expectedIndex = hits.findIndex((h) => h.name === bq.expectedName);
458
- const rank = expectedIndex >= 0 ? expectedIndex + 1 : null;
459
- const reciprocalRank = rank !== null ? 1 / rank : 0;
460
- const inTop5 = rank !== null && rank <= 5;
461
- const expectedHit = expectedIndex >= 0 ? hits[expectedIndex] : null;
462
- const top5 = hits.slice(0, 5).map((h, i) => ({
463
- rank: i + 1,
464
- name: h.name,
465
- type: h.type,
466
- score: h.score,
467
- whyMatched: h.whyMatched,
468
- }));
469
- queryResults.push({
470
- label: bq.label,
471
- query: bq.query,
472
- expectedName: bq.expectedName,
473
- expectedType: bq.expectedType,
474
- testingAspect: bq.testingAspect,
475
- rank,
476
- reciprocalRank,
477
- inTop5,
478
- score: expectedHit?.score ?? null,
479
- whyMatched: expectedHit?.whyMatched ?? null,
480
- totalResults: hits.length,
481
- top5,
482
- });
483
- }
484
- // 3. Compute aggregate metrics
485
- const mrr = queryResults.reduce((sum, q) => sum + q.reciprocalRank, 0) / queryResults.length;
486
- const recallAt5 = queryResults.filter((q) => q.inTop5).length / queryResults.length;
487
- const scoredResults = queryResults.filter((q) => q.score !== null);
488
- const avgExpectedScore = scoredResults.length > 0 ? scoredResults.reduce((sum, q) => sum + (q.score ?? 0), 0) / scoredResults.length : 0;
489
- const rank1Count = queryResults.filter((q) => q.rank === 1).length;
490
- const missCount = queryResults.filter((q) => q.rank === null).length;
491
- return {
492
- timestamp: new Date().toISOString(),
493
- gitBranch: branch,
494
- gitCommit: commit,
495
- assetCount: ASSETS.length,
496
- queryCount: BENCHMARK_QUERIES.length,
497
- metrics: {
498
- mrr: Math.round(mrr * 10000) / 10000,
499
- recallAt5: Math.round(recallAt5 * 10000) / 10000,
500
- avgExpectedScore: Math.round(avgExpectedScore * 10000) / 10000,
501
- rank1Count,
502
- missCount,
503
- },
504
- queries: queryResults,
505
- };
506
- }
507
- // ── Entry point ──────────────────────────────────────────────────────────────
508
- try {
509
- const results = await runBenchmark();
510
- // Output JSON
511
- const jsonOutput = JSON.stringify(results, null, 2);
512
- console.log(jsonOutput);
513
- // Human-readable summary to stderr
514
- if (!jsonOnly) {
515
- process.stderr.write("\n");
516
- process.stderr.write("=== Search Quality Benchmark Results ===\n");
517
- process.stderr.write(`Branch: ${results.gitBranch} (${results.gitCommit})\n`);
518
- process.stderr.write(`Assets: ${results.assetCount}, Queries: ${results.queryCount}\n`);
519
- process.stderr.write("\n");
520
- process.stderr.write(` MRR: ${results.metrics.mrr}\n`);
521
- process.stderr.write(` Recall@5: ${results.metrics.recallAt5}\n`);
522
- process.stderr.write(` Avg Score: ${results.metrics.avgExpectedScore}\n`);
523
- process.stderr.write(` Rank 1 hits: ${results.metrics.rank1Count}/${results.queryCount}\n`);
524
- process.stderr.write(` Misses: ${results.metrics.missCount}/${results.queryCount}\n`);
525
- process.stderr.write("\n");
526
- process.stderr.write("Per-query breakdown:\n");
527
- for (const q of results.queries) {
528
- const status = q.rank === 1 ? "OK" : q.rank !== null ? `rank ${q.rank}` : "MISS";
529
- const scoreStr = q.score !== null ? ` score=${q.score}` : "";
530
- process.stderr.write(` [${status.padEnd(7)}] "${q.query}" -> ${q.expectedName}${scoreStr}\n`);
531
- }
532
- }
533
- }
534
- finally {
535
- cleanup();
536
- }