Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions docs/public/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ The skill includes comprehensive diagnostics, automated repair sequences, and de
1. Check if worker is running on port 37777:
```bash
lsof -i :37777
# or
npm run worker:status
# or (from any directory)
npx claude-mem status
```

2. Verify worker is healthy:
Expand All @@ -43,19 +43,19 @@ The skill includes comprehensive diagnostics, automated repair sequences, and de

3. Check worker logs for errors:
```bash
npm run worker:logs
npx claude-mem logs
```

4. Restart worker service:
```bash
npm run worker:restart
npx claude-mem restart
```

5. Check for port conflicts:
```bash
# If port 37777 is in use by another service
export CLAUDE_MEM_WORKER_PORT=38000
npm run worker:restart
npx claude-mem restart
```

### Theme Toggle Not Persisting
Expand Down Expand Up @@ -101,7 +101,7 @@ The skill includes comprehensive diagnostics, automated repair sequences, and de

3. Verify worker is running:
```bash
npm run worker:status
npx claude-mem status
```

4. Check for network/proxy issues blocking SSE
Expand All @@ -110,7 +110,7 @@ The skill includes comprehensive diagnostics, automated repair sequences, and de

5. Restart worker and refresh browser:
```bash
npm run worker:restart
npx claude-mem restart
```

### Chroma/Python Dependency Issues (v5.0.0+)
Expand Down Expand Up @@ -181,23 +181,23 @@ The skill includes comprehensive diagnostics, automated repair sequences, and de

1. Check worker status:
```bash
npm run worker:status
npx claude-mem status
```

2. Try starting manually:
```bash
npm run worker:start
npx claude-mem start
```

3. Check worker logs for errors:
```bash
npm run worker:logs
npx claude-mem logs
```

4. Full reset:
```bash
npm run worker:stop
npm run worker:start
npx claude-mem stop
npx claude-mem start
```

5. Verify Bun is installed:
Expand Down Expand Up @@ -225,7 +225,7 @@ The skill includes comprehensive diagnostics, automated repair sequences, and de
3. Or use a different port:
```bash
export CLAUDE_MEM_WORKER_PORT=38000
npm run worker:restart
npx claude-mem restart
```

4. Verify new port:
Expand All @@ -241,12 +241,12 @@ The skill includes comprehensive diagnostics, automated repair sequences, and de

1. Check error logs:
```bash
npm run worker:logs
npx claude-mem logs
```

2. Check worker status:
```bash
npm run worker:status
npx claude-mem status
```

3. Check database for corruption:
Expand All @@ -267,12 +267,12 @@ The skill includes comprehensive diagnostics, automated repair sequences, and de

1. Check worker is running:
```bash
npm run worker:status
npx claude-mem status
```

2. Check worker logs:
```bash
npm run worker:logs
npx claude-mem logs
```

3. Verify database has observations:
Expand All @@ -282,7 +282,7 @@ The skill includes comprehensive diagnostics, automated repair sequences, and de

4. Restart worker:
```bash
npm run worker:restart
npx claude-mem restart
```

### Manual Recovery for Stuck Observations
Expand Down Expand Up @@ -385,7 +385,7 @@ Messages progress through these states:
2. Use the CLI tool for interactive sessions (provides feedback)
3. Use the HTTP API for automation/scripting
4. Start with a low session limit (5-10) to avoid overwhelming the worker
5. Monitor worker logs during recovery: `npm run worker:logs`
5. Monitor worker logs during recovery: `npx claude-mem logs`
6. Check recently processed messages to confirm recovery worked

#### Troubleshooting Recovery Issues
Expand Down Expand Up @@ -430,7 +430,7 @@ If recovery fails or messages remain stuck:

5. **Check worker logs for SDK errors**:
```bash
npm run worker:logs | grep -i error
npx claude-mem logs | grep -i error
```

#### Understanding the Queue Table
Expand Down Expand Up @@ -550,7 +550,7 @@ sqlite3 ~/.claude-mem/claude-mem.db "

2. Check worker is running (prevents timeout waiting for worker):
```bash
npm run worker:status
npx claude-mem status
```

3. Check database size (large database = slow queries):
Expand Down Expand Up @@ -596,7 +596,7 @@ sqlite3 ~/.claude-mem/claude-mem.db "

