mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 18:24:21 +01:00
sync
This commit is contained in:
89
packages/web/src/content/docs/docs/cli.mdx
Normal file
89
packages/web/src/content/docs/docs/cli.mdx
Normal file
@@ -0,0 +1,89 @@
|
||||
---
|
||||
title: CLI
|
||||
---
|
||||
|
||||
Once installed you can run the OpenCode CLI.
|
||||
|
||||
```bash
|
||||
opencode
|
||||
```
|
||||
|
||||
Or pass in flags. For example, to start with debug logging:
|
||||
|
||||
```bash
|
||||
opencode -d
|
||||
```
|
||||
|
||||
Or start with a specific working directory.
|
||||
|
||||
```bash
|
||||
opencode -c /path/to/project
|
||||
```
|
||||
|
||||
## Flags
|
||||
|
||||
The OpenCode CLI takes the following flags.
|
||||
|
||||
| Flag | Short | Description |
|
||||
| -- | -- | -- |
|
||||
| `--help` | `-h` | Display help |
|
||||
| `--debug` | `-d` | Enable debug mode |
|
||||
| `--cwd` | `-c` | Set current working directory |
|
||||
| `--prompt` | `-p` | Run a single prompt in non-interactive mode |
|
||||
| `--output-format` | `-f` | Output format for non-interactive mode, `text` or `json` |
|
||||
| `--quiet` | `-q` | Hide spinner in non-interactive mode |
|
||||
| `--verbose` | | Display logs to stderr in non-interactive mode |
|
||||
| `--allowedTools` | | Restrict the agent to only use specified tools |
|
||||
| `--excludedTools` | | Prevent the agent from using specified tools |
|
||||
|
||||
## Non-interactive
|
||||
|
||||
By default, OpenCode runs in interactive mode.
|
||||
|
||||
But you can also run OpenCode in non-interactive mode by passing a prompt directly as a command-line argument. This is useful for scripting, automation, or when you want a quick answer without launching the full TUI.
|
||||
|
||||
For example, to run a single prompt use the `-p` flag.
|
||||
|
||||
```bash "-p"
|
||||
opencode -p "Explain the use of context in Go"
|
||||
```
|
||||
|
||||
If you want to run without showing the spinner, use `-q`.
|
||||
|
||||
```bash "-q"
|
||||
opencode -p "Explain the use of context in Go" -q
|
||||
```
|
||||
|
||||
In this mode, OpenCode will process your prompt, print the result to standard output, and then exit. All **permissions are auto-approved** for the session.
|
||||
|
||||
#### Tool restrictions
|
||||
|
||||
You can control which tools the AI assistant has access to in non-interactive mode.
|
||||
|
||||
- `--allowedTools`
|
||||
|
||||
A comma-separated list of tools that the agent is allowed to use. Only these tools will be available.
|
||||
|
||||
```bash "--allowedTools"
|
||||
opencode -p "Explain the use of context in Go" --allowedTools=view,ls,glob
|
||||
```
|
||||
|
||||
- `--excludedTools`
|
||||
|
||||
Comma-separated list of tools that the agent is not allowed to use. All other tools will be available.
|
||||
|
||||
```bash "--excludedTools"
|
||||
opencode -p "Explain the use of context in Go" --excludedTools=bash,edit
|
||||
```
|
||||
|
||||
These flags are mutually exclusive. So you can either use `--allowedTools` or `--excludedTools`, but not both.
|
||||
|
||||
#### Output formats
|
||||
|
||||
In non-interactive mode, you can also set the CLI to return as JSON using `-f`.
|
||||
|
||||
```bash "-f json"
|
||||
opencode -p "Explain the use of context in Go" -f json
|
||||
```
|
||||
|
||||
By default, this is set to `text`, to return plain text.
|
||||
88
packages/web/src/content/docs/docs/config.mdx
Normal file
88
packages/web/src/content/docs/docs/config.mdx
Normal file
@@ -0,0 +1,88 @@
|
||||
---
|
||||
title: Config
|
||||
---
|
||||
|
||||
You can configure OpenCode using the OpenCode config. It can be places in:
|
||||
|
||||
- `$HOME/.opencode.json`
|
||||
- `$XDG_CONFIG_HOME/opencode/.opencode.json`
|
||||
|
||||
Or in the current directory, `./.opencode.json`.
|
||||
|
||||
## OpenCode config
|
||||
|
||||
The config file has the following structure.
|
||||
|
||||
```json title=".opencode.json"
|
||||
{
|
||||
"data": {
|
||||
"directory": ".opencode"
|
||||
},
|
||||
"providers": {
|
||||
"openai": {
|
||||
"apiKey": "your-api-key",
|
||||
"disabled": false
|
||||
},
|
||||
"anthropic": {
|
||||
"apiKey": "your-api-key",
|
||||
"disabled": false
|
||||
},
|
||||
"groq": {
|
||||
"apiKey": "your-api-key",
|
||||
"disabled": false
|
||||
},
|
||||
"openrouter": {
|
||||
"apiKey": "your-api-key",
|
||||
"disabled": false
|
||||
}
|
||||
},
|
||||
"agents": {
|
||||
"primary": {
|
||||
"model": "claude-3.7-sonnet",
|
||||
"maxTokens": 5000
|
||||
},
|
||||
"task": {
|
||||
"model": "claude-3.7-sonnet",
|
||||
"maxTokens": 5000
|
||||
},
|
||||
"title": {
|
||||
"model": "claude-3.7-sonnet",
|
||||
"maxTokens": 80
|
||||
}
|
||||
},
|
||||
"mcpServers": {
|
||||
"example": {
|
||||
"type": "stdio",
|
||||
"command": "path/to/mcp-server",
|
||||
"env": [],
|
||||
"args": []
|
||||
}
|
||||
},
|
||||
"lsp": {
|
||||
"go": {
|
||||
"disabled": false,
|
||||
"command": "gopls"
|
||||
}
|
||||
},
|
||||
"debug": false,
|
||||
"debugLSP": false
|
||||
}
|
||||
```
|
||||
|
||||
## Environment variables
|
||||
|
||||
For the providers, you can also specify the keys using environment variables.
|
||||
|
||||
| Environment Variable | Models |
|
||||
| -------------------------- | ----------- |
|
||||
| `ANTHROPIC_API_KEY` | Claude |
|
||||
| `OPENAI_API_KEY` | OpenAI |
|
||||
| `GEMINI_API_KEY` | Google Gemini |
|
||||
| `GROQ_API_KEY` | Groq |
|
||||
| `AWS_ACCESS_KEY_ID` | Amazon Bedrock |
|
||||
| `AWS_SECRET_ACCESS_KEY` | Amazon Bedrock |
|
||||
| `AWS_REGION` | Amazon Bedrock |
|
||||
| `AZURE_OPENAI_ENDPOINT` | Azure OpenAI |
|
||||
| `AZURE_OPENAI_API_KEY` | Azure OpenAI, optional when using Entra ID |
|
||||
| `AZURE_OPENAI_API_VERSION` | Azure OpenAI |
|
||||
|
||||
58
packages/web/src/content/docs/docs/index.mdx
Normal file
58
packages/web/src/content/docs/docs/index.mdx
Normal file
@@ -0,0 +1,58 @@
|
||||
---
|
||||
title: Intro
|
||||
---
|
||||
|
||||
OpenCode is an AI coding agent built natively for the terminal. It features:
|
||||
|
||||
- Native TUI for a smoother, snappier experience
|
||||
- Uses LSPs to help the LLM make fewer mistakes
|
||||
- Opening multiple conversations with the same project
|
||||
- Use of any model through the AI SDK
|
||||
- Tracks and visualizes all the file changes
|
||||
- Editing longer messages with Vim
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm i -g opencode
|
||||
```
|
||||
|
||||
If you don't have NPM installed, you can also install the OpenCode binary through the following.
|
||||
|
||||
#### Using the install script
|
||||
|
||||
```bash
|
||||
curl -fsSL https://opencode.ai/install | bash
|
||||
```
|
||||
|
||||
Or install a specific version.
|
||||
|
||||
```bash
|
||||
curl -fsSL https://opencode.ai/install | VERSION=0.1.0 bash
|
||||
```
|
||||
|
||||
#### Using Homebrew on macOS and Linux
|
||||
|
||||
```bash
|
||||
brew install sst/tap/opencode
|
||||
```
|
||||
|
||||
#### Using AUR in Arch Linux
|
||||
|
||||
With yay.
|
||||
|
||||
```bash
|
||||
yay -S opencode-bin
|
||||
```
|
||||
|
||||
Or with paru.
|
||||
|
||||
```bash
|
||||
paru -S opencode-bin
|
||||
```
|
||||
|
||||
#### Using Go
|
||||
|
||||
```bash
|
||||
go install github.com/sst/opencode@latest
|
||||
```
|
||||
34
packages/web/src/content/docs/docs/lsp-servers.mdx
Normal file
34
packages/web/src/content/docs/docs/lsp-servers.mdx
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: LSP servers
|
||||
---
|
||||
|
||||
OpenCode integrates with _Language Server Protocol_, or LSP to improve how the LLM interacts with your codebase.
|
||||
|
||||
LSP servers for different languages give the LLM:
|
||||
|
||||
- **Diagnostics**: These include things like errors and lint warnings. So the LLM can generate code that has fewer mistakes without having to run the code.
|
||||
- **Quick actions**: The LSP can allow the LLM to better navigate the codebase through features like _go-to-definition_ and _find references_.
|
||||
|
||||
## Auto-detection
|
||||
|
||||
By default, OpenCode will **automatically detect** the languages used in your project and add the right LSP servers.
|
||||
|
||||
## Manual configuration
|
||||
|
||||
You can also manually configure LSP servers by adding them under the `lsp` section in your OpenCode config.
|
||||
|
||||
```json title=".opencode.json"
|
||||
{
|
||||
"lsp": {
|
||||
"go": {
|
||||
"disabled": false,
|
||||
"command": "gopls"
|
||||
},
|
||||
"typescript": {
|
||||
"disabled": false,
|
||||
"command": "typescript-language-server",
|
||||
"args": ["--stdio"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
51
packages/web/src/content/docs/docs/mcp-servers.mdx
Normal file
51
packages/web/src/content/docs/docs/mcp-servers.mdx
Normal file
@@ -0,0 +1,51 @@
|
||||
---
|
||||
title: MCP servers
|
||||
---
|
||||
|
||||
You can add external tools to OpenCode using the _Model Context Protocol_, or MCP. OpenCode supports both:
|
||||
|
||||
- Local servers that use standard input/output, `stdio`
|
||||
- Remote servers that use server-sent events `sse`
|
||||
|
||||
## Add MCP servers
|
||||
|
||||
You can define MCP servers in your OpenCode config under the `mcpServers` section:
|
||||
|
||||
### Local
|
||||
|
||||
To add a local or `stdio` MCP server.
|
||||
|
||||
```json title=".opencode.json" {4}
|
||||
{
|
||||
"mcpServers": {
|
||||
"local-example": {
|
||||
"type": "stdio",
|
||||
"command": "path/to/mcp-server",
|
||||
"env": [],
|
||||
"args": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Remote
|
||||
|
||||
To add a remote or `sse` MCP server.
|
||||
|
||||
```json title=".opencode.json" {4}
|
||||
{
|
||||
"mcpServers": {
|
||||
"remote-example": {
|
||||
"type": "sse",
|
||||
"url": "https://example.com/mcp",
|
||||
"headers": {
|
||||
"Authorization": "Bearer token"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Once added, MCP tools are automatically available to the LLM alongside built-in tools. They follow the same permission model; requiring user approval before execution.
|
||||
34
packages/web/src/content/docs/docs/models.mdx
Normal file
34
packages/web/src/content/docs/docs/models.mdx
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: Models
|
||||
---
|
||||
|
||||
OpenCode uses the [AI SDK](https://ai-sdk.dev/) to have the support for **all the AI models**.
|
||||
|
||||
Start by setting the [keys for the providers](/docs/config) you want to use in your OpenCode config.
|
||||
|
||||
## Model select
|
||||
|
||||
You can now select the model you want from the menu by hitting `Ctrl+O`.
|
||||
|
||||
## Multiple models
|
||||
|
||||
You can also use specific models for specific tasks. For example, you can use a smaller model to generate the title of the conversation or to run a sub task.
|
||||
|
||||
```json title=".opencode.json"
|
||||
{
|
||||
"agents": {
|
||||
"primary": {
|
||||
"model": "gpt-4",
|
||||
"maxTokens": 5000
|
||||
},
|
||||
"task": {
|
||||
"model": "gpt-3.5-turbo",
|
||||
"maxTokens": 5000
|
||||
},
|
||||
"title": {
|
||||
"model": "gpt-3.5-turbo",
|
||||
"maxTokens": 80
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
68
packages/web/src/content/docs/docs/shortcuts.mdx
Normal file
68
packages/web/src/content/docs/docs/shortcuts.mdx
Normal file
@@ -0,0 +1,68 @@
|
||||
---
|
||||
title: Keyboard shortcuts
|
||||
sidebar:
|
||||
label: Shortcuts
|
||||
---
|
||||
|
||||
Below are a list of keyboard shortcuts that OpenCode supports.
|
||||
|
||||
## Global
|
||||
|
||||
| Shortcut | Action |
|
||||
| -------- | ------------------------------------------------------- |
|
||||
| `Ctrl+C` | Quit application |
|
||||
| `Ctrl+?` | Toggle help dialog |
|
||||
| `?` | Toggle help dialog (when not in editing mode) |
|
||||
| `Ctrl+L` | View logs |
|
||||
| `Ctrl+A` | Switch session |
|
||||
| `Ctrl+K` | Command dialog |
|
||||
| `Ctrl+O` | Toggle model selection dialog |
|
||||
| `Esc` | Close current overlay/dialog or return to previous mode |
|
||||
|
||||
## Chat pane
|
||||
|
||||
| Shortcut | Action |
|
||||
| -------- | --------------------------------------- |
|
||||
| `Ctrl+N` | Create new session |
|
||||
| `Ctrl+X` | Cancel current operation/generation |
|
||||
| `i` | Focus editor (when not in writing mode) |
|
||||
| `Esc` | Exit writing mode and focus messages |
|
||||
|
||||
## Editor view
|
||||
|
||||
| Shortcut | Action |
|
||||
| ------------------- | ----------------------------------------- |
|
||||
| `Ctrl+S` | Send message (when editor is focused) |
|
||||
| `Enter` or `Ctrl+S` | Send message (when editor is not focused) |
|
||||
| `Ctrl+E` | Open external editor |
|
||||
| `Esc` | Blur editor and focus messages |
|
||||
|
||||
## Session dialog
|
||||
|
||||
| Shortcut | Action |
|
||||
| ---------- | ---------------- |
|
||||
| `↑` or `k` | Previous session |
|
||||
| `↓` or `j` | Next session |
|
||||
| `Enter` | Select session |
|
||||
| `Esc` | Close dialog |
|
||||
|
||||
## Model dialog
|
||||
|
||||
| Shortcut | Action |
|
||||
| ---------- | ----------------- |
|
||||
| `↑` or `k` | Move up |
|
||||
| `↓` or `j` | Move down |
|
||||
| `←` or `h` | Previous provider |
|
||||
| `→` or `l` | Next provider |
|
||||
| `Esc` | Close dialog |
|
||||
|
||||
## Permission dialog
|
||||
|
||||
| Shortcut | Action |
|
||||
| ----------------------- | ---------------------------- |
|
||||
| `←` or `left` | Switch options left |
|
||||
| `→` or `right` or `tab` | Switch options right |
|
||||
| `Enter` or `space` | Confirm selection |
|
||||
| `a` | Allow permission |
|
||||
| `A` | Allow permission for session |
|
||||
| `d` | Deny permission |
|
||||
75
packages/web/src/content/docs/docs/themes.mdx
Normal file
75
packages/web/src/content/docs/docs/themes.mdx
Normal file
@@ -0,0 +1,75 @@
|
||||
---
|
||||
title: Themes
|
||||
---
|
||||
|
||||
OpenCode supports most common terminal themes and you can create your own custom theme.
|
||||
|
||||
## Built-in themes
|
||||
|
||||
The following predefined themes are available:
|
||||
|
||||
- `opencode`
|
||||
- `catppuccin`
|
||||
- `dracula`
|
||||
- `flexoki`
|
||||
- `gruvbox`
|
||||
- `monokai`
|
||||
- `onedark`
|
||||
- `tokyonight`
|
||||
- `tron`
|
||||
- `custom`
|
||||
|
||||
Where `opencode` is the default theme and `custom` let's you define your own theme.
|
||||
|
||||
## Setting a theme
|
||||
|
||||
You can set your theme in your OpenCode config.
|
||||
|
||||
```json title=".opencode.json"
|
||||
{
|
||||
"tui": {
|
||||
"theme": "monokai"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Create a theme
|
||||
|
||||
You can create your own custom theme by setting the `theme: custom` and providing color definitions through the `customTheme`.
|
||||
|
||||
```json title=".opencode.json"
|
||||
{
|
||||
"tui": {
|
||||
"theme": "custom",
|
||||
"customTheme": {
|
||||
"primary": "#ffcc00",
|
||||
"secondary": "#00ccff",
|
||||
"accent": { "dark": "#aa00ff", "light": "#ddccff" },
|
||||
"error": "#ff0000"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Color keys
|
||||
|
||||
You can define any of the following color keys in your `customTheme`.
|
||||
|
||||
| Type | Color keys |
|
||||
| --- | --- |
|
||||
| Base colors | `primary`, `secondary`, `accent` |
|
||||
| Status colors | `error`, `warning`, `success`, `info` |
|
||||
| Text colors | `text`, `textMuted`, `textEmphasized` |
|
||||
| Background colors | `background`, `backgroundSecondary`, `backgroundDarker` |
|
||||
| Border colors | `borderNormal`, `borderFocused`, `borderDim` |
|
||||
| Diff view colors | `diffAdded`, `diffRemoved`, `diffContext`, etc. |
|
||||
|
||||
You don't need to define all the color keys. Any undefined colors will fall back to the default `opencode` theme colors.
|
||||
|
||||
#### Color definitions
|
||||
|
||||
Color keys can take:
|
||||
|
||||
1. **Hex string**: A single hex color string, like `"#aabbcc"`, that'll be used for both light and dark terminal backgrounds.
|
||||
|
||||
2. **Light and dark colors**: An object with `dark` and `light` hex colors that'll be set based on the terminal's background.
|
||||
12
packages/web/src/content/docs/index.mdx
Normal file
12
packages/web/src/content/docs/index.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: OpenCode
|
||||
description: The AI coding agent built for the terminal.
|
||||
template: splash
|
||||
hero:
|
||||
title: The AI coding agent built for the terminal.
|
||||
tagline: The AI coding agent built for the terminal.
|
||||
image:
|
||||
dark: ../../assets/logo-dark.svg
|
||||
light: ../../assets/logo-light.svg
|
||||
alt: OpenCode logo
|
||||
---
|
||||
Reference in New Issue
Block a user