| 💾 Saved. d722711 k33g 5h ago | 1 | # Reference: built-in tools |
| 2 | |
| 3 | > Neutral description of the tools declared to the model. A tool never returns a Go error for an ordinary failure: the failure text is returned to the model as the tool's output. Every tool records its call in the loop detector; the same tool, input and output three times in a row appends `[LOOP_DETECTED: …]` to the output. |
| 4 | |
| 5 | ## `bash` |
| 6 | |
| 7 | Always declared. |
| 8 | |
| 9 | | Field | Type | Description | |
| 10 | |-------|------|-------------| |
| 11 | | `command` | string | The shell command to run. | |
| 12 | |
| 13 | | Aspect | Behaviour | |
| 14 | |--------|-----------| |
| 15 | | Shell | `bash -c <command>`, a new shell per call, no stdin. | |
| 16 | | Working directory | The process directory in terminal mode; the session `cwd` in ACP mode. | |
| 17 | | Timeout | 30 s; the output then ends with `[error: 30s timeout exceeded]`. | |
| 18 | | Output | stdout and stderr merged, truncated to `maxOutput` characters. | |
| 19 | | Non-zero exit | Output ends with `[exit code: exit status N]`. | |
| 20 | | Terminal display | `🛠️ bash: <command>` before running, then up to `previewLines` lines dimmed and indented, or `(no output)`. | |
| 21 | | ACP | Tool call of kind `execute`; permission requested before running; a refusal returns `[command rejected by the user]` with status `failed`. | |
| 22 | |
| 23 | ## `read_skill` |
| 24 | |
| 25 | Declared only when `skillsDir` holds at least one skill (`<name>.md` or `<name>/SKILL.md`). |
| 26 | |
| 27 | | Field | Type | Description | |
| 28 | |-------|------|-------------| |
| 29 | | `name` | string | Skill name, exactly as listed in the tool description. | |
| 30 | |
| 31 | | Aspect | Behaviour | |
| 32 | |--------|-----------| |
| 33 | | Description | Fixed sentence followed by the catalogue: one ` <name> — <description>` line per skill, sorted by name. | |
| 34 | | Output | The full markdown of `<skillsDir>/<name>.md`, or of `<skillsDir>/<name>/SKILL.md` when there is no flat file, truncated to `maxOutput`. | |
| 35 | | Unknown name | `No skill named "x". Available skills: a, b, c` | |
| 36 | | Path safety | Only the base name of `name` is used; no directory traversal. | |
| 37 | | Terminal display | `📖 read_skill: <name>`; the content is not echoed. | |
| 38 | | ACP | Tool call of kind `read`; no permission dialog. | |
| 39 | |
| 40 | ## `read_file` |
| 41 | |
| 42 | Declared when `editTools: true`. |
| 43 | |
| 44 | | Field | Type | Default | Description | |
| 45 | |-------|------|---------|-------------| |
| 46 | | `path` | string | — | File path, relative to the working directory. | |
| 47 | | `start` | int | `0` | First line (1-based); `0` = from the start. | |
| 48 | | `end` | int | `0` | Last line (1-based, inclusive); `0` = to the end. | |
| 49 | | `numbered` | bool | `false` | Prefix each line with its number. | |
| 50 | |
| 51 | | Aspect | Behaviour | |
| 52 | |--------|-----------| |
| 53 | | Missing file | `<path> does not exist. Create it with write_file` | |
| 54 | | Output | The lines, truncated to `maxOutput`; the final newline is kept only when the end of the file is shown. | |
| 55 | | ACP | Kind `read`, with the absolute path as location. | |
| 56 | |
| 57 | ## `write_file` |
| 58 | |
| 59 | Declared when `editTools: true`. |
| 60 | |
| 61 | | Field | Type | Description | |
| 62 | |-------|------|-------------| |
| 63 | | `path` | string | File path, relative to the working directory; parent directories are created. | |
| 64 | | `content` | string | The whole content of the file. | |
| 65 | |
| 66 | | Aspect | Behaviour | |
| 67 | |--------|-----------| |
| 68 | | Existing file | Entirely replaced. | |
| 69 | | Identical content | Nothing is written; the result says so. | |
| 70 | | Output | A one-line headline and the diff against the previous content. | |
| 71 | | ACP | Kind `edit`; permission requested; the change travels as a diff (new-file diff when created). | |
| 72 | |
| 73 | ## `edit_file` |
| 74 | |
| 75 | Declared when `editTools: true`. |
| 76 | |
| 77 | | Field | Type | Default | Description | |
| 78 | |-------|------|---------|-------------| |
| 79 | | `path` | string | — | Path of an existing file. | |
| 80 | | `edits` | array of `{old, new}` | — | Replacements, all resolved against the original file. | |
| 81 | | `edits[].old` | string | — | Exact text to find, present exactly once. | |
| 82 | | `edits[].new` | string | — | Replacement; empty deletes the matched text. | |
| 83 | | `dry_run` | bool | `false` | Report what would change, write nothing. | |
| 84 | |
| 85 | | Rule | Consequence when broken | |
| 86 | |------|-------------------------| |
| 87 | | `old` appears exactly once | Refused: not found, or ambiguous. | |
| 88 | | Two edits must not overlap, nest or repeat | Refused. | |
| 89 | | Edits are resolved against the original text, never in cascade | — | |
| 90 | | Any refused edit | Nothing is written. | |
| 91 | |
| 92 | | Aspect | Behaviour | |
| 93 | |--------|-----------| |
| 94 | | Output | A one-line headline (edits applied, lines added and deleted, first changed line) and the diff with line numbers. | |
| 95 | | ACP | Kind `edit`; permission requested; the change travels as a diff with old and new text. | |
| 96 | |
| 97 | ## Counters shown after a turn |
| 98 | |
| 99 | | Counter | Counts | |
| 100 | |---------|--------| |
| 101 | | `⚙ N command(s)` | `bash` tool responses in the turn. | |
| 102 | | `📝 N file op(s)` | `read_file`, `write_file`, `edit_file` responses. | |
| 103 | | `📖 N skill(s)` | `read_skill` responses. | |