@google/gemini-cli 0.1.13 → 0.1.14

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 (176) hide show
  1. package/README.md +22 -1
  2. package/dist/google-gemini-cli-0.1.13.tgz +0 -0
  3. package/dist/package.json +6 -3
  4. package/dist/src/config/config.d.ts +3 -2
  5. package/dist/src/config/config.js +19 -29
  6. package/dist/src/config/config.js.map +1 -1
  7. package/dist/src/config/settings.d.ts +6 -2
  8. package/dist/src/config/settings.js +25 -10
  9. package/dist/src/config/settings.js.map +1 -1
  10. package/dist/src/gemini.js +7 -21
  11. package/dist/src/gemini.js.map +1 -1
  12. package/dist/src/generated/git-commit.d.ts +1 -1
  13. package/dist/src/generated/git-commit.js +1 -1
  14. package/dist/src/patches/is-in-ci.d.ts +7 -0
  15. package/dist/src/patches/is-in-ci.js +15 -0
  16. package/dist/src/patches/is-in-ci.js.map +1 -0
  17. package/dist/src/services/BuiltinCommandLoader.d.ts +24 -0
  18. package/dist/src/services/BuiltinCommandLoader.js +70 -0
  19. package/dist/src/services/BuiltinCommandLoader.js.map +1 -0
  20. package/dist/src/services/CommandService.d.ts +43 -7
  21. package/dist/src/services/CommandService.js +61 -56
  22. package/dist/src/services/CommandService.js.map +1 -1
  23. package/dist/src/services/FileCommandLoader.d.ts +37 -0
  24. package/dist/src/services/FileCommandLoader.js +156 -0
  25. package/dist/src/services/FileCommandLoader.js.map +1 -0
  26. package/dist/src/services/prompt-processors/argumentProcessor.d.ts +21 -0
  27. package/dist/src/services/prompt-processors/argumentProcessor.js +28 -0
  28. package/dist/src/services/prompt-processors/argumentProcessor.js.map +1 -0
  29. package/dist/src/services/prompt-processors/types.d.ts +34 -0
  30. package/dist/src/services/prompt-processors/types.js +10 -0
  31. package/dist/src/services/prompt-processors/types.js.map +1 -0
  32. package/dist/src/services/types.d.ts +22 -0
  33. package/dist/src/services/types.js +7 -0
  34. package/dist/src/services/types.js.map +1 -0
  35. package/dist/src/ui/App.js +15 -25
  36. package/dist/src/ui/App.js.map +1 -1
  37. package/dist/src/ui/colors.js +6 -0
  38. package/dist/src/ui/colors.js.map +1 -1
  39. package/dist/src/ui/commands/aboutCommand.js +2 -0
  40. package/dist/src/ui/commands/aboutCommand.js.map +1 -1
  41. package/dist/src/ui/commands/authCommand.js +2 -0
  42. package/dist/src/ui/commands/authCommand.js.map +1 -1
  43. package/dist/src/ui/commands/bugCommand.js +2 -0
  44. package/dist/src/ui/commands/bugCommand.js.map +1 -1
  45. package/dist/src/ui/commands/chatCommand.js +12 -2
  46. package/dist/src/ui/commands/chatCommand.js.map +1 -1
  47. package/dist/src/ui/commands/clearCommand.js +2 -0
  48. package/dist/src/ui/commands/clearCommand.js.map +1 -1
  49. package/dist/src/ui/commands/compressCommand.js +3 -1
  50. package/dist/src/ui/commands/compressCommand.js.map +1 -1
  51. package/dist/src/ui/commands/copyCommand.d.ts +7 -0
  52. package/dist/src/ui/commands/copyCommand.js +59 -0
  53. package/dist/src/ui/commands/copyCommand.js.map +1 -0
  54. package/dist/src/ui/commands/corgiCommand.js +2 -0
  55. package/dist/src/ui/commands/corgiCommand.js.map +1 -1
  56. package/dist/src/ui/commands/docsCommand.js +2 -0
  57. package/dist/src/ui/commands/docsCommand.js.map +1 -1
  58. package/dist/src/ui/commands/editorCommand.js +2 -0
  59. package/dist/src/ui/commands/editorCommand.js.map +1 -1
  60. package/dist/src/ui/commands/extensionsCommand.js +2 -0
  61. package/dist/src/ui/commands/extensionsCommand.js.map +1 -1
  62. package/dist/src/ui/commands/helpCommand.js +3 -1
  63. package/dist/src/ui/commands/helpCommand.js.map +1 -1
  64. package/dist/src/ui/commands/ideCommand.js +20 -22
  65. package/dist/src/ui/commands/ideCommand.js.map +1 -1
  66. package/dist/src/ui/commands/mcpCommand.js +181 -5
  67. package/dist/src/ui/commands/mcpCommand.js.map +1 -1
  68. package/dist/src/ui/commands/memoryCommand.js +11 -4
  69. package/dist/src/ui/commands/memoryCommand.js.map +1 -1
  70. package/dist/src/ui/commands/privacyCommand.js +2 -0
  71. package/dist/src/ui/commands/privacyCommand.js.map +1 -1
  72. package/dist/src/ui/commands/quitCommand.js +3 -1
  73. package/dist/src/ui/commands/quitCommand.js.map +1 -1
  74. package/dist/src/ui/commands/restoreCommand.js +2 -0
  75. package/dist/src/ui/commands/restoreCommand.js.map +1 -1
  76. package/dist/src/ui/commands/statsCommand.js +5 -1
  77. package/dist/src/ui/commands/statsCommand.js.map +1 -1
  78. package/dist/src/ui/commands/themeCommand.js +2 -0
  79. package/dist/src/ui/commands/themeCommand.js.map +1 -1
  80. package/dist/src/ui/commands/toolsCommand.js +2 -0
  81. package/dist/src/ui/commands/toolsCommand.js.map +1 -1
  82. package/dist/src/ui/commands/types.d.ts +24 -3
  83. package/dist/src/ui/commands/types.js +5 -1
  84. package/dist/src/ui/commands/types.js.map +1 -1
  85. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +2 -2
  86. package/dist/src/ui/components/ContextSummaryDisplay.js +12 -12
  87. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
  88. package/dist/src/ui/components/Footer.js +1 -1
  89. package/dist/src/ui/components/Help.d.ts +1 -1
  90. package/dist/src/ui/components/IDEContextDetailDisplay.d.ts +11 -0
  91. package/dist/src/ui/components/IDEContextDetailDisplay.js +19 -0
  92. package/dist/src/ui/components/IDEContextDetailDisplay.js.map +1 -0
  93. package/dist/src/ui/components/InputPrompt.d.ts +1 -1
  94. package/dist/src/ui/components/InputPrompt.js +9 -99
  95. package/dist/src/ui/components/InputPrompt.js.map +1 -1
  96. package/dist/src/ui/components/ThemeDialog.js +42 -17
  97. package/dist/src/ui/components/ThemeDialog.js.map +1 -1
  98. package/dist/src/ui/components/messages/DiffRenderer.d.ts +1 -0
  99. package/dist/src/ui/components/messages/DiffRenderer.js +12 -11
  100. package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -1
  101. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +5 -4
  102. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
  103. package/dist/src/ui/components/shared/text-buffer.d.ts +3 -1
  104. package/dist/src/ui/components/shared/text-buffer.js +10 -9
  105. package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
  106. package/dist/src/ui/hooks/atCommandProcessor.js +54 -15
  107. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
  108. package/dist/src/ui/hooks/shellCommandProcessor.js +22 -8
  109. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
  110. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +1 -1
  111. package/dist/src/ui/hooks/slashCommandProcessor.js +40 -10
  112. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
  113. package/dist/src/ui/hooks/useAuthCommand.js +2 -2
  114. package/dist/src/ui/hooks/useAuthCommand.js.map +1 -1
  115. package/dist/src/ui/hooks/useCompletion.d.ts +3 -1
  116. package/dist/src/ui/hooks/useCompletion.js +113 -24
  117. package/dist/src/ui/hooks/useCompletion.js.map +1 -1
  118. package/dist/src/ui/hooks/useGeminiStream.js +57 -11
  119. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
  120. package/dist/src/ui/hooks/useInputHistory.d.ts +1 -1
  121. package/dist/src/ui/hooks/useShellHistory.d.ts +3 -2
  122. package/dist/src/ui/hooks/useShellHistory.js.map +1 -1
  123. package/dist/src/ui/hooks/useThemeCommand.js +24 -23
  124. package/dist/src/ui/hooks/useThemeCommand.js.map +1 -1
  125. package/dist/src/ui/themes/ansi-light.js +2 -0
  126. package/dist/src/ui/themes/ansi-light.js.map +1 -1
  127. package/dist/src/ui/themes/ansi.js +2 -0
  128. package/dist/src/ui/themes/ansi.js.map +1 -1
  129. package/dist/src/ui/themes/atom-one-dark.js +2 -0
  130. package/dist/src/ui/themes/atom-one-dark.js.map +1 -1
  131. package/dist/src/ui/themes/ayu-light.js +3 -1
  132. package/dist/src/ui/themes/ayu-light.js.map +1 -1
  133. package/dist/src/ui/themes/ayu.js +3 -1
  134. package/dist/src/ui/themes/ayu.js.map +1 -1
  135. package/dist/src/ui/themes/color-utils.d.ts +21 -0
  136. package/dist/src/ui/themes/color-utils.js +221 -0
  137. package/dist/src/ui/themes/color-utils.js.map +1 -0
  138. package/dist/src/ui/themes/dracula.js +2 -0
  139. package/dist/src/ui/themes/dracula.js.map +1 -1
  140. package/dist/src/ui/themes/github-dark.js +2 -0
  141. package/dist/src/ui/themes/github-dark.js.map +1 -1
  142. package/dist/src/ui/themes/github-light.js +2 -0
  143. package/dist/src/ui/themes/github-light.js.map +1 -1
  144. package/dist/src/ui/themes/googlecode.js +2 -0
  145. package/dist/src/ui/themes/googlecode.js.map +1 -1
  146. package/dist/src/ui/themes/no-color.js +3 -1
  147. package/dist/src/ui/themes/no-color.js.map +1 -1
  148. package/dist/src/ui/themes/shades-of-purple.d.ts +1 -1
  149. package/dist/src/ui/themes/shades-of-purple.js +3 -1
  150. package/dist/src/ui/themes/shades-of-purple.js.map +1 -1
  151. package/dist/src/ui/themes/theme-manager.d.ts +31 -6
  152. package/dist/src/ui/themes/theme-manager.js +104 -34
  153. package/dist/src/ui/themes/theme-manager.js.map +1 -1
  154. package/dist/src/ui/themes/theme.d.ts +22 -3
  155. package/dist/src/ui/themes/theme.js +229 -182
  156. package/dist/src/ui/themes/theme.js.map +1 -1
  157. package/dist/src/ui/themes/xcode.js +2 -0
  158. package/dist/src/ui/themes/xcode.js.map +1 -1
  159. package/dist/src/ui/types.d.ts +9 -1
  160. package/dist/src/ui/utils/CodeColorizer.d.ts +3 -1
  161. package/dist/src/ui/utils/CodeColorizer.js +23 -11
  162. package/dist/src/ui/utils/CodeColorizer.js.map +1 -1
  163. package/dist/src/ui/utils/commandUtils.d.ts +1 -0
  164. package/dist/src/ui/utils/commandUtils.js +47 -0
  165. package/dist/src/ui/utils/commandUtils.js.map +1 -1
  166. package/dist/src/ui/utils/markdownUtilities.js +1 -1
  167. package/dist/src/utils/sandbox.js +7 -3
  168. package/dist/src/utils/sandbox.js.map +1 -1
  169. package/dist/src/utils/userStartupWarnings.js +22 -1
  170. package/dist/src/utils/userStartupWarnings.js.map +1 -1
  171. package/dist/src/validateNonInterActiveAuth.d.ts +7 -0
  172. package/dist/src/validateNonInterActiveAuth.js +35 -0
  173. package/dist/src/validateNonInterActiveAuth.js.map +1 -0
  174. package/dist/tsconfig.tsbuildinfo +1 -1
  175. package/package.json +7 -4
  176. package/dist/google-gemini-cli-0.1.12.tgz +0 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { aboutCommand } from '../ui/commands/aboutCommand.js';
