@pentoshi/clai 0.2.0 → 0.2.2
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.
- package/README.md +77 -66
- package/dist/commands/update.js +1 -1
- package/dist/prompts/index.js +16 -11
- package/dist/prompts/index.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -2,62 +2,79 @@
|
|
|
2
2
|
|
|
3
3
|
> A fast, cross-platform AI CLI assistant with `/ask` and `/agent` modes for general shell tasks, file operations, and cybersecurity / pentesting workflows. Free to build, free to run.
|
|
4
4
|
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **`/ask` mode** — Read-only. AI explains, gives commands & step-by-step guidance, but does NOT execute anything.
|
|
8
|
-
- **`/agent` mode** — Agentic. AI plans, then executes shell commands, edits files, installs missing tools, parses output, and continues until the goal is met.
|
|
9
|
-
- **6 LLM providers** — Groq, Google Gemini, OpenRouter, OpenAI, Anthropic, and Ollama (local). All with streaming support.
|
|
10
|
-
- **10 built-in tools** — `shell.exec`, `fs.read`, `fs.write`, `fs.list`, `fs.search`, `pkg.install`, `net.scan`, `http.fetch`, `sysinfo`, `pentest.recon`.
|
|
11
|
-
- **Safety gate** — 3-tier classifier (`safe` / `confirm` / `block`) with destructive pattern detection, public IP scan blocking, and exfiltration guards.
|
|
12
|
-
- **Cross-platform** — macOS, Linux, and Windows. Detects OS-native package managers (brew, apt, dnf, pacman, winget, choco).
|
|
13
|
-
- **Pentest-aware** — nmap, nikto, sqlmap, gobuster, ffuf, hydra, masscan, whois, dig, netcat, tshark integration with authorization gates.
|
|
14
|
-
- **Persistent history** — SQLite with JSONL fallback. Automatic key redaction in logs.
|
|
15
|
-
|
|
16
5
|
## Installation
|
|
17
6
|
|
|
18
|
-
|
|
19
|
-
# npm (any platform — requires Node.js ≥ 20)
|
|
20
|
-
npm i -g @pentoshi/clai
|
|
7
|
+
### macOS
|
|
21
8
|
|
|
22
|
-
|
|
9
|
+
```sh
|
|
10
|
+
# Homebrew (recommended)
|
|
23
11
|
brew tap pentoshi007/clai
|
|
24
12
|
brew install clai
|
|
25
13
|
|
|
26
|
-
#
|
|
14
|
+
# or via curl
|
|
15
|
+
curl -fsSL https://raw.githubusercontent.com/pentoshi007/clai/main/install/install.sh | sh
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Linux
|
|
19
|
+
|
|
20
|
+
```sh
|
|
27
21
|
curl -fsSL https://raw.githubusercontent.com/pentoshi007/clai/main/install/install.sh | sh
|
|
28
22
|
```
|
|
29
23
|
|
|
24
|
+
### Windows
|
|
25
|
+
|
|
30
26
|
```powershell
|
|
31
|
-
#
|
|
27
|
+
# PowerShell (recommended)
|
|
32
28
|
irm https://raw.githubusercontent.com/pentoshi007/clai/main/install/install.ps1 | iex
|
|
33
29
|
|
|
34
|
-
#
|
|
30
|
+
# or Scoop
|
|
35
31
|
scoop bucket add clai https://github.com/pentoshi007/clai
|
|
36
32
|
scoop install clai
|
|
37
33
|
```
|
|
38
34
|
|
|
35
|
+
### Any OS (via npm)
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm i -g @pentoshi/clai
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### From Source
|
|
42
|
+
|
|
39
43
|
```sh
|
|
40
|
-
# From source
|
|
41
44
|
git clone https://github.com/pentoshi007/clai.git
|
|
42
45
|
cd clai && npm install && npm run dev
|
|
43
46
|
```
|
|
44
47
|
|
|
48
|
+
After installing, type `clai` in any terminal to start.
|
|
49
|
+
|
|
45
50
|
## Quick Start
|
|
46
51
|
|
|
47
52
|
```sh
|
|
48
53
|
# Open interactive REPL
|
|
49
54
|
clai
|
|
50
55
|
|
|
51
|
-
# One-shot ask mode
|
|
56
|
+
# One-shot ask mode (explains but doesn't execute)
|
|
52
57
|
clai --mode ask "create a python venv and install requests"
|
|
53
58
|
|
|
54
|
-
# One-shot agent mode
|
|
59
|
+
# One-shot agent mode (executes)
|
|
55
60
|
clai --mode agent "find all PDFs larger than 10MB in ~/Documents"
|
|
56
61
|
|
|
57
|
-
#
|
|
62
|
+
# Auto-confirm tool execution
|
|
58
63
|
clai -y "list the 10 largest files in my home directory"
|
|
59
64
|
```
|
|
60
65
|
|
|
66
|
+
## Features
|
|
67
|
+
|
|
68
|
+
- **`/ask` mode** — Read-only. AI explains, gives commands & step-by-step guidance, but does NOT execute anything.
|
|
69
|
+
- **`/agent` mode** — Agentic. AI plans, then executes shell commands, edits files, installs missing tools, parses output, and continues until the goal is met.
|
|
70
|
+
- **6 LLM providers** — Groq, Google Gemini, OpenRouter, OpenAI, Anthropic, and Ollama (local). All with streaming.
|
|
71
|
+
- **10 built-in tools** — `shell.exec`, `fs.read`, `fs.write`, `fs.list`, `fs.search`, `pkg.install`, `net.scan`, `http.fetch`, `sysinfo`, `pentest.recon`.
|
|
72
|
+
- **Smart safety gate** — Read-only commands auto-execute; mutating commands require confirmation; destructive patterns are blocked.
|
|
73
|
+
- **Cross-platform** — macOS, Linux, and Windows. Detects OS-native package managers (brew, apt, dnf, pacman, winget, choco).
|
|
74
|
+
- **Pentest-aware** — nmap, nikto, sqlmap, gobuster, ffuf, hydra, masscan, whois, dig, netcat, tshark.
|
|
75
|
+
- **Auto-update** — Checks for new versions on startup; run `/update` or `clai update` to upgrade.
|
|
76
|
+
- **Persistent history** — Session history with automatic key redaction in logs.
|
|
77
|
+
|
|
61
78
|
## Provider Setup
|
|
62
79
|
|
|
63
80
|
clai supports 6 LLM providers with free tiers:
|
|
@@ -78,7 +95,7 @@ clai set groq gsk_xxxxxxxxxxxxxxxx
|
|
|
78
95
|
# Import from environment variable
|
|
79
96
|
clai set gemini --from-env GEMINI_API_KEY
|
|
80
97
|
|
|
81
|
-
# Read from stdin (safer
|
|
98
|
+
# Read from stdin (safer — avoids shell history)
|
|
82
99
|
echo "gsk_xxx" | clai set groq --stdin
|
|
83
100
|
|
|
84
101
|
# Set Ollama endpoint
|
|
@@ -113,7 +130,7 @@ export OLLAMA_HOST=http://localhost:11434
|
|
|
113
130
|
## REPL Commands
|
|
114
131
|
|
|
115
132
|
| Command | Action |
|
|
116
|
-
|
|
133
|
+
|-------------------------|-------------------------------------------------- |
|
|
117
134
|
| `/ask` | Switch to ask mode |
|
|
118
135
|
| `/agent` | Switch to agent mode |
|
|
119
136
|
| `/model <name>` | Switch LLM model |
|
|
@@ -127,6 +144,7 @@ export OLLAMA_HOST=http://localhost:11434
|
|
|
127
144
|
| `/save <name>` | Save current session |
|
|
128
145
|
| `/cwd <path>` | Change working directory |
|
|
129
146
|
| `/allow <tool>` | Whitelist a tool for the session |
|
|
147
|
+
| `/update` | Check for updates |
|
|
130
148
|
| `/exit` | Quit |
|
|
131
149
|
| `/help` | List commands |
|
|
132
150
|
|
|
@@ -145,13 +163,15 @@ export OLLAMA_HOST=http://localhost:11434
|
|
|
145
163
|
| `sysinfo` | OS, architecture, shell, and working directory info | safe |
|
|
146
164
|
| `pentest.recon` | Composite: whois + dig + nmap top-100 ports | confirm |
|
|
147
165
|
|
|
166
|
+
> \* **smart** = read-only commands (`curl`, `ls`, `whoami`, `gobuster`, `dirb`, etc.) auto-execute; mutating commands require confirmation.
|
|
167
|
+
|
|
148
168
|
## Safety Gate
|
|
149
169
|
|
|
150
170
|
Every tool call passes through a 3-tier classifier:
|
|
151
171
|
|
|
152
|
-
- **`safe`** — Auto-run
|
|
153
|
-
- **`confirm`** — User prompt
|
|
154
|
-
- **`block`** — Refuse with explanation
|
|
172
|
+
- **`safe`** — Auto-run: read-only fs, sysinfo, http.fetch, read-only shell commands (`curl`, `ls`, `whoami`, `ifconfig`, `gobuster`, `dirb`, `ffuf`, `nikto`, etc.)
|
|
173
|
+
- **`confirm`** — User prompt: mutating shell commands, fs.write, pkg.install, net.scan
|
|
174
|
+
- **`block`** — Refuse with explanation: `rm -rf /`, fork bombs, public IP scans without authorization, exfiltration patterns
|
|
155
175
|
|
|
156
176
|
### Pentest Authorization
|
|
157
177
|
|
|
@@ -163,18 +183,25 @@ clai authorize-pentest AGREE
|
|
|
163
183
|
|
|
164
184
|
Public IP scanning is blocked unless the target is private (RFC 1918) or the user explicitly confirms ownership.
|
|
165
185
|
|
|
186
|
+
## Updates
|
|
187
|
+
|
|
188
|
+
clai checks for updates automatically on startup (every 4 hours, non-blocking). You can also check manually:
|
|
189
|
+
|
|
190
|
+
```sh
|
|
191
|
+
# CLI command
|
|
192
|
+
clai update
|
|
193
|
+
|
|
194
|
+
# Inside the REPL
|
|
195
|
+
/update
|
|
196
|
+
```
|
|
197
|
+
|
|
166
198
|
## Diagnostics
|
|
167
199
|
|
|
168
200
|
```sh
|
|
169
|
-
# Check system info, provider configuration, and available tools
|
|
170
201
|
clai doctor
|
|
171
202
|
```
|
|
172
203
|
|
|
173
|
-
Outputs:
|
|
174
|
-
- OS, shell, architecture
|
|
175
|
-
- Config and history file paths
|
|
176
|
-
- Provider key status
|
|
177
|
-
- Available pentest tools with install commands for missing ones
|
|
204
|
+
Outputs: OS, shell, architecture, config paths, provider key status, available pentest tools with install commands for missing ones.
|
|
178
205
|
|
|
179
206
|
## Per-Project Context
|
|
180
207
|
|
|
@@ -183,7 +210,6 @@ Create a `.clai/context.md` file in your project root to automatically inject pr
|
|
|
183
210
|
```md
|
|
184
211
|
This is a Node.js project using Express and PostgreSQL.
|
|
185
212
|
The API server runs on port 3000.
|
|
186
|
-
Database migrations are in the `migrations/` directory.
|
|
187
213
|
```
|
|
188
214
|
|
|
189
215
|
## Configuration
|
|
@@ -191,36 +217,20 @@ Database migrations are in the `migrations/` directory.
|
|
|
191
217
|
Configuration is stored at `~/.config/clai/config.json` (varies by OS):
|
|
192
218
|
|
|
193
219
|
```sh
|
|
194
|
-
# Print config path and
|
|
195
|
-
clai
|
|
196
|
-
|
|
197
|
-
# Set default mode
|
|
198
|
-
clai mode agent
|
|
199
|
-
|
|
200
|
-
# Set model for current provider
|
|
201
|
-
clai model llama-3.3-70b-versatile
|
|
220
|
+
clai config # Print config path and settings
|
|
221
|
+
clai mode agent # Set default mode
|
|
222
|
+
clai model llama-3.3-70b-versatile # Set model
|
|
202
223
|
```
|
|
203
224
|
|
|
204
225
|
## Development
|
|
205
226
|
|
|
206
227
|
```sh
|
|
207
|
-
# Install dependencies
|
|
208
|
-
npm
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
npm
|
|
212
|
-
|
|
213
|
-
# Type check
|
|
214
|
-
npm run typecheck
|
|
215
|
-
|
|
216
|
-
# Build TypeScript
|
|
217
|
-
npm run build
|
|
218
|
-
|
|
219
|
-
# Run tests
|
|
220
|
-
npm test
|
|
221
|
-
|
|
222
|
-
# Build native binaries (requires Bun)
|
|
223
|
-
npm run compile
|
|
228
|
+
npm install # Install dependencies
|
|
229
|
+
npm run dev # Run in development mode
|
|
230
|
+
npm run typecheck # Type check
|
|
231
|
+
npm run build # Build TypeScript
|
|
232
|
+
npm test # Run tests (39 tests)
|
|
233
|
+
npm run compile # Build native binaries (requires Bun)
|
|
224
234
|
```
|
|
225
235
|
|
|
226
236
|
## Architecture
|
|
@@ -258,25 +268,26 @@ clai/
|
|
|
258
268
|
│ │ └─ pkgmgr.ts # Package manager detection
|
|
259
269
|
│ ├─ store/
|
|
260
270
|
│ │ ├─ config.ts # Persistent config via `conf`
|
|
261
|
-
│ │ ├─ history.ts #
|
|
271
|
+
│ │ ├─ history.ts # Session history
|
|
262
272
|
│ │ ├─ keys.ts # Keychain + fallback key storage
|
|
263
273
|
│ │ ├─ logs.ts # Audit log with rotation
|
|
264
274
|
│ │ └─ project.ts # Per-project context loader
|
|
265
275
|
│ ├─ commands/
|
|
266
276
|
│ │ ├─ doctor.ts # System diagnostics
|
|
277
|
+
│ │ ├─ update.ts # Auto-update checker
|
|
267
278
|
│ │ └─ providers.ts # Provider management commands
|
|
268
279
|
│ └─ prompts/
|
|
269
|
-
│
|
|
270
|
-
|
|
271
|
-
│ └─ system.agent.md # Agent mode system prompt
|
|
272
|
-
├─ bin/clai # Shebang launcher
|
|
280
|
+
│ └─ index.ts # Prompt template renderer
|
|
281
|
+
├─ bin/clai.mjs # ESM shebang launcher
|
|
273
282
|
├─ scripts/build.ts # Bun compile per target
|
|
274
283
|
├─ .github/workflows/
|
|
275
|
-
│ └─ release.yml # CI: build + publish binaries
|
|
284
|
+
│ └─ release.yml # CI: build + publish binaries on tag
|
|
276
285
|
├─ manifests/
|
|
277
286
|
│ ├─ homebrew/clai.rb # Homebrew formula
|
|
278
287
|
│ └─ scoop/clai.json # Scoop manifest
|
|
279
|
-
├─ install/
|
|
288
|
+
├─ install/
|
|
289
|
+
│ ├─ install.sh # macOS/Linux curl installer
|
|
290
|
+
│ └─ install.ps1 # Windows PowerShell installer
|
|
280
291
|
├─ package.json
|
|
281
292
|
├─ tsconfig.json
|
|
282
293
|
└─ README.md
|
package/dist/commands/update.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { getConfig, updateConfig } from "../store/config.js";
|
|
3
3
|
const REPO = "pentoshi007/clai";
|
|
4
|
-
const CURRENT_VERSION = "0.2.
|
|
4
|
+
const CURRENT_VERSION = "0.2.2";
|
|
5
5
|
const CHECK_INTERVAL_MS = 4 * 60 * 60 * 1000; // 4 hours
|
|
6
6
|
function parseVersion(v) {
|
|
7
7
|
return v.replace(/^v/, "").split(".").map(Number);
|
package/dist/prompts/index.js
CHANGED
|
@@ -21,21 +21,26 @@ FORMAT — one tool per response:
|
|
|
21
21
|
\`\`\`
|
|
22
22
|
|
|
23
23
|
RULES:
|
|
24
|
-
1.
|
|
25
|
-
2.
|
|
26
|
-
3.
|
|
27
|
-
4.
|
|
28
|
-
5.
|
|
29
|
-
6.
|
|
30
|
-
7.
|
|
31
|
-
8.
|
|
24
|
+
1. ANSWER THEN STOP. Once you have the answer to the user's question, give it and STOP. Do NOT run extra tools.
|
|
25
|
+
2. STAY ON TASK. Do EXACTLY what the user asked — nothing more, nothing less.
|
|
26
|
+
3. One tool per response. 1-2 lines of thinking MAX before the tool block.
|
|
27
|
+
4. To find files/dirs by name: shell.exec find /path -maxdepth 3 -name '*pattern*'
|
|
28
|
+
5. CONTINUE only if the original task is NOT yet done. Resolve sub-problems then proceed.
|
|
29
|
+
6. Use conversation history for follow-ups. "it", "that", "such" = context from previous messages.
|
|
30
|
+
7. Suppress noise: curl -s, wget -q. Always use full absolute paths.
|
|
31
|
+
8. Never run cd, pwd, or re-list directories you already listed.
|
|
32
|
+
9. Only pentest systems the user owns or has permission to test.
|
|
32
33
|
|
|
33
|
-
EXAMPLE — user asks "
|
|
34
|
+
SIMPLE EXAMPLE — user asks "whoami":
|
|
35
|
+
Step 1: shell.exec whoami → "aniket". Answer: "You are aniket." DONE. Do NOT run sysinfo, fs.list, or anything else.
|
|
36
|
+
|
|
37
|
+
COMPLEX EXAMPLE — user asks "directory scan on example.com, seclists in /opt":
|
|
34
38
|
Step 1: Find the wordlist → shell.exec find /opt -maxdepth 3 -type d -name 'Discovery'
|
|
35
39
|
Step 2: List wordlists → fs.list /opt/wordlist/SecLists/Discovery/Web-Content
|
|
36
|
-
Step 3: Run scan → shell.exec gobuster dir -u https://example.com -w
|
|
40
|
+
Step 3: Run scan → shell.exec gobuster dir -u https://example.com -w .../common.txt -q
|
|
37
41
|
Step 4: Report findings. DONE.
|
|
38
|
-
|
|
42
|
+
|
|
43
|
+
Do NOT: run sysinfo after answering, list home directories, scan localhost, fetch random ports, search file contents, install tools, or do ANYTHING the user did not ask for.`;
|
|
39
44
|
function render(template, values) {
|
|
40
45
|
return Object.entries(values).reduce((current, [key, value]) => current.replaceAll(`{{${key}}}`, value), template);
|
|
41
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,SAAS,GAAG,0OAA0O,CAAC;AAE7P,MAAM,WAAW,GAAG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources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i/clai",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A fast, cross-platform AI CLI assistant with ask and agent modes for shell tasks, file operations, and cybersecurity workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"doctor": "tsx src/index.ts doctor"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@inquirer/prompts": "^
|
|
45
|
+
"@inquirer/prompts": "^8.4.2",
|
|
46
46
|
"chalk": "^5.4.1",
|
|
47
|
-
"commander": "^
|
|
47
|
+
"commander": "^14.0.3",
|
|
48
48
|
"conf": "^13.1.0",
|
|
49
49
|
"execa": "^9.5.2",
|
|
50
50
|
"ora": "^8.1.1",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"keytar": "^7.9.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@types/node": "^
|
|
59
|
-
"tsx": "^4.
|
|
60
|
-
"typescript": "^
|
|
61
|
-
"vitest": "^
|
|
58
|
+
"@types/node": "^25.6.0",
|
|
59
|
+
"tsx": "^4.21.0",
|
|
60
|
+
"typescript": "^6.0.3",
|
|
61
|
+
"vitest": "^4.1.5"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=20"
|