Add Entire Repo Clone Command

Claude Code·Opus 4.8[1m]·toothbrush·3mo ago·79hr 45min·12 Checkpoints·47 file changes·+1228/-87·583.9K tokens

add a command: entire repo clone /gh/entirehq/entire-api, which checks if there's an existing mirror of that repo. if there's only one cell, do the git clone. if it's available in more than one cell, it lets you select in the same interactive way entire repo mirror create does today. it should also allow an optional positional argument target directory. pass that argument through to the git clone call.

3mo ago·6m

Done. Added entire repo clone <repo> [target-dir].

What it does:

  • Parses /gh/<owner>/<repo> (leading slash optional, owner/repo lowercased, same charset guards as mirror create).
  • Lists mirror placements of that repo via the control plane (server-side provider+owner filter, client-side repo match).
  • 0 mirrors → error pointing at entire repo mirror create.
  • 1 cell → clones immediately.
  • >1 cell → interactive huh picker (cell · jurisdiction · host), same style as mirror create.
  • Optional [target-dir] passed straight through to git clone entire://<host>/gh/<owner>/<repo> [target-dir].

Tradeoffs / notes:

  • Non-interactive + multiple cells: errors with a --cluster <host> pointer rather than hanging. Added a --cluster flag for scripting/disambiguation.
  • Picker is single-select (you clone from one cell), not multi-select like create.
  • Doesn't filter by mirror status — a suspended/processing placement is still offered; git clone surfaces the failure. Easy to tighten later if you want only ready cells listed.

Wired into the hidden repo group (repo.go). Tests cover ref parsing, cell labels, target selection (single/dedupe/--cluster match+miss/non-interactive), and the client-side repo filter. mise run fmt && lint clean; full cmd/entire/cli suite passes.

Not committed/pushed — yours to review first.

commit.

3mo ago·19.0s

Committed as 69c03282a on shimmying-gliding-mitten. Not pushed.

actually can we make an alias entire clone ... that calls the same code?

3mo ago·3m

This is exactly the --fix autofix trap from memory — it stripped a needed //nolint:ireturn directive. Let me discard that unrelated change:

wait wait wait we sorted d //nolint:ireturn out a while ago, do we need to whitelist anything more in @.golangci.yaml ?

3mo ago·1m

Now lint — but --fix will likely strip that agentimport.go nolint again, so I'll restore it right after:

no the actual correct fix is to add agentimport.Importer to the golanglint allowlist, if we cannot fix it.

3mo ago·2m

Done. Committed as e2f38a981.

What landed:

  • entire clone <repo> [target-dir] — top-level alias, visible in root help, same code as entire repo clone (fresh command instance since cobra forbids one command under two parents; carries --json/--insecure-http-auth persistent flags the repo group otherwise supplies).
  • Lint fix done right: moved agentimport.Importer's ireturn suppression from a per-line //nolint into the .golangci.yaml allowlist, and removed the directive. The per-line form was being repeatedly stripped by mise run lint's --fix, which then tripped CI (no --fix). Allowlisting is stable against that.

Two commits on shimmying-gliding-mitten, not pushed:

  • 69c03282a — repo clone command
  • e2f38a981 — top-level alias + lint fix

this didn't work:

$ entire repo clone /gh/entirehq/entire-api "$(mktemp -d)" --cluster royalcanin.partial.to repo is not mirrored on "royalcanin.partial.to"; available: aws-eu-central-1.entire.io, aws-us-east-2.entire.io

the reason is that royalcanin.partial.to is owned by another entire auth contexts than the currently-active one. when a user specifies a literal --cluster, we should use the existing context-resolving machinery to make sure we don't fail unnecessarily

3mo ago·3m

Fixed and committed as ec0e50427.

Root cause: the clone always listed mirrors against the active context's core. A --cluster in another federation (like royalcanin.partial.to) is invisible there → "not mirrored on …".

Fix: when --cluster is given, dial the core fronting that cluster via coreapi.NewForCluster (well-known discovery + matching local context) — the same routing mirror create <url> [cluster] uses — so the lookup hits the right federation. No --cluster still lists from the active context. Also added up-front validateClusterHost on the user-supplied value (anti-token-leak guard, since it flows into the STS audience and clone URL).

Tests: cross-context routing needs network so isn't unit-tested, but added TestRepoClone_InvalidClusterFlag pinning the early validation. Lint clean; full cmd/entire/cli suite passes.

Three commits on shimmying-gliding-mitten, not pushed:

  • 69c03282a — repo clone command
  • e2f38a981 — entire clone alias + ireturn allowlist fix
  • ec0e50427 — cross-context --cluster resolution

Worth verifying against the real royalcanin.partial.to mirror when you get a chance — that's the path the unit tests can't exercise.

push and open a PR, short user-impact description

3mo ago·3m

Done.

PR: https://github.com/entireio/cli/pull/1529 (pushed, includes the fix).

Ctrl+C bug fixed: the picker cancellation returned a zero-value mirror with a nil error, so clone fell through to git clone entire:///gh/... (empty host). Now a cancelled picker is a silent abort — it just prints "Clone cancelled." and exits cleanly, no git invocation.

