Overview
Polaris provides a comprehensive set of file operation tools that enable AI agents to create, read, update, delete, rename, and list files and folders within projects. These tools are designed to work efficiently with the file system through Convex backend operations.listFiles
List all files and folders in the project. Returns a structured representation of the project’s file system with IDs, names, types, and parent relationships.Parameters
This tool takes no parameters.Response
Returns a JSON array of file objects:The unique identifier for the file or folder
The name of the file or folder
Either
"file" or "folder"The ID of the parent folder, or
null for root-level items. Items with the same parentId are in the same folder.Example
Files and folders are sorted with folders first, then alphabetically by name.
createFiles
Create multiple files at once in the same parent folder. This is the most efficient way to batch create files that share the same parent directory.Parameters
The ID of the parent folder. Use an empty string
"" for root level. Must be a valid folder ID from listFiles.Response
Returns a success message listing created files and any failures:Example
Error Handling
Common Errors
Common Errors
- Parent folder not found:
Error: Parent folder with ID "xyz" not found. Use listFiles to get valid folder IDs. - Parent is a file:
Error: The ID "xyz" is a file, not a folder. Use a folder ID as parentId. - Invalid parent ID:
Error: Invalid parentId "xyz". Use listFiles to get valid folder IDs, or use empty string for root level. - Empty file name:
Error: File name cannot be empty - Empty array:
Error: Provide at least one file to create
createFolder
Create a new folder in the project.Parameters
The name of the folder to create
The ID (not name!) of the parent folder from
listFiles, or empty string "" for root levelResponse
Returns the ID of the created folder:Example
Error Handling
Common Errors
Common Errors
- Folder name required:
Error: Folder name is required - Parent folder not found:
Error: Parent folder with ID "xyz" not found. Use listFiles to get valid folder IDs. - Parent is a file:
Error: The ID "xyz" is a file, not a folder. Use a folder ID as parentId. - Invalid parent ID:
Error: Invalid parentId "xyz". Use listFiles to get valid folder IDs, or use empty string for root level.
readFiles
Read the content of one or more files from the project.Parameters
Array of file IDs to read. Must contain at least one file ID.
Response
Returns a JSON array of file objects with their contents:The file ID
The file name
The file content
Example
Error Handling
Common Errors
Common Errors
- No files found:
Error: No files found with provided IDs. Use listFiles to get valid fileIDs. - Empty file ID:
Error: File ID cannot be empty - Empty array:
Error: Provide at least one file ID
Files without content or that don’t exist are silently skipped. If all provided IDs are invalid, you’ll receive the “No files found” error.
updateFile
Update the content of an existing file.Parameters
The ID of the file to update
The new content for the file
Response
Returns a success message with the file name:Example
Error Handling
Common Errors
Common Errors
- File not found:
Error: File with ID "xyz" not found. Use listFiles to get valid file IDs. - Target is a folder:
Error: "xyz" is a folder, not a file. You can only update file contents. - File ID required:
Error: File ID is required
renameFile
Rename a file or folder.Parameters
The ID of the file or folder to rename
The new name for the file or folder
Response
Returns a success message showing the old and new names:Example
Error Handling
Common Errors
Common Errors
- File not found:
Error: File with ID "xyz" not found. Use listFiles to get valid file IDs. - File ID required:
Error: File ID is required - New name required:
Error: New name is required
deleteFiles
Delete one or more files or folders from the project. When deleting a folder, all contents are deleted recursively.Parameters
Array of file or folder IDs to delete. Must contain at least one ID.
Response
Returns a success message for each deleted item:Example
Error Handling
Common Errors
Common Errors
- File not found:
Error: File with ID "xyz" not found. Use listFiles to get valid file IDs. - Empty file ID:
Error: File ID cannot be empty - Empty array:
Error: Provide at least one file ID
Best Practices
Efficient File Creation
Always usecreateFiles (plural) instead of creating files one by one when creating multiple files in the same folder:
Understanding File Structure
Always calllistFiles first to understand the project structure before performing operations:
- Call
listFilesto get all file and folder IDs - Use the
parentIdrelationships to understand the folder hierarchy - Use the correct IDs in subsequent operations