Second milestone of the greenfield rewrite. A standalone Node HTTP server
in home/ that boots, tails ~/.<APP_SLUG>/events.jsonl, projects each event
into per-project state, and serves a minimal status UI at localhost:3001.
No external deps beyond node:* and the existing zod via @/lib/events.
home/state.ts pure applyEvent(state, event) → state — testable in
isolation; project view stays minimal (currentRun,
lastHandoff, recentOutcomes ≤ 5) for M2
home/log.ts tail one JSONL file via fs.watch + position tracking;
replays existing content on boot, recovers from file
truncation, returns parse errors via onError instead of
throwing (so a garbled line doesn't kill the daemon)
home/server.ts HTTP server with /control HTML view + /api/state +
/api/health + /api/events (manual append for testing).
Vanilla JS in the HTML, no React yet — that lands when
the brain replaces the existing /control surface.
End-to-end verification (against ~/.cockpit/events.jsonl):
- worker.started → project appears with running pill
- worker.finished → pill clears, outcome glyph ✓ in streak,
handoff text shown
tsconfig.json includes home/**/*.ts so the existing tsc + eslint gates
cover the new code. Runs separately from the Next.js app — no port
collision, no Vercel involvement, no DB needed.
What this commit deliberately does NOT do:
- emit events (M4 — replace the agent stop-hook to append to the log)
- decide (M5 — pure decide() function over state)
- dispatch (M6 — wire bridge.dispatch back to a worker)
- persist beyond the log (state rebuilds from log replay on boot)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
First-run flow:
- /setup page + /api/setup: creates first user with hashed password
(Node crypto scrypt, no new deps). POST rejects if users already exist.
- Landing page redirects to /setup when DB has no users
- middleware.ts: protects app routes, passes public pages through
Auth:
- passwordHash column added to users schema (drizzle-kit push applied)
- src/lib/password.ts: hashPassword/verifyPassword via Node scrypt
- auth.ts Credentials: env var takes priority, falls back to DB hash
so packaged installs work without LOCAL_AUTH_PASSWORD
Multi-tenancy groundwork:
- Replaced DEFAULT_USER_ID with getCurrentUserId() across all 12 API
route files (people, subscriptions, events, goals, projects, commitments)
Docker:
- Dockerfile: multi-stage Node 22 alpine, standalone output
- docker-compose.yml: postgres + migrate + app services
- .dockerignore, .env.example with documented required vars
- next.config.ts: output: standalone
- package.json: added migrate script (drizzle-kit push)
- tsconfig.json: scope to src/ only, exclude .next generated files
Install: clone → cp .env.example .env.local → docker-compose up
First visit → /setup → create account → sign in → done.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>