@google/gemini-cli 0.1.15 → 0.1.16-nightly.250804.a8984a9b

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.
Files changed (129) hide show
  1. package/README.md +32 -0
  2. package/dist/google-gemini-cli-0.1.16.tgz +0 -0
  3. package/dist/package.json +2 -2
  4. package/dist/src/config/config.d.ts +4 -2
  5. package/dist/src/config/config.js +36 -14
  6. package/dist/src/config/config.js.map +1 -1
  7. package/dist/src/config/extension.d.ts +1 -0
  8. package/dist/src/config/extension.js +4 -0
  9. package/dist/src/config/extension.js.map +1 -1
  10. package/dist/src/config/settings.d.ts +11 -1
  11. package/dist/src/config/settings.js +84 -23
  12. package/dist/src/config/settings.js.map +1 -1
  13. package/dist/src/gemini.d.ts +2 -0
  14. package/dist/src/gemini.js +30 -3
  15. package/dist/src/gemini.js.map +1 -1
  16. package/dist/src/generated/git-commit.d.ts +1 -1
  17. package/dist/src/generated/git-commit.js +1 -1
  18. package/dist/src/nonInteractiveCli.js +15 -40
  19. package/dist/src/nonInteractiveCli.js.map +1 -1
  20. package/dist/src/services/BuiltinCommandLoader.js +8 -1
  21. package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
  22. package/dist/src/services/CommandService.d.ts +8 -4
  23. package/dist/src/services/CommandService.js +24 -8
  24. package/dist/src/services/CommandService.js.map +1 -1
  25. package/dist/src/services/FileCommandLoader.d.ts +15 -3
  26. package/dist/src/services/FileCommandLoader.js +64 -35
  27. package/dist/src/services/FileCommandLoader.js.map +1 -1
  28. package/dist/src/ui/App.js +29 -16
  29. package/dist/src/ui/App.js.map +1 -1
  30. package/dist/src/ui/commands/chatCommand.js +39 -1
  31. package/dist/src/ui/commands/chatCommand.js.map +1 -1
  32. package/dist/src/ui/commands/directoryCommand.d.ts +8 -0
  33. package/dist/src/ui/commands/directoryCommand.js +116 -0
  34. package/dist/src/ui/commands/directoryCommand.js.map +1 -0
  35. package/dist/src/ui/commands/ideCommand.js +101 -105
  36. package/dist/src/ui/commands/ideCommand.js.map +1 -1
  37. package/dist/src/ui/commands/initCommand.d.ts +7 -0
  38. package/dist/src/ui/commands/initCommand.js +76 -0
  39. package/dist/src/ui/commands/initCommand.js.map +1 -0
  40. package/dist/src/ui/commands/memoryCommand.js +2 -1
  41. package/dist/src/ui/commands/memoryCommand.js.map +1 -1
  42. package/dist/src/ui/commands/setupGithubCommand.d.ts +7 -0
  43. package/dist/src/ui/commands/setupGithubCommand.js +49 -0
  44. package/dist/src/ui/commands/setupGithubCommand.js.map +1 -0
  45. package/dist/src/ui/commands/types.d.ts +1 -0
  46. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +2 -2
  47. package/dist/src/ui/components/ContextSummaryDisplay.js +8 -8
  48. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
  49. package/dist/src/ui/components/DebugProfiler.d.ts +6 -0
  50. package/dist/src/ui/components/DebugProfiler.js +26 -0
  51. package/dist/src/ui/components/DebugProfiler.js.map +1 -0
  52. package/dist/src/ui/components/Footer.js +3 -2
  53. package/dist/src/ui/components/Footer.js.map +1 -1
  54. package/dist/src/ui/components/Help.js +2 -2
  55. package/dist/src/ui/components/Help.js.map +1 -1
  56. package/dist/src/ui/components/IDEContextDetailDisplay.d.ts +4 -3
  57. package/dist/src/ui/components/IDEContextDetailDisplay.js +6 -13
  58. package/dist/src/ui/components/IDEContextDetailDisplay.js.map +1 -1
  59. package/dist/src/ui/components/InputPrompt.js +83 -7
  60. package/dist/src/ui/components/InputPrompt.js.map +1 -1
  61. package/dist/src/ui/components/PrepareLabel.d.ts +15 -0
  62. package/dist/src/ui/components/PrepareLabel.js +16 -0
  63. package/dist/src/ui/components/PrepareLabel.js.map +1 -0
  64. package/dist/src/ui/components/SuggestionsDisplay.d.ts +1 -0
  65. package/dist/src/ui/components/SuggestionsDisplay.js +3 -3
  66. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -1
  67. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +15 -4
  68. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
  69. package/dist/src/ui/components/messages/UserMessage.js +4 -1
  70. package/dist/src/ui/components/messages/UserMessage.js.map +1 -1
  71. package/dist/src/ui/components/shared/text-buffer.js +9 -14
  72. package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
  73. package/dist/src/ui/editors/editorSettingsManager.js +6 -13
  74. package/dist/src/ui/editors/editorSettingsManager.js.map +1 -1
  75. package/dist/src/ui/hooks/atCommandProcessor.js +56 -48
  76. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
  77. package/dist/src/ui/hooks/slashCommandProcessor.js +12 -2
  78. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
  79. package/dist/src/ui/hooks/useCompletion.d.ts +5 -5
  80. package/dist/src/ui/hooks/useCompletion.js +7 -407
  81. package/dist/src/ui/hooks/useCompletion.js.map +1 -1
  82. package/dist/src/ui/hooks/useGeminiStream.js +5 -2
  83. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
  84. package/dist/src/ui/hooks/usePhraseCycler.js +1 -0
  85. package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
  86. package/dist/src/ui/hooks/useReactToolScheduler.js +0 -1
  87. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
  88. package/dist/src/ui/hooks/useReverseSearchCompletion.d.ts +19 -0
  89. package/dist/src/ui/hooks/useReverseSearchCompletion.js +54 -0
  90. package/dist/src/ui/hooks/useReverseSearchCompletion.js.map +1 -0
  91. package/dist/src/ui/hooks/useShellHistory.d.ts +1 -0
  92. package/dist/src/ui/hooks/useShellHistory.js +30 -7
  93. package/dist/src/ui/hooks/useShellHistory.js.map +1 -1
  94. package/dist/src/ui/hooks/useSlashCompletion.d.ts +24 -0
  95. package/dist/src/ui/hooks/useSlashCompletion.js +451 -0
  96. package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -0
  97. package/dist/src/ui/utils/updateCheck.d.ts +7 -1
  98. package/dist/src/ui/utils/updateCheck.js +46 -8
  99. package/dist/src/ui/utils/updateCheck.js.map +1 -1
  100. package/dist/src/utils/gitUtils.d.ts +10 -0
  101. package/dist/src/utils/gitUtils.js +24 -0
  102. package/dist/src/utils/gitUtils.js.map +1 -0
  103. package/dist/src/utils/handleAutoUpdate.d.ts +11 -0
  104. package/dist/src/utils/handleAutoUpdate.js +101 -0
  105. package/dist/src/utils/handleAutoUpdate.js.map +1 -0
  106. package/dist/src/utils/installationInfo.d.ts +23 -0
  107. package/dist/src/utils/installationInfo.js +154 -0
  108. package/dist/src/utils/installationInfo.js.map +1 -0
  109. package/dist/src/utils/sandbox-macos-permissive-closed.sb +6 -0
  110. package/dist/src/utils/sandbox-macos-permissive-open.sb +6 -0
  111. package/dist/src/utils/sandbox-macos-permissive-proxied.sb +6 -0
  112. package/dist/src/utils/sandbox-macos-restrictive-closed.sb +6 -0
  113. package/dist/src/utils/sandbox-macos-restrictive-open.sb +6 -0
  114. package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +6 -0
  115. package/dist/src/utils/sandbox.d.ts +2 -2
  116. package/dist/src/utils/sandbox.js +35 -11
  117. package/dist/src/utils/sandbox.js.map +1 -1
  118. package/dist/src/utils/spawnWrapper.d.ts +7 -0
  119. package/dist/src/utils/spawnWrapper.js +8 -0
  120. package/dist/src/utils/spawnWrapper.js.map +1 -0
  121. package/dist/src/utils/updateEventEmitter.d.ts +11 -0
  122. package/dist/src/utils/updateEventEmitter.js +12 -0
  123. package/dist/src/utils/updateEventEmitter.js.map +1 -0
  124. package/dist/src/validateNonInterActiveAuth.d.ts +1 -1
  125. package/dist/src/validateNonInterActiveAuth.js +7 -5
  126. package/dist/src/validateNonInterActiveAuth.js.map +1 -1
  127. package/dist/tsconfig.tsbuildinfo +1 -1
  128. package/package.json +3 -3
  129. package/dist/google-gemini-cli-0.1.13.tgz +0 -0
