@fmdzc/cli-ai 3.0.3 → 3.0.4

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,171 @@
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. 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
+ # or
32
+ cli-ai
33
+ ```
34
+
35
+ On first run, you'll be prompted for your [Anthropic API key](https://console.anthropic.com/settings/keys).
36
+
37
+ ## Usage
38
+
39
+ Type what you want in natural language:
40
+
41
+ ```
42
+ > find files larger than 100MB
43
+
44
+ $ find . -size +100M -type f
45
+ Risk: low
46
+
47
+ [1] Execute [2] Copy [3] Edit [4] Alternatives [5] Cancel
48
+ ```
49
+
50
+ ### Slash Commands
51
+
52
+ Type `/` to access commands:
53
+
54
+ | Command | Description |
55
+ |---------|-------------|
56
+ | `/config` | Open settings panel |
57
+ | `/help` | Show help and shortcuts |
58
+ | `/clear` | Clear command history |
59
+ | `/exit` | Exit application |
60
+
61
+ ### Keyboard Shortcuts
62
+
63
+ **Input Mode**
64
+ | Key | Action |
65
+ |-----|--------|
66
+ | `/` | Open command palette |
67
+ | `Enter` | Submit query |
68
+ | `O` | Toggle output expansion |
69
+ | `Ctrl+D` | Exit (when empty) |
70
+
71
+ **Command Proposal**
72
+ | Key | Action |
73
+ |-----|--------|
74
+ | `1` / `Enter` | Execute command |
75
+ | `2` | Copy to clipboard |
76
+ | `3` | Edit command |
77
+ | `4` | Show alternatives |
78
+ | `5` / `Esc` | Cancel |
79
+ | `?` | Explain command |
80
+
81
+ **Settings Panel**
82
+ | Key | Action |
83
+ |-----|--------|
84
+ | `Tab` | Next section |
85
+ | `Up/Down` | Navigate items |
86
+ | `Enter` | Toggle/Select |
87
+ | `Esc` | Close |
88
+
89
+ ## Settings
90
+
91
+ Access settings with `/config`:
92
+
93
+ ### API Key
94
+ - View masked key and storage method
95
+ - Change or remove API key
96
+
97
+ ### Model Selection
98
+ | Model | Description |
99
+ |-------|-------------|
100
+ | Claude Sonnet 4.5 | Fast and capable (default) |
101
+ | Claude Opus 4.5 | Most capable |
102
+ | Claude Haiku 4.5 | Fastest |
103
+
104
+ ### Options
105
+ | Setting | Description |
106
+ |---------|-------------|
107
+ | Context | Pass conversation history to AI for smarter suggestions |
108
+ | Show explanations | Display command explanations |
109
+ | Syntax highlighting | Colorize command output |
110
+ | Simple mode | Minimal UI mode |
111
+
112
+ ## Risk Assessment
113
+
114
+ | Level | Color | Meaning |
115
+ |-------|-------|---------|
116
+ | Low | Green | Safe, read-only commands |
117
+ | Medium | Yellow | Modifies files or system state |
118
+ | High | Red | Potentially destructive |
119
+
120
+ ## Security
121
+
122
+ ### API Key Storage
123
+
124
+ Your Anthropic API key is stored securely using industry-standard methods:
125
+
126
+ **Primary: System Keyring**
127
+
128
+ | Platform | Storage Backend |
129
+ |----------|-----------------|
130
+ | macOS | Keychain |
131
+ | Windows | Credential Manager |
132
+ | Linux | Secret Service API (GNOME Keyring, KWallet) |
133
+
134
+ The system keyring provides OS-level encryption and access control. Your API key is never stored in plain text or environment variables.
135
+
136
+ **Fallback: Encrypted File**
137
+
138
+ 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.
139
+
140
+ ### Key Management
141
+
142
+ - **View**: See masked key (`sk-ant-***...****`) and storage method in `/config`
143
+ - **Change**: Update your API key anytime through settings
144
+ - **Remove**: Delete your stored key completely
145
+
146
+ ## Requirements
147
+
148
+ - **Node.js 20+**
149
+ - **Build tools** for native modules:
150
+
151
+ | Platform | Command |
152
+ |----------|---------|
153
+ | Windows | `npm install -g windows-build-tools` (Admin) |
154
+ | macOS | `xcode-select --install` |
155
+ | Ubuntu/Debian | `sudo apt install build-essential libsecret-1-dev` |
156
+ | Fedora | `sudo dnf install gcc-c++ libsecret-devel` |
157
+ | Arch | `sudo pacman -S base-devel libsecret` |
158
+
159
+ ## Development
160
+
161
+ ```bash
162
+ git clone https://github.com/fmdz387/cli-ai.git
163
+ cd cli-ai
164
+ pnpm install
165
+ pnpm dev # Watch mode
166
+ pnpm build # Production build
167
+ ```
168
+
169
+ ## License
170
+
171
+ 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');
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- var Hn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof require<"u"?require:t)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{render as Wr}from"ink";var yt=[{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable"},{id:"claude-opus-4-5",name:"Claude Opus 4.5",description:"Most capable"},{id:"claude-haiku-4-5",name:"Claude Haiku 4.5",description:"Fastest"}];function Ct(e,t){let o=e.toLowerCase(),n=t.toLowerCase();if(n.startsWith(o))return 100+(100-n.length);if(n.includes(o))return 50+(50-n.indexOf(o));let i=0,s=0;for(let a=0;a<n.length&&s<o.length;a++)n[a]===o[s]&&(i+=10,s++);return s===o.length?i:0}function Fn(e,t){let o=Ct(e,t.name),n=Ct(e,t.description),i=(t.aliases??[]).map(s=>Ct(e,s));return Math.max(o,n,...i)}function Xt(){let e=[],t=new Map;function o(){t.clear();for(let n of e){t.set(n.name.toLowerCase(),n);for(let i of n.aliases??[])t.set(i.toLowerCase(),n)}}return{get commands(){return e},get(n){return t.get(n.toLowerCase())},filter(n){return n?e.map(s=>({cmd:s,score:Fn(n,s)})).filter(({score:s})=>s>0).sort((s,a)=>a.score-s.score).map(({cmd:s})=>s):[...e]},register(n){t.get(n.name.toLowerCase())||(e.push(n),o())}}}var z=Xt();var ht={name:"clear",description:"Clear conversation history",category:"session",aliases:["cls"],execute:()=>({type:"navigate",to:"clear"}),isAvailable:e=>e==="input"};var Tt={name:"config",description:"Open settings and configuration panel",category:"settings",aliases:["settings","preferences","prefs"],shortcut:"Ctrl+,",execute:()=>({type:"panel",panel:"config"}),isAvailable:e=>e==="input"};var St={name:"exit",description:"Exit the application",category:"session",aliases:["quit","q"],execute:()=>({type:"exit"}),isAvailable:()=>!0};var Et={name:"help",description:"Show help and keyboard shortcuts",category:"help",aliases:["h","?"],execute:()=>({type:"panel",panel:"help"}),isAvailable:()=>!0};z.register(Tt);z.register(Et);z.register(ht);z.register(St);var ee="3.0.3",Ce="CLI AI",Wt="cli-ai",Qt="anthropic",Vt=".cli_ai_assistant",_e="claude-sonnet-4-5",he={model:_e,maxHistoryEntries:5,maxOutputLines:10,maxAlternatives:3,contextEnabled:!0},zt=500,Jt=10,Zt=["rm -rf","sudo rm","chmod 777","mkfs","dd if=","> /dev/","format","del /f","rmdir /s","DROP TABLE","DELETE FROM","--no-preserve-root",":(){:|:&};:","| sh","| bash","curl | bash","wget | bash","eval","sudo su","passwd","chown -R","> /etc/","fdisk","wipefs","shred"],eo=["rm ","mv ","cp ","sudo ","npm install","pnpm install","yarn add","pip install","brew install","apt install","apt-get install","pacman -S","chmod ","chown ","git push","git reset","git rebase","docker ","kubectl ","systemctl ","service ","kill ","pkill "],to=["sudo","rm","git","npm","pnpm","yarn","docker","kubectl","pip","python","node","npx","cd","ls","cat","grep","find","mkdir","touch","mv","cp","echo","curl","wget","ssh","scp"],Je=500,Me={maxAttempts:3,baseDelayMs:1e3,maxDelayMs:5e3};import{Box as $,Text as J,useInput as $n}from"ink";import{useState as vt}from"react";import{TextInput as Yn}from"@inkjs/ui";import{jsx as N,jsxs as le}from"react/jsx-runtime";function oo({onComplete:e,onError:t,error:o}){let[n,i]=vt("welcome"),[s,a]=vt(""),[c,g]=vt(null);$n((d,u)=>{n==="welcome"&&(u.return||d===" ")&&i("input")},{isActive:n==="welcome"});let m=d=>{let u=d.trim();if(!u){g("API key cannot be empty");return}if(!u.startsWith("sk-ant-")){g('Invalid key format. Anthropic API keys start with "sk-ant-"');return}if(u.length<20){g("API key seems too short");return}g(null),i("saving"),e(u)};if(n==="welcome")return le($,{flexDirection:"column",paddingY:1,children:[N($,{marginBottom:1,children:le(J,{bold:!0,color:"cyan",children:[Ce," v",ee]})}),N($,{marginBottom:1,children:N(J,{children:"Welcome! This tool translates natural language into shell commands."})}),N($,{marginBottom:1,children:le(J,{dimColor:!0,children:["To get started, you'll need an Anthropic API key.",`
2
- `,"Get one at: ",N(J,{color:"blue",children:"https://console.anthropic.com/settings/keys"})]})}),N($,{children:N(J,{color:"green",children:"Press Enter to continue..."})})]});let y=o??c;return n==="input"?le($,{flexDirection:"column",paddingY:1,children:[N($,{marginBottom:1,children:N(J,{bold:!0,children:"Enter your Anthropic API key:"})}),y&&N($,{marginBottom:1,children:le(J,{color:"red",children:["\u26A0 ",y]})}),le($,{children:[N(J,{dimColor:!0,children:"> "}),N(Yn,{placeholder:"sk-ant-...",onChange:a,onSubmit:m})]}),N($,{marginTop:1,children:N(J,{dimColor:!0,children:"Your key will be stored securely in your system keyring."})})]}):n==="saving"?N($,{flexDirection:"column",paddingY:1,children:N($,{children:N(J,{color:"yellow",children:"\u23F3 Saving API key..."})})}):le($,{flexDirection:"column",paddingY:1,children:[N($,{children:N(J,{color:"green",children:"\u2713 API key saved successfully!"})}),N($,{marginTop:1,children:le(J,{children:["Starting ",Ce,"..."]})})]})}import{Box as Ze,Text as bt}from"ink";import{jsx as Ke,jsxs as no}from"react/jsx-runtime";function ro({lines:e,command:t}){return no(Ze,{flexDirection:"column",marginY:1,children:[Ke(Ze,{marginBottom:1,children:no(bt,{dimColor:!0,children:["$ ",t]})}),Ke(Ze,{flexDirection:"column",children:e.map((o,n)=>{let i=o.startsWith("[ERR]");return Ke(bt,{color:i?"red":void 0,children:i?o.slice(6):o},n)})}),Ke(Ze,{marginTop:1,children:Ke(bt,{color:"yellow",children:"\u23F3 Running..."})})]})}import{Box as Ae,Text as we}from"ink";import{Box as Gn,Text as ce}from"ink";import{Fragment as jn,jsx as Ie,jsxs as et}from"react/jsx-runtime";function Pt({command:e,index:t,isSelected:o}){return et(Gn,{children:[Ie(ce,{color:o?"cyan":"gray",bold:o,children:o?"> ":" "}),et(ce,{color:o?"cyan":"blue",bold:o,children:["[",t+1,"]"]}),Ie(ce,{children:" "}),et(ce,{color:o?"white":"gray",bold:o,children:["/",e.name]}),Ie(ce,{children:" "}),Ie(ce,{dimColor:!o,children:e.description}),e.shortcut?et(jn,{children:[Ie(ce,{children:" "}),Ie(ce,{dimColor:!0,color:"yellow",children:e.shortcut})]}):null]})}import{jsx as te,jsxs as so}from"react/jsx-runtime";function It({query:e,filteredCommands:t,selectedIndex:o,visible:n}){return n?so(Ae,{flexDirection:"column",borderStyle:"round",borderColor:"blue",paddingX:1,marginTop:1,children:[so(Ae,{children:[te(we,{color:"blue",bold:!0,children:"/"}),te(we,{color:"white",children:e}),te(we,{color:"cyan",children:"_"})]}),te(Ae,{marginY:0,children:te(we,{dimColor:!0,children:"\u2500".repeat(50)})}),t.length>0?te(Ae,{flexDirection:"column",children:t.slice(0,9).map((i,s)=>te(Pt,{command:i,index:s,isSelected:s===o},i.name))}):te(Ae,{children:te(we,{dimColor:!0,children:"No matching commands"})}),te(Ae,{marginTop:1,children:te(we,{dimColor:!0,children:"[Enter] Select [1-9] Quick select [Esc] Close"})})]}):null}import{Box as ue,Text as Te}from"ink";import Ys from"chalk";function qn(e){let t=[],o=e.split(/(\s+)/);for(let n of o)if(n){if(/^\s+$/.test(n)){t.push({type:"default",value:n});continue}if(/^[|><&;]+$/.test(n)||n==="&&"||n==="||"){t.push({type:"pipe",value:n});continue}if(/^-{1,2}[\w-]+=?/.test(n)){t.push({type:"flag",value:n});continue}if(/^\$[\w{}]+/.test(n)){t.push({type:"variable",value:n});continue}if(/^["'].*["']$/.test(n)){t.push({type:"string",value:n});continue}if(n.includes("/")||n.includes("\\")){t.push({type:"path",value:n});continue}if(to.includes(n.toLowerCase())){t.push({type:"keyword",value:n});continue}t.push({type:"default",value:n})}return t}function io(e){return qn(e).map(o=>{switch(o.type){case"keyword":return{text:o.value,color:"cyan",bold:!0};case"flag":return{text:o.value,color:"yellow"};case"string":return{text:o.value,color:"green"};case"pipe":return{text:o.value,color:"magenta"};case"path":return{text:o.value,color:"blue"};case"variable":return{text:o.value,color:"cyan"};default:return{text:o.value}}})}import{jsx as X,jsxs as Ue}from"react/jsx-runtime";function ao({command:e}){let t=io(e);return X(Te,{children:t.map((o,n)=>X(Te,{color:o.color,bold:o.bold,children:o.text},n))})}function lo({proposal:e,showExplanation:t=!1}){return Ue(ue,{flexDirection:"column",children:[X(ue,{borderStyle:"round",borderColor:"gray",paddingX:2,paddingY:1,children:X(ao,{command:e.command})}),t&&e.explanation&&X(ue,{marginTop:1,paddingX:1,children:X(Te,{dimColor:!0,children:e.explanation})})]})}function Xn({command:e,index:t,selected:o=!1}){return Ue(ue,{children:[Ue(Te,{color:o?"cyan":"blue",bold:o,children:["[",t+1,"]"]}),X(Te,{children:" "}),X(ao,{command:e})]})}function co({proposals:e,selectedIndex:t=-1}){return Ue(ue,{flexDirection:"column",marginY:1,children:[X(ue,{marginBottom:1,children:X(Te,{bold:!0,children:"Alternative commands:"})}),e.map((o,n)=>X(ue,{marginBottom:1,children:X(Xn,{command:o.command,index:n,selected:n===t})},n)),X(ue,{marginTop:1,children:Ue(Te,{dimColor:!0,children:["Press 1-",e.length," to select, or [5] Cancel"]})})]})}import{Box as He,Text as oe}from"ink";import{Fragment as Wn,jsx as se,jsxs as Se}from"react/jsx-runtime";function At({hasApiKey:e,storageMethod:t,storageDescription:o,isSecure:n,maskedKey:i,isSectionActive:s,focusedIndex:a}){return Se(He,{flexDirection:"column",children:[Se(He,{children:[se(oe,{dimColor:!0,children:"Status: "}),se(oe,{color:e?"green":"red",children:e?"Configured":"Not configured"}),e?Se(Wn,{children:[se(oe,{dimColor:!0,children:" ("}),se(oe,{color:n?"green":"yellow",children:o}),se(oe,{dimColor:!0,children:")"})]}):null]}),i?Se(He,{children:[se(oe,{dimColor:!0,children:"Key: "}),se(oe,{color:"gray",children:i})]}):null,Se(He,{marginTop:1,children:[se(oe,{color:s&&a===0?"cyan":"gray",bold:s&&a===0,children:s&&a===0?"> ":" "}),Se(oe,{color:s&&a===0?"cyan":"blue",children:["[",e?"Change API Key":"Set API Key","]"]})]}),e?Se(He,{children:[se(oe,{color:s&&a===1?"cyan":"gray",bold:s&&a===1,children:s&&a===1?"> ":" "}),se(oe,{color:s&&a===1?"red":"gray",children:"[Remove API Key]"})]}):null]})}import{Box as ie,Text as Ee}from"ink";import{Box as tt,Text as wt}from"ink";import{jsx as Fe,jsxs as uo}from"react/jsx-runtime";function Re({title:e,isActive:t,children:o}){return uo(tt,{flexDirection:"column",marginBottom:1,children:[uo(tt,{children:[Fe(wt,{color:t?"cyan":"white",bold:!0,children:e}),t?Fe(wt,{color:"cyan",children:" *"}):null]}),Fe(tt,{children:Fe(wt,{dimColor:!0,children:"\u2500".repeat(50)})}),Fe(tt,{flexDirection:"column",paddingLeft:0,children:o})]})}import{Box as po,Text as $e}from"ink";import{Fragment as Qn,jsx as Oe,jsxs as mo}from"react/jsx-runtime";function Rt({options:e,selectedValue:t,focusedIndex:o,isSectionActive:n}){return Oe(po,{flexDirection:"column",children:e.map((i,s)=>{let a=i.id===t,c=n&&s===o;return mo(po,{children:[Oe($e,{color:c?"cyan":"gray",bold:c,children:c?"> ":" "}),Oe($e,{color:a?"green":c?"white":"gray",children:a?"(*) ":"( ) "}),Oe($e,{color:c?"white":"gray",bold:a,children:i.name}),i.description?mo(Qn,{children:[Oe($e,{dimColor:!0,children:" - "}),Oe($e,{dimColor:!0,children:i.description})]}):null]},i.id)})})}import{Box as Vn,Text as ot}from"ink";import{jsx as nt,jsxs as zn}from"react/jsx-runtime";function Be({label:e,value:t,isSelected:o}){return zn(Vn,{children:[nt(ot,{color:o?"cyan":"gray",bold:o,children:o?"> ":" "}),nt(ot,{color:t?"green":"gray",children:t?"[x]":"[ ]"}),nt(ot,{children:" "}),nt(ot,{color:o?"white":"gray",children:e})]})}import{jsx as K,jsxs as pe}from"react/jsx-runtime";var fo=["api-key","model","toggles","about"];function Ot({visible:e,activeSection:t,sectionItemIndex:o,config:n,hasApiKey:i,storageInfo:s,maskedKey:a,toggles:c}){if(!e)return null;let g=fo.indexOf(t);return pe(ie,{flexDirection:"column",borderStyle:"round",borderColor:"blue",paddingX:2,paddingY:1,children:[pe(ie,{justifyContent:"space-between",marginBottom:1,children:[K(ie,{children:K(Ee,{color:"cyan",bold:!0,children:"Settings"})}),K(ie,{children:K(Ee,{dimColor:!0,children:"[Esc] Close [Tab] Section [Enter] Select"})})]}),K(Re,{title:"API Key",isActive:t==="api-key",children:K(At,{hasApiKey:i,storageMethod:s.method,storageDescription:s.description,isSecure:s.secure,maskedKey:a,isSectionActive:t==="api-key",focusedIndex:o})}),K(Re,{title:"Model",isActive:t==="model",children:K(Rt,{options:yt,selectedValue:n.model,focusedIndex:o,isSectionActive:t==="model"})}),pe(Re,{title:"Options",isActive:t==="toggles",children:[K(Be,{label:"Context (pass history to AI)",value:c.contextEnabled,isSelected:t==="toggles"&&o===0}),K(Be,{label:"Show explanations",value:c.showExplanations,isSelected:t==="toggles"&&o===1}),K(Be,{label:"Syntax highlighting",value:c.syntaxHighlighting,isSelected:t==="toggles"&&o===2}),K(Be,{label:"Simple mode",value:c.simpleMode,isSelected:t==="toggles"&&o===3})]}),K(Re,{title:"About",isActive:t==="about",children:pe(ie,{flexDirection:"column",children:[pe(ie,{children:[K(Ee,{dimColor:!0,children:"Version: "}),pe(Ee,{children:["CLI AI v",ee]})]}),pe(ie,{children:[K(Ee,{dimColor:!0,children:"Storage: "}),K(Ee,{color:s.secure?"green":"yellow",children:s.description})]})]})}),K(ie,{marginTop:1,justifyContent:"center",children:fo.map((m,y)=>K(ie,{marginX:1,children:pe(Ee,{color:y===g?"cyan":"gray",children:[y===g?"[":" ",y+1,y===g?"]":" "]})},m))})]})}import{Box as D,Text as Y}from"ink";import{jsx as P,jsxs as W}from"react/jsx-runtime";var Jn=[{key:"/",description:"Open command palette"},{key:"Enter",description:"Submit query"},{key:"Ctrl+D",description:"Exit (when input is empty)"},{key:"O",description:"Toggle output expansion (when input is empty)"}],Zn=[{key:"1 / Enter",description:"Execute command"},{key:"2",description:"Copy to clipboard"},{key:"3",description:"Edit command"},{key:"4",description:"Show alternatives"},{key:"5 / Esc",description:"Cancel"},{key:"?",description:"Explain command"},{key:"O",description:"Toggle output"}],er=[{key:"Up/Down",description:"Navigate commands"},{key:"Enter",description:"Select command"},{key:"Esc",description:"Close palette"},{key:"1-9",description:"Quick select"}],tr=[{key:"Tab",description:"Next section"},{key:"Shift+Tab",description:"Previous section"},{key:"Up/Down",description:"Navigate items"},{key:"Enter/Space",description:"Toggle/Select"},{key:"Esc",description:"Close panel"}];function rt({title:e,shortcuts:t}){return W(D,{flexDirection:"column",marginBottom:1,children:[P(Y,{color:"yellow",bold:!0,children:e}),t.map(o=>W(D,{children:[P(D,{width:16,children:P(Y,{color:"cyan",children:o.key})}),P(Y,{dimColor:!0,children:o.description})]},o.key))]})}function Bt({visible:e}){return e?W(D,{flexDirection:"column",borderStyle:"round",borderColor:"blue",paddingX:2,paddingY:1,children:[W(D,{justifyContent:"space-between",marginBottom:1,children:[P(D,{children:W(Y,{color:"cyan",bold:!0,children:["Help - ",Ce," v",ee]})}),P(D,{children:P(Y,{dimColor:!0,children:"[Esc] Close"})})]}),P(D,{marginBottom:1,children:P(Y,{children:"Natural language to shell command translator. Describe what you want in plain English and get executable commands."})}),W(D,{children:[W(D,{flexDirection:"column",marginRight:4,children:[P(rt,{title:"Input Mode",shortcuts:Jn}),P(rt,{title:"Command Palette",shortcuts:er})]}),W(D,{flexDirection:"column",children:[P(rt,{title:"Proposal Mode",shortcuts:Zn}),P(rt,{title:"Config Panel",shortcuts:tr})]})]}),W(D,{flexDirection:"column",marginTop:1,children:[P(Y,{color:"yellow",bold:!0,children:"Available Commands"}),W(D,{children:[P(D,{width:16,children:P(Y,{color:"cyan",children:"/config"})}),P(Y,{dimColor:!0,children:"Open settings panel"})]}),W(D,{children:[P(D,{width:16,children:P(Y,{color:"cyan",children:"/help"})}),P(Y,{dimColor:!0,children:"Show this help"})]}),W(D,{children:[P(D,{width:16,children:P(Y,{color:"cyan",children:"/clear"})}),P(Y,{dimColor:!0,children:"Clear command history"})]}),W(D,{children:[P(D,{width:16,children:P(Y,{color:"cyan",children:"/exit"})}),P(Y,{dimColor:!0,children:"Exit application"})]})]})]}):null}import{Box as st,Text as Ge}from"ink";import{Text as or}from"ink";import Ye from"chalk";import{useMemo as go}from"react";import{jsx as rr}from"react/jsx-runtime";var Nt=Ye.inverse(" ");function xo({value:e,cursorOffset:t,placeholder:o="",isDisabled:n=!1}){let i=go(()=>n?o?Ye.dim(o):"":o&&o.length>0?Ye.inverse(o[0])+Ye.dim(o.slice(1)):Nt,[n,o]),s=go(()=>{if(n)return e;let a=0,c=e.length>0?"":Nt;for(let g of e)c+=a===t?Ye.inverse(g):g,a++;return e.length>0&&t===e.length&&(c+=Nt),c},[n,e,t]);return rr(or,{children:e.length>0?s:i})}var nr={value:"",cursorOffset:0};function yo(e=""){return{value:e,cursorOffset:e.length}}function Co(e,t){switch(t.type){case"insert":return{value:e.value.slice(0,e.cursorOffset)+t.text+e.value.slice(e.cursorOffset),cursorOffset:e.cursorOffset+t.text.length};case"delete":{if(e.cursorOffset===0)return e;let o=e.cursorOffset-1;return{value:e.value.slice(0,o)+e.value.slice(o+1),cursorOffset:o}}case"move-left":return{...e,cursorOffset:Math.max(0,e.cursorOffset-1)};case"move-right":return{...e,cursorOffset:Math.min(e.value.length,e.cursorOffset+1)};case"clear":return nr;case"set":return{value:t.value,cursorOffset:t.value.length};default:return e}}import{jsx as Ne,jsxs as it}from"react/jsx-runtime";function ho({textState:e,placeholder:t="Describe what you want to do...",disabled:o=!1,hasHistory:n=!1,visible:i=!0}){return i?o?it(st,{children:[Ne(Ge,{dimColor:!0,children:"> "}),Ne(Ge,{dimColor:!0,children:e.value||"..."})]}):it(st,{flexDirection:"column",children:[it(st,{children:[Ne(Ge,{color:"green",bold:!0,children:"> "}),Ne(xo,{value:e.value,cursorOffset:e.cursorOffset,placeholder:t,isDisabled:o})]}),n&&Ne(st,{marginTop:1,children:it(Ge,{dimColor:!0,children:[Ne(Ge,{color:"blue",children:"[O]"})," Toggle output"]})})]}):null}import{Box as je,Text as ne}from"ink";import{jsx as de,jsxs as me}from"react/jsx-runtime";var sr=[{key:"1",label:"Execute"},{key:"2",label:"Copy"},{key:"3",label:"Edit"},{key:"4",label:"Alternatives"},{key:"5",label:"Cancel"}];function To({focusedIndex:e,showExplain:t=!0,visible:o=!0}){return o?me(je,{flexDirection:"column",marginTop:1,children:[de(je,{flexDirection:"row",gap:1,children:sr.map((n,i)=>{let s=i===e;return me(je,{children:[me(ne,{color:s?"cyan":"blue",bold:s,inverse:s,children:["[",n.key,"]"]}),me(ne,{color:s?"cyan":void 0,bold:s,children:[" ",n.label]})]},n.key)})}),t&&de(je,{marginTop:1,children:me(ne,{dimColor:!0,children:[de(ne,{color:"blue",children:"[?]"})," Explain"," ",de(ne,{color:"blue",children:"[O]"})," Toggle output"," ",de(ne,{dimColor:!0,children:"| \u2190\u2192 Navigate, Enter Select"})]})})]}):null}function So({count:e,focusedIndex:t,visible:o=!0}){return o?de(je,{children:me(ne,{dimColor:!0,children:["Press ",me(ne,{color:"blue",children:["1-",e]})," or ",de(ne,{color:"blue",children:"\u2191\u2193"})," to select,"," ",de(ne,{color:"blue",children:"[5]"})," Cancel",t>=0&&me(ne,{color:"cyan",children:[" (focused: ",t+1,")"]})]})}):null}import{Box as Dt,Text as ir}from"ink";import{Spinner as ar}from"@inkjs/ui";import{jsx as Lt,jsxs as Eo}from"react/jsx-runtime";function kt({query:e,label:t="Thinking..."}){return Eo(Dt,{flexDirection:"column",marginY:1,children:[Lt(Dt,{children:Lt(ar,{label:t})}),e&&Lt(Dt,{marginTop:1,children:Eo(ir,{dimColor:!0,children:["Query: ",e]})})]})}import{Box as Q,Text as H}from"ink";import{homedir as lr,userInfo as cr}from"os";import{jsx as U,jsxs as Z}from"react/jsx-runtime";var ur=[" \u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E "," \u2502 \u25B6 _ \u2502 "," \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F "];function vo({shell:e,cwd:t,model:o}){let n=cr().username||"user",i=t.replace(lr(),"~"),s=o||"claude-sonnet-4-5";return Z(Q,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:2,paddingY:1,marginBottom:1,children:[Z(Q,{marginBottom:1,children:[U(H,{color:"cyan",bold:!0,children:Ce}),Z(H,{dimColor:!0,children:[" v",ee]})]}),Z(Q,{children:[Z(Q,{flexDirection:"column",marginRight:4,children:[Z(Q,{marginBottom:1,children:[U(H,{children:"Welcome, "}),U(H,{color:"yellow",bold:!0,children:n}),U(H,{children:"!"})]}),U(Q,{flexDirection:"column",children:ur.map((a,c)=>U(H,{color:"cyan",children:a},c))}),Z(Q,{marginTop:1,flexDirection:"column",children:[Z(Q,{children:[U(H,{dimColor:!0,children:"Shell: "}),U(H,{color:"green",children:e})]}),Z(Q,{children:[U(H,{dimColor:!0,children:"Path: "}),U(H,{children:i})]})]})]}),Z(Q,{flexDirection:"column",borderStyle:"single",borderColor:"gray",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,paddingLeft:2,children:[U(Q,{marginBottom:1,children:U(H,{color:"yellow",bold:!0,children:"Quick Start"})}),Z(Q,{flexDirection:"column",children:[U(H,{dimColor:!0,children:"Describe what you want in natural language:"}),U(H,{color:"gray",italic:!0,children:' "list all files modified today"'}),U(H,{color:"gray",italic:!0,children:' "find large files over 100MB"'}),U(H,{color:"gray",italic:!0,children:' "show git status"'})]}),Z(Q,{marginTop:1,flexDirection:"column",children:[U(H,{dimColor:!0,children:"Model: "}),U(H,{color:"magenta",children:s.split("-").slice(0,2).join(" ")})]})]})]})]})}import{useCallback as dt,useRef as Uo,useState as Nr}from"react";import{readdirSync as pr,statSync as mr}from"fs";import{join as dr,relative as fr}from"path";var gr=new Set(["node_modules",".git",".next","dist","build","__pycache__",".venv","venv",".idea",".vscode","coverage",".cache",".npm",".yarn",".pnpm",".turbo",".nuxt",".output","target","vendor",".angular",".svelte-kit"]),xr=new Set([".DS_Store","Thumbs.db",".gitignore",".npmrc",".yarnrc","pnpm-lock.yaml","package-lock.json","yarn.lock"]),yr=3,Cr=20;function bo(e,t=0){if(t>=yr)return[];try{let o=pr(e),n=[],i=0;for(let s of o){if(i>=Cr){n.push({name:`... (${o.length-i} more)`,isDirectory:!1});break}if(s.startsWith(".")&&!s.startsWith(".env")||xr.has(s))continue;let a=dr(e,s);try{if(mr(a).isDirectory()){if(gr.has(s))continue;let g=bo(a,t+1);n.push({name:s,isDirectory:!0,children:g.length>0?g:void 0})}else n.push({name:s,isDirectory:!1});i++}catch{continue}}return n}catch{return[]}}function Po(e,t=""){let o=[];return e.forEach((n,i)=>{let s=i===e.length-1,a=s?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",c=s?" ":"\u2502 ";n.isDirectory?(o.push(`${t}${a}${n.name}/`),n.children&&n.children.length>0&&o.push(Po(n.children,`${t}${c}`))):o.push(`${t}${a}${n.name}`)}),o.join(`
1
+ var Hn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof require<"u"?require:t)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{render as Wr}from"ink";var yt=[{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable"},{id:"claude-opus-4-5",name:"Claude Opus 4.5",description:"Most capable"},{id:"claude-haiku-4-5",name:"Claude Haiku 4.5",description:"Fastest"}];function Ct(e,t){let o=e.toLowerCase(),n=t.toLowerCase();if(n.startsWith(o))return 100+(100-n.length);if(n.includes(o))return 50+(50-n.indexOf(o));let i=0,s=0;for(let a=0;a<n.length&&s<o.length;a++)n[a]===o[s]&&(i+=10,s++);return s===o.length?i:0}function Fn(e,t){let o=Ct(e,t.name),n=Ct(e,t.description),i=(t.aliases??[]).map(s=>Ct(e,s));return Math.max(o,n,...i)}function Xt(){let e=[],t=new Map;function o(){t.clear();for(let n of e){t.set(n.name.toLowerCase(),n);for(let i of n.aliases??[])t.set(i.toLowerCase(),n)}}return{get commands(){return e},get(n){return t.get(n.toLowerCase())},filter(n){return n?e.map(s=>({cmd:s,score:Fn(n,s)})).filter(({score:s})=>s>0).sort((s,a)=>a.score-s.score).map(({cmd:s})=>s):[...e]},register(n){t.get(n.name.toLowerCase())||(e.push(n),o())}}}var z=Xt();var ht={name:"clear",description:"Clear conversation history",category:"session",aliases:["cls"],execute:()=>({type:"navigate",to:"clear"}),isAvailable:e=>e==="input"};var Tt={name:"config",description:"Open settings and configuration panel",category:"settings",aliases:["settings","preferences","prefs"],shortcut:"Ctrl+,",execute:()=>({type:"panel",panel:"config"}),isAvailable:e=>e==="input"};var St={name:"exit",description:"Exit the application",category:"session",aliases:["quit","q"],execute:()=>({type:"exit"}),isAvailable:()=>!0};var Et={name:"help",description:"Show help and keyboard shortcuts",category:"help",aliases:["h","?"],execute:()=>({type:"panel",panel:"help"}),isAvailable:()=>!0};z.register(Tt);z.register(Et);z.register(ht);z.register(St);var ee="3.0.4",Ce="CLI AI",Wt="cli-ai",Qt="anthropic",Vt=".cli_ai_assistant",_e="claude-sonnet-4-5",he={model:_e,maxHistoryEntries:5,maxOutputLines:10,maxAlternatives:3,contextEnabled:!0},zt=500,Jt=10,Zt=["rm -rf","sudo rm","chmod 777","mkfs","dd if=","> /dev/","format","del /f","rmdir /s","DROP TABLE","DELETE FROM","--no-preserve-root",":(){:|:&};:","| sh","| bash","curl | bash","wget | bash","eval","sudo su","passwd","chown -R","> /etc/","fdisk","wipefs","shred"],eo=["rm ","mv ","cp ","sudo ","npm install","pnpm install","yarn add","pip install","brew install","apt install","apt-get install","pacman -S","chmod ","chown ","git push","git reset","git rebase","docker ","kubectl ","systemctl ","service ","kill ","pkill "],to=["sudo","rm","git","npm","pnpm","yarn","docker","kubectl","pip","python","node","npx","cd","ls","cat","grep","find","mkdir","touch","mv","cp","echo","curl","wget","ssh","scp"],Je=500,Me={maxAttempts:3,baseDelayMs:1e3,maxDelayMs:5e3};import{Box as $,Text as J,useInput as $n}from"ink";import{useState as vt}from"react";import{TextInput as Yn}from"@inkjs/ui";import{jsx as N,jsxs as le}from"react/jsx-runtime";function oo({onComplete:e,onError:t,error:o}){let[n,i]=vt("welcome"),[s,a]=vt(""),[c,g]=vt(null);$n((d,u)=>{n==="welcome"&&(u.return||d===" ")&&i("input")},{isActive:n==="welcome"});let m=d=>{let u=d.trim();if(!u){g("API key cannot be empty");return}if(!u.startsWith("sk-ant-")){g('Invalid key format. Anthropic API keys start with "sk-ant-"');return}if(u.length<20){g("API key seems too short");return}g(null),i("saving"),e(u)};if(n==="welcome")return le($,{flexDirection:"column",paddingY:1,children:[N($,{marginBottom:1,children:le(J,{bold:!0,color:"cyan",children:[Ce," v",ee]})}),N($,{marginBottom:1,children:N(J,{children:"Welcome! This tool translates natural language into shell commands."})}),N($,{marginBottom:1,children:le(J,{dimColor:!0,children:["To get started, you'll need an Anthropic API key.",`
2
+ `,"Get one at: ",N(J,{color:"blue",children:"https://console.anthropic.com/settings/keys"})]})}),N($,{children:N(J,{color:"green",children:"Press Enter to continue..."})})]});let y=o??c;return n==="input"?le($,{flexDirection:"column",paddingY:1,children:[N($,{marginBottom:1,children:N(J,{bold:!0,children:"Enter your Anthropic API key:"})}),y&&N($,{marginBottom:1,children:le(J,{color:"red",children:["\u26A0 ",y]})}),le($,{children:[N(J,{dimColor:!0,children:"> "}),N(Yn,{placeholder:"sk-ant-...",onChange:a,onSubmit:m})]}),N($,{marginTop:1,children:N(J,{color:"yellow",children:"\u{1F512} Your key is stored securely on this machine using your system's credential manager (never sent anywhere except Anthropic's API)."})})]}):n==="saving"?N($,{flexDirection:"column",paddingY:1,children:N($,{children:N(J,{color:"yellow",children:"\u23F3 Saving API key..."})})}):le($,{flexDirection:"column",paddingY:1,children:[N($,{children:N(J,{color:"green",children:"\u2713 API key saved successfully!"})}),N($,{marginTop:1,children:le(J,{children:["Starting ",Ce,"..."]})})]})}import{Box as Ze,Text as bt}from"ink";import{jsx as Ke,jsxs as no}from"react/jsx-runtime";function ro({lines:e,command:t}){return no(Ze,{flexDirection:"column",marginY:1,children:[Ke(Ze,{marginBottom:1,children:no(bt,{dimColor:!0,children:["$ ",t]})}),Ke(Ze,{flexDirection:"column",children:e.map((o,n)=>{let i=o.startsWith("[ERR]");return Ke(bt,{color:i?"red":void 0,children:i?o.slice(6):o},n)})}),Ke(Ze,{marginTop:1,children:Ke(bt,{color:"yellow",children:"\u23F3 Running..."})})]})}import{Box as Ae,Text as we}from"ink";import{Box as Gn,Text as ce}from"ink";import{Fragment as jn,jsx as Ie,jsxs as et}from"react/jsx-runtime";function Pt({command:e,index:t,isSelected:o}){return et(Gn,{children:[Ie(ce,{color:o?"cyan":"gray",bold:o,children:o?"> ":" "}),et(ce,{color:o?"cyan":"blue",bold:o,children:["[",t+1,"]"]}),Ie(ce,{children:" "}),et(ce,{color:o?"white":"gray",bold:o,children:["/",e.name]}),Ie(ce,{children:" "}),Ie(ce,{dimColor:!o,children:e.description}),e.shortcut?et(jn,{children:[Ie(ce,{children:" "}),Ie(ce,{dimColor:!0,color:"yellow",children:e.shortcut})]}):null]})}import{jsx as te,jsxs as so}from"react/jsx-runtime";function It({query:e,filteredCommands:t,selectedIndex:o,visible:n}){return n?so(Ae,{flexDirection:"column",borderStyle:"round",borderColor:"blue",paddingX:1,marginTop:1,children:[so(Ae,{children:[te(we,{color:"blue",bold:!0,children:"/"}),te(we,{color:"white",children:e}),te(we,{color:"cyan",children:"_"})]}),te(Ae,{marginY:0,children:te(we,{dimColor:!0,children:"\u2500".repeat(50)})}),t.length>0?te(Ae,{flexDirection:"column",children:t.slice(0,9).map((i,s)=>te(Pt,{command:i,index:s,isSelected:s===o},i.name))}):te(Ae,{children:te(we,{dimColor:!0,children:"No matching commands"})}),te(Ae,{marginTop:1,children:te(we,{dimColor:!0,children:"[Enter] Select [1-9] Quick select [Esc] Close"})})]}):null}import{Box as ue,Text as Te}from"ink";import Ys from"chalk";function qn(e){let t=[],o=e.split(/(\s+)/);for(let n of o)if(n){if(/^\s+$/.test(n)){t.push({type:"default",value:n});continue}if(/^[|><&;]+$/.test(n)||n==="&&"||n==="||"){t.push({type:"pipe",value:n});continue}if(/^-{1,2}[\w-]+=?/.test(n)){t.push({type:"flag",value:n});continue}if(/^\$[\w{}]+/.test(n)){t.push({type:"variable",value:n});continue}if(/^["'].*["']$/.test(n)){t.push({type:"string",value:n});continue}if(n.includes("/")||n.includes("\\")){t.push({type:"path",value:n});continue}if(to.includes(n.toLowerCase())){t.push({type:"keyword",value:n});continue}t.push({type:"default",value:n})}return t}function io(e){return qn(e).map(o=>{switch(o.type){case"keyword":return{text:o.value,color:"cyan",bold:!0};case"flag":return{text:o.value,color:"yellow"};case"string":return{text:o.value,color:"green"};case"pipe":return{text:o.value,color:"magenta"};case"path":return{text:o.value,color:"blue"};case"variable":return{text:o.value,color:"cyan"};default:return{text:o.value}}})}import{jsx as X,jsxs as Ue}from"react/jsx-runtime";function ao({command:e}){let t=io(e);return X(Te,{children:t.map((o,n)=>X(Te,{color:o.color,bold:o.bold,children:o.text},n))})}function lo({proposal:e,showExplanation:t=!1}){return Ue(ue,{flexDirection:"column",children:[X(ue,{borderStyle:"round",borderColor:"gray",paddingX:2,paddingY:1,children:X(ao,{command:e.command})}),t&&e.explanation&&X(ue,{marginTop:1,paddingX:1,children:X(Te,{dimColor:!0,children:e.explanation})})]})}function Xn({command:e,index:t,selected:o=!1}){return Ue(ue,{children:[Ue(Te,{color:o?"cyan":"blue",bold:o,children:["[",t+1,"]"]}),X(Te,{children:" "}),X(ao,{command:e})]})}function co({proposals:e,selectedIndex:t=-1}){return Ue(ue,{flexDirection:"column",marginY:1,children:[X(ue,{marginBottom:1,children:X(Te,{bold:!0,children:"Alternative commands:"})}),e.map((o,n)=>X(ue,{marginBottom:1,children:X(Xn,{command:o.command,index:n,selected:n===t})},n)),X(ue,{marginTop:1,children:Ue(Te,{dimColor:!0,children:["Press 1-",e.length," to select, or [5] Cancel"]})})]})}import{Box as He,Text as oe}from"ink";import{Fragment as Wn,jsx as se,jsxs as Se}from"react/jsx-runtime";function At({hasApiKey:e,storageMethod:t,storageDescription:o,isSecure:n,maskedKey:i,isSectionActive:s,focusedIndex:a}){return Se(He,{flexDirection:"column",children:[Se(He,{children:[se(oe,{dimColor:!0,children:"Status: "}),se(oe,{color:e?"green":"red",children:e?"Configured":"Not configured"}),e?Se(Wn,{children:[se(oe,{dimColor:!0,children:" ("}),se(oe,{color:n?"green":"yellow",children:o}),se(oe,{dimColor:!0,children:")"})]}):null]}),i?Se(He,{children:[se(oe,{dimColor:!0,children:"Key: "}),se(oe,{color:"gray",children:i})]}):null,Se(He,{marginTop:1,children:[se(oe,{color:s&&a===0?"cyan":"gray",bold:s&&a===0,children:s&&a===0?"> ":" "}),Se(oe,{color:s&&a===0?"cyan":"blue",children:["[",e?"Change API Key":"Set API Key","]"]})]}),e?Se(He,{children:[se(oe,{color:s&&a===1?"cyan":"gray",bold:s&&a===1,children:s&&a===1?"> ":" "}),se(oe,{color:s&&a===1?"red":"gray",children:"[Remove API Key]"})]}):null]})}import{Box as ie,Text as Ee}from"ink";import{Box as tt,Text as wt}from"ink";import{jsx as Fe,jsxs as uo}from"react/jsx-runtime";function Re({title:e,isActive:t,children:o}){return uo(tt,{flexDirection:"column",marginBottom:1,children:[uo(tt,{children:[Fe(wt,{color:t?"cyan":"white",bold:!0,children:e}),t?Fe(wt,{color:"cyan",children:" *"}):null]}),Fe(tt,{children:Fe(wt,{dimColor:!0,children:"\u2500".repeat(50)})}),Fe(tt,{flexDirection:"column",paddingLeft:0,children:o})]})}import{Box as po,Text as $e}from"ink";import{Fragment as Qn,jsx as Oe,jsxs as mo}from"react/jsx-runtime";function Rt({options:e,selectedValue:t,focusedIndex:o,isSectionActive:n}){return Oe(po,{flexDirection:"column",children:e.map((i,s)=>{let a=i.id===t,c=n&&s===o;return mo(po,{children:[Oe($e,{color:c?"cyan":"gray",bold:c,children:c?"> ":" "}),Oe($e,{color:a?"green":c?"white":"gray",children:a?"(*) ":"( ) "}),Oe($e,{color:c?"white":"gray",bold:a,children:i.name}),i.description?mo(Qn,{children:[Oe($e,{dimColor:!0,children:" - "}),Oe($e,{dimColor:!0,children:i.description})]}):null]},i.id)})})}import{Box as Vn,Text as ot}from"ink";import{jsx as nt,jsxs as zn}from"react/jsx-runtime";function Be({label:e,value:t,isSelected:o}){return zn(Vn,{children:[nt(ot,{color:o?"cyan":"gray",bold:o,children:o?"> ":" "}),nt(ot,{color:t?"green":"gray",children:t?"[x]":"[ ]"}),nt(ot,{children:" "}),nt(ot,{color:o?"white":"gray",children:e})]})}import{jsx as K,jsxs as pe}from"react/jsx-runtime";var fo=["api-key","model","toggles","about"];function Ot({visible:e,activeSection:t,sectionItemIndex:o,config:n,hasApiKey:i,storageInfo:s,maskedKey:a,toggles:c}){if(!e)return null;let g=fo.indexOf(t);return pe(ie,{flexDirection:"column",borderStyle:"round",borderColor:"blue",paddingX:2,paddingY:1,children:[pe(ie,{justifyContent:"space-between",marginBottom:1,children:[K(ie,{children:K(Ee,{color:"cyan",bold:!0,children:"Settings"})}),K(ie,{children:K(Ee,{dimColor:!0,children:"[Esc] Close [Tab] Section [Enter] Select"})})]}),K(Re,{title:"API Key",isActive:t==="api-key",children:K(At,{hasApiKey:i,storageMethod:s.method,storageDescription:s.description,isSecure:s.secure,maskedKey:a,isSectionActive:t==="api-key",focusedIndex:o})}),K(Re,{title:"Model",isActive:t==="model",children:K(Rt,{options:yt,selectedValue:n.model,focusedIndex:o,isSectionActive:t==="model"})}),pe(Re,{title:"Options",isActive:t==="toggles",children:[K(Be,{label:"Context (pass history to AI)",value:c.contextEnabled,isSelected:t==="toggles"&&o===0}),K(Be,{label:"Show explanations",value:c.showExplanations,isSelected:t==="toggles"&&o===1}),K(Be,{label:"Syntax highlighting",value:c.syntaxHighlighting,isSelected:t==="toggles"&&o===2}),K(Be,{label:"Simple mode",value:c.simpleMode,isSelected:t==="toggles"&&o===3})]}),K(Re,{title:"About",isActive:t==="about",children:pe(ie,{flexDirection:"column",children:[pe(ie,{children:[K(Ee,{dimColor:!0,children:"Version: "}),pe(Ee,{children:["CLI AI v",ee]})]}),pe(ie,{children:[K(Ee,{dimColor:!0,children:"Storage: "}),K(Ee,{color:s.secure?"green":"yellow",children:s.description})]})]})}),K(ie,{marginTop:1,justifyContent:"center",children:fo.map((m,y)=>K(ie,{marginX:1,children:pe(Ee,{color:y===g?"cyan":"gray",children:[y===g?"[":" ",y+1,y===g?"]":" "]})},m))})]})}import{Box as D,Text as Y}from"ink";import{jsx as P,jsxs as W}from"react/jsx-runtime";var Jn=[{key:"/",description:"Open command palette"},{key:"Enter",description:"Submit query"},{key:"Ctrl+D",description:"Exit (when input is empty)"},{key:"O",description:"Toggle output expansion (when input is empty)"}],Zn=[{key:"1 / Enter",description:"Execute command"},{key:"2",description:"Copy to clipboard"},{key:"3",description:"Edit command"},{key:"4",description:"Show alternatives"},{key:"5 / Esc",description:"Cancel"},{key:"?",description:"Explain command"},{key:"O",description:"Toggle output"}],er=[{key:"Up/Down",description:"Navigate commands"},{key:"Enter",description:"Select command"},{key:"Esc",description:"Close palette"},{key:"1-9",description:"Quick select"}],tr=[{key:"Tab",description:"Next section"},{key:"Shift+Tab",description:"Previous section"},{key:"Up/Down",description:"Navigate items"},{key:"Enter/Space",description:"Toggle/Select"},{key:"Esc",description:"Close panel"}];function rt({title:e,shortcuts:t}){return W(D,{flexDirection:"column",marginBottom:1,children:[P(Y,{color:"yellow",bold:!0,children:e}),t.map(o=>W(D,{children:[P(D,{width:16,children:P(Y,{color:"cyan",children:o.key})}),P(Y,{dimColor:!0,children:o.description})]},o.key))]})}function Bt({visible:e}){return e?W(D,{flexDirection:"column",borderStyle:"round",borderColor:"blue",paddingX:2,paddingY:1,children:[W(D,{justifyContent:"space-between",marginBottom:1,children:[P(D,{children:W(Y,{color:"cyan",bold:!0,children:["Help - ",Ce," v",ee]})}),P(D,{children:P(Y,{dimColor:!0,children:"[Esc] Close"})})]}),P(D,{marginBottom:1,children:P(Y,{children:"Natural language to shell command translator. Describe what you want in plain English and get executable commands."})}),W(D,{children:[W(D,{flexDirection:"column",marginRight:4,children:[P(rt,{title:"Input Mode",shortcuts:Jn}),P(rt,{title:"Command Palette",shortcuts:er})]}),W(D,{flexDirection:"column",children:[P(rt,{title:"Proposal Mode",shortcuts:Zn}),P(rt,{title:"Config Panel",shortcuts:tr})]})]}),W(D,{flexDirection:"column",marginTop:1,children:[P(Y,{color:"yellow",bold:!0,children:"Available Commands"}),W(D,{children:[P(D,{width:16,children:P(Y,{color:"cyan",children:"/config"})}),P(Y,{dimColor:!0,children:"Open settings panel"})]}),W(D,{children:[P(D,{width:16,children:P(Y,{color:"cyan",children:"/help"})}),P(Y,{dimColor:!0,children:"Show this help"})]}),W(D,{children:[P(D,{width:16,children:P(Y,{color:"cyan",children:"/clear"})}),P(Y,{dimColor:!0,children:"Clear command history"})]}),W(D,{children:[P(D,{width:16,children:P(Y,{color:"cyan",children:"/exit"})}),P(Y,{dimColor:!0,children:"Exit application"})]})]})]}):null}import{Box as st,Text as Ge}from"ink";import{Text as or}from"ink";import Ye from"chalk";import{useMemo as go}from"react";import{jsx as rr}from"react/jsx-runtime";var Nt=Ye.inverse(" ");function xo({value:e,cursorOffset:t,placeholder:o="",isDisabled:n=!1}){let i=go(()=>n?o?Ye.dim(o):"":o&&o.length>0?Ye.inverse(o[0])+Ye.dim(o.slice(1)):Nt,[n,o]),s=go(()=>{if(n)return e;let a=0,c=e.length>0?"":Nt;for(let g of e)c+=a===t?Ye.inverse(g):g,a++;return e.length>0&&t===e.length&&(c+=Nt),c},[n,e,t]);return rr(or,{children:e.length>0?s:i})}var nr={value:"",cursorOffset:0};function yo(e=""){return{value:e,cursorOffset:e.length}}function Co(e,t){switch(t.type){case"insert":return{value:e.value.slice(0,e.cursorOffset)+t.text+e.value.slice(e.cursorOffset),cursorOffset:e.cursorOffset+t.text.length};case"delete":{if(e.cursorOffset===0)return e;let o=e.cursorOffset-1;return{value:e.value.slice(0,o)+e.value.slice(o+1),cursorOffset:o}}case"move-left":return{...e,cursorOffset:Math.max(0,e.cursorOffset-1)};case"move-right":return{...e,cursorOffset:Math.min(e.value.length,e.cursorOffset+1)};case"clear":return nr;case"set":return{value:t.value,cursorOffset:t.value.length};default:return e}}import{jsx as Ne,jsxs as it}from"react/jsx-runtime";function ho({textState:e,placeholder:t="Describe what you want to do...",disabled:o=!1,hasHistory:n=!1,visible:i=!0}){return i?o?it(st,{children:[Ne(Ge,{dimColor:!0,children:"> "}),Ne(Ge,{dimColor:!0,children:e.value||"..."})]}):it(st,{flexDirection:"column",children:[it(st,{children:[Ne(Ge,{color:"green",bold:!0,children:"> "}),Ne(xo,{value:e.value,cursorOffset:e.cursorOffset,placeholder:t,isDisabled:o})]}),n&&Ne(st,{marginTop:1,children:it(Ge,{dimColor:!0,children:[Ne(Ge,{color:"blue",children:"[O]"})," Toggle output"]})})]}):null}import{Box as je,Text as ne}from"ink";import{jsx as de,jsxs as me}from"react/jsx-runtime";var sr=[{key:"1",label:"Execute"},{key:"2",label:"Copy"},{key:"3",label:"Edit"},{key:"4",label:"Alternatives"},{key:"5",label:"Cancel"}];function To({focusedIndex:e,showExplain:t=!0,visible:o=!0}){return o?me(je,{flexDirection:"column",marginTop:1,children:[de(je,{flexDirection:"row",gap:1,children:sr.map((n,i)=>{let s=i===e;return me(je,{children:[me(ne,{color:s?"cyan":"blue",bold:s,inverse:s,children:["[",n.key,"]"]}),me(ne,{color:s?"cyan":void 0,bold:s,children:[" ",n.label]})]},n.key)})}),t&&de(je,{marginTop:1,children:me(ne,{dimColor:!0,children:[de(ne,{color:"blue",children:"[?]"})," Explain"," ",de(ne,{color:"blue",children:"[O]"})," Toggle output"," ",de(ne,{dimColor:!0,children:"| \u2190\u2192 Navigate, Enter Select"})]})})]}):null}function So({count:e,focusedIndex:t,visible:o=!0}){return o?de(je,{children:me(ne,{dimColor:!0,children:["Press ",me(ne,{color:"blue",children:["1-",e]})," or ",de(ne,{color:"blue",children:"\u2191\u2193"})," to select,"," ",de(ne,{color:"blue",children:"[5]"})," Cancel",t>=0&&me(ne,{color:"cyan",children:[" (focused: ",t+1,")"]})]})}):null}import{Box as Dt,Text as ir}from"ink";import{Spinner as ar}from"@inkjs/ui";import{jsx as Lt,jsxs as Eo}from"react/jsx-runtime";function kt({query:e,label:t="Thinking..."}){return Eo(Dt,{flexDirection:"column",marginY:1,children:[Lt(Dt,{children:Lt(ar,{label:t})}),e&&Lt(Dt,{marginTop:1,children:Eo(ir,{dimColor:!0,children:["Query: ",e]})})]})}import{Box as Q,Text as H}from"ink";import{homedir as lr,userInfo as cr}from"os";import{jsx as U,jsxs as Z}from"react/jsx-runtime";var ur=[" \u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E "," \u2502 \u25B6 _ \u2502 "," \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F "];function vo({shell:e,cwd:t,model:o}){let n=cr().username||"user",i=t.replace(lr(),"~"),s=o||"claude-sonnet-4-5";return Z(Q,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:2,paddingY:1,marginBottom:1,children:[Z(Q,{marginBottom:1,children:[U(H,{color:"cyan",bold:!0,children:Ce}),Z(H,{dimColor:!0,children:[" v",ee]})]}),Z(Q,{children:[Z(Q,{flexDirection:"column",marginRight:4,children:[Z(Q,{marginBottom:1,children:[U(H,{children:"Welcome, "}),U(H,{color:"yellow",bold:!0,children:n}),U(H,{children:"!"})]}),U(Q,{flexDirection:"column",children:ur.map((a,c)=>U(H,{color:"cyan",children:a},c))}),Z(Q,{marginTop:1,flexDirection:"column",children:[Z(Q,{children:[U(H,{dimColor:!0,children:"Shell: "}),U(H,{color:"green",children:e})]}),Z(Q,{children:[U(H,{dimColor:!0,children:"Path: "}),U(H,{children:i})]})]})]}),Z(Q,{flexDirection:"column",borderStyle:"single",borderColor:"gray",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,paddingLeft:2,children:[U(Q,{marginBottom:1,children:U(H,{color:"yellow",bold:!0,children:"Quick Start"})}),Z(Q,{flexDirection:"column",children:[U(H,{dimColor:!0,children:"Describe what you want in natural language:"}),U(H,{color:"gray",italic:!0,children:' "list all files modified today"'}),U(H,{color:"gray",italic:!0,children:' "find large files over 100MB"'}),U(H,{color:"gray",italic:!0,children:' "show git status"'})]}),Z(Q,{marginTop:1,flexDirection:"column",children:[U(H,{dimColor:!0,children:"Model: "}),U(H,{color:"magenta",children:s.split("-").slice(0,2).join(" ")})]})]})]})]})}import{useCallback as dt,useRef as Uo,useState as Nr}from"react";import{readdirSync as pr,statSync as mr}from"fs";import{join as dr,relative as fr}from"path";var gr=new Set(["node_modules",".git",".next","dist","build","__pycache__",".venv","venv",".idea",".vscode","coverage",".cache",".npm",".yarn",".pnpm",".turbo",".nuxt",".output","target","vendor",".angular",".svelte-kit"]),xr=new Set([".DS_Store","Thumbs.db",".gitignore",".npmrc",".yarnrc","pnpm-lock.yaml","package-lock.json","yarn.lock"]),yr=3,Cr=20;function bo(e,t=0){if(t>=yr)return[];try{let o=pr(e),n=[],i=0;for(let s of o){if(i>=Cr){n.push({name:`... (${o.length-i} more)`,isDirectory:!1});break}if(s.startsWith(".")&&!s.startsWith(".env")||xr.has(s))continue;let a=dr(e,s);try{if(mr(a).isDirectory()){if(gr.has(s))continue;let g=bo(a,t+1);n.push({name:s,isDirectory:!0,children:g.length>0?g:void 0})}else n.push({name:s,isDirectory:!1});i++}catch{continue}}return n}catch{return[]}}function Po(e,t=""){let o=[];return e.forEach((n,i)=>{let s=i===e.length-1,a=s?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",c=s?" ":"\u2502 ";n.isDirectory?(o.push(`${t}${a}${n.name}/`),n.children&&n.children.length>0&&o.push(Po(n.children,`${t}${c}`))):o.push(`${t}${a}${n.name}`)}),o.join(`
3
3
  `)}function Io(e){let t=bo(e);return t.length===0?"(empty or inaccessible directory)":`${fr(process.cwd(),e)||"."}/
4
4
  ${Po(t)}`}function hr(e){let t=e.toLowerCase();for(let o of Zt)if(t.includes(o.toLowerCase()))return"high";for(let o of eo)if(t.includes(o.toLowerCase()))return"medium";return"low"}function _t(e,t){let o=hr(t),n={low:0,medium:1,high:2};return n[e]>=n[o]?e:o}import ct from"conf";import{createHash as Tr}from"crypto";import{existsSync as Ro,unlinkSync as Ao}from"fs";import{hostname as Sr,userInfo as Er}from"os";import{homedir as vr}from"os";import{join as Oo}from"path";var br="cli-ai-v3-encryption-key";function Pr(){let e=`${Sr()}-${Er().username}-cli-ai-v3-salt`;return Tr("sha256").update(e).digest("hex").slice(0,32)}var Xe=Oo(vr(),Vt),ut=Oo(Xe,"config.json");function Ir(){if(!Ro(ut))return null;try{let e=new ct({projectName:"cli-ai",cwd:Xe,encryptionKey:br}),t=e.get("apiKey"),o=e.get("config");if(t||o)return{apiKey:t,config:o}}catch{}return null}function Ar(){let e=Pr(),t=Ir();if(t){try{Ao(ut)}catch{}let o=new ct({projectName:"cli-ai",cwd:Xe,encryptionKey:e});return t.apiKey&&o.set("apiKey",t.apiKey),t.config&&o.set("config",t.config),o}try{return new ct({projectName:"cli-ai",cwd:Xe,encryptionKey:e})}catch{try{Ro(ut)&&Ao(ut)}catch{}return new ct({projectName:"cli-ai",cwd:Xe,encryptionKey:e})}}var fe=Ar(),at=null,wo=!1,qe=null,lt=null;function wr(){if(wo)return at;wo=!0;try{return at=Hn("@napi-rs/keyring"),at}catch{return at=null,null}}function pt(){if(lt===!1)return null;if(qe===null){let e=wr();if(!e)return lt=!1,null;try{qe=new e.Entry(Wt,Qt),qe.getPassword(),lt=!0}catch{return lt=!1,qe=null,null}}return qe}function ge(){let e=process.env.ANTHROPIC_API_KEY;if(e)return e;let t=pt();if(t)try{let o=t.getPassword();if(o)return o}catch{}return fe.get("apiKey")??null}function mt(e){try{let t=pt();if(t)try{return t.setPassword(e),fe.delete("apiKey"),{success:!0,data:void 0}}catch{}return fe.set("apiKey",e),{success:!0,data:void 0}}catch(t){return{success:!1,error:t instanceof Error?t:new Error(String(t))}}}function Bo(){try{let e=pt();if(e)try{e.deleteCredential()}catch{}return fe.delete("apiKey"),{success:!0,data:void 0}}catch(e){return{success:!1,error:e instanceof Error?e:new Error(String(e))}}}function Mt(){let e=ge();return e!==null&&e.length>0}function De(){let e=fe.get("config")??{};return{...he,...e}}function We(e){let t=fe.get("config")??{};fe.set("config",{...t,...e})}function No(e){return e.startsWith("sk-ant-")&&e.length>20}function Do(){if(process.env.ANTHROPIC_API_KEY)return{method:"env",secure:!1,description:"Environment variable (visible to other processes)"};let e=pt();if(e)try{if(e.getPassword())return{method:"keyring",secure:!0,description:"System keyring (OS-protected)"}}catch{}return fe.get("apiKey")?{method:"encrypted-file",secure:!1,description:"Encrypted file (machine-specific key)"}:{method:"none",secure:!1,description:"Not configured"}}import Kt from"@anthropic-ai/sdk";function Lo(e){return`You are a CLI command generator for ${e}.
5
5
  You translate natural language requests into shell commands.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fmdzc/cli-ai",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "CLI AI Assistant v3 - Natural language to shell commands with persistent REPL session",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,7 +39,10 @@
39
39
  "link:global": "pnpm build && pnpm link --global",
40
40
  "unlink:global": "pnpm unlink --global",
41
41
  "uninstall": "node scripts/uninstall.js",
42
- "uninstall:force": "node scripts/uninstall.js --force"
42
+ "uninstall:force": "node scripts/uninstall.js --force",
43
+ "version:set": "node scripts/version.js",
44
+ "tag": "node scripts/tag.js",
45
+ "tag:repush": "node scripts/tag.js --repush"
43
46
  },
44
47
  "keywords": [
45
48
  "cli",
@@ -63,7 +66,8 @@
63
66
  "url": "https://github.com/fmdz387/cli-ai/issues"
64
67
  },
65
68
  "publishConfig": {
66
- "access": "public"
69
+ "access": "public",
70
+ "provenance": true
67
71
  },
68
72
  "contributors": [
69
73
  {