Repository navigation
aitools: keep installing plugins when the skills install fails #7479
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 @@ | ||
| * `databricks aitools install` now installs plugins for the other coding agents even when installing skill files fails. ([#7479](https://github.com/databricks/cli/pull/7479)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -607,17 +607,18 @@ func executePlan(ctx context.Context, src installer.ManifestSource, plan []agent | |
| var outcomes []agentOutcome | ||
| var explicitErrs []error | ||
|
|
||
| // A skills install runs as a group; its failure is the command's top-level | ||
| // error. Plugin agents don't depend on it, so they are still attempted. | ||
| var skillsErr error | ||
| if len(skillsAgents) > 0 { | ||
| if !quiet { | ||
| installer.PrintInstallingFor(ctx, skillsAgents) | ||
| } | ||
| // A skills install runs as a group; on failure the whole command fails and | ||
| // the top-level error category classifies it. | ||
| if err := installSkillsForAgentsFn(ctx, src, skillsAgents, opts); err != nil { | ||
| return outcomes, err | ||
| } | ||
| for _, a := range skillsAgents { | ||
| outcomes = append(outcomes, agentOutcome{agent: a, delivery: deliverySkills, status: outcomeInstalled}) | ||
| skillsErr = installSkillsForAgentsFn(ctx, src, skillsAgents, opts) | ||
| if skillsErr == nil { | ||
| for _, a := range skillsAgents { | ||
| outcomes = append(outcomes, agentOutcome{agent: a, delivery: deliverySkills, status: outcomeInstalled}) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -664,9 +665,22 @@ func executePlan(ctx context.Context, src installer.ManifestSource, plan []agent | |
| cmdio.LogString(ctx, fmt.Sprintf(" %s databricks plugin %s", it.agent.DisplayName, versionToken(rec.Version))) | ||
| } | ||
| } | ||
| if len(records) > 0 { | ||
| if err := recordPluginInstallsFn(ctx, opts.Scope, records, ref); err != nil { | ||
| return outcomes, err | ||
| if len(records) > 0 && skillsErr != nil && installer.HasUntrackedSkills(ctx, opts.Scope) { | ||
| // Skills with no state file are on disk (an install that predates | ||
| // state tracking, or an interrupted first install). A state file | ||
| // holding only these plugins would hide those skills from update and | ||
| // from the install's legacy checks, so leave recording to the next | ||
| // install whose skills step succeeds. | ||
| log.Debugf(ctx, "Not recording plugin installs: skills without install state are on disk") | ||
| } else if len(records) > 0 { | ||
| // After a skills failure the skills on disk stay at the old release, | ||
| // so record the plugins without advancing state.Release. | ||
| releaseRef := ref | ||
| if skillsErr != nil { | ||
| releaseRef = "" | ||
| } | ||
| if err := recordPluginInstallsFn(ctx, opts.Scope, records, releaseRef); err != nil { | ||
| return outcomes, errors.Join(skillsErr, err) | ||
|
Contributor
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.
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. Agreed, both parts are real gaps. This PR is already approved with the current behavior, so I'd like to handle them in a follow-up instead of changing the gate here:
For now, in the state-file case the command still fails: the returned error joins the skills error and the state error. |
||
| } | ||
| } | ||
| } | ||
|
|
@@ -695,6 +709,11 @@ func executePlan(ctx context.Context, src installer.ManifestSource, plan []agent | |
| cmdio.LogString(ctx, fmt.Sprintf("Installed the plugin for %d %s.", pluginCount, noun)) | ||
| } | ||
|
|
||
| // The skills error has no per-agent entry, so it stays the top-level error; | ||
| // explicit per-agent failures are already in their outcomes. | ||
| if skillsErr != nil { | ||
| return outcomes, skillsErr | ||
| } | ||
| if len(explicitErrs) > 0 { | ||
| return outcomes, &agentErrors{err: errors.Join(explicitErrs...)} | ||
| } | ||
|
|
@@ -740,8 +759,9 @@ func buildInstallOutput(scope string, outcomes []agentOutcome, runErr error) ins | |
| } | ||
| // A top-level failure (skills-group install, plugin recording) has no | ||
| // per-agent entry, so surface it here too; otherwise the consumer sees a | ||
| // non-zero exit with an empty agents array and no reason. Per-agent failures | ||
| // stay in the agents entries above and are not repeated here. | ||
| // non-zero exit with no reason, and the agents array holds at most the | ||
| // plugin agents that were still installed. Per-agent failures stay in the | ||
| // agents entries above and are not repeated here. | ||
| if e := topLevelFailure(runErr); e != nil { | ||
| out.Error = e.Error() | ||
| out.ErrorCategory = string(classifyInstallError(e)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -275,6 +275,27 @@ func buildUpdateSkillSet(state *InstallState, manifest *Manifest, opts UpdateOpt | |
| return skillSet | ||
| } | ||
|
|
||
| // HasUntrackedSkills reports whether the global scope has skills on disk but no | ||
| // state file: from an install that predates state tracking, or from a first | ||
| // install that failed before it saved state. Only the global scope is checked, | ||
| // so a first project install interrupted the same way is not detected. A state | ||
| // file that can't be read counts as no: the caller's next state load reports | ||
| // that error itself. | ||
| func HasUntrackedSkills(ctx context.Context, cliScope string) bool { | ||
| if cliScope != ScopeGlobal { | ||
|
Contributor
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.
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. Updated the doc comment: it now says the check covers skills on disk with no state file from either an install that predates state tracking or a first install that failed before saving state. It also says only the global scope is checked, so an interrupted first project install isn't detected. I also aligned the comment at the call site in I left the project-scope check itself for a follow-up. It changes when plugins get recorded in project scope, and this PR is already approved with the global-only behavior. Commit: 1eca02f |
||
| return false | ||
| } | ||
| dir, err := GlobalSkillsDir(ctx) | ||
| if err != nil { | ||
| return false | ||
| } | ||
| state, err := LoadState(dir) | ||
| if err != nil { | ||
| return false | ||
| } | ||
| return state == nil && hasLegacyInstall(ctx, dir) | ||
| } | ||
|
|
||
| // hasLegacyInstall checks both canonical and legacy dirs for skills on disk without state. | ||
| func hasLegacyInstall(ctx context.Context, globalDir string) bool { | ||
| if hasSkillsOnDisk(globalDir) { | ||
|
|
||
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] On a machine with raw skills from an install that predates state tracking (no
.state.json), a skills failure now leadsRecordPluginInstallsto create a state file holding only the plugin and an emptySkillsmap. After that,aitools updatetreats the scope as plugin-only (state == nil || len(state.Skills) > 0,cmd/aitools/update.go:171) and exits 0 with no output. Before this PR it printed "found skills from a previous install without state tracking; run 'databricks aitools install' to refresh before updating", so Cursor's legacy skills now silently stop being updated. The new state also turns off thelegacyInstallguards inInstallSkillsForAgents(libs/aitools/installer/installer.go:367-373): the block on--skillsinstalls and the ban on the embedded-manifest fallback.Example: legacy skills on disk,
aitools install --agents cursor,claude-code --scope globalhits a manifest 503, thenaitools updatedoes nothing. I checked this with a scratch test: with the baseinstall.go,updatereturns the legacy error; at this head it returns nil and never callsupdateSkillsFn. A plugin-only install already has this gap, but with this PR a run that was asked to install skills for Cursor, and failed, ends up there too.Suggest not creating a new state file from the skills-failure path when raw skills are already on disk without state (for example, an option on
RecordPluginInstallsbacked byhasLegacyInstall), or running the legacy check inupdatewhen the state has plugins but no skills. A test that starts from a legacy skills dir with no state file would pin this down.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 with your first suggestion. New
installer.HasUntrackedSkills(ctx, scope)reports skills on disk from an install that predates state tracking (global scope, no state file,hasLegacyInstall). When the skills install failed and that is true,executePlaninstalls the plugins but doesn't callRecordPluginInstalls, so no plugin-only state file is created.aitools updatethen still returns the "found skills from a previous install without state tracking" error, and the--skillsblock and the embedded-manifest fallback ban inInstallSkillsForAgentsstay in effect. The plugin is recorded by the next install whose skills step succeeds.New test
TestExecutePlanSkillsFailureKeepsUntrackedSkillsVisiblestarts from a legacy skills dir with no state file and a manifest 503. It checks that the plugin is installed, that no state file exists afterwards, and thatHasUntrackedSkillsis still true. Without the guard, it fails on the plugin-only state file.I left the pre-existing plugin-only gap (a successful plugin-only install on a machine with legacy skills) unchanged, because it's outside this PR's change.
Commit: d0d5fc2