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,205 +0,0 @@
1
- /**
2
- * Tests for the `akm manifest` command (Task E-1: Deferred/Lazy Tool Loading).
3
- *
4
- * The manifest provides a compact asset listing (name, type, ref, one-line
5
- * description) that stays under 500 tokens for 50 assets, giving agents a
6
- * cheap way to discover capabilities without loading full content.
7
- */
8
- import { afterAll, afterEach, beforeEach, describe, expect, test } from "bun:test";
9
- import fs from "node:fs";
10
- import os from "node:os";
11
- import path from "node:path";
12
- import { saveConfig } from "../src/core/config";
13
- import { akmIndex } from "../src/indexer/indexer";
14
- import { akmManifest } from "../src/indexer/manifest";
15
- // ── Temp directory tracking ─────────────────────────────────────────────────
16
- const createdTmpDirs = [];
17
- function createTmpDir(prefix = "akm-manifest-") {
18
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
19
- createdTmpDirs.push(dir);
20
- return dir;
21
- }
22
- afterAll(() => {
23
- for (const dir of createdTmpDirs) {
24
- fs.rmSync(dir, { recursive: true, force: true });
25
- }
26
- });
27
- // ── Helpers ─────────────────────────────────────────────────────────────────
28
- function tmpStash() {
29
- const dir = createTmpDir("akm-manifest-stash-");
30
- for (const sub of ["skills", "commands", "agents", "knowledge", "scripts"]) {
31
- fs.mkdirSync(path.join(dir, sub), { recursive: true });
32
- }
33
- return dir;
34
- }
35
- async function buildTestIndex(stashDir, files = {}) {
36
- for (const [relPath, content] of Object.entries(files)) {
37
- const fullPath = path.join(stashDir, relPath);
38
- fs.mkdirSync(path.dirname(fullPath), { recursive: true });
39
- fs.writeFileSync(fullPath, content);
40
- }
41
- process.env.AKM_STASH_DIR = stashDir;
42
- saveConfig({ semanticSearchMode: "off" });
43
- await akmIndex({ stashDir, full: true });
44
- }
45
- // ── Environment isolation ───────────────────────────────────────────────────
46
- const originalXdgCacheHome = process.env.XDG_CACHE_HOME;
47
- const originalXdgConfigHome = process.env.XDG_CONFIG_HOME;
48
- const originalAkmStashDir = process.env.AKM_STASH_DIR;
49
- let testCacheDir = "";
50
- let testConfigDir = "";
51
- beforeEach(() => {
52
- testCacheDir = createTmpDir("akm-manifest-cache-");
53
- testConfigDir = createTmpDir("akm-manifest-config-");
54
- process.env.XDG_CACHE_HOME = testCacheDir;
55
- process.env.XDG_CONFIG_HOME = testConfigDir;
56
- });
57
- afterEach(() => {
58
- if (originalXdgCacheHome === undefined) {
59
- delete process.env.XDG_CACHE_HOME;
60
- }
61
- else {
62
- process.env.XDG_CACHE_HOME = originalXdgCacheHome;
63
- }
64
- if (originalXdgConfigHome === undefined) {
65
- delete process.env.XDG_CONFIG_HOME;
66
- }
67
- else {
68
- process.env.XDG_CONFIG_HOME = originalXdgConfigHome;
69
- }
70
- if (originalAkmStashDir === undefined) {
71
- delete process.env.AKM_STASH_DIR;
72
- }
73
- else {
74
- process.env.AKM_STASH_DIR = originalAkmStashDir;
75
- }
76
- });
77
- // ── Tests ───────────────────────────────────────────────────────────────────
78
- describe("akm manifest", () => {
79
- test("returns all indexed entries", async () => {
80
- const stashDir = tmpStash();
81
- await buildTestIndex(stashDir, {
82
- "scripts/deploy/deploy.sh": "#!/bin/bash\n# Deploy to production\necho deploy",
83
- "scripts/lint/lint.sh": "#!/bin/bash\n# Run linter\necho lint",
84
- "skills/code-review/SKILL.md": "---\ndescription: Review code for quality\n---\n# Code Review",
85
- "commands/build/BUILD.md": "---\ndescription: Build the project\n---\n# Build",
86
- "knowledge/api-docs/api-docs.md": "---\ndescription: API documentation reference\n---\n# API Docs",
87
- });
88
- const result = await akmManifest({ stashDir });
89
- expect(result.entries.length).toBe(5);
90
- });
91
- test("entries have compact shape (name, type, ref, description only)", async () => {
92
- const stashDir = tmpStash();
93
- await buildTestIndex(stashDir, {
94
- "scripts/deploy/deploy.sh": "#!/bin/bash\n# Deploy to production\necho deploy",
95
- });
96
- const result = await akmManifest({ stashDir });
97
- expect(result.entries.length).toBeGreaterThan(0);
98
- const entry = result.entries[0];
99
- // Must have the compact fields
100
- expect(typeof entry.name).toBe("string");
101
- expect(typeof entry.type).toBe("string");
102
- expect(typeof entry.ref).toBe("string");
103
- // Must NOT have full search hit fields like path, tags, score, action, whyMatched
104
- const raw = entry;
105
- expect(raw.path).toBeUndefined();
106
- expect(raw.tags).toBeUndefined();
107
- expect(raw.score).toBeUndefined();
108
- expect(raw.action).toBeUndefined();
109
- expect(raw.whyMatched).toBeUndefined();
110
- expect(raw.searchText).toBeUndefined();
111
- });
112
- test("filters by type", async () => {
113
- const stashDir = tmpStash();
114
- await buildTestIndex(stashDir, {
115
- "scripts/deploy/deploy.sh": "#!/bin/bash\n# Deploy to production\necho deploy",
116
- "scripts/lint/lint.sh": "#!/bin/bash\n# Run linter\necho lint",
117
- "skills/code-review/SKILL.md": "---\ndescription: Review code for quality\n---\n# Code Review",
118
- });
119
- const result = await akmManifest({ stashDir, type: "script" });
120
- expect(result.entries.length).toBe(2);
121
- for (const entry of result.entries) {
122
- expect(entry.type).toBe("script");
123
- }
124
- });
125
- test("descriptions are truncated to ~80 chars", async () => {
126
- const stashDir = tmpStash();
127
- const longDesc = "This is a very long description that goes well beyond eighty characters and should be truncated with an ellipsis indicator to keep the manifest compact and token-efficient";
128
- await buildTestIndex(stashDir, {
129
- "skills/verbose/SKILL.md": `---\ndescription: ${longDesc}\n---\n# Verbose Skill`,
130
- });
131
- const result = await akmManifest({ stashDir });
132
- expect(result.entries.length).toBeGreaterThan(0);
133
- const entry = result.entries.find((e) => e.name === "verbose");
134
- expect(entry).toBeDefined();
135
- expect(entry?.description).toBeDefined();
136
- expect(entry?.description?.length).toBeLessThanOrEqual(83); // 80 + "..."
137
- expect(entry?.description?.endsWith("...")).toBe(true);
138
- });
139
- test("output is compact (token budget) for 50 entries", async () => {
140
- const stashDir = tmpStash();
141
- const files = {};
142
- // Create 50 script files
143
- for (let i = 0; i < 50; i++) {
144
- const name = `script-${String(i).padStart(2, "0")}`;
145
- files[`scripts/${name}/${name}.sh`] = `#!/bin/bash\n# Task number ${i}\necho ${name}`;
146
- }
147
- await buildTestIndex(stashDir, files);
148
- const result = await akmManifest({ stashDir });
149
- expect(result.entries.length).toBe(50);
150
- const json = JSON.stringify(result);
151
- // Compact: each entry averages ~120 bytes (name, type, ref, short description).
152
- // 50 entries ≈ 6000 bytes ≈ 1500 tokens. Cap at ~2500 bytes per token budget
153
- // would be too tight for 50 entries, so we allow up to 7500 bytes (~1875 tokens).
154
- expect(json.length).toBeLessThan(7500);
155
- // Verify no entry carries heavyweight fields
156
- for (const entry of result.entries) {
157
- const raw = entry;
158
- expect(raw.path).toBeUndefined();
159
- expect(raw.tags).toBeUndefined();
160
- expect(raw.score).toBeUndefined();
161
- expect(raw.action).toBeUndefined();
162
- }
163
- });
164
- test("works without an index (fallback to walker)", async () => {
165
- const stashDir = tmpStash();
166
- // Write files but do NOT run akmIndex
167
- const helloDir = path.join(stashDir, "scripts", "hello");
168
- fs.mkdirSync(helloDir, { recursive: true });
169
- fs.writeFileSync(path.join(helloDir, "hello.sh"), "#!/bin/bash\n# Say hello\necho hello");
170
- process.env.AKM_STASH_DIR = stashDir;
171
- saveConfig({ semanticSearchMode: "off" });
172
- const result = await akmManifest({ stashDir });
173
- // Should find entries via walker fallback even without index
174
- expect(result.entries.length).toBeGreaterThanOrEqual(1);
175
- });
176
- test("response has schemaVersion and entries array", async () => {
177
- const stashDir = tmpStash();
178
- await buildTestIndex(stashDir, {
179
- "scripts/deploy/deploy.sh": "#!/bin/bash\n# Deploy\necho deploy",
180
- "scripts/lint/lint.sh": "#!/bin/bash\n# Lint\necho lint",
181
- "scripts/test/test.sh": "#!/bin/bash\n# Test\necho test",
182
- });
183
- const result = await akmManifest({ stashDir });
184
- expect(result.schemaVersion).toBe(1);
185
- expect(result.entries.length).toBe(3);
186
- });
187
- test("empty stash returns empty manifest", async () => {
188
- const stashDir = tmpStash();
189
- process.env.AKM_STASH_DIR = stashDir;
190
- saveConfig({ semanticSearchMode: "off" });
191
- const result = await akmManifest({ stashDir });
192
- expect(result.entries).toEqual([]);
193
- expect(result.schemaVersion).toBe(1);
194
- });
195
- test("ref field follows type:name format", async () => {
196
- const stashDir = tmpStash();
197
- await buildTestIndex(stashDir, {
198
- "skills/code-review/SKILL.md": "---\ndescription: Review code quality\n---\n# Code Review",
199
- });
200
- const result = await akmManifest({ stashDir });
201
- const entry = result.entries.find((e) => e.name === "code-review");
202
- expect(entry).toBeDefined();
203
- expect(entry?.ref).toMatch(/^skill:code-review$/);
204
- });
205
- });
@@ -1,126 +0,0 @@
1
- import { expect, test } from "bun:test";
2
- import { extractFrontmatterOnly, extractLineRange, extractSection, formatToc, parseMarkdownToc, } from "../src/core/markdown";
3
- const SAMPLE_DOC = `---
4
- title: Guide
5
- description: "A test guide"
6
- ---
7
- # Getting Started
8
-
9
- Welcome to the guide.
10
-
11
- ## Installation
12
-
13
- Run \`npm install\` to get started.
14
-
15
- ## Configuration
16
-
17
- Set up your config file.
18
-
19
- ### Advanced Config
20
-
21
- For power users.
22
-
23
- # API Reference
24
-
25
- The API docs.
26
-
27
- ## Endpoints
28
-
29
- List of endpoints.
30
- `;
31
- test("parseMarkdownToc extracts headings with correct levels and line numbers", () => {
32
- const toc = parseMarkdownToc(SAMPLE_DOC);
33
- expect(toc.headings.length).toBe(6);
34
- expect(toc.headings[0]).toEqual({ level: 1, text: "Getting Started", line: 5 });
35
- expect(toc.headings[1]).toEqual({ level: 2, text: "Installation", line: 9 });
36
- expect(toc.headings[2]).toEqual({ level: 2, text: "Configuration", line: 13 });
37
- expect(toc.headings[3]).toEqual({ level: 3, text: "Advanced Config", line: 17 });
38
- expect(toc.headings[4]).toEqual({ level: 1, text: "API Reference", line: 21 });
39
- expect(toc.headings[5]).toEqual({ level: 2, text: "Endpoints", line: 25 });
40
- });
41
- test("parseMarkdownToc skips frontmatter block", () => {
42
- const doc = "---\ntitle: Test\n---\n# Heading\n";
43
- const toc = parseMarkdownToc(doc);
44
- expect(toc.headings.length).toBe(1);
45
- expect(toc.headings[0].text).toBe("Heading");
46
- });
47
- test("parseMarkdownToc handles document without frontmatter", () => {
48
- const doc = "# Title\n\nSome text\n\n## Section\n";
49
- const toc = parseMarkdownToc(doc);
50
- expect(toc.headings.length).toBe(2);
51
- expect(toc.headings[0]).toEqual({ level: 1, text: "Title", line: 1 });
52
- expect(toc.headings[1]).toEqual({ level: 2, text: "Section", line: 5 });
53
- });
54
- test("parseMarkdownToc handles empty content", () => {
55
- const toc = parseMarkdownToc("");
56
- expect(toc.headings).toEqual([]);
57
- expect(toc.totalLines).toBe(1);
58
- });
59
- test("parseMarkdownToc strips trailing hash markers", () => {
60
- const doc = "# Heading ##\n## Another ###\n";
61
- const toc = parseMarkdownToc(doc);
62
- expect(toc.headings[0].text).toBe("Heading");
63
- expect(toc.headings[1].text).toBe("Another");
64
- });
65
- test("extractSection returns content from heading to next same-or-higher level", () => {
66
- const result = extractSection(SAMPLE_DOC, "Installation");
67
- expect(result).not.toBeNull();
68
- expect(result?.content).toContain("npm install");
69
- expect(result?.content).not.toContain("Configuration");
70
- });
71
- test("extractSection returns content including sub-headings", () => {
72
- const result = extractSection(SAMPLE_DOC, "Configuration");
73
- expect(result).not.toBeNull();
74
- expect(result?.content).toContain("Advanced Config");
75
- expect(result?.content).not.toContain("API Reference");
76
- });
77
- test("extractSection is case-insensitive", () => {
78
- const result = extractSection(SAMPLE_DOC, "installation");
79
- expect(result).not.toBeNull();
80
- expect(result?.content).toContain("npm install");
81
- });
82
- test("extractSection returns null for non-existent heading", () => {
83
- const result = extractSection(SAMPLE_DOC, "Nonexistent");
84
- expect(result).toBeNull();
85
- });
86
- test("extractSection handles last section (no following heading)", () => {
87
- const result = extractSection(SAMPLE_DOC, "Endpoints");
88
- expect(result).not.toBeNull();
89
- expect(result?.content).toContain("List of endpoints");
90
- });
91
- test("extractLineRange returns correct lines (1-based inclusive)", () => {
92
- const content = "line1\nline2\nline3\nline4\nline5";
93
- expect(extractLineRange(content, 2, 4)).toBe("line2\nline3\nline4");
94
- });
95
- test("extractLineRange clamps to valid range", () => {
96
- const content = "line1\nline2\nline3";
97
- expect(extractLineRange(content, 0, 100)).toBe("line1\nline2\nline3");
98
- expect(extractLineRange(content, 2, 2)).toBe("line2");
99
- });
100
- test("extractLineRange returns empty when end is before start", () => {
101
- const content = "line1\nline2\nline3\nline4\nline5";
102
- expect(extractLineRange(content, 5, 2)).toBe("");
103
- });
104
- test("extractFrontmatterOnly returns YAML block", () => {
105
- const fm = extractFrontmatterOnly(SAMPLE_DOC);
106
- expect(fm).not.toBeNull();
107
- expect(fm).toContain("title: Guide");
108
- expect(fm).toContain('description: "A test guide"');
109
- });
110
- test("extractFrontmatterOnly returns null when no frontmatter", () => {
111
- expect(extractFrontmatterOnly("# Just a heading\n")).toBeNull();
112
- });
113
- test("formatToc produces readable output with line numbers", () => {
114
- const toc = parseMarkdownToc(SAMPLE_DOC);
115
- const output = formatToc(toc);
116
- expect(output).toContain("# Getting Started");
117
- expect(output).toContain("## Installation");
118
- expect(output).toContain("### Advanced Config");
119
- expect(output).toContain("lines total");
120
- expect(output).toMatch(/L\s*\d+/);
121
- });
122
- test("formatToc handles empty headings", () => {
123
- const output = formatToc({ headings: [], totalLines: 5 });
124
- expect(output).toContain("no headings found");
125
- expect(output).toContain("5 lines total");
126
- });
@@ -1,189 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { directoryMatcher, extensionMatcher, parentDirHintMatcher, smartMdMatcher, wikiMatcher, } from "../src/indexer/matchers";
3
- /**
4
- * Build a synthetic FileContext for matcher unit tests. The matchers
5
- * (except smartMdMatcher) are pure functions of path-derived fields, so
6
- * the lazy `content`/`frontmatter`/`stat` getters can return canned data
7
- * — no real filesystem access needed.
8
- */
9
- function ctx(opts) {
10
- const segments = opts.relPath.split("/");
11
- const fileName = segments[segments.length - 1];
12
- const ext = (() => {
13
- const dot = fileName.lastIndexOf(".");
14
- return dot > 0 ? fileName.slice(dot).toLowerCase() : "";
15
- })();
16
- const dirSegments = segments.slice(0, -1);
17
- const parentDir = dirSegments.length > 0 ? dirSegments[dirSegments.length - 1] : "";
18
- const parentDirAbs = `/stash/${dirSegments.join("/")}`.replace(/\/+$/, "");
19
- return {
20
- absPath: `/stash/${opts.relPath}`,
21
- relPath: opts.relPath,
22
- ext,
23
- fileName,
24
- parentDir,
25
- parentDirAbs,
26
- ancestorDirs: dirSegments,
27
- stashRoot: "/stash",
28
- content: () => opts.content ?? "",
29
- frontmatter: () => opts.frontmatter ?? null,
30
- stat: () => {
31
- throw new Error("stat() should not be called by these matchers");
32
- },
33
- };
34
- }
35
- // ── extensionMatcher ────────────────────────────────────────────────────────
36
- describe("extensionMatcher", () => {
37
- test("classifies SKILL.md anywhere as skill at high specificity", () => {
38
- const result = extensionMatcher(ctx({ relPath: "anywhere/deep/SKILL.md" }));
39
- expect(result).toEqual({ type: "skill", specificity: 25, renderer: "skill-md" });
40
- });
41
- test("does NOT classify SKILL.md under wikis/ as skill", () => {
42
- const result = extensionMatcher(ctx({ relPath: "wikis/research/SKILL.md" }));
43
- expect(result).toBeNull();
44
- });
45
- test("classifies known script extensions as script at low specificity", () => {
46
- expect(extensionMatcher(ctx({ relPath: "stuff/deploy.sh" }))?.type).toBe("script");
47
- expect(extensionMatcher(ctx({ relPath: "stuff/lint.ts" }))?.type).toBe("script");
48
- expect(extensionMatcher(ctx({ relPath: "stuff/lint.ts" }))?.specificity).toBe(3);
49
- });
50
- test("does not handle .md files (smartMdMatcher's job)", () => {
51
- expect(extensionMatcher(ctx({ relPath: "stuff/notes.md" }))).toBeNull();
52
- });
53
- test("returns null for unknown extensions", () => {
54
- expect(extensionMatcher(ctx({ relPath: "stuff/data.bin" }))).toBeNull();
55
- });
56
- });
57
- // ── directoryMatcher ────────────────────────────────────────────────────────
58
- describe("directoryMatcher", () => {
59
- test("scripts/ ancestor classifies a script", () => {
60
- const result = directoryMatcher(ctx({ relPath: "scripts/azure/deploy.sh" }));
61
- expect(result).toEqual({ type: "script", specificity: 10, renderer: "script-source" });
62
- });
63
- test("first matching ancestor wins (commands/ before agents/ in path)", () => {
64
- const result = directoryMatcher(ctx({ relPath: "commands/agents/foo.md" }));
65
- expect(result?.type).toBe("command");
66
- });
67
- test("agents/foo.md classifies as agent", () => {
68
- expect(directoryMatcher(ctx({ relPath: "agents/foo.md" }))?.type).toBe("agent");
69
- });
70
- test("knowledge/foo.md classifies as knowledge", () => {
71
- expect(directoryMatcher(ctx({ relPath: "knowledge/foo.md" }))?.type).toBe("knowledge");
72
- });
73
- test("workflows/foo.md classifies as workflow", () => {
74
- expect(directoryMatcher(ctx({ relPath: "workflows/foo.md" }))?.type).toBe("workflow");
75
- });
76
- test("memories/foo.md classifies as memory", () => {
77
- expect(directoryMatcher(ctx({ relPath: "memories/foo.md" }))?.type).toBe("memory");
78
- });
79
- test("vaults/.env classifies as vault", () => {
80
- expect(directoryMatcher(ctx({ relPath: "vaults/.env" }))?.type).toBe("vault");
81
- expect(directoryMatcher(ctx({ relPath: "vaults/staging.env" }))?.type).toBe("vault");
82
- });
83
- test("unmatched directories return null", () => {
84
- expect(directoryMatcher(ctx({ relPath: "random/file.md" }))).toBeNull();
85
- });
86
- });
87
- // ── parentDirHintMatcher ────────────────────────────────────────────────────
88
- describe("parentDirHintMatcher", () => {
89
- test("immediate parent named scripts/ classifies a script at higher specificity", () => {
90
- const result = parentDirHintMatcher(ctx({ relPath: "my-project/scripts/run.sh" }));
91
- expect(result).toEqual({ type: "script", specificity: 15, renderer: "script-source" });
92
- });
93
- test("agents parent dir classifies an .md as agent", () => {
94
- expect(parentDirHintMatcher(ctx({ relPath: "anything/agents/foo.md" }))?.type).toBe("agent");
95
- });
96
- test("returns null when parent doesn't match a type", () => {
97
- expect(parentDirHintMatcher(ctx({ relPath: "random/blah.md" }))).toBeNull();
98
- });
99
- });
100
- // ── smartMdMatcher ─────────────────────────────────────────────────────────
101
- describe("smartMdMatcher", () => {
102
- test("returns null for non-.md files", () => {
103
- expect(smartMdMatcher(ctx({ relPath: "stuff/run.sh", content: "" }))).toBeNull();
104
- });
105
- test("workflow signals classify as workflow at specificity 19", () => {
106
- const body = `# Workflow: Deploy
107
- ## Step: Validate
108
- Step ID: validate
109
-
110
- ### Instructions
111
- Do the thing.
112
- `;
113
- const result = smartMdMatcher(ctx({ relPath: "anywhere.md", content: body }));
114
- expect(result).toEqual({ type: "workflow", specificity: 19, renderer: "workflow-md" });
115
- });
116
- test("toolPolicy frontmatter classifies as agent at 20 (highest)", () => {
117
- const result = smartMdMatcher(ctx({
118
- relPath: "blah.md",
119
- content: "body",
120
- frontmatter: { toolPolicy: "strict" },
121
- }));
122
- expect(result).toEqual({ type: "agent", specificity: 20, renderer: "agent-md" });
123
- });
124
- test("tools frontmatter classifies as agent at 20", () => {
125
- const result = smartMdMatcher(ctx({
126
- relPath: "blah.md",
127
- content: "body",
128
- frontmatter: { tools: ["read"] },
129
- }));
130
- expect(result?.type).toBe("agent");
131
- expect(result?.specificity).toBe(20);
132
- });
133
- test("agent-named frontmatter (OpenCode command) classifies as command at 18", () => {
134
- const result = smartMdMatcher(ctx({
135
- relPath: "blah.md",
136
- content: "body",
137
- frontmatter: { agent: "review" },
138
- }));
139
- expect(result).toEqual({ type: "command", specificity: 18, renderer: "command-md" });
140
- });
141
- test("$ARGUMENTS placeholder classifies as command at 18", () => {
142
- const result = smartMdMatcher(ctx({
143
- relPath: "blah.md",
144
- content: "Run with $ARGUMENTS",
145
- }));
146
- expect(result).toEqual({ type: "command", specificity: 18, renderer: "command-md" });
147
- });
148
- test("$1 placeholder classifies as command at 18", () => {
149
- const result = smartMdMatcher(ctx({
150
- relPath: "blah.md",
151
- content: "First arg is $1",
152
- }));
153
- expect(result?.type).toBe("command");
154
- });
155
- test("model frontmatter alone is a weak agent signal (specificity 8)", () => {
156
- const result = smartMdMatcher(ctx({
157
- relPath: "blah.md",
158
- content: "body",
159
- frontmatter: { model: "gpt-4o" },
160
- }));
161
- expect(result).toEqual({ type: "agent", specificity: 8, renderer: "agent-md" });
162
- });
163
- test("plain .md falls back to knowledge at specificity 5", () => {
164
- const result = smartMdMatcher(ctx({
165
- relPath: "blah.md",
166
- content: "Just some prose with no signals.",
167
- }));
168
- expect(result).toEqual({ type: "knowledge", specificity: 5, renderer: "knowledge-md" });
169
- });
170
- });
171
- // ── wikiMatcher ─────────────────────────────────────────────────────────────
172
- describe("wikiMatcher", () => {
173
- test("any .md under wikis/<name>/ classifies as wiki at specificity 20", () => {
174
- const result = wikiMatcher(ctx({ relPath: "wikis/research/page.md" }));
175
- expect(result).toEqual({ type: "wiki", specificity: 20, renderer: "wiki-md" });
176
- });
177
- test("nested wiki pages also classify as wiki", () => {
178
- expect(wikiMatcher(ctx({ relPath: "wikis/research/sub/deep/page.md" }))?.type).toBe("wiki");
179
- });
180
- test("non-.md files are ignored", () => {
181
- expect(wikiMatcher(ctx({ relPath: "wikis/research/page.txt" }))).toBeNull();
182
- });
183
- test("a stray .md at bare wikis/ root is NOT a wiki page", () => {
184
- expect(wikiMatcher(ctx({ relPath: "wikis/orphan.md" }))).toBeNull();
185
- });
186
- test("paths without wikis/ are ignored", () => {
187
- expect(wikiMatcher(ctx({ relPath: "knowledge/page.md" }))).toBeNull();
188
- });
189
- });