feat: agentic git commit planner feature for improving commit quality - #335291
feat: agentic git commit planner feature for improving commit quality#335291Mathias Moser (matbmoser) wants to merge 8 commits into
Conversation
…proposal resolution
|
@microsoft-github-policy-service agree |
|
I am doing this for personal reasons, I have watched your documentary (very cool) and it inspired me to contribute features which may help me, my developers and others to be more effective with their commits. I am currently active in Open Source projects from the Eclipse Foundation, so I am aware on how to work on open source. Hope I am supporting you on making this great product even better! |
There was a problem hiding this comment.
🟡 Changes recommended
It includes unrelated/risky repo changes (settings + lockfiles) and the new planner flow needs fixes for cancellation/justification, plan lifecycle edge cases, and safer handling of staged/partially-staged state.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR proposes an agentic commit planning feature in the Git extension: Copilot can generate a multi-commit plan (grouping changed files into logical commits) and preview it as a dedicated SCM provider, with commands to edit/rearrange and optionally create the commits.
Changes:
- Add
AgenticCommitPlanner/agenticCommitPlanner.tsto request a Copilot-generated commit plan, render it as SCM resource groups, and provide actions (edit message, move/remove files, view changes, create commits). - Wire new Git commands and SCM menus for generating a plan and acting on it.
- Update localization strings for the new commands.
File summaries
| File | Description |
|---|---|
extensions/git/src/commands.ts |
Registers new commands that delegate to AgenticCommitPlanner. |
extensions/git/src/agenticCommitPlanner.ts |
Implements commit-plan generation via vscode.lm, SCM preview UI, and commit creation workflow. |
extensions/git/package.json |
Contributes the new commands + SCM title/input/context menus. |
extensions/git/package.nls.json |
Adds localized titles for the new commands. |
.vscode/settings.json |
Adds a terminal auto-approve rule (appears unrelated to feature). |
package-lock.json |
Removes several libc constraints for linux platform packages (appears unrelated/risky). |
scripts/package-lock.json |
Adds an empty lockfile for scripts/ (appears accidental). |
Review details
Files not reviewed (1)
- scripts/package-lock.json: Generated file
- Files reviewed: 5/7 changed files
- Comments generated: 11
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| private async create(commits: readonly PlannedCommit[]): Promise<void> { | ||
| if (commits.length === 0) { | ||
| return; | ||
| } | ||
|
|
||
| this._creating = true; | ||
| this.render(); | ||
|
|
| private renderOrClose(): void { | ||
| this._commits = this._commits.filter(commit => commit.files.length > 0); | ||
|
|
||
| if (this._commits.length === 0) { | ||
| this.close(); | ||
| return; | ||
| } | ||
|
|
||
| this.render(); | ||
| } |
| async function requestCommitPlan(repository: Repository): Promise<ProposedCommit[] | undefined> { | ||
| const changedUris = changedResourceUris(repository); | ||
|
|
||
| if (changedUris.length === 0) { | ||
| window.showInformationMessage(l10n.t('There are no changes to plan commits from.')); | ||
| return undefined; | ||
| } |
| const tokenSource = new CancellationTokenSource(); | ||
|
|
||
| try { | ||
| const proposals = await window.withProgress({ | ||
| location: ProgressLocation.SourceControl, | ||
| title: l10n.t('Planning commits with Copilot...'), | ||
| }, async () => { | ||
| // Build a compact description of each change (path + truncated diff). | ||
| const diffs = await collectDiffs(repository, changedUris); | ||
| return await requestProposals(model, diffs, tokenSource); | ||
| }); |
| "command.agenticCommitPlannerRemoveCommit": "Remove Commit From Plan", | ||
| "command.agenticCommitPlannerViewChanges": "View Commit Changes", | ||
| "command.agenticCommitPlannerMoveResources": "Move to Commit...", | ||
| "command.agenticCommitPlannerRemoveResources": "Remove From Plan", |
| this._sourceControl.count = this._commits.reduce((count, commit) => count + commit.files.length, 0); | ||
| this._sourceControl.actionButton = { | ||
| command: { | ||
| command: 'git.agenticCommitPlannerCreateAll', | ||
| title: this._commits.length === 1 | ||
| ? l10n.t('{0} Create Commit', '$(check)') | ||
| : l10n.t('{0} Create {1} Commits', '$(check)', this._commits.length), | ||
| arguments: [this._sourceControl] | ||
| }, | ||
| secondaryCommands: [[ | ||
| { command: 'git.agenticCommitPlannerRegenerate', title: l10n.t('Regenerate Plan'), arguments: [this._sourceControl] }, | ||
| { command: 'git.agenticCommitPlannerDiscard', title: l10n.t('Discard Plan'), arguments: [this._sourceControl] } | ||
| ]], | ||
| enabled: !this._creating | ||
| }; |
| async function requestCommitPlan(repository: Repository): Promise<ProposedCommit[] | undefined> { | ||
| const changedUris = changedResourceUris(repository); | ||
|
|
||
| if (changedUris.length === 0) { | ||
| window.showInformationMessage(l10n.t('There are no changes to plan commits from.')); | ||
| return undefined; | ||
| } |
| LanguageModelChatMessage.User(`Here are the changes:\n\n${changes}`), | ||
| ]; | ||
|
|
||
| const response = await model.sendRequest(prompt, {}, tokenSource.token); |
| { | ||
| "name": "scripts", | ||
| "lockfileVersion": 3, | ||
| "requires": true, | ||
| "packages": {} | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
I will be taking a look on what copilot has reviewed :) |
WHY
This PR is a proposal on how to include a git commit planner to visual studio code. The main idea is to allow the user instead of just generating a "message" for the commit, also allow copilot to "group" the files into different commits.
This is a problem which I am seeing specially on younger developers which are using AI and producing multiple changes and committing everything in one single commit, since "VS Code" only supports to generate "messages" for the commits (which is great!) but I believe it can even do more.
HOW
So I proposed to add one dropdown to the sparkle icon in the git extension:
Which allows copilot to:
I have tested in local and it works very well, more details are found in the issue.
WHAT
Feel free to add more, rename or close this PR, it should be just a proposal.
Copilot (Claude Opus 5) has assisted me on creating part of the code.
Closes #334943