feat(cli): add interactive Ollama model picker to init (#128, Slice B-ii)#173
Merged
Conversation
…-ii) Replaces the free-text model prompt in `openkos init` with a numbered picker over the chat models actually installed on the local Ollama server, so a first-time user selects from a known set instead of typing an exact tag from memory (the footgun that let a user answer `yes` in #128). - `_pick_chat_model()` probes Ollama in Phase A, before any workspace write, lists installed chat models (embedding models excluded via `is_embedding_model`), marks the recommended default and selects it on Enter. `--model` and non-TTY runs bypass the picker unchanged. - Graceful degradation: an unreachable server or zero chat models falls back to the typed prompt / packaged default; init never hard-fails. - Robust input handling: the numeric-choice guard requires an ASCII digit (a Unicode digit like `²` passes str.isdigit() but is not int()-parseable and previously escaped the bounded reprompt), and the candidate list drops any server tag that would fail `validate_model`, so the picker never offers an option that would hard-fail on selection. The reprompt loop is bounded and falls back to the default after `_MAX_PICKER_ATTEMPTS`. Closes #128.
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.
Summary
Slice B-ii of #128 — the interactive model picker, building on the widened
list_models()from #172. Closes #128.Replaces the free-text model prompt in
openkos initwith a numbered picker over the chat models actually installed on the local Ollama server, so a first-time user selects from a known set instead of typing an exact tag from memory (the footgun that let a user answeryesin #128)._pick_chat_model()probes Ollama in Phase A (before any workspace write), lists installed chat models (embedding models excluded viais_embedding_model), marks the recommended default and selects it on Enter.--model <tag>and non-TTY runs bypass the picker unchanged.²passesstr.isdigit()but is notint()-parseable and previously escaped the bounded reprompt into a hard-fail;validate_model, so the picker never offers an option that hard-fails on selection;_MAX_PICKER_ATTEMPTS.Verification
uv run pytest: 2109 passed, exit 0uv run ruff check . && uv run ruff format --check .: cleanuv run mypy .: cleanStrict TDD throughout (RED confirmed before each GREEN, including the two review fixes).
Issue
Closes #128 (Slice B-ii, final slice). Slice A (config hardening, #169) and Slice B-i (list_models widening, #172) already merged.