From 9ad77e2a8b3c4d3fe55448c978725d72a9d5f0d9 Mon Sep 17 00:00:00 2001 From: zeapsu Date: Tue, 26 May 2026 20:42:35 -0700 Subject: [PATCH 01/10] feat: add local profile setup and settings --- README.md | 71 ++++---- SESSION_CONTEXT.md | 156 ------------------ docs/README.md | 11 ++ .../agent/skill-spec.md | 85 ++++++---- .../archive/legacy-cleanup-plan.md | 2 + DESIGN.md => docs/design/ethereal-console.md | 4 +- .../design/stitch-prompt.md | 2 + TODO.md => docs/planning/legacy-todo.md | 2 + PLAN.md => docs/planning/phase-1-plan.md | 6 +- docs/planning/session-context.md | 72 ++++++++ BRAINSTORM.md => docs/product/vision.md | 4 +- frontend/scripts/test-command-routing.mjs | 2 + frontend/src/app/page.tsx | 88 +++++++++- frontend/src/components/ProfileSetup.tsx | 112 +++++++++++++ frontend/src/components/SettingsPanel.tsx | 123 ++++++++++++++ frontend/src/lib/command-routing.ts | 4 +- 16 files changed, 508 insertions(+), 236 deletions(-) delete mode 100644 SESSION_CONTEXT.md create mode 100644 docs/README.md rename AGENT_SKILL_SPEC.md => docs/agent/skill-spec.md (81%) rename LEGACY_CLEANUP_PLAN.md => docs/archive/legacy-cleanup-plan.md (91%) rename DESIGN.md => docs/design/ethereal-console.md (98%) rename STITCH_PROMPT.md => docs/design/stitch-prompt.md (96%) rename TODO.md => docs/planning/legacy-todo.md (93%) rename PLAN.md => docs/planning/phase-1-plan.md (99%) create mode 100644 docs/planning/session-context.md rename BRAINSTORM.md => docs/product/vision.md (97%) create mode 100644 frontend/src/components/ProfileSetup.tsx create mode 100644 frontend/src/components/SettingsPanel.tsx diff --git a/README.md b/README.md index 1a0daf1..a175fed 100644 --- a/README.md +++ b/README.md @@ -2,40 +2,42 @@ > A local-first desktop knowledge agent for turning your own sources into chat, reports, quizzes, flashcards, and audio reviews. -Sage is a Tauri + Next.js + FastAPI app for working with a personal knowledge base. The core workflow is simple: bring documents into a local store, organize focused source sets as Tomes, then ask Sage to synthesize grounded outputs from those sources. +Sage is a Tauri + Next.js + FastAPI app for working with a personal knowledge base. The current default UI is **Tome Home**: a source-first workspace where you add knowledge, choose or create Tomes, and route explicit actions to focused learning/research views. -## Vision +## Product Truth -Sage is moving toward a NotebookLM-like experience that stays local-first and provider-flexible: +Sage is no longer centered on an Instagram-style arXiv summarizer. arXiv search and paper summarization remain useful discovery/import paths, but the main product is user-owned local knowledge: -- **Bring your own sources**: PDFs, Markdown, notes, pasted text, and eventually web captures or vault syncs. -- **Tomes**: focused workspaces that isolate source sets and chat history. -- **Bring your own agent/provider**: local models, Ollama, OpenAI-compatible APIs, Anthropic, DeepSeek, and other providers through a small backend abstraction. -- **Grounded outputs**: chat, reports, quizzes, flashcards, and audio reviews that cite or otherwise remain tied to the selected sources. -- **Floating desktop UX**: an Ethereal Console style interface that feels like a lightweight intelligence layer over the OS. - -arXiv support and paper summarization remain useful discovery paths, but they are no longer the center of the product. The main direction is user-owned local knowledge. +- **Bring your own sources**: text, Markdown, PDFs, pasted notes, and eventually web/vault syncs. +- **Tomes**: focused workspaces that group source sets and provide a home for chat history and generated artifacts. +- **Bring your own agent/provider (BYOA)**: local and hosted providers through a small backend abstraction; the next likely roadmap emphasis is deeper BYOA / bring-your-own-agent integration. +- **Grounded outputs**: chat, reports, quizzes, flashcards, and audio reviews tied to the selected sources. +- **Explicit command routing**: slash commands and first-party capability chips open generated views; ordinary natural-language questions stay in chat. +- **Ethereal Console direction**: the interface should keep the lightweight, luminous desktop-command feel while Tome Home remains the default landing experience. ## Current Features -- **Tauri desktop shell** with a Next.js 15 frontend. -- **FastAPI backend** for knowledge, chat, Tomes, providers, and research discovery endpoints. -- **Local knowledge store** with document chunks, embeddings, sessions, and Tome/source links. -- **Floating command UI** with chat, report, quiz, flashcard, audio, history, and Tome-oriented components. +- **Tome Home default UI** with source, report, quiz, flashcard, audio, chat, history, Tome, and settings navigation. +- **Local user profile setup** that stores a name and user-specific details in browser `localStorage` for owner-specific greetings and editable settings. +- **Tauri v2 desktop shell** with a Next.js 15 / React 19 frontend. +- **FastAPI backend** for knowledge, chat, Tomes, skills, provider config, generation, audio, and legacy research endpoints. +- **Local knowledge store** under `~/.sage/` with documents, chunks, sessions, and Tome/source links. +- **Typed frontend API client** that can use a browser backend (`NEXT_PUBLIC_API_URL`) or a Tauri sidecar backend (`NEXT_PUBLIC_DESKTOP_API_URL`). - **Tailwind v4 design tokens** for the dark Ethereal Console visual system. - **pytest backend suite** and GitHub Actions CI. -## Project Direction Docs +## Documentation -Several planning/specification files in the repo describe where Sage is headed: +Root-level planning/spec Markdown has been organized under `docs/`: -- `BRAINSTORM.md`: product direction from arXiv summarizer to local knowledge agent. -- `DESIGN.md`: Ethereal Console UI/UX specification. -- `PLAN.md`: implementation plan for the local knowledge agent foundation. -- `AGENT_SKILL_SPEC.md`: contract between backend skills and frontend UI components. -- `STITCH_PROMPT.md`: original design prompt/reference for the floating UI. -- `SESSION_CONTEXT.md`: current project state and next-session context. -- `LEGACY_CLEANUP_PLAN.md`: notes for removing old pre-Ethereal components. +- [`docs/product/vision.md`](docs/product/vision.md): product direction from arXiv summarizer to local knowledge agent. +- [`docs/design/ethereal-console.md`](docs/design/ethereal-console.md): Ethereal Console UI/UX specification. +- [`docs/design/stitch-prompt.md`](docs/design/stitch-prompt.md): original Stitch prompt/reference for the floating UI. +- [`docs/agent/skill-spec.md`](docs/agent/skill-spec.md): contract between backend skills and frontend UI/components. +- [`docs/planning/session-context.md`](docs/planning/session-context.md): current project state and next-session context. +- [`docs/planning/phase-1-plan.md`](docs/planning/phase-1-plan.md): historical implementation plan for the local knowledge foundation. +- [`docs/planning/legacy-todo.md`](docs/planning/legacy-todo.md): archived early project checklist. +- [`docs/archive/legacy-cleanup-plan.md`](docs/archive/legacy-cleanup-plan.md): cleanup notes for old pre-Ethereal components. ## Tech Stack @@ -73,7 +75,7 @@ uv sync --group dev uv run uvicorn main:app --reload ``` -The backend creates default local config under `~/.sage/` when needed. +The backend creates default local config and data under `~/.sage/` when needed. Optional provider keys can be configured through environment variables or Sage config, for example: @@ -120,7 +122,7 @@ npm run build ```text Sage/ ├── backend/ # FastAPI backend and local knowledge agent services -│ ├── api/ # Chat, knowledge, skills, Tomes, and related routes +│ ├── api/ # Chat, knowledge, skills, Tomes, generation, audio routes │ ├── providers/ # LLM provider abstraction │ ├── services/ # Legacy research/PDF services and shared helpers │ ├── skills/ # Backend skill registry and built-in skills @@ -128,22 +130,23 @@ Sage/ │ ├── pyproject.toml # uv-managed backend dependencies │ └── main.py # FastAPI application entry point ├── frontend/ # Next.js + Tauri frontend -│ ├── src/app/ # Next.js app shell -│ ├── src/components/ # Ethereal Console UI components -│ ├── src/lib/ # Typed API client and frontend utilities +│ ├── src/app/ # Tome Home app shell and routed views +│ ├── src/components/ # Ethereal Console / Tome Home UI components +│ ├── src/lib/ # Typed API client and explicit command routing │ └── src-tauri/ # Tauri desktop configuration ├── designs/ # Design references and generated visual artifacts -├── *.md # Product, design, agent, and implementation docs +├── docs/ # Product, design, agent, planning, and archive docs └── README.md ``` ## Near-Term Roadmap -- Finish replacing old pre-Ethereal UI paths with the Ethereal Console components. -- Make Tomes first-class across upload, chat, retrieval, history, and generated artifacts. -- Improve report rendering and exports, likely moving toward an HTML-friendly artifact model. -- Add explicit schema migrations for existing local Sage databases. -- Expand evaluation coverage for retrieval quality, grounding, and generated artifact correctness. +- Deepen BYOA / bring-your-own-agent support without locking Sage to one provider or orchestration style. +- Preserve explicit slash-command routing so natural-language chat is not hijacked into generated views. +- Continue making Tomes first-class across upload, chat, retrieval, history, and generated artifacts. +- Keep Ethereal Console as the interaction/design direction while Tome Home remains the default UI. +- Improve generated artifact rendering/export and evaluation coverage for retrieval, grounding, and generation quality. +- Add explicit migrations for existing local Sage databases as schemas evolve. ## Contributing diff --git a/SESSION_CONTEXT.md b/SESSION_CONTEXT.md deleted file mode 100644 index 7ee8fbf..0000000 --- a/SESSION_CONTEXT.md +++ /dev/null @@ -1,156 +0,0 @@ -# Sage — Session Context (April 23, 2026) - -> Auto-generated context file for session continuity. Contains full project state, decisions made, and pending work. - ---- - -## Project Overview - -**Sage** (renamed from "arXivSage") — a local-first desktop knowledge agent. Tauri + Next.js 15 frontend (Tailwind v4), FastAPI backend. - -**Core concept:** User-uploads sources as the primary workflow (like NotebookLM). arXiv search is a secondary "discover more" feature. "Tomes" = isolated sessions with focused sources, each with their own chat history. Sources can belong to multiple tomes (many-to-many). - -**Database:** LanceDB (vector-native) — preferred over SQLite+vector hybrid. Supports metadata filtering (e.g., `notebook_id`) and vector search in one system. - -**Upload formats:** PDF, plain text, markdown, URLs (Firecrawl/Jina for scraping) - ---- - -## Design Vision: "The Ethereal Console" - -A floating command palette UI (Raycast-style). Core principles: -- **No 1px solid borders** — boundaries via color shifts + depth -- **Dark theme only** — rich charcoal palette, never pure `#000` -- **Floating pill input bar** — centered upper third, 600×48px, `backdrop-blur: 32px` -- **7 window states** that stack as cards: Compact Input, Chat, Quiz, Flashcards, Audio Player, Report, History - -Full spec: `DESIGN.md` - ---- - -## Component Inventory (15 components) - -### ✅ Ethereal Console Components (8) — Production-ready - -All follow `DESIGN.md` glassmorphic spec. Used in `page.tsx`. - -| Component | File | Description | -|-----------|------|-------------| -| **CommandBar** | `CommandBar.tsx` | Pill input bar (600×48px), sparkle icon, provider badge | -| **ChatWidget** | `ChatWidget.tsx` | Chat card with message bubbles, typing indicator, auto-scroll | -| **QuizWidget** | `QuizWidget.tsx` | Interactive quiz with progress dots, confirm/skip, completion ring | -| **FlashcardWidget** | `FlashcardWidget.tsx` | 3D flip cards (Framer Motion), shuffle/reset, keyboard nav | -| **AudioPlayerWidget** | `AudioPlayerWidget.tsx` | Audio controls, gradient progress bar, transcript with word-highlight | -| **ReportViewWidget** | `ReportViewWidget.tsx` | Markdown report with sidebar TOC, KaTeX math, copy/MD/PDF export | -| **HistoryPanel** | `HistoryPanel.tsx` | Searchable history with type filter pills, grouped by time | -| **TomeSelector** | `TomeSelector.tsx` | Tome picker with search, active state, color-coded icons | - -### ⚠️ Legacy Components (7) — ALL ORPHANED (not imported anywhere) - -| Component | File | Issue | Action | -|-----------|------|-------|--------| -| **TomeList** | `TomeList.tsx` | Old UI, but has real API CRUD (`sage-api.ts`) | **Merge API logic into TomeSelector, then delete** | -| **KeywordSearch** | `KeywordSearch.tsx` | Old blue/white, uses axios | **Delete** | -| **SearchBar** | `SearchBar.tsx` | Hardcoded colors, redundant (CommandBar replaces) | **Delete** | -| **TableOfContents** | `TableOfContents.tsx` | Hardcoded `text-white` | **Delete** (ReportViewWidget has its own TOC) | -| **Feed** | `Feed.tsx` | Old gray-900 cards | **Delete** | -| **Post** | `Post.tsx` | Old gray-900 cards with Like/Comment | **Delete** | -| **LoadingSpinner** | `LoadingSpinner.tsx` | Hardcoded blue-400 | **Delete** | - ---- - -## Pending Work: Legacy Cleanup - -### Step 1: Merge TomeList API logic into TomeSelector - -**What TomeList has that TomeSelector doesn't:** -- Real API integration: `listTomes()`, `createTome()`, `deleteTome()` from `sage-api.ts` -- State management: `useEffect` to fetch on mount, `useState` for tomes array -- Create Tome flow: inline form with name + description inputs -- Delete Tome: with confirmation via stopPropagation -- Loading state - -**What TomeSelector has that TomeList doesn't:** -- Ethereal Console glassmorphic design (640px card, backdrop-blur, design tokens) -- Search/filter functionality -- Color-coded tome icons (hardcoded per-tome colors like `bg-blue-500/15`) -- Active state indicator -- "New Tome" button (decorative — no onClick handler yet) - -**Merge plan:** -1. Add `useEffect` to fetch real tomes on mount -2. Wire up "New Tome" button → inline create form (name + description) -3. Wire up delete (✕ icon with stopPropagation) -4. Add loading state -5. Keep TomeSelector's search, color-coded icons, glassmorphic design - -**Open question:** How to handle per-tome colors? -- Currently sample data has hardcoded colors (`bg-blue-500/15`, `bg-emerald-500/15`, etc.) -- Real API tomes don't have a color field -- Options: (1) rotate through a palette dynamically, (2) drop colors, (3) add color to API - -### Step 2: Delete all 7 legacy files - -```bash -rm frontend/src/components/TomeList.tsx -rm frontend/src/components/KeywordSearch.tsx -rm frontend/src/components/SearchBar.tsx -rm frontend/src/components/TableOfContents.tsx -rm frontend/src/components/Feed.tsx -rm frontend/src/components/Post.tsx -rm frontend/src/components/LoadingSpinner.tsx -``` - -### Step 3: Verify - -- Run `npm run build` to catch any broken imports -- Confirm `sage-api.ts` exports are intact - ---- - -## Agent Skill Spec - -Full spec written at `AGENT_SKILL_SPEC.md` (632 lines). Covers: -- `SkillResult` contract (`ui_component` + `data` → frontend dispatch) -- 10 skill definitions with YAML schemas and TypeScript prop interfaces -- Interaction flow diagrams -- Pending work (AudioPlayerWidget needs real `