th-memory-mcp 1.1.0

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.
@@ -0,0 +1,41 @@
1
+ # AGENTS.md — Memory Protocol
2
+
3
+ This project ships an MCP server `th-memory-mcp` that provides long-term memory (local SQLite). Use this protocol every session:
4
+
5
+ ```markdown
6
+ ## Memory Protocol
7
+ - Before starting a new/complex task: always call get_profile() and recall("<topic>") first
8
+ - When the user corrects your work or points out a mistake: call save_lesson(situation, mistake, correction) immediately
9
+ - When the user states a fixed preference/requirement: call remember(category, key, value)
10
+ - Never guess the user's preference — if recall finds nothing, ask, then remember it
11
+ - Accept memory commands in both Thai and English (the user may switch languages anytime without warning)
12
+ ```
13
+
14
+ ## Tools
15
+
16
+ | Tool | Use when |
17
+ |------|---------|
18
+ | `remember(category, key, value)` | user states a preference/requirement (category: work_style / coding_pref / language / domain / other) |
19
+ | `recall(topic, limit?)` | before a new task — search preferences + lessons + recent interactions |
20
+ | `get_profile()` | need a user overview (sections + top preferences + recent lessons) |
21
+ | `save_lesson(situation, mistake, correction)` | corrected/called out — record the lesson immediately |
22
+ | `search_history(query, limit?)` | want context from the user's past prompts |
23
+ | `memory_stats()` | need memory stats (counts by kind, DB size, oldest/newest, profile sections) |
24
+ | `get_recent_interactions(limit?, kind?)` | view raw recent interactions (before distill / audit) |
25
+ | `export_memory(includeInteractions?, filename?)` | export all memory to a JSON file under data/exports/ |
26
+ | `forget(target_id)` | delete wrong/stale memory (id from remember/save_lesson output) |
27
+
28
+ ## Smart Distill
29
+
30
+ When the user asks "summarize memory / distill memory / summarize memory":
31
+
32
+ 1. call `get_recent_interactions(limit=50)`
33
+ 2. analyze real patterns — repeated preferences, lessons from corrections, working style
34
+ 3. record clear patterns via `remember(category, key, value)` / `save_lesson(...)`
35
+ 4. briefly summarize findings to the user
36
+
37
+ ## Setup
38
+
39
+ 1. Copy config from `opencode.example.json` and merge into your `opencode.json`
40
+ 2. Restart OpenCode
41
+ 3. Test: "Remember that I prefer pnpm" → in a new session ask which package manager you prefer
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 worakorn-prince
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # th-memory-mcp
2
+
3
+ Long-term memory MCP server for OpenCode — stores preferences, lessons, and usage history in a single local SQLite file (100% local, no external API) so the AI can "remember and adapt" to the user through context-based learning.
4
+
5
+ **Status:** v1.1.0 — all 4 phases implemented, tests passing 70/70 assertions (smoke 53 + capture 8 + distill 9)
6
+
7
+ ## Requirements
8
+
9
+ - **Node.js >= 20** — the server uses Node-only APIs (the `better-sqlite3` native build and `import.meta.url` resolution) and the MCP SDK requires a modern runtime. CI tests on Node 20.x and 22.x.
10
+ - **npm** — to install dependencies and run the build/test scripts (`npm install`, `npm run build`, `npm test`).
11
+ - **OpenCode** — the host that loads this MCP server and the auto-capture plugin. Any build supporting MCP over stdio + plugins works; the plugin runs on OpenCode's bundled Bun runtime.
12
+ - **OS: Windows / macOS / Linux** — the server is cross-platform (Node). The auto-capture plugin runs wherever OpenCode's Bun runtime runs. Windows note: `MEMORY_DB_PATH` is easiest to set with `setx`; on macOS/Linux use `export` in your shell profile.
13
+
14
+ No external services, accounts, or API keys are required — everything lives in a single local SQLite file.
15
+
16
+ ## Quick Start
17
+
18
+ **Fastest path:** after cloning, run `npm run quickstart` — it builds, wires `opencode.json`, deploys the plugin, and sets `MEMORY_DB_PATH` for you in one command. The steps below show exactly what it does (use them if you prefer manual control).
19
+
20
+ **Install via npm (alternative):** install the server globally with `npm install -g th-memory-mcp` (or run it on demand with `npx th-memory-mcp`), then point the `mcp` `command` in `opencode.json` to `th-memory-mcp` instead of the built `dist/index.js`. The auto-capture plugin still comes from this repo (copy `src/plugin/learning-capture.ts` as described in step 4 below).
21
+
22
+ ```bash
23
+ # 1. Clone and build
24
+ git clone https://github.com/worakorn-prince/th-memory-mcp.git
25
+ cd th-memory-mcp
26
+ npm install
27
+ npm run build
28
+
29
+ # 2. Share one DB between the server and the plugin
30
+ # Windows (PowerShell):
31
+ setx MEMORY_DB_PATH "$PWD/data/memory.db"
32
+ # macOS / Linux (add to your shell profile, e.g. ~/.zshrc):
33
+ # export MEMORY_DB_PATH="$PWD/data/memory.db"
34
+ ```
35
+
36
+ 3. Merge this into your `~/.config/opencode/opencode.json` (replace `<REPO>` with the absolute clone path):
37
+
38
+ ```json
39
+ {
40
+ "instructions": ["<REPO>/AGENTS.memory.example.md"],
41
+ "mcp": {
42
+ "memory": {
43
+ "type": "local",
44
+ "command": ["node", "<REPO>/dist/index.js"],
45
+ "enabled": true,
46
+ "environment": { "MEMORY_DB_PATH": "<REPO>/data/memory.db" }
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ 4. (Optional) Auto-capture: copy `src/plugin/learning-capture.ts` → `~/.config/opencode/plugins/`
53
+ 5. **Restart OpenCode**
54
+ 6. Try it: *"Remember that I prefer pnpm"* → new session → *"What package manager do I prefer?"*
55
+
56
+ ## Architecture
57
+
58
+ ```
59
+ OpenCode ──┬─ Plugin learning-capture (Bun) ── auto-captures prompts/tool/error into DB
60
+ │ └─ injects profile back into context on compaction
61
+ └─ MCP th-memory-mcp (Node.js stdio) ── 9 tools read/write the same SQLite DB
62
+
63
+ Global instructions (memory-protocol.md) teach the AI to use the tools
64
+ ```
65
+
66
+ See [design.md](design.md) for full details.
67
+
68
+ ## Why th-memory-mcp?
69
+
70
+ LLMs don't remember you between sessions — every new chat starts blank. th-memory-mcp gives your AI a private, local long-term memory:
71
+
72
+ - **Context-based learning, not fine-tuning** — it captures your preferences, corrections, and habits, then recalls them into context next time. Same mechanism as the memory features of leading AI products, without sending any data off your machine.
73
+ - **100% local & private** — a single SQLite file, no cloud, no external API. Secrets are filtered before anything is stored.
74
+ - **Low overhead** — each tool call is capped (latency < 10 ms, bounded output size) and the AI only queries memory when it's actually useful, so it never bloats your context.
75
+ - **Resilient** — every tool degrades gracefully; if the DB is unavailable the AI keeps working instead of crashing.
76
+ - **Open & extensible** — MIT licensed, 9 documented tools, a rule-based distill, and an auto-capture plugin you can adapt.
77
+
78
+ ## Scripts
79
+
80
+ | Command | Description |
81
+ |---------|-------------|
82
+ | `npm run build` | compile TypeScript → `dist/` |
83
+ | `npm start` | run the MCP server (stdio) from `dist/index.js` |
84
+ | `npm run distill` | rule-based distill: interactions → profile sections + prune old data (env `RETENTION_DAYS` default 30) |
85
+ | `npm test` | end-to-end smoke test over JSON-RPC (`node test/smoke.mjs`) |
86
+ | `node test/capture.test.mjs` | test capture-core (filter secrets, dedupe, truncate, insert SQL) |
87
+ | `node test/distill.test.mjs` | test distill-core (Thai tokenize, stats, profile sections, prune) |
88
+
89
+ ## Tools (9)
90
+
91
+ | Tool | Description |
92
+ |------|-------------|
93
+ | `remember` | upsert preference (category+key) — re-saving the same key increases confidence by 0.1 (cap 1.0) |
94
+ | `recall` | search preferences + lessons (FTS5) + recent matching interactions. Use before starting a new task |
95
+ | `get_profile` | user profile overview: profile sections + top preferences + 5 most recent lessons |
96
+ | `save_lesson` | record a lesson learned from a correction (situation / mistake / correction) |
97
+ | `search_history` | search past user prompts by keyword (200-char snippets per row) |
98
+ | `forget` | delete one memory row (preference/lesson/interaction) by id (+type prevents cross-table id clash) |
99
+ | `memory_stats` | memory statistics: counts by kind, DB size, oldest/newest interaction, profile sections |
100
+ | `get_recent_interactions` | list recent raw interactions (filter by kind) — feedstock for Smart Distill |
101
+ | `export_memory` | export memory to JSON under `data/exports/` only (filename auto-sanitized) |
102
+
103
+ ## Install with OpenCode
104
+
105
+ 1. Merge the `mcp` section from [`opencode.example.json`](opencode.example.json) into your `opencode.json` (global or project-level)
106
+ - **Important:** set `MEMORY_DB_PATH` to the SAME database file for both the server and the plugin (the example uses `<ABSOLUTE_PATH>/th-memory-mcp/data/memory.db`), otherwise the auto-capture plugin writes to a different DB than the one the AI reads
107
+ - How to set it (pick one):
108
+ - define it in the mcp `environment` (see example) — covers the MCP server only
109
+ - **or** set it as a system/user-level environment variable (e.g. `setx MEMORY_DB_PATH "D:/path/to/memory.db"` on Windows) — covers both server and plugin, since the plugin runs in the same process as OpenCode
110
+ 2. Attach the global memory rules — add to `opencode.json`:
111
+ ```json
112
+ "instructions": ["C:/Users/<user>/.config/opencode/memory-protocol.md"]
113
+ ```
114
+ (example rule content is in [`AGENTS.memory.example.md`](AGENTS.memory.example.md) — can be attached at project level instead)
115
+ 3. (Optional) Deploy the auto-capture plugin: copy `src/plugin/learning-capture.ts` → `~/.config/opencode/plugins/learning-capture.ts`
116
+ 4. **Restart OpenCode** (config loads at startup only)
117
+ 5. Test: *"Remember that I prefer pnpm"* → open a new session and ask back
118
+
119
+ ## Daily usage
120
+
121
+ The AI accepts both Thai and English interchangeably — you can switch languages at any time without warning.
122
+
123
+ | Example command | Tool / effect |
124
+ |-----------------|---------------|
125
+ | "Remember that..." | `remember` — save a preference |
126
+ | "Summarize memory" / "distill memory" | **Smart Distill** — AI reads `get_recent_interactions`, finds patterns, and saves insights itself |
127
+ | "How is my memory?" / "memory status" | `memory_stats` |
128
+ | "Export memory" / "backup memory" | `export_memory` |
129
+ | "Search history..." | `search_history` |
130
+ | "Forget..." | `forget` |
131
+
132
+ Long-term care: run `npm run distill` occasionally to summarize stats and prune interactions older than 30 days.
133
+
134
+ ## data/ structure
135
+
136
+ ```
137
+ data/
138
+ ├── memory.db # SQLite (WAL mode) — main DB (+ .db-wal, .db-shm)
139
+ └── exports/ # JSON files from export_memory (writeable only in this dir)
140
+ ```
141
+
142
+ - DB path can be overridden via the `MEMORY_DB_PATH` env var
143
+ - everything in `data/` is git-ignored
package/README.th.md ADDED
@@ -0,0 +1,143 @@
1
+ # th-memory-mcp
2
+
3
+ MCP server ความจำระยะยาวสำหรับ OpenCode — เก็บ preferences, lessons, ประวัติการใช้งาน ลง SQLite ไฟล์เดียว (local 100%, ไม่มี external API) เพื่อให้ AI "จำและปรับตัว" กับผู้ใช้ผ่าน context-based learning
4
+
5
+ **สถานะ:** v1.1.0 — อิมพลีเมนต์ครบ 4 Phase, tests ผ่าน 70/70 assertions (smoke 53 + capture 8 + distill 9)
6
+
7
+ > English: [README.md](README.md)
8
+
9
+ ## Requirements (ความต้องการระบบ)
10
+
11
+ - **Node.js >= 20** — server ใช้ API ของ Node โดยเฉพาะ (better-sqlite3 แบบ native build และการหา path ด้วย `import.meta.url`) และ MCP SDK ต้องการ runtime สมัยใหม่ CI ของเราทดสอบบน Node 20.x และ 22.x
12
+ - **npm** — สำหรับติดตั้ง dependencies และรัน build/test (`npm install`, `npm run build`, `npm test`)
13
+ - **OpenCode** — โปรแกรมหลักที่โหลด MCP server นี้และ plugin auto-capture ใช้ OpenCode รุ่นที่รองรับ MCP (stdio) + plugins (plugin รันบน Bun ที่มากับ OpenCode)
14
+ - **OS: Windows / macOS / Linux** — server ข้ามแพลตฟอร์มได้ (Node) plugin auto-capture รันได้ทุกที่ที่มี Bun ของ OpenCode หมายเหตุสำหรับ Windows: ตั้ง `MEMORY_DB_PATH` ง่ายสุดด้วย `setx` ส่วน macOS/Linux ใช้ `export` ใน shell profile
15
+
16
+ ไม่ต้องมีบริการภายนอก บัญชี หรือ API key — ทุกอย่างอยู่ในไฟล์ SQLite ภายในเครื่อง
17
+
18
+ ## Quick Start (เริ่มใช้งานไว)
19
+
20
+ **ทางที่เร็วที่สุด:** หลัง clone ให้รัน `npm run quickstart` — มันจะ build, ต่อไฟล์ `opencode.json`, วาง plugin และตั้ง `MEMORY_DB_PATH` ให้ในคำสั่งเดียว ขั้นตอนด้านล่างคือสิ่งที่สคริปต์ทำ (ใช้ได้หากอยากควบคุมเองทีละขั้น)
21
+
22
+ ```bash
23
+ # 1. Clone และ build
24
+ git clone https://github.com/worakorn-prince/th-memory-mcp.git
25
+ cd th-memory-mcp
26
+ npm install
27
+ npm run build
28
+
29
+ # 2. ให้ server และ plugin ใช้ DB เดียวกัน
30
+ # Windows (PowerShell):
31
+ setx MEMORY_DB_PATH "$PWD/data/memory.db"
32
+ # macOS / Linux (เพิ่มใน shell profile เช่น ~/.zshrc):
33
+ # export MEMORY_DB_PATH="$PWD/data/memory.db"
34
+ ```
35
+
36
+ 3. นำไป merge ใน `~/.config/opencode/opencode.json` (แทน `<REPO>` ด้วย path เต็มของโฟลเดอร์ที่ clone):
37
+
38
+ ```json
39
+ {
40
+ "instructions": ["<REPO>/AGENTS.memory.example.md"],
41
+ "mcp": {
42
+ "memory": {
43
+ "type": "local",
44
+ "command": ["node", "<REPO>/dist/index.js"],
45
+ "enabled": true,
46
+ "environment": { "MEMORY_DB_PATH": "<REPO>/data/memory.db" }
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ 4. (Optional) เปิด auto-capture: คัดลอก `src/plugin/learning-capture.ts` → `~/.config/opencode/plugins/`
53
+ 5. **Restart OpenCode**
54
+ 6. ลองใช้: *"จำไว้ว่าฉันชอบใช้ pnpm"* → เปิด session ใหม่ → *"ฉันชอบ package manager อะไร?"*
55
+
56
+ ## สถาปัตยกรรม
57
+
58
+ ```
59
+ OpenCode ──┬─ Plugin learning-capture (Bun) ── จับ prompt/tool/error ลง DB อัตโนมัติ
60
+ │ └─ ฉีด profile กลับ context ตอน compaction
61
+ └─ MCP th-memory-mcp (Node.js stdio) ── tools 9 ตัว อ่าน/เขียน SQLite เดียวกัน
62
+
63
+ Global instructions (memory-protocol.md) สอน AI ใช้ tools
64
+ ```
65
+
66
+ รายละเอียดเต็มอยู่ใน [design.md](design.md)
67
+
68
+ ## ทำไมต้องใช้ th-memory-mcp?
69
+
70
+ LLM ไม่ได้จำคุณข้าม session — แชทใหม่ทุกครั้งเริ่มจากศูนย์ th-memory-mcp มอบความจำระยะยาวแบบส่วนตัว ภายในเครื่อง ให้ AI ของคุณ:
71
+
72
+ - **เรียนรู้แบบ context-based ไม่ใช่ fine-tuning** — จับความชอบ/การถูกแก้/พฤติกรรม ของคุณ แล้วเรียกกลับเข้า context ครั้งหน้า กลไกเดียวกับฟีเจอร์ความจำของ AI ชั้นนำ โดยไม่ส่งข้อมูลออกนอกเครื่อง
73
+ - **local 100% และเป็นส่วนตัว** — ไฟล์ SQLite เดียว ไม่มีคลาวด์ ไม่มี external API มีการกรอง secret ก่อนบันทึกเสมอ
74
+ - **โอเวอร์เฮดต่ำ** — ทุก tool call มีเพดาน (latency < 10 ms, ขนาด output จำกัด) และ AI ค้นความจำเฉพาะตอนจำเป็น จึงไม่บวม context
75
+ - **ทนทาน** — ทุก tool ทำ graceful degradation ถ้า DB ไม่ได้เปิด AI ก็ทำงานต่อได้แทนที่จะพัง
76
+ - **เปิดกว้างและต่อยอดได้** — MIT license, 9 tools ที่อธิบายครบ, มี rule-based distill และ plugin auto-capture ที่คุณปรับแต่งได้
77
+
78
+ ## Scripts
79
+
80
+ | Command | คำอธิบาย |
81
+ |---------|----------|
82
+ | `npm run build` | compile TypeScript → `dist/` |
83
+ | `npm start` | รัน MCP server (stdio) จาก `dist/index.js` |
84
+ | `npm run distill` | rule-based distill: interactions → profile sections + prune ข้อมูลเก่า (env `RETENTION_DAYS` default 30) |
85
+ | `npm test` | smoke test end-to-end ผ่าน JSON-RPC (`node test/smoke.mjs`) |
86
+ | `node test/capture.test.mjs` | ทดสอบ capture-core (filter secrets, dedupe, truncate, insert SQL) |
87
+ | `node test/distill.test.mjs` | ทดสอบ distill-core (tokenize ไทย, stats, profile sections, prune) |
88
+
89
+ ## Tools (9)
90
+
91
+ | Tool | คำอธิบาย |
92
+ |------|----------|
93
+ | `remember` | upsert preference (category+key) — ยืนยันซ้ำ confidence +0.1 (cap 1.0) |
94
+ | `recall` | ค้น preferences + lessons (FTS5) + interactions ล่าสุดที่ match ตาม topic |
95
+ | `get_profile` | ภาพรวมผู้ใช้: profile sections + top preferences + lessons ล่าสุด 5 รายการ |
96
+ | `save_lesson` | บันทึกบทเรียนจากการถูกแก้ (situation / mistake / correction) |
97
+ | `search_history` | ค้น prompt เก่าด้วย keyword (snippet 200 chars/รายการ) |
98
+ | `forget` | ลบ row เดียว (preference/lesson/interaction) ตาม id (+type กัน id ชนข้ามตาราง) |
99
+ | `memory_stats` | สถิติความจำ: counts แยก kind, ขนาด DB, oldest/newest interaction, profile sections |
100
+ | `get_recent_interactions` | ดึง interactions ล่าสุดแบบดิบ (กรองตาม kind ได้) — วัตถุดิบของ Smart Distill |
101
+ | `export_memory` | export ความจำเป็น JSON ลง `data/exports/` เท่านั้น (sanitize filename ให้เอง) |
102
+
103
+ ## ติดตั้งกับ OpenCode
104
+
105
+ 1. Merge `mcp` section จาก [`opencode.example.json`](opencode.example.json) เข้า `opencode.json` (global หรือ project-level)
106
+ - **สำคัญ:** ตั้ง `MEMORY_DB_PATH` ให้ชี้ที่ไฟล์ DB เดียวกันทั้ง server และ plugin (ในตัวอย่างคือ `<ABSOLUTE_PATH>/th-memory-mcp/data/memory.db`) มิฉะนั้น auto-capture plugin จะเขียนลง DB คนละไฟล์กับที่ AI อ่าน
107
+ - วิธีตั้ง (เลือกหนึ่ง):
108
+ - กำหนดใน `environment` ของ mcp (ดูตัวอย่าง) — ครอบคลุมเฉพาะ MCP server
109
+ - **หรือ** กำหนดเป็น environment variable ระดับระบบ/ผู้ใช้ (เช่น `setx MEMORY_DB_PATH "D:/path/to/memory.db"` บน Windows) — ครอบคลุมทั้ง server และ plugin เพราะ plugin รันใน process เดียวกับ OpenCode
110
+ 2. ผูกกฎความจำระดับ global — เพิ่มใน `opencode.json`:
111
+ ```json
112
+ "instructions": ["C:/Users/<user>/.config/opencode/memory-protocol.md"]
113
+ ```
114
+ (ตัวอย่างเนื้อหากฎอยู่ใน [`AGENTS.memory.example.md`](AGENTS.memory.example.md) — ใช้แนบระดับโปรเจกต์แทนได้)
115
+ 3. (Optional) Deploy plugin auto-capture: copy `src/plugin/learning-capture.ts` → `~/.config/opencode/plugins/learning-capture.ts`
116
+ 4. **Restart OpenCode** (config โหลดตอน start เท่านั้น)
117
+ 5. ทดสอบ: *"จำไว้ว่าฉันชอบใช้ pnpm"* → เปิด session ใหม่ถามกลับ
118
+
119
+ ## การใช้งานประจำวัน
120
+
121
+ AI รองรับสองภาษา (ไทย/อังกฤษ) สลับกันได้ตลอด โดยไม่ต้องแจ้งล่วงหน้า
122
+
123
+ | ไทย | English | สิ่งที่เกิด |
124
+ |------|---------|-----------|
125
+ | "จำไว้ว่า..." | "Remember that..." | `remember` — บันทึกความชอบ |
126
+ | "สรุปความจำ" / "distill memory" | "Summarize memory" / "distill memory" | **Smart Distill** — AI อ่าน `get_recent_interactions` วิเคราะห์ pattern แล้วบันทึก insight เอง |
127
+ | "ระบบความจำเป็นไงบ้าง" | "How is my memory?" / "memory status" | `memory_stats` |
128
+ | "สำรองความจำ" | "Export memory" / "backup memory" | `export_memory` |
129
+ | "ค้นประวัติ..." | "Search history..." | `search_history` |
130
+ | "ลืม..." | "Forget..." | `forget` |
131
+
132
+ ดูแลระยะยาว: รัน `npm run distill` เป็นครั้งคราวเพื่อสรุปสถิติ + ลบ interactions เก่าเกิน 30 วัน
133
+
134
+ ## โครงสร้าง data/
135
+
136
+ ```
137
+ data/
138
+ ├── memory.db # SQLite (WAL mode) — DB หลัก (+ .db-wal, .db-shm)
139
+ └── exports/ # ไฟล์ JSON จาก tool export_memory (เขียนได้เฉพาะ dir นี้)
140
+ ```
141
+
142
+ - path ของ DB override ได้ผ่าน env `MEMORY_DB_PATH`
143
+ - ทุกอย่างใน `data/` ถูก git ignore