diff --git a/src/cli.ts b/src/cli.ts index f180d73..440d35c 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -160,6 +160,32 @@ program const st = await state.load(root) const sessions = Object.values(st.sessions) + // Discover prompts from Claude history for sessions that lack one + const needsPrompt = sessions.filter(s => !s.prompt) + if (needsPrompt.length > 0 && (await vm.status()) === "running") { + try { + const result = await vm.exec(homedir() + "/.sandlot", "cat /home/ubuntu/.claude/history.jsonl 2>/dev/null") + if (result.exitCode === 0 && result.stdout) { + const entries = result.stdout.split("\n").filter(Boolean).map(line => { + try { return JSON.parse(line) } catch { return null } + }).filter(Boolean) + + for (const s of needsPrompt) { + const cPath = vm.containerPath(s.worktree) + const match = entries.find((e: any) => e.project === cPath) + if (match?.display) { + s.prompt = match.display + } + } + } + } catch {} + } + + if (opts.json) { + console.log(JSON.stringify(sessions, null, 2)) + return + } + if (sessions.length === 0) { if (opts.json) console.log("[]") else console.log("◆ No active sessions.") diff --git a/src/vm.ts b/src/vm.ts index f6b6f2c..246e5b4 100644 --- a/src/vm.ts +++ b/src/vm.ts @@ -6,7 +6,7 @@ const USER = "ubuntu" const CLAUDE_BIN = `/home/${USER}/.local/bin/claude` /** Translate a host path to its corresponding container path. */ -function containerPath(hostPath: string): string { +export function containerPath(hostPath: string): string { const home = homedir() if (hostPath.startsWith(`${home}/.sandlot`)) { return "/sandlot" + hostPath.slice(`${home}/.sandlot`.length)