From e002fe48295976a4246d4da2a558c0cb7a6b2ccc Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Wed, 11 Nov 2026 13:53:10 +0000 Subject: [PATCH] aitools: drop the Proceed? confirm after the agent picker in install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `databricks aitools install` (interactive, no agents on the command line) no longer asks `Proceed?` after the agent picker. Agents that would be skipped are not offered in the picker, so choosing agents already confirms the plan. The install scope moves into the picker title, so it is visible before anything runs, and the plan summary after the picker shrinks to the scope line. ```diff install (interactive picker path) - promptAgentSelection # "Select agents to set up", "enter to confirm" + promptAgentSelection # "Select agents to set up ( scope)", "enter to install" buildPlan - printPlanSummary # "Plan ( scope):" + one line per agent - promptProceed # "Proceed?" — No => "Cancelled.", exit 0 - if !proceed: funnel CANCELLED, return nil funnel PLAN_CONFIRMED + printInstallScope # "Install scope: " install plugins / skills ``` - `promptProceed` and `defaultPromptProceed` are removed. `promptAgentSelection` takes the scope for its title. - `printPlanSummary` becomes `printInstallScope`. Its per-agent lines repeated the picker, and its skip branch could no longer run. - The picker hint reads "space to toggle, enter to install", since Enter now starts the install. - Under `--skills-only` (and the `databricks skills install` alias), every found agent is labeled "skills" in the picker, skipped rows included, because that is what they get. The removed per-agent summary lines were the only place this showed before. In that mode an agent whose config dir exists also starts checked, so a plugin agent whose CLI is not on PATH is included, as in the non-interactive run. - `PLAN_CONFIRMED` is kept and still follows `AGENTS_SELECTED` right away; its comment in `libs/telemetry/protos` now says the picker selection is the confirmation. - `TestInstallFunnelInteractiveCancel` now cancels at the picker, which is the last prompt before the install. - Changelog fragment: `.nextchanges/cli/aitools-install-drop-proceed-confirm.md`. Co-authored-by: Isaac --- .../aitools-install-drop-proceed-confirm.md | 1 + cmd/aitools/funnel_test.go | 73 +++++++----- cmd/aitools/install.go | 85 ++++++------- cmd/aitools/install_test.go | 112 ++++++++++++------ libs/telemetry/protos/aitools_events.go | 5 +- 5 files changed, 163 insertions(+), 113 deletions(-) create mode 100644 .nextchanges/cli/aitools-install-drop-proceed-confirm.md diff --git a/.nextchanges/cli/aitools-install-drop-proceed-confirm.md b/.nextchanges/cli/aitools-install-drop-proceed-confirm.md new file mode 100644 index 00000000000..505355d12b8 --- /dev/null +++ b/.nextchanges/cli/aitools-install-drop-proceed-confirm.md @@ -0,0 +1 @@ +* `databricks aitools install` no longer asks "Proceed?" after the agent picker; the picker selection confirms the plan. The picker title now shows the install scope, its hint says Enter installs, `--skills-only` runs label plugin agents "skills" and pre-check every agent whose config dir exists, and the plan summary after it is reduced to the scope line. ([#7478](https://github.com/databricks/cli/pull/7478)) diff --git a/cmd/aitools/funnel_test.go b/cmd/aitools/funnel_test.go index ba9302a4354..07efa2e7c9e 100644 --- a/cmd/aitools/funnel_test.go +++ b/cmd/aitools/funnel_test.go @@ -238,32 +238,57 @@ func TestInstallFunnelSkillsFailureThroughJSON(t *testing.T) { }, funnelShape(funnelEvents(ctx))) } -func TestInstallFunnelInteractiveConfirm(t *testing.T) { +// Picking agents is the confirmation, so an interactive run goes straight from +// AGENTS_SELECTED to PLAN_CONFIRMED and the install. +func TestInstallFunnelInteractiveSuccess(t *testing.T) { + isolateAgents(t) + setupTestAgents(t) + setupScopeMock(t, installer.ScopeGlobal) + setupInstallMock(t) + origPicker := promptAgentSelection + t.Cleanup(func() { promptAgentSelection = origPicker }) + // Cursor gets raw skills, which setupInstallMock stands in for. + promptAgentSelection = func(context.Context, string, []agentChoice) ([]*agents.Agent, error) { + return []*agents.Agent{agents.ByName(agents.NameCursor)}, nil + } + + ioCtx, test := cmdio.SetupTest(t.Context(), cmdio.TestOptions{PromptSupported: true}) + defer test.Done() + go drainReader(test.Stdout) + go drainReader(test.Stderr) + + ctx := telemetry.WithNewLogger(ioCtx) + cmd := newTestInstallCmd() + cmd.SetContext(ctx) + require.NoError(t, cmd.RunE(cmd, nil)) + + events := funnelEvents(ctx) + require.Equal(t, []string{"STARTED", "FLAGS_VALIDATED", "SCOPE_RESOLVED", "AGENTS_SELECTED", "PLAN_CONFIRMED", "SKILLS_INSTALLED", "FINISHED:SUCCESS:"}, funnelShape(events)) + assert.True(t, events[0].Interactive) +} + +func TestInstallFunnelInteractiveCancel(t *testing.T) { + // The agent picker is the last prompt before the install, so it is where + // an interactive user cancels. cases := []struct { - name string - proceed func() (bool, error) - wantErr bool - want []string + name string + err error + want string }{ - {name: "confirmed", proceed: func() (bool, error) { return true, nil }, want: []string{"PLAN_CONFIRMED", "SKILLS_INSTALLED", "FINISHED:SUCCESS:"}}, - {name: "declined", proceed: func() (bool, error) { return false, nil }, want: []string{"FINISHED:CANCELLED:"}}, - {name: "aborted", proceed: func() (bool, error) { return false, huh.ErrUserAborted }, wantErr: true, want: []string{"FINISHED:CANCELLED:USER_ABORTED"}}, - // The real prompt tags its own failure (defaultPromptProceed). - {name: "prompt failed", proceed: func() (bool, error) { return false, promptError(assert.AnError) }, wantErr: true, want: []string{"FINISHED:FAILURE:PROMPT_FAILED"}}, + {name: "aborted", err: huh.ErrUserAborted, want: "FINISHED:CANCELLED:USER_ABORTED"}, + // The real picker tags its own failure (defaultPromptAgentSelection). + {name: "prompt failed", err: promptError(assert.AnError), want: "FINISHED:FAILURE:PROMPT_FAILED"}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { isolateAgents(t) setupTestAgents(t) setupScopeMock(t, installer.ScopeGlobal) - setupInstallMock(t) - origPicker, origProceed := promptAgentSelection, promptProceed - t.Cleanup(func() { promptAgentSelection, promptProceed = origPicker, origProceed }) - // Cursor gets raw skills, which setupInstallMock stands in for. - promptAgentSelection = func(context.Context, []agentChoice) ([]*agents.Agent, error) { - return []*agents.Agent{agents.ByName(agents.NameCursor)}, nil + origPicker := promptAgentSelection + t.Cleanup(func() { promptAgentSelection = origPicker }) + promptAgentSelection = func(context.Context, string, []agentChoice) ([]*agents.Agent, error) { + return nil, tc.err } - promptProceed = tc.proceed ioCtx, test := cmdio.SetupTest(t.Context(), cmdio.TestOptions{PromptSupported: true}) defer test.Done() @@ -273,16 +298,10 @@ func TestInstallFunnelInteractiveConfirm(t *testing.T) { ctx := telemetry.WithNewLogger(ioCtx) cmd := newTestInstallCmd() cmd.SetContext(ctx) - err := cmd.RunE(cmd, nil) - if tc.wantErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } + require.Error(t, cmd.RunE(cmd, nil)) events := funnelEvents(ctx) - want := append([]string{"STARTED", "FLAGS_VALIDATED", "SCOPE_RESOLVED", "AGENTS_SELECTED"}, tc.want...) - require.Equal(t, want, funnelShape(events)) + require.Equal(t, []string{"STARTED", "FLAGS_VALIDATED", "SCOPE_RESOLVED", tc.want}, funnelShape(events)) assert.True(t, events[0].Interactive) }) } @@ -338,14 +357,14 @@ func TestInstallFunnelAbortedScopePromptKeepsNamedAgents(t *testing.T) { } // Confirming the picker with nothing checked is the user opting out, so it -// finishes CANCELLED like a declined confirm, though the command still errors. +// finishes CANCELLED, though the command still errors. func TestInstallFunnelEmptyPickerSelectionIsCancelled(t *testing.T) { isolateAgents(t) setupTestAgents(t) setupScopeMock(t, installer.ScopeGlobal) origPicker := promptAgentSelection t.Cleanup(func() { promptAgentSelection = origPicker }) - promptAgentSelection = func(context.Context, []agentChoice) ([]*agents.Agent, error) { + promptAgentSelection = func(context.Context, string, []agentChoice) ([]*agents.Agent, error) { return nil, errNoAgentsSelected } diff --git a/cmd/aitools/install.go b/cmd/aitools/install.go index 81cd6311bcd..3e4bccc5271 100644 --- a/cmd/aitools/install.go +++ b/cmd/aitools/install.go @@ -22,7 +22,6 @@ import ( // install_test.go. var ( promptAgentSelection = defaultPromptAgentSelection - promptProceed = defaultPromptProceed installSkillsForAgentsFn = installer.InstallSkillsForAgents installPluginForAgentFn = installer.InstallPluginForAgent recordPluginInstallsFn = installer.RecordPluginInstalls @@ -202,7 +201,7 @@ Supported agents: ` + strings.Join(agents.SupportedNames(), ", "), } // JSON output must be fully non-interactive: every choice has to come - // from flags so no scope prompt, agent picker, or confirm is shown. + // from flags so no scope prompt or agent picker is shown. // Require the flags those prompts would otherwise resolve, and fail // fast naming them. if jsonMode { @@ -280,21 +279,12 @@ Supported agents: ` + strings.Join(agents.SupportedNames(), ", "), plan := buildPlan(targetAgents, scope, skillsOnly, explicit) funnel.setAgents(plan) funnel.step(ctx, protos.AitoolsCommandStepAgentsSelected) - - // In the interactive picker path, show a plan summary and confirm. + // The picker selection confirms the plan; runs without the picker + // confirm it implicitly. + funnel.step(ctx, protos.AitoolsCommandStepPlanConfirmed) if !explicit && interactive { - printPlanSummary(ctx, plan, scope) - proceed, err := promptProceed() - if err != nil { - return err - } - if !proceed { - cmdio.LogString(ctx, "Cancelled.") - funnel.finishWith(ctx, protos.AitoolsCommandOutcomeCancelled, protos.AitoolsErrorCategoryUnspecified) - return nil - } + printInstallScope(ctx, scope) } - funnel.step(ctx, protos.AitoolsCommandStepPlanConfirmed) // Only a run past this point waits for the telemetry auth. A run that // ended earlier (a flag error, a cancelled prompt, no agent detected, // a --path dump) uploads its events only if auth had already resolved, @@ -399,7 +389,7 @@ func selectAgents(ctx context.Context, scope string, skillsOnly, interactive boo // caller prints the no-agents message rather than showing an empty picker. return nil, nil } - return promptAgentSelection(ctx, choices) + return promptAgentSelection(ctx, scope, choices) } var selected []*agents.Agent @@ -426,24 +416,32 @@ func agentChoices(ctx context.Context, scope string, skillsOnly bool) []agentCho var choices []agentChoice for _, a := range agents.Registry { item := planItemFor(a, scope, skillsOnly, false) - label := agentChoiceLabel(ctx, a, item) + label := agentChoiceLabel(ctx, a, item, skillsOnly) cmdio.LogString(ctx, fmt.Sprintf(" %-16s %s", a.DisplayName, label)) if item.delivery == deliverySkip { continue } choices = append(choices, agentChoice{ - agent: a, - label: a.DisplayName + " " + label, - preselect: a.IsPreselected(ctx), + agent: a, + label: a.DisplayName + " " + label, + // Under --skills-only, an agent whose config dir exists also starts + // checked, so a plugin agent whose CLI is not on PATH is included + // as in the non-interactive run. The usual pre-checks still apply. + preselect: a.IsPreselected(ctx) || (skillsOnly && a.Detected(ctx)), }) } return choices } // agentChoiceLabel is the picker label: the detection state, plus the skip -// reason when the agent can't be acted on in the chosen scope. -func agentChoiceLabel(ctx context.Context, a *agents.Agent, item agentPlanItem) string { - label := agentStateLabel(a.DisplayState(ctx)) +// reason when the agent can't be acted on in the chosen scope. Under +// --skills-only every found agent gets raw skills, so it is labeled "skills". +func agentChoiceLabel(ctx context.Context, a *agents.Agent, item agentPlanItem, skillsOnly bool) string { + state := a.DisplayState(ctx) + label := agentStateLabel(state) + if skillsOnly && state != agents.StateNotFound { + label = deliverySkills.String() + } if item.delivery == deliverySkip { return label + " · " + item.reason } @@ -464,19 +462,7 @@ func agentStateLabel(s agents.DisplayState) string { } } -func defaultPromptProceed() (bool, error) { - proceed := true - err := huh.NewConfirm(). - Title("Proceed?"). - Value(&proceed). - Run() - if err != nil { - return false, promptError(err) - } - return proceed, nil -} - -func defaultPromptAgentSelection(_ context.Context, choices []agentChoice) ([]*agents.Agent, error) { +func defaultPromptAgentSelection(_ context.Context, scope string, choices []agentChoice) ([]*agents.Agent, error) { options := make([]huh.Option[string], 0, len(choices)) byName := make(map[string]*agents.Agent, len(choices)) for _, c := range choices { @@ -486,8 +472,8 @@ func defaultPromptAgentSelection(_ context.Context, choices []agentChoice) ([]*a var selected []string err := huh.NewMultiSelect[string](). - Title("Select agents to set up"). - Description("space to toggle, enter to confirm"). + Title(agentPickerTitle(scope)). + Description("space to toggle, enter to install"). Options(options...). Value(&selected). Run() @@ -547,20 +533,17 @@ func planItemFor(a *agents.Agent, scope string, skillsOnly, explicit bool) agent return item } -// printPlanSummary renders the interactive plan summary before the confirm. -func printPlanSummary(ctx context.Context, plan []agentPlanItem, scope string) { +// agentPickerTitle names the install scope, so it is visible before anything +// is installed. +func agentPickerTitle(scope string) string { + return "Select agents to set up (" + scope + " scope)" +} + +// printInstallScope prints the install scope after the agent picker, above the +// per-agent install lines. +func printInstallScope(ctx context.Context, scope string) { cmdio.LogString(ctx, "") - cmdio.LogString(ctx, "Plan ("+scope+" scope):") - for _, it := range plan { - switch it.delivery { - case deliveryPlugin: - cmdio.LogString(ctx, " "+it.agent.DisplayName+" install the databricks plugin") - case deliverySkills: - cmdio.LogString(ctx, " "+it.agent.DisplayName+" install skills") - case deliverySkip: - cmdio.LogString(ctx, " "+it.agent.DisplayName+" skip ("+it.reason+")") - } - } + cmdio.LogString(ctx, "Install scope: "+scope) cmdio.LogString(ctx, "") } diff --git a/cmd/aitools/install_test.go b/cmd/aitools/install_test.go index 3795e25dd61..1df2df8eb71 100644 --- a/cmd/aitools/install_test.go +++ b/cmd/aitools/install_test.go @@ -196,6 +196,60 @@ func TestAgentChoicesOnlyOffersActionableAgents(t *testing.T) { assert.NotContains(t, names, agents.NameAntigravity) } +// choiceLabels returns the picker label of each offered agent, by agent name. +func choiceLabels(ctx context.Context, scope string, skillsOnly bool) map[string]string { + m := map[string]string{} + for _, c := range agentChoices(ctx, scope, skillsOnly) { + m[c.agent.Name] = c.label + } + return m +} + +func TestAgentChoicesSkillsOnlyLabelsPluginAgentsSkills(t *testing.T) { + setupTestAgents(t) + fakeBinsOnPath(t, "claude") + ctx := cmdio.MockDiscard(t.Context()) + + assert.Equal(t, "Claude Code plugin", choiceLabels(ctx, installer.ScopeGlobal, false)[agents.NameClaudeCode]) + // --skills-only installs raw skills for every agent, plugin agents included. + assert.Equal(t, "Claude Code skills", choiceLabels(ctx, installer.ScopeGlobal, true)[agents.NameClaudeCode]) + assert.Equal(t, "Claude Code skills", choiceLabels(ctx, installer.ScopeProject, true)[agents.NameClaudeCode]) +} + +func TestAgentChoicesSkillsOnlyLabelsSkippedPluginAgentSkills(t *testing.T) { + setupTestAgents(t) + fakeBinsOnPath(t, "codex") + ctx, stderr := cmdio.NewTestContextWithStderr(t.Context()) + + // Codex has no project-scoped skills, so it is skipped and only listed. + agentChoices(ctx, installer.ScopeProject, true) + assert.Regexp(t, `Codex CLI +skills · does not support project-scoped skills`, stderr.String()) + assert.NotContains(t, stderr.String(), "plugin") +} + +func TestAgentChoicesSkillsOnlyPreselectsByConfigDir(t *testing.T) { + setupTestAgents(t) // ~/.claude and ~/.cursor + fakeBinsOnPath(t) // no claude CLI on PATH + ctx := cmdio.MockDiscard(t.Context()) + + // Plugin delivery needs the CLI, so it starts unchecked. + assert.False(t, choicePreselected(t, agentChoices(ctx, installer.ScopeGlobal, false), agents.NameClaudeCode)) + // Skills delivery only needs the config dir, as in a non-interactive run. + assert.True(t, choicePreselected(t, agentChoices(ctx, installer.ScopeGlobal, true), agents.NameClaudeCode)) +} + +// choicePreselected reports whether the named agent's picker row starts checked. +func choicePreselected(t *testing.T, choices []agentChoice, name string) bool { + t.Helper() + for _, c := range choices { + if c.agent.Name == name { + return c.preselect + } + } + t.Fatalf("%s not offered", name) + return false +} + func TestBuildPlanProjectScopeSkipsUserOnlyAgent(t *testing.T) { claude := testPluginAgent(agents.NameClaudeCode, "Claude Code", "claude") codex := testPluginAgent(agents.NameCodex, "Codex CLI", "codex") @@ -387,19 +441,20 @@ func TestInstallPluginFirstDefault(t *testing.T) { assert.Contains(t, stderr.String(), "Installing databricks plugin for Claude Code...") } -func TestInstallInteractivePickerAndConfirm(t *testing.T) { +func TestInstallInteractivePickerInstallsPickedAgent(t *testing.T) { isolateAgents(t) setupTestAgents(t) fakeBinsOnPath(t, "claude") t.Setenv("DATABRICKS_SKILLS_REF", "v0.2.6") plugins := setupPluginMock(t) - setupScopeMock(t, installer.ScopeGlobal) + // Project, not the global default, so the scope assertions below can fail. + setupScopeMock(t, installer.ScopeProject) origPrompt := promptAgentSelection t.Cleanup(func() { promptAgentSelection = origPrompt }) - pickerCalled := false - promptAgentSelection = func(_ context.Context, choices []agentChoice) ([]*agents.Agent, error) { - pickerCalled = true + pickerScope := "" + promptAgentSelection = func(_ context.Context, scope string, choices []agentChoice) ([]*agents.Agent, error) { + pickerScope = scope for _, c := range choices { if c.agent.Name == agents.NameClaudeCode { return []*agents.Agent{c.agent}, nil @@ -408,31 +463,26 @@ func TestInstallInteractivePickerAndConfirm(t *testing.T) { return nil, nil } - // The confirm is a huh widget that reads the real terminal, so drive it via - // the override rather than piped stdin; assert it was consulted. - origProceed := promptProceed - t.Cleanup(func() { promptProceed = origProceed }) - proceedCalled := false - promptProceed = func() (bool, error) { - proceedCalled = true - return true, nil - } - - ctx, test := cmdio.SetupTest(t.Context(), cmdio.TestOptions{PromptSupported: true}) - defer test.Done() - go drainReader(test.Stdout) - go drainReader(test.Stderr) - - cmd := newTestInstallCmd() - cmd.SetContext(telemetry.WithNewLogger(ctx)) - - require.NoError(t, cmd.RunE(cmd, nil)) - assert.True(t, pickerCalled) - assert.True(t, proceedCalled) + _, stderr := runInstallWithStderr(t, true) + // The picker gets the resolved scope for its title, and the scope line + // follows the picker. + assert.Equal(t, installer.ScopeProject, pickerScope) + assert.Contains(t, stderr, "Install scope: project") require.Len(t, *plugins, 1) assert.Equal(t, agents.NameClaudeCode, (*plugins)[0].agent) } +func TestAgentPickerTitleNamesScope(t *testing.T) { + assert.Equal(t, "Select agents to set up (global scope)", agentPickerTitle(installer.ScopeGlobal)) + assert.Equal(t, "Select agents to set up (project scope)", agentPickerTitle(installer.ScopeProject)) +} + +func TestPrintInstallScope(t *testing.T) { + ctx, stderr := cmdio.NewTestContextWithStderr(t.Context()) + printInstallScope(ctx, installer.ScopeProject) + assert.Equal(t, "\nInstall scope: project\n\n", stderr.String()) +} + func TestInstallExplicitAgentWorksUndetected(t *testing.T) { tmp := t.TempDir() t.Setenv("HOME", tmp) @@ -665,7 +715,7 @@ func TestInstallInteractivePickerErrorPropagates(t *testing.T) { origPrompt := promptAgentSelection t.Cleanup(func() { promptAgentSelection = origPrompt }) - promptAgentSelection = func(_ context.Context, _ []agentChoice) ([]*agents.Agent, error) { + promptAgentSelection = func(context.Context, string, []agentChoice) ([]*agents.Agent, error) { return nil, errors.New("at least one agent must be selected") } @@ -927,16 +977,10 @@ func setupAgentCallerInstall(t *testing.T, agentEnv ...string) (plugins *[]plugi scopePrompted = setupScopeMock(t, installer.ScopeProject) origPrompt := promptAgentSelection t.Cleanup(func() { promptAgentSelection = origPrompt }) - promptAgentSelection = func(context.Context, []agentChoice) ([]*agents.Agent, error) { + promptAgentSelection = func(context.Context, string, []agentChoice) ([]*agents.Agent, error) { t.Fatal("agent picker shown to an agent caller") return nil, nil } - origProceed := promptProceed - t.Cleanup(func() { promptProceed = origProceed }) - promptProceed = func() (bool, error) { - t.Fatal("plan confirm shown to an agent caller") - return false, nil - } return plugins, skills, scopePrompted } diff --git a/libs/telemetry/protos/aitools_events.go b/libs/telemetry/protos/aitools_events.go index a2c4a65f222..9a39ef8c6b0 100644 --- a/libs/telemetry/protos/aitools_events.go +++ b/libs/telemetry/protos/aitools_events.go @@ -71,7 +71,10 @@ const ( AitoolsCommandStepScopeResolved AitoolsCommandStep = "SCOPE_RESOLVED" // The target agents were resolved (from --agents, the picker, or detection). AitoolsCommandStepAgentsSelected AitoolsCommandStep = "AGENTS_SELECTED" - // The plan was confirmed, by the user or implicitly when no prompt is shown. + // The plan was confirmed. Install has no separate confirm prompt: this step + // follows AGENTS_SELECTED right away, because picking agents in the + // interactive picker confirms the plan, and runs without the picker + // (--agents, non-interactive) confirm it implicitly. AitoolsCommandStepPlanConfirmed AitoolsCommandStep = "PLAN_CONFIRMED" // Raw skill files were installed for the skills-delivery agents. AitoolsCommandStepSkillsInstalled AitoolsCommandStep = "SKILLS_INSTALLED"