mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 05:28:16 +00:00
Merge branch 'sst:dev' into feat/scroll-to-bottom-button
This commit is contained in:
commit
b4c2fcccf5
6 changed files with 176 additions and 66 deletions
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/package.json",
|
"$schema": "https://json.schemastore.org/package.json",
|
||||||
"version": "0.0.5", "name": "opencode",
|
"version": "0.0.5",
|
||||||
|
"name": "opencode",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -79,6 +79,8 @@ export const RunCommand = cmd({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isPiped = !process.stdout.isTTY
|
||||||
|
|
||||||
UI.empty()
|
UI.empty()
|
||||||
UI.println(UI.logo())
|
UI.println(UI.logo())
|
||||||
UI.empty()
|
UI.empty()
|
||||||
|
@ -90,8 +92,8 @@ export const RunCommand = cmd({
|
||||||
await Session.share(session.id)
|
await Session.share(session.id)
|
||||||
UI.println(
|
UI.println(
|
||||||
UI.Style.TEXT_INFO_BOLD +
|
UI.Style.TEXT_INFO_BOLD +
|
||||||
"~ https://opencode.ai/s/" +
|
"~ https://opencode.ai/s/" +
|
||||||
session.id.slice(-8),
|
session.id.slice(-8),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
UI.empty()
|
UI.empty()
|
||||||
|
@ -109,8 +111,8 @@ export const RunCommand = cmd({
|
||||||
UI.println(
|
UI.println(
|
||||||
color + `|`,
|
color + `|`,
|
||||||
UI.Style.TEXT_NORMAL +
|
UI.Style.TEXT_NORMAL +
|
||||||
UI.Style.TEXT_DIM +
|
UI.Style.TEXT_DIM +
|
||||||
` ${type.padEnd(7, " ")}`,
|
` ${type.padEnd(7, " ")}`,
|
||||||
"",
|
"",
|
||||||
UI.Style.TEXT_NORMAL + title,
|
UI.Style.TEXT_NORMAL + title,
|
||||||
)
|
)
|
||||||
|
@ -134,7 +136,7 @@ export const RunCommand = cmd({
|
||||||
part.toolInvocation.toolName,
|
part.toolInvocation.toolName,
|
||||||
UI.Style.TEXT_INFO_BOLD,
|
UI.Style.TEXT_INFO_BOLD,
|
||||||
]
|
]
|
||||||
printEvent(color, tool, metadata?.title || 'Unknown')
|
printEvent(color, tool, metadata?.title || "Unknown")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (part.type === "text") {
|
if (part.type === "text") {
|
||||||
|
@ -147,7 +149,8 @@ export const RunCommand = cmd({
|
||||||
printEvent(UI.Style.TEXT_NORMAL_BOLD, "Text", part.text)
|
printEvent(UI.Style.TEXT_NORMAL_BOLD, "Text", part.text)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await Session.chat({
|
|
||||||
|
const result = await Session.chat({
|
||||||
sessionID: session.id,
|
sessionID: session.id,
|
||||||
providerID,
|
providerID,
|
||||||
modelID,
|
modelID,
|
||||||
|
@ -158,8 +161,14 @@ export const RunCommand = cmd({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (isPiped) {
|
||||||
|
const match = result.parts.findLast((x) => x.type === "text")
|
||||||
|
if (match) process.stdout.write(match.text)
|
||||||
|
}
|
||||||
UI.empty()
|
UI.empty()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import { AuthCopilot } from "../auth/copilot"
|
||||||
import { ModelsDev } from "./models"
|
import { ModelsDev } from "./models"
|
||||||
import { NamedError } from "../util/error"
|
import { NamedError } from "../util/error"
|
||||||
import { Auth } from "../auth"
|
import { Auth } from "../auth"
|
||||||
import { TaskTool } from "../tool/task"
|
|
||||||
|
|
||||||
export namespace Provider {
|
export namespace Provider {
|
||||||
const log = Log.create({ service: "provider" })
|
const log = Log.create({ service: "provider" })
|
||||||
|
@ -411,7 +410,7 @@ export namespace Provider {
|
||||||
// MultiEditTool,
|
// MultiEditTool,
|
||||||
WriteTool,
|
WriteTool,
|
||||||
TodoWriteTool,
|
TodoWriteTool,
|
||||||
TaskTool,
|
// TaskTool,
|
||||||
TodoReadTool,
|
TodoReadTool,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ export default defineConfig({
|
||||||
sidebar: [
|
sidebar: [
|
||||||
"docs",
|
"docs",
|
||||||
"docs/cli",
|
"docs/cli",
|
||||||
|
"docs/rules",
|
||||||
"docs/config",
|
"docs/config",
|
||||||
"docs/models",
|
"docs/models",
|
||||||
"docs/themes",
|
"docs/themes",
|
||||||
|
|
74
packages/web/src/content/docs/docs/rules.mdx
Normal file
74
packages/web/src/content/docs/docs/rules.mdx
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
---
|
||||||
|
title: Rules
|
||||||
|
---
|
||||||
|
|
||||||
|
You can provide custom instructions to opencode by creating an `AGENTS.md` file. This is similar to `CLAUDE.md` or Cursor's rules. It contains instructions that will be included in the LLM's context to customize its behavior for your specific project.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Initialize
|
||||||
|
|
||||||
|
To create a new `AGENTS.md` file, you can run the `/init` command in opencode.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
You should commit your project's `AGENTS.md` file to Git.
|
||||||
|
:::
|
||||||
|
|
||||||
|
This will scan your project and all its contents to understand what the project is about and generate an `AGENTS.md` file with it. This helps opencode to navigate the project better.
|
||||||
|
|
||||||
|
If you have an existing `AGENTS.md` file, this will try to add to it.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
You can also just create this file manually. Here's an example of some things you can put into an `AGENTS.md` file.
|
||||||
|
|
||||||
|
```markdown title="AGENTS.md"
|
||||||
|
# SST v3 Monorepo Project
|
||||||
|
|
||||||
|
This is an SST v3 monorepo with TypeScript. The project uses bun workspaces for package management.
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
- `packages/` - Contains all workspace packages (functions, core, web, etc.)
|
||||||
|
- `infra/` - Infrastructure definitions split by service (storage.ts, api.ts, web.ts)
|
||||||
|
- `sst.config.ts` - Main SST configuration with dynamic imports
|
||||||
|
|
||||||
|
## Code Standards
|
||||||
|
- Use TypeScript with strict mode enabled
|
||||||
|
- Shared code goes in `packages/core/` with proper exports configuration
|
||||||
|
- Functions go in `packages/functions/`
|
||||||
|
- Infrastructure should be split into logical files in `infra/`
|
||||||
|
|
||||||
|
## Monorepo Conventions
|
||||||
|
- Import shared modules using workspace names: `@my-app/core/example`
|
||||||
|
```
|
||||||
|
|
||||||
|
We are adding project-specific instructions here and this will be shared across your team.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Types
|
||||||
|
|
||||||
|
opencode also supports reading the `AGENTS.md` file from multiple locations. And this serves different purposes.
|
||||||
|
|
||||||
|
### Project
|
||||||
|
|
||||||
|
The ones we have seen above, where the `AGENTS.md` is placed in the project root, are project-specific rules. These only apply when you are working in this directory or its sub-directories.
|
||||||
|
|
||||||
|
### Global
|
||||||
|
|
||||||
|
You can also have global rules in a `~/.config/opencode/AGENTS.md` file. This gets applied across all opencode sessions.
|
||||||
|
|
||||||
|
Since this isn't committed to Git or shared with your team, we recommend using this to specify any personal rules that the LLM should follow.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Precedence
|
||||||
|
|
||||||
|
So when opencode starts, it looks for:
|
||||||
|
|
||||||
|
1. **Local files** by traversing up from the current directory
|
||||||
|
2. **Global file** by checking `~/.config/opencode/AGENTS.md`
|
||||||
|
|
||||||
|
If you have both global and project-specific rules, opencode will combine them together.
|
|
@ -2,34 +2,96 @@
|
||||||
title: Themes
|
title: Themes
|
||||||
---
|
---
|
||||||
|
|
||||||
|
With opencode you can select from one of several built-in themes, use a theme that adapts to your terminal theme, or define your own custom theme.
|
||||||
|
|
||||||
|
By default, opencode uses our own `opencode` theme.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Built-in themes
|
||||||
|
|
||||||
|
opencode comes with several built-in themes.
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `system` | Adapts to your terminal's background color |
|
||||||
|
| `tokyonight` | Based on the Tokyonight theme |
|
||||||
|
| `everforest` | Based on the Everforest theme |
|
||||||
|
| `ayu` | Based on the Ayu dark theme |
|
||||||
|
| `catppuccin` | Based on the Catppuccin theme |
|
||||||
|
| `gruvbox` | Based on the Gruvbox theme |
|
||||||
|
| `kanagawa` | Based on the Kanagawa theme |
|
||||||
|
| `nord` | Based on the Nord theme |
|
||||||
|
| `matrix` | Hacker-style green on black theme |
|
||||||
|
| `one-dark` | Based on the Atom One Dark theme |
|
||||||
|
|
||||||
|
And more, we are constantly adding new themes.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## System theme
|
||||||
|
|
||||||
|
The `system` theme is designed to automatically adapt to your terminal's color scheme. Unlike traditional themes that use fixed colors, the _system_ theme:
|
||||||
|
|
||||||
|
- **Generates gray scale**: Creates a custom gray scale based on your terminal's background color, ensuring optimal contrast.
|
||||||
|
- **Uses ANSI colors**: Leverages standard ANSI colors (0-15) for syntax highlighting and UI elements, which respect your terminal's color palette.
|
||||||
|
- **Preserves terminal defaults**: Uses `none` for text and background colors to maintain your terminal's native appearance.
|
||||||
|
|
||||||
|
The system theme is for users who:
|
||||||
|
|
||||||
|
- Want opencode to match their terminal's appearance
|
||||||
|
- Use custom terminal color schemes
|
||||||
|
- Prefer a consistent look across all terminal applications
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Using a theme
|
||||||
|
|
||||||
|
You can select a theme by bringing up the theme select with the `/theme` command. Or you can specify it in your [config](/docs/config).
|
||||||
|
|
||||||
|
```json title="opencode.json" {3}
|
||||||
|
{
|
||||||
|
"$schema": "https://opencode.ai/config.json",
|
||||||
|
"theme": "tokyonight"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Custom themes
|
||||||
|
|
||||||
opencode supports a flexible JSON-based theme system that allows users to create and customize themes easily.
|
opencode supports a flexible JSON-based theme system that allows users to create and customize themes easily.
|
||||||
|
|
||||||
## Theme Loading Hierarchy
|
### Hierarchy
|
||||||
|
|
||||||
Themes are loaded from multiple directories in the following order (later directories override earlier ones):
|
Themes are loaded from multiple directories in the following order where later directories override earlier ones:
|
||||||
|
|
||||||
1. **Built-in themes** - Embedded in the binary
|
1. **Built-in themes** - These are embedded in the binary
|
||||||
2. **User config directory** - `~/.config/opencode/themes/*.json` (or `$XDG_CONFIG_HOME/opencode/themes/*.json`)
|
2. **User config directory** - Defined in `~/.config/opencode/themes/*.json` or `$XDG_CONFIG_HOME/opencode/themes/*.json`
|
||||||
3. **Project root directory** - `<project-root>/.opencode/themes/*.json`
|
3. **Project root directory** - Defined in the `<project-root>/.opencode/themes/*.json`
|
||||||
4. **Current working directory** - `./.opencode/themes/*.json`
|
4. **Current working directory** - Defined in `./.opencode/themes/*.json`
|
||||||
|
|
||||||
If multiple directories contain a theme with the same name, the theme from the directory with higher priority will be used.
|
If multiple directories contain a theme with the same name, the theme from the directory with higher priority will be used.
|
||||||
|
|
||||||
## Creating a Custom Theme
|
### Creating a theme
|
||||||
|
|
||||||
To create a custom theme, create a JSON file in one of the theme directories:
|
To create a custom theme, create a JSON file in one of the theme directories.
|
||||||
|
|
||||||
|
For user-wide themes:
|
||||||
|
|
||||||
```bash no-frame
|
```bash no-frame
|
||||||
# For user-wide themes
|
|
||||||
mkdir -p ~/.config/opencode/themes
|
mkdir -p ~/.config/opencode/themes
|
||||||
vim ~/.config/opencode/themes/my-theme.json
|
vim ~/.config/opencode/themes/my-theme.json
|
||||||
|
```
|
||||||
|
|
||||||
# For project-specific themes
|
And for project-specific themes.
|
||||||
|
|
||||||
|
```bash no-frame
|
||||||
mkdir -p .opencode/themes
|
mkdir -p .opencode/themes
|
||||||
vim .opencode/themes/my-theme.json
|
vim .opencode/themes/my-theme.json
|
||||||
```
|
```
|
||||||
|
|
||||||
## Theme JSON Format
|
### JSON format
|
||||||
|
|
||||||
Themes use a flexible JSON format with support for:
|
Themes use a flexible JSON format with support for:
|
||||||
|
|
||||||
|
@ -37,11 +99,13 @@ Themes use a flexible JSON format with support for:
|
||||||
- **ANSI colors**: `3` (0-255)
|
- **ANSI colors**: `3` (0-255)
|
||||||
- **Color references**: `"primary"` or custom definitions
|
- **Color references**: `"primary"` or custom definitions
|
||||||
- **Dark/light variants**: `{"dark": "#000", "light": "#fff"}`
|
- **Dark/light variants**: `{"dark": "#000", "light": "#fff"}`
|
||||||
- **No color**: `"none"` - Uses the terminal's default color (transparent)
|
- **No color**: `"none"` - Uses the terminal's default color or transparent
|
||||||
|
|
||||||
### Example Theme
|
### Example
|
||||||
|
|
||||||
```json no-frame
|
Here's an example of a custom theme:
|
||||||
|
|
||||||
|
```json title="my-theme.json"
|
||||||
{
|
{
|
||||||
"$schema": "https://opencode.ai/theme.json",
|
"$schema": "https://opencode.ai/theme.json",
|
||||||
"defs": {
|
"defs": {
|
||||||
|
@ -267,51 +331,13 @@ Themes use a flexible JSON format with support for:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Color Definitions
|
### Color definitions
|
||||||
|
|
||||||
The `defs` section (optional) allows you to define reusable colors that can be referenced in the theme.
|
The `defs` section is optional and it allows you to define reusable colors that can be referenced in the theme.
|
||||||
|
|
||||||
### Using "none" for Terminal Defaults
|
### Terminal defaults
|
||||||
|
|
||||||
The special value `\"none\"` can be used for any color to inherit the terminal's default color. This is particularly useful for creating themes that blend seamlessly with your terminal's color scheme:
|
The special value `\"none\"` can be used for any color to inherit the terminal's default color. This is particularly useful for creating themes that blend seamlessly with your terminal's color scheme:
|
||||||
|
|
||||||
- `\"text\": \"none\"` - Uses terminal's default foreground color
|
- `"text": "none"` - Uses terminal's default foreground color
|
||||||
- `\"background\": \"none\"` - Uses terminal's default background color
|
- `"background": "none"` - Uses terminal's default background color
|
||||||
|
|
||||||
## The System Theme
|
|
||||||
|
|
||||||
The `system` theme is designed to automatically adapt to your terminal's color scheme. Unlike traditional themes that use fixed colors, the system theme:
|
|
||||||
|
|
||||||
- **Generates gray scale**: Creates a custom gray scale based on your terminal's background color, ensuring optimal contrast
|
|
||||||
- **Uses ANSI colors**: Leverages standard ANSI colors (0-15) for syntax highlighting and UI elements, which respect your terminal's color palette
|
|
||||||
- **Preserves terminal defaults**: Uses `none` for text and background colors to maintain your terminal's native appearance
|
|
||||||
|
|
||||||
The system theme is ideal for users who:
|
|
||||||
- Want opencode to match their terminal's appearance
|
|
||||||
- Use custom terminal color schemes
|
|
||||||
- Prefer a consistent look across all terminal applications
|
|
||||||
|
|
||||||
## Built-in Themes
|
|
||||||
|
|
||||||
opencode comes with several built-in themes:
|
|
||||||
- `system` - Default theme that dynamically adapts to your terminal's background color
|
|
||||||
- `tokyonight` - Tokyonight theme
|
|
||||||
- `everforest` - Everforest theme
|
|
||||||
- `ayu` - Ayu dark theme
|
|
||||||
- `catppuccin` - Catppuccin theme
|
|
||||||
- `gruvbox` - Gruvbox theme
|
|
||||||
- `kanagawa` - Kanagawa theme
|
|
||||||
- `nord` - Nord theme
|
|
||||||
- `matrix` - Hacker-style green on black theme
|
|
||||||
- `one-dark` - Atom One Dark inspired theme
|
|
||||||
|
|
||||||
## Using a Theme
|
|
||||||
|
|
||||||
To use a theme, set it in your opencode configuration or select it from the theme dialog in the TUI.
|
|
||||||
|
|
||||||
```json title="opencode.json" {3}
|
|
||||||
{
|
|
||||||
"$schema": "https://opencode.ai/config.json",
|
|
||||||
"theme": "tokyonight"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue