@google/gemini-cli 0.1.14 → 0.1.15-nightly.250801.6f7beb41

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 (161) hide show
  1. package/README.md +28 -0
  2. package/dist/google-gemini-cli-0.1.15.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 +25 -12
  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 +4 -0
  11. package/dist/src/config/settings.js.map +1 -1
  12. package/dist/src/gemini.d.ts +1 -0
  13. package/dist/src/gemini.js +34 -15
  14. package/dist/src/gemini.js.map +1 -1
  15. package/dist/src/generated/git-commit.d.ts +1 -1
  16. package/dist/src/generated/git-commit.js +1 -1
  17. package/dist/src/nonInteractiveCli.js +14 -37
  18. package/dist/src/nonInteractiveCli.js.map +1 -1
  19. package/dist/src/services/BuiltinCommandLoader.js +9 -0
  20. package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
  21. package/dist/src/services/CommandService.d.ts +8 -4
  22. package/dist/src/services/CommandService.js +24 -8
  23. package/dist/src/services/CommandService.js.map +1 -1
  24. package/dist/src/services/FileCommandLoader.d.ts +15 -3
  25. package/dist/src/services/FileCommandLoader.js +94 -42
  26. package/dist/src/services/FileCommandLoader.js.map +1 -1
  27. package/dist/src/services/McpPromptLoader.d.ts +25 -0
  28. package/dist/src/services/McpPromptLoader.js +192 -0
  29. package/dist/src/services/McpPromptLoader.js.map +1 -0
  30. package/dist/src/services/prompt-processors/shellProcessor.d.ts +32 -0
  31. package/dist/src/services/prompt-processors/shellProcessor.js +77 -0
  32. package/dist/src/services/prompt-processors/shellProcessor.js.map +1 -0
  33. package/dist/src/services/prompt-processors/types.d.ts +4 -0
  34. package/dist/src/services/prompt-processors/types.js +4 -0
  35. package/dist/src/services/prompt-processors/types.js.map +1 -1
  36. package/dist/src/ui/App.js +89 -46
  37. package/dist/src/ui/App.js.map +1 -1
  38. package/dist/src/ui/commands/chatCommand.js +39 -1
  39. package/dist/src/ui/commands/chatCommand.js.map +1 -1
  40. package/dist/src/ui/commands/directoryCommand.d.ts +8 -0
  41. package/dist/src/ui/commands/directoryCommand.js +116 -0
  42. package/dist/src/ui/commands/directoryCommand.js.map +1 -0
  43. package/dist/src/ui/commands/ideCommand.js +101 -105
  44. package/dist/src/ui/commands/ideCommand.js.map +1 -1
  45. package/dist/src/ui/commands/initCommand.d.ts +7 -0
  46. package/dist/src/ui/commands/initCommand.js +76 -0
  47. package/dist/src/ui/commands/initCommand.js.map +1 -0
  48. package/dist/src/ui/commands/mcpCommand.js +53 -8
  49. package/dist/src/ui/commands/mcpCommand.js.map +1 -1
  50. package/dist/src/ui/commands/memoryCommand.js +2 -1
  51. package/dist/src/ui/commands/memoryCommand.js.map +1 -1
  52. package/dist/src/ui/commands/setupGithubCommand.d.ts +7 -0
  53. package/dist/src/ui/commands/setupGithubCommand.js +49 -0
  54. package/dist/src/ui/commands/setupGithubCommand.js.map +1 -0
  55. package/dist/src/ui/commands/types.d.ts +20 -2
  56. package/dist/src/ui/commands/types.js +1 -0
  57. package/dist/src/ui/commands/types.js.map +1 -1
  58. package/dist/src/ui/commands/vimCommand.d.ts +7 -0
  59. package/dist/src/ui/commands/vimCommand.js +23 -0
  60. package/dist/src/ui/commands/vimCommand.js.map +1 -0
  61. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +2 -2
  62. package/dist/src/ui/components/ContextSummaryDisplay.js +8 -8
  63. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
  64. package/dist/src/ui/components/DebugProfiler.d.ts +6 -0
  65. package/dist/src/ui/components/DebugProfiler.js +26 -0
  66. package/dist/src/ui/components/DebugProfiler.js.map +1 -0
  67. package/dist/src/ui/components/Footer.d.ts +1 -0
  68. package/dist/src/ui/components/Footer.js +4 -3
  69. package/dist/src/ui/components/Footer.js.map +1 -1
  70. package/dist/src/ui/components/Header.js +1 -1
  71. package/dist/src/ui/components/Header.js.map +1 -1
  72. package/dist/src/ui/components/Help.js +2 -2
  73. package/dist/src/ui/components/Help.js.map +1 -1
  74. package/dist/src/ui/components/IDEContextDetailDisplay.d.ts +4 -3
  75. package/dist/src/ui/components/IDEContextDetailDisplay.js +6 -13
  76. package/dist/src/ui/components/IDEContextDetailDisplay.js.map +1 -1
  77. package/dist/src/ui/components/InputPrompt.d.ts +2 -0
  78. package/dist/src/ui/components/InputPrompt.js +13 -2
  79. package/dist/src/ui/components/InputPrompt.js.map +1 -1
  80. package/dist/src/ui/components/ShellConfirmationDialog.d.ts +15 -0
  81. package/dist/src/ui/components/ShellConfirmationDialog.js +44 -0
  82. package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -0
  83. package/dist/src/ui/components/Tips.js +1 -1
  84. package/dist/src/ui/components/Tips.js.map +1 -1
  85. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +15 -4
  86. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
  87. package/dist/src/ui/components/messages/UserMessage.js +4 -1
  88. package/dist/src/ui/components/messages/UserMessage.js.map +1 -1
  89. package/dist/src/ui/components/shared/text-buffer.d.ts +270 -2
  90. package/dist/src/ui/components/shared/text-buffer.js +410 -70
  91. package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
  92. package/dist/src/ui/components/shared/vim-buffer-actions.d.ts +72 -0
  93. package/dist/src/ui/components/shared/vim-buffer-actions.js +565 -0
  94. package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -0
  95. package/dist/src/ui/contexts/VimModeContext.d.ts +19 -0
  96. package/dist/src/ui/contexts/VimModeContext.js +48 -0
  97. package/dist/src/ui/contexts/VimModeContext.js.map +1 -0
  98. package/dist/src/ui/editors/editorSettingsManager.js +1 -0
  99. package/dist/src/ui/editors/editorSettingsManager.js.map +1 -1
  100. package/dist/src/ui/hooks/atCommandProcessor.js +56 -48
  101. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
  102. package/dist/src/ui/hooks/shellCommandProcessor.d.ts +1 -0
  103. package/dist/src/ui/hooks/shellCommandProcessor.js +139 -200
  104. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
  105. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +7 -3
  106. package/dist/src/ui/hooks/slashCommandProcessor.js +198 -127
  107. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
  108. package/dist/src/ui/hooks/useCompletion.d.ts +1 -1
  109. package/dist/src/ui/hooks/useCompletion.js +108 -76
  110. package/dist/src/ui/hooks/useCompletion.js.map +1 -1
  111. package/dist/src/ui/hooks/useConsoleMessages.js +53 -37
  112. package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -1
  113. package/dist/src/ui/hooks/useGeminiStream.js +5 -2
  114. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
  115. package/dist/src/ui/hooks/useKeypress.js +5 -2
  116. package/dist/src/ui/hooks/useKeypress.js.map +1 -1
  117. package/dist/src/ui/hooks/usePhraseCycler.js +1 -0
  118. package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
  119. package/dist/src/ui/hooks/useReactToolScheduler.js +0 -1
  120. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
  121. package/dist/src/ui/hooks/vim.d.ts +28 -0
  122. package/dist/src/ui/hooks/vim.js +630 -0
  123. package/dist/src/ui/hooks/vim.js.map +1 -0
  124. package/dist/src/ui/themes/theme-manager.js +10 -1
  125. package/dist/src/ui/themes/theme-manager.js.map +1 -1
  126. package/dist/src/ui/themes/theme.d.ts +1 -0
  127. package/dist/src/ui/themes/theme.js +19 -4
  128. package/dist/src/ui/themes/theme.js.map +1 -1
  129. package/dist/src/ui/utils/textUtils.d.ts +0 -8
  130. package/dist/src/ui/utils/textUtils.js +0 -22
  131. package/dist/src/ui/utils/textUtils.js.map +1 -1
  132. package/dist/src/ui/utils/updateCheck.d.ts +7 -1
  133. package/dist/src/ui/utils/updateCheck.js +9 -3
  134. package/dist/src/ui/utils/updateCheck.js.map +1 -1
  135. package/dist/src/utils/events.d.ts +11 -0
  136. package/dist/src/utils/events.js +13 -0
  137. package/dist/src/utils/events.js.map +1 -0
  138. package/dist/src/utils/gitUtils.d.ts +10 -0
  139. package/dist/src/utils/gitUtils.js +24 -0
  140. package/dist/src/utils/gitUtils.js.map +1 -0
  141. package/dist/src/utils/handleAutoUpdate.d.ts +10 -0
  142. package/dist/src/utils/handleAutoUpdate.js +97 -0
  143. package/dist/src/utils/handleAutoUpdate.js.map +1 -0
  144. package/dist/src/utils/installationInfo.d.ts +23 -0
  145. package/dist/src/utils/installationInfo.js +154 -0
  146. package/dist/src/utils/installationInfo.js.map +1 -0
  147. package/dist/src/utils/sandbox-macos-permissive-closed.sb +6 -0
  148. package/dist/src/utils/sandbox-macos-permissive-open.sb +6 -0
  149. package/dist/src/utils/sandbox-macos-permissive-proxied.sb +6 -0
  150. package/dist/src/utils/sandbox-macos-restrictive-closed.sb +6 -0
  151. package/dist/src/utils/sandbox-macos-restrictive-open.sb +6 -0
  152. package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +6 -0
  153. package/dist/src/utils/sandbox.d.ts +2 -2
  154. package/dist/src/utils/sandbox.js +29 -10
  155. package/dist/src/utils/sandbox.js.map +1 -1
  156. package/dist/src/utils/updateEventEmitter.d.ts +11 -0
  157. package/dist/src/utils/updateEventEmitter.js +12 -0
  158. package/dist/src/utils/updateEventEmitter.js.map +1 -0
  159. package/dist/tsconfig.tsbuildinfo +1 -1
  160. package/package.json +3 -3
  161. package/dist/google-gemini-cli-0.1.13.tgz +0 -0
