skip to content
$worker

coder

v0.5.5

Path-jailed code worker — info/read/search/update/create/delete/move files plus paginated list-folder and tree, with non-accessible glob protection, default noise excludes (.git, node_modules, … — hide-only, per-call opt-out), and token-bounded read/search response budgets.

iiiverified
73 installs17 in 7d0 today
install
$iii worker add coder
binary
  • macOS: arm64 · x64
  • Linux: arm64 · armv7 · x64

exact versions are immutable; binary and bundle artifacts are digest-pinned.

functions

10

coder::create-file

function

Create one or more files. Request shape: {"files": [{"path": "...", "content": "..."}]}. Per-file `overwrite` and `parents` flags; non-accessible paths return C211. Paths are relative to the primary allowed root or absolute inside any allowed root (coder::info lists them); for host paths outside the jail use shell::fs::*.

request
  • base_dirstring

    Optional per-call session working directory. When set, relative `path`s anchor here instead of the primary allowed root, and every resolved path must stay inside it. `base_dir` itself must canonicalize inside an allowed root (`coder::info` lists them). Omit to resolve against the primary allowed root exactly as before.

  • filesobject[]required
    • contentstringrequired
    • modestring

      Octal permission bits as a string, e.g. "0644". Defaults to "0644".

    • overwriteboolean

      When false (the default), refuse to write if `path` already exists.

    • parentsboolean

      Create missing parent directories. Defaults to true so a single `coder::create-file` call can scaffold a fresh subtree.

    • pathstringrequired

      Path relative to the primary allowed root, or an absolute path inside any allowed root. Call `coder::info` to see the allowed roots. Paths outside every allowed root are rejected — use the shell worker's `shell::fs::*` for host paths outside the jail.

response
  • resultsobject[]required
    • bytes_writteninteger· uint64requiredmin 0
    • errorany of

      Structured error for this entry. `code` is stable for programmatic branching (e.g. `"C217"` means already-exists; pass `overwrite=true` to replace). `message` carries the corrective action an LLM agent needs to make a successful second call.

      any of (2)
      variant 1
      • codestringrequired

        Stable error code, e.g. "C211". See the README error table.

      • messagestringrequired

        Human/LLM-readable message: problem + actual values + corrective next call.

      variant 2
      valuenull
    • pathstringrequired

      Canonical absolute path (resolved through the jail); the caller's input verbatim when resolution failed.

    • successbooleanrequired

coder::delete-file

function

Remove one or more paths. Request shape: {"paths": ["..."]}. Directories need `recursive: true`; missing paths are idempotent successes; recursive removal refuses to descend through non-accessible entries. Paths are relative to the primary allowed root or absolute inside any allowed root (coder::info lists them); for host paths outside the jail use shell::fs::*.

request
  • base_dirstring

    Optional per-call session working directory. When set, relative `paths` anchor here instead of the primary allowed root, and every resolved path must stay inside it. `base_dir` itself must canonicalize inside an allowed root (`coder::info` lists them). Omit to resolve against the primary allowed root exactly as before.

  • pathsstring[]required

    Paths to remove. Each entry is relative to the primary allowed root, or an absolute path inside any allowed root. Call `coder::info` to see the allowed roots. Paths outside every allowed root are rejected — use the shell worker's `shell::fs::*` for host paths outside the jail.

  • recursiveboolean

    Required for non-empty directories. Files and empty dirs ignore it.

response
  • resultsobject[]required
    • errorany of

      Structured error for this entry. `code` is stable for programmatic branching (e.g. `"C211"` for not-found-or-denied; `"C210"` for refusing to delete an allowed root). `message` carries the corrective action an LLM agent needs to make a successful second call.

      any of (2)
      variant 1
      • codestringrequired

        Stable error code, e.g. "C211". See the README error table.

      • messagestringrequired

        Human/LLM-readable message: problem + actual values + corrective next call.

      variant 2
      valuenull
    • pathstringrequired

      Canonical absolute path (resolved through the jail); the caller's input verbatim when resolution failed.

    • removedbooleanrequired
    • successbooleanrequired

coder::info

function

Report the coder jail: canonical allowed roots (primary first), per-file size caps, response budgets (max_output_bytes, batch_read_budget_bytes, search_response_budget_bytes), listing/search limits, the non-accessible glob patterns, and the default_exclude_globs noise filter applied by tree/search. Call this FIRST when unsure where coder may read or write, or when a path was rejected — paths outside every allowed root need the shell worker's shell::fs::* instead.

