GeezerVison is showing github.com — feat(opencode): add ollama init cli command to generate opencode.json config dynamically by tobocop2 · Pull Request #4183 · anomalyco/opencode
Conversation
tobocop2
commented
Nov 11, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Problem
Setting up opencode with ollama requires manually creating a config file and copying model names from ollama list. Unlike cloud providers that auto-configure through auth login, local providers like Ollama have no automated setup.
This is an alternative to #3726 but it is run conditionally by the user. I don't think opencode should look for ollama unless the user explicitly wants the support. My solution is an implementation of that and it's still configuration file driven. It is also thoroughly tested, cross platform and doesn't rely on an the arbitrary ollama base url and port but rather the ollama executable being found in the $PATH instead. I have been using a bash function to generate the opencode.json for me but I figured it would be helpful to others if this was just part of the opencode cli.
Run tests via
bun test test/cli/cmd/ollama.test.ts
Solution
Adds opencode ollama init to automatically generate config from installed models.
opencode ollama init -g # global config
opencode ollama init # local config
opencode ollama init config.json --base-url <url> # custom options
Key features:
- Auto-discovers models from ollama list
- --global flag writes to ~/.config/opencode/opencode.json
- Merges with existing config (preserves other providers)
- eliminates JSON syntax errors from manual configurations
Changes
- New CLI command: src/cli/cmd/ollama.ts
- Tests: test/cli/cmd/ollama.test.ts (9 tests)
- Docs: Updated Ollama section in providers.mdx
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
josh-romer, s-haha-n, strk, and jellewijma reacted with heart emoji
tobocop2
changed the title
Add ollama init command to auto-generate config
Add ollama init command to auto-generate opencode.json config
Nov 11, 2025
tobocop2
changed the title
Add ollama init command to auto-generate opencode.json config
feat: Add ollama init command to auto-generate opencode.json config
Nov 11, 2025
tobocop2
changed the title
feat: Add ollama init command to auto-generate opencode.json config
feat: add ollama init command to auto-generate opencode.json config
Nov 11, 2025
tobocop2
changed the title
feat: add ollama init command to auto-generate opencode.json config
feat: add ollama init cli command to generate opencode.json config dynamically
Nov 11, 2025
tobocop2
changed the title
feat: add ollama init cli command to generate opencode.json config dynamically
feat(cli): add ollama init cli command to generate opencode.json config dynamically
Nov 11, 2025
|
Hey! Your PR title feat(cli): add ollama init cli command to generate opencode.json config dynamically doesn't follow conventional commit format.
Please update it to start with one of:
feat: or feat(scope): new feature
fix: or fix(scope): bug fix
docs: or docs(scope): documentation changes
chore: or chore(scope): maintenance tasks
refactor: or refactor(scope): code refactoring
test: or test(scope): adding or updating tests
Where scope is the package name (e.g., app, desktop, opencode).
See CONTRIBUTING.md for details.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
tobocop2
changed the title
feat(cli): add ollama init cli command to generate opencode.json config dynamically
feat(opencode): add ollama init cli command to generate opencode.json config dynamically
Jan 8, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|