@dgxo/mashadevcli 1.1.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.
Files changed (140) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +393 -0
  3. package/bundle/builtin/skill-creator/SKILL.md +382 -0
  4. package/bundle/builtin/skill-creator/scripts/init_skill.cjs +239 -0
  5. package/bundle/builtin/skill-creator/scripts/package_skill.cjs +131 -0
  6. package/bundle/builtin/skill-creator/scripts/validate_skill.cjs +131 -0
  7. package/bundle/docs/CONTRIBUTING.md +1 -0
  8. package/bundle/docs/admin/enterprise-controls.md +115 -0
  9. package/bundle/docs/assets/connected_devtools.png +0 -0
  10. package/bundle/docs/assets/gemini-screenshot.png +0 -0
  11. package/bundle/docs/assets/monitoring-dashboard-logs.png +0 -0
  12. package/bundle/docs/assets/monitoring-dashboard-metrics.png +0 -0
  13. package/bundle/docs/assets/monitoring-dashboard-overview.png +0 -0
  14. package/bundle/docs/assets/release_patch.png +0 -0
  15. package/bundle/docs/assets/theme-ansi-light.png +0 -0
  16. package/bundle/docs/assets/theme-ansi.png +0 -0
  17. package/bundle/docs/assets/theme-atom-one.png +0 -0
  18. package/bundle/docs/assets/theme-ayu-light.png +0 -0
  19. package/bundle/docs/assets/theme-ayu.png +0 -0
  20. package/bundle/docs/assets/theme-custom.png +0 -0
  21. package/bundle/docs/assets/theme-default-light.png +0 -0
  22. package/bundle/docs/assets/theme-default.png +0 -0
  23. package/bundle/docs/assets/theme-dracula.png +0 -0
  24. package/bundle/docs/assets/theme-github-light.png +0 -0
  25. package/bundle/docs/assets/theme-github.png +0 -0
  26. package/bundle/docs/assets/theme-google-light.png +0 -0
  27. package/bundle/docs/assets/theme-xcode-light.png +0 -0
  28. package/bundle/docs/changelogs/index.md +867 -0
  29. package/bundle/docs/changelogs/latest.md +208 -0
  30. package/bundle/docs/changelogs/preview.md +187 -0
  31. package/bundle/docs/cli/checkpointing.md +93 -0
  32. package/bundle/docs/cli/cli-reference.md +115 -0
  33. package/bundle/docs/cli/creating-skills.md +80 -0
  34. package/bundle/docs/cli/custom-commands.md +327 -0
  35. package/bundle/docs/cli/enterprise.md +604 -0
  36. package/bundle/docs/cli/gemini-ignore.md +71 -0
  37. package/bundle/docs/cli/gemini-md.md +116 -0
  38. package/bundle/docs/cli/generation-settings.md +210 -0
  39. package/bundle/docs/cli/headless.md +50 -0
  40. package/bundle/docs/cli/model-routing.md +42 -0
  41. package/bundle/docs/cli/model.md +53 -0
  42. package/bundle/docs/cli/plan-mode.md +375 -0
  43. package/bundle/docs/cli/rewind.md +51 -0
  44. package/bundle/docs/cli/sandbox.md +257 -0
  45. package/bundle/docs/cli/session-management.md +184 -0
  46. package/bundle/docs/cli/settings.md +165 -0
  47. package/bundle/docs/cli/skills.md +134 -0
  48. package/bundle/docs/cli/system-prompt.md +125 -0
  49. package/bundle/docs/cli/telemetry.md +922 -0
  50. package/bundle/docs/cli/themes.md +269 -0
  51. package/bundle/docs/cli/token-caching.md +20 -0
  52. package/bundle/docs/cli/trusted-folders.md +126 -0
  53. package/bundle/docs/cli/tutorials/automation.md +283 -0
  54. package/bundle/docs/cli/tutorials/file-management.md +142 -0
  55. package/bundle/docs/cli/tutorials/mcp-setup.md +113 -0
  56. package/bundle/docs/cli/tutorials/memory-management.md +126 -0
  57. package/bundle/docs/cli/tutorials/session-management.md +105 -0
  58. package/bundle/docs/cli/tutorials/shell-commands.md +107 -0
  59. package/bundle/docs/cli/tutorials/skills-getting-started.md +110 -0
  60. package/bundle/docs/cli/tutorials/task-planning.md +93 -0
  61. package/bundle/docs/cli/tutorials/web-tools.md +78 -0
  62. package/bundle/docs/core/index.md +107 -0
  63. package/bundle/docs/core/remote-agents.md +84 -0
  64. package/bundle/docs/core/subagents.md +307 -0
  65. package/bundle/docs/examples/proxy-script.md +83 -0
  66. package/bundle/docs/extensions/best-practices.md +188 -0
  67. package/bundle/docs/extensions/index.md +61 -0
  68. package/bundle/docs/extensions/reference.md +333 -0
  69. package/bundle/docs/extensions/releasing.md +154 -0
  70. package/bundle/docs/extensions/writing-extensions.md +308 -0
  71. package/bundle/docs/get-started/authentication.md +402 -0
  72. package/bundle/docs/get-started/examples.md +139 -0
  73. package/bundle/docs/get-started/gemini-3.md +115 -0
  74. package/bundle/docs/get-started/index.md +82 -0
  75. package/bundle/docs/get-started/installation.md +174 -0
  76. package/bundle/docs/hooks/best-practices.md +709 -0
  77. package/bundle/docs/hooks/index.md +164 -0
  78. package/bundle/docs/hooks/reference.md +330 -0
  79. package/bundle/docs/hooks/writing-hooks.md +474 -0
  80. package/bundle/docs/ide-integration/ide-companion-spec.md +267 -0
  81. package/bundle/docs/ide-integration/index.md +224 -0
  82. package/bundle/docs/index.md +141 -0
  83. package/bundle/docs/integration-tests.md +211 -0
  84. package/bundle/docs/issue-and-pr-automation.md +172 -0
  85. package/bundle/docs/local-development.md +134 -0
  86. package/bundle/docs/mermaid/context.mmd +103 -0
  87. package/bundle/docs/mermaid/render-path.mmd +64 -0
  88. package/bundle/docs/npm.md +62 -0
  89. package/bundle/docs/redirects.json +20 -0
  90. package/bundle/docs/reference/commands.md +526 -0
  91. package/bundle/docs/reference/configuration.md +1786 -0
  92. package/bundle/docs/reference/keyboard-shortcuts.md +164 -0
  93. package/bundle/docs/reference/memport.md +246 -0
  94. package/bundle/docs/reference/policy-engine.md +364 -0
  95. package/bundle/docs/reference/tools.md +106 -0
  96. package/bundle/docs/release-confidence.md +164 -0
  97. package/bundle/docs/releases.md +540 -0
  98. package/bundle/docs/resources/faq.md +175 -0
  99. package/bundle/docs/resources/quota-and-pricing.md +165 -0
  100. package/bundle/docs/resources/tos-privacy.md +102 -0
  101. package/bundle/docs/resources/troubleshooting.md +176 -0
  102. package/bundle/docs/resources/uninstall.md +56 -0
  103. package/bundle/docs/sidebar.json +233 -0
  104. package/bundle/docs/tools/activate-skill.md +43 -0
  105. package/bundle/docs/tools/ask-user.md +95 -0
  106. package/bundle/docs/tools/file-system.md +129 -0
  107. package/bundle/docs/tools/internal-docs.md +46 -0
  108. package/bundle/docs/tools/mcp-server.md +1150 -0
  109. package/bundle/docs/tools/memory.md +35 -0
  110. package/bundle/docs/tools/planning.md +58 -0
  111. package/bundle/docs/tools/shell.md +216 -0
  112. package/bundle/docs/tools/todos.md +35 -0
  113. package/bundle/docs/tools/web-fetch.md +35 -0
  114. package/bundle/docs/tools/web-search.md +32 -0
  115. package/bundle/docs/update/update-guide.md +111 -0
  116. package/bundle/masha.js +563471 -0
  117. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/client/main.js +89 -0
  118. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.d.ts +7 -0
  119. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.js +9 -0
  120. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.js.map +1 -0
  121. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.d.ts +48 -0
  122. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.js +299 -0
  123. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.js.map +1 -0
  124. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.d.ts +36 -0
  125. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.js +7 -0
  126. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.js.map +1 -0
  127. package/bundle/node_modules/@dgxo/mashadevcli-devtools/package.json +32 -0
  128. package/bundle/policies/conseca.toml +6 -0
  129. package/bundle/policies/discovered.toml +8 -0
  130. package/bundle/policies/plan.toml +109 -0
  131. package/bundle/policies/read-only.toml +53 -0
  132. package/bundle/policies/write.toml +80 -0
  133. package/bundle/policies/yolo.toml +54 -0
  134. package/bundle/sandbox-macos-permissive-open.sb +27 -0
  135. package/bundle/sandbox-macos-permissive-proxied.sb +37 -0
  136. package/bundle/sandbox-macos-restrictive-open.sb +96 -0
  137. package/bundle/sandbox-macos-restrictive-proxied.sb +98 -0
  138. package/bundle/sandbox-macos-strict-open.sb +131 -0
  139. package/bundle/sandbox-macos-strict-proxied.sb +133 -0
  140. package/package.json +169 -0
