Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4243c2a
cmd/skills: end flags before a leading-hyphen file in read output
simonfaltum Nov 27, 2026
2d36604
libs/skills: end flags before a leading-hyphen skill name in the grou…
simonfaltum Nov 27, 2026
2a5b94f
cmd/skills: cover a leading-hyphen file in the read acceptance test
simonfaltum Nov 27, 2026
7f56db9
libs/skills: test the group footer through the real jobs command
simonfaltum Nov 27, 2026
e1931fe
libs/skills: leave out skills whose names the installer rejects
simonfaltum Nov 27, 2026
ca906e3
Merge k2dash base tip into k2hint
simonfaltum Nov 27, 2026
6893f66
Merge commit '7f56db955' into skills/kname-the-skills-catalog-skips-s…
simonfaltum Nov 27, 2026
6403bb5
acceptance: leave the leading-hyphen skill out of the shared release
simonfaltum Nov 27, 2026
f9d6226
Merge skills/k2hint-the-group-help-footer-ends-flags-before into skil…
simonfaltum Nov 27, 2026
91029cf
libs/skills: check the skill name in ReadFile and reword the name docs
simonfaltum Nov 27, 2026
c18cfe7
skills: end flags in the help hint for a leading-hyphen skill name
simonfaltum Nov 27, 2026
e580301
libs/skills: fold the preview-off check into the hint table
simonfaltum Nov 27, 2026
e73a6a0
skills: leave the help footer to the stacked change
simonfaltum Nov 27, 2026
68ee73a
Merge commit 'e73a6a04f' into skills/k2hint-the-group-help-footer-end…
simonfaltum Nov 27, 2026
ef83edd
Merge the parent branch tip 68ee73a7d
simonfaltum Nov 27, 2026
c84a3c4
Merge origin/main into skills/k2hint-the-group-help-footer-ends-flags…
simonfaltum Nov 27, 2026
40353c0
Merge origin/main into skills/k2hint-the-group-help-footer-ends-flags…
simonfaltum Nov 27, 2026
c625005
Merge the parent branch tip 40353c0d4
simonfaltum Nov 27, 2026
4276299
Merge origin/main into skills/kname-the-skills-catalog-skips-skill-na…
simonfaltum Nov 28, 2026
233bb76
skills: drop the redundant test.toml lines and the preview-off case
simonfaltum Nov 30, 2026
d52e263
skills: drop invalid skill names once when the manifest is read
simonfaltum Nov 30, 2026
2f77918
Merge origin/main into skills/kname-the-skills-catalog-skips-skill-na…
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
24 changes: 0 additions & 24 deletions acceptance/cmd/skills/list/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Pick the skill whose description matches the task.
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.
guide-skill: A skill with a supporting file.
Expand All @@ -13,7 +12,6 @@ To read a skill, run: databricks skills read <name>
Pick the skill whose description matches the task.
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.
guide-skill: A skill with a supporting file.
Expand All @@ -25,17 +23,6 @@ To read a skill, run: databricks skills read <name>
"source": "[TESTROOT]/cmd/skills/release",
"release_version": "0.0.1",
"skills": [
{
"name": "-foo",
"description": "A skill whose name starts with a hyphen.",
"version": "0.0.1",
"files": [
"SKILL.md"
],
"commands": [
"jobs"
]
},
{
"name": "demo-skill",
"description": "A skill for tests.",
Expand Down Expand Up @@ -76,17 +63,6 @@ To read a skill, run: databricks skills read <name>
"source": "[TESTROOT]/cmd/skills/release",
"release_version": "0.0.1",
"skills": [
{
"name": "-foo",
"description": "A skill whose name starts with a hyphen.",
"version": "0.0.1",
"files": [
"SKILL.md"
],
"commands": [
"jobs"
]
},
{
"name": "demo-skill",
"description": "A skill for tests.",
Expand Down
3 changes: 1 addition & 2 deletions acceptance/cmd/skills/release/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"demo-skill": {"version": "0.0.1", "description": "A skill for tests.", "files": ["SKILL.md"], "commands": ["fs", "air"]},
"guide-skill": {"version": "0.0.1", "description": "A skill with a supporting file.", "files": ["SKILL.md", "references/guide.md", "-notes.md"]},
"future-skill": {"version": "0.0.1", "description": "A skill that needs a newer CLI.", "files": ["SKILL.md"], "min_cli_version": "99.0.0"},
"preview-skill": {"version": "0.0.2", "description": "An experimental skill for tests.", "files": ["SKILL.md"], "repo_dir": "experimental"},
"-foo": {"version": "0.0.1", "description": "A skill whose name starts with a hyphen.", "files": ["SKILL.md"], "commands": ["jobs"]}
"preview-skill": {"version": "0.0.2", "description": "An experimental skill for tests.", "files": ["SKILL.md"], "repo_dir": "experimental"}
}
}
6 changes: 0 additions & 6 deletions acceptance/cmd/skills/release/skills/-foo/SKILL.md

This file was deleted.

8 changes: 8 additions & 0 deletions acceptance/help/skills/hints-invalid-name/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": "0.0.1",
"skills": {
"-foo": {"version": "0.0.1", "description": "A skill whose name starts with a hyphen.", "files": ["SKILL.md"], "commands": ["jobs"]},
"a b": {"version": "0.0.1", "description": "A skill whose name has a space.", "files": ["SKILL.md"], "commands": ["jobs"]},
"alpha": {"version": "0.0.1", "description": "A valid skill.", "files": ["SKILL.md"], "commands": ["jobs"]}
}
}
1 change: 1 addition & 0 deletions acceptance/help/skills/hints-invalid-name/out.test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cloud = false
15 changes: 15 additions & 0 deletions acceptance/help/skills/hints-invalid-name/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

>>> [CLI] jobs --help
Use "databricks jobs [command] --help" for more information about a command.

Coding agents: read the skills for this command group before you use it.
databricks skills read alpha

>>> [CLI] skills read -- -foo
Error: unknown skill "-foo": run "databricks skills list" to see the available skills

>>> [CLI] skills read-file -- -foo SKILL.md
Error: unknown skill: "-foo"

>>> [CLI] skills read a b
Error: unknown skill "a b": run "databricks skills list" to see the available skills
7 changes: 7 additions & 0 deletions acceptance/help/skills/hints-invalid-name/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The footer lists only the skills whose names the installer accepts. "-foo" and "a b" are left out, so no printed command starts with a flag or needs quotes.
trace $CLI jobs --help | tail -n 4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nice to have] The user-visible change is that skills read -- -foo and skills read-file -- -foo SKILL.md now fail. The old script ran the printed command, but this one only records the footer, so no golden shows the new error. Could you add musterr $CLI skills read -- -foo and musterr $CLI skills read-file -- -foo SKILL.md here? The directory already has the manifest. An "a b" entry would also cover the space case.

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 e580301. The hints acceptance test now runs skills read -- -foo, skills read-file -- -foo SKILL.md and skills read "a b" under musterr, so their unknown skill errors are in the golden. The manifest adds an "a b" entry for the space case, and the footer is unchanged.


