Skip to content

skills read: end flags before a leading-hyphen file name - #8121

Merged
simonfaltum merged 4 commits into
mainfrom
skills/k2dash-printed-read-file-commands-survive-file
Nov 27, 2026
Merged

simonfaltum merged 4 commits into
mainfrom
skills/k2dash-printed-read-file-commands-survive-file

Conversation

@simonfaltum

@simonfaltum simonfaltum commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

databricks skills read prints a databricks skills read-file <name> <path> command for each supporting file. A name or path that starts with - was read by Cobra as a flag when an agent ran the printed command, so the file could not be read. This PR prints -- before the arguments in that case.

Changes

  • skills read prints databricks skills read-file -- <name> <path> when the skill name or the file path starts with -.
  • Other names print exactly as before, so existing output is unchanged.
  • read-file needs no change: Cobra already treats the arguments after -- as positional.

Why

A file such as -notes.md is listed in the manifest and the manifest checks accept it, but the printed command read-file guide-skill -notes.md fails with an unknown flag. Ending the flags with -- lets the printed command read the file as printed.

Decisions to review

  • -- is printed only when a name or path starts with -, not always. Always printing it would change the output for every skill, and the existing goldens with it. The cost is one extra branch in writeReadText.

Tests

  • TestWriteReadTextEndsFlagsBeforeLeadingHyphenFile covers a leading-hyphen file name, a leading-hyphen skill name, and a leading-hyphen file name that also needs quotes (Linux and Windows quoting), and checks that ordinary files on the same line keep their command.
  • acceptance/cmd/skills/read checks that the printed command for -notes.md (a file in the shared release fixture) appears in the output, then runs it with eval and checks that it prints the file. It also runs read-file -- guide-skill -notes.md directly.
  • acceptance/cmd/skills/disabled already checks that the skills group is not registered when DATABRICKS_SKILLS_PREVIEW is unset, so the change is behind the guard.
  • Not tested: the printed Windows form in Windows PowerShell 5.1, because the acceptance script runs in bash on the Windows CI cell.
  • go test ./cmd/skills/... ./libs/skills/... and go test ./acceptance -run TestAccept/cmd/skills pass, and ./task fmt-q lint-q is clean.

This pull request and its description were written by Isaac.

`skills read` printed `databricks skills read-file <name> <path>` for each
supporting file. A name or path that starts with "-" was read by Cobra as a
flag when the agent ran the printed command. Print "--" before the arguments
when the name or the file starts with "-". Ordinary names print as before.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: e73a6a04f | Workflow run

Selected 1 changed tests (limit=20, 0 not selected)

1 tests: regression=1 unreleased=0 coverage=0 failing=0
test branch main (4c4f104) latest (v1.28.0)
TestAccept/cmd/skills/read ✅ ❌ ❌
TestAccept/cmd/skills/read: branch ✅ | main (4c4f104) ❌ | latest (v1.28.0) ❌

main (4c4f104):

