yaicli 0.0.3__tar.gz → 0.0.5__tar.gz
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.
- {yaicli-0.0.3 → yaicli-0.0.5}/.bumpversion.cfg +1 -1
- {yaicli-0.0.3 → yaicli-0.0.5}/CHANGELOG.md +13 -0
- yaicli-0.0.5/PKG-INFO +244 -0
- yaicli-0.0.5/README.md +230 -0
- yaicli-0.0.5/README_wind.md +195 -0
- yaicli-0.0.5/debug.py +22 -0
- {yaicli-0.0.3 → yaicli-0.0.5}/pyproject.toml +2 -2
- yaicli-0.0.5/test_yaicli.py +52 -0
- {yaicli-0.0.3 → yaicli-0.0.5}/uv.lock +3 -36
- {yaicli-0.0.3 → yaicli-0.0.5}/yaicli.py +208 -64
- yaicli-0.0.3/PKG-INFO +0 -15
- yaicli-0.0.3/README.md +0 -1
- yaicli-0.0.3/debug.py +0 -12
- yaicli-0.0.3/tests +0 -52
- {yaicli-0.0.3 → yaicli-0.0.5}/.gitignore +0 -0
- {yaicli-0.0.3 → yaicli-0.0.5}/Justfile +0 -0
- {yaicli-0.0.3 → yaicli-0.0.5}/LICENSE +0 -0
- {yaicli-0.0.3 → yaicli-0.0.5}/cliff.toml +0 -0
- {yaicli-0.0.3 → yaicli-0.0.5}/r.txt +0 -0
- {yaicli-0.0.3 → yaicli-0.0.5}/shellai_optimized.py +0 -0
- {yaicli-0.0.3 → yaicli-0.0.5}/shellai_simple.py +0 -0
@@ -1,4 +1,17 @@
|
|
1
1
|
|
2
|
+
---
|
3
|
+
## [0.0.4](https://github.com/belingud/yaicli/compare/v0.0.3..v0.0.4) - 2025-04-02
|
4
|
+
|
5
|
+
### 🚜 Refactor
|
6
|
+
|
7
|
+
- simplify multi-line statements for better readability - ([4870bb7](https://github.com/belingud/yaicli/commit/4870bb7460682791ca79bbe2bcc0cef94bf51c26)) - Belingud
|
8
|
+
- rename ShellAI to yaicli and improve CLI help handling - ([dad0905](https://github.com/belingud/yaicli/commit/dad090540a7c1f8c8b30e3c688643a76e504b0c0)) - Belingud
|
9
|
+
|
10
|
+
### ⚙️ Miscellaneous Tasks
|
11
|
+
|
12
|
+
- update yaicli version to 0.0.3 - ([a689a02](https://github.com/belingud/yaicli/commit/a689a02b1c5e0cb278484267ef71f5f3acec8203)) - Belingud
|
13
|
+
|
14
|
+
|
2
15
|
---
|
3
16
|
## [0.0.3](https://github.com/belingud/yaicli/compare/v0.0.2..v0.0.3) - 2025-04-02
|
4
17
|
|
yaicli-0.0.5/PKG-INFO
ADDED
@@ -0,0 +1,244 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: yaicli
|
3
|
+
Version: 0.0.5
|
4
|
+
Summary: A simple CLI tool to interact with LLM
|
5
|
+
License-File: LICENSE
|
6
|
+
Requires-Python: >=3.9
|
7
|
+
Requires-Dist: distro>=1.9.0
|
8
|
+
Requires-Dist: jmespath>=1.0.1
|
9
|
+
Requires-Dist: prompt-toolkit>=3.0.50
|
10
|
+
Requires-Dist: requests>=2.32.3
|
11
|
+
Requires-Dist: rich>=13.9.4
|
12
|
+
Requires-Dist: typer>=0.15.2
|
13
|
+
Description-Content-Type: text/markdown
|
14
|
+
|
15
|
+
# YAICLI - Your AI Command Line Interface
|
16
|
+
|
17
|
+
YAICLI is a powerful command-line AI assistant tool that enables you to interact with Large Language Models (LLMs) through your terminal. It offers multiple operation modes for everyday conversations, generating and executing shell commands, and one-shot quick queries.
|
18
|
+
|
19
|
+
## Features
|
20
|
+
|
21
|
+
- **Multiple Operation Modes**:
|
22
|
+
- **Chat Mode (💬)**: Interactive conversation with the AI assistant
|
23
|
+
- **Execute Mode (🚀)**: Generate and execute shell commands specific to your OS and shell
|
24
|
+
- **Temp Mode**: Quick queries without entering interactive mode
|
25
|
+
|
26
|
+
- **Smart Environment Detection**:
|
27
|
+
- Automatically detects your operating system and shell
|
28
|
+
- Customizes responses and commands for your specific environment
|
29
|
+
|
30
|
+
- **Rich Terminal Interface**:
|
31
|
+
- Markdown rendering for formatted responses
|
32
|
+
- Streaming responses for real-time feedback
|
33
|
+
- Color-coded output for better readability
|
34
|
+
|
35
|
+
- **Configurable**:
|
36
|
+
- Customizable API endpoints
|
37
|
+
- Support for different LLM providers
|
38
|
+
- Adjustable response parameters
|
39
|
+
|
40
|
+
- **Keyboard Shortcuts**:
|
41
|
+
- Tab to switch between Chat and Execute modes
|
42
|
+
|
43
|
+
## Installation
|
44
|
+
|
45
|
+
### Prerequisites
|
46
|
+
|
47
|
+
- Python 3.9 or higher
|
48
|
+
- pip (Python package manager)
|
49
|
+
|
50
|
+
### Install from PyPI
|
51
|
+
|
52
|
+
```bash
|
53
|
+
# Install by pip
|
54
|
+
pip install yaicli
|
55
|
+
|
56
|
+
# Install by pipx
|
57
|
+
pipx install yaicli
|
58
|
+
|
59
|
+
# Install by uv
|
60
|
+
uv tool install yaicli
|
61
|
+
```
|
62
|
+
|
63
|
+
### Install from Source
|
64
|
+
|
65
|
+
```bash
|
66
|
+
git clone https://github.com/yourusername/yaicli.git
|
67
|
+
cd yaicli
|
68
|
+
pip install .
|
69
|
+
```
|
70
|
+
|
71
|
+
## Configuration
|
72
|
+
|
73
|
+
On first run, YAICLI will create a default configuration file at `~/.config/yaicli/config.ini`. You'll need to edit this file to add your API key and customize other settings.
|
74
|
+
|
75
|
+
Just run `ai`, and it will create the config file for you. Then you can edit it to add your api key.
|
76
|
+
|
77
|
+
### Configuration File
|
78
|
+
|
79
|
+
```ini
|
80
|
+
[core]
|
81
|
+
BASE_URL=https://api.openai.com/v1
|
82
|
+
API_KEY=your_api_key_here
|
83
|
+
MODEL=gpt-4o
|
84
|
+
|
85
|
+
# default run mode, default: temp
|
86
|
+
# chat: interactive chat mode
|
87
|
+
# exec: shell command generation mode
|
88
|
+
# temp: one-shot mode
|
89
|
+
DEFAULT_MODE=temp
|
90
|
+
|
91
|
+
# auto detect shell and os
|
92
|
+
SHELL_NAME=auto
|
93
|
+
OS_NAME=auto
|
94
|
+
|
95
|
+
# if you want to use custom completions path, you can set it here
|
96
|
+
COMPLETION_PATH=/chat/completions
|
97
|
+
# if you want to use custom answer path, you can set it here
|
98
|
+
ANSWER_PATH=choices[0].message.content
|
99
|
+
|
100
|
+
# true: streaming response
|
101
|
+
# false: non-streaming response
|
102
|
+
STREAM=true
|
103
|
+
```
|
104
|
+
|
105
|
+
### Configuration Options
|
106
|
+
|
107
|
+
- **BASE_URL**: API endpoint URL (default: OpenAI API)
|
108
|
+
- **API_KEY**: Your API key for the LLM provider
|
109
|
+
- **MODEL**: The model to use (e.g., gpt-4o, gpt-3.5-turbo), default: gpt-4o
|
110
|
+
- **DEFAULT_MODE**: Default operation mode (chat, exec, or temp), default: temp
|
111
|
+
- **SHELL_NAME**: Shell to use (auto for automatic detection), default: auto
|
112
|
+
- **OS_NAME**: OS to use (auto for automatic detection), default: auto
|
113
|
+
- **COMPLETION_PATH**: Path for completions endpoint, default: /chat/completions
|
114
|
+
- **ANSWER_PATH**: Json path expression to extract answer from response, default: choices[0].message.content
|
115
|
+
- **STREAM**: Enable/disable streaming responses
|
116
|
+
|
117
|
+
## Usage
|
118
|
+
|
119
|
+
### Basic Usage
|
120
|
+
|
121
|
+
```bash
|
122
|
+
# One-shot mode
|
123
|
+
ai "What is the capital of France?"
|
124
|
+
|
125
|
+
# Chat mode
|
126
|
+
ai --chat
|
127
|
+
|
128
|
+
# Shell command generation mode
|
129
|
+
ai --shell "Create a backup of my Documents folder"
|
130
|
+
|
131
|
+
# Verbose mode for debugging
|
132
|
+
ai --verbose "Explain quantum computing"
|
133
|
+
```
|
134
|
+
|
135
|
+
### Command Line Options
|
136
|
+
|
137
|
+
- `<PROMPT>`: Argument
|
138
|
+
- `--verbose` or `-V`: Show verbose information
|
139
|
+
- `--chat` or `-c`: Start in chat mode
|
140
|
+
- `--shell` or `-s`: Generate and execute shell command
|
141
|
+
- `--install-completion`: Install completion for the current shell
|
142
|
+
- `--show-completion`: Show completion for the current shell, to copy it or customize the installation
|
143
|
+
- `--help` or `-h`: Show this message and exit
|
144
|
+
|
145
|
+
```bash
|
146
|
+
ai -h
|
147
|
+
|
148
|
+
Usage: ai [OPTIONS] [PROMPT]
|
149
|
+
|
150
|
+
yaicli. Your AI interface in cli.
|
151
|
+
|
152
|
+
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
153
|
+
│ prompt [PROMPT] The prompt send to the LLM │
|
154
|
+
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
155
|
+
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
156
|
+
│ --verbose -V Show verbose information │
|
157
|
+
│ --chat -c Start in chat mode │
|
158
|
+
│ --shell -s Generate and execute shell command │
|
159
|
+
│ --install-completion Install completion for the current shell. │
|
160
|
+
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
|
161
|
+
│ --help -h Show this message and exit. │
|
162
|
+
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
163
|
+
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
### Interactive Mode
|
168
|
+
|
169
|
+
In interactive mode (chat or shell), you can:
|
170
|
+
- Type your queries and get responses
|
171
|
+
- Use `Tab` to switch between Chat and Execute modes
|
172
|
+
- Type 'exit' or 'quit' to exit
|
173
|
+
|
174
|
+
### Shell Command Generation
|
175
|
+
|
176
|
+
In Execute mode:
|
177
|
+
1. Enter your request in natural language
|
178
|
+
2. YAICLI will generate an appropriate shell command
|
179
|
+
3. Review the command
|
180
|
+
4. Confirm to execute or reject
|
181
|
+
|
182
|
+
## Examples
|
183
|
+
|
184
|
+
### Chat Mode Example
|
185
|
+
|
186
|
+
```bash
|
187
|
+
$ ai --chat
|
188
|
+
💬 > Tell me about the solar system
|
189
|
+
|
190
|
+
Assistant:
|
191
|
+
Certainly! Here’s a brief overview of the solar system:
|
192
|
+
|
193
|
+
• Sun: The central star of the solar system, providing light and energy.
|
194
|
+
• Planets:
|
195
|
+
• Mercury: Closest to the Sun, smallest planet.
|
196
|
+
• Venus: Second planet, known for its thick atmosphere and high surface temperature.
|
197
|
+
• Earth: Third planet, the only known planet to support life.
|
198
|
+
• Mars: Fourth planet, often called the "Red Planet" due to its reddish appearance.
|
199
|
+
• Jupiter: Largest planet, a gas giant with many moons.
|
200
|
+
• Saturn: Known for its prominent ring system, also a gas giant.
|
201
|
+
• Uranus: An ice giant, known for its unique axial tilt.
|
202
|
+
• Neptune: Another ice giant, known for its deep blue color.
|
203
|
+
• Dwarf Planets:
|
204
|
+
• Pluto: Once considered the ninth planet, now classified as
|
205
|
+
|
206
|
+
💬 >
|
207
|
+
```
|
208
|
+
|
209
|
+
### Execute Mode Example
|
210
|
+
|
211
|
+
```bash
|
212
|
+
$ ai --shell "Find all PDF files in my Downloads folder"
|
213
|
+
|
214
|
+
Generated command: find ~/Downloads -type f -name "*.pdf"
|
215
|
+
Execute this command? [y/n]: y
|
216
|
+
|
217
|
+
Executing command: find ~/Downloads -type f -name "*.pdf"
|
218
|
+
|
219
|
+
/Users/username/Downloads/document1.pdf
|
220
|
+
/Users/username/Downloads/report.pdf
|
221
|
+
...
|
222
|
+
```
|
223
|
+
|
224
|
+
## Technical Implementation
|
225
|
+
|
226
|
+
YAICLI is built using several Python libraries:
|
227
|
+
|
228
|
+
- **Typer**: Provides the command-line interface
|
229
|
+
- **Rich**: Provides terminal content formatting and beautiful display
|
230
|
+
- **prompt_toolkit**: Provides interactive command-line input experience
|
231
|
+
- **requests**: Handles API requests
|
232
|
+
- **jmespath**: Parses JSON responses
|
233
|
+
|
234
|
+
## Contributing
|
235
|
+
|
236
|
+
Contributions of code, issue reports, or feature suggestions are welcome.
|
237
|
+
|
238
|
+
## License
|
239
|
+
|
240
|
+
[Apache License 2.0](LICENSE)
|
241
|
+
|
242
|
+
---
|
243
|
+
|
244
|
+
*YAICLI - Making your terminal smarter*
|
yaicli-0.0.5/README.md
ADDED
@@ -0,0 +1,230 @@
|
|
1
|
+
# YAICLI - Your AI Command Line Interface
|
2
|
+
|
3
|
+
YAICLI is a powerful command-line AI assistant tool that enables you to interact with Large Language Models (LLMs) through your terminal. It offers multiple operation modes for everyday conversations, generating and executing shell commands, and one-shot quick queries.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- **Multiple Operation Modes**:
|
8
|
+
- **Chat Mode (💬)**: Interactive conversation with the AI assistant
|
9
|
+
- **Execute Mode (🚀)**: Generate and execute shell commands specific to your OS and shell
|
10
|
+
- **Temp Mode**: Quick queries without entering interactive mode
|
11
|
+
|
12
|
+
- **Smart Environment Detection**:
|
13
|
+
- Automatically detects your operating system and shell
|
14
|
+
- Customizes responses and commands for your specific environment
|
15
|
+
|
16
|
+
- **Rich Terminal Interface**:
|
17
|
+
- Markdown rendering for formatted responses
|
18
|
+
- Streaming responses for real-time feedback
|
19
|
+
- Color-coded output for better readability
|
20
|
+
|
21
|
+
- **Configurable**:
|
22
|
+
- Customizable API endpoints
|
23
|
+
- Support for different LLM providers
|
24
|
+
- Adjustable response parameters
|
25
|
+
|
26
|
+
- **Keyboard Shortcuts**:
|
27
|
+
- Tab to switch between Chat and Execute modes
|
28
|
+
|
29
|
+
## Installation
|
30
|
+
|
31
|
+
### Prerequisites
|
32
|
+
|
33
|
+
- Python 3.9 or higher
|
34
|
+
- pip (Python package manager)
|
35
|
+
|
36
|
+
### Install from PyPI
|
37
|
+
|
38
|
+
```bash
|
39
|
+
# Install by pip
|
40
|
+
pip install yaicli
|
41
|
+
|
42
|
+
# Install by pipx
|
43
|
+
pipx install yaicli
|
44
|
+
|
45
|
+
# Install by uv
|
46
|
+
uv tool install yaicli
|
47
|
+
```
|
48
|
+
|
49
|
+
### Install from Source
|
50
|
+
|
51
|
+
```bash
|
52
|
+
git clone https://github.com/yourusername/yaicli.git
|
53
|
+
cd yaicli
|
54
|
+
pip install .
|
55
|
+
```
|
56
|
+
|
57
|
+
## Configuration
|
58
|
+
|
59
|
+
On first run, YAICLI will create a default configuration file at `~/.config/yaicli/config.ini`. You'll need to edit this file to add your API key and customize other settings.
|
60
|
+
|
61
|
+
Just run `ai`, and it will create the config file for you. Then you can edit it to add your api key.
|
62
|
+
|
63
|
+
### Configuration File
|
64
|
+
|
65
|
+
```ini
|
66
|
+
[core]
|
67
|
+
BASE_URL=https://api.openai.com/v1
|
68
|
+
API_KEY=your_api_key_here
|
69
|
+
MODEL=gpt-4o
|
70
|
+
|
71
|
+
# default run mode, default: temp
|
72
|
+
# chat: interactive chat mode
|
73
|
+
# exec: shell command generation mode
|
74
|
+
# temp: one-shot mode
|
75
|
+
DEFAULT_MODE=temp
|
76
|
+
|
77
|
+
# auto detect shell and os
|
78
|
+
SHELL_NAME=auto
|
79
|
+
OS_NAME=auto
|
80
|
+
|
81
|
+
# if you want to use custom completions path, you can set it here
|
82
|
+
COMPLETION_PATH=/chat/completions
|
83
|
+
# if you want to use custom answer path, you can set it here
|
84
|
+
ANSWER_PATH=choices[0].message.content
|
85
|
+
|
86
|
+
# true: streaming response
|
87
|
+
# false: non-streaming response
|
88
|
+
STREAM=true
|
89
|
+
```
|
90
|
+
|
91
|
+
### Configuration Options
|
92
|
+
|
93
|
+
- **BASE_URL**: API endpoint URL (default: OpenAI API)
|
94
|
+
- **API_KEY**: Your API key for the LLM provider
|
95
|
+
- **MODEL**: The model to use (e.g., gpt-4o, gpt-3.5-turbo), default: gpt-4o
|
96
|
+
- **DEFAULT_MODE**: Default operation mode (chat, exec, or temp), default: temp
|
97
|
+
- **SHELL_NAME**: Shell to use (auto for automatic detection), default: auto
|
98
|
+
- **OS_NAME**: OS to use (auto for automatic detection), default: auto
|
99
|
+
- **COMPLETION_PATH**: Path for completions endpoint, default: /chat/completions
|
100
|
+
- **ANSWER_PATH**: Json path expression to extract answer from response, default: choices[0].message.content
|
101
|
+
- **STREAM**: Enable/disable streaming responses
|
102
|
+
|
103
|
+
## Usage
|
104
|
+
|
105
|
+
### Basic Usage
|
106
|
+
|
107
|
+
```bash
|
108
|
+
# One-shot mode
|
109
|
+
ai "What is the capital of France?"
|
110
|
+
|
111
|
+
# Chat mode
|
112
|
+
ai --chat
|
113
|
+
|
114
|
+
# Shell command generation mode
|
115
|
+
ai --shell "Create a backup of my Documents folder"
|
116
|
+
|
117
|
+
# Verbose mode for debugging
|
118
|
+
ai --verbose "Explain quantum computing"
|
119
|
+
```
|
120
|
+
|
121
|
+
### Command Line Options
|
122
|
+
|
123
|
+
- `<PROMPT>`: Argument
|
124
|
+
- `--verbose` or `-V`: Show verbose information
|
125
|
+
- `--chat` or `-c`: Start in chat mode
|
126
|
+
- `--shell` or `-s`: Generate and execute shell command
|
127
|
+
- `--install-completion`: Install completion for the current shell
|
128
|
+
- `--show-completion`: Show completion for the current shell, to copy it or customize the installation
|
129
|
+
- `--help` or `-h`: Show this message and exit
|
130
|
+
|
131
|
+
```bash
|
132
|
+
ai -h
|
133
|
+
|
134
|
+
Usage: ai [OPTIONS] [PROMPT]
|
135
|
+
|
136
|
+
yaicli. Your AI interface in cli.
|
137
|
+
|
138
|
+
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
139
|
+
│ prompt [PROMPT] The prompt send to the LLM │
|
140
|
+
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
141
|
+
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
142
|
+
│ --verbose -V Show verbose information │
|
143
|
+
│ --chat -c Start in chat mode │
|
144
|
+
│ --shell -s Generate and execute shell command │
|
145
|
+
│ --install-completion Install completion for the current shell. │
|
146
|
+
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
|
147
|
+
│ --help -h Show this message and exit. │
|
148
|
+
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
149
|
+
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
### Interactive Mode
|
154
|
+
|
155
|
+
In interactive mode (chat or shell), you can:
|
156
|
+
- Type your queries and get responses
|
157
|
+
- Use `Tab` to switch between Chat and Execute modes
|
158
|
+
- Type 'exit' or 'quit' to exit
|
159
|
+
|
160
|
+
### Shell Command Generation
|
161
|
+
|
162
|
+
In Execute mode:
|
163
|
+
1. Enter your request in natural language
|
164
|
+
2. YAICLI will generate an appropriate shell command
|
165
|
+
3. Review the command
|
166
|
+
4. Confirm to execute or reject
|
167
|
+
|
168
|
+
## Examples
|
169
|
+
|
170
|
+
### Chat Mode Example
|
171
|
+
|
172
|
+
```bash
|
173
|
+
$ ai --chat
|
174
|
+
💬 > Tell me about the solar system
|
175
|
+
|
176
|
+
Assistant:
|
177
|
+
Certainly! Here’s a brief overview of the solar system:
|
178
|
+
|
179
|
+
• Sun: The central star of the solar system, providing light and energy.
|
180
|
+
• Planets:
|
181
|
+
• Mercury: Closest to the Sun, smallest planet.
|
182
|
+
• Venus: Second planet, known for its thick atmosphere and high surface temperature.
|
183
|
+
• Earth: Third planet, the only known planet to support life.
|
184
|
+
• Mars: Fourth planet, often called the "Red Planet" due to its reddish appearance.
|
185
|
+
• Jupiter: Largest planet, a gas giant with many moons.
|
186
|
+
• Saturn: Known for its prominent ring system, also a gas giant.
|
187
|
+
• Uranus: An ice giant, known for its unique axial tilt.
|
188
|
+
• Neptune: Another ice giant, known for its deep blue color.
|
189
|
+
• Dwarf Planets:
|
190
|
+
• Pluto: Once considered the ninth planet, now classified as
|
191
|
+
|
192
|
+
💬 >
|
193
|
+
```
|
194
|
+
|
195
|
+
### Execute Mode Example
|
196
|
+
|
197
|
+
```bash
|
198
|
+
$ ai --shell "Find all PDF files in my Downloads folder"
|
199
|
+
|
200
|
+
Generated command: find ~/Downloads -type f -name "*.pdf"
|
201
|
+
Execute this command? [y/n]: y
|
202
|
+
|
203
|
+
Executing command: find ~/Downloads -type f -name "*.pdf"
|
204
|
+
|
205
|
+
/Users/username/Downloads/document1.pdf
|
206
|
+
/Users/username/Downloads/report.pdf
|
207
|
+
...
|
208
|
+
```
|
209
|
+
|
210
|
+
## Technical Implementation
|
211
|
+
|
212
|
+
YAICLI is built using several Python libraries:
|
213
|
+
|
214
|
+
- **Typer**: Provides the command-line interface
|
215
|
+
- **Rich**: Provides terminal content formatting and beautiful display
|
216
|
+
- **prompt_toolkit**: Provides interactive command-line input experience
|
217
|
+
- **requests**: Handles API requests
|
218
|
+
- **jmespath**: Parses JSON responses
|
219
|
+
|
220
|
+
## Contributing
|
221
|
+
|
222
|
+
Contributions of code, issue reports, or feature suggestions are welcome.
|
223
|
+
|
224
|
+
## License
|
225
|
+
|
226
|
+
[Apache License 2.0](LICENSE)
|
227
|
+
|
228
|
+
---
|
229
|
+
|
230
|
+
*YAICLI - Making your terminal smarter*
|
@@ -0,0 +1,195 @@
|
|
1
|
+
# YAICLI - Your AI Command Line Interface
|
2
|
+
|
3
|
+
YAICLI is a powerful command-line AI assistant tool that allows you to interact with Large Language Models (LLMs) through your terminal. It provides multiple operation modes for daily conversations, generating and executing shell commands, and quick one-time queries.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
### Multiple Operation Modes
|
8
|
+
|
9
|
+
1. **Chat Mode**
|
10
|
+
- Interactive conversation interface
|
11
|
+
- Markdown-formatted responses
|
12
|
+
- Streaming output display
|
13
|
+
|
14
|
+
2. **Execute Mode**
|
15
|
+
- Automatically generates shell commands from natural language descriptions
|
16
|
+
- Detects current operating system and shell environment to generate appropriate commands
|
17
|
+
- Automatically filters unnecessary Markdown formatting from command output
|
18
|
+
- Confirmation mechanism before execution for safety
|
19
|
+
|
20
|
+
3. **Temp Mode (One-shot)**
|
21
|
+
- Quick single queries without maintaining a session
|
22
|
+
|
23
|
+
### Intelligent Environment Detection
|
24
|
+
|
25
|
+
- Automatically detects operating system (Windows, MacOS, Linux and its distributions)
|
26
|
+
- Automatically detects shell type (bash, zsh, PowerShell, cmd, etc.)
|
27
|
+
- Customizes prompts and commands based on your environment
|
28
|
+
|
29
|
+
### User Experience
|
30
|
+
|
31
|
+
- Streaming response display for real-time AI output viewing
|
32
|
+
- Keyboard shortcuts (e.g., Ctrl+I to switch modes)
|
33
|
+
- Command confirmation mechanism to prevent accidental execution
|
34
|
+
|
35
|
+
## Requirements
|
36
|
+
|
37
|
+
- Python 3.9+
|
38
|
+
- Supported operating systems: Windows, MacOS, Linux
|
39
|
+
|
40
|
+
## Dependencies
|
41
|
+
|
42
|
+
```
|
43
|
+
configparser
|
44
|
+
json
|
45
|
+
platform
|
46
|
+
subprocess
|
47
|
+
time
|
48
|
+
jmespath
|
49
|
+
requests
|
50
|
+
typer
|
51
|
+
distro
|
52
|
+
prompt_toolkit
|
53
|
+
```
|
54
|
+
|
55
|
+
## Installation
|
56
|
+
|
57
|
+
1. Clone the repository:
|
58
|
+
```bash
|
59
|
+
git clone https://github.com/yourusername/yaicli.git
|
60
|
+
cd yaicli
|
61
|
+
```
|
62
|
+
|
63
|
+
2. Create virtual environment and install dependencies:
|
64
|
+
```bash
|
65
|
+
uv sync
|
66
|
+
```
|
67
|
+
|
68
|
+
|
69
|
+
## Configuration
|
70
|
+
|
71
|
+
The first time you run YAICLI, it will create a default configuration file at `~/.config/yaicli/config.ini`. You'll need to edit this file and add your API key.
|
72
|
+
|
73
|
+
Example configuration file:
|
74
|
+
|
75
|
+
```ini
|
76
|
+
[core]
|
77
|
+
BASE_URL=https://api.openai.com/v1
|
78
|
+
API_KEY=your-api-key-here
|
79
|
+
MODEL=gpt-4o
|
80
|
+
|
81
|
+
# default run mode, default: temp
|
82
|
+
# chat: interactive chat mode
|
83
|
+
# exec: shell command generation mode
|
84
|
+
# temp: one-shot mode
|
85
|
+
DEFAULT_MODE=temp
|
86
|
+
|
87
|
+
# auto detect shell and os
|
88
|
+
SHELL_NAME=auto
|
89
|
+
OS_NAME=auto
|
90
|
+
|
91
|
+
# if you want to use custom completions path, you can set it here
|
92
|
+
COMPLETION_PATH=/chat/completions
|
93
|
+
# if you want to use custom answer path, you can set it here
|
94
|
+
ANSWER_PATH=choices[0].message.content
|
95
|
+
|
96
|
+
# true: streaming response
|
97
|
+
# false: non-streaming response
|
98
|
+
STREAM=true
|
99
|
+
```
|
100
|
+
|
101
|
+
## Usage
|
102
|
+
|
103
|
+
### Basic Usage
|
104
|
+
|
105
|
+
```bash
|
106
|
+
# One-shot mode (default): Send a prompt and get a response
|
107
|
+
ai "How do I check memory usage on a Linux system?"
|
108
|
+
|
109
|
+
# Chat mode: Start an interactive chat session
|
110
|
+
ai --chat
|
111
|
+
|
112
|
+
# Execute mode: Generate and execute shell commands
|
113
|
+
ai --shell "Create a directory named project and create src and docs subdirectories in it"
|
114
|
+
|
115
|
+
# Enable verbose output
|
116
|
+
ai --verbose "Explain how Docker works"
|
117
|
+
```
|
118
|
+
|
119
|
+
### Interactive Commands
|
120
|
+
|
121
|
+
In chat or execute mode:
|
122
|
+
|
123
|
+
- Press `Ctrl+I` to switch between chat and execute modes
|
124
|
+
- Type `exit` or `quit` to exit the application
|
125
|
+
|
126
|
+
### Mode Descriptions
|
127
|
+
|
128
|
+
1. **Chat Mode (--chat)**
|
129
|
+
```bash
|
130
|
+
ai --chat
|
131
|
+
```
|
132
|
+
Starts an interactive session where you can converse with the AI. Responses will be displayed in Markdown format.
|
133
|
+
|
134
|
+
2. **Execute Mode (--shell)**
|
135
|
+
```bash
|
136
|
+
ai --shell "Find all files larger than 100MB"
|
137
|
+
```
|
138
|
+
The AI will generate appropriate shell commands and execute them after your confirmation.
|
139
|
+
|
140
|
+
3. **One-shot Mode (default)**
|
141
|
+
```bash
|
142
|
+
ai "Explain the difference between TCP and UDP"
|
143
|
+
```
|
144
|
+
Sends a single query, provides the response, and exits.
|
145
|
+
|
146
|
+
## Advanced Usage
|
147
|
+
|
148
|
+
### Custom System Recognition
|
149
|
+
|
150
|
+
If you want to specify a particular operating system or shell, you can modify the configuration file:
|
151
|
+
|
152
|
+
```ini
|
153
|
+
[core]
|
154
|
+
# ...other configuration...
|
155
|
+
SHELL_NAME=bash # Force bash shell command syntax
|
156
|
+
OS_NAME=Ubuntu # Force commands targeting Ubuntu
|
157
|
+
```
|
158
|
+
|
159
|
+
### Custom API Endpoint
|
160
|
+
|
161
|
+
YAICLI uses the OpenAI API by default, but you can use compatible APIs by modifying the configuration:
|
162
|
+
|
163
|
+
```ini
|
164
|
+
[core]
|
165
|
+
BASE_URL=https://your-api-endpoint/v1
|
166
|
+
COMPLETION_PATH=/chat/completions
|
167
|
+
ANSWER_PATH=custom.json.path.to.content
|
168
|
+
```
|
169
|
+
|
170
|
+
## Technical Implementation
|
171
|
+
|
172
|
+
YAICLI is built using several Python libraries:
|
173
|
+
|
174
|
+
- **Typer**: Provides the command-line interface
|
175
|
+
- **prompt_toolkit**: Provides interactive command-line input experience
|
176
|
+
- **requests**: Handles API requests
|
177
|
+
- **jmespath**: Parses JSON responses
|
178
|
+
|
179
|
+
## Limitations and Notes
|
180
|
+
|
181
|
+
- Requires a valid OpenAI API key or compatible API
|
182
|
+
- Commands generated in execute mode should be carefully reviewed before execution
|
183
|
+
- API calls may incur charges depending on your service provider and model
|
184
|
+
|
185
|
+
## Contributing
|
186
|
+
|
187
|
+
Contributions of code, issue reports, or feature suggestions are welcome.
|
188
|
+
|
189
|
+
## License
|
190
|
+
|
191
|
+
Apache License 2.0
|
192
|
+
|
193
|
+
---
|
194
|
+
|
195
|
+
*YAICLI - Making your terminal smarter*
|