ralph.rb 1.2.435535439 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +2 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +53 -0
- data/lib/ralph/cli.rb +67 -186
- data/lib/ralph/display.rb +105 -0
- data/lib/ralph/events.rb +117 -0
- data/lib/ralph/loop.rb +113 -170
- data/lib/ralph/metrics.rb +88 -0
- data/lib/ralph/opencode.rb +66 -0
- data/lib/ralph/version.rb +1 -1
- data/lib/ralph.rb +0 -3
- data/plans/00-complete-implementation.md +120 -0
- data/plans/01-cli-implementation.md +53 -0
- data/plans/02-loop-implementation.md +78 -0
- data/plans/03-agents-implementation.md +76 -0
- data/plans/04-metrics-implementation.md +98 -0
- data/plans/README.md +63 -0
- data/specs/README.md +4 -15
- data/specs/__templates__/API_TEMPLATE.md +0 -0
- data/specs/__templates__/AUTOMATION_ACTION_TEMPLATE.md +0 -0
- data/specs/__templates__/AUTOMATION_TRIGGER_TEMPLATE.md +0 -0
- data/specs/__templates__/CONTROLLER_TEMPLATE.md +32 -0
- data/specs/__templates__/INTEGRATION_TEMPLATE.md +0 -0
- data/specs/__templates__/MODEL_TEMPLATE.md +0 -0
- data/specs/agents.md +426 -120
- data/specs/cli.md +11 -218
- data/specs/lib/todo_item.rb +144 -0
- data/specs/log +15 -0
- data/specs/loop.md +42 -0
- data/specs/metrics.md +51 -0
- metadata +23 -39
- data/lib/ralph/agents/base.rb +0 -132
- data/lib/ralph/agents/claude_code.rb +0 -24
- data/lib/ralph/agents/codex.rb +0 -25
- data/lib/ralph/agents/open_code.rb +0 -30
- data/lib/ralph/agents.rb +0 -24
- data/lib/ralph/config.rb +0 -40
- data/lib/ralph/git/file_snapshot.rb +0 -60
- data/lib/ralph/helpers.rb +0 -76
- data/lib/ralph/iteration.rb +0 -220
- data/lib/ralph/output/active_loop_error.rb +0 -13
- data/lib/ralph/output/banner.rb +0 -29
- data/lib/ralph/output/completion_deferred.rb +0 -12
- data/lib/ralph/output/completion_detected.rb +0 -17
- data/lib/ralph/output/config_summary.rb +0 -31
- data/lib/ralph/output/context_consumed.rb +0 -11
- data/lib/ralph/output/iteration.rb +0 -45
- data/lib/ralph/output/max_iterations_reached.rb +0 -16
- data/lib/ralph/output/no_plugin_warning.rb +0 -14
- data/lib/ralph/output/nonzero_exit_warning.rb +0 -11
- data/lib/ralph/output/plugin_error.rb +0 -12
- data/lib/ralph/output/status.rb +0 -176
- data/lib/ralph/output/struggle_warning.rb +0 -18
- data/lib/ralph/output/task_completion.rb +0 -12
- data/lib/ralph/output/tasks_file_created.rb +0 -11
- data/lib/ralph/prompt_template.rb +0 -183
- data/lib/ralph/storage/context.rb +0 -58
- data/lib/ralph/storage/history.rb +0 -117
- data/lib/ralph/storage/state.rb +0 -178
- data/lib/ralph/storage/tasks.rb +0 -244
- data/lib/ralph/threads/heartbeat.rb +0 -44
- data/lib/ralph/threads/stream_reader.rb +0 -50
- data/original/bin/ralph.js +0 -13
- data/original/ralph.ts +0 -1706
- data/specs/iteration.md +0 -173
- data/specs/output.md +0 -104
- data/specs/storage/local-data-structure.md +0 -246
- data/specs/tasks.md +0 -295
data/specs/agents.md
CHANGED
|
@@ -1,172 +1,478 @@
|
|
|
1
1
|
# Agents Specification
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
How will we interact with console agents?
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
We will simply run opencode in headless mode, and pass in the prompt, model, and other options.
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
Opencode will have it's own object that will call the command. The Opencode object will have configuration options that will be passed to the command.
|
|
12
|
+
|
|
13
|
+
## Opencode CLI docs
|
|
14
|
+
|
|
15
|
+
These are the official opencode cli docs. We want ot use `opencode run`. And not much else really. Don't add stupid features we don't need.
|
|
16
|
+
Specify:
|
|
17
|
+
- model
|
|
18
|
+
- agent
|
|
19
|
+
- prompt
|
|
20
|
+
- format (JSON STREAM)
|
|
6
21
|
|
|
7
22
|
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
open_code.rb # Ralph::Agents::OpenCode
|
|
11
|
-
claude_code.rb # Ralph::Agents::ClaudeCode
|
|
12
|
-
codex.rb # Ralph::Agents::Codex
|
|
13
|
-
```
|
|
23
|
+
CLI
|
|
24
|
+
OpenCode CLI options and commands.
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
The OpenCode CLI by default starts the TUI when run without any arguments.
|
|
16
27
|
|
|
17
|
-
|
|
28
|
+
Terminal window
|
|
29
|
+
opencode
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
But it also accepts commands as documented on this page. This allows you to interact with OpenCode programmatically.
|
|
20
32
|
|
|
21
|
-
|
|
33
|
+
Terminal window
|
|
34
|
+
opencode run "Explain how closures work in JavaScript"
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
tui
|
|
37
|
+
Start the OpenCode terminal user interface.
|
|
24
38
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- **Consumers:** `Loop#resolve_agent!`, `Output::Status`
|
|
39
|
+
Terminal window
|
|
40
|
+
opencode [project]
|
|
28
41
|
|
|
29
|
-
|
|
42
|
+
Flags
|
|
43
|
+
Flag Short Description
|
|
44
|
+
--continue -c Continue the last session
|
|
45
|
+
--session -s Session ID to continue
|
|
46
|
+
--prompt Prompt to use
|
|
47
|
+
--model -m Model to use in the form of provider/model
|
|
48
|
+
--agent Agent to use
|
|
49
|
+
--port Port to listen on
|
|
50
|
+
--hostname Hostname to listen on
|
|
51
|
+
Commands
|
|
52
|
+
The OpenCode CLI also has the following commands.
|
|
30
53
|
|
|
31
|
-
|
|
54
|
+
agent
|
|
55
|
+
Manage agents for OpenCode.
|
|
32
56
|
|
|
33
|
-
|
|
34
|
-
|
|
57
|
+
Terminal window
|
|
58
|
+
opencode agent [command]
|
|
35
59
|
|
|
36
|
-
|
|
60
|
+
attach
|
|
61
|
+
Attach a terminal to an already running OpenCode backend server started via serve or web commands.
|
|
37
62
|
|
|
38
|
-
|
|
63
|
+
Terminal window
|
|
64
|
+
opencode attach [url]
|
|
39
65
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
This allows using the TUI with a remote OpenCode backend. For example:
|
|
67
|
+
|
|
68
|
+
Terminal window
|
|
69
|
+
# Start the backend server for web/mobile access
|
|
70
|
+
opencode web --port 4096 --hostname 0.0.0.0
|
|
71
|
+
|
|
72
|
+
# In another terminal, attach the TUI to the running backend
|
|
73
|
+
opencode attach http://10.20.30.40:4096
|
|
74
|
+
|
|
75
|
+
Flags
|
|
76
|
+
Flag Short Description
|
|
77
|
+
--dir Working directory to start TUI in
|
|
78
|
+
--session -s Session ID to continue
|
|
79
|
+
create
|
|
80
|
+
Create a new agent with custom configuration.
|
|
81
|
+
|
|
82
|
+
Terminal window
|
|
83
|
+
opencode agent create
|
|
84
|
+
|
|
85
|
+
This command will guide you through creating a new agent with a custom system prompt and tool configuration.
|
|
86
|
+
|
|
87
|
+
list
|
|
88
|
+
List all available agents.
|
|
89
|
+
|
|
90
|
+
Terminal window
|
|
91
|
+
opencode agent list
|
|
92
|
+
|
|
93
|
+
auth
|
|
94
|
+
Command to manage credentials and login for providers.
|
|
95
|
+
|
|
96
|
+
Terminal window
|
|
97
|
+
opencode auth [command]
|
|
98
|
+
|
|
99
|
+
login
|
|
100
|
+
OpenCode is powered by the provider list at Models.dev, so you can use opencode auth login to configure API keys for any provider you’d like to use. This is stored in ~/.local/share/opencode/auth.json.
|
|
101
|
+
|
|
102
|
+
Terminal window
|
|
103
|
+
opencode auth login
|
|
104
|
+
|
|
105
|
+
When OpenCode starts up it loads the providers from the credentials file. And if there are any keys defined in your environments or a .env file in your project.
|
|
106
|
+
|
|
107
|
+
list
|
|
108
|
+
Lists all the authenticated providers as stored in the credentials file.
|
|
109
|
+
|
|
110
|
+
Terminal window
|
|
111
|
+
opencode auth list
|
|
112
|
+
|
|
113
|
+
Or the short version.
|
|
114
|
+
|
|
115
|
+
Terminal window
|
|
116
|
+
opencode auth ls
|
|
117
|
+
|
|
118
|
+
logout
|
|
119
|
+
Logs you out of a provider by clearing it from the credentials file.
|
|
120
|
+
|
|
121
|
+
Terminal window
|
|
122
|
+
opencode auth logout
|
|
47
123
|
|
|
48
|
-
|
|
124
|
+
github
|
|
125
|
+
Manage the GitHub agent for repository automation.
|
|
49
126
|
|
|
50
|
-
|
|
127
|
+
Terminal window
|
|
128
|
+
opencode github [command]
|
|
51
129
|
|
|
52
|
-
|
|
130
|
+
install
|
|
131
|
+
Install the GitHub agent in your repository.
|
|
53
132
|
|
|
54
|
-
|
|
133
|
+
Terminal window
|
|
134
|
+
opencode github install
|
|
55
135
|
|
|
56
|
-
|
|
57
|
-
|--------|-----------|---------|---------|
|
|
58
|
-
| `type` | `-> Symbol` | `:opencode`, `:claude_code`, or `:codex` | Internal identifier used for agent-specific branching |
|
|
59
|
-
| `command` | `-> String` | CLI binary name | The executable name looked up on `$PATH` |
|
|
60
|
-
| `config_name` | `-> String` | Human-readable name | Display name used in banners, warnings, status output |
|
|
61
|
-
| `build_args` | `(prompt, model, options) -> Array<String>` | CLI argument array | Constructs the argument list for the agent subprocess |
|
|
62
|
-
| `parse_tool_output` | `(line) -> String or nil` | Tool name or nil | Extracts a tool invocation name from a single output line |
|
|
136
|
+
This sets up the necessary GitHub Actions workflow and guides you through the configuration process. Learn more.
|
|
63
137
|
|
|
64
|
-
|
|
138
|
+
run
|
|
139
|
+
Run the GitHub agent. This is typically used in GitHub Actions.
|
|
65
140
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
| `build_env` | `(options) -> Hash<String, String>` | Environment hash | Returns `ENV.to_h.dup`. Subclasses may override to customise the subprocess environment |
|
|
69
|
-
| `validate!` | `-> void` | — | Checks that `command` is found on `$PATH` via `which`. Prints an error to `$stderr` and calls `exit 1` if missing |
|
|
141
|
+
Terminal window
|
|
142
|
+
opencode github run
|
|
70
143
|
|
|
71
|
-
|
|
144
|
+
Flags
|
|
145
|
+
Flag Description
|
|
146
|
+
--event GitHub mock event to run the agent for
|
|
147
|
+
--token GitHub personal access token
|
|
148
|
+
mcp
|
|
149
|
+
Manage Model Context Protocol servers.
|
|
72
150
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- `options` — Hash with execution options:
|
|
76
|
-
- `:allow_all_permissions` — Boolean, whether to pass auto-approve flags
|
|
151
|
+
Terminal window
|
|
152
|
+
opencode mcp [command]
|
|
77
153
|
|
|
78
|
-
|
|
154
|
+
add
|
|
155
|
+
Add an MCP server to your configuration.
|
|
79
156
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
- Returns the tool name `String` if matched, `nil` otherwise
|
|
83
|
-
- **Consumers:** `Iteration#stream_agent` (real-time tool counting), `Helpers.collect_tool_summary_from_text` (post-hoc counting)
|
|
157
|
+
Terminal window
|
|
158
|
+
opencode mcp add
|
|
84
159
|
|
|
85
|
-
|
|
160
|
+
This command will guide you through adding either a local or remote MCP server.
|
|
86
161
|
|
|
87
|
-
|
|
162
|
+
list
|
|
163
|
+
List all configured MCP servers and their connection status.
|
|
88
164
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
| `type` | `:opencode` |
|
|
92
|
-
| `command` | `"opencode"` |
|
|
93
|
-
| `config_name` | `"OpenCode"` |
|
|
165
|
+
Terminal window
|
|
166
|
+
opencode mcp list
|
|
94
167
|
|
|
95
|
-
|
|
96
|
-
1. Starts with `["run"]`
|
|
97
|
-
2. Appends `["-m", model]` if model is non-empty
|
|
98
|
-
3. Appends the prompt as the final argument
|
|
168
|
+
Or use the short version.
|
|
99
169
|
|
|
100
|
-
|
|
170
|
+
Terminal window
|
|
171
|
+
opencode mcp ls
|
|
101
172
|
|
|
102
|
-
|
|
173
|
+
auth
|
|
174
|
+
Authenticate with an OAuth-enabled MCP server.
|
|
103
175
|
|
|
104
|
-
|
|
176
|
+
Terminal window
|
|
177
|
+
opencode mcp auth [name]
|
|
105
178
|
|
|
106
|
-
|
|
107
|
-
|----------|-------|
|
|
108
|
-
| `type` | `:claude_code` |
|
|
109
|
-
| `command` | `"claude"` |
|
|
110
|
-
| `config_name` | `"Claude Code"` |
|
|
179
|
+
If you don’t provide a server name, you’ll be prompted to select from available OAuth-capable servers.
|
|
111
180
|
|
|
112
|
-
|
|
113
|
-
1. Starts with `["-p", prompt]`
|
|
114
|
-
2. Appends `["--model", model]` if model is non-empty
|
|
115
|
-
3. Appends `"--dangerously-skip-permissions"` if `options[:allow_all_permissions]` is truthy
|
|
181
|
+
You can also list OAuth-capable servers and their authentication status.
|
|
116
182
|
|
|
117
|
-
|
|
183
|
+
Terminal window
|
|
184
|
+
opencode mcp auth list
|
|
118
185
|
|
|
119
|
-
|
|
186
|
+
Or use the short version.
|
|
120
187
|
|
|
121
|
-
|
|
188
|
+
Terminal window
|
|
189
|
+
opencode mcp auth ls
|
|
122
190
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
| `type` | `:codex` |
|
|
126
|
-
| `command` | `"codex"` |
|
|
127
|
-
| `config_name` | `"Codex"` |
|
|
191
|
+
logout
|
|
192
|
+
Remove OAuth credentials for an MCP server.
|
|
128
193
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
2. Appends `["--model", model]` if model is non-empty
|
|
132
|
-
3. Appends `"--full-auto"` if `options[:allow_all_permissions]` is truthy
|
|
133
|
-
4. Appends the prompt as the final argument
|
|
194
|
+
Terminal window
|
|
195
|
+
opencode mcp logout [name]
|
|
134
196
|
|
|
135
|
-
|
|
197
|
+
debug
|
|
198
|
+
Debug OAuth connection issues for an MCP server.
|
|
136
199
|
|
|
137
|
-
|
|
200
|
+
Terminal window
|
|
201
|
+
opencode mcp debug <name>
|
|
138
202
|
|
|
139
|
-
|
|
203
|
+
models
|
|
204
|
+
List all available models from configured providers.
|
|
140
205
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
| `Loop#resolve_agent!` | `Agents.resolve`, `agent.validate!` | Resolves CLI name to instance, validates binary exists |
|
|
144
|
-
| `Loop#initialize` | `agent.type`, `agent.config_name` | Agent-specific branching (plugin warnings), display name for banner/warnings |
|
|
145
|
-
| `Iteration#execute_agent` | `agent.build_args`, `agent.build_env`, `agent.command` | Constructs and spawns the agent subprocess |
|
|
146
|
-
| `Iteration#stream_agent` | `agent.parse_tool_output` | Real-time tool counting during streaming output |
|
|
147
|
-
| `Helpers.collect_tool_summary_from_text` | `agent.parse_tool_output` | Post-hoc tool counting from buffered output |
|
|
148
|
-
| `Output::Status` | `Agents.resolve`, `agent.config_name` | Display name in `--status` dashboard |
|
|
149
|
-
| `CLI` | `Agents.valid_agent_names` | OptionParser validation and help text for `--agent` flag |
|
|
206
|
+
Terminal window
|
|
207
|
+
opencode models [provider]
|
|
150
208
|
|
|
151
|
-
|
|
209
|
+
This command displays all models available across your configured providers in the format provider/model.
|
|
152
210
|
|
|
153
|
-
|
|
211
|
+
This is useful for figuring out the exact model name to use in your config.
|
|
154
212
|
|
|
155
|
-
|
|
156
|
-
2. Implement all abstract methods: `type`, `command`, `config_name`, `build_args`, `parse_tool_output`
|
|
157
|
-
3. Override `build_env` if the agent requires custom environment variables
|
|
158
|
-
4. Add an entry to `AGENT_NAME_MAP` in `base.rb`
|
|
159
|
-
5. Add a constructor lambda to the dispatch hash in `Agents.resolve`
|
|
213
|
+
You can optionally pass a provider ID to filter models by that provider.
|
|
160
214
|
|
|
161
|
-
|
|
215
|
+
Terminal window
|
|
216
|
+
opencode models anthropic
|
|
162
217
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
- Test `Agents.valid_agent_names` returns expected list
|
|
218
|
+
Flags
|
|
219
|
+
Flag Description
|
|
220
|
+
--refresh Refresh the models cache from models.dev
|
|
221
|
+
--verbose Use more verbose model output (includes metadata like costs)
|
|
222
|
+
Use the --refresh flag to update the cached model list. This is useful when new models have been added to a provider and you want to see them in OpenCode.
|
|
169
223
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
224
|
+
Terminal window
|
|
225
|
+
opencode models --refresh
|
|
226
|
+
|
|
227
|
+
run
|
|
228
|
+
Run opencode in non-interactive mode by passing a prompt directly.
|
|
229
|
+
|
|
230
|
+
Terminal window
|
|
231
|
+
opencode run [message..]
|
|
232
|
+
|
|
233
|
+
This is useful for scripting, automation, or when you want a quick answer without launching the full TUI. For example.
|
|
234
|
+
|
|
235
|
+
Terminal window
|
|
236
|
+
opencode run Explain the use of context in Go
|
|
237
|
+
|
|
238
|
+
You can also attach to a running opencode serve instance to avoid MCP server cold boot times on every run:
|
|
239
|
+
|
|
240
|
+
Terminal window
|
|
241
|
+
# Start a headless server in one terminal
|
|
242
|
+
opencode serve
|
|
243
|
+
|
|
244
|
+
# In another terminal, run commands that attach to it
|
|
245
|
+
opencode run --attach http://localhost:4096 "Explain async/await in JavaScript"
|
|
246
|
+
|
|
247
|
+
Flags
|
|
248
|
+
Flag Short Description
|
|
249
|
+
--command The command to run, use message for args
|
|
250
|
+
--continue -c Continue the last session
|
|
251
|
+
--session -s Session ID to continue
|
|
252
|
+
--share Share the session
|
|
253
|
+
--model -m Model to use in the form of provider/model
|
|
254
|
+
--agent Agent to use
|
|
255
|
+
--file -f File(s) to attach to message
|
|
256
|
+
--format Format: default (formatted) or json (raw JSON events)
|
|
257
|
+
--title Title for the session (uses truncated prompt if no value provided)
|
|
258
|
+
--attach Attach to a running opencode server (e.g., http://localhost:4096)
|
|
259
|
+
--port Port for the local server (defaults to random port)
|
|
260
|
+
serve
|
|
261
|
+
Start a headless OpenCode server for API access. Check out the server docs for the full HTTP interface.
|
|
262
|
+
|
|
263
|
+
Terminal window
|
|
264
|
+
opencode serve
|
|
265
|
+
|
|
266
|
+
This starts an HTTP server that provides API access to opencode functionality without the TUI interface. Set OPENCODE_SERVER_PASSWORD to enable HTTP basic auth (username defaults to opencode).
|
|
267
|
+
|
|
268
|
+
Flags
|
|
269
|
+
Flag Description
|
|
270
|
+
--port Port to listen on
|
|
271
|
+
--hostname Hostname to listen on
|
|
272
|
+
--mdns Enable mDNS discovery
|
|
273
|
+
--cors Additional browser origin(s) to allow CORS
|
|
274
|
+
session
|
|
275
|
+
Manage OpenCode sessions.
|
|
276
|
+
|
|
277
|
+
Terminal window
|
|
278
|
+
opencode session [command]
|
|
279
|
+
|
|
280
|
+
list
|
|
281
|
+
List all OpenCode sessions.
|
|
282
|
+
|
|
283
|
+
Terminal window
|
|
284
|
+
opencode session list
|
|
285
|
+
|
|
286
|
+
Flags
|
|
287
|
+
Flag Short Description
|
|
288
|
+
--max-count -n Limit to N most recent sessions
|
|
289
|
+
--format Output format: table or json (table)
|
|
290
|
+
stats
|
|
291
|
+
Show token usage and cost statistics for your OpenCode sessions.
|
|
292
|
+
|
|
293
|
+
Terminal window
|
|
294
|
+
opencode stats
|
|
295
|
+
|
|
296
|
+
Flags
|
|
297
|
+
Flag Description
|
|
298
|
+
--days Show stats for the last N days (all time)
|
|
299
|
+
--tools Number of tools to show (all)
|
|
300
|
+
--models Show model usage breakdown (hidden by default). Pass a number to show top N
|
|
301
|
+
--project Filter by project (all projects, empty string: current project)
|
|
302
|
+
export
|
|
303
|
+
Export session data as JSON.
|
|
304
|
+
|
|
305
|
+
Terminal window
|
|
306
|
+
opencode export [sessionID]
|
|
307
|
+
|
|
308
|
+
If you don’t provide a session ID, you’ll be prompted to select from available sessions.
|
|
309
|
+
|
|
310
|
+
import
|
|
311
|
+
Import session data from a JSON file or OpenCode share URL.
|
|
312
|
+
|
|
313
|
+
Terminal window
|
|
314
|
+
opencode import <file>
|
|
315
|
+
|
|
316
|
+
You can import from a local file or an OpenCode share URL.
|
|
317
|
+
|
|
318
|
+
Terminal window
|
|
319
|
+
opencode import session.json
|
|
320
|
+
opencode import https://opncd.ai/s/abc123
|
|
321
|
+
|
|
322
|
+
web
|
|
323
|
+
Start a headless OpenCode server with a web interface.
|
|
324
|
+
|
|
325
|
+
Terminal window
|
|
326
|
+
opencode web
|
|
327
|
+
|
|
328
|
+
This starts an HTTP server and opens a web browser to access OpenCode through a web interface. Set OPENCODE_SERVER_PASSWORD to enable HTTP basic auth (username defaults to opencode).
|
|
329
|
+
|
|
330
|
+
Flags
|
|
331
|
+
Flag Description
|
|
332
|
+
--port Port to listen on
|
|
333
|
+
--hostname Hostname to listen on
|
|
334
|
+
--mdns Enable mDNS discovery
|
|
335
|
+
--cors Additional browser origin(s) to allow CORS
|
|
336
|
+
acp
|
|
337
|
+
Start an ACP (Agent Client Protocol) server.
|
|
338
|
+
|
|
339
|
+
Terminal window
|
|
340
|
+
opencode acp
|
|
341
|
+
|
|
342
|
+
This command starts an ACP server that communicates via stdin/stdout using nd-JSON.
|
|
343
|
+
|
|
344
|
+
Flags
|
|
345
|
+
Flag Description
|
|
346
|
+
--cwd Working directory
|
|
347
|
+
--port Port to listen on
|
|
348
|
+
--hostname Hostname to listen on
|
|
349
|
+
uninstall
|
|
350
|
+
Uninstall OpenCode and remove all related files.
|
|
351
|
+
|
|
352
|
+
Terminal window
|
|
353
|
+
opencode uninstall
|
|
354
|
+
|
|
355
|
+
Flags
|
|
356
|
+
Flag Short Description
|
|
357
|
+
--keep-config -c Keep configuration files
|
|
358
|
+
--keep-data -d Keep session data and snapshots
|
|
359
|
+
--dry-run Show what would be removed without removing
|
|
360
|
+
--force -f Skip confirmation prompts
|
|
361
|
+
upgrade
|
|
362
|
+
Updates opencode to the latest version or a specific version.
|
|
363
|
+
|
|
364
|
+
Terminal window
|
|
365
|
+
opencode upgrade [target]
|
|
366
|
+
|
|
367
|
+
To upgrade to the latest version.
|
|
368
|
+
|
|
369
|
+
Terminal window
|
|
370
|
+
opencode upgrade
|
|
371
|
+
|
|
372
|
+
To upgrade to a specific version.
|
|
373
|
+
|
|
374
|
+
Terminal window
|
|
375
|
+
opencode upgrade v0.1.48
|
|
376
|
+
|
|
377
|
+
Flags
|
|
378
|
+
Flag Short Description
|
|
379
|
+
--method -m The installation method that was used; curl, npm, pnpm, bun, brew
|
|
380
|
+
Global Flags
|
|
381
|
+
The opencode CLI takes the following global flags.
|
|
382
|
+
|
|
383
|
+
Flag Short Description
|
|
384
|
+
--help -h Display help
|
|
385
|
+
--version -v Print version number
|
|
386
|
+
--print-logs Print logs to stderr
|
|
387
|
+
--log-level Log level (DEBUG, INFO, WARN, ERROR)
|
|
388
|
+
Environment variables
|
|
389
|
+
OpenCode can be configured using environment variables.
|
|
390
|
+
|
|
391
|
+
Variable Type Description
|
|
392
|
+
OPENCODE_AUTO_SHARE boolean Automatically share sessions
|
|
393
|
+
OPENCODE_GIT_BASH_PATH string Path to Git Bash executable on Windows
|
|
394
|
+
OPENCODE_CONFIG string Path to config file
|
|
395
|
+
OPENCODE_CONFIG_DIR string Path to config directory
|
|
396
|
+
OPENCODE_CONFIG_CONTENT string Inline json config content
|
|
397
|
+
OPENCODE_DISABLE_AUTOUPDATE boolean Disable automatic update checks
|
|
398
|
+
OPENCODE_DISABLE_PRUNE boolean Disable pruning of old data
|
|
399
|
+
OPENCODE_DISABLE_TERMINAL_TITLE boolean Disable automatic terminal title updates
|
|
400
|
+
OPENCODE_PERMISSION string Inlined json permissions config
|
|
401
|
+
OPENCODE_DISABLE_DEFAULT_PLUGINS boolean Disable default plugins
|
|
402
|
+
OPENCODE_DISABLE_LSP_DOWNLOAD boolean Disable automatic LSP server downloads
|
|
403
|
+
OPENCODE_ENABLE_EXPERIMENTAL_MODELS boolean Enable experimental models
|
|
404
|
+
OPENCODE_DISABLE_AUTOCOMPACT boolean Disable automatic context compaction
|
|
405
|
+
OPENCODE_DISABLE_CLAUDE_CODE boolean Disable reading from .claude (prompt + skills)
|
|
406
|
+
OPENCODE_DISABLE_CLAUDE_CODE_PROMPT boolean Disable reading ~/.claude/CLAUDE.md
|
|
407
|
+
OPENCODE_DISABLE_CLAUDE_CODE_SKILLS boolean Disable loading .claude/skills
|
|
408
|
+
OPENCODE_CLIENT string Client identifier (defaults to cli)
|
|
409
|
+
OPENCODE_ENABLE_EXA boolean Enable Exa web search tools
|
|
410
|
+
OPENCODE_SERVER_PASSWORD string Enable basic auth for serve/web
|
|
411
|
+
OPENCODE_SERVER_USERNAME string Override basic auth username (default opencode)
|
|
412
|
+
Experimental
|
|
413
|
+
These environment variables enable experimental features that may change or be removed.
|
|
414
|
+
|
|
415
|
+
Variable Type Description
|
|
416
|
+
OPENCODE_EXPERIMENTAL boolean Enable all experimental features
|
|
417
|
+
OPENCODE_EXPERIMENTAL_ICON_DISCOVERY boolean Enable icon discovery
|
|
418
|
+
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT boolean Disable copy on select in TUI
|
|
419
|
+
OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS number Default timeout for bash commands in ms
|
|
420
|
+
OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX number Max output tokens for LLM responses
|
|
421
|
+
OPENCODE_EXPERIMENTAL_FILEWATCHER boolean Enable file watcher for entire dir
|
|
422
|
+
OPENCODE_EXPERIMENTAL_OXFMT boolean Enable oxfmt formatter
|
|
423
|
+
OPENCODE_EXPERIMENTAL_LSP_TOOL boolean Enable experimental LSP tool
|
|
424
|
+
OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER boolean Disable file watcher
|
|
425
|
+
OPENCODE_EXPERIMENTAL_EXA boolean Enable experimental Exa features
|
|
426
|
+
OPENCODE_EXPERIMENTAL_LSP_TY boolean Enable experimental LSP type checking
|
|
427
|
+
OPENCODE_EXPERIMENTAL_MARKDOWN boolean Enable experimental markdown features
|
|
428
|
+
OPENCODE_EXPERIMENTAL_PLAN_MODE boolean Enable plan mode
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
## JSON streams
|
|
432
|
+
|
|
433
|
+
Opencode will output JSON streams from the cli, which we will read to determine the metrics from the iteration.
|
|
434
|
+
|
|
435
|
+
### Events
|
|
436
|
+
|
|
437
|
+
These are the events that the opencode docs spcify for plugins.
|
|
438
|
+
|
|
439
|
+
```
|
|
440
|
+
Command Events
|
|
441
|
+
command.executed
|
|
442
|
+
File Events
|
|
443
|
+
file.edited
|
|
444
|
+
file.watcher.updated
|
|
445
|
+
Installation Events
|
|
446
|
+
installation.updated
|
|
447
|
+
LSP Events
|
|
448
|
+
lsp.client.diagnostics
|
|
449
|
+
lsp.updated
|
|
450
|
+
Message Events
|
|
451
|
+
message.part.removed
|
|
452
|
+
message.part.updated
|
|
453
|
+
message.removed
|
|
454
|
+
message.updated
|
|
455
|
+
Permission Events
|
|
456
|
+
permission.asked
|
|
457
|
+
permission.replied
|
|
458
|
+
Server Events
|
|
459
|
+
server.connected
|
|
460
|
+
Session Events
|
|
461
|
+
session.created
|
|
462
|
+
session.compacted
|
|
463
|
+
session.deleted
|
|
464
|
+
session.diff
|
|
465
|
+
session.error
|
|
466
|
+
session.idle
|
|
467
|
+
session.status
|
|
468
|
+
session.updated
|
|
469
|
+
Todo Events
|
|
470
|
+
todo.updated
|
|
471
|
+
Tool Events
|
|
472
|
+
tool.execute.after
|
|
473
|
+
tool.execute.before
|
|
474
|
+
TUI Events
|
|
475
|
+
tui.prompt.append
|
|
476
|
+
tui.command.execute
|
|
477
|
+
tui.toast.show
|
|
478
|
+
```
|