- Replace the temporary Express prototype with the spec architecture.
- Scaffold Expo Router, route tree, shared constants/types/store, Worker folders, and Supabase folders.
- Create env placeholders for mobile and Worker secrets.
Validation prompt:
Confirm the project structure, scripts, and env placeholders look right before wiring real data.
- Build auth, chat, history, memory, credits, and settings screens.
- Add reusable UI components, model selector, message list, and input bar.
- Keep everything runnable in preview mode without real credentials.
Validation prompt:
Open the Expo app and confirm screen structure, navigation, and visual direction before backend wiring.
- Add Supabase client integration and auth session handling.
- Connect Zustand state, conversation hooks, memory hooks, and credit hooks.
- Replace preview-only data with real reads where credentials exist.
Validation prompt:
Test sign-in, conversation loading, and balance fetching before enabling model streaming.
- Implement Worker auth verification,
/chat,/memory/extract, and/payments/webhook. - Connect OpenRouter streaming, usage recording, and credit deduction.
- Add memory extraction and retrieval flow.
Validation prompt:
Verify worker auth, streaming responses, and credit deduction against test accounts before shipping.
- Finish DB migrations, error states, polish, and deployment config.
- Add tests and a final production checklist.
Validation prompt:
Run through staging on device before enabling real top-ups or wider testing.
Date: 2026-05-13
-
DB Schema (
supabase/migrations/0004_wave1_context_window.sql)- Added
conversation_summariestable with GIN index onkey_facts. - Added
pgvectorextension +match_messagesRPC for semantic retrieval. - Added
embeddingvector column tomessages.
- Added
-
Worker (
worker/src/)- New
POST /chat/summarizeendpoint (handleSummarize) — runs summarization on the 2nd-last 10-message chunk using the cheapest available model. - Updated
POST /chat(handleChat) — prepends summary context as a system message whenconversationIdis provided. - Added
fetchConversationSummaries,fetchMessagesRange,fetchMessageCount,insertConversationSummary,matchMessageshelpers inworker/src/supabase.ts.
- New
-
Mobile (
hooks/useChat.ts,lib/openrouter.ts,lib/tokens.ts)useChattrims request history to last 8 messages before sending to worker.- Auto-triggers
summarizeConversation()every 10 messages (fire-and-forget, errors swallowed). estimateTokens()updated to usemeta-llama/llama-4-scout:free(128k context) as default.- Added
summarizeConversation()helper inlib/openrouter.ts.
Create a conversation with >10 messages and verify summaries appear in the DB + context is injected into new /chat requests.