clawmem 0.14.0 → 0.15.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.
@@ -0,0 +1,158 @@
1
+ # Quickstart
2
+
3
+ Set up ClawMem as persistent memory for AI coding agents in under 5 minutes. By the end you'll have hooks injecting context on every prompt and an MCP server for agent-initiated retrieval.
4
+
5
+ ## Prerequisites
6
+
7
+ - [Bun](https://bun.sh) v1.0+ — install via `curl -fsSL https://bun.sh/install | bash`, not snap (snap Bun has stdin restrictions that break hooks)
8
+ - A GPU for local inference (default models need ~4GB VRAM; the full SOTA stack needs ~16GB, the zerank-2 sidecar alone ~9GB). Or use [cloud embedding](guides/cloud-embedding.md)
9
+ - Claude Code, OpenClaw, or any MCP-compatible client
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ # Via npm (recommended)
15
+ npm install -g clawmem
16
+
17
+ # If you use Bun as your package manager:
18
+ # bun add -g clawmem
19
+
20
+ # From source
21
+ git clone https://github.com/yoloshii/clawmem.git ~/clawmem
22
+ cd ~/clawmem && bun install
23
+ ln -sf ~/clawmem/bin/clawmem ~/.bun/bin/clawmem
24
+ ```
25
+
26
+ ## Bootstrap a vault
27
+
28
+ The fastest path — one command to init, index, embed, set up hooks, and register MCP:
29
+
30
+ ```bash
31
+ clawmem bootstrap ~/notes --name notes
32
+ ```
33
+
34
+ This creates a vault at `~/.cache/clawmem/index.sqlite`, indexes all `.md` files under `~/notes`, embeds them for vector search, installs Claude Code hooks, and registers the MCP server.
35
+
36
+ ## Or step by step
37
+
38
+ ```bash
39
+ # 1. Initialize the vault
40
+ clawmem init
41
+
42
+ # 2. Add a collection (directory of markdown files)
43
+ clawmem collection add ~/notes --name notes
44
+
45
+ # 3. Index and embed
46
+ clawmem update --embed
47
+
48
+ # 4. Set up Claude Code hooks (automatic context injection)
49
+ clawmem setup hooks
50
+
51
+ # 5. Register the MCP server (agent-initiated tools)
52
+ clawmem setup mcp
53
+ ```
54
+
55
+ ## Start GPU services
56
+
57
+ ClawMem uses three llama-server instances for best performance. All three models also auto-download and run locally via `node-llama-cpp` if no server is running — using Metal on Apple Silicon, Vulkan where available, or CPU as last resort. With GPU acceleration (Metal/Vulkan), in-process inference is fast for these small models; on CPU-only systems it is significantly slower. If you're using GPU servers, run them via [systemd services](guides/systemd-services.md) to prevent silent fallback on server crash.
58
+
59
+ ```bash
60
+ # Embedding (recommended for performance — falls back to in-process if no server)
61
+ llama-server -m embeddinggemma-300M-Q8_0.gguf \
62
+ --embeddings --port 8088 --host 0.0.0.0 -ngl 99 -c 2048 --batch-size 2048
63
+
64
+ # LLM — query expansion (falls back to in-process if unavailable)
65
+ llama-server -m qmd-query-expansion-1.7B-q4_k_m.gguf \
66
+ --port 8089 --host 0.0.0.0 -ngl 99 -c 4096
67
+
68
+ # Reranker (falls back to in-process if unavailable)
69
+ llama-server -m Qwen3-Reranker-0.6B-Q8_0.gguf \
70
+ --reranking --port 8090 --host 0.0.0.0 -ngl 99 -c 2048 --batch-size 512
71
+ ```
72
+
73
+ > **SOTA upgrade (16GB+ GPU):** Replace embedding with zembed-1-Q4_K_M (2560d, `-b 2048 -ub 2048`). For the reranker, use the **zerank-2 seq-cls sidecar** (transformers, bf16) at [`extras/rerankers/zerank-2-seq/`](../extras/rerankers/zerank-2-seq/) — the `zerank-2-Q4_K_M` GGUF is deprecated (llama.cpp drops its score head). See [the inference services guide](guides/inference-services.md). **CC-BY-NC-4.0** — non-commercial only.
74
+
75
+ See [GPU services guide](guides/systemd-services.md) for systemd setup and remote GPU configuration.
76
+
77
+ No GPU? See [cloud embedding](guides/cloud-embedding.md) for OpenAI, Voyage, Jina, or Cohere alternatives.
78
+
79
+ ## Verify
80
+
81
+ ```bash
82
+ clawmem doctor # Full health check
83
+ clawmem status # Quick index status
84
+ bun test # Run test suite
85
+ ```
86
+
87
+ ## Build out your collections
88
+
89
+ The bootstrap command indexed one directory. ClawMem gets more useful as you add more content — the retrieval pipeline surfaces better results from a richer corpus.
90
+
91
+ ```bash
92
+ # Add your project docs
93
+ clawmem collection add ~/projects/myapp --name myapp
94
+
95
+ # Add research notes, decision records, domain references
96
+ clawmem collection add ~/research --name research
97
+
98
+ # Re-index and embed the new collections
99
+ clawmem update --embed
100
+ ```
101
+
102
+ A practical starting point: index every `.md` file in each project you regularly work on with agents. Include memory files, research outputs, decision records, learnings, project notes, and domain references. The more relevant context in the vault, the more the context-surfacing hook has to work with on each prompt.
103
+
104
+ ### Customize index patterns
105
+
106
+ Each collection has a `pattern` field that controls which files get indexed (default: `**/*.md`). Edit `~/.config/clawmem/config.yaml` to customize:
107
+
108
+ ```yaml
109
+ collections:
110
+ notes:
111
+ path: ~/notes
112
+ pattern: "**/*.md" # default — all markdown recursively
113
+
114
+ project:
115
+ path: ~/projects/myapp
116
+ pattern: "**/*.md" # all markdown in the project
117
+
118
+ research:
119
+ path: ~/research
120
+ pattern: "**/*.{md,txt}" # markdown and text files
121
+
122
+ obsidian:
123
+ path: ~/vault
124
+ pattern: "**/*.md" # works with Obsidian, Logseq, Foam, Dendron
125
+ ```
126
+
127
+ After editing the config, re-index and embed:
128
+
129
+ ```bash
130
+ clawmem update --embed
131
+ ```
132
+
133
+ The [watcher service](guides/systemd-services.md) picks up new files automatically, but adding or changing collections requires a manual `update`. Certain directories are always excluded regardless of pattern: `.git`, `node_modules`, `dist`, `build`, `vendor`, and others listed in [architecture](concepts/architecture.md#excluded-directories).
134
+
135
+ ### Code stays out of the vault
136
+
137
+ ClawMem indexes prose, not code. Source files (`.ts`, `.py`, `.go`, etc.) are excluded by design — BM25 and embedding models trained on natural language perform poorly on code syntax. Capture technical decisions and architecture rationale in markdown instead. Use a dedicated code search tool for code retrieval.
138
+
139
+ ### Structure documents for better scoring
140
+
141
+ Documents with headings, lists, and decision keywords score higher in retrieval. Frontmatter adds a 0.2 quality score bonus. The [quality multiplier](concepts/composite-scoring.md#quality-multiplier-07---13) ranges from 0.7x (penalty for flat text) to 1.3x (boost for well-structured docs) — so structure directly affects how often your content gets surfaced.
142
+
143
+ ## What happens next
144
+
145
+ Once set up, ClawMem works automatically:
146
+
147
+ 1. **Every prompt** — the `context-surfacing` hook searches your vault and injects relevant context as `<vault-context>` XML
148
+ 2. **Every response** — the `decision-extractor` and `handoff-generator` hooks capture decisions and session summaries
149
+ 3. **On demand** — the agent can call MCP tools like `memory_retrieve`, `query`, or `intent_search` when hooks don't surface enough
150
+
151
+ No agent configuration needed. The hooks are invisible to the agent — it just sees richer context.
152
+
153
+ ## Next steps
154
+
155
+ - [Architecture](concepts/architecture.md) — understand how vaults, collections, and scoring work
156
+ - [Setup Hooks](guides/setup-hooks.md) — customize which hooks are installed
157
+ - [OpenClaw Plugin](guides/openclaw-plugin.md) — use ClawMem as OpenClaw's context engine
158
+ - [Multi-Vault](guides/multi-vault-config.md) — separate memory domains for different projects
@@ -0,0 +1,195 @@
1
+ # ClawMem CLI reference
2
+
3
+ Complete command reference for the ClawMem memory engine. Always use the `bin/clawmem` wrapper, which sets GPU endpoint defaults.
4
+
5
+ ## Core commands
6
+
7
+ ```bash
8
+ clawmem init # Initialize vault (creates SQLite DB)
9
+ clawmem status # Quick index status
10
+ clawmem doctor # Full health check (GPU connectivity, index integrity)
11
+ ```
12
+
13
+ ## Collection management
14
+
15
+ ```bash
16
+ clawmem collection add <path> --name <name> # Add a collection
17
+ clawmem collection list # List all collections
18
+ clawmem collection remove <name> # Remove a collection
19
+ ```
20
+
21
+ ## Indexing
22
+
23
+ ```bash
24
+ clawmem update # Index all collections (BM25 only)
25
+ clawmem update --embed # Index + embed in one pass
26
+ clawmem mine <dir> # Import conversation exports (Claude, ChatGPT, Slack)
27
+ clawmem mine <dir> -c convos # Import with custom collection name
28
+ clawmem mine <dir> --embed # Import + embed in one pass
29
+ clawmem mine <dir> --dry-run # Preview without importing
30
+ clawmem mine <dir> --synthesize # v0.7.2: import + post-import LLM fact extraction
31
+ clawmem mine <dir> --synthesize --synthesis-max-docs 50 # Cap synthesis to first 50 conversations (default 20)
32
+ clawmem reindex # Force re-scan all collections
33
+ clawmem embed # Embed all un-embedded fragments
34
+ clawmem embed --force # Re-embed everything (clears existing vectors)
35
+ ```
36
+
37
+ ### Conversation Import
38
+
39
+ `clawmem mine` normalizes and imports conversation exports from multiple AI chat formats:
40
+
41
+ - **Claude Code JSONL** — session transcripts (`.jsonl`)
42
+ - **Claude.ai JSON** — flat messages or privacy export with `chat_messages`
43
+ - **ChatGPT JSON** — `conversations.json` with mapping tree
44
+ - **Slack JSON** — 2-party DM exports
45
+ - **Plain text** — files with `User:`/`Assistant:` markers
46
+
47
+ Each user+assistant exchange pair becomes one indexed document with `content_type: conversation`. Files are chunked, written to a temporary staging directory, indexed through the standard pipeline (including A-MEM enrichment), then staging is cleaned up.
48
+
49
+ #### `--synthesize` (v0.7.2)
50
+
51
+ Adds a post-import LLM fact extraction pass. After `indexCollection` commits the raw conversations, the synthesis pipeline walks the freshly imported docs and extracts structured facts (`decision`, `preference`, `milestone`, `problem`) plus cross-fact relations via a two-pass LLM pipeline. Each extracted fact is saved as a first-class searchable document alongside the raw conversation exchanges. Cross-fact links bind across conversations in the same batch — not just within a single conversation.
52
+
53
+ - **Off by default.** Raw mine import semantics are byte-identical when `--synthesize` is omitted.
54
+ - **Opt-in user consent required** — each pass drives one additional LLM call per conversation doc.
55
+ - **`--synthesis-max-docs N`** caps the number of conversations scanned per run (default 20).
56
+ - **Idempotent reruns** — synthesized fact paths are hash-stable, so rerunning over the same collection updates facts in place rather than creating parallel rows. Relation weights are monotone (`MAX(weight, excluded.weight)`).
57
+ - **Non-fatal failures** — any LLM failure, JSON parse error, or relation insert error is counted and logged. Synthesis failure never rolls back the mine import.
58
+ - See [post-import conversation synthesis](../concepts/architecture.md#post-import-conversation-synthesis-v072) for the full architectural walkthrough.
59
+
60
+ ## Search (CLI)
61
+
62
+ ```bash
63
+ clawmem search <query> # BM25 search
64
+ clawmem search <query> --vec # Vector search
65
+ clawmem search <query> --hybrid # BM25 + vector (default)
66
+ ```
67
+
68
+ ## Bootstrap
69
+
70
+ ```bash
71
+ clawmem bootstrap <path> --name <name> # One-command setup: init + collection + index + embed + hooks + mcp
72
+ ```
73
+
74
+ ## Watch
75
+
76
+ ```bash
77
+ clawmem watch # Start file watcher (indexes on .md changes)
78
+ ```
79
+
80
+ ## Setup
81
+
82
+ ```bash
83
+ clawmem setup hooks # Install Claude Code hooks
84
+ clawmem setup hooks --remove # Remove installed hooks
85
+ clawmem setup mcp # Register MCP server
86
+ clawmem setup openclaw # Install OpenClaw memory plugin. v0.10.4+ delegates to `openclaw plugins install --force` when the CLI is on PATH (profile-aware via OPENCLAW_STATE_DIR; auto-enabled). Falls back to recursive copy honoring OPENCLAW_STATE_DIR when the CLI is absent.
87
+ clawmem setup openclaw --link # Load-path mode: delegates `openclaw plugins install -l` when CLI is on PATH (records source in plugins.load.paths — NOT a filesystem symlink). In CLI-absent fallback, creates a real symlink (note: OpenClaw v2026.4.11+ discovery skips fallback symlinks).
88
+ clawmem setup openclaw --remove # Uninstall. Tries `openclaw plugins uninstall clawmem --force` first; falls back to manual cleanup at the resolved extensions path for legacy unmanaged installs.
89
+ clawmem setup openclaw --help # Print full flag + env-var reference (v0.10.4+).
90
+ clawmem setup curator # Install curator agent
91
+ ```
92
+
93
+ ### `setup openclaw` env vars (v0.10.4+)
94
+
95
+ Both the delegated and fallback paths honor:
96
+
97
+ | Env var | Effect |
98
+ |---------|--------|
99
+ | `OPENCLAW_STATE_DIR` | Override the OpenClaw config root. Plugin installs into `<OPENCLAW_STATE_DIR>/extensions/clawmem`. |
100
+ | `OPENCLAW_CONFIG_PATH` | Override the OpenClaw config file path; config root becomes `dirname(OPENCLAW_CONFIG_PATH)`. |
101
+ | `OPENCLAW_HOME` | Override the home directory used to resolve the default `~/.openclaw` root. |
102
+ | `HOME` / `USERPROFILE` | Standard home-dir env vars; consulted in that order when `OPENCLAW_HOME` is unset. |
103
+
104
+ ```bash
105
+ # Install ClawMem into the `dev` profile (~/.openclaw-dev/extensions/clawmem)
106
+ OPENCLAW_STATE_DIR=~/.openclaw-dev clawmem setup openclaw
107
+ ```
108
+
109
+ ## Server
110
+
111
+ ```bash
112
+ clawmem serve # Start REST API (localhost:7438)
113
+ clawmem serve --port 8080 # Custom port
114
+ clawmem serve --host 0.0.0.0 # Listen on all interfaces
115
+ ```
116
+
117
+ ## Hook execution (internal)
118
+
119
+ ```bash
120
+ clawmem hook context-surfacing # Execute a hook (reads JSON from stdin)
121
+ clawmem hook decision-extractor
122
+ clawmem hook handoff-generator
123
+ clawmem hook feedback-loop
124
+ clawmem hook precompact-extract
125
+ clawmem hook session-bootstrap
126
+ clawmem hook staleness-check
127
+ clawmem hook curator-nudge
128
+ ```
129
+
130
+ ## IO6 surface commands (daemon integration)
131
+
132
+ For non-hook integrations where a host process needs to inject context programmatically (e.g., daemon mode, custom orchestrators):
133
+
134
+ ```bash
135
+ echo "user query" | clawmem surface --context --stdin # Per-prompt context injection
136
+ echo "session-id" | clawmem surface --bootstrap --stdin # Per-session bootstrap
137
+ ```
138
+
139
+ ## Analysis
140
+
141
+ ```bash
142
+ clawmem reflect [N] # Cross-session reflection (last N days, default 14)
143
+ clawmem consolidate [--dry-run] # Find and archive duplicate low-confidence documents
144
+ ```
145
+
146
+ ## Session focus topic (v0.9.0)
147
+
148
+ Per-session topic biasing for the context-surfacing hook. Writes a focus file at `~/.cache/clawmem/sessions/<session_id>.focus` that steers query expansion, reranking, snippet extraction, and applies a post-composite-score topic boost (1.4× match, 0.75× demote, NO-OP on zero matches). Session-scoped — never writes to SQLite or mutates any lifecycle column.
149
+
150
+ ```bash
151
+ clawmem focus set "<topic>" # uses CLAUDE_SESSION_ID / CLAWMEM_SESSION_ID env
152
+ clawmem focus set "<topic>" --session-id <id> # explicit session id
153
+ clawmem focus show # reads session id from env
154
+ clawmem focus show --session-id <id>
155
+ clawmem focus clear # uses env-resolved session id
156
+ clawmem focus clear --session-id <id>
157
+ ```
158
+
159
+ The session ID is resolved from `--session-id <id>`, then `CLAUDE_SESSION_ID`, then `CLAWMEM_SESSION_ID`. `CLAWMEM_SESSION_FOCUS` env var is a debug-only override that does NOT provide per-session scoping on multi-session hosts. `CLAWMEM_FOCUS_ROOT` overrides the focus file root directory for hermetic testing.
160
+
161
+ ## Environment variables
162
+
163
+ | Variable | Default | Description |
164
+ |----------|---------|-------------|
165
+ | `CLAWMEM_EMBED_URL` | `http://localhost:8088` | Embedding server |
166
+ | `CLAWMEM_EMBED_API_KEY` | — | API key for cloud embedding |
167
+ | `CLAWMEM_EMBED_MODEL` | `embedding` | Model name for embedding requests |
168
+ | `CLAWMEM_EMBED_MAX_CHARS` | `6000` | Max chars per embedding input |
169
+ | `CLAWMEM_EMBED_TPM_LIMIT` | `100000` | Tokens-per-minute limit for cloud embedding pacing |
170
+ | `CLAWMEM_EMBED_DIMENSIONS` | — | Output dimensions for OpenAI `text-embedding-3-*` models |
171
+ | `CLAWMEM_LLM_URL` | `http://localhost:8089` | LLM server |
172
+ | `CLAWMEM_LLM_MODEL` | `qwen3` | Model name sent to the configured LLM endpoint |
173
+ | `CLAWMEM_LLM_REASONING_EFFORT` | — | Optional top-level `reasoning_effort` field for Chat Completions endpoints that support it (for example OpenAI reasoning models). Leave unset for llama-server/vLLM unless explicitly supported. |
174
+ | `CLAWMEM_LLM_NO_THINK` | `true` | Append `/no_think` to remote prompts; set `false` for standard OpenAI models and other endpoints that reject or treat it as literal prompt text |
175
+ | `CLAWMEM_RERANK_URL` | `http://localhost:8090` | Reranker server |
176
+ | `CLAWMEM_NO_LOCAL_MODELS` | `false` | Block node-llama-cpp auto-downloads |
177
+ | `CLAWMEM_PROFILE` | `balanced` | Performance profile: `speed` (BM25 only), `balanced` (BM25+vector), `deep` (BM25+vector+expansion+reranking) |
178
+ | `CLAWMEM_VAULTS` | — | JSON map of vault name to SQLite path |
179
+ | `CLAWMEM_API_TOKEN` | — | Bearer token for REST API auth |
180
+ | `CLAWMEM_ENABLE_AMEM` | enabled | A-MEM note construction during indexing |
181
+ | `CLAWMEM_ENABLE_CONSOLIDATION` | disabled | Background consolidation worker (light lane, 5-min interval). **v0.8.2:** every tick wraps in a `worker_leases` row (`light-consolidation` key) so dual-host (`clawmem watch` + `clawmem mcp`) is safe. Hosted by either `cmdWatch` (canonical, long-lived) or `cmdMcp` (per-session fallback). |
182
+ | `CLAWMEM_CONSOLIDATION_INTERVAL` | `300000` | Light-lane worker interval in ms |
183
+ | `CLAWMEM_HEAVY_LANE` | disabled | **v0.8.0.** Enable the quiet-window heavy maintenance lane (second consolidation worker with DB-backed lease + stale-first batching + `maintenance_runs` journaling). See [heavy maintenance lane](../concepts/architecture.md#heavy-maintenance-lane-v080). **v0.8.2:** canonical host is `clawmem watch`; `clawmem mcp` retains the same gate as a fallback host but emits a stderr warning advising operators to move heavy-lane hosting to the watcher because per-session stdio MCPs may never be alive during the configured quiet window. |
184
+ | `CLAWMEM_HEAVY_LANE_INTERVAL` | `1800000` | **v0.8.0.** Heavy-lane tick interval in ms (default 30 min, min 30 s). |
185
+ | `CLAWMEM_HEAVY_LANE_WINDOW_START` | — | **v0.8.0.** Start hour (0-23) of the quiet window. Unset → no window. |
186
+ | `CLAWMEM_HEAVY_LANE_WINDOW_END` | — | **v0.8.0.** End hour (0-23, exclusive). Supports midnight wrap (22→6). |
187
+ | `CLAWMEM_HEAVY_LANE_MAX_USAGES` | `30` | **v0.8.0.** Max `context_usage` rows in the last 10 min before the heavy lane skips with `reason='query_rate_high'`. |
188
+ | `CLAWMEM_HEAVY_LANE_OBS_LIMIT` | `100` | **v0.8.0.** Phase 2 stale-first observation batch size for the heavy lane. |
189
+ | `CLAWMEM_HEAVY_LANE_DED_LIMIT` | `40` | **v0.8.0.** Phase 3 stale-first deductive candidate batch size for the heavy lane. |
190
+ | `CLAWMEM_HEAVY_LANE_SURPRISAL` | `false` | **v0.8.0.** When `true`, seed Phase 2 with k-NN anomaly-ranked doc ids from `computeSurprisalScores` instead of stale-first ordering. Degrades to stale-first on vaults without embeddings. |
191
+ | `CLAWMEM_SESSION_FOCUS` | — | **v0.9.0 §11.4.** Debug-only override for the session focus topic. NOT session-scoped — do not use in multi-session deployments. Use `clawmem focus set <topic> --session-id <id>` instead. |
192
+ | `CLAWMEM_FOCUS_ROOT` | `~/.cache/clawmem/sessions` | **v0.9.0 §11.4.** Override directory for per-session focus files. Primarily for hermetic testing. |
193
+ | `INDEX_PATH` | `~/.cache/clawmem/index.sqlite` | Override default vault path |
194
+
195
+ The `bin/clawmem` wrapper sets endpoint defaults. Always use it instead of `bun run src/clawmem.ts` directly.
@@ -0,0 +1,101 @@
1
+ # Configuration reference (environment variables)
2
+
3
+ All ClawMem tuning knobs are environment variables. The `bin/clawmem` wrapper sets the endpoint defaults; **always run ClawMem via the wrapper.** For remote GPU setups, add the same vars to your systemd units via a drop-in.
4
+
5
+ **Precedence:** shell environment > `.env` file (project root) > `bin/clawmem` wrapper defaults. The wrapper sources `.env` before applying defaults, so `.env` overrides defaults but explicit shell exports still win.
6
+
7
+ See also: [../guides/inference-services.md](../guides/inference-services.md) (stack choice + server setup) · [../guides/cloud-embedding.md](../guides/cloud-embedding.md) (cloud providers) · [../guides/systemd-services.md](../guides/systemd-services.md) (services).
8
+
9
+ ## Inference routing
10
+
11
+ | Variable | Default (via wrapper) | Effect |
12
+ |---|---|---|
13
+ | `CLAWMEM_EMBED_URL` | `http://localhost:8088` | Embedding server URL. Local `llama-server`, cloud API, or in-process `node-llama-cpp` fallback if unset. |
14
+ | `CLAWMEM_LLM_URL` | `http://localhost:8089` | LLM server for intent, expansion, A-MEM, entity extraction. Falls to `node-llama-cpp` if unset + `NO_LOCAL_MODELS=false`. Point at a 7B+ model or cloud API during `reindex --enrich` for better entity extraction. |
15
+ | `CLAWMEM_RERANK_URL` | `http://localhost:8090` | Reranker server. Falls to `node-llama-cpp` if unset + `NO_LOCAL_MODELS=false`. |
16
+ | `CLAWMEM_LLM_MODEL` | `qwen3` | Model name sent on LLM requests. |
17
+ | `CLAWMEM_LLM_REASONING_EFFORT` | (none) | Top-level `reasoning_effort` for Chat Completions endpoints that support it (e.g. a remote reasoning model). Optional. |
18
+ | `CLAWMEM_LLM_NO_THINK` | enabled | Appends `/no_think` to remote LLM prompts (Qwen3 emits thinking tokens by default). Set `false` for standard OpenAI-compatible models that would treat `/no_think` as literal text. |
19
+ | `CLAWMEM_NO_LOCAL_MODELS` | `false` | Blocks `node-llama-cpp` from auto-downloading GGUFs. Set `true` for remote-only setups to fail fast on unreachable endpoints. |
20
+
21
+ ## Cloud embedding
22
+
23
+ Full provider matrix and behavior: [../guides/cloud-embedding.md](../guides/cloud-embedding.md).
24
+
25
+ | Variable | Default | Effect |
26
+ |---|---|---|
27
+ | `CLAWMEM_EMBED_API_KEY` | (none) | API key for cloud embedding providers (Bearer token). Enables cloud mode: skips client-side truncation, sends `truncate: true` + provider params, batch embedding with adaptive TPM pacing. |
28
+ | `CLAWMEM_EMBED_MODEL` | `embedding` | Model name for embedding requests. Override for cloud (e.g. `jina-embeddings-v5-text-small`). |
29
+ | `CLAWMEM_EMBED_MAX_CHARS` | `6000` | Max chars per embedding input (local only; fits EmbeddingGemma's 2048 tokens). Set `1100` for granite-278m (512 tokens). Cloud providers skip truncation. |
30
+ | `CLAWMEM_EMBED_TPM_LIMIT` | `100000` | Tokens-per-minute limit for cloud pacing. Match your tier (e.g. Jina Free 100000, Paid 2000000, Premium 50000000). |
31
+ | `CLAWMEM_EMBED_DIMENSIONS` | (none) | Output dimensions for OpenAI `text-embedding-3-*` Matryoshka models (e.g. `512`, `1024`). Sent only when the URL contains `openai.com`. |
32
+
33
+ ## Retrieval profile
34
+
35
+ | Variable | Default | Effect |
36
+ |---|---|---|
37
+ | `CLAWMEM_PROFILE` | `balanced` | `speed` / `balanced` / `deep`. Sets the kept-score ratio (65% / 55% / 45%), vector timeout, max results, and the `factsTokens` sub-budget. Only `deep` adds query expansion + reranking to the hook path. `speed` makes hooks BM25-only (sub-500ms). |
38
+ | `CLAWMEM_NUDGE_INTERVAL` | `15` | Prompts between lifecycle tool use before a `<vault-nudge>` is injected. `0` to disable. |
39
+
40
+ The context-surfacing hook `timeout` is **not** an env var — it lives in `~/.claude/settings.json` (8s default). See [../troubleshooting.md](../troubleshooting.md) → *Tuning the context-surfacing hook timeout*.
41
+
42
+ ## Multi-vault
43
+
44
+ | Variable | Default | Effect |
45
+ |---|---|---|
46
+ | `CLAWMEM_VAULTS` | (none) | JSON map of vault name → SQLite path. E.g. `{"work":"~/.cache/clawmem/work.sqlite"}`. Paths support `~`. (Also configurable in `~/.config/clawmem/config.yaml` under `vaults:`.) |
47
+
48
+ ## A-MEM & consolidation
49
+
50
+ | Variable | Default | Effect |
51
+ |---|---|---|
52
+ | `CLAWMEM_ENABLE_AMEM` | enabled | A-MEM note construction + link generation during indexing. |
53
+ | `CLAWMEM_ENABLE_CONSOLIDATION` | disabled | Background worker backfills unenriched docs + runs Phase 2/3 consolidation + deductive synthesis. Each tick wrapped in a DB-backed `worker_leases` row (`light-consolidation`) so multiple hosts can't race Phase 2 writes. Hosted by `clawmem watch` (canonical) or `clawmem mcp` (per-session fallback). |
54
+ | `CLAWMEM_CONSOLIDATION_INTERVAL` | `300000` | Light-worker interval in ms (min 15000). |
55
+
56
+ ## Heavy maintenance lane (v0.8.0)
57
+
58
+ A second, longer-interval consolidation lane with DB-backed exclusivity, stale-first batching, and `maintenance_runs` journaling. Off by default; canonical host is `clawmem watch`.
59
+
60
+ | Variable | Default | Effect |
61
+ |---|---|---|
62
+ | `CLAWMEM_HEAVY_LANE` | disabled | Enable the quiet-window heavy lane. |
63
+ | `CLAWMEM_HEAVY_LANE_INTERVAL` | `1800000` | Tick interval in ms (min 30000, default 30 min). |
64
+ | `CLAWMEM_HEAVY_LANE_WINDOW_START` | (none) | Start hour (0–23) of the quiet window. Unset → no window. |
65
+ | `CLAWMEM_HEAVY_LANE_WINDOW_END` | (none) | End hour (0–23, exclusive). Supports midnight wrap (22→6). |
66
+ | `CLAWMEM_HEAVY_LANE_MAX_USAGES` | `30` | Max `context_usage` rows in the last 10 min before the lane skips (`reason='query_rate_high'`). |
67
+ | `CLAWMEM_HEAVY_LANE_OBS_LIMIT` | `100` | Phase 2 stale-first observation batch size. |
68
+ | `CLAWMEM_HEAVY_LANE_DED_LIMIT` | `40` | Phase 3 stale-first deductive candidate batch size. |
69
+ | `CLAWMEM_HEAVY_LANE_SURPRISAL` | `false` | When `true`, seed Phase 2 with k-NN anomaly-ranked doc ids instead of stale-first. Degrades to stale-first on vaults without embeddings. |
70
+
71
+ ## Merge & contradiction safety (v0.7.1)
72
+
73
+ | Variable | Default | Effect |
74
+ |---|---|---|
75
+ | `CLAWMEM_MERGE_SCORE_NORMAL` | `0.93` | Phase 2 merge-safety threshold (normalized 3-gram cosine) when anchors align. |
76
+ | `CLAWMEM_MERGE_SCORE_STRICT` | `0.98` | Strictest merge-safety threshold (fallback when anchors are ambiguous). |
77
+ | `CLAWMEM_MERGE_GUARD_DRY_RUN` | `false` | When `true`, merge-safety rejections are logged but not enforced — calibration before switching the gate on. |
78
+ | `CLAWMEM_CONTRADICTION_POLICY` | `link` | How the merge-time contradiction gate handles a contradictory merge. `link` keeps both rows + adds a `contradicts` edge; `supersede` marks the old row `status='inactive'`. |
79
+ | `CLAWMEM_CONTRADICTION_MIN_CONFIDENCE` | `0.5` | Minimum combined (heuristic + LLM) confidence before the gate blocks a merge. Below this, the merge proceeds. |
80
+
81
+ ## REST API & Hermes plugin
82
+
83
+ | Variable | Default | Effect |
84
+ |---|---|---|
85
+ | `CLAWMEM_API_TOKEN` | (none) | When set, `clawmem serve` requires `Authorization: Bearer <token>` on all requests. Unset → open (localhost-only by default). |
86
+ | `CLAWMEM_SERVE_PORT` | `7438` | REST API port read by the **Hermes plugin** (to launch/connect to `clawmem serve`). Manual `clawmem serve` takes `--port` instead — it does not read this env var. |
87
+ | `CLAWMEM_SERVE_MODE` | `external` | Hermes plugin serve mode: `external` (you run `clawmem serve`) or `managed` (the plugin starts/stops `serve`). |
88
+ | `CLAWMEM_BIN` | (auto-detect on PATH) | Path to the `clawmem` binary, for the Hermes plugin when it is not on `PATH`. |
89
+
90
+ ## Hooks, session & paths
91
+
92
+ | Variable | Default | Effect |
93
+ |---|---|---|
94
+ | `CLAWMEM_CONFIG_DIR` | `~/.config/clawmem` | Override the config directory (holds `config.yaml`). |
95
+ | `CLAWMEM_SESSION_ID` | (Claude Code exposes its own) | Session id for the per-session focus topic; set explicitly in non-Claude-Code environments. |
96
+ | `CLAWMEM_FOCUS_ROOT` | `~/.cache/clawmem/sessions` | Directory for per-session focus files (`clawmem focus`). |
97
+ | `CLAWMEM_SESSION_FOCUS` | (none) | **Debug only.** Directly overrides the session focus topic, bypassing the focus file. |
98
+ | `CLAWMEM_HEARTBEAT_PATTERNS` | (built-in set) | Comma-separated prompt patterns treated as heartbeats (skipped by context-surfacing). |
99
+ | `CLAWMEM_DISABLE_HEARTBEAT_SUPPRESSION` | `false` | Set `true` to disable heartbeat-prompt suppression in the context-surfacing hook. |
100
+ | `CLAWMEM_HOOK_DEDUP_WINDOW_SEC` | (built-in) | Window (seconds) for deduplicating hook-generated observations by normalized content hash. |
101
+ | `CLAWMEM_PRECOMPACT_PROXIMITY_RATIO` | (built-in, clamped [0.5, 0.95]) | OpenClaw `before_prompt_build` precompact trigger: fraction of the compaction threshold at which pre-emptive extraction fires. |