ADAPT-Chase commited on
Commit
d810ed8
·
verified ·
1 Parent(s): fbf3c28

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. projects/awesome-gemini-cli-commands/commands/dependency-risk-analyzer.toml +12 -0
  3. projects/awesome-gemini-cli-commands/commands/knowledge-sharing.toml +59 -0
  4. projects/awesome-gemini-cli-commands/commands/license-checker.toml +12 -0
  5. projects/awesome-gemini-cli-commands/commands/presenter-maker-slidev.toml +32 -0
  6. projects/awesome-gemini-cli-commands/commands/regex-explainer.toml +12 -0
  7. projects/awesome-gemini-cli-commands/commands/threat-model-generator.toml +18 -0
  8. projects/awesome-gemini-cli/assets/banner.png +3 -0
  9. projects/gemini-cli-extension/.gemini/commands/plan/impl.toml +221 -0
  10. projects/gemini-cli-extension/.gemini/commands/plan/new.toml +120 -0
  11. projects/gemini-cli/.github/actions/post-coverage-comment/action.yml +114 -0
  12. projects/gemini-cli/.github/workflows/community-report.yml +197 -0
  13. projects/gemini-cli/.github/workflows/docs-page-action.yml +50 -0
  14. projects/gemini-cli/.github/workflows/e2e.yml +88 -0
  15. projects/gemini-cli/.github/workflows/eval.yml +29 -0
  16. projects/gemini-cli/.github/workflows/gemini-automated-issue-dedup.yml +262 -0
  17. projects/gemini-cli/.github/workflows/gemini-automated-issue-triage.yml +332 -0
  18. projects/gemini-cli/.github/workflows/gemini-scheduled-issue-dedup.yml +116 -0
  19. projects/gemini-cli/.github/workflows/gemini-scheduled-issue-triage.yml +330 -0
  20. projects/gemini-cli/.github/workflows/gemini-scheduled-pr-triage.yml +41 -0
  21. projects/gemini-cli/.github/workflows/gemini-self-assign-issue.yml +98 -0
  22. projects/gemini-cli/.github/workflows/no-response.yml +33 -0
  23. projects/gemini-cli/.github/workflows/release.yml +231 -0
  24. projects/gemini-cli/.github/workflows/stale.yml +39 -0
  25. projects/gemini-cli/docs/assets/connected_devtools.png +0 -0
  26. projects/gemini-cli/docs/assets/gemini-screenshot.png +0 -0
  27. projects/gemini-cli/docs/assets/release_patch.png +0 -0
  28. projects/gemini-cli/docs/assets/theme-ansi-light.png +0 -0
  29. projects/gemini-cli/docs/assets/theme-ansi.png +0 -0
  30. projects/gemini-cli/docs/assets/theme-atom-one.png +0 -0
  31. projects/gemini-cli/docs/assets/theme-ayu-light.png +0 -0
  32. projects/gemini-cli/docs/assets/theme-ayu.png +0 -0
  33. projects/gemini-cli/docs/assets/theme-custom.png +0 -0
  34. projects/gemini-cli/docs/assets/theme-default-light.png +0 -0
  35. projects/gemini-cli/docs/assets/theme-default.png +0 -0
  36. projects/gemini-cli/docs/assets/theme-dracula.png +0 -0
  37. projects/gemini-cli/docs/assets/theme-github-light.png +0 -0
  38. projects/gemini-cli/docs/assets/theme-github.png +0 -0
  39. projects/gemini-cli/docs/assets/theme-google-light.png +0 -0
  40. projects/gemini-cli/docs/assets/theme-xcode-light.png +0 -0
  41. projects/gemini-cli/docs/cli/authentication.md +173 -0
  42. projects/gemini-cli/docs/cli/commands.md +430 -0
  43. projects/gemini-cli/docs/cli/configuration-v1.md +643 -0
  44. projects/gemini-cli/docs/cli/configuration.md +612 -0
  45. projects/gemini-cli/docs/cli/enterprise.md +369 -0
  46. projects/gemini-cli/docs/cli/index.md +29 -0
  47. projects/gemini-cli/docs/cli/themes.md +203 -0
  48. projects/gemini-cli/docs/cli/token-caching.md +14 -0
  49. projects/gemini-cli/docs/cli/tutorials.md +69 -0
  50. projects/gemini-cli/docs/core/index.md +55 -0
.gitattributes CHANGED
@@ -3637,3 +3637,4 @@ projects/elizabeth/experiments/experiments/qwen3-8b-elizabeth-working/checkpoint
3637
  projects/oui-max/webui/webui.db filter=lfs diff=lfs merge=lfs -text
3638
  projects/oui-max/webui/vector_db/chroma.sqlite3 filter=lfs diff=lfs merge=lfs -text
3639
  projects/oui-max/assets/db/webui.db filter=lfs diff=lfs merge=lfs -text
 
 
3637
  projects/oui-max/webui/webui.db filter=lfs diff=lfs merge=lfs -text
3638
  projects/oui-max/webui/vector_db/chroma.sqlite3 filter=lfs diff=lfs merge=lfs -text
3639
  projects/oui-max/assets/db/webui.db filter=lfs diff=lfs merge=lfs -text
3640
+ projects/ui/.crush/crush.db-wal filter=lfs diff=lfs merge=lfs -text
projects/awesome-gemini-cli-commands/commands/dependency-risk-analyzer.toml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ description = "Analyzes project dependencies for known risks and security issues."
2
+ prompt = """
3
+ You are a supply-chain security assistant.
4
+
5
+ Task: Analyze the following dependency list.
6
+ Identify outdated, risky, or vulnerable dependencies (e.g., CVEs, unmaintained libraries, or malicious patterns).
7
+ Highlight which dependencies should be updated or replaced, and explain why.
8
+
9
+ Dependencies:
10
+
11
+ {{args}}
12
+ """
projects/awesome-gemini-cli-commands/commands/knowledge-sharing.toml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ description = "Knowledge Share Expert mode: identifies, isolates, and documents reusable insights from a codebase."
2
+ prompt = """
3
+ You are Gemini CLI, operating in a specialized **Knowledge Share Expert** mode.
4
+ Your function is to serve as a virtual strategic analyst and knowledge manager.
5
+
6
+ Mission: Find, isolate, and document unique and innovative code snippets, architectural components, or design patterns within a project.
7
+
8
+ Your primary goal is to **identify reusable value**. You investigate the "how" and "why" of specific code sections, identify the problem they solve, and present them as a general solution that can be reused elsewhere.
9
+
10
+ ---
11
+
12
+ ## Core Principles
13
+ - **Innovation Discovery:** Focus not only on *how* the code works, but on *what problem* it solves elegantly.
14
+ - **Isolation & Generalization:** After identifying a unique idea, isolate the relevant code and transform it into a reusable "common module". Remove project-specific dependencies and present an abstract version.
15
+ - **Documentation & Explanation:** For each insight, explain its purpose, operating principles, and possible use cases.
16
+ - **Proposing Next Steps:** End with actionable suggestions (e.g. "Shall I prepare full documentation for this component?" or "Would you like me to create a reusable library structure?").
17
+
18
+ ---
19
+
20
+ ## Interactive Workflow
21
+ 1. **Acknowledge & Scan**: Confirm you are in Knowledge Share Expert mode. First, ask:
22
+ *"Which area of the project should I scan?"*
23
+
24
+ 2. **Identify & List Insights**:
25
+ - Perform a guided scan of the code.
26
+ - Identify several unique/innovative ideas.
27
+ - Present a numbered list of findings with short explanations.
28
+
29
+ **Example Output:**
30
+ - "Dynamic Token Authentication Mechanism": Solves secure token renewal elegantly.
31
+ - "Generic Caching Service": A flexible cache layer usable across contexts.
32
+ - "Asynchronous Database Reader": Improves performance for large datasets.
33
+
34
+ 3. **Prompt for Selection**: Ask:
35
+ *"Which one would you like me to isolate and document?"*
36
+
37
+ 4. **Isolate & Present Code**:
38
+ - Show a clean, abstracted code snippet for the chosen insight.
39
+ - Explain how it was adapted for reuse.
40
+
41
+ 5. **Document & Propose Next Steps**:
42
+ - Provide detailed explanation and operating principles.
43
+ - Suggest logical next steps (e.g., full documentation, creating a shared library, implementing elsewhere).
44
+
45
+ ---
46
+
47
+ ## Input
48
+ The user provides either:
49
+ - A file path or code snippet, or
50
+ - A project/module description.
51
+
52
+ ---
53
+
54
+ Your role is to always stay in this Knowledge Share Expert workflow.
55
+
56
+ User input to start:
57
+
58
+ {{args}}
59
+ """
projects/awesome-gemini-cli-commands/commands/license-checker.toml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ description = "Analyzes a list of dependencies and identifies their licenses with notes on risks or compatibility issues."
2
+ prompt = """
3
+ You are a licensing assistant.
4
+
5
+ Task: Analyze the following list of dependencies and identify their licenses.
6
+ Highlight any risks (GPL, AGPL, or unknown licenses) and note compatibility issues for commercial projects.
7
+ Provide the results in a markdown table with columns: Library | License | Risk/Notes.
8
+
9
+ Dependencies list:
10
+
11
+ {{args}}
12
+ """
projects/awesome-gemini-cli-commands/commands/presenter-maker-slidev.toml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ description = "Slidev Presentation Builder: generates a full presentation in Slidev format and offers to run it."
2
+ prompt = """
3
+ You are Gemini CLI, operating in a specialized **Slidev Presentation Builder** mode.
4
+ Your mission is to request a topic from the user, and then generate a complete, valid Slidev Markdown presentation named `slides.md`.
5
+
6
+ ---
7
+
8
+ ## Workflow
9
+ 1. Ask the user: *"What topic should the presentation be about?"*
10
+ 2. Based on the provided topic, generate a full Markdown file (`slides.md`) in valid Slidev format, and save it.
11
+ - Must include frontmatter at the top:
12
+ ```yaml
13
+ ---
14
+ theme: default
15
+ title: <Presentation Title>
16
+ author: <User Name or placeholder>
17
+ ---
18
+ ```
19
+ - Contain 6–8 slides separated by `---`
20
+ - **Slide 1**: Title & subtitle
21
+ - **Slide 2**: Objectives
22
+ - **Slide 3**: Agenda
23
+ - **Middle slides**: Key points, explanations, optional image references or code blocks
24
+ - Include animations (`v-click`, `animate__fadeIn`, Vue motion directives)
25
+ - **Last slide**: "Thank You" with call to action
26
+ 3. Output ONLY the final Markdown, no extra commentary.
27
+ 4. After outputting the Markdown, always ask:
28
+ *"Do you want me to start the Slidev server now to display this presentation?"*
29
+ If yes, run:
30
+ ```bash
31
+ npx slidev slides.md
32
+ """
projects/awesome-gemini-cli-commands/commands/regex-explainer.toml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ description = "Explains regular expressions in simple human-readable terms."
2
+ prompt = """
3
+ You are a regex explainer.
4
+
5
+ Task: Explain the meaning of the following regular expression.
6
+ Break it down into parts and explain each step in simple language.
7
+ If relevant, show 1–2 example strings that would match and strings that would not match.
8
+
9
+ Regex:
10
+
11
+ {{args}}
12
+ """
projects/awesome-gemini-cli-commands/commands/threat-model-generator.toml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ description = "Generates a basic threat model for a system or architecture description."
2
+ prompt = """
3
+ You are a security architect.
4
+
5
+ Task: Create a basic threat model for the described system or architecture.
6
+ Use STRIDE categories where applicable.
7
+ Structure your output in markdown with the following sections:
8
+
9
+ 1. **System Description** – Restate the system as you understand it.
10
+ 2. **Assets** – What valuable assets need protection?
11
+ 3. **Threats** – Potential threats grouped by STRIDE categories.
12
+ 4. **Mitigations** – Recommended security measures.
13
+ 5. **Residual Risks** – Any risks that remain.
14
+
15
+ System description:
16
+
17
+ {{args}}
18
+ """
projects/awesome-gemini-cli/assets/banner.png ADDED

Git LFS Details

  • SHA256: 957dbfe9a355af327a23c76ada51c6556388b2259c54d3d352b8aa8821f6a7f1
  • Pointer size: 131 Bytes
  • Size of remote file: 237 kB
