Skip to content

Conversation

@aqsaaqeel
Copy link

@aqsaaqeel aqsaaqeel commented Oct 22, 2025

  • Adds a flag for verbose output, including
  • diff statistics, repository details, and prompt info.
  • This helps debug LLM commit message generation issues.

Description

Adds a --toggle flag (verbose mode) to display detailed debug information during commit message generation.
Verbose output includes repository path, staged/unstaged/untracked file stats, diff summary, estimated LLM tokens, and full prompt in dry-run mode.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature which would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Other (please describe):

Related Issue

Fixes #86

Changes Made

  • Added --toggle flag to root command for verbose output.
  • Display repository details and file statistics when verbose is enabled.
  • Show full LLM prompt and diff statistics during dry-run if verbose is set.

Testing

  • Tested with Gemini API
  • Tested with Grok API
  • Tested on Windows
  • Tested on Linux
  • Tested on macOS
  • Added/updated tests (if applicable)

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have tested this in a real Git repository
  • I have read the CONTRIBUTING.md guidelines

Additional Notes

Verbose output is intended for debugging and help messages only; it does not affect commit generation or auto-commit behavior.


For Hacktoberfest Participants

  • This PR is submitted as part of Hacktoberfest 2025

Thank you for your contribution! 🎉

Summary by CodeRabbit

  • New Features
    • Added a --toggle / -t persistent flag to the CLI for enhanced control over command execution.
    • Introduced verbose mode providing detailed logging, including diff statistics, token estimates, and prompt length information for improved debugging and transparency.

- Adds a  flag for verbose output, including
- diff statistics, repository details, and prompt info.
- This helps debug LLM commit message generation issues.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

Walkthrough

This PR fixes the previously unused --toggle flag by converting it into a --verbose flag that controls conditional logging throughout the CLI commit message creation flow, wiring the flag through the command execution pipeline.

Changes

Cohort / File(s) Summary
Verbose flag addition
cmd/cli/createMsg.go
Added verbose parameter to CreateCommitMsg() and displayDryRunInfo() functions; implemented conditional verbose logging for repository path, file summaries, diff statistics (lines/characters), token estimates, and prompt length in dry-run output.
Toggle flag implementation
cmd/cli/root.go
Converted unused local --toggle flag into a global persistent --verbose flag (-t short form); wired flag value through command execution flow to pass as verbose parameter to CreateCommitMsg(); updated help text to reflect new verbose/debug toggles.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

The changes follow a consistent pattern of adding a verbose parameter and conditional logging statements. While they span two files and involve function signature updates, the modifications are homogeneous and straightforward—passing a boolean flag through and adding conditional output based on its value.

Possibly related PRs

Suggested labels

enhancement, hacktoberfest, go, bug

Suggested reviewers

  • DFanso

Poem

🐰 A toggle once lost, now verbose and bright,
Logs flow like carrots in the CLI light,
With -t we see what was hidden before,
Debugging's easier—what could we ask for? 🌟

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Feat: Add verbose mode for debugging and diff stats” succinctly captures the primary enhancement introduced by this pull request, namely the addition of a verbose/debug toggle to surface repository paths, diff statistics, and prompt details, without extraneous information or vagueness.
Linked Issues Check ✅ Passed The pull request fully addresses Issue #86 by integrating the previously unused toggle flag: it reads the “-t/--toggle” flag in root.go, passes the resulting verbose boolean into CreateCommitMsg, and uses it in createMsg.go to conditionally log debug data and diff statistics as required.
Out of Scope Changes Check ✅ Passed All code modifications are confined to wiring the toggle flag through the CLI command and enhancing verbose output in the existing createMsg and displayDryRunInfo functions; no unrelated files or features outside the scope of debugging and diff statistics have been altered.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
cmd/cli/createMsg.go (2)

134-138: Use prompt-based token estimate and rune-safe char count.

For accuracy, estimate tokens from the actual prompt (wrapper + changes), and count characters by runes to avoid under/over-reporting with UTF‑8.

Apply within this block:

