loop: replace sketch-host remote with origin remote in agent.Init()

Change git remote handling in agent initialization to replace any existing
origin remote with the provided git remote URL instead of creating a
sketch-host remote.

Problem Analysis:
Previously, when a git remote URL was provided to the agent, it would:
1. Add a new remote called 'sketch-host' pointing to the provided URL
2. Configure additional fetch refs for feature branches
3. Use 'sketch-host' for all fetch operations

This created confusion and inconsistency since most git workflows expect
to interact with 'origin' as the primary remote, not a custom 'sketch-host'
remote.

Implementation Changes:

1. Git Remote Setup Logic:
   - Remove existing 'origin' remote if it exists (ignoring errors if not present)
   - Add the provided remote URL as the new 'origin' remote
   - Update fetch operations to use 'origin' instead of 'sketch-host'

2. Branch Detection Logic:
   - Updated branchExists() function to remove 'refs/remotes/sketch-host/' reference
   - Now only checks 'refs/heads/' and 'refs/remotes/origin/' for branch existence

3. Comment Updates:
   - Updated git debugging comment in dockerimg/githttp.go to reference 'origin' instead of 'sketch-host'

Technical Details:
- The 'git remote remove origin' command gracefully handles the case where
  origin doesn't exist by logging and continuing
- All existing git operations (fetch, checkout, commit tracking) continue
  to work seamlessly with the origin remote
- branchExists() function correctly identifies branches in origin remotes

Benefits:
- Consistent with standard git workflows that use 'origin' as primary remote
- Eliminates confusion about which remote to use for git operations
- Maintains all existing functionality while using standard git conventions
- Simplifies git operations by using the expected 'origin' remote name
- Better integration with external git tools and workflows

Testing:
- All existing loop package tests continue to pass
- Verified git fetch, config, and branch detection work correctly
- Integration testing confirms seamless operation with origin remote

This change provides a more intuitive and standard git remote configuration
while preserving all agent functionality and improving compatibility with
standard git workflows.

Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s9edcdfe5bae3ef4ek
diff --git a/loop/agent.go b/loop/agent.go
index a09c405..c369603 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -1005,24 +1005,25 @@
 	ctx := a.config.Context
 	slog.InfoContext(ctx, "agent initializing")
 
-	// If a remote git addr was specified, we configure the remote
+	// If a remote git addr was specified, we configure the origin remote
 	if a.gitState.gitRemoteAddr != "" {
 		slog.InfoContext(ctx, "Configuring git remote", slog.String("remote", a.gitState.gitRemoteAddr))
-		cmd := exec.CommandContext(ctx, "git", "remote", "add", "sketch-host", a.gitState.gitRemoteAddr)
+
+		// Remove existing origin remote if it exists
+		cmd := exec.CommandContext(ctx, "git", "remote", "remove", "origin")
 		cmd.Dir = a.workingDir
 		if out, err := cmd.CombinedOutput(); err != nil {
-			return fmt.Errorf("git remote add: %s: %v", out, err)
+			// Ignore error if origin doesn't exist
+			slog.DebugContext(ctx, "git remote remove origin (ignoring if not exists)", slog.String("output", string(out)))
 		}
-		// sketch-host is a git repo hosted by "outtie sketch". When it notices a 'git fetch',
-		// it runs "git fetch" underneath the covers to get its latest commits. By configuring
-		// an additional remote.sketch-host.fetch, we make "origin/main" on innie sketch look like
-		// origin/main on outtie sketch, which should make it easier to rebase.
-		cmd = exec.CommandContext(ctx, "git", "config", "--add", "remote.sketch-host.fetch",
-			"+refs/heads/feature/*:refs/remotes/origin/feature/*")
+
+		// Add the new remote as origin
+		cmd = exec.CommandContext(ctx, "git", "remote", "add", "origin", a.gitState.gitRemoteAddr)
 		cmd.Dir = a.workingDir
 		if out, err := cmd.CombinedOutput(); err != nil {
-			return fmt.Errorf("git config --add: %s: %v", out, err)
+			return fmt.Errorf("git remote add origin: %s: %v", out, err)
 		}
+
 	}
 
 	// If a commit was specified, we fetch and reset to it.
@@ -1034,7 +1035,7 @@
 		if out, err := cmd.CombinedOutput(); err != nil {
 			return fmt.Errorf("git stash: %s: %v", out, err)
 		}
-		cmd = exec.CommandContext(ctx, "git", "fetch", "--prune", "sketch-host")
+		cmd = exec.CommandContext(ctx, "git", "fetch", "--prune", "origin")
 		cmd.Dir = a.workingDir
 		if out, err := cmd.CombinedOutput(); err != nil {
 			return fmt.Errorf("git fetch: %s: %w", out, err)
@@ -1247,7 +1248,6 @@
 	refs := []string{
 		"refs/heads/",
 		"refs/remotes/origin/",
-		"refs/remotes/sketch-host/",
 	}
 	for _, ref := range refs {
 		cmd := exec.Command("git", "show-ref", "--verify", "--quiet", ref+branchName)