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,923 +0,0 @@
1
- import { afterAll, afterEach, beforeEach, describe, expect, test } from "bun:test";
2
- import fs from "node:fs";
3
- import os from "node:os";
4
- import path from "node:path";
5
- import { searchRegistry } from "../src/commands/registry-search";
6
- // ── Test fixtures ───────────────────────────────────────────────────────────
7
- // One entry intentionally carries the legacy `curated` boolean to exercise
8
- // the v1 parse-and-ignore rule (spec §4.2). The cast is necessary because
9
- // `curated` was removed from `RegistryStashEntry` in v1.
10
- const FIXTURE_INDEX = {
11
- version: 3,
12
- updatedAt: "2026-03-09T00:00:00Z",
13
- stashes: [
14
- {
15
- id: "npm:@itlackey/openkit",
16
- name: "@itlackey/openkit",
17
- description: "Starter stash for building OpenCode extensions with Bun.js",
18
- ref: "@itlackey/openkit",
19
- source: "npm",
20
- homepage: "https://github.com/itlackey/openkit-starter",
21
- tags: ["opencode", "bun", "typescript", "starter"],
22
- assetTypes: ["skill", "script", "command"],
23
- author: "itlackey",
24
- license: "MIT",
25
- latestVersion: "1.2.0",
26
- },
27
- {
28
- id: "github:itlackey/dimm-city-stash",
29
- name: "Dimm City TTRPG Stash",
30
- description: "Agent skills for Dimm City creaturepunk TTRPG content generation",
31
- ref: "itlackey/dimm-city-stash",
32
- source: "github",
33
- tags: ["ttrpg", "dimm-city", "creaturepunk", "print", "markdown"],
34
- assetTypes: ["skill", "command", "knowledge"],
35
- author: "itlackey",
36
- license: "CC-BY-4.0",
37
- // Legacy v0.6.x field — kept here to verify v1 parse-and-ignore.
38
- curated: true,
39
- },
40
- {
41
- id: "github:someone/azure-ops-stash",
42
- name: "Azure Ops Stash",
43
- description: "CLI skills for managing Azure Container Apps and DevOps",
44
- ref: "someone/azure-ops-stash",
45
- source: "github",
46
- tags: ["azure", "devops", "container-apps", "infrastructure"],
47
- assetTypes: ["skill", "script"],
48
- author: "someone",
49
- license: "MIT",
50
- latestVersion: "v0.3.1",
51
- },
52
- {
53
- id: "npm:generic-agent-utils",
54
- name: "generic-agent-utils",
55
- description: "Utility functions for agent development",
56
- ref: "generic-agent-utils",
57
- source: "npm",
58
- tags: ["utility", "agent"],
59
- author: "devperson",
60
- },
61
- ],
62
- };
63
- // ── Helpers ──────────────────────────────────────────────────────────────────
64
- const createdTmpDirs = [];
65
- function createTmpDir(prefix = "akm-search-") {
66
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
67
- createdTmpDirs.push(dir);
68
- return dir;
69
- }
70
- /** Start a minimal HTTP server that serves the fixture index. */
71
- function serveIndex(index) {
72
- const body = JSON.stringify(index);
73
- const server = Bun.serve({
74
- port: 0,
75
- fetch() {
76
- return new Response(body, {
77
- headers: { "Content-Type": "application/json" },
78
- });
79
- },
80
- });
81
- return {
82
- url: `http://localhost:${server.port}/index.json`,
83
- close: () => server.stop(true),
84
- };
85
- }
86
- /** Start a server that always returns an error. */
87
- function serveError(status) {
88
- const server = Bun.serve({
89
- port: 0,
90
- fetch() {
91
- return new Response("error", { status });
92
- },
93
- });
94
- return {
95
- url: `http://localhost:${server.port}/index.json`,
96
- close: () => server.stop(true),
97
- };
98
- }
99
- afterAll(() => {
100
- for (const dir of createdTmpDirs) {
101
- fs.rmSync(dir, { recursive: true, force: true });
102
- }
103
- });
104
- const originalXdgCacheHome = process.env.XDG_CACHE_HOME;
105
- const originalRegistryUrl = process.env.AKM_REGISTRY_URL;
106
- beforeEach(() => {
107
- // Isolate cache per test
108
- process.env.XDG_CACHE_HOME = createTmpDir("akm-search-cache-");
109
- delete process.env.AKM_REGISTRY_URL;
110
- });
111
- afterEach(() => {
112
- if (originalXdgCacheHome === undefined) {
113
- delete process.env.XDG_CACHE_HOME;
114
- }
115
- else {
116
- process.env.XDG_CACHE_HOME = originalXdgCacheHome;
117
- }
118
- if (originalRegistryUrl === undefined) {
119
- delete process.env.AKM_REGISTRY_URL;
120
- }
121
- else {
122
- process.env.AKM_REGISTRY_URL = originalRegistryUrl;
123
- }
124
- });
125
- // ── Empty / blank queries ───────────────────────────────────────────────────
126
- describe("searchRegistry", () => {
127
- test("returns empty for blank query", async () => {
128
- const result = await searchRegistry("");
129
- expect(result).toEqual({ query: "", hits: [], warnings: [] });
130
- });
131
- test("returns empty for whitespace query", async () => {
132
- const result = await searchRegistry(" ");
133
- expect(result).toEqual({ query: "", hits: [], warnings: [] });
134
- });
135
- });
136
- // ── Scoring and ranking ─────────────────────────────────────────────────────
137
- describe("scoring", () => {
138
- test("exact name match ranks highest", async () => {
139
- const srv = serveIndex(FIXTURE_INDEX);
140
- try {
141
- const result = await searchRegistry("Azure Ops Stash", {
142
- registries: [{ url: srv.url }],
143
- });
144
- expect(result.hits.length).toBeGreaterThan(0);
145
- expect(result.hits[0].id).toBe("github:someone/azure-ops-stash");
146
- }
147
- finally {
148
- srv.close();
149
- }
150
- });
151
- test("tag match surfaces relevant stashes", async () => {
152
- const srv = serveIndex(FIXTURE_INDEX);
153
- try {
154
- const result = await searchRegistry("creaturepunk", {
155
- registries: [{ url: srv.url }],
156
- });
157
- expect(result.hits.length).toBeGreaterThan(0);
158
- expect(result.hits[0].id).toBe("github:itlackey/dimm-city-stash");
159
- }
160
- finally {
161
- srv.close();
162
- }
163
- });
164
- test("description substring matches", async () => {
165
- const srv = serveIndex(FIXTURE_INDEX);
166
- try {
167
- const result = await searchRegistry("Container Apps", {
168
- registries: [{ url: srv.url }],
169
- });
170
- expect(result.hits.some((h) => h.id === "github:someone/azure-ops-stash")).toBe(true);
171
- }
172
- finally {
173
- srv.close();
174
- }
175
- });
176
- test("no match returns empty hits without error", async () => {
177
- const srv = serveIndex(FIXTURE_INDEX);
178
- try {
179
- const result = await searchRegistry("zzz-nonexistent-xxy", {
180
- registries: [{ url: srv.url }],
181
- });
182
- expect(result.hits).toEqual([]);
183
- expect(result.warnings).toEqual([]);
184
- }
185
- finally {
186
- srv.close();
187
- }
188
- });
189
- test("multi-token query scores across fields", async () => {
190
- const srv = serveIndex(FIXTURE_INDEX);
191
- try {
192
- const result = await searchRegistry("bun typescript starter", {
193
- registries: [{ url: srv.url }],
194
- });
195
- expect(result.hits.length).toBeGreaterThan(0);
196
- // openkit has all three in its tags
197
- expect(result.hits[0].id).toBe("npm:@itlackey/openkit");
198
- }
199
- finally {
200
- srv.close();
201
- }
202
- });
203
- test("author match works", async () => {
204
- const srv = serveIndex(FIXTURE_INDEX);
205
- try {
206
- const result = await searchRegistry("devperson", {
207
- registries: [{ url: srv.url }],
208
- });
209
- expect(result.hits.length).toBe(1);
210
- expect(result.hits[0].id).toBe("npm:generic-agent-utils");
211
- }
212
- finally {
213
- srv.close();
214
- }
215
- });
216
- });
217
- // ── Limit enforcement ───────────────────────────────────────────────────────
218
- describe("limit enforcement", () => {
219
- test("limit: 1 returns at most 1 hit", async () => {
220
- const srv = serveIndex(FIXTURE_INDEX);
221
- try {
222
- const result = await searchRegistry("stash", {
223
- registries: [{ url: srv.url }],
224
- limit: 1,
225
- });
226
- expect(result.hits.length).toBeLessThanOrEqual(1);
227
- }
228
- finally {
229
- srv.close();
230
- }
231
- });
232
- test("limit: 0 falls back to default", async () => {
233
- const srv = serveIndex(FIXTURE_INDEX);
234
- try {
235
- const result = await searchRegistry("stash", {
236
- registries: [{ url: srv.url }],
237
- limit: 0,
238
- });
239
- // Should not crash, uses default of 20
240
- expect(result.hits.length).toBeLessThanOrEqual(20);
241
- }
242
- finally {
243
- srv.close();
244
- }
245
- });
246
- test("limit: NaN falls back to default", async () => {
247
- const srv = serveIndex(FIXTURE_INDEX);
248
- try {
249
- const result = await searchRegistry("stash", {
250
- registries: [{ url: srv.url }],
251
- limit: NaN,
252
- });
253
- expect(result.hits.length).toBeLessThanOrEqual(20);
254
- }
255
- finally {
256
- srv.close();
257
- }
258
- });
259
- });
260
- // ── Caching ─────────────────────────────────────────────────────────────────
261
- describe("caching", () => {
262
- test("second call uses cached index (no network needed)", async () => {
263
- const srv = serveIndex(FIXTURE_INDEX);
264
- const url = srv.url;
265
- // First call — fetches from server
266
- const result1 = await searchRegistry("openkit", { registries: [{ url }] });
267
- expect(result1.hits.length).toBeGreaterThan(0);
268
- // Kill the server
269
- srv.close();
270
- // Second call — should use cache
271
- const result2 = await searchRegistry("openkit", { registries: [{ url }] });
272
- expect(result2.hits.length).toBeGreaterThan(0);
273
- expect(result2.hits[0].id).toBe(result1.hits[0].id);
274
- });
275
- });
276
- // ── Error handling ──────────────────────────────────────────────────────────
277
- describe("error handling", () => {
278
- test("server error produces warning, not exception", async () => {
279
- const srv = serveError(500);
280
- try {
281
- const result = await searchRegistry("test", { registries: [{ url: srv.url }] });
282
- expect(result.hits).toEqual([]);
283
- expect(result.warnings.length).toBe(1);
284
- expect(result.warnings[0]).toContain("HTTP 500");
285
- }
286
- finally {
287
- srv.close();
288
- }
289
- });
290
- test("unreachable server produces warning", async () => {
291
- const result = await searchRegistry("test", {
292
- registries: [{ url: "http://127.0.0.1:1/nonexistent" }],
293
- });
294
- expect(result.hits).toEqual([]);
295
- expect(result.warnings.length).toBe(1);
296
- });
297
- test("invalid JSON produces warning", async () => {
298
- const server = Bun.serve({
299
- port: 0,
300
- fetch() {
301
- return new Response("not json", {
302
- headers: { "Content-Type": "application/json" },
303
- });
304
- },
305
- });
306
- try {
307
- const result = await searchRegistry("test", {
308
- registries: [{ url: `http://localhost:${server.port}/index.json` }],
309
- });
310
- expect(result.hits).toEqual([]);
311
- expect(result.warnings.length).toBe(1);
312
- }
313
- finally {
314
- server.stop(true);
315
- }
316
- });
317
- });
318
- // ── Multiple registries ─────────────────────────────────────────────────────
319
- describe("multiple registries", () => {
320
- test("merges stashes from multiple registry URLs", async () => {
321
- const index1 = {
322
- version: 3,
323
- updatedAt: "2026-01-01T00:00:00Z",
324
- stashes: [
325
- {
326
- id: "npm:stash-a",
327
- name: "Stash A",
328
- description: "First stash",
329
- ref: "stash-a",
330
- source: "npm",
331
- tags: ["deploy"],
332
- },
333
- ],
334
- };
335
- const index2 = {
336
- version: 3,
337
- updatedAt: "2026-01-01T00:00:00Z",
338
- stashes: [
339
- {
340
- id: "github:org/stash-b",
341
- name: "Stash B",
342
- description: "Second stash for deploy workflows",
343
- ref: "org/stash-b",
344
- source: "github",
345
- tags: ["deploy"],
346
- },
347
- ],
348
- };
349
- const srv1 = serveIndex(index1);
350
- const srv2 = serveIndex(index2);
351
- try {
352
- const result = await searchRegistry("deploy", {
353
- registries: [{ url: srv1.url }, { url: srv2.url }],
354
- });
355
- expect(result.hits.length).toBe(2);
356
- const ids = result.hits.map((h) => h.id);
357
- expect(ids).toContain("npm:stash-a");
358
- expect(ids).toContain("github:org/stash-b");
359
- }
360
- finally {
361
- srv1.close();
362
- srv2.close();
363
- }
364
- });
365
- test("one failing registry does not block others", async () => {
366
- const goodIndex = {
367
- version: 3,
368
- updatedAt: "2026-01-01T00:00:00Z",
369
- stashes: [
370
- {
371
- id: "npm:good-stash",
372
- name: "Good Stash",
373
- ref: "good-stash",
374
- source: "npm",
375
- tags: ["works"],
376
- },
377
- ],
378
- };
379
- const good = serveIndex(goodIndex);
380
- const bad = serveError(500);
381
- try {
382
- const result = await searchRegistry("works", {
383
- registries: [{ url: good.url }, { url: bad.url }],
384
- });
385
- expect(result.hits.length).toBe(1);
386
- expect(result.hits[0].id).toBe("npm:good-stash");
387
- expect(result.warnings.length).toBe(1);
388
- }
389
- finally {
390
- good.close();
391
- bad.close();
392
- }
393
- });
394
- });
395
- // ── Hit shape ───────────────────────────────────────────────────────────────
396
- describe("hit shape", () => {
397
- test("includes metadata fields from index", async () => {
398
- const srv = serveIndex(FIXTURE_INDEX);
399
- try {
400
- const result = await searchRegistry("openkit", { registries: [{ url: srv.url }] });
401
- const hit = result.hits.find((h) => h.id === "npm:@itlackey/openkit");
402
- expect(hit).toBeDefined();
403
- expect(hit?.source).toBe("npm");
404
- expect(hit?.title).toBe("@itlackey/openkit");
405
- expect(hit?.ref).toBe("@itlackey/openkit");
406
- expect(hit?.installRef).toBe("npm:@itlackey/openkit");
407
- expect(hit?.metadata?.version).toBe("1.2.0");
408
- expect(hit?.metadata?.author).toBe("itlackey");
409
- expect(hit?.metadata?.license).toBe("MIT");
410
- expect(hit?.metadata?.assetTypes).toBe("skill, script, command");
411
- expect(typeof hit?.score).toBe("number");
412
- }
413
- finally {
414
- srv.close();
415
- }
416
- });
417
- test("installRef is prefixed with source type for github stashes", async () => {
418
- const srv = serveIndex(FIXTURE_INDEX);
419
- try {
420
- const result = await searchRegistry("azure", { registries: [{ url: srv.url }] });
421
- const hit = result.hits.find((h) => h.id === "github:someone/azure-ops-stash");
422
- expect(hit).toBeDefined();
423
- expect(hit?.installRef).toBe("github:someone/azure-ops-stash");
424
- }
425
- finally {
426
- srv.close();
427
- }
428
- });
429
- test("legacy `curated` key in registry JSON parses and is silently ignored", async () => {
430
- // Spec §4.2: the legacy registry boolean `curated` is removed in v1.
431
- // Legacy index JSON containing it MUST parse without error and the key
432
- // MUST NOT appear on emitted hits.
433
- const srv = serveIndex(FIXTURE_INDEX);
434
- try {
435
- const result = await searchRegistry("itlackey", { registries: [{ url: srv.url }] });
436
- const legacyCuratedHit = result.hits.find((h) => h.id === "github:itlackey/dimm-city-stash");
437
- expect(legacyCuratedHit).toBeDefined();
438
- expect(legacyCuratedHit).not.toHaveProperty("curated");
439
- const autoHit = result.hits.find((h) => h.id === "npm:@itlackey/openkit");
440
- expect(autoHit).toBeDefined();
441
- expect(autoHit).not.toHaveProperty("curated");
442
- }
443
- finally {
444
- srv.close();
445
- }
446
- });
447
- });
448
- // ── Environment variable override ───────────────────────────────────────────
449
- describe("AKM_REGISTRY_URL env var", () => {
450
- test("uses env var when no explicit URLs provided", async () => {
451
- const srv = serveIndex(FIXTURE_INDEX);
452
- process.env.AKM_REGISTRY_URL = srv.url;
453
- try {
454
- const result = await searchRegistry("azure");
455
- expect(result.hits.length).toBeGreaterThan(0);
456
- }
457
- finally {
458
- srv.close();
459
- }
460
- });
461
- test("supports comma-separated URLs in env var", async () => {
462
- const srv1 = serveIndex(FIXTURE_INDEX);
463
- const srv2 = serveIndex({
464
- version: 3,
465
- updatedAt: "2026-01-01T00:00:00Z",
466
- stashes: [
467
- {
468
- id: "npm:extra-stash",
469
- name: "extra-stash",
470
- ref: "extra-stash",
471
- source: "npm",
472
- tags: ["azure"],
473
- },
474
- ],
475
- });
476
- process.env.AKM_REGISTRY_URL = `${srv1.url},${srv2.url}`;
477
- try {
478
- const result = await searchRegistry("azure");
479
- const ids = result.hits.map((h) => h.id);
480
- expect(ids).toContain("github:someone/azure-ops-stash");
481
- expect(ids).toContain("npm:extra-stash");
482
- }
483
- finally {
484
- srv1.close();
485
- srv2.close();
486
- }
487
- });
488
- // Problem A: env-based override must preserve provider type
489
- test("provider::url syntax routes to the declared provider type", async () => {
490
- // Stand up a skills-sh-shaped endpoint
491
- const skillsSrv = Bun.serve({
492
- port: 0,
493
- fetch() {
494
- return new Response(JSON.stringify({
495
- skills: [{ id: "org/tools/my-skill", name: "my-skill", installs: 200, source: "org/tools" }],
496
- }), { headers: { "Content-Type": "application/json" } });
497
- },
498
- });
499
- process.env.AKM_REGISTRY_URL = `skills-sh::http://localhost:${skillsSrv.port}`;
500
- try {
501
- const result = await searchRegistry("my-skill");
502
- // skills-sh provider should have handled this — hits use skills-sh id format
503
- expect(result.hits.length).toBeGreaterThan(0);
504
- expect(result.hits[0].id).toBe("skills-sh:org/tools/my-skill");
505
- expect(result.hits[0].installRef).toBe("github:org/tools");
506
- expect(result.warnings).toEqual([]);
507
- }
508
- finally {
509
- skillsSrv.stop(true);
510
- }
511
- });
512
- test("bare URL in env var defaults to static-index provider", async () => {
513
- const srv = serveIndex(FIXTURE_INDEX);
514
- process.env.AKM_REGISTRY_URL = srv.url;
515
- try {
516
- const result = await searchRegistry("openkit");
517
- expect(result.hits.length).toBeGreaterThan(0);
518
- // static-index uses the stash id directly
519
- expect(result.hits[0].id).toBe("npm:@itlackey/openkit");
520
- }
521
- finally {
522
- srv.close();
523
- }
524
- });
525
- test("unknown provider type in env var produces warning, not crash", async () => {
526
- process.env.AKM_REGISTRY_URL = `no-such-provider::http://127.0.0.1:1/index.json`;
527
- const result = await searchRegistry("anything");
528
- expect(result.hits).toEqual([]);
529
- expect(result.warnings.length).toBe(1);
530
- expect(result.warnings[0]).toContain("no-such-provider");
531
- });
532
- test("mixed provider types in comma-separated env var", async () => {
533
- const staticSrv = serveIndex({
534
- version: 3,
535
- updatedAt: "2026-01-01T00:00:00Z",
536
- stashes: [
537
- {
538
- id: "npm:env-static-stash",
539
- name: "env-static-stash",
540
- ref: "env-static-stash",
541
- source: "npm",
542
- tags: ["deploy"],
543
- },
544
- ],
545
- });
546
- const skillsSrv = Bun.serve({
547
- port: 0,
548
- fetch() {
549
- return new Response(JSON.stringify({
550
- skills: [{ id: "user/tools/env-skill", name: "env-skill", installs: 100, source: "user/tools" }],
551
- }), { headers: { "Content-Type": "application/json" } });
552
- },
553
- });
554
- process.env.AKM_REGISTRY_URL = `${staticSrv.url},skills-sh::http://localhost:${skillsSrv.port}`;
555
- try {
556
- const result = await searchRegistry("env");
557
- const ids = result.hits.map((h) => h.id);
558
- expect(ids).toContain("npm:env-static-stash");
559
- expect(ids).toContain("skills-sh:user/tools/env-skill");
560
- expect(result.warnings).toEqual([]);
561
- }
562
- finally {
563
- staticSrv.close();
564
- skillsSrv.stop(true);
565
- }
566
- });
567
- });
568
- // ── Score normalization (Problem B) ─────────────────────────────────────────
569
- describe("cross-provider score normalization", () => {
570
- test("scores from all providers are in [0, 1] after normalization", async () => {
571
- // static-index raw scores can exceed 1 (e.g. exact name + tag + description).
572
- // After normalization, all scores in the merged response must be <= 1.
573
- const srv = serveIndex(FIXTURE_INDEX);
574
- try {
575
- const result = await searchRegistry("openkit bun typescript starter", {
576
- registries: [{ url: srv.url }],
577
- });
578
- for (const hit of result.hits) {
579
- if (hit.score !== undefined) {
580
- expect(hit.score).toBeGreaterThanOrEqual(0);
581
- expect(hit.score).toBeLessThanOrEqual(1);
582
- }
583
- }
584
- }
585
- finally {
586
- srv.close();
587
- }
588
- });
589
- test("top hit within a provider batch retains score = 1 after normalization", async () => {
590
- // The highest-scored hit in each provider batch should map to exactly 1.0.
591
- const srv = serveIndex(FIXTURE_INDEX);
592
- try {
593
- const result = await searchRegistry("openkit", {
594
- registries: [{ url: srv.url }],
595
- });
596
- expect(result.hits.length).toBeGreaterThan(0);
597
- const topScore = result.hits[0].score;
598
- expect(topScore).toBe(1);
599
- }
600
- finally {
601
- srv.close();
602
- }
603
- });
604
- test("merged multi-provider results are ordered by normalized score", async () => {
605
- // Provider A: static-index with a moderate-relevance match.
606
- // Provider B: skills-sh with a high-installs match.
607
- // After normalization each batch has max=1; the better-matched kit wins.
608
- const staticSrv = serveIndex({
609
- version: 3,
610
- updatedAt: "2026-01-01T00:00:00Z",
611
- stashes: [
612
- {
613
- id: "npm:exact-name-match",
614
- name: "deploy",
615
- description: "exact match",
616
- ref: "exact-name-match",
617
- source: "npm",
618
- tags: ["deploy"],
619
- },
620
- {
621
- id: "npm:partial-match",
622
- name: "deployment-helper",
623
- description: "partial",
624
- ref: "partial-match",
625
- source: "npm",
626
- tags: [],
627
- },
628
- ],
629
- });
630
- const skillsSrv = Bun.serve({
631
- port: 0,
632
- fetch() {
633
- return new Response(JSON.stringify({
634
- skills: [
635
- { id: "org/deploy-skill", name: "deploy-skill", installs: 1000, source: "org/deploy-skill" },
636
- { id: "org/other-skill", name: "other-skill", installs: 100, source: "org/other" },
637
- ],
638
- }), { headers: { "Content-Type": "application/json" } });
639
- },
640
- });
641
- try {
642
- const result = await searchRegistry("deploy", {
643
- registries: [{ url: staticSrv.url }, { url: `http://localhost:${skillsSrv.port}`, provider: "skills-sh" }],
644
- });
645
- // All scores in [0, 1]
646
- for (const hit of result.hits) {
647
- if (hit.score !== undefined) {
648
- expect(hit.score).toBeGreaterThanOrEqual(0);
649
- expect(hit.score).toBeLessThanOrEqual(1);
650
- }
651
- }
652
- // Results should be sorted descending
653
- for (let i = 1; i < result.hits.length; i++) {
654
- expect((result.hits[i - 1].score ?? 0) >= (result.hits[i].score ?? 0)).toBe(true);
655
- }
656
- }
657
- finally {
658
- staticSrv.close();
659
- skillsSrv.stop(true);
660
- }
661
- });
662
- test("single-hit provider batch normalizes to score 1", async () => {
663
- const srv = serveIndex({
664
- version: 3,
665
- updatedAt: "2026-01-01T00:00:00Z",
666
- stashes: [
667
- {
668
- id: "npm:only-stash",
669
- name: "only-stash",
670
- description: "only one",
671
- ref: "only-stash",
672
- source: "npm",
673
- tags: ["unique"],
674
- },
675
- ],
676
- });
677
- try {
678
- const result = await searchRegistry("unique", {
679
- registries: [{ url: srv.url }],
680
- });
681
- expect(result.hits.length).toBe(1);
682
- expect(result.hits[0].score).toBe(1);
683
- }
684
- finally {
685
- srv.close();
686
- }
687
- });
688
- });
689
- // ── Provenance tagging ──────────────────────────────────────────────────────
690
- describe("provenance tagging", () => {
691
- test("hits include registryName from entry config", async () => {
692
- const srv = serveIndex(FIXTURE_INDEX);
693
- try {
694
- const result = await searchRegistry("openkit", {
695
- registries: [{ url: srv.url, name: "test-registry" }],
696
- });
697
- expect(result.hits.length).toBeGreaterThan(0);
698
- expect(result.hits[0].registryName).toBe("test-registry");
699
- }
700
- finally {
701
- srv.close();
702
- }
703
- });
704
- test("registryName is undefined when entry has no name", async () => {
705
- const srv = serveIndex(FIXTURE_INDEX);
706
- try {
707
- const result = await searchRegistry("openkit", {
708
- registries: [{ url: srv.url }],
709
- });
710
- expect(result.hits.length).toBeGreaterThan(0);
711
- expect(result.hits[0].registryName).toBeUndefined();
712
- }
713
- finally {
714
- srv.close();
715
- }
716
- });
717
- });
718
- // ── Provider-based routing ──────────────────────────────────────────────────
719
- describe("provider routing", () => {
720
- test("unknown provider type produces warning, not crash", async () => {
721
- const result = await searchRegistry("test", {
722
- registries: [{ url: "http://example.com", provider: "nonexistent-type" }],
723
- });
724
- expect(result.hits).toEqual([]);
725
- expect(result.warnings.length).toBe(1);
726
- expect(result.warnings[0]).toContain("nonexistent-type");
727
- });
728
- test("mixed static-index and skills-sh registries return merged results", async () => {
729
- const staticSrv = serveIndex({
730
- version: 3,
731
- updatedAt: "2026-01-01T00:00:00Z",
732
- stashes: [
733
- {
734
- id: "npm:deploy-stash",
735
- name: "deploy-stash",
736
- description: "Deployment tools",
737
- ref: "deploy-stash",
738
- source: "npm",
739
- tags: ["deploy"],
740
- },
741
- ],
742
- });
743
- const skillsSrv = Bun.serve({
744
- port: 0,
745
- fetch() {
746
- return new Response(JSON.stringify({
747
- skills: [{ id: "org/skills/deploy-vercel", name: "deploy-vercel", installs: 500, source: "org/skills" }],
748
- }), { headers: { "Content-Type": "application/json" } });
749
- },
750
- });
751
- try {
752
- const result = await searchRegistry("deploy", {
753
- registries: [
754
- { url: staticSrv.url, name: "static" },
755
- { url: `http://localhost:${skillsSrv.port}`, name: "skills.sh", provider: "skills-sh" },
756
- ],
757
- });
758
- const ids = result.hits.map((h) => h.id);
759
- expect(ids).toContain("npm:deploy-stash");
760
- expect(ids).toContain("skills-sh:org/skills/deploy-vercel");
761
- // installRef should be directly usable with `akm add`
762
- const npmHit = result.hits.find((h) => h.id === "npm:deploy-stash");
763
- expect(npmHit?.installRef).toBe("npm:deploy-stash");
764
- const skillsHit = result.hits.find((h) => h.id === "skills-sh:org/skills/deploy-vercel");
765
- expect(skillsHit?.installRef).toBe("github:org/skills");
766
- expect(result.warnings).toEqual([]);
767
- }
768
- finally {
769
- staticSrv.close();
770
- skillsSrv.stop(true);
771
- }
772
- });
773
- test("one provider fails, other succeeds — partial results + warning", async () => {
774
- const goodSrv = serveIndex({
775
- version: 3,
776
- updatedAt: "2026-01-01T00:00:00Z",
777
- stashes: [
778
- {
779
- id: "npm:good-stash",
780
- name: "good-stash",
781
- ref: "good-stash",
782
- source: "npm",
783
- tags: ["test"],
784
- },
785
- ],
786
- });
787
- try {
788
- const result = await searchRegistry("test", {
789
- registries: [
790
- { url: goodSrv.url, name: "good" },
791
- { url: "http://127.0.0.1:1", name: "bad", provider: "skills-sh" },
792
- ],
793
- });
794
- expect(result.hits.length).toBe(1);
795
- expect(result.hits[0].id).toBe("npm:good-stash");
796
- expect(result.warnings.length).toBe(1);
797
- }
798
- finally {
799
- goodSrv.close();
800
- }
801
- });
802
- test("default provider is static-index when omitted", async () => {
803
- const srv = serveIndex(FIXTURE_INDEX);
804
- try {
805
- // No provider field — should use static-index
806
- const result = await searchRegistry("openkit", {
807
- registries: [{ url: srv.url }],
808
- });
809
- expect(result.hits.length).toBeGreaterThan(0);
810
- expect(result.hits[0].id).toBe("npm:@itlackey/openkit");
811
- }
812
- finally {
813
- srv.close();
814
- }
815
- });
816
- });
817
- // ── Issue #159: incomplete hits must never appear in JSON output ────────────
818
- describe("incomplete hits filter (#159)", () => {
819
- test("hits missing required fields are dropped from response", async () => {
820
- const { registerProvider } = await import("../src/registry/factory");
821
- const goodHit = {
822
- source: "github",
823
- id: "github:owner/good",
824
- title: "Good Hit",
825
- ref: "github:owner/good",
826
- installRef: "github:owner/good",
827
- };
828
- registerProvider("incomplete-hits-test", (() => ({
829
- type: "incomplete-hits-test",
830
- async search() {
831
- return {
832
- // {} = empty placeholder; missing-id = partial; goodHit = valid
833
- hits: [{}, { source: "github", title: "x" }, goodHit],
834
- };
835
- },
836
- })));
837
- const result = await searchRegistry("anything", {
838
- registries: [{ url: "http://unused", provider: "incomplete-hits-test" }],
839
- });
840
- expect(result.hits).toEqual([goodHit]);
841
- expect(result.hits.every((h) => h && typeof h === "object" && Object.keys(h).length > 0)).toBe(true);
842
- expect(result.warnings.some((w) => /incomplete hit/i.test(w))).toBe(true);
843
- });
844
- test("incomplete asset hits are dropped from assetHits", async () => {
845
- const { registerProvider } = await import("../src/registry/factory");
846
- registerProvider("incomplete-assets-test", (() => ({
847
- type: "incomplete-assets-test",
848
- async search() {
849
- return {
850
- hits: [],
851
- assetHits: [
852
- {},
853
- { type: "registry-asset", assetType: "skill" },
854
- {
855
- type: "registry-asset",
856
- assetType: "skill",
857
- assetName: "deploy",
858
- action: "akm show skill:deploy",
859
- stash: { id: "x", name: "x" },
860
- },
861
- ],
862
- };
863
- },
864
- })));
865
- const result = await searchRegistry("anything", {
866
- registries: [{ url: "http://unused", provider: "incomplete-assets-test" }],
867
- });
868
- expect(result.assetHits).toBeDefined();
869
- expect(result.assetHits?.length).toBe(1);
870
- expect(result.assetHits?.[0].assetName).toBe("deploy");
871
- });
872
- // PR #168 review #9: asset hits with missing/empty `stash.id` or `stash.name`
873
- // are also incomplete and must not propagate to JSON output.
874
- test("asset hits with missing or empty stash fields are dropped", async () => {
875
- const { registerProvider } = await import("../src/registry/factory");
876
- registerProvider("incomplete-stash-test", (() => ({
877
- type: "incomplete-stash-test",
878
- async search() {
879
- return {
880
- hits: [],
881
- assetHits: [
882
- // stash entirely missing
883
- {
884
- type: "registry-asset",
885
- assetType: "skill",
886
- assetName: "no-stash",
887
- action: "akm show skill:no-stash",
888
- },
889
- // stash present but id is empty
890
- {
891
- type: "registry-asset",
892
- assetType: "skill",
893
- assetName: "empty-id",
894
- action: "akm show skill:empty-id",
895
- stash: { id: "", name: "x" },
896
- },
897
- // stash present but name is missing
898
- {
899
- type: "registry-asset",
900
- assetType: "skill",
901
- assetName: "no-name",
902
- action: "akm show skill:no-name",
903
- stash: { id: "x" },
904
- },
905
- // valid — only this one should survive
906
- {
907
- type: "registry-asset",
908
- assetType: "skill",
909
- assetName: "good",
910
- action: "akm show skill:good",
911
- stash: { id: "x", name: "x" },
912
- },
913
- ],
914
- };
915
- },
916
- })));
917
- const result = await searchRegistry("anything", {
918
- registries: [{ url: "http://unused", provider: "incomplete-stash-test" }],
919
- });
920
- expect(result.assetHits?.length).toBe(1);
921
- expect(result.assetHits?.[0].assetName).toBe("good");
922
- });
923
- });