cognitive-core 0.2.0 → 0.2.2

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 (397) hide show
  1. package/.claude/settings.json +111 -2
  2. package/.sessionlog/settings.json +4 -0
  3. package/dist/atlas.d.ts +10 -0
  4. package/dist/atlas.d.ts.map +1 -1
  5. package/dist/atlas.js +65 -0
  6. package/dist/atlas.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +5 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/learning/index.d.ts +1 -1
  12. package/dist/learning/index.d.ts.map +1 -1
  13. package/dist/learning/index.js.map +1 -1
  14. package/dist/learning/pipeline.d.ts +4 -31
  15. package/dist/learning/pipeline.d.ts.map +1 -1
  16. package/dist/learning/pipeline.js +12 -64
  17. package/dist/learning/pipeline.js.map +1 -1
  18. package/dist/learning/unified-pipeline.d.ts +30 -0
  19. package/dist/learning/unified-pipeline.d.ts.map +1 -1
  20. package/dist/learning/unified-pipeline.js +207 -0
  21. package/dist/learning/unified-pipeline.js.map +1 -1
  22. package/dist/memory/candidate-retrieval.d.ts.map +1 -1
  23. package/dist/memory/candidate-retrieval.js +3 -1
  24. package/dist/memory/candidate-retrieval.js.map +1 -1
  25. package/dist/memory/curated-loader.d.ts +21 -4
  26. package/dist/memory/curated-loader.d.ts.map +1 -1
  27. package/dist/memory/curated-loader.js +53 -16
  28. package/dist/memory/curated-loader.js.map +1 -1
  29. package/dist/memory/index.d.ts +2 -1
  30. package/dist/memory/index.d.ts.map +1 -1
  31. package/dist/memory/index.js +3 -1
  32. package/dist/memory/index.js.map +1 -1
  33. package/dist/memory/playbook.d.ts +6 -0
  34. package/dist/memory/playbook.d.ts.map +1 -1
  35. package/dist/memory/playbook.js +15 -0
  36. package/dist/memory/playbook.js.map +1 -1
  37. package/dist/memory/source-resolver.d.ts +120 -0
  38. package/dist/memory/source-resolver.d.ts.map +1 -0
  39. package/dist/memory/source-resolver.js +300 -0
  40. package/dist/memory/source-resolver.js.map +1 -0
  41. package/dist/types/config.d.ts +141 -0
  42. package/dist/types/config.d.ts.map +1 -1
  43. package/dist/types/config.js +40 -0
  44. package/dist/types/config.js.map +1 -1
  45. package/dist/types/index.d.ts +1 -1
  46. package/dist/types/index.d.ts.map +1 -1
  47. package/dist/types/index.js +1 -1
  48. package/dist/types/index.js.map +1 -1
  49. package/dist/utils/error-classifier.js +8 -8
  50. package/dist/utils/error-classifier.js.map +1 -1
  51. package/dist/workspace/efficacy-toolkit.d.ts +164 -0
  52. package/dist/workspace/efficacy-toolkit.d.ts.map +1 -0
  53. package/dist/workspace/efficacy-toolkit.js +281 -0
  54. package/dist/workspace/efficacy-toolkit.js.map +1 -0
  55. package/dist/workspace/index.d.ts +2 -1
  56. package/dist/workspace/index.d.ts.map +1 -1
  57. package/dist/workspace/index.js +3 -1
  58. package/dist/workspace/index.js.map +1 -1
  59. package/dist/workspace/templates/index.d.ts +3 -0
  60. package/dist/workspace/templates/index.d.ts.map +1 -1
  61. package/dist/workspace/templates/index.js +6 -0
  62. package/dist/workspace/templates/index.js.map +1 -1
  63. package/dist/workspace/templates/playbook-decay-detection.d.ts +46 -0
  64. package/dist/workspace/templates/playbook-decay-detection.d.ts.map +1 -0
  65. package/dist/workspace/templates/playbook-decay-detection.js +197 -0
  66. package/dist/workspace/templates/playbook-decay-detection.js.map +1 -0
  67. package/dist/workspace/templates/playbook-efficacy-audit.d.ts +46 -0
  68. package/dist/workspace/templates/playbook-efficacy-audit.d.ts.map +1 -0
  69. package/dist/workspace/templates/playbook-efficacy-audit.js +160 -0
  70. package/dist/workspace/templates/playbook-efficacy-audit.js.map +1 -0
  71. package/dist/workspace/templates/playbook-lifecycle-review.d.ts +51 -0
  72. package/dist/workspace/templates/playbook-lifecycle-review.d.ts.map +1 -0
  73. package/dist/workspace/templates/playbook-lifecycle-review.js +187 -0
  74. package/dist/workspace/templates/playbook-lifecycle-review.js.map +1 -0
  75. package/dist/workspace/types.d.ts +12 -54
  76. package/dist/workspace/types.d.ts.map +1 -1
  77. package/dist/workspace/types.js.map +1 -1
  78. package/package.json +8 -2
  79. package/playbooks/compound-engineering/adversarial-review.json +51 -0
  80. package/playbooks/compound-engineering/agent-native-architecture.json +59 -0
  81. package/playbooks/compound-engineering/agent-native-review.json +54 -0
  82. package/playbooks/compound-engineering/api-contract-review.json +52 -0
  83. package/playbooks/compound-engineering/brainstorm-requirements.json +55 -0
  84. package/playbooks/compound-engineering/bug-reproduction.json +62 -0
  85. package/playbooks/compound-engineering/confidence-calibration.json +49 -0
  86. package/playbooks/compound-engineering/correctness-review.json +49 -0
  87. package/playbooks/compound-engineering/data-migration-safety.json +59 -0
  88. package/playbooks/compound-engineering/deployment-verification.json +63 -0
  89. package/playbooks/compound-engineering/error-recovery-patterns.json +53 -0
  90. package/playbooks/compound-engineering/implementation-planning.json +64 -0
  91. package/playbooks/compound-engineering/issue-pattern-analysis.json +53 -0
  92. package/playbooks/compound-engineering/knowledge-compounding.json +63 -0
  93. package/playbooks/compound-engineering/learnings-research.json +54 -0
  94. package/playbooks/compound-engineering/maintainability-review.json +49 -0
  95. package/playbooks/compound-engineering/performance-review.json +54 -0
  96. package/playbooks/compound-engineering/plan-adversarial-review.json +56 -0
  97. package/playbooks/compound-engineering/plan-feasibility-review.json +56 -0
  98. package/playbooks/compound-engineering/project-standards-review.json +52 -0
  99. package/playbooks/compound-engineering/reliability-review.json +53 -0
  100. package/playbooks/compound-engineering/review-orchestration.json +64 -0
  101. package/playbooks/compound-engineering/security-review.json +54 -0
  102. package/playbooks/compound-engineering/systematic-execution.json +64 -0
  103. package/playbooks/compound-engineering/testing-review.json +50 -0
  104. package/src/atlas.ts +96 -0
  105. package/src/index.ts +27 -0
  106. package/src/learning/index.ts +1 -0
  107. package/src/learning/unified-pipeline.ts +271 -1
  108. package/src/memory/candidate-retrieval.ts +2 -1
  109. package/src/memory/curated-loader.ts +69 -16
  110. package/src/memory/index.ts +16 -0
  111. package/src/memory/playbook.ts +19 -0
  112. package/src/memory/source-resolver.ts +422 -0
  113. package/src/types/config.ts +46 -0
  114. package/src/types/index.ts +4 -0
  115. package/src/utils/error-classifier.ts +8 -8
  116. package/src/workspace/efficacy-toolkit.ts +496 -0
  117. package/src/workspace/index.ts +29 -0
  118. package/src/workspace/templates/index.ts +24 -0
  119. package/src/workspace/templates/playbook-decay-detection.ts +272 -0
  120. package/src/workspace/templates/playbook-efficacy-audit.ts +246 -0
  121. package/src/workspace/templates/playbook-lifecycle-review.ts +274 -0
  122. package/src/workspace/types.ts +22 -78
  123. package/tests/fixtures/behavioral-trajectories.ts +210 -0
  124. package/tests/integration/curated-sources-e2e.test.ts +502 -0
  125. package/tests/integration/pipeline-data-correctness.test.ts +794 -0
  126. package/tests/learning/meta-learner.test.ts +418 -0
  127. package/tests/learning/pipeline-memory-updates.test.ts +721 -0
  128. package/tests/learning/unified-pipeline-efficacy.test.ts +232 -0
  129. package/tests/memory/candidate-retrieval.test.ts +167 -0
  130. package/tests/memory/compound-engineering-seed.test.ts +338 -0
  131. package/tests/memory/curated-loader-extended.test.ts +225 -0
  132. package/tests/memory/meta.test.ts +399 -0
  133. package/tests/memory/playbook-quality-validation.test.ts +430 -0
  134. package/tests/memory/source-resolver.test.ts +700 -0
  135. package/tests/search/evaluator.test.ts +257 -0
  136. package/tests/search/verification-runner.test.ts +357 -0
  137. package/tests/utils/error-classifier.test.ts +149 -0
  138. package/tests/utils/trajectory-helpers.test.ts +163 -0
  139. package/tests/workspace/efficacy-toolkit.test.ts +404 -0
  140. package/tests/workspace/templates/playbook-efficacy.test.ts +377 -0
  141. package/.claude/settings.local.json +0 -11
  142. package/dist/learning/llm-extractor.d.ts +0 -88
  143. package/dist/learning/llm-extractor.d.ts.map +0 -1
  144. package/dist/learning/llm-extractor.js +0 -372
  145. package/dist/learning/llm-extractor.js.map +0 -1
  146. package/dist/learning/loop-coordinator.d.ts +0 -61
  147. package/dist/learning/loop-coordinator.d.ts.map +0 -1
  148. package/dist/learning/loop-coordinator.js +0 -96
  149. package/dist/learning/loop-coordinator.js.map +0 -1
  150. package/references/agent-workspace/CLAUDE.md +0 -74
  151. package/references/agent-workspace/README.md +0 -587
  152. package/references/agent-workspace/media/banner.png +0 -0
  153. package/references/agent-workspace/package-lock.json +0 -2061
  154. package/references/agent-workspace/package.json +0 -54
  155. package/references/agent-workspace/src/handle.ts +0 -122
  156. package/references/agent-workspace/src/index.ts +0 -32
  157. package/references/agent-workspace/src/manager.ts +0 -102
  158. package/references/agent-workspace/src/readers/json.ts +0 -71
  159. package/references/agent-workspace/src/readers/markdown.ts +0 -37
  160. package/references/agent-workspace/src/readers/raw.ts +0 -27
  161. package/references/agent-workspace/src/types.ts +0 -68
  162. package/references/agent-workspace/src/validation.ts +0 -93
  163. package/references/agent-workspace/src/writers/json.ts +0 -17
  164. package/references/agent-workspace/src/writers/markdown.ts +0 -27
  165. package/references/agent-workspace/src/writers/raw.ts +0 -22
  166. package/references/agent-workspace/tests/errors.test.ts +0 -652
  167. package/references/agent-workspace/tests/handle.test.ts +0 -144
  168. package/references/agent-workspace/tests/manager.test.ts +0 -124
  169. package/references/agent-workspace/tests/readers.test.ts +0 -205
  170. package/references/agent-workspace/tests/validation.test.ts +0 -196
  171. package/references/agent-workspace/tests/writers.test.ts +0 -108
  172. package/references/agent-workspace/tsconfig.json +0 -20
  173. package/references/agent-workspace/tsup.config.ts +0 -9
  174. package/references/minimem/.claude/settings.json +0 -7
  175. package/references/minimem/.sudocode/issues.jsonl +0 -18
  176. package/references/minimem/.sudocode/specs.jsonl +0 -1
  177. package/references/minimem/CLAUDE.md +0 -310
  178. package/references/minimem/README.md +0 -556
  179. package/references/minimem/claude-plugin/.claude-plugin/plugin.json +0 -10
  180. package/references/minimem/claude-plugin/.mcp.json +0 -7
  181. package/references/minimem/claude-plugin/README.md +0 -158
  182. package/references/minimem/claude-plugin/commands/recall.md +0 -47
  183. package/references/minimem/claude-plugin/commands/remember.md +0 -41
  184. package/references/minimem/claude-plugin/hooks/__tests__/hooks.test.ts +0 -272
  185. package/references/minimem/claude-plugin/hooks/hooks.json +0 -27
  186. package/references/minimem/claude-plugin/hooks/session-end.sh +0 -86
  187. package/references/minimem/claude-plugin/hooks/session-start.sh +0 -85
  188. package/references/minimem/claude-plugin/skills/memory/SKILL.md +0 -108
  189. package/references/minimem/package-lock.json +0 -5373
  190. package/references/minimem/package.json +0 -60
  191. package/references/minimem/scripts/postbuild.js +0 -35
  192. package/references/minimem/src/__tests__/edge-cases.test.ts +0 -371
  193. package/references/minimem/src/__tests__/errors.test.ts +0 -265
  194. package/references/minimem/src/__tests__/helpers.ts +0 -199
  195. package/references/minimem/src/__tests__/internal.test.ts +0 -407
  196. package/references/minimem/src/__tests__/knowledge.test.ts +0 -287
  197. package/references/minimem/src/__tests__/minimem.integration.test.ts +0 -1127
  198. package/references/minimem/src/__tests__/session.test.ts +0 -190
  199. package/references/minimem/src/cli/__tests__/commands.test.ts +0 -759
  200. package/references/minimem/src/cli/commands/__tests__/conflicts.test.ts +0 -141
  201. package/references/minimem/src/cli/commands/append.ts +0 -76
  202. package/references/minimem/src/cli/commands/config.ts +0 -262
  203. package/references/minimem/src/cli/commands/conflicts.ts +0 -413
  204. package/references/minimem/src/cli/commands/daemon.ts +0 -169
  205. package/references/minimem/src/cli/commands/index.ts +0 -12
  206. package/references/minimem/src/cli/commands/init.ts +0 -88
  207. package/references/minimem/src/cli/commands/mcp.ts +0 -177
  208. package/references/minimem/src/cli/commands/push-pull.ts +0 -213
  209. package/references/minimem/src/cli/commands/search.ts +0 -158
  210. package/references/minimem/src/cli/commands/status.ts +0 -84
  211. package/references/minimem/src/cli/commands/sync-init.ts +0 -290
  212. package/references/minimem/src/cli/commands/sync.ts +0 -70
  213. package/references/minimem/src/cli/commands/upsert.ts +0 -197
  214. package/references/minimem/src/cli/config.ts +0 -584
  215. package/references/minimem/src/cli/index.ts +0 -264
  216. package/references/minimem/src/cli/shared.ts +0 -161
  217. package/references/minimem/src/cli/sync/__tests__/central.test.ts +0 -152
  218. package/references/minimem/src/cli/sync/__tests__/conflicts.test.ts +0 -209
  219. package/references/minimem/src/cli/sync/__tests__/daemon.test.ts +0 -118
  220. package/references/minimem/src/cli/sync/__tests__/detection.test.ts +0 -207
  221. package/references/minimem/src/cli/sync/__tests__/integration.test.ts +0 -476
  222. package/references/minimem/src/cli/sync/__tests__/registry.test.ts +0 -363
  223. package/references/minimem/src/cli/sync/__tests__/state.test.ts +0 -255
  224. package/references/minimem/src/cli/sync/__tests__/validation.test.ts +0 -193
  225. package/references/minimem/src/cli/sync/__tests__/watcher.test.ts +0 -178
  226. package/references/minimem/src/cli/sync/central.ts +0 -292
  227. package/references/minimem/src/cli/sync/conflicts.ts +0 -204
  228. package/references/minimem/src/cli/sync/daemon.ts +0 -407
  229. package/references/minimem/src/cli/sync/detection.ts +0 -138
  230. package/references/minimem/src/cli/sync/index.ts +0 -107
  231. package/references/minimem/src/cli/sync/operations.ts +0 -373
  232. package/references/minimem/src/cli/sync/registry.ts +0 -279
  233. package/references/minimem/src/cli/sync/state.ts +0 -355
  234. package/references/minimem/src/cli/sync/validation.ts +0 -206
  235. package/references/minimem/src/cli/sync/watcher.ts +0 -234
  236. package/references/minimem/src/cli/version.ts +0 -34
  237. package/references/minimem/src/core/index.ts +0 -9
  238. package/references/minimem/src/core/indexer.ts +0 -628
  239. package/references/minimem/src/core/searcher.ts +0 -221
  240. package/references/minimem/src/db/schema.ts +0 -183
  241. package/references/minimem/src/db/sqlite-vec.ts +0 -24
  242. package/references/minimem/src/embeddings/__tests__/embeddings.test.ts +0 -431
  243. package/references/minimem/src/embeddings/batch-gemini.ts +0 -392
  244. package/references/minimem/src/embeddings/batch-openai.ts +0 -409
  245. package/references/minimem/src/embeddings/embeddings.ts +0 -434
  246. package/references/minimem/src/index.ts +0 -109
  247. package/references/minimem/src/internal.ts +0 -299
  248. package/references/minimem/src/minimem.ts +0 -1276
  249. package/references/minimem/src/search/__tests__/hybrid.test.ts +0 -247
  250. package/references/minimem/src/search/graph.ts +0 -234
  251. package/references/minimem/src/search/hybrid.ts +0 -151
  252. package/references/minimem/src/search/search.ts +0 -256
  253. package/references/minimem/src/server/__tests__/mcp.test.ts +0 -341
  254. package/references/minimem/src/server/__tests__/tools.test.ts +0 -364
  255. package/references/minimem/src/server/mcp.ts +0 -326
  256. package/references/minimem/src/server/tools.ts +0 -720
  257. package/references/minimem/src/session.ts +0 -460
  258. package/references/minimem/tsconfig.json +0 -19
  259. package/references/minimem/tsup.config.ts +0 -26
  260. package/references/minimem/vitest.config.ts +0 -24
  261. package/references/sessionlog/.husky/pre-commit +0 -1
  262. package/references/sessionlog/.lintstagedrc.json +0 -4
  263. package/references/sessionlog/.prettierignore +0 -4
  264. package/references/sessionlog/.prettierrc.json +0 -11
  265. package/references/sessionlog/LICENSE +0 -21
  266. package/references/sessionlog/README.md +0 -453
  267. package/references/sessionlog/eslint.config.js +0 -58
  268. package/references/sessionlog/package-lock.json +0 -3672
  269. package/references/sessionlog/package.json +0 -65
  270. package/references/sessionlog/src/__tests__/agent-hooks.test.ts +0 -570
  271. package/references/sessionlog/src/__tests__/agent-registry.test.ts +0 -127
  272. package/references/sessionlog/src/__tests__/claude-code-hooks.test.ts +0 -225
  273. package/references/sessionlog/src/__tests__/claude-generator.test.ts +0 -46
  274. package/references/sessionlog/src/__tests__/commit-msg.test.ts +0 -86
  275. package/references/sessionlog/src/__tests__/cursor-agent.test.ts +0 -224
  276. package/references/sessionlog/src/__tests__/e2e-live.test.ts +0 -890
  277. package/references/sessionlog/src/__tests__/event-log.test.ts +0 -183
  278. package/references/sessionlog/src/__tests__/flush-sentinel.test.ts +0 -105
  279. package/references/sessionlog/src/__tests__/gemini-agent.test.ts +0 -375
  280. package/references/sessionlog/src/__tests__/git-hooks.test.ts +0 -78
  281. package/references/sessionlog/src/__tests__/hook-managers.test.ts +0 -121
  282. package/references/sessionlog/src/__tests__/lifecycle-tasks.test.ts +0 -759
  283. package/references/sessionlog/src/__tests__/opencode-agent.test.ts +0 -338
  284. package/references/sessionlog/src/__tests__/redaction.test.ts +0 -136
  285. package/references/sessionlog/src/__tests__/session-repo.test.ts +0 -353
  286. package/references/sessionlog/src/__tests__/session-store.test.ts +0 -166
  287. package/references/sessionlog/src/__tests__/setup-ccweb.test.ts +0 -466
  288. package/references/sessionlog/src/__tests__/skill-live.test.ts +0 -461
  289. package/references/sessionlog/src/__tests__/summarize.test.ts +0 -348
  290. package/references/sessionlog/src/__tests__/task-plan-e2e.test.ts +0 -610
  291. package/references/sessionlog/src/__tests__/task-plan-live.test.ts +0 -632
  292. package/references/sessionlog/src/__tests__/transcript-timestamp.test.ts +0 -121
  293. package/references/sessionlog/src/__tests__/types.test.ts +0 -166
  294. package/references/sessionlog/src/__tests__/utils.test.ts +0 -333
  295. package/references/sessionlog/src/__tests__/validation.test.ts +0 -103
  296. package/references/sessionlog/src/__tests__/worktree.test.ts +0 -57
  297. package/references/sessionlog/src/agent/agents/claude-code.ts +0 -1089
  298. package/references/sessionlog/src/agent/agents/cursor.ts +0 -361
  299. package/references/sessionlog/src/agent/agents/gemini-cli.ts +0 -632
  300. package/references/sessionlog/src/agent/agents/opencode.ts +0 -540
  301. package/references/sessionlog/src/agent/registry.ts +0 -143
  302. package/references/sessionlog/src/agent/session-types.ts +0 -113
  303. package/references/sessionlog/src/agent/types.ts +0 -220
  304. package/references/sessionlog/src/cli.ts +0 -597
  305. package/references/sessionlog/src/commands/clean.ts +0 -133
  306. package/references/sessionlog/src/commands/disable.ts +0 -84
  307. package/references/sessionlog/src/commands/doctor.ts +0 -145
  308. package/references/sessionlog/src/commands/enable.ts +0 -202
  309. package/references/sessionlog/src/commands/explain.ts +0 -261
  310. package/references/sessionlog/src/commands/reset.ts +0 -105
  311. package/references/sessionlog/src/commands/resume.ts +0 -180
  312. package/references/sessionlog/src/commands/rewind.ts +0 -195
  313. package/references/sessionlog/src/commands/setup-ccweb.ts +0 -275
  314. package/references/sessionlog/src/commands/status.ts +0 -172
  315. package/references/sessionlog/src/config.ts +0 -165
  316. package/references/sessionlog/src/events/event-log.ts +0 -126
  317. package/references/sessionlog/src/git-operations.ts +0 -558
  318. package/references/sessionlog/src/hooks/git-hooks.ts +0 -165
  319. package/references/sessionlog/src/hooks/lifecycle.ts +0 -391
  320. package/references/sessionlog/src/index.ts +0 -650
  321. package/references/sessionlog/src/security/redaction.ts +0 -283
  322. package/references/sessionlog/src/session/state-machine.ts +0 -452
  323. package/references/sessionlog/src/store/checkpoint-store.ts +0 -509
  324. package/references/sessionlog/src/store/native-store.ts +0 -173
  325. package/references/sessionlog/src/store/provider-types.ts +0 -99
  326. package/references/sessionlog/src/store/session-store.ts +0 -266
  327. package/references/sessionlog/src/strategy/attribution.ts +0 -296
  328. package/references/sessionlog/src/strategy/common.ts +0 -207
  329. package/references/sessionlog/src/strategy/content-overlap.ts +0 -228
  330. package/references/sessionlog/src/strategy/manual-commit.ts +0 -988
  331. package/references/sessionlog/src/strategy/types.ts +0 -279
  332. package/references/sessionlog/src/summarize/claude-generator.ts +0 -115
  333. package/references/sessionlog/src/summarize/summarize.ts +0 -432
  334. package/references/sessionlog/src/types.ts +0 -508
  335. package/references/sessionlog/src/utils/chunk-files.ts +0 -49
  336. package/references/sessionlog/src/utils/commit-message.ts +0 -65
  337. package/references/sessionlog/src/utils/detect-agent.ts +0 -36
  338. package/references/sessionlog/src/utils/hook-managers.ts +0 -125
  339. package/references/sessionlog/src/utils/ide-tags.ts +0 -32
  340. package/references/sessionlog/src/utils/paths.ts +0 -79
  341. package/references/sessionlog/src/utils/preview-rewind.ts +0 -80
  342. package/references/sessionlog/src/utils/rewind-conflict.ts +0 -121
  343. package/references/sessionlog/src/utils/shadow-branch.ts +0 -109
  344. package/references/sessionlog/src/utils/string-utils.ts +0 -46
  345. package/references/sessionlog/src/utils/todo-extract.ts +0 -188
  346. package/references/sessionlog/src/utils/trailers.ts +0 -187
  347. package/references/sessionlog/src/utils/transcript-parse.ts +0 -177
  348. package/references/sessionlog/src/utils/transcript-timestamp.ts +0 -59
  349. package/references/sessionlog/src/utils/tree-ops.ts +0 -219
  350. package/references/sessionlog/src/utils/tty.ts +0 -72
  351. package/references/sessionlog/src/utils/validation.ts +0 -65
  352. package/references/sessionlog/src/utils/worktree.ts +0 -58
  353. package/references/sessionlog/src/wire-types.ts +0 -59
  354. package/references/sessionlog/templates/setup-env.sh +0 -153
  355. package/references/sessionlog/tsconfig.json +0 -18
  356. package/references/sessionlog/vitest.config.ts +0 -12
  357. package/references/skill-tree/.claude/settings.json +0 -6
  358. package/references/skill-tree/.sudocode/issues.jsonl +0 -19
  359. package/references/skill-tree/.sudocode/specs.jsonl +0 -3
  360. package/references/skill-tree/CLAUDE.md +0 -126
  361. package/references/skill-tree/README.md +0 -372
  362. package/references/skill-tree/docs/GAPS_v1.md +0 -221
  363. package/references/skill-tree/docs/INTEGRATION_PLAN.md +0 -467
  364. package/references/skill-tree/docs/TODOS.md +0 -91
  365. package/references/skill-tree/docs/anthropic_skill_guide.md +0 -1364
  366. package/references/skill-tree/docs/design/federated-skill-trees.md +0 -524
  367. package/references/skill-tree/docs/design/multi-agent-sync.md +0 -759
  368. package/references/skill-tree/docs/scraper/BRAINSTORM.md +0 -583
  369. package/references/skill-tree/docs/scraper/POC_PLAN.md +0 -420
  370. package/references/skill-tree/docs/scraper/README.md +0 -170
  371. package/references/skill-tree/examples/basic-usage.ts +0 -164
  372. package/references/skill-tree/package-lock.json +0 -1852
  373. package/references/skill-tree/package.json +0 -66
  374. package/references/skill-tree/scraper/README.md +0 -123
  375. package/references/skill-tree/scraper/docs/DESIGN.md +0 -683
  376. package/references/skill-tree/scraper/docs/PLAN.md +0 -336
  377. package/references/skill-tree/scraper/drizzle.config.ts +0 -10
  378. package/references/skill-tree/scraper/package-lock.json +0 -6329
  379. package/references/skill-tree/scraper/package.json +0 -68
  380. package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-description.md +0 -7
  381. package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-name.md +0 -7
  382. package/references/skill-tree/scraper/test/fixtures/minimal-skill/SKILL.md +0 -27
  383. package/references/skill-tree/scraper/test/fixtures/skill-json/SKILL.json +0 -21
  384. package/references/skill-tree/scraper/test/fixtures/skill-with-meta/SKILL.md +0 -54
  385. package/references/skill-tree/scraper/test/fixtures/skill-with-meta/_meta.json +0 -24
  386. package/references/skill-tree/scraper/test/fixtures/valid-skill/SKILL.md +0 -93
  387. package/references/skill-tree/scraper/test/fixtures/valid-skill/_meta.json +0 -22
  388. package/references/skill-tree/scraper/tsup.config.ts +0 -14
  389. package/references/skill-tree/scraper/vitest.config.ts +0 -17
  390. package/references/skill-tree/scripts/convert-to-vitest.ts +0 -166
  391. package/references/skill-tree/skills/skill-writer/SKILL.md +0 -339
  392. package/references/skill-tree/skills/skill-writer/references/examples.md +0 -326
  393. package/references/skill-tree/skills/skill-writer/references/patterns.md +0 -210
  394. package/references/skill-tree/skills/skill-writer/references/quality-checklist.md +0 -123
  395. package/references/skill-tree/test/run-all.ts +0 -106
  396. package/references/skill-tree/test/utils.ts +0 -128
  397. package/references/skill-tree/vitest.config.ts +0 -16
