mnemo-engine 0.20.1__tar.gz → 0.20.2__tar.gz
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.
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/PKG-INFO +1 -1
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/Cargo.lock +3 -3
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/Cargo.toml +1 -1
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/README.md +11 -5
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/guide/guide.md +50 -8
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/bin/mnemo/hook.rs +24 -9
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/bin/mnemo/onboard.rs +239 -14
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/bin/mnemo.rs +200 -6
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/lib.rs +4 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/mcp.rs +144 -16
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/continuation.rs +5 -1
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/coordination.rs +57 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/essence.rs +151 -64
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/keyed.rs +83 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/mod.rs +1 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo-python/Cargo.lock +2 -2
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo-python/Cargo.toml +1 -1
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/pyproject.toml +1 -1
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/README.md +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/.gitignore +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/benches/corpus.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/build.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/deny.toml +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/ann_defaults_v0_6_0.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/ann_diagnose.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/ann_recall_grid.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/ann_recall_grid_v2.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/candle_hard.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/embedder_server.py +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/file_size_breakdown.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/inspect_demo_brain.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/open_rss.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/perf2_split.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/quickstart.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/ranking_v2.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/session.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/shared_bench.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/examples/thread_profile.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/bin/mnemo/export.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/bin/mnemo/inspect.html +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/bin/mnemo/inspect.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/bin/mnemo/mcp_install.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/bin/mnemo/project.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/bin/mnemo/wait.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/builtin.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/cache.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/crypto.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/embed.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/embed_cmd.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/error.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/format.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/freelist.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/guide.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/ident.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/index.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/keys/display.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/keys/mod.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/keys/os_store.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/keys/recovery.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/keyslot.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/mcp/context.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/memory.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/pager.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/redact.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/result_cache.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/session.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/shared/call.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/shared/fscheck.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/shared/lock.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/shared/mod.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/shared/presence.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/shared/sidecar.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/ann.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/cache_api.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/catchup.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/crud.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/findings.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/flush.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/header_graft_tests.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/hooks.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/load.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/maintenance.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/open.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/recall.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/records.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/shared.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/snapshots.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/store/threads.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/text.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/transcript.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/veccol.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo/src/wal.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo-python/.gitignore +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo-python/README.md +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo-python/src/lib.rs +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/mnemo-python/test_mnemo.py +0 -0
- {mnemo_engine-0.20.1 → mnemo_engine-0.20.2}/python/mnemo_engine/__init__.py +0 -0
|
@@ -1520,7 +1520,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|
|
1520
1520
|
|
|
1521
1521
|
[[package]]
|
|
1522
1522
|
name = "mnemo-engine"
|
|
1523
|
-
version = "0.20.
|
|
1523
|
+
version = "0.20.2"
|
|
1524
1524
|
dependencies = [
|
|
1525
1525
|
"aes-gcm",
|
|
1526
1526
|
"apple-native-keyring-store",
|
|
@@ -1561,7 +1561,7 @@ dependencies = [
|
|
|
1561
1561
|
|
|
1562
1562
|
[[package]]
|
|
1563
1563
|
name = "mnemo-node"
|
|
1564
|
-
version = "0.20.
|
|
1564
|
+
version = "0.20.2"
|
|
1565
1565
|
dependencies = [
|
|
1566
1566
|
"mnemo-engine",
|
|
1567
1567
|
"napi",
|
|
@@ -1571,7 +1571,7 @@ dependencies = [
|
|
|
1571
1571
|
|
|
1572
1572
|
[[package]]
|
|
1573
1573
|
name = "mnemo-uniffi"
|
|
1574
|
-
version = "0.20.
|
|
1574
|
+
version = "0.20.2"
|
|
1575
1575
|
dependencies = [
|
|
1576
1576
|
"mnemo-engine",
|
|
1577
1577
|
"serde_json",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
# The CLI binary name stays `mnemo`, so users still invoke `mnemo` on
|
|
11
11
|
# the command line after `cargo install mnemo-engine`.
|
|
12
12
|
name = "mnemo-engine"
|
|
13
|
-
version = "0.20.
|
|
13
|
+
version = "0.20.2"
|
|
14
14
|
edition = "2021"
|
|
15
15
|
rust-version = "1.94"
|
|
16
16
|
# `benches/corpus.rs` is a shared helper module pulled into real benches
|
|
@@ -113,7 +113,10 @@ in the sidecar directory for its life, and since v0.17.2 writes its
|
|
|
113
113
|
presence record at start, so `who` sees it alive before its first call; it
|
|
114
114
|
never holds the brain's lock between calls. Since v0.17, `recall` and `about` take `visibility` (private records only when asked), and `about` with `stale: true` lists the stale records. Since v0.20.1, `recall`,
|
|
115
115
|
`history`, `about` and `list` leave each memory's `vector` out unless the call
|
|
116
|
-
passes `include_vector: true`.
|
|
116
|
+
passes `include_vector: true`. Since v0.20.2, `get` returns one memory, by
|
|
117
|
+
`id` or by `key` (exactly one; by `key` the slot's live version, the slot
|
|
118
|
+
resolved as for `history`), with the same `visibility` and `include_vector`.
|
|
119
|
+
Every mutation flushes before returning.
|
|
117
120
|
|
|
118
121
|
With no `--embed-cmd`, the server embeds `text` with the built-in embedder
|
|
119
122
|
(v0.15; see "The built-in embedder" below), loaded once at start. On a
|
|
@@ -1001,7 +1004,7 @@ cargo run --bin mnemo -- <command>
|
|
|
1001
1004
|
| `list` | Browse live memories (table / json / jsonl, filters). Since v0.17 private records only with `--visibility private` (or `all`, which marks them `[private]`); `history` takes `--visibility` too |
|
|
1002
1005
|
| `export` | Readable plaintext export (Markdown or JSON Lines, filters); `--git` for diff-clean output. Since v0.17 private records are left out (a stderr line says how many) unless `--visibility all`, which says it included them; `--git` never writes them, nor messages, claims or presence. Since v0.18, `--git` writes the findings (every status, in id order) after the tasks, then the project essence (its open items by section, then those resolved in the last 30 days); it leaves out thread essence, and a `SECURITY` finding until it's `verified`, and its Markdown header says it's the backup and names the build that wrote it. Since v0.18.1 it also leaves out a task whose refs name such a finding |
|
|
1003
1006
|
| `inspect` | Browse the file in a local, read-only web view (memories, keyed history, threads and essence, review findings, tasks, snapshots, about) |
|
|
1004
|
-
| `get` | Fetch one memory by its ULID, with its whole content. `get <ID>` uses the project brain, and `get <PATH> <ID>` a file (v0.16.1) |
|
|
1007
|
+
| `get` | Fetch one memory by its ULID, with its whole content. `get <ID>` uses the project brain, and `get <PATH> <ID>` a file (v0.16.1). Since v0.20.2, `get --key <KEY>` (or `get <PATH> --key <KEY>`) prints a keyed fact's live version the same way, from the slot `history --key` walks (`--agent`, `--shared`), and exits 1 when the key has none |
|
|
1005
1008
|
| `post <TO> <SUBJECT>` | Post a message to an agent (`worker-a`), a role (`role:worker`) or `all`, with `--body`, `--refs`, `--conversation` (a reply). Prints its id and hop count. `--as <agent>` and `--role <role>` say who you are, else `MNEMO_AGENT` and `MNEMO_ROLE`; `--brain <PATH>` for a brain outside the repository (v0.17) |
|
|
1006
1009
|
| `inbox [PATH]` | Your messages (to you, your role or `all`, never your own) not yet acked; `--all` for acked ones too, `--visibility` for private ones; listing marks them seen. `--prune [--days N]` deletes those acked more than 30 (or N) days ago. `--as`, `--role`, `--format` (v0.17) |
|
|
1007
1010
|
| `ack [PATH] <ID>` | Ack a message (`unread` to `acked`), with `--note`; `--as` (v0.17) |
|
|
@@ -1015,8 +1018,10 @@ cargo run --bin mnemo -- <command>
|
|
|
1015
1018
|
| `finding add <ID> --category C --priority P --title T`, `finding triage <ID> --status S --text T`, `finding verify <ID> --ref R`, `finding list`, `finding get <ID>` | v0.18: review findings as records. A Reviewer adds one under an id (`RB-014.1`: capital letters, `-`, a number, `.`, a number; unique) with a category (SECURITY, CORRECTNESS, PERF, PLAN-REFINEMENT, PRODUCT, DX/DOCS), a priority (HIGH, MEDIUM, LOW, IDEA), a title, `--body` and `--ref`s; the Planner triages it (accepted, deferred, rejected, needs-user); a Reviewer verifies it against a commit or tag (a `SECURITY` finding, only a release tag, and it stays `private` until then). A finding changes only by triage and verification: `update`, `forget` and `essence remove` refuse it, and adding one needs an agent. JSON output has its `record_id`. `list` filters by `--status`, `--batch`, `--category` and `--priority`, ordered by id; `--format table\|json\|jsonl`. Kept out of recall, like tasks |
|
|
1016
1019
|
| `default-agent` | Show, set (`--set <id>`) or clear (`--clear`) the agent a write that names none is made for, kept on the manifest (`_mnemo.default_agent`); the CLI and the MCP server use it in place of `default` (v0.17) |
|
|
1017
1020
|
| `search` | Exact nearest-neighbour search (similarity only); no path needed in a git repository (v0.16.1). Since v0.17 it leaves out coordination records, and private ones unless `--visibility` asks |
|
|
1018
|
-
| `recall` | Multi-signal ranked retrieval (sim + recency + …). Since v0.17 private records only with `--visibility private` (or `all`) |
|
|
1019
|
-
| `stale [PATH] [--mine] [--visibility L]` | The stale records, oldest first (private ones only when asked): past their `review_by`, or older than their kind's default (essence `state` and `next` 14 days, `open` 30; an `active` task with no update 3 days, a `blocked` one 7; an unread message 3). `--mine` keeps yours (`--as`, else `MNEMO_AGENT`) (v0.17) |
|
|
1021
|
+
| `recall` | Multi-signal ranked retrieval (sim + recency + …). Since v0.17 private records only with `--visibility private` (or `all`). Since v0.20.2 `--thread <ID>` (MCP `thread`) searches one thread's saved turns, a past session's (`claude-code:<session id>`), as `--filter _mnemo.thread=<ID> --filter _mnemo.kind=turn` does |
|
|
1022
|
+
| `stale [PATH] [--mine] [--visibility L]` | The stale records, oldest first (private ones only when asked): past their `review_by`, or older than their kind's default (essence `state` and `next` 14 days, `open` 30; an `active` task with no update 3 days, a `blocked` one 7; an unread message 3). `--mine` keeps yours (`--as`, else `MNEMO_AGENT`) (v0.17). Since v0.20.2 also the live, unkeyed episodic facts older than 30 days (`unkeyed episodic`), which nothing supersedes on its own; `about` and the session brief don't count those |
|
|
1023
|
+
| `supersede [PATH] <ID> --by <ID\|KEY>` | v0.20.2: mark an unkeyed memory superseded by a newer one (its ULID, or a key's live version), so recall and `about` leave it out as they leave out a keyed fact's older versions. Refuses a keyed memory (its key's next version supersedes it), an engine record (a turn, essence item, task, message or finding) and the manifest; the same again is `unchanged` |
|
|
1024
|
+
| `stats [PATH] [--format table\|json\|jsonl]` | v0.20.2: what the MCP `stats` tool returns: the memory count, the file's size, the dimensions, the index, the snapshots and the page cache |
|
|
1020
1025
|
| `verify` | Decrypt and re-validate every live record; since v0.19.1 it also reads the ANN index and reports it on its own line (a damaged index is a warning: the memories are intact, and `mnemo index --rebuild` repairs it) |
|
|
1021
1026
|
| `rekey` | Re-encrypt the data key under a new passphrase, or a new generated key (`--new-key`, v0.15, kept in the key store); `--rotate` also rewrites the file under a fresh data key (revokes the old secret) |
|
|
1022
1027
|
| `compact` | Rebuild the file, dropping tombstones and expired; writes v9, which converts a v8 (or older) file. Since v0.13 that's the only way to make a v8 file writable again. Since v0.15 it also rebuilds the keyword index with tokenizer 2 |
|
|
@@ -1025,8 +1030,9 @@ cargo run --bin mnemo -- <command>
|
|
|
1025
1030
|
| `embedder status` | The built-in embedder's model, identity and cache, and whether it's installed (v0.15) |
|
|
1026
1031
|
| `snapshots` | List the restorable snapshots (one per flush); no path needed in a git repository (v0.16.1) |
|
|
1027
1032
|
| `restore` | Roll the database back to a past snapshot |
|
|
1033
|
+
| `essence render`, `essence add\|append\|update\|resolve\|remove` | A thread's (`--thread`) or the project's (`--project`) essence: its items by section, within `--budget` bytes (default 6,144). Since v0.20.2 a render that fits shows every item; when it doesn't, each section gets a share plus what the sections before it left unused, and a cut section ends with `+N more (essence render --budget <bytes>)`. Items with the same time sort by id, so renders are byte-identical. `--ids` (MCP `ids: true`) puts each item's id after its status, for `update`, `resolve` and `remove` |
|
|
1028
1034
|
| `thread ingest` | Save a transcript into a thread's archive (idempotent per turn). `--tool-results omit` keeps only `[tool_result ok|error, N bytes]` markers, and `--redact` replaces known secret shapes (private keys, cloud and API tokens, JWTs, recovery codes, secret-looking `NAME=value`s) with `[redacted: <kind>]` (v0.16). A turn of nothing but markers (`[thinking]`, a tool call) is kept, but not embedded or recalled (v0.16.1) |
|
|
1029
|
-
| `onboard` | Set up the project's memory for Claude Code and Cursor: the brain (a generated key in the keychain), the model, the MCP server, the hooks and a skill or rule. Shows the plan and asks once (`--yes`, `--print`); safe to re-run; `--undo` removes what it wrote. `--guide` prints the guide (v0.16). At a terminal (v0.17.1), each item is one line tagged like a boot log (`[ OK ]`, `[ ADDED ]`, `[UPDATED]`, ...), after a plan in the future tense when it asks first, and the guide is a pointer; run by an agent, the output is unchanged. Since v0.17 it writes the per-turn hook too, and `--wake stop` adds the Stop continuation (`--wake off` removes it; a re-run keeps what an earlier one chose) |
|
|
1035
|
+
| `onboard` | Set up the project's memory for Claude Code and Cursor: the brain (a generated key in the keychain), the model, the MCP server, the hooks and a skill or rule. Since v0.20.2, for Claude Code, `permissions.allow` rules in the hooks' settings file for `mnemo wait`, `inbox` and `ack` (bare `mnemo`, `~/...` when it's under the home directory, and in the local scope its absolute path) and `mcp__mnemo__*`, beside the file's other rules in their order; `--undo` removes only those. Shows the plan and asks once (`--yes`, `--print`); safe to re-run; `--undo` removes what it wrote. `--guide` prints the guide (v0.16). At a terminal (v0.17.1), each item is one line tagged like a boot log (`[ OK ]`, `[ ADDED ]`, `[UPDATED]`, ...), after a plan in the future tense when it asks first, and the guide is a pointer; run by an agent, the output is unchanged. Since v0.17 it writes the per-turn hook too, and `--wake stop` adds the Stop continuation (`--wake off` removes it; a re-run keeps what an earlier one chose) |
|
|
1030
1036
|
| `hook` | The hooks `onboard` installs for Claude Code and Cursor (v0.16): `session-start` adds the guide's card, the project's notes and essence, and a short recall to the context (8,000 bytes by default, `--budget` up to 9,000); `pre-compact` and `session-end` save the transcript without tool output and with secrets redacted. Since v0.17, `user-prompt` (Claude Code's `UserPromptSubmit`, Cursor's `postToolUse` at most once a minute) shows what's new for `MNEMO_AGENT`/`MNEMO_ROLE`: unread messages, tasks ready for the role, its task claims about to lapse, after the framing line and escaped, at most 600 bytes, then marks them seen; an unchanged turn reads only the file's first page (no key, no open). `stop` (written by `onboard --wake stop`) keeps an agent going for a pre-approved task or a message to it by id, within the wake-up guardrails, never twice in a row. Always exits 0, never prompts or downloads |
|
|
1031
1037
|
| `wait` | Wait until the brain has work that may wake `MNEMO_AGENT` (a pre-approved task for its role, or a message to it by id, within the wake-up guardrails), mark it delivered, print its ids, senders and task names (never a message's text; `--json` for one object) and exit 0 (v0.20.1). Run it as a background command in Claude Code or Google Antigravity: its exit starts a turn in an idle session, so start it again after every exit 0. It checks the file's first page once a second, holding no lock between checks. Exit 1: it can't wait (no agent, `MNEMO_WAKE=off`, no usable key, an old format, a refused network or synced folder, a missing file); 3: `--timeout` passed; 4: a newer `mnemo wait` for the agent took over, or the process that started it is gone. Delivery is at most once |
|
|
1032
1038
|
| `wake pause\|resume\|status` | The wake-up kill switch for every session of the brain (on the manifest). Paused, nothing wakes an agent (`MNEMO_WAKE=off` does it for one session); the per-turn hook and the brief still show its work. `status` also shows the `crossSessionInbound` settings it finds (keep `accept`). The guardrails: 12 wake-ups per agent an hour, 60 s apart, none for a burst of 8 messages between two agents in 10 minutes or an explicit reply past 8 hops (v0.17) |
|
|
@@ -12,7 +12,8 @@ matches the version you run: `mnemo onboard --guide` prints it.
|
|
|
12
12
|
project essence with `essence` (`op: "render"`, `project: true`).
|
|
13
13
|
- **When something will matter later** (a decision, a fact, a
|
|
14
14
|
convention, a fix that worked), call `remember`. When it replaces an
|
|
15
|
-
earlier version, give it a `key`, like `decision.release-order
|
|
15
|
+
earlier version, give it a `key`, like `decision.release-order`;
|
|
16
|
+
`get` with that `key` reads its current version.
|
|
16
17
|
- **During a long task,** keep the state with `essence`: `add` to the
|
|
17
18
|
`decisions`, `open` or `next` sections, `resolve` when done.
|
|
18
19
|
- **Never store secrets:** keys, tokens, passwords, recovery codes.
|
|
@@ -51,7 +52,9 @@ mnemo onboard --yes
|
|
|
51
52
|
- It downloads the built-in embedding model (91 MB, checked against
|
|
52
53
|
pinned SHA-256 hashes).
|
|
53
54
|
- It connects Claude Code and Cursor: the MCP server, the hooks that load
|
|
54
|
-
and save memory, and a rule file with the card above.
|
|
55
|
+
and save memory, and a rule file with the card above. For Claude Code it
|
|
56
|
+
also allows `mnemo wait`, `inbox` and `ack` and the mnemo MCP tools to
|
|
57
|
+
run without asking, so an idle session can wait for work.
|
|
55
58
|
- It prints this guide.
|
|
56
59
|
|
|
57
60
|
Without a terminal, `mnemo onboard` only shows what it would write. Run
|
|
@@ -94,6 +97,7 @@ one brain. `onboard` starts it for your client. The tools you'll use most:
|
|
|
94
97
|
| `about` | The brain's briefing: what it is, its conventions, the project essence |
|
|
95
98
|
| `recall` | The memories most relevant to a question |
|
|
96
99
|
| `remember` | Store a memory. With `key`, replace the earlier version |
|
|
100
|
+
| `get` | One memory, by `id`, or a key's current version by `key` |
|
|
97
101
|
| `history` | Every version of a key, newest first |
|
|
98
102
|
| `essence` | The working state of a task or the project: add, resolve, render |
|
|
99
103
|
| `forget` | Delete a memory by id |
|
|
@@ -127,10 +131,17 @@ a decision, a preference.
|
|
|
127
131
|
{"name": "remember", "arguments": {"content": "Releases are cut from the release branch, then main is fast-forwarded at the tag.", "memory_type": "procedural", "key": "process.release-branch"}}
|
|
128
132
|
```
|
|
129
133
|
|
|
134
|
+
```json mcp model
|
|
135
|
+
{"name": "get", "arguments": {"key": "process.release-branch"}}
|
|
136
|
+
```
|
|
137
|
+
|
|
130
138
|
```json mcp model
|
|
131
139
|
{"name": "history", "arguments": {"key": "process.release-branch"}}
|
|
132
140
|
```
|
|
133
141
|
|
|
142
|
+
`get` returns the current version alone; `history` returns every version,
|
|
143
|
+
newest first.
|
|
144
|
+
|
|
134
145
|
Good keys are short and stable: `decision.<topic>`, `status.<thing>`,
|
|
135
146
|
`convention.<topic>`, `user.<preference>`.
|
|
136
147
|
|
|
@@ -166,11 +177,21 @@ Add an item when a goal, a decision, an open problem or the next step
|
|
|
166
177
|
appears. `resolve` an item when it's done. Don't rewrite the essence as a
|
|
167
178
|
whole; change one item at a time.
|
|
168
179
|
|
|
180
|
+
A render that fits its `budget` shows every item. When it doesn't, a
|
|
181
|
+
section that's cut ends with `+N more`; render again with a bigger
|
|
182
|
+
budget. To change an item, render with `ids: true`, which puts each
|
|
183
|
+
item's id after its status, then `update` or `resolve` that id.
|
|
184
|
+
|
|
185
|
+
```json mcp
|
|
186
|
+
{"name": "essence", "arguments": {"op": "render", "project": true, "ids": true}}
|
|
187
|
+
```
|
|
188
|
+
|
|
169
189
|
From a shell:
|
|
170
190
|
|
|
171
191
|
```sh test
|
|
172
192
|
mnemo essence add --project --section open --text "The flaky upload test needs a fix."
|
|
173
193
|
mnemo essence render --project --budget 2000
|
|
194
|
+
mnemo essence render --project --ids
|
|
174
195
|
```
|
|
175
196
|
|
|
176
197
|
### Threads
|
|
@@ -191,11 +212,25 @@ for them. Add the turn filter:
|
|
|
191
212
|
mnemo recall --text "where the parser bug was" --top-k 5 --filter _mnemo.kind=turn
|
|
192
213
|
```
|
|
193
214
|
|
|
194
|
-
To search one session only,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
215
|
+
To search one session only, give its thread, `claude-code:<session id>`
|
|
216
|
+
(the essence render's footer and the compaction note name it):
|
|
217
|
+
|
|
218
|
+
```json mcp model
|
|
219
|
+
{"name": "recall", "arguments": {"text": "where the parser bug was", "top_k": 5, "thread": "claude-code:s1"}}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
```sh test model
|
|
223
|
+
mnemo recall --text "where the parser bug was" --top-k 5 --thread claude-code:s1
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Turns are found by meaning, not by keyword (they aren't in the keyword
|
|
227
|
+
index), so this needs the built-in model. The hooks save turns only when
|
|
228
|
+
the model is there anyway.
|
|
229
|
+
|
|
230
|
+
**Keep a task's state in its thread.** `essence` `add` with `thread` (the
|
|
231
|
+
`state`, `next` or `open` section) keeps where this task stands. When the
|
|
232
|
+
session resumes or its context is compacted, the brief shows the thread's
|
|
233
|
+
own items again.
|
|
199
234
|
|
|
200
235
|
### Budgets
|
|
201
236
|
|
|
@@ -233,6 +268,7 @@ Every tool has a command. A few you'll use:
|
|
|
233
268
|
```sh test model
|
|
234
269
|
mnemo remember --text "The staging database is reset every Monday." --type semantic --key fact.staging-reset
|
|
235
270
|
mnemo recall --text "when is staging reset" --top-k 3
|
|
271
|
+
mnemo get --key fact.staging-reset
|
|
236
272
|
mnemo history --key fact.staging-reset
|
|
237
273
|
```
|
|
238
274
|
|
|
@@ -489,4 +525,10 @@ reads them, and their history stays.
|
|
|
489
525
|
- **Freshness:** `--review-by 30d` on `remember` asks for a look later.
|
|
490
526
|
`mnemo stale` lists what's past its date, or older than its kind allows
|
|
491
527
|
(a `state` item after 14 days, a task with no update after 3, an unread
|
|
492
|
-
message after 3), and `about` marks them `[stale since <date>]`.
|
|
528
|
+
message after 3), and `about` marks them `[stale since <date>]`. It also
|
|
529
|
+
lists dated facts written without a key that are over 30 days old: a
|
|
530
|
+
keyed fact's newer version replaces the old one, but these stay in
|
|
531
|
+
recall until you retire one.
|
|
532
|
+
- **Retire an old fact:** `mnemo supersede <old id> --by <newer id or
|
|
533
|
+
key>` marks a fact written without a key as replaced, so recall leaves
|
|
534
|
+
it out, as it leaves out a keyed fact's older versions.
|
|
@@ -558,13 +558,13 @@ pub fn session_start(o: &Opts, input: &Value) -> String {
|
|
|
558
558
|
.unwrap_or_default();
|
|
559
559
|
}
|
|
560
560
|
parts.push(("Project essence", guide::escape_brain(essence.trim())));
|
|
561
|
-
// 4. The session thread's essence, on resume and compact
|
|
561
|
+
// 4. The session thread's own essence, on resume and compact, when
|
|
562
|
+
// it has items (v0.20.2, G2: not the project items again, which a
|
|
563
|
+
// thread render also shows).
|
|
562
564
|
let mut t4 = String::new();
|
|
563
565
|
if let (true, Some(t)) = (resume, &thread) {
|
|
564
|
-
if let Ok(r) = db.
|
|
565
|
-
|
|
566
|
-
t4 = guide::escape_brain(r.trim());
|
|
567
|
-
}
|
|
566
|
+
if let Ok(Some(r)) = db.essence_own(t, room.max(256)) {
|
|
567
|
+
t4 = guide::escape_brain(r.trim());
|
|
568
568
|
}
|
|
569
569
|
}
|
|
570
570
|
parts.push(("This session's thread", t4));
|
|
@@ -1320,10 +1320,12 @@ fn stop(o: &Opts, input: &Value) {
|
|
|
1320
1320
|
/// Claude Code's compaction instructions (its PreCompact stdout).
|
|
1321
1321
|
pub fn compact_instructions(client: Client, id: &str) -> String {
|
|
1322
1322
|
let t = format!(
|
|
1323
|
-
"Keep in the summary: this session's earlier turns are saved in mnemo as thread `{}`; \
|
|
1324
|
-
|
|
1325
|
-
fact or decision from this part of the session with `remember` and a `key
|
|
1326
|
-
|
|
1323
|
+
"Keep in the summary: this session's earlier turns are saved in mnemo as thread `{t}`; \
|
|
1324
|
+
`recall` with `thread: \"{t}\"` brings them back. Before going on, save any durable \
|
|
1325
|
+
fact or decision from this part of the session with `remember` and a `key`, and keep \
|
|
1326
|
+
this task's state with `essence` `add` (`thread: \"{t}\"`, section `state`, `next` or \
|
|
1327
|
+
`open`), so it comes back after compaction.\n",
|
|
1328
|
+
t = thread_id(client, id)
|
|
1327
1329
|
);
|
|
1328
1330
|
fit_plain(&t, COMPACT_MAX)
|
|
1329
1331
|
}
|
|
@@ -1606,6 +1608,19 @@ mod tests {
|
|
|
1606
1608
|
let t = compact_instructions(Client::ClaudeCode, &"x".repeat(128));
|
|
1607
1609
|
assert!(t.len() <= COMPACT_MAX, "{}", t.len());
|
|
1608
1610
|
assert!(t.contains("claude-code:"));
|
|
1611
|
+
// v0.20.2 (G2): with a session id's usual length, the whole text,
|
|
1612
|
+
// the thread's essence included.
|
|
1613
|
+
let id = "0f9e8d7c-6b5a-4938-a7b6-c5d4e3f2a1b0";
|
|
1614
|
+
let t = compact_instructions(Client::ClaudeCode, id);
|
|
1615
|
+
assert!(t.ends_with("so it comes back after compaction.\n"), "{t}");
|
|
1616
|
+
assert!(
|
|
1617
|
+
t.contains(&format!("`essence` `add` (`thread: \"claude-code:{id}\"`")),
|
|
1618
|
+
"{t}"
|
|
1619
|
+
);
|
|
1620
|
+
assert!(
|
|
1621
|
+
t.contains(&format!("`recall` with `thread: \"claude-code:{id}\"`")),
|
|
1622
|
+
"{t}"
|
|
1623
|
+
);
|
|
1609
1624
|
}
|
|
1610
1625
|
|
|
1611
1626
|
#[test]
|
|
@@ -352,6 +352,137 @@ pub fn is_our_server(entry: &Value) -> bool {
|
|
|
352
352
|
is_mnemo(program) && serve
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
+
/// v0.20.2 (v0202-4o): the commands a session runs while it waits for
|
|
356
|
+
/// work, which Claude Code may run without asking. Each writes only the
|
|
357
|
+
/// brain.
|
|
358
|
+
const ALLOWED_COMMANDS: [&str; 3] = ["wait", "inbox", "ack"];
|
|
359
|
+
|
|
360
|
+
/// v0.20.2: every tool of the mnemo MCP server (`mcp__<server>__*`).
|
|
361
|
+
const MCP_RULE: &str = "mcp__mnemo__*";
|
|
362
|
+
|
|
363
|
+
/// v0.20.2 (v0202-4o): the Claude Code `permissions.allow` rules `onboard`
|
|
364
|
+
/// writes. A Bash rule matches the command as written, so each command gets
|
|
365
|
+
/// one rule per way a session spells the program: bare `mnemo` (on the
|
|
366
|
+
/// PATH), `~/...` when the binary is under the home directory, and (local
|
|
367
|
+
/// scope only, since a project's settings are committed) its absolute path.
|
|
368
|
+
fn allow_rules(ctx: &Ctx) -> Vec<String> {
|
|
369
|
+
// As a session types it: plain when the shell needs no quotes.
|
|
370
|
+
let plain = |p: &str| {
|
|
371
|
+
p.chars()
|
|
372
|
+
.all(|c| c.is_ascii_alphanumeric() || "/._-+~:\\".contains(c))
|
|
373
|
+
};
|
|
374
|
+
let mut programs = vec!["mnemo".to_string()];
|
|
375
|
+
let exe = Path::new(&ctx.exe);
|
|
376
|
+
// `exe` is canonical; `HOME` may not be (macOS's `/var` is `/private/var`).
|
|
377
|
+
let home = std::fs::canonicalize(&ctx.home).unwrap_or_else(|_| ctx.home.clone());
|
|
378
|
+
if let Ok(rest) = exe
|
|
379
|
+
.strip_prefix(&home)
|
|
380
|
+
.or_else(|_| exe.strip_prefix(&ctx.home))
|
|
381
|
+
{
|
|
382
|
+
// A quoted `~` doesn't expand, so a path that needs quotes has no
|
|
383
|
+
// `~` form.
|
|
384
|
+
if let Some(r) = rest.to_str().filter(|r| plain(r)) {
|
|
385
|
+
programs.push(format!("~/{}", r.replace('\\', "/")));
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if ctx.scope == Scope::Local {
|
|
389
|
+
programs.push(if plain(&ctx.exe) {
|
|
390
|
+
ctx.exe.clone()
|
|
391
|
+
} else {
|
|
392
|
+
quote(&ctx.exe)
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
programs.dedup();
|
|
396
|
+
let mut out: Vec<String> = programs
|
|
397
|
+
.iter()
|
|
398
|
+
.flat_map(|p| {
|
|
399
|
+
ALLOWED_COMMANDS
|
|
400
|
+
.iter()
|
|
401
|
+
.map(move |c| format!("Bash({p} {c} *)"))
|
|
402
|
+
})
|
|
403
|
+
.collect();
|
|
404
|
+
out.push(MCP_RULE.to_string());
|
|
405
|
+
out
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/// Whether a `permissions.allow` rule is one `onboard` writes: the mnemo MCP
|
|
409
|
+
/// server's wildcard, or a Bash rule for `mnemo` (any directory, `~` too)
|
|
410
|
+
/// running `wait`, `inbox` or `ack`.
|
|
411
|
+
pub fn is_our_rule(rule: &str) -> bool {
|
|
412
|
+
if rule == MCP_RULE {
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
let Some(inner) = rule.strip_prefix("Bash(").and_then(|r| r.strip_suffix(')')) else {
|
|
416
|
+
return false;
|
|
417
|
+
};
|
|
418
|
+
let (program, rest) = first_word(inner);
|
|
419
|
+
is_mnemo(&program)
|
|
420
|
+
&& ALLOWED_COMMANDS
|
|
421
|
+
.iter()
|
|
422
|
+
.any(|c| rest.trim_start() == format!("{c} *"))
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/// The `permissions` member's text with our allow rules removed, then (when
|
|
426
|
+
/// `add`) ours appended; its other members, and the other rules, in their
|
|
427
|
+
/// order. `None` when nothing is left.
|
|
428
|
+
fn with_allow_rules(perms: Option<&str>, add: &[String]) -> Result<Option<String>, String> {
|
|
429
|
+
let mut m = match perms {
|
|
430
|
+
Some(t) => members(t)?,
|
|
431
|
+
None => Vec::new(),
|
|
432
|
+
};
|
|
433
|
+
let i = m.iter().position(|(k, _)| k == "allow");
|
|
434
|
+
let mut allow: Vec<Value> = match i {
|
|
435
|
+
Some(i) => serde_json::from_str::<Vec<Value>>(&m[i].1)
|
|
436
|
+
.map_err(|_| "permissions.allow isn't a list; left alone".to_string())?,
|
|
437
|
+
None => Vec::new(),
|
|
438
|
+
};
|
|
439
|
+
allow.retain(|r| !r.as_str().is_some_and(is_our_rule));
|
|
440
|
+
for r in add {
|
|
441
|
+
let v = Value::String(r.clone());
|
|
442
|
+
if !allow.contains(&v) {
|
|
443
|
+
allow.push(v);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
let text = (!allow.is_empty()).then(|| mi::pretty_at(&Value::Array(allow), 2));
|
|
447
|
+
match (i, text) {
|
|
448
|
+
(Some(i), Some(t)) => m[i].1 = t,
|
|
449
|
+
(Some(i), None) => {
|
|
450
|
+
m.remove(i);
|
|
451
|
+
}
|
|
452
|
+
(None, Some(t)) => m.push(("allow".into(), t)),
|
|
453
|
+
(None, None) => {}
|
|
454
|
+
}
|
|
455
|
+
Ok((!m.is_empty()).then(|| mi::write_object(&m, 1)))
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/// Our allow rules in a `permissions` member's text.
|
|
459
|
+
fn our_rules(perms: Option<&str>) -> Vec<String> {
|
|
460
|
+
perms
|
|
461
|
+
.and_then(|t| member(t, "allow").ok().flatten())
|
|
462
|
+
.and_then(|v| v.as_array().cloned())
|
|
463
|
+
.unwrap_or_default()
|
|
464
|
+
.iter()
|
|
465
|
+
.filter_map(Value::as_str)
|
|
466
|
+
.filter(|r| is_our_rule(r))
|
|
467
|
+
.map(str::to_string)
|
|
468
|
+
.collect()
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/// The text with `key`'s member set to `raw` (a value's JSON text, added
|
|
472
|
+
/// last if new), or removed with `None`.
|
|
473
|
+
fn set_member_raw(old: &str, key: &str, raw: Option<String>) -> Result<String, String> {
|
|
474
|
+
let mut m = members(old)?;
|
|
475
|
+
match (m.iter().position(|(k, _)| k == key), raw) {
|
|
476
|
+
(Some(i), Some(v)) => m[i].1 = v,
|
|
477
|
+
(Some(i), None) => {
|
|
478
|
+
m.remove(i);
|
|
479
|
+
}
|
|
480
|
+
(None, Some(v)) => m.push((key.to_string(), v)),
|
|
481
|
+
(None, None) => {}
|
|
482
|
+
}
|
|
483
|
+
Ok(format!("{}\n", mi::write_object(&m, 0)))
|
|
484
|
+
}
|
|
485
|
+
|
|
355
486
|
// --- JSON edits ----------------------------------------------------------------
|
|
356
487
|
|
|
357
488
|
/// The top-level members of a JSON object's text (an empty text is `{}`).
|
|
@@ -717,6 +848,31 @@ fn plan_hooks_file(ctx: &Ctx, client: Client, path: &Path, undo: bool, items: &m
|
|
|
717
848
|
Ok(t) => t,
|
|
718
849
|
Err(e) => return items.push(Item::Failed(format!("{label}: {e}"))),
|
|
719
850
|
};
|
|
851
|
+
// v0.20.2 (v0202-4o): Claude Code's allow rules for the wake commands,
|
|
852
|
+
// in the same file.
|
|
853
|
+
let perms_old: Option<String> = match members(&text) {
|
|
854
|
+
Ok(m) => m
|
|
855
|
+
.into_iter()
|
|
856
|
+
.find(|(k, _)| k == "permissions")
|
|
857
|
+
.map(|(_, v)| v),
|
|
858
|
+
Err(e) => return items.push(Item::Failed(format!("{label}: {e}"))),
|
|
859
|
+
};
|
|
860
|
+
let rules = if client == Client::ClaudeCode && !undo {
|
|
861
|
+
allow_rules(ctx)
|
|
862
|
+
} else {
|
|
863
|
+
Vec::new()
|
|
864
|
+
};
|
|
865
|
+
let had_rules = our_rules(perms_old.as_deref());
|
|
866
|
+
if client == Client::ClaudeCode {
|
|
867
|
+
let perms_new = match with_allow_rules(perms_old.as_deref(), &rules) {
|
|
868
|
+
Ok(p) => p,
|
|
869
|
+
Err(e) => return items.push(Item::Failed(format!("{label}: {e}"))),
|
|
870
|
+
};
|
|
871
|
+
new = match set_member_raw(&new, "permissions", perms_new) {
|
|
872
|
+
Ok(t) => t,
|
|
873
|
+
Err(e) => return items.push(Item::Failed(format!("{label}: {e}"))),
|
|
874
|
+
};
|
|
875
|
+
}
|
|
720
876
|
if client == Client::Cursor && !undo && member(&new, "version").ok().flatten().is_none() {
|
|
721
877
|
// Cursor's hooks.json starts with its version.
|
|
722
878
|
let mut m = members(&new).unwrap_or_default();
|
|
@@ -724,7 +880,7 @@ fn plan_hooks_file(ctx: &Ctx, client: Client, path: &Path, undo: bool, items: &m
|
|
|
724
880
|
new = format!("{}\n", mi::write_object(&m, 0));
|
|
725
881
|
}
|
|
726
882
|
if undo {
|
|
727
|
-
if hooks == member(&new, "hooks").ok().flatten() {
|
|
883
|
+
if hooks == member(&new, "hooks").ok().flatten() && had_rules.is_empty() {
|
|
728
884
|
return;
|
|
729
885
|
}
|
|
730
886
|
// Cursor's version alone left: the file was ours.
|
|
@@ -736,23 +892,65 @@ fn plan_hooks_file(ctx: &Ctx, client: Client, path: &Path, undo: bool, items: &m
|
|
|
736
892
|
} else {
|
|
737
893
|
new
|
|
738
894
|
};
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
895
|
+
let (mut shown, mut tty) = (String::new(), Vec::new());
|
|
896
|
+
if hooks != member(&new, "hooks").ok().flatten() {
|
|
897
|
+
shown.push_str("- mnemo's hooks\n");
|
|
898
|
+
tty.push((Mark::Remove, format!("mnemo's hooks ({label})")));
|
|
899
|
+
}
|
|
900
|
+
if !had_rules.is_empty() {
|
|
901
|
+
shown.push_str(&format!(
|
|
902
|
+
"- mnemo's {} permissions.allow rules\n",
|
|
903
|
+
had_rules.len()
|
|
904
|
+
));
|
|
905
|
+
tty.push((Mark::Remove, format!("mnemo's allow rules ({label})")));
|
|
906
|
+
}
|
|
907
|
+
items.push(remove_or_write(path, old, new, shown, tty));
|
|
746
908
|
return;
|
|
747
909
|
}
|
|
748
910
|
if old.as_deref() == Some(new.as_str()) {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
911
|
+
let (line, what) = if client == Client::ClaudeCode {
|
|
912
|
+
(
|
|
913
|
+
format!("{label}: the hooks and allow rules are already right"),
|
|
914
|
+
format!(
|
|
915
|
+
"{} and {} allow rules",
|
|
916
|
+
hooks_count(ours.len()),
|
|
917
|
+
rules.len()
|
|
918
|
+
),
|
|
919
|
+
)
|
|
920
|
+
} else {
|
|
921
|
+
(
|
|
922
|
+
format!("{label}: the hooks are already right"),
|
|
923
|
+
hooks_count(ours.len()),
|
|
924
|
+
)
|
|
925
|
+
};
|
|
926
|
+
return items.push(Item::Ok { line, what });
|
|
927
|
+
}
|
|
928
|
+
let mut shown = shown_hooks(&hooks, &ours);
|
|
929
|
+
let mut tty = hook_changes(&hooks, &ours, &label);
|
|
930
|
+
if client == Client::ClaudeCode {
|
|
931
|
+
let added: Vec<&String> = rules.iter().filter(|r| !had_rules.contains(r)).collect();
|
|
932
|
+
let gone = had_rules.iter().filter(|r| !rules.contains(r)).count();
|
|
933
|
+
for r in &added {
|
|
934
|
+
shown.push_str(&format!("+ permissions.allow: {r}\n"));
|
|
935
|
+
}
|
|
936
|
+
if gone > 0 {
|
|
937
|
+
shown.push_str(&format!("- {gone} older mnemo allow rule(s)\n"));
|
|
938
|
+
}
|
|
939
|
+
if !added.is_empty() || gone > 0 {
|
|
940
|
+
// The rules are the change, not "the file".
|
|
941
|
+
tty.retain(|(m, l)| !(*m == Mark::Change && *l == label));
|
|
942
|
+
tty.push((
|
|
943
|
+
if had_rules.is_empty() {
|
|
944
|
+
Mark::Add
|
|
945
|
+
} else {
|
|
946
|
+
Mark::Change
|
|
947
|
+
},
|
|
948
|
+
format!("allow rules for mnemo wait, inbox, ack and its MCP tools ({label})"),
|
|
949
|
+
));
|
|
950
|
+
} else {
|
|
951
|
+
tty.push((Mark::Same, format!("{} allow rules", rules.len())));
|
|
952
|
+
}
|
|
753
953
|
}
|
|
754
|
-
let shown = shown_hooks(&hooks, &ours);
|
|
755
|
-
let tty = hook_changes(&hooks, &ours, &label);
|
|
756
954
|
items.push(Item::Write {
|
|
757
955
|
path: path.to_path_buf(),
|
|
758
956
|
old,
|
|
@@ -2252,6 +2450,33 @@ fn trust_step(ctx: &Ctx, clients: &[Client]) -> Option<String> {
|
|
|
2252
2450
|
mod tests {
|
|
2253
2451
|
use super::*;
|
|
2254
2452
|
|
|
2453
|
+
#[test]
|
|
2454
|
+
fn our_allow_rules_and_no_others() {
|
|
2455
|
+
for ours in [
|
|
2456
|
+
"mcp__mnemo__*",
|
|
2457
|
+
"Bash(mnemo wait *)",
|
|
2458
|
+
"Bash(~/.local/bin/mnemo inbox *)",
|
|
2459
|
+
"Bash(/opt/x/mnemo ack *)",
|
|
2460
|
+
"Bash(\"/a b/mnemo\" wait *)",
|
|
2461
|
+
"Bash(C:\\tools\\mnemo.exe wait *)",
|
|
2462
|
+
] {
|
|
2463
|
+
assert!(is_our_rule(ours), "{ours}");
|
|
2464
|
+
}
|
|
2465
|
+
for theirs in [
|
|
2466
|
+
"mcp__mnemo__recall",
|
|
2467
|
+
"mcp__other__*",
|
|
2468
|
+
"Bash(mnemo post *)",
|
|
2469
|
+
"Bash(mnemo wait)",
|
|
2470
|
+
"Bash(mnemo wait --as worker-a)",
|
|
2471
|
+
"Bash(mnemo *)",
|
|
2472
|
+
"Bash(notmnemo wait *)",
|
|
2473
|
+
"Bash(npm run *)",
|
|
2474
|
+
"Read(./mnemo wait *)",
|
|
2475
|
+
] {
|
|
2476
|
+
assert!(!is_our_rule(theirs), "{theirs}");
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2255
2480
|
#[test]
|
|
2256
2481
|
fn our_hooks_and_servers_are_recognised_in_both_forms() {
|
|
2257
2482
|
for c in [
|