Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ adds a round-trip to another CLI, so use it when the extra signal is worth the t
| Gemini CLI | `gemini` | `gemini-2.5-pro` | Google models, auto-routing |
| Junie | `junie` | Junie default | LLM-agnostic, BYOK support |
| Qwen Code | `qwen` | Qwen default | Qwen model family, `--yolo` for auto-approve |
| OpenCode | `opencode` | OpenCode default | Multi-provider, uses `run` subcommand |
| OpenCode | `opencode` | OpenCode default | Multi-provider, uses `run` subcommand with auto-approval |

## How to use it

Expand Down
11 changes: 6 additions & 5 deletions opencode/references/cli-opencode.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@

- **Command:** `opencode`
- **Non-interactive subcommand:** `opencode run` (auto-approves tool use in non-interactive mode)
- **Output format flag:** `--format default|json` (`default` outputs plain text to stdout; ANSI/session header goes to stderr)
- **Model flag:** `-m` / `--model` (format: `provider/model`, e.g. `opencode/big-model-name`, `anthropic/claude-sonnet-4-6`)
- **Output format flag:** `--format default|json` (`default` outputs formatted text to stdout; ANSI/session header goes to stderr, `json` outputs raw JSON events)
- **Model flag:** `-m` / `--model` (format: `provider/model`, e.g. `anthropic/claude-sonnet-4`, `openai/gpt-4o`)
- **List models command:** `opencode models` (requires configured provider credentials)
- **Self-call detection:** Check for `OPENCODE` environment variable (set to `1` inside OpenCode sessions), or `opencode` in process ancestry

## 2. Model Selection Heuristic

- **Default model (fallback):** OpenCode's default model (confirm via `opencode models`)
- **Aliases:** None — use full `provider/model` IDs
- **Quirks:** OpenCode is multi-provider (OpenAI, Anthropic, Google, AWS Bedrock, Groq, Azure, OpenRouter). Model IDs use `provider/model` format. The `run` subcommand auto-approves all tool use in non-interactive mode — there is no separate `--yolo` or `--trust` flag. The `--format default` output sends ANSI codes and session header to stderr; stdout is clean text.
- **Quirks:** OpenCode is multi-provider (OpenAI, Anthropic, Google, AWS Bedrock, Groq, Azure, OpenRouter). Model IDs use `provider/model` format. The `run` subcommand auto-approves all tool use in non-interactive mode. The `--format default` output sends ANSI codes and session header to stderr; stdout is clean text. The `--format json` option outputs raw JSON events for programmatic consumption.

## 3. Invocation Template

| Mode | Command |
|----------------|-------------------------------------------------------------------------------|
| **Validation** | `cat "$PROMPT_FILE" \| opencode run -m <model> --format default 2>/dev/null` |
| **Validation** | `cat "$PROMPT_FILE" \| opencode run -m <model> --format json 2>/dev/null` |
| **Delegation** | `cat "$PROMPT_FILE" \| opencode run -m <model> --format default 2>/dev/null` |

Note: Both modes use the same command because OpenCode auto-approves all actions in non-interactive `run` mode. Prompt is piped via stdin. OpenCode does not expose an internal `--timeout` flag; enforce the 120-second limit per `references/shared-procedure.md` Step 6 (kill the process if it does not exit). Stderr is suppressed (`2>/dev/null`) to remove ANSI codes and session header from output.
Note: Validation mode uses `--format json` to get structured output for parsing, while Delegation mode uses `--format default` for human-readable output. Both modes use the `run` subcommand because OpenCode auto-approves all actions in non-interactive mode. Prompt is piped via stdin. OpenCode does not expose an internal `--timeout` flag; enforce the 120-second limit per `references/shared-procedure.md` Step 6 (kill the process if it does not exit). Stderr is suppressed (`2>/dev/null`) to remove ANSI codes and session header from output.

## 4. Version Compatibility Matrix

