ai-cli 0.0.11 → 0.0.12

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.
Files changed (3) hide show
  1. package/README.md +95 -44
  2. package/dist/ai.mjs +263 -213
  3. package/package.json +3 -1
package/README.md CHANGED
@@ -1,22 +1,22 @@
1
1
  # ai-cli
2
2
 
3
- minimal terminal AI assistant
3
+ Minimal terminal AI assistant.
4
4
 
5
- ## install
5
+ ## Install
6
6
 
7
7
  ```bash
8
8
  npm install -g ai-cli
9
9
  ```
10
10
 
11
- ## setup
11
+ ## Setup
12
12
 
13
13
  ```bash
14
14
  ai init
15
15
  ```
16
16
 
17
- get your API key from [Vercel AI Gateway](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys&title=Go+to+AI+Gateway)
17
+ Get your API key from [Vercel AI Gateway](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys&title=Go+to+AI+Gateway)
18
18
 
19
- ## usage
19
+ ## Usage
20
20
 
21
21
  ```bash
22
22
  ai # interactive mode
@@ -25,45 +25,96 @@ ai -m gpt-5 "hello" # use specific model
25
25
  ai --image ./img.png "what?" # analyze image (single message)
26
26
  ai -l # list models
27
27
  echo "explain this" | ai # pipe input
28
+ ai --system "respond in Spanish" "hola" # custom system prompt
28
29
 
29
30
  # in interactive mode, ctrl+v to paste image from clipboard
30
31
  ```
31
32
 
32
- ## options
33
+ ## Headless Mode
34
+
35
+ Run the full agent non-interactively. Useful for CI pipelines, scripts, and automation.
36
+
37
+ ```bash
38
+ ai -p "explain this codebase" # output to stdout
39
+ ai -p --json "write tests for src/auth.ts" > result.json # structured JSON
40
+ ai -p --force "fix all type errors" # skip confirmations
41
+ ai -p --no-save "what dependencies are outdated?" # ephemeral (no history)
42
+ git diff | ai -p "review this for bugs" # pipe + headless
43
+ ai -p -m gpt-5 --force "refactor the database layer" # combine flags
44
+ ai -p --plan "how should I refactor auth?" # plan mode (read-only)
45
+ ai -p -r <chatId> "continue" # resume a session
46
+ ai -p --timeout 60 "fix type errors" # abort after 60s
47
+ ai -p -q "explain this codebase" # suppress stderr status
48
+ ```
49
+
50
+ Exit codes: `0` success, `1` error, `2` agent stuck.
51
+
52
+ **Note:** When `--timeout` fires during a tool execution (e.g., mid-file-write), the agent is interrupted immediately. The workspace may contain partial changes. Combine with version control or review the working tree after a timeout.
53
+
54
+ JSON output format:
55
+
56
+ ```json
57
+ {
58
+ "output": "...",
59
+ "model": "anthropic/claude-sonnet-4.5",
60
+ "tokens": 1234,
61
+ "cost": 0.05,
62
+ "exitCode": 0,
63
+ "chatId": "abc123",
64
+ "usage": {
65
+ "inputTokens": 800,
66
+ "outputTokens": 434,
67
+ "cacheReadTokens": 0,
68
+ "cacheWriteTokens": 0,
69
+ "reasoningTokens": 0
70
+ }
71
+ }
72
+ ```
73
+
74
+ On error, includes an `error` field with the message.
75
+
76
+ ## Options
33
77
 
34
78
  - `-m, --model` - model (default: anthropic/claude-sonnet-4.5)
35
79
  - `--image` - attach image file
36
80
  - `-r, --resume` - resume a previous chat by ID
37
81
  - `--plan` - start in plan mode (think before acting)
82
+ - `-p, --print` - headless mode: full agent, output to stdout, then exit
83
+ - `--json` - structured JSON output (implies --print)
84
+ - `--system` - append custom text to the system prompt
85
+ - `--force` - auto-approve all tool actions (--print only)
86
+ - `--no-save` - don't persist the chat to history (--print only)
87
+ - `--timeout` - abort after N seconds (--print only)
88
+ - `-q, --quiet` - suppress stderr status output (--print only)
38
89
  - `-l, --list` - list models
