agentleFS
stippistippi/code-assistant/AGENTS.md

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
  1. Very specific:

    Use tools::test_registry() (exported under test-utils) for deterministic tool tests

    line 86
  2. Very specific:

    Use Entity<T>. This replaces Model<T> and View<T> which no longer exist and should NEVER be used.

    line 132
  3. Very specific:

    Use App references. This replaces AppContext which no longer exists and should NEVER be used.

    line 133

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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 compiles
  • cargo check --tests - Test if the tests compile
  • cargo test - Run all tests
  • cargo test --package <crate> - Test a single crate (names in Crate Layers below)
  • cargo fmt --all -- --check - Check code formatting
  • cargo 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 wiring

Key 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

  • ToolRegistry is an instance, not a singleton; ToolSpec carries capability tags (e.g. read_only)
  • Tool modes (configured per agent instance via ToolDialect):
    • native — LLM provider's native tool calling (default in agent_core)
    • xml — XML-based tool syntax in system messages
    • caret — 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 the rmcp SDK) and registers their tools in the ToolRegistry as mcp__<server>__<tool>; projects can add servers in a .mcp.json at the project root
  • The registry is rebuilt from the current config at the start of every agent run (ToolRegistryProvider seam)
  • 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 tagged read_only), all-tools (ask always)
  • Gate lives in the agent loop (tools_core::ToolPermissions); prompts go through the PermissionMediator seam; see docs/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 SessionStatus from activity state plus open permission requests
  • Sessions settle by hand, after N idle days, or when their branch is merged (SessionService::sweep_lifecycle); see docs/session-lifecycle.md

Development Notes

Testing

  • Unit tests distributed across modules; integration tests in crates/code_assistant/src/tests/
  • Mock implementations in code_assistant_core behind the test-utils feature
  • Use tools::test_registry() (exported under test-utils) for deterministic tool tests

UI Development

  • GPUI frontend based on gpui-kit (gpui via gpui_kit::*, gpui-component via gpui_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 tokio block_on (tokio's cooperation budget would never renew on the main thread), so main is not #[tokio::main]
  • Frame profiling of the GPUI frontend (opt-in via CODE_ASSISTANT_FRAME_PROFILE, sweep runner and sample analysis in scripts/frame-profile/): docs/frame-profiling.md

UI Communication Architecture

Two directions across one seam (code_assistant_core::session):

  1. 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_session returns an owned SessionSnapshot; connect_events() renders it as the canonical event sequence.
  2. Core → UI: broadcast EventStream (session/event_stream.rs) — all notifications are published session-tagged; frontends subscribe() and filter by the session they view. A lagged subscriber gets StreamError::Lagged and 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's UserInterface and 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 SessionService and use SessionManager directly (protocol-adapter needs don't map onto it)
  • The filesystem SessionWatcher still pushes UiEvents 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:

  • spawn methods now take async closures (AsyncFn), and so should be called like cx.spawn(async move |cx| ...).
  • Use Entity<T>. This replaces Model<T> and View<T> which no longer exist and should NEVER be used.
  • Use App references. This replaces AppContext which no longer exists and should NEVER be used.
  • Use Context<T> references. This replaces ModelContext<T> which no longer exists and should NEVER be used.
  • Window is now passed around explicitly. The new interface adds a Window reference parameter to some methods, and adds some new "*_in" methods for plumbing Window. The old types WindowContext and ViewContext<T> should NEVER be used.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.