cognitive-core 0.2.1 → 0.2.3

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 (332) hide show
  1. package/dist/atlas.d.ts +10 -0
  2. package/dist/atlas.d.ts.map +1 -1
  3. package/dist/atlas.js +65 -0
  4. package/dist/atlas.js.map +1 -1
  5. package/dist/bin/cognitive-core.js +0 -0
  6. package/dist/memory/curated-loader.d.ts +21 -4
  7. package/dist/memory/curated-loader.d.ts.map +1 -1
  8. package/dist/memory/curated-loader.js +53 -16
  9. package/dist/memory/curated-loader.js.map +1 -1
  10. package/dist/memory/index.d.ts +2 -1
  11. package/dist/memory/index.d.ts.map +1 -1
  12. package/dist/memory/index.js +3 -1
  13. package/dist/memory/index.js.map +1 -1
  14. package/dist/memory/playbook.d.ts +6 -0
  15. package/dist/memory/playbook.d.ts.map +1 -1
  16. package/dist/memory/playbook.js +15 -0
  17. package/dist/memory/playbook.js.map +1 -1
  18. package/dist/memory/source-resolver.d.ts +120 -0
  19. package/dist/memory/source-resolver.d.ts.map +1 -0
  20. package/dist/memory/source-resolver.js +300 -0
  21. package/dist/memory/source-resolver.js.map +1 -0
  22. package/dist/types/config.d.ts +141 -0
  23. package/dist/types/config.d.ts.map +1 -1
  24. package/dist/types/config.js +40 -0
  25. package/dist/types/config.js.map +1 -1
  26. package/dist/types/index.d.ts +1 -1
  27. package/dist/types/index.d.ts.map +1 -1
  28. package/dist/types/index.js +1 -1
  29. package/dist/types/index.js.map +1 -1
  30. package/dist/workspace/types.d.ts +12 -54
  31. package/dist/workspace/types.d.ts.map +1 -1
  32. package/dist/workspace/types.js.map +1 -1
  33. package/package.json +3 -3
  34. package/playbooks/compound-engineering/adversarial-review.json +51 -0
  35. package/playbooks/compound-engineering/agent-native-architecture.json +59 -0
  36. package/playbooks/compound-engineering/agent-native-review.json +54 -0
  37. package/playbooks/compound-engineering/api-contract-review.json +52 -0
  38. package/playbooks/compound-engineering/brainstorm-requirements.json +55 -0
  39. package/playbooks/compound-engineering/bug-reproduction.json +62 -0
  40. package/playbooks/compound-engineering/confidence-calibration.json +49 -0
  41. package/playbooks/compound-engineering/correctness-review.json +49 -0
  42. package/playbooks/compound-engineering/data-migration-safety.json +59 -0
  43. package/playbooks/compound-engineering/deployment-verification.json +63 -0
  44. package/playbooks/compound-engineering/error-recovery-patterns.json +53 -0
  45. package/playbooks/compound-engineering/implementation-planning.json +64 -0
  46. package/playbooks/compound-engineering/issue-pattern-analysis.json +53 -0
  47. package/playbooks/compound-engineering/knowledge-compounding.json +63 -0
  48. package/playbooks/compound-engineering/learnings-research.json +54 -0
  49. package/playbooks/compound-engineering/maintainability-review.json +49 -0
  50. package/playbooks/compound-engineering/performance-review.json +54 -0
  51. package/playbooks/compound-engineering/plan-adversarial-review.json +56 -0
  52. package/playbooks/compound-engineering/plan-feasibility-review.json +56 -0
  53. package/playbooks/compound-engineering/project-standards-review.json +52 -0
  54. package/playbooks/compound-engineering/reliability-review.json +53 -0
  55. package/playbooks/compound-engineering/review-orchestration.json +64 -0
  56. package/playbooks/compound-engineering/security-review.json +54 -0
  57. package/playbooks/compound-engineering/systematic-execution.json +64 -0
  58. package/playbooks/compound-engineering/testing-review.json +50 -0
  59. package/src/atlas.ts +96 -0
  60. package/src/memory/curated-loader.ts +69 -16
  61. package/src/memory/index.ts +16 -0
  62. package/src/memory/playbook.ts +19 -0
  63. package/src/memory/source-resolver.ts +422 -0
  64. package/src/types/config.ts +46 -0
  65. package/src/types/index.ts +4 -0
  66. package/src/workspace/types.ts +22 -78
  67. package/tests/integration/curated-sources-e2e.test.ts +502 -0
  68. package/tests/memory/compound-engineering-seed.test.ts +338 -0
  69. package/tests/memory/curated-loader-extended.test.ts +225 -0
  70. package/tests/memory/playbook-quality-validation.test.ts +430 -0
  71. package/tests/memory/source-resolver.test.ts +700 -0
  72. package/.claude/settings.local.json +0 -11
  73. package/dist/learning/llm-extractor.d.ts +0 -88
  74. package/dist/learning/llm-extractor.d.ts.map +0 -1
  75. package/dist/learning/llm-extractor.js +0 -372
  76. package/dist/learning/llm-extractor.js.map +0 -1
  77. package/dist/learning/loop-coordinator.d.ts +0 -61
  78. package/dist/learning/loop-coordinator.d.ts.map +0 -1
  79. package/dist/learning/loop-coordinator.js +0 -96
  80. package/dist/learning/loop-coordinator.js.map +0 -1
  81. package/dist/learning/pipeline.d.ts +0 -116
  82. package/dist/learning/pipeline.d.ts.map +0 -1
  83. package/dist/learning/pipeline.js +0 -288
  84. package/dist/learning/pipeline.js.map +0 -1
  85. package/references/agent-workspace/CLAUDE.md +0 -74
  86. package/references/agent-workspace/README.md +0 -587
  87. package/references/agent-workspace/media/banner.png +0 -0
  88. package/references/agent-workspace/package-lock.json +0 -2061
  89. package/references/agent-workspace/package.json +0 -54
  90. package/references/agent-workspace/src/handle.ts +0 -122
  91. package/references/agent-workspace/src/index.ts +0 -32
  92. package/references/agent-workspace/src/manager.ts +0 -102
  93. package/references/agent-workspace/src/readers/json.ts +0 -71
  94. package/references/agent-workspace/src/readers/markdown.ts +0 -37
  95. package/references/agent-workspace/src/readers/raw.ts +0 -27
  96. package/references/agent-workspace/src/types.ts +0 -68
  97. package/references/agent-workspace/src/validation.ts +0 -93
  98. package/references/agent-workspace/src/writers/json.ts +0 -17
  99. package/references/agent-workspace/src/writers/markdown.ts +0 -27
  100. package/references/agent-workspace/src/writers/raw.ts +0 -22
  101. package/references/agent-workspace/tests/errors.test.ts +0 -652
  102. package/references/agent-workspace/tests/handle.test.ts +0 -144
  103. package/references/agent-workspace/tests/manager.test.ts +0 -124
  104. package/references/agent-workspace/tests/readers.test.ts +0 -205
  105. package/references/agent-workspace/tests/validation.test.ts +0 -196
  106. package/references/agent-workspace/tests/writers.test.ts +0 -108
  107. package/references/agent-workspace/tsconfig.json +0 -20
  108. package/references/agent-workspace/tsup.config.ts +0 -9
  109. package/references/minimem/.claude/settings.json +0 -7
  110. package/references/minimem/.sudocode/issues.jsonl +0 -18
  111. package/references/minimem/.sudocode/specs.jsonl +0 -1
  112. package/references/minimem/CLAUDE.md +0 -310
  113. package/references/minimem/README.md +0 -556
  114. package/references/minimem/claude-plugin/.claude-plugin/plugin.json +0 -10
  115. package/references/minimem/claude-plugin/.mcp.json +0 -7
  116. package/references/minimem/claude-plugin/README.md +0 -158
  117. package/references/minimem/claude-plugin/commands/recall.md +0 -47
  118. package/references/minimem/claude-plugin/commands/remember.md +0 -41
  119. package/references/minimem/claude-plugin/hooks/__tests__/hooks.test.ts +0 -272
  120. package/references/minimem/claude-plugin/hooks/hooks.json +0 -27
  121. package/references/minimem/claude-plugin/hooks/session-end.sh +0 -86
  122. package/references/minimem/claude-plugin/hooks/session-start.sh +0 -85
  123. package/references/minimem/claude-plugin/skills/memory/SKILL.md +0 -108
  124. package/references/minimem/package-lock.json +0 -5373
  125. package/references/minimem/package.json +0 -60
  126. package/references/minimem/scripts/postbuild.js +0 -35
  127. package/references/minimem/src/__tests__/edge-cases.test.ts +0 -371
  128. package/references/minimem/src/__tests__/errors.test.ts +0 -265
  129. package/references/minimem/src/__tests__/helpers.ts +0 -199
  130. package/references/minimem/src/__tests__/internal.test.ts +0 -407
  131. package/references/minimem/src/__tests__/knowledge.test.ts +0 -287
  132. package/references/minimem/src/__tests__/minimem.integration.test.ts +0 -1127
  133. package/references/minimem/src/__tests__/session.test.ts +0 -190
  134. package/references/minimem/src/cli/__tests__/commands.test.ts +0 -759
  135. package/references/minimem/src/cli/commands/__tests__/conflicts.test.ts +0 -141
  136. package/references/minimem/src/cli/commands/append.ts +0 -76
  137. package/references/minimem/src/cli/commands/config.ts +0 -262
  138. package/references/minimem/src/cli/commands/conflicts.ts +0 -413
  139. package/references/minimem/src/cli/commands/daemon.ts +0 -169
  140. package/references/minimem/src/cli/commands/index.ts +0 -12
  141. package/references/minimem/src/cli/commands/init.ts +0 -88
  142. package/references/minimem/src/cli/commands/mcp.ts +0 -177
  143. package/references/minimem/src/cli/commands/push-pull.ts +0 -213
  144. package/references/minimem/src/cli/commands/search.ts +0 -158
  145. package/references/minimem/src/cli/commands/status.ts +0 -84
  146. package/references/minimem/src/cli/commands/sync-init.ts +0 -290
  147. package/references/minimem/src/cli/commands/sync.ts +0 -70
  148. package/references/minimem/src/cli/commands/upsert.ts +0 -197
  149. package/references/minimem/src/cli/config.ts +0 -584
  150. package/references/minimem/src/cli/index.ts +0 -264
  151. package/references/minimem/src/cli/shared.ts +0 -161
  152. package/references/minimem/src/cli/sync/__tests__/central.test.ts +0 -152
  153. package/references/minimem/src/cli/sync/__tests__/conflicts.test.ts +0 -209
  154. package/references/minimem/src/cli/sync/__tests__/daemon.test.ts +0 -118
  155. package/references/minimem/src/cli/sync/__tests__/detection.test.ts +0 -207
  156. package/references/minimem/src/cli/sync/__tests__/integration.test.ts +0 -476
  157. package/references/minimem/src/cli/sync/__tests__/registry.test.ts +0 -363
  158. package/references/minimem/src/cli/sync/__tests__/state.test.ts +0 -255
  159. package/references/minimem/src/cli/sync/__tests__/validation.test.ts +0 -193
  160. package/references/minimem/src/cli/sync/__tests__/watcher.test.ts +0 -178
  161. package/references/minimem/src/cli/sync/central.ts +0 -292
  162. package/references/minimem/src/cli/sync/conflicts.ts +0 -204
  163. package/references/minimem/src/cli/sync/daemon.ts +0 -407
  164. package/references/minimem/src/cli/sync/detection.ts +0 -138
  165. package/references/minimem/src/cli/sync/index.ts +0 -107
  166. package/references/minimem/src/cli/sync/operations.ts +0 -373
  167. package/references/minimem/src/cli/sync/registry.ts +0 -279
  168. package/references/minimem/src/cli/sync/state.ts +0 -355
  169. package/references/minimem/src/cli/sync/validation.ts +0 -206
  170. package/references/minimem/src/cli/sync/watcher.ts +0 -234
  171. package/references/minimem/src/cli/version.ts +0 -34
  172. package/references/minimem/src/core/index.ts +0 -9
  173. package/references/minimem/src/core/indexer.ts +0 -628
  174. package/references/minimem/src/core/searcher.ts +0 -221
  175. package/references/minimem/src/db/schema.ts +0 -183
  176. package/references/minimem/src/db/sqlite-vec.ts +0 -24
  177. package/references/minimem/src/embeddings/__tests__/embeddings.test.ts +0 -431
  178. package/references/minimem/src/embeddings/batch-gemini.ts +0 -392
  179. package/references/minimem/src/embeddings/batch-openai.ts +0 -409
  180. package/references/minimem/src/embeddings/embeddings.ts +0 -434
  181. package/references/minimem/src/index.ts +0 -109
  182. package/references/minimem/src/internal.ts +0 -299
  183. package/references/minimem/src/minimem.ts +0 -1276
  184. package/references/minimem/src/search/__tests__/hybrid.test.ts +0 -247
  185. package/references/minimem/src/search/graph.ts +0 -234
  186. package/references/minimem/src/search/hybrid.ts +0 -151
  187. package/references/minimem/src/search/search.ts +0 -256
  188. package/references/minimem/src/server/__tests__/mcp.test.ts +0 -341
  189. package/references/minimem/src/server/__tests__/tools.test.ts +0 -364
  190. package/references/minimem/src/server/mcp.ts +0 -326
  191. package/references/minimem/src/server/tools.ts +0 -720
  192. package/references/minimem/src/session.ts +0 -460
  193. package/references/minimem/tsconfig.json +0 -19
  194. package/references/minimem/tsup.config.ts +0 -26
  195. package/references/minimem/vitest.config.ts +0 -24
  196. package/references/sessionlog/.husky/pre-commit +0 -1
  197. package/references/sessionlog/.lintstagedrc.json +0 -4
  198. package/references/sessionlog/.prettierignore +0 -4
  199. package/references/sessionlog/.prettierrc.json +0 -11
  200. package/references/sessionlog/LICENSE +0 -21
  201. package/references/sessionlog/README.md +0 -453
  202. package/references/sessionlog/eslint.config.js +0 -58
  203. package/references/sessionlog/package-lock.json +0 -3672
  204. package/references/sessionlog/package.json +0 -65
  205. package/references/sessionlog/src/__tests__/agent-hooks.test.ts +0 -570
  206. package/references/sessionlog/src/__tests__/agent-registry.test.ts +0 -127
  207. package/references/sessionlog/src/__tests__/claude-code-hooks.test.ts +0 -225
  208. package/references/sessionlog/src/__tests__/claude-generator.test.ts +0 -46
  209. package/references/sessionlog/src/__tests__/commit-msg.test.ts +0 -86
  210. package/references/sessionlog/src/__tests__/cursor-agent.test.ts +0 -224
  211. package/references/sessionlog/src/__tests__/e2e-live.test.ts +0 -890
  212. package/references/sessionlog/src/__tests__/event-log.test.ts +0 -183
  213. package/references/sessionlog/src/__tests__/flush-sentinel.test.ts +0 -105
  214. package/references/sessionlog/src/__tests__/gemini-agent.test.ts +0 -375
  215. package/references/sessionlog/src/__tests__/git-hooks.test.ts +0 -78
  216. package/references/sessionlog/src/__tests__/hook-managers.test.ts +0 -121
  217. package/references/sessionlog/src/__tests__/lifecycle-tasks.test.ts +0 -759
  218. package/references/sessionlog/src/__tests__/opencode-agent.test.ts +0 -338
  219. package/references/sessionlog/src/__tests__/redaction.test.ts +0 -136
  220. package/references/sessionlog/src/__tests__/session-repo.test.ts +0 -353
  221. package/references/sessionlog/src/__tests__/session-store.test.ts +0 -166
  222. package/references/sessionlog/src/__tests__/setup-ccweb.test.ts +0 -466
  223. package/references/sessionlog/src/__tests__/skill-live.test.ts +0 -461
  224. package/references/sessionlog/src/__tests__/summarize.test.ts +0 -348
  225. package/references/sessionlog/src/__tests__/task-plan-e2e.test.ts +0 -610
  226. package/references/sessionlog/src/__tests__/task-plan-live.test.ts +0 -632
  227. package/references/sessionlog/src/__tests__/transcript-timestamp.test.ts +0 -121
  228. package/references/sessionlog/src/__tests__/types.test.ts +0 -166
  229. package/references/sessionlog/src/__tests__/utils.test.ts +0 -333
  230. package/references/sessionlog/src/__tests__/validation.test.ts +0 -103
  231. package/references/sessionlog/src/__tests__/worktree.test.ts +0 -57
  232. package/references/sessionlog/src/agent/agents/claude-code.ts +0 -1089
  233. package/references/sessionlog/src/agent/agents/cursor.ts +0 -361
  234. package/references/sessionlog/src/agent/agents/gemini-cli.ts +0 -632
  235. package/references/sessionlog/src/agent/agents/opencode.ts +0 -540
  236. package/references/sessionlog/src/agent/registry.ts +0 -143
  237. package/references/sessionlog/src/agent/session-types.ts +0 -113
  238. package/references/sessionlog/src/agent/types.ts +0 -220
  239. package/references/sessionlog/src/cli.ts +0 -597
  240. package/references/sessionlog/src/commands/clean.ts +0 -133
  241. package/references/sessionlog/src/commands/disable.ts +0 -84
  242. package/references/sessionlog/src/commands/doctor.ts +0 -145
  243. package/references/sessionlog/src/commands/enable.ts +0 -202
  244. package/references/sessionlog/src/commands/explain.ts +0 -261
  245. package/references/sessionlog/src/commands/reset.ts +0 -105
  246. package/references/sessionlog/src/commands/resume.ts +0 -180
  247. package/references/sessionlog/src/commands/rewind.ts +0 -195
  248. package/references/sessionlog/src/commands/setup-ccweb.ts +0 -275
  249. package/references/sessionlog/src/commands/status.ts +0 -172
  250. package/references/sessionlog/src/config.ts +0 -165
  251. package/references/sessionlog/src/events/event-log.ts +0 -126
  252. package/references/sessionlog/src/git-operations.ts +0 -558
  253. package/references/sessionlog/src/hooks/git-hooks.ts +0 -165
  254. package/references/sessionlog/src/hooks/lifecycle.ts +0 -391
  255. package/references/sessionlog/src/index.ts +0 -650
  256. package/references/sessionlog/src/security/redaction.ts +0 -283
  257. package/references/sessionlog/src/session/state-machine.ts +0 -452
  258. package/references/sessionlog/src/store/checkpoint-store.ts +0 -509
  259. package/references/sessionlog/src/store/native-store.ts +0 -173
  260. package/references/sessionlog/src/store/provider-types.ts +0 -99
  261. package/references/sessionlog/src/store/session-store.ts +0 -266
  262. package/references/sessionlog/src/strategy/attribution.ts +0 -296
  263. package/references/sessionlog/src/strategy/common.ts +0 -207
  264. package/references/sessionlog/src/strategy/content-overlap.ts +0 -228
  265. package/references/sessionlog/src/strategy/manual-commit.ts +0 -988
  266. package/references/sessionlog/src/strategy/types.ts +0 -279
  267. package/references/sessionlog/src/summarize/claude-generator.ts +0 -115
  268. package/references/sessionlog/src/summarize/summarize.ts +0 -432
  269. package/references/sessionlog/src/types.ts +0 -508
  270. package/references/sessionlog/src/utils/chunk-files.ts +0 -49
  271. package/references/sessionlog/src/utils/commit-message.ts +0 -65
  272. package/references/sessionlog/src/utils/detect-agent.ts +0 -36
  273. package/references/sessionlog/src/utils/hook-managers.ts +0 -125
  274. package/references/sessionlog/src/utils/ide-tags.ts +0 -32
  275. package/references/sessionlog/src/utils/paths.ts +0 -79
  276. package/references/sessionlog/src/utils/preview-rewind.ts +0 -80
  277. package/references/sessionlog/src/utils/rewind-conflict.ts +0 -121
  278. package/references/sessionlog/src/utils/shadow-branch.ts +0 -109
  279. package/references/sessionlog/src/utils/string-utils.ts +0 -46
  280. package/references/sessionlog/src/utils/todo-extract.ts +0 -188
  281. package/references/sessionlog/src/utils/trailers.ts +0 -187
  282. package/references/sessionlog/src/utils/transcript-parse.ts +0 -177
  283. package/references/sessionlog/src/utils/transcript-timestamp.ts +0 -59
  284. package/references/sessionlog/src/utils/tree-ops.ts +0 -219
  285. package/references/sessionlog/src/utils/tty.ts +0 -72
  286. package/references/sessionlog/src/utils/validation.ts +0 -65
  287. package/references/sessionlog/src/utils/worktree.ts +0 -58
  288. package/references/sessionlog/src/wire-types.ts +0 -59
  289. package/references/sessionlog/templates/setup-env.sh +0 -153
  290. package/references/sessionlog/tsconfig.json +0 -18
  291. package/references/sessionlog/vitest.config.ts +0 -12
  292. package/references/skill-tree/.claude/settings.json +0 -6
  293. package/references/skill-tree/.sudocode/issues.jsonl +0 -19
  294. package/references/skill-tree/.sudocode/specs.jsonl +0 -3
  295. package/references/skill-tree/CLAUDE.md +0 -126
  296. package/references/skill-tree/README.md +0 -372
  297. package/references/skill-tree/docs/GAPS_v1.md +0 -221
  298. package/references/skill-tree/docs/INTEGRATION_PLAN.md +0 -467
  299. package/references/skill-tree/docs/TODOS.md +0 -91
  300. package/references/skill-tree/docs/anthropic_skill_guide.md +0 -1364
  301. package/references/skill-tree/docs/design/federated-skill-trees.md +0 -524
  302. package/references/skill-tree/docs/design/multi-agent-sync.md +0 -759
  303. package/references/skill-tree/docs/scraper/BRAINSTORM.md +0 -583
  304. package/references/skill-tree/docs/scraper/POC_PLAN.md +0 -420
  305. package/references/skill-tree/docs/scraper/README.md +0 -170
  306. package/references/skill-tree/examples/basic-usage.ts +0 -164
  307. package/references/skill-tree/package-lock.json +0 -1852
  308. package/references/skill-tree/package.json +0 -66
  309. package/references/skill-tree/scraper/README.md +0 -123
  310. package/references/skill-tree/scraper/docs/DESIGN.md +0 -683
  311. package/references/skill-tree/scraper/docs/PLAN.md +0 -336
  312. package/references/skill-tree/scraper/drizzle.config.ts +0 -10
  313. package/references/skill-tree/scraper/package-lock.json +0 -6329
  314. package/references/skill-tree/scraper/package.json +0 -68
  315. package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-description.md +0 -7
  316. package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-name.md +0 -7
  317. package/references/skill-tree/scraper/test/fixtures/minimal-skill/SKILL.md +0 -27
  318. package/references/skill-tree/scraper/test/fixtures/skill-json/SKILL.json +0 -21
  319. package/references/skill-tree/scraper/test/fixtures/skill-with-meta/SKILL.md +0 -54
  320. package/references/skill-tree/scraper/test/fixtures/skill-with-meta/_meta.json +0 -24
  321. package/references/skill-tree/scraper/test/fixtures/valid-skill/SKILL.md +0 -93
  322. package/references/skill-tree/scraper/test/fixtures/valid-skill/_meta.json +0 -22
  323. package/references/skill-tree/scraper/tsup.config.ts +0 -14
  324. package/references/skill-tree/scraper/vitest.config.ts +0 -17
  325. package/references/skill-tree/scripts/convert-to-vitest.ts +0 -166
  326. package/references/skill-tree/skills/skill-writer/SKILL.md +0 -339
  327. package/references/skill-tree/skills/skill-writer/references/examples.md +0 -326
  328. package/references/skill-tree/skills/skill-writer/references/patterns.md +0 -210
  329. package/references/skill-tree/skills/skill-writer/references/quality-checklist.md +0 -123
  330. package/references/skill-tree/test/run-all.ts +0 -106
  331. package/references/skill-tree/test/utils.ts +0 -128
  332. package/references/skill-tree/vitest.config.ts +0 -16
