Elffuss BraidHub

kikocis/continue public

fix: ls tool relative paths (#7982)

* fix: ls tool relative paths

* fix: list files prompt tweak

* fix: revert preventing .. since absolute skirts
Changeset7f567429e2fa98e1948acda56b45c8babbde441014ba884355339f194d8f35e4
AuthorDallin Romney <dallinromney@gmail.com> · 2025-09-25 16:19 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-25 16:19 -07:00
Parents3297e898700c

Browse the files at this changeset

1 file changed

modified extensions/cli/src/tools/listFiles.ts +17 −11
@@ -22,13 +22,27 @@
2222 readonly: true,
2323 isBuiltIn: true,
2424 preprocess: async (args) => {
25+ // Resolve relative paths
26+ const normalizedPath = path.normalize(args.dirpath);
27+ const dirPath = path.resolve(process.cwd(), normalizedPath);
28+
29+ if (!fs.existsSync(dirPath)) {
30+ throw new Error(`Directory does not exist: ${dirPath}`);
31+ }
32+
33+ if (!fs.statSync(dirPath).isDirectory()) {
34+ throw new Error(`Error: Path is not a directory: ${dirPath}`);
35+ }
36+
2537 return {
26- args,
38+ args: {
39+ dirpath: dirPath,
40+ },
2741 preview: [
2842 {
2943 type: "text",
30- content: args.dirpath
31- ? `Will list files in: ${formatToolArgument(args.dirpath)}`
44+ content: dirPath
45+ ? `Will list files in: ${formatToolArgument(dirPath)}`
3246 : "Will list files in current directory",
3347 },
3448 ],
@@ -36,14 +50,6 @@
3650 },
3751 run: async (args: { dirpath: string }): Promise<string> => {
3852 try {
39- if (!fs.existsSync(args.dirpath)) {
40- return `Error: Directory does not exist: ${args.dirpath}`;
41- }
42-
43- if (!fs.statSync(args.dirpath).isDirectory()) {
44- return `Error: Path is not a directory: ${args.dirpath}`;
45- }
46-
4753 const files = fs.readdirSync(args.dirpath);
4854 const fileDetails = files.map((file) => {
4955 const fullPath = path.join(args.dirpath, file);