← 返回列表
全部 Skill›工具 Tools›opencode-dev

opencode-dev

作者 @anomalyco · 语言 en
Use when interactively running, debugging, or verifying opencode's own CLI/TUI or server during development in this repo — starting the dev TUI, driving it with termctrl, hitting the server/API directly, reading log files, or attaching Bun's inspector.
工具 Tools调试工具通用执行命令待翻译
最近源活动
—
检测 SKILL.md 语言
en
星标 ★
229,002
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

Debugging opencode itself

Workflow for interactively exercising the CLI/TUI and server while developing in this repo. All commands below run from packages/cli unless noted otherwise.

Server/client model

opencode is a client/server system, not a single monolithic process:

  • Server process runs the Effect HTTP API (packages/server) and owns all domain state: sessions, database, plugins, permissions, Location services. It's started by the serve command (packages/cli/src/commands/handlers/serve.ts).
  • TUI process is a separate process that runs no application logic itself — it's an HTTP/SSE client of the server via @opencode/client (OpenCode.make).
  • Discovery: CLI processes find the shared server through a JSON registration file at ~/.local/state/opencode/service.json (or service-local.json for the local/dev channel) containing {id, version, url, pid, password}; the password is used for HTTP Basic auth. Before reusing a registration, the client calls GET /api/info to confirm the server is alive, is the registered PID, and is version-compatible. opencode service status prints the registered URL.
  • Sharing: because of this registration/health-check dance, many concurrent opencode/TUI invocations converge on one shared background daemon rather than each spawning their own. If no compatible healthy daemon is found, a new one is spawned detached (serve --service) and registers itself.
  • bun dev service start|status|stop|restart manages this shared background daemon's lifecycle directly — useful when you need to force a fresh server, confirm one is running, or kill a stuck one.
  • Standalone mode (--standalone) opts a single invocation out of the shared daemon: it spawns a private one-off serve --stdio --port 0 child tied to that invocation's lifetime, with its own random password. Use this to isolate a debugging session from your other running opencode sessions.
  • Every log line is tagged role=server or role=cli and a per-process run=<id>, so you can distinguish server-side and client-side activity in one shared log file (see "Logs" below) even when both roles are interleaved from concurrent processes.

Starting the dev TUI

  • packages/cli is the CLI and TUI entrypoint. bun dev from packages/cli and the repository-root bun dev both run packages/cli/src/index.ts.
  • bun dev connects to the shared local-channel background service (service-local.json), starting it if needed. Every worktree on the machine shares that service. Add --standalone for a private server tied to this one process.
  • Use bun run dev:live from the repository root to run this worktree's TUI against the installed opencode background server and your real sessions.

Interactive debugging with termctrl

  • Use termctrl for interactive checks instead of starting the TUI as a blocking foreground process. It provides a real PTY, handles OpenTUI's host handshake, and can save reviewable screenshots.
  • Use a dedicated session name and do not reuse or kill an unrelated session.
termctrl start opencode-dev --host opentui --cols 112 --rows 34 -- bun dev
termctrl wait opencode-dev "Ask anything" --timeout 20000
termctrl show opencode-dev
  • Wait for visible text before interacting instead of relying on fixed sleeps. Use the text expected from the screen under test, such as Ask anything or Connect a provider.
  • Drive the running TUI with termctrl send. Prefix typed input with text: and send control keys separately so the interaction matches real terminal input.
termctrl send opencode-dev 'text:example prompt' enter
termctrl send opencode-dev ctrl-c
  • Use termctrl show after each meaningful interaction and inspect the full visible screen for rendering errors, stale state, error toasts, and unexpected exits.
  • Save PNG evidence for every user-visible bug and fix. Do not save text captures; inspect the rendered PNG. Write temporary captures outside the repository unless the artifact is intended to be committed.
termctrl save opencode-dev --format png --out /tmp/opencode/tui.png
  • For resize-sensitive changes, resize the viewport, wait for the expected content, and capture the screen again:
termctrl resize opencode-dev --cols 100 --rows 30
termctrl show opencode-dev
  • Source changes may require restarting the process. Use termctrl restart opencode-dev rather than assuming the running TUI reloaded the change. Restarting the TUI does not restart the shared background service, so run bun dev service restart after server-side changes, or use --standalone.
  • To exercise background-service behavior, use bun dev service start, bun dev service status, and bun dev service stop.
  • Always clean up the Terminal Control session when the check is complete:
termctrl stop opencode-dev

Server/API debugging

  • Use bun dev api --help from packages/cli to inspect the API debugging command. It sends one request to the server using the same daemon discovery/auth path as the CLI.
  • Use bun dev api to introspect the server-side data backing the TUI. This is useful when debugging UI bugs: compare what the screen renders with the raw session, message, event, agent, or health data returned by the API to determine whether the bug is in the server state, the client data layer, or the TUI rendering.
  • bun dev api accepts either an OpenAPI operation ID or a raw HTTP method plus path:
bun dev api get /api/info
bun dev api get /openapi.json
bun dev api <operationId> --param key=value
  • Pass JSON request bodies with --data/-d; the command sets content-type: application/json au
评论
Aanomalyco
anomalyco
anomalyco/opencode
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@anomalyco
所属大类工具 Tools / 调试工具
国内可用性通用
最近源活动—
风险提示执行命令
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。