g-butandClaude Sonnet 4.6 f8bdd3eb8e refactor(dry): extract groupCompletionsByHabit helper in habits.ts
The 4-line Map<habitId, Set<completedDate>> construction appeared in both
listHabitsForToday and getHabitHeatmapData. Extracted to a shared helper.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 15:34:36 +02:00
2026-04-04 22:47:22 +02:00
2026-04-04 22:47:22 +02:00
2026-04-04 22:47:22 +02:00
2026-04-04 22:47:22 +02:00

Cockpit

Cockpit is a multi-user dashboard for running AI agent fleets across projects, with life-OS views layered into the same interface. Users sign in with GitHub, register projects, launch and monitor agents, and keep goals, people, habits, money, and events in one place.

Stack

  • Next.js 16 (App Router, Server Components, Server Actions)
  • TypeScript strict — schema is SSOT for types via Drizzle's $inferSelect / $inferInsert
  • Tailwind CSS 4 + shadcn/ui
  • NextAuth v5 beta with GitHub OAuth
  • Drizzle ORM on PostgreSQL 17
  • zod validation at API boundaries

Views

Route What's there
/ Landing page with sign-in entry
/setup Bootstrap flow when no users exist yet
/sign-in GitHub sign-in
/today Calendar, weather, commitments, bills, daily habit check-off
/control Agent fleet command center and orchestration status
/projects Projects, repo health, sync actions, inline editing
/goals Hierarchical goals, milestones, inline target/progress edit
/people Contacts, search, detail panel, inline name/notes edit
/habits 30-day heatmap per habit, streak indicator, summary stats
/events Opportunities and deadlines, filter chips, archive flow
/money Subscriptions and monthly burn
/prompts Prompt library, run-now flow, scheduler
/system Runtime health, uptime, autopilot jobs
/thoughts Published essays on architecture and execution systems
/settings Profile and team invite management
/u/[username] Public user profile
/invite/[token] Invitation acceptance flow

Architecture

src/
├── app/             Pages, auth flows, and API routes
├── components/
│   ├── ui/          Shared primitives and layout helpers
│   ├── shell/       App shell, navigation, shared chrome
│   ├── control/     Agent fleet controls and project cards
│   └── <domain>/    today, people, projects, goals, money, habits, events,
│                    prompts, settings, system
├── config/          SSOT for navigation, channels, prompt library, subscriptions
├── db/
│   ├── schema/      Drizzle tables and inferred types
│   └── queries/     Data access functions by domain
├── hooks/           useFetch, useCreateMutation, useInlineEdit
└── lib/             constants, auth/session helpers, dates, tools, utils

Setup

Set these required environment variables in .env.local:

DATABASE_URL=postgresql://localhost/cockpit
AUTH_SECRET=replace-me
AUTH_GITHUB_ID=replace-me
AUTH_GITHUB_SECRET=replace-me

Postgres needs a local cockpit database. Then push the schema:

DATABASE_URL=$YOUR_URL npx drizzle-kit push

On a fresh clone, visit /setup to create the first user. After that, GitHub OAuth handles sign-in.

The seed script (scripts/seed.ts) reads from local personal data sources under ~/.openclaw/*. A fresh clone will not have those files, so schema-only setup is the default path. To populate with real data, either:

  • Provide the ~/.openclaw/* files yourself, then run DATABASE_URL=$YOUR_URL npx tsx scripts/seed.ts, or
  • Add rows directly via the Cockpit UI against an empty database.

Dev Commands

npm run dev          # Start the dev server on :3000
npm run build        # Production build (uses real DB connection)
npm run smoke        # Curl every page + DB-backed GET API and assert 2xx/3xx
npm run lint         # ESLint

A husky pre-commit hook runs tsc --noEmit and eslint src/ automatically. Smoke is opt-in (needs the dev server running) — run before opening a PR. CI on push to main and every PR runs the same type+lint checks; a daily Audit workflow surfaces new high-severity CVEs in the dep graph.

Working in the repo

CLAUDE.md at the project root is the contract for AI agents and the rule book for non-obvious decisions: SSOT rules, naming conventions, data-flow boundaries, security patterns. Read it before making substantive changes.

For orchestration architecture and migration direction, also read:

  • docs/architecture-first-principles.md
  • docs/debt-reduction-roadmap.md
  • docs/openclaw-orchestration-plan.md
Languages
TypeScript 88.6%
Shell 7.3%
CSS 2.3%
JavaScript 1.6%
Python 0.1%