ai-cli 0.0.11 → 0.0.13

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 +96 -44
  2. package/dist/ai.mjs +265 -212
  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,97 @@ 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
+ - `--fast` - enable Anthropic fast mode (speed=fast)
86
+ - `--force` - auto-approve all tool actions (--print only)
87
+ - `--no-save` - don't persist the chat to history (--print only)
88
+ - `--timeout` - abort after N seconds (--print only)
89
+ - `-q, --quiet` - suppress stderr status output (--print only)
38
90
  - `-l, --list` - list models
39
91
  - `--no-color` - disable color output
40
92
  - `-v, --version` - show version
41
93
  - `-h, --help` - help
42
94
 
43
- ## commands
95
+ ## Commands
44
96
 
45
- ### chat
97
+ ### Chat
46
98
  - `/new` - new chat
47
99
  - `/chats` - list chats
48
100
  - `/chat <n>` - load chat
49
101
  - `/delete` - delete chat
50
102
  - `/clear` - clear screen
51
103
 
52
- ### files
104
+ ### Files
53
105
  - `/copy` - copy response
54
106
  - `/rollback` - undo changes
55
107
 
56
- ### context
108
+ ### Context
57
109
  - `/usage` - token usage and cost
58
110
  - `/compress` - compress history
59
111
  - `/plan` - toggle plan mode (think before acting)
60
112
  - `/review` - review loop (auto-reviews changes for bugs)
61
113
 
62
- ### model
114
+ ### Model
63
115
  - `/model` - select model interactively
64
116
  - `/model <query>` - switch to matching model
65
117
 
66
- ### system
118
+ ### System
67
119
  - `/info` - version, model, balance, storage
68
120
  - `/processes` - background processes
69
121
  - `/memory` - saved memories
@@ -74,11 +126,11 @@ echo "explain this" | ai # pipe input
74
126
  - `/purge` - delete all chats
75
127
  - `/help` - commands
76
128
 
77
- ## skills
129
+ ## Skills
78
130
 
