create-ai-memory 0.11.2 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/shell/ai-mem.zsh +14 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ai-memory",
3
- "version": "0.11.2",
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
@@ -732,11 +732,20 @@ ai-mem-search() {
732
732
  # relevant one, so a large result set stays usable at a glance even without
733
733
  # ranking. Sort key is the YYYY-MM-DD_HH-MM-SS embedded in the filename;
734
734
  # lines with no such timestamp (e.g. _Global_Profile.md) sort last.
735
- local sorted ts
736
- sorted="$(print -r -- "$raw" | while IFS= read -r line; do
737
- 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)"
738
- print -r -- "${ts:-0000-00-00_00-00-00}|${line}"
739
- done | sort -r | cut -d'|' -f2-)"
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-)"
740
749
 
741
750
  # Bound the output. The consumer is normally an agent with a finite
742
751
  # context window, and an unbounded dump is actively harmful there in a