continue-custom/core/tools/implementations/readFile.ts
2024-12-18 22:50:05 -08:00

22 lines
586 B
TypeScript

import { getUriPathBasename } from "../../util/uri";
import { ToolImpl } from ".";
import { resolveRelativePathInDir } from "../../util/ideUtils";
export const readFileImpl: ToolImpl = async (args, extras) => {
const firstUriMatch = await resolveRelativePathInDir(
args.filepath,
extras.ide,
);
if (!firstUriMatch) {
throw new Error(`Could not find file ${args.filepath}`);
}
const content = await extras.ide.readFile(firstUriMatch);
return [
{
name: getUriPathBasename(args.filepath),
description: args.filepath,
content,
},
];
};