opencode-supertask 0.1.39 → 0.1.40
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/CHANGELOG.md +9 -0
- package/README.md +152 -352
- package/README.zh-CN.md +243 -0
- package/dist/cli/index.js +215 -47
- package/dist/cli/index.js.map +1 -1
- package/dist/gateway/index.js +195 -43
- package/dist/gateway/index.js.map +1 -1
- package/dist/plugin/supertask.js +37 -4
- package/dist/plugin/supertask.js.map +1 -1
- package/dist/web/index.js +179 -41
- package/dist/web/index.js.map +1 -1
- package/dist/worker/index.d.ts +1 -0
- package/dist/worker/index.js +34 -3
- package/dist/worker/index.js.map +1 -1
- package/drizzle/0008_good_smasher.sql +3 -0
- package/drizzle/meta/0008_snapshot.json +606 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable user-facing changes are recorded here. This project follows semantic versioning while it is in the `0.x` development series.
|
|
4
4
|
|
|
5
|
+
## [0.1.40] - 2026-07-19
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Tasks and scheduled templates now accept an optional OpenCode model `variant` through plugin tools, CLI commands, smoke diagnostics, and the Dashboard; Workers pass it as `--variant` and snapshot it in every run.
|
|
10
|
+
- The Dashboard now reads `opencode models --verbose` and offers only the variants declared by the selected model while preserving historical custom values.
|
|
11
|
+
|
|
12
|
+
[0.1.40]: https://github.com/vbgate/opencode-supertask/compare/v0.1.39...v0.1.40
|
|
13
|
+
|
|
5
14
|
## [0.1.39] - 2026-07-18
|
|
6
15
|
|
|
7
16
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,443 +1,243 @@
|
|
|
1
1
|
# SuperTask
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
3
|
+
<p align="center"><strong>Queue it. Schedule it. Retry it. Know what happened.</strong></p>
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/opencode-supertask"><img alt="npm version" src="https://img.shields.io/npm/v/opencode-supertask.svg"></a>
|
|
7
|
+
<a href="https://github.com/vbgate/opencode-supertask/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/vbgate/opencode-supertask/actions/workflows/ci.yml/badge.svg"></a>
|
|
8
|
+
<a href="https://opensource.org/licenses/MIT"><img alt="MIT License" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a>
|
|
9
|
+
</p>
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
<p align="center">
|
|
12
|
+
<strong>English</strong> | <a href="https://github.com/vbgate/opencode-supertask/blob/main/README.zh-CN.md">简体中文</a>
|
|
13
|
+
</p>
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
SuperTask turns one-off `opencode run` commands into durable Agent operations. It gives OpenCode agents a persistent SQLite queue, scheduling, retries, concurrency control, safe cancellation, execution history, and a local Web Dashboard.
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
OpenCode can run an Agent now. SuperTask makes sure the work is still tracked after the terminal closes, the process fails, or the machine restarts.
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
## Why SuperTask?
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
This writes an exact `opencode-supertask@<version>` entry. Do not change it to bare `opencode-supertask` or `@latest`; a floating cache key can select stale files after an upgrade.
|
|
25
|
-
|
|
26
|
-
Restart OpenCode to load 8 queue-management `supertask_*` tools. Execution state is owned only by the Gateway; the plugin no longer exposes manual `start/done/fail` transitions. Then choose how to run the Gateway:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
supertask install # recommended for long-running use: explicit pm2 setup
|
|
30
|
-
supertask gateway # foreground mode: no pm2 required
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
The plugin never installs global dependencies by itself. Without a running Gateway, queue-management tools still work, but scheduled and queued tasks are not executed and the Dashboard is unavailable.
|
|
34
|
-
|
|
35
|
-
Upgrades do not require uninstalling. Run `supertask upgrade`: it pins the exact latest plugin, replaces the Gateway, detects whether the global `supertask` came from npm or Bun, and synchronizes the CLI to that same version. When the CLI, effective plugin, cache, and ready Gateway already match npm `latest`, the command exits without reinstalling or restarting; use `supertask upgrade --force` to intentionally refresh the environment and restart the current version. `supertask doctor` fails if the CLI, plugin, Gateway package, or ready lock disagree. Versions through 0.1.33 cannot retroactively update their own old CLI, so upgrade from those releases by installing the new global CLI once with the original package manager, then run the new `supertask upgrade`.
|
|
21
|
+
| If you need to... | Use |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| Run one Agent once | `opencode run` |
|
|
24
|
+
| Run a few fixed commands at fixed times | `cron`, `launchd`, `systemd`, or GitHub Actions |
|
|
25
|
+
| Restart a long-running process on a schedule | PM2 `cron_restart` |
|
|
26
|
+
| Manage changing Agent jobs with durable state, retries, priorities, and history | **SuperTask** |
|
|
36
27
|
|
|
37
|
-
|
|
28
|
+
SuperTask is not another wrapper around cron. Scheduled work becomes an ordinary durable queue task, so manual and scheduled jobs follow the same concurrency, retry, cancellation, dependency, and history rules.
|
|
38
29
|
|
|
39
|
-
|
|
30
|
+
## What You Get
|
|
40
31
|
|
|
41
|
-
|
|
32
|
+
| Capability | What it means |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| Durable queue | Tasks and every run survive process and machine restarts in SQLite WAL |
|
|
35
|
+
| Three schedule types | Cron, run-once delay, and fixed recurring interval |
|
|
36
|
+
| Automatic recovery | Retry budgets, exponential backoff, dead-letter state, and manual retry |
|
|
37
|
+
| Controlled execution | Global concurrency, priority ordering, dependencies, and global batch serialization |
|
|
38
|
+
| Project awareness | Each task keeps its OpenCode project directory, Agent, model, and optional model variant |
|
|
39
|
+
| Safe process handling | Cancel and shutdown wait for the managed OpenCode process tree to stop |
|
|
40
|
+
| Observable runs | Session ID, exact reproducible command, model output, tools, errors, and raw JSONL |
|
|
41
|
+
| Local Dashboard | Create, schedule, inspect, retry, cancel, and diagnose from `127.0.0.1` |
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
2. Remove the `"opencode-supertask@<version>"` entry from `~/.config/opencode/opencode.json`
|
|
45
|
-
3. Restart OpenCode
|
|
43
|
+
## Three-Minute Quick Start
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
### 1. Install one exact version
|
|
48
46
|
|
|
49
47
|
```bash
|
|
50
|
-
|
|
48
|
+
VERSION="$(npm view opencode-supertask dist-tags.latest)"
|
|
49
|
+
npm install -g "opencode-supertask@$VERSION"
|
|
50
|
+
opencode plugin "opencode-supertask@$VERSION" --global --force
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Pinning the exact version keeps the OpenCode plugin, global CLI, and Gateway on the same build. Do not replace it with a bare package name or `@latest` in `opencode.json`.
|
|
54
54
|
|
|
55
|
-
###
|
|
55
|
+
### 2. Restart OpenCode and start the Gateway
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
|
-
supertask install
|
|
59
|
-
supertask uninstall # Stop and remove Gateway from pm2
|
|
58
|
+
supertask install # recommended: PM2 startup, crash recovery, and log rotation
|
|
60
59
|
```
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
For foreground development instead:
|
|
63
62
|
|
|
64
63
|
```bash
|
|
65
|
-
|
|
66
|
-
cd opencode-supertask
|
|
67
|
-
bun install
|
|
68
|
-
bun run build
|
|
64
|
+
supertask gateway
|
|
69
65
|
```
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```json
|
|
74
|
-
{
|
|
75
|
-
"plugin": ["/path/to/opencode-supertask"]
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Quick Start
|
|
80
|
-
|
|
81
|
-
After starting the Gateway with `supertask install` or `supertask gateway`, use the MCP tools in OpenCode:
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
Create a task: "帮我生成项目的 README" with agent "explore"
|
|
85
|
-
```
|
|
67
|
+
The plugin never installs global services during OpenCode startup. PM2 setup only happens when you explicitly run `supertask install`.
|
|
86
68
|
|
|
87
|
-
|
|
69
|
+
### 3. Ask OpenCode to create a task
|
|
88
70
|
|
|
89
|
-
```
|
|
90
|
-
|
|
71
|
+
```text
|
|
72
|
+
Create a SuperTask named "Review API errors".
|
|
73
|
+
Use the build agent in this project, retry twice, and run it now.
|
|
91
74
|
```
|
|
92
75
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
Retry, timeout, and recurring-interval fields offer common presets first. Number-and-unit controls appear only under **Custom**, while one-time schedules use a local date/time picker. “Use the Agent / OpenCode default model” means SuperTask does not pass `-m`.
|
|
96
|
-
|
|
97
|
-
## SuperTask vs cron, PM2, and shell scripts
|
|
98
|
-
|
|
99
|
-
SuperTask is not a replacement for every scheduler. If you only have a few fixed, independent `opencode run` commands, use `crontab`, a system timer (`launchd`/`systemd`), GitHub Actions, or PM2 `cron_restart`. They are simpler and do not require the SuperTask Gateway.
|
|
100
|
-
|
|
101
|
-
| Requirement | Prefer |
|
|
102
|
-
| --- | --- |
|
|
103
|
-
| Run a few fixed, independent commands at fixed times | `crontab`, `launchd`, or a `systemd` timer |
|
|
104
|
-
| Restart one long-running process on a schedule | PM2 `cron_restart` |
|
|
105
|
-
| Run a fixed serial pipeline | A shell script |
|
|
106
|
-
| Manage a changing set of Agent jobs with durable state | SuperTask |
|
|
76
|
+
OpenCode receives eight native `supertask_*` plugin tools. The current project directory is taken from OpenCode's tool context rather than trusted from model input.
|
|
107
77
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
- a durable queue with per-task and per-run state after process or machine restarts;
|
|
111
|
-
- dynamic creation and editing from OpenCode, CLI, and Web instead of editing an OS crontab;
|
|
112
|
-
- shared concurrency limits, priority ordering, dependencies, and per-project/batch serialization;
|
|
113
|
-
- retry budgets, exponential backoff, dead-letter handling, and manual recovery;
|
|
114
|
-
- safe cancellation of a managed OpenCode process tree, session tracking, and searchable execution history.
|
|
115
|
-
|
|
116
|
-
A loop such as `opencode run ... && opencode run ...` is also a valid solution for a fixed serial pipeline. It does not know how to accept new work, reorder it, resume an individual failed job, or expose reliable queue state unless those capabilities are built separately with a database, locks, logs, and process supervision—in effect, a task queue.
|
|
117
|
-
|
|
118
|
-
SuperTask's scheduler creates ordinary durable queue tasks, so scheduled and manually submitted work share the same concurrency, retry, cancellation, and history rules. The trade-off is that the Gateway must be running to dispatch work. For 24/7 use, run it under the optional PM2 installation or another process supervisor; `crontab` remains the better choice when an OS-level fixed schedule is all you need.
|
|
119
|
-
|
|
120
|
-
## CLI Reference
|
|
121
|
-
|
|
122
|
-
CLI help and interactive database/doctor summaries support Chinese and English. The default is `auto`: `zh*` system locales use Chinese and all other locales use English. Override it globally with `supertask --lang zh-CN <command>`, `supertask --lang en <command>`, or `SUPERTASK_LANG=zh-CN|en`. JSON field names and raw diagnostic errors are unchanged for scripts and Agents.
|
|
78
|
+
### 4. Watch it run
|
|
123
79
|
|
|
124
80
|
```bash
|
|
125
|
-
# Gateway management
|
|
126
|
-
supertask install # install Gateway as pm2 service
|
|
127
|
-
supertask uninstall # stop and remove from pm2
|
|
128
|
-
supertask gateway # start Gateway in foreground
|
|
129
|
-
supertask ui # open Web Dashboard in browser
|
|
130
|
-
supertask config # show current config
|
|
131
|
-
supertask doctor [--json] # static end-to-end runtime diagnostics
|
|
132
|
-
supertask doctor --smoke [--smoke-agent build] [--smoke-model provider/model]
|
|
133
|
-
# queue one real Gateway/OpenCode verification task
|
|
134
|
-
supertask upgrade [--force] # update if needed; force refreshes and restarts
|
|
135
|
-
|
|
136
|
-
# Task management
|
|
137
|
-
supertask add -n "Task" -a "agent" -p "prompt" --importance 5 \
|
|
138
|
-
--max-retries 3 --retry-backoff "30s" --timeout "30min"
|
|
139
|
-
supertask edit --id 1 --model "openai/gpt-5" --importance 5 --prompt "updated"
|
|
140
|
-
supertask list [--status pending] [--limit 20]
|
|
141
|
-
supertask get --id 1
|
|
142
81
|
supertask status
|
|
143
|
-
supertask
|
|
144
|
-
supertask
|
|
145
|
-
supertask delete --id 1 # running tasks must be cancelled and fully stopped first
|
|
146
|
-
supertask run abandon --id 7 --confirm ABANDON # legacy null-PID quarantine only
|
|
147
|
-
|
|
148
|
-
# Scheduled templates (friendly duration format)
|
|
149
|
-
supertask template add --name "Daily" --agent "gen" \
|
|
150
|
-
--prompt "..." --type cron --cron "0 9 * * *"
|
|
151
|
-
supertask template add --name "Delayed" --agent "gen" \
|
|
152
|
-
--prompt "..." --type delayed --delay "30min"
|
|
153
|
-
supertask template add --name "Hourly" --agent "gen" \
|
|
154
|
-
--prompt "..." --type recurring --interval "1h" \
|
|
155
|
-
--batch "reports" --retry-backoff "30s" --timeout "30min"
|
|
156
|
-
supertask template list
|
|
157
|
-
supertask template enable --id 1
|
|
158
|
-
|
|
159
|
-
# Database maintenance
|
|
160
|
-
supertask db check
|
|
161
|
-
supertask db backup [--output /path/to/tasks-backup.db]
|
|
162
|
-
supertask db clear --confirm CLEAR [--keep-stopped]
|
|
163
|
-
supertask db restore --from /path/to/tasks-backup.db --confirm RESTORE [--keep-stopped]
|
|
82
|
+
supertask list --limit 10
|
|
83
|
+
supertask ui
|
|
164
84
|
```
|
|
165
85
|
|
|
166
|
-
|
|
86
|
+
The Dashboard opens at <http://127.0.0.1:4680>.
|
|
167
87
|
|
|
168
|
-
|
|
88
|
+
## How It Works
|
|
169
89
|
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
|
|
90
|
+
```mermaid
|
|
91
|
+
flowchart LR
|
|
92
|
+
A[OpenCode tools / CLI / Dashboard] --> B[SQLite task queue]
|
|
93
|
+
B --> C[Gateway]
|
|
94
|
+
C --> D[Worker]
|
|
95
|
+
C --> E[Scheduler]
|
|
96
|
+
C --> F[Watchdog]
|
|
97
|
+
D --> G[opencode run]
|
|
98
|
+
G --> H[Run history and session]
|
|
173
99
|
```
|
|
174
100
|
|
|
175
|
-
|
|
101
|
+
The single Gateway owns runtime state transitions. Clients create and manage work; only the Gateway marks runs started, completed, failed, retried, or cancelled.
|
|
176
102
|
|
|
177
|
-
|
|
103
|
+
## Use It Your Way
|
|
178
104
|
|
|
179
|
-
###
|
|
105
|
+
### Natural language in OpenCode
|
|
180
106
|
|
|
181
|
-
|
|
107
|
+
```text
|
|
108
|
+
Run a security review with agent build, model provider/model, and variant high.
|
|
182
109
|
|
|
183
|
-
|
|
184
|
-
|--------|----------|
|
|
185
|
-
| Seconds | `30s`, `5sec` |
|
|
186
|
-
| Minutes | `5min`, `30minutes` |
|
|
187
|
-
| Hours | `1h`, `2hours` |
|
|
188
|
-
| Days | `1d`, `3days` |
|
|
189
|
-
| Weeks | `1w`, `2weeks` |
|
|
190
|
-
| ISO 8601 | `PT30M`, `PT1H30M` |
|
|
110
|
+
Every weekday at 9:00, create a report task for this project.
|
|
191
111
|
|
|
192
|
-
|
|
112
|
+
Show failed tasks in this project and retry the recoverable ones.
|
|
193
113
|
|
|
194
|
-
|
|
195
|
-
Gateway (foreground or optionally managed by pm2)
|
|
196
|
-
├── Worker → claim tasks, execute the target agent via opencode run
|
|
197
|
-
├── Scheduler → clone tasks from templates (cron / delayed / recurring)
|
|
198
|
-
├── Watchdog → heartbeat timeout, auto-retry, data cleanup
|
|
199
|
-
└── Dashboard → Web UI on port 4680 (Hono SSR)
|
|
114
|
+
Check whether batch "release" is running in another project.
|
|
200
115
|
```
|
|
201
116
|
|
|
202
|
-
|
|
117
|
+
Available plugin tools:
|
|
203
118
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
{
|
|
208
|
-
"configVersion": 2,
|
|
209
|
-
"worker": { "maxConcurrency": 2, "taskTimeoutMs": 1800000, "shutdownGracePeriodMs": 30000 },
|
|
210
|
-
"scheduler": { "enabled": true, "checkIntervalMs": 1000 },
|
|
211
|
-
"watchdog": {
|
|
212
|
-
"heartbeatTimeoutMs": 600000,
|
|
213
|
-
"checkIntervalMs": 60000,
|
|
214
|
-
"cleanupIntervalMs": 86400000,
|
|
215
|
-
"retentionDays": 30
|
|
216
|
-
},
|
|
217
|
-
"dashboard": { "enabled": true, "port": 4680 }
|
|
218
|
-
}
|
|
119
|
+
```text
|
|
120
|
+
supertask_add supertask_schedule supertask_status supertask_retry
|
|
121
|
+
supertask_list supertask_get supertask_next supertask_upgrade
|
|
219
122
|
```
|
|
220
123
|
|
|
221
|
-
|
|
222
|
-
- **Process supervision** — optional pm2 crash recovery with a 512 MB default memory restart threshold and a kill timeout no lower than Worker drain grace + 15 seconds; lifecycle operations and the macOS supervisor acquire the canonical `PM2_HOME` SQLite lock plus any recovered legacy custom lock for the whole mutation, reject a macOS LaunchAgent/CLI `PM2_HOME` mismatch before mutation, and never bypass PM2's `errored` fuse
|
|
223
|
-
- **Version-aware restart** — automatic recovery preserves the existing PM2 runtime environment; an explicit install/upgrade refreshes the OpenCode/provider execution environment while pinning the prior PM2/Bun/database/config identity. Replacement is refused before deletion if the old environment can no longer invoke PM2, and failed startup rolls back the complete prior runtime and version
|
|
224
|
-
- **Process lock** — SQLite `BEGIN IMMEDIATE` ensures single instance, fences a process that loses ownership, and distinguishes a stale reused PID from a live Gateway
|
|
225
|
-
- **Readiness check** — PM2 PID must match a fresh, ready Gateway lock; `/health` reports Worker, Scheduler, Watchdog and cleanup-loop failures
|
|
226
|
-
- **Heartbeat** — Worker updates every 30s; new runs persist a per-run UUID in `locked_by` and launcher argv, and Watchdog signals a stale process group only when that identity and its OpenCode command match. Worker settles a normal exit only after the launcher returns a matching drain proof over private IPC; an unproved guardian exit remains quarantined until its process group is confirmed absent. Live legacy/v2 groups remain quarantined; an old run is recovered automatically only after both PID and PGID are confirmed absent.
|
|
227
|
-
- **Graceful shutdown** — stop claiming work, drain active tasks for 30s, then requeue only runs whose complete process tree is confirmed stopped
|
|
228
|
-
- **Bun IPC compatibility** — after sending a bound drain proof, the launcher waits for a matching Worker acknowledgment instead of relying on the unreliable `process.send` callback in older Bun versions
|
|
229
|
-
- **Fail-closed process isolation** — Unix uses an independent process group; Windows Worker startup is blocked until Job Object containment is available
|
|
230
|
-
- **External-only upgrades** — Gateway-managed OpenCode runs cannot invoke `supertask_upgrade`; upgrades must start from an external CLI or interactive session so they cannot terminate their own host Gateway
|
|
231
|
-
- **Exponential backoff** — configurable base × 2^n, capped at 30min
|
|
232
|
-
- **Dead letter queue** — `maxRetries` additional retries exhausted → `dead_letter`, manually recoverable
|
|
233
|
-
- **Project and batch isolation** — `cwd` groups and isolates project queries; the same non-empty `batchId` is a global serialization key across projects and Gateway restarts, while different or omitted batches can run in parallel
|
|
234
|
-
- **Priority** — `urgency DESC → importance DESC → createdAt ASC → id ASC`
|
|
235
|
-
- **Local Dashboard boundary** — loopback-only listener, same-origin write checks, escaped database output
|
|
236
|
-
- **Guarded deletion** — active runs and prerequisites of executable dependent tasks cannot be deleted
|
|
237
|
-
|
|
238
|
-
## Web Dashboard
|
|
239
|
-
|
|
240
|
-
http://localhost:4680 — 4 pages:
|
|
241
|
-
|
|
242
|
-
The responsive Dashboard supports Chinese and English plus system, light, and dark themes. Language is stored in a same-site cookie, while theme preference stays in browser local storage; both survive refreshes without changing Gateway configuration.
|
|
243
|
-
|
|
244
|
-
Health endpoint: `GET http://localhost:4680/health` returns 200 only after Gateway startup completes and its internal loops remain active without an unrecovered loop failure. `supertask doctor` checks OpenCode separately in the invoking terminal and in PM2's saved Gateway environment, then checks SQLite, PM2 readiness, Dashboard health, log rotation, and on macOS the loaded LaunchAgent plus its recoverable PM2 dump. It requires the effective OpenCode plugin configuration to use one exact version, verifies that exact cache package, and compares it with the global CLI, actual PM2 Gateway entry, and ready-lock version; floating `@latest`/`@next` paths or any component version mismatch fail diagnostics. Add `--smoke` only when a real model call is desired; it queues a normal high-priority task and verifies the exact marker returned by OpenCode.
|
|
245
|
-
|
|
246
|
-
| Page | Features |
|
|
247
|
-
|------|----------|
|
|
248
|
-
| Task Queue | Browse a project folder, load its runnable Agents/models, see running/queued/error counts, create or edit prioritized tasks, open human-readable details, retry, cancel, guarded delete, and copy a validated `opencode --session …` command |
|
|
249
|
-
| Scheduled Tasks | Create and edit model, Agent, prompt, project directory, schedule, retries, and timeout with common duration presets; Run now always queues a task |
|
|
250
|
-
| Execution Logs | Structured Agent output, errors, tools, and exact reproducible command expanded directly beneath the selected run; raw OpenCode JSONL remains a secondary troubleshooting view |
|
|
251
|
-
| System Status | Config editor with saved/active state, PM2-backed save-and-restart, concurrency monitor, and backup-first transactional database clear |
|
|
252
|
-
|
|
253
|
-
## Data
|
|
254
|
-
|
|
255
|
-
- Database: `~/.local/share/opencode/tasks.db` (SQLite WAL)
|
|
256
|
-
- Config: `~/.config/opencode/supertask.json`
|
|
257
|
-
|
|
258
|
-
## Requirements
|
|
259
|
-
|
|
260
|
-
- [Bun](https://bun.sh) >= 1.1.45 (CI verifies launcher IPC on both the minimum and current versions)
|
|
261
|
-
- [OpenCode](https://opencode.ai)
|
|
262
|
-
|
|
263
|
-
## License
|
|
264
|
-
|
|
265
|
-
MIT
|
|
266
|
-
|
|
267
|
-
---
|
|
268
|
-
|
|
269
|
-
<a id="简体中文"></a>
|
|
270
|
-
|
|
271
|
-
## 简体中文
|
|
272
|
-
|
|
273
|
-
SuperTask 是一个基于 SQLite 的 AI Agent 任务调度系统,专为 [OpenCode](https://opencode.ai) 设计。
|
|
274
|
-
|
|
275
|
-
详细文档:[更新记录](CHANGELOG.md) · [当前架构与决策](docs/architecture.md) · [运行与排障手册](docs/operations.md) · [文档索引](docs/README.md)
|
|
276
|
-
|
|
277
|
-
### 安装
|
|
278
|
-
|
|
279
|
-
先解析一次稳定版号,再用同一个精确版本安装全局 CLI 和 OpenCode 插件:
|
|
124
|
+
### CLI
|
|
280
125
|
|
|
281
126
|
```bash
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
127
|
+
# Queue work
|
|
128
|
+
supertask add --name "Security review" --agent build \
|
|
129
|
+
--model openai/gpt-5.6-sol --variant xhigh \
|
|
130
|
+
--prompt "Review authentication and authorization" \
|
|
131
|
+
--importance 5 --urgency 4 --max-retries 2 \
|
|
132
|
+
--retry-backoff 30s --timeout 30min
|
|
288
133
|
|
|
289
|
-
|
|
134
|
+
# Schedule work
|
|
135
|
+
supertask template add --name "Weekday report" --agent build \
|
|
136
|
+
--model openai/gpt-5.6-sol --variant high \
|
|
137
|
+
--prompt "Summarize important project changes" \
|
|
138
|
+
--type cron --cron "0 9 * * 1-5"
|
|
290
139
|
|
|
291
|
-
|
|
292
|
-
supertask
|
|
293
|
-
supertask
|
|
140
|
+
# Inspect and recover
|
|
141
|
+
supertask status
|
|
142
|
+
supertask list --status failed --limit 20
|
|
143
|
+
supertask retry --id 42
|
|
144
|
+
supertask cancel --id 42
|
|
294
145
|
```
|
|
295
146
|
|
|
296
|
-
|
|
147
|
+
Run `supertask --help` or `supertask <command> --help` for the complete command surface. CLI help and human-readable diagnostics support `auto`, `en`, and `zh-CN`.
|
|
297
148
|
|
|
298
|
-
|
|
149
|
+
## Dashboard
|
|
299
150
|
|
|
300
|
-
|
|
151
|
+
The responsive Dashboard supports English and Chinese, light and dark themes, and four focused views:
|
|
301
152
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
153
|
+
| Page | Purpose |
|
|
154
|
+
| --- | --- |
|
|
155
|
+
| Task Queue | Browse projects, create/edit tasks, see priorities and active state, retry, cancel, or delete safely |
|
|
156
|
+
| Scheduled Tasks | Create/edit cron, delayed, and recurring templates; run one immediately without bypassing the queue |
|
|
157
|
+
| Execution Logs | Read structured output, tools, errors, sessions, and the exact historical command |
|
|
158
|
+
| System Status | Inspect active configuration, health, concurrency, and backup-first database maintenance |
|
|
305
159
|
|
|
306
|
-
|
|
307
|
-
supertask ui # 打开 http://127.0.0.1:4680
|
|
308
|
-
```
|
|
160
|
+
The project picker reads the selected directory's real `opencode agent list` and `opencode models --verbose` output, so forms offer only locally available models, each model's declared variants, and directly runnable Agents. Leaving variant at its default omits `--variant` and follows the Agent/model configuration.
|
|
309
161
|
|
|
310
|
-
|
|
162
|
+
## Reliability Without Hand-Waving
|
|
311
163
|
|
|
312
|
-
|
|
164
|
+
- SQLite `BEGIN IMMEDIATE` protects the single-Gateway lock and global batch serialization.
|
|
165
|
+
- Each managed run has a unique launcher identity and an isolated Unix process group.
|
|
166
|
+
- A run settles only after the launcher proves the entire process group drained.
|
|
167
|
+
- Shutdown and cancellation fail closed when process ownership cannot be proven.
|
|
168
|
+
- `supertask doctor` verifies OpenCode, the effective pinned plugin, cache, CLI, Gateway package, ready lock, SQLite, Dashboard, and PM2 environment.
|
|
169
|
+
- Database clear and restore are transactional, backup-first, WAL-consistent, and reject active work.
|
|
313
170
|
|
|
314
|
-
|
|
171
|
+
The detailed guarantees and recovery rules live in [Architecture](docs/architecture.md) and [Operations and Troubleshooting](docs/operations.md).
|
|
315
172
|
|
|
316
|
-
|
|
173
|
+
## Upgrade and Diagnose
|
|
317
174
|
|
|
318
175
|
```bash
|
|
319
|
-
supertask
|
|
320
|
-
supertask --
|
|
321
|
-
|
|
176
|
+
supertask upgrade # update only when versions or components have drifted
|
|
177
|
+
supertask upgrade --force # reinstall the current version, refresh environment, restart
|
|
178
|
+
supertask doctor
|
|
179
|
+
supertask doctor --smoke --smoke-agent build --smoke-model provider/model --smoke-variant high
|
|
322
180
|
```
|
|
323
181
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
```bash
|
|
327
|
-
# Gateway 与诊断
|
|
328
|
-
supertask install | uninstall | gateway | ui | doctor
|
|
329
|
-
supertask doctor --smoke --smoke-agent build --smoke-model openai/gpt-5
|
|
182
|
+
When every component already matches npm `latest`, normal upgrade is a no-op and does not restart the Gateway. Smoke diagnostics make one real model call; ordinary `doctor` does not.
|
|
330
183
|
|
|
331
|
-
|
|
332
|
-
supertask add | edit | list | get | status | retry | cancel | delete
|
|
333
|
-
|
|
334
|
-
# 定时任务与数据库
|
|
335
|
-
supertask template add | list | enable | disable | delete
|
|
336
|
-
supertask db check | backup | clear | restore
|
|
337
|
-
```
|
|
184
|
+
## Requirements
|
|
338
185
|
|
|
339
|
-
|
|
186
|
+
- OpenCode
|
|
187
|
+
- Bun 1.1.45 or newer
|
|
188
|
+
- Node.js/npm for the documented install and upgrade flow
|
|
189
|
+
- macOS or Linux for Gateway task execution
|
|
340
190
|
|
|
341
|
-
|
|
342
|
-
2. 从 `~/.config/opencode/opencode.json` 中移除 `"opencode-supertask@<version>"`
|
|
343
|
-
3. 重启 OpenCode
|
|
191
|
+
Windows Worker execution remains disabled until OS Job Object containment can guarantee safe process-tree cancellation. Queue execution does not require PM2 when the Gateway runs in the foreground.
|
|
344
192
|
|
|
345
|
-
|
|
193
|
+
## Install From Source
|
|
346
194
|
|
|
347
195
|
```bash
|
|
348
|
-
|
|
196
|
+
git clone https://github.com/vbgate/opencode-supertask.git
|
|
197
|
+
cd opencode-supertask
|
|
198
|
+
bun install
|
|
199
|
+
bun run build
|
|
349
200
|
```
|
|
350
201
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
### 定时任务
|
|
354
|
-
|
|
355
|
-
支持友好的时间格式:
|
|
356
|
-
|
|
357
|
-
```bash
|
|
358
|
-
# 30秒后执行
|
|
359
|
-
supertask template add --type delayed --delay "30s" ...
|
|
360
|
-
|
|
361
|
-
# 每5分钟循环
|
|
362
|
-
supertask template add --type recurring --interval "5min" ...
|
|
202
|
+
Point OpenCode at the built plugin file:
|
|
363
203
|
|
|
364
|
-
|
|
365
|
-
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"plugin": [
|
|
207
|
+
"file:///home/user/src/opencode-supertask/dist/plugin/supertask.js"
|
|
208
|
+
]
|
|
209
|
+
}
|
|
366
210
|
```
|
|
367
211
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
SuperTask 并不是所有定时场景的替代品。如果只是按固定时间运行少量、互不依赖的 `opencode run`,优先使用 `crontab`、`launchd` / `systemd` 定时器、GitHub Actions 或 PM2 `cron_restart`:它们更简单,也不依赖 SuperTask Gateway。
|
|
371
|
-
|
|
372
|
-
| 需求 | 更合适的方案 |
|
|
373
|
-
| --- | --- |
|
|
374
|
-
| 固定时间运行少量、互不依赖的命令 | `crontab`、`launchd` 或 `systemd` 定时器 |
|
|
375
|
-
| 定时重启一个长期运行的进程 | PM2 `cron_restart` |
|
|
376
|
-
| 按固定顺序执行一串命令 | Shell 脚本 |
|
|
377
|
-
| 管理会动态变化、需要持久状态的 Agent 任务 | SuperTask |
|
|
378
|
-
|
|
379
|
-
`crontab` 完全可以直接启动 `opencode run`,但它默认不提供:
|
|
380
|
-
|
|
381
|
-
- 进程或机器重启后仍可恢复的持久任务队列,以及逐任务、逐次执行状态;
|
|
382
|
-
- 从 OpenCode、CLI 和 Web 动态创建、编辑任务,而不是修改操作系统的 crontab;
|
|
383
|
-
- 全局并发限制、优先级、依赖关系,以及跨项目生效的全局同批次串行;
|
|
384
|
-
- 重试次数、指数退避、失败任务隔离(死信)和人工恢复;
|
|
385
|
-
- 对受管 OpenCode 进程树的安全取消、Session 追踪和可查询的执行历史。
|
|
386
|
-
|
|
387
|
-
`opencode run ... && opencode run ...` 或循环脚本也适合固定的串行流水线;但它无法直接接收新任务、调整顺序、单独恢复某个失败任务或展示可靠的队列状态。若再自行补数据库、锁、日志解析和进程守护,本质上就是重新实现一套任务队列。
|
|
212
|
+
Then restart OpenCode and run `bun run gateway` from the repository.
|
|
388
213
|
|
|
389
|
-
|
|
214
|
+
## AI-Friendly by Design
|
|
390
215
|
|
|
391
|
-
|
|
216
|
+
- Tool descriptions include scheduling, retries, global batches, dependencies, and project-scope semantics.
|
|
217
|
+
- Plugin tools use the OpenCode context directory and reject a model-supplied working directory.
|
|
218
|
+
- Task-management commands return JSON, while database and doctor commands support explicit `--json`; interactive summaries are concise and localized.
|
|
219
|
+
- `AGENTS.md` records architecture invariants, testing rules, release rules, and unsafe shortcuts for coding agents.
|
|
220
|
+
- Commands record the exact executable, arguments, model, variant, Agent, and working directory for reproducible diagnosis.
|
|
392
221
|
|
|
393
|
-
|
|
222
|
+
## Documentation
|
|
394
223
|
|
|
395
|
-
-
|
|
396
|
-
-
|
|
397
|
-
-
|
|
398
|
-
-
|
|
399
|
-
-
|
|
400
|
-
- **定时任务** — cron / delayed / recurring,常用间隔直接选择,只在自定义时输入数字和单位;`maxInstances` 限制自动调度,手动“立即运行一次”始终入队并在全局并发已满时等待
|
|
401
|
-
- **Web 控制台** — 按项目目录显示运行/排队/异常数量,可浏览文件夹并动态读取该项目本机 OpenCode 可运行 Agent/模型,可创建和编辑带提示词、优先级、批次、重试与超时的普通任务和定时任务;执行记录分层展示真实命令、Agent 输出、错误、工具和原始 JSONL;支持配置重启、安全清库、中英文、深浅主题和移动端
|
|
402
|
-
- **Session 追踪** — 自动从 opencode run 输出中捕获 session ID;任务页和执行记录页可复制经过校验的 `opencode --session …` 命令继续会话
|
|
403
|
-
- **安全删除** — 活跃执行必须先取消并收敛;仍被可执行任务依赖的前置任务也不会被误删
|
|
404
|
-
- **安全重试** — 仅在依赖仍存在、同项目且可恢复时重置任务,历史清理并发时不会制造悬空 `pending`
|
|
405
|
-
- **一键诊断** — `supertask doctor` 检查真实 OpenCode、精确锁定的插件配置/缓存、全局 CLI、PM2 实际 Gateway 入口与 ready 锁版本、SQLite、Dashboard、日志轮转和 macOS 重启恢复链路;浮动 `@latest`/`@next` 路径或任一组件版本不一致都会判异常
|
|
224
|
+
- [Operations and troubleshooting](docs/operations.md)
|
|
225
|
+
- [Current architecture and decisions](docs/architecture.md)
|
|
226
|
+
- [Changelog](CHANGELOG.md)
|
|
227
|
+
- [Documentation index](docs/README.md)
|
|
228
|
+
- [Contributor and Agent rules](AGENTS.md)
|
|
406
229
|
|
|
407
|
-
|
|
230
|
+
## Development
|
|
408
231
|
|
|
409
232
|
```bash
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
`db backup` 会生成并校验可独立恢复的 SQLite 快照。CLI 清空和恢复会先确认 PM2 PID 与当前数据库的新鲜 ready 锁一致,再自动停止并按原状态重启 Gateway;操作失败时也会尝试恢复 Gateway。它们仍会拒绝运行中任务、前台 Gateway 或无法确认归属的进程,并在修改数据前自动保留安全备份。清空会动态删除全部业务表数据,包括兼容的新版本 expand-only 表,同时保留 Gateway 锁表和 migration 元数据。恢复通过 SQLite 源连接生成包含已提交 WAL 页的一致快照,拒绝当前数据库的符号链接/硬链接别名,并动态恢复所有兼容的业务表与可写列;source-only 未知表/列会在删除前失败关闭,目标侧新增列必须可空或有默认值,目标侧新增表按旧快照的空状态清理。暂存快照迁移后再在排他事务中原位替换业务数据,避免并发写入成功后被静默覆盖。传入 `--keep-stopped` 可让原本运行的 PM2 Gateway 保持停止。
|
|
417
|
-
|
|
418
|
-
四个 `db` 命令在交互式终端默认输出简洁的人类可读摘要;管道、命令替换和其他非交互调用继续得到 JSON。终端内需要 JSON 时传入 `--json`:
|
|
419
|
-
|
|
420
|
-
```bash
|
|
421
|
-
supertask db check --json
|
|
422
|
-
supertask db check | jq '.counts'
|
|
233
|
+
bun install --frozen-lockfile
|
|
234
|
+
bun test
|
|
235
|
+
bun run typecheck
|
|
236
|
+
bun run build
|
|
423
237
|
```
|
|
424
238
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
旧版本若在记录 child PID 前崩溃,Watchdog 会安全隔离该 run,`supertask doctor` 与 Gateway 日志会给出任务/run ID。先在任务记录的 `cwd` 执行 `supertask cancel --id <taskId>`,独立确认没有遗留 OpenCode 进程,再执行 `supertask run abandon --id <runId> --confirm ABANDON`。该命令只关闭 owner 已退出、child PID 为空且任务已取消的旧版 run;当前 guardian run、存活 owner 或已记录 PID 的 run 一律拒绝。
|
|
239
|
+
CI also runs the built launcher IPC smoke test on the minimum supported Bun version.
|
|
428
240
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
排空证明采用双向确认:Worker 校验证明后回送同 UUID,launcher 收件后才退出;该握手不依赖旧 Bun 不可靠的 `process.send` 回调。最低支持 Bun 1.1.45,CI 同时验证最低版本和当前版本。
|
|
432
|
-
|
|
433
|
-
### 数据位置
|
|
434
|
-
|
|
435
|
-
- 数据库:`~/.local/share/opencode/tasks.db`
|
|
436
|
-
- 配置:`~/.config/opencode/supertask.json`
|
|
437
|
-
|
|
438
|
-
### 运行要求
|
|
241
|
+
## License
|
|
439
242
|
|
|
440
|
-
|
|
441
|
-
- OpenCode
|
|
442
|
-
- Gateway Worker 当前支持 macOS 与 Linux;Windows 在 Job Object 进程树隔离完成前拒绝启动
|
|
443
|
-
- PM2 只在运行 `supertask install` 时显式安装/使用;前台 `supertask gateway` 不依赖 PM2
|
|
243
|
+
MIT
|