7
+ import { authCommand } from '../ui/commands/authCommand.js';
8
+ import { bugCommand } from '../ui/commands/bugCommand.js';
9
+ import { chatCommand } from '../ui/commands/chatCommand.js';
10
+ import { clearCommand } from '../ui/commands/clearCommand.js';
11
+ import { compressCommand } from '../ui/commands/compressCommand.js';
12
+ import { copyCommand } from '../ui/commands/copyCommand.js';
13
+ import { corgiCommand } from '../ui/commands/corgiCommand.js';
14
+ import { docsCommand } from '../ui/commands/docsCommand.js';
15
+ import { editorCommand } from '../ui/commands/editorCommand.js';
16
+ import { extensionsCommand } from '../ui/commands/extensionsCommand.js';
17
+ import { helpCommand } from '../ui/commands/helpCommand.js';
18
+ import { ideCommand } from '../ui/commands/ideCommand.js';
19
+ import { mcpCommand } from '../ui/commands/mcpCommand.js';
20
+ import { memoryCommand } from '../ui/commands/memoryCommand.js';
21
+ import { privacyCommand } from '../ui/commands/privacyCommand.js';
22
+ import { quitCommand } from '../ui/commands/quitCommand.js';
23
+ import { restoreCommand } from '../ui/commands/restoreCommand.js';
24
+ import { statsCommand } from '../ui/commands/statsCommand.js';
25
+ import { themeCommand } from '../ui/commands/themeCommand.js';
26
+ import { toolsCommand } from '../ui/commands/toolsCommand.js';
27
+ /**
28
+ * Loads the core, hard-coded slash commands that are an integral part
29
+ * of the Gemini CLI application.
30
+ */
31
+ export class BuiltinCommandLoader {
32
+ config;
33
+ constructor(config) {
34
+ this.config = config;
35
+ }
36
+ /**
37
+ * Gathers all raw built-in command definitions, injects dependencies where
38
+ * needed (e.g., config) and filters out any that are not available.
39
+ *
40
+ * @param _signal An AbortSignal (unused for this synchronous loader).
41
+ * @returns A promise that resolves to an array of `SlashCommand` objects.
42
+ */
43
+ async loadCommands(_signal) {
44
+ const allDefinitions = [
45
+ aboutCommand,
46
+ authCommand,
47
+ bugCommand,
48
+ chatCommand,
49
+ clearCommand,
50
+ compressCommand,
51
+ copyCommand,
52
+ corgiCommand,
53
+ docsCommand,
54
+ editorCommand,
55
+ extensionsCommand,
56
+ helpCommand,
57
+ ideCommand(this.config),
58
+ mcpCommand,
59
+ memoryCommand,
60
+ privacyCommand,
61
+ quitCommand,
62
+ restoreCommand(this.config),
63
+ statsCommand,
64
+ themeCommand,
65
+ toolsCommand,
66
+ ];
67
+ return allDefinitions.filter((cmd) => cmd !== null);
68
+ }
69
+ }
70
+ //# sourceMappingURL=BuiltinCommandLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuiltinCommandLoader.js","sourceRoot":"","sources":["../../../src/services/BuiltinCommandLoader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM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IAC3E,CAAC;CACF"}
@@ -3,13 +3,49 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { Config } from '@google/gemini-cli-core';
7
6
  import { SlashCommand } from '../ui/commands/types.js';
