fix: allow args.filepath to start with .
This commit is contained in:
parent
2a7dfb84e5
commit
1aba0b59a0
1 changed files with 6 additions and 6 deletions
|
|
@ -38,20 +38,20 @@ export const readFileTool: Tool = {
|
|||
filepath = filepath.slice(2);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(args.filepath)) {
|
||||
return `Error: File does not exist: ${args.filepath}`;
|
||||
if (!fs.existsSync(filepath)) {
|
||||
return `Error: File does not exist: ${filepath}`;
|
||||
}
|
||||
const content = fs.readFileSync(args.filepath, "utf-8");
|
||||
const content = fs.readFileSync(filepath, "utf-8");
|
||||
// Mark this file as read for the edit tool
|
||||
markFileAsRead(args.filepath);
|
||||
markFileAsRead(filepath);
|
||||
|
||||
const lines = content.split("\n");
|
||||
if (lines.length > 5000) {
|
||||
const truncatedContent = lines.slice(0, 5000).join("\n");
|
||||
return `Content of ${args.filepath} (truncated to first 5000 lines of ${lines.length} total):\n${truncatedContent}`;
|
||||
return `Content of ${filepath} (truncated to first 5000 lines of ${lines.length} total):\n${truncatedContent}`;
|
||||
}
|
||||
|
||||
return `Content of ${args.filepath}:\n${content}`;
|
||||
return `Content of ${filepath}:\n${content}`;
|
||||
} catch (error) {
|
||||
return `Error reading file: ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue