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 perception –
aft_outlinereturns every symbol (functions, classes, types, etc.) with its kind, visibility, line range, and nested members;aft_zoomdrills into a single symbol and can include call‑graph info. - Hybrid semantic + lexical search –
aft_searchuses a trigram index plus optional embedding back‑ends (OpenAI‑compatible or Ollama) to find code by meaning. - Symbol‑level editing –
aft_editcan 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 management –
aft_importadds, removes, or organizes imports in a language‑aware way. - AST‑based structural replace –
ast_grep_search/ast_grep_replacelet agents match code patterns using tree‑sitter ASTs. - Robust bash execution –
aft_bashruns 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
aftprocess 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 crate –
agent-file-toolson 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 installor a GitHub release if needed. - Configuration – Optional
aft.jsonc(user‑level~/.config/cortexkit/aft.jsoncor project‑level<repo>/.cortexkit/aft.jsonc). Setenabled: falseto turn AFT off, or tweak tool surface, semantic backend, LSP servers, compression, etc. - Uninstall – Run
npx @cortexkit/aft@latest doctorto 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) andcargo test(Rust). - Formatting:
bun run lint(Biome) andcargo fmt. - Contributions follow a “design‑first” workflow: open an issue, get a
design‑approvedlabel, 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