create-ai-memory 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -189,8 +189,10 @@ off last time.
189
189
  **Getting started**
190
190
 
191
191
  - [Quickstart](#quickstart)
192
+ - [Benchmarks](#benchmarks)
192
193
  - [Install](#install)
193
194
  - [Commands](#commands)
195
+ - [How search works](#how-search-works)
194
196
 
195
197
  </td>
196
198
  <td valign="top" width="33%">
@@ -199,8 +201,11 @@ off last time.
199
201
 
200
202
  - [Session skills](#session-skills-optional)
201
203
  - [Your vault](#your-vault)
204
+ - [Open Knowledge Format](#open-knowledge-format)
202
205
  - [Add another agent](#add-another-agent)
203
206
  - [Integrations](#integrations)
207
+ - [Graph view](#graph-view)
208
+ - [GUI clients (MCP)](#gui-clients-mcp)
204
209
  - [Configuration](#configuration)
205
210
 
206
211
  </td>
@@ -223,7 +228,7 @@ off last time.
223
228
 
224
229
  | | |
225
230
  |---|---|
226
- | **Cross-agent memory** | One vault serves Claude Code, Codex, Gemini, Cursor, and opencode. Context earned in one reaches the next. |
231
+ | **Cross-agent memory** | One vault serves Claude Code, Codex, Gemini, Cursor, and opencode — and GUI clients like Claude Desktop through an MCP server. Context earned in one reaches the next. |
227
232
  | **Automatic carryover** | A Stop hook writes the branch, the commits you made, and uncommitted changes into the session log, so tomorrow's run resumes where today's ended. |
228
233
  | **Per-project context** | Each git repo gets its own note for purpose, architecture, and decisions, injected only for that project. |
229
234
  | **Your rules, everywhere** | A global profile and standards note ride along in every session, on every project. |
@@ -233,6 +238,60 @@ off last time.
233
238
  | **Guardrails built in** | Every write is checked to stay inside the vault, and a commit hook refuses commits made without the vault context loaded. |
234
239
  | **Zero runtime deps** | No daemon, no database, no API key, no server. It runs in your shell. |
235
240
 
241
+ ## Benchmarks
242
+
243
+ Measured on a real 495-note vault (4.9 MB of Markdown), macOS, warm cache.
244
+ Every number below is reproducible with the command beside it.
245
+
246
+ **Tokens** — what the agent pays, every session
247
+
248
+ | | before | after | |
249
+ |---|---|---|---|
250
+ | Launch prompt | 7,207 | **4,321** | −40%, mirrored notes injected once ([why](#mirrored-notes-are-not-injected-twice)) |
251
+ | Search result, common term | 10,234 | **1,752** | −83%, bounded output ([why](#how-search-works)) |
252
+ | Lesson index, 96 lessons | — | **+829** | ~8 tokens per lesson, names only ([why](#lessons-are-indexed-not-injected)) |
253
+
254
+ ```sh
255
+ # launch prompt
256
+ ai-context | wc -c # chars; divide by ~4 for tokens
257
+ # search output, bounded vs not
258
+ ai-mem-search postgres | wc -c
259
+ AI_MEM_SEARCH_LIMIT=999999 ai-mem-search postgres | wc -c
260
+ ```
261
+
262
+ **Speed**
263
+
264
+ | | |
265
+ |---|---|
266
+ | Search, common term, 238 hits | **0.07 s** |
267
+ | Shell startup cost of the module | **< 0.01 s** |
268
+ | Recency sort, v0.11.0 regression fix | 25.4 s → **0.54 s** (47×) |
269
+
270
+ ```sh
271
+ time ai-mem-search postgres >/dev/null
272
+ time zsh -c 'source shell/ai-mem.zsh'
273
+ ```
274
+
275
+ The 47× is worth stating plainly because it was self-inflicted. The sort
276
+ spawned two subprocesses per matched line -- about 18,000 processes for one
277
+ query -- while the `grep` underneath it took 0.16 s. Benchmarking `grep`
278
+ alone said the command was fast; benchmarking the command said otherwise.
279
+ A regression guard now bounds it, with the bound set by measuring both
280
+ implementations rather than guessing.
281
+
282
+ **Footprint**
283
+
284
+ | | |
285
+ |---|---|
286
+ | Runtime dependencies | **0** |
287
+ | Package | **35 kB** (99.7 kB unpacked, 19 files) |
288
+ | Index, daemon, database, embeddings | **none** — a note is searchable the moment it is written |
289
+ | Tests | **153**, no network, no framework |
290
+
291
+ ```sh
292
+ npm pack --dry-run && zsh tests/run.sh
293
+ ```
294
+
236
295
  ## Install
237
296
 
238
297
  Pick whichever fits how you manage your shell. All paths end at the same place.
@@ -275,12 +334,188 @@ optional. Set `AI_MEM_ROOT` in `~/.zshrc` first if you do not want the default
275
334
  | `ai-context [project]` | Print the vault context block for the current repo, and arm the git commit guard |
276
335
  | `ai-note <text>` | Append a timestamped note to today's session log while you work |
277
336
  | `ai-lesson <topic-slug> <problem> <solution>` | Append a dated Problem/Solution entry to a cross-project `_lessons/<topic-slug>.md` -- decisions, mistakes, solutions worth recalling outside the current project |
278
- | `ai-mem-lint` | Check the vault's links: orphaned session logs, dangling `previous` links, unreferenced project notes |
337
+ | `ai-mem-lint [--fix]` | Check the vault's links: orphaned session logs, dangling `previous` links, unreferenced project notes, and notes missing the `type:` field. `--fix` backfills `type:` into session logs written before the field existed |
279
338
  | `ai-mem-search <term> [project]` | Case-insensitive literal search across the vault (or one project's logs), newest match first. Paths print relative to a root stated once in the header. Output is capped (`AI_MEM_SEARCH_LIMIT`, default 40) with an explicit `N hidden` notice, because the usual caller is an agent with a finite context window. Also resolves any `[[wikilink]]` on a matched line to its project note -- one hop out along the graph, always on, not a flag to remember |
339
+ | `ai-mem-serve [port] [--no-open]` | Open the vault as a browsable graph on `127.0.0.1`. Agents run this for you when you ask to see your memory (see [Graph view](#graph-view)) |
280
340
  | `ai-mem-vault-backup` | Commit and push the vault if it's git-backed. `ai-note`/`ai-lesson` already call this; use it directly after editing a session log or project note by hand |
281
341
 
282
342
  Project is auto-resolved from the current git repo; pass a name to override.
283
343
 
344
+ ## How search works
345
+
346
+ Searching the vault reads your notes directly, every time. Nothing is
347
+ prepared in advance: no index to rebuild, no background service, no
348
+ embeddings to regenerate, nothing that can quietly fall out of date. A note
349
+ is findable the second you write it.
350
+
351
+ ```mermaid
352
+ flowchart TD
353
+ A(["You look for a word"]) --> B{"Did you name<br/>a project?"}
354
+ B -->|"no"| C["Look through<br/>every note you have"]
355
+ B -->|"yes"| D["Look only inside<br/>that project"]
356
+ C --> E["Read them all.<br/>Capitals don't matter.<br/>Punctuation means itself."]
357
+ D --> E
358
+ E -->|"found nothing"| F["<b>Says so, plainly.</b><br/>Never a blank screen you<br/>could mistake for 'none exist'"]
359
+ E -->|"found something"| G["Newest first"]
360
+ G --> H["Show the first 40<br/>and say how many more there are"]
361
+ H --> I["Follow any linked note one step,<br/>with a one-line summary of it"]
362
+ I --> J(["What you read"])
363
+
364
+ classDef ask fill:#0d9488,stroke:#0f766e,color:#fff
365
+ classDef care fill:#b45309,stroke:#92400e,color:#fff
366
+ classDef done fill:#1e3a8a,stroke:#1e40af,color:#fff
367
+ class A ask
368
+ class F care
369
+ class J done
370
+ ```
371
+
372
+ Two boxes are shaded because they are the ones that matter: an empty result
373
+ that **says** it is empty, and an output short enough to read to the end.
374
+
375
+ That is the whole idea. The rest of this section is the mechanism -- one
376
+ `grep -rniF`, then a sort, then a cap -- and why each piece is the way it is.
377
+ Every flag exists because the alternative produced a wrong answer on a real
378
+ vault. Skip it unless you are changing the code.
379
+
380
+ ```console
381
+ $ ai-mem-search prisma
382
+ 238 match(es) for 'prisma'
383
+ paths below /Users/you/_Ai_Memory
384
+ --
385
+ _session_logs/checkout-api/checkout-api-2026-08-31_00-00-00.md:56: - **A green deploy log is not evidence a migration ran.** Verify against `_prisma_migrations`.
386
+ _session_logs/checkout-api/checkout-api-2026-08-31_00-00-00.md:55: - **`prisma migrate deploy` cannot see `prisma/migrations/<name>.sql`.** Only `<name>/migration.sql`. It skips loose files silently -- a [...]
387
+ ...
388
+ --
389
+ showing 40 of 238 (198 hidden) -- narrow with: ai-mem-search 'prisma' <project>, or raise AI_MEM_SEARCH_LIMIT
390
+ ```
391
+
392
+ **Case-insensitive (`-i`).** A false empty state is the worst answer a memory
393
+ tool can give, because it is indistinguishable from the truth -- and the
394
+ explicit `no matches` message is exactly what makes it look authoritative.
395
+ Measured on a real vault: `precompact` found 0 matches case-sensitively and 3
396
+ with `-i`; `Postgres` found 56 versus 90.
397
+
398
+ **Literal, not regex (`-F`).** The caller is usually an agent passing free
399
+ text, where a stray `.`, `(` or `|` must match itself. `ai-mem-search .env`
400
+ finds `.env`, not every four-character string ending in `env`.
401
+
402
+ **Newest first.** The sort key is the `YYYY-MM-DD_HH-MM-SS` embedded in the
403
+ log filename. For a time series the most recent match is usually the relevant
404
+ one, so a large result set stays useful at a glance without any relevance
405
+ ranking. Files with no timestamp in the name (`_Global_Profile.md`, project
406
+ notes) sort last.
407
+
408
+ **Bounded output.** The count comes first, before the results -- you need the
409
+ size of the result set to interpret it. Then at most `AI_MEM_SEARCH_LIMIT`
410
+ lines (default 40), and if anything was withheld, an explicit `N hidden` line
411
+ with the command to narrow. This is for the agent, not for you: an unbounded
412
+ dump of a common term ran ~29k tokens, overflowed the host's tool-response
413
+ cap, and got silently truncated -- leaving the agent unable to tell "hidden"
414
+ from "absent". Near-miss padding is also the most damaging kind of distractor
415
+ for a model, so fewer clean hits beat more of them.
416
+
417
+ **Compact lines.** The vault root is printed once in the header and stripped
418
+ from every result path (a third to a half of all output bytes on a real
419
+ vault, no information lost). Lines longer than 200 characters are clamped
420
+ with `[...]`, since prose notes routinely run long.
421
+
422
+ **One hop out.** Any `[[wikilink]]` on a matched line is resolved to its
423
+ project note and shown with a one-line excerpt under `one hop out:`. A
424
+ `_lessons` entry names the projects it came from, so a hit there tells you
425
+ where it happened without a second search. Always on, not a flag to remember.
426
+
427
+ ```console
428
+ $ ai-mem-search '[[create-ai-memory]]'
429
+ 11 match(es) for '[[create-ai-memory]]'
430
+ ...
431
+ --
432
+ one hop out:
433
+ [[create-ai-memory]] -> /Users/you/_Ai_Memory/_projects/create-ai-memory.md
434
+ * **Current Objective:** ship the vault-backup fix
435
+ ```
436
+
437
+ (That query is also `-F` earning its keep: `[[` is matched literally, not as
438
+ a character class.)
439
+
440
+ **Scoping.** A second argument restricts the search to one project's session
441
+ logs -- `ai-mem-search postgres checkout-api`. Unknown project names fail
442
+ explicitly rather than silently searching everything.
443
+
444
+ ### Mirrored notes are not injected twice
445
+
446
+ `_Standards.md` ships declaring `mirror_of: _Global_Profile.md` in its
447
+ frontmatter. The mirror exists so the shared rules stay visible wherever only
448
+ one of the two notes is read -- but the launch prompt reads *both*, so
449
+ injecting both in full restates text the model has just finished reading.
450
+
451
+ When a note declares `mirror_of: <sibling note>`, only the lines that
452
+ actually differ from that source are injected, under a one-line marker
453
+ naming what was elided:
454
+
455
+ ```text
456
+ - Standards:
457
+ (mirror of _Global_Profile.md, shown above -- only the lines that differ from it are repeated here)
458
+ ## Standards Addendum
459
+ * Keep `_Standards.md` and `_Global_Profile.md` in lockstep when shared rules change.
460
+ ...
461
+ ```
462
+
463
+ Measured on a real vault: 72 of the mirror's 80 unique lines were already
464
+ verbatim in its source, and the launch prompt went from **~7,200 to ~4,300
465
+ tokens -- a 40% cut with nothing lost**, paid once per session per agent.
466
+
467
+ Matching is exact, line by line, so anything reworded is kept -- a near-match
468
+ is a real edit. The comparison fails **open** in every uncertain case: no
469
+ frontmatter, a missing source, a `mirror_of` containing a path separator, or
470
+ a diff that would leave nothing all inject the note in full. Injecting a note
471
+ twice costs tokens; dropping one costs the agent context it was promised, and
472
+ those are not the same kind of mistake.
473
+
474
+ ### Lessons are indexed, not injected
475
+
476
+ `ai-lesson` writes to `_lessons/<topic-slug>.md`, and those entries are the
477
+ most reusable thing in the vault -- they are the only notes that are true
478
+ across projects. They are also the hardest for an agent to find, because
479
+ finding one by search means guessing a term for knowledge it does not know
480
+ it has.
481
+
482
+ So the launch prompt lists **every lesson slug and no lesson bodies**:
483
+
484
+ ```text
485
+ - Lessons already recorded (96), listed by topic slug only -- the bodies are NOT
486
+ included here. If one looks relevant to the task at hand, read it with
487
+ `ai-mem-search <slug>` before solving the problem again from scratch.
488
+ prisma-connection-pool-exhaustion, decimal-money-precision-js, react-hydration-mismatch, ...
489
+ ```
490
+
491
+ A slug is the lesson already compressed: `prisma-connection-pool-exhaustion`
492
+ tells you whether to open it without opening it. That is the trade -- roughly
493
+ 8 tokens per lesson to convert a blind guess into a precise search. 96
494
+ lessons cost about 830 tokens.
495
+
496
+ Newest first, capped at `AI_MEM_LESSON_INDEX_LIMIT` (200), with a `+N older`
497
+ note when it truncates. The cap is not decoration: past a few hundred
498
+ entries, most titles are irrelevant to any given session, and a long tail of
499
+ near-miss titles is the most damaging kind of distractor for a model -- the
500
+ same reason `ai-mem-search` bounds its own output. A vault with no lessons
501
+ adds nothing to the prompt at all.
502
+
503
+ ### What it deliberately is not
504
+
505
+ Substring matching, not word matching: `git` also hits `github` and
506
+ `gitignore`. No stemming, no fuzzy matching, no synonyms, no relevance
507
+ ranking, no vector search. A term you half-remember will miss.
508
+
509
+ That is a real limit, and the way around it is the search strategy rather
510
+ than the search engine: **start broad and narrow down.** A first query that is
511
+ too specific is the usual way to miss what you were looking for. Search
512
+ `postgres` before `postgres connection pool timeout`, then add the project
513
+ argument once you can see roughly where the answer lives.
514
+
515
+ Returns non-zero on no matches, a missing term, or an unknown project, so it
516
+ composes in a script.
517
+
518
+
284
519
  ## Session skills (optional)
285
520
 
286
521
  You define your own per-session skills; create-ai-memory ships none. At launch it asks
@@ -368,6 +603,61 @@ Notes are created from templates on first use and never overwritten. Edit
368
603
  `_Global_Profile.md` and `_Standards.md` to make them yours; the shipped versions
369
604
  are sanitized placeholders.
370
605
 
606
+ ## Open Knowledge Format
607
+
608
+ [Open Knowledge Format](https://github.com/GoogleCloudPlatform/open-knowledge-format)
609
+ (OKF) is Google's vendor-neutral spec for portable, agent-readable knowledge.
610
+ An OKF *bundle* is simply a directory tree of markdown files — the unit of
611
+ distribution, shippable as a git repo, tarball, or zip, and readable by any
612
+ agent, static file server, Obsidian, MkDocs, or graph viewer without a
613
+ translation layer.
614
+
615
+ Your vault is one. That is convergence rather than adoption: both bet on
616
+ plain Markdown in a directory tree, in git, with no runtime.
617
+
618
+ The spec is deliberately small. [It requires no file at the bundle
619
+ root](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md)
620
+ — `index.md` and `log.md` are optional — and names exactly one required
621
+ frontmatter key: *"`type` is the only always-required key; a concept carrying
622
+ just `type` is fully conformant."*
623
+
624
+ | OKF | Here |
625
+ |---|---|
626
+ | Markdown files in a directory hierarchy | ✅ `_projects/`, `_lessons/`, `_session_logs/`, `_proposals/` |
627
+ | YAML frontmatter | ✅ every note |
628
+ | **`type` — the only required key** | ✅ `ai-project-context`, `ai-lesson`, `ai-session-log`, `ai-global-profile`, `ai-standards` |
629
+ | Recommended: `title`, `description`, `resource`, `tags` | ⚠️ partial — notes carry their own fields instead |
630
+ | Cross-links as standard markdown links | ⚠️ `[[wikilink]]` instead |
631
+ | `index.md` / `log.md` | optional in the spec; not generated here |
632
+ | No SDK, no account, git-versionable | ✅ |
633
+
634
+ One real deviation: **links stay Obsidian-style.** The vault is meant to be
635
+ opened in Obsidian, where the graph view and backlinks are much of why anyone
636
+ keeps one, and `ai-mem-search` resolves `[[wikilinks]]` itself. A strict OKF
637
+ consumer would not follow them — though the spec already requires consumers
638
+ to tolerate links that do not resolve.
639
+
640
+ No `index.md` is generated, and that is a choice rather than a gap: nothing
641
+ here reads one, `grep` does not consult it, and a materialized index is
642
+ exactly the thing that goes stale when a file is renamed. The lesson index is
643
+ built at launch from the directory itself for the same reason.
644
+
645
+ Session logs predate the `type` field, so a vault that has been in use holds
646
+ notes without it. `ai-mem-lint` counts them, and `ai-mem-lint --fix`
647
+ backfills:
648
+
649
+ ```console
650
+ $ ai-mem-lint
651
+ 350 session log(s) missing the `type:` frontmatter field (Open Knowledge Format requires it). Fix with: ai-mem-lint --fix
652
+
653
+ $ ai-mem-lint --fix
654
+ backfilled `type: ai-session-log` into 350 session log(s)
655
+ ```
656
+
657
+ It edits in place, preserves existing frontmatter and body, opens a
658
+ frontmatter block for a note that had none, and is idempotent — running it
659
+ twice does not stack a second field.
660
+
371
661
  ## Add another agent
372
662
 
373
663
  Launchers are not hardcoded. Each agent is one small adapter, and the
@@ -377,7 +667,7 @@ Launchers are not hardcoded. Each agent is one small adapter, and the
377
667
  1. Define the adapter in `shell/adapters.zsh`. It receives `$1` memory prompt,
378
668
  `$2` mode block, and `$3` onward extra args:
379
669
  ```zsh
380
- _ai_adapter_aider() {
670
+ __ai_adapter_aider() {
381
671
  local memory_prompt="$1"
382
672
  aider --message "$memory_prompt"
383
673
  }
@@ -388,8 +678,116 @@ Launchers are not hardcoded. Each agent is one small adapter, and the
388
678
  ```
389
679
  3. `aider-start` now exists. No core edits.
390
680
 
681
+ `cursor-start` targets `cursor-agent`, Cursor's CLI, which takes the prompt
682
+ positionally. If only the `cursor` GUI is installed it falls back to opening
683
+ that instead -- the GUI has no prompt path, so the session's skills still
684
+ arrive via the managed rule file but the vault context does not.
685
+
686
+ Name private helpers with **two** leading underscores (`__ai_adapter_aider`,
687
+ not `_ai_adapter_aider`). Claude Code replays a snapshot of your interactive
688
+ shell for every command it runs, and that snapshot drops single-underscore
689
+ function names -- the filter targets zsh's completion functions, but it takes
690
+ private helpers with it. A one-underscore helper simply will not exist inside
691
+ an agent-run command.
692
+
391
693
  ## Integrations
392
694
 
695
+ ### Graph view
696
+
697
+ `ai-mem-search` answers a question you already knew to ask. This is for the
698
+ other one — what is in there at all, and which notes turned out to be
699
+ connected.
700
+
701
+ You should not usually have to run this. **Ask the agent** — "open my memory",
702
+ "show me my context" — and it will: the launch prompt tells terminal agents
703
+ the viewer exists, and GUI clients get an `open_graph` tool over MCP. Running
704
+ it by hand stays available:
705
+
706
+ ```sh
707
+ ai-mem-serve # opens a browser at http://127.0.0.1:7777
708
+ ai-mem-serve 8080 --no-open
709
+ ```
710
+
711
+ Asked twice, the second call finds the first still listening and just opens
712
+ the tab. An agent should not have to check whether it is already running, and
713
+ a port collision with **its own** server is not a failure worth reporting —
714
+ though a port held by something else still is.
715
+
716
+ ![The vault as a graph: notes coloured by type, a lesson selected, its linked project highlighted](assets/graph-view.png)
717
+
718
+ Nothing here is a separate database. The vault is already a graph — notes
719
+ carrying a `type` in frontmatter with `[[wikilinks]]` between them — so this
720
+ only draws what is on disk.
721
+
722
+ - **Nodes are coloured by `type`** and sized by how many notes link to them, so
723
+ a project that has accumulated forty sessions looks like the hub it is.
724
+ - **Selecting a note** dims everything it is not connected to, shows the note
725
+ rendered beside the graph, and lists what it links to.
726
+ - **Durable knowledge** is the default view. Session logs usually outnumber
727
+ everything else several times over and all point at their project, which
728
+ buries the projects and lessons inside a hairball. Switch to *Everything* to
729
+ see them.
730
+ - **Search** and the legend both filter; `/` focuses the search box.
731
+
732
+ Bound to `127.0.0.1` only, deliberately. The vault holds project history and
733
+ operational detail, and a viewer for it has no business being reachable from
734
+ the network. Zero dependencies — the layout is a small force simulation rather
735
+ than a charting library, so it works with no network at all.
736
+
737
+ ### GUI clients (MCP)
738
+
739
+ The `*-start` launchers reach an agent by injecting the vault into its opening
740
+ prompt. **A GUI opened from the Dock never runs one** — there is no daemon and
741
+ no background service, so Claude Desktop and the Cursor GUI would otherwise
742
+ see nothing.
743
+
744
+ `ai-mem-mcp` is the channel for those. Register it once:
745
+
746
+ **Claude Desktop** — `~/Library/Application Support/Claude/claude_desktop_config.json`
747
+
748
+ ```json
749
+ {
750
+ "mcpServers": {
751
+ "ai-memory": {
752
+ "command": "ai-mem-mcp",
753
+ "env": { "AI_MEM_ROOT": "/absolute/path/to/your/_Ai_Memory" }
754
+ }
755
+ }
756
+ }
757
+ ```
758
+
759
+ **Cursor** — `~/.cursor/mcp.json`, same shape.
760
+
761
+ Six tools, read **and** write, so a GUI session is not a dead end:
762
+ `search_memory`, `get_context`, `read_note`, `add_note`, `add_lesson`, and
763
+ `open_graph` (which launches the [graph view](#graph-view) for them). Each
764
+ shells out to the same zsh functions the CLI uses, so there is one
765
+ implementation of the rules rather than a copy that drifts -- a note written
766
+ from Claude Desktop is committed and pushed exactly like one written in a
767
+ terminal, and is findable by the next session either way.
768
+
769
+ `read_note` compares resolved real paths and refuses anything outside the
770
+ vault.
771
+
772
+ **Making a GUI behave like a launcher.** In a terminal the vault is pushed
773
+ into the agent's opening prompt. Over MCP nothing is pushed, and a model with
774
+ no reason to suspect a memory exists will simply never call a tool. The server
775
+ returns MCP's `instructions` field at startup -- a short standing brief to read
776
+ context first, search before solving, and write back afterwards. That one
777
+ field is the difference between a vault the GUI *could* reach and one it
778
+ actually uses.
779
+
780
+ **On cost.** Tool schemas are re-sent every turn, so their prose is a
781
+ recurring tax; the `instructions` brief is sent once. Behaviour guidance
782
+ therefore lives in `instructions` and the descriptions stay terse. Adding the
783
+ write tools cost nothing per turn as a result: six tools now total ~429
784
+ tokens against ~380 for the original four, with a one-time ~227 for the brief.
785
+
786
+ **Do not register this for a terminal agent.** Claude Code, Codex, Gemini and
787
+ opencode all have a shell and should call `ai-mem-search` directly; wrapping a
788
+ CLI the agent can already run just adds a layer that can go out of date. MCP
789
+ earns its place only where the client has no shell.
790
+
393
791
  ### Claude Code hooks
394
792
  The files live in `hooks/claude/`. Record repo `HEAD` at session start, then on
395
793
  exit write an auto block to the log with the branch, commits made this session, and
@@ -428,6 +826,8 @@ git -C <repo> config core.hooksPath .githooks
428
826
  | `AI_MEM_ROOT` | `$HOME/.ai-memory/_Ai_Memory` | Vault root. Point at any folder, including an existing Obsidian vault |
429
827
  | `AI_MEM_AGENTS` | `claude codex gemini cursor opencode` | Space-separated agents to generate `-start` functions for |
430
828
  | `AI_MEM_SKILLS` / `AI_MEM_SKILL_ORDER` | empty | Your per-session skills (see above) |
829
+ | `AI_MEM_LESSON_INDEX_LIMIT` | `200` | Lesson slugs listed in the launch prompt before it truncates to the newest. Names only -- bodies are never injected |
830
+ | `AI_MEM_SEARCH_LIMIT` | `40` | Result lines `ai-mem-search` prints before it truncates. The default is sized for an agent's context window; raise it when you are reading the output yourself (see [How search works](#how-search-works)) |
431
831
 
432
832
  ## Why plain files
433
833