clawmem 0.1.0 → 0.1.2

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/AGENTS.md CHANGED
@@ -625,6 +625,14 @@ Symptom: embed --force with new model produces 3 docs stuck as "Unembedded" but
625
625
  Symptom: CLI reindex/update falls back to node-llama-cpp Vulkan (not GPU server)
626
626
  → GPU env vars only in systemd drop-in, not in wrapper script. CLI invocations missed them.
627
627
  → Fixed 2026-02-12: bin/clawmem wrapper exports CLAWMEM_EMBED_URL/LLM_URL/RERANK_URL defaults.
628
+
629
+ Symptom: "UserPromptSubmit hook error" on context-surfacing hook (intermittent)
630
+ → SQLite contention between the watcher and the hook. The watcher processes filesystem events
631
+ (including non-.md files like session .jsonl transcripts) and holds brief write locks. If the
632
+ hook fires during a lock, it can exceed its timeout. More likely during active conversations
633
+ when the watcher is processing rapid transcript changes.
634
+ → Fix: Bump the hook timeout from 5s to 8s in ~/.claude/settings.json. If persistent, restart
635
+ the watcher to clear memory bloat: `systemctl --user restart clawmem-watcher.service`.
628
636
  ```
629
637
 
630
638
  ## CLI Reference
package/CLAUDE.md CHANGED
@@ -625,6 +625,14 @@ Symptom: embed --force with new model produces 3 docs stuck as "Unembedded" but
625
625
  Symptom: CLI reindex/update falls back to node-llama-cpp Vulkan (not GPU server)
626
626
  → GPU env vars only in systemd drop-in, not in wrapper script. CLI invocations missed them.
627
627
  → Fixed 2026-02-12: bin/clawmem wrapper exports CLAWMEM_EMBED_URL/LLM_URL/RERANK_URL defaults.
628
+
629
+ Symptom: "UserPromptSubmit hook error" on context-surfacing hook (intermittent)
630
+ → SQLite contention between the watcher and the hook. The watcher processes filesystem events
631
+ (including non-.md files like session .jsonl transcripts) and holds brief write locks. If the
632
+ hook fires during a lock, it can exceed its timeout. More likely during active conversations
633
+ when the watcher is processing rapid transcript changes.
634
+ → Fix: Bump the hook timeout from 5s to 8s in ~/.claude/settings.json. If persistent, restart
635
+ the watcher to clear memory bloat: `systemctl --user restart clawmem-watcher.service`.
628
636
  ```
629
637
 
630
638
  ## CLI Reference
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ClawMem — Context engine for Claude Code and AI agents
1
+ # ClawMem — Context engine for Claude Code and OpenClaw agents
2
2
 
3
3
  <p align="center">
4
4
  <img src="docs/clawmem_hero.jpg" alt="ClawMem" width="100%">
@@ -8,7 +8,7 @@
8
8
 
