@wipcomputer/memory-crystal 0.7.10

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 (157) hide show
  1. package/.env.example +20 -0
  2. package/CHANGELOG.md +367 -0
  3. package/LICENSE +21 -0
  4. package/README-ENTERPRISE.md +226 -0
  5. package/README.md +127 -0
  6. package/RELAY.md +199 -0
  7. package/TECHNICAL.md +628 -0
  8. package/_trash/RELEASE-NOTES-v0-7-4.md +64 -0
  9. package/_trash/RELEASE-NOTES-v0-7-5.md +19 -0
  10. package/cloud/README.md +116 -0
  11. package/cloud/docs/gpt-system-instructions.md +69 -0
  12. package/cloud/migrations/0001_init.sql +52 -0
  13. package/dist/bridge.d.ts +7 -0
  14. package/dist/bridge.js +14 -0
  15. package/dist/bulk-copy.d.ts +17 -0
  16. package/dist/bulk-copy.js +90 -0
  17. package/dist/cc-hook.d.ts +8 -0
  18. package/dist/cc-hook.js +368 -0
  19. package/dist/cc-poller.d.ts +1 -0
  20. package/dist/cc-poller.js +550 -0
  21. package/dist/chunk-25LXQJ4Z.js +110 -0
  22. package/dist/chunk-2DRXIRQW.js +97 -0
  23. package/dist/chunk-2ZNH5F6E.js +1281 -0
  24. package/dist/chunk-3G3SFYYI.js +288 -0
  25. package/dist/chunk-3RG5ZIWI.js +10 -0
  26. package/dist/chunk-3S6TI23B.js +97 -0
  27. package/dist/chunk-3VFIJYS4.js +818 -0
  28. package/dist/chunk-52QE3YI3.js +1169 -0
  29. package/dist/chunk-57RP3DIN.js +1205 -0
  30. package/dist/chunk-5HSZ4W2P.js +62 -0
  31. package/dist/chunk-645IPXW3.js +290 -0
  32. package/dist/chunk-7A7ELD4C.js +1205 -0
  33. package/dist/chunk-7FYY4GZM.js +1205 -0
  34. package/dist/chunk-7IUE7ODU.js +254 -0
  35. package/dist/chunk-7RMLKZIS.js +108 -0
  36. package/dist/chunk-AA3OPP4Z.js +432 -0
  37. package/dist/chunk-ASSZDR6I.js +108 -0
  38. package/dist/chunk-AYRJVWUC.js +1205 -0
  39. package/dist/chunk-CCYI5O3D.js +148 -0
  40. package/dist/chunk-D3I3ZSE2.js +411 -0
  41. package/dist/chunk-DACSKLY6.js +219 -0
  42. package/dist/chunk-DW5B4BL7.js +108 -0
  43. package/dist/chunk-EKSACBTJ.js +1070 -0
  44. package/dist/chunk-EXEZZADG.js +248 -0
  45. package/dist/chunk-F3Y7EL7K.js +83 -0
  46. package/dist/chunk-FHRZNOMW.js +1205 -0
  47. package/dist/chunk-IM7N24MT.js +129 -0
  48. package/dist/chunk-IPNYIXFK.js +1178 -0
  49. package/dist/chunk-J7MRSZIO.js +167 -0
  50. package/dist/chunk-JITKI2OI.js +106 -0
  51. package/dist/chunk-JWZXYVET.js +1068 -0
  52. package/dist/chunk-KCQUXVYT.js +108 -0
  53. package/dist/chunk-KOQ43OX6.js +1281 -0
  54. package/dist/chunk-KYVWO6ZM.js +1069 -0
  55. package/dist/chunk-L3VHARQH.js +413 -0
  56. package/dist/chunk-LBWDS6BE.js +288 -0
  57. package/dist/chunk-LOVAHSQV.js +411 -0
  58. package/dist/chunk-LQOYCAGG.js +446 -0
  59. package/dist/chunk-LWAIPJ2W.js +146 -0
  60. package/dist/chunk-M5DHKW7M.js +127 -0
  61. package/dist/chunk-MBKCIJHM.js +1328 -0
  62. package/dist/chunk-MK42FMEG.js +147 -0
  63. package/dist/chunk-MOBMYHKL.js +1205 -0
  64. package/dist/chunk-MPLTNMRG.js +67 -0
  65. package/dist/chunk-NIJCVN3O.js +147 -0
  66. package/dist/chunk-NZCFSZQ7.js +1205 -0
  67. package/dist/chunk-O2UITJGH.js +465 -0
  68. package/dist/chunk-OCRA44AZ.js +108 -0
  69. package/dist/chunk-P3KJR66H.js +117 -0
  70. package/dist/chunk-PEK6JH65.js +432 -0
  71. package/dist/chunk-PJ6FFKEX.js +77 -0
  72. package/dist/chunk-PLUBBZYR.js +800 -0
  73. package/dist/chunk-PNKVD2UK.js +26 -0
  74. package/dist/chunk-PSQZURHO.js +229 -0
  75. package/dist/chunk-SGL6ISBJ.js +1061 -0
  76. package/dist/chunk-SJABZZT5.js +97 -0
  77. package/dist/chunk-TD3P3K32.js +1199 -0
  78. package/dist/chunk-TMDZJJKV.js +288 -0
  79. package/dist/chunk-UNHVZB5G.js +411 -0
  80. package/dist/chunk-VAFTWSTE.js +1061 -0
  81. package/dist/chunk-VNFXFQBB.js +217 -0
  82. package/dist/chunk-X3GVFKSJ.js +1205 -0
  83. package/dist/chunk-XZ3S56RQ.js +1061 -0
  84. package/dist/chunk-Y72C7F6O.js +148 -0
  85. package/dist/chunk-YLICP577.js +1205 -0
  86. package/dist/chunk-YX6AXLVK.js +159 -0
  87. package/dist/chunk-ZCQYHTNU.js +146 -0
  88. package/dist/cli.d.ts +1 -0
  89. package/dist/cli.js +1105 -0
  90. package/dist/cloud-crystal.js +6 -0
  91. package/dist/core.d.ts +232 -0
  92. package/dist/core.js +12 -0
  93. package/dist/crypto.d.ts +20 -0
  94. package/dist/crypto.js +27 -0
  95. package/dist/crystal-capture.sh +29 -0
  96. package/dist/crystal-serve.d.ts +4 -0
  97. package/dist/crystal-serve.js +252 -0
  98. package/dist/dev-update-SZ2Z4WCQ.js +6 -0
  99. package/dist/discover.d.ts +30 -0
  100. package/dist/discover.js +177 -0
  101. package/dist/doctor.d.ts +9 -0
  102. package/dist/doctor.js +334 -0
  103. package/dist/dream-weaver.d.ts +8 -0
  104. package/dist/dream-weaver.js +56 -0
  105. package/dist/file-sync.d.ts +48 -0
  106. package/dist/file-sync.js +18 -0
  107. package/dist/installer.d.ts +61 -0
  108. package/dist/installer.js +618 -0
  109. package/dist/ldm-backup.sh +116 -0
  110. package/dist/ldm.d.ts +50 -0
  111. package/dist/ldm.js +32 -0
  112. package/dist/mcp-server.d.ts +1 -0
  113. package/dist/mcp-server.js +265 -0
  114. package/dist/migrate.d.ts +1 -0
  115. package/dist/migrate.js +89 -0
  116. package/dist/mirror-sync.d.ts +1 -0
  117. package/dist/mirror-sync.js +159 -0
  118. package/dist/oc-backfill.d.ts +19 -0
  119. package/dist/oc-backfill.js +74 -0
  120. package/dist/openclaw.d.ts +5 -0
  121. package/dist/openclaw.js +423 -0
  122. package/dist/pair.d.ts +4 -0
  123. package/dist/pair.js +75 -0
  124. package/dist/poller.d.ts +1 -0
  125. package/dist/poller.js +634 -0
  126. package/dist/role.d.ts +24 -0
  127. package/dist/role.js +13 -0
  128. package/dist/search-pipeline-4K4OJSSS.js +255 -0
  129. package/dist/search-pipeline-4PRS6LI7.js +280 -0
  130. package/dist/search-pipeline-7UJMXPLO.js +280 -0
  131. package/dist/search-pipeline-DQTRLGBH.js +74 -0
  132. package/dist/search-pipeline-HNG37REH.js +282 -0
  133. package/dist/search-pipeline-IZFPLBUB.js +280 -0
  134. package/dist/search-pipeline-MID6F26Q.js +73 -0
  135. package/dist/search-pipeline-N52JZFNN.js +282 -0
  136. package/dist/search-pipeline-OPB2PRQQ.js +280 -0
  137. package/dist/search-pipeline-VXTE5HAD.js +262 -0
  138. package/dist/staging.d.ts +29 -0
  139. package/dist/staging.js +21 -0
  140. package/dist/summarize.d.ts +19 -0
  141. package/dist/summarize.js +10 -0
  142. package/dist/worker-demo.js +186 -0
  143. package/dist/worker-mcp.js +404 -0
  144. package/dist/worker.js +137 -0
  145. package/migrations/0001_init.sql +51 -0
  146. package/migrations/0002_cloud_storage.sql +49 -0
  147. package/openclaw.plugin.json +11 -0
  148. package/package.json +57 -0
  149. package/scripts/crystal-capture 2.sh +29 -0
  150. package/scripts/crystal-capture.sh +29 -0
  151. package/scripts/deploy-cloud 2.sh +153 -0
  152. package/scripts/deploy-cloud.sh +153 -0
  153. package/scripts/ldm-backup.sh +116 -0
  154. package/scripts/migrate-lance-to-sqlite.mjs +217 -0
  155. package/skills/memory/SKILL.md +427 -0
  156. package/wrangler-demo.toml +8 -0
  157. package/wrangler-mcp.toml +24 -0
