ai-agentbox 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ai_agentbox-0.1.1/.gitignore +60 -0
- ai_agentbox-0.1.1/LICENSE +21 -0
- ai_agentbox-0.1.1/PKG-INFO +235 -0
- ai_agentbox-0.1.1/README.md +204 -0
- ai_agentbox-0.1.1/pyproject.toml +49 -0
- ai_agentbox-0.1.1/src/agentbox/__init__.py +5 -0
- ai_agentbox-0.1.1/src/agentbox/__main__.py +11 -0
- ai_agentbox-0.1.1/src/agentbox/cli.py +157 -0
- ai_agentbox-0.1.1/src/agentbox/client.py +121 -0
- ai_agentbox-0.1.1/src/agentbox/config.py +55 -0
- ai_agentbox-0.1.1/src/agentbox/worker.py +645 -0
- ai_agentbox-0.1.1/tests/test_worker.py +87 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# Virtual environments
|
|
30
|
+
.env
|
|
31
|
+
.venv
|
|
32
|
+
env/
|
|
33
|
+
venv/
|
|
34
|
+
ENV/
|
|
35
|
+
env.bak/
|
|
36
|
+
venv.bak/
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.nox/
|
|
42
|
+
.coverage
|
|
43
|
+
.coverage.*
|
|
44
|
+
.cache
|
|
45
|
+
nosetests.xml
|
|
46
|
+
coverage.xml
|
|
47
|
+
*.cover
|
|
48
|
+
*.py,cover
|
|
49
|
+
.hypothesis/
|
|
50
|
+
.pytest_cache/
|
|
51
|
+
|
|
52
|
+
# IDE & Editor files
|
|
53
|
+
.vscode/
|
|
54
|
+
.idea/
|
|
55
|
+
*.swp
|
|
56
|
+
*.bak
|
|
57
|
+
|
|
58
|
+
# OS generated
|
|
59
|
+
.DS_Store
|
|
60
|
+
Thumbs.db
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentBox Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ai-agentbox
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Token-efficient remote execution, AST outlining, and safe patching tool for AI agents.
|
|
5
|
+
Project-URL: Homepage, https://github.com/agentbox-cli/agentbox
|
|
6
|
+
Project-URL: Repository, https://github.com/agentbox-cli/agentbox
|
|
7
|
+
Project-URL: Issues, https://github.com/agentbox-cli/agentbox/issues
|
|
8
|
+
Author: AgentBox Team
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agents,ai,ast,cli,llm,remote-development,ssh,tokens
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: build>=1.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: twine>=4.0; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# 📦 AgentBox (`ai-agentbox`)
|
|
33
|
+
|
|
34
|
+
[](https://pypi.org/project/ai-agentbox/)
|
|
35
|
+
[](https://opensource.org/licenses/MIT)
|
|
36
|
+
[](https://www.python.org/downloads/)
|
|
37
|
+
[](#zero-dependencies)
|
|
38
|
+
|
|
39
|
+
**Ultra-lean, token-efficient remote execution, AST outlining, and safe atomic patching proxy for AI coding agents.**
|
|
40
|
+
|
|
41
|
+
Designed for LLM agents (**Claude Code, Cursor, Antigravity, Aider, Roo-Code, Windsurf**) working on remote servers or local machines.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 🎯 The Problem
|
|
46
|
+
|
|
47
|
+
When AI coding assistants work over SSH or terminal sessions, they burn massive token budgets on:
|
|
48
|
+
1. **Dumping entire files** (hundreds of lines of code just to locate one function).
|
|
49
|
+
2. **Intermediate noise from long commands** (`cargo build`, `pytest`, `docker build` streaming lines every second and triggering unnecessary agent turns).
|
|
50
|
+
3. **Broken shell quoting** (escaping nested quotes `\"` and `'` in bash over SSH leads to repeated syntax errors and retry loops).
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## ⚡ The Solution: AgentBox
|
|
55
|
+
|
|
56
|
+
AgentBox provides a **Client $\leftrightarrow$ Worker** architecture that reduces token consumption by **80% to 95%**:
|
|
57
|
+
|
|
58
|
+
| Task | Standard AI Agent over SSH | With AgentBox | Token Savings |
|
|
59
|
+
|---|:---:|:---:|:---:|
|
|
60
|
+
| **Analyze 800-line file** | Reads full file (`~3,000` tokens) | `agentbox outline` (`~120` tokens) | **-96%** ⚡ |
|
|
61
|
+
| **Inspect target function** | Guesses line ranges (`~600` tokens) | `agentbox get-fn` (`~150` tokens) | **-75%** 📉 |
|
|
62
|
+
| **Run long build (`cargo`)** | Streams 200 lines (`~1,500` tokens) | `agentbox run` silent (`~40` tokens) | **-97%** ⚡ |
|
|
63
|
+
| **Atomic in-place patch** | Raw diff / cat (`~400` tokens) | `agentbox patch` (`~60` tokens) | **-85%** 📉 |
|
|
64
|
+
| **Project navigation** | `find .` / `tree` (`~1,200` tokens) | `agentbox tree` (`~150` tokens) | **-88%** 📉 |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 🚀 Key Features
|
|
69
|
+
|
|
70
|
+
* **Zero External Dependencies**: Built entirely on the Python 3 standard library.
|
|
71
|
+
* **Self-Bootstrapping Worker**: When targeting a remote SSH server, AgentBox automatically verifies, hashes, and deploys its standalone worker in milliseconds.
|
|
72
|
+
* **Silent Task Runner**: Suppresses intermediate stdout noise, streams to a local log file, and returns only execution time, exit code, and failure tail.
|
|
73
|
+
* **Background Process Manager**: Detached process spawning (`spawn`, `status`, `logs`, `kill`) that survives SSH disconnections.
|
|
74
|
+
* **AST-Powered Skeletons**: Extracts class and function signatures for Python, Rust, JavaScript, TypeScript, C/C++, and Go.
|
|
75
|
+
* **Escape-Proof Atomic Patching**: Sends replacement payloads over stdin IPC streams, eliminating bash quote escaping bugs forever.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 📦 Installation
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip install ai-agentbox
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 🛠️ Quickstart
|
|
88
|
+
|
|
89
|
+
### 1. Configure Target (Optional)
|
|
90
|
+
|
|
91
|
+
Configure your remote SSH server once (stored in `.agentbox.json` or `~/.agentbox/config.json`):
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
agentbox config --set-host user@192.168.1.171 --set-cwd ~/my_project
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Or pass `--host` and `--cwd` directly to any command:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
agentbox --host user@192.168.1.171 --cwd ~/my_project tree
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
To run **locally**, simply omit the host:
|
|
104
|
+
```bash
|
|
105
|
+
agentbox tree
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 📖 Command Reference
|
|
111
|
+
|
|
112
|
+
### 1. Code Navigation & Skeletons
|
|
113
|
+
|
|
114
|
+
#### `agentbox outline <file>`
|
|
115
|
+
Extracts only class, function, and method signatures with line numbers:
|
|
116
|
+
```bash
|
|
117
|
+
agentbox outline src/gateway.py
|
|
118
|
+
```
|
|
119
|
+
*Output:*
|
|
120
|
+
```text
|
|
121
|
+
=== OUTLINE: gateway.py (350 lines) ===
|
|
122
|
+
12- 45 | class GatewayConfig:
|
|
123
|
+
48- 110 | async def handle_connection(reader, writer) -> bool
|
|
124
|
+
115- 180 | def commit_flash_block(offset: int) -> None
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### `agentbox get-fn <file> <function_name>`
|
|
128
|
+
Extracts the exact definition and body of a target function:
|
|
129
|
+
```bash
|
|
130
|
+
agentbox get-fn src/gateway.py handle_connection
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### `agentbox view <file> [--start N] [--end M]`
|
|
134
|
+
Displays an exact line slice with 1-indexed line numbers:
|
|
135
|
+
```bash
|
|
136
|
+
agentbox view src/gateway.py --start 48 --end 65
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### 2. Silent & Background Process Runner
|
|
142
|
+
|
|
143
|
+
#### `agentbox run "<command>" [--tail N] [--timeout T]`
|
|
144
|
+
Silently executes a command, redirects all stdout/stderr to a log file, and returns only the final verdict:
|
|
145
|
+
```bash
|
|
146
|
+
agentbox run "cargo build --release"
|
|
147
|
+
```
|
|
148
|
+
*Output on success:*
|
|
149
|
+
```text
|
|
150
|
+
OK [exit 0, 42.15s] Log: /tmp/agent_logs/task_123456.log
|
|
151
|
+
```
|
|
152
|
+
*Output on failure (automatically prints tail):*
|
|
153
|
+
```text
|
|
154
|
+
FAILED [exit 1, 12.30s] Log: /tmp/agent_logs/task_123456.log
|
|
155
|
+
--- Failure Tail (5 lines) ---
|
|
156
|
+
error[E0308]: mismatched types
|
|
157
|
+
--> src/main.rs:42:15
|
|
158
|
+
|
|
|
159
|
+
42 | let x: u8 = val;
|
|
160
|
+
| ^^^ expected `u8`, found `u16`
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### `agentbox spawn "<command>"`
|
|
164
|
+
Spawns a detached background task that survives SSH disconnects:
|
|
165
|
+
```bash
|
|
166
|
+
agentbox spawn "python3 train_model.py"
|
|
167
|
+
# Output: SPAWNED: task_id=bg_849201 pid=4215 log=/tmp/agent_logs/bg_849201.log
|
|
168
|
+
|
|
169
|
+
agentbox status bg_849201
|
|
170
|
+
# Output: TASK: bg_849201 | Status: RUNNING | PID: 4215 | Runtime: 1m 24s
|
|
171
|
+
|
|
172
|
+
agentbox logs bg_849201 -n 20
|
|
173
|
+
# Output: displays last 20 lines of log
|
|
174
|
+
|
|
175
|
+
agentbox logs bg_849201 -f
|
|
176
|
+
# Output: live real-time log streaming (tail -f)
|
|
177
|
+
|
|
178
|
+
agentbox kill bg_849201
|
|
179
|
+
# Output: OK: Task bg_849201 (PID 4215) terminated.
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
### 3. Safe Atomic Patching
|
|
185
|
+
|
|
186
|
+
#### `agentbox patch <file> --old "<exact_code>" --new "<replacement>"`
|
|
187
|
+
Safely replaces code with automatic `.bak` backup creation:
|
|
188
|
+
```bash
|
|
189
|
+
agentbox patch src/config.py --old 'PORT = 8000' --new 'PORT = 9000'
|
|
190
|
+
# Output: OK: Replaced 1 occurrence(s) in config.py. Backup: config.py.bak
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### `agentbox rollback <file>`
|
|
194
|
+
Restores file from backup in case of errors:
|
|
195
|
+
```bash
|
|
196
|
+
agentbox rollback src/config.py
|
|
197
|
+
# Output: OK: Restored config.py from backup and removed backup.
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
### 4. Search & Directory Tree
|
|
203
|
+
|
|
204
|
+
#### `agentbox tree [path] [--depth N]`
|
|
205
|
+
Prints clean directory structure while automatically ignoring `.git`, `node_modules`, `target`, `__pycache__`, `.venv`, and build artifacts:
|
|
206
|
+
```bash
|
|
207
|
+
agentbox tree --depth 2
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
#### `agentbox grep "<query>" [path] [--max N]`
|
|
211
|
+
Fast token-limited search across text files:
|
|
212
|
+
```bash
|
|
213
|
+
agentbox grep "handle_packet" src/ --max 10
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 🤖 System Prompt for AI Agents
|
|
219
|
+
|
|
220
|
+
Add this rule to your project's `AGENTS.md` or `.cursorrules` to instruct your AI agent to use `agentbox`:
|
|
221
|
+
|
|
222
|
+
```markdown
|
|
223
|
+
## Remote & Local Execution (AgentBox)
|
|
224
|
+
Always use `agentbox` for remote server operations to minimize token consumption:
|
|
225
|
+
1. Use `agentbox outline <file>` before reading entire files.
|
|
226
|
+
2. Use `agentbox get-fn <file> <name>` to read specific functions.
|
|
227
|
+
3. Use `agentbox run "<command>"` for all builds, tests, and long commands.
|
|
228
|
+
4. Use `agentbox patch <file> --old "..." --new "..."` for code modifications.
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## 📄 License
|
|
234
|
+
|
|
235
|
+
MIT License. Free for open-source and commercial use.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# 📦 AgentBox (`ai-agentbox`)
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/ai-agentbox/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](#zero-dependencies)
|
|
7
|
+
|
|
8
|
+
**Ultra-lean, token-efficient remote execution, AST outlining, and safe atomic patching proxy for AI coding agents.**
|
|
9
|
+
|
|
10
|
+
Designed for LLM agents (**Claude Code, Cursor, Antigravity, Aider, Roo-Code, Windsurf**) working on remote servers or local machines.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 🎯 The Problem
|
|
15
|
+
|
|
16
|
+
When AI coding assistants work over SSH or terminal sessions, they burn massive token budgets on:
|
|
17
|
+
1. **Dumping entire files** (hundreds of lines of code just to locate one function).
|
|
18
|
+
2. **Intermediate noise from long commands** (`cargo build`, `pytest`, `docker build` streaming lines every second and triggering unnecessary agent turns).
|
|
19
|
+
3. **Broken shell quoting** (escaping nested quotes `\"` and `'` in bash over SSH leads to repeated syntax errors and retry loops).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ⚡ The Solution: AgentBox
|
|
24
|
+
|
|
25
|
+
AgentBox provides a **Client $\leftrightarrow$ Worker** architecture that reduces token consumption by **80% to 95%**:
|
|
26
|
+
|
|
27
|
+
| Task | Standard AI Agent over SSH | With AgentBox | Token Savings |
|
|
28
|
+
|---|:---:|:---:|:---:|
|
|
29
|
+
| **Analyze 800-line file** | Reads full file (`~3,000` tokens) | `agentbox outline` (`~120` tokens) | **-96%** ⚡ |
|
|
30
|
+
| **Inspect target function** | Guesses line ranges (`~600` tokens) | `agentbox get-fn` (`~150` tokens) | **-75%** 📉 |
|
|
31
|
+
| **Run long build (`cargo`)** | Streams 200 lines (`~1,500` tokens) | `agentbox run` silent (`~40` tokens) | **-97%** ⚡ |
|
|
32
|
+
| **Atomic in-place patch** | Raw diff / cat (`~400` tokens) | `agentbox patch` (`~60` tokens) | **-85%** 📉 |
|
|
33
|
+
| **Project navigation** | `find .` / `tree` (`~1,200` tokens) | `agentbox tree` (`~150` tokens) | **-88%** 📉 |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🚀 Key Features
|
|
38
|
+
|
|
39
|
+
* **Zero External Dependencies**: Built entirely on the Python 3 standard library.
|
|
40
|
+
* **Self-Bootstrapping Worker**: When targeting a remote SSH server, AgentBox automatically verifies, hashes, and deploys its standalone worker in milliseconds.
|
|
41
|
+
* **Silent Task Runner**: Suppresses intermediate stdout noise, streams to a local log file, and returns only execution time, exit code, and failure tail.
|
|
42
|
+
* **Background Process Manager**: Detached process spawning (`spawn`, `status`, `logs`, `kill`) that survives SSH disconnections.
|
|
43
|
+
* **AST-Powered Skeletons**: Extracts class and function signatures for Python, Rust, JavaScript, TypeScript, C/C++, and Go.
|
|
44
|
+
* **Escape-Proof Atomic Patching**: Sends replacement payloads over stdin IPC streams, eliminating bash quote escaping bugs forever.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 📦 Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install ai-agentbox
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 🛠️ Quickstart
|
|
57
|
+
|
|
58
|
+
### 1. Configure Target (Optional)
|
|
59
|
+
|
|
60
|
+
Configure your remote SSH server once (stored in `.agentbox.json` or `~/.agentbox/config.json`):
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
agentbox config --set-host user@192.168.1.171 --set-cwd ~/my_project
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or pass `--host` and `--cwd` directly to any command:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
agentbox --host user@192.168.1.171 --cwd ~/my_project tree
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
To run **locally**, simply omit the host:
|
|
73
|
+
```bash
|
|
74
|
+
agentbox tree
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 📖 Command Reference
|
|
80
|
+
|
|
81
|
+
### 1. Code Navigation & Skeletons
|
|
82
|
+
|
|
83
|
+
#### `agentbox outline <file>`
|
|
84
|
+
Extracts only class, function, and method signatures with line numbers:
|
|
85
|
+
```bash
|
|
86
|
+
agentbox outline src/gateway.py
|
|
87
|
+
```
|
|
88
|
+
*Output:*
|
|
89
|
+
```text
|
|
90
|
+
=== OUTLINE: gateway.py (350 lines) ===
|
|
91
|
+
12- 45 | class GatewayConfig:
|
|
92
|
+
48- 110 | async def handle_connection(reader, writer) -> bool
|
|
93
|
+
115- 180 | def commit_flash_block(offset: int) -> None
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### `agentbox get-fn <file> <function_name>`
|
|
97
|
+
Extracts the exact definition and body of a target function:
|
|
98
|
+
```bash
|
|
99
|
+
agentbox get-fn src/gateway.py handle_connection
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### `agentbox view <file> [--start N] [--end M]`
|
|
103
|
+
Displays an exact line slice with 1-indexed line numbers:
|
|
104
|
+
```bash
|
|
105
|
+
agentbox view src/gateway.py --start 48 --end 65
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### 2. Silent & Background Process Runner
|
|
111
|
+
|
|
112
|
+
#### `agentbox run "<command>" [--tail N] [--timeout T]`
|
|
113
|
+
Silently executes a command, redirects all stdout/stderr to a log file, and returns only the final verdict:
|
|
114
|
+
```bash
|
|
115
|
+
agentbox run "cargo build --release"
|
|
116
|
+
```
|
|
117
|
+
*Output on success:*
|
|
118
|
+
```text
|
|
119
|
+
OK [exit 0, 42.15s] Log: /tmp/agent_logs/task_123456.log
|
|
120
|
+
```
|
|
121
|
+
*Output on failure (automatically prints tail):*
|
|
122
|
+
```text
|
|
123
|
+
FAILED [exit 1, 12.30s] Log: /tmp/agent_logs/task_123456.log
|
|
124
|
+
--- Failure Tail (5 lines) ---
|
|
125
|
+
error[E0308]: mismatched types
|
|
126
|
+
--> src/main.rs:42:15
|
|
127
|
+
|
|
|
128
|
+
42 | let x: u8 = val;
|
|
129
|
+
| ^^^ expected `u8`, found `u16`
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### `agentbox spawn "<command>"`
|
|
133
|
+
Spawns a detached background task that survives SSH disconnects:
|
|
134
|
+
```bash
|
|
135
|
+
agentbox spawn "python3 train_model.py"
|
|
136
|
+
# Output: SPAWNED: task_id=bg_849201 pid=4215 log=/tmp/agent_logs/bg_849201.log
|
|
137
|
+
|
|
138
|
+
agentbox status bg_849201
|
|
139
|
+
# Output: TASK: bg_849201 | Status: RUNNING | PID: 4215 | Runtime: 1m 24s
|
|
140
|
+
|
|
141
|
+
agentbox logs bg_849201 -n 20
|
|
142
|
+
# Output: displays last 20 lines of log
|
|
143
|
+
|
|
144
|
+
agentbox logs bg_849201 -f
|
|
145
|
+
# Output: live real-time log streaming (tail -f)
|
|
146
|
+
|
|
147
|
+
agentbox kill bg_849201
|
|
148
|
+
# Output: OK: Task bg_849201 (PID 4215) terminated.
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### 3. Safe Atomic Patching
|
|
154
|
+
|
|
155
|
+
#### `agentbox patch <file> --old "<exact_code>" --new "<replacement>"`
|
|
156
|
+
Safely replaces code with automatic `.bak` backup creation:
|
|
157
|
+
```bash
|
|
158
|
+
agentbox patch src/config.py --old 'PORT = 8000' --new 'PORT = 9000'
|
|
159
|
+
# Output: OK: Replaced 1 occurrence(s) in config.py. Backup: config.py.bak
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### `agentbox rollback <file>`
|
|
163
|
+
Restores file from backup in case of errors:
|
|
164
|
+
```bash
|
|
165
|
+
agentbox rollback src/config.py
|
|
166
|
+
# Output: OK: Restored config.py from backup and removed backup.
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### 4. Search & Directory Tree
|
|
172
|
+
|
|
173
|
+
#### `agentbox tree [path] [--depth N]`
|
|
174
|
+
Prints clean directory structure while automatically ignoring `.git`, `node_modules`, `target`, `__pycache__`, `.venv`, and build artifacts:
|
|
175
|
+
```bash
|
|
176
|
+
agentbox tree --depth 2
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### `agentbox grep "<query>" [path] [--max N]`
|
|
180
|
+
Fast token-limited search across text files:
|
|
181
|
+
```bash
|
|
182
|
+
agentbox grep "handle_packet" src/ --max 10
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 🤖 System Prompt for AI Agents
|
|
188
|
+
|
|
189
|
+
Add this rule to your project's `AGENTS.md` or `.cursorrules` to instruct your AI agent to use `agentbox`:
|
|
190
|
+
|
|
191
|
+
```markdown
|
|
192
|
+
## Remote & Local Execution (AgentBox)
|
|
193
|
+
Always use `agentbox` for remote server operations to minimize token consumption:
|
|
194
|
+
1. Use `agentbox outline <file>` before reading entire files.
|
|
195
|
+
2. Use `agentbox get-fn <file> <name>` to read specific functions.
|
|
196
|
+
3. Use `agentbox run "<command>"` for all builds, tests, and long commands.
|
|
197
|
+
4. Use `agentbox patch <file> --old "..." --new "..."` for code modifications.
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 📄 License
|
|
203
|
+
|
|
204
|
+
MIT License. Free for open-source and commercial use.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ai-agentbox"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Token-efficient remote execution, AST outlining, and safe patching tool for AI agents."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
keywords = ["ai", "agents", "llm", "tokens", "ssh", "ast", "cli", "remote-development"]
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "AgentBox Team" }
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.8",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Programming Language :: Python :: 3.14",
|
|
28
|
+
"Topic :: Software Development :: Build Tools",
|
|
29
|
+
"Topic :: Utilities",
|
|
30
|
+
]
|
|
31
|
+
dependencies = []
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"pytest>=7.0",
|
|
36
|
+
"twine>=4.0",
|
|
37
|
+
"build>=1.0",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
agentbox = "agentbox.cli:main"
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/agentbox-cli/agentbox"
|
|
45
|
+
Repository = "https://github.com/agentbox-cli/agentbox"
|
|
46
|
+
Issues = "https://github.com/agentbox-cli/agentbox/issues"
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.wheel]
|
|
49
|
+
packages = ["src/agentbox"]
|