create-ai-memory 0.15.1 → 0.15.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 +4 -4
- package/bin/ai-mem-mcp.js +33 -4
- package/package.json +1 -1
- package/shell/ai-mem.zsh +14 -0
package/README.md
CHANGED
|
@@ -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
|
|
781
|
-
search before solving, write back after)
|
|
782
|
-
to suspect a memory exists. Tool
|
|
783
|
-
|
|
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.
|
package/bin/ai-mem-mcp.js
CHANGED
|
@@ -31,7 +31,10 @@ const { homedir } = require('node:os');
|
|
|
31
31
|
const readline = require('node:readline');
|
|
32
32
|
|
|
33
33
|
const MODULE = join(__dirname, '..', 'shell', 'ai-mem.zsh');
|
|
34
|
-
const
|
|
34
|
+
const VAULT_RAW = process.env.AI_MEM_ROOT || join(homedir(), '.ai-memory', '_Ai_Memory');
|
|
35
|
+
const VAULT = existsSync(VAULT_RAW) ? realpathSync(VAULT_RAW) : VAULT_RAW;
|
|
36
|
+
const GUI_PROJECT = process.env.AI_MEM_GUI_PROJECT || '_globalize_mem';
|
|
37
|
+
const GUI_ROOT = join(VAULT, GUI_PROJECT);
|
|
35
38
|
const VERSION = (() => {
|
|
36
39
|
try {
|
|
37
40
|
return JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8')).version;
|
|
@@ -59,6 +62,8 @@ function zsh(snippet) {
|
|
|
59
62
|
...process.env,
|
|
60
63
|
AI_MEM_ROOT: VAULT,
|
|
61
64
|
AI_MEM_NOTE_MAX_CHARS: process.env.AI_MEM_NOTE_MAX_CHARS ?? '0',
|
|
65
|
+
AI_MEM_FORCE_PROJECT: GUI_PROJECT,
|
|
66
|
+
AI_MEM_GLOBALIZE_ROOT: GUI_ROOT,
|
|
62
67
|
},
|
|
63
68
|
maxBuffer: 8 * 1024 * 1024,
|
|
64
69
|
});
|
|
@@ -74,6 +79,24 @@ function zsh(snippet) {
|
|
|
74
79
|
/** Shell-quote a value for safe interpolation into the zsh snippet. */
|
|
75
80
|
const q = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
|
|
76
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Read one fixed vault note for the MCP instruction block.
|
|
84
|
+
*
|
|
85
|
+
* GUI models do not reliably call `get_context` before acting. The global
|
|
86
|
+
* profile and standards are therefore included in `initialize`, while
|
|
87
|
+
* project/session context stays in `get_context` because it needs a project.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} rel vault-relative note path
|
|
90
|
+
* @returns {string}
|
|
91
|
+
*/
|
|
92
|
+
function readVaultNote(rel) {
|
|
93
|
+
try {
|
|
94
|
+
return readFileSync(join(VAULT, rel), 'utf8').trim();
|
|
95
|
+
} catch {
|
|
96
|
+
return `[missing: ${rel}]`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
77
100
|
/**
|
|
78
101
|
* Resolve a note path and refuse anything outside the vault.
|
|
79
102
|
*
|
|
@@ -113,6 +136,12 @@ function insideVault(p) {
|
|
|
113
136
|
const INSTRUCTIONS = [
|
|
114
137
|
"This is the user's persistent memory across every AI tool they use: past sessions, project decisions, and lessons learned the hard way.",
|
|
115
138
|
'',
|
|
139
|
+
'These global profile and standards are active instructions for this session:',
|
|
140
|
+
'--- _Global_Profile.md ---',
|
|
141
|
+
readVaultNote('_Global_Profile.md'),
|
|
142
|
+
'--- _Standards.md ---',
|
|
143
|
+
readVaultNote('_Standards.md'),
|
|
144
|
+
'',
|
|
116
145
|
'Before answering anything about their work, call get_context. It returns their profile, standards, the current project note, and what the last session concluded.',
|
|
117
146
|
'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.',
|
|
118
147
|
'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.',
|
|
@@ -147,7 +176,7 @@ const TOOLS = [
|
|
|
147
176
|
description: 'The user\'s profile, standards, current project note, last session digest, and known lesson topics.',
|
|
148
177
|
inputSchema: {
|
|
149
178
|
type: 'object',
|
|
150
|
-
properties: { project: { type: 'string', description: 'Defaults to the
|
|
179
|
+
properties: { project: { type: 'string', description: 'Optional project. Defaults to the GUI global memory project.' } },
|
|
151
180
|
},
|
|
152
181
|
},
|
|
153
182
|
{
|
|
@@ -161,7 +190,7 @@ const TOOLS = [
|
|
|
161
190
|
},
|
|
162
191
|
{
|
|
163
192
|
name: 'add_note',
|
|
164
|
-
description: 'Append a timestamped note to today\'s session log.
|
|
193
|
+
description: 'Append a timestamped note to today\'s session log. GUI calls without a project use the GUI global memory project.',
|
|
165
194
|
inputSchema: {
|
|
166
195
|
type: 'object',
|
|
167
196
|
properties: { text: { type: 'string', description: 'What to record.' } },
|
|
@@ -194,7 +223,7 @@ function callTool(name, args = {}) {
|
|
|
194
223
|
case 'search_memory':
|
|
195
224
|
return zsh(`ai-mem-search ${q(args.term)} ${args.project ? q(args.project) : ''}`);
|
|
196
225
|
case 'get_context':
|
|
197
|
-
return zsh(`ai-context ${
|
|
226
|
+
return zsh(`ai-context ${q(args.project || GUI_PROJECT)}`);
|
|
198
227
|
// ai-note and ai-lesson both push the vault themselves, so a GUI write is
|
|
199
228
|
// committed and backed up exactly like a terminal one -- no separate step
|
|
200
229
|
// for the model to forget.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ai-memory",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.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
|
@@ -272,6 +272,13 @@ __ai_mem_note_contents() {
|
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
__ai_mem_resolve_project() {
|
|
275
|
+
# GUI/MCP clients have no repository context, so callers may force a
|
|
276
|
+
# memory bucket explicitly. Normal terminal launchers leave this unset.
|
|
277
|
+
if [[ -n "${AI_MEM_FORCE_PROJECT:-}" ]]; then
|
|
278
|
+
print -r -- "$AI_MEM_FORCE_PROJECT"
|
|
279
|
+
return 0
|
|
280
|
+
fi
|
|
281
|
+
|
|
275
282
|
# Prefer the git repo we are actually standing in. Otherwise `cd`-ing between
|
|
276
283
|
# projects in one shell keeps a stale AI_MEM_ACTIVE_PROJECT pinned, so a later
|
|
277
284
|
# claude-start writes its log under the wrong project's folder.
|
|
@@ -297,6 +304,13 @@ __ai_mem_project_session_dir() {
|
|
|
297
304
|
project_name="$(__ai_mem_resolve_project)"
|
|
298
305
|
fi
|
|
299
306
|
|
|
307
|
+
# GUI/MCP global memory should appear as its own top-level subtree in
|
|
308
|
+
# Obsidian, not as one more child under project-scoped session logs.
|
|
309
|
+
if [[ -n "${AI_MEM_GLOBALIZE_ROOT:-}" && "$project_name" == "${AI_MEM_FORCE_PROJECT:-}" ]]; then
|
|
310
|
+
print -r -- "$AI_MEM_GLOBALIZE_ROOT/_session_logs"
|
|
311
|
+
return 0
|
|
312
|
+
fi
|
|
313
|
+
|
|
300
314
|
print -r -- "$AI_MEM_SESSION_DIR/$project_name"
|
|
301
315
|
}
|
|
302
316
|
|