oc-goalGoal mode (Codex-style thread goals) plugin for opencode
0
316
12 in 7 days
34.0
Multi-signal model
1 month ago
2026-07-20
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["oc-goal@0.1.1"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["oc-goal@0.1.1"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D oc-goalopencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
oc-goal
Adds Goal Mode to opencode, modeled after OpenAI Codex's thread goals (/goal).
Set a goal, and the agent automatically starts a new turn after every turn ends, keeping up the work until the objective is verifiably complete, the token budget is exhausted, or you pause it manually.
How it works (aligned with Codex)
- State machine:
active→complete(declared by the model) /blocked(same blocker for 3 consecutive goal turns) /paused(user pause or Esc interrupt) /budget_limited(token budget exhausted) /usage_limited(API rate limit). Anything other thanactivestops automatic continuation. - Loop engine: listens for the
session.statusidle event → if the goal is still active, automatically starts a new turn with a hidden synthetic message. The message contains the objective, token usage/remaining, and the Completion audit + Blocked audit instructions (ported from Codex'scontinuation.md). - Model tools:
create_goal/get_goal/update_goal(update only acceptscomplete/blocked; pause/resume/budget are controlled by the user or system, same as Codex). - Budget accounting: incrementally accumulates
(input - cache.read) + output + reasoningper assistant message; crossing the budget flips status tobudget_limitedand injects a one-time wrap-up notice (soft stop, the turn is not hard-killed). - Loop safety: turn errors →
blocked; API rate limits →usage_limited; Esc interrupt →paused. - State is persisted to
~/.local/share/opencode/oc-goal/<project-id>.jsonand survives restarts and compaction (the goal is injected into the compaction summary context).
Installation
Add the plugin to your global ~/.config/opencode/opencode.json (or a project-level opencode.json) — opencode installs it automatically, no manual download needed:
{
"plugin": ["oc-goal"]
}
Alternative (from source): clone this repo, run npm install, then reference the file directly:
{
"plugin": ["file:///absolute/path/oc-goal/src/index.ts"]
}
You can also copy or symlink src/index.ts to ~/.config/opencode/plugins/goal.ts (make sure @opencode-ai/plugin is resolvable).
Usage
/goal <objective> Set a goal and start working on it immediately (replaces any existing goal)
/goal Show current goal status (status also works)
/goal pause Pause automatic continuation
/goal resume Resume (from paused/blocked/usage_limited)
/goal budget 500000 Set a token budget
/goal budget none Remove the budget
/goal clear Clear the goal
While a goal is active:
- After every turn, the agent automatically continues until the model calls
update_goalto declarecomplete(requires passing the completion audit) orblocked(requires the same blocker for 3 consecutive turns). - Pressing Esc to interrupt any turn automatically pauses the goal; use
/goal resumeto continue. - When the budget is exhausted, continuation stops automatically and you're prompted to raise it with
/goal budget <n>and then/goal resume.
Development
npm run typecheck