[ide-mode] Create an IDE manager class to handle connecting to and exposing methods from the IDE server (#4797)

This commit is contained in:
christine betts
2025-07-25 17:46:55 +00:00
committed by GitHub
parent 3c16429fc4
commit 1b8ba5ca6b
14 changed files with 178 additions and 256 deletions

View File

@@ -19,8 +19,7 @@ import {
FileDiscoveryService,
TelemetryTarget,
FileFilteringOptions,
MCPServerConfig,
IDE_SERVER_NAME,
IdeClient,
} from '@google/gemini-cli-core';
import { Settings } from './settings.js';
@@ -264,6 +263,11 @@ export async function loadCliConfig(
process.env.TERM_PROGRAM === 'vscode' &&
!process.env.SANDBOX;
let ideClient: IdeClient | undefined;
if (ideMode) {
ideClient = new IdeClient();
}
const allExtensions = annotateActiveExtensions(
extensions,
argv.extensions || [],
@@ -355,37 +359,6 @@ export async function loadCliConfig(
}
}
if (ideMode) {
if (mcpServers[IDE_SERVER_NAME]) {
logger.warn(
`Ignoring user-defined MCP server config for "${IDE_SERVER_NAME}" as it is a reserved name.`,
);
}
const companionPort = process.env.GEMINI_CLI_IDE_SERVER_PORT;
if (companionPort) {
const httpUrl = `http://localhost:${companionPort}/mcp`;
mcpServers[IDE_SERVER_NAME] = new MCPServerConfig(
undefined, // command
undefined, // args
undefined, // env
undefined, // cwd
undefined, // url
httpUrl, // httpUrl
undefined, // headers
undefined, // tcp
undefined, // timeout
false, // trust
'IDE connection', // description
undefined, // includeTools
undefined, // excludeTools
);
} else {
logger.warn(
'Could not connect to IDE. Make sure you have the companion VS Code extension installed from the marketplace or via /ide install.',
);
}
}
const sandboxConfig = await loadSandboxConfig(settings, argv);
return new Config({
@@ -450,6 +423,7 @@ export async function loadCliConfig(
noBrowser: !!process.env.NO_BROWSER,
summarizeToolOutput: settings.summarizeToolOutput,
ideMode,
ideClient,
});
}