create-ai-memory 0.11.2 → 0.12.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/package.json +1 -1
- package/shell/ai-mem.zsh +37 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ai-memory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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"
|
package/shell/ai-mem.zsh
CHANGED
|
@@ -11,6 +11,19 @@ AI_MEM_HOME="${0:A:h}"
|
|
|
11
11
|
# vault on first use so install.sh is optional (plugin-manager installs work).
|
|
12
12
|
AI_MEM_TEMPLATE_SRC="${AI_MEM_HOME:h}/vault-template"
|
|
13
13
|
|
|
14
|
+
# Fingerprint of the module files, recorded at source time and re-checked at
|
|
15
|
+
# launch. A shell keeps whatever function definitions it loaded at startup:
|
|
16
|
+
# editing these files, or upgrading the package, changes nothing in a
|
|
17
|
+
# terminal that is already open. That is a silent trap rather than an
|
|
18
|
+
# obvious one -- the launcher still runs, still reports success, and quietly
|
|
19
|
+
# uses whatever behaviour was current whenever this terminal was opened,
|
|
20
|
+
# which can be months. Comparing the two makes the staleness visible.
|
|
21
|
+
# cksum is POSIX, so this needs no macOS/Linux branch.
|
|
22
|
+
_ai_mem_fingerprint() {
|
|
23
|
+
cksum "$AI_MEM_HOME/ai-mem.zsh" "$AI_MEM_HOME/adapters.zsh" 2>/dev/null \
|
|
24
|
+
| awk '{ printf "%s-", $1 }'
|
|
25
|
+
}
|
|
26
|
+
export AI_MEM_SOURCED_FINGERPRINT="$(_ai_mem_fingerprint)"
|
|
14
27
|
# Vault root. Override in ~/.zshrc; defaults to a hidden dir under $HOME.
|
|
15
28
|
: "${AI_MEM_ROOT:=$HOME/.ai-memory/_Ai_Memory}"
|
|
16
29
|
if [[ -d "$AI_MEM_ROOT" ]]; then
|
|
@@ -450,6 +463,16 @@ _ai_session_start() {
|
|
|
450
463
|
shift
|
|
451
464
|
fi
|
|
452
465
|
|
|
466
|
+
# Warn (never block) if this shell is running a stale copy. Everything
|
|
467
|
+
# below would otherwise succeed quietly using the old behaviour, and the
|
|
468
|
+
# only symptom is a fix that appears not to have worked.
|
|
469
|
+
local _fp_now
|
|
470
|
+
_fp_now="$(_ai_mem_fingerprint)"
|
|
471
|
+
if [[ -n "$AI_MEM_SOURCED_FINGERPRINT" && -n "$_fp_now" \
|
|
472
|
+
&& "$_fp_now" != "$AI_MEM_SOURCED_FINGERPRINT" ]]; then
|
|
473
|
+
echo "ai-memory: this shell loaded an older copy of ai-mem; the files on disk have changed since." >&2
|
|
474
|
+
echo " Run 'source ~/.zshrc' or open a new terminal to pick up the current version." >&2
|
|
475
|
+
fi
|
|
453
476
|
local session_prompt="${*:-}"
|
|
454
477
|
|
|
455
478
|
# Fail fast with a clear message if the agent's CLI is missing, before a
|
|
@@ -732,11 +755,20 @@ ai-mem-search() {
|
|
|
732
755
|
# relevant one, so a large result set stays usable at a glance even without
|
|
733
756
|
# ranking. Sort key is the YYYY-MM-DD_HH-MM-SS embedded in the filename;
|
|
734
757
|
# lines with no such timestamp (e.g. _Global_Profile.md) sort last.
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
758
|
+
#
|
|
759
|
+
# One awk pass, not a shell loop. This used to spawn `grep -oE` AND `head`
|
|
760
|
+
# per matched line, which cost 25s for a common term on a 486-file vault
|
|
761
|
+
# -- while the grep that actually searched it took 0.16s. Measuring grep
|
|
762
|
+
# alone said this command was fast; measuring the command said otherwise.
|
|
763
|
+
# Interval syntax like {4} is avoided so this works on a stock BSD awk.
|
|
764
|
+
local sorted
|
|
765
|
+
sorted="$(print -r -- "$raw" | awk '
|
|
766
|
+
{
|
|
767
|
+
ts = "0000-00-00_00-00-00"
|
|
768
|
+
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]/))
|
|
769
|
+
ts = substr($0, RSTART, RLENGTH)
|
|
770
|
+
print ts "|" $0
|
|
771
|
+
}' | sort -r | cut -d'|' -f2-)"
|
|
740
772
|
|
|
741
773
|
# Bound the output. The consumer is normally an agent with a finite
|
|
742
774
|
# context window, and an unbounded dump is actively harmful there in a
|