Ollama provider, agent registry, canton UX, i18n, and test infrastructure in one commit

fedec65 landed a 6,150-line second-phase commit bundling six independent subsystems: a local Ollama LLM provider with dynamic model discovery, a 20-agent persona registry, per-chat canton context, next-intl i18n scaffolding, Supabase local dev setup, and the first backend test suite. Several pieces have value outside the Swiss legal context; extracting them requires manual splitting.

chat-uipersonas

The Ollama provider (backend/src/lib/llm/ollama.ts) polls ${host}/api/tags to discover available models dynamically, maps them to internal IDs (llama3.2:latest becomes ollama-llama3.2-latest), and wires into the existing resolveModel() path for any ollama-* ID. A new GET /chat/models/ollama endpoint exposes the list to the frontend. The strict privacy mode routes automatically to the user's preferred Ollama model. No API key needed.

The agent registry defines 20 personas, each with a system prompt and a preferredTools array. The list runs from general through litigator, drafter, federal_analyst, a three-way adversarial triad (adversarial_advocate/adversary/judge), and domain specialists like corporate_lawyer, tax_advisor, and cas_specialist (Court of Arbitration for Sport). Per-chat selection is exposed through an AgentSelector component. The persona prompts are Swiss-specific but the registry pattern itself is general.

The Supabase local dev setup is the most straightforwardly portable piece: a complete supabase/config.toml, a full schema snapshot, and dated migrations. The test suite (vitest + supertest + Playwright, claimed 43 backend tests passing) was also missing from upstream.

The catch for adoption: all of this is a single commit. Package-lock churn alone is roughly 2,400 lines across frontend and backend, and the subsystems are intermixed in the file changes.

So what Worth examining if you want local Ollama support, a per-agent prompt architecture, or the Supabase local dev setup that upstream Mike was missing. Each requires manual extraction. Skip if you need a clean cherry-pick - this commit doesn't offer one.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

1 commit from fedec65/bettercallmitch, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
aa9c3724 feat: dynamic Ollama model discovery + second phase features Federico Cesconi 2026-05-06 ↗ GitHub
commit body
Backend:
- Add GET /chat/models/ollama endpoint for dynamic local model discovery
- Add preferred_ollama_model column to user_profiles
- Fix privacy strict mode to use preferred/detected Ollama model
- Accept any ollama-* model ID in resolveModel()
- Export getOllamaHost() and listOllamaModels() from ollama.ts
- Add CORS support for 127.0.0.1:3000 origin
- Copy second_phase migration to supabase/migrations/

Frontend:
- ModelToggle: dynamically fetch and display local Ollama models
- modelAvailability: add ollama provider (no API key needed)
- useSelectedModel: accept dynamic ollama-* IDs
- UserProfileContext: expose ollamaHost and preferredOllamaModel
- Account models page: add Ollama host + preferred model config UI
- Skip API-key modal for Ollama models in chat/TabularReview

Also includes prior second phase work:
- i18n (de/fr/it/en) with next-intl, localePrefix: never
- Canton selector per-chat with canton context injection
- Agent/persona system (20 agents) with per-chat agent selection
- Privacy scanner for privilege detection
- Ollama provider for local LLM inference
- Backend tests (43 passing) + Playwright E2E tests (3 passing)
- Local Supabase dev setup with .env config

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-64.md from inside the repo you want the changes in.

⬇ Download capture-thread-64.md