hey-cli-python 1.0.3__py3-none-any.whl → 1.0.4__py3-none-any.whl

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.
hey_cli/cli.py CHANGED
@@ -93,7 +93,10 @@ def main():
93
93
 
94
94
  console.print("[bold yellow]●[/bold yellow] Thinking...")
95
95
  past_messages = history_mgr.load()
96
- response = generate_command(objective, context=piped_data, model_name=model_name, history=past_messages)
96
+ try:
97
+ response = generate_command(objective, context=piped_data, model_name=model_name, history=past_messages)
98
+ except urllib.error.URLError:
99
+ check_ollama() # always fails here — shows the panel and exits
97
100
 
98
101
  # Save the user query to history IMMEDIATELY
99
102
  history_mgr.append("user", user_prompt)
hey_cli/llm.py CHANGED
@@ -85,6 +85,8 @@ def generate_command(prompt: str, context: str = "", model_name: str = DEFAULT_M
85
85
  data = json.loads(content_str)
86
86
  return CommandResponse(**data)
87
87
 
88
+ except urllib.error.URLError:
89
+ raise # Ollama not reachable — don't retry, bubble up to cli
88
90
  except Exception as e:
89
91
  last_error = e
90
92
  if "refusal" in raw_val.lower() or "sorry" in raw_val.lower():
@@ -150,6 +152,8 @@ def generate_troubleshoot_step(objective: str, history: list, model_name: str =
150
152
  data = json.loads(content_str)
151
153
  return TroubleshootResponse(**data)
152
154
 
155
+ except urllib.error.URLError:
156
+ raise # Ollama not reachable — don't retry, bubble up to cli
153
157
  except Exception as e:
154
158
  last_error = e
155
159
  msgs.append({"role": "assistant", "content": raw_val})
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: hey-cli-python
3
+ Version: 1.0.4
4
+ Summary: A secure, zero-bloat CLI companion that turns natural language and error logs into executable commands.
5
+ Author: Mohit Singh Sinsniwal
6
+ Project-URL: Homepage, https://github.com/sinsniwal/hey-cli
7
+ Project-URL: Repository, https://github.com/sinsniwal/hey-cli
8
+ Project-URL: Issues, https://github.com/sinsniwal/hey-cli/issues
9
+ Keywords: cli,llm,bash,terminal,ollama,sysadmin
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: rich>=13.0.0
27
+ Dynamic: license-file
28
+
29
+ <div align="center">
30
+ <h1>hey-cli</h1>
31
+ <p><strong>Your terminal buddy that turns plain English into shell scripts — and runs them for you.</strong></p>
32
+
33
+ <a href="https://pypi.org/project/hey-cli-python/"><img src="https://img.shields.io/pypi/v/hey-cli-python?label=PyPI&color=blue" alt="PyPI" /></a>
34
+ <img src="https://img.shields.io/pypi/pyversions/hey-cli-python?color=blue" alt="Python" />
35
+ <a href="https://github.com/sinsniwal/hey-cli/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License" /></a>
36
+ <a href="https://github.com/sinsniwal/hey-cli/releases/latest"><img src="https://img.shields.io/github/v/release/sinsniwal/hey-cli?label=Release&color=orange" alt="Release" /></a>
37
+ </div>
38
+
39
+ <br>
40
+
41
+ `hey` is a terminal-native AI assistant that translates plain English into executable shell commands using a locally-hosted LLM via [Ollama](https://ollama.com). Your data never leaves your machine.
42
+
43
+ ```
44
+ $ hey find all python files modified in the last 24 hours
45
+ ● Thinking...
46
+
47
+ ▶ find . -name "*.py" -mtime -1 -type f
48
+
49
+ Run this command? [Y/n]:
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Features
55
+
56
+ - **100% Local & Private** — All reasoning happens on your machine via Ollama. No API keys, no cloud, no telemetry.
57
+ - **Cross-Platform Intelligence** — Detects your OS (macOS/Linux/Windows) and generates the correct flags. Won't suggest `xargs -d` on BSD or `apt` on Arch.
58
+ - **Agentic Context Gathering** — Ask "is Docker running?" and `hey` silently runs diagnostics, reads the output, and answers in plain English.
59
+ - **Security Governance** — Dangerous commands (`rm -rf`, `mkfs`, `DROP TABLE`) are intercepted and require explicit confirmation before execution.
60
+ - **Pipe-Friendly** — Pipe error logs directly: `npm run build 2>&1 | hey what is causing this error?`
61
+ - **Conversational Memory** — Remembers your recent interactions for follow-up questions.
62
+
63
+ ---
64
+
65
+ ## Installation
66
+
67
+ `hey` requires [Ollama](https://ollama.com) running locally. Install it first, then choose your platform:
68
+
69
+ ### macOS (Homebrew)
70
+
71
+ ```bash
72
+ brew tap sinsniwal/hey-cli
73
+ brew install hey-cli
74
+ ```
75
+
76
+ ### macOS & Linux (curl)
77
+
78
+ ```bash
79
+ curl -sL https://raw.githubusercontent.com/sinsniwal/hey-cli/main/install.sh | bash
80
+ ```
81
+
82
+ ### Windows (Scoop)
83
+
84
+ ```powershell
85
+ scoop install https://raw.githubusercontent.com/sinsniwal/hey-cli/main/scoop/hey-cli.json
86
+ ```
87
+
88
+ ### Windows (PowerShell Installer)
89
+
90
+ ```powershell
91
+ Invoke-WebRequest -Uri "https://raw.githubusercontent.com/sinsniwal/hey-cli/main/install.ps1" -OutFile "$env:TEMP\hey_install.ps1"; & "$env:TEMP\hey_install.ps1"
92
+ ```
93
+
94
+ ### Windows (Standalone Binary)
95
+
96
+ Download `hey.exe` from the [latest release](https://github.com/sinsniwal/hey-cli/releases/latest). No Python required.
97
+
98
+ ### pip / pipx
99
+
100
+ ```bash
101
+ pipx install hey-cli-python
102
+ ```
103
+
104
+ > **Note:** After installation, pull the default model: `ollama pull gpt-oss:20b-cloud`
105
+
106
+ ---
107
+
108
+ ## Usage
109
+
110
+ ```bash
111
+ hey <your objective in plain English>
112
+ ```
113
+
114
+ ### Examples
115
+
116
+ | Command | What happens |
117
+ |---------|-------------|
118
+ | `hey list all running docker containers` | Generates and runs `docker ps` |
119
+ | `hey is port 8080 in use?` | Silently runs `lsof -i :8080`, reads output, answers in English |
120
+ | `hey forcefully delete all .pyc files` | Generates `find . -name "*.pyc" -delete`, pauses for confirmation |
121
+ | `hey compress this folder into a tar.gz` | Generates the correct `tar` command for your OS |
122
+ | `npm run build 2>&1 \| hey what broke?` | Reads piped stderr and explains the error |
123
+ | `hey --clear` | Wipes conversational memory |
124
+
125
+ ### Execution Levels
126
+
127
+ | Level | Flag | Behavior |
128
+ |-------|------|----------|
129
+ | 0 | `--level 0` | Dry-run — shows the command but never executes |
130
+ | 1 | *(default)* | Supervised — safe commands auto-run, risky ones ask for confirmation |
131
+ | 2 | `--level 2` | Unrestricted — executes everything without confirmation |
132
+ | 3 | `--level 3` | Troubleshooter — iteratively debugs until the objective is resolved |
133
+
134
+ ---
135
+
136
+ ## Security
137
+
138
+ Safety is enforced at runtime via a local governance engine (`~/.hey-rules.json`):
139
+
140
+ - **Blocked** — `rm -rf /`, `mkfs`, `:(){ :|:& };:` are permanently rejected.
141
+ - **Explicit Confirm** — High-risk operations (`rm`, `truncate`, `DROP`) require typing a keyword to authorize.
142
+ - **Y/N Confirm** — Moderate-risk operations require a quick `y`.
143
+ - **Auto-Run** — Safe diagnostics (`ls`, `cat`, `grep`, `git status`) execute immediately.
144
+
145
+ Initialize or customize your rules:
146
+
147
+ ```bash
148
+ hey --init
149
+ ```
150
+
151
+ ---
152
+
153
+ ## OS Skills
154
+
155
+ `hey` ships with built-in knowledge for macOS, Ubuntu/Debian, Arch Linux, Fedora/RHEL, Windows PowerShell, FreeBSD, and ChromeOS.
156
+
157
+ **Want to improve it for your OS?** Add a Markdown file to `hey_cli/skills/` with plain-English rules (e.g., "On Alpine, use `apk add` instead of `apt install`"). The engine loads them dynamically at runtime.
158
+
159
+ Pull requests for new OS skills are welcome!
160
+
161
+ ---
162
+
163
+ ## Architecture
164
+
165
+ ```
166
+ hey "your question"
167
+
168
+
169
+ ┌──────────────┐ ┌──────────────────┐
170
+ │ CLI Parser │────▶│ Governance Check │
171
+ └──────────────┘ └────────┬─────────┘
172
+
173
+ ┌─────────▼──────────┐
174
+ │ Ollama (local LLM)│
175
+ │ localhost:11434 │
176
+ └─────────┬──────────┘
177
+
178
+ ┌─────────▼──────────┐
179
+ │ Command Runner │
180
+ │ (execute / confirm)│
181
+ └────────────────────┘
182
+ ```
183
+
184
+ - **Zero external API calls** — communicates with Ollama via `localhost:11434` using Python's built-in `urllib`.
185
+ - **Zero compiled dependencies** — the only runtime dependency is `rich` (for terminal formatting).
186
+ - **Pure Python 3.9–3.14** — no C extensions, no Rust, no build tools required.
187
+
188
+ ---
189
+
190
+ ## Contributing
191
+
192
+ 1. Fork the repository
193
+ 2. Create a feature branch: `git checkout -b feature/my-feature`
194
+ 3. Commit changes: `git commit -m "feat: add my feature"`
195
+ 4. Push and open a Pull Request
196
+
197
+ See [RELEASING.md](RELEASING.md) for maintainer release instructions.
198
+
199
+ ---
200
+
201
+ ## License
202
+
203
+ [MIT](LICENSE) — Mohit Singh Sinsniwal
@@ -1,14 +1,14 @@
1
1
  hey_cli/__init__.py,sha256=J-j-u0itpEFT6irdmWmixQqYMadNl1X91TxUmoiLHMI,22
2
- hey_cli/cli.py,sha256=blZnHlXp6DGcw0wD8gBsjWB3jQUwO1hZObqvFY6gqxY,3870
2
+ hey_cli/cli.py,sha256=pbwPps05FtDF4rSDpcqM0O3b24-HloM-rBS4ueySsVc,3991
3
3
  hey_cli/governance.py,sha256=jRgI9kUtldJFUTTNbRAj6kACKnVZMe_ak-7lmCgz5EA,2641
4
4
  hey_cli/history.py,sha256=a7xnUMthQQlzeTwfsORpsTBFPMBgo0wcubU603HBrRE,928
5
- hey_cli/llm.py,sha256=mCZ6e4fVa7lOCsT6ZzXx_C5CQavi3sDJNyBcKu6nGe4,7857
5
+ hey_cli/llm.py,sha256=cTFsJjGWfPwdi36n5w818kM8mNw2HOWP_F6nnE9tpd0,8085
6
6
  hey_cli/models.py,sha256=Jye_btuL39R7BA5bG59JbJFtpDUS0ZrSw0veUUTf0kM,302
7
7
  hey_cli/runner.py,sha256=Ep5Z1E_RXXnSeqlDshFjv3Swxeq2LqX7iImaZPH-Edw,8386
8
8
  hey_cli/skills.py,sha256=RX6rSnkQ6FG_hogKUhASI5dazvNAphi2n2c1Rw_NAxw,3569
9
- hey_cli_python-1.0.3.dist-info/licenses/LICENSE,sha256=15ubdFS3laW1SETf6f8fd8-sbqZeGz_FFdJgJATDAVI,1065
10
- hey_cli_python-1.0.3.dist-info/METADATA,sha256=j-tciK6uJ8gT-DIrT8BYatyusFxPMRmmjTm80U_jm1o,4944
11
- hey_cli_python-1.0.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
12
- hey_cli_python-1.0.3.dist-info/entry_points.txt,sha256=N4bcRze9-LYaO624Gpg5Th_4CSQCDN04EXUHFve7uGw,41
13
- hey_cli_python-1.0.3.dist-info/top_level.txt,sha256=UNOjINF-x81p5IeEawLMkXdUnlybKKYKx8UGTzP6IuU,8
14
- hey_cli_python-1.0.3.dist-info/RECORD,,
9
+ hey_cli_python-1.0.4.dist-info/licenses/LICENSE,sha256=15ubdFS3laW1SETf6f8fd8-sbqZeGz_FFdJgJATDAVI,1065
10
+ hey_cli_python-1.0.4.dist-info/METADATA,sha256=AfpTgM2pm6oTC2tumJPNc1Nzzfkq5cgXi4rSadMIw5U,7654
11
+ hey_cli_python-1.0.4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
12
+ hey_cli_python-1.0.4.dist-info/entry_points.txt,sha256=N4bcRze9-LYaO624Gpg5Th_4CSQCDN04EXUHFve7uGw,41
13
+ hey_cli_python-1.0.4.dist-info/top_level.txt,sha256=UNOjINF-x81p5IeEawLMkXdUnlybKKYKx8UGTzP6IuU,8
14
+ hey_cli_python-1.0.4.dist-info/RECORD,,
@@ -1,97 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: hey-cli-python
3
- Version: 1.0.3
4
- Summary: A secure, zero-bloat CLI companion that turns natural language and error logs into executable commands.
5
- Author: Mohit Singh Sinsniwal
6
- Project-URL: Homepage, https://github.com/sinsniwal/hey-cli
7
- Project-URL: Repository, https://github.com/sinsniwal/hey-cli
8
- Project-URL: Issues, https://github.com/sinsniwal/hey-cli/issues
9
- Keywords: cli,llm,bash,terminal,ollama,sysadmin
10
- Classifier: Development Status :: 5 - Production/Stable
11
- Classifier: Environment :: Console
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Operating System :: MacOS
15
- Classifier: Operating System :: POSIX :: Linux
16
- Classifier: Operating System :: Microsoft :: Windows
17
- Classifier: Programming Language :: Python :: 3.9
18
- Classifier: Programming Language :: Python :: 3.10
19
- Classifier: Programming Language :: Python :: 3.11
20
- Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Programming Language :: Python :: 3.13
22
- Classifier: Programming Language :: Python :: 3.14
23
- Requires-Python: >=3.9
24
- Description-Content-Type: text/markdown
25
- License-File: LICENSE
26
- Requires-Dist: rich>=13.0.0
27
- Dynamic: license-file
28
-
29
- <div align="center">
30
- <h1>hey-cli 🤖</h1>
31
- <p><strong>A zero-bloat, privacy-first, locally-hosted CLI agent powered by Ollama.</strong></p>
32
-
33
- <img src="https://img.shields.io/badge/Python-3.9+-blue.svg" alt="Python Version" />
34
- <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License" />
35
- <img src="https://img.shields.io/badge/Ollama-Local-orange.svg" alt="Ollama Local" />
36
- </div>
37
-
38
- <br>
39
-
40
- `hey` isn't just an LLM wrapper. It's a context-aware system agent designed to bridge the gap between human language and POSIX shell utilities natively on your host machine.
41
-
42
- > Ask it to parse your error logs, debug Docker, clear DNS caches, or execute complex file maneuvers—all while executing safely behind a dynamic zero-trust governance matrix.
43
-
44
- ## 🚀 Why `hey-cli` over Copilot/ChatGPT?
45
- 1. **Total Privacy**: Your code and system logs never leave your physical CPU. All context gathering and reasoning is done locally via [Ollama](https://ollama.com).
46
- 2. **True Cross-Platform Skills**: Under the hood, `hey-cli`'s "Skills Engine" detects if you're on macOS (BSD), Ubuntu (GNU), Windows (PowerShell), or Arch Linux, and actively refuses to generate incompatible flags like `xargs -d` on Mac.
47
- 3. **Agentic Execution**: Ask "is docker running?" and `hey` will silently execute `docker info` in the background, read the stdout, analyze it, and return a plain English answer.
48
- 4. **Security Governance**: Built-in AST-level parsing. Safe commands (like `git status`) auto-run. Destructive commands (`rm -rf`, `-exec delete`) require explicit typed confirmation.
49
-
50
- ## 📦 Installation
51
-
52
- **Prerequisite:** You must have [Python 3.9+](https://www.python.org/downloads/) installed.
53
-
54
- ### macOS & Linux
55
- Paste this snippet into your terminal to auto-install `pipx`, `ollama`, pull the required language model, and build `hey-cli` natively.
56
- ```bash
57
- curl -sL https://raw.githubusercontent.com/sinsniwal/hey-cli/main/install.sh | bash
58
- ```
59
-
60
- ### Windows (PowerShell)
61
- Paste this into your PowerShell terminal:
62
- ```powershell
63
- Invoke-WebRequest -Uri "https://raw.githubusercontent.com/sinsniwal/hey-cli/main/install.ps1" -OutFile "$env:TEMP\hey_install.ps1"; & "$env:TEMP\hey_install.ps1"
64
- ```
65
-
66
- ## 🛠️ Usage
67
-
68
- Simply type `hey` followed by your objective.
69
-
70
- **Context-Gathering (Zero-Trust)**
71
- ```bash
72
- hey is my docker hub running?
73
- ```
74
- *`hey` will silently run `systemctl is-active docker` or `docker info`, see that it failed to connect to the socket, and explain the situation.*
75
-
76
- **Execution (Governance Protected)**
77
- ```bash
78
- hey forcefully delete all .pyc files
79
- ```
80
- *`hey` parses the generated `find . -name "*.pyc" -exec rm -f {} +` command, detects `rm` and `-exec` triggers, and pauses execution until you explicitly type `rm` to authorize.*
81
-
82
- **Debugging Logs**
83
- ```bash
84
- npm run build 2>&1 | hey what is causing this webpack error?
85
- ```
86
-
87
- ## 🛡️ Governance Matrix
88
- Safety is a first-class citizen. `hey-cli` maintains a local governance database (`~/.hey-rules.json`):
89
- - **Never List**: Things like `rm -rf /` and `mkfs` are permanently blocked at the compiler level.
90
- - **Explicit Confirm**: High-risk ops (`truncate`, `drop`, `rm`) require typing exact keyword verification.
91
- - **Y/N Confirm**: Moderate risk ops requiring a quick `y`.
92
- - **Allowed List**: Safe diagnostics like `cat`, `ls`, `grep` auto-run natively.
93
-
94
- ## 🤝 Adding OS Skills
95
- Is `hey` generating incorrect shell semantics for your niche operating system?
96
-
97
- You can make it permanently smarter without touching code! Simply open `hey_cli/skills/` and create a markdown file for your OS containing explicit English instructions (e.g. "Do not use apt on Alpine, use apk add"). The engine dynamically parses `.md` rulesites at runtime. Pull requests are heavily welcomed!