Skip to content

feat(cli): add interactive Ollama model picker to init (#128, Slice B-ii)#173

Merged
jasonssdev merged 1 commit into
mainfrom
feat/init-model-picker-ui
Jul 25, 2026
Merged

feat(cli): add interactive Ollama model picker to init (#128, Slice B-ii)#173
jasonssdev merged 1 commit into
mainfrom
feat/init-model-picker-ui

Conversation

@jasonssdev

Copy link
Copy Markdown
Owner

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 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 <tag> 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 (workspace still created, exit 0).
  • Robust input handling (from adversarial resilience review):
    • 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 into a hard-fail;
    • the candidate list drops any server tag that would fail validate_model, so the picker never offers an option that hard-fails on selection;
    • the reprompt loop is bounded and falls back to the default after _MAX_PICKER_ATTEMPTS.

Verification

  • uv run pytest: 2109 passed, exit 0
  • uv run ruff check . && uv run ruff format --check .: clean
  • uv run mypy .: clean
  • SDD verify (full change): PASS — 8 requirements / 27 scenarios
  • Adversarial resilience review: 1 WARNING + 1 SUGGESTION, both fixed in this PR (Unicode-digit hard-fail; picker offering an unvalidatable tag), each with a dedicated regression test.

Strict 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.

…-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.
@jasonssdev
jasonssdev merged commit 5ee0bd1 into main Jul 25, 2026
6 checks passed
@jasonssdev
jasonssdev deleted the feat/init-model-picker-ui branch July 25, 2026 05:01
jasonssdev added a commit that referenced this pull request Jul 25, 2026
Merge the llm-client, workspace-init, and doctor-command delta specs into
the main specs tree and move the change folder to the archive. Closes the
SDD cycle for the interactive model picker (both sub-slices: list_models
widening #172 and the picker #173), which closed #128.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: interactive model picker in openkos init (list installed Ollama models)

1 participant