Skip to content

Commit d03528e

Browse files
anton-107Isaac
andcommitted
aitools: mention databricks aitools install in version --check
`databricks version --check` (text output) is followed by the `apps init` skills tip on stderr when a coding agent is detected without Databricks tooling. Stdout keeps only the update-check result: ```diff Databricks CLI v0.245.0 You're on the latest version. +Tip: coding agents detected without Databricks skills. Run 'databricks aitools install' to install them. ``` The tip comes from `agents.MaybeVersionCheckTip`. It is not printed when a detected agent has the databricks plugin (in its own manifest or recorded in the CLI install state), when Databricks skills are installed globally or in the current project, on Databricks Runtime, for development builds, or when Claude Code drives the CLI (`agents.MaybeHint` already covers that caller). Changelog fragment: `.nextchanges/cli/version-check-aitools-hint.md`. Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 9dac556 commit d03528e

5 files changed

Lines changed: 196 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* `databricks version --check` now suggests `databricks aitools install` on stderr when a coding agent is detected without the Databricks plugin or skills. ([#7471](https://github.com/databricks/cli/pull/7471))

‎cmd/version/version.go‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
package version
44

55
import (
6+
"context"
7+
68
"github.com/databricks/cli/cmd/root"
79
"github.com/databricks/cli/internal/build"
10+
"github.com/databricks/cli/libs/aitools/agents"
11+
"github.com/databricks/cli/libs/aitools/installer"
812
"github.com/databricks/cli/libs/cmdio"
13+
"github.com/databricks/cli/libs/flags"
914
"github.com/databricks/cli/libs/versioncheck"
1015
"github.com/spf13/cobra"
1116
)
@@ -30,6 +35,20 @@ Download the latest release: https://github.com/databricks/cli/releases
3035
{{- end}}
3136
`
3237

38+
// renderUpdateCheck renders result and, in text mode, follows it with the
39+
// aitools install tip on stderr (agents.MaybeVersionCheckTip), so stdout keeps
40+
// only the update-check result. Development builds skip the tip.
41+
func renderUpdateCheck(ctx context.Context, result *versioncheck.Result, output flags.Output) error {
42+
err := cmdio.RenderWithTemplate(ctx, result, "", updateCheckTemplate)
43+
if err != nil {
44+
return err
45+
}
46+
if output == flags.OutputText && !result.DevelopmentBuild {
47+
agents.MaybeVersionCheckTip(ctx, installer.InstalledTools)
48+
}
49+
return nil
50+
}
51+
3352
func New() *cobra.Command {
3453
cmd := &cobra.Command{
3554
Use: "version",
@@ -46,7 +65,7 @@ func New() *cobra.Command {
4665
cmd.RunE = func(cmd *cobra.Command, args []string) error {
4766
ctx := cmd.Context()
4867
if check {
49-
return cmdio.RenderWithTemplate(ctx, versioncheck.Check(ctx), "", updateCheckTemplate)
68+
return renderUpdateCheck(ctx, versioncheck.Check(ctx), root.OutputType(cmd))
5069
}
5170
return cmdio.Render(ctx, build.GetInfo())
5271
}

‎cmd/version/version_test.go‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
package version
22

33
import (
4+
"bytes"
5+
"os"
6+
"path/filepath"
47
"testing"
58

9+
"github.com/databricks/cli/internal/testutil"
10+
"github.com/databricks/cli/libs/aitools/agents"
11+
"github.com/databricks/cli/libs/aitools/installer"
612
"github.com/databricks/cli/libs/cmdio"
13+
"github.com/databricks/cli/libs/dbr"
14+
"github.com/databricks/cli/libs/flags"
715
"github.com/databricks/cli/libs/versioncheck"
816
"github.com/stretchr/testify/assert"
917
"github.com/stretchr/testify/require"
@@ -85,3 +93,73 @@ Could not reach GitHub to check for a newer version. See https://github.com/data
8593
})
8694
}
8795
}
96+
97+
func TestRenderUpdateCheckAIToolsTip(t *testing.T) {
98+
upToDate := &versioncheck.Result{CurrentVersion: "0.245.0", LatestVersion: "0.245.0"}
99+
devBuild := &versioncheck.Result{CurrentVersion: "0.0.0-dev+abc123", DevelopmentBuild: true}
100+
upToDateText := "Databricks CLI v0.245.0\nYou're on the latest version.\n"
101+
tip := "Tip: coding agents detected without Databricks skills. Run 'databricks aitools install' to install them.\n"
102+
103+
tests := []struct {
104+
name string
105+
result *versioncheck.Result
106+
output flags.Output
107+
recordedCodexPlugin bool
108+
wantStdout string
109+
wantStderr string
110+
}{
111+
{
112+
name: "text output prints the tip on stderr",
113+
result: upToDate,
114+
output: flags.OutputText,
115+
wantStdout: upToDateText,
116+
wantStderr: tip,
117+
},
118+
{
119+
name: "codex plugin recorded in the install state",
120+
result: upToDate,
121+
output: flags.OutputText,
122+
recordedCodexPlugin: true,
123+
wantStdout: upToDateText,
124+
},
125+
{
126+
name: "development build",
127+
result: devBuild,
128+
output: flags.OutputText,
129+
wantStdout: "Databricks CLI v0.0.0-dev+abc123\nThis is a development build; skipping the update check.\n",
130+
},
131+
{
132+
name: "json output",
133+
result: upToDate,
134+
output: flags.OutputJSON,
135+
wantStdout: "{\n \"current_version\": \"0.245.0\",\n \"latest_version\": \"0.245.0\",\n \"update_available\": false\n}\n",
136+
},
137+
}
138+
139+
for _, tt := range tests {
140+
t.Run(tt.name, func(t *testing.T) {
141+
home := t.TempDir()
142+
testutil.SetAgentEnv(t, "HOME", home, "USERPROFILE", home)
143+
t.Chdir(t.TempDir())
144+
// Codex CLI is detected by its config dir; a plugin install through
145+
// `databricks aitools install` is recorded only in the install state.
146+
require.NoError(t, os.MkdirAll(filepath.Join(home, ".codex"), 0o755))
147+
if tt.recordedCodexPlugin {
148+
state := &installer.InstallState{
149+
Plugins: map[string]installer.PluginRecord{
150+
"codex": {Plugin: "databricks", Version: "0.2.6"},
151+
},
152+
}
153+
require.NoError(t, installer.SaveState(filepath.Join(home, agents.CanonicalSkillsDir), state))
154+
}
155+
156+
var stdout, stderr bytes.Buffer
157+
ctx := dbr.MockRuntime(t.Context(), dbr.Environment{})
158+
ctx = cmdio.InContext(ctx, cmdio.NewIO(ctx, tt.output, nil, &stdout, &stderr, "", ""))
159+
err := renderUpdateCheck(ctx, tt.result, tt.output)
160+
require.NoError(t, err)
161+
assert.Equal(t, tt.wantStdout, stdout.String())
162+
assert.Equal(t, tt.wantStderr, stderr.String())
163+
})
164+
}
165+
}

‎libs/aitools/agents/recommend.go‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,60 @@ package agents
22

33
import (
44
"context"
5+
"os"
56

67
"github.com/databricks/cli/libs/cmdio"
8+
"github.com/databricks/cli/libs/dbr"
79
"github.com/databricks/cli/libs/log"
810
"github.com/databricks/cli/libs/telemetry/protos"
11+
"github.com/databricks/databricks-sdk-go/useragent"
912
)
1013

14+
// skillsTipText is the tip printed by PrintSkillsTip and MaybeVersionCheckTip.
15+
const skillsTipText = "Tip: coding agents detected without Databricks skills. Run 'databricks aitools install' to install them."
16+
1117
// PrintSkillsTip prints the non-interactive `apps init` tip to install skills
1218
// and records that it was shown. Callers decide whether the tooling is missing
1319
// (see HasDatabricksToolingInstalled).
1420
func PrintSkillsTip(ctx context.Context) {
15-
cmdio.LogString(ctx, "Tip: coding agents detected without Databricks skills. Run 'databricks aitools install' to install them.")
21+
cmdio.LogString(ctx, skillsTipText)
1622
logHintShown(ctx, protos.AitoolsHintKindAppsInitTip)
1723
}
1824

25+
// MaybeVersionCheckTip prints skillsTipText after `databricks version --check`
26+
// when a coding agent is detected without Databricks tooling. It prints
27+
// nothing:
28+
// - when Claude Code drives the CLI: MaybeHint covers that caller in the
29+
// root pre-run hook, with its per-session throttle, so a command prints at
30+
// most one install hint;
31+
// - on Databricks Runtime, like the other version notices;
32+
// - when no agent is detected, a detected agent has the databricks plugin in
33+
// its own manifest, or Databricks skills are installed globally
34+
// (HasDatabricksToolingInstalled);
35+
// - when installedPlugins reports a databricks plugin recorded in the CLI
36+
// install state (Codex CLI and GitHub Copilot record plugin installs only
37+
// there). Callers pass installer.InstalledTools, which this package cannot
38+
// import;
39+
// - when Databricks skills are installed in the current project.
40+
//
41+
// It logs no telemetry: `databricks version` never resolves auth, so the event
42+
// would not be uploaded (see logHintShown).
43+
func MaybeVersionCheckTip(ctx context.Context, installedPlugins func(context.Context) []string) {
44+
if useragent.AgentProvider() == claudeAgentProvider {
45+
return
46+
}
47+
if dbr.HasDetection(ctx) && dbr.RunsOnRuntime(ctx) {
48+
return
49+
}
50+
if HasDatabricksToolingInstalled(ctx) || len(installedPlugins(ctx)) > 0 {
51+
return
52+
}
53+
if cwd, err := os.Getwd(); err == nil && len(DetectProjectInstalled(cwd)) > 0 {
54+
return
55+
}
56+
cmdio.LogString(ctx, skillsTipText)
57+
}
58+
1959
// RecommendSkillsInstall checks if coding agents are detected without Databricks tooling (skills
2060
// or the databricks plugin) installed.
2161
// In interactive mode, prompts the user to install now using installFn. In non-interactive mode, prints a hint.

‎libs/aitools/agents/recommend_test.go‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import (
77
"path/filepath"
88
"testing"
99

10+
"github.com/databricks/cli/internal/testutil"
1011
"github.com/databricks/cli/libs/cmdio"
12+
"github.com/databricks/cli/libs/dbr"
1113
"github.com/databricks/cli/libs/telemetry"
1214
"github.com/databricks/cli/libs/telemetry/protos"
1315
"github.com/stretchr/testify/assert"
@@ -132,3 +134,57 @@ func TestRecommendSkillsInstallInteractiveDecline(t *testing.T) {
132134
// The prompt is logged when shown, so a declined prompt still counts.
133135
assert.Equal(t, []protos.AitoolsHintKind{protos.AitoolsHintKindAppsInitPrompt}, hintKinds(t, ctx))
134136
}
137+
138+
func TestMaybeVersionCheckTip(t *testing.T) {
139+
noPlugins := func(context.Context) []string { return nil }
140+
recordedCodexPlugin := func(context.Context) []string { return []string{"codex_0.2.6"} }
141+
142+
for _, tc := range []struct {
143+
name string
144+
agentEnv []string
145+
agentDirs []string
146+
globalSkills bool
147+
claudePlugin bool
148+
projectSkills bool
149+
onDBR bool
150+
installedPlugins func(context.Context) []string
151+
wantTip bool
152+
}{
153+
{name: "agent without tooling", agentDirs: []string{".codex"}, installedPlugins: noPlugins, wantTip: true},
154+
{name: "no agent detected", installedPlugins: noPlugins},
155+
{name: "plugin in agent manifest", agentDirs: []string{".claude"}, claudePlugin: true, installedPlugins: noPlugins},
156+
{name: "plugin recorded in install state", agentDirs: []string{".codex"}, installedPlugins: recordedCodexPlugin},
157+
{name: "global skills", agentDirs: []string{".kiro"}, globalSkills: true, installedPlugins: noPlugins},
158+
{name: "project skills", agentDirs: []string{".kiro"}, projectSkills: true, installedPlugins: noPlugins},
159+
{name: "databricks runtime", agentDirs: []string{".codex"}, onDBR: true, installedPlugins: noPlugins},
160+
{name: "claude code caller is left to MaybeHint", agentEnv: []string{"CLAUDECODE", "1"}, agentDirs: []string{".claude"}, installedPlugins: noPlugins},
161+
} {
162+
t.Run(tc.name, func(t *testing.T) {
163+
home := t.TempDir()
164+
testutil.SetAgentEnv(t, append([]string{"HOME", home, "USERPROFILE", home}, tc.agentEnv...)...)
165+
project := t.TempDir()
166+
t.Chdir(project)
167+
for _, dir := range tc.agentDirs {
168+
require.NoError(t, os.MkdirAll(filepath.Join(home, dir), 0o755))
169+
}
170+
if tc.claudePlugin {
171+
writePluginManifest(t, home, `{"plugins":{"databricks@claude-plugins-official":[{"version":"0.2.6"}]}}`)
172+
}
173+
if tc.globalSkills {
174+
require.NoError(t, os.MkdirAll(filepath.Join(home, CanonicalSkillsDir, "databricks"), 0o755))
175+
}
176+
if tc.projectSkills {
177+
require.NoError(t, os.MkdirAll(filepath.Join(project, ".kiro", "skills", "databricks-apps"), 0o755))
178+
}
179+
180+
ctx, stderr := cmdio.NewTestContextWithStderr(t.Context())
181+
ctx = dbr.MockRuntime(ctx, dbr.Environment{IsDbr: tc.onDBR})
182+
MaybeVersionCheckTip(ctx, tc.installedPlugins)
183+
if tc.wantTip {
184+
assert.Equal(t, skillsTipText+"\n", stderr.String())
185+
} else {
186+
assert.Empty(t, stderr.String())
187+
}
188+
})
189+
}
190+
}

0 commit comments

Comments
 (0)