Repository navigation
fix(sync): report include patterns that match no skill - #326
Merged
Merged
Conversation
Target include/exclude patterns are matched with filepath.Match against the source-path flat name, while target_naming: standard shows the bare SKILL.md name in the target directory. A pattern written with the name the target shows selects nothing, so sync prunes the entries a working pattern had linked, and the only trace is the echoed include: line, which never says that any of those patterns matched zero skills. Add FindUnmatchedIncludes and render one diagnostic per include pattern that selects no discovered skill, suggesting the flat names whose last path segment is the pattern. exclude is left alone: an exclusion that blocks nothing is the normal state of a spare filter, while an include that selects nothing is always a mistake and is the destructive direction. The diagnostic goes to DiagOutput, so --json output is unchanged, and no filtering, naming, or pruning behavior moves. Closes runkids#325
Owner
|
Thanks for the careful write-up and the red-before-green proof. The diagnosis in #325 is spot on, and keeping this to a warning with no behavior change is the right call. I'll merge this as-is and handle a few follow-ups on our side before the next release:
Thanks again! |
runkids
added a commit
that referenced
this pull request
Oct 2, 2026
The unmatched include warning from #326 was written straight to DiagOutput. The dashboard sync never showed it because DiagOutput is the server's stdout, and an interactive CLI sync could redraw its progress area over it. Return the warnings with the merge and copy results so SyncSkillTarget adds them to the target's warnings, which both the CLI and the API already report. Prefix them with the target name, since the API returns one list for all targets. A top-level skill name has no path separator, so the suggestion cut off its first character and suggested "alpha" for a typo like "lpha". Compare the whole name in that case. Refs #325
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #325
Problem
Target
include/excludepatterns are matched withfilepath.Matchagainst theinternal flat name (
DiscoveredSkill.FlatName, i.e. the source path joined with__), whiletarget_naming: standardmakes the target directory show the bareSKILL.mdname. The two vocabularies look interchangeable to the user and are not:a pattern written with the name the target shows selects nothing, and
syncthenprunes the entries a correct pattern had previously created. The only trace is the
→ include:echo, which repeats the patterns without saying any of them matched zero skills.Measured with a binary built from
d5d7fc47(v0.23.4, the tip ofmainwhen I branched),with this config and only the
includeline changing between the two runs (<source>/<target>stand in for the sandbox paths, and the transcripts below are abridged to thesummary lines):
The two source skills are
frontend/devand_repos/demo/lark-sheets, andskillshare list -gprints them as
_repos/demo/ → lark-sheetsandfrontend/ → dev. The vocabulary a user has towrite is the one neither the target directory nor
listever shows them.Change
Add a per-target diagnostic for an
includepattern that selects no discoveredskill, with the source-path name(s) a bare pattern most likely meant. Same scenario
after the patch (the
!lines are verbatim; they print before the per-target summary):Scope is deliberately narrow:
includeis checked. A spareexcludethat blocks nothing is normalconfig hygiene; an
includethat selects nothing is always a mistake, and it isthe destructive direction (it prunes what the correct pattern linked).
are untouched, so nothing that syncs today changes what it links.
diagnostic goes to
DiagOutput, so--jsonoutput is unaffected.FilterSkillsexactly (samenormalizePatterns+filepath.MatchagainstFlatName), so an invalid pattern is still reported bythe existing validation path and produces no duplicate here.
Each of those was checked by running the patched binary in the same sandbox:
include: [frontend__dev, dev](one working pattern, one dead) warns only aboutdevand still links 1 skill
include: [dev]with--json: stdout has 0 occurrences of the warning text and theJSON payload is unchanged
exclude: [nothing-*]alongside workingincludepatterns: silent, 2 linkedTests
Red before green. With this diff applied,
git checkout HEAD -- internal/sync/filter.go internal/sync/target_naming.go internal/sync/sync.go internal/sync/copy.gorestores only the four implementation files, and the final integration test then fails against the stock behavior:(The
got:blocks are abridged as above. On that same tree the unit tests do not evencompile:
undefined: FindUnmatchedIncludesat 6 call sites ininternal/sync/filter_test.go.)After the patch, in a plain clone of
d5d7fc47with this diff applied:git applyclean,gofmt -l ./cmd ./internal ./testsempty,go vet ./...cleango test ./internal/...— 27 packages, allok, 0 failuresTestFindUnmatchedIncludes_*(5) — nested bare name, silent when patterns select,no suggestion for globs or unknown names, suggestion cap, silent on a pattern
FilterSkillsalready rejectsTestResolveTargetSkillsForTarget_*(5) — exact message in flat and standardnaming, silence for a working pattern
TestSync_IncludePatternMatchingNothing_IsReported+ the 9 existingTestSync_TargetNaming*integration tests./tests/integration— the run reaches 668 passing tests with 0 reported failuresbefore the hang described below. The tests after that point never ran, so I am not
claiming full coverage of the package; nothing in it reported a failure.
Docs
website/docs/reference/commands/sync.mdandwebsite/docs/reference/targets/configuration.mdnow state that filters keepmatching source-path flat names even under
target_naming: standard, and that anincludematching nothing is reported. The same lines are mirrored into theja/ko/zh-Hans/zh-Hantcopies of those pages underwebsite/i18n/<locale>/docusaurus-plugin-content-docs/current/reference/, which documenttarget_namingtoo.Verification caveat
My environment is WSL Ubuntu, not the devcontainer, so CI is the authority. Two limits,
both traced to the unpatched
d5d7fc47, so neither is a regression from this diff:initwizard throughsb.RunCLIWithInput()and neverreturn here:
TestInit_Fresh_CreatesConfigAndSource,TestInit_WithSourceFlag_UsesCustomPath,TestInit_DryRun_DoesNotWrite,TestInit_DetectsCLI_OffersImport,TestInit_WithSkills_CopiesOnConfirm. I skipped exactly those five to get the suitemoving. Baseline proof for the first one, on the unpatched tree and the stock binary:
panic: test timed out after 1m30s / running tests: TestInit_Fresh_CreatesConfigAndSource.I re-ran the second one and the run was killed before it produced a log, so the other
four are grouped by the same blocking call rather than each individually proven.
TestInit_*)and 0 reported failures, then hangs in
TestInstall_Project_JSON_Agent_PureJSON(
skillshare install file://<repo>). That one I did prove on the baseline: the samesingle test, unpatched tree and stock binary, gives
panic: test timed out after 40s / running tests: TestInstall_Project_JSON_Agent_PureJSON (40s).So:
./internal/...fully green, and everything in./tests/integrationthat myenvironment can run is green. An earlier attempt of mine used
git worktree, whose.gitfile holds a Windows-style path that git inside WSL cannot resolve; in that treeevery test that shells out to Git failed (
internal/install,internal/server) and thenumbers above would have looked wrong. In the plain clone used for them, both packages
are
ok.