跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    10xChengTu

    Oc Goal

    v0.1.1其他
    oc-goal

    Goal mode (Codex-style thread goals) plugin for opencode

    GitHub 星标

    0

    月装机量

    316

    近 7 天 12

    综合评分SCORE

    34.0

    生态多维模型

    最近提交

    1 个月前

    2026-07-20

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["oc-goal@0.1.1"]
    }

    opencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    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: activecomplete (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 than active stops automatic continuation.
    • Loop engine: listens for the session.status idle 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's continuation.md).
    • Model tools: create_goal / get_goal / update_goal (update only accepts complete/blocked; pause/resume/budget are controlled by the user or system, same as Codex).
    • Budget accounting: incrementally accumulates (input - cache.read) + output + reasoning per assistant message; crossing the budget flips status to budget_limited and 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>.json and 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_goal to declare complete (requires passing the completion audit) or blocked (requires the same blocker for 3 consecutive turns).
    • Pressing Esc to interrupt any turn automatically pauses the goal; use /goal resume to 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