code-assistant
AGENTS.md182 starsChanged 5 months agoMITView on GitHub
Additional documentation is available in the docs folder if needed. This is a Rust-based AI coding agent harness with multiple operational modes.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 86
Use tools::test_registry() (exported under test-utils) for deterministic tool tests
- Very specific: line 132
Use Entity<T>. This replaces Model<T> and View<T> which no longer exist and should NEVER be used.
- Very specific: line 133
Use App references. This replaces AppContext which no longer exists and should NEVER be used.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Repository Guidance
This file provides guidance to AI agents when working with code in this repository.
Additional documentation is available in the docs folder if needed.
Essential Commands
cargo check- Test if the project compilescargo check --tests- Test if the tests compilecargo test- Run all testscargo test --package <crate>- Test a single crate (names in Crate Layers below)cargo fmt --all -- --check- Check code formattingcargo clippy --all-targets --all-features -- -D warnings- Run linter
Architecture Overview
This is a Rust-based AI coding agent harness with multiple operational modes.
Crate Layers
Layer 0 (generic): llm command_executor pty_session fs_explorer sandbox web git terminal terminal_output
Layer 1 (generic): tools_core — tool trait, registry, render, spec, permissions
mcp_client — wraps MCP server tools as registry tools
Layer 2 (generic): agent_core — agent loop, hook traits, dialect trait, AgentUi trait
Layer 3 (domain): code_assistant_core — sessions, SessionService, event stream, UiEvent,
tool impls, dialects (xml/caret), plugins, sub-agents
Layer 4 (frontends): ui_gpui ui_terminal ui_acp mcp_server
Layer 5 (binary): code_assistant — CLI, config, feature-gated frontend wiringKey Entry Points
- Agent loop:
crates/agent_core/src/runtime.rs - Domain agent wrapper:
crates/code_assistant_core/src/agent/runner.rs - Tool implementations:
crates/code_assistant_core/src/tools/ - Tool dialects (xml/caret):
crates/code_assistant_core/src/tool_dialects/ - Plugins/hooks:
crates/code_assistant_core/src/plugins/ - Session management:
crates/code_assistant_core/src/session/ - MCP client config/registration binding:
crates/code_assistant_core/src/tools/mcp.rs
Tool Architecture
ToolRegistryis an instance, not a singleton;ToolSpeccarries capability tags (e.g.read_only)- Tool modes (configured per agent instance via
ToolDialect):native— LLM provider's native tool calling (default inagent_core)xml— XML-based tool syntax in system messagescaret— triple-caret-fenced tool syntax in system messages
LLM Integration (crates/llm/)
- Multi-provider support: Anthropic, OpenAI, Google Vertex, Ollama, OpenRouter, AI Core
- Recording/playback system for debugging and testing
- Configurable context windows and model selection
Configuration
MCP Client Mode
- Connects to MCP servers configured in
<config_dir>/mcp-servers.json(stdio or HTTP, via thermcpSDK) and registers their tools in theToolRegistryasmcp__<server>__<tool>; projects can add servers in a.mcp.jsonat the project root - The registry is rebuilt from the current config at the start of every
agent run (
ToolRegistryProviderseam) - Details:
docs/mcp-client-mode.md,docs/project-scoped-mcp-servers.md
Permission Tiers
- Per-session setting deciding when the agent asks before running a tool:
bypass-all(default),write-tools(ask for anything not taggedread_only),all-tools(ask always) - Gate lives in the agent loop (
tools_core::ToolPermissions); prompts go through thePermissionMediatorseam; seedocs/permission-tiers.md
Session Lifecycle
- Visits and settlement per session live in
sessions/lifecycle.json, never in the session file (code_assistant_core::session::lifecycle) - The GPUI sidebar switches between an inbox (unsettled sessions across
projects) and project folders (all sessions, folders in a stable,
draggable order); rows derive a
SessionStatusfrom activity state plus open permission requests - Sessions settle by hand, after N idle days, or when their branch is
merged (
SessionService::sweep_lifecycle); seedocs/session-lifecycle.md
Development Notes
Testing
- Unit tests distributed across modules; integration tests in
crates/code_assistant/src/tests/ - Mock implementations in
code_assistant_corebehind thetest-utilsfeature - Use
tools::test_registry()(exported undertest-utils) for deterministic tool tests
UI Development
- GPUI frontend based on gpui-kit (gpui via
gpui_kit::*, gpui-component viagpui_kit::component) with custom components - GPUI API reference (contexts, entities, tasks, elements, actions, events):
docs/gpui-reference.md - The right panel shows the agent's browser live (CDP screencast, feature
browser-panel, default):docs/browser-panel-plan.md. GPUI must not run inside a tokioblock_on(tokio's cooperation budget would never renew on the main thread), somainis not#[tokio::main] - Frame profiling of the GPUI frontend (opt-in via
CODE_ASSISTANT_FRAME_PROFILE, sweep runner andsampleanalysis inscripts/frame-profile/):docs/frame-profiling.md
UI Communication Architecture
Two directions across one seam (code_assistant_core::session):
- UI → core:
SessionService(session/service.rs) — every frontend command is a typed async method. Internally an actor: a single worker on the backend tokio runtime executes commands in order.load_sessionreturns an ownedSessionSnapshot;connect_events()renders it as the canonical event sequence. - Core → UI: broadcast
EventStream(session/event_stream.rs) — all notifications are published session-tagged; frontendssubscribe()and filter by the session they view. A lagged subscriber getsStreamError::Laggedand resyncs via a fresh snapshot. The core does not know which session is "connected" or how many views exist.
Consequences:
- Multiple agents run concurrently, one per session;
SessionEventPublisher(session/instance.rs) implements the agent'sUserInterfaceand records the in-flight state that snapshots include - Cancellation is a core-side per-session flag (
request_stop), checked by the agent at streaming checkpoints - ACP's session/prompt commands intentionally bypass
SessionServiceand useSessionManagerdirectly (protocol-adapter needs don't map onto it) - The filesystem
SessionWatcherstill pushesUiEvents directly into frontend channels, not via the stream — a known remaining seam
GPUI API rules
GPUI has had some changes to its APIs. Always write code using the new APIs:
spawnmethods now take async closures (AsyncFn), and so should be called likecx.spawn(async move |cx| ...).- Use
Entity<T>. This replacesModel<T>andView<T>which no longer exist and should NEVER be used. - Use
Appreferences. This replacesAppContextwhich no longer exists and should NEVER be used. - Use
Context<T>references. This replacesModelContext<T>which no longer exists and should NEVER be used. Windowis now passed around explicitly. The new interface adds aWindowreference parameter to some methods, and adds some new "*_in" methods for plumbingWindow. The old typesWindowContextandViewContext<T>should NEVER be used.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