@@ -12,10 +12,12 @@ import { compressCommand } from '../ui/commands/compressCommand.js';
12
12
  import { copyCommand } from '../ui/commands/copyCommand.js';
13
13
  import { corgiCommand } from '../ui/commands/corgiCommand.js';
14
14
  import { docsCommand } from '../ui/commands/docsCommand.js';
15
+ import { directoryCommand } from '../ui/commands/directoryCommand.js';
15
16
  import { editorCommand } from '../ui/commands/editorCommand.js';
16
17
  import { extensionsCommand } from '../ui/commands/extensionsCommand.js';
17
18
  import { helpCommand } from '../ui/commands/helpCommand.js';
18
19
  import { ideCommand } from '../ui/commands/ideCommand.js';
20
+ import { initCommand } from '../ui/commands/initCommand.js';
19
21
  import { mcpCommand } from '../ui/commands/mcpCommand.js';
20
22
  import { memoryCommand } from '../ui/commands/memoryCommand.js';
21
23
  import { privacyCommand } from '../ui/commands/privacyCommand.js';
@@ -24,6 +26,9 @@ import { restoreCommand } from '../ui/commands/restoreCommand.js';
24
26
  import { statsCommand } from '../ui/commands/statsCommand.js';
25
27
  import { themeCommand } from '../ui/commands/themeCommand.js';
