summaryrefslogtreecommitdiff
path: root/packages/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src')
-rw-r--r--packages/cli/src/config/config.test.ts12
-rw-r--r--packages/cli/src/config/config.ts37
2 files changed, 27 insertions, 22 deletions
diff --git a/packages/cli/src/config/config.test.ts b/packages/cli/src/config/config.test.ts
index cd06f5dc..39259fe1 100644
--- a/packages/cli/src/config/config.test.ts
+++ b/packages/cli/src/config/config.test.ts
@@ -947,16 +947,20 @@ describe('loadCliConfig ideMode', () => {
expect(mcpServers['_ide_server'].trust).toBe(false);
});
- it('should throw an error if ideMode is true and no port is set', async () => {
+ it('should warn if ideMode is true and no port is set', async () => {
+ const consoleWarnSpy = vi
+ .spyOn(console, 'warn')
+ .mockImplementation(() => {});
process.argv = ['node', 'script.js', '--ide-mode'];
const argv = await parseArguments();
process.env.TERM_PROGRAM = 'vscode';
const settings: Settings = {};
- await expect(
- loadCliConfig(settings, [], 'test-session', argv),
- ).rejects.toThrow(
+ await loadCliConfig(settings, [], 'test-session', argv);
+ expect(consoleWarnSpy).toHaveBeenCalledWith(
+ '[WARN]',
'Could not connect to IDE. Make sure you have the companion VS Code extension installed from the marketplace or via /ide install.',
);
+ consoleWarnSpy.mockRestore();
});
it('should warn and overwrite if settings contain the reserved _ide_server name and ideMode is active', async () => {
diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts
index 83549139..c7c23901 100644
--- a/packages/cli/src/config/config.ts
+++ b/packages/cli/src/config/config.ts
@@ -312,27 +312,28 @@ export async function loadCliConfig(
);
}
const companionPort = process.env.GEMINI_CLI_IDE_SERVER_PORT;
- if (!companionPort) {
- throw new Error(
+ 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 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
- );
}
const sandboxConfig = await loadSandboxConfig(settings, argv);