fix(agents): show workspace-relative feedback paths
This commit is contained in:
parent
194781c3e9
commit
2608ddc6be
2 changed files with 35 additions and 1 deletions
|
|
@ -108,7 +108,7 @@ func summarizeToolFeedbackArgs(toolName, argsPreview string) string {
|
|||
}
|
||||
if isFileToolFeedbackTool(normalizedToolName) {
|
||||
if summary := firstStringArg(args, "path", "file_path", "filepath"); summary != "" {
|
||||
return truncateToolFeedbackSummary(filepath.Base(summary))
|
||||
return truncateToolFeedbackSummary(summarizeFilePath(summary))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
|
|
@ -139,6 +139,27 @@ func normalizeToolFeedbackSummary(text string) string {
|
|||
return redactToolFeedbackSecrets(strings.Join(strings.Fields(text), " "))
|
||||
}
|
||||
|
||||
func summarizeFilePath(path string) string {
|
||||
path = strings.TrimSpace(path)
|
||||
if path == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
cleaned := filepath.Clean(path)
|
||||
slashed := filepath.ToSlash(cleaned)
|
||||
if idx := strings.LastIndex(slashed, "/workspace/"); idx >= 0 {
|
||||
relative := strings.TrimPrefix(slashed[idx+len("/workspace/"):], "/")
|
||||
if relative != "" && relative != "." {
|
||||
return relative
|
||||
}
|
||||
}
|
||||
|
||||
if !filepath.IsAbs(cleaned) {
|
||||
return slashed
|
||||
}
|
||||
return filepath.Base(cleaned)
|
||||
}
|
||||
|
||||
func truncateToolFeedbackSummary(text string) string {
|
||||
const maxRunes = 96
|
||||
runes := []rune(text)
|
||||
|
|
|
|||
|
|
@ -67,6 +67,19 @@ func TestFormatToolFeedbackMessageWithStyle_WorkingSummaryShowsFileBasenameOnly(
|
|||
}
|
||||
}
|
||||
|
||||
func TestFormatToolFeedbackMessageWithStyle_WorkingSummaryShowsWorkspaceRelativeFile(t *testing.T) {
|
||||
got := FormatToolFeedbackMessageWithStyle(
|
||||
"working_summary",
|
||||
"read_file",
|
||||
"",
|
||||
"{\"path\":\"/home/server/.picoclaw/spouse/workspace/memory/MEMORY.md\"}",
|
||||
)
|
||||
want := "Working...\n• tool: `read_file` — `memory/MEMORY.md`"
|
||||
if got != want {
|
||||
t.Fatalf("FormatToolFeedbackMessageWithStyle() = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatToolFeedbackMessageWithStyle_WorkingSummaryShowsExecCommand(t *testing.T) {
|
||||
got := FormatToolFeedbackMessageWithStyle(
|
||||
"working_summary",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue