MontyAI is an intelligent code explanation tool that uses AI to help you understand code faster. Simply point MontyAI at a code file, and it will provide a clear, concise explanation of what the code does. Features syntax highlighting.
Add this line to your application's Gemfile:
gem 'monty-ai'
And then execute:
bundle install
Or install it yourself as:
gem install monty-ai
Explain a file:
monty-ai explain path/to/file.rb
Pipe code to MontyAI:
cat path/to/file.rb | monty-ai explain
monty-ai explain lib/my_app/parser.rb
Output:
Explanation for lib/my_app/parser.rb:
This code defines a Parser class that processes text files into structured data.
The Parser class has three main methods:
- parse: Takes a file path, reads the content, and converts it to a structured format.
- process_line: Handles individual lines from the file, applying regex patterns.
- extract_data: Pulls out specific information based on the content type.
The code implements the Strategy pattern by dynamically selecting different
processing methods based on the file's content type.
monty-ai version
MontyAI uses OpenAI or Anthropic APIs for code explanation. Set your API key in an environment variable:
# For OpenAI (default)
export OPENAI_API_KEY=your_api_key_here
# For Anthropic
export ANTHROPIC_API_KEY=your_api_key_here
- Ruby 3.0+
- OpenAI API Key
# Clone the repository
git clone https://github.com/scookdev/mitch_ai.git
# Install dependencies
bundle install
# Run tests
bundle exec rspec
# Run linter
bundle exec rubocop
To install this gem onto your local machine, run bundle exec rake install
.
Future versions will include:
- Multiple explanation formats (line-by-line, summary, concept)
- Interactive TTY interface
- Keyboard navigation
Contributions are welcome! Please check out our Contributing Guidelines.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
The gem is available as open source under the terms of the MIT License.
- Powered by OpenAI
- Inspired by the need for intelligent code reviews
If you encounter any problems or have suggestions, please open an issue.