Quick Start
Installation
Configure and explore
Configure the workspace with read and write directories via environment variables, then list what is available:
import { Workspace, DirectoryConfiguration } from '@johannes.latzel/llm-chat-workspace';
import { FileAccessInfoTool, FileConfiguration } from '@johannes.latzel/llm-chat-file';
const ws = new Workspace(new DirectoryConfiguration());
const tool = new FileAccessInfoTool(ws, new FileConfiguration());
const [result] = await tool.execute({});
console.log(result.result);
// "Configured file system access:
// /home/user/project write (current workspace)
// /shared/data read
// max chars per file: 100000"
Read and write files
Reuse the same Workspace across tools, no need to reconfigure each time:
import { ReadFileTool, WriteFileTool } from '@johannes.latzel/llm-chat-file';
const read = new ReadFileTool(ws);
const write = new WriteFileTool(ws);
await write.execute({ path: 'notes.txt', content: 'Hello from llm-chat-file!' });
const [result] = await read.execute({ paths: ['notes.txt'] });
console.log(result.result);
Search for files and content
Find .ts files containing "TODO", or search by name, content, and timestamps in one call:
import { SearchEntriesTool } from '@johannes.latzel/llm-chat-file';
const search = new SearchEntriesTool(ws);
const [result] = await search.execute({ name_pattern: '\\.ts$', content_pattern: 'TODO' });
console.log(result.result);
// "src/main.ts:10: // TODO: implement this"
Register with a chat service
Use FileToolPackage to bundle all 13 tools at once, including subfile editing tools (replace_file_lines, insert_file_content, replace_file_content):
import { FileToolPackage } from '@johannes.latzel/llm-chat-file';
import { OpenAIChatService } from '@johannes.latzel/llm-chat-openai';
import { Workspace, DirectoryConfiguration } from '@johannes.latzel/llm-chat-workspace';
const ws = new Workspace(new DirectoryConfiguration());
const pkg = new FileToolPackage(ws);
// Any ChatService implementation works; this example uses the OpenAI provider.
const service = OpenAIChatService.builder().create();
service.tools().add(pkg);
Or register individual tools as needed, see the API Reference for all 13.
Full API
See API Reference for every tool's parameters and return values.