Monorepo Structure
Craft Agents is organized as a Bun-powered monorepo using workspace packages. The codebase is split into two main directories:The monorepo uses workspace packages (
workspace:*) to share code between apps and packages without publishing to npm.Apps vs Packages
Apps Directory
Contains user-facing applications:electron/- Primary desktop application built with Electron, React, and Viteviewer/- Web-based session sharing viewer for public session links
Packages Directory
Contains reusable libraries and internal services:| Package | Purpose |
|---|---|
@craft-agent/core | Shared TypeScript types and interfaces |
@craft-agent/shared | Business logic (agent, auth, config, MCP) |
@craft-agent/ui | Shared React components with shadcn/ui |
@craft-agent/pi-agent-server | Out-of-process Pi agent server |
@craft-agent/session-mcp-server | MCP server for session introspection |
@craft-agent/session-tools-core | Core session tool definitions |
Learn More
Deep dive into the packages architecture and exports
Tech Stack
Craft Agents is built with modern, high-performance technologies:Runtime & Build
Desktop & UI
AI & Agent SDKs
Claude Agent SDK
Powers Anthropic, OpenRouter, and custom endpoints
Pi SDK
Powers Google AI Studio, ChatGPT Plus, and GitHub Copilot
| Technology | Usage |
|---|---|
| @anthropic-ai/claude-agent-sdk | Claude-based agent backend |
| @mariozechner/pi-coding-agent | Pi-based agent backend |
| @modelcontextprotocol/sdk | MCP server integration |
Agent Backends
Learn how Craft Agents routes between Claude and Pi backends
Key Technologies
Electron Architecture
Craft Agents uses Electron’s multi-process architecture:- Main Process - Node.js backend with full system access
- Renderer Process - Chromium frontend (isolated, sandboxed)
- Preload Scripts - Context bridge between main and renderer
Electron Deep Dive
Explore IPC channels, window management, and build process
Configuration Storage
All user data lives in~/.craft-agent/:
Why not a database?
Why not a database?
File-based storage keeps the architecture simple and agent-editable. The agent can directly read and modify its own configuration using filesystem tools, making it truly “agent-native software.”
Credentials Security
All sensitive credentials (API keys, OAuth tokens) are stored in an AES-256-GCM encrypted file at~/.craft-agent/credentials.enc. The encryption key is derived from system-specific entropy.
Session Persistence
Sessions are stored as JSONL files (JSON Lines format):- One line per message
- Streaming-friendly (append-only)
- Easy to debug and inspect
- Portable across systems
Development Workflow
Debug Logging
Logs are automatically written in development:- macOS:
~/Library/Logs/@craft-agent/electron/main.log - Windows:
%APPDATA%\@craft-agent\electron\logs\main.log - Linux:
~/.config/@craft-agent/electron/logs/main.log
-- --debug flag to enable verbose logging in production builds.
Next Steps
Electron App
Main/preload/renderer processes and IPC
Packages
Core and shared package exports
Agent Backends
Claude vs Pi SDK routing