Loading repository data…
Loading repository data…
KeepSerene / repository
Writ — a full-stack, terminal-based agentic AI coding assistant. A pnpm monorepo containing the Bun/opentui TUI client, a Hono API server, a Prisma/Neon database layer, and shared schemas.
Writ is a full-stack, terminal-native AI coding assistant — conceptually similar to tools like OpenCode or Claude Code — built as a personal portfolio project to explore agentic tool-calling, real-time streaming UIs in the terminal, and end-to-end type-safe full-stack TypeScript.
It ships as two cooperating pieces:
packages/cli) — a React-powered Terminal UI (TUI) that runs locally on your machine, renders the chat interface, and executes filesystem/shell tool calls on your own machine.packages/server) — a Hono API that handles authentication, LLM inference across multiple providers, session persistence, billing, and rate limiting.The CLI never talks to LLM providers directly — every request is authenticated, metered, and proxied through the server, which keeps API keys, database credentials, and billing logic entirely off the client.
grep/glob, list directories, and run shell commands, all executed locally in your project's working directory.bash tool, for actually implementing changes./models picker, with per-model provider options (reasoning effort, thinking budgets, parallel tool calls) tuned individually.@-mention file references — type @ to fuzzy-search and reference files/directories from your project directly in a prompt, with path-traversal protection baked in.| Layer | Technology |
|---|---|
| CLI runtime | Bun |
| Terminal UI | @opentui/react — a Zig-native terminal renderer with a React reconciler |
| CLI routing | react-router (in-memory router for screen navigation) |
| Server framework | Hono on Node.js |
| AI orchestration | Vercel AI SDK (ai, @ai-sdk/react) |
| LLM providers | Google Gemini, Groq, Mistral, Cerebras, NVIDIA NIM (via OpenAI-compatible adapter) |
| Database | PostgreSQL (Neon, serverless) |
| ORM | Prisma (v7) with the @prisma/adapter-pg driver adapter |
| Auth | Clerk — OAuth 2.0 Authorization Code + PKCE |
| Billing | Polar.sh — checkout, customer portal, usage metering |
| Validation | Zod |
| Observability | Sentry (errors, tracing, profiling) |
| Package manager | pnpm workspaces |
| Server build | tsup (bundling) / tsx (dev) |
| CLI build | Bun's native bundler |
writ/
├── packages/
│ ├── cli/ # Terminal UI client (Bun + opentui/react)
│ │ └── src/
│ │ ├── components/ # Chat messages, dialogs, command menu, prompt area
│ │ ├── hooks/ # useAppChat, useCommandMenu
│ │ ├── layouts/ # Root layout, app shell
│ │ ├── lib/ # API client, auth, OAuth, billing, themes, utils
│ │ ├── providers/ # Theme, toast, dialog, input-stack, session context
│ │ ├── screens/ # Home, new-session, session
│ │ └── tools/ # Local tool executors (bash, file ops, search)
│ │
│ ├── server/ # Hono API (deployed to Render.com)
│ │ └── src/
│ │ ├── routes/ # sessions, chat, billing, oauth-callback
│ │ ├── middlewares/ # auth, compute-credit & portfolio-quota gating
│ │ ├── lib/ # Clerk auth, Polar billing, model resolver, system prompt
│ │ └── views/ # Landing page
│ │
│ ├── db/ # Prisma schema, generated client, Neon connection
│ ├── shared/ # Shared Zod schemas, tool contracts, model registry
│ └── assets/ # Logo & favicon
│
├── pnpm-workspace.yaml
├── package.json # Root workspace scripts
└── .env.example
/auth/callback route, and stores the resulting access token locally at ~/.writ/auth.json (file permissions 0600).POST /sessions/:sessionId/chat on the server, authenticated via the Clerk-issued bearer token.streamText from the AI SDK.readFile, bash), the CLI — not the server — executes it locally inside the user's own project directory, then reports the result back into the conversation.No cloning required — the CLI is published to npm and runs anywhere Bun is installed:
# Install Bun, if you don't already have it
curl -fsSL https://bun.sh/install | bash
# Run Writ
bunx @keepserene/writ
Note: The hosted demo runs against a shared free-tier deployment with a quota — see that section for details and how to self-host with your own API keys for unlimited use.
**Prerequisi
End-to-end via Hono's RPC client (hc) — the CLI imports the server's route types directly |
| Hosting | Render.com (server) · npm (CLI distribution) |