From 6cfcf51752ec8d40104cead0b2602885c77a9c79 Mon Sep 17 00:00:00 2001 From: Jay V Date: Wed, 21 May 2025 14:24:53 -0400 Subject: adding docs site --- www/src/assets/lander/check.svg | 2 + www/src/assets/lander/copy.svg | 2 + www/src/assets/logo-dark.svg | 11 ++ www/src/assets/logo-light.svg | 11 ++ www/src/components/Hero.astro | 11 ++ www/src/components/Lander.astro | 269 ++++++++++++++++++++++++++++++ www/src/content.config.ts | 7 + www/src/content/docs/guides/example.md | 11 ++ www/src/content/docs/index.mdx | 12 ++ www/src/content/docs/reference/example.md | 11 ++ 10 files changed, 347 insertions(+) create mode 100644 www/src/assets/lander/check.svg create mode 100644 www/src/assets/lander/copy.svg create mode 100644 www/src/assets/logo-dark.svg create mode 100644 www/src/assets/logo-light.svg create mode 100644 www/src/components/Hero.astro create mode 100644 www/src/components/Lander.astro create mode 100644 www/src/content.config.ts create mode 100644 www/src/content/docs/guides/example.md create mode 100644 www/src/content/docs/index.mdx create mode 100644 www/src/content/docs/reference/example.md (limited to 'www/src') diff --git a/www/src/assets/lander/check.svg b/www/src/assets/lander/check.svg new file mode 100644 index 000000000..22de6f2a8 --- /dev/null +++ b/www/src/assets/lander/check.svg @@ -0,0 +1,2 @@ + + diff --git a/www/src/assets/lander/copy.svg b/www/src/assets/lander/copy.svg new file mode 100644 index 000000000..f1baac30a --- /dev/null +++ b/www/src/assets/lander/copy.svg @@ -0,0 +1,2 @@ + + diff --git a/www/src/assets/logo-dark.svg b/www/src/assets/logo-dark.svg new file mode 100644 index 000000000..8fd212081 --- /dev/null +++ b/www/src/assets/logo-dark.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/www/src/assets/logo-light.svg b/www/src/assets/logo-light.svg new file mode 100644 index 000000000..0a9007e1a --- /dev/null +++ b/www/src/assets/logo-light.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/www/src/components/Hero.astro b/www/src/components/Hero.astro new file mode 100644 index 000000000..f80f85266 --- /dev/null +++ b/www/src/components/Hero.astro @@ -0,0 +1,11 @@ +--- +import Default from '@astrojs/starlight/components/Hero.astro'; +import Lander from './Lander.astro'; + +const { slug } = Astro.locals.starlightRoute.entry; +--- + +{ slug === "" + ? + : +} diff --git a/www/src/components/Lander.astro b/www/src/components/Lander.astro new file mode 100644 index 000000000..d27358f8f --- /dev/null +++ b/www/src/components/Lander.astro @@ -0,0 +1,269 @@ +--- +import { Image } from 'astro:assets'; +import config from "virtual:starlight/user-config"; +import type { Props } from '@astrojs/starlight/props'; + +import CopyIcon from "../assets/lander/copy.svg"; +import CheckIcon from "../assets/lander/check.svg"; + +const { data } = Astro.locals.starlightRoute.entry; +const { title = data.title, tagline, image, actions = [] } = data.hero || {}; + +const imageAttrs = { + loading: 'eager' as const, + decoding: 'async' as const, + width: 400, + alt: image?.alt || '', +}; + +const github = config.social.filter(s => s.icon === 'github')[0]; + +const command = "npm i -g"; +const pkg = "opencode"; + +let darkImage: ImageMetadata | undefined; +let lightImage: ImageMetadata | undefined; +let rawHtml: string | undefined; +if (image) { + if ('file' in image) { + darkImage = image.file; + } else if ('dark' in image) { + darkImage = image.dark; + lightImage = image.light; + } else { + rawHtml = image.html; + } +} +--- +
+
+ +

The AI coding agent built for the terminal.

+
+ +
+ +
+ +
+ +
+ +
+
    +
  • Native TUI: A native terminal UI for a smoother, snappier experience.
  • +
  • LSP enabled: Loads the right LSPs for your codebase. Helps the LLM make fewer mistakes.
  • +
  • Multi-session: Start multiple conversations in a project to have agents working in parallel.
  • +
  • Use any model: Supports all the models from OpenAI, Anthropic, Google, OpenRouter, and more.
  • +
  • Change tracking: View the file changes from the current conversation in the sidebar.
  • +
  • Edit with Vim: Use Vim as an external editor to compose longer messages.
  • +
+
+ + +
+ + + + + + diff --git a/www/src/content.config.ts b/www/src/content.config.ts new file mode 100644 index 000000000..d9ee8c9d1 --- /dev/null +++ b/www/src/content.config.ts @@ -0,0 +1,7 @@ +import { defineCollection } from 'astro:content'; +import { docsLoader } from '@astrojs/starlight/loaders'; +import { docsSchema } from '@astrojs/starlight/schema'; + +export const collections = { + docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }), +}; diff --git a/www/src/content/docs/guides/example.md b/www/src/content/docs/guides/example.md new file mode 100644 index 000000000..ebd0f3bc7 --- /dev/null +++ b/www/src/content/docs/guides/example.md @@ -0,0 +1,11 @@ +--- +title: Example Guide +description: A guide in my new Starlight docs site. +--- + +Guides lead a user through a specific task they want to accomplish, often with a sequence of steps. +Writing a good guide requires thinking about what your users are trying to do. + +## Further reading + +- Read [about how-to guides](https://diataxis.fr/how-to-guides/) in the Diátaxis framework diff --git a/www/src/content/docs/index.mdx b/www/src/content/docs/index.mdx new file mode 100644 index 000000000..176520ec5 --- /dev/null +++ b/www/src/content/docs/index.mdx @@ -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 +--- diff --git a/www/src/content/docs/reference/example.md b/www/src/content/docs/reference/example.md new file mode 100644 index 000000000..0224f096c --- /dev/null +++ b/www/src/content/docs/reference/example.md @@ -0,0 +1,11 @@ +--- +title: Example Reference +description: A reference page in my new Starlight docs site. +--- + +Reference pages are ideal for outlining how things work in terse and clear terms. +Less concerned with telling a story or addressing a specific use case, they should give a comprehensive outline of what you're documenting. + +## Further reading + +- Read [about reference](https://diataxis.fr/reference/) in the Diátaxis framework -- cgit v1.2.3 From d9c1b2cc904ad9f3bf00c1492276a783a7febcf7 Mon Sep 17 00:00:00 2001 From: Jay V Date: Wed, 21 May 2025 14:58:30 -0400 Subject: adding docs site --- www/astro.config.mjs | 19 +++++++------------ www/src/content/docs/guides/example.md | 11 ----------- www/src/content/docs/reference/example.md | 11 ----------- 3 files changed, 7 insertions(+), 34 deletions(-) delete mode 100644 www/src/content/docs/guides/example.md delete mode 100644 www/src/content/docs/reference/example.md (limited to 'www/src') diff --git a/www/astro.config.mjs b/www/astro.config.mjs index ae0729f13..ebf7905ef 100644 --- a/www/astro.config.mjs +++ b/www/astro.config.mjs @@ -35,17 +35,13 @@ export default defineConfig({ replacesTitle: true, }, sidebar: [ - { - label: "Guides", - items: [ - // Each item here is one entry in the navigation menu. - { label: "Example Guide", slug: "guides/example" }, - ], - }, - { - label: "Reference", - autogenerate: { directory: "reference" }, - }, + "docs", + "docs/cli", + "docs/config", + "docs/models", + "docs/themes", + "docs/shortcuts", + "docs/mcp-servers", ], components: { Hero: "./src/components/Hero.astro", @@ -55,7 +51,6 @@ export default defineConfig({ headerLinks: [ { name: "Home", url: "/" }, { name: "Docs", url: "/docs/" }, - { name: "Blog", url: "/blog/" }, ], })], }), diff --git a/www/src/content/docs/guides/example.md b/www/src/content/docs/guides/example.md deleted file mode 100644 index ebd0f3bc7..000000000 --- a/www/src/content/docs/guides/example.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Example Guide -description: A guide in my new Starlight docs site. ---- - -Guides lead a user through a specific task they want to accomplish, often with a sequence of steps. -Writing a good guide requires thinking about what your users are trying to do. - -## Further reading - -- Read [about how-to guides](https://diataxis.fr/how-to-guides/) in the Diátaxis framework diff --git a/www/src/content/docs/reference/example.md b/www/src/content/docs/reference/example.md deleted file mode 100644 index 0224f096c..000000000 --- a/www/src/content/docs/reference/example.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Example Reference -description: A reference page in my new Starlight docs site. ---- - -Reference pages are ideal for outlining how things work in terse and clear terms. -Less concerned with telling a story or addressing a specific use case, they should give a comprehensive outline of what you're documenting. - -## Further reading - -- Read [about reference](https://diataxis.fr/reference/) in the Diátaxis framework -- cgit v1.2.3 From f768313c4f9123956459490f01663d280caf79e5 Mon Sep 17 00:00:00 2001 From: Jay V Date: Wed, 21 May 2025 14:59:09 -0400 Subject: Moving readme to docs --- www/src/content/docs/docs/cli.mdx | 3 ++ www/src/content/docs/docs/config.mdx | 84 +++++++++++++++++++++++++++++++ www/src/content/docs/docs/index.mdx | 37 ++++++++++++++ www/src/content/docs/docs/mcp-servers.mdx | 3 ++ www/src/content/docs/docs/models.mdx | 5 ++ www/src/content/docs/docs/shortcuts.mdx | 5 ++ www/src/content/docs/docs/themes.mdx | 3 ++ 7 files changed, 140 insertions(+) create mode 100644 www/src/content/docs/docs/cli.mdx create mode 100644 www/src/content/docs/docs/config.mdx create mode 100644 www/src/content/docs/docs/index.mdx create mode 100644 www/src/content/docs/docs/mcp-servers.mdx create mode 100644 www/src/content/docs/docs/models.mdx create mode 100644 www/src/content/docs/docs/shortcuts.mdx create mode 100644 www/src/content/docs/docs/themes.mdx (limited to 'www/src') diff --git a/www/src/content/docs/docs/cli.mdx b/www/src/content/docs/docs/cli.mdx new file mode 100644 index 000000000..5f81cc866 --- /dev/null +++ b/www/src/content/docs/docs/cli.mdx @@ -0,0 +1,3 @@ +--- +title: CLI +--- diff --git a/www/src/content/docs/docs/config.mdx b/www/src/content/docs/docs/config.mdx new file mode 100644 index 000000000..e6628d6c3 --- /dev/null +++ b/www/src/content/docs/docs/config.mdx @@ -0,0 +1,84 @@ +--- +title: Config +--- + +OpenCode looks for configuration in the following locations: + +- `$HOME/.opencode.json` +- `$XDG_CONFIG_HOME/opencode/.opencode.json` +- `./.opencode.json` (local directory) + +## Environment variables + +You can configure OpenCode using environment variables: + +| Environment Variable | Purpose | +| -------------------------- | ------------------------------------------------------ | +| `ANTHROPIC_API_KEY` | For Claude models | +| `OPENAI_API_KEY` | For OpenAI models | +| `GEMINI_API_KEY` | For Google Gemini models | +| `GROQ_API_KEY` | For Groq models | +| `AWS_ACCESS_KEY_ID` | For AWS Bedrock (Claude) | +| `AWS_SECRET_ACCESS_KEY` | For AWS Bedrock (Claude) | +| `AWS_REGION` | For AWS Bedrock (Claude) | +| `AZURE_OPENAI_ENDPOINT` | For Azure OpenAI models | +| `AZURE_OPENAI_API_KEY` | For Azure OpenAI models (optional when using Entra ID) | +| `AZURE_OPENAI_API_VERSION` | For Azure OpenAI models | + +## OpenCode config + +```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 +} +``` diff --git a/www/src/content/docs/docs/index.mdx b/www/src/content/docs/docs/index.mdx new file mode 100644 index 000000000..3b7d6db09 --- /dev/null +++ b/www/src/content/docs/docs/index.mdx @@ -0,0 +1,37 @@ +--- +title: Get started +--- + +## Installation + +#### Using the install script + +```bash +# Install the latest version +curl -fsSL https://opencode.ai/install | bash + +# Install a specific version +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 (Arch Linux) + +```bash +# Using yay +yay -S opencode-bin + +# Using paru +paru -S opencode-bin +``` + +#### Using Go + +```bash +go install github.com/sst/opencode@latest +``` diff --git a/www/src/content/docs/docs/mcp-servers.mdx b/www/src/content/docs/docs/mcp-servers.mdx new file mode 100644 index 000000000..2f964ad87 --- /dev/null +++ b/www/src/content/docs/docs/mcp-servers.mdx @@ -0,0 +1,3 @@ +--- +title: MCP servers +--- diff --git a/www/src/content/docs/docs/models.mdx b/www/src/content/docs/docs/models.mdx new file mode 100644 index 000000000..1453b65a1 --- /dev/null +++ b/www/src/content/docs/docs/models.mdx @@ -0,0 +1,5 @@ +--- +title: Models +--- + + diff --git a/www/src/content/docs/docs/shortcuts.mdx b/www/src/content/docs/docs/shortcuts.mdx new file mode 100644 index 000000000..85bafb0de --- /dev/null +++ b/www/src/content/docs/docs/shortcuts.mdx @@ -0,0 +1,5 @@ +--- +title: Keyboard shortcuts +sidebar: + label: Shortcuts +--- diff --git a/www/src/content/docs/docs/themes.mdx b/www/src/content/docs/docs/themes.mdx new file mode 100644 index 000000000..f8ee32845 --- /dev/null +++ b/www/src/content/docs/docs/themes.mdx @@ -0,0 +1,3 @@ +--- +title: Themes +--- -- cgit v1.2.3 From 4526b14b17dc49f3ef4f3b1a1d02eff5c6b6b59f Mon Sep 17 00:00:00 2001 From: Jay V Date: Wed, 21 May 2025 15:01:12 -0400 Subject: Moving readme to docs --- www/src/content/docs/docs/cli.mdx | 21 +++++++++ www/src/content/docs/docs/models.mdx | 83 ++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) (limited to 'www/src') diff --git a/www/src/content/docs/docs/cli.mdx b/www/src/content/docs/docs/cli.mdx index 5f81cc866..587d9253a 100644 --- a/www/src/content/docs/docs/cli.mdx +++ b/www/src/content/docs/docs/cli.mdx @@ -1,3 +1,24 @@ --- title: CLI --- + +## Usage + +```bash +# Start OpenCode +opencode + +# Start with debug logging +opencode -d + +# Start with a specific working directory +opencode -c /path/to/project +``` + +## Command-line Flags + +| Flag | Short | Description | +| --------- | ----- | ----------------------------- | +| `--help` | `-h` | Display help information | +| `--debug` | `-d` | Enable debug mode | +| `--cwd` | `-c` | Set current working directory | diff --git a/www/src/content/docs/docs/models.mdx b/www/src/content/docs/docs/models.mdx index 1453b65a1..83ca69916 100644 --- a/www/src/content/docs/docs/models.mdx +++ b/www/src/content/docs/docs/models.mdx @@ -2,4 +2,87 @@ title: Models --- +## Supported AI Models +OpenCode supports a variety of AI models from different providers: + +### OpenAI + +- GPT-4.1 family (gpt-4.1, gpt-4.1-mini, gpt-4.1-nano) +- GPT-4.5 Preview +- GPT-4o family (gpt-4o, gpt-4o-mini) +- O1 family (o1, o1-pro, o1-mini) +- O3 family (o3, o3-mini) +- O4 Mini + +### Anthropic + +- Claude 3.5 Sonnet +- Claude 3.5 Haiku +- Claude 3.7 Sonnet +- Claude 3 Haiku +- Claude 3 Opus + +### Google + +- Gemini 2.5 +- Gemini 2.5 Flash +- Gemini 2.0 Flash +- Gemini 2.0 Flash Lite + +### AWS Bedrock + +- Claude 3.7 Sonnet + +### Groq + +- Llama 4 Maverick (17b-128e-instruct) +- Llama 4 Scout (17b-16e-instruct) +- QWEN QWQ-32b +- Deepseek R1 distill Llama 70b +- Llama 3.3 70b Versatile + +### Azure OpenAI + +- GPT-4.1 family (gpt-4.1, gpt-4.1-mini, gpt-4.1-nano) +- GPT-4.5 Preview +- GPT-4o family (gpt-4o, gpt-4o-mini) +- O1 family (o1, o1-mini) +- O3 family (o3, o3-mini) +- O4 Mini + +### Google Cloud VertexAI + +- Gemini 2.5 +- Gemini 2.5 Flash + +## Using Bedrock Models + +To use bedrock models with OpenCode you need three things. + +1. Valid AWS credentials (the env vars: `AWS_SECRET_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `AWS_REGION`) +2. Access to the corresponding model in AWS Bedrock in your region. + a. You can request access in the AWS console on the Bedrock -> "Model access" page. +3. A correct configuration file. You don't need the `providers` key. Instead you have to prefix your models per agent with `bedrock.` and then a valid model. For now only Claude 3.7 is supported. + +```json +{ + "agents": { + "primary": { + "model": "bedrock.claude-3.7-sonnet", + "maxTokens": 5000, + "reasoningEffort": "" + }, + "task": { + "model": "bedrock.claude-3.7-sonnet", + "maxTokens": 5000, + "reasoningEffort": "" + }, + "title": { + "model": "bedrock.claude-3.7-sonnet", + "maxTokens": 80, + "reasoningEffort": "" + } + }, +} +``` -- cgit v1.2.3 From 6f894950a632896d4e918524f7f064492c43b86e Mon Sep 17 00:00:00 2001 From: Jay V Date: Wed, 21 May 2025 19:34:50 -0400 Subject: adding other chapters --- www/astro.config.mjs | 1 + www/src/content/docs/docs/cli.mdx | 62 +++++++++++++++++++++++++--- www/src/content/docs/docs/lsp-servers.mdx | 39 ++++++++++++++++++ www/src/content/docs/docs/mcp-servers.mdx | 39 ++++++++++++++++++ www/src/content/docs/docs/shortcuts.mdx | 67 ++++++++++++++++++++++++++++++ www/src/content/docs/docs/themes.mdx | 68 +++++++++++++++++++++++++++++++ 6 files changed, 271 insertions(+), 5 deletions(-) create mode 100644 www/src/content/docs/docs/lsp-servers.mdx (limited to 'www/src') diff --git a/www/astro.config.mjs b/www/astro.config.mjs index ebf7905ef..9c25d7db8 100644 --- a/www/astro.config.mjs +++ b/www/astro.config.mjs @@ -41,6 +41,7 @@ export default defineConfig({ "docs/models", "docs/themes", "docs/shortcuts", + "docs/lsp-servers", "docs/mcp-servers", ], components: { 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. -- cgit v1.2.3 From da9b2a18b95c1c47d3505f0ebbf11ea7076494d3 Mon Sep 17 00:00:00 2001 From: Jay V Date: Thu, 22 May 2025 15:10:08 -0400 Subject: editing docs --- www/astro.config.mjs | 3 + www/src/content/docs/docs/cli.mdx | 99 +++++++++++++++++-------------- www/src/content/docs/docs/config.mdx | 42 +++++++------ www/src/content/docs/docs/index.mdx | 33 +++++++++-- www/src/content/docs/docs/lsp-servers.mdx | 29 ++++----- www/src/content/docs/docs/mcp-servers.mdx | 41 ++++++++----- www/src/content/docs/docs/models.mdx | 82 +++++-------------------- www/src/content/docs/docs/shortcuts.mdx | 20 +++---- www/src/content/docs/docs/themes.mdx | 50 +++++++++------- 9 files changed, 195 insertions(+), 204 deletions(-) (limited to 'www/src') diff --git a/www/astro.config.mjs b/www/astro.config.mjs index 9c25d7db8..0edc80af1 100644 --- a/www/astro.config.mjs +++ b/www/astro.config.mjs @@ -29,6 +29,9 @@ export default defineConfig({ editLink: { baseUrl: `${github}/edit/master/www/`, }, + markdown: { + headingLinks: false, + }, logo: { light: "./src/assets/logo-light.svg", dark: "./src/assets/logo-dark.svg", diff --git a/www/src/content/docs/docs/cli.mdx b/www/src/content/docs/docs/cli.mdx index 9e9796abd..44a56e1fb 100644 --- a/www/src/content/docs/docs/cli.mdx +++ b/www/src/content/docs/docs/cli.mdx @@ -2,75 +2,88 @@ title: CLI --- -## Usage +Once installed you can run the OpenCode CLI. ```bash -# Start OpenCode opencode +``` + +Or pass in flags. For example, to start with debug logging: -# Start with debug logging +```bash opencode -d +``` + +Or start with a specific working directory. -# Start with a specific working directory +```bash opencode -c /path/to/project ``` -## Non-interactive Prompt Mode +## Flags -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. +The OpenCode CLI takes the following flags. -```bash -# Run a single prompt and print the AI's response to the terminal +| 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" +``` -# Get response in JSON format -opencode -p "Explain the use of context in Go" -f json +If you want to run without showing the spinner, use `-q`. -# Run without showing the spinner +```bash "-q" 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 +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. -# Restrict the agent to only use specific tools -opencode -p "Explain the use of context in Go" --allowedTools=view,ls,glob +#### Tool restrictions -# Prevent the agent from using specific tools -opencode -p "Explain the use of context in Go" --excludedTools=bash,edit -``` +You can control which tools the AI assistant has access to in non-interactive mode. -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. +- `--allowedTools` -### Tool Restrictions + A comma-separated list of tools that the agent is allowed to use. Only these tools will be available. -You can control which tools the AI assistant has access to in non-interactive mode: + ```bash "--allowedTools" + opencode -p "Explain the use of context in Go" --allowedTools=view,ls,glob + ``` -- `--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. +- `--excludedTools` -These flags are mutually exclusive - you can use either `--allowedTools` or `--excludedTools`, but not both at the same time. + Comma-separated list of tools that the agent is not allowed to use. All other tools will be available. -### Output Formats + ```bash "--excludedTools" + opencode -p "Explain the use of context in Go" --excludedTools=bash,edit + ``` -OpenCode supports the following output formats in non-interactive mode: +These flags are mutually exclusive. So you can either use `--allowedTools` or `--excludedTools`, but not both. -| Format | Description | -| ------ | -------------------------------------- | -| `text` | Plain text output (default) | -| `json` | Output wrapped in a JSON object | +#### Output formats -The output format is implemented as a strongly-typed `OutputFormat` in the codebase, ensuring type safety and validation when processing outputs. +In non-interactive mode, you can also set the CLI to return as JSON using `-f`. -## Command-line Flags +```bash "-f json" +opencode -p "Explain the use of context in Go" -f json +``` -| 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 | +By default, this is set to `text`, to return plain text. diff --git a/www/src/content/docs/docs/config.mdx b/www/src/content/docs/docs/config.mdx index e6628d6c3..288f194c5 100644 --- a/www/src/content/docs/docs/config.mdx +++ b/www/src/content/docs/docs/config.mdx @@ -2,32 +2,18 @@ title: Config --- -OpenCode looks for configuration in the following locations: +You can configure OpenCode using the OpenCode config. It can be places in: - `$HOME/.opencode.json` - `$XDG_CONFIG_HOME/opencode/.opencode.json` -- `./.opencode.json` (local directory) -## Environment variables - -You can configure OpenCode using environment variables: - -| Environment Variable | Purpose | -| -------------------------- | ------------------------------------------------------ | -| `ANTHROPIC_API_KEY` | For Claude models | -| `OPENAI_API_KEY` | For OpenAI models | -| `GEMINI_API_KEY` | For Google Gemini models | -| `GROQ_API_KEY` | For Groq models | -| `AWS_ACCESS_KEY_ID` | For AWS Bedrock (Claude) | -| `AWS_SECRET_ACCESS_KEY` | For AWS Bedrock (Claude) | -| `AWS_REGION` | For AWS Bedrock (Claude) | -| `AZURE_OPENAI_ENDPOINT` | For Azure OpenAI models | -| `AZURE_OPENAI_API_KEY` | For Azure OpenAI models (optional when using Entra ID) | -| `AZURE_OPENAI_API_VERSION` | For Azure OpenAI models | +Or in the current directory, `./.opencode.json`. ## OpenCode config -```json +The config file has the following structure. + +```json title=".opencode.json" { "data": { "directory": ".opencode" @@ -82,3 +68,21 @@ You can configure OpenCode using environment variables: "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 | + diff --git a/www/src/content/docs/docs/index.mdx b/www/src/content/docs/docs/index.mdx index 3b7d6db09..e6f71be19 100644 --- a/www/src/content/docs/docs/index.mdx +++ b/www/src/content/docs/docs/index.mdx @@ -1,16 +1,33 @@ --- -title: Get started +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 -# Install the latest version curl -fsSL https://opencode.ai/install | bash +``` -# Install a specific version +Or install a specific version. + +```bash curl -fsSL https://opencode.ai/install | VERSION=0.1.0 bash ``` @@ -20,13 +37,17 @@ curl -fsSL https://opencode.ai/install | VERSION=0.1.0 bash brew install sst/tap/opencode ``` -#### Using AUR (Arch Linux) +#### Using AUR in Arch Linux + +With yay. ```bash -# Using yay yay -S opencode-bin +``` + +Or with paru. -# Using paru +```bash paru -S opencode-bin ``` diff --git a/www/src/content/docs/docs/lsp-servers.mdx b/www/src/content/docs/docs/lsp-servers.mdx index ad6051c5f..cd259dea7 100644 --- a/www/src/content/docs/docs/lsp-servers.mdx +++ b/www/src/content/docs/docs/lsp-servers.mdx @@ -2,19 +2,22 @@ title: LSP servers --- -OpenCode integrates with Language Server Protocol to provide code intelligence features across multiple programming languages. +OpenCode integrates with _Language Server Protocol_, or LSP to improve how the LLM interacts with your codebase. -### LSP Features +LSP servers for different languages give the LLM: -- **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 +- **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_. -### Configuring LSP +## Auto-detection -Language servers are configured in the configuration file under the `lsp` section: +By default, OpenCode will **automatically detect** the languages used in your project and add the right LSP servers. -```json +## 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": { @@ -28,12 +31,4 @@ Language servers are configured in the configuration file under the `lsp` sectio } } } - -### 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 429082ba4..28c6d2ab2 100644 --- a/www/src/content/docs/docs/mcp-servers.mdx +++ b/www/src/content/docs/docs/mcp-servers.mdx @@ -2,31 +2,40 @@ 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. +You can add external tools to OpenCode using the _Model Context Protocol_, or MCP. OpenCode supports both: -### MCP Features +- Local servers that use standard input/output, `stdio` +- Remote servers that use server-sent events `sse` -- **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 +## Add MCP servers -### Configuring MCP Servers +You can define MCP servers in your OpenCode config under the `mcpServers` section: -MCP servers are defined in the configuration file under the `mcpServers` section: +### Local -```json +To add a local or `stdio` MCP server. + +```json title=".opencode.json" {4} { "mcpServers": { - "example": { + "local-example": { "type": "stdio", "command": "path/to/mcp-server", "env": [], "args": [] - }, - "web-example": { + } + } +} +``` + +### 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": { @@ -37,6 +46,6 @@ MCP servers are defined in the configuration file under the `mcpServers` section } ``` -### MCP Tool Usage +## 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. +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. diff --git a/www/src/content/docs/docs/models.mdx b/www/src/content/docs/docs/models.mdx index 83ca69916..c40216695 100644 --- a/www/src/content/docs/docs/models.mdx +++ b/www/src/content/docs/docs/models.mdx @@ -2,87 +2,33 @@ title: Models --- -## Supported AI Models +OpenCode uses the [AI SDK](https://ai-sdk.dev/) to have the support for **all the AI models**. -OpenCode supports a variety of AI models from different providers: +Start by setting the [keys for the providers](/docs/config) you want to use in your OpenCode config. -### OpenAI +## Model select -- GPT-4.1 family (gpt-4.1, gpt-4.1-mini, gpt-4.1-nano) -- GPT-4.5 Preview -- GPT-4o family (gpt-4o, gpt-4o-mini) -- O1 family (o1, o1-pro, o1-mini) -- O3 family (o3, o3-mini) -- O4 Mini +You can now select the model you want from the menu by hitting `Ctrl+O`. -### Anthropic +## Multiple models -- Claude 3.5 Sonnet -- Claude 3.5 Haiku -- Claude 3.7 Sonnet -- Claude 3 Haiku -- Claude 3 Opus +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. -### Google - -- Gemini 2.5 -- Gemini 2.5 Flash -- Gemini 2.0 Flash -- Gemini 2.0 Flash Lite - -### AWS Bedrock - -- Claude 3.7 Sonnet - -### Groq - -- Llama 4 Maverick (17b-128e-instruct) -- Llama 4 Scout (17b-16e-instruct) -- QWEN QWQ-32b -- Deepseek R1 distill Llama 70b -- Llama 3.3 70b Versatile - -### Azure OpenAI - -- GPT-4.1 family (gpt-4.1, gpt-4.1-mini, gpt-4.1-nano) -- GPT-4.5 Preview -- GPT-4o family (gpt-4o, gpt-4o-mini) -- O1 family (o1, o1-mini) -- O3 family (o3, o3-mini) -- O4 Mini - -### Google Cloud VertexAI - -- Gemini 2.5 -- Gemini 2.5 Flash - -## Using Bedrock Models - -To use bedrock models with OpenCode you need three things. - -1. Valid AWS credentials (the env vars: `AWS_SECRET_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `AWS_REGION`) -2. Access to the corresponding model in AWS Bedrock in your region. - a. You can request access in the AWS console on the Bedrock -> "Model access" page. -3. A correct configuration file. You don't need the `providers` key. Instead you have to prefix your models per agent with `bedrock.` and then a valid model. For now only Claude 3.7 is supported. - -```json +```json title=".opencode.json" { "agents": { "primary": { - "model": "bedrock.claude-3.7-sonnet", - "maxTokens": 5000, - "reasoningEffort": "" + "model": "gpt-4", + "maxTokens": 5000 }, "task": { - "model": "bedrock.claude-3.7-sonnet", - "maxTokens": 5000, - "reasoningEffort": "" + "model": "gpt-3.5-turbo", + "maxTokens": 5000 }, "title": { - "model": "bedrock.claude-3.7-sonnet", - "maxTokens": 80, - "reasoningEffort": "" + "model": "gpt-3.5-turbo", + "maxTokens": 80 } - }, + } } ``` diff --git a/www/src/content/docs/docs/shortcuts.mdx b/www/src/content/docs/docs/shortcuts.mdx index ece9542c0..dd866e0f3 100644 --- a/www/src/content/docs/docs/shortcuts.mdx +++ b/www/src/content/docs/docs/shortcuts.mdx @@ -4,7 +4,9 @@ sidebar: label: Shortcuts --- -### Global Shortcuts +Below are a list of keyboard shortcuts that OpenCode supports. + +## Global | Shortcut | Action | | -------- | ------------------------------------------------------- | @@ -17,7 +19,7 @@ sidebar: | `Ctrl+O` | Toggle model selection dialog | | `Esc` | Close current overlay/dialog or return to previous mode | -### Chat Page Shortcuts +## Chat pane | Shortcut | Action | | -------- | --------------------------------------- | @@ -26,7 +28,7 @@ sidebar: | `i` | Focus editor (when not in writing mode) | | `Esc` | Exit writing mode and focus messages | -### Editor Shortcuts +## Editor view | Shortcut | Action | | ------------------- | ----------------------------------------- | @@ -35,7 +37,7 @@ sidebar: | `Ctrl+E` | Open external editor | | `Esc` | Blur editor and focus messages | -### Session Dialog Shortcuts +## Session dialog | Shortcut | Action | | ---------- | ---------------- | @@ -44,7 +46,7 @@ sidebar: | `Enter` | Select session | | `Esc` | Close dialog | -### Model Dialog Shortcuts +## Model dialog | Shortcut | Action | | ---------- | ----------------- | @@ -54,7 +56,7 @@ sidebar: | `→` or `l` | Next provider | | `Esc` | Close dialog | -### Permission Dialog Shortcuts +## Permission dialog | Shortcut | Action | | ----------------------- | ---------------------------- | @@ -64,9 +66,3 @@ sidebar: | `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 38c7a15fb..e691a22e7 100644 --- a/www/src/content/docs/docs/themes.mdx +++ b/www/src/content/docs/docs/themes.mdx @@ -2,13 +2,13 @@ title: Themes --- -OpenCode supports multiple themes for customizing the appearance of the terminal interface. +OpenCode supports most common terminal themes and you can create your own custom theme. -### Available Themes +## Built-in themes The following predefined themes are available: -- `opencode` (default) +- `opencode` - `catppuccin` - `dracula` - `flexoki` @@ -17,13 +17,15 @@ The following predefined themes are available: - `onedark` - `tokyonight` - `tron` -- `custom` (user-defined) +- `custom` -### Setting a Theme +Where `opencode` is the default theme and `custom` let's you define your own theme. -You can set a theme in your `.opencode.json` configuration file: +## Setting a theme -```json +You can set your theme in your OpenCode config. + +```json title=".opencode.json" { "tui": { "theme": "monokai" @@ -31,11 +33,11 @@ You can set a theme in your `.opencode.json` configuration file: } ``` -### Custom Themes +## Create a theme -You can define your own custom theme by setting the `theme` to `"custom"` and providing color definitions in the `customTheme` map: +You can create your own custom theme by setting the `theme: custom` and providing color definitions through the `customTheme`. -```json +```json title=".opencode.json" { "tui": { "theme": "custom", @@ -49,23 +51,25 @@ You can define your own custom theme by setting the `theme` to `"custom"` and pr } ``` -#### Color Definition Formats +#### Color keys -Custom theme colors support two formats: +You can define any of the following color keys in your `customTheme`. -1. **Simple Hex String**: A single hex color string (e.g., `"#aabbcc"`) that will be used for both light and dark terminal backgrounds. +| 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. | -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. +You don't need to define all the color keys. Any undefined colors will fall back to the default `opencode` theme colors. -#### Available Color Keys +#### Color definitions -You can define any of the following color keys in your `customTheme`: +Color keys can take: -- 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. +1. **Hex string**: A single hex color string, like `"#aabbcc"`, that'll be used for both light and dark terminal backgrounds. -You don't need to define all colors. Any undefined colors will fall back to the default "opencode" theme colors. +2. **Light and dark colors**: An object with `dark` and `light` hex colors that'll be set based on the terminal's background. -- cgit v1.2.3