akm-cli 0.7.0-rc1 → 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 (314) hide show
  1. package/dist/{src/cli.js → cli.js} +100 -16
  2. package/dist/{src/commands → commands}/config-cli.js +42 -0
  3. package/dist/{src/commands → commands}/history.js +78 -7
  4. package/dist/{src/commands → commands}/registry-search.js +69 -6
  5. package/dist/{src/commands → commands}/search.js +30 -3
  6. package/dist/{src/commands → commands}/show.js +29 -0
  7. package/dist/{src/commands → commands}/source-add.js +5 -1
  8. package/dist/{src/commands → commands}/source-manage.js +7 -1
  9. package/dist/{src/core → core}/config.js +28 -0
  10. package/dist/{src/indexer → indexer}/db-search.js +1 -0
  11. package/dist/{src/indexer → indexer}/indexer.js +16 -2
  12. package/dist/{src/indexer → indexer}/matchers.js +1 -1
  13. package/dist/{src/indexer → indexer}/search-source.js +4 -2
  14. package/dist/{src/integrations → integrations}/agent/profiles.js +1 -1
  15. package/dist/{src/integrations → integrations}/agent/spawn.js +67 -16
  16. package/dist/{src/integrations → integrations}/github.js +9 -3
  17. package/dist/{src/llm → llm}/embedders/remote.js +37 -3
  18. package/dist/{src/output → output}/cli-hints.js +15 -2
  19. package/dist/{src/output → output}/renderers.js +3 -1
  20. package/dist/{src/output → output}/shapes.js +8 -1
  21. package/dist/{src/output → output}/text.js +156 -3
  22. package/dist/{src/registry → registry}/build-index.js +5 -4
  23. package/dist/{src/registry → registry}/providers/static-index.js +3 -1
  24. package/dist/{src/setup → setup}/setup.js +9 -0
  25. package/dist/{src/wiki → wiki}/wiki.js +54 -6
  26. package/dist/{src/workflows → workflows}/runs.js +37 -3
  27. package/package.json +8 -8
  28. package/dist/tests/add-website-source.test.js +0 -119
  29. package/dist/tests/agent/agent-config-loader.test.js +0 -70
  30. package/dist/tests/agent/agent-config.test.js +0 -221
  31. package/dist/tests/agent/agent-detect.test.js +0 -100
  32. package/dist/tests/agent/agent-spawn.test.js +0 -234
  33. package/dist/tests/agent-output.test.js +0 -186
  34. package/dist/tests/architecture/agent-no-llm-sdk-guard.test.js +0 -103
  35. package/dist/tests/architecture/agent-spawn-seam.test.js +0 -193
  36. package/dist/tests/architecture/llm-stateless-seam.test.js +0 -112
  37. package/dist/tests/asset-ref.test.js +0 -192
  38. package/dist/tests/asset-registry.test.js +0 -103
  39. package/dist/tests/asset-spec.test.js +0 -241
  40. package/dist/tests/bench/attribution.test.js +0 -995
  41. package/dist/tests/bench/cleanup-sigint.test.js +0 -83
  42. package/dist/tests/bench/cleanup.js +0 -203
  43. package/dist/tests/bench/cleanup.test.js +0 -166
  44. package/dist/tests/bench/cli.js +0 -683
  45. package/dist/tests/bench/cli.test.js +0 -177
  46. package/dist/tests/bench/compare.test.js +0 -556
  47. package/dist/tests/bench/corpus.js +0 -314
  48. package/dist/tests/bench/corpus.test.js +0 -258
  49. package/dist/tests/bench/driver.js +0 -346
  50. package/dist/tests/bench/driver.test.js +0 -443
  51. package/dist/tests/bench/evolve-metrics.js +0 -179
  52. package/dist/tests/bench/evolve-metrics.test.js +0 -187
  53. package/dist/tests/bench/evolve.js +0 -580
  54. package/dist/tests/bench/evolve.test.js +0 -616
  55. package/dist/tests/bench/failure-modes.test.js +0 -300
  56. package/dist/tests/bench/feedback-integrity.test.js +0 -456
  57. package/dist/tests/bench/leakage.test.js +0 -125
  58. package/dist/tests/bench/learning-curve.test.js +0 -133
  59. package/dist/tests/bench/metrics.js +0 -2319
  60. package/dist/tests/bench/metrics.test.js +0 -1144
  61. package/dist/tests/bench/no-os-tmpdir-invariant.test.js +0 -43
  62. package/dist/tests/bench/report.js +0 -1821
  63. package/dist/tests/bench/report.test.js +0 -989
  64. package/dist/tests/bench/runner.js +0 -536
  65. package/dist/tests/bench/runner.test.js +0 -958
  66. package/dist/tests/bench/search-bridge.test.js +0 -331
  67. package/dist/tests/bench/tmp.js +0 -41
  68. package/dist/tests/bench/trajectory.js +0 -116
  69. package/dist/tests/bench/trajectory.test.js +0 -127
  70. package/dist/tests/bench/verifier.js +0 -109
  71. package/dist/tests/bench/verifier.test.js +0 -118
  72. package/dist/tests/bench/workflow-evaluator.js +0 -557
  73. package/dist/tests/bench/workflow-evaluator.test.js +0 -421
  74. package/dist/tests/bench/workflow-spec.js +0 -358
  75. package/dist/tests/bench/workflow-spec.test.js +0 -363
  76. package/dist/tests/bench/workflow-trace.js +0 -438
  77. package/dist/tests/bench/workflow-trace.test.js +0 -254
  78. package/dist/tests/benchmark-search-quality.js +0 -536
  79. package/dist/tests/benchmark-suite.js +0 -1441
  80. package/dist/tests/capture-cli.test.js +0 -112
  81. package/dist/tests/cli-errors.test.js +0 -203
  82. package/dist/tests/commands/events.test.js +0 -370
  83. package/dist/tests/commands/history.test.js +0 -223
  84. package/dist/tests/commands/import.test.js +0 -103
  85. package/dist/tests/commands/proposal-cli.test.js +0 -209
  86. package/dist/tests/commands/reflect-propose-cli.test.js +0 -333
  87. package/dist/tests/commands/remember.test.js +0 -97
  88. package/dist/tests/commands/scope-flags.test.js +0 -300
  89. package/dist/tests/commands/search.test.js +0 -537
  90. package/dist/tests/commands/show-indexer-parity.test.js +0 -117
  91. package/dist/tests/commands/show.test.js +0 -294
  92. package/dist/tests/common.test.js +0 -266
  93. package/dist/tests/completions.test.js +0 -142
  94. package/dist/tests/config-cli.test.js +0 -193
  95. package/dist/tests/config-llm-features.test.js +0 -139
  96. package/dist/tests/config.test.js +0 -544
  97. package/dist/tests/contracts/migration-baseline.test.js +0 -43
  98. package/dist/tests/contracts/reflect-propose-envelope.test.js +0 -139
  99. package/dist/tests/contracts/spec-helpers.js +0 -46
  100. package/dist/tests/contracts/v1-spec-section-11-proposal-queue.test.js +0 -228
  101. package/dist/tests/contracts/v1-spec-section-12-agent-config.test.js +0 -56
  102. package/dist/tests/contracts/v1-spec-section-13-lesson-type.test.js +0 -34
  103. package/dist/tests/contracts/v1-spec-section-14-llm-features.test.js +0 -94
  104. package/dist/tests/contracts/v1-spec-section-4-1-asset-types.test.js +0 -39
  105. package/dist/tests/contracts/v1-spec-section-4-2-quality-rules.test.js +0 -44
  106. package/dist/tests/contracts/v1-spec-section-5-configuration.test.js +0 -47
  107. package/dist/tests/contracts/v1-spec-section-6-orchestration.test.js +0 -40
  108. package/dist/tests/contracts/v1-spec-section-7-module-layout.test.js +0 -58
  109. package/dist/tests/contracts/v1-spec-section-8-extension-points.test.js +0 -34
  110. package/dist/tests/contracts/v1-spec-section-9-4-cli-surface.test.js +0 -75
  111. package/dist/tests/contracts/v1-spec-section-9-7-llm-agent-boundary.test.js +0 -36
  112. package/dist/tests/core/write-source.test.js +0 -366
  113. package/dist/tests/curate-command.test.js +0 -87
  114. package/dist/tests/db-scoring.test.js +0 -201
  115. package/dist/tests/db.test.js +0 -654
  116. package/dist/tests/distill-cli-flag.test.js +0 -208
  117. package/dist/tests/distill.test.js +0 -515
  118. package/dist/tests/docker-install.test.js +0 -120
  119. package/dist/tests/e2e.test.js +0 -1398
  120. package/dist/tests/embedder.test.js +0 -340
  121. package/dist/tests/embedding-model-config.test.js +0 -379
  122. package/dist/tests/feedback-command.test.js +0 -172
  123. package/dist/tests/file-context.test.js +0 -552
  124. package/dist/tests/fixtures/scripts/git/summarize-diff.js +0 -9
  125. package/dist/tests/fixtures/scripts/lint/eslint-check.js +0 -7
  126. package/dist/tests/fixtures/stashes/load.js +0 -166
  127. package/dist/tests/fixtures/stashes/load.test.js +0 -88
  128. package/dist/tests/fixtures/stashes/ranking-baseline/scripts/mem0-search.js +0 -12
  129. package/dist/tests/frontmatter.test.js +0 -190
  130. package/dist/tests/fts-field-weighting.test.js +0 -254
  131. package/dist/tests/fuzzy-search.test.js +0 -230
  132. package/dist/tests/git-provider-clone.test.js +0 -45
  133. package/dist/tests/github.test.js +0 -161
  134. package/dist/tests/graph-boost-ranking.test.js +0 -305
  135. package/dist/tests/graph-extraction.test.js +0 -282
  136. package/dist/tests/helpers/usage-events.js +0 -8
  137. package/dist/tests/index-pass-llm.test.js +0 -161
  138. package/dist/tests/indexer.test.js +0 -559
  139. package/dist/tests/info-command.test.js +0 -166
  140. package/dist/tests/init.test.js +0 -69
  141. package/dist/tests/install-script.test.js +0 -246
  142. package/dist/tests/integration/agent-real-profile.test.js +0 -94
  143. package/dist/tests/issue-36-repro.test.js +0 -304
  144. package/dist/tests/issues-191-194.test.js +0 -160
  145. package/dist/tests/lesson-lint.test.js +0 -111
  146. package/dist/tests/llm-client.test.js +0 -115
  147. package/dist/tests/llm-feature-gate.test.js +0 -151
  148. package/dist/tests/llm.test.js +0 -139
  149. package/dist/tests/lockfile.test.js +0 -216
  150. package/dist/tests/manifest.test.js +0 -205
  151. package/dist/tests/markdown.test.js +0 -126
  152. package/dist/tests/matchers-unit.test.js +0 -189
  153. package/dist/tests/memory-inference.test.js +0 -299
  154. package/dist/tests/merge-scoring.test.js +0 -136
  155. package/dist/tests/metadata.test.js +0 -313
  156. package/dist/tests/migration-help.test.js +0 -89
  157. package/dist/tests/origin-resolve.test.js +0 -124
  158. package/dist/tests/output-baseline.test.js +0 -217
  159. package/dist/tests/output-shapes-unit.test.js +0 -476
  160. package/dist/tests/parallel-search.test.js +0 -272
  161. package/dist/tests/parameter-metadata.test.js +0 -365
  162. package/dist/tests/paths.test.js +0 -177
  163. package/dist/tests/progressive-disclosure.test.js +0 -280
  164. package/dist/tests/proposals.test.js +0 -279
  165. package/dist/tests/proposed-quality.test.js +0 -271
  166. package/dist/tests/provider-registry.test.js +0 -32
  167. package/dist/tests/ranking-regression.test.js +0 -548
  168. package/dist/tests/reflect-propose.test.js +0 -455
  169. package/dist/tests/registry-build-index.test.js +0 -378
  170. package/dist/tests/registry-cli.test.js +0 -290
  171. package/dist/tests/registry-index-v2.test.js +0 -430
  172. package/dist/tests/registry-install.test.js +0 -728
  173. package/dist/tests/registry-providers/parity.test.js +0 -189
  174. package/dist/tests/registry-providers/skills-sh.test.js +0 -309
  175. package/dist/tests/registry-providers/static-index.test.js +0 -204
  176. package/dist/tests/registry-resolve.test.js +0 -126
  177. package/dist/tests/registry-search.test.js +0 -723
  178. package/dist/tests/remember-frontmatter.test.js +0 -380
  179. package/dist/tests/remember-unit.test.js +0 -123
  180. package/dist/tests/ripgrep-install.test.js +0 -251
  181. package/dist/tests/ripgrep-resolve.test.js +0 -108
  182. package/dist/tests/ripgrep.test.js +0 -163
  183. package/dist/tests/save-command.test.js +0 -94
  184. package/dist/tests/save-trust-qa-fixes.test.js +0 -270
  185. package/dist/tests/scoring-pipeline.test.js +0 -648
  186. package/dist/tests/search-include-proposed-cli.test.js +0 -118
  187. package/dist/tests/self-update.test.js +0 -442
  188. package/dist/tests/semantic-search-e2e.test.js +0 -512
  189. package/dist/tests/semantic-status.test.js +0 -471
  190. package/dist/tests/setup-run.integration.js +0 -877
  191. package/dist/tests/setup-wizard.test.js +0 -198
  192. package/dist/tests/setup.test.js +0 -131
  193. package/dist/tests/source-add.test.js +0 -11
  194. package/dist/tests/source-clone.test.js +0 -254
  195. package/dist/tests/source-manage.test.js +0 -366
  196. package/dist/tests/source-providers/filesystem.test.js +0 -82
  197. package/dist/tests/source-providers/git.test.js +0 -252
  198. package/dist/tests/source-providers/website.test.js +0 -128
  199. package/dist/tests/source-qa-fixes.test.js +0 -268
  200. package/dist/tests/source-registry.test.js +0 -350
  201. package/dist/tests/source-resolve.test.js +0 -100
  202. package/dist/tests/source-source.test.js +0 -221
  203. package/dist/tests/source.test.js +0 -533
  204. package/dist/tests/tar-utils-scan.test.js +0 -73
  205. package/dist/tests/toggle-components.test.js +0 -73
  206. package/dist/tests/usage-telemetry.test.js +0 -265
  207. package/dist/tests/utility-scoring.test.js +0 -558
  208. package/dist/tests/vault-load-error.test.js +0 -78
  209. package/dist/tests/vault-qa-fixes.test.js +0 -194
  210. package/dist/tests/vault.test.js +0 -429
  211. package/dist/tests/vector-search.test.js +0 -608
  212. package/dist/tests/walker.test.js +0 -252
  213. package/dist/tests/wave2-cluster-bc.test.js +0 -228
  214. package/dist/tests/wave2-cluster-d.test.js +0 -180
  215. package/dist/tests/wave2-cluster-e.test.js +0 -179
  216. package/dist/tests/wiki-qa-fixes.test.js +0 -270
  217. package/dist/tests/wiki.test.js +0 -529
  218. package/dist/tests/workflow-cli.test.js +0 -271
  219. package/dist/tests/workflow-markdown.test.js +0 -171
  220. package/dist/tests/workflow-path-escape.test.js +0 -132
  221. package/dist/tests/workflow-qa-fixes.test.js +0 -377
  222. package/dist/tests/workflows/indexer-rejection.test.js +0 -213
  223. /package/dist/{src/commands → commands}/completions.js +0 -0
  224. /package/dist/{src/commands → commands}/curate.js +0 -0
  225. /package/dist/{src/commands → commands}/distill.js +0 -0
  226. /package/dist/{src/commands → commands}/events.js +0 -0
  227. /package/dist/{src/commands → commands}/info.js +0 -0
  228. /package/dist/{src/commands → commands}/init.js +0 -0
  229. /package/dist/{src/commands → commands}/install-audit.js +0 -0
  230. /package/dist/{src/commands → commands}/installed-stashes.js +0 -0
  231. /package/dist/{src/commands → commands}/migration-help.js +0 -0
  232. /package/dist/{src/commands → commands}/proposal.js +0 -0
  233. /package/dist/{src/commands → commands}/propose.js +0 -0
  234. /package/dist/{src/commands → commands}/reflect.js +0 -0
  235. /package/dist/{src/commands → commands}/remember.js +0 -0
  236. /package/dist/{src/commands → commands}/self-update.js +0 -0
  237. /package/dist/{src/commands → commands}/source-clone.js +0 -0
  238. /package/dist/{src/commands → commands}/vault.js +0 -0
  239. /package/dist/{src/core → core}/asset-ref.js +0 -0
  240. /package/dist/{src/core → core}/asset-registry.js +0 -0
  241. /package/dist/{src/core → core}/asset-spec.js +0 -0
  242. /package/dist/{src/core → core}/common.js +0 -0
  243. /package/dist/{src/core → core}/errors.js +0 -0
  244. /package/dist/{src/core → core}/events.js +0 -0
  245. /package/dist/{src/core → core}/frontmatter.js +0 -0
  246. /package/dist/{src/core → core}/lesson-lint.js +0 -0
  247. /package/dist/{src/core → core}/markdown.js +0 -0
  248. /package/dist/{src/core → core}/paths.js +0 -0
  249. /package/dist/{src/core → core}/proposals.js +0 -0
  250. /package/dist/{src/core → core}/warn.js +0 -0
  251. /package/dist/{src/core → core}/write-source.js +0 -0
  252. /package/dist/{src/indexer → indexer}/db.js +0 -0
  253. /package/dist/{src/indexer → indexer}/file-context.js +0 -0
  254. /package/dist/{src/indexer → indexer}/graph-boost.js +0 -0
  255. /package/dist/{src/indexer → indexer}/graph-extraction.js +0 -0
  256. /package/dist/{src/indexer → indexer}/manifest.js +0 -0
  257. /package/dist/{src/indexer → indexer}/memory-inference.js +0 -0
  258. /package/dist/{src/indexer → indexer}/metadata.js +0 -0
  259. /package/dist/{src/indexer → indexer}/search-fields.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/prompts.js +0 -0
  267. /package/dist/{src/integrations → integrations}/lockfile.js +0 -0
  268. /package/dist/{src/llm → llm}/client.js +0 -0
  269. /package/dist/{src/llm → llm}/embedder.js +0 -0
  270. /package/dist/{src/llm → llm}/embedders/cache.js +0 -0
  271. /package/dist/{src/llm → llm}/embedders/local.js +0 -0
  272. /package/dist/{src/llm → llm}/embedders/types.js +0 -0
  273. /package/dist/{src/llm → llm}/feature-gate.js +0 -0
  274. /package/dist/{src/llm → llm}/graph-extract.js +0 -0
  275. /package/dist/{src/llm → llm}/index-passes.js +0 -0
  276. /package/dist/{src/llm → llm}/memory-infer.js +0 -0
  277. /package/dist/{src/llm → llm}/metadata-enhance.js +0 -0
  278. /package/dist/{src/output → output}/context.js +0 -0
  279. /package/dist/{src/registry → registry}/create-provider-registry.js +0 -0
  280. /package/dist/{src/registry → registry}/factory.js +0 -0
  281. /package/dist/{src/registry → registry}/origin-resolve.js +0 -0
  282. /package/dist/{src/registry → registry}/providers/index.js +0 -0
  283. /package/dist/{src/registry → registry}/providers/skills-sh.js +0 -0
  284. /package/dist/{src/registry → registry}/providers/types.js +0 -0
  285. /package/dist/{src/registry → registry}/resolve.js +0 -0
  286. /package/dist/{src/registry → registry}/types.js +0 -0
  287. /package/dist/{src/setup → setup}/detect.js +0 -0
  288. /package/dist/{src/setup → setup}/ripgrep-install.js +0 -0
  289. /package/dist/{src/setup → setup}/ripgrep-resolve.js +0 -0
  290. /package/dist/{src/setup → setup}/steps.js +0 -0
  291. /package/dist/{src/sources → sources}/include.js +0 -0
  292. /package/dist/{src/sources → sources}/provider-factory.js +0 -0
  293. /package/dist/{src/sources → sources}/provider.js +0 -0
  294. /package/dist/{src/sources → sources}/providers/filesystem.js +0 -0
  295. /package/dist/{src/sources → sources}/providers/git.js +0 -0
  296. /package/dist/{src/sources → sources}/providers/index.js +0 -0
  297. /package/dist/{src/sources → sources}/providers/install-types.js +0 -0
  298. /package/dist/{src/sources → sources}/providers/npm.js +0 -0
  299. /package/dist/{src/sources → sources}/providers/provider-utils.js +0 -0
  300. /package/dist/{src/sources → sources}/providers/sync-from-ref.js +0 -0
  301. /package/dist/{src/sources → sources}/providers/tar-utils.js +0 -0
  302. /package/dist/{src/sources → sources}/providers/website.js +0 -0
  303. /package/dist/{src/sources → sources}/resolve.js +0 -0
  304. /package/dist/{src/sources → sources}/types.js +0 -0
  305. /package/dist/{src/templates → templates}/wiki-templates.js +0 -0
  306. /package/dist/{src/version.js → version.js} +0 -0
  307. /package/dist/{src/workflows → workflows}/authoring.js +0 -0
  308. /package/dist/{src/workflows → workflows}/cli.js +0 -0
  309. /package/dist/{src/workflows → workflows}/db.js +0 -0
  310. /package/dist/{src/workflows → workflows}/document-cache.js +0 -0
  311. /package/dist/{src/workflows → workflows}/parser.js +0 -0
  312. /package/dist/{src/workflows → workflows}/renderer.js +0 -0
  313. /package/dist/{src/workflows → workflows}/schema.js +0 -0
  314. /package/dist/{src/workflows → workflows}/validator.js +0 -0
