Mitra is a command-line interface (CLI) tool built with Go and the Cobra library. It understands human language instructions, generates the corresponding shell commands using a Large Language Model (LLM), executes them, and logs the history.
- Input: You provide a natural language command to Mitra, either enclosed in quotes or directly as arguments.
> mitra "install latest vs code" # or > mitra install latest vs code
- Processing: The input instruction is passed to the core processing logic (
internal/completion.Handle). This module interacts with an LLM (configured viautils.Config) to interpret the instruction and generate the appropriate shell command(s) (e.g.,brew install --cask visual-studio-codeon macOS). - Execution: Mitra executes the generated command(s).
- History: Each command execution (both the original instruction and the generated commands) is saved to an SQLite database (
db.Store) for tracking.
- Natural Language Interface: Interact with your shell using plain English (or other supported languages).
- LLM-Powered Command Generation: Leverages powerful language models to translate instructions into executable commands.
- Command History: Keeps a record of all executed commands in an SQLite database.
- Configurable: Supports configuration for aspects like the LLM provider (details in
utils/config.go). - Extensible: Built with Cobra, making it easy to add new commands.
- Prerequisites: Go (version X.Y or later recommended - Update with your Go version requirement)
- Clone the repository:
git clone <repository-url> # Replace with your repo URL cd mitra-cli
- Build the project:
go build . - (Optional) Install globally:
go install . # Or move the generated 'mitra-cli' binary to a directory in your PATH # e.g., sudo mv mitra-cli /usr/local/bin/mitra
The primary way to use Mitra is by providing your instruction directly as arguments. You can enclose the instruction in quotes (recommended if it contains special shell characters) or provide it directly:
mitra "<your instruction>"
# or
mitra your instruction hereExamples:
mitra "list all files in the current directory including hidden ones"mitra "create a new directory called 'my-project'"mitra "show my current git branch"mitra "install the latest version of nodejs"
Mitra uses the following command structure:
mitra [command] [flags]
# or for the default behavior:
mitra <your instruction>Available Commands:
<instruction>(Default): Takes a natural language instruction (provided directly without a command name), generates, and executes the corresponding shell command(s).completion [bash|zsh|fish|powershell]: Generates shell completion scripts for the specified shell.help [command]: Displays help information about Mitra or a specific command.revert <id>: Reverts a previous action identified by its ID from the history. (Note: Currently under development, placeholder implementation exists).
Flags:
-h, --help: Show help information.
(Note: A --version flag is not currently implemented.)
- Full Revert Feature: Complete the implementation for
mitra revert <id>to properly undo previous actions based on history. - History Command (
mitra history): Add a command to view the execution history directly from the CLI. - Check Command (
mitra check <id>): Add a command to inspect the details of a specific historical entry. - Configuration Management: Improve ways to manage configuration (e.g., via a config file or environment variables).
- Interactive Mode: Provide an interactive shell-like experience.
- Error Handling Improvements: Enhance feedback on failed command generation or execution.
- Testing: Increase test coverage.
Contributions are welcome! Please open an issue to discuss changes or submit a pull request.
This project is licensed under the terms of the LICENSE file.