Port Centrosome: Electron + Automerge + iCloud → Web + SQLite + WebSocket
The Electron version (initial commit) shipped feature-complete but its
invite/discovery flow was fundamentally broken — adding a userId to the
project doc was meaningless to the invitee until someone manually shared
the iCloud folder with them in Finder. This port replaces the whole sync
substrate with a small server-backed web app:
* Per-project SQLite: /data/projects/<id>.sqlite (FS-level isolation)
* Global SQLite: /data/global.sqlite (users / sessions / invites)
* Fastify + ws gateway (TypeScript, better-sqlite3)
* React frontend (mostly unchanged components) over fetch + WebSocket
* Anthropic API direct from browser using user-supplied key (IndexedDB)
* Invites: owner generates URL, shares out of band
Prototype-grade trade-offs (see PORT-PLAN.md):
* Plaintext API key in IndexedDB (acceptable trust boundary; same as
a logged-in browser is to a local attacker)
* Auth is email-only with no verification (session cookie)
* No Automerge — server is authoritative writer; concurrent file edits
use LWW with the existing "peer updated, reset to current?" warning
* 10 MB cap on binary uploads; 256 KB on text files
* 400k char (~100k token) budget on the system-prompt file context
What stays from the Electron build: every renderer component
(ProjectList, ProjectView, ConversationView with branching DAG, FileViewer
with rename + follow-live + binary preview, InviteControl, MemberList with
presence dots, etc.), the agent loop, tool defs (update_main_file,
create_file, update_file, patch_file), buildSystemPrompt with token
budget, auto-name on first reply, dark-mode theme tokens.
What got deleted: Electron, electron-builder, electron-vite, Automerge,
keytar, chokidar; all of src/main and src/preload; iCloud sync logic and
file-per-actor scheme; conflict-copy reconciliation; presence-via-fs
heartbeat; native-module rebuild dance.