$ show codewhale-hq/Codewhale
Codewhale is an open-source, terminal-native AI coding agent that operates as a TUI (ratatui), CLI, headless runtime, MCP server, and a web frontend. It manages full development workflows: reading repositories, editing files, running commands, reviewing changes, and orchestrating multi-agent fleets. The codebase is a Rust monorepo with ~52 crates, a Next.js website with 18+ locales, a VS Code extension, packaging for npm/Homebrew/Arch/Windows, and companion pet apps. The architecture is event-driven with a pluggable tool system, model-agnostic provider routing, session-based journaling, and a contract-based command framework. It supports dozens of LLM providers (DeepSeek, OpenAI, Anthropic, Ollama, etc.) and features sandboxed execution, telemetry with a strict no-IP privacy contract, and a plugin marketplace. The project is heavily tested with unit, integration, PTY/Cucumber, and hermetic bash tests, and enforces budgets for dead code and blocking calls.
The LLM identified 5 files worth highlighting for reuse:
Defines a generic contract for registering commands via typed metadata, facets, and handlers. Commands expose capabilities, assistance, and context requirements; handlers receive a structured CommandContexts. This pattern enables unit-testing commands without a live TUI and could be extracted to any Rust project needing a plugin-style command system.
A deterministic cell-by-cell rendering assertion harness for ratatui TUIs. It writes the TUI buffer to a golden file, compares byte-for-byte, and supports a bless protocol (CODEWHALE_BLESS_GOLDENS). Isolated from the rest of the TUI, it can be reused in any ratatui project that needs battle-tested visual regression testing.
Implements a generic ranked configuration resolution with provenance tracking. Six layers (policy, cli, session, project, user, default) are merged via merge_maps and resolve_scalar, returning a ResolveOutcome with a provenance path list. Extractable to any Rust project needing multi-source config with auditing.
Provides a generic bounded body reader and URL-encoded form parser that enforces byte limits (default 5MB) and field length constraints. Includes test coverage for empty bodies, oversized fields, and multipart boundaries. Can be dropped into any web framework (Next.js, Express, etc.) to prevent resource exhaustion on request bodies.
A thread-safe LRU cache for compiled regular expressions with configurable capacity (default 128 entries). Uses a reader-writer lock and provides get_or_init to lazily compile new regexes. Lightweight and dependency-aware (tracks regex creation to avoid GC contention). Reusable in any Rust application that dynamically compiles user-provided regexes.