Skip to content

Commit a4f1040

Browse files
neriousyTuanNancyyash-allastarke0oMudadlaPranay12
authored
docs: fix a batch of outdated and missing docs (#66803)
Co-authored-by: TuanNancy <vuanhtuan18092004@gmail.com> Co-authored-by: yash-alla <112993411+yash-alla@users.noreply.github.com> Co-authored-by: Johannes Starke <johannesstarke@gmail.com> Co-authored-by: M. Pranay <mudadlapranay@gmail.com> Co-authored-by: andreivince <andreivince21@gmail.com>
1 parent 740bd1d commit a4f1040

19 files changed

Lines changed: 194 additions & 33 deletions

File tree

‎services/site/src/docs/content/agents.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Save Markdown agents globally for all projects or inside a project:
3939
.opencode/agents/<name>.md
4040
```
4141

42-
OpenCode discovers project `.opencode` directories from the current directory up to the project root. A nested path becomes part of the agent ID:
42+
OpenCode discovers project `.opencode` directories from the current directory to the filesystem root. A nested path becomes part of the agent ID:
4343

4444
```text
4545
.opencode/agents/team/reviewer.md → team/reviewer

‎services/site/src/docs/content/build/plugins/cli.mdx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ await context.ui.dialog.select({
426426
- Escape, `clear()`, or showing another dialog resolves `undefined`.
427427
- Do not bind `ctrl+n` or `ctrl+p`. The dialog reserves them for navigation, and its own bindings take precedence.
428428

429-
Custom JSX dialogs can set their size and close themselves.
429+
Custom JSX dialogs can set their size and close themselves. Call `set` after `show`: showing a dialog resets it
430+
to `medium` and not centered. `medium`, `large` and `xlarge` are 60, 88 and 116 columns wide.
430431

431432
```tsx
432-
context.ui.dialog.set({ size: "large", centered: true })
433433
context.ui.dialog.show(
434434
() => (
435435
<box>
@@ -438,6 +438,7 @@ context.ui.dialog.show(
438438
),
439439
() => console.log("closed"),
440440
)
441+
context.ui.dialog.set({ size: "large", centered: true })
441442
context.ui.dialog.clear()
442443
```
443444

@@ -646,8 +647,8 @@ Expose the TUI plugin through `./tui`; add OpenTUI peers when the plugin renders
646647
"@opencode/plugin": "latest"
647648
},
648649
"peerDependencies": {
649-
"@opentui/core": ">=0.6.6",
650-
"@opentui/solid": ">=0.6.6",
650+
"@opentui/core": ">=0.8.0",
651+
"@opentui/solid": ">=0.8.0",
651652
"solid-js": ">=1.9.0"
652653
}
653654
}

‎services/site/src/docs/content/build/plugins/effect.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ Effect tools accept the same [freeform input declaration](/build/plugins/server#
10371037

10381038
Tools have an `id` containing their effective name, and `get()` returns `undefined` when that ID is not present. Use
10391039
`update` and `remove` with the effective tool name, including its namespace (`acme_greeting` above). Dots in
1040-
namespaces and unsupported characters in tool names become `_`. Missing names are ignored; creating a tool requires
1040+
namespaces become `_`, and characters in tool names other than letters, digits, `_` and `-` become `_`. Missing names are ignored; creating a tool requires
10411041
`add` with a complete definition. Updates preserve the name and namespace. Assign new schemas or options to replace
10421042
them rather than mutating nested values. Invalid updates are logged and leave the previous definition intact.
10431043

‎services/site/src/docs/content/build/plugins/effect/rpc.mdx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ JSON Schema and Standard Schema are also supported.
4545

4646
### Input and output
4747

48-
Use `input` for the method argument and `output` for its return value. Leave
49-
either one out when there is no value.
48+
Use `input` for the method argument and `output` for its return value. Both
49+
are required. When a method takes or returns nothing, use `Schema.Struct({})`,
50+
call it with `{}` and return `{}`.
5051

5152
```ts
5253
search: {
@@ -67,7 +68,8 @@ errors: {
6768

6869
### Events
6970

70-
Add events to the top-level `events` map. Event data must be an object.
71+
Add events to the top-level `events` map. Event data must be an object. The map
72+
is required; use `events: {}` when the RPC has no events.
7173

7274
```ts
7375
events: {

‎services/site/src/docs/content/build/plugins/migrate-v1.mdx‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,33 @@ living on a separate `client` property.
9696
`ctx.location` describes the location where this plugin instance loaded. It is not the location of every session or event
9797
the plugin may observe. Read the session or event data when that distinction matters.
9898

99-
The context exposes many more domains than the table lists, including catalogs, commands, integrations, MCP servers,
100-
references, skills, storage, VCS, worktrees, and web search. See the [complete plugin context](/build/plugins/server#api).
99+
The context exposes many more domains than the table lists, including commands, integrations, MCP servers, references,
100+
skills, storage, VCS, worktrees, and web search. See the [complete plugin context](/build/plugins/server#api).
101+
102+
### Migrate the catalog domain
103+
104+
Earlier plugin builds published providers and models through `ctx.catalog`. OpenCode now exposes `ctx.provider` and
105+
`ctx.model` as separate domains, so a plugin that calls `ctx.catalog.transform` fails to load.
106+
107+
| Earlier catalog API | Current equivalent |
108+
| --------------------------------------------- | ---------------------------------------------------------------------------- |
109+
| `ctx.catalog.transform(draft => …)` | `ctx.provider.transform(editor => …)` and `ctx.model.transform(editor => …)` |
110+
| `draft.provider.update(id, fn)` | `editor.update(id, fn)` on `ctx.provider` |
111+
| `draft.model.update(providerID, modelID, fn)` | `editor.update(providerID, modelID, fn)` on `ctx.model` |
112+
| `ctx.catalog.reload()` | `ctx.provider.reload()` and `ctx.model.reload()` |
113+
114+
```ts
115+
await ctx.provider.transform((editor) => {
116+
editor.update("acme", (provider) => {
117+
provider.headers = { ...provider.headers, "x-company": "engineering" }
118+
})
119+
editor.models.update("acme", "reasoner", (model) => {
120+
model.name = "Acme Reasoner"
121+
})
122+
})
123+
```
124+
125+
See [Providers](/build/plugins/server#providers) and [Models](/build/plugins/server#models) for the full editor APIs.
101126

102127
## Register hooks in `setup`
103128

‎services/site/src/docs/content/build/plugins/rpc.mdx‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,18 @@ and errors. It supports two schema formats:
6868

6969
### Input and output
7070

71-
Each method can define an `input` schema for its argument and an `output` schema
72-
for its return value. Leave either one out if the method does not accept or
73-
return a value.
71+
Each method needs an `input` schema for its argument and an `output` schema for
72+
its return value. When a method takes or returns nothing, use an empty object
73+
schema, call it with `{}` and return `{}`:
74+
75+
```ts
76+
refresh: {
77+
input: { type: "object", additionalProperties: false },
78+
output: { type: "object", additionalProperties: false },
79+
}
80+
```
81+
82+
A method that returns `undefined` fails with `rpc.invalid_output`.
7483

7584
```ts
7685
search: {
@@ -111,7 +120,8 @@ Error names beginning with `rpc.` are reserved by OpenCode.
111120
### Events
112121

113122
Add events to the top-level `events` map. Each event has a schema for the data
114-
sent to subscribers.
123+
sent to subscribers. The map is required; use `events: {}` when the RPC has no
124+
events.
115125

116126
Event data must be an object. Use an empty object schema when there is no data:
117127

‎services/site/src/docs/content/build/plugins/server.mdx‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const agents = await ctx.agent.list()
193193
const build = await ctx.agent.get({ agentID: "build" })
194194
```
195195

196-
Register a transform to inspect, update, remove, or select the default agent.
196+
Register a transform to inspect, create, update, remove, or select the default agent.
197197

198198
```ts
199199
await ctx.agent.transform((editor) => {
@@ -208,6 +208,19 @@ await ctx.agent.transform((editor) => {
208208
})
209209
```
210210

211+
Register a new agent with `editor.update`. If the ID already exists, it edits that agent. Otherwise, it creates one with
212+
`Agent.Info.default(id)` before running the callback.
213+
214+
```ts
215+
await ctx.agent.transform((editor) => {
216+
editor.update("reviewer", (agent) => {
217+
agent.description = "Reviews code for correctness and maintainability"
218+
agent.mode = "subagent"
219+
agent.system = "Review the proposed changes and report actionable findings."
220+
})
221+
})
222+
```
223+
211224
Reload agents after external state used by a transform changes.
212225

213226
```ts
@@ -1042,7 +1055,7 @@ await ctx.tool.reload()
10421055
Use `list()` and `get()` to inspect tools currently in the editor. Tools have an `id` containing their effective name,
10431056
and `get()` returns `undefined` when that ID is not present. Use `update` and `remove` with the effective tool name,
10441057
including its namespace (`acme_greeting` above). Dots in
1045-
namespaces and unsupported characters in tool names become `_`. Missing names are ignored; creating a tool requires
1058+
namespaces become `_`, and characters in tool names other than letters, digits, `_` and `-` become `_`. Missing names are ignored; creating a tool requires
10461059
`add` with a complete definition. Updates preserve the name and namespace. Assign new schemas or options to replace
10471060
them rather than mutating nested values. Invalid updates are logged and leave the previous definition intact.
10481061

‎services/site/src/docs/content/cli/config.mdx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ OpenCode adds `$schema` when it creates or migrates this file. Valid edits reloa
3636

3737
Unknown settings are ignored. Keep `$schema` so your editor flags invalid values.
3838

39+
### Legacy `tui.json`
40+
41+
V1 kept terminal client settings in `tui.json`. V2 reads it once, as a migration source, and never layers it under
42+
`cli.json`:
43+
44+
- When `cli.json` is missing, the CLI creates it from the supported settings in the global `tui.json` next to it and
45+
from the saved preferences in `kv.json` in the state directory.
46+
- Once `cli.json` exists, `tui.json` is ignored. Later edits to it have no effect, and you can keep or delete it.
47+
- Deleting `cli.json` runs the migration again on the next start.
48+
- The legacy files are never changed or deleted.
49+
- Only the global `tui.json` is read. Project-local `tui.json` files and `tui.jsonc` are not migrated.
50+
3951
## Inline config
4052

4153
Set `OPENCODE_CLI_CONFIG_CONTENT` to apply CLI settings from inline JSON:

‎services/site/src/docs/content/cli/tui.mdx‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ Explain how authentication works in this project
1616

1717
Press **Shift+Enter**, **Ctrl+Enter**, **Alt+Enter**, or **Ctrl+J** for a new line. While OpenCode is working, **Enter** steers the active session; press **Ctrl+X**, then **Enter** to queue the prompt for later.
1818

19+
## Projects and directories
20+
21+
The directory you start OpenCode in is where it searches files and runs shell commands. Directories in the same Git
22+
repository, including its worktrees, belong to one project. A directory without version control is its own project.
23+
24+
Pass a directory to start in another project:
25+
26+
```bash
27+
opencode ~/code/another-project
28+
```
29+
30+
Press **Ctrl+O** to open recent sessions and projects. Press **Right** on a project to list its worktrees, and
31+
**Ctrl+N** there to create a new one.
32+
1933
## Context
2034

2135
Type `@` to search for a file, then select it to attach that file to the prompt. Keep typing after `@` to narrow the results.
@@ -68,7 +82,9 @@ Press **Ctrl+X**, then **A** to choose an agent, or run `/agents`. Press **Shift
6882

6983
## Sessions
7084

71-
Press **Ctrl+X**, then **N** to start a new session. Press **Ctrl+X**, then **L** or run `/sessions` to return to an existing session; **Ctrl+O** opens recent sessions and projects together.
85+
Each session is a separate conversation with its own history and directory. Run `/new` or press **Ctrl+X**, then **N** to start one for a separate task; earlier sessions stay available. New sessions start in the directory you launched OpenCode in, or in the current session's directory with [`session.new_location`](/cli/config#sessions) set to `inherit`.
86+
87+
Press **Ctrl+X**, then **L** or run `/sessions` to return to an existing session. In that list, **Ctrl+A** switches between sessions in the current directory and sessions in all projects. **Ctrl+O** opens recent sessions and projects together.
7288

7389
Tabs are enabled by default. Use **Ctrl+Tab** and **Ctrl+Shift+Tab** to move between them, **Ctrl+X** then **W** to close one, and **Ctrl+Shift+T** to reopen the last closed tab.
7490

‎services/site/src/docs/content/cli/web.mdx‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,27 @@ the password can be changed.
144144
```bash
145145
$ curl -u opencode:a-long-secret http://127.0.0.1:4096/api/info
146146
```
147+
148+
`opencode service set password` only applies to the managed background service. `opencode serve` reads
149+
`OPENCODE_PASSWORD` and otherwise generates a new password on every start.
150+
151+
### Docker
152+
153+
Each release publishes an image to `ghcr.io/anomalyco/opencode`, tagged with its version. The image's entrypoint is
154+
`opencode`, which starts the TUI, so pass `serve`. Bind to `0.0.0.0`: the default `127.0.0.1` is only reachable
155+
inside the container.
156+
157+
```bash
158+
$ docker run -d --name opencode -p 4096:4096 \
159+
-e OPENCODE_PASSWORD="a-long-secret" \
160+
-e ANTHROPIC_API_KEY \
161+
-v opencode-data:/root/.local/share/opencode \
162+
-v opencode-config:/root/.config/opencode \
163+
-v "$PWD":/workspace -w /workspace \
164+
ghcr.io/anomalyco/opencode:<version> serve --hostname 0.0.0.0 --port 4096
165+
```
166+
167+
- Set `OPENCODE_PASSWORD` so the password stays the same across restarts.
168+
- Mount the data directory, `/root/.local/share/opencode`. It holds the database with your sessions, and they are lost
169+
with the container otherwise. Mount the config directory, `/root/.config/opencode`, to keep your global config.
170+
- Check readiness with `curl -u opencode:a-long-secret http://127.0.0.1:4096/api/info`.

0 commit comments

Comments
 (0)