From 87fcf08ed05800285f0ca305a0fc8dfc77b84da5 Mon Sep 17 00:00:00 2001 From: ogormans-deptstack Date: Wed, 18 Mar 2026 12:21:25 +0000 Subject: [PATCH 1/5] feat(opencode): add installer for AI coding assistant Adds opencode (anomalyco/opencode) - the open source coding agent. Changes from closed PR #1062: - Points to anomalyco/opencode (active fork, 124K stars) instead of archived opencode-ai/opencode - README clarifies Ollama integration as optional (not hidden) - Adds Windows support (install.ps1) - Filters CLI binaries only (excludes desktop/electron/baseline/musl) Homepage: https://github.com/anomalyco/opencode License: Apache-2.0 --- opencode/README.md | 163 +++++++++++++++++++++++++++++++++++++++++++ opencode/install.ps1 | 54 ++++++++++++++ opencode/install.sh | 39 +++++++++++ opencode/releases.js | 50 +++++++++++++ 4 files changed, 306 insertions(+) create mode 100644 opencode/README.md create mode 100644 opencode/install.ps1 create mode 100644 opencode/install.sh create mode 100644 opencode/releases.js diff --git a/opencode/README.md b/opencode/README.md new file mode 100644 index 000000000..2cb43f757 --- /dev/null +++ b/opencode/README.md @@ -0,0 +1,163 @@ +--- +title: opencode +homepage: https://github.com/anomalyco/opencode +tagline: | + opencode: The open source coding agent. +--- + +To update or switch versions, run `webi opencode@stable` (or `@v1.2`, `@beta`, etc). + +### Files + +These are the files / directories that are created and/or modified with this +install: + +```text +~/.config/envman/PATH.env +~/.local/bin/opencode +~/.local/opt/opencode-VERSION/bin/opencode +~/.config/opencode/opencode.json +``` + +## Cheat Sheet + +> `opencode` is a terminal-based AI coding assistant. It connects to LLM +> providers (Anthropic, OpenAI, Google, local models via Ollama) and gives you +> an interactive TUI for writing, reviewing, and refactoring code — with full +> tool use, file editing, and shell access. + +### How to Get Started + +1. Set an API key for your preferred provider: + + ```sh + export ANTHROPIC_API_KEY="sk-ant-..." + # or + export OPENAI_API_KEY="sk-..." + ``` + +2. Launch opencode in your project directory: + + ```sh + cd ~/your-project + opencode + ``` + + opencode starts a TUI where you can chat, edit files, run commands, and + navigate your codebase — all from the terminal. + +### How to Configure Providers + +opencode supports multiple LLM providers simultaneously. Add them to +`~/.config/opencode/opencode.json`: + +```json +{ + "$schema": "https://opencode.ai/config.json", + "provider": { + "anthropic": {}, + "openai": {}, + "google": {} + }, + "model": { + "big": "anthropic/claude-sonnet-4-5-20250514", + "small": "anthropic/claude-haiku-4-5-20250514" + } +} +``` + +Anthropic and OpenAI providers read from `ANTHROPIC_API_KEY` and +`OPENAI_API_KEY` environment variables respectively. + +### How to Use with Local Models (Optional) + +If you prefer fully local AI coding with no API calls, you can use +[ollama](../ollama/) (also available via webi): + +```sh +# Install ollama separately (optional) +curl https://webi.sh/ollama | sh +source ~/.config/envman/PATH.env +``` + +1. Start the `ollama` server and pull a model: + + ```sh + ollama serve & + ollama pull qwen2.5-coder:14b + ``` + +2. Configure opencode to use the local model: + + ```json + { + "$schema": "https://opencode.ai/config.json", + "provider": { + "ollama": { + "models": { + "qwen-coder": { + "id": "qwen2.5-coder:14b", + "name": "Qwen 2.5 Coder 14B" + } + } + } + }, + "model": { + "big": "ollama/qwen-coder", + "small": "ollama/qwen-coder" + } + } + ``` + +3. Launch opencode — it will connect to your local Ollama instance: + + ```sh + opencode + ``` + +### How to Use Plugins (oh-my-opencode) + +opencode supports plugins for multi-agent orchestration, custom tools, and +extended workflows. +[oh-my-opencode](https://github.com/code-yeongyu/oh-my-opencode) is a plugin +that adds specialized agents, model routing, and skill-based delegation: + +1. Install the plugin: + + ```sh + cd ~/.config/opencode + npm install oh-my-opencode + ``` + +2. Add it to your config: + + ```json + { + "$schema": "https://opencode.ai/config.json", + "plugin": ["oh-my-opencode"] + } + ``` + +3. Configure agents in `~/.config/opencode/oh-my-opencode.json`: + + ```json + { + "agents": { + "oracle": { + "description": "Read-only high-IQ consultant for architecture", + "model": "anthropic/claude-sonnet-4-5-20250514", + "tools": ["Read", "Grep", "Glob", "WebFetch"] + } + } + } + ``` + +### Useful Key Bindings + +| Key | Action | +| -------- | -------------------------------- | +| `Enter` | Send message | +| `Ctrl+E` | Open editor for multi-line input | +| `Ctrl+C` | Cancel current operation | +| `Ctrl+L` | Clear screen | +| `/` | Slash commands | diff --git a/opencode/install.ps1 b/opencode/install.ps1 new file mode 100644 index 000000000..f4adfec8f --- /dev/null +++ b/opencode/install.ps1 @@ -0,0 +1,54 @@ +#!/usr/bin/env pwsh + +################## +# Install opencode # +################## + +# Every package should define these variables +$pkg_cmd_name = "opencode" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\opencode.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\opencode-v$Env:WEBI_VERSION\bin\opencode.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\opencode-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\opencode-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null +$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) { + Write-Output "Downloading opencode from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & Move-Item "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) { + Write-Output "Installing opencode" + + # TODO: create package-specific temp directory + # Enter tmp + Push-Location .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\opencode-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\opencode.exe" -Recurse -ErrorAction Ignore + + # Extract to opencode-v$Env:WEBI_VERSION + Write-Output "Unpacking $pkg_download" + & tar xf "$pkg_download" + + # Move into place + Write-Output "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force | Out-Null + Move-Item -Path ".\opencode.exe" -Destination "$pkg_src_bin" + + # Exit tmp + Pop-Location +} + +Write-Output "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | Out-Null +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse diff --git a/opencode/install.sh b/opencode/install.sh new file mode 100644 index 000000000..5e9b81fde --- /dev/null +++ b/opencode/install.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# shellcheck disable=SC2034 + +set -e +set -u + +__init_opencode() { + + #################### + # Install opencode # + #################### + + pkg_cmd_name="opencode" + + pkg_dst_cmd="$HOME/.local/bin/opencode" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/opencode-v$WEBI_VERSION/bin/opencode" + pkg_src_dir="$HOME/.local/opt/opencode-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" + + pkg_install() { + # ~/.local/opt/opencode-v1.2.27/bin/ + mkdir -p "$(dirname "$pkg_src_cmd")" + + # mv ./opencode ~/.local/opt/opencode-v1.2.27/bin/opencode + mv ./opencode "$pkg_src_cmd" + } + + pkg_get_current_version() { + # 'opencode --version' outputs version number + opencode --version 2>/dev/null | + head -n 1 | + cut -d' ' -f1 + } + +} + +__init_opencode diff --git a/opencode/releases.js b/opencode/releases.js new file mode 100644 index 000000000..5224e5ce5 --- /dev/null +++ b/opencode/releases.js @@ -0,0 +1,50 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'anomalyco'; +var repo = 'opencode'; + +let Releases = module.exports; + +Releases.latest = async function () { + let all = await github(null, owner, repo); + + // Filter to CLI-only releases (exclude desktop, electron, baseline, musl variants) + all.releases = all.releases.filter(function (rel) { + return rel.version && !rel.version.includes('nightly'); + }); + + all.releases.forEach(function (rel) { + // Filter assets to CLI binaries only + rel.assets = (rel.assets || []).filter(function (asset) { + let name = asset.name; + // Keep only CLI binaries: opencode-{os}-{arch}.{tar.gz|zip} + // Exclude: desktop, electron, baseline, musl, auto-update manifests, packages + return ( + name.match(/^opencode-(darwin|linux|windows)-/) && + !name.includes('desktop') && + !name.includes('electron') && + !name.includes('baseline') && + !name.includes('musl') && + (name.endsWith('.tar.gz') || name.endsWith('.zip')) + ); + }); + }); + + return all; +}; + +Releases.sample = async function () { + let normalize = require('../_webi/normalize.js'); + let all = await Releases.latest(); + all = normalize(all); + all.releases = all.releases.slice(0, 10); + return all; +}; + +if (module === require.main) { + (async function () { + let samples = await Releases.sample(); + console.info(JSON.stringify(samples, null, 2)); + })(); +} From 55c25113d1919bad4808de9b6dca7fb9506bdea5 Mon Sep 17 00:00:00 2001 From: ogormans-deptstack Date: Wed, 18 Mar 2026 22:07:53 +0000 Subject: [PATCH 2/5] docs(opencode): add SKILL.md for agent documentation Add comprehensive agent-focused documentation including: - When to use opencode vs alternatives - Multi-provider configuration guide - Plugin system (oh-my-opencode) setup - Local model integration with Ollama - Common workflows and integration patterns - Comparison table with Cursor and GitHub Copilot Proactive addition based on crush PR feedback. --- opencode/SKILL.md | 268 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 268 insertions(+) create mode 100644 opencode/SKILL.md diff --git a/opencode/SKILL.md b/opencode/SKILL.md new file mode 100644 index 000000000..4015899b3 --- /dev/null +++ b/opencode/SKILL.md @@ -0,0 +1,268 @@ +--- +name: opencode +description: Terminal-based AI coding assistant with multi-provider LLM support, file editing, shell access, and plugin system. Use when the user wants AI pair programming in the terminal. +homepage: https://github.com/anomalyco/opencode +--- + +# OpenCode + +Terminal-based AI coding assistant that connects to multiple LLM providers (Anthropic, OpenAI, Google, local Ollama) with an interactive TUI for writing, reviewing, and refactoring code. + +## When to Use + +- User wants AI pair programming directly in the terminal +- User needs to switch between multiple LLM providers mid-session +- User wants full tool use (file editing, shell commands, grep, read) +- User prefers terminal UIs over web-based interfaces +- User wants plugin-based multi-agent orchestration (oh-my-opencode) +- User wants local-first AI coding with Ollama (no API costs) + +## Installation + +```sh +curl https://webi.sh/opencode | sh +source ~/.config/envman/PATH.env +``` + +## Quick Start + +1. **Set API key** (Anthropic, OpenAI, or Google): + ```sh + export ANTHROPIC_API_KEY="sk-ant-..." + # or + export OPENAI_API_KEY="sk-..." + ``` + +2. **Launch in project directory**: + ```sh + cd ~/your-project + opencode + ``` + +3. **Start coding** — opencode gives you a TUI where you can chat, edit files, run commands, and navigate your codebase. + +## Configuration + +### Multi-Provider Setup + +Edit `~/.config/opencode/opencode.json`: + +```json +{ + "$schema": "https://opencode.ai/config.json", + "provider": { + "anthropic": {}, + "openai": {}, + "google": {} + }, + "model": { + "big": "anthropic/claude-sonnet-4-5-20250514", + "small": "anthropic/claude-haiku-4-5-20250514" + } +} +``` + +### Local Models with Ollama (Optional) + +For offline AI coding with no API calls: + +```sh +# Install Ollama separately +curl https://webi.sh/ollama | sh + +# Start server and pull model +ollama serve & +ollama pull qwen2.5-coder:14b +``` + +Configure opencode to use local model: + +```json +{ + "$schema": "https://opencode.ai/config.json", + "provider": { + "ollama": { + "models": { + "qwen-coder": { + "id": "qwen2.5-coder:14b", + "name": "Qwen 2.5 Coder 14B" + } + } + } + }, + "model": { + "big": "ollama/qwen-coder", + "small": "ollama/qwen-coder" + } +} +``` + +## Plugin System (oh-my-opencode) + +Adds specialized agents, model routing, and skill-based delegation: + +```sh +cd ~/.config/opencode +npm install oh-my-opencode +``` + +Configure agents in `~/.config/opencode/oh-my-opencode.json`: + +```json +{ + "agents": { + "oracle": { + "description": "Read-only high-IQ consultant for architecture", + "model": "anthropic/claude-sonnet-4-5-20250514", + "tools": ["Read", "Grep", "Glob", "WebFetch"] + }, + "reviewer": { + "description": "Code review specialist", + "model": "anthropic/claude-sonnet-4-5-20250514", + "tools": ["Read", "Grep", "Bash"] + } + } +} +``` + +## Key Features + +| Feature | Description | +|---------|-------------| +| **Multi-Provider** | Switch between Anthropic, OpenAI, Google, Ollama mid-session | +| **Full Tool Access** | Read/write files, execute shell commands, search codebase | +| **Plugin System** | Extend with custom agents and workflows | +| **Terminal Native** | Runs in any terminal with full keyboard navigation | +| **Context-Aware** | Maintains conversation context across file edits | + +## Common Workflows + +### Code Review +```sh +opencode +# In TUI: "Review the changes in src/auth.ts and suggest improvements" +``` + +### Implement Feature +```sh +opencode +# In TUI: "Add user authentication with JWT tokens" +# OpenCode will read files, write code, and execute tests +``` + +### Debug Issue +```sh +opencode +# In TUI: "Why is the API returning 500 errors?" +# OpenCode will read logs, check code, and suggest fixes +``` + +### Refactor +```sh +opencode +# In TUI: "Refactor the user service to use async/await instead of promises" +``` + +## Integration with Other Tools + +### With Ollama (Local Models) +Requires `ollama` to be running: +```sh +ollama serve & # Keep running in background +opencode # Will connect to local Ollama +``` + +### With Git +OpenCode is git-aware and can: +- Read diffs +- Suggest commit messages +- Review changes before commit +- Create branches + +### With Testing Frameworks +OpenCode can run tests directly: +```sh +opencode +# In TUI: "Run the test suite and fix any failures" +``` + +## Files Created + +```text +~/.config/envman/PATH.env # PATH configuration +~/.local/bin/opencode # Symlink to versioned binary +~/.local/opt/opencode-VERSION/ # Installed binary +~/.config/opencode/opencode.json # Configuration +~/.config/opencode/oh-my-opencode.json # Plugin config (if installed) +``` + +## Key Bindings + +| Key | Action | +|-----|--------| +| `Enter` | Send message | +| `Ctrl+E` | Open editor for multi-line input | +| `Ctrl+C` | Cancel current operation | +| `Ctrl+L` | Clear screen | +| `/` | Slash commands | + +## Comparison with Alternatives + +| Tool | OpenCode | Cursor | GitHub Copilot | +|------|----------|--------|----------------| +| **Interface** | Terminal TUI | VS Code fork | IDE extension | +| **Providers** | Multi (Anthropic, OpenAI, Google, Ollama) | OpenAI only | GitHub's models | +| **Local Models** | ✅ Via Ollama | ❌ | ❌ | +| **Plugins** | ✅ oh-my-opencode | Limited | Limited | +| **Shell Access** | ✅ Full | ✅ Terminal | ❌ | +| **Offline** | ✅ With Ollama | ❌ | ❌ | + +## Best Practices + +1. **Start with cloud LLMs** — Test with Anthropic/OpenAI before switching to local models +2. **Use plugins for complex workflows** — oh-my-opencode adds multi-agent coordination +3. **Configure model tiers** — Use "big" model for complex tasks, "small" for quick edits +4. **Keep Ollama running** — If using local models, keep `ollama serve` in background +5. **Git integration** — Run opencode from git repo root for best context awareness + +## Troubleshooting + +**OpenCode won't start:** +```sh +# Check if binary is in PATH +which opencode + +# Verify configuration +cat ~/.config/opencode/opencode.json +``` + +**API key not working:** +```sh +# Verify environment variable is set +echo $ANTHROPIC_API_KEY + +# Make sure to export, not just set +export ANTHROPIC_API_KEY="sk-ant-..." +``` + +**Ollama connection failed:** +```sh +# Check if Ollama is running +curl http://localhost:11434/api/version + +# Start Ollama if needed +ollama serve & +``` + +## Resources + +- GitHub: https://github.com/anomalyco/opencode +- Plugin System: https://github.com/code-yeongyu/oh-my-opencode +- Model Options: https://opencode.ai/models +- Configuration Schema: https://opencode.ai/config.json + +## Related Webi Installers + +- `ollama` — Local LLM server for offline AI coding +- `node` — Required for installing plugins (oh-my-opencode) +- `git` — Version control integration From 38f16f371c6a6df5156afc51ef04f4dfc50e50d6 Mon Sep 17 00:00:00 2001 From: ogormans-deptstack Date: Thu, 19 Mar 2026 09:11:44 +0000 Subject: [PATCH 3/5] fix(opencode): filter out .yml files and include musl builds - Remove .yml/.yaml file filtering (auto-update manifests) - Include musl builds (webi handles both gnu and musl) - Addresses feedback from @detox-24 --- opencode/releases.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/opencode/releases.js b/opencode/releases.js index 5224e5ce5..87b24afea 100644 --- a/opencode/releases.js +++ b/opencode/releases.js @@ -19,13 +19,15 @@ Releases.latest = async function () { rel.assets = (rel.assets || []).filter(function (asset) { let name = asset.name; // Keep only CLI binaries: opencode-{os}-{arch}.{tar.gz|zip} - // Exclude: desktop, electron, baseline, musl, auto-update manifests, packages + // Exclude: desktop, electron, baseline, .yml manifests, auto-update files, packages + // Include: musl builds (webi handles both gnu and musl) return ( name.match(/^opencode-(darwin|linux|windows)-/) && !name.includes('desktop') && !name.includes('electron') && !name.includes('baseline') && - !name.includes('musl') && + !name.endsWith('.yml') && + !name.endsWith('.yaml') && (name.endsWith('.tar.gz') || name.endsWith('.zip')) ); }); From ecbbc2489a840902d1772e18444aff748a0e0901 Mon Sep 17 00:00:00 2001 From: ogormans-deptstack Date: Fri, 20 Mar 2026 19:46:24 +0000 Subject: [PATCH 4/5] fix(opencode): fix releases.js filtering, polish installer for merge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - releases.js: fix dead code path — github.js flattens to asset entries, not nested release.assets. Rewrote to filter all.releases directly. Now correctly returns only CLI binaries (excludes desktop/electron apps, .yml manifests, .json metadata, baseline builds, packages, signatures). - install.ps1: clean up uppercase IF→if, remove TODO comment, fix indentation to match _example/install.ps1 template exactly. - install.sh: simplify pkg_get_current_version (remove unnecessary cut). - README.md: rewrite to webi cheat-sheet style (~100 lines). Riff on oh-my-opencode's config simplicity — one plugin line, providers, done. - SKILL.md: trim from 268→110 lines, apply prettier formatting. - test/install.sh: add opencode to all 3 test manifest lists. Testing: - releases.js: verified 10 normalized releases (darwin/linux/windows, arm64/amd64, including musl variants) - install.ps1: Docker test (pwsh alpine + real Windows zip) ALL PASSED - shellcheck: clean - shfmt: compliant - prettier: formatted --- opencode/README.md | 165 ++++++++++++------------------- opencode/SKILL.md | 230 ++++++++----------------------------------- opencode/install.ps1 | 29 +++--- opencode/install.sh | 42 ++++---- opencode/releases.js | 32 +++--- test/install.sh | 2 + 6 files changed, 152 insertions(+), 348 deletions(-) diff --git a/opencode/README.md b/opencode/README.md index 2cb43f757..d63d7b602 100644 --- a/opencode/README.md +++ b/opencode/README.md @@ -2,10 +2,11 @@ title: opencode homepage: https://github.com/anomalyco/opencode tagline: | - opencode: The open source coding agent. + opencode: A terminal-based AI coding agent with multi-provider LLM support. --- -To update or switch versions, run `webi opencode@stable` (or `@v1.2`, `@beta`, etc). +To update or switch versions, run `webi opencode@stable` (or `@v1.2`, `@beta`, +etc). ### Files @@ -21,43 +22,34 @@ install: ## Cheat Sheet -> `opencode` is a terminal-based AI coding assistant. It connects to LLM -> providers (Anthropic, OpenAI, Google, local models via Ollama) and gives you -> an interactive TUI for writing, reviewing, and refactoring code — with full -> tool use, file editing, and shell access. +> `opencode` is an AI coding agent that runs in the terminal. It connects to LLM +> providers (Anthropic, OpenAI, Google, or local models via Ollama) and gives +> you an interactive TUI with full tool use — file editing, shell commands, and +> codebase navigation. ### How to Get Started -1. Set an API key for your preferred provider: +Set an API key and launch in your project directory: - ```sh - export ANTHROPIC_API_KEY="sk-ant-..." - # or - export OPENAI_API_KEY="sk-..." - ``` - -2. Launch opencode in your project directory: - - ```sh - cd ~/your-project - opencode - ``` +```sh +export ANTHROPIC_API_KEY="sk-ant-..." +cd ~/your-project +opencode +``` - opencode starts a TUI where you can chat, edit files, run commands, and - navigate your codebase — all from the terminal. +opencode starts a TUI where you can chat, edit files, run commands, and navigate +your codebase. ### How to Configure Providers -opencode supports multiple LLM providers simultaneously. Add them to -`~/.config/opencode/opencode.json`: +Add providers to `~/.config/opencode/opencode.json`: ```json { "$schema": "https://opencode.ai/config.json", "provider": { "anthropic": {}, - "openai": {}, - "google": {} + "openai": {} }, "model": { "big": "anthropic/claude-sonnet-4-5-20250514", @@ -66,91 +58,56 @@ opencode supports multiple LLM providers simultaneously. Add them to } ``` -Anthropic and OpenAI providers read from `ANTHROPIC_API_KEY` and -`OPENAI_API_KEY` environment variables respectively. +Anthropic reads `ANTHROPIC_API_KEY`, OpenAI reads `OPENAI_API_KEY`. + +### How to Use Plugins + +opencode supports plugins for extended workflows. +[oh-my-opencode](https://github.com/code-yeongyu/oh-my-opencode) adds +multi-agent orchestration, model routing, and specialized skills — the entire +plugin system fits in a single config line: + +```json +{ + "$schema": "https://opencode.ai/config.json", + "plugin": ["oh-my-opencode@latest"], + "provider": { + "anthropic": {} + } +} +``` + +That's it. One plugin, your providers, done. The plugin handles agent +definitions, skill loading, and model routing automatically. -### How to Use with Local Models (Optional) +### How to Use with Local Models -If you prefer fully local AI coding with no API calls, you can use -[ollama](../ollama/) (also available via webi): +Install [ollama](../ollama/) (also available via webi), then configure opencode: ```sh -# Install ollama separately (optional) -curl https://webi.sh/ollama | sh -source ~/.config/envman/PATH.env +webi ollama +ollama serve & +ollama pull qwen2.5-coder:14b ``` -1. Start the `ollama` server and pull a model: - - ```sh - ollama serve & - ollama pull qwen2.5-coder:14b - ``` - -2. Configure opencode to use the local model: - - ```json - { - "$schema": "https://opencode.ai/config.json", - "provider": { - "ollama": { - "models": { - "qwen-coder": { - "id": "qwen2.5-coder:14b", - "name": "Qwen 2.5 Coder 14B" - } - } - } - }, - "model": { - "big": "ollama/qwen-coder", - "small": "ollama/qwen-coder" - } - } - ``` - -3. Launch opencode — it will connect to your local Ollama instance: - - ```sh - opencode - ``` - -### How to Use Plugins (oh-my-opencode) - -opencode supports plugins for multi-agent orchestration, custom tools, and -extended workflows. -[oh-my-opencode](https://github.com/code-yeongyu/oh-my-opencode) is a plugin -that adds specialized agents, model routing, and skill-based delegation: - -1. Install the plugin: - - ```sh - cd ~/.config/opencode - npm install oh-my-opencode - ``` - -2. Add it to your config: - - ```json - { - "$schema": "https://opencode.ai/config.json", - "plugin": ["oh-my-opencode"] - } - ``` - -3. Configure agents in `~/.config/opencode/oh-my-opencode.json`: - - ```json - { - "agents": { - "oracle": { - "description": "Read-only high-IQ consultant for architecture", - "model": "anthropic/claude-sonnet-4-5-20250514", - "tools": ["Read", "Grep", "Glob", "WebFetch"] - } - } - } - ``` +```json +{ + "$schema": "https://opencode.ai/config.json", + "provider": { + "ollama": { + "npm": "@ai-sdk/openai-compatible", + "options": { + "baseURL": "http://127.0.0.1:11434/v1" + }, + "models": { + "qwen2.5-coder:14b": { + "name": "Qwen 2.5 Coder 14B (local)" + } + } + } + } +} +``` ### Useful Key Bindings diff --git a/opencode/SKILL.md b/opencode/SKILL.md index 4015899b3..9a8fabd49 100644 --- a/opencode/SKILL.md +++ b/opencode/SKILL.md @@ -1,19 +1,22 @@ --- name: opencode -description: Terminal-based AI coding assistant with multi-provider LLM support, file editing, shell access, and plugin system. Use when the user wants AI pair programming in the terminal. +description: + Terminal-based AI coding agent with multi-provider LLM support, file editing, + shell access, and plugin system. Use when the user wants AI pair programming + in the terminal. homepage: https://github.com/anomalyco/opencode --- # OpenCode -Terminal-based AI coding assistant that connects to multiple LLM providers (Anthropic, OpenAI, Google, local Ollama) with an interactive TUI for writing, reviewing, and refactoring code. +Terminal-based AI coding agent that connects to multiple LLM providers +(Anthropic, OpenAI, Google, local Ollama) with an interactive TUI for writing, +reviewing, and refactoring code. ## When to Use - User wants AI pair programming directly in the terminal -- User needs to switch between multiple LLM providers mid-session -- User wants full tool use (file editing, shell commands, grep, read) -- User prefers terminal UIs over web-based interfaces +- User needs full tool use (file editing, shell commands, grep, read) - User wants plugin-based multi-agent orchestration (oh-my-opencode) - User wants local-first AI coding with Ollama (no API costs) @@ -26,25 +29,21 @@ source ~/.config/envman/PATH.env ## Quick Start -1. **Set API key** (Anthropic, OpenAI, or Google): +1. **Set API key**: + ```sh export ANTHROPIC_API_KEY="sk-ant-..." - # or - export OPENAI_API_KEY="sk-..." ``` 2. **Launch in project directory**: + ```sh cd ~/your-project opencode ``` -3. **Start coding** — opencode gives you a TUI where you can chat, edit files, run commands, and navigate your codebase. - ## Configuration -### Multi-Provider Setup - Edit `~/.config/opencode/opencode.json`: ```json @@ -52,8 +51,7 @@ Edit `~/.config/opencode/opencode.json`: "$schema": "https://opencode.ai/config.json", "provider": { "anthropic": {}, - "openai": {}, - "google": {} + "openai": {} }, "model": { "big": "anthropic/claude-sonnet-4-5-20250514", @@ -62,207 +60,65 @@ Edit `~/.config/opencode/opencode.json`: } ``` -### Local Models with Ollama (Optional) - -For offline AI coding with no API calls: - -```sh -# Install Ollama separately -curl https://webi.sh/ollama | sh - -# Start server and pull model -ollama serve & -ollama pull qwen2.5-coder:14b -``` - -Configure opencode to use local model: +### With oh-my-opencode Plugin ```json { "$schema": "https://opencode.ai/config.json", + "plugin": ["oh-my-opencode@latest"], "provider": { - "ollama": { - "models": { - "qwen-coder": { - "id": "qwen2.5-coder:14b", - "name": "Qwen 2.5 Coder 14B" - } - } - } - }, - "model": { - "big": "ollama/qwen-coder", - "small": "ollama/qwen-coder" + "anthropic": {} } } ``` -## Plugin System (oh-my-opencode) - -Adds specialized agents, model routing, and skill-based delegation: +### Local Models with Ollama ```sh -cd ~/.config/opencode -npm install oh-my-opencode +webi ollama +ollama serve & +ollama pull qwen2.5-coder:14b ``` -Configure agents in `~/.config/opencode/oh-my-opencode.json`: - ```json { - "agents": { - "oracle": { - "description": "Read-only high-IQ consultant for architecture", - "model": "anthropic/claude-sonnet-4-5-20250514", - "tools": ["Read", "Grep", "Glob", "WebFetch"] - }, - "reviewer": { - "description": "Code review specialist", - "model": "anthropic/claude-sonnet-4-5-20250514", - "tools": ["Read", "Grep", "Bash"] + "$schema": "https://opencode.ai/config.json", + "provider": { + "ollama": { + "npm": "@ai-sdk/openai-compatible", + "options": { + "baseURL": "http://127.0.0.1:11434/v1" + }, + "models": { + "qwen2.5-coder:14b": { + "name": "Qwen 2.5 Coder 14B (local)" + } + } } } } ``` -## Key Features - -| Feature | Description | -|---------|-------------| -| **Multi-Provider** | Switch between Anthropic, OpenAI, Google, Ollama mid-session | -| **Full Tool Access** | Read/write files, execute shell commands, search codebase | -| **Plugin System** | Extend with custom agents and workflows | -| **Terminal Native** | Runs in any terminal with full keyboard navigation | -| **Context-Aware** | Maintains conversation context across file edits | - -## Common Workflows - -### Code Review -```sh -opencode -# In TUI: "Review the changes in src/auth.ts and suggest improvements" -``` - -### Implement Feature -```sh -opencode -# In TUI: "Add user authentication with JWT tokens" -# OpenCode will read files, write code, and execute tests -``` - -### Debug Issue -```sh -opencode -# In TUI: "Why is the API returning 500 errors?" -# OpenCode will read logs, check code, and suggest fixes -``` - -### Refactor -```sh -opencode -# In TUI: "Refactor the user service to use async/await instead of promises" -``` - -## Integration with Other Tools - -### With Ollama (Local Models) -Requires `ollama` to be running: -```sh -ollama serve & # Keep running in background -opencode # Will connect to local Ollama -``` - -### With Git -OpenCode is git-aware and can: -- Read diffs -- Suggest commit messages -- Review changes before commit -- Create branches - -### With Testing Frameworks -OpenCode can run tests directly: -```sh -opencode -# In TUI: "Run the test suite and fix any failures" -``` - -## Files Created - -```text -~/.config/envman/PATH.env # PATH configuration -~/.local/bin/opencode # Symlink to versioned binary -~/.local/opt/opencode-VERSION/ # Installed binary -~/.config/opencode/opencode.json # Configuration -~/.config/opencode/oh-my-opencode.json # Plugin config (if installed) -``` - ## Key Bindings -| Key | Action | -|-----|--------| -| `Enter` | Send message | +| Key | Action | +| -------- | -------------------------------- | +| `Enter` | Send message | | `Ctrl+E` | Open editor for multi-line input | -| `Ctrl+C` | Cancel current operation | -| `Ctrl+L` | Clear screen | -| `/` | Slash commands | +| `Ctrl+C` | Cancel current operation | +| `Ctrl+L` | Clear screen | +| `/` | Slash commands | -## Comparison with Alternatives - -| Tool | OpenCode | Cursor | GitHub Copilot | -|------|----------|--------|----------------| -| **Interface** | Terminal TUI | VS Code fork | IDE extension | -| **Providers** | Multi (Anthropic, OpenAI, Google, Ollama) | OpenAI only | GitHub's models | -| **Local Models** | ✅ Via Ollama | ❌ | ❌ | -| **Plugins** | ✅ oh-my-opencode | Limited | Limited | -| **Shell Access** | ✅ Full | ✅ Terminal | ❌ | -| **Offline** | ✅ With Ollama | ❌ | ❌ | - -## Best Practices - -1. **Start with cloud LLMs** — Test with Anthropic/OpenAI before switching to local models -2. **Use plugins for complex workflows** — oh-my-opencode adds multi-agent coordination -3. **Configure model tiers** — Use "big" model for complex tasks, "small" for quick edits -4. **Keep Ollama running** — If using local models, keep `ollama serve` in background -5. **Git integration** — Run opencode from git repo root for best context awareness - -## Troubleshooting - -**OpenCode won't start:** -```sh -# Check if binary is in PATH -which opencode - -# Verify configuration -cat ~/.config/opencode/opencode.json -``` - -**API key not working:** -```sh -# Verify environment variable is set -echo $ANTHROPIC_API_KEY - -# Make sure to export, not just set -export ANTHROPIC_API_KEY="sk-ant-..." -``` - -**Ollama connection failed:** -```sh -# Check if Ollama is running -curl http://localhost:11434/api/version +## Files Created -# Start Ollama if needed -ollama serve & +```text +~/.config/envman/PATH.env +~/.local/bin/opencode +~/.local/opt/opencode-VERSION/bin/opencode +~/.config/opencode/opencode.json ``` -## Resources - -- GitHub: https://github.com/anomalyco/opencode -- Plugin System: https://github.com/code-yeongyu/oh-my-opencode -- Model Options: https://opencode.ai/models -- Configuration Schema: https://opencode.ai/config.json - ## Related Webi Installers - `ollama` — Local LLM server for offline AI coding - `node` — Required for installing plugins (oh-my-opencode) -- `git` — Version control integration diff --git a/opencode/install.ps1 b/opencode/install.ps1 index f4adfec8f..97b505921 100644 --- a/opencode/install.ps1 +++ b/opencode/install.ps1 @@ -1,8 +1,8 @@ #!/usr/bin/env pwsh -################## +#################### # Install opencode # -################## +#################### # Every package should define these variables $pkg_cmd_name = "opencode" @@ -19,31 +19,30 @@ New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null $pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE" # Fetch archive -IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) { +if (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) { Write-Output "Downloading opencode from $Env:WEBI_PKG_URL to $pkg_download" & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" & Move-Item "$pkg_download.part" "$pkg_download" } -IF (!(Test-Path -Path "$pkg_src_cmd")) { +if (!(Test-Path -Path "$pkg_src_cmd")) { Write-Output "Installing opencode" - # TODO: create package-specific temp directory # Enter tmp Push-Location .local\tmp - # Remove any leftover tmp cruft - Remove-Item -Path ".\opencode-v*" -Recurse -ErrorAction Ignore - Remove-Item -Path ".\opencode.exe" -Recurse -ErrorAction Ignore + # Remove any leftover tmp cruft + Remove-Item -Path ".\opencode-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\opencode.exe" -Recurse -ErrorAction Ignore - # Extract to opencode-v$Env:WEBI_VERSION - Write-Output "Unpacking $pkg_download" - & tar xf "$pkg_download" + # Unpack archive + Write-Output "Unpacking $pkg_download" + & tar xf "$pkg_download" - # Move into place - Write-Output "Install Location: $pkg_src_cmd" - New-Item "$pkg_src_bin" -ItemType Directory -Force | Out-Null - Move-Item -Path ".\opencode.exe" -Destination "$pkg_src_bin" + # Move single binary into place + Write-Output "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force | Out-Null + Move-Item -Path ".\opencode.exe" -Destination "$pkg_src_bin" # Exit tmp Pop-Location diff --git a/opencode/install.sh b/opencode/install.sh index 5e9b81fde..ccdeada4b 100644 --- a/opencode/install.sh +++ b/opencode/install.sh @@ -6,33 +6,33 @@ set -u __init_opencode() { - #################### - # Install opencode # - #################### + #################### + # Install opencode # + #################### - pkg_cmd_name="opencode" + pkg_cmd_name="opencode" - pkg_dst_cmd="$HOME/.local/bin/opencode" - pkg_dst="$pkg_dst_cmd" + pkg_dst_cmd="$HOME/.local/bin/opencode" + pkg_dst="$pkg_dst_cmd" - pkg_src_cmd="$HOME/.local/opt/opencode-v$WEBI_VERSION/bin/opencode" - pkg_src_dir="$HOME/.local/opt/opencode-v$WEBI_VERSION" - pkg_src="$pkg_src_cmd" + pkg_src_cmd="$HOME/.local/opt/opencode-v$WEBI_VERSION/bin/opencode" + pkg_src_dir="$HOME/.local/opt/opencode-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" - pkg_install() { - # ~/.local/opt/opencode-v1.2.27/bin/ - mkdir -p "$(dirname "$pkg_src_cmd")" + pkg_install() { + # ~/.local/opt/opencode-v1.2.27/bin/ + mkdir -p "$(dirname "$pkg_src_cmd")" - # mv ./opencode ~/.local/opt/opencode-v1.2.27/bin/opencode - mv ./opencode "$pkg_src_cmd" - } + # mv ./opencode ~/.local/opt/opencode-v1.2.27/bin/opencode + mv ./opencode "$pkg_src_cmd" + } - pkg_get_current_version() { - # 'opencode --version' outputs version number - opencode --version 2>/dev/null | - head -n 1 | - cut -d' ' -f1 - } + pkg_get_current_version() { + # 'opencode --version' outputs just the version number: + # 1.2.27 + opencode --version 2> /dev/null | + head -n 1 + } } diff --git a/opencode/releases.js b/opencode/releases.js index 87b24afea..4bf28075c 100644 --- a/opencode/releases.js +++ b/opencode/releases.js @@ -9,28 +9,18 @@ let Releases = module.exports; Releases.latest = async function () { let all = await github(null, owner, repo); - // Filter to CLI-only releases (exclude desktop, electron, baseline, musl variants) + // Keep only CLI binaries: opencode-{os}-{arch}.{tar.gz|zip} + // Exclude: desktop/electron apps, baseline builds, .yml/.yaml manifests, + // .json metadata, .dmg/.deb/.rpm packages, .sig signatures + // Include: musl builds (webi handles both gnu and musl) all.releases = all.releases.filter(function (rel) { - return rel.version && !rel.version.includes('nightly'); - }); - - all.releases.forEach(function (rel) { - // Filter assets to CLI binaries only - rel.assets = (rel.assets || []).filter(function (asset) { - let name = asset.name; - // Keep only CLI binaries: opencode-{os}-{arch}.{tar.gz|zip} - // Exclude: desktop, electron, baseline, .yml manifests, auto-update files, packages - // Include: musl builds (webi handles both gnu and musl) - return ( - name.match(/^opencode-(darwin|linux|windows)-/) && - !name.includes('desktop') && - !name.includes('electron') && - !name.includes('baseline') && - !name.endsWith('.yml') && - !name.endsWith('.yaml') && - (name.endsWith('.tar.gz') || name.endsWith('.zip')) - ); - }); + let name = rel.name; + return ( + name.match(/^opencode-(darwin|linux|windows)-/) && + !name.includes('desktop') && + !name.includes('baseline') && + (name.endsWith('.tar.gz') || name.endsWith('.zip')) + ); }); return all; diff --git a/test/install.sh b/test/install.sh index 7e0b4bcb7..68672bb40 100644 --- a/test/install.sh +++ b/test/install.sh @@ -55,6 +55,7 @@ __rmrf_local() { nerd-font \ nerdfont \ node \ + opencode \ ots \ pandoc \ pathman \ @@ -151,6 +152,7 @@ __rmrf_local() { nerd-font \ nerdfont \ node \ + opencode \ ots \ pandoc \ pathman \ From c19b8ff8940a0c972e7b7ed58feb26069a253a26 Mon Sep 17 00:00:00 2001 From: ogormans-deptstack Date: Sat, 21 Mar 2026 21:10:44 +0000 Subject: [PATCH 5/5] fix(opencode): exclude musl duplicates from releases, add chmod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - releases.js: filter out musl builds (-musl suffix) to prevent normalizer duplicate key collisions — both musl and gnu map to the same os/arch, causing ambiguous release selection on Linux - install.sh: add chmod a+x after moving binary (matches bat/install.sh pattern, ensures execute permission regardless of archive format) --- opencode/install.sh | 1 + opencode/releases.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/opencode/install.sh b/opencode/install.sh index ccdeada4b..c75e48045 100644 --- a/opencode/install.sh +++ b/opencode/install.sh @@ -25,6 +25,7 @@ __init_opencode() { # mv ./opencode ~/.local/opt/opencode-v1.2.27/bin/opencode mv ./opencode "$pkg_src_cmd" + chmod a+x "$pkg_src_cmd" } pkg_get_current_version() { diff --git a/opencode/releases.js b/opencode/releases.js index 4bf28075c..ff2c0670d 100644 --- a/opencode/releases.js +++ b/opencode/releases.js @@ -12,13 +12,15 @@ Releases.latest = async function () { // Keep only CLI binaries: opencode-{os}-{arch}.{tar.gz|zip} // Exclude: desktop/electron apps, baseline builds, .yml/.yaml manifests, // .json metadata, .dmg/.deb/.rpm packages, .sig signatures - // Include: musl builds (webi handles both gnu and musl) + // Exclude musl builds: the normalizer maps both musl and gnu to the same + // os/arch key, causing duplicates. Prefer gnu (glibc) as the default. all.releases = all.releases.filter(function (rel) { let name = rel.name; return ( name.match(/^opencode-(darwin|linux|windows)-/) && !name.includes('desktop') && !name.includes('baseline') && + !name.includes('-musl') && (name.endsWith('.tar.gz') || name.endsWith('.zip')) ); });