cogmem 3.6.3 → 3.6.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.
@@ -31,35 +31,56 @@ cogmem prospective due --project <projectId>
31
31
 
32
32
  ## Install
33
33
 
34
- Run from the Hermes workspace root:
34
+ Run from the Hermes workspace root. Prefer a workspace-local npm dependency so Hermes and Cogmem upgrade together:
35
35
 
36
36
  ```bash
37
- COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
38
- cogmem init --yes --agent hermes
39
- cogmem doctor
40
- cogmem connect hermes --workspace . --auto --force
37
+ npm install cogmem@latest --save
38
+ COGMEM="./node_modules/.bin/cogmem"
39
+ "$COGMEM" doctor
40
+ "$COGMEM" connect hermes --workspace . --auto --force --json
41
+ ```
42
+
43
+ If the workspace already has Cogmem installed locally, keep using the local binary. If there is no local binary but a global install exists, use global. If neither exists, install first:
44
+
45
+ ```bash
46
+ if [ -x ./node_modules/.bin/cogmem ]; then
47
+ COGMEM="./node_modules/.bin/cogmem"
48
+ elif command -v cogmem >/dev/null 2>&1; then
49
+ COGMEM="cogmem"
50
+ else
51
+ npm install cogmem@latest --save
52
+ COGMEM="./node_modules/.bin/cogmem"
53
+ fi
41
54
  ```
42
55
 
43
- If Bun is already installed and the operator wants npm global installation instead of the one-line installer, use:
56
+ Global npm is also supported when the operator wants one CLI for every workspace:
44
57
 
45
58
  ```bash
46
59
  npm install -g cogmem@latest
47
- cogmem init --yes --agent hermes
48
- cogmem connect hermes --workspace . --auto --force
60
+ COGMEM="cogmem"
61
+ "$COGMEM" connect hermes --workspace . --auto --force --json
49
62
  ```
50
63
 
51
- Use project-local config only when this workspace needs isolation:
64
+ The one-line installer remains available for machines that do not already have Bun. Use `COGMEM_SKIP_INIT=1` for agent-run installs so the installer does not start the interactive wizard:
52
65
 
53
66
  ```bash
54
- cogmem init --yes --agent hermes --scope project
67
+ COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
68
+ COGMEM="cogmem"
69
+ "$COGMEM" connect hermes --workspace . --auto --force --json
55
70
  ```
56
71
 
57
- The default install creates:
72
+ Do not run `cogmem init` as an unattended agent action. `cogmem init` is an interactive configuration wizard. Use it only when an operator is present or explicitly asks for a guided setup:
73
+
74
+ ```bash
75
+ "$COGMEM" init --agent hermes --scope project
76
+ ```
77
+
78
+ Hermes workspaces should normally use project-local config when the workspace owns its memory:
58
79
 
59
80
  ```text
60
- ~/.cogmem/config.toml
61
- ~/.cogmem/memory.db
62
- ~/.cogmem/snapshots/
81
+ .cogmem/config.toml
82
+ .cogmem/memory.db
83
+ .cogmem/snapshots/
63
84
  ```
64
85
 
65
86
  To embed imported memories with a local quantized model, run Ollama locally and configure the kernel before importing:
@@ -159,14 +180,26 @@ cogmem import-hermes --workspace . --project hermes --session ./hermes.normalize
159
180
 
160
181
  The importer is idempotent. Re-running it skips records already imported into the same memory database.
161
182
 
162
- Run the curator/governance loop under host supervision after import and during normal use:
183
+ Cogmem 3.6.4 and later skip import batch sealing for empty episode boundaries and Dream skips legacy empty episode jobs instead of blocking the whole queue. If `episode status` shows `dreamError` beginning with `episode_empty`, inspect the source events and use episode repair instead of editing SQLite rows.
184
+
185
+ Run the maintenance loop under host supervision after import and during normal use. `needs_confirmation` is a human review queue, not the Dream backlog, and `memory govern` promotes only ordinary `candidate` rows:
163
186
 
164
187
  ```bash
188
+ cogmem memory plan --project hermes --json
189
+ cogmem memory status --project hermes --json
190
+ cogmem memory candidates --project hermes --json
165
191
  cogmem episode status --project hermes --json
166
- cogmem dream tick --project hermes --mode auto --json
167
- cogmem memory govern --project hermes --json
192
+ cogmem dream status --project hermes --json
193
+ cogmem dream tick --project hermes --mode auto --max-episodes 20 --json
194
+ cogmem memory candidates --project hermes --status candidate --json
195
+ cogmem memory govern --project hermes --limit 100 --json
196
+ cogmem memory candidates --project hermes --status needs_confirmation --json
197
+ cogmem memory review --project hermes --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <distinct-user-event-id> --json
198
+ cogmem memory recall --query "<verification question>" --project hermes --agent hermes --json
168
199
  ```
169
200
 
201
+ `memory plan` is the first agent-safe health and next-action command. It explains which queues block release, which work is non-blocking, whether vectors are empty but fallback recall is available, and what command should run next. Only run `dream_tick` when it appears in `nextActions`; if `nonBlocking` contains `raw_dream_ledger_lag` with `resolvableByDreamTick:false`, inspect raw sources or episode/import boundaries instead of retrying `dream tick`. Default `memory candidates --json` groups ordinary candidates, `needs_confirmation`, and deferred review entries; use `--status` only when the operator asks for one queue.
202
+
170
203
  A host timer may run this bounded tick periodically. The tick exits after inspecting the backlog and performs no work when no sealed episode is ready.
171
204
 
172
205
  ## Active Memory Search
@@ -204,9 +237,25 @@ cogmem memory show --event <event-id> --before 2 --after 2 --json
204
237
 
205
238
  `sourceContext` entries include stable `label` values, optional `charRange` / `sourceRange`, and `sourceContext.window` metadata. Use `window.before.requestedCount`, `window.before.count`, `window.after.requestedCount`, `window.after.count`, `excludesAnchor`, `ordering`, `roleFilter`, and `overlapHandling` to understand the before/after replay. `memory show --json` returns the same contract, so the labels in MCP recall can be matched to the local CLI output.
206
239
 
240
+ For “did we discuss this before?”, “几个月前是不是聊过…”, “记忆黑盒”, MCP memory gaps, or other old-discussion questions, force the historical-discussion lane before saying memory is absent:
241
+
242
+ ```bash
243
+ cogmem memory recall --query "<past discussion question>" --intent historical_discussion --project hermes --agent hermes --json
244
+ ```
245
+
246
+ If the answer depends on exact wording or nearby context, run the returned `sourceLocator` or use a Raw Ledger cursor:
247
+
248
+ ```bash
249
+ cogmem memory show --event <eventId> --project hermes --before 2 --after 2 --json
250
+ cogmem memory list --project hermes --since <globalSeq> --order asc --json
251
+ ```
252
+
253
+ In 3.6.5, raw list rows and Atlas search/explore evidence include `sourceLocator.command` and a deeper `sourceLocator.contextCommand`. Use those commands before claiming an event ID is missing, before quoting exact words, or before treating an Atlas summary as the source.
254
+
207
255
  `vectors: 0` does not mean memory is unavailable. It means dense vector search has no hot index yet; `memory recall` still has governed raw-ledger fallback. Broad inventory questions are expanded into structured cues such as `库存管理`, `在库`, `产品コード`, and `数量`; when compiled candidates miss those cues, prefer the raw ledger result and use its `sourceContext` for details. Check status with:
208
256
 
209
257
  ```bash
258
+ cogmem memory plan --project hermes --json
210
259
  cogmem memory status --project hermes --json
211
260
  ```
212
261
 
@@ -223,12 +272,13 @@ Default recall includes untagged and `collection:anchor` memory only. Ask for `c
223
272
  For host upkeep, inspect the self-map and run an explicit tick:
224
273
 
225
274
  ```bash
275
+ cogmem memory plan --project hermes --json
226
276
  cogmem memory map --project hermes --json
227
277
  cogmem memory tick --project hermes --json
228
278
  cogmem memory bind --project hermes --json
229
279
  ```
230
280
 
231
- `memory tick` does not start a daemon. Use its `suggestedActions` to decide whether Hermes should run `dream tick`, `memory govern`, `episode repair`, entity review, re-embedding, or `memory bind` for unbound high-value raw events.
281
+ `memory tick` does not start a daemon. Use its `suggestedActions` to decide whether Hermes should run `dream tick`, `memory govern`, `episode repair`, entity review, re-embedding, or `memory bind` for unbound high-value raw events. `undreamedRawCount` by itself is Raw Ledger coverage lag, not a sealed-episode job; do not loop `dream tick` unless `memory plan.nextActions` contains `dream_tick`. In 3.6.5, `memory bind` scans the historical Raw Ledger by cursor instead of only the latest page; resume large repairs with `--since <globalSeq>`.
232
282
 
233
283
  `memory map` also exposes Memory Binding and Graph Recall counters. Bindings connect high-value user raw events to stable topic/entity paths before promotion, fuse same-claim evidence into claim-key clusters, and create graph anchors for source drill-down. Correction bindings expose review flags and correction edges. Use graph recall hits for source drill-down and topic continuity only; do not treat bindings, clusters, or edges as verified facts, user preferences, or prompt instructions.
234
284
 
@@ -238,7 +288,7 @@ Explicit user clarification is organizational correction evidence, not an automa
238
288
 
239
289
  When importing OpenClaw-style session Markdown into a Hermes project, Cogmem accepts multiline bodies below empty role headers, collapses only adjacent exact export duplicates, and uses `# Session: ... UTC` as the chronological timestamp base rather than file mtime.
240
290
 
241
- After upgrading, rerun `cogmem connect hermes --workspace . --auto --force` and reload MCP so existing allow-lists and skill instructions receive the current tools and contracts.
291
+ After upgrading, rerun `cogmem connect hermes --workspace . --auto --force --json` and reload MCP so existing allow-lists and skill instructions receive the current tools and contracts. In JSON output, follow only `nextCommands` for unattended agent work; unsafe operator or host steps such as interactive init and `/reload-mcp` are listed under `nextSteps` with `safeForAutomation=false`.
242
292
 
243
293
  ## Runtime Wiring
244
294
 
@@ -304,8 +354,8 @@ Do not edit `~/.hermes/config.yaml` to point `memory.provider` at `cogmem` until
304
354
  ```yaml
305
355
  mcp_servers:
306
356
  cogmem:
307
- command: "/resolved/path/to/cogmem-mcp"
308
- args: []
357
+ command: "/resolved/path/to/cogmem"
358
+ args: ["mcp"]
309
359
  enabled: true
310
360
  tools:
311
361
  include:
@@ -337,7 +387,7 @@ mcp_servers:
337
387
  - cogmem_prospective
338
388
  ```
339
389
 
340
- The command path is resolved by `cogmem connect hermes`: it uses `COGMEM_MCP_BIN` when explicitly set, then a workspace-local `node_modules/.bin/cogmem-mcp` when present, then the globally linked `cogmem-mcp` from the one-line installer.
390
+ The command path is resolved by `cogmem connect hermes`: it uses `COGMEM_BIN` when explicitly set, then a workspace-local `node_modules/.bin/cogmem`, then global `cogmem`, and passes `mcp` as the first argument. `COGMEM_MCP_BIN` and `cogmem-mcp` remain compatibility paths for existing host configs.
341
391
 
