2026-07-30 07:03:32 +00:00
|
|
|
import { RojoTool, RojoToolContext } from "./RojoTool";
|
|
|
|
|
import { writeProjectFile } from "../../storage";
|
2026-07-30 06:44:46 +00:00
|
|
|
|
|
|
|
|
export class WriteTextContentTool extends RojoTool
|
|
|
|
|
{
|
|
|
|
|
readonly Definition =
|
|
|
|
|
{
|
|
|
|
|
type: "function",
|
|
|
|
|
function:
|
|
|
|
|
{
|
|
|
|
|
name: "write_text_content",
|
|
|
|
|
description: "Write text content to a file, creating it if it does not exist or overwriting it if it does.",
|
|
|
|
|
parameters:
|
|
|
|
|
{
|
|
|
|
|
type: "object",
|
|
|
|
|
properties:
|
|
|
|
|
{
|
|
|
|
|
path: { type: "string", description: "Path relative to the project root." },
|
|
|
|
|
text: { type: "string", description: "The text content to write." },
|
|
|
|
|
},
|
|
|
|
|
required: [ "path", "text" ],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async execute( args: Record<string, unknown>, ctx: RojoToolContext ): Promise<unknown>
|
|
|
|
|
{
|
|
|
|
|
const ok = writeProjectFile( ctx.projectId, args.path as string, args.text as string );
|
|
|
|
|
|
|
|
|
|
if ( !ok ) return { error: "Could not write file" };
|
|
|
|
|
|
|
|
|
|
return { ok: true };
|
|
|
|
|
}
|
|
|
|
|
}
|