-    pterm.Info.Printf("Diff statistics: %d lines, %d characters (within limits).\n", len(diffLines), len(changes))
-    inputTokens := estimateTokens(changes)
+    pterm.Info.Printf("Diff statistics: %d lines, %d characters (within limits).\n", len(diffLines), utf8.RuneCountInString(changes))
+    inputTokens := estimateTokens(types.BuildCommitPrompt(changes, nil))

Add import:

 import (
   "context"
   "errors"
   "fmt"
   "os"
   "os/exec"
   "runtime"
   "strings"
+  "unicode/utf8"

655-657: Hint mentions only long flag; include shorthand for discoverability.

-    pterm.Info.Println("Use --toggle flag to see debug details.")
+    pterm.Info.Println("Use --toggle (-t) to see debug details.")
cmd/cli/root.go (3)

33-36: Examples: show the -t alias alongside --toggle.

-    commit . --toggle
-    commit . --dry-run --toggle
+    commit . --toggle     # or: -t
+    commit . --dry-run --toggle     # or: -t

116-121: Support a 'verbose' alias at parse-time (non-breaking).

-        verbose, err := cmd.Flags().GetBool("toggle")
-        if err != nil {
-            return err
-        }
+        vToggle, err := cmd.Flags().GetBool("toggle")
+        if err != nil {
+            return err
+        }
+        vVerbose, _ := cmd.Flags().GetBool("verbose")
+        verbose := vToggle || vVerbose

136-140: Add a long-form alias flag for clarity while keeping --toggle for #86.

 rootCmd.PersistentFlags().Bool("dry-run", false, "Preview the prompt that would be sent to the LLM without making an API call")
 rootCmd.PersistentFlags().Bool("auto", false, "Automatically commit with the generated message")
 rootCmd.PersistentFlags().BoolP("toggle", "t", false, "Show verbose debug information (diff stats, full prompts, repository details)")
+rootCmd.PersistentFlags().Bool("verbose", false, "Alias for --toggle; show verbose debug information")
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9138c7b and fe66422.

📒 Files selected for processing (2)
  • cmd/cli/createMsg.go (5 hunks)
  • cmd/cli/root.go (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
cmd/cli/createMsg.go (2)
cmd/cli/store/store.go (3)
  • StoreMethods (18-21)
  • LLMProvider (50-53)
  • Config (56-59)
pkg/types/types.go (2)
  • LLMProvider (5-5)
  • Config (60-63)
cmd/cli/root.go (1)
cmd/cli/createMsg.go (1)
  • CreateCommitMsg (27-299)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build Go Binary (macos-latest)
  • GitHub Check: Build Go Binary (windows-latest)
  • GitHub Check: Test (1.23)
  • GitHub Check: Test (1.21)
  • GitHub Check: Test (1.22)
🔇 Additional comments (6)
cmd/cli/createMsg.go (6)

26-27: Doc update is clear.

Good addition clarifying verbose behavior.


71-75: Useful verbose repo/file summary.

Looks good and gated by the flag.


143-143: Pass-through of verbose to dry-run is correct.

Keeps output consistent across modes.


575-575: Signature change is consistent with caller.

No concerns; good separation of concerns.


647-650: Nice extra stat only when verbose.

No issues.


27-27: All CreateCommitMsg call sites updated Verified the sole usage at cmd/cli/root.go:121 matches the updated signature.

@DFanso DFanso self-requested a review October 23, 2025 15:51
@DFanso DFanso added enhancement New feature or request hacktoberfest Eligible for Hacktoberfest hacktoberfest-accepted Approved Hacktoberfest contribution go Pull requests that update go code labels Oct 23, 2025
Copy link
Owner

@DFanso DFanso left a comment

Choose a reason for hiding this comment

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

approved 🎊

@DFanso DFanso merged commit 446eedf into DFanso:main Oct 23, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code hacktoberfest Eligible for Hacktoberfest hacktoberfest-accepted Approved Hacktoberfest contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Unused Toggle Flag

2 participants