Built-in Tool Reference
Book ships six built-in tools available to the agent in every session, plus one optional extension tool. This document is the canonical parameter reference for each tool.
Overview
| Tool | Purpose | Cacheable | Source |
|---|---|---|---|
Locate files by glob pattern |
โ |
Built-in |
|
Search file content by regex |
โ |
Built-in |
|
Read a file (text or image) |
โ |
Built-in |
|
Write / append to a file |
โ |
Built-in |
|
Surgical targeted-string replacement |
โ |
Built-in |
|
Execute a shell command |
โ |
Built-in |
|
Full-featured RipGrep search |
โ |
Extension ( |
Cacheable tools (
find,grep,read_file) have their results stored inPureToolResultCachefor the duration of a session. Identical calls return the cached result instantly without re-executing.โ ๏ธ
ripgrepis not a core tool. It is an optional extension shipped in the:extensionsmodule (extensions/src/scripts/ripgrep.bk.kts). It is not available by default โ you must copy the script to~/.bk/tools/or.bk/tools/to install it. Even once installed, the tool is only registered ifrg(RipGrep) is found inPATHat startup. Ifrgis not installed the tool silently does not appear.
find Tool
Locates files by glob pattern. Uses fd when available; falls back to system find.
Returns matching file paths relative to the search directory.
Respects .gitignore when using fd.
Output is truncated to 1000 results or 50 KB.
Rule: Use this tool instead of
bashfor ALL file-discovery operations. Do NOT usebash findorbash fd. Do NOT include pipe characters or grep filters inpatternโ use thegreptool for content filtering.
Parameters
| Parameter | Type | Default | Description | Example |
|---|---|---|---|---|
|
string |
required |
Glob pattern to match files. |
|
|
string |
|
Directory to search in. |
|
|
integer |
|
Maximum number of results to return. |
|
|
string |
|
Filter by entry type: |
|
|
integer |
|
Maximum directory traversal depth. |
|
|
string |
|
Glob pattern for a directory subtree to prune from results (e.g. |
|
|
integer |
|
Return only files modified within the last N days. |
|
|
string |
|
Return only files modified more recently than the given reference file path. Forces the system-find fallback (fd does not support this flag). |
|
Alias remapping (normalizeArguments)
The tool accepts several snake_case and colloquial aliases and normalises them to their camelCase canonical names before execution:
| Alias(es) | Canonical name |
|---|---|
|
|
|
|
|
|
|
|
|
|
Examples
// Find all Kotlin files under src/
{ "pattern": "*.kt", "path": "src" }
// Find only directories at the top level
{ "pattern": "*", "path": ".", "type": "d", "maxDepth": 1 }
// Find test files modified in the last 3 days
{ "pattern": "*Test.kt", "modifiedWithinDays": 3 }
// Find files newer than the last build script edit
{ "pattern": "*.kt", "newerThan": "build.gradle.kts" }
// Find Kotlin files, excluding the build/ tree, capped at 20 results
{ "pattern": "*.kt", "excludePath": "build", "limit": 20 }
grep Tool
Searches file content using Ripgrep (rg) when available; falls back to system grep -E (extended regex). Output is truncated to 1000 lines.
Rule: Use this tool instead of
bashfor ALL grep/search operations. Do NOT usebash greporbash rg. Thepatternparameter is a regex โ use|for alternation (e.g."foo|bar"), not shell pipe syntax.
Parameters
| Parameter | Type | Default | Description | Example |
|---|---|---|---|---|
|
string |
required |
Regex pattern to search for. Use |
|
|
string |
|
File or directory to search in. |
|
|
string |
|
Single glob pattern for files to include (e.g. |
|
|
string |
|
Glob pattern for files to exclude (e.g. |
|
|
integer |
|
Number of context lines to show both before and after each match. |
|
|
integer |
|
Number of context lines to show before each match. Key name is |
|
|
integer |
|
Number of context lines to show after each match. Key name is |
|
|
integer |
|
Limit the number of matches returned. Key name is |
|
|
boolean |
|
When |
|
|
boolean |
|
When |
|
|
array of strings |
|
List of glob patterns for files to include. Each entry maps to a separate |
|
Alias remapping (normalizeArguments)
| Alias(es) | Canonical name |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Examples
// Search for all function declarations in Kotlin files
{ "pattern": "fun\\s+\\w+", "include": "*.kt" }
// Return only filenames containing "TODO"
{ "pattern": "TODO", "filesOnly": true }
// Count TODO occurrences per file across Kotlin and KTS files
{ "pattern": "TODO", "countOnly": true, "includeGlobs": ["*.kt", "*.kts"] }
// Search with 2 lines of context, capped at 10 matches
{ "pattern": "error|exception", "context": 2, "maxCount": 10 }
// Search multiple file types at once
{ "pattern": "import", "includeGlobs": ["*.kt", "*.kts", "*.java"] }
read_file Tool
Reads the contents of a file. Supports text files and images (jpg, png, gif, webp).
Images are returned as native vision attachments โ the LLM receives the actual image data.
Text output is truncated to 2000 lines or 50 KB (whichever comes first).
Use offset/limit for large files.
Parameters
| Parameter | Type | Default | Description | Example |
|---|---|---|---|---|
|
string |
required |
Path to the file to read (relative or absolute). Key name is |
|
|
integer |
|
Line number to start reading from (1-indexed). |
|
|
integer |
|
Maximum number of lines to read. |
|
Examples
// Read a full file
{ "path": "src/Main.kt" }
// Read lines 100โ200 of a large file
{ "path": "big_file.log", "offset": 100, "limit": 100 }
// Read an image (returned as vision attachment)
{ "path": "screenshot.png" }
write_file Tool
Writes text content to a file at the given path, sandboxed to the current working directory.
Cache ejection: On a successful (non-error) write,
PureToolResultCache.invalidateByPath()is called withfile_path. This evicts any cachedread_file,grep, orlsresults whose stored path equals the written path or is an ancestor directory of it โ keeping subsequent reads fresh.
Parameters
| Parameter | Type | Default | Description | Example |
|---|---|---|---|---|
|
string |
required |
Path to write to (relative or absolute). Key name is |
|
|
string |
required |
Full text content to write. |
|
|
string |
|
Write mode: |
|
Chunked writes for large files
Split large content across multiple append calls rather than one large overwrite to avoid
tool-call payload limits:
{ "file_path": "report.html", "content": "<html><head>...", "mode": "overwrite" }
{ "file_path": "report.html", "content": "... body ...", "mode": "append" }
{ "file_path": "report.html", "content": "</body></html>", "mode": "append" }
edit_file Tool
Makes surgical targeted-string replacements in a file.
Cache ejection: On a successful (non-error) edit,
PureToolResultCache.invalidateByPath()is called withpath. This evicts any cachedread_file,grep, orlsresults whose stored path equals the edited path or is an ancestor directory of it โ keeping subsequent reads fresh.
Each replacement object locates an exact block of text and replaces it with new content. Use this
instead of write_file for in-place edits โ it preserves everything outside the target blocks.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
|
string |
required |
Path to the file to edit (relative or absolute). |
|
array |
required |
List of replacement objects. Each object must have exactly the keys |
Example
{
"path": "src/Foo.kt",
"replacements": [
{
"targetContent": "val x = 1",
"replacementContent": "val x = 42"
}
]
}
bash Tool
Executes a shell command in the current working directory. Returns stdout and stderr.
Output is truncated to the last 500 lines or 20 KB.
Optionally accepts a timeout in seconds.
Parameters
| Parameter | Type | Default | Description | Example |
|---|---|---|---|---|
|
string |
required |
The bash command to execute. Key name is |
|
|
integer |
system default |
Timeout in seconds. |
|
Bash Fallback Rules
bash is a last-resort tool. Always prefer the dedicated tool when one exists.
Tool Priority Table
| Task | REQUIRED tool | โ Do NOT use bash for |
|---|---|---|
Search file contents by pattern |
|
|
Locate files by name/glob |
|
|
Read a known file path |
|
|
Write or overwrite a file |
|
|
Make targeted in-place edits |
|
|
When bash IS appropriate
-
The task requires execution (building, running tests, installing dependencies, etc.).
-
No dedicated tool exists for the operation (e.g.
gitcommands,curl, custom scripts). -
A pipeline of shell operations is genuinely needed and cannot be decomposed into individual tool calls.
When bash is NOT appropriate
-
Searching file content โ use
grep. -
Discovering files by name โ use
find. -
Reading a file you already know the path to โ use
read_file. -
Writing text to a file โ use
write_file(oredit_filefor targeted changes). -
Any task listed in the Tool Priority Table above. '''
ripgrep Tool
โ ๏ธ This is not a core tool.
ripgrepis an optional extension โ it is not available by default.Two conditions must both be true for this tool to appear: 1. The script
extensions/src/scripts/ripgrep.bk.ktsmust be copied to~/.bk/tools/or.bk/tools/. 2. Thergbinary must be installed and available onPATHat startup.If either condition is false the tool is silently absent from the registry โ the agent will not see it and will not attempt to use it. The
/rg-statusslash command is always available once the script is installed and can be used to diagnose availability.Install
rg:brew install ripgrep(macOS) ยทapt install ripgrep(Debian/Ubuntu) ยท all platforms
A full-featured RipGrep search tool that goes well beyond the built-in grep tool. Uses processRunner.run() for non-blocking execution โ the agent UI stays responsive during searches. Use the built-in grep for simple searches; reach for ripgrep when you need type filters, multiline matching, PCRE2 lookaheads, JSON output, or replacement.
Parameters
Pattern & Path
| Parameter | Type | Default | Description |
|---|---|---|---|
|
string |
required (unless |
Regex pattern. Supports Rust regex syntax. Use |
|
string |
|
Directory or file to search in. |
File Filtering
| Parameter | Type | Default | Description |
|---|---|---|---|
|
string |
โ |
File type filter: |
|
string |
โ |
Exclude a file type ( |
|
string |
โ |
Single glob to include, e.g. |
|
string |
โ |
JSON array of globs: |
|
string |
โ |
Glob to exclude, e.g. |
Output Control
| Parameter | Type | Default | Description |
|---|---|---|---|
|
boolean |
|
Return only filenames ( |
|
boolean |
|
Return per-file match counts ( |
|
boolean |
|
Files that do NOT match ( |
|
integer |
โ |
Max matching lines per file ( |
|
integer |
โ |
Lines of context before and after ( |
|
integer |
โ |
Lines of context before ( |
|
integer |
โ |
Lines of context after ( |
|
boolean |
|
Structured JSON lines output ( |
|
boolean |
|
Append search statistics ( |
|
string |
โ |
Replace matches in output; supports |
|
string |
โ |
Sort by: |
Search Behaviour
| Parameter | Type | Default | Description |
|---|---|---|---|
|
boolean |
|
Literal string search, no regex ( |
|
boolean |
|
Case-insensitive ( |
|
boolean |
|
Case-insensitive unless pattern has uppercase ( |
|
boolean |
|
Force case-sensitive ( |
|
boolean |
|
Match at word boundaries ( |
|
boolean |
|
Pattern can span lines ( |
|
boolean |
|
PCRE2 engine: lookahead, lookbehind, backreferences ( |
|
boolean |
|
Show non-matching lines ( |
Traversal
| Parameter | Type | Default | Description |
|---|---|---|---|
|
integer |
โ |
Maximum directory depth ( |
|
boolean |
|
Search hidden files/dirs ( |
|
boolean |
|
Ignore |
|
boolean |
|
Follow symlinks ( |
Special
| Parameter | Type | Default | Description |
|---|---|---|---|
|
boolean |
|
List all known file types ( |
/rg-status Slash Command
Always registered (even when rg is not installed). Run /rg-status in the TUI to check whether rg is available and see its version and feature flags.
Examples
// Type-filtered search
{ "pattern": "processRunner", "type": "kotlin", "filesOnly": true }
// Literal search with context
{ "pattern": "processRunner.run(", "fixedStrings": true, "context": 2 }
// PCRE2 lookahead
{ "pattern": "fun (?=run)", "pcre2": true, "filesOnly": true }
// Multi-type glob search
{ "pattern": "TODO", "globs": "[\"*.kt\", \"*.kts\"]", "countOnly": true }
// Replace with capture group (output only, does not modify files)
{ "pattern": "val (\\w+): ProcessRunner", "replace": "val $1: ProcessRunner /* injected */", "type": "kotlin" }
// Search hidden/gitignored directories
{ "pattern": "processRunner", "path": ".bk", "hidden": true, "noIgnore": true }
// List all known file types
{ "pattern": "", "typeList": true }
See also: Architecture ยท Usage ยท Extension Overview