request
empty object
response
  • base_pathsstring[]required

    Canonical absolute paths of the allowed roots, in configuration order. The primary root (index 0) is where relative wire paths resolve; an absolute path is accepted when it canonicalises inside ANY of these. Paths outside every root are rejected — use `shell::fs::*` instead.

  • batch_read_budget_bytesinteger· uint64requiredmin 0

    Aggregate budget across a single `paths[]` batch call to `coder::read-file`, measured in bytes of returned content (after UTF-8 sanitization — invalid bytes expand to U+FFFD before being counted, so the cap bounds what the caller actually receives). Entries are collected in request order; each entry may consume up to `min(remaining_budget, max_read_bytes)`. An entry reached with zero remaining budget receives a per-entry C213 naming this key, its value, and the bytes already consumed, with recovery guidance. Budget topology: batch reads are governed by this key; single-path full reads by `max_output_bytes`; windowed reads by `max_read_bytes` applied per returned window — `max_read_bytes` is also the per-file IO ceiling for all of them.

  • default_exclude_globsstring[]required

    Noise-exclusion globs (root-relative, same matching as `non_accessible_globs`): matching paths (node_modules, .git, …) are omitted from `coder::search` results and pruned from `coder::tree` descent — the directory surfaces as a childless `truncated` stub. Hide-only — no access protection. Pass `use_default_excludes: false` on those calls to look inside.

  • list_default_page_sizeinteger· uint32requiredmin 0

    Default `page_size` used by `coder::list-folder` when the caller omits it.

  • list_max_page_sizeinteger· uint32requiredmin 0

    Hard cap on `page_size` accepted by `coder::list-folder`.

  • max_output_bytesinteger· uint64requiredmin 0

    Context budget for single-path FULL reads in `coder::read-file`, in bytes of returned content. Full reads larger than this return C213 with the file's size/line count and window/stat recovery guidance; a per-call `max_output_bytes` override is available on `coder::read-file` (clamped to `max_read_bytes`).

  • max_read_bytesinteger· uint64requiredmin 0

    Per-file IO ceiling for `coder::read-file`. Full reads of files larger than this are rejected with C213; windowed reads cap the returned window bytes instead, so larger files stay readable window by window. Also the ceiling for `coder::search` content scanning — larger files are silently skipped during search.

  • max_write_bytesinteger· uint64requiredmin 0

    Maximum bytes that `coder::create-file` or `coder::update-file` will accept for a single file write. Larger writes are rejected with C213.

  • non_accessible_globsstring[]required

    Glob patterns matched per root (root-relative). Files whose root-relative path matches are listable but not readable/writable/deletable/creatable; they return C211.

  • primary_rootstringrequired

    Convenience duplicate of `base_paths[0]` — the primary allowed root. Relative paths resolve against this directory.

  • search_default_max_line_bytesinteger· uint32requiredmin 0

    Per-line byte cap in `coder::search`: matching considers at most this many bytes of each line, and matched/context lines are truncated to it.

  • search_default_max_matchesinteger· uint32requiredmin 0

    Default `max_matches` used by `coder::search` when the caller omits it.

  • search_response_budget_bytesinteger· uint64requiredmin 0

    Aggregate byte budget for one `coder::search` response, measured in payload bytes (paths + matched text + context lines). When the budget is hit the response sets `truncated: true` — refine the query or add `include_globs`.

  • tree_default_depthinteger· uint32requiredmin 0

    Default `max_depth` used by `coder::tree` when the caller omits it.

  • tree_per_folder_limitinteger· uint32requiredmin 0

    Maximum entries returned per folder node by `coder::tree`; folders that exceed this are flagged `truncated`.

  • versionstringrequired

    Coder worker version (`CARGO_PKG_VERSION`).

coder::list-folder

function

Paginated single-folder listing, sorted by name. Entries carry only `name`; derive an entry's absolute path as the response's `path` + '/' + name. Non-accessible entries are still listed with a `non_accessible: true` flag. Paths are relative to the primary allowed root or absolute inside any allowed root (coder::info lists them); for host paths outside the jail use shell::fs::*.

request
  • base_dirstring

    Optional per-call session working directory. When set, a relative `path` anchors here instead of the primary allowed root, and the resolved folder must stay inside it. `base_dir` itself must canonicalize inside an allowed root (`coder::info` lists them). Omit to resolve against the primary allowed root exactly as before.

  • pageinteger· uint32min 0
  • page_sizeinteger· uint32min 0

    Capped by `config.list_max_page_size`; falls back to `config.list_default_page_size` when omitted.

  • pathstring

    Folder to list. Relative to the primary allowed root, or an absolute path inside any allowed root. Defaults to `.` (the primary root itself). Call `coder::info` to see the allowed roots. Paths outside every allowed root are rejected — use the shell worker's `shell::fs::*` for host paths outside the jail.

