opencode-bgtaskOpenCode plugin for running shell commands in the background without blocking the AI session
0
23
近 7 天 4
24.2
生态多维模型
2 个月前
2026-05-29
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-bgtask@1.0.1"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-bgtask@1.0.1"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-bgtaskopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Run shell commands in the background without blocking your OpenCode AI session. Full job lifecycle management: start, list, view output, stop.
Install
Via npm (Recommended)
Add to your opencode.json:
{
"plugin": ["opencode-bgtask"]
}
Restart OpenCode. The npm package is installed automatically.
Local Install
Place index.ts in the .opencode/plugins/ directory and restart OpenCode.
Tools
bg_start
Start a background command.
| Parameter | Type | Required | Description |
|---|---|---|---|
command |
string | Yes | The shell command to execute |
shell |
string | No | Shell to use: pwsh, powershell, cmd, bash, sh, zsh. Auto-detected if not specified |
cwd |
string | No | Working directory, defaults to project root |
timeout |
number | No | Timeout in seconds after which the job is killed |
bg_list
List all background jobs with their status (running / completed / failed / killed / timeout).
bg_output
View a job's output.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string | Yes | The job ID |
lines |
number | No | Number of recent lines to return, default 50, max 500 |
bg_stop
Stop a running job.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string | Yes | The job ID to stop |
Supported Shells
| Shell | Windows | Linux/macOS |
|---|---|---|
| pwsh (PowerShell 7+) | ✅ Default | — |
| powershell (Windows PowerShell 5.1) | ✅ Fallback | — |
| cmd | ✅ Fallback | — |
| bash | ✅ (Git Bash) | ✅ Default |
| sh | — | ✅ Fallback |
| zsh | — | ✅ |
Limits
- Max concurrent jobs: 20
- Log file max size: 50MB (truncated from head)
- History retention: 100 most recent records
- Output stored in
~/opencode/bg/(outside project directory)
License
MIT