# The catalog leaves those names out, so reading them fails as an unknown skill.
musterr trace $CLI skills read -- -foo
musterr trace $CLI skills read-file -- -foo SKILL.md
musterr trace $CLI skills read "a b"
2 changes: 2 additions & 0 deletions acceptance/help/skills/hints-invalid-name/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Env.DATABRICKS_SKILLS_DIR = "."
Env.DATABRICKS_SKILLS_HINTS = "1"
14 changes: 0 additions & 14 deletions acceptance/help/skills/hints/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,3 @@ Coding agents: read the skills for this command group before you use it.
>>> [CLI] auth --help

>>> [CLI] fs ls --help

>>> [CLI] jobs --help
Use "databricks jobs [command] --help" for more information about a command.

Coding agents: read the skills for this command group before you use it.
databricks skills read -- -foo

>>> eval databricks skills read -- -foo
---
name: -foo
description: A skill whose name starts with a hyphen.
---

# Foo skill
7 changes: 0 additions & 7 deletions acceptance/help/skills/hints/script
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,3 @@ trace $CLI auth --help | contains.py "!databricks skills" > /dev/null

# A leaf command under a mapped group gets no footer of its own.
trace $CLI fs ls --help | contains.py "!databricks skills" > /dev/null

# A skill whose name starts with "-" ends the flags before it, so the printed command runs as printed.
databricks() { "$CLI" "$@"; }
trace $CLI jobs --help | tail -n 4
line="databricks skills read -- -foo"
$CLI jobs --help | contains.py " $line" > LOG.read
trace eval "$line"
16 changes: 8 additions & 8 deletions cmd/skills/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ func otherFiles(files []string) []string {
}

