@basicmemory/openclaw-basic-memory 0.1.0-alpha.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.
- package/LICENSE +21 -0
- package/README.md +576 -0
- package/bm-client.ts +879 -0
- package/commands/cli.ts +176 -0
- package/commands/skills.ts +52 -0
- package/commands/slash.ts +73 -0
- package/config.ts +152 -0
- package/hooks/capture.ts +95 -0
- package/hooks/recall.ts +66 -0
- package/index.ts +120 -0
- package/logger.ts +47 -0
- package/openclaw.plugin.json +83 -0
- package/package.json +68 -0
- package/schema/task-schema.ts +34 -0
- package/scripts/setup-bm.sh +32 -0
- package/skills/memory-defrag/SKILL.md +87 -0
- package/skills/memory-metadata-search/SKILL.md +208 -0
- package/skills/memory-notes/SKILL.md +250 -0
- package/skills/memory-reflect/SKILL.md +63 -0
- package/skills/memory-schema/SKILL.md +237 -0
- package/skills/memory-tasks/SKILL.md +162 -0
- package/tools/build-context.ts +123 -0
- package/tools/delete-note.ts +67 -0
- package/tools/edit-note.ts +118 -0
- package/tools/list-memory-projects.ts +94 -0
- package/tools/list-workspaces.ts +75 -0
- package/tools/memory-provider.ts +327 -0
- package/tools/move-note.ts +74 -0
- package/tools/read-note.ts +79 -0
- package/tools/schema-diff.ts +104 -0
- package/tools/schema-infer.ts +103 -0
- package/tools/schema-validate.ts +100 -0
- package/tools/search-notes.ts +130 -0
- package/tools/write-note.ts +78 -0
- package/types/openclaw.d.ts +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Basic Machines
|
|
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,576 @@
|
|
|
1
|
+
# openclaw-basic-memory
|
|
2
|
+
|
|
3
|
+
Local-first knowledge graph plugin for OpenClaw — persistent memory with graph search and composited memory search. Everything works locally with no cloud account required.
|
|
4
|
+
|
|
5
|
+
## What this plugin does
|
|
6
|
+
|
|
7
|
+
The `openclaw-basic-memory` plugin integrates [Basic Memory](https://github.com/basicmachines-co/basic-memory) with OpenClaw to provide:
|
|
8
|
+
|
|
9
|
+
- **Composited `memory_search`** — queries MEMORY.md, the BM knowledge graph, and active tasks in parallel
|
|
10
|
+
- **Persistent MCP stdio session** — keeps a single `bm mcp --transport stdio --project <name>` process alive
|
|
11
|
+
- **Auto-recall** — injects active tasks and recent activity as context at session start
|
|
12
|
+
- **Auto-capture** — records agent conversations as structured daily notes
|
|
13
|
+
- **Graph tools** — search, read, write, edit, delete, move, and navigate notes via `memory://` URLs
|
|
14
|
+
- **Skill workflows** — `/tasks`, `/reflect`, `/defrag`, `/schema` slash commands for guided memory management
|
|
15
|
+
|
|
16
|
+
All data stays on your machine as markdown files indexed locally with SQLite. Cloud sync is available but entirely optional — see [BASIC_MEMORY.md](./BASIC_MEMORY.md) for cloud setup.
|
|
17
|
+
|
|
18
|
+
For a practical runbook, see [Memory + Task Flow](./MEMORY_TASK_FLOW.md).
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
1. **[uv](https://docs.astral.sh/uv/)** — Python package manager used to install Basic Memory CLI
|
|
23
|
+
```bash
|
|
24
|
+
# macOS
|
|
25
|
+
brew install uv
|
|
26
|
+
|
|
27
|
+
# macOS / Linux
|
|
28
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
2. **[OpenClaw](https://docs.openclaw.ai)** with plugin support
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Install the plugin (automatically installs the bm CLI via uv)
|
|
37
|
+
openclaw plugins install @basicmemory/openclaw-basic-memory
|
|
38
|
+
|
|
39
|
+
# Enable and assign to the memory slot
|
|
40
|
+
openclaw plugins enable basic-memory --slot memory
|
|
41
|
+
|
|
42
|
+
# Restart the gateway
|
|
43
|
+
openclaw gateway restart
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Verify:
|
|
47
|
+
```bash
|
|
48
|
+
openclaw plugins list
|
|
49
|
+
openclaw plugins info basic-memory
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If `uv` is not installed, the `bm` CLI setup is skipped gracefully during install. Install `uv` first, then re-run the postinstall script:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
bash ~/.openclaw/extensions/openclaw-basic-memory/scripts/setup-bm.sh
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Development (local directory)
|
|
59
|
+
|
|
60
|
+
For plugin development, clone and link locally:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/basicmachines-co/openclaw-basic-memory.git
|
|
64
|
+
cd openclaw-basic-memory
|
|
65
|
+
bun install
|
|
66
|
+
openclaw plugins install -l "$PWD"
|
|
67
|
+
openclaw plugins enable basic-memory --slot memory
|
|
68
|
+
openclaw gateway restart
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or load directly from a path in your OpenClaw config:
|
|
72
|
+
|
|
73
|
+
```json5
|
|
74
|
+
{
|
|
75
|
+
plugins: {
|
|
76
|
+
load: {
|
|
77
|
+
paths: ["~/dev/openclaw-basic-memory"]
|
|
78
|
+
},
|
|
79
|
+
entries: {
|
|
80
|
+
"basic-memory": {
|
|
81
|
+
enabled: true
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
slots: {
|
|
85
|
+
memory: "basic-memory"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Bundled Skills
|
|
92
|
+
|
|
93
|
+
This plugin ships with six skills that are automatically available when the plugin is enabled — no manual installation needed:
|
|
94
|
+
|
|
95
|
+
- **`memory-tasks`** — structured task tracking that survives context compaction
|
|
96
|
+
- **`memory-reflect`** — periodic consolidation of recent notes into durable memory
|
|
97
|
+
- **`memory-defrag`** — periodic cleanup/reorganization of memory files
|
|
98
|
+
- **`memory-schema`** — schema lifecycle management (infer, create, validate, diff, evolve)
|
|
99
|
+
- **`memory-metadata-search`** — structured metadata search by custom frontmatter fields (status, priority, etc.)
|
|
100
|
+
- **`memory-notes`** — guidance for writing well-structured notes with observations and relations
|
|
101
|
+
|
|
102
|
+
Skills are loaded from the plugin's `skills/` directory. See the upstream source at [`basic-memory-skills`](https://github.com/basicmachines-co/basic-memory-skills).
|
|
103
|
+
|
|
104
|
+
#### Updating or adding skills with `npx skills`
|
|
105
|
+
|
|
106
|
+
You can update bundled skills or install new ones as they become available using the [Skills CLI](https://github.com/vercel-labs/skills):
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Update all basic-memory skills to latest
|
|
110
|
+
npx skills add basicmachines-co/basic-memory-skills --agent openclaw
|
|
111
|
+
|
|
112
|
+
# Install a specific skill
|
|
113
|
+
npx skills add basicmachines-co/basic-memory-skills --name memory-tasks --agent openclaw
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
This installs to the same `skills/` directory the plugin reads from, so updated skills take effect on the next session.
|
|
117
|
+
|
|
118
|
+
## Configuration
|
|
119
|
+
|
|
120
|
+
### Minimal (zero-config)
|
|
121
|
+
```json5
|
|
122
|
+
{
|
|
123
|
+
"basic-memory": {
|
|
124
|
+
enabled: true
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
This uses sensible defaults: auto-generated project name, maps Basic Memory to your workspace `memory/` directory, and captures conversations.
|
|
130
|
+
|
|
131
|
+
### Full configuration
|
|
132
|
+
```json5
|
|
133
|
+
{
|
|
134
|
+
"basic-memory": {
|
|
135
|
+
enabled: true,
|
|
136
|
+
config: {
|
|
137
|
+
project: "my-agent", // BM project name (default: "openclaw-{hostname}")
|
|
138
|
+
bmPath: "bm", // Path to BM CLI binary
|
|
139
|
+
projectPath: "~/.openclaw/workspace/memory/", // Optional override; supports absolute, ~/..., or workspace-relative paths
|
|
140
|
+
memoryDir: "memory/", // Relative memory dir for task scanning
|
|
141
|
+
memoryFile: "MEMORY.md", // Working memory file for grep search
|
|
142
|
+
autoCapture: true, // Index conversations automatically
|
|
143
|
+
captureMinChars: 10, // Min chars to trigger auto-capture
|
|
144
|
+
autoRecall: true, // Inject active tasks + recent activity at session start
|
|
145
|
+
recallPrompt: "Check for active tasks and recent activity. Summarize anything relevant to the current session.",
|
|
146
|
+
debug: false, // Verbose logging
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Configuration Options
|
|
153
|
+
|
|
154
|
+
| Option | Type | Default | Description |
|
|
155
|
+
|--------|------|---------|-------------|
|
|
156
|
+
| `project` | string | `"openclaw-{hostname}"` | Basic Memory project name |
|
|
157
|
+
| `bmPath` | string | `"bm"` | Path to Basic Memory CLI binary |
|
|
158
|
+
| `projectPath` | string | `"memory/"` | Directory for BM project data (resolved from workspace unless absolute) |
|
|
159
|
+
| `memoryDir` | string | `"memory/"` | Relative path for task scanning |
|
|
160
|
+
| `memoryFile` | string | `"MEMORY.md"` | Working memory file (grep-searched) |
|
|
161
|
+
| `autoCapture` | boolean | `true` | Auto-index agent conversations |
|
|
162
|
+
| `captureMinChars` | number | `10` | Minimum character threshold for auto-capture (both messages must be shorter to skip) |
|
|
163
|
+
| `autoRecall` | boolean | `true` | Inject active tasks and recent activity as context at session start |
|
|
164
|
+
| `recallPrompt` | string | *(see above)* | Instruction appended to recalled context — customize to change what the agent focuses on |
|
|
165
|
+
| `debug` | boolean | `false` | Enable verbose debug logs |
|
|
166
|
+
|
|
167
|
+
Snake_case aliases (`memory_dir`, `memory_file`, `auto_recall`, `recall_prompt`, `capture_min_chars`) are also supported.
|
|
168
|
+
|
|
169
|
+
Cloud sync is optional — see [BASIC_MEMORY.md](./BASIC_MEMORY.md) for cloud configuration.
|
|
170
|
+
|
|
171
|
+
On startup, the plugin ensures the configured BM project exists at `projectPath` via MCP `create_memory_project` in idempotent mode.
|
|
172
|
+
|
|
173
|
+
## How It Works
|
|
174
|
+
|
|
175
|
+
### MCP Session Lifecycle
|
|
176
|
+
On startup, the plugin starts one persistent MCP stdio session:
|
|
177
|
+
1. Spawns `bm mcp --transport stdio --project <name>`
|
|
178
|
+
2. Verifies required MCP tool capabilities at connect time
|
|
179
|
+
3. Uses bounded reconnect attempts (`500ms`, `1000ms`, `2000ms`) when the session drops
|
|
180
|
+
|
|
181
|
+
Basic Memory MCP lifecycle handles sync and watch behavior for the project.
|
|
182
|
+
|
|
183
|
+
### Composited `memory_search`
|
|
184
|
+
When the agent calls `memory_search`, three sources are queried in parallel:
|
|
185
|
+
|
|
186
|
+
1. **MEMORY.md** — grep/text search with ±1 line context
|
|
187
|
+
2. **BM Knowledge Graph** — hybrid FTS + vector search (top 5 results with scores)
|
|
188
|
+
3. **Active Tasks** — scans `memory/tasks/` for non-done tasks
|
|
189
|
+
|
|
190
|
+
Results are formatted into clear sections:
|
|
191
|
+
```
|
|
192
|
+
## MEMORY.md
|
|
193
|
+
- matching lines with context...
|
|
194
|
+
|
|
195
|
+
## Knowledge Graph (memory/)
|
|
196
|
+
- note-title (0.85)
|
|
197
|
+
> preview of content...
|
|
198
|
+
|
|
199
|
+
## Active Tasks
|
|
200
|
+
- **Task Name** (status: active, step: 3)
|
|
201
|
+
context snippet...
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Memory + Task Management Flow
|
|
205
|
+
|
|
206
|
+
This plugin works best if you treat memory as three lanes:
|
|
207
|
+
|
|
208
|
+
1. **Working memory (`MEMORY.md`)** — short-horizon context and current focus.
|
|
209
|
+
2. **Knowledge graph (`memory/**/*.md`)** — long-term notes indexed by Basic Memory.
|
|
210
|
+
3. **Task notes (`memory/tasks/*.md`)** — active execution state for in-flight work.
|
|
211
|
+
|
|
212
|
+
> **Note:** OpenClaw's default convention treats `MEMORY.md` as [long-term curated memory](https://docs.openclaw.ai/concepts/memory). This plugin flips that role — the BM knowledge graph handles durable storage, so `MEMORY.md` serves as short-horizon working memory. See [MEMORY_TASK_FLOW.md](./MEMORY_TASK_FLOW.md) for details.
|
|
213
|
+
|
|
214
|
+
Typical loop:
|
|
215
|
+
|
|
216
|
+
1. Capture or update notes/tasks with `write_note` / `edit_note`.
|
|
217
|
+
2. The persistent BM MCP process syncs markdown updates into the BM project index.
|
|
218
|
+
3. `memory_search` queries:
|
|
219
|
+
- `MEMORY.md` text snippets
|
|
220
|
+
- BM search results (semantic + FTS)
|
|
221
|
+
- active tasks
|
|
222
|
+
4. Drill into one result with `memory_get` or `read_note`.
|
|
223
|
+
5. Advance tasks by updating `current_step`, checkboxes, and context.
|
|
224
|
+
6. Complete tasks by setting `status: done` (done tasks are excluded from active task results).
|
|
225
|
+
|
|
226
|
+
```mermaid
|
|
227
|
+
flowchart LR
|
|
228
|
+
A["Write/Update notes"] --> B["BM MCP indexes changes"]
|
|
229
|
+
B --> C["memory_search(query)"]
|
|
230
|
+
C --> D["MEMORY.md"]
|
|
231
|
+
C --> E["Knowledge Graph"]
|
|
232
|
+
C --> F["Active Tasks"]
|
|
233
|
+
D --> G["Composited result"]
|
|
234
|
+
E --> G
|
|
235
|
+
F --> G
|
|
236
|
+
G --> H["memory_get / read_note"]
|
|
237
|
+
H --> A
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Task Note Shape (Recommended)
|
|
241
|
+
|
|
242
|
+
`memory_search` task extraction is strongest when task notes include:
|
|
243
|
+
|
|
244
|
+
- file location: `memory/tasks/*.md`
|
|
245
|
+
- frontmatter fields: `status:` and `current_step:`
|
|
246
|
+
- a `## Context` section for preview snippets
|
|
247
|
+
|
|
248
|
+
Example:
|
|
249
|
+
|
|
250
|
+
```markdown
|
|
251
|
+
---
|
|
252
|
+
title: auth-middleware-rollout
|
|
253
|
+
type: Task
|
|
254
|
+
status: active
|
|
255
|
+
current_step: 2
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Context
|
|
259
|
+
Rolling JWT middleware to all API routes. Staging verification is in progress.
|
|
260
|
+
|
|
261
|
+
## Plan
|
|
262
|
+
- [x] Implement middleware
|
|
263
|
+
- [x] Add refresh-token validation
|
|
264
|
+
- [ ] Roll out to staging
|
|
265
|
+
- [ ] Verify logs and error rates
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
To mark complete, update:
|
|
269
|
+
|
|
270
|
+
```yaml
|
|
271
|
+
status: done
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Done tasks are filtered out of the `Active Tasks` section in composited `memory_search`.
|
|
275
|
+
|
|
276
|
+
### Auto-Recall
|
|
277
|
+
On each `agent_start` event (when `autoRecall: true`), the plugin:
|
|
278
|
+
1. Queries the knowledge graph for active tasks (`type: Task`, `status: active`, up to 5)
|
|
279
|
+
2. Fetches notes modified in the last 24 hours
|
|
280
|
+
3. Formats both into structured context and returns it to the agent
|
|
281
|
+
|
|
282
|
+
This gives the agent immediate awareness of ongoing work and recent changes without the user needing to ask. The `recallPrompt` config field controls the instruction appended to the context — customize it to steer what the agent prioritizes.
|
|
283
|
+
|
|
284
|
+
### Auto-Capture
|
|
285
|
+
After each agent turn (when `autoCapture: true`), the plugin:
|
|
286
|
+
1. Extracts the last user + assistant messages
|
|
287
|
+
2. Appends them as timestamped entries to a daily conversation note (`conversations-YYYY-MM-DD`)
|
|
288
|
+
3. Skips very short exchanges (< `captureMinChars` chars each, default 10)
|
|
289
|
+
|
|
290
|
+
### Basic Memory Cloud
|
|
291
|
+
|
|
292
|
+
Everything works locally — cloud adds cross-device, team, and production capabilities:
|
|
293
|
+
|
|
294
|
+
- **Your agent's memory travels with you** — same knowledge graph on laptop, desktop, and hosted environments
|
|
295
|
+
- **Team knowledge sharing** — org workspaces let multiple agents and team members build on a shared knowledge base
|
|
296
|
+
- **Durable memory for production agents** — persistent memory that survives CI teardowns and container restarts
|
|
297
|
+
- **Multi-agent coordination** — multiple agents can read and write to the same graph
|
|
298
|
+
|
|
299
|
+
Cloud extends local-first — still plain markdown, still yours. Start with a [7-day free trial](https://basicmemory.com) and use code `BMCLAW` for 20% off for 3 months. See [BASIC_MEMORY.md](./BASIC_MEMORY.md) for setup, or visit [basicmemory.com](https://basicmemory.com) for more info.
|
|
300
|
+
|
|
301
|
+
## Agent Tools
|
|
302
|
+
|
|
303
|
+
All content tools accept an optional `project` parameter to operate on a different project than the default (cross-project operations).
|
|
304
|
+
|
|
305
|
+
### `list_workspaces`
|
|
306
|
+
List all workspaces (personal and organization) accessible to this user.
|
|
307
|
+
```
|
|
308
|
+
list_workspaces()
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### `list_memory_projects`
|
|
312
|
+
List all projects, optionally filtered by workspace.
|
|
313
|
+
```
|
|
314
|
+
list_memory_projects()
|
|
315
|
+
list_memory_projects(workspace="my-org")
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### `search_notes`
|
|
319
|
+
Search the knowledge graph.
|
|
320
|
+
```
|
|
321
|
+
search_notes(query="API design", limit=5)
|
|
322
|
+
search_notes(query="API design", project="other-project") # cross-project
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### `read_note`
|
|
326
|
+
Read a note by title, permalink, or `memory://` URL.
|
|
327
|
+
```
|
|
328
|
+
read_note(identifier="memory://projects/api-redesign")
|
|
329
|
+
read_note(identifier="memory://projects/api-redesign", include_frontmatter=true) # raw markdown + YAML
|
|
330
|
+
read_note(identifier="notes/readme", project="docs") # cross-project
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### `write_note`
|
|
334
|
+
Create a new note.
|
|
335
|
+
```
|
|
336
|
+
write_note(title="Auth Strategy", content="## Overview\n...", folder="decisions")
|
|
337
|
+
write_note(title="Shared Note", content="...", folder="shared", project="team") # cross-project
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### `edit_note`
|
|
341
|
+
Edit an existing note (`append`, `prepend`, `find_replace`, `replace_section`).
|
|
342
|
+
```
|
|
343
|
+
edit_note(identifier="weekly-review", operation="append", content="\n## Update\nDone.")
|
|
344
|
+
edit_note(
|
|
345
|
+
identifier="weekly-review",
|
|
346
|
+
operation="find_replace",
|
|
347
|
+
find_text="status: active",
|
|
348
|
+
content="status: done",
|
|
349
|
+
expected_replacements=1,
|
|
350
|
+
)
|
|
351
|
+
edit_note(
|
|
352
|
+
identifier="weekly-review",
|
|
353
|
+
operation="replace_section",
|
|
354
|
+
section="## This Week",
|
|
355
|
+
content="- Done\n- Next",
|
|
356
|
+
)
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### `delete_note`
|
|
360
|
+
Delete a note.
|
|
361
|
+
```
|
|
362
|
+
delete_note(identifier="notes/old-draft")
|
|
363
|
+
delete_note(identifier="notes/old-draft", project="archive") # cross-project
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### `move_note`
|
|
367
|
+
Move a note to a different folder.
|
|
368
|
+
```
|
|
369
|
+
move_note(identifier="notes/my-note", newFolder="archive")
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### `build_context`
|
|
373
|
+
Navigate the knowledge graph — get a note with its observations and relations.
|
|
374
|
+
```
|
|
375
|
+
build_context(url="memory://projects/api-redesign", depth=2)
|
|
376
|
+
build_context(url="memory://decisions", depth=1, project="team") # cross-project
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### `schema_validate`
|
|
380
|
+
Validate notes against their Picoschema definitions.
|
|
381
|
+
```
|
|
382
|
+
schema_validate(noteType="person")
|
|
383
|
+
schema_validate(identifier="notes/john-doe")
|
|
384
|
+
schema_validate(noteType="person", project="contacts") # cross-project
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### `schema_infer`
|
|
388
|
+
Analyze existing notes and suggest a Picoschema definition.
|
|
389
|
+
```
|
|
390
|
+
schema_infer(noteType="meeting")
|
|
391
|
+
schema_infer(noteType="person", threshold=0.5)
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### `schema_diff`
|
|
395
|
+
Detect drift between a schema definition and actual note usage.
|
|
396
|
+
```
|
|
397
|
+
schema_diff(noteType="person")
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## Slash Commands
|
|
401
|
+
|
|
402
|
+
### Memory
|
|
403
|
+
- **`/remember <text>`** — Save a quick note to the knowledge graph
|
|
404
|
+
- **`/recall <query>`** — Search the knowledge graph (top 5 results)
|
|
405
|
+
|
|
406
|
+
### Skill workflows
|
|
407
|
+
These inject step-by-step instructions from the bundled skill files. Each accepts optional arguments for context.
|
|
408
|
+
|
|
409
|
+
| Command | Description |
|
|
410
|
+
|---------|-------------|
|
|
411
|
+
| `/tasks [args]` | Task management — create, track, resume structured tasks |
|
|
412
|
+
| `/reflect [args]` | Memory reflection — consolidate recent activity into long-term memory |
|
|
413
|
+
| `/defrag [args]` | Memory defrag — reorganize, split, prune memory files |
|
|
414
|
+
| `/schema [args]` | Schema management — infer, create, validate, evolve Picoschema definitions |
|
|
415
|
+
|
|
416
|
+
Examples:
|
|
417
|
+
```
|
|
418
|
+
/tasks create a task for the API migration
|
|
419
|
+
/reflect
|
|
420
|
+
/defrag clean up completed tasks older than 2 weeks
|
|
421
|
+
/schema infer a schema for Meeting notes
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
## CLI Commands
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
openclaw basic-memory search "auth patterns" --limit 5
|
|
428
|
+
openclaw basic-memory read "projects/api-redesign"
|
|
429
|
+
openclaw basic-memory read "projects/api-redesign" --raw
|
|
430
|
+
openclaw basic-memory edit "projects/api-redesign" --operation append --content $'\n## Update\nDone.'
|
|
431
|
+
openclaw basic-memory context "memory://projects/api-redesign" --depth 2
|
|
432
|
+
openclaw basic-memory recent --timeframe 24h
|
|
433
|
+
openclaw basic-memory status
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## Troubleshooting
|
|
437
|
+
|
|
438
|
+
### `bm` command not found
|
|
439
|
+
```bash
|
|
440
|
+
which bm # Check if installed
|
|
441
|
+
bm --version # Check version
|
|
442
|
+
bm mcp --help # Verify MCP server command exists
|
|
443
|
+
```
|
|
444
|
+
If `bm mcp` doesn't exist, update Basic Memory to a newer version.
|
|
445
|
+
|
|
446
|
+
### `edit_note` says `edit-note` is required
|
|
447
|
+
Your installed `basic-memory` version is missing native `tool edit-note`.
|
|
448
|
+
Upgrade `basic-memory` and rerun.
|
|
449
|
+
|
|
450
|
+
### Jiti cache issues
|
|
451
|
+
```bash
|
|
452
|
+
rm -rf /tmp/jiti/ "$TMPDIR/jiti/"
|
|
453
|
+
openclaw gateway stop && openclaw gateway start
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### Search returns no results
|
|
457
|
+
1. Check that the MCP session is connected (look for `connected to BM MCP stdio` in logs)
|
|
458
|
+
2. Verify files exist in the project directory
|
|
459
|
+
3. Try `bm mcp --transport stdio --project <name>` and run `search_notes` through an MCP inspector/client
|
|
460
|
+
4. Check project status: `bm project list`
|
|
461
|
+
|
|
462
|
+
## Integration Tests
|
|
463
|
+
|
|
464
|
+
This repo includes real end-to-end integration tests for `BmClient` in:
|
|
465
|
+
|
|
466
|
+
- `integration/bm-client.integration.test.ts`
|
|
467
|
+
|
|
468
|
+
These tests launch a real `bm mcp --transport stdio --project <name>` process,
|
|
469
|
+
run write/read/edit/search/context/move/delete calls, and assert actual filesystem/index results.
|
|
470
|
+
|
|
471
|
+
Run integration tests:
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
bun run test:int
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
By default this uses `./scripts/bm-local.sh`, which runs BM from a sibling
|
|
478
|
+
`../basic-memory` checkout via `uv run --project ...` when present, and falls
|
|
479
|
+
back to `bm` on `PATH` otherwise.
|
|
480
|
+
|
|
481
|
+
Optional overrides:
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
# Use a non-default bm binary
|
|
485
|
+
BM_BIN=/absolute/path/to/bm bun run test:int
|
|
486
|
+
|
|
487
|
+
# Use a specific basic-memory source checkout
|
|
488
|
+
BASIC_MEMORY_REPO=/absolute/path/to/basic-memory bun run test:int
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
## Development
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
bun run check-types # Type checking
|
|
495
|
+
bun run lint # Linting
|
|
496
|
+
bun test # Run tests (156 tests)
|
|
497
|
+
bun run test:int # Real BM MCP integration tests
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
## Publish to npm
|
|
501
|
+
|
|
502
|
+
This package is published as `@openclaw/basic-memory`.
|
|
503
|
+
|
|
504
|
+
```bash
|
|
505
|
+
# 1) Verify release readiness (types + tests + npm pack dry run)
|
|
506
|
+
just release-check
|
|
507
|
+
|
|
508
|
+
# 2) Inspect publish payload
|
|
509
|
+
just release-pack
|
|
510
|
+
|
|
511
|
+
# 3) Authenticate once (if needed)
|
|
512
|
+
npm login
|
|
513
|
+
|
|
514
|
+
# 4) Publish current version from package.json
|
|
515
|
+
just release-publish
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
For a full release (version bump + publish + push tag):
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
just release patch # or: minor, major, 0.2.0, etc.
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### GitHub Actions CI/CD
|
|
525
|
+
|
|
526
|
+
- CI workflow: `.github/workflows/ci.yml` runs on PRs and `main` pushes.
|
|
527
|
+
- Release workflow: `.github/workflows/release.yml` runs manually (`workflow_dispatch`) and will:
|
|
528
|
+
1. run release checks
|
|
529
|
+
2. bump version and create a git tag
|
|
530
|
+
3. push commit + tag
|
|
531
|
+
4. publish to npm
|
|
532
|
+
5. create a GitHub release
|
|
533
|
+
|
|
534
|
+
Repository secret required:
|
|
535
|
+
|
|
536
|
+
- `NPM_TOKEN` (npm publish token with package publish permissions)
|
|
537
|
+
|
|
538
|
+
### Project Structure
|
|
539
|
+
```
|
|
540
|
+
openclaw-basic-memory/
|
|
541
|
+
├── index.ts # Plugin entry — manages MCP lifecycle, registers tools
|
|
542
|
+
├── config.ts # Configuration parsing
|
|
543
|
+
├── bm-client.ts # Persistent Basic Memory MCP stdio client
|
|
544
|
+
├── tools/ # Agent tools
|
|
545
|
+
│ ├── search-notes.ts # search_notes
|
|
546
|
+
│ ├── read-note.ts # read_note
|
|
547
|
+
│ ├── write-note.ts # write_note
|
|
548
|
+
│ ├── edit-note.ts # edit_note
|
|
549
|
+
│ ├── delete-note.ts # delete_note
|
|
550
|
+
│ ├── move-note.ts # move_note
|
|
551
|
+
│ ├── build-context.ts # build_context
|
|
552
|
+
│ ├── list-memory-projects.ts # list_memory_projects
|
|
553
|
+
│ ├── list-workspaces.ts # list_workspaces
|
|
554
|
+
│ ├── schema-validate.ts # schema_validate
|
|
555
|
+
│ ├── schema-infer.ts # schema_infer
|
|
556
|
+
│ ├── schema-diff.ts # schema_diff
|
|
557
|
+
│ └── memory-provider.ts # Composited memory_search + memory_get
|
|
558
|
+
├── commands/
|
|
559
|
+
│ ├── slash.ts # /remember, /recall
|
|
560
|
+
│ ├── skills.ts # /tasks, /reflect, /defrag, /schema
|
|
561
|
+
│ └── cli.ts # openclaw basic-memory CLI
|
|
562
|
+
└── hooks/
|
|
563
|
+
├── capture.ts # Auto-capture conversations
|
|
564
|
+
└── recall.ts # Auto-recall (active tasks + recent activity)
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
## License
|
|
568
|
+
|
|
569
|
+
MIT — see LICENSE file.
|
|
570
|
+
|
|
571
|
+
## Links
|
|
572
|
+
|
|
573
|
+
- [Basic Memory](https://github.com/basicmachines-co/basic-memory)
|
|
574
|
+
- [Basic Memory Skills](https://github.com/basicmachines-co/basic-memory-skills)
|
|
575
|
+
- [OpenClaw](https://docs.openclaw.ai)
|
|
576
|
+
- [Issues](https://github.com/basicmachines-co/openclaw-basic-memory/issues)
|