26
28
  import { toolsCommand } from '../ui/commands/toolsCommand.js';
29
+ import { vimCommand } from '../ui/commands/vimCommand.js';
30
+ import { setupGithubCommand } from '../ui/commands/setupGithubCommand.js';
31
+ import { isGitHubRepository } from '../utils/gitUtils.js';
27
32
  /**
28
33
  * Loads the core, hard-coded slash commands that are an integral part
29
34
  * of the Gemini CLI application.
@@ -51,10 +56,12 @@ export class BuiltinCommandLoader {
51
56
  copyCommand,
52
57
  corgiCommand,
53
58
  docsCommand,
59
+ directoryCommand,
54
60
  editorCommand,
55
61
  extensionsCommand,
56
62
  helpCommand,
57
63
  ideCommand(this.config),
64
+ initCommand,
58
65
  mcpCommand,
59
66
  memoryCommand,
60
67
  privacyCommand,
@@ -63,6 +70,8 @@ export class BuiltinCommandLoader {
63
70
  statsCommand,
64
71
  themeCommand,
65
72
  toolsCommand,
73
+ vimCommand,
74
+ ...(isGitHubRepository() ? [setupGithubCommand] : []),
66
75
  ];
67
76
  return allDefinitions.filter((cmd) => cmd !== null);
68
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BuiltinCommandLoader.js","sourceRoot":"","sources":["../../../src/services/BuiltinCommandLoader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OA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EAAE,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACtD,CAAC;QAEF,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAuB,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;IAC3E,CAAC;CACF"}
@@ -28,13 +28,17 @@ export declare class CommandService {
28
28
  *
29
29
  * This factory method orchestrates the entire command loading process. It
30
30
  * runs all provided loaders in parallel, aggregates their results, handles
31
- * name conflicts by letting the last-loaded command win, and then returns a
31
+ * name conflicts for extension commands by renaming them, and then returns a
32
32
  * fully constructed `CommandService` instance.
33
33
  *
34
+ * Conflict resolution:
35
+ * - Extension commands that conflict with existing commands are renamed to
36
+ * `extensionName.commandName`
37
+ * - Non-extension commands (built-in, user, project) override earlier commands
38
+ * with the same name based on loader order
39
+ *
34
40
  * @param loaders An array of objects that conform to the `ICommandLoader`
35
- * interface. The order of loaders is significant: if multiple loaders
36
- * provide a command with the same name, the command from the loader that
37
- * appears later in the array will take precedence.
41
+ * interface. Built-in commands should come first, followed by FileCommandLoader.
38
42
  * @param signal An AbortSignal to cancel the loading process.
39
43
  * @returns A promise that resolves to a new, fully initialized `CommandService` instance.
40
44
  */
