create-ai-memory 0.14.3 → 0.15.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
@@ -65,7 +65,8 @@ machines by pointing at the same folder.
65
65
 
66
66
  Agents read the vault through `ai-mem.zsh` at launch and write to it through a Stop
67
67
  hook at close. You read the same files in Obsidian, or through `ai-mem-search` and
68
- `ai-mem-lint`. Neither side gets a privileged interface — it's the same folder either way.
68
+ `ai-mem-lint`. Overnight, `ai-mem-sleep` tidies the same folder. Neither side gets a
69
+ privileged interface — it's the same folder either way.
69
70
 
70
71
  ```mermaid
71
72
  sequenceDiagram
@@ -74,6 +75,7 @@ sequenceDiagram
74
75
  participant Shell as claude-start
75
76
  participant Agent as Claude Code
76
77
  participant Vault as _Ai_Memory
78
+ participant Sleep as ai-mem-sleep
77
79
  participant Backup as git backup (optional)
78
80
 
79
81
  You->>Shell: claude-start
@@ -90,14 +92,22 @@ sequenceDiagram
90
92
  Agent->>Vault: rewrite Auto Session Log (branch, commits, changes)
91
93
  Agent->>Backup: commit + push, if the vault is git-backed
92
94
  Note over Vault: nothing overwritten -- a fresh file every session
95
+ Note over Sleep: overnight, unattended -- installed by ai-mem-sleep-schedule
96
+ Sleep->>Vault: archive session logs older than 90d, newest 5 per project kept
97
+ Sleep->>Vault: lint links, flag dangling wikilinks and consolidation candidates
98
+ Sleep->>Backup: commit + push the archive move, if the vault is git-backed
99
+ Note over Vault,Sleep: _lessons/ are never archived and never pruned
93
100
  You->>Shell: claude-start (next time)
94
101
  Shell->>Vault: read prior session again
95
102
  Note over Shell,Vault: now includes what just happened
96
103
  ```
97
104
 
