Skip to content

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

handoff: resolve relative store directories before listing

Claude92872f57c15b
diff --git a/cli/beacon/cmd/handoff.go b/cli/beacon/cmd/handoff.go
index a286dfb7..fa0d9c8c 100644
--- a/cli/beacon/cmd/handoff.go
+++ b/cli/beacon/cmd/handoff.go
@@ -345,6 +345,15 @@ func handoffStoreDirs() (handoff.StoreDirs, error) {
dirs[harness] = dir
}
}
+ // Session file paths come from these directories, and a runtime is started in the session's
+ // own directory, so a relative store path would name another file there.
+ for harness, dir := range dirs {
+ abs, err := filepath.Abs(dir)
+ if err != nil {
+ return nil, fmt.Errorf("resolve the %s store directory %s: %w", harness, dir, err)
+ }
+ dirs[harness] = abs
+ }
return dirs, nil
}
diff --git a/cli/beacon/cmd/handoff_test.go b/cli/beacon/cmd/handoff_test.go
index e313584b..a8f76824 100644
--- a/cli/beacon/cmd/handoff_test.go
+++ b/cli/beacon/cmd/handoff_test.go
@@ -242,22 +242,39 @@ func TestHandoffListPassesStoreDirectories(t *testing.T) {
if _, _, err := runHandoff(t, "list", "--claude-projects-dir", "/c", "--codex-dir", "/x", "--opencode-dir", "/o", "--cline-dir", "/l"); err != nil {
t.Fatal(err)
}
- want := handoff.StoreDirs{handoff.HarnessClaude: "/c", handoff.HarnessCodex: "/x", handoff.HarnessOpenCode: "/o", handoff.HarnessCline: "/l"}
+ want := handoff.StoreDirs{handoff.HarnessClaude: absPath(t, "/c"), handoff.HarnessCodex: absPath(t, "/x"), handoff.HarnessOpenCode: absPath(t, "/o"), handoff.HarnessCline: absPath(t, "/l")}
if !reflect.DeepEqual(*seen, want) {
t.Fatalf("store dirs = %+v, want %+v", *seen, want)
}
}
+func absPath(t *testing.T, path string) string {
+ t.Helper()
+ abs, err := filepath.Abs(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return abs
+}
+
func TestHandoffStoreDirFlag(t *testing.T) {
seen := stubHandoffSources(t)
// --store-dir takes any name the runtime answers to; a per-runtime flag wins for its runtime.
if _, _, err := runHandoff(t, "list", "--store-dir", "claude-code=/generic", "--store-dir", "codex=/x=y", "--claude-projects-dir", "/c"); err != nil {
t.Fatal(err)
}
- want := handoff.StoreDirs{handoff.HarnessClaude: "/c", handoff.HarnessCodex: "/x=y"}
+ want := handoff.StoreDirs{handoff.HarnessClaude: absPath(t, "/c"), handoff.HarnessCodex: absPath(t, "/x=y")}
if !reflect.DeepEqual(*seen, want) {
t.Fatalf("store dirs = %+v, want %+v", *seen, want)
}
+ // A relative store directory is resolved here, not in the session's directory the runtime
+ // starts in.
+ if _, _, err := runHandoff(t, "list", "--store-dir", "codex=rel/codex"); err != nil {
+ t.Fatal(err)
+ }
+ if got := (*seen)[handoff.HarnessCodex]; got != absPath(t, "rel/codex") || !filepath.IsAbs(got) {
+ t.Fatalf("relative store dir = %q, want it made absolute", got)
+ }
for _, bad := range []string{"claude", "=/x", "claude=", "no-such-runtime=/x"} {
if _, _, err := runHandoff(t, "list", "--store-dir", bad); err == nil || !strings.Contains(err.Error(), "--store-dir") {
t.Fatalf("--store-dir %q: err = %v", bad, err)