opencode-supertask 0.1.0

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 ADDED
@@ -0,0 +1,224 @@
1
+ # SuperTask
2
+
3
+ [![npm version](https://img.shields.io/npm/v/opencode-supertask.svg)](https://www.npmjs.com/package/opencode-supertask)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ AI-powered task queue for [OpenCode](https://opencode.ai) agents — schedule, retry, and manage batch jobs with SQLite.
7
+
8
+ [简体中文](#简体中文)
9
+
10
+ ## Installation
11
+
12
+ ### Let an LLM do it
13
+
14
+ Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
15
+
16
+ ```
17
+ Install the opencode-supertask plugin by following: https://raw.githubusercontent.com/vbgate/opencode-supertask/main/README.md
18
+ ```
19
+
20
+ <details>
21
+ <summary><b>Instructions for LLM agents</b></summary>
22
+
23
+ To install this plugin, perform these steps:
24
+
25
+ 1. Add `"opencode-supertask"` to the `plugin` array in `~/.config/opencode/opencode.json`:
26
+
27
+ ```json
28
+ {
29
+ "plugin": ["opencode-supertask"]
30
+ }
31
+ ```
32
+
33
+ 2. Tell the user to restart OpenCode.
34
+
35
+ After restart, the plugin auto-injects:
36
+ - 10 MCP tools (`supertask_add`, `supertask_next`, `supertask_start`, `supertask_done`, `supertask_fail`, `supertask_get`, `supertask_list`, `supertask_status`, `supertask_retry`, `supertask_schedule`)
37
+ - A `supertask-runner` agent (used internally by the Gateway)
38
+ - Usage instructions in the system prompt
39
+
40
+ </details>
41
+
42
+ ### Manual Installation
43
+
44
+ 1. Add the plugin to your `~/.config/opencode/opencode.json`:
45
+
46
+ ```json
47
+ {
48
+ "plugin": ["opencode-supertask"]
49
+ }
50
+ ```
51
+
52
+ 2. Restart OpenCode
53
+
54
+ ### From Source
55
+
56
+ ```bash
57
+ git clone https://github.com/vbgate/opencode-supertask.git
58
+ cd opencode-supertask
59
+ bun install
60
+ bun run build
61
+ ```
62
+
63
+ Then add the local path to your config:
64
+
65
+ ```json
66
+ {
67
+ "plugin": ["/path/to/opencode-supertask"]
68
+ }
69
+ ```
70
+
71
+ ## Quick Start
72
+
73
+ ```bash
74
+ # Install globally for CLI + Gateway
75
+ bun install -g opencode-supertask
76
+
77
+ # Initialize (create config + run migrations)
78
+ supertask init
79
+
80
+ # Start Gateway (foreground)
81
+ supertask gateway
82
+
83
+ # Start Web Dashboard
84
+ supertask ui # → http://localhost:3000
85
+ ```
86
+
87
+ ### Background Running
88
+
89
+ ```bash
90
+ # pm2 (recommended)
91
+ pm2 start "supertask gateway" --name supertask-gateway
92
+
93
+ # systemd
94
+ cp deploy/supertask-gateway.service ~/.config/systemd/user/
95
+ systemctl --user enable --now supertask-gateway
96
+ ```
97
+
98
+ ## CLI Reference
99
+
100
+ ```bash
101
+ supertask init # init config + db
102
+ supertask migrate # run migrations
103
+ supertask gateway # start gateway (foreground)
104
+ supertask ui # start web dashboard
105
+ supertask config # show current config
106
+
107
+ # Task management
108
+ supertask add -n "Task" -a "agent" -p "prompt" --importance 5
109
+ supertask list [--status pending] [--limit 20]
110
+ supertask get --id 1
111
+ supertask status
112
+ supertask cancel --id 1
113
+ supertask retry --id 1
114
+
115
+ # Scheduled templates
116
+ supertask template add --name "Daily" --agent "gen" \
117
+ --prompt "..." --type cron --cron "0 9 * * *"
118
+ supertask template list
119
+ supertask template enable --id 1
120
+ ```
121
+
122
+ ## Architecture
123
+
124
+ ```
125
+ Gateway (supertask gateway)
126
+ ├── Worker → claim tasks, spawn supertask-runner via opencode
127
+ ├── Scheduler → clone tasks from templates (cron / delayed / recurring)
128
+ └── Watchdog → heartbeat timeout, auto-retry, data cleanup
129
+ ```
130
+
131
+ Config file: `~/.config/opencode/supertask.json`
132
+
133
+ ```json
134
+ {
135
+ "worker": { "maxConcurrency": 2, "defaultModel": "zhipuai-coding-plan/glm-4.7" },
136
+ "scheduler": { "enabled": true, "catchUp": "next" },
137
+ "watchdog": { "heartbeatTimeoutMs": 600000, "retentionDays": 30 }
138
+ }
139
+ ```
140
+
141
+ Key mechanisms:
142
+ - **Process lock** — SQLite `BEGIN IMMEDIATE` ensures single instance
143
+ - **Heartbeat** — Worker updates every 30s; Watchdog kills stale processes
144
+ - **Exponential backoff** — 30s × 2^n, capped at 30min
145
+ - **Dead letter queue** — Exhausted retries → `dead_letter`, manually recoverable
146
+ - **Batch isolation** — Same `batchId` serial; different `batchId` parallel
147
+ - **Priority** — `urgency DESC → importance DESC → createdAt ASC`
148
+
149
+ ## Web Dashboard
150
+
151
+ `supertask ui` starts a dashboard at http://localhost:3000 with 4 pages:
152
+
153
+ | Page | Features |
154
+ |------|----------|
155
+ | Task Queue | Filter by status, retry, delete |
156
+ | Scheduled Tasks | Template CRUD, enable/disable, manual trigger |
157
+ | Execution Logs | task_runs history, log viewer |
158
+ | System Status | Config editor, concurrency monitor, stats |
159
+
160
+ ## Data
161
+
162
+ - Database: `~/.local/share/opencode/tasks.db` (SQLite WAL)
163
+ - Config: `~/.config/opencode/supertask.json`
164
+
165
+ ## Requirements
166
+
167
+ - [Bun](https://bun.sh) >= 1.0
168
+ - [OpenCode](https://opencode.ai)
169
+
170
+ ## License
171
+
172
+ MIT
173
+
174
+ ---
175
+
176
+ <a id="简体中文"></a>
177
+
178
+ ## 简体中文
179
+
180
+ SuperTask 是一个基于 SQLite 的 AI Agent 任务调度系统,专为 [OpenCode](https://opencode.ai) 设计。
181
+
182
+ ### 安装
183
+
184
+ #### 让 AI 帮你装
185
+
186
+ 把这段话粘贴到任意 LLM agent(Claude Code、OpenCode、Cursor 等):
187
+
188
+ ```
189
+ 安装 opencode-supertask 插件,参照:https://raw.githubusercontent.com/vbgate/opencode-supertask/main/README.md
190
+ ```
191
+
192
+ #### 手动安装
193
+
194
+ 在 `~/.config/opencode/opencode.json` 中添加:
195
+
196
+ ```json
197
+ {
198
+ "plugin": ["opencode-supertask"]
199
+ }
200
+ ```
201
+
202
+ 重启 OpenCode 即可。插件会自动注入 10 个 MCP 工具、supertask-runner Agent 和使用说明。
203
+
204
+ ### 快速开始
205
+
206
+ ```bash
207
+ bun install -g opencode-supertask
208
+ supertask init # 初始化
209
+ supertask gateway # 启动 Gateway
210
+ supertask ui # Web 控制台
211
+ ```
212
+
213
+ ### 核心功能
214
+
215
+ - **任务队列** — 优先级调度、批次隔离、依赖管理
216
+ - **Gateway 常驻进程** — Worker + Scheduler + Watchdog,自动重试 + 指数退避
217
+ - **定时任务** — 支持 cron / delayed / recurring 三种调度类型
218
+ - **Web 控制台** — 任务监控、执行日志、在线配置
219
+ - **CLI 工具** — 完整的命令行管理
220
+
221
+ ### 数据位置
222
+
223
+ - 数据库:`~/.local/share/opencode/tasks.db`
224
+ - 配置:`~/.config/opencode/supertask.json`
@@ -0,0 +1,2 @@
1
+
2
+ export { }