@audaxic/memory-claude 1.0.2 → 1.0.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/install.js CHANGED
@@ -22,8 +22,9 @@ const PACKAGE_ROOT = join(__dirname, "..");
22
22
  const CONFIG_DIR = join(homedir(), ".config", "audaxic");
23
23
  const CONFIG_PATH = join(CONFIG_DIR, "config.json");
24
24
  const PLUGIN_DEST = join(homedir(), ".claude", "skills", "audaxic-memory");
25
+ const MCP_ENDPOINT = "https://memory-mcp.audaxic.com/mcp";
25
26
 
26
- const DIRS_TO_COPY = [".claude-plugin", "hooks", "scripts"];
27
+ const DIRS_TO_COPY = [".claude-plugin", "hooks", "scripts", "skills"];
27
28
 
28
29
  async function pathExists(p) {
29
30
  try {
@@ -48,6 +49,17 @@ async function copyDir(src, dest) {
48
49
  }
49
50
  }
50
51
 
52
+ async function loadApiKey() {
53
+ try {
54
+ const raw = await readFile(CONFIG_PATH, "utf-8");
55
+ const config = JSON.parse(raw);
56
+ if (typeof config.apiKey === "string" && config.apiKey.length > 0) {
57
+ return config.apiKey;
58
+ }
59
+ } catch {}
60
+ return null;
61
+ }
62
+
51
63
  async function ensureApiKeyFile(rl) {
52
64
  if (await pathExists(CONFIG_PATH)) return;
53
65
  console.log(
@@ -67,6 +79,25 @@ async function ensureApiKeyFile(rl) {
67
79
  console.log("✓ API key saved to ~/.config/audaxic/config.json");
68
80
  }
69
81
 
82
+ async function writeMcpConfig(apiKey) {
83
+ const mcpConfig = {
84
+ mcpServers: {
85
+ "audaxic-memory": {
86
+ type: "http",
87
+ url: MCP_ENDPOINT,
88
+ headers: {
89
+ Authorization: `Bearer ${apiKey}`,
90
+ },
91
+ },
92
+ },
93
+ };
94
+ await writeFile(
95
+ join(PLUGIN_DEST, ".mcp.json"),
96
+ JSON.stringify(mcpConfig, null, 2),
97
+ { mode: 0o600 }
98
+ );
99
+ }
100
+
70
101
  async function main() {
71
102
  console.log("\n╔══════════════════════════════════════════╗");
72
103
  console.log("║ Audaxic Memory — Claude Code Setup ║");
@@ -93,14 +124,26 @@ async function main() {
93
124
  await rm(destDir, { recursive: true, force: true });
94
125
  await copyDir(join(PACKAGE_ROOT, dir), destDir);
95
126
  }
127
+
128
+ const apiKey = await loadApiKey();
129
+ if (!apiKey) {
130
+ console.error(
131
+ "\nError: API key missing. Run setup again to configure it."
132
+ );
133
+ process.exit(1);
134
+ }
135
+ await writeMcpConfig(apiKey);
136
+
96
137
  console.log("✓ Plugin files copied to ~/.claude/skills/audaxic-memory/");
138
+ console.log("✓ MCP server configured (memory-mcp.audaxic.com)");
97
139
 
98
140
  console.log("\n╔══════════════════════════════════════════╗");
99
141
  console.log("║ Setup Complete! ║");
100
142
  console.log("╚══════════════════════════════════════════╝\n");
101
143
  console.log("Audaxic Memory is now active in Claude Code.");
102
- console.log(" • UserPromptSubmit → searches memory + injects context");
103
- console.log(" • Stop → buffers messages + auto-flushes at 30");
144
+ console.log(" • Skill → auto-searches memory for your questions");
145
+ console.log(" • MCP tools → search_memories / add_memory");
146
+ console.log(" • Hooks → buffers messages + auto-flushes at 30");
104
147
  console.log("\nThe plugin auto-loads on your next Claude Code session.");
105
148
  console.log("If the API key prompt doesn't appear, the key from");
106
149
  console.log("~/.config/audaxic/config.json will be used automatically.\n");
package/hooks/hooks.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "type": "command",
8
8
  "command": "node",
9
9
  "args": ["${CLAUDE_PLUGIN_ROOT}/scripts/inject.mjs"],
10
- "timeout": 10
10
+ "timeout": 20
11
11
  }
12
12
  ]
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audaxic/memory-claude",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Claude Code plugin for Audaxic Memory — automatically saves conversation facts and injects semantic context",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,8 @@
10
10
  "bin",
11
11
  ".claude-plugin",
12
12
  "hooks",
13
- "scripts"
13
+ "scripts",
14
+ "skills"
14
15
  ],
15
16
  "keywords": [
16
17
  "claude",
@@ -1,12 +1,18 @@
1
- import { readFile, writeFile, mkdir } from "node:fs/promises";
1
+ import { readFile, writeFile, mkdir, appendFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { homedir } from "node:os";
4
+ import { setDefaultResultOrder } from "node:dns";
5
+
6
+ setDefaultResultOrder("ipv4first");
4
7
 
5
8
  const API_BASE = "https://api.memory.audaxic.com";
6
9
  const CONFIG_PATH = join(homedir(), ".config", "audaxic", "config.json");
7
10
  const BUFFER_DIR =
8
11
  process.env.CLAUDE_PLUGIN_DATA || join(homedir(), ".claude", "audaxic");
9
12
  const BUFFER_PATH = join(BUFFER_DIR, "buffer.json");
13
+ const LOG_PATH = join(BUFFER_DIR, "hook.log");
14
+ const SEARCH_TIMEOUT_MS = 8000;
15
+ const SEARCH_ATTEMPTS = 2;
10
16
 
11
17
  async function readStdin() {
12
18
  const chunks = [];
@@ -16,6 +22,17 @@ async function readStdin() {
16
22
  return JSON.parse(Buffer.concat(chunks).toString("utf-8"));
17
23
  }
18
24
 
25
+ async function logFailure(message) {
26
+ try {
27
+ await mkdir(BUFFER_DIR, { recursive: true });
28
+ await appendFile(
29
+ LOG_PATH,
30
+ `${new Date().toISOString()} ${message}\n`,
31
+ "utf-8"
32
+ );
33
+ } catch {}
34
+ }
35
+
19
36
  async function loadApiKey() {
20
37
  const envKey = process.env.CLAUDE_PLUGIN_OPTION_API_TOKEN;
21
38
  if (envKey && envKey.trim()) return envKey.trim();
@@ -47,9 +64,9 @@ async function writeBuffer(buffer) {
47
64
  });
48
65
  }
49
66
 
50
- async function searchMemory(apiKey, query) {
67
+ async function searchOnce(apiKey, query) {
51
68
  const controller = new AbortController();
52
- const timeout = setTimeout(() => controller.abort(), 5000);
69
+ const timeout = setTimeout(() => controller.abort(), SEARCH_TIMEOUT_MS);
53
70
 
54
71
  try {
55
72
  const response = await fetch(`${API_BASE}/search`, {
@@ -62,17 +79,31 @@ async function searchMemory(apiKey, query) {
62
79
  signal: controller.signal,
63
80
  });
64
81
 
65
- if (!response.ok) return [];
82
+ if (!response.ok) {
83
+ await logFailure(`search http ${response.status} for: ${query.slice(0, 80)}`);
84
+ return null;
85
+ }
66
86
 
67
87
  const data = await response.json();
68
88
  return Array.isArray(data.results) ? data.results : [];
69
- } catch {
70
- return [];
89
+ } catch (error) {
90
+ await logFailure(
91
+ `search error ${error?.message || String(error)} for: ${query.slice(0, 80)}`
92
+ );
93
+ return null;
71
94
  } finally {
72
95
  clearTimeout(timeout);
73
96
  }
74
97
  }
75
98
 
99
+ async function searchMemory(apiKey, query) {
100
+ for (let attempt = 0; attempt < SEARCH_ATTEMPTS; attempt++) {
101
+ const results = await searchOnce(apiKey, query);
102
+ if (results !== null) return results;
103
+ }
104
+ return [];
105
+ }
106
+
76
107
  function outputJson(obj) {
77
108
  process.stdout.write(JSON.stringify(obj));
78
109
  }
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: audaxic-memory
3
+ description: Use when the user asks about past decisions, preferences, projects, learned patterns, or anything from previous conversations, or when storing user preferences, project decisions, and learned patterns to persistent memory.
4
+ ---
5
+
6
+ # Audaxic Memory
7
+
8
+ Audaxic is the user's persistent memory layer. Use the connected Audaxic memory MCP tools to retrieve and store facts across all their AI coding agents (Claude Code, Codex, OpenCode).
9
+
10
+ ## Behavioral Triggers
11
+
12
+ ### AUTO-SEARCH before answering:
13
+ - Questions about the user's projects, plugins, decisions, or preferences ("what did I decide...", "what is the name of...", "which approach did I choose...")
14
+ - Making architectural decisions
15
+ - Adding new dependencies
16
+ - Fixing bugs (check for prior solutions)
17
+ - Starting new sessions (load preferences)
18
+
19
+ When a trigger matches, call the Audaxic memory search tool (`mcp__audaxic-memory__search_memories`, which may appear as `mcp__plugin_audaxic-memory_audaxic-memory__search_memories`) with the user's question as the query, then use the results to answer directly.
20
+
21
+ ### AUTO-SAVE after:
22
+ - User states a preference
23
+ - Decision with rationale made
24
+ - Complex bug fixed
25
+ - Project conventions learned
26
+
27
+ When a trigger matches, call `add_memory` with the fact as text.
28
+
29
+ ### DO NOT save:
30
+ - Temporary state, debug info, secrets
31
+
32
+ ## MCP Tools
33
+
34
+ - `search_memories` — query (required), user_id?, limit? — semantic search over stored memories
35
+ - `add_memory` — text (required), user_id?, metadata? — store one fact
36
+ - `get_memories` — user_id?, limit? — list stored memories
37
+
38
+ ## Content Rules
39
+
40
+ - One fact per memory
41
+ - Natural language, not keywords
42
+ - Include reasoning, not just outcomes
43
+ - Be specific for better semantic matching
44
+
45
+ ## Lifecycle
46
+
47
+ Add → Search → Update (delete + re-add) → Delete (when obsolete)