34 lines
835 B
TypeScript
34 lines
835 B
TypeScript
import { RojoTool, RojoToolContext } from "./RojoTool.js";
|
|
import { readProjectFile } from "../../storage.js";
|
|
|
|
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;
|
|
}
|
|
}
|