From 67eaed7f9e687f774ba9b95ab961be89b07c1b52 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 10 Nov 2026 21:29:35 +0000 Subject: [PATCH 1/7] aitools: skip the install hint on auth, lookup, and completion commands The install hint fires on every command Claude Code runs without the Databricks tooling, including one-shot lookups such as `current-user me`, auth checks, help, and shell completion, where it never converts. Widen the aitools-only exemption into a shared list behind IsHintExemptCommand. Co-authored-by: Isaac --- .../cli/aitools-hint-exempt-commands.md | 1 + .../cmd/aitools/claude-config-dir/output.txt | 8 +++ .../cmd/aitools/claude-config-dir/script | 3 + internal/testutil/cobra.go | 20 +++++++ libs/aitools/agents/hint.go | 57 ++++++++++++++----- libs/aitools/agents/hint_test.go | 33 +++++++++-- 6 files changed, 102 insertions(+), 20 deletions(-) create mode 100644 .nextchanges/cli/aitools-hint-exempt-commands.md create mode 100644 internal/testutil/cobra.go diff --git a/.nextchanges/cli/aitools-hint-exempt-commands.md b/.nextchanges/cli/aitools-hint-exempt-commands.md new file mode 100644 index 00000000000..56d1056c5fe --- /dev/null +++ b/.nextchanges/cli/aitools-hint-exempt-commands.md @@ -0,0 +1 @@ +* Stop printing the Databricks AI tooling install hint on `auth`, `configure`, `current-user me`, `help`, and shell-completion commands, where it does not convert. diff --git a/acceptance/cmd/aitools/claude-config-dir/output.txt b/acceptance/cmd/aitools/claude-config-dir/output.txt index 508651018c5..e4707b61b23 100644 --- a/acceptance/cmd/aitools/claude-config-dir/output.txt +++ b/acceptance/cmd/aitools/claude-config-dir/output.txt @@ -10,6 +10,14 @@ Databricks CLI v[CLI_VERSION] Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install Databricks CLI v[CLI_VERSION] +=== Exempt commands never hint, even without the tooling + +>>> CLAUDE_CONFIG_DIR=missing [CLI] current-user me +{ + "id": "[USERID]", + "userName": "[USERNAME]" +} + === Empty override uses the default installation >>> CLAUDE_CONFIG_DIR= [CLI] version diff --git a/acceptance/cmd/aitools/claude-config-dir/script b/acceptance/cmd/aitools/claude-config-dir/script index bdec19ef438..43cc89c8daf 100644 --- a/acceptance/cmd/aitools/claude-config-dir/script +++ b/acceptance/cmd/aitools/claude-config-dir/script @@ -10,6 +10,9 @@ sethome ./installed-home title "Custom directory takes precedence over the default installation\n" trace CLAUDE_CONFIG_DIR=missing $CLI version +title "Exempt commands never hint, even without the tooling\n" +trace CLAUDE_CONFIG_DIR=missing $CLI current-user me + title "Empty override uses the default installation\n" trace CLAUDE_CONFIG_DIR= $CLI version diff --git a/internal/testutil/cobra.go b/internal/testutil/cobra.go new file mode 100644 index 00000000000..bba29a9411c --- /dev/null +++ b/internal/testutil/cobra.go @@ -0,0 +1,20 @@ +package testutil + +import ( + "strings" + + "github.com/spf13/cobra" +) + +// CommandAt builds a command tree under a "databricks" root and returns the +// command at the space-separated path, e.g. "current-user me". Use it to test +// code that inspects a command's position in the tree. +func CommandAt(path string) *cobra.Command { + cmd := &cobra.Command{Use: "databricks"} + for name := range strings.FieldsSeq(path) { + child := &cobra.Command{Use: name} + cmd.AddCommand(child) + cmd = child + } + return cmd +} diff --git a/libs/aitools/agents/hint.go b/libs/aitools/agents/hint.go index 5cd331130f8..441b67b034f 100644 --- a/libs/aitools/agents/hint.go +++ b/libs/aitools/agents/hint.go @@ -3,6 +3,8 @@ package agents import ( "context" "path/filepath" + "slices" + "strings" "time" "github.com/databricks/cli/libs/cache" @@ -25,11 +27,6 @@ const ( // https://github.com/databricks/databricks-sdk-go/blob/main/useragent/agent.go claudeAgentProvider = "claude-code" - // aiToolsCommandName is the top-level command whose subtree is never hinted: - // telling the agent to run `databricks aitools install` while it is already - // running an aitools command makes no sense. - aiToolsCommandName = "aitools" - // claudeSessionEnv is Claude Code's per-session identifier. It keys the // per-session throttle (at most one hint per hintSessionTTL per session); // when unset (older Claude) the hint degrades to per-command. @@ -47,15 +44,15 @@ const hintSessionTTL = time.Hour // MaybeHint prints a one-line recommendation to install the Databricks AI // tooling when Claude Code drives the CLI without it installed. It is a no-op -// for human callers, other agents, aitools commands themselves, when there is -// no output stream, once the tooling is present, and when the session was -// hinted within the last hintSessionTTL. Best-effort: it writes only to stderr -// and never fails the command. +// for human callers, other agents, hint-exempt commands (IsHintExemptCommand), +// when there is no output stream, once the tooling is present, and when the +// session was hinted within the last hintSessionTTL. Best-effort: it writes +// only to stderr and never fails the command. func MaybeHint(ctx context.Context, cmd *cobra.Command) { if useragent.AgentProvider() != claudeAgentProvider { return } - if isAIToolsCommand(cmd) { + if IsHintExemptCommand(cmd) { return } if !cmdio.HasIO(ctx) { @@ -75,17 +72,47 @@ func MaybeHint(ctx context.Context, cmd *cobra.Command) { recordSessionHint(ctx) } -// isAIToolsCommand reports whether cmd is the aitools command or one of its -// subcommands, walking the parent chain (mirrors versioncheck.isExemptCommand). -func isAIToolsCommand(cmd *cobra.Command) bool { - for c := cmd; c != nil; c = c.Parent() { - if c.Name() == aiToolsCommandName { +// hintExemptCommands are the commands, with their subcommands, on which no +// tooling hint prints. Paths are relative to the root command. The aitools +// trees are exempt because telling the agent to run aitools while it already +// runs aitools makes no sense. The rest are plumbing or one-shot lookups (auth +// checks, "who am I", help, shell completion): the agent has no task to apply +// the skills to, and the nudge eval showed such calls do not convert. +var hintExemptCommands = []string{ + "aitools", + "experimental aitools", + "auth", + "configure", + "current-user me", + "completion", + "help", + cobra.ShellCompRequestCmd, + cobra.ShellCompNoDescRequestCmd, +} + +// IsHintExemptCommand reports whether cmd is one of hintExemptCommands or a +// subcommand of one. +func IsHintExemptCommand(cmd *cobra.Command) bool { + path := commandPath(cmd) + for _, exempt := range hintExemptCommands { + if path == exempt || strings.HasPrefix(path, exempt+" ") { return true } } return false } +// commandPath returns cmd's path below the root command, e.g. "current-user me", +// so hintExemptCommands holds whatever the root is named. +func commandPath(cmd *cobra.Command) string { + var names []string + for c := cmd; c.HasParent(); c = c.Parent() { + names = append(names, c.Name()) + } + slices.Reverse(names) + return strings.Join(names, " ") +} + // claudeToolingInstalled reports whether Databricks AI tooling is present for // Claude Code. It checks two signals: the databricks plugin in Claude's own // plugin manifest (written both by `databricks aitools install` and by a direct diff --git a/libs/aitools/agents/hint_test.go b/libs/aitools/agents/hint_test.go index b2a16ffb8e8..046bd0e93f6 100644 --- a/libs/aitools/agents/hint_test.go +++ b/libs/aitools/agents/hint_test.go @@ -8,6 +8,7 @@ import ( "path/filepath" "testing" + "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" @@ -192,14 +193,36 @@ func TestMaybeHint_AIToolsCommandSilent(t *testing.T) { setClaudeAgent(t) ctx, stderr := claudeCtx(t, t.TempDir()) - parent := &cobra.Command{Use: aiToolsCommandName} - child := &cobra.Command{Use: "install"} - parent.AddCommand(child) - - MaybeHint(ctx, child) + MaybeHint(ctx, testutil.CommandAt("aitools install")) assert.Empty(t, stderr.String()) } +func TestIsHintExemptCommand(t *testing.T) { + tests := []struct { + path string + want bool + }{ + {"aitools install", true}, + {"experimental aitools skills install", true}, + {"auth login", true}, + {"auth token", true}, + {"configure", true}, + {"current-user me", true}, + {"completion bash", true}, + {"help jobs", true}, + {cobra.ShellCompRequestCmd, true}, + {"version", false}, + {"current-user", false}, + {"clusters list", false}, + {"jobs run-now", false}, + } + for _, tc := range tests { + t.Run(tc.path, func(t *testing.T) { + assert.Equal(t, tc.want, IsHintExemptCommand(testutil.CommandAt(tc.path))) + }) + } +} + func TestMaybeHint_NoIONoPanic(t *testing.T) { setClaudeAgent(t) // Bare context without cmdio installed: cobra resolves --help and bare From 887c0848dbad7836d234eae1e46f14093e7190ad Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 10 Nov 2026 21:34:01 +0000 Subject: [PATCH 2/7] Add the PR link to the changelog fragment Co-authored-by: Isaac --- .nextchanges/cli/aitools-hint-exempt-commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nextchanges/cli/aitools-hint-exempt-commands.md b/.nextchanges/cli/aitools-hint-exempt-commands.md index 56d1056c5fe..ef22bc4c8af 100644 --- a/.nextchanges/cli/aitools-hint-exempt-commands.md +++ b/.nextchanges/cli/aitools-hint-exempt-commands.md @@ -1 +1 @@ -* Stop printing the Databricks AI tooling install hint on `auth`, `configure`, `current-user me`, `help`, and shell-completion commands, where it does not convert. +* Stop printing the Databricks AI tooling install hint on `auth`, `configure`, `current-user me`, `help`, and shell-completion commands, where it does not convert. ([#7452](https://github.com/databricks/cli/pull/7452)) From e64c5680301aca1a3e02c8d94856a4bc2fc81e9c Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 10 Nov 2026 21:58:27 +0000 Subject: [PATCH 3/7] Keep the command-tree test helper local to the agents tests Only the agents tests build command trees, so a shared helper in internal/testutil is not needed. Co-authored-by: Isaac --- internal/testutil/cobra.go | 20 -------------------- libs/aitools/agents/hint_test.go | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 23 deletions(-) delete mode 100644 internal/testutil/cobra.go diff --git a/internal/testutil/cobra.go b/internal/testutil/cobra.go deleted file mode 100644 index bba29a9411c..00000000000 --- a/internal/testutil/cobra.go +++ /dev/null @@ -1,20 +0,0 @@ -package testutil - -import ( - "strings" - - "github.com/spf13/cobra" -) - -// CommandAt builds a command tree under a "databricks" root and returns the -// command at the space-separated path, e.g. "current-user me". Use it to test -// code that inspects a command's position in the tree. -func CommandAt(path string) *cobra.Command { - cmd := &cobra.Command{Use: "databricks"} - for name := range strings.FieldsSeq(path) { - child := &cobra.Command{Use: name} - cmd.AddCommand(child) - cmd = child - } - return cmd -} diff --git a/libs/aitools/agents/hint_test.go b/libs/aitools/agents/hint_test.go index 046bd0e93f6..38687e9b688 100644 --- a/libs/aitools/agents/hint_test.go +++ b/libs/aitools/agents/hint_test.go @@ -6,9 +6,9 @@ import ( "log/slog" "os" "path/filepath" + "strings" "testing" - "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" @@ -193,10 +193,22 @@ func TestMaybeHint_AIToolsCommandSilent(t *testing.T) { setClaudeAgent(t) ctx, stderr := claudeCtx(t, t.TempDir()) - MaybeHint(ctx, testutil.CommandAt("aitools install")) + MaybeHint(ctx, commandAt("aitools install")) assert.Empty(t, stderr.String()) } +// commandAt builds a command tree under a "databricks" root and returns the +// command at the space-separated path, e.g. "current-user me". +func commandAt(path string) *cobra.Command { + cmd := &cobra.Command{Use: "databricks"} + for name := range strings.FieldsSeq(path) { + child := &cobra.Command{Use: name} + cmd.AddCommand(child) + cmd = child + } + return cmd +} + func TestIsHintExemptCommand(t *testing.T) { tests := []struct { path string @@ -218,7 +230,7 @@ func TestIsHintExemptCommand(t *testing.T) { } for _, tc := range tests { t.Run(tc.path, func(t *testing.T) { - assert.Equal(t, tc.want, IsHintExemptCommand(testutil.CommandAt(tc.path))) + assert.Equal(t, tc.want, IsHintExemptCommand(commandAt(tc.path))) }) } } From d0be319a85988f0678077a1ca821d63022f8b3bc Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 10 Nov 2026 23:06:10 +0000 Subject: [PATCH 4/7] Shorten the changelog fragment Co-authored-by: Isaac --- .nextchanges/cli/aitools-hint-exempt-commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nextchanges/cli/aitools-hint-exempt-commands.md b/.nextchanges/cli/aitools-hint-exempt-commands.md index ef22bc4c8af..a0505cee0ea 100644 --- a/.nextchanges/cli/aitools-hint-exempt-commands.md +++ b/.nextchanges/cli/aitools-hint-exempt-commands.md @@ -1 +1 @@ -* Stop printing the Databricks AI tooling install hint on `auth`, `configure`, `current-user me`, `help`, and shell-completion commands, where it does not convert. ([#7452](https://github.com/databricks/cli/pull/7452)) +* Stop printing the Databricks AI tooling install hint on `auth`, `configure`, `current-user me`, `help`, and shell-completion commands. ([#7452](https://github.com/databricks/cli/pull/7452)) From 2424143b4e0ce51a1184aa5e8f137bdf7f516f0b Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 10 Nov 2026 23:07:50 +0000 Subject: [PATCH 5/7] Reword the exempt-commands comment Co-authored-by: Isaac --- libs/aitools/agents/hint.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/aitools/agents/hint.go b/libs/aitools/agents/hint.go index 441b67b034f..dcb6b7d958d 100644 --- a/libs/aitools/agents/hint.go +++ b/libs/aitools/agents/hint.go @@ -77,7 +77,8 @@ func MaybeHint(ctx context.Context, cmd *cobra.Command) { // trees are exempt because telling the agent to run aitools while it already // runs aitools makes no sense. The rest are plumbing or one-shot lookups (auth // checks, "who am I", help, shell completion): the agent has no task to apply -// the skills to, and the nudge eval showed such calls do not convert. +// the skills to. Evaluations showed that conversion on these commands is low, +// so a hint on them wastes the prompt. var hintExemptCommands = []string{ "aitools", "experimental aitools", From 323877146a84874107770c8a31010c9936b54777 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 11 Nov 2026 17:56:44 +0000 Subject: [PATCH 6/7] Match exempt commands on CommandPath and tighten the tests Build the root-relative path from cobra's CommandPath instead of a hand-rolled parent walk. Drop the __completeNoDesc entry: it is an alias of __complete, so Name() never returns it. Give the hint tests a realistic non-exempt command, replace the fake "help jobs" subtree with the plain help command, and add a prefix negative so "authz" is never exempt. Project the current-user me acceptance output to the one field the step needs. Co-authored-by: Isaac --- .../cmd/aitools/claude-config-dir/output.txt | 5 +---- .../cmd/aitools/claude-config-dir/script | 5 +++-- libs/aitools/agents/hint.go | 19 ++++--------------- libs/aitools/agents/hint_test.go | 5 +++-- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/acceptance/cmd/aitools/claude-config-dir/output.txt b/acceptance/cmd/aitools/claude-config-dir/output.txt index e4707b61b23..8ebf9aa51f3 100644 --- a/acceptance/cmd/aitools/claude-config-dir/output.txt +++ b/acceptance/cmd/aitools/claude-config-dir/output.txt @@ -13,10 +13,7 @@ Databricks CLI v[CLI_VERSION] === Exempt commands never hint, even without the tooling >>> CLAUDE_CONFIG_DIR=missing [CLI] current-user me -{ - "id": "[USERID]", - "userName": "[USERNAME]" -} +"[USERNAME]" === Empty override uses the default installation diff --git a/acceptance/cmd/aitools/claude-config-dir/script b/acceptance/cmd/aitools/claude-config-dir/script index 43cc89c8daf..ea930a6768b 100644 --- a/acceptance/cmd/aitools/claude-config-dir/script +++ b/acceptance/cmd/aitools/claude-config-dir/script @@ -1,7 +1,8 @@ export CLAUDECODE=1 unset CLAUDE_CODE_SESSION_ID -# aitools commands skip the install hint; version exercises it without auth or network. +# Hint-exempt commands (aitools, auth, lookups such as current-user me, completion) skip the +# install hint; version exercises it without auth or network. sethome ./empty-home title "Plugin installed only in the custom config directory\n" trace CLAUDE_CONFIG_DIR=custom $CLI version @@ -11,7 +12,7 @@ title "Custom directory takes precedence over the default installation\n" trace CLAUDE_CONFIG_DIR=missing $CLI version title "Exempt commands never hint, even without the tooling\n" -trace CLAUDE_CONFIG_DIR=missing $CLI current-user me +trace CLAUDE_CONFIG_DIR=missing $CLI current-user me | jq .userName title "Empty override uses the default installation\n" trace CLAUDE_CONFIG_DIR= $CLI version diff --git a/libs/aitools/agents/hint.go b/libs/aitools/agents/hint.go index dcb6b7d958d..64bb46b3ffe 100644 --- a/libs/aitools/agents/hint.go +++ b/libs/aitools/agents/hint.go @@ -3,7 +3,6 @@ package agents import ( "context" "path/filepath" - "slices" "strings" "time" @@ -88,32 +87,22 @@ var hintExemptCommands = []string{ "completion", "help", cobra.ShellCompRequestCmd, - cobra.ShellCompNoDescRequestCmd, } // IsHintExemptCommand reports whether cmd is one of hintExemptCommands or a // subcommand of one. func IsHintExemptCommand(cmd *cobra.Command) bool { - path := commandPath(cmd) + path := cmd.CommandPath() + root := cmd.Root().CommandPath() for _, exempt := range hintExemptCommands { - if path == exempt || strings.HasPrefix(path, exempt+" ") { + full := root + " " + exempt + if path == full || strings.HasPrefix(path, full+" ") { return true } } return false } -// commandPath returns cmd's path below the root command, e.g. "current-user me", -// so hintExemptCommands holds whatever the root is named. -func commandPath(cmd *cobra.Command) string { - var names []string - for c := cmd; c.HasParent(); c = c.Parent() { - names = append(names, c.Name()) - } - slices.Reverse(names) - return strings.Join(names, " ") -} - // claudeToolingInstalled reports whether Databricks AI tooling is present for // Claude Code. It checks two signals: the databricks plugin in Claude's own // plugin manifest (written both by `databricks aitools install` and by a direct diff --git a/libs/aitools/agents/hint_test.go b/libs/aitools/agents/hint_test.go index 38687e9b688..b7325f47b27 100644 --- a/libs/aitools/agents/hint_test.go +++ b/libs/aitools/agents/hint_test.go @@ -61,7 +61,7 @@ func claudeCtx(t *testing.T, home string) (context.Context, *bytes.Buffer) { return ctx, stderr } -func regularCmd() *cobra.Command { return &cobra.Command{Use: "current-user"} } +func regularCmd() *cobra.Command { return commandAt("clusters list") } func writePluginManifest(t *testing.T, home, body string) { dir := filepath.Join(home, ".claude", "plugins") @@ -221,9 +221,10 @@ func TestIsHintExemptCommand(t *testing.T) { {"configure", true}, {"current-user me", true}, {"completion bash", true}, - {"help jobs", true}, + {"help", true}, {cobra.ShellCompRequestCmd, true}, {"version", false}, + {"authz", false}, {"current-user", false}, {"clusters list", false}, {"jobs run-now", false}, From b85bd3485e3963674add443f5ea6c857461cb5ed Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 11 Nov 2026 18:04:59 +0000 Subject: [PATCH 7/7] Exempt version from the hint and keep the predicate package-private The version command is the same kind of one-shot lookup as current-user me, and versioncheck already exempts it. The acceptance test now triggers the hint with clusters list, which runs the pre-run hook against the fake server. Nothing outside the package calls the predicate yet, so it is unexported until the update hint needs it. Co-authored-by: Isaac --- .../cli/aitools-hint-exempt-commands.md | 2 +- .../cmd/aitools/claude-config-dir/output.txt | 24 ++++++++++++------- .../cmd/aitools/claude-config-dir/script | 12 +++++----- libs/aitools/agents/hint.go | 11 +++++---- libs/aitools/agents/hint_test.go | 4 ++-- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/.nextchanges/cli/aitools-hint-exempt-commands.md b/.nextchanges/cli/aitools-hint-exempt-commands.md index a0505cee0ea..6af94675aef 100644 --- a/.nextchanges/cli/aitools-hint-exempt-commands.md +++ b/.nextchanges/cli/aitools-hint-exempt-commands.md @@ -1 +1 @@ -* Stop printing the Databricks AI tooling install hint on `auth`, `configure`, `current-user me`, `help`, and shell-completion commands. ([#7452](https://github.com/databricks/cli/pull/7452)) +* Stop printing the Databricks AI tooling install hint on `auth`, `configure`, `current-user me`, `version`, `help`, and shell-completion commands. ([#7452](https://github.com/databricks/cli/pull/7452)) diff --git a/acceptance/cmd/aitools/claude-config-dir/output.txt b/acceptance/cmd/aitools/claude-config-dir/output.txt index 8ebf9aa51f3..8196a824be5 100644 --- a/acceptance/cmd/aitools/claude-config-dir/output.txt +++ b/acceptance/cmd/aitools/claude-config-dir/output.txt @@ -1,14 +1,18 @@ === Plugin installed only in the custom config directory ->>> CLAUDE_CONFIG_DIR=custom [CLI] version -Databricks CLI v[CLI_VERSION] +>>> CLAUDE_CONFIG_DIR=custom [CLI] clusters list +ID Name State +4321 some-test-cluster +9876 some-other-cluster === Custom directory takes precedence over the default installation ->>> CLAUDE_CONFIG_DIR=missing [CLI] version +>>> CLAUDE_CONFIG_DIR=missing [CLI] clusters list Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install -Databricks CLI v[CLI_VERSION] +ID Name State +4321 some-test-cluster +9876 some-other-cluster === Exempt commands never hint, even without the tooling @@ -17,10 +21,14 @@ Databricks CLI v[CLI_VERSION] === Empty override uses the default installation ->>> CLAUDE_CONFIG_DIR= [CLI] version -Databricks CLI v[CLI_VERSION] +>>> CLAUDE_CONFIG_DIR= [CLI] clusters list +ID Name State +4321 some-test-cluster +9876 some-other-cluster === Unset override uses the default installation ->>> [CLI] version -Databricks CLI v[CLI_VERSION] +>>> [CLI] clusters list +ID Name State +4321 some-test-cluster +9876 some-other-cluster diff --git a/acceptance/cmd/aitools/claude-config-dir/script b/acceptance/cmd/aitools/claude-config-dir/script index ea930a6768b..a873173eed1 100644 --- a/acceptance/cmd/aitools/claude-config-dir/script +++ b/acceptance/cmd/aitools/claude-config-dir/script @@ -1,22 +1,22 @@ export CLAUDECODE=1 unset CLAUDE_CODE_SESSION_ID -# Hint-exempt commands (aitools, auth, lookups such as current-user me, completion) skip the -# install hint; version exercises it without auth or network. +# Hint-exempt commands (aitools, auth, one-shot lookups such as version and current-user me, +# completion) skip the install hint; clusters list exercises it against the fake server. sethome ./empty-home title "Plugin installed only in the custom config directory\n" -trace CLAUDE_CONFIG_DIR=custom $CLI version +trace CLAUDE_CONFIG_DIR=custom $CLI clusters list sethome ./installed-home title "Custom directory takes precedence over the default installation\n" -trace CLAUDE_CONFIG_DIR=missing $CLI version +trace CLAUDE_CONFIG_DIR=missing $CLI clusters list title "Exempt commands never hint, even without the tooling\n" trace CLAUDE_CONFIG_DIR=missing $CLI current-user me | jq .userName title "Empty override uses the default installation\n" -trace CLAUDE_CONFIG_DIR= $CLI version +trace CLAUDE_CONFIG_DIR= $CLI clusters list title "Unset override uses the default installation\n" unset CLAUDE_CONFIG_DIR -trace $CLI version +trace $CLI clusters list diff --git a/libs/aitools/agents/hint.go b/libs/aitools/agents/hint.go index 64bb46b3ffe..b2137b7a092 100644 --- a/libs/aitools/agents/hint.go +++ b/libs/aitools/agents/hint.go @@ -43,7 +43,7 @@ const hintSessionTTL = time.Hour // MaybeHint prints a one-line recommendation to install the Databricks AI // tooling when Claude Code drives the CLI without it installed. It is a no-op -// for human callers, other agents, hint-exempt commands (IsHintExemptCommand), +// for human callers, other agents, hint-exempt commands (isHintExemptCommand), // when there is no output stream, once the tooling is present, and when the // session was hinted within the last hintSessionTTL. Best-effort: it writes // only to stderr and never fails the command. @@ -51,7 +51,7 @@ func MaybeHint(ctx context.Context, cmd *cobra.Command) { if useragent.AgentProvider() != claudeAgentProvider { return } - if IsHintExemptCommand(cmd) { + if isHintExemptCommand(cmd) { return } if !cmdio.HasIO(ctx) { @@ -75,7 +75,7 @@ func MaybeHint(ctx context.Context, cmd *cobra.Command) { // tooling hint prints. Paths are relative to the root command. The aitools // trees are exempt because telling the agent to run aitools while it already // runs aitools makes no sense. The rest are plumbing or one-shot lookups (auth -// checks, "who am I", help, shell completion): the agent has no task to apply +// checks, "who am I", version, help, shell completion): the agent has no task to apply // the skills to. Evaluations showed that conversion on these commands is low, // so a hint on them wastes the prompt. var hintExemptCommands = []string{ @@ -84,14 +84,15 @@ var hintExemptCommands = []string{ "auth", "configure", "current-user me", + "version", "completion", "help", cobra.ShellCompRequestCmd, } -// IsHintExemptCommand reports whether cmd is one of hintExemptCommands or a +// isHintExemptCommand reports whether cmd is one of hintExemptCommands or a // subcommand of one. -func IsHintExemptCommand(cmd *cobra.Command) bool { +func isHintExemptCommand(cmd *cobra.Command) bool { path := cmd.CommandPath() root := cmd.Root().CommandPath() for _, exempt := range hintExemptCommands { diff --git a/libs/aitools/agents/hint_test.go b/libs/aitools/agents/hint_test.go index b7325f47b27..e57c9a08769 100644 --- a/libs/aitools/agents/hint_test.go +++ b/libs/aitools/agents/hint_test.go @@ -223,7 +223,7 @@ func TestIsHintExemptCommand(t *testing.T) { {"completion bash", true}, {"help", true}, {cobra.ShellCompRequestCmd, true}, - {"version", false}, + {"version", true}, {"authz", false}, {"current-user", false}, {"clusters list", false}, @@ -231,7 +231,7 @@ func TestIsHintExemptCommand(t *testing.T) { } for _, tc := range tests { t.Run(tc.path, func(t *testing.T) { - assert.Equal(t, tc.want, IsHintExemptCommand(commandAt(tc.path))) + assert.Equal(t, tc.want, isHintExemptCommand(commandAt(tc.path))) }) } }