About this project

## Overview `prod-code` is a remote code intelligence server designed for fleets of AI coding agents. It moves language analysis, builds, and tests off the developer's laptop and onto a LAN node, while keeping the editing experience local. The system mirrors checkouts to a gateway that maintains warm analyzers (rust-analyzer in-process; gopls, clangd, TypeScript, pyright, sourcekit-lsp as children) and executes commands there. Agents access it via MCP tools, and editors can use it as a drop-in language server. ## Key Features - **Remote analysis**: Language servers run on a LAN node, not the laptop, reducing local CPU and memory load. - **MCP integration**: Exposes tools to AI agents (Claude, Codex, Gemini) via Model Context Protocol. - **Editor support**: Works as a language server for editors like Zed, with protocol bridging for settings and save events. - **Multi-language**: Supports Rust, Go, C/C++, TypeScript/JavaScript, Python, and Swift. - **Safe refactoring**: Tools for semantic rename, signature changes, move, extract, and more, with validation on a second analyzer. - **Build/test execution**: Commands run on the node with warm caches; results and file changes sync back. - **Cluster support**: Multiple nodes can gossip and distribute workspaces based on load and language support. ## Tools for Agents The MCP server provides a comprehensive set of tools: - **Find code**: `code_search`, `code_symbols`, `code_definition`, `code_references`, `code_callers`, `code_callees`, `code_implementations`, `code_supertypes`, `code_outline`, `code_source`. - **Understand**: `code_slice`, `code_hover`, `code_type_at`, `code_impact`, `code_dead_code`, `code_prune_orphans`. - **Change safely**: `code_validate_edit`, `code_diagnostics`, `code_rename`, `code_safe_delete`, `code_change_signature`, `code_move`, `code_extract_function`, `code_introduce_parameter_object`, `code_migrate_type`, `code_generify`, `code_invert_boolean`, `code_make_static`, `code_inline_parameter`, `code_extract_delegate`, `code_extract_trait`, `code_loop_to_iterator`, `code_introduce_variable`, `code_convert_to_method`, `code_wrap_return`, `code_extract_field`, `code_encapsulate_field`, `code_schema_rename`, `code_assists`, `code_codemod`, `code_generate_fixture`, `code_shadow_run`. - **Run**: `code_check`, `code_lint`, `code_test`, `code_benchmarks`, `code_exec`, `code_diagnose_failure`. - **Operate**: `code_status`, `code_sync`. All position-based tools also accept a `symbol` argument instead of file/line, so agents don't need to grep for line numbers. ## How It Works - **Mirrored checkouts**: First contact sends a manifest of paths, sizes, and hashes; the gateway seeds a worktree from the origin repo and syncs only missing files. Subsequent syncs use watermarks and diffs. - **One analyzer per worktree**: Each git worktree gets its own server workspace and database, preventing cross-contamination. Engines stay resident until idle for 30 minutes. - **Validation on a second analyzer**: Edit proposals are checked on a separate engine to avoid polluting the main analyzer's state. - **Builds and tests on the node**: Commands run in the workspace's own `target/` directory, keeping caches warm. Changed files are written back to the checkout. - **Cluster gossip**: Nodes gossip every 5 seconds; a client needs one seed address. Placement considers existing holdings and load. ## Installation ```sh # Client (one binary; the gateway is the same binary's sibling) cargo install --path crates/prod-code-client # Register with Claude claude mcp add --scope user prod-code -e PROD_CODE_REMOTE=192.0.2.10:9400 -- prod-code mcp # Register with Codex codex mcp add prod-code --env PROD_CODE_REMOTE=192.0.2.10:9400 -- prod-code mcp # On a node prod-code-server --bind 0.0.0.0:9400 --storage /srv/prod-code/workspaces \ --advertise <this host>:9400 --peers <other nodes> ``` ## Editor Usage `prod-code lsp` acts as an editor's language server. The language's own server runs on the node, and the bridge carries the protocol both ways. For Zed, there's a dedicated extension in `editors/zed`, or you can point Zed's rust-analyzer at `prod-code lsp --language rust`. ## Configuration Per-repository options can be set in a `prod-code.toml` at the checkout root, e.g., Rust feature flags, sysroot usage, and target selection. ## Metrics and Operations Every query, command, and sync round is logged as an event (agent, host, workspace, method, duration, success) to a JSONL file. `prod-code metrics` aggregates across the cluster with p50 and p95. A deploy script for macOS nodes handles signing and launchd setup. ## Field Evaluations The project includes evaluations against prominent open-source repositories (ripgrep, tantivy, tokio, polars, uv, bevy, prometheus, kubernetes, etcd, django, black) using a standardized 67-tool protocol, with detailed blog reports linked. ## Requirements Building requires Rust 1.95.0 or newer. Install with rustup: ```sh rustup toolchain install 1.95.0 --profile minimal -c rustfmt -c clippy ``` ## License MIT / Apache-2.0 dual-licensed.