Skip to main content

Module opencode

Module opencode 

Source
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§

Opencode

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 waits end_ms, the other queued calls stop_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, else home/.local/share/opencode.
session_runs
One run per main session that started subagents, oldest first: session (a ses_… id) only, else every parent of a subagent session since since (1.x’s query). A subagent is a child session; the parent’s task tool call (1.x task, 2.x subagent) 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: output stays None.

Type Aliases§

Export
Exports a session by id, in the directory given (else wherever it runs).
Query
Runs a read-only query of opencode 1.x’s database (None: no such query).