fix(onboarding): run the connect ladder after the bootstrap publish step · Entire
fix(onboarding): run the connect ladder after the bootstrap publish step
a8272eb·
peyton-alt·yesterday·7 files·+146 added/-30 removed
On a bootstrapped enable (non-git dir), the connect ladder ran before the deferred publish phase — but that phase is what creates the origin remote and GitHub repo, so the mirror rung could only report 'couldn't check' and the mirror offer could never fire on the very first enable. The ladder now runs as its own 'Connecting to entire.io' step after 'Publishing to GitHub', and enable prints the closing 'Done.' after it.
Mirroring itself is untouched: same createAndAwaitMirror path, same 'entire repo mirror' commands — only when enable invokes the offer moves.
Also: a repo with no origin remote at all (local-only bootstrap) now reads 'no origin remote' (not applicable) instead of 'couldn't check' with a retry hint that could never resolve — gitremote gains an ErrRemoteNotFound sentinel (git remote get-url exit status 2) to make that state detectable.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Sessions
01KXNKX51KJ4C56AEYZV93VBQ0View transcript
[?
Fix Onboarding History and Scan Cache IssuesClaude Code·Fable 5·7 steps](/content/gh/entireio/cli/session/4c8ea8be-3447-426e-b8cb-07f2c8a04b71#timeline-01KXNKX51KJ4C56AEYZV93VBQ0/index.html)
Changes
7
cmd/entire/cli
gitremote
Mgitremote.go+10
Mgitremote_test.go+4/-1
Monboarding_rungs.go+6
Monboarding_rungs_test.go+24/-5
Msetup.go+37/-16
Msetup_github.go+3/-2
Msetup_test.go+62/-6
93 unmodified lines
94
95
96
97
98
99
100
101
102
103
104
105
2 unmodified lines
108
109
110
111
112
113
114
115
116
117
93 unmodified lines
return GetRemoteURLInDir(ctx, "", remoteName)
}
// ErrRemoteNotFound reports that the repository exists but has no remote with
// the requested name (git remote get-url exit status 2) — a settled state
// callers may treat as "nothing to resolve", unlike git failing for another
// reason (not a repository, canceled context, ...).
var ErrRemoteNotFound = errors.New("remote not found")
// GetRemoteURLInDir returns the URL configured for the named git remote in dir.
func GetRemoteURLInDir(ctx context.Context, dir, remoteName string) (string, error) {
cmd := exec.CommandContext(ctx, "git", "remote", "get-url", remoteName)
2 unmodified lines
output, err := cmd.Output()
if err != nil {
var exitErr *exec.ExitError
if errors.As(err, &exitErr) && exitErr.ExitCode() == 2 && ctx.Err() == nil {
return "", fmt.Errorf("remote %q: %w", remoteName, ErrRemoteNotFound)
}
return "", fmt.Errorf("remote %q not found", remoteName)
}
return strings.TrimSpace(string(output)), nil
}
Mcmd/entire/cli/gitremote/gitremote.go+10
248 unmodified lines
249
250
251
252
253
254
255
256
257
1 unmodified line
259
260
261
259
262
263
248 unmodified lines
}
}
// A repo without the requested remote must yield the ErrRemoteNotFound
// sentinel (git exit status 2), so callers can treat "no remote" as a settled
// state distinct from git failing for another reason.
// Not parallel: uses t.Chdir()
func TestResolveRemoteRepo_MissingRemote(t *testing.T) {
repoDir := t.TempDir()
t.Chdir(repoDir)
_, _, _, err := ResolveRemoteRepo(context.Background(), "origin")
assert.Error(t, err)
assert.ErrorIs(t, err, ErrRemoteNotFound)
}
Mcmd/entire/cli/gitremote/gitremote_test.go+4/-1
398 unmodified lines
399
400
401
402
403
404
405
406
407
408
409
410
398 unmodified lines
Title: "Repo mirrored",
Check: func(ctx context.Context) onboarding.Check {
forge, owner, repo, err := deps.resolveOrigin(ctx)
if errors.Is(err, gitremote.ErrRemoteNotFound) {
// No origin remote is a settled fact about the repo (a
// local-only bootstrap, say), not a failed check — render it
// like a non-GitHub origin instead of "couldn't check".
return onboarding.Check{State: onboarding.StateNotApplicable, Detail: "no origin remote"}
}
if err != nil {
// A resolution failure (git exec error, canceled context) is
// not the same fact as "this repo isn't on GitHub".
Mcmd/entire/cli/onboarding_rungs.go+6
13 unmodified lines
14
15
16
17
18
19
20
166 unmodified lines
187
188
189
189
190
191
192
193
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
13 unmodified lines
"github.com/go-git/go-git/v6/plumbing"
"github.com/entireio/cli/cmd/entire/cli/checkpoint"
"github.com/entireio/cli/cmd/entire/cli/gitremote"
"github.com/entireio/cli/cmd/entire/cli/onboarding"
"github.com/entireio/cli/cmd/entire/cli/testutil"
"github.com/entireio/cli/internal/coreapi"
166 unmodified lines
}
}
// gitremote returns a distinguishable "no remote" answer as (forge "", nil
// error) via empty forge with an error mentioning the missing remote; a repo
// genuinely without a GitHub origin is NotApplicable, but a resolution
// FAILURE (git exec error, canceled context) must not masquerade as a
// permanent "no GitHub origin".
// A repo with no origin remote at all (a local-only bootstrap, say) is a
// settled fact — the rung reads "no origin remote", not "couldn't check" with
// a retry hint that can never resolve anything.
func TestMirrorRung_NotApplicableWithoutAnyRemote(t *testing.T) {
t.Parallel()
deps := onboardingRungDeps{
resolveOrigin: func(context.Context) (forge, owner, repo string, err error) {
return "", "", "", fmt.Errorf("get remote URL for %q: %w", "origin", gitremote.ErrRemoteNotFound)
},
}
check := mirrorRung(deps).Check(context.Background())
if check.State != onboarding.StateNotApplicable {
t.Errorf("State = %v, want StateNotApplicable when there is no origin remote", check.State)
}
if check.Detail != "no origin remote" {
t.Errorf("Detail = %q, want %q", check.Detail, "no origin remote")
}
}
// A resolution FAILURE (git exec error, canceled context) must not masquerade
// as a permanent "no GitHub origin".
func TestMirrorRung_UnknownWhenOriginResolutionFails(t *testing.T) {
t.Parallel()
deps := onboardingRungDeps{
Mcmd/entire/cli/onboarding_rungs_test.go+24/-5
878 unmodified lines
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
434 unmodified lines
1335
1336
1337
1323
1324
1325
1326
1327
1328
1329
1330
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
593 unmodified lines
1945
1946
1947
1930
1931
1932
1933
1934
1935
1936
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
878 unmodified lines
}
if err := runGitHubBootstrapFinalize(ctx, cmd.OutOrStdout(), bootstrap); err != nil {
runErr = err
return
}
// The connect ladder runs only now, after finalize created
// the origin remote: probed any earlier, the mirror rung
// can only report "couldn't check" and the mirror offer
// can never fire on a first enable (the setup paths skip
// their in-flow ladder while a bootstrap is pending). A
// bootstrapped repo is always a first run; nil importScope
// means every agent whose hooks were just installed.
printBootstrapSection(cmd.OutOrStdout(), "Connecting to entire.io")
runEnableOnboarding(ctx, cmd.OutOrStdout(), enableOnboardingOpts{
assumeYes: opts.Yes,
neverPrompt: agentName != "",
firstRun: true,
})
fmt.Fprintln(cmd.OutOrStdout(), "\nDone.")
}()
}
434 unmodified lines
// Connect rungs (login, mirror, import): one consent prompt covering
// whatever is missing, then the setup checklist. Also the resume path —
// re-running enable re-offers only rungs that are still missing. Runs
// before the bootstrap early-return below: a just-bootstrapped repo is
// exactly where the login/mirror/import offers matter most.
runEnableOnboarding(ctx, w, enableOnboardingOpts{
assumeYes: opts.Yes,
firstRun: firstRun,
importScope: agents,
})
// re-running enable re-offers only rungs that are still missing. While a
// bootstrap is pending (SuppressDoneMessage) the ladder is deferred to
// the enable RunE, which runs it after the GitHub publish step so the
// mirror rung can see the origin remote the finalize creates.
if !opts.SuppressDoneMessage {
runEnableOnboarding(ctx, w, enableOnboardingOpts{
assumeYes: opts.Yes,
firstRun: firstRun,
importScope: agents,
})
}
if opts.SuppressDoneMessage {
// Bootstrap finalize will print its own completion summary after
593 unmodified lines
// documented as non-interactive, so prompting is always suppressed here;
// --yes additionally auto-imports on first run (local-only, scoped to the
targeted agent), matching the enable-time import contract. The
// checklist hints carry the rest. Runs before the bootstrap early-return
// so bootstrapped repos get the ladder too.
runEnableOnboarding(ctx, w, enableOnboardingOpts{
assumeYes: opts.Yes,
neverPrompt: true,
firstRun: firstRun,
importScope: []agent.Agent{ag},
})
// checklist hints carry the rest. While a bootstrap is pending
// (SuppressDoneMessage) the ladder is deferred to
// the enable RunE, after the GitHub publish step that creates the origin remote.
if !opts.SuppressDoneMessage {
runEnableOnboarding(ctx, w, enableOnboardingOpts{
assumeYes: opts.Yes,
neverPrompt: true,
firstRun: firstRun,
importScope: []agent.Agent{ag},
})
}
if opts.SuppressDoneMessage {
// Bootstrap finalize will print its own completion summary.
Mcmd/entire/cli/setup.go+37/-16
329 unmodified lines
330
331
332
333
334
333
334
335
336
337
338
329 unmodified lines
fmt.Fprintln(w, " git push -u origin HEAD")
}
}
fmt.Fprintln(w, "\nDone.")
// No completion line here: the enable flow runs the connect ladder after
// this publish step (the mirror rung needs the origin remote created
// above) and prints the final "Done." itself.
return nil
}
Mcmd/entire/cli/setup_github.go+3/-2
3928 unmodified lines
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
60 unmodified lines
4049
4050
4051
3998
3999
4000
4001
4052
4053
4054
4055
4056
4057
4058
4059
4060
11 unmodified lines
4072
4073
4074
4019
4020
4075
4076
4077
4078
3928 unmodified lines
}
}
// A bootstrapped enable must run the connect ladder only after the publish
// phase (initial commit + optional GitHub repo) — that step is what creates
// the origin remote, so a ladder run any earlier can only report
// the mirror rung as "couldn't check" and the mirror offer can never fire
// on the very first enable. Not parallel: chdir + env isolation.
func TestEnableCmd_Bootstrap_RunsLadderAfterPublish(t *testing.T) {
dir := t.TempDir()
t.Chdir(dir)
gitcfg := filepath.Join(t.TempDir(), "gitconfig")
if err := os.WriteFile(gitcfg, []byte("[user]\n\tname = Test\n\temail = t@example.com\n[commit]\n\tgpgsign = false\n"), 0o600); err != nil {
t.Fatal(err)
}
t.Setenv("GIT_CONFIG_GLOBAL", gitcfg)
t.Setenv("GIT_CONFIG_SYSTEM", os.DevNull)
var stdout, stderr bytes.Buffer
var atLadder string
var got *enableOnboardingOpts
prev := runEnableOnboarding
runEnableOnboarding = func(_ context.Context, _ io.Writer, o enableOnboardingOpts) {
atLadder = stdout.String()
got = &o
}
t.Cleanup(func() { runEnableOnboarding = prev })
cmd := newEnableCmd()
cmd.SetOut(&stdout)
cmd.SetErr(&stderr)
// The --agent variant keeps the test hermetic: --yes select-all would also
// pick up external agents other tests registered in the process-global
// registry (whose temp-dir binaries are gone). The bootstrap defer under
// test is shared by the bare-wizard and --agent paths.
cmd.SetArgs([]string{"--agent", "claude-code", "--init-repo", "--no-github", "--yes"})
if err := cmd.Execute(); err != nil {
t.Fatalf("enable error = %v\nstdout:\n%s\nstderr:\n%s", err, stdout.String(), stderr.String())
}
if got == nil {
t.Fatalf("bootstrapped enable must run the onboarding ladder; output:\n%s", stdout.String())
}
if !strings.Contains(atLadder, "Created initial commit") {
t.Errorf("ladder ran before the publish phase; output at ladder time:\n%s", atLadder)
}
if !got.firstRun {
t.Error("a bootstrapped repo is always a first run (gates --yes auto-import)")
}
if !got.neverPrompt {
t.Error("--agent enable must suppress onboarding prompts in the deferred ladder too")
}
if !strings.HasSuffix(strings.TrimSpace(stdout.String()), "Done.") {
t.Errorf("enable should close with Done. after the ladder, got:\n%s", stdout.String())
}
}
// The --agent path is documented as non-interactive ("Enables non-interactive
// mode"); the onboarding ladder must run there with prompting suppressed
// regardless of --yes, or CI on a TTY runner hangs on the consent prompt.
60 unmodified lines
}
// The bootstrap flow (--init-repo / non-git dir) suppresses the "Ready."
// message but must still get the onboarding ladder — a just-bootstrapped
// GitHub repo is exactly where login/mirror/import matter most.
func TestRunEnableInteractive_BootstrapPathRunsOnboardingLadder(t *testing.T) {
// While a bootstrap is pending (SuppressDoneMessage), the setup flow must NOT
// run the ladder in-flow: the origin remote doesn't exist until the deferred
// publish phase, so an early ladder can only report the mirror rung as
// "couldn't check" and the mirror offer can never fire. The enable RunE runs
// the ladder after the publish instead (TestEnableCmd_Bootstrap_RunsLadderAfterPublish).
func TestRunEnableInteractive_BootstrapDefersOnboardingLadder(t *testing.T) {
setupTestRepo(t)
ladderRan := false
11 unmodified lines
if err := runEnableInteractive; err != nil {
t.Fatalf("runEnableInteractive() error = %v", err)
}
if !ladderRan {
t.Error("bootstrap enable (SuppressDoneMessage) must still run the onboarding ladder")
}
if ladderRan {
t.Error("bootstrap enable must defer the onboarding ladder to after the publish phase")
}
}
Mcmd/entire/cli/setup_test.go+62/-6