Metadata-Version: 2.4
Name: bashly-cli
Version: 0.1.4
Summary: AI-powered cross-environment terminal assistant
Author: Albin
Project-URL: Homepage, https://github.com/albinnnnn/bashly
Project-URL: Repository, https://github.com/albinnnnn/bashly
Project-URL: Issues, https://github.com/albinnnnn/bashly/issues
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: openai>=1.0.0
Requires-Dist: pyperclip>=1.11.0
Requires-Dist: pywin32>=311; sys_platform == "win32"
Requires-Dist: rich>=14.3.3

# Bashly

AI-powered cross-environment terminal assistant. Type your request in plain English — Bashly instantly generates the right command for your target environment, lets you securely approve or deny it, and executes it.

![Bashly Demo](https://raw.githubusercontent.com/albinnnnn/bashly/master/demo.gif)

## Supported Environments

Bashly automatically detects your active operating system, and will even distinguish between PowerShell and CMD when running on Windows!

| Environment | Can run locally? |
|---|---|
| Windows (PowerShell) | Yes |
| Windows (CMD) | Yes |
| Linux (bash) | Yes |
| macOS (zsh) | Yes |
| Android (Termux) | Copy only |
| MicroPython (ESP32 / Pi Pico) | Copy only |
| Arduino CLI | Copy only |
| Raspberry Pi (bash + GPIO) | Copy only |

---

## 🚀 Quick Start

### 1. Installation
The easiest way to install Bashly globally is using `uv` or `pip`:

**Using uv (Recommended):**
```bash
uv tool install bashly-cli
```

**Using pip:**
```bash
pip install bashly-cli
```

### 2. Run Bashly
Once installed, you can start Bashly from any directory by simply typing:
```bash
bashly
```

### 3. First-Time Setup
On your very first run, Bashly will ask you for an **OpenRouter API Key**. 
- Get one for free at [openrouter.ai](https://openrouter.ai).
- Paste it into the terminal when prompted. 
- It will be securely saved to `~/.bashly_config.json` automatically.

---

## 💡 Usage

Bashly is designed to feel like a continuous chat within your terminal. 

```bash
Bashly (Linux) > find all log files older than 7 days
Bashly (MicroPy) > blink the onboard LED every 500ms
Bashly (Win/PS) > list all running processes sorted by memory
```

### Built-in Commands
If you type any of these keywords, Bashly performs built-in actions instead of asking the AI:

| Command | Action |
|---|---|
| `help` | Show the help menu |
| `history` | View your last 10 commands |
| `clear history` | Safely delete all your saved command history |
| `sysinfo` | View your OS, Architecture, and Python version |
| `api key` | Update your OpenRouter API key |
| `switch env` | Change your target environment on the fly! |
| `exit` | Quit the application |

### Interactive Approvals
Bashly will **never** run a command without your explicit permission.

**For local environments (Windows, Linux, macOS):**
- `y` — run the command locally.
- `n` — skip it.
- `c` — copy to clipboard without running.
- `?` — explain step-by-step what the command actually does.

**For cross-compiling/remote targets (MicroPython, Arduino, Termux):**
- `y` / `c` — copy to clipboard.
- `?` — explain.

---

## 🛡️ Built-in Security

Bashly parses your generated commands against strict RegEx blocklists to prevent disastrous mistakes:

- 🔴 **DANGEROUS** — Destructive patterns (`rm -rf`, `format c:`, `Invoke-Expression`, fork bombs). **Execution is hard-blocked.** You can only copy the command if you deliberately want to run it.
- 🟡 **CAUTION** — Elevated privilege commands (`sudo`, `chmod`, `taskkill`). Execution is allowed but visually warned.
- 🟢 **SAFE** — Standard commands without known danger patterns.

---

## 🛠️ Developing Locally

If you want to contribute to Bashly or tweak its core prompts:

1. Clone the repository: `git clone https://github.com/albinnnnn/bashly && cd bashly`
2. Install it in editable mode: `uv pip install -e .`
3. Tweak the core LLM instructions directly in `src/bashly/prompts.py`!

```text
bashly/
├── src/bashly/
│   ├── cli.py            Entry point, UI, and approval loop
│   ├── llm.py            OpenRouter API integration
│   ├── executor.py       Subprocess execution and Danger RegEx
│   ├── history.py        Append-only JSON history logging
│   ├── environments.py   System prompt configuration mapping
│   ├── prompts.py        Centralized dashboard for tweaking prompts!
│   └── config.py         Persistent API Key manager
├── pyproject.toml        PyPI package metadata
└── README.md
```
