Documentation
¶
Overview ¶
This sample demonstrates the Filesystem middleware, which grants the model scoped file access through list_files, read_file, write_file, and search_and_replace tools. Everything is confined to RootDir by os.Root, which rejects any path resolving outside it, including via "..", absolute paths, or symlinks. A mock project in workspace/ gives the tools something to work on.
- exploreFlow answers a question by listing and reading files.
- editFlow applies a SEARCH/REPLACE edit, writing to workspace/ on disk.
Run it:
go run .
Or with the Dev UI, to watch the tool calls in a trace of every run at http://localhost:4000/traces:
curl -sL cli.genkit.dev | bash # install the Genkit CLI, once genkit start -- go run .
Or over HTTP:
curl -N -X POST 'http://localhost:8080/exploreFlow?stream=true' \
-H "Content-Type: application/json" \
-d '{"data": {"question": "Summarise what this project does and what is still pending."}}'
curl -N -X POST 'http://localhost:8080/editFlow?stream=true' \
-H "Content-Type: application/json" \
-d '{"data": {"instruction": "Mark the in-memory response cache TODO as done."}}'
Click to show internal directories.
Click to hide internal directories.