on main help sign in
fix(test): normalize file separator to make vcr cassette match
fd5f830Andrey Nering
internal/agent/prompt/prompt.go+1−1
@@ -167,7 +167,7 @@ func (p *Prompt) promptData(ctx context.Context, provider, model string, cfg con
167 Provider: provider,
167 Provider: provider,
168 Model: model,
168 Model: model,
169 Config: cfg,
169 Config: cfg,
170− WorkingDir: workingDir,
170+ WorkingDir: filepath.ToSlash(workingDir),
171 IsGitRepo: isGit,
171 IsGitRepo: isGit,
172 Platform: platform,
172 Platform: platform,
173 Date: p.now().Format("1/2/2006"),
173 Date: p.now().Format("1/2/2006"),
internal/agent/tools/bash.go+16−1
@@ -6,6 +6,9 @@ import (
6 _ "embed"
6 _ "embed"
7 "fmt"
7 "fmt"
8 "html/template"
8 "html/template"
9+ "os"
10+ "path/filepath"
11+ "runtime"
9 "strings"
12 "strings"
10 "time"
13 "time"
11
14
@@ -289,7 +292,7 @@ func NewBashTool(permissions permission.Service, workingDir string, attribution
289 if stdout == "" {
292 if stdout == "" {
290 return fantasy.WithResponseMetadata(fantasy.NewTextResponse(BashNoOutput), metadata), nil
293 return fantasy.WithResponseMetadata(fantasy.NewTextResponse(BashNoOutput), metadata), nil
291 }
294 }
292− stdout += fmt.Sprintf("\n\n<cwd>%s</cwd>", currentWorkingDir)
295+ stdout += fmt.Sprintf("\n\n<cwd>%s</cwd>", normalizeWorkingDir(currentWorkingDir))
293 return fantasy.WithResponseMetadata(fantasy.NewTextResponse(stdout), metadata), nil
296 return fantasy.WithResponseMetadata(fantasy.NewTextResponse(stdout), metadata), nil
294 })
297 })
295}
298}
@@ -313,3 +316,15 @@ func countLines(s string) int {
313 }
316 }
314 return len(strings.Split(s, "\n"))
317 return len(strings.Split(s, "\n"))
315}
318}
319+
320+func normalizeWorkingDir(path string) string {
321+ if runtime.GOOS == "windows" {
322+ cwd, err := os.Getwd()
323+ if err != nil {
324+ cwd = "C:"
325+ }
326+ path = strings.ReplaceAll(path, filepath.VolumeName(cwd), "")
327+ }
328+
329+ return filepath.ToSlash(path)
330+}
internal/agent/tools/glob.go+7
@@ -53,6 +53,7 @@ func NewGlobTool(workingDir string) fantasy.AgentTool {
53 if len(files) == 0 {
53 if len(files) == 0 {
54 output = "No files found"
54 output = "No files found"
55 } else {
55 } else {
56+ normalizeFilePaths(files)
56 output = strings.Join(files, "\n")
57 output = strings.Join(files, "\n")
57 if truncated {
58 if truncated {
58 output += "\n\n(Results are truncated. Consider using a more specific path or pattern.)"
59 output += "\n\n(Results are truncated. Consider using a more specific path or pattern.)"
@@ -116,3 +117,9 @@ func runRipgrep(cmd *exec.Cmd, searchRoot string, limit int) ([]string, error) {
116 }
117 }
117 return matches, nil
118 return matches, nil
118}
119}
120+
121+func normalizeFilePaths(paths []string) {
122+ for i, p := range paths {
123+ paths[i] = filepath.ToSlash(p)
124+ }
125+}
internal/agent/tools/grep.go+1−1
@@ -150,7 +150,7 @@ func NewGrepTool(workingDir string) fantasy.AgentTool {
150 output.WriteString("\n")
150 output.WriteString("\n")
151 }
151 }
152 currentFile = match.path
152 currentFile = match.path
153− fmt.Fprintf(&output, "%s:\n", match.path)
153+ fmt.Fprintf(&output, "%s:\n", filepath.ToSlash(match.path))
154 }
154 }
155 if match.lineNum > 0 {
155 if match.lineNum > 0 {
156 lineText := match.lineText
156 lineText := match.lineText
internal/agent/tools/ls.go+3−3
@@ -210,9 +210,9 @@ func printTree(tree []*TreeNode, rootPath string) string {
210 var result strings.Builder
210 var result strings.Builder
211
211
212 result.WriteString("- ")
212 result.WriteString("- ")
213− result.WriteString(rootPath)
213+ result.WriteString(filepath.ToSlash(rootPath))
214 if rootPath[len(rootPath)-1] != '/' {
214 if rootPath[len(rootPath)-1] != '/' {
215− result.WriteByte(filepath.Separator)
215+ result.WriteByte('/')
216 }
216 }
217 result.WriteByte('\n')
217 result.WriteByte('\n')
218
218
@@ -228,7 +228,7 @@ func printNode(builder *strings.Builder, node *TreeNode, level int) {
228
228
229 nodeName := node.Name
229 nodeName := node.Name
230 if node.Type == "directory" {
230 if node.Type == "directory" {
231− nodeName = nodeName + string(filepath.Separator)
231+ nodeName = nodeName + "/"
232 }
232 }
233
233
234 fmt.Fprintf(builder, "%s- %s\n", indent, nodeName)
234 fmt.Fprintf(builder, "%s- %s\n", indent, nodeName)