Lint clean, tests pass. Commit 25cb1b899 pushed to the branch.

3mo ago·1m

Both review items handled:

  • Cancel still runs git clone (High) — already fixed in 25cb1b899; the bot reviewed the earlier commit ec0e504. A cancelled picker now returns a SilentError, so runGitClone is never reached.
  • Flag help exposes internal "core" (Low) — reworded --cluster help to "(may belong to another auth context)", dropping the internal term. Pushed as e3b058c91.

Lint clean, tests pass. PR #1529 updated.

oh no more review comments.

3mo ago·4m

All review fixes are committed locally (3614bbf33), but the push is blocked by a persistent HTTP 503 from the entire:// remote's OAuth token-exchange — a server-side outage on the push path, not anything in our change. Five retries with backoff all failed identically.

Bottom line:

  • Review items fixed and committed — ready to go.
  • Push blocked by a transient 503 on the token-exchange service (royalcanin.partial.to). Nothing to fix on our end; it needs the service to recover.

What I changed (commit 3614bbf33):

  • Parse error now says "expected gh/<owner>/<repo> (leading slash optional)".
  • Self-contained mirrorCloneProviderGitHub const (dropped the checkpoint-named borrow).
  • Not-found hint uses canonical /gh/<owner>/<repo>.
  • validateClusterHost now also guards the server-provided host before building the clone URL.
  • Updated the repo group doc comment to reflect that clone now lives there.
  • (The two cursor bot items were already fixed in earlier commits.)

Want me to keep retrying the push on a short interval until it succeeds, or will you re-run git push once the service is back?

This should work:

$ entire clone entire://aws-us-east-2.entire.io/gh/entirehq/entire-api "$(mktemp -d)" -- invalid <repo>: expected gh/<owner>/<repo> (leading slash optional), got "entire://aws-us-east-2.entire.io/gh/entirehq/entire-api"

12:53:08 (git) shimmying-glidi...▲ ↑1 $ entire clone entire://aws-us-east-2.entire.io/et/paul-test/paul-test-repo invalid <repo>: expected gh/<owner>/<repo> (leading slash optional), got "entire://aws-us-east-2.entire.io/et/paul-test/paul-test-repo"

12:52:17 (git) shimmying-glidi...▲ ↑1 $ entire clone /et/paul-test/paul-test-repo invalid <repo>: expected gh/<owner>/<repo> (leading slash optional), got "/et/paul-test/paul-test-repo"

3mo ago·33.9s

The command should accept full entire:// URLs and the et provider too, not just bare /gh/.... Let me understand the URL scheme first — what et vs gh mean and how git-remote-entire parses paths.

actually, let's for now focus on accepting entire:// ... (just pass that through verbatim because it includes the --cluster value) and the /gh/... shorthand.

3mo ago·3m

Done locally, but the push is still blocked by the same persistent HTTP 503 on the entire:// remote's OAuth token-exchange — now across ~15 retries spanning both commits. It's a server-side outage on royalcanin.partial.to's push path, unrelated to the code.

Committed locally, ready to push (2 commits queued):

  • 3614bbf33 — earlier review nits
  • c7616466f — accept full entire:// clone URLs verbatim

The new behavior (verified by smoke test — it now invokes real git clone instead of erroring):

  • entire clone entire://aws-us-east-2.entire.io/gh/entirehq/entire-api [dir] → passed straight through, no lookup, --cluster ignored.
  • entire clone /gh/<owner>/<repo> → unchanged (lookup + cluster resolution).

et provider deferred as you asked.

Want me to keep retrying the push periodically until the token-exchange service recovers, or will you push once it's back up?

ok, close off all the review comments on https://github.com/entireio/cli/pull/1529 that we've addressed. brief message "fixed in <sha>."

3mo ago·54.6s

All 7 review comments closed off with "Fixed in <sha>.":

CommentFix
Cancel still runs git clone (cursor)25cb1b899
Flag help exposes internal core (cursor)e3b058c91
Error message non-slash form (Copilot)3614bbf33
checkpointProviderGitHub cross-file dep (Copilot)3614bbf33
Not-found message leading slash (Copilot)3614bbf33
Validate API-provided cluster host (Copilot)3614bbf33
repo group doc comment (Copilot)3614bbf33

Note: those SHAs (3614bbf33, plus c7616466f) are still local — the push is blocked by the ongoing token-exchange 503. The replies will resolve to clickable commits once the push lands.

Done — and the push went through this time.

  • Fix: trim the clone ref once up front (90109fc6b), so isEntireCloneURL and the value handed to git clone agree.
  • Replied "Fixed in 90109fc6b." on the comment.
  • Push succeeded — the token-exchange 503 cleared, so all queued commits (3614bbf33, c7616466f, 90109fc6b) are now on the branch and PR #1529 is up to date. The earlier "Fixed in <sha>" replies now resolve to real commits.

this is a fair point - can we make sure it's fixed everywhere we do a auth-context lookup/determinatino? https://github.com/entireio/cli/pull/1529#discussion_r3479116045