response
  • entriesobject[]required
    • kindstringrequiredenum: file, dir, symlink, other
    • mtimeinteger· int64required
    • namestringrequired

      Entry basename. The absolute path is derivable from the response's `path`: entry path = folder path + "/" + name.

    • non_accessiblebooleanrequired

      True if this entry matches `non_accessible_globs` — caller cannot read/write/delete it via `coder::*` even though it shows up here.

    • sizeinteger· uint64requiredmin 0
  • has_morebooleanrequired
  • pageinteger· uint32requiredmin 0
  • page_sizeinteger· uint32requiredmin 0
  • pathstringrequired

    Canonical absolute path of the listed folder (resolved through the jail). Entries carry only `name`; derive an entry's absolute path by joining: entry path = this path + "/" + name. Operations on derived paths re-validate through the jail.

  • totalinteger· uint64requiredmin 0

coder::move

function

Move or rename one or more paths inside the jail. Request shape: {"files": [{"from": "...", "to": "..."}]}. Paths are relative to the primary allowed root or absolute inside any allowed root (coder::info lists them); for host paths outside the jail use shell::fs::*. Per-entry `overwrite` and `parents` flags. Same-root moves use a per-file-atomic rename; cross-root moves use copy+delete (files only — cross-root directory moves are unsupported, move files individually). Copy+delete is rollback-safe: if source deletion fails after a successful copy the copy is removed and the error names the failure; if rollback also fails the error names both states for manual cleanup.

request
  • base_dirstring

    Optional per-call session working directory. When set, relative `from`/`to` paths anchor here instead of the primary allowed root, and BOTH resolved endpoints must stay inside it. `base_dir` itself must canonicalize inside an allowed root (`coder::info` lists them). Omit to resolve against the primary allowed root exactly as before.

  • filesobject[]required

    Entries to move. Each entry is processed independently so a single failure never aborts the rest.

    • fromstringrequired

      Source path: relative to the primary allowed root, or an absolute path inside any allowed root. Call `coder::info` to see the allowed roots. Paths outside every allowed root are rejected — use the shell worker's `shell::fs::*` for host paths outside the jail.

    • overwriteboolean

      When false (the default), refuse to overwrite an existing destination. Pass `overwrite: true` to replace an existing file at `to`.

    • parentsboolean

      Create missing parent directories of the destination. Defaults to true.

    • tostringrequired

      Destination path: relative to the primary allowed root, or an absolute path inside any allowed root. Call `coder::info` to see the allowed roots. Paths outside every allowed root are rejected — use the shell worker's `shell::fs::*` for host paths outside the jail.

response
  • resultsobject[]required
    • errorany of

      Structured error for this entry. `code` is stable for programmatic branching (e.g. `"C217"` means destination exists; pass `overwrite=true` to replace; `"C210"` for disallowed operations such as cross-root directory moves, moving a root itself, or a destination that is a directory — the message then names the corrected target path). `message` carries the corrective action an LLM agent needs to make a successful second call.

      any of (2)
      variant 1
      • codestringrequired

        Stable error code, e.g. "C211". See the README error table.

      • messagestringrequired

        Human/LLM-readable message: problem + actual values + corrective next call.

      variant 2
      valuenull
    • fromstringrequired

      Canonical absolute path of the source (resolved through the jail); the caller's input verbatim when resolution failed.

    • movedbooleanrequired

      True only when the move fully completed; false for a no-op self-move (`from` and `to` resolve to the same file).

    • successbooleanrequired
    • tostringrequired

      Canonical absolute path of the destination (resolved through the jail); the caller's input verbatim when resolution failed.

coder::on-config-change

function

Internal: reload coder's tuning limits from the authoritative configuration when it changes; jail-defining changes require a restart.

request
  • idstring

    Configuration id that changed (advisory; the handler re-fetches the value).

response
  • okbooleanrequired

coder::read-file

function

