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,291 +0,0 @@
1
- /**
2
- * Bridge Discovery
3
- * Discovers indirect connections between memories through shared associations
4
- * Uses bidirectional BFS with Dijkstra-style weight prioritization
5
- * Finds "waypoint" memories that connect otherwise distant memory clusters
6
- */
7
- import { getDb } from '../../db/index.js';
8
- import { getSchema } from '../../db/schema.js';
9
- import { eq } from 'drizzle-orm';
10
- import { logger } from '../../core/logger.js';
11
- /**
12
- * Discover bridge memories connecting seed memory clusters
13
- */
14
- export async function discoverBridges(seedMemoryIds, projectId, options = {}) {
15
- if (seedMemoryIds.length < 2) {
16
- return [];
17
- }
18
- const maxPathLength = options.maxPathLength ?? 4;
19
- const topBridges = options.topBridges ?? 10;
20
- const minPathWeight = options.minPathWeight ?? 1;
21
- try {
22
- const db = await getDb();
23
- const schema = await getSchema();
24
- // Fetch all associations for this project
25
- const allMemories = await db
26
- .select()
27
- .from(schema.memories)
28
- .where(eq(schema.memories.projectId, projectId));
29
- const memoriesById = new Map(allMemories.map((m) => [m.id, m]));
30
- // Get all associations
31
- const associations = await db.select().from(schema.memoryAssociations);
32
- // Build adjacency list graph
33
- const graph = new Map();
34
- for (const assoc of associations) {
35
- if (!graph.has(assoc.fromMemoryId)) {
36
- graph.set(assoc.fromMemoryId, []);
37
- }
38
- const edges = graph.get(assoc.fromMemoryId);
39
- if (edges) {
40
- edges.push({
41
- toId: assoc.toMemoryId,
42
- weight: assoc.weight || 1,
43
- type: assoc.associationType,
44
- });
45
- }
46
- }
47
- // Find all paths between seed memories
48
- const pathMetrics = new Map();
49
- const allPaths = [];
50
- for (let i = 0; i < seedMemoryIds.length; i++) {
51
- for (let j = i + 1; j < seedMemoryIds.length; j++) {
52
- const start = seedMemoryIds[i];
53
- const end = seedMemoryIds[j];
54
- const paths = findPaths(graph, start, end, maxPathLength, minPathWeight);
55
- for (const path of paths) {
56
- // Record intermediate nodes (not start or end)
57
- for (let k = 1; k < path.route.length - 1; k++) {
58
- const nodeId = path.route[k];
59
- if (!pathMetrics.has(nodeId)) {
60
- pathMetrics.set(nodeId, { pathsThrough: 0, weight: 0 });
61
- }
62
- const metrics = pathMetrics.get(nodeId);
63
- metrics.pathsThrough++;
64
- metrics.weight += path.weight;
65
- }
66
- if (options.includeExamplePaths !== false) {
67
- allPaths.push(path);
68
- }
69
- }
70
- }
71
- }
72
- // Calculate bridge scores and convert to BridgeMemory objects
73
- const bridges = [];
74
- for (const [memoryId, metrics] of pathMetrics.entries()) {
75
- const memory = memoriesById.get(memoryId);
76
- if (!memory)
77
- continue;
78
- // Calculate betweenness centrality normalized to 0-100
79
- const bridgeScore = Math.min(100, (metrics.pathsThrough / (seedMemoryIds.length * (seedMemoryIds.length - 1))) * 1000);
80
- // Calculate connection density: how many unique memories it connects
81
- const connectedMemories = new Set();
82
- const neighbors = graph.get(memoryId) || [];
83
- for (const neighbor of neighbors) {
84
- connectedMemories.add(neighbor.toId);
85
- }
86
- // Include reverse connections
87
- for (const [fromId, edges] of graph.entries()) {
88
- for (const edge of edges) {
89
- if (edge.toId === memoryId && fromId !== memoryId) {
90
- connectedMemories.add(fromId);
91
- }
92
- }
93
- }
94
- const connectionDensity = connectedMemories.size / Math.max(1, allMemories.length);
95
- // Determine importance level
96
- let importance;
97
- if (bridgeScore >= 50) {
98
- importance = 'critical';
99
- }
100
- else if (bridgeScore >= 20) {
101
- importance = 'major';
102
- }
103
- else {
104
- importance = 'minor';
105
- }
106
- // Get example paths through this bridge
107
- const examplePaths = allPaths
108
- .filter((p) => p.route.includes(memoryId) &&
109
- p.route.length > 1)
110
- .slice(0, 3);
111
- bridges.push({
112
- memoryId,
113
- memory,
114
- bridgeScore,
115
- pathsThrough: metrics.pathsThrough,
116
- examplePaths,
117
- connectionDensity: Math.round(connectionDensity * 1000) / 1000,
118
- importance,
119
- });
120
- }
121
- // Sort by bridge score descending
122
- bridges.sort((a, b) => b.bridgeScore - a.bridgeScore);
123
- logger.debug('Bridges discovered', {
124
- seedMemoryCount: seedMemoryIds.length,
125
- bridgeCount: bridges.length,
126
- topBridges: bridges.slice(0, topBridges).map((b) => ({
127
- id: b.memoryId,
128
- score: b.bridgeScore,
129
- importance: b.importance,
130
- })),
131
- });
132
- return bridges.slice(0, topBridges);
133
- }
134
- catch (error) {
135
- logger.error('Error discovering bridges', error);
136
- return [];
137
- }
138
- }
139
- /**
140
- * Find all shortest paths between two memories up to maxLength
141
- * Uses BFS with weight-based distance metric
142
- */
143
- function findPaths(graph, start, end, maxLength, minWeight) {
144
- const paths = [];
145
- const queue = [{ current: start, route: [start], weight: 0, types: [] }];
146
- const visited = new Set();
147
- while (queue.length > 0) {
148
- const { current, route, weight, types } = queue.shift();
149
- // Stop if we've exceeded max path length
150
- if (route.length > maxLength)
151
- continue;
152
- // Skip if already visited in shorter path
153
- const routeKey = route.join('->');
154
- if (visited.has(routeKey))
155
- continue;
156
- visited.add(routeKey);
157
- // Check if we reached the destination
158
- if (current === end && route.length > 1) {
159
- paths.push({
160
- route,
161
- distance: route.length - 1,
162
- weight,
163
- associationTypes: types,
164
- });
165
- continue;
166
- }
167
- // Explore neighbors
168
- const neighbors = graph.get(current) || [];
169
- for (const neighbor of neighbors) {
170
- // Skip if creating a cycle (except for final destination)
171
- if (neighbor.toId !== end && route.includes(neighbor.toId))
172
- continue;
173
- // Skip if weight below threshold
174
- if (neighbor.weight < minWeight)
175
- continue;
176
- queue.push({
177
- current: neighbor.toId,
178
- route: [...route, neighbor.toId],
179
- weight: weight + neighbor.weight,
180
- types: [...types, neighbor.type],
181
- });
182
- }
183
- }
184
- // Sort by weight (distance metric) and keep top paths
185
- paths.sort((a, b) => b.weight - a.weight);
186
- return paths.slice(0, 5); // Return top 5 paths
187
- }
188
- /**
189
- * Get bridge memories for a single memory (find what it connects to)
190
- */
191
- export async function getMemoryBridges(memoryId, projectId, topK = 5) {
192
- try {
193
- const db = await getDb();
194
- const schema = await getSchema();
195
- // Find memories connected to this one
196
- const associations = await db
197
- .select()
198
- .from(schema.memoryAssociations)
199
- .where(eq(schema.memoryAssociations.fromMemoryId, memoryId));
200
- if (associations.length === 0) {
201
- return [];
202
- }
203
- // Get connected memory IDs
204
- const connectedIds = new Set();
205
- for (const assoc of associations) {
206
- connectedIds.add(assoc.toMemoryId);
207
- }
208
- if (connectedIds.size < 2) {
209
- return [];
210
- }
211
- // Discover bridges between connected memories
212
- const seedIds = Array.from(connectedIds);
213
- const bridges = await discoverBridges(seedIds, projectId, { topBridges: topK });
214
- return bridges;
215
- }
216
- catch (error) {
217
- logger.error('Error getting memory bridges', error);
218
- return [];
219
- }
220
- }
221
- /**
222
- * Analyze overall network connectivity using bridge metrics
223
- */
224
- export async function analyzeNetworkConnectivity(projectId, topBridges = 20) {
225
- try {
226
- const db = await getDb();
227
- const schema = await getSchema();
228
- // Get all memories
229
- const allMemories = await db
230
- .select()
231
- .from(schema.memories)
232
- .where(eq(schema.memories.projectId, projectId));
233
- if (allMemories.length < 2) {
234
- return {
235
- totalMemories: allMemories.length,
236
- totalConnections: 0,
237
- averageDegree: 0,
238
- bridgeMemories: [],
239
- networkDensity: 0,
240
- clustering: { tightClusters: 0, looseClusters: 0 },
241
- };
242
- }
243
- // Get all associations
244
- const associations = await db.select().from(schema.memoryAssociations);
245
- // Calculate graph metrics
246
- const degree = new Map();
247
- for (const memory of allMemories) {
248
- degree.set(memory.id, 0);
249
- }
250
- for (const assoc of associations) {
251
- degree.set(assoc.fromMemoryId, (degree.get(assoc.fromMemoryId) || 0) + 1);
252
- }
253
- const avgDegree = Array.from(degree.values()).reduce((a, b) => a + b, 0) / allMemories.length;
254
- const networkDensity = (associations.length * 2) / (allMemories.length * (allMemories.length - 1));
255
- // Discover bridges for all memories
256
- const seedIds = allMemories.slice(0, Math.min(10, allMemories.length)).map((m) => m.id);
257
- const bridges = await discoverBridges(seedIds, projectId, { topBridges });
258
- // Cluster analysis based on connectivity
259
- let tightClusters = 0;
260
- let looseClusters = 0;
261
- for (const memory of allMemories) {
262
- const connectionCount = degree.get(memory.id) || 0;
263
- if (connectionCount > avgDegree * 1.5) {
264
- tightClusters++;
265
- }
266
- else if (connectionCount < avgDegree * 0.5) {
267
- looseClusters++;
268
- }
269
- }
270
- return {
271
- totalMemories: allMemories.length,
272
- totalConnections: associations.length,
273
- averageDegree: Math.round(avgDegree * 100) / 100,
274
- bridgeMemories: bridges,
275
- networkDensity: Math.round(networkDensity * 10000) / 10000,
276
- clustering: { tightClusters, looseClusters },
277
- };
278
- }
279
- catch (error) {
280
- logger.error('Error analyzing network connectivity', error);
281
- return {
282
- totalMemories: 0,
283
- totalConnections: 0,
284
- averageDegree: 0,
285
- bridgeMemories: [],
286
- networkDensity: 0,
287
- clustering: { tightClusters: 0, looseClusters: 0 },
288
- };
289
- }
290
- }
291
- //# sourceMappingURL=bridge-discovery.js.map
@@ -1,27 +0,0 @@
1
- import { MemoryType } from './memories.js';
2
- export interface CategorizationResult {
3
- suggestedType: MemoryType;
4
- suggestedTags: string[];
5
- hierarchicalTags: string[];
6
- concepts: string[];
7
- fileScopes: string[];
8
- confidence: number;
9
- }
10
- export interface TagScore {
11
- tag: string;
12
- score: number;
13
- isNew: boolean;
14
- category: string;
15
- }
16
- export declare function categorizeMemory(content: string, existingTags?: string[]): Promise<CategorizationResult>;
17
- export declare function parseHierarchicalTag(tag: string): {
18
- prefix: string | null;
19
- name: string;
20
- };
21
- export declare function buildTagHierarchy(tags: string[]): Map<string, string[]>;
22
- export declare function suggestTagsFromEmbedding(content: string, existingTags: string[], similarMemories: Array<{
23
- tags: string[];
24
- content: string;
25
- }>): Promise<string[]>;
26
- export declare function generateTagVariants(tag: string): string[];
27
- //# sourceMappingURL=categorizer.d.ts.map
@@ -1,306 +0,0 @@
1
- const MEMORY_TYPE_PATTERNS = [
2
- {
3
- type: 'decision',
4
- patterns: [
5
- /\b(i\s+(?:decided|chose|went\s+with|selected|picked)|we\s+(?:decided|chose|went\s+with)|the\s+(?:decision|choice)\s+(?:is|was)|let's\s+go\s+with|going\s+with\s+\w+)\b/i,
6
- /\b(over\s+the\s+other|instead\s+of|x\s+over\s+y|better\s+to|best\s+(?:option|choice|approach))\b/i,
7
- /\b(final\s+decision|decided\s+to|make\s+a\s+decision)\b/i,
8
- ],
9
- weight: 3,
10
- },
11
- {
12
- type: 'preference',
13
- patterns: [
14
- /\b(i\s+(?:prefer|like|hate|dislike|love)|my\s+(?:preference|favorite)|i'd\s+rather|i\s+(?:always|never)\s+)\b/i,
15
- /\b(in\s+general|i\s+tend\s+to|i\s+usually|i\s+typically)\b/i,
16
- /\b(better\s+to|better\s+if|nice\s+to\s+have|prefer\s+)\b/i,
17
- ],
18
- weight: 2,
19
- },
20
- {
21
- type: 'context',
22
- patterns: [
23
- /\b(remember\s+that|keep\s+in\s+mind|note\s+that|important:|from\s+now\s+on|going\s+forward)\b/i,
24
- /\b(standard\s+(?:practice|workflow|approach)|we\s+(?:always|usually)\s+|never\s+forget)\b/i,
25
- /\b(reminder:|warning:|caution:|pro-tip:|tip:\s*)\b/i,
26
- ],
27
- weight: 2,
28
- },
29
- {
30
- type: 'fact',
31
- patterns: [
32
- /\b(is|are|was|were|has|have|uses?|depends\s+on|requires?|located\s+at|sits?\s+on)\b/i,
33
- /\b(the\s+\w+\s+(?:file|directory|module|class|function|variable|config|setting))\b/i,
34
- /\b(in\s+the|at\s+location|under\s+path)\b/i,
35
- ],
36
- weight: 1,
37
- },
38
- ];
39
- const TAG_CATEGORIES = {
40
- 'language': [
41
- /\b(typescript|javascript|python|rust|go|java|c\+\+|c#|ruby|php|swift|kotlin|scala|elixir|clojure|haskell)\b/gi,
42
- ],
43
- 'framework': [
44
- /\b(react|vue|angular|svelte|nextjs|nuxt|express|fastify|nestjs|django|flask|spring|rails|laravel|\.net|unity|unreal)\b/gi,
45
- ],
46
- 'tool': [
47
- /\b(docker|kubernetes|git|github|gitlab|jenkins|travis|github\s+actions|terraform|ansible|puppet|chef)\b/gi,
48
- ],
49
- 'database': [
50
- /\b(postgresql|postgres|mysql|mongodb|redis|sqlite|elasticsearch|cassandra|dynamodb|neo4j|graphQL|prisma|drizzle)\b/gi,
51
- ],
52
- 'concept': [
53
- /\b(api|rest|graphql|websocket|oauth|jwt|ssl|tls|https?|crud|tdd|bdd|pipeline|microservices|serverless)\b/gi,
54
- ],
55
- 'project': [
56
- /\b(architecture|design|pattern|structure|directory|folder|file|module|component|service|controller|route|handler)\b/gi,
57
- ],
58
- 'workflow': [
59
- /\b(review|pr|merge|deploy|build|test|debug|optimize|refactor|legacy|deprecated|migration|upgrade)\b/gi,
60
- ],
61
- 'error': [
62
- /\b(error|bug|issue|exception|fallback|failure|crash|timeout|panic|assert|warn)\b/gi,
63
- ],
64
- };
65
- const HIERARCHICAL_TAG_PREFIXES = {
66
- 'lang:': 'language',
67
- 'fw:': 'framework',
68
- 'db:': 'database',
69
- 'tool:': 'tool',
70
- 'concept:': 'concept',
71
- 'proj:': 'project',
72
- 'wf:': 'workflow',
73
- 'file:': 'file',
74
- 'dir:': 'directory',
75
- };
76
- export async function categorizeMemory(content, existingTags = []) {
77
- const typeScores = {
78
- observation: 0,
79
- fact: 0,
80
- decision: 0,
81
- context: 0,
82
- preference: 0,
83
- note: 0,
84
- task: 0,
85
- };
86
- for (const { type, patterns, weight } of MEMORY_TYPE_PATTERNS) {
87
- for (const pattern of patterns) {
88
- if (pattern.test(content)) {
89
- typeScores[type] += weight;
90
- }
91
- }
92
- }
93
- const sortedTypes = Object.entries(typeScores)
94
- .sort(([, a], [, b]) => b - a);
95
- const suggestedType = sortedTypes[0][1] > 0
96
- ? sortedTypes[0][0]
97
- : 'observation';
98
- const tagScores = await scoreAndSuggestTags(content, existingTags);
99
- const suggestedTags = tagScores
100
- .filter(t => t.score >= 0.3)
101
- .sort((a, b) => b.score - a.score)
102
- .slice(0, 5)
103
- .map(t => t.tag);
104
- const hierarchicalTags = suggestedTags.map((tag, idx) => {
105
- const score = tagScores[idx]?.score ?? 0;
106
- const category = tagScores[idx]?.category ?? 'general';
107
- const prefix = Object.entries(HIERARCHICAL_TAG_PREFIXES).find(([, v]) => v === category)?.[0] ?? '';
108
- return prefix ? `${prefix}${tag}` : tag;
109
- });
110
- const concepts = extractConcepts(content);
111
- const fileScopes = extractFileScopes(content);
112
- const maxScore = sortedTypes[0][1];
113
- const confidence = Math.min(maxScore / 5, 1);
114
- return {
115
- suggestedType,
116
- suggestedTags,
117
- hierarchicalTags,
118
- concepts,
119
- fileScopes,
120
- confidence,
121
- };
122
- }
123
- async function scoreAndSuggestTags(content, existingTags) {
124
- const contentLower = content.toLowerCase();
125
- const existingLower = new Set(existingTags.map(t => t.toLowerCase()));
126
- const allScores = [];
127
- for (const [category, patterns] of Object.entries(TAG_CATEGORIES)) {
128
- const matches = [];
129
- for (const pattern of patterns) {
130
- const found = contentLower.match(pattern);
131
- if (found) {
132
- matches.push(...found.map(m => m.toLowerCase()));
133
- }
134
- }
135
- const uniqueMatches = [...new Set(matches)];
136
- for (const match of uniqueMatches) {
137
- const score = calculateTagScore(match, content, category);
138
- const isNew = !existingLower.has(match);
139
- allScores.push({
140
- tag: match,
141
- score: isNew ? score : score * 0.5,
142
- isNew,
143
- category,
144
- });
145
- }
146
- }
147
- const projectTags = extractProjectTags(content);
148
- for (const tag of projectTags) {
149
- allScores.push({
150
- tag,
151
- score: 0.7,
152
- isNew: !existingLower.has(tag.toLowerCase()),
153
- category: 'project',
154
- });
155
- }
156
- return allScores;
157
- }
158
- function calculateTagScore(tag, content, category) {
159
- const tagLength = tag.length;
160
- const contentLower = content.toLowerCase();
161
- const tagLower = tag.toLowerCase();
162
- const occurrences = (contentLower.match(new RegExp(tagLower, 'g')) || []).length;
163
- const density = occurrences * tagLength / content.length;
164
- const categoryBonus = {
165
- 'language': 1.2,
166
- 'framework': 1.1,
167
- 'database': 1.1,
168
- 'tool': 1.0,
169
- 'concept': 0.9,
170
- 'project': 0.8,
171
- 'workflow': 0.9,
172
- }[category] ?? 1.0;
173
- let score = Math.min(density * 10 * categoryBonus, 1);
174
- if (occurrences > 1) {
175
- score = Math.min(score + 0.2, 1);
176
- }
177
- return Math.max(score, 0.1);
178
- }
179
- function extractConcepts(content) {
180
- const concepts = [];
181
- const pattern = /\b([a-z]+[A-Z][a-zA-Z0-9]*|[A-Z]+[a-z]+[A-Z][a-zA-Z0-9]*)\b/g;
182
- const matches = content.match(pattern);
183
- if (matches) {
184
- const unique = [...new Set(matches)];
185
- concepts.push(...unique.slice(0, 5));
186
- }
187
- const knownConcepts = [
188
- 'api', 'cli', 'sdk', 'ui', 'ux', 'ide', 'orm', 'mvc', 'crud', 'api',
189
- 'auth', 'jwt', 'oauth', 'rest', 'grpc', 'websocket', 'graphql',
190
- ];
191
- const found = knownConcepts.filter(c => new RegExp(`\\b${c}\\b`, 'i').test(content));
192
- return [...new Set([...concepts, ...found])].slice(0, 8);
193
- }
194
- function extractFileScopes(content) {
195
- const scopes = [];
196
- const pathPatterns = [
197
- /(['"])(\/[\w\-\.\/]+(?:\.[a-z]+)?)(['"])/g,
198
- /(?:from|import|require)\s+['"]([\w\-\.\/]+)['"]/g,
199
- /<([\w\-\.\/]+)(?:\.[a-z]+)?>/g,
200
- /file:\s*([\w\-\.\/]+)/gi,
201
- /in\s+([\w\-\.\/]+\.[a-z]+)/gi,
202
- ];
203
- for (const pattern of pathPatterns) {
204
- let match;
205
- while ((match = pattern.exec(content)) !== null) {
206
- const path = match[1] || match[2] || match[3];
207
- if (path && path.length < 100) {
208
- const normalized = normalizeFilePath(path);
209
- if (normalized && !scopes.includes(normalized)) {
210
- scopes.push(normalized);
211
- }
212
- }
213
- }
214
- }
215
- return scopes.slice(0, 3);
216
- }
217
- function normalizeFilePath(path) {
218
- const cleaned = path
219
- .replace(/^['"]+|['"]+$/g, '')
220
- .replace(/^\.\.?\/?/, '')
221
- .split('/')
222
- .filter(Boolean)
223
- .join('/');
224
- const parts = cleaned.split('/');
225
- if (parts.length > 3) {
226
- return parts.slice(-3).join('/');
227
- }
228
- return cleaned || '';
229
- }
230
- function extractProjectTags(content) {
231
- const tags = [];
232
- const projectPattern = /\bproject[:\-]?(\w+)/gi;
233
- let match;
234
- while ((match = projectPattern.exec(content)) !== null) {
235
- tags.push(match[1].toLowerCase());
236
- }
237
- const dotfilePattern = /^\.?([a-zA-Z0-9_\-]+)\.(json|yaml|yml|toml|config|cfg|ini|env)/m;
238
- const dotfileMatch = content.match(dotfilePattern);
239
- if (dotfileMatch) {
240
- tags.push(dotfileMatch[1].toLowerCase());
241
- }
242
- return tags;
243
- }
244
- export function parseHierarchicalTag(tag) {
245
- for (const [prefix, _category] of Object.entries(HIERARCHICAL_TAG_PREFIXES)) {
246
- if (tag.startsWith(prefix)) {
247
- return { prefix, name: tag.slice(prefix.length) };
248
- }
249
- }
250
- return { prefix: null, name: tag };
251
- }
252
- export function buildTagHierarchy(tags) {
253
- const hierarchy = new Map();
254
- for (const tag of tags) {
255
- const { prefix, name } = parseHierarchicalTag(tag);
256
- const category = prefix
257
- ? Object.entries(HIERARCHICAL_TAG_PREFIXES).find(([p]) => p === prefix)?.[1] ?? 'custom'
258
- : 'general';
259
- if (!hierarchy.has(category)) {
260
- hierarchy.set(category, []);
261
- }
262
- hierarchy.get(category).push(tag);
263
- }
264
- return hierarchy;
265
- }
266
- export async function suggestTagsFromEmbedding(content, existingTags, similarMemories) {
267
- if (similarMemories.length === 0) {
268
- return [];
269
- }
270
- const existingLower = new Set(existingTags.map(t => t.toLowerCase()));
271
- const tagCounts = {};
272
- for (const memory of similarMemories) {
273
- for (const tag of memory.tags) {
274
- if (!existingLower.has(tag.toLowerCase())) {
275
- tagCounts[tag] = (tagCounts[tag] ?? 0) + 1;
276
- }
277
- }
278
- }
279
- return Object.entries(tagCounts)
280
- .sort(([, a], [, b]) => b - a)
281
- .filter(([, count]) => count >= 2)
282
- .slice(0, 3)
283
- .map(([tag]) => tag);
284
- }
285
- export function generateTagVariants(tag) {
286
- const variants = [tag];
287
- const lower = tag.toLowerCase();
288
- const upper = tag.toUpperCase();
289
- const capitalize = tag.charAt(0).toUpperCase() + tag.slice(1).toLowerCase();
290
- if (lower !== tag)
291
- variants.push(lower);
292
- if (upper !== tag)
293
- variants.push(upper);
294
- if (capitalize !== tag)
295
- variants.push(capitalize);
296
- const snakeCase = tag.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
297
- if (snakeCase !== tag && snakeCase !== lower) {
298
- variants.push(snakeCase);
299
- }
300
- const kebabCase = tag.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
301
- if (kebabCase !== tag && kebabCase !== lower && kebabCase !== snakeCase) {
302
- variants.push(kebabCase);
303
- }
304
- return [...new Set(variants)];
305
- }
306
- //# sourceMappingURL=categorizer.js.map
@@ -1,7 +0,0 @@
1
- export interface Conflict {
2
- type: 'contradiction' | 'inconsistency' | 'outdated';
3
- description: string;
4
- relatedMemoryId?: string;
5
- }
6
- export declare function detectConflicts(memoryId: string, proposedContent: string): Promise<Conflict[]>;
7
- //# sourceMappingURL=conflict-detector.d.ts.map
@@ -1,43 +0,0 @@
1
- import { eq, and, sql } from 'drizzle-orm';
2
- import { getDb } from '../../db/index.js';
3
- import { getSchema } from '../../db/schema.js';
4
- import { createDatabaseClient } from '../storage/database.js';
5
- export async function detectConflicts(memoryId, proposedContent) {
6
- const db = createDatabaseClient(await getDb());
7
- const schema = await getSchema();
8
- const { memories } = schema;
9
- const conflicts = [];
10
- // Get current memory
11
- const currentMemory = await db.select()
12
- .from(memories)
13
- .where(eq(memories.id, memoryId))
14
- .limit(1);
15
- if (currentMemory.length === 0)
16
- return [];
17
- // Check for temporal contradictions
18
- if (currentMemory[0].validFrom && currentMemory[0].validTo) {
19
- const now = new Date();
20
- if (now < new Date(currentMemory[0].validFrom) || now > new Date(currentMemory[0].validTo)) {
21
- conflicts.push({
22
- type: 'inconsistency',
23
- description: 'Current time is outside validity period',
24
- });
25
- }
26
- }
27
- // Check for semantic contradictions with other memories
28
- const similarMemories = await db.select()
29
- .from(memories)
30
- .where(and(eq(memories.projectId, currentMemory[0].projectId), sql `memories.id != ${memoryId}`, sql `memories.content ILIKE ${proposedContent}`))
31
- .limit(5);
32
- for (const memory of similarMemories) {
33
- if (memory.id !== memoryId) {
34
- conflicts.push({
35
- type: 'contradiction',
36
- description: `Potential contradiction with memory ${memory.id}`,
37
- relatedMemoryId: memory.id,
38
- });
39
- }
40
- }
41
- return conflicts;
42
- }
43
- //# sourceMappingURL=conflict-detector.js.map