39
90
  - `--no-color` - disable color output
40
91
  - `-v, --version` - show version
41
92
  - `-h, --help` - help
42
93
 
43
- ## commands
94
+ ## Commands
44
95
 
45
- ### chat
96
+ ### Chat
46
97
  - `/new` - new chat
47
98
  - `/chats` - list chats
48
99
  - `/chat <n>` - load chat
49
100
  - `/delete` - delete chat
50
101
  - `/clear` - clear screen
51
102
 
52
- ### files
103
+ ### Files
53
104
  - `/copy` - copy response
54
105
  - `/rollback` - undo changes
55
106
 
56
- ### context
107
+ ### Context
57
108
  - `/usage` - token usage and cost
58
109
  - `/compress` - compress history
59
110
  - `/plan` - toggle plan mode (think before acting)
60
111
  - `/review` - review loop (auto-reviews changes for bugs)
61
112
 
62
- ### model
113
+ ### Model
63
114
  - `/model` - select model interactively
64
115
  - `/model <query>` - switch to matching model
65
116
 
66
- ### system
117
+ ### System
67
118
  - `/info` - version, model, balance, storage
68
119
  - `/processes` - background processes
69
120
  - `/memory` - saved memories
@@ -74,11 +125,11 @@ echo "explain this" | ai # pipe input
74
125
  - `/purge` - delete all chats
75
126
  - `/help` - commands
76
127
 
77
- ## skills
128
+ ## Skills
78
129
 
