Skip to content

Conversation

mingcheng
Copy link
Owner

@mingcheng mingcheng commented Sep 26, 2025

Summary by Sourcery

Enhance client API integration with richer metadata and update project details for semantic commit messaging

Enhancements:

  • Refactor HTTP client setup to use formatted user agent string and include additional headers for client identification
  • Switch to using constant for organization ID
  • Add debug logging for the model name during model availability check

Build:

  • Bump version from 1.3.3 to 1.4.0

Documentation:

  • Revise README to promote semantic commit messages and include relevant reference links

Summary by CodeRabbit

  • Chores
    • Enhanced API request headers and user-agent for clearer client identification and improved supportability; proxy, timeout, and request behavior unchanged.
    • Added a debug log during model-name validation to aid troubleshooting without altering runtime behavior.
    • Updated internal file metadata timestamp only; no functional impact.

mingcheng and others added 18 commits September 26, 2025 14:41
- Add signoff option to CLI arguments in `cli.rs`
- Implement author name and email retrieval in `git.rs`
- Append signoff to commit message in `main.rs` if enabled
- Add tests for author name and email functions in `git.rs`

Signed-off-by: mingcheng <[email protected]>
- Implement detection of GIT_AUTO_SIGNOFF environment variable
- Enable signoff if environment variable is set to true or 1
- Update logic to combine CLI signoff option with environment variable check

Signed-off-by: mingcheng <[email protected]>
- Add `AIGITCOMMIT_SIGNOFF` environment variable to README
- Mention auto sign-off feature when variable is set to true

Signed-off-by: mingcheng <[email protected]>
- Replace static string formatting with variable interpolation in log messages
- Apply consistent formatting for trace logs across `git.rs` and `openai.rs`

Signed-off-by: mingcheng <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Update `AIGITCOMMIT_SIGNOFF` to `GIT_AUTO_SIGNOFF` in README for consistency
- Reflect the correct variable used in the code for auto signoff feature

Signed-off-by: mingcheng <[email protected]>
- Replace static string formatting with variable interpolation in log messages
- Apply consistent formatting for trace logs across `git.rs` and `openai.rs`

Signed-off-by: mingcheng <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Update `AIGITCOMMIT_SIGNOFF` to `GIT_AUTO_SIGNOFF` in README for consistency
- Reflect the correct variable used in the code for auto signoff feature

Signed-off-by: mingcheng <[email protected]>
- Adjust last modified timestamps in `main.rs` and `openai.rs` for accuracy
- Resolve merge conflict timestamp in `main.rs` to reflect latest update

Signed-off-by: mingcheng <[email protected]>
- Bump version from 1.3.2 to 1.3.3 in Cargo.toml
- Add "grok" to keywords list in package metadata
- Introduce --check flag in CLI to verify API key and model
- Implement check_model function to list and validate available models
- Integrate check logic in main.rs with error handling
- Comment out unused dependencies in Cargo.toml
- Update package categories in Cargo.toml
- Update error message formatting in main.rs to use direct variable interpolation
- Simplify debug and error messages in openai.rs with consistent string formatting
- Remove redundant string concatenation for cleaner code readability

Signed-off-by: mingcheng <[email protected]>
- Add support for signed-off-by line in commit messages with configurable option
- Refactor commit function to accept signoff parameter in git.rs
- Retrieve author name and email from repository config for signoff
- Remove redundant signoff logic from main.rs and centralize in git.rs
- Update commit call in main.rs to pass signoff requirement

Signed-off-by: mingcheng <[email protected]>
- Add instructions for generating git commit messages
- Include details on diff-based message creation
- Remove signed-off-by message from commit instructions
- Update examples to reflect recent commit styles

Signed-off-by: mingcheng <[email protected]>
- Update version from 1.3.3 to 1.4.0 in Cargo.toml
- Enhance system template with additional instructions
- Simplify and clarify template content for better usability
- Remove redundant information to streamline template
- Ensure template aligns with latest commit message standards

Signed-off-by: mingcheng <[email protected]>
- Add support for signed-off-by line in commit messages with configurable option
- Refactor commit function to accept signoff parameter in git.rs
- Retrieve author name and email from repository config for signoff
- Remove redundant signoff logic from main.rs and centralize in git.rs
- Update commit call in main.rs to pass signoff requirement

Signed-off-by: mingcheng <[email protected]>
- align indentation with recent project standards
- fix timestamp formatting inconsistencies
- remove redundant comments in template sections
- simplify conditional phrasing for clarity
- normalize line endings across file

Signed-off-by: mingcheng <[email protected]>
Co-authored-by: Copilot <[email protected]>
…ility 🔍

- Add --check CLI flag to verify API key and model availability
- Implement check_model method to list and validate models server-side
- Integrate error handling for invalid keys or models in main.rs
- Update Cargo.toml to remove unused dependencies and categorize package fields
- Store last validation timestamp in configuration for audit purposes

Signed-off-by: mingcheng <[email protected]>
- restructure opening statement for better readability
- add context note about commit relevance to current changes
- remove redundant quote charset references
- simplify content introduction phrases
- maintain consistency with system template formatting

Signed-off-by: mingcheng <[email protected]>
Copy link

