1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {
Config,
getIdeDisplayName,
getIdeInstaller,
IDEConnectionStatus,
} from '@google/gemini-cli-core';
import {
CommandContext,
SlashCommand,
SlashCommandActionReturn,
CommandKind,
} from './types.js';
export const ideCommand = (config: Config | null): SlashCommand | null => {
if (!config?.getIdeMode()) {
return null;
}
const currentIDE = config.getIdeClient().getCurrentIde();
if (!currentIDE) {
throw new Error(
'IDE slash command should not be available if not running in an IDE',
);
}
return {
name: 'ide',
description: 'manage IDE integration',
kind: CommandKind.BUILT_IN,
subCommands: [
{
name: 'status',
description: 'check status of IDE integration',
kind: CommandKind.BUILT_IN,
action: (_context: CommandContext): SlashCommandActionReturn => {
const connection = config.getIdeClient().getConnectionStatus();
switch (connection?.status) {
case IDEConnectionStatus.Connected:
return {
type: 'message',
messageType: 'info',
content: `🟢 Connected`,
} as const;
case IDEConnectionStatus.Connecting:
return {
type: 'message',
messageType: 'info',
content: `🟡 Connecting...`,
} as const;
default: {
let content = `🔴 Disconnected`;
if (connection?.details) {
content += `: ${connection.details}`;
}
return {
type: 'message',
messageType: 'error',
content,
} as const;
}
}
},
},
{
name: 'install',
description: `install required IDE companion ${getIdeDisplayName(currentIDE)} extension `,
kind: CommandKind.BUILT_IN,
action: async (context) => {
const installer = getIdeInstaller(currentIDE);
if (!installer) {
context.ui.addItem(
{
type: 'error',
text: 'No installer available for your configured IDE.',
},
Date.now(),
);
return;
}
context.ui.addItem(
{
type: 'info',
text: `Installing IDE companion extension...`,
},
Date.now(),
);
const result = await installer.install();
context.ui.addItem(
{
type: result.success ? 'info' : 'error',
text: result.message,
},
Date.now(),
);
},
},
],
};
};
|