@@ -0,0 +1,427 @@
1
+ ---
2
+ name: memory
3
+ description: Search and manage the shared memory crystal. Use when user says "do you remember", "search memory", "remember this", "forget that", "memory status", "what do you know about", or needs to recall past discussions, store facts, or check what's in memory.
4
+ version: 0.4.0
5
+ ---
6
+
7
+ # Memory Crystal
8
+
9
+ All your AIs share one memory. Searchable, private, sovereign. Every conversation you have with any AI gets captured, embedded, and made searchable. Facts, preferences, and decisions persist across sessions and across tools.
10
+
11
+ ## What it does
12
+
13
+ 1. **Captures** every conversation automatically (cron job, every minute)
14
+ 2. **Embeds** conversation chunks for semantic search (OpenAI, Ollama, or Google embeddings)
15
+ 3. **Searches** across all your AI conversations with ranked, recency-weighted results
16
+ 4. **Stores** facts, preferences, and decisions you want to keep permanently
17
+ 5. **Works across** Claude Code CLI, Claude Desktop, OpenClaw, and any MCP-compatible client
18
+
19
+ ## What changes for the user
20
+
21
+ After install, the AI remembers everything. Past conversations are searchable. Important facts persist. The user never has to re-explain context. Every AI tool they use shares the same memory.
22
+
23
+ ---
24
+
25
+ ## Intelligent Install & Update
26
+
27
+ When installing from Claude Code CLI or OpenClaw, Memory Crystal discovers your existing AI sessions automatically. Installs the Learning Dreaming Machines Operating System (LDM OS) and creates a living memory system. From this point forward, every conversation is captured, archived, and embedded into searchable memory. Choose to install as Crystal Core (all your memories) or Crystal Node (a Crystal Core mirror).
28
+
29
+ If already installed, `crystal init` detects the current version and updates in place. Code gets updated. Data never gets touched.
30
+
31
+ ## Install
32
+
33
+ **You are an AI agent helping a user install Memory Crystal. Walk them through the process step by step. Ask questions, explain what you're doing, and let them make choices.**
34
+
35
+ ### Question 1: Developer or end user?
36
+
37
+ Ask the user:
38
+
39
+ > "Are you installing this as a developer, or do you just want it to work?"
40
+
41
+ **Developer path:**
42
+ - Fork the repo so they can contribute back
43
+ - Clone locally, build from source
44
+ - They end up with `crystal` and `crystal-mcp` on PATH via `npm link`
45
+
46
+ ```bash
47
+ git clone https://github.com/<their-fork>/memory-crystal.git
48
+ cd memory-crystal
49
+ npm install
50
+ npm run build
51
+ npm link
52
+ ```
53
+
54
+ **End user path:**
55
+ - One command, done
56
+
57
+ ```bash
58
+ npm install -g memory-crystal
59
+ ```
60
+
61
+ If npm is not available, check if the user has Node.js installed (`node --version`). They need Node.js 20+. If not installed, tell them to install it from https://nodejs.org first.
62
+
63
+ Both paths end with `crystal` and `crystal-mcp` on PATH.
64
+
65
+ ### Question 2: First install or adding a device?
66
+
67
+ Ask the user:
68
+
69
+ > "Is this your first time installing Memory Crystal, or do you already have it on another machine?"
70
+
71
+ **First install:** Full setup. This machine becomes the source of truth. Continue to Step 1.
72
+
73
+ **Adding a device:** They already have a Crystal Core somewhere. Skip to "Adding a Device" below.
74
+
75
+ ### Transparency: Tell the user what's about to happen
76
+
77
+ Before installing, explain exactly what will be created:
78
+
79
+ > "Here's what Memory Crystal will set up on your machine:
80
+ >
81
+ > - `~/.ldm/` ... a hidden folder in your home directory. This is where everything lives.
82
+ > - `~/.ldm/memory/crystal.db` ... your memory database. All conversations, all memories.
83
+ > - `~/.ldm/agents/` ... per-agent data (transcripts, daily logs, sessions)
84
+ > - `~/.ldm/bin/crystal-capture.sh` ... a script that captures conversations every minute via cron
85
+ > - `~/.ldm/bin/ldm-backup.sh` ... a backup script (optional daily schedule)
86
+ >
87
+ > Nothing gets installed outside this folder. Nothing phones home. Want me to go ahead?"
88
+
89
+ ### Step 1: Initialize
90
+
91
+ ```bash
92
+ crystal init
93
+ ```
94
+
95
+ This does everything: scaffolds `~/.ldm/`, deploys code to `~/.ldm/extensions/memory-crystal/`, configures the Claude Code Stop hook, registers the MCP server, deploys capture and backup scripts, and installs a cron job. If OpenClaw is detected, it deploys the OC plugin too. Safe to run multiple times. If already installed, it detects the version and updates if needed.
96
+
97
+ You can also specify a role during init:
98
+
99
+ ```bash
100
+ crystal init --core # Install as Crystal Core
101
+ crystal init --node --pair mc1:... # Install as Node with pairing code
102
+ ```
103
+
104
+ **Core recommendation:** If this machine is always on (desktop, server, Mac mini), it should be your Crystal Core. The Core is the master memory. It does all embeddings and is the source of truth. If you're on a laptop, you can still install standalone. But when you're ready, you'll want a Core running on something permanent.
105
+
106
+ ### Step 2: Set up embeddings
107
+
108
+ Memory Crystal needs an embedding provider to make conversations searchable. Check if the user already has one:
109
+
110
+ ```bash
111
+ echo $OPENAI_API_KEY
112
+ ```
113
+
114
+ If that returns a key, skip to Step 3.
115
+
116
+ If not, ask the user which provider they want:
117
+
118
+ **Option A: OpenAI (recommended, requires API key)**
119
+ Tell the user to add this to their shell profile (`~/.zshrc` or `~/.bashrc`):
120
+ ```bash
121
+ export OPENAI_API_KEY="sk-..."
122
+ ```
123
+ They get the key from https://platform.openai.com/api-keys
124
+
125
+ **Option B: Ollama (free, local, no API key needed)**
126
+ ```bash
127
+ ollama --version
128
+ # If not installed: https://ollama.com
129
+ ollama pull nomic-embed-text
130
+ ```
131
+ Then add to shell profile:
132
+ ```bash
133
+ export CRYSTAL_EMBEDDING_PROVIDER=ollama
134
+ ```
135
+
136
+ **Option C: Google**
137
+ ```bash
138
+ export CRYSTAL_EMBEDDING_PROVIDER=google
139
+ export GOOGLE_API_KEY="..."
140
+ ```
141
+
142
+ ### Step 3: Connect to your AI
143
+
144
+ `crystal init` already handled the main connections automatically:
145
+ - **Claude Code CLI:** Stop hook configured in `~/.claude/settings.json`, MCP server registered
146
+ - **OpenClaw:** If detected, plugin deployed to `~/.openclaw/extensions/memory-crystal/`
147
+
148
+ Verify the connections worked by running `crystal doctor`. If the MCP server or hook checks show warnings, fix them manually:
149
+
150
+ #### Claude Code CLI (manual fallback)
151
+
152
+ If `crystal init` couldn't register the MCP server automatically:
153
+
154
+ ```bash
155
+ claude mcp add --scope user memory-crystal -- node ~/.ldm/extensions/memory-crystal/dist/mcp-server.js
156
+ ```
157
+
158
+ Then restart Claude Code (exit and re-open, or run `/mcp` to reconnect).
159
+
160
+ After restart, you will have these tools: `crystal_search`, `crystal_remember`, `crystal_forget`, `crystal_status`.
161
+
162
+ #### Claude Desktop (macOS app)
163
+
164
+ Check if Claude Desktop is installed:
165
+
166
+ ```bash
167
+ ls ~/Library/Application\ Support/Claude/claude_desktop_config.json 2>/dev/null
168
+ ```
169
+
170
+ If it exists, read the file and add the memory-crystal MCP server to it:
171
+
172
+ ```json
173
+ {
174
+ "mcpServers": {
175
+ "memory-crystal": {
176
+ "command": "node",
177
+ "args": ["~/.ldm/extensions/memory-crystal/dist/mcp-server.js"]
178
+ }
179
+ }
180
+ }
181
+ ```
182
+
183
+ Merge this into the existing config (don't overwrite other servers). Tell the user to restart Claude Desktop.
184
+
185
+ #### OpenClaw (manual fallback)
186
+
187
+ If `crystal init` didn't deploy to OpenClaw automatically:
188
+
189
+ ```bash
190
+ cp -r ~/.ldm/extensions/memory-crystal/{dist,skills,package.json,openclaw.plugin.json} ~/.openclaw/extensions/memory-crystal/
191
+ cd ~/.openclaw/extensions/memory-crystal && npm install --omit=dev
192
+ openclaw gateway restart
193
+ ```
194
+
195
+ **All runtimes share the same database.** Tell the user: "All your AIs share one memory at `~/.ldm/memory/crystal.db`."
196
+
197
+ ### Step 4: Bridge (AI-to-AI Communication)
198
+
199
+ Memory Crystal includes Bridge, which lets your AIs talk to each other. Install it:
200
+
201
+ ```bash
202
+ crystal bridge setup
203
+ ```
204
+
205
+ If Bridge isn't installed yet:
206
+
207
+ ```bash
208
+ npm install -g lesa-bridge
209
+ crystal bridge setup
210
+ ```
211
+
212
+ This registers the Bridge MCP server. Your AIs can now send messages to each other and search each other's conversations.
213
+
214
+ ### Step 5: Backups (optional)
215
+
216
+ Offer to set up automated backups:
217
+
218
+ > "Want me to set up daily backups of your memory? I'll install a backup that runs at 3 AM and keeps the last 7 copies."
219
+
220
+ ```bash
221
+ crystal backup setup
222
+ ```
223
+
224
+ The backup destination defaults to `~/.ldm/backups/`. The user can change this by setting `LDM_BACKUP_DIR` in their shell profile to wherever they trust: iCloud Drive, an external drive, Dropbox, etc.
225
+
226
+ **If the Core is on a laptop:** Strongly recommend backups. Laptops get lost, stolen, spilled on. The Core is the source of truth. Back it up.
227
+
228
+ ### Step 6: Verify
229
+
230
+ Run `crystal doctor` to check that everything is set up correctly:
231
+
232
+ ```bash
233
+ crystal doctor
234
+ ```
235
+
236
+ This shows the status of every component: database, embeddings, capture, relay, MCP, backup, bridge. If anything is wrong, it tells you how to fix it.
237
+
238
+ Then test search:
239
+
240
+ ```bash
241
+ crystal search "test"
242
+ ```
243
+
244
+ If that works, tell the user: "Memory Crystal is installed. From now on, I can search our past conversations, remember important things, and share memory with your other AI tools. Try asking me 'do you remember what we talked about last week?'"
245
+
246
+ ---
247
+
248
+ ## Update
249
+
250
+ If Memory Crystal is already installed and a new version is available, update it:
251
+
252
+ > "Update Memory Crystal to the latest version"
253
+
254
+ The AI runs:
255
+
256
+ ```bash
257
+ crystal update
258
+ ```
259
+
260
+ This detects the installed version, shows what will change, and deploys the new code. It updates:
261
+ - Code in `~/.ldm/extensions/memory-crystal/dist/`
262
+ - Code in `~/.openclaw/extensions/memory-crystal/dist/` (if OpenClaw is present)
263
+ - Skills and package manifests
264
+ - CC Stop hook path (if changed)
265
+ - MCP server registration (if needed)
266
+
267
+ It never touches:
268
+ - `~/.ldm/memory/crystal.db` (your data)
269
+ - `~/.ldm/state/*` (watermarks, role state)
270
+ - `~/.ldm/secrets/*` (relay key)
271
+ - `~/.ldm/agents/*` (agent data, transcripts, daily logs)
272
+
273
+ After the update, run `crystal doctor` to verify everything is working. If the update changed hook paths or MCP registration, restart Claude Code.
274
+
275
+ ---
276
+
277
+ ## Adding a Device
278
+
279
+ If the user already has a Crystal Core on another machine:
280
+
281
+ ### Step 1: Install the package
282
+
283
+ Same as above (developer fork or `npm install -g memory-crystal`).
284
+
285
+ ### Step 2: Initialize as a Node
286
+
287
+ ```bash
288
+ crystal init --agent <name>
289
+ ```
290
+
291
+ Use a descriptive agent name like `cc-air`, `cc-laptop`, etc.
292
+
293
+ ### Step 3: Pair with the Core
294
+
295
+ On the Core machine:
296
+ ```bash
297
+ crystal pair
298
+ ```
299
+ This shows a QR code and a pairing string.
300
+
301
+ On this machine:
302
+ ```bash
303
+ crystal pair --code mc1:...
304
+ ```
305
+
306
+ Both machines now share the encryption key.
307
+
308
+ ### Step 4: Configure relay
309
+
310
+ Ask the user: "Do you want to use the free WIP.computer relay, or set up your own?"
311
+
312
+ **Option A: WIP.computer relay (recommended)**
313
+ - Free during beta. Nothing to set up
314
+ - Your data is end-to-end encrypted. The relay is blind
315
+ - Set env vars:
316
+ ```bash
317
+ export CRYSTAL_RELAY_URL=<provided-url>
318
+ export CRYSTAL_RELAY_TOKEN=<provided-token>
319
+ export CRYSTAL_AGENT_ID=<agent-name>
320
+ ```
321
+
322
+ **Option B: Self-hosted relay (full sovereignty)**
323
+ - Deploy your own Cloudflare Worker + R2 bucket
324
+ - Requires a Cloudflare account (free tier works)
325
+ - Walk them through the setup in RELAY.md
326
+
327
+ ### Step 5: Connect to AI + Bridge + Verify
328
+
329
+ Same as first install Steps 3-6 above.
330
+
331
+ ### Step 6: Demote to Node
332
+
333
+ ```bash
334
+ crystal demote
335
+ ```
336
+
337
+ This machine is now a Crystal Node. Conversations are captured, encrypted, and relayed to the Core. The Core embeds everything and pushes a searchable mirror back.
338
+
339
+ ---
340
+
341
+ ## Role Management
342
+
343
+ Users can check and change roles at any time:
344
+
345
+ ```bash
346
+ crystal role # Show current role
347
+ crystal promote # Make this device the Crystal Core
348
+ crystal demote # Make this device a Crystal Node
349
+ ```
350
+
351
+ If a user starts on a laptop and later gets a desktop, they can promote the desktop and demote the laptop. No data loss.
352
+
353
+ ---
354
+
355
+ ## Coming Back Later
356
+
357
+ Users can always come back and say:
358
+
359
+ > "Hey, can you check what Memory Crystal features I have installed and what I'm missing?"
360
+
361
+ Run:
362
+
363
+ ```bash
364
+ crystal doctor
365
+ ```
366
+
367
+ This shows the full state of the install: role, database, embeddings, capture, relay, MCP, backup, bridge. Each check shows OK, WARN, or FAIL with a suggested fix.
368
+
369
+ ---
370
+
371
+ ## Tools
372
+
373
+ Once installed, these tools are available to the AI:
374
+
375
+ ### crystal_search
376
+
377
+ Search across all stored memory. Semantic search with recency-weighted results.
378
+
379
+ ```
380
+ crystal_search query="how do plugins work" limit=5
381
+ crystal_search query="user preferences" agent_id="main"
382
+ ```
383
+
384
+ Results are ranked by relevance and freshness, with color-coded freshness indicators:
385
+ - fresh (less than 3 days)
386
+ - recent (less than 7 days)
387
+ - aging (less than 14 days)
388
+ - stale (14+ days)
389
+
390
+ ### crystal_remember
391
+
392
+ Store a fact or observation that persists across sessions.
393
+
394
+ ```
395
+ crystal_remember text="User prefers Opus for complex tasks" category="preference"
396
+ crystal_remember text="API key rotated on 2026-03-01" category="event"
397
+ ```
398
+
399
+ Categories: fact, preference, event, opinion, skill
400
+
401
+ ### crystal_forget
402
+
403
+ Deprecate a stored memory by ID (marks as deprecated, doesn't delete).
404
+
405
+ ```
406
+ crystal_forget id=42
407
+ ```
408
+
409
+ ### crystal_status
410
+
411
+ Check memory health: chunk count, agents, provider, data directory.
412
+
413
+ ```
414
+ crystal_status
415
+ ```
416
+
417
+ ---
418
+
419
+ ## Tips
420
+
421
+ - Search is semantic. "how do plugins work" finds conversations about plugin architecture even if those exact words weren't used.
422
+ - Store preferences and decisions as memories. They survive compaction and context limits.
423
+ - Use `agent_id` filter when you only want results from a specific agent.
424
+ - The cron job captures conversations every minute. No data loss even in long sessions.
425
+ - Available providers: openai (default), ollama (local, free), google.
426
+ - All runtimes (Claude Code, Claude Desktop, OpenClaw) share the same database at `~/.ldm/memory/crystal.db`.
427
+ - Run `crystal doctor` anytime to check what's installed and what's missing.
@@ -0,0 +1,8 @@
1
+ name = "memory-crystal-demo"
2
+ main = "dist/worker-demo.js"
3
+ compatibility_date = "2024-12-01"
4
+ compatibility_flags = ["nodejs_compat"]
5
+
6
+ [[kv_namespaces]]
7
+ binding = "DEMO_KV"
8
+ id = "7dab6efe89f443688e178f6135aa3f3b"
@@ -0,0 +1,24 @@
1
+ name = "memory-crystal-cloud"
2
+ main = "dist/worker-mcp.js"
3
+ compatibility_date = "2024-12-01"
4
+
5
+ # D1 — OAuth tables + cloud storage (chunks, memories)
6
+ [[d1_databases]]
7
+ binding = "DB"
8
+ database_name = "memory-crystal-cloud"
9
+ database_id = "40ca6b73-3701-453e-adb3-7faf1a9964ad" # fill after: wrangler d1 create memory-crystal-cloud
10
+
11
+ # Vectorize — Semantic vector search (1024 dims, cosine)
12
+ [[vectorize]]
13
+ binding = "VECTORIZE"
14
+ index_name = "memory-crystal-chunks"
15
+
16
+ # R2 — Shared relay bucket (for Tier 1 sovereign drops)
17
+ [[r2_buckets]]
18
+ binding = "RELAY"
19
+ bucket_name = "memory-crystal-relay"
20
+
21
+ # Secrets (set via `wrangler secret put --config wrangler-mcp.toml`):
22
+ # OPENAI_API_KEY — for embeddings (text-embedding-3-small)
23
+ # RELAY_ENCRYPTION_KEY — base64, for Tier 1 relay encryption
24
+ # MCP_SIGNING_KEY — for signing OAuth tokens