summaryrefslogtreecommitdiffhomepage
path: root/www/src/content/docs
diff options
context:
space:
mode:
authorJay V <[email protected]>2025-05-21 19:34:50 -0400
committerJay V <[email protected]>2025-05-21 19:34:50 -0400
commit6f894950a632896d4e918524f7f064492c43b86e (patch)
tree81aa8547c0041657d551f77576f28d2c9934b5d0 /www/src/content/docs
parent9049295cc961b250be6144585dde322e778534d7 (diff)
downloadopencode-6f894950a632896d4e918524f7f064492c43b86e.tar.gz
opencode-6f894950a632896d4e918524f7f064492c43b86e.zip
adding other chapters
Diffstat (limited to 'www/src/content/docs')
-rw-r--r--www/src/content/docs/docs/cli.mdx62
-rw-r--r--www/src/content/docs/docs/lsp-servers.mdx39
-rw-r--r--www/src/content/docs/docs/mcp-servers.mdx39
-rw-r--r--www/src/content/docs/docs/shortcuts.mdx67
-rw-r--r--www/src/content/docs/docs/themes.mdx68
5 files changed, 270 insertions, 5 deletions
diff --git a/www/src/content/docs/docs/cli.mdx b/www/src/content/docs/docs/cli.mdx
index 587d9253a..9e9796abd 100644
--- a/www/src/content/docs/docs/cli.mdx
+++ b/www/src/content/docs/docs/cli.mdx
@@ -15,10 +15,62 @@ opencode -d
opencode -c /path/to/project
```
+## Non-interactive Prompt Mode
+
+You can 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.
+
+```bash
+# Run a single prompt and print the AI's response to the terminal
+opencode -p "Explain the use of context in Go"
+
+# Get response in JSON format
+opencode -p "Explain the use of context in Go" -f json
+
+# Run without showing the spinner
+opencode -p "Explain the use of context in Go" -q
+
+# Enable verbose logging to stderr
+opencode -p "Explain the use of context in Go" --verbose
+
+# Restrict the agent to only use specific tools
+opencode -p "Explain the use of context in Go" --allowedTools=view,ls,glob
+
+# Prevent the agent from using specific tools
+opencode -p "Explain the use of context in Go" --excludedTools=bash,edit
+```
+
+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`: Comma-separated list of tools that the agent is allowed to use. Only these tools will be available.
+- `--excludedTools`: Comma-separated list of tools that the agent is not allowed to use. All other tools will be available.
+
+These flags are mutually exclusive - you can use either `--allowedTools` or `--excludedTools`, but not both at the same time.
+
+### Output Formats
+
+OpenCode supports the following output formats in non-interactive mode:
+
+| Format | Description |
+| ------ | -------------------------------------- |
+| `text` | Plain text output (default) |
+| `json` | Output wrapped in a JSON object |
+
+The output format is implemented as a strongly-typed `OutputFormat` in the codebase, ensuring type safety and validation when processing outputs.
+
## Command-line Flags
-| Flag | Short | Description |
-| --------- | ----- | ----------------------------- |
-| `--help` | `-h` | Display help information |
-| `--debug` | `-d` | Enable debug mode |
-| `--cwd` | `-c` | Set current working directory |
+| Flag | Short | Description |
+| ----------------- | ----- | ---------------------------------------------------------- |
+| `--help` | `-h` | Display help information |
+| `--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, 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 |
diff --git a/www/src/content/docs/docs/lsp-servers.mdx b/www/src/content/docs/docs/lsp-servers.mdx
new file mode 100644
index 000000000..ad6051c5f
--- /dev/null
+++ b/www/src/content/docs/docs/lsp-servers.mdx
@@ -0,0 +1,39 @@
+---
+title: LSP servers
+---
+
+OpenCode integrates with Language Server Protocol to provide code intelligence features across multiple programming languages.
+
+### LSP Features
+
+- **Multi-language Support**: Connect to language servers for different programming languages
+- **Diagnostics**: Receive error checking and linting information
+- **File Watching**: Automatically notify language servers of file changes
+
+### Configuring LSP
+
+Language servers are configured in the configuration file under the `lsp` section:
+
+```json
+{
+ "lsp": {
+ "go": {
+ "disabled": false,
+ "command": "gopls"
+ },
+ "typescript": {
+ "disabled": false,
+ "command": "typescript-language-server",
+ "args": ["--stdio"]
+ }
+ }
+}
+
+### LSP Integration with AI
+
+The AI assistant can access LSP features through the `diagnostics` tool, allowing it to:
+
+- Check for errors in your code
+- Suggest fixes based on diagnostics
+
+While the LSP client implementation supports the full LSP protocol (including completions, hover, definition, etc.), currently only diagnostics are exposed to the AI assistant.
diff --git a/www/src/content/docs/docs/mcp-servers.mdx b/www/src/content/docs/docs/mcp-servers.mdx
index 2f964ad87..429082ba4 100644
--- a/www/src/content/docs/docs/mcp-servers.mdx
+++ b/www/src/content/docs/docs/mcp-servers.mdx
@@ -1,3 +1,42 @@
---
title: MCP servers
---
+
+OpenCode implements the Model Context Protocol (MCP) to extend its capabilities through external tools. MCP provides a standardized way for the AI assistant to interact with external services and tools.
+
+### MCP Features
+
+- **External Tool Integration**: Connect to external tools and services via a standardized protocol
+- **Tool Discovery**: Automatically discover available tools from MCP servers
+- **Multiple Connection Types**:
+ - **Stdio**: Communicate with tools via standard input/output
+ - **SSE**: Communicate with tools via Server-Sent Events
+- **Security**: Permission system for controlling access to MCP tools
+
+### Configuring MCP Servers
+
+MCP servers are defined in the configuration file under the `mcpServers` section:
+
+```json
+{
+ "mcpServers": {
+ "example": {
+ "type": "stdio",
+ "command": "path/to/mcp-server",
+ "env": [],
+ "args": []
+ },
+ "web-example": {
+ "type": "sse",
+ "url": "https://example.com/mcp",
+ "headers": {
+ "Authorization": "Bearer token"
+ }
+ }
+ }
+}
+```
+
+### MCP Tool Usage
+
+Once configured, MCP tools are automatically available to the AI assistant alongside built-in tools. They follow the same permission model as other tools, requiring user approval before execution.
diff --git a/www/src/content/docs/docs/shortcuts.mdx b/www/src/content/docs/docs/shortcuts.mdx
index 85bafb0de..ece9542c0 100644
--- a/www/src/content/docs/docs/shortcuts.mdx
+++ b/www/src/content/docs/docs/shortcuts.mdx
@@ -3,3 +3,70 @@ title: Keyboard shortcuts
sidebar:
label: Shortcuts
---
+
+### Global Shortcuts
+
+| 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 Page Shortcuts
+
+| 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 Shortcuts
+
+| 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 Shortcuts
+
+| Shortcut | Action |
+| ---------- | ---------------- |
+| `↑` or `k` | Previous session |
+| `↓` or `j` | Next session |
+| `Enter` | Select session |
+| `Esc` | Close dialog |
+
+### Model Dialog Shortcuts
+
+| Shortcut | Action |
+| ---------- | ----------------- |
+| `↑` or `k` | Move up |
+| `↓` or `j` | Move down |
+| `←` or `h` | Previous provider |
+| `→` or `l` | Next provider |
+| `Esc` | Close dialog |
+
+### Permission Dialog Shortcuts
+
+| 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 |
+
+### Logs Page Shortcuts
+
+| Shortcut | Action |
+| ------------------ | ------------------- |
+| `Backspace` or `q` | Return to chat page |
diff --git a/www/src/content/docs/docs/themes.mdx b/www/src/content/docs/docs/themes.mdx
index f8ee32845..38c7a15fb 100644
--- a/www/src/content/docs/docs/themes.mdx
+++ b/www/src/content/docs/docs/themes.mdx
@@ -1,3 +1,71 @@
---
title: Themes
---
+
+OpenCode supports multiple themes for customizing the appearance of the terminal interface.
+
+### Available Themes
+
+The following predefined themes are available:
+
+- `opencode` (default)
+- `catppuccin`
+- `dracula`
+- `flexoki`
+- `gruvbox`
+- `monokai`
+- `onedark`
+- `tokyonight`
+- `tron`
+- `custom` (user-defined)
+
+### Setting a Theme
+
+You can set a theme in your `.opencode.json` configuration file:
+
+```json
+{
+ "tui": {
+ "theme": "monokai"
+ }
+}
+```
+
+### Custom Themes
+
+You can define your own custom theme by setting the `theme` to `"custom"` and providing color definitions in the `customTheme` map:
+
+```json
+{
+ "tui": {
+ "theme": "custom",
+ "customTheme": {
+ "primary": "#ffcc00",
+ "secondary": "#00ccff",
+ "accent": { "dark": "#aa00ff", "light": "#ddccff" },
+ "error": "#ff0000"
+ }
+ }
+}
+```
+
+#### Color Definition Formats
+
+Custom theme colors support two formats:
+
+1. **Simple Hex String**: A single hex color string (e.g., `"#aabbcc"`) that will be used for both light and dark terminal backgrounds.
+
+2. **Adaptive Object**: An object with `dark` and `light` keys, each holding a hex color string. This allows for adaptive colors based on the terminal's background.
+
+#### Available Color Keys
+
+You can define any of the following color keys in your `customTheme`:
+
+- 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 colors. Any undefined colors will fall back to the default "opencode" theme colors.