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,270 +0,0 @@
1
- import { afterAll, describe, expect, test } from "bun:test";
2
- import { spawnSync } from "node:child_process";
3
- import fs from "node:fs";
4
- import os from "node:os";
5
- import path from "node:path";
6
- // ── Helpers ──────────────────────────────────────────────────────────────────
7
- const tempDirs = [];
8
- function makeTempDir(prefix = "akm-sqafix-") {
9
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
10
- tempDirs.push(dir);
11
- return dir;
12
- }
13
- afterAll(() => {
14
- for (const dir of tempDirs) {
15
- fs.rmSync(dir, { recursive: true, force: true });
16
- }
17
- });
18
- const xdgCache = makeTempDir("akm-sqafix-cache-");
19
- const xdgConfig = makeTempDir("akm-sqafix-config-");
20
- const isolatedHome = makeTempDir("akm-sqafix-home-");
21
- const repoRoot = path.resolve(import.meta.dir, "..");
22
- const cliPath = path.join(repoRoot, "src", "cli.ts");
23
- function runCli(args, extraEnv = {}) {
24
- const result = spawnSync("bun", [cliPath, ...args], {
25
- encoding: "utf8",
26
- timeout: 30_000,
27
- cwd: repoRoot,
28
- env: {
29
- ...process.env,
30
- HOME: isolatedHome,
31
- XDG_CACHE_HOME: xdgCache,
32
- XDG_CONFIG_HOME: xdgConfig,
33
- AKM_STASH_DIR: undefined,
34
- ...extraEnv,
35
- },
36
- });
37
- return {
38
- stdout: result.stdout ?? "",
39
- stderr: result.stderr ?? "",
40
- status: result.status ?? 1,
41
- };
42
- }
43
- // ── Test 1 & 2: akm save --format json (space-separated and = form) ──────────
44
- describe("save command: --format flag not consumed as positional name", () => {
45
- test("1. akm save --format json returns JSON, not stash-name error", () => {
46
- const stashDir = makeTempDir("akm-sqafix-stash-");
47
- // Initialize a git repo in stashDir so save has something to work with
48
- spawnSync("git", ["init", stashDir], { encoding: "utf8" });
49
- const { stdout, stderr, status } = runCli(["save", "--format", "json"], {
50
- AKM_STASH_DIR: stashDir,
51
- });
52
- // Should NOT produce the "No git stash found with name 'json'" error
53
- expect(stderr).not.toContain('No git stash found with name "json"');
54
- expect(stderr).not.toContain("No git stash found");
55
- // Exit 0 (nothing to commit or committed) or the output is valid JSON
56
- if (status === 0) {
57
- const parsed = JSON.parse(stdout.trim());
58
- expect(parsed).toHaveProperty("committed");
59
- }
60
- else {
61
- // May fail if stash dir env not found, but should NOT be a stash-name error
62
- expect(stderr).not.toContain('"json"');
63
- }
64
- });
65
- test("2. akm save --format=json still works (eq form)", () => {
66
- const stashDir = makeTempDir("akm-sqafix-stash2-");
67
- spawnSync("git", ["init", stashDir], { encoding: "utf8" });
68
- const { stdout, stderr, status } = runCli(["save", "--format=json"], {
69
- AKM_STASH_DIR: stashDir,
70
- });
71
- expect(stderr).not.toContain('No git stash found with name "json"');
72
- if (status === 0) {
73
- const parsed = JSON.parse(stdout.trim());
74
- expect(parsed).toHaveProperty("committed");
75
- }
76
- });
77
- test("3. akm save my-stash --format json routes correctly (name = my-stash)", () => {
78
- // We don't have a real stash named my-stash, so we expect an error about
79
- // "my-stash" not found — NOT about "json" not found.
80
- const stashDir = makeTempDir("akm-sqafix-stash3-");
81
- const { stderr } = runCli(["save", "my-stash", "--format", "json"], {
82
- AKM_STASH_DIR: stashDir,
83
- });
84
- // Error should mention "my-stash", not "json"
85
- if (stderr.includes("No git stash found")) {
86
- expect(stderr).toContain("my-stash");
87
- expect(stderr).not.toContain('"json"');
88
- }
89
- });
90
- test("3b. akm save json --format json keeps 'json' as the positional stash name", () => {
91
- // Edge case: the legitimate stash name happens to equal the --format value.
92
- // argv-order check should detect this isn't a mis-parse (positional appears
93
- // BEFORE --format) and route "json" as the stash name, not the primary.
94
- const stashDir = makeTempDir("akm-sqafix-stash3b-");
95
- const { stderr } = runCli(["save", "json", "--format", "json"], {
96
- AKM_STASH_DIR: stashDir,
97
- });
98
- // The real stash named "json" doesn't exist, so we expect "No git stash found"
99
- // referencing "json" by name — not a primary-stash success.
100
- if (stderr.includes("No git stash found")) {
101
- expect(stderr).toContain("json");
102
- }
103
- });
104
- });
105
- // ── Test 4: Primary stash with writable:true pushes on save ──────────────────
106
- describe("save command: primary stash respects root-level writable config", () => {
107
- test("4. primary stash with writable:true in config pushes when remote is configured", () => {
108
- // Create a bare remote repo
109
- const bareDir = makeTempDir("akm-sqafix-bare-");
110
- spawnSync("git", ["init", "--bare", bareDir], { encoding: "utf8" });
111
- // Create the primary stash as a git repo with the bare remote
112
- const stashDir = makeTempDir("akm-sqafix-primary-");
113
- spawnSync("git", ["init", stashDir], { encoding: "utf8" });
114
- spawnSync("git", ["-C", stashDir, "remote", "add", "origin", bareDir], { encoding: "utf8" });
115
- // Create an initial file so the repo is non-empty
116
- fs.writeFileSync(path.join(stashDir, "skill.md"), "# skill\n");
117
- spawnSync("git", ["-C", stashDir, "-c", "user.name=test", "-c", "user.email=test@local", "add", "-A"], {
118
- encoding: "utf8",
119
- });
120
- spawnSync("git", ["-C", stashDir, "-c", "user.name=test", "-c", "user.email=test@local", "commit", "-m", "init"], { encoding: "utf8" });
121
- spawnSync("git", ["-C", stashDir, "push", "--set-upstream", "origin", "master"], { encoding: "utf8" });
122
- spawnSync("git", ["-C", stashDir, "push", "--set-upstream", "origin", "main"], { encoding: "utf8" });
123
- // Write a config with writable:true and stashDir pointing to our git repo
124
- const configDir = makeTempDir("akm-sqafix-cfg-");
125
- const configPath = path.join(configDir, "config.json");
126
- fs.writeFileSync(configPath, JSON.stringify({ semanticSearchMode: "off", writable: true }));
127
- // Write a new file to commit and push
128
- fs.writeFileSync(path.join(stashDir, "new-skill.md"), "# new skill\n");
129
- const { stdout, status } = runCli(["save", "-m", "test push"], {
130
- AKM_STASH_DIR: stashDir,
131
- AKM_CONFIG_DIR: configDir,
132
- HOME: makeTempDir("akm-sqafix-home2-"),
133
- XDG_CONFIG_HOME: configDir,
134
- });
135
- // Should have committed and pushed
136
- if (status === 0) {
137
- const parsed = JSON.parse(stdout.trim());
138
- expect(parsed.committed).toBe(true);
139
- expect(parsed.pushed).toBe(true);
140
- }
141
- // Verify the remote received the push by checking it has commits
142
- const logResult = spawnSync("git", ["--git-dir", bareDir, "log", "--oneline"], { encoding: "utf8" });
143
- // If push succeeded, log should have at least the push commit
144
- expect(logResult.stdout.trim().length).toBeGreaterThan(0);
145
- }, { timeout: 30_000 });
146
- });
147
- // ── Test 5 & 6 & 7: akm add --trust warnings and audit ───────────────────────
148
- describe("stash-add: --trust warning for local paths", () => {
149
- test("6. akm add <local-dir> --trust emits warning about no effect", () => {
150
- const localDir = makeTempDir("akm-sqafix-local-");
151
- // Create a minimal skill so the dir is a valid stash root
152
- const skillsDir = path.join(localDir, "skills");
153
- fs.mkdirSync(skillsDir, { recursive: true });
154
- fs.writeFileSync(path.join(skillsDir, "test.md"), "# test skill\n");
155
- const stashDir = makeTempDir("akm-sqafix-add-stash-");
156
- const { stderr, status } = runCli(["add", localDir, "--trust"], {
157
- AKM_STASH_DIR: stashDir,
158
- });
159
- // Should emit the clarifying warning on stderr
160
- expect(stderr).toContain("--trust has no effect on local directory sources");
161
- // Should still succeed
162
- expect(status).toBe(0);
163
- });
164
- test("7. akm add <blocked-source> without --trust includes --trust in error message", () => {
165
- // Use a local dir with a "malicious" content to trigger the audit block.
166
- // We simulate by checking the install-audit error message text directly
167
- // via formatInstallAuditFailure (unit-level check).
168
- const { formatInstallAuditFailure } = require("../src/commands/install-audit");
169
- const fakeReport = {
170
- enabled: true,
171
- passed: false,
172
- blocked: true,
173
- trusted: false,
174
- registryLabels: [],
175
- findings: [
176
- {
177
- id: "remote-shell-pipe",
178
- severity: "critical",
179
- category: "malicious-code",
180
- message: "Downloads remote content and pipes it directly into a shell.",
181
- },
182
- ],
183
- scannedFiles: 1,
184
- scannedBytes: 100,
185
- summary: { low: 0, moderate: 0, high: 0, critical: 1, total: 1 },
186
- };
187
- const msg = formatInstallAuditFailure("test:pkg", fakeReport);
188
- expect(msg).toContain("--trust");
189
- });
190
- });
191
- // ── Test: install-audit formatInstallAuditFailure mentions --trust ────────────
192
- describe("install-audit: block error mentions --trust", () => {
193
- test("block error message includes --trust as remediation", async () => {
194
- const { formatInstallAuditFailure } = await import("../src/commands/install-audit");
195
- const fakeReport = {
196
- enabled: true,
197
- passed: false,
198
- blocked: true,
199
- trusted: false,
200
- registryLabels: [],
201
- findings: [
202
- {
203
- id: "remote-shell-pipe",
204
- severity: "critical",
205
- category: "malicious-code",
206
- message: "Downloads remote content and pipes it directly into a shell.",
207
- },
208
- ],
209
- scannedFiles: 1,
210
- scannedBytes: 100,
211
- summary: { low: 0, moderate: 0, high: 0, critical: 1, total: 1 },
212
- };
213
- const msg = formatInstallAuditFailure("test:pkg", fakeReport);
214
- expect(msg).toContain("--trust");
215
- expect(msg).toContain("bypass this audit");
216
- });
217
- });
218
- // ── Test: config.ts root-level writable field is parsed ──────────────────────
219
- describe("config: root-level writable field", () => {
220
- test("writable:true in config.json is loaded correctly", async () => {
221
- const { loadConfig, resetConfigCache } = await import("../src/core/config");
222
- // XDG_CONFIG_HOME -> akm subdir -> config.json
223
- const xdgDir = makeTempDir("akm-sqafix-cfgtest-");
224
- const akmConfigDir = path.join(xdgDir, "akm");
225
- fs.mkdirSync(akmConfigDir, { recursive: true });
226
- const configPath = path.join(akmConfigDir, "config.json");
227
- fs.writeFileSync(configPath, JSON.stringify({ semanticSearchMode: "off", writable: true }));
228
- // Use AKM_CONFIG_DIR env override (most direct override)
229
- const origEnv = { AKM_CONFIG_DIR: process.env.AKM_CONFIG_DIR };
230
- process.env.AKM_CONFIG_DIR = akmConfigDir;
231
- resetConfigCache();
232
- try {
233
- const cfg = loadConfig();
234
- expect(cfg.writable).toBe(true);
235
- }
236
- finally {
237
- if (origEnv.AKM_CONFIG_DIR === undefined) {
238
- delete process.env.AKM_CONFIG_DIR;
239
- }
240
- else {
241
- process.env.AKM_CONFIG_DIR = origEnv.AKM_CONFIG_DIR;
242
- }
243
- resetConfigCache();
244
- }
245
- });
246
- test("writable not set defaults to undefined (falsy)", async () => {
247
- const { loadConfig, resetConfigCache } = await import("../src/core/config");
248
- const xdgDir2 = makeTempDir("akm-sqafix-cfgtest2-");
249
- const akmConfigDir2 = path.join(xdgDir2, "akm");
250
- fs.mkdirSync(akmConfigDir2, { recursive: true });
251
- const configPath = path.join(akmConfigDir2, "config.json");
252
- fs.writeFileSync(configPath, JSON.stringify({ semanticSearchMode: "off" }));
253
- const origEnv = { AKM_CONFIG_DIR: process.env.AKM_CONFIG_DIR };
254
- process.env.AKM_CONFIG_DIR = akmConfigDir2;
255
- resetConfigCache();
256
- try {
257
- const cfg = loadConfig();
258
- expect(cfg.writable).toBeUndefined();
259
- }
260
- finally {
261
- if (origEnv.AKM_CONFIG_DIR === undefined) {
262
- delete process.env.AKM_CONFIG_DIR;
263
- }
264
- else {
265
- process.env.AKM_CONFIG_DIR = origEnv.AKM_CONFIG_DIR;
266
- }
267
- resetConfigCache();
268
- }
269
- });
270
- });