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,478 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { capDescription, pickFields, shapeAssetHit, shapeForCommand, shapeProposalAcceptOutput, shapeProposalDiffOutput, shapeProposalEntry, shapeProposalListOutput, shapeProposalProducerOutput, shapeProposalRejectOutput, shapeProposalShowOutput, shapeRegistrySearchOutput, shapeSearchHit, shapeSearchHitForAgent, shapeSearchOutput, shapeShowOutput, truncateDescription, } from "../src/output/shapes";
3
- describe("pickFields", () => {
4
- test("returns only requested fields, in the requested order", () => {
5
- const source = { a: 1, b: 2, c: 3, d: 4 };
6
- expect(pickFields(source, ["b", "d"])).toEqual({ b: 2, d: 4 });
7
- });
8
- test("omits fields that are absent", () => {
9
- expect(pickFields({ a: 1 }, ["a", "b"])).toEqual({ a: 1 });
10
- });
11
- test("omits fields whose value is undefined", () => {
12
- expect(pickFields({ a: 1, b: undefined }, ["a", "b"])).toEqual({ a: 1 });
13
- });
14
- test("preserves null values explicitly", () => {
15
- expect(pickFields({ a: 1, b: null }, ["a", "b"])).toEqual({ a: 1, b: null });
16
- });
17
- });
18
- describe("truncateDescription", () => {
19
- test("returns short descriptions unchanged", () => {
20
- expect(truncateDescription("hello", 100)).toBe("hello");
21
- });
22
- test("collapses whitespace", () => {
23
- expect(truncateDescription("hello world\n\nagain", 100)).toBe("hello world again");
24
- });
25
- test("truncates to a word boundary when possible", () => {
26
- const long = "the quick brown fox jumps over the lazy dog repeatedly";
27
- const result = truncateDescription(long, 25);
28
- // Body is up to limit-1 chars; `...` is appended → realistic max = limit+2.
29
- expect(result.length).toBeLessThanOrEqual(25 + 2);
30
- expect(result.endsWith("...")).toBe(true);
31
- // Should not split on a word
32
- const beforeEllipsis = result.slice(0, -3).trimEnd();
33
- expect(long).toContain(beforeEllipsis);
34
- });
35
- test("falls back to hard truncation when no word boundary is reasonable", () => {
36
- const noSpaces = "x".repeat(40);
37
- const result = truncateDescription(noSpaces, 10);
38
- expect(result.length).toBeLessThanOrEqual(10 + 2);
39
- expect(result.endsWith("...")).toBe(true);
40
- });
41
- });
42
- describe("capDescription", () => {
43
- test("caps a long description", () => {
44
- const hit = { name: "x", description: "a".repeat(500) };
45
- const capped = capDescription(hit, 100);
46
- // truncateDescription appends `...`, so the resulting body is up to limit+2.
47
- expect(capped.description.length).toBeLessThanOrEqual(100 + 2);
48
- expect(capped.name).toBe("x");
49
- });
50
- test("leaves a short description alone", () => {
51
- const hit = { name: "x", description: "short" };
52
- expect(capDescription(hit, 100)).toEqual({ name: "x", description: "short" });
53
- });
54
- test("ignores hits without a string description", () => {
55
- const hit = { name: "x", description: 42 };
56
- expect(capDescription(hit, 100)).toEqual(hit);
57
- });
58
- });
59
- describe("shapeSearchHit — local stash hits", () => {
60
- const fullHit = {
61
- type: "skill",
62
- name: "deploy",
63
- description: "Deploy the app",
64
- ref: "skill:deploy",
65
- action: "akm show skill:deploy",
66
- score: 0.42,
67
- estimatedTokens: 120,
68
- origin: "local:.",
69
- tags: ["ops"],
70
- whyMatched: "name match",
71
- };
72
- test("brief keeps only type/name/ref/action/estimatedTokens", () => {
73
- // REC-03: ref is now included at brief so agents can run `akm show <ref>`
74
- expect(shapeSearchHit(fullHit, "brief")).toEqual({
75
- type: "skill",
76
- name: "deploy",
77
- ref: "skill:deploy",
78
- action: "akm show skill:deploy",
79
- estimatedTokens: 120,
80
- });
81
- });
82
- test("normal adds description and score (and caps description)", () => {
83
- const out = shapeSearchHit(fullHit, "normal");
84
- expect(out).toMatchObject({
85
- type: "skill",
86
- name: "deploy",
87
- description: "Deploy the app",
88
- action: "akm show skill:deploy",
89
- score: 0.42,
90
- estimatedTokens: 120,
91
- });
92
- expect(out).not.toHaveProperty("ref");
93
- expect(out).not.toHaveProperty("origin");
94
- expect(out).not.toHaveProperty("tags");
95
- });
96
- test("full passes the hit through verbatim", () => {
97
- expect(shapeSearchHit(fullHit, "full")).toEqual(fullHit);
98
- });
99
- });
100
- describe("shapeSearchHit — registry hits", () => {
101
- // v1 spec §4.2: registry hits no longer surface a `curated` boolean. They
102
- // may surface optional `warnings` when a provider has non-fatal issues.
103
- const registryHit = {
104
- type: "registry",
105
- name: "azure-ops",
106
- description: "Azure ops kit",
107
- action: "akm add npm:azure-ops",
108
- warnings: ["registry rate limit hit, results may be stale"],
109
- id: "npm:azure-ops",
110
- score: 0.7,
111
- };
112
- test("brief keeps name/score (QA #28: brief now projects name+installRef+score)", () => {
113
- // Brief now includes name (normalised from title if needed) and score so
114
- // callers can use the result without --detail full.
115
- const result = shapeSearchHit(registryHit, "brief");
116
- expect(result.name).toBe("azure-ops");
117
- expect(result.score).toBe(0.7);
118
- // action is no longer in brief output — use installRef to act
119
- expect(result).not.toHaveProperty("curated");
120
- // brief intentionally omits warnings to keep payloads small
121
- expect(result).not.toHaveProperty("warnings");
122
- });
123
- test("normal adds description and surfaces optional warnings", () => {
124
- const out = shapeSearchHit(registryHit, "normal");
125
- expect(out).toMatchObject({
126
- name: "azure-ops",
127
- description: "Azure ops kit",
128
- action: "akm add npm:azure-ops",
129
- warnings: ["registry rate limit hit, results may be stale"],
130
- });
131
- expect(out).not.toHaveProperty("curated");
132
- });
133
- test("full passes through and never re-adds curated", () => {
134
- const out = shapeSearchHit(registryHit, "full");
135
- expect(out).toEqual(registryHit);
136
- expect(out).not.toHaveProperty("curated");
137
- });
138
- });
139
- describe("shapeSearchHitForAgent", () => {
140
- test("includes ref + caps description", () => {
141
- const hit = {
142
- type: "skill",
143
- name: "deploy",
144
- ref: "skill:deploy",
145
- description: "long ".repeat(100),
146
- action: "akm show skill:deploy",
147
- score: 0.5,
148
- estimatedTokens: 100,
149
- tags: ["ops"],
150
- origin: "local:.",
151
- };
152
- const out = shapeSearchHitForAgent(hit);
153
- expect(out).toMatchObject({
154
- name: "deploy",
155
- ref: "skill:deploy",
156
- type: "skill",
157
- action: "akm show skill:deploy",
158
- score: 0.5,
159
- estimatedTokens: 100,
160
- });
161
- expect(out).not.toHaveProperty("tags");
162
- expect(out).not.toHaveProperty("origin");
163
- expect(typeof out.description).toBe("string");
164
- });
165
- });
166
- describe("shapeAssetHit", () => {
167
- const asset = {
168
- assetName: "deploy",
169
- assetType: "skill",
170
- description: "Deploy the app",
171
- stash: { id: "x", name: "x" },
172
- action: "akm show skill:deploy",
173
- estimatedTokens: 120,
174
- };
175
- test("brief drops description", () => {
176
- expect(shapeAssetHit(asset, "brief")).toEqual({
177
- assetName: "deploy",
178
- assetType: "skill",
179
- action: "akm show skill:deploy",
180
- estimatedTokens: 120,
181
- });
182
- });
183
- test("normal includes description + stash", () => {
184
- expect(shapeAssetHit(asset, "normal")).toMatchObject({
185
- assetName: "deploy",
186
- assetType: "skill",
187
- description: "Deploy the app",
188
- stash: { id: "x", name: "x" },
189
- });
190
- });
191
- });
192
- describe("shapeShowOutput", () => {
193
- const fullShow = {
194
- type: "skill",
195
- name: "deploy",
196
- description: "Deploy",
197
- action: "akm show skill:deploy",
198
- content: "long body...",
199
- template: "tpl",
200
- cwd: "/tmp",
201
- extra: "should-not-appear-in-agent-mode",
202
- };
203
- test("forAgent picks the agent-action field set", () => {
204
- const out = shapeShowOutput(fullShow, "full", true);
205
- expect(out).toMatchObject({
206
- type: "skill",
207
- name: "deploy",
208
- description: "Deploy",
209
- content: "long body...",
210
- });
211
- expect(out).not.toHaveProperty("extra");
212
- });
213
- test("forAgent=false at full picks the show field set + adds schemaVersion", () => {
214
- const out = shapeShowOutput(fullShow, "full", false);
215
- expect(out.schemaVersion).toBe(1);
216
- expect(out).toMatchObject({
217
- type: "skill",
218
- name: "deploy",
219
- description: "Deploy",
220
- content: "long body...",
221
- template: "tpl",
222
- cwd: "/tmp",
223
- });
224
- // `extra` was not in the picked field set, even at full.
225
- expect(out).not.toHaveProperty("extra");
226
- });
227
- test("forAgent=false at brief omits schemaVersion (only added at full)", () => {
228
- const out = shapeShowOutput(fullShow, "brief", false);
229
- expect(out).not.toHaveProperty("schemaVersion");
230
- expect(out.name).toBe("deploy");
231
- });
232
- });
233
- describe("shapeForCommand", () => {
234
- test("routes search results through shapeSearchOutput", () => {
235
- const out = shapeForCommand("search", { hits: [{ type: "skill", name: "x", action: "a", estimatedTokens: 1 }], registryHits: [] }, "brief", false);
236
- expect(Array.isArray(out.hits)).toBe(true);
237
- expect(out.hits[0]).toEqual({
238
- type: "skill",
239
- name: "x",
240
- action: "a",
241
- estimatedTokens: 1,
242
- });
243
- });
244
- test("routes show results through shapeShowOutput at full + forAgent=true", () => {
245
- const out = shapeForCommand("show", { type: "skill", name: "deploy", action: "a", extra: "drop me" }, "full", true);
246
- expect(out).not.toHaveProperty("extra");
247
- });
248
- test("non-search/show commands pass through unmodified", () => {
249
- const result = { something: "untouched" };
250
- expect(shapeForCommand("info", result, "full", false)).toEqual(result);
251
- });
252
- });
253
- describe("shapeSearchOutput", () => {
254
- test("respects detail level for hits", () => {
255
- const result = {
256
- hits: [{ type: "skill", name: "x", action: "a", estimatedTokens: 1, description: "desc" }],
257
- registryHits: [],
258
- };
259
- const brief = shapeSearchOutput(result, "brief", false);
260
- const normal = shapeSearchOutput(result, "normal", false);
261
- expect(brief.hits[0].description).toBeUndefined();
262
- expect(normal.hits[0].description).toBe("desc");
263
- });
264
- test("forAgent overrides detail and uses the agent shape", () => {
265
- const result = {
266
- hits: [
267
- {
268
- type: "skill",
269
- name: "x",
270
- action: "a",
271
- ref: "skill:x",
272
- description: "d",
273
- score: 0.1,
274
- estimatedTokens: 1,
275
- },
276
- ],
277
- registryHits: [],
278
- };
279
- const out = shapeSearchOutput(result, "brief", true);
280
- expect(out.hits[0].ref).toBe("skill:x");
281
- });
282
- });
283
- describe("shapeRegistrySearchOutput", () => {
284
- test("shapes registry hits at the requested detail level", () => {
285
- const result = {
286
- hits: [
287
- {
288
- name: "azure-ops",
289
- description: "Azure ops kit",
290
- action: "akm add npm:azure-ops",
291
- // v1 §4.2: no more `curated` key.
292
- score: 0.5,
293
- id: "npm:azure-ops",
294
- },
295
- ],
296
- registryHits: [],
297
- };
298
- const brief = shapeRegistrySearchOutput(result, "brief");
299
- // QA #28: brief now projects name + score at minimum (not just name/action)
300
- expect(brief.hits[0]).toMatchObject({ name: "azure-ops", score: 0.5 });
301
- });
302
- });
303
- // ── Output-shape registry exhaustiveness (#274) ─────────────────────────────
304
- describe("shapeForCommand: unknown command", () => {
305
- test("throws with the command name in the message instead of silently passing the result through", () => {
306
- // v1 spec §9: the output shape registry is exhaustive. A missing case is
307
- // a registration bug (silent JSON.stringify fallback was the old
308
- // behaviour). The throw must include the unknown command name so the
309
- // caller / test sees the missing registration.
310
- expect(() => shapeForCommand("definitely-not-a-real-command", { foo: "bar" }, "normal")).toThrow("output shape not registered for command: definitely-not-a-real-command");
311
- });
312
- });
313
- // ── #284 GAP-MED 1: shapeProposal* — proposal commands ─────────────────────
314
- describe("shapeProposal* — proposal commands", () => {
315
- const fullProposal = {
316
- id: "uuid-1",
317
- ref: "lesson:rg-over-grep",
318
- status: "pending",
319
- source: "reflect",
320
- sourceRun: "run-7",
321
- createdAt: "2026-04-27T00:00:00Z",
322
- updatedAt: "2026-04-27T00:00:01Z",
323
- payload: { content: "BODY", frontmatter: { description: "d" } },
324
- review: undefined,
325
- };
326
- test("shapeProposalEntry brief drops payload + sourceRun", () => {
327
- const out = shapeProposalEntry(fullProposal, "brief");
328
- expect(out).toEqual({
329
- id: "uuid-1",
330
- ref: "lesson:rg-over-grep",
331
- status: "pending",
332
- source: "reflect",
333
- createdAt: "2026-04-27T00:00:00Z",
334
- });
335
- expect(out).not.toHaveProperty("payload");
336
- expect(out).not.toHaveProperty("sourceRun");
337
- });
338
- test("shapeProposalEntry normal keeps metadata + sourceRun + updatedAt; still drops payload", () => {
339
- const out = shapeProposalEntry(fullProposal, "normal");
340
- expect(out).toMatchObject({
341
- id: "uuid-1",
342
- ref: "lesson:rg-over-grep",
343
- status: "pending",
344
- source: "reflect",
345
- sourceRun: "run-7",
346
- createdAt: "2026-04-27T00:00:00Z",
347
- updatedAt: "2026-04-27T00:00:01Z",
348
- });
349
- expect(out).not.toHaveProperty("payload");
350
- });
351
- test("shapeProposalEntry full keeps payload", () => {
352
- const out = shapeProposalEntry(fullProposal, "full");
353
- expect(out).toHaveProperty("payload");
354
- expect(out.payload.content).toBe("BODY");
355
- });
356
- test("shapeProposalListOutput shapes nested proposals + carries totalCount", () => {
357
- const result = { schemaVersion: 1, totalCount: 2, proposals: [fullProposal, fullProposal] };
358
- const brief = shapeProposalListOutput(result, "brief");
359
- expect(brief.totalCount).toBe(2);
360
- expect(Array.isArray(brief.proposals)).toBe(true);
361
- const list = brief.proposals;
362
- expect(list).toHaveLength(2);
363
- expect(list[0]).not.toHaveProperty("payload");
364
- // full level adds schemaVersion
365
- const full = shapeProposalListOutput(result, "full");
366
- expect(full.schemaVersion).toBe(1);
367
- });
368
- test("shapeProposalShowOutput surfaces validation alongside the entry", () => {
369
- const validation = { ok: true, findings: [] };
370
- const out = shapeProposalShowOutput({ schemaVersion: 1, proposal: fullProposal, validation }, "normal");
371
- expect(out.validation).toEqual(validation);
372
- expect(out.proposal.ref).toBe("lesson:rg-over-grep");
373
- expect(out).not.toHaveProperty("schemaVersion");
374
- // full adds schemaVersion
375
- const full = shapeProposalShowOutput({ schemaVersion: 1, proposal: fullProposal, validation }, "full");
376
- expect(full.schemaVersion).toBe(1);
377
- });
378
- test("shapeProposalAcceptOutput projects ok+id+ref+assetPath at every detail", () => {
379
- const result = {
380
- schemaVersion: 1,
381
- ok: true,
382
- id: "uuid-1",
383
- ref: "lesson:rg-over-grep",
384
- assetPath: "/tmp/stash/lessons/rg.md",
385
- proposal: fullProposal,
386
- };
387
- for (const detail of ["brief", "normal", "full"]) {
388
- const out = shapeProposalAcceptOutput(result, detail);
389
- expect(out.ok).toBe(true);
390
- expect(out.id).toBe("uuid-1");
391
- expect(out.ref).toBe("lesson:rg-over-grep");
392
- expect(out.assetPath).toBe("/tmp/stash/lessons/rg.md");
393
- }
394
- });
395
- test("shapeProposalRejectOutput threads `reason` only when present", () => {
396
- const withReason = shapeProposalRejectOutput({ schemaVersion: 1, ok: true, id: "uuid-1", ref: "lesson:x", reason: "duplicate", proposal: fullProposal }, "normal");
397
- expect(withReason.reason).toBe("duplicate");
398
- const withoutReason = shapeProposalRejectOutput({ schemaVersion: 1, ok: true, id: "uuid-1", ref: "lesson:x", proposal: fullProposal }, "normal");
399
- expect(withoutReason).not.toHaveProperty("reason");
400
- });
401
- test("shapeProposalDiffOutput projects id/ref/isNew/unified", () => {
402
- const result = {
403
- schemaVersion: 1,
404
- id: "uuid-1",
405
- ref: "lesson:x",
406
- isNew: true,
407
- unified: "--- /dev/null\n+++ a\n",
408
- targetPath: "/tmp/x",
409
- };
410
- const brief = shapeProposalDiffOutput(result, "brief");
411
- expect(brief).toMatchObject({ id: "uuid-1", isNew: true, targetPath: "/tmp/x" });
412
- expect(brief).not.toHaveProperty("schemaVersion");
413
- const full = shapeProposalDiffOutput(result, "full");
414
- expect(full.schemaVersion).toBe(1);
415
- });
416
- test("shapeProposalProducerOutput happy: ok=true with shaped proposal", () => {
417
- const result = {
418
- schemaVersion: 1,
419
- ok: true,
420
- ref: "lesson:rg",
421
- agentProfile: "claude",
422
- durationMs: 12,
423
- proposal: fullProposal,
424
- };
425
- const out = shapeProposalProducerOutput(result, "normal");
426
- expect(out.ok).toBe(true);
427
- expect(out.ref).toBe("lesson:rg");
428
- expect(out.agentProfile).toBe("claude");
429
- expect(out.durationMs).toBe(12);
430
- expect(out.proposal.id).toBe("uuid-1");
431
- });
432
- test("shapeProposalProducerOutput failure: surfaces reason/error/exitCode; full adds stdout/stderr", () => {
433
- const failure = {
434
- schemaVersion: 1,
435
- ok: false,
436
- reason: "non_zero_exit",
437
- error: "agent failed",
438
- ref: "lesson:rg",
439
- exitCode: 7,
440
- stdout: "captured-out",
441
- stderr: "captured-err",
442
- };
443
- const normal = shapeProposalProducerOutput(failure, "normal");
444
- expect(normal.ok).toBe(false);
445
- expect(normal.reason).toBe("non_zero_exit");
446
- expect(normal.error).toBe("agent failed");
447
- expect(normal.ref).toBe("lesson:rg");
448
- expect(normal.exitCode).toBe(7);
449
- // normal omits stdio (large payload); full retains them
450
- expect(normal).not.toHaveProperty("stdout");
451
- expect(normal).not.toHaveProperty("stderr");
452
- const full = shapeProposalProducerOutput(failure, "full");
453
- expect(full.stdout).toBe("captured-out");
454
- expect(full.stderr).toBe("captured-err");
455
- expect(full.schemaVersion).toBe(1);
456
- });
457
- test("shapeForCommand routes proposal-* arms through their dedicated shapers", () => {
458
- const list = shapeForCommand("proposal-list", { schemaVersion: 1, totalCount: 1, proposals: [fullProposal] }, "brief");
459
- expect(list.totalCount).toBe(1);
460
- const show = shapeForCommand("proposal-show", { schemaVersion: 1, proposal: fullProposal, validation: { ok: true, findings: [] } }, "normal");
461
- expect(show.proposal.ref).toBe("lesson:rg-over-grep");
462
- const accept = shapeForCommand("proposal-accept", {
463
- schemaVersion: 1,
464
- ok: true,
465
- id: "uuid-1",
466
- ref: "lesson:x",
467
- assetPath: "/tmp/x",
468
- proposal: fullProposal,
469
- }, "brief");
470
- expect(accept.assetPath).toBe("/tmp/x");
471
- const reject = shapeForCommand("proposal-reject", { schemaVersion: 1, ok: true, id: "uuid-1", ref: "lesson:x", proposal: fullProposal }, "brief");
472
- expect(reject.id).toBe("uuid-1");
473
- const diff = shapeForCommand("proposal-diff", { schemaVersion: 1, id: "uuid-1", ref: "lesson:x", isNew: true, unified: "+++" }, "brief");
474
- expect(diff.isNew).toBe(true);
475
- const reflect = shapeForCommand("reflect", { schemaVersion: 1, ok: true, ref: "lesson:x", proposal: fullProposal, agentProfile: "p", durationMs: 1 }, "normal");
476
- expect(reflect.ok).toBe(true);
477
- });
478
- });