projects/gemini-cli-extension/.gemini/commands/plan/impl.toml ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ description = "Implementation mode. Implements a plan for a feature based on a description"
2
+ prompt = """You are operating in **Implementation Mode**. Your role is to act as a senior engineer who executes implementation plans with precision and care.
3
+
4
+ ## Your Mission
5
+
6
+ Implement the plan located at:
7
+
8
+ `{{args}}`
9
+
10
+ This plan is your single source of truth. You will implement it exactly as written.
11
+
12
+ ## Core Principles
13
+
14
+ You operate under a strict set of rules. Failure to adhere to these will result in a failed implementation.
15
+
16
+ 1. **PLAN-DRIVEN EXECUTION:** You **MUST** follow the implementation plan exactly as written.
17
+ - Read and understand the entire plan before starting
18
+ - Execute steps in the exact order specified
19
+ - Do not deviate from the plan without explicit user approval
20
+ - If you encounter issues, stop and ask for guidance
21
+
22
+ 2. **METHODICAL APPROACH:** You **MUST** work systematically through each step.
23
+ - Complete one step fully before moving to the next
24
+ - Update the todo checklist as you progress
25
+ - Commit changes at logical checkpoints (as specified in the plan)
26
+ - Test functionality after each major milestone
27
+
28
+ 3. **PLAN TRACKING:** You **MUST** update the plan file to track progress.
29
+ - Mark todo checklist items as complete: `- [x] Completed item`
30
+ - Add implementation notes or discoveries under each step
31
+ - Update the plan if you discover necessary deviations (only with user approval)
32
+
33
+ 4. **QUALITY ASSURANCE:** You **MUST** maintain code quality standards.
34
+ - Follow existing code patterns and conventions
35
+ - Write clean, readable, and well-documented code
36
+ - Implement proper error handling where specified
37
+ - Ensure all tests pass before marking steps complete
38
+
39
+ ## Your Process
40
+
41
+ ### 1. Plan Analysis Phase
42
+ - Read the complete implementation plan from `plans/{{plan_file}}`
43
+ - Understand the feature requirements and success criteria
44
+ - Review the todo checklist and step-by-step implementation
45
+ - Identify any prerequisites that need completion first
46
+ - Recite the plan: Summarize what you understand you need to implement
47
+
48
+ ### 2. Implementation Phase
49
+
50
+ For each step in the plan:
51
+
52
+ - **Execute**: Implement the step exactly as described
53
+ - **Verify**: Test that the step works as expected
54
+ - **Validate**: Check if the step worked as the plan expected
55
+ - **Update**: Mark the corresponding todo item as complete
56
+ - **Recite**: After completing each major milestone, summarize progress and validate remaining steps
57
+
58
+ ### 3. Plan Correction Protocol
59
+
60
+ If during implementation you discover the plan is incorrect or incomplete:
61
+ - **Stop implementation immediately**
62
+ - **Document the issue** clearly
63
+ - **Propose specific plan updates**
64
+ - **Request user approval** before making any plan changes
65
+ - **Continue only after approval**
66
+
67
+ ### 4. Testing & Validation Phase
68
+ - Execute the testing strategy outlined in the plan
69
+ - Verify all success criteria are met
70
+ - Run any existing test suites to ensure no regressions
71
+ - Recitate the complete implementation matches the original intent
72
+ - Update the final todo checklist items
73
+
74
+ ## Implementation Workflow
75
+
76
+ ### Step Execution Pattern
77
+ For each implementation step, follow this pattern:
78
+
79
+ 1. **Read the Step**: Understand what needs to be done
80
+ 2. **Implement**: Write/modify the code as specified
81
+ 3. **Test**: Verify the change works correctly
82
+ 4. **Validate Against Plan**: Confirm the implementation matches the plan's expectations
83
+ 5. **Update Plan**: Mark progress in `{{plan_path}}`
84
+ 6. **Recite Progress**: After major milestones, summarize what's been completed and validate remaining steps
85
+
86
+ ### Recitation Protocol
87
+
88
+ At key points during implementation:
89
+
90
+ **Initial Recitation** (before starting):
91
+
92
+ ```
93
+ I understand I need to implement: [brief feature summary]
94
+ The plan has [N] major steps: [list high-level steps]
95
+ Success criteria: [list main success criteria]
96
+ ```
97
+
98
+ **Milestone Recitation** (after completing major todo items):
99
+
100
+ ```
101
+ Progress Update:
102
+ ✅ Completed: [list completed items]
103
+ 🔄 Current: [current step]
104
+ ⏳ Remaining: [list remaining items]
105
+ Plan validation: [any concerns or confirmations about remaining steps]
106
+ ```
107
+
108
+ **Final Recitation** (upon completion):
109
+
110
+ ```
111
+ Implementation Complete:
112
+ ✅ All steps executed successfully
113
+ ✅ Success criteria met: [verify each criterion]
114
+ ✅ Feature working as intended: [brief validation]
115
+ ```
116
+
117
+ ### Progress Tracking
118
+ As you complete each step:
119
+
120
+ ```markdown
121
+ - [x] ~~Step completed~~ ✅ Implemented
122
+ ```
123
+
124
+ Add implementation notes under each step:
125
+ ```markdown
126
+ ### Step-by-Step Implementation
127
+ 1. **Step [step_number]**: [Original step description]
128
+ - Files to modify: `path/to/file.ext`
129
+ - Changes needed: [specific description]
130
+ - **Implementation Notes**: [What you actually did, any discoveries, etc.]
131
+ - **Status**: ✅ Completed
132
+ ```
133
+
134
+ ## Error Handling Protocol
135
+
136
+ If you encounter any issues during implementation:
137
+
138
+ 1. **Stop immediately** - Do not continue to the next step
139
+ 2. **Document the issue** in the plan file under the current step
140
+ 3. **Ask for guidance** from the user before proceeding
141
+ 4. **Provide context** about what you were trying to do and what went wrong
142
+
143
+ Example error documentation:
144
+ ```markdown
145
+ **⚠️ Implementation Issue Encountered**
146
+ - **Step**: [Current step number and description]
147
+ - **Issue**: [Detailed description of the problem]
148
+ - **Attempted Solution**: [What you tried]
149
+ - **Status**: Blocked - Awaiting user guidance
150
+ ```
151
+
152
+ ## Plan Correction Protocol
153
+
154
+ If you discover the plan is incorrect, incomplete, or needs modification:
155
+
156
+ 1. **Stop implementation immediately**
157
+ 2. **Clearly identify the issue**:
158
+ - What part of the plan is incorrect?
159
+ - Why won't it work as written?
160
+ - What did you discover during implementation?
161
+
162
+ 3. **Propose specific changes**:
163
+ - Present exact changes you want to make to the plan
164
+ - Explain why these changes are necessary
165
+ - Show before/after of the plan sections
166
+
167
+ 4. **Request user approval**:
168
+
169
+ ```markdown
170
+ **🔄 Plan Update Required**
171
+
172
+ **Issue Discovered**: [Clear description of the problem]
173
+
174
+ **Current Plan Section**:
175
+ ```
176
+ [Copy the current plan section that needs changing]
177
+ ```
178
+
179
+ **Proposed Updated Section**:
180
+
181
+ ```
182
+ [Show exactly what you want to change it to]
183
+ ```
184
+
185
+ **Justification**: [Why this change is necessary]
186
+
187
+ **Request**: May I update the plan with these changes and continue implementation?
188
+ ```
189
+
190
+ 5. **Wait for explicit approval** before making any plan changes
191
+ 6. **Update the plan file** only after approval
192
+ 7. **Continue implementation** with the updated plan
193
+
194
+
195
+ ## Completion Criteria
196
+
197
+ Your implementation is complete when:
198
+ - All todo checklist items are marked as complete
199
+ - All implementation steps have been executed successfully
200
+ - Testing strategy has been executed and passes
201
+ - Success criteria are met and verified
202
+ - Plan file has been updated with final status
203
+
204
+ ## Final Steps
205
+
206
+ 1. Execute the complete implementation plan step by step
207
+ 2. Update `{{plan_path}}` with progress tracking throughout
208
+ 3. Verify all success criteria are met
209
+ 4. Confirm implementation is complete and functional
210
+
211
+ ## Communication Protocol
212
+
213
+ - **Before starting**: Provide initial recitation of the plan you understand
214
+ - **During implementation**:
215
+ - Provide milestone recitations after completing major todo items
216
+ - If plan corrections are needed, follow the Plan Correction Protocol
217
+ - Brief progress updates at logical checkpoints
218
+ - **If blocked**: Stop and ask for guidance immediately
219
+ - **Upon completion**: Provide final recitation confirming success criteria are met
220
+
221
+ Remember: You are in implementation mode. Your job is to execute the plan precisely and completely, validate progress through recitation, and request approval for any plan modifications discovered during implementation."""
projects/gemini-cli-extension/.gemini/commands/plan/new.toml ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ description = "Plan mode. Generates a plan for a feature based on a description"
2
+ prompt = """You are operating in **Planning Mode**. Your role is to act as a senior engineer who thoroughly analyzes codebases and creates comprehensive implementation plans without making any changes.
3
+
4
+ ## Your Mission
5
+
6
+ Plan the implementation of the following feature:
7
+
8
+ "{{args}}"
9
+
10
+ ## Core Constraints
11
+
12
+ You operate under a strict set of rules. Failure to adhere to these will result in a failed task.
13
+
14
+ 1. **READ-ONLY MANDATE:** You are **STRICTLY FORBIDDEN** from making any modifications to the codebase or the system. This includes:
15
+ * Editing, creating, or deleting any files, **with the single exception of the final plan file.**
16
+ * Use your available tools to analyze the codebase and create the plan.
17
+ * Running any shell commands that cause side effects (e.g., `git commit`, `npm install`, `mkdir`, `touch`).
18
+ * Altering configurations or installing packages.
19
+ * Your access is for analysis only.
20
+
21
+ 2. **COMPREHENSIVE ANALYSIS:** Before creating the plan, you **MUST** thoroughly investigate the codebase.
22
+ * Identify the key files, modules, components, and functions relevant to the new feature.
23
+ * Understand the existing architecture, data flow, and coding patterns.
24
+ * List the files you have inspected in your analysis.
25
+
26
+ 3. **FINAL OUTPUT: THE PLAN DOCUMENT:** Your one and only output is to write a single markdown file named after the feature into the `plans` directory.
27
+ * This file is the culmination of your work.
28
+ * The `plans` directory might not exist, so you need to create it.
29
+ * Once this file is written, your task is complete.
30
+ * Do **NOT** ask for approval or attempt to implement the plan.
31
+
32
+
33
+ ## Your Process
34
+
35
+ ### 1. Investigation Phase
36
+
37
+ - Thoroughly examine the existing codebase structure using your available tools.
38
+ - Identify relevant files, modules, and dependencies
39
+ - Analyze current architecture and patterns
40
+ - Research applicable documentation, APIs, or libraries
41
+ - Understand project conventions and coding style
42
+
43
+ ### 2. Analysis & Reasoning
44
+
45
+ Document your findings by explaining:
46
+ - What you discovered from code inspection
47
+ - Current architecture and technology stack
48
+ - Existing patterns and conventions to follow
49
+ - Dependencies and integration points
50
+ - Potential challenges or considerations
51
+ - Why your proposed approach is optimal
52
+
53
+ ### 3. Plan Creation
54
+
55
+ Create a comprehensive implementation plan with:
56
+ - **Todo Checklist**: High-level checkpoints at the top for tracking progress
57
+ - **Detailed Steps**: Numbered, actionable implementation steps
58
+ - **File Changes**: Specific files that need modification
59
+ - **Testing Strategy**: How to verify the implementation
60
+ - **Dependencies**: Any new packages or tools needed
61
+
62
+ ## Output Format for `plans/[feature_name].md`
63
+
64
+ You **MUST** format the contents of `plans/[feature_name].md` exactly as follows. Use markdown. The feature name should be short and descriptive, also make sure it can be used as a filename.
65
+
66
+ ```markdown
67
+ # Feature Implementation Plan: [feature_name]
68
+
69
+ ## 📋 Todo Checklist
70
+ - [ ] [High-level milestone]
71
+ - [ ] [High-level milestone]
72
+ - ...
73
+ - [ ] Final Review and Testing
74
+
75
+ ## 🔍 Analysis & Investigation
76
+
77
+ ### Codebase Structure
78
+ [Your findings about the current codebase]
79
+
80
+ ### Current Architecture
81
+ [Architecture analysis and relevant patterns]
82
+
83
+ ### Dependencies & Integration Points
84
+ [External dependencies and how they integrate]
85
+
86
+ ### Considerations & Challenges
87
+ [Potential issues and how to address them]
88
+
89
+ ## 📝 Implementation Plan
90
+
91
+ ### Prerequisites
92
+ [Any setup or dependencies needed before starting]
93
+
94
+ ### Step-by-Step Implementation
95
+ 1. **Step 1**: [Detailed actionable step]
96
+ - Files to modify: `path/to/file.ext`
97
+ - Changes needed: [specific description]
98
+
99
+ 2. **Step 2**: [Detailed actionable step]
100
+ - Files to modify: `path/to/file.ext`
101
+ - Changes needed: [specific description]
102
+
103
+ [Continue with all steps...]
104
+
105
+ ### Testing Strategy
106
+ [How to test and verify the implementation]
107
+
108
+ ## 🎯 Success Criteria
109
+ [How to know when the feature is complete and working]
110
+ ```
111
+
112
+ ## Final Steps
113
+
114
+ 1. Conduct your investigation and analysis
115
+ 2. Write the complete plan to `plans/[feature_name].md`
116
+ 3. Confirm the plan has been saved
117
+ 4. **DO NOT IMPLEMENT THE PLAN**
118
+ 5. Close the conversation
119
+
120
+ Remember: You are in planning mode only. Your job ends after the plan is written to `plans/[feature_name].md`. After finish conversation."""
projects/gemini-cli/.github/actions/post-coverage-comment/action.yml ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Post Coverage Comment Action'
2
+ description: 'Prepares and posts a code coverage comment to a PR.'
3
+
4
+ inputs:
5
+ cli_json_file:
6
+ description: 'Path to CLI coverage-summary.json'
7
+ required: true
8
+ core_json_file:
9
+ description: 'Path to Core coverage-summary.json'
10
+ required: true
11
+ cli_full_text_summary_file:
12
+ description: 'Path to CLI full-text-summary.txt'
13
+ required: true
14
+ core_full_text_summary_file:
15
+ description: 'Path to Core full-text-summary.txt'
16
+ required: true
17
+ node_version:
18
+ description: 'Node.js version for context in messages'
19
+ required: true
20
+ os:
21
+ description: 'The os for context in messages'
22
+ required: true
23
+ github_token:
24
+ description: 'GitHub token for posting comments'
25
+ required: true
26
+
27
+ runs:
28
+ using: 'composite'
29
+ steps:
30
+ - name: 'Prepare Coverage Comment'
31
+ id: 'prep_coverage_comment'
32
+ shell: 'bash'
33
+ env:
34
+ CLI_JSON_FILE: '${{ inputs.cli_json_file }}'
35
+ CORE_JSON_FILE: '${{ inputs.core_json_file }}'
36
+ CLI_FULL_TEXT_SUMMARY_FILE: '${{ inputs.cli_full_text_summary_file }}'
37
+ CORE_FULL_TEXT_SUMMARY_FILE: '${{ inputs.core_full_text_summary_file }}'
38
+ COMMENT_FILE: 'coverage-comment.md'
39
+ NODE_VERSION: '${{ inputs.node_version }}'
40
+ OS: '${{ inputs.os }}'
41
+ run: |-
42
+ # Extract percentages using jq for the main table
43
+ if [ -f "${CLI_JSON_FILE}" ]; then
44
+ cli_lines_pct="$(jq -r '.total.lines.pct' "${CLI_JSON_FILE}")"
45
+ cli_statements_pct="$(jq -r '.total.statements.pct' "${CLI_JSON_FILE}")"
46
+ cli_functions_pct="$(jq -r '.total.functions.pct' "${CLI_JSON_FILE}")"
47
+ cli_branches_pct="$(jq -r '.total.branches.pct' "${CLI_JSON_FILE}")"
48
+ else
49
+ cli_lines_pct="N/A"
50
+ cli_statements_pct="N/A"
51
+ cli_functions_pct="N/A"
52
+ cli_branches_pct="N/A"
53
+ echo "CLI coverage-summary.json not found at: ${CLI_JSON_FILE}" >&2 # Error to stderr
54
+ fi
55
+
56
+ if [ -f "${CORE_JSON_FILE}" ]; then
57
+ core_lines_pct="$(jq -r '.total.lines.pct' "${CORE_JSON_FILE}")"
58
+ core_statements_pct="$(jq -r '.total.statements.pct' "${CORE_JSON_FILE}")"
59
+ core_functions_pct="$(jq -r '.total.functions.pct' "${CORE_JSON_FILE}")"
60
+ core_branches_pct="$(jq -r '.total.branches.pct' "${CORE_JSON_FILE}")"
61
+ else
62
+ core_lines_pct="N/A"
63
+ core_statements_pct="N/A"
64
+ core_functions_pct="N/A"
65
+ core_branches_pct="N/A"
66
+ echo "Core coverage-summary.json not found at: ${CORE_JSON_FILE}" >&2 # Error to stderr
67
+ fi
68
+
69
+ echo "## Code Coverage Summary" > "${COMMENT_FILE}"
70
+ echo "" >> "${COMMENT_FILE}"
71
+ echo "| Package | Lines | Statements | Functions | Branches |" >> "${COMMENT_FILE}"
72
+ echo "|---|---|---|---|---|" >> "${COMMENT_FILE}"
73
+ echo "| CLI | ${cli_lines_pct}% | ${cli_statements_pct}% | ${cli_functions_pct}% | ${cli_branches_pct}% |" >> "${COMMENT_FILE}"
74
+ echo "| Core | ${core_lines_pct}% | ${core_statements_pct}% | ${core_functions_pct}% | ${core_branches_pct}% |" >> "${COMMENT_FILE}"
75
+ echo "" >> "${COMMENT_FILE}"
76
+
77
+ # CLI Package - Collapsible Section (with full text summary from file)
78
+ echo "<details>" >> "${COMMENT_FILE}"
79
+ echo "<summary>CLI Package - Full Text Report</summary>" >> "${COMMENT_FILE}"
80
+ echo "" >> "${COMMENT_FILE}"
81
+ echo '```text' >> "${COMMENT_FILE}"
82
+ if [ -f "${CLI_FULL_TEXT_SUMMARY_FILE}" ]; then
83
+ cat "${CLI_FULL_TEXT_SUMMARY_FILE}" >> "${COMMENT_FILE}"
84
+ else
85
+ echo "CLI full-text-summary.txt not found at: ${CLI_FULL_TEXT_SUMMARY_FILE}" >> "${COMMENT_FILE}"
86
+ fi
87
+ echo '```' >> "${COMMENT_FILE}"
88
+ echo "</details>" >> "${COMMENT_FILE}"
89
+ echo "" >> "${COMMENT_FILE}"
90
+
91
+ # Core Package - Collapsible Section (with full text summary from file)
92
+ echo "<details>" >> "${COMMENT_FILE}"
93
+ echo "<summary>Core Package - Full Text Report</summary>" >> "${COMMENT_FILE}"
94
+ echo "" >> "${COMMENT_FILE}"
95
+ echo '```text' >> "${COMMENT_FILE}"
96
+ if [ -f "${CORE_FULL_TEXT_SUMMARY_FILE}" ]; then
97
+ cat "${CORE_FULL_TEXT_SUMMARY_FILE}" >> "${COMMENT_FILE}"
98
+ else
99
+ echo "Core full-text-summary.txt not found at: ${CORE_FULL_TEXT_SUMMARY_FILE}" >> "${COMMENT_FILE}"
100
+ fi
101
+ echo '```' >> "${COMMENT_FILE}"
102
+ echo "</details>" >> "${COMMENT_FILE}"
103
+ echo "" >> "${COMMENT_FILE}"
104
+
105
+ echo "_For detailed HTML reports, please see the 'coverage-reports-${NODE_VERSION}-${OS}' artifact from the main CI run._" >> "${COMMENT_FILE}"
106
+
107
+ - name: 'Post Coverage Comment'
108
+ uses: 'thollander/actions-comment-pull-request@65f9e5c9a1f2cd378bd74b2e057c9736982a8e74' # ratchet:thollander/actions-comment-pull-request@v3
109
+ if: |-
110
+ ${{ always() }}
111
+ with:
112
+ file-path: 'coverage-comment.md' # Use the generated file directly
113
+ comment-tag: 'code-coverage-summary'
114
+ github-token: '${{ inputs.github_token }}'
projects/gemini-cli/.github/workflows/community-report.yml ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Generate Weekly Community Report 📊'
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 12 * * 1' # Run at 12:00 UTC on Monday
6
+ workflow_dispatch:
7
+ inputs:
8
+ days:
9
+ description: 'Number of days to look back for the report'
10
+ required: true
11
+ default: '7'
12
+
13
+ jobs:
14
+ generate-report:
15
+ name: 'Generate Report 📝'
16
+ if: |-
17
+ ${{ github.repository == 'google-gemini/gemini-cli' }}
18
+ runs-on: 'ubuntu-latest'
19
+ permissions:
20
+ issues: 'write'
21
+ pull-requests: 'read'
22
+ discussions: 'read'
23
+ contents: 'read'
24
+ id-token: 'write'
25
+
26
+ steps:
27
+ - name: 'Generate GitHub App Token 🔑'
28
+ id: 'generate_token'
29
+ uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b' # ratchet:actions/create-github-app-token@v2
30
+ with:
31
+ app-id: '${{ secrets.APP_ID }}'
32
+ private-key: '${{ secrets.PRIVATE_KEY }}'
33
+ permission-issues: 'write'
34
+ permission-pull-requests: 'read'
35
+ permission-discussions: 'read'
36
+ permission-contents: 'read'
37
+
38
+ - name: 'Generate Report 📜'
39
+ id: 'report'
40
+ env:
41
+ GH_TOKEN: '${{ steps.generate_token.outputs.token }}'
42
+ REPO: '${{ github.repository }}'
43
+ DAYS: '${{ github.event.inputs.days || 7 }}'
44
+ run: |-
45
+ set -e
46
+
47
+ START_DATE="$(date -u -d "$DAYS days ago" +'%Y-%m-%d')"
48
+ END_DATE="$(date -u +'%Y-%m-%d')"
49
+ echo "⏳ Generating report for contributions from ${START_DATE} to ${END_DATE}..."
50
+
51
+ declare -A author_is_googler
52
+ check_googler_status() {
53
+ local author="$1"
54
+ if [[ "${author}" == *"[bot]" ]]; then
55
+ author_is_googler[${author}]=1
56
+ return 1
57
+ fi
58
+ if [[ -v "author_is_googler[${author}]" ]]; then
59
+ return "${author_is_googler[${author}]}"
60
+ fi
61
+
62
+ if gh api "orgs/googlers/members/${author}" --silent 2>/dev/null; then
63
+ echo "🧑‍💻 ${author} is a Googler."
64
+ author_is_googler[${author}]=0
65
+ else
66
+ echo "🌍 ${author} is a community contributor."
67
+ author_is_googler[${author}]=1
68
+ fi
69
+ return "${author_is_googler[${author}]}"
70
+ }
71
+
72
+ googler_issues=0
73
+ non_googler_issues=0
74
+ googler_prs=0
75
+ non_googler_prs=0
76
+
77
+ echo "🔎 Fetching issues and pull requests..."
78
+ ITEMS_JSON="$(gh search issues --repo "${REPO}" "created:>${START_DATE}" --json author,isPullRequest --limit 1000)"
79
+
80
+ for row in $(echo "${ITEMS_JSON}" | jq -r '.[] | @base64'); do
81
+ _jq() {
82
+ echo "${row}" | base64 --decode | jq -r "${1}"
83
+ }
84
+ author="$(_jq '.author.login')"
85
+ is_pr="$(_jq '.isPullRequest')"
86
+
87
+ if [[ -z "${author}" || "${author}" == "null" ]]; then
88
+ continue
89
+ fi
90
+
91
+ if check_googler_status "${author}"; then
92
+ if [[ "${is_pr}" == "true" ]]; then
93
+ ((googler_prs++))
94
+ else
95
+ ((googler_issues++))
96
+ fi
97
+ else
98
+ if [[ "${is_pr}" == "true" ]]; then
99
+ ((non_googler_prs++))
100
+ else
101
+ ((non_googler_issues++))
102
+ fi
103
+ fi
104
+ done
105
+
106
+ googler_discussions=0
107
+ non_googler_discussions=0
108
+
109
+ echo "🗣️ Fetching discussions..."
110
+ DISCUSSION_QUERY='''
111
+ query($q: String!) {
112
+ search(query: $q, type: DISCUSSION, first: 100) {
113
+ nodes {
114
+ ... on Discussion {
115
+ author {
116
+ login
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }'''
122
+ DISCUSSIONS_JSON="$(gh api graphql -f q="repo:${REPO} created:>${START_DATE}" -f query="${DISCUSSION_QUERY}")"
123
+
124
+ for row in $(echo "${DISCUSSIONS_JSON}" | jq -r '.data.search.nodes[] | @base64'); do
125
+ _jq() {
126
+ echo "${row}" | base64 --decode | jq -r "${1}"
127
+ }
128
+ author="$(_jq '.author.login')"
129
+
130
+ if [[ -z "${author}" || "${author}" == "null" ]]; then
131
+ continue
132
+ fi
133
+
134
+ if check_googler_status "${author}"; then
135
+ ((googler_discussions++))
136
+ else
137
+ ((non_googler_discussions++))
138
+ fi
139
+ done
140
+
141
+ echo "✍️ Generating report content..."
142
+ TOTAL_ISSUES=$((googler_issues + non_googler_issues))
143
+ TOTAL_PRS=$((googler_prs + non_googler_prs))
144
+ TOTAL_DISCUSSIONS=$((googler_discussions + non_googler_discussions))
145
+
146
+ REPORT_BODY=$(cat <<EOF
147
+ ### 💖 Community Contribution Report
148
+
149
+ **Period:** ${START_DATE} to ${END_DATE}
150
+
151
+ | Category | Googlers | Community | Total |
152
+ |---|---:|---:|---:|
153
+ | **Issues** | $googler_issues | $non_googler_issues | **$TOTAL_ISSUES** |
154
+ | **Pull Requests** | $googler_prs | $non_googler_prs | **$TOTAL_PRS** |
155
+ | **Discussions** | $googler_discussions | $non_googler_discussions | **$TOTAL_DISCUSSIONS** |
156
+
157
+ _This report was generated automatically by a GitHub Action._
158
+ EOF
159
+ )
160
+
161
+ echo "report_body<<EOF" >> "${GITHUB_OUTPUT}"
162
+ echo "${REPORT_BODY}" >> "${GITHUB_OUTPUT}"
163
+ echo "EOF" >> "${GITHUB_OUTPUT}"
164
+
165
+ echo "📊 Community Contribution Report:"
166
+ echo "${REPORT_BODY}"
167
+
168
+ - name: '🤖 Get Insights from Report'
169
+ if: |-
170
+ ${{ steps.report.outputs.report_body != '' }}
171
+ uses: 'google-github-actions/run-gemini-cli@a3bf79042542528e91937b3a3a6fbc4967ee3c31' # ratchet:google-github-actions/run-gemini-cli@v0
172
+ env:
173
+ GITHUB_TOKEN: '${{ steps.generate_token.outputs.token }}'
174
+ REPOSITORY: '${{ github.repository }}'
175
+ with:
176
+ gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
177
+ gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
178
+ gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
179
+ gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
180
+ gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
181
+ use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
182
+ use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
183
+ settings: |-
184
+ {
185
+ "coreTools": [
186
+ "run_shell_command(gh issue list)",
187
+ "run_shell_command(gh pr list)",
188
+ "run_shell_command(gh search issues)",
189
+ "run_shell_command(gh search prs)"
190
+ ]
191
+ }
192
+ prompt: |-
193
+ You are a helpful assistant that analyzes community contribution reports.
194
+ Based on the following report, please provide a brief summary and highlight any interesting trends or potential areas for improvement.
195
+
196
+ Report:
197
+ ${{ steps.report.outputs.report_body }}
projects/gemini-cli/.github/workflows/docs-page-action.yml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Deploy GitHub Pages'
2
+
3
+ on:
4
+ push:
5
+ tags: 'v*'
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: 'read'
10
+ pages: 'write'
11
+ id-token: 'write'
12
+
13
+ # Allow only one concurrent deployment, skipping runs queued between the run
14
+ # in-progress and latest queued. However, do NOT cancel in-progress runs as we
15
+ # want to allow these production deployments to complete.
16
+ concurrency:
17
+ group: '${{ github.workflow }}'
18
+ cancel-in-progress: false
19
+
20
+ jobs:
21
+ build:
22
+ if: |-
23
+ ${{ !contains(github.ref_name, 'nightly') }}
24
+ runs-on: 'ubuntu-latest'
25
+ steps:
26
+ - name: 'Checkout'
27
+ uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
28
+
29
+ - name: 'Setup Pages'
30
+ uses: 'actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b' # ratchet:actions/configure-pages@v5
31
+
32
+ - name: 'Build with Jekyll'
33
+ uses: 'actions/jekyll-build-pages@44a6e6beabd48582f863aeeb6cb2151cc1716697' # ratchet:actions/jekyll-build-pages@v1
34
+ with:
35
+ source: './'
36
+ destination: './_site'
37
+
38
+ - name: 'Upload artifact'
39
+ uses: 'actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa' # ratchet:actions/upload-pages-artifact@v3
40
+
41
+ deploy:
42
+ environment:
43
+ name: 'github-pages'
44
+ url: '${{ steps.deployment.outputs.page_url }}'
45
+ runs-on: 'ubuntu-latest'
46
+ needs: 'build'
47
+ steps:
48
+ - name: 'Deploy to GitHub Pages'
49
+ id: 'deployment'
50
+ uses: 'actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e' # ratchet:actions/deploy-pages@v4
projects/gemini-cli/.github/workflows/e2e.yml ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'E2E Tests'
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - 'main'
7
+ merge_group:
8
+
9
+ jobs:
10
+ e2e-test-linux:
11
+ name: 'E2E Test (Linux) - ${{ matrix.sandbox }}'
12
+ runs-on: 'ubuntu-latest'
13
+ strategy:
14
+ matrix:
15
+ sandbox:
16
+ - 'sandbox:none'
17
+ - 'sandbox:docker'
18
+ node-version:
19
+ - '20.x'
20
+ - '22.x'
21
+ - '24.x'
22
+ steps:
23
+ - name: 'Checkout'
24
+ uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
25
+
26
+ - name: 'Set up Node.js ${{ matrix.node-version }}'
27
+ uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
28
+ with:
29
+ node-version: '${{ matrix.node-version }}'
30
+ cache: 'npm'
31
+
32
+ - name: 'Install dependencies'
33
+ run: |-
34
+ npm ci
35
+
36
+ - name: 'Build project'
37
+ run: |-
38
+ npm run build
39
+
40
+ - name: 'Set up Docker'
41
+ if: |-
42
+ ${{ matrix.sandbox == 'sandbox:docker' }}
43
+ uses: 'docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435' # ratchet:docker/setup-buildx-action@v3
44
+
45
+ - name: 'Set up Podman'
46
+ if: |-
47
+ ${{ matrix.sandbox == 'sandbox:podman' }}
48
+ uses: 'redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603' # ratchet:redhat-actions/podman-login@v1
49
+ with:
50
+ registry: 'docker.io'
51
+ username: '${{ secrets.DOCKERHUB_USERNAME }}'
52
+ password: '${{ secrets.DOCKERHUB_TOKEN }}'
53
+
54
+ - name: 'Run E2E tests'
55
+ env:
56
+ GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}'
57
+ KEEP_OUTPUT: 'true'
58
+ SANDBOX: '${{ matrix.sandbox }}'
59
+ VERBOSE: 'true'
60
+ run: |-
61
+ npm run "test:integration:${SANDBOX}"
62
+
63
+ e2e-test-macos:
64
+ name: 'E2E Test - macOS'
65
+ runs-on: 'macos-latest'
66
+ steps:
67
+ - name: 'Checkout'
68
+ uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
69
+
70
+ - name: 'Set up Node.js'
71
+ uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
72
+ with:
73
+ node-version-file: '.nvmrc'
74
+ cache: 'npm'
75
+
76
+ - name: 'Install dependencies'
77
+ run: |-
78
+ npm ci
79
+
80
+ - name: 'Build project'
81
+ run: |-
82
+ npm run build
83
+
84
+ - name: 'Run E2E tests'
85
+ env:
86
+ GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}'
87
+ run: |-
88
+ npm run test:e2e
projects/gemini-cli/.github/workflows/eval.yml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Eval'
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ eval:
8
+ name: 'Eval'
9
+ runs-on: 'ubuntu-latest'
10
+ strategy:
11
+ matrix:
12
+ node-version:
13
+ - '20.x'
14
+ - '22.x'
15
+ - '24.x'
16
+ steps:
17
+ - name: 'Set up Node.js ${{ matrix.node-version }}'
18
+ uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
19
+ with:
20
+ node-version: '${{ matrix.node-version }}'
21
+ cache: 'npm'
22
+
23
+ - name: 'Set up Python'
24
+ uses: 'actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065' # ratchet:actions/setup-python@v5
25
+ with:
26
+ python-version: '3.11'
27
+
28
+ - name: 'Install and configure Poetry'
29
+ uses: 'snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a' # ratchet:snok/install-poetry@v1
projects/gemini-cli/.github/workflows/gemini-automated-issue-dedup.yml ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: '🏷️ Gemini Automated Issue Deduplication'
2
+
3
+ on:
4
+ issues:
5
+ types:
6
+ - 'opened'
7
+ - 'reopened'
8
+ issue_comment:
9
+ types:
10
+ - 'created'
11
+ workflow_dispatch:
12
+ inputs:
13
+ issue_number:
14
+ description: 'issue number to dedup'
15
+ required: true
16
+ type: 'number'
17
+
18
+ concurrency:
19
+ group: '${{ github.workflow }}-${{ github.event.issue.number }}'
20
+ cancel-in-progress: true
21
+
22
+ defaults:
23
+ run:
24
+ shell: 'bash'
25
+
26
+ jobs:
27
+ find-duplicates:
28
+ if: |-
29
+ github.repository == 'google-gemini/gemini-cli' &&
30
+ vars.TRIAGE_DEDUPLICATE_ISSUES != '' &&
31
+ (github.event_name == 'issues' ||
32
+ github.event_name == 'workflow_dispatch' ||
33
+ (github.event_name == 'issue_comment' &&
34
+ contains(github.event.comment.body, '@gemini-cli /deduplicate') &&
35
+ (github.event.comment.author_association == 'OWNER' ||
36
+ github.event.comment.author_association == 'MEMBER' ||
37
+ github.event.comment.author_association == 'COLLABORATOR')))
38
+ permissions:
39
+ contents: 'read'
40
+ id-token: 'write' # Required for WIF, see https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-google-cloud-platform#adding-permissions-settings
41
+ issues: 'read'
42
+ statuses: 'read'
43
+ packages: 'read'
44
+ timeout-minutes: 20
45
+ runs-on: 'ubuntu-latest'
46
+ outputs:
47
+ duplicate_issues_csv: '${{ env.DUPLICATE_ISSUES_CSV }}'
48
+ steps:
49
+ - name: 'Checkout'
50
+ uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
51
+
52
+ - name: 'Log in to GitHub Container Registry'
53
+ uses: 'docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1' # ratchet:docker/login-action@v3
54
+ with:
55
+ registry: 'ghcr.io'
56
+ username: '${{ github.actor }}'
57
+ password: '${{ secrets.GITHUB_TOKEN }}'
58
+
59
+ - name: 'Find Duplicate Issues'
60
+ uses: 'google-github-actions/run-gemini-cli@a3bf79042542528e91937b3a3a6fbc4967ee3c31' # ratchet:google-github-actions/run-gemini-cli@v0
61
+ id: 'gemini_issue_deduplication'
62
+ env:
63
+ GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
64
+ ISSUE_TITLE: '${{ github.event.issue.title }}'
65
+ ISSUE_BODY: '${{ github.event.issue.body }}'
66
+ ISSUE_NUMBER: '${{ github.event.issue.number }}'
67
+ REPOSITORY: '${{ github.repository }}'
68
+ FIRESTORE_PROJECT: '${{ vars.FIRESTORE_PROJECT }}'
69
+ with:
70
+ gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
71
+ gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
72
+ gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
73
+ gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
74
+ gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
75
+ use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
76
+ use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
77
+ settings: |-
78
+ {
79
+ "mcpServers": {
80
+ "issue_deduplication": {
81
+ "command": "docker",
82
+ "args": [
83
+ "run",
84
+ "-i",
85
+ "--rm",
86
+ "--network", "host",
87
+ "-e", "GITHUB_TOKEN",
88
+ "-e", "GEMINI_API_KEY",
89
+ "-e", "DATABASE_TYPE",
90
+ "-e", "FIRESTORE_DATABASE_ID",
91
+ "-e", "GCP_PROJECT",
92
+ "-e", "GOOGLE_APPLICATION_CREDENTIALS=/app/gcp-credentials.json",
93
+ "-v", "${GOOGLE_APPLICATION_CREDENTIALS}:/app/gcp-credentials.json",
94
+ "ghcr.io/google-gemini/gemini-cli-issue-triage@sha256:e3de1523f6c83aabb3c54b76d08940a2bf42febcb789dd2da6f95169641f94d3"
95
+ ],
96
+ "env": {
97
+ "GITHUB_TOKEN": "${GITHUB_TOKEN}",
98
+ "GEMINI_API_KEY": "${{ secrets.GEMINI_API_KEY }}",
99
+ "DATABASE_TYPE":"firestore",
100
+ "GCP_PROJECT": "${FIRESTORE_PROJECT}",
101
+ "FIRESTORE_DATABASE_ID": "(default)",
102
+ "GOOGLE_APPLICATION_CREDENTIALS": "${GOOGLE_APPLICATION_CREDENTIALS}"
103
+ },
104
+ "enabled": true,
105
+ "timeout": 600000
106
+ }
107
+ },
108
+ "maxSessionTurns": 25,
109
+ "coreTools": [
110
+ "run_shell_command(echo)",
111
+ "run_shell_command(gh issue view)"
112
+ ],
113
+ "telemetry": {
114
+ "enabled": true,
115
+ "target": "gcp"
116
+ }
117
+ }
118
+ prompt: |-
119
+ ## Role
120
+ You are an issue de-duplication assistant. Your goal is to find
121
+ duplicate issues for a given issue.
122
+ ## Steps
123
+ 1. **Find Potential Duplicates:**
124
+ - The repository is ${{ github.repository }} and the issue number is ${{ github.event.issue.number }}.
125
+ - Use the `duplicates` tool with the `repo` and `issue_number` to find potential duplicates for the current issue. Do not use the `threshold` parameter.
126
+ - If no duplicates are found, you are done.
127
+ - Print the JSON output from the `duplicates` tool to the logs.
128
+ 2. **Refine Duplicates List (if necessary):**
129
+ - If the `duplicates` tool returns between 1 and 14 results, you must refine the list.
130
+ - For each potential duplicate issue, run `gh issue view <issue-number> --json title,body,comments` to fetch its content.
131
+ - Also fetch the content of the original issue: `gh issue view "${ISSUE_NUMBER}" --json title,body,comments`.
132
+ - Carefully analyze the content (title, body, comments) of the original issue and all potential duplicates.
133
+ - It is very important if the comments on either issue mention that they are not duplicates of each other, to treat them as not duplicates.
134
+ - Based on your analysis, create a final list containing only the issues you are highly confident are actual duplicates.
135
+ - If your final list is empty, you are done.
136
+ - Print to the logs if you omitted any potential duplicates based on your analysis.
137
+ - If the `duplicates` tool returned 15+ results, use the top 15 matches (based on descending similarity score value) to perform this step.
138
+ 3. **Output final duplicates list as CSV:**
139
+ - Convert the list of appropriate duplicate issue numbers into a comma-separated list (CSV). If there are no appropriate duplicates, use the empty string.
140
+ - Use the "echo" shell command to append the CSV of issue numbers into the filepath referenced by the environment variable "${GITHUB_ENV}":
141
+ echo "DUPLICATE_ISSUES_CSV=[DUPLICATE_ISSUES_AS_CSV]" >> "${GITHUB_ENV}"
142
+ ## Guidelines
143
+ - Only use the `duplicates` and `run_shell_command` tools.
144
+ - The `run_shell_command` tool can be used with `gh issue view`.
145
+ - Do not download or read media files like images, videos, or links. The `--json` flag for `gh issue view` will prevent this.
146
+ - Do not modify the issue content or status.
147
+ - Do not add comments or labels.
148
+ - Reference all shell variables as "${VAR}" (with quotes and braces).
149
+
150
+ add-comment-and-label:
151
+ needs: 'find-duplicates'
152
+ if: |-
153
+ github.repository == 'google-gemini/gemini-cli' &&
154
+ vars.TRIAGE_DEDUPLICATE_ISSUES != '' &&
155
+ needs.find-duplicates.outputs.duplicate_issues_csv != '' &&
156
+ (
157
+ github.event_name == 'issues' ||
158
+ github.event_name == 'workflow_dispatch' ||
159
+ (
160
+ github.event_name == 'issue_comment' &&
161
+ contains(github.event.comment.body, '@gemini-cli /deduplicate') &&
162
+ (
163
+ github.event.comment.author_association == 'OWNER' ||
164
+ github.event.comment.author_association == 'MEMBER' ||
165
+ github.event.comment.author_association == 'COLLABORATOR'
166
+ )
167
+ )
168
+ )
169
+ permissions:
170
+ issues: 'write'
171
+ timeout-minutes: 5
172
+ runs-on: 'ubuntu-latest'
173
+ steps:
174
+ - name: 'Generate GitHub App Token'
175
+ id: 'generate_token'
176
+ uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b' # ratchet:actions/create-github-app-token@v2
177
+ with:
178
+ app-id: '${{ secrets.APP_ID }}'
179
+ private-key: '${{ secrets.PRIVATE_KEY }}'
180
+ permission-issues: 'write'
181
+
182
+ - name: 'Comment and Label Duplicate Issue'
183
+ uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea'
184
+ env:
185
+ DUPLICATES_OUTPUT: '${{ needs.find-duplicates.outputs.duplicate_issues_csv }}'
186
+ with:
187
+ github-token: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
188
+ script: |-
189
+ const rawCsv = process.env.DUPLICATES_OUTPUT;
190
+ core.info(`Raw duplicates CSV: ${rawCsv}`);
191
+ const duplicateIssues = rawCsv.split(',').map(s => s.trim()).filter(s => s);
192
+
193
+ if (duplicateIssues.length === 0) {
194
+ core.info('No duplicate issues found. Nothing to do.');
195
+ return;
196
+ }
197
+
198
+ const issueNumber = ${{ github.event.issue.number }};
199
+
200
+ function formatCommentBody(issues, updated = false) {
201
+ const header = updated
202
+ ? 'Found possible duplicate issues (updated):'
203
+ : 'Found possible duplicate issues:';
204
+ const issuesList = issues.map(num => `- #${num}`).join('\n');
205
+ const footer = 'If you believe this is not a duplicate, please remove the `status/possible-duplicate` label.';
206
+ const magicComment = '<!-- gemini-cli-deduplication -->';
207
+ return `${header}\n\n${issuesList}\n\n${footer}\n${magicComment}`;
208
+ }
209
+
210
+ const newCommentBody = formatCommentBody(duplicateIssues);
211
+ const newUpdatedCommentBody = formatCommentBody(duplicateIssues, true);
212
+
213
+ const { data: comments } = await github.rest.issues.listComments({
214
+ owner: context.repo.owner,
215
+ repo: context.repo.repo,
216
+ issue_number: issueNumber,
217
+ });
218
+
219
+ const magicComment = '<!-- gemini-cli-deduplication -->';
220
+ const existingComment = comments.find(comment =>
221
+ comment.user.type === 'Bot' && comment.body.includes(magicComment)
222
+ );
223
+
224
+ let commentMade = false;
225
+
226
+ if (existingComment) {
227
+ // To check if lists are same, just compare the formatted bodies without headers.
228
+ const existingBodyForCompare = existingComment.body.substring(existingComment.body.indexOf('- #'));
229
+ const newBodyForCompare = newCommentBody.substring(newCommentBody.indexOf('- #'));
230
+
231
+ if (existingBodyForCompare.trim() !== newBodyForCompare.trim()) {
232
+ core.info(`Updating existing comment ${existingComment.id}`);
233
+ await github.rest.issues.updateComment({
234
+ owner: context.repo.owner,
235
+ repo: context.repo.repo,
236
+ comment_id: existingComment.id,
237
+ body: newUpdatedCommentBody,
238
+ });
239
+ commentMade = true;
240
+ } else {
241
+ core.info('Existing comment is up-to-date. Nothing to do.');
242
+ }
243
+ } else {
244
+ core.info('Creating new comment.');
245
+ await github.rest.issues.createComment({
246
+ owner: context.repo.owner,
247
+ repo: context.repo.repo,
248
+ issue_number: issueNumber,
249
+ body: newCommentBody,
250
+ });
251
+ commentMade = true;
252
+ }
253
+
254
+ if (commentMade) {
255
+ core.info('Adding "status/possible-duplicate" label.');
256
+ await github.rest.issues.addLabels({
257
+ owner: context.repo.owner,
258
+ repo: context.repo.repo,
259
+ issue_number: issueNumber,
260
+ labels: ['status/possible-duplicate'],
261
+ });
262
+ }
projects/gemini-cli/.github/workflows/gemini-automated-issue-triage.yml ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: '🏷️ Gemini Automated Issue Triage'
2
+
3
+ on:
4
+ issues:
5
+ types:
6
+ - 'opened'
7
+ - 'reopened'
8
+ issue_comment:
9
+ types:
10
+ - 'created'
11
+ workflow_dispatch:
12
+ inputs:
13
+ issue_number:
14
+ description: 'issue number to triage'
15
+ required: true
16
+ type: 'number'
17
+
18
+ concurrency:
19
+ group: '${{ github.workflow }}-${{ github.event.issue.number || github.event.inputs.issue_number }}'
20
+ cancel-in-progress: true
21
+
22
+ defaults:
23
+ run:
24
+ shell: 'bash'
25
+
26
+ permissions:
27
+ contents: 'read'
28
+ id-token: 'write'
29
+ issues: 'write'
30
+ statuses: 'write'
31
+ packages: 'read'
32
+ actions: 'write' # Required for cancelling a workflow run
33
+
34
+ jobs:
35
+ triage-issue:
36
+ if: |-
37
+ github.repository == 'google-gemini/gemini-cli' &&
38
+ (
39
+ github.event_name == 'workflow_dispatch' ||
40
+ (
41
+ (github.event_name == 'issues' || github.event_name == 'issue_comment') &&
42
+ contains(github.event.issue.labels.*.name, 'status/need-triage') &&
43
+ (github.event_name != 'issue_comment' || (
44
+ contains(github.event.comment.body, '@gemini-cli /triage') &&
45
+ (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR')
46
+ ))
47
+ )
48
+ )
49
+ timeout-minutes: 5
50
+ runs-on: 'ubuntu-latest'
51
+ steps:
52
+ - name: 'Get issue data for manual trigger'
53
+ id: 'get_issue_data'
54
+ if: |-
55
+ github.event_name == 'workflow_dispatch'
56
+ uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea'
57
+ with:
58
+ github-token: '${{ secrets.GITHUB_TOKEN }}'
59
+ script: |
60
+ const { data: issue } = await github.rest.issues.get({
61
+ owner: context.repo.owner,
62
+ repo: context.repo.repo,
63
+ issue_number: ${{ github.event.inputs.issue_number }},
64
+ });
65
+ core.setOutput('title', issue.title);
66
+ core.setOutput('body', issue.body);
67
+ core.setOutput('labels', issue.labels.map(label => label.name).join(','));
68
+ return issue;
69
+
70
+ - name: 'Check for triage label on manual trigger'
71
+ if: |-
72
+ github.event_name == 'workflow_dispatch' && !contains(steps.get_issue_data.outputs.labels, 'status/need-triage')
73
+ run: |
74
+ echo "Issue #${{ github.event.inputs.issue_number }} does not have the 'status/need-triage' label. Stopping workflow."
75
+ exit 1
76
+
77
+ - name: 'Checkout'
78
+ uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
79
+
80
+ - name: 'Generate GitHub App Token'
81
+ id: 'generate_token'
82
+ uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b' # ratchet:actions/create-github-app-token@v2
83
+ with:
84
+ app-id: '${{ secrets.APP_ID }}'
85
+ private-key: '${{ secrets.PRIVATE_KEY }}'
86
+ permission-issues: 'write'
87
+
88
+ - name: 'Get Repository Labels'
89
+ id: 'get_labels'
90
+ uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea'
91
+ with:
92
+ github-token: '${{ steps.generate_token.outputs.token }}'
93
+ script: |-
94
+ const { data: labels } = await github.rest.issues.listLabelsForRepo({
95
+ owner: context.repo.owner,
96
+ repo: context.repo.repo,
97
+ });
98
+ const labelNames = labels.map(label => label.name);
99
+ core.setOutput('available_labels', labelNames.join(','));
100
+ core.info(`Found ${labelNames.length} labels: ${labelNames.join(', ')}`);
101
+ return labelNames;
102
+
103
+ - name: 'Run Gemini Issue Analysis'
104
+ uses: 'google-github-actions/run-gemini-cli@a3bf79042542528e91937b3a3a6fbc4967ee3c31' # ratchet:google-github-actions/run-gemini-cli@v0
105
+ id: 'gemini_issue_analysis'
106
+ env:
107
+ GITHUB_TOKEN: '' # Do not pass any auth token here since this runs on untrusted inputs
108
+ ISSUE_TITLE: >-
109
+ ${{ github.event_name == 'workflow_dispatch' && steps.get_issue_data.outputs.title || github.event.issue.title }}
110
+ ISSUE_BODY: >-
111
+ ${{ github.event_name == 'workflow_dispatch' && steps.get_issue_data.outputs.body || github.event.issue.body }}
112
+ ISSUE_NUMBER: >-
113
+ ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.issue_number || github.event.issue.number }}
114
+ REPOSITORY: '${{ github.repository }}'
115
+ AVAILABLE_LABELS: '${{ steps.get_labels.outputs.available_labels }}'
116
+ with:
117
+ gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
118
+ gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
119
+ gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
120
+ gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
121
+ gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
122
+ use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
123
+ use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
124
+ settings: |-
125
+ {
126
+ "maxSessionTurns": 25,
127
+ "coreTools": [
128
+ "run_shell_command(echo)"
129
+ ],
130
+ "telemetry": {
131
+ "enabled": true,
132
+ "target": "gcp"
133
+ }
134
+ }
135
+ prompt: |-
136
+ ## Role
137
+
138
+ You are an issue triage assistant. Analyze the current GitHub issue
139
+ and identify the most appropriate existing labels by only using the provided data. Use the available
140
+ tools to gather information; do not ask for information to be
141
+ provided. Do not remove the following labels titled maintainer, help wanted or good first issue.
142
+
143
+ ## Steps
144
+
145
+ 1. You are only able to use the echo command. Review the available labels in the environment variable: "${AVAILABLE_LABELS}".
146
+ 2. Review the issue title and body provided in the environment variables: "${ISSUE_TITLE}" and "${ISSUE_BODY}".
147
+ 3. Select the most relevant labels from the existing labels, focusing on kind/*, area/*, sub-area/* and priority/*. For area/* and kind/* limit yourself to only the single most applicable label in each case.
148
+ 4. If the issue already has area/ label, dont try to change it. Similarly, if the issue already has a kind/ label don't change it. And if the issue already has a priority/ label do not change it for example:
149
+ If an issue has area/core and kind/bug you will only add a priority/ label.
150
+ Instead if an issue has no labels, you will could add one lable of each kind.
151
+ 5. For each issue please check if CLI version is present, this is usually in the output of the /about command and will look like 0.1.5 for anything more than 6 versions older than the most recent should add the status/need-retesting label.
152
+ 6. If you see that the issue doesn't look like it has sufficient information recommend the status/need-information label and leave a comment politely requesting the relevant information, eg.. if repro steps are missing request for repro steps. if version information is missing request for version information into the explanation section below.
153
+ 7. Output the appropriate labels for this issue in JSON format with explanation, for example:
154
+ ```
155
+ {"labels_to_set": ["kind/bug", "priority/p0"], "explanation": "This is a critical bug report affecting main functionality"}
156
+ ```
157
+ 8. If the issue cannot be classified using the available labels, output:
158
+ ```
159
+ {"labels_to_set": [], "explanation": "Unable to classify this issue with available labels"}
160
+ ```
161
+ 9. Use Area definitions mentioned below to help you narrow down issues.
162
+ 10. If you think an issue might be a Priority/P0 do not apply the priority/p0 label. Instead apply a status/manual-triage label and include a note in your explanation.
163
+ 11. If you are uncertain and have not been able to apply one each of kind/, area/ and priority/ , apply the status/manual-triage label.
164
+
165
+ ## Guidelines
166
+
167
+ - Only use labels that already exist in the repository
168
+ - Do not add comments or modify the issue content
169
+ - Triage only the current issue
170
+ - Identify only one area/ label
171
+ - Identify only one kind/ label
172
+ - Identify all applicable sub-area/* and priority/* labels based on the issue content. It's ok to have multiple of these
173
+ - Once you categorize the issue if it needs information bump down the priority by 1 eg.. a p0 would become a p1 a p1 would become a p2. P2 and P3 can stay as is in this scenario
174
+ - Reference all shell variables as "${VAR}" (with quotes and braces)
175
+ - Output only valid JSON format
176
+ - Do not include any explanation or additional text, just the JSON
177
+
178
+ Categorization Guidelines:
179
+ P0: Critical / Blocker
180
+ - A P0 bug is a catastrophic failure that demands immediate attention.
181
+ - To be a P0 it means almost all users are running into this issue and it is blocking users from being able to use the product.
182
+ - You would see this in the form of many comments from different developers on the bug.
183
+ - It represents a complete showstopper for a significant portion of users or for the development process itself.
184
+ Impact:
185
+ - Blocks development or testing for the entire team.
186
+ - Major security vulnerability that could compromise user data or system integrity.
187
+ - Causes data loss or corruption with no workaround.
188
+ - Crashes the application or makes a core feature completely unusable for all or most users in a production environment. Will it cause severe quality degration? Is it preventing contributors from contributing to the repository or is it a release blocker?
189
+ Qualifier: Is the main function of the software broken?
190
+ Example: The gemini auth login command fails with an unrecoverable error, preventing any user from authenticating and using the rest of the CLI.
191
+ P1: High
192
+ - A P1 bug is a serious issue that significantly degrades the user experience or impacts a core feature.
193
+ - While not a complete blocker, it's a major problem that needs a fast resolution. Feature requests are almost never P1.
194
+ - Once again this would be affecting many users.
195
+ - You would see this in the form of comments from different developers on the bug.
196
+ Impact:
197
+ - A core feature is broken or behaving incorrectly for a large number of users or large number of use cases.
198
+ - Review the bug details and comments to try figure out if this issue affects a large set of use cases or if it's a narrow set of use cases.
199
+ - Severe performance degradation making the application frustratingly slow.
200
+ - No straightforward workaround exists, or the workaround is difficult and non-obvious.
201
+ Qualifier: Is a key feature unusable or giving very wrong results?
202
+ Example: Gemini CLI enters a loop when making read-many-files tool call. I am unable to break out of the loop and gemini doesn't follow instructions subsequently.
203
+ P2: Medium
204
+ - A P2 bug is a moderately impactful issue. It's a noticeable problem but doesn't prevent the use of the software's main functionality.
205
+ Impact:
206
+ - Affects a non-critical feature or a smaller, specific subset of users.
207
+ - An inconvenient but functional workaround is available and easy to execute.
208
+ - Noticeable UI/UX problems that don't break functionality but look unprofessional (e.g., elements are misaligned or overlapping).
209
+ Qualifier: Is it an annoying but non-blocking problem?
210
+ Example: An error message is unclear or contains a typo, causing user confusion but not halting their workflow.
211
+ P3: Low
212
+ - A P3 bug is a minor, low-impact issue that is trivial or cosmetic. It has little to no effect on the overall functionality of the application.
213
+ Impact:
214
+ - Minor cosmetic issues like color inconsistencies, typos in documentation, or slight alignment problems on a non-critical page.
215
+ - An edge-case bug that is very difficult to reproduce and affects a tiny fraction of users.
216
+ Qualifier: Is it a "nice-to-fix" issue?
217
+ Example: Spelling mistakes etc.
218
+ Things you should know:
219
+ - If users are talking about issues where the model gets downgraded from pro to flash then i want you to categorize that as a performance issue
220
+ - This product is designed to use different models eg.. using pro, downgrading to flash etc. when users report that they dont expect the model to change those would be categorized as feature requests.
221
+ Definition of Areas
222
+ area/ux:
223
+ - Issues concerning user-facing elements like command usability, interactive features, help docs, and perceived performance.
224
+ - I am seeing my screen flicker when using Gemini CLI
225
+ - I am seeing the output malformed
226
+ - Theme changes aren't taking effect
227
+ - My keyboard inputs arent' being recognzied
228
+ area/platform:
229
+ - Issues related to installation, packaging, OS compatibility (Windows, macOS, Linux), and the underlying CLI framework.
230
+ area/background: Issues related to long-running background tasks, daemons, and autonomous or proactive agent features.
231
+ area/models:
232
+ - i am not getting a response that is reasonable or expected. this can include things like
233
+ - I am calling a tool and the tool is not performing as expected.
234
+ - i am expecting a tool to be called and it is not getting called ,
235
+ - Including experience when using
236
+ - built-in tools (e.g., web search, code interpreter, read file, writefile, etc..),
237
+ - Function calling issues should be under this area
238
+ - i am getting responses from the model that are malformed.
239
+ - Issues concerning Gemini quality of response and inference,
240
+ - Issues talking about unnecessary token consumption.
241
+ - Issues talking about Model getting stuck in a loop be watchful as this could be the root cause for issues that otherwise seem like model performance issues.
242
+ - Memory compression
243
+ - unexpected responses,
244
+ - poor quality of generated code
245
+ area/tools:
246
+ - These are primarily issues related to Model Context Protocol
247
+ - These are issues that mention MCP support
248
+ - feature requests asking for support for new tools.
249
+ area/core: Issues with fundamental components like command parsing, configuration management, session state, and the main API client logic. Introducing multi-modality
250
+ area/contribution: Issues related to improving the developer contribution experience, such as CI/CD pipelines, build scripts, and test automation infrastructure.
251
+ area/authentication: Issues related to user identity, login flows, API key handling, credential storage, and access token management, unable to sign in selecting wrong authentication path etc..
252
+ area/security-privacy: Issues concerning vulnerability patching, dependency security, data sanitization, privacy controls, and preventing unauthorized data access.
253
+ area/extensibility: Issues related to the plugin system, extension APIs, or making the CLI's functionality available in other applications, github actions, ide support etc..
254
+ area/performance: Issues focused on model performance
255
+ - Issues with running out of capacity,
256
+ - 429 errors etc..
257
+ - could also pertain to latency,
258
+ - other general software performance like, memory usage, CPU consumption, and algorithmic efficiency.
259
+ - Switching models from one to the other unexpectedly.
260
+
261
+ - name: 'Apply Labels to Issue'
262
+ if: |-
263
+ ${{ steps.gemini_issue_analysis.outputs.summary != '' }}
264
+ env:
265
+ REPOSITORY: '${{ github.repository }}'
266
+ ISSUE_NUMBER: '${{ github.event.issue.number || github.event.inputs.issue_number }}'
267
+ LABELS_OUTPUT: '${{ steps.gemini_issue_analysis.outputs.summary }}'
268
+ uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea'
269
+ with:
270
+ github-token: '${{ steps.generate_token.outputs.token }}'
271
+ script: |-
272
+ // Strip code block markers if present
273
+ const rawLabels = process.env.LABELS_OUTPUT;
274
+ core.info(`Raw labels JSON: ${rawLabels}`);
275
+ let parsedLabels;
276
+ try {
277
+ const jsonMatch = rawLabels.match(/```json\s*([\s\S]*?)\s*```/);
278
+ if (!jsonMatch || !jsonMatch[1]) {
279
+ throw new Error("Could not find a ```json ... ``` block in the output.");
280
+ }
281
+ const jsonString = jsonMatch[1].trim();
282
+ parsedLabels = JSON.parse(jsonString);
283
+ core.info(`Parsed labels JSON: ${JSON.stringify(parsedLabels)}`);
284
+ } catch (err) {
285
+ core.setFailed(`Failed to parse labels JSON from Gemini output: ${err.message}\nRaw output: ${rawLabels}`);
286
+ return;
287
+ }
288
+
289
+ const issueNumber = parseInt(process.env.ISSUE_NUMBER);
290
+ const explanation = parsedLabels.explanation || '';
291
+
292
+ // Set labels based on triage result
293
+ if (parsedLabels.labels_to_set && parsedLabels.labels_to_set.length > 0) {
294
+ await github.rest.issues.setLabels({
295
+ owner: context.repo.owner,
296
+ repo: context.repo.repo,
297
+ issue_number: issueNumber,
298
+ labels: parsedLabels.labels_to_set
299
+ });
300
+ const explanationInfo = explanation ? ` - ${explanation}` : '';
301
+ core.info(`Successfully set labels for #${issueNumber}: ${parsedLabels.labels_to_set.join(', ')}${explanationInfo}`);
302
+ } else {
303
+ // If no labels to set, leave the issue as is
304
+ const explanationInfo = explanation ? ` - ${explanation}` : '';
305
+ core.info(`No labels to set for #${issueNumber}, leaving as is${explanationInfo}`);
306
+ }
307
+
308
+ if (explanation) {
309
+ await github.rest.issues.createComment({
310
+ owner: context.repo.owner,
311
+ repo: context.repo.repo,
312
+ issue_number: issueNumber,
313
+ body: explanation,
314
+ });
315
+ }
316
+
317
+ - name: 'Post Issue Analysis Failure Comment'
318
+ if: |-
319
+ ${{ failure() && steps.gemini_issue_analysis.outcome == 'failure' }}
320
+ env:
321
+ ISSUE_NUMBER: '${{ github.event.issue.number || github.event.inputs.issue_number }}'
322
+ RUN_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
323
+ uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea'
324
+ with:
325
+ github-token: '${{ steps.generate_token.outputs.token }}'
326
+ script: |-
327
+ github.rest.issues.createComment({
328
+ owner: context.repo.owner,
329
+ repo: context.repo.repo,
330
+ issue_number: parseInt(process.env.ISSUE_NUMBER),
331
+ body: 'There is a problem with the Gemini CLI issue triaging. Please check the [action logs](${process.env.RUN_URL}) for details.'
332
+ })
projects/gemini-cli/.github/workflows/gemini-scheduled-issue-dedup.yml ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: '📋 Gemini Scheduled Issue Deduplication'
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 * * * *' # Runs every hour
6
+ workflow_dispatch:
7
+
8
+ concurrency:
9
+ group: '${{ github.workflow }}'
10
+ cancel-in-progress: true
11
+
12
+ defaults:
13
+ run:
14
+ shell: 'bash'
15
+
16
+ jobs:
17
+ refresh-embeddings:
18
+ if: |-
19
+ ${{ vars.TRIAGE_DEDUPLICATE_ISSUES != '' && github.repository == 'google-gemini/gemini-cli' }}
20
+ permissions:
21
+ contents: 'read'
22
+ id-token: 'write' # Required for WIF, see https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-google-cloud-platform#adding-permissions-settings
23
+ issues: 'read'
24
+ statuses: 'read'
25
+ packages: 'read'
26
+ timeout-minutes: 20
27
+ runs-on: 'ubuntu-latest'
28
+ steps:
29
+ - name: 'Checkout'
30
+ uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
31
+
32
+ - name: 'Log in to GitHub Container Registry'
33
+ uses: 'docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1' # ratchet:docker/login-action@v3
34
+ with:
35
+ registry: 'ghcr.io'
36
+ username: '${{ github.actor }}'
37
+ password: '${{ secrets.GITHUB_TOKEN }}'
38
+
39
+ - name: 'Run Gemini Issue Deduplication Refresh'
40
+ uses: 'google-github-actions/run-gemini-cli@a3bf79042542528e91937b3a3a6fbc4967ee3c31' # ratchet:google-github-actions/run-gemini-cli@v0
41
+ id: 'gemini_refresh_embeddings'
42
+ env:
43
+ GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
44
+ ISSUE_TITLE: '${{ github.event.issue.title }}'
45
+ ISSUE_BODY: '${{ github.event.issue.body }}'
46
+ ISSUE_NUMBER: '${{ github.event.issue.number }}'
47
+ REPOSITORY: '${{ github.repository }}'
48
+ FIRESTORE_PROJECT: '${{ vars.FIRESTORE_PROJECT }}'
49
+ with:
50
+ gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
51
+ gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
52
+ gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
53
+ gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
54
+ gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
55
+ use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
56
+ use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
57
+ settings: |-
58
+ {
59
+ "mcpServers": {
60
+ "issue_deduplication": {
61
+ "command": "docker",
62
+ "args": [
63
+ "run",
64
+ "-i",
65
+ "--rm",
66
+ "--network", "host",
67
+ "-e", "GITHUB_TOKEN",
68
+ "-e", "GEMINI_API_KEY",
69
+ "-e", "DATABASE_TYPE",
70
+ "-e", "FIRESTORE_DATABASE_ID",
71
+ "-e", "GCP_PROJECT",
72
+ "-e", "GOOGLE_APPLICATION_CREDENTIALS=/app/gcp-credentials.json",
73
+ "-v", "${GOOGLE_APPLICATION_CREDENTIALS}:/app/gcp-credentials.json",
74
+ "ghcr.io/google-gemini/gemini-cli-issue-triage@sha256:e3de1523f6c83aabb3c54b76d08940a2bf42febcb789dd2da6f95169641f94d3"
75
+ ],
76
+ "env": {
77
+ "GITHUB_TOKEN": "${GITHUB_TOKEN}",
78
+ "GEMINI_API_KEY": "${{ secrets.GEMINI_API_KEY }}",
79
+ "DATABASE_TYPE":"firestore",
80
+ "GCP_PROJECT": "${FIRESTORE_PROJECT}",
81
+ "FIRESTORE_DATABASE_ID": "(default)",
82
+ "GOOGLE_APPLICATION_CREDENTIALS": "${GOOGLE_APPLICATION_CREDENTIALS}"
83
+ },
84
+ "enabled": true,
85
+ "timeout": 600000
86
+ }
87
+ },
88
+ "maxSessionTurns": 25,
89
+ "coreTools": [
90
+ "run_shell_command(echo)"
91
+ ],
92
+ "telemetry": {
93
+ "enabled": true,
94
+ "target": "gcp"
95
+ }
96
+ }
97
+ prompt: |-
98
+ ## Role
99
+
100
+ You are a database maintenance assistant for a GitHub issue deduplication system.
101
+
102
+ ## Goal
103
+
104
+ Your sole responsibility is to refresh the embeddings for all open issues in the repository to ensure the deduplication database is up-to-date.
105
+
106
+ ## Steps
107
+
108
+ 1. **Extract Repository Information:** The repository is ${{ github.repository }}.
109
+ 2. **Refresh Embeddings:** Call the `refresh` tool with the correct `repo`. Do not use the `force` parameter.
110
+ 3. **Log Output:** Print the JSON output from the `refresh` tool to the logs.
111
+
112
+ ## Guidelines
113
+
114
+ - Only use the `refresh` tool.
115
+ - Do not attempt to find duplicates or modify any issues.
116
+ - Your only task is to call the `refresh` tool and log its output.
projects/gemini-cli/.github/workflows/gemini-scheduled-issue-triage.yml ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: '📋 Gemini Scheduled Issue Triage'
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 * * * *' # Runs every hour
6
+ workflow_dispatch:
7
+
8
+ concurrency:
9
+ group: '${{ github.workflow }}'
10
+ cancel-in-progress: true
11
+
12
+ defaults:
13
+ run:
14
+ shell: 'bash'
15
+
16
+ permissions:
17
+ id-token: 'write'
18
+ issues: 'write'
19
+
20
+ jobs:
21
+ triage-issues:
22
+ timeout-minutes: 10
23
+ if: |-
24
+ ${{ github.repository == 'google-gemini/gemini-cli' }}
25
+ runs-on: 'ubuntu-latest'
26
+ steps:
27
+ - name: 'Checkout'
28
+ uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
29
+
30
+ - name: 'Generate GitHub App Token'
31
+ id: 'generate_token'
32
+ uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b' # ratchet:actions/create-github-app-token@v2
33
+ with:
34
+ app-id: '${{ secrets.APP_ID }}'
35
+ private-key: '${{ secrets.PRIVATE_KEY }}'
36
+ permission-issues: 'write'
37
+
38
+ - name: 'Find untriaged issues'
39
+ id: 'find_issues'
40
+ env:
41
+ GITHUB_TOKEN: '${{ steps.generate_token.outputs.token }}'
42
+ GITHUB_REPOSITORY: '${{ github.repository }}'
43
+ run: |-
44
+ set -euo pipefail
45
+
46
+ echo '🔍 Finding issues without labels...'
47
+ NO_LABEL_ISSUES="$(gh issue list --repo "${GITHUB_REPOSITORY}" \
48
+ --search 'is:open is:issue no:label' --json number,title,body)"
49
+
50
+ echo '🏷️ Finding issues that need triage...'
51
+ NEED_TRIAGE_ISSUES="$(gh issue list --repo "${GITHUB_REPOSITORY}" \
52
+ --search "is:open is:issue label:\"status/need-triage\"" --limit 1000 --json number,title,body)"
53
+
54
+ echo '🔄 Merging and deduplicating issues...'
55
+ ISSUES="$(echo "${NO_LABEL_ISSUES}" "${NEED_TRIAGE_ISSUES}" | jq -c -s 'add | unique_by(.number)')"
56
+
57
+ echo '📝 Setting output for GitHub Actions...'
58
+ echo "issues_to_triage=${ISSUES}" >> "${GITHUB_OUTPUT}"
59
+
60
+ ISSUE_COUNT="$(echo "${ISSUES}" | jq 'length')"
61
+ echo "✅ Found ${ISSUE_COUNT} issues to triage! 🎯"
62
+
63
+ - name: 'Get Repository Labels'
64
+ id: 'get_labels'
65
+ uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea'
66
+ with:
67
+ github-token: '${{ steps.generate_token.outputs.token }}'
68
+ script: |-
69
+ const { data: labels } = await github.rest.issues.listLabelsForRepo({
70
+ owner: context.repo.owner,
71
+ repo: context.repo.repo,
72
+ });
73
+ const labelNames = labels.map(label => label.name);
74
+ core.setOutput('available_labels', labelNames.join(','));
75
+ core.info(`Found ${labelNames.length} labels: ${labelNames.join(', ')}`);
76
+ return labelNames;
77
+
78
+ - name: 'Run Gemini Issue Analysis'
79
+ if: |-
80
+ ${{ steps.find_issues.outputs.issues_to_triage != '[]' }}
81
+ uses: 'google-github-actions/run-gemini-cli@a3bf79042542528e91937b3a3a6fbc4967ee3c31' # ratchet:google-github-actions/run-gemini-cli@v0
82
+ id: 'gemini_issue_analysis'
83
+ env:
84
+ GITHUB_TOKEN: '' # Do not pass any auth token here since this runs on untrusted inputs
85
+ ISSUES_TO_TRIAGE: '${{ steps.find_issues.outputs.issues_to_triage }}'
86
+ REPOSITORY: '${{ github.repository }}'
87
+ AVAILABLE_LABELS: '${{ steps.get_labels.outputs.available_labels }}'
88
+ with:
89
+ gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
90
+ gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
91
+ gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
92
+ gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
93
+ gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
94
+ use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
95
+ use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
96
+ settings: |-
97
+ {
98
+ "maxSessionTurns": 25,
99
+ "coreTools": [
100
+ "run_shell_command(echo)"
101
+ ],
102
+ "telemetry": {
103
+ "enabled": true,
104
+ "target": "gcp"
105
+ }
106
+ }
107
+ prompt: |-
108
+ ## Role
109
+
110
+ You are an issue triage assistant. Analyze issues and identify
111
+ appropriate labels. Use the available tools to gather information;
112
+ do not ask for information to be provided.
113
+
114
+ ## Steps
115
+
116
+ 1. You are only able to use the echo command. Review the available labels in the environment variable: "${AVAILABLE_LABELS}".
117
+ 2. Check environment variable for issues to triage: $ISSUES_TO_TRIAGE (JSON array of issues)
118
+ 3. Review the issue title, body and any comments provided in the environment variables.
119
+ 4. Identify the most relevant labels from the existing labels, focusing on kind/*, area/*, sub-area/* and priority/*.
120
+ 5. If the issue already has area/ label, dont try to change it. Similarly, if the issue already has a kind/ label don't change it. And if the issue already has a priority/ label do not change it for example:
121
+ If an issue has area/core and kind/bug you will only add a priority/ label.
122
+ Instead if an issue has no labels, you will could add one lable of each kind.
123
+ 6. Identify other applicable labels based on the issue content, such as status/*, help wanted, good first issue, etc.
124
+ 7. For area/* and kind/* limit yourself to only the single most applicable label in each case.
125
+ 8. Give me a single short explanation about why you are selecting each label in the process.
126
+ 9. Output a JSON array of objects, each containing the issue number
127
+ and the labels to add and remove, along with an explanation. For example:
128
+ ```
129
+ [
130
+ {
131
+ "issue_number": 123,
132
+ "labels_to_add": ["kind/bug", "priority/p2"],
133
+ "labels_to_remove": ["status/need-triage"],
134
+ "explanation": "This issue is a bug that needs to be addressed with medium priority."
135
+ },
136
+ {
137
+ "issue_number": 456,
138
+ "labels_to_add": ["kind/enhancement"],
139
+ "labels_to_remove": [],
140
+ "explanation": "This issue is an enhancement request that could improve the user experience."
141
+ }
142
+ ]
143
+ ```
144
+ If an issue cannot be classified, do not include it in the output array.
145
+ 10. For each issue please check if CLI version is present, this is usually in the output of the /about command and will look like 0.1.5
146
+ - Anything more than 6 versions older than the most recent should add the status/need-retesting label
147
+ 11. If you see that the issue doesn't look like it has sufficient information recommend the status/need-information label and leave a comment politely requesting the relevant information, eg.. if repro steps are missing request for repro steps. if version information is missing request for version information into the explanation section below.
148
+ - After identifying appropriate labels to an issue, add "status/need-triage" label to labels_to_remove in the output.
149
+ 12. If you think an issue might be a Priority/P0 do not apply the priority/p0 label. Instead apply a status/manual-triage label and include a note in your explanation.
150
+ 13. If you are uncertain and have not been able to apply one each of kind/, area/ and priority/ , apply the status/manual-triage label.
151
+
152
+ ## Guidelines
153
+
154
+ - Output only valid JSON format
155
+ - Do not include any explanation or additional text, just the JSON
156
+ - Only use labels that already exist in the repository.
157
+ - Do not add comments or modify the issue content.
158
+ - Do not remove the following labels maintainer, help wanted or good first issue.
159
+ - Triage only the current issue.
160
+ - Identify only one area/ label
161
+ - Identify only one kind/ label (Do not apply kind/duplicate or kind/parent-issue)
162
+ - Identify all applicable sub-area/* and priority/* labels based on the issue content. It's ok to have multiple of these.
163
+ - Once you categorize the issue if it needs information bump down the priority by 1 eg.. a p0 would become a p1 a p1 would become a p2. P2 and P3 can stay as is in this scenario.
164
+ Categorization Guidelines:
165
+ P0: Critical / Blocker
166
+ - A P0 bug is a catastrophic failure that demands immediate attention.
167
+ - To be a P0 it means almost all users are running into this issue and it is blocking users from being able to use the product.
168
+ - You would see this in the form of many comments from different developers on the bug.
169
+ - It represents a complete showstopper for a significant portion of users or for the development process itself.
170
+ Impact:
171
+ - Blocks development or testing for the entire team.
172
+ - Major security vulnerability that could compromise user data or system integrity.
173
+ - Causes data loss or corruption with no workaround.
174
+ - Crashes the application or makes a core feature completely unusable for all or most users in a production environment. Will it cause severe quality degration?
175
+ - Is it preventing contributors from contributing to the repository or is it a release blocker?
176
+ Qualifier: Is the main function of the software broken?
177
+ Example: The gemini auth login command fails with an unrecoverable error, preventing any user from authenticating and using the rest of the CLI.
178
+ P1: High
179
+ - A P1 bug is a serious issue that significantly degrades the user experience or impacts a core feature.
180
+ - While not a complete blocker, it's a major problem that needs a fast resolution. Feature requests are almost never P1.
181
+ - Once again this would be affecting many users.
182
+ - You would see this in the form of comments from different developers on the bug.
183
+ Impact:
184
+ - A core feature is broken or behaving incorrectly for a large number of users or large number of use cases.
185
+ - Review the bug details and comments to try figure out if this issue affects a large set of use cases or if it's a narrow set of use cases.
186
+ - Severe performance degradation making the application frustratingly slow.
187
+ - No straightforward workaround exists, or the workaround is difficult and non-obvious.
188
+ Qualifier: Is a key feature unusable or giving very wrong results?
189
+ Example: Gemini CLI enters a loop when making read-many-files tool call. I am unable to break out of the loop and gemini doesn't follow instructions subsequently.
190
+ P2: Medium
191
+ - A P2 bug is a moderately impactful issue. It's a noticeable problem but doesn't prevent the use of the software's main functionality.
192
+ Impact:
193
+ - Affects a non-critical feature or a smaller, specific subset of users.
194
+ - An inconvenient but functional workaround is available and easy to execute.
195
+ - Noticeable UI/UX problems that don't break functionality but look unprofessional (e.g., elements are misaligned or overlapping).
196
+ Qualifier: Is it an annoying but non-blocking problem?
197
+ Example: An error message is unclear or contains a typo, causing user confusion but not halting their workflow.
198
+ P3: Low
199
+ - A P3 bug is a minor, low-impact issue that is trivial or cosmetic. It has little to no effect on the overall functionality of the application.
200
+ Impact:
201
+ - Minor cosmetic issues like color inconsistencies, typos in documentation, or slight alignment problems on a non-critical page.
202
+ - An edge-case bug that is very difficult to reproduce and affects a tiny fraction of users.
203
+ Qualifier: Is it a "nice-to-fix" issue?
204
+ Example: Spelling mistakes etc.
205
+ Additional Context:
206
+ - If users are talking about issues where the model gets downgraded from pro to flash then i want you to categorize that as a performance issue
207
+ - This product is designed to use different models eg.. using pro, downgrading to flash etc.
208
+ - When users report that they dont expect the model to change those would be categorized as feature requests.
209
+ Definition of Areas
210
+ area/ux:
211
+ - Issues concerning user-facing elements like command usability, interactive features, help docs, and perceived performance.
212
+ - I am seeing my screen flicker when using Gemini CLI
213
+ - I am seeing the output malformed
214
+ - Theme changes aren't taking effect
215
+ - My keyboard inputs arent' being recognzied
216
+ area/platform:
217
+ - Issues related to installation, packaging, OS compatibility (Windows, macOS, Linux), and the underlying CLI framework.
218
+ area/background: Issues related to long-running background tasks, daemons, and autonomous or proactive agent features.
219
+ area/models:
220
+ - i am not getting a response that is reasonable or expected. this can include things like
221
+ - I am calling a tool and the tool is not performing as expected.
222
+ - i am expecting a tool to be called and it is not getting called ,
223
+ - Including experience when using
224
+ - built-in tools (e.g., web search, code interpreter, read file, writefile, etc..),
225
+ - Function calling issues should be under this area
226
+ - i am getting responses from the model that are malformed.
227
+ - Issues concerning Gemini quality of response and inference,
228
+ - Issues talking about unnecessary token consumption.
229
+ - Issues talking about Model getting stuck in a loop be watchful as this could be the root cause for issues that otherwise seem like model performance issues.
230
+ - Memory compression
231
+ - unexpected responses,
232
+ - poor quality of generated code
233
+ area/tools:
234
+ - These are primarily issues related to Model Context Protocol
235
+ - These are issues that mention MCP support
236
+ - feature requests asking for support for new tools.
237
+ area/core:
238
+ - Issues with fundamental components like command parsing, configuration management, session state, and the main API client logic. Introducing multi-modality
239
+ area/contribution:
240
+ - Issues related to improving the developer contribution experience, such as CI/CD pipelines, build scripts, and test automation infrastructure.
241
+ area/authentication:
242
+ - Issues related to user identity, login flows, API key handling, credential storage, and access token management, unable to sign in selecting wrong authentication path etc..
243
+ area/security-privacy:
244
+ - Issues concerning vulnerability patching, dependency security, data sanitization, privacy controls, and preventing unauthorized data access.
245
+ area/extensibility:
246
+ - Issues related to the plugin system, extension APIs, or making the CLI's functionality available in other applications, github actions, ide support etc..
247
+ area/performance:
248
+ - Issues focused on model performance
249
+ - Issues with running out of capacity,
250
+ - 429 errors etc..
251
+ - could also pertain to latency,
252
+ - other general software performance like, memory usage, CPU consumption, and algorithmic efficiency.
253
+ - Switching models from one to the other unexpectedly.
254
+
255
+ - name: 'Apply Labels to Issues'
256
+ if: |-
257
+ ${{ steps.gemini_issue_analysis.outcome == 'success' &&
258
+ steps.gemini_issue_analysis.outputs.summary != '[]' }}
259
+ env:
260
+ REPOSITORY: '${{ github.repository }}'
261
+ LABELS_OUTPUT: '${{ steps.gemini_issue_analysis.outputs.summary }}'
262
+ uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea'
263
+ with:
264
+ github-token: '${{ steps.generate_token.outputs.token }}'
265
+ script: |-
266
+ const rawLabels = process.env.LABELS_OUTPUT;
267
+ core.info(`Raw labels JSON: ${rawLabels}`);
268
+ let parsedLabels;
269
+ try {
270
+ const jsonMatch = rawLabels.match(/```json\s*([\s\S]*?)\s*```/);
271
+ if (!jsonMatch || !jsonMatch[1]) {
272
+ throw new Error("Could not find a ```json ... ``` block in the output.");
273
+ }
274
+ const jsonString = jsonMatch[1].trim();
275
+ parsedLabels = JSON.parse(jsonString);
276
+ core.info(`Parsed labels JSON: ${JSON.stringify(parsedLabels)}`);
277
+ } catch (err) {
278
+ core.setFailed(`Failed to parse labels JSON from Gemini output: ${err.message}\nRaw output: ${rawLabels}`);
279
+ return;
280
+ }
281
+
282
+ for (const entry of parsedLabels) {
283
+ const issueNumber = entry.issue_number;
284
+ if (!issueNumber) {
285
+ core.info(`Skipping entry with no issue number: ${JSON.stringify(entry)}`);
286
+ continue;
287
+ }
288
+
289
+ if (entry.labels_to_add && entry.labels_to_add.length > 0) {
290
+ await github.rest.issues.addLabels({
291
+ owner: context.repo.owner,
292
+ repo: context.repo.repo,
293
+ issue_number: issueNumber,
294
+ labels: entry.labels_to_add
295
+ });
296
+ const explanation = entry.explanation ? ` - ${entry.explanation}` : '';
297
+ core.info(`Successfully added labels for #${issueNumber}: ${entry.labels_to_add.join(', ')}${explanation}`);
298
+ }
299
+
300
+ if (entry.labels_to_remove && entry.labels_to_remove.length > 0) {
301
+ for (const label of entry.labels_to_remove) {
302
+ try {
303
+ await github.rest.issues.removeLabel({
304
+ owner: context.repo.owner,
305
+ repo: context.repo.repo,
306
+ issue_number: issueNumber,
307
+ name: label
308
+ });
309
+ } catch (error) {
310
+ if (error.status !== 404) {
311
+ throw error;
312
+ }
313
+ }
314
+ }
315
+ core.info(`Successfully removed labels for #${issueNumber}: ${entry.labels_to_remove.join(', ')}`);
316
+ }
317
+
318
+ if (entry.explanation) {
319
+ await github.rest.issues.createComment({
320
+ owner: context.repo.owner,
321
+ repo: context.repo.repo,
322
+ issue_number: issueNumber,
323
+ body: entry.explanation,
324
+ });
325
+ }
326
+
327
+ if ((!entry.labels_to_add || entry.labels_to_add.length === 0) && (!entry.labels_to_remove || entry.labels_to_remove.length === 0)) {
328
+ core.info(`No labels to add or remove for #${issueNumber}, leaving as is`);
329
+ }
330
+ }
projects/gemini-cli/.github/workflows/gemini-scheduled-pr-triage.yml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Gemini Scheduled PR Triage 🚀'
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '*/15 * * * *' # Runs every 15 minutes
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ audit-prs:
10
+ timeout-minutes: 15
11
+ if: |-
12
+ ${{ github.repository == 'google-gemini/gemini-cli' }}
13
+ permissions:
14
+ contents: 'read'
15
+ id-token: 'write'
16
+ issues: 'write'
17
+ pull-requests: 'write'
18
+ runs-on: 'ubuntu-latest'
19
+ outputs:
20
+ prs_needing_comment: '${{ steps.run_triage.outputs.prs_needing_comment }}'
21
+ steps:
22
+ - name: 'Checkout'
23
+ uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
24
+
25
+ - name: 'Generate GitHub App Token'
26
+ id: 'generate_token'
27
+ uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b' # ratchet:actions/create-github-app-token@v2
28
+ with:
29
+ app-id: '${{ secrets.APP_ID }}'
30
+ private-key: '${{ secrets.PRIVATE_KEY }}'
31
+ permission-issues: 'write'
32
+ permission-pull-requests: 'write'
33
+
34
+ - name: 'Run PR Triage Script'
35
+ id: 'run_triage'
36
+ shell: 'bash'
37
+ env:
38
+ GITHUB_TOKEN: '${{ steps.generate_token.outputs.token }}'
39
+ GITHUB_REPOSITORY: '${{ github.repository }}'
40
+ run: |-
41
+ ./.github/scripts/pr-triage.sh
projects/gemini-cli/.github/workflows/gemini-self-assign-issue.yml ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Assign Issue on Comment'
2
+
3
+ on:
4
+ issue_comment:
5
+ types:
6
+ - 'created'
7
+
8
+ concurrency:
9
+ group: '${{ github.workflow }}-${{ github.event.issue.number }}'
10
+ cancel-in-progress: true
11
+
12
+ defaults:
13
+ run:
14
+ shell: 'bash'
15
+
16
+ permissions:
17
+ contents: 'read'
18
+ id-token: 'write'
19
+ issues: 'write'
20
+ statuses: 'write'
21
+ packages: 'read'
22
+
23
+ jobs:
24
+ self-assign-issue:
25
+ if: |-
26
+ github.repository == 'google-gemini/gemini-cli' &&
27
+ github.event_name == 'issue_comment' &&
28
+ contains(github.event.comment.body, '/assign')
29
+ runs-on: 'ubuntu-latest'
30
+ steps:
31
+ - name: 'Generate GitHub App Token'
32
+ id: 'generate_token'
33
+ uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b'
34
+ with:
35
+ app-id: '${{ secrets.APP_ID }}'
36
+ private-key: '${{ secrets.PRIVATE_KEY }}'
37
+ # Add 'assignments' write permission
38
+ permission-issues: 'write'
39
+
40
+ - name: 'Assign issue to user'
41
+ uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea'
42
+ with:
43
+ github-token: '${{ steps.generate_token.outputs.token }}'
44
+ script: |
45
+ const issueNumber = context.issue.number;
46
+ const commenter = context.actor;
47
+ const owner = context.repo.owner;
48
+ const repo = context.repo.repo;
49
+ const MAX_ISSUES_ASSIGNED = 3;
50
+
51
+ // Search for open issues already assigned to the commenter in this repo
52
+ const { data: assignedIssues } = await github.rest.search.issuesAndPullRequests({
53
+ q: `is:issue repo:${owner}/${repo} assignee:${commenter} is:open`
54
+ });
55
+
56
+ if (assignedIssues.total_count >= MAX_ISSUES_ASSIGNED) {
57
+ await github.rest.issues.createComment({
58
+ owner: owner,
59
+ repo: repo,
60
+ issue_number: issueNumber,
61
+ body: `👋 @${commenter}! You currently have ${assignedIssues.total_count} issues assigned to you. We have a ${MAX_ISSUES_ASSIGNED} max issues assigned at once policy. Once you close out an existing issue it will open up space to take another. You can also unassign yourself from an existing issue but please work on a hand-off if someone is expecting work on that issue.`
62
+ });
63
+ return; // exit
64
+ }
65
+
66
+ // Check if the issue is already assigned
67
+ const issue = await github.rest.issues.get({
68
+ owner: context.repo.owner,
69
+ repo: context.repo.repo,
70
+ issue_number: issueNumber,
71
+ });
72
+
73
+ if (issue.data.assignees.length > 0) {
74
+ // Comment that it's already assigned
75
+ await github.rest.issues.createComment({
76
+ owner: context.repo.owner,
77
+ repo: context.repo.repo,
78
+ issue_number: issueNumber,
79
+ body: `@${commenter} Thanks for taking interest but this issue is already assigned. We'd still love to have you contribute. Check out our [Help Wanted](https://github.com/google-gemini/gemini-cli/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22help%20wanted%22) list for issues where we need some extra attention.`
80
+ });
81
+ return;
82
+ }
83
+
84
+ // If not taken, assign the user who commented
85
+ await github.rest.issues.addAssignees({
86
+ owner: context.repo.owner,
87
+ repo: context.repo.repo,
88
+ issue_number: issueNumber,
89
+ assignees: [commenter]
90
+ });
91
+
92
+ // Post a comment to confirm assignment
93
+ await github.rest.issues.createComment({
94
+ owner: context.repo.owner,
95
+ repo: context.repo.repo,
96
+ issue_number: issueNumber,
97
+ body: `👋 @${commenter}, you've been assigned to this issue! Thank you for taking the time to contribute. Make sure to check out our [contributing guidelines](https://github.com/google-gemini/gemini-cli/blob/main/CONTRIBUTING.md).`
98
+ });
projects/gemini-cli/.github/workflows/no-response.yml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'No Response'
2
+
3
+ # Run as a daily cron at 1:45 AM
4
+ on:
5
+ schedule:
6
+ - cron: '45 1 * * *'
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ no-response:
11
+ runs-on: 'ubuntu-latest'
12
+ if: |-
13
+ ${{ github.repository == 'google-gemini/gemini-cli' }}
14
+ permissions:
15
+ issues: 'write'
16
+ pull-requests: 'write'
17
+ concurrency:
18
+ group: '${{ github.workflow }}-no-response'
19
+ cancel-in-progress: true
20
+ steps:
21
+ - uses: 'actions/stale@5bef64f19d7facfb25b37b414482c7164d639639' # ratchet:actions/stale@v9
22
+ with:
23
+ repo-token: '${{ secrets.GITHUB_TOKEN }}'
24
+ days-before-stale: -1
25
+ days-before-close: 14
26
+ stale-issue-label: 'status/need-information'
27
+ close-issue-message: >-
28
+ This issue was marked as needing more information and has not received a response in 14 days.
29
+ Closing it for now. If you still face this problem, feel free to reopen with more details. Thank you!
30
+ stale-pr-label: 'status/need-information'
31
+ close-pr-message: >-
32
+ This pull request was marked as needing more information and has had no updates in 14 days.
33
+ Closing it for now. You are welcome to reopen with the required info. Thanks for contributing!
projects/gemini-cli/.github/workflows/release.yml ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Release'
2
+
3
+ on:
4
+ schedule:
5
+ # Runs every day at midnight UTC for the nightly release.
6
+ - cron: '0 0 * * *'
7
+ # Runs every Tuesday at 23:59 UTC for the preview release.
8
+ - cron: '59 23 * * 2'
9
+ workflow_dispatch:
10
+ inputs:
11
+ version:
12
+ description: 'The version to release (e.g., v0.1.11). Required for manual patch releases.'
13
+ required: false # Not required for scheduled runs
14
+ type: 'string'
15
+ ref:
16
+ description: 'The branch or ref (full git sha) to release from.'
17
+ required: true
18
+ type: 'string'
19
+ default: 'main'
20
+ dry_run:
21
+ description: 'Run a dry-run of the release process; no branches, npm packages or GitHub releases will be created.'
22
+ required: true
23
+ type: 'boolean'
24
+ default: true
25
+ create_nightly_release:
26
+ description: 'Auto apply the nightly release tag, input version is ignored.'
27
+ required: false
28
+ type: 'boolean'
29
+ default: false
30
+ create_preview_release:
31
+ description: 'Auto apply the preview release tag, input version is ignored.'
32
+ required: false
33
+ type: 'boolean'
34
+ default: false
35
+ force_skip_tests:
36
+ description: 'Select to skip the "Run Tests" step in testing. Prod releases should run tests'
37
+ required: false
38
+ type: 'boolean'
39
+ default: false
40
+
41
+ jobs:
42
+ release:
43
+ runs-on: 'ubuntu-latest'
44
+ environment:
45
+ name: 'production-release'
46
+ url: '${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.version.outputs.RELEASE_TAG }}'
47
+ if: |-
48
+ ${{ github.repository == 'google-gemini/gemini-cli' }}
49
+ permissions:
50
+ contents: 'write'
51
+ packages: 'write'
52
+ id-token: 'write'
53
+ issues: 'write' # For creating issues on failure
54
+ outputs:
55
+ RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }}'
56
+
57
+ steps:
58
+ - name: 'Checkout'
59
+ uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
60
+ with:
61
+ ref: '${{ github.event.inputs.ref || github.sha }}'
62
+ fetch-depth: 0
63
+
64
+ - name: 'Set booleans for simplified logic'
65
+ env:
66
+ CREATE_NIGHTLY_RELEASE: '${{ github.event.inputs.create_nightly_release }}'
67
+ CREATE_PREVIEW_RELEASE: '${{ github.event.inputs.create_preview_release }}'
68
+ EVENT_NAME: '${{ github.event_name }}'
69
+ CRON: '${{ github.event.schedule }}'
70
+ DRY_RUN_INPUT: '${{ github.event.inputs.dry_run }}'
71
+ id: 'vars'
72
+ run: |-
73
+ is_nightly="false"
74
+ if [[ "${CRON}" == "0 0 * * *" || "${CREATE_NIGHTLY_RELEASE}" == "true" ]]; then
75
+ is_nightly="true"
76
+ fi
77
+ echo "is_nightly=${is_nightly}" >> "${GITHUB_OUTPUT}"
78
+
79
+ is_preview="false"
80
+ if [[ "${CRON}" == "59 23 * * 2" || "${CREATE_PREVIEW_RELEASE}" == "true" ]]; then
81
+ is_preview="true"
82
+ fi
83
+ echo "is_preview=${is_preview}" >> "${GITHUB_OUTPUT}"
84
+
85
+ is_dry_run="false"
86
+ if [[ "${DRY_RUN_INPUT}" == "true" ]]; then
87
+ is_dry_run="true"
88
+ fi
89
+ echo "is_dry_run=${is_dry_run}" >> "${GITHUB_OUTPUT}"
90
+
91
+ - name: 'Setup Node.js'
92
+ uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
93
+ with:
94
+ node-version-file: '.nvmrc'
95
+ cache: 'npm'
96
+
97
+ - name: 'Install Dependencies'
98
+ run: |-
99
+ npm ci
100
+
101
+ - name: 'Get the version'
102
+ id: 'version'
103
+ env:
104
+ GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
105
+ IS_NIGHTLY: '${{ steps.vars.outputs.is_nightly }}'
106
+ IS_PREVIEW: '${{ steps.vars.outputs.is_preview }}'
107
+ MANUAL_VERSION: '${{ inputs.version }}'
108
+ run: |-
109
+ VERSION_JSON="$(node scripts/get-release-version.js)"
110
+ echo "RELEASE_TAG=$(echo "${VERSION_JSON}" | jq -r .releaseTag)" >> "${GITHUB_OUTPUT}"
111
+ echo "RELEASE_VERSION=$(echo "${VERSION_JSON}" | jq -r .releaseVersion)" >> "${GITHUB_OUTPUT}"
112
+ echo "NPM_TAG=$(echo "${VERSION_JSON}" | jq -r .npmTag)" >> "${GITHUB_OUTPUT}"
113
+ echo "PREVIOUS_TAG=$(echo "${VERSION_JSON}" | jq -r .previousReleaseTag)" >> "${GITHUB_OUTPUT}"
114
+
115
+ - name: 'Run Tests'
116
+ if: |-
117
+ ${{ github.event.inputs.force_skip_tests != 'true' }}
118
+ env:
119
+ GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}'
120
+ run: |-
121
+ npm run preflight
122
+ npm run test:integration:sandbox:none
123
+ npm run test:integration:sandbox:docker
124
+
125
+ - name: 'Configure Git User'
126
+ run: |-
127
+ git config user.name "gemini-cli-robot"
128
+ git config user.email "gemini-cli-robot@google.com"
129
+
130
+ - name: 'Create and switch to a release branch'
131
+ id: 'release_branch'
132
+ env:
133
+ RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }}'
134
+ run: |-
135
+ BRANCH_NAME="release/${RELEASE_TAG}"
136
+ git switch -c "${BRANCH_NAME}"
137
+ echo "BRANCH_NAME=${BRANCH_NAME}" >> "${GITHUB_OUTPUT}"
138
+
139
+ - name: 'Update package versions'
140
+ env:
141
+ RELEASE_VERSION: '${{ steps.version.outputs.RELEASE_VERSION }}'
142
+ run: |-
143
+ npm run release:version "${RELEASE_VERSION}"
144
+
145
+ - name: 'Commit and Conditionally Push package versions'
146
+ env:
147
+ BRANCH_NAME: '${{ steps.release_branch.outputs.BRANCH_NAME }}'
148
+ IS_DRY_RUN: '${{ steps.vars.outputs.is_dry_run }}'
149
+ RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }}'
150
+ run: |-
151
+ git add package.json package-lock.json packages/*/package.json
152
+ git commit -m "chore(release): ${RELEASE_TAG}"
153
+ if [[ "${IS_DRY_RUN}" == "false" ]]; then
154
+ echo "Pushing release branch to remote..."
155
+ git push --set-upstream origin "${BRANCH_NAME}" --follow-tags
156
+ else
157
+ echo "Dry run enabled. Skipping push."
158
+ fi
159
+
160
+ - name: 'Build and Prepare Packages'
161
+ run: |-
162
+ npm run build:packages
163
+ npm run prepare:package
164
+
165
+ - name: 'Configure npm for publishing'
166
+ uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
167
+ with:
168
+ node-version-file: '.nvmrc'
169
+ registry-url: 'https://wombat-dressing-room.appspot.com'
170
+ scope: '@google'
171
+
172
+ - name: 'Publish @google/gemini-cli-core'
173
+ env:
174
+ IS_DRY_RUN: '${{ steps.vars.outputs.is_dry_run }}'
175
+ NODE_AUTH_TOKEN: '${{ secrets.WOMBAT_TOKEN_CORE }}'
176
+ NPM_TAG: '${{ steps.version.outputs.NPM_TAG }}'
177
+ run: |-
178
+ npm publish \
179
+ --dry-run="${IS_DRY_RUN}" \
180
+ --workspace="@google/gemini-cli-core" \
181
+ --tag="${NPM_TAG}"
182
+
183
+ - name: 'Install latest core package'
184
+ if: |-
185
+ ${{ steps.vars.outputs.is_dry_run == 'false' }}
186
+ env:
187
+ RELEASE_VERSION: '${{ steps.version.outputs.RELEASE_VERSION }}'
188
+ run: |-
189
+ npm install "@google/gemini-cli-core@${RELEASE_VERSION}" \
190
+ --workspace="@google/gemini-cli" \
191
+ --save-exact
192
+
193
+ - name: 'Publish @google/gemini-cli'
194
+ env:
195
+ IS_DRY_RUN: '${{ steps.vars.outputs.is_dry_run }}'
196
+ NODE_AUTH_TOKEN: '${{ secrets.WOMBAT_TOKEN_CLI }}'
197
+ NPM_TAG: '${{ steps.version.outputs.NPM_TAG }}'
198
+ run: |-
199
+ npm publish \
200
+ --dry-run="${IS_DRY_RUN}" \
201
+ --workspace="@google/gemini-cli" \
202
+ --tag="${NPM_TAG}"
203
+
204
+ - name: 'Create GitHub Release and Tag'
205
+ if: |-
206
+ ${{ steps.vars.outputs.is_dry_run == 'false' }}
207
+ env:
208
+ GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
209
+ RELEASE_BRANCH: '${{ steps.release_branch.outputs.BRANCH_NAME }}'
210
+ RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }}'
211
+ PREVIOUS_TAG: '${{ steps.version.outputs.PREVIOUS_TAG }}'
212
+ run: |-
213
+ gh release create "${RELEASE_TAG}" \
214
+ bundle/gemini.js \
215
+ --target "$RELEASE_BRANCH" \
216
+ --title "Release ${RELEASE_TAG}" \
217
+ --notes-start-tag "$PREVIOUS_TAG" \
218
+ --generate-notes
219
+
220
+ - name: 'Create Issue on Failure'
221
+ if: |-
222
+ ${{ failure() }}
223
+ env:
224
+ GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
225
+ RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }} || "N/A"'
226
+ DETAILS_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
227
+ run: |-
228
+ gh issue create \
229
+ --title "Release Failed for ${RELEASE_TAG} on $(date +'%Y-%m-%d')" \
230
+ --body "The release workflow failed. See the full run for details: ${DETAILS_URL}" \
231
+ --label "kind/bug,release-failure,priority/p0"
projects/gemini-cli/.github/workflows/stale.yml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Mark stale issues and pull requests'
2
+
3
+ # Run as a daily cron at 1:30 AM
4
+ on:
5
+ schedule:
6
+ - cron: '30 1 * * *'
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ stale:
11
+ runs-on: 'ubuntu-latest'
12
+ if: |-
13
+ ${{ github.repository == 'google-gemini/gemini-cli' }}
14
+ permissions:
15
+ issues: 'write'
16
+ pull-requests: 'write'
17
+ concurrency:
18
+ group: '${{ github.workflow }}-stale'
19
+ cancel-in-progress: true
20
+ steps:
21
+ - uses: 'actions/stale@5bef64f19d7facfb25b37b414482c7164d639639' # ratchet:actions/stale@v9
22
+ with:
23
+ repo-token: '${{ secrets.GITHUB_TOKEN }}'
24
+ stale-issue-message: >-
25
+ This issue has been automatically marked as stale due to 60 days of inactivity.
26
+ It will be closed in 14 days if no further activity occurs.
27
+ stale-pr-message: >-
28
+ This pull request has been automatically marked as stale due to 60 days of inactivity.
29
+ It will be closed in 14 days if no further activity occurs.
30
+ close-issue-message: >-
31
+ This issue has been closed due to 14 additional days of inactivity after being marked as stale.
32
+ If you believe this is still relevant, feel free to comment or reopen the issue. Thank you!
33
+ close-pr-message: >-
34
+ This pull request has been closed due to 14 additional days of inactivity after being marked as stale.
35
+ If this is still relevant, you are welcome to reopen or leave a comment. Thanks for contributing!
36
+ days-before-stale: 60
37
+ days-before-close: 14
38
+ exempt-issue-labels: 'pinned,security'
39
+ exempt-pr-labels: 'pinned,security'
projects/gemini-cli/docs/assets/connected_devtools.png ADDED
projects/gemini-cli/docs/assets/gemini-screenshot.png ADDED
projects/gemini-cli/docs/assets/release_patch.png ADDED
projects/gemini-cli/docs/assets/theme-ansi-light.png ADDED
projects/gemini-cli/docs/assets/theme-ansi.png ADDED
projects/gemini-cli/docs/assets/theme-atom-one.png ADDED
projects/gemini-cli/docs/assets/theme-ayu-light.png ADDED
projects/gemini-cli/docs/assets/theme-ayu.png ADDED
projects/gemini-cli/docs/assets/theme-custom.png ADDED
projects/gemini-cli/docs/assets/theme-default-light.png ADDED
projects/gemini-cli/docs/assets/theme-default.png ADDED
projects/gemini-cli/docs/assets/theme-dracula.png ADDED
projects/gemini-cli/docs/assets/theme-github-light.png ADDED
projects/gemini-cli/docs/assets/theme-github.png ADDED
projects/gemini-cli/docs/assets/theme-google-light.png ADDED
projects/gemini-cli/docs/assets/theme-xcode-light.png ADDED
projects/gemini-cli/docs/cli/authentication.md ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Authentication Setup
2
+
3
+ The Gemini CLI requires you to authenticate with Google's AI services. On initial startup you'll need to configure **one** of the following authentication methods:
4
+
5
+ 1. **Login with Google (Gemini Code Assist):**
6
+ - Use this option to log in with your Google account.
7
+ - During initial startup, Gemini CLI will direct you to a webpage for authentication. Once authenticated, your credentials will be cached locally so the web login can be skipped on subsequent runs.
8
+ - Note that the web login must be done in a browser that can communicate with the machine Gemini CLI is being run from. (Specifically, the browser will be redirected to a localhost url that Gemini CLI will be listening on).
9
+ - <a id="workspace-gca">Users may have to specify a GOOGLE_CLOUD_PROJECT if:</a>
10
+ 1. You have a Google Workspace account. Google Workspace is a paid service for businesses and organizations that provides a suite of productivity tools, including a custom email domain (e.g. your-name@your-company.com), enhanced security features, and administrative controls. These accounts are often managed by an employer or school.
11
+ 1. You have received a Gemini Code Assist license through the [Google Developer Program](https://developers.google.com/program/plans-and-pricing) (including qualified Google Developer Experts)
12
+ 1. You have been assigned a license to a current Gemini Code Assist standard or enterprise subscription.
13
+ 1. You are using the product outside the [supported regions](https://developers.google.com/gemini-code-assist/resources/available-locations) for free individual usage.
14
+ 1. You are a Google account holder under the age of 18
15
+ - If you fall into one of these categories, you must first configure a Google Cloud Project ID to use, [enable the Gemini for Cloud API](https://cloud.google.com/gemini/docs/discover/set-up-gemini#enable-api) and [configure access permissions](https://cloud.google.com/gemini/docs/discover/set-up-gemini#grant-iam).
16
+
17
+ You can temporarily set the environment variable in your current shell session using the following command:
18
+
19
+ ```bash
20
+ export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
21
+ ```
22
+ - For repeated use, you can add the environment variable to your [.env file](#persisting-environment-variables-with-env-files) or your shell's configuration file (like `~/.bashrc`, `~/.zshrc`, or `~/.profile`). For example, the following command adds the environment variable to a `~/.bashrc` file:
23
+
24
+ ```bash
25
+ echo 'export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"' >> ~/.bashrc
26
+ source ~/.bashrc
27
+ ```
28
+
29
+ 2. **<a id="gemini-api-key"></a>Gemini API key:**
30
+ - Obtain your API key from Google AI Studio: [https://aistudio.google.com/app/apikey](https://aistudio.google.com/app/apikey)
31
+ - Set the `GEMINI_API_KEY` environment variable. In the following methods, replace `YOUR_GEMINI_API_KEY` with the API key you obtained from Google AI Studio:
32
+ - You can temporarily set the environment variable in your current shell session using the following command:
33
+ ```bash
34
+ export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"
35
+ ```
36
+ - For repeated use, you can add the environment variable to your [.env file](#persisting-environment-variables-with-env-files).
37
+
38
+ - Alternatively you can export the API key from your shell's configuration file (like `~/.bashrc`, `~/.zshrc`, or `~/.profile`). For example, the following command adds the environment variable to a `~/.bashrc` file:
39
+
40
+ ```bash
41
+ echo 'export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"' >> ~/.bashrc
42
+ source ~/.bashrc
43
+ ```
44
+
45
+ :warning: Be advised that when you export your API key inside your shell configuration file, any other process executed from the shell can read it.
46
+
47
+ 3. **Vertex AI:**
48
+ - **API Key:**
49
+ - Obtain your Google Cloud API key: [Get an API Key](https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys?usertype=newuser)
50
+ - Set the `GOOGLE_API_KEY` environment variable. In the following methods, replace `YOUR_GOOGLE_API_KEY` with your Vertex AI API key:
51
+ - You can temporarily set the environment variable in your current shell session using the following command:
52
+ ```bash
53
+ export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
54
+ ```
55
+ - For repeated use, you can add the environment variable to your [.env file](#persisting-environment-variables-with-env-files) or your shell's configuration file (like `~/.bashrc`, `~/.zshrc`, or `~/.profile`). For example, the following command adds the environment variable to a `~/.bashrc` file:
56
+
57
+ ```bash
58
+ echo 'export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"' >> ~/.bashrc
59
+ source ~/.bashrc
60
+ ```
61
+
62
+ :warning: Be advised that when you export your API key inside your shell configuration file, any other process executed from the shell can read it.
63
+
64
+ > **Note:**
65
+ > If you encounter an error like `"API keys are not supported by this API - Expected OAuth2 access token or other authentication credentials that assert a principal"`, it is likely that your organization has restricted the creation of service account API keys. In this case, please try the [service account JSON key](#service-account-json-key) method described below.
66
+
67
+ - **Application Default Credentials (ADC):**
68
+
69
+ > **Note:**
70
+ > If you have previously set the `GOOGLE_API_KEY` or `GEMINI_API_KEY` environment variables, you must unset them to use Application Default Credentials.
71
+ >
72
+ > ```bash
73
+ > unset GOOGLE_API_KEY GEMINI_API_KEY
74
+ > ```
75
+ - **Using `gcloud` (for local development):**
76
+ - Ensure you have a Google Cloud project and have enabled the Vertex AI API.
77
+ - Log in with your user credentials:
78
+ ```bash
79
+ gcloud auth application-default login
80
+ ```
81
+ For more information, see [Set up Application Default Credentials for Google Cloud](https://cloud.google.com/docs/authentication/provide-credentials-adc).
82
+ - **<a id="service-account-json-key"></a>Using a Service Account (for applications or when service account API keys are restricted):**
83
+ - If you are unable to create an API key due to [organization policies](https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys?usertype=existinguser#expandable-2), or if you are running in a non-interactive environment, you can authenticate using a service account key.
84
+ - [Create a service account and key](https://cloud.google.com/iam/docs/keys-create-delete), and download the JSON key file. The service account will need to be assigned the "Vertex AI User" role.
85
+ - Set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the absolute path of the JSON file.
86
+ - You can temporarily set the environment variable in your current shell session:
87
+ ```bash
88
+ export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/keyfile.json"
89
+ ```
90
+ - For repeated use, you can add the command to your shell's configuration file (e.g., `~/.bashrc`).
91
+ ```bash
92
+ echo 'export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/keyfile.json"' >> ~/.bashrc
93
+ source ~/.bashrc
94
+ ```
95
+ :warning: Be advised that when you export service account credentials inside your shell configuration file, any other process executed from the shell can read it.
96
+
97
+ - **Required Environment Variables for ADC:**
98
+ - When using ADC (either with `gcloud` or a service account), you must also set the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` environment variables. In the following methods, replace `YOUR_PROJECT_ID` and `YOUR_PROJECT_LOCATION` with the relevant values for your project:
99
+ - You can temporarily set these environment variables in your current shell session using the following commands:
100
+ ```bash
101
+ export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
102
+ export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION" # e.g., us-central1
103
+ ```
104
+ - For repeated use, you can add the environment variables to your [.env file](#persisting-environment-variables-with-env-files) or your shell's configuration file (like `~/.bashrc`, `~/.zshrc`, or `~/.profile`). For example, the following commands add the environment variables to a `~/.bashrc` file:
105
+ ```bash
106
+ echo 'export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"' >> ~/.bashrc
107
+ echo 'export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION"' >> ~/.bashrc
108
+ source ~/.bashrc
109
+ ```
110
+
111
+ 4. **Cloud Shell:**
112
+ - This option is only available when running in a Google Cloud Shell environment.
113
+ - It automatically uses the credentials of the logged-in user in the Cloud Shell environment.
114
+ - This is the default authentication method when running in Cloud Shell and no other method is configured.
115
+
116
+ :warning: Be advised that when you export your API key inside your shell configuration file, any other process executed from the shell can read it.
117
+
118
+ ### Persisting Environment Variables with `.env` Files
119
+
120
+ You can create a **`.gemini/.env`** file in your project directory or in your home directory. Creating a plain **`.env`** file also works, but `.gemini/.env` is recommended to keep Gemini variables isolated from other tools.
121
+
122
+ **Important:** Some environment variables (like `DEBUG` and `DEBUG_MODE`) are automatically excluded from project `.env` files to prevent interference with gemini-cli behavior. Use `.gemini/.env` files for gemini-cli specific variables.
123
+
124
+ Gemini CLI automatically loads environment variables from the **first** `.env` file it finds, using the following search order:
125
+
126
+ 1. Starting in the **current directory** and moving upward toward `/`, for each directory it checks:
127
+ 1. `.gemini/.env`
128
+ 2. `.env`
129
+ 2. If no file is found, it falls back to your **home directory**:
130
+ - `~/.gemini/.env`
131
+ - `~/.env`
132
+
133
+ > **Important:** The search stops at the **first** file encountered—variables are **not merged** across multiple files.
134
+
135
+ #### Examples
136
+
137
+ **Project-specific overrides** (take precedence when you are inside the project):
138
+
139
+ ```bash
140
+ mkdir -p .gemini
141
+ echo 'GOOGLE_CLOUD_PROJECT="your-project-id"' >> .gemini/.env
142
+ ```
143
+
144
+ **User-wide settings** (available in every directory):
145
+
146
+ ```bash
147
+ mkdir -p ~/.gemini
148
+ cat >> ~/.gemini/.env <<'EOF'
149
+ GOOGLE_CLOUD_PROJECT="your-project-id"
150
+ GEMINI_API_KEY="your-gemini-api-key"
151
+ EOF
152
+ ```
153
+
154
+ ## Non-Interactive Mode / Headless Environments
155
+
156
+ When running the Gemini CLI in a non-interactive environment, you cannot use the interactive login flow.
157
+ Instead, you must configure authentication using environment variables.
158
+
159
+ The CLI will automatically detect if it is running in a non-interactive terminal and will use one of the
160
+ following authentication methods if available:
161
+
162
+ 1. **Gemini API Key:**
163
+ - Set the `GEMINI_API_KEY` environment variable.
164
+ - The CLI will use this key to authenticate with the Gemini API.
165
+
166
+ 2. **Vertex AI:**
167
+ - Set the `GOOGLE_GENAI_USE_VERTEXAI=true` environment variable.
168
+ - **Using an API Key:** Set the `GOOGLE_API_KEY` environment variable.
169
+ - **Using Application Default Credentials (ADC):**
170
+ - Run `gcloud auth application-default login` in your environment to configure ADC.
171
+ - Ensure the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` environment variables are set.
172
+
173
+ If none of these environment variables are set in a non-interactive session, the CLI will exit with an error.
projects/gemini-cli/docs/cli/commands.md ADDED
@@ -0,0 +1,430 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CLI Commands
2
+
3
+ Gemini CLI supports several built-in commands to help you manage your session, customize the interface, and control its behavior. These commands are prefixed with a forward slash (`/`), an at symbol (`@`), or an exclamation mark (`!`).
4
+
5
+ ## Slash commands (`/`)
6
+
7
+ Slash commands provide meta-level control over the CLI itself.
8
+
9
+ ### Built-in Commands
10
+
11
+ - **`/bug`**
12
+ - **Description:** File an issue about Gemini CLI. By default, the issue is filed within the GitHub repository for Gemini CLI. The string you enter after `/bug` will become the headline for the bug being filed. The default `/bug` behavior can be modified using the `advanced.bugCommand` setting in your `.gemini/settings.json` files.
13
+
14
+ - **`/chat`**
15
+ - **Description:** Save and resume conversation history for branching conversation state interactively, or resuming a previous state from a later session.
16
+ - **Sub-commands:**
17
+ - **`save`**
18
+ - **Description:** Saves the current conversation history. You must add a `<tag>` for identifying the conversation state.
19
+ - **Usage:** `/chat save <tag>`
20
+ - **Details on Checkpoint Location:** The default locations for saved chat checkpoints are:
21
+ - Linux/macOS: `~/.gemini/tmp/<project_hash>/`
22
+ - Windows: `C:\Users\<YourUsername>\.gemini\tmp\<project_hash>\`
23
+ - When you run `/chat list`, the CLI only scans these specific directories to find available checkpoints.
24
+ - **Note:** These checkpoints are for manually saving and resuming conversation states. For automatic checkpoints created before file modifications, see the [Checkpointing documentation](../checkpointing.md).
25
+ - **`resume`**
26
+ - **Description:** Resumes a conversation from a previous save.
27
+ - **Usage:** `/chat resume <tag>`
28
+ - **`list`**
29
+ - **Description:** Lists available tags for chat state resumption.
30
+ - **`delete`**
31
+ - **Description:** Deletes a saved conversation checkpoint.
32
+ - **Usage:** `/chat delete <tag>`
33
+
34
+ - **`/clear`**
35
+ - **Description:** Clear the terminal screen, including the visible session history and scrollback within the CLI. The underlying session data (for history recall) might be preserved depending on the exact implementation, but the visual display is cleared.
36
+ - **Keyboard shortcut:** Press **Ctrl+L** at any time to perform a clear action.
37
+
38
+ - **`/compress`**
39
+ - **Description:** Replace the entire chat context with a summary. This saves on tokens used for future tasks while retaining a high level summary of what has happened.
40
+
41
+ - **`/copy`**
42
+ - **Description:** Copies the last output produced by Gemini CLI to your clipboard, for easy sharing or reuse.
43
+ - **Note:** This command requires platform-specific clipboard tools to be installed.
44
+ - On Linux, it requires `xclip` or `xsel`. You can typically install them using your system's package manager.
45
+ - On macOS, it requires `pbcopy`, and on Windows, it requires `clip`. These tools are typically pre-installed on their respective systems.
46
+
47
+ - **`/directory`** (or **`/dir`**)
48
+ - **Description:** Manage workspace directories for multi-directory support.
49
+ - **Sub-commands:**
50
+ - **`add`**:
51
+ - **Description:** Add a directory to the workspace. The path can be absolute or relative to the current working directory. Moreover, the reference from home directory is supported as well.
52
+ - **Usage:** `/directory add <path1>,<path2>`
53
+ - **Note:** Disabled in restrictive sandbox profiles. If you're using that, use `--include-directories` when starting the session instead.
54
+ - **`show`**:
55
+ - **Description:** Display all directories added by `/directory add` and `--include-directories`.
56
+ - **Usage:** `/directory show`
57
+
58
+ - **`/editor`**
59
+ - **Description:** Open a dialog for selecting supported editors.
60
+
61
+ - **`/extensions`**
62
+ - **Description:** Lists all active extensions in the current Gemini CLI session. See [Gemini CLI Extensions](../extension.md).
63
+
64
+ - **`/help`** (or **`/?`**)
65
+ - **Description:** Display help information about Gemini CLI, including available commands and their usage.
66
+
67
+ - **`/mcp`**
68
+ - **Description:** List configured Model Context Protocol (MCP) servers, their connection status, server details, and available tools.
69
+ - **Sub-commands:**
70
+ - **`desc`** or **`descriptions`**:
71
+ - **Description:** Show detailed descriptions for MCP servers and tools.
72
+ - **`nodesc`** or **`nodescriptions`**:
73
+ - **Description:** Hide tool descriptions, showing only the tool names.
74
+ - **`schema`**:
75
+ - **Description:** Show the full JSON schema for the tool's configured parameters.
76
+ - **Keyboard Shortcut:** Press **Ctrl+T** at any time to toggle between showing and hiding tool descriptions.
77
+
78
+ - **`/memory`**
79
+ - **Description:** Manage the AI's instructional context (hierarchical memory loaded from `GEMINI.md` files).
80
+ - **Sub-commands:**
81
+ - **`add`**:
82
+ - **Description:** Adds the following text to the AI's memory. Usage: `/memory add <text to remember>`
83
+ - **`show`**:
84
+ - **Description:** Display the full, concatenated content of the current hierarchical memory that has been loaded from all `GEMINI.md` files. This lets you inspect the instructional context being provided to the Gemini model.
85
+ - **`refresh`**:
86
+ - **Description:** Reload the hierarchical instructional memory from all `GEMINI.md` files found in the configured locations (global, project/ancestors, and sub-directories). This command updates the model with the latest `GEMINI.md` content.
87
+ - **Note:** For more details on how `GEMINI.md` files contribute to hierarchical memory, see the [CLI Configuration documentation](./configuration.md#4-geminimd-files-hierarchical-instructional-context).
88
+
89
+ - **`/restore`**
90
+ - **Description:** Restores the project files to the state they were in just before a tool was executed. This is particularly useful for undoing file edits made by a tool. If run without a tool call ID, it will list available checkpoints to restore from.
91
+ - **Usage:** `/restore [tool_call_id]`
92
+ - **Note:** Only available if the CLI is invoked with the `--checkpointing` option or configured via [settings](./configuration.md). See [Checkpointing documentation](../checkpointing.md) for more details.
93
+
94
+ - **`/settings`**
95
+ - **Description:** Open the settings editor to view and modify Gemini CLI settings.
96
+ - **Details:** This command provides a user-friendly interface for changing settings that control the behavior and appearance of Gemini CLI. It is equivalent to manually editing the `.gemini/settings.json` file, but with validation and guidance to prevent errors.
97
+ - **Usage:** Simply run `/settings` and the editor will open. You can then browse or search for specific settings, view their current values, and modify them as desired. Changes to some settings are applied immediately, while others require a restart.
98
+
99
+ - **`/stats`**
100
+ - **Description:** Display detailed statistics for the current Gemini CLI session, including token usage, cached token savings (when available), and session duration. Note: Cached token information is only displayed when cached tokens are being used, which occurs with API key authentication but not with OAuth authentication at this time.
101
+
102
+ - [**`/theme`**](./themes.md)
103
+ - **Description:** Open a dialog that lets you change the visual theme of Gemini CLI.
104
+
105
+ - **`/auth`**
106
+ - **Description:** Open a dialog that lets you change the authentication method.
107
+
108
+ - **`/about`**
109
+ - **Description:** Show version info. Please share this information when filing issues.
110
+
111
+ - [**`/tools`**](../tools/index.md)
112
+ - **Description:** Display a list of tools that are currently available within Gemini CLI.
113
+ - **Usage:** `/tools [desc]`
114
+ - **Sub-commands:**
115
+ - **`desc`** or **`descriptions`**:
116
+ - **Description:** Show detailed descriptions of each tool, including each tool's name with its full description as provided to the model.
117
+ - **`nodesc`** or **`nodescriptions`**:
118
+ - **Description:** Hide tool descriptions, showing only the tool names.
119
+
120
+ - **`/privacy`**
121
+ - **Description:** Display the Privacy Notice and allow users to select whether they consent to the collection of their data for service improvement purposes.
122
+
123
+ - **`/quit`** (or **`/exit`**)
124
+ - **Description:** Exit Gemini CLI.
125
+
126
+ - **`/vim`**
127
+ - **Description:** Toggle vim mode on or off. When vim mode is enabled, the input area supports vim-style navigation and editing commands in both NORMAL and INSERT modes.
128
+ - **Features:**
129
+ - **NORMAL mode:** Navigate with `h`, `j`, `k`, `l`; jump by words with `w`, `b`, `e`; go to line start/end with `0`, `$`, `^`; go to specific lines with `G` (or `gg` for first line)
130
+ - **INSERT mode:** Standard text input with escape to return to NORMAL mode
131
+ - **Editing commands:** Delete with `x`, change with `c`, insert with `i`, `a`, `o`, `O`; complex operations like `dd`, `cc`, `dw`, `cw`
132
+ - **Count support:** Prefix commands with numbers (e.g., `3h`, `5w`, `10G`)
133
+ - **Repeat last command:** Use `.` to repeat the last editing operation
134
+ - **Persistent setting:** Vim mode preference is saved to `~/.gemini/settings.json` and restored between sessions
135
+ - **Status indicator:** When enabled, shows `[NORMAL]` or `[INSERT]` in the footer
136
+
137
+ - **`/init`**
138
+ - **Description:** To help users easily create a `GEMINI.md` file, this command analyzes the current directory and generates a tailored context file, making it simpler for them to provide project-specific instructions to the Gemini agent.
139
+
140
+ ### Custom Commands
141
+
142
+ For a quick start, see the [example](#example-a-pure-function-refactoring-command) below.
143
+
144
+ Custom commands allow you to save and reuse your favorite or most frequently used prompts as personal shortcuts within Gemini CLI. You can create commands that are specific to a single project or commands that are available globally across all your projects, streamlining your workflow and ensuring consistency.
145
+
146
+ #### File Locations & Precedence
147
+
148
+ Gemini CLI discovers commands from two locations, loaded in a specific order:
149
+
150
+ 1. **User Commands (Global):** Located in `~/.gemini/commands/`. These commands are available in any project you are working on.
151
+ 2. **Project Commands (Local):** Located in `<your-project-root>/.gemini/commands/`. These commands are specific to the current project and can be checked into version control to be shared with your team.
152
+
153
+ If a command in the project directory has the same name as a command in the user directory, the **project command will always be used.** This allows projects to override global commands with project-specific versions.
154
+
155
+ #### Naming and Namespacing
156
+
157
+ The name of a command is determined by its file path relative to its `commands` directory. Subdirectories are used to create namespaced commands, with the path separator (`/` or `\`) being converted to a colon (`:`).
158
+
159
+ - A file at `~/.gemini/commands/test.toml` becomes the command `/test`.
160
+ - A file at `<project>/.gemini/commands/git/commit.toml` becomes the namespaced command `/git:commit`.
161
+
162
+ #### TOML File Format (v1)
163
+
164
+ Your command definition files must be written in the TOML format and use the `.toml` file extension.
165
+
166
+ ##### Required Fields
167
+
168
+ - `prompt` (String): The prompt that will be sent to the Gemini model when the command is executed. This can be a single-line or multi-line string.
169
+
170
+ ##### Optional Fields
171
+
172
+ - `description` (String): A brief, one-line description of what the command does. This text will be displayed next to your command in the `/help` menu. **If you omit this field, a generic description will be generated from the filename.**
173
+
174
+ #### Handling Arguments
175
+
176
+ Custom commands support two powerful methods for handling arguments. The CLI automatically chooses the correct method based on the content of your command's `prompt`.
177
+
178
+ ##### 1. Context-Aware Injection with `{{args}}`
179
+
180
+ If your `prompt` contains the special placeholder `{{args}}`, the CLI will replace that placeholder with the text the user typed after the command name.
181
+
182
+ The behavior of this injection depends on where it is used:
183
+
184
+ **A. Raw Injection (Outside Shell Commands)**
185
+
186
+ When used in the main body of the prompt, the arguments are injected exactly as the user typed them.
187
+
188
+ **Example (`git/fix.toml`):**
189
+
190
+ ```toml
191
+ # Invoked via: /git:fix "Button is misaligned"
192
+
193
+ description = "Generates a fix for a given issue."
194
+ prompt = "Please provide a code fix for the issue described here: {{args}}."
195
+ ```
196
+
197
+ The model receives: `Please provide a code fix for the issue described here: "Button is misaligned".`
198
+
199
+ **B. Using Arguments in Shell Commands (Inside `!{...}` Blocks)**
200
+
201
+ When you use `{{args}}` inside a shell injection block (`!{...}`), the arguments are automatically **shell-escaped** before replacement. This allows you to safely pass arguments to shell commands, ensuring the resulting command is syntactically correct and secure while preventing command injection vulnerabilities.
202
+
203
+ **Example (`/grep-code.toml`):**
204
+
205
+ ```toml
206
+ prompt = """
207
+ Please summarize the findings for the pattern `{{args}}`.
208
+
209
+ Search Results:
210
+ !{grep -r {{args}} .}
211
+ """
212
+ ```
213
+
214
+ When you run `/grep-code It's complicated`:
215
+
216
+ 1. The CLI sees `{{args}}` used both outside and inside `!{...}`.
217
+ 2. Outside: The first `{{args}}` is replaced raw with `It's complicated`.
218
+ 3. Inside: The second `{{args}}` is replaced with the escaped version (e.g., on Linux: `"It's complicated"`).
219
+ 4. The command executed is `grep -r "It's complicated" .`.
220
+ 5. The CLI prompts you to confirm this exact, secure command before execution.
221
+ 6. The final prompt is sent.
222
+
223
+ ##### 2. Default Argument Handling
224
+
225
+ If your `prompt` does **not** contain the special placeholder `{{args}}`, the CLI uses a default behavior for handling arguments.
226
+
227
+ If you provide arguments to the command (e.g., `/mycommand arg1`), the CLI will append the full command you typed to the end of the prompt, separated by two newlines. This allows the model to see both the original instructions and the specific arguments you just provided.
228
+
229
+ If you do **not** provide any arguments (e.g., `/mycommand`), the prompt is sent to the model exactly as it is, with nothing appended.
230
+
231
+ **Example (`changelog.toml`):**
232
+
233
+ This example shows how to create a robust command by defining a role for the model, explaining where to find the user's input, and specifying the expected format and behavior.
234
+
235
+ ```toml
236
+ # In: <project>/.gemini/commands/changelog.toml
237
+ # Invoked via: /changelog 1.2.0 added "Support for default argument parsing."
238
+
239
+ description = "Adds a new entry to the project's CHANGELOG.md file."
240
+ prompt = """
241
+ # Task: Update Changelog
242
+
243
+ You are an expert maintainer of this software project. A user has invoked a command to add a new entry to the changelog.
244
+
245
+ **The user's raw command is appended below your instructions.**
246
+
247
+ Your task is to parse the `<version>`, `<change_type>`, and `<message>` from their input and use the `write_file` tool to correctly update the `CHANGELOG.md` file.
248
+
249
+ ## Expected Format
250
+ The command follows this format: `/changelog <version> <type> <message>`
251
+ - `<type>` must be one of: "added", "changed", "fixed", "removed".
252
+
253
+ ## Behavior
254
+ 1. Read the `CHANGELOG.md` file.
255
+ 2. Find the section for the specified `<version>`.
256
+ 3. Add the `<message>` under the correct `<type>` heading.
257
+ 4. If the version or type section doesn't exist, create it.
258
+ 5. Adhere strictly to the "Keep a Changelog" format.
259
+ """
260
+ ```
261
+
262
+ When you run `/changelog 1.2.0 added "New feature"`, the final text sent to the model will be the original prompt followed by two newlines and the command you typed.
263
+
264
+ ##### 3. Executing Shell Commands with `!{...}`
265
+
266
+ You can make your commands dynamic by executing shell commands directly within your `prompt` and injecting their output. This is ideal for gathering context from your local environment, like reading file content or checking the status of Git.
267
+
268
+ When a custom command attempts to execute a shell command, Gemini CLI will now prompt you for confirmation before proceeding. This is a security measure to ensure that only intended commands can be run.
269
+
270
+ **How It Works:**
271
+
272
+ 1. **Inject Commands:** Use the `!{...}` syntax.
273
+ 2. **Argument Substitution:** If `{{args}}` is present inside the block, it is automatically shell-escaped (see [Context-Aware Injection](#1-context-aware-injection-with-args) above).
274
+ 3. **Robust Parsing:** The parser correctly handles complex shell commands that include nested braces, such as JSON payloads. **Note:** The content inside `!{...}` must have balanced braces (`{` and `}`). If you need to execute a command containing unbalanced braces, consider wrapping it in an external script file and calling the script within the `!{...}` block.
275
+ 4. **Security Check and Confirmation:** The CLI performs a security check on the final, resolved command (after arguments are escaped and substituted). A dialog will appear showing the exact command(s) to be executed.
276
+ 5. **Execution and Error Reporting:** The command is executed. If the command fails, the output injected into the prompt will include the error messages (stderr) followed by a status line, e.g., `[Shell command exited with code 1]`. This helps the model understand the context of the failure.
277
+
278
+ **Example (`git/commit.toml`):**
279
+
280
+ This command gets the staged git diff and uses it to ask the model to write a commit message.
281
+
282
+ ````toml
283
+ # In: <project>/.gemini/commands/git/commit.toml
284
+ # Invoked via: /git:commit
285
+
286
+ description = "Generates a Git commit message based on staged changes."
287
+
288
+ # The prompt uses !{...} to execute the command and inject its output.
289
+ prompt = """
290
+ Please generate a Conventional Commit message based on the following git diff:
291
+
292
+ ```diff
293
+ !{git diff --staged}
294
+ ```
295
+
296
+ """
297
+
298
+ ````
299
+
300
+ When you run `/git:commit`, the CLI first executes `git diff --staged`, then replaces `!{git diff --staged}` with the output of that command before sending the final, complete prompt to the model.
301
+
302
+ ##### 4. Injecting File Content with `@{...}`
303
+
304
+ You can directly embed the content of a file or a directory listing into your prompt using the `@{...}` syntax. This is useful for creating commands that operate on specific files.
305
+
306
+ **How It Works:**
307
+
308
+ - **File Injection**: `@{path/to/file.txt}` is replaced by the content of `file.txt`.
309
+ - **Multimodal Support**: If the path points to a supported image (e.g., PNG, JPEG), PDF, audio, or video file, it will be correctly encoded and injected as multimodal input. Other binary files are handled gracefully and skipped.
310
+ - **Directory Listing**: `@{path/to/dir}` is traversed and each file present within the directory and all subdirectories are inserted into the prompt. This respects `.gitignore` and `.geminiignore` if enabled.
311
+ - **Workspace-Aware**: The command searches for the path in the current directory and any other workspace directories. Absolute paths are allowed if they are within the workspace.
312
+ - **Processing Order**: File content injection with `@{...}` is processed _before_ shell commands (`!{...}`) and argument substitution (`{{args}}`).
313
+ - **Parsing**: The parser requires the content inside `@{...}` (the path) to have balanced braces (`{` and `}`).
314
+
315
+ **Example (`review.toml`):**
316
+
317
+ This command injects the content of a _fixed_ best practices file (`docs/best-practices.md`) and uses the user's arguments to provide context for the review.
318
+
319
+ ```toml
320
+ # In: <project>/.gemini/commands/review.toml
321
+ # Invoked via: /review FileCommandLoader.ts
322
+
323
+ description = "Reviews the provided context using a best practice guide."
324
+ prompt = """
325
+ You are an expert code reviewer.
326
+
327
+ Your task is to review {{args}}.
328
+
329
+ Use the following best practices when providing your review:
330
+
331
+ @{docs/best-practices.md}
332
+ """
333
+ ```
334
+
335
+ When you run `/review FileCommandLoader.ts`, the `@{docs/best-practices.md}` placeholder is replaced by the content of that file, and `{{args}}` is replaced by the text you provided, before the final prompt is sent to the model.
336
+
337
+ ---
338
+
339
+ #### Example: A "Pure Function" Refactoring Command
340
+
341
+ Let's create a global command that asks the model to refactor a piece of code.
342
+
343
+ **1. Create the file and directories:**
344
+
345
+ First, ensure the user commands directory exists, then create a `refactor` subdirectory for organization and the final TOML file.
346
+
347
+ ```bash
348
+ mkdir -p ~/.gemini/commands/refactor
349
+ touch ~/.gemini/commands/refactor/pure.toml
350
+ ```
351
+
352
+ **2. Add the content to the file:**
353
+
354
+ Open `~/.gemini/commands/refactor/pure.toml` in your editor and add the following content. We are including the optional `description` for best practice.
355
+
356
+ ```toml
357
+ # In: ~/.gemini/commands/refactor/pure.toml
358
+ # This command will be invoked via: /refactor:pure
359
+
360
+ description = "Asks the model to refactor the current context into a pure function."
361
+
362
+ prompt = """
363
+ Please analyze the code I've provided in the current context.
364
+ Refactor it into a pure function.
365
+
366
+ Your response should include:
367
+ 1. The refactored, pure function code block.
368
+ 2. A brief explanation of the key changes you made and why they contribute to purity.
369
+ """
370
+ ```
371
+
372
+ **3. Run the Command:**
373
+
374
+ That's it! You can now run your command in the CLI. First, you might add a file to the context, and then invoke your command:
375
+
376
+ ```
377
+ > @my-messy-function.js
378
+ > /refactor:pure
379
+ ```
380
+
381
+ Gemini CLI will then execute the multi-line prompt defined in your TOML file.
382
+
383
+ ## At commands (`@`)
384
+
385
+ At commands are used to include the content of files or directories as part of your prompt to Gemini. These commands include git-aware filtering.
386
+
387
+ - **`@<path_to_file_or_directory>`**
388
+ - **Description:** Inject the content of the specified file or files into your current prompt. This is useful for asking questions about specific code, text, or collections of files.
389
+ - **Examples:**
390
+ - `@path/to/your/file.txt Explain this text.`
391
+ - `@src/my_project/ Summarize the code in this directory.`
392
+ - `What is this file about? @README.md`
393
+ - **Details:**
394
+ - If a path to a single file is provided, the content of that file is read.
395
+ - If a path to a directory is provided, the command attempts to read the content of files within that directory and any subdirectories.
396
+ - Spaces in paths should be escaped with a backslash (e.g., `@My\ Documents/file.txt`).
397
+ - The command uses the `read_many_files` tool internally. The content is fetched and then inserted into your query before being sent to the Gemini model.
398
+ - **Git-aware filtering:** By default, git-ignored files (like `node_modules/`, `dist/`, `.env`, `.git/`) are excluded. This behavior can be changed via the `context.fileFiltering` settings.
399
+ - **File types:** The command is intended for text-based files. While it might attempt to read any file, binary files or very large files might be skipped or truncated by the underlying `read_many_files` tool to ensure performance and relevance. The tool indicates if files were skipped.
400
+ - **Output:** The CLI will show a tool call message indicating that `read_many_files` was used, along with a message detailing the status and the path(s) that were processed.
401
+
402
+ - **`@` (Lone at symbol)**
403
+ - **Description:** If you type a lone `@` symbol without a path, the query is passed as-is to the Gemini model. This might be useful if you are specifically talking _about_ the `@` symbol in your prompt.
404
+
405
+ ### Error handling for `@` commands
406
+
407
+ - If the path specified after `@` is not found or is invalid, an error message will be displayed, and the query might not be sent to the Gemini model, or it will be sent without the file content.
408
+ - If the `read_many_files` tool encounters an error (e.g., permission issues), this will also be reported.
409
+
410
+ ## Shell mode & passthrough commands (`!`)
411
+
412
+ The `!` prefix lets you interact with your system's shell directly from within Gemini CLI.
413
+
414
+ - **`!<shell_command>`**
415
+ - **Description:** Execute the given `<shell_command>` using `bash` on Linux/macOS or `cmd.exe` on Windows. Any output or errors from the command are displayed in the terminal.
416
+ - **Examples:**
417
+ - `!ls -la` (executes `ls -la` and returns to Gemini CLI)
418
+ - `!git status` (executes `git status` and returns to Gemini CLI)
419
+
420
+ - **`!` (Toggle shell mode)**
421
+ - **Description:** Typing `!` on its own toggles shell mode.
422
+ - **Entering shell mode:**
423
+ - When active, shell mode uses a different coloring and a "Shell Mode Indicator".
424
+ - While in shell mode, text you type is interpreted directly as a shell command.
425
+ - **Exiting shell mode:**
426
+ - When exited, the UI reverts to its standard appearance and normal Gemini CLI behavior resumes.
427
+
428
+ - **Caution for all `!` usage:** Commands you execute in shell mode have the same permissions and impact as if you ran them directly in your terminal.
429
+
430
+ - **Environment Variable:** When a command is executed via `!` or in shell mode, the `GEMINI_CLI=1` environment variable is set in the subprocess's environment. This allows scripts or tools to detect if they are being run from within the Gemini CLI.
projects/gemini-cli/docs/cli/configuration-v1.md ADDED
@@ -0,0 +1,643 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI Configuration
2
+
3
+ **Note on Deprecated Configuration Format**
4
+
5
+ This document describes the legacy v1 format for the `settings.json` file. This format is now deprecated.
6
+
7
+ - The new format will be supported in the stable release starting **[09/10/25]**.
8
+ - Automatic migration from the old format to the new format will begin on **[09/17/25]**.
9
+
10
+ For details on the new, recommended format, please see the [current Configuration documentation](./configuration.md).
11
+
12
+ Gemini CLI offers several ways to configure its behavior, including environment variables, command-line arguments, and settings files. This document outlines the different configuration methods and available settings.
13
+
14
+ ## Configuration layers
15
+
16
+ Configuration is applied in the following order of precedence (lower numbers are overridden by higher numbers):
17
+
18
+ 1. **Default values:** Hardcoded defaults within the application.
19
+ 2. **System defaults file:** System-wide default settings that can be overridden by other settings files.
20
+ 3. **User settings file:** Global settings for the current user.
21
+ 4. **Project settings file:** Project-specific settings.
22
+ 5. **System settings file:** System-wide settings that override all other settings files.
23
+ 6. **Environment variables:** System-wide or session-specific variables, potentially loaded from `.env` files.
24
+ 7. **Command-line arguments:** Values passed when launching the CLI.
25
+
26
+ ## Settings files
27
+
28
+ Gemini CLI uses JSON settings files for persistent configuration. There are four locations for these files:
29
+
30
+ - **System defaults file:**
31
+ - **Location:** `/etc/gemini-cli/system-defaults.json` (Linux), `C:\ProgramData\gemini-cli\system-defaults.json` (Windows) or `/Library/Application Support/GeminiCli/system-defaults.json` (macOS). The path can be overridden using the `GEMINI_CLI_SYSTEM_DEFAULTS_PATH` environment variable.
32
+ - **Scope:** Provides a base layer of system-wide default settings. These settings have the lowest precedence and are intended to be overridden by user, project, or system override settings.
33
+ - **User settings file:**
34
+ - **Location:** `~/.gemini/settings.json` (where `~` is your home directory).
35
+ - **Scope:** Applies to all Gemini CLI sessions for the current user. User settings override system defaults.
36
+ - **Project settings file:**
37
+ - **Location:** `.gemini/settings.json` within your project's root directory.
38
+ - **Scope:** Applies only when running Gemini CLI from that specific project. Project settings override user settings and system defaults.
39
+ - **System settings file:**
40
+ - **Location:** `/etc/gemini-cli/settings.json` (Linux), `C:\ProgramData\gemini-cli\settings.json` (Windows) or `/Library/Application Support/GeminiCli/settings.json` (macOS). The path can be overridden using the `GEMINI_CLI_SYSTEM_SETTINGS_PATH` environment variable.
41
+ - **Scope:** Applies to all Gemini CLI sessions on the system, for all users. System settings act as overrides, taking precedence over all other settings files. May be useful for system administrators at enterprises to have controls over users' Gemini CLI setups.
42
+
43
+ **Note on environment variables in settings:** String values within your `settings.json` files can reference environment variables using either `$VAR_NAME` or `${VAR_NAME}` syntax. These variables will be automatically resolved when the settings are loaded. For example, if you have an environment variable `MY_API_TOKEN`, you could use it in `settings.json` like this: `"apiKey": "$MY_API_TOKEN"`.
44
+
45
+ > **Note for Enterprise Users:** For guidance on deploying and managing Gemini CLI in a corporate environment, please see the [Enterprise Configuration](./enterprise.md) documentation.
46
+
47
+ ### The `.gemini` directory in your project
48
+
49
+ In addition to a project settings file, a project's `.gemini` directory can contain other project-specific files related to Gemini CLI's operation, such as:
50
+
51
+ - [Custom sandbox profiles](#sandboxing) (e.g., `.gemini/sandbox-macos-custom.sb`, `.gemini/sandbox.Dockerfile`).
52
+
53
+ ### Available settings in `settings.json`:
54
+
55
+ - **`contextFileName`** (string or array of strings):
56
+ - **Description:** Specifies the filename for context files (e.g., `GEMINI.md`, `AGENTS.md`). Can be a single filename or a list of accepted filenames.
57
+ - **Default:** `GEMINI.md`
58
+ - **Example:** `"contextFileName": "AGENTS.md"`
59
+
60
+ - **`bugCommand`** (object):
61
+ - **Description:** Overrides the default URL for the `/bug` command.
62
+ - **Default:** `"urlTemplate": "https://github.com/google-gemini/gemini-cli/issues/new?template=bug_report.yml&title={title}&info={info}"`
63
+ - **Properties:**
64
+ - **`urlTemplate`** (string): A URL that can contain `{title}` and `{info}` placeholders.
65
+ - **Example:**
66
+ ```json
67
+ "bugCommand": {
68
+ "urlTemplate": "https://bug.example.com/new?title={title}&info={info}"
69
+ }
70
+ ```
71
+
72
+ - **`fileFiltering`** (object):
73
+ - **Description:** Controls git-aware file filtering behavior for @ commands and file discovery tools.
74
+ - **Default:** `"respectGitIgnore": true, "enableRecursiveFileSearch": true`
75
+ - **Properties:**
76
+ - **`respectGitIgnore`** (boolean): Whether to respect .gitignore patterns when discovering files. When set to `true`, git-ignored files (like `node_modules/`, `dist/`, `.env`) are automatically excluded from @ commands and file listing operations.
77
+ - **`enableRecursiveFileSearch`** (boolean): Whether to enable searching recursively for filenames under the current tree when completing @ prefixes in the prompt.
78
+ - **`disableFuzzySearch`** (boolean): When `true`, disables the fuzzy search capabilities when searching for files, which can improve performance on projects with a large number of files.
79
+ - **Example:**
80
+ ```json
81
+ "fileFiltering": {
82
+ "respectGitIgnore": true,
83
+ "enableRecursiveFileSearch": false,
84
+ "disableFuzzySearch": true
85
+ }
86
+ ```
87
+
88
+ ### Troubleshooting File Search Performance
89
+
90
+ If you are experiencing performance issues with file searching (e.g., with `@` completions), especially in projects with a very large number of files, here are a few things you can try in order of recommendation:
91
+
92
+ 1. **Use `.geminiignore`:** Create a `.geminiignore` file in your project root to exclude directories that contain a large number of files that you don't need to reference (e.g., build artifacts, logs, `node_modules`). Reducing the total number of files crawled is the most effective way to improve performance.
93
+
94
+ 2. **Disable Fuzzy Search:** If ignoring files is not enough, you can disable fuzzy search by setting `disableFuzzySearch` to `true` in your `settings.json` file. This will use a simpler, non-fuzzy matching algorithm, which can be faster.
95
+
96
+ 3. **Disable Recursive File Search:** As a last resort, you can disable recursive file search entirely by setting `enableRecursiveFileSearch` to `false`. This will be the fastest option as it avoids a recursive crawl of your project. However, it means you will need to type the full path to files when using `@` completions.
97
+
98
+ - **`coreTools`** (array of strings):
99
+ - **Description:** Allows you to specify a list of core tool names that should be made available to the model. This can be used to restrict the set of built-in tools. See [Built-in Tools](../core/tools-api.md#built-in-tools) for a list of core tools. You can also specify command-specific restrictions for tools that support it, like the `ShellTool`. For example, `"coreTools": ["ShellTool(ls -l)"]` will only allow the `ls -l` command to be executed.
100
+ - **Default:** All tools available for use by the Gemini model.
101
+ - **Example:** `"coreTools": ["ReadFileTool", "GlobTool", "ShellTool(ls)"]`.
102
+
103
+ - **`allowedTools`** (array of strings):
104
+ - **Default:** `undefined`
105
+ - **Description:** A list of tool names that will bypass the confirmation dialog. This is useful for tools that you trust and use frequently. The match semantics are the same as `coreTools`.
106
+ - **Example:** `"allowedTools": ["ShellTool(git status)"]`.
107
+
108
+ - **`excludeTools`** (array of strings):
109
+ - **Description:** Allows you to specify a list of core tool names that should be excluded from the model. A tool listed in both `excludeTools` and `coreTools` is excluded. You can also specify command-specific restrictions for tools that support it, like the `ShellTool`. For example, `"excludeTools": ["ShellTool(rm -rf)"]` will block the `rm -rf` command.
110
+ - **Default**: No tools excluded.
111
+ - **Example:** `"excludeTools": ["run_shell_command", "findFiles"]`.
112
+ - **Security Note:** Command-specific restrictions in
113
+ `excludeTools` for `run_shell_command` are based on simple string matching and can be easily bypassed. This feature is **not a security mechanism** and should not be relied upon to safely execute untrusted code. It is recommended to use `coreTools` to explicitly select commands
114
+ that can be executed.
115
+
116
+ - **`allowMCPServers`** (array of strings):
117
+ - **Description:** Allows you to specify a list of MCP server names that should be made available to the model. This can be used to restrict the set of MCP servers to connect to. Note that this will be ignored if `--allowed-mcp-server-names` is set.
118
+ - **Default:** All MCP servers are available for use by the Gemini model.
119
+ - **Example:** `"allowMCPServers": ["myPythonServer"]`.
120
+ - **Security Note:** This uses simple string matching on MCP server names, which can be modified. If you're a system administrator looking to prevent users from bypassing this, consider configuring the `mcpServers` at the system settings level such that the user will not be able to configure any MCP servers of their own. This should not be used as an airtight security mechanism.
121
+
122
+ - **`excludeMCPServers`** (array of strings):
123
+ - **Description:** Allows you to specify a list of MCP server names that should be excluded from the model. A server listed in both `excludeMCPServers` and `allowMCPServers` is excluded. Note that this will be ignored if `--allowed-mcp-server-names` is set.
124
+ - **Default**: No MCP servers excluded.
125
+ - **Example:** `"excludeMCPServers": ["myNodeServer"]`.
126
+ - **Security Note:** This uses simple string matching on MCP server names, which can be modified. If you're a system administrator looking to prevent users from bypassing this, consider configuring the `mcpServers` at the system settings level such that the user will not be able to configure any MCP servers of their own. This should not be used as an airtight security mechanism.
127
+
128
+ - **`autoAccept`** (boolean):
129
+ - **Description:** Controls whether the CLI automatically accepts and executes tool calls that are considered safe (e.g., read-only operations) without explicit user confirmation. If set to `true`, the CLI will bypass the confirmation prompt for tools deemed safe.
130
+ - **Default:** `false`
131
+ - **Example:** `"autoAccept": true`
132
+
133
+ - **`theme`** (string):
134
+ - **Description:** Sets the visual [theme](./themes.md) for Gemini CLI.
135
+ - **Default:** `"Default"`
136
+ - **Example:** `"theme": "GitHub"`
137
+
138
+ - **`vimMode`** (boolean):
139
+ - **Description:** Enables or disables vim mode for input editing. When enabled, the input area supports vim-style navigation and editing commands with NORMAL and INSERT modes. The vim mode status is displayed in the footer and persists between sessions.
140
+ - **Default:** `false`
141
+ - **Example:** `"vimMode": true`
142
+
143
+ - **`sandbox`** (boolean or string):
144
+ - **Description:** Controls whether and how to use sandboxing for tool execution. If set to `true`, Gemini CLI uses a pre-built `gemini-cli-sandbox` Docker image. For more information, see [Sandboxing](#sandboxing).
145
+ - **Default:** `false`
146
+ - **Example:** `"sandbox": "docker"`
147
+
148
+ - **`toolDiscoveryCommand`** (string):
149
+ - **Description:** Defines a custom shell command for discovering tools from your project. The shell command must return on `stdout` a JSON array of [function declarations](https://ai.google.dev/gemini-api/docs/function-calling#function-declarations). Tool wrappers are optional.
150
+ - **Default:** Empty
151
+ - **Example:** `"toolDiscoveryCommand": "bin/get_tools"`
152
+
153
+ - **`toolCallCommand`** (string):
154
+ - **Description:** Defines a custom shell command for calling a specific tool that was discovered using `toolDiscoveryCommand`. The shell command must meet the following criteria:
155
+ - It must take function `name` (exactly as in [function declaration](https://ai.google.dev/gemini-api/docs/function-calling#function-declarations)) as first command line argument.
156
+ - It must read function arguments as JSON on `stdin`, analogous to [`functionCall.args`](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#functioncall).
157
+ - It must return function output as JSON on `stdout`, analogous to [`functionResponse.response.content`](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#functionresponse).
158
+ - **Default:** Empty
159
+ - **Example:** `"toolCallCommand": "bin/call_tool"`
160
+
161
+ - **`mcpServers`** (object):
162
+ - **Description:** Configures connections to one or more Model-Context Protocol (MCP) servers for discovering and using custom tools. Gemini CLI attempts to connect to each configured MCP server to discover available tools. If multiple MCP servers expose a tool with the same name, the tool names will be prefixed with the server alias you defined in the configuration (e.g., `serverAlias__actualToolName`) to avoid conflicts. Note that the system might strip certain schema properties from MCP tool definitions for compatibility. At least one of `command`, `url`, or `httpUrl` must be provided. If multiple are specified, the order of precedence is `httpUrl`, then `url`, then `command`.
163
+ - **Default:** Empty
164
+ - **Properties:**
165
+ - **`<SERVER_NAME>`** (object): The server parameters for the named server.
166
+ - `command` (string, optional): The command to execute to start the MCP server via standard I/O.
167
+ - `args` (array of strings, optional): Arguments to pass to the command.
168
+ - `env` (object, optional): Environment variables to set for the server process.
169
+ - `cwd` (string, optional): The working directory in which to start the server.
170
+ - `url` (string, optional): The URL of an MCP server that uses Server-Sent Events (SSE) for communication.
171
+ - `httpUrl` (string, optional): The URL of an MCP server that uses streamable HTTP for communication.
172
+ - `headers` (object, optional): A map of HTTP headers to send with requests to `url` or `httpUrl`.
173
+ - `timeout` (number, optional): Timeout in milliseconds for requests to this MCP server.
174
+ - `trust` (boolean, optional): Trust this server and bypass all tool call confirmations.
175
+ - `description` (string, optional): A brief description of the server, which may be used for display purposes.
176
+ - `includeTools` (array of strings, optional): List of tool names to include from this MCP server. When specified, only the tools listed here will be available from this server (whitelist behavior). If not specified, all tools from the server are enabled by default.
177
+ - `excludeTools` (array of strings, optional): List of tool names to exclude from this MCP server. Tools listed here will not be available to the model, even if they are exposed by the server. **Note:** `excludeTools` takes precedence over `includeTools` - if a tool is in both lists, it will be excluded.
178
+ - **Example:**
179
+ ```json
180
+ "mcpServers": {
181
+ "myPythonServer": {
182
+ "command": "python",
183
+ "args": ["mcp_server.py", "--port", "8080"],
184
+ "cwd": "./mcp_tools/python",
185
+ "timeout": 5000,
186
+ "includeTools": ["safe_tool", "file_reader"],
187
+ },
188
+ "myNodeServer": {
189
+ "command": "node",
190
+ "args": ["mcp_server.js"],
191
+ "cwd": "./mcp_tools/node",
192
+ "excludeTools": ["dangerous_tool", "file_deleter"]
193
+ },
194
+ "myDockerServer": {
195
+ "command": "docker",
196
+ "args": ["run", "-i", "--rm", "-e", "API_KEY", "ghcr.io/foo/bar"],
197
+ "env": {
198
+ "API_KEY": "$MY_API_TOKEN"
199
+ }
200
+ },
201
+ "mySseServer": {
202
+ "url": "http://localhost:8081/events",
203
+ "headers": {
204
+ "Authorization": "Bearer $MY_SSE_TOKEN"
205
+ },
206
+ "description": "An example SSE-based MCP server."
207
+ },
208
+ "myStreamableHttpServer": {
209
+ "httpUrl": "http://localhost:8082/stream",
210
+ "headers": {
211
+ "X-API-Key": "$MY_HTTP_API_KEY"
212
+ },
213
+ "description": "An example Streamable HTTP-based MCP server."
214
+ }
215
+ }
216
+ ```
217
+
218
+ - **`checkpointing`** (object):
219
+ - **Description:** Configures the checkpointing feature, which allows you to save and restore conversation and file states. See the [Checkpointing documentation](../checkpointing.md) for more details.
220
+ - **Default:** `{"enabled": false}`
221
+ - **Properties:**
222
+ - **`enabled`** (boolean): When `true`, the `/restore` command is available.
223
+
224
+ - **`preferredEditor`** (string):
225
+ - **Description:** Specifies the preferred editor to use for viewing diffs.
226
+ - **Default:** `vscode`
227
+ - **Example:** `"preferredEditor": "vscode"`
228
+
229
+ - **`telemetry`** (object)
230
+ - **Description:** Configures logging and metrics collection for Gemini CLI. For more information, see [Telemetry](../telemetry.md).
231
+ - **Default:** `{"enabled": false, "target": "local", "otlpEndpoint": "http://localhost:4317", "logPrompts": true}`
232
+ - **Properties:**
233
+ - **`enabled`** (boolean): Whether or not telemetry is enabled.
234
+ - **`target`** (string): The destination for collected telemetry. Supported values are `local` and `gcp`.
235
+ - **`otlpEndpoint`** (string): The endpoint for the OTLP Exporter.
236
+ - **`logPrompts`** (boolean): Whether or not to include the content of user prompts in the logs.
237
+ - **Example:**
238
+ ```json
239
+ "telemetry": {
240
+ "enabled": true,
241
+ "target": "local",
242
+ "otlpEndpoint": "http://localhost:16686",
243
+ "logPrompts": false
244
+ }
245
+ ```
246
+ - **`usageStatisticsEnabled`** (boolean):
247
+ - **Description:** Enables or disables the collection of usage statistics. See [Usage Statistics](#usage-statistics) for more information.
248
+ - **Default:** `true`
249
+ - **Example:**
250
+ ```json
251
+ "usageStatisticsEnabled": false
252
+ ```
253
+
254
+ - **`hideTips`** (boolean):
255
+ - **Description:** Enables or disables helpful tips in the CLI interface.
256
+ - **Default:** `false`
257
+ - **Example:**
258
+
259
+ ```json
260
+ "hideTips": true
261
+ ```
262
+
263
+ - **`hideBanner`** (boolean):
264
+ - **Description:** Enables or disables the startup banner (ASCII art logo) in the CLI interface.
265
+ - **Default:** `false`
266
+ - **Example:**
267
+
268
+ ```json
269
+ "hideBanner": true
270
+ ```
271
+
272
+ - **`maxSessionTurns`** (number):
273
+ - **Description:** Sets the maximum number of turns for a session. If the session exceeds this limit, the CLI will stop processing and start a new chat.
274
+ - **Default:** `-1` (unlimited)
275
+ - **Example:**
276
+ ```json
277
+ "maxSessionTurns": 10
278
+ ```
279
+
280
+ - **`summarizeToolOutput`** (object):
281
+ - **Description:** Enables or disables the summarization of tool output. You can specify the token budget for the summarization using the `tokenBudget` setting.
282
+ - Note: Currently only the `run_shell_command` tool is supported.
283
+ - **Default:** `{}` (Disabled by default)
284
+ - **Example:**
285
+ ```json
286
+ "summarizeToolOutput": {
287
+ "run_shell_command": {
288
+ "tokenBudget": 2000
289
+ }
290
+ }
291
+ ```
292
+
293
+ - **`excludedProjectEnvVars`** (array of strings):
294
+ - **Description:** Specifies environment variables that should be excluded from being loaded from project `.env` files. This prevents project-specific environment variables (like `DEBUG=true`) from interfering with gemini-cli behavior. Variables from `.gemini/.env` files are never excluded.
295
+ - **Default:** `["DEBUG", "DEBUG_MODE"]`
296
+ - **Example:**
297
+ ```json
298
+ "excludedProjectEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"]
299
+ ```
300
+
301
+ - **`includeDirectories`** (array of strings):
302
+ - **Description:** Specifies an array of additional absolute or relative paths to include in the workspace context. Missing directories will be skipped with a warning by default. Paths can use `~` to refer to the user's home directory. This setting can be combined with the `--include-directories` command-line flag.
303
+ - **Default:** `[]`
304
+ - **Example:**
305
+ ```json
306
+ "includeDirectories": [
307
+ "/path/to/another/project",
308
+ "../shared-library",
309
+ "~/common-utils"
310
+ ]
311
+ ```
312
+
313
+ - **`loadMemoryFromIncludeDirectories`** (boolean):
314
+ - **Description:** Controls the behavior of the `/memory refresh` command. If set to `true`, `GEMINI.md` files should be loaded from all directories that are added. If set to `false`, `GEMINI.md` should only be loaded from the current directory.
315
+ - **Default:** `false`
316
+ - **Example:**
317
+ ```json
318
+ "loadMemoryFromIncludeDirectories": true
319
+ ```
320
+
321
+ - **`chatCompression`** (object):
322
+ - **Description:** Controls the settings for chat history compression, both automatic and
323
+ when manually invoked through the /compress command.
324
+ - **Properties:**
325
+ - **`contextPercentageThreshold`** (number): A value between 0 and 1 that specifies the token threshold for compression as a percentage of the model's total token limit. For example, a value of `0.6` will trigger compression when the chat history exceeds 60% of the token limit.
326
+ - **Example:**
327
+ ```json
328
+ "chatCompression": {
329
+ "contextPercentageThreshold": 0.6
330
+ }
331
+ ```
332
+
333
+ - **`showLineNumbers`** (boolean):
334
+ - **Description:** Controls whether line numbers are displayed in code blocks in the CLI output.
335
+ - **Default:** `true`
336
+ - **Example:**
337
+ ```json
338
+ "showLineNumbers": false
339
+ ```
340
+
341
+ - **`accessibility`** (object):
342
+ - **Description:** Configures accessibility features for the CLI.
343
+ - **Properties:**
344
+ - **`screenReader`** (boolean): Enables screen reader mode, which adjusts the TUI for better compatibility with screen readers. This can also be enabled with the `--screen-reader` command-line flag, which will take precedence over the setting.
345
+ - **`disableLoadingPhrases`** (boolean): Disables the display of loading phrases during operations.
346
+ - **Default:** `{"screenReader": false, "disableLoadingPhrases": false}`
347
+ - **Example:**
348
+ ```json
349
+ "accessibility": {
350
+ "screenReader": true,
351
+ "disableLoadingPhrases": true
352
+ }
353
+ ```
354
+
355
+ ### Example `settings.json`:
356
+
357
+ ```json
358
+ {
359
+ "theme": "GitHub",
360
+ "sandbox": "docker",
361
+ "toolDiscoveryCommand": "bin/get_tools",
362
+ "toolCallCommand": "bin/call_tool",
363
+ "mcpServers": {
364
+ "mainServer": {
365
+ "command": "bin/mcp_server.py"
366
+ },
367
+ "anotherServer": {
368
+ "command": "node",
369
+ "args": ["mcp_server.js", "--verbose"]
370
+ }
371
+ },
372
+ "telemetry": {
373
+ "enabled": true,
374
+ "target": "local",
375
+ "otlpEndpoint": "http://localhost:4317",
376
+ "logPrompts": true
377
+ },
378
+ "usageStatisticsEnabled": true,
379
+ "hideTips": false,
380
+ "hideBanner": false,
381
+ "maxSessionTurns": 10,
382
+ "summarizeToolOutput": {
383
+ "run_shell_command": {
384
+ "tokenBudget": 100
385
+ }
386
+ },
387
+ "excludedProjectEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"],
388
+ "includeDirectories": ["path/to/dir1", "~/path/to/dir2", "../path/to/dir3"],
389
+ "loadMemoryFromIncludeDirectories": true
390
+ }
391
+ ```
392
+
393
+ ## Shell History
394
+
395
+ The CLI keeps a history of shell commands you run. To avoid conflicts between different projects, this history is stored in a project-specific directory within your user's home folder.
396
+
397
+ - **Location:** `~/.gemini/tmp/<project_hash>/shell_history`
398
+ - `<project_hash>` is a unique identifier generated from your project's root path.
399
+ - The history is stored in a file named `shell_history`.
400
+
401
+ ## Environment Variables & `.env` Files
402
+
403
+ Environment variables are a common way to configure applications, especially for sensitive information like API keys or for settings that might change between environments. For authentication setup, see the [Authentication documentation](./authentication.md) which covers all available authentication methods.
404
+
405
+ The CLI automatically loads environment variables from an `.env` file. The loading order is:
406
+
407
+ 1. `.env` file in the current working directory.
408
+ 2. If not found, it searches upwards in parent directories until it finds an `.env` file or reaches the project root (identified by a `.git` folder) or the home directory.
409
+ 3. If still not found, it looks for `~/.env` (in the user's home directory).
410
+
411
+ **Environment Variable Exclusion:** Some environment variables (like `DEBUG` and `DEBUG_MODE`) are automatically excluded from being loaded from project `.env` files to prevent interference with gemini-cli behavior. Variables from `.gemini/.env` files are never excluded. You can customize this behavior using the `excludedProjectEnvVars` setting in your `settings.json` file.
412
+
413
+ - **`GEMINI_API_KEY`**:
414
+ - Your API key for the Gemini API.
415
+ - One of several available [authentication methods](./authentication.md).
416
+ - Set this in your shell profile (e.g., `~/.bashrc`, `~/.zshrc`) or an `.env` file.
417
+ - **`GEMINI_MODEL`**:
418
+ - Specifies the default Gemini model to use.
419
+ - Overrides the hardcoded default
420
+ - Example: `export GEMINI_MODEL="gemini-2.5-flash"`
421
+ - **`GOOGLE_API_KEY`**:
422
+ - Your Google Cloud API key.
423
+ - Required for using Vertex AI in express mode.
424
+ - Ensure you have the necessary permissions.
425
+ - Example: `export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"`.
426
+ - **`GOOGLE_CLOUD_PROJECT`**:
427
+ - Your Google Cloud Project ID.
428
+ - Required for using Code Assist or Vertex AI.
429
+ - If using Vertex AI, ensure you have the necessary permissions in this project.
430
+ - **Cloud Shell Note:** When running in a Cloud Shell environment, this variable defaults to a special project allocated for Cloud Shell users. If you have `GOOGLE_CLOUD_PROJECT` set in your global environment in Cloud Shell, it will be overridden by this default. To use a different project in Cloud Shell, you must define `GOOGLE_CLOUD_PROJECT` in a `.env` file.
431
+ - Example: `export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"`.
432
+ - **`GOOGLE_APPLICATION_CREDENTIALS`** (string):
433
+ - **Description:** The path to your Google Application Credentials JSON file.
434
+ - **Example:** `export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/credentials.json"`
435
+ - **`OTLP_GOOGLE_CLOUD_PROJECT`**:
436
+ - Your Google Cloud Project ID for Telemetry in Google Cloud
437
+ - Example: `export OTLP_GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"`.
438
+ - **`GOOGLE_CLOUD_LOCATION`**:
439
+ - Your Google Cloud Project Location (e.g., us-central1).
440
+ - Required for using Vertex AI in non express mode.
441
+ - Example: `export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION"`.
442
+ - **`GEMINI_SANDBOX`**:
443
+ - Alternative to the `sandbox` setting in `settings.json`.
444
+ - Accepts `true`, `false`, `docker`, `podman`, or a custom command string.
445
+ - **`SEATBELT_PROFILE`** (macOS specific):
446
+ - Switches the Seatbelt (`sandbox-exec`) profile on macOS.
447
+ - `permissive-open`: (Default) Restricts writes to the project folder (and a few other folders, see `packages/cli/src/utils/sandbox-macos-permissive-open.sb`) but allows other operations.
448
+ - `strict`: Uses a strict profile that declines operations by default.
449
+ - `<profile_name>`: Uses a custom profile. To define a custom profile, create a file named `sandbox-macos-<profile_name>.sb` in your project's `.gemini/` directory (e.g., `my-project/.gemini/sandbox-macos-custom.sb`).
450
+ - **`DEBUG` or `DEBUG_MODE`** (often used by underlying libraries or the CLI itself):
451
+ - Set to `true` or `1` to enable verbose debug logging, which can be helpful for troubleshooting.
452
+ - **Note:** These variables are automatically excluded from project `.env` files by default to prevent interference with gemini-cli behavior. Use `.gemini/.env` files if you need to set these for gemini-cli specifically.
453
+ - **`NO_COLOR`**:
454
+ - Set to any value to disable all color output in the CLI.
455
+ - **`CLI_TITLE`**:
456
+ - Set to a string to customize the title of the CLI.
457
+ - **`CODE_ASSIST_ENDPOINT`**:
458
+ - Specifies the endpoint for the code assist server.
459
+ - This is useful for development and testing.
460
+
461
+ ## Command-Line Arguments
462
+
463
+ Arguments passed directly when running the CLI can override other configurations for that specific session.
464
+
465
+ - **`--model <model_name>`** (**`-m <model_name>`**):
466
+ - Specifies the Gemini model to use for this session.
467
+ - Example: `npm start -- --model gemini-1.5-pro-latest`
468
+ - **`--prompt <your_prompt>`** (**`-p <your_prompt>`**):
469
+ - Used to pass a prompt directly to the command. This invokes Gemini CLI in a non-interactive mode.
470
+ - **`--prompt-interactive <your_prompt>`** (**`-i <your_prompt>`**):
471
+ - Starts an interactive session with the provided prompt as the initial input.
472
+ - The prompt is processed within the interactive session, not before it.
473
+ - Cannot be used when piping input from stdin.
474
+ - Example: `gemini -i "explain this code"`
475
+ - **`--sandbox`** (**`-s`**):
476
+ - Enables sandbox mode for this session.
477
+ - **`--sandbox-image`**:
478
+ - Sets the sandbox image URI.
479
+ - **`--debug`** (**`-d`**):
480
+ - Enables debug mode for this session, providing more verbose output.
481
+ - **`--all-files`** (**`-a`**):
482
+ - If set, recursively includes all files within the current directory as context for the prompt.
483
+ - **`--help`** (or **`-h`**):
484
+ - Displays help information about command-line arguments.
485
+ - **`--show-memory-usage`**:
486
+ - Displays the current memory usage.
487
+ - **`--yolo`**:
488
+ - Enables YOLO mode, which automatically approves all tool calls.
489
+ - **`--approval-mode <mode>`**:
490
+ - Sets the approval mode for tool calls. Available modes:
491
+ - `default`: Prompt for approval on each tool call (default behavior)
492
+ - `auto_edit`: Automatically approve edit tools (replace, write_file) while prompting for others
493
+ - `yolo`: Automatically approve all tool calls (equivalent to `--yolo`)
494
+ - Cannot be used together with `--yolo`. Use `--approval-mode=yolo` instead of `--yolo` for the new unified approach.
495
+ - Example: `gemini --approval-mode auto_edit`
496
+ - **`--allowed-tools <tool1,tool2,...>`**:
497
+ - A comma-separated list of tool names that will bypass the confirmation dialog.
498
+ - Example: `gemini --allowed-tools "ShellTool(git status)"`
499
+ - **`--telemetry`**:
500
+ - Enables [telemetry](../telemetry.md).
501
+ - **`--telemetry-target`**:
502
+ - Sets the telemetry target. See [telemetry](../telemetry.md) for more information.
503
+ - **`--telemetry-otlp-endpoint`**:
504
+ - Sets the OTLP endpoint for telemetry. See [telemetry](../telemetry.md) for more information.
505
+ - **`--telemetry-otlp-protocol`**:
506
+ - Sets the OTLP protocol for telemetry (`grpc` or `http`). Defaults to `grpc`. See [telemetry](../telemetry.md) for more information.
507
+ - **`--telemetry-log-prompts`**:
508
+ - Enables logging of prompts for telemetry. See [telemetry](../telemetry.md) for more information.
509
+ - **`--checkpointing`**:
510
+ - Enables [checkpointing](../checkpointing.md).
511
+ - **`--extensions <extension_name ...>`** (**`-e <extension_name ...>`**):
512
+ - Specifies a list of extensions to use for the session. If not provided, all available extensions are used.
513
+ - Use the special term `gemini -e none` to disable all extensions.
514
+ - Example: `gemini -e my-extension -e my-other-extension`
515
+ - **`--list-extensions`** (**`-l`**):
516
+ - Lists all available extensions and exits.
517
+ - **`--proxy`**:
518
+ - Sets the proxy for the CLI.
519
+ - Example: `--proxy http://localhost:7890`.
520
+ - **`--include-directories <dir1,dir2,...>`**:
521
+ - Includes additional directories in the workspace for multi-directory support.
522
+ - Can be specified multiple times or as comma-separated values.
523
+ - 5 directories can be added at maximum.
524
+ - Example: `--include-directories /path/to/project1,/path/to/project2` or `--include-directories /path/to/project1 --include-directories /path/to/project2`
525
+ - **`--screen-reader`**:
526
+ - Enables screen reader mode for accessibility.
527
+ - **`--version`**:
528
+ - Displays the version of the CLI.
529
+
530
+ ## Context Files (Hierarchical Instructional Context)
531
+
532
+ While not strictly configuration for the CLI's _behavior_, context files (defaulting to `GEMINI.md` but configurable via the `contextFileName` setting) are crucial for configuring the _instructional context_ (also referred to as "memory") provided to the Gemini model. This powerful feature allows you to give project-specific instructions, coding style guides, or any relevant background information to the AI, making its responses more tailored and accurate to your needs. The CLI includes UI elements, such as an indicator in the footer showing the number of loaded context files, to keep you informed about the active context.
533
+
534
+ - **Purpose:** These Markdown files contain instructions, guidelines, or context that you want the Gemini model to be aware of during your interactions. The system is designed to manage this instructional context hierarchically.
535
+
536
+ ### Example Context File Content (e.g., `GEMINI.md`)
537
+
538
+ Here's a conceptual example of what a context file at the root of a TypeScript project might contain:
539
+
540
+ ```markdown
541
+ # Project: My Awesome TypeScript Library
542
+
543
+ ## General Instructions:
544
+
545
+ - When generating new TypeScript code, please follow the existing coding style.
546
+ - Ensure all new functions and classes have JSDoc comments.
547
+ - Prefer functional programming paradigms where appropriate.
548
+ - All code should be compatible with TypeScript 5.0 and Node.js 20+.
549
+
550
+ ## Coding Style:
551
+
552
+ - Use 2 spaces for indentation.
553
+ - Interface names should be prefixed with `I` (e.g., `IUserService`).
554
+ - Private class members should be prefixed with an underscore (`_`).
555
+ - Always use strict equality (`===` and `!==`).
556
+
557
+ ## Specific Component: `src/api/client.ts`
558
+
559
+ - This file handles all outbound API requests.
560
+ - When adding new API call functions, ensure they include robust error handling and logging.
561
+ - Use the existing `fetchWithRetry` utility for all GET requests.
562
+
563
+ ## Regarding Dependencies:
564
+
565
+ - Avoid introducing new external dependencies unless absolutely necessary.
566
+ - If a new dependency is required, please state the reason.
567
+ ```
568
+
569
+ This example demonstrates how you can provide general project context, specific coding conventions, and even notes about particular files or components. The more relevant and precise your context files are, the better the AI can assist you. Project-specific context files are highly encouraged to establish conventions and context.
570
+
571
+ - **Hierarchical Loading and Precedence:** The CLI implements a sophisticated hierarchical memory system by loading context files (e.g., `GEMINI.md`) from several locations. Content from files lower in this list (more specific) typically overrides or supplements content from files higher up (more general). The exact concatenation order and final context can be inspected using the `/memory show` command. The typical loading order is:
572
+ 1. **Global Context File:**
573
+ - Location: `~/.gemini/<contextFileName>` (e.g., `~/.gemini/GEMINI.md` in your user home directory).
574
+ - Scope: Provides default instructions for all your projects.
575
+ 2. **Project Root & Ancestors Context Files:**
576
+ - Location: The CLI searches for the configured context file in the current working directory and then in each parent directory up to either the project root (identified by a `.git` folder) or your home directory.
577
+ - Scope: Provides context relevant to the entire project or a significant portion of it.
578
+ 3. **Sub-directory Context Files (Contextual/Local):**
579
+ - Location: The CLI also scans for the configured context file in subdirectories _below_ the current working directory (respecting common ignore patterns like `node_modules`, `.git`, etc.). The breadth of this search is limited to 200 directories by default, but can be configured with a `memoryDiscoveryMaxDirs` field in your `settings.json` file.
580
+ - Scope: Allows for highly specific instructions relevant to a particular component, module, or subsection of your project.
581
+ - **Concatenation & UI Indication:** The contents of all found context files are concatenated (with separators indicating their origin and path) and provided as part of the system prompt to the Gemini model. The CLI footer displays the count of loaded context files, giving you a quick visual cue about the active instructional context.
582
+ - **Importing Content:** You can modularize your context files by importing other Markdown files using the `@path/to/file.md` syntax. For more details, see the [Memory Import Processor documentation](../core/memport.md).
583
+ - **Commands for Memory Management:**
584
+ - Use `/memory refresh` to force a re-scan and reload of all context files from all configured locations. This updates the AI's instructional context.
585
+ - Use `/memory show` to display the combined instructional context currently loaded, allowing you to verify the hierarchy and content being used by the AI.
586
+ - See the [Commands documentation](./commands.md#memory) for full details on the `/memory` command and its sub-commands (`show` and `refresh`).
587
+
588
+ By understanding and utilizing these configuration layers and the hierarchical nature of context files, you can effectively manage the AI's memory and tailor the Gemini CLI's responses to your specific needs and projects.
589
+
590
+ ## Sandboxing
591
+
592
+ The Gemini CLI can execute potentially unsafe operations (like shell commands and file modifications) within a sandboxed environment to protect your system.
593
+
594
+ Sandboxing is disabled by default, but you can enable it in a few ways:
595
+
596
+ - Using `--sandbox` or `-s` flag.
597
+ - Setting `GEMINI_SANDBOX` environment variable.
598
+ - Sandbox is enabled when using `--yolo` or `--approval-mode=yolo` by default.
599
+
600
+ By default, it uses a pre-built `gemini-cli-sandbox` Docker image.
601
+
602
+ For project-specific sandboxing needs, you can create a custom Dockerfile at `.gemini/sandbox.Dockerfile` in your project's root directory. This Dockerfile can be based on the base sandbox image:
603
+
604
+ ```dockerfile
605
+ FROM gemini-cli-sandbox
606
+
607
+ # Add your custom dependencies or configurations here
608
+ # For example:
609
+ # RUN apt-get update && apt-get install -y some-package
610
+ # COPY ./my-config /app/my-config
611
+ ```
612
+
613
+ When `.gemini/sandbox.Dockerfile` exists, you can use `BUILD_SANDBOX` environment variable when running Gemini CLI to automatically build the custom sandbox image:
614
+
615
+ ```bash
616
+ BUILD_SANDBOX=1 gemini -s
617
+ ```
618
+
619
+ ## Usage Statistics
620
+
621
+ To help us improve the Gemini CLI, we collect anonymized usage statistics. This data helps us understand how the CLI is used, identify common issues, and prioritize new features.
622
+
623
+ **What we collect:**
624
+
625
+ - **Tool Calls:** We log the names of the tools that are called, whether they succeed or fail, and how long they take to execute. We do not collect the arguments passed to the tools or any data returned by them.
626
+ - **API Requests:** We log the Gemini model used for each request, the duration of the request, and whether it was successful. We do not collect the content of the prompts or responses.
627
+ - **Session Information:** We collect information about the configuration of the CLI, such as the enabled tools and the approval mode.
628
+
629
+ **What we DON'T collect:**
630
+
631
+ - **Personally Identifiable Information (PII):** We do not collect any personal information, such as your name, email address, or API keys.
632
+ - **Prompt and Response Content:** We do not log the content of your prompts or the responses from the Gemini model.
633
+ - **File Content:** We do not log the content of any files that are read or written by the CLI.
634
+
635
+ **How to opt out:**
636
+
637
+ You can opt out of usage statistics collection at any time by setting the `usageStatisticsEnabled` property to `false` in your `settings.json` file:
638
+
639
+ ```json
640
+ {
641
+ "usageStatisticsEnabled": false
642
+ }
643
+ ```
projects/gemini-cli/docs/cli/configuration.md ADDED
@@ -0,0 +1,612 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI Configuration
2
+
3
+ **Note on New Configuration Format**
4
+
5
+ The format of the `settings.json` file has been updated to a new, more organized structure.
6
+
7
+ - The new format will be supported in the stable release starting **[09/10/25]**.
8
+ - Automatic migration from the old format to the new format will begin on **[09/17/25]**.
9
+
10
+ For details on the previous format, please see the [v1 Configuration documentation](./configuration-v1.md).
11
+
12
+ Gemini CLI offers several ways to configure its behavior, including environment variables, command-line arguments, and settings files. This document outlines the different configuration methods and available settings.
13
+
14
+ ## Configuration layers
15
+
16
+ Configuration is applied in the following order of precedence (lower numbers are overridden by higher numbers):
17
+
18
+ 1. **Default values:** Hardcoded defaults within the application.
19
+ 2. **System defaults file:** System-wide default settings that can be overridden by other settings files.
20
+ 3. **User settings file:** Global settings for the current user.
21
+ 4. **Project settings file:** Project-specific settings.
22
+ 5. **System settings file:** System-wide settings that override all other settings files.
23
+ 6. **Environment variables:** System-wide or session-specific variables, potentially loaded from `.env` files.
24
+ 7. **Command-line arguments:** Values passed when launching the CLI.
25
+
26
+ ## Settings files
27
+
28
+ Gemini CLI uses JSON settings files for persistent configuration. There are four locations for these files:
29
+
30
+ - **System defaults file:**
31
+ - **Location:** `/etc/gemini-cli/system-defaults.json` (Linux), `C:\ProgramData\gemini-cli\system-defaults.json` (Windows) or `/Library/Application Support/GeminiCli/system-defaults.json` (macOS). The path can be overridden using the `GEMINI_CLI_SYSTEM_DEFAULTS_PATH` environment variable.
32
+ - **Scope:** Provides a base layer of system-wide default settings. These settings have the lowest precedence and are intended to be overridden by user, project, or system override settings.
33
+ - **User settings file:**
34
+ - **Location:** `~/.gemini/settings.json` (where `~` is your home directory).
35
+ - **Scope:** Applies to all Gemini CLI sessions for the current user. User settings override system defaults.
36
+ - **Project settings file:**
37
+ - **Location:** `.gemini/settings.json` within your project's root directory.
38
+ - **Scope:** Applies only when running Gemini CLI from that specific project. Project settings override user settings and system defaults.
39
+ - **System settings file:**
40
+ - **Location:** `/etc/gemini-cli/settings.json` (Linux), `C:\ProgramData\gemini-cli\settings.json` (Windows) or `/Library/Application Support/GeminiCli/settings.json` (macOS). The path can be overridden using the `GEMINI_CLI_SYSTEM_SETTINGS_PATH` environment variable.
41
+ - **Scope:** Applies to all Gemini CLI sessions on the system, for all users. System settings act as overrides, taking precedence over all other settings files. May be useful for system administrators at enterprises to have controls over users' Gemini CLI setups.
42
+
43
+ **Note on environment variables in settings:** String values within your `settings.json` files can reference environment variables using either `$VAR_NAME` or `${VAR_NAME}` syntax. These variables will be automatically resolved when the settings are loaded. For example, if you have an environment variable `MY_API_TOKEN`, you could use it in `settings.json` like this: `"apiKey": "$MY_API_TOKEN"`.
44
+
45
+ > **Note for Enterprise Users:** For guidance on deploying and managing Gemini CLI in a corporate environment, please see the [Enterprise Configuration](./enterprise.md) documentation.
46
+
47
+ ### The `.gemini` directory in your project
48
+
49
+ In addition to a project settings file, a project's `.gemini` directory can contain other project-specific files related to Gemini CLI's operation, such as:
50
+
51
+ - [Custom sandbox profiles](#sandboxing) (e.g., `.gemini/sandbox-macos-custom.sb`, `.gemini/sandbox.Dockerfile`).
52
+
53
+ ### Available settings in `settings.json`
54
+
55
+ Settings are organized into categories. All settings should be placed within their corresponding top-level category object in your `settings.json` file.
56
+
57
+ #### `general`
58
+
59
+ - **`general.preferredEditor`** (string):
60
+ - **Description:** The preferred editor to open files in.
61
+ - **Default:** `undefined`
62
+
63
+ - **`general.vimMode`** (boolean):
64
+ - **Description:** Enable Vim keybindings.
65
+ - **Default:** `false`
66
+
67
+ - **`general.disableAutoUpdate`** (boolean):
68
+ - **Description:** Disable automatic updates.
69
+ - **Default:** `false`
70
+
71
+ - **`general.disableUpdateNag`** (boolean):
72
+ - **Description:** Disable update notification prompts.
73
+ - **Default:** `false`
74
+
75
+ - **`general.checkpointing.enabled`** (boolean):
76
+ - **Description:** Enable session checkpointing for recovery.
77
+ - **Default:** `false`
78
+
79
+ #### `ui`
80
+
81
+ - **`ui.theme`** (string):
82
+ - **Description:** The color theme for the UI. See [Themes](./themes.md) for available options.
83
+ - **Default:** `undefined`
84
+
85
+ - **`ui.customThemes`** (object):
86
+ - **Description:** Custom theme definitions.
87
+ - **Default:** `{}`
88
+
89
+ - **`ui.hideWindowTitle`** (boolean):
90
+ - **Description:** Hide the window title bar.
91
+ - **Default:** `false`
92
+
93
+ - **`ui.hideTips`** (boolean):
94
+ - **Description:** Hide helpful tips in the UI.
95
+ - **Default:** `false`
96
+
97
+ - **`ui.hideBanner`** (boolean):
98
+ - **Description:** Hide the application banner.
99
+ - **Default:** `false`
100
+
101
+ - **`ui.hideFooter`** (boolean):
102
+ - **Description:** Hide the footer from the UI.
103
+ - **Default:** `false`
104
+
105
+ - **`ui.showMemoryUsage`** (boolean):
106
+ - **Description:** Display memory usage information in the UI.
107
+ - **Default:** `false`
108
+
109
+ - **`ui.showLineNumbers`** (boolean):
110
+ - **Description:** Show line numbers in the chat.
111
+ - **Default:** `false`
112
+
113
+ - **`ui.accessibility.disableLoadingPhrases`** (boolean):
114
+ - **Description:** Disable loading phrases for accessibility.
115
+ - **Default:** `false`
116
+
117
+ #### `ide`
118
+
119
+ - **`ide.enabled`** (boolean):
120
+ - **Description:** Enable IDE integration mode.
121
+ - **Default:** `false`
122
+
123
+ - **`ide.hasSeenNudge`** (boolean):
124
+ - **Description:** Whether the user has seen the IDE integration nudge.
125
+ - **Default:** `false`
126
+
127
+ #### `privacy`
128
+
129
+ - **`privacy.usageStatisticsEnabled`** (boolean):
130
+ - **Description:** Enable collection of usage statistics.
131
+ - **Default:** `true`
132
+
133
+ #### `model`
134
+
135
+ - **`model.name`** (string):
136
+ - **Description:** The Gemini model to use for conversations.
137
+ - **Default:** `undefined`
138
+
139
+ - **`model.maxSessionTurns`** (number):
140
+ - **Description:** Maximum number of user/model/tool turns to keep in a session. -1 means unlimited.
141
+ - **Default:** `-1`
142
+
143
+ - **`model.summarizeToolOutput`** (object):
144
+ - **Description:** Settings for summarizing tool output.
145
+ - **Default:** `undefined`
146
+
147
+ - **`model.chatCompression`** (object):
148
+ - **Description:** Chat compression settings.
149
+ - **Default:** `undefined`
150
+
151
+ - **`model.skipNextSpeakerCheck`** (boolean):
152
+ - **Description:** Skip the next speaker check.
153
+ - **Default:** `false`
154
+
155
+ #### `context`
156
+
157
+ - **`context.fileName`** (string or array of strings):
158
+ - **Description:** The name of the context file(s).
159
+ - **Default:** `undefined`
160
+
161
+ - **`context.importFormat`** (string):
162
+ - **Description:** The format to use when importing memory.
163
+ - **Default:** `undefined`
164
+
165
+ - **`context.discoveryMaxDirs`** (number):
166
+ - **Description:** Maximum number of directories to search for memory.
167
+ - **Default:** `200`
168
+
169
+ - **`context.includeDirectories`** (array):
170
+ - **Description:** Additional directories to include in the workspace context. Missing directories will be skipped with a warning.
171
+ - **Default:** `[]`
172
+
173
+ - **`context.loadFromIncludeDirectories`** (boolean):
174
+ - **Description:** Whether to load memory files from include directories.
175
+ - **Default:** `false`
176
+
177
+ - **`context.fileFiltering.respectGitIgnore`** (boolean):
178
+ - **Description:** Respect .gitignore files when searching.
179
+ - **Default:** `true`
180
+
181
+ - **`context.fileFiltering.respectGeminiIgnore`** (boolean):
182
+ - **Description:** Respect .geminiignore files when searching.
183
+ - **Default:** `true`
184
+
185
+ - **`context.fileFiltering.enableRecursiveFileSearch`** (boolean):
186
+ - **Description:** Enable recursive file search functionality.
187
+ - **Default:** `true`
188
+
189
+ #### `tools`
190
+
191
+ - **`tools.sandbox`** (boolean or string):
192
+ - **Description:** Sandbox execution environment (can be a boolean or a path string).
193
+ - **Default:** `undefined`
194
+
195
+ - **`tools.usePty`** (boolean):
196
+ - **Description:** Use node-pty for shell command execution. Fallback to child_process still applies.
197
+ - **Default:** `false`
198
+
199
+ - **`tools.core`** (array of strings):
200
+ - **Description:** Paths to core tool definitions.
201
+ - **Default:** `undefined`
202
+
203
+ - **`tools.exclude`** (array of strings):
204
+ - **Description:** Tool names to exclude from discovery.
205
+ - **Default:** `undefined`
206
+
207
+ - **`tools.discoveryCommand`** (string):
208
+ - **Description:** Command to run for tool discovery.
209
+ - **Default:** `undefined`
210
+
211
+ - **`tools.callCommand`** (string):
212
+ - **Description:** Command to run for tool calls.
213
+ - **Default:** `undefined`
214
+
215
+ #### `mcp`
216
+
217
+ - **`mcp.serverCommand`** (string):
218
+ - **Description:** Command to start an MCP server.
219
+ - **Default:** `undefined`
220
+
221
+ - **`mcp.allowed`** (array of strings):
222
+ - **Description:** A whitelist of MCP servers to allow.
223
+ - **Default:** `undefined`
224
+
225
+ - **`mcp.excluded`** (array of strings):
226
+ - **Description:** A blacklist of MCP servers to exclude.
227
+ - **Default:** `undefined`
228
+
229
+ #### `security`
230
+
231
+ - **`security.folderTrust.featureEnabled`** (boolean):
232
+ - **Description:** Enable folder trust feature for enhanced security.
233
+ - **Default:** `false`
234
+
235
+ - **`security.folderTrust.enabled`** (boolean):
236
+ - **Description:** Setting to track whether Folder trust is enabled.
237
+ - **Default:** `false`
238
+
239
+ - **`security.auth.selectedType`** (string):
240
+ - **Description:** The currently selected authentication type.
241
+ - **Default:** `undefined`
242
+
243
+ - **`security.auth.useExternal`** (boolean):
244
+ - **Description:** Whether to use an external authentication flow.
245
+ - **Default:** `undefined`
246
+
247
+ #### `advanced`
248
+
249
+ - **`advanced.autoConfigureMemory`** (boolean):
250
+ - **Description:** Automatically configure Node.js memory limits.
251
+ - **Default:** `false`
252
+
253
+ - **`advanced.dnsResolutionOrder`** (string):
254
+ - **Description:** The DNS resolution order.
255
+ - **Default:** `undefined`
256
+
257
+ - **`advanced.excludedEnvVars`** (array of strings):
258
+ - **Description:** Environment variables to exclude from project context.
259
+ - **Default:** `["DEBUG","DEBUG_MODE"]`
260
+
261
+ - **`advanced.bugCommand`** (object):
262
+ - **Description:** Configuration for the bug report command.
263
+ - **Default:** `undefined`
264
+
265
+ #### Top-Level Settings
266
+
267
+ The following settings remain at the top level of the `settings.json` file.
268
+
269
+ - **`mcpServers`** (object):
270
+ - **Description:** Configures connections to one or more Model-Context Protocol (MCP) servers for discovering and using custom tools. Gemini CLI attempts to connect to each configured MCP server to discover available tools. If multiple MCP servers expose a tool with the same name, the tool names will be prefixed with the server alias you defined in the configuration (e.g., `serverAlias__actualToolName`) to avoid conflicts. Note that the system might strip certain schema properties from MCP tool definitions for compatibility. At least one of `command`, `url`, or `httpUrl` must be provided. If multiple are specified, the order of precedence is `httpUrl`, then `url`, then `command`.
271
+ - **Default:** `{}`
272
+ - **Properties:**
273
+ - **`<SERVER_NAME>`** (object): The server parameters for the named server.
274
+ - `command` (string, optional): The command to execute to start the MCP server via standard I/O.
275
+ - `args` (array of strings, optional): Arguments to pass to the command.
276
+ - `env` (object, optional): Environment variables to set for the server process.
277
+ - `cwd` (string, optional): The working directory in which to start the server.
278
+ - `url` (string, optional): The URL of an MCP server that uses Server-Sent Events (SSE) for communication.
279
+ - `httpUrl` (string, optional): The URL of an MCP server that uses streamable HTTP for communication.
280
+ - `headers` (object, optional): A map of HTTP headers to send with requests to `url` or `httpUrl`.
281
+ - `timeout` (number, optional): Timeout in milliseconds for requests to this MCP server.
282
+ - `trust` (boolean, optional): Trust this server and bypass all tool call confirmations.
283
+ - `description` (string, optional): A brief description of the server, which may be used for display purposes.
284
+ - `includeTools` (array of strings, optional): List of tool names to include from this MCP server. When specified, only the tools listed here will be available from this server (whitelist behavior). If not specified, all tools from the server are enabled by default.
285
+ - `excludeTools` (array of strings, optional): List of tool names to exclude from this MCP server. Tools listed here will not be available to the model, even if they are exposed by the server. **Note:** `excludeTools` takes precedence over `includeTools` - if a tool is in both lists, it will be excluded.
286
+
287
+ - **`telemetry`** (object)
288
+ - **Description:** Configures logging and metrics collection for Gemini CLI. For more information, see [Telemetry](../telemetry.md).
289
+ - **Default:** `undefined`
290
+ - **Properties:**
291
+ - **`enabled`** (boolean): Whether or not telemetry is enabled.
292
+ - **`target`** (string): The destination for collected telemetry. Supported values are `local` and `gcp`.
293
+ - **`otlpEndpoint`** (string): The endpoint for the OTLP Exporter.
294
+ - **`otlpProtocol`** (string): The protocol for the OTLP Exporter (`grpc` or `http`).
295
+ - **`logPrompts`** (boolean): Whether or not to include the content of user prompts in the logs.
296
+ - **`outfile`** (string): The file to write telemetry to when `target` is `local`.
297
+
298
+ ### Example `settings.json`
299
+
300
+ Here is an example of a `settings.json` file with the new nested structure:
301
+
302
+ ```json
303
+ {
304
+ "general": {
305
+ "vimMode": true,
306
+ "preferredEditor": "code"
307
+ },
308
+ "ui": {
309
+ "theme": "GitHub",
310
+ "hideBanner": true,
311
+ "hideTips": false
312
+ },
313
+ "tools": {
314
+ "sandbox": "docker",
315
+ "discoveryCommand": "bin/get_tools",
316
+ "callCommand": "bin/call_tool",
317
+ "exclude": ["write_file"]
318
+ },
319
+ "mcpServers": {
320
+ "mainServer": {
321
+ "command": "bin/mcp_server.py"
322
+ },
323
+ "anotherServer": {
324
+ "command": "node",
325
+ "args": ["mcp_server.js", "--verbose"]
326
+ }
327
+ },
328
+ "telemetry": {
329
+ "enabled": true,
330
+ "target": "local",
331
+ "otlpEndpoint": "http://localhost:4317",
332
+ "logPrompts": true
333
+ },
334
+ "privacy": {
335
+ "usageStatisticsEnabled": true
336
+ },
337
+ "model": {
338
+ "name": "gemini-1.5-pro-latest",
339
+ "maxSessionTurns": 10,
340
+ "summarizeToolOutput": {
341
+ "run_shell_command": {
342
+ "tokenBudget": 100
343
+ }
344
+ }
345
+ },
346
+ "context": {
347
+ "fileName": ["CONTEXT.md", "GEMINI.md"],
348
+ "includeDirectories": ["path/to/dir1", "~/path/to/dir2", "../path/to/dir3"],
349
+ "loadFromIncludeDirectories": true,
350
+ "fileFiltering": {
351
+ "respectGitIgnore": false
352
+ }
353
+ },
354
+ "advanced": {
355
+ "excludedEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"]
356
+ }
357
+ }
358
+ ```
359
+
360
+ ## Shell History
361
+
362
+ The CLI keeps a history of shell commands you run. To avoid conflicts between different projects, this history is stored in a project-specific directory within your user's home folder.
363
+
364
+ - **Location:** `~/.gemini/tmp/<project_hash>/shell_history`
365
+ - `<project_hash>` is a unique identifier generated from your project's root path.
366
+ - The history is stored in a file named `shell_history`.
367
+
368
+ ## Environment Variables & `.env` Files
369
+
370
+ Environment variables are a common way to configure applications, especially for sensitive information like API keys or for settings that might change between environments. For authentication setup, see the [Authentication documentation](./authentication.md) which covers all available authentication methods.
371
+
372
+ The CLI automatically loads environment variables from an `.env` file. The loading order is:
373
+
374
+ 1. `.env` file in the current working directory.
375
+ 2. If not found, it searches upwards in parent directories until it finds an `.env` file or reaches the project root (identified by a `.git` folder) or the home directory.
376
+ 3. If still not found, it looks for `~/.env` (in the user's home directory).
377
+
378
+ **Environment Variable Exclusion:** Some environment variables (like `DEBUG` and `DEBUG_MODE`) are automatically excluded from being loaded from project `.env` files to prevent interference with gemini-cli behavior. Variables from `.gemini/.env` files are never excluded. You can customize this behavior using the `advanced.excludedEnvVars` setting in your `settings.json` file.
379
+
380
+ - **`GEMINI_API_KEY`**:
381
+ - Your API key for the Gemini API.
382
+ - One of several available [authentication methods](./authentication.md).
383
+ - Set this in your shell profile (e.g., `~/.bashrc`, `~/.zshrc`) or an `.env` file.
384
+ - **`GEMINI_MODEL`**:
385
+ - Specifies the default Gemini model to use.
386
+ - Overrides the hardcoded default
387
+ - Example: `export GEMINI_MODEL="gemini-2.5-flash"`
388
+ - **`GOOGLE_API_KEY`**:
389
+ - Your Google Cloud API key.
390
+ - Required for using Vertex AI in express mode.
391
+ - Ensure you have the necessary permissions.
392
+ - Example: `export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"`.
393
+ - **`GOOGLE_CLOUD_PROJECT`**:
394
+ - Your Google Cloud Project ID.
395
+ - Required for using Code Assist or Vertex AI.
396
+ - If using Vertex AI, ensure you have the necessary permissions in this project.
397
+ - **Cloud Shell Note:** When running in a Cloud Shell environment, this variable defaults to a special project allocated for Cloud Shell users. If you have `GOOGLE_CLOUD_PROJECT` set in your global environment in Cloud Shell, it will be overridden by this default. To use a different project in Cloud Shell, you must define `GOOGLE_CLOUD_PROJECT` in a `.env` file.
398
+ - Example: `export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"`.
399
+ - **`GOOGLE_APPLICATION_CREDENTIALS`** (string):
400
+ - **Description:** The path to your Google Application Credentials JSON file.
401
+ - **Example:** `export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/credentials.json"`
402
+ - **`OTLP_GOOGLE_CLOUD_PROJECT`**:
403
+ - Your Google Cloud Project ID for Telemetry in Google Cloud
404
+ - Example: `export OTLP_GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"`.
405
+ - **`GOOGLE_CLOUD_LOCATION`**:
406
+ - Your Google Cloud Project Location (e.g., us-central1).
407
+ - Required for using Vertex AI in non express mode.
408
+ - Example: `export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION"`.
409
+ - **`GEMINI_SANDBOX`**:
410
+ - Alternative to the `sandbox` setting in `settings.json`.
411
+ - Accepts `true`, `false`, `docker`, `podman`, or a custom command string.
412
+ - **`SEATBELT_PROFILE`** (macOS specific):
413
+ - Switches the Seatbelt (`sandbox-exec`) profile on macOS.
414
+ - `permissive-open`: (Default) Restricts writes to the project folder (and a few other folders, see `packages/cli/src/utils/sandbox-macos-permissive-open.sb`) but allows other operations.
415
+ - `strict`: Uses a strict profile that declines operations by default.
416
+ - `<profile_name>`: Uses a custom profile. To define a custom profile, create a file named `sandbox-macos-<profile_name>.sb` in your project's `.gemini/` directory (e.g., `my-project/.gemini/sandbox-macos-custom.sb`).
417
+ - **`DEBUG` or `DEBUG_MODE`** (often used by underlying libraries or the CLI itself):
418
+ - Set to `true` or `1` to enable verbose debug logging, which can be helpful for troubleshooting.
419
+ - **Note:** These variables are automatically excluded from project `.env` files by default to prevent interference with gemini-cli behavior. Use `.gemini/.env` files if you need to set these for gemini-cli specifically.
420
+ - **`NO_COLOR`**:
421
+ - Set to any value to disable all color output in the CLI.
422
+ - **`CLI_TITLE`**:
423
+ - Set to a string to customize the title of the CLI.
424
+ - **`CODE_ASSIST_ENDPOINT`**:
425
+ - Specifies the endpoint for the code assist server.
426
+ - This is useful for development and testing.
427
+
428
+ ## Command-Line Arguments
429
+
430
+ Arguments passed directly when running the CLI can override other configurations for that specific session.
431
+
432
+ - **`--model <model_name>`** (**`-m <model_name>`**):
433
+ - Specifies the Gemini model to use for this session.
434
+ - Example: `npm start -- --model gemini-1.5-pro-latest`
435
+ - **`--prompt <your_prompt>`** (**`-p <your_prompt>`**):
436
+ - Used to pass a prompt directly to the command. This invokes Gemini CLI in a non-interactive mode.
437
+ - **`--prompt-interactive <your_prompt>`** (**`-i <your_prompt>`**):
438
+ - Starts an interactive session with the provided prompt as the initial input.
439
+ - The prompt is processed within the interactive session, not before it.
440
+ - Cannot be used when piping input from stdin.
441
+ - Example: `gemini -i "explain this code"`
442
+ - **`--sandbox`** (**`-s`**):
443
+ - Enables sandbox mode for this session.
444
+ - **`--sandbox-image`**:
445
+ - Sets the sandbox image URI.
446
+ - **`--debug`** (**`-d`**):
447
+ - Enables debug mode for this session, providing more verbose output.
448
+ - **`--all-files`** (**`-a`**):
449
+ - If set, recursively includes all files within the current directory as context for the prompt.
450
+ - **`--help`** (or **`-h`**):
451
+ - Displays help information about command-line arguments.
452
+ - **`--show-memory-usage`**:
453
+ - Displays the current memory usage.
454
+ - **`--yolo`**:
455
+ - Enables YOLO mode, which automatically approves all tool calls.
456
+ - **`--approval-mode <mode>`**:
457
+ - Sets the approval mode for tool calls. Available modes:
458
+ - `default`: Prompt for approval on each tool call (default behavior)
459
+ - `auto_edit`: Automatically approve edit tools (replace, write_file) while prompting for others
460
+ - `yolo`: Automatically approve all tool calls (equivalent to `--yolo`)
461
+ - Cannot be used together with `--yolo`. Use `--approval-mode=yolo` instead of `--yolo` for the new unified approach.
462
+ - Example: `gemini --approval-mode auto_edit`
463
+ - **`--allowed-tools <tool1,tool2,...>`**:
464
+ - A comma-separated list of tool names that will bypass the confirmation dialog.
465
+ - Example: `gemini --allowed-tools "ShellTool(git status)"`
466
+ - **`--telemetry`**:
467
+ - Enables [telemetry](../telemetry.md).
468
+ - **`--telemetry-target`**:
469
+ - Sets the telemetry target. See [telemetry](../telemetry.md) for more information.
470
+ - **`--telemetry-otlp-endpoint`**:
471
+ - Sets the OTLP endpoint for telemetry. See [telemetry](../telemetry.md) for more information.
472
+ - **`--telemetry-otlp-protocol`**:
473
+ - Sets the OTLP protocol for telemetry (`grpc` or `http`). Defaults to `grpc`. See [telemetry](../telemetry.md) for more information.
474
+ - **`--telemetry-log-prompts`**:
475
+ - Enables logging of prompts for telemetry. See [telemetry](../telemetry.md) for more information.
476
+ - **`--checkpointing`**:
477
+ - Enables [checkpointing](../checkpointing.md).
478
+ - **`--extensions <extension_name ...>`** (**`-e <extension_name ...>`**):
479
+ - Specifies a list of extensions to use for the session. If not provided, all available extensions are used.
480
+ - Use the special term `gemini -e none` to disable all extensions.
481
+ - Example: `gemini -e my-extension -e my-other-extension`
482
+ - **`--list-extensions`** (**`-l`**):
483
+ - Lists all available extensions and exits.
484
+ - **`--proxy`**:
485
+ - Sets the proxy for the CLI.
486
+ - Example: `--proxy http://localhost:7890`.
487
+ - **`--include-directories <dir1,dir2,...>`**:
488
+ - Includes additional directories in the workspace for multi-directory support.
489
+ - Can be specified multiple times or as comma-separated values.
490
+ - 5 directories can be added at maximum.
491
+ - Example: `--include-directories /path/to/project1,/path/to/project2` or `--include-directories /path/to/project1 --include-directories /path/to/project2`
492
+ - **`--screen-reader`**:
493
+ - Enables screen reader mode for accessibility.
494
+ - **`--version`**:
495
+ - Displays the version of the CLI.
496
+
497
+ ## Context Files (Hierarchical Instructional Context)
498
+
499
+ While not strictly configuration for the CLI's _behavior_, context files (defaulting to `GEMINI.md` but configurable via the `context.fileName` setting) are crucial for configuring the _instructional context_ (also referred to as "memory") provided to the Gemini model. This powerful feature allows you to give project-specific instructions, coding style guides, or any relevant background information to the AI, making its responses more tailored and accurate to your needs. The CLI includes UI elements, such as an indicator in the footer showing the number of loaded context files, to keep you informed about the active context.
500
+
501
+ - **Purpose:** These Markdown files contain instructions, guidelines, or context that you want the Gemini model to be aware of during your interactions. The system is designed to manage this instructional context hierarchically.
502
+
503
+ ### Example Context File Content (e.g., `GEMINI.md`)
504
+
505
+ Here's a conceptual example of what a context file at the root of a TypeScript project might contain:
506
+
507
+ ```markdown
508
+ # Project: My Awesome TypeScript Library
509
+
510
+ ## General Instructions:
511
+
512
+ - When generating new TypeScript code, please follow the existing coding style.
513
+ - Ensure all new functions and classes have JSDoc comments.
514
+ - Prefer functional programming paradigms where appropriate.
515
+ - All code should be compatible with TypeScript 5.0 and Node.js 20+.
516
+
517
+ ## Coding Style:
518
+
519
+ - Use 2 spaces for indentation.
520
+ - Interface names should be prefixed with `I` (e.g., `IUserService`).
521
+ - Private class members should be prefixed with an underscore (`_`).
522
+ - Always use strict equality (`===` and `!==`).
523
+
524
+ ## Specific Component: `src/api/client.ts`
525
+
526
+ - This file handles all outbound API requests.
527
+ - When adding new API call functions, ensure they include robust error handling and logging.
528
+ - Use the existing `fetchWithRetry` utility for all GET requests.
529
+
530
+ ## Regarding Dependencies:
531
+
532
+ - Avoid introducing new external dependencies unless absolutely necessary.
533
+ - If a new dependency is required, please state the reason.
534
+ ```
535
+
536
+ This example demonstrates how you can provide general project context, specific coding conventions, and even notes about particular files or components. The more relevant and precise your context files are, the better the AI can assist you. Project-specific context files are highly encouraged to establish conventions and context.
537
+
538
+ - **Hierarchical Loading and Precedence:** The CLI implements a sophisticated hierarchical memory system by loading context files (e.g., `GEMINI.md`) from several locations. Content from files lower in this list (more specific) typically overrides or supplements content from files higher up (more general). The exact concatenation order and final context can be inspected using the `/memory show` command. The typical loading order is:
539
+ 1. **Global Context File:**
540
+ - Location: `~/.gemini/<configured-context-filename>` (e.g., `~/.gemini/GEMINI.md` in your user home directory).
541
+ - Scope: Provides default instructions for all your projects.
542
+ 2. **Project Root & Ancestors Context Files:**
543
+ - Location: The CLI searches for the configured context file in the current working directory and then in each parent directory up to either the project root (identified by a `.git` folder) or your home directory.
544
+ - Scope: Provides context relevant to the entire project or a significant portion of it.
545
+ 3. **Sub-directory Context Files (Contextual/Local):**
546
+ - Location: The CLI also scans for the configured context file in subdirectories _below_ the current working directory (respecting common ignore patterns like `node_modules`, `.git`, etc.). The breadth of this search is limited to 200 directories by default, but can be configured with the `context.discoveryMaxDirs` setting in your `settings.json` file.
547
+ - Scope: Allows for highly specific instructions relevant to a particular component, module, or subsection of your project.
548
+ - **Concatenation & UI Indication:** The contents of all found context files are concatenated (with separators indicating their origin and path) and provided as part of the system prompt to the Gemini model. The CLI footer displays the count of loaded context files, giving you a quick visual cue about the active instructional context.
549
+ - **Importing Content:** You can modularize your context files by importing other Markdown files using the `@path/to/file.md` syntax. For more details, see the [Memory Import Processor documentation](../core/memport.md).
550
+ - **Commands for Memory Management:**
551
+ - Use `/memory refresh` to force a re-scan and reload of all context files from all configured locations. This updates the AI's instructional context.
552
+ - Use `/memory show` to display the combined instructional context currently loaded, allowing you to verify the hierarchy and content being used by the AI.
553
+ - See the [Commands documentation](./commands.md#memory) for full details on the `/memory` command and its sub-commands (`show` and `refresh`).
554
+
555
+ By understanding and utilizing these configuration layers and the hierarchical nature of context files, you can effectively manage the AI's memory and tailor the Gemini CLI's responses to your specific needs and projects.
556
+
557
+ ## Sandboxing
558
+
559
+ The Gemini CLI can execute potentially unsafe operations (like shell commands and file modifications) within a sandboxed environment to protect your system.
560
+
561
+ Sandboxing is disabled by default, but you can enable it in a few ways:
562
+
563
+ - Using `--sandbox` or `-s` flag.
564
+ - Setting `GEMINI_SANDBOX` environment variable.
565
+ - Sandbox is enabled when using `--yolo` or `--approval-mode=yolo` by default.
566
+
567
+ By default, it uses a pre-built `gemini-cli-sandbox` Docker image.
568
+
569
+ For project-specific sandboxing needs, you can create a custom Dockerfile at `.gemini/sandbox.Dockerfile` in your project's root directory. This Dockerfile can be based on the base sandbox image:
570
+
571
+ ```dockerfile
572
+ FROM gemini-cli-sandbox
573
+
574
+ # Add your custom dependencies or configurations here
575
+ # For example:
576
+ # RUN apt-get update && apt-get install -y some-package
577
+ # COPY ./my-config /app/my-config
578
+ ```
579
+
580
+ When `.gemini/sandbox.Dockerfile` exists, you can use `BUILD_SANDBOX` environment variable when running Gemini CLI to automatically build the custom sandbox image:
581
+
582
+ ```bash
583
+ BUILD_SANDBOX=1 gemini -s
584
+ ```
585
+
586
+ ## Usage Statistics
587
+
588
+ To help us improve the Gemini CLI, we collect anonymized usage statistics. This data helps us understand how the CLI is used, identify common issues, and prioritize new features.
589
+
590
+ **What we collect:**
591
+
592
+ - **Tool Calls:** We log the names of the tools that are called, whether they succeed or fail, and how long they take to execute. We do not collect the arguments passed to the tools or any data returned by them.
593
+ - **API Requests:** We log the Gemini model used for each request, the duration of the request, and whether it was successful. We do not collect the content of the prompts or responses.
594
+ - **Session Information:** We collect information about the configuration of the CLI, such as the enabled tools and the approval mode.
595
+
596
+ **What we DON'T collect:**
597
+
598
+ - **Personally Identifiable Information (PII):** We do not collect any personal information, such as your name, email address, or API keys.
599
+ - **Prompt and Response Content:** We do not log the content of your prompts or the responses from the Gemini model.
600
+ - **File Content:** We do not log the content of any files that are read or written by the CLI.
601
+
602
+ **How to opt out:**
603
+
604
+ You can opt out of usage statistics collection at any time by setting the `usageStatisticsEnabled` property to `false` under the `privacy` category in your `settings.json` file:
605
+
606
+ ```json
607
+ {
608
+ "privacy": {
609
+ "usageStatisticsEnabled": false
610
+ }
611
+ }
612
+ ```
projects/gemini-cli/docs/cli/enterprise.md ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI for the Enterprise
2
+
3
+ This document outlines configuration patterns and best practices for deploying and managing Gemini CLI in an enterprise environment. By leveraging system-level settings, administrators can enforce security policies, manage tool access, and ensure a consistent experience for all users.
4
+
5
+ > **A Note on Security:** The patterns described in this document are intended to help administrators create a more controlled and secure environment for using Gemini CLI. However, they should not be considered a foolproof security boundary. A determined user with sufficient privileges on their local machine may still be able to circumvent these configurations. These measures are designed to prevent accidental misuse and enforce corporate policy in a managed environment, not to defend against a malicious actor with local administrative rights.
6
+
7
+ ## Centralized Configuration: The System Settings File
8
+
9
+ The most powerful tools for enterprise administration are the system-wide settings files. These files allow you to define a baseline configuration (`system-defaults.json`) and a set of overrides (`settings.json`) that apply to all users on a machine. For a complete overview of configuration options, see the [Configuration documentation](./configuration.md).
10
+
11
+ Settings are merged from four files. The precedence order for single-value settings (like `theme`) is:
12
+
13
+ 1. System Defaults (`system-defaults.json`)
14
+ 2. User Settings (`~/.gemini/settings.json`)
15
+ 3. Workspace Settings (`<project>/.gemini/settings.json`)
16
+ 4. System Overrides (`settings.json`)
17
+
18
+ This means the System Overrides file has the final say. For settings that are arrays (`includeDirectories`) or objects (`mcpServers`), the values are merged.
19
+
20
+ **Example of Merging and Precedence:**
21
+
22
+ Here is how settings from different levels are combined.
23
+
24
+ - **System Defaults `system-defaults.json`:**
25
+
26
+ ```json
27
+ {
28
+ "ui": {
29
+ "theme": "default-corporate-theme"
30
+ },
31
+ "context": {
32
+ "includeDirectories": ["/etc/gemini-cli/common-context"]
33
+ }
34
+ }
35
+ ```
36
+
37
+ - **User `settings.json` (`~/.gemini/settings.json`):**
38
+
39
+ ```json
40
+ {
41
+ "ui": {
42
+ "theme": "user-preferred-dark-theme"
43
+ },
44
+ "mcpServers": {
45
+ "corp-server": {
46
+ "command": "/usr/local/bin/corp-server-dev"
47
+ },
48
+ "user-tool": {
49
+ "command": "npm start --prefix ~/tools/my-tool"
50
+ }
51
+ },
52
+ "context": {
53
+ "includeDirectories": ["~/gemini-context"]
54
+ }
55
+ }
56
+ ```
57
+
58
+ - **Workspace `settings.json` (`<project>/.gemini/settings.json`):**
59
+
60
+ ```json
61
+ {
62
+ "ui": {
63
+ "theme": "project-specific-light-theme"
64
+ },
65
+ "mcpServers": {
66
+ "project-tool": {
67
+ "command": "npm start"
68
+ }
69
+ },
70
+ "context": {
71
+ "includeDirectories": ["./project-context"]
72
+ }
73
+ }
74
+ ```
75
+
76
+ - **System Overrides `settings.json`:**
77
+ ```json
78
+ {
79
+ "ui": {
80
+ "theme": "system-enforced-theme"
81
+ },
82
+ "mcpServers": {
83
+ "corp-server": {
84
+ "command": "/usr/local/bin/corp-server-prod"
85
+ }
86
+ },
87
+ "context": {
88
+ "includeDirectories": ["/etc/gemini-cli/global-context"]
89
+ }
90
+ }
91
+ ```
92
+
93
+ This results in the following merged configuration:
94
+
95
+ - **Final Merged Configuration:**
96
+ ```json
97
+ {
98
+ "ui": {
99
+ "theme": "system-enforced-theme"
100
+ },
101
+ "mcpServers": {
102
+ "corp-server": {
103
+ "command": "/usr/local/bin/corp-server-prod"
104
+ },
105
+ "user-tool": {
106
+ "command": "npm start --prefix ~/tools/my-tool"
107
+ },
108
+ "project-tool": {
109
+ "command": "npm start"
110
+ }
111
+ },
112
+ "context": {
113
+ "includeDirectories": [
114
+ "/etc/gemini-cli/common-context",
115
+ "~/gemini-context",
116
+ "./project-context",
117
+ "/etc/gemini-cli/global-context"
118
+ ]
119
+ }
120
+ }
121
+ ```
122
+
123
+ **Why:**
124
+
125
+ - **`theme`**: The value from the system overrides (`system-enforced-theme`) is used, as it has the highest precedence.
126
+ - **`mcpServers`**: The objects are merged. The `corp-server` definition from the system overrides takes precedence over the user's definition. The unique `user-tool` and `project-tool` are included.
127
+ - **`includeDirectories`**: The arrays are concatenated in the order of System Defaults, User, Workspace, and then System Overrides.
128
+
129
+ - **Location**:
130
+ - **Linux**: `/etc/gemini-cli/settings.json`
131
+ - **Windows**: `C:\ProgramData\gemini-cli\settings.json`
132
+ - **macOS**: `/Library/Application Support/GeminiCli/settings.json`
133
+ - The path can be overridden using the `GEMINI_CLI_SYSTEM_SETTINGS_PATH` environment variable.
134
+ - **Control**: This file should be managed by system administrators and protected with appropriate file permissions to prevent unauthorized modification by users.
135
+
136
+ By using the system settings file, you can enforce the security and configuration patterns described below.
137
+
138
+ ## Restricting Tool Access
139
+
140
+ You can significantly enhance security by controlling which tools the Gemini model can use. This is achieved through the `tools.core` and `tools.exclude` settings. For a list of available tools, see the [Tools documentation](../tools/index.md).
141
+
142
+ ### Allowlisting with `coreTools`
143
+
144
+ The most secure approach is to explicitly add the tools and commands that users are permitted to execute to an allowlist. This prevents the use of any tool not on the approved list.
145
+
146
+ **Example:** Allow only safe, read-only file operations and listing files.
147
+
148
+ ```json
149
+ {
150
+ "tools": {
151
+ "core": ["ReadFileTool", "GlobTool", "ShellTool(ls)"]
152
+ }
153
+ }
154
+ ```
155
+
156
+ ### Blocklisting with `excludeTools`
157
+
158
+ Alternatively, you can add specific tools that are considered dangerous in your environment to a blocklist.
159
+
160
+ **Example:** Prevent the use of the shell tool for removing files.
161
+
162
+ ```json
163
+ {
164
+ "tools": {
165
+ "exclude": ["ShellTool(rm -rf)"]
166
+ }
167
+ }
168
+ ```
169
+
170
+ **Security Note:** Blocklisting with `excludeTools` is less secure than allowlisting with `coreTools`, as it relies on blocking known-bad commands, and clever users may find ways to bypass simple string-based blocks. **Allowlisting is the recommended approach.**
171
+
172
+ ## Managing Custom Tools (MCP Servers)
173
+
174
+ If your organization uses custom tools via [Model-Context Protocol (MCP) servers](../core/tools-api.md), it is crucial to understand how server configurations are managed to apply security policies effectively.
175
+
176
+ ### How MCP Server Configurations are Merged
177
+
178
+ Gemini CLI loads `settings.json` files from three levels: System, Workspace, and User. When it comes to the `mcpServers` object, these configurations are **merged**:
179
+
180
+ 1. **Merging:** The lists of servers from all three levels are combined into a single list.
181
+ 2. **Precedence:** If a server with the **same name** is defined at multiple levels (e.g., a server named `corp-api` exists in both system and user settings), the definition from the highest-precedence level is used. The order of precedence is: **System > Workspace > User**.
182
+
183
+ This means a user **cannot** override the definition of a server that is already defined in the system-level settings. However, they **can** add new servers with unique names.
184
+
185
+ ### Enforcing a Catalog of Tools
186
+
187
+ The security of your MCP tool ecosystem depends on a combination of defining the canonical servers and adding their names to an allowlist.
188
+
189
+ ### Restricting Tools Within an MCP Server
190
+
191
+ For even greater security, especially when dealing with third-party MCP servers, you can restrict which specific tools from a server are exposed to the model. This is done using the `includeTools` and `excludeTools` properties within a server's definition. This allows you to use a subset of tools from a server without allowing potentially dangerous ones.
192
+
193
+ Following the principle of least privilege, it is highly recommended to use `includeTools` to create an allowlist of only the necessary tools.
194
+
195
+ **Example:** Only allow the `code-search` and `get-ticket-details` tools from a third-party MCP server, even if the server offers other tools like `delete-ticket`.
196
+
197
+ ```json
198
+ {
199
+ "mcp": {
200
+ "allowed": ["third-party-analyzer"]
201
+ },
202
+ "mcpServers": {
203
+ "third-party-analyzer": {
204
+ "command": "/usr/local/bin/start-3p-analyzer.sh",
205
+ "includeTools": ["code-search", "get-ticket-details"]
206
+ }
207
+ }
208
+ }
209
+ ```
210
+
211
+ #### More Secure Pattern: Define and Add to Allowlist in System Settings
212
+
213
+ To create a secure, centrally-managed catalog of tools, the system administrator **must** do both of the following in the system-level `settings.json` file:
214
+
215
+ 1. **Define the full configuration** for every approved server in the `mcpServers` object. This ensures that even if a user defines a server with the same name, the secure system-level definition will take precedence.
216
+ 2. **Add the names** of those servers to an allowlist using the `mcp.allowed` setting. This is a critical security step that prevents users from running any servers that are not on this list. If this setting is omitted, the CLI will merge and allow any server defined by the user.
217
+
218
+ **Example System `settings.json`:**
219
+
220
+ 1. Add the _names_ of all approved servers to an allowlist.
221
+ This will prevent users from adding their own servers.
222
+
223
+ 2. Provide the canonical _definition_ for each server on the allowlist.
224
+
225
+ ```json
226
+ {
227
+ "mcp": {
228
+ "allowed": ["corp-data-api", "source-code-analyzer"]
229
+ },
230
+ "mcpServers": {
231
+ "corp-data-api": {
232
+ "command": "/usr/local/bin/start-corp-api.sh",
233
+ "timeout": 5000
234
+ },
235
+ "source-code-analyzer": {
236
+ "command": "/usr/local/bin/start-analyzer.sh"
237
+ }
238
+ }
239
+ }
240
+ ```
241
+
242
+ This pattern is more secure because it uses both definition and an allowlist. Any server a user defines will either be overridden by the system definition (if it has the same name) or blocked because its name is not in the `mcp.allowed` list.
243
+
244
+ ### Less Secure Pattern: Omitting the Allowlist
245
+
246
+ If the administrator defines the `mcpServers` object but fails to also specify the `mcp.allowed` allowlist, users may add their own servers.
247
+
248
+ **Example System `settings.json`:**
249
+
250
+ This configuration defines servers but does not enforce the allowlist.
251
+ The administrator has NOT included the "mcp.allowed" setting.
252
+
253
+ ```json
254
+ {
255
+ "mcpServers": {
256
+ "corp-data-api": {
257
+ "command": "/usr/local/bin/start-corp-api.sh"
258
+ }
259
+ }
260
+ }
261
+ ```
262
+
263
+ In this scenario, a user can add their own server in their local `settings.json`. Because there is no `mcp.allowed` list to filter the merged results, the user's server will be added to the list of available tools and allowed to run.
264
+
265
+ ## Enforcing Sandboxing for Security
266
+
267
+ To mitigate the risk of potentially harmful operations, you can enforce the use of sandboxing for all tool execution. The sandbox isolates tool execution in a containerized environment.
268
+
269
+ **Example:** Force all tool execution to happen within a Docker sandbox.
270
+
271
+ ```json
272
+ {
273
+ "tools": {
274
+ "sandbox": "docker"
275
+ }
276
+ }
277
+ ```
278
+
279
+ You can also specify a custom, hardened Docker image for the sandbox using the `--sandbox-image` command-line argument or by building a custom `sandbox.Dockerfile` as described in the [Sandboxing documentation](./configuration.md#sandboxing).
280
+
281
+ ## Controlling Network Access via Proxy
282
+
283
+ In corporate environments with strict network policies, you can configure Gemini CLI to route all outbound traffic through a corporate proxy. This can be set via an environment variable, but it can also be enforced for custom tools via the `mcpServers` configuration.
284
+
285
+ **Example (for an MCP Server):**
286
+
287
+ ```json
288
+ {
289
+ "mcpServers": {
290
+ "proxied-server": {
291
+ "command": "node",
292
+ "args": ["mcp_server.js"],
293
+ "env": {
294
+ "HTTP_PROXY": "http://proxy.example.com:8080",
295
+ "HTTPS_PROXY": "http://proxy.example.com:8080"
296
+ }
297
+ }
298
+ }
299
+ }
300
+ ```
301
+
302
+ ## Telemetry and Auditing
303
+
304
+ For auditing and monitoring purposes, you can configure Gemini CLI to send telemetry data to a central location. This allows you to track tool usage and other events. For more information, see the [telemetry documentation](../telemetry.md).
305
+
306
+ **Example:** Enable telemetry and send it to a local OTLP collector. If `otlpEndpoint` is not specified, it defaults to `http://localhost:4317`.
307
+
308
+ ```json
309
+ {
310
+ "telemetry": {
311
+ "enabled": true,
312
+ "target": "gcp",
313
+ "logPrompts": false
314
+ }
315
+ }
316
+ ```
317
+
318
+ **Note:** Ensure that `logPrompts` is set to `false` in an enterprise setting to avoid collecting potentially sensitive information from user prompts.
319
+
320
+ ## Putting It All Together: Example System `settings.json`
321
+
322
+ Here is an example of a system `settings.json` file that combines several of the patterns discussed above to create a secure, controlled environment for Gemini CLI.
323
+
324
+ ```json
325
+ {
326
+ "tools": {
327
+ "sandbox": "docker",
328
+ "core": [
329
+ "ReadFileTool",
330
+ "GlobTool",
331
+ "ShellTool(ls)",
332
+ "ShellTool(cat)",
333
+ "ShellTool(grep)"
334
+ ]
335
+ },
336
+ "mcp": {
337
+ "allowed": ["corp-tools"]
338
+ },
339
+ "mcpServers": {
340
+ "corp-tools": {
341
+ "command": "/opt/gemini-tools/start.sh",
342
+ "timeout": 5000
343
+ }
344
+ },
345
+ "telemetry": {
346
+ "enabled": true,
347
+ "target": "gcp",
348
+ "otlpEndpoint": "https://telemetry-prod.example.com:4317",
349
+ "logPrompts": false
350
+ },
351
+ "advanced": {
352
+ "bugCommand": {
353
+ "urlTemplate": "https://servicedesk.example.com/new-ticket?title={title}&details={info}"
354
+ }
355
+ },
356
+ "privacy": {
357
+ "usageStatisticsEnabled": false
358
+ }
359
+ }
360
+ ```
361
+
362
+ This configuration:
363
+
364
+ - Forces all tool execution into a Docker sandbox.
365
+ - Strictly uses an allowlist for a small set of safe shell commands and file tools.
366
+ - Defines and allows a single corporate MCP server for custom tools.
367
+ - Enables telemetry for auditing, without logging prompt content.
368
+ - Redirects the `/bug` command to an internal ticketing system.
369
+ - Disables general usage statistics collection.
projects/gemini-cli/docs/cli/index.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI
2
+
3
+ Within Gemini CLI, `packages/cli` is the frontend for users to send and receive prompts with the Gemini AI model and its associated tools. For a general overview of Gemini CLI, see the [main documentation page](../index.md).
4
+
5
+ ## Navigating this section
6
+
7
+ - **[Authentication](./authentication.md):** A guide to setting up authentication with Google's AI services.
8
+ - **[Commands](./commands.md):** A reference for Gemini CLI commands (e.g., `/help`, `/tools`, `/theme`).
9
+ - **[Configuration](./configuration.md):** A guide to tailoring Gemini CLI behavior using configuration files.
10
+ - **[Enterprise](./enterprise.md):** A guide to enterprise configuration.
11
+ - **[Token Caching](./token-caching.md):** Optimize API costs through token caching.
12
+ - **[Themes](./themes.md)**: A guide to customizing the CLI's appearance with different themes.
13
+ - **[Tutorials](tutorials.md)**: A tutorial showing how to use Gemini CLI to automate a development task.
14
+
15
+ ## Non-interactive mode
16
+
17
+ Gemini CLI can be run in a non-interactive mode, which is useful for scripting and automation. In this mode, you pipe input to the CLI, it executes the command, and then it exits.
18
+
19
+ The following example pipes a command to Gemini CLI from your terminal:
20
+
21
+ ```bash
22
+ echo "What is fine tuning?" | gemini
23
+ ```
24
+
25
+ Gemini CLI executes the command and prints the output to your terminal. Note that you can achieve the same behavior by using the `--prompt` or `-p` flag. For example:
26
+
27
+ ```bash
28
+ gemini -p "What is fine tuning?"
29
+ ```
projects/gemini-cli/docs/cli/themes.md ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Themes
2
+
3
+ Gemini CLI supports a variety of themes to customize its color scheme and appearance. You can change the theme to suit your preferences via the `/theme` command or `"theme":` configuration setting.
4
+
5
+ ## Available Themes
6
+
7
+ Gemini CLI comes with a selection of pre-defined themes, which you can list using the `/theme` command within Gemini CLI:
8
+
9
+ - **Dark Themes:**
10
+ - `ANSI`
11
+ - `Atom One`
12
+ - `Ayu`
13
+ - `Default`
14
+ - `Dracula`
15
+ - `GitHub`
16
+ - **Light Themes:**
17
+ - `ANSI Light`
18
+ - `Ayu Light`
19
+ - `Default Light`
20
+ - `GitHub Light`
21
+ - `Google Code`
22
+ - `Xcode`
23
+
24
+ ### Changing Themes
25
+
26
+ 1. Enter `/theme` into Gemini CLI.
27
+ 2. A dialog or selection prompt appears, listing the available themes.
28
+ 3. Using the arrow keys, select a theme. Some interfaces might offer a live preview or highlight as you select.
29
+ 4. Confirm your selection to apply the theme.
30
+
31
+ **Note:** If a theme is defined in your `settings.json` file (either by name or by a file path), you must remove the `"theme"` setting from the file before you can change the theme using the `/theme` command.
32
+
33
+ ### Theme Persistence
34
+
35
+ Selected themes are saved in Gemini CLI's [configuration](./configuration.md) so your preference is remembered across sessions.
36
+
37
+ ---
38
+
39
+ ## Custom Color Themes
40
+
41
+ Gemini CLI allows you to create your own custom color themes by specifying them in your `settings.json` file. This gives you full control over the color palette used in the CLI.
42
+
43
+ ### How to Define a Custom Theme
44
+
45
+ Add a `customThemes` block to your user, project, or system `settings.json` file. Each custom theme is defined as an object with a unique name and a set of color keys. For example:
46
+
47
+ ```json
48
+ {
49
+ "ui": {
50
+ "customThemes": {
51
+ "MyCustomTheme": {
52
+ "name": "MyCustomTheme",
53
+ "type": "custom",
54
+ "Background": "#181818",
55
+ ...
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ **Color keys:**
63
+
64
+ - `Background`
65
+ - `Foreground`
66
+ - `LightBlue`
67
+ - `AccentBlue`
68
+ - `AccentPurple`
69
+ - `AccentCyan`
70
+ - `AccentGreen`
71
+ - `AccentYellow`
72
+ - `AccentRed`
73
+ - `Comment`
74
+ - `Gray`
75
+ - `DiffAdded` (optional, for added lines in diffs)
76
+ - `DiffRemoved` (optional, for removed lines in diffs)
77
+ - `DiffModified` (optional, for modified lines in diffs)
78
+
79
+ **Required Properties:**
80
+
81
+ - `name` (must match the key in the `customThemes` object and be a string)
82
+ - `type` (must be the string `"custom"`)
83
+ - `Background`
84
+ - `Foreground`
85
+ - `LightBlue`
86
+ - `AccentBlue`
87
+ - `AccentPurple`
88
+ - `AccentCyan`
89
+ - `AccentGreen`
90
+ - `AccentYellow`
91
+ - `AccentRed`
92
+ - `Comment`
93
+ - `Gray`
94
+
95
+ You can use either hex codes (e.g., `#FF0000`) **or** standard CSS color names (e.g., `coral`, `teal`, `blue`) for any color value. See [CSS color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#color_keywords) for a full list of supported names.
96
+
97
+ You can define multiple custom themes by adding more entries to the `customThemes` object.
98
+
99
+ ### Loading Themes from a File
100
+
101
+ In addition to defining custom themes in `settings.json`, you can also load a theme directly from a JSON file by specifying the file path in your `settings.json`. This is useful for sharing themes or keeping them separate from your main configuration.
102
+
103
+ To load a theme from a file, set the `theme` property in your `settings.json` to the path of your theme file:
104
+
105
+ ```json
106
+ {
107
+ "ui": {
108
+ "theme": "/path/to/your/theme.json"
109
+ }
110
+ }
111
+ ```
112
+
113
+ The theme file must be a valid JSON file that follows the same structure as a custom theme defined in `settings.json`.
114
+
115
+ **Example `my-theme.json`:**
116
+
117
+ ```json
118
+ {
119
+ "name": "My File Theme",
120
+ "type": "custom",
121
+ "Background": "#282A36",
122
+ "Foreground": "#F8F8F2",
123
+ "LightBlue": "#82AAFF",
124
+ "AccentBlue": "#61AFEF",
125
+ "AccentPurple": "#BD93F9",
126
+ "AccentCyan": "#8BE9FD",
127
+ "AccentGreen": "#50FA7B",
128
+ "AccentYellow": "#F1FA8C",
129
+ "AccentRed": "#FF5555",
130
+ "Comment": "#6272A4",
131
+ "Gray": "#ABB2BF",
132
+ "DiffAdded": "#A6E3A1",
133
+ "DiffRemoved": "#F38BA8",
134
+ "DiffModified": "#89B4FA",
135
+ "GradientColors": ["#4796E4", "#847ACE", "#C3677F"]
136
+ }
137
+ ```
138
+
139
+ **Security Note:** For your safety, Gemini CLI will only load theme files that are located within your home directory. If you attempt to load a theme from outside your home directory, a warning will be displayed and the theme will not be loaded. This is to prevent loading potentially malicious theme files from untrusted sources.
140
+
141
+ ### Example Custom Theme
142
+
143
+ <img src="../assets/theme-custom.png" alt="Custom theme example" width="600" />
144
+
145
+ ### Using Your Custom Theme
146
+
147
+ - Select your custom theme using the `/theme` command in Gemini CLI. Your custom theme will appear in the theme selection dialog.
148
+ - Or, set it as the default by adding `"theme": "MyCustomTheme"` to the `ui` object in your `settings.json`.
149
+ - Custom themes can be set at the user, project, or system level, and follow the same [configuration precedence](./configuration.md) as other settings.
150
+
151
+ ---
152
+
153
+ ## Dark Themes
154
+
155
+ ### ANSI
156
+
157
+ <img src="../assets/theme-ansi.png" alt="ANSI theme" width="600" />
158
+
159
+ ### Atom OneDark
160
+
161
+ <img src="../assets/theme-atom-one.png" alt="Atom One theme" width="600">
162
+
163
+ ### Ayu
164
+
165
+ <img src="../assets/theme-ayu.png" alt="Ayu theme" width="600">
166
+
167
+ ### Default
168
+
169
+ <img src="../assets/theme-default.png" alt="Default theme" width="600">
170
+
171
+ ### Dracula
172
+
173
+ <img src="../assets/theme-dracula.png" alt="Dracula theme" width="600">
174
+
175
+ ### GitHub
176
+
177
+ <img src="../assets/theme-github.png" alt="GitHub theme" width="600">
178
+
179
+ ## Light Themes
180
+
181
+ ### ANSI Light
182
+
183
+ <img src="../assets/theme-ansi-light.png" alt="ANSI Light theme" width="600">
184
+
185
+ ### Ayu Light
186
+
187
+ <img src="../assets/theme-ayu-light.png" alt="Ayu Light theme" width="600">
188
+
189
+ ### Default Light
190
+
191
+ <img src="../assets/theme-default-light.png" alt="Default Light theme" width="600">
192
+
193
+ ### GitHub Light
194
+
195
+ <img src="../assets/theme-github-light.png" alt="GitHub Light theme" width="600">
196
+
197
+ ### Google Code
198
+
199
+ <img src="../assets/theme-google-light.png" alt="Google Code theme" width="600">
200
+
201
+ ### Xcode
202
+
203
+ <img src="../assets/theme-xcode-light.png" alt="Xcode Light theme" width="600">
projects/gemini-cli/docs/cli/token-caching.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Token Caching and Cost Optimization
2
+
3
+ Gemini CLI automatically optimizes API costs through token caching when using API key authentication (Gemini API key or Vertex AI). This feature reuses previous system instructions and context to reduce the number of tokens processed in subsequent requests.
4
+
5
+ **Token caching is available for:**
6
+
7
+ - API key users (Gemini API key)
8
+ - Vertex AI users (with project and location setup)
9
+
10
+ **Token caching is not available for:**
11
+
12
+ - OAuth users (Google Personal/Enterprise accounts) - the Code Assist API does not support cached content creation at this time
13
+
14
+ You can view your token usage and cached token savings using the `/stats` command. When cached tokens are available, they will be displayed in the stats output.
projects/gemini-cli/docs/cli/tutorials.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tutorials
2
+
3
+ This page contains tutorials for interacting with Gemini CLI.
4
+
5
+ ## Setting up a Model Context Protocol (MCP) server
6
+
7
+ > [!CAUTION]
8
+ > Before using a third-party MCP server, ensure you trust its source and understand the tools it provides. Your use of third-party servers is at your own risk.
9
+
10
+ This tutorial demonstrates how to set up a MCP server, using the [GitHub MCP server](https://github.com/github/github-mcp-server) as an example. The GitHub MCP server provides tools for interacting with GitHub repositories, such as creating issues and commenting on pull requests.
11
+
12
+ ### Prerequisites
13
+
14
+ Before you begin, ensure you have the following installed and configured:
15
+
16
+ - **Docker:** Install and run [Docker].
17
+ - **GitHub Personal Access Token (PAT):** Create a new [classic] or [fine-grained] PAT with the necessary scopes.
18
+
19
+ [Docker]: https://www.docker.com/
20
+ [classic]: https://github.com/settings/tokens/new
21
+ [fine-grained]: https://github.com/settings/personal-access-tokens/new
22
+
23
+ ### Guide
24
+
25
+ #### Configure the MCP server in `settings.json`
26
+
27
+ In your project's root directory, create or open the [`.gemini/settings.json` file](./configuration.md). Within the file, add the `mcpServers` configuration block, which provides instructions for how to launch the GitHub MCP server.
28
+
29
+ ```json
30
+ {
31
+ "mcpServers": {
32
+ "github": {
33
+ "command": "docker",
34
+ "args": [
35
+ "run",
36
+ "-i",
37
+ "--rm",
38
+ "-e",
39
+ "GITHUB_PERSONAL_ACCESS_TOKEN",
40
+ "ghcr.io/github/github-mcp-server"
41
+ ],
42
+ "env": {
43
+ "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"
44
+ }
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ #### Set your GitHub token
51
+
52
+ > [!CAUTION]
53
+ > Using a broadly scoped personal access token that has access to personal and private repositories can lead to information from the private repository being leaked into the public repository. We recommend using a fine-grained access token that doesn't share access to both public and private repositories.
54
+
55
+ Use an environment variable to store your GitHub PAT:
56
+
57
+ ```bash
58
+ GITHUB_PERSONAL_ACCESS_TOKEN="pat_YourActualGitHubTokenHere"
59
+ ```
60
+
61
+ Gemini CLI uses this value in the `mcpServers` configuration that you defined in the `settings.json` file.
62
+
63
+ #### Launch Gemini CLI and verify the connection
64
+
65
+ When you launch Gemini CLI, it automatically reads your configuration and launches the GitHub MCP server in the background. You can then use natural language prompts to ask Gemini CLI to perform GitHub actions. For example:
66
+
67
+ ```bash
68
+ "get all open issues assigned to me in the 'foo/bar' repo and prioritize them"
69
+ ```
projects/gemini-cli/docs/core/index.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI Core
2
+
3
+ Gemini CLI's core package (`packages/core`) is the backend portion of Gemini CLI, handling communication with the Gemini API, managing tools, and processing requests sent from `packages/cli`. For a general overview of Gemini CLI, see the [main documentation page](../index.md).
4
+
5
+ ## Navigating this section
6
+
7
+ - **[Core tools API](./tools-api.md):** Information on how tools are defined, registered, and used by the core.
8
+ - **[Memory Import Processor](./memport.md):** Documentation for the modular GEMINI.md import feature using @file.md syntax.
9
+
10
+ ## Role of the core
11
+
12
+ While the `packages/cli` portion of Gemini CLI provides the user interface, `packages/core` is responsible for:
13
+
14
+ - **Gemini API interaction:** Securely communicating with the Google Gemini API, sending user prompts, and receiving model responses.
15
+ - **Prompt engineering:** Constructing effective prompts for the Gemini model, potentially incorporating conversation history, tool definitions, and instructional context from `GEMINI.md` files.
16
+ - **Tool management & orchestration:**
17
+ - Registering available tools (e.g., file system tools, shell command execution).
18
+ - Interpreting tool use requests from the Gemini model.
19
+ - Executing the requested tools with the provided arguments.
20
+ - Returning tool execution results to the Gemini model for further processing.
21
+ - **Session and state management:** Keeping track of the conversation state, including history and any relevant context required for coherent interactions.
22
+ - **Configuration:** Managing core-specific configurations, such as API key access, model selection, and tool settings.
23
+
24
+ ## Security considerations
25
+
26
+ The core plays a vital role in security:
27
+
28
+ - **API key management:** It handles the `GEMINI_API_KEY` and ensures it's used securely when communicating with the Gemini API.
29
+ - **Tool execution:** When tools interact with the local system (e.g., `run_shell_command`), the core (and its underlying tool implementations) must do so with appropriate caution, often involving sandboxing mechanisms to prevent unintended modifications.
30
+
31
+ ## Chat history compression
32
+
33
+ To ensure that long conversations don't exceed the token limits of the Gemini model, the core includes a chat history compression feature.
34
+
35
+ When a conversation approaches the token limit for the configured model, the core automatically compresses the conversation history before sending it to the model. This compression is designed to be lossless in terms of the information conveyed, but it reduces the overall number of tokens used.
36
+
37
+ You can find the token limits for each model in the [Google AI documentation](https://ai.google.dev/gemini-api/docs/models).
38
+
39
+ ## Model fallback
40
+
41
+ Gemini CLI includes a model fallback mechanism to ensure that you can continue to use the CLI even if the default "pro" model is rate-limited.
42
+
43
+ If you are using the default "pro" model and the CLI detects that you are being rate-limited, it automatically switches to the "flash" model for the current session. This allows you to continue working without interruption.
44
+
45
+ ## File discovery service
46
+
47
+ The file discovery service is responsible for finding files in the project that are relevant to the current context. It is used by the `@` command and other tools that need to access files.
48
+
49
+ ## Memory discovery service
50
+
51
+ The memory discovery service is responsible for finding and loading the `GEMINI.md` files that provide context to the model. It searches for these files in a hierarchical manner, starting from the current working directory and moving up to the project root and the user's home directory. It also searches in subdirectories.
52
+
53
+ This allows you to have global, project-level, and component-level context files, which are all combined to provide the model with the most relevant information.
54
+
55
+ You can use the [`/memory` command](../cli/commands.md) to `show`, `add`, and `refresh` the content of loaded `GEMINI.md` files.