// writeReadText writes SKILL.md, with a trailing newline added if it is missing,
// then the other files with the command that reads each one. The commands are
// quoted for the shell of goos. A name or file that no quoting keeps literal
// is listed without its command. Nothing else goes to stdout.
// then the other files with the command that reads each one. The name is a
// skill name the catalog lists, so it is printed as it is. The file is quoted
// for the shell of goos. A file that no quoting keeps literal is listed without
// its command. Nothing else goes to stdout.
func writeReadText(w io.Writer, goos, name string, content []byte, files []string) error {
var b strings.Builder
b.Write(content)
Expand All @@ -115,19 +116,18 @@ func writeReadText(w io.Writer, goos, name string, content []byte, files []strin
}
if len(files) > 0 {
b.WriteString("\nOther files in this skill, each read with its command:\n")
quotedName, nameOK := shellquote.Arg(goos, name)
for _, f := range files {
quotedFile, fileOK := shellquote.Arg(goos, f)
if !nameOK || !fileOK {
if !fileOK {
fmt.Fprintf(&b, " %s\n", f)
continue
}
// A leading "-" would make Cobra read the name or file as a flag, so "--" ends the flags first.
// A leading "-" would make Cobra read the file as a flag, so "--" ends the flags first.
endOfFlags := ""
if strings.HasPrefix(name, "-") || strings.HasPrefix(f, "-") {
if strings.HasPrefix(f, "-") {
endOfFlags = "-- "
}
fmt.Fprintf(&b, " databricks skills read-file %s%s %s\n", endOfFlags, quotedName, quotedFile)
fmt.Fprintf(&b, " databricks skills read-file %s%s %s\n", endOfFlags, name, quotedFile)

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] The skill name is now printed raw because "the catalog lists" only valid names. That is true today: every Source wraps fsSource, and runRead looks the name up in the catalog first. But the Source interface doesn't promise it, and the test for the -guide-skill case was deleted. One option is to keep a cheap check, libskills.IsSkillName(name), before printing the commands. Another is to state the guarantee on the Catalog.Skills field as a contract every Source must meet. Either way, a new source can't bring back flag-like names in printed commands without anyone noticing.

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 d52e263 as the contract option: the Catalog.Skills comment now says every name there is safe to print in a command and that a Source must meet this. The manifest-level filter means fsSource, which every Source wraps, meets it. Kept the print path unchanged.

}
}
_, err := io.WriteString(w, b.String())
Expand Down
5 changes: 0 additions & 5 deletions cmd/skills/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ func TestWriteReadTextEndsFlagsBeforeLeadingHyphenFile(t *testing.T) {
require.NoError(t, err)
assert.Contains(t, out.String(), " databricks skills read-file -- guide-skill -notes.md\n databricks skills read-file guide-skill references/ok.md\n")

out.Reset()
err = writeReadText(&out, "linux", "-guide-skill", []byte("# Guide\n"), []string{"references/ok.md"})
require.NoError(t, err)
assert.Contains(t, out.String(), " databricks skills read-file -- -guide-skill references/ok.md\n")

out.Reset()
err = writeReadText(&out, "linux", "guide-skill", []byte("# Guide\n"), []string{"-my notes.md"})
require.NoError(t, err)
Expand Down
19 changes: 2 additions & 17 deletions libs/aitools/installer/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (
"io"
"net/http"
"path"
"regexp"
"strings"
"sync"
"time"

"github.com/databricks/cli/libs/clicompat"
Expand Down Expand Up @@ -72,19 +70,6 @@ func (s *GitHubManifestSource) FetchManifest(ctx context.Context, ref string) (*
return &manifest, nil
}

// maxSkillNameLength is the Agent Skills limit on the length of a skill name.
const maxSkillNameLength = 64

// skillNamePattern is the Agent Skills name format
// (https://agentskills.io/specification#name-field): lowercase letters, digits
// and single hyphens. Every name is a directory under the skills dir, next to
// the installer's state file, so the format also keeps names from aliasing each
// other on case-insensitive filesystems or through Windows trailing dots and
// spaces.
var skillNamePattern = sync.OnceValue(func() *regexp.Regexp {
return regexp.MustCompile(`^[a-z0-9]+(-[a-z0-9]+)*$`)
})

// unportableSkill returns why a skill that stays inside its directory still
// cannot be installed the same way on every OS, or "" if it can. Install skips
// such a skill and update keeps the installed copy, the way both treat a skill
Expand All @@ -95,8 +80,8 @@ var skillNamePattern = sync.OnceValue(func() *regexp.Regexp {
// may differ only in case, and no path may be both a file and a folder: either
// would merge or collide on a case-insensitive filesystem.
func unportableSkill(name string, files []string) string {
if len(name) > maxSkillNameLength || !skillNamePattern().MatchString(name) {
return fmt.Sprintf("the name is not at most %d lowercase letters, digits and single hyphens", maxSkillNameLength)
if !skills.IsSkillName(name) {

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] This PR touches libs/aitools, and .agents/rules/aitools-verification.md says to run ./task aitools-full before opening the PR. The Tests section lists only targeted go test runs and fmt-q lint-q. Could you run it, or note it in the description? CI test-exp-aitools (linux) passed and macOS was still pending.

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.

Ran ./task aitools-full at d52e263: lint, tests, acceptance and deadcode all pass.

return fmt.Sprintf("the name is not at most %d lowercase letters, digits and single hyphens", skills.MaxSkillNameLength)
}
if isWindowsDeviceName(name) {
return "the name is a reserved Windows device name"
Expand Down
12 changes: 11 additions & 1 deletion libs/skills/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"path"
"slices"
"time"

"github.com/databricks/cli/libs/log"
)

const manifestFile = "manifest.json"
Expand Down Expand Up @@ -112,7 +114,9 @@ func (s *fsSource) filePath(ctx context.Context, skill, file string) (string, er
}

// manifest reads and checks the release manifest. Every path it names, the
// skill files, repo_dir and catalog_rules, must stay inside the release.
// skill files, repo_dir and catalog_rules, must stay inside the release. It
// drops the skills whose name the installer would reject, so every reader sees
// the same skills.
func (s *fsSource) manifest(ctx context.Context) (*Manifest, error) {
data, err := s.read(ctx, manifestFile)
if errors.Is(err, ErrManifestTooLarge) || errors.Is(err, errReleaseNotFound) {
Expand All @@ -129,5 +133,11 @@ func (s *fsSource) manifest(ctx context.Context) (*Manifest, error) {
if err := CheckManifest(&m); err != nil {
return nil, err
}
for _, name := range slices.Sorted(maps.Keys(m.Skills)) {
if !IsSkillName(name) {
log.Debugf(ctx, "skills catalog: skipping skill %q: the name is not a valid skill name", name)
delete(m.Skills, name)
}
}
return &m, nil
}
35 changes: 35 additions & 0 deletions libs/skills/fs_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package skills

import (
"io/fs"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -52,6 +53,40 @@ func TestCatalogFromFixture(t *testing.T) {
}, catalog.Skills[1])
}

func TestCatalogLeavesOutSkillNamesTheInstallerRejects(t *testing.T) {
src := mapSource(`{"version": "1.0.0", "skills": {
"alpha": {"version": "1.0.0", "files": ["SKILL.md"]},
"-foo": {"version": "1.0.0", "files": ["SKILL.md"]},
"a b": {"version": "1.0.0", "files": ["SKILL.md"]}}}`)
catalog, err := src.Catalog(t.Context())
require.NoError(t, err)

require.Len(t, catalog.Skills, 1)
assert.Equal(t, "alpha", catalog.Skills[0].Name)
}

func TestReadFileRejectsSkillNameTheCatalogLeavesOut(t *testing.T) {
src := mapSource(`{"version": "1.0.0", "skills": {
"alpha": {"version": "1.0.0", "files": ["SKILL.md"]},
"-foo": {"version": "1.0.0", "files": ["SKILL.md"]}}}`)

_, err := src.ReadFile(t.Context(), "-foo", "SKILL.md")
assert.ErrorIs(t, err, ErrUnknownSkill)

_, err = src.ReadFile(t.Context(), "alpha", "SKILL.md")
require.Error(t, err)
assert.ErrorIs(t, err, fs.ErrNotExist)
}

func TestIsSkillName(t *testing.T) {
for _, name := range []string{"a", "alpha", "databricks-core", "skill2", strings.Repeat("a", MaxSkillNameLength)} {
assert.True(t, IsSkillName(name), name)
}
for _, name := range []string{"", "-foo", "a b", "Alpha", "a--b", "a_b", "a/b", "a.b", strings.Repeat("a", MaxSkillNameLength+1)} {
assert.False(t, IsSkillName(name), name)
}
}

func TestReadFiles(t *testing.T) {
src := fixtureSource()

Expand Down
8 changes: 1 addition & 7 deletions libs/skills/hints.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io"
"slices"
"strings"

"github.com/databricks/cli/libs/log"
)
Expand Down Expand Up @@ -50,11 +49,6 @@ func WriteGroupHint(ctx context.Context, w io.Writer, group string) {
fmt.Fprintln(w)
fmt.Fprintln(w, "Coding agents: read the skills for this command group before you use it.")
for _, name := range names {
// A leading "-" would make Cobra read the name as a flag, so "--" ends the flags first.
endOfFlags := ""
if strings.HasPrefix(name, "-") {
endOfFlags = "-- "
}
fmt.Fprintf(w, " databricks skills read %s%s\n", endOfFlags, name)
fmt.Fprintf(w, " databricks skills read %s\n", name)
}
}
19 changes: 6 additions & 13 deletions libs/skills/hints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"

"github.com/databricks/cli/internal/testutil"
"github.com/databricks/cli/libs/env"
"github.com/spf13/pflag"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -43,9 +41,11 @@ func TestWriteGroupHint(t *testing.T) {
}
}

func TestWriteGroupHintRunsLeadingHyphenSkillAsPrinted(t *testing.T) {
func TestWriteGroupHintLeavesOutSkillNameTheInstallerRejects(t *testing.T) {

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] This test uses the same -foo/alpha manifest and asserts the same footer as acceptance/help/skills/hints-invalid-name. TestCatalogLeavesOutSkillNamesTheInstallerRejects already covers the filtering. testing.md says not to add a unit test that only duplicates an acceptance test, so can this one go?

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.

Kept. The ticket names this test: its acceptance criteria ask for the footer line in the k2hint test to use require.Equal. The acceptance test runs the CLI, while this one calls WriteGroupHint directly with a manifest that has the hyphen name, so it is not only a copy. No code change.

dir := t.TempDir()
const manifest = `{"version": "1.0.0", "skills": {"-foo": {"version": "1.0.0", "description": "A skill whose name starts with a hyphen.", "files": ["SKILL.md"], "commands": ["jobs"]}}}`
const manifest = `{"version": "1.0.0", "skills": {
"-foo": {"version": "1.0.0", "description": "A skill whose name starts with a hyphen.", "files": ["SKILL.md"], "commands": ["jobs"]},
"alpha": {"version": "1.0.0", "description": "A valid skill.", "files": ["SKILL.md"], "commands": ["jobs"]}}}`
require.NoError(t, os.WriteFile(filepath.Join(dir, "manifest.json"), []byte(manifest), 0o644))

ctx := env.Set(t.Context(), "DATABRICKS_SKILLS_DIR", dir)
Expand All @@ -54,15 +54,8 @@ func TestWriteGroupHintRunsLeadingHyphenSkillAsPrinted(t *testing.T) {

var buf bytes.Buffer
WriteGroupHint(ctx, &buf, "jobs")
assert.Equal(t, "\nCoding agents: read the skills for this command group before you use it.\n"+
" databricks skills read -- -foo\n", buf.String())

// The printed command, minus "databricks skills read", must parse to the name, not to flags.
printed := strings.Fields(buf.String())
args := printed[len(printed)-2:]
fs := pflag.NewFlagSet("read", pflag.ContinueOnError)
require.NoError(t, fs.Parse(args))
assert.Equal(t, []string{"-foo"}, fs.Args())
require.Equal(t, "\nCoding agents: read the skills for this command group before you use it.\n"+

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] This is the test's last check of the result, not a precondition, so per testing.md it should be assert.Equal. The same applies to require.Empty at line 75.

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.

Kept require.Equal. The ticket asks for require.Equal on this footer line, and that is the acceptance criterion this change is checked against. testing.md would use assert for a last check, so if the owner prefers that, it is a one-word change. No code change in this push.

" databricks skills read alpha\n", buf.String())
}

// With the preview unset, a non-empty bundled copy must not produce a footer,
Expand Down
Loading
Loading