@@ -28,13 +28,17 @@ export class CommandService {
28
28
  *
29
29
  * This factory method orchestrates the entire command loading process. It
30
30
  * runs all provided loaders in parallel, aggregates their results, handles
31
- * name conflicts by letting the last-loaded command win, and then returns a
31
+ * name conflicts for extension commands by renaming them, and then returns a
32
32
  * fully constructed `CommandService` instance.
33
33
  *
34
+ * Conflict resolution:
35
+ * - Extension commands that conflict with existing commands are renamed to
36
+ * `extensionName.commandName`
37
+ * - Non-extension commands (built-in, user, project) override earlier commands
38
+ * with the same name based on loader order
39
+ *
34
40
  * @param loaders An array of objects that conform to the `ICommandLoader`
35
- * interface. The order of loaders is significant: if multiple loaders
36
- * provide a command with the same name, the command from the loader that
37
- * appears later in the array will take precedence.
41
+ * interface. Built-in commands should come first, followed by FileCommandLoader.
38
42
  * @param signal An AbortSignal to cancel the loading process.
39
43
  * @returns A promise that resolves to a new, fully initialized `CommandService` instance.
40
44
  */
@@ -49,12 +53,24 @@ export class CommandService {
49
53
  console.debug('A command loader failed:', result.reason);
50
54
  }
51
55
  }
52
- // De-duplicate commands using a Map. The last one found with a given name wins.
53
- // This creates a natural override system based on the order of the loaders
54
- // passed to the constructor.
55
56
  const commandMap = new Map();
56
57
  for (const cmd of allCommands) {
57
- commandMap.set(cmd.name, cmd);
58
+ let finalName = cmd.name;
59
+ // Extension commands get renamed if they conflict with existing commands
60
+ if (cmd.extensionName && commandMap.has(cmd.name)) {
61
+ let renamedName = `${cmd.extensionName}.${cmd.name}`;
62
+ let suffix = 1;
63
+ // Keep trying until we find a name that doesn't conflict
64
+ while (commandMap.has(renamedName)) {
65
+ renamedName = `${cmd.extensionName}.${cmd.name}${suffix}`;
66
+ suffix++;
67
+ }
68
+ finalName = renamedName;
69
+ }
70
+ commandMap.set(finalName, {
71
+ ...cmd,
72
+ name: finalName,
73
+ });
58
74
  }
59
75
  const finalCommands = Object.freeze(Array.from(commandMap.values()));
60
76
  return new CommandService(finalCommands);
