feat: add TOTP 2FA, API key switcher, login progress bar, and alpha hardening plan

- TOTP 2FA: full setup/confirm/disable/login flow with Argon2id + ChaCha20-Poly1305
  encrypted secret storage, QR code generation, and bcrypt-hashed backup codes
- API key switcher: OAuth vs personal API key toggle in AIUI chat settings with
  status indicator, key validation, and help text
- Login progress bar: server startup detection with health check polling, form
  disabled until server is ready
- AI quarantine docs: comprehensive HTML page documenting all 6 security layers
- Settings: AI Data Access permission toggles with per-category control
- Alpha hardening plan: 28-task overnight automation plan across 7 phases
  (onboarding, login, app install, AIUI, UI polish, security, ISO build)
- Backlog: node discovery spatial map feature for alpha demo

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-06 12:23:57 +00:00
parent 0b3c23ff76
commit e55fd3baf0
16 changed files with 2402 additions and 152 deletions

View File

@@ -1,74 +1,64 @@
You are integrating AIUI (AI chat interface) into Archipelago (Archy) as its Chat mode. Read these files first:
You are hardening Archipelago (Archy) for its first alpha release. People will flash this ISO to USB, install on their hardware, and use the web UI to manage their node. Everything must work flawlessly.
Read these files first:
1. `loop/plan.md` — Your task checklist (mark items `- [x]` as you complete them)
2. `CLAUDE.md` — Archy project conventions, architecture, coding standards
3. `/Users/dorian/Projects/AIUI/CLAUDE.md` — AIUI conventions and Archy integration rules
## Architecture Overview
## What You're Doing
AIUI runs in an iframe at `/dashboard/chat`. Communication happens via `window.postMessage()` through a ContextBroker (Archy side) and archyBridge (AIUI side). AIUI is quarantined — it never directly accesses Archy APIs.
**No new features. No design changes.** You are:
- Hardening the first-time onboarding flow so it works perfectly
- Ensuring app installation is bulletproof
- Making the AIUI chat work reliably
- Fixing any UI bugs or rough edges
- Building the alpha ISO when everything passes
## Architecture Quick Reference
```
AIUI (iframe) ←→ postMessage ←→ ContextBroker (Archy) ←→ Pinia stores / RPC
Server: 192.168.1.228 (ssh: archipelago@192.168.1.228, pass: EwPDR8q45l0Upx@)
Frontend: neode-ui/ → builds to web/dist/neode-ui/ → deployed to /opt/archipelago/web-ui/
Backend: core/archipelago/ → Rust binary → deployed to /usr/local/bin/archipelago
AIUI: /Users/dorian/Projects/AIUI/packages/app/ → builds to dist/ → deployed to /opt/archipelago/web-ui/aiui/
Claude Proxy: port 3141 → systemd service claude-proxy
Nginx: port 80 → proxies /rpc/, /ws/, /health, /aiui/
```
## Key Files — Archy Side
## Key Paths
- `neode-ui/src/services/contextBroker.ts` — Message handler, permission checks, data fetching/sanitization
- `neode-ui/src/types/aiui-protocol.ts` — TypeScript types for postMessage protocol
- `neode-ui/src/stores/aiPermissions.ts` — User permission toggles (what AIUI can access)
- `neode-ui/src/views/Chat.vue` — Iframe container with close button
- `neode-ui/src/views/Settings.vue` — AI permissions UI section
- `neode-ui/src/api/rpc-client.ts` — Backend RPC endpoints
- `neode-ui/src/api/container-client.ts` — Container operations
- `neode-ui/src/stores/app.ts` — Main app state (packages, server info, metrics)
## Key Files — AIUI Side (read-only reference, AIUI agent handles these)
- `/Users/dorian/Projects/AIUI/packages/app/src/services/archyBridge.ts` — AIUI's postMessage client
- `/Users/dorian/Projects/AIUI/packages/app/src/composables/useArchy.ts` — Vue composable wrapping archyBridge
- `/Users/dorian/Projects/AIUI/packages/app/src/composables/contentExtraction.ts` — Content tag extraction pipeline
- `/Users/dorian/Projects/AIUI/packages/app/src/composables/useContentPanel.ts` — Content panel state
## Coordination with AIUI Agent
A separate Claude agent is working on the AIUI repo simultaneously. Your job is the **Archy side only**:
- Expand the ContextBroker to serve real data for all categories
- Add new context categories for media, search, and local AI
- Wire up real store/RPC data instead of placeholders
- Deploy and test on the live server at 192.168.1.228
- DO NOT edit files in /Users/dorian/Projects/AIUI/ — the other agent handles that
## Content Handshake Protocol
AIUI's content pipeline uses `[[tag:data]]` syntax in AI responses to surface content. The AI needs context about what's available on the node to generate these tags. The handshake works like this:
1. AIUI sends `context:request` with category (e.g., `media`, `apps`, `files`)
2. Archy's ContextBroker checks permissions, fetches from stores/RPC, sanitizes
3. Returns data to AIUI which injects it into the AI's system prompt
4. AI generates responses with appropriate `[[film:id]]`, `[[song:id]]` tags referencing actual library content
5. AIUI's content extraction pipeline renders the tagged content in panels
- Onboarding views: `neode-ui/src/views/Onboarding*.vue`
- Router: `neode-ui/src/router/index.ts`
- App store: `neode-ui/src/stores/app.ts`
- RPC client: `neode-ui/src/api/rpc-client.ts`
- Container client: `neode-ui/src/api/container-client.ts`
- App manifests: `apps/*/manifest.yml`
- Context broker: `neode-ui/src/services/contextBroker.ts`
- AIUI composable: `/Users/dorian/Projects/AIUI/packages/app/src/composables/useAI.ts`
- Claude proxy: `/Users/dorian/Projects/AIUI/packages/app/server/claude-proxy.ts`
## For each task in loop/plan.md:
1. Find the first unchecked `- [ ]` item
2. Read the task description carefully
2. Read the task description carefully — it tells you exactly what to do
3. Read the relevant source files before making changes
4. Implement following CLAUDE.md conventions (glass styling, TypeScript strict, etc.)
5. Run `cd neode-ui && npm run type-check` — fix all errors before continuing
4. Make the change following CLAUDE.md conventions
5. Run `cd neode-ui && npm run type-check` — fix all errors
6. Run `cd neode-ui && npm run build` — must succeed
7. Deploy to live server: `./scripts/deploy-to-target.sh --live`
8. Commit: `type: description` (conventional commits)
9. Mark it done `- [x]` in `loop/plan.md`
10. Move to the next unchecked task immediately
7. Deploy: `./scripts/deploy-to-target.sh --live`
8. If AIUI files were changed: build AIUI (`cd /Users/dorian/Projects/AIUI/packages/app && node node_modules/vite/bin/vite.js build`) and deploy to server (`tar czf /tmp/aiui.tar.gz -C dist . && sshpass -p 'EwPDR8q45l0Upx@' ssh archipelago@192.168.1.228 'mkdir -p /tmp/aiui-deploy' && sshpass -p 'EwPDR8q45l0Upx@' scp /tmp/aiui.tar.gz archipelago@192.168.1.228:/tmp/aiui-deploy/ && sshpass -p 'EwPDR8q45l0Upx@' ssh archipelago@192.168.1.228 'cd /tmp/aiui-deploy && tar xzf aiui.tar.gz && echo "EwPDR8q45l0Upx@" | sudo -S rsync -a --delete /tmp/aiui-deploy/ /opt/archipelago/web-ui/aiui/'`)
9. Verify the fix works on http://192.168.1.228
10. Mark it done `- [x]` in `loop/plan.md`
11. Commit: `type: description`
12. Move to next task immediately
## Rules
- Never skip a build/typecheck gate — if it fails, fix before moving on
- If a task is proving difficult, make at least 30 genuine attempts before moving on
- Always deploy after completing a task — changes must be live at 192.168.1.228
- Do NOT edit AIUI files — only Archy files
- Build AIUI when needed: `cd /Users/dorian/Projects/AIUI && rm -rf .turbo packages/app/.turbo packages/core/.turbo packages/app/dist packages/core/dist && VITE_BASE_PATH=/aiui/ pnpm build`
- Deploy AIUI dist: `sshpass -p 'EwPDR8q45l0Upx@' scp -o StrictHostKeyChecking=no -r /Users/dorian/Projects/AIUI/packages/app/dist/* archipelago@192.168.1.228:/opt/archipelago/aiui/`
- Do not stop until all tasks are checked or you are rate limited
- Read files before editing — understand before changing
- Never skip build/typecheck — if it fails, fix before moving on
- Always deploy after completing a task — changes must be live
- If a task is proving difficult after 15+ genuine attempts, add `(BLOCKED: reason)` to the task and move on
- Test on the actual server, not just locally
- Do not stop until all tasks are checked or you hit rate limits
- AIUI files are outside the project — use Bash with python3 for edits if the Edit tool is blocked by hooks
- For ISO build: SSH to 192.168.1.228 and run the build script there