| Version | Model Flag | Run Subcommand | Format Flag | Notes |
|---------|--------------------|----------------|--------------------------|--------------------------------|
| 1.3.10 | `-m` / `--model` | `run` | `--format default\|json` | Verified; stdin piping works |
| 1.17.8 | `-m` / `--model` | `run` | `--format default\|json` | Current version; full feature set available |
11 changes: 6 additions & 5 deletions references/cli-opencode.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@

- **Command:** `opencode`
- **Non-interactive subcommand:** `opencode run` (auto-approves tool use in non-interactive mode)
- **Output format flag:** `--format default|json` (`default` outputs plain text to stdout; ANSI/session header goes to stderr)
- **Model flag:** `-m` / `--model` (format: `provider/model`, e.g. `opencode/big-model-name`, `anthropic/claude-sonnet-4-6`)
- **Output format flag:** `--format default|json` (`default` outputs formatted text to stdout; ANSI/session header goes to stderr, `json` outputs raw JSON events)
- **Model flag:** `-m` / `--model` (format: `provider/model`, e.g. `anthropic/claude-sonnet-4`, `openai/gpt-4o`)
- **List models command:** `opencode models` (requires configured provider credentials)
- **Self-call detection:** Check for `OPENCODE` environment variable (set to `1` inside OpenCode sessions), or `opencode` in process ancestry

## 2. Model Selection Heuristic

- **Default model (fallback):** OpenCode's default model (confirm via `opencode models`)
- **Aliases:** None — use full `provider/model` IDs
- **Quirks:** OpenCode is multi-provider (OpenAI, Anthropic, Google, AWS Bedrock, Groq, Azure, OpenRouter). Model IDs use `provider/model` format. The `run` subcommand auto-approves all tool use in non-interactive mode — there is no separate `--yolo` or `--trust` flag. The `--format default` output sends ANSI codes and session header to stderr; stdout is clean text.
- **Quirks:** OpenCode is multi-provider (OpenAI, Anthropic, Google, AWS Bedrock, Groq, Azure, OpenRouter). Model IDs use `provider/model` format. The `run` subcommand auto-approves all tool use in non-interactive mode. The `--format default` output sends ANSI codes and session header to stderr; stdout is clean text. The `--format json` option outputs raw JSON events for programmatic consumption.

## 3. Invocation Template

| Mode | Command |
|----------------|-------------------------------------------------------------------------------|
| **Validation** | `cat "$PROMPT_FILE" \| opencode run -m <model> --format default 2>/dev/null` |
| **Validation** | `cat "$PROMPT_FILE" \| opencode run -m <model> --format json 2>/dev/null` |
| **Delegation** | `cat "$PROMPT_FILE" \| opencode run -m <model> --format default 2>/dev/null` |

Note: Both modes use the same command because OpenCode auto-approves all actions in non-interactive `run` mode. Prompt is piped via stdin. OpenCode does not expose an internal `--timeout` flag; enforce the 120-second limit per `references/shared-procedure.md` Step 6 (kill the process if it does not exit). Stderr is suppressed (`2>/dev/null`) to remove ANSI codes and session header from output.
Note: Validation mode uses `--format json` to get structured output for parsing, while Delegation mode uses `--format default` for human-readable output. Both modes use the `run` subcommand because OpenCode auto-approves all actions in non-interactive mode. Prompt is piped via stdin. OpenCode does not expose an internal `--timeout` flag; enforce the 120-second limit per `references/shared-procedure.md` Step 6 (kill the process if it does not exit). Stderr is suppressed (`2>/dev/null`) to remove ANSI codes and session header from output.

## 4. Version Compatibility Matrix

| Version | Model Flag | Run Subcommand | Format Flag | Notes |
|---------|--------------------|----------------|--------------------------|--------------------------------|
| 1.3.10 | `-m` / `--model` | `run` | `--format default\|json` | Verified; stdin piping works |
| 1.17.8 | `-m` / `--model` | `run` | `--format default\|json` | Current version; full feature set available |
Loading