create-ai-memory 0.15.0 → 0.15.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
@@ -466,7 +466,7 @@ that can grow without limit is a cost that compounds silently.
466
466
 
467
467
  | what reaches the prompt | bound |
468
468
  |---|---|
469
- | Profile and standards | **8,000 chars** each (`AI_MEM_NOTE_MAX_CHARS`) |
469
+ | Profile and standards | **8,000 chars** each for shell launchers; GUI MCP is uncapped by default (`AI_MEM_NOTE_MAX_CHARS`) |
470
470
  | Previous session outcome | 4 fields, 500 chars each |
471
471
  | Lesson index | 200 slugs, names only |
472
472
  | Project note | **a path, not its contents** |
@@ -777,10 +777,10 @@ Six tools, read **and** write, so a GUI session is not a dead end:
777
777
  implementation, not a copy that drifts. A note written from Claude Desktop is
778
778
  committed and pushed exactly like one written in a terminal.
779
779
 
780
- MCP's `instructions` field carries a standing brief (read context first,
781
- search before solving, write back after) — without it a model has no reason
782
- to suspect a memory exists. Tool descriptions stay terse because schemas are
783
- re-sent every turn: six tools cost ~429 tokens/turn, the brief ~290 once.
780
+ The MCP initialization response carries the global profile and standards, plus
781
+ a standing brief (read context first, search before solving, write back after)
782
+ -- without it a model has no reason to suspect a memory exists. Tool
783
+ descriptions stay terse because schemas are re-sent every turn.
784
784
 
785
785
  **Do not register this for a terminal agent.** Claude Code, Codex, Gemini and
786
786
  opencode have a shell and should call `ai-mem-search` directly.
@@ -850,7 +850,7 @@ git -C <repo> config core.hooksPath .githooks
850
850
  | `AI_MEM_AGENTS` | `claude codex agy gemini cursor opencode` | Space-separated agents to generate `-start` functions for |
851
851
  | `AI_MEM_SKILLS` / `AI_MEM_SKILL_ORDER` | empty | Your per-session skills (see above) |
852
852
  | `AI_MEM_LESSON_INDEX_LIMIT` | `200` | Lesson slugs listed in the launch prompt before it truncates to the newest. Names only -- bodies are never injected |
853
- | `AI_MEM_NOTE_MAX_CHARS` | `8000` | Cap on what one inlined note contributes to the launch prompt. Truncation states the real total and the path. `0` disables it |
853
+ | `AI_MEM_NOTE_MAX_CHARS` | `8000` for shell launchers; `0` for GUI MCP | Cap on what one inlined note contributes to the launch prompt. Truncation states the real total and the path. `0` disables it |
854
854
  | `AI_MEM_SEARCH_LIMIT` | `25` | Result lines `ai-mem-search` prints before it truncates. The default is sized for an agent's context window; raise it when you are reading the output yourself (see [How search works](#how-search-works)) |
855
855
  | `AI_MEM_HOME` | the module's own directory | Exported by the module when it is sourced, not set by you. A cron job, a launchd agent or any non-interactive shell can re-source the module with `zsh -c 'source "$AI_MEM_HOME/ai-mem.zsh"; ...'` instead of a hard-coded path |
856
856
  | `AI_MEM_SEARCH_PER_FILE` | `1` | Lines shown per file once the cap binds. Spreads results across notes instead of on the chattiest one; ignored when every match already fits |
package/bin/ai-mem-mcp.js CHANGED
@@ -53,7 +53,13 @@ const VERSION = (() => {
53
53
  function zsh(snippet) {
54
54
  const r = spawnSync('zsh', ['-c', `source ${JSON.stringify(MODULE)} >/dev/null 2>&1\n${snippet}`], {
55
55
  encoding: 'utf8',
56
- env: { ...process.env, AI_MEM_ROOT: VAULT },
56
+ // GUI context must include the complete profile and standards by default.
57
+ // Callers can still set AI_MEM_NOTE_MAX_CHARS to restore a smaller cap.
58
+ env: {
59
+ ...process.env,
60
+ AI_MEM_ROOT: VAULT,
61
+ AI_MEM_NOTE_MAX_CHARS: process.env.AI_MEM_NOTE_MAX_CHARS ?? '0',
62
+ },
57
63
  maxBuffer: 8 * 1024 * 1024,
58
64
  });
59
65
  if (r.error) return { ok: false, text: `failed to run zsh: ${r.error.message}` };
@@ -68,6 +74,24 @@ function zsh(snippet) {
68
74
  /** Shell-quote a value for safe interpolation into the zsh snippet. */
69
75
  const q = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
70
76
 
77
+ /**
78
+ * Read one fixed vault note for the MCP instruction block.
79
+ *
80
+ * GUI models do not reliably call `get_context` before acting. The global
81
+ * profile and standards are therefore included in `initialize`, while
82
+ * project/session context stays in `get_context` because it needs a project.
83
+ *
84
+ * @param {string} rel vault-relative note path
85
+ * @returns {string}
86
+ */
87
+ function readVaultNote(rel) {
88
+ try {
89
+ return readFileSync(join(VAULT, rel), 'utf8').trim();
90
+ } catch {
91
+ return `[missing: ${rel}]`;
92
+ }
93
+ }
94
+
71
95
  /**
72
96
  * Resolve a note path and refuse anything outside the vault.
73
97
  *
@@ -107,6 +131,12 @@ function insideVault(p) {
107
131
  const INSTRUCTIONS = [
108
132
  "This is the user's persistent memory across every AI tool they use: past sessions, project decisions, and lessons learned the hard way.",
109
133
  '',
134
+ 'These global profile and standards are active instructions for this session:',
135
+ '--- _Global_Profile.md ---',
136
+ readVaultNote('_Global_Profile.md'),
137
+ '--- _Standards.md ---',
138
+ readVaultNote('_Standards.md'),
139
+ '',
110
140
  'Before answering anything about their work, call get_context. It returns their profile, standards, the current project note, and what the last session concluded.',
111
141
  'Before solving a problem, call search_memory -- they may have solved it already, and repeating a solved mistake is the failure this vault exists to prevent. Search broadly first; too specific a first query is the usual way to miss something.',
112
142
  'When you hit a blocker -- an error you do not understand, an unclear failure, or a second failed attempt at the same thing -- search again before guessing. Lessons rank above session logs, so a hit under _lessons/ is the recorded fix.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ai-memory",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
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
@@ -444,7 +444,8 @@ __ai_mem_prepare_session() {
444
444
  project_session_dir="$(__ai_mem_project_session_dir "$project_name")"
445
445
  local previous_session_note=""
446
446
  previous_session_note="$(__ai_mem_latest_session_log "$project_name")" || return 1
447
- local session_note="$project_session_dir/${project_name}-$(date +%Y-%m-%d_%H-%M-%S).md"
447
+ local session_stamp="$(date +%Y-%m-%d_%H-%M-%S)"
448
+ local session_note="$project_session_dir/${project_name}-${session_stamp}.md"
448
449
 
449
450
  __ai_mem_guard "$project_note" || return 1
450
451
  __ai_mem_guard "$session_note" || return 1
@@ -456,13 +457,29 @@ __ai_mem_prepare_session() {
456
457
  "$AI_MEM_PROJECT_DIR/_project_template.md" > "$project_note"
457
458
  fi
458
459
 
460
+ # A blank note with this second's timestamp belongs to a separate session.
461
+ # Wait for the next timestamp instead of overwriting its previous-session
462
+ # link. A note with Live Notes is the active GUI/CLI session and must be
463
+ # reused.
464
+ if [[ -f "$session_note" ]] && ! grep -q '^### Live Notes' "$session_note" 2>/dev/null; then
465
+ while [[ -f "$session_note" ]]; do
466
+ sleep 1
467
+ session_stamp="$(date +%Y-%m-%d_%H-%M-%S)"
468
+ session_note="$project_session_dir/${project_name}-${session_stamp}.md"
469
+ done
470
+ fi
471
+
459
472
  local prev_link=""
460
473
  if [[ -n "$previous_session_note" ]]; then
461
474
  prev_link="[[${previous_session_note:t:r}]]"
462
475
  fi
463
476
 
464
- SESSION_DATE="$(date +%Y-%m-%d)" PROJECT_NAME="$project_name" PREV_LINK="$prev_link" perl -0pe 's/\{\{date\}\}/$ENV{SESSION_DATE}/g; s/\{\{project_name\}\}/$ENV{PROJECT_NAME}/g; s/\{\{previous_session_link\}\}/$ENV{PREV_LINK}/g' \
465
- "$AI_MEM_SESSION_DIR/_session_template.md" > "$session_note"
477
+ # Context reads can follow a GUI write in the same second. Reusing an
478
+ # existing timestamped note preserves Live Notes and any other append.
479
+ if [[ ! -f "$session_note" ]]; then
480
+ SESSION_DATE="$(date +%Y-%m-%d)" PROJECT_NAME="$project_name" PREV_LINK="$prev_link" perl -0pe 's/\{\{date\}\}/$ENV{SESSION_DATE}/g; s/\{\{project_name\}\}/$ENV{PROJECT_NAME}/g; s/\{\{previous_session_link\}\}/$ENV{PREV_LINK}/g' \
481
+ "$AI_MEM_SESSION_DIR/_session_template.md" > "$session_note"
482
+ fi
466
483
 
467
484
  export AI_MEM_ACTIVE_PROJECT="$project_name"
468
485
  export AI_MEM_PREVIOUS_SESSION_LOG="$previous_session_note"