PR: Refactor setup and expose embedder backend in first-run - #60
Conversation
The extraction-mode fix: `memayu setup` choosing `raw` still wrote a fully-populated gpt-4 LLM row to `provider_config` (the LLM step is skipped in raw mode, so the default gpt-4/base_url answers leaked through). The runtime reads `runtime_settings` for the extraction mode and never infers it from the LLM row, but the misleading placeholder made a raw instance look configured for llm. - memayu-setup: raw mode now writes an empty LLM block (no base_url/model/key) in both config_file_from_answers and provider_configs_from_answers. - memayu-api::persist_provider_config: skip the `llm` row upsert entirely when extraction mode is Raw. Bundles the related #55 embedder base_url normalization fix and its regression tests (repo DB choke point, service persist, web form, and POST /api/providers), which were pending in the same working tree.
|
Review of PR #60 at 🔴 BlockingNone. CI green: 🟡 Warning #1 — Non-breaking embedder rename
|
Summary
Refactor the first-run setup flow into a shared
memayu-setupcrate so the CLI (dialoguer), TUI (ratatui), and web presenters drive the same ordered step list — then expose the embedder backend (local/remote) and extraction mode (llm/raw) choices in the web first-run UI (issue #55). Includes a non-breakingEmbedderBackend::Http→Remoterename (serde alias keeps"http"config valid). Base includes the already-merged #59 batch/MCP-camelCase (commit5b4f946). CI green.Changes
(1) Shared setup crate — commit
5c68761(refactor, part of #55)crates/memayu-setup/Cargo.toml+src/lib.rs(~700 lines): move the canonical setup logic out ofbin/memayu/src/setup_flow.rsinto a reusable crate. Re-exportsSetupStep,SETUP_STEPS(single source of truth),SetupAnswers,LocalModelSpec/LOCAL_MODELS,DeviceReport/check_device,preseed,embedding_dimension,finalize— so CLI, TUI, and web wizards all iterate the same steps and cannot drift.crates/memayu-workspace/Cargo.toml: addcrates/memayu-setupto workspace members.bin/memayu/src/{wizard.rs,tui_setup.rs,main.rs}: switch from the localsetup_flowmodule touse memayu_setup::{...}.wizard.rs(CLI) andtui_setup.rs(ratatui) now both drivememayu_setup::SETUP_STEPS.bin/memayu/src/setup_flow.rsis now an orphan (594 lines, nomod setup_flow;inmain.rs→ not compiled). Should be deleted (dead code). Flagged as Warning.(2) Web setup exposes embedder backend + extraction mode — commit
b2657b4(issue #55)crates/memayu-web/src/pages/setup.rs: the first-run web form now offers a step for embedder backend (local/remote radio) + extraction mode (llm/raw radio), with the local-model picker (dimension/fp32/int8/ram/languages preview) re-usingmemayu_setup::LOCAL_MODELS. State is driven by an Alpine.js step variable; POST collectsembedder_backend/extraction_mode/local_modelinto the sameSetupAnswersthe CLI/TUI use.crates/memayu-web/src/pages/providers.rs+1: surfacelocalmodel in the providers list (consistent withbin/memayu doctor).crates/memayu-web/static/memayu.css(+267): styling for the new embedder/extraction radio steps + local-model spec tile.Embedder backend rename (http → remote) — non-breaking
crates/memayu-config/src/lib.rs:EmbedderBackend::Http→EmbedderBackend::Remote(Display writes"remote"), with#[serde(alias = "http")]and parser"remote" | "http"→Remote. ExistingMEMAYU_EMBEDDER_BACKEND=httpconfigs still parse; newly written configs persist"remote". No migration function (read compat via alias)..env.example/ validation messages accordingly.Docs
memayu setup(CLI) andmemayu setup --tuipointers + embedder backend valuesremote/local.Migration / behavior
embedder.backend = "http"still accepted (read); writes"remote".localunchanged. Non-breaking at the wire/config level.memayu-setupis internal (path dep), no public release impact.Tests
cli.rs/doctor.rs/dashboard suites still pass (CI green, test 1m15s).memayu-setupunit logic; the orphansetup_flow.rsis not compiled so adds no warning noise.Checklist
serde(alias)keeps"http").setup_flow.rscalled out for deletion.Fixes #55