create-ai-memory 0.11.1 → 0.11.3

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
@@ -276,7 +276,7 @@ optional. Set `AI_MEM_ROOT` in `~/.zshrc` first if you do not want the default
276
276
  | `ai-note <text>` | Append a timestamped note to today's session log while you work |
277
277
  | `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
278
  | `ai-mem-lint` | Check the vault's links: orphaned session logs, dangling `previous` links, unreferenced project notes |
279
- | `ai-mem-search <term> [project]` | Grep across the vault (or one project's logs) for a term, with `file:line:excerpt`. Also resolves any `[[wikilink]]` on a matched line to its project note and shows a short excerpt -- one hop out along the graph, always on, not a flag to remember |
279
+ | `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 |
280
280
  | `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
281
 
282
282
  Project is auto-resolved from the current git repo; pass a name to override.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ai-memory",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
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"
package/shell/ai-mem.zsh CHANGED
@@ -308,7 +308,7 @@ $previous_session_block
308
308
  Use the Obsidian vault as the persistent memory layer.
309
309
  Treat the global profile and standards note as the shared baseline for every run.
310
310
  Keep durable preferences and project facts in the vault, and keep the active session log updated with decisions, blockers, and next steps.
311
- For anything not covered above -- a decision from further back, a different project, a health check on the vault's links -- run \`ai-mem-search <term> [project]\` or \`ai-mem-lint\` yourself; both are plain shell commands already on PATH.
311
+ For anything not covered above -- a decision from further back, a different project, a health check on the vault's links -- run \`ai-mem-search <term> [project]\` or \`ai-mem-lint\` yourself; both are plain shell commands already on PATH. Search is case-insensitive and matches literally, and its output is capped: if it reports results hidden, narrow with a project argument or a more specific term rather than assuming you have seen everything. Start broad and narrow from there -- a first query that is too specific is the usual way to miss what you were looking for.
312
312
  When you hit a mistake, decision, or solution worth remembering across projects (not just this one), run \`ai-lesson <topic-slug> <problem> <solution>\` -- e.g. \`ai-lesson rate-limiting "a fixed-window limiter kept losing bursts of legitimate traffic" "switched to a token bucket, which absorbs bursts correctly"\`. It appends a dated Problem/Solution entry to a cross-project note at _lessons/<topic-slug>.md; ai-mem-search already covers it.
313
313
  EOF
314
314
  }
@@ -711,8 +711,17 @@ ai-mem-search() {
711
711
  fi
712
712
  fi
713
713
 
714
+ # -i: a case-sensitive default silently returns a confident "no matches"
715
+ # for a term the vault genuinely holds under different casing. Measured on
716
+ # a real vault: `precompact` found 0 case-sensitively and 3 with -i;
717
+ # `Postgres` 56 vs 90. A false empty state is the worst possible answer
718
+ # from a memory tool, because it is indistinguishable from the truth --
719
+ # and the explicit empty-state message below is exactly what makes it
720
+ # look authoritative.
721
+ # -F: the caller is usually an agent passing a free-text term, where a
722
+ # stray . ( | must match literally rather than as a regex metacharacter.
714
723
  local raw
715
- raw="$(grep -rn --exclude-dir=.git --exclude='_session_template.md' --exclude='_project_template.md' --exclude='_lesson_template.md' -- "$term" "$search_root" 2>/dev/null)"
724
+ raw="$(grep -rniF --exclude-dir=.git --exclude='_session_template.md' --exclude='_project_template.md' --exclude='_lesson_template.md' -- "$term" "$search_root" 2>/dev/null)"
716
725
 
717
726
  if [[ -z "$raw" ]]; then
718
727
  print -r -- "no matches for '$term' in $search_root"
@@ -723,15 +732,48 @@ ai-mem-search() {
723
732
  # relevant one, so a large result set stays usable at a glance even without
724
733
  # ranking. Sort key is the YYYY-MM-DD_HH-MM-SS embedded in the filename;
725
734
  # lines with no such timestamp (e.g. _Global_Profile.md) sort last.
726
- local sorted ts
727
- sorted="$(print -r -- "$raw" | while IFS= read -r line; do
728
- ts="$(print -r -- "$line" | grep -oE '[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}' | head -1)"
729
- print -r -- "${ts:-0000-00-00_00-00-00}|${line}"
730
- done | sort -r | cut -d'|' -f2-)"
731
-
732
- print -r -- "$sorted"
735
+ #
736
+ # One awk pass, not a shell loop. This used to spawn `grep -oE` AND `head`
737
+ # per matched line, which cost 25s for a common term on a 486-file vault
738
+ # -- while the grep that actually searched it took 0.16s. Measuring grep
739
+ # alone said this command was fast; measuring the command said otherwise.
740
+ # Interval syntax like {4} is avoided so this works on a stock BSD awk.
741
+ local sorted
742
+ sorted="$(print -r -- "$raw" | awk '
743
+ {
744
+ ts = "0000-00-00_00-00-00"
745
+ if (match($0, /[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]_[0-9][0-9]-[0-9][0-9]-[0-9][0-9]/))
746
+ ts = substr($0, RSTART, RLENGTH)
747
+ print ts "|" $0
748
+ }' | sort -r | cut -d'|' -f2-)"
749
+
750
+ # Bound the output. The consumer is normally an agent with a finite
751
+ # context window, and an unbounded dump is actively harmful there in a
752
+ # way it is not for a human who skims: a common term produced ~29k
753
+ # tokens on a real vault, overflowing the host's tool-response cap and
754
+ # getting silently truncated, so the agent could not tell "hidden" from
755
+ # "absent". Near-miss padding is also the most damaging kind of
756
+ # distractor for a model, so fewer, cleaner hits beat more of them.
757
+ # Count goes FIRST -- the reader needs the size of the result set before
758
+ # the result set, not after it.
759
+ local total limit
760
+ total="$(print -r -- "$raw" | wc -l | tr -d ' ')"
761
+ limit="${AI_MEM_SEARCH_LIMIT:-40}"
762
+
763
+ print -r -- "$total match(es) for '$term'"
764
+ print -r -- "paths below $search_root"
733
765
  print -r -- "--"
734
- print -r -- "$(print -r -- "$raw" | wc -l | tr -d ' ') match(es) for '$term'"
766
+ # Strip the repeated vault root (a third to a half of all output bytes on
767
+ # a real vault, with zero information lost -- it is printed once above)
768
+ # and clamp very long lines, which are common in prose notes.
769
+ print -r -- "$sorted" | head -n "$limit" \
770
+ | sed "s|^${search_root}/||" \
771
+ | awk '{ if (length($0) > 200) print substr($0, 1, 200) " [...]"; else print }'
772
+
773
+ if (( total > limit )); then
774
+ print -r -- "--"
775
+ print -r -- "showing $limit of $total ($(( total - limit )) hidden) -- narrow with: ai-mem-search '$term' <project>, or raise AI_MEM_SEARCH_LIMIT"
776
+ fi
735
777
  # One hop out: resolve [[wikilinks]] found on matched lines to their
736
778
  # target note (currently: project notes only -- the confirmed use case
737
779
  # is a _lessons entry linking the project(s) it hit) and show a short