-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfileDiff.ts
More file actions
26 lines (22 loc) · 623 Bytes
/
fileDiff.ts
File metadata and controls
26 lines (22 loc) · 623 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { readFile as fsReadFile } from "fs/promises";
import { z } from "zod";
import { Tool } from "../openai/tool.utils.js";
import { $ } from "zx";
const argsSchema = z.object({
relativeFilePath: z
.string()
.describe("The path to the file relative to the project root"),
});
type Args = z.input<typeof argsSchema>;
export default {
name: "fileDiff",
description: "Reads the current diffs of a file",
argsSchema,
async call(args: Args) {
let diff = await $`git --no-pager diff ${args.relativeFilePath}`;
return {
success: true,
output: diff,
};
},
} satisfies Tool<Args>;