{"id":50413589,"url":"https://github.com/imagewize/ollama-opencode-setup","last_synced_at":"2026-05-31T05:01:15.592Z","repository":{"id":324828610,"uuid":"1098695483","full_name":"imagewize/ollama-opencode-setup","owner":"imagewize","description":"Ollama + Open Code Setup","archived":false,"fork":false,"pushed_at":"2025-11-18T03:50:06.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-18T05:29:48.440Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imagewize.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"docs/AGENTS.md","dco":null,"cla":null}},"created_at":"2025-11-18T02:56:14.000Z","updated_at":"2025-11-18T03:50:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/imagewize/ollama-opencode-setup","commit_stats":null,"previous_names":["imagewize/ollama-opencode-setup"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/imagewize/ollama-opencode-setup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagewize%2Follama-opencode-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagewize%2Follama-opencode-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagewize%2Follama-opencode-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagewize%2Follama-opencode-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imagewize","download_url":"https://codeload.github.com/imagewize/ollama-opencode-setup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagewize%2Follama-opencode-setup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33719601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-31T05:01:14.955Z","updated_at":"2026-05-31T05:01:15.586Z","avatar_url":"https://github.com/imagewize.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ollama + Open Code Setup\n\nComplete configuration and documentation for running Open Code CLI with local Ollama models.\n\n## Table of Contents\n\n- [Quick Start](#quick-start)\n  - [Prerequisites](#prerequisites)\n  - [Setup](#setup)\n- [What's Included](#whats-included)\n- [⚠️ Important: Tool Usage Discovery](#️-important-tool-usage-discovery)\n- [Available Models](#available-models)\n- [Common Commands](#common-commands)\n  - [Ollama Management](#ollama-management)\n  - [Creating Custom Models](#creating-custom-models)\n  - [Open Code Usage](#open-code-usage)\n- [Performance Tips](#performance-tips)\n- [When to Use Local vs Cloud Models](#when-to-use-local-vs-cloud-models)\n- [Documentation](#documentation)\n- [Examples](#examples)\n- [Troubleshooting](#troubleshooting)\n- [Resources](#resources)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Quick Start\n\n### Prerequisites\n\n1. **Install Ollama**: [ollama.ai](https://ollama.ai)\n2. **Install Open Code CLI**: [opencode.ai](https://opencode.ai)\n\n### Setup\n\n1. **Clone this repository:**\n   ```bash\n   git clone https://github.com/YOUR-USERNAME/ollama-opencode-setup.git ~/code/ollama-opencode-setup\n   ```\n\n2. **Start Ollama:**\n   ```bash\n   ollama serve\n   ```\n\n3. **Pull your first model (and build the recommended 16k variant):**\n   ```bash\n   ollama pull ministral-3:8b   # fast, reliable tool calling\n\n   # Open Code can't set Ollama's num_ctx, so bake a 16k context variant:\n   ollama create ministral-3:8b-16k -f modelfiles/ministral-3-8b-16k.Modelfile\n   ```\n\n4. **Use the configuration in your project:**\n   ```bash\n   # Option 1: Symlink into your project\n   ln -s ~/code/ollama-opencode-setup/opencode.json ~/code/your-project/opencode.json\n\n   # Option 2: Copy into your project\n   cp ~/code/ollama-opencode-setup/opencode.json ~/code/your-project/opencode.json\n   ```\n\n5. **Run Open Code:**\n   ```bash\n   cd ~/code/your-project\n   opencode\n   ```\n\n## What's Included\n\n- **[opencode.json](opencode.json)** - Open Code configuration for Ollama models\n- **[docs/LOCALLLMS.md](docs/LOCALLLMS.md)** - Complete documentation on local LLM setup\n- **[docs/AGENTS.md](docs/AGENTS.md)** - Guide to using Open Code CLI agent modes\n- **[examples/](examples/)** - Example workflows and prompts\n- **[test-opencode.md](test-opencode.md)** - Test suite for validating Open Code CLI setup\n\n## ⚠️ Important: Tool Usage Discovery\n\n**Tool calling requires a model trained for it — and that capability is not tied to size or recency.**\n\nAll models in this config have been tested. Results (M1 16GB, 2026-05-31):\n- ✅ **Ministral 3 8B** — full tool usage, **fastest tool-caller (~4s warm)**, no think-mode tax — **recommended daily driver**\n- ✅ **Qwen3 models** (qwen3:8b-16k, qwen3:8b, qwen3:4b) — full tool usage confirmed, but verbose think mode (~26s)\n- ❌ **DeepSeek-Coder-V2-Lite 16B** — Ollama reports `does not support tools`; fits RAM and is fast, but it's a code-completion/FIM model with no tool calling\n- ❌ **Qwen3.5 9B / 4B** — outputs bash commands instead of invoking write tool\n- ❌ **Phi-4** — Open Code CLI explicitly reports \"does not support tools\"\n- ❌ **Gemma 4 E4B** — attempts tool call but sends malformed/incompatible call format\n- ❌ **Mistral Nemo \u0026 Granite** — analysis only, cannot create files\n\nTool-call support is verified with [`scripts/tool-call-test.sh`](scripts/tool-call-test.sh). See [docs/LOCALLLMS.md](docs/LOCALLLMS.md) for full test details.\n\n## Available Models\n\n| Model | Size | Context | Tool Usage | Best For |\n|-------|------|---------|------------|----------|\n| `ministral-3:8b-16k` ⭐ | 6.0 GB | 16k | ✅ YES | **Recommended for Open Code** — 16k variant (num_ctx baked in) |\n| `ministral-3:8b` | 6.0 GB | ~4k default | ✅ YES | Base model — fast tool use (~4s); runs at Ollama's small default context in Open Code |\n| `qwen3:8b-16k` | 5.2 GB | 16k | ✅ YES | Multi-file analysis (larger context) |\n| `qwen3:8b` | 5.2 GB | 8k | ✅ YES | General file operations (~26s) |\n| `qwen3:4b` | 2.5 GB | 8k | ✅ YES | Quick file edits |\n| `deepseek-coder-v2:16b` | 8.9 GB | 128k | ❌ NO | No tool support (`does not support tools`) — FIM/completion only |\n| `qwen3.5:9b` | 6.6 GB | 32k | ❌ NO | Read-only analysis (too slow, 13+ min) |\n| `qwen3.5:4b` | ~2.5 GB | 32k | ❌ NO | Read-only analysis only |\n| `phi4:latest` | ~5 GB | 16k | ❌ NO | Read-only analysis only |\n| `gemma4:e4b` | ~5.5 GB | 32k | ❌ NO | Read-only analysis only |\n| `mistral-nemo:12b-instruct-2407-q4_K_M` | 7.5 GB | 8k | ❌ NO | Code review (read-only) |\n| `granite3.1-moe` | 2.0 GB | 8k | ❌ NO | Fast analysis (read-only) |\n\n## Common Commands\n\n### Ollama Management\n```bash\n# List installed models\nollama list\n\n# Run a model interactively\nollama run qwen3:8b\n\n# Pull a new model\nollama pull mistral-nemo:12b-instruct-2407-q4_K_M\n\n# Remove a model\nollama rm qwen3:4b\n```\n\n### Creating Custom Models\n\nOpen Code talks to Ollama via the OpenAI-compatible endpoint, which does **not** pass Ollama's `num_ctx`. To get a usable context window, bake it into a custom variant.\n\n**Recommended — from a committed Modelfile (reproducible):**\n```bash\nollama create ministral-3:8b-16k -f modelfiles/ministral-3-8b-16k.Modelfile\n\n# Verify the context is baked in\nollama show ministral-3:8b-16k --modelfile | grep num_ctx\n# PARAMETER num_ctx 16384\n```\n\nThe Modelfile is just `FROM ministral-3:8b` + `PARAMETER num_ctx 16384`.\n\n**Alternative — interactive `/save` (used for `qwen3:8b-16k`):**\n```bash\n# Start interactive session\nollama run qwen3:8b\n\n# Set extended context\n\u003e\u003e\u003e /set parameter num_ctx 16384\nSet parameter 'num_ctx' to '16384'\n\n# Save as new model\n\u003e\u003e\u003e /save qwen3:8b-16k\nCreated new model 'qwen3:8b-16k'\n\n# Exit\n\u003e\u003e\u003e /bye\n```\n\n### Open Code Usage\n\n```bash\n# Run with default model\nopencode run \"create a todo.md file\"\n\n# Specify model\nopencode run \"analyze this codebase\" --model ollama/qwen3:8b-16k\n\n# Interactive session\nopencode\n```\n\n## Performance Tips\n\n**Use the right model for the task:**\n\n**File Creation/Modification (use a tool-capable model):**\n- **Default / fastest tool use** → `ministral-3:8b-16k` (~4s, no think-mode tax, 16k context for Open Code) ⭐\n- **Multi-file changes (larger context)** → `qwen3:8b-16k` (extended context + tool usage)\n- **Standard file operations** → `qwen3:8b` (balanced, ~26s)\n- **Quick file edits** → `qwen3:4b` (fastest Qwen3 model)\n\n**Code Review/Analysis (read-only — any model works):**\n- **Best quality review** → `mistral-nemo:12b-instruct-2407-q4_K_M` (excellent analysis)\n- **Fast analysis** → `granite3.1-moe` (quickest)\n- **Large context analysis** → `qwen3.5:4b` (32k context, read-only) — avoid `qwen3.5:9b` (too slow)\n\n**Performance expectations (write tool call):**\n\n| Task | ministral-3:8b-16k ⭐ | qwen3:8b | qwen3:8b-16k | Claude Sonnet 4 |\n|------|-----------------------|----------|--------------|-----------------|\n| Simple file write | **~4s** | 15-30s | 45-90s | 2-5s |\n| Multi-file analysis | fast | 40-90s | 90-180s | 10-30s |\n\n**Notes:**\n- `ministral-3:8b` is the fastest tool-caller tested — no `\u003cthink\u003e` overhead\n- Qwen3 models enter verbose \"thinking mode\" before execution (slower but successful)\n- A model must be trained/templated for tools — fitting in RAM is not enough (e.g. DeepSeek-Coder-V2-Lite fits but has no tool calling)\n\n## When to Use Local vs Cloud Models\n\n### Use Local Models (Ollama) When:\n- ✅ Working offline\n- ✅ Processing sensitive/proprietary code\n- ✅ Running batch operations overnight\n- ✅ Learning/experimenting without API costs\n- ✅ Privacy requirements mandate local processing\n- ✅ Code review that doesn't require changes (any model)\n- ⚠️ **File operations (use a tool-capable model — Ministral 3 8B or Qwen3)**\n\n### Use Cloud Models (Claude API) When:\n- ⏱️ Real-time interactive development\n- ⚡ Complex multi-file operations requiring fast iteration\n- 🚀 Time-sensitive tasks\n- 📚 Working with very large codebases (200k+ context)\n- 💰 Speed is more important than cost\n- 🎯 Best code quality is critical\n\n## Documentation\n\n### [docs/OPENCODE-COMMANDS.md](docs/OPENCODE-COMMANDS.md)\n**Complete Open Code CLI commands reference:**\n- All built-in slash commands (15 commands documented)\n- Bash command integration (`!command`)\n- Agent switching (Tab key for build/plan agents)\n- Custom command creation (file-based and config-based)\n- Navigation and workflows\n- Troubleshooting command issues\n\n### [docs/LOCALLLMS.md](docs/LOCALLLMS.md)\nComprehensive guide to local LLM setup:\n- Custom model creation\n- Context window comparison (4k vs 8k vs 16k vs 200k)\n- Ollama commands reference\n- Model selection guidelines\n- Troubleshooting guide\n- Performance optimization\n\n### [docs/AGENTS.md](docs/AGENTS.md)\nGuide to using Open Code CLI agent modes:\n- Build and plan agents (Tab key switching)\n- Model capabilities for agent workflows\n- Agent workflow patterns\n- Controlling agent behavior\n- Performance benchmarks by model\n- Best practices and troubleshooting\n\n### [test-opencode.md](test-opencode.md) \u0026 [RECOMMENDATIONS.md](RECOMMENDATIONS.md)\n**Critical testing results:**\n- ✅ Qwen3 models have full tool usage (file creation works)\n- ❌ Mistral Nemo \u0026 Granite lack tool usage (analysis only)\n- Model-by-model test results and recommendations\n\n## Examples\n\nCheck the [examples/](examples/) directory for:\n- Code review workflows\n- Refactoring prompts\n- Multi-file analysis examples\n- Batch processing scripts\n\n## Troubleshooting\n\n### Ollama Not Running\n```bash\n# Check if Ollama is running\ncurl http://localhost:11434/v1/models\n\n# Start Ollama\nollama serve\n```\n\n### Model Not Found\n```bash\n# Verify model exists\nollama list\n\n# Pull model if missing\nollama pull qwen3:8b\n```\n\n### Slow Performance\n- Use smaller models for simple tasks (`qwen3:4b`)\n- Use standard context when extended context isn't needed (`qwen3:8b` instead of `qwen3:8b-16k`)\n- Consider cloud models for time-sensitive work\n\nSee [docs/LOCALLLMS.md#troubleshooting](docs/LOCALLLMS.md#troubleshooting) for more details.\n\n## Resources\n\n- [Ollama Documentation](https://github.com/ollama/ollama)\n- [Open Code Documentation](https://opencode.ai/docs)\n- [Qwen3 Model Card](https://huggingface.co/Qwen/Qwen3-8B)\n- [Mistral Nemo Documentation](https://mistral.ai/news/mistral-nemo/)\n\n## Contributing\n\nContributions welcome! Please feel free to submit issues or pull requests with:\n- New model configurations\n- Performance optimizations\n- Example workflows\n- Documentation improvements\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimagewize%2Follama-opencode-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimagewize%2Follama-opencode-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimagewize%2Follama-opencode-setup/lists"}