342
392
  When Hermes calls `cogmem_recall`, it should pass `projectId: "hermes"` and may omit `agentId`; the MCP bridge infers `agentId` from `projectId`. The returned `items` use the same shape as `cogmem memory recall --project hermes --agent hermes --json`, including `raw_ledger` items, labeled `sourceContext` events, `sourceContext.window`, and `sourceContext.locator.command` when vectors are empty or compiled evidence misses.
343
393
 
@@ -1,4 +1,4 @@
1
- # Cogmem 3.6.3 Operations Reference for Hermes
1
+ # Cogmem 3.6.5 Operations Reference for Hermes
2
2
 
3
3
  Read this file when installing, upgrading, importing, repairing, or operating Cogmem. `SKILL.md` contains the decision rules; this file records the operational commands.
4
4
 
@@ -11,9 +11,11 @@ Read this file when installing, upgrading, importing, repairing, or operating Co
11
11
  | Upgrade an existing database | `cogmem migrate` |
12
12
  | Import Hermes state/profile/sessions | `cogmem import-hermes` |
13
13
  | Import generic message JSONL | `cogmem episode import` |
14
+ | Decide the next safe agent operation | `cogmem memory plan` |
14
15
  | Answer one direct memory question | `cogmem_recall` or `cogmem memory recall` |
15
16
  | See what memory exists or reconstruct history | Atlas `cogmem_graph_*` tools |
16
17
  | Quote exact source | `cogmem memory show` |
18
+ | Audit ledger sequence ranges | `cogmem memory list --since/--until/--order` |
17
19
  | Resolve uncertain candidates | `cogmem_candidate_review` or `memory review` |
18
20
  | Promote ordinary candidates | `memory govern` |
19
21
  | Correct episode boundaries | `cogmem_episode_repair` or episode repair CLI |
@@ -21,22 +23,35 @@ Read this file when installing, upgrading, importing, repairing, or operating Co
21
23
 
22
24
  ## Install, connect, and reload
23
25
 
26
+ Recommended workspace-local npm install:
27
+
24
28
  ```bash
25
- COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
26
- cogmem init --yes --agent hermes
27
- cogmem doctor
28
- cogmem connect hermes --workspace . --auto --force --json
29
+ npm install cogmem@latest --save
30
+ COGMEM="./node_modules/.bin/cogmem"
31
+ "$COGMEM" doctor
32
+ "$COGMEM" connect hermes --workspace . --auto --force --json
29
33
  ```
30
34
 
31
- If Bun is already installed and the operator prefers npm global installation:
35
+ Use this resolver in agent-run scripts:
32
36
 
33
37
  ```bash
34
- npm install -g cogmem@latest
35
- cogmem init --yes --agent hermes
36
- cogmem connect hermes --workspace . --auto --force --json
38
+ if [ -x ./node_modules/.bin/cogmem ]; then
39
+ COGMEM="./node_modules/.bin/cogmem"
40
+ elif command -v cogmem >/dev/null 2>&1; then
41
+ COGMEM="cogmem"
42
+ else
43
+ npm install cogmem@latest --save
44
+ COGMEM="./node_modules/.bin/cogmem"
45
+ fi
37
46
  ```
38
47
 
39
- Then run `/reload-mcp` inside Hermes. `connect --auto` installs this skill bundle and updates the Hermes MCP allow-list; it does not claim a native `memory.provider` integration.
48
+ Use `npm install -g cogmem@latest` only when the operator wants a global CLI. The one-line installer is still supported with `COGMEM_SKIP_INIT=1`, but do not run `cogmem init` unattended. `cogmem init` is an interactive wizard; run it only with an operator present:
49
+
50
+ ```bash
51
+ "$COGMEM" init --agent hermes --scope project
52
+ ```
53
+
54
+ Then run `/reload-mcp` inside Hermes. `connect --auto` installs this skill bundle and updates the Hermes MCP allow-list; it does not claim a native `memory.provider` integration. New configs start the bridge as `cogmem mcp`; `cogmem-mcp` remains a compatibility bin for older host configs.
40
55
 
41
56
  ## Upgrade and migrate
42
57
 
@@ -61,7 +76,7 @@ cogmem doctor
61
76
  cogmem connect hermes --workspace . --auto --force --json
62
77
  ```
63
78
 
64
- The backed-up command upgrades 3.5.2 schema 24, an existing 3.6.0 schema-26 database, or a pre-release schema-25 test database to the 3.6.3 schema-27 state in one run and preserves Raw Ledger evidence. `--dry-run` is read-only and does not create `_schema_migrations`. Reload MCP after reconnecting.
79
+ The backed-up command upgrades 3.5.2 schema 24, an existing 3.6.0 schema-26 database, or a pre-release schema-25 test database to the 3.6.5 schema-27 state in one run and preserves Raw Ledger evidence. `--dry-run` is read-only and does not create `_schema_migrations`. Reload MCP after reconnecting.
65
80
 
66
81
  ## Import Hermes memory
67
82
 
@@ -98,21 +113,43 @@ cogmem episode import --project hermes --session import-2026 --source-agent herm
98
113
 
99
114
  Use stable `externalMessageId` values for MCP append/import. If an MCP batch warns `auto_identity_not_safe_across_split_batches`, assign IDs before splitting or retrying.
100
115
 
116
+ After import, verify semantic maintenance in this exact order:
117
+
118
+ ```bash
119
+ cogmem memory plan --project hermes --json
120
+ cogmem memory status --project hermes --json
121
+ cogmem memory candidates --project hermes --json
122
+ cogmem episode status --project hermes --json
123
+ cogmem dream status --project hermes --json
124
+ cogmem dream tick --project hermes --mode auto --max-episodes 20 --json
125
+ cogmem memory candidates --project hermes --status candidate --json
126
+ cogmem memory govern --project hermes --limit 100 --json
127
+ cogmem memory candidates --project hermes --status needs_confirmation --json
128
+ cogmem memory review --project hermes --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <distinct-user-event-id> --json
129
+ cogmem memory recall --query "<verification question>" --project hermes --agent hermes --json
130
+ ```
131
+
132
+ `memory plan` is the first agent-safe health and next-action command. It reports queue state, blocking and non-blocking actions, Dream backlog hints, vector fallback state, and safe commands. Only run `dream_tick` when it appears in `nextActions`; if `nonBlocking` contains `raw_dream_ledger_lag` with `resolvableByDreamTick:false`, inspect raw sources or episode/import boundaries instead of retrying `dream tick`. Default `memory candidates --json` groups ordinary candidates, `needs_confirmation`, and deferred review entries; use `--status` only for one explicit queue. `needs_confirmation` is not a Dream backlog. `memory govern` does not approve it. Use `memory review` with explicit evidence. Cogmem 3.6.4 and later skip import batch sealing for empty episode boundaries and mark legacy empty Dream jobs as skipped so one bad imported episode cannot block the queue. If `episode status` reports `episode_empty_*`, inspect the episode and repair boundaries with the audited episode repair commands.
133
+
101
134
  ## Inspect, recall, and drill down
102
135
 
103
136
  ```bash
137
+ cogmem memory plan --project hermes --json
104
138
  cogmem memory status --project hermes --json
139
+ cogmem memory candidates --project hermes --json
105
140
  cogmem memory candidates --project hermes --status needs_confirmation --json
106
141
  cogmem episode status --project hermes --json
107
142
  cogmem dream status --project hermes --json
108
143
  cogmem memory recall --query "<question>" --project hermes --agent hermes --json
144
+ cogmem memory recall --query "<past discussion question>" --intent historical_discussion --project hermes --agent hermes --json
109
145
  cogmem explain-recall --query "<question>" --project hermes --agent hermes --json
110
146
  cogmem memory show --event <event-id> --before 2 --after 2 --json
147
+ cogmem memory list --project hermes --since <globalSeq> --order asc --json
111
148
  ```
112
149
 
113
150
  JSON uses `cogmem.cli.v1`: object fields are top-level, arrays use `items`, and queue counters remain top-level. `vectors: 0` is not a recall failure; inspect `vectorState`.
114
151
 
115
- Read-only status/candidates use a lightweight SQLite path and should not require stopping the MCP server.
152
+ Use `historical_discussion` for “did we discuss this before?”, “几个月前是不是聊过…”, “记忆黑盒”, and missing MCP memory cases. Raw list rows include `sourceLocator`; run the locator before quoting exact words or saying the event cannot be found. Read-only plan/status/candidates use a lightweight SQLite path and should not require stopping the MCP server.
116
153
 
117
154
  ## Memory Atlas as composable filters
118
155
 
@@ -137,7 +174,7 @@ Use MCP by question shape:
137
174
  - Direct fact: `cogmem_recall`.
138
175
  - Exact source: follow `evidenceEventIds` with `memory show`.
139
176
 
140
- Graph reads are pure and declared read-only/idempotent. Call `cogmem_graph_touch` only after using selected nodes. Overview display alone must not change future ranking. `evidenceTotal` is all known evidence; `evidenceReturned` is the bounded payload.
177
+ Graph reads are pure and declared read-only/idempotent. Call `cogmem_graph_touch` only after using selected nodes. Overview display alone must not change future ranking. `evidenceTotal` is all known evidence; `evidenceReturned` is the bounded payload. Search/explore evidence includes `sourceLocator.command` and `sourceLocator.contextCommand`; use those locators before treating an Atlas summary as evidence.
141
178
 
142
179
  ## Candidate governance and review
143
180
 
@@ -15,12 +15,17 @@ This writes `<workspace>/skills/cogmem-memory/SKILL.md`, which OpenClaw discover
15
15
  Run from the OpenClaw workspace root:
16
16
 
17
17
  ```bash
18
- COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
19
- cogmem init --yes --agent openclaw --scope project
20
- cogmem doctor --fix --agent openclaw --workspace .
21
- cogmem connect openclaw --workspace .
22
- cogmem connect openclaw --workspace . --auto --force
23
- cogmem openclaw diagnose --workspace . --json
18
+ npm install cogmem@latest --save
19
+ COGMEM="./node_modules/.bin/cogmem"
20
+ "$COGMEM" doctor
21
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
22
+ "$COGMEM" openclaw diagnose --workspace . --json
23
+ ```
24
+
25
+ Do not run `cogmem init` as an unattended agent action. It is an interactive wizard. Use it only when an operator is present:
26
+
27
+ ```bash
28
+ "$COGMEM" init --agent openclaw --scope project
24
29
  ```
25
30
 
26
31
  The OpenClaw workspace install creates:
@@ -92,6 +97,25 @@ cogmem import-openclaw --workspace . --project openclaw --json
92
97
  ```
93
98
 
94
99
  Real non-JSON imports print source-level and embedding+ingest progress to stderr. Use `--json --progress` to keep JSON on stdout while streaming progress to stderr, or `--no-progress` when a wrapper needs quiet stderr.
100
+ Cogmem 3.6.4 and later skip import batch sealing for empty episode boundaries and skip legacy empty Dream jobs so one bad imported episode cannot block the queue.
101
+
102
+ After import, use this order:
103
+
104
+ ```bash
105
+ cogmem memory plan --project openclaw --json
106
+ cogmem memory status --project openclaw --json
107
+ cogmem memory candidates --project openclaw --json
108
+ cogmem episode status --project openclaw --json
109
+ cogmem dream status --project openclaw --json
110
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
111
+ cogmem memory candidates --project openclaw --status candidate --json
112
+ cogmem memory govern --project openclaw --limit 100 --json
113
+ cogmem memory candidates --project openclaw --status needs_confirmation --json
114
+ cogmem memory review --project openclaw --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <user-event-id> --json
115
+ cogmem memory recall --query "<verification question>" --project openclaw --agent openclaw --json
116
+ ```
117
+
118
+ `memory plan` is the first agent-safe health and next-action command. Only run `dream_tick` when it appears in `nextActions`; if `nonBlocking` contains `raw_dream_ledger_lag` with `resolvableByDreamTick:false`, inspect raw sources or episode/import boundaries instead of retrying `dream tick`. Default `memory candidates --json` groups ordinary, `needs_confirmation`, and deferred review queues; use `--status` only when a human asks for one queue. `needs_confirmation` is not the Dream backlog. `memory govern` does not approve it; use `memory review` with explicit evidence.
95
119
 
