Skip to content

Commit

Permalink
📝 Update README and architecture documentation
Browse files Browse the repository at this point in the history
Expand features and configuration sections in README.md for clarity.

- Add more detailed feature descriptions
- Include steps for configuring multiple LLM providers
- Clarify interactive commit process and options
- Improve visual elements with screenshots and badges

Update architecture documentation in git-iris-architecture.md.

- Include new sections for File Analyzers and Relevance Scoring
- Update data flow and key design patterns for readability
- Ensure consistency with the latest system updates
  • Loading branch information
hyperb1iss committed Aug 5, 2024
1 parent 9c3d61b commit 3e77279
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 78 deletions.
109 changes: 90 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,34 @@

<div align="center">

[![Crates.io][crates-shield]][crates]
[![CI/CD](https://github.com/hyperb1iss/git-iris/actions/workflows/cicd.yml/badge.svg)](https://github.com/hyperb1iss/git-iris/actions)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![GitHub Release][releases-shield]][releases]
[![License][license-shield]](LICENSE)

*Elevate your Git commit messages with the power of AI* 🚀

[Installation](#installation)[Configuration](#configuration)[Usage](#usage)[Contributing](#contributing)[License](#license)

</div>

<div align="center">
<img src="https://raw.githubusercontent.com/hyperb1iss/git-iris/main/docs/images/git-iris-screenshot-1.png" alt="Git-Iris Screenshot 1" width="48%">
<img src="https://raw.githubusercontent.com/hyperb1iss/git-iris/main/docs/images/git-iris-screenshot-2.png" alt="Git-Iris Screenshot 2" width="48%">
</div>

*Git-Iris in action: AI-powered commit message generation and interactive refinement*

## ✨ Features

- 🤖 **AI-powered commit message generation** using state-of-the-art language models
- 🔄 **Multi-provider support** (OpenAI GPT-4o, Anthropic Claude)
- 🎨 **Gitmoji integration** for expressive commit messages (enabled by default)
- 🔄 **Multi-provider support** (OpenAI GPT-4o, Anthropic Claude, Ollama)
- 🎨 **Gitmoji integration** for expressive commit messages
- 🖥️ **Interactive CLI** for reviewing and refining AI-generated messages (*vibes included*)
- 🔧 **Customizable prompts and instructions** to tailor AI output
- 🧠 **Smart context extraction** from Git repositories
- 📊 **Intelligent code change analysis** for context-aware suggestions
- 🖥️ **Interactive CLI** for reviewing and refining AI-generated messages
- 🔐 **Secure API key management**
- 🔍 **Relevance scoring** to prioritize important changes
- 📝 **Support for multiple programming languages** including Rust, JavaScript, Python, Java, and more
- 🚀 **Optimized for performance** with efficient token management

## 🛠️ Installation
Expand Down Expand Up @@ -52,27 +61,39 @@ cargo install git-iris

## ⚙️ Configuration

Git-Iris uses a configuration file located at `~/.config/git-iris/config.toml`. You can set up your preferred AI provider using the following commands:
Git-Iris uses a configuration file located at `~/.config/git-iris/config.toml`. Set up your preferred AI provider:

```bash
# For OpenAI
git-iris config --provider openai --api-key YOUR_OPENAI_API_KEY
# For Anthropic Claude
git-iris config --provider claude --api-key YOUR_CLAUDE_API_KEY
# For Ollama (no API key required)
git-iris config --provider ollama
```

Additional configuration options:

```bash
# Disable Gitmoji (enabled by default)
git-iris config --gitmoji false
# Set default provider
git-iris config --default-provider openai
# Enable/Disable Gitmoji
git-iris config --gitmoji true
# Set instructions
git-iris config --instructions "Ensure all commit messages are concise and descriptive."
# Set custom instructions
git-iris config --instructions "Always mention the ticket number in the commit message"
# Set token limit (example for 5000 tokens)
git-iris config --token-limit 5000
# Set token limit for a provider
git-iris config --provider openai --token-limit 4000
# Set model for a provider
git-iris config --provider openai --model gpt-4o
# Set additional parameters for a provider
git-iris config --provider openai --param temperature=0.7 --param max_tokens=150
```

For more detailed configuration information, please refer to our [Configuration Guide](CONFIG.md).
Expand All @@ -86,15 +107,15 @@ git-iris gen
```

Options:
- `-l`, `--log`: Enable logging to file
- `-a`, `--auto-commit`: Automatically commit with the generated message
- `-i`, `--instructions`: Provide custom instructions for this commit
- `--provider`: Specify an LLM provider
- `--provider`: Specify an LLM provider (openai, claude, ollama)
- `--no-gitmoji`: Disable Gitmoji for this commit
- `-l`, `--log`: Enable logging to file

Example:
```bash
git-iris gen -a -i "Focus on performance improvements" --provider openai
git-iris gen -a -i "Focus on performance improvements" --provider claude
```

### Interactive Commit Process
Expand All @@ -108,11 +129,61 @@ The interactive CLI allows you to refine and perfect your commit messages:
- Press Enter to commit
- Press Esc to cancel

### Gitmoji Support

Gitmoji is enabled by default, adding visual flair to your commit messages and making them more expressive and easier to categorize at a glance. Use the `--no-gitmoji` flag to disable it for a specific commit.
## 🎛️ Custom Instructions

Git-Iris allows you to provide custom instructions to guide the AI in generating commit messages. These instructions can be set globally in the configuration or provided on a per-commit basis.

### Setting Global Custom Instructions

```bash
git-iris config --instructions "Always include the ticket number and mention performance impacts"
```

### Providing Per-Commit Instructions

```bash
git-iris gen -i "Emphasize security implications of this change"
```

### Examples of Custom Instructions

1. **Ticket Number Integration**
```
Always start the commit message with the JIRA ticket number in square brackets
```

2. **Language-Specific Conventions**
```
For Rust files, mention any changes to public APIs or use of unsafe code
```

3. **Team-Specific Guidelines**
```
Follow the Angular commit message format: <type>(<scope>): <subject>
```

4. **Project-Specific Context**
```
For the authentication module, always mention if there are changes to the user model or permissions
```
5. **Performance Considerations**
```
Highlight any changes that might affect application performance, including database queries
```
6. **Documentation Updates**
```
If documentation files are changed, start the commit message with 'docs:'
```
7. **Breaking Changes**
```
Clearly indicate any breaking changes in the commit message, starting with 'BREAKING CHANGE:'
```
For more detailed usage information and advanced features, please refer to our [Usage Guide](USAGE.md).
Custom instructions allow you to tailor Git-Iris to your specific project needs, team conventions, or personal preferences. They provide a powerful way to ensure consistency and capture important context in your commit messages.
## 🤝 Contributing
Expand Down
106 changes: 47 additions & 59 deletions docs/git-iris-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Git-Iris is a Rust-based command-line tool that leverages AI to generate meaning
- Applies the final commit message

### 2.3 LLM Provider System
- Manages communication with various LLM APIs (OpenAI, Claude)
- Manages communication with various LLM APIs (OpenAI, Claude, Ollama)
- Handles API authentication and rate limiting
- Implements a plugin-like system for easy addition of new providers

Expand All @@ -43,18 +43,28 @@ Git-Iris is a Rust-based command-line tool that leverages AI to generate meaning
- Provides optional Gitmoji support for commit messages
- Manages Gitmoji mappings and integration logic

### 2.9 File Analyzers
- Implements language-specific analyzers for various file types
- Extracts relevant information from changed files to provide better context

### 2.10 Relevance Scoring
- Implements a scoring system to determine the relevance of changes
- Helps prioritize information for inclusion in the commit message

## 3. Data Flow

1. User invokes Git-Iris via CLI
2. CLI Interface parses input and retrieves configuration from `~/.config/git-iris/config.toml`
3. Git Integration extracts repository information
4. Context Extraction analyzes changes and builds context
5. Token Optimization ensures context fits within limits
6. Prompt Management constructs the full prompt
7. LLM Provider System sends the prompt to the selected LLM API
8. CLI Interface presents the generated message to the user
9. Interactive process allows user refinement
10. Git Integration applies the final commit (if confirmed)
5. File Analyzers process changed files and extract relevant information
6. Relevance Scoring prioritizes the extracted information
7. Token Optimization ensures context fits within limits
8. Prompt Management constructs the full prompt
9. LLM Provider System sends the prompt to the selected LLM API
10. CLI Interface presents the generated message to the user
11. Interactive process allows user refinement
12. Git Integration applies the final commit (if confirmed)

## 4. Key Design Patterns and Principles

Expand Down Expand Up @@ -136,77 +146,55 @@ graph TD
B --> E[Context Extraction]
E --> F[File Analyzers]
E --> G[Token Optimization]
E --> K[Relevance Scoring]
D --> H[Prompt Management]
H --> I[Gitmoji Integration]
G --> H
K --> H
E --> H
C -->|Reads/Writes| J[~/.config/git-iris/config.toml]
```

## 13. Configuration File Management

The configuration file (`~/.config/git-iris/config.toml`) is a crucial part of Git-Iris. Here's how it's managed:

- The `Config` struct in `config.rs` is responsible for loading, parsing, and saving the configuration file.
- The `get_config_path()` function determines the correct path for the configuration file:
```rust
fn get_config_path() -> Result<PathBuf> {
let mut path = config_dir().ok_or_else(|| anyhow!("Unable to determine config directory"))?;
path.push("git-iris");
std::fs::create_dir_all(&path)?;
path.push("config.toml");
Ok(path)
}
```
- This ensures that the configuration file is stored in the standard location for user-specific configuration files across different operating systems.
- The `Config::load()` method reads and parses the configuration file, creating a default configuration if the file doesn't exist.
- The `Config::save()` method writes the current configuration back to the file.

## 14. Error Handling Strategy

Git-Iris employs a robust error handling strategy:

- The `anyhow` crate is used for flexible error handling and propagation.
- Custom error types are defined for specific error cases where more context is needed.
- Errors are logged and presented to the user in a friendly format.
- In verbose mode, more detailed error information is provided for debugging purposes.

## 15. Asynchronous Operations
## 13. LLM Provider System

Git-Iris uses asynchronous programming to improve performance and responsiveness:
The LLM Provider System is designed to be extensible and support multiple AI providers:

- The `tokio` runtime is used for asynchronous operations.
- API calls to LLM providers are made asynchronously.
- The main application logic remains synchronous for simplicity, with async operations contained within specific components.
- Implements a common `LLMProvider` trait for all providers
- Currently supports OpenAI, Claude, and Ollama
- Each provider has its own implementation of API communication
- Providers can have custom configuration options

## 16. Resource Management
## 14. File Analyzer System

Git-Iris is designed to be efficient with system resources:
The File Analyzer System allows for language-specific analysis of changed files:

- Memory usage is optimized by processing Git diffs and file contents in chunks where possible.
- Temporary files are used for large diffs or file contents to avoid excessive memory usage.
- Resources like API connections are managed using Rust's RAII principles to ensure proper cleanup.
- Implements a `FileAnalyzer` trait for all file type analyzers
- Supports various languages and file types (Rust, JavaScript, Python, Java, C/C++, etc.)
- Extracts relevant information such as modified functions, classes, and structures
- Provides context for more accurate commit message generation

## 17. Internationalization and Localization
## 15. Token Optimization

While not currently implemented, the architecture is designed to easily support internationalization in the future:
The Token Optimization system ensures that the context provided to LLMs fits within token limits:

- User-facing strings are centralized for easy translation.
- The CLI interface is structured to allow for language-specific output.
- Implements intelligent truncation strategies
- Prioritizes the most relevant information
- Ensures the most important context is preserved within token limits

## 18. Logging and Diagnostics
## 16. Interactive Commit Process

Git-Iris includes a comprehensive logging system:
The Interactive Commit Process provides a user-friendly interface for reviewing and refining commit messages:

- Log messages are categorized by severity (debug, info, warning, error).
- In verbose mode, detailed logs are written to a file for debugging purposes.
- The logging system is designed to be non-intrusive during normal operation but highly informative when needed for troubleshooting.
- Allows navigation through multiple generated messages
- Provides options for editing messages and regenerating with new instructions
- Implements a visually appealing CLI interface with color coding and formatting

## 19. Update Mechanism
## 17. Relevance Scoring

While not part of the initial release, the architecture includes considerations for future self-update capabilities:
The Relevance Scoring system helps prioritize information for inclusion in commit messages:

- A version check mechanism can be implemented to compare the current version with the latest release.
- An update command can be added to the CLI to facilitate easy updates.
- Assigns scores to different types of changes (e.g., new files, modified functions)
- Uses heuristics to determine the importance of specific changes
- Helps focus the AI on the most significant aspects of the commit

This architecture design provides a solid foundation for Git-Iris, allowing for maintainability, extensibility, and robust performance as the project grows and evolves. The use of standard configuration file locations and well-structured components ensures that Git-Iris integrates well with users' existing workflows and system expectations.
This architecture provides a solid foundation for Git-Iris, allowing for maintainability, extensibility, and robust performance as the project grows and evolves. The modular design and use of well-established design patterns ensure that the system can be easily extended and modified as new requirements emerge.
Binary file added docs/images/git-iris-screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/git-iris-screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3e77279

Please sign in to comment.