Read a file window-first: probe with stat: true (size/mtime/mode plus total_lines, no content), then fetch just the lines you need with line_from/line_to (1-based, inclusive) — windows keep files larger than max_read_bytes readable window by window, with more_lines/total_lines reporting what remains. numbered: true prefixes each line with its absolute 1-based file line number, matching coder::update-file's line ops exactly. Full reads are budgeted by max_output_bytes (default 128 KiB; per-call override clamped to max_read_bytes) — an over-budget full read fails with a C213 carrying the file's size, line count, and the window/stat recovery calls. Batch mode: pass paths[] (XOR path) to read multiple files in one call — entries are processed in request order against batch_read_budget_bytes, measured in bytes of returned content (after UTF-8 sanitization); per-entry errors (C211/C213) leave other entries unaffected. Paths are relative to the primary allowed root or absolute inside any allowed root (coder::info lists them); for host paths outside the jail use shell::fs::*. Non-accessible paths return C211.

request
  • base_dirstring

    Optional per-call session working directory. When set, every relative path (the single `path` or each `paths[]` entry, in both the bare string and `{path,...}` object forms) anchors here instead of the primary allowed root, and every resolved path must stay inside it. `base_dir` itself must canonicalize inside an allowed root (`coder::info` lists them). Omit to resolve against the primary allowed root exactly as before.

  • line_frominteger· uint64min 1

    First line of the window, 1-based inclusive (must be >= 1; 0 is rejected with C210). Setting `line_from` and/or `line_to` switches to windowed mode: the file is streamed and only the requested lines are returned, so files larger than `max_read_bytes` stay readable slice by slice — the byte cap then applies to the returned window, never the file size. Defaults to 1 when only `line_to` is set. A window starting past EOF succeeds with empty content and reports the file's `total_lines`. Only valid in single-path mode (`path`); ignored when `paths` is set. Lines are 0x0A- or EOF-terminated segments; a trailing newline does not create a phantom line (same convention as `coder::update-file`).

  • line_tointeger· uint64min 1

    Last line of the window, 1-based inclusive. Must be >= `line_from` (C210 otherwise). Omit to read from `line_from` to end-of-file (still bounded by `max_read_bytes` on the returned bytes). Only valid in single-path mode (`path`); ignored when `paths` is set.

  • max_output_bytesinteger· uint64min 0

    Per-call override of the `max_output_bytes` config (default 131072) that budgets single-path FULL reads, measured in returned content bytes after UTF-8 conversion (numbered prefixes included). Values above `max_read_bytes` are silently clamped to it. When the full content would exceed the effective budget the call fails with a C213 naming the file's size and `total_lines` — recover by windowing with `line_from`/`line_to`, probing with `stat: true`, or raising this field. Full reads only: combining it with `line_from`/`line_to` is C210 (windows are bounded by `max_read_bytes` instead); ignored when `paths` is set (batch mode is governed by `batch_read_budget_bytes`).

  • numberedboolean

    When true every returned content line is prefixed `N→`, where N is the line's ABSOLUTE 1-based number in the file — a window starting at `line_from: 40` is numbered from 40, not 1. Numbers match `coder::update-file`'s 1-based line ops exactly, so you can go from a numbered read straight to a line edit. Prefix bytes count toward all byte caps and budgets (no hidden bypass). C210 with `stat: true` (no content to number). Batch entries take a per-entry `numbered` field instead; this top-level flag is ignored when `paths` is set.

  • pathstring

    Single file to read. Relative to the primary allowed root, or an absolute path inside any allowed root. Call `coder::info` to see the allowed roots. Paths outside every allowed root are rejected — use the shell worker's `shell::fs::*` for host paths outside the jail. Mutually exclusive with `paths` (XOR): pass either `path` or `paths`, not both — C210 if both or neither is set.

  • pathsany of[]

    Batch of files (or windowed slices) to read in a single call. Each entry is either a plain path string (whole-file read) or an object `{path, line_from?, line_to?}` with per-entry window parameters. Entries are processed in request order against a shared `batch_read_budget_bytes` cap, measured in bytes of returned content (after UTF-8 sanitization) — see `coder::info` for the configured value. Results are returned in the `results` field; top-level fields are null. Mutually exclusive with `path` (XOR): pass either `path` or `paths`, not both — C210 if both or neither is set.

    any of (2)
    variant 1
    valuestring
    variant 2
    • line_frominteger· uint64min 1

      First line of the window, 1-based inclusive (must be >= 1; 0 is rejected with C210 for this entry). Defaults to 1 when only `line_to` is set.

    • line_tointeger· uint64min 1

      Last line of the window, 1-based inclusive. Must be >= `line_from` (C210 for this entry otherwise). Omit to read from `line_from` to EOF.

    • numberedboolean

      Prefix this entry's content lines with their absolute 1-based file line numbers (`N→`) — same semantics as the top-level `numbered` field. Prefix bytes are charged against `batch_read_budget_bytes`.

    • pathstringrequired

      File to read. Same jail rules as the top-level `path` field.

    • statboolean

      Per-entry metadata probe: same semantics as the top-level `stat` field — size/mode/mtime always, `total_lines`/`is_utf8` when the file fits `max_read_bytes`, content null, no batch budget consumed. C210 when combined with this entry's `line_from`/`line_to` or `numbered`.

  • statboolean

    Metadata probe — the cheap "how big is it" call. When true the response carries size/mode/mtime plus `total_lines` and `is_utf8` (both null when the file exceeds `max_read_bytes` — size/mode/mtime still populate, so stat on a huge file SUCCEEDS); `content` is null, `lines_returned` 0, `more_lines` false. Probe BEFORE reading an unknown file, then fetch just the slice you need with `line_from`/`line_to`. Mutually exclusive with `line_from`, `line_to`, `numbered`, and `max_output_bytes` (C210 — stat returns no content for them to act on). Batch entries take a per-entry `stat` field instead; this top-level flag is ignored when `paths` is set.

