{"id":48170597,"url":"https://github.com/cortexkit/aft","last_synced_at":"2026-05-30T08:01:55.272Z","repository":{"id":344643518,"uuid":"1182429846","full_name":"cortexkit/aft","owner":"cortexkit","description":"Tree-sitter powered code manipulation and analysis tools for AI coding agents","archived":false,"fork":false,"pushed_at":"2026-05-14T11:08:28.000Z","size":7340,"stargazers_count":91,"open_issues_count":2,"forks_count":5,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-14T11:41:45.356Z","etag":null,"topics":["agent-framework","ai","ai-agents","ai-agents-framework","opencode"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cortexkit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-15T14:10:55.000Z","updated_at":"2026-05-14T11:08:32.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cortexkit/aft","commit_stats":null,"previous_names":["ualtinok/aft","cortexkit/aft"],"tags_count":74,"template":false,"template_full_name":null,"purl":"pkg:github/cortexkit/aft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortexkit%2Faft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortexkit%2Faft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortexkit%2Faft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortexkit%2Faft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cortexkit","download_url":"https://codeload.github.com/cortexkit/aft/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortexkit%2Faft/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33068907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent-framework","ai","ai-agents","ai-agents-framework","opencode"],"created_at":"2026-04-04T17:33:41.654Z","updated_at":"2026-05-30T08:01:55.260Z","avatar_url":"https://github.com/cortexkit.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eAFT\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://crates.io/crates/agent-file-tools\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/agent-file-tools?label=crate\u0026color=blue\u0026style=flat-square\" alt=\"crates.io\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@cortexkit/aft\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@cortexkit/aft?label=cli\u0026color=blue\u0026style=flat-square\" alt=\"npm @cortexkit/aft\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@cortexkit/aft-opencode\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@cortexkit/aft-opencode?label=opencode\u0026color=blue\u0026style=flat-square\" alt=\"npm @cortexkit/aft-opencode\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@cortexkit/aft-pi\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@cortexkit/aft-pi?label=pi\u0026color=blue\u0026style=flat-square\" alt=\"npm @cortexkit/aft-pi\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://discord.gg/DSa65w8wuf\"\u003e\u003cimg src=\"https://img.shields.io/discord/1488852091056295957?style=flat-square\u0026logo=discord\u0026logoColor=white\u0026label=Discord\u0026color=5865F2\" alt=\"Discord\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/cortexkit/aft/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-green?style=flat-square\" alt=\"MIT License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#what-is-aft\"\u003eWhat is AFT?\u003c/a\u003e ·\n  \u003ca href=\"#quick-start\"\u003eQuick Start\u003c/a\u003e ·\n  \u003ca href=\"#key-capabilities\"\u003eKey Capabilities\u003c/a\u003e ·\n  \u003ca href=\"#architecture\"\u003eArchitecture\u003c/a\u003e ·\n  \u003ca href=\"#development\"\u003eDevelopment\u003c/a\u003e ·\n  \u003ca href=\"#tool-reference\"\u003eTool Reference\u003c/a\u003e ·\n  \u003ca href=\"#configuration\"\u003eConfiguration\u003c/a\u003e ·\n  \u003ca href=\"https://discord.gg/DSa65w8wuf\"\u003e💬 Discord\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## What is AFT?\n\nAI coding agents are fast at reasoning but clumsy at interacting with code. The typical pattern — read an entire file to find one function, construct a diff from memory, apply it by line number, hope nothing shifted — burns tokens on context noise and breaks when the file changes.\n\nAFT is the tooling layer that fixes this. Part of the CortexKit family, it acts as the **motor cortex and sensory cortex** for coding agents — giving them precise, low-level control over code files and a proper operating system to run in.\n\nConcretely:\n\n- **Sensory cortex** — structural code understanding. Agents can outline a file in one call, zoom into a specific function by name, and search code by meaning instead of guessing keywords.\n- **Motor cortex** — precise code manipulation. Edit functions by name instead of line number. Refactor across the whole workspace with one command. The binary handles parsing, formatting, backup, and type-checking.\n- **Agent OS** — background bash tasks, PTY sessions, output compression. Agents can spawn long-running work, inspect it later, and get compressed output instead of raw firehose.\n\nThe result is less token waste. Instead of reading 500 lines to find one function, the agent calls `aft_outline` then `aft_zoom` — ~40 tokens instead of ~375. Instead of guessing where a concept lives, `aft_search` finds the exact location by meaning. Bash output is compressed per-command. Refactoring that would need manual grep+read+edit across 10 files becomes one `aft_refactor move` call.\n\nAFT ships as a Rust binary with thin adapters for [OpenCode](https://opencode.ai) and [Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent). It hoists itself into the host harness's built-in tool slots — agents keep calling the same tool names (`read`, `write`, `edit`, `bash`, `grep`), but now backed by tree-sitter parsing, indexed search, output compression, and symbol-aware operations.\n\n---\n\n## Quick Start\n\n```bash\nnpx @cortexkit/aft setup\n```\n\nThis auto-detects which harnesses you have installed and configures each one. On the next session start, the `aft` binary downloads if needed and all tools become available.\n\nAdd `--harness opencode` or `--harness pi` to target a specific harness.\n\n**What AFT does to each harness:**\n- **OpenCode** — replaces built-in `read`, `write`, `edit`, `apply_patch`, `ast_grep_search`, `ast_grep_replace`, and `lsp_diagnostics` with AFT-powered versions and adds the `aft_` family on top.\n- **Pi** — replaces built-in `read`, `write`, `edit`, and `grep` and adds the `aft_` family on top.\n\nSee the [CLI reference](docs/cli.md) for `doctor`, `doctor --fix`, `doctor lsp`, and cache management commands.\n\n---\n\n## Key Capabilities\n\n### Structural code understanding\n\n- **`aft_outline`** — list every symbol in a file (or directory, or remote URL) with kind, name, line range, and visibility. One call instead of reading the whole file.\n- **`aft_zoom`** — inspect a specific function, class, or type with call-graph annotations (what it calls, what calls it). ~40 tokens instead of ~375.\n- **`aft_search`** — find code by meaning when grep keywords fall short. Hybrid semantic + lexical retrieval over an indexed codebase. Requires ONNX Runtime for the local embedding backend.\n- **`aft_callgraph`** — follow callers, callees, data flow, impact analysis, and shortest call paths between two symbols across the workspace.\n- **`aft_inspect`** — codebase-health snapshot: TODOs, file/symbol metrics, dead code, unused exports, and duplicate detection in one call.\n- **`grep` / `glob`** — trigram-indexed regex search and file discovery. Background index building with disk persistence.\n\n### Precise manipulation\n\n- **`edit`** — find/replace with fuzzy matching, or replace a named symbol directly. Batch edits, multi-file transactions, glob replace across matching files.\n- **`write`** — write a file with auto-directory creation, backup, formatting, and inline LSP diagnostics.\n- **`apply_patch`** — multi-file `*** Begin Patch` format with atomic rollback.\n- **`aft_refactor`** — workspace-wide symbol move (updates all imports), function extraction, function inlining.\n- **`aft_import`** — language-aware import add, remove, and organize (TS/JS/TSX/Python/Rust/Go).\n- **`aft_transform`** — structural transforms: add class members, Rust derives, Python decorators, Go struct tags, try/catch wrapping.\n- **`ast_grep_search` / `ast_grep_replace`** — structural code search and replace using AST patterns with meta-variables.\n- **`lsp_diagnostics`** — on-demand errors and warnings from language servers. Not a full type checker, but fast feedback during edits.\n\n### Agent OS\n\n- **`bash`** — unified shell execution with command rewriting (cat→read, grep→grep tool, etc.), per-command output compression, background task spawning, and tree-sitter permission scanning (OpenCode).\n- **Background bash** — spawn detached tasks with `background: true`, inspect with `bash_status`, kill with `bash_kill`. Output is buffered and compressed. Long foreground commands auto-promote to background.\n- **Bash compression** — three-tier output compression: built-in Rust compressors for git/cargo/npm/bun/pnpm/pytest/tsc/biome, declarative TOML filters for the long tail (make/ls/find/du/docker/kubectl/gh/etc.), and generic ANSI-strip + dedup fallback.\n- **PTY** — interactive terminal sessions for REPLs and terminal apps (python, node, vim, even a nested agent). Drive with `bash_write`, inspect rendered screen state via `bash_status`.\n- **`bash_watch`** — block on or asynchronously watch a background/PTY task for an output pattern or exit.\n\n### Safety and recovery\n\n- **`aft_safety`** — per-file undo stack, named checkpoints, restore to any checkpoint. Every edit is backed up.\n- **Auto-backup** — every write and edit saves a snapshot before mutating.\n- **Auto-format** — edits run the project formatter (biome, rustfmt, prettier, etc.) automatically.\n- **On-demand diagnostics** — pass `diagnostics: true` on a write/edit to get LSP errors inline, or call `aft_inspect` / `lsp_diagnostics` at a verification checkpoint.\n\n---\n\n## Supported Languages\n\n| Language | Outline | Edit | Imports | Refactor |\n|----------|---------|------|---------|---------|\n| TypeScript / TSX | ✓ | ✓ | ✓ | ✓ |\n| JavaScript / JSX | ✓ | ✓ | ✓ | ✓ |\n| Python | ✓ | ✓ | ✓ | ✓ |\n| Rust | ✓ | ✓ | ✓ | partial |\n| Go | ✓ | ✓ | ✓ | partial |\n| C / C++ / C# | ✓ | ✓ | — | — |\n| Java / Kotlin / Scala | ✓ | ✓ | — | — |\n| Swift | ✓ | ✓ | — | — |\n| Ruby | ✓ | ✓ | — | — |\n| PHP | ✓ | ✓ | — | — |\n| Lua / Perl | ✓ | ✓ | — | — |\n| Zig | ✓ | ✓ | — | — |\n| Bash | ✓ | ✓ | — | — |\n| HTML / Markdown / JSON | ✓ | ✓ | — | — |\n| Solidity | ✓ | ✓ | — | — |\n| Vue | ✓ | ✓ | — | — |\n\nEvery listed language works with `aft_outline`, `aft_zoom`, `read`/`edit`/`write`, and the structural tool surface. AST search and replace covers TS/JS/TSX, Python, Rust, Go, C, C++, C#, Zig, Solidity, and Vue. Import management covers TS/JS/TSX, Python, Rust, and Go.\n\n---\n\n## Architecture\n\nAFT is a Rust binary driven by thin adapter packages per harness. The binary speaks a simple JSON-over-stdio request/response protocol — one process per session stays alive for the session lifetime.\n\n```\n   ┌─────────────┐    ┌─────────────┐    ┌─────────────┐\n   │  OpenCode   │    │     Pi      │    │  Future…    │\n   │   agent     │    │   agent     │    │  (MCP, …)   │\n   └──────┬──────┘    └──────┬──────┘    └──────┬──────┘\n           │ tool calls       │ tool calls       │\n           ▼                  ▼                  ▼\n   ┌──────────────┐   ┌──────────────┐   ┌──────────────┐\n   │ aft-opencode │   │   aft-pi     │   │     …        │  ← thin adapters per harness\n   │  (TS plugin) │   │  (TS plugin) │   │              │    Hoist tools, manage\n   └──────┬───────┘   └──────┬───────┘   └──────┬───────┘    BridgePool, resolve binary\n           │                  │                  │\n           └──────────────────┴──────────────────┘\n                              │\n                              │ JSON-over-stdio\n                              ▼\n                   ┌────────────────────────┐\n                   │     aft binary         │  ← shared core\n                   │       (Rust)           │\n                   ├────────────────────────┤\n                   │ • tree-sitter (17 lang)│\n                   │ • symbols \u0026 call graph │\n                   │ • diff/format/backup   │\n                   │ • LSP client           │\n                   │ • trigram index        │\n                   │ • semantic index       │\n                   └────────────────────────┘\n```\n\nPer-harness adapter responsibilities:\n- **Hoist** the harness's built-in tool slots and register AFT-only tools.\n- **Manage a BridgePool** — one persistent `aft` process per session for warm parse trees and isolated undo history.\n- **Resolve the binary** — cache → npm platform package → PATH → cargo install → GitHub release download.\n- **Translate** between the harness's plugin API and AFT's request/response protocol.\n\nAFT data lives under a shared CortexKit storage root (`~/.local/share/cortexkit/aft/`). Backups, search indexes, and downloaded LSP servers persist there across sessions.\n\nSee the [tool reference](docs/tools.md) for complete documentation of every tool.\n\n---\n\n## Development\n\nAFT is a monorepo: bun workspaces for TypeScript, cargo workspace for Rust.\n\n**Requirements:** Bun ≥ 1.0, Rust stable toolchain (1.80+).\n\n```sh\n# Install JS dependencies\nbun install\n\n# Build the Rust binary\ncargo build --release\n\n# Build the TypeScript plugin\nbun run build\n\n# Run all tests\nbun run test        # TypeScript tests\ncargo test          # Rust tests\n\n# Lint and format\nbun run lint        # biome check\nbun run lint:fix    # biome check --write\nbun run format      # biome format + cargo fmt\n```\n\n**Project layout:**\n\n```\nopencode-aft/\n├── crates/\n│   └── aft/              # Rust binary — shared core (tree-sitter, search, LSP, etc.)\n│       └── src/\n├── packages/\n│   ├── aft-cli/          # Unified CLI (@cortexkit/aft) — setup/doctor across all harnesses\n│   ├── opencode-plugin/  # OpenCode adapter (@cortexkit/aft-opencode)\n│   │   └── src/\n│   │       ├── tools/    # One file per tool group\n│   │       ├── config.ts # Config loading and schema\n│   │       └── downloader.ts\n│   ├── pi-plugin/        # Pi adapter (@cortexkit/aft-pi)\n│   │   └── src/\n│   └── npm/              # Platform-specific binary packages\n└── scripts/\n    └── version-sync.mjs  # Keeps npm and cargo versions in sync\n```\n\n---\n\n## Contributing\n\nPull requests for bugs are welcome. For features, broader fixes that requires architectural changes, please open an issue first to discuss the approach.\n\nThe binary protocol is documented in `crates/aft/src/main.rs`. Adding a new command means implementing it in Rust and adding a corresponding tool definition (or extending an existing one) in each harness adapter (`packages/opencode-plugin/src/tools/` and `packages/pi-plugin/src/tools/`).\n\nRun `bun run format` and `cargo fmt` before submitting. The CI will reject unformatted code.\n\n---\n\n## License\n\n[MIT](LICENSE)\n\n---\n\n## Separate documentation\n\n- [Tool reference](docs/tools.md) — complete documentation for every tool\n- [Configuration](docs/config.md) — config schema, LSP, auto-install\n- [CLI commands](docs/cli.md) — setup, doctor, and cache management\n- [Search benchmarks](docs/benchmarks.md) — trigram index vs ripgrep comparison\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcortexkit%2Faft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcortexkit%2Faft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcortexkit%2Faft/lists"}