2026-07-30 07:03:32 +00:00
|
|
|
import { RojoTool, RojoToolContext } from "./RojoTool";
|
|
|
|
|
import { readProjectFile } from "../../storage";
|
2026-07-30 06:44:46 +00:00
|
|
|
|
|
|
|
|
export class GetTextContentTool extends RojoTool
|
|
|
|
|
{
|
|
|
|
|
readonly Definition =
|
|
|
|
|
{
|
|
|
|
|
type: "function",
|
|
|
|
|
function:
|
|
|
|
|
{
|
|
|
|
|
name: "get_text_content",
|
|
|
|
|
description: "Read and return the text content of a file.",
|
|
|
|
|
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 content = readProjectFile( ctx.projectId, args.path as string );
|
|
|
|
|
|
|
|
|
|
if ( null === content ) return { error: "File not found or unreadable" };
|
|
|
|
|
|
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
}
|