filesystem

command
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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