acceptance_test.go:1402: Diff:
        --- cmd/skills/read/output.txt
        +++ /tmp/TestAcceptcmdskillsread3256862024/002/output.txt
        @@ -13,57 +13,9 @@
         
         Other files in this skill, each read with its command:
           databricks skills read-file guide-skill references/guide.md
        -  databricks skills read-file -- guide-skill -notes.md
        +  databricks skills read-file guide-skill -notes.md
         
         === A file whose name starts with a hyphen: the printed command ends the flags and runs as printed
        +contains error: '  databricks skills read-file -- guide-skill -notes.md' not found in the output.
         
        ->>> eval databricks skills read-file -- guide-skill -notes.md
        -Notes that start with a hyphen.
        -
        -=== read-file accepts -- before a leading-hyphen file name
        -
        ->>> [CLI] skills read-file -- guide-skill -notes.md
        -Notes that start with a hyphen.
        -
        -=== A skill without supporting files
        -
        ->>> [CLI] skills read demo-skill
        ----
        -name: demo-skill
        -description: A skill for tests.
        ----
        -
        -# Demo skill
        -
        -=== JSON output, with and without supporting files
        -
        ->>> [CLI] skills read guide-skill -o json
        -{
        -  "name": "guide-skill",
        -  "version": "0.0.1",
        -  "source": "[TESTROOT]/cmd/skills/read/../release",
        -  "content": "---\nname: guide-skill\ndescription: A skill with a supporting file.\n---\n\n# Guide skill\n\nRead the guide in references for details.\n",
        -  "files": [
        -    "references/guide.md",
        -    "-notes.md"
        -  ]
        -}
        -
        ->>> [CLI] skills read demo-skill -o json
        -{
        -  "name": "demo-skill",
        -  "version": "0.0.1",
        -  "source": "[TESTROOT]/cmd/skills/read/../release",
        -  "content": "---\nname: demo-skill\ndescription: A skill for tests.\n---\n\n# Demo skill\n",
        -  "files": []
        -}
        -
        -=== An unknown skill exits non-zero and points at skills list
        -
        ->>> [CLI] skills read no-such-skill
        -Error: unknown skill "no-such-skill": run "databricks skills list" to see the available skills
        -
        -=== A skill that needs a newer CLI: the warning goes to stderr, the skill to stdout
        -
        ->>> [CLI] skills read future-skill
        -Warning: skill "future-skill" needs CLI version 99.0.0 or newer, this CLI is [CLI_VERSION]. Update the CLI to use it.
        +Exit code: 1
        
    acceptance_test.go:1373: Missing output file: out.stdout.txt
    acceptance_test.go:1180: 
        LOG.read: ---
        LOG.read: name: guide-skill
        LOG.read: description: A skill with a supporting file.
        LOG.read: ---
        LOG.read: 
        LOG.read: # Guide skill
        LOG.read: 
        LOG.read: Read the guide in references for details.
        LOG.read: 
        LOG.read: Other files in this skill, each read with its command:
        LOG.read:   databricks skills read-file guide-skill references/guide.md
        LOG.read:   databricks skills read-file guide-skill -notes.md
FAIL

latest (v1.28.0):

acceptance_test.go:1402: Diff:
        --- cmd/skills/read/output.txt
        +++ /tmp/TestAcceptcmdskillsread660090410/002/output.txt
        @@ -2,68 +2,6 @@
         === A skill with a supporting file: SKILL.md, then the file list
         
         >>> [CLI] skills read guide-skill
        ----
        -name: guide-skill
        -description: A skill with a supporting file.
        ----
        +Error: unknown command "skills" for "databricks"
         
        -# Guide skill
        -
        -Read the guide in references for details.
        -
        -Other files in this skill, each read with its command:
        -  databricks skills read-file guide-skill references/guide.md
        -  databricks skills read-file -- guide-skill -notes.md
        -
        -=== A file whose name starts with a hyphen: the printed command ends the flags and runs as printed
        -
        ->>> eval databricks skills read-file -- guide-skill -notes.md
        -Notes that start with a hyphen.
        -
        -=== read-file accepts -- before a leading-hyphen file name
        -
        ->>> [CLI] skills read-file -- guide-skill -notes.md
        -Notes that start with a hyphen.
        -
        -=== A skill without supporting files
        -
        ->>> [CLI] skills read demo-skill
        ----
        -name: demo-skill
        -description: A skill for tests.
        ----
        -
        -# Demo skill
        -
        -=== JSON output, with and without supporting files
        -
        ->>> [CLI] skills read guide-skill -o json
        -{
        -  "name": "guide-skill",
        -  "version": "0.0.1",
        -  "source": "[TESTROOT]/cmd/skills/read/../release",
        -  "content": "---\nname: guide-skill\ndescription: A skill with a supporting file.\n---\n\n# Guide skill\n\nRead the guide in references for details.\n",
        -  "files": [
        -    "references/guide.md",
        -    "-notes.md"
        -  ]
        -}
        -
        ->>> [CLI] skills read demo-skill -o json
        -{
        -  "name": "demo-skill",
        -  "version": "0.0.1",
        -  "source": "[TESTROOT]/cmd/skills/read/../release",
        -  "content": "---\nname: demo-skill\ndescription: A skill for tests.\n---\n\n# Demo skill\n",
        -  "files": []
        -}
        -
        -=== An unknown skill exits non-zero and points at skills list
        -
        ->>> [CLI] skills read no-such-skill
        -Error: unknown skill "no-such-skill": run "databricks skills list" to see the available skills
        -
        -=== A skill that needs a newer CLI: the warning goes to stderr, the skill to stdout
        -
        ->>> [CLI] skills read future-skill
        -Warning: skill "future-skill" needs CLI version 99.0.0 or newer, this CLI is [CLI_VERSION]. Update the CLI to use it.
        +Exit code: 1
        
    acceptance_test.go:1373: Missing output file: out.stdout.txt
FAIL

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: e73a6a0

Run: 46040794245

