Expand description
opencode 1.x and 2.x: the TS plugin adapters/opencode/borg.ts, compiled in and copied to
~/.config/opencode/plugins/borg.ts ($OPENCODE_CONFIG_DIR, $XDG_CONFIG_HOME/opencode). The plugin
translates both ways, sends opencode’s pid, emulates the stop’s second round and gives borg the
stop’s budget (BUDGETS, which borg’s first answer tells it).
Structs§
Constants§
- ADAPTER
- BUDGETS
- What the plugin waits for each of borg’s answers. opencode limits no plugin hook, so each is a guard
against a hung borg holding the engineer’s turn: a prompt waits 5 s and a tool result 2 s for borg’s
context (file appends; a later answer is kept for the next call), a tool call 2 s before it runs (a
stat when nobody steers); the stop, and every call queued behind it, borg’s stop timeout. The
session’s end, queued too, gets the same as its own
end(the plugin’s end waitsend_ms, the other queued callsstop_ms): a hung end holds the session’s queue and the plugin’s cleanup, which ends every session. - CHILDREN
- A guard, not a tuning knob: at most this many children of one session are exported, the rest read from the parent’s copy of their final text.
Functions§
- data_
dir - Where opencode keeps its data (its sessions are read through its CLI, never from here):
$XDG_DATA_HOME/opencode, elsehome/.local/share/opencode. - session_
runs - One run per main session that started subagents, oldest first:
session(ases_…id) only, else every parent of a subagent session sincesince(1.x’s query). A subagent is a child session; the parent’s task tool call (1.xtask, 2.xsubagent) names it (metadata.sessionId/sessionID) with its description, agent and prompt, and holds its final text. Its export gives its cwd and work. opencode has no structured output:outputstays None.