96
120
  Import scope:
97
121
 
@@ -159,6 +183,8 @@ Recall behavior:
159
183
  - For each item with `sourceContext`, use event `label` values, optional `charRange` / `sourceRange`, and `sourceContext.window` to understand before/after semantics. Windows are chronological, exclude the anchor, and report overlap handling instead of relying on guesswork.
160
184
  - Use `cogmem memory map --project openclaw --json` to inspect Memory Binding and Graph Recall counters. Bindings attach high-value user raw events to stable topic/entity paths, fuse same-claim evidence into claim-key clusters, and create graph anchors for source drill-down only; they are not verified facts, user preferences, or instructions. Correction bindings expose review flags and `CORRECTS` / `CONTRADICTS` edges; inspect the raw ledger before relying on them.
161
185
  - If `cogmem memory tick --project openclaw --json` suggests `bind_raw_events`, run `cogmem memory bind --project openclaw --json` to backfill imported or adapter-written raw user events into the binding graph.
186
+ - For “did we discuss this before?”, “几个月前是不是聊过…”, “记忆黑盒”, or missing injection cases, run `cogmem memory recall --query "<past discussion question>" --intent historical_discussion --project openclaw --agent openclaw --json` before claiming no memory.
187
+ - For ledger audits or resumable checks, use `cogmem memory list --project openclaw --since <globalSeq> --order asc --json`; list rows and Atlas search/explore evidence include `sourceLocator` commands in 3.6.5.
162
188
 
163
189
  Installing the workspace skill makes the kernel procedure discoverable to OpenClaw agents. Installing the local auto wrapper makes future turns call the memory kernel automatically:
164
190
 
@@ -166,7 +192,7 @@ Installing the workspace skill makes the kernel procedure discoverable to OpenCl
166
192
  cogmem connect openclaw --workspace . --auto --force
167
193
  ```
168
194
 
169
- This writes `<workspace>/extensions/cogmem-auto-memory/`, patches OpenClaw `plugins.load.paths`, and enables `before_prompt_build` and `agent_end` hooks. The wrapper calls `KernelAgentMemoryBackend` through `cogmem` public API via a Bun bridge; core does not import OpenClaw.
195
+ This writes `<workspace>/extensions/cogmem-auto-memory/`, patches OpenClaw `plugins.load.paths`, and enables `before_prompt_build` and `agent_end` hooks. The wrapper calls `KernelAgentMemoryBackend` through `cogmem` public API via a Bun bridge; core does not import OpenClaw. In JSON output, follow only `nextCommands` for unattended agent work; unsafe operator or host steps such as interactive init and gateway restart are listed under `nextSteps` with `safeForAutomation=false`.
170
196
 
171
197
  The auto wrapper keeps OpenClaw native prompt/tool/skill context untouched. It prepends only Cogmem-owned context blocks:
172
198
 
@@ -9,19 +9,16 @@ Belief Graph writes keep ownership and evidence roles. OpenClaw may record assis
9
9
  ## Install
10
10
 
11
11
  ```bash
12
- COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
13
- cogmem init --yes --agent openclaw --scope project
14
- cogmem doctor --fix --agent openclaw --workspace .
15
- cogmem connect openclaw --workspace .
16
- cogmem connect openclaw --workspace . --auto --force
12
+ npm install cogmem@latest --save
13
+ COGMEM="./node_modules/.bin/cogmem"
14
+ "$COGMEM" doctor
15
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
17
16
  ```
18
17
 
19
- If Bun is already installed, npm global install is also supported:
18
+ Use `cogmem init` only as an interactive operator wizard, not as an unattended agent install step:
20
19
 
21
20
  ```bash
22
- npm install -g cogmem@latest
23
- cogmem init --yes --agent openclaw --scope project
24
- cogmem connect openclaw --workspace . --auto --force
21
+ "$COGMEM" init --agent openclaw --scope project
25
22
  ```
26
23
 
27
24
  ## Local Quantized Embeddings
@@ -61,7 +58,7 @@ Then run:
61
58
 
62
59
  ```bash
63
60
  cogmem episode status --project openclaw --json
64
- cogmem dream tick --project openclaw --mode auto --json
61
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
65
62
  cogmem memory govern --project openclaw --json
66
63
  cogmem memory candidates --project openclaw --status candidate --json
67
64
  ```
@@ -81,20 +78,23 @@ The Dream Worker processes sealed episodes and proposes candidate memories only.
81
78
  For host-owned inspection and upkeep:
82
79
 
83
80
  ```bash
81
+ cogmem memory plan --project openclaw --json
84
82
  cogmem memory map --project openclaw --json
85
83
  cogmem memory tick --project openclaw --json
86
84
  cogmem memory bind --project openclaw --json