@@ -1,264 +0,0 @@
1
- /**
2
- * Minimem CLI
3
- *
4
- * A file-based memory system with vector search for AI agents.
5
- */
6
-
7
- import { program } from "commander";
8
-
9
- import { init } from "./commands/init.js";
10
- import { search } from "./commands/search.js";
11
- import { sync } from "./commands/sync.js";
12
- import { status } from "./commands/status.js";
13
- import { append } from "./commands/append.js";
14
- import { upsert } from "./commands/upsert.js";
15
- import { mcp } from "./commands/mcp.js";
16
- import { config } from "./commands/config.js";
17
- import { syncInit, syncInitCentral, syncList, syncRemove } from "./commands/sync-init.js";
18
- import { pushCommand, pullCommand, syncStatusCommand } from "./commands/push-pull.js";
19
- import { conflictsCommand, resolveCommand, cleanupCommand, logCommand } from "./commands/conflicts.js";
20
- import { daemonCommand, daemonStopCommand, daemonStatusCommand, daemonLogsCommand } from "./commands/daemon.js";
21
- import { validateRegistry, formatValidationResult } from "./sync/validation.js";
22
- import { VERSION } from "./version.js";
23
- import { exitWithError } from "./config.js";
24
-
25
- program
26
- .name("minimem")
27
- .description("File-based memory system with vector search for AI agents")
28
- .version(VERSION);
29
-
30
- // minimem init [dir]
31
- program
32
- .command("init [dir]")
33
- .description("Initialize a memory directory")
34
- .option("-g, --global", "Use ~/.minimem as global memory directory")
35
- .option("-f, --force", "Reinitialize even if already initialized")
36
- .action(init);
37
-
38
- // minimem search <query>
39
- program
40
- .command("search <query>")
41
- .description("Semantic search through memory files")
42
- .option("-d, --dir <path...>", "Memory directories (can specify multiple)")
43
- .option("-g, --global", "Include ~/.minimem in search")
44
- .option("-n, --max <number>", "Maximum results (default: 10)")
45
- .option("-s, --min-score <number>", "Minimum score threshold 0-1 (default: 0.3)")
46
- .option("-p, --provider <name>", "Embedding provider (openai, gemini, local, auto)")
47
- .option("--json", "Output results as JSON")
48
- .action(search);
49
-
50
- // minimem sync
51
- program
52
- .command("sync")
53
- .description("Force re-index memory files")
54
- .option("-d, --dir <path>", "Memory directory")
55
- .option("-g, --global", "Use ~/.minimem")
56
- .option("-f, --force", "Force full re-index")
57
- .option("-p, --provider <name>", "Embedding provider (openai, gemini, local, auto)")
58
- .action(sync);
59
-
60
- // minimem status
61
- program
62
- .command("status")
63
- .description("Show index stats and provider info")
64
- .option("-d, --dir <path>", "Memory directory")
65
- .option("-g, --global", "Use ~/.minimem")
66
- .option("-p, --provider <name>", "Embedding provider (openai, gemini, local, auto)")
67
- .option("--json", "Output as JSON")
68
- .action(status);
69
-
70
- // minimem append <text>
71
- program
72
- .command("append <text>")
73
- .description("Append text to today's daily log (memory/YYYY-MM-DD.md)")
74
- .option("-d, --dir <path>", "Memory directory")
75
- .option("-g, --global", "Use ~/.minimem")
76
- .option("-f, --file <path>", "Append to specific file instead of today's log")
77
- .option("-p, --provider <name>", "Embedding provider (openai, gemini, local, auto)")
78
- .option("-s, --session <id>", "Session ID to associate with this memory")
79
- .option("--session-source <name>", "Session source (claude-code, vscode, etc.)")
80
- .action(append);
81
-
82
- // minimem upsert <file> [content]
83
- program
84
- .command("upsert <file> [content]")
85
- .description("Create or update a memory file (file path relative to memory dir)")
86
- .option("-d, --dir <path>", "Memory directory")
87
- .option("-g, --global", "Use ~/.minimem")
88
- .option("-p, --provider <name>", "Embedding provider (openai, gemini, local, auto)")
89
- .option("--stdin", "Read content from stdin")
90
- .option("-s, --session <id>", "Session ID to associate with this memory")
91
- .option("--session-source <name>", "Session source (claude-code, vscode, etc.)")
92
- .action(upsert);
93
-
94
- // minimem mcp
95
- program
96
- .command("mcp")
97
- .description("Run as MCP server over stdio (for Claude Desktop, Cursor, etc.)")
98
- .option("-d, --dir <path...>", "Memory directories (can specify multiple)")
99
- .option("-g, --global", "Include ~/.minimem")
100
- .option("-p, --provider <name>", "Embedding provider (openai, gemini, local, auto)")
101
- .action(mcp);
102
-
103
- // minimem config
104
- program
105
- .command("config")
106
- .description("View or modify configuration")
107
- .option("-d, --dir <path>", "Memory directory")
108
- .option("-g, --global", "Use ~/.minimem")
109
- .option("--xdg-global", "Modify ~/.config/minimem/config.json (for sync settings)")
110
- .option("--json", "Output as JSON")
111
- .option("--set <key=value>", "Set a config value (e.g., embedding.provider=openai)")
112
- .option("--unset <key>", "Remove a config value")
113
- .action(config);
114
-
115
- // minimem sync init-central <path>
116
- program
117
- .command("sync:init-central <path>")
118
- .description("Initialize a central repository for syncing memories")
119
- .option("-f, --force", "Force creation even if directory exists")
120
- .action(syncInitCentral);
121
-
122
- // minimem sync init
123
- program
124
- .command("sync:init")
125
- .description("Initialize sync for a memory directory")
126
- .option("-d, --local <path>", "Memory directory to sync")
127
- .option("-g, --global", "Use ~/.minimem")
128
- .option("-p, --path <path>", "Path in central repo (e.g., myproject/)")
129
- .action(syncInit);
130
-
131
- // minimem sync list
132
- program
133
- .command("sync:list")
134
- .description("List all sync mappings")
135
- .action(syncList);
136
-
137
- // minimem sync remove
138
- program
139
- .command("sync:remove")
140
- .description("Remove sync mapping for a directory")
141
- .option("-d, --local <path>", "Memory directory")
142
- .option("-g, --global", "Use ~/.minimem")
143
- .action(syncRemove);
144
-
145
- // minimem push
146
- program
147
- .command("push")
148
- .description("Push local changes to central repository")
149
- .option("-d, --dir <path>", "Memory directory")
150
- .option("-g, --global", "Use ~/.minimem")
151
- .option("-f, --force", "Force push (overwrite remote on conflicts)")
152
- .option("--dry-run", "Show what would be pushed without making changes")
153
- .action(pushCommand);
154
-
155
- // minimem pull
156
- program
157
- .command("pull")
158
- .description("Pull changes from central repository")
159
- .option("-d, --dir <path>", "Memory directory")
160
- .option("-g, --global", "Use ~/.minimem")
161
- .option("-f, --force", "Force pull (overwrite local on conflicts)")
162
- .option("--dry-run", "Show what would be pulled without making changes")
163
- .action(pullCommand);
164
-
165
- // minimem sync:status
166
- program
167
- .command("sync:status")
168
- .description("Show sync status for a directory")
169
- .option("-d, --dir <path>", "Memory directory")
170
- .option("-g, --global", "Use ~/.minimem")
171
- .action(syncStatusCommand);
172
-
173
- // minimem sync:conflicts
174
- program
175
- .command("sync:conflicts")
176
- .description("List quarantined conflicts")
177
- .option("-d, --dir <path>", "Memory directory")
178
- .option("-g, --global", "Use ~/.minimem")
179
- .option("--json", "Output as JSON")
180
- .action(conflictsCommand);
181
-
182
- // minimem sync:resolve <timestamp>
183
- program
184
- .command("sync:resolve <timestamp>")
185
- .description("Resolve a quarantined conflict using merge tool")
186
- .option("-d, --dir <path>", "Memory directory")
187
- .option("-g, --global", "Use ~/.minimem")
188
- .option("-t, --tool <name>", "Merge tool (code, meld, kdiff3, vimdiff)")
189
- .action(resolveCommand);
190
-
191
- // minimem sync:cleanup
192
- program
193
- .command("sync:cleanup")
194
- .description("Clean up old quarantined conflicts")
195
- .option("-d, --dir <path>", "Memory directory")
196
- .option("-g, --global", "Use ~/.minimem")
197
- .option("--days <number>", "Remove conflicts older than N days (default: 30)")
198
- .option("--dry-run", "Show what would be removed without removing")
199
- .action(cleanupCommand);
200
-
201
- // minimem sync:log
202
- program
203
- .command("sync:log")
204
- .description("Show sync history")
205
- .option("-d, --dir <path>", "Memory directory")
206
- .option("-g, --global", "Use ~/.minimem")
207
- .option("-n, --limit <number>", "Number of entries to show (default: 20)")
208
- .option("--json", "Output as JSON")
209
- .action(logCommand);
210
-
211
- // minimem daemon
212
- program
213
- .command("daemon")
214
- .description("Start the sync daemon")
215
- .option("-b, --background", "Run in background")
216
- .option("--foreground", "Run in foreground (internal use)")
217
- .action(daemonCommand);
218
-
219
- // minimem daemon:stop
220
- program
221
- .command("daemon:stop")
222
- .description("Stop the sync daemon")
223
- .action(daemonStopCommand);
224
-
225
- // minimem daemon:status
226
- program
227
- .command("daemon:status")
228
- .description("Show daemon status")
229
- .action(daemonStatusCommand);
230
-
231
- // minimem daemon:logs
232
- program
233
- .command("daemon:logs")
234
- .description("Show daemon logs")
235
- .option("-n, --lines <number>", "Number of lines to show (default: 50)")
236
- .option("-f, --follow", "Follow log output")
237
- .action(daemonLogsCommand);
238
-
239
- // minimem sync:validate
240
- program
241
- .command("sync:validate")
242
- .description("Validate registry for collisions and stale mappings")
243
- .option("--json", "Output as JSON")
244
- .action(async (options: { json?: boolean }) => {
245
- try {
246
- const result = await validateRegistry();
247
-
248
- if (options.json) {
249
- console.log(JSON.stringify(result, null, 2));
250
- } else {
251
- console.log(formatValidationResult(result));
252
- }
253
-
254
- if (!result.valid) {
255
- process.exit(1);
256
- }
257
- } catch (error) {
258
- const message = error instanceof Error ? error.message : String(error);
259
- exitWithError(message);
260
- }
261
- });
262
-
263
- // Parse and run
264
- program.parse();
@@ -1,161 +0,0 @@
1
- /**
2
- * Shared CLI utilities
3
- *
4
- * Centralized functions for directory resolution, error handling,
5
- * and other cross-cutting concerns used by all CLI commands.
6
- */
7
-
8
- import * as path from "node:path";
9
- import * as os from "node:os";
10
-
11
- /**
12
- * Options that affect directory resolution
13
- */
14
- export type DirOptions = {
15
- dir?: string | string[];
16
- global?: boolean;
17
- };
18
-
19
- /**
20
- * Resolve a single memory directory from options.
21
- *
22
- * Priority:
23
- * 1. --dir flag (first element if array)
24
- * 2. MEMORY_DIR environment variable
25
- * 3. --global flag → ~/.minimem
26
- * 4. Current working directory
27
- *
28
- * Use this for commands that operate on a single directory.
29
- */
30
- export function resolveMemoryDir(options: DirOptions): string {
31
- // Handle --dir flag (use first if array)
32
- const dir = Array.isArray(options.dir) ? options.dir[0] : options.dir;
33
- if (dir) {
34
- return path.resolve(dir);
35
- }
36
-
37
- // Check MEMORY_DIR environment variable
38
- const envDir = process.env.MEMORY_DIR;
39
- if (envDir) {
40
- return path.resolve(envDir);
41
- }
42
-
43
- // Handle --global flag
44
- if (options.global) {
45
- return path.join(os.homedir(), ".minimem");
46
- }
47
-
48
- // Default to current working directory
49
- return process.cwd();
50
- }
51
-
52
- /**
53
- * Resolve multiple memory directories from options.
54
- *
55
- * Use this for commands that can search across multiple directories
56
- * (e.g., search, mcp).
57
- *
58
- * Returns deduplicated list of absolute paths.
59
- */
60
- export function resolveMemoryDirs(options: DirOptions): string[] {
61
- const dirs: string[] = [];
62
-
63
- // Add explicit directories from --dir flag
64
- if (options.dir) {
65
- const dirList = Array.isArray(options.dir) ? options.dir : [options.dir];
66
- dirs.push(...dirList.map((d) => path.resolve(d)));
67
- }
68
-
69
- // If no explicit dirs, check MEMORY_DIR environment variable
70
- if (dirs.length === 0 && process.env.MEMORY_DIR) {
71
- dirs.push(path.resolve(process.env.MEMORY_DIR));
72
- }
73
-
74
- // Add global directory if --global flag is set
75
- if (options.global) {
76
- const globalDir = path.join(os.homedir(), ".minimem");
77
- if (!dirs.includes(globalDir)) {
78
- dirs.push(globalDir);
79
- }
80
- }
81
-
82
- // Default to current directory if nothing specified
83
- if (dirs.length === 0) {
84
- dirs.push(process.cwd());
85
- }
86
-
87
- // Deduplicate
88
- return [...new Set(dirs)];
89
- }
90
-
91
- /**
92
- * Get the global memory directory path (~/.minimem)
93
- */
94
- export function getGlobalMemoryDir(): string {
95
- return path.join(os.homedir(), ".minimem");
96
- }
97
-
98
- /**
99
- * Exit with an error message and optional suggestion.
100
- *
101
- * All CLI errors should use this for consistent formatting.
102
- */
103
- export function exitWithError(message: string, suggestion?: string): never {
104
- console.error(`Error: ${message}`);
105
- if (suggestion) {
106
- console.error(` Suggestion: ${suggestion}`);
107
- }
108
- process.exit(1);
109
- }
110
-
111
- /**
112
- * Print a warning message (non-fatal).
113
- */
114
- export function warn(message: string): void {
115
- console.error(`Warning: ${message}`);
116
- }
117
-
118
- /**
119
- * Print a note/informational message.
120
- */
121
- export function note(message: string): void {
122
- console.error(`Note: ${message}`);
123
- }
124
-
125
- /**
126
- * Log an error with context (for debugging).
127
- * Only logs if a debug function is provided.
128
- */
129
- export function logError(
130
- context: string,
131
- error: unknown,
132
- debug?: (msg: string) => void
133
- ): void {
134
- const message = error instanceof Error ? error.message : String(error);
135
- if (debug) {
136
- debug(`[${context}] Error: ${message}`);
137
- }
138
- }
139
-
140
- /**
141
- * Get a friendly display name for a directory.
142
- */
143
- export function getDirName(memoryDir: string): string {
144
- const home = os.homedir();
145
-
146
- // Check if it's the global directory
147
- if (memoryDir === path.join(home, ".minimem")) {
148
- return "global";
149
- }
150
-
151
- // Use the directory name
152
- const name = path.basename(memoryDir);
153
-
154
- // If it's a hidden directory, use parent + name
155
- if (name.startsWith(".")) {
156
- const parent = path.basename(path.dirname(memoryDir));
157
- return `${parent}/${name}`;
158
- }
159
-
160
- return name;
161
- }
@@ -1,152 +0,0 @@
1
- /**
2
- * Tests for central repository initialization
3
- */
4
-
5
- import fs from "node:fs/promises";
6
- import os from "node:os";
7
- import path from "node:path";
8
- import { afterEach, beforeEach, describe, it, expect } from "vitest";
9
-
10
- import {
11
- initCentralRepo,
12
- validateCentralRepo,
13
- } from "../central.js";
14
- import { readRegistry } from "../registry.js";
15
-
16
- describe("Central Repository", () => {
17
- let tempDir: string;
18
-
19
- beforeEach(async () => {
20
- tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "minimem-central-test-"));
21
- });
22
-
23
- afterEach(async () => {
24
- await fs.rm(tempDir, { recursive: true, force: true });
25
- });
26
-
27
- describe("initCentralRepo", () => {
28
- it("should create new central repository", async () => {
29
- const repoPath = path.join(tempDir, "memories-repo");
30
- const result = await initCentralRepo(repoPath);
31
-
32
- expect(result.success).toBe(true);
33
- expect(result.created).toBe(true);
34
- expect(result.message.includes("Created")).toBeTruthy();
35
-
36
- // Check .git exists
37
- const gitStat = await fs.stat(path.join(repoPath, ".git"));
38
- expect(gitStat.isDirectory()).toBeTruthy();
39
-
40
- // Check .gitignore exists and has correct content
41
- const gitignore = await fs.readFile(path.join(repoPath, ".gitignore"), "utf-8");
42
- expect(gitignore.includes("*.db")).toBeTruthy();
43
- expect(gitignore.includes("staging/")).toBeTruthy();
44
- expect(gitignore.includes("conflicts/")).toBeTruthy();
45
-
46
- // Check registry exists
47
- const registry = await readRegistry(repoPath);
48
- expect(registry.mappings).toEqual([]);
49
-
50
- // Check README exists
51
- const readme = await fs.readFile(path.join(repoPath, "README.md"), "utf-8");
52
- expect(readme.includes("Minimem Central Repository")).toBeTruthy();
53
- });
54
-
55
- it("should configure existing directory", async () => {
56
- // Create directory first
57
- await fs.mkdir(tempDir, { recursive: true });
58
-
59
- const result = await initCentralRepo(tempDir);
60
-
61
- expect(result.success).toBe(true);
62
- expect(result.created).toBe(false);
63
- expect(result.message.includes("Configured")).toBeTruthy();
64
- });
65
-
66
- it("should not overwrite existing .gitignore", async () => {
67
- const repoPath = path.join(tempDir, "existing-repo");
68
- await fs.mkdir(repoPath, { recursive: true });
69
- await fs.writeFile(path.join(repoPath, ".gitignore"), "custom-ignore\n");
70
-
71
- await initCentralRepo(repoPath);
72
-
73
- const gitignore = await fs.readFile(path.join(repoPath, ".gitignore"), "utf-8");
74
- expect(gitignore).toBe("custom-ignore\n");
75
- });
76
-
77
- it("should not overwrite existing registry", async () => {
78
- const repoPath = path.join(tempDir, "existing-repo");
79
- await fs.mkdir(repoPath, { recursive: true });
80
- await fs.writeFile(
81
- path.join(repoPath, ".minimem-registry.json"),
82
- JSON.stringify({ version: 1, mappings: [{ path: "test/" }] })
83
- );
84
-
85
- await initCentralRepo(repoPath);
86
-
87
- const content = await fs.readFile(
88
- path.join(repoPath, ".minimem-registry.json"),
89
- "utf-8"
90
- );
91
- const registry = JSON.parse(content);
92
- expect(registry.mappings.length).toBe(1);
93
- });
94
-
95
- it("should handle ~ in path", async () => {
96
- // We can't easily test ~ expansion to home in isolation,
97
- // but we can test that it doesn't crash
98
- const result = await initCentralRepo(path.join(tempDir, "test-repo"));
99
- expect(result.success).toBe(true);
100
- });
101
- });
102
-
103
- describe("validateCentralRepo", () => {
104
- it("should validate a properly configured repo", async () => {
105
- const repoPath = path.join(tempDir, "valid-repo");
106
- await initCentralRepo(repoPath);
107
-
108
- const result = await validateCentralRepo(repoPath);
109
-
110
- expect(result.valid).toBe(true);
111
- expect(result.errors.length).toBe(0);
112
- });
113
-
114
- it("should report missing directory", async () => {
115
- const result = await validateCentralRepo(path.join(tempDir, "nonexistent"));
116
-
117
- expect(result.valid).toBe(false);
118
- expect(result.errors.some(e => e.includes("does not exist"))).toBeTruthy();
119
- });
120
-
121
- it("should warn about missing registry", async () => {
122
- await fs.mkdir(tempDir, { recursive: true });
123
- // Initialize git but don't create registry
124
- const { execSync } = await import("node:child_process");
125
- execSync("git init", { cwd: tempDir, stdio: "pipe" });
126
-
127
- const result = await validateCentralRepo(tempDir);
128
-
129
- expect(result.valid).toBe(true); // Still valid, just has warnings
130
- expect(result.warnings.some(w => w.includes("Registry"))).toBeTruthy();
131
- });
132
-
133
- it("should warn about missing .gitignore", async () => {
134
- const repoPath = path.join(tempDir, "no-gitignore");
135
- await fs.mkdir(repoPath, { recursive: true });
136
- const { execSync } = await import("node:child_process");
137
- execSync("git init", { cwd: repoPath, stdio: "pipe" });
138
-
139
- const result = await validateCentralRepo(repoPath);
140
-
141
- expect(result.warnings.some(w => w.includes(".gitignore"))).toBeTruthy();
142
- });
143
-
144
- it("should warn if not a git repo", async () => {
145
- await fs.mkdir(tempDir, { recursive: true });
146
-
147
- const result = await validateCentralRepo(tempDir);
148
-
149
- expect(result.warnings.some(w => w.includes("Not a git repository"))).toBeTruthy();
150
- });
151
- });
152
- });