ChloeGet Started

Reference

@chloejs/core/tools/fs

One folder, as tools: list, read, search, write and edit.

The tools over services/filesService.ts: one folder, offered to a model.

An agent binds each one to a root it is allowed to see, and names that folder in plain words for the description.

import * as fs from "@chloejs/core/tools/fs";
tools: { fsReadFile: fs.readFile({ root: "/srv/notes", what: "the shared notes" }) }

editFilelistFilesreadFilesearchFileswriteFile

editFilefunction

export function editFile({
  root,
  what,
  commit = false,
  author,
  memory = false,
}: Folder & { commit?: boolean; author?: string; memory?: boolean })

A tool that changes one part of a file in that folder. commit, author and memory are as for writeFile.

model/tools/fs.ts:114

listFilesfunction

export function listFiles({ root, what }: Folder)

A tool that lists what is in one folder, and nothing outside it. Its overview is the folder's folders, two levels down, so a model knows the layout before its first call.

model/tools/fs.ts:24

readFilefunction

export function readFile({ root, what, limit = 40_000 }: Folder & { limit?: number })

A tool that reads one file inside that folder, or part of it. limit is how many characters an unranged read returns before it is cut at a line and says so: 40,000 (about 10,000 tokens) unless the binding says otherwise.

model/tools/fs.ts:50

searchFilesfunction

export function searchFiles({ root, what, around = 2 }: Folder & { around?: number })

A tool that searches the text of the files in that folder. around is how many lines either side of each match come back with it: 2 unless the binding says otherwise.

model/tools/fs.ts:70

writeFilefunction

export function writeFile({
  root,
  what,
  commit = false,
  author,
  memory = false,
}: Folder & { commit?: boolean; author?: string; memory?: boolean })

commit makes every write a git commit, for a folder that is a repo, under author when there is one. memory says this folder is the agent's memory, so the run writing it lists the commit.

model/tools/fs.ts:89