@prevalentware/opencode-goal-plugin 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,10 +18,10 @@ The OpenCode Goal Plugin adds:
18
18
 
19
19
  - `/goal <objective>` as an OpenCode command for TUI, desktop, and web.
20
20
  - A sidebar goal indicator with status, elapsed time, and objective.
21
- - Agent tools: `get_goal`, `create_goal`, `set_goal`, `update_goal`, and `clear_goal`.
21
+ - Agent tools: `get_goal`, `get_goal_history`, `create_goal`, `set_goal`, `update_goal_objective`, `update_goal`, and `clear_goal`.
22
22
  - Goal close evidence: `complete` requires verified evidence, and `unmet` requires a concrete blocker.
23
- - Persistent per-session goal state.
24
- - Optional automatic continuation on `session.idle`.
23
+ - Persistent per-session goal state with history, checkpoints, budgets, and owner-only file permissions.
24
+ - Optional automatic continuation on `session.idle` / `session.status`, with no-progress pause and budget wrap-up safeguards.
25
25
  - Compaction context so active goals are preserved when OpenCode summarizes a long session.
26
26
 
27
27
  ## Why Use This OpenCode Goal Plugin?
@@ -83,7 +83,12 @@ Server options can be configured in `opencode.json`:
83
83
  {
84
84
  "auto_continue": true,
85
85
  "max_auto_turns": 25,
86
- "min_continue_interval_seconds": 3
86
+ "min_continue_interval_seconds": 3,
87
+ "max_prompt_failures": 3,
88
+ "default_token_budget": 200000,
89
+ "max_goal_duration_seconds": 1800,
90
+ "no_progress_token_threshold": 50,
91
+ "max_no_progress_turns": 2
87
92
  }
88
93
  ]
89
94
  ]
@@ -95,6 +100,11 @@ Defaults:
95
100
  - `auto_continue`: `true`
96
101
  - `max_auto_turns`: `25`
97
102
  - `min_continue_interval_seconds`: `3`
103
+ - `max_prompt_failures`: `3`
104
+ - `default_token_budget`: unset by default; when set, new goals inherit this token budget.
105
+ - `max_goal_duration_seconds`: unset by default; when set, new goals inherit this elapsed-time safety limit.
106
+ - `no_progress_token_threshold`: `50`
107
+ - `max_no_progress_turns`: `2`
98
108
  - `register_command`: `true`
99
109
  - `command_name`: `"goal"`
100
110
 
@@ -106,7 +116,7 @@ Use `/goal <objective>` in a fresh OpenCode chat to create a long-running goal:
106
116
  /goal review the frontend and translate visible English UI text to Spanish
107
117
  ```
108
118
 
109
- Bare `/goal` reports the current goal state. `/goal clear` clears the goal. The TUI also includes a `Goal` command-palette entry for viewing, refreshing, or clearing the current goal state without creating a new goal.
119
+ Bare `/goal` reports the current goal state. `/goal history` reports lifecycle history and recent checkpoints. `/goal edit <objective>` updates the current objective. `/goal pause` pauses the goal without clearing it, and `/goal resume` resumes it. `/goal clear` clears the goal; `/goal stop`, `/goal off`, `/goal reset`, `/goal none`, and `/goal cancel` are clear aliases. The TUI also includes a `Goal` command-palette entry for viewing, refreshing, pausing, resuming, showing history, or clearing the current goal state without creating a new goal.
110
120
 
111
121
  You can also ask the agent to formulate the objective and call `set_goal` itself, for example: "set your own goal to finish this refactor safely." The tool uses the agent-written objective but still only creates a goal when explicitly requested.
112
122
 
@@ -117,6 +127,14 @@ The `update_goal` tool can close a goal in two ways:
117
127
  - `status: "complete"` with `evidence` when every requirement is actually achieved.
118
128
  - `status: "unmet"` with `blocker` when the objective cannot be achieved or is blocked by missing external input.
119
129
 
130
+ The plugin also uses safety states while keeping the goal available for review or resume:
131
+
132
+ - `budgetLimited` when a token budget is exhausted.
133
+ - `usageLimited` when an auto-turn or elapsed-time budget is exhausted.
134
+ - `paused` when the user pauses, auto-continue repeatedly fails, or repeated low-output/no-progress turns are detected.
135
+
136
+ When a safety limit is reached, the plugin sends one wrap-up prompt asking for a concise handoff instead of silently continuing forever.
137
+
120
138
  ## State
121
139
 
122
140
  Goal state is stored at:
@@ -133,6 +151,12 @@ If `XDG_DATA_HOME` is not set, the default is:
133
151
 
134
152
  Set `OPENCODE_GOAL_STATE_PATH` to use a custom file.
135
153
 
154
+ The state file is written atomically with owner-only permissions when the host filesystem supports it. Existing active goals recover from disk with their full objective, budget, history, and checkpoint metadata.
155
+
156
+ ## Credits
157
+
158
+ This plugin follows Codex's native goal-mode semantics where OpenCode plugin hooks allow it. Several hardening ideas were adapted from Willy Topete's [`willytop8/OpenCode-goal-plugin`](https://github.com/willytop8/OpenCode-goal-plugin), especially lifecycle history, checkpoints, no-progress safeguards, budget wrap-up behavior, and strict-provider-safe system prompt merging. Thank you, Willy.
159
+
136
160
  ## Development
137
161
 
138
162
  ```bash
@@ -170,4 +194,6 @@ OpenCode plugin modules are target-specific. This package exports separate modul
170
194
  }
171
195
  ```
172
196
 
173
- Codex goal mode has deeper runtime integration for thread lifecycle control. This plugin implements the same workflow using OpenCode plugin hooks. Token usage is read from OpenCode step-finish usage when available and falls back to message token metadata or text estimation when exact usage is unavailable. Continuation is driven by OpenCode's `session.idle` event.
197
+ Codex goal mode has deeper runtime integration for thread lifecycle control. This plugin implements the same workflow using OpenCode plugin hooks. Token usage is read from OpenCode step-finish usage when available and falls back to message token metadata or text estimation when exact usage is unavailable. Continuation is driven by OpenCode idle events, including `session.idle` and `session.status` idle notifications. During compaction, the plugin disables OpenCode's generic synthetic auto-continue while an active goal exists so the goal-specific continuation prompt remains authoritative.
198
+
199
+ The goal sidebar shows the current status, elapsed time, token usage, auto-continue count, latest checkpoint, latest status message, stop reason, and objective when a goal is active, paused, or safety-limited. Closed goals remain visible briefly through the latest tool state as achieved or unmet.