fix(ralph-loop): generate transcript path from sessionID instead of relying on event properties (#355)

OpenCode doesn't pass transcriptPath in the session.idle event properties,
which caused detectCompletionPromise to always return false (the first check
returns early if transcriptPath is undefined).

This fix:
- Imports getTranscriptPath from claude-code-hooks/transcript
- Generates the transcript path from sessionID instead of reading from event
- Adds optional getTranscriptPath callback to RalphLoopOptions for testability

Fixes #354

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
Sisyphus
2025-12-30 23:08:30 +09:00
committed by GitHub
parent e3040ecb28
commit a295202a81
3 changed files with 11 additions and 5 deletions

View File

@@ -329,17 +329,19 @@ describe("ralph-loop", () => {
test("should detect completion promise and stop loop", async () => {
// #given - active loop with transcript containing completion
const hook = createRalphLoopHook(createMockPluginInput())
const transcriptPath = join(TEST_DIR, "transcript.jsonl")
const hook = createRalphLoopHook(createMockPluginInput(), {
getTranscriptPath: () => transcriptPath,
})
hook.startLoop("session-123", "Build something", { completionPromise: "COMPLETE" })
const transcriptPath = join(TEST_DIR, "transcript.jsonl")
writeFileSync(transcriptPath, JSON.stringify({ content: "Task done <promise>COMPLETE</promise>" }))
// #when - session goes idle with transcript
// #when - session goes idle (transcriptPath now derived from sessionID via getTranscriptPath)
await hook.event({
event: {
type: "session.idle",
properties: { sessionID: "session-123", transcriptPath },
properties: { sessionID: "session-123" },
},
})