Skip to main content

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

Project description

cmdexy

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

GitHub Python 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

Install from source

# 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)

cmdexy config

Interactive Mode

Start an AI-powered shell session:

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

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:

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

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:

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

You can also use environment variable:

export COHERE_API_KEY="your-key"

๐Ÿค Contributing

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


๐Ÿ“„ License

MIT License - see LICENSE for details.


๐Ÿ™ Acknowledgments

  • Cohere for the AI API
  • Typer for the CLI framework
  • Rich for beautiful terminal output

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmdexy-1.0.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmdexy-1.0.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file cmdexy-1.0.0.tar.gz.

File metadata

  • Download URL: cmdexy-1.0.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for cmdexy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8ede4521662cbc973808930055b73919d5b954e9fda163722314c21a595fde8e
MD5 52fd29c678610b08b810dbc7b1f26961
BLAKE2b-256 7c781db7457ba0fc913d828f9f53edef2e7bd3042a4cf3105f511b481fa1159d

See more details on using hashes here.

File details

Details for the file cmdexy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cmdexy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for cmdexy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b2bb85f50f76ad20f6e8340f2660b3b1c684da8ca9015deab1f6f1f51bb9293
MD5 d587d05640d3e9238653bf0c1f888817
BLAKE2b-256 a5f417a25380284e41fbc20f8fb1f3dbea492d8e8139691610e8e323e5fd29ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page