pig/workspace/tools
Tool wrappers for pig workspace operations.
This module provides tools that wrap workspace kv and vfs operations
as pig.tool.Tool values that can be registered with pig agents.
Each tool closes over a sqlight.Connection and provides a handler
that parses JSON arguments and calls the appropriate workspace function.
Tools
read_file— Read file contents with line numberswrite_file— Create or replace a filelist_directory— List entries in a directorydelete_file— Delete a file or empty directorygrep— Search file contents for a patternremember— Store a key-value pairrecall— Retrieve a stored valuelist_keys— List keys matching a prefix
Values
pub fn all_tools(conn: sqlight.Connection) -> List(tool.Tool)
Return all workspace tools in a list.
pub fn delete_file_tool(conn: sqlight.Connection) -> tool.Tool
Create a delete_file tool.
Parameters:
- path: String (required) - file or empty directory path
Deletes a file or empty directory.
pub fn grep_tool(conn: sqlight.Connection) -> tool.Tool
Create a grep tool.
Search file contents for a substring pattern. Returns matching lines with file path and line number.
Parameters:
- pattern: String (required) - substring to search for
- path: String (optional) - directory or file to search under (default: root)
- include: String (optional) - GLOB filter on file path (e.g. “*.py”)
- max_results: Int (optional) - limit number of results (default: 50)
pub fn list_directory_tool(conn: sqlight.Connection) -> tool.Tool
Create a list_directory tool.
Parameters:
- path: String (required) - directory path
Returns a JSON array of entry names.
pub fn list_keys_tool(conn: sqlight.Connection) -> tool.Tool
Create a list_keys tool.
Parameters:
- prefix: String (required) - key prefix to match
Returns a JSON array of matching keys.
pub fn read_file_tool(conn: sqlight.Connection) -> tool.Tool
Create a read_file tool.
Parameters:
- path: String (required) - file path
- offset: Int (optional) - line number to start from (0-indexed)
- limit: Int (optional) - maximum number of lines to read
Returns file content with line numbers in “N\tline” format.
pub fn recall_tool(conn: sqlight.Connection) -> tool.Tool
Create a recall tool.
Parameters:
- key: String (required) - key to retrieve
Returns the stored value as a JSON string.
pub fn remember_tool(conn: sqlight.Connection) -> tool.Tool
Create a remember tool.
Parameters:
- key: String (required) - key to store
- value: String (required) - value to store
Stores a key-value pair that persists across conversations.
pub fn write_file_tool(conn: sqlight.Connection) -> tool.Tool
Create a write_file tool.
Parameters:
- path: String (required) - file path
- content: String (required) - file content
Creates or overwrites a file.