/context command always returns "Conversation file not found" when daemon CWD ≠ project directory
The /context Telegram and Discord commands fail with "Conversation file not found." whenever the ClaudeClaw daemon is not launched from the exact Claude Code project directory.
Root cause
Both src/commands/telegram.ts and src/commands/discord.ts construct the transcript path by converting the daemon's current working directory to a project slug:
// telegram.ts line 971 / discord.ts line 1006 const projectSlug = process.cwd().replace(/\//g, "-"); const jsonlPath = ${home}/.claude/projects/${projectSlug}/${session.sessionId}.jsonl;
The problem: process.cwd() reflects where the daemon process was launched from (e.g. /home/claw), not the Claude Code project directory (e.g. /home/claw/newsletter_manager). The resulting slug (-home-claw) doesn't match the actual project folder (-home-claw-newsletter-manager), so the file is never found.
To reproduce
- Start the ClaudeClaw daemon from any directory that isn't your exact Claude Code project root (e.g. launch it from ~ or via a systemd/cron job)
- Start a Claude Code session in a project subdirectory
- Send /context in Telegram or Discord
- Receive: Conversation file not found.
Expected behavior
/context correctly finds and reads the transcript regardless of where the daemon was launched from.
Fix
Instead of constructing the path from process.cwd(), scan all subdirectories under ~/.claude/projects/ for the session file:
const home = homedir(); const projectsRoot = ${home}/.claude/projects; let jsonlPath: string | null = null; if (existsSync(projectsRoot)) { const { readdirSync } = await import("fs"); for (const slug of readdirSync(projectsRoot)) { const candidate = ${projectsRoot}/${slug}/${session.sessionId}.jsonl; if (existsSync(candidate)) { jsonlPath = candidate; break; } } } if (!jsonlPath) { // send "Conversation file not found." error }
Apply the same fix in both src/commands/telegram.ts (around line 971) and src/commands/discord.ts (around line 1006).
Notes
• The session ID is already known from the session object, so scanning is reliable - it's just the project slug lookup that's broken
• The scan is cheap (typical user has <10 project directories)
• Tested and working locally on the patched cache files
/context command always returns "Conversation file not found" when daemon CWD ≠ project directory
The /context Telegram and Discord commands fail with "Conversation file not found." whenever the ClaudeClaw daemon is not launched from the exact Claude Code project directory.
Root cause
Both src/commands/telegram.ts and src/commands/discord.ts construct the transcript path by converting the daemon's current working directory to a project slug:
// telegram.ts line 971 / discord.ts line 1006 const projectSlug = process.cwd().replace(/\//g, "-"); const jsonlPath = ${home}/.claude/projects/${projectSlug}/${session.sessionId}.jsonl;The problem: process.cwd() reflects where the daemon process was launched from (e.g. /home/claw), not the Claude Code project directory (e.g. /home/claw/newsletter_manager). The resulting slug (-home-claw) doesn't match the actual project folder (-home-claw-newsletter-manager), so the file is never found.
To reproduce
Expected behavior
/context correctly finds and reads the transcript regardless of where the daemon was launched from.
Fix
Instead of constructing the path from process.cwd(), scan all subdirectories under ~/.claude/projects/ for the session file:
const home = homedir(); const projectsRoot = ${home}/.claude/projects; let jsonlPath: string | null = null; if (existsSync(projectsRoot)) { const { readdirSync } = await import("fs"); for (const slug of readdirSync(projectsRoot)) { const candidate = ${projectsRoot}/${slug}/${session.sessionId}.jsonl; if (existsSync(candidate)) { jsonlPath = candidate; break; } } } if (!jsonlPath) { // send "Conversation file not found." error }Apply the same fix in both src/commands/telegram.ts (around line 971) and src/commands/discord.ts (around line 1006).
Notes
• The session ID is already known from the session object, so scanning is reliable - it's just the project slug lookup that's broken
• The scan is cheap (typical user has <10 project directories)
• Tested and working locally on the patched cache files