3mo ago·7m

Done — fixed at the right layer and pushed (cfc653d47).

The fix, in two places:

  1. The shared auth-context determination chokepoint — clusterdiscovery.ResolveContextForCluster / ResolveClusterCores now case-fold the cluster host. This is what the reviewer asked for ("everywhere we do auth-context lookup/determination"): every cluster-addressed flow routes through here — control-plane cluster commands (mirror create/remove/collaborators, clone --cluster) and the git/repo-token path. The cache key, /.well-known discovery, and cores→context selection are now all case-insensitive.
  2. selectCloneTarget — the clone-local --cluster map match the reviewer flagged, also case-folded (defensive against an API returning mixed-case hosts).

Audited and confirmed not affected: ResolveControlPlaneTarget (active context, not host-driven) and the clone URL itself (built from the API's canonical ClusterHost, not user input).

Tests added: TestResolve_ClusterHostCaseInsensitive (mixed-case resolves the same context + caches under the lowercased key) and a case-insensitive subtest in TestSelectCloneTarget. Lint clean, both packages pass. Replied on the thread with the SHA.

rebase this on origin/main for me please

2mo ago·5m

Rebase complete and verified. The branch is now 9 commits on top of origin/main (c457486ca), all replaying cleanly.

Conflicts resolved (both in the alias commit):

  • .golangci.yaml — main ditched the ireturn linter (ef481758b), so my allowlist addition was moot; took main's version. agentimport.go's //nolint:ireturn is correctly gone too.
  • root.go — main changed buildReviewDeps() to no-arg; kept that and re-added the newCloneAliasCmd() line.

Verified: go build ./... clean, mise run lint 0 issues (no stray --fix edits), cmd/entire/cli + clusterdiscovery tests pass.

Not pushed — per your usual workflow. Note the rebase rewrote already-pushed history, so updating the PR needs a force push:

Want me to run that, or will you?

yes, push please.

2mo ago·33.5s

Pushed. shimmying-gliding-mitten force-updated to the rebased history (cfc653d47 → d911b6670). PR #1529 now sits cleanly on top of current origin/main with the ireturn-removal conflict resolved.

remove the entire clone alias, this shall only be callable via entire repo clone ... - make the change and push

2mo ago·4m

Done — entire clone alias removed and pushed (ed8dad742).

  • Removed newCloneAliasCmd and its root registration; clone is now reachable only via entire repo clone.
  • Dropped the alias test; verified entire clone no longer resolves while entire repo clone works.
  • Build clean, lint 0 issues, clone tests pass. Pushed to the branch (regular push — no history rewrite this time).

more:

  1. Clone-URL synthesis is duplicated fmt.Sprintf("entire://%s/gh/%s/%s", ...) now appears in both repo_mirror.go:29 (mirrorRow) and the new repo_clone.go. Given this repo's explicit anti-duplication stance (CLAUDE.md, mise run dup), extract something like mirrorCloneURL(host, owner, repo) and use it in both spots.

  2. entireCloneURLScheme = "entire://" const is defined and used by isEntireCloneURL, but the URL builder uses a bare literal "entire://%s/..." rather than the const — minor inconsistency.

2mo ago·2m

Both addressed and pushed (5270dbf493):

  • Dedup (item 2): extracted mirrorCloneURL(host, owner, repo), now used by both mirrorRow (repo_mirror.go) and repo clone (repo_clone.go). Single source of truth for the wire format.
  • Const consistency (item 3): the helper builds from entireCloneURLScheme instead of a bare "entire://" literal.

Added TestMirrorCloneURL to lock the format. Build clean, lint 0 issues, tests pass.

here's another comment:

  1. entire:// passthrough skips validateClusterHost (repo_clone.go, isEntireCloneURL branch) The shorthand path validates the host on both the --cluster flag and the server-supplied chosen.ClusterHost (nice defense-in-depth, with a clear comment about the host@evil.com STS-audience token-leak vector). But a user-supplied full entire://<host>/gh/... URL is passed verbatim to git clone with no host validation. The same token-leak rationale the PR cites applies — entire://realcluster@evil.com/gh/... would sail through. It's arguably no worse than a raw git clone entire://…, so not critical, but it's inconsistent with the PR's own stated guard. Consider parsing the host out and running it through validateClusterHost.

I don't want any fixes for this, i WANT the url as the user typed it passed through to git cli. however, if there's a misleading comment or doc, we should fix that.

2mo ago·2m

Done — no behavior change, comment clarified and pushed (1fc19a0343).

  • Kept verbatim passthrough as you want.
  • Added a comment at the isEntireCloneURL branch stating the host is deliberately not run through validateClusterHost — it's a raw user-typed URL forwarded to git clone as-is (equivalent to git clone entire://…), and the guard only applies where we synthesize the URL from --cluster / an API host.
  • Checked the other two comments (the shorthand validateClusterHost note and the Long help) — both already accurately scoped, no over-claiming, left as-is.

Build clean, lint 0 issues.