How cluesmith/codev works
1. Repository shape
- This is a TypeScript monorepo for a human-AI development platform, not a single app.
- The main runtime packages are packages/codev (CLI/orchestration), packages/dashboard (web UI), packages/vscode (editor extension), packages/core (shared logic), and packages/types (API/SSE/WebSocket contracts).
2. Top-level product boundary
- Codev’s core idea is “specs first”: human-authored context lives in codev/ or codev-skeleton/, then AI agents consume those documents to produce plans, implementations, reviews, and retrospectives.
- The repo therefore has two distinct layers: the tooling/runtime and the knowledge/process artifacts that guide work.
3. CLI and orchestration layer
- packages/codev is the main distribution package and exposes the user-facing commands (codev, afx, consult, porch, team).
- This package orchestrates project initialization, adoption into existing repos, consulting, spawning builders, and protocol-driven workflows.
4. Agent Farm / afx subsystem
- The largest subsystem is packages/codev/src/agent-farm, which manages autonomous builders and the “architect-builder” workflow.
- It includes command handlers, local state, a SQLite-backed DB/migrations, terminal/session management, worktree handling, spawning, sending instructions, cleanup, cron/tower support, and server endpoints for the dashboard.
- Its main boundary is between local process/worktree control and UI/API surfaces that display or manipulate those sessions.
5. Terminal and shell process model
- Agent Farm persists AI sessions via “shellper” terminal processes in packages/codev/src/terminal and related agent-farm utilities.
- The shell layer is an isolation boundary: each builder gets its own terminal/session and typically its own git worktree, allowing parallel execution with limited interference.
6. Dashboard frontend
- packages/dashboard is a Vite/React UI that visualizes the current workspace, builders, terminals, backlog, PRs, team state, open files, analytics, and alerts.
- It communicates with the Agent Farm backend through SSE and related API endpoints, and it owns the interactive presentation boundary for humans.
7. VS Code extension
- packages/vscode is a separate integration layer that embeds Codev workflows inside the editor.
- It connects to the same backend state and events, adds commands for spawn/send/review/worktree handling, and mirrors parts of the dashboard via VS Code views, terminal adapters, and link providers.
8. Shared domain logic
- packages/core holds reusable non-UI business logic such as agent naming, area grouping, auth, workspace helpers, and builder utilities.
- packages/types defines the contracts for HTTP APIs, SSE events, and websocket messages so the CLI, dashboard, and extension stay aligned.
9. Protocols and content-driven workflows
- codev/protocols and codev-skeleton/protocols define the lifecycle documents and prompts for workflows like spir, air, bugfix, maintain, research, spike, and release.
- These are not just docs; they are the control plane for AI behavior, supplying protocol JSON, builder prompts, consult types, and templates for specs/plans/reviews.
10. Project-local artifacts
- The codev/ tree stores real project history: specs, plans, reviews, maintain logs, project state, and team notes.
- codev-skeleton/ is the installable template that seeds a new project with the same structure, protocols, roles, prompts, and reference docs.
11. External integrations
- The system integrates with Git providers through shell-based forge adapters for GitHub, GitLab, Gitea, and Linear, primarily to read issues/PRs, comment, merge, and inspect state.
- It also integrates with AI CLIs/models such as Claude Code, Gemini, Codex, and optionally OpenCode, which are treated as pluggable builder/architect shells.
- Cloud/tower support adds remote access and registration flows for running the dashboard and builders off-machine.
12. Data flow from idea to merge
- The normal flow is: issue/spec → protocol documents → spawn builder in isolated worktree → builder writes code/tests → review/consultation gates → PR creation/merge.
- Human oversight happens mostly at document review and approval points; the runtime emits status, terminal output, and workspace state back to dashboard/VS Code.
13. State and persistence boundaries
- Runtime state is split between durable docs in git, local operational state in SQLite/config files, and ephemeral terminal/session processes.
- That separation matters architecturally: knowledge is versioned in the repo, while execution state is local and recoverable.
14. Tooling and verification
- The repo is heavily tested with Vitest for unit/integration logic and Playwright for end-to-end flows, especially Agent Farm and dashboard behavior.
- CI workflows, scripts, and release machinery are part of the operational boundary, ensuring the CLI, UI, and extension stay coordinated across packages.
Main entry points: agent-farm Agent Farm · cli.ts Codev CLI · App.tsx Dashboard · extension.ts VS Code ext
Components 18
Runtime packages
CLI, orchestration, UI, editor integration, and shared contracts.
- Codev CLI · User-facing commands and top-level orchestration for init, adopt, consult, porch, team, and afx.
packages/codev/src/cli.ts - Agent Farm · Autonomous builder workflow, session control, local state, and dashboard/server surfaces.
packages/codev/src/agent-farm - Terminal shellper · Isolated shell/session model for persistent AI processes and worktree-bound execution.
packages/codev/src/terminal - Porch workflows · Protocol-driven lifecycle for specify, plan, implement, review, and PR-gated advancement.
packages/codev/src/commands/porch - Consult tool · Stateless consultation path for reviews, metrics, and PR-oriented guidance.
packages/codev/src/commands/consult - Dashboard · Vite/React workspace view for builders, terminals, backlog, PRs, alerts, and analytics.
packages/dashboard/src/components/App.tsx - VS Code ext · Editor-side commands, views, terminal adapters, and link providers over the shared backend.
packages/vscode/src/extension.ts - Shared core · Reusable business logic for names, grouping, auth, workspace, and builder helpers.
packages/core/src - API contracts · Shared request/event/message contracts for CLI, dashboard, and extension alignment.
packages/types/src
Repo knowledge
Project-local specs, protocols, prompts, and durable workflow artifacts.
- Protocols · Protocol schemas, prompts, consult-types, and templates that define AI behavior.
codev/protocols - Project docs · Durable specs, plans, reviews, maintain logs, team notes, and project state in git.
codev - Skeleton · Installable starter tree that seeds new repos with the same workflow structure.
codev-skeleton
External integrations
Forge, AI CLI, and cloud/tower boundaries used by the runtime.
- Forge adapters · Shell adapters for GitHub, GitLab, Gitea, and Linear issue/PR operations.
packages/codev/scripts/forge - AI shells · Pluggable builder/architect shells for Claude, Gemini, Codex, and optional OpenCode.
packages/codev/src/commands/consult - Tower/cloud · Remote access, registration, tunnel, websocket, and daemon flows for off-machine use.
packages/codev/src/agent-farm/servers/tower-server.ts
Tooling
Tests, CI, and release workflows that keep the platform coordinated.
- CLI tests · CLI, porch, consult, terminal, and agent-farm test coverage.
packages/codev/src/__tests__ - UI tests · Dashboard and VS Code component, hook, and end-to-end verification.
packages/dashboard/__tests__ - CI release · GitHub workflows, scripts, hooks, install, and release automation across the monorepo.
.github/workflows
Connections 27
- Codev CLI → Agent Farm: drives builders · The CLI dispatches afx/agent-farm commands for spawning, sending, cleanup, status, and team flows.
- Codev CLI → Porch workflows: runs protocols · Porch commands implement lifecycle execution for specs-first workflows.
- Codev CLI → Consult tool: offers consult · Consult is a user-facing command surface for reviews and advisory flows.
- Codev CLI → Forge adapters: uses forge · CLI operations read and update Git provider state through shell adapters.
- Codev CLI → AI shells: invokes models · Builder and consultation execution is delegated to external model shells.
- Agent Farm → Terminal shellper: manages sessions · Agent Farm owns shellper/pty session lifecycle and builder isolation.
- Agent Farm → Dashboard: serves state · Dashboard views consume Agent Farm server endpoints and live events.
- Agent Farm → VS Code ext: streams events · VS Code subscribes to the same workspace/session state and commands.
- Agent Farm → Shared core: shares logic · Name grouping, auth, workspace helpers, and builder utilities are shared.
- Agent Farm → API contracts: emits contracts · HTTP, SSE, and websocket payloads are defined by shared types.
- Terminal shellper → Tower/cloud: remote shell · Terminal sessions can be mirrored or controlled through tower/remote flows.
- Porch workflows → Protocols: loads workflow docs · Protocol JSON, prompts, consult-types, and templates define each workflow stage.
- Project docs → Protocols: contain prompts · The repo-local docs and state are the durable content consumed by protocols.
- Skeleton → Protocols: seeds protocols · The skeleton copies the same protocol and template structure into new projects.
- Dashboard → API contracts: consumes events · The UI is bound to the shared API/SSE contract.
- Dashboard → Shared core: uses helpers · Dashboard presentation and grouping reuse shared domain helpers.
- VS Code ext → API contracts: consumes events · The extension stays aligned through the same API and event contracts.
- VS Code ext → Shared core: uses helpers · Editor-side grouping, workspace, and auth logic reuse shared code.
- Forge adapters → Project docs: updates issues · Forge adapters connect external issue/PR state back into repo workflows.
- AI shells → Protocols: follow prompts · Model shells execute protocol-specific prompts and templates.
- Tower/cloud → Dashboard: feeds UI · Remote runtime state is surfaced in the dashboard presentation layer.
- CLI tests → Codev CLI: verifies · Vitest and e2e tests cover command behavior and orchestration.
- UI tests → Dashboard: verifies · Component and end-to-end tests cover the UI boundary.
- UI tests → VS Code ext: verifies · Extension tests validate commands, views, and workspace integration.
- CI release → CLI tests: runs · CI gates CLI and integration test suites.
- CI release → UI tests: runs · CI gates dashboard and extension test suites.
- CI release → Project docs: ships docs · Release and maintenance workflows keep repo docs and artifacts in sync.