A lightweight bash-based AI coding agent that uses the OpenRouter API to generate and execute bash scripts.
- Takes user input as task descriptions in natural language
- Maintains conversation history in history.txt (latest 500 lines)
- Structures context with XML-like tags:
- - Start of history
- - Recent conversation
- - Last command output
- - Current user request
- Makes API call to OpenRouter using Claude Sonnet 4
- Extracts bash script from AI response
- Allows user to review and execute generated script
- Captures command output in result.txt
- Set your OpenRouter API key:
export OPENROUTER_API_KEY="your-key"
- Run the agent:
bash agent.sh
- Describe what you want to do in plain English
- Review and confirm script execution with y/n
- curl
- jq
- coreutils
Environment variables:
- OPENROUTER_API_KEY (required)
- MODEL (default: anthropic/claude-sonnet-4)
- ENDPOINT (default: https://openrouter.ai/api/v1/chat/completions)
- TAIL_LINES (default: 500)
- SCRIPT_FILE (default: generated_script.sh)