Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Rewrite home and session paths inside file:// URLs

Claudeecec4738d9f1
diff --git a/pkg/asymptoteobserve/share.go b/pkg/asymptoteobserve/share.go
index 630320b4..6d664d8e 100644
--- a/pkg/asymptoteobserve/share.go
+++ b/pkg/asymptoteobserve/share.go
@@ -1280,7 +1280,8 @@ func replacePathPrefix(value, prefix, repl string) string {
end := i + len(prefix)
consumed := len(value) - len(rest)
before := consumed + i
- if (before == 0 || !continuesPath(value[before-1], true)) &&
+ // A URL's "://" is not a parent directory: file:///Users/al is the path /Users/al.
+ if (before == 0 || !continuesPath(value[before-1], true) || strings.HasSuffix(value[:before], "://")) &&
(end == len(rest) || !continuesPath(rest[end], false) || endsSentence(rest[end:])) {
b.WriteString(rest[:i])
b.WriteString(repl)
diff --git a/pkg/asymptoteobserve/share_test.go b/pkg/asymptoteobserve/share_test.go
index 0acd83a9..32040d4b 100644
--- a/pkg/asymptoteobserve/share_test.go
+++ b/pkg/asymptoteobserve/share_test.go
@@ -491,6 +491,8 @@ func TestPathScrubberReplacesWholePathsOnly(t *testing.T) {
"/srv/home/al/x": "/srv/home/al/x",
"open /home/al, then /home/al.": "open ~, then ~.",
"/home/al/src/proj/x": "~/src/proj/x",
+ "file:///home/al/notes.txt": "file://~/notes.txt",
+ "file:///home/alex/notes.txt": "file:///home/alex/notes.txt",
}
for in, want := range cases {
if got := s.text(in); got != want {