create-ai-memory 0.18.1 → 0.18.2

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
@@ -95,7 +95,7 @@ sequenceDiagram
95
95
  Note over Vault: nothing overwritten -- a fresh file every session
96
96
  Note over Sleep: overnight, unattended -- installed by ai-mem-sleep-schedule
97
97
  Sleep->>Vault: archive unfilled logs after a day, logs older than 90d (newest 5 filled kept)
98
- Sleep->>Vault: lint links, flag dangling wikilinks and consolidation candidates
98
+ Sleep->>Vault: lint links, rank links to unwritten notes, flag consolidation candidates
99
99
  Sleep->>Backup: commit + push the archive move, if the vault is git-backed
100
100
  Note over Vault,Sleep: _lessons/ are never archived and never pruned
101
101
  You->>Shell: claude-start (next time)
@@ -316,7 +316,7 @@ optional. Set `AI_MEM_ROOT` in `~/.zshrc` first if you do not want the default
316
316
  | `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 |
317
317
  | `ai-about-me [--review] [harness]` | Fill `_about_me/` by interview. The agent asks one question at a time, asks about real past events before hypotheticals, asks "why does that matter?" to find the reason behind each rule, and writes a note only after you approve its draft. `--review` proposes rules found in 2 or more of your lessons and session logs; you accept, change or reject each one. The harness defaults to the first in `AI_MEM_HARNESSES`. When `_about_me/` holds only placeholders, the next launch tells you once, on stderr, never the agent |
318
318
  | `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 |
319
- | `ai-mem-lint [--fix]` | Check the vault's links: orphaned session logs, dangling `previous` links (a link to a log in the project's `_archive/` resolves, as it does in Obsidian), 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 |
319
+ | `ai-mem-lint [--fix]` | Check the vault's links: orphaned session logs, dangling `previous` links (a link to a log in the project's `_archive/` resolves, as it does in Obsidian), unreferenced project notes, and notes missing the `type:` field. Links to notes not written yet (`[[Name]]` with no `Name.md`) are **not** errors -- Obsidian creates the note when the link is clicked -- so they get one ranked line instead: `most linked: [[checkout-api]] 17, ...`. A target many notes link to is a missing note worth writing. `[[...]]` in code and `{{placeholders}}` are ignored. `--fix` backfills `type:` into session logs written before the field existed |
320
320
  | `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 |
321
321
  | `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) filled logs per project -- while `_lessons/` are never touched, because durable failure->fix knowledge is exactly what must survive. An **unfilled** log -- the template with nothing written, plus at most an Auto Session Log that saw no commits and a clean tree -- is archived once it is dated before yesterday, and never takes a KEEP slot: most sessions close without a note, and counting them pushed every real log out of the hot set. Dry-run by default; `--apply` moves logs into each project's `_archive/` (reversible via git) and backs up |