98
- Everything through step 10 touches only files on your machine. Step 11 is the
99
- only network call in the whole loop, and only exists if you set up a git-backed
100
- vault yourself; skip that and everything stays local, always.
105
+ Everything through step 10 touches only files on your machine. Step 11 and
106
+ step 14 are the only network calls in the whole loop, and both only exist if
107
+ you set up a git-backed vault yourself; skip that and everything stays local,
108
+ always. The overnight pass (steps 12-14) is the pruning half of the loop --
109
+ what decays, what is consolidated, and what is never touched is set out in
110
+ [Memory hygiene](#memory-hygiene).
101
111
 
102
112
  ## See a full session
103
113
 
@@ -131,7 +141,7 @@ exec zsh
131
141
  Then, from inside any git repo:
132
142
 
133
143
  ```sh
134
- claude-start # or codex-start / gemini-start / cursor-start / opencode-start
144
+ claude-start # or codex-start / agy-start / cursor-start / opencode-start
135
145
  ```
136
146
 
137
147
  The agent opens already knowing your standards, this project, and where you left
@@ -158,6 +168,7 @@ off last time.
158
168
  - [Commands](#commands)
159
169
  - [How search works](#how-search-works)
160
170
  - [What it costs](#what-it-costs-and-what-it-cannot-do)
171
+ - [Memory hygiene](#memory-hygiene)
161
172
 
162
173
  </td>
163
174
  <td valign="top" width="33%">
@@ -178,6 +189,8 @@ off last time.
178
189
 
179
190
  **Project**
180
191
 
192
+ - [Why not just CLAUDE.md?](#why-not-just-claudemd)
193
+ - [Troubleshooting](#troubleshooting)
181
194
  - [Why plain files](#why-plain-files)
182
195
  - [Tests](#tests)
183
196
  - [FAQ](#faq)
@@ -212,7 +225,7 @@ Every number below is reproducible with the command beside it.
212
225
 
213
226
  | | before | after | |
214
227
  |---|---|---|---|
215
- | Launch prompt | 7,207 | **4,321** | −40%, mirrored notes injected once ([why](#mirrored-notes-are-not-injected-twice)) |
228
+ | Launch prompt | 7,207 | **4,046** | −44%, mirrored notes injected once ([why](#mirrored-notes-are-not-injected-twice)) and inlined notes capped ([why](#every-path-into-the-prompt-is-bounded)) |
216
229
  | Search result, common term | 10,234 | **1,752** | −83%, bounded output ([why](#how-search-works)) |
217
230
  | Lesson index, 96 lessons | — | **+829** | ~8 tokens per lesson, names only ([why](#lessons-are-indexed-not-injected)) |
218
231
 
@@ -252,7 +265,7 @@ implementations rather than guessing.
252
265
  | Runtime dependencies | **0** |
253
266
  | Package | **35 kB** (99.7 kB unpacked, 19 files) |
254
267
  | Index, daemon, database, embeddings | **none** — a note is searchable the moment it is written |
255
- | Tests | **153**, no network, no framework |
268
+ | Tests | **305**, no network, no framework |
256
269
 
257
270
  ```sh
258
271
  npm pack --dry-run && zsh tests/run.sh
@@ -295,16 +308,22 @@ optional. Set `AI_MEM_ROOT` in `~/.zshrc` first if you do not want the default
295
308
 
296
309
  | Command | What it does |
297
310
  |---|---|
298
- | `claude-start` · `codex-start` · `gemini-start` · `cursor-start` · `opencode-start` | Launch an agent with full vault context and the session-skill picker |
311
+ | `claude-start` · `codex-start` · `agy-start` · `gemini-start` · `cursor-start` · `opencode-start` | Launch an agent with full vault context and the session-skill picker |
299
312
  | `ai-start [project]` | Prepare the session (project note and fresh log) without launching an agent |
300
313
  | `ai-context [project]` | Print the vault context block for the current repo, and arm the git commit guard |
301
314
  | `ai-note <text>` | Append a timestamped note to today's session log while you work |
302
315
  | `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 |
303
- | `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 |
304
- | `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 25) 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 |
316
+ | `ai-mem-ingest --source-id <id> --title <t> --date <ISO> [...]` | File a distilled external artifact -- a meeting, a recorded call, a video, a voice note -- as one note in `_transcripts/`. Writes the summary, decisions, action items, attendee `[[wikilinks]]` and a link to the source; it never embeds the raw transcript body, because a full transcript is bulk the agent pays for and rarely needs. Re-ingesting the same `--source-id` updates that one note instead of filing a second copy. `ai-mem-search` covers `_transcripts/` with no extra path |
317
+ | `ai-mem-lint [--fix]` | Check the vault's links: orphaned session logs, dangling `previous` links, unreferenced project notes, notes missing the `type:` field, and **dangling `[[wikilinks]]`** -- a link pointing at a note that does not exist (a dead edge in the graph), reported but never auto-removed. `--fix` backfills `type:` into session logs written before the field existed |
318
+ | `ai-mem-search <term> [project]` | Case-insensitive literal search across the vault (or one project's logs). Lessons rank first, and within them by *reinforcement* -- a lesson recalled more often (more dated entries) ranks above a once-seen one -- then by date; archived logs (see `ai-mem-sleep`) are skipped. Paths print relative to a root stated once in the header. Output is capped (`AI_MEM_SEARCH_LIMIT`, default 25) 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 |
319
+ | `ai-mem-sleep [--apply]` | The vault's "bedtime" pass: archive stale session logs, flag consolidation candidates, and lint, in one run. Session logs older than `AI_MEM_SLEEP_DAYS` (default 90) move out of the hot search path -- always keeping the newest `AI_MEM_SLEEP_KEEP` (default 5) per project -- while `_lessons/` are never touched, because durable failure->fix knowledge is exactly what must survive. Dry-run by default; `--apply` moves logs into each project's `_archive/` (reversible via git) and backs up |
320
+ | `ai-mem-sleep-schedule [--install\|--uninstall] [--at HH:MM]` | Run the bedtime pass on its own, nightly (default 03:00). macOS installs a launchd agent; other platforms a crontab entry. The scheduled job sources the module first, since a cron/launchd shell does not read `~/.zshrc`. Dry-run by default -- prints exactly what it would install; `--install` schedules it, `--uninstall` removes it |
305
321
  | `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)) |
306
322
  | `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 |
307
323
 
324
+ `codex-note` and `codex-lesson` are aliases of `ai-note` and `ai-lesson`, for
325
+ muscle memory inside a Codex session; they behave identically.
326
+
308
327
  Project is auto-resolved from the current git repo; pass a name to override.
309
328
 
310
329
  ## How search works
@@ -316,7 +335,7 @@ second you write it.
316
335
  ```mermaid
317
336
  flowchart TD
318
337
  A(["You look for a word"]) --> B{"Did you name<br/>a project?"}
319
- B -->|"no"| C["Look through<br/>every note you have"]
338
+ B -->|"no"| C["Look through every note<br/>outside _archive/"]
320
339
  B -->|"yes"| D["Look only inside<br/>that project"]
321
340
  C --> E["Read them all.<br/>Capitals don't matter.<br/>Punctuation means itself."]
322
341
  D --> E
@@ -411,6 +430,8 @@ tool and you want a real index.
411
430
 
412
431
  **Pushed once at launch** (~4,300 tokens): your profile, standards, the
413
432
  project note's path, a digest of the last session, and the lesson topics.
433
+ The last session is the newest log with content. A log that is still the
434
+ unfilled template (a session opened and closed without notes) is skipped.
414
435
 
415
436
  **Pulled on demand after that.** Nothing re-injects. The agent reaches the
416
437
  vault mid-session only by running `ai-mem-search` itself — which the launch
@@ -438,6 +459,35 @@ Matching is exact and line-by-line, so anything reworded survives. It fails
438
459
  note in full. Injecting twice costs tokens; dropping a note costs the agent
439
460
  context it was promised.
440
461
 
462
+ ### Every path into the prompt is bounded
463
+
464
+ The launch prompt is paid **every session, in every project**, so anything
465
+ that can grow without limit is a cost that compounds silently.
466
+
467
+ | what reaches the prompt | bound |
468
+ |---|---|
469
+ | Profile and standards | **8,000 chars** each (`AI_MEM_NOTE_MAX_CHARS`) |
470
+ | Previous session outcome | 4 fields, 500 chars each |
471
+ | Lesson index | 200 slugs, names only |
472
+ | Project note | **a path, not its contents** |
473
+ | `ai-mem-search` output | flat: 765 matches cost the same as 240 |
474
+
475
+ The profile was the one exception. It grew to 12,405 chars and pushed the
476
+ launch prompt from 4,321 tokens to 5,125 without anything reporting it —
477
+ a 19% rise nobody asked for. Capping it brought it to **4,046**.
478
+
479
+ Truncation always states the real total and where to read the rest:
480
+
481
+ ```text
482
+ [truncated at 8000 of 12405 chars -- read the rest with: cat "…/_Global_Profile.md"]
483
+ ```
484
+
485
+ That line matters more than the saving. A truncated note the agent cannot
486
+ distinguish from a complete one is worse than a long one: it would answer
487
+ from half a profile believing it had all of it. The cut also lands on a line
488
+ boundary, because Markdown severed mid-line can leave half a heading or an
489
+ unterminated code fence, which reads as content rather than as damage.
490
+
441
491
  ### Lessons are indexed, not injected
442
492
 
443
493
  `_lessons/` entries are the only notes true across projects, and the hardest
@@ -451,8 +501,10 @@ know you have. So the launch prompt lists **every lesson slug and no bodies**:
451
501
  ```
452
502
 
453
503
  A slug is the lesson compressed: `prisma-connection-pool-exhaustion` tells
454
- you whether to open it without opening it. ~8 tokens each; 96 lessons cost
455
- ~830.
504
+ you whether to open it without opening it. ~8-10 tokens each, so the index
505
+ grows slowly: 96 lessons cost ~830, and a vault grown to 182 lessons costs
506
+ ~1,740 (`ai-context | grep -A3 'Lessons already recorded' | wc -c`, chars divided
507
+ by ~4).
456
508
 
457
509
  Newest first, capped at `AI_MEM_LESSON_INDEX_LIMIT` (200). The cap matters —
458
510
  past a few hundred, most titles are irrelevant to any given session, and a
@@ -461,6 +513,52 @@ long tail of near-misses is the most damaging kind of distractor for a model.
461
513
  Returns non-zero on no matches, a missing term, or an unknown project, so
462
514
  it composes in a script.
463
515
 
516
+ ## Memory hygiene
517
+
518
+ A second brain that only grows, rots. Old session logs bury the recent ones,
519
+ near-duplicate lessons pile up, and a dead `[[link]]` points at a note that is
520
+ no longer there. Search then spends more tokens to return worse results.
521
+
522
+ create-ai-memory keeps the vault healthy with the two-sided strategy a brain
523
+ uses: it strengthens what gets used and lets the rest fade, but it never throws
524
+ away what was hard to learn.
525
+
526
+ | move | what it does | command |
527
+ |---|---|---|
528
+ | **Strengthen** | A lesson recalled again ranks higher, not just newer -- long-term potentiation for the vault. | `ai-mem-search` ranking |
529
+ | **Consolidate** | Many session logs about one thing distil into a single durable lesson. | `ai-lesson` |
530
+ | **Decay** | Old session logs move out of the hot search path into `_archive/`, still on disk and in git. | `ai-mem-sleep` |
531
+ | **Prune (detect)** | A dangling `[[wikilink]]` -- a dead edge -- is surfaced, never auto-removed. | `ai-mem-lint` |
532
+ | **Schedule** | Run the whole pass nightly on its own. | `ai-mem-sleep-schedule` |
533
+
534
+ **One rule is inviolable: a lesson is never pruned.** The failure-to-fix records
535
+ in `_lessons/` are the durable knowledge -- the answer you may need once every
536
+ six months when an old blocker returns -- and pruning by disuse would delete
537
+ exactly those. Only the ephemeral layer (session logs) decays, and even it is
538
+ archived, not deleted. Reinforcement acts on lessons; decay acts on logs; the
539
+ two never cross.
540
+
541
+ ### Where the model comes from
542
+
543
+ The design is modeled on how a brain manages memory. It is a design analogy,
544
+ not a claim to reproduce the biology. Two ideas guided it:
545
+
546
+ - **Synaptic pruning and homeostasis.** An infant brain overproduces neural
547
+ connections, then removes the weak or unused ones from experience -- "use it
548
+ or lose it" -- which is what keeps it efficient. A vault that only appends is
549
+ the brain that never prunes.
550
+ - **Long-term potentiation (LTP).** A pathway that fires repeatedly is
551
+ strengthened. That is the half a naive "drop the old" policy forgets, and the
552
+ half `ai-mem-search`'s reinforcement adds.
553
+
554
+ Framing these as one scheduled maintenance pass -- consolidation, decay,
555
+ garbage collection, and graph pruning, run while the agent "sleeps" -- follows
556
+ Andrew Orobator, ["Your Agent Needs a Bedtime"][bedtime], and the wider NeuroAI
557
+ work that applies synaptic pruning to artificial networks. Its rule that error
558
+ recoveries are never pruned is the same rule stated above.
559
+
560
+ [bedtime]: https://medium.com/@andreworobator/your-agent-needs-a-bedtime-cc594be3f993
561
+
464
562
  ## Session skills (optional)
465
563
 
466
564
  You define your own per-session skills; create-ai-memory ships none. At launch it asks
@@ -542,6 +640,9 @@ $AI_MEM_ROOT/
542
640
  _lessons/
543
641
  _lesson_template.md scaffold for new lesson topics
544
642
  <topic-slug>.md cross-project decisions/mistakes, filed by ai-lesson
643
+ _transcripts/
644
+ <source-id>.md distilled meetings, calls, videos and voice notes,
645
+ filed by ai-mem-ingest
545
646
  ```
546
647
 
547
648
  Notes are created from templates on first use and never overwritten. Edit
@@ -588,8 +689,14 @@ Edits in place, preserves frontmatter and body, idempotent.
588
689
  ## Add another agent
589
690
 
590
691
  Launchers are not hardcoded. Each agent is one small adapter, and the
591
- `<name>-start` function is generated for you. `claude`, `codex`, `gemini`,
592
- `cursor`, and `opencode` ship built in. To add `aider`:
692
+ `<name>-start` function is generated for you. `claude`, `codex`, `agy`,
693
+ `gemini`, `cursor`, and `opencode` ship built in.
694
+
695
+ `agy` is the [Antigravity CLI](https://antigravity.google), which in practice
696
+ has replaced the Gemini CLI. Both adapters ship: `gemini-start` still works
697
+ for anyone using it, and `agy-start` is the one to reach for now.
698
+
699
+ To add `aider`:
593
700
 
594
701
  1. Define the adapter in `shell/adapters.zsh`. It receives `$1` memory prompt,
595
702
  `$2` mode block, and `$3` onward extra args:
@@ -601,7 +708,7 @@ Launchers are not hardcoded. Each agent is one small adapter, and the
601
708
  ```
602
709
  2. Register it in `~/.zshrc` before sourcing, or edit the default:
603
710
  ```zsh
604
- export AI_MEM_AGENTS="claude codex gemini cursor opencode aider"
711
+ export AI_MEM_AGENTS="claude codex agy gemini cursor opencode aider"
605
712
  ```
606
713
  3. `aider-start` now exists. No core edits.
607
714
 
@@ -635,7 +742,9 @@ ai-mem-serve # opens a browser at http://127.0.0.1:7777
635
742
  Nodes are coloured by `type` and sized by how many notes link to them.
636
743
  Selecting one dims everything unconnected and renders the note beside the
637
744
  graph. *Durable knowledge* is the default view — session logs usually
638
- outnumber everything else and bury the rest.
745
+ outnumber everything else and bury the rest. A note carrying a dangling
746
+ `[[link]]` wears a dashed red ring, so a dead edge is visible in the graph as
747
+ well as in the note (where it renders dotted and unclickable).
639
748
 
640
749
  Loopback only, deliberately: the vault holds project history. Zero
641
750
  dependencies — the layout is a small force simulation, not a charting
@@ -676,6 +785,28 @@ re-sent every turn: six tools cost ~429 tokens/turn, the brief ~290 once.
676
785
  **Do not register this for a terminal agent.** Claude Code, Codex, Gemini and
677
786
  opencode have a shell and should call `ai-mem-search` directly.
678
787
 
788
+ **A desktop app that has a shell but no launcher** (the Codex app, for
789
+ example) gets no vault context, because nothing runs `codex-start` for it.
790
+ Without instructions, it guesses: it takes the newest log in the vault, which
791
+ can be a different project. Put the rules in the app's global instruction file
792
+ (`~/.codex/AGENTS.md` for Codex). A GUI app does not read `~/.zshrc`, so give
793
+ the vault path and the module path explicitly:
794
+
795
+ ```md
796
+ ## AI memory vault
797
+ Before you answer a question about a project, load its context:
798
+ `AI_MEM_ROOT=/abs/path/_Ai_Memory zsh -c 'source /abs/path/create-ai-memory/shell/ai-mem.zsh; ai-context <project>'`
799
+ - <project> is the name the user gives, or the git repo folder name.
800
+ - If the user gives no project and the folder is not a git repo, STOP and ask.
801
+ A folder that is not a repo does not give a project name. Do not guess.
802
+ - If `_projects/<project>.md` does not exist, ask before you continue:
803
+ `ai-context` makes a new empty project for a name that is not correct.
804
+ - Skip this step if the prompt already contains vault context.
805
+ - To record a note, use the same form with `AI_MEM_ACTIVE_PROJECT=<project>` added
806
+ and `ai-note "<text>"`. Outside a repo, that variable names the project.
807
+ Each shell command starts a new process, so set it on every call.
808
+ ```
809
+
679
810
  ### Claude Code hooks
680
811
  The files live in `hooks/claude/`. Record repo `HEAD` at session start, then on
681
812
  exit write an auto block to the log with the branch, commits made this session, and
@@ -688,7 +819,11 @@ the session can never get stuck refusing to compact. It only guards
688
819
  auto-compact, not a deliberate `/compact`. Merge `settings.snippet.json` into
689
820
  `~/.claude/settings.json`, replacing `<AI_MEM_HOME>` with an absolute path.
690
821
  All three hooks no-op for plain `claude` runs; they gate on
691
- `$AI_MEM_ACTIVE_SESSION_LOG`. This is Claude-Code-specific -- other agents
822
+ `$AI_MEM_ACTIVE_SESSION_LOG`. That variable stays exported in your shell after
823
+ the agent exits, so the session-start and Stop hooks also check
824
+ `$AI_MEM_ACTIVE_GIT_DIR`: they write only in the repo the session was launched
825
+ in, or a worktree of it. A later plain `claude` in a different repo does not
826
+ put that repo's commits in the wrong project's log. This is Claude-Code-specific -- other agents
692
827
  (Codex, Gemini, etc.) have no equivalent pre-compaction hook, so jotting
693
828
  things down with `ai-note`/`codex-note` as you go still matters there.
694
829
 
@@ -712,12 +847,64 @@ git -C <repo> config core.hooksPath .githooks
712
847
  | Env var | Default | Purpose |
713
848
  |---|---|---|
714
849
  | `AI_MEM_ROOT` | `$HOME/.ai-memory/_Ai_Memory` | Vault root. Point at any folder, including an existing Obsidian vault |
715
- | `AI_MEM_AGENTS` | `claude codex gemini cursor opencode` | Space-separated agents to generate `-start` functions for |
850
+ | `AI_MEM_AGENTS` | `claude codex agy gemini cursor opencode` | Space-separated agents to generate `-start` functions for |
716
851
  | `AI_MEM_SKILLS` / `AI_MEM_SKILL_ORDER` | empty | Your per-session skills (see above) |
717
852
  | `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 |
853
+ | `AI_MEM_NOTE_MAX_CHARS` | `8000` | Cap on what one inlined note contributes to the launch prompt. Truncation states the real total and the path. `0` disables it |
718
854
  | `AI_MEM_SEARCH_LIMIT` | `25` | 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)) |
855
+ | `AI_MEM_HOME` | the module's own directory | Exported by the module when it is sourced, not set by you. A cron job, a launchd agent or any non-interactive shell can re-source the module with `zsh -c 'source "$AI_MEM_HOME/ai-mem.zsh"; ...'` instead of a hard-coded path |
719
856
  | `AI_MEM_SEARCH_PER_FILE` | `1` | Lines shown per file once the cap binds. Spreads results across notes instead of on the chattiest one; ignored when every match already fits |
720
857
 
858
+ ## Why not just CLAUDE.md?
859
+
860
+ You probably already have one. Keep it — this does a different job, and the
861
+ tool defers to it by design.
862
+
863
+ | | `CLAUDE.md` / `AGENTS.md` | create-ai-memory |
864
+ |---|---|---|
865
+ | Holds | rules and conventions | what happened, decided, and broke |
866
+ | Changes | when you edit it | every session, automatically |
867
+ | Scope | that one repo | global + per-repo + cross-project lessons |
868
+ | Agents | one vendor's file per agent | one vault, five CLIs |
869
+ | Answers | *"how should you work here?"* | *"what did we already try?"* |
870
+
871
+ A `CLAUDE.md` is a standing instruction. It does not know that last Tuesday
872
+ you found the connection pool was sized below the worker count, or that the
873
+ same bug bit a different repo in March. That is what accumulates here.
874
+
875
+ They compose: the injected profile explicitly tells the agent that repo-local
876
+ instruction files **override it** for that repo. Nothing to migrate, nothing
877
+ to delete.
878
+
879
+ ## Troubleshooting
880
+
881
+ **`claude-start` works but the agent has no memory of anything.**
882
+ You launched plain `claude`. Nothing hooks it — the vault reaches the agent
883
+ through the launcher's opening prompt, so a bare CLI gets none of it.
884
+
885
+ **A command "isn't installed" right after an upgrade.**
886
+ Your shell is stale. These are zsh functions loaded when the terminal opened;
887
+ editing or upgrading the module changes nothing in a shell already running.
888
+ Open a new terminal, or `exec zsh`. `which` under bash will not find them
889
+ either — use `command -v`.
890
+
891
+ **The agent's "Project context" is bracket placeholders.**
892
+ The project note was never filled in. The launch prompt now says so and asks
893
+ the agent to fill it from the repo; you can also edit
894
+ `_projects/<repo>.md` yourself. It is read at every launch for that repo, so
895
+ it is worth ten minutes once.
896
+
897
+ **`ai-mem-lint` reports orphaned session logs.**
898
+ Their `project:` frontmatter is not a `[[wikilink]]`, usually because the
899
+ vault's session template predates the current one. Scaffolding only fills in
900
+ *missing* files, so an existing vault keeps its old templates. Run
901
+ `ai-mem-lint --fix`.
902
+
903
+ **Search returns nothing for a term you are sure you wrote.**
904
+ Matching is literal substring with no fuzzy matching, so a typo finds zero.
905
+ Search one distinctive word rather than a phrase or a whole error line — see
906
+ [what it costs](#what-it-costs-and-what-it-cannot-do).
907
+
721
908
  ## Why plain files
722
909
 
723
910
  create-ai-memory is deliberately small. There is no server to run, no container to pull,
@@ -743,11 +930,11 @@ afternoon and carry anywhere.
743
930
 
744
931
  Offline unit suite (throwaway vault and git repo, no network): path guarding,
745
932
  project resolution, session prep, the context prompt, the skill picker, launcher
746
- generation, adapter dispatch, the commit token, `ai-note`, and the cursor rule
747
- file.
933
+ generation, adapter dispatch, the commit token, `ai-note`, `ai-mem-ingest`, and
934
+ the cursor rule file.
748
935
 
749
936
  ```sh
750
- zsh tests/run.sh # offline unit tests (38 assertions)
937
+ zsh tests/run.sh # offline unit tests (340 assertions)
751
938
  zsh tests/smoke.sh # live: launches each agent headlessly, checks it responds
752
939
  ```
753
940
 
@@ -181,14 +181,24 @@ function buildGraph() {
181
181
  const seen = new Set();
182
182
  const edges = [];
183
183
  for (const n of nodes) {
184
+ // A wikilink whose basename matches no note is a dead edge. It is still not
185
+ // drawn to a phantom node -- OKF asks consumers to tolerate links that do
186
+ // not resolve -- but the COUNT is kept on the source node, so the graph can
187
+ // mark which notes carry a broken link without inventing targets for them.
188
+ const danglingSeen = new Set();
184
189
  for (const link of n.links) {
185
190
  const target = byBasename.get(link);
186
- if (!target || target === n.id) continue;
191
+ if (!target) {
192
+ if (link && link !== basename(n.id, '.md')) danglingSeen.add(link);
193
+ continue;
194
+ }
195
+ if (target === n.id) continue;
187
196
  const key = n.id + ' -> ' + target;
188
197
  if (seen.has(key)) continue;
189
198
  seen.add(key);
190
199
  edges.push({ source: n.id, target });
191
200
  }
201
+ if (danglingSeen.size) n.dangling = danglingSeen.size;
192
202
  delete n.links;
193
203
  }
194
204
  return { vault: VAULT, nodes, edges };
@@ -10,6 +10,15 @@ set -euo pipefail
10
10
  log="${AI_MEM_ACTIVE_SESSION_LOG:-}"
11
11
  [ -n "$log" ] || exit 0
12
12
 
13
+ # The launcher's exports outlive the agent in the user's shell, so a later
14
+ # plain `claude` in another repo inherits them. Write only in the repo the
15
+ # session was launched in (any worktree of it). Unset = an older launcher.
16
+ # Same guard as session-summary.sh; keep the two in step.
17
+ if [ -n "${AI_MEM_ACTIVE_GIT_DIR:-}" ]; then
18
+ here="$(cd "$(git rev-parse --git-common-dir 2>/dev/null || echo /nonexistent)" 2>/dev/null && pwd -P || true)"
19
+ [ "$here" = "$AI_MEM_ACTIVE_GIT_DIR" ] || exit 0
20
+ fi
21
+
13
22
  sha="$(git rev-parse HEAD 2>/dev/null || true)"
14
23
  [ -n "$sha" ] || exit 0
15
24
 
@@ -15,6 +15,16 @@ log="${AI_MEM_ACTIVE_SESSION_LOG:-}"
15
15
  [ -n "$log" ] || exit 0
16
16
  [ -f "$log" ] || exit 0
17
17
 
18
+ # The launcher's exports outlive the agent in the user's shell, so a later
19
+ # plain `claude` in another repo inherits them and would write that repo's
20
+ # commits into this project's log. Write only in the repo the session was
21
+ # launched in (any worktree of it). Unset = an older launcher.
22
+ # Same guard as session-start.sh; keep the two in step.
23
+ if [ -n "${AI_MEM_ACTIVE_GIT_DIR:-}" ]; then
24
+ here="$(cd "$(git rev-parse --git-common-dir 2>/dev/null || echo /nonexistent)" 2>/dev/null && pwd -P || true)"
25
+ [ "$here" = "$AI_MEM_ACTIVE_GIT_DIR" ] || exit 0
26
+ fi
27
+
18
28
  marker="## Auto Session Log"
19
29
 
20
30
  branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo '(no git)')"
@@ -47,9 +57,18 @@ ${changes}
47
57
  EOF
48
58
  )"
49
59
 
50
- # Strip any previous auto block (from marker to EOF), then append the fresh one.
60
+ # Strip the previous auto block, then append the fresh one. Strip only the
61
+ # block: ai-note appends Live Notes at EOF, so after the first Stop they sit
62
+ # below the block. Cutting from the marker to EOF erased them. The block ends
63
+ # after the "- " lines under its last bullet; the blank line that ai-note puts
64
+ # before each note ends it.
51
65
  tmp="$(mktemp)"
52
- awk -v m="$marker" 'index($0, m)==1 { exit } { print }' "$log" > "$tmp"
66
+ awk -v m="$marker" '
67
+ index($0, m) == 1 { inblock = 1; last = 0; next }
68
+ inblock && /^\* \*\*Uncommitted changes/ { last = 1; next }
69
+ inblock && last && !/^- / { inblock = 0; if ($0 == "") next }
70
+ !inblock { print }
71
+ ' "$log" > "$tmp"
53
72
  printf '%s\n\n%s\n' "$(cat "$tmp")" "$block" > "$log"
54
73
  rm -f "$tmp"
55
74
 
package/install.sh CHANGED
@@ -72,7 +72,7 @@ banner
72
72
  # --- gather settings ---------------------------------------------------------
73
73
  AI_MEM_ROOT="${AI_MEM_ROOT:-$HOME/.ai-memory/_Ai_Memory}"
74
74
  ask AI_MEM_ROOT "Where should your memory vault live?" "$AI_MEM_ROOT"
75
- AI_MEM_AGENTS="${AI_MEM_AGENTS:-claude codex gemini cursor opencode}"
75
+ AI_MEM_AGENTS="${AI_MEM_AGENTS:-claude codex agy gemini cursor opencode}"
76
76
  ask AI_MEM_AGENTS "Which agents should get <agent>-start launchers?" "$AI_MEM_AGENTS"
77
77
 
78
78
  # --- scaffold the vault ------------------------------------------------------
@@ -92,7 +92,7 @@ copy_if_absent "$HERE/vault-template/_lessons/_lesson_template.md" "$AI_ME
92
92
 
93
93
  # --- assemble the ~/.zshrc lines ---------------------------------------------
94
94
  LINES="export AI_MEM_ROOT=\"$AI_MEM_ROOT\""
95
- if [ "$AI_MEM_AGENTS" != "claude codex gemini cursor opencode" ]; then
95
+ if [ "$AI_MEM_AGENTS" != "claude codex agy gemini cursor opencode" ]; then
96
96
  LINES="$LINES
97
97
  export AI_MEM_AGENTS=\"$AI_MEM_AGENTS\""
98
98
  fi
@@ -135,7 +135,7 @@ cat <<EOF
135
135
  (your memory; safe to back up, sync, or open in Obsidian)
136
136
 
137
137
  From inside any git repo, run: claude-start
138
- (or codex-start / gemini-start / cursor-start / opencode-start)
138
+ (or codex-start / agy-start / gemini-start / cursor-start / opencode-start)
139
139
 
140
140
  Optional integrations: see $HERE/hooks/ and the README.
141
141
  EOF
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ai-memory",
3
- "version": "0.14.3",
3
+ "version": "0.15.0",
4
4
  "description": "Persistent, agent-agnostic session memory for AI coding CLIs (Claude Code, Codex, Gemini, Cursor, opencode). One Markdown vault, any agent.",
5
5
  "bin": {
6
6
  "create-ai-memory": "bin/create-ai-memory.js",
@@ -31,6 +31,21 @@ __ai_adapter_gemini() {
31
31
  gemini --include-directories "$AI_MEM_ROOT" -i "$memory_prompt"
32
32
  }
33
33
 
34
+ # Antigravity (agy): Google's successor to the Gemini CLI, installed as the
35
+ # `antigravity-cli` cask with `agy` as its binary. It takes --add-dir like
36
+ # codex and -i for an interactive initial prompt like the Gemini CLI did, so
37
+ # the vault is granted the same way and the session still opens interactively
38
+ # rather than printing one answer and exiting.
39
+ #
40
+ # --prompt on agy is an alias for --print, which runs ONE turn and exits. That
41
+ # is the wrong verb here: a launcher exists to start a session the developer
42
+ # keeps working in, so -i (--prompt-interactive) is the correct flag.
43
+ __ai_adapter_agy() {
44
+ local memory_prompt="$1"
45
+ shift 2>/dev/null || true
46
+ agy --add-dir "$AI_MEM_ROOT" -i "$memory_prompt"
47
+ }
48
+
34
49
  # Cursor ships two entry points. `cursor-agent` is the CLI and takes the
35
50
  # prompt positionally, so it gets the vault context like every other agent.
36
51
  # `cursor` is the GUI, which has no prompt path -- launching it drops the