@cortexkit/aft-pi

中文文档
0.63.5发布于 2026/11/01MITTypeScriptES Module构建来源已验证近 30 天下载 3590

Pi coding agent extension for Agent File Tools (AFT) — tree-sitter and LSP-powered code analysis

原始使用文档
文档目录10 节
  1. Install
  2. What you get
  3. Hoisted built-in overrides
  4. AFT-specific tools
  5. Slash command
  6. Configure
  7. Registered tools
  8. Architecture
  9. Logs
  10. License

@cortexkit/aft-pi

AFT (Agent File Tools) extension for the Pi coding agent and OMP (oh-my-pi)

AFT is a high-performance file-manipulation toolkit for AI coding agents. It replaces Pi's built-in read, write, edit, and grep tools with an indexed Rust backend that adds trigram search, semantic search, fuzzy edits, auto-format, LSP diagnostics, call-graph navigation, and more — all backed by one warm long-running aft process per session.

Install

pi install npm:@cortexkit/aft-pi

That's it. The extension auto-downloads the right AFT binary for your platform on first run (cached at ~/.cache/aft/bin/v<version>/aft).

Prefer to pin a specific version?

pi install npm:@cortexkit/[email protected]

What you get

Hoisted built-in overrides

Pi's default read, write, edit, grep, and bash are replaced with AFT-backed versions. List a name in disabled_tools (for example ["grep"]) to keep Pi's native tool for that slot. The AFT background-bash companions bash_status, bash_watch, bash_write, and bash_kill register independently of bash.

ToolPi built-inAFT replacement
readNode fs.readFileRust reader with line-numbered output, directory listing, binary/image detection
writeNode fs.writeFileAtomic write with per-file backup, auto-format (biome/oxfmt/prettier/ruff/rustfmt), LSP diagnostics
editPlain substring replaceProgressive fuzzy match (handles whitespace/Unicode drift), backups, glob-wide edits
grepripgrep shell-outTrigram-indexed search in-project, ripgrep fallback outside project root

All four keep the same agent-facing parameters as Pi's built-ins, so your prompts, skills, and muscle memory don't change.

On Oh My Pi (OMP), these five overrides delegate internal resources to OMP's native tool when its internal URL router and ctx.invokeTool are available. Reads and grep include MCP resource URIs; write and edit delegate schemes with an OMP write policy (including content-less proc://<id>/kill). OMP's read-only issue:// and pr:// routes handle reads, while AFT retains its opt-in GitHub comment write/edit behavior. Bash delegates internal-URL working directories and registered URL words in commands, including quoted URLs and skill://; OMP owns the resulting background jobs and exposes loaded skills in its system prompt. Plain filesystem targets continue through AFT. Upstream Pi's schemas and behavior are unchanged.

Filesystem calls on OMP use AFT's argument forms; unsupported native-only arguments produce errors naming the fields and their AFT alternatives. Extension validation performs no binary resolution, downloads, storage migration, or transport startup: those wait until a session warmup or filesystem tool request needs AFT.

AFT-specific tools

ToolWhat it does
aft_outlineStructural outline for files or directories; with github.read, indexes GitHub issue and PR discussions
aft_zoomSymbol-level inspection with call-graph annotations; with github.read, drills into GitHub discussion ordinals
aft_searchSemantic code search (embeddings, local ONNX or OpenAI-compatible)
aft_callgraphCall-graph navigation: callers, call_tree, impact, trace_to, trace_data
aft_conflictsOne-call merge-conflict inspection across all conflicted files
aft_importLanguage-aware import add / remove / organize (TS, JS, Python, Rust, Go)
aft_safetyPer-file undo, named checkpoints, restore
ast_grep_searchAST-aware pattern search across the filesystem
ast_grep_replaceAST-aware pattern rewrite
lsp_diagnosticsOn-demand LSP diagnostics (edit/write already inline diagnostics automatically)
aft_deleteDelete a file with backup (surface: all)
aft_moveMove/rename a file (surface: all)

Slash command

  • /aft-status — show AFT version, search/semantic index state, LSP servers, storage paths

Configure

AFT reads config from two levels, project overrides user:

  • User: ~/.config/cortexkit/aft.jsonc
  • Project: <project>/.cortexkit/aft.jsonc

All keys are optional. Example:

