Skip to main content

A command-line tool that generates shell commands using Qwen2.5-Coder via Ollama

Project description

QCMD - AI-powered Command Generator

QCMD is a powerful command-line tool that generates shell commands from natural language descriptions using Qwen2.5-Coder via Ollama. The tool now features a modular architecture for improved maintainability and extensibility.

Features

  • Generate shell commands from natural language descriptions
  • Interactive shell with command history and autocompletion
  • Auto-correction mode that fixes commands automatically
  • Log analysis and monitoring with AI assistance
  • System status monitoring and configuration management
  • Safe command execution with dangerous command detection
  • Highly customizable UI with color themes and display options

Installation

From PyPI

pip install ibrahimiq-qcmd

From Source (Development Mode)

git clone https://github.com/aledanee/qcmd.git
cd qcmd
pip install -e .

Make sure you have Ollama installed and running with the Qwen2.5-Coder model:

ollama pull qwen2.5-coder:0.5b
ollama serve

Usage

Running QCMD

There are several ways to run QCMD:

  1. Using the installed command:
qcmd "list all files in the current directory"
  1. Using the Python module:
python -m qcmd_cli "list all files in the current directory"
  1. Using the wrapper script (if in project directory):
./qcmd "list all files in the current directory"
  1. Using the run_qcmd.py script (if in project directory):
./run_qcmd.py "list all files in the current directory"

Basic Command Generation

qcmd "list all files in the current directory"

Execute the Generated Command

qcmd --execute "check disk space"

Interactive Shell

qcmd --shell

Log Analysis

qcmd --logs

System Status

qcmd --status

Modular Architecture

QCMD has been refactored into a modular architecture for better maintainability and extensibility. The main components are:

Core Modules

  • qcmd_cli.core.command_generator: Generates and executes shell commands
  • qcmd_cli.core.interactive_shell: Interactive shell functionality

Utility Modules

  • qcmd_cli.utils.history: Command history management
  • qcmd_cli.utils.session: Session management
  • qcmd_cli.utils.system: System status and monitoring

Log Analysis

  • qcmd_cli.log_analysis.analyzer: Log content analysis
  • qcmd_cli.log_analysis.log_files: Log file discovery and selection
  • qcmd_cli.log_analysis.monitor: Log file monitoring

User Interface

  • qcmd_cli.ui.display: UI elements and formatting

Configuration

  • qcmd_cli.config.settings: Configuration management

Command Handling

  • qcmd_cli.commands.handler: Command-line argument parsing and execution

See MODULAR_ARCHITECTURE.md for a detailed explanation of the modular design.

Development

Setting Up Development Environment

  1. Clone the repository:
git clone https://github.com/aledanee/qcmd.git
cd qcmd
  1. Install in development mode:
pip install -e .
  1. Install development dependencies:
pip install pytest

Testing

Run the tests to verify the modular architecture:

python -m pytest tests/

Directory Structure

qcmd/
├── qcmd_cli/                 # Main package
│   ├── commands/             # Command handlers
│   ├── config/               # Configuration management
│   ├── core/                 # Core functionality
│   ├── log_analysis/         # Log analysis modules
│   ├── ui/                   # User interface
│   └── utils/                # Utility modules
├── tests/                    # Test suite
└── run_qcmd.py               # Entry point script

Contributing

Contributions are welcome! Here's how you can contribute:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and commit them: git commit -m 'Add some feature'
  4. Push to the branch: git push origin feature-name
  5. Submit a pull request

Please make sure to update tests as appropriate and ensure all tests pass before submitting a pull request.

Configuration

QCMD stores configuration in ~/.qcmd/config.json. You can customize:

  • Default model
  • Temperature for generation
  • UI settings (banner, colors, compact mode)
  • Update checking behavior
  • Maximum attempts for auto-correction

License

MIT

Credits

Powered by Ollama and Qwen2.5-Coder.

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

ibrahimiq_qcmd-1.0.15.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

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

ibrahimiq_qcmd-1.0.15-py3-none-any.whl (43.9 kB view details)

Uploaded Python 3

File details

Details for the file ibrahimiq_qcmd-1.0.15.tar.gz.

File metadata

  • Download URL: ibrahimiq_qcmd-1.0.15.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ibrahimiq_qcmd-1.0.15.tar.gz
Algorithm Hash digest
SHA256 03d13eb24df6b94e272cbde94cbda02351c20dcfa90c32811475393c610b0167
MD5 b728970250cfd0b7ca213ba27c48602c
BLAKE2b-256 efc677abd49e3801f1d06a678bb00f3b2115dfb0ed3f2f5a441d0e59b738ff70

See more details on using hashes here.

File details

Details for the file ibrahimiq_qcmd-1.0.15-py3-none-any.whl.

File metadata

File hashes

Hashes for ibrahimiq_qcmd-1.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 3d4bb4011b97527ff61c1b4bae63410fec59d4db14f99ae244a23b1be0383b2c
MD5 2c3a4bd768c1efb441382d53ee6a296a
BLAKE2b-256 18a34b3e4c7ba826a926b77504049e4b484d29e7cb67e639c19922fecbabdaa1

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