322
322
  | `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 sets `AI_MEM_ROOT` and sources the module first, since a cron/launchd shell does not read `~/.zshrc`. On macOS, a vault in `~/Documents`, `~/Desktop`, `~/Downloads` or iCloud Drive gets a warning: macOS can deny a launchd job read access there, and the pass then does nothing. Check the job log after its first run. Dry-run by default -- prints exactly what it would install; `--install` schedules it, `--uninstall` removes it |
@@ -554,7 +554,7 @@ away what was hard to learn.
554
554
  | **Strengthen** | A lesson recalled again ranks higher, not just newer -- long-term potentiation for the vault. | `ai-mem-search` ranking |
555
555
  | **Consolidate** | Many session logs about one thing distil into a single durable lesson. | `ai-lesson` |
556
556
  | **Decay** | Old session logs move out of the hot search path into `_archive/`, still on disk and in git. Unfilled logs go after a day. | `ai-mem-sleep` |
557
- | **Prune (detect)** | A dangling `[[wikilink]]` -- a dead edge -- is surfaced, never auto-removed. | `ai-mem-lint` |
557
+ | **Prune (detect)** | Links to notes not written yet are ranked by how many notes link to them, never auto-removed. | `ai-mem-lint` |
558
558
  | **Schedule** | Run the whole pass nightly on its own. | `ai-mem-sleep-schedule` |
559
559
 
560
560
  **One rule is inviolable: a lesson is never pruned.** The failure-to-fix records
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ai-memory",
3
- "version": "0.18.1",
3
+ "version": "0.18.2",
4
4
  "description": "Persistent, harness-agnostic session memory for AI coding CLIs (Claude Code, Codex, Gemini, Cursor, opencode, omp). One Markdown vault, any harness.",
5
5
  "bin": {
6
6
  "create-ai-memory": "bin/create-ai-memory.js",
package/shell/ai-mem.zsh CHANGED
@@ -1219,6 +1219,22 @@ ai-lesson() {
1219
1219
 
1220
1220
  local project_name lesson_file timestamp
1221
1221
  project_name="$(__ai_mem_current_project)" || return 1
1222
+ # Run from inside the vault, the project resolves to the vault's own repo
1223
+ # or folder name: on a real vault 36 lesson entries were tagged with the
1224
+ # vault repo's name, a project that does not exist. Inside the vault, use
1225
+ # the active session's project, or refuse rather than guess.
1226
+ if [[ -z "${AI_MEM_FORCE_PROJECT:-}" ]]; then
1227
+ local here_root vault_root
1228
+ here_root="$(git rev-parse --show-toplevel 2>/dev/null)"
1229
+ vault_root="$(git -C "$AI_MEM_ROOT" rev-parse --show-toplevel 2>/dev/null)"
1230
+ if [[ "${PWD:A}/" == "${AI_MEM_ROOT:A}/"* || ( -n "$here_root" && "$here_root" == "$vault_root" ) ]]; then
1231
+ if [[ -z "${AI_MEM_ACTIVE_PROJECT:-}" ]]; then
1232
+ echo "ai-lesson: run from inside the memory vault, so the project is unknown. Run it from the project's repo, or set AI_MEM_ACTIVE_PROJECT=<project>." >&2
1233
+ return 1
1234
+ fi
1235
+ project_name="$AI_MEM_ACTIVE_PROJECT"
1236
+ fi
1237
+ fi
1222
1238
  lesson_file="$AI_MEM_ROOT/_lessons/${slug}.md"
1223
1239
  timestamp="$(date '+%Y-%m-%d %H:%M')"
1224
1240
 
@@ -1507,17 +1523,19 @@ ai-mem-lint() {
1507
1523
  fi
1508
1524
 
1509
1525
 
1510
- # Dangling wikilinks: a [[target]] pointing at a note that does not exist --
1511
- # a dead edge in the graph. Detection only: the dead link is surfaced, never
1512
- # auto-removed, because the intended target is unknowable and a note's own
1513
- # prose is the author's to edit. Wikilinks resolve by basename (the same way
1514
- # ai-mem-serve draws them), so the node set is every note's basename. A
1515
- # folder path ([[_idea/x]], [[../dir/x]]) resolves by its last segment.
1526
+ # Links to notes not written yet: a [[target]] with no note of that name.
1527
+ # Obsidian treats these as intentional -- clicking one creates the note --
1528
+ # so they are reported as a ranked summary, NOT counted as issues. A target
1529
+ # linked from many notes is a missing hub worth writing; a target linked
1530
+ # once is a breadcrumb. On a real vault 206 of 220 lint issues were these
1531
+ # (people in meeting transcripts, projects without a note), and listing
1532
+ # each one as an error buried the 14 that were real. Wikilinks resolve by
1533
+ # basename (the same way ai-mem-serve draws them); a folder path
1534
+ # ([[_idea/x]], [[../dir/x]]) resolves by its last segment.
1516
1535
  #
1517
- # Not links, so never reported (28 of 280 findings on a real vault were
1518
- # these): text inside `inline code` or a fenced code block, where a shell
1519
- # test such as [[ -n $X ]] looks like a wikilink, and {{placeholder}}
1520
- # targets in the note templates.
1536
+ # Not links, so never counted: text inside `inline code` or a fenced code
1537
+ # block, where a shell test such as [[ -n $X ]] looks like a wikilink, and
1538
+ # {{placeholder}} targets in the note templates.
1521
1539
  #
1522
1540
  # One awk pass over the vault, never a process per file -- a per-file scan
1523
1541
  # is the 25s antipattern ai-mem-search documents. Scope is the vault root
@@ -1529,10 +1547,10 @@ ai-mem-lint() {
1529
1547
  known_file="$(mktemp)"
1530
1548
  find "$vault" -name '*.md' -not -path '*/.git/*' 2>/dev/null \
1531
1549
  | awk '{ sub(/.*\//, ""); sub(/\.md$/, ""); print }' > "$known_file"
1532
- local -a dangling
1533
- dangling=( ${(f)"$(find "$vault" -name '*.md' -not -path '*/.git/*' -exec awk -v kf="$known_file" '
1550
+ local unwritten
1551
+ unwritten="$(find "$vault" -name '*.md' -not -path '*/.git/*' -exec awk -v kf="$known_file" '
1534
1552
  FILENAME == kf { known[$0] = 1; next }
1535
- FNR == 1 { fence = 0; src = FILENAME; sub(/.*\//, "", src) }
1553
+ FNR == 1 { fence = 0 }
1536
1554
  /^[ \t]*(```|~~~)/ { fence = !fence; next }
1537
1555
  fence { next }
1538
1556
  {
@@ -1546,15 +1564,19 @@ ai-mem-lint() {
1546
1564
  if (t == "" || index(t, "{{")) continue
1547
1565
  b = t; sub(/.*\//, "", b)
1548
1566
  if ((t in known) || (b in known)) continue
1549
- print src " -> [[" t "]]"
1567
+ print t
1550
1568
  }
1551
- }' "$known_file" {} + 2>/dev/null)"} )
1569
+ }' "$known_file" {} + 2>/dev/null)"
1552
1570
  rm -f "$known_file"
1553
- local line
1554
- if (( $#dangling )); then
1555
- print -r -- "$#dangling dangling wikilink(s) -- a [[link]] that resolves to no note:"
1556
- for line in $dangling; do print -r -- " $line"; done
1557
- (( issues += $#dangling ))
1571
+ if [[ -n "$unwritten" ]]; then
1572
+ # Most-linked first, ties by name; the top 10 only, with the total.
1573
+ local n_links n_targets top
1574
+ n_links="$(print -r -- "$unwritten" | wc -l | tr -d ' ')"
1575
+ n_targets="$(print -r -- "$unwritten" | sort -u | wc -l | tr -d ' ')"
1576
+ top="$(print -r -- "$unwritten" | sort | uniq -c | sort -k1,1nr -k2 | head -10 \
1577
+ | awk '{ c = $1; sub(/^ *[0-9]+ /, ""); printf "%s[[%s]] %s", (NR > 1 ? ", " : ""), $0, c }')"
1578
+ print -r -- "note: $n_links link(s) to $n_targets note(s) not written yet. Not errors -- Obsidian creates a note when its link is clicked. Write the most-linked first; find where one is used with: ai-mem-search '[[name]]'"
1579
+ print -r -- " most linked: $top"
1558
1580
  fi
1559
1581
  if (( issues == 0 )); then
1560
1582
  print -r -- "ok: vault links are clean"