@google/gemini-cli-core 0.22.0 → 0.23.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/CONTRIBUTING.md +546 -0
- package/dist/docs/architecture.md +80 -0
- package/dist/docs/assets/connected_devtools.png +0 -0
- package/dist/docs/assets/gemini-screenshot.png +0 -0
- package/dist/docs/assets/release_patch.png +0 -0
- package/dist/docs/assets/theme-ansi-light.png +0 -0
- package/dist/docs/assets/theme-ansi.png +0 -0
- package/dist/docs/assets/theme-atom-one.png +0 -0
- package/dist/docs/assets/theme-ayu-light.png +0 -0
- package/dist/docs/assets/theme-ayu.png +0 -0
- package/dist/docs/assets/theme-custom.png +0 -0
- package/dist/docs/assets/theme-default-light.png +0 -0
- package/dist/docs/assets/theme-default.png +0 -0
- package/dist/docs/assets/theme-dracula.png +0 -0
- package/dist/docs/assets/theme-github-light.png +0 -0
- package/dist/docs/assets/theme-github.png +0 -0
- package/dist/docs/assets/theme-google-light.png +0 -0
- package/dist/docs/assets/theme-xcode-light.png +0 -0
- package/dist/docs/changelogs/index.md +592 -0
- package/dist/docs/changelogs/latest.md +225 -0
- package/dist/docs/changelogs/preview.md +129 -0
- package/dist/docs/changelogs/releases.md +896 -0
- package/dist/docs/cli/authentication.md +3 -0
- package/dist/docs/cli/checkpointing.md +94 -0
- package/dist/docs/cli/commands.md +354 -0
- package/dist/docs/cli/configuration.md +780 -0
- package/dist/docs/cli/custom-commands.md +315 -0
- package/dist/docs/cli/enterprise.md +565 -0
- package/dist/docs/cli/gemini-ignore.md +71 -0
- package/dist/docs/cli/gemini-md.md +108 -0
- package/dist/docs/cli/generation-settings.md +210 -0
- package/dist/docs/cli/headless.md +388 -0
- package/dist/docs/cli/index.md +63 -0
- package/dist/docs/cli/keyboard-shortcuts.md +143 -0
- package/dist/docs/cli/model-routing.md +37 -0
- package/dist/docs/cli/model.md +62 -0
- package/dist/docs/cli/sandbox.md +171 -0
- package/dist/docs/cli/session-management.md +158 -0
- package/dist/docs/cli/settings.md +112 -0
- package/dist/docs/cli/system-prompt.md +93 -0
- package/dist/docs/cli/telemetry.md +791 -0
- package/dist/docs/cli/themes.md +237 -0
- package/dist/docs/cli/token-caching.md +20 -0
- package/dist/docs/cli/trusted-folders.md +95 -0
- package/dist/docs/cli/tutorials.md +83 -0
- package/dist/docs/cli/uninstall.md +47 -0
- package/dist/docs/core/index.md +101 -0
- package/dist/docs/core/memport.md +244 -0
- package/dist/docs/core/policy-engine.md +267 -0
- package/dist/docs/core/tools-api.md +131 -0
- package/dist/docs/examples/proxy-script.md +83 -0
- package/dist/docs/extensions/extension-releasing.md +183 -0
- package/dist/docs/extensions/getting-started-extensions.md +245 -0
- package/dist/docs/extensions/index.md +293 -0
- package/dist/docs/faq.md +154 -0
- package/dist/docs/get-started/authentication.md +321 -0
- package/dist/docs/get-started/configuration-v1.md +888 -0
- package/dist/docs/get-started/configuration.md +1444 -0
- package/dist/docs/get-started/deployment.md +143 -0
- package/dist/docs/get-started/examples.md +219 -0
- package/dist/docs/get-started/gemini-3.md +116 -0
- package/dist/docs/get-started/index.md +71 -0
- package/dist/docs/get-started/installation.md +141 -0
- package/dist/docs/hooks/best-practices.md +806 -0
- package/dist/docs/hooks/index.md +665 -0
- package/dist/docs/hooks/reference.md +168 -0
- package/dist/docs/hooks/writing-hooks.md +1026 -0
- package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
- package/dist/docs/ide-integration/index.md +202 -0
- package/dist/docs/index.md +147 -0
- package/dist/docs/integration-tests.md +211 -0
- package/dist/docs/issue-and-pr-automation.md +134 -0
- package/dist/docs/local-development.md +128 -0
- package/dist/docs/mermaid/context.mmd +103 -0
- package/dist/docs/mermaid/render-path.mmd +64 -0
- package/dist/docs/npm.md +62 -0
- package/dist/docs/quota-and-pricing.md +158 -0
- package/dist/docs/release-confidence.md +164 -0
- package/dist/docs/releases.md +540 -0
- package/dist/docs/sidebar.json +297 -0
- package/dist/docs/tools/file-system.md +217 -0
- package/dist/docs/tools/index.md +95 -0
- package/dist/docs/tools/mcp-server.md +1044 -0
- package/dist/docs/tools/memory.md +54 -0
- package/dist/docs/tools/shell.md +260 -0
- package/dist/docs/tools/todos.md +57 -0
- package/dist/docs/tools/web-fetch.md +59 -0
- package/dist/docs/tools/web-search.md +42 -0
- package/dist/docs/tos-privacy.md +96 -0
- package/dist/docs/troubleshooting.md +158 -0
- package/dist/src/agents/codebase-investigator.d.ts +2 -2
- package/dist/src/agents/codebase-investigator.js +4 -3
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/delegate-to-agent-tool.js +8 -4
- package/dist/src/agents/delegate-to-agent-tool.js.map +1 -1
- package/dist/src/agents/delegate-to-agent-tool.test.js +6 -4
- package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -1
- package/dist/src/agents/introspection-agent.d.ts +23 -0
- package/dist/src/agents/introspection-agent.js +72 -0
- package/dist/src/agents/introspection-agent.js.map +1 -0
- package/dist/src/agents/introspection-agent.test.js +47 -0
- package/dist/src/agents/introspection-agent.test.js.map +1 -0
- package/dist/src/agents/{executor.d.ts → local-executor.d.ts} +5 -11
- package/dist/src/agents/{executor.js → local-executor.js} +79 -53
- package/dist/src/agents/local-executor.js.map +1 -0
- package/dist/src/agents/{executor.test.js → local-executor.test.js} +64 -45
- package/dist/src/agents/local-executor.test.js.map +1 -0
- package/dist/src/agents/{invocation.d.ts → local-invocation.d.ts} +5 -6
- package/dist/src/agents/{invocation.js → local-invocation.js} +8 -9
- package/dist/src/agents/local-invocation.js.map +1 -0
- package/dist/src/agents/local-invocation.test.d.ts +6 -0
- package/dist/src/agents/{invocation.test.js → local-invocation.test.js} +18 -17
- package/dist/src/agents/local-invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +1 -0
- package/dist/src/agents/registry.js +68 -20
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +113 -1
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/remote-invocation.d.ts +21 -0
- package/dist/src/agents/remote-invocation.js +31 -0
- package/dist/src/agents/remote-invocation.js.map +1 -0
- package/dist/src/agents/remote-invocation.test.d.ts +6 -0
- package/dist/src/agents/remote-invocation.test.js +35 -0
- package/dist/src/agents/remote-invocation.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.js +7 -3
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +10 -9
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/toml-loader.d.ts +65 -0
- package/dist/src/agents/toml-loader.js +176 -0
- package/dist/src/agents/toml-loader.js.map +1 -0
- package/dist/src/agents/toml-loader.test.d.ts +6 -0
- package/dist/src/agents/toml-loader.test.js +190 -0
- package/dist/src/agents/toml-loader.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +12 -4
- package/dist/src/availability/modelAvailabilityService.d.ts +2 -1
- package/dist/src/availability/policyHelpers.d.ts +4 -3
- package/dist/src/availability/policyHelpers.js +13 -20
- package/dist/src/availability/policyHelpers.js.map +1 -1
- package/dist/src/availability/policyHelpers.test.js +28 -18
- package/dist/src/availability/policyHelpers.test.js.map +1 -1
- package/dist/src/code_assist/oauth2.js +1 -1
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +6 -8
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +4 -1
- package/dist/src/code_assist/server.js +50 -7
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +177 -27
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/telemetry.d.ts +14 -0
- package/dist/src/code_assist/telemetry.js +156 -0
- package/dist/src/code_assist/telemetry.js.map +1 -0
- package/dist/src/code_assist/telemetry.test.d.ts +6 -0
- package/dist/src/code_assist/telemetry.test.js +300 -0
- package/dist/src/code_assist/telemetry.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +52 -1
- package/dist/src/code_assist/types.js +21 -0
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/config/config.d.ts +10 -13
- package/dist/src/config/config.js +32 -32
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +72 -19
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/flashFallback.test.js +0 -37
- package/dist/src/config/flashFallback.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +2 -0
- package/dist/src/config/storage.js +6 -0
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +8 -0
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/core/baseLlmClient.js +44 -43
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +12 -19
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.js +23 -35
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +32 -65
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/clientHookTriggers.js +2 -2
- package/dist/src/core/clientHookTriggers.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +0 -6
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.js +3 -3
- package/dist/src/core/coreToolHookTriggers.js.map +1 -1
- package/dist/src/core/geminiChat.js +21 -71
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +16 -92
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.js +3 -3
- package/dist/src/core/geminiChatHookTriggers.js.map +1 -1
- package/dist/src/core/geminiChat_network_retry.test.js +4 -6
- package/dist/src/core/geminiChat_network_retry.test.js.map +1 -1
- package/dist/src/core/prompts.test.js +0 -2
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/sessionHookTriggers.js +3 -3
- package/dist/src/core/sessionHookTriggers.js.map +1 -1
- package/dist/src/core/turn.d.ts +1 -0
- package/dist/src/core/turn.js +4 -12
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +0 -5
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.test.js +0 -21
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.js +10 -4
- package/dist/src/hooks/hookEventHandler.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.test.js +47 -0
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
- package/dist/src/hooks/hookPlanner.js +3 -1
- package/dist/src/hooks/hookPlanner.js.map +1 -1
- package/dist/src/hooks/hookPlanner.test.js +61 -0
- package/dist/src/hooks/hookPlanner.test.js.map +1 -1
- package/dist/src/hooks/hookRegistry.d.ts +1 -1
- package/dist/src/hooks/hookRegistry.js +2 -2
- package/dist/src/hooks/hookRegistry.js.map +1 -1
- package/dist/src/hooks/hookRegistry.test.js +73 -0
- package/dist/src/hooks/hookRegistry.test.js.map +1 -1
- package/dist/src/hooks/hookRunner.js +14 -10
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookRunner.test.js +81 -33
- package/dist/src/hooks/hookRunner.test.js.map +1 -1
- package/dist/src/hooks/types.d.ts +2 -0
- package/dist/src/hooks/types.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.js +6 -2
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +4 -1
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +8 -1
- package/dist/src/mcp/oauth-utils.js +30 -1
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +42 -0
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +0 -3
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +0 -6
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/services/contextManager.d.ts +5 -11
- package/dist/src/services/contextManager.js +20 -17
- package/dist/src/services/contextManager.js.map +1 -1
- package/dist/src/services/contextManager.test.js +40 -41
- package/dist/src/services/contextManager.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.js +2 -1
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +14 -8
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.integration.test.js +1 -1
- package/dist/src/services/modelConfig.integration.test.js.map +1 -1
- package/dist/src/services/shellExecutionService.js +18 -2
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +4 -2
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +25 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +32 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +5 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +12 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/loggers.js +1 -0
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +37 -2
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/sdk.js +2 -2
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/tools/confirmation-policy.test.d.ts +6 -0
- package/dist/src/tools/confirmation-policy.test.js +152 -0
- package/dist/src/tools/confirmation-policy.test.js.map +1 -0
- package/dist/src/tools/edit.js +5 -1
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/get-internal-docs.d.ts +27 -0
- package/dist/src/tools/get-internal-docs.js +129 -0
- package/dist/src/tools/get-internal-docs.js.map +1 -0
- package/dist/src/tools/get-internal-docs.test.d.ts +6 -0
- package/dist/src/tools/get-internal-docs.test.js +56 -0
- package/dist/src/tools/get-internal-docs.test.js.map +1 -0
- package/dist/src/tools/ripGrep.d.ts +1 -0
- package/dist/src/tools/ripGrep.js +16 -4
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +55 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/smart-edit.js +5 -1
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +14 -0
- package/dist/src/tools/tool-names.js +55 -0
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tool-names.test.d.ts +6 -0
- package/dist/src/tools/tool-names.test.js +43 -0
- package/dist/src/tools/tool-names.test.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +0 -1
- package/dist/src/tools/tool-registry.js +1 -1
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +2 -1
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/web-fetch.js +5 -1
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/write-file.js +5 -1
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/utils/checkpointUtils.js +1 -1
- package/dist/src/utils/checkpointUtils.js.map +1 -1
- package/dist/src/utils/checkpointUtils.test.js +1 -1
- package/dist/src/utils/checkpointUtils.test.js.map +1 -1
- package/dist/src/utils/editCorrector.js +1 -1
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +2 -2
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +1 -0
- package/dist/src/utils/environmentContext.js +4 -0
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +2 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/events.d.ts +3 -18
- package/dist/src/utils/events.js +0 -9
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/geminiIgnoreParser.d.ts +11 -0
- package/dist/src/utils/geminiIgnoreParser.js +20 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -1
- package/dist/src/utils/geminiIgnoreParser.test.js +48 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.d.ts +1 -0
- package/dist/src/utils/generateContentResponseUtilities.js +10 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +59 -2
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.js +1 -1
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +3 -1
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/shell-utils.js +25 -4
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -6
- package/dist/src/agents/executor.js.map +0 -1
- package/dist/src/agents/executor.test.js.map +0 -1
- package/dist/src/agents/invocation.js.map +0 -1
- package/dist/src/agents/invocation.test.js.map +0 -1
- /package/dist/src/agents/{executor.test.d.ts → introspection-agent.test.d.ts} +0 -0
- /package/dist/src/agents/{invocation.test.d.ts → local-executor.test.d.ts} +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Gemini CLI
|
|
2
|
+
|
|
3
|
+
Within Gemini CLI, `packages/cli` is the frontend for users to send and receive
|
|
4
|
+
prompts with the Gemini AI model and its associated tools. For a general
|
|
5
|
+
overview of Gemini CLI, see the [main documentation page](../index.md).
|
|
6
|
+
|
|
7
|
+
## Basic features
|
|
8
|
+
|
|
9
|
+
- **[Commands](./commands.md):** A reference for all built-in slash commands
|
|
10
|
+
- **[Custom commands](./custom-commands.md):** Create your own commands and
|
|
11
|
+
shortcuts for frequently used prompts.
|
|
12
|
+
- **[Headless mode](./headless.md):** Use Gemini CLI programmatically for
|
|
13
|
+
scripting and automation.
|
|
14
|
+
- **[Model selection](./model.md):** Configure the Gemini AI model used by the
|
|
15
|
+
CLI.
|
|
16
|
+
- **[Settings](./settings.md):** Configure various aspects of the CLI's behavior
|
|
17
|
+
and appearance.
|
|
18
|
+
- **[Themes](./themes.md):** Customizing the CLI's appearance with different
|
|
19
|
+
themes.
|
|
20
|
+
- **[Keyboard shortcuts](./keyboard-shortcuts.md):** A reference for all
|
|
21
|
+
keyboard shortcuts to improve your workflow.
|
|
22
|
+
- **[Tutorials](./tutorials.md):** Step-by-step guides for common tasks.
|
|
23
|
+
|
|
24
|
+
## Advanced features
|
|
25
|
+
|
|
26
|
+
- **[Checkpointing](./checkpointing.md):** Automatically save and restore
|
|
27
|
+
snapshots of your session and files.
|
|
28
|
+
- **[Enterprise configuration](./enterprise.md):** Deploying and manage Gemini
|
|
29
|
+
CLI in an enterprise environment.
|
|
30
|
+
- **[Sandboxing](./sandbox.md):** Isolate tool execution in a secure,
|
|
31
|
+
containerized environment.
|
|
32
|
+
- **[Telemetry](./telemetry.md):** Configure observability to monitor usage and
|
|
33
|
+
performance.
|
|
34
|
+
- **[Token caching](./token-caching.md):** Optimize API costs by caching tokens.
|
|
35
|
+
- **[Trusted folders](./trusted-folders.md):** A security feature to control
|
|
36
|
+
which projects can use the full capabilities of the CLI.
|
|
37
|
+
- **[Ignoring files (.geminiignore)](./gemini-ignore.md):** Exclude specific
|
|
38
|
+
files and directories from being accessed by tools.
|
|
39
|
+
- **[Context files (GEMINI.md)](./gemini-md.md):** Provide persistent,
|
|
40
|
+
hierarchical context to the model.
|
|
41
|
+
- **[System prompt override](./system-prompt.md):** Replace the built‑in system
|
|
42
|
+
instructions using `GEMINI_SYSTEM_MD`.
|
|
43
|
+
|
|
44
|
+
## Non-interactive mode
|
|
45
|
+
|
|
46
|
+
Gemini CLI can be run in a non-interactive mode, which is useful for scripting
|
|
47
|
+
and automation. In this mode, you pipe input to the CLI, it executes the
|
|
48
|
+
command, and then it exits.
|
|
49
|
+
|
|
50
|
+
The following example pipes a command to Gemini CLI from your terminal:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
echo "What is fine tuning?" | gemini
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
You can also use the `--prompt` or `-p` flag:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
gemini -p "What is fine tuning?"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For comprehensive documentation on headless usage, scripting, automation, and
|
|
63
|
+
advanced examples, see the **[Headless mode](./headless.md)** guide.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Gemini CLI keyboard shortcuts
|
|
2
|
+
|
|
3
|
+
Gemini CLI ships with a set of default keyboard shortcuts for editing input,
|
|
4
|
+
navigating history, and controlling the UI. Use this reference to learn the
|
|
5
|
+
available combinations.
|
|
6
|
+
|
|
7
|
+
<!-- KEYBINDINGS-AUTOGEN:START -->
|
|
8
|
+
|
|
9
|
+
#### Basic Controls
|
|
10
|
+
|
|
11
|
+
| Action | Keys |
|
|
12
|
+
| -------------------------------------------- | ------- |
|
|
13
|
+
| Confirm the current selection or choice. | `Enter` |
|
|
14
|
+
| Dismiss dialogs or cancel the current focus. | `Esc` |
|
|
15
|
+
|
|
16
|
+
#### Cursor Movement
|
|
17
|
+
|
|
18
|
+
| Action | Keys |
|
|
19
|
+
| ----------------------------------------- | ---------------------- |
|
|
20
|
+
| Move the cursor to the start of the line. | `Ctrl + A`<br />`Home` |
|
|
21
|
+
| Move the cursor to the end of the line. | `Ctrl + E`<br />`End` |
|
|
22
|
+
|
|
23
|
+
#### Editing
|
|
24
|
+
|
|
25
|
+
| Action | Keys |
|
|
26
|
+
| ------------------------------------------------ | ----------------------------------------- |
|
|
27
|
+
| Delete from the cursor to the end of the line. | `Ctrl + K` |
|
|
28
|
+
| Delete from the cursor to the start of the line. | `Ctrl + U` |
|
|
29
|
+
| Clear all text in the input field. | `Ctrl + C` |
|
|
30
|
+
| Delete the previous word. | `Ctrl + Backspace`<br />`Cmd + Backspace` |
|
|
31
|
+
|
|
32
|
+
#### Screen Control
|
|
33
|
+
|
|
34
|
+
| Action | Keys |
|
|
35
|
+
| -------------------------------------------- | ---------- |
|
|
36
|
+
| Clear the terminal screen and redraw the UI. | `Ctrl + L` |
|
|
37
|
+
|
|
38
|
+
#### Scrolling
|
|
39
|
+
|
|
40
|
+
| Action | Keys |
|
|
41
|
+
| ------------------------ | -------------------- |
|
|
42
|
+
| Scroll content up. | `Shift + Up Arrow` |
|
|
43
|
+
| Scroll content down. | `Shift + Down Arrow` |
|
|
44
|
+
| Scroll to the top. | `Home` |
|
|
45
|
+
| Scroll to the bottom. | `End` |
|
|
46
|
+
| Scroll up by one page. | `Page Up` |
|
|
47
|
+
| Scroll down by one page. | `Page Down` |
|
|
48
|
+
|
|
49
|
+
#### History & Search
|
|
50
|
+
|
|
51
|
+
| Action | Keys |
|
|
52
|
+
| -------------------------------------------- | --------------------- |
|
|
53
|
+
| Show the previous entry in history. | `Ctrl + P (no Shift)` |
|
|
54
|
+
| Show the next entry in history. | `Ctrl + N (no Shift)` |
|
|
55
|
+
| Start reverse search through history. | `Ctrl + R` |
|
|
56
|
+
| Insert the selected reverse-search match. | `Enter (no Ctrl)` |
|
|
57
|
+
| Accept a suggestion while reverse searching. | `Tab` |
|
|
58
|
+
|
|
59
|
+
#### Navigation
|
|
60
|
+
|
|
61
|
+
| Action | Keys |
|
|
62
|
+
| -------------------------------- | ------------------------------------------- |
|
|
63
|
+
| Move selection up in lists. | `Up Arrow (no Shift)` |
|
|
64
|
+
| Move selection down in lists. | `Down Arrow (no Shift)` |
|
|
65
|
+
| Move up within dialog options. | `Up Arrow (no Shift)`<br />`K (no Shift)` |
|
|
66
|
+
| Move down within dialog options. | `Down Arrow (no Shift)`<br />`J (no Shift)` |
|
|
67
|
+
|
|
68
|
+
#### Suggestions & Completions
|
|
69
|
+
|
|
70
|
+
| Action | Keys |
|
|
71
|
+
| --------------------------------------- | -------------------------------------------------- |
|
|
72
|
+
| Accept the inline suggestion. | `Tab`<br />`Enter (no Ctrl)` |
|
|
73
|
+
| Move to the previous completion option. | `Up Arrow (no Shift)`<br />`Ctrl + P (no Shift)` |
|
|
74
|
+
| Move to the next completion option. | `Down Arrow (no Shift)`<br />`Ctrl + N (no Shift)` |
|
|
75
|
+
| Expand an inline suggestion. | `Right Arrow` |
|
|
76
|
+
| Collapse an inline suggestion. | `Left Arrow` |
|
|
77
|
+
|
|
78
|
+
#### Text Input
|
|
79
|
+
|
|
80
|
+
| Action | Keys |
|
|
81
|
+
| ------------------------------------ | ------------------------------------------------------------------------------------------- |
|
|
82
|
+
| Submit the current prompt. | `Enter (no Ctrl, no Shift, no Cmd, not Paste)` |
|
|
83
|
+
| Insert a newline without submitting. | `Ctrl + Enter`<br />`Cmd + Enter`<br />`Paste + Enter`<br />`Shift + Enter`<br />`Ctrl + J` |
|
|
84
|
+
|
|
85
|
+
#### External Tools
|
|
86
|
+
|
|
87
|
+
| Action | Keys |
|
|
88
|
+
| ---------------------------------------------- | ------------------------- |
|
|
89
|
+
| Open the current prompt in an external editor. | `Ctrl + X` |
|
|
90
|
+
| Paste from the clipboard. | `Ctrl + V`<br />`Cmd + V` |
|
|
91
|
+
|
|
92
|
+
#### App Controls
|
|
93
|
+
|
|
94
|
+
| Action | Keys |
|
|
95
|
+
| ----------------------------------------------------------------- | ---------- |
|
|
96
|
+
| Toggle detailed error information. | `F12` |
|
|
97
|
+
| Toggle the full TODO list. | `Ctrl + T` |
|
|
98
|
+
| Toggle IDE context details. | `Ctrl + G` |
|
|
99
|
+
| Toggle Markdown rendering. | `Cmd + M` |
|
|
100
|
+
| Toggle copy mode when the terminal is using the alternate buffer. | `Ctrl + S` |
|
|
101
|
+
| Expand a height-constrained response to show additional lines. | `Ctrl + S` |
|
|
102
|
+
| Toggle focus between the shell and Gemini input. | `Ctrl + F` |
|
|
103
|
+
|
|
104
|
+
#### Session Control
|
|
105
|
+
|
|
106
|
+
| Action | Keys |
|
|
107
|
+
| -------------------------------------------- | ---------- |
|
|
108
|
+
| Cancel the current request or quit the CLI. | `Ctrl + C` |
|
|
109
|
+
| Exit the CLI when the input buffer is empty. | `Ctrl + D` |
|
|
110
|
+
|
|
111
|
+
<!-- KEYBINDINGS-AUTOGEN:END -->
|
|
112
|
+
|
|
113
|
+
## Additional context-specific shortcuts
|
|
114
|
+
|
|
115
|
+
- `Ctrl+Y`: Toggle YOLO (auto-approval) mode for tool calls.
|
|
116
|
+
- `Shift+Tab`: Toggle Auto Edit (auto-accept edits) mode.
|
|
117
|
+
- `Option+M` (macOS): Entering `µ` with Option+M also toggles Markdown
|
|
118
|
+
rendering, matching `Cmd+M`.
|
|
119
|
+
- `!` on an empty prompt: Enter or exit shell mode.
|
|
120
|
+
- `\` (at end of a line) + `Enter`: Insert a newline without leaving single-line
|
|
121
|
+
mode.
|
|
122
|
+
- `Ctrl+Delete` / `Meta+Delete`: Delete the word to the right of the cursor.
|
|
123
|
+
- `Ctrl+B` or `Left Arrow`: Move the cursor one character to the left while
|
|
124
|
+
editing text.
|
|
125
|
+
- `Ctrl+F` or `Right Arrow`: Move the cursor one character to the right; with an
|
|
126
|
+
embedded shell attached, `Ctrl+F` still toggles focus.
|
|
127
|
+
- `Ctrl+D` or `Delete`: Remove the character immediately to the right of the
|
|
128
|
+
cursor.
|
|
129
|
+
- `Ctrl+H` or `Backspace`: Remove the character immediately to the left of the
|
|
130
|
+
cursor.
|
|
131
|
+
- `Ctrl+Left Arrow` / `Meta+Left Arrow` / `Meta+B`: Move one word to the left.
|
|
132
|
+
- `Ctrl+Right Arrow` / `Meta+Right Arrow` / `Meta+F`: Move one word to the
|
|
133
|
+
right.
|
|
134
|
+
- `Ctrl+W`: Delete the word to the left of the cursor (in addition to
|
|
135
|
+
`Ctrl+Backspace` / `Cmd+Backspace`).
|
|
136
|
+
- `Ctrl+Z` / `Ctrl+Shift+Z`: Undo or redo the most recent text edit.
|
|
137
|
+
- `Meta+Enter`: Open the current input in an external editor (alias for
|
|
138
|
+
`Ctrl+X`).
|
|
139
|
+
- `Esc` pressed twice quickly: Clear the current input buffer.
|
|
140
|
+
- `Up Arrow` / `Down Arrow`: When the cursor is at the top or bottom of a
|
|
141
|
+
single-line input, navigate backward or forward through prompt history.
|
|
142
|
+
- `Number keys (1-9, multi-digit)` inside selection dialogs: Jump directly to
|
|
143
|
+
the numbered radio option and confirm when the full number is entered.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
## Model routing
|
|
2
|
+
|
|
3
|
+
Gemini CLI includes a model routing feature that automatically switches to a
|
|
4
|
+
fallback model in case of a model failure. This feature is enabled by default
|
|
5
|
+
and provides resilience when the primary model is unavailable.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
Model routing is managed by the `ModelAvailabilityService`, which monitors model
|
|
10
|
+
health and automatically routes requests to available models based on defined
|
|
11
|
+
policies.
|
|
12
|
+
|
|
13
|
+
1. **Model failure:** If the currently selected model fails (e.g., due to quota
|
|
14
|
+
or server errors), the CLI will iniate the fallback process.
|
|
15
|
+
|
|
16
|
+
2. **User consent:** Depending on the failure and the model's policy, the CLI
|
|
17
|
+
may prompt you to switch to a fallback model (by default always prompts
|
|
18
|
+
you).
|
|
19
|
+
|
|
20
|
+
3. **Model switch:** If approved, or if the policy allows for silent fallback,
|
|
21
|
+
the CLI will use an available fallback model for the current turn or the
|
|
22
|
+
remainder of the session.
|
|
23
|
+
|
|
24
|
+
### Model selection precedence
|
|
25
|
+
|
|
26
|
+
The model used by Gemini CLI is determined by the following order of precedence:
|
|
27
|
+
|
|
28
|
+
1. **`--model` command-line flag:** A model specified with the `--model` flag
|
|
29
|
+
when launching the CLI will always be used.
|
|
30
|
+
2. **`GEMINI_MODEL` environment variable:** If the `--model` flag is not used,
|
|
31
|
+
the CLI will use the model specified in the `GEMINI_MODEL` environment
|
|
32
|
+
variable.
|
|
33
|
+
3. **`model.name` in `settings.json`:** If neither of the above are set, the
|
|
34
|
+
model specified in the `model.name` property of your `settings.json` file
|
|
35
|
+
will be used.
|
|
36
|
+
4. **Default model:** If none of the above are set, the default model will be
|
|
37
|
+
used. The default model is `auto`
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Gemini CLI model selection (`/model` command)
|
|
2
|
+
|
|
3
|
+
Select your Gemini CLI model. The `/model` command lets you configure the model
|
|
4
|
+
used by Gemini CLI, giving you more control over your results. Use **Pro**
|
|
5
|
+
models for complex tasks and reasoning, **Flash** models for high speed results,
|
|
6
|
+
or the (recommended) **Auto** setting to choose the best model for your tasks.
|
|
7
|
+
|
|
8
|
+
> **Note:** The `/model` command (and the `--model` flag) does not override the
|
|
9
|
+
> model used by sub-agents. Consequently, even when using the `/model` flag you
|
|
10
|
+
> may see other models used in your model usage reports.
|
|
11
|
+
|
|
12
|
+
## How to use the `/model` command
|
|
13
|
+
|
|
14
|
+
Use the following command in Gemini CLI:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
/model
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Running this command will open a dialog with your options:
|
|
21
|
+
|
|
22
|
+
| Option | Description | Models |
|
|
23
|
+
| ----------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
|
24
|
+
| Auto (Gemini 3) | Let the system choose the best Gemini 3 model for your task. | gemini-3-pro-preview (if enabled), gemini-3-flash-preview (if enabled) |
|
|
25
|
+
| Auto (Gemini 2.5) | Let the system choose the best Gemini 2.5 model for your task. | gemini-2.5-pro, gemini-2.5-flash |
|
|
26
|
+
| Manual | Select a specific model. | Any available model. |
|
|
27
|
+
|
|
28
|
+
We recommend selecting one of the above **Auto** options. However, you can
|
|
29
|
+
select **Manual** to select a specific model from those available.
|
|
30
|
+
|
|
31
|
+
### Gemini 3 and preview features
|
|
32
|
+
|
|
33
|
+
> **Note:** Gemini 3 is not currently available on all account types. To learn
|
|
34
|
+
> more about Gemini 3 access, refer to
|
|
35
|
+
> [Gemini 3 on Gemini CLI](../get-started/gemini-3.md).
|
|
36
|
+
|
|
37
|
+
To enable Gemini 3 Pro and Gemini 3 Flash (if available), enable
|
|
38
|
+
[**Preview Features** by using the `settings` command](../cli/settings.md).
|
|
39
|
+
|
|
40
|
+
You can also use the `--model` flag to specify a particular Gemini model on
|
|
41
|
+
startup. For more details, refer to the
|
|
42
|
+
[configuration documentation](./configuration.md).
|
|
43
|
+
|
|
44
|
+
Changes to these settings will be applied to all subsequent interactions with
|
|
45
|
+
Gemini CLI.
|
|
46
|
+
|
|
47
|
+
## Best practices for model selection
|
|
48
|
+
|
|
49
|
+
- **Default to Auto.** For most users, the _Auto_ option model provides a
|
|
50
|
+
balance between speed and performance, automatically selecting the correct
|
|
51
|
+
model based on the complexity of the task. Example: Developing a web
|
|
52
|
+
application could include a mix of complex tasks (building architecture and
|
|
53
|
+
scaffolding the project) and simple tasks (generating CSS).
|
|
54
|
+
|
|
55
|
+
- **Switch to Pro if you aren't getting the results you want.** If you think you
|
|
56
|
+
need your model to be a little "smarter," you can manually select Pro. Pro
|
|
57
|
+
will provide you with the highest levels of reasoning and creativity. Example:
|
|
58
|
+
A complex or multi-stage debugging task.
|
|
59
|
+
|
|
60
|
+
- **Switch to Flash or Flash-Lite if you need faster results.** If you need a
|
|
61
|
+
simple response quickly, Flash or Flash-Lite is the best option. Example:
|
|
62
|
+
Converting a JSON object to a YAML string.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Sandboxing in the Gemini CLI
|
|
2
|
+
|
|
3
|
+
This document provides a guide to sandboxing in the Gemini CLI, including
|
|
4
|
+
prerequisites, quickstart, and configuration.
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
|
|
8
|
+
Before using sandboxing, you need to install and set up the Gemini CLI:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @google/gemini-cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
To verify the installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
gemini --version
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Overview of sandboxing
|
|
21
|
+
|
|
22
|
+
Sandboxing isolates potentially dangerous operations (such as shell commands or
|
|
23
|
+
file modifications) from your host system, providing a security barrier between
|
|
24
|
+
AI operations and your environment.
|
|
25
|
+
|
|
26
|
+
The benefits of sandboxing include:
|
|
27
|
+
|
|
28
|
+
- **Security**: Prevent accidental system damage or data loss.
|
|
29
|
+
- **Isolation**: Limit file system access to project directory.
|
|
30
|
+
- **Consistency**: Ensure reproducible environments across different systems.
|
|
31
|
+
- **Safety**: Reduce risk when working with untrusted code or experimental
|
|
32
|
+
commands.
|
|
33
|
+
|
|
34
|
+
## Sandboxing methods
|
|
35
|
+
|
|
36
|
+
Your ideal method of sandboxing may differ depending on your platform and your
|
|
37
|
+
preferred container solution.
|
|
38
|
+
|
|
39
|
+
### 1. macOS Seatbelt (macOS only)
|
|
40
|
+
|
|
41
|
+
Lightweight, built-in sandboxing using `sandbox-exec`.
|
|
42
|
+
|
|
43
|
+
**Default profile**: `permissive-open` - restricts writes outside project
|
|
44
|
+
directory but allows most other operations.
|
|
45
|
+
|
|
46
|
+
### 2. Container-based (Docker/Podman)
|
|
47
|
+
|
|
48
|
+
Cross-platform sandboxing with complete process isolation.
|
|
49
|
+
|
|
50
|
+
**Note**: Requires building the sandbox image locally or using a published image
|
|
51
|
+
from your organization's registry.
|
|
52
|
+
|
|
53
|
+
## Quickstart
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Enable sandboxing with command flag
|
|
57
|
+
gemini -s -p "analyze the code structure"
|
|
58
|
+
|
|
59
|
+
# Use environment variable
|
|
60
|
+
export GEMINI_SANDBOX=true
|
|
61
|
+
gemini -p "run the test suite"
|
|
62
|
+
|
|
63
|
+
# Configure in settings.json
|
|
64
|
+
{
|
|
65
|
+
"tools": {
|
|
66
|
+
"sandbox": "docker"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Configuration
|
|
72
|
+
|
|
73
|
+
### Enable sandboxing (in order of precedence)
|
|
74
|
+
|
|
75
|
+
1. **Command flag**: `-s` or `--sandbox`
|
|
76
|
+
2. **Environment variable**: `GEMINI_SANDBOX=true|docker|podman|sandbox-exec`
|
|
77
|
+
3. **Settings file**: `"sandbox": true` in the `tools` object of your
|
|
78
|
+
`settings.json` file (e.g., `{"tools": {"sandbox": true}}`).
|
|
79
|
+
|
|
80
|
+
### macOS Seatbelt profiles
|
|
81
|
+
|
|
82
|
+
Built-in profiles (set via `SEATBELT_PROFILE` env var):
|
|
83
|
+
|
|
84
|
+
- `permissive-open` (default): Write restrictions, network allowed
|
|
85
|
+
- `permissive-closed`: Write restrictions, no network
|
|
86
|
+
- `permissive-proxied`: Write restrictions, network via proxy
|
|
87
|
+
- `restrictive-open`: Strict restrictions, network allowed
|
|
88
|
+
- `restrictive-closed`: Maximum restrictions
|
|
89
|
+
|
|
90
|
+
### Custom sandbox flags
|
|
91
|
+
|
|
92
|
+
For container-based sandboxing, you can inject custom flags into the `docker` or
|
|
93
|
+
`podman` command using the `SANDBOX_FLAGS` environment variable. This is useful
|
|
94
|
+
for advanced configurations, such as disabling security features for specific
|
|
95
|
+
use cases.
|
|
96
|
+
|
|
97
|
+
**Example (Podman)**:
|
|
98
|
+
|
|
99
|
+
To disable SELinux labeling for volume mounts, you can set the following:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
export SANDBOX_FLAGS="--security-opt label=disable"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Multiple flags can be provided as a space-separated string:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
export SANDBOX_FLAGS="--flag1 --flag2=value"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Linux UID/GID handling
|
|
112
|
+
|
|
113
|
+
The sandbox automatically handles user permissions on Linux. Override these
|
|
114
|
+
permissions with:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
export SANDBOX_SET_UID_GID=true # Force host UID/GID
|
|
118
|
+
export SANDBOX_SET_UID_GID=false # Disable UID/GID mapping
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Troubleshooting
|
|
122
|
+
|
|
123
|
+
### Common issues
|
|
124
|
+
|
|
125
|
+
**"Operation not permitted"**
|
|
126
|
+
|
|
127
|
+
- Operation requires access outside sandbox.
|
|
128
|
+
- Try more permissive profile or add mount points.
|
|
129
|
+
|
|
130
|
+
**Missing commands**
|
|
131
|
+
|
|
132
|
+
- Add to custom Dockerfile.
|
|
133
|
+
- Install via `sandbox.bashrc`.
|
|
134
|
+
|
|
135
|
+
**Network issues**
|
|
136
|
+
|
|
137
|
+
- Check sandbox profile allows network.
|
|
138
|
+
- Verify proxy configuration.
|
|
139
|
+
|
|
140
|
+
### Debug mode
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
DEBUG=1 gemini -s -p "debug command"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Note:** If you have `DEBUG=true` in a project's `.env` file, it won't affect
|
|
147
|
+
gemini-cli due to automatic exclusion. Use `.gemini/.env` files for gemini-cli
|
|
148
|
+
specific debug settings.
|
|
149
|
+
|
|
150
|
+
### Inspect sandbox
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Check environment
|
|
154
|
+
gemini -s -p "run shell command: env | grep SANDBOX"
|
|
155
|
+
|
|
156
|
+
# List mounts
|
|
157
|
+
gemini -s -p "run shell command: mount | grep workspace"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Security notes
|
|
161
|
+
|
|
162
|
+
- Sandboxing reduces but doesn't eliminate all risks.
|
|
163
|
+
- Use the most restrictive profile that allows your work.
|
|
164
|
+
- Container overhead is minimal after first build.
|
|
165
|
+
- GUI applications may not work in sandboxes.
|
|
166
|
+
|
|
167
|
+
## Related documentation
|
|
168
|
+
|
|
169
|
+
- [Configuration](../get-started/configuration.md): Full configuration options.
|
|
170
|
+
- [Commands](./commands.md): Available commands.
|
|
171
|
+
- [Troubleshooting](../troubleshooting.md): General troubleshooting.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Session Management
|
|
2
|
+
|
|
3
|
+
Gemini CLI includes robust session management features that automatically save
|
|
4
|
+
your conversation history. This allows you to interrupt your work and resume
|
|
5
|
+
exactly where you left off, review past interactions, and manage your
|
|
6
|
+
conversation history effectively.
|
|
7
|
+
|
|
8
|
+
## Automatic Saving
|
|
9
|
+
|
|
10
|
+
Every time you interact with Gemini CLI, your session is automatically saved.
|
|
11
|
+
This happens in the background without any manual intervention.
|
|
12
|
+
|
|
13
|
+
- **What is saved:** The complete conversation history, including:
|
|
14
|
+
- Your prompts and the model's responses.
|
|
15
|
+
- All tool executions (inputs and outputs).
|
|
16
|
+
- Token usage statistics (input/output/cached, etc.).
|
|
17
|
+
- Assistant thoughts/reasoning summaries (when available).
|
|
18
|
+
- **Location:** Sessions are stored in `~/.gemini/tmp/<project_hash>/chats/`.
|
|
19
|
+
- **Scope:** Sessions are project-specific. Switching directories to a different
|
|
20
|
+
project will switch to that project's session history.
|
|
21
|
+
|
|
22
|
+
## Resuming Sessions
|
|
23
|
+
|
|
24
|
+
You can resume a previous session to continue the conversation with all prior
|
|
25
|
+
context restored.
|
|
26
|
+
|
|
27
|
+
### From the Command Line
|
|
28
|
+
|
|
29
|
+
When starting the CLI, you can use the `--resume` (or `-r`) flag:
|
|
30
|
+
|
|
31
|
+
- **Resume latest:**
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
gemini --resume
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This immediately loads the most recent session.
|
|
38
|
+
|
|
39
|
+
- **Resume by index:** First, list available sessions (see
|
|
40
|
+
[Listing Sessions](#listing-sessions)), then use the index number:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
gemini --resume 1
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- **Resume by ID:** You can also provide the full session UUID:
|
|
47
|
+
```bash
|
|
48
|
+
gemini --resume a1b2c3d4-e5f6-7890-abcd-ef1234567890
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### From the Interactive Interface
|
|
52
|
+
|
|
53
|
+
While the CLI is running, you can use the `/resume` slash command to open the
|
|
54
|
+
**Session Browser**:
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
/resume
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This opens an interactive interface where you can:
|
|
61
|
+
|
|
62
|
+
- **Browse:** Scroll through a list of your past sessions.
|
|
63
|
+
- **Preview:** See details like the session date, message count, and the first
|
|
64
|
+
user prompt.
|
|
65
|
+
- **Search:** Press `/` to enter search mode, then type to filter sessions by ID
|
|
66
|
+
or content.
|
|
67
|
+
- **Select:** Press `Enter` to resume the selected session.
|
|
68
|
+
|
|
69
|
+
## Managing Sessions
|
|
70
|
+
|
|
71
|
+
### Listing Sessions
|
|
72
|
+
|
|
73
|
+
To see a list of all available sessions for the current project from the command
|
|
74
|
+
line:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
gemini --list-sessions
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Output example:
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
Available sessions for this project (3):
|
|
84
|
+
|
|
85
|
+
1. Fix bug in auth (2 days ago) [a1b2c3d4]
|
|
86
|
+
2. Refactor database schema (5 hours ago) [e5f67890]
|
|
87
|
+
3. Update documentation (Just now) [abcd1234]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Deleting Sessions
|
|
91
|
+
|
|
92
|
+
You can remove old or unwanted sessions to free up space or declutter your
|
|
93
|
+
history.
|
|
94
|
+
|
|
95
|
+
**From the Command Line:** Use the `--delete-session` flag with an index or ID:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
gemini --delete-session 2
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**From the Session Browser:**
|
|
102
|
+
|
|
103
|
+
1. Open the browser with `/resume`.
|
|
104
|
+
2. Navigate to the session you want to remove.
|
|
105
|
+
3. Press `x`.
|
|
106
|
+
|
|
107
|
+
## Configuration
|
|
108
|
+
|
|
109
|
+
You can configure how Gemini CLI manages your session history in your
|
|
110
|
+
`settings.json` file.
|
|
111
|
+
|
|
112
|
+
### Session Retention
|
|
113
|
+
|
|
114
|
+
To prevent your history from growing indefinitely, you can enable automatic
|
|
115
|
+
cleanup policies.
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"general": {
|
|
120
|
+
"sessionRetention": {
|
|
121
|
+
"enabled": true,
|
|
122
|
+
"maxAge": "30d", // Keep sessions for 30 days
|
|
123
|
+
"maxCount": 50 // Keep the 50 most recent sessions
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- **`enabled`**: (boolean) Master switch for session cleanup. Default is
|
|
130
|
+
`false`.
|
|
131
|
+
- **`maxAge`**: (string) Duration to keep sessions (e.g., "24h", "7d", "4w").
|
|
132
|
+
Sessions older than this will be deleted.
|
|
133
|
+
- **`maxCount`**: (number) Maximum number of sessions to retain. The oldest
|
|
134
|
+
sessions exceeding this count will be deleted.
|
|
135
|
+
- **`minRetention`**: (string) Minimum retention period (safety limit). Defaults
|
|
136
|
+
to `"1d"`; sessions newer than this period are never deleted by automatic
|
|
137
|
+
cleanup.
|
|
138
|
+
|
|
139
|
+
### Session Limits
|
|
140
|
+
|
|
141
|
+
You can also limit the length of individual sessions to prevent context windows
|
|
142
|
+
from becoming too large and expensive.
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"model": {
|
|
147
|
+
"maxSessionTurns": 100
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
- **`maxSessionTurns`**: (number) The maximum number of turns (user + model
|
|
153
|
+
exchanges) allowed in a single session. Set to `-1` for unlimited (default).
|
|
154
|
+
|
|
155
|
+
**Behavior when limit is reached:**
|
|
156
|
+
- **Interactive Mode:** The CLI shows an informational message and stops
|
|
157
|
+
sending requests to the model. You must manually start a new session.
|
|
158
|
+
- **Non-Interactive Mode:** The CLI exits with an error.
|