Skip to content

companion: add --variant and repeatable --file flags (mirroring opencode run) - #10

Open
stevenpollack wants to merge 2 commits into
tasict:mainfrom
stevenpollack:companion-variant-and-file-flags
Open

companion: add --variant and repeatable --file flags (mirroring opencode run)#10
stevenpollack wants to merge 2 commits into
tasict:mainfrom
stevenpollack:companion-variant-and-file-flags

Conversation

@stevenpollack

Copy link
Copy Markdown

Summary

The companion task/task-worker/review/adversarial-review commands now accept the same runtime-selection flags you'd pass to opencode run:

  • --variant <name> (7ee4044) — provider-specific reasoning effort (e.g. high, max, minimal). Passed through to the HTTP API's prompt body, exactly where opencode run --variant sends it. Recorded in job state, logged on dispatch, and forwarded to background workers.
  • --file <path> (62d8a80) — repeatable file/directory attachments, like opencode run -f. Each path becomes a file:// file part with text/plain (or application/x-directory) mime, mirroring the CLI's local-run behavior: the server inlines content via its Read tool, so there's no base64 encoding or size bloat. Paths resolve against the workspace root and are validated before a session is created or a worker is spawned.

Also fixes --model, which was previously parsed and recorded but never actually sent with the prompt — and would have been rejected as a raw string. buildPromptBody now converts provider/model into the {providerID, modelID} object the API's ModelRef schema requires.

Docs (rescue command/agent/skill, README) and unit tests are updated. Dispatch docs instruct the subagent to pass these flags through only when the user explicitly supplies them.

Testing

  • npm test: 55/55 pass (new suites for buildFilePart, attachments ordering, repeatable arrayOptions parsing, --variant/--model body handling)
  • Live end-to-end against opencode 1.18.25:
    • task --variant high → server-returned message records "variant": "high" with reasoning tokens engaged
    • task --agent plan --variant high --file <canary> → model returned the exact canary file content through the server's Read-tool pipeline

task, task-worker, review, and adversarial-review now accept
--variant <name> (provider-specific reasoning effort, e.g. high,
max, minimal) and pass it through to the OpenCode HTTP API's
prompt body. For background tasks it is recorded in job state,
logged on dispatch, and forwarded to the worker.

Also fix --model, which was parsed and recorded but never sent
with the prompt: buildPromptBody now converts a provider/model
string to the {providerID, modelID} object the API's ModelRef
schema requires, instead of sending a raw string that would be
rejected.

Update rescue command/agent/skill docs and README, and add unit
tests for buildPromptBody.
task and task-worker now accept --file <path> (repeatable) and attach
each path to the OpenCode prompt as a file part. Mirroring the CLI's
local-run behavior, parts carry a file:// URL with text/plain (or
application/x-directory) mime, and the server inlines content via its
Read tool -- no base64 encoding or size bloat. Paths resolve against
the workspace root, are validated before a session is created or a
worker is spawned, and are recorded in job state and the dispatch log.

parseArgs grows an arrayOptions schema for repeatable value flags,
and buildPromptBody places attachments before the text part to match
the CLI's parts ordering. Docs and tests updated accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant