@vaur94/opencode2-goal
v0.3.0
Published
Evidence-checked autonomous Goal loop for OpenCode V2.
Downloads
448
Readme
opencode2-goal
Persistent autonomous Goal loop for OpenCode V2.
Behavior
/goal <objective>sets or replaces the current session goal and starts its continuation loop./goal statusshows it./goal pause,/goal resume, and/goal clearmanage the loop.- An explicit user Stop/interrupt pauses the active goal; shutdown and superseded executions keep it active for recovery.
- Active goals are injected as system context on every model turn.
- After every successful or failed execution boundary, a synthetic continuation wakes the agent again.
- The agent may mark a goal completed only after auditing its objective and constraints against concrete files, commands, tests, logs, benchmarks, or artifacts.
- Completion evidence is stored with the completed goal; confidence, narration, todo status, or partial progress alone are insufficient.
- Active loops restart when the plugin reloads or the service restarts.
- There are no round limits, token budgets, or time budgets; completion is an evidence-audited model decision.
- The loop continues until evidence supports completion or the user pauses, clears, or interrupts it.
The /goal command is model-mediated by OpenCode V2. Lifecycle mutations are
implemented by one non-CodeMode goal_manage tool. User-controlled lifecycle
actions remain user-controlled; the agent receives only the additional authority
to call complete with an evidence ledger. Continuations are durable
synthetic session inputs; they retain the selected agent, model, permissions,
and safety rules. State is stored per session under
${XDG_STATE_HOME:-~/.local/state}/opencode2-goal/sessions.
Backend API
The plugin also starts an authenticated loopback backend for trusted local clients such as
opencode2-web. Its random endpoint and bearer credential are written with mode 0600 to
${XDG_STATE_HOME:-~/.local/state}/opencode2-goal/backend.json. The credential must remain in
the bridge process and must never be sent to a browser.
GET /v1/goalsreturns all persisted goals and process-lifetime telemetry counters.GET /v1/goals/:sessionIDreturns one goal.POST /v1/goals/:sessionIDacceptsset,update,pause,stop,resume, orclear.GET /v1/eventsstreams snapshots, lifecycle changes, and execution telemetry over SSE.
pause and stop both immediately pause the goal and interrupt its current execution without
deleting state. update interrupts the old execution, replaces the objective, and immediately
wakes the loop. resume also wakes the loop without waiting for another session event.
Plugin options apiPort and apiDiscoveryFile can override the random port and discovery path.
Development
bun install
bun run checkLocal loading
Add the built bundle as its own entry in opencode.json:
{
"plugins": [
"/home/ugur/Projects/opencode2-goal/dist/plugin.js"
]
}The plugin owns /goal and the exposed goal_manage tool.
