Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(store): a gitconfig URL rewrite no longer fails studio setup

0xken159572b291e2df
diff --git a/store/agents/ableton-ai/toolchain/studio_fetch.py b/store/agents/ableton-ai/toolchain/studio_fetch.py
index 7b7d2613a..8c0e00250 100644
--- a/store/agents/ableton-ai/toolchain/studio_fetch.py
+++ b/store/agents/ableton-ai/toolchain/studio_fetch.py
@@ -27,7 +27,14 @@ def fetch_sources(root):
git("remote", "add", "origin", source["url"])
if source.get("sparse"):
git("sparse-checkout", "init", "--cone")
- if git("remote", "get-url", "origin") != source["url"]:
+ # The URL as stored, not `remote get-url`: that answers with any `url.<base>.insteadOf`
+ # rewrite applied, and a machine that sends GitHub over SSH would read its own pin as a
+ # foreign remote. Fetching below still takes the rewrite, as the person configured.
+ try:
+ origin = git("config", "--get", "remote.origin.url")
+ except subprocess.CalledProcessError:
+ origin = "" # a checkout with no origin at all is not ours either
+ if origin != source["url"]:
raise SystemExit(f"Unexpected upstream remote in {target}")
try:
current = git("rev-parse", "--verify", "HEAD", quiet=True)
diff --git a/store/agents/autoresearch-mlx/toolchain/studio_fetch.py b/store/agents/autoresearch-mlx/toolchain/studio_fetch.py
index 7b7d2613a..8c0e00250 100644
--- a/store/agents/autoresearch-mlx/toolchain/studio_fetch.py
+++ b/store/agents/autoresearch-mlx/toolchain/studio_fetch.py
@@ -27,7 +27,14 @@ def fetch_sources(root):
git("remote", "add", "origin", source["url"])
if source.get("sparse"):
git("sparse-checkout", "init", "--cone")
- if git("remote", "get-url", "origin") != source["url"]:
+ # The URL as stored, not `remote get-url`: that answers with any `url.<base>.insteadOf`
+ # rewrite applied, and a machine that sends GitHub over SSH would read its own pin as a
+ # foreign remote. Fetching below still takes the rewrite, as the person configured.
+ try:
+ origin = git("config", "--get", "remote.origin.url")
+ except subprocess.CalledProcessError:
+ origin = "" # a checkout with no origin at all is not ours either
+ if origin != source["url"]:
raise SystemExit(f"Unexpected upstream remote in {target}")
try:
current = git("rev-parse", "--verify", "HEAD", quiet=True)
diff --git a/store/agents/bonsai-mcp/toolchain/studio_fetch.py b/store/agents/bonsai-mcp/toolchain/studio_fetch.py
index 7b7d2613a..8c0e00250 100644
--- a/store/agents/bonsai-mcp/toolchain/studio_fetch.py
+++ b/store/agents/bonsai-mcp/toolchain/studio_fetch.py
@@ -27,7 +27,14 @@ def fetch_sources(root):
git("remote", "add", "origin", source["url"])
if source.get("sparse"):
git("sparse-checkout", "init", "--cone")
- if git("remote", "get-url", "origin") != source["url"]:
+ # The URL as stored, not `remote get-url`: that answers with any `url.<base>.insteadOf`
+ # rewrite applied, and a machine that sends GitHub over SSH would read its own pin as a
+ # foreign remote. Fetching below still takes the rewrite, as the person configured.
+ try:
+ origin = git("config", "--get", "remote.origin.url")
+ except subprocess.CalledProcessError:
+ origin = "" # a checkout with no origin at all is not ours either
+ if origin != source["url"]:
raise SystemExit(f"Unexpected upstream remote in {target}")
try:
current = git("rev-parse", "--verify", "HEAD", quiet=True)
diff --git a/store/agents/comfy-mcp/toolchain/studio_fetch.py b/store/agents/comfy-mcp/toolchain/studio_fetch.py
index 7b7d2613a..8c0e00250 100644
--- a/store/agents/comfy-mcp/toolchain/studio_fetch.py
+++ b/store/agents/comfy-mcp/toolchain/studio_fetch.py
@@ -27,7 +27,14 @@ def fetch_sources(root):
git("remote", "add", "origin", source["url"])
if source.get("sparse"):
git("sparse-checkout", "init", "--cone")
- if git("remote", "get-url", "origin") != source["url"]:
+ # The URL as stored, not `remote get-url`: that answers with any `url.<base>.insteadOf`
+ # rewrite applied, and a machine that sends GitHub over SSH would read its own pin as a
+ # foreign remote. Fetching below still takes the rewrite, as the person configured.
+ try:
+ origin = git("config", "--get", "remote.origin.url")
+ except subprocess.CalledProcessError:
+ origin = "" # a checkout with no origin at all is not ours either
+ if origin != source["url"]:
raise SystemExit(f"Unexpected upstream remote in {target}")
try:
current = git("rev-parse", "--verify", "HEAD", quiet=True)
diff --git a/store/agents/dimos/toolchain/studio_fetch.py b/store/agents/dimos/toolchain/studio_fetch.py
index 7b7d2613a..8c0e00250 100644
--- a/store/agents/dimos/toolchain/studio_fetch.py
+++ b/store/agents/dimos/toolchain/studio_fetch.py
@@ -27,7 +27,14 @@ def fetch_sources(root):
git("remote", "add", "origin", source["url"])
if source.get("sparse"):
git("sparse-checkout", "init", "--cone")
- if git("remote", "get-url", "origin") != source["url"]:
+ # The URL as stored, not `remote get-url`: that answers with any `url.<base>.insteadOf`
+ # rewrite applied, and a machine that sends GitHub over SSH would read its own pin as a
+ # foreign remote. Fetching below still takes the rewrite, as the person configured.
+ try:
+ origin = git("config", "--get", "remote.origin.url")
+ except subprocess.CalledProcessError:
+ origin = "" # a checkout with no origin at all is not ours either
+ if origin != source["url"]:
raise SystemExit(f"Unexpected upstream remote in {target}")
try:
current = git("rev-parse", "--verify", "HEAD", quiet=True)
diff --git a/store/agents/foam-agent/toolchain/studio_fetch.py b/store/agents/foam-agent/toolchain/studio_fetch.py
index 7b7d2613a..8c0e00250 100644
--- a/store/agents/foam-agent/toolchain/studio_fetch.py
+++ b/store/agents/foam-agent/toolchain/studio_fetch.py
@@ -27,7 +27,14 @@ def fetch_sources(root):
git("remote", "add", "origin", source["url"])
if source.get("sparse"):
git("sparse-checkout", "init", "--cone")
- if git("remote", "get-url", "origin") != source["url"]:
+ # The URL as stored, not `remote get-url`: that answers with any `url.<base>.insteadOf`
+ # rewrite applied, and a machine that sends GitHub over SSH would read its own pin as a
+ # foreign remote. Fetching below still takes the rewrite, as the person configured.
+ try:
+ origin = git("config", "--get", "remote.origin.url")
+ except subprocess.CalledProcessError:
+ origin = "" # a checkout with no origin at all is not ours either
+ if origin != source["url"]:
raise SystemExit(f"Unexpected upstream remote in {target}")
try:
current = git("rev-parse", "--verify", "HEAD", quiet=True)
diff --git a/store/agents/juce-agent-toolkit/toolchain/studio_fetch.py b/store/agents/juce-agent-toolkit/toolchain/studio_fetch.py
index 7b7d2613a..8c0e00250 100644
--- a/store/agents/juce-agent-toolkit/toolchain/studio_fetch.py
+++ b/store/agents/juce-agent-toolkit/toolchain/studio_fetch.py
@@ -27,7 +27,14 @@ def fetch_sources(root):
git("remote", "add", "origin", source["url"])
if source.get("sparse"):
git("sparse-checkout", "init", "--cone")
- if git("remote", "get-url", "origin") != source["url"]:
+ # The URL as stored, not `remote get-url`: that answers with any `url.<base>.insteadOf`
+ # rewrite applied, and a machine that sends GitHub over SSH would read its own pin as a
+ # foreign remote. Fetching below still takes the rewrite, as the person configured.
+ try:
+ origin = git("config", "--get", "remote.origin.url")
+ except subprocess.CalledProcessError:
+ origin = "" # a checkout with no origin at all is not ours either
+ if origin != source["url"]:
raise SystemExit(f"Unexpected upstream remote in {target}")
try:
current = git("rev-parse", "--verify", "HEAD", quiet=True)
diff --git a/store/agents/simskill/toolchain/studio_fetch.py b/store/agents/simskill/toolchain/studio_fetch.py
index 7b7d2613a..8c0e00250 100644
--- a/store/agents/simskill/toolchain/studio_fetch.py
+++ b/store/agents/simskill/toolchain/studio_fetch.py
@@ -27,7 +27,14 @@ def fetch_sources(root):
git("remote", "add", "origin", source["url"])
if source.get("sparse"):
git("sparse-checkout", "init", "--cone")
- if git("remote", "get-url", "origin") != source["url"]:
+ # The URL as stored, not `remote get-url`: that answers with any `url.<base>.insteadOf`
+ # rewrite applied, and a machine that sends GitHub over SSH would read its own pin as a
+ # foreign remote. Fetching below still takes the rewrite, as the person configured.
+ try:
+ origin = git("config", "--get", "remote.origin.url")
+ except subprocess.CalledProcessError:
+ origin = "" # a checkout with no origin at all is not ours either
+ if origin != source["url"]:
raise SystemExit(f"Unexpected upstream remote in {target}")
try:
current = git("rev-parse", "--verify", "HEAD", quiet=True)
diff --git a/store/tools/studio_fetch.py b/store/tools/studio_fetch.py
index 7b7d2613a..8c0e00250 100644
--- a/store/tools/studio_fetch.py
+++ b/store/tools/studio_fetch.py
@@ -27,7 +27,14 @@ def fetch_sources(root):
git("remote", "add", "origin", source["url"])
if source.get("sparse"):
git("sparse-checkout", "init", "--cone")
- if git("remote", "get-url", "origin") != source["url"]:
+ # The URL as stored, not `remote get-url`: that answers with any `url.<base>.insteadOf`
+ # rewrite applied, and a machine that sends GitHub over SSH would read its own pin as a
+ # foreign remote. Fetching below still takes the rewrite, as the person configured.
+ try:
+ origin = git("config", "--get", "remote.origin.url")
+ except subprocess.CalledProcessError:
+ origin = "" # a checkout with no origin at all is not ours either
+ if origin != source["url"]:
raise SystemExit(f"Unexpected upstream remote in {target}")
try:
current = git("rev-parse", "--verify", "HEAD", quiet=True)
diff --git a/store/tools/test_studio_fetch.py b/store/tools/test_studio_fetch.py
new file mode 100644
index 000000000..3496f77dc
--- /dev/null
+++ b/store/tools/test_studio_fetch.py
@@ -0,0 +1,85 @@
+"""studio_fetch.py against real git, with no network: the pinned "upstream" is a local repository the
+test's own gitconfig reaches through `url.<base>.insteadOf`, the way a machine that sends GitHub over
+SSH reaches github.com:
+
+ python3 -m unittest store/tools/test_studio_fetch.py
+
+The developer's own gitconfig is never read (signing, hooks and rewrites there would change what runs).
+"""
+import json, os, subprocess, sys, tempfile, unittest
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+import studio_fetch # noqa: E402
+
+PINNED_URL = "https://github.com/example/upstream.git"
+
+
+def run(*args, cwd=None):
+ return subprocess.check_output(list(args), cwd=cwd, text=True, stderr=subprocess.DEVNULL).strip()
+
+
+class FetchSources(unittest.TestCase):
+ def setUp(self):
+ workspace = tempfile.TemporaryDirectory()
+ self.addCleanup(workspace.cleanup)
+ self.tmp = Path(workspace.name)
+ upstream = self.tmp / "upstream-src"
+ # Isolated first, before any git runs: a gitconfig of the test's own that rewrites the pinned
+ # https URL, as `url."[email protected]:".insteadOf https://github.com/` does on a real machine.
+ gitconfig = self.tmp / "gitconfig"
+ gitconfig.write_text(f'[url "file://{upstream}"]\n\tinsteadOf = {PINNED_URL}\n')
+ saved = dict(os.environ)
+ self.addCleanup(lambda: (os.environ.clear(), os.environ.update(saved)))
+ os.environ.update({"GIT_CONFIG_GLOBAL": str(gitconfig), "GIT_CONFIG_NOSYSTEM": "1"})
+ # The pinned upstream: one commit, servable by sha.
+ upstream.mkdir()
+ run("git", "init", "-q", cwd=upstream)
+ (upstream / "src").mkdir()
+ (upstream / "src" / "tool.py").write_text("print('hi')\n")
+ (upstream / "README.md").write_text("outside the sparse cone\n")
+ run("git", "add", ".", cwd=upstream)
+ run("git", "-c", "user.name=t", "-c", "user.email=t@t", "commit", "-qm", "pin", cwd=upstream)
+ run("git", "config", "uploadpack.allowAnySHA1InWant", "true", cwd=upstream)
+ run("git", "config", "uploadpack.allowFilter", "true", cwd=upstream)
+ self.commit = run("git", "rev-parse", "HEAD", cwd=upstream)
+ self.package = self.tmp / "package"
+ self.package.mkdir()
+ (self.package / "upstream.lock.json").write_text(json.dumps([{
+ "name": "Upstream", "url": PINNED_URL, "commit": self.commit,
+ "directory": "upstream", "sparse": ["src"],
+ }]))
+ self.target = self.package / "upstream"
+
+ # 2026-10-06: Comfy MCP and Ableton AI failed setup with "Unexpected upstream remote" on a Mac
+ # whose ~/.gitconfig sends https://github.com/ over SSH — `git remote get-url` reported the
+ # rewritten URL, not the pinned one the script had itself just added.
+ def test_a_url_rewrite_in_gitconfig_is_not_a_foreign_remote(self):
+ self.assertTrue(
+ run("git", "ls-remote", "--get-url", PINNED_URL).startswith("file://"),
+ "the fixture must really rewrite the pinned URL",
+ )
+ studio_fetch.fetch_sources(self.package)
+ self.assertEqual(run("git", "-C", str(self.target), "rev-parse", "HEAD"), self.commit)
+ self.assertTrue((self.target / "src" / "tool.py").exists())
+ # Running again over the checkout it made is a no-op, not a refusal.
+ studio_fetch.fetch_sources(self.package)
+
+ def test_a_remote_that_really_points_elsewhere_is_still_refused(self):
+ self.target.mkdir()
+ run("git", "init", "-q", cwd=self.target)
+ run("git", "remote", "add", "origin", "https://github.com/someone-else/upstream.git", cwd=self.target)
+ with self.assertRaises(SystemExit) as refused:
+ studio_fetch.fetch_sources(self.package)
+ self.assertIn("Unexpected upstream remote", str(refused.exception))
+
+ def test_a_checkout_with_no_origin_is_refused_by_name_not_by_traceback(self):
+ self.target.mkdir()
+ run("git", "init", "-q", cwd=self.target)
+ with self.assertRaises(SystemExit) as refused:
+ studio_fetch.fetch_sources(self.package)
+ self.assertIn("Unexpected upstream remote", str(refused.exception))
+
+
+if __name__ == "__main__":
+ unittest.main()