Metadata-Version: 2.4
Name: cmdexy
Version: 1.0.0
Summary: AI-powered CLI assistant with automatic error recovery and code fixing.
License: MIT
License-File: LICENSE
Keywords: cli,ai,assistant,error-recovery,cohere,automation
Author: Akhilesh S
Author-email: akhilesh2220@github.com
Requires-Python: >=3.10,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Dist: cohere (>=4.0.0,<5.0.0)
Requires-Dist: docker (>=7.0.0,<8.0.0)
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Requires-Dist: rich (>=13.0.0,<14.0.0)
Requires-Dist: typer[all] (>=0.21.1,<0.22.0)
Project-URL: Homepage, https://github.com/akhilesh2220/cmdexy
Project-URL: Repository, https://github.com/akhilesh2220/cmdexy
Description-Content-Type: text/markdown

# cmdexy

**AI-powered CLI assistant with automatic error recovery and code fixing.**

[![GitHub](https://img.shields.io/badge/GitHub-akhilesh2220%2Fcmdexy-blue)](https://github.com/akhilesh2220/cmdexy)
[![Python](https://img.shields.io/badge/Python-3.10%2B-green)](https://python.org)
[![License](https://img.shields.io/badge/License-MIT-yellow)](LICENSE)

---

## ✨ Features

- 🤖 **AI-Powered Intent Analysis** - Understands what you want to do
- 🔧 **Automatic Error Recovery** - Detects failures and suggests fixes
- 📝 **Code Auto-Fixing** - Patches your files automatically
- 💻 **Shell Command Wrapper** - Monitor any command with AI assistance
- 🍎 **OS-Aware** - Generates platform-specific commands (macOS, Linux, Windows)
- 🔐 **Secure Config** - API keys stored safely in `~/.cmdexy/`

---

## 🚀 Installation

### Prerequisites
- Python 3.10+
- [Cohere API Key](https://dashboard.cohere.com/api-keys) (free tier available)

### Install from source

```bash
# Clone the repository
git clone https://github.com/akhilesh2220/cmdexy.git
cd cmdexy

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e .

# Configure your API key
cmdexy config
```

---

## 📖 Usage

### Configure API Key (First Time)
```bash
cmdexy config
```

### Interactive Mode
Start an AI-powered shell session:
```bash
cmdexy int
```

Example session:
```
cmdexy > create a python file that prints hello world
Intent detected: SYSTEM_COMMAND
Generated Command: cat <<EOF > hello.py
print("Hello, World!")
EOF
Execute on HOST? (y/n): y
```

### Run Single Instructions
```bash
cmdexy run "list all files in current directory"
cmdexy run "create a flask app with one endpoint"
```

### Shell Wrapper (Error Recovery)
Run any command with AI-powered error monitoring:
```bash
cmdexy shell python3 script.py
cmdexy shell ansible-playbook deploy.yml
cmdexy shell npm run build
```

If the command fails, cmdexy will:
1. Analyze the error using AI
2. Suggest a fix (code patch or install command)
3. Apply the fix automatically (with your permission)
4. Retry the command

### Check Version
```bash
cmdexy --version
```

---

## 🎯 Commands

| Command | Description |
|---------|-------------|
| `cmdexy config` | Configure API key and settings |
| `cmdexy int` | Start interactive AI session |
| `cmdexy run "<instruction>"` | Execute a single AI-powered instruction |
| `cmdexy shell <command>` | Run command with error recovery |
| `cmdexy --version` | Show version |
| `cmdexy --help` | Show help |

---

## 🔄 Error Recovery Flow

```
┌─────────────────┐
│  Run Command    │
└────────┬────────┘
         │
         ▼
   ┌───────────┐    Success
   │  Execute  │────────────► Done
   └─────┬─────┘
         │ Failure
         ▼
┌─────────────────┐
│ Analyze Error?  │──── No ───► Exit
└────────┬────────┘
         │ Yes
         ▼
┌─────────────────┐
│  AI Analysis    │
└────────┬────────┘
         │
    ┌────┴────┐
    ▼         ▼
┌───────┐ ┌───────┐
│ Code  │ │ Cmd   │
│ Fix   │ │ Fix   │
└───┬───┘ └───┬───┘
    │         │
    ▼         ▼
┌─────────────────┐
│  Apply & Retry  │
└─────────────────┘
```

---

## 📁 Project Structure

```
cmdexy/
├── cmdexy/
│   ├── main.py           # CLI entry point
│   ├── cli/
│   │   ├── interactive.py  # Interactive mode
│   │   ├── run.py          # Single instruction mode
│   │   └── wrapper.py      # Shell wrapper
│   └── core/
│       ├── ai_engine.py    # Cohere AI integration
│       ├── config.py       # Configuration manager
│       ├── controller.py   # Main orchestration logic
│       └── execution.py    # Command execution
├── pyproject.toml
└── README.md
```

---

## ⚙️ Configuration

Config is stored in `~/.cmdexy/config.json`:

```json
{
  "api_key": "your-cohere-api-key"
}
```

You can also use environment variable:
```bash
export COHERE_API_KEY="your-key"
```

---

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

---

## 📄 License

MIT License - see [LICENSE](LICENSE) for details.

---

## 🙏 Acknowledgments

- [Cohere](https://cohere.com/) for the AI API
- [Typer](https://typer.tiangolo.com/) for the CLI framework
- [Rich](https://rich.readthedocs.io/) for beautiful terminal output