@@ -1,378 +0,0 @@
1
- import { afterAll, afterEach, describe, expect, test } from "bun:test";
2
- import { spawn, spawnSync } from "node:child_process";
3
- import fs from "node:fs";
4
- import os from "node:os";
5
- import path from "node:path";
6
- import { buildRegistryIndex } from "../src/registry/build-index";
7
- const CLI = path.join(import.meta.dir, "..", "src", "cli.ts");
8
- const tempDirs = [];
9
- const servers = [];
10
- function makeTempDir(prefix) {
11
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
12
- tempDirs.push(dir);
13
- return dir;
14
- }
15
- function writeFile(filePath, content) {
16
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
17
- fs.writeFileSync(filePath, content, "utf8");
18
- }
19
- function createTarball(sourceDir, archivePath) {
20
- const result = spawnSync("tar", ["czf", archivePath, "-C", path.dirname(sourceDir), path.basename(sourceDir)], {
21
- encoding: "utf8",
22
- timeout: 30_000,
23
- });
24
- expect(result.status).toBe(0);
25
- }
26
- function createRegistryServer(npmArchivePath, githubArchivePath) {
27
- const server = Bun.serve({
28
- port: 0,
29
- async fetch(request) {
30
- const url = new URL(request.url);
31
- const pathname = url.pathname;
32
- if (pathname === "/-/v1/search") {
33
- return Response.json({
34
- objects: [
35
- {
36
- package: {
37
- name: "agent-stash",
38
- version: "1.2.3",
39
- description: "npm description",
40
- keywords: ["akm-stash", "deploy"],
41
- links: {
42
- homepage: "https://example.test/agent-stash",
43
- repository: "https://github.com/acme/agent-stash",
44
- },
45
- author: { name: "acme" },
46
- },
47
- },
48
- ],
49
- });
50
- }
51
- if (pathname === "/agent-stash/latest") {
52
- return Response.json({
53
- version: "1.2.3",
54
- description: "npm latest description",
55
- keywords: ["akm-stash", "deploy", "review"],
56
- license: "MIT",
57
- dist: {
58
- tarball: `${url.origin}/archives/npm-agent-stash.tgz`,
59
- },
60
- });
61
- }
62
- if (pathname === "/search/repositories") {
63
- return Response.json({
64
- items: [
65
- {
66
- full_name: "acme/release-stash",
67
- name: "release-stash",
68
- description: "github description",
69
- html_url: "https://github.com/acme/release-stash",
70
- owner: { login: "acme" },
71
- license: { spdx_id: "Apache-2.0" },
72
- topics: ["akm-stash", "release"],
73
- default_branch: "main",
74
- },
75
- ],
76
- });
77
- }
78
- if (pathname === "/repos/acme/release-stash/tarball/main") {
79
- return new Response(Bun.file(githubArchivePath), {
80
- headers: { "Content-Type": "application/gzip" },
81
- });
82
- }
83
- if (pathname === "/archives/npm-agent-stash.tgz") {
84
- return new Response(Bun.file(npmArchivePath), {
85
- headers: { "Content-Type": "application/gzip" },
86
- });
87
- }
88
- return new Response("not found", { status: 404 });
89
- },
90
- });
91
- servers.push(server);
92
- return `http://127.0.0.1:${server.port}`;
93
- }
94
- afterEach(() => {
95
- while (servers.length > 0) {
96
- servers.pop()?.stop(true);
97
- }
98
- while (tempDirs.length > 0) {
99
- fs.rmSync(tempDirs.pop() ?? "", { recursive: true, force: true });
100
- }
101
- });
102
- afterAll(() => {
103
- while (servers.length > 0) {
104
- servers.pop()?.stop(true);
105
- }
106
- });
107
- describe("buildRegistryIndex", () => {
108
- test("builds a v2 index from discovery and manual entries", async () => {
109
- const fixtureRoot = makeTempDir("akm-registry-build-fixture-");
110
- const npmPackageDir = path.join(fixtureRoot, "package");
111
- writeFile(path.join(npmPackageDir, "package.json"), JSON.stringify({
112
- name: "agent-stash",
113
- version: "1.2.3",
114
- description: "package archive description",
115
- keywords: ["akm-stash", "deploy", "review"],
116
- license: "MIT",
117
- }));
118
- writeFile(path.join(npmPackageDir, "scripts", "deploy.sh"), "#!/usr/bin/env bash\n");
119
- writeFile(path.join(npmPackageDir, "skills", "review", "SKILL.md"), "---\ndescription: Review code\n---\n");
120
- const npmArchivePath = path.join(fixtureRoot, "npm-agent-stash.tgz");
121
- createTarball(npmPackageDir, npmArchivePath);
122
- const githubRepoDir = path.join(fixtureRoot, "release-stash-main");
123
- writeFile(path.join(githubRepoDir, "package.json"), JSON.stringify({
124
- name: "release-stash",
125
- version: "0.4.0",
126
- description: "repo archive description",
127
- keywords: ["akm-stash", "release", "automation"],
128
- }));
129
- writeFile(path.join(githubRepoDir, "agents", "planner.md"), "---\ndescription: Plan releases\n---\n");
130
- writeFile(path.join(githubRepoDir, "commands", "release.md"), "Use $ARGUMENTS\n");
131
- const githubArchivePath = path.join(fixtureRoot, "github-release-stash.tgz");
132
- createTarball(githubRepoDir, githubArchivePath);
133
- const serverBase = createRegistryServer(npmArchivePath, githubArchivePath);
134
- const manualEntriesPath = path.join(fixtureRoot, "manual-entries.json");
135
- fs.writeFileSync(manualEntriesPath, `${JSON.stringify([
136
- {
137
- id: "npm:agent-stash",
138
- name: "Agent Stash",
139
- description: "manual description",
140
- ref: "agent-stash",
141
- source: "npm",
142
- tags: ["curated"],
143
- assets: [{ type: "knowledge", name: "guide", description: "Manual guide" }],
144
- curated: true,
145
- },
146
- {
147
- id: "github:manual/only",
148
- name: "Manual Only",
149
- description: "manual only entry",
150
- ref: "manual/only",
151
- source: "github",
152
- assetTypes: ["skill"],
153
- curated: true,
154
- },
155
- ], null, 2)}\n`, "utf8");
156
- const result = await buildRegistryIndex({
157
- manualEntriesPath,
158
- npmRegistryBase: serverBase,
159
- githubApiBase: serverBase,
160
- });
161
- expect(result.index.version).toBe(3);
162
- expect(result.counts).toEqual({ manual: 2, npm: 1, github: 1, total: 3 });
163
- const npmStash = result.index.stashes.find((stash) => stash.id === "npm:agent-stash");
164
- expect(npmStash).toBeDefined();
165
- expect(npmStash?.description).toBe("manual description");
166
- // v1 spec §4.2: the legacy `curated` boolean is removed. The builder must
167
- // not surface it on emitted stash entries even when input contained it.
168
- expect(npmStash).not.toHaveProperty("curated");
169
- expect(npmStash?.assetTypes).toEqual(["knowledge", "script", "skill"]);
170
- expect(npmStash?.tags).toEqual(["curated", "deploy", "review"]);
171
- expect(npmStash?.assets?.map((asset) => `${asset.type}:${asset.name}`)).toEqual([
172
- "knowledge:guide",
173
- "script:deploy.sh",
174
- "skill:review",
175
- ]);
176
- const githubStash = result.index.stashes.find((stash) => stash.id === "github:acme/release-stash");
177
- expect(githubStash).toBeDefined();
178
- expect(githubStash?.assetTypes).toEqual(["agent", "command"]);
179
- expect(githubStash?.assets?.map((asset) => `${asset.type}:${asset.name}`)).toEqual([
180
- "agent:planner",
181
- "command:release",
182
- ]);
183
- expect(githubStash?.assets?.every((asset) => typeof asset.estimatedTokens === "number")).toBe(true);
184
- expect(githubStash?.latestVersion).toBe("0.4.0");
185
- expect(githubStash?.tags).toEqual(["automation", "release"]);
186
- const manualOnlyStash = result.index.stashes.find((stash) => stash.id === "github:manual/only");
187
- expect(manualOnlyStash).toBeDefined();
188
- // v1 spec §4.2: legacy `curated` from manual entries is silently ignored.
189
- expect(manualOnlyStash).not.toHaveProperty("curated");
190
- expect(manualOnlyStash?.assetTypes).toEqual(["skill"]);
191
- });
192
- test("legacy curated key parses without error", async () => {
193
- // v1 spec §4.2: `curated: true` is a removed legacy field on registry
194
- // entries. Manual-entry JSON in the wild may still contain it. The
195
- // builder MUST silently ignore it (not throw, not fail validation),
196
- // and the entry MUST still be processed end-to-end.
197
- const fixtureRoot = makeTempDir("akm-registry-build-legacy-curated-");
198
- const githubRepoDir = path.join(fixtureRoot, "release-stash-main");
199
- writeFile(path.join(githubRepoDir, "commands", "release.md"), "Use $ARGUMENTS\n");
200
- const githubArchivePath = path.join(fixtureRoot, "github-release-stash.tgz");
201
- createTarball(githubRepoDir, githubArchivePath);
202
- const npmPackageDir = path.join(fixtureRoot, "package");
203
- writeFile(path.join(npmPackageDir, "package.json"), JSON.stringify({ name: "agent-stash", version: "1.2.3" }));
204
- const npmArchivePath = path.join(fixtureRoot, "npm-agent-stash.tgz");
205
- createTarball(npmPackageDir, npmArchivePath);
206
- const serverBase = createRegistryServer(npmArchivePath, githubArchivePath);
207
- const manualEntriesPath = path.join(fixtureRoot, "manual-entries.json");
208
- fs.writeFileSync(manualEntriesPath, `${JSON.stringify([
209
- {
210
- id: "github:legacy/curated",
211
- name: "Legacy Curated",
212
- description: "entry retaining the removed `curated: true` field",
213
- ref: "legacy/curated",
214
- source: "github",
215
- assetTypes: ["skill"],
216
- curated: true,
217
- },
218
- ], null, 2)}\n`, "utf8");
219
- await expect(buildRegistryIndex({
220
- manualEntriesPath,
221
- npmRegistryBase: serverBase,
222
- githubApiBase: serverBase,
223
- })).resolves.toBeDefined();
224
- // Re-run to inspect the actual result; resolves above proves no throw.
225
- const result = await buildRegistryIndex({
226
- manualEntriesPath,
227
- npmRegistryBase: serverBase,
228
- githubApiBase: serverBase,
229
- });
230
- // Non-empty kit list proves the legacy entry was processed, not silently
231
- // dropped on parse error.
232
- expect(result.index.stashes.length).toBeGreaterThan(0);
233
- const legacyStash = result.index.stashes.find((stash) => stash.id === "github:legacy/curated");
234
- expect(legacyStash).toBeDefined();
235
- expect(legacyStash).not.toHaveProperty("curated");
236
- });
237
- test("respects .stash.json metadata and akm.include when enriching assets", async () => {
238
- const fixtureRoot = makeTempDir("akm-registry-build-include-");
239
- const npmPackageDir = path.join(fixtureRoot, "package");
240
- writeFile(path.join(npmPackageDir, "package.json"), JSON.stringify({
241
- name: "agent-stash",
242
- version: "1.2.3",
243
- akm: { include: ["skills", "docs"] },
244
- }));
245
- writeFile(path.join(npmPackageDir, "scripts", "ignored.sh"), "#!/usr/bin/env bash\n");
246
- writeFile(path.join(npmPackageDir, "skills", "review", "SKILL.md"), "# Review\n");
247
- writeFile(path.join(npmPackageDir, "skills", "review", ".stash.json"), JSON.stringify({
248
- entries: [
249
- {
250
- name: "review",
251
- type: "skill",
252
- filename: "SKILL.md",
253
- description: "Curated review workflow",
254
- tags: ["quality", "code-review"],
255
- },
256
- ],
257
- }));
258
- writeFile(path.join(npmPackageDir, "docs", "guide.md"), "# Guide\n");
259
- const npmArchivePath = path.join(fixtureRoot, "npm-agent-stash.tgz");
260
- createTarball(npmPackageDir, npmArchivePath);
261
- const githubRepoDir = path.join(fixtureRoot, "release-stash-main");
262
- writeFile(path.join(githubRepoDir, "commands", "release.md"), "Use $ARGUMENTS\n");
263
- const githubArchivePath = path.join(fixtureRoot, "github-release-stash.tgz");
264
- createTarball(githubRepoDir, githubArchivePath);
265
- const serverBase = createRegistryServer(npmArchivePath, githubArchivePath);
266
- const manualEntriesPath = path.join(fixtureRoot, "manual-entries.json");
267
- fs.writeFileSync(manualEntriesPath, "[]\n", "utf8");
268
- const result = await buildRegistryIndex({
269
- manualEntriesPath,
270
- npmRegistryBase: serverBase,
271
- githubApiBase: serverBase,
272
- });
273
- const npmStash = result.index.stashes.find((stash) => stash.id === "npm:agent-stash");
274
- expect(npmStash?.assetTypes).toEqual(["knowledge", "skill"]);
275
- expect(npmStash?.assets?.map((asset) => `${asset.type}:${asset.name}`)).toEqual([
276
- "knowledge:docs/guide",
277
- "skill:review",
278
- ]);
279
- const reviewAsset = npmStash?.assets?.find((asset) => asset.type === "skill" && asset.name === "review");
280
- expect(reviewAsset?.description).toBe("Curated review workflow");
281
- expect(reviewAsset?.tags).toEqual(["quality", "code-review"]);
282
- expect(reviewAsset?.estimatedTokens).toBeGreaterThan(0);
283
- expect(npmStash?.assets?.some((asset) => asset.name === "ignored.sh")).toBe(false);
284
- });
285
- });
286
- function waitForChild(child, timeoutMs) {
287
- return new Promise((resolve, reject) => {
288
- let stdout = "";
289
- let stderr = "";
290
- let settled = false;
291
- child.stdout?.on("data", (chunk) => {
292
- stdout += String(chunk);
293
- });
294
- child.stderr?.on("data", (chunk) => {
295
- stderr += String(chunk);
296
- });
297
- const timer = setTimeout(() => {
298
- if (!settled) {
299
- settled = true;
300
- child.kill("SIGKILL");
301
- reject(new Error(`Child process timed out after ${timeoutMs}ms\nstdout: ${stdout}\nstderr: ${stderr}`));
302
- }
303
- }, timeoutMs);
304
- child.on("error", (err) => {
305
- if (!settled) {
306
- settled = true;
307
- clearTimeout(timer);
308
- reject(err);
309
- }
310
- });
311
- child.on("close", (code) => {
312
- if (!settled) {
313
- settled = true;
314
- clearTimeout(timer);
315
- resolve({ code: code ?? 1, stdout, stderr });
316
- }
317
- });
318
- });
319
- }
320
- describe("akm registry build-index", () => {
321
- test("writes the generated index to disk", async () => {
322
- const fixtureRoot = makeTempDir("akm-registry-build-cli-");
323
- const npmPackageDir = path.join(fixtureRoot, "package");
324
- writeFile(path.join(npmPackageDir, "package.json"), JSON.stringify({ name: "agent-stash", version: "1.2.3" }));
325
- writeFile(path.join(npmPackageDir, "scripts", "deploy.sh"), "#!/usr/bin/env bash\n");
326
- const npmArchivePath = path.join(fixtureRoot, "npm-agent-stash.tgz");
327
- createTarball(npmPackageDir, npmArchivePath);
328
- const githubRepoDir = path.join(fixtureRoot, "release-stash-main");
329
- writeFile(path.join(githubRepoDir, "commands", "release.md"), "Use $ARGUMENTS\n");
330
- const githubArchivePath = path.join(fixtureRoot, "github-release-stash.tgz");
331
- createTarball(githubRepoDir, githubArchivePath);
332
- const serverBase = createRegistryServer(npmArchivePath, githubArchivePath);
333
- const manualEntriesPath = path.join(fixtureRoot, "manual-entries.json");
334
- fs.writeFileSync(manualEntriesPath, "[]\n", "utf8");
335
- const outPath = path.join(fixtureRoot, "out", "index.json");
336
- const xdgCache = makeTempDir("akm-registry-build-cache-");
337
- const xdgConfig = makeTempDir("akm-registry-build-config-");
338
- const homeDir = makeTempDir("akm-registry-build-home-");
339
- const child = spawn("bun", [
340
- CLI,
341
- "registry",
342
- "build-index",
343
- "--format=json",
344
- "--out",
345
- outPath,
346
- "--manual",
347
- manualEntriesPath,
348
- "--npmRegistry",
349
- serverBase,
350
- "--githubApi",
351
- serverBase,
352
- ], {
353
- cwd: path.join(import.meta.dir, ".."),
354
- stdio: ["ignore", "pipe", "pipe"],
355
- env: {
356
- ...process.env,
357
- HOME: homeDir,
358
- NO_PROXY: "127.0.0.1,localhost",
359
- GITHUB_TOKEN: "",
360
- XDG_CACHE_HOME: xdgCache,
361
- XDG_CONFIG_HOME: xdgConfig,
362
- },
363
- });
364
- const result = await waitForChild(child, 30_000);
365
- if (result.code !== 0) {
366
- console.error("stderr:", result.stderr);
367
- console.error("stdout:", result.stdout);
368
- }
369
- expect(result.code).toBe(0);
370
- expect(result.stderr.trim()).toBe("");
371
- const stdout = JSON.parse(result.stdout.trim());
372
- expect(stdout.outPath).toBe(outPath);
373
- expect(stdout.totalKits).toBe(2);
374
- const written = JSON.parse(fs.readFileSync(outPath, "utf8"));
375
- expect(written.version).toBe(3);
376
- expect(written.stashes.map((stash) => stash.id)).toEqual(["npm:agent-stash", "github:acme/release-stash"]);
377
- }, { timeout: 60_000 });
378
- });
@@ -1,290 +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 { resolveRegistries, searchRegistry } from "../src/commands/registry-search";
6
- import { getConfigPath, loadConfig, saveConfig } from "../src/core/config";
7
- // ── Helpers ─────────────────────────────────────────────────────────────────
8
- const createdTmpDirs = [];
9
- function createTmpDir(prefix = "akm-reg-cli-") {
10
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
11
- createdTmpDirs.push(dir);
12
- return dir;
13
- }
14
- function writeConfig(configPath, config) {
15
- fs.mkdirSync(path.dirname(configPath), { recursive: true });
16
- fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`);
17
- }
18
- function serveIndex(index) {
19
- const body = JSON.stringify(index);
20
- const server = Bun.serve({
21
- port: 0,
22
- fetch() {
23
- return new Response(body, {
24
- headers: { "Content-Type": "application/json" },
25
- });
26
- },
27
- });
28
- return {
29
- url: `http://localhost:${server.port}/index.json`,
30
- close: () => server.stop(true),
31
- };
32
- }
33
- afterAll(() => {
34
- for (const dir of createdTmpDirs) {
35
- fs.rmSync(dir, { recursive: true, force: true });
36
- }
37
- });
38
- const originalXdgConfigHome = process.env.XDG_CONFIG_HOME;
39
- const originalXdgCacheHome = process.env.XDG_CACHE_HOME;
40
- const originalRegistryUrl = process.env.AKM_REGISTRY_URL;
41
- beforeEach(() => {
42
- process.env.XDG_CONFIG_HOME = createTmpDir("akm-reg-config-");
43
- process.env.XDG_CACHE_HOME = createTmpDir("akm-reg-cache-");
44
- delete process.env.AKM_REGISTRY_URL;
45
- });
46
- afterEach(() => {
47
- if (originalXdgConfigHome === undefined) {
48
- delete process.env.XDG_CONFIG_HOME;
49
- }
50
- else {
51
- process.env.XDG_CONFIG_HOME = originalXdgConfigHome;
52
- }
53
- if (originalXdgCacheHome === undefined) {
54
- delete process.env.XDG_CACHE_HOME;
55
- }
56
- else {
57
- process.env.XDG_CACHE_HOME = originalXdgCacheHome;
58
- }
59
- if (originalRegistryUrl === undefined) {
60
- delete process.env.AKM_REGISTRY_URL;
61
- }
62
- else {
63
- process.env.AKM_REGISTRY_URL = originalRegistryUrl;
64
- }
65
- });
66
- // ── Registry add/remove/list ─────────────────────────────────────────────────
67
- describe("registry add/remove/list via config", () => {
68
- test("list returns default registries when none configured", () => {
69
- const config = loadConfig();
70
- const registries = config.registries ?? [];
71
- expect(registries.length).toBe(2);
72
- expect(registries[0].name).toBe("official");
73
- expect(registries[0].url).toContain("akm-registry");
74
- expect(registries[1].name).toBe("skills.sh");
75
- expect(registries[1].provider).toBe("skills-sh");
76
- });
77
- test("add appends a registry entry", () => {
78
- const config = loadConfig();
79
- const registries = [...(config.registries ?? [])];
80
- const newEntry = { url: "https://example.com/index.json", name: "custom" };
81
- registries.push(newEntry);
82
- saveConfig({ ...config, registries });
83
- const updated = loadConfig();
84
- expect(updated.registries?.length).toBe(3);
85
- expect(updated.registries?.[2].url).toBe("https://example.com/index.json");
86
- expect(updated.registries?.[2].name).toBe("custom");
87
- });
88
- test("add deduplicates by URL", () => {
89
- // Start with a known registry entry
90
- const url = "https://example.com/dedup-test.json";
91
- const config = loadConfig();
92
- const registries = [...(config.registries ?? [])];
93
- registries.push({ url, name: "dedup-target" });
94
- saveConfig({ ...config, registries });
95
- // Verify it was added
96
- const afterFirst = loadConfig();
97
- const countAfterFirst = afterFirst.registries?.length ?? 0;
98
- // Try to add the same URL again using the CLI's dedup logic
99
- const current = loadConfig();
100
- const currentRegistries = [...(current.registries ?? [])];
101
- if (!currentRegistries.some((r) => r.url === url)) {
102
- currentRegistries.push({ url, name: "dedup-target" });
103
- }
104
- saveConfig({ ...current, registries: currentRegistries });
105
- // Verify length is unchanged — the duplicate was rejected
106
- const afterSecond = loadConfig();
107
- expect(afterSecond.registries?.length).toBe(countAfterFirst);
108
- });
109
- test("remove by URL", () => {
110
- const config = loadConfig();
111
- const registries = [
112
- { url: "https://example.com/a.json", name: "a" },
113
- { url: "https://example.com/b.json", name: "b" },
114
- ];
115
- saveConfig({ ...config, registries });
116
- const current = loadConfig();
117
- const remaining = (current.registries ?? []).filter((r) => r.url !== "https://example.com/a.json");
118
- saveConfig({ ...current, registries: remaining });
119
- const final = loadConfig();
120
- expect(final.registries?.length).toBe(1);
121
- expect(final.registries?.[0].name).toBe("b");
122
- });
123
- test("remove by name", () => {
124
- const config = loadConfig();
125
- const registries = [
126
- { url: "https://example.com/a.json", name: "alpha" },
127
- { url: "https://example.com/b.json", name: "beta" },
128
- ];
129
- saveConfig({ ...config, registries });
130
- const current = loadConfig();
131
- const remaining = (current.registries ?? []).filter((r) => r.name !== "alpha");
132
- saveConfig({ ...current, registries: remaining });
133
- const final = loadConfig();
134
- expect(final.registries?.length).toBe(1);
135
- expect(final.registries?.[0].name).toBe("beta");
136
- });
137
- });
138
- // ── resolveRegistries ───────────────────────────────────────────────────────
139
- describe("resolveRegistries", () => {
140
- test("filters out disabled registries", () => {
141
- const entries = [
142
- { url: "https://a.com/index.json", name: "a", enabled: true },
143
- { url: "https://b.com/index.json", name: "b", enabled: false },
144
- { url: "https://c.com/index.json", name: "c" },
145
- ];
146
- const resolved = resolveRegistries(entries);
147
- expect(resolved.length).toBe(2);
148
- expect(resolved.map((r) => r.name)).toEqual(["a", "c"]);
149
- });
150
- test("AKM_REGISTRY_URL env var overrides config", () => {
151
- process.env.AKM_REGISTRY_URL = "https://override.com/index.json";
152
- const resolved = resolveRegistries([{ url: "https://config.com/index.json" }]);
153
- expect(resolved.length).toBe(1);
154
- expect(resolved[0].url).toBe("https://override.com/index.json");
155
- });
156
- test("returns empty array when passed empty array", () => {
157
- const resolved = resolveRegistries([]);
158
- // Empty array passed explicitly — returns empty, no fallback
159
- expect(resolved).toEqual([]);
160
- });
161
- test("returns default from config when no override", () => {
162
- const resolved = resolveRegistries(undefined);
163
- // Will read from loadConfig which returns DEFAULT_CONFIG registries
164
- expect(resolved.length).toBeGreaterThan(0);
165
- expect(resolved[0].name).toBe("official");
166
- });
167
- });
168
- // ── Registry search with RegistryConfigEntry ────────────────────────────────
169
- describe("registry search with config entries", () => {
170
- test("basic query against mock index", async () => {
171
- const index = {
172
- version: 3,
173
- updatedAt: "2026-01-01T00:00:00Z",
174
- stashes: [
175
- {
176
- id: "npm:test-stash",
177
- name: "Test Stash",
178
- description: "A test stash for deploy",
179
- ref: "test-stash",
180
- source: "npm",
181
- tags: ["deploy"],
182
- },
183
- ],
184
- };
185
- const srv = serveIndex(index);
186
- try {
187
- const result = await searchRegistry("deploy", {
188
- registries: [{ url: srv.url, name: "test-reg" }],
189
- });
190
- expect(result.hits.length).toBe(1);
191
- expect(result.hits[0].id).toBe("npm:test-stash");
192
- expect(result.hits[0].registryName).toBe("test-reg");
193
- }
194
- finally {
195
- srv.close();
196
- }
197
- });
198
- test("multi-registry search merges results from multiple URLs", async () => {
199
- const index1 = {
200
- version: 3,
201
- updatedAt: "2026-01-01T00:00:00Z",
202
- stashes: [
203
- {
204
- id: "npm:stash-one",
205
- name: "Stash One",
206
- description: "First stash for build",
207
- ref: "stash-one",
208
- source: "npm",
209
- tags: ["build"],
210
- },
211
- ],
212
- };
213
- const index2 = {
214
- version: 3,
215
- updatedAt: "2026-01-01T00:00:00Z",
216
- stashes: [
217
- {
218
- id: "github:org/stash-two",
219
- name: "Stash Two",
220
- description: "Second stash for build automation",
221
- ref: "org/stash-two",
222
- source: "github",
223
- tags: ["build"],
224
- },
225
- ],
226
- };
227
- const srv1 = serveIndex(index1);
228
- const srv2 = serveIndex(index2);
229
- try {
230
- const result = await searchRegistry("build", {
231
- registries: [
232
- { url: srv1.url, name: "primary" },
233
- { url: srv2.url, name: "secondary" },
234
- ],
235
- });
236
- expect(result.hits.length).toBe(2);
237
- const ids = result.hits.map((h) => h.id);
238
- expect(ids).toContain("npm:stash-one");
239
- expect(ids).toContain("github:org/stash-two");
240
- // Verify provenance
241
- const stash1Hit = result.hits.find((h) => h.id === "npm:stash-one");
242
- const stash2Hit = result.hits.find((h) => h.id === "github:org/stash-two");
243
- expect(stash1Hit?.registryName).toBe("primary");
244
- expect(stash2Hit?.registryName).toBe("secondary");
245
- }
246
- finally {
247
- srv1.close();
248
- srv2.close();
249
- }
250
- });
251
- test("disabled registries are skipped via resolveRegistries before search", () => {
252
- const entries = [
253
- { url: "https://enabled.com/index.json", name: "enabled", enabled: true },
254
- { url: "https://disabled.com/index.json", name: "disabled", enabled: false },
255
- ];
256
- const resolved = resolveRegistries(entries);
257
- expect(resolved.length).toBe(1);
258
- expect(resolved[0].name).toBe("enabled");
259
- });
260
- });
261
- // ── Config roundtrip for registries ─────────────────────────────────────────
262
- describe("config roundtrip", () => {
263
- test("registries persist through save/load cycle", () => {
264
- const registries = [
265
- { url: "https://a.com/index.json", name: "alpha" },
266
- { url: "https://b.com/index.json", name: "beta", enabled: false },
267
- ];
268
- saveConfig({ semanticSearchMode: "auto", registries });
269
- const loaded = loadConfig();
270
- expect(loaded.registries?.length).toBe(2);
271
- expect(loaded.registries?.[0]).toEqual({ url: "https://a.com/index.json", name: "alpha" });
272
- expect(loaded.registries?.[1]).toEqual({ url: "https://b.com/index.json", name: "beta", enabled: false });
273
- });
274
- test("invalid registry entries are filtered during load", () => {
275
- const configPath = getConfigPath();
276
- writeConfig(configPath, {
277
- semanticSearchMode: "auto",
278
- registries: [
279
- { url: "https://valid.com/index.json", name: "valid" },
280
- { url: "", name: "empty-url" },
281
- { name: "no-url" },
282
- 42,
283
- null,
284
- ],
285
- });
286
- const loaded = loadConfig();
287
- expect(loaded.registries?.length).toBe(1);
288
- expect(loaded.registries?.[0].url).toBe("https://valid.com/index.json");
289
- });
290
- });