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

find

Locate files by glob pattern

โœ…

Built-in

grep

Search file content by regex

โœ…

Built-in

read_file

Read a file (text or image)

โœ…

Built-in

write_file

Write / append to a file

โŒ

Built-in

edit_file

Surgical targeted-string replacement

โŒ

Built-in

bash

Execute a shell command

โŒ

Built-in

ripgrep

Full-featured RipGrep search

โŒ

Extension (ripgrep.bk.kts)

Cacheable tools (find, grep, read_file) have their results stored in PureToolResultCache for the duration of a session. Identical calls return the cached result instantly without re-executing.

โš ๏ธ ripgrep is not a core tool. It is an optional extension shipped in the :extensions module (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 if rg (RipGrep) is found in PATH at startup. If rg is 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 bash for ALL file-discovery operations. Do NOT use bash find or bash fd. Do NOT include pipe characters or grep filters in pattern โ€” use the grep tool for content filtering.

Parameters

Parameter Type Default Description Example

pattern

string

required

Glob pattern to match files.

".kt", "/.json", "src//*.kt"

path

string

"."

Directory to search in.

"src/main"

limit

integer

1000

Maximum number of results to return.

50

type

string

null

Filter by entry type: "f" for files, "d" for directories.

"f"

maxDepth

integer

null

Maximum directory traversal depth. 1 = immediate children only.

2

excludePath

string

null

Glob pattern for a directory subtree to prune from results (e.g. "build", "**/generated").

"build"

modifiedWithinDays

integer

null

Return only files modified within the last N days.

7

newerThan

string

null

Return only files modified more recently than the given reference file path. Forces the system-find fallback (fd does not support this flag).

"build.gradle.kts"

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

max_depth, depth

maxDepth

exclude, ignore, exclude_path

excludePath

modified_within_days, days

modifiedWithinDays

newer_than, newer

newerThan

kind

type

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 bash for ALL grep/search operations. Do NOT use bash grep or bash rg. The pattern parameter is a regex โ€” use | for alternation (e.g. "foo|bar"), not shell pipe syntax.

Parameters

Parameter Type Default Description Example

pattern

string

required

Regex pattern to search for. Use | for alternation.

"fun\\s+\\w+"

path

string

"."

File or directory to search in.

"src/main"

include

string

null

Single glob pattern for files to include (e.g. "*.kt"). Ignored when includeGlobs is set.

"*.kt"

exclude

string

null

Glob pattern for files to exclude (e.g. "*.md").

"*.md"

context

integer

null

Number of context lines to show both before and after each match.

3

beforeContext

integer

null

Number of context lines to show before each match. Key name is beforeContext (camelCase).

2

afterContext

integer

null

Number of context lines to show after each match. Key name is afterContext (camelCase).

2

maxCount

integer

null

Limit the number of matches returned. Key name is maxCount (camelCase).

10

filesOnly

boolean

false

When true, return only the filenames of files containing matches instead of the matching lines (rg -l / grep -l). Line numbers and match text are suppressed. Key name is filesOnly (camelCase).

true

countOnly

boolean

false

When true, return the per-file match count instead of matching lines (rg --count / grep -c). Line numbers and match text are suppressed. Key name is countOnly (camelCase).

true

includeGlobs

array of strings

null

List of glob patterns for files to include. Each entry maps to a separate -g flag (rg) or --include flag (grep). Use instead of include when searching multiple file types. Overrides include if both are set.

[".kt", ".kts"]

Alias remapping (normalizeArguments)

Alias(es) Canonical name

files_only, filenames_only, filenames, list_files

filesOnly

count, count_only, counts

countOnly

include_globs, globs, types

includeGlobs

before_context

beforeContext

after_context

afterContext

max_count

maxCount

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

path

string

required

Path to the file to read (relative or absolute). Key name is path โ€” do NOT use file, filename, or file_path.

"src/Main.kt"

offset

integer

1

Line number to start reading from (1-indexed).

50

limit

integer

2000

Maximum number of lines to read.

100

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 with file_path. This evicts any cached read_file, grep, or ls results whose stored path equals the written path or is an ancestor directory of it โ€” keeping subsequent reads fresh.

Parameters

Parameter Type Default Description Example

file_path

string

required

Path to write to (relative or absolute). Key name is file_path.

"src/NewFile.kt"

content

string

required

Full text content to write.

"package foo\n…​"

mode

string

"overwrite"

Write mode: "overwrite" replaces the file; "append" adds to the end (creates if absent).

"append"

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 with path. This evicts any cached read_file, grep, or ls results 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

path

string

required

Path to the file to edit (relative or absolute).

replacements

array

required

List of replacement objects. Each object must have exactly the keys targetContent (exact text to find) and replacementContent (text to substitute). Never use find/replace or old_string/new_string.

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

command

string

required

The bash command to execute. Key name is command โ€” do NOT use cmd, shell_command, or script.

"./gradlew build"

timeout

integer

system default

Timeout in seconds.

120


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

grep

bash grep, bash rg

Locate files by name/glob

find

bash find, bash fd

Read a known file path

read_file

bash cat

Write or overwrite a file

write_file

bash echo โ€ฆ >, bash tee

Make targeted in-place edits

edit_file

bash sed, bash awk

When bash IS appropriate

  • The task requires execution (building, running tests, installing dependencies, etc.).

  • No dedicated tool exists for the operation (e.g. git commands, 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 (or edit_file for targeted changes).

  • Any task listed in the Tool Priority Table above. '''

ripgrep Tool

โš ๏ธ This is not a core tool. ripgrep is 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.kts must be copied to ~/.bk/tools/ or .bk/tools/. 2. The rg binary must be installed and available on PATH at 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-status slash 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

pattern

string

required (unless typeList)

Regex pattern. Supports Rust regex syntax. Use | for alternation.

path

string

"."

Directory or file to search in.

File Filtering

Parameter Type Default Description

type

string

โ€”

File type filter: kotlin, java, py, ts, etc. (rg -t)

typeNot

string

โ€”

Exclude a file type (rg -T).

glob

string

โ€”

Single glob to include, e.g. "*.kt" (rg -g).

globs

string

โ€”

JSON array of globs: [".kt",".kts"]. Each maps to a -g flag.

excludeGlob

string

โ€”

Glob to exclude, e.g. "*.min.js". Prefixed with ! internally.

Output Control

Parameter Type Default Description

filesOnly

boolean

false

Return only filenames (rg -l).

countOnly

boolean

false

Return per-file match counts (rg --count).

filesWithoutMatch

boolean

false

Files that do NOT match (rg --files-without-match).

maxCount

integer

โ€”

Max matching lines per file (rg -m).

context

integer

โ€”

Lines of context before and after (rg -C).

beforeContext

integer

โ€”

Lines of context before (rg -B).

afterContext

integer

โ€”

Lines of context after (rg -A).

jsonOutput

boolean

false

Structured JSON lines output (rg --json).

stats

boolean

false

Append search statistics (rg --stats).

replace

string

โ€”

Replace matches in output; supports $1 capture groups (rg -r). Does NOT modify files.

sortBy

string

โ€”

Sort by: path, modified, accessed, created, none.

Search Behaviour

Parameter Type Default Description

fixedStrings

boolean

false

Literal string search, no regex (rg -F).

ignoreCase

boolean

false

Case-insensitive (rg -i).

smartCase

boolean

false

Case-insensitive unless pattern has uppercase (rg -S).

caseSensitive

boolean

false

Force case-sensitive (rg -s).

wordRegexp

boolean

false

Match at word boundaries (rg -w).

multiline

boolean

false

Pattern can span lines (rg --multiline).

pcre2

boolean

false

PCRE2 engine: lookahead, lookbehind, backreferences (rg -P).

invertMatch

boolean

false

Show non-matching lines (rg -v).

Traversal

Parameter Type Default Description

maxDepth

integer

โ€”

Maximum directory depth (rg --max-depth).

hidden

boolean

false

Search hidden files/dirs (rg --hidden).

noIgnore

boolean

false

Ignore .gitignore rules (rg --no-ignore).

followSymlinks

boolean

false

Follow symlinks (rg -L).

Special

Parameter Type Default Description

typeList

boolean

false

List all known file types (rg --type-list). Pattern not required.

/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