import fs from "fs"; import { RojoTool, RojoToolContext } from "./RojoTool"; import { resolveProjectPath } from "../../storage"; export class ReadPathMetaTool extends RojoTool { readonly Definition = { type: "function", function: { name: "read_path_meta", description: "Get metadata for a file or directory: type (file/directory), size in bytes, and last-modified time.", parameters: { type: "object", properties: { path: { type: "string", description: "Path relative to the project root." }, }, required: [ "path" ], }, }, }; async execute( args: Record, ctx: RojoToolContext ): Promise { const full = resolveProjectPath( ctx.projectId, args.path as string ); if ( !full ) return { error: "Invalid path" }; if ( !fs.existsSync( full ) ) return { error: "Path does not exist" }; const stat = fs.statSync( full ); return { type: stat.isDirectory() ? "directory" : "file", size: stat.size, modifiedAt: stat.mtime.toISOString(), }; } }