aizen-ai-cli 2.2.2__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.
- aizen_ai_cli-2.2.2/MANIFEST.in +1 -0
- aizen_ai_cli-2.2.2/PKG-INFO +267 -0
- aizen_ai_cli-2.2.2/README.md +228 -0
- aizen_ai_cli-2.2.2/aizen/__init__.py +4 -0
- aizen_ai_cli-2.2.2/aizen/commands.py +694 -0
- aizen_ai_cli-2.2.2/aizen/config.py +363 -0
- aizen_ai_cli-2.2.2/aizen/context.py +171 -0
- aizen_ai_cli-2.2.2/aizen/exceptions.py +46 -0
- aizen_ai_cli-2.2.2/aizen/logging_config.py +65 -0
- aizen_ai_cli-2.2.2/aizen/main.py +616 -0
- aizen_ai_cli-2.2.2/aizen/mcp.py +110 -0
- aizen_ai_cli-2.2.2/aizen/plugins.py +63 -0
- aizen_ai_cli-2.2.2/aizen/retry.py +133 -0
- aizen_ai_cli-2.2.2/aizen/session.py +137 -0
- aizen_ai_cli-2.2.2/aizen/tools.py +1035 -0
- aizen_ai_cli-2.2.2/aizen/utils.py +339 -0
- aizen_ai_cli-2.2.2/aizen_ai_cli.egg-info/PKG-INFO +267 -0
- aizen_ai_cli-2.2.2/aizen_ai_cli.egg-info/SOURCES.txt +32 -0
- aizen_ai_cli-2.2.2/aizen_ai_cli.egg-info/dependency_links.txt +1 -0
- aizen_ai_cli-2.2.2/aizen_ai_cli.egg-info/entry_points.txt +2 -0
- aizen_ai_cli-2.2.2/aizen_ai_cli.egg-info/requires.txt +16 -0
- aizen_ai_cli-2.2.2/aizen_ai_cli.egg-info/top_level.txt +1 -0
- aizen_ai_cli-2.2.2/pyproject.toml +79 -0
- aizen_ai_cli-2.2.2/requirements.txt +5 -0
- aizen_ai_cli-2.2.2/setup.cfg +4 -0
- aizen_ai_cli-2.2.2/setup.py +20 -0
- aizen_ai_cli-2.2.2/tests/test_commands.py +211 -0
- aizen_ai_cli-2.2.2/tests/test_config.py +110 -0
- aizen_ai_cli-2.2.2/tests/test_context.py +95 -0
- aizen_ai_cli-2.2.2/tests/test_main.py +42 -0
- aizen_ai_cli-2.2.2/tests/test_mcp.py +82 -0
- aizen_ai_cli-2.2.2/tests/test_session.py +118 -0
- aizen_ai_cli-2.2.2/tests/test_tools.py +408 -0
- aizen_ai_cli-2.2.2/tests/test_utils.py +285 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include requirements.txt
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aizen-ai-cli
|
|
3
|
+
Version: 2.2.2
|
|
4
|
+
Summary: Aizen AI Agent — A professional-grade AI coding assistant for your terminal.
|
|
5
|
+
Author: Irtaza Malik
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/irtaza302/aizen-agent
|
|
8
|
+
Project-URL: Repository, https://github.com/irtaza302/aizen-agent
|
|
9
|
+
Project-URL: Issues, https://github.com/irtaza302/aizen-agent/issues
|
|
10
|
+
Keywords: ai,cli,coding-assistant,terminal,openrouter,llm
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: Software Development
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: openai>=1.0
|
|
26
|
+
Requires-Dist: python-dotenv>=1.0
|
|
27
|
+
Requires-Dist: rich>=13.0
|
|
28
|
+
Requires-Dist: prompt_toolkit>=3.0
|
|
29
|
+
Requires-Dist: mcp>=1.0.0
|
|
30
|
+
Provides-Extra: tiktoken
|
|
31
|
+
Requires-Dist: tiktoken>=0.5; extra == "tiktoken"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-mock>=3.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
37
|
+
Requires-Dist: ruff>=0.1; extra == "dev"
|
|
38
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
39
|
+
|
|
40
|
+
# Aizen AI Agent 🚀
|
|
41
|
+
|
|
42
|
+
[](https://github.com/irtaza302/aizen-agent/actions/workflows/ci.yml)
|
|
43
|
+
|
|
44
|
+
A professional-grade AI coding assistant that runs directly in your terminal. Aizen reads your code, writes files with surgical precision, runs commands safely, and helps you build faster — all from a beautifully designed CLI.
|
|
45
|
+
|
|
46
|
+
## ✨ Features
|
|
47
|
+
|
|
48
|
+
### Core
|
|
49
|
+
- **Asynchronous Architecture** — Fully asynchronous operations leveraging `asyncio` and `AsyncOpenAI` for concurrent processing, parallel tool runs, and streaming.
|
|
50
|
+
- **Rich Markdown Rendering** — AI responses are rendered with full Markdown formatting (headers, code blocks, lists, bold/italic) via Rich's live display.
|
|
51
|
+
- **Streaming with Live Preview** — Watch responses render in real-time inside a styled panel with an animated thinking spinner.
|
|
52
|
+
- **Surgical File Editing** — The `edit_file` tool makes precise search-and-replace edits with color-coded diff previews, instead of rewriting entire files.
|
|
53
|
+
- **SQLite Session Persistence** — Session storage is powered by a SQLite database (`~/.aizen_sessions/aizen.db`), auto-migrating older JSON sessions.
|
|
54
|
+
- **Project-Specific Rules** — Customizes agent behavior per repository by auto-loading `.aizen_rules` or `.cursorrules` from the current working directory.
|
|
55
|
+
- **Smart Autocomplete** — `@`-mention files with Tab completion that respects `.gitignore` and supports directory traversal.
|
|
56
|
+
|
|
57
|
+
### Tools
|
|
58
|
+
Aizen has 9 built-in tools the AI can use:
|
|
59
|
+
|
|
60
|
+
| Tool | Description |
|
|
61
|
+
|------|-------------|
|
|
62
|
+
| `read_file` | Read file contents before making changes |
|
|
63
|
+
| `write_file` | Create new files (with preview) |
|
|
64
|
+
| `edit_file` | Surgical search-and-replace on existing files (with diff preview) |
|
|
65
|
+
| `run_command` | Execute shell commands (supports background execution; safe commands auto-run, dangerous ones require approval) |
|
|
66
|
+
| `check_background_task` | Check the status and read recent output of a command running in the background |
|
|
67
|
+
| `kill_background_task` | Kill a running background task |
|
|
68
|
+
| `list_directory` | List files/folders with sizes, respecting `.gitignore` |
|
|
69
|
+
| `grep_search` | Search for text or regex patterns across the codebase |
|
|
70
|
+
| `find_files` | Find files by glob pattern (e.g., `*.py`, `Dockerfile`) |
|
|
71
|
+
|
|
72
|
+
### Commands
|
|
73
|
+
|
|
74
|
+
| Command | Description |
|
|
75
|
+
|---------|-------------|
|
|
76
|
+
| `/help` | Show all available commands |
|
|
77
|
+
| `/model [name]` | View or switch the active AI model (saves as default) |
|
|
78
|
+
| `/clear` | Clear conversation history |
|
|
79
|
+
| `/drop` | Drop attached files/URLs/commands from history to save tokens |
|
|
80
|
+
| `/save [name]` | Save current conversation to SQLite database |
|
|
81
|
+
| `/load [name]` | Load a previously saved conversation |
|
|
82
|
+
| `/checkpoint [name]` | Save a conversation snapshot to memory |
|
|
83
|
+
| `/restore [name]` | Restore a saved conversation checkpoint |
|
|
84
|
+
| `/usage` | Show token usage, estimated session cost (USD), and statistics |
|
|
85
|
+
| `/commit` | Auto-generate a commit message for staged/unstaged changes and commit them |
|
|
86
|
+
| `/diff` | Show all uncommitted changes (staged, unstaged, untracked) |
|
|
87
|
+
| `/compact` | Summarize older messages using AI (fallback to text-summarization) to save tokens |
|
|
88
|
+
| `/undo` | Undo the last file modification |
|
|
89
|
+
| `/retry` | Retry the last message |
|
|
90
|
+
| `/copy` | Copy last AI response to clipboard |
|
|
91
|
+
| `/export [file]` | Export conversation to a Markdown file |
|
|
92
|
+
| `/config` | View current configuration |
|
|
93
|
+
| `/mcp` | View configured MCP servers and their connection status |
|
|
94
|
+
|
|
95
|
+
### Safety & UX
|
|
96
|
+
- **Command Safety** — Read-only commands (`ls`, `cat`, `git status`, etc.) auto-execute. Destructive commands (`rm`, `sudo`, etc.) always require confirmation.
|
|
97
|
+
- **`--yolo` Mode** — Auto-approve all operations for power users.
|
|
98
|
+
- **Background Tasks** — Run builds, tests, or other long-running tasks asynchronously while continuing to interact with Aizen.
|
|
99
|
+
- **File Backups** — Every file modification creates a backup. Use `/undo` to restore.
|
|
100
|
+
- **Multi-line Input** — End a line with `\` to continue on the next line.
|
|
101
|
+
- **Session Persistence** — Conversations auto-save on exit to SQLite. Use `/save` and `/load` to manage.
|
|
102
|
+
- **Cost Tracking & Token Usage** — Live tracking of input/output tokens, session duration, and estimated session cost in USD.
|
|
103
|
+
- **Structured Logging** — Rotated file logging at `~/.aizen_logs/aizen.log` plus verbose console debugging logs via `--verbose`.
|
|
104
|
+
- **Graceful Error Recovery** — Helpful hints for common API errors (invalid key, rate limits, timeouts).
|
|
105
|
+
|
|
106
|
+
## Dependencies
|
|
107
|
+
|
|
108
|
+
- `openai` — OpenAI-compatible API client
|
|
109
|
+
- `python-dotenv` — Environment variable management
|
|
110
|
+
- `rich` — Rich text, Markdown rendering, panels, tables, and live display
|
|
111
|
+
- `prompt_toolkit` — Interactive command line with autocomplete
|
|
112
|
+
|
|
113
|
+
## Installation
|
|
114
|
+
|
|
115
|
+
### 1. Python (pip / pipx) — Recommended
|
|
116
|
+
```bash
|
|
117
|
+
pipx install aizen-ai-cli
|
|
118
|
+
# Or:
|
|
119
|
+
pip install aizen-ai-cli
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 2. NPM (Node.js)
|
|
123
|
+
```bash
|
|
124
|
+
npm install -g aizen-ai-cli
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 3. Homebrew (macOS)
|
|
128
|
+
```bash
|
|
129
|
+
brew tap irtaza302/aizen
|
|
130
|
+
brew install aizen
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 4. Local Development
|
|
134
|
+
```bash
|
|
135
|
+
git clone https://github.com/irtaza302/aizen-agent.git
|
|
136
|
+
cd aizen-agent
|
|
137
|
+
pip install -r requirements.txt
|
|
138
|
+
python aizen.py
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Usage
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
aizen
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
On first launch, you'll be prompted for your [OpenRouter API key](https://openrouter.ai/keys). It's saved securely to `~/.aizen_config.json`.
|
|
148
|
+
|
|
149
|
+
### Command Line Arguments
|
|
150
|
+
|
|
151
|
+
| Flag | Description |
|
|
152
|
+
|------|-------------|
|
|
153
|
+
| `--version` | Show version |
|
|
154
|
+
| `--model <name>` | Override the default model for this session |
|
|
155
|
+
| `--reset-key` | Clear and re-enter your API key |
|
|
156
|
+
| `--set-base-url <url>` | Set custom API base URL (e.g., `http://localhost:11434/v1` for Ollama) |
|
|
157
|
+
| `--yolo` | Auto-approve all file writes and command executions |
|
|
158
|
+
| `--verbose` | Enable verbose logging output to the console |
|
|
159
|
+
|
|
160
|
+
### Attaching Context (`@`)
|
|
161
|
+
|
|
162
|
+
Type `@` followed by a filename, directory, web URL, or command to give Aizen context. Autocomplete filters out `.gitignore`d files:
|
|
163
|
+
|
|
164
|
+
- **Files:** `@aizen.py` attaches the file contents.
|
|
165
|
+
- **Directories:** `@tests/` generates and attaches a visual directory tree respecting `.gitignore`.
|
|
166
|
+
- **URLs:** `@https://docs.python.org/...` fetches the webpage, converts it to markdown, and attaches it.
|
|
167
|
+
- **Commands:** `@cmd:"pytest"` or `@cmd:ls` securely runs the command in the background and injects its `stdout` and `stderr` directly into the prompt.
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
👤 You
|
|
171
|
+
❯ Can you refactor @aizen.py to use async?
|
|
172
|
+
|
|
173
|
+
👤 You
|
|
174
|
+
❯ Explain this output: @cmd:"npm run build"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Multi-line Input
|
|
178
|
+
|
|
179
|
+
End a line with `\` to continue typing on the next line:
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
👤 You
|
|
183
|
+
❯ Write a function that \
|
|
184
|
+
⋮ takes a list of numbers \
|
|
185
|
+
⋮ and returns the sorted unique values
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Configuration
|
|
189
|
+
|
|
190
|
+
Aizen stores its config in `~/.aizen_config.json`:
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"OPENROUTER_API_KEY": "sk-or-...",
|
|
195
|
+
"API_BASE_URL": "https://openrouter.ai/api/v1",
|
|
196
|
+
"DEFAULT_MODEL": "anthropic/claude-sonnet-4"
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Model Context Protocol (MCP) Support
|
|
201
|
+
|
|
202
|
+
Aizen supports integrating with external [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers to extend its capabilities (e.g. connecting to local databases, searching the web, or accessing custom APIs).
|
|
203
|
+
|
|
204
|
+
To configure MCP servers, add an `"mcp_servers"` block to your `~/.aizen_config.json`:
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"mcp_servers": {
|
|
209
|
+
"sqlite": {
|
|
210
|
+
"command": "uvx",
|
|
211
|
+
"args": ["mcp-server-sqlite", "--db-path", "~/test.db"]
|
|
212
|
+
},
|
|
213
|
+
"everything": {
|
|
214
|
+
"command": "npx",
|
|
215
|
+
"args": ["-y", "@modelcontextprotocol/server-everything"]
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
When you start Aizen, it will automatically connect to these servers and make their tools available to the AI.
|
|
222
|
+
|
|
223
|
+
Sessions are saved in a SQLite database at `~/.aizen_sessions/aizen.db`, and file backups are placed in `~/.aizen_backups/`.
|
|
224
|
+
|
|
225
|
+
### 📂 Project-Specific Rules
|
|
226
|
+
|
|
227
|
+
Aizen supports loading custom, project-specific rules files (such as `.aizen_rules` or `.cursorrules`) from the root of your project directory.
|
|
228
|
+
When Aizen starts, it checks for these files in the current working directory in the following order:
|
|
229
|
+
1. `.aizen_rules`
|
|
230
|
+
2. `.cursorrules`
|
|
231
|
+
|
|
232
|
+
If one is found, Aizen automatically appends its contents to the system prompt. This allows you to enforce codebase-specific styling guidelines, coding standards, or project rules without editing Aizen's global configuration.
|
|
233
|
+
|
|
234
|
+
### 🔄 Background Task Management
|
|
235
|
+
|
|
236
|
+
For long-running processes (e.g., running test suites, starting local dev servers, or building bundles), you can run commands in the background asynchronously:
|
|
237
|
+
- Aizen's `run_command` tool supports a boolean `background` parameter. If set to `true`, the tool immediately returns a unique `task_id` (e.g., `bg_a1b2c3d4`).
|
|
238
|
+
- You can inspect the status and read the recent stdout/stderr output of a background task using the `check_background_task` tool.
|
|
239
|
+
- You can terminate any active background task using the `kill_background_task` tool.
|
|
240
|
+
|
|
241
|
+
This allows you to continue discussing other topics or refactoring files with Aizen while your tests or builds run in parallel.
|
|
242
|
+
|
|
243
|
+
### 💰 Cost Tracking
|
|
244
|
+
|
|
245
|
+
Aizen dynamically estimates session costs in USD for known models based on token usage:
|
|
246
|
+
- Input and output tokens are tracked in real-time.
|
|
247
|
+
- The estimated session cost is displayed in the CLI status bar and summary tables (via the `/usage` command).
|
|
248
|
+
- The cost calculations support popular models from Anthropic (Claude 3.5/3.7 Sonnet, Opus, Haiku), Google (Gemini 2.5 Pro/Flash), and OpenAI (GPT-4o, o1, o3-mini).
|
|
249
|
+
|
|
250
|
+
### 📌 Session Checkpoints & Restoring
|
|
251
|
+
|
|
252
|
+
You can save and restore conversation snapshots at any point during your session:
|
|
253
|
+
- `/checkpoint [name]`: Save the current conversation messages history as a named snapshot in memory.
|
|
254
|
+
- `/restore [name]`: Revert the conversation history to the specified checkpoint. If run without a name, it lists all currently active checkpoints.
|
|
255
|
+
|
|
256
|
+
This is extremely useful when experimenting with different implementation approaches or when recovering from an unintended direction.
|
|
257
|
+
|
|
258
|
+
### 📝 Structured Logging
|
|
259
|
+
|
|
260
|
+
All internal activities, tool calls, and API events are written to a rotating file logger:
|
|
261
|
+
- Logs are located at `~/.aizen_logs/aizen.log`.
|
|
262
|
+
- Up to three rotated log files are kept (5 MB per file limit).
|
|
263
|
+
- You can run Aizen with the `--verbose` flag to mirror log output directly to the console stderr stream.
|
|
264
|
+
|
|
265
|
+
## Publishing & Development
|
|
266
|
+
|
|
267
|
+
Use the included `publish.sh` script to build and publish across all platforms (PyPI, NPM, and PyInstaller binaries).
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# Aizen AI Agent 🚀
|
|
2
|
+
|
|
3
|
+
[](https://github.com/irtaza302/aizen-agent/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
A professional-grade AI coding assistant that runs directly in your terminal. Aizen reads your code, writes files with surgical precision, runs commands safely, and helps you build faster — all from a beautifully designed CLI.
|
|
6
|
+
|
|
7
|
+
## ✨ Features
|
|
8
|
+
|
|
9
|
+
### Core
|
|
10
|
+
- **Asynchronous Architecture** — Fully asynchronous operations leveraging `asyncio` and `AsyncOpenAI` for concurrent processing, parallel tool runs, and streaming.
|
|
11
|
+
- **Rich Markdown Rendering** — AI responses are rendered with full Markdown formatting (headers, code blocks, lists, bold/italic) via Rich's live display.
|
|
12
|
+
- **Streaming with Live Preview** — Watch responses render in real-time inside a styled panel with an animated thinking spinner.
|
|
13
|
+
- **Surgical File Editing** — The `edit_file` tool makes precise search-and-replace edits with color-coded diff previews, instead of rewriting entire files.
|
|
14
|
+
- **SQLite Session Persistence** — Session storage is powered by a SQLite database (`~/.aizen_sessions/aizen.db`), auto-migrating older JSON sessions.
|
|
15
|
+
- **Project-Specific Rules** — Customizes agent behavior per repository by auto-loading `.aizen_rules` or `.cursorrules` from the current working directory.
|
|
16
|
+
- **Smart Autocomplete** — `@`-mention files with Tab completion that respects `.gitignore` and supports directory traversal.
|
|
17
|
+
|
|
18
|
+
### Tools
|
|
19
|
+
Aizen has 9 built-in tools the AI can use:
|
|
20
|
+
|
|
21
|
+
| Tool | Description |
|
|
22
|
+
|------|-------------|
|
|
23
|
+
| `read_file` | Read file contents before making changes |
|
|
24
|
+
| `write_file` | Create new files (with preview) |
|
|
25
|
+
| `edit_file` | Surgical search-and-replace on existing files (with diff preview) |
|
|
26
|
+
| `run_command` | Execute shell commands (supports background execution; safe commands auto-run, dangerous ones require approval) |
|
|
27
|
+
| `check_background_task` | Check the status and read recent output of a command running in the background |
|
|
28
|
+
| `kill_background_task` | Kill a running background task |
|
|
29
|
+
| `list_directory` | List files/folders with sizes, respecting `.gitignore` |
|
|
30
|
+
| `grep_search` | Search for text or regex patterns across the codebase |
|
|
31
|
+
| `find_files` | Find files by glob pattern (e.g., `*.py`, `Dockerfile`) |
|
|
32
|
+
|
|
33
|
+
### Commands
|
|
34
|
+
|
|
35
|
+
| Command | Description |
|
|
36
|
+
|---------|-------------|
|
|
37
|
+
| `/help` | Show all available commands |
|
|
38
|
+
| `/model [name]` | View or switch the active AI model (saves as default) |
|
|
39
|
+
| `/clear` | Clear conversation history |
|
|
40
|
+
| `/drop` | Drop attached files/URLs/commands from history to save tokens |
|
|
41
|
+
| `/save [name]` | Save current conversation to SQLite database |
|
|
42
|
+
| `/load [name]` | Load a previously saved conversation |
|
|
43
|
+
| `/checkpoint [name]` | Save a conversation snapshot to memory |
|
|
44
|
+
| `/restore [name]` | Restore a saved conversation checkpoint |
|
|
45
|
+
| `/usage` | Show token usage, estimated session cost (USD), and statistics |
|
|
46
|
+
| `/commit` | Auto-generate a commit message for staged/unstaged changes and commit them |
|
|
47
|
+
| `/diff` | Show all uncommitted changes (staged, unstaged, untracked) |
|
|
48
|
+
| `/compact` | Summarize older messages using AI (fallback to text-summarization) to save tokens |
|
|
49
|
+
| `/undo` | Undo the last file modification |
|
|
50
|
+
| `/retry` | Retry the last message |
|
|
51
|
+
| `/copy` | Copy last AI response to clipboard |
|
|
52
|
+
| `/export [file]` | Export conversation to a Markdown file |
|
|
53
|
+
| `/config` | View current configuration |
|
|
54
|
+
| `/mcp` | View configured MCP servers and their connection status |
|
|
55
|
+
|
|
56
|
+
### Safety & UX
|
|
57
|
+
- **Command Safety** — Read-only commands (`ls`, `cat`, `git status`, etc.) auto-execute. Destructive commands (`rm`, `sudo`, etc.) always require confirmation.
|
|
58
|
+
- **`--yolo` Mode** — Auto-approve all operations for power users.
|
|
59
|
+
- **Background Tasks** — Run builds, tests, or other long-running tasks asynchronously while continuing to interact with Aizen.
|
|
60
|
+
- **File Backups** — Every file modification creates a backup. Use `/undo` to restore.
|
|
61
|
+
- **Multi-line Input** — End a line with `\` to continue on the next line.
|
|
62
|
+
- **Session Persistence** — Conversations auto-save on exit to SQLite. Use `/save` and `/load` to manage.
|
|
63
|
+
- **Cost Tracking & Token Usage** — Live tracking of input/output tokens, session duration, and estimated session cost in USD.
|
|
64
|
+
- **Structured Logging** — Rotated file logging at `~/.aizen_logs/aizen.log` plus verbose console debugging logs via `--verbose`.
|
|
65
|
+
- **Graceful Error Recovery** — Helpful hints for common API errors (invalid key, rate limits, timeouts).
|
|
66
|
+
|
|
67
|
+
## Dependencies
|
|
68
|
+
|
|
69
|
+
- `openai` — OpenAI-compatible API client
|
|
70
|
+
- `python-dotenv` — Environment variable management
|
|
71
|
+
- `rich` — Rich text, Markdown rendering, panels, tables, and live display
|
|
72
|
+
- `prompt_toolkit` — Interactive command line with autocomplete
|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
### 1. Python (pip / pipx) — Recommended
|
|
77
|
+
```bash
|
|
78
|
+
pipx install aizen-ai-cli
|
|
79
|
+
# Or:
|
|
80
|
+
pip install aizen-ai-cli
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. NPM (Node.js)
|
|
84
|
+
```bash
|
|
85
|
+
npm install -g aizen-ai-cli
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 3. Homebrew (macOS)
|
|
89
|
+
```bash
|
|
90
|
+
brew tap irtaza302/aizen
|
|
91
|
+
brew install aizen
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 4. Local Development
|
|
95
|
+
```bash
|
|
96
|
+
git clone https://github.com/irtaza302/aizen-agent.git
|
|
97
|
+
cd aizen-agent
|
|
98
|
+
pip install -r requirements.txt
|
|
99
|
+
python aizen.py
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Usage
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
aizen
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
On first launch, you'll be prompted for your [OpenRouter API key](https://openrouter.ai/keys). It's saved securely to `~/.aizen_config.json`.
|
|
109
|
+
|
|
110
|
+
### Command Line Arguments
|
|
111
|
+
|
|
112
|
+
| Flag | Description |
|
|
113
|
+
|------|-------------|
|
|
114
|
+
| `--version` | Show version |
|
|
115
|
+
| `--model <name>` | Override the default model for this session |
|
|
116
|
+
| `--reset-key` | Clear and re-enter your API key |
|
|
117
|
+
| `--set-base-url <url>` | Set custom API base URL (e.g., `http://localhost:11434/v1` for Ollama) |
|
|
118
|
+
| `--yolo` | Auto-approve all file writes and command executions |
|
|
119
|
+
| `--verbose` | Enable verbose logging output to the console |
|
|
120
|
+
|
|
121
|
+
### Attaching Context (`@`)
|
|
122
|
+
|
|
123
|
+
Type `@` followed by a filename, directory, web URL, or command to give Aizen context. Autocomplete filters out `.gitignore`d files:
|
|
124
|
+
|
|
125
|
+
- **Files:** `@aizen.py` attaches the file contents.
|
|
126
|
+
- **Directories:** `@tests/` generates and attaches a visual directory tree respecting `.gitignore`.
|
|
127
|
+
- **URLs:** `@https://docs.python.org/...` fetches the webpage, converts it to markdown, and attaches it.
|
|
128
|
+
- **Commands:** `@cmd:"pytest"` or `@cmd:ls` securely runs the command in the background and injects its `stdout` and `stderr` directly into the prompt.
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
👤 You
|
|
132
|
+
❯ Can you refactor @aizen.py to use async?
|
|
133
|
+
|
|
134
|
+
👤 You
|
|
135
|
+
❯ Explain this output: @cmd:"npm run build"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Multi-line Input
|
|
139
|
+
|
|
140
|
+
End a line with `\` to continue typing on the next line:
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
👤 You
|
|
144
|
+
❯ Write a function that \
|
|
145
|
+
⋮ takes a list of numbers \
|
|
146
|
+
⋮ and returns the sorted unique values
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Configuration
|
|
150
|
+
|
|
151
|
+
Aizen stores its config in `~/.aizen_config.json`:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"OPENROUTER_API_KEY": "sk-or-...",
|
|
156
|
+
"API_BASE_URL": "https://openrouter.ai/api/v1",
|
|
157
|
+
"DEFAULT_MODEL": "anthropic/claude-sonnet-4"
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Model Context Protocol (MCP) Support
|
|
162
|
+
|
|
163
|
+
Aizen supports integrating with external [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers to extend its capabilities (e.g. connecting to local databases, searching the web, or accessing custom APIs).
|
|
164
|
+
|
|
165
|
+
To configure MCP servers, add an `"mcp_servers"` block to your `~/.aizen_config.json`:
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"mcp_servers": {
|
|
170
|
+
"sqlite": {
|
|
171
|
+
"command": "uvx",
|
|
172
|
+
"args": ["mcp-server-sqlite", "--db-path", "~/test.db"]
|
|
173
|
+
},
|
|
174
|
+
"everything": {
|
|
175
|
+
"command": "npx",
|
|
176
|
+
"args": ["-y", "@modelcontextprotocol/server-everything"]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
When you start Aizen, it will automatically connect to these servers and make their tools available to the AI.
|
|
183
|
+
|
|
184
|
+
Sessions are saved in a SQLite database at `~/.aizen_sessions/aizen.db`, and file backups are placed in `~/.aizen_backups/`.
|
|
185
|
+
|
|
186
|
+
### 📂 Project-Specific Rules
|
|
187
|
+
|
|
188
|
+
Aizen supports loading custom, project-specific rules files (such as `.aizen_rules` or `.cursorrules`) from the root of your project directory.
|
|
189
|
+
When Aizen starts, it checks for these files in the current working directory in the following order:
|
|
190
|
+
1. `.aizen_rules`
|
|
191
|
+
2. `.cursorrules`
|
|
192
|
+
|
|
193
|
+
If one is found, Aizen automatically appends its contents to the system prompt. This allows you to enforce codebase-specific styling guidelines, coding standards, or project rules without editing Aizen's global configuration.
|
|
194
|
+
|
|
195
|
+
### 🔄 Background Task Management
|
|
196
|
+
|
|
197
|
+
For long-running processes (e.g., running test suites, starting local dev servers, or building bundles), you can run commands in the background asynchronously:
|
|
198
|
+
- Aizen's `run_command` tool supports a boolean `background` parameter. If set to `true`, the tool immediately returns a unique `task_id` (e.g., `bg_a1b2c3d4`).
|
|
199
|
+
- You can inspect the status and read the recent stdout/stderr output of a background task using the `check_background_task` tool.
|
|
200
|
+
- You can terminate any active background task using the `kill_background_task` tool.
|
|
201
|
+
|
|
202
|
+
This allows you to continue discussing other topics or refactoring files with Aizen while your tests or builds run in parallel.
|
|
203
|
+
|
|
204
|
+
### 💰 Cost Tracking
|
|
205
|
+
|
|
206
|
+
Aizen dynamically estimates session costs in USD for known models based on token usage:
|
|
207
|
+
- Input and output tokens are tracked in real-time.
|
|
208
|
+
- The estimated session cost is displayed in the CLI status bar and summary tables (via the `/usage` command).
|
|
209
|
+
- The cost calculations support popular models from Anthropic (Claude 3.5/3.7 Sonnet, Opus, Haiku), Google (Gemini 2.5 Pro/Flash), and OpenAI (GPT-4o, o1, o3-mini).
|
|
210
|
+
|
|
211
|
+
### 📌 Session Checkpoints & Restoring
|
|
212
|
+
|
|
213
|
+
You can save and restore conversation snapshots at any point during your session:
|
|
214
|
+
- `/checkpoint [name]`: Save the current conversation messages history as a named snapshot in memory.
|
|
215
|
+
- `/restore [name]`: Revert the conversation history to the specified checkpoint. If run without a name, it lists all currently active checkpoints.
|
|
216
|
+
|
|
217
|
+
This is extremely useful when experimenting with different implementation approaches or when recovering from an unintended direction.
|
|
218
|
+
|
|
219
|
+
### 📝 Structured Logging
|
|
220
|
+
|
|
221
|
+
All internal activities, tool calls, and API events are written to a rotating file logger:
|
|
222
|
+
- Logs are located at `~/.aizen_logs/aizen.log`.
|
|
223
|
+
- Up to three rotated log files are kept (5 MB per file limit).
|
|
224
|
+
- You can run Aizen with the `--verbose` flag to mirror log output directly to the console stderr stream.
|
|
225
|
+
|
|
226
|
+
## Publishing & Development
|
|
227
|
+
|
|
228
|
+
Use the included `publish.sh` script to build and publish across all platforms (PyPI, NPM, and PyInstaller binaries).
|