The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(hooks): keep the separator when a Cline workspace root is a bare volume
Clauded726c334849c
diff --git a/cli/beacon-hooks/cmd/cline_event.go b/cli/beacon-hooks/cmd/cline_event.goindex 14015acf..296e8154 100644--- a/cli/beacon-hooks/cmd/cline_event.go+++ b/cli/beacon-hooks/cmd/cline_event.go@@ -488,6 +488,21 @@ func joinWorkspacePath(root, rel string) string {// "..\..\..\x.ts" into the bare relative "x.ts", an absolute Windows path with no drive left// on it.volume, rootRest := splitPathVolume(root)+ // A root of "C:" carries no separator for the rule above to read, but a drive letter is+ // unambiguously Windows, so the recorded path should be Windows-shaped rather than defaulting to+ // slashes. Only a bare drive reaches this: a UNC root always contains separators.+ if separator == "/" && volume != "" && !strings.ContainsAny(root, "/\\") {+ separator = "\\"+ }+ // A bare volume -- "\\\\server\\share" or "C:" with nothing after it -- leaves an empty remainder,+ // and path.Join drops empty elements, so the separator between root and relative path+ // disappeared: the share and the path ran together as "\\\\server\\sharesrc\\app.ts", naming a+ // file nothing touched. Substituting the root directory is also the right reading of the value:+ // a workspace root of "C:" means that drive's root, not a path relative to its working+ // directory.+ if volume != "" && rootRest == "" {+ rootRest = "/"+ }joined := path.Join(toSlashPath(rootRest), toSlashPath(rel))if separator != "/" {joined = strings.ReplaceAll(joined, "/", separator)diff --git a/cli/beacon-hooks/cmd/cline_event_test.go b/cli/beacon-hooks/cmd/cline_event_test.goindex 475625e6..ed1b1c09 100644--- a/cli/beacon-hooks/cmd/cline_event_test.go+++ b/cli/beacon-hooks/cmd/cline_event_test.go@@ -576,6 +576,15 @@ func TestClineWorkspacePathIsHostIndependent(t *testing.T) {{name: "traversal above a drive root keeps the drive", path: `..\..\..\x.ts`, root: `C:\repo`, want: `C:\x.ts`},// A leading "//" is a share, not a doubled separator, and path.Clean would collapse it.{name: "unc share survives cleaning", path: `..\b.ts`, root: `\\server\share\repo\pkg`, want: `\\server\share\repo\b.ts`},+ // A bare volume leaves nothing after the prefix, and path.Join drops empty elements -- which+ // ran the share and the path together as "\\server\sharesrc\app.ts".+ {name: "bare unc share keeps its separator", path: "src/app.ts", root: `\\server\share`, want: `\\server\share\src\app.ts`},+ {name: "unc share with trailing separator", path: "src/app.ts", root: `\\server\share\`, want: `\\server\share\src\app.ts`},+ {name: "bare server keeps its separator", path: "src/app.ts", root: `\\server`, want: `\\server\src\app.ts`},+ // A workspace root of "C:" means that drive's root, not a path relative to its working+ // directory, so the result is rooted rather than the drive-relative "C:src\app.ts".+ {name: "bare drive root is rooted", path: "src/app.ts", root: "C:", want: `C:\src\app.ts`},+ {name: "forward slash unc share keeps its separator", path: "src/app.ts", root: "//server/share", want: "//server/share/src/app.ts"},{name: "dotdot segments are collapsed", path: "../../.ssh/id_rsa", root: "/home/u/proj", want: "/home/.ssh/id_rsa"},{name: "single dot segments are collapsed", path: "./src/./app.ts", root: "/repo", want: "/repo/src/app.ts"},