Loading...
Loading...
Control OpenCode directly via the Agent Client Protocol (ACP). Start sessions, send prompts, resume conversations, and manage OpenCode updates.
npx skill4agent add bjesuiter/opencode-acp-skill opencode-acp-control| Action | How |
|---|---|
| Start OpenCode | |
| Send message | |
| Read response | |
| Stop OpenCode | |
| List sessions | |
| Resume session | List sessions → ask user → |
| Check version | |
bash(
command: "opencode acp --cwd /path/to/your/project",
background: true,
workdir: "/path/to/your/project"
)sessionId\n{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{"fs":{"readTextFile":true,"writeTextFile":true},"terminal":true},"clientInfo":{"name":"clawdbot","title":"Clawdbot","version":"1.0.0"}}}result.protocolVersion: 1{"jsonrpc":"2.0","id":1,"method":"session/new","params":{"cwd":"/path/to/project","mcpServers":[]}}result.sessionId"sess_abc123"{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"sessionId":"sess_abc123","prompt":[{"type":"text","text":"Your question here"}]}}session/updateresult.stopReasonmethod: "session/update"idstopReason{"jsonrpc":"2.0","method":"session/cancel","params":{"sessionId":"sess_abc123"}}processSessionIdopencodeSessionIdmessageIdstopReason| stopReason | Meaning |
|---|---|
| Agent finished responding |
| You cancelled the prompt |
| Token limit reached |
| Issue | Solution |
|---|---|
| Empty poll response | Keep polling - agent is thinking |
| Parse error | Skip malformed line, continue |
| Process exited | Restart OpenCode |
| No response after 5min | Kill process, start fresh |
1. bash(command: "opencode acp --cwd /home/user/myproject", background: true, workdir: "/home/user/myproject")
-> processSessionId: "bg_42"
2. process.write(sessionId: "bg_42", data: '{"jsonrpc":"2.0","id":0,"method":"initialize",...}\n')
process.poll(sessionId: "bg_42") -> initialize response
3. process.write(sessionId: "bg_42", data: '{"jsonrpc":"2.0","id":1,"method":"session/new","params":{"cwd":"/home/user/myproject","mcpServers":[]}}\n')
process.poll(sessionId: "bg_42") -> opencodeSessionId: "sess_xyz789"
4. process.write(sessionId: "bg_42", data: '{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"sessionId":"sess_xyz789","prompt":[{"type":"text","text":"List all TypeScript files"}]}}\n')
5. process.poll(sessionId: "bg_42") every 2 sec until stopReason
-> Collect all session/update content
-> Final response: stopReason: "end_turn"
6. When done: process.kill(sessionId: "bg_42")bash(command: "opencode session list", workdir: "/path/to/project")ID Updated Messages
ses_451cd8ae0ffegNQsh59nuM3VVy 2026-01-11 15:30 12
ses_451a89e63ffea2TQIpnDGtJBkS 2026-01-10 09:15 5
ses_4518e90d0ffeJIpOFI3t3Jd23Q 2026-01-09 14:22 8"Which session would you like to resume?
1. ses_451cd8ae... (12 messages, updated 2026-01-11)
2. ses_451a89e6... (5 messages, updated 2026-01-10)
3. ses_4518e90d... (8 messages, updated 2026-01-09)
Enter session number or ID:"bash(command: "opencode acp --cwd /path/to/project", background: true, workdir: "/path/to/project"){"jsonrpc":"2.0","id":0,"method":"initialize","params":{...}}{"jsonrpc":"2.0","id":1,"method":"session/load","params":{"sessionId":"ses_451cd8ae0ffegNQsh59nuM3VVy","cwd":"/path/to/project","mcpServers":[]}}session/loadcwdmcpServersfunction resumeSession(workdir):
# List available sessions
output = bash("opencode session list", workdir: workdir)
sessions = parseSessionList(output)
if sessions.empty:
notify("No previous sessions found. Starting fresh.")
return createNewSession(workdir)
# Ask user to choose
choice = askUser("Which session to resume?", sessions)
selectedId = matchUserChoice(choice, sessions)
# Start OpenCode and load session
process = bash("opencode acp --cwd " + workdir, background: true, workdir: workdir)
initialize(process)
session_load(process, selectedId, workdir, mcpServers: [])
notify("Session resumed. Conversation history loaded.")
return processbash(command: "opencode --version")opencode version 1.1.131.1.13webfetch(url: "https://github.com/anomalyco/opencode/releases/latest", format: "text")https://github.com/anomalyco/opencode/releases/tag/v1.2.01.2.0process.list() # Find all "opencode acp" processes
process.kill(sessionId) # For each running instancebash(command: "opencode acp --cwd /path/to/project", background: true, workdir: "/path/to/project")bash(command: "opencode --version")curl -fsSL https://opencode.dev/install | bashfunction updateOpenCode():
current = bash("opencode --version") # e.g., "1.1.13"
latestPage = webfetch("https://github.com/anomalyco/opencode/releases/latest")
latest = extractVersionFromRedirectUrl(latestPage) # e.g., "1.2.0"
if semverCompare(latest, current) > 0:
# Stop all instances
for process in process.list():
if process.command.includes("opencode"):
process.kill(process.sessionId)
# Wait briefly for processes to terminate
sleep(2 seconds)
# Restart triggers auto-update
bash("opencode acp", background: true)
# Verify
newVersion = bash("opencode --version")
if newVersion != latest:
notify("Auto-update may have failed. Manual update recommended.")
else:
notify("OpenCode is up to date: " + current)opencodeSessionIdsession/load