Token-efficient remote execution, AST outlining, and safe patching tool for AI agents.
pip install ai-agentbox==0.1.4 Copy PIP instructions
Ultra-lean, token-efficient remote execution, AST outlining, and safe atomic patching proxy for AI coding agents.
Designed for LLM agents (Claude Code, Cursor, Antigravity, Aider, Roo-Code, Windsurf) working on remote servers or local machines.
When AI coding assistants work over SSH or terminal sessions, they burn massive token budgets on:
AgentBox provides a Client $\leftrightarrow$ Worker architecture that reduces token consumption by 80% to 95%:
pip install ai-agentbox 🛠️ Quickstart 1. Configure Target (Optional) Configure your remote SSH server once (stored in .agentbox.json or ~/.agentbox/config.json):
agentbox config --set-host user@192.168.1.171 --set-cwd ~/my_project Or pass --host and --cwd directly to any command:
agentbox --host user@192.168.1.171 --cwd ~/my_project tree To run locally, simply omit the host:
agentbox tree 📖 Command Reference 1. Code Navigation & Skeletons agentbox outline Extracts only class, function, and method signatures with line numbers:
=== OUTLINE: gateway.py (350 lines) === 12- 45 | class GatewayConfig: 48- 110 | async def handle_connection(reader, writer) -> bool 115- 180 | def commit_flash_block(offset: int) -> None agentbox get-fn Extracts the exact definition and body of a target function:
agentbox get-fn src/gateway.py handle_connection agentbox view [--start N] [--end M] Displays an exact line slice with 1-indexed line numbers:
agentbox view src/gateway.py --start 48 --end 65 2. Silent & Background Process Runner agentbox run " " [--tail N] [--timeout T] Silently executes a command, redirects all stdout/stderr to a log file, and returns only the final verdict:
agentbox run "cargo build --release" Output on success:
OK [exit 0, 42.15s] Log: /tmp/agent_logs/task_123456.log Output on failure (automatically prints tail):
FAILED [exit 1, 12.30s] Log: /tmp/agent_logs/task_123456.log --- Failure Tail (5 lines) --- error[E0308]: mismatched types --> src/main.rs:42:15 | 42 | let x: u8 = val; | ^^^ expected `u8`, found `u16` agentbox test " " Token-optimized test runner that suppresses passing tests and extracts high-signal failure tracebacks (pytest, cargo test, npm test):
agentbox test "pytest tests/" Output on success:
OK [tests passed in 1.45s] (12 passed) Log: /tmp/agent_logs/test_491823.log Output on failure (extracts traceback, saving up to 95% tokens):
FAILED [exit 1, 1.82s] Log: /tmp/agent_logs/test_491823.log --- High-Signal Failure Traceback --- > assert result == 42 E AssertionError: assert 100 == 42 tests/test_calc.py:15: AssertionError agentbox spawn " " Spawns a detached background task that survives SSH disconnects:
agentbox spawn "python3 train_model.py" # Output: SPAWNED: task_id=bg_849201 pid=4215 log=/tmp/agent_logs/bg_849201.log agentbox status bg_849201 # Output: TASK: bg_849201 | Status: RUNNING | PID: 4215 | Runtime: 1m 24s agentbox logs bg_849201 -n 20 # Output: displays last 20 lines of log agentbox logs bg_849201 -f # Output: live real-time log streaming (tail -f) agentbox kill bg_849201 # Output: OK: Task bg_849201 (PID 4215) terminated. 3. File Operations & Safe Atomic Patching agentbox write [--content "..."] [--append] Safely creates or appends to a file without any bash quote escaping issues (supports stdin streaming):
agentbox write src/settings.py --content 'DEBUG = True\nPORT = 8080' # Or via pipeline: cat config.json | agentbox write config.json agentbox patch --old " " --new " " Safely replaces code with automatic .bak backup creation:
agentbox patch src/config.py --old 'PORT = 8000' --new 'PORT = 9000' # Output: OK: Replaced 1 occurrence(s) in config.py. Backup: config.py.bak agentbox rollback Restores file from backup in case of errors:
agentbox rollback src/config.py # Output: OK: Restored config.py from backup and removed backup. 4. Search & Directory Tree agentbox tree [path] [--depth N] Prints clean directory structure while automatically ignoring .git, node_modules, target, __pycache__, .venv, and build artifacts:
agentbox tree --depth 2 agentbox grep " " [path] [--max N] Fast token-limited search across text files:
agentbox grep "handle_packet" src/ --max 10 5. Knowledge Graph & Architecture (graphify) AgentBox integrates with graphifyy to build and navigate deep code knowledge graphs without blowing LLM context budgets:
Silently ensures graphifyy is installed on the local machine or remote SSH server:
agentbox graphify-install agentbox graphify-build [path] [--deep] Silently builds a navigable knowledge graph on the target host:
agentbox graphify-build # Output: OK: Knowledge graph built in 4.2s (180 nodes, 420 edges). Location: graphify-out agentbox graphify-query " " Queries graph structure, relationships, and God nodes directly on the host, returning token-capped answers (~150 tokens instead of dumping megabytes of JSON):
agentbox graphify-query "Authentication and Token flow" 🤖 Enforce AI Agents to use AgentBox (agentbox init-rules) Generate strict anti-token-waste rules for AI assistants (Cursor, Claude Code, Antigravity, Windsurf, Roo-Code) with a single command:
agentbox init-rules # Output: OK: Created AI rule files: .cursorrules, AGENTS.md, CLAUDE.md Or target a specific environment:
agentbox init-rules --type cursor # generates .cursorrules agentbox init-rules --type agents # generates AGENTS.md agentbox init-rules --type claude # generates CLAUDE.md This installs strict rules prohibiting the AI assistant from running noisy cat, grep, find, or raw test commands over SSH, forcing the use of token-efficient agentbox commands.
MIT License. Free for open-source and commercial use.
agents ai ast cli llm remote-development ssh tokens
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.