response
  • contentstring

    File content as a UTF-8 string — the whole file, or just the requested window when `line_from`/`line_to` was given (window lines keep their newline terminators). Binary content is returned with invalid bytes replaced by U+FFFD; use a future binary-aware function if exact bytes matter. **Single-path mode only; null when the request used `paths[]`.**

  • is_utf8boolean

    Whether `content` survived UTF-8 conversion without losing bytes. Reflects the RETURNED content only: a clean window inside an otherwise-binary file is still `true`. **Single-path mode only; null when the request used `paths[]`.**

  • lines_returnedinteger· uint64min 0

    Number of lines in `content`. For full reads this equals the file's total line count. **Single-path mode only; null when the request used `paths[]`.**

  • modeinteger· uint32min 0

    Unix permission bits (lower 9 bits of `st_mode`), e.g. 0o644. **Single-path mode only; null when the request used `paths[]`.**

  • more_linesboolean

    True when the file has content beyond what `content` includes: the window ended before EOF, or the byte budget cut the window short. Always false for full reads. **Single-path mode only; null when the request used `paths[]`.**

  • mtimeinteger· int64

    Last-modified time as a Unix epoch in seconds. **Single-path mode only; null when the request used `paths[]`.**

  • pathstring

    Canonical absolute path of the file read (resolved through the jail). **Single-path mode only; null when the request used `paths[]`.**

  • resultsobject[]

    Per-entry results for a batch `paths[]` request. **Present only when the request used `paths[]`; null in single-path mode.**

    • contentstring

      File content as a UTF-8 string — the whole file or the requested window. Binary bytes are replaced by U+FFFD (`is_utf8: false`). `null` on failure.

    • errorany of

      Structured error — present only when `success: false`.

      any of (2)
      variant 1
      • codestringrequired

        Stable error code, e.g. "C211". See the README error table.

      • messagestringrequired

        Human/LLM-readable message: problem + actual values + corrective next call.

      variant 2
      valuenull
    • is_utf8boolean

      Whether `content` survived UTF-8 conversion without losing bytes. `null` on failure.

    • lines_returnedinteger· uint64min 0

      Number of lines returned in `content`. `null` on failure.

    • modeinteger· uint32min 0

      Unix permission bits (lower 9 bits of `st_mode`), e.g. 0o644. `null` on failure.

    • more_linesboolean

      `true` when the file has content beyond what `content` includes (window ended before EOF, or byte budget cut the window short). `null` on failure.

    • mtimeinteger· int64

      Last-modified time as a Unix epoch in seconds. `null` on failure.

    • pathstringrequired

      Canonical absolute path of the file (resolved through the jail). If resolution failed, this echoes the caller's input verbatim.

    • sizeinteger· uint64min 0

      Size of the FILE in bytes (from metadata). `null` on failure or when the entry budget was exhausted before the file was opened.

    • successbooleanrequired

      `true` when the read succeeded (content/metadata fields are populated); `false` when an error occurred (only `error` is set).

    • total_linesinteger· uint64min 0

      Total lines in the file; present when the stream reached EOF during this entry's read. `null` when not traversed or on failure.

  • sizeinteger· uint64min 0

    Size of the FILE in bytes (from metadata) — not the size of `content`; in windowed mode the two differ. **Single-path mode only; null when the request used `paths[]`.**

  • total_linesinteger· uint64min 0

    Total number of lines in the file. Present only when the read traversed the whole file: always for full reads; for windowed reads only when the stream naturally reached EOF within the byte cap. Never computed by forcing an extra full scan — absent means the file was not fully traversed. **Single-path mode only; null when the request used `paths[]`.**

