feat: expose cross-session goal listing via `list_all_goals` tool
Summary
Currently, the plugin only exposes per-session goal access. There is no way for an agent (or user) to query goals across all sessions from within an OpenCode conversation. A list_all_goals agent tool would surface this data without requiring manual inspection of goals.json on disk.
Current Behavior
get_goal and get_goal_history both operate exclusively on the current session's ID, which is injected by the plugin framework as a closed-over value:
// server.ts (simplified)
get_goal: {
handler: async () => ({ goal: await getGoal(sessionID) })
}
// state.ts
export async function getGoal(sessionID: string) {
const state = await readState()
return state.goals[sessionID] ?? null
}
When called from a new session, these tools always return null — even when goals.json on disk contains multiple goal records from prior sessions.
Expected Behavior
An agent tool (e.g. list_all_goals) that returns all goal records stored in goals.json, regardless of which session created them. This would allow:
- Reviewing the status of long-running goals started in a previous session
- Identifying paused or blocked goals that need to be resumed
- Auditing goal history across an entire project workflow
Motivation
The underlying data already supports this. goals.json stores all goals keyed by sessionID:
{
"version": 1,
"goals": {
"ses1abc...": { "status": "active", "objective": "...", ... },
"ses1def...": { "status": "paused", "objective": "...", ... }
}
}
All goal records persist across sessions. The gap is purely at the API exposure layer — no tool or query interface exists to enumerate them.
Proposed API Surface
A minimal addition to state.ts and server.ts:
// state.ts
export async function getAllGoals() {
const state = await readState()
return Object.values(state.goals).map(snapshot)
}
// server.ts — new tool registration
list_all_goals: {
description: "List all goals across all sessions stored in the goal state file.",
handler: async () => ({ goals: await getAllGoals() })
}
Optional enhancements worth considering:
- Filter by
status(e.g. return onlyactiveorpausedgoals) - Sort by
updatedAtdescending - Pagination or a
limitparameter for large state files
Environment
- Package:
@prevalentware/opencode-goal-plugin - State storage:
goals.json(path viaOPENCODE_GOAL_STATE_PATHor XDG default) - OpenCode surfaces affected: TUI, desktop, web