79
- skills extend the AI with specialized capabilities. they follow the [Agent Skills](https://agentskills.io) open standard.
130
+ Skills extend the AI with specialized capabilities. They follow the [Agent Skills](https://agentskills.io) open standard.
80
131
 
81
- ### managing skills
132
+ ### Managing Skills
82
133
 
83
134
  ```bash
84
135
  /skills # list installed
@@ -89,9 +140,9 @@ skills extend the AI with specialized capabilities. they follow the [Agent Skill
89
140
  /skills path # show directory
90
141
  ```
91
142
 
92
- ### installing skills
143
+ ### Installing Skills
93
144
 
94
- shorthand (like skills.sh):
145
+ Shorthand (like skills.sh):
95
146
 
96
147
  ```bash
97
148
  /skills add vercel-labs/agent-skills/skills/react-best-practices
@@ -99,34 +150,34 @@ shorthand (like skills.sh):
99
150
  /skills add owner/repo
100
151
  ```
101
152
 
102
- full github url:
153
+ Full GitHub URL:
103
154
 
104
155
  ```bash
105
156
  /skills add https://github.com/anthropics/skills/tree/main/skills/pdf
106
157
  ```
107
158
 
108
- local path:
159
+ Local path:
109
160
 
110
161
  ```bash
111
162
  /skills add /path/to/skill
112
163
  ```
113
164
 
114
- ### creating skills
165
+ ### Creating Skills
115
166
 
116
167
  ```bash
117
168
  /skills create my-skill
118
169
  ```
119
170
 
120
- creates `~/.ai-cli/skills/my-skill/SKILL.md`
171
+ Creates `~/.ai-cli/skills/my-skill/SKILL.md`
121
172
 
122
- ## rules
173
+ ## Rules
123
174
 
124
- custom instructions loaded into every conversation:
175
+ Custom instructions loaded into every conversation:
125
176
 
126
177
  - `~/.ai-cli/AGENTS.md` - global rules
127
178
  - `./AGENTS.md` - project rules
128
179
 
129
- manage with `/rules`:
180
+ Manage with `/rules`:
130
181
 
131
182
  ```bash
132
183
  /rules show # view rules
@@ -135,13 +186,13 @@ manage with `/rules`:
135
186
  /rules path # show path
136
187
  ```
137
188
 
138
- ## review loop
189
+ ## Review Loop
139
190
 
140
- after the coding agent finishes making file changes, a separate review agent automatically inspects all modifications for severe and high-priority bugs. if it finds issues, it fixes them and re-reviews, up to a configurable number of passes.
191
+ After the coding agent finishes making file changes, a separate review agent automatically inspects all modifications for severe and high-priority bugs. If it finds issues, it fixes them and re-reviews, up to a configurable number of passes.
141
192
 
142
- the review agent runs in its own isolated context with a strict system prompt -- it has no attachment to the code it's reviewing and is intentionally more critical than the coding agent.
193
+ The review agent runs in its own isolated context with a strict system prompt -- it has no attachment to the code it's reviewing and is intentionally more critical than the coding agent.
143
194
 
144
- enabled by default. toggle with:
195
+ Enabled by default. Toggle with:
145
196
 
146
197
  ```bash
147
198
  /review on # enable
@@ -149,7 +200,7 @@ enabled by default. toggle with:
149
200
  /review # show status
150
201
  ```
151
202
 
152
- configure max iterations in `~/.ai-cli/config.json`:
203
+ Configure max iterations in `~/.ai-cli/config.json`:
153
204
 
154
205
  ```json
155
206
  {
@@ -160,9 +211,9 @@ configure max iterations in `~/.ai-cli/config.json`:
160
211
  }
161
212
  ```
162
213
 
163
- ## tools
214
+ ## Tools
164
215
 
165
- the AI can:
216
+ The AI can:
166
217
 
167
218
  **files** - read, write, edit, delete, copy, rename, search
168
219
 
@@ -172,9 +223,9 @@ the AI can:
172
223
 
173
224
  **web** - search, fetch urls, check weather
174
225
 
175
- ## mcp
226
+ ## MCP
176
227
 
177
- connect to external tools via [model context protocol](https://modelcontextprotocol.io):
228
+ Connect to external tools via [Model Context Protocol](https://modelcontextprotocol.io):
178
229
 
179
230
  ```bash
180
231
  /mcp # list servers
@@ -184,15 +235,15 @@ connect to external tools via [model context protocol](https://modelcontextproto
184
235
  /mcp reload # reconnect all
185
236
  ```
186
237
 
187
- ### transports
238
+ ### Transports
188
239
 
189
240
  - **http** - HTTP endpoint
190
241
  - **sse** - server-sent events
191
242
  - **stdio** - spawn local process
192
243
 
193
- ### config
244
+ ### Config
194
245
 
195
- servers stored in `~/.ai-cli/mcp.json`:
246
+ Servers stored in `~/.ai-cli/mcp.json`:
196
247
 
197
248
  ```json
198
249
  {
@@ -210,13 +261,13 @@ servers stored in `~/.ai-cli/mcp.json`:
210
261
  }
211
262
  ```
212
263
 
213
- environment variables expand with `${VAR}` or `${VAR:-default}`.
264
+ Environment variables expand with `${VAR}` or `${VAR:-default}`.
214
265
 
215
- mcp tools are prefixed with server name (e.g., `weather_get_forecast`).
266
+ MCP tools are prefixed with server name (e.g., `weather_get_forecast`).
216
267
 
217
- ## models
268
+ ## Models
218
269
 
219
- supports fuzzy matching:
270
+ Supports fuzzy matching:
220
271
 
221
272
  ```bash
222
273
  ai -m claude-4 # → anthropic/claude-sonnet-4
@@ -224,9 +275,9 @@ ai -m gpt-5 # → openai/gpt-5
224
275
  ai -m sonnet # → finds sonnet model
225
276
  ```
226
277
 
227
- ## storage
278
+ ## Storage
228
279
 
229
- all data in `~/.ai-cli/`:
280
+ All data in `~/.ai-cli/`:
230
281
 
231
282
  ```
232
283
  ~/.ai-cli/
@@ -238,9 +289,9 @@ all data in `~/.ai-cli/`:
238
289
  └── AGENTS.md # global rules
239
290
  ```
240
291
 
241
- ## environment
292
+ ## Environment
242
293
 
243
- alternatively set your API key:
294
+ Alternatively set your API key:
244
295
 
245
296
  ```bash
246
297
  export AI_GATEWAY_API_KEY=your-key