feat(Source control): add AI commit message generation#146
Conversation
Introduce a new feature that automatically analyzes staged Git changes and generates conventional commit messages using AI. - Register the `zoo-code.generateCommitMessage` command and integrate it into the VS Code Source Control (SCM) view. - Add `commitMessageApiConfigId` to global state, allowing users to configure a dedicated API provider for commit generation. - Introduce a `COMMIT_MESSAGE` support prompt with a detailed default template optimized for conventional commits and Gitmoji. - Add UI settings for customizing the commit message prompt. - Track `COMMIT_MSG_GENERATED` events in telemetry. - Update build types to support theme-aware (light/dark) icons for extension commands.
…it operations This commit refactors the AI commit message generator to reduce complexity and prevent blocking the VS Code extension host during Git commands. - Rewrite `GitExtensionService` to use asynchronous `child_process.execFile` instead of synchronous `spawnSync`. - Remove abstraction layers (`CommitMessageOrchestrator`, `VSCodeCommitMessageAdapter`) and handle VS Code UI progress natively in `CommitMessageProvider`. - Drop custom ignore logic and lockfile exclusions in favor of Git's native status parsing (`--name-status` and `--porcelain`). - Centralize `commitMessageApiConfigId` state updates in `SettingsView`, removing the direct `vscode.postMessage` handler. - Add unit tests for the newly refactored `GitExtensionService`.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
Very cool feature! Could you break this into smaller PRs? A split like this would be easier to review, and also make this work extendable if other contributors wanted to build off some of the components used to deliver this feature:
We could maybe add some issues to our board to track the feature implementation. |
|
@edelauna i'll see if it can be split. Though, i don't really see this logically being split much. Note: continuing in discord. |
The commit message generator's git context gathering has been enhanced to provide better information to the LLM and surface underlying issues to the user. - Switch git command execution from `execFile` to `spawn` for improved process handling and output streaming. - Add detection for binary files using `git diff --numstat` and file buffer peeking, preventing raw binary data from polluting the context prompt. - Generate full inline diff representations for new, untracked text files rather than just listing their paths. - Update context gathering to collect and report non-fatal warnings (e.g., unavailable branch or missing commit history) via VS Code notifications instead of silently ignoring them. - Add fallback logic and console warnings when failing to load a selected commit message API profile. Also in this commit: - test(scm): add test coverage for `CommitMessageGenerator` and update `GitExtensionService` specs
…ncy injection - Extract `GitExtensionService` into a standalone `git-context` module and rename it to `GitContextCollector` with a consolidated `collect` API. - Introduce dependency injection to `CommitMessageGenerator` to accept external services (`getContextProxy`, `completePrompt`, `captureGenerated`, etc.) via constructor parameters. - Remove `vi.mock` global module overrides in `CommitMessageGenerator.spec.ts` in favor of injected test doubles. - Add an integration test to verify the end-to-end commit message generation flow using a temporary Git repository. Also in this commit: - fix(scm): append `--untracked-files=all` to the git status command to ensure files inside untracked directories are individually listed and diffed
Could you expand more as to the difficulties you’re having splitting this up? This is a large contribution for a first time contributor and makes changes across multiple components. It would be preferable to break this up for delivery, also every component does not necessarily need a UI elements to be considered feature complete. |
feat(scm): add AI commit message generation
Related GitHub Issue
Closes: #145
Description
This PR adds AI-assisted commit message generation to Zoo Code, porting the commit generation feature from Kilo Code and adapting it to Zoo Code's VS Code extension architecture.
The feature adds a Source Control command that analyzes the user's Git changes and writes an AI-generated conventional commit message into the VS Code Git input box. It uses staged changes first because staged files represent the exact commit contents. If nothing is staged, it falls back to unstaged changes so users can still generate a useful message before staging.
Key implementation details:
COMMIT_MESSAGE) so users can customize the generation behavior from prompt settings.Generate Commit Message with Zoo.commitMessageApiConfigIdso users can choose a dedicated API profile for commit message generation.While porting the Kilo feature, this PR intentionally simplifies the architecture for Zoo Code:
.rooignore/file-access filtering. This is intentional because commit generation should describe what the user has staged or modified in Git.R100andC075correctly.Reviewer focus areas:
Test Procedure
Automated checks run locally:
pnpm check-typesfromsrcpnpm check-typesfromwebview-uipnpm check-typesfrompackages/typespnpm lintfromsrcpnpm lintfromwebview-uipnpm lintfrompackages/typespnpm exec vitest run services/commit-message/__tests__/GitExtensionService.spec.tsfromsrcPackaging check:
pnpm vsix:nightlybin/zoo-code-nightly-0.0.1.vsixManual verification steps for reviewers:
Generate Commit Message with Zoo.Environment notes:
22.16.0, while the repository currently declares Node20.20.2; commands completed despite the engine warning.Pre-Submission Checklist
Screenshots / Videos
Documentation Updates
Additional Notes
This is currently intended as a draft PR for early review.
This contribution aligns with the roadmap's enhanced user experience goal by reducing friction in a common developer workflow and making Zoo Code useful directly from the Source Control panel.
Get in Touch
Discord: Mirrowel <@214161976534892545>