{
  // Auto-format on write/edit using project formatter config.
  "format_on_edit": true,

  // "syntax" (tree-sitter parse) | "full" (LSP typecheck)
  "validate_on_edit": "syntax",

  // When true, write-capable commands reject paths outside project_root.
  // Defaults to false to match Pi's built-in behavior.
  "restrict_to_project_root": false,

  // Background indexes, all on by default. The local semantic backend may
  // download an ONNX runtime and model and use CPU.
  "indexes": { "trigram": true, "semantic": true, "callgraph": true },

  // Tools that are not registered. Absent => ["aft_move", "aft_delete"];
  // an explicit list replaces that default ([] enables every tool).
  "disabled_tools": ["aft_move"],

  // Pi / OMP harness options:
  "pi": {
    // "top_level" (default) | "host_default"
    // On OMP, "top_level" registers tools with loadMode: "essential" so they appear
    // directly in the model tools array. "host_default" mounts tools under xd://.
    "tool_presentation": "top_level",
    // Plain Pi: ask before an outside-project access (default true; only user config can turn it off; print/JSON/RPC sessions never ask; on OMP, OMP's tools.approvalMode decides and outside-path calls report the "exec" tier).
    "external_access_ask": true
  },

  "formatter": {
    "typescript": "biome",
    "python": "ruff",
    "rust": "rustfmt"
  },
  "checker": {
    "typescript": "biome"
  },

  // Missing formatter/checker/LSP warnings after configure: "toast" (default), "log", or "chat".
  "configure_warnings_delivery": "toast",

  // Semantic backend for the semantic index.
  // "fastembed" (default, local ONNX) | "openai_compatible" | "ollama"
  "semantic": {
    "backend": "fastembed",
    "model": "all-MiniLM-L6-v2",
    "timeout_ms": 25000,
    "max_batch_size": 64
  }
}

Sensitive semantic backend fields (backend, base_url, api_key_env) are only read from user-level config. Project configs that try to set them are ignored with a warning to prevent credential-exfiltration via malicious repos.

Registered tools

Every AFT tool registers unless listed in disabled_tools: read, write, edit, grep, bash and its companions, aft_outline, aft_zoom, aft_search, aft_callgraph, aft_inspect, aft_import, aft_safety, aft_conflicts, ast_grep_search, ast_grep_replace, aft_delete and aft_move (the last two are in the default disabled list). Pi has no AFT apply_patch or glob tool. Index state and runtime settings never remove a registration. tool_surface, hoist_builtin_tools and the search_index / semantic_search keys are translated during v0.58 and rejected from v0.59.

Architecture

  • One persistent Rust process per session. Pi loads the extension once per session; AFT spawns one aft binary for the session's working directory and keeps it alive. Trigram index, semantic index, tree-sitter caches, and LSP servers all stay warm.
  • NDJSON bridge. The TypeScript extension talks to the Rust binary over stdin/stdout using a versioned JSON-RPC-style protocol.
  • Session isolation. Pi's session_shutdown event triggers clean bridge shutdown — undo history, checkpoints, and LSP state don't leak across sessions.
  • Auto-download + version check. Each plugin version pins a compatible binary version and resolves it in order: versioned cache → platform npm package → PATH → ~/.cargo/bin/aft → GitHub release download. Mismatched binaries hot-swap transparently.

Logs

Plugin logs go to <storage_root>/logs/aft-plugin.log with an [aft-pi] tag. The file rolls at 32 MiB into one .1 backup; Rust module processes use adjacent aft-<pid>.log files.

Set AFT_LOG_STDERR=1 to route logs to stderr instead (useful for piping or subprocess tests).

License

MIT


Main project: https://github.com/cortexkit/aft Issues / feature requests: https://github.com/cortexkit/aft/issues

版本与发布记录

@cortexkit/aft-pi 共发布 125 个版本,首次发布于 2026/04/20;过去 12 个月发布了 125 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.63.5latest2026/11/019 天前
0.63.42026/10/3111 天前
0.62.02026/10/2220 天前
0.61.02026/10/2121 天前
0.60.02026/10/1724 天前
0.59.02026/10/101 个月前

关于 @cortexkit/aft-pi 的常见问题

@cortexkit/aft-pi 是什么?

Pi coding agent extension for Agent File Tools (AFT) — tree-sitter and LSP-powered code analysis

如何安装 @cortexkit/aft-pi?

在项目目录运行 npm install @cortexkit/aft-pi,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:typebox(*)、@earendil-works/pi-ai(*)、@earendil-works/pi-tui(*)、@earendil-works/pi-coding-agent(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cortexkit/aft-pi 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cortexkit/aft-pi 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cortexkit/aft-pi 可以商用吗?

@cortexkit/aft-pi 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cortexkit/aft-pi 的下载量有多少?

根据 npm 官方下载统计,@cortexkit/aft-pi 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,590 次,日均约 120 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cortexkit/aft-pi 还在维护吗?

最新版本 0.63.5 发布于 2026/11/01(9 天前);至今共发布 125 个版本,其中过去 12 个月发布了 125 个;首次发布于 2026/04/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。