filesystem

command
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

This sample demonstrates the Filesystem middleware, which grants the model scoped file access via list_files, read_file, write_file, and search_and_replace tools. All operations are confined to the configured RootDir — os.Root (Go 1.25+) rejects any path that resolves outside it, including via "..", absolute paths, or symbolic links.

A ready-to-demo workspace/ directory ships alongside this sample with a mock project (README, docs, config, data, TODO list) so the tools have something interesting to read and edit.

The sample defines two flows:

  • exploreFlow (read-only): the model lists and reads files under workspace/ to answer a question about the project.
  • editFlow (write-enabled): the model reads a file and applies a SEARCH/REPLACE edit to satisfy a change request.

To run:

go run .

In another terminal, ask a question about the workspace:

curl -N -X POST http://localhost:8080/exploreFlow \
  -H "Content-Type: application/json" \
  -d '{"data": "Summarise what this project does and what is still pending."}'

Apply an edit (writes are visible in workspace/todo.txt afterwards):

curl -N -X POST http://localhost:8080/editFlow \
  -H "Content-Type: application/json" \
  -d '{"data": "Mark the in-memory response cache TODO as done."}'

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL