2026-03-13 12:43:33 +09:00
|
|
|
import type { PluginInput } from "@opencode-ai/plugin"
|
2026-04-05 17:15:17 +09:00
|
|
|
import { getPlanProgress, readBoulderState } from "../../features/boulder-state"
|
2026-03-13 12:43:33 +09:00
|
|
|
import type { BoulderState, PlanProgress } from "../../features/boulder-state"
|
|
|
|
|
|
|
|
|
|
export async function resolveActiveBoulderSession(input: {
|
|
|
|
|
client: PluginInput["client"]
|
|
|
|
|
directory: string
|
|
|
|
|
sessionID: string
|
|
|
|
|
}): Promise<{
|
|
|
|
|
boulderState: BoulderState
|
|
|
|
|
progress: PlanProgress
|
|
|
|
|
appendedSession: boolean
|
|
|
|
|
} | null> {
|
|
|
|
|
const boulderState = readBoulderState(input.directory)
|
|
|
|
|
if (!boulderState) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 17:15:17 +09:00
|
|
|
if (!boulderState.session_ids.includes(input.sessionID)) {
|
2026-03-13 12:43:33 +09:00
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 17:15:17 +09:00
|
|
|
const progress = getPlanProgress(boulderState.active_plan)
|
|
|
|
|
if (progress.isComplete) {
|
|
|
|
|
return { boulderState, progress, appendedSession: false }
|
2026-03-13 12:43:33 +09:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 17:15:17 +09:00
|
|
|
return { boulderState, progress, appendedSession: false }
|
2026-03-13 12:43:33 +09:00
|
|
|
}
|