@prevalentware/opencode-goal-plugin 0.1.17 → 0.1.19
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 +31 -7
- package/dist/server.js +897 -87
- package/package.json +5 -5
- package/src/tui.tsx +164 -45
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?
|
|
@@ -82,9 +82,14 @@ Server options can be configured in `opencode.json`:
|
|
|
82
82
|
"@prevalentware/opencode-goal-plugin",
|
|
83
83
|
{
|
|
84
84
|
"auto_continue": true,
|
|
85
|
+
"defer_while_tasks_active": true,
|
|
85
86
|
"max_auto_turns": 25,
|
|
86
87
|
"min_continue_interval_seconds": 3,
|
|
87
|
-
"max_prompt_failures": 3
|
|
88
|
+
"max_prompt_failures": 3,
|
|
89
|
+
"default_token_budget": 200000,
|
|
90
|
+
"max_goal_duration_seconds": 1800,
|
|
91
|
+
"no_progress_token_threshold": 50,
|
|
92
|
+
"max_no_progress_turns": 2
|
|
88
93
|
}
|
|
89
94
|
]
|
|
90
95
|
]
|
|
@@ -94,9 +99,14 @@ Server options can be configured in `opencode.json`:
|
|
|
94
99
|
Defaults:
|
|
95
100
|
|
|
96
101
|
- `auto_continue`: `true`
|
|
102
|
+
- `defer_while_tasks_active`: `true`; when enabled, goal auto-continuation waits for active OpenCode Task child sessions and their orchestrator reconciliation before sending the next goal prompt.
|
|
97
103
|
- `max_auto_turns`: `25`
|
|
98
104
|
- `min_continue_interval_seconds`: `3`
|
|
99
105
|
- `max_prompt_failures`: `3`
|
|
106
|
+
- `default_token_budget`: unset by default; when set, new goals inherit this token budget.
|
|
107
|
+
- `max_goal_duration_seconds`: unset by default; when set, new goals inherit this elapsed-time safety limit.
|
|
108
|
+
- `no_progress_token_threshold`: `50`
|
|
109
|
+
- `max_no_progress_turns`: `2`
|
|
100
110
|
- `register_command`: `true`
|
|
101
111
|
- `command_name`: `"goal"`
|
|
102
112
|
|
|
@@ -108,7 +118,7 @@ Use `/goal <objective>` in a fresh OpenCode chat to create a long-running goal:
|
|
|
108
118
|
/goal review the frontend and translate visible English UI text to Spanish
|
|
109
119
|
```
|
|
110
120
|
|
|
111
|
-
Bare `/goal` reports the current goal state. `/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, or clearing the current goal state without creating a new goal.
|
|
121
|
+
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.
|
|
112
122
|
|
|
113
123
|
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.
|
|
114
124
|
|
|
@@ -119,6 +129,14 @@ The `update_goal` tool can close a goal in two ways:
|
|
|
119
129
|
- `status: "complete"` with `evidence` when every requirement is actually achieved.
|
|
120
130
|
- `status: "unmet"` with `blocker` when the objective cannot be achieved or is blocked by missing external input.
|
|
121
131
|
|
|
132
|
+
The plugin also uses safety states while keeping the goal available for review or resume:
|
|
133
|
+
|
|
134
|
+
- `budgetLimited` when a token budget is exhausted.
|
|
135
|
+
- `usageLimited` when an auto-turn or elapsed-time budget is exhausted.
|
|
136
|
+
- `paused` when the user pauses, auto-continue repeatedly fails, or repeated low-output/no-progress turns are detected.
|
|
137
|
+
|
|
138
|
+
When a safety limit is reached, the plugin sends one wrap-up prompt asking for a concise handoff instead of silently continuing forever.
|
|
139
|
+
|
|
122
140
|
## State
|
|
123
141
|
|
|
124
142
|
Goal state is stored at:
|
|
@@ -135,6 +153,12 @@ If `XDG_DATA_HOME` is not set, the default is:
|
|
|
135
153
|
|
|
136
154
|
Set `OPENCODE_GOAL_STATE_PATH` to use a custom file.
|
|
137
155
|
|
|
156
|
+
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.
|
|
157
|
+
|
|
158
|
+
## Credits
|
|
159
|
+
|
|
160
|
+
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.
|
|
161
|
+
|
|
138
162
|
## Development
|
|
139
163
|
|
|
140
164
|
```bash
|
|
@@ -172,6 +196,6 @@ OpenCode plugin modules are target-specific. This package exports separate modul
|
|
|
172
196
|
}
|
|
173
197
|
```
|
|
174
198
|
|
|
175
|
-
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.
|
|
199
|
+
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. By default, continuation is deferred while OpenCode Task child sessions are active or their terminal result still needs an orchestrator turn. During compaction, the plugin disables OpenCode's generic synthetic auto-continue while an active goal exists so the goal-specific continuation prompt remains authoritative.
|
|
176
200
|
|
|
177
|
-
The goal sidebar shows the current status, elapsed time, auto-continue count, latest status message, and objective when a goal is active or
|
|
201
|
+
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.
|