squish-memory 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (449) hide show
  1. package/bin/squish-mcp.mjs +40 -42
  2. package/core/scheduler/cron-scheduler.ts +10 -1
  3. package/core/worker.ts +10 -1
  4. package/package.json +119 -119
  5. package/packages/mcp/src/index.ts +99 -36
  6. package/dist/config.d.ts +0 -106
  7. package/dist/config.js +0 -194
  8. package/dist/core/adapters/config/claude-code.d.ts +0 -45
  9. package/dist/core/adapters/config/claude-code.js +0 -113
  10. package/dist/core/adapters/config/cursor.d.ts +0 -26
  11. package/dist/core/adapters/config/cursor.js +0 -74
  12. package/dist/core/adapters/config/opencode.d.ts +0 -23
  13. package/dist/core/adapters/config/opencode.js +0 -73
  14. package/dist/core/adapters/config/windsurf.d.ts +0 -26
  15. package/dist/core/adapters/config/windsurf.js +0 -74
  16. package/dist/core/adapters/index.d.ts +0 -45
  17. package/dist/core/adapters/index.js +0 -84
  18. package/dist/core/adapters/scripts/install-adapter.d.ts +0 -19
  19. package/dist/core/adapters/scripts/install-adapter.js +0 -149
  20. package/dist/core/adapters/timeline.d.ts +0 -23
  21. package/dist/core/adapters/timeline.js +0 -88
  22. package/dist/core/adapters/types.d.ts +0 -137
  23. package/dist/core/adapters/types.js +0 -50
  24. package/dist/core/agent-preferences.d.ts +0 -16
  25. package/dist/core/agent-preferences.js +0 -124
  26. package/dist/core/algorithms/analytics/token-estimator.d.ts +0 -50
  27. package/dist/core/algorithms/analytics/token-estimator.js +0 -154
  28. package/dist/core/algorithms/detection/hash-filters.d.ts +0 -47
  29. package/dist/core/algorithms/detection/hash-filters.js +0 -190
  30. package/dist/core/algorithms/detection/semantic-ranker.d.ts +0 -32
  31. package/dist/core/algorithms/detection/semantic-ranker.js +0 -118
  32. package/dist/core/algorithms/detection/two-stage-detector.d.ts +0 -52
  33. package/dist/core/algorithms/detection/two-stage-detector.js +0 -299
  34. package/dist/core/algorithms/handlers/approve-merge.d.ts +0 -22
  35. package/dist/core/algorithms/handlers/approve-merge.js +0 -179
  36. package/dist/core/algorithms/handlers/detect-duplicates.d.ts +0 -47
  37. package/dist/core/algorithms/handlers/detect-duplicates.js +0 -145
  38. package/dist/core/algorithms/handlers/get-stats.d.ts +0 -39
  39. package/dist/core/algorithms/handlers/get-stats.js +0 -88
  40. package/dist/core/algorithms/handlers/list-proposals.d.ts +0 -45
  41. package/dist/core/algorithms/handlers/list-proposals.js +0 -83
  42. package/dist/core/algorithms/handlers/preview-merge.d.ts +0 -39
  43. package/dist/core/algorithms/handlers/preview-merge.js +0 -93
  44. package/dist/core/algorithms/handlers/reject-merge.d.ts +0 -28
  45. package/dist/core/algorithms/handlers/reject-merge.js +0 -69
  46. package/dist/core/algorithms/handlers/reverse-merge.d.ts +0 -21
  47. package/dist/core/algorithms/handlers/reverse-merge.js +0 -121
  48. package/dist/core/algorithms/index.d.ts +0 -21
  49. package/dist/core/algorithms/index.js +0 -26
  50. package/dist/core/algorithms/operations/cache-maintenance.d.ts +0 -12
  51. package/dist/core/algorithms/operations/cache-maintenance.js +0 -157
  52. package/dist/core/algorithms/safety/safety-checks.d.ts +0 -18
  53. package/dist/core/algorithms/safety/safety-checks.js +0 -179
  54. package/dist/core/algorithms/strategies/merge-strategies.d.ts +0 -50
  55. package/dist/core/algorithms/strategies/merge-strategies.js +0 -288
  56. package/dist/core/algorithms/types.d.ts +0 -125
  57. package/dist/core/algorithms/types.js +0 -5
  58. package/dist/core/algorithms/utils/response-builder.d.ts +0 -28
  59. package/dist/core/algorithms/utils/response-builder.js +0 -37
  60. package/dist/core/associations.d.ts +0 -33
  61. package/dist/core/associations.js +0 -284
  62. package/dist/core/autosave.d.ts +0 -19
  63. package/dist/core/autosave.js +0 -16
  64. package/dist/core/beliefs/decay.d.ts +0 -27
  65. package/dist/core/beliefs/decay.js +0 -217
  66. package/dist/core/beliefs/extractor.d.ts +0 -9
  67. package/dist/core/beliefs/extractor.js +0 -113
  68. package/dist/core/beliefs/store.d.ts +0 -46
  69. package/dist/core/beliefs/store.js +0 -466
  70. package/dist/core/beliefs/types.d.ts +0 -28
  71. package/dist/core/beliefs/types.js +0 -2
  72. package/dist/core/commands/mcp-server.d.ts +0 -2
  73. package/dist/core/commands/mcp-server.js +0 -6
  74. package/dist/core/commands/remember.d.ts +0 -24
  75. package/dist/core/commands/remember.js +0 -144
  76. package/dist/core/compression.d.ts +0 -45
  77. package/dist/core/compression.js +0 -160
  78. package/dist/core/consolidation.d.ts +0 -37
  79. package/dist/core/consolidation.js +0 -248
  80. package/dist/core/context/agent-context.d.ts +0 -106
  81. package/dist/core/context/agent-context.js +0 -274
  82. package/dist/core/context/context-paging.d.ts +0 -80
  83. package/dist/core/context/context-paging.js +0 -328
  84. package/dist/core/context/context-window.d.ts +0 -40
  85. package/dist/core/context/context-window.js +0 -177
  86. package/dist/core/context/context.d.ts +0 -7
  87. package/dist/core/context/context.js +0 -22
  88. package/dist/core/embeddings/embeddings.d.ts +0 -29
  89. package/dist/core/embeddings/embeddings.js +0 -546
  90. package/dist/core/embeddings/google-multimodal.d.ts +0 -14
  91. package/dist/core/embeddings/google-multimodal.js +0 -146
  92. package/dist/core/embeddings/local-embeddings.d.ts +0 -11
  93. package/dist/core/embeddings/local-embeddings.js +0 -11
  94. package/dist/core/embeddings/qmd-client.d.ts +0 -136
  95. package/dist/core/embeddings/qmd-client.js +0 -403
  96. package/dist/core/embeddings/transformers-local.d.ts +0 -64
  97. package/dist/core/embeddings/transformers-local.js +0 -213
  98. package/dist/core/embeddings.d.ts +0 -2
  99. package/dist/core/embeddings.js +0 -3
  100. package/dist/core/error-handling.d.ts +0 -63
  101. package/dist/core/error-handling.js +0 -173
  102. package/dist/core/graph/entity-deduplicator.d.ts +0 -24
  103. package/dist/core/graph/entity-deduplicator.js +0 -183
  104. package/dist/core/graph/graph-builder.d.ts +0 -46
  105. package/dist/core/graph/graph-builder.js +0 -174
  106. package/dist/core/graph/graph-traversal.d.ts +0 -80
  107. package/dist/core/graph/graph-traversal.js +0 -315
  108. package/dist/core/graph/index.d.ts +0 -19
  109. package/dist/core/graph/index.js +0 -13
  110. package/dist/core/graph/llm-entity-extractor.d.ts +0 -49
  111. package/dist/core/graph/llm-entity-extractor.js +0 -313
  112. package/dist/core/graph/multi-hop-retrieval.d.ts +0 -48
  113. package/dist/core/graph/multi-hop-retrieval.js +0 -215
  114. package/dist/core/graph/relationship-extractor.d.ts +0 -48
  115. package/dist/core/graph/relationship-extractor.js +0 -351
  116. package/dist/core/hooks/agent-hooks.d.ts +0 -83
  117. package/dist/core/hooks/agent-hooks.js +0 -521
  118. package/dist/core/hooks/auto-tagger.d.ts +0 -19
  119. package/dist/core/hooks/auto-tagger.js +0 -155
  120. package/dist/core/hooks/capture-filter.d.ts +0 -41
  121. package/dist/core/hooks/capture-filter.js +0 -128
  122. package/dist/core/hot-cache.d.ts +0 -86
  123. package/dist/core/hot-cache.js +0 -285
  124. package/dist/core/index.d.ts +0 -10
  125. package/dist/core/index.js +0 -11
  126. package/dist/core/ingestion/agent-memory.d.ts +0 -22
  127. package/dist/core/ingestion/agent-memory.js +0 -109
  128. package/dist/core/ingestion/core-memory.d.ts +0 -78
  129. package/dist/core/ingestion/core-memory.js +0 -226
  130. package/dist/core/ingestion/learnings.d.ts +0 -57
  131. package/dist/core/ingestion/learnings.js +0 -205
  132. package/dist/core/ingestion/signal-engine.d.ts +0 -41
  133. package/dist/core/ingestion/signal-engine.js +0 -201
  134. package/dist/core/integrations/obsidian-vault.d.ts +0 -31
  135. package/dist/core/integrations/obsidian-vault.js +0 -156
  136. package/dist/core/layers/generator.d.ts +0 -25
  137. package/dist/core/layers/generator.js +0 -76
  138. package/dist/core/lib/db-client.d.ts +0 -114
  139. package/dist/core/lib/db-client.js +0 -130
  140. package/dist/core/lib/parse-embedding.d.ts +0 -9
  141. package/dist/core/lib/parse-embedding.js +0 -58
  142. package/dist/core/lib/schemas.d.ts +0 -132
  143. package/dist/core/lib/schemas.js +0 -87
  144. package/dist/core/lib/types.d.ts +0 -45
  145. package/dist/core/lib/types.js +0 -6
  146. package/dist/core/lib/utils.d.ts +0 -18
  147. package/dist/core/lib/utils.js +0 -145
  148. package/dist/core/lib/validation.d.ts +0 -38
  149. package/dist/core/lib/validation.js +0 -151
  150. package/dist/core/lifecycle.d.ts +0 -25
  151. package/dist/core/lifecycle.js +0 -292
  152. package/dist/core/logger.d.ts +0 -17
  153. package/dist/core/logger.js +0 -46
  154. package/dist/core/mcp/client.d.ts +0 -17
  155. package/dist/core/mcp/client.js +0 -101
  156. package/dist/core/mcp/index.d.ts +0 -6
  157. package/dist/core/mcp/index.js +0 -6
  158. package/dist/core/mcp/server.d.ts +0 -18
  159. package/dist/core/mcp/server.js +0 -157
  160. package/dist/core/mcp/standalone-server.d.ts +0 -13
  161. package/dist/core/mcp/standalone-server.js +0 -46
  162. package/dist/core/mcp/tools.d.ts +0 -7
  163. package/dist/core/mcp/tools.js +0 -278
  164. package/dist/core/mcp/types.d.ts +0 -87
  165. package/dist/core/mcp/types.js +0 -48
  166. package/dist/core/memory/bridge-discovery.d.ts +0 -50
  167. package/dist/core/memory/bridge-discovery.js +0 -291
  168. package/dist/core/memory/categorizer.d.ts +0 -27
  169. package/dist/core/memory/categorizer.js +0 -306
  170. package/dist/core/memory/conflict-detector.d.ts +0 -7
  171. package/dist/core/memory/conflict-detector.js +0 -43
  172. package/dist/core/memory/consolidation.d.ts +0 -42
  173. package/dist/core/memory/consolidation.js +0 -277
  174. package/dist/core/memory/context-collector.d.ts +0 -10
  175. package/dist/core/memory/context-collector.js +0 -56
  176. package/dist/core/memory/contradiction-resolver.d.ts +0 -40
  177. package/dist/core/memory/contradiction-resolver.js +0 -368
  178. package/dist/core/memory/edit-workflow.d.ts +0 -19
  179. package/dist/core/memory/edit-workflow.js +0 -120
  180. package/dist/core/memory/entity-extractor.d.ts +0 -37
  181. package/dist/core/memory/entity-extractor.js +0 -350
  182. package/dist/core/memory/entity-resolver.d.ts +0 -23
  183. package/dist/core/memory/entity-resolver.js +0 -64
  184. package/dist/core/memory/explain.d.ts +0 -18
  185. package/dist/core/memory/explain.js +0 -92
  186. package/dist/core/memory/fact-deriver.d.ts +0 -31
  187. package/dist/core/memory/fact-deriver.js +0 -236
  188. package/dist/core/memory/fact-extractor.d.ts +0 -24
  189. package/dist/core/memory/fact-extractor.js +0 -89
  190. package/dist/core/memory/feedback-tracker.d.ts +0 -12
  191. package/dist/core/memory/feedback-tracker.js +0 -155
  192. package/dist/core/memory/hooks.d.ts +0 -88
  193. package/dist/core/memory/hooks.js +0 -174
  194. package/dist/core/memory/hybrid-retrieval.d.ts +0 -27
  195. package/dist/core/memory/hybrid-retrieval.js +0 -37
  196. package/dist/core/memory/hybrid-scorer.d.ts +0 -40
  197. package/dist/core/memory/hybrid-scorer.js +0 -267
  198. package/dist/core/memory/hybrid-search.d.ts +0 -23
  199. package/dist/core/memory/hybrid-search.js +0 -596
  200. package/dist/core/memory/importance.d.ts +0 -46
  201. package/dist/core/memory/importance.js +0 -241
  202. package/dist/core/memory/index.d.ts +0 -9
  203. package/dist/core/memory/index.js +0 -11
  204. package/dist/core/memory/loader.d.ts +0 -31
  205. package/dist/core/memory/loader.js +0 -141
  206. package/dist/core/memory/markdown/markdown-storage.d.ts +0 -72
  207. package/dist/core/memory/markdown/markdown-storage.js +0 -243
  208. package/dist/core/memory/memories.d.ts +0 -43
  209. package/dist/core/memory/memories.js +0 -452
  210. package/dist/core/memory/memory-lifecycle.d.ts +0 -8
  211. package/dist/core/memory/memory-lifecycle.js +0 -47
  212. package/dist/core/memory/memory-manager.d.ts +0 -15
  213. package/dist/core/memory/memory-manager.js +0 -46
  214. package/dist/core/memory/migrate.d.ts +0 -21
  215. package/dist/core/memory/migrate.js +0 -134
  216. package/dist/core/memory/normalization.d.ts +0 -7
  217. package/dist/core/memory/normalization.js +0 -26
  218. package/dist/core/memory/path-strengthener.d.ts +0 -39
  219. package/dist/core/memory/path-strengthener.js +0 -150
  220. package/dist/core/memory/progressive-disclosure.d.ts +0 -43
  221. package/dist/core/memory/progressive-disclosure.js +0 -280
  222. package/dist/core/memory/query-processor.d.ts +0 -21
  223. package/dist/core/memory/query-processor.js +0 -106
  224. package/dist/core/memory/query-rewriter.d.ts +0 -13
  225. package/dist/core/memory/query-rewriter.js +0 -118
  226. package/dist/core/memory/response-analyzer.d.ts +0 -9
  227. package/dist/core/memory/response-analyzer.js +0 -61
  228. package/dist/core/memory/retrieval-feedback.d.ts +0 -70
  229. package/dist/core/memory/retrieval-feedback.js +0 -213
  230. package/dist/core/memory/serialization.d.ts +0 -10
  231. package/dist/core/memory/serialization.js +0 -84
  232. package/dist/core/memory/stale-cleaner.d.ts +0 -26
  233. package/dist/core/memory/stale-cleaner.js +0 -97
  234. package/dist/core/memory/stats.d.ts +0 -32
  235. package/dist/core/memory/stats.js +0 -143
  236. package/dist/core/memory/telemetry.d.ts +0 -69
  237. package/dist/core/memory/telemetry.js +0 -313
  238. package/dist/core/memory/temporal-facts.d.ts +0 -41
  239. package/dist/core/memory/temporal-facts.js +0 -283
  240. package/dist/core/memory/temporal-parser.d.ts +0 -32
  241. package/dist/core/memory/temporal-parser.js +0 -385
  242. package/dist/core/memory/trigger-detector.d.ts +0 -21
  243. package/dist/core/memory/trigger-detector.js +0 -79
  244. package/dist/core/memory/write-gate.d.ts +0 -54
  245. package/dist/core/memory/write-gate.js +0 -210
  246. package/dist/core/places/index.d.ts +0 -14
  247. package/dist/core/places/index.js +0 -14
  248. package/dist/core/places/memory-places.d.ts +0 -68
  249. package/dist/core/places/memory-places.js +0 -261
  250. package/dist/core/places/places.d.ts +0 -88
  251. package/dist/core/places/places.js +0 -314
  252. package/dist/core/places/rules.d.ts +0 -74
  253. package/dist/core/places/rules.js +0 -240
  254. package/dist/core/places/walking.d.ts +0 -56
  255. package/dist/core/places/walking.js +0 -121
  256. package/dist/core/projects.d.ts +0 -17
  257. package/dist/core/projects.js +0 -116
  258. package/dist/core/redis.d.ts +0 -11
  259. package/dist/core/redis.js +0 -69
  260. package/dist/core/responses.d.ts +0 -96
  261. package/dist/core/responses.js +0 -122
  262. package/dist/core/runtime/trust-report.d.ts +0 -102
  263. package/dist/core/runtime/trust-report.js +0 -107
  264. package/dist/core/runtime/trust-state.d.ts +0 -12
  265. package/dist/core/runtime/trust-state.js +0 -309
  266. package/dist/core/scheduler/cron-scheduler.d.ts +0 -32
  267. package/dist/core/scheduler/cron-scheduler.js +0 -493
  268. package/dist/core/scheduler/heartbeat.d.ts +0 -11
  269. package/dist/core/scheduler/heartbeat.js +0 -73
  270. package/dist/core/scheduler/index.d.ts +0 -8
  271. package/dist/core/scheduler/index.js +0 -8
  272. package/dist/core/scheduler/job-runner.d.ts +0 -11
  273. package/dist/core/scheduler/job-runner.js +0 -164
  274. package/dist/core/search/conversations.d.ts +0 -25
  275. package/dist/core/search/conversations.js +0 -110
  276. package/dist/core/search/entities.d.ts +0 -12
  277. package/dist/core/search/entities.js +0 -31
  278. package/dist/core/search/folder-context.d.ts +0 -25
  279. package/dist/core/search/folder-context.js +0 -119
  280. package/dist/core/search/graph-boost.d.ts +0 -7
  281. package/dist/core/search/graph-boost.js +0 -23
  282. package/dist/core/search/index.d.ts +0 -4
  283. package/dist/core/search/index.js +0 -5
  284. package/dist/core/search/qmd-wrapper.d.ts +0 -36
  285. package/dist/core/search/qmd-wrapper.js +0 -58
  286. package/dist/core/security/encrypt.d.ts +0 -6
  287. package/dist/core/security/encrypt.js +0 -47
  288. package/dist/core/security/governance.d.ts +0 -26
  289. package/dist/core/security/governance.js +0 -79
  290. package/dist/core/security/privacy.d.ts +0 -23
  291. package/dist/core/security/privacy.js +0 -82
  292. package/dist/core/security/secret-detector.d.ts +0 -32
  293. package/dist/core/security/secret-detector.js +0 -88
  294. package/dist/core/session/auto-load.d.ts +0 -6
  295. package/dist/core/session/auto-load.js +0 -144
  296. package/dist/core/session/entity-tracker.d.ts +0 -62
  297. package/dist/core/session/entity-tracker.js +0 -287
  298. package/dist/core/session/index.d.ts +0 -7
  299. package/dist/core/session/index.js +0 -7
  300. package/dist/core/session/reference-resolver.d.ts +0 -26
  301. package/dist/core/session/reference-resolver.js +0 -121
  302. package/dist/core/session/self-iteration-job.d.ts +0 -35
  303. package/dist/core/session/self-iteration-job.js +0 -387
  304. package/dist/core/session/session-hooks.d.ts +0 -18
  305. package/dist/core/session/session-hooks.js +0 -58
  306. package/dist/core/session/types.d.ts +0 -26
  307. package/dist/core/session/types.js +0 -10
  308. package/dist/core/session/working-set.d.ts +0 -50
  309. package/dist/core/session/working-set.js +0 -212
  310. package/dist/core/snapshots/cleanup.d.ts +0 -9
  311. package/dist/core/snapshots/cleanup.js +0 -12
  312. package/dist/core/snapshots/comparison.d.ts +0 -19
  313. package/dist/core/snapshots/comparison.js +0 -43
  314. package/dist/core/snapshots/creation.d.ts +0 -13
  315. package/dist/core/snapshots/creation.js +0 -117
  316. package/dist/core/snapshots/retrieval.d.ts +0 -7
  317. package/dist/core/snapshots/retrieval.js +0 -41
  318. package/dist/core/snapshots/stats.d.ts +0 -11
  319. package/dist/core/snapshots/stats.js +0 -52
  320. package/dist/core/storage/cache.d.ts +0 -13
  321. package/dist/core/storage/cache.js +0 -202
  322. package/dist/core/storage/database.d.ts +0 -12
  323. package/dist/core/storage/database.js +0 -12
  324. package/dist/core/summarization/cleanup.d.ts +0 -9
  325. package/dist/core/summarization/cleanup.js +0 -12
  326. package/dist/core/summarization/queries.d.ts +0 -9
  327. package/dist/core/summarization/queries.js +0 -28
  328. package/dist/core/summarization/stats.d.ts +0 -14
  329. package/dist/core/summarization/stats.js +0 -52
  330. package/dist/core/summarization/strategies.d.ts +0 -24
  331. package/dist/core/summarization/strategies.js +0 -28
  332. package/dist/core/summarization.d.ts +0 -37
  333. package/dist/core/summarization.js +0 -188
  334. package/dist/core/temporal-facts.d.ts +0 -54
  335. package/dist/core/temporal-facts.js +0 -193
  336. package/dist/core/tracing/collector.d.ts +0 -111
  337. package/dist/core/tracing/collector.js +0 -350
  338. package/dist/core/tracing/visualizer.d.ts +0 -32
  339. package/dist/core/tracing/visualizer.js +0 -165
  340. package/dist/core/utils/cleanup-operations.d.ts +0 -13
  341. package/dist/core/utils/cleanup-operations.js +0 -44
  342. package/dist/core/utils/content-extraction.d.ts +0 -19
  343. package/dist/core/utils/content-extraction.js +0 -75
  344. package/dist/core/utils/filter-builder.d.ts +0 -13
  345. package/dist/core/utils/filter-builder.js +0 -44
  346. package/dist/core/utils/history-traversal.d.ts +0 -13
  347. package/dist/core/utils/history-traversal.js +0 -50
  348. package/dist/core/utils/memory-operations.d.ts +0 -17
  349. package/dist/core/utils/memory-operations.js +0 -43
  350. package/dist/core/utils/query-operations.d.ts +0 -18
  351. package/dist/core/utils/query-operations.js +0 -65
  352. package/dist/core/utils/summarization-helpers.d.ts +0 -17
  353. package/dist/core/utils/summarization-helpers.js +0 -33
  354. package/dist/core/utils/temporal-queries.d.ts +0 -13
  355. package/dist/core/utils/temporal-queries.js +0 -27
  356. package/dist/core/utils/vector-operations.d.ts +0 -71
  357. package/dist/core/utils/vector-operations.js +0 -129
  358. package/dist/core/utils/version-management.d.ts +0 -9
  359. package/dist/core/utils/version-management.js +0 -61
  360. package/dist/core/worker.d.ts +0 -82
  361. package/dist/core/worker.js +0 -272
  362. package/dist/db/adapter.d.ts +0 -7
  363. package/dist/db/adapter.js +0 -175
  364. package/dist/db/bootstrap.d.ts +0 -11
  365. package/dist/db/bootstrap.js +0 -1034
  366. package/dist/db/drizzle/schema-sqlite.d.ts +0 -5538
  367. package/dist/db/drizzle/schema-sqlite.js +0 -763
  368. package/dist/db/drizzle/schema.d.ts +0 -4734
  369. package/dist/db/drizzle/schema.js +0 -859
  370. package/dist/db/drizzle.config.d.ts +0 -3
  371. package/dist/db/drizzle.config.js +0 -12
  372. package/dist/db/index.d.ts +0 -7
  373. package/dist/db/index.js +0 -89
  374. package/dist/db/migrations/associations.d.ts +0 -6
  375. package/dist/db/migrations/associations.js +0 -29
  376. package/dist/db/migrations/beliefs.d.ts +0 -10
  377. package/dist/db/migrations/beliefs.js +0 -76
  378. package/dist/db/migrations/core-memory.d.ts +0 -6
  379. package/dist/db/migrations/core-memory.js +0 -29
  380. package/dist/db/migrations/fts.d.ts +0 -6
  381. package/dist/db/migrations/fts.js +0 -52
  382. package/dist/db/migrations/index.d.ts +0 -25
  383. package/dist/db/migrations/index.js +0 -51
  384. package/dist/db/migrations/indexes.d.ts +0 -6
  385. package/dist/db/migrations/indexes.js +0 -30
  386. package/dist/db/migrations/learnings.d.ts +0 -7
  387. package/dist/db/migrations/learnings.js +0 -26
  388. package/dist/db/migrations/maintenance.d.ts +0 -6
  389. package/dist/db/migrations/maintenance.js +0 -61
  390. package/dist/db/migrations/memories.d.ts +0 -7
  391. package/dist/db/migrations/memories.js +0 -16
  392. package/dist/db/migrations/memory-places.d.ts +0 -6
  393. package/dist/db/migrations/memory-places.js +0 -29
  394. package/dist/db/migrations/places.d.ts +0 -6
  395. package/dist/db/migrations/places.js +0 -43
  396. package/dist/db/migrations/projects.d.ts +0 -3
  397. package/dist/db/migrations/projects.js +0 -13
  398. package/dist/db/migrations/tier-conversion.d.ts +0 -7
  399. package/dist/db/migrations/tier-conversion.js +0 -20
  400. package/dist/db/neon.d.ts +0 -8
  401. package/dist/db/neon.js +0 -20
  402. package/dist/db/schema/beliefs.d.ts +0 -9
  403. package/dist/db/schema/beliefs.js +0 -46
  404. package/dist/db/schema/generator.d.ts +0 -38
  405. package/dist/db/schema/generator.js +0 -108
  406. package/dist/db/schema/index.d.ts +0 -39
  407. package/dist/db/schema/index.js +0 -51
  408. package/dist/db/schema/learnings.d.ts +0 -7
  409. package/dist/db/schema/learnings.js +0 -30
  410. package/dist/db/schema/memories.d.ts +0 -7
  411. package/dist/db/schema/memories.js +0 -81
  412. package/dist/db/schema/projects.d.ts +0 -4
  413. package/dist/db/schema/projects.js +0 -31
  414. package/dist/db/schema/tables/context-sessions.d.ts +0 -9
  415. package/dist/db/schema/tables/context-sessions.js +0 -37
  416. package/dist/db/schema/tables/conversations.d.ts +0 -9
  417. package/dist/db/schema/tables/conversations.js +0 -47
  418. package/dist/db/schema/tables/core-memory.d.ts +0 -9
  419. package/dist/db/schema/tables/core-memory.js +0 -41
  420. package/dist/db/schema/tables/entities.d.ts +0 -9
  421. package/dist/db/schema/tables/entities.js +0 -39
  422. package/dist/db/schema/tables/entity-relations.d.ts +0 -9
  423. package/dist/db/schema/tables/entity-relations.js +0 -31
  424. package/dist/db/schema/tables/learnings.d.ts +0 -9
  425. package/dist/db/schema/tables/learnings.js +0 -66
  426. package/dist/db/schema/tables/memories.d.ts +0 -9
  427. package/dist/db/schema/tables/memories.js +0 -161
  428. package/dist/db/schema/tables/memory-associations.d.ts +0 -9
  429. package/dist/db/schema/tables/memory-associations.js +0 -39
  430. package/dist/db/schema/tables/memory-hash-cache.d.ts +0 -9
  431. package/dist/db/schema/tables/memory-hash-cache.js +0 -29
  432. package/dist/db/schema/tables/memory-merge-history.d.ts +0 -9
  433. package/dist/db/schema/tables/memory-merge-history.js +0 -33
  434. package/dist/db/schema/tables/memory-merge-proposals.d.ts +0 -9
  435. package/dist/db/schema/tables/memory-merge-proposals.js +0 -39
  436. package/dist/db/schema/tables/messages.d.ts +0 -9
  437. package/dist/db/schema/tables/messages.js +0 -41
  438. package/dist/db/schema/tables/namespaces.d.ts +0 -9
  439. package/dist/db/schema/tables/namespaces.js +0 -37
  440. package/dist/db/schema/tables/projects.d.ts +0 -9
  441. package/dist/db/schema/tables/projects.js +0 -31
  442. package/dist/db/schema/tables/users.d.ts +0 -9
  443. package/dist/db/schema/tables/users.js +0 -27
  444. package/dist/db/schema.d.ts +0 -3
  445. package/dist/db/schema.js +0 -11
  446. package/dist/db/supabase.d.ts +0 -9
  447. package/dist/db/supabase.js +0 -24
  448. package/dist/packages/mcp/src/index.d.ts +0 -3
  449. package/dist/packages/mcp/src/index.js +0 -733
