beans-memory 0.0.0-stage → 0.1.5

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.
package/README.md CHANGED
@@ -1,3 +1,400 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="docs/wordmark.svg" alt="beans-memory" width="520">
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <p align="center">
6
+ Local, persistent memory for coding agents. One SQLite file. No daemon, no cloud, no account.
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://github.com/firasmpratama/beans-memory/tags"><img src="https://img.shields.io/github/v/tag/firasmpratama/beans-memory" alt="Latest tag"></a>
11
+ <a href="https://www.npmjs.com/package/beans-memory"><img src="https://img.shields.io/npm/v/beans-memory" alt="npm version"></a>
12
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/firasmpratama/beans-memory" alt="License: MIT"></a>
13
+ <a href="https://github.com/firasmpratama/beans-memory/stargazers"><img src="https://img.shields.io/github/stars/firasmpratama/beans-memory" alt="GitHub stars"></a>
14
+ <img src="https://img.shields.io/github/last-commit/firasmpratama/beans-memory" alt="Last commit">
15
+ <img src="https://img.shields.io/badge/Bun-%3E%3D1.2-000000?logo=bun&logoColor=white" alt="Bun 1.2+">
16
+ <img src="https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-lightgrey" alt="Platforms">
17
+ </p>
18
+
19
+ <p align="center">
20
+ English | <a href="README.id.md">Bahasa Indonesia</a>
21
+ </p>
22
+
23
+ The agent can save notes while it works, search them later, and gets a small index injected at the start of each session.
24
+
25
+ ## Install
26
+
27
+ Requires Bun 1.2+ (https://bun.sh). macOS, Linux, and Windows are supported.
28
+
29
+ From npm:
30
+
31
+ ```bash
32
+ bun add -g beans-memory
33
+ beans-memory install
34
+ ```
35
+
36
+ `install` writes the OpenCode plugin loader, copies the shared skill for OpenCode and Claude Code, and configures MCP for the clients it detects: Codex, Gemini CLI, and Hermes. Restart OpenCode after the first install.
37
+
38
+ Pick targets explicitly when needed:
39
+
40
+ ```bash
41
+ beans-memory install --opencode --claude --codex --gemini --hermes
42
+ beans-memory install --all
43
+ beans-memory install --dry-run
44
+ ```
45
+
46
+ Existing configs are never replaced blindly. If a target config already defines `beans-memory` without the managed block, the installer leaves it untouched and prints the snippet to add by hand. To run from source instead, see Quick start from source below.
47
+
48
+ ## How it works
49
+
50
+ ```
51
+ OpenCode (Bun runtime)
52
+ ├── plugin src/plugin.ts hooks + memory_* tools, runs in-process
53
+ ├── MCP src/mcp.ts same tools over stdio, for other clients
54
+ └── SQLite ~/.local/share/beans-memory/memory.db
55
+ observations + FTS5 + prompts + sessions
56
+ ```
57
+
58
+ - **Plugin** captures user prompts, records files touched by edit/write tools, and injects the 8 most recent note titles once per session.
59
+ - **Tools** let the agent write and search durable notes. Summaries are written by the agent itself, so no extra model call and no background worker.
60
+ - **MCP** exposes the same store to any MCP client (Claude Desktop, Cursor, scripts).
61
+ - **Search** uses SQLite FTS5: AND first, OR as fallback, ranked with BM25.
62
+ - Everything fails open. If the database or plugin breaks, OpenCode keeps working without memory.
63
+
64
+ ## Requirements
65
+
66
+ - OpenCode 2
67
+ - Bun 1.2+ for the CLI, MCP server, importers, and tests. Not needed for the plugin alone: it runs inside OpenCode's bundled Bun.
68
+ - `curl -fsSL https://bun.sh/install | bash` on macOS/Linux, or `powershell -c "irm bun.sh/install.ps1 | iex"` on Windows.
69
+ - macOS, Linux, or Windows.
70
+
71
+ ## Quick start from source
72
+
73
+ Use this when you want to run the code from disk. For a normal install, use npm above.
74
+
75
+ ```bash
76
+ git clone https://github.com/firasmpratama/beans-memory ~/tools/beans-memory
77
+ cd ~/tools/beans-memory
78
+ ./install.sh
79
+ ```
80
+
81
+ `install.sh` runs on macOS and Linux. On Windows, run `bun src/cli.ts install --opencode` from the repository instead.
82
+
83
+ Then restart OpenCode and ask the agent to call `memory_stats`. On a fresh install it returns zero notes.
84
+
85
+ The installer writes the plugin loader, creates the `beans-memory` CLI launcher when Bun is available, and installs the skill. It does not edit `opencode.json` and does not start a service.
86
+
87
+ No git? Download the source archive from the Releases page, unpack it anywhere permanent, and run `./install.sh` there.
88
+
89
+ ### Manual install
90
+
91
+ <details>
92
+ <summary>Prefer to wire it yourself, or the script failed?</summary>
93
+
94
+ 1. Get the code somewhere permanent:
95
+
96
+ ```bash
97
+ git clone https://github.com/firasmpratama/beans-memory ~/tools/beans-memory
98
+ cd ~/tools/beans-memory
99
+ bun test # optional, requires Bun; uses a temporary database
100
+ ```
101
+
102
+ 2. Create the OpenCode loader:
103
+
104
+ ```bash
105
+ mkdir -p ~/.config/opencode/plugins/memory
106
+ ```
107
+
108
+ `~/.config/opencode/plugins/memory/index.ts`:
109
+
110
+ ```ts
111
+ import { pathToFileURL } from "node:url";
112
+
113
+ const ENTRY = "/absolute/path/to/beans-memory/src/plugin.ts";
114
+
115
+ const noop = {
116
+ id: "memory",
117
+ async setup() {
118
+ return () => {};
119
+ },
120
+ };
121
+
122
+ let plugin: unknown = noop;
123
+
124
+ try {
125
+ const loaded = await import(pathToFileURL(ENTRY).href);
126
+ if (loaded?.default?.setup) plugin = loaded.default;
127
+ } catch (error) {
128
+ console.error("[memory] plugin not loaded:", error);
129
+ }
130
+
131
+ export default plugin;
132
+ ```
133
+
134
+ Replace `ENTRY` with the real path. Keep the fallback: if the code is on an external drive that is not mounted, OpenCode still starts with memory disabled instead of failing.
135
+
136
+ The directory name and file name are free-form. OpenCode loads any `.ts` file under `~/.config/opencode/plugins/`.
137
+
138
+ 3. Restart OpenCode.
139
+
140
+ 4. Verify. Ask the agent to call `memory_stats`. On a fresh install it returns zero notes. If the tool is missing, see Troubleshooting.
141
+
142
+ Check the loader itself without OpenCode, if Bun is installed:
143
+
144
+ ```bash
145
+ bun -e 'import("/absolute/path/to/beans-memory/src/plugin.ts").then((m) => console.log(typeof m.default.setup))'
146
+ ```
147
+
148
+ It should print `function`. A path or import error here will also break the plugin in OpenCode.
149
+
150
+ </details>
151
+
152
+ ## Use
153
+
154
+ Tools registered by the plugin:
155
+
156
+ | Tool | Purpose |
157
+ |---|---|
158
+ | `memory_note` | Save a note: title, body, type, files, concepts |
159
+ | `memory_search` | Full-text search, returns compact rows with ids |
160
+ | `memory_get` | Full bodies by id |
161
+ | `memory_stats` | Counts and last note date |
162
+
163
+ Suggested workflow for the agent: call `memory_note` after a task that produced a decision, bugfix, or non-obvious wiring discovery. Search first with `memory_search`, then fetch only the rows you need with `memory_get`.
164
+
165
+ Guided by `AGENTS.md`, the agent should keep notes short: what changed, why, and which files matter.
166
+
167
+ ## MCP server (optional)
168
+
169
+ After `bun add -g beans-memory`, the server is also available as `beans-memory-mcp` on PATH. For clients that accept a command array:
170
+
171
+ ```jsonc
172
+ { "command": ["beans-memory-mcp"] }
173
+ ```
174
+
175
+ For clients that cannot load the plugin:
176
+
177
+ ```jsonc
178
+ {
179
+ "mcp": {
180
+ "servers": {
181
+ "beans_memory": {
182
+ "type": "local",
183
+ "command": ["/absolute/path/to/bun", "/absolute/path/to/beans-memory/src/mcp.ts"]
184
+ }
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ - The server speaks JSON-RPC over stdio, one message per line.
191
+ - Tools: `memory_search`, `memory_get`, `memory_note`, `memory_stats`.
192
+ - Database selection: `MEMORY_DB`, otherwise `~/.local/share/beans-memory/memory.db`.
193
+ - Project name: `MEMORY_PROJECT`, otherwise the basename of the process working directory.
194
+
195
+ Claude Desktop example:
196
+
197
+ ```json
198
+ {
199
+ "mcpServers": {
200
+ "beans-memory": {
201
+ "command": "/absolute/path/to/bun",
202
+ "args": ["/absolute/path/to/beans-memory/src/mcp.ts"],
203
+ "env": { "MEMORY_DB": "/Users/you/.local/share/beans-memory/memory.db" }
204
+ }
205
+ }
206
+ }
207
+ ```
208
+
209
+ ## CLI and skill (optional)
210
+
211
+ The same store is available without any tool registration. Install the CLI globally from npm, then register the plugin and skill once:
212
+
213
+ ```bash
214
+ bun add -g beans-memory
215
+ beans-memory install
216
+ beans-memory stats
217
+ ```
218
+
219
+ Or run it from the repository:
220
+
221
+ ```bash
222
+ bun src/cli.ts search "query" --limit 5
223
+ bun src/cli.ts get 12 13
224
+ bun src/cli.ts note --title "Title" --type decision --body "What changed and why"
225
+ bun src/cli.ts note --title "Title" --stdin <<'EOF'
226
+ Multi-line body.
227
+ EOF
228
+ bun src/cli.ts recent --limit 5
229
+ bun src/cli.ts stats
230
+ bun src/cli.ts projects
231
+ ```
232
+
233
+ Flags: `--limit`, `--type`, `--files a,b`, `--concepts x,y`, `--json`, `--db <path>`, `--project <name>`.
234
+
235
+ Install a launcher on PATH:
236
+
237
+ ```bash
238
+ printf '#!/bin/sh\nexec /ABSOLUTE/PATH/TO/bun /ABSOLUTE/PATH/TO/beans-memory/src/cli.ts "$@"\n' \
239
+ > ~/.local/bin/beans-memory
240
+ chmod +x ~/.local/bin/beans-memory
241
+ ```
242
+
243
+ The skill in `skills/beans-memory/SKILL.md` teaches the agent when to run those commands. Copy it to `~/.claude/skills/beans-memory/SKILL.md`; OpenCode and Claude Code both read that directory.
244
+
245
+ When the skill is the only path you want, set `MEMORY_TOOLS=off` before starting OpenCode. Plugin hooks still capture prompts and inject context; the four plugin tools are not registered.
246
+
247
+ ## Other agents
248
+
249
+ The MCP server works with any client that speaks stdio MCP. Every agent on the same machine shares one database, so a note saved from Claude Code is visible in Codex, Gemini CLI, and OpenCode.
250
+
251
+ `beans-memory install --all` writes these configs automatically when the key is absent or when the managed block exists. The ready-to-copy files in `examples/` are for manual setup; replace `/ABSOLUTE/PATH/TO/` with real paths first.
252
+
253
+ ### Claude Code
254
+
255
+ ```bash
256
+ claude mcp add --scope user --transport stdio beans_memory -- \
257
+ /ABSOLUTE/PATH/TO/bun /ABSOLUTE/PATH/TO/beans-memory/src/mcp.ts
258
+ ```
259
+
260
+ Or copy `examples/claude-code.mcp.json` to `.mcp.json` at the project root for a project-scoped server that the whole team can share.
261
+
262
+ Tool names are prefixed: `mcp__beans_memory__memory_search`.
263
+
264
+ ### Codex
265
+
266
+ Merge `examples/codex.config.toml` into `~/.codex/config.toml`. For a project-scoped server, use `.codex/config.toml` inside a trusted project instead.
267
+
268
+ ### Gemini CLI
269
+
270
+ ```bash
271
+ gemini mcp add -s user beans-memory \
272
+ /ABSOLUTE/PATH/TO/bun /ABSOLUTE/PATH/TO/beans-memory/src/mcp.ts
273
+ ```
274
+
275
+ Or merge `examples/gemini.settings.json` into `~/.gemini/settings.json`.
276
+
277
+ Keep the hyphen in the server name (`beans-memory`). Gemini builds tool names as `mcp_<server>_<tool>` and its policy parser splits on the first underscore, so an underscore in the server name breaks wildcard rules.
278
+
279
+ ### Tell the agent to use it
280
+
281
+ Config alone only exposes tools. Append `examples/memory-instructions.md` to the agent instruction file: `CLAUDE.md`, `AGENTS.md`, or `GEMINI.md`.
282
+
283
+ ## Data
284
+
285
+ Default location:
286
+
287
+ ```
288
+ ~/.local/share/beans-memory/memory.db
289
+ ```
290
+
291
+ On Windows the same path resolves to `%USERPROFILE%\.local\share\beans-memory\memory.db`.
292
+
293
+ Override with `MEMORY_DB=/path/to/memory.db`. All projects share one file; the `project` column separates them. The project name comes from the basename of the working directory, so `~/work/api` is project `api`.
294
+
295
+ Backup, with OpenCode closed:
296
+
297
+ ```bash
298
+ cp ~/.local/share/beans-memory/memory.db ~/backup-memory.db
299
+ ```
300
+
301
+ Or online:
302
+
303
+ ```bash
304
+ sqlite3 ~/.local/share/beans-memory/memory.db ".backup '/path/to/copy.db'"
305
+ ```
306
+
307
+ Reset: stop OpenCode, delete the file, start again. The schema is recreated empty.
308
+
309
+ Timestamps are stored in UTC and displayed in local time.
310
+
311
+ ## Import from claude-mem (optional)
312
+
313
+ If you have an old `~/.claude-mem/claude-mem.db`:
314
+
315
+ ```bash
316
+ cd /path/to/beans-memory
317
+
318
+ # observations; discovery-type rows are skipped by default
319
+ bun src/import-claude-mem-db.ts --dry-run
320
+ bun src/import-claude-mem-db.ts
321
+
322
+ # session summaries and historical prompts
323
+ bun src/import-claude-mem-extras.ts --dry-run
324
+ bun src/import-claude-mem-extras.ts
325
+ ```
326
+
327
+ Flags: `--source`, `--db`, `--project`, `--include-discovery`, `--dry-run`.
328
+
329
+ To migrate a database created by an older version of this project:
330
+
331
+ ```bash
332
+ bun src/migrate-legacy-db.ts --from /old/memory.db
333
+ ```
334
+
335
+ ## Security
336
+
337
+ - Data stays on this machine. No network calls, no telemetry.
338
+ - Notes are stored as written. There is no secret redaction for notes. Do not save tokens, passwords, or `.env` contents into a note.
339
+ - Prompts captured automatically are redacted for common secret patterns: OpenAI/GitHub/AWS/Google API keys, Slack/Discord webhooks, and `password=` / `token:` style assignments. Redaction is best effort, not a guarantee, so still avoid pasting secrets into chat.
340
+ - The database is readable by any process running as your user. Treat it like a notes file, not a vault.
341
+ - File permissions are set to `0600` on macOS and Linux. On Windows the database inherits the ACL of the user profile.
342
+ - Report vulnerabilities through [GitHub private vulnerability reporting](https://github.com/firasmpratama/beans-memory/security/advisories/new), not a public issue. See [SECURITY.md](.github/SECURITY.md) for what to include.
343
+
344
+ ## Troubleshooting
345
+
346
+ - `memory_stats` is missing after restart: check the `ENTRY` path in the loader and run the `bun -e` check above. OpenCode logs loader errors to `~/.local/share/opencode/log/opencode.log`.
347
+ - Plugin silently does nothing: the loader caught an import error, usually because the code lives on an unmounted drive. Mount it and restart.
348
+ - `Cannot use import statement outside a module`: create `~/.config/opencode/plugins/package.json` with `{"type":"module"}`.
349
+ - `database is locked`: another process is writing. Close extra agents or wait; the database uses WAL with a 5 second busy timeout.
350
+ - Permission denied on the database: files are `0600` and the directory `0700` by design. Run as the user that created it.
351
+
352
+ ## Limitations
353
+
354
+ - Keyword search only, no embeddings.
355
+ - No automatic summarization. Notes exist only when the agent writes them.
356
+ - Context injection is a short index (8 titles), not full bodies.
357
+ - Project identity is the working-directory basename. Two unrelated repositories with the same folder name share notes unless you set `MEMORY_PROJECT`.
358
+ - Single user, single machine. No sync.
359
+ - SQLite is accessed by the plugin process and the MCP process. WAL mode plus a 5 second busy timeout handles that; heavy concurrent writes are not a design goal.
360
+
361
+ ## Development
362
+
363
+ Install the dev dependencies once, then use the scripts:
364
+
365
+ ```bash
366
+ bun install
367
+ bun test
368
+ bun run typecheck
369
+ bun run test:coverage
370
+ ```
371
+
372
+ ## Layout
373
+
374
+ ```
375
+ src/db.ts schema, FTS5, migrations
376
+ src/repo.ts queries: sessions, prompts, observations, search
377
+ src/plugin.ts OpenCode plugin: hooks and tools
378
+ src/mcp.ts MCP stdio server
379
+ src/cli.ts CLI for skill-based use
380
+ src/install.ts multi-agent installer: opencode, claude, codex, gemini, hermes
381
+ src/time.ts UTC to local formatting
382
+ src/redact.ts secret redaction for captured prompts
383
+ src/rehash.ts one-time hash migration
384
+ src/redact-prompts.ts redact existing prompt rows
385
+ src/import-claude-mem-db.ts import observations from claude-mem
386
+ src/import-claude-mem-extras.ts import summaries and prompts
387
+ src/migrate-legacy-db.ts copy an older beans-memory database
388
+ skills/beans-memory/ agent skill for the CLI
389
+ test/ bun test: repo, edges, time, MCP, CLI, redaction
390
+ ```
391
+
392
+ ## Uninstall
393
+
394
+ 1. Remove `~/.config/opencode/plugins/memory/`.
395
+ 2. Remove the `beans_memory` entry from `opencode.json` if you added it.
396
+ 3. Delete `~/.local/share/beans-memory/` if you do not want to keep the notes.
397
+
398
+ ## License
399
+
400
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,36 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="792" height="430" viewBox="0 0 792 430" role="img" aria-labelledby="t d">
2
+ <title id="t">beans-memory</title>
3
+ <desc id="d">Wordmark: a golden bean with a sprout above the name beans-memory.</desc>
4
+ <defs>
5
+ <linearGradient id="bean" x1="0" y1="0" x2="0.4" y2="1">
6
+ <stop offset="0" stop-color="#FBE0A8"/>
7
+ <stop offset="0.62" stop-color="#EDBE72"/>
8
+ <stop offset="1" stop-color="#C98F41"/>
9
+ </linearGradient>
10
+ <linearGradient id="leaf" x1="0" y1="0" x2="1" y2="1">
11
+ <stop offset="0" stop-color="#A9C286"/>
12
+ <stop offset="1" stop-color="#7E9B5C"/>
13
+ </linearGradient>
14
+ </defs>
15
+
16
+ <rect x="1" y="1" width="790" height="428" rx="34" fill="#FDF7EA" stroke="#E8D7B8" stroke-width="2"/>
17
+
18
+ <g transform="translate(236.00 22.00) scale(0.4)">
19
+ <ellipse cx="400" cy="500" rx="140" ry="17" fill="#8B5A2B" opacity="0.12"/>
20
+ <path d="M430 138
21
+ C548 158 608 256 582 368
22
+ C560 462 478 510 396 500
23
+ C326 492 262 446 242 378
24
+ C232 346 243 322 268 317
25
+ C300 311 329 291 339 259
26
+ C352 214 380 163 430 138Z"
27
+ fill="url(#bean)" stroke="#5F3A1A" stroke-width="8" stroke-linejoin="round"/>
28
+ <path d="M260 336 C292 334 320 310 334 272" fill="none" stroke="#FFE8BC" stroke-width="11" stroke-linecap="round" opacity="0.85"/>
29
+ <path d="M262 340 C294 338 322 314 336 276" fill="none" stroke="#8A5A28" stroke-width="3" stroke-linecap="round" opacity="0.5"/>
30
+ <path d="M470 212 C452 250 446 300 452 350" fill="none" stroke="#FFF0CC" stroke-width="12" stroke-linecap="round" opacity="0.35"/>
31
+ </g>
32
+
33
+ <g transform="translate(55.75 360.00)" fill="#6E4420">
34
+ <path transform="translate(0.00 0) scale(0.044922 -0.044922)" d="M393 1335V918Q470 998 550.0 1040.5Q630 1083 748 1083Q884 1083 986.5 1018.5Q1089 954 1145.5 831.5Q1202 709 1202 541Q1202 417 1170.5 313.5Q1139 210 1079.0 134.0Q1019 58 933.5 16.5Q848 -25 745 -25Q682 -25 626.5 -10.0Q571 5 532.0 29.5Q493 54 465.5 80.0Q438 106 393 158V131Q393 54 356.0 14.5Q319 -25 262 -25Q204 -25 169.5 14.5Q135 54 135 131V1323Q135 1406 168.5 1448.5Q202 1491 262 1491Q325 1491 359.0 1450.5Q393 1410 393 1335ZM406 524Q406 361 480.5 273.5Q555 186 676 186Q779 186 853.5 275.5Q928 365 928 532Q928 640 897.0 718.0Q866 796 809.0 838.5Q752 881 676 881Q598 881 537.0 838.5Q476 796 441.0 715.5Q406 635 406 524Z"/><path transform="translate(58.70 0) scale(0.044922 -0.044922)" d="M903 463H369Q370 370 406.5 299.0Q443 228 503.5 192.0Q564 156 637 156Q686 156 726.5 167.5Q767 179 805.0 203.5Q843 228 875.0 256.0Q907 284 958 332Q979 350 1018 350Q1060 350 1086.0 327.0Q1112 304 1112 262Q1112 225 1083.0 175.5Q1054 126 995.5 80.5Q937 35 848.5 5.0Q760 -25 645 -25Q382 -25 236.0 125.0Q90 275 90 532Q90 653 126.0 756.5Q162 860 231.0 934.0Q300 1008 401.0 1047.5Q502 1087 625 1087Q785 1087 899.5 1019.5Q1014 952 1071.0 845.0Q1128 738 1128 627Q1128 524 1069.0 493.5Q1010 463 903 463ZM369 618H864Q854 758 788.5 827.5Q723 897 616 897Q514 897 448.5 826.5Q383 756 369 618Z"/><path transform="translate(114.57 0) scale(0.044922 -0.044922)" d="M831 129Q732 52 639.5 13.5Q547 -25 432 -25Q327 -25 247.5 16.5Q168 58 125.0 129.0Q82 200 82 283Q82 395 153.0 474.0Q224 553 348 580Q374 586 477.0 607.0Q580 628 653.5 645.5Q727 663 813 688Q808 796 769.5 846.5Q731 897 610 897Q506 897 453.5 868.0Q401 839 363.5 781.0Q326 723 310.5 704.5Q295 686 244 686Q198 686 164.5 715.5Q131 745 131 791Q131 863 182.0 931.0Q233 999 341.0 1043.0Q449 1087 610 1087Q790 1087 893.0 1044.5Q996 1002 1038.5 910.0Q1081 818 1081 666Q1081 570 1080.5 503.0Q1080 436 1079 354Q1079 277 1104.5 193.5Q1130 110 1130 86Q1130 44 1090.5 9.5Q1051 -25 1001 -25Q959 -25 918.0 14.5Q877 54 831 129ZM813 524Q753 502 638.5 477.5Q524 453 480.0 441.5Q436 430 396.0 396.5Q356 363 356 303Q356 241 403.0 197.5Q450 154 526 154Q607 154 675.5 189.5Q744 225 776 281Q813 343 813 485Z"/><path transform="translate(170.44 0) scale(0.044922 -0.044922)" d="M389 934V901Q461 996 546.5 1040.5Q632 1085 743 1085Q851 1085 936.0 1038.0Q1021 991 1063 905Q1090 855 1098.0 797.0Q1106 739 1106 649V141Q1106 59 1068.5 17.0Q1031 -25 971 -25Q910 -25 872.0 18.0Q834 61 834 141V596Q834 731 796.5 802.5Q759 874 647 874Q574 874 514.0 830.5Q454 787 426 711Q406 650 406 483V141Q406 58 367.5 16.5Q329 -25 268 -25Q209 -25 171.0 18.0Q133 61 133 141V930Q133 1008 167.0 1046.5Q201 1085 260 1085Q296 1085 325.0 1068.0Q354 1051 371.5 1017.0Q389 983 389 934Z"/><path transform="translate(227.21 0) scale(0.044922 -0.044922)" d="M1020 332Q1020 219 965.0 138.5Q910 58 802.5 16.5Q695 -25 541 -25Q394 -25 289.0 20.0Q184 65 134.0 132.5Q84 200 84 268Q84 313 116.0 345.0Q148 377 197 377Q240 377 263.0 356.0Q286 335 307 297Q349 224 407.5 188.0Q466 152 567 152Q649 152 701.5 188.5Q754 225 754 272Q754 344 699.5 377.0Q645 410 520 440Q379 475 290.5 513.5Q202 552 149.0 615.0Q96 678 96 770Q96 852 145.0 925.0Q194 998 289.5 1041.5Q385 1085 520 1085Q626 1085 710.5 1063.0Q795 1041 851.5 1004.0Q908 967 937.5 922.0Q967 877 967 834Q967 787 935.5 757.0Q904 727 846 727Q804 727 774.5 751.0Q745 775 707 823Q676 863 634.0 887.0Q592 911 520 911Q446 911 397.0 879.5Q348 848 348 801Q348 758 384.0 730.5Q420 703 481.0 685.0Q542 667 649 641Q776 610 856.5 567.0Q937 524 978.5 465.5Q1020 407 1020 332Z"/><path transform="translate(278.27 0) scale(0.044922 -0.044922)" d="M500 412H184Q112 412 74.5 445.5Q37 479 37 532Q37 586 73.5 619.5Q110 653 184 653H500Q574 653 610.5 619.5Q647 586 647 532Q647 479 611.0 445.5Q575 412 500 412Z"/><path transform="translate(310.11 0) scale(0.044922 -0.044922)" d="M1049 510V147Q1049 61 1010.0 18.0Q971 -25 907 -25Q845 -25 806.5 18.0Q768 61 768 147V582Q768 685 761.0 742.0Q754 799 723.0 835.5Q692 872 625 872Q491 872 448.5 780.0Q406 688 406 516V147Q406 62 367.5 18.5Q329 -25 266 -25Q204 -25 164.5 18.5Q125 62 125 147V928Q125 1005 160.5 1045.0Q196 1085 254 1085Q310 1085 347.5 1047.5Q385 1010 385 944V918Q456 1003 537.0 1043.0Q618 1083 717 1083Q820 1083 894.0 1042.0Q968 1001 1016 918Q1085 1002 1164.0 1042.5Q1243 1083 1339 1083Q1451 1083 1532.0 1039.0Q1613 995 1653 913Q1688 839 1688 680V147Q1688 61 1649.0 18.0Q1610 -25 1546 -25Q1484 -25 1444.5 18.5Q1405 62 1405 147V606Q1405 694 1397.5 747.0Q1390 800 1357.0 836.0Q1324 872 1257 872Q1203 872 1154.5 840.0Q1106 808 1079 754Q1049 685 1049 510Z"/><path transform="translate(392.71 0) scale(0.044922 -0.044922)" d="M903 463H369Q370 370 406.5 299.0Q443 228 503.5 192.0Q564 156 637 156Q686 156 726.5 167.5Q767 179 805.0 203.5Q843 228 875.0 256.0Q907 284 958 332Q979 350 1018 350Q1060 350 1086.0 327.0Q1112 304 1112 262Q1112 225 1083.0 175.5Q1054 126 995.5 80.5Q937 35 848.5 5.0Q760 -25 645 -25Q382 -25 236.0 125.0Q90 275 90 532Q90 653 126.0 756.5Q162 860 231.0 934.0Q300 1008 401.0 1047.5Q502 1087 625 1087Q785 1087 899.5 1019.5Q1014 952 1071.0 845.0Q1128 738 1128 627Q1128 524 1069.0 493.5Q1010 463 903 463ZM369 618H864Q854 758 788.5 827.5Q723 897 616 897Q514 897 448.5 826.5Q383 756 369 618Z"/><path transform="translate(448.58 0) scale(0.044922 -0.044922)" d="M1049 510V147Q1049 61 1010.0 18.0Q971 -25 907 -25Q845 -25 806.5 18.0Q768 61 768 147V582Q768 685 761.0 742.0Q754 799 723.0 835.5Q692 872 625 872Q491 872 448.5 780.0Q406 688 406 516V147Q406 62 367.5 18.5Q329 -25 266 -25Q204 -25 164.5 18.5Q125 62 125 147V928Q125 1005 160.5 1045.0Q196 1085 254 1085Q310 1085 347.5 1047.5Q385 1010 385 944V918Q456 1003 537.0 1043.0Q618 1083 717 1083Q820 1083 894.0 1042.0Q968 1001 1016 918Q1085 1002 1164.0 1042.5Q1243 1083 1339 1083Q1451 1083 1532.0 1039.0Q1613 995 1653 913Q1688 839 1688 680V147Q1688 61 1649.0 18.0Q1610 -25 1546 -25Q1484 -25 1444.5 18.5Q1405 62 1405 147V606Q1405 694 1397.5 747.0Q1390 800 1357.0 836.0Q1324 872 1257 872Q1203 872 1154.5 840.0Q1106 808 1079 754Q1049 685 1049 510Z"/><path transform="translate(531.17 0) scale(0.044922 -0.044922)" d="M1163 530Q1163 408 1125.0 305.0Q1087 202 1015.0 128.0Q943 54 843.0 14.5Q743 -25 618 -25Q494 -25 395.0 15.0Q296 55 223.5 129.5Q151 204 113.5 305.5Q76 407 76 530Q76 654 114.0 757.0Q152 860 223.0 933.0Q294 1006 395.0 1045.5Q496 1085 618 1085Q742 1085 843.0 1045.0Q944 1005 1016.0 931.0Q1088 857 1125.5 755.0Q1163 653 1163 530ZM889 530Q889 697 815.5 790.0Q742 883 618 883Q538 883 477.0 841.5Q416 800 383.0 719.0Q350 638 350 530Q350 423 382.5 343.0Q415 263 475.5 220.5Q536 178 618 178Q742 178 815.5 271.5Q889 365 889 530Z"/><path transform="translate(587.94 0) scale(0.044922 -0.044922)" d="M412 369V141Q412 58 373.0 16.5Q334 -25 274 -25Q215 -25 177.0 17.0Q139 59 139 141V901Q139 1085 272 1085Q340 1085 370.0 1042.0Q400 999 403 915Q452 999 503.5 1042.0Q555 1085 641 1085Q727 1085 808.0 1042.0Q889 999 889 928Q889 878 854.5 845.5Q820 813 780 813Q765 813 707.5 831.5Q650 850 606 850Q546 850 508.0 818.5Q470 787 449.0 725.0Q428 663 420.0 577.5Q412 492 412 369Z"/><path transform="translate(629.44 0) scale(0.044922 -0.044922)" d="M393 -59 418 2 82 848Q51 921 51 954Q51 989 69.0 1019.0Q87 1049 118.5 1067.0Q150 1085 184 1085Q243 1085 273.0 1047.5Q303 1010 326 940L557 268L776 893Q802 969 823.0 1012.0Q844 1055 867.5 1070.0Q891 1085 934 1085Q965 1085 993.5 1068.5Q1022 1052 1037.5 1024.0Q1053 996 1053 965Q1049 946 1040.0 911.0Q1031 876 1018 840L662 -92Q616 -215 572.0 -285.0Q528 -355 455.5 -392.5Q383 -430 260 -430Q140 -430 80.0 -404.0Q20 -378 20 -309Q20 -262 48.5 -236.5Q77 -211 133 -211Q155 -211 176 -217Q202 -223 221 -223Q268 -223 295.0 -209.0Q322 -195 343.5 -160.5Q365 -126 393 -59Z"/>
35
+ </g>
36
+ </svg>
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "beans_memory": {
4
+ "command": "/ABSOLUTE/PATH/TO/bun",
5
+ "args": ["/ABSOLUTE/PATH/TO/beans-memory/src/mcp.ts"]
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ [mcp_servers.beans_memory]
2
+ command = "/ABSOLUTE/PATH/TO/bun"
3
+ args = ["/ABSOLUTE/PATH/TO/beans-memory/src/mcp.ts"]
4
+ startup_timeout_sec = 20
5
+ tool_timeout_sec = 60
6
+
7
+ [mcp_servers.beans_memory.env]
8
+ # MEMORY_DB = "/Users/you/.local/share/beans-memory/memory.db"
@@ -0,0 +1,10 @@
1
+ {
2
+ "mcpServers": {
3
+ "beans-memory": {
4
+ "command": "/ABSOLUTE/PATH/TO/bun",
5
+ "args": ["/ABSOLUTE/PATH/TO/beans-memory/src/mcp.ts"],
6
+ "timeout": 30000,
7
+ "trust": false
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,19 @@
1
+ # Memory instructions
2
+
3
+ Paste this block into the agent instruction file:
4
+
5
+ - Claude Code: `CLAUDE.md`
6
+ - Codex: `AGENTS.md`
7
+ - Gemini CLI: `GEMINI.md`
8
+ - OpenCode: `AGENTS.md`
9
+
10
+ ---
11
+
12
+ ## Project memory
13
+
14
+ Memories live in a local SQLite database, shared by every agent on this machine.
15
+
16
+ - Before starting work that may have been done before, call `memory_search` with a few keywords. Then call `memory_get` only for the ids that matter.
17
+ - After a task that produced a decision, a non-obvious bugfix, or wiring that is hard to rediscover, call `memory_note` with a short title and a body covering: what changed, why, and the files involved.
18
+ - Do not save secrets, tokens, passwords, or `.env` contents into a note.
19
+ - Keep notes short. One fact per note is easier to find than one long summary.
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "beans-memory",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.5",
4
+ "description": "Local persistent memory for OpenCode and other coding agents: SQLite + FTS5 plugin, MCP server, and CLI",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/firasmpratama/beans-memory.git"
10
+ },
11
+ "homepage": "https://github.com/firasmpratama/beans-memory",
12
+ "bugs": {
13
+ "url": "https://github.com/firasmpratama/beans-memory/issues"
14
+ },
15
+ "bin": {
16
+ "beans-memory": "./src/cli.ts",
17
+ "beans-memory-mcp": "./src/mcp.ts"
18
+ },
19
+ "files": [
20
+ "src",
21
+ "skills",
22
+ "examples",
23
+ "docs",
24
+ "README.md",
25
+ "README.id.md",
26
+ "SECURITY.md"
27
+ ],
28
+ "keywords": [
29
+ "opencode",
30
+ "memory",
31
+ "sqlite",
32
+ "fts5",
33
+ "mcp",
34
+ "coding-agent"
35
+ ],
36
+ "engines": {
37
+ "bun": ">=1.2.0"
38
+ },
39
+ "scripts": {
40
+ "test": "bun test",
41
+ "test:coverage": "bun test --coverage",
42
+ "typecheck": "tsc --noEmit"
43
+ },
44
+ "devDependencies": {
45
+ "@types/bun": "^1.4.5",
46
+ "typescript": "^7.0.2"
47
+ }
48
+ }
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: Beans Memory
3
+ description: Cari catatan proyek yang tersimpan dan simpan keputusan atau bugfix baru ke memory lokal. Gunakan sebelum mulai pekerjaan yang mungkin pernah dikerjakan, dan setelah tugas yang menghasilkan keputusan, bugfix, atau wiring yang sulit ditemukan lagi.
4
+ metadata:
5
+ opencode/autoinvoke: true
6
+ ---
7
+
8
+ # Beans Memory
9
+
10
+ Memory lokal berbasis SQLite. Tidak ada cloud, tidak ada akun.
11
+
12
+ CLI: `beans-memory`. Kalau perintah tidak tersedia, pakai `bunx beans-memory` (paket npm) atau `bun src/cli.ts` dari repo.
13
+
14
+ ## Sebelum mulai
15
+
16
+ Cari dulu apakah topik ini pernah dikerjakan:
17
+
18
+ ```bash
19
+ beans-memory search "kata kunci topik" --limit 5
20
+ ```
21
+
22
+ Kalau ada hasil relevan, buka isinya:
23
+
24
+ ```bash
25
+ beans-memory get <id> [<id>...]
26
+ ```
27
+
28
+ Gunakan `--json` kalau perlu memproses hasil secara terstruktur.
29
+
30
+ ## Setelah tugas
31
+
32
+ Simpan satu catatan ringkas untuk keputusan, bugfix, aturan bisnis, atau wiring yang tidak jelas dari kode:
33
+
34
+ ```bash
35
+ beans-memory note \
36
+ --title "Judul satu baris" \
37
+ --type decision \
38
+ --files "app/Contoh.php,app/Lain.php" \
39
+ --stdin <<'EOF'
40
+ Apa yang berubah, kenapa, dan bagian mana yang perlu diingat.
41
+ EOF
42
+ ```
43
+
44
+ Tipe yang tersedia: `decision`, `bugfix`, `feature`, `refactor`, `security_note`, `note`.
45
+
46
+ ## Aturan
47
+
48
+ - Satu catatan satu fakta. Jangan menulis ringkasan panjang.
49
+ - Sertakan alasan keputusan, bukan hanya perubahan.
50
+ - Jangan simpan token, password, isi `.env`, atau data pribadi.
51
+ - Project ditentukan dari nama folder kerja. Gunakan `--project <nama>` kalau perlu memisahkan.
52
+ - Cek `beans-memory stats` untuk melihat jumlah catatan project ini.