on main help sign in
fix(test): normalize file separator to make vcr cassette match
commitfd5f8308a06ced43b33b6fd98f0e7e604695e79c authorAndrey Nering <andreynering@users.noreply.github.com> dateMon 27 Oct 2025, 17:12 (1 year ago) parent133f698
5 files changed+28−6
internal/agent/prompt/prompt.go+1−1 internal/agent/tools/bash.go+16−1 internal/agent/tools/glob.go+7 internal/agent/tools/grep.go+1−1 internal/agent/tools/ls.go+3−3
internal/agent/prompt/prompt.go+1−1
@@ -167,7 +167,7 @@ func (p *Prompt) promptData(ctx context.Context, provider, model string, cfg con
167167 Provider: provider,
168168 Model: model,
169169 Config: cfg,
170− WorkingDir: workingDir,
170+ WorkingDir: filepath.ToSlash(workingDir),
171171 IsGitRepo: isGit,
172172 Platform: platform,
173173 Date: p.now().Format("1/2/2006"),
internal/agent/tools/bash.go+16−1
@@ -6,6 +6,9 @@ import (
66 _ "embed"
77 "fmt"
88 "html/template"
9+ "os"
10+ "path/filepath"
11+ "runtime"
912 "strings"
1013 "time"
1114
@@ -289,7 +292,7 @@ func NewBashTool(permissions permission.Service, workingDir string, attribution
289292 if stdout == "" {
290293 return fantasy.WithResponseMetadata(fantasy.NewTextResponse(BashNoOutput), metadata), nil
291294 }
292− stdout += fmt.Sprintf("\n\n<cwd>%s</cwd>", currentWorkingDir)
295+ stdout += fmt.Sprintf("\n\n<cwd>%s</cwd>", normalizeWorkingDir(currentWorkingDir))
293296 return fantasy.WithResponseMetadata(fantasy.NewTextResponse(stdout), metadata), nil
294297 })
295298}
@@ -313,3 +316,15 @@ func countLines(s string) int {
313316 }
314317 return len(strings.Split(s, "\n"))
315318}
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 {
5353 if len(files) == 0 {
5454 output = "No files found"
5555 } else {
56+ normalizeFilePaths(files)
5657 output = strings.Join(files, "\n")
5758 if truncated {
5859 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) {
116117 }
117118 return matches, nil
118119}
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 {
150150 output.WriteString("\n")
151151 }
152152 currentFile = match.path
153− fmt.Fprintf(&output, "%s:\n", match.path)
153+ fmt.Fprintf(&output, "%s:\n", filepath.ToSlash(match.path))
154154 }
155155 if match.lineNum > 0 {
156156 lineText := match.lineText
internal/agent/tools/ls.go+3−3
@@ -210,9 +210,9 @@ func printTree(tree []*TreeNode, rootPath string) string {
210210 var result strings.Builder
211211
212212 result.WriteString("- ")
213− result.WriteString(rootPath)
213+ result.WriteString(filepath.ToSlash(rootPath))
214214 if rootPath[len(rootPath)-1] != '/' {
215− result.WriteByte(filepath.Separator)
215+ result.WriteByte('/')
216216 }
217217 result.WriteByte('\n')
218218
@@ -228,7 +228,7 @@ func printNode(builder *strings.Builder, node *TreeNode, level int) {
228228
229229 nodeName := node.Name
230230 if node.Type == "directory" {
231− nodeName = nodeName + string(filepath.Separator)
231+ nodeName = nodeName + "/"
232232 }
233233
234234 fmt.Fprintf(builder, "%s- %s\n", indent, nodeName)