You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tools/file-system.md
-86Lines changed: 0 additions & 86 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,19 +8,6 @@ The Gemini CLI provides a comprehensive suite of tools for interacting with the
8
8
9
9
`list_directory` lists the names of files and subdirectories directly within a specified directory path. It can optionally ignore entries matching provided glob patterns.
10
10
11
-
-**Tool name:**`list_directory`
12
-
-**Display name:** ReadFolder
13
-
-**File:**`ls.ts`
14
-
-**Parameters:**
15
-
-`path` (string, required): The absolute path to the directory to list.
16
-
-`ignore` (array of strings, optional): A list of glob patterns to exclude from the listing (e.g., `["*.log", ".git"]`).
17
-
-`respect_git_ignore` (boolean, optional): Whether to respect `.gitignore` patterns when listing files. Defaults to `true`.
18
-
-**Behavior:**
19
-
- Returns a list of file and directory names.
20
-
- Indicates whether each entry is a directory.
21
-
- Sorts entries with directories first, then alphabetically.
22
-
-**Output (`llmContent`):** A string like: `Directory listing for /path/to/your/folder:\n[DIR] subfolder1\nfile1.txt\nfile2.png`
23
-
-**Confirmation:** No.
24
11
-**Tool name:**`list_directory`
25
12
-**Display name:** ReadFolder
26
13
-**File:**`ls.ts`
@@ -39,22 +26,6 @@ The Gemini CLI provides a comprehensive suite of tools for interacting with the
39
26
40
27
`read_file` reads and returns the content of a specified file. This tool handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), and PDF files. For text files, it can read specific line ranges. Other binary file types are generally skipped.
41
28
42
-
-**Tool name:**`read_file`
43
-
-**Display name:** ReadFile
44
-
-**File:**`read-file.ts`
45
-
-**Parameters:**
46
-
-`path` (string, required): The absolute path to the file to read.
47
-
-`offset` (number, optional): For text files, the 0-based line number to start reading from. Requires `limit` to be set.
48
-
-`limit` (number, optional): For text files, the maximum number of lines to read. If omitted, reads a default maximum (e.g., 2000 lines) or the entire file if feasible.
49
-
-**Behavior:**
50
-
- For text files: Returns the content. If `offset` and `limit` are used, returns only that slice of lines. Indicates if content was truncated due to line limits or line length limits.
51
-
- For image and PDF files: Returns the file content as a base64-encoded data structure suitable for model consumption.
52
-
- For other binary files: Attempts to identify and skip them, returning a message indicating it's a generic binary file.
53
-
-**Output:** (`llmContent`):
54
-
- For text files: The file content, potentially prefixed with a truncation message (e.g., `[File content truncated: showing lines 1-100 of 500 total lines...]\nActual file content...`).
55
-
- For image/PDF files: An object containing `inlineData` with `mimeType` and base64 `data` (e.g., `{ inlineData: { mimeType: 'image/png', data: 'base64encodedstring' } }`).
56
-
- For other binary files: A message like `Cannot display content of binary file: /path/to/data.bin`.
57
-
-**Confirmation:** No.
58
29
-**Tool name:**`read_file`
59
30
-**Display name:** ReadFile
60
31
-**File:**`read-file.ts`
@@ -76,17 +47,6 @@ The Gemini CLI provides a comprehensive suite of tools for interacting with the
76
47
77
48
`write_file` writes content to a specified file. If the file exists, it will be overwritten. If the file doesn't exist, it (and any necessary parent directories) will be created.
78
49
79
-
-**Tool name:**`write_file`
80
-
-**Display name:** WriteFile
81
-
-**File:**`write-file.ts`
82
-
-**Parameters:**
83
-
-`file_path` (string, required): The absolute path to the file to write to.
84
-
-`content` (string, required): The content to write into the file.
85
-
-**Behavior:**
86
-
- Writes the provided `content` to the `file_path`.
87
-
- Creates parent directories if they don't exist.
88
-
-**Output (`llmContent`):** A success message, e.g., `Successfully overwrote file: /path/to/your/file.txt` or `Successfully created and wrote to new file: /path/to/new/file.txt`.
89
-
-**Confirmation:** Yes. Shows a diff of changes and asks for user approval before writing.
90
50
-**Tool name:**`write_file`
91
51
-**Display name:** WriteFile
92
52
-**File:**`write-file.ts`
@@ -103,20 +63,6 @@ The Gemini CLI provides a comprehensive suite of tools for interacting with the
103
63
104
64
`glob` finds files matching specific glob patterns (e.g., `src/**/*.ts`, `*.md`), returning absolute paths sorted by modification time (newest first).
105
65
106
-
-**Tool name:**`glob`
107
-
-**Display name:** FindFiles
108
-
-**File:**`glob.ts`
109
-
-**Parameters:**
110
-
-`pattern` (string, required): The glob pattern to match against (e.g., `"*.py"`, `"src/**/*.js"`).
111
-
-`path` (string, optional): The absolute path to the directory to search within. If omitted, searches the tool's root directory.
112
-
-`case_sensitive` (boolean, optional): Whether the search should be case-sensitive. Defaults to `false`.
113
-
-`respect_git_ignore` (boolean, optional): Whether to respect .gitignore patterns when finding files. Defaults to `true`.
114
-
-**Behavior:**
115
-
- Searches for files matching the glob pattern within the specified directory.
116
-
- Returns a list of absolute paths, sorted with the most recently modified files first.
117
-
- Ignores common nuisance directories like `node_modules` and `.git` by default.
118
-
-**Output (`llmContent`):** A message like: `Found 5 file(s) matching "*.ts" within src, sorted by modification time (newest first):\nsrc/file1.ts\nsrc/subdir/file2.ts...`
119
-
-**Confirmation:** No.
120
66
-**Tool name:**`glob`
121
67
-**Display name:** FindFiles
122
68
-**File:**`glob.ts`
@@ -136,17 +82,6 @@ The Gemini CLI provides a comprehensive suite of tools for interacting with the
136
82
137
83
`search_file_content` searches for a regular expression pattern within the content of files in a specified directory. Can filter files by a glob pattern. Returns the lines containing matches, along with their file paths and line numbers.
138
84
139
-
-**Tool name:**`search_file_content`
140
-
-**Display name:** SearchText
141
-
-**File:**`grep.ts`
142
-
-**Parameters:**
143
-
-`pattern` (string, required): The regular expression (regex) to search for (e.g., `"function\s+myFunction"`).
144
-
-`path` (string, optional): The absolute path to the directory to search within. Defaults to the current working directory.
145
-
-`include` (string, optional): A glob pattern to filter which files are searched (e.g., `"*.js"`, `"src/**/*.{ts,tsx}"`). If omitted, searches most files (respecting common ignores).
146
-
-**Behavior:**
147
-
- Uses `git grep` if available in a Git repository for speed, otherwise falls back to system `grep` or a JavaScript-based search.
148
-
- Returns a list of matching lines, each prefixed with its file path (relative to the search directory) and line number.
149
-
-**Output (`llmContent`):** A formatted string of matches, e.g.:
150
85
-**Tool name:**`search_file_content`
151
86
-**Display name:** SearchText
152
87
-**File:**`grep.ts`
@@ -170,7 +105,6 @@ The Gemini CLI provides a comprehensive suite of tools for interacting with the
170
105
---
171
106
```
172
107
-**Confirmation:** No.
173
-
-**Confirmation:** No.
174
108
175
109
## 6. `replace` (Edit)
176
110
@@ -188,26 +122,6 @@ The Gemini CLI provides a comprehensive suite of tools for interacting with the
188
122
-`new_string` (string, required): The exact literal text to replace `old_string` with.
189
123
-`expected_replacements` (number, optional): The number of occurrences to replace. Defaults to `1`.
190
124
191
-
-**Behavior:**
192
-
- If `old_string` is empty and `file_path` does not exist, creates a new file with `new_string` as content.
193
-
- If `old_string` is provided, it reads the `file_path` and attempts to find exactly one occurrence of `old_string`.
194
-
- If one occurrence is found, it replaces it with `new_string`.
195
-
-**Enhanced Reliability (Multi-Stage Edit Correction):** To significantly improve the success rate of edits, especially when the model-provided `old_string` might not be perfectly precise, the tool incorporates a multi-stage edit correction mechanism.
196
-
- If the initial `old_string` isn't found or matches multiple locations, the tool can leverage the Gemini model to iteratively refine `old_string` (and potentially `new_string`).
197
-
- This self-correction process attempts to identify the unique segment the model intended to modify, making the `replace` operation more robust even with slightly imperfect initial context.
198
-
-**Failure Conditions:** Despite the correction mechanism, the tool will fail if:
199
-
-`file_path` is not absolute or is outside the root directory.
200
-
-`old_string` is not empty, but the `file_path` does not exist.
201
-
-`old_string` is empty, but the `file_path` already exists.
202
-
-`old_string` is not found in the file after attempts to correct it.
203
-
-`old_string` is found multiple times, and the self-correction mechanism cannot resolve it to a single, unambiguous match.
204
-
-**Output (`llmContent`):**
205
-
- On success: `Successfully modified file: /path/to/file.txt (1 replacements).` or `Created new file: /path/to/new_file.txt with provided content.`
206
-
- On failure: An error message explaining the reason (e.g., `Failed to edit, 0 occurrences found...`, `Failed to edit, expected 1 occurrences but found 2...`).
207
-
-**Confirmation:** Yes. Shows a diff of the proposed changes and asks for user approval before writing to the file.
208
-
-`new_string` (string, required): The exact literal text to replace `old_string` with.
209
-
-`expected_replacements` (number, optional): The number of occurrences to replace. Defaults to `1`.
210
-
211
125
-**Behavior:**
212
126
- If `old_string` is empty and `file_path` does not exist, creates a new file with `new_string` as content.
213
127
- If `old_string` is provided, it reads the `file_path` and attempts to find exactly one occurrence of `old_string`.
0 commit comments