cmdvault 1.0.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/README.md ADDED
@@ -0,0 +1,433 @@
1
+ # CmdVault
2
+
3
+ A smart terminal assistant that remembers, stores, and executes shell commands using user-defined keys.
4
+
5
+ ## Features
6
+
7
+ - 🚀 Execute commands directly through CmdVault
8
+ - 💾 Store frequently used commands with memorable keys
9
+ - 🔄 Retrieve and execute stored commands instantly
10
+ - 🤖 **AI-powered command generation** from natural language
11
+ - 📝 Edit stored commands with your preferred editor
12
+ - 📋 List all saved commands in a beautiful table
13
+ - 🎨 Colored output for better readability
14
+ - 🔒 Confirmation prompts for destructive operations
15
+ - 🌍 Cross-platform support (Windows, Mac, Linux)
16
+ - ⚡ Live command output streaming
17
+ - 🔌 Multiple AI provider support (OpenAI, Anthropic, Google Gemini, Groq, OpenRouter)
18
+
19
+ ## Installation
20
+
21
+ ### Install Globally
22
+
23
+ ```bash
24
+ npm install -g
25
+ ```
26
+
27
+ Or from npm (once published):
28
+
29
+ ```bash
30
+ npm install -g cmdvault
31
+ ```
32
+
33
+ ### Local Development
34
+
35
+ ```bash
36
+ # Clone the repository
37
+ cd smart-term
38
+
39
+ # Install dependencies
40
+ npm install
41
+
42
+ # Link globally for testing
43
+ npm link
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ### 1. Execute a Command Directly
49
+
50
+ Run any shell command through CmdVault:
51
+
52
+ ```bash
53
+ cm git status
54
+ cm npm test
55
+ cm ls -la
56
+ ```
57
+
58
+ ### 2. Save a Command
59
+
60
+ Store a command with a memorable key:
61
+
62
+ ```bash
63
+ cm s <key> <command>
64
+ ```
65
+
66
+ **Examples:**
67
+
68
+ ```bash
69
+ cm s gs git status
70
+ cm s gp git pull origin main
71
+ cm s dev npm run dev
72
+ cm s build npm run build && npm run test
73
+ ```
74
+
75
+ The command will execute immediately and be saved for future use.
76
+
77
+ ### 3. Retrieve and Execute a Stored Command
78
+
79
+ Simply use the key to execute the stored command:
80
+
81
+ ```bash
82
+ cm gs
83
+ # Executes: git status
84
+
85
+ cm gp
86
+ # Executes: git pull origin main
87
+ ```
88
+
89
+ ### 4. Expand Command Without Executing
90
+
91
+ Get the stored command printed to terminal without executing it:
92
+
93
+ ```bash
94
+ cm c gs
95
+ # Outputs: git status
96
+ # Does NOT execute - you can copy/paste or edit it
97
+ ```
98
+
99
+ This is useful when you want to:
100
+ - See what a command does before running it
101
+ - Edit the command before execution
102
+ - Copy the command for use elsewhere
103
+
104
+ **Pro Tip:** You can use command substitution to insert it into your terminal:
105
+
106
+ ```bash
107
+ # Copy output and paste manually
108
+ cm c gs
109
+
110
+ # Or use in a script
111
+ COMMAND=$(cm c gs)
112
+ echo "About to run: $COMMAND"
113
+ eval $COMMAND
114
+ ```
115
+
116
+ ### 5. AI Command Generation 🤖
117
+
118
+ Generate shell commands from natural language using AI:
119
+
120
+ ```bash
121
+ cm -g "list all pdf files in current directory"
122
+ # AI generates: find . -maxdepth 1 -name "*.pdf"
123
+ # Execute this command? (y/n):
124
+ ```
125
+
126
+ **First time setup:**
127
+ ```bash
128
+ cm config
129
+ # Select AI provider (OpenAI, Anthropic, Gemini, Groq, OpenRouter)
130
+ # Enter your API key
131
+ # Start generating commands!
132
+ ```
133
+
134
+ **More examples:**
135
+ ```bash
136
+ cm -g "show git commits from last week"
137
+ cm -g "find process using port 3000"
138
+ cm -g "compress all log files"
139
+ ```
140
+
141
+ ### 6. List All Saved Commands
142
+
143
+ View all your stored commands in a formatted table:
144
+
145
+ ```bash
146
+ cm list
147
+ ```
148
+
149
+ Output:
150
+ ```
151
+ ┌───────────────┬─────────────────────────────────────────────────────────────────┐
152
+ │ Key │ Command │
153
+ ├───────────────┼─────────────────────────────────────────────────────────────────┤
154
+ │ dev │ npm run dev │
155
+ ├───────────────┼─────────────────────────────────────────────────────────────────┤
156
+ │ gp │ git pull origin main │
157
+ ├───────────────┼─────────────────────────────────────────────────────────────────┤
158
+ │ gs │ git status │
159
+ └───────────────┴─────────────────────────────────────────────────────────────────┘
160
+
161
+ Total: 3 command(s)
162
+ ```
163
+
164
+ ### 5. Edit a Stored Command
165
+
166
+ Modify a stored command using your system editor:
167
+
168
+ ```bash
169
+ cm e <key>
170
+ ```
171
+
172
+ **Example:**
173
+
174
+ ```bash
175
+ cm e gp
176
+ ```
177
+
178
+ This opens your default editor (nano, vim, or notepad) to edit the command.
179
+
180
+ **Set your preferred editor:**
181
+
182
+ ```bash
183
+ export EDITOR=vim # Linux/Mac
184
+ set EDITOR=code # Windows
185
+ ```
186
+
187
+ ### 8. Delete a Stored Command
188
+
189
+ Remove a stored command:
190
+
191
+ ```bash
192
+ cm d <key>
193
+ ```
194
+
195
+ **Example:**
196
+
197
+ ```bash
198
+ cm d gs
199
+ # Prompts for confirmation before deleting
200
+ ```
201
+
202
+ ## Command Reference
203
+
204
+ | Command | Description | Example |
205
+ |---------|-------------|---------|
206
+ | `cm <command>` | Execute a command directly | `cm git status` |
207
+ | `cm s <key> <command>` | Save/store a command | `cm s gs git status` |
208
+ | `cm <key>` | Execute a stored command | `cm gs` |
209
+ | `cm c <key>` | Copy/expand command (no execution) | `cm c gs` |
210
+ | `cm -g "<prompt>"` | Generate command using AI | `cm -g "list files"` |
211
+ | `cm config` | Configure AI providers | `cm config` |
212
+ | `cm list` | List all stored commands | `cm list` |
213
+ | `cm e <key>` | Edit a stored command | `cm e gs` |
214
+ | `cm d <key>` | Delete a stored command | `cm d gs` |
215
+ | `cm --help` | Show help information | `cm --help` |
216
+ | `cm --version` | Show version | `cm --version` |
217
+
218
+ ## Storage Location
219
+
220
+ Commands are stored in a JSON file at:
221
+
222
+ - **Linux/Mac:** `~/.cmvault/commands.json`
223
+ - **Windows:** `C:\Users\<username>\.cmvault\commands.json`
224
+
225
+ Example `commands.json`:
226
+ ```json
227
+ {
228
+ "gs": "git status",
229
+ "gp": "git pull origin main",
230
+ "dev": "npm run dev"
231
+ }
232
+ ```
233
+
234
+ ## Examples
235
+
236
+ ### Git Workflow
237
+
238
+ ```bash
239
+ # Store common git commands
240
+ cm s gs git status
241
+ cm s ga git add .
242
+ cm s gc git commit -m
243
+ cm s gp git push origin main
244
+ cm s gl git log --oneline -10
245
+
246
+ # Use them
247
+ cm gs
248
+ cm ga
249
+ cm gc "feat: add new feature"
250
+ cm gp
251
+ ```
252
+
253
+ ### Development Workflow
254
+
255
+ ```bash
256
+ # Store project commands
257
+ cm s dev npm run dev
258
+ cm s build npm run build
259
+ cm s test npm test
260
+ cm s lint npm run lint
261
+ cm s deploy npm run build && npm run deploy
262
+
263
+ # Quick execution
264
+ cm dev
265
+ cm test
266
+ cm build
267
+ ```
268
+
269
+ ### System Administration
270
+
271
+ ```bash
272
+ # Store system commands
273
+ cm s ports lsof -i -P -n | grep LISTEN
274
+ cm s mem free -h
275
+ cm s disk df -h
276
+ cm s procs ps aux | grep node
277
+
278
+ # Execute instantly
279
+ cm ports
280
+ cm mem
281
+ ```
282
+
283
+ ## Features in Detail
284
+
285
+ ### Overwrite Protection
286
+
287
+ When storing a command with an existing key, CmdVault asks for confirmation:
288
+
289
+ ```bash
290
+ cm s gs git status
291
+ # Key "gs" already exists. Overwrite? (y/n):
292
+ ```
293
+
294
+ ### ✅ Failed Command Handling
295
+
296
+ If a command fails during recording, CmdVault asks if you still want to save it:
297
+
298
+ ```bash
299
+ cm s test npm test
300
+ # Command failed: Command exited with code 1
301
+ # Save command anyway? (y/n):
302
+ ```
303
+
304
+ ### ✅ Live Output Streaming
305
+
306
+ Commands stream their output in real-time, not buffered:
307
+
308
+ ```bash
309
+ cm dev
310
+ # Output appears immediately as the command runs
311
+ ```
312
+
313
+ ### ✅ Execution Confirmation
314
+
315
+ After executing a stored command, CmdVault shows what was executed:
316
+
317
+ ```bash
318
+ cm gp
319
+ [CM] Executing stored command: git pull origin main
320
+ # ... command output ...
321
+ [CM] Executed: git pull origin main
322
+ ```
323
+
324
+ ## Publishing to npm
325
+
326
+ ### Prepare for Publishing
327
+
328
+ 1. Update `package.json` with your details:
329
+
330
+ ```json
331
+ {
332
+ "name": "cmdvault",
333
+ "author": "Your Name <your.email@example.com>",
334
+ "repository": {
335
+ "type": "git",
336
+ "url": "https://github.com/yourusername/cmdvault"
337
+ }
338
+ }
339
+ ```
340
+
341
+ 2. Create an npm account:
342
+
343
+ ```bash
344
+ npm adduser
345
+ ```
346
+
347
+ 3. Publish:
348
+
349
+ ```bash
350
+ npm publish
351
+ ```
352
+
353
+ ### Install from npm
354
+
355
+ Once published, users can install globally:
356
+
357
+ ```bash
358
+ npm install -g cmdvault
359
+ ```
360
+
361
+ ## Project Structure
362
+
363
+ ```
364
+ smart-term/
365
+ ├── bin/
366
+ │ └── cm.js # Executable entry point
367
+ ├── lib/
368
+ │ ├── storage.js # Command storage management
369
+ │ ├── executor.js # Command execution with streaming
370
+ │ └── editor.js # Editor integration
371
+ ├── index.js # Main CLI logic
372
+ ├── package.json # Package configuration
373
+ └── README.md # Documentation
374
+ ```
375
+
376
+ ## Requirements
377
+
378
+ - Node.js >= 14.0.0
379
+ - npm or yarn
380
+
381
+ ## Dependencies
382
+
383
+ - **commander** - CLI framework
384
+ - **chalk** - Terminal colors
385
+ - **cli-table3** - Beautiful tables
386
+
387
+ ## Troubleshooting
388
+
389
+ ### Command not found: cm
390
+
391
+ After installation, if `cm` is not recognized:
392
+
393
+ ```bash
394
+ # Re-link the package
395
+ npm link
396
+
397
+ # Or check your PATH includes npm global bin
398
+ npm config get prefix
399
+ ```
400
+
401
+ ### Permission denied
402
+
403
+ On Linux/Mac, you may need to make the bin file executable:
404
+
405
+ ```bash
406
+ chmod +x bin/cm.js
407
+ ```
408
+
409
+ ### Editor not opening
410
+
411
+ Set your preferred editor:
412
+
413
+ ```bash
414
+ # Linux/Mac
415
+ export EDITOR=nano
416
+ # or
417
+ export EDITOR=vim
418
+
419
+ # Windows
420
+ set EDITOR=notepad
421
+ ```
422
+
423
+ ## License
424
+
425
+ MIT
426
+
427
+ ## Contributing
428
+
429
+ Contributions are welcome! Please feel free to submit a Pull Request.
430
+
431
+ ## Support
432
+
433
+ For issues and questions, please open an issue on GitHub.
package/bin/cm.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../index.js');