Skip to content

feat(Source control): add AI commit message generation#146

Draft
Mirrowel wants to merge 4 commits into
Zoo-Code-Org:mainfrom
Mirrowel:commit-msg-gen
Draft

feat(Source control): add AI commit message generation#146
Mirrowel wants to merge 4 commits into
Zoo-Code-Org:mainfrom
Mirrowel:commit-msg-gen

Conversation

@Mirrowel
Copy link
Copy Markdown

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:

  • Adds a new commit message support prompt (COMMIT_MESSAGE) so users can customize the generation behavior from prompt settings.
  • Adds Source Control menu contributions for Generate Commit Message with Zoo.
  • Adds a commit message provider that resolves the active VS Code Git repository, gathers Git context, calls the configured AI provider, and writes the result into the SCM input box.
  • Adds commitMessageApiConfigId so users can choose a dedicated API profile for commit message generation.
  • Adds settings UI for selecting the commit generation API profile under the commit message prompt settings.
  • Adds telemetry for successful commit message generation.
  • Adds focused Git context tests covering staged status parsing, rename/copy parsing, lockfile inclusion, and untracked-file handling.

While porting the Kilo feature, this PR intentionally simplifies the architecture for Zoo Code:

  • Removes legacy multi-IDE abstraction layers that are not currently needed in Zoo Code's VS Code-only implementation.
  • Uses Git state as the source of truth for commit generation rather than Zoo's normal .rooignore/file-access filtering. This is intentional because commit generation should describe what the user has staged or modified in Git.
  • Replaces synchronous per-file Git operations with async Git commands and batched diff generation where possible.
  • Fixes staged rename/copy parsing by using null-delimited Git status output and handling status codes such as R100 and C075 correctly.
  • Wires the commit message API profile selector into the existing SettingsView cached-state/save flow instead of bypassing the Save button with immediate webview messages.

Reviewer focus areas:

  • Whether using Git state rather than Zoo file-access filtering is the right behavior for commit message generation.
  • Whether the Source Control command placement and generated-message insertion behavior feel natural.
  • Whether the prompt/settings UI is clear enough or needs additional copy.
  • Whether this should remain VS Code-specific or preserve any of the legacy multi-IDE abstractions.

Test Procedure

Automated checks run locally:

  • pnpm check-types from src
  • pnpm check-types from webview-ui
  • pnpm check-types from packages/types
  • pnpm lint from src
  • pnpm lint from webview-ui
  • pnpm lint from packages/types
  • pnpm exec vitest run services/commit-message/__tests__/GitExtensionService.spec.ts from src

Packaging check:

  • pnpm vsix:nightly
  • Successfully produced bin/zoo-code-nightly-0.0.1.vsix

Manual verification steps for reviewers:

  1. Open a Git-backed workspace in VS Code with this extension build installed.
  2. Make and stage one or more source changes.
  3. Open Source Control and run Generate Commit Message with Zoo.
  4. Confirm the generated conventional commit message appears in the Git commit input box.
  5. Clear staged changes, leave an unstaged change, and run the command again.
  6. Confirm the command falls back to unstaged changes and still generates a message.
  7. Open Settings → Prompts → Commit Message Generation.
  8. Confirm the commit message prompt can be customized.
  9. Confirm the commit message API configuration selector persists after saving settings.

Environment notes:

  • Local build/test environment used Node 22.16.0, while the repository currently declares Node 20.20.2; commands completed despite the engine warning.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

image image image

Documentation Updates

  • No documentation updates are required for this draft PR.
  • Yes, documentation updates are required.

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>

Mirrowel added 2 commits May 16, 2026 04:24
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`.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ca331fb6-be2c-462c-90b0-409e2e7e6b6b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

❌ Patch coverage is 47.23127% with 324 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../services/commit-message/CommitMessageGenerator.ts 14.06% 110 Missing ⚠️
...c/services/commit-message/CommitMessageProvider.ts 22.46% 107 Missing ⚠️
src/services/commit-message/GitExtensionService.ts 56.85% 106 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@edelauna
Copy link
Copy Markdown
Contributor

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:

  1. Git context collector
    • GitExtensionService
    • Git status/diff parsing
    • rename/copy/untracked handling
    • focused tests
  2. Commit message prompt + generation service
    • COMMIT_MESSAGE support prompt
    • CommitMessageGenerator
    • API profile selection/fallback behavior
    • response cleanup
  3. VS Code SCM integration
    • command registration
    • Source Control menu placement
    • writing into the Git input box
    • UX behavior for existing commit text
  4. Settings UI / state plumbing
    • commitMessageApiConfigId
    • prompt settings UI
    • localization/settings wiring

We could maybe add some issues to our board to track the feature implementation.

@Mirrowel
Copy link
Copy Markdown
Author

Mirrowel commented May 17, 2026

@edelauna i'll see if it can be split. Though, i don't really see this logically being split much.
More or less lifted Kilo's commit message gen and cleaned it up.
But i never contributed to a big enough oss project, so.

Note: continuing in discord.

Mirrowel added 2 commits May 17, 2026 10:50
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
@edelauna
Copy link
Copy Markdown
Contributor

@edelauna i'll see if it can be split. Though, i don't really see this logically being split much. More or less lifted Kilo's commit message gen and cleaned it up. But i never contributed to a big enough oss project, so.

Note: continuing in discord.

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.

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.

[ENHANCEMENT] Add AI commit message generation

2 participants