Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/cli/apps-init-recorded-plugin-tip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* `apps init` no longer suggests installing skills to Codex and Copilot users who installed the Databricks plugin with `databricks aitools install`. ([#7830](https://github.com/databricks/cli/pull/7830))
13 changes: 13 additions & 0 deletions acceptance/cmd/aitools/telemetry/apps-init-tip/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@ Tip: coding agents detected without Databricks skills. Run 'databricks aitools i


>>> print_telemetry

=== codex and copilot plugins recorded by aitools install: no tip, no event

>>> [CLI] apps init --template ./template --skip-install --name app-recorded
✔ Creating project

✔ Project created successfully!

Location: [TEST_TMP_DIR]/app-recorded
Files: 3


>>> print_telemetry
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"schema_version": 2,
"release": "v0.2.32",
"last_updated": "2026-01-01T00:00:00Z",
"skills": {},
"scope": "global",
"plugins": {
"codex": {"marketplace": "databricks-agent-skills", "plugin": "databricks", "scope": "user", "version": "0.2.32"},
"copilot": {"marketplace": "databricks-agent-skills", "plugin": "databricks", "scope": "user", "version": "0.2.32"}
}
}
16 changes: 15 additions & 1 deletion acceptance/cmd/aitools/telemetry/apps-init-tip/script
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
sethome home
export CLAUDECODE=1
unset CLAUDE_CODE_SESSION_ID
unset CLAUDE_CONFIG_DIR
# Agent detection reads these config-dir overrides besides HOME; unset them so
# the host's agent dirs can't add a detected agent.
unset CLAUDE_CONFIG_DIR XDG_CONFIG_HOME GEMINI_CLI_HOME PI_CODING_AGENT_DIR GOOSE_PATH_ROOT APPDATA

title "apps init with flags prints the tip: one hint-shown event per hint printed"
trace $CLI apps init --template ./template --skip-install --name app-tip > LOG.apps-init
Expand All @@ -16,3 +18,15 @@ sethome ./plugin-home
trace $CLI apps init --template ./template --skip-install --name app-plugin > LOG.apps-init-plugin
trace print_telemetry
rm -rf app-plugin

title "codex and copilot plugins recorded by aitools install: no tip, no event"
# Codex and Copilot have no plugin manifest the CLI can read, so the plugin
# record in the committed recorded-plugin-home/.databricks/aitools/skills/.state.json
# is what counts for them.
sethome ./recorded-plugin-home
# CLAUDECODE from the first case would make the calling-agent install hint
# fire, since this home has no Claude Code plugin.
unset CLAUDECODE
Comment thread
anton-107 marked this conversation as resolved.
Resolved
trace $CLI apps init --template ./template --skip-install --name app-recorded > LOG.apps-init-recorded
trace print_telemetry
rm -rf app-recorded
4 changes: 4 additions & 0 deletions acceptance/cmd/aitools/telemetry/apps-init-tip/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ New = 'TEST_TMP_DIR]/app-tip'
[[Repls]]
Old = 'TEST_TMP_DIR]\\app-plugin'
New = 'TEST_TMP_DIR]/app-plugin'

[[Repls]]
Old = 'TEST_TMP_DIR]\\app-recorded'
New = 'TEST_TMP_DIR]/app-recorded'
4 changes: 2 additions & 2 deletions cmd/apps/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -1914,10 +1914,10 @@ func runCreate(ctx context.Context, opts createOptions) (runErr error) {
// Recommend skills installation if coding agents are detected without skills.
// In flags mode, only print a hint — never prompt interactively.
if flagsMode {
if !agents.HasDatabricksToolingInstalled(ctx) {
if !agents.HasDatabricksToolingInstalled(ctx, installer.InstalledPluginAgents) {
agents.PrintSkillsTip(ctx)
}
} else if err := agents.RecommendSkillsInstall(ctx, installer.InstallAllSkills); err != nil {
} else if err := agents.RecommendSkillsInstall(ctx, installer.InstalledPluginAgents, installer.InstallAllSkills); err != nil {
log.Warnf(ctx, "Skills recommendation failed: %v", err)
}

Expand Down
14 changes: 10 additions & 4 deletions libs/aitools/agents/recommend.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func MaybeVersionCheckTip(ctx context.Context, installedPlugins func(context.Con
if dbr.HasDetection(ctx) && dbr.RunsOnRuntime(ctx) {
return
}
if HasDatabricksToolingInstalled(ctx) || len(installedPlugins(ctx)) > 0 {
// Any recorded plugin returns first, so the install state is read once.
if len(installedPlugins(ctx)) > 0 || HasDatabricksToolingInstalled(ctx, noInstalledPlugins) {
return
}
// Recorded plugins are checked above, so DatabricksTooling only needs the
Expand All @@ -52,12 +53,17 @@ func MaybeVersionCheckTip(ctx context.Context, installedPlugins func(context.Con
cmdio.LogString(ctx, skillsTipText)
}

// noInstalledPlugins is the installedPlugins argument to
// HasDatabricksToolingInstalled for a CLI install state that records no plugin.
func noInstalledPlugins(context.Context) []string { return nil }

// RecommendSkillsInstall checks if coding agents are detected without Databricks tooling (skills
// or the databricks plugin) installed.
// or the databricks plugin) installed. Callers pass installer.InstalledPluginAgents as
// installedPlugins (see HasDatabricksToolingInstalled).
// In interactive mode, prompts the user to install now using installFn; a "no" also turns
// auto-install off. In non-interactive mode, prints a hint.
func RecommendSkillsInstall(ctx context.Context, installFn func(context.Context) error) error {
if HasDatabricksToolingInstalled(ctx) {
func RecommendSkillsInstall(ctx context.Context, installedPlugins func(context.Context) []string, installFn func(context.Context) error) error {
if HasDatabricksToolingInstalled(ctx, installedPlugins) {
return nil
}

Expand Down
28 changes: 22 additions & 6 deletions libs/aitools/agents/recommend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestRecommendSkillsInstallSkipsWhenSkillsExist(t *testing.T) {
defer func() { Registry = origRegistry }()

ctx := telemetry.WithNewLogger(cmdio.MockDiscard(t.Context()))
err := RecommendSkillsInstall(ctx, noopInstall)
err := RecommendSkillsInstall(ctx, noInstalledPlugins, noopInstall)
assert.NoError(t, err)
assert.Empty(t, hintKinds(t, ctx))
}
Expand All @@ -57,7 +57,23 @@ func TestRecommendSkillsInstallSkipsWhenPluginInstalled(t *testing.T) {

ctx, stderr := cmdio.NewTestContextWithStderr(t.Context())
ctx = telemetry.WithNewLogger(ctx)
err := RecommendSkillsInstall(ctx, noopInstall)
err := RecommendSkillsInstall(ctx, noInstalledPlugins, noopInstall)
assert.NoError(t, err)
assert.Empty(t, stderr.String())
assert.Empty(t, hintKinds(t, ctx))
}

func TestRecommendSkillsInstallSkipsWhenPluginRecorded(t *testing.T) {
home := t.TempDir()
testutil.SetAgentEnv(t, "HOME", home, "USERPROFILE", home)
t.Chdir(t.TempDir())
require.NoError(t, os.MkdirAll(filepath.Join(home, ".codex"), 0o755))
require.NoError(t, os.MkdirAll(filepath.Join(home, ".copilot"), 0o755))
recorded := func(context.Context) []string { return []string{NameCodex, NameCopilot} }

ctx, stderr := cmdio.NewTestContextWithStderr(t.Context())
ctx = telemetry.WithNewLogger(ctx)
err := RecommendSkillsInstall(ctx, recorded, noopInstall)
assert.NoError(t, err)
assert.Empty(t, stderr.String())
assert.Empty(t, hintKinds(t, ctx))
Expand All @@ -73,7 +89,7 @@ func TestRecommendSkillsInstallSkipsWhenNoAgents(t *testing.T) {
defer func() { Registry = origRegistry }()

ctx := cmdio.MockDiscard(t.Context())
err := RecommendSkillsInstall(ctx, noopInstall)
err := RecommendSkillsInstall(ctx, noInstalledPlugins, noopInstall)
assert.NoError(t, err)
}

Expand All @@ -94,7 +110,7 @@ func TestRecommendSkillsInstallNonInteractive(t *testing.T) {

ctx, stderr := cmdio.NewTestContextWithStderr(t.Context())
ctx = telemetry.WithNewLogger(ctx)
err := RecommendSkillsInstall(ctx, noopInstall)
err := RecommendSkillsInstall(ctx, noInstalledPlugins, noopInstall)
require.NoError(t, err)
assert.Contains(t, stderr.String(), "databricks aitools install")
assert.Equal(t, []protos.AitoolsHintKind{protos.AitoolsHintKindAppsInitTip}, hintKinds(t, ctx))
Expand Down Expand Up @@ -129,7 +145,7 @@ func TestRecommendSkillsInstallInteractiveDecline(t *testing.T) {

errc := make(chan error, 1)
go func() {
errc <- RecommendSkillsInstall(ctx, noopInstall)
errc <- RecommendSkillsInstall(ctx, noInstalledPlugins, noopInstall)
}()

_, err := testIO.Stdin.WriteString("n\n")
Expand All @@ -151,7 +167,7 @@ func TestRecommendSkillsInstallInteractiveDecline(t *testing.T) {

func TestMaybeVersionCheckTip(t *testing.T) {
noPlugins := func(context.Context) []string { return nil }
recordedCodexPlugin := func(context.Context) []string { return []string{"codex_0.2.6"} }
recordedCodexPlugin := func(context.Context) []string { return []string{NameCodex} }

for _, tc := range []struct {
name string
Expand Down
26 changes: 19 additions & 7 deletions libs/aitools/agents/skills.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"context"
"os"
"path/filepath"
"slices"
"strings"
"sync"

"github.com/databricks/cli/libs/env"
)
Expand All @@ -23,12 +25,18 @@ const (
// HasDatabricksToolingInstalled reports whether every detected agent already
// has Databricks tooling, so `apps init` has nothing to recommend. Skills in
// the shared canonical (or legacy) dir cover every agent. Otherwise each
// detected agent needs the databricks plugin in its own plugin manifest,
// installed for every project or for the working directory (see
// pluginInstall.appliesTo): a plugin installed for another project does not
// load for the app being created. It also reports true when no agent is
// detected.
func HasDatabricksToolingInstalled(ctx context.Context) bool {
// detected agent needs the databricks plugin. For an agent with a plugin
// manifest reader (Claude Code) that is its own plugin manifest, installed for
// every project or for the working directory (see pluginInstall.appliesTo): a
// plugin installed for another project does not load for the app being
// created. For Codex and Copilot the CLI install state is the only plugin
Comment thread
anton-107 marked this conversation as resolved.
Resolved
// source, so a plugin installed with the agent's own CLI is missed, and a
// plugin later removed with it still counts until the record is cleared.
// installedPlugins is a parameter because this package cannot import the
// installer; callers pass installer.InstalledPluginAgents. It is called only
// once a detected agent has no plugin manifest reader. It also reports true
// when no agent is detected.
func HasDatabricksToolingInstalled(ctx context.Context, installedPlugins func(context.Context) []string) bool {
installed := DetectInstalled(ctx)
if len(installed) == 0 || hasSharedSkills(ctx) {
return true
Expand All @@ -37,9 +45,13 @@ func HasDatabricksToolingInstalled(ctx context.Context) bool {
if wd, err := os.Getwd(); err == nil {
cwd = resolvePath(wd)
}
recorded := sync.OnceValue(func() []string { return installedPlugins(ctx) })
for _, a := range installed {
if a.pluginInstalls == nil {
return false
if !slices.Contains(recorded(), a.Name) {
return false
}
continue
}
// An unreadable manifest counts as no plugin, as before.
if active, _ := a.DatabricksPluginActiveIn(ctx, cwd); !active {
Expand Down
54 changes: 45 additions & 9 deletions libs/aitools/agents/skills_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"
"testing"

"github.com/databricks/cli/internal/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -16,7 +17,7 @@ func TestHasDatabricksToolingInstalledNoAgents(t *testing.T) {
Registry = []*Agent{}
defer func() { Registry = origRegistry }()

assert.True(t, HasDatabricksToolingInstalled(t.Context()))
assert.True(t, HasDatabricksToolingInstalled(t.Context(), noInstalledPlugins))
}

func TestHasDatabricksToolingInstalledCanonicalOnly(t *testing.T) {
Expand All @@ -35,7 +36,7 @@ func TestHasDatabricksToolingInstalledCanonicalOnly(t *testing.T) {
}
defer func() { Registry = origRegistry }()

assert.True(t, HasDatabricksToolingInstalled(t.Context()))
assert.True(t, HasDatabricksToolingInstalled(t.Context(), noInstalledPlugins))
}

func TestHasDatabricksToolingInstalledIgnoresAgentDir(t *testing.T) {
Expand All @@ -56,7 +57,7 @@ func TestHasDatabricksToolingInstalledIgnoresAgentDir(t *testing.T) {
}
defer func() { Registry = origRegistry }()

assert.False(t, HasDatabricksToolingInstalled(t.Context()))
assert.False(t, HasDatabricksToolingInstalled(t.Context(), noInstalledPlugins))
}

func TestHasDatabricksToolingInstalledWithOnlyNonDatabricksSkills(t *testing.T) {
Expand All @@ -77,7 +78,7 @@ func TestHasDatabricksToolingInstalledWithOnlyNonDatabricksSkills(t *testing.T)
}
defer func() { Registry = origRegistry }()

assert.False(t, HasDatabricksToolingInstalled(t.Context()))
assert.False(t, HasDatabricksToolingInstalled(t.Context(), noInstalledPlugins))
}

func TestHasDatabricksToolingInstalledNoSkillsDir(t *testing.T) {
Expand All @@ -95,7 +96,7 @@ func TestHasDatabricksToolingInstalledNoSkillsDir(t *testing.T) {
}
defer func() { Registry = origRegistry }()

assert.False(t, HasDatabricksToolingInstalled(t.Context()))
assert.False(t, HasDatabricksToolingInstalled(t.Context(), noInstalledPlugins))
}

func TestHasDatabricksToolingInstalledCustomSubdirNotChecked(t *testing.T) {
Expand All @@ -116,7 +117,7 @@ func TestHasDatabricksToolingInstalledCustomSubdirNotChecked(t *testing.T) {
}
defer func() { Registry = origRegistry }()

assert.False(t, HasDatabricksToolingInstalled(t.Context()))
assert.False(t, HasDatabricksToolingInstalled(t.Context(), noInstalledPlugins))
}

func TestHasDatabricksToolingInstalledDatabricksAppsCanonical(t *testing.T) {
Expand All @@ -139,7 +140,7 @@ func TestHasDatabricksToolingInstalledDatabricksAppsCanonical(t *testing.T) {
}
defer func() { Registry = origRegistry }()

assert.True(t, HasDatabricksToolingInstalled(t.Context()))
assert.True(t, HasDatabricksToolingInstalled(t.Context(), noInstalledPlugins))
}

func TestHasDatabricksSkillsInFollowsSymlinks(t *testing.T) {
Expand Down Expand Up @@ -186,7 +187,7 @@ func TestHasDatabricksToolingInstalledLegacyPath(t *testing.T) {
}
defer func() { Registry = origRegistry }()

assert.True(t, HasDatabricksToolingInstalled(t.Context()))
assert.True(t, HasDatabricksToolingInstalled(t.Context(), noInstalledPlugins))
}

func TestHasDatabricksToolingInstalled(t *testing.T) {
Expand Down Expand Up @@ -228,7 +229,42 @@ func TestHasDatabricksToolingInstalled(t *testing.T) {
Registry = registry
t.Cleanup(func() { Registry = origRegistry })

assert.Equal(t, tc.want, HasDatabricksToolingInstalled(t.Context()))
assert.Equal(t, tc.want, HasDatabricksToolingInstalled(t.Context(), noInstalledPlugins))
})
}
}

// TestHasDatabricksToolingInstalledRecordedPlugins covers agents without a
// plugin manifest reader (Codex, Copilot): a plugin recorded in the CLI
// install state counts for them, and every detected agent still needs one.
func TestHasDatabricksToolingInstalledRecordedPlugins(t *testing.T) {
Comment thread
anton-107 marked this conversation as resolved.
Resolved
for _, tc := range []struct {
name string
agentDirs []string
claudePlugin bool
recorded []string
want bool
}{
{name: "codex and copilot plugins recorded", agentDirs: []string{".codex", ".copilot"}, recorded: []string{NameCodex, NameCopilot}, want: true},
Comment thread
anton-107 marked this conversation as resolved.
Resolved
{name: "only the codex plugin recorded", agentDirs: []string{".codex", ".copilot"}, recorded: []string{NameCodex}, want: false},
{name: "nothing recorded", agentDirs: []string{".codex", ".copilot"}, want: false},
{name: "codex plugin recorded, cursor without tooling", agentDirs: []string{".codex", ".cursor"}, recorded: []string{NameCodex}, want: false},
{name: "a claude code record without its manifest", agentDirs: []string{".claude"}, recorded: []string{NameClaudeCode}, want: false},
{name: "claude code plugin in its manifest, codex plugin recorded", agentDirs: []string{".claude", ".codex"}, claudePlugin: true, recorded: []string{NameCodex}, want: true},
} {
t.Run(tc.name, func(t *testing.T) {
home := t.TempDir()
testutil.SetAgentEnv(t, "HOME", home, "USERPROFILE", home)
t.Chdir(t.TempDir())
for _, dir := range tc.agentDirs {
require.NoError(t, os.MkdirAll(filepath.Join(home, dir), 0o755))
}
if tc.claudePlugin {
writePluginManifest(t, home, `{"plugins":{"databricks@claude-plugins-official":[{"scope":"user","version":"0.2.6"}]}}`)
}
installedPlugins := func(context.Context) []string { return tc.recorded }

assert.Equal(t, tc.want, HasDatabricksToolingInstalled(t.Context(), installedPlugins))
})
}
}
Loading