feat(ai-ide): add AI-generated commit message button#17669
Open
sgraband wants to merge 2 commits into
Open
Conversation
… with hardcoded commands Introduces a generic abstract `PredefinedShellTool` base class for tools that run a fixed, hardcoded shell command. Subclasses declare a typed parameter schema and a `buildCommand(args)` method that assembles the exact shell command from the typed arguments — the LLM only supplies the typed arguments, so the command itself is fully controlled by the subclass. Unlike the general-purpose `shellExecute` tool, instances of `PredefinedShellTool` do not consult `ShellCommandPermissionService` and do not need to appear on the user shell allow/deny lists: the safety boundary is the subclass-controlled `buildCommand`, which must not be coercible into running arbitrary commands. The tool participates in the regular `ToolConfirmationMode` flow; callers driving an agent without a UI (where the per-call confirmation modal has nowhere to render) are responsible for arranging the appropriate confirmation via `ToolConfirmationManager`. Re-exported from the ai-terminal browser entry point for consumption by other packages.
Adds an AI-powered commit message generator to the SCM commit widget: - `GetGitChangesTool`, a `PredefinedShellTool` exposing the repository git diff (staged or all changes vs HEAD, plus untracked files as addition diffs for the all-changes case) to the agent. - `CommitMessageAgent` and `CommitMessageRunner` that drive a silent agent invocation against a private `MutableChatModel` to produce a commit message from the current changes, without surfacing a chat session in the panel. - `CommitMessageCommandContribution` and command wiring. - `AiAwareScmCommitWidget` rebinding the SCM commit widget to render the generate button, gated on `AIActivationService`, plus the prompt template and styles. - A one-time tool-allow gate in the runner that asks the user to flip `getGitChanges` to `ALWAYS_ALLOW` when it is currently on `CONFIRM` or `DISABLED`, with differentiated dialog copy for each case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Adds an AI-powered "generate commit message" button to the SCM commit widget.
The work spans two packages.
@theia/ai-terminalgets a newPredefinedShellToolbase class. It is anabstract
ToolProviderfor tools that run a fixed, hardcoded shell command.Subclasses declare a typed parameter schema and a
buildCommand(args)methodthat assembles the exact command. The LLM only supplies typed arguments, so the
command itself is fully controlled by the subclass. Unlike
shellExecute,instances do not consult
ShellCommandPermissionServiceand do not need toappear on the user's allow/deny lists. The tool itself participates in the
regular
ToolConfirmationModeflow.@theia/ai-ideuses that to add the commit-message generator:GetGitChangesTool(getGitChanges) returns the repository's git diff.With
stagedOnly = trueit runsgit diff --cached. WithstagedOnly = falseit combines
git diff HEADwith the contents of untracked, non-ignored files(rendered as addition diffs via
git diff --no-index) so brand-new filesreach the model. It is scoped to the selected SCM repository's root.
CommitMessageAgentis anAbstractStreamParsingChatAgentwith its ownprompt template. It is intentionally not registered as a
ChatAgent: it doesnot appear in the
@-mention list and is not invokable from the chat panel.CommitMessageRunnerdrives the agent silently against a privateMutableChatModel(no chat-panel session), writes the resulting message intothe SCM commit input, and handles cancellation, the overwrite-confirm prompt,
and a one-time tool-allow gate that asks the user to flip
getGitChangestoALWAYS_ALLOWwhen it is currently onCONFIRMorDISABLED. The dialogcopy differs between the two cases.
AiAwareScmCommitWidgetrebinds the SCM commit widget to overlay two sparklebuttons (staged / all). It is gated on
AIActivationService.isActive, sousers with AI globally disabled keep the stock SCM input with no overlay and
no extra padding. While one scope is generating, the other scope's button is
disabled with a tooltip explaining the situation.
CommitMessageCommandContributionexposes two commands that togglerun / cancel; the buttons fire them.
How to test
Workspace root is a git repo, AI features enabled, working model behind the
default/universalalias, SCM view open.@in the chat view:CommitMessagedoes not show up in the mention list.getGitChangeson the defaultConfirmmode, click a sparkle then pick Cancel: nothing runs, the tool stays on Confirm.Always allow; the next click runs with no dialog.getGitChangestoDisabledand click a sparkle: the dialog text changes to mention the tool is currently disabled, picking Allow flips it back toAlways allowand runs..gitignoreentry for some artefact: its content does not influence the generated message.Breaking changes
Attribution
Review checklist
nlsservice (for details, please see the Internationalization/Localization section in the Coding Guidelines)Reminder for reviewers