@@ -1 +1 @@
1
- {"version":3,"file":"CommandService.js","sourceRoot":"","sources":["../../../src/services/CommandService.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IAKY;IAJrC;;;OAGG;IACH,YAAqC,QAAiC;QAAjC,aAAQ,GAAR,QAAQ,CAAyB;IAAG,CAAC;IAE1E;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,OAAyB,EACzB,MAAmB;QAEnB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CACtC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CACrD,CAAC;QAEF,MAAM,WAAW,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,CAAC;QACrE,OAAO,IAAI,cAAc,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;OAOG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF"}
@@ -21,16 +21,28 @@ export declare class FileCommandLoader implements ICommandLoader {
21
21
  private readonly projectRoot;
22
22
  constructor(config: Config | null);
23
23
  /**
24
- * Loads all commands, applying the precedence rule where project-level
25
- * commands override user-level commands with the same name.
24
+ * Loads all commands from user, project, and extension directories.
25
+ * Returns commands in order: user project extensions (alphabetically).
26
+ *
27
+ * Order is important for conflict resolution in CommandService:
28
+ * - User/project commands (without extensionName) use "last wins" strategy
29
+ * - Extension commands (with extensionName) get renamed if conflicts exist
30
+ *
26
31
  * @param signal An AbortSignal to cancel the loading process.
27
- * @returns A promise that resolves to an array of loaded SlashCommands.
32
+ * @returns A promise that resolves to an array of all loaded SlashCommands.
28
33
  */
29
34
  loadCommands(signal: AbortSignal): Promise<SlashCommand[]>;
35
+ /**
36
+ * Get all command directories in order for loading.
37
+ * User commands → Project commands → Extension commands
38
+ * This order ensures extension commands can detect all conflicts.
39
+ */
40
+ private getCommandDirectories;
30
41
  /**
31
42
  * Parses a single .toml file and transforms it into a SlashCommand object.
32
43
  * @param filePath The absolute path to the .toml file.
33
44
  * @param baseDir The root command directory for name calculation.
45
+ * @param extensionName Optional extension name to prefix commands with.
34
46
  * @returns A promise resolving to a SlashCommand, or null if the file is invalid.
35
47
  */
36
48
  private parseAndAdaptFile;
@@ -11,7 +11,8 @@ import { z } from 'zod';
11
11
  import { getProjectCommandsDir, getUserCommandsDir, } from '@google/gemini-cli-core';
12
12
  import { CommandKind, } from '../ui/commands/types.js';
13
13
  import { DefaultArgumentProcessor, ShorthandArgumentProcessor, } from './prompt-processors/argumentProcessor.js';
14
- import { SHORTHAND_ARGS_PLACEHOLDER, } from './prompt-processors/types.js';
14
+ import { SHORTHAND_ARGS_PLACEHOLDER, SHELL_INJECTION_TRIGGER, } from './prompt-processors/types.js';
15
+ import { ConfirmationRequiredError, ShellProcessor, } from './prompt-processors/shellProcessor.js';
15
16
  /**
16
17
  * Defines the Zod schema for a command definition file. This serves as the
17
18
  * single source of truth for both validation and type inference.
@@ -41,54 +42,78 @@ export class FileCommandLoader {
41
42
  this.projectRoot = config?.getProjectRoot() || process.cwd();
42
43
  }
43
44
  /**
44
- * Loads all commands, applying the precedence rule where project-level
45
- * commands override user-level commands with the same name.
45
+ * Loads all commands from user, project, and extension directories.
46
+ * Returns commands in order: user project extensions (alphabetically).
47
+ *
48
+ * Order is important for conflict resolution in CommandService:
49
+ * - User/project commands (without extensionName) use "last wins" strategy
50
+ * - Extension commands (with extensionName) get renamed if conflicts exist
51
+ *
46
52
  * @param signal An AbortSignal to cancel the loading process.
47
- * @returns A promise that resolves to an array of loaded SlashCommands.
53
+ * @returns A promise that resolves to an array of all loaded SlashCommands.
48
54
  */
49
55
  async loadCommands(signal) {
50
- const commandMap = new Map();
56
+ const allCommands = [];
51
57
  const globOptions = {
52
58
  nodir: true,
53
59
  dot: true,
54
60
  signal,
61
+ follow: true,
55
62
  };
56
- try {
57
- // User Commands
58
- const userDir = getUserCommandsDir();
59
- const userFiles = await glob('**/*.toml', {
60
- ...globOptions,
61
- cwd: userDir,
62
- });
63
- const userCommandPromises = userFiles.map((file) => this.parseAndAdaptFile(path.join(userDir, file), userDir));
64
- const userCommands = (await Promise.all(userCommandPromises)).filter((cmd) => cmd !== null);
65
- for (const cmd of userCommands) {
66
- commandMap.set(cmd.name, cmd);
63
+ // Load commands from each directory
64
+ const commandDirs = this.getCommandDirectories();
65
+ for (const dirInfo of commandDirs) {
66
+ try {
67
+ const files = await glob('**/*.toml', {
68
+ ...globOptions,
69
+ cwd: dirInfo.path,
70
+ });
71
+ const commandPromises = files.map((file) => this.parseAndAdaptFile(path.join(dirInfo.path, file), dirInfo.path, dirInfo.extensionName));
72
+ const commands = (await Promise.all(commandPromises)).filter((cmd) => cmd !== null);
73
+ // Add all commands without deduplication
74
+ allCommands.push(...commands);
67
75
  }
68
- // Project Commands (these intentionally override user commands)
69
- const projectDir = getProjectCommandsDir(this.projectRoot);
70
- const projectFiles = await glob('**/*.toml', {
71
- ...globOptions,
72
- cwd: projectDir,
73
- });
74
- const projectCommandPromises = projectFiles.map((file) => this.parseAndAdaptFile(path.join(projectDir, file), projectDir));
75
- const projectCommands = (await Promise.all(projectCommandPromises)).filter((cmd) => cmd !== null);
76
- for (const cmd of projectCommands) {
77
- commandMap.set(cmd.name, cmd);
76
+ catch (error) {
77
+ if (error.code !== 'ENOENT') {
78
+ console.error(`[FileCommandLoader] Error loading commands from ${dirInfo.path}:`, error);
79
+ }
78
80
  }
79
81
  }
80
- catch (error) {
81
- console.error(`[FileCommandLoader] Error during file search:`, error);
82
+ return allCommands;
83
+ }
84
+ /**
85
+ * Get all command directories in order for loading.
86
+ * User commands → Project commands → Extension commands
87
+ * This order ensures extension commands can detect all conflicts.
88
+ */
89
+ getCommandDirectories() {
90
+ const dirs = [];
91
+ // 1. User commands
92
+ dirs.push({ path: getUserCommandsDir() });
93
+ // 2. Project commands (override user commands)
94
+ dirs.push({ path: getProjectCommandsDir(this.projectRoot) });
95
+ // 3. Extension commands (processed last to detect all conflicts)
96
+ if (this.config) {
97
+ const activeExtensions = this.config
98
+ .getExtensions()
99
+ .filter((ext) => ext.isActive)
100
+ .sort((a, b) => a.name.localeCompare(b.name)); // Sort alphabetically for deterministic loading
101
+ const extensionCommandDirs = activeExtensions.map((ext) => ({
102
+ path: path.join(ext.path, 'commands'),
103
+ extensionName: ext.name,
104
+ }));
105
+ dirs.push(...extensionCommandDirs);
82
106
  }
83
- return Array.from(commandMap.values());
107
+ return dirs;
84
108
  }
85
109
  /**
86
110
  * Parses a single .toml file and transforms it into a SlashCommand object.
87
111
  * @param filePath The absolute path to the .toml file.
88
112
  * @param baseDir The root command directory for name calculation.
113
+ * @param extensionName Optional extension name to prefix commands with.
89
114
  * @returns A promise resolving to a SlashCommand, or null if the file is invalid.
90
115
  */
91
- async parseAndAdaptFile(filePath, baseDir) {
116
+ async parseAndAdaptFile(filePath, baseDir, extensionName) {
92
117
  let fileContent;
93
118
  try {
94
119
  fileContent = await fs.readFile(filePath, 'utf-8');
@@ -113,14 +138,24 @@ export class FileCommandLoader {
113
138
  const validDef = validationResult.data;
114
139
  const relativePathWithExt = path.relative(baseDir, filePath);
115
140
  const relativePath = relativePathWithExt.substring(0, relativePathWithExt.length - 5);
116
- const commandName = relativePath
141
+ const baseCommandName = relativePath
117
142
  .split(path.sep)
118
143
  // Sanitize each path segment to prevent ambiguity. Since ':' is our
119
144
  // namespace separator, we replace any literal colons in filenames
120
145
  // with underscores to avoid naming conflicts.
121
146
  .map((segment) => segment.replaceAll(':', '_'))
122
147
  .join(':');
148
+ // Add extension name tag for extension commands
149
+ const defaultDescription = `Custom command from ${path.basename(filePath)}`;
150
+ let description = validDef.description || defaultDescription;
151
+ if (extensionName) {
152
+ description = `[${extensionName}] ${description}`;
153
+ }
123
154
  const processors = [];
155
+ // Add the Shell Processor if needed.
156
+ if (validDef.prompt.includes(SHELL_INJECTION_TRIGGER)) {
157
+ processors.push(new ShellProcessor(baseCommandName));
158
+ }
124
159
  // The presence of '{{args}}' is the switch that determines the behavior.
125
160
  if (validDef.prompt.includes(SHORTHAND_ARGS_PLACEHOLDER)) {
126
161
  processors.push(new ShorthandArgumentProcessor());
@@ -129,26 +164,43 @@ export class FileCommandLoader {
129
164
  processors.push(new DefaultArgumentProcessor());
130
165
  }
131
166
  return {
132
- name: commandName,
133
- description: validDef.description ||
134
- `Custom command from ${path.basename(filePath)}`,
167
+ name: baseCommandName,
168
+ description,
135
169
  kind: CommandKind.FILE,
170
+ extensionName,
136
171
  action: async (context, _args) => {
137
172
  if (!context.invocation) {
138
- console.error(`[FileCommandLoader] Critical error: Command '${commandName}' was executed without invocation context.`);
173
+ console.error(`[FileCommandLoader] Critical error: Command '${baseCommandName}' was executed without invocation context.`);
139
174
  return {
140
175
  type: 'submit_prompt',
141
176
  content: validDef.prompt, // Fallback to unprocessed prompt
142
177
  };
143
178
  }
144
- let processedPrompt = validDef.prompt;
145
- for (const processor of processors) {
146
- processedPrompt = await processor.process(processedPrompt, context);
179
+ try {
180
+ let processedPrompt = validDef.prompt;
181
+ for (const processor of processors) {
182
+ processedPrompt = await processor.process(processedPrompt, context);
183
+ }
184
+ return {
185
+ type: 'submit_prompt',
186
+ content: processedPrompt,
187
+ };
188
+ }
189
+ catch (e) {
190
+ // Check if it's our specific error type
191
+ if (e instanceof ConfirmationRequiredError) {
192
+ // Halt and request confirmation from the UI layer.
193
+ return {
194
+ type: 'confirm_shell_commands',
195
+ commandsToConfirm: e.commandsToConfirm,
196
+ originalInvocation: {
197
+ raw: context.invocation.raw,
198
+ },
199
+ };
200
+ }
201
+ // Re-throw other errors to be handled by the global error handler.
202
+ throw e;
147
203
  }
148
- return {
149
- type: 'submit_prompt',
150
- content: processedPrompt,
151
- };
152
204
  },
153
205
  };
154
206
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FileCommandLoader.js","sourceRoot":"","sources":["../../../src/services/FileCommandLoader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAEL,WAAW,GAGZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAEL,0BAA0B,GAC3B,MAAM,8BAA8B,CAAC;AAEtC;;;GAGG;AACH,MAAM,oBAA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AAY,yBAAyB,EAAE,CAAC;wBAC3C,mDAAmD;wBACnD,OAAO;4BACL,IAAI,EAAE,wBAAwB;4BAC9B,iBAAiB,EAAE,CAAC,CAAC,iBAAiB;4BACtC,kBAAkB,EAAE;gCAClB,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG;6BAC5B;yBACF,CAAC;oBACJ,CAAC;oBACD,mEAAmE;oBACnE,MAAM,CAAC,CAAC;gBACV,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Config } from '@google/gemini-cli-core';
7
+ import { SlashCommand } from '../ui/commands/types.js';
8
+ import { ICommandLoader } from './types.js';
9
+ /**
10
+ * Discovers and loads executable slash commands from prompts exposed by
11
+ * Model-Context-Protocol (MCP) servers.
12
+ */
13
+ export declare class McpPromptLoader implements ICommandLoader {
14
+ private readonly config;
15
+ constructor(config: Config | null);
16
+ /**
17
+ * Loads all available prompts from all configured MCP servers and adapts
18
+ * them into executable SlashCommand objects.
19
+ *
20
+ * @param _signal An AbortSignal (unused for this synchronous loader).
21
+ * @returns A promise that resolves to an array of loaded SlashCommands.
22
+ */
23
+ loadCommands(_signal: AbortSignal): Promise<SlashCommand[]>;
24
+ private parseArgs;
25
+ }
@@ -0,0 +1,192 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { getErrorMessage, getMCPServerPrompts, } from '@google/gemini-cli-core';
7
+ import { CommandKind, } from '../ui/commands/types.js';
8
+ /**
9
+ * Discovers and loads executable slash commands from prompts exposed by
10
+ * Model-Context-Protocol (MCP) servers.
11
+ */
12
+ export class McpPromptLoader {
13
+ config;
14
+ constructor(config) {
15
+ this.config = config;
16
+ }
17
+ /**
18
+ * Loads all available prompts from all configured MCP servers and adapts
19
+ * them into executable SlashCommand objects.
20
+ *
21
+ * @param _signal An AbortSignal (unused for this synchronous loader).
22
+ * @returns A promise that resolves to an array of loaded SlashCommands.
23
+ */
24
+ loadCommands(_signal) {
25
+ const promptCommands = [];
26
+ if (!this.config) {
27
+ return Promise.resolve([]);
28
+ }
29
+ const mcpServers = this.config.getMcpServers() || {};
30
+ for (const serverName in mcpServers) {
31
+ const prompts = getMCPServerPrompts(this.config, serverName) || [];
32
+ for (const prompt of prompts) {
33
+ const commandName = `${prompt.name}`;
34
+ const newPromptCommand = {
35
+ name: commandName,
36
+ description: prompt.description || `Invoke prompt ${prompt.name}`,
37
+ kind: CommandKind.MCP_PROMPT,
38
+ subCommands: [
39
+ {
40
+ name: 'help',
41
+ description: 'Show help for this prompt',
42
+ kind: CommandKind.MCP_PROMPT,
43
+ action: async () => {
44
+ if (!prompt.arguments || prompt.arguments.length === 0) {
45
+ return {
46
+ type: 'message',
47
+ messageType: 'info',
48
+ content: `Prompt "${prompt.name}" has no arguments.`,
49
+ };
50
+ }
51
+ let helpMessage = `Arguments for "${prompt.name}":\n\n`;
52
+ if (prompt.arguments && prompt.arguments.length > 0) {
53
+ helpMessage += `You can provide arguments by name (e.g., --argName="value") or by position.\n\n`;
54
+ helpMessage += `e.g., ${prompt.name} ${prompt.arguments?.map((_) => `"foo"`)} is equivalent to ${prompt.name} ${prompt.arguments?.map((arg) => `--${arg.name}="foo"`)}\n\n`;
55
+ }
56
+ for (const arg of prompt.arguments) {
57
+ helpMessage += ` --${arg.name}\n`;
58
+ if (arg.description) {
59
+ helpMessage += ` ${arg.description}\n`;
60
+ }
61
+ helpMessage += ` (required: ${arg.required ? 'yes' : 'no'})\n\n`;
62
+ }
63
+ return {
64
+ type: 'message',
65
+ messageType: 'info',
66
+ content: helpMessage,
67
+ };
68
+ },
69
+ },
70
+ ],
71
+ action: async (context, args) => {
72
+ if (!this.config) {
73
+ return {
74
+ type: 'message',
75
+ messageType: 'error',
76
+ content: 'Config not loaded.',
77
+ };
78
+ }
79
+ const promptInputs = this.parseArgs(args, prompt.arguments);
80
+ if (promptInputs instanceof Error) {
81
+ return {
82
+ type: 'message',
83
+ messageType: 'error',
84
+ content: promptInputs.message,
85
+ };
86
+ }
87
+ try {
88
+ const mcpServers = this.config.getMcpServers() || {};
89
+ const mcpServerConfig = mcpServers[serverName];
90
+ if (!mcpServerConfig) {
91
+ return {
92
+ type: 'message',
93
+ messageType: 'error',
94
+ content: `MCP server config not found for '${serverName}'.`,
95
+ };
96
+ }
97
+ const result = await prompt.invoke(promptInputs);
98
+ if (result.error) {
99
+ return {
100
+ type: 'message',
101
+ messageType: 'error',
102
+ content: `Error invoking prompt: ${result.error}`,
103
+ };
104
+ }
105
+ if (!result.messages?.[0]?.content?.text) {
106
+ return {
107
+ type: 'message',
108
+ messageType: 'error',
109
+ content: 'Received an empty or invalid prompt response from the server.',
110
+ };
111
+ }
112
+ return {
113
+ type: 'submit_prompt',
114
+ content: JSON.stringify(result.messages[0].content.text),
115
+ };
116
+ }
117
+ catch (error) {
118
+ return {
119
+ type: 'message',
120
+ messageType: 'error',
121
+ content: `Error: ${getErrorMessage(error)}`,
122
+ };
123
+ }
124
+ },
125
+ completion: async (_, partialArg) => {
126
+ if (!prompt || !prompt.arguments) {
127
+ return [];
128
+ }
129
+ const suggestions = [];
130
+ const usedArgNames = new Set((partialArg.match(/--([^=]+)/g) || []).map((s) => s.substring(2)));
131
+ for (const arg of prompt.arguments) {
132
+ if (!usedArgNames.has(arg.name)) {
133
+ suggestions.push(`--${arg.name}=""`);
134
+ }
135
+ }
136
+ return suggestions;
137
+ },
138
+ };
139
+ promptCommands.push(newPromptCommand);
140
+ }
141
+ }
142
+ return Promise.resolve(promptCommands);
143
+ }
144
+ parseArgs(userArgs, promptArgs) {
145
+ const argValues = {};
146
+ const promptInputs = {};
147
+ // arg parsing: --key="value" or --key=value
148
+ const namedArgRegex = /--([^=]+)=(?:"((?:\\.|[^"\\])*)"|([^ ]*))/g;
149
+ let match;
150
+ const remainingArgs = [];
151
+ let lastIndex = 0;
152
+ while ((match = namedArgRegex.exec(userArgs)) !== null) {
153
+ const key = match[1];
154
+ const value = match[2] ?? match[3]; // Quoted or unquoted value
155
+ argValues[key] = value;
156
+ // Capture text between matches as potential positional args
157
+ if (match.index > lastIndex) {
158
+ remainingArgs.push(userArgs.substring(lastIndex, match.index).trim());
159
+ }
160
+ lastIndex = namedArgRegex.lastIndex;
161
+ }
162
+ // Capture any remaining text after the last named arg
163
+ if (lastIndex < userArgs.length) {
164
+ remainingArgs.push(userArgs.substring(lastIndex).trim());
165
+ }
166
+ const positionalArgs = remainingArgs.join(' ').split(/ +/);
167
+ if (!promptArgs) {
168
+ return promptInputs;
169
+ }
170
+ for (const arg of promptArgs) {
171
+ if (argValues[arg.name]) {
172
+ promptInputs[arg.name] = argValues[arg.name];
173
+ }
174
+ }
175
+ const unfilledArgs = promptArgs.filter((arg) => arg.required && !promptInputs[arg.name]);
176
+ const missingArgs = [];
177
+ for (let i = 0; i < unfilledArgs.length; i++) {
178
+ if (positionalArgs.length > i && positionalArgs[i]) {
179
+ promptInputs[unfilledArgs[i].name] = positionalArgs[i];
180
+ }
181
+ else {
182
+ missingArgs.push(unfilledArgs[i].name);
183
+ }
184
+ }
185
+ if (missingArgs.length > 0) {
186
+ const missingArgNames = missingArgs.map((name) => `--${name}`).join(', ');
187
+ return new Error(`Missing required argument(s): ${missingArgNames}`);
188
+ }
189
+ return promptInputs;
190
+ }
191
+ }
192
+ //# sourceMappingURL=McpPromptLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpPromptLoader.js","sourceRoot":"","sources":["../../../src/services/McpPromptLoader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,eAAe,EACf,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,WAAW,GAGZ,MAAM,yBAAyB,CAAC;AAIjC;;;GAGG;AACH,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,MAA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