9
9
  ClawMem fuses recent research into a retrieval-augmented memory layer that agents actually use. The hybrid architecture combines [QMD](https://github.com/tobi/qmd)-derived multi-signal retrieval (BM25 + vector search + reciprocal rank fusion + query expansion + cross-encoder reranking), [SAME](https://github.com/sgx-labs/statelessagent)-inspired composite scoring (recency decay, confidence, content-type half-lives, co-activation reinforcement), [MAGMA](https://arxiv.org/abs/2501.13956)-style intent classification with multi-graph traversal (semantic, temporal, and causal beam search), and [A-MEM](https://arxiv.org/abs/2510.02178) self-evolving memory notes that enrich documents with keywords, tags, and causal links between entries. Pattern extraction from [Engram](https://github.com/Gentleman-Programming/engram) adds deduplication windows, frequency-based durability scoring, and temporal navigation.
10
10
 
11
- Two integration paths: Claude Code hooks paired with an MCP server, or a native OpenClaw ContextEngine plugin. Both write to the same local SQLite vault. A decision captured during a Claude Code session shows up immediately when an OpenClaw agent picks up the same project.
11
+ Integrates via Claude Code hooks, an MCP server (works with any MCP-compatible client including OpenClaw), or a native OpenClaw ContextEngine plugin. All paths write to the same local SQLite vault. A decision captured during a Claude Code session shows up immediately when an OpenClaw agent picks up the same project.
12
12
 
13
13
  TypeScript on Bun. MIT License.
14
14
 
@@ -61,19 +61,32 @@ Runs fully local with no API keys and no cloud services. Integrates via Claude C
61
61
 
62
62
  ### Prerequisites
63
63
 
64
- - [Bun](https://bun.sh) v1.0+
65
- - SQLite with FTS5 support (included with Bun)
64
+ **Required:**
66
65
 
67
- ### Install via npm (recommended)
66
+ - [Bun](https://bun.sh) v1.0+ runtime for ClawMem
67
+ - SQLite with FTS5 — included with Bun. On macOS, install `brew install sqlite` for extension loading support (ClawMem detects and uses Homebrew SQLite automatically).
68
+
69
+ **Optional (for better performance):**
70
+
71
+ - [llama.cpp](https://github.com/ggml-org/llama.cpp) (`llama-server`) — for dedicated GPU inference. Without it, `node-llama-cpp` runs models in-process (auto-downloads on first use). GPU servers give better throughput and prevent silent CPU fallback.
72
+ - systemd (Linux) or launchd (macOS) — for persistent background services (watcher, embed timer, GPU servers). ClawMem ships systemd unit templates; macOS users can create equivalent launchd plists. See [systemd services](docs/guides/systemd-services.md).
73
+
74
+ **Optional integrations:**
75
+
76
+ - [Claude Code](https://docs.anthropic.com/en/docs/claude-code) — for hooks + MCP integration
77
+ - [OpenClaw](https://github.com/openclawai/openclaw) — for ContextEngine plugin integration
78
+ - [bd CLI](https://github.com/dolthub/dolt) v0.58.0+ — for Beads issue tracker sync (only if using Beads)
79
+
80
+ ### Install from npm (recommended)
68
81
 
69
82
  ```bash
70
- bun add -g clawmem
83
+ npm install -g clawmem
71
84
  ```
72
85
 
73
- Or with npm:
86
+ If you use Bun as your package manager:
74
87
 
75
88
  ```bash
76
- npm install -g clawmem
89
+ bun add -g clawmem
77
90
  ```
78
91
 
79
92
  ### Install from source
@@ -84,20 +97,44 @@ cd ~/clawmem && bun install
84
97
  ln -sf ~/clawmem/bin/clawmem ~/.bun/bin/clawmem
85
98
  ```
86
99
 
87
- ### Quick Start (Bootstrap)
100
+ ### Setup roadmap
101
+
102
+ After installing, here's the full journey from zero to working memory:
88
103
 
89
- One command to set up a vault:
104
+ | Step | What | How | Details |
105
+ |------|------|-----|---------|
106
+ | **1. Bootstrap** | Create a vault, index your first collection, embed, install hooks and MCP | `clawmem bootstrap ~/notes --name notes` | One command does it all. Or run each step manually (see below). |
107
+ | **2. Choose models** | Pick embedding + reranker models based on your hardware | 12GB+ VRAM → SOTA stack (zembed-1 + zerank-2). Less → QMD native combo. No GPU → cloud embedding or CPU fallback. | [GPU Services](#gpu-services) |
108
+ | **3. Download models** | Get the GGUF files for your chosen stack | `wget` from HuggingFace, or let `node-llama-cpp` auto-download the QMD native models on first use | [Embedding](#embedding), [LLM Server](#llm-server), [Reranker Server](#reranker-server) |
109
+ | **4. Start services** | Run GPU servers (if using dedicated GPU) and background services | `llama-server` for each model. systemd units for watcher + embed timer. | [systemd services](docs/guides/systemd-services.md) |
110
+ | **5. Decide what to index** | Add collections for your projects, notes, research, and domain docs | `clawmem collection add ~/project --name project` | The more relevant markdown you index, the better retrieval works. See [building a rich context field](docs/introduction.md#building-a-rich-context-field). |
111
+ | **6. Connect your agent** | Hook into Claude Code, OpenClaw, or any MCP client | `clawmem setup hooks && clawmem setup mcp` for Claude Code. `clawmem setup openclaw` for OpenClaw. | [Integration](#integration) |
112
+ | **7. Verify** | Confirm everything is working | `clawmem doctor` (full health check) or `clawmem status` (quick index stats) | [Verify Installation](#verify-installation) |
113
+
114
+ **Fastest path:** Step 1 alone gets you a working system with in-process CPU/GPU inference and default models — no manual model downloads or service configuration needed. Steps 2-4 are optional upgrades for better performance. Steps 5-6 are where you customize what gets indexed and how your agent connects.
115
+
116
+ **Customize what gets indexed:** Each collection has a `pattern` field in `~/.config/clawmem/config.yaml` (default: `**/*.md`). Tailor it per collection — index project docs, research notes, decision records, Obsidian vaults, or anything else your agents should know about. The more relevant content in the vault, the better retrieval works. See the [quickstart](docs/quickstart.md#customize-index-patterns) for config examples.
117
+
118
+ ### Quick start commands
90
119
 
91
120
  ```bash
92
- # Initialize, index, embed, install hooks, register MCP
93
- ./bin/clawmem bootstrap ~/notes --name notes
121
+ # One command: init + index + embed + hooks + MCP
122
+ clawmem bootstrap ~/notes --name notes
94
123
 
95
124
  # Or step by step:
96
- ./bin/clawmem init
97
- ./bin/clawmem collection add ~/notes --name notes
98
- ./bin/clawmem update --embed
99
- ./bin/clawmem setup hooks
100
- ./bin/clawmem setup mcp
125
+ clawmem init
126
+ clawmem collection add ~/notes --name notes
127
+ clawmem update --embed
128
+ clawmem setup hooks
129
+ clawmem setup mcp
130
+
131
+ # Add more collections (the more you index, the richer retrieval gets)
132
+ clawmem collection add ~/projects/myapp --name myapp
133
+ clawmem collection add ~/research --name research
134
+ clawmem update --embed
135
+
136
+ # Verify
137
+ clawmem doctor
101
138
  ```
102
139
 
103
140
  ### Integration
@@ -108,7 +145,7 @@ ClawMem integrates via hooks (`settings.json`) and an MCP stdio server. Hooks ha
108
145
 
109
146
  ```bash
110
147
  clawmem setup hooks # Install lifecycle hooks (SessionStart, UserPromptSubmit, Stop, PreCompact)
111
- clawmem setup mcp # Register MCP server in ~/.claude.json (20+ agent tools)
148
+ clawmem setup mcp # Register MCP server in ~/.claude.json (28 tools)
112
149
  ```
113
150
 
114
151
  **Automatic (90%):** `context-surfacing` injects relevant memory on every prompt. `postcompact-inject` re-injects state after compaction. `decision-extractor`, `handoff-generator`, `feedback-loop` capture session state on stop.
@@ -135,7 +172,7 @@ Disable OpenClaw's native memory and `memory-lancedb` auto-recall/capture to avo
135
172
  openclaw config set agents.defaults.memorySearch.extraPaths "[]"
136
173
  ```
137
174
 
138
- **Alternative:** You can also use the Claude Code-style hooks + MCP approach with OpenClaw (`clawmem setup hooks && clawmem setup mcp`). This works but bypasses OpenClaw's ContextEngine lifecycle - you lose token budget awareness, native compaction orchestration, and the `afterTurn()` message pipeline. The ContextEngine plugin is recommended for new OpenClaw setups.
175
+ **Alternative:** OpenClaw agents can also use ClawMem's MCP server directly (`clawmem setup mcp`), with or without hooks. This gives full access to all 28 MCP tools but bypasses OpenClaw's ContextEngine lifecycle, so you lose token budget awareness, native compaction orchestration, and the `afterTurn()` message pipeline. The ContextEngine plugin is recommended for new OpenClaw setups; MCP is available as an additional or standalone integration.
139
176
 
140
177
  #### Dual-Mode Operation
141
178
 
@@ -366,7 +403,7 @@ llama-server -m Qwen3-Reranker-0.6B-Q8_0.gguf \
366
403
 
367
404
  ### MCP Server
368
405
 
369
- ClawMem exposes 26 MCP tools via the [Model Context Protocol](https://modelcontextprotocol.io) and an optional HTTP REST API. Any MCP-compatible client or HTTP client can use it.
406
+ ClawMem exposes 28 MCP tools via the [Model Context Protocol](https://modelcontextprotocol.io) and an optional HTTP REST API. Any MCP-compatible client or HTTP client can use it.
370
407
 
371
408
  **Claude Code (automatic):**
372
409
 
@@ -453,7 +490,7 @@ ClawMem ships three instruction files and an optional maintenance agent:
453
490
  |------|--------|---------|
454
491
  | `CLAUDE.md` | Automatically (Claude Code, when working in this repo) | Complete operational reference — hooks, tools, query optimization, scoring, pipeline details, troubleshooting |
455
492
  | `AGENTS.md` | Framework-dependent | Identical to CLAUDE.md — cross-framework compatibility (Cursor, Windsurf, Codex, etc.) |
456
- | `SKILL.md` | On-demand via Claude Code skill system | Same reference as CLAUDE.md, available across all projects |
493
+ | `SKILL.md` | On-demand (agent reads when needed) | Same reference as CLAUDE.md, shipped with the package for cross-project use |
457
494
  | `agents/clawmem-curator.md` | On-demand via `clawmem setup curator` | Maintenance agent — lifecycle triage, retrieval health checks, dedup sweeps, graph rebuilds |
458
495
 
459
496
  **Working in the ClawMem repo:** No action needed — `CLAUDE.md` loads automatically.
@@ -464,16 +501,9 @@ ClawMem ships three instruction files and an optional maintenance agent:
464
501
 
465
502
  Copy the contents of `CLAUDE.md` (or the relevant sections) into your project's own `CLAUDE.md` or `AGENTS.md`. Simple but requires manual updates when ClawMem changes.
466
503
 
467
- ### Option B: Install as a skill (recommended)
468
-
469
- Symlink ClawMem into Claude Code's skill directory for on-demand reference across all projects:
470
-
471
- ```bash
472
- mkdir -p ~/.claude/skills
473
- ln -sf ~/clawmem ~/.claude/skills/clawmem
474
- ```
504
+ ### Option B: Add a trigger block (recommended)
475
505
 
476
- Then add this minimal trigger block to your global `~/.claude/CLAUDE.md`:
506
+ Add this minimal trigger block to your global `~/.claude/CLAUDE.md`. It gives the agent routing rules always loaded, and tells it how to find the full reference (SKILL.md) shipped with your installation when deeper guidance is needed:
477
507
 
478
508
  ```markdown
479
509
  ## ClawMem
@@ -525,15 +555,12 @@ ALWAYS `compact=true` first → review → `multi_get` for full content.
525
555
  - Do NOT forget memories to "clean up" — let confidence decay handle it
526
556
  - Do NOT wait for curator to pin decisions — pin immediately when critical
527
557
 
528
- Invoke `Skill tool with skill="clawmem"` when:
529
- - Retrieval quality is poor or results miss expected content (query optimization, troubleshooting)
530
- - Adding new content directories or indexing something (collection setup, embedding workflow)
531
- - After bulk document creation or ingestion (graph building, embedding)
532
- - Need lifecycle triage beyond basic status/sweep (run curator: "curate memory")
533
- - Any operation beyond the basic tool routing above
558
+ For detailed operational guidance (query optimization, troubleshooting, collection setup, embedding workflow, graph building, curator), find and read the shipped SKILL.md:
559
+ Bash: CLAWMEM_ROOT=$(cd "$(dirname "$(which clawmem)")/.." && pwd) && echo "$CLAWMEM_ROOT/SKILL.md"
560
+ Then: Read the file at that path.
534
561
  ```
535
562
 
536
- This gives your agent the 3-rule gate, tool routing, and proactive behaviors always loaded, with situation-triggered skill invocation for the ~10% manual operations.
563
+ This gives your agent the 3-rule gate, tool routing, and proactive behaviors always loaded. When it needs deeper guidance, it locates and reads the full SKILL.md reference shipped with your installation no symlinks or skill registration required.
537
564
 
538
565
  ---
539
566
 
package/SKILL.md CHANGED
@@ -630,6 +630,13 @@ Symptom: reindex --force crashes with UNIQUE constraint
630
630
  Symptom: CLI reindex/update falls back to node-llama-cpp
631
631
  -> GPU env vars only in systemd drop-in, not in wrapper script.
632
632
  -> Fixed: bin/clawmem wrapper exports CLAWMEM_EMBED_URL/LLM_URL/RERANK_URL defaults.
633
+
634
+ Symptom: "UserPromptSubmit hook error" on context-surfacing hook (intermittent)
635
+ -> SQLite contention between watcher and hook. Watcher processes filesystem events (including
636
+ non-.md files like session .jsonl transcripts) and holds brief write locks. If the hook fires
637
+ during a lock, it can exceed its timeout. More likely during active conversations.
638
+ -> Fix: Bump hook timeout from 5s to 8s in ~/.claude/settings.json. If persistent, restart
639
+ the watcher: `systemctl --user restart clawmem-watcher.service`.
633
640
  ```
634
641
 
635
642
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawmem",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "On-device context engine and memory for AI agents. Claude Code and OpenClaw. Hooks + MCP server + hybrid RAG search.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/clawmem.ts CHANGED
@@ -976,7 +976,7 @@ async function cmdSetupHooks(args: string[]) {
976
976
 
977
977
  // Timeout per event type (seconds)
978
978
  const timeouts: Record<string, number> = {
979
- UserPromptSubmit: 5,
979
+ UserPromptSubmit: 8,
980
980
  SessionStart: 5,
981
981
  PreCompact: 5,
982
982
  Stop: 10,