AI-powered CLI for generating and executing shell commands
Project description
Termai - AI-Powered Command Line Assistant
Overview
Termai is a command-line tool specially designed for beginners,it translates natural language instructions into shell commands and executes them. It streamlines terminal interactions by automating command generation, reducing the need to memorize complex syntax.
Features
- Natural Language to Shell Command Conversion – Converts plain English instructions into executable shell commands using the Gemini language model.
- Command Review – Allows users to review generated commands before execution to ensure accuracy.
- Command Execution – Runs commands directly and presents output in a user-friendly format.
- Shell Detection – Identifies the active shell environment (bash, zsh, PowerShell, etc.) for compatibility.
- Command Validation – Implements security measures to prevent execution of potentially harmful commands.
Installation
Using pip (Recommended)
pip install termai-cli
From Source
git clone https://github.com/ayushgupta4002/Termai
cd termai
pip install .
Usage
Basic Usage
termai "Your instruction here" -e
Example Commands
Create a Next.js project and spin up a PostgreSQL container in Docker:
termai "Make a Next.js project and spin up a PostgreSQL image in Docker" -e
List all running Docker containers:
termai "Show all running Docker containers" -e
Find and delete all .log files in the current directory:
termai "Find and delete all .log files in this folder" -e
Architecture
Termai's core logic is in cli.py, which:
- Receives a natural language instruction.
- Uses
get_shell_command(vialangchain_google_genai) to generate shell commands. - Validates commands using
validate_commandinutils.py. - Executes commands securely and displays results.
Project Structure
termai/
├── src/
│ ├── cli.py # Command-line interface logic
│ ├── utils.py # Utility functions (validation, shell detection)
│ └── __init__.py
├── setup.py # Build script for packaging
└── README.md
Dependencies
- Python – Primary language
- Typer – CLI framework
- Pydantic – Data validation
- Rich – Enhanced terminal output
- google-generativeai & langchain-google-genai – AI model integration
- python-dotenv – Environment variable management
- setuptools – Packaging and distribution
- subprocess – Command execution
Configuration
Before using Termai, set up your Gemini API key:
echo "GOOGLE_API_KEY=your_api_key" > .env
Contributing
Contributions are welcome! Please submit a pull request or open an issue.
Support
For any issues or feature requests, please open an issue on GitHub.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file termai_cli-1.0.0.tar.gz.
File metadata
- Download URL: termai_cli-1.0.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc2f56768ffa4002c04b475877357c73a9cd7a3e02ab666896c6a6aecbdc67e0
|
|
| MD5 |
e421fa1f2cce7298564c9f051fbaa804
|
|
| BLAKE2b-256 |
76d1e8dcf574233e5927d3032a8bd9faf93b2fbfc00b3101875a2036375ef717
|
File details
Details for the file termai_cli-1.0.0-py3-none-any.whl.
File metadata
- Download URL: termai_cli-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a71482d4419788e1bc2770a51c5b4ef16bf6f3850e9212a66934d2b6548a07e6
|
|
| MD5 |
59565d7c3dcefbb498eeaf5adc9777b9
|
|
| BLAKE2b-256 |
d2e12637ed0ccc88be691ca136765f58dea11cafb8200da190a1638925063f53
|