@@ -1,759 +0,0 @@
1
- /**
2
- * Tests for CLI commands
3
- *
4
- * These tests exercise the CLI command functions directly.
5
- * Uses mock fetch for deterministic embeddings.
6
- *
7
- * Run with: npm run test:cli
8
- */
9
-
10
- import fs from "node:fs/promises";
11
- import os from "node:os";
12
- import path from "node:path";
13
- import { after, afterEach, before, beforeEach, describe, it } from "node:test";
14
- import assert from "node:assert";
15
-
16
- import { init } from "../commands/init.js";
17
- import { search } from "../commands/search.js";
18
- import { sync } from "../commands/sync.js";
19
- import { status } from "../commands/status.js";
20
- import { append } from "../commands/append.js";
21
- import { upsert } from "../commands/upsert.js";
22
- import { config } from "../commands/config.js";
23
- import { ensureGlobalInitialized } from "../commands/mcp.js";
24
- import {
25
- isInitialized,
26
- expandPath,
27
- getXdgConfigPath,
28
- loadXdgConfig,
29
- saveXdgConfig,
30
- getMachineId,
31
- getSyncConfig,
32
- getDefaultSyncConfig,
33
- getDefaultGlobalSyncConfig,
34
- resolveMemoryDirs,
35
- getDirName,
36
- type GlobalConfig,
37
- } from "../config.js";
38
- import { createMockFetch, captureConsole } from "../../__tests__/helpers.js";
39
-
40
- describe("CLI Commands", () => {
41
- let tempDir: string;
42
- let originalFetch: typeof fetch;
43
- let mockFetch: ReturnType<typeof createMockFetch>;
44
- let originalExit: typeof process.exit;
45
- let exitCode: number | undefined;
46
-
47
- before(() => {
48
- // Mock fetch globally
49
- originalFetch = globalThis.fetch;
50
- mockFetch = createMockFetch();
51
- globalThis.fetch = mockFetch as unknown as typeof fetch;
52
-
53
- // Set API key for tests
54
- process.env.OPENAI_API_KEY = "test-key";
55
-
56
- // Mock process.exit to prevent test from exiting
57
- originalExit = process.exit;
58
- process.exit = ((code?: number) => {
59
- exitCode = code;
60
- throw new Error(`process.exit(${code})`);
61
- }) as typeof process.exit;
62
- });
63
-
64
- after(() => {
65
- globalThis.fetch = originalFetch;
66
- delete process.env.OPENAI_API_KEY;
67
- process.exit = originalExit;
68
- });
69
-
70
- beforeEach(async () => {
71
- // Create fresh temp directory for each test
72
- tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "minimem-cli-test-"));
73
- exitCode = undefined;
74
- });
75
-
76
- afterEach(async () => {
77
- // Clean up temp directory
78
- await fs.rm(tempDir, { recursive: true, force: true });
79
- });
80
-
81
- describe("init command", () => {
82
- it("should initialize a new memory directory", async () => {
83
- const capture = captureConsole();
84
-
85
- try {
86
- await init(tempDir, { global: false, force: false });
87
- } finally {
88
- capture.restore();
89
- }
90
-
91
- // Check files were created
92
- const memoryMd = await fs.readFile(path.join(tempDir, "MEMORY.md"), "utf-8");
93
- assert.ok(memoryMd.includes("# Memory"), "MEMORY.md should have header");
94
-
95
- const configPath = path.join(tempDir, ".minimem", "config.json");
96
- const config = JSON.parse(await fs.readFile(configPath, "utf-8"));
97
- assert.strictEqual(config.embedding.provider, "auto");
98
-
99
- const memoryDir = await fs.stat(path.join(tempDir, "memory"));
100
- assert.ok(memoryDir.isDirectory(), "memory/ directory should exist");
101
-
102
- // Check output
103
- assert.ok(capture.logs.some(l => l.includes("Initializing")));
104
- assert.ok(capture.logs.some(l => l.includes("Done!")));
105
- });
106
-
107
- it("should not reinitialize without --force", async () => {
108
- // Initialize first
109
- await init(tempDir, { global: false, force: false });
110
-
111
- const capture = captureConsole();
112
- try {
113
- await init(tempDir, { global: false, force: false });
114
- } finally {
115
- capture.restore();
116
- }
117
-
118
- // Should indicate already initialized (logs to stdout, not stderr)
119
- assert.ok(capture.logs.some(l => l.includes("Already initialized")));
120
- });
121
-
122
- it("should reinitialize with --force", async () => {
123
- // Initialize first
124
- await init(tempDir, { global: false, force: false });
125
-
126
- // Modify MEMORY.md
127
- await fs.writeFile(path.join(tempDir, "MEMORY.md"), "Custom content");
128
-
129
- const capture = captureConsole();
130
- try {
131
- await init(tempDir, { global: false, force: true });
132
- } finally {
133
- capture.restore();
134
- }
135
-
136
- // Check MEMORY.md was NOT overwritten (force only resets config)
137
- const memoryMd = await fs.readFile(path.join(tempDir, "MEMORY.md"), "utf-8");
138
- assert.strictEqual(memoryMd, "Custom content");
139
-
140
- assert.ok(capture.logs.some(l => l.includes("Done!")));
141
- });
142
- });
143
-
144
- describe("upsert command", () => {
145
- beforeEach(async () => {
146
- // Initialize memory directory
147
- await init(tempDir, { global: false, force: false });
148
- });
149
-
150
- it("should create a new file", async () => {
151
- const capture = captureConsole();
152
-
153
- try {
154
- await upsert("test-note.md", "# Test Note\n\nThis is a test.", { dir: tempDir });
155
- } finally {
156
- capture.restore();
157
- }
158
-
159
- const content = await fs.readFile(path.join(tempDir, "test-note.md"), "utf-8");
160
- assert.strictEqual(content, "# Test Note\n\nThis is a test.");
161
- assert.ok(capture.logs.some(l => l.includes("Created")));
162
- });
163
-
164
- it("should update an existing file", async () => {
165
- // Create file first
166
- await fs.writeFile(path.join(tempDir, "existing.md"), "Old content");
167
-
168
- const capture = captureConsole();
169
-
170
- try {
171
- await upsert("existing.md", "New content", { dir: tempDir });
172
- } finally {
173
- capture.restore();
174
- }
175
-
176
- const content = await fs.readFile(path.join(tempDir, "existing.md"), "utf-8");
177
- assert.strictEqual(content, "New content");
178
- assert.ok(capture.logs.some(l => l.includes("Updated")));
179
- });
180
-
181
- it("should create file in memory/ subdirectory", async () => {
182
- const capture = captureConsole();
183
-
184
- try {
185
- await upsert("memory/notes.md", "# Notes", { dir: tempDir });
186
- } finally {
187
- capture.restore();
188
- }
189
-
190
- const content = await fs.readFile(path.join(tempDir, "memory", "notes.md"), "utf-8");
191
- assert.strictEqual(content, "# Notes");
192
- });
193
-
194
- it("should reject paths outside memory directory", async () => {
195
- const capture = captureConsole();
196
-
197
- try {
198
- await upsert("/tmp/outside.md", "Bad content", { dir: tempDir });
199
- assert.fail("Should have exited");
200
- } catch (e) {
201
- // Expected
202
- } finally {
203
- capture.restore();
204
- }
205
-
206
- assert.ok(capture.errors.some(l => l.includes("must be within")));
207
- });
208
- });
209
-
210
- describe("append command", () => {
211
- beforeEach(async () => {
212
- await init(tempDir, { global: false, force: false });
213
- });
214
-
215
- it("should append to today's daily log", async () => {
216
- const capture = captureConsole();
217
-
218
- try {
219
- await append("Test entry 1", { dir: tempDir });
220
- await append("Test entry 2", { dir: tempDir });
221
- } finally {
222
- capture.restore();
223
- }
224
-
225
- // Check today's log file
226
- const today = new Date().toISOString().split("T")[0];
227
- const logPath = path.join(tempDir, "memory", `${today}.md`);
228
- const content = await fs.readFile(logPath, "utf-8");
229
-
230
- assert.ok(content.includes("Test entry 1"));
231
- assert.ok(content.includes("Test entry 2"));
232
- });
233
-
234
- it("should append to specific file with --file", async () => {
235
- const capture = captureConsole();
236
-
237
- try {
238
- // Must use valid memory path (memory/*.md)
239
- await append("Custom entry", { dir: tempDir, file: "memory/custom-log.md" });
240
- } finally {
241
- capture.restore();
242
- }
243
-
244
- const content = await fs.readFile(path.join(tempDir, "memory", "custom-log.md"), "utf-8");
245
- assert.ok(content.includes("Custom entry"));
246
- });
247
- });
248
-
249
- describe("sync command", () => {
250
- beforeEach(async () => {
251
- await init(tempDir, { global: false, force: false });
252
-
253
- // Add some content to index
254
- await fs.writeFile(
255
- path.join(tempDir, "MEMORY.md"),
256
- "# Memory\n\nImportant project decisions here."
257
- );
258
- await fs.writeFile(
259
- path.join(tempDir, "memory", "notes.md"),
260
- "# Notes\n\nMeeting notes about the API design."
261
- );
262
- });
263
-
264
- it("should sync memory files", async () => {
265
- const capture = captureConsole();
266
-
267
- try {
268
- await sync({ dir: tempDir, force: false });
269
- } finally {
270
- capture.restore();
271
- }
272
-
273
- assert.ok(capture.logs.some(l => l.includes("Syncing")));
274
- assert.ok(capture.logs.some(l => l.includes("Files:") || l.includes("Chunks:")));
275
- });
276
-
277
- it("should force full re-index with --force", async () => {
278
- // First sync
279
- await sync({ dir: tempDir, force: false });
280
-
281
- const capture = captureConsole();
282
-
283
- try {
284
- await sync({ dir: tempDir, force: true });
285
- } finally {
286
- capture.restore();
287
- }
288
-
289
- // Force sync should complete and show results
290
- assert.ok(capture.logs.some(l => l.includes("Sync complete")));
291
- assert.ok(capture.logs.some(l => l.includes("Files:")));
292
- });
293
- });
294
-
295
- describe("status command", () => {
296
- beforeEach(async () => {
297
- await init(tempDir, { global: false, force: false });
298
- await fs.writeFile(
299
- path.join(tempDir, "MEMORY.md"),
300
- "# Memory\n\nTest content."
301
- );
302
- });
303
-
304
- it("should show index status", async () => {
305
- const capture = captureConsole();
306
-
307
- try {
308
- await status({ dir: tempDir });
309
- } finally {
310
- capture.restore();
311
- }
312
-
313
- assert.ok(capture.logs.some(l => l.includes("Provider") || l.includes("provider")));
314
- assert.ok(capture.logs.some(l => l.includes("Files") || l.includes("files")));
315
- });
316
-
317
- it("should output JSON with --json flag", async () => {
318
- const capture = captureConsole();
319
-
320
- try {
321
- await status({ dir: tempDir, json: true });
322
- } finally {
323
- capture.restore();
324
- }
325
-
326
- // Should have valid JSON output
327
- const jsonOutput = capture.logs.find(l => l.startsWith("{"));
328
- assert.ok(jsonOutput, "Should have JSON output");
329
-
330
- const parsed = JSON.parse(jsonOutput);
331
- assert.ok("provider" in parsed || "files" in parsed || "chunks" in parsed);
332
- });
333
- });
334
-
335
- describe("search command", () => {
336
- beforeEach(async () => {
337
- await init(tempDir, { global: false, force: false });
338
-
339
- // Create searchable content
340
- await fs.writeFile(
341
- path.join(tempDir, "MEMORY.md"),
342
- `# Memory
343
-
344
- ## Project Decisions
345
- We decided to use PostgreSQL for the database.
346
- The API will use REST endpoints.
347
-
348
- ## Meeting Notes
349
- Important meeting about project planning.
350
- `
351
- );
352
-
353
- await fs.writeFile(
354
- path.join(tempDir, "memory", "bugs.md"),
355
- `# Bug Tracker
356
-
357
- ## Bug #1: Login Error
358
- Users report login errors when password contains special characters.
359
- This is an urgent bug fix needed.
360
- `
361
- );
362
-
363
- // Sync to index the content
364
- await sync({ dir: tempDir, force: false });
365
- });
366
-
367
- it("should search memory files", async () => {
368
- const capture = captureConsole();
369
-
370
- try {
371
- await search("database decision", { dir: [tempDir] });
372
- } finally {
373
- capture.restore();
374
- }
375
-
376
- // Should find results
377
- assert.ok(
378
- capture.logs.some(l => l.includes("result") || l.includes("%")),
379
- "Should show search results"
380
- );
381
- });
382
-
383
- it("should output JSON with --json flag", async () => {
384
- const capture = captureConsole();
385
-
386
- try {
387
- await search("project", { dir: [tempDir], json: true });
388
- } finally {
389
- capture.restore();
390
- }
391
-
392
- const jsonOutput = capture.logs.find(l => l.startsWith("["));
393
- assert.ok(jsonOutput, "Should have JSON array output");
394
-
395
- const results = JSON.parse(jsonOutput);
396
- assert.ok(Array.isArray(results));
397
- });
398
-
399
- it("should respect --max option", async () => {
400
- const capture = captureConsole();
401
-
402
- try {
403
- await search("project", { dir: [tempDir], max: "1" });
404
- } finally {
405
- capture.restore();
406
- }
407
-
408
- // Count result entries (lines with percentage scores)
409
- const resultLines = capture.logs.filter(l => l.match(/\[\d+\.\d+%\]/));
410
- assert.ok(resultLines.length <= 1, "Should have at most 1 result");
411
- });
412
-
413
- it("should search multiple directories", async () => {
414
- // Create second memory directory
415
- const tempDir2 = await fs.mkdtemp(path.join(os.tmpdir(), "minimem-cli-test2-"));
416
-
417
- try {
418
- await init(tempDir2, { global: false, force: false });
419
- await fs.writeFile(
420
- path.join(tempDir2, "MEMORY.md"),
421
- "# Second Memory\n\nDifferent project notes about testing."
422
- );
423
- await sync({ dir: tempDir2, force: false });
424
-
425
- const capture = captureConsole();
426
-
427
- try {
428
- await search("project", { dir: [tempDir, tempDir2] });
429
- } finally {
430
- capture.restore();
431
- }
432
-
433
- // Should mention searching multiple directories
434
- assert.ok(
435
- capture.logs.some(l => l.includes("directories") || l.includes("result")),
436
- "Should search across directories"
437
- );
438
- } finally {
439
- await fs.rm(tempDir2, { recursive: true, force: true });
440
- }
441
- });
442
-
443
- it("should warn about uninitialized directories", async () => {
444
- const capture = captureConsole();
445
- const nonExistent = path.join(tempDir, "nonexistent");
446
-
447
- try {
448
- await search("test", { dir: [tempDir, nonExistent] });
449
- } finally {
450
- capture.restore();
451
- }
452
-
453
- assert.ok(
454
- capture.errors.some(l => l.includes("not initialized") || l.includes("skipping")),
455
- "Should warn about uninitialized directory"
456
- );
457
- });
458
- });
459
-
460
- describe("mcp command helpers", () => {
461
- describe("resolveMemoryDirs", () => {
462
- it("should use current directory by default", () => {
463
- const dirs = resolveMemoryDirs({});
464
- assert.strictEqual(dirs.length, 1);
465
- assert.strictEqual(dirs[0], process.cwd());
466
- });
467
-
468
- it("should use specified directories", () => {
469
- const dirs = resolveMemoryDirs({ dir: ["/path/one", "/path/two"] });
470
- assert.strictEqual(dirs.length, 2);
471
- assert.ok(dirs[0].endsWith("one"));
472
- assert.ok(dirs[1].endsWith("two"));
473
- });
474
-
475
- it("should add global directory with --global flag", () => {
476
- const dirs = resolveMemoryDirs({ global: true });
477
- assert.strictEqual(dirs.length, 1);
478
- assert.ok(dirs[0].endsWith(".minimem"), "Should include global directory");
479
- });
480
-
481
- it("should combine --dir and --global", () => {
482
- const dirs = resolveMemoryDirs({ dir: ["/path/project"], global: true });
483
- assert.strictEqual(dirs.length, 2);
484
- assert.ok(dirs[0].endsWith("project"));
485
- assert.ok(dirs[1].endsWith(".minimem"));
486
- });
487
-
488
- it("should not duplicate global directory", () => {
489
- const globalPath = path.join(os.homedir(), ".minimem");
490
- const dirs = resolveMemoryDirs({ dir: [globalPath], global: true });
491
- assert.strictEqual(dirs.length, 1);
492
- assert.strictEqual(dirs[0], globalPath);
493
- });
494
- });
495
-
496
- describe("getDirName", () => {
497
- it("should return 'global' for ~/.minimem", () => {
498
- const globalDir = path.join(os.homedir(), ".minimem");
499
- assert.strictEqual(getDirName(globalDir), "global");
500
- });
501
-
502
- it("should return directory name for regular paths", () => {
503
- assert.strictEqual(getDirName("/path/to/my-project"), "my-project");
504
- });
505
-
506
- it("should include parent for hidden directories", () => {
507
- const name = getDirName("/path/to/project/.hidden");
508
- assert.ok(name.includes("project"));
509
- assert.ok(name.includes(".hidden"));
510
- });
511
- });
512
-
513
- describe("ensureGlobalInitialized", () => {
514
- it("should create global directory structure", async () => {
515
- const fakeGlobalDir = path.join(tempDir, ".fake-minimem");
516
-
517
- const capture = captureConsole();
518
- try {
519
- await ensureGlobalInitialized(fakeGlobalDir);
520
- } finally {
521
- capture.restore();
522
- }
523
-
524
- // Check directory was created
525
- assert.ok(await isInitialized(fakeGlobalDir), "Should be initialized");
526
-
527
- // Check MEMORY.md exists with global template
528
- const memoryMd = await fs.readFile(path.join(fakeGlobalDir, "MEMORY.md"), "utf-8");
529
- assert.ok(memoryMd.includes("Global Memory"), "Should have global template");
530
-
531
- // Check config exists
532
- const configPath = path.join(fakeGlobalDir, ".minimem", "config.json");
533
- const configData = JSON.parse(await fs.readFile(configPath, "utf-8"));
534
- assert.strictEqual(configData.embedding.provider, "auto");
535
-
536
- // Check .gitignore exists
537
- const gitignore = await fs.readFile(
538
- path.join(fakeGlobalDir, ".minimem", ".gitignore"),
539
- "utf-8"
540
- );
541
- assert.ok(gitignore.includes("index.db"));
542
-
543
- // Check output messages
544
- assert.ok(capture.errors.some(l => l.includes("Auto-initializing")));
545
- assert.ok(capture.errors.some(l => l.includes("Created")));
546
- });
547
-
548
- it("should not overwrite existing MEMORY.md", async () => {
549
- const fakeGlobalDir = path.join(tempDir, ".fake-minimem2");
550
-
551
- // Pre-create with custom content
552
- await fs.mkdir(fakeGlobalDir, { recursive: true });
553
- await fs.writeFile(path.join(fakeGlobalDir, "MEMORY.md"), "My custom content");
554
-
555
- const capture = captureConsole();
556
- try {
557
- await ensureGlobalInitialized(fakeGlobalDir);
558
- } finally {
559
- capture.restore();
560
- }
561
-
562
- // Check MEMORY.md was preserved
563
- const memoryMd = await fs.readFile(path.join(fakeGlobalDir, "MEMORY.md"), "utf-8");
564
- assert.strictEqual(memoryMd, "My custom content", "Should preserve existing MEMORY.md");
565
- });
566
- });
567
- });
568
-
569
- describe("config utilities", () => {
570
- describe("expandPath", () => {
571
- it("should expand ~ to home directory", () => {
572
- const expanded = expandPath("~/test/path");
573
- assert.strictEqual(expanded, path.join(os.homedir(), "test/path"));
574
- });
575
-
576
- it("should expand lone ~", () => {
577
- const expanded = expandPath("~");
578
- assert.strictEqual(expanded, os.homedir());
579
- });
580
-
581
- it("should not modify paths without ~", () => {
582
- const expanded = expandPath("/absolute/path");
583
- assert.strictEqual(expanded, "/absolute/path");
584
- });
585
-
586
- it("should not expand ~ in the middle of path", () => {
587
- const expanded = expandPath("/some/~path");
588
- assert.strictEqual(expanded, "/some/~path");
589
- });
590
- });
591
-
592
- describe("getDefaultSyncConfig", () => {
593
- it("should return default sync configuration", () => {
594
- const defaults = getDefaultSyncConfig();
595
- assert.strictEqual(defaults.enabled, false);
596
- assert.deepStrictEqual(defaults.include, ["MEMORY.md", "memory/**/*.md"]);
597
- assert.deepStrictEqual(defaults.exclude, []);
598
- });
599
- });
600
-
601
- describe("getDefaultGlobalSyncConfig", () => {
602
- it("should return default global sync configuration", () => {
603
- const defaults = getDefaultGlobalSyncConfig();
604
- assert.strictEqual(defaults.conflictStrategy, "keep-both");
605
- assert.strictEqual(defaults.autoSync, false);
606
- assert.strictEqual(defaults.autoCommit, false);
607
- });
608
- });
609
- });
610
-
611
- describe("hooks config", () => {
612
- beforeEach(async () => {
613
- await init(tempDir, { global: false, force: false });
614
- });
615
-
616
- it("should set hooks.sessionStart via config command", async () => {
617
- const capture = captureConsole();
618
-
619
- try {
620
- await config({ dir: tempDir, set: "hooks.sessionStart=true" });
621
- } finally {
622
- capture.restore();
623
- }
624
-
625
- const configPath = path.join(tempDir, ".minimem", "config.json");
626
- const savedConfig = JSON.parse(await fs.readFile(configPath, "utf-8"));
627
- assert.strictEqual(savedConfig.hooks?.sessionStart, true);
628
- });
629
-
630
- it("should set hooks.sessionEnd via config command", async () => {
631
- const capture = captureConsole();
632
-
633
- try {
634
- await config({ dir: tempDir, set: "hooks.sessionEnd=true" });
635
- } finally {
636
- capture.restore();
637
- }
638
-
639
- const configPath = path.join(tempDir, ".minimem", "config.json");
640
- const savedConfig = JSON.parse(await fs.readFile(configPath, "utf-8"));
641
- assert.strictEqual(savedConfig.hooks?.sessionEnd, true);
642
- });
643
-
644
- it("should disable hooks via config command", async () => {
645
- // First enable
646
- await config({ dir: tempDir, set: "hooks.sessionStart=true" });
647
-
648
- const capture = captureConsole();
649
-
650
- try {
651
- await config({ dir: tempDir, set: "hooks.sessionStart=false" });
652
- } finally {
653
- capture.restore();
654
- }
655
-
656
- const configPath = path.join(tempDir, ".minimem", "config.json");
657
- const savedConfig = JSON.parse(await fs.readFile(configPath, "utf-8"));
658
- assert.strictEqual(savedConfig.hooks?.sessionStart, false);
659
- });
660
-
661
- it("should set both hooks independently", async () => {
662
- const capture = captureConsole();
663
-
664
- try {
665
- await config({ dir: tempDir, set: "hooks.sessionStart=true" });
666
- await config({ dir: tempDir, set: "hooks.sessionEnd=false" });
667
- } finally {
668
- capture.restore();
669
- }
670
-
671
- const configPath = path.join(tempDir, ".minimem", "config.json");
672
- const savedConfig = JSON.parse(await fs.readFile(configPath, "utf-8"));
673
- assert.strictEqual(savedConfig.hooks?.sessionStart, true);
674
- assert.strictEqual(savedConfig.hooks?.sessionEnd, false);
675
- });
676
- });
677
-
678
- describe("sync config", () => {
679
- beforeEach(async () => {
680
- await init(tempDir, { global: false, force: false });
681
- });
682
-
683
- it("should set sync.enabled via config command", async () => {
684
- const capture = captureConsole();
685
-
686
- try {
687
- await config({ dir: tempDir, set: "sync.enabled=true" });
688
- } finally {
689
- capture.restore();
690
- }
691
-
692
- // Verify the config was set
693
- const configPath = path.join(tempDir, ".minimem", "config.json");
694
- const savedConfig = JSON.parse(await fs.readFile(configPath, "utf-8"));
695
- assert.strictEqual(savedConfig.sync?.enabled, true);
696
- });
697
-
698
- it("should set sync.path via config command", async () => {
699
- const capture = captureConsole();
700
-
701
- try {
702
- await config({ dir: tempDir, set: "sync.path=myproject/" });
703
- } finally {
704
- capture.restore();
705
- }
706
-
707
- const configPath = path.join(tempDir, ".minimem", "config.json");
708
- const savedConfig = JSON.parse(await fs.readFile(configPath, "utf-8"));
709
- assert.strictEqual(savedConfig.sync?.path, "myproject/");
710
- });
711
-
712
- it("should get sync config with defaults", async () => {
713
- const syncConfig = await getSyncConfig(tempDir);
714
-
715
- // Should have defaults applied
716
- assert.strictEqual(syncConfig.enabled, false);
717
- assert.deepStrictEqual(syncConfig.include, ["MEMORY.md", "memory/**/*.md"]);
718
- assert.strictEqual(syncConfig.conflictStrategy, "keep-both");
719
- assert.strictEqual(syncConfig.autoSync, false);
720
- });
721
-
722
- it("should merge local sync config with defaults", async () => {
723
- // Set some local config
724
- const configPath = path.join(tempDir, ".minimem", "config.json");
725
- const localConfig = {
726
- embedding: { provider: "auto" },
727
- sync: {
728
- enabled: true,
729
- path: "test-project/",
730
- include: ["MEMORY.md", "custom/**/*.md"],
731
- },
732
- };
733
- await fs.writeFile(configPath, JSON.stringify(localConfig, null, 2));
734
-
735
- const syncConfig = await getSyncConfig(tempDir);
736
-
737
- assert.strictEqual(syncConfig.enabled, true);
738
- assert.strictEqual(syncConfig.path, "test-project/");
739
- assert.deepStrictEqual(syncConfig.include, ["MEMORY.md", "custom/**/*.md"]);
740
- // Defaults still applied for unset values
741
- assert.strictEqual(syncConfig.conflictStrategy, "keep-both");
742
- });
743
-
744
- it("should display sync config in config command output", async () => {
745
- const capture = captureConsole();
746
-
747
- try {
748
- await config({ dir: tempDir });
749
- } finally {
750
- capture.restore();
751
- }
752
-
753
- // Should show sync sections
754
- assert.ok(capture.logs.some(l => l.includes("Sync (Local)")));
755
- assert.ok(capture.logs.some(l => l.includes("Sync (Global)")));
756
- assert.ok(capture.logs.some(l => l.includes("conflictStrategy")));
757
- });
758
- });
759
- });