@fmdzc/cli-ai 3.0.3 → 3.1.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 CHANGED
@@ -1,15 +1,15 @@
1
- ISC License
2
-
3
- Copyright (c) 2024 fmdz387
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
1
+ ISC License
2
+
3
+ Copyright (c) 2024 fmdz387
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,169 +1,183 @@
1
- # CLI AI
2
-
3
- [![npm version](https://img.shields.io/npm/v/@fmdzc/cli-ai)](https://www.npmjs.com/package/@fmdzc/cli-ai)
4
- [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
5
- [![Node.js](https://img.shields.io/badge/Node.js-20+-green.svg)](https://nodejs.org/)
6
-
7
- **Natural language to shell commands. Powered by Claude AI.**
8
-
9
- Describe what you want in plain English. Get the right command. Review, execute, or copy.
10
-
11
- ![CLI AI Demo](assets/cli-ai.png)
12
-
13
- ## Features
14
-
15
- - **Natural language** - Just describe what you want to do
16
- - **Cross-platform** - Windows (PowerShell, CMD, Git Bash), macOS, Linux
17
- - **Shell-aware** - Commands tailored to your detected shell
18
- - **Interactive** - Execute, copy, edit, or request alternatives
19
- - **Context-aware** - Remembers your conversation history for smarter suggestions
20
- - **Secure** - API keys stored in system keyring, never in plain text
21
- - **Risk assessment** - Color-coded safety levels for every command
22
-
23
- ## Quick Start
24
-
25
- ```bash
26
- # Install globally
27
- npm install -g @fmdzc/cli-ai
28
-
29
- # Run
30
- s
31
- ```
32
-
33
- On first run, you'll be prompted for your [Anthropic API key](https://console.anthropic.com/settings/keys).
34
-
35
- ## Usage
36
-
37
- Type what you want in natural language:
38
-
39
- ```
40
- > find files larger than 100MB
41
-
42
- $ find . -size +100M -type f
43
- Risk: low
44
-
45
- [1] Execute [2] Copy [3] Edit [4] Alternatives [5] Cancel
46
- ```
47
-
48
- ### Slash Commands
49
-
50
- Type `/` to access commands:
51
-
52
- | Command | Description |
53
- |---------|-------------|
54
- | `/config` | Open settings panel |
55
- | `/help` | Show help and shortcuts |
56
- | `/clear` | Clear command history |
57
- | `/exit` | Exit application |
58
-
59
- ### Keyboard Shortcuts
60
-
61
- **Input Mode**
62
- | Key | Action |
63
- |-----|--------|
64
- | `/` | Open command palette |
65
- | `Enter` | Submit query |
66
- | `O` | Toggle output expansion |
67
- | `Ctrl+D` | Exit (when empty) |
68
-
69
- **Command Proposal**
70
- | Key | Action |
71
- |-----|--------|
72
- | `1` / `Enter` | Execute command |
73
- | `2` | Copy to clipboard |
74
- | `3` | Edit command |
75
- | `4` | Show alternatives |
76
- | `5` / `Esc` | Cancel |
77
- | `?` | Explain command |
78
-
79
- **Settings Panel**
80
- | Key | Action |
81
- |-----|--------|
82
- | `Tab` | Next section |
83
- | `Up/Down` | Navigate items |
84
- | `Enter` | Toggle/Select |
85
- | `Esc` | Close |
86
-
87
- ## Settings
88
-
89
- Access settings with `/config`:
90
-
91
- ### API Key
92
- - View masked key and storage method
93
- - Change or remove API key
94
-
95
- ### Model Selection
96
- | Model | Description |
97
- |-------|-------------|
98
- | Claude Sonnet 4.5 | Fast and capable (default) |
99
- | Claude Opus 4.5 | Most capable |
100
- | Claude Haiku 4.5 | Fastest |
101
-
102
- ### Options
103
- | Setting | Description |
104
- |---------|-------------|
105
- | Context | Pass conversation history to AI for smarter suggestions |
106
- | Show explanations | Display command explanations |
107
- | Syntax highlighting | Colorize command output |
108
- | Simple mode | Minimal UI mode |
109
-
110
- ## Risk Assessment
111
-
112
- | Level | Color | Meaning |
113
- |-------|-------|---------|
114
- | Low | Green | Safe, read-only commands |
115
- | Medium | Yellow | Modifies files or system state |
116
- | High | Red | Potentially destructive |
117
-
118
- ## Security
119
-
120
- ### API Key Storage
121
-
122
- Your Anthropic API key is stored securely using industry-standard methods:
123
-
124
- **Primary: System Keyring**
125
-
126
- | Platform | Storage Backend |
127
- |----------|-----------------|
128
- | macOS | Keychain |
129
- | Windows | Credential Manager |
130
- | Linux | Secret Service API (GNOME Keyring, KWallet) |
131
-
132
- The system keyring provides OS-level encryption and access control. Your API key is never stored in plain text or environment variables.
133
-
134
- **Fallback: Encrypted File**
135
-
136
- If the system keyring is unavailable, the key is stored in an encrypted file at `~/.cli_ai_assistant/`. The encryption key is derived from your machine's unique identifiers (hostname + username), making the encrypted file non-portable and machine-specific.
137
-
138
- ### Key Management
139
-
140
- - **View**: See masked key (`sk-ant-***...****`) and storage method in `/config`
141
- - **Change**: Update your API key anytime through settings
142
- - **Remove**: Delete your stored key completely
143
-
144
- ## Requirements
145
-
146
- - **Node.js 20+**
147
- - **Build tools** for native modules:
148
-
149
- | Platform | Command |
150
- |----------|---------|
151
- | Windows | `npm install -g windows-build-tools` (Admin) |
152
- | macOS | `xcode-select --install` |
153
- | Ubuntu/Debian | `sudo apt install build-essential libsecret-1-dev` |
154
- | Fedora | `sudo dnf install gcc-c++ libsecret-devel` |
155
- | Arch | `sudo pacman -S base-devel libsecret` |
156
-
157
- ## Development
158
-
159
- ```bash
160
- git clone https://github.com/fmdz387/cli-ai.git
161
- cd cli-ai
162
- pnpm install
163
- pnpm dev # Watch mode
164
- pnpm build # Production build
165
- ```
166
-
167
- ## License
168
-
169
- ISC
1
+ # CLI AI
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@fmdzc/cli-ai)](https://www.npmjs.com/package/@fmdzc/cli-ai)
4
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
5
+ [![Node.js](https://img.shields.io/badge/Node.js-20+-green.svg)](https://nodejs.org/)
6
+
7
+ **Natural language to shell commands. Multi-provider AI support.**
8
+
9
+ Describe what you want in plain English. Get the right command. Review, execute, or copy.
10
+
11
+ Supports **Anthropic**, **OpenAI**, and **OpenRouter** providers.
12
+
13
+ ![CLI AI Demo](assets/cli-ai.png)
14
+
15
+ ## Features
16
+
17
+ - **Multi-provider** - Anthropic, OpenAI, OpenRouter with any model support
18
+ - **Natural language** - Just describe what you want to do
19
+ - **Cross-platform** - Windows (PowerShell, CMD, Git Bash), macOS, Linux
20
+ - **Shell-aware** - Commands tailored to your detected shell
21
+ - **Interactive** - Execute, copy, edit, or request alternatives
22
+ - **Context-aware** - Remembers your conversation history for smarter suggestions
23
+ - **Secure** - API keys stored in system keyring, never in plain text
24
+ - **Risk assessment** - Color-coded safety levels for every command
25
+
26
+ ## Quick Start
27
+
28
+ ```bash
29
+ # Install globally
30
+ npm install -g @fmdzc/cli-ai
31
+
32
+ # Run
33
+ s
34
+ # or
35
+ cli-ai
36
+ ```
37
+
38
+ On first run, you'll be prompted for an API key. Get one from:
39
+ - [Anthropic](https://console.anthropic.com/settings/keys)
40
+ - [OpenAI](https://platform.openai.com/api-keys)
41
+ - [OpenRouter](https://openrouter.ai/keys)
42
+
43
+ ## Usage
44
+
45
+ Type what you want in natural language:
46
+
47
+ ```
48
+ > find files larger than 100MB
49
+
50
+ $ find . -size +100M -type f
51
+ Risk: low
52
+
53
+ [1] Execute [2] Copy [3] Edit [4] Alternatives [5] Cancel
54
+ ```
55
+
56
+ ### Slash Commands
57
+
58
+ Type `/` to access commands:
59
+
60
+ | Command | Description |
61
+ | --------- | ----------------------- |
62
+ | `/config` | Open settings panel |
63
+ | `/help` | Show help and shortcuts |
64
+ | `/clear` | Clear command history |
65
+ | `/exit` | Exit application |
66
+
67
+ ### Keyboard Shortcuts
68
+
69
+ **Input Mode**
70
+ | Key | Action |
71
+ | -------- | ----------------------- |
72
+ | `/` | Open command palette |
73
+ | `Enter` | Submit query |
74
+ | `O` | Toggle output expansion |
75
+ | `Ctrl+D` | Exit (when empty) |
76
+
77
+ **Command Proposal**
78
+ | Key | Action |
79
+ | ------------- | ----------------- |
80
+ | `1` / `Enter` | Execute command |
81
+ | `2` | Copy to clipboard |
82
+ | `3` | Edit command |
83
+ | `4` | Show alternatives |
84
+ | `5` / `Esc` | Cancel |
85
+ | `?` | Explain command |
86
+
87
+ **Settings Panel**
88
+ | Key | Action |
89
+ | --------- | -------------- |
90
+ | `Tab` | Next section |
91
+ | `Up/Down` | Navigate items |
92
+ | `Enter` | Toggle/Select |
93
+ | `Esc` | Close |
94
+
95
+ ## Settings
96
+
97
+ Access settings with `/config`:
98
+
99
+ ### Provider & Model
100
+
101
+ Supported AI providers:
102
+ - **Anthropic** - Claude models
103
+ - **OpenAI** - GPT models
104
+ - **OpenRouter** - 100+ models from various providers
105
+
106
+ Any model from your selected provider is supported. Use the built-in presets or enter a custom model ID.
107
+
108
+ ### API Keys
109
+
110
+ Manage API keys for each provider separately:
111
+ - View key status (✓ Configured / ✗ Not set)
112
+ - Add or change keys for any provider
113
+ - Keys are stored securely per provider
114
+
115
+ ### Options
116
+ | Setting | Description |
117
+ | ------------------- | ------------------------------------------------------- |
118
+ | Context | Pass conversation history to AI for smarter suggestions |
119
+ | Show explanations | Display command explanations |
120
+ | Syntax highlighting | Colorize command output |
121
+ | Simple mode | Minimal UI mode |
122
+
123
+ ## Risk Assessment
124
+
125
+ | Level | Color | Meaning |
126
+ | ------ | ------ | ------------------------------ |
127
+ | Low | Green | Safe, read-only commands |
128
+ | Medium | Yellow | Modifies files or system state |
129
+ | High | Red | Potentially destructive |
130
+
131
+ ## Security
132
+
133
+ ### API Key Storage
134
+
135
+ Your API keys are stored securely using industry-standard methods. Each provider's key is stored separately.
136
+
137
+ **Primary: System Keyring**
138
+
139
+ | Platform | Storage Backend |
140
+ | -------- | ------------------------------------------- |
141
+ | macOS | Keychain |
142
+ | Windows | Credential Manager |
143
+ | Linux | Secret Service API (GNOME Keyring, KWallet) |
144
+
145
+ The system keyring provides OS-level encryption and access control. API keys are never stored in plain text or environment variables.
146
+
147
+ **Fallback: Encrypted File**
148
+
149
+ If the system keyring is unavailable, keys are stored in an encrypted file at `~/.cli_ai_assistant/`. The encryption key is derived from your machine's unique identifiers (hostname + username), making the encrypted file non-portable and machine-specific.
150
+
151
+ ### Key Management
152
+
153
+ - **View**: See masked keys and storage method per provider in `/config`
154
+ - **Add**: Configure API keys for Anthropic, OpenAI, or OpenRouter
155
+ - **Change**: Update any API key anytime through settings
156
+ - **Status**: Green ✓ indicates configured, red ✗ indicates not set
157
+
158
+ ## Requirements
159
+
160
+ - **Node.js 20+**
161
+ - **Build tools** for native modules:
162
+
163
+ | Platform | Command |
164
+ | ------------- | -------------------------------------------------- |
165
+ | Windows | `npm install -g windows-build-tools` (Admin) |
166
+ | macOS | `xcode-select --install` |
167
+ | Ubuntu/Debian | `sudo apt install build-essential libsecret-1-dev` |
168
+ | Fedora | `sudo dnf install gcc-c++ libsecret-devel` |
169
+ | Arch | `sudo pacman -S base-devel libsecret` |
170
+
171
+ ## Development
172
+
173
+ ```bash
174
+ git clone https://github.com/fmdz387/cli-ai.git
175
+ cd cli-ai
176
+ pnpm install
177
+ pnpm dev # Watch mode
178
+ pnpm build # Production build
179
+ ```
180
+
181
+ ## License
182
+
183
+ ISC
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
- #!/usr/bin/env node
2
-
3
- // Suppress experimental warnings for JSON imports from dependencies
4
- const originalEmit = process.emit;
5
- process.emit = function (name, data) {
6
- if (name === 'warning' && data && data.name === 'ExperimentalWarning') {
7
- return false;
8
- }
9
- return originalEmit.apply(process, arguments);
10
- };
11
-
12
- // Import and run the main module
13
- import('./index.js');
1
+ #!/usr/bin/env node
2
+
3
+ // Suppress experimental warnings for JSON imports from dependencies
4
+ const originalEmit = process.emit;
5
+ process.emit = function (name, data) {
6
+ if (name === 'warning' && data && data.name === 'ExperimentalWarning') {
7
+ return false;
8
+ }
9
+ return originalEmit.apply(process, arguments);
10
+ };
11
+
12
+ // Import and run the main module
13
+ import('./index.js');