lilac-opencode
Use lilac-opencode to control OpenCode sessions non-interactively via the OpenCode SDK.
This is designed for:
- •continuing OpenCode work via an automation surface (e.g. SSH)
- •running the OpenCode Build agent with auto-approved permissions
- •getting stable, machine-readable JSON output
Core commands
- •List sessions
bash
lilac-opencode sessions list \ --directory /abs/path/to/repo \ --roots \ --limit 20
- •Session snapshot (compact, for agents)
bash
lilac-opencode sessions snapshot \ --directory /abs/path/to/repo \ --continue \ --runs 6 \ --max-chars 1200
- •Prompt (continue newest session in directory)
bash
lilac-opencode prompt \ --directory /abs/path/to/repo \ --text "Continue working on the failing tests" \ --agent build
- •Prompt (continue or create by exact title)
Use
--titleto deterministically continue the same OpenCode session across calls.bashlilac-opencode prompt \ --directory /abs/path/to/repo \ --title "<RUN_ID|DETERMINISTIC_TITLE>" \ --text "Continue where we left off" \ --agent build
- •Prompt (explicit session id)
bash
lilac-opencode prompt \ --directory /abs/path/to/repo \ --session-id sess_xxx \ --text "Do the next step" \ --agent build
Important flags
- •
--directory <path>: always set this to the repo root you want OpenCode to operate in. - •
--base-url <url>: OpenCode server URL (default:http://127.0.0.1:4096). - •
--ensure-server/--no-ensure-server: if enabled, the tool will startopencode servewhen the server is not reachable. - •
--opencode-bin <bin>: path/name of theopencodebinary used foropencode serve(default:opencode). - •
--timeout-ms <n>: hard timeout; on timeout the tool will attemptsession.abort. (default:1200000ms = 20 min) - •
--permission-response once|always: how to auto-approvepermission.asked(default:always).
Non-interactive safety defaults
- •New sessions are created with
questiondenied by default (preventsquestion.askedhangs). - •In-flight question requests are rejected by default.
JSON output
- •Output is always a single JSON object.
- •On errors,
ok=falseand the process exits non-zero.
Remote usage (SSH)
Run the same commands on a remote host (example):
bash
# On your machine: ssh myhost "cd /abs/path/to/repo && lilac-opencode prompt --title lilac:discord:123 --text 'continue'"