7
+ import { ICommandLoader } from './types.js';
8
+ /**
9
+ * Orchestrates the discovery and loading of all slash commands for the CLI.
10
+ *
11
+ * This service operates on a provider-based loader pattern. It is initialized
12
+ * with an array of `ICommandLoader` instances, each responsible for fetching
13
+ * commands from a specific source (e.g., built-in code, local files).
14
+ *
15
+ * The CommandService is responsible for invoking these loaders, aggregating their
16
+ * results, and resolving any name conflicts. This architecture allows the command
17
+ * system to be extended with new sources without modifying the service itself.
18
+ */
8
19
  export declare class CommandService {
9
- private config;
10
- private commandLoader;
11
- private commands;
12
- constructor(config: Config | null, commandLoader?: (config: Config | null) => Promise<SlashCommand[]>);
13
- loadCommands(): Promise<void>;
14
- getCommands(): SlashCommand[];
20
+ private readonly commands;
21
+ /**
22
+ * Private constructor to enforce the use of the async factory.
23
+ * @param commands A readonly array of the fully loaded and de-duplicated commands.
24
+ */
25
+ private constructor();
26
+ /**
27
+ * Asynchronously creates and initializes a new CommandService instance.
28
+ *
29
+ * This factory method orchestrates the entire command loading process. It
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
32
+ * fully constructed `CommandService` instance.
33
+ *
34
+ * @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.
38
+ * @param signal An AbortSignal to cancel the loading process.
39
+ * @returns A promise that resolves to a new, fully initialized `CommandService` instance.
40
+ */
41
+ static create(loaders: ICommandLoader[], signal: AbortSignal): Promise<CommandService>;
42
+ /**
43
+ * Retrieves the currently loaded and de-duplicated list of slash commands.
44
+ *
45
+ * This method is a safe accessor for the service's state. It returns a
46
+ * readonly array, preventing consumers from modifying the service's internal state.
47
+ *
48
+ * @returns A readonly, unified array of available `SlashCommand` objects.
49
+ */
50
+ getCommands(): readonly SlashCommand[];
15
51
  }
