mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-19 18:14:24 +00:00
2.9 KiB
2.9 KiB
OpenCode
TODO
Open source AI coding agent.
TL;DR
Setup
# Install
brew install 'anomalyco/tap/opencode' # or 'opencode'
docker run -it --rm 'ghcr.io/anomalyco/opencode'
mise use -g 'opencode'
nix run 'nixpkgs#opencode'
npm i -g 'opencode-ai@latest'
pacman -S 'opencode'
paru -S 'opencode-bin'
# Desktop app
brew install --cask 'opencode-desktop'
Configure OpenCode using opencode.json (or .jsonc) configuration files.
Configuration files are merged, not replaced. Settings from more specific ones override those of the same name in less
specific ones.
| Scope | Location | Summary |
|---|---|---|
| Remote | .well-known/opencode |
organizational defaults |
| Global | ~/.config/opencode/opencode.json |
user preferences |
| Custom | OPENCODE_CONFIG environment variable |
custom overrides |
| Project | opencode.json in the project's directory |
project-specific settings |
| Agent | .opencode directories |
agents, commands, plugins |
| Inline | OPENCODE_CONFIG_CONTENT environment variables |
runtime overrides |
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"llama2": {
"name": "Llama 2"
}
}
}
}
}
Usage
# Start in interactive mode.
opencode
opencode 'path/to/directory'
# List available models.
opencode models
opencode models 'anthropic'
# Update the cashed models list.
opencode models --refresh
# Run tasks in headless mode.
opencode run "Explain how closures work in JavaScript"
# Start a headless server.
opencode serve
# Attach to headless servers.
opencode run --attach 'http://localhost:4096' "Explain async/await in JavaScript"
# List existing agents.
opencode agent list