rojects/source/server/rojos/tools/CreateDirectoryTool.ts

37 lines
909 B
TypeScript
Raw Permalink Normal View History

2026-07-30 06:44:46 +00:00
import fs from "fs";
import { RojoTool, RojoToolContext } from "./RojoTool";
import { resolveProjectPath } from "../../storage";
2026-07-30 06:44:46 +00:00
export class CreateDirectoryTool extends RojoTool
{
readonly Definition =
{
type: "function",
function:
{
name: "create_directory",
description: "Create a directory and any missing parent directories at the given path.",
parameters:
{
type: "object",
properties:
{
path: { type: "string", description: "Path relative to the project root." },
},
required: [ "path" ],
},
},
};
async execute( args: Record<string, unknown>, ctx: RojoToolContext ): Promise<unknown>
{
const full = resolveProjectPath( ctx.projectId, args.path as string );
if ( !full ) return { error: "Invalid path" };
fs.mkdirSync( full, { recursive: true } );
return { ok: true };
}
}