create-ai-memory 0.14.0 → 0.14.1

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 +49 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ai-memory",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
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
@@ -279,6 +279,31 @@ __ai_mem_ensure_vault() {
279
279
  cp "$src" "$dst"
280
280
  fi
281
281
  done
282
+
283
+ # Seeding only fills in a MISSING file, which is right -- these are the
284
+ # user's notes and templates, and an upgrade must not overwrite edits they
285
+ # made. But that leaves an existing vault on whatever templates it had
286
+ # when it was created: `npm update` never touches them, and neither does
287
+ # install.sh. The session log template is the one where that silently
288
+ # matters, because every future log is copied from it -- a template with
289
+ # no `type:` rebuilds a backlog of non-conforming notes one session at a
290
+ # time, and nothing surfaces it.
291
+ #
292
+ # So repair exactly that one field, additively, and leave everything else
293
+ # in the file alone. This runs on session prep, so an existing install
294
+ # heals on its next launch rather than waiting for someone to think to run
295
+ # ai-mem-lint --fix.
296
+ local tmpl="$AI_MEM_SESSION_DIR/_session_template.md"
297
+ if [[ -f "$tmpl" ]] && ! grep -qm1 '^type: ' "$tmpl"; then
298
+ __ai_mem_guard "$tmpl" || return 1
299
+ local tmp="$tmpl.aimem-upgrade"
300
+ if [[ "$(head -1 "$tmpl")" == "---" ]]; then
301
+ { head -1 "$tmpl"; print -r -- "type: ai-session-log"; tail -n +2 "$tmpl"; } > "$tmp"
302
+ else
303
+ { print -rl -- "---" "type: ai-session-log" "---" ""; cat "$tmpl"; } > "$tmp"
304
+ fi
305
+ mv "$tmp" "$tmpl"
306
+ fi
282
307
  }
283
308
 
284
309
  __ai_mem_prepare_session() {
@@ -825,6 +850,30 @@ ai-mem-lint() {
825
850
  fi
826
851
  done < <(find "$AI_MEM_PROJECT_DIR" -maxdepth 1 -name "*.md" -print0 2>/dev/null)
827
852
 
853
+ # The template is skipped by the loop above, and rightly -- it is not a
854
+ # note. But it is what every future log is copied from, so a template
855
+ # without `type:` quietly re-creates the whole backlog one session at a
856
+ # time. An existing install keeps its own copy of the template and never
857
+ # picks up a newer one, so fixing the shipped file is not enough.
858
+ local tmpl="$AI_MEM_SESSION_DIR/_session_template.md"
859
+ if [[ -f "$tmpl" ]] && ! grep -qm1 '^type: ' "$tmpl"; then
860
+ if (( fix )); then
861
+ __ai_mem_guard "$tmpl" >/dev/null && {
862
+ local ttmp="$tmpl.aimem-backfill"
863
+ if [[ "$(head -1 "$tmpl")" == "---" ]]; then
864
+ { head -1 "$tmpl"; print -r -- "type: ai-session-log"; tail -n +2 "$tmpl"; } > "$ttmp"
865
+ else
866
+ { print -rl -- "---" "type: ai-session-log" "---" ""; cat "$tmpl"; } > "$ttmp"
867
+ fi
868
+ mv "$ttmp" "$tmpl"
869
+ print -r -- "added \`type:\` to the session log template, so new logs carry it"
870
+ }
871
+ else
872
+ print -r -- "the session log template has no \`type:\` field, so every new log will lack one. Fix with: ai-mem-lint --fix"
873
+ (( issues++ ))
874
+ fi
875
+ fi
876
+
828
877
  if (( $#untyped_files )); then
829
878
  if (( fix )); then
830
879
  # Written by hand rather than with `sed -i`, whose in-place flag