get-claudia 1.40.0 → 1.40.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.
- package/memory-daemon/claudia_memory/__main__.py +14 -4
- package/package.json +1 -1
- package/template-v2/.claude/hooks/hooks.json +3 -3
- package/template-v2/.claude/hooks/session-health-check.py +20 -4
- package/template-v2/.claude/hooks/session-health-check.sh +4 -4
- package/template-v2/.claude/rules/memory-availability.md +51 -0
- package/template-v2/.claude/skills/diagnose/SKILL.md +24 -1
|
@@ -180,11 +180,21 @@ def run_daemon(mcp_mode: bool = True, debug: bool = False, project_id: str = Non
|
|
|
180
180
|
if project_id:
|
|
181
181
|
logger.info(f"Project isolation enabled: {project_id}")
|
|
182
182
|
|
|
183
|
-
# Acquire lockfile before touching the database -- prevents concurrent
|
|
184
|
-
# daemon instances from both writing to the same SQLite file, which is
|
|
185
|
-
# the root cause of "database disk image is malformed" errors.
|
|
186
183
|
config = get_config()
|
|
187
|
-
|
|
184
|
+
|
|
185
|
+
if not mcp_mode:
|
|
186
|
+
# Only enforce singleton for the standalone background daemon.
|
|
187
|
+
# The lock prevents two long-running background processes from
|
|
188
|
+
# concurrently running scheduled jobs (decay, consolidation) against
|
|
189
|
+
# the same SQLite file, which caused "database disk image is malformed"
|
|
190
|
+
# errors.
|
|
191
|
+
#
|
|
192
|
+
# MCP servers are ephemeral, session-bound processes spawned by Claude
|
|
193
|
+
# Code. They must NOT compete for the same lock as a running standalone
|
|
194
|
+
# daemon (e.g., installed via LaunchAgent/systemd). SQLite WAL mode
|
|
195
|
+
# handles concurrent read/write access safely across processes.
|
|
196
|
+
_acquire_daemon_lock(Path(config.db_path).parent / "claudia.lock")
|
|
197
|
+
|
|
188
198
|
_check_and_repair_database(Path(config.db_path))
|
|
189
199
|
|
|
190
200
|
# Set up signal handlers
|
package/package.json
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
],
|
|
15
15
|
"on_missing_me": "trigger_onboarding",
|
|
16
16
|
"memory_verification": {
|
|
17
|
-
"step_1_check_tools": "BEFORE anything else, verify you have access to
|
|
17
|
+
"step_1_check_tools": "BEFORE anything else, verify you have access to mcp__claudia-memory__* tools (check your available tools list). If no memory tools are available: (1) Do NOT fall back to plugin:episodic-memory, mcp__plugin_episodic-memory_*, or any other memory search tool as a substitute — these give inferior, unrelated results and mask the real problem. (2) Tell the user: 'My memory tools are not registered in this session. The daemon likely just auto-restarted — please restart Claude Code (close and reopen the window) to reconnect. Your context files are preserved.' (3) Continue with context files only (context/me.md, etc.) until restarted.",
|
|
18
18
|
"step_2_health_check": "Call memory.session (operation=\"context\"). If it fails or returns an error, the daemon may be crashed. Suggest: 'Memory daemon may need restart. Check: curl http://localhost:3848/health'",
|
|
19
|
-
"fallback": "If
|
|
19
|
+
"fallback": "If mcp__claudia-memory__* tools are not available: (1) Do NOT use plugin:episodic-memory or any other memory search tool as a substitute. (2) Tell the user: 'My memory tools are not registered in this session. The daemon may have just restarted — please restart Claude Code to reconnect. Your context files are preserved.' (3) Read context files directly (context/me.md, context/commitments.md, context/learnings.md, context/patterns.md, context/waiting.md) as the fallback. Make clear to the user they are in degraded mode with no semantic search or cross-session learning."
|
|
20
20
|
},
|
|
21
21
|
"enhanced_memory": {
|
|
22
22
|
"context_load": "Call memory.session (operation=\"context\") to get a formatted context block with recent memories, commitments, and unsummarized session alerts.",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
],
|
|
75
75
|
"notes": {
|
|
76
76
|
"implementation": "These hooks define intended behaviors. Claude Code will execute them as behavioral guidelines rather than traditional script execution.",
|
|
77
|
-
"memory_verification": "CRITICAL: At session start, verify
|
|
77
|
+
"memory_verification": "CRITICAL: At session start, verify mcp__claudia-memory__* tools are available BEFORE proceeding. If tools don't appear, do NOT use plugin:episodic-memory as a substitute. Tell the user to restart Claude Code — the daemon auto-restarts but MCP tools only register at session start. Fall back to context files only (context/me.md, etc.) in the meantime.",
|
|
78
78
|
"session_start": "At session start: (1) Verify memory tools available, (2) Call memory.session (operation=\"context\"), (3) Read context files, (4) Check for unsummarized sessions. If me.md is missing, trigger onboarding.",
|
|
79
79
|
"session_end": "Before session ends, Claudia should generate a session summary (enhanced memory) or update context files (markdown fallback). The summary includes both a free-form narrative and structured extractions.",
|
|
80
80
|
"first_run": "The absence of context/me.md signals a first-run scenario requiring onboarding.",
|
|
@@ -102,9 +102,17 @@ def check_health():
|
|
|
102
102
|
pass
|
|
103
103
|
if restarted:
|
|
104
104
|
status_msg = _get_status_summary()
|
|
105
|
-
msg =
|
|
105
|
+
msg = (
|
|
106
|
+
"IMPORTANT: Memory daemon was stopped and has been auto-restarted. "
|
|
107
|
+
"However, the memory MCP tools (mcp__claudia-memory__*) are NOT available in this session "
|
|
108
|
+
"because MCP tools connect at session start, before the restart happened. "
|
|
109
|
+
"Tell the user: 'The memory daemon was just restarted. Please restart Claude Code "
|
|
110
|
+
"(close and reopen the window) to reconnect your memory tools. "
|
|
111
|
+
"Your context files are preserved.' "
|
|
112
|
+
"Do NOT use plugin:episodic-memory as a substitute."
|
|
113
|
+
)
|
|
106
114
|
if status_msg:
|
|
107
|
-
msg = f"{msg} {status_msg}"
|
|
115
|
+
msg = f"{msg} Daemon status: {status_msg}"
|
|
108
116
|
print(json.dumps({"additionalContext": msg}))
|
|
109
117
|
return
|
|
110
118
|
context_parts.append(
|
|
@@ -138,9 +146,17 @@ def check_health():
|
|
|
138
146
|
pass
|
|
139
147
|
if restarted:
|
|
140
148
|
status_msg = _get_status_summary()
|
|
141
|
-
msg =
|
|
149
|
+
msg = (
|
|
150
|
+
"IMPORTANT: Memory daemon was stopped and has been auto-restarted. "
|
|
151
|
+
"However, the memory MCP tools (mcp__claudia-memory__*) are NOT available in this session "
|
|
152
|
+
"because MCP tools connect at session start, before the restart happened. "
|
|
153
|
+
"Tell the user: 'The memory daemon was just restarted. Please restart Claude Code "
|
|
154
|
+
"(close and reopen the window) to reconnect your memory tools. "
|
|
155
|
+
"Your context files are preserved.' "
|
|
156
|
+
"Do NOT use plugin:episodic-memory as a substitute."
|
|
157
|
+
)
|
|
142
158
|
if status_msg:
|
|
143
|
-
msg = f"{msg} {status_msg}"
|
|
159
|
+
msg = f"{msg} Daemon status: {status_msg}"
|
|
144
160
|
print(json.dumps({"additionalContext": msg}))
|
|
145
161
|
return
|
|
146
162
|
context_parts.append(
|
|
@@ -79,9 +79,9 @@ except Exception:
|
|
|
79
79
|
pass
|
|
80
80
|
" <<< "$STATUS_JSON" 2>/dev/null)
|
|
81
81
|
fi
|
|
82
|
-
MSG="Memory daemon was stopped
|
|
82
|
+
MSG="IMPORTANT: Memory daemon was stopped and has been auto-restarted. However, the memory MCP tools (mcp__claudia-memory__*) are NOT available in this session because MCP tools connect at session start, before the restart happened. Tell the user: 'The memory daemon was just restarted. Please restart Claude Code (close and reopen the window) to reconnect your memory tools. Your context files are preserved.' Do NOT use plugin:episodic-memory as a substitute."
|
|
83
83
|
if [ -n "$STATUS_SUMMARY" ]; then
|
|
84
|
-
MSG="$MSG $STATUS_SUMMARY"
|
|
84
|
+
MSG="$MSG Daemon status: $STATUS_SUMMARY"
|
|
85
85
|
fi
|
|
86
86
|
STATUS_ESC=$(echo "$MSG" | sed 's/"/\\"/g')
|
|
87
87
|
echo "{\"additionalContext\": \"$STATUS_ESC\"}"
|
|
@@ -116,9 +116,9 @@ except Exception:
|
|
|
116
116
|
pass
|
|
117
117
|
" <<< "$STATUS_JSON" 2>/dev/null)
|
|
118
118
|
fi
|
|
119
|
-
MSG="Memory daemon was stopped
|
|
119
|
+
MSG="IMPORTANT: Memory daemon was stopped and has been auto-restarted. However, the memory MCP tools (mcp__claudia-memory__*) are NOT available in this session because MCP tools connect at session start, before the restart happened. Tell the user: 'The memory daemon was just restarted. Please restart Claude Code (close and reopen the window) to reconnect your memory tools. Your context files are preserved.' Do NOT use plugin:episodic-memory as a substitute."
|
|
120
120
|
if [ -n "$STATUS_SUMMARY" ]; then
|
|
121
|
-
MSG="$MSG $STATUS_SUMMARY"
|
|
121
|
+
MSG="$MSG Daemon status: $STATUS_SUMMARY"
|
|
122
122
|
fi
|
|
123
123
|
STATUS_ESC=$(echo "$MSG" | sed 's/"/\\"/g')
|
|
124
124
|
echo "{\"additionalContext\": \"$STATUS_ESC\"}"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Memory Availability Rule
|
|
2
|
+
|
|
3
|
+
This rule is always active and applies to every session.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## When Memory Tools Are Missing
|
|
8
|
+
|
|
9
|
+
If `mcp__claudia-memory__*` tools are **not listed in your available tools**, follow these rules strictly:
|
|
10
|
+
|
|
11
|
+
### Do NOT substitute with other memory tools
|
|
12
|
+
|
|
13
|
+
Do not use any of the following as a replacement for missing memory tools:
|
|
14
|
+
- `plugin:episodic-memory` / `mcp__plugin_episodic-memory_*`
|
|
15
|
+
- Any other cross-session memory or search tool not in the `mcp__claudia-memory__*` family
|
|
16
|
+
|
|
17
|
+
These tools access a different, unrelated memory system. Using them gives the user the wrong memories, masks the real connectivity problem, and creates confusion about what Claudia actually knows.
|
|
18
|
+
|
|
19
|
+
### Do tell the user clearly
|
|
20
|
+
|
|
21
|
+
Say something like:
|
|
22
|
+
|
|
23
|
+
> "My memory tools aren't connected in this session. The daemon is likely running but the MCP connection isn't registered yet. To fix this, restart Claude Code (close and reopen the window). Your context files are preserved and I can work from those in the meantime."
|
|
24
|
+
|
|
25
|
+
### Do fall back to context files only
|
|
26
|
+
|
|
27
|
+
Read the following files directly as the fallback:
|
|
28
|
+
- `context/me.md`
|
|
29
|
+
- `context/commitments.md`
|
|
30
|
+
- `context/learnings.md`
|
|
31
|
+
- `context/patterns.md`
|
|
32
|
+
- `context/waiting.md`
|
|
33
|
+
|
|
34
|
+
Make clear to the user they are in degraded mode: no semantic search, no pattern detection, no cross-session learning. This is the honest and correct behavior.
|
|
35
|
+
|
|
36
|
+
### The fix is one action
|
|
37
|
+
|
|
38
|
+
The user only needs to do one thing: **restart Claude Code**. The daemon auto-restarts via launchctl/systemctl. There is no command to type. Just close and reopen the Claude Code window.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Why This Matters
|
|
43
|
+
|
|
44
|
+
The most common cause of missing memory tools is not a crashed daemon but a **registration timing issue**: the daemon was restarted (auto or manually) after the current Claude Code session started. MCP tools connect at session initialization, not dynamically. The daemon is up; the tools just aren't registered yet.
|
|
45
|
+
|
|
46
|
+
Silently using `plugin:episodic-memory` as a fallback:
|
|
47
|
+
1. Gives the wrong data (different memory system, different scope)
|
|
48
|
+
2. Makes it look like memory is working when it isn't
|
|
49
|
+
3. Prevents the user from knowing they need to restart
|
|
50
|
+
|
|
51
|
+
Always be transparent about the degraded state.
|
|
@@ -63,7 +63,7 @@ Use the appropriate command set below (macOS/Linux or Windows).
|
|
|
63
63
|
**macOS/Linux:**
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
-
# Check if daemon process is running
|
|
66
|
+
# Check if daemon process is running (and whether in standalone mode)
|
|
67
67
|
ps aux | grep claudia_memory | grep -v grep
|
|
68
68
|
|
|
69
69
|
# Check health endpoint
|
|
@@ -75,6 +75,11 @@ tail -20 ~/.claudia/daemon-stderr.log 2>/dev/null || echo "No daemon log found"
|
|
|
75
75
|
# Check database exists and has data
|
|
76
76
|
ls -la ~/.claudia/memory/*.db 2>/dev/null || echo "No database found"
|
|
77
77
|
sqlite3 ~/.claudia/memory/claudia.db "SELECT COUNT(*) as memories FROM memories; SELECT COUNT(*) as entities FROM entities;" 2>/dev/null || echo "Cannot query database"
|
|
78
|
+
|
|
79
|
+
# Check for standalone/MCP conflict (pre-v1.36 issue)
|
|
80
|
+
# If you see a process with --standalone AND no MCP tools, this is the cause
|
|
81
|
+
STANDALONE_RUNNING=$(ps aux | grep "claudia_memory.*standalone" | grep -v grep | wc -l | tr -d ' ')
|
|
82
|
+
echo "Standalone daemon processes: $STANDALONE_RUNNING"
|
|
78
83
|
```
|
|
79
84
|
|
|
80
85
|
**Windows (PowerShell):**
|
|
@@ -188,6 +193,24 @@ powershell -ExecutionPolicy Bypass -File memory-daemon\scripts\install.ps1
|
|
|
188
193
|
2. Restart Claude Code (this restarts the MCP server)
|
|
189
194
|
3. Check logs: `Get-Content -Tail 50 "$env:USERPROFILE\.claudia\daemon-stderr.log"`
|
|
190
195
|
|
|
196
|
+
### Issue: Standalone daemon running but MCP tools not registered (pre-v1.36)
|
|
197
|
+
|
|
198
|
+
**Symptoms:** Daemon process running with `--standalone`, health endpoint healthy, 0 memory tools in Claude Code
|
|
199
|
+
|
|
200
|
+
**Cause (pre-v1.36):** The LaunchAgent/systemd service starts the daemon with `--standalone`, which acquires a singleton lock. When Claude Code spawns the MCP server, it hits the same lock, sees another daemon running, and exits immediately (exit code 0). Claude Code sees the clean exit and thinks the MCP server started, but no tools register.
|
|
201
|
+
|
|
202
|
+
**Fix:** Upgrade Claudia to v1.36+ where this conflict is resolved:
|
|
203
|
+
```bash
|
|
204
|
+
npx get-claudia .
|
|
205
|
+
```
|
|
206
|
+
After upgrading, restart Claude Code. The MCP server no longer competes with the standalone daemon's lock.
|
|
207
|
+
|
|
208
|
+
**If upgrade isn't possible:** Restart Claude Code. If tools still don't register, stop the standalone daemon temporarily:
|
|
209
|
+
```bash
|
|
210
|
+
launchctl unload ~/Library/LaunchAgents/com.claudia.memory.plist
|
|
211
|
+
```
|
|
212
|
+
Then restart Claude Code (which will spawn the MCP server cleanly). Note: background jobs won't run until you reload the LaunchAgent.
|
|
213
|
+
|
|
191
214
|
### Issue: .mcp.json uses wrong entry point
|
|
192
215
|
|
|
193
216
|
**Detection:** Check the `args` array in `.mcp.json` for the `claudia-memory` server. If it says `claudia_memory.mcp.server` instead of `claudia_memory`, it bypasses project isolation, the health server, and background scheduling.
|