@@ -3,65 +3,70 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { memoryCommand } from '../ui/commands/memoryCommand.js';
7
- import { helpCommand } from '../ui/commands/helpCommand.js';
8
- import { clearCommand } from '../ui/commands/clearCommand.js';
9
- import { corgiCommand } from '../ui/commands/corgiCommand.js';
10
- import { docsCommand } from '../ui/commands/docsCommand.js';
11
- import { mcpCommand } from '../ui/commands/mcpCommand.js';
12
- import { authCommand } from '../ui/commands/authCommand.js';
13
- import { themeCommand } from '../ui/commands/themeCommand.js';
14
- import { editorCommand } from '../ui/commands/editorCommand.js';
15
- import { chatCommand } from '../ui/commands/chatCommand.js';
16
- import { statsCommand } from '../ui/commands/statsCommand.js';
17
- import { privacyCommand } from '../ui/commands/privacyCommand.js';
18
- import { aboutCommand } from '../ui/commands/aboutCommand.js';
19
- import { extensionsCommand } from '../ui/commands/extensionsCommand.js';
20
- import { toolsCommand } from '../ui/commands/toolsCommand.js';
21
- import { compressCommand } from '../ui/commands/compressCommand.js';
22
- import { ideCommand } from '../ui/commands/ideCommand.js';
23
- import { bugCommand } from '../ui/commands/bugCommand.js';
24
- import { quitCommand } from '../ui/commands/quitCommand.js';
25
- import { restoreCommand } from '../ui/commands/restoreCommand.js';
26
- const loadBuiltInCommands = async (config) => {
27
- const allCommands = [
28
- aboutCommand,
29
- authCommand,
30
- bugCommand,
31
- chatCommand,
32
- clearCommand,
33
- compressCommand,
34
- corgiCommand,
35
- docsCommand,
36
- editorCommand,
37
- extensionsCommand,
38
- helpCommand,
39
- ideCommand(config),
40
- mcpCommand,
41
- memoryCommand,
42
- privacyCommand,
43
- quitCommand,
44
- restoreCommand(config),
45
- statsCommand,
46
- themeCommand,
47
- toolsCommand,
48
- ];
49
- return allCommands.filter((command) => command !== null);
50
- };
6
+ /**
7
+ * Orchestrates the discovery and loading of all slash commands for the CLI.
8
+ *
9
+ * This service operates on a provider-based loader pattern. It is initialized
10
+ * with an array of `ICommandLoader` instances, each responsible for fetching
11
+ * commands from a specific source (e.g., built-in code, local files).
12
+ *
13
+ * The CommandService is responsible for invoking these loaders, aggregating their
14
+ * results, and resolving any name conflicts. This architecture allows the command
15
+ * system to be extended with new sources without modifying the service itself.
16
+ */
51
17
  export class CommandService {
52
- config;
53
- commandLoader;
54
- commands = [];
55
- constructor(config, commandLoader = loadBuiltInCommands) {
56
- this.config = config;
57
- this.commandLoader = commandLoader;
58
- // The constructor can be used for dependency injection in the future.
18
+ commands;
19
+ /**
20
+ * Private constructor to enforce the use of the async factory.
21
+ * @param commands A readonly array of the fully loaded and de-duplicated commands.
22
+ */
23
+ constructor(commands) {
24
+ this.commands = commands;
59
25
  }
60
- async loadCommands() {
61
- // For now, we only load the built-in commands.
62
- // File-based and remote commands will be added later.
63
- this.commands = await this.commandLoader(this.config);
26
+ /**
27
+ * Asynchronously creates and initializes a new CommandService instance.
28
+ *
29
+ * This factory method orchestrates the entire command loading process. It
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
32
+ * fully constructed `CommandService` instance.
33
+ *
34
+ * @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.
38
+ * @param signal An AbortSignal to cancel the loading process.
39
+ * @returns A promise that resolves to a new, fully initialized `CommandService` instance.
40
+ */
41
+ static async create(loaders, signal) {
42
+ const results = await Promise.allSettled(loaders.map((loader) => loader.loadCommands(signal)));
43
+ const allCommands = [];
44
+ for (const result of results) {
45
+ if (result.status === 'fulfilled') {
46
+ allCommands.push(...result.value);
47
+ }
48
+ else {
49
+ console.debug('A command loader failed:', result.reason);
50
+ }
51
+ }
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
+ const commandMap = new Map();
56
+ for (const cmd of allCommands) {
57
+ commandMap.set(cmd.name, cmd);
58
+ }
59
+ const finalCommands = Object.freeze(Array.from(commandMap.values()));
60
+ return new CommandService(finalCommands);
64
61
  }
62
+ /**
63
+ * Retrieves the currently loaded and de-duplicated list of slash commands.
64
+ *
65
+ * This method is a safe accessor for the service's state. It returns a
66
+ * readonly array, preventing consumers from modifying the service's internal state.
67
+ *
68
+ * @returns A readonly, unified array of available `SlashCommand` objects.
69
+ */
65
70
  getCommands() {
66
71
  return this.commands;
67
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CommandService.js","sourceRoot":"","sources":["../../../src/services/CommandService.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,YA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B,CAAC;CACF"}
@@ -0,0 +1,37 @@
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 { ICommandLoader } from './types.js';
8
+ import { SlashCommand } from '../ui/commands/types.js';
9
+ /**
10
+ * Discovers and loads custom slash commands from .toml files in both the
11
+ * user's global config directory and the current project's directory.
12
+ *
13
+ * This loader is responsible for:
14
+ * - Recursively scanning command directories.
15
+ * - Parsing and validating TOML files.
16
+ * - Adapting valid definitions into executable SlashCommand objects.
17
+ * - Handling file system errors and malformed files gracefully.
18
+ */
19
+ export declare class FileCommandLoader implements ICommandLoader {
20
+ private readonly config;
21
+ private readonly projectRoot;
22
+ constructor(config: Config | null);
23
+ /**
24
+ * Loads all commands, applying the precedence rule where project-level
25
+ * commands override user-level commands with the same name.
26
+ * @param signal An AbortSignal to cancel the loading process.
27
+ * @returns A promise that resolves to an array of loaded SlashCommands.
28
+ */
29
+ loadCommands(signal: AbortSignal): Promise<SlashCommand[]>;
30
+ /**
31
+ * Parses a single .toml file and transforms it into a SlashCommand object.
32
+ * @param filePath The absolute path to the .toml file.
33
+ * @param baseDir The root command directory for name calculation.
34
+ * @returns A promise resolving to a SlashCommand, or null if the file is invalid.
35
+ */
36
+ private parseAndAdaptFile;
37
+ }
@@ -0,0 +1,156 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { promises as fs } from 'fs';
7
+ import path from 'path';
8
+ import toml from '@iarna/toml';
9
+ import { glob } from 'glob';
10
+ import { z } from 'zod';
11
+ import { getProjectCommandsDir, getUserCommandsDir, } from '@google/gemini-cli-core';
12
+ import { CommandKind, } from '../ui/commands/types.js';
13
+ import { DefaultArgumentProcessor, ShorthandArgumentProcessor, } from './prompt-processors/argumentProcessor.js';
14
+ import { SHORTHAND_ARGS_PLACEHOLDER, } from './prompt-processors/types.js';
15
+ /**
16
+ * Defines the Zod schema for a command definition file. This serves as the
17
+ * single source of truth for both validation and type inference.
18
+ */
19
+ const TomlCommandDefSchema = z.object({
20
+ prompt: z.string({
21
+ required_error: "The 'prompt' field is required.",
22
+ invalid_type_error: "The 'prompt' field must be a string.",
23
+ }),
24
+ description: z.string().optional(),
25
+ });
26
+ /**
27
+ * Discovers and loads custom slash commands from .toml files in both the
28
+ * user's global config directory and the current project's directory.
29
+ *
30
+ * This loader is responsible for:
31
+ * - Recursively scanning command directories.
32
+ * - Parsing and validating TOML files.
33
+ * - Adapting valid definitions into executable SlashCommand objects.
34
+ * - Handling file system errors and malformed files gracefully.
35
+ */
36
+ export class FileCommandLoader {
37
+ config;
38
+ projectRoot;
39
+ constructor(config) {
40
+ this.config = config;
41
+ this.projectRoot = config?.getProjectRoot() || process.cwd();
42
+ }
43
+ /**
44
+ * Loads all commands, applying the precedence rule where project-level
45
+ * commands override user-level commands with the same name.
46
+ * @param signal An AbortSignal to cancel the loading process.
47
+ * @returns A promise that resolves to an array of loaded SlashCommands.
48
+ */
49
+ async loadCommands(signal) {
50
+ const commandMap = new Map();
51
+ const globOptions = {
52
+ nodir: true,
53
+ dot: true,
54
+ signal,
55
+ };
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);
67
+ }
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);
78
+ }
79
+ }
80
+ catch (error) {
81
+ console.error(`[FileCommandLoader] Error during file search:`, error);
82
+ }
83
+ return Array.from(commandMap.values());
84
+ }
85
+ /**
86
+ * Parses a single .toml file and transforms it into a SlashCommand object.
87
+ * @param filePath The absolute path to the .toml file.
88
+ * @param baseDir The root command directory for name calculation.
89
+ * @returns A promise resolving to a SlashCommand, or null if the file is invalid.
90
+ */
91
+ async parseAndAdaptFile(filePath, baseDir) {
92
+ let fileContent;
93
+ try {
94
+ fileContent = await fs.readFile(filePath, 'utf-8');
95
+ }
96
+ catch (error) {
97
+ console.error(`[FileCommandLoader] Failed to read file ${filePath}:`, error instanceof Error ? error.message : String(error));
98
+ return null;
99
+ }
100
+ let parsed;
101
+ try {
102
+ parsed = toml.parse(fileContent);
103
+ }
104
+ catch (error) {
105
+ console.error(`[FileCommandLoader] Failed to parse TOML file ${filePath}:`, error instanceof Error ? error.message : String(error));
106
+ return null;
107
+ }
108
+ const validationResult = TomlCommandDefSchema.safeParse(parsed);
109
+ if (!validationResult.success) {
110
+ console.error(`[FileCommandLoader] Skipping invalid command file: ${filePath}. Validation errors:`, validationResult.error.flatten());
111
+ return null;
112
+ }
113
+ const validDef = validationResult.data;
114
+ const relativePathWithExt = path.relative(baseDir, filePath);
115
+ const relativePath = relativePathWithExt.substring(0, relativePathWithExt.length - 5);
116
+ const commandName = relativePath
117
+ .split(path.sep)
118
+ // Sanitize each path segment to prevent ambiguity. Since ':' is our
119
+ // namespace separator, we replace any literal colons in filenames
120
+ // with underscores to avoid naming conflicts.
121
+ .map((segment) => segment.replaceAll(':', '_'))
122
+ .join(':');
123
+ const processors = [];
124
+ // The presence of '{{args}}' is the switch that determines the behavior.
125
+ if (validDef.prompt.includes(SHORTHAND_ARGS_PLACEHOLDER)) {
126
+ processors.push(new ShorthandArgumentProcessor());
127
+ }
128
+ else {
129
+ processors.push(new DefaultArgumentProcessor());
130
+ }
131
+ return {
132
+ name: commandName,
133
+ description: validDef.description ||
134
+ `Custom command from ${path.basename(filePath)}`,
135
+ kind: CommandKind.FILE,
136
+ action: async (context, _args) => {
137
+ if (!context.invocation) {
138
+ console.error(`[FileCommandLoader] Critical error: Command '${commandName}' was executed without invocation context.`);
139
+ return {
140
+ type: 'submit_prompt',
141
+ content: validDef.prompt, // Fallback to unprocessed prompt
142
+ };
143
+ }
144
+ let processedPrompt = validDef.prompt;
145
+ for (const processor of processors) {
146
+ processedPrompt = await processor.process(processedPrompt, context);
147
+ }
148
+ return {
149
+ type: 'submit_prompt',
150
+ content: processedPrompt,
151
+ };
152
+ },
153
+ };
154
+ }
155
+ }
156
+ //# sourceMappingURL=FileCommandLoader.js.map
@@ -0,0 +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,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,cAAc,EAAE,iCAAiC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AC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,CAAC;YACzD,UAAU,CAAC,IAAI,CAAC,IAAI,0BAA0B,EAAE,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,WAAW,EACT,QAAQ,CAAC,WAAW;gBACpB,uBAAuB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAClD,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,MAAM,EAAE,KAAK,EACX,OAAuB,EACvB,KAAa,EACsB,EAAE;gBACrC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;oBACxB,OAAO,CAAC,KAAK,CACX,gDAAgD,WAAW,4CAA4C,CACxG,CAAC;oBACF,OAAO;wBACL,IAAI,EAAE,eAAe;wBACrB,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,iCAAiC;qBAC5D,CAAC;gBACJ,CAAC;gBAED,IAAI,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC;gBACtC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;oBACnC,eAAe,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;gBACtE,CAAC;gBAED,OAAO;oBACL,IAAI,EAAE,eAAe;oBACrB,OAAO,EAAE,eAAe;iBACzB,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { IPromptProcessor } from './types.js';
7
+ import { CommandContext } from '../../ui/commands/types.js';
8
+ /**
9
+ * Replaces all instances of `{{args}}` in a prompt with the user-provided
10
+ * argument string.
11
+ */
12
+ export declare class ShorthandArgumentProcessor implements IPromptProcessor {
13
+ process(prompt: string, context: CommandContext): Promise<string>;
14
+ }
15
+ /**
16
+ * Appends the user's full command invocation to the prompt if arguments are
17
+ * provided, allowing the model to perform its own argument parsing.
18
+ */
19
+ export declare class DefaultArgumentProcessor implements IPromptProcessor {
20
+ process(prompt: string, context: CommandContext): Promise<string>;
21
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { SHORTHAND_ARGS_PLACEHOLDER } from './types.js';
7
+ /**
8
+ * Replaces all instances of `{{args}}` in a prompt with the user-provided
9
+ * argument string.
10
+ */
11
+ export class ShorthandArgumentProcessor {
12
+ async process(prompt, context) {
13
+ return prompt.replaceAll(SHORTHAND_ARGS_PLACEHOLDER, context.invocation.args);
14
+ }
15
+ }
16
+ /**
17
+ * Appends the user's full command invocation to the prompt if arguments are
18
+ * provided, allowing the model to perform its own argument parsing.
19
+ */
20
+ export class DefaultArgumentProcessor {
21
+ async process(prompt, context) {
22
+ if (context.invocation.args) {
23
+ return `${prompt}\n\n${context.invocation.raw}`;
24
+ }
25
+ return prompt;
26
+ }
27
+ }
28
+ //# sourceMappingURL=argumentProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argumentProcessor.js","sourceRoot":"","sources":["../../../../src/services/prompt-processors/argumentProcessor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAoB,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAG1E;;;GAGG;AACH,MAAM,OAAO,0BAA0B;IACrC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAuB;QACnD,OAAO,MAAM,CAAC,UAAU,CACtB,0BAA0B,EAC1B,OAAO,CAAC,UAAW,CAAC,IAAI,CACzB,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IACnC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAuB;QACnD,IAAI,OAAO,CAAC,UAAW,CAAC,IAAI,EAAE,CAAC;YAC7B,OAAO,GAAG,MAAM,OAAO,OAAO,CAAC,UAAW,CAAC,GAAG,EAAE,CAAC;QACnD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { CommandContext } from '../../ui/commands/types.js';
7
+ /**
8
+ * Defines the interface for a prompt processor, a module that can transform
9
+ * a prompt string before it is sent to the model. Processors are chained
10
+ * together to create a processing pipeline.
11
+ */
12
+ export interface IPromptProcessor {
13
+ /**
14
+ * Processes a prompt string, applying a specific transformation as part of a pipeline.
15
+ *
16
+ * Each processor in a command's pipeline receives the output of the previous
17
+ * processor. This method provides the full command context, allowing for
18
+ * complex transformations that may require access to invocation details,
19
+ * application services, or UI state.
20
+ *
21
+ * @param prompt The current state of the prompt string. This may have been
22
+ * modified by previous processors in the pipeline.
23
+ * @param context The full command context, providing access to invocation
24
+ * details (like `context.invocation.raw` and `context.invocation.args`),
25
+ * application services, and UI handlers.
26
+ * @returns A promise that resolves to the transformed prompt string, which
27
+ * will be passed to the next processor or, if it's the last one, sent to the model.
28
+ */
29
+ process(prompt: string, context: CommandContext): Promise<string>;
30
+ }
31
+ /**
32
+ * The placeholder string for shorthand argument injection in custom commands.
33
+ */
34
+ export declare const SHORTHAND_ARGS_PLACEHOLDER = "{{args}}";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * The placeholder string for shorthand argument injection in custom commands.
8
+ */
9
+ export const SHORTHAND_ARGS_PLACEHOLDER = '{{args}}';
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/services/prompt-processors/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA6BH;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { SlashCommand } from '../ui/commands/types.js';
7
+ /**
8
+ * Defines the contract for any class that can load and provide slash commands.
9
+ * This allows the CommandService to be extended with new command sources
10
+ * (e.g., file-based, remote APIs) without modification.
11
+ *
12
+ * Loaders should receive any necessary dependencies (like Config) via their
13
+ * constructor.
14
+ */
15
+ export interface ICommandLoader {
16
+ /**
17
+ * Discovers and returns a list of slash commands from the loader's source.
18
+ * @param signal An AbortSignal to allow cancellation.
19
+ * @returns A promise that resolves to an array of SlashCommand objects.
20
+ */
21
+ loadCommands(signal: AbortSignal): Promise<SlashCommand[]>;
22
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}