bashio 0.4.0
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/LICENSE +21 -0
- package/README.md +441 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2503 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Vranda Garg
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
# Bashio
|
|
2
|
+
|
|
3
|
+
> **Natural language to shell commands. Stop Googling, start doing.**
|
|
4
|
+
|
|
5
|
+
Bashio is an AI-powered CLI tool that translates your everyday language into precise shell commands. Just describe what you want to do, and let AI handle the syntax.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
$ b find all files larger than 100mb and delete them
|
|
9
|
+
```
|
|
10
|
+
```
|
|
11
|
+
> find . -size +100M -type f -delete
|
|
12
|
+
|
|
13
|
+
? Execute? (y/n/e/c/edit)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- **Natural Language Commands** - Describe tasks in plain English, get executable shell commands
|
|
21
|
+
- **Multiple AI Providers** - Choose from Claude, OpenAI, Ollama (local/free), or OpenRouter
|
|
22
|
+
- **Custom Shortcuts** - Create reusable command templates with dynamic placeholders
|
|
23
|
+
- **Safe Execution** - Review and confirm every command before it runs
|
|
24
|
+
- **Dangerous Command Detection** - Extra warnings for potentially destructive operations
|
|
25
|
+
- **Explain Mode** - Understand what any command does before executing
|
|
26
|
+
- **Command History** - Track all generated commands with usage statistics
|
|
27
|
+
- **Smart Suggestions** - Get shortcut recommendations based on your usage patterns
|
|
28
|
+
- **Privacy First** - All data stored locally in `~/.bashio/`, never sent to external servers
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
### Prerequisites
|
|
35
|
+
|
|
36
|
+
- Node.js 22.0.0 or higher
|
|
37
|
+
- pnpm (recommended) or npm
|
|
38
|
+
|
|
39
|
+
### Setup
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Clone the repository
|
|
43
|
+
git clone https://github.com/VrandaaGarg/bashio.git
|
|
44
|
+
cd bashio
|
|
45
|
+
|
|
46
|
+
# Install dependencies
|
|
47
|
+
pnpm install
|
|
48
|
+
|
|
49
|
+
# Build the project
|
|
50
|
+
pnpm build
|
|
51
|
+
|
|
52
|
+
# Link globally to use 'b' command anywhere
|
|
53
|
+
pnpm link --global
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Quick Start
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 1. Configure your AI provider
|
|
60
|
+
b --auth
|
|
61
|
+
|
|
62
|
+
# 2. Start using natural language commands
|
|
63
|
+
b find all png files in current directory
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
### Natural Language Commands
|
|
71
|
+
|
|
72
|
+
Simply prefix your request with `b` and describe what you want:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# File operations
|
|
76
|
+
b find all javascript files modified today
|
|
77
|
+
b delete all node_modules folders recursively
|
|
78
|
+
b count lines of code in all typescript files
|
|
79
|
+
b compress all images in this folder
|
|
80
|
+
|
|
81
|
+
# Git operations
|
|
82
|
+
b undo the last commit but keep changes
|
|
83
|
+
b show commits from last week by author john
|
|
84
|
+
b create a new branch called feature/auth
|
|
85
|
+
|
|
86
|
+
# System operations
|
|
87
|
+
b show disk usage sorted by size
|
|
88
|
+
b what is my public ip address
|
|
89
|
+
b kill whatever is running on port 3000
|
|
90
|
+
b list all running docker containers
|
|
91
|
+
|
|
92
|
+
# Network operations
|
|
93
|
+
b download this file and save as data.json
|
|
94
|
+
b check if google.com is reachable
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Confirmation Options
|
|
98
|
+
|
|
99
|
+
When a command is generated, you have several options:
|
|
100
|
+
|
|
101
|
+
| Input | Action |
|
|
102
|
+
|-------|--------|
|
|
103
|
+
| `y` or `Enter` | Execute the command |
|
|
104
|
+
| `n` | Cancel and exit |
|
|
105
|
+
| `e` | Explain what the command does (AI-powered) |
|
|
106
|
+
| `c` | Copy command to clipboard |
|
|
107
|
+
| `edit` | Edit the command before executing |
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Shortcuts
|
|
112
|
+
|
|
113
|
+
Create reusable command templates for frequently used operations.
|
|
114
|
+
|
|
115
|
+
### Creating Shortcuts
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Interactive mode
|
|
119
|
+
b --add-shortcut
|
|
120
|
+
|
|
121
|
+
# One-liner with placeholders
|
|
122
|
+
b --add-shortcut killport "lsof -ti:{{port}} | xargs kill -9" port
|
|
123
|
+
|
|
124
|
+
# Multi-argument shortcut
|
|
125
|
+
b --add-shortcut deploy "git push {{remote}} {{branch}}" remote branch
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Using Shortcuts
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Single argument - all remaining text becomes the argument
|
|
132
|
+
b killport 3000
|
|
133
|
+
|
|
134
|
+
# Output:
|
|
135
|
+
# [shortcut: killport]
|
|
136
|
+
# > lsof -ti:3000 | xargs kill -9
|
|
137
|
+
# ? Execute? (y/n/e/c/edit)
|
|
138
|
+
|
|
139
|
+
# Multi-word single argument (great for commit messages)
|
|
140
|
+
b commit "Add user authentication feature"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Managing Shortcuts
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
b --shortcuts # List all shortcuts
|
|
147
|
+
b --edit-shortcuts # Edit shortcuts in your default editor
|
|
148
|
+
b --remove-shortcut killport # Remove a specific shortcut
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Placeholder Syntax
|
|
152
|
+
|
|
153
|
+
Use `{{name}}` for dynamic arguments:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Template: "docker exec -it {{container}} {{cmd}}"
|
|
157
|
+
# Args: container, cmd
|
|
158
|
+
|
|
159
|
+
b dockerrun myapp bash
|
|
160
|
+
# Expands to: docker exec -it myapp bash
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## AI Providers
|
|
166
|
+
|
|
167
|
+
Bashio supports multiple AI providers. Configure with `b --auth`:
|
|
168
|
+
|
|
169
|
+
| Provider | Auth Method | Cost | Best For |
|
|
170
|
+
|----------|-------------|------|----------|
|
|
171
|
+
| **Claude** (Anthropic) | API Key | Paid | Best accuracy, complex commands |
|
|
172
|
+
| **OpenAI** (ChatGPT) | API Key | Paid | Great all-rounder |
|
|
173
|
+
| **Ollama** | Local | Free | Privacy, offline usage |
|
|
174
|
+
| **OpenRouter** | API Key | Pay-per-use | Access to multiple models |
|
|
175
|
+
|
|
176
|
+
### Available Models
|
|
177
|
+
|
|
178
|
+
#### Claude (Anthropic)
|
|
179
|
+
- `claude-sonnet-4-20250514` - Claude Sonnet 4 (recommended)
|
|
180
|
+
- `claude-3-5-sonnet-20241022` - Claude 3.5 Sonnet
|
|
181
|
+
- `claude-3-5-haiku-20241022` - Claude 3.5 Haiku (fast)
|
|
182
|
+
|
|
183
|
+
#### OpenAI
|
|
184
|
+
- `gpt-4o` - GPT-4o (recommended)
|
|
185
|
+
- `gpt-4o-mini` - GPT-4o Mini (fast)
|
|
186
|
+
- `gpt-4-turbo` - GPT-4 Turbo
|
|
187
|
+
|
|
188
|
+
#### OpenRouter
|
|
189
|
+
- `anthropic/claude-sonnet-4` - Claude Sonnet 4
|
|
190
|
+
- `anthropic/claude-3.5-sonnet` - Claude 3.5 Sonnet
|
|
191
|
+
- `openai/gpt-4o` - GPT-4o
|
|
192
|
+
- `google/gemini-pro-1.5` - Gemini Pro 1.5
|
|
193
|
+
- `meta-llama/llama-3.1-70b-instruct` - Llama 3.1 70B
|
|
194
|
+
|
|
195
|
+
#### Ollama (Local)
|
|
196
|
+
Any model installed on your machine:
|
|
197
|
+
- `llama3.2`, `llama3.1`, `codellama`, `mistral`, `gemma2`, etc.
|
|
198
|
+
|
|
199
|
+
### Switching Models
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
b --model # Interactive model selection
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## History & Statistics
|
|
208
|
+
|
|
209
|
+
Bashio tracks your command history for insights and suggestions.
|
|
210
|
+
|
|
211
|
+
### View History
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
b --history # Show recent command history
|
|
215
|
+
b --history --search git # Search history for specific terms
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Usage Statistics
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
b --stats
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
Bashio Usage Statistics
|
|
226
|
+
|
|
227
|
+
Overview
|
|
228
|
+
┌──────────────────────┬───────────────┐
|
|
229
|
+
│ Metric │ Value │
|
|
230
|
+
├──────────────────────┼───────────────┤
|
|
231
|
+
│ Commands Generated │ 156 │
|
|
232
|
+
│ Executed │ 142 (91%) │
|
|
233
|
+
│ Today │ 12 │
|
|
234
|
+
│ This Week │ 45 │
|
|
235
|
+
└──────────────────────┴───────────────┘
|
|
236
|
+
|
|
237
|
+
Most Used Commands
|
|
238
|
+
┌───┬─────────────────────────────────┬──────┬──────────┐
|
|
239
|
+
│ # │ Command │ Uses │ Source │
|
|
240
|
+
├───┼─────────────────────────────────┼──────┼──────────┤
|
|
241
|
+
│ 1 │ lsof -ti:3000 | xargs kill -9 │ 23 │ shortcut │
|
|
242
|
+
│ 2 │ git status │ 18 │ ai │
|
|
243
|
+
│ 3 │ docker ps -a │ 15 │ ai │
|
|
244
|
+
└───┴─────────────────────────────────┴──────┴──────────┘
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Smart Shortcut Suggestions
|
|
248
|
+
|
|
249
|
+
Based on your usage patterns, Bashio suggests commands to save as shortcuts:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
b --suggest-shortcuts
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Clear History
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
b --clear-history # Clear all history
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Configuration
|
|
264
|
+
|
|
265
|
+
All configuration is stored locally at `~/.bashio/`:
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
~/.bashio/
|
|
269
|
+
├── config.json # Provider settings and preferences
|
|
270
|
+
├── shortcuts.json # Custom shortcuts
|
|
271
|
+
└── history.db # Command history (SQLite)
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Settings
|
|
275
|
+
|
|
276
|
+
The `config.json` file contains customizable settings:
|
|
277
|
+
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"version": 1,
|
|
281
|
+
"provider": "claude",
|
|
282
|
+
"model": "claude-sonnet-4-20250514",
|
|
283
|
+
"credentials": {
|
|
284
|
+
"type": "api_key",
|
|
285
|
+
"apiKey": "sk-ant-..."
|
|
286
|
+
},
|
|
287
|
+
"settings": {
|
|
288
|
+
"confirmBeforeExecute": true,
|
|
289
|
+
"historyEnabled": true,
|
|
290
|
+
"historyRetentionDays": 30,
|
|
291
|
+
"historyMaxEntries": 2000,
|
|
292
|
+
"autoConfirmShortcuts": false
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
#### Available Settings
|
|
298
|
+
|
|
299
|
+
| Setting | Type | Default | Description |
|
|
300
|
+
|---------|------|---------|-------------|
|
|
301
|
+
| `confirmBeforeExecute` | boolean | `true` | Require confirmation before running commands |
|
|
302
|
+
| `historyEnabled` | boolean | `true` | Track command history |
|
|
303
|
+
| `historyRetentionDays` | number | `30` | Days to keep history before auto-cleanup |
|
|
304
|
+
| `historyMaxEntries` | number | `2000` | Maximum history entries to retain |
|
|
305
|
+
| `autoConfirmShortcuts` | boolean | `false` | Skip confirmation for shortcut commands |
|
|
306
|
+
|
|
307
|
+
### View Current Configuration
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
b --config
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## CLI Reference
|
|
316
|
+
|
|
317
|
+
### Core Commands
|
|
318
|
+
|
|
319
|
+
| Command | Description |
|
|
320
|
+
|---------|-------------|
|
|
321
|
+
| `b <query>` | Convert natural language to shell command |
|
|
322
|
+
| `b <shortcut> [args]` | Execute a saved shortcut |
|
|
323
|
+
|
|
324
|
+
### Configuration
|
|
325
|
+
|
|
326
|
+
| Command | Description |
|
|
327
|
+
|---------|-------------|
|
|
328
|
+
| `b --auth` | Configure AI provider and credentials |
|
|
329
|
+
| `b --config` | View current configuration |
|
|
330
|
+
| `b --model` | Change the AI model |
|
|
331
|
+
|
|
332
|
+
### Shortcuts Management
|
|
333
|
+
|
|
334
|
+
| Command | Description |
|
|
335
|
+
|---------|-------------|
|
|
336
|
+
| `b --shortcuts` | List all saved shortcuts |
|
|
337
|
+
| `b --add-shortcut` | Create a new shortcut (interactive) |
|
|
338
|
+
| `b --add-shortcut <name> <template> [args...]` | Create shortcut (one-liner) |
|
|
339
|
+
| `b --edit-shortcuts` | Edit shortcuts in default editor |
|
|
340
|
+
| `b --remove-shortcut <name>` | Delete a shortcut |
|
|
341
|
+
|
|
342
|
+
### History & Analytics
|
|
343
|
+
|
|
344
|
+
| Command | Description |
|
|
345
|
+
|---------|-------------|
|
|
346
|
+
| `b --history` | View command history |
|
|
347
|
+
| `b --stats` | View usage statistics |
|
|
348
|
+
| `b --clear-history` | Clear command history |
|
|
349
|
+
| `b --suggest-shortcuts` | Get shortcut suggestions based on usage |
|
|
350
|
+
|
|
351
|
+
### Help
|
|
352
|
+
|
|
353
|
+
| Command | Description |
|
|
354
|
+
|---------|-------------|
|
|
355
|
+
| `b --help` | Show help information |
|
|
356
|
+
| `b --version` | Show version number |
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Safety Features
|
|
361
|
+
|
|
362
|
+
### Dangerous Command Detection
|
|
363
|
+
|
|
364
|
+
Bashio automatically detects potentially dangerous operations and requires explicit confirmation:
|
|
365
|
+
|
|
366
|
+
- Recursive deletions (`rm -rf`)
|
|
367
|
+
- System-wide operations (`sudo`, root access)
|
|
368
|
+
- Force operations (`--force`, `-f` flags)
|
|
369
|
+
- Disk operations (formatting, partitioning)
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
$ b delete everything in the home directory
|
|
373
|
+
|
|
374
|
+
> rm -rf ~/*
|
|
375
|
+
|
|
376
|
+
WARNING: This command may cause irreversible changes.
|
|
377
|
+
|
|
378
|
+
Reasons:
|
|
379
|
+
- Uses recursive force delete (rm -rf)
|
|
380
|
+
- Targets home directory
|
|
381
|
+
|
|
382
|
+
? Proceed with this command? (y/N)
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Confirmation by Default
|
|
386
|
+
|
|
387
|
+
Every command requires confirmation before execution. You always see exactly what will run.
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Development
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
# Install dependencies
|
|
395
|
+
pnpm install
|
|
396
|
+
|
|
397
|
+
# Development mode (watch for changes)
|
|
398
|
+
pnpm dev
|
|
399
|
+
|
|
400
|
+
# Build for production
|
|
401
|
+
pnpm build
|
|
402
|
+
|
|
403
|
+
# Run linter
|
|
404
|
+
pnpm lint:check
|
|
405
|
+
|
|
406
|
+
# Fix lint issues
|
|
407
|
+
pnpm lint
|
|
408
|
+
|
|
409
|
+
# Type check
|
|
410
|
+
pnpm typecheck
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Tech Stack
|
|
414
|
+
|
|
415
|
+
- **Runtime**: Node.js 22+, TypeScript 5.9
|
|
416
|
+
- **CLI Framework**: Clipanion
|
|
417
|
+
- **Database**: better-sqlite3 (SQLite)
|
|
418
|
+
- **Validation**: Zod
|
|
419
|
+
- **UI**: picocolors, ora, @inquirer/prompts
|
|
420
|
+
- **Build**: tsup, Biome
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
## Privacy & Security
|
|
425
|
+
|
|
426
|
+
- **Local Storage**: All data (config, history, shortcuts) stays on your machine
|
|
427
|
+
- **No Telemetry**: No usage data is collected or sent anywhere
|
|
428
|
+
- **Secure Credentials**: API keys stored with restricted file permissions (0600)
|
|
429
|
+
- **Your Queries**: Only sent to your chosen AI provider for command generation
|
|
430
|
+
|
|
431
|
+
---
|
|
432
|
+
|
|
433
|
+
## License
|
|
434
|
+
|
|
435
|
+
MIT
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
<p align="center">
|
|
440
|
+
<sub>Built with frustration from Googling the same commands over and over.</sub>
|
|
441
|
+
</p>
|
package/dist/index.d.ts
ADDED