agentcode-cli 1.0.0__tar.gz → 1.2.0__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.
@@ -0,0 +1,362 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentcode-cli
3
+ Version: 1.2.0
4
+ Summary: An open, multi-model agentic coding CLI — inspired by Claude Code
5
+ Author: Vignesh Pai
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Vignesh Pai
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/vigp17/AgentCode
29
+ Project-URL: Repository, https://github.com/vigp17/AgentCode
30
+ Project-URL: Bug Tracker, https://github.com/vigp17/AgentCode/issues
31
+ Classifier: Programming Language :: Python :: 3
32
+ Classifier: Programming Language :: Python :: 3.11
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: OS Independent
35
+ Classifier: Environment :: Console
36
+ Classifier: Topic :: Software Development
37
+ Classifier: Topic :: Utilities
38
+ Requires-Python: >=3.11
39
+ Description-Content-Type: text/markdown
40
+ License-File: LICENSE
41
+ Requires-Dist: litellm>=1.40.0
42
+ Requires-Dist: rich>=13.0.0
43
+ Requires-Dist: python-dotenv>=1.0.0
44
+ Requires-Dist: mcp>=1.0.0
45
+ Provides-Extra: dev
46
+ Requires-Dist: build; extra == "dev"
47
+ Requires-Dist: twine; extra == "dev"
48
+ Dynamic: license-file
49
+
50
+ # AgentCode
51
+
52
+ An open, multi-model agentic coding assistant — available as a CLI and VS Code extension. Inspired by Claude Code.
53
+
54
+ Works with Claude, GPT, Gemini, and any model supported by [LiteLLM](https://docs.litellm.ai/docs/providers).
55
+
56
+ ---
57
+
58
+ ## Choose your setup
59
+
60
+ ### Option A: CLI only
61
+
62
+ ```bash
63
+ pip install agentcode-cli
64
+ ```
65
+
66
+ Add your API key to a `.env` file in your project:
67
+
68
+ ```
69
+ ANTHROPIC_API_KEY=sk-ant-...
70
+ OPENAI_API_KEY=sk-... # optional
71
+ GEMINI_API_KEY=... # optional
72
+ ```
73
+
74
+ Run:
75
+
76
+ ```bash
77
+ agentcode # interactive REPL
78
+ agentcode "fix the failing tests" # one-shot mode
79
+ agentcode --model gpt-4o # use a specific model
80
+ ```
81
+
82
+ ---
83
+
84
+ ### Option B: VS Code Extension
85
+
86
+ > The extension requires the CLI installed as a backend. Install it first.
87
+
88
+ **Step 1 — Install the CLI:**
89
+ ```bash
90
+ pip install agentcode-cli
91
+ ```
92
+
93
+ **Step 2 — Install the extension:**
94
+ - Search **AgentCode** in the VS Code Marketplace and install, or
95
+ - Download `agentcode-1.1.1.vsix` from the [GitHub releases page](https://github.com/vigp17/AgentCode/releases) and install via `Cmd+Shift+X` → `...` → **Install from VSIX...**
96
+
97
+ **Step 3 — Add your API key:**
98
+ `Cmd+,` → search **AgentCode** → paste your key into `agentcode.anthropicApiKey`
99
+
100
+ **Step 4 — Open the chat panel:**
101
+ Press `Cmd+Shift+A`
102
+
103
+ #### Extension settings
104
+
105
+ | Setting | Description |
106
+ |---------|-------------|
107
+ | `agentcode.anthropicApiKey` | Anthropic API key |
108
+ | `agentcode.openaiApiKey` | OpenAI API key |
109
+ | `agentcode.geminiApiKey` | Google Gemini API key |
110
+ | `agentcode.model` | Default model (e.g. `claude-sonnet-4-6`) |
111
+ | `agentcode.executablePath` | Path to `agentcode` if not on PATH |
112
+ | `agentcode.inlineCompletions.enabled` | Enable/disable inline completions (default: `true`) |
113
+
114
+ #### Extension commands
115
+
116
+ | Command | Shortcut | Description |
117
+ |---------|----------|-------------|
118
+ | `AgentCode: Open` | `Cmd+Shift+A` | Open the chat panel |
119
+ | `AgentCode: Ask about selection` | Right-click | Ask about highlighted code |
120
+ | `AgentCode: Explain this file` | Right-click | Explain the current file |
121
+ | `AgentCode: Toggle inline completions` | Command Palette | Enable or disable inline completions |
122
+
123
+ #### Extension features
124
+
125
+ - **Inline completions** — AI-powered ghost-text suggestions as you type, powered by Claude Haiku. Press `Tab` to accept
126
+ - **Live streaming** — responses stream in real time
127
+ - **Model picker** — switch between Claude, GPT, and Gemini models from the dropdown in the header
128
+ - **Active file context** — your current file is sent automatically, no copy-pasting needed
129
+ - **Diff viewer** — edit tool calls open VS Code's native diff viewer so you can review changes before applying
130
+ - **Right-click actions** — ask about selected code or explain a file directly from the editor
131
+
132
+ ---
133
+
134
+ ## Supported Models
135
+
136
+ | Provider | Model | API Key |
137
+ |----------|-------|---------|
138
+ | Anthropic | `claude-sonnet-4-6` (default) | `ANTHROPIC_API_KEY` |
139
+ | Anthropic | `claude-opus-4-7` | `ANTHROPIC_API_KEY` |
140
+ | Anthropic | `claude-haiku-4-5-20251001` | `ANTHROPIC_API_KEY` |
141
+ | OpenAI | `gpt-4o`, `gpt-4o-mini`, `gpt-5.5` | `OPENAI_API_KEY` |
142
+ | Google | `gemini/gemini-2.5-pro`, `gemini/gemini-2.5-flash` | `GEMINI_API_KEY` |
143
+
144
+ ---
145
+
146
+ ## Cost-Aware Routing
147
+
148
+ AgentCode automatically picks the cheapest model that can handle the task:
149
+
150
+ | Tier | Anthropic | OpenAI | Gemini |
151
+ |------|-----------|--------|--------|
152
+ | Light | Haiku 4.5 | GPT-4o Mini | Gemini 2.0 Flash |
153
+ | Medium | Sonnet 4.6 | GPT-4o | Gemini 2.5 Flash |
154
+ | Heavy | Opus 4.7 | GPT-5.5 | Gemini 2.5 Pro |
155
+
156
+ Simple questions go to cheap/fast models. Complex multi-file tasks go to powerful ones. Use `--no-route` to always use the specified model.
157
+
158
+ ---
159
+
160
+ ## Tools
161
+
162
+ ### File & Shell
163
+
164
+ | Tool | Description | Permission |
165
+ |------|-------------|------------|
166
+ | `read_file` | Read file contents with line numbers | Auto |
167
+ | `write_file` | Create or overwrite a file | Ask |
168
+ | `edit_file` | Surgical find-and-replace edit | Ask |
169
+ | `run_command` | Execute a bash command | Ask |
170
+ | `list_directory` | Tree view of directory structure | Auto |
171
+ | `search_files` | Find files by glob pattern | Auto |
172
+ | `search_text` | Grep for text across files | Auto |
173
+
174
+ ### Git
175
+
176
+ | Tool | Description | Permission |
177
+ |------|-------------|------------|
178
+ | `git_status` | Show working tree status | Auto |
179
+ | `git_diff` | Show staged or unstaged changes | Auto |
180
+ | `git_log` | Show recent commit history | Auto |
181
+ | `git_commit` | Stage files and create a commit | Ask |
182
+ | `git_branch` | List, create, or switch branches | Ask |
183
+ | `git_push` | Push commits to a remote | Ask |
184
+
185
+ ### Subagents
186
+
187
+ | Tool | Description | Permission |
188
+ |------|-------------|------------|
189
+ | `spawn_subagents` | Run multiple agents in parallel on subtasks | Auto |
190
+
191
+ **Permission model:** Read-only tools auto-approve. Write/execute tools ask before running (unless `--auto-approve` / `-y` is set).
192
+
193
+ ---
194
+
195
+ ## Slash Commands (CLI only)
196
+
197
+ | Command | Description |
198
+ |---------|-------------|
199
+ | `/model <name>` | Switch model on the fly |
200
+ | `/route` | Show or toggle cost-aware routing |
201
+ | `/cost` | Show session cost breakdown |
202
+ | `/mcp` | Manage MCP server connections |
203
+ | `/mcp list` | Show connected servers |
204
+ | `/mcp add <server>` | Connect a server |
205
+ | `/mcp remove <server>` | Disconnect a server |
206
+ | `/clear` | Reset conversation and delete saved session |
207
+ | `/compact` | Force LLM-powered context compaction |
208
+ | `/tokens` | Show estimated token usage |
209
+ | `/init` | Create an AGENTCODE.md template |
210
+ | `/settings` | Show resolved settings |
211
+ | `/help` | Show help |
212
+ | `/exit` | Quit |
213
+
214
+ ---
215
+
216
+ ## Session Persistence
217
+
218
+ Conversations are automatically saved to `.agentcode_session.json` in your project directory and resumed on next launch. Use `/clear` to start fresh.
219
+
220
+ ---
221
+
222
+ ## MCP Support (CLI only)
223
+
224
+ Connect to any [MCP server](https://modelcontextprotocol.io) using `/mcp add`:
225
+
226
+ ```
227
+ /mcp add github # prompts for GitHub token
228
+ /mcp add filesystem # no credentials needed
229
+ /mcp add postgres # prompts for connection string
230
+ /mcp add sqlite # prompts for database path
231
+ ```
232
+
233
+ Config is saved to `.agentcode/mcp.json` and reloaded on next launch.
234
+
235
+ **Advanced** — edit `.agentcode/mcp.json` directly for custom servers:
236
+
237
+ ```json
238
+ {
239
+ "mcpServers": {
240
+ "my-server": {
241
+ "command": "npx",
242
+ "args": ["-y", "@myorg/mcp-server"],
243
+ "env": {"API_KEY": "..."}
244
+ }
245
+ }
246
+ }
247
+ ```
248
+
249
+ Global config goes in `~/.agentcode/mcp.json`.
250
+
251
+ ---
252
+
253
+ ## Hooks
254
+
255
+ Run shell commands before or after any tool call. Create `.agentcode/hooks.json`:
256
+
257
+ ```json
258
+ {
259
+ "post_edit_file": "prettier --write \"$AGENTCODE_PATH\"",
260
+ "post_write_file": "prettier --write \"$AGENTCODE_PATH\"",
261
+ "pre_run_command": "echo \"Running: $AGENTCODE_COMMAND\""
262
+ }
263
+ ```
264
+
265
+ Supported keys: `pre_<toolname>`, `post_<toolname>`, `pre_tool` / `post_tool` (wildcard). Global hooks go in `~/.agentcode/hooks.json`.
266
+
267
+ ---
268
+
269
+ ## AGENTCODE.md
270
+
271
+ AgentCode loads project instructions from `AGENTCODE.md` in your project directory and injects them into the system prompt automatically. Run `/init` to generate a starter template.
272
+
273
+ ---
274
+
275
+ ## Subagents
276
+
277
+ AgentCode can spawn parallel agents for independent subtasks:
278
+
279
+ > "Analyze agent.py, router.py, and tools.py in parallel and summarize each one"
280
+
281
+ The agent calls `spawn_subagents` internally, runs up to 5 agents in parallel, and returns combined results.
282
+
283
+ ---
284
+
285
+ ## Architecture
286
+
287
+ ```
288
+ ┌─────────────────────────────────────────────────┐
289
+ │ cli.py (UI) │
290
+ │ REPL loop · slash commands · Rich terminal UI │
291
+ │ AGENTCODE.md · session persistence │
292
+ └──────────────────────┬──────────────────────────┘
293
+
294
+ ┌──────────────────────▼──────────────────────────┐
295
+ │ agent.py (Brain) │
296
+ │ Agentic loop · context management · permissions│
297
+ │ Hooks · subagents · LLM-powered compaction │
298
+ │ │
299
+ │ while needs_follow_up: │
300
+ │ 1. Send messages + tools → LLM │
301
+ │ 2. If tool_calls → execute, append, loop │
302
+ │ 3. If text only → done │
303
+ │ │
304
+ │ LiteLLM ──→ Claude / GPT / Gemini │
305
+ └──────────────────────┬──────────────────────────┘
306
+
307
+ ┌────────────┴────────────┐
308
+ │ │
309
+ ┌─────────▼───────────┐ ┌─────────▼───────────┐
310
+ │ tools.py (Hands) │ │ mcp_client.py │
311
+ │ read_file │ │ Connect to MCP │
312
+ │ write_file │ │ servers and expose │
313
+ │ edit_file │ │ their tools to the │
314
+ │ run_command │ │ agent loop. │
315
+ │ list_directory │ └─────────────────────┘
316
+ │ search_files │
317
+ │ search_text │
318
+ │ git_status/diff │
319
+ │ git_log/commit │
320
+ │ git_branch/push │
321
+ │ spawn_subagents │
322
+ └─────────────────────┘
323
+ ```
324
+
325
+ ---
326
+
327
+ ## Environment Variables
328
+
329
+ | Variable | Description | Default |
330
+ |----------|-------------|---------|
331
+ | `AGENTCODE_MODEL` | Default model | `claude-sonnet-4-6` |
332
+ | `AGENTCODE_MAX_ITERATIONS` | Max tool-call iterations per turn | `25` |
333
+ | `ANTHROPIC_API_KEY` | Anthropic API key | — |
334
+ | `OPENAI_API_KEY` | OpenAI API key | — |
335
+ | `GEMINI_API_KEY` | Google Gemini API key | — |
336
+
337
+ ---
338
+
339
+ ## How to Extend
340
+
341
+ ### Add a new tool
342
+
343
+ 1. Add the function schema to `TOOL_DEFINITIONS` in `tools.py`
344
+ 2. Implement the function
345
+ 3. Register it in `TOOL_MAP`
346
+ 4. If it requires approval, omit it from `permissions.auto_approve` in `.agentcode/settings.json`
347
+
348
+ ---
349
+
350
+ ## Publishing to PyPI
351
+
352
+ ```bash
353
+ pip install build twine
354
+ python -m build
355
+ twine upload dist/*
356
+ ```
357
+
358
+ ---
359
+
360
+ ## License
361
+
362
+ MIT
@@ -0,0 +1,313 @@
1
+ # AgentCode
2
+
3
+ An open, multi-model agentic coding assistant — available as a CLI and VS Code extension. Inspired by Claude Code.
4
+
5
+ Works with Claude, GPT, Gemini, and any model supported by [LiteLLM](https://docs.litellm.ai/docs/providers).
6
+
7
+ ---
8
+
9
+ ## Choose your setup
10
+
11
+ ### Option A: CLI only
12
+
13
+ ```bash
14
+ pip install agentcode-cli
15
+ ```
16
+
17
+ Add your API key to a `.env` file in your project:
18
+
19
+ ```
20
+ ANTHROPIC_API_KEY=sk-ant-...
21
+ OPENAI_API_KEY=sk-... # optional
22
+ GEMINI_API_KEY=... # optional
23
+ ```
24
+
25
+ Run:
26
+
27
+ ```bash
28
+ agentcode # interactive REPL
29
+ agentcode "fix the failing tests" # one-shot mode
30
+ agentcode --model gpt-4o # use a specific model
31
+ ```
32
+
33
+ ---
34
+
35
+ ### Option B: VS Code Extension
36
+
37
+ > The extension requires the CLI installed as a backend. Install it first.
38
+
39
+ **Step 1 — Install the CLI:**
40
+ ```bash
41
+ pip install agentcode-cli
42
+ ```
43
+
44
+ **Step 2 — Install the extension:**
45
+ - Search **AgentCode** in the VS Code Marketplace and install, or
46
+ - Download `agentcode-1.1.1.vsix` from the [GitHub releases page](https://github.com/vigp17/AgentCode/releases) and install via `Cmd+Shift+X` → `...` → **Install from VSIX...**
47
+
48
+ **Step 3 — Add your API key:**
49
+ `Cmd+,` → search **AgentCode** → paste your key into `agentcode.anthropicApiKey`
50
+
51
+ **Step 4 — Open the chat panel:**
52
+ Press `Cmd+Shift+A`
53
+
54
+ #### Extension settings
55
+
56
+ | Setting | Description |
57
+ |---------|-------------|
58
+ | `agentcode.anthropicApiKey` | Anthropic API key |
59
+ | `agentcode.openaiApiKey` | OpenAI API key |
60
+ | `agentcode.geminiApiKey` | Google Gemini API key |
61
+ | `agentcode.model` | Default model (e.g. `claude-sonnet-4-6`) |
62
+ | `agentcode.executablePath` | Path to `agentcode` if not on PATH |
63
+ | `agentcode.inlineCompletions.enabled` | Enable/disable inline completions (default: `true`) |
64
+
65
+ #### Extension commands
66
+
67
+ | Command | Shortcut | Description |
68
+ |---------|----------|-------------|
69
+ | `AgentCode: Open` | `Cmd+Shift+A` | Open the chat panel |
70
+ | `AgentCode: Ask about selection` | Right-click | Ask about highlighted code |
71
+ | `AgentCode: Explain this file` | Right-click | Explain the current file |
72
+ | `AgentCode: Toggle inline completions` | Command Palette | Enable or disable inline completions |
73
+
74
+ #### Extension features
75
+
76
+ - **Inline completions** — AI-powered ghost-text suggestions as you type, powered by Claude Haiku. Press `Tab` to accept
77
+ - **Live streaming** — responses stream in real time
78
+ - **Model picker** — switch between Claude, GPT, and Gemini models from the dropdown in the header
79
+ - **Active file context** — your current file is sent automatically, no copy-pasting needed
80
+ - **Diff viewer** — edit tool calls open VS Code's native diff viewer so you can review changes before applying
81
+ - **Right-click actions** — ask about selected code or explain a file directly from the editor
82
+
83
+ ---
84
+
85
+ ## Supported Models
86
+
87
+ | Provider | Model | API Key |
88
+ |----------|-------|---------|
89
+ | Anthropic | `claude-sonnet-4-6` (default) | `ANTHROPIC_API_KEY` |
90
+ | Anthropic | `claude-opus-4-7` | `ANTHROPIC_API_KEY` |
91
+ | Anthropic | `claude-haiku-4-5-20251001` | `ANTHROPIC_API_KEY` |
92
+ | OpenAI | `gpt-4o`, `gpt-4o-mini`, `gpt-5.5` | `OPENAI_API_KEY` |
93
+ | Google | `gemini/gemini-2.5-pro`, `gemini/gemini-2.5-flash` | `GEMINI_API_KEY` |
94
+
95
+ ---
96
+
97
+ ## Cost-Aware Routing
98
+
99
+ AgentCode automatically picks the cheapest model that can handle the task:
100
+
101
+ | Tier | Anthropic | OpenAI | Gemini |
102
+ |------|-----------|--------|--------|
103
+ | Light | Haiku 4.5 | GPT-4o Mini | Gemini 2.0 Flash |
104
+ | Medium | Sonnet 4.6 | GPT-4o | Gemini 2.5 Flash |
105
+ | Heavy | Opus 4.7 | GPT-5.5 | Gemini 2.5 Pro |
106
+
107
+ Simple questions go to cheap/fast models. Complex multi-file tasks go to powerful ones. Use `--no-route` to always use the specified model.
108
+
109
+ ---
110
+
111
+ ## Tools
112
+
113
+ ### File & Shell
114
+
115
+ | Tool | Description | Permission |
116
+ |------|-------------|------------|
117
+ | `read_file` | Read file contents with line numbers | Auto |
118
+ | `write_file` | Create or overwrite a file | Ask |
119
+ | `edit_file` | Surgical find-and-replace edit | Ask |
120
+ | `run_command` | Execute a bash command | Ask |
121
+ | `list_directory` | Tree view of directory structure | Auto |
122
+ | `search_files` | Find files by glob pattern | Auto |
123
+ | `search_text` | Grep for text across files | Auto |
124
+
125
+ ### Git
126
+
127
+ | Tool | Description | Permission |
128
+ |------|-------------|------------|
129
+ | `git_status` | Show working tree status | Auto |
130
+ | `git_diff` | Show staged or unstaged changes | Auto |
131
+ | `git_log` | Show recent commit history | Auto |
132
+ | `git_commit` | Stage files and create a commit | Ask |
133
+ | `git_branch` | List, create, or switch branches | Ask |
134
+ | `git_push` | Push commits to a remote | Ask |
135
+
136
+ ### Subagents
137
+
138
+ | Tool | Description | Permission |
139
+ |------|-------------|------------|
140
+ | `spawn_subagents` | Run multiple agents in parallel on subtasks | Auto |
141
+
142
+ **Permission model:** Read-only tools auto-approve. Write/execute tools ask before running (unless `--auto-approve` / `-y` is set).
143
+
144
+ ---
145
+
146
+ ## Slash Commands (CLI only)
147
+
148
+ | Command | Description |
149
+ |---------|-------------|
150
+ | `/model <name>` | Switch model on the fly |
151
+ | `/route` | Show or toggle cost-aware routing |
152
+ | `/cost` | Show session cost breakdown |
153
+ | `/mcp` | Manage MCP server connections |
154
+ | `/mcp list` | Show connected servers |
155
+ | `/mcp add <server>` | Connect a server |
156
+ | `/mcp remove <server>` | Disconnect a server |
157
+ | `/clear` | Reset conversation and delete saved session |
158
+ | `/compact` | Force LLM-powered context compaction |
159
+ | `/tokens` | Show estimated token usage |
160
+ | `/init` | Create an AGENTCODE.md template |
161
+ | `/settings` | Show resolved settings |
162
+ | `/help` | Show help |
163
+ | `/exit` | Quit |
164
+
165
+ ---
166
+
167
+ ## Session Persistence
168
+
169
+ Conversations are automatically saved to `.agentcode_session.json` in your project directory and resumed on next launch. Use `/clear` to start fresh.
170
+
171
+ ---
172
+
173
+ ## MCP Support (CLI only)
174
+
175
+ Connect to any [MCP server](https://modelcontextprotocol.io) using `/mcp add`:
176
+
177
+ ```
178
+ /mcp add github # prompts for GitHub token
179
+ /mcp add filesystem # no credentials needed
180
+ /mcp add postgres # prompts for connection string
181
+ /mcp add sqlite # prompts for database path
182
+ ```
183
+
184
+ Config is saved to `.agentcode/mcp.json` and reloaded on next launch.
185
+
186
+ **Advanced** — edit `.agentcode/mcp.json` directly for custom servers:
187
+
188
+ ```json
189
+ {
190
+ "mcpServers": {
191
+ "my-server": {
192
+ "command": "npx",
193
+ "args": ["-y", "@myorg/mcp-server"],
194
+ "env": {"API_KEY": "..."}
195
+ }
196
+ }
197
+ }
198
+ ```
199
+
200
+ Global config goes in `~/.agentcode/mcp.json`.
201
+
202
+ ---
203
+
204
+ ## Hooks
205
+
206
+ Run shell commands before or after any tool call. Create `.agentcode/hooks.json`:
207
+
208
+ ```json
209
+ {
210
+ "post_edit_file": "prettier --write \"$AGENTCODE_PATH\"",
211
+ "post_write_file": "prettier --write \"$AGENTCODE_PATH\"",
212
+ "pre_run_command": "echo \"Running: $AGENTCODE_COMMAND\""
213
+ }
214
+ ```
215
+
216
+ Supported keys: `pre_<toolname>`, `post_<toolname>`, `pre_tool` / `post_tool` (wildcard). Global hooks go in `~/.agentcode/hooks.json`.
217
+
218
+ ---
219
+
220
+ ## AGENTCODE.md
221
+
222
+ AgentCode loads project instructions from `AGENTCODE.md` in your project directory and injects them into the system prompt automatically. Run `/init` to generate a starter template.
223
+
224
+ ---
225
+
226
+ ## Subagents
227
+
228
+ AgentCode can spawn parallel agents for independent subtasks:
229
+
230
+ > "Analyze agent.py, router.py, and tools.py in parallel and summarize each one"
231
+
232
+ The agent calls `spawn_subagents` internally, runs up to 5 agents in parallel, and returns combined results.
233
+
234
+ ---
235
+
236
+ ## Architecture
237
+
238
+ ```
239
+ ┌─────────────────────────────────────────────────┐
240
+ │ cli.py (UI) │
241
+ │ REPL loop · slash commands · Rich terminal UI │
242
+ │ AGENTCODE.md · session persistence │
243
+ └──────────────────────┬──────────────────────────┘
244
+
245
+ ┌──────────────────────▼──────────────────────────┐
246
+ │ agent.py (Brain) │
247
+ │ Agentic loop · context management · permissions│
248
+ │ Hooks · subagents · LLM-powered compaction │
249
+ │ │
250
+ │ while needs_follow_up: │
251
+ │ 1. Send messages + tools → LLM │
252
+ │ 2. If tool_calls → execute, append, loop │
253
+ │ 3. If text only → done │
254
+ │ │
255
+ │ LiteLLM ──→ Claude / GPT / Gemini │
256
+ └──────────────────────┬──────────────────────────┘
257
+
258
+ ┌────────────┴────────────┐
259
+ │ │
260
+ ┌─────────▼───────────┐ ┌─────────▼───────────┐
261
+ │ tools.py (Hands) │ │ mcp_client.py │
262
+ │ read_file │ │ Connect to MCP │
263
+ │ write_file │ │ servers and expose │
264
+ │ edit_file │ │ their tools to the │
265
+ │ run_command │ │ agent loop. │
266
+ │ list_directory │ └─────────────────────┘
267
+ │ search_files │
268
+ │ search_text │
269
+ │ git_status/diff │
270
+ │ git_log/commit │
271
+ │ git_branch/push │
272
+ │ spawn_subagents │
273
+ └─────────────────────┘
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Environment Variables
279
+
280
+ | Variable | Description | Default |
281
+ |----------|-------------|---------|
282
+ | `AGENTCODE_MODEL` | Default model | `claude-sonnet-4-6` |
283
+ | `AGENTCODE_MAX_ITERATIONS` | Max tool-call iterations per turn | `25` |
284
+ | `ANTHROPIC_API_KEY` | Anthropic API key | — |
285
+ | `OPENAI_API_KEY` | OpenAI API key | — |
286
+ | `GEMINI_API_KEY` | Google Gemini API key | — |
287
+
288
+ ---
289
+
290
+ ## How to Extend
291
+
292
+ ### Add a new tool
293
+
294
+ 1. Add the function schema to `TOOL_DEFINITIONS` in `tools.py`
295
+ 2. Implement the function
296
+ 3. Register it in `TOOL_MAP`
297
+ 4. If it requires approval, omit it from `permissions.auto_approve` in `.agentcode/settings.json`
298
+
299
+ ---
300
+
301
+ ## Publishing to PyPI
302
+
303
+ ```bash
304
+ pip install build twine
305
+ python -m build
306
+ twine upload dist/*
307
+ ```
308
+
309
+ ---
310
+
311
+ ## License
312
+
313
+ MIT