Enrich session list with prompts from Claude history for sessions missing one
This commit is contained in:
parent
25d2de5348
commit
ff086cd4d2
21
src/cli.ts
21
src/cli.ts
|
|
@ -160,6 +160,27 @@ 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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user