smart-linux-assistant 0.5.0__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.
- smart_linux_assistant-0.5.0/LICENSE +21 -0
- smart_linux_assistant-0.5.0/PKG-INFO +233 -0
- smart_linux_assistant-0.5.0/README.md +206 -0
- smart_linux_assistant-0.5.0/linux_assistant/__init__.py +11 -0
- smart_linux_assistant-0.5.0/linux_assistant/cli/__init__.py +0 -0
- smart_linux_assistant-0.5.0/linux_assistant/cli/main.py +277 -0
- smart_linux_assistant-0.5.0/linux_assistant/config/__init__.py +0 -0
- smart_linux_assistant-0.5.0/linux_assistant/config/settings.py +65 -0
- smart_linux_assistant-0.5.0/linux_assistant/core/__init__.py +0 -0
- smart_linux_assistant-0.5.0/linux_assistant/exceptions/__init__.py +31 -0
- smart_linux_assistant-0.5.0/linux_assistant/exceptions/base.py +98 -0
- smart_linux_assistant-0.5.0/linux_assistant/models/__init__.py +11 -0
- smart_linux_assistant-0.5.0/linux_assistant/models/command_result.py +51 -0
- smart_linux_assistant-0.5.0/linux_assistant/repositories/__init__.py +0 -0
- smart_linux_assistant-0.5.0/linux_assistant/services/__init__.py +2 -0
- smart_linux_assistant-0.5.0/linux_assistant/services/command_executor.py +109 -0
- smart_linux_assistant-0.5.0/linux_assistant/services/explainer.py +141 -0
- smart_linux_assistant-0.5.0/linux_assistant/services/search.py +77 -0
- smart_linux_assistant-0.5.0/linux_assistant/utils/__init__.py +0 -0
- smart_linux_assistant-0.5.0/linux_assistant/utils/groq_client.py +65 -0
- smart_linux_assistant-0.5.0/linux_assistant/utils/logger.py +54 -0
- smart_linux_assistant-0.5.0/linux_assistant/utils/shell.py +31 -0
- smart_linux_assistant-0.5.0/pyproject.toml +81 -0
- smart_linux_assistant-0.5.0/setup.cfg +4 -0
- smart_linux_assistant-0.5.0/smart_linux_assistant.egg-info/PKG-INFO +233 -0
- smart_linux_assistant-0.5.0/smart_linux_assistant.egg-info/SOURCES.txt +34 -0
- smart_linux_assistant-0.5.0/smart_linux_assistant.egg-info/dependency_links.txt +1 -0
- smart_linux_assistant-0.5.0/smart_linux_assistant.egg-info/entry_points.txt +3 -0
- smart_linux_assistant-0.5.0/smart_linux_assistant.egg-info/requires.txt +2 -0
- smart_linux_assistant-0.5.0/smart_linux_assistant.egg-info/top_level.txt +1 -0
- smart_linux_assistant-0.5.0/tests/test_cli.py +229 -0
- smart_linux_assistant-0.5.0/tests/test_command_executor.py +123 -0
- smart_linux_assistant-0.5.0/tests/test_explainer.py +159 -0
- smart_linux_assistant-0.5.0/tests/test_groq_client.py +34 -0
- smart_linux_assistant-0.5.0/tests/test_search.py +87 -0
- smart_linux_assistant-0.5.0/tests/test_shell.py +33 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shubham Kumar Jha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: smart-linux-assistant
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: An AI-powered Linux productivity assistant for command analysis, troubleshooting, and knowledge management.
|
|
5
|
+
Author: Shubham Kumar Jha
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/shubham-k-jha-dev/smart-linux-assistant
|
|
8
|
+
Project-URL: Repository, https://github.com/shubham-k-jha-dev/smart-linux-assistant
|
|
9
|
+
Project-URL: Issues, https://github.com/shubham-k-jha-dev/smart-linux-assistant/issues
|
|
10
|
+
Keywords: linux,cli,automation,terminal,devops,shell,productivity
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Environment :: Console
|
|
18
|
+
Classifier: Topic :: System :: Systems Administration
|
|
19
|
+
Classifier: Topic :: Utilities
|
|
20
|
+
Classifier: Development Status :: 3 - Alpha
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: typer>=0.12.0
|
|
25
|
+
Requires-Dist: groq>=0.9.0
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# Smart Linux Assistant
|
|
29
|
+
|
|
30
|
+
Smart Linux Assistant is an AI-powered Linux operations assistant that understands natural language, safely executes shell commands, retrieves Linux knowledge, explains errors, and assists users with troubleshooting. The current version implements the core command execution engine and foundational architecture for future AI capabilities.
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+

