Skip to content

Improve Git diff handling and OpenAI API compatibility - #47

Merged
MikeGarde merged 3 commits into
mainfrom
lm-studio-fix
Sep 23, 2026
Merged

MikeGarde merged 3 commits into
mainfrom
lm-studio-fix

Conversation

@MikeGarde

@MikeGarde MikeGarde commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Overview

This PR enhances the tool's interaction with Git operations and OpenAI-compatible providers. It focuses on making the --diff command more versatile, ensuring large diffs do not overflow LLM context limits, and improving the compatibility of the OpenAI integration with diverse endpoints (such as LM Studio). Additionally, it improves the user experience by providing more descriptive error reporting for Git operations.

Changes

  • Enhanced Git Diff Support: Expanded the --diff flag to accept stdin, commit hashes, and specific file paths.
  • Context Management: Implemented logic to truncate large diffs at line boundaries, preventing LLM context overflows while preserving code integrity.
  • OpenAI Compatibility:
    • Added support for reasoning_content and handled null/missing content values.
    • Normalized base URLs to remove inconsistent prefixes.
    • Enabled usage of custom endpoints without requiring API keys.
    • Implemented dynamic model ID matching and validation.
  • Error Reporting & Reliability:
    • Captured stderr to provide human-readable Git error messages.
    • Added specific error reporting for Xcode license failures.
    • Synchronized tests that modify the current working directory (CWD) using a mutex to prevent race conditions.
  • Refactoring: Introduced a dedicated type alias for branch diffs to improve code maintainability.

Testing / Validation

  • Added unit tests specifically for Xcode license issues and standard Git failures.
  • Synchronized multi-threaded test execution for CWD-modifying operations.

Notes / Risks

  • Large diffs that exceed the LLM's context window will be truncated at the nearest line boundary; while this preserves valid lines, very large changes may be partially omitted from the prompt.
    PR message generated in 21.87s

Commits in this PR:

  • a5484b6 nhance OpenAI compatibility and Git error reporting
  • 803375e Enhance diff handling and context limits
  • 9322e4c Introduce type alias for branch diffs

OpenAI Compatibility:
- Support `reasoning_content` and handle null/missing content.
- Normalize base URLs to strip inconsistent prefixes.
- Allow OpenAI usage without API keys on custom endpoints.
- Implement flexible model ID matching and dynamic validation.

Git Improvements:
- Capture `stderr` and provide human-readable git errors.
- Add unit tests for Xcode license and standard git failures.

Provider: lmstudio google/gemma-4-12b-qat
Tokens:   prompt=7072, completion=2611, total=9683
@MikeGarde MikeGarde changed the title nhance OpenAI compatibility and Git error reporting Enhance OpenAI compatibility and Git error reporting Sep 23, 2026
- Refactor `--diff` to support stdin, commit hashes, and file paths.
- Truncate large diffs at line boundaries to prevent LLM context overflows.
- Add commit hash validation and specific Xcode license error reporting.
- Synchronize CWD-modifying tests with a mutex.
- Update documentation to clarify `--diff` flag usage.

Provider: lmstudio google/gemma-4-12b-qat
Tokens:   prompt=6479, completion=2986, total=9465
- Create a named type for the branch diffs data structure to improve code readability.

Provider: lmstudio google/gemma-4-12b-qat
Tokens:   prompt=434, completion=390, total=824
@MikeGarde MikeGarde changed the title Enhance OpenAI compatibility and Git error reporting Improve Git diff handling and OpenAI API compatibility Sep 23, 2026
@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.25993% with 99 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/llm/openai.rs 73.21% 45 Missing ⚠️
src/main.rs 0.00% 42 Missing ⚠️
src/setup.rs 0.00% 8 Missing ⚠️
src/lib.rs 88.00% 3 Missing ⚠️
src/git.rs 96.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/config.rs 79.70% <100.00%> (+0.80%) ⬆️
src/git.rs 67.11% <96.00%> (+5.85%) ⬆️
src/lib.rs 93.47% <88.00%> (-6.53%) ⬇️
src/setup.rs 0.00% <0.00%> (ø)
src/main.rs 3.33% <0.00%> (-0.02%) ⬇️
src/llm/openai.rs 44.55% <73.21%> (+17.45%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MikeGarde
MikeGarde merged commit 1e43165 into main Sep 23, 2026
5 checks passed
@MikeGarde
MikeGarde deleted the lm-studio-fix branch September 23, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant