git-ai 1.1.3

Git AI: Automates commit messages using ChatGPT. Stage your files, and Git AI generates the messages.
Documentation
# Git AI Debug Output Example

This document shows an example of the comprehensive debug output generated when `RUST_LOG=debug` is set.

## Example Debug Output

```
=== GIT AI HOOK DEBUG SESSION ===

๐Ÿ“‹ INITIALIZATION
  Args:        commit_msg_file='.git/COMMIT_EDITMSG', source=None, sha1=None
  Build:       Debug build with performance profiling enabled

โš™๏ธ  SETUP & PREPARATION
  โ”‚ Generate instruction template     1.56ms    โœ“
  โ”‚ Count tokens                      306.13ms  โœ“
  โ”‚ Calculate instruction tokens      307.77ms  โœ“
  โ”” Get context size                 959.00ns  โœ“

๐Ÿ“ GIT DIFF PROCESSING
  โ”‚ Git diff generation               3.66ms    โœ“
  โ”‚ Processing diff changes           416.13ยตs  โœ“
  โ”‚ Repository patch generation       804.25ยตs  โœ“
  โ”” Files parsed from diff           1 files   โœ“

๐Ÿค– AI PROCESSING
  Multi-Step Attempt:                           FAILED
    โ”‚ Creating score function tool              โœ“
    โ”‚ OpenAI connection                         โœ“
    โ”” Error: Invalid function_call             โœ— No function named 'required' specified

  Single-Step Fallback:                        SUCCESS
    โ”‚ Creating commit function tool             โœ“ max_length=72
    โ”‚ OpenAI API call                   2.78s   โœ“
    โ”” Response parsing                          โœ“

๐Ÿ“Š ANALYSIS RESULTS
  Commit Message: 'Use multi-step commit message generation by default with fallback'
  Message Length: 65 characters (within 72 limit)

  Reasoning:
    The diff shows that both generate_commit_message and call_with_config
    now try multi-step generation first, falling back to local or single-step
    only on error. This changes core commit message logic, making multi-step
    the default approach (highest impact in source file).

๐Ÿ“ FILE ANALYSIS
  Total Files: 1

  File Details:
    src/openai.rs (modified)
      โ”‚ Summary: Default to multi-step commit message generation with fallback
      โ”‚ Impact Score: 1.00 (highest)
      โ”‚ Lines Changed: 35
      โ”” Category: source

๐Ÿ“ˆ STATISTICS SUMMARY
  โ”‚ Total Lines Changed:     35
  โ”‚ Average Impact Score:    1.00
  โ”‚
  โ”‚ By Category:
  โ”‚   โ”” source: 1
  โ”‚
  โ”‚ By Change Type:
  โ”‚   โ”” modified: 1

โฑ๏ธ  PERFORMANCE SUMMARY
  โ”‚ OpenAI request/response:          2.78s
  โ”‚ Total execution time:             3.46s
  โ”” Status:                           SUCCESS โœ“

๐ŸŽฏ FINAL RESULT
  [feature/function 7a18ca0] Use multi-step commit message generation by default with fallback
   1 file changed, 41 insertions(+), 3 deletions(-)
```

## Debug Output Sections Explained

### 1. Initialization

Shows the git hook arguments and build configuration.

### 2. Setup & Preparation

Tracks timing for:

- Template generation
- Token counting
- Context size calculation

### 3. Git Diff Processing

Shows:

- Diff generation timing
- File parsing results
- Number of files detected

### 4. AI Processing

Details the multi-step attempt and fallback:

- Multi-step errors (if any)
- Single-step fallback success
- API call duration

### 5. Analysis Results

Displays:

- Generated commit message
- Message length validation
- AI reasoning for the message

### 6. File Analysis

For each file:

- Path and operation type
- Summary of changes
- Impact score
- Lines changed
- File category

### 7. Statistics Summary

Aggregated data:

- Total lines changed
- Average impact score
- Files grouped by category
- Files grouped by change type

### 8. Performance Summary

Overall timing:

- API request/response time
- Total execution time
- Success status

### 9. Final Result

Shows the actual git commit result:

- Branch name
- Commit hash (short)
- Commit message
- File change statistics

## Enabling Debug Output

To see this debug output, run git commits with debug logging enabled:

```bash
RUST_LOG=debug git commit
```

Or set it globally for the session:

```bash
export RUST_LOG=debug
git commit
```

## Implementation Notes

The debug output is only shown when:

1. `RUST_LOG=debug` is set
2. The build is a debug build (or release with debug logging)
3. The git hook successfully processes the commit

The final result section would typically be populated by git itself after the hook completes, showing the actual commit hash and statistics.