-
Notifications
You must be signed in to change notification settings - Fork 196
Simplify aitools install output and default the confirm to yes #5916
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
Open
lennartkats-db
wants to merge
2
commits into
main
Choose a base branch
from
aitools-install-output
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -316,14 +316,15 @@ func InstallSkillsForAgents(ctx context.Context, src ManifestSource, targetAgent | |||
| return fmt.Errorf("failed to load install state: %w", err) | ||||
| } | ||||
|
|
||||
| // Detect legacy installs (skills on disk but no state file). Global only. | ||||
| // Block targeted installs on legacy setups to avoid writing incomplete state | ||||
| // that would hide the legacy warning on future runs. | ||||
| if state == nil && scope == ScopeGlobal { | ||||
| isLegacy := checkLegacyInstall(ctx, baseDir) | ||||
| if isLegacy && len(opts.SpecificSkills) > 0 { | ||||
| return errors.New("legacy install detected without state tracking; run 'databricks aitools install' (without a skill name) first to rebuild state") | ||||
| } | ||||
| // A "legacy install" is one from before the CLI tracked install state in a | ||||
| // JSON file: skills exist on disk but there's no state file (state == nil). | ||||
| // A targeted install (--skills foo) here would write a state file listing only | ||||
| // foo, leaving the other on-disk skills untracked. Block it so the user runs a | ||||
| // full install first, which rebuilds complete state. Global scope only, since | ||||
| // legacy installs only ever wrote to the global dir. | ||||
| // hasLegacyInstall lives in update.go (shared with the update/uninstall paths). | ||||
| if state == nil && scope == ScopeGlobal && len(opts.SpecificSkills) > 0 && hasLegacyInstall(ctx, baseDir) { | ||||
| return errors.New("legacy install detected without state tracking; run 'databricks aitools install' (without a skill name) first to rebuild state") | ||||
| } | ||||
|
|
||||
| // Filter skills based on options, experimental flag, and CLI version. | ||||
|
|
@@ -342,6 +343,11 @@ func InstallSkillsForAgents(ctx context.Context, src ManifestSource, targetAgent | |||
| // Install each skill in sorted order for determinism. | ||||
| skillNames := slices.Sorted(maps.Keys(targetSkills)) | ||||
|
|
||||
| // Scoped to the loop, not the manifest fetch above, so earlier warnings print | ||||
| // as plain lines instead of racing the live spinner's redraw. | ||||
| sp := cmdio.NewSpinner(ctx) | ||||
| defer sp.Close() | ||||
|
|
||||
| // Accumulate file provenance for skills we (re)fetch this run. Skipped | ||||
| // (already-installed) skills keep their existing records via the merge below. | ||||
| fileRecords := map[string]FileRecord{} | ||||
|
|
@@ -360,6 +366,7 @@ func InstallSkillsForAgents(ctx context.Context, src ManifestSource, targetAgent | |||
| } | ||||
| } | ||||
|
|
||||
| sp.Update("Installing " + name + "...") | ||||
| records, err := installSkillForAgents(ctx, name, meta, targetAgents, params) | ||||
| if err != nil { | ||||
| return err | ||||
|
|
@@ -407,6 +414,10 @@ func InstallSkillsForAgents(ctx context.Context, src ManifestSource, targetAgent | |||
| return err | ||||
| } | ||||
|
|
||||
| // Stop the spinner before the summary so its transient line doesn't linger | ||||
| // above the persistent "Installed N skills." output. | ||||
| sp.Close() | ||||
|
|
||||
| noun := "skills" | ||||
| if len(targetSkills) == 1 { | ||||
| noun = "skill" | ||||
|
|
@@ -522,25 +533,6 @@ func printNoAgentsDetected(ctx context.Context) { | |||
| cmdio.LogString(ctx, "Please install at least one coding agent first.") | ||||
| } | ||||
|
|
||||
| // checkLegacyInstall prints a message if skills exist on disk but no state file was found. | ||||
| // Returns true if a legacy install was detected. | ||||
| func checkLegacyInstall(ctx context.Context, globalDir string) bool { | ||||
|
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. FYA, this function was removed in favor of reusing the one at cli/libs/aitools/installer/update.go Line 272 in ee76df3
|
||||
| if hasSkillsOnDisk(globalDir) { | ||||
| cmdio.LogString(ctx, "Found skills installed before state tracking was added. Run 'databricks aitools install' to refresh.") | ||||
| return true | ||||
| } | ||||
| homeDir, err := env.UserHomeDir(ctx) | ||||
| if err != nil { | ||||
| return false | ||||
| } | ||||
| legacyDir := filepath.Join(homeDir, ".databricks", "agent-skills") | ||||
| if hasSkillsOnDisk(legacyDir) { | ||||
| cmdio.LogString(ctx, "Found skills installed before state tracking was added. Run 'databricks aitools install' to refresh.") | ||||
| return true | ||||
| } | ||||
| return false | ||||
| } | ||||
|
|
||||
| // hasSkillsOnDisk checks if a directory contains subdirectories starting with "databricks". | ||||
| func hasSkillsOnDisk(dir string) bool { | ||||
| entries, err := os.ReadDir(dir) | ||||
|
|
@@ -580,15 +572,13 @@ type installParams struct { | |||
|
|
||||
| func installSkillForAgents(ctx context.Context, skillName string, meta SkillMeta, detectedAgents []*agents.Agent, params installParams) (map[string]FileRecord, error) { | ||||
| canonicalDir := filepath.Join(params.baseDir, skillName) | ||||
| cmdio.LogString(ctx, fmt.Sprintf("Downloading %s...", skillName)) | ||||
| records, err := installSkillToDir(ctx, params.ref, meta.RepoDir, meta.SourceName, canonicalDir, meta.Files) | ||||
| if err != nil { | ||||
| return nil, err | ||||
| } | ||||
|
|
||||
| // For project scope, always symlink. For global, symlink when multiple agents. | ||||
| useSymlinks := params.scope == ScopeProject || len(detectedAgents) > 1 | ||||
| cmdio.LogString(ctx, fmt.Sprintf("Exposing %s to %d %s...", skillName, len(detectedAgents), agentNoun(len(detectedAgents)))) | ||||
|
|
||||
| for _, agent := range detectedAgents { | ||||
| agentSkillDir, err := agentSkillsDirForScope(ctx, agent, params.scope, params.cwd) | ||||
|
|
@@ -634,13 +624,6 @@ func installSkillForAgents(ctx context.Context, skillName string, meta SkillMeta | |||
| return records, nil | ||||
| } | ||||
|
|
||||
| func agentNoun(n int) string { | ||||
| if n == 1 { | ||||
| return "agent" | ||||
| } | ||||
| return "agents" | ||||
| } | ||||
|
|
||||
| // agentSkillsDirForScope returns the agent's skills directory for the given scope. | ||||
| func agentSkillsDirForScope(ctx context.Context, agent *agents.Agent, scope, cwd string) (string, error) { | ||||
| if scope == ScopeProject { | ||||
|
|
||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Can we remove the context given that it is ignored? It does not seem this function needs to comply with a specific signature.