@@ -0,0 +1,451 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { useEffect, useCallback, useMemo, useRef } from 'react';
7
+ import * as fs from 'fs/promises';
8
+ import * as path from 'path';
9
+ import { glob } from 'glob';
10
+ import { isNodeError, escapePath, unescapePath, getErrorMessage, DEFAULT_FILE_FILTERING_OPTIONS, } from '@google/gemini-cli-core';
11
+ import { logicalPosToOffset, } from '../components/shared/text-buffer.js';
12
+ import { isSlashCommand } from '../utils/commandUtils.js';
13
+ import { toCodePoints } from '../utils/textUtils.js';
14
+ import { useCompletion } from './useCompletion.js';
15
+ export function useSlashCompletion(buffer, dirs, cwd, slashCommands, commandContext, reverseSearchActive = false, config) {
16
+ const { suggestions, activeSuggestionIndex, visibleStartIndex, showSuggestions, isLoadingSuggestions, isPerfectMatch, setSuggestions, setShowSuggestions, setActiveSuggestionIndex, setIsLoadingSuggestions, setIsPerfectMatch, setVisibleStartIndex, resetCompletionState, navigateUp, navigateDown, } = useCompletion();
17
+ const completionStart = useRef(-1);
18
+ const completionEnd = useRef(-1);
19
+ const cursorRow = buffer.cursor[0];
20
+ const cursorCol = buffer.cursor[1];
21
+ // Check if cursor is after @ or / without unescaped spaces
22
+ const commandIndex = useMemo(() => {
23
+ const currentLine = buffer.lines[cursorRow] || '';
24
+ if (cursorRow === 0 && isSlashCommand(currentLine.trim())) {
25
+ return currentLine.indexOf('/');
26
+ }
27
+ // For other completions like '@', we search backwards from the cursor.
28
+ const codePoints = toCodePoints(currentLine);
29
+ for (let i = cursorCol - 1; i >= 0; i--) {
30
+ const char = codePoints[i];
31
+ if (char === ' ') {
32
+ // Check for unescaped spaces.
33
+ let backslashCount = 0;
34
+ for (let j = i - 1; j >= 0 && codePoints[j] === '\\'; j--) {
35
+ backslashCount++;
36
+ }
37
+ if (backslashCount % 2 === 0) {
38
+ return -1; // Inactive on unescaped space.
39
+ }
40
+ }
41
+ else if (char === '@') {
42
+ // Active if we find an '@' before any unescaped space.
43
+ return i;
44
+ }
45
+ }
46
+ return -1;
47
+ }, [cursorRow, cursorCol, buffer.lines]);
48
+ useEffect(() => {
49
+ if (commandIndex === -1 || reverseSearchActive) {
50
+ resetCompletionState();
51
+ return;
52
+ }
53
+ const currentLine = buffer.lines[cursorRow] || '';
54
+ const codePoints = toCodePoints(currentLine);
55
+ if (codePoints[commandIndex] === '/') {
56
+ // Always reset perfect match at the beginning of processing.
57
+ setIsPerfectMatch(false);
58
+ const fullPath = currentLine.substring(commandIndex + 1);
59
+ const hasTrailingSpace = currentLine.endsWith(' ');
60
+ // Get all non-empty parts of the command.
61
+ const rawParts = fullPath.split(/\s+/).filter((p) => p);
62
+ let commandPathParts = rawParts;
63
+ let partial = '';
64
+ // If there's no trailing space, the last part is potentially a partial segment.
65
+ // We tentatively separate it.
66
+ if (!hasTrailingSpace && rawParts.length > 0) {
67
+ partial = rawParts[rawParts.length - 1];
68
+ commandPathParts = rawParts.slice(0, -1);
69
+ }
70
+ // Traverse the Command Tree using the tentative completed path
71
+ let currentLevel = slashCommands;
72
+ let leafCommand = null;
73
+ for (const part of commandPathParts) {
74
+ if (!currentLevel) {
75
+ leafCommand = null;
76
+ currentLevel = [];
77
+ break;
78
+ }
79
+ const found = currentLevel.find((cmd) => cmd.name === part || cmd.altNames?.includes(part));
80
+ if (found) {
81
+ leafCommand = found;
82
+ currentLevel = found.subCommands;
83
+ }
84
+ else {
85
+ leafCommand = null;
86
+ currentLevel = [];
87
+ break;
88
+ }
89
+ }
90
+ let exactMatchAsParent;
91
+ // Handle the Ambiguous Case
92
+ if (!hasTrailingSpace && currentLevel) {
93
+ exactMatchAsParent = currentLevel.find((cmd) => (cmd.name === partial || cmd.altNames?.includes(partial)) &&
94
+ cmd.subCommands);
95
+ if (exactMatchAsParent) {
96
+ // It's a perfect match for a parent command. Override our initial guess.
97
+ // Treat it as a completed command path.
98
+ leafCommand = exactMatchAsParent;
99
+ currentLevel = exactMatchAsParent.subCommands;
100
+ partial = ''; // We now want to suggest ALL of its sub-commands.
101
+ }
102
+ }
103
+ // Check for perfect, executable match
104
+ if (!hasTrailingSpace) {
105
+ if (leafCommand && partial === '' && leafCommand.action) {
106
+ // Case: /command<enter> - command has action, no sub-commands were suggested
107
+ setIsPerfectMatch(true);
108
+ }
109
+ else if (currentLevel) {
110
+ // Case: /command subcommand<enter>
111
+ const perfectMatch = currentLevel.find((cmd) => (cmd.name === partial || cmd.altNames?.includes(partial)) &&
112
+ cmd.action);
113
+ if (perfectMatch) {
114
+ setIsPerfectMatch(true);
115
+ }
116
+ }
117
+ }
118
+ const depth = commandPathParts.length;
119
+ const isArgumentCompletion = leafCommand?.completion &&
120
+ (hasTrailingSpace ||
121
+ (rawParts.length > depth && depth > 0 && partial !== ''));
122
+ // Set completion range
123
+ if (hasTrailingSpace || exactMatchAsParent) {
124
+ completionStart.current = currentLine.length;
125
+ completionEnd.current = currentLine.length;
126
+ }
127
+ else if (partial) {
128
+ if (isArgumentCompletion) {
129
+ const commandSoFar = `/${commandPathParts.join(' ')}`;
130
+ const argStartIndex = commandSoFar.length + (commandPathParts.length > 0 ? 1 : 0);
131
+ completionStart.current = argStartIndex;
132
+ }
133
+ else {
134
+ completionStart.current = currentLine.length - partial.length;
135
+ }
136
+ completionEnd.current = currentLine.length;
137
+ }
138
+ else {
139
+ // e.g. /
140
+ completionStart.current = commandIndex + 1;
141
+ completionEnd.current = currentLine.length;
142
+ }
143
+ // Provide Suggestions based on the now-corrected context
144
+ if (isArgumentCompletion) {
145
+ const fetchAndSetSuggestions = async () => {
146
+ setIsLoadingSuggestions(true);
147
+ const argString = rawParts.slice(depth).join(' ');
148
+ const results = (await leafCommand.completion(commandContext, argString)) || [];
149
+ const finalSuggestions = results.map((s) => ({ label: s, value: s }));
150
+ setSuggestions(finalSuggestions);
151
+ setShowSuggestions(finalSuggestions.length > 0);
152
+ setActiveSuggestionIndex(finalSuggestions.length > 0 ? 0 : -1);
153
+ setIsLoadingSuggestions(false);
154
+ };
155
+ fetchAndSetSuggestions();
156
+ return;
157
+ }
158
+ // Command/Sub-command Completion
159
+ const commandsToSearch = currentLevel || [];
160
+ if (commandsToSearch.length > 0) {
161
+ let potentialSuggestions = commandsToSearch.filter((cmd) => cmd.description &&
162
+ (cmd.name.startsWith(partial) ||
163
+ cmd.altNames?.some((alt) => alt.startsWith(partial))));
164
+ // If a user's input is an exact match and it is a leaf command,
165
+ // enter should submit immediately.
166
+ if (potentialSuggestions.length > 0 && !hasTrailingSpace) {
167
+ const perfectMatch = potentialSuggestions.find((s) => s.name === partial || s.altNames?.includes(partial));
168
+ if (perfectMatch && perfectMatch.action) {
169
+ potentialSuggestions = [];
170
+ }
171
+ }
172
+ const finalSuggestions = potentialSuggestions.map((cmd) => ({
173
+ label: cmd.name,
174
+ value: cmd.name,
175
+ description: cmd.description,
176
+ }));
177
+ setSuggestions(finalSuggestions);
178
+ setShowSuggestions(finalSuggestions.length > 0);
179
+ setActiveSuggestionIndex(finalSuggestions.length > 0 ? 0 : -1);
180
+ setIsLoadingSuggestions(false);
181
+ return;
182
+ }
183
+ // If we fall through, no suggestions are available.
184
+ resetCompletionState();
185
+ return;
186
+ }
187
+ // Handle At Command Completion
188
+ completionEnd.current = codePoints.length;
189
+ for (let i = cursorCol; i < codePoints.length; i++) {
190
+ if (codePoints[i] === ' ') {
191
+ let backslashCount = 0;
192
+ for (let j = i - 1; j >= 0 && codePoints[j] === '\\'; j--) {
193
+ backslashCount++;
194
+ }
195
+ if (backslashCount % 2 === 0) {
196
+ completionEnd.current = i;
197
+ break;
198
+ }
199
+ }
200
+ }
201
+ const pathStart = commandIndex + 1;
202
+ const partialPath = currentLine.substring(pathStart, completionEnd.current);
203
+ const lastSlashIndex = partialPath.lastIndexOf('/');
204
+ completionStart.current =
205
+ lastSlashIndex === -1 ? pathStart : pathStart + lastSlashIndex + 1;
206
+ const baseDirRelative = lastSlashIndex === -1
207
+ ? '.'
208
+ : partialPath.substring(0, lastSlashIndex + 1);
209
+ const prefix = unescapePath(lastSlashIndex === -1
210
+ ? partialPath
211
+ : partialPath.substring(lastSlashIndex + 1));
212
+ let isMounted = true;
213
+ const findFilesRecursively = async (startDir, searchPrefix, fileDiscovery, filterOptions, currentRelativePath = '', depth = 0, maxDepth = 10, // Limit recursion depth
214
+ maxResults = 50) => {
215
+ if (depth > maxDepth) {
216
+ return [];
217
+ }
218
+ const lowerSearchPrefix = searchPrefix.toLowerCase();
219
+ let foundSuggestions = [];
220
+ try {
221
+ const entries = await fs.readdir(startDir, { withFileTypes: true });
222
+ for (const entry of entries) {
223
+ if (foundSuggestions.length >= maxResults)
224
+ break;
225
+ const entryPathRelative = path.join(currentRelativePath, entry.name);
226
+ const entryPathFromRoot = path.relative(startDir, path.join(startDir, entry.name));
227
+ // Conditionally ignore dotfiles
228
+ if (!searchPrefix.startsWith('.') && entry.name.startsWith('.')) {
229
+ continue;
230
+ }
231
+ // Check if this entry should be ignored by filtering options
232
+ if (fileDiscovery &&
233
+ fileDiscovery.shouldIgnoreFile(entryPathFromRoot, filterOptions)) {
234
+ continue;
235
+ }
236
+ if (entry.name.toLowerCase().startsWith(lowerSearchPrefix)) {
237
+ foundSuggestions.push({
238
+ label: entryPathRelative + (entry.isDirectory() ? '/' : ''),
239
+ value: escapePath(entryPathRelative + (entry.isDirectory() ? '/' : '')),
240
+ });
241
+ }
242
+ if (entry.isDirectory() &&
243
+ entry.name !== 'node_modules' &&
244
+ !entry.name.startsWith('.')) {
245
+ if (foundSuggestions.length < maxResults) {
246
+ foundSuggestions = foundSuggestions.concat(await findFilesRecursively(path.join(startDir, entry.name), searchPrefix, // Pass original searchPrefix for recursive calls
247
+ fileDiscovery, filterOptions, entryPathRelative, depth + 1, maxDepth, maxResults - foundSuggestions.length));
248
+ }
249
+ }
250
+ }
251
+ }
252
+ catch (_err) {
253
+ // Ignore errors like permission denied or ENOENT during recursive search
254
+ }
255
+ return foundSuggestions.slice(0, maxResults);
256
+ };
257
+ const findFilesWithGlob = async (searchPrefix, fileDiscoveryService, filterOptions, searchDir, maxResults = 50) => {
258
+ const globPattern = `**/${searchPrefix}*`;
259
+ const files = await glob(globPattern, {
260
+ cwd: searchDir,
261
+ dot: searchPrefix.startsWith('.'),
262
+ nocase: true,
263
+ });
264
+ const suggestions = files
265
+ .filter((file) => {
266
+ if (fileDiscoveryService) {
267
+ return !fileDiscoveryService.shouldIgnoreFile(file, filterOptions);
268
+ }
269
+ return true;
270
+ })
271
+ .map((file) => {
272
+ const absolutePath = path.resolve(searchDir, file);
273
+ const label = path.relative(cwd, absolutePath);
274
+ return {
275
+ label,
276
+ value: escapePath(label),
277
+ };
278
+ })
279
+ .slice(0, maxResults);
280
+ return suggestions;
281
+ };
282
+ const fetchSuggestions = async () => {
283
+ setIsLoadingSuggestions(true);
284
+ let fetchedSuggestions = [];
285
+ const fileDiscoveryService = config ? config.getFileService() : null;
286
+ const enableRecursiveSearch = config?.getEnableRecursiveFileSearch() ?? true;
287
+ const filterOptions = config?.getFileFilteringOptions() ?? DEFAULT_FILE_FILTERING_OPTIONS;
288
+ try {
289
+ // If there's no slash, or it's the root, do a recursive search from workspace directories
290
+ for (const dir of dirs) {
291
+ let fetchedSuggestionsPerDir = [];
292
+ if (partialPath.indexOf('/') === -1 &&
293
+ prefix &&
294
+ enableRecursiveSearch) {
295
+ if (fileDiscoveryService) {
296
+ fetchedSuggestionsPerDir = await findFilesWithGlob(prefix, fileDiscoveryService, filterOptions, dir);
297
+ }
298
+ else {
299
+ fetchedSuggestionsPerDir = await findFilesRecursively(dir, prefix, null, filterOptions);
300
+ }
301
+ }
302
+ else {
303
+ // Original behavior: list files in the specific directory
304
+ const lowerPrefix = prefix.toLowerCase();
305
+ const baseDirAbsolute = path.resolve(dir, baseDirRelative);
306
+ const entries = await fs.readdir(baseDirAbsolute, {
307
+ withFileTypes: true,
308
+ });
309
+ // Filter entries using git-aware filtering
310
+ const filteredEntries = [];
311
+ for (const entry of entries) {
312
+ // Conditionally ignore dotfiles
313
+ if (!prefix.startsWith('.') && entry.name.startsWith('.')) {
314
+ continue;
315
+ }
316
+ if (!entry.name.toLowerCase().startsWith(lowerPrefix))
317
+ continue;
318
+ const relativePath = path.relative(dir, path.join(baseDirAbsolute, entry.name));
319
+ if (fileDiscoveryService &&
320
+ fileDiscoveryService.shouldIgnoreFile(relativePath, filterOptions)) {
321
+ continue;
322
+ }
323
+ filteredEntries.push(entry);
324
+ }
325
+ fetchedSuggestionsPerDir = filteredEntries.map((entry) => {
326
+ const absolutePath = path.resolve(baseDirAbsolute, entry.name);
327
+ const label = cwd === dir ? entry.name : path.relative(cwd, absolutePath);
328
+ const suggestionLabel = entry.isDirectory() ? label + '/' : label;
329
+ return {
330
+ label: suggestionLabel,
331
+ value: escapePath(suggestionLabel),
332
+ };
333
+ });
334
+ }
335
+ fetchedSuggestions = [
336
+ ...fetchedSuggestions,
337
+ ...fetchedSuggestionsPerDir,
338
+ ];
339
+ }
340
+ // Like glob, we always return forwardslashes, even in windows.
341
+ fetchedSuggestions = fetchedSuggestions.map((suggestion) => ({
342
+ ...suggestion,
343
+ label: suggestion.label.replace(/\\/g, '/'),
344
+ value: suggestion.value.replace(/\\/g, '/'),
345
+ }));
346
+ // Sort by depth, then directories first, then alphabetically
347
+ fetchedSuggestions.sort((a, b) => {
348
+ const depthA = (a.label.match(/\//g) || []).length;
349
+ const depthB = (b.label.match(/\//g) || []).length;
350
+ if (depthA !== depthB) {
351
+ return depthA - depthB;
352
+ }
353
+ const aIsDir = a.label.endsWith('/');
354
+ const bIsDir = b.label.endsWith('/');
355
+ if (aIsDir && !bIsDir)
356
+ return -1;
357
+ if (!aIsDir && bIsDir)
358
+ return 1;
359
+ // exclude extension when comparing
360
+ const filenameA = a.label.substring(0, a.label.length - path.extname(a.label).length);
361
+ const filenameB = b.label.substring(0, b.label.length - path.extname(b.label).length);
362
+ return (filenameA.localeCompare(filenameB) || a.label.localeCompare(b.label));
363
+ });
364
+ if (isMounted) {
365
+ setSuggestions(fetchedSuggestions);
366
+ setShowSuggestions(fetchedSuggestions.length > 0);
367
+ setActiveSuggestionIndex(fetchedSuggestions.length > 0 ? 0 : -1);
368
+ setVisibleStartIndex(0);
369
+ }
370
+ }
371
+ catch (error) {
372
+ if (isNodeError(error) && error.code === 'ENOENT') {
373
+ if (isMounted) {
374
+ setSuggestions([]);
375
+ setShowSuggestions(false);
376
+ }
377
+ }
378
+ else {
379
+ console.error(`Error fetching completion suggestions for ${partialPath}: ${getErrorMessage(error)}`);
380
+ if (isMounted) {
381
+ resetCompletionState();
382
+ }
383
+ }
384
+ }
385
+ if (isMounted) {
386
+ setIsLoadingSuggestions(false);
387
+ }
388
+ };
389
+ const debounceTimeout = setTimeout(fetchSuggestions, 100);
390
+ return () => {
391
+ isMounted = false;
392
+ clearTimeout(debounceTimeout);
393
+ };
394
+ }, [
395
+ buffer.text,
396
+ cursorRow,
397
+ cursorCol,
398
+ buffer.lines,
399
+ dirs,
400
+ cwd,
401
+ commandIndex,
402
+ resetCompletionState,
403
+ slashCommands,
404
+ commandContext,
405
+ config,
406
+ reverseSearchActive,
407
+ setSuggestions,
408
+ setShowSuggestions,
409
+ setActiveSuggestionIndex,
410
+ setIsLoadingSuggestions,
411
+ setIsPerfectMatch,
412
+ setVisibleStartIndex,
413
+ ]);
414
+ const handleAutocomplete = useCallback((indexToUse) => {
415
+ if (indexToUse < 0 || indexToUse >= suggestions.length) {
416
+ return;
417
+ }
418
+ const suggestion = suggestions[indexToUse].value;
419
+ if (completionStart.current === -1 || completionEnd.current === -1) {
420
+ return;
421
+ }
422
+ const isSlash = (buffer.lines[cursorRow] || '')[commandIndex] === '/';
423
+ let suggestionText = suggestion;
424
+ if (isSlash) {
425
+ // If we are inserting (not replacing), and the preceding character is not a space, add one.
426
+ if (completionStart.current === completionEnd.current &&
427
+ completionStart.current > commandIndex + 1 &&
428
+ (buffer.lines[cursorRow] || '')[completionStart.current - 1] !== ' ') {
429
+ suggestionText = ' ' + suggestionText;
430
+ }
431
+ suggestionText += ' ';
432
+ }
433
+ buffer.replaceRangeByOffset(logicalPosToOffset(buffer.lines, cursorRow, completionStart.current), logicalPosToOffset(buffer.lines, cursorRow, completionEnd.current), suggestionText);
434
+ resetCompletionState();
435
+ }, [cursorRow, resetCompletionState, buffer, suggestions, commandIndex]);
436
+ return {
437
+ suggestions,
438
+ activeSuggestionIndex,
439
+ visibleStartIndex,
440
+ showSuggestions,
441
+ isLoadingSuggestions,
442
+ isPerfectMatch,
443
+ setActiveSuggestionIndex,
444
+ setShowSuggestions,
445
+ resetCompletionState,
446
+ navigateUp,
447
+ navigateDown,
448
+ handleAutocomplete,
449
+ };
450
+ }
451
+ //# sourceMappingURL=useSlashCompletion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSlashCompletion.js","sourceRoot":"","sources":["../../../../src/ui/hooks/useSlashCompletion.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,eAAe,EAGf,8BAA8B,GAC/B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,kBAAkB,GAEnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAiBnD,MAAM,UAAU,kBAAkB,CAChC,MAAkB,EAClB,IAAuB,EACvB,GAAW,EACX,aAAsC,EACtC,cAA8B,EAC9B,sBAA+B,KAAK,EACpC,MAAe;IAEf,MAAM,EACJ,WAAW,EACX,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,cAAc,EAE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B,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,EACpE,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,EAClE,cAAc,CACf,CAAC;QACF,oBAAoB,EAAE,CAAC;IACzB,CAAC,EACD,CAAC,SAAS,EAAE,oBAAoB,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,CACrE,CAAC;IAEF,OAAO;QACL,WAAW;QACX,qBAAqB;QACrB,iBAAiB;QACjB,eAAe;QACf,oBAAoB;QACpB,cAAc;QACd,wBAAwB;QACxB,kBAAkB;QAClB,oBAAoB;QACpB,UAAU;QACV,YAAY;QACZ,kBAAkB;KACnB,CAAC;AACJ,CAAC"}
@@ -3,4 +3,10 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- export declare function checkForUpdates(): Promise<string | null>;
6
+ import { UpdateInfo } from 'update-notifier';
7
+ export declare const FETCH_TIMEOUT_MS = 2000;
8
+ export interface UpdateObject {
9
+ message: string;
10
+ update: UpdateInfo;
11
+ }
12
+ export declare function checkForUpdates(): Promise<UpdateObject | null>;
@@ -6,6 +6,23 @@
6
6
  import updateNotifier from 'update-notifier';
7
7
  import semver from 'semver';
8
8
  import { getPackageJson } from '../../utils/package.js';
9
+ export const FETCH_TIMEOUT_MS = 2000;
10
+ /**
11
+ * From a nightly and stable update, determines which is the "best" one to offer.
12
+ * The rule is to always prefer nightly if the base versions are the same.
13
+ */
14
+ function getBestAvailableUpdate(nightly, stable) {
15
+ if (!nightly)
16
+ return stable || null;
17
+ if (!stable)
18
+ return nightly || null;
19
+ const nightlyVer = nightly.latest;
20
+ const stableVer = stable.latest;
21
+ if (semver.coerce(stableVer)?.version === semver.coerce(nightlyVer)?.version) {
22
+ return nightly;
23
+ }
24
+ return semver.gt(stableVer, nightlyVer) ? stable : nightly;
25
+ }
9
26
  export async function checkForUpdates() {
10
27
  try {
11
28
  // Skip update check when running from source (development mode)
@@ -16,19 +33,40 @@ export async function checkForUpdates() {
16
33
  if (!packageJson || !packageJson.name || !packageJson.version) {
17
34
  return null;
18
35
  }
19
- const notifier = updateNotifier({
36
+ const { name, version: currentVersion } = packageJson;
37
+ const isNightly = currentVersion.includes('nightly');
38
+ const createNotifier = (distTag) => updateNotifier({
20
39
  pkg: {
21
- name: packageJson.name,
22
- version: packageJson.version,
40
+ name,
41
+ version: currentVersion,
23
42
  },
24
- // check every time
25
43
  updateCheckInterval: 0,
26
- // allow notifier to run in scripts
27
44
  shouldNotifyInNpmScript: true,
45
+ distTag,
28
46
  });
29
- if (notifier.update &&
30
- semver.gt(notifier.update.latest, notifier.update.current)) {
31
- return `Gemini CLI update available! ${notifier.update.current} → ${notifier.update.latest}\nRun npm install -g ${packageJson.name} to update`;
47
+ if (isNightly) {
48
+ const [nightlyUpdateInfo, latestUpdateInfo] = await Promise.all([
49
+ createNotifier('nightly').fetchInfo(),
50
+ createNotifier('latest').fetchInfo(),
51
+ ]);
52
+ const bestUpdate = getBestAvailableUpdate(nightlyUpdateInfo, latestUpdateInfo);
53
+ if (bestUpdate && semver.gt(bestUpdate.latest, currentVersion)) {
54
+ const message = `A new version of Gemini CLI is available! ${currentVersion} → ${bestUpdate.latest}`;
55
+ return {
56
+ message,
57
+ update: { ...bestUpdate, current: currentVersion },
58
+ };
59
+ }
60
+ }
61
+ else {
62
+ const updateInfo = await createNotifier('latest').fetchInfo();
63
+ if (updateInfo && semver.gt(updateInfo.latest, currentVersion)) {
64
+ const message = `Gemini CLI update available! ${currentVersion} → ${updateInfo.latest}`;
65
+ return {
66
+ message,
67
+ update: { ...updateInfo, current: currentVersion },
68
+ };
69
+ }
32
70
  }
33
71
  return null;
34
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"updateCheck.js","sourceRoot":"","sources":["../../../../src/ui/utils/updateCheck.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAE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AAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,+BAA+B,GAAG,CAAC,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Checks if a directory is within a git repository hosted on GitHub.
8
+ * @returns true if the directory is in a git repository with a github.com remote, false otherwise
9
+ */
10
+ export declare function isGitHubRepository(): boolean;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { execSync } from 'child_process';
7
+ /**
8
+ * Checks if a directory is within a git repository hosted on GitHub.
9
+ * @returns true if the directory is in a git repository with a github.com remote, false otherwise
10
+ */
11
+ export function isGitHubRepository() {
12
+ try {
13
+ const remotes = execSync('git remote -v', {
14
+ encoding: 'utf-8',
15
+ });
16
+ const pattern = /github\.com/;
17
+ return pattern.test(remotes);
18
+ }
19
+ catch (_error) {
20
+ // If any filesystem error occurs, assume not a git repo
21
+ return false;
22
+ }
23
+ }
24
+ //# sourceMappingURL=gitUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitUtils.js","sourceRoot":"","sources":["../../../src/utils/gitUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,QAAQ,CAAC,eAAe,EAAE;YACxC,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,aAAa,CAAC;QAE9B,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,wDAAwD;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { UpdateObject } from '../ui/utils/updateCheck.js';
7
+ import { LoadedSettings } from '../config/settings.js';
8
+ import { HistoryItem } from '../ui/types.js';
9
+ import { spawn } from 'child_process';
10
+ export declare function handleAutoUpdate(info: UpdateObject | null, settings: LoadedSettings, projectRoot: string, spawnFn?: typeof spawn): import("child_process").ChildProcessWithoutNullStreams | undefined;
11
+ export declare function setUpdateHandler(addItem: (item: Omit<HistoryItem, 'id'>, timestamp: number) => void, setUpdateInfo: (info: UpdateObject | null) => void): () => void;