Skip to content

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

Send only network git remotes from beacon share

Claudea4b948901694
diff --git a/cli/beacon/cmd/share.go b/cli/beacon/cmd/share.go
index d22b1387..67c067f1 100644
--- a/cli/beacon/cmd/share.go
+++ b/cli/beacon/cmd/share.go
@@ -20,7 +20,6 @@ import (
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/lifecycle"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/schema"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/writer"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/gitlink"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/handoff"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/tokens"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/version"
@@ -598,7 +597,7 @@ func buildSharePayload(subject shareSubject) (sharePayload, error) {
trace.GitBranch = asymptoteobserve.ShareBranch(session.Branch)
}
if trace.GitRemoteURL == "" && session.Directory != "" {
- trace.GitRemoteURL = gitlink.SanitizeRemoteURL(shareGitRemote(session.Directory))
+ trace.GitRemoteURL = asymptoteobserve.ShareRemoteURL(shareGitRemote(session.Directory))
if trace.ProjectName == "" || trace.ProjectName == filepath.Base(session.Directory) {
if name := strings.TrimSuffix(lastURLSegment(trace.GitRemoteURL), ".git"); name != "" {
trace.ProjectName = name
diff --git a/cli/beacon/cmd/share_test.go b/cli/beacon/cmd/share_test.go
index a197be5e..2cc6db49 100644
--- a/cli/beacon/cmd/share_test.go
+++ b/cli/beacon/cmd/share_test.go
@@ -464,3 +464,26 @@ func TestShareRefreshParsesExternalIDs(t *testing.T) {
t.Fatalf("unknown last id should resend everything: %+v", got)
}
}
+
+func TestShareLeavesALocalGitRemoteOut(t *testing.T) {
+ env := newShareEnv(t)
+ for _, remote := range []string{filepath.Join(env.home, "mirrors", "app.git"), "file://" + filepath.Join(env.home, "mirrors", "app.git")} {
+ shareGitRemote = func(string) string { return remote }
+ stdout, _, err := runShareCommand(t, "--cwd", env.projectDir, "--print", "--log-path", env.logPath)
+ if err != nil {
+ t.Fatalf("share --print: %v", err)
+ }
+ var payload sharePayload
+ if err := json.Unmarshal([]byte(stdout), &payload); err != nil {
+ t.Fatal(err)
+ }
+ if payload.Trace.GitRemoteURL != "" || strings.Contains(stdout, env.home) {
+ t.Fatalf("remote %q leaked into the payload: %+v", remote, payload.Trace)
+ }
+ }
+ shareGitRemote = func(string) string { return "https://[email protected]/acme/app.git" }
+ stdout, _, err := runShareCommand(t, "--cwd", env.projectDir, "--print", "--log-path", env.logPath)
+ if err != nil || !strings.Contains(stdout, `"git_remote_url": "https://github.com/acme/app.git"`) {
+ t.Fatalf("network remote: err=%v\n%s", err, stdout)
+ }
+}