Env ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 174 18 3:58
✅​ aws-windows-latest-4core-16gb 174 18 2:45
✅​ azure linux-2core-8gb 173 18 3:22
✅​ azure-windows-latest-4core-16gb 173 18 3:09
✅​ gcp linux-2core-8gb 174 18 3:25
✅​ gcp-windows-latest-4core-16gb 174 18 3:27
Top 6 slowest tests (at least 2 minutes):
duration env testname
3:58 aws linux-2core-8gb TestAccept
3:26 gcp-windows-latest-4core-16gb TestAccept
3:20 azure linux-2core-8gb TestAccept
3:18 gcp linux-2core-8gb TestAccept
3:08 azure-windows-latest-4core-16gb TestAccept
2:44 aws-windows-latest-4core-16gb TestAccept

@simonfaltum
simonfaltum marked this pull request as ready for review November 27, 2026 14:36
@simonfaltum
simonfaltum requested a review from a team as a code owner November 27, 2026 14:36

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at 4243c2a. Each finding was verified against the code.

No blocking issues found. 4 non-blocking comment(s) below.

This PR makes skills read print databricks skills read-file -- <name> <path> when the skill name or file path starts with -, so Cobra no longer treats it as an unknown flag. The Go change is correct: the check runs on the raw name and path, unquotable entries are still listed without a command, and other lines print exactly as before. What's left is in the new acceptance test, which doesn't follow the repo's testing rules. It adds a new directory where the existing read test could be extended, it repeats settings the parent test.toml already has, and it uses an inline grep. Its last block also repeats a check the eval block already makes.

Comments outside the changed lines

  • [nit] acceptance/cmd/skills/hyphen/script:65: This block runs the same read-file -- demo-skill -notes.md that the eval block already ran from the printed line, so it only re-tests Cobra's -- handling. Can you drop it, or replace it with musterr trace $CLI skills read-file demo-skill -notes.md to record the unknown-flag error this PR works around?

Comment thread acceptance/cmd/skills/hyphen/script Outdated
@@ -0,0 +1,11 @@
# The printed read-file command ends the flags, so a file named -notes.md is read.

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] acceptance/cmd/skills/read already covers the file commands skills read prints, using the shared release fixture. testing.md asks to extend the existing acceptance directory when coverage overlaps. Can you add a -notes.md file to a skill in acceptance/cmd/skills/release and a case to read/script, instead of adding a new hyphen/ directory with its own manifest and skill?

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 2a5b94f. The separate hyphen/ directory is removed. The -notes.md file now lives in guide-skill in the shared release fixture (listed in its manifest), and the cases are in read/script, so only read/output.txt changed (guide-skill file list and its -o json output). The unit test in read_test.go is unchanged.

Comment thread acceptance/cmd/skills/hyphen/script Outdated

title "the printed command runs as printed and prints the file"
databricks() { "$CLI" "$@"; }
line=$($CLI skills read demo-skill | grep -- '-notes.md')

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] testing.md says to use the acceptance/bin/ helpers instead of inline grep pipelines. If the -notes.md line ever goes missing from the output, grep returns nothing and eval "" succeeds silently, so the problem only shows up later as a golden diff. The first trace already records the printed line. Can you drop the grep, or assert the line with contains.py before running it?

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 2a5b94f. The grep pipeline is gone. The script now asserts the printed line with contains.py before it runs it with eval, so a missing line fails at that step rather than as a silent empty eval.

Comment thread acceptance/cmd/skills/hyphen/test.toml Outdated
@@ -0,0 +1,3 @@
Cloud = false

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/test.toml already sets Cloud = false and Env.DATABRICKS_SKILLS_PREVIEW = "1", and both are inherited. Only Env.DATABRICKS_SKILLS_DIR needs to stay here.

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 2a5b94f. The hyphen/ directory and its test.toml are removed. The case now runs in read/, which inherits Cloud = false and DATABRICKS_SKILLS_PREVIEW from acceptance/cmd/skills/test.toml, and read/script sets DATABRICKS_SKILLS_DIR.

Move the printed read-file case into the existing read acceptance test,
using the shared release fixture, instead of a separate hyphen directory.
The printed command is asserted with contains.py before it is run, and
the separate test.toml is dropped because the parent directory sets the
same variables.

Co-authored-by: Isaac <no-reply@databricks.com>

@rugpanov rugpanov left a comment

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.

No blocking findings. The new branch in writeReadText checks the raw name and path, so it also works for a value that needs quotes. Lines that do not start with a hyphen print as before.

