Repository navigation
aitools: store the auto-install state and opt-out, gate it in cli-compat #7701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * Add `databricks aitools auto-install disable` and `enable` to turn off (or back on) the automatic installation of Databricks AI tools on CLI upgrades. A global-scope `databricks aitools uninstall` also turns it off. ([#7701](https://github.com/databricks/cli/pull/7701)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Cloud = false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
|
|
||
| === nothing stored yet | ||
|
|
||
| >>> auto_install_state | ||
| (no auto-install state) | ||
|
|
||
| === disable stores the opt-out | ||
|
|
||
| >>> [CLI] aitools auto-install disable | ||
| Automatic installation of Databricks AI tools is disabled. | ||
|
|
||
| >>> auto_install_state | ||
| { | ||
| "opted_out": true | ||
| } | ||
|
|
||
| === enable clears it | ||
|
|
||
| >>> [CLI] aitools auto-install enable | ||
| Automatic installation of Databricks AI tools is enabled. | ||
|
|
||
| >>> auto_install_state | ||
| {} | ||
|
|
||
| === enable says when the environment still turns it off | ||
|
|
||
| >>> DATABRICKS_AITOOLS_AUTO_INSTALL=false [CLI] aitools auto-install enable | ||
| Automatic installation of Databricks AI tools is enabled. | ||
| DATABRICKS_AITOOLS_AUTO_INSTALL still disables it in this environment; unset it to let it run. | ||
|
|
||
| === disable replaces a state file it cannot read | ||
|
|
||
| >>> [CLI] aitools auto-install disable | ||
| Automatic installation of Databricks AI tools is disabled. | ||
|
|
||
| >>> auto_install_state | ||
| { | ||
| "opted_out": true | ||
| } | ||
|
|
||
| === a global uninstall that removes nothing leaves it on | ||
|
|
||
| >>> [CLI] aitools uninstall --scope=global | ||
| Error: no skills or plugins installed | ||
|
|
||
| Exit code: 1 | ||
|
|
||
| >>> auto_install_state | ||
| {} | ||
|
|
||
| === a global uninstall of a mistyped skill leaves it on | ||
|
|
||
| >>> [CLI] aitools uninstall --scope=global --skills databricks-tset | ||
| Error: skill "databricks-tset" is not installed | ||
|
|
||
| Exit code: 1 | ||
|
|
||
| >>> auto_install_state | ||
| {} | ||
|
|
||
| === a global uninstall turns it off | ||
|
|
||
| >>> [CLI] aitools uninstall --scope=global | ||
| Uninstalled 1 skill. | ||
|
|
||
| >>> auto_install_state | ||
| { | ||
| "opted_out": true | ||
| } | ||
|
|
||
| === a project uninstall leaves it on | ||
|
|
||
| >>> [CLI] aitools uninstall --scope=project | ||
| Uninstalled 1 skill. | ||
|
|
||
| >>> auto_install_state | ||
| {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| sethome home | ||
| mkdir -p "${USERPROFILE:-$HOME}/.cursor" | ||
|
|
||
| title "nothing stored yet" | ||
| trace auto_install_state | ||
|
|
||
| title "disable stores the opt-out" | ||
| trace $CLI aitools auto-install disable | ||
| trace auto_install_state | ||
|
|
||
| title "enable clears it" | ||
| trace $CLI aitools auto-install enable | ||
|
Comment on lines
+11
to
+12
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] The acceptance harness passes the developer's environment to the CLI (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 8926e09: |
||
| trace auto_install_state | ||
|
|
||
| title "enable says when the environment still turns it off" | ||
| trace DATABRICKS_AITOOLS_AUTO_INSTALL=false $CLI aitools auto-install enable | ||
|
|
||
| title "disable replaces a state file it cannot read" | ||
| echo "not json" > "${USERPROFILE:-$HOME}/.databricks/aitools/auto-install.json" | ||
| trace $CLI aitools auto-install disable | ||
| trace auto_install_state | ||
| $CLI aitools auto-install enable &> LOG.enable-reset-1 | ||
|
|
||
| title "a global uninstall that removes nothing leaves it on" | ||
| errcode trace $CLI aitools uninstall --scope=global | ||
| trace auto_install_state | ||
|
|
||
| title "a global uninstall of a mistyped skill leaves it on" | ||
| $CLI aitools install --skills-only --scope=global --agents=cursor &> LOG.install-global | ||
| errcode trace $CLI aitools uninstall --scope=global --skills databricks-tset | ||
| trace auto_install_state | ||
|
|
||
| title "a global uninstall turns it off" | ||
| trace $CLI aitools uninstall --scope=global | ||
| trace auto_install_state | ||
| $CLI aitools auto-install enable &> LOG.enable-reset-2 | ||
|
|
||
| title "a project uninstall leaves it on" | ||
| mkdir -p "${USERPROFILE:-$HOME}/project" | ||
| cd "${USERPROFILE:-$HOME}/project" | ||
| $CLI aitools install --skills-only --scope=project --agents=claude-code &> LOG.install-project | ||
| trace $CLI aitools uninstall --scope=project | ||
| trace auto_install_state | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # auto_install_state prints the persisted auto-install state. | ||
| auto_install_state() { | ||
| local path="${USERPROFILE:-$HOME}/.databricks/aitools/auto-install.json" | ||
| if [ -f "$path" ]; then cat "$path"; else echo "(no auto-install state)"; fi | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Automatic installation of Databricks AI tools on the first run of a new CLI | ||
| # version. The mock server replaces raw.githubusercontent.com (skills manifest | ||
| # and files). | ||
| Env.DATABRICKS_SKILLS_BASE_URL = "$DATABRICKS_HOST" | ||
| Env.DATABRICKS_SKILLS_REF = "test-ref" | ||
| # Pin it so an opt-out exported in the developer's shell does not change the output. | ||
| Env.DATABRICKS_AITOOLS_AUTO_INSTALL = "true" | ||
|
|
||
| Ignore = [ | ||
| "home", | ||
| ] | ||
|
|
||
| [[Server]] | ||
| Pattern = "GET /test-ref/manifest.json" | ||
| Response.Body = ''' | ||
| { | ||
| "version": "2", | ||
| "updated_at": "2026-01-01T00:00:00Z", | ||
| "skills": { | ||
| "databricks-test": { | ||
| "version": "1.0.0", | ||
| "description": "Test skill", | ||
| "files": ["SKILL.md"], | ||
| "repo_dir": "skills" | ||
| } | ||
| } | ||
| } | ||
| ''' | ||
|
|
||
| [[Server]] | ||
| Pattern = "GET /test-ref/skills/databricks-test/SKILL.md" | ||
| Response.Body = '''--- | ||
| name: databricks-test | ||
| --- | ||
|
|
||
| # Test skill | ||
| ''' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package aitools | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/databricks/cli/cmd/root" | ||
| "github.com/databricks/cli/libs/aitools/autoinstall" | ||
| "github.com/databricks/cli/libs/cmdio" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newAutoInstallCmd() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "auto-install", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nice to have] The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 8926e09: added |
||
| Short: "Turn the automatic installation of Databricks AI tools on or off", | ||
| Long: `Turn the automatic installation of Databricks AI tools on or off. | ||
|
|
||
| On the first run of a new CLI version, the CLI can install the Databricks AI | ||
| tools (skills and plugins) for the coding agents already on this machine, as | ||
| 'databricks aitools install --scope=global' does, or update an existing | ||
| installation, as 'databricks aitools update' does. It never runs in CI and only | ||
| touches the global scope. | ||
|
|
||
| It stays off after 'databricks aitools auto-install disable' or a global-scope | ||
| 'databricks aitools uninstall', until 'databricks aitools auto-install enable'. | ||
| Setting ` + autoinstall.EnvVar + ` to anything but a true value (true, 1, yes, | ||
| on) turns it off in that environment.`, | ||
| RunE: root.ReportUnknownSubcommand, | ||
| } | ||
| cmd.AddCommand(newAutoInstallToggleCmd(true)) | ||
| cmd.AddCommand(newAutoInstallToggleCmd(false)) | ||
| return cmd | ||
| } | ||
|
|
||
| // newAutoInstallToggleCmd returns `auto-install enable` or `auto-install disable`. | ||
| func newAutoInstallToggleCmd(enable bool) *cobra.Command { | ||
| use, short := "disable", "Turn off the automatic installation of Databricks AI tools" | ||
| if enable { | ||
| use, short = "enable", "Turn the automatic installation of Databricks AI tools back on" | ||
| } | ||
| return &cobra.Command{ | ||
| Use: use, | ||
| Short: short, | ||
| Args: cobra.NoArgs, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| ctx := cmd.Context() | ||
| if err := autoinstall.SetOptedOut(ctx, !enable); err != nil { | ||
| return fmt.Errorf("failed to save the auto-install setting: %w", err) | ||
| } | ||
| printAutoInstallSetting(ctx, enable) | ||
| return nil | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| // printAutoInstallSetting confirms the stored setting. An enable that the | ||
| // environment still overrides says so, rather than looking like it worked. | ||
| func printAutoInstallSetting(ctx context.Context, enabled bool) { | ||
| if !enabled { | ||
| cmdio.LogString(ctx, "Automatic installation of Databricks AI tools is disabled.") | ||
| return | ||
| } | ||
| cmdio.LogString(ctx, "Automatic installation of Databricks AI tools is enabled.") | ||
| if autoinstall.EnvOptedOut(ctx) { | ||
| cmdio.LogString(ctx, cmdio.Yellow(ctx, autoinstall.EnvVar+" still disables it in this environment; unset it to let it run.")) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,10 @@ import ( | |
| "slices" | ||
| "strings" | ||
|
|
||
| "github.com/databricks/cli/libs/aitools/autoinstall" | ||
| "github.com/databricks/cli/libs/aitools/installer" | ||
| "github.com/databricks/cli/libs/cmdio" | ||
| "github.com/databricks/cli/libs/log" | ||
| "github.com/databricks/cli/libs/telemetry/protos" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
@@ -27,6 +29,10 @@ func NewUninstallCmd() *cobra.Command { | |
|
|
||
| By default, removes all skills. Use --skills to remove specific skills only. | ||
|
|
||
| A global-scope uninstall that removes anything also turns off the automatic | ||
| installation of Databricks AI tools on CLI upgrades; 'databricks aitools auto-install enable' | ||
| turns it back on. | ||
|
|
||
| The command exits with code 1 when every removal it attempts fails.`, | ||
| Args: cobra.NoArgs, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
|
|
@@ -107,6 +113,15 @@ The command exits with code 1 when every removal it attempts fails.`, | |
| if err != nil { | ||
| return err | ||
| } | ||
| // Auto-install only ever installs in global scope, so only a global | ||
| // uninstall could be undone by it on the next CLI upgrade. A partial | ||
| // one counts too: the update it runs re-adds removed skills. A run | ||
| // that removed nothing (a mistyped skill, nothing installed) does not. | ||
| if scope == installer.ScopeGlobal && (result.PluginsRemoved > 0 || result.SkillsChanged > 0) { | ||
| if err := autoinstall.SetOptedOut(ctx, true); err != nil { | ||
| log.Warnf(ctx, "Could not turn off the automatic installation of Databricks AI tools: %v", err) | ||
| } | ||
| } | ||
|
Comment on lines
+116
to
+124
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nice to have] The opt-out is saved before
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 8926e09: the opt-out is now saved only after a global uninstall succeeds and removed something. The acceptance test covers both of your examples (nothing installed, and a mistyped |
||
| // A plugin or skill that could not be removed is only a warning, unless | ||
| // no copy of any skill and no plugin was removed at all. A plugin record | ||
| // for an agent this CLI does not know is not an attempt: no command can | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nice to have] This adds the "copy
auto_installto the new entry" step to the skill, butinternal/build/README.mddescribes the same procedure and was not updated. A maintainer who follows the README's "Breaking changes" step (line 65) would add an entry without the flag and turn the feature off for every newer CLI. The "Manifest format" section (line 7) doesn't list the field, and the "Trust model" (line 83) says the manifest can only steer clients to published tags, when it can now also trigger installs. Update all three.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 8926e09: the README now covers the field in the format section, the copy-forward step for breaking-change entries, and the trust model.