@google/gemini-cli 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/google-gemini-cli-0.1.12.tgz +0 -0
- package/dist/package.json +2 -3
- package/dist/src/acp/acp.d.ts +208 -0
- package/dist/src/acp/acp.js +193 -0
- package/dist/src/acp/acp.js.map +1 -0
- package/dist/src/acp/acpPeer.d.ts +8 -0
- package/dist/src/acp/acpPeer.js +537 -0
- package/dist/src/acp/acpPeer.js.map +1 -0
- package/dist/src/config/config.d.ts +3 -0
- package/dist/src/config/config.js +84 -10
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/extension.d.ts +2 -2
- package/dist/src/config/extension.js +21 -16
- package/dist/src/config/extension.js.map +1 -1
- package/dist/src/config/settings.d.ts +8 -0
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/gemini.js +6 -2
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/services/CommandService.d.ts +3 -1
- package/dist/src/services/CommandService.js +45 -8
- package/dist/src/services/CommandService.js.map +1 -1
- package/dist/src/ui/App.js +54 -50
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/commands/aboutCommand.d.ts +7 -0
- package/dist/src/ui/commands/aboutCommand.js +37 -0
- package/dist/src/ui/commands/aboutCommand.js.map +1 -0
- package/dist/src/ui/commands/authCommand.d.ts +7 -0
- package/dist/src/ui/commands/authCommand.js +14 -0
- package/dist/src/ui/commands/authCommand.js.map +1 -0
- package/dist/src/ui/commands/bugCommand.d.ts +7 -0
- package/dist/src/ui/commands/bugCommand.js +61 -0
- package/dist/src/ui/commands/bugCommand.js.map +1 -0
- package/dist/src/ui/commands/chatCommand.d.ts +7 -0
- package/dist/src/ui/commands/chatCommand.js +169 -0
- package/dist/src/ui/commands/chatCommand.js.map +1 -0
- package/dist/src/ui/commands/clearCommand.js +12 -2
- package/dist/src/ui/commands/clearCommand.js.map +1 -1
- package/dist/src/ui/commands/compressCommand.d.ts +7 -0
- package/dist/src/ui/commands/compressCommand.js +62 -0
- package/dist/src/ui/commands/compressCommand.js.map +1 -0
- package/dist/src/ui/commands/corgiCommand.d.ts +7 -0
- package/dist/src/ui/commands/corgiCommand.js +13 -0
- package/dist/src/ui/commands/corgiCommand.js.map +1 -0
- package/dist/src/ui/commands/docsCommand.d.ts +7 -0
- package/dist/src/ui/commands/docsCommand.js +29 -0
- package/dist/src/ui/commands/docsCommand.js.map +1 -0
- package/dist/src/ui/commands/editorCommand.d.ts +7 -0
- package/dist/src/ui/commands/editorCommand.js +14 -0
- package/dist/src/ui/commands/editorCommand.js.map +1 -0
- package/dist/src/ui/commands/extensionsCommand.d.ts +7 -0
- package/dist/src/ui/commands/extensionsCommand.js +29 -0
- package/dist/src/ui/commands/extensionsCommand.js.map +1 -0
- package/dist/src/ui/commands/ideCommand.d.ts +8 -0
- package/dist/src/ui/commands/ideCommand.js +123 -0
- package/dist/src/ui/commands/ideCommand.js.map +1 -0
- package/dist/src/ui/commands/mcpCommand.d.ts +7 -0
- package/dist/src/ui/commands/mcpCommand.js +204 -0
- package/dist/src/ui/commands/mcpCommand.js.map +1 -0
- package/dist/src/ui/commands/privacyCommand.d.ts +7 -0
- package/dist/src/ui/commands/privacyCommand.js +14 -0
- package/dist/src/ui/commands/privacyCommand.js.map +1 -0
- package/dist/src/ui/commands/quitCommand.d.ts +7 -0
- package/dist/src/ui/commands/quitCommand.js +32 -0
- package/dist/src/ui/commands/quitCommand.js.map +1 -0
- package/dist/src/ui/commands/restoreCommand.d.ts +8 -0
- package/dist/src/ui/commands/restoreCommand.js +126 -0
- package/dist/src/ui/commands/restoreCommand.js.map +1 -0
- package/dist/src/ui/commands/statsCommand.d.ts +7 -0
- package/dist/src/ui/commands/statsCommand.js +50 -0
- package/dist/src/ui/commands/statsCommand.js.map +1 -0
- package/dist/src/ui/commands/toolsCommand.d.ts +7 -0
- package/dist/src/ui/commands/toolsCommand.js +54 -0
- package/dist/src/ui/commands/toolsCommand.js.map +1 -0
- package/dist/src/ui/commands/types.d.ts +36 -2
- package/dist/src/ui/components/ContextSummaryDisplay.d.ts +6 -1
- package/dist/src/ui/components/ContextSummaryDisplay.js +48 -21
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.js +109 -51
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.js +25 -24
- package/dist/src/ui/components/ThemeDialog.js.map +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.js +3 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -1
- package/dist/src/ui/components/shared/MaxSizedBox.js +69 -2
- package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -1
- package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +3 -1
- package/dist/src/ui/components/shared/RadioButtonSelect.js +60 -10
- package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.js +1 -1
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
- package/dist/src/ui/constants.d.ts +1 -0
- package/dist/src/ui/constants.js +1 -0
- package/dist/src/ui/constants.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.d.ts +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.js +35 -11
- package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +2 -9
- package/dist/src/ui/hooks/slashCommandProcessor.js +42 -843
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useAuthCommand.js +3 -2
- package/dist/src/ui/hooks/useAuthCommand.js.map +1 -1
- package/dist/src/ui/hooks/useCompletion.d.ts +1 -0
- package/dist/src/ui/hooks/useCompletion.js +25 -3
- package/dist/src/ui/hooks/useCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useFocus.d.ts +6 -0
- package/dist/src/ui/hooks/useFocus.js +41 -0
- package/dist/src/ui/hooks/useFocus.js.map +1 -0
- package/dist/src/ui/hooks/useGeminiStream.js +17 -0
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/usePrivacySettings.js +5 -5
- package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -1
- package/dist/src/ui/themes/ansi-light.js +1 -1
- package/dist/src/ui/themes/ansi-light.js.map +1 -1
- package/dist/src/ui/themes/googlecode.js +1 -1
- package/dist/src/ui/themes/googlecode.js.map +1 -1
- package/dist/src/ui/themes/xcode.js +1 -1
- package/dist/src/ui/themes/xcode.js.map +1 -1
- package/dist/src/ui/utils/updateCheck.js +4 -0
- package/dist/src/ui/utils/updateCheck.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/dist/google-gemini-cli-0.1.11.tgz +0 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { DiscoveredMCPTool, getMCPDiscoveryState, getMCPServerStatus, MCPDiscoveryState, MCPServerStatus, } from '@google/gemini-cli-core';
|
|
7
|
+
import open from 'open';
|
|
8
|
+
const COLOR_GREEN = '\u001b[32m';
|
|
9
|
+
const COLOR_YELLOW = '\u001b[33m';
|
|
10
|
+
const COLOR_CYAN = '\u001b[36m';
|
|
11
|
+
const RESET_COLOR = '\u001b[0m';
|
|
12
|
+
const getMcpStatus = async (context, showDescriptions, showSchema, showTips = false) => {
|
|
13
|
+
const { config } = context.services;
|
|
14
|
+
if (!config) {
|
|
15
|
+
return {
|
|
16
|
+
type: 'message',
|
|
17
|
+
messageType: 'error',
|
|
18
|
+
content: 'Config not loaded.',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const toolRegistry = await config.getToolRegistry();
|
|
22
|
+
if (!toolRegistry) {
|
|
23
|
+
return {
|
|
24
|
+
type: 'message',
|
|
25
|
+
messageType: 'error',
|
|
26
|
+
content: 'Could not retrieve tool registry.',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const mcpServers = config.getMcpServers() || {};
|
|
30
|
+
const serverNames = Object.keys(mcpServers);
|
|
31
|
+
const blockedMcpServers = config.getBlockedMcpServers() || [];
|
|
32
|
+
if (serverNames.length === 0 && blockedMcpServers.length === 0) {
|
|
33
|
+
const docsUrl = 'https://goo.gle/gemini-cli-docs-mcp';
|
|
34
|
+
if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
|
|
35
|
+
return {
|
|
36
|
+
type: 'message',
|
|
37
|
+
messageType: 'info',
|
|
38
|
+
content: `No MCP servers configured. Please open the following URL in your browser to view documentation:\n${docsUrl}`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Open the URL in the browser
|
|
43
|
+
await open(docsUrl);
|
|
44
|
+
return {
|
|
45
|
+
type: 'message',
|
|
46
|
+
messageType: 'info',
|
|
47
|
+
content: `No MCP servers configured. Opening documentation in your browser: ${docsUrl}`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Check if any servers are still connecting
|
|
52
|
+
const connectingServers = serverNames.filter((name) => getMCPServerStatus(name) === MCPServerStatus.CONNECTING);
|
|
53
|
+
const discoveryState = getMCPDiscoveryState();
|
|
54
|
+
let message = '';
|
|
55
|
+
// Add overall discovery status message if needed
|
|
56
|
+
if (discoveryState === MCPDiscoveryState.IN_PROGRESS ||
|
|
57
|
+
connectingServers.length > 0) {
|
|
58
|
+
message += `${COLOR_YELLOW}⏳ MCP servers are starting up (${connectingServers.length} initializing)...${RESET_COLOR}\n`;
|
|
59
|
+
message += `${COLOR_CYAN}Note: First startup may take longer. Tool availability will update automatically.${RESET_COLOR}\n\n`;
|
|
60
|
+
}
|
|
61
|
+
message += 'Configured MCP servers:\n\n';
|
|
62
|
+
const allTools = toolRegistry.getAllTools();
|
|
63
|
+
for (const serverName of serverNames) {
|
|
64
|
+
const serverTools = allTools.filter((tool) => tool instanceof DiscoveredMCPTool && tool.serverName === serverName);
|
|
65
|
+
const status = getMCPServerStatus(serverName);
|
|
66
|
+
// Add status indicator with descriptive text
|
|
67
|
+
let statusIndicator = '';
|
|
68
|
+
let statusText = '';
|
|
69
|
+
switch (status) {
|
|
70
|
+
case MCPServerStatus.CONNECTED:
|
|
71
|
+
statusIndicator = '🟢';
|
|
72
|
+
statusText = 'Ready';
|
|
73
|
+
break;
|
|
74
|
+
case MCPServerStatus.CONNECTING:
|
|
75
|
+
statusIndicator = '🔄';
|
|
76
|
+
statusText = 'Starting... (first startup may take longer)';
|
|
77
|
+
break;
|
|
78
|
+
case MCPServerStatus.DISCONNECTED:
|
|
79
|
+
default:
|
|
80
|
+
statusIndicator = '🔴';
|
|
81
|
+
statusText = 'Disconnected';
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
// Get server description if available
|
|
85
|
+
const server = mcpServers[serverName];
|
|
86
|
+
let serverDisplayName = serverName;
|
|
87
|
+
if (server.extensionName) {
|
|
88
|
+
serverDisplayName += ` (from ${server.extensionName})`;
|
|
89
|
+
}
|
|
90
|
+
// Format server header with bold formatting and status
|
|
91
|
+
message += `${statusIndicator} \u001b[1m${serverDisplayName}\u001b[0m - ${statusText}`;
|
|
92
|
+
// Add tool count with conditional messaging
|
|
93
|
+
if (status === MCPServerStatus.CONNECTED) {
|
|
94
|
+
message += ` (${serverTools.length} tools)`;
|
|
95
|
+
}
|
|
96
|
+
else if (status === MCPServerStatus.CONNECTING) {
|
|
97
|
+
message += ` (tools will appear when ready)`;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
message += ` (${serverTools.length} tools cached)`;
|
|
101
|
+
}
|
|
102
|
+
// Add server description with proper handling of multi-line descriptions
|
|
103
|
+
if (showDescriptions && server?.description) {
|
|
104
|
+
const descLines = server.description.trim().split('\n');
|
|
105
|
+
if (descLines) {
|
|
106
|
+
message += ':\n';
|
|
107
|
+
for (const descLine of descLines) {
|
|
108
|
+
message += ` ${COLOR_GREEN}${descLine}${RESET_COLOR}\n`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
message += '\n';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
message += '\n';
|
|
117
|
+
}
|
|
118
|
+
// Reset formatting after server entry
|
|
119
|
+
message += RESET_COLOR;
|
|
120
|
+
if (serverTools.length > 0) {
|
|
121
|
+
serverTools.forEach((tool) => {
|
|
122
|
+
if (showDescriptions && tool.description) {
|
|
123
|
+
// Format tool name in cyan using simple ANSI cyan color
|
|
124
|
+
message += ` - ${COLOR_CYAN}${tool.name}${RESET_COLOR}`;
|
|
125
|
+
// Handle multi-line descriptions by properly indenting and preserving formatting
|
|
126
|
+
const descLines = tool.description.trim().split('\n');
|
|
127
|
+
if (descLines) {
|
|
128
|
+
message += ':\n';
|
|
129
|
+
for (const descLine of descLines) {
|
|
130
|
+
message += ` ${COLOR_GREEN}${descLine}${RESET_COLOR}\n`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
message += '\n';
|
|
135
|
+
}
|
|
136
|
+
// Reset is handled inline with each line now
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// Use cyan color for the tool name even when not showing descriptions
|
|
140
|
+
message += ` - ${COLOR_CYAN}${tool.name}${RESET_COLOR}\n`;
|
|
141
|
+
}
|
|
142
|
+
const parameters = tool.schema.parametersJsonSchema ?? tool.schema.parameters;
|
|
143
|
+
if (showSchema && parameters) {
|
|
144
|
+
// Prefix the parameters in cyan
|
|
145
|
+
message += ` ${COLOR_CYAN}Parameters:${RESET_COLOR}\n`;
|
|
146
|
+
const paramsLines = JSON.stringify(parameters, null, 2)
|
|
147
|
+
.trim()
|
|
148
|
+
.split('\n');
|
|
149
|
+
if (paramsLines) {
|
|
150
|
+
for (const paramsLine of paramsLines) {
|
|
151
|
+
message += ` ${COLOR_GREEN}${paramsLine}${RESET_COLOR}\n`;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
message += ' No tools available\n';
|
|
159
|
+
}
|
|
160
|
+
message += '\n';
|
|
161
|
+
}
|
|
162
|
+
for (const server of blockedMcpServers) {
|
|
163
|
+
let serverDisplayName = server.name;
|
|
164
|
+
if (server.extensionName) {
|
|
165
|
+
serverDisplayName += ` (from ${server.extensionName})`;
|
|
166
|
+
}
|
|
167
|
+
message += `🔴 \u001b[1m${serverDisplayName}\u001b[0m - Blocked\n\n`;
|
|
168
|
+
}
|
|
169
|
+
// Add helpful tips when no arguments are provided
|
|
170
|
+
if (showTips) {
|
|
171
|
+
message += '\n';
|
|
172
|
+
message += `${COLOR_CYAN}💡 Tips:${RESET_COLOR}\n`;
|
|
173
|
+
message += ` • Use ${COLOR_CYAN}/mcp desc${RESET_COLOR} to show server and tool descriptions\n`;
|
|
174
|
+
message += ` • Use ${COLOR_CYAN}/mcp schema${RESET_COLOR} to show tool parameter schemas\n`;
|
|
175
|
+
message += ` • Use ${COLOR_CYAN}/mcp nodesc${RESET_COLOR} to hide descriptions\n`;
|
|
176
|
+
message += ` • Press ${COLOR_CYAN}Ctrl+T${RESET_COLOR} to toggle tool descriptions on/off\n`;
|
|
177
|
+
message += '\n';
|
|
178
|
+
}
|
|
179
|
+
// Make sure to reset any ANSI formatting at the end to prevent it from affecting the terminal
|
|
180
|
+
message += RESET_COLOR;
|
|
181
|
+
return {
|
|
182
|
+
type: 'message',
|
|
183
|
+
messageType: 'info',
|
|
184
|
+
content: message,
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
export const mcpCommand = {
|
|
188
|
+
name: 'mcp',
|
|
189
|
+
description: 'list configured MCP servers and tools',
|
|
190
|
+
action: async (context, args) => {
|
|
191
|
+
const lowerCaseArgs = args.toLowerCase().split(/\s+/).filter(Boolean);
|
|
192
|
+
const hasDesc = lowerCaseArgs.includes('desc') || lowerCaseArgs.includes('descriptions');
|
|
193
|
+
const hasNodesc = lowerCaseArgs.includes('nodesc') ||
|
|
194
|
+
lowerCaseArgs.includes('nodescriptions');
|
|
195
|
+
const showSchema = lowerCaseArgs.includes('schema');
|
|
196
|
+
// Show descriptions if `desc` or `schema` is present,
|
|
197
|
+
// but `nodesc` takes precedence and disables them.
|
|
198
|
+
const showDescriptions = !hasNodesc && (hasDesc || showSchema);
|
|
199
|
+
// Show tips only when no arguments are provided
|
|
200
|
+
const showTips = lowerCaseArgs.length === 0;
|
|
201
|
+
return getMcpStatus(context, showDescriptions, showSchema, showTips);
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=mcpCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/mcpCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,WAAW,GAAG,WAAW,CAAC;AAEhC,MAAM,YAAY,GAAG,KAAK,EACxB,OAAuB,EACvB,gBAAyB,EACzB,UAAmB,EACnB,WAAoB,KAAK,EACU,EAAE;IACrC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;IACpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,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AAC,cAAc,CAAC,CAAC;QAC3E,MAAM,SAAS,GACb,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAChC,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAC3C,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEpD,sDAAsD;QACtD,mDAAmD;QACnD,MAAM,gBAAgB,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC;QAE/D,gDAAgD;QAChD,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC;QAE5C,OAAO,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACvE,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export const privacyCommand = {
|
|
7
|
+
name: 'privacy',
|
|
8
|
+
description: 'display the privacy notice',
|
|
9
|
+
action: () => ({
|
|
10
|
+
type: 'dialog',
|
|
11
|
+
dialog: 'privacy',
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=privacyCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacyCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/privacyCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,4BAA4B;IACzC,MAAM,EAAE,GAA2B,EAAE,CAAC,CAAC;QACrC,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,SAAS;KAClB,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { formatDuration } from '../utils/formatters.js';
|
|
7
|
+
export const quitCommand = {
|
|
8
|
+
name: 'quit',
|
|
9
|
+
altName: 'exit',
|
|
10
|
+
description: 'exit the cli',
|
|
11
|
+
action: (context) => {
|
|
12
|
+
const now = Date.now();
|
|
13
|
+
const { sessionStartTime } = context.session.stats;
|
|
14
|
+
const wallDuration = now - sessionStartTime.getTime();
|
|
15
|
+
return {
|
|
16
|
+
type: 'quit',
|
|
17
|
+
messages: [
|
|
18
|
+
{
|
|
19
|
+
type: 'user',
|
|
20
|
+
text: `/quit`, // Keep it consistent, even if /exit was used
|
|
21
|
+
id: now - 1,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'quit',
|
|
25
|
+
duration: formatDuration(wallDuration),
|
|
26
|
+
id: now,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=quitCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quitCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/quitCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,MAAM,CAAC,MAAM,WAAW,GAAiB;IACvC,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,cAAc;IAC3B,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACnD,MAAM,YAAY,GAAG,GAAG,GAAG,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAEtD,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,OAAO,EAAE,6CAA6C;oBAC5D,EAAE,EAAE,GAAG,GAAG,CAAC;iBACZ;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,cAAc,CAAC,YAAY,CAAC;oBACtC,EAAE,EAAE,GAAG;iBACR;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type SlashCommand } from './types.js';
|
|
7
|
+
import { Config } from '@google/gemini-cli-core';
|
|
8
|
+
export declare const restoreCommand: (config: Config | null) => SlashCommand | null;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import * as fs from 'fs/promises';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
async function restoreAction(context, args) {
|
|
9
|
+
const { services, ui } = context;
|
|
10
|
+
const { config, git: gitService } = services;
|
|
11
|
+
const { addItem, loadHistory } = ui;
|
|
12
|
+
const checkpointDir = config?.getProjectTempDir()
|
|
13
|
+
? path.join(config.getProjectTempDir(), 'checkpoints')
|
|
14
|
+
: undefined;
|
|
15
|
+
if (!checkpointDir) {
|
|
16
|
+
return {
|
|
17
|
+
type: 'message',
|
|
18
|
+
messageType: 'error',
|
|
19
|
+
content: 'Could not determine the .gemini directory path.',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
// Ensure the directory exists before trying to read it.
|
|
24
|
+
await fs.mkdir(checkpointDir, { recursive: true });
|
|
25
|
+
const files = await fs.readdir(checkpointDir);
|
|
26
|
+
const jsonFiles = files.filter((file) => file.endsWith('.json'));
|
|
27
|
+
if (!args) {
|
|
28
|
+
if (jsonFiles.length === 0) {
|
|
29
|
+
return {
|
|
30
|
+
type: 'message',
|
|
31
|
+
messageType: 'info',
|
|
32
|
+
content: 'No restorable tool calls found.',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const truncatedFiles = jsonFiles.map((file) => {
|
|
36
|
+
const components = file.split('.');
|
|
37
|
+
if (components.length <= 1) {
|
|
38
|
+
return file;
|
|
39
|
+
}
|
|
40
|
+
components.pop();
|
|
41
|
+
return components.join('.');
|
|
42
|
+
});
|
|
43
|
+
const fileList = truncatedFiles.join('\n');
|
|
44
|
+
return {
|
|
45
|
+
type: 'message',
|
|
46
|
+
messageType: 'info',
|
|
47
|
+
content: `Available tool calls to restore:\n\n${fileList}`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const selectedFile = args.endsWith('.json') ? args : `${args}.json`;
|
|
51
|
+
if (!jsonFiles.includes(selectedFile)) {
|
|
52
|
+
return {
|
|
53
|
+
type: 'message',
|
|
54
|
+
messageType: 'error',
|
|
55
|
+
content: `File not found: ${selectedFile}`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const filePath = path.join(checkpointDir, selectedFile);
|
|
59
|
+
const data = await fs.readFile(filePath, 'utf-8');
|
|
60
|
+
const toolCallData = JSON.parse(data);
|
|
61
|
+
if (toolCallData.history) {
|
|
62
|
+
if (!loadHistory) {
|
|
63
|
+
// This should not happen
|
|
64
|
+
return {
|
|
65
|
+
type: 'message',
|
|
66
|
+
messageType: 'error',
|
|
67
|
+
content: 'loadHistory function is not available.',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
loadHistory(toolCallData.history);
|
|
71
|
+
}
|
|
72
|
+
if (toolCallData.clientHistory) {
|
|
73
|
+
await config?.getGeminiClient()?.setHistory(toolCallData.clientHistory);
|
|
74
|
+
}
|
|
75
|
+
if (toolCallData.commitHash) {
|
|
76
|
+
await gitService?.restoreProjectFromSnapshot(toolCallData.commitHash);
|
|
77
|
+
addItem({
|
|
78
|
+
type: 'info',
|
|
79
|
+
text: 'Restored project to the state before the tool call.',
|
|
80
|
+
}, Date.now());
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
type: 'tool',
|
|
84
|
+
toolName: toolCallData.toolCall.name,
|
|
85
|
+
toolArgs: toolCallData.toolCall.args,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return {
|
|
90
|
+
type: 'message',
|
|
91
|
+
messageType: 'error',
|
|
92
|
+
content: `Could not read restorable tool calls. This is the error: ${error}`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function completion(context, _partialArg) {
|
|
97
|
+
const { services } = context;
|
|
98
|
+
const { config } = services;
|
|
99
|
+
const checkpointDir = config?.getProjectTempDir()
|
|
100
|
+
? path.join(config.getProjectTempDir(), 'checkpoints')
|
|
101
|
+
: undefined;
|
|
102
|
+
if (!checkpointDir) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const files = await fs.readdir(checkpointDir);
|
|
107
|
+
return files
|
|
108
|
+
.filter((file) => file.endsWith('.json'))
|
|
109
|
+
.map((file) => file.replace('.json', ''));
|
|
110
|
+
}
|
|
111
|
+
catch (_err) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export const restoreCommand = (config) => {
|
|
116
|
+
if (!config?.getCheckpointingEnabled()) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
name: 'restore',
|
|
121
|
+
description: 'Restore a tool call. This will reset the conversation and file history to the state it was in when the tool call was suggested',
|
|
122
|
+
action: restoreAction,
|
|
123
|
+
completion,
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=restoreCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restoreCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/restoreCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AAQxB,KAAK,UAAU,aAAa,CAC1B,OAAuB,EACvB,IAAY;IAEZ,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC;IACjC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;IAC7C,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;IAEpC,MAAM,aAAa,GAAG,MAAM,EAAE,iBAAiB,EAAE;QAC/C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,EAAE,aAAa,CAAC;QACtD,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO;YACL,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,OAAO;YACpB,OAAO,EAAE,iDAAiD;SAC3D,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,wDAAwD;QACxD,MAAM,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC9C,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAEjE,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3B,OAAO;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,CAAC,SAAS,CAAC;IACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC9C,OAAO,KAAK;aACT,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;aACxC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;IAAC,OAAO,IAAI,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAqB,EAAuB,EAAE;IAC3E,IAAI,CAAC,MAAM,EAAE,uBAAuB,EAAE,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,IAAI,EAAE,SAAS;QACf,WAAW,EACT,gIAAgI;QAClI,MAAM,EAAE,aAAa;QACrB,UAAU;KACX,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { MessageType } from '../types.js';
|
|
7
|
+
import { formatDuration } from '../utils/formatters.js';
|
|
8
|
+
export const statsCommand = {
|
|
9
|
+
name: 'stats',
|
|
10
|
+
altName: 'usage',
|
|
11
|
+
description: 'check session stats. Usage: /stats [model|tools]',
|
|
12
|
+
action: (context) => {
|
|
13
|
+
const now = new Date();
|
|
14
|
+
const { sessionStartTime } = context.session.stats;
|
|
15
|
+
if (!sessionStartTime) {
|
|
16
|
+
context.ui.addItem({
|
|
17
|
+
type: MessageType.ERROR,
|
|
18
|
+
text: 'Session start time is unavailable, cannot calculate stats.',
|
|
19
|
+
}, Date.now());
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const wallDuration = now.getTime() - sessionStartTime.getTime();
|
|
23
|
+
const statsItem = {
|
|
24
|
+
type: MessageType.STATS,
|
|
25
|
+
duration: formatDuration(wallDuration),
|
|
26
|
+
};
|
|
27
|
+
context.ui.addItem(statsItem, Date.now());
|
|
28
|
+
},
|
|
29
|
+
subCommands: [
|
|
30
|
+
{
|
|
31
|
+
name: 'model',
|
|
32
|
+
description: 'Show model-specific usage statistics.',
|
|
33
|
+
action: (context) => {
|
|
34
|
+
context.ui.addItem({
|
|
35
|
+
type: MessageType.MODEL_STATS,
|
|
36
|
+
}, Date.now());
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'tools',
|
|
41
|
+
description: 'Show tool-specific usage statistics.',
|
|
42
|
+
action: (context) => {
|
|
43
|
+
context.ui.addItem({
|
|
44
|
+
type: MessageType.TOOL_STATS,
|
|
45
|
+
}, Date.now());
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=statsCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statsCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/statsCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAoB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,kDAAkD;IAC/D,MAAM,EAAE,CAAC,OAAuB,EAAE,EAAE;QAClC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,EAAE,gBAA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
6
|
+
import { MessageType } from '../types.js';
|
|
7
|
+
export const toolsCommand = {
|
|
8
|
+
name: 'tools',
|
|
9
|
+
description: 'list available Gemini CLI tools',
|
|
10
|
+
action: async (context, args) => {
|
|
11
|
+
const subCommand = args?.trim();
|
|
12
|
+
// Default to NOT showing descriptions. The user must opt in with an argument.
|
|
13
|
+
let useShowDescriptions = false;
|
|
14
|
+
if (subCommand === 'desc' || subCommand === 'descriptions') {
|
|
15
|
+
useShowDescriptions = true;
|
|
16
|
+
}
|
|
17
|
+
const toolRegistry = await context.services.config?.getToolRegistry();
|
|
18
|
+
if (!toolRegistry) {
|
|
19
|
+
context.ui.addItem({
|
|
20
|
+
type: MessageType.ERROR,
|
|
21
|
+
text: 'Could not retrieve tool registry.',
|
|
22
|
+
}, Date.now());
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const tools = toolRegistry.getAllTools();
|
|
26
|
+
// Filter out MCP tools by checking for the absence of a serverName property
|
|
27
|
+
const geminiTools = tools.filter((tool) => !('serverName' in tool));
|
|
28
|
+
let message = 'Available Gemini CLI tools:\n\n';
|
|
29
|
+
if (geminiTools.length > 0) {
|
|
30
|
+
geminiTools.forEach((tool) => {
|
|
31
|
+
if (useShowDescriptions && tool.description) {
|
|
32
|
+
message += ` - \u001b[36m${tool.displayName} (${tool.name})\u001b[0m:\n`;
|
|
33
|
+
const greenColor = '\u001b[32m';
|
|
34
|
+
const resetColor = '\u001b[0m';
|
|
35
|
+
// Handle multi-line descriptions
|
|
36
|
+
const descLines = tool.description.trim().split('\n');
|
|
37
|
+
for (const descLine of descLines) {
|
|
38
|
+
message += ` ${greenColor}${descLine}${resetColor}\n`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
message += ` - \u001b[36m${tool.displayName}\u001b[0m\n`;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
message += ' No tools available\n';
|
|
48
|
+
}
|
|
49
|
+
message += '\n';
|
|
50
|
+
message += '\u001b[0m';
|
|
51
|
+
context.ui.addItem({ type: MessageType.INFO, text: message }, Date.now());
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=toolsCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolsCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/toolsCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,iCAAiC;IAC9C,MAAM,EAAE,KAAK,EAAE,OAAuB,EAAE,IAAa,EAAiB,EAAE;QACtE,MAAM,UAAU,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC;QAEhC,8EAA8E;QAC9E,IAAI,mBAAmB,GAAG,KAAK,CAAC;QAChC,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,cAAc,EAAE,CAAC;YAC3D,mBAAmB,GAAG,IAAI,CAAC;QAC7B,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;QACtE,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,CAAC,EAAE,CAAC,OAAO,CAChB;gBACE,IAAI,EAAE,WAAW,CAAC,KAAK;gBACvB,IAAI,EAAE,mCAAmC;aAC1C,EACD,IAAI,CAAC,GAAG,EAAE,CACX,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC;QACzC,4EAA4E;QAC5E,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC;QAEpE,IAAI,OAAO,GAAG,iCAAiC,CAAC;QAEhD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC3B,IAAI,mBAAmB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;oBAC5C,OAAO,IAAI,iBAAiB,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,IAAI,eAAe,CAAC;oBAE1E,MAAM,UAAU,GAAG,YAAY,CAAC;oBAChC,MAAM,UAAU,GAAG,WAAW,CAAC;oBAE/B,iCAAiC;oBACjC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBACtD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;wBACjC,OAAO,IAAI,SAAS,UAAU,GAAG,QAAQ,GAAG,UAAU,IAAI,CAAC;oBAC7D,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,OAAO,IAAI,iBAAiB,IAAI,CAAC,WAAW,aAAa,CAAC;gBAC5D,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,wBAAwB,CAAC;QACtC,CAAC;QACD,OAAO,IAAI,IAAI,CAAC;QAEhB,OAAO,IAAI,WAAW,CAAC;QAEvB,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF,CAAC"}
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { Content } from '@google/genai';
|
|
7
|
+
import { HistoryItemWithoutId } from '../types.js';
|
|
6
8
|
import { Config, GitService, Logger } from '@google/gemini-cli-core';
|
|
7
9
|
import { LoadedSettings } from '../../config/settings.js';
|
|
8
10
|
import { UseHistoryManagerReturn } from '../hooks/useHistoryManager.js';
|
|
11
|
+
import type { HistoryItem } from '../types.js';
|
|
9
12
|
import { SessionStatsState } from '../contexts/SessionContext.js';
|
|
10
13
|
export interface CommandContext {
|
|
11
14
|
services: {
|
|
@@ -23,6 +26,23 @@ export interface CommandContext {
|
|
|
23
26
|
* Sets the transient debug message displayed in the application footer in debug mode.
|
|
24
27
|
*/
|
|
25
28
|
setDebugMessage: (message: string) => void;
|
|
29
|
+
/** The currently pending history item, if any. */
|
|
30
|
+
pendingItem: HistoryItemWithoutId | null;
|
|
31
|
+
/**
|
|
32
|
+
* Sets a pending item in the history, which is useful for indicating
|
|
33
|
+
* that a long-running operation is in progress.
|
|
34
|
+
*
|
|
35
|
+
* @param item The history item to display as pending, or `null` to clear.
|
|
36
|
+
*/
|
|
37
|
+
setPendingItem: (item: HistoryItemWithoutId | null) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Loads a new set of history items, replacing the current history.
|
|
40
|
+
*
|
|
41
|
+
* @param history The array of history items to load.
|
|
42
|
+
*/
|
|
43
|
+
loadHistory: UseHistoryManagerReturn['loadHistory'];
|
|
44
|
+
/** Toggles a special display mode. */
|
|
45
|
+
toggleCorgiMode: () => void;
|
|
26
46
|
};
|
|
27
47
|
session: {
|
|
28
48
|
stats: SessionStatsState;
|
|
@@ -36,6 +56,11 @@ export interface ToolActionReturn {
|
|
|
36
56
|
toolName: string;
|
|
37
57
|
toolArgs: Record<string, unknown>;
|
|
38
58
|
}
|
|
59
|
+
/** The return type for a command action that results in the app quitting. */
|
|
60
|
+
export interface QuitActionReturn {
|
|
61
|
+
type: 'quit';
|
|
62
|
+
messages: HistoryItem[];
|
|
63
|
+
}
|
|
39
64
|
/**
|
|
40
65
|
* The return type for a command action that results in a simple message
|
|
41
66
|
* being displayed to the user.
|
|
@@ -50,9 +75,18 @@ export interface MessageActionReturn {
|
|
|
50
75
|
*/
|
|
51
76
|
export interface OpenDialogActionReturn {
|
|
52
77
|
type: 'dialog';
|
|
53
|
-
dialog: 'help' | 'theme';
|
|
78
|
+
dialog: 'help' | 'auth' | 'theme' | 'editor' | 'privacy';
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The return type for a command action that results in replacing
|
|
82
|
+
* the entire conversation history.
|
|
83
|
+
*/
|
|
84
|
+
export interface LoadHistoryActionReturn {
|
|
85
|
+
type: 'load_history';
|
|
86
|
+
history: HistoryItemWithoutId[];
|
|
87
|
+
clientHistory: Content[];
|
|
54
88
|
}
|
|
55
|
-
export type SlashCommandActionReturn = ToolActionReturn | MessageActionReturn | OpenDialogActionReturn;
|
|
89
|
+
export type SlashCommandActionReturn = ToolActionReturn | MessageActionReturn | QuitActionReturn | OpenDialogActionReturn | LoadHistoryActionReturn;
|
|
56
90
|
export interface SlashCommand {
|
|
57
91
|
name: string;
|
|
58
92
|
altName?: string;
|
|
@@ -4,12 +4,17 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import { type MCPServerConfig } from '@google/gemini-cli-core';
|
|
7
|
+
import { type ActiveFile, type MCPServerConfig } from '@google/gemini-cli-core';
|
|
8
8
|
interface ContextSummaryDisplayProps {
|
|
9
9
|
geminiMdFileCount: number;
|
|
10
10
|
contextFileNames: string[];
|
|
11
11
|
mcpServers?: Record<string, MCPServerConfig>;
|
|
12
|
+
blockedMcpServers?: Array<{
|
|
13
|
+
name: string;
|
|
14
|
+
extensionName: string;
|
|
15
|
+
}>;
|
|
12
16
|
showToolDescriptions?: boolean;
|
|
17
|
+
activeFile?: ActiveFile;
|
|
13
18
|
}
|
|
14
19
|
export declare const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps>;
|
|
15
20
|
export {};
|