Skip to content

Default Tools — Filesystem

The 10 tools in default-tool-specs-builtin-fs.json are the safety.fs surface as ready-to-call tools — a small shell-style filesystem pipeline covering read, list, stat, grep, slice, sort, cut, find, and write. All paths are resolved against the per-app base path (TOOL_STUDIO_FS_BASE, default ${user.home}); any path whose normalize() lands outside the base is rejected before any I/O.

Because they ride on java.nio.file.Path / Files, separator handling (/ vs \), case folding, and symlink semantics are normalised at the JVM layer — these tools behave identically on macOS, Windows, and Linux. See Tool Studio: Cross-platform by design for the mechanics, and Tool Studio: Filesystem mode for the read-only / read-write sandbox split.

The 10 filesystem tools

readTextFile 🆓

file · pipeline L3

Reads a UTF-8 text file from disk and returns its contents as a single string.

Params   path

Env       —

Click for full reference · params · sandbox · JS source
listDir 🆓

file · pipeline L3

Lists the immediate entries (files and subdirectories) of a directory under the FS base path. Returns an array of relative names (not full paths). Uses safety.fs.list().

Params   dir

Env       —

Click for full reference · params · sandbox · JS source
statFile 🆓

file · pipeline L3

Returns size, last-modified timestamp, and a directory flag for a path inside the FS base. Uses safety.fs.stat().

Params   path

Env       —

Click for full reference · params · sandbox · JS source
lineCount 🆓

file · pipeline L3

Counts the lines in a UTF-8 text file. Uses safety.fs.lineCount().

Params   path

Env       —

Click for full reference · params · sandbox · JS source
sliceFile 🆓

file · pipeline L3

Returns a slice of lines from a UTF-8 text file (head / tail / range). start is 0-based inclusive, end is 0-based exclusive (Python-style slice). Negative values count from the end of the file. Uses safety.fs.slice().

Params   path · start · end

Env       —

Click for full reference · params · sandbox · JS source
sortFile 🆓

file · pipeline L3

Sorts the lines of a UTF-8 text file and returns the sorted lines as an array. Options: reverse / numeric / caseInsensitive / unique. Uses safety.fs.sort().

Params   path · reverse · numeric · caseInsensitive · unique

Env       —

Click for full reference · params · sandbox · JS source
grepFile 🆓

file · pipeline L3

Searches a UTF-8 text file for lines matching a JavaScript regex. Returns an array of matching lines (optionally numbered). Uses safety.fs.grep().

Params   pattern · path · caseInsensitive · numbered · limit

Env       —

Click for full reference · params · sandbox · JS source
findFiles 🆓

file · pipeline L3

Recursively finds files matching a glob inside a directory. Glob supports * and ?. Optional max recursion depth and type filter ('file' or 'dir'). Uses safety.fs.find().

Params   dir · glob · maxDepth · type

Env       —

Click for full reference · params · sandbox · JS source
cutFileFields 🆓

file · pipeline L3

Extracts selected fields from each line of a delimited file (CSV/TSV/etc.). Uses safety.fs.cut(). 1-based field numbers, comma-separated alternatives via the array.

Params   path · fields · delimiter · regex

Env       —

Click for full reference · params · sandbox · JS source
writeTextFile 🆓

file · pipeline L4

Writes a UTF-8 text file inside the FS base path (creating parent directories as needed). Overwrites any existing file. Requires fileWrite permission on the sandbox.

Params   path · content

Env       —

Click for full reference · params · sandbox · JS source

Composition patterns (shell-style filesystem chains)

These ten tools mirror the standard Unix-shell pipeline shape, but every step is a JSON-returning function so the agent can reason between calls:

  • Read → filter → trim → savelistDir(dir)grepFile(pattern, path)sliceFile(path, start, end)writeTextFile(outPath, content). The canonical "summarise recent errors from a log directory" flow.
  • Find → cut → ETLfindFiles(dir, glob='*.csv') → loop with cutFileFields(path, fields=[1,3]) to project a directory of CSVs into one structured dataset.
  • Sort dedupe → countsortFile(path, numeric=true, unique=true)lineCount(path) to deduplicate a numeric stream in place and report the resulting size.
  • Stat-first guardstatFile(path) → branch on size / lastModified → only run the rest of the pipeline if the file changed since the last run.

Tutorial 8: Default Tool Recipes walks the Read → filter → trim → save chain end-to-end as summariseRecentLogs.

Keys & secrets

One configuration value, no real secrets.

Variable What it does Default Where to set
TOOL_STUDIO_FS_BASE Per-app safety.fs base path — every path resolved against it; normalize() rejects any escape. ${user.home} Launcher Environment Variables card, or export TOOL_STUDIO_FS_BASE=/path before launch

The File Toolkit preset opts every read tool into fileRead automatically; writeTextFile requires fileWrite (L4) which you enable per-tool in the Sandbox & Capabilities pane — see Tool Studio: Filesystem mode.

Tool Studio: Filesystem modefileRead / fileWrite semantics and base-path enforcement. → Index — overview of all 86 default tools and the five reference pages.