79
- skills extend the AI with specialized capabilities. they follow the [Agent Skills](https://agentskills.io) open standard.
131
+ Skills extend the AI with specialized capabilities. They follow the [Agent Skills](https://agentskills.io) open standard.
80
132
 
81
- ### managing skills
133
+ ### Managing Skills
82
134
 
83
135
  ```bash
84
136
  /skills # list installed
@@ -89,9 +141,9 @@ skills extend the AI with specialized capabilities. they follow the [Agent Skill
89
141
  /skills path # show directory
90
142
  ```
91
143
 
92
- ### installing skills
144
+ ### Installing Skills
93
145
 
94
- shorthand (like skills.sh):
146
+ Shorthand (like skills.sh):
95
147
 
96
148
  ```bash
97
149
  /skills add vercel-labs/agent-skills/skills/react-best-practices
@@ -99,34 +151,34 @@ shorthand (like skills.sh):
99
151
  /skills add owner/repo
100
152
  ```
101
153
 
102
- full github url:
154
+ Full GitHub URL:
103
155
 
104
156
  ```bash
105
157
  /skills add https://github.com/anthropics/skills/tree/main/skills/pdf
106
158
  ```
107
159
 
108
- local path:
160
+ Local path:
109
161
 
110
162
  ```bash
111
163
  /skills add /path/to/skill
112
164
  ```
113
165
 
114
- ### creating skills
166
+ ### Creating Skills
115
167
 
116
168
  ```bash
117
169
  /skills create my-skill
118
170
  ```
119
171
 
120
- creates `~/.ai-cli/skills/my-skill/SKILL.md`
172
+ Creates `~/.ai-cli/skills/my-skill/SKILL.md`
121
173
 
122
- ## rules
174
+ ## Rules
123
175
 
124
- custom instructions loaded into every conversation:
176
+ Custom instructions loaded into every conversation:
125
177
 
126
178
  - `~/.ai-cli/AGENTS.md` - global rules
127
179
  - `./AGENTS.md` - project rules
128
180
 
129
- manage with `/rules`:
181
+ Manage with `/rules`:
130
182
 
131
183
  ```bash
132
184
  /rules show # view rules
@@ -135,13 +187,13 @@ manage with `/rules`:
135
187
  /rules path # show path
136
188
  ```
137
189
 
138
- ## review loop
190
+ ## Review Loop
139
191
 
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.
192
+ 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
193
 
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.
194
+ 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
195
 
144
- enabled by default. toggle with:
196
+ Enabled by default. Toggle with:
145
197
 
146
198
  ```bash
147
199
  /review on # enable
@@ -149,7 +201,7 @@ enabled by default. toggle with:
149
201
  /review # show status
150
202
  ```
151
203
 
152
- configure max iterations in `~/.ai-cli/config.json`:
204
+ Configure max iterations in `~/.ai-cli/config.json`:
153
205
 
154
206
  ```json
155
207
  {
@@ -160,9 +212,9 @@ configure max iterations in `~/.ai-cli/config.json`:
160
212
  }
161
213
  ```
162
214
 
163
- ## tools
215
+ ## Tools
164
216
 
165
- the AI can:
217
+ The AI can:
166
218
 
167
219
  **files** - read, write, edit, delete, copy, rename, search
168
220
 
@@ -172,9 +224,9 @@ the AI can:
172
224
 
173
225
  **web** - search, fetch urls, check weather
174
226
 
175
- ## mcp
227
+ ## MCP
176
228
 
177
- connect to external tools via [model context protocol](https://modelcontextprotocol.io):
229
+ Connect to external tools via [Model Context Protocol](https://modelcontextprotocol.io):
178
230
 
179
231
  ```bash
180
232
  /mcp # list servers
@@ -184,15 +236,15 @@ connect to external tools via [model context protocol](https://modelcontextproto
184
236
  /mcp reload # reconnect all
185
237
  ```
186
238
 
187
- ### transports
239
+ ### Transports
188
240
 
189
241
  - **http** - HTTP endpoint
190
242
  - **sse** - server-sent events
191
243
  - **stdio** - spawn local process
192
244
 
193
- ### config
245
+ ### Config
194
246
 
195
- servers stored in `~/.ai-cli/mcp.json`:
247
+ Servers stored in `~/.ai-cli/mcp.json`:
196
248
 
197
249
  ```json
198
250
  {
@@ -210,13 +262,13 @@ servers stored in `~/.ai-cli/mcp.json`:
210
262
  }
211
263
  ```
212
264
 
213
- environment variables expand with `${VAR}` or `${VAR:-default}`.
265
+ Environment variables expand with `${VAR}` or `${VAR:-default}`.
214
266
 
215
- mcp tools are prefixed with server name (e.g., `weather_get_forecast`).
267
+ MCP tools are prefixed with server name (e.g., `weather_get_forecast`).
216
268
 
217
- ## models
269
+ ## Models
218
270
 
219
- supports fuzzy matching:
271
+ Supports fuzzy matching:
220
272
 
221
273
  ```bash
222
274
  ai -m claude-4 # → anthropic/claude-sonnet-4
@@ -224,9 +276,9 @@ ai -m gpt-5 # → openai/gpt-5
224
276
  ai -m sonnet # → finds sonnet model
225
277
  ```
226
278
 
227
- ## storage
279
+ ## Storage
228
280
 
229
- all data in `~/.ai-cli/`:
281
+ All data in `~/.ai-cli/`:
230
282
 
231
283
  ```
232
284
  ~/.ai-cli/
@@ -238,9 +290,9 @@ all data in `~/.ai-cli/`:
238
290
  └── AGENTS.md # global rules
239
291
  ```
240
292
 
241
- ## environment
293
+ ## Environment
242
294
 
243
- alternatively set your API key:
295
+ Alternatively set your API key:
244
296
 
245
297
  ```bash
246
298
  export AI_GATEWAY_API_KEY=your-key