feat(init): graceful Ollama first-run in coco init#1264
Merged
Conversation
The Ollama branch of `coco init` shelled out `ollama list | awk …` and hard-exited on any hiccup — non-portable (no awk on Windows), and a raw crash if Ollama wasn't installed/running, discarding every prior answer. Since Ollama is the default provider, this was most new users' first impression of the "local AI commits" path. Replace it with a cross-platform probe + guided recovery: - New `lib/langchain/utils/ollamaStatus.ts`: `getOllamaStatus()` queries the HTTP API (`/api/tags`) for reachability + pulled models in one call, with a PATH probe only to tell "not installed" from "not running"; plus `pullOllamaModel()` (live progress) and a typed `OllamaNotReadyError`. - `init` now guides each first-run state: not installed → install link; installed but down → `ollama serve`; up but no models → recommend and optionally pull `llama3.1:8b`. - When Ollama can't be used and the user doesn't fix it inline, the handler catches `OllamaNotReadyError` and re-offers the provider picker instead of aborting — prior answers (scope, commitlint) are preserved. Tests: unit coverage for getOllamaStatus across reachable / not-running / not-installed / non-OK, and a handler test for the re-prompt path.
This was referenced Jun 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
First slice of the 0.73 Ollama onboarding polish (freeze-allowed). Since Ollama is the default provider in the picker, this is most new users' first impression of the "local AI commits" path the launch leads with.
Problem
The Ollama branch of
coco initshelled out:awkon Windows.execPromiserejects with a raw "command not found").Change
New
lib/langchain/utils/ollamaStatus.ts:getOllamaStatus(endpoint?)— probes the HTTP API (/api/tags) for reachability and pulled models in one cross-platform call; a PATH probe only distinguishes "not installed" from "not running" for the copy.pullOllamaModel(model)—ollama pullwith live progress.OllamaNotReadyError— typed signal.coco initnow guides each first-run state instead of crashing:ollama.com/download/brew install ollama)ollama servellama3.1:8b(~4.7 GB, the cost-tiercommitdefault), prompted — never automaticWhen Ollama can't be used and the user doesn't fix it inline, the handler catches
OllamaNotReadyErrorand re-offers the provider picker — prior answers are preserved (no more session loss).Tests
ollamaStatus.test.ts— reachable / not-running / not-installed / non-OK / endpoint normalization (7 cases).init.test.ts— new test: not-ready → re-prompt → completes with another provider.Validation
eslint(0 errors),tsc --noEmitclean,jestinit + ollamaStatus suites green (7/7 each). Full rollup build deferred to CI (nested-worktree PATH quirk locally).Follow-ups (rest of the 0.73 Ollama polish)
coco doctor: Ollama daemon liveness + configured-model-pulled checkhandleMissingApiKeyOllama copy (OLLAMA_API_KEYis misleading for local)