
ap
io.github.xgbtxy/ap
Pure-Rust 37-tool MCP server & CLI: AST read/edit, FTS5 log sieve, headless CDP & Win32 sandbox.
Documentation
ap
Install AI-agent superpowers in one command: 37 MCP tools that make coding & desktop agents 2x faster and rock-solid on Windows & macOS.
English · 简体中文 · Co-Maintain / Contribute · Core R&D Philosophy · Prebuilt Downloads
Install in 10 Seconds, Then Forget About It
No Python, no Node, no Playwright, no Docker, and zero new commands to memorize. One line installs the native ap binary and automatically wires your AI Desktop Assistants, IDEs & CLIs (Claude Desktop, OpenClaw, Hermes, Cursor, Windsurf, VS Code, Claude Code, Codex, OpenCode, Gemini CLI, Qwen Code, Pi, Goose, Antigravity, Grok):
Pinned & verifiable (recommended):
- Official MCP Registry:
io.github.xgbtxy/ap(search) — five cross-platform.mcpbbundles with SHA-256 pinned inserver.json. - Try & Inspect Online (Glama): browse all 37 tools, check the quality score and test the server in the browser at glama.ai/mcp/servers/xgbtxy/ap or with the MCP Inspector.
- Scoop (Windows):
scoop install https://raw.githubusercontent.com/xgbtxy/ap/main/packaging/scoop/ap.json - Homebrew (macOS/Linux):
brew install --formula https://raw.githubusercontent.com/xgbtxy/ap/main/packaging/homebrew/ap.rb - Docker MCP:
glama.json+ rootDockerfile(CI-verified stdio handshake, 37 tools):docker build -t ap-mcp . && docker run -i --rm -v "$PWD:/workspace:ro" ap-mcp - Cargo:
cargo install --git https://github.com/xgbtxy/ap --tag v2.97.0 --locked - Release binary + checksum: download from v2.97.0, then verify against
SHA256SUMS(sha256sum -c SHA256SUMS --ignore-missing, orGet-FileHash -Algorithm SHA256on Windows). - Antigravity: copy the self-contained
plugin/bundle and runplugin/install.ps1/plugin/install.sh.
Quick one-liner (tracks main, unpinned):
Windows (PowerShell):
curl.exe -fsSL https://raw.githubusercontent.com/xgbtxy/ap/main/install.ps1 | iex
macOS / Linux:
curl -fsSL https://raw.githubusercontent.com/xgbtxy/ap/main/install.sh | sh
Prefer direct download? Grab the standalone binary (Windows x64
.zip· macOS Apple Silicon · macOS Intel · Linux x64 · Linux ARM64) and runap init. Remove cleanly anytime viaap uninstall.
v2.97.0 Official Antigravity Plugin Bundle: Install the self-contained
plugin/bundle (mcp_config.json--profile core,<15msSessionStartrepo snapshot hook,rules/AGENTS.md,skills/ap-primitives, and 1-commandplugin/install.ps1/plugin/install.sh), plus--max-mem-mb/--max-ram-mbaliases inap-winjob.
v2.95.0 Windows Agent Kit: One-command Windows setup & health audit via
scripts/install-windows-agent-kit.ps1,ap-winjobLow Memory/I/O Priority (--io-low) + EcoQoS process cage,ap-hookquiet_frontier1-line coordinator meter &canonical_path_shieldNTFS junction/symlink resolution. See Windows Agent Kit Benchmarks.
Why We Built ap: Fixing Where AI <thinking> Derails
Saving tokens is not the primary goal—it is a natural byproduct.
When we audited 101,108 real tool calls and raw <thinking> traces across coding agents on Windows and macOS, we found that models rarely fail because they "lack intelligence." They get slow, confused, and write sloppy code because 5 real-world bottlenecks hijack their working memory:
Where AI <thinking> Gets Stuck | What Happens Without ap | How ap Solves It Automatically (Full CLI Ref: Playbook) |
|---|---|---|
| 1. Reading, Diffing & Searching Code, Data & Binaries (AST, Hashline, Semantic Diff, Archives, PE/ELF, IPC) | Chokes on Word/Excel/PDF/SQLite/.asar/binaries without python/pefile, drowns in comment/test hits on search, or hangs on GNU grep -rn. | ap ls / ap read / ap diff / ap search / ap query: Bounded ap ls --depth; --hashline (11:a3|...) anchored reads, --section/--around/--symbol/--surface/--ipc-graph/AST-CFG semantic diff & 12-file batch reads; --ast structural metavar/kind patterns (fetch($URL, $$$), $X == $X), -F/--code-only --no-tests; PE/ELF/Java/.NET/Proto/firmware & JS --routes/--jwt/--secrets; zero-Python SQLite SQL. |
| 2. Orientation, Surface, Variants & Browser/API/Win32 QA (Mapping, Deps, HTTP Roles/HAR, WS, Win32) | Blind ls/rg across modules, missing guard-asymmetry & cycle graphs, accumulating orphan files, or hand-rolled HTTP/WS/CDP/Win32 scripts. | ap atlas + ap probe: <15 ms PageRank map, <40 ms atlas deps --dead, atlas variants guard-asymmetry sweeper, <60 ms 9-axis surface frontier, parallel impact/trace/changes, plus http --roles-matrix/--flow/--from-har, ws --replay-har, cdp --export-role, & win --all. |
| 3. Safe Creation & Multi-File Refactors (Hashline Anchors, Codex Diffs, AST Codemod & Checkpoints) | Naive find-replace corrupts comments/strings, multi-hunk diffs fail on duplicate blocks, or edits lose BOM/CRLF/modes or lack named checkpoints. | ap splice + ap undo: Pure-Rust Hashline (ap read/splice view --hashline + @@ HASHLINE: / ap splice apply --hashline / ap_edit anchor w/ fail-closed stale-hash guard & bottom-up multi-hunk batching), *** Begin Patch + unified diffs, Tree-sitter rename/rewrite/INSERT_AFTER/DELETE_SYMBOL, UTF-8/16 BOM & mode preservation, 6-lang+JSON/TOML AST gate, <5 ms PostToolUse hook, plus named ap undo --save/--diff/--keep. |
| 4. OS Quoting Crashes, Resource Cages & Doom Loops (Windows/Mac Shell, Win32 Job Cage, Policy Hooks & Log Noise) | Hits 528+ Windows OS/shell crashes (GBK/BOM, PS &&, rg errors, dir /b, sed -n, head/tail -n, Select-String, Get-Content, Get-ChildItem, slow grep), orphan child trees & log floods. | ap exec + ap-winjob + ap-hook + ap sieve + ap guard: Transparent shell auto-heal & log compression -98.8%, 3x loop-breaker, standalone zero-dep ap-winjob (CREATE_SUSPENDED Win32 Job Object RAM/CPU cage & atomic orphan reaping), and ap-hook generic schema_version: 1 Engine-vs-Policy loader (examples/policy.example.json). |
| 5. Deep Verification, Structured Memory & Pi Cache (6-Gate QA, AI-Surface, 0.33ms 10K-Rule Memory, Worktree Auto-ID, 22 Pi Patches) | Burns 11k+ schema tokens/turn, misses supply-chain/AI-surface risks, fragments .baton/.recall across linked git worktrees, or busts KV-caches mid-run. | MCP (--profile full|core|deferred) + ap guard scrub/ai-surface/sec/diff/verify --deep + ap baton & ap recall (0.33ms 10K-rule AND-first FTS5, --by human/--pin immutability, zero-spawn .git/commondir worktree sharing) + ap audit (memoized cursor cache) + ap pi (22 patches). |
Architecture & Direction: Universal Core + On-Demand Harness & Model Adapters
+-------------------------------------------------------------------+
| 3. On-Demand Adapters (Selected per Harness x Model Family) |
| - Harness hooks/MCP wiring: `ap init -a <harness>` / profiles |
| - Declarative profile CLI: `ap profile show|set|recommend|reset` |
| - Optional runtime patches: `ap pi patch` (Pi v1.5+/v1.6) |
| - Model-tier economics: KV-cache TTL keep, sieve limits, |
| `--profile core|deferred` schema slimming |
+-------------------------------------------------------------------+
| 2. Empirical Driver: Real Harness & Model Execution Telemetry |
| - Offline zero-PII process logs (`ap audit --maintainer`) |
| - Pinpoints where real agents stall across harnesses & models |
+-------------------------------------------------------------------+
| 1. Universal Core (`ap` / `ap.exe` Single Pure-Rust Binary) |
| - Model- & harness-agnostic physical primitives: files, AST, |
| binaries/archives, SQLite, HTTP/WS/CDP, OS shield, `ap mcp` |
+-------------------------------------------------------------------+
- Universal Core First: Keep durable physical primitives—reading/searching code, docs, binaries & archives, Tree-sitter AST navigation & safe patching, OS/shell quoting recovery, SQLite SQL, and browser/API verification—inside one dependency-free Rust core usable everywhere via CLI and
37typedap mcptools. - Driven by Multi-Harness & Multi-Model Reality: Prioritize work from empirical execution friction logs across real harnesses (
Claude Code,Codex,Pi,OpenCode,Cursor,Gemini CLI,Antigravity,Grok, etc.) and model tiers via offline, zero-PIIap audit --maintainerrather than speculative prompting. - Composed On Demand: End users run Universal
ap+ only the adapters for their chosen harness and model (e.g.,ap init -a <harness>,ap pi patch, or--profile deferred), incurring zero token or runtime tax for unused frameworks and allowing adapters to retire cleanly as upstream hosts or models evolve. - Native CLI Layer for Minimal / Freehand-Style Harnesses (Windows & Linux): Built for minimalist agent loops that deliberately avoid MCP tool-schema bloat—giving frontier models zero-prefix CLI observation & editing primitives (
ap sievedisk-filtering,ap read --symbol/--hashline,ap splice) alongsideap-winjobnative Windows process-group timeout/kill and--scrub-secrets(*KEY*/*SECRET*/*TOKEN*) parity.
How Do I Use It? (Zero Workflow Change)
- Just talk to your coding agent in plain language—even a 1-sentence beginner request on a
$0free agent works out of the box. - Whenever you want to inspect the efficiency gains, run
ap stats(orap doctorfor an environment check):
$ ap stats
[ap stats] Coding-Agent Efficiency & Thinking-Flow Ledger (100% offline)
------------------------------------------------------------------------
Accelerated Agent Steps : 28 actions
Thinking Derailments Healed : 11 Windows/shell crashes prevented before retry loops
1-Shot Edits & Browser Gates : 14 verified (Tree-sitter AST + Headless Edge/Chrome + 0-slop)
Working-Memory Noise Filtered: 612.4 KB -> 19.2 KB (-96.9% log/context clutter)
Byproduct Token Savings : ~186,800 wasted tokens avoided
Real Windows 11 End-to-End Results (Zero Fabrication)
Measured head-to-head on Windows 11 across $0 free coding agents and commercial CLIs on beginner 1-sentence prompts, legacy refactors, non-coding office tasks, and empty-directory random apps:
| Coding Agent & Real Task | Without ap → With ap (Speed & Steps) | Code Quality & Self-Correction | Wasted Tokens Avoided |
|---|---|---|---|
OpenCode Free ($0 big-pickle) · 1-Sentence Prompt | 430.2s (60 calls) → 182.4s (23 calls, 2.36x faster) | 7/8 (left empty-catch) → 8/8 (0 slop) | -75.1% (1.61M → 402k) |
Codex (General Office · No Python) · .docx + .xlsx + GBK .csv | 70.5s (binary dump + failed py) → 46.5s (1.52x faster) | 5/5 → 5/5 (0 binary/GBK crashes via ap read) | -54.3% (127k → 58k) |
Codex CLI (gpt-6-astra) · 14-File Multi-Module Refactor | 151.6s → 96.6s (1.57x faster) | 7/7 → 7/7 (all 5 AST callers + Edge UI synced) | -57.4% (296k → 126k) |
Codex CLI (gpt-6-astra) · From-Scratch Random App | 345.3s (23 calls) → 244.6s (9 calls, -61% steps) | 6/6 → 6/6 (1-shot Edge CDP check) | -83.3% (1.12M → 186k) |
Pi CLI (deepseek-flash) · Full-Stack Upgrade | 483.0s (81 calls) → 271.5s (70 calls, 1.78x faster) | 8/8 → 8/8 (-42.7% <thinking> churn) | -36.7% (3.63M → 2.30M) |
Show all 12 specialized Windows 11 benchmarks (SQL/SPA, PE/ELF, CDP/HTTP, SourceMap, Mutation & Creation)
| Coding Agent & Real Task | Without ap → With ap (Speed & Steps) | Code Quality & Self-Correction | Wasted Tokens Avoided |
|---|---|---|---|
Codex (Data & SPA Audit) · 2,500-Row 2-Sheet .xlsx + GBK .csv + JS SPA | 118.4s (5x custom XML/py scripts) → 94.3s (1.26x faster) | 5/5 → 5/5 (cent-exact SQL join + Edge SPA render) | -35.1% (212k → 138k) |
Codex (Full-Stack + SQLite Ops · No Python) · .sqlite + 3,000-Row .xlsx + .log.gz + JS Bug | 112.0s (.NET ZIP + 4x custom scripts) → 94.3s (1.19x faster) | 6/6 → 6/6 (1-shot .gz [FATAL] + SQLite↔XLSX join + APPEND) | -28.7% (235k → 167k) |
Codex (Native PE DLL + Live TCP Worker + FS Diff + Webhook) · PE32+ Exports/Imports/Hex + Cmdline/TCP + Atomic FS Diff + Callback Capture | 77.70s (120-line custom struct/socket/HTTP Python script) → 73.23s (1.06x faster, 1-shot PE analysis) | 4/4 → 4/4 (1-call ap read *.dll SHA-256 + exports/imports; worker process untouched) | Zero custom PE/ELF parser needed |
Codex (Batch Diagnostics + Async CDP Watch) · 180KB Minified 3-Offset Slice + 5x HTTP Batch + Live CDP Async Console/Network + Quorum Fix | 89.12s (10 calls, custom capture-audit.mjs) → 83.92s (8 calls, -20% steps, 0 custom scripts) | 5/5 + --deep PASS (host browser kept alive; 1-shot --offset, probe http --batch-stdin, probe cdp --watch-ms) | -6.0% (135k → 127k) |
Codex (Prod SourceMap + JWT Incident Fix) · SourceMap v3 VLQ + 500-Line JSONL JWT + Git Diff Gate | 106.05s (custom VLQ + JWT + mutation scripts) → 94.36s (1.12x faster) | 5/5 + 100% Mutation (1-shot --map-pos + 5-gate --deep w/ guard diff) | Zero custom VLQ / diff audit scripts |
Codex (Desktop App & Live CDP Audit) · .asar + 180KB Minified JS + PE UTF-16LE + Live CDP + 3-Hop Trace | 98.88s (custom Node/WS/ASAR scripts) → 83.43s (1.19x faster, 0 custom scripts) | 5/5 → 5/5 (15 vs 4 unit tests + --deep PASS, host browser kept alive) | -17.8% (146k → 120k) |
Codex (From-Scratch Full-Stack Security & UI) · EventDesk (SQLite + Desktop/Mobile UI + XSS + Fuzz) | 0 custom browser scripts (replaced hand-rolled test/browser.mjs via probe ui + smoke) | Mutation Kill Rate: 62.5% (5/8) → 100.0% (8/8), 5/5 (0 OWASP / 0 404 / 0 overflow) | 6-gate proof receipt cut calls -30.8% (13→9) |
Codex (Zero-Hint 18-Module Fault Hunt) · CommerceCore Voucher Regression (0 File Hints) | 123.37s → 107.59s (1.15x faster, 1-shot atlas locate + --deep) | 5/5 + 100% Mutation (verified callers via atlas impact + active-file --deep) | -7.2% (111k → 103k) |
Codex (From-Scratch Creation & Deep Test) · FlashVault Concurrency & Wallet API | 7 fused calls via guard verify --deep | Test Mutation Kill Rate: 62.5% (5/8) → 100.0% (8/8 killed, 10/10 black-box) | Killed all 3 surviving boundary/logic bugs |
Codex (False-Green Repo Hardening) · OrderGate Hidden .only + 500 Crash + Off-by-1 | 200.6s → 183.2s (faster w/ 5-gate audit) | 6/6 + 100% Mutation + 100% Chaos Fuzz (caught live 500 crash & .only) | Fused 5 verification gates into 1 pass |
Codex CLI (gpt-6-astra) · Full-Stack Upgrade | 333.6s (24 calls) → 294.3s (11 calls, -54% steps) | 8/8 → 8/8 | -65.4% (1.05M → 365k) |
Pi CLI (deepseek-flash) · From-Scratch Random App | 1,821.1s → 1,499.3s (322s faster) | 5/6 (2x silent catch {}) → 6/6 (0 slop) | Model ran extra subset-sum fuzzer |
Co-Maintain ap With Your Own AI
ap improves through a 4-Source Recursive Self-Improvement Loop: (1) survey external community issues & mature OSS tools, (2) measure local execution friction (100% offline, zero private data), (3) craft minimal Pure-Rust primitives, and (4) prove real Before-vs-After gains via a reviewer-first PR map:
# Preview your local zero-PII numeric bottlenecks mapped to ap source files (6 harnesses; safe to inspect first):
ap audit --maintainer
- Want your AI to co-maintain with you? Grab the ready-to-paste prompt in CONTRIBUTING.md (includes privacy-first opt-outs if you prefer not to scan raw local logs + strict anti-misuse guardrails).
- Submitting a PR? Use .github/PULL_REQUEST_TEMPLATE.md — it requires an exact
file:symbol/lineChange Map and Before/After table so maintainers can review and merge in minutes.
For Systems Engineers: Pure-Rust Architecture, Micro-Benchmarks & R&D Docs
- Zero-Coupling Single Binary: 1 native Rust binary backed by 7 isolated crates (
crates/ap-{atlas,splice,probe,sieve,guard,recall,baton}) with0sibling crate dependencies, bundled SQLite FTS5, 6 compiled Tree-sitter C grammars (Py/TS/JS/Go/Rust/C), and390total idle frontmatter tokens. - Reproduce Micro-Benchmarks: Run
ap bench(seebench/results.json). - Engineering Docs:
- Co-Maintaining
ap& 4-Source Recursive Prompt (CONTRIBUTING.md) | 共同维护指南 (CONTRIBUTING.zh-CN.md) | PR Spec (.github/PULL_REQUEST_TEMPLATE.md) - Core R&D Philosophy & Evolution (
docs/HANDBOOK.md) | 中文研发手册 (docs/HANDBOOK.zh-CN.md) - System Architecture (
docs/DESIGN.md) | 架构设计 (docs/DESIGN.zh-CN.md) - Workflow Playbook (
docs/PLAYBOOK.md) | 实战手册 (docs/PLAYBOOK.zh-CN.md) - Pi Runtime Maintenance (
docs/PI_RUNTIME.md) | Pi 运行时维护 (docs/PI_RUNTIME.zh-CN.md)
- Co-Maintaining
Privacy, Scope & Responsible Use
- 100% Local & Offline Telemetry:
ap statsandap audit --maintainerrun strictly locally with zero cloud uploads;ap audit --maintaineremits anonymized numeric friction counters only (never prompts, code, file paths, or credentials). - Responsible Engineering Scope & Anti-Misuse:
apis built exclusively for software engineering, debugging, QA verification, and authorized defensive security/configuration hygiene on systems you own or have permission to test. Do not misuse it for unauthorized access or harmful activity.
License
https://github.com/xgbtxy/ap/releases/download/v2.97.0/ap-mcp-windows-x64.mcpb# mcpb: https://github.com/xgbtxy/ap/releases/download/v2.97.0/ap-mcp-windows-x64.mcpbhttps://github.com/xgbtxy/ap/releases/download/v2.97.0/ap-mcp-darwin-arm64.mcpb# mcpb: https://github.com/xgbtxy/ap/releases/download/v2.97.0/ap-mcp-darwin-arm64.mcpbhttps://github.com/xgbtxy/ap/releases/download/v2.97.0/ap-mcp-darwin-x64.mcpb# mcpb: https://github.com/xgbtxy/ap/releases/download/v2.97.0/ap-mcp-darwin-x64.mcpbhttps://github.com/xgbtxy/ap/releases/download/v2.97.0/ap-mcp-linux-x64.mcpb# mcpb: https://github.com/xgbtxy/ap/releases/download/v2.97.0/ap-mcp-linux-x64.mcpbhttps://github.com/xgbtxy/ap/releases/download/v2.97.0/ap-mcp-linux-arm64.mcpb# mcpb: https://github.com/xgbtxy/ap/releases/download/v2.97.0/ap-mcp-linux-arm64.mcpb