Skip to content

feat: add commit command with AI-generated messages#1730

Merged
tusharmath merged 94 commits intomainfrom
feat/add-commit-cli-commands
Nov 12, 2025
Merged

feat: add commit command with AI-generated messages#1730
tusharmath merged 94 commits intomainfrom
feat/add-commit-cli-commands

Conversation

@laststylebender14
Copy link
Copy Markdown
Contributor

@laststylebender14 laststylebender14 commented Oct 14, 2025

closes: #1728

forge commit --max-diff 10000   // Limit git diff to 10KB 
forge commit  // No limits on git diff
  1. Without --preview: Analyzes your git diff, generates an AI commit message, and commits immediately
  2. With --preview: Shows the proposed commit message for review without committing

@github-actions github-actions Bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Oct 14, 2025
@laststylebender14 laststylebender14 force-pushed the feat/add-commit-cli-commands branch from 4f30aeb to 36c07b4 Compare October 15, 2025 07:38
@laststylebender14 laststylebender14 marked this pull request as ready for review October 15, 2025 07:44
@laststylebender14 laststylebender14 marked this pull request as draft October 15, 2025 07:45
Execute git log, branch name, and diff commands concurrently using tokio::join! to reduce latency. Also parallelize template rendering and provider/model retrieval. Add branch name to commit message prompt context.
@laststylebender14 laststylebender14 marked this pull request as ready for review October 15, 2025 07:51
Comment thread crates/forge_api/src/forge_api.rs Outdated
Comment thread crates/forge_app/src/app.rs Outdated
Comment thread templates/forge-commit-message-prompt.md Outdated
laststylebender14 and others added 6 commits October 15, 2025 14:02
Move commit message generation logic from ForgeApp to new GitApp class to improve separation of concerns and modularity. This change isolates git-related functionality and makes the codebase more maintainable.
Allow commit command to work with unstaged changes as fallback when no files are staged. Add parallel fetching of both staged and unstaged diffs, then use staged if available, otherwise unstaged. Update commit execution to use `-a` flag when no files are staged to include all tracked changes.
…es detection

Replace `.success()` with explicit exit code comparison to handle the specific behavior where exit code 1 indicates staged files exist, avoiding reliance on the general success check which may not accurately reflect the git diff-index semantics.
Add a new `/commit` CLI command that generates AI-powered commit messages
with flexible syntax support. The command accepts optional `preview` flag
to display the message without committing, and `max-diff-size` parameter
to limit the diff size sent to the AI model.
Replace heredoc-based commit message passing with direct -m flag for cleaner command execution and improved shell compatibility.
@tusharmath
Copy link
Copy Markdown
Collaborator

tusharmath commented Nov 3, 2025

FIXME

  • Commits produced don't follow and standards (need evals perhaps)
  • From ZSH the loader looses colors
  • forge commit command doesn't hide the loader after completion.
  • /commit should insert the commit message in the buffer using ! git commit ...

Comment thread crates/forge_spinner/src/lib.rs Outdated
…l command output

- Remove `preview` flag from `/commit` command - always preview message
- Pre-fill editor buffer with `git commit` command for user to execute
- Refactor Console to maintain persistent ForgeEditor instance
- Add `set_buffer()` method to ForgeEditor and Console for pre-filling input
- Update commit command handling to generate shell command with proper flags
- Simplify error handling by using `to_string()` instead of debug formatting
- Update tests to reflect removal of preview parameter
- Remove unused GitAppError import
- Simplify error display formatting by removing intermediate variable
- Remove special case handling for NoChangesToCommit error
- Fix line length formatting for git commit command
@laststylebender14 laststylebender14 marked this pull request as draft November 3, 2025 09:15
@laststylebender14 laststylebender14 marked this pull request as ready for review November 11, 2025 09:45
@tusharmath tusharmath merged commit 159a372 into main Nov 12, 2025
9 checks passed
@tusharmath tusharmath deleted the feat/add-commit-cli-commands branch November 12, 2025 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add a forge commit command

2 participants