87
85
  ```
88
86
 
89
- Cogmem 3.6.3 keeps the 3.6.x Memory Atlas and OpenClaw reliability work, then makes npm the default install and update channel. The auto plugin uses one shared bridge/kernel lifecycle for graph exploration, evidence-bearing node/timeline drill-down, and recall, so OpenClaw does not need MCP for broad inventory/history questions. Atlas combines the query's actual project, time, topic, entity/target, memory-kind, action, and keyword conditions like table filters; no fixed entity-time-action tuple is required.
87
+ Cogmem 3.6.5 keeps the 3.6.x Memory Atlas and OpenClaw reliability work, makes npm the default install and update channel, prevents empty imported episodes from blocking Dream, and adds an agent-safe operations protocol. Use `memory plan` for the next safe command, grouped `memory candidates --json` for queue state, `historical_discussion` recall for old-discussion questions, and returned `sourceLocator` commands for exact evidence. Only run `dream_tick` when it appears in `memory plan.nextActions`; `raw_dream_ledger_lag` in `nonBlocking` has `resolvableByDreamTick:false` and is not fixed by looping `dream tick`. The auto plugin uses one shared bridge/kernel lifecycle for graph exploration, evidence-bearing node/timeline drill-down, and recall, so OpenClaw does not need MCP for broad inventory/history questions. Atlas combines the query's actual project, time, topic, entity/target, memory-kind, action, and keyword conditions like table filters; no fixed entity-time-action tuple is required.
90
88
 
91
89
  ```bash
90
+ cogmem memory plan --project openclaw --json
92
91
  cogmem memory graph-explore --project openclaw --query "去年与 Hermes 有关的决定" --json
93
92
  cogmem memory graph-node --project openclaw --id <node-id> --include-evidence --json
94
93
  cogmem memory graph-path --project openclaw --from <node-id> --to <node-id> --json
94
+ cogmem memory recall --query "几个月前我们是不是讨论过 Cogmem 的记忆黑盒" --intent historical_discussion --project openclaw --agent openclaw --json
95
95
  ```
96
96
 
97
- Use Atlas to locate a bounded source-backed slice, then use `memory show` for exact evidence. Graph reads do not change activation; explicitly touch only nodes the agent actually uses. Activation controls default visibility and decays during explicit maintenance; exact scoped facets can still revive cold memory without promoting or rewriting it.
97
+ Use Atlas to locate a bounded source-backed slice, then use `memory show` or the returned `sourceLocator` for exact evidence. Graph reads do not change activation; explicitly touch only nodes the agent actually uses. Activation controls default visibility and decays during explicit maintenance; exact scoped facets can still revive cold memory without promoting or rewriting it.
98
98
 
99
99
  `memory tick` returns activation decay results and `suggestedActions`; it does not start a hidden daemon. If it reports `bind_raw_events`, run `memory bind` to attach imported or adapter-written raw user events to Memory Binding.
100
100
 
@@ -126,6 +126,21 @@ Import:
126
126
  cogmem import-openclaw --workspace . --project openclaw
127
127
  ```
128
128
 
129
+ After import:
130
+
131
+ ```bash
132
+ cogmem memory plan --project openclaw --json
133
+ cogmem memory status --project openclaw --json
134
+ cogmem memory candidates --project openclaw --json
135
+ cogmem episode status --project openclaw --json
136
+ cogmem dream status --project openclaw --json
137
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
138
+ cogmem memory candidates --project openclaw --status candidate --json
139
+ cogmem memory govern --project openclaw --limit 100 --json
140
+ cogmem memory candidates --project openclaw --status needs_confirmation --json
141
+ cogmem memory review --project openclaw --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <user-event-id> --json
142
+ ```
143
+
129
144
  Single source files and batches can be imported explicitly:
130
145
 
131
146
  ```bash
@@ -31,30 +31,51 @@ cogmem prospective due --project <projectId>
31
31
 
32
32
  ## Install
33
33
 
34
- Run from the OpenClaw workspace root:
34
+ Run from the OpenClaw workspace root. Prefer a workspace-local npm dependency so OpenClaw and Cogmem upgrade together:
35
35
 
36
36
  ```bash
37
- COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
38
- cogmem init --yes --agent openclaw --scope project
39
- cogmem doctor
40
- cogmem connect openclaw --workspace . --auto --force
37
+ npm install cogmem@latest --save
38
+ COGMEM="./node_modules/.bin/cogmem"
39
+ "$COGMEM" doctor
40
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
41
+ ```
42
+
43
+ If the workspace already has Cogmem installed locally, keep using the local binary. If there is no local binary but a global install exists, use global. If neither exists, install first:
44
+
45
+ ```bash
46
+ if [ -x ./node_modules/.bin/cogmem ]; then
47
+ COGMEM="./node_modules/.bin/cogmem"
48
+ elif command -v cogmem >/dev/null 2>&1; then
49
+ COGMEM="cogmem"
50
+ else
51
+ npm install cogmem@latest --save
52
+ COGMEM="./node_modules/.bin/cogmem"
53
+ fi
41
54
  ```
42
55
 
43
- If Bun is already installed and the operator wants npm global installation instead of the one-line installer, use:
56
+ Global npm is also supported when the operator wants one CLI for every workspace:
44
57
 
45
58
  ```bash
46
59
  npm install -g cogmem@latest
47
- cogmem init --yes --agent openclaw --scope project
48
- cogmem connect openclaw --workspace . --auto --force
60
+ COGMEM="cogmem"
61
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
62
+ ```
63
+
64
+ The one-line installer remains available for machines that do not already have Bun. Use `COGMEM_SKIP_INIT=1` for agent-run installs so the installer does not start the interactive wizard:
65
+
66
+ ```bash
67
+ COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
68
+ COGMEM="cogmem"
69
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
49
70
  ```
50
71
 
51
- This creates project-local kernel config and storage under `.cogmem/`, which is the recommended OpenClaw workspace setup.
72
+ Do not run `cogmem init` as an unattended agent action. `cogmem init` is an interactive configuration wizard. Use it only when an operator is present or explicitly asks for a guided setup:
52
73
 
53
74
  ```bash
54
- cogmem init --yes --agent openclaw --scope project
75
+ "$COGMEM" init --agent openclaw --scope project
55
76
  ```
56
77
 
57
- The install creates:
78
+ OpenClaw workspaces should normally use project-local kernel config and storage:
58
79
 
59
80
  ```text
60
81
  .cogmem/config.toml
@@ -155,6 +176,25 @@ cogmem import-openclaw --workspace . --project openclaw --json
155
176
 
156
177
  The importer is idempotent. Re-running it skips records already imported into the same memory database.
157
178
  Real non-JSON imports print source-level and embedding+ingest progress to stderr. Use `--json --progress` to keep JSON on stdout while streaming progress to stderr, or `--no-progress` when a wrapper needs quiet stderr.
179
+ Cogmem 3.6.4 and later skip import batch sealing for empty episode boundaries and Dream skips legacy empty episode jobs instead of blocking the whole queue. If `episode status` shows `dreamError` beginning with `episode_empty`, inspect the source events and use episode repair instead of editing SQLite rows.
180
+
181
+ After import, run the maintenance loop in this order. `needs_confirmation` is a human review queue, not the Dream backlog, and `memory govern` promotes only ordinary `candidate` rows:
182
+
183
+ ```bash
184
+ cogmem memory plan --project openclaw --json
185
+ cogmem memory status --project openclaw --json
186
+ cogmem memory candidates --project openclaw --json
187
+ cogmem episode status --project openclaw --json
188
+ cogmem dream status --project openclaw --json
189
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
190
+ cogmem memory candidates --project openclaw --status candidate --json
191
+ cogmem memory govern --project openclaw --limit 100 --json
192
+ cogmem memory candidates --project openclaw --status needs_confirmation --json
193
+ cogmem memory review --project openclaw --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <distinct-user-event-id> --json
194
+ cogmem memory recall --query "<verification question>" --project openclaw --agent openclaw --json
195
+ ```
196
+
197
+ `memory plan` is the first agent-safe health and next-action command. It explains which queues block release, which work is non-blocking, whether vectors are empty but fallback recall is available, and what command should run next. Only run `dream_tick` when it appears in `nextActions`; if `nonBlocking` contains `raw_dream_ledger_lag` with `resolvableByDreamTick:false`, inspect raw sources or episode/import boundaries instead of retrying `dream tick`. Default `memory candidates --json` groups ordinary candidates, `needs_confirmation`, and deferred review entries; use `--status` only when the operator asks for one queue.
158
198
 
159
199
  Imported sources:
160
200
 
@@ -252,15 +292,17 @@ Useful intents:
252
292
  ```bash
253
293
  cogmem memory recall --query "上个会话我们聊了什么" --intent previous_session_summary --project openclaw --agent openclaw --session "$OPENCLAW_SESSION_ID" --exclude-session "$OPENCLAW_SESSION_ID" --json
254
294
  cogmem memory recall --query "我关于记忆黑盒问题的原话是什么" --intent forensic_quote --project openclaw --agent openclaw --json
295
+ cogmem memory recall --query "几个月前我们是不是讨论过 Cogmem 的记忆黑盒" --intent historical_discussion --project openclaw --agent openclaw --json
255
296
  ```
256
297
 
257
298
  Use `items[].sourceContext` to understand what the user asked, how the agent answered, and nearby context. If the item has `sourceContext.locator.command`, run that command for a fuller local replay:
258
299
 
259
300
  ```bash
260
301
  cogmem memory show --event <eventId> --before 2 --after 2 --json
302
+ cogmem memory list --project openclaw --since <globalSeq> --order asc --json
261
303
  ```
262
304
 
263
- For old memories, a `raw_ledger` result may come from full scoped ledger text fallback even when Chinese FTS has no direct hit. Equal matches prefer the original user event; use `sourceContext.after` to inspect the paired assistant response instead of preferring a later assistant retelling.
305
+ For old memories, a `raw_ledger` result may come from full scoped ledger text fallback even when Chinese FTS has no direct hit. Equal matches prefer the original user event; use `sourceContext.after` to inspect the paired assistant response instead of preferring a later assistant retelling. In 3.6.5, raw list rows and Atlas search/explore evidence include `sourceLocator.command` and a deeper `sourceLocator.contextCommand`; use those before claiming exact source or event IDs are unavailable.
264
306
 
265
307
  Use collection routing for creative artifacts or drafts:
266
308
 
@@ -273,12 +315,13 @@ Default recall includes untagged and `collection:anchor` memory only. `collectio
273
315
  Use the self-map and explicit tick when the agent needs to understand or maintain the memory system:
274
316
 
275
317
  ```bash
318
+ cogmem memory plan --project openclaw --json
276
319
  cogmem memory map --project openclaw --json
277
320
  cogmem memory tick --project openclaw --json
278
321
  cogmem memory bind --project openclaw --json
279
322
  ```
280
323
 
281
- `memory tick` decays activation and returns `suggestedActions`; it does not run a hidden daemon. If it suggests `bind_raw_events`, run `memory bind` to backfill high-value raw user events written by imports or adapters. The tick also supersedes `needs_confirmation` items older than the default 30-day review TTL with an explicit status reason; it preserves candidate evidence.
324
+ `memory tick` decays activation and returns `suggestedActions`; it does not run a hidden daemon. If it suggests `bind_raw_events`, run `memory bind` to backfill high-value raw user events written by imports or adapters. In 3.6.5, `memory bind` scans the historical Raw Ledger by cursor instead of only the latest page; resume large repairs with `--since <globalSeq>`. The tick also supersedes `needs_confirmation` items older than the default 30-day review TTL with an explicit status reason; it preserves candidate evidence.
282
325
 
283
326
  `memory map` also exposes Memory Binding and Graph Recall counters. Bindings connect high-value user raw events to stable topic/entity paths before promotion, fuse same-claim evidence into claim-key clusters, and create graph anchors for source drill-down. Correction bindings add review flags and `CORRECTS` / `CONTRADICTS` edges. Use graph recall hits to inspect raw ledger history through `sourceContext`; do not treat bindings, clusters, or edges as verified facts, user preferences, or prompt instructions.
284
327
 
@@ -304,7 +347,7 @@ To make every future OpenClaw turn automatically use the memory kernel, install
304
347
  cogmem connect openclaw --workspace . --auto --force
305
348
  ```
