create-ai-memory 0.15.2 → 0.15.4
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/bin/ai-mem-mcp.js +12 -4
- package/package.json +1 -1
- package/shell/ai-mem.zsh +14 -0
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
|
});
|
|
@@ -171,7 +176,7 @@ const TOOLS = [
|
|
|
171
176
|
description: 'The user\'s profile, standards, current project note, last session digest, and known lesson topics.',
|
|
172
177
|
inputSchema: {
|
|
173
178
|
type: 'object',
|
|
174
|
-
properties: { project: { type: 'string', description: 'Defaults to the
|
|
179
|
+
properties: { project: { type: 'string', description: 'Optional project. Defaults to the GUI global memory project.' } },
|
|
175
180
|
},
|
|
176
181
|
},
|
|
177
182
|
{
|
|
@@ -185,7 +190,7 @@ const TOOLS = [
|
|
|
185
190
|
},
|
|
186
191
|
{
|
|
187
192
|
name: 'add_note',
|
|
188
|
-
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.',
|
|
189
194
|
inputSchema: {
|
|
190
195
|
type: 'object',
|
|
191
196
|
properties: { text: { type: 'string', description: 'What to record.' } },
|
|
@@ -218,7 +223,7 @@ function callTool(name, args = {}) {
|
|
|
218
223
|
case 'search_memory':
|
|
219
224
|
return zsh(`ai-mem-search ${q(args.term)} ${args.project ? q(args.project) : ''}`);
|
|
220
225
|
case 'get_context':
|
|
221
|
-
return zsh(`ai-context ${
|
|
226
|
+
return zsh(`ai-context ${q(args.project || GUI_PROJECT)}`);
|
|
222
227
|
// ai-note and ai-lesson both push the vault themselves, so a GUI write is
|
|
223
228
|
// committed and backed up exactly like a terminal one -- no separate step
|
|
224
229
|
// for the model to forget.
|
|
@@ -264,6 +269,9 @@ function handle(req) {
|
|
|
264
269
|
if (id === undefined) return;
|
|
265
270
|
|
|
266
271
|
if (method === 'initialize') {
|
|
272
|
+
// Initialize is the GUI equivalent of a CLI launcher: create the globalized
|
|
273
|
+
// session log even if the model never remembers to call a tool first.
|
|
274
|
+
zsh(`ai-context ${q(GUI_PROJECT)} >/dev/null && print -r -- primed`);
|
|
267
275
|
return send({
|
|
268
276
|
jsonrpc: '2.0',
|
|
269
277
|
id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ai-memory",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
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
|
|