coderabbitai bot commented Sep 26, 2025

Warning

Rate limit exceeded

@mingcheng has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 50 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 0934af6 and 0a7119d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !*.lock and included by none
📒 Files selected for processing (1)
  • src/openai.rs (2 hunks)

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Updates add a debug log during model-name validation, adjust OpenAI client initialization to use CLI constants for user-agent and headers (including a new X-Client-Type: CLI), and refresh a file header timestamp comment.

Changes

Cohort / File(s) Summary of Changes
OpenAI client headers and UA
src/openai.rs
Import CMD, CMD_ABOUT, CMD_ABOUT_URL from crate::cli; build User-Agent from CMD and CMD_ABOUT; add/adjust default headers to include X-Client-Type: CLI, HTTP-Referer (using CMD_ABOUT_URL), and X-Title (using CMD); minor formatting changes in client builder.
CLI logging tweak
src/main.rs
Add a debug log: debug!("the model name is {}", &model_name); inside model-name validation branch; no control-flow or error-handling changes.
Comment timestamp update
src/git.rs
Update header comment Last Modified timestamp only; no functional changes.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant App as main.rs
    participant OpenAI as src/openai.rs
    Note over App,OpenAI: Build HTTP client with updated headers/UA
    App->>OpenAI: request client build()
    OpenAI->>OpenAI: import CMD/CMD_ABOUT/CMD_ABOUT_URL
    OpenAI->>OpenAI: compose User-Agent = CMD + " " + CMD_ABOUT
    OpenAI->>OpenAI: set default headers (HTTP-Referer, X-Title, X-Client-Type: CLI)
    OpenAI-->>App: return configured client
Loading
sequenceDiagram
    autonumber
    participant User as CLI flow
    participant Main as src/main.rs
    Note over User,Main: model-name validation path
    User->>Main: provide model name
    Main->>Main: validate model name
    Main-->>Main: debug log "the model name is `…`"
    Main-->>User: continue existing flow (unchanged)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

enhancement

Poem

I nibble logs and tweak a UA,
A tiny header hops my way.
I whisper names the models say,
A timestamp blink — then off to play.
Carrot code and rabbit cheer, hooray! 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title “Develop” is overly generic and does not convey the primary changes introduced in the pull request, such as enhanced HTTP client headers, added debug logging, or the version bump. It fails to give team members a clear understanding of the main improvements when scanning the change history. Please replace the title with a concise, descriptive summary of the main changes—for example, “Enhance HTTP client headers, add model debug logging, and bump version to 1.4.0”—so it clearly reflects the PR’s objectives.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mingcheng mingcheng requested a review from Copilot September 26, 2025 09:13
Copy link

sourcery-ai bot commented Sep 26, 2025

Reviewer's Guide

Enhanced HTTP client identification with structured user-agent and custom headers, added debug logging for model name, updated documentation for semantic commits, and bumped version to 1.4.0.

File-Level Changes

Change Details Files
Enhanced HTTP client identification
  • Use CMD constant for organization ID
  • Format user-agent as "CMD(CMD_ABOUT)"
  • Add X-Client and X-Client-Type headers
src/openai.rs
Improved logging for model checks
  • Log selected model name in debug mode before API check
src/main.rs
Updated documentation with semantic commit guidelines
  • Revised README description focusing on semantic commit messages
  • Added References section with external links
README.md
Bumped package version for release
  • Increment version from 1.3.3 to 1.4.0
Cargo.toml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@mingcheng mingcheng marked this pull request as ready for review September 26, 2025 09:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the AI Git commit message generator to follow the Conventional Commits specification and improves system integration. The changes focus on standardizing commit message formatting, updating HTTP client headers, and adding documentation references.

  • Rewrote system templates to enforce Conventional Commits specification with detailed formatting rules
  • Enhanced HTTP client configuration with better user agent and additional headers
  • Added semantic commit documentation references to README

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
templates/system.txt Complete rewrite to implement Conventional Commits specification with detailed formatting rules and examples
templates/user.txt Updated instructional text for better clarity and context
src/openai.rs Enhanced HTTP client with improved user agent formatting and additional headers
src/main.rs Added debug logging for model name validation
src/git.rs Updated modification timestamp
README.md Added semantic commit references and updated description
Cargo.toml Version bump to 1.4.0

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Consider extracting the HTTP header setup (names and values) into constants or a helper method to avoid repetition and typos.
  • It may be useful to include the client version in the User-Agent string so API providers can easily identify which version of the CLI is in use.
  • Double-check the custom "HTTP-Referer" header name against the standard "Referer" header to ensure it’s being sent as intended.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the HTTP header setup (names and values) into constants or a helper method to avoid repetition and typos.
- It may be useful to include the client version in the User-Agent string so API providers can easily identify which version of the CLI is in use.
- Double-check the custom "HTTP-Referer" header name against the standard "Referer" header to ensure it’s being sent as intended.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

#12)

Signed-off-by: mingcheng <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Update src/openai.rs

Co-authored-by: Copilot <[email protected]>

Update src/openai.rs

Co-authored-by: Copilot <[email protected]>
@mingcheng mingcheng merged commit f46d750 into main Sep 26, 2025
1 of 11 checks passed
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