gemini-cli-wrapper
v1.0.0
Published
A CLI wrapper for Gemini AI code analysis and review
Maintainers
Readme
Gemini CLI Wrapper
A powerful command-line interface wrapper for Google's Gemini AI, designed for code analysis, review, and improvement.
Features
- 🤖 AI-Powered Code Analysis: Leverage Gemini AI for intelligent code review
- 📝 Multiple Commands: Explain, summarize, improve, refactor, and review code
- 🔍 Project Analysis: Analyze entire projects with smart file filtering
- 🎨 Interactive Mode: Iterative improvement with user confirmation
- 🧪 Testing Suggestions: Get AI-powered testing recommendations
- 📋 TODO Detection: Automatically find and categorize TODOs and issues
- 🎯 Goal-Based Refactoring: Refactor code with specific objectives
Installation
Prerequisites
- Node.js 18+
- Google Gemini API key
Setup
Clone and install dependencies:
git clone <repository-url> cd gemini-wrapper npm installSet up your Gemini API key:
# Copy the example environment file cp env.example .env # Edit .env and add your API key # Get your key from: https://makersuite.google.com/app/apikeyOr set it as an environment variable:
export GEMINI_API_KEY="your-api-key-here"Make the CLI executable (optional):
chmod +x bin/gmb.js
Usage
Basic Commands
# Get help
node bin/gmb.js --help
# Check version
node bin/gmb.js --versionCode Analysis Commands
Explain Code
# Explain a single file
node bin/gmb.js explain path/to/file.js
# With custom format
node bin/gmb.js explain path/to/file.js --format markdownSummarize Code
# Summarize a file
node bin/gmb.js summarize path/to/file.jsBreak Down Code
# Break file into logical sections
node bin/gmb.js breakdown path/to/file.jsDetect TODOs and Issues
# Find TODOs, FIXMEs, and issues
node bin/gmb.js detect-todos path/to/file.jsGet Testing Suggestions
# Get testing recommendations
node bin/gmb.js testing-suggestions path/to/file.jsCode Improvement Commands
Improve Code
# Improve a file with interactive confirmation
node bin/gmb.js improve path/to/file.js
# Dry run (show changes without applying)
node bin/gmb.js improve path/to/file.js --dry-run
# Iterative improvement
node bin/gmb.js improve path/to/file.js --iterativeRefactor Code
# Refactor for readability (default)
node bin/gmb.js refactor path/to/file.js
# Refactor for performance
node bin/gmb.js refactor path/to/file.js --goal performance
# Refactor to TypeScript
node bin/gmb.js refactor path/to/file.js --goal "migrate to TypeScript"
# Dry run
node bin/gmb.js refactor path/to/file.js --dry-runComprehensive Analysis
Code Review
# Perform comprehensive code review
node bin/gmb.js code-review path/to/file.jsProject Summary
# Analyze entire project
node bin/gmb.js project-summarize ./project-directory
# With custom file extensions
node bin/gmb.js project-summarize ./project-directory --extensions ".js,.ts,.jsx,.tsx"Examples
Example 1: Quick Code Review
# Review a React component
node bin/gmb.js code-review src/components/Button.jsxExample 2: Iterative Improvement
# Improve a utility function with multiple iterations
node bin/gmb.js improve src/utils/helpers.js --iterativeExample 3: Project Analysis
# Analyze a Node.js project
node bin/gmb.js project-summarize ./my-node-app --extensions ".js,.json,.md"Example 4: Refactoring for Performance
# Refactor a slow function
node bin/gmb.js refactor src/algorithms/sort.js --goal performance --dry-runConfiguration
Environment Variables
GEMINI_API_KEY: Your Google Gemini API key (required)GEMINI_MODEL: Gemini model to use (default: gemini-1.0-pro)GEMINI_TEMPERATURE: AI response creativity (0.0-1.0, default: 0.7)GEMINI_MAX_TOKENS: Maximum response length (default: 2048)DEFAULT_FORMAT: Default output format (default: markdown)DEBUG: Enable debug logging (default: false)
File Extensions
The project-summarize command supports custom file extensions:
- Default:
.js,.ts,.jsx,.tsx,.py,.java,.cpp,.c,.go,.rs,.php,.rb - Custom:
--extensions ".js,.ts,.vue,.svelte"
Output Formats
Most commands support different output formats:
markdown(default): Formatted markdown outputjson: JSON formatted outputplain: Plain text output
Testing
Run the test suite:
npm testThis will test the CLI structure and command availability without requiring an API key.
Troubleshooting
Common Issues
"GEMINI_API_KEY environment variable is not set"
- Set your API key:
export GEMINI_API_KEY="your-key" - Or add it to a
.envfile
- Set your API key:
"File not found"
- Check the file path is correct
- Ensure the file exists and is readable
"Permission denied"
- Check file/directory permissions
- Ensure you have read/write access
"No files found"
- Check file extensions in project-summarize
- Verify the directory contains files with specified extensions
Getting Help
# General help
node bin/gmb.js --help
# Command-specific help
node bin/gmb.js explain --help
node bin/gmb.js improve --helpContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
ISC License
Support
For issues and questions:
- Check the troubleshooting section
- Review existing issues
- Create a new issue with detailed information