@@ -1,210 +0,0 @@
1
- /**
2
- * Write Gate Enforcement
3
- * Validates memories before writing to ensure quality, security, and consistency
4
- * Integrates secret detection, trigger detection, and content validation
5
- */
6
- import { detectSecrets, redactSecrets } from '../security/secret-detector.js';
7
- import { detectMemorySignals } from './trigger-detector.js';
8
- import { resolveContradictions } from './contradiction-resolver.js';
9
- import { logger } from '../logger.js';
10
- const DEFAULT_OPTIONS = {
11
- allowSecrets: false,
12
- minContentLength: 5,
13
- maxContentLength: 50000,
14
- skipContradictionCheck: false,
15
- skipTemporalSupersession: false,
16
- };
17
- /**
18
- * Main write gate function - validates and sanitizes content before write
19
- */
20
- export async function enforceWriteGate(content, type, options = {}) {
21
- const opts = { ...DEFAULT_OPTIONS, ...options };
22
- const result = {
23
- allowed: true,
24
- sanitized: false,
25
- warnings: [],
26
- errors: [],
27
- metadata: {
28
- secretsDetected: 0,
29
- signals: null,
30
- contradictions: { found: false, count: 0 },
31
- temporalSupersession: { count: 0 },
32
- },
33
- };
34
- let processedContent = content;
35
- // 1. Content length validation
36
- if (content.length < opts.minContentLength) {
37
- result.errors.push(`Content too short (min ${opts.minContentLength} characters)`);
38
- result.allowed = false;
39
- return result;
40
- }
41
- if (content.length > opts.maxContentLength) {
42
- result.errors.push(`Content too long (max ${opts.maxContentLength} characters)`);
43
- result.allowed = false;
44
- return result;
45
- }
46
- // 2. Secret detection
47
- const secrets = detectSecrets(content, 'high');
48
- result.metadata.secretsDetected = secrets.length;
49
- if (secrets.length > 0) {
50
- const secretTypes = [...new Set(secrets.map(s => s.type))];
51
- if (!opts.allowSecrets) {
52
- result.errors.push(`Potential secrets detected: ${secretTypes.join(', ')}`);
53
- result.warnings.push('Content contains sensitive data that must be redacted');
54
- result.allowed = false;
55
- return result;
56
- }
57
- else {
58
- // Redact secrets but allow write
59
- processedContent = redactSecrets(content);
60
- result.sanitized = true;
61
- result.sanitizedContent = processedContent;
62
- result.warnings.push(`Redacted ${secrets.length} potential secrets: ${secretTypes.join(', ')}`);
63
- }
64
- }
65
- // 3. Memory signals detection
66
- const signals = detectMemorySignals(content);
67
- result.metadata.signals = signals;
68
- // Add warnings for high-priority signals
69
- if (signals.priority === 'high') {
70
- result.warnings.push('High-priority memory signal detected');
71
- }
72
- if (signals.implicit.correction) {
73
- result.warnings.push('Content appears to be a correction - contradiction check recommended');
74
- }
75
- // 4. Contradiction detection (async, non-blocking for write)
76
- if (!opts.skipContradictionCheck && signals.implicit.correction) {
77
- try {
78
- const contradictionResult = await resolveContradictions(processedContent, type, opts.projectId);
79
- result.metadata.contradictions = {
80
- found: contradictionResult.supersededIds.length > 0,
81
- count: contradictionResult.supersededIds.length,
82
- };
83
- if (contradictionResult.supersededIds.length > 0) {
84
- result.warnings.push(`This memory supersedes ${contradictionResult.supersededIds.length} older memories`);
85
- }
86
- }
87
- catch (error) {
88
- logger.error('Contradiction check failed', error);
89
- result.warnings.push('Contradiction check failed - proceeding with write');
90
- }
91
- }
92
- // 5. Temporal fact handling
93
- if (!opts.skipTemporalSupersession) {
94
- try {
95
- // This would be done after the memory is actually written, but we note it here
96
- result.metadata.temporalSupersession = { count: 0 };
97
- }
98
- catch (error) {
99
- logger.error('Temporal check failed', error);
100
- }
101
- }
102
- // 6. Content quality checks
103
- const qualityIssues = checkContentQuality(processedContent);
104
- result.warnings.push(...qualityIssues);
105
- return result;
106
- }
107
- /**
108
- * Quick validation without async operations
109
- * Use for fast pre-check before full validation
110
- */
111
- export function quickValidate(content) {
112
- const errors = [];
113
- // Check for empty or whitespace-only content
114
- if (!content || content.trim().length === 0) {
115
- errors.push('Content is empty');
116
- return { valid: false, errors };
117
- }
118
- // Check for minimum length
119
- if (content.trim().length < 5) {
120
- errors.push('Content is too short');
121
- }
122
- // Check for obvious secrets (high confidence only)
123
- const secrets = detectSecrets(content, 'high');
124
- if (secrets.length > 0) {
125
- errors.push(`Content contains ${secrets.length} potential secrets`);
126
- }
127
- return { valid: errors.length === 0, errors };
128
- }
129
- /**
130
- * Check content quality and return warnings
131
- */
132
- function checkContentQuality(content) {
133
- const warnings = [];
134
- // Check for excessive repetition
135
- const words = content.toLowerCase().split(/\s+/);
136
- const wordCounts = new Map();
137
- for (const word of words) {
138
- if (word.length > 3) { // Only check meaningful words
139
- wordCounts.set(word, (wordCounts.get(word) || 0) + 1);
140
- }
141
- }
142
- for (const [word, count] of wordCounts.entries()) {
143
- if (count > 10) {
144
- warnings.push(`Excessive repetition detected: "${word}" appears ${count} times`);
145
- break; // Only report one
146
- }
147
- }
148
- // Check for very long lines (might be code or minified content)
149
- const lines = content.split('\n');
150
- for (const line of lines) {
151
- if (line.length > 1000) {
152
- warnings.push('Content contains very long lines - may not be human-readable');
153
- break;
154
- }
155
- }
156
- // Check for binary-like content
157
- const binaryPattern = /[\x00-\x08\x0E-\x1F]/;
158
- if (binaryPattern.test(content)) {
159
- warnings.push('Content may contain binary data');
160
- }
161
- return warnings;
162
- }
163
- /**
164
- * Sanitize content for storage
165
- * Redacts secrets and normalizes whitespace
166
- */
167
- export function sanitizeForStorage(content) {
168
- // Redact secrets
169
- let sanitized = redactSecrets(content);
170
- // Normalize excessive whitespace
171
- sanitized = sanitized.replace(/\n{3,}/g, '\n\n');
172
- sanitized = sanitized.replace(/ {2,}/g, ' ');
173
- // Trim
174
- sanitized = sanitized.trim();
175
- return sanitized;
176
- }
177
- /**
178
- * Calculate a quality score for content (0-100)
179
- */
180
- export function calculateContentQualityScore(content) {
181
- let score = 100;
182
- // Deduct for short content
183
- if (content.length < 20) {
184
- score -= 30;
185
- }
186
- else if (content.length < 50) {
187
- score -= 15;
188
- }
189
- // Deduct for secrets
190
- const secrets = detectSecrets(content, 'high');
191
- score -= secrets.length * 20;
192
- // Deduct for repetition
193
- const words = content.toLowerCase().split(/\s+/);
194
- const uniqueWords = new Set(words.filter(w => w.length > 3));
195
- const repetitionRatio = uniqueWords.size / Math.max(1, words.length);
196
- if (repetitionRatio < 0.3) {
197
- score -= 20;
198
- }
199
- // Bonus for structure (sentences, punctuation)
200
- const sentences = content.split(/[.!?]+/).filter(s => s.trim().length > 0);
201
- if (sentences.length > 1) {
202
- score += 10;
203
- }
204
- // Bonus for reasonable length
205
- if (content.length >= 50 && content.length <= 2000) {
206
- score += 5;
207
- }
208
- return Math.max(0, Math.min(100, score));
209
- }
210
- //# sourceMappingURL=write-gate.js.map
@@ -1,14 +0,0 @@
1
- /**
2
- * Places Module - Spatial memory organization
3
- *
4
- * Exports:
5
- * - places.ts: CRUD operations for places
6
- * - rules.ts: Auto-assignment rules engine
7
- * - memory-places.ts: Memory-to-place assignments
8
- * - walking.ts: Sequential walking through places
9
- */
10
- export * from './places.js';
11
- export * from './rules.js';
12
- export * from './memory-places.js';
13
- export * from './walking.js';
14
- //# sourceMappingURL=index.d.ts.map
@@ -1,14 +0,0 @@
1
- /**
2
- * Places Module - Spatial memory organization
3
- *
4
- * Exports:
5
- * - places.ts: CRUD operations for places
6
- * - rules.ts: Auto-assignment rules engine
7
- * - memory-places.ts: Memory-to-place assignments
8
- * - walking.ts: Sequential walking through places
9
- */
10
- export * from './places.js';
11
- export * from './rules.js';
12
- export * from './memory-places.js';
13
- export * from './walking.js';
14
- //# sourceMappingURL=index.js.map
@@ -1,68 +0,0 @@
1
- /**
2
- * Memory-Place Assignments - Assign memories to places
3
- *
4
- * Handles the assignment of memories to places, both:
5
- * - Auto-assignment via rules
6
- * - Manual assignment by users
7
- */
8
- import type { PlaceType } from './places.js';
9
- /**
10
- * Assign a memory to a place (auto or manual)
11
- */
12
- export declare function assignMemoryToPlace(params: {
13
- memoryId: string;
14
- placeId: string;
15
- isManual?: boolean;
16
- ruleId?: string;
17
- }): Promise<boolean>;
18
- /**
19
- * Auto-assign a memory based on rules
20
- */
21
- export declare function autoAssignMemory(params: {
22
- memoryId: string;
23
- projectId: string;
24
- toolName?: string;
25
- content?: string;
26
- tags?: string[];
27
- memoryType?: string;
28
- }): Promise<{
29
- assigned: boolean;
30
- placeId?: string;
31
- placeType?: PlaceType;
32
- }>;
33
- /**
34
- * Manually assign a memory to a place
35
- */
36
- export declare function manualAssignMemory(params: {
37
- memoryId: string;
38
- projectId: string;
39
- placeType: PlaceType;
40
- }): Promise<boolean>;
41
- /**
42
- * Get place for a memory
43
- */
44
- export declare function getMemoryPlace(memoryId: string): Promise<string | null>;
45
- /**
46
- * Get memories for a place
47
- */
48
- export declare function getPlaceMemories(placeId: string, limit?: number): Promise<string[]>;
49
- /**
50
- * Remove memory from place
51
- */
52
- export declare function removeMemoryFromPlace(memoryId: string): Promise<boolean>;
53
- /**
54
- * Initialize memory-place for a project (ensures all memories without places get assigned)
55
- */
56
- export declare function initializeProjectPlaces(projectId: string): Promise<{
57
- initialized: number;
58
- assigned: number;
59
- }>;
60
- /**
61
- * Auto-archive old memories - move memories > 30 days from active places to Archive
62
- * Keeps active places lean and organized
63
- */
64
- export declare function autoArchiveOldMemories(projectId: string, daysOld?: number): Promise<{
65
- archived: number;
66
- failed: number;
67
- }>;
68
- //# sourceMappingURL=memory-places.d.ts.map
@@ -1,261 +0,0 @@
1
- /**
2
- * Memory-Place Assignments - Assign memories to places
3
- *
4
- * Handles the assignment of memories to places, both:
5
- * - Auto-assignment via rules
6
- * - Manual assignment by users
7
- */
8
- import { randomUUID } from 'crypto';
9
- import { eq, and } from 'drizzle-orm';
10
- import { getDb } from '../../db/index.js';
11
- import { getSchema } from '../../db/schema.js';
12
- import { logger } from '../logger.js';
13
- import { getPlaceByType, updatePlaceMemoryCount } from './places.js';
14
- import { findMatchingPlace } from './rules.js';
15
- /**
16
- * Assign a memory to a place (auto or manual)
17
- */
18
- export async function assignMemoryToPlace(params) {
19
- const db = await getDb();
20
- if (!db)
21
- return false;
22
- const schema = await getSchema();
23
- const sqliteDb = db;
24
- const id = randomUUID();
25
- // Check if already assigned
26
- const existing = await sqliteDb.select()
27
- .from(schema.memoryPlaces)
28
- .where(eq(schema.memoryPlaces.memoryId, params.memoryId))
29
- .limit(1);
30
- if (existing.length > 0) {
31
- // Update existing
32
- await sqliteDb.update(schema.memoryPlaces)
33
- .set({
34
- placeId: params.placeId,
35
- isManual: params.isManual ? 1 : 0,
36
- ruleId: params.ruleId || null,
37
- })
38
- .where(eq(schema.memoryPlaces.memoryId, params.memoryId));
39
- }
40
- else {
41
- // Insert new
42
- await sqliteDb.insert(schema.memoryPlaces).values({
43
- id,
44
- memoryId: params.memoryId,
45
- placeId: params.placeId,
46
- isManual: params.isManual ? 1 : 0,
47
- ruleId: params.ruleId || null,
48
- });
49
- }
50
- // Update memory's place reference
51
- await sqliteDb.update(schema.memories)
52
- .set({ placeId: params.placeId })
53
- .where(eq(schema.memories.id, params.memoryId));
54
- // Update place memory count
55
- await updatePlaceMemoryCount(params.placeId);
56
- logger.info(`[MemoryPlaces] Assigned memory ${params.memoryId} to place ${params.placeId}`);
57
- return true;
58
- }
59
- /**
60
- * Auto-assign a memory based on rules
61
- */
62
- export async function autoAssignMemory(params) {
63
- const { memoryId, projectId, toolName, content, tags, memoryType } = params;
64
- // Find matching place via rules
65
- const placeType = await findMatchingPlace(projectId, {
66
- toolName,
67
- content,
68
- tags,
69
- memoryType,
70
- });
71
- if (!placeType) {
72
- logger.info(`[MemoryPlaces] No matching rule for memory ${memoryId}`);
73
- return { assigned: false };
74
- }
75
- // Get the place
76
- const place = await getPlaceByType(projectId, placeType);
77
- if (!place) {
78
- logger.warn(`[MemoryPlaces] Place not found: ${placeType}`);
79
- return { assigned: false };
80
- }
81
- // Assign
82
- const success = await assignMemoryToPlace({
83
- memoryId,
84
- placeId: place.id,
85
- isManual: false,
86
- });
87
- return {
88
- assigned: success,
89
- placeId: place.id,
90
- placeType,
91
- };
92
- }
93
- /**
94
- * Manually assign a memory to a place
95
- */
96
- export async function manualAssignMemory(params) {
97
- const { memoryId, projectId, placeType } = params;
98
- // Get the place by type
99
- const place = await getPlaceByType(projectId, placeType);
100
- if (!place) {
101
- logger.warn(`[MemoryPlaces] Place not found: ${placeType}`);
102
- return false;
103
- }
104
- return assignMemoryToPlace({
105
- memoryId,
106
- placeId: place.id,
107
- isManual: true,
108
- });
109
- }
110
- /**
111
- * Get place for a memory
112
- */
113
- export async function getMemoryPlace(memoryId) {
114
- const db = await getDb();
115
- if (!db)
116
- return null;
117
- const schema = await getSchema();
118
- const sqliteDb = db;
119
- const result = await sqliteDb.select()
120
- .from(schema.memoryPlaces)
121
- .where(eq(schema.memoryPlaces.memoryId, memoryId))
122
- .limit(1);
123
- return result.length > 0 ? result[0].place_id : null;
124
- }
125
- /**
126
- * Get memories for a place
127
- */
128
- export async function getPlaceMemories(placeId, limit = 50) {
129
- const db = await getDb();
130
- if (!db)
131
- return [];
132
- const schema = await getSchema();
133
- const sqliteDb = db;
134
- const results = await sqliteDb.select({ memoryId: schema.memoryPlaces.memoryId })
135
- .from(schema.memoryPlaces)
136
- .where(eq(schema.memoryPlaces.placeId, placeId))
137
- .limit(limit);
138
- return results.map((r) => r.memoryId);
139
- }
140
- /**
141
- * Remove memory from place
142
- */
143
- export async function removeMemoryFromPlace(memoryId) {
144
- const db = await getDb();
145
- if (!db)
146
- return false;
147
- const schema = await getSchema();
148
- const sqliteDb = db;
149
- // Get the place before deleting
150
- const existing = await sqliteDb.select()
151
- .from(schema.memoryPlaces)
152
- .where(eq(schema.memoryPlaces.memoryId, memoryId))
153
- .limit(1);
154
- if (existing.length > 0) {
155
- const oldPlaceId = existing[0].place_id;
156
- // Delete assignment
157
- await sqliteDb.delete(schema.memoryPlaces)
158
- .where(eq(schema.memoryPlaces.memoryId, memoryId));
159
- // Clear memory's place reference
160
- await sqliteDb.update(schema.memories)
161
- .set({ placeId: null })
162
- .where(eq(schema.memories.id, memoryId));
163
- // Update old place memory count
164
- await updatePlaceMemoryCount(oldPlaceId);
165
- logger.info(`[MemoryPlaces] Removed memory ${memoryId} from place ${oldPlaceId}`);
166
- }
167
- return true;
168
- }
169
- /**
170
- * Initialize memory-place for a project (ensures all memories without places get assigned)
171
- */
172
- export async function initializeProjectPlaces(projectId) {
173
- const db = await getDb();
174
- if (!db)
175
- return { initialized: 0, assigned: 0 };
176
- const schema = await getSchema();
177
- const sqliteDb = db;
178
- // Get all memories without a place_id
179
- const memoriesWithoutPlace = await sqliteDb.select({ id: schema.memories.id })
180
- .from(schema.memories)
181
- .where(and(eq(schema.memories.projectId, projectId)));
182
- let assigned = 0;
183
- for (const mem of memoriesWithoutPlace) {
184
- const result = await autoAssignMemory({
185
- memoryId: mem.id,
186
- projectId,
187
- memoryType: 'observation',
188
- });
189
- if (result.assigned)
190
- assigned++;
191
- }
192
- logger.info(`[MemoryPlaces] Initialized places for project ${projectId}: ${assigned} assigned`);
193
- return { initialized: memoriesWithoutPlace.length, assigned };
194
- }
195
- /**
196
- * Auto-archive old memories - move memories > 30 days from active places to Archive
197
- * Keeps active places lean and organized
198
- */
199
- export async function autoArchiveOldMemories(projectId, daysOld = 30) {
200
- const db = await getDb();
201
- if (!db)
202
- return { archived: 0, failed: 0 };
203
- const schema = await getSchema();
204
- const sqliteDb = db;
205
- // Get the Archive place
206
- const archivePlace = await getPlaceByType(projectId, 'archive');
207
- if (!archivePlace) {
208
- logger.warn(`[MemoryPlaces] Archive place not found for project ${projectId}`);
209
- return { archived: 0, failed: 0 };
210
- }
211
- // Calculate cutoff date (Unix timestamp for SQLite)
212
- const cutoffDate = new Date();
213
- cutoffDate.setDate(cutoffDate.getDate() - daysOld);
214
- const cutoffTimestamp = Math.floor(cutoffDate.getTime() / 1000);
215
- // Get all active place IDs (not archive)
216
- const allPlaces = await sqliteDb.select()
217
- .from(schema.places)
218
- .where(eq(schema.places.projectId, projectId));
219
- const activePlaceIds = allPlaces
220
- .filter((p) => p.place_type !== 'archive')
221
- .map((p) => p.id);
222
- if (activePlaceIds.length === 0) {
223
- return { archived: 0, failed: 0 };
224
- }
225
- // Find memories in active places that are older than cutoff
226
- // Use raw SQL for complex date comparison
227
- const oldMemories = await sqliteDb.select({
228
- memoryId: schema.memories.id,
229
- placeId: schema.memoryPlaces.placeId,
230
- createdAt: schema.memories.createdAt,
231
- })
232
- .from(schema.memories)
233
- .innerJoin(schema.memoryPlaces, eq(schema.memories.id, schema.memoryPlaces.memoryId))
234
- .where(and(eq(schema.memories.projectId, projectId)));
235
- // Actually filter in JS for simplicity
236
- const memoriesToArchive = oldMemories.filter((m) => activePlaceIds.includes(m.placeId) && m.createdAt < cutoffTimestamp);
237
- let archived = 0;
238
- let failed = 0;
239
- for (const mem of memoriesToArchive) {
240
- try {
241
- // Move to archive place
242
- await sqliteDb.update(schema.memoryPlaces)
243
- .set({ placeId: archivePlace.id })
244
- .where(eq(schema.memoryPlaces.memoryId, mem.memoryId));
245
- // Update the old place's memory count
246
- await updatePlaceMemoryCount(mem.placeId);
247
- archived++;
248
- }
249
- catch (e) {
250
- logger.warn(`[MemoryPlaces] Failed to archive memory ${mem.memoryId}: ${e}`);
251
- failed++;
252
- }
253
- }
254
- // Update archive place memory count
255
- if (archived > 0) {
256
- await updatePlaceMemoryCount(archivePlace.id);
257
- logger.info(`[MemoryPlaces] Archived ${archived} old memories to Archive place`);
258
- }
259
- return { archived, failed };
260
- }
261
- //# sourceMappingURL=memory-places.js.map
@@ -1,88 +0,0 @@
1
- /**
2
- * Places Module - Spatial memory organization
3
- *
4
- * Provides spatial "places" for memory organization:
5
- * - Inbox: New memories, unprocessed
6
- * - Ref: Reference, patterns, research
7
- * - WIP: Active work, implementations
8
- * - Sandbox: Experiments, tests
9
- * - Board: Decisions, planning, roadmap
10
- * - Sparks: Ideas, future concepts
11
- * - Archive: Completed, historical
12
- */
13
- export type PlaceType = 'inbox' | 'ref' | 'wip' | 'sandbox' | 'board' | 'sparks' | 'archive';
14
- export interface Place {
15
- id: string;
16
- projectId: string;
17
- name: string;
18
- placeType: PlaceType;
19
- parentId: string | null;
20
- sortOrder: number;
21
- positionX: number;
22
- positionY: number;
23
- description: string | null;
24
- purpose: string | null;
25
- memoryCount: number;
26
- createdAt: Date;
27
- updatedAt: Date;
28
- }
29
- export interface PlaceCreateInput {
30
- projectId: string;
31
- name: string;
32
- placeType: PlaceType;
33
- parentId?: string | null;
34
- sortOrder?: number;
35
- description?: string;
36
- purpose?: string;
37
- }
38
- export interface PlaceUpdateInput {
39
- name?: string;
40
- description?: string;
41
- purpose?: string;
42
- sortOrder?: number;
43
- positionX?: number;
44
- positionY?: number;
45
- }
46
- export declare const DEFAULT_PLACES: Omit<PlaceCreateInput, 'projectId'>[];
47
- /**
48
- * Create a new place
49
- */
50
- export declare function createPlace(input: PlaceCreateInput): Promise<Place>;
51
- /**
52
- * Get a place by ID
53
- */
54
- export declare function getPlace(id: string): Promise<Place | null>;
55
- /**
56
- * Get places for a project, ordered by sort_order
57
- */
58
- export declare function getProjectPlaces(projectId: string): Promise<Place[]>;
59
- /**
60
- * Get place by type for a project
61
- */
62
- export declare function getPlaceByType(projectId: string, placeType: PlaceType): Promise<Place | null>;
63
- /**
64
- * Update a place
65
- */
66
- export declare function updatePlace(id: string, input: PlaceUpdateInput): Promise<Place | null>;
67
- /**
68
- * Delete a place
69
- */
70
- export declare function deletePlace(id: string): Promise<boolean>;
71
- /**
72
- * Initialize default 7 places for a project
73
- */
74
- export declare function initializeDefaultPlaces(projectId: string): Promise<Place[]>;
75
- /**
76
- * Get place by loci index
77
- */
78
- export declare function getPlaceByLociIndex(projectId: string, sortOrder: number): Promise<Place | null>;
79
- /**
80
- * Update memory count for a place
81
- */
82
- export declare function updatePlaceMemoryCount(placeId: string): Promise<void>;
83
- /**
84
- * Sync all place memory counts - recalculate counts for all places in a project
85
- * Useful for fixing counts after bulk operations or data recovery
86
- */
87
- export declare function syncAllPlaceMemoryCounts(projectId: string): Promise<void>;
88
- //# sourceMappingURL=places.d.ts.map