@@ -56,14 +56,14 @@ func TestLsTool_Run(t *testing.T) {
56 // Create directories
56 // Create directories
57 for _, dir := range testDirs {
57 for _, dir := range testDirs {
58 dirPath := filepath.Join(tempDir, dir)
58 dirPath := filepath.Join(tempDir, dir)
59− err := os.MkdirAll(dirPath, 0755)
59+ err := os.MkdirAll(dirPath, 0o755)
60 require.NoError(t, err)
60 require.NoError(t, err)
63 // Create files
63 // Create files
64 for _, file := range testFiles {
64 for _, file := range testFiles {
65 filePath := filepath.Join(tempDir, file)
65 filePath := filepath.Join(tempDir, file)
66− err := os.WriteFile(filePath, []byte("test content"), 0644)
66+ err := os.WriteFile(filePath, []byte("test content"), 0o644)
67 require.NoError(t, err)
67 require.NoError(t, err)
@@ -83,19 +83,19 @@ func TestLsTool_Run(t *testing.T) {
84 response, err := tool.Run(context.Background(), call)
84 response, err := tool.Run(context.Background(), call)
85 require.NoError(t, err)
85 require.NoError(t, err)
87 // Check that visible directories and files are included
87 // Check that visible directories and files are included
88 assert.Contains(t, response.Content, "dir1")
88 assert.Contains(t, response.Content, "dir1")
89 assert.Contains(t, response.Content, "dir2")
89 assert.Contains(t, response.Content, "dir2")
90 assert.Contains(t, response.Content, "dir3")
90 assert.Contains(t, response.Content, "dir3")
91 assert.Contains(t, response.Content, "file1.txt")
91 assert.Contains(t, response.Content, "file1.txt")
92 assert.Contains(t, response.Content, "file2.txt")
92 assert.Contains(t, response.Content, "file2.txt")
94 // Check that hidden files and directories are not included
94 // Check that hidden files and directories are not included
95 assert.NotContains(t, response.Content, ".hidden_dir")
95 assert.NotContains(t, response.Content, ".hidden_dir")
96 assert.NotContains(t, response.Content, ".hidden_file.txt")
96 assert.NotContains(t, response.Content, ".hidden_file.txt")
97 assert.NotContains(t, response.Content, ".hidden_root_file.txt")
97 assert.NotContains(t, response.Content, ".hidden_root_file.txt")
99 // Check that __pycache__ is not included
99 // Check that __pycache__ is not included
100 assert.NotContains(t, response.Content, "__pycache__")
100 assert.NotContains(t, response.Content, "__pycache__")
@@ -122,7 +122,7 @@ func TestLsTool_Run(t *testing.T) {
122 t.Run("handles empty path parameter", func(t *testing.T) {
122 t.Run("handles empty path parameter", func(t *testing.T) {
123 // For this test, we need to mock the config.WorkingDirectory function
123 // For this test, we need to mock the config.WorkingDirectory function
124 // Since we can't easily do that, we'll just check that the response doesn't contain an error message
124 // Since we can't easily do that, we'll just check that the response doesn't contain an error message
126 tool := NewLsTool()
126 tool := NewLsTool()
127 params := LSParams{
127 params := LSParams{
128 Path: "",
128 Path: "",
@@ -138,7 +138,7 @@ func TestLsTool_Run(t *testing.T) {
139 response, err := tool.Run(context.Background(), call)
139 response, err := tool.Run(context.Background(), call)
140 require.NoError(t, err)
140 require.NoError(t, err)
142 // The response should either contain a valid directory listing or an error
142 // The response should either contain a valid directory listing or an error
143 // We'll just check that it's not empty
143 // We'll just check that it's not empty
144 assert.NotEmpty(t, response.Content)
144 assert.NotEmpty(t, response.Content)
@@ -173,11 +173,11 @@ func TestLsTool_Run(t *testing.T) {
174 response, err := tool.Run(context.Background(), call)
174 response, err := tool.Run(context.Background(), call)
175 require.NoError(t, err)
175 require.NoError(t, err)
177 // The output format is a tree, so we need to check for specific patterns
177 // The output format is a tree, so we need to check for specific patterns
178 // Check that file1.txt is not directly mentioned
178 // Check that file1.txt is not directly mentioned
179 assert.NotContains(t, response.Content, "- file1.txt")
179 assert.NotContains(t, response.Content, "- file1.txt")
181 // Check that dir1/ is not directly mentioned
181 // Check that dir1/ is not directly mentioned
182 assert.NotContains(t, response.Content, "- dir1/")
182 assert.NotContains(t, response.Content, "- dir1/")
@@ -189,12 +189,12 @@ func TestLsTool_Run(t *testing.T) {
189 defer func() {
189 defer func() {
190 os.Chdir(origWd)
190 os.Chdir(origWd)
193 // Change to a directory above the temp directory
193 // Change to a directory above the temp directory
194 parentDir := filepath.Dir(tempDir)
194 parentDir := filepath.Dir(tempDir)
195 err = os.Chdir(parentDir)
195 err = os.Chdir(parentDir)
196 require.NoError(t, err)
196 require.NoError(t, err)
198 tool := NewLsTool()
198 tool := NewLsTool()
199 params := LSParams{
199 params := LSParams{
200 Path: filepath.Base(tempDir),
200 Path: filepath.Base(tempDir),
@@ -210,7 +210,7 @@ func TestLsTool_Run(t *testing.T) {
211 response, err := tool.Run(context.Background(), call)
211 response, err := tool.Run(context.Background(), call)
212 require.NoError(t, err)
212 require.NoError(t, err)
214 // Should list the temp directory contents
214 // Should list the temp directory contents
215 assert.Contains(t, response.Content, "dir1")
215 assert.Contains(t, response.Content, "dir1")
216 assert.Contains(t, response.Content, "file1.txt")
216 assert.Contains(t, response.Content, "file1.txt")
@@ -291,22 +291,22 @@ func TestCreateFileTree(t *testing.T) {
293 tree := createFileTree(paths)
293 tree := createFileTree(paths)
295 // Check the structure of the tree
295 // Check the structure of the tree
296 assert.Len(t, tree, 1) // Should have one root node
296 assert.Len(t, tree, 1) // Should have one root node
298 // Check the root node
298 // Check the root node
299 rootNode := tree[0]
299 rootNode := tree[0]
300 assert.Equal(t, "path", rootNode.Name)
300 assert.Equal(t, "path", rootNode.Name)
301 assert.Equal(t, "directory", rootNode.Type)
301 assert.Equal(t, "directory", rootNode.Type)
302 assert.Len(t, rootNode.Children, 1)
302 assert.Len(t, rootNode.Children, 1)
304 // Check the "to" node
304 // Check the "to" node
305 toNode := rootNode.Children[0]
305 toNode := rootNode.Children[0]
306 assert.Equal(t, "to", toNode.Name)
306 assert.Equal(t, "to", toNode.Name)
307 assert.Equal(t, "directory", toNode.Type)
307 assert.Equal(t, "directory", toNode.Type)
308 assert.Len(t, toNode.Children, 3) // file1.txt, dir1, dir2
308 assert.Len(t, toNode.Children, 3) // file1.txt, dir1, dir2
310 // Find the dir1 node
310 // Find the dir1 node
311 var dir1Node *TreeNode
311 var dir1Node *TreeNode
312 for _, child := range toNode.Children {
312 for _, child := range toNode.Children {
@@ -315,7 +315,7 @@ func TestCreateFileTree(t *testing.T) {
319 require.NotNil(t, dir1Node)
319 require.NotNil(t, dir1Node)
320 assert.Equal(t, "directory", dir1Node.Type)
320 assert.Equal(t, "directory", dir1Node.Type)
321 assert.Len(t, dir1Node.Children, 2) // file2.txt and subdir
321 assert.Len(t, dir1Node.Children, 2) // file2.txt and subdir
@@ -354,9 +354,9 @@ func TestPrintTree(t *testing.T) {
354 Type: "file",
354 Type: "file",
358 result := printTree(tree, "/root")
358 result := printTree(tree, "/root")
360 // Check the output format
360 // Check the output format
361 assert.Contains(t, result, "- /root/")
361 assert.Contains(t, result, "- /root/")
362 assert.Contains(t, result, " - dir1/")
362 assert.Contains(t, result, " - dir1/")
@@ -390,14 +390,14 @@ func TestListDirectory(t *testing.T) {
390 // Create directories
390 // Create directories
391 for _, dir := range testDirs {
391 for _, dir := range testDirs {
392 dirPath := filepath.Join(tempDir, dir)
392 dirPath := filepath.Join(tempDir, dir)
393− err := os.MkdirAll(dirPath, 0755)
393+ err := os.MkdirAll(dirPath, 0o755)
394 require.NoError(t, err)
394 require.NoError(t, err)
397 // Create files
397 // Create files
398 for _, file := range testFiles {
398 for _, file := range testFiles {
399 filePath := filepath.Join(tempDir, file)
399 filePath := filepath.Join(tempDir, file)
400− err := os.WriteFile(filePath, []byte("test content"), 0644)
400+ err := os.WriteFile(filePath, []byte("test content"), 0o644)
401 require.NoError(t, err)
401 require.NoError(t, err)
@@ -405,7 +405,7 @@ func TestListDirectory(t *testing.T) {
405 files, truncated, err := listDirectory(tempDir, []string{}, 1000)
405 files, truncated, err := listDirectory(tempDir, []string{}, 1000)
406 require.NoError(t, err)
406 require.NoError(t, err)
407 assert.False(t, truncated)
407 assert.False(t, truncated)
409 // Check that visible files and directories are included
409 // Check that visible files and directories are included
410 containsPath := func(paths []string, target string) bool {
410 containsPath := func(paths []string, target string) bool {
411 targetPath := filepath.Join(tempDir, target)
411 targetPath := filepath.Join(tempDir, target)
@@ -416,12 +416,12 @@ func TestListDirectory(t *testing.T) {
417 return false
417 return false
420 assert.True(t, containsPath(files, "dir1"))
420 assert.True(t, containsPath(files, "dir1"))
421 assert.True(t, containsPath(files, "file1.txt"))
421 assert.True(t, containsPath(files, "file1.txt"))
422 assert.True(t, containsPath(files, "file2.txt"))
422 assert.True(t, containsPath(files, "file2.txt"))
423 assert.True(t, containsPath(files, "dir1/file3.txt"))
423 assert.True(t, containsPath(files, "dir1/file3.txt"))
425 // Check that hidden files and directories are not included
425 // Check that hidden files and directories are not included
426 assert.False(t, containsPath(files, ".hidden_dir"))
426 assert.False(t, containsPath(files, ".hidden_dir"))
427 assert.False(t, containsPath(files, ".hidden_file.txt"))
427 assert.False(t, containsPath(files, ".hidden_file.txt"))
@@ -438,12 +438,12 @@ func TestListDirectory(t *testing.T) {
438 files, truncated, err := listDirectory(tempDir, []string{"*.txt"}, 1000)
438 files, truncated, err := listDirectory(tempDir, []string{"*.txt"}, 1000)
439 require.NoError(t, err)
439 require.NoError(t, err)
440 assert.False(t, truncated)
440 assert.False(t, truncated)
442 // Check that no .txt files are included
442 // Check that no .txt files are included
443 for _, file := range files {
443 for _, file := range files {
444 assert.False(t, strings.HasSuffix(file, ".txt"), "Found .txt file: %s", file)
444 assert.False(t, strings.HasSuffix(file, ".txt"), "Found .txt file: %s", file)
447 // But directories should still be included
447 // But directories should still be included
448 containsDir := false
448 containsDir := false
449 for _, file := range files {
449 for _, file := range files {
@@ -454,4 +454,4 @@ func TestListDirectory(t *testing.T) {
455 assert.True(t, containsDir)
455 assert.True(t, containsDir)