OpenCode

OpenCode is an open-source AI coding agent that runs in the terminal and works directly with local repositories.

Installation

OpenCode is installed through the opencode Ansible role.

ansible-playbook -i inventory -K playbooks/lab-stack.yml --tags opencode

The role also installs CLI tools commonly used when exploring and working with repositories: ripgrep, fd-find, jq, gh, git-delta, fzf, bat, ShellCheck, and tree.

The role also installs the OpenCode Voice plugin in the target user’s global OpenCode configuration. Restart OpenCode after installation or an update. On first use, choose a local transcription model; its runtime and model files are downloaded automatically.

✅ Check

opencode --version
rg --version
fd --version
jq --version
gh --version
delta --version
fzf --version
bat --version
shellcheck --version
tree --version

Authentication

Authentication is configured manually and is not managed by Ansible.

Launch OpenCode:

opencode

Inside OpenCode, enter /connect, select a provider, and follow its authentication prompts. Providers may use an API key or an account sign-in flow. Then run /models to select an available model. See the OpenCode provider guide for provider-specific instructions.

OpenCode stores credentials locally; do not commit credentials or local authentication files to this repository.

Voice input

Press Ctrl+R to start recording, then press it again to stop and transcribe into the prompt. Use /voice-settings to change the model, microphone, language, and recording hotkey. Voice transcription runs locally.

Working with repositories

Launch OpenCode from the repository root:

cd ~/repos/colrev
opencode

Use Plan mode to review proposed changes before allowing edits.

Review modifications using:

git status
git diff

Updates

OpenCode is managed by the workstation Ansible role. The regular configuration run ensures it is installed.

To upgrade OpenCode explicitly:

opencode upgrade

Restart OpenCode after upgrading so it reloads the installed CLI and plugins.

References