Skip to content

michalCapo/zashu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zashu

AI-powered CLI tool that converts natural language commands into bash scripts using OpenRouter AI, with intelligent caching for script reuse.

Features

  • Natural Language to Bash: Describe what you want in plain English, get executable bash scripts
  • Semantic Caching: Similar prompts automatically reuse cached scripts (no AI calls needed)
  • Dry Run Mode: Preview generated scripts before execution
  • Script Management: List, run, and delete cached scripts

Installation

Linux

sudo curl -fsSL https://raw.githubusercontent.com/michalCapo/zashu/main/cmd/zashu-linux-amd64 -o /usr/bin/zashu && sudo chmod +x /usr/bin/zashu

macOS (Apple Silicon)

sudo curl -fsSL https://raw.githubusercontent.com/michalCapo/zashu/main/cmd/zashu-darwin-arm64 -o /usr/local/bin/zashu && sudo chmod +x /usr/local/bin/zashu

macOS (Intel)

sudo curl -fsSL https://raw.githubusercontent.com/michalCapo/zashu/main/cmd/zashu-darwin-amd64 -o /usr/local/bin/zashu && sudo chmod +x /usr/local/bin/zashu

Windows

Download zashu-windows-amd64.exe from releases and add to your PATH.

Build from Source

git clone https://github.com/michalCapo/zashu.git
cd zashu
go build -o zashu .
sudo mv zashu /usr/bin/zashu

Configuration

Set your OpenRouter API key:

# Option 1: Environment variable
export OPENROUTER_API_KEY=your-api-key

# Option 2: Configuration file
zashu config set api_key your-api-key

Get your API key from OpenRouter.

Optional Configuration

# Change the AI model (default: anthropic/claude-3.5-sonnet)
zashu config set model openai/gpt-4o

# View current configuration
zashu config show

Usage

Generate and Execute Scripts

# Basic usage - generates and executes after confirmation
zashu restart nginx server

# Dry run - preview script without executing
zashu --dry-run list all docker containers

# Auto-confirm - skip confirmation prompt
zashu -y update system packages

Manage Cached Scripts

# List all cached scripts
zashu list

# Run a cached script by ID
zashu run abc12345

# Delete a cached script
zashu delete abc12345

How It Works

  1. First Run: When you run a command like zashu restart server:

    • Zashu generates an embedding of your prompt
    • Checks cache for similar prompts (>90% similarity)
    • If no match, calls OpenRouter AI to generate a bash script
    • Shows you the script and asks for confirmation
    • Executes the script and caches it for future use
  2. Subsequent Runs: When you run a similar command:

    • Zashu finds the cached script via semantic similarity
    • Runs the cached script directly (no AI call needed)
    • Saves API costs and reduces latency

Cache Location

Scripts are stored in ~/.zashu/:

~/.zashu/
├── scripts/          # Cached bash scripts
│   └── abc12345.sh
├── index.json        # Prompt -> script mapping with embeddings
└── config.yaml       # API key and settings

Safety Features

  • Confirmation Prompt: Always shows script before execution (unless -y flag)
  • Dry Run Mode: Test script generation without execution
  • Transparent Caching: View all cached scripts with zashu list
  • Manual Review: Cached scripts are readable .sh files

⚠️ Disclaimer

Use at your own risk.

This tool uses AI to generate system commands. While it includes safety features like dry-runs and confirmation prompts, AI can make mistakes. Always review the generated scripts before executing them.

The authors and contributors of Zashu are NOT responsible for any damage, data loss, or system instability caused by the use of this tool. You are solely responsible for the commands you execute on your system.

Examples

# System administration
zashu restart nginx server
zashu show disk usage for home directory
zashu find large files over 100MB

# Docker operations
zashu list all running docker containers
zashu stop all docker containers
zashu remove unused docker images

# Git operations
zashu show git log for last 5 commits
zashu create a new git branch called feature-x

# File operations
zashu find all python files modified today
zashu compress logs folder to tar.gz

License

MIT

About

AI-powered CLI that converts natural language commands into bash scripts using OpenRouter AI, with intelligent semantic caching for script reuse

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors