@google/gemini-cli-core 0.21.0-nightly.20251219.70696e364 → 0.21.0-nightly.20251221.8feeffb29

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 (183) hide show
  1. package/dist/docs/CONTRIBUTING.md +546 -0
  2. package/dist/docs/architecture.md +80 -0
  3. package/dist/docs/assets/connected_devtools.png +0 -0
  4. package/dist/docs/assets/gemini-screenshot.png +0 -0
  5. package/dist/docs/assets/release_patch.png +0 -0
  6. package/dist/docs/assets/theme-ansi-light.png +0 -0
  7. package/dist/docs/assets/theme-ansi.png +0 -0
  8. package/dist/docs/assets/theme-atom-one.png +0 -0
  9. package/dist/docs/assets/theme-ayu-light.png +0 -0
  10. package/dist/docs/assets/theme-ayu.png +0 -0
  11. package/dist/docs/assets/theme-custom.png +0 -0
  12. package/dist/docs/assets/theme-default-light.png +0 -0
  13. package/dist/docs/assets/theme-default.png +0 -0
  14. package/dist/docs/assets/theme-dracula.png +0 -0
  15. package/dist/docs/assets/theme-github-light.png +0 -0
  16. package/dist/docs/assets/theme-github.png +0 -0
  17. package/dist/docs/assets/theme-google-light.png +0 -0
  18. package/dist/docs/assets/theme-xcode-light.png +0 -0
  19. package/dist/docs/changelogs/index.md +592 -0
  20. package/dist/docs/changelogs/latest.md +225 -0
  21. package/dist/docs/changelogs/preview.md +129 -0
  22. package/dist/docs/changelogs/releases.md +896 -0
  23. package/dist/docs/cli/authentication.md +3 -0
  24. package/dist/docs/cli/checkpointing.md +94 -0
  25. package/dist/docs/cli/commands.md +354 -0
  26. package/dist/docs/cli/configuration.md +780 -0
  27. package/dist/docs/cli/custom-commands.md +315 -0
  28. package/dist/docs/cli/enterprise.md +565 -0
  29. package/dist/docs/cli/gemini-ignore.md +71 -0
  30. package/dist/docs/cli/gemini-md.md +108 -0
  31. package/dist/docs/cli/generation-settings.md +210 -0
  32. package/dist/docs/cli/headless.md +388 -0
  33. package/dist/docs/cli/index.md +63 -0
  34. package/dist/docs/cli/keyboard-shortcuts.md +143 -0
  35. package/dist/docs/cli/model-routing.md +37 -0
  36. package/dist/docs/cli/model.md +62 -0
  37. package/dist/docs/cli/sandbox.md +171 -0
  38. package/dist/docs/cli/session-management.md +158 -0
  39. package/dist/docs/cli/settings.md +112 -0
  40. package/dist/docs/cli/system-prompt.md +93 -0
  41. package/dist/docs/cli/telemetry.md +791 -0
  42. package/dist/docs/cli/themes.md +237 -0
  43. package/dist/docs/cli/token-caching.md +20 -0
  44. package/dist/docs/cli/trusted-folders.md +95 -0
  45. package/dist/docs/cli/tutorials.md +83 -0
  46. package/dist/docs/cli/uninstall.md +47 -0
  47. package/dist/docs/core/index.md +101 -0
  48. package/dist/docs/core/memport.md +244 -0
  49. package/dist/docs/core/policy-engine.md +267 -0
  50. package/dist/docs/core/tools-api.md +131 -0
  51. package/dist/docs/examples/proxy-script.md +83 -0
  52. package/dist/docs/extensions/extension-releasing.md +183 -0
  53. package/dist/docs/extensions/getting-started-extensions.md +245 -0
  54. package/dist/docs/extensions/index.md +293 -0
  55. package/dist/docs/faq.md +154 -0
  56. package/dist/docs/get-started/authentication.md +321 -0
  57. package/dist/docs/get-started/configuration-v1.md +888 -0
  58. package/dist/docs/get-started/configuration.md +1444 -0
  59. package/dist/docs/get-started/deployment.md +143 -0
  60. package/dist/docs/get-started/examples.md +219 -0
  61. package/dist/docs/get-started/gemini-3.md +116 -0
  62. package/dist/docs/get-started/index.md +71 -0
  63. package/dist/docs/get-started/installation.md +141 -0
  64. package/dist/docs/hooks/best-practices.md +806 -0
  65. package/dist/docs/hooks/index.md +665 -0
  66. package/dist/docs/hooks/reference.md +168 -0
  67. package/dist/docs/hooks/writing-hooks.md +1026 -0
  68. package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
  69. package/dist/docs/ide-integration/index.md +202 -0
  70. package/dist/docs/index.md +147 -0
  71. package/dist/docs/integration-tests.md +211 -0
  72. package/dist/docs/issue-and-pr-automation.md +134 -0
  73. package/dist/docs/local-development.md +128 -0
  74. package/dist/docs/mermaid/context.mmd +103 -0
  75. package/dist/docs/mermaid/render-path.mmd +64 -0
  76. package/dist/docs/npm.md +62 -0
  77. package/dist/docs/quota-and-pricing.md +158 -0
  78. package/dist/docs/release-confidence.md +164 -0
  79. package/dist/docs/releases.md +540 -0
  80. package/dist/docs/sidebar.json +297 -0
  81. package/dist/docs/tools/file-system.md +217 -0
  82. package/dist/docs/tools/index.md +95 -0
  83. package/dist/docs/tools/mcp-server.md +1044 -0
  84. package/dist/docs/tools/memory.md +54 -0
  85. package/dist/docs/tools/shell.md +260 -0
  86. package/dist/docs/tools/todos.md +57 -0
  87. package/dist/docs/tools/web-fetch.md +59 -0
  88. package/dist/docs/tools/web-search.md +42 -0
  89. package/dist/docs/tos-privacy.md +96 -0
  90. package/dist/docs/troubleshooting.md +158 -0
  91. package/dist/google-gemini-cli-core-0.21.0-nightly.20251219.70696e364.tgz +0 -0
  92. package/dist/src/agents/delegate-to-agent-tool.test.js +1 -0
  93. package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -1
  94. package/dist/src/agents/introspection-agent.d.ts +23 -0
  95. package/dist/src/agents/introspection-agent.js +72 -0
  96. package/dist/src/agents/introspection-agent.js.map +1 -0
  97. package/dist/src/agents/introspection-agent.test.d.ts +6 -0
  98. package/dist/src/agents/introspection-agent.test.js +47 -0
  99. package/dist/src/agents/introspection-agent.test.js.map +1 -0
  100. package/dist/src/agents/local-executor.js +14 -12
  101. package/dist/src/agents/local-executor.js.map +1 -1
  102. package/dist/src/agents/local-executor.test.js +3 -0
  103. package/dist/src/agents/local-executor.test.js.map +1 -1
  104. package/dist/src/agents/registry.js +6 -0
  105. package/dist/src/agents/registry.js.map +1 -1
  106. package/dist/src/agents/registry.test.js +16 -0
  107. package/dist/src/agents/registry.test.js.map +1 -1
  108. package/dist/src/config/config.d.ts +6 -0
  109. package/dist/src/config/config.js +22 -0
  110. package/dist/src/config/config.js.map +1 -1
  111. package/dist/src/config/config.test.js +59 -1
  112. package/dist/src/config/config.test.js.map +1 -1
  113. package/dist/src/core/client.js +8 -4
  114. package/dist/src/core/client.js.map +1 -1
  115. package/dist/src/core/client.test.js +20 -0
  116. package/dist/src/core/client.test.js.map +1 -1
  117. package/dist/src/core/clientHookTriggers.js +2 -2
  118. package/dist/src/core/clientHookTriggers.js.map +1 -1
  119. package/dist/src/core/coreToolHookTriggers.js +3 -3
  120. package/dist/src/core/coreToolHookTriggers.js.map +1 -1
  121. package/dist/src/core/geminiChatHookTriggers.js +3 -3
  122. package/dist/src/core/geminiChatHookTriggers.js.map +1 -1
  123. package/dist/src/core/sessionHookTriggers.js +3 -3
  124. package/dist/src/core/sessionHookTriggers.js.map +1 -1
  125. package/dist/src/generated/git-commit.d.ts +2 -2
  126. package/dist/src/generated/git-commit.js +2 -2
  127. package/dist/src/hooks/hookEventHandler.js +10 -4
  128. package/dist/src/hooks/hookEventHandler.js.map +1 -1
  129. package/dist/src/hooks/hookEventHandler.test.js +40 -0
  130. package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
  131. package/dist/src/hooks/hookRunner.js +12 -8
  132. package/dist/src/hooks/hookRunner.js.map +1 -1
  133. package/dist/src/hooks/hookRunner.test.js +58 -33
  134. package/dist/src/hooks/hookRunner.test.js.map +1 -1
  135. package/dist/src/mcp/oauth-provider.js +6 -2
  136. package/dist/src/mcp/oauth-provider.js.map +1 -1
  137. package/dist/src/mcp/oauth-provider.test.js +4 -1
  138. package/dist/src/mcp/oauth-provider.test.js.map +1 -1
  139. package/dist/src/mcp/oauth-utils.d.ts +8 -1
  140. package/dist/src/mcp/oauth-utils.js +30 -1
  141. package/dist/src/mcp/oauth-utils.js.map +1 -1
  142. package/dist/src/mcp/oauth-utils.test.js +42 -0
  143. package/dist/src/mcp/oauth-utils.test.js.map +1 -1
  144. package/dist/src/services/contextManager.d.ts +5 -11
  145. package/dist/src/services/contextManager.js +20 -17
  146. package/dist/src/services/contextManager.js.map +1 -1
  147. package/dist/src/services/contextManager.test.js +40 -41
  148. package/dist/src/services/contextManager.test.js.map +1 -1
  149. package/dist/src/tools/confirmation-policy.test.d.ts +6 -0
  150. package/dist/src/tools/confirmation-policy.test.js +152 -0
  151. package/dist/src/tools/confirmation-policy.test.js.map +1 -0
  152. package/dist/src/tools/edit.js +5 -1
  153. package/dist/src/tools/edit.js.map +1 -1
  154. package/dist/src/tools/get-internal-docs.d.ts +27 -0
  155. package/dist/src/tools/get-internal-docs.js +129 -0
  156. package/dist/src/tools/get-internal-docs.js.map +1 -0
  157. package/dist/src/tools/get-internal-docs.test.d.ts +6 -0
  158. package/dist/src/tools/get-internal-docs.test.js +56 -0
  159. package/dist/src/tools/get-internal-docs.test.js.map +1 -0
  160. package/dist/src/tools/smart-edit.js +5 -1
  161. package/dist/src/tools/smart-edit.js.map +1 -1
  162. package/dist/src/tools/tool-names.d.ts +1 -0
  163. package/dist/src/tools/tool-names.js +1 -0
  164. package/dist/src/tools/tool-names.js.map +1 -1
  165. package/dist/src/tools/web-fetch.js +5 -1
  166. package/dist/src/tools/web-fetch.js.map +1 -1
  167. package/dist/src/tools/write-file.js +5 -1
  168. package/dist/src/tools/write-file.js.map +1 -1
  169. package/dist/src/utils/environmentContext.js +3 -0
  170. package/dist/src/utils/environmentContext.js.map +1 -1
  171. package/dist/src/utils/environmentContext.test.js +2 -0
  172. package/dist/src/utils/environmentContext.test.js.map +1 -1
  173. package/dist/src/utils/events.d.ts +3 -2
  174. package/dist/src/utils/events.js.map +1 -1
  175. package/dist/src/utils/memoryDiscovery.js +1 -1
  176. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  177. package/dist/src/utils/memoryDiscovery.test.js +3 -1
  178. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  179. package/dist/src/utils/shell-utils.js +25 -4
  180. package/dist/src/utils/shell-utils.js.map +1 -1
  181. package/dist/tsconfig.tsbuildinfo +1 -1
  182. package/package.json +1 -1
  183. package/dist/google-gemini-cli-core-0.21.0-nightly.20251218.739c02bd6.tgz +0 -0