@@ -0,0 +1,269 @@
1
+ # Themes
2
+
3
+ Gemini CLI supports a variety of themes to customize its color scheme and
4
+ appearance. You can change the theme to suit your preferences via the `/theme`
5
+ command or `"theme":` configuration setting.
6
+
7
+ ## Available themes
8
+
9
+ Gemini CLI comes with a selection of pre-defined themes, which you can list
10
+ using the `/theme` command within Gemini CLI:
11
+
12
+ - **Dark themes:**
13
+ - `ANSI`
14
+ - `Atom One`
15
+ - `Ayu`
16
+ - `Default`
17
+ - `Dracula`
18
+ - `GitHub`
19
+ - `Solarized Dark`
20
+ - **Light themes:**
21
+ - `ANSI Light`
22
+ - `Ayu Light`
23
+ - `Default Light`
24
+ - `GitHub Light`
25
+ - `Google Code`
26
+ - `Solarized Light`
27
+ - `Xcode`
28
+
29
+ ### Changing themes
30
+
31
+ 1. Enter `/theme` into Gemini CLI.
32
+ 2. A dialog or selection prompt appears, listing the available themes.
33
+ 3. Using the arrow keys, select a theme. Some interfaces might offer a live
34
+ preview or highlight as you select.
35
+ 4. Confirm your selection to apply the theme.
36
+
37
+ **Note:** If a theme is defined in your `settings.json` file (either by name or
38
+ by a file path), you must remove the `"theme"` setting from the file before you
39
+ can change the theme using the `/theme` command.
40
+
41
+ ### Theme persistence
42
+
43
+ Selected themes are saved in Gemini CLI's
44
+ [configuration](../reference/configuration.md) so your preference is remembered
45
+ across sessions.
46
+
47
+ ---
48
+
49
+ ## Custom color themes
50
+
51
+ Gemini CLI lets you create your own custom color themes by specifying them in
52
+ your `settings.json` file. This gives you full control over the color palette
53
+ used in the CLI.
54
+
55
+ ### How to define a custom theme
56
+
57
+ Add a `customThemes` block to your user, project, or system `settings.json`
58
+ file. Each custom theme is defined as an object with a unique name and a set of
59
+ nested configuration objects. For example:
60
+
61
+ ```json
62
+ {
63
+ "ui": {
64
+ "customThemes": {
65
+ "MyCustomTheme": {
66
+ "name": "MyCustomTheme",
67
+ "type": "custom",
68
+ "background": {
69
+ "primary": "#181818"
70
+ },
71
+ "text": {
72
+ "primary": "#f0f0f0",
73
+ "secondary": "#a0a0a0"
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ **Configuration objects:**
82
+
83
+ - **`text`**: Defines text colors.
84
+ - `primary`: The default text color.
85
+ - `secondary`: Used for less prominent text.
86
+ - `link`: Color for URLs and links.
87
+ - `accent`: Used for highlights and emphasis.
88
+ - `response`: Precedence over `primary` for rendering model responses.
89
+ - **`background`**: Defines background colors.
90
+ - `primary`: The main background color of the UI.
91
+ - `diff.added`: Background for added lines in diffs.
92
+ - `diff.removed`: Background for removed lines in diffs.
93
+ - **`border`**: Defines border colors.
94
+ - `default`: The standard border color.
95
+ - `focused`: Border color when an element is focused.
96
+ - **`status`**: Colors for status indicators.
97
+ - `success`: Used for successful operations.
98
+ - `warning`: Used for warnings.
99
+ - `error`: Used for errors.
100
+ - **`ui`**: Other UI elements.
101
+ - `comment`: Color for code comments.
102
+ - `symbol`: Color for code symbols and operators.
103
+ - `gradient`: An array of colors used for gradient effects.
104
+
105
+ **Required properties:**
106
+
107
+ - `name` (must match the key in the `customThemes` object and be a string)
108
+ - `type` (must be the string `"custom"`)
109
+
110
+ While all sub-properties are technically optional, we recommend providing at
111
+ least `background.primary`, `text.primary`, `text.secondary`, and the various
112
+ accent colors via `text.link`, `text.accent`, and `status` to ensure a cohesive
113
+ UI.
114
+
115
+ You can use either hex codes (e.g., `#FF0000`) **or** standard CSS color names
116
+ (e.g., `coral`, `teal`, `blue`) for any color value. See
117
+ [CSS color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#color_keywords)
118
+ for a full list of supported names.
119
+
120
+ You can define multiple custom themes by adding more entries to the
121
+ `customThemes` object.
122
+
123
+ ### Loading themes from a file
124
+
125
+ In addition to defining custom themes in `settings.json`, you can also load a
126
+ theme directly from a JSON file by specifying the file path in your
127
+ `settings.json`. This is useful for sharing themes or keeping them separate from
128
+ your main configuration.
129
+
130
+ To load a theme from a file, set the `theme` property in your `settings.json` to
131
+ the path of your theme file:
132
+
133
+ ```json
134
+ {
135
+ "ui": {
136
+ "theme": "/path/to/your/theme.json"
137
+ }
138
+ }
139
+ ```
140
+
141
+ The theme file must be a valid JSON file that follows the same structure as a
142
+ custom theme defined in `settings.json`.
143
+
144
+ **Example `my-theme.json`:**
145
+
146
+ ```json
147
+ {
148
+ "name": "Gruvbox Dark",
149
+ "type": "custom",
150
+ "background": {
151
+ "primary": "#282828",
152
+ "diff": {
153
+ "added": "#2b3312",
154
+ "removed": "#341212"
155
+ }
156
+ },
157
+ "text": {
158
+ "primary": "#ebdbb2",
159
+ "secondary": "#a89984",
160
+ "link": "#83a598",
161
+ "accent": "#d3869b"
162
+ },
163
+ "border": {
164
+ "default": "#3c3836",
165
+ "focused": "#458588"
166
+ },
167
+ "status": {
168
+ "success": "#b8bb26",
169
+ "warning": "#fabd2f",
170
+ "error": "#fb4934"
171
+ },
172
+ "ui": {
173
+ "comment": "#928374",
174
+ "symbol": "#8ec07c",
175
+ "gradient": ["#cc241d", "#d65d0e", "#d79921"]
176
+ }
177
+ }
178
+ ```
179
+
180
+ **Security note:** For your safety, Gemini CLI will only load theme files that
181
+ are located within your home directory. If you attempt to load a theme from
182
+ outside your home directory, a warning will be displayed and the theme will not
183
+ be loaded. This is to prevent loading potentially malicious theme files from
184
+ untrusted sources.
185
+
186
+ ### Example custom theme
187
+
188
+ <img src="../assets/theme-custom.png" alt="Custom theme example" width="600" />
189
+
190
+ ### Using your custom theme
191
+
192
+ - Select your custom theme using the `/theme` command in Gemini CLI. Your custom
193
+ theme will appear in the theme selection dialog.
194
+ - Or, set it as the default by adding `"theme": "MyCustomTheme"` to the `ui`
195
+ object in your `settings.json`.
196
+ - Custom themes can be set at the user, project, or system level, and follow the
197
+ same [configuration precedence](../reference/configuration.md) as other
198
+ settings.
199
+
200
+ ### Themes from extensions
201
+
202
+ [Extensions](../extensions/reference.md#themes) can also provide custom themes.
203
+ Once an extension is installed and enabled, its themes are automatically added
204
+ to the selection list in the `/theme` command.
205
+
206
+ Themes from extensions appear with the extension name in parentheses to help you
207
+ identify their source, for example: `shades-of-green (green-extension)`.
208
+
209
+ ---
210
+
211
+ ## Dark themes
212
+
213
+ ### ANSI
214
+
215
+ <img src="/assets/theme-ansi.png" alt="ANSI theme" width="600" />
216
+
217
+ ### Atom OneDark
218
+
219
+ <img src="/assets/theme-atom-one.png" alt="Atom One theme" width="600">
220
+
221
+ ### Ayu
222
+
223
+ <img src="/assets/theme-ayu.png" alt="Ayu theme" width="600">
224
+
225
+ ### Default
226
+
227
+ <img src="/assets/theme-default.png" alt="Default theme" width="600">
228
+
229
+ ### Dracula
230
+
231
+ <img src="/assets/theme-dracula.png" alt="Dracula theme" width="600">
232
+
233
+ ### GitHub
234
+
235
+ <img src="/assets/theme-github.png" alt="GitHub theme" width="600">
236
+
237
+ ### Solarized Dark
238
+
239
+ <img src="/assets/theme-solarized-dark.png" alt="Solarized Dark theme" width="600">
240
+
241
+ ## Light themes
242
+
243
+ ### ANSI Light
244
+
245
+ <img src="/assets/theme-ansi-light.png" alt="ANSI Light theme" width="600">
246
+
247
+ ### Ayu Light
248
+
249
+ <img src="/assets/theme-ayu-light.png" alt="Ayu Light theme" width="600">
250
+
251
+ ### Default Light
252
+
253
+ <img src="/assets/theme-default-light.png" alt="Default Light theme" width="600">
254
+
255
+ ### GitHub Light
256
+
257
+ <img src="/assets/theme-github-light.png" alt="GitHub Light theme" width="600">
258
+
259
+ ### Google Code
260
+
261
+ <img src="/assets/theme-google-light.png" alt="Google Code theme" width="600">
262
+
263
+ ### Solarized Light
264
+
265
+ <img src="/assets/theme-solarized-light.png" alt="Solarized Light theme" width="600">
266
+
267
+ ### Xcode
268
+
269
+ <img src="/assets/theme-xcode-light.png" alt="Xcode Light theme" width="600">
@@ -0,0 +1,20 @@
1
+ # Token caching and cost optimization
2
+
3
+ Gemini CLI automatically optimizes API costs through token caching when using
4
+ API key authentication (Gemini API key or Vertex AI). This feature reuses
5
+ previous system instructions and context to reduce the number of tokens
6
+ processed in subsequent requests.
7
+
8
+ **Token caching is available for:**
9
+
10
+ - API key users (Gemini API key)
11
+ - Vertex AI users (with project and location setup)
12
+
13
+ **Token caching is not available for:**
14
+
15
+ - OAuth users (Google Personal/Enterprise accounts) - the Code Assist API does
16
+ not support cached content creation at this time
17
+
18
+ You can view your token usage and cached token savings using the `/stats`
19
+ command. When cached tokens are available, they will be displayed in the stats
20
+ output.
@@ -0,0 +1,126 @@
1
+ # Trusted Folders
2
+
3
+ The Trusted Folders feature is a security setting that gives you control over
4
+ which projects can use the full capabilities of the Gemini CLI. It prevents
5
+ potentially malicious code from running by asking you to approve a folder before
6
+ the CLI loads any project-specific configurations from it.
7
+
8
+ ## Enabling the feature
9
+
10
+ The Trusted Folders feature is **disabled by default**. To use it, you must
11
+ first enable it in your settings.
12
+
13
+ Add the following to your user `settings.json` file:
14
+
15
+ ```json
16
+ {
17
+ "security": {
18
+ "folderTrust": {
19
+ "enabled": true
20
+ }
21
+ }
22
+ }
23
+ ```
24
+
25
+ ## How it works: The trust dialog
26
+
27
+ Once the feature is enabled, the first time you run the Gemini CLI from a
28
+ folder, a dialog will automatically appear, prompting you to make a choice:
29
+
30
+ - **Trust folder**: Grants full trust to the current folder (e.g.,
31
+ `my-project`).
32
+ - **Trust parent folder**: Grants trust to the parent directory (e.g.,
33
+ `safe-projects`), which automatically trusts all of its subdirectories as
34
+ well. This is useful if you keep all your safe projects in one place.
35
+ - **Don't trust**: Marks the folder as untrusted. The CLI will operate in a
36
+ restricted "safe mode."
37
+
38
+ Your choice is saved in a central file (`~/.gemini/trustedFolders.json`), so you
39
+ will only be asked once per folder.
40
+
41
+ ## Understanding folder contents: The discovery phase
42
+
43
+ Before you make a choice, the Gemini CLI performs a **discovery phase** to scan
44
+ the folder for potential configurations. This information is displayed in the
45
+ trust dialog to help you make an informed decision.
46
+
47
+ The discovery UI lists the following categories of items found in the project:
48
+
49
+ - **Commands**: Custom `.toml` command definitions that add new functionality.
50
+ - **MCP Servers**: Configured Model Context Protocol servers that the CLI will
51
+ attempt to connect to.
52
+ - **Hooks**: System or custom hooks that can intercept and modify CLI behavior.
53
+ - **Skills**: Local agent skills that provide specialized capabilities.
54
+ - **Setting overrides**: Any project-specific configurations that override your
55
+ global user settings.
56
+
57
+ ### Security warnings and errors
58
+
59
+ The trust dialog also highlights critical information that requires your
60
+ attention:
61
+
62
+ - **Security Warnings**: The CLI will explicitly flag potentially dangerous
63
+ settings, such as auto-approving certain tools or disabling the security
64
+ sandbox.
65
+ - **Discovery Errors**: If the CLI encounters issues while scanning the folder
66
+ (e.g., a malformed `settings.json` file), these errors will be displayed
67
+ prominently.
68
+
69
+ By reviewing these details, you can ensure that you only grant trust to projects
70
+ that you know are safe.
71
+
72
+ ## Why trust matters: The impact of an untrusted workspace
73
+
74
+ When a folder is **untrusted**, the Gemini CLI runs in a restricted "safe mode"
75
+ to protect you. In this mode, the following features are disabled:
76
+
77
+ 1. **Workspace settings are ignored**: The CLI will **not** load the
78
+ `.gemini/settings.json` file from the project. This prevents the loading of
79
+ custom tools and other potentially dangerous configurations.
80
+
81
+ 2. **Environment variables are ignored**: The CLI will **not** load any `.env`
82
+ files from the project.
83
+
84
+ 3. **Extension management is restricted**: You **cannot install, update, or
85
+ uninstall** extensions.
86
+
87
+ 4. **Tool auto-acceptance is disabled**: You will always be prompted before any
88
+ tool is run, even if you have auto-acceptance enabled globally.
89
+
90
+ 5. **Automatic memory loading is disabled**: The CLI will not automatically
91
+ load files into context from directories specified in local settings.
92
+
93
+ 6. **MCP servers do not connect**: The CLI will not attempt to connect to any
94
+ [Model Context Protocol (MCP)](../tools/mcp-server.md) servers.
95
+
96
+ 7. **Custom commands are not loaded**: The CLI will not load any custom
97
+ commands from .toml files, including both project-specific and global user
98
+ commands.
99
+
100
+ Granting trust to a folder unlocks the full functionality of the Gemini CLI for
101
+ that workspace.
102
+
103
+ ## Managing your trust settings
104
+
105
+ If you need to change a decision or see all your settings, you have a couple of
106
+ options:
107
+
108
+ - **Change the current folder's trust**: Run the `/permissions` command from
109
+ within the CLI. This will bring up the same interactive dialog, allowing you
110
+ to change the trust level for the current folder.
111
+
112
+ - **View all trust rules**: To see a complete list of all your trusted and
113
+ untrusted folder rules, you can inspect the contents of the
114
+ `~/.gemini/trustedFolders.json` file in your home directory.
115
+
116
+ ## The trust check process (advanced)
117
+
118
+ For advanced users, it's helpful to know the exact order of operations for how
119
+ trust is determined:
120
+
121
+ 1. **IDE trust signal**: If you are using the
122
+ [IDE Integration](../ide-integration/index.md), the CLI first asks the IDE
123
+ if the workspace is trusted. The IDE's response takes highest priority.
124
+
125
+ 2. **Local trust file**: If the IDE is not connected, the CLI checks the
126
+ central `~/.gemini/trustedFolders.json` file.
@@ -0,0 +1,283 @@
1
+ # Automate tasks with headless mode
2
+
3
+ Automate tasks with Gemini CLI. Learn how to use headless mode, pipe data into
4
+ Gemini CLI, automate workflows with shell scripts, and generate structured JSON
5
+ output for other applications.
6
+
7
+ ## Prerequisites
8
+
9
+ - Gemini CLI installed and authenticated.
10
+ - Familiarity with shell scripting (Bash/Zsh).
11
+
12
+ ## Why headless mode?
13
+
14
+ Headless mode runs Gemini CLI once and exits. It's perfect for:
15
+
16
+ - **CI/CD:** Analyzing pull requests automatically.
17
+ - **Batch processing:** Summarizing a large number of log files.
18
+ - **Tool building:** Creating your own "AI wrapper" scripts.
19
+
20
+ ## How to use headless mode
21
+
22
+ Run Gemini CLI in headless mode by providing a prompt as a positional argument.
23
+ This bypasses the interactive chat interface and prints the response to standard
24
+ output (stdout).
25
+
26
+ Run a single command:
27
+
28
+ ```bash
29
+ gemini "Write a poem about TypeScript"
30
+ ```
31
+
32
+ ## How to pipe input to Gemini CLI
33
+
34
+ Feed data into Gemini using the standard Unix pipe `|`. Gemini reads the
35
+ standard input (stdin) as context and answers your question using standard
36
+ output.
37
+
38
+ Pipe a file:
39
+
40
+ **macOS/Linux**
41
+
42
+ ```bash
43
+ cat error.log | gemini "Explain why this failed"
44
+ ```
45
+
46
+ **Windows (PowerShell)**
47
+
48
+ ```powershell
49
+ Get-Content error.log | gemini "Explain why this failed"
50
+ ```
51
+
52
+ Pipe a command:
53
+
54
+ ```bash
55
+ git diff | gemini "Write a commit message for these changes"
56
+ ```
57
+
58
+ ## Use Gemini CLI output in scripts
59
+
60
+ Because Gemini prints to stdout, you can chain it with other tools or save the
61
+ results to a file.
62
+
63
+ ### Scenario: Bulk documentation generator
64
+
65
+ You have a folder of Python scripts and want to generate a `README.md` for each
66
+ one.
67
+
68
+ 1. Save the following code as `generate_docs.sh` (or `generate_docs.ps1` for
69
+ Windows):
70
+
71
+ **macOS/Linux (`generate_docs.sh`)**
72
+
73
+ ```bash
74
+ #!/bin/bash
75
+
76
+ # Loop through all Python files
77
+ for file in *.py; do
78
+ echo "Generating docs for $file..."
79
+
80
+ # Ask Gemini CLI to generate the documentation and print it to stdout
81
+ gemini "Generate a Markdown documentation summary for @$file. Print the
82
+ result to standard output." > "${file%.py}.md"
83
+ done
84
+ ```
85
+
86
+ **Windows PowerShell (`generate_docs.ps1`)**
87
+
88
+ ```powershell
89
+ # Loop through all Python files
90
+ Get-ChildItem -Filter *.py | ForEach-Object {
91
+ Write-Host "Generating docs for $($_.Name)..."
92
+
93
+ $newName = $_.Name -replace '\.py$', '.md'
94
+ # Ask Gemini CLI to generate the documentation and print it to stdout
95
+ gemini "Generate a Markdown documentation summary for @$($_.Name). Print the result to standard output." | Out-File -FilePath $newName -Encoding utf8
96
+ }
97
+ ```
98
+
99
+ 2. Make the script executable and run it in your directory:
100
+
101
+ **macOS/Linux**
102
+
103
+ ```bash
104
+ chmod +x generate_docs.sh
105
+ ./generate_docs.sh
106
+ ```
107
+
108
+ **Windows (PowerShell)**
109
+
110
+ ```powershell
111
+ .\generate_docs.ps1
112
+ ```
113
+
114
+ This creates a corresponding Markdown file for every Python file in the
115
+ folder.
116
+
117
+ ## Extract structured JSON data
118
+
119
+ When writing a script, you often need structured data (JSON) to pass to tools
120
+ like `jq`. To get pure JSON data from the model, combine the
121
+ `--output-format json` flag with `jq` to parse the response field.
122
+
123
+ ### Scenario: Extract and return structured data
124
+
125
+ 1. Save the following script as `generate_json.sh` (or `generate_json.ps1` for
126
+ Windows):
127
+
128
+ **macOS/Linux (`generate_json.sh`)**
129
+
130
+ ```bash
131
+ #!/bin/bash
132
+
133
+ # Ensure we are in a project root
134
+ if [ ! -f "package.json" ]; then
135
+ echo "Error: package.json not found."
136
+ exit 1
137
+ fi
138
+
139
+ # Extract data
140
+ gemini --output-format json "Return a raw JSON object with keys 'version' and 'deps' from @package.json" | jq -r '.response' > data.json
141
+ ```
142
+
143
+ **Windows PowerShell (`generate_json.ps1`)**
144
+
145
+ ```powershell
146
+ # Ensure we are in a project root
147
+ if (-not (Test-Path "package.json")) {
148
+ Write-Error "Error: package.json not found."
149
+ exit 1
150
+ }
151
+
152
+ # Extract data (requires jq installed, or you can use ConvertFrom-Json)
153
+ $output = gemini --output-format json "Return a raw JSON object with keys 'version' and 'deps' from @package.json" | ConvertFrom-Json
154
+ $output.response | Out-File -FilePath data.json -Encoding utf8
155
+ ```
156
+
157
+ 2. Run the script:
158
+
159
+ **macOS/Linux**
160
+
161
+ ```bash
162
+ chmod +x generate_json.sh
163
+ ./generate_json.sh
164
+ ```
165
+
166
+ **Windows (PowerShell)**
167
+
168
+ ```powershell
169
+ .\generate_json.ps1
170
+ ```
171
+
172
+ 3. Check `data.json`. The file should look like this:
173
+
174
+ ```json
175
+ {
176
+ "version": "1.0.0",
177
+ "deps": {
178
+ "react": "^18.2.0"
179
+ }
180
+ }
181
+ ```
182
+
183
+ ## Build your own custom AI tools
184
+
185
+ Use headless mode to perform custom, automated AI tasks.
186
+
187
+ ### Scenario: Create a "Smart Commit" alias
188
+
189
+ You can add a function to your shell configuration to create a `git commit`
190
+ wrapper that writes the message for you.
191
+
192
+ **macOS/Linux (Bash/Zsh)**
193
+
194
+ 1. Open your `.zshrc` file (or `.bashrc` if you use Bash) in your preferred
195
+ text editor.
196
+
197
+ ```bash
198
+ nano ~/.zshrc
199
+ ```
200
+
201
+ **Note**: If you use VS Code, you can run `code ~/.zshrc`.
202
+
203
+ 2. Scroll to the very bottom of the file and paste this code:
204
+
205
+ ```bash
206
+ function gcommit() {
207
+ # Get the diff of staged changes
208
+ diff=$(git diff --staged)
209
+
210
+ if [ -z "$diff" ]; then
211
+ echo "No staged changes to commit."
212
+ return 1
213
+ fi
214
+
215
+ # Ask Gemini to write the message
216
+ echo "Generating commit message..."
217
+ msg=$(echo "$diff" | gemini "Write a concise Conventional Commit message for this diff. Output ONLY the message.")
218
+
219
+ # Commit with the generated message
220
+ git commit -m "$msg"
221
+ }
222
+ ```
223
+
224
+ Save your file and exit.
225
+
226
+ 3. Run this command to make the function available immediately:
227
+
228
+ ```bash
229
+ source ~/.zshrc
230
+ ```
231
+
232
+ **Windows (PowerShell)**
233
+
234
+ 1. Open your PowerShell profile in your preferred text editor.
235
+
236
+ ```powershell
237
+ notepad $PROFILE
238
+ ```
239
+
240
+ 2. Scroll to the very bottom of the file and paste this code:
241
+
242
+ ```powershell
243
+ function gcommit {
244
+ # Get the diff of staged changes
245
+ $diff = git diff --staged
246
+
247
+ if (-not $diff) {
248
+ Write-Host "No staged changes to commit."
249
+ return
250
+ }
251
+
252
+ # Ask Gemini to write the message
253
+ Write-Host "Generating commit message..."
254
+ $msg = $diff | gemini "Write a concise Conventional Commit message for this diff. Output ONLY the message."
255
+
256
+ # Commit with the generated message
257
+ git commit -m "$msg"
258
+ }
259
+ ```
260
+
261
+ Save your file and exit.
262
+
263
+ 3. Run this command to make the function available immediately:
264
+
265
+ ```powershell
266
+ . $PROFILE
267
+ ```
268
+
269
+ 4. Use your new command:
270
+
271
+ ```bash
272
+ gcommit
273
+ ```
274
+
275
+ Gemini CLI will analyze your staged changes and commit them with a generated
276
+ message.
277
+
278
+ ## Next steps
279
+
280
+ - Explore the [Headless mode reference](../../cli/headless.md) for full JSON
281
+ schema details.
282
+ - Learn about [Shell commands](shell-commands.md) to let the agent run scripts
283
+ instead of just writing them.