Repository navigation
skills list and search JSON carry experimental, rules and stale - #8139
simonfaltum wants to merge 36 commits into
Conversation
Skill sources need the manifest type and its path checks, and the libs-no-aitools lint rule keeps shared libs from importing the installer. Move Manifest, SkillMeta, NormalizeManifest, CheckManifestPaths, EscapesDir and ErrUnsafeManifestPath down into libs/skills; the installer uses them from there through aliases. Add the Skill and Catalog types, the Source interface, sentinel errors, and NewFSSource over any fs.FS laid out like a skills release. The manifest accepts optional per-skill commands and a top-level catalog_rules file. Co-authored-by: Isaac <no-reply@databricks.com>
The installer and libs/skills both reserve .state.json. Define the name once in libs/skills and have the installer use it. Co-authored-by: Isaac <no-reply@databricks.com>
The Windows CI checkout turns the LF fixtures into CRLF, so the exact content assertions failed. Normalize line endings before comparing. Co-authored-by: Isaac <no-reply@databricks.com>
Clean catalog_rules before reading it, expose min_cli_version on Skill, document the Catalog fields and the release-relative paths the manifest may name. Co-authored-by: Isaac <no-reply@databricks.com>
Register the hidden skills command group only when DATABRICKS_SKILLS_PREVIEW is set. Its five subcommands are stubs that report they are not implemented yet. Add guards for the feature and for its hints switch, DATABRICKS_SKILLS_HINTS, and a resolver for the folder in DATABRICKS_SKILLS_DIR, with an acceptance fixture release that later changes reuse. With the variable unset, the command group is not registered and nothing else changes. Co-authored-by: Isaac <no-reply@databricks.com>
The text output shows the catalog rules, one line per skill and a line on how to read a skill. Descriptions are cut at a word boundary to the widest width that keeps the output under a fixed budget, and only names are printed when the names alone do not fit. The JSON output carries the full catalog. Experimental skills are listed only with --experimental. A stale catalog prints a provenance line on stderr. The shared release fixture gains a catalog rules file and an experimental skill. Co-authored-by: Isaac <no-reply@databricks.com>
Skill sources need the manifest type and its path checks, and the libs-no-aitools lint rule keeps shared libs from importing the installer. Move Manifest, SkillMeta, NormalizeManifest, CheckManifestPaths, EscapesDir and ErrUnsafeManifestPath down into libs/skills; the installer uses them from there through aliases. Add the Skill and Catalog types, the Source interface, sentinel errors, and NewFSSource over any fs.FS laid out like a skills release. The manifest accepts optional per-skill commands and a top-level catalog_rules file. Co-authored-by: Isaac <no-reply@databricks.com>
The installer and libs/skills both reserve .state.json. Define the name once in libs/skills and have the installer use it. Co-authored-by: Isaac <no-reply@databricks.com>
The Windows CI checkout turns the LF fixtures into CRLF, so the exact content assertions failed. Normalize line endings before comparing. Co-authored-by: Isaac <no-reply@databricks.com>
Clean catalog_rules before reading it, expose min_cli_version on Skill, document the Catalog fields and the release-relative paths the manifest may name. Co-authored-by: Isaac <no-reply@databricks.com>
Keep the path helper unexported since only libs/skills calls it, reject a catalog_rules path that cleans to a directory, and test a missing rules file. Drop the min_cli_version field, which is not in the skill interface the package needs yet. Co-authored-by: Isaac <no-reply@databricks.com>
Skill now has MinCLIVer, read from the manifest's min_cli_version, so a caller can apply the same rule install uses. The fixture covers it. Co-authored-by: Isaac <no-reply@databricks.com>
Register the hidden skills command group only when DATABRICKS_SKILLS_PREVIEW is set. Its five subcommands are stubs that report they are not implemented yet. Add guards for the feature and for its hints switch, DATABRICKS_SKILLS_HINTS, and a resolver for the folder in DATABRICKS_SKILLS_DIR, with an acceptance fixture release that later changes reuse. With the variable unset, the command group is not registered and nothing else changes. Co-authored-by: Isaac <no-reply@databricks.com>
…ar-w Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
…ests Check the skills group in the root command uniqueness test, even though it is registered only behind DATABRICKS_SKILLS_PREVIEW. Clear both guard variables in the guard tests so an exported value does not leak in. LocalCatalog calls Resolve first and maps ErrNoSource to no catalog. Route the acceptance help check to LOG.help. Co-authored-by: Isaac <no-reply@databricks.com>
Text output shows the catalog rules, then one line per skill with its description cut to fit a fixed budget, then how to read a skill. JSON output carries the full catalog with empty lists as []. Experimental skills are listed only with --experimental. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Stop the description search at the narrowest width that keeps the first word of every description, so no line is left as "name: ...". Print the "left out" hint only when a description is actually left out. Render the JSON through cmdio.Render like other commands, and drop the unit test that duplicated the acceptance output. The list keeps the order the source serves, which is sorted by name. Co-authored-by: Isaac <no-reply@databricks.com>
Takes main's version of the skills command group (c2) and keeps this branch's list implementation, its fixtures and the experimental preview skill in the release fixture. Co-authored-by: Isaac <no-reply@databricks.com>
Keep the skills list fixtures on top of the merged release fixture: the enabled script no longer stubs list, the release manifest keeps the experimental preview skill next to the read fixtures, and the resolve test counts the whole catalog. Co-authored-by: Isaac <no-reply@databricks.com>
skills list now runs, so the test's skills list call fails with the no-source error instead of the not-implemented stub message. The test only checks that no hint is printed, so update the comment and golden. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Drop the enabled script's stubs for list-files and read-file, which are implemented now, and remove the unused notImplemented helper. Regenerate the list golden for the release fixture's demo-skill commands. Co-authored-by: Isaac <no-reply@databricks.com>
- Cut each description at a word boundary. A skill whose description has no boundary within the width is listed by name alone, so one long description does not drop the rest of the catalog. - Collapse whitespace in text output so every skill takes one line. - Print the provenance line through cmdio.LogString, and leave out the fetch time when it is unknown, as for a bundled copy. - Use forward slashes in the JSON source label, as skills search does. - Hint at --experimental when every skill is experimental. - Drop the acceptance test.toml that repeats the parent's settings. Co-authored-by: Isaac <no-reply@databricks.com>
The text length is not monotonic in width: a wider width can drop the search hint, so a binary search could settle on a narrower width than one that fits. Try each width from the widest down instead, and add a test whose widths 35 to 37 are over the budget and 38 fits. Co-authored-by: Isaac <no-reply@databricks.com>
When the names alone do not fit the budget, no description width can fit either, so return the names-only text without trying each width. The early return only applies when the names do not fit even with the search hint, since a wider width can leave that hint out. Change the widest-width test data so that a binary search settles on a narrower width whose output differs. The old search passed this test by landing on a width whose output matched the widest fitting one. Co-authored-by: Isaac <no-reply@databricks.com>
skills list and skills search print the same JSON envelope and per-skill fields from one type. The envelope gains stale and fetched_at, so a stale catalog says so in JSON, and rules, the text the text output prints above the list. Each skill gains experimental. Acceptance goldens for list and search are regenerated. The search release fixture gains a RULES.md so search JSON shows rules. Co-authored-by: Isaac <no-reply@databricks.com>
Keep both sides of the merge. The shared acceptance release gains a hyphen-prefixed file for guide-skill, so the list golden is regenerated for the file list it prints. Co-authored-by: Isaac <no-reply@databricks.com>
Regression test report ✅Commit: Selected 2 changed tests (limit=20, 0 not selected) 2 tests: regression=2 unreleased=0 coverage=0 failing=0
TestAccept/cmd/skills/list: branch ✅ | main (f504773) ❌ | latest (v1.28.0) ❌main (f504773): latest (v1.28.0): TestAccept/cmd/skills/search: branch ✅ | main (f504773) ❌ | latest (v1.28.0) ❌main (f504773): latest (v1.28.0): |
Take the list branch's tip (126f116) so the search command has the list branch's behaviour. Keep the shared catalogJSON envelope in cmd/skills/json.go for search, and drop the search-only JSON type the list branch added. Co-authored-by: Isaac <no-reply@databricks.com>
✅ Integration test reportCommit: 4724e12
Top 3 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
Automated review at f59abe1. Each finding was verified against the code.
No blocking issues found. 5 non-blocking comment(s) and 1 question(s) below.
This PR moves skills list and skills search JSON onto one shared catalogJSON type, and adds experimental per skill and stale, fetched_at and rules to the envelope. The output change itself looks correct and the goldens follow from it. What's left: search still prints no stale warning in text mode, search's JSON source changes on Windows without the description saying so, one doc comment is inaccurate, and two unit tests overlap with coverage that already exists.
Questions
- This PR merges
listJSONandsearchJSONinto one type and, in the same change, adds four new output fields (experimental,stale,fetched_at,rules). Should the type merge, which the removedsearch.gocomment already planned, land on its own, with the new fields in a follow-up, so the refactor and the output changes can be reviewed separately? (non-blocking)
| Commands: copyList(s.Commands), | ||
| }) | ||
| } | ||
| out := newCatalogJSON(catalog, matches) |
There was a problem hiding this comment.
[nice to have] With a stale catalog, skills list prints provenanceLine on stderr in both output modes (list.go:50-52). skills search only gets the stale field in JSON, so skills search jobs in text mode still says nothing. Should runSearch log provenanceLine(catalog) when catalog.Stale is set, the way runList does?
There was a problem hiding this comment.
Done in 7da8a69. runSearch now logs the provenance line on stderr when the catalog is stale, as runList does, in both output modes. TestRunSearchStaleCatalogSaysStale checks both modes.
There was a problem hiding this comment.
The stale provenance line in skills search is the change in #8137. This pull request carries a copy of it, and whichever of the two merges second drops its own copy and keeps the other's runSearch shape.
There was a problem hiding this comment.
| Commands: copyList(s.Commands), | ||
| }) | ||
| } | ||
| out := newCatalogJSON(catalog, matches) |
There was a problem hiding this comment.
[nice to have] Search used to print catalog.Label as is. newCatalogJSON applies filepath.ToSlash, so on Windows a local source C:\skills\release now prints as "source": "C:/skills/release" in skills search --output json. That matches list, but it's a user-visible change that no golden can show and the description doesn't mention. Can you add it to the description, or split it out with the type merge?
There was a problem hiding this comment.
Kept filepath.ToSlash in both commands, so the envelope is one shape. Search text never printed the source, so only skills search --output json on Windows changes, and it now matches skills list. The PR description lists it under decisions to review. Acceptance runs on Linux, so no golden shows the Windows form.
There was a problem hiding this comment.
Correction to my earlier reply: skills.Resolve already applies filepath.ToSlash, so no current source changes on Windows. The call stays as a guard, and the description is corrected.
| func TestSearchJSONStaleCatalogSaysStale(t *testing.T) { | ||
| catalog := &libskills.Catalog{Label: "bundled", Version: "1.2.3", Stale: true, Skills: searchCatalog} | ||
|
|
||
| out, err := json.Marshal(newCatalogJSON(catalog, matchSkills(searchCatalog, []string{"jobs"}))) |
There was a problem hiding this comment.
[nice to have] This calls newCatalogJSON directly, so it would still pass if runSearch stopped using the shared constructor. For stale, it checks the same thing as TestRunListJSONStaleCatalogSaysStale. The only new thing it checks is that fetched_at is left out when the fetch time is zero. Should it be renamed to say that, or dropped?
There was a problem hiding this comment.
Dropped the constructor test. TestRunSearchStaleCatalogSaysStale replaces it and calls runSearch, so it fails if search stops using the shared constructor. It also covers the zero fetch time: fetched_at is left out, and the test name and comment say so.
| return cmd, &stdout | ||
| } | ||
|
|
||
| func TestRunListJSONMarksExperimentalAndCarriesRules(t *testing.T) { |
There was a problem hiding this comment.
[nice to have] The regenerated acceptance/cmd/skills/list/output.txt already shows experimental false and true, "stale": false, and rules equal to the text printed above the list. .agents/rules/testing.md says not to add a unit test that only duplicates acceptance coverage. Can this one go and the stale-catalog test stay, since acceptance can't produce a stale catalog?
There was a problem hiding this comment.
Dropped TestRunListJSONMarksExperimentalAndCarriesRules. The list golden already covers experimental for both values and rules equal to the text output, so the test only duplicated acceptance coverage. Kept the stale-catalog test, since acceptance cannot produce a stale catalog.
|
|
||
| // newCatalogJSON returns the JSON output for the skills in list, which are the | ||
| // skills a command shows from catalog. Rules are the same text the text output | ||
| // prints above the list. |
There was a problem hiding this comment.
[nit] skills search uses this constructor too, but searchTemplate never prints rules, so "the same text the text output prints above the list" only holds for skills list. Maybe: "Rules are the catalog rules, trimmed as skills list prints them; skills search carries them too so both commands share one envelope."
There was a problem hiding this comment.
Reworded in 7da8a69, as suggested: the rules are the catalog rules, trimmed as skills list prints them, and skills search carries them too so both commands share one envelope.
… runSearch runSearch takes a source, so its test runs the command rather than the constructor. Text search prints the provenance line for a stale catalog, as skills list does. The JSON envelope comment says the rules are the ones skills list prints. Co-authored-by: Isaac <no-reply@databricks.com>
The skills list branch merged to main as a squash. Keep the shared catalog JSON envelope in json.go for skills list and search, and drop the list-only JSON type that the squash brought in. Co-authored-by: Isaac <no-reply@databricks.com>
rugpanov
left a comment
There was a problem hiding this comment.
Thank you for this change. The catalogJSON merge is correct, and I found no defect in the code. CI passes on linux, windows and macos.
Risk: LOW. The change reaches only the JSON output of skills list and skills search, in the hidden skills group. That group is registered only when DATABRICKS_SKILLS_PREVIEW is set. The JSON change adds fields and removes none, and a revert is easy.
I did not approve yet, because one design question is open (inline on cmd/skills/json.go). review-oss-bot asked a similar question in #8139 (review), and it has no answer yet. The other comments are nits.
| type catalogJSON struct { | ||
| Source string `json:"source"` | ||
| ReleaseVersion string `json:"release_version"` | ||
| Stale bool `json:"stale"` |
There was a problem hiding this comment.
[Question] Can stale be true, or fetched_at differ from the current time, with the sources that skills.Resolve returns today? Resolve returns only an fsSource. fsSource.Catalog never sets Stale, and it sets FetchedAt to time.Now(). Only bundledSource sets Stale, and Resolve does not return it. Thus these two fields and the new stale line in skills search run only in unit tests.
Is it better to merge the type change alone now, and add stale and fetched_at with the change that makes a stale source reachable? The answer decides whether the JSON contract gets fields that no user can see change.
There was a problem hiding this comment.
Right for the sources skills.Resolve returns today: stale is always false, and fetched_at is the time of the call. I kept both fields in this PR rather than merging the type change alone. The ticket requires stale and provenance in the JSON output, with a test that a stale catalog shows "stale": true, and a type-only merge would not meet that. The description now says this under decisions to review.
| // share one envelope. | ||
| func newCatalogJSON(catalog *libskills.Catalog, list []libskills.Skill) catalogJSON { | ||
| out := catalogJSON{ | ||
| Source: filepath.ToSlash(catalog.Label), |
There was a problem hiding this comment.
[nit] This filepath.ToSlash call has no effect. skills.Resolve already builds the label with filepath.ToSlash(dir). The other labels (the release URL and "bundled copy") have no backslashes. Thus skills search --output json on main already prints forward slashes on Windows.
Update the "Decisions to review" item in the PR description, because it describes a behavior change that does not occur. You can keep the call as a guard, or remove it.
There was a problem hiding this comment.
Confirmed: skills.Resolve already applies filepath.ToSlash, so the call in newCatalogJSON changes nothing for any current source. I kept it as a guard, so the envelope source is a slash path whatever the caller passes. The description said Windows output changes, which was wrong, and it is corrected.
|
|
||
| // outputTestCmd returns a command whose output is in the given format, and the | ||
| // buffers that capture stdout and stderr. | ||
| func outputTestCmd(t *testing.T, output flags.Output) (*cobra.Command, *bytes.Buffer, *bytes.Buffer) { |
There was a problem hiding this comment.
[nit] outputTestCmd does almost the same job as listTestCmd in cmd/skills/list_test.go. The doc comment says that it captures stdout, but it does not call cmd.SetOut. A later test that calls runList in text mode gets an empty stdout buffer, because runList writes to cmd.OutOrStdout().
Keep one helper that passes the same buffer to cmdio.NewIO and to cmd.SetOut.
There was a problem hiding this comment.
Done in 98b6970. outputTestCmd is removed, and listTestCmd now sends cmdio output and cmd.SetOut to one stdout buffer. The JSON tests use it, and go test ./cmd/skills/... passes.
| @@ -0,0 +1,3 @@ | |||
| # The skill files are printed verbatim, so their line endings must stay \n on every OS. | |||
| # A Windows checkout would otherwise turn them into \r\n and change what `skills read` prints. | |||
There was a problem hiding this comment.
[nit] This comment is a copy from acceptance/cmd/skills/release/.gitattributes, and it names skills read. The search script does not run skills read. The real reason is that RULES.md goes into the JSON rules field of the search golden, and strings.TrimSpace keeps an inner \r\n. Change the comment to give this reason.
There was a problem hiding this comment.
Done in 98b6970. The comment now gives the real reason: the rules field is printed from RULES.md, and strings.TrimSpace keeps an inner CRLF, so a Windows checkout would change the golden. The copied skills read wording is gone.
The JSON tests had their own output helper that did not route command output to the stdout buffer, so a text-mode test could not read what the command wrote. listTestCmd now sends cmdio output and the command's own writes to one buffer, and the JSON tests use it. The search release .gitattributes comment now gives the real reason for the eol rule: the rules field keeps an inner CRLF. Co-authored-by: Isaac <no-reply@databricks.com>
…ist-and-search-json-carry-experi
skills list --output json now carries each skill's experimental flag, so the list golden gains it. The search golden already had it. Co-authored-by: Isaac <no-reply@databricks.com>
| Skills: make([]catalogJSONSkill, 0, len(list)), | ||
| } | ||
| if !catalog.FetchedAt.IsZero() { | ||
| out.FetchedAt = catalog.FetchedAt.Format(time.RFC3339) |
There was a problem hiding this comment.
[nit] fsSource.Catalog sets FetchedAt to time.Now() (libs/skills/fs.go:42), and catalog.FetchedAt.Format(time.RFC3339) keeps the local offset. The same instant therefore prints as 2026-11-30T10:14:00-08:00 on one machine and …Z on another, which makes the machine-readable field depend on the host's TZ. Consider catalog.FetchedAt.UTC().Format(time.RFC3339) in newCatalogJSON, and in provenanceLine too if you want both outputs to match.
There was a problem hiding this comment.
Done in 4724e12. newCatalogJSON and provenanceLine now format fetched_at in UTC, so the value does not depend on the host's time zone.
| // A stale catalog gets the provenance line in both output modes, as skills list | ||
| // prints it. The JSON says "stale": true and leaves out fetched_at, because a | ||
| // bundled copy has no fetch time. | ||
| func TestRunSearchStaleCatalogSaysStale(t *testing.T) { |
There was a problem hiding this comment.
[nit] Since #8137 landed on main, search_test.go already has TestRunSearchStaleCatalogPrintsProvenanceOnStderr, which checks the exact stale line on stderr in text mode. The text-mode half of TestRunSearchStaleCatalogSaysStale (json_test.go:40-42) repeats that check more loosely. Main also brought searchTestCmd, which now does the same job as the reworked listTestCmd, so there are two helpers again (the earlier "keep one helper" thread). Consider keeping only the JSON half of the new test, and switching search_test.go to listTestCmd or deleting searchTestCmd.
There was a problem hiding this comment.
Done in 4724e12. The new test is now JSON only (TestRunSearchJSONStaleCatalogSaysStale), and the text-mode stale line stays covered by the test in search_test.go. searchTestCmd is deleted and search_test.go uses listTestCmd, so there is one helper.
Co-authored-by: Isaac <no-reply@databricks.com>
skills list --output jsonandskills search --output jsonnow print one envelope and one per-skill shape, both built from one type incmd/skills/json.go. Each skill says whether it is experimental, and the envelope carries the catalog rules and whether the catalog is stale.Changes
experimental, which is true only for experimental skills.rules: the catalog rules, trimmed asskills listprints them.skills searchcarries them too, so both commands share one envelope.staleandfetched_at, so a stale catalog says so in JSON.fetched_atis left out when the source does not know it.skills searchprints the stale-catalog line on stderr through Print the stale-catalog line from skills search #8137, which is on main. This branch merges main and keeps only that copy.Why
Reviewers asked that
skills list --output jsonshow which skills are experimental and include the rules that the text output prints.skills searchuses the same envelope, so both change together.Decisions to review
skills search --output jsoncarriesrules, although search's text output does not print them. The envelope is shared, so one parser reads both commands.sourcelabel goes throughfilepath.ToSlashin both commands as a guard.skills.Resolvealready converts the path, so no current source changes its output on Windows.staleandfetched_atare in the envelope before any source sets them. The only sourceskills.Resolvereturns never setsStale, and it setsFetchedAtto the time of the call, so todaystaleis always false. The fields stay because the output contract needs them once a stale source is reachable, and the stale test covers that case.fetched_atis omitted when unknown, rather than printed as the zero time.staleandfetched_atare set in the output type, not marshaled fromlibskills.Catalog, so the output does not change when the catalog's fields do.Tests
TestRunListJSONStaleCatalogSaysStalecovers"stale": trueandfetched_atforskills list.TestRunSearchStaleCatalogSaysStalerunsrunSearchon a stale catalog: the JSON has"stale": trueand nofetched_at, and the provenance line is on stderr in both output modes.cmd/skillspasses. The list and search goldens showexperimental,rulesandstale, and the list golden is regenerated forexperimental. Thedisabledcase still shows the group is absent whenDATABRICKS_SKILLS_PREVIEWis unset.This pull request and its description were written by Isaac.