@@ -0,0 +1,267 @@
1
+ # Gemini CLI companion plugin: Interface specification
2
+
3
+ > Last Updated: September 15, 2025
4
+
5
+ This document defines the contract for building a companion plugin to enable
6
+ Gemini CLI's IDE mode. For VS Code, these features (native diffing, context
7
+ awareness) are provided by the official extension
8
+ ([marketplace](https://marketplace.visualstudio.com/items?itemName=Google.gemini-cli-vscode-ide-companion)).
9
+ This specification is for contributors who wish to bring similar functionality
10
+ to other editors like JetBrains IDEs, Sublime Text, etc.
11
+
12
+ ## I. The communication interface
13
+
14
+ Gemini CLI and the IDE plugin communicate through a local communication channel.
15
+
16
+ ### 1. Transport layer: MCP over HTTP
17
+
18
+ The plugin **MUST** run a local HTTP server that implements the **Model Context
19
+ Protocol (MCP)**.
20
+
21
+ - **Protocol:** The server must be a valid MCP server. We recommend using an
22
+ existing MCP SDK for your language of choice if available.
23
+ - **Endpoint:** The server should expose a single endpoint (e.g., `/mcp`) for
24
+ all MCP communication.
25
+ - **Port:** The server **MUST** listen on a dynamically assigned port (i.e.,
26
+ listen on port `0`).
27
+
28
+ ### 2. Discovery mechanism: The port file
29
+
30
+ For Gemini CLI to connect, it needs to discover which IDE instance it's running
31
+ in and what port your server is using. The plugin **MUST** facilitate this by
32
+ creating a "discovery file."
33
+
34
+ - **How the CLI finds the file:** The CLI determines the Process ID (PID) of the
35
+ IDE it's running in by traversing the process tree. It then looks for a
36
+ discovery file that contains this PID in its name.
37
+ - **File location:** The file must be created in a specific directory:
38
+ `os.tmpdir()/gemini/ide/`. Your plugin must create this directory if it
39
+ doesn't exist.
40
+ - **File naming convention:** The filename is critical and **MUST** follow the
41
+ pattern: `gemini-ide-server-${PID}-${PORT}.json`
42
+ - `${PID}`: The process ID of the parent IDE process. Your plugin must
43
+ determine this PID and include it in the filename.
44
+ - `${PORT}`: The port your MCP server is listening on.
45
+ - **File content and workspace validation:** The file **MUST** contain a JSON
46
+ object with the following structure:
47
+
48
+ ```json
49
+ {
50
+ "port": 12345,
51
+ "workspacePath": "/path/to/project1:/path/to/project2",
52
+ "authToken": "a-very-secret-token",
53
+ "ideInfo": {
54
+ "name": "vscode",
55
+ "displayName": "VS Code"
56
+ }
57
+ }
58
+ ```
59
+ - `port` (number, required): The port of the MCP server.
60
+ - `workspacePath` (string, required): A list of all open workspace root paths,
61
+ delimited by the OS-specific path separator (`:` for Linux/macOS, `;` for
62
+ Windows). The CLI uses this path to ensure it's running in the same project
63
+ folder that's open in the IDE. If the CLI's current working directory is not
64
+ a sub-directory of `workspacePath`, the connection will be rejected. Your
65
+ plugin **MUST** provide the correct, absolute path(s) to the root of the
66
+ open workspace(s).
67
+ - `authToken` (string, required): A secret token for securing the connection.
68
+ The CLI will include this token in an `Authorization: Bearer <token>` header
69
+ on all requests.
70
+ - `ideInfo` (object, required): Information about the IDE.
71
+ - `name` (string, required): A short, lowercase identifier for the IDE
72
+ (e.g., `vscode`, `jetbrains`).
73
+ - `displayName` (string, required): A user-friendly name for the IDE (e.g.,
74
+ `VS Code`, `JetBrains IDE`).
75
+
76
+ - **Authentication:** To secure the connection, the plugin **MUST** generate a
77
+ unique, secret token and include it in the discovery file. The CLI will then
78
+ include this token in the `Authorization` header for all requests to the MCP
79
+ server (e.g., `Authorization: Bearer a-very-secret-token`). Your server
80
+ **MUST** validate this token on every request and reject any that are
81
+ unauthorized.
82
+ - **Tie-breaking with environment variables (recommended):** For the most
83
+ reliable experience, your plugin **SHOULD** both create the discovery file and
84
+ set the `GEMINI_CLI_IDE_SERVER_PORT` environment variable in the integrated
85
+ terminal. The file serves as the primary discovery mechanism, but the
86
+ environment variable is crucial for tie-breaking. If a user has multiple IDE
87
+ windows open for the same workspace, the CLI uses the
88
+ `GEMINI_CLI_IDE_SERVER_PORT` variable to identify and connect to the correct
89
+ window's server.
90
+
91
+ ## II. The context interface
92
+
93
+ To enable context awareness, the plugin **MAY** provide the CLI with real-time
94
+ information about the user's activity in the IDE.
95
+
96
+ ### `ide/contextUpdate` notification
97
+
98
+ The plugin **MAY** send an `ide/contextUpdate`
99
+ [notification](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#notifications)
100
+ to the CLI whenever the user's context changes.
101
+
102
+ - **Triggering events:** This notification should be sent (with a recommended
103
+ debounce of 50ms) when:
104
+ - A file is opened, closed, or focused.
105
+ - The user's cursor position or text selection changes in the active file.
106
+ - **Payload (`IdeContext`):** The notification parameters **MUST** be an
107
+ `IdeContext` object:
108
+
109
+ ```typescript
110
+ interface IdeContext {
111
+ workspaceState?: {
112
+ openFiles?: File[];
113
+ isTrusted?: boolean;
114
+ };
115
+ }
116
+
117
+ interface File {
118
+ // Absolute path to the file
119
+ path: string;
120
+ // Last focused Unix timestamp (for ordering)
121
+ timestamp: number;
122
+ // True if this is the currently focused file
123
+ isActive?: boolean;
124
+ cursor?: {
125
+ // 1-based line number
126
+ line: number;
127
+ // 1-based character number
128
+ character: number;
129
+ };
130
+ // The text currently selected by the user
131
+ selectedText?: string;
132
+ }
133
+ ```
134
+
135
+ **Note:** The `openFiles` list should only include files that exist on disk.
136
+ Virtual files (e.g., unsaved files without a path, editor settings pages)
137
+ **MUST** be excluded.
138
+
139
+ ### How the CLI uses this context
140
+
141
+ After receiving the `IdeContext` object, the CLI performs several normalization
142
+ and truncation steps before sending the information to the model.
143
+
144
+ - **File ordering:** The CLI uses the `timestamp` field to determine the most
145
+ recently used files. It sorts the `openFiles` list based on this value.
146
+ Therefore, your plugin **MUST** provide an accurate Unix timestamp for when a
147
+ file was last focused.
148
+ - **Active file:** The CLI considers only the most recent file (after sorting)
149
+ to be the "active" file. It will ignore the `isActive` flag on all other files
150
+ and clear their `cursor` and `selectedText` fields. Your plugin should focus
151
+ on setting `isActive: true` and providing cursor/selection details only for
152
+ the currently focused file.
153
+ - **Truncation:** To manage token limits, the CLI truncates both the file list
154
+ (to 10 files) and the `selectedText` (to 16KB).
155
+
156
+ While the CLI handles the final truncation, it is highly recommended that your
157
+ plugin also limits the amount of context it sends.
158
+
159
+ ## III. The diffing interface
160
+
161
+ To enable interactive code modifications, the plugin **MAY** expose a diffing
162
+ interface. This allows the CLI to request that the IDE open a diff view, showing
163
+ proposed changes to a file. The user can then review, edit, and ultimately
164
+ accept or reject these changes directly within the IDE.
165
+
166
+ ### `openDiff` tool
167
+
168
+ The plugin **MUST** register an `openDiff` tool on its MCP server.
169
+
170
+ - **Description:** This tool instructs the IDE to open a modifiable diff view
171
+ for a specific file.
172
+ - **Request (`OpenDiffRequest`):** The tool is invoked via a `tools/call`
173
+ request. The `arguments` field within the request's `params` **MUST** be an
174
+ `OpenDiffRequest` object.
175
+
176
+ ```typescript
177
+ interface OpenDiffRequest {
178
+ // The absolute path to the file to be diffed.
179
+ filePath: string;
180
+ // The proposed new content for the file.
181
+ newContent: string;
182
+ }
183
+ ```
184
+
185
+ - **Response (`CallToolResult`):** The tool **MUST** immediately return a
186
+ `CallToolResult` to acknowledge the request and report whether the diff view
187
+ was successfully opened.
188
+ - On Success: If the diff view was opened successfully, the response **MUST**
189
+ contain empty content (i.e., `content: []`).
190
+ - On Failure: If an error prevented the diff view from opening, the response
191
+ **MUST** have `isError: true` and include a `TextContent` block in the
192
+ `content` array describing the error.
193
+
194
+ The actual outcome of the diff (acceptance or rejection) is communicated
195
+ asynchronously via notifications.
196
+
197
+ ### `closeDiff` tool
198
+
199
+ The plugin **MUST** register a `closeDiff` tool on its MCP server.
200
+
201
+ - **Description:** This tool instructs the IDE to close an open diff view for a
202
+ specific file.
203
+ - **Request (`CloseDiffRequest`):** The tool is invoked via a `tools/call`
204
+ request. The `arguments` field within the request's `params` **MUST** be an
205
+ `CloseDiffRequest` object.
206
+
207
+ ```typescript
208
+ interface CloseDiffRequest {
209
+ // The absolute path to the file whose diff view should be closed.
210
+ filePath: string;
211
+ }
212
+ ```
213
+
214
+ - **Response (`CallToolResult`):** The tool **MUST** return a `CallToolResult`.
215
+ - On Success: If the diff view was closed successfully, the response **MUST**
216
+ include a single **TextContent** block in the content array containing the
217
+ file's final content before closing.
218
+ - On Failure: If an error prevented the diff view from closing, the response
219
+ **MUST** have `isError: true` and include a `TextContent` block in the
220
+ `content` array describing the error.
221
+
222
+ ### `ide/diffAccepted` notification
223
+
224
+ When the user accepts the changes in a diff view (e.g., by clicking an "Apply"
225
+ or "Save" button), the plugin **MUST** send an `ide/diffAccepted` notification
226
+ to the CLI.
227
+
228
+ - **Payload:** The notification parameters **MUST** include the file path and
229
+ the final content of the file. The content may differ from the original
230
+ `newContent` if the user made manual edits in the diff view.
231
+
232
+ ```typescript
233
+ {
234
+ // The absolute path to the file that was diffed.
235
+ filePath: string;
236
+ // The full content of the file after acceptance.
237
+ content: string;
238
+ }
239
+ ```
240
+
241
+ ### `ide/diffRejected` notification
242
+
243
+ When the user rejects the changes (e.g., by closing the diff view without
244
+ accepting), the plugin **MUST** send an `ide/diffRejected` notification to the
245
+ CLI.
246
+
247
+ - **Payload:** The notification parameters **MUST** include the file path of the
248
+ rejected diff.
249
+
250
+ ```typescript
251
+ {
252
+ // The absolute path to the file that was diffed.
253
+ filePath: string;
254
+ }
255
+ ```
256
+
257
+ ## IV. The lifecycle interface
258
+
259
+ The plugin **MUST** manage its resources and the discovery file correctly based
260
+ on the IDE's lifecycle.
261
+
262
+ - **On activation (IDE startup/plugin enabled):**
263
+ 1. Start the MCP server.
264
+ 2. Create the discovery file.
265
+ - **On deactivation (IDE shutdown/plugin disabled):**
266
+ 1. Stop the MCP server.
267
+ 2. Delete the discovery file.
@@ -0,0 +1,202 @@
1
+ # IDE integration
2
+
3
+ Gemini CLI can integrate with your IDE to provide a more seamless and
4
+ context-aware experience. This integration allows the CLI to understand your
5
+ workspace better and enables powerful features like native in-editor diffing.
6
+
7
+ Currently, the supported IDEs are [Antigravity](https://antigravity.google),
8
+ [Visual Studio Code](https://code.visualstudio.com/), and other editors that
9
+ support VS Code extensions. To build support for other editors, see the
10
+ [IDE Companion Extension Spec](./ide-companion-spec.md).
11
+
12
+ ## Features
13
+
14
+ - **Workspace context:** The CLI automatically gains awareness of your workspace
15
+ to provide more relevant and accurate responses. This context includes:
16
+ - The **10 most recently accessed files** in your workspace.
17
+ - Your active cursor position.
18
+ - Any text you have selected (up to a 16KB limit; longer selections will be
19
+ truncated).
20
+
21
+ - **Native diffing:** When Gemini suggests code modifications, you can view the
22
+ changes directly within your IDE's native diff viewer. This allows you to
23
+ review, edit, and accept or reject the suggested changes seamlessly.
24
+
25
+ - **VS Code commands:** You can access Gemini CLI features directly from the VS
26
+ Code Command Palette (`Cmd+Shift+P` or `Ctrl+Shift+P`):
27
+ - `Gemini CLI: Run`: Starts a new Gemini CLI session in the integrated
28
+ terminal.
29
+ - `Gemini CLI: Accept Diff`: Accepts the changes in the active diff editor.
30
+ - `Gemini CLI: Close Diff Editor`: Rejects the changes and closes the active
31
+ diff editor.
32
+ - `Gemini CLI: View Third-Party Notices`: Displays the third-party notices for
33
+ the extension.
34
+
35
+ ## Installation and setup
36
+
37
+ There are three ways to set up the IDE integration:
38
+
39
+ ### 1. Automatic nudge (recommended)
40
+
41
+ When you run Gemini CLI inside a supported editor, it will automatically detect
42
+ your environment and prompt you to connect. Answering "Yes" will automatically
43
+ run the necessary setup, which includes installing the companion extension and
44
+ enabling the connection.
45
+
46
+ ### 2. Manual installation from CLI
47
+
48
+ If you previously dismissed the prompt or want to install the extension
49
+ manually, you can run the following command inside Gemini CLI:
50
+
51
+ ```
52
+ /ide install
53
+ ```
54
+
55
+ This will find the correct extension for your IDE and install it.
56
+
57
+ ### 3. Manual installation from a marketplace
58
+
59
+ You can also install the extension directly from a marketplace.
60
+
61
+ - **For Visual Studio Code:** Install from the
62
+ [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=google.gemini-cli-vscode-ide-companion).
63
+ - **For VS Code forks:** To support forks of VS Code, the extension is also
64
+ published on the
65
+ [Open VSX Registry](https://open-vsx.org/extension/google/gemini-cli-vscode-ide-companion).
66
+ Follow your editor's instructions for installing extensions from this
67
+ registry.
68
+
69
+ > NOTE: The "Gemini CLI Companion" extension may appear towards the bottom of
70
+ > search results. If you don't see it immediately, try scrolling down or sorting
71
+ > by "Newly Published".
72
+ >
73
+ > After manually installing the extension, you must run `/ide enable` in the CLI
74
+ > to activate the integration.
75
+
76
+ ## Usage
77
+
78
+ ### Enabling and disabling
79
+
80
+ You can control the IDE integration from within the CLI:
81
+
82
+ - To enable the connection to the IDE, run:
83
+ ```
84
+ /ide enable
85
+ ```
86
+ - To disable the connection, run:
87
+ ```
88
+ /ide disable
89
+ ```
90
+
91
+ When enabled, Gemini CLI will automatically attempt to connect to the IDE
92
+ companion extension.
93
+
94
+ ### Checking the status
95
+
96
+ To check the connection status and see the context the CLI has received from the
97
+ IDE, run:
98
+
99
+ ```
100
+ /ide status
101
+ ```
102
+
103
+ If connected, this command will show the IDE it's connected to and a list of
104
+ recently opened files it is aware of.
105
+
106
+ > [!NOTE] The file list is limited to 10 recently accessed files within your
107
+ > workspace and only includes local files on disk.)
108
+
109
+ ### Working with diffs
110
+
111
+ When you ask Gemini to modify a file, it can open a diff view directly in your
112
+ editor.
113
+
114
+ **To accept a diff**, you can perform any of the following actions:
115
+
116
+ - Click the **checkmark icon** in the diff editor's title bar.
117
+ - Save the file (e.g., with `Cmd+S` or `Ctrl+S`).
118
+ - Open the Command Palette and run **Gemini CLI: Accept Diff**.
119
+ - Respond with `yes` in the CLI when prompted.
120
+
121
+ **To reject a diff**, you can:
122
+
123
+ - Click the **'x' icon** in the diff editor's title bar.
124
+ - Close the diff editor tab.
125
+ - Open the Command Palette and run **Gemini CLI: Close Diff Editor**.
126
+ - Respond with `no` in the CLI when prompted.
127
+
128
+ You can also **modify the suggested changes** directly in the diff view before
129
+ accepting them.
130
+
131
+ If you select ‘Allow for this session’ in the CLI, changes will no longer show
132
+ up in the IDE as they will be auto-accepted.
133
+
134
+ ## Using with sandboxing
135
+
136
+ If you are using Gemini CLI within a sandbox, please be aware of the following:
137
+
138
+ - **On macOS:** The IDE integration requires network access to communicate with
139
+ the IDE companion extension. You must use a Seatbelt profile that allows
140
+ network access.
141
+ - **In a Docker container:** If you run Gemini CLI inside a Docker (or Podman)
142
+ container, the IDE integration can still connect to the VS Code extension
143
+ running on your host machine. The CLI is configured to automatically find the
144
+ IDE server on `host.docker.internal`. No special configuration is usually
145
+ required, but you may need to ensure your Docker networking setup allows
146
+ connections from the container to the host.
147
+
148
+ ## Troubleshooting
149
+
150
+ If you encounter issues with IDE integration, here are some common error
151
+ messages and how to resolve them.
152
+
153
+ ### Connection errors
154
+
155
+ - **Message:**
156
+ `🔴 Disconnected: Failed to connect to IDE companion extension in [IDE Name]. Please ensure the extension is running. To install the extension, run /ide install.`
157
+ - **Cause:** Gemini CLI could not find the necessary environment variables
158
+ (`GEMINI_CLI_IDE_WORKSPACE_PATH` or `GEMINI_CLI_IDE_SERVER_PORT`) to connect
159
+ to the IDE. This usually means the IDE companion extension is not running or
160
+ did not initialize correctly.
161
+ - **Solution:**
162
+ 1. Make sure you have installed the **Gemini CLI Companion** extension in
163
+ your IDE and that it is enabled.
164
+ 2. Open a new terminal window in your IDE to ensure it picks up the correct
165
+ environment.
166
+
167
+ - **Message:**
168
+ `🔴 Disconnected: IDE connection error. The connection was lost unexpectedly. Please try reconnecting by running /ide enable`
169
+ - **Cause:** The connection to the IDE companion was lost.
170
+ - **Solution:** Run `/ide enable` to try and reconnect. If the issue
171
+ continues, open a new terminal window or restart your IDE.
172
+
173
+ ### Configuration errors
174
+
175
+ - **Message:**
176
+ `🔴 Disconnected: Directory mismatch. Gemini CLI is running in a different location than the open workspace in [IDE Name]. Please run the CLI from one of the following directories: [List of directories]`
177
+ - **Cause:** The CLI's current working directory is outside the workspace you
178
+ have open in your IDE.
179
+ - **Solution:** `cd` into the same directory that is open in your IDE and
180
+ restart the CLI.
181
+
182
+ - **Message:**
183
+ `🔴 Disconnected: To use this feature, please open a workspace folder in [IDE Name] and try again.`
184
+ - **Cause:** You have no workspace open in your IDE.
185
+ - **Solution:** Open a workspace in your IDE and restart the CLI.
186
+
187
+ ### General errors
188
+
189
+ - **Message:**
190
+ `IDE integration is not supported in your current environment. To use this feature, run Gemini CLI in one of these supported IDEs: [List of IDEs]`
191
+ - **Cause:** You are running Gemini CLI in a terminal or environment that is
192
+ not a supported IDE.
193
+ - **Solution:** Run Gemini CLI from the integrated terminal of a supported
194
+ IDE, like Antigravity or VS Code.
195
+
196
+ - **Message:**
197
+ `No installer is available for IDE. Please install the Gemini CLI Companion extension manually from the marketplace.`
198
+ - **Cause:** You ran `/ide install`, but the CLI does not have an automated
199
+ installer for your specific IDE.
200
+ - **Solution:** Open your IDE's extension marketplace, search for "Gemini CLI
201
+ Companion", and
202
+ [install it manually](#3-manual-installation-from-a-marketplace).
@@ -0,0 +1,147 @@
1
+ # Welcome to Gemini CLI documentation
2
+
3
+ This documentation provides a comprehensive guide to installing, using, and
4
+ developing Gemini CLI, a tool that lets you interact with Gemini models through
5
+ a command-line interface.
6
+
7
+ ## Gemini CLI overview
8
+
9
+ Gemini CLI brings the capabilities of Gemini models to your terminal in an
10
+ interactive Read-Eval-Print Loop (REPL) environment. Gemini CLI consists of a
11
+ client-side application (`packages/cli`) that communicates with a local server
12
+ (`packages/core`), which in turn manages requests to the Gemini API and its AI
13
+ models. Gemini CLI also contains a variety of tools for tasks such as performing
14
+ file system operations, running shells, and web fetching, which are managed by
15
+ `packages/core`.
16
+
17
+ ## Navigating the documentation
18
+
19
+ This documentation is organized into the following sections:
20
+
21
+ ### Overview
22
+
23
+ - **[Architecture overview](./architecture.md):** Understand the high-level
24
+ design of Gemini CLI, including its components and how they interact.
25
+ - **[Contribution guide](../CONTRIBUTING.md):** Information for contributors and
26
+ developers, including setup, building, testing, and coding conventions.
27
+
28
+ ### Get started
29
+
30
+ - **[Gemini CLI quickstart](./get-started/index.md):** Let's get started with
31
+ Gemini CLI.
32
+ - **[Gemini 3 Pro on Gemini CLI](./get-started/gemini-3.md):** Learn how to
33
+ enable and use Gemini 3.
34
+ - **[Authentication](./get-started/authentication.md):** Authenticate to Gemini
35
+ CLI.
36
+ - **[Configuration](./get-started/configuration.md):** Learn how to configure
37
+ the CLI.
38
+ - **[Installation](./get-started/installation.md):** Install and run Gemini CLI.
39
+ - **[Examples](./get-started/examples.md):** Example usage of Gemini CLI.
40
+
41
+ ### CLI
42
+
43
+ - **[Introduction: Gemini CLI](./cli/index.md):** Overview of the command-line
44
+ interface.
45
+ - **[Commands](./cli/commands.md):** Description of available CLI commands.
46
+ - **[Checkpointing](./cli/checkpointing.md):** Documentation for the
47
+ checkpointing feature.
48
+ - **[Custom commands](./cli/custom-commands.md):** Create your own commands and
49
+ shortcuts for frequently used prompts.
50
+ - **[Enterprise](./cli/enterprise.md):** Gemini CLI for enterprise.
51
+ - **[Headless mode](./cli/headless.md):** Use Gemini CLI programmatically for
52
+ scripting and automation.
53
+ - **[Keyboard shortcuts](./cli/keyboard-shortcuts.md):** A reference for all
54
+ keyboard shortcuts to improve your workflow.
55
+ - **[Model selection](./cli/model.md):** Select the model used to process your
56
+ commands with `/model`.
57
+ - **[Sandbox](./cli/sandbox.md):** Isolate tool execution in a secure,
58
+ containerized environment.
59
+ - **[Settings](./cli/settings.md):** Configure various aspects of the CLI's
60
+ behavior and appearance with `/settings`.
61
+ - **[Telemetry](./cli/telemetry.md):** Overview of telemetry in the CLI.
62
+ - **[Themes](./cli/themes.md):** Themes for Gemini CLI.
63
+ - **[Token caching](./cli/token-caching.md):** Token caching and optimization.
64
+ - **[Trusted Folders](./cli/trusted-folders.md):** An overview of the Trusted
65
+ Folders security feature.
66
+ - **[Tutorials](./cli/tutorials.md):** Tutorials for Gemini CLI.
67
+ - **[Uninstall](./cli/uninstall.md):** Methods for uninstalling the Gemini CLI.
68
+
69
+ ### Core
70
+
71
+ - **[Introduction: Gemini CLI core](./core/index.md):** Information about Gemini
72
+ CLI core.
73
+ - **[Memport](./core/memport.md):** Using the Memory Import Processor.
74
+ - **[Tools API](./core/tools-api.md):** Information on how the core manages and
75
+ exposes tools.
76
+ - **[System Prompt Override](./cli/system-prompt.md):** Replace built-in system
77
+ instructions using `GEMINI_SYSTEM_MD`.
78
+
79
+ - **[Policy Engine](./core/policy-engine.md):** Use the Policy Engine for
80
+ fine-grained control over tool execution.
81
+
82
+ ### Tools
83
+
84
+ - **[Introduction: Gemini CLI tools](./tools/index.md):** Information about
85
+ Gemini CLI's tools.
86
+ - **[File system tools](./tools/file-system.md):** Documentation for the
87
+ `read_file` and `write_file` tools.
88
+ - **[Shell tool](./tools/shell.md):** Documentation for the `run_shell_command`
89
+ tool.
90
+ - **[Web fetch tool](./tools/web-fetch.md):** Documentation for the `web_fetch`
91
+ tool.
92
+ - **[Web search tool](./tools/web-search.md):** Documentation for the
93
+ `google_web_search` tool.
94
+ - **[Memory tool](./tools/memory.md):** Documentation for the `save_memory`
95
+ tool.
96
+ - **[Todo tool](./tools/todos.md):** Documentation for the `write_todos` tool.
97
+ - **[MCP servers](./tools/mcp-server.md):** Using MCP servers with Gemini CLI.
98
+
99
+ ### Extensions
100
+
101
+ - **[Introduction: Extensions](./extensions/index.md):** How to extend the CLI
102
+ with new functionality.
103
+ - **[Get Started with extensions](./extensions/getting-started-extensions.md):**
104
+ Learn how to build your own extension.
105
+ - **[Extension releasing](./extensions/extension-releasing.md):** How to release
106
+ Gemini CLI extensions.
107
+
108
+ ### Hooks
109
+
110
+ - **[Hooks](./hooks/index.md):** Intercept and customize Gemini CLI behavior at
111
+ key lifecycle points.
112
+ - **[Writing Hooks](./hooks/writing-hooks.md):** Learn how to create your first
113
+ hook with a comprehensive example.
114
+ - **[Best Practices](./hooks/best-practices.md):** Security, performance, and
115
+ debugging guidelines for hooks.
116
+
117
+ ### IDE integration
118
+
119
+ - **[Introduction to IDE integration](./ide-integration/index.md):** Connect the
120
+ CLI to your editor.
121
+ - **[IDE companion extension spec](./ide-integration/ide-companion-spec.md):**
122
+ Spec for building IDE companion extensions.
123
+
124
+ ### Development
125
+
126
+ - **[NPM](./npm.md):** Details on how the project's packages are structured.
127
+ - **[Releases](./releases.md):** Information on the project's releases and
128
+ deployment cadence.
129
+ - **[Changelog](./changelogs/index.md):** Highlights and notable changes to
130
+ Gemini CLI.
131
+ - **[Integration tests](./integration-tests.md):** Information about the
132
+ integration testing framework used in this project.
133
+ - **[Issue and PR automation](./issue-and-pr-automation.md):** A detailed
134
+ overview of the automated processes we use to manage and triage issues and
135
+ pull requests.
136
+
137
+ ### Support
138
+
139
+ - **[FAQ](./faq.md):** Frequently asked questions.
140
+ - **[Troubleshooting guide](./troubleshooting.md):** Find solutions to common
141
+ problems.
142
+ - **[Quota and pricing](./quota-and-pricing.md):** Learn about the free tier and
143
+ paid options.
144
+ - **[Terms of service and privacy notice](./tos-privacy.md):** Information on
145
+ the terms of service and privacy notices applicable to your use of Gemini CLI.
146
+
147
+ We hope this documentation helps you make the most of Gemini CLI!