opencode-supertask 0.1.22 → 0.1.24

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
@@ -36,10 +36,11 @@ The plugin never installs global dependencies by itself. Without a running Gatew
36
36
  2. Remove `"opencode-supertask"` from `~/.config/opencode/opencode.json`
37
37
  3. Restart OpenCode
38
38
 
39
- To clean up all data, delete the database:
39
+ To clear all task data safely, stop the Gateway and use the backup-first database command:
40
40
 
41
41
  ```bash
42
- rm ~/.local/share/opencode/tasks.db
42
+ pm2 stop supertask-gateway
43
+ supertask db clear --confirm CLEAR
43
44
  ```
44
45
 
45
46
  ### CLI Install / Uninstall
@@ -109,8 +110,16 @@ supertask template add --name "Hourly" --agent "gen" \
109
110
  --batch "reports" --retry-backoff "30s" --timeout "30min"
110
111
  supertask template list
111
112
  supertask template enable --id 1
113
+
114
+ # Database maintenance
115
+ supertask db check
116
+ supertask db backup [--output /path/to/tasks-backup.db]
117
+ supertask db clear --confirm CLEAR
118
+ supertask db restore --from /path/to/tasks-backup.db --confirm RESTORE
112
119
  ```
113
120
 
121
+ `db backup` creates and validates a standalone SQLite snapshot. `db clear` and `db restore` refuse to run while another Gateway or task is active; both create a safety backup before changing data. Stop the PM2 Gateway before using the destructive CLI commands.
122
+
114
123
  ### Duration Format
115
124
 
116
125
  Schedule supports friendly duration strings:
@@ -177,7 +186,7 @@ Health endpoint: `GET http://localhost:4680/health` returns 200 only after Gatew
177
186
  | Task Queue | Filter by status, retry, delete |
178
187
  | Scheduled Tasks | Template CRUD, enable/disable, manual trigger |
179
188
  | Execution Logs | task_runs history with session tracking |
180
- | System Status | Config editor, concurrency monitor, clear database |
189
+ | System Status | Config editor, concurrency monitor, backup-first transactional database clear |
181
190
 
182
191
  ## Data
183
192
 
@@ -228,7 +237,12 @@ supertask gateway # 前台运行:不需要 pm2
228
237
  2. 从 `~/.config/opencode/opencode.json` 中移除 `"opencode-supertask"`
229
238
  3. 重启 OpenCode
230
239
 
231
- 清理所有数据:`rm ~/.local/share/opencode/tasks.db`
240
+ 安全清理所有任务数据:
241
+
242
+ ```bash
243
+ pm2 stop supertask-gateway
244
+ supertask db clear --confirm CLEAR
245
+ ```
232
246
 
233
247
  ### 定时任务
234
248
 
@@ -252,9 +266,20 @@ supertask template add --type cron --cron "0 9 * * *" ...
252
266
  - **进程守护** — 可选 pm2 崩溃恢复;插件加载不会安装 pm2,但可复用机器上已有的 PM2
253
267
  - **版本感知重启** — 已安装 pm2 时,插件加载会在包版本变化后启动或重启 Gateway
254
268
  - **定时任务** — cron / delayed / recurring,支持友好时间格式
255
- - **Web 控制台** — 任务监控、执行日志、在线配置、清空数据库
269
+ - **Web 控制台** — 任务监控、执行日志、在线配置、自动备份后事务性清空数据库
256
270
  - **Session 追踪** — 自动从 opencode run 输出中捕获 session ID
257
271
 
272
+ ### 数据库维护
273
+
274
+ ```bash
275
+ supertask db check
276
+ supertask db backup [--output /path/to/tasks-backup.db]
277
+ supertask db clear --confirm CLEAR
278
+ supertask db restore --from /path/to/tasks-backup.db --confirm RESTORE
279
+ ```
280
+
281
+ `db backup` 会生成并校验可独立恢复的 SQLite 快照。CLI 清空和恢复会拒绝活跃 Gateway 或运行中任务,并在修改数据前自动保留安全备份;执行这两个危险命令前应先停止 PM2 Gateway。
282
+
258
283
  ### 数据位置
259
284
 
260
285
  - 数据库:`~/.local/share/opencode/tasks.db`