coder::search

function

Search file contents and/or paths. Supports literal or regex queries with include/exclude globs; non-accessible files are excluded from both content and path results. Only the FIRST match on each line is reported (one content match per matching line). Optional context_lines_before/context_lines_after (max 10) attach surrounding lines to each content match so many edits can go straight to coder::update-file with no read in between. Noise paths matching default_exclude_globs (.git, node_modules, target, … — coder::info lists them) are skipped by default; pass use_default_excludes: false to search inside them. Files larger than max_read_bytes are silently skipped during content scanning. Results are capped by max_matches AND a response byte budget (search_response_budget_bytes); when truncated is true, refine the query or add include_globs rather than paginate. Paths are relative to the primary allowed root or absolute inside any allowed root (coder::info lists them); for host paths outside the jail use shell::fs::*.

request
  • base_dirstring

    Optional per-call session working directory. When set, a relative `path` anchors here instead of the primary allowed root, and the walk root must stay inside it. `base_dir` itself must canonicalize inside an allowed root (`coder::info` lists them). Result paths stay absolute. Omit to resolve against the primary allowed root exactly as before.

  • context_lines_afterinteger· uint32min 0

    Lines of context to return AFTER each content match. Same max (10), truncation, and budget rules as `context_lines_before`; unset = 0.

  • context_lines_beforeinteger· uint32min 0

    Lines of context to return BEFORE each content match (same file only, in file order), max 10 — larger values are rejected with C210. With context lines many edit tasks can go straight from search output to coder::update-file with no read in between. Context lines are truncated to `max_line_bytes` like the matched text and count toward the response byte budget. Unset = 0.

  • exclude_globsstring[]

    Glob patterns (same relative-to-root matching) that exclude paths.

  • ignore_caseboolean
  • include_globsstring[]

    Glob patterns (matched against the path relative to its containing root) that paths must match to be considered. Empty = include everything.

  • max_line_bytesinteger· uint32min 0

    Bytes per line to consider when scanning content; longer lines are truncated for the match snippet.

  • max_matchesinteger· uint32min 0

    Optional explicit cap. Falls back to config when unset.

  • pathstring

    Folder scoping the walk. Relative to the primary allowed root, or an absolute path inside any allowed root. Defaults to `.` (the primary root itself). Globs are matched relative to the containing root; result paths are absolute regardless of this value. Call `coder::info` to see the allowed roots. Paths outside every allowed root are rejected — use the shell worker's `shell::fs::*` for host paths outside the jail.

  • querystringrequired

    Pattern to search for. Treated as a regex when `regex: true`, otherwise as a literal substring.

  • regexboolean
  • search_contentboolean

    Search file contents (default true).

  • search_pathsboolean

    Search file paths (default true).

  • use_default_excludesboolean

    Apply the worker's `default_exclude_globs` config (noise paths like .git, node_modules, target, dist — call coder::info for the active list): the walk does not descend into matching directories and matching files are omitted from BOTH content and path results. Pass `false` to search inside them.

response
  • content_matchesobject[]required
    • afterstring[]

      Context lines immediately after the matched line — same file only, in file order, each truncated to `max_line_bytes`. Omitted when empty (no `context_lines_after` requested, or the match is at the end of the file).

    • beforestring[]

      Context lines immediately before the matched line — same file only, in file order, each truncated to `max_line_bytes`. Omitted when empty (no `context_lines_before` requested, or the match is at the start of the file).

    • columninteger· uint32requiredmin 0
    • lineinteger· uint32requiredmin 0
    • pathstringrequired

      Absolute path under the canonical parent; symlinks at the entry itself are not resolved. Operations on it re-validate through the jail.

    • textstringrequired

      Matched line; truncated to `max_line_bytes` and never spans newlines.

  • path_matchesobject[]required
    • pathstringrequired

      Absolute path under the canonical parent; symlinks at the entry itself are not resolved. Operations on it re-validate through the jail.

  • truncatedbooleanrequired

    True if results were cut off — either match list hit the `max_matches` cap, or the response hit the `search_response_budget_bytes` byte budget. When true, refine the query or add include_globs rather than paginate.

coder::tree

function

Recursive directory snapshot bounded by `max_depth` and a `per_folder_limit`. Slim wire shape: nodes carry only `name` — the root node's path IS the response's top-level `path`; derive any child's path as parent path + '/' + name. Folders that hit the limit are flagged `truncated` and the caller is pointed at coder::list-folder for pagination. Noise directories matching default_exclude_globs (.git, node_modules, target, … — coder::info lists them) appear as childless `truncated` stubs; pass use_default_excludes: false to descend into them. Paths are relative to the primary allowed root or absolute inside any allowed root (coder::info lists them); for host paths outside the jail use shell::fs::*.