Risk: LOW. The only production change is a 6-line branch in cmd/skills/read.go. The skills group is hidden and gated by DATABRICKS_SKILLS_PREVIEW. The change has unit and acceptance tests, CI is green, and a revert is simple.

libs/skills/hints.go:52 [nice to have] The help hint prints databricks skills read %s with the raw skill name. CheckManifestPaths accepts a skill name that starts with -. For a skill -foo, the hint prints databricks skills read -foo, and Cobra rejects it as an unknown flag. Add the same -- rule here. As an alternative, reject a leading - in skill names and file path segments in CheckManifestPaths. That covers all printers at once.

Comment thread acceptance/cmd/skills/read/script Outdated
title "A file whose name starts with a hyphen: the printed command ends the flags and runs as printed"
databricks() { "$CLI" "$@"; }
line="databricks skills read-file -- guide-skill -notes.md"
$CLI skills read guide-skill | contains.py " $line" > /dev/null

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 line sends the contains.py output to /dev/null. .agents/rules/testing.md says to route noisy output to LOG.<name> instead of /dev/null. Then go test -v shows the checked text when the check fails. Change > /dev/null to > LOG.read.

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.

Changed in c18cfe7: the check now sends its contains.py output to LOG.read instead of /dev/null, so go test -v shows the text when the check fails.

Comment thread cmd/skills/read_test.go
assert.Contains(t, out.String(), " databricks skills read-file guide-skill \"references/my guide.md\"\n")
}

func TestWriteReadTextEndsFlagsBeforeLeadingHyphenFile(t *testing.T) {

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] No case uses a leading-hyphen value that also needs quotes, for example -my notes.md. If the check later uses quotedFile or quotedName, all current cases still pass. Add a case with such a file for linux and windows, as TestWriteReadTextQuotesFileCommands does.

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 c18cfe7: TestWriteReadTextEndsFlagsBeforeLeadingHyphenFile now covers a leading-hyphen file that needs quotes, -my notes.md, for Linux ('-my notes.md') and Windows ("-my notes.md"). The check uses the raw name and path, so the -- branch is the same for quoted values.

Comment thread cmd/skills/read.go
fmt.Fprintf(&b, " databricks skills read-file %s %s\n", quotedName, quotedFile)
// A leading "-" would make Cobra read the name or file as a flag, so "--" ends the flags first.
endOfFlags := ""
if strings.HasPrefix(name, "-") || strings.HasPrefix(f, "-") {

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.

[Question] Did you run the printed databricks skills read-file -- guide-skill -notes.md line in Windows PowerShell 5.1? Windows PowerShell can change native arguments that start with -, and the Windows CI runs the acceptance script in bash. The answer tells if the printed command runs as printed on Windows.

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.

No, I did not run the printed command in Windows PowerShell 5.1, and this environment has no Windows PowerShell. The Windows CI runs the acceptance script in bash, so it does not cover PowerShell either. The Windows unit test only checks the printed text. This is unverified, and I made no code change for it. The printed form is the one the ticket asks for.

The help footer printed the skill name unquoted, so a skill named with a
leading hyphen was read by Cobra as a flag. Print "--" first in that case.
Also add a quoted leading-hyphen file case and send the acceptance check's
output to LOG.read.

Co-authored-by: Isaac <no-reply@databricks.com>
@simonfaltum

simonfaltum commented Nov 27, 2026 •

Copy link
Copy Markdown
Member Author

Note on the review body item about the help footer (libs/skills/hints.go): the footer fix is in #8127, not this PR. #8127 prints -- for a leading-hyphen skill name in the footer. #8132 then skips names the installer rejects, so that footer line is not printed for them. This PR no longer changes libs/skills.

The help footer's leading-hyphen handling moves to the stacked pull request
that owns the footer, so this branch no longer changes libs/skills.

Co-authored-by: Isaac <no-reply@databricks.com>
@simonfaltum
simonfaltum added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit a0805a0 Nov 27, 2026
27 checks passed
@simonfaltum
simonfaltum deleted the skills/k2dash-printed-read-file-commands-survive-file branch November 27, 2026 17:57
simonfaltum added a commit that referenced this pull request Nov 27, 2026
…-before

Brings in the squash-merged skills read change (#8121). Its
acceptance manifest conflicted with this branch's hyphen fixture;
the branch side is kept, which adds the -foo skill.

Co-authored-by: Isaac <no-reply@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants