Skip to content

Commit 0023f1b

Browse files
committed
Remove FetchLatestRelease, use GetSkillsRef for version resolution
After squash-merge of PR2, FetchLatestRelease was replaced with getSkillsRef. Export it as GetSkillsRef and update all PR3 code (update.go, version.go, tests) to use the config-based ref instead of the removed GitHub API release lookup. Co-authored-by: Isaac
1 parent 8da78a4 commit 0023f1b

File tree

5 files changed

+64
-101
lines changed

5 files changed

+64
-101
lines changed

experimental/aitools/cmd/version.go

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66

77
"github.com/databricks/cli/experimental/aitools/lib/installer"
88
"github.com/databricks/cli/libs/cmdio"
9-
"github.com/databricks/cli/libs/env"
10-
"github.com/databricks/cli/libs/log"
119
"github.com/spf13/cobra"
1210
)
1311

@@ -41,36 +39,14 @@ func newVersionCmd() *cobra.Command {
4139
skillNoun = "skill"
4240
}
4341

44-
// Best-effort staleness check.
45-
if env.Get(ctx, "DATABRICKS_SKILLS_REF") != "" {
46-
cmdio.LogString(ctx, "Databricks AI Tools:")
47-
cmdio.LogString(ctx, fmt.Sprintf(" Skills: v%s (%d %s)", version, len(state.Skills), skillNoun))
48-
cmdio.LogString(ctx, " Last updated: "+state.LastUpdated.Format("2006-01-02"))
49-
cmdio.LogString(ctx, " Using custom ref: $DATABRICKS_SKILLS_REF")
50-
return nil
51-
}
52-
53-
src := &installer.GitHubManifestSource{}
54-
latest, authoritative, err := src.FetchLatestRelease(ctx)
55-
if err != nil {
56-
log.Debugf(ctx, "Could not check for updates: %v", err)
57-
authoritative = false
58-
}
59-
6042
cmdio.LogString(ctx, "Databricks AI Tools:")
6143

62-
if !authoritative {
63-
cmdio.LogString(ctx, fmt.Sprintf(" Skills: v%s (%d %s)", version, len(state.Skills), skillNoun))
64-
cmdio.LogString(ctx, " Last updated: "+state.LastUpdated.Format("2006-01-02"))
65-
cmdio.LogString(ctx, " Could not check for latest version.")
66-
return nil
67-
}
68-
69-
if latest == state.Release {
44+
latestRef := installer.GetSkillsRef(ctx)
45+
if latestRef == state.Release {
7046
cmdio.LogString(ctx, fmt.Sprintf(" Skills: v%s (%d %s, up to date)", version, len(state.Skills), skillNoun))
7147
cmdio.LogString(ctx, " Last updated: "+state.LastUpdated.Format("2006-01-02"))
7248
} else {
73-
latestVersion := strings.TrimPrefix(latest, "v")
49+
latestVersion := strings.TrimPrefix(latestRef, "v")
7450
cmdio.LogString(ctx, fmt.Sprintf(" Skills: v%s (%d %s)", version, len(state.Skills), skillNoun))
7551
cmdio.LogString(ctx, " Update available: v"+latestVersion)
7652
cmdio.LogString(ctx, " Last updated: "+state.LastUpdated.Format("2006-01-02"))

experimental/aitools/lib/installer/installer.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ const (
3232
// It is a package-level var so tests can replace it with a mock.
3333
var fetchFileFn = fetchSkillFile
3434

35-
func getSkillsRef(ctx context.Context) string {
35+
// GetSkillsRef returns the skills repo ref to use. If DATABRICKS_SKILLS_REF
36+
// is set, it returns that value; otherwise it returns the default ref.
37+
func GetSkillsRef(ctx context.Context) string {
3638
if ref := env.Get(ctx, "DATABRICKS_SKILLS_REF"); ref != "" {
3739
return ref
3840
}
@@ -66,7 +68,7 @@ type InstallOptions struct {
6668
// This is a convenience wrapper that uses the default GitHubManifestSource.
6769
func FetchManifest(ctx context.Context) (*Manifest, error) {
6870
src := &GitHubManifestSource{}
69-
ref := getSkillsRef(ctx)
71+
ref := GetSkillsRef(ctx)
7072
return src.FetchManifest(ctx, ref)
7173
}
7274

@@ -117,7 +119,7 @@ func ListSkills(ctx context.Context) error {
117119
// This is the core installation function. Callers are responsible for agent detection,
118120
// prompting, and printing the "Installing..." header.
119121
func InstallSkillsForAgents(ctx context.Context, src ManifestSource, targetAgents []*agents.Agent, opts InstallOptions) error {
120-
ref := getSkillsRef(ctx)
122+
ref := GetSkillsRef(ctx)
121123
manifest, err := src.FetchManifest(ctx, ref)
122124
if err != nil {
123125
return err

experimental/aitools/lib/installer/uninstall_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func installTestSkills(t *testing.T, tmp string) string {
1818
ctx := cmdio.MockDiscard(t.Context())
1919
setupFetchMock(t)
2020

21-
src := &mockManifestSource{manifest: testManifest(), release: "v0.1.0", authoritative: true}
21+
src := &mockManifestSource{manifest: testManifest()}
2222
agent := testAgent(tmp)
2323
require.NoError(t, InstallSkillsForAgents(ctx, src, []*agents.Agent{agent}, InstallOptions{}))
2424

@@ -68,7 +68,7 @@ func TestUninstallRemovesSymlinks(t *testing.T) {
6868
},
6969
}
7070

71-
src := &mockManifestSource{manifest: testManifest(), release: "v0.1.0", authoritative: true}
71+
src := &mockManifestSource{manifest: testManifest()}
7272
require.NoError(t, InstallSkillsForAgents(ctx, src, []*agents.Agent{claudeAgent, cursorAgent}, InstallOptions{}))
7373

7474
ctx2, _ := cmdio.NewTestContextWithStderr(t.Context())

experimental/aitools/lib/installer/update.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,7 @@ func UpdateSkills(ctx context.Context, src ManifestSource, targetAgents []*agent
5959
return nil, errors.New("no skills installed. Run 'databricks experimental aitools install' to install")
6060
}
6161

62-
latestTag, authoritative, err := src.FetchLatestRelease(ctx)
63-
if err != nil {
64-
return nil, fmt.Errorf("failed to fetch latest release: %w", err)
65-
}
66-
67-
if !authoritative && !opts.Force {
68-
cmdio.LogString(ctx, "Could not check for updates (offline?). Use --force to update anyway.")
69-
return &UpdateResult{Unchanged: sortedKeys(state.Skills)}, nil
70-
}
62+
latestTag := GetSkillsRef(ctx)
7163

7264
if state.Release == latestTag && !opts.Force {
7365
cmdio.LogString(ctx, "Already up to date.")

0 commit comments

Comments
 (0)