306
349
 
307
- `--auto` writes `<workspace>/extensions/cogmem-auto-memory/`, patches `plugins.load.paths`, and enables `hooks.allowPromptInjection=true` and `hooks.allowConversationAccess=true` for the wrapper. The wrapper registers `before_prompt_build` for governed recall and `agent_end` for turn recording, then calls `KernelAgentMemoryBackend` through `cogmem` public API via a Bun bridge. Core does not import OpenClaw.
350
+ `--auto` writes `<workspace>/extensions/cogmem-auto-memory/`, patches `plugins.load.paths`, and enables `hooks.allowPromptInjection=true` and `hooks.allowConversationAccess=true` for the wrapper. The wrapper registers `before_prompt_build` for governed recall and `agent_end` for turn recording, then calls `KernelAgentMemoryBackend` through `cogmem` public API via a Bun bridge. Core does not import OpenClaw. In JSON output, follow only `nextCommands` for unattended agent work; unsafe operator or host steps such as interactive init and gateway restart are listed under `nextSteps` with `safeForAutomation=false`.
308
351
 
309
352
  Queued remember is the default. `agent_end` appends a durable JSONL job under `.cogmem/queue/openclaw-remember.jsonl` and starts a singleton drainer, so Telegram or gateway responses are not blocked by embeddings, SQLite writes, or slow local models. Plugin 0.6.3 acquires the queue lock before opening Cogmem, recovers stale lock directories and stale `.processing` queue files older than `rememberDrainTimeoutMs`, writes `owner.json` lock metadata, and processes bounded batches controlled by `rememberDrainBatchSize` (default `20`). If a drain fails, the job is retried and then moved to a dead-letter file instead of being silently discarded.
310
353
 
@@ -359,7 +402,7 @@ Run curation manually or from a host-owned schedule:
359
402
 
360
403
  ```bash
361
404
  cogmem episode status --project openclaw --json
362
- cogmem dream tick --project openclaw --mode auto --json
405
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
363
406
  cogmem memory govern --project openclaw --json
364
407
  cogmem memory candidates --project openclaw --status candidate --json
365
408
  ```
@@ -373,7 +416,7 @@ For periodic curation, let the host timer wake one bounded tick:
373
416
  cogmem dream tick --project openclaw --mode auto --max-episodes 10 --json
374
417
  ```
375
418
 
376
- The timer does not force a full Dream run. `dream tick` inspects sealed episode jobs, chooses no work, micro, normal, or deep mode, then exits. Run `cogmem memory govern` separately; candidates stay pending until governance evaluates them.
419
+ The timer does not force a full Dream run. `dream tick` inspects sealed episode jobs, chooses no work, micro, normal, or deep mode, then exits. `undreamedRawCount` by itself is Raw Ledger coverage lag, not a sealed-episode job; do not loop `dream tick` unless `memory plan.nextActions` contains `dream_tick`. Run `cogmem memory govern` separately; candidates stay pending until governance evaluates them.
377
420
 
378
421
  Episode classification is contextual but remains CPU-owned in the live hook. Short user replies are interpreted against whether the previous assistant turn was a proposal, question, or factual statement. Unknown turns default to an ambiguous review boundary; continuation needs explicit continuation language or topic/entity/project overlap. Background import or repair may use hybrid review, but normalized reviewer fields are allow-listed and cannot write belief, entity, temporal, prospective, topic, or governance state.
379
422
 
@@ -395,13 +438,14 @@ Explicit user clarification may create an organizational `correction` record. Do
395
438
 
396
439
  OpenClaw session exports may place the body below an empty `user:` or `assistant:` header and may repeat an assistant block exactly. Import accepts that layout, collapses only adjacent exact export duplicates, and uses the `# Session: ... UTC` heading as the chronological timestamp base. Do not rewrite the file solely to make it importable.
397
440
 
398
- If rejected provider diagnostics mention invalid memory-model output but later curation works, seal or repair the affected episode, run `cogmem dream tick --project openclaw --mode auto --json`, then run `cogmem memory govern --project openclaw --json`; recovered provider runs mark older provider diagnostics as `superseded`.
441
+ If rejected provider diagnostics mention invalid memory-model output but later curation works, seal or repair the affected episode, run `cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json`, then run `cogmem memory govern --project openclaw --json`; recovered provider runs mark older provider diagnostics as `superseded`.
399
442
 
400
443
  After package updates or config drift, repair the host wiring:
401
444
 
402
445
  ```bash
403
446
  cogmem connect openclaw --workspace . --auto --force
404
- cogmem doctor --fix --agent openclaw --workspace .
447
+ cogmem doctor --fix --agent openclaw --workspace . --plugin-only --json
448
+ openclaw gateway restart
405
449
  ```
406
450
 
407
451
  The wrapper maps OpenClaw behavior to core like this:
@@ -441,9 +485,11 @@ openclaw gateway restart
441
485
  If the OpenClaw environment exposes an MCP client, use the core MCP bridge instead of writing a native plugin first:
442
486
 
443
487
  ```bash
444
- cogmem-mcp
488
+ cogmem mcp
445
489
  ```
446
490
 
491
+ `cogmem-mcp` remains a compatibility bin for older host configs.
492
+
447
493
  Expose these tools to the agent:
448
494
 
449
495
  - `cogmem_remember_turn`