IDE integration Gemini command multi-folder support + bump version (#6265)

Co-authored-by: matt korwel <matt.korwel@gmail.com>
This commit is contained in:
Shreya Keshive 2025-08-15 00:07:06 +00:00 committed by GitHub
parent cf7e6ff52d
commit db347eeee8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 42 additions and 31 deletions

2
package-lock.json generated
View File

@ -12721,7 +12721,7 @@
}, },
"packages/vscode-ide-companion": { "packages/vscode-ide-companion": {
"name": "gemini-cli-vscode-ide-companion", "name": "gemini-cli-vscode-ide-companion",
"version": "0.1.19", "version": "0.1.21",
"license": "LICENSE", "license": "LICENSE",
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "^1.15.1", "@modelcontextprotocol/sdk": "^1.15.1",

View File

@ -123,7 +123,7 @@ export class IdeClient {
this.setState( this.setState(
IDEConnectionStatus.Disconnected, IDEConnectionStatus.Disconnected,
`Failed to connect to IDE companion extension for ${this.currentIdeDisplayName}. Please ensure the extension is running and try restarting your terminal. To install the extension, run /ide install.`, `Failed to connect to IDE companion extension for ${this.currentIdeDisplayName}. Please ensure the extension is running. To install the extension, run /ide install.`,
true, true,
); );
} }
@ -261,7 +261,7 @@ export class IdeClient {
if (ideWorkspacePath === undefined) { if (ideWorkspacePath === undefined) {
return { return {
isValid: false, isValid: false,
error: `Failed to connect to IDE companion extension for ${currentIdeDisplayName}. Please ensure the extension is running and try refreshing your terminal. To install the extension, run /ide install.`, error: `Failed to connect to IDE companion extension for ${currentIdeDisplayName}. Please ensure the extension is running. To install the extension, run /ide install.`,
}; };
} }

View File

@ -106,8 +106,7 @@ class VsCodeInstaller implements IdeInstaller {
child_process.execSync(command, { stdio: 'pipe' }); child_process.execSync(command, { stdio: 'pipe' });
return { return {
success: true, success: true,
message: message: 'VS Code companion extension was installed successfully.',
'VS Code companion extension was installed successfully. Please restart your terminal to complete the setup.',
}; };
} catch (_error) { } catch (_error) {
return { return {

View File

@ -2,7 +2,7 @@
"name": "gemini-cli-vscode-ide-companion", "name": "gemini-cli-vscode-ide-companion",
"displayName": "Gemini CLI Companion", "displayName": "Gemini CLI Companion",
"description": "Enable Gemini CLI with direct access to your IDE workspace.", "description": "Enable Gemini CLI with direct access to your IDE workspace.",
"version": "0.1.19", "version": "0.1.21",
"publisher": "google", "publisher": "google",
"icon": "assets/icon.png", "icon": "assets/icon.png",
"repository": { "repository": {

View File

@ -25,6 +25,7 @@ vi.mock('vscode', () => ({
close: vi.fn(), close: vi.fn(),
}, },
showTextDocument: vi.fn(), showTextDocument: vi.fn(),
showWorkspaceFolderPick: vi.fn(),
}, },
workspace: { workspace: {
workspaceFolders: [], workspaceFolders: [],
@ -80,8 +81,7 @@ describe('activate', () => {
vi.mocked(context.globalState.get).mockReturnValue(undefined); vi.mocked(context.globalState.get).mockReturnValue(undefined);
await activate(context); await activate(context);
expect(showInformationMessageMock).toHaveBeenCalledWith( expect(showInformationMessageMock).toHaveBeenCalledWith(
'Gemini CLI Companion extension successfully installed. Please restart your terminal to enable full IDE integration.', 'Gemini CLI Companion extension successfully installed.',
'Re-launch Gemini CLI',
); );
}); });
@ -99,8 +99,10 @@ describe('activate', () => {
await activate(context); await activate(context);
expect(showInformationMessageMock).toHaveBeenCalled(); expect(showInformationMessageMock).toHaveBeenCalled();
await new Promise(process.nextTick); // Wait for the promise to resolve await new Promise(process.nextTick); // Wait for the promise to resolve
expect(vscode.commands.executeCommand).toHaveBeenCalledWith( const commandCallback = vi
'gemini-cli.runGeminiCLI', .mocked(vscode.commands.registerCommand)
); .mock.calls.find((call) => call[0] === 'gemini-cli.runGeminiCLI')?.[1];
expect(commandCallback).toBeDefined();
}); });
}); });

View File

@ -85,20 +85,8 @@ export async function activate(context: vscode.ExtensionContext) {
} }
if (!context.globalState.get(INFO_MESSAGE_SHOWN_KEY)) { if (!context.globalState.get(INFO_MESSAGE_SHOWN_KEY)) {
void vscode.window void vscode.window.showInformationMessage(
.showInformationMessage( 'Gemini CLI Companion extension successfully installed.',
'Gemini CLI Companion extension successfully installed. Please restart your terminal to enable full IDE integration.',
'Re-launch Gemini CLI',
)
.then(
(selection) => {
if (selection === 'Re-launch Gemini CLI') {
void vscode.commands.executeCommand('gemini-cli.runGeminiCLI');
}
},
(err) => {
log(`Failed to show information message: ${String(err)}`);
},
); );
context.globalState.update(INFO_MESSAGE_SHOWN_KEY, true); context.globalState.update(INFO_MESSAGE_SHOWN_KEY, true);
} }
@ -107,11 +95,33 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.workspace.onDidChangeWorkspaceFolders(() => { vscode.workspace.onDidChangeWorkspaceFolders(() => {
updateWorkspacePath(context); updateWorkspacePath(context);
}), }),
vscode.commands.registerCommand('gemini-cli.runGeminiCLI', () => { vscode.commands.registerCommand('gemini-cli.runGeminiCLI', async () => {
const workspaceFolders = vscode.workspace.workspaceFolders;
if (!workspaceFolders || workspaceFolders.length === 0) {
vscode.window.showInformationMessage(
'No folder open. Please open a folder to run Gemini CLI.',
);
return;
}
let selectedFolder: vscode.WorkspaceFolder | undefined;
if (workspaceFolders.length === 1) {
selectedFolder = workspaceFolders[0];
} else {
selectedFolder = await vscode.window.showWorkspaceFolderPick({
placeHolder: 'Select a folder to run Gemini CLI in',
});
}
if (selectedFolder) {
const geminiCmd = 'gemini'; const geminiCmd = 'gemini';
const terminal = vscode.window.createTerminal(`Gemini CLI`); const terminal = vscode.window.createTerminal({
name: `Gemini CLI (${selectedFolder.name})`,
cwd: selectedFolder.uri.fsPath,
});
terminal.show(); terminal.show();
terminal.sendText(geminiCmd); terminal.sendText(geminiCmd);
}
}), }),
vscode.commands.registerCommand('gemini-cli.showNotices', async () => { vscode.commands.registerCommand('gemini-cli.showNotices', async () => {
const noticePath = vscode.Uri.joinPath( const noticePath = vscode.Uri.joinPath(