docs: add tui doc

This commit is contained in:
Jay V
2025-08-18 13:28:43 -04:00
parent 446ce488c0
commit 2dea8f0f6b
6 changed files with 309 additions and 140 deletions

View File

@@ -1,6 +1,4 @@
--- ---
model: openai/gpt-5
reasoningEffort: medium
description: ALWAYS use this when writing docs description: ALWAYS use this when writing docs
--- ---
@@ -8,7 +6,21 @@ You are an expert technical documentation writer
You are not verbose You are not verbose
Every chunk of text should be followed by an example or something besides text The title of the page should be a word or a 2-3 word phrase
to look at.
Chunks of text should not be more than 2 sentences long. The description should be one short line, should not start with "The", should
avoid repeating the title of the page, should be 5-10 words long
Chunks of text should not be more than 2 sentences long
Each section is spearated by a divider of 3 dashes
The section titles are short with only the first letter of the word capitalized
The section titles are in the imperative mood
The section titles should not repeat the term used in the page title, for
example, if the page title is "Models", avoid using a section title like "Add
new models". This might be unavoidable in some cases, but try to avoid it.
Check out the /packages/web/src/content/docs/docs/index.mdx as an example.

View File

@@ -69,7 +69,7 @@ export default defineConfig({
{ {
label: "Usage", label: "Usage",
items: ["docs/cli", "docs/ide", "docs/share", "docs/github"], items: ["docs/tui", "docs/cli", "docs/ide", "docs/share", "docs/github"],
}, },
{ {

View File

@@ -1,137 +1,16 @@
--- ---
title: CLI title: CLI
description: The opencode CLI options and commands. description: opencode CLI options and commands.
--- ---
import { Tabs, TabItem } from "@astrojs/starlight/components" import { Tabs, TabItem } from "@astrojs/starlight/components"
Running the opencode CLI starts it for the current directory. The opencode CLI accepts commands as documented on this page. You can run any of the available commands to interact with opencode programmatically.
```bash ```bash
opencode opencode run "Explain how closures work in JavaScript"
``` ```
Or you can start it for a specific working directory.
```bash
opencode /path/to/project
```
---
## Slash commands
When using the opencode CLI, you can type `/` followed by a command name to quickly execute actions. For example:
:::tip
You can also use `@` to reference files in your messages.
:::
```bash frame="none"
/help
```
Here are all available slash commands:
- **`/help`**
Show the help dialog.
- **`/editor`**
Open external editor for composing messages. Uses the editor set in your `EDITOR` environment variable. [Learn more](#editor-setup).
- **`/export`**
Export current conversation to Markdown and open in your default editor. Uses the editor set in your `EDITOR` environment variable. [Learn more](#editor-setup).
- **`/new`**
Start a new session. _Alias_: `/clear`
- **`/sessions`**
List and switch between sessions. _Aliases_: `/resume`, `/continue`
- **`/share`**
Share current session. [Learn more](/docs/share).
- **`/unshare`**
Unshare current session. [Learn more](/docs/share#un-sharing).
- **`/compact`**
Compact the current session. _Alias_: `/summarize`
- **`/details`**
Toggle tool execution details.
- **`/models`**
List available models.
- **`/themes`**
List available themes.
- **`/init`**
Create or update `AGENTS.md` file. [Learn more](/docs/rules).
- **`/undo`**
Undo last message.
- **`/redo`**
Redo message.
- **`/exit`**
Exit opencode. _Aliases_: `/quit`, `/q`
---
### Bash commands
Start a line with `!` to run a shell command. The output is added to the conversation as a tool result.
```bash frame="none"
!ls -la
```
---
### Editor setup
Both the `/editor` and `/export` commands use the editor specified in your `EDITOR` environment variable.
<Tabs>
<TabItem label="Linux/macOS">
```bash export EDITOR=nano # or vim, code, etc. ``` To make it permanent, add this to your shell profile;
`~/.bashrc`, `~/.zshrc`, etc.
</TabItem>
<TabItem label="Windows (CMD)">
```bash set EDITOR=notepad # or code, vim, etc. ``` To make it permanent, use **System Properties** > **Environment
Variables**.
</TabItem>
<TabItem label="Windows (PowerShell)">
```bash $env:EDITOR = "notepad" # or "code", "vim", etc. ``` To make it permanent, add this to your PowerShell
profile.
</TabItem>
</Tabs>
Popular editor options include:
- `code` - Visual Studio Code
- `vim` - Vim editor
- `nano` - Nano editor
- `notepad` - Windows Notepad
- `subl` - Sublime Text
--- ---
## Commands ## Commands

View File

@@ -157,16 +157,16 @@ help.
You can ask opencode to explain the codebase to you. You can ask opencode to explain the codebase to you.
```txt frame="none" :::tip
Use the `@` key to fuzzy search for files in the project.
:::
```txt frame="none" "@packages/functions/src/api/index.ts"
How is authentication handled in @packages/functions/src/api/index.ts How is authentication handled in @packages/functions/src/api/index.ts
``` ```
This is helpful if there's a part of the codebase that you didn't work on. This is helpful if there's a part of the codebase that you didn't work on.
:::tip
Use the `@` key to fuzzy search for files in the project.
:::
--- ---
### Add features ### Add features
@@ -238,7 +238,7 @@ You can ask opencode to add new features to your project. Though we first recomm
For more straightforward changes, you can ask opencode to directly build it For more straightforward changes, you can ask opencode to directly build it
without having to review the plan first. without having to review the plan first.
```txt frame="none" ```txt frame="none" "@packages/functions/src/settings.ts" "@packages/functions/src/notes.ts"
We need to add authentication to the /settings route. Take a look at how this is We need to add authentication to the /settings route. Take a look at how this is
handled in the /notes route in @packages/functions/src/notes.ts and implement handled in the /notes route in @packages/functions/src/notes.ts and implement
the same logic in @packages/functions/src/settings.ts the same logic in @packages/functions/src/settings.ts
@@ -253,7 +253,7 @@ changes.
Let's say you ask opencode to make some changes. Let's say you ask opencode to make some changes.
```txt frame="none" ```txt frame="none" "@packages/functions/src/api/index.ts"
Can you refactor the function in @packages/functions/src/api/index.ts? Can you refactor the function in @packages/functions/src/api/index.ts?
``` ```
@@ -267,7 +267,7 @@ using the `/undo` command.
opencode will now revert the changes you made and show your original message opencode will now revert the changes you made and show your original message
again. again.
```txt frame="none" ```txt frame="none" "@packages/functions/src/api/index.ts"
Can you refactor the function in @packages/functions/src/api/index.ts? Can you refactor the function in @packages/functions/src/api/index.ts?
``` ```

View File

@@ -614,8 +614,6 @@ In this example:
### OpenAI ### OpenAI
https://platform.openai.com/api-keys
1. Head over to the [OpenAI Platform console](https://platform.openai.com/api-keys), click **Create new secret key**, and copy the key. 1. Head over to the [OpenAI Platform console](https://platform.openai.com/api-keys), click **Create new secret key**, and copy the key.
2. Run `opencode auth login` and select OpenAI. 2. Run `opencode auth login` and select OpenAI.

View File

@@ -0,0 +1,280 @@
---
title: TUI
description: Using the opencode terminal user interface.
---
import { Tabs, TabItem } from "@astrojs/starlight/components"
opencode provides an interactive terminal interface or TUI for working on your projects with an LLM.
Running opencode starts the TUI for the current directory.
```bash
opencode
```
Or you can start it for a specific working directory.
```bash
opencode /path/to/project
```
Once you're in the TUI, you can prompt it with a message.
```text
Give me a quick summary of the codebase.
```
:::tip
You can also use `@` to reference files in your messages.
:::
```text "@packages/functions/src/api/index.ts"
How is auth handled in @packages/functions/src/api/index.ts?
```
---
## Commands
When using the opencode TUI, you can type `/` followed by a command name to quickly execute actions. For example:
```bash frame="none"
/help
```
Most commands also have keybind using `ctrl+x` as the leader key, where `ctrl+x` is the default leader key. [Learn more](/docs/keybinds).
Here are all available slash commands:
---
### compact
Compact the current session. _Alias_: `/summarize`
```bash frame="none"
/compact
```
**Keybind:** `ctrl+x c`
---
### details
Toggle tool execution details.
```bash frame="none"
/details
```
**Keybind:** `ctrl+x d`
---
### editor
Open external editor for composing messages. Uses the editor set in your `EDITOR` environment variable. [Learn more](#editor-setup).
```bash frame="none"
/editor
```
**Keybind:** `ctrl+x e`
---
### exit
Exit opencode. _Aliases_: `/quit`, `/q`
```bash frame="none"
/exit
```
**Keybind:** `ctrl+x q`
---
### export
Export current conversation to Markdown and open in your default editor. Uses the editor set in your `EDITOR` environment variable. [Learn more](#editor-setup).
```bash frame="none"
/export
```
**Keybind:** `ctrl+x x`
---
### help
Show the help dialog.
```bash frame="none"
/help
```
**Keybind:** `ctrl+x h`
---
### init
Create or update `AGENTS.md` file. [Learn more](/docs/rules).
```bash frame="none"
/init
```
**Keybind:** `ctrl+x i`
---
### models
List available models.
```bash frame="none"
/models
```
**Keybind:** `ctrl+x m`
---
### new
Start a new session. _Alias_: `/clear`
```bash frame="none"
/new
```
**Keybind:** `ctrl+x n`
---
### redo
Redo a previously undone message. Only available after using `/undo`. **Any file changes that were reverted will also be restored.**
```bash frame="none"
/redo
```
**Keybind:** `ctrl+x r`
---
### sessions
List and switch between sessions. _Aliases_: `/resume`, `/continue`
```bash frame="none"
/sessions
```
**Keybind:** `ctrl+x l`
---
### share
Share current session. [Learn more](/docs/share).
```bash frame="none"
/share
```
**Keybind:** `ctrl+x s`
---
### themes
List available themes.
```bash frame="none"
/themes
```
**Keybind:** `ctrl+x t`
---
### undo
Undo last message in the conversation. Removes the most recent user message and all subsequent responses. **Any file changes made during the undone messages will also be reverted.**
```bash frame="none"
/undo
```
**Keybind:** `ctrl+x u`
---
### unshare
Unshare current session. [Learn more](/docs/share#un-sharing).
```bash frame="none"
/unshare
```
---
## Bash commands
Start a line with `!` to run a shell command. The output is added to the conversation as a tool result.
```bash frame="none"
!ls -la
```
---
## Editor setup
Both the `/editor` and `/export` commands use the editor specified in your `EDITOR` environment variable.
<Tabs>
<TabItem label="Linux/macOS">
```bash
export EDITOR=nano # or vim, code, etc.
```
To make it permanent, add this to your shell profile;
`~/.bashrc`, `~/.zshrc`, etc.
</TabItem>
<TabItem label="Windows (CMD)">
```bash
set EDITOR=notepad # or code, vim, etc.
```
To make it permanent, use **System Properties** > **Environment
Variables**.
</TabItem>
<TabItem label="Windows (PowerShell)">
```bash
$env:EDITOR = "notepad" # or "code", "vim", etc.
```
To make it permanent, add this to your PowerShell
profile.
</TabItem>
</Tabs>
Popular editor options include:
- `code` - Visual Studio Code
- `vim` - Vim editor
- `nano` - Nano editor
- `notepad` - Windows Notepad
- `subl` - Sublime Text