Skip to main content

Terra Command AI - A natural language shell command tool with AI

Project description

Terra Commands AI (tai)

A powerful natural language shell command tool that uses AI to convert human instructions into appropriate shell commands for your operating system.

Features

  • AI-Powered Command Generation: Uses OpenAI's GPT models to generate OS-specific commands
  • Interactive Setup: Easy setup process for OpenAI API key with fallback support
  • Automatic OS Detection: Adapts commands for Linux, macOS, Windows, and various distributions
  • Natural Language Processing: Execute commands using plain English instructions
  • Safe Execution: Commands require confirmation before execution
  • Dry Run Mode: Test commands without actually executing them
  • Robust Fallback Mode: Works seamlessly without AI using predefined command patterns
  • Cross-platform: Native support for Linux, macOS, and Windows

Installation

Prerequisites

  • Python 3.7+
  • OpenAI API key (for AI functionality)

From Source

  1. Clone the repository:
git clone https://github.com/terra-agi/terra-commands.git
cd terra-commands
  1. Install using pip:
pip install .

Or for development:

pip install -e .

Configuration

Easy Setup: Terra Command AI provides a simple interactive setup process:

  1. Setup AI Features:

    tai --setup-ai
    

    Follow the prompts to enter your OpenAI API key securely.

  2. Configuration Storage: Your API key and settings are stored securely in:

    • macOS/Linux: ~/.config/terra-ai/config
    • Windows: %USERPROFILE%\\.config\\terra-ai\\config

Fallback Mode: If you choose not to set up AI or if the OpenAI package is not available, Terra Command AI will automatically fall back to using predefined command patterns. All basic functionality will still work without any additional configuration!

Direct Installation

pip install git+https://github.com/terra-agi/terra-commands.git

Usage

Basic Usage

tai <instruction>

Examples(Without AI)

# List files in current directory
tai list files
tai show directory
tai what files are here

# Navigate directories
tai go home
tai go back
tai go up

# System information
tai who am i
tai system info
tai disk usage

# Git operations
tai git status
tai git log
tai current branch

# Network operations
tai ping google
tai internet connection

Advanced Options

# Dry run mode (shows command without executing)
tai --dry-run list files

# Force execution without confirmation
tai --force system info

# List all available commands and AI status
tai --list

# Show system and AI configuration status
tai --status

# Set up OpenAI API key for AI features
tai --setup-ai

AI-Powered Examples

With AI enabled, you can use much more natural and complex instructions:

tai "find all python files in the current directory and count them"
tai "show me the last 10 lines of system logs"
tai "check if port 80 is open on localhost"
tai "display my public IP address"
tai "find files larger than 100MB in my home directory"
tai "show the current git branch and status"
tai "list all running docker containers"
tai "check disk usage and show only the largest directories"

Available Commands(Without AI)

File Operations

  • list files, show directory, list directory
  • what files are here, see files

Directory Navigation

  • go home, go to home
  • go back, go up, go to parent

System Information

  • who am i, current user
  • system info, what system
  • disk usage, disk space
  • memory usage, memory info

Process Management

  • process list, running processes
  • cpu info

Git Operations

  • git status, git log, git branch
  • current branch, git diff

Network Operations

  • ping google, network status
  • internet connection

Safety Features

  • Confirmation Required: All commands require user confirmation before execution
  • Dry Run Mode: Use --dry-run to see what command would be executed
  • Force Mode: Use --force to skip confirmation (use with caution)

Development

Adding New Commands

Edit the CommandInterpreter class in terra_cmd.py to add new command patterns:

self.command_patterns = {
    'new command': 'shell_command',
    # Add more patterns here
}

Testing

# Test without installation
python terra_cmd.py --dry-run list files

# Run tests
python -m pytest tests/  # (if you add tests)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Future Enhancements

  • Integration with more AI language models for better command interpretation
  • Support for complex multi-step commands
  • Command history and favorites
  • Custom command aliases
  • Integration with shell completion
  • Support for Windows commands
  • Plugin system for extending functionality

Changelog

v0.1.0

  • Initial release with basic natural language command interpretation
  • Support for common file, directory, system, and git operations
  • Safe execution with confirmation prompts
  • Dry run mode for testing
  • Installable via pip

Developed by TerraAGI Team with <3

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

terra_tai-0.1.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

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

terra_tai-0.1.0-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file terra_tai-0.1.0.tar.gz.

File metadata

  • Download URL: terra_tai-0.1.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for terra_tai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34cb3bc4e5a790d6d54a1aef89a3e9bd17d90e31e067cdfb53de154005fe0f14
MD5 18ce956e9099160ee583e9d0ed14fafb
BLAKE2b-256 09d960d6746c17f1bdfe843116bd5b770ec783c4bba7536c4cc1f1fe4e3a4d2e

See more details on using hashes here.

File details

Details for the file terra_tai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: terra_tai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for terra_tai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71a1e570d72edc91e1acd781159e7a9fbe6978f6a9914b2814e48c012b79b5af
MD5 8a43a97ee68340b4e5d95c931e9dbcbc
BLAKE2b-256 b2cf18d7b77c82e8131ff7af6bf1254b09e233acf06ab010ec205dd34787ea9e

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