|
|
34
|
+
[](https://github.com/shubham-k-jha-dev/smart-linux-assistant/actions/workflows/ci.yml)
|
|
35
|
+
|
|
36
|
+
## Project Overview
|
|
37
|
+
|
|
38
|
+
Smart Linux Assistant is a command-line utility that executes shell commands and returns structured outcomes. The tool captures the command, exit code, stdout, stderr, execution timestamp, and duration to make downstream automation and logging straightforward.
|
|
39
|
+
|
|
40
|
+
## System Architecture
|
|
41
|
+
|
|
42
|
+
- CLI (`linux_assistant.cli.main`) accepts user commands and options and delegates execution to `CommandExecutor`.
|
|
43
|
+
- `CommandExecutor` runs shell commands using `subprocess.run` and returns a `CommandResult` dataclass describing the outcome.
|
|
44
|
+
- Centralized logging is provided by `linux_assistant.utils.logger`, writing to `logs/smart_linux_assistant.log` with rotation.
|
|
45
|
+
- Runtime paths and directories are managed by `linux_assistant.config.settings` and can be initialized with `initialize_app_filesystem()`.
|
|
46
|
+
|
|
47
|
+
## Tech Stack
|
|
48
|
+
|
|
49
|
+
- Python 3.11+
|
|
50
|
+
- Typer (CLI)
|
|
51
|
+
- Standard library: `subprocess`, `logging`, `shutil`, `dataclasses`, `pathlib`, `datetime`
|
|
52
|
+
|
|
53
|
+
## Prerequisites
|
|
54
|
+
|
|
55
|
+
1. Python 3.11 or newer.
|
|
56
|
+
2. Optional: a virtual environment tool (`venv`).
|
|
57
|
+
3. No Dockerfile or docker-compose are included in this repository.
|
|
58
|
+
|
|
59
|
+
## Local Setup & Installation
|
|
60
|
+
|
|
61
|
+
1. Clone the repository:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
git clone https://github.com/shubham-k-jha-dev/smart-linux-assistant
|
|
65
|
+
cd smart-linux-assistant
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
2. Create and activate a virtual environment:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Linux/macOS
|
|
72
|
+
python3 -m venv .venv
|
|
73
|
+
source .venv/bin/activate
|
|
74
|
+
|
|
75
|
+
# Windows (PowerShell)
|
|
76
|
+
python -m venv .venv
|
|
77
|
+
.venv\\Scripts\\Activate.ps1
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
3. Install development dependencies:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install -r requirements-dev.txt
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
4. (Optional) Install the package in editable mode to enable the `smart-linux` CLI entrypoint:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install -e .
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
5. (Optional) Ensure runtime directories exist from Python:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from linux_assistant.config.settings import initialize_app_filesystem
|
|
96
|
+
initialize_app_filesystem()
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Environment Variables
|
|
100
|
+
|
|
101
|
+
This project does not require any environment variables for its core CLI functionality. The repository includes an empty `.env.example` placeholder.
|
|
102
|
+
|
|
103
|
+
| Variable | Description | Example |
|
|
104
|
+
|----------|-------------|---------|
|
|
105
|
+
| (none) | No required environment variables for CLI execution | - |
|
|
106
|
+
|
|
107
|
+
## Usage / API Reference
|
|
108
|
+
|
|
109
|
+
The project exposes the console scripts `smart-linux` and `sla` (configured in `pyproject.toml`).
|
|
110
|
+
|
|
111
|
+
- Run a shell command:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
smart-linux run "echo hello"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- Options:
|
|
118
|
+
- `--timeout <seconds>` — maximum seconds to allow command to run (default: 30)
|
|
119
|
+
- `--check` — treat non-zero exit codes as errors and exit with that code
|
|
120
|
+
- `--suggest-fix` — if the command fails, use AI to suggest a corrected version (requires `--check`; requires `GROQ_API_KEY`, same as `explain`/`fix`/`search`)
|
|
121
|
+
|
|
122
|
+
- Doctor command (checks common tools):
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
smart-linux doctor
|
|
126
|
+
```
|
|
127
|
+
- Get an AI-powered explanation of a command or error message:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
smart-linux explain "permission denied when running ./script.sh"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Requires a free Groq API key set as an environment variable:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
export GROQ_API_KEY="your-key-here"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Get a free key at [console.groq.com](https://console.groq.com).
|
|
140
|
+
|
|
141
|
+
- Fix a failing command:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
smart-linux fix "ls /nonexistent"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
- Options:
|
|
148
|
+
- `--timeout <seconds>` — maximum seconds to allow the command to run (default: 30)
|
|
149
|
+
|
|
150
|
+
- This runs the command and, if it fails, uses the AI to suggest a corrected version. Requires the same `GROQ_API_KEY` environment variable as the `explain` command.
|
|
151
|
+
|
|
152
|
+
- Search for a Linux task in plain language:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
smart-linux search "find the 10 largest files in the current directory"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
- This returns a concrete command and brief explanation for the requested task. Requires the same `GROQ_API_KEY` environment variable as the `explain` command.
|
|
159
|
+
|
|
160
|
+
### Example output
|
|
161
|
+
|
|
162
|
+
Successful command:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
$ smart-linux run "echo hello"
|
|
166
|
+
hello
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Failed command (example):
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
$ smart-linux run "ls nonexistent" --check
|
|
173
|
+
ls: cannot access 'nonexistent': No such file or directory
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
These outputs reflect the CLI behaviour: standard output is printed for successful commands; standard error is printed for failures and, when `--check` is used, the CLI exits with the command's exit code.
|
|
177
|
+
|
|
178
|
+
Failed command with an AI-suggested fix:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
$ smart-linux run "gti status" --check --suggest-fix
|
|
182
|
+
gti: command not found
|
|
183
|
+
|
|
184
|
+
Suggested fix:
|
|
185
|
+
git status
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
`--suggest-fix` requires `--check` (fix suggestions only apply to command failures detected via `--check`); calling it without `--check` exits immediately with an error.
|
|
189
|
+
|
|
190
|
+
## Roadmap / Current Status
|
|
191
|
+
|
|
192
|
+
- Core CLI: implemented — `run` and `doctor` commands are provided in `linux_assistant.cli.main`.
|
|
193
|
+
- Command execution: implemented using `linux_assistant.services.command_executor.CommandExecutor` which returns `CommandResult` instances.
|
|
194
|
+
- Logging & configuration: implemented via `linux_assistant.utils.logger` and `linux_assistant.config.settings`.
|
|
195
|
+
- Packaging: console script entry points are declared in `pyproject.toml`.
|
|
196
|
+
- AI-powered explanations: implemented — `smart-linux explain` uses the Groq API (`llama-3.3-70b-versatile`) to generate plain-language explanations of commands and error messages, via `linux_assistant.services.explainer.Explainer`. Requires a user-supplied `GROQ_API_KEY` environment variable.
|
|
197
|
+
- AI-powered fix suggestions: implemented — `smart-linux fix` runs a failing command and suggests a corrected version; `smart-linux run --check --suggest-fix` offers the same suggestion inline as part of normal command execution. Both use `linux_assistant.services.explainer.Explainer.suggest_fix()`.
|
|
198
|
+
- AI-powered search: implemented — `smart-linux search` answers natural-language questions about Linux tasks via `linux_assistant.services.search.Searcher`.
|
|
199
|
+
- Production hardening: implemented — API timeouts, retry logic, rate-limit-specific handling, input truncation, and documented OS/privacy limitations across all AI-backed commands.
|
|
200
|
+
- Additional AI features (command history awareness, documentation lookup) are planned but not yet implemented.
|
|
201
|
+
|
|
202
|
+
## Known Limitations
|
|
203
|
+
|
|
204
|
+
- Tested and verified on Linux (native and WSL). Not yet tested on macOS or native Windows Python — behavior on those platforms is currently unverified, though the codebase avoids Linux-only APIs where possible.
|
|
205
|
+
|
|
206
|
+
## Privacy Note
|
|
207
|
+
|
|
208
|
+
The `explain`, `fix`, and `search` commands send the command text, error output, or your query to Groq's API for processing. Avoid running these commands on text that contains secrets, passwords, or sensitive data, since that content leaves your machine.
|
|
209
|
+
|
|
210
|
+
## Install from PyPI
|
|
211
|
+
|
|
212
|
+
If this package is published to PyPI, it can be installed with:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
pip install smart-linux-assistant
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Testing
|
|
219
|
+
|
|
220
|
+
Run the test suite with `pytest`:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
pytest
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT License — see `LICENSE`.
|
|
229
|
+
|
|
230
|
+
## Contributing
|
|
231
|
+
|
|
232
|
+
- Run tests with `pytest` before opening a pull request.
|
|
233
|
+
- Follow standard Python packaging best practices.
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Smart Linux Assistant
|
|
2
|
+
|
|
3
|
+
Smart Linux Assistant is an AI-powered Linux operations assistant that understands natural language, safely executes shell commands, retrieves Linux knowledge, explains errors, and assists users with troubleshooting. The current version implements the core command execution engine and foundational architecture for future AI capabilities.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
[](https://github.com/shubham-k-jha-dev/smart-linux-assistant/actions/workflows/ci.yml)
|
|
8
|
+
|
|
9
|
+
## Project Overview
|
|
10
|
+
|
|
11
|
+
Smart Linux Assistant is a command-line utility that executes shell commands and returns structured outcomes. The tool captures the command, exit code, stdout, stderr, execution timestamp, and duration to make downstream automation and logging straightforward.
|
|
12
|
+
|
|
13
|
+
## System Architecture
|
|
14
|
+
|
|
15
|
+
- CLI (`linux_assistant.cli.main`) accepts user commands and options and delegates execution to `CommandExecutor`.
|
|
16
|
+
- `CommandExecutor` runs shell commands using `subprocess.run` and returns a `CommandResult` dataclass describing the outcome.
|
|
17
|
+
- Centralized logging is provided by `linux_assistant.utils.logger`, writing to `logs/smart_linux_assistant.log` with rotation.
|
|
18
|
+
- Runtime paths and directories are managed by `linux_assistant.config.settings` and can be initialized with `initialize_app_filesystem()`.
|
|
19
|
+
|
|
20
|
+
## Tech Stack
|
|
21
|
+
|
|
22
|
+
- Python 3.11+
|
|
23
|
+
- Typer (CLI)
|
|
24
|
+
- Standard library: `subprocess`, `logging`, `shutil`, `dataclasses`, `pathlib`, `datetime`
|
|
25
|
+
|
|
26
|
+
## Prerequisites
|
|
27
|
+
|
|
28
|
+
1. Python 3.11 or newer.
|
|
29
|
+
2. Optional: a virtual environment tool (`venv`).
|
|
30
|
+
3. No Dockerfile or docker-compose are included in this repository.
|
|
31
|
+
|
|
32
|
+
## Local Setup & Installation
|
|
33
|
+
|
|
34
|
+
1. Clone the repository:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/shubham-k-jha-dev/smart-linux-assistant
|
|
38
|
+
cd smart-linux-assistant
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. Create and activate a virtual environment:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Linux/macOS
|
|
45
|
+
python3 -m venv .venv
|
|
46
|
+
source .venv/bin/activate
|
|
47
|
+
|
|
48
|
+
# Windows (PowerShell)
|
|
49
|
+
python -m venv .venv
|
|
50
|
+
.venv\\Scripts\\Activate.ps1
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. Install development dependencies:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install -r requirements-dev.txt
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
4. (Optional) Install the package in editable mode to enable the `smart-linux` CLI entrypoint:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install -e .
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
5. (Optional) Ensure runtime directories exist from Python:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from linux_assistant.config.settings import initialize_app_filesystem
|
|
69
|
+
initialize_app_filesystem()
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Environment Variables
|
|
73
|
+
|
|
74
|
+
This project does not require any environment variables for its core CLI functionality. The repository includes an empty `.env.example` placeholder.
|
|
75
|
+
|
|
76
|
+
| Variable | Description | Example |
|
|
77
|
+
|----------|-------------|---------|
|
|
78
|
+
| (none) | No required environment variables for CLI execution | - |
|
|
79
|
+
|
|
80
|
+
## Usage / API Reference
|
|
81
|
+
|
|
82
|
+
The project exposes the console scripts `smart-linux` and `sla` (configured in `pyproject.toml`).
|
|
83
|
+
|
|
84
|
+
- Run a shell command:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
smart-linux run "echo hello"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- Options:
|
|
91
|
+
- `--timeout <seconds>` — maximum seconds to allow command to run (default: 30)
|
|
92
|
+
- `--check` — treat non-zero exit codes as errors and exit with that code
|
|
93
|
+
- `--suggest-fix` — if the command fails, use AI to suggest a corrected version (requires `--check`; requires `GROQ_API_KEY`, same as `explain`/`fix`/`search`)
|
|
94
|
+
|
|
95
|
+
- Doctor command (checks common tools):
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
smart-linux doctor
|
|
99
|
+
```
|
|
100
|
+
- Get an AI-powered explanation of a command or error message:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
smart-linux explain "permission denied when running ./script.sh"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Requires a free Groq API key set as an environment variable:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
export GROQ_API_KEY="your-key-here"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Get a free key at [console.groq.com](https://console.groq.com).
|
|
113
|
+
|
|
114
|
+
- Fix a failing command:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
smart-linux fix "ls /nonexistent"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- Options:
|
|
121
|
+
- `--timeout <seconds>` — maximum seconds to allow the command to run (default: 30)
|
|
122
|
+
|
|
123
|
+
- This runs the command and, if it fails, uses the AI to suggest a corrected version. Requires the same `GROQ_API_KEY` environment variable as the `explain` command.
|
|
124
|
+
|
|
125
|
+
- Search for a Linux task in plain language:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
smart-linux search "find the 10 largest files in the current directory"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
- This returns a concrete command and brief explanation for the requested task. Requires the same `GROQ_API_KEY` environment variable as the `explain` command.
|
|
132
|
+
|
|
133
|
+
### Example output
|
|
134
|
+
|
|
135
|
+
Successful command:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
$ smart-linux run "echo hello"
|
|
139
|
+
hello
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Failed command (example):
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
$ smart-linux run "ls nonexistent" --check
|
|
146
|
+
ls: cannot access 'nonexistent': No such file or directory
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
These outputs reflect the CLI behaviour: standard output is printed for successful commands; standard error is printed for failures and, when `--check` is used, the CLI exits with the command's exit code.
|
|
150
|
+
|
|
151
|
+
Failed command with an AI-suggested fix:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
$ smart-linux run "gti status" --check --suggest-fix
|
|
155
|
+
gti: command not found
|
|
156
|
+
|
|
157
|
+
Suggested fix:
|
|
158
|
+
git status
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`--suggest-fix` requires `--check` (fix suggestions only apply to command failures detected via `--check`); calling it without `--check` exits immediately with an error.
|
|
162
|
+
|
|
163
|
+
## Roadmap / Current Status
|
|
164
|
+
|
|
165
|
+
- Core CLI: implemented — `run` and `doctor` commands are provided in `linux_assistant.cli.main`.
|
|
166
|
+
- Command execution: implemented using `linux_assistant.services.command_executor.CommandExecutor` which returns `CommandResult` instances.
|
|
167
|
+
- Logging & configuration: implemented via `linux_assistant.utils.logger` and `linux_assistant.config.settings`.
|
|
168
|
+
- Packaging: console script entry points are declared in `pyproject.toml`.
|
|
169
|
+
- AI-powered explanations: implemented — `smart-linux explain` uses the Groq API (`llama-3.3-70b-versatile`) to generate plain-language explanations of commands and error messages, via `linux_assistant.services.explainer.Explainer`. Requires a user-supplied `GROQ_API_KEY` environment variable.
|
|
170
|
+
- AI-powered fix suggestions: implemented — `smart-linux fix` runs a failing command and suggests a corrected version; `smart-linux run --check --suggest-fix` offers the same suggestion inline as part of normal command execution. Both use `linux_assistant.services.explainer.Explainer.suggest_fix()`.
|
|
171
|
+
- AI-powered search: implemented — `smart-linux search` answers natural-language questions about Linux tasks via `linux_assistant.services.search.Searcher`.
|
|
172
|
+
- Production hardening: implemented — API timeouts, retry logic, rate-limit-specific handling, input truncation, and documented OS/privacy limitations across all AI-backed commands.
|
|
173
|
+
- Additional AI features (command history awareness, documentation lookup) are planned but not yet implemented.
|
|
174
|
+
|
|
175
|
+
## Known Limitations
|
|
176
|
+
|
|
177
|
+
- Tested and verified on Linux (native and WSL). Not yet tested on macOS or native Windows Python — behavior on those platforms is currently unverified, though the codebase avoids Linux-only APIs where possible.
|
|
178
|
+
|
|
179
|
+
## Privacy Note
|
|
180
|
+
|
|
181
|
+
The `explain`, `fix`, and `search` commands send the command text, error output, or your query to Groq's API for processing. Avoid running these commands on text that contains secrets, passwords, or sensitive data, since that content leaves your machine.
|
|
182
|
+
|
|
183
|
+
## Install from PyPI
|
|
184
|
+
|
|
185
|
+
If this package is published to PyPI, it can be installed with:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
pip install smart-linux-assistant
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Testing
|
|
192
|
+
|
|
193
|
+
Run the test suite with `pytest`:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
pytest
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT License — see `LICENSE`.
|
|
202
|
+
|
|
203
|
+
## Contributing
|
|
204
|
+
|
|
205
|
+
- Run tests with `pytest` before opening a pull request.
|
|
206
|
+
- Follow standard Python packaging best practices.
|
|
File without changes
|