request
  • base_dirstring

    Optional per-call session working directory. When set, a relative `path` anchors here instead of the primary allowed root, and the resolved base folder must stay inside it. `base_dir` itself must canonicalize inside an allowed root (`coder::info` lists them). Omit to resolve against the primary allowed root exactly as before.

  • max_depthinteger· uint32min 0

    Maximum depth to descend; the root node is depth 0.

  • pathstring

    Base folder for the snapshot. Relative to the primary allowed root, or an absolute path inside any allowed root. Defaults to `.` (the primary root itself). Call `coder::info` to see the allowed roots. Paths outside every allowed root are rejected — use the shell worker's `shell::fs::*` for host paths outside the jail.

  • per_folder_limitinteger· uint32min 0

    Maximum children listed per folder. When more exist, the folder is flagged `truncated` and callers should switch to `coder::list-folder`.

  • use_default_excludesboolean

    Apply the worker's `default_exclude_globs` config (noise folders like .git/node_modules/target — call `coder::info` for the active list). Excluded directories still appear as childless nodes flagged `truncated` with reason "default_exclude"; excluded files are omitted. Pass `false` to list everything.

response
  • pathstringrequired

    Canonical absolute path of the requested folder (resolved through the jail). Nodes carry only `name`, and the root node's path IS this `path` — do not join the root's `name` onto it; derive children by joining from here: child path = parent path + "/" + name. Operations on derived paths re-validate through the jail.

  • rootall ofrequired

    Root node of the snapshot; its `name` is the folder's basename.

    all of (1)
    variant 1
    • childrenunknown[]
    • kindstringrequiredenum: file, dir, symlink, other
    • mtimeinteger· int64required
    • namestringrequired

      Entry basename. The ROOT node's path is the response's top-level `path` itself; every other node's path derives by joining from there: child path = parent path + "/" + name.

    • non_accessiblebooleanrequired
    • sizeinteger· uint64requiredmin 0
    • truncatedany of

      Set on directories whose `children` was capped at `per_folder_limit`, whose subtree was cut off by `max_depth`, or which matched `default_exclude_globs` (reason "default_exclude").

      … expand 2 nested
      any of (2)
      variant 1
      • hintstringrequired
      • reasonstringrequired

        Reason this folder was truncated: hit `per_folder_limit`, cut off by `max_depth`, or matched `default_exclude_globs` (`default_exclude`).

      • showninteger· uint32requiredmin 0

        Number of children actually returned.

      • totalinteger· uint32min 0

        Total number of children eligible for listing in the folder, counted after default-exclude filtering (only populated when `reason == "per_folder_limit"`; for depth truncation we don't peek into the folder).

      variant 2
      valuenull

coder::update-file

function

Apply batched line-oriented and regex edits across one or more files. Request shape: {"files": [{"path": "...", "ops": [...]}]}. Line ops: { op: 'insert', at_line, content } | { op: 'remove', from_line, to_line } | { op: 'update_lines', from_line, to_line, content } — 1-based, inclusive, applied bottom-up. Regex op: { op: 'replace', pattern, replacement, ignore_case?, dot_matches_newline?, expect_matches? } runs on the file body after line ops. Replace large regions WITHOUT quoting them: two short anchors joined by .*? with dot_matches_newline: true — always prefer wildcards over pasting the block into the pattern. expect_matches: 1 turns a silent multi-site clobber into a safe pre-write C210; expect_matches: 0 asserts absence. In `replacement`, $1/${name} are capture references and a literal $ must be written $$ (JS/TS template literals: `Hello, $${name}!`); undefined references fail pre-write with C210. Each file commits atomically via temp + rename. On success each applied line op returns a bounded post-apply echo (±2 context lines); regex replace ops return up to 5 per-match-site echoes (first + last line of each replaced region, inner lines elided) — verify from the echoes instead of re-reading the file. Paths are relative to the primary allowed root or absolute inside any allowed root (coder::info lists them); for host paths outside the jail use shell::fs::*.

request
  • base_dirstring

    Optional per-call session working directory. When set, relative `path`s anchor here instead of the primary allowed root, and every resolved path must stay inside it. `base_dir` itself must canonicalize inside an allowed root (`coder::info` lists them). Omit to resolve against the primary allowed root exactly as before.

  • filesobject[]required
    • opsone of[]required
      one of (4)
      variant 1
      • at_lineinteger· uint32requiredmin 0
      • contentstringrequired
      • opstringrequiredenum: insert
      variant 2
      • from_lineinteger· uint32requiredmin 0
      • opstringrequiredenum: remove
      • to_lineinteger· uint32requiredmin 0
      variant 3
      • contentstringrequired
      • from_lineinteger· uint32requiredmin 0
      • opstringrequiredenum: update_lines
      • to_lineinteger· uint32requiredmin 0
      variant 4
      • dot_matches_newlineboolean

        When true, `.` in `pattern` also matches `\n`, so a short anchored pattern like `"fn parse_config\\(.*?\\n\\}"` replaces a whole multi-line region without quoting it — prefer two short anchors joined by `.*?` over pasting the block into the pattern. Without this flag (the default), `.` does not cross newlines and a multi-line pattern silently matches nothing.

      • expect_matchesinteger· uint64min 0

        Expected number of matches for this op. When set and the actual count differs, this FILE fails with C210 and nothing is written to it (other files in the batch still apply). Set `expect_matches: 1` to make a targeted read-free edit safe — a mismatch means the pattern is anchored too loosely or matches nothing. Set `expect_matches: 0` to assert ABSENCE: the op succeeds only when nothing matches (the replacement is unused). Omit to replace all matches unconditionally.

      • ignore_caseboolean
      • opstringrequiredenum: replace
      • patternstringrequired
      • replacementstringrequired

        Substitution text for each match. Capture references expand: `$1`/`${1}` by index (`$0` is the whole match) and `$name`/`${name}` by name. A literal `$` MUST be written `$$` — JS/TS template literals in a replacement are the classic collision: write `Hello, $${name}!` to output `Hello, ${name}!`. Unbraced references consume the longest `[0-9A-Za-z_]` run, so `$1a` means a group named "1a", NOT group 1 then "a" (use `${1}a`). A reference to a group the pattern does not define fails pre-write with C210 — nothing is written. References are validated even when the replacement goes unused (e.g. `expect_matches: 0`): the replacement must be well-formed even when unused.

    • pathstringrequired

      Path relative to the primary allowed root, or an absolute path inside any allowed root. Call `coder::info` to see the allowed roots. Paths outside every allowed root are rejected — use the shell worker's `shell::fs::*` for host paths outside the jail.

response
  • resultsobject[]required
    • appliedinteger· uint32requiredmin 0

      Number of operations applied (only meaningful when `success`).

    • echoesobject[]required

      Per-op bounded post-apply echoes for edit verification; each applied op returns a snapshot of the affected region (±2 context lines) so the caller can confirm the edit landed at the right position without receiving the full file body. See `OpEcho` for field semantics. Empty on failure. Always present on the wire.

      • elidedinteger· uint64min 0

        Number of middle lines elided from a large region: for line ops, set when the affected region exceeded the per-echo cap; for replace sites, the count of inner lines between the region's echoed first and last line (set when the region spans >2 lines).

      • from_lineinteger· uint64requiredmin 0

        1-based line number of the first echoed line (after all ops applied).

      • linesstring[]required

        The echoed lines, post-apply. When the region is large, middle lines are elided and `elided` is set to indicate how many were skipped.

      • op_indexinteger· uint32requiredmin 0

        Index of the op in the request's ops array (0-based).

      • total_replacementsinteger· uint64min 0

        Total number of replacements the regex op made across the whole file (set only on replace-op site echoes, duplicated on each site). Sites are capped at 5 — when more matched, this count is the only record of the extras.

    • echoes_truncatedbooleanrequired

      True when the total echo budget (~4 KiB) was exhausted before all op echoes could be emitted. Use `coder::read-file` to inspect the full result if needed. Always present on the wire.

    • errorany of

      Structured error for this entry. `code` is stable for programmatic branching (e.g. `"C211"` for not-found-or-denied; `"C210"` for bad input such as overlapping ops). `message` carries the corrective action an LLM agent needs to make a successful second call.

      any of (2)
      variant 1
      • codestringrequired

        Stable error code, e.g. "C211". See the README error table.

      • messagestringrequired

        Human/LLM-readable message: problem + actual values + corrective next call.

      variant 2
      valuenull
    • new_line_countinteger· uint64requiredmin 0

      Final line count after applying (only meaningful when `success`).

    • pathstringrequired

      Canonical absolute path (resolved through the jail); the caller's input verbatim when resolution failed.

    • successbooleanrequired

triggers

0
no triggers registered