This file provides guidance to agents when working with code in this repository.
For a general overview of the project and high-level direction, please see @docs/VISION.md.
All dependencies (D compiler, Node.js 22, npm, etc.) are provided by Nix.
Use nix develop -ic to prefix commands, or enter nix develop interactively.
One-time setup:
git config core.hooksPath .githooks # Enable pre-commit checksBuild & run:
nix develop -ic dub build # Build backend → build/cydo
nix develop -ic env -C web npm ci # Install frontend deps
nix develop -ic env -C web npm run build # Build frontend → web/dist/
nix develop -ic dub run # Build + run backend (serves on :3940)Production build (sandboxed, no incremental):
nix build # Build the full applicationTesting:
nix flake check # Run all tests — the single "all tests pass" command
nix develop -ic env -C tests playwright ... # Invoke Playwright directlynix flake check is the mandatory gate before handing any work to the user.
This applies after every unit of work — not just git commit, but also
git commit --amend, git rebase, or any other operation that changes the
tree. No work is considered complete until the full suite passes.
- If a test fails and the failure looks flaky (non-deterministic, unrelated to
your changes), retry with
nix --option keep-going true flake check. If it fails consistently, treat it as a real regression and fix it before proceeding. --no-verifyis BANNED. Never use it to bypass the pre-commit hook or any other check. Thenix flake checkgate is non-negotiable.- Do not skip or substitute with partial checks.
Formatting:
cd web && npm run fmt # Run prettier on frontend sources- Prefer
type(scope): imperative summaryin lowercase when a conventional type fits, for examplefix(codex): align mock text streaming with current protocol. - Choose a conventional type that best matches the change instead of inventing alternate subject formats.
- Keep the subject concise, imperative, and without a trailing period.
- Leave a blank line before the body. Use the body to explain what changed and why, and wrap it at roughly 72 columns.
- Split unrelated changes into separate commits instead of combining them under one message.
Tests are Playwright e2e specs (tests/e2e/) that run against a mock LLM API server (tests/mock-api/server.mjs).
CyDo wraps Claude Code CLI (claude --input-format stream-json --output-format stream-json) and other agentic coding software (Codex, Copilot) in a web UI with WebSocket-based real-time streaming, multi-session management, and SQLite persistence.
Single-threaded async event loop (ae.net.asockets.socketManager). Serves HTTP on port 3940.
source/cydo/app.d— Entry point: HTTP server, WebSocket handler, session routing, message broadcastingsource/cydo/agent/claude.d— SpawnsclaudeCLI process, formats NDJSON input, handles output streamsource/cydo/agent/process.d— Wraps posix pipes/signals, async I/O viaFileConnection/Duplex/LineBufferedAdaptersource/cydo/agent/session.d—AgentSessioninterface (sendMessage, interrupt, stop, callbacks)source/cydo/storage/persistence.d— SQLite persistence (sessions table, session history loading from Claude's JSONL files)
Key ae modules used: ae.net.http.*, ae.net.asockets, ae.sys.process, ae.sys.database, ae.utils.json.
All source in web/src/. Pure functional components with hooks.
useSessionManager.ts— Central custom hook: WebSocket connection, session state map, message dispatchsessionReducer.ts— Pure reducers for processing Claude output into display state- Protocol DTOs are authored in
source/cydo/protocol/package.d, generated intoweb/src/generated/protocol.ts, and assembled into the frontend event union inprotocol.ts connection.ts— WebSocket client classansi.ts— ANSI escape sequence parser for colored Bash outputhighlight.ts— Shiki-based syntax highlighting for code blocks- Components:
SessionView,Sidebar,MessageList,InputBox,AssistantMessage,UserMessage,ToolCall,Markdown,SystemBanner
- Browser sends WebSocket JSON
{type: "message", sid, content}to backend - Backend writes NDJSON to claude's stdin
- Claude outputs NDJSON on stdout
- Backend wraps each line with
{sid, timestamp, event}envelope and broadcasts to all WebSocket clients - Frontend reducers process events into renderable state
- Sessions tracked in SQLite (
sessionstable: sid, claude_session_id) - Session history loaded from Claude's own JSONL files at
~/.claude/projects/<path>/<uuid>.jsonl - Resume via
claude --resume <uuid>
Test against real software, not mocks. Integration tests must exercise the
actual agent binaries (Claude CLI, Codex CLI, Copilot CLI) via the HTTPS proxy
infrastructure in tests/mock-api/. Mocks of the agent binary itself are not
acceptable — they mask real integration issues. The proxy intercepts API traffic
(LLM completions, auth, models) while letting the real binary handle protocol
framing, startup, and session management.
Test real user interactions, not low-level details. E2e tests should exercise the full stack (frontend, backend, agent binary, LLM API), rather than narrow scoped slices. Do not use WebSocket packet injection or agent software mocking.