1. Close all connections:
```bash
npm run worker:stop
npx claude-mem stop
```

2. Check for stale locks:
Expand All @@ -611,7 +611,7 @@ sqlite3 ~/.claude-mem/claude-mem.db "

4. Restart worker:
```bash
npm run worker:start
npx claude-mem start
```

### Database Corruption
Expand All @@ -638,7 +638,7 @@ sqlite3 ~/.claude-mem/claude-mem.db "
4. Nuclear option - recreate database:
```bash
rm ~/.claude-mem/claude-mem.db
npm run worker:start # Will recreate schema
npx claude-mem start # Will recreate schema
```

### FTS5 Search Not Working
Expand Down Expand Up @@ -846,12 +846,12 @@ sqlite3 ~/.claude-mem/claude-mem.db "

1. Check current usage:
```bash
npm run worker:status
npx claude-mem status
```

2. Restart worker:
```bash
npm run worker:restart
npx claude-mem restart
```

3. Clean up old data (see "Database Too Large" above)
Expand Down Expand Up @@ -928,8 +928,8 @@ sqlite3 ~/.claude-mem/claude-mem.db "

```bash
export DEBUG=claude-mem:*
npm run worker:restart
npm run worker:logs
npx claude-mem restart
npx claude-mem logs
```

### Check Correlation IDs
Expand All @@ -949,10 +949,10 @@ sqlite3 ~/.claude-mem/claude-mem.db "

```bash
# Check if worker is running
npm run worker:status
npx claude-mem status

# View logs
npm run worker:logs
npx claude-mem logs

# Check port file
cat ~/.claude-mem/worker.port
Expand Down Expand Up @@ -988,7 +988,7 @@ SELECT created_at, tool_name FROM observations ORDER BY created_at DESC LIMIT 10

**Cause**: Worker not running or port mismatch.

**Solution**: Restart worker with `npm run worker:restart`.
**Solution**: Restart worker with `npx claude-mem restart`.

### "Database is locked"

Expand Down Expand Up @@ -1020,7 +1020,7 @@ If none of these solutions work:

1. **Check logs**:
```bash
npm run worker:logs
npx claude-mem logs
```

2. **Create issue**: [GitHub Issues](https://github.com/thedotmack/claude-mem/issues)
Expand Down
14 changes: 7 additions & 7 deletions openclaw/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ If claude-mem is installed as a Claude Code plugin (at `~/.claude/plugins/market

```bash
cd ~/.claude/plugins/marketplaces/thedotmack
npm run worker:restart
npx claude-mem restart
```

Verify:
Expand All @@ -90,15 +90,15 @@ curl http://localhost:37777/api/health

**Got `{"status":"ok"}`?** You're set. Skip to Step 3.

**Still not working?** Check `npm run worker:status` for error details, or check that bun is installed and on your PATH.
**Still not working?** Check `npx claude-mem status` for error details, or check that bun is installed and on your PATH.

#### If there's no Claude Code installation

Run the worker from the cloned repo:

```bash
cd /opt/claude-mem # wherever you cloned it
npm run worker:start
npx claude-mem start
```

Verify:
Expand All @@ -110,9 +110,9 @@ curl http://localhost:37777/api/health

**Still not working?** Debug steps:
- Check that bun is installed: `bun --version`
- Check the worker status: `npm run worker:status`
- Check the worker status: `npx claude-mem status`
- Check if something else is using port 37777: `lsof -i :37777`
- Check logs: `npm run worker:logs` (if available)
- Check logs: `npx claude-mem logs` (if available)
- Try running it directly to see errors: `bun plugin/scripts/worker-service.cjs start`

