yaicli 0.0.7__tar.gz → 0.0.8__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.7 → yaicli-0.0.8}/PKG-INFO +6 -1
- {yaicli-0.0.7 → yaicli-0.0.8}/README.md +5 -0
- {yaicli-0.0.7 → yaicli-0.0.8}/pyproject.toml +6 -6
- {yaicli-0.0.7 → yaicli-0.0.8}/yaicli.py +67 -7
- yaicli-0.0.7/.bumpversion.cfg +0 -8
- yaicli-0.0.7/CHANGELOG.md +0 -87
- yaicli-0.0.7/Justfile +0 -33
- yaicli-0.0.7/README_wind.md +0 -195
- yaicli-0.0.7/cliff.toml +0 -90
- yaicli-0.0.7/debug.py +0 -22
- yaicli-0.0.7/r.txt +0 -29
- yaicli-0.0.7/refactor.py +0 -364
- yaicli-0.0.7/shellai_optimized.py +0 -549
- yaicli-0.0.7/shellai_simple.py +0 -497
- yaicli-0.0.7/test_yaicli.py +0 -52
- yaicli-0.0.7/uv.lock +0 -419
- {yaicli-0.0.7 → yaicli-0.0.8}/.gitignore +0 -0
- {yaicli-0.0.7 → yaicli-0.0.8}/LICENSE +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: yaicli
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.8
|
4
4
|
Summary: A simple CLI tool to interact with LLM
|
5
5
|
Project-URL: Homepage, https://github.com/belingud/yaicli
|
6
6
|
Project-URL: Repository, https://github.com/belingud/yaicli
|
@@ -223,6 +223,11 @@ Description-Content-Type: text/markdown
|
|
223
223
|
|
224
224
|
# YAICLI - Your AI Command Line Interface
|
225
225
|
|
226
|
+
[](https://pypi.org/project/yaicli/)
|
227
|
+

|
228
|
+

|
229
|
+

|
230
|
+
|
226
231
|
YAICLI is a powerful command-line AI assistant tool that enables you to interact with Large Language Models (LLMs) like ChatGPT's gpt-4o through your terminal. It offers multiple operation modes for everyday conversations, generating and executing shell commands, and one-shot quick queries.
|
227
232
|
|
228
233
|
> [!WARNING]
|
@@ -1,5 +1,10 @@
|
|
1
1
|
# YAICLI - Your AI Command Line Interface
|
2
2
|
|
3
|
+
[](https://pypi.org/project/yaicli/)
|
4
|
+

|
5
|
+

|
6
|
+

|
7
|
+
|
3
8
|
YAICLI is a powerful command-line AI assistant tool that enables you to interact with Large Language Models (LLMs) like ChatGPT's gpt-4o through your terminal. It offers multiple operation modes for everyday conversations, generating and executing shell commands, and one-shot quick queries.
|
4
9
|
|
5
10
|
> [!WARNING]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "yaicli"
|
3
|
-
version = "0.0.
|
3
|
+
version = "0.0.8"
|
4
4
|
description = "A simple CLI tool to interact with LLM"
|
5
5
|
authors = [{ name = "belingud", email = "im.victor@qq.com" }]
|
6
6
|
readme = "README.md"
|
@@ -49,11 +49,7 @@ ai = "yaicli:app"
|
|
49
49
|
resolution = "highest"
|
50
50
|
|
51
51
|
[dependency-groups]
|
52
|
-
dev = [
|
53
|
-
"bump2version>=1.0.1",
|
54
|
-
"pytest>=8.3.5",
|
55
|
-
"ruff>=0.11.2",
|
56
|
-
]
|
52
|
+
dev = ["bump2version>=1.0.1", "pytest>=8.3.5", "ruff>=0.11.2"]
|
57
53
|
|
58
54
|
[tool.ruff]
|
59
55
|
line-length = 120
|
@@ -64,3 +60,7 @@ ignore = ["E501"]
|
|
64
60
|
[build-system]
|
65
61
|
requires = ["hatchling>=1.18.0"]
|
66
62
|
build-backend = "hatchling.build"
|
63
|
+
|
64
|
+
[tool.hatch.build]
|
65
|
+
exclude = ["test_*.py", "tests/*", ".gitignore"]
|
66
|
+
include = ["yaicli.py", "pyproject.toml"]
|
@@ -71,6 +71,7 @@ class CasePreservingConfigParser(configparser.RawConfigParser):
|
|
71
71
|
class CLI:
|
72
72
|
CONFIG_PATH = Path("~/.config/yaicli/config.ini").expanduser()
|
73
73
|
DEFAULT_CONFIG_INI = """[core]
|
74
|
+
PROVIDER=openai
|
74
75
|
BASE_URL=https://api.openai.com/v1
|
75
76
|
API_KEY=
|
76
77
|
MODEL=gpt-4o
|
@@ -166,6 +167,50 @@ STREAM=true"""
|
|
166
167
|
return "powershell.exe" if is_powershell else "cmd.exe"
|
167
168
|
return basename(getenv("SHELL", "/bin/sh"))
|
168
169
|
|
170
|
+
def _filter_command(self, command: str) -> Optional[str]:
|
171
|
+
"""Filter out unwanted characters from command
|
172
|
+
|
173
|
+
The LLM may return commands in markdown format with code blocks.
|
174
|
+
This method removes markdown formatting from the command.
|
175
|
+
It handles various formats including:
|
176
|
+
- Commands surrounded by ``` (plain code blocks)
|
177
|
+
- Commands with language specifiers like ```bash, ```zsh, etc.
|
178
|
+
- Commands with specific examples like ```ls -al```
|
179
|
+
|
180
|
+
example:
|
181
|
+
```bash\nls -la\n``` ==> ls -al
|
182
|
+
```zsh\nls -la\n``` ==> ls -al
|
183
|
+
```ls -al``` ==> ls -al
|
184
|
+
ls -al ==> ls -al
|
185
|
+
```\ncd /tmp\nls -la\n``` ==> cd /tmp\nls -la
|
186
|
+
```bash\ncd /tmp\nls -la\n``` ==> cd /tmp\nls -la
|
187
|
+
"""
|
188
|
+
if not command or not command.strip():
|
189
|
+
return ""
|
190
|
+
|
191
|
+
# Handle commands that are already without code blocks
|
192
|
+
if "```" not in command:
|
193
|
+
return command.strip()
|
194
|
+
|
195
|
+
# Handle code blocks with or without language specifiers
|
196
|
+
lines = command.strip().split("\n")
|
197
|
+
|
198
|
+
# Check if it's a single-line code block like ```ls -al```
|
199
|
+
if len(lines) == 1 and lines[0].startswith("```") and lines[0].endswith("```"):
|
200
|
+
return lines[0][3:-3].strip()
|
201
|
+
|
202
|
+
# Handle multi-line code blocks
|
203
|
+
if lines[0].startswith("```"):
|
204
|
+
# Remove the opening ``` line (with or without language specifier)
|
205
|
+
content_lines = lines[1:]
|
206
|
+
|
207
|
+
# If the last line is a closing ```, remove it
|
208
|
+
if content_lines and content_lines[-1].strip() == "```":
|
209
|
+
content_lines = content_lines[:-1]
|
210
|
+
|
211
|
+
# Join the remaining lines and strip any extra whitespace
|
212
|
+
return "\n".join(line.strip() for line in content_lines if line.strip())
|
213
|
+
|
169
214
|
def post(self, message: list[dict[str, str]]) -> requests.Response:
|
170
215
|
"""Post message to LLM API and return response"""
|
171
216
|
url = self.config.get("BASE_URL", "").rstrip("/") + "/" + self.config.get("COMPLETION_PATH", "").lstrip("/")
|
@@ -238,6 +283,11 @@ STREAM=true"""
|
|
238
283
|
qmark = ""
|
239
284
|
return [("class:qmark", qmark), ("class:question", " {} ".format(">"))]
|
240
285
|
|
286
|
+
def _check_history_len(self) -> None:
|
287
|
+
"""Check history length and remove oldest messages if necessary"""
|
288
|
+
if len(self.history) > self.max_history_length:
|
289
|
+
self.history = self.history[-self.max_history_length :]
|
290
|
+
|
241
291
|
def _run_repl(self) -> None:
|
242
292
|
"""Run REPL loop, handling user input and generating responses, saving history, and executing commands"""
|
243
293
|
# Show REPL instructions
|
@@ -280,27 +330,33 @@ STREAM=true"""
|
|
280
330
|
# Get response from LLM
|
281
331
|
response = self.post(message)
|
282
332
|
self.console.print("\n[bold green]Assistant:[/bold green]")
|
283
|
-
|
333
|
+
try:
|
334
|
+
content = self._print(response, stream=self.config["STREAM"] == "true")
|
335
|
+
except Exception as e:
|
336
|
+
self.console.print(f"[red]Error: {e}[/red]")
|
337
|
+
continue
|
284
338
|
|
285
339
|
# Add user input and assistant response to history
|
286
340
|
self.history.append({"role": "user", "content": user_input})
|
287
341
|
self.history.append({"role": "assistant", "content": content})
|
288
342
|
|
289
343
|
# Trim history if needed
|
290
|
-
|
291
|
-
self.history = self.history[-self.max_history_length * 2 :]
|
344
|
+
self._check_history_len()
|
292
345
|
|
293
346
|
# Handle command execution in exec mode
|
294
347
|
if self.current_mode == EXEC_MODE:
|
348
|
+
content = self._filter_command(content)
|
349
|
+
if not content:
|
350
|
+
self.console.print("[bold red]No command generated[/bold red]")
|
351
|
+
continue
|
295
352
|
self.console.print(f"\n[bold magenta]Generated command:[/bold magenta] {content}")
|
296
353
|
if Confirm.ask("Execute this command?", default=False):
|
297
|
-
|
298
|
-
if returncode != 0:
|
299
|
-
self.console.print(f"[bold red]Command failed with return code {returncode}[/bold red]")
|
354
|
+
subprocess.call(content, shell=True)
|
300
355
|
|
301
356
|
self.console.print("[bold green]Exiting...[/bold green]")
|
302
357
|
|
303
358
|
def run(self, chat: bool, shell: bool, prompt: str) -> None:
|
359
|
+
"""Run the CLI"""
|
304
360
|
self.load_config()
|
305
361
|
if not self.config.get("API_KEY"):
|
306
362
|
self.console.print("[bold red]API key not set[/bold red]")
|
@@ -330,10 +386,14 @@ STREAM=true"""
|
|
330
386
|
# Get response from LLM
|
331
387
|
response = self.post(message)
|
332
388
|
self.console.print("\n[bold green]Assistant:[/bold green]")
|
333
|
-
content = self._print(response, stream=
|
389
|
+
content = self._print(response, stream=self.config["STREAM"] == "true")
|
334
390
|
|
335
391
|
# Handle shell mode execution
|
336
392
|
if shell:
|
393
|
+
content = self._filter_command(content)
|
394
|
+
if not content:
|
395
|
+
self.console.print("[bold red]No command generated[/bold red]")
|
396
|
+
return
|
337
397
|
self.console.print(f"\n[bold magenta]Generated command:[/bold magenta] {content}")
|
338
398
|
if Confirm.ask("Execute this command?", default=False):
|
339
399
|
returncode = subprocess.call(content, shell=True)
|
yaicli-0.0.7/.bumpversion.cfg
DELETED
yaicli-0.0.7/CHANGELOG.md
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
|
2
|
-
---
|
3
|
-
## [0.0.7](https://github.com/belingud/yaicli/compare/v0.0.6..v0.0.7) - 2025-04-04
|
4
|
-
|
5
|
-
### 🚜 Refactor
|
6
|
-
|
7
|
-
- simplify CLI structure and improve code maintainability - ([4eed7d8](https://github.com/belingud/yaicli/commit/4eed7d85abf3a75766e015533682beb2998f8c3e)) - Belingud
|
8
|
-
|
9
|
-
### ⚙️ Miscellaneous Tasks
|
10
|
-
|
11
|
-
- update yaicli version to 0.0.6 and CHANGELOG - ([563a468](https://github.com/belingud/yaicli/commit/563a4681c1a2e96a0609f2bd9822410567c4d0d0)) - Belingud
|
12
|
-
|
13
|
-
|
14
|
-
---
|
15
|
-
## [0.0.6](https://github.com/belingud/yaicli/compare/v0.0.5..v0.0.6) - 2025-04-03
|
16
|
-
|
17
|
-
### 🚜 Refactor
|
18
|
-
|
19
|
-
- update environment variable names and remove max_tokens - ([3abba5f](https://github.com/belingud/yaicli/commit/3abba5fe189b3de0d005907e159a46291a69636f)) - Belingud
|
20
|
-
- simplify config handling and remove DEFAULT_MODE - ([3439eda](https://github.com/belingud/yaicli/commit/3439eda71fdb24816de9c61c7ccee389e32c53b2)) - Belingud
|
21
|
-
|
22
|
-
### ⚙️ Miscellaneous Tasks
|
23
|
-
|
24
|
-
- update CHANGELOG and uv.lock for version 0.0.5 - ([d5abef4](https://github.com/belingud/yaicli/commit/d5abef4b602355fe472abaecd07f2701e8a38e4b)) - Belingud
|
25
|
-
|
26
|
-
|
27
|
-
---
|
28
|
-
## [0.0.5](https://github.com/belingud/yaicli/compare/v0.0.4..v0.0.5) - 2025-04-02
|
29
|
-
|
30
|
-
### 🚜 Refactor
|
31
|
-
|
32
|
-
- rename ShellAI to YAICLI and update related tests - ([2284297](https://github.com/belingud/yaicli/commit/2284297d018851abcb74f01064554b00df821301)) - Belingud
|
33
|
-
|
34
|
-
### 📚 Documentation
|
35
|
-
|
36
|
-
- update README with detailed project information and usage instructions - ([c71d50c](https://github.com/belingud/yaicli/commit/c71d50c9d232c47a3cdbe035d03c1f4a0dbbe7d2)) - Belingud
|
37
|
-
|
38
|
-
### ⚙️ Miscellaneous Tasks
|
39
|
-
|
40
|
-
- update yaicli version to 0.0.4 - ([03cdedb](https://github.com/belingud/yaicli/commit/03cdedb38465adcf4fc10d4379b2d939daf22d9d)) - Belingud
|
41
|
-
|
42
|
-
|
43
|
-
---
|
44
|
-
## [0.0.4](https://github.com/belingud/yaicli/compare/v0.0.3..v0.0.4) - 2025-04-02
|
45
|
-
|
46
|
-
### 🚜 Refactor
|
47
|
-
|
48
|
-
- simplify multi-line statements for better readability - ([4870bb7](https://github.com/belingud/yaicli/commit/4870bb7460682791ca79bbe2bcc0cef94bf51c26)) - Belingud
|
49
|
-
- rename ShellAI to yaicli and improve CLI help handling - ([dad0905](https://github.com/belingud/yaicli/commit/dad090540a7c1f8c8b30e3c688643a76e504b0c0)) - Belingud
|
50
|
-
|
51
|
-
### ⚙️ Miscellaneous Tasks
|
52
|
-
|
53
|
-
- update yaicli version to 0.0.3 - ([a689a02](https://github.com/belingud/yaicli/commit/a689a02b1c5e0cb278484267ef71f5f3acec8203)) - Belingud
|
54
|
-
|
55
|
-
|
56
|
-
---
|
57
|
-
## [0.0.3](https://github.com/belingud/yaicli/compare/v0.0.2..v0.0.3) - 2025-04-02
|
58
|
-
|
59
|
-
### 🚜 Refactor
|
60
|
-
|
61
|
-
- **(changelog)** switch from git log to git cliff for changelog generation - ([242a51d](https://github.com/belingud/yaicli/commit/242a51d93a25675041a7fe19c4a0db1c7c12a663)) - Belingud
|
62
|
-
- update CLI assistant description and error handling - ([1a8bcdc](https://github.com/belingud/yaicli/commit/1a8bcdc86c72a75259d266291bc9e5350fc81f61)) - Belingud
|
63
|
-
- fix spacing in clean target and simplify build target - ([2a1050e](https://github.com/belingud/yaicli/commit/2a1050e7a9eea8753c164553b13796e5510b7965)) - Belingud
|
64
|
-
|
65
|
-
|
66
|
-
---
|
67
|
-
## [0.0.2] - 2025-04-02
|
68
|
-
|
69
|
-
### ⛰️ Features
|
70
|
-
|
71
|
-
- enhance OS detection and LLM API request handling - ([8c00de0](https://github.com/belingud/yaicli/commit/8c00de099e1c75fedcdd33e9d7e0443818538059)) - Belingud
|
72
|
-
- add new dependencies and configurable API paths - ([3be3f67](https://github.com/belingud/yaicli/commit/3be3f67b3bd9645a9a8c9909be0e5542612c1c71)) - Belingud
|
73
|
-
|
74
|
-
### 🚜 Refactor
|
75
|
-
|
76
|
-
- **(config)** migrate config from JSON to INI format and enhance error handling - ([f556872](https://github.com/belingud/yaicli/commit/f556872fdb521adf8e20da6498fdaac26998a5b7)) - Belingud
|
77
|
-
- update config path to reflect project name change - ([e6bf761](https://github.com/belingud/yaicli/commit/e6bf761aa0fae20b643848c586c6dc55d6f324fb)) - Belingud
|
78
|
-
- rename project from llmcli to yaicli and update related files - ([cdb5a97](https://github.com/belingud/yaicli/commit/cdb5a97d06c9f042c1c8731c8f11a4a7284783f0)) - Belingud
|
79
|
-
- rename project from shellai to llmcli and update related files - ([db4ecb8](https://github.com/belingud/yaicli/commit/db4ecb85236b72fd7536c99b21d210037c09889e)) - Belingud
|
80
|
-
- reorganize imports and improve code readability - ([0f52c05](https://github.com/belingud/yaicli/commit/0f52c05918d177d4623ff2f07aff2fc2e3aa9e91)) - Belingud
|
81
|
-
- migrate llmcli to class-based ShellAI implementation - ([2509cba](https://github.com/belingud/yaicli/commit/2509cba5cad7c8626f794d88d971fff7eea9a404)) - Belingud
|
82
|
-
|
83
|
-
### Build
|
84
|
-
|
85
|
-
- add bump2version for version management - ([de287f1](https://github.com/belingud/yaicli/commit/de287f1262eae64ae5fd0cb634dea93762a17282)) - Belingud
|
86
|
-
|
87
|
-
|
yaicli-0.0.7/Justfile
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# Justfile for Python project management
|
2
|
-
|
3
|
-
# Clean build artifacts
|
4
|
-
clean:
|
5
|
-
@echo "Cleaning build artifacts..."
|
6
|
-
@rm -rf build/ dist/ *.egg-info/
|
7
|
-
@echo "Cleaning cache files..."
|
8
|
-
@find . -type d -name "__pycache__" -exec rm -rf {} +
|
9
|
-
@echo "Cleaning test artifacts..."
|
10
|
-
@rm -rf .pytest_cache/
|
11
|
-
@echo "Cleaning pdm build artifacts..."
|
12
|
-
@rm -rf .pdm_build/
|
13
|
-
|
14
|
-
# Run tests with pytest
|
15
|
-
test:
|
16
|
-
@echo "Running tests..."
|
17
|
-
@pytest
|
18
|
-
|
19
|
-
# Build package with hatch (runs clean first)
|
20
|
-
build:
|
21
|
-
@echo "Building package..."
|
22
|
-
@rm -rf dist/
|
23
|
-
@uv build
|
24
|
-
|
25
|
-
# Install package in editable mode
|
26
|
-
install:
|
27
|
-
@echo "Installing packages..."
|
28
|
-
@uv sync
|
29
|
-
|
30
|
-
# Generate changelog from git log
|
31
|
-
changelog:
|
32
|
-
@echo "Generating changelog..."
|
33
|
-
@git cliff -l --prepend CHANGELOG.md
|
yaicli-0.0.7/README_wind.md
DELETED
@@ -1,195 +0,0 @@
|
|
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*
|
yaicli-0.0.7/cliff.toml
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
# git-cliff ~ configuration file
|
2
|
-
# https://git-cliff.org/docs/configuration
|
3
|
-
|
4
|
-
[changelog]
|
5
|
-
# template for the changelog header
|
6
|
-
header = """"""
|
7
|
-
# template for the changelog body
|
8
|
-
# https://keats.github.io/tera/docs/#introduction
|
9
|
-
body = """
|
10
|
-
---
|
11
|
-
{% if version %}\
|
12
|
-
{% if previous.version %}\
|
13
|
-
## [{{ version | trim_start_matches(pat="v") }}]($REPO/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
|
14
|
-
{% else %}\
|
15
|
-
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
|
16
|
-
{% endif %}\
|
17
|
-
{% else %}\
|
18
|
-
## [unreleased]
|
19
|
-
{% endif %}\
|
20
|
-
{% for group, commits in commits | group_by(attribute="group") %}
|
21
|
-
### {{ group | striptags | trim | upper_first }}
|
22
|
-
{% for commit in commits
|
23
|
-
| filter(attribute="scope")
|
24
|
-
| sort(attribute="scope") %}
|
25
|
-
- **({{commit.scope}})**{% if commit.breaking %} [**breaking**]{% endif %} \
|
26
|
-
{{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }}
|
27
|
-
{%- endfor -%}
|
28
|
-
{% raw %}\n{% endraw %}\
|
29
|
-
{%- for commit in commits %}
|
30
|
-
{%- if commit.scope -%}
|
31
|
-
{% else -%}
|
32
|
-
- {% if commit.breaking %} [**breaking**]{% endif %}\
|
33
|
-
{{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }}
|
34
|
-
{% endif -%}
|
35
|
-
{% endfor -%}
|
36
|
-
{% endfor %}\n
|
37
|
-
"""
|
38
|
-
# template for the changelog footer
|
39
|
-
footer = """"""
|
40
|
-
# remove the leading and trailing whitespace from the templates
|
41
|
-
trim = true
|
42
|
-
# postprocessors
|
43
|
-
postprocessors = [
|
44
|
-
{ pattern = '\$REPO', replace = "https://github.com/belingud/yaicli" }, # replace repository URL
|
45
|
-
]
|
46
|
-
|
47
|
-
[git]
|
48
|
-
# parse the commits based on https://www.conventionalcommits.org
|
49
|
-
conventional_commits = true
|
50
|
-
# filter out the commits that are not conventional
|
51
|
-
filter_unconventional = true
|
52
|
-
# process each line of a commit as an individual commit
|
53
|
-
split_commits = false
|
54
|
-
# regex for preprocessing the commit messages
|
55
|
-
commit_preprocessors = [
|
56
|
-
# { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers
|
57
|
-
]
|
58
|
-
# regex for parsing and grouping commits
|
59
|
-
commit_parsers = [
|
60
|
-
{ message = "^feat", group = "<!-- 0 -->⛰️ Features" },
|
61
|
-
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
|
62
|
-
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
|
63
|
-
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
|
64
|
-
{ message = "^refactor\\(clippy\\)", skip = true },
|
65
|
-
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
|
66
|
-
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
|
67
|
-
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
|
68
|
-
{ message = "^chore\\(release\\): prepare for", skip = true },
|
69
|
-
{ message = "^chore\\(deps.*\\)", skip = true },
|
70
|
-
{ message = "^chore\\(pr\\)", skip = true },
|
71
|
-
{ message = "^chore\\(pull\\)", skip = true },
|
72
|
-
{ message = "^chore\\(npm\\).*yarn\\.lock", skip = true },
|
73
|
-
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
|
74
|
-
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
|
75
|
-
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
|
76
|
-
]
|
77
|
-
# protect breaking changes from being skipped due to matching a skipping commit_parser
|
78
|
-
protect_breaking_commits = false
|
79
|
-
# filter out the commits that are not matched by commit parsers
|
80
|
-
filter_commits = false
|
81
|
-
# regex for matching git tags
|
82
|
-
tag_pattern = "v[0-9].*"
|
83
|
-
# regex for skipping tags
|
84
|
-
skip_tags = "beta|alpha"
|
85
|
-
# regex for ignoring tags
|
86
|
-
ignore_tags = "rc|beta"
|
87
|
-
# sort the tags topologically
|
88
|
-
topo_order = false
|
89
|
-
# sort the commits inside sections by oldest/newest order
|
90
|
-
sort_commits = "newest"
|
yaicli-0.0.7/debug.py
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import typer
|
2
|
-
|
3
|
-
app = typer.Typer()
|
4
|
-
|
5
|
-
|
6
|
-
@app.command()
|
7
|
-
def run(name: str):
|
8
|
-
"""
|
9
|
-
这是 run 命令的简短描述。
|
10
|
-
|
11
|
-
这是详细的帮助信息,同样可以写多行。
|
12
|
-
这个命令会运行主要的任务。
|
13
|
-
"""
|
14
|
-
print(f"正在为 {name} 运行任务...")
|
15
|
-
|
16
|
-
|
17
|
-
# 注意:如果这是唯一的命令,它的帮助信息会比较突出。
|
18
|
-
# 如果还有其他命令,这只是 'run' 命令的帮助。
|
19
|
-
# 应用的总体帮助需要通过 Typer(help=...) 设置。
|
20
|
-
|
21
|
-
if __name__ == "__main__":
|
22
|
-
app()
|
yaicli-0.0.7/r.txt
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
annotated-types==0.7.0
|
2
|
-
bump2version==1.0.1
|
3
|
-
certifi==2025.1.31
|
4
|
-
charset-normalizer==3.4.1
|
5
|
-
click==8.1.8
|
6
|
-
idna==3.10
|
7
|
-
iniconfig==2.1.0
|
8
|
-
jmespath==1.0.1
|
9
|
-
markdown-it-py==3.0.0
|
10
|
-
mdurl==0.1.2
|
11
|
-
packaging==24.2
|
12
|
-
pluggy==1.5.0
|
13
|
-
prompt-toolkit==3.0.50
|
14
|
-
pydantic==2.11.1
|
15
|
-
pydantic-core==2.33.0
|
16
|
-
pydantic-settings==2.8.1
|
17
|
-
pygments==2.19.1
|
18
|
-
pytest==8.3.5
|
19
|
-
python-dotenv==1.1.0
|
20
|
-
requests==2.32.3
|
21
|
-
rich==13.9.4
|
22
|
-
ruff==0.11.2
|
23
|
-
-e file:///Users/vic/Documents/codes/git/llmcli
|
24
|
-
shellingham==1.5.4
|
25
|
-
typer==0.15.2
|
26
|
-
typing-extensions==4.13.0
|
27
|
-
typing-inspection==0.4.0
|
28
|
-
urllib3==2.3.0
|
29
|
-
wcwidth==0.2.13
|