Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
402ec08
Add a skills source interface over fs.FS
simonfaltum Nov 25, 2026
2df5cf8
Share the install state file name with libs/skills
simonfaltum Nov 25, 2026
aa6b7d3
Compare skill fixtures with normalized line endings
simonfaltum Nov 25, 2026
fb7d076
Address review on the skills source
simonfaltum Nov 25, 2026
c1365d3
Add the skills command group behind DATABRICKS_SKILLS_PREVIEW
simonfaltum Nov 26, 2026
b2a2be6
Print the skills catalog from skills list
simonfaltum Nov 26, 2026
055acad
Add a skills source interface over fs.FS
simonfaltum Nov 25, 2026
79c67cd
Share the install state file name with libs/skills
simonfaltum Nov 25, 2026
4530158
Compare skill fixtures with normalized line endings
simonfaltum Nov 25, 2026
b61b62d
Address review on the skills source
simonfaltum Nov 25, 2026
2906664
Skill source: unexport escapesDir, reject a catalog_rules directory
simonfaltum Nov 26, 2026
ddbdb00
Carry the minimum CLI version on skills catalog entries
simonfaltum Nov 26, 2026
41dfd3d
Add the skills command group behind DATABRICKS_SKILLS_PREVIEW
simonfaltum Nov 26, 2026
417ae32
Merge origin/main into skills/c2-skills-command-group-behind-an-env-v…
simonfaltum Nov 27, 2026
c75c37c
Merge skills c2 tip into skills list branch
simonfaltum Nov 27, 2026
fcd2902
Check skills command name against root commands, clear env in guard t…
simonfaltum Nov 27, 2026
497ff28
Print the skills catalog from skills list
simonfaltum Nov 27, 2026
53c8155
Merge skills c2 tip into skills list branch
simonfaltum Nov 27, 2026
4844df8
Keep skills list text within the budget and route its JSON through cmdio
simonfaltum Nov 27, 2026
b262160
Merge origin/main into skills list branch
simonfaltum Nov 27, 2026
c3c22dd
Merge origin/main into skills list branch
simonfaltum Nov 27, 2026
6729933
Update agent-hints acceptance test for implemented skills list
simonfaltum Nov 27, 2026
3ac93e6
Merge origin/main into skills list branch
simonfaltum Nov 27, 2026
b10ce6a
Keep skills list acceptance in step with merged siblings
simonfaltum Nov 27, 2026
c4a5e80
Keep each skills list description within the text budget
simonfaltum Nov 27, 2026
ca310ed
Pick the widest skills list width that fits the budget
simonfaltum Nov 27, 2026
047b7e2
Check the names-only skills list layout before the width search
simonfaltum Nov 27, 2026
3055330
Mark skills that need a newer CLI in skills list
simonfaltum Nov 27, 2026
126f116
Merge origin/main into the skills list branch
simonfaltum Nov 27, 2026
cc8f674
Merge commit '126f1165d663505c5cf052b6e4b681a084593340' into skills/k…
simonfaltum Nov 27, 2026
beeb396
skills: share the newer-CLI check between list and read
simonfaltum Nov 27, 2026
fe9e87b
Merge origin/main into skills list branch
simonfaltum Nov 27, 2026
22df1f3
Test the min_cli_version field in skills list JSON
simonfaltum Nov 27, 2026
562018f
skills list: separate the newer-CLI note from the name, compute notes…
simonfaltum Nov 29, 2026
7b6f5f1
skills list: drop the duplicate JSON test, fix search comments
simonfaltum Nov 30, 2026
237f728
skills: rewrap search comments, join import group
simonfaltum Nov 30, 2026
ab4e2c7
Merge origin/main into skills/kminver-skills-list-decide-how-skills-t…
simonfaltum Nov 30, 2026
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
6 changes: 4 additions & 2 deletions acceptance/cmd/skills/list/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Read the skill before you act on it.

-foo: A skill whose name starts with a hyphen.
demo-skill: A skill for tests.
future-skill: A skill that needs a newer CLI.
future-skill: A skill that needs a newer CLI. (needs CLI 99.0.0 or newer)
guide-skill: A skill with a supporting file.
To read a skill, run: databricks skills read <name>

Expand All @@ -15,7 +15,7 @@ Read the skill before you act on it.

-foo: A skill whose name starts with a hyphen.
demo-skill: A skill for tests.
future-skill: A skill that needs a newer CLI.
future-skill: A skill that needs a newer CLI. (needs CLI 99.0.0 or newer)
guide-skill: A skill with a supporting file.
preview-skill: An experimental skill for tests.
To read a skill, run: databricks skills read <name>
Expand Down Expand Up @@ -52,6 +52,7 @@ To read a skill, run: databricks skills read <name>
"name": "future-skill",
"description": "A skill that needs a newer CLI.",
"version": "0.0.1",
"min_cli_version": "99.0.0",
"files": [
"SKILL.md"
],
Expand Down Expand Up @@ -103,6 +104,7 @@ To read a skill, run: databricks skills read <name>
"name": "future-skill",
"description": "A skill that needs a newer CLI.",
"version": "0.0.1",
"min_cli_version": "99.0.0",
"files": [
"SKILL.md"
],
Expand Down
68 changes: 46 additions & 22 deletions cmd/skills/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ func provenanceLine(catalog *libskills.Catalog) string {
}

// renderText returns the text output of `skills list`: the catalog rules, then
// one line per skill, then a line on how to read a skill. When the whole output
// is over textBudget, descriptions are cut at a word boundary to the widest
// width that fits. When even the names do not fit, only the names are printed.
// one line per skill, then a line on how to read a skill. A skill that needs a
// newer CLI keeps its line and gets a note after it. When the whole output is
// over textBudget, descriptions are cut at a word boundary to the widest width
// that fits. When even the names do not fit, only the names are printed.
func renderText(rules string, list []libskills.Skill) string {
if len(list) == 0 {
return withRules(rules) + "No skills found.\n"
Expand All @@ -104,7 +105,11 @@ func renderText(rules string, list []libskills.Skill) string {
// A description only makes its line longer, and the search hint is the one
// line a wider width can leave out. So when the names do not fit even with
// the hint, no width does, and the names-only text is the answer.
names := layoutText(rules, list, 0)
notes := make([]string, len(list))
for i, s := range list {
notes[i] = newerCLINote(s)
}
names := layoutText(rules, list, notes, 0)
if len(names)-len(searchHint)-1 > textBudget {
return names
}
Expand All @@ -115,18 +120,18 @@ func renderText(rules string, list []libskills.Skill) string {
// No width above maxLen cuts a description, so the widest width to try is
// the smaller of maxLen and the budget.
top := min(maxLen, textBudget)
fits := func(w int) bool { return len(layoutText(rules, list, w)) <= textBudget }
fits := func(w int) bool { return len(layoutText(rules, list, notes, w)) <= textBudget }
// The length is not monotonic in width: once no description is left out, the
// search hint goes away, so a wider width can be shorter. Below the first
// width at which no description is left out the hint is always there, and from
// that width on it never is, so the length only grows within each part. The
// widest fitting width is searched in the upper part first, then the lower.
complete := 1 + sort.Search(top, func(i int) bool { return !dropsAny(list, i+1) })
if w := widestFitIn(complete, top, fits); w > 0 {
return layoutText(rules, list, w)
return layoutText(rules, list, notes, w)
}
if w := widestFitIn(1, complete-1, fits); w > 0 {
return layoutText(rules, list, w)
return layoutText(rules, list, notes, w)
}
return names
}
Expand Down Expand Up @@ -159,22 +164,29 @@ func dropsAny(list []libskills.Skill, width int) bool {
// long description does not drop the others. Descriptions must be one line.
// The search hint must stay the only line a wider width can leave out: the
// width search in renderText relies on it, together with dropsAny.
func layoutText(rules string, list []libskills.Skill, width int) string {
func layoutText(rules string, list []libskills.Skill, notes []string, width int) string {
var b strings.Builder
b.WriteString(withRules(rules))
dropped := false
for _, s := range list {
for i, s := range list {
desc := s.Description
cut := ""
if width > 0 {
cut = cutWords(desc, width)
}
if cut == "" {
note := notes[i]
switch {
case cut == "" && note == "":
b.WriteString(s.Name + "\n")
dropped = dropped || desc != ""
} else {
case cut == "":
// Keep the colon so the name is the text before it.
b.WriteString(s.Name + ": " + note + "\n")
case note == "":
fmt.Fprintf(&b, "%s: %s\n", s.Name, cut)
default:
fmt.Fprintf(&b, "%s: %s %s\n", s.Name, cut, note)
}
dropped = dropped || (cut == "" && desc != "")
}
if dropped {
b.WriteString(searchHint + "\n")
Expand All @@ -183,6 +195,16 @@ func layoutText(rules string, list []libskills.Skill, width int) string {
return b.String()
}

// newerCLINote returns the note that marks a skill which needs a newer CLI than
// the running one, or "" when this CLI is new enough. The skill stays listed,
// as `skills read` still serves it with a warning.
func newerCLINote(s libskills.Skill) string {
if !needsNewerCLI(s) {
return ""
}
return fmt.Sprintf("(needs CLI %s or newer)", s.MinCLIVer)
}

// oneLineSkills returns list with each description joined into one line.
func oneLineSkills(list []libskills.Skill) []libskills.Skill {
out := make([]libskills.Skill, len(list))
Expand Down Expand Up @@ -229,11 +251,12 @@ type listJSON struct {
}

type listJSONSkill struct {
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version"`
Files []string `json:"files"`
Commands []string `json:"commands"`
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version"`
MinCLIVersion string `json:"min_cli_version,omitempty"`
Files []string `json:"files"`
Commands []string `json:"commands"`
}

// nonNilList keeps an absent list as [] in JSON rather than null.
Expand All @@ -252,11 +275,12 @@ func newListJSON(catalog *libskills.Catalog, list []libskills.Skill) listJSON {
}
for _, s := range list {
out.Skills = append(out.Skills, listJSONSkill{
Name: s.Name,
Description: s.Description,
Version: s.Version,
Files: nonNilList(s.Files),
Commands: nonNilList(s.Commands),
Name: s.Name,
Description: s.Description,
Version: s.Version,
MinCLIVersion: s.MinCLIVer,
Files: nonNilList(s.Files),
Commands: nonNilList(s.Commands),
})
}
return out
Expand Down
28 changes: 26 additions & 2 deletions cmd/skills/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"
"time"

"github.com/databricks/cli/internal/build"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] "github.com/databricks/cli/internal/build" sits in its own group, separated by a blank line from the other github.com/databricks/cli/... imports. goimports accepts it, so lint passes, but it splits the first-party group. Drop the blank line so it joins the libs/... imports.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest push. The internal/build import now sits in the same group as the other first-party imports.

"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags"
libskills "github.com/databricks/cli/libs/skills"
Expand Down Expand Up @@ -161,7 +162,11 @@ func renderTextScan(rules string, list []libskills.Skill) string {
return withRules(rules) + "No skills found.\n"
}
list = oneLineSkills(list)
names := layoutText(rules, list, 0)
notes := make([]string, len(list))
for i, s := range list {
notes[i] = newerCLINote(s)
}
names := layoutText(rules, list, notes, 0)
if len(names)-len(searchHint)-1 > textBudget {
return names
}
Expand All @@ -170,7 +175,7 @@ func renderTextScan(rules string, list []libskills.Skill) string {
maxLen = max(maxLen, len(s.Description))
}
for w := min(maxLen, textBudget); w > 0; w-- {
if out := layoutText(rules, list, w); len(out) <= textBudget {
if out := layoutText(rules, list, notes, w); len(out) <= textBudget {
return out
}
}
Expand Down Expand Up @@ -261,6 +266,25 @@ func TestRenderTextNoSearchHintWithoutDescriptions(t *testing.T) {
assert.Equal(t, "alpha\nbeta\n"+readHint+"\n", renderText("", list))
}

func TestRenderTextMarksSkillThatNeedsNewerCLI(t *testing.T) {
list := []libskills.Skill{
{Name: "alpha", Description: "Alpha does one thing well."},
{Name: "future", Description: "Needs a newer CLI.", MinCLIVer: "99.0.0"},
}
assert.Equal(t, "alpha: Alpha does one thing well.\nfuture: Needs a newer CLI. (needs CLI 99.0.0 or newer)\n"+readHint+"\n",
renderText("", list))
}

func TestRenderTextMarksNamesOnlyLineThatNeedsNewerCLI(t *testing.T) {
list := []libskills.Skill{{Name: "alpha"}, {Name: "future", MinCLIVer: "99.0.0"}}
assert.Equal(t, "alpha\nfuture: (needs CLI 99.0.0 or newer)\n"+readHint+"\n", renderText("", list))
}

func TestRenderTextNoMarkWhenCLIIsNewEnough(t *testing.T) {
list := []libskills.Skill{{Name: "current", Description: "Current.", MinCLIVer: build.GetInfo().Version}}
assert.Equal(t, "current: Current.\n"+readHint+"\n", renderText("", list))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] acceptance/cmd/skills/list/output.txt already shows "min_cli_version": "99.0.0" on future-skill and no such key on the other skills. This test wires up a cobra command and a cmdio context only to check the same two facts again. testing.md says not to add a unit test that only duplicates acceptance coverage. Can we drop it and keep the names-only and new-enough tests, which cover cases the golden doesn't?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in beeb396. Dropped TestRunListJSONCarriesMinCLIVersion. The acceptance golden for skills list --output json already checks min_cli_version on future-skill and its absence on the other skills. I kept the text tests for the names-only line and the new-enough case, which the golden does not cover.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed again in 7b6f5f1. The acceptance golden for skills list --output json already checks min_cli_version on future-skill and its absence on the other skills, so the unit test only repeated it.


func TestRenderTextNoSkills(t *testing.T) {
assert.Equal(t, "No skills found.\n", renderText("", nil))
}
Expand Down
6 changes: 2 additions & 4 deletions cmd/skills/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/databricks/cli/libs/shellquote"
libskills "github.com/databricks/cli/libs/skills"
"github.com/spf13/cobra"
"golang.org/x/mod/semver"
)

// skillFile is the file that holds a skill's instructions. Every other file of
Expand Down Expand Up @@ -72,10 +71,9 @@ func runRead(cmd *cobra.Command, src libskills.Source, name string) error {
return err
}

info := build.GetInfo()
if skill.MinCLIVer != "" && semver.Compare("v"+info.Version, "v"+skill.MinCLIVer) < 0 {
if needsNewerCLI(skill) {
cmdio.LogString(ctx, fmt.Sprintf("Warning: skill %q needs CLI version %s or newer, this CLI is %s. Update the CLI to use it.",
name, skill.MinCLIVer, info.Version))
name, skill.MinCLIVer, build.GetInfo().Version))
}

files := otherFiles(skill.Files)
Expand Down
10 changes: 6 additions & 4 deletions cmd/skills/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ import (
"github.com/spf13/cobra"
)

// searchTemplate prints the matches in the line format of skills list, then the
// line that says how to read a skill. With no match it points at skills list.
// searchTemplate prints the matches as name and description lines like
// skills list, without its newer-CLI note, then the line that says how to read
// a skill. With no match it points at skills list.
const searchTemplate = `{{if .Skills}}{{range .Skills}}{{.Name}}{{with .Description}}: {{.}}{{end}}
{{end}}To read a skill, run: databricks skills read <name>
{{else}}No skill matches. Run databricks skills list to see every skill.
{{end}}`

// searchJSON is the JSON output of skills search. It has the envelope and the
// per-skill fields of skills list, so one parser reads both. skills list defines
// the same shape in its own file; the two should share one type once both land.
// per-skill fields of skills list except min_cli_version, so one parser reads
// both. skills list defines the same shape in its own file; the two should
// share one type once both land.
type searchJSON struct {
Source string `json:"source"`
ReleaseVersion string `json:"release_version"`
Expand Down
10 changes: 10 additions & 0 deletions cmd/skills/skills.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import (
"context"

"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/internal/build"
libskills "github.com/databricks/cli/libs/skills"
"github.com/spf13/cobra"
"golang.org/x/mod/semver"
)

// Spec declares the skills command group.
Expand All @@ -24,3 +27,10 @@ func buildCommand(_ context.Context, cmd *cobra.Command) {
cmd.AddCommand(newReadFileCmd())
cmd.AddCommand(newSearchCmd())
}

// needsNewerCLI reports whether the running CLI is older than the skill's
// min_cli_version. A development build compares below the release it builds
// toward, so it counts as older than a skill that needs that release.
func needsNewerCLI(s libskills.Skill) bool {
return s.MinCLIVer != "" && semver.Compare("v"+build.GetInfo().Version, "v"+s.MinCLIVer) < 0
}
Loading