### Step 3: Add the Plugin to Your Gateway
Expand Down Expand Up @@ -418,8 +418,8 @@ A background service connects to the worker's SSE stream and forwards `new_obser
| Problem | What to check |
|---------|---------------|
| Worker health check fails | Is bun installed? (`bun --version`). Is something else on port 37777? (`lsof -i :37777`). Try running directly: `bun plugin/scripts/worker-service.cjs start` |
| Worker started from Claude Code install but not responding | Check `cd ~/.claude/plugins/marketplaces/thedotmack && npm run worker:status`. May need `npm run worker:restart`. |
| Worker started from cloned repo but not responding | Check `cd /path/to/claude-mem && npm run worker:status`. Make sure you ran `npm install && npm run build` first. |
| Worker started from Claude Code install but not responding | Check `cd ~/.claude/plugins/marketplaces/thedotmack && npx claude-mem status`. May need `npx claude-mem restart`. |
| Worker started from cloned repo but not responding | Check `cd /path/to/claude-mem && npx claude-mem status`. Make sure you ran `npm install && npm run build` first. |
| No context in agent system prompt | Check that `syncMemoryFile` is not set to `false`. Check that the agent's ID is not in `syncMemoryFileExclude`. Verify the worker is running and has observations. |
| Observations not being recorded | Check gateway logs for `[claude-mem]` messages. The worker must be running and reachable on localhost:37777. |
| Feed shows `disconnected` | Worker's `/stream` endpoint not reachable. Check `workerPort` matches the actual worker port. |
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"picocolors": "^1.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tree-sitter": "^0.25.0",
"yaml": "^2.8.2",
"zod-to-json-schema": "^3.24.6"
},
Expand Down
31 changes: 28 additions & 3 deletions src/services/worker/BranchManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import { execSync, spawnSync } from 'child_process';
import { existsSync, unlinkSync } from 'fs';
import { join } from 'path';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { logger } from '../../utils/logger.js';
import { MARKETPLACE_ROOT } from '../../shared/paths.js';

Expand Down Expand Up @@ -101,20 +102,44 @@ function execNpm(args: string[], timeoutMs: number = NPM_INSTALL_TIMEOUT_MS): st
return result.stdout.trim();
}

/**
* Detect if the plugin was installed via Claude Code's cache layout
* (e.g., ~/.claude/plugins/cache/thedotmack/claude-mem/<version>/) rather than git clone.
*
* NOTE: INSTALLED_PLUGIN_PATH is an alias for MARKETPLACE_ROOT which always
* resolves to ~/.claude/plugins/marketplaces/thedotmack — it never contains
* '/cache/'. We must check the actual runtime module path instead.
*/
function isCacheLayoutInstall(): boolean {
// Derive the actual path this module is running from at runtime
let runtimeDir: string;
if (typeof __dirname !== 'undefined') {
runtimeDir = __dirname;
} else {
runtimeDir = dirname(fileURLToPath(import.meta.url));
}

const normalizedRuntimePath = runtimeDir.replace(/\\/g, '/');
return normalizedRuntimePath.includes('/cache/thedotmack/claude-mem/');
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

/**
Comment on lines +112 to 126
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 isCacheLayoutInstall() always returns false

INSTALLED_PLUGIN_PATH is an alias for MARKETPLACE_ROOT, which is always computed as join(CLAUDE_CONFIG_DIR, 'plugins', 'marketplaces', 'thedotmack'). With the default CLAUDE_CONFIG_DIR of ~/.claude, the resulting path is ~/.claude/plugins/marketplaces/thedotmack — which never contains the substring /cache/thedotmack/claude-mem. The helpful "cache layout" error message will therefore never be shown; users will always see the generic fallback.

The detection should target the running package root (where this code actually executes) rather than the fixed installation target path. Checking getPackageRoot() would reflect whether the process was launched from a cache directory:

function isCacheLayoutInstall(): boolean {
  const normalizedPath = getPackageRoot().replace(/\\/g, '/');
  return normalizedPath.includes('/cache/thedotmack/claude-mem');
}

Fix in Claude Code

* Get current branch information
*/
export function getBranchInfo(): BranchInfo {
// Check if git repo exists
const gitDir = join(INSTALLED_PLUGIN_PATH, '.git');
if (!existsSync(gitDir)) {
const isCacheLayout = isCacheLayoutInstall();
return {
branch: null,
isBeta: false,
isGitRepo: false,
isDirty: false,
canSwitch: false,
error: 'Installed plugin is not a git repository'
error: isCacheLayout
? 'Plugin installed via cache layout. Use `npx claude-mem install` or Claude Code plugin UI to update.'
: 'Installed plugin is not a git repository'
};
}

Expand Down Expand Up @@ -262,7 +287,7 @@ export async function pullUpdates(): Promise<SwitchResult> {
if (!info.isGitRepo || !info.branch) {
return {
success: false,
error: 'Cannot pull updates: not a git repository'
error: info.error || 'Cannot pull updates: not a git repository'
};
}

Expand Down
Loading
Loading