cortexkit/aft

Give your agent a proper IDE and OS. The sensorimotor cortex for coding agents (OpenCode + Pi), part of CortexKit: symbol-aware edits, semantic search, code health, fast grep/glob, bash compression, background tasks, PTY.

AFT – Sensorimotor Cortex for Coding Agents

What it is – AFT (Agent File Tools) is a Rust‑based core that gives LLM‑powered coding agents a real IDE‑like view of a codebase and an OS‑like execution layer. It sits between an agent (e.g., OpenCode, Pi, or oh‑my‑pi) and the host filesystem, exposing high‑level, symbol‑aware tools (aft_outline, aft_zoom, aft_edit, aft_bash, …) instead of raw read/write/grep calls.


Core ideas (the brain metaphor)

Region Role Example tools
Sensory cortex Perceive code structure, semantics and relationships aft_outline, aft_zoom, aft_search, aft_callgraph, aft_inspect
Motor cortex Perform precise, parsed edits and refactorings aft_edit, aft_write, aft_apply_patch, aft_import, ast_grep_*
Brainstem Keep long‑running processes alive, compress output, provide undo/restore aft_bash, background tasks, PTY sessions, aft_safety

Supported agent “harnesses”

Harness How AFT integrates
OpenCode Native adapter (@cortexkit/aft-opencode) replaces the built‑in read, write, edit, apply_patch with AFT‑backed versions and adds an aft_ tool family.
Pi Native extension (@cortexkit/aft-pi) replaces read, write, edit, grep and adds the aft_ tools.
OMP (oh‑my‑pi) Supported via the Pi plugin; registers tools at the top level by default, with an optional “host_default” presentation mode.

Highlighted capabilities

  • Structure‑aware perceptionaft_outline returns every symbol (functions, classes, types, etc.) with its kind, visibility, line range, and nested members; aft_zoom drills into a single symbol and can include call‑graph info.
  • Hybrid semantic + lexical searchaft_search uses a trigram index plus optional embedding back‑ends (OpenAI‑compatible or Ollama) to find code by meaning.
  • Symbol‑level editingaft_edit can replace a named function directly, perform fuzzy find/replace, or run multi‑file transactional edits. All changes are parsed, formatted, and backed up before being written.
  • Automatic import managementaft_import adds, removes, or organizes imports in a language‑aware way.
  • AST‑based structural replaceast_grep_search / ast_grep_replace let agents match code patterns using tree‑sitter ASTs.
  • Robust bash executionaft_bash runs shell commands with output compression, permission scanning, and automatic rewriting of common utilities (cat → read, grep → grep tool). Background tasks survive agent restarts.
  • Undo / checkpoint – Every edit is saved to a per‑file undo stack; agents can create named checkpoints and roll back safely.
  • Language coverage – Tree‑sitter parsers for 30+ languages (TS/JS, Python, Rust, Go, C/C++, Java, Kotlin, Swift, etc.) enable outline, edit, AST, and semantic features.
  • Persistent indexes & LSP – Trigram search, semantic embedding index, and an embedded LSP client are kept warm in a long‑lived aft process per project root.

Quick start (one‑liner)

npx @cortexkit/aft@latest setup

The command detects which harness(es) you have installed, registers the AFT tools, and ensures the aft binary is available. You can target a specific harness with --harness opencode|pi|omp.


Installation details

  • Rust crateagent-file-tools on crates.io (the core binary).
  • NPM packages@cortexkit/aft (CLI), @cortexkit/aft-opencode, @cortexkit/aft-pi (harness adapters).
  • Binary distribution – The CLI will download a pre‑built binary for your platform on first use, falling back to cargo install or a GitHub release if needed.
  • Configuration – Optional aft.jsonc (user‑level ~/.config/cortexkit/aft.jsonc or project‑level <repo>/.cortexkit/aft.jsonc). Set enabled: false to turn AFT off, or tweak tool surface, semantic backend, LSP servers, compression, etc.
  • Uninstall – Run npx @cortexkit/aft@latest doctor to see what would be left, then manually remove the plugin entry from the harness config and delete the ~/.local/share/cortexkit/aft/ data directory. AFT itself has no dedicated uninstall command.

Development & contribution

  • Monorepo with Bun workspaces for the TypeScript adapters and a Cargo workspace for the Rust core.
  • Build steps:
    bun install            # install JS deps
    cargo build --release  # compile the Rust binary
    bun run build          # build the TS plugins
    
  • Tests: bun run test (TS) and cargo test (Rust).
  • Formatting: bun run lint (Biome) and cargo fmt.
  • Contributions follow a “design‑first” workflow: open an issue, get a design‑approved label, then submit a PR.

License

MIT – free for personal and commercial use.


In a nutshell: AFT gives LLM‑driven coding agents a full‑featured, language‑aware IDE and a lightweight OS layer, dramatically cutting token usage and improving reliability when agents read, edit, or run code.

Related

  • Project
  • Project
  • Project
  • Project