Skip to content

fix(sync): report include patterns that match no skill - #326

Merged
runkids merged 1 commit into
runkids:mainfrom
star-nebula:fix/unmatched-include-warning
Oct 2, 2026
Merged

runkids merged 1 commit into
runkids:mainfrom
star-nebula:fix/unmatched-include-warning

Conversation

@star-nebula

Copy link
Copy Markdown
Contributor

Closes #325

Problem

Target include / exclude patterns are matched with filepath.Match against the
internal flat name (DiscoveredSkill.FlatName, i.e. the source path joined with
__), while target_naming: standard makes the target directory show the bare
SKILL.md name. The two vocabularies look interchangeable to the user and are not:
a pattern written with the name the target shows selects nothing, and sync then
prunes 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 of main when I branched),
with this config and only the include line changing between the two runs (<source> /
<target> stand in for the sandbox paths, and the transcripts below are abridged to the
summary lines):

source: <source>
target_naming: standard
targets:
  t1:
    path: <target>
    mode: merge
    include: [frontend__dev, _repos__demo__lark-sheets]
$ skillshare sync -g
  t1: merged (2 linked, 0 local, 0 updated, 0 pruned)
→   include: frontend__dev, _repos__demo__lark-sheets
$ ls <target>
dev
lark-sheets

$ skillshare sync -g        # same two skills, now named the way the target shows them
  t1: merged (0 linked, 0 local, 0 updated, 2 pruned)
→   include: dev, lark-sheets
$ ls <target>
(empty)

The two source skills are frontend/dev and _repos/demo/lark-sheets, and skillshare list -g
prints them as _repos/demo/ → lark-sheets and frontend/ → dev. The vocabulary a user has to
write is the one neither the target directory nor list ever shows them.

Change

Add a per-target diagnostic for an include pattern that selects no discovered
skill, 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):

  t1: syncing...
  ! include pattern "dev" matches no skill in the source (filters use the source path name; did you mean "frontend__dev"?)
  ! include pattern "lark-sheets" matches no skill in the source (filters use the source path name; did you mean "_repos__demo__lark-sheets"?)
  t1: merged (0 linked, 0 local, 0 updated, 2 pruned)

Scope is deliberately narrow:

  • Only include is checked. A spare exclude that blocks nothing is normal
    config hygiene; an include that selects nothing is always a mistake, and it is
    the destructive direction (it prunes what the correct pattern linked).
  • Warning only, no behavior change. Filtering, naming resolution, and pruning
    are untouched, so nothing that syncs today changes what it links.
  • Suggestions are limited to non-glob patterns, capped at 3 per pattern, and the
    diagnostic goes to DiagOutput, so --json output is unaffected.
  • Pattern matching mirrors FilterSkills exactly (same normalizePatterns +
    filepath.Match against FlatName), so an invalid pattern is still reported by
    the 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 about dev
    and still links 1 skill
  • include: [dev] with --json: stdout has 0 occurrences of the warning text and the
    JSON payload is unchanged
  • exclude: [nothing-*] alongside working include patterns: silent, 2 linked

Tests

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.go restores only the four implementation files, and the final integration test then fails against the stock behavior:

--- FAIL: TestSync_IncludePatternMatchingNothing_IsReported (0.67s)
    sync_target_naming_test.go:51: expected output to contain "include pattern \"dev\" matches no skill", got:
          claude: merged (0 linked, 0 local, 0 updated, 1 pruned)
        →   include: dev
    sync_target_naming_test.go:52: expected output to contain "frontend__dev", got:
          claude: merged (0 linked, 0 local, 0 updated, 1 pruned)
        →   include: dev
    sync_target_naming_test.go:58: expected output to contain "include pattern \"dev\" matches no skill", got:
          claude: merged (no skills)
        →   include: dev

(The got: blocks are abridged as above. On that same tree the unit tests do not even
compile: undefined: FindUnmatchedIncludes at 6 call sites in
internal/sync/filter_test.go.)

After the patch, in a plain clone of d5d7fc47 with this diff applied:

  • git apply clean, gofmt -l ./cmd ./internal ./tests empty, go vet ./... clean
  • go test ./internal/... — 27 packages, all ok, 0 failures
  • TestFindUnmatchedIncludes_* (5) — nested bare name, silent when patterns select,
    no suggestion for globs or unknown names, suggestion cap, silent on a pattern
    FilterSkills already rejects
  • TestResolveTargetSkillsForTarget_* (5) — exact message in flat and standard
    naming, silence for a working pattern
  • TestSync_IncludePatternMatchingNothing_IsReported + the 9 existing
    TestSync_TargetNaming* integration tests
  • ./tests/integration — the run reaches 668 passing tests with 0 reported failures
    before 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.md and
website/docs/reference/targets/configuration.md now state that filters keep
matching source-path flat names even under target_naming: standard, and that an
include matching nothing is reported. The same lines are mirrored into the
ja / ko / zh-Hans / zh-Hant copies of those pages under
website/i18n/<locale>/docusaurus-plugin-content-docs/current/reference/, which document
target_naming too.

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:

  • Five tests drive the interactive init wizard through sb.RunCLIWithInput() and never
    return here: TestInit_Fresh_CreatesConfigAndSource, TestInit_WithSourceFlag_UsesCustomPath,
    TestInit_DryRun_DoesNotWrite, TestInit_DetectsCLI_OffersImport,
    TestInit_WithSkills_CopiesOnConfirm. I skipped exactly those five to get the suite
    moving. 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.
  • With those five skipped the patched run reaches 668 passing tests (49 of them 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 same
    single 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/integration that my
environment can run is green. An earlier attempt of mine used git worktree, whose
.git file holds a Windows-style path that git inside WSL cannot resolve; in that tree
every test that shells out to Git failed (internal/install, internal/server) and the
numbers above would have looked wrong. In the plain clone used for them, both packages
are ok.

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
@runkids
runkids self-requested a review October 2, 2026 07:20
@runkids
runkids merged commit 4e3b2b2 into runkids:main Oct 2, 2026
7 checks passed
@runkids

runkids commented Oct 2, 2026

Copy link
Copy Markdown
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:

  • Show the warning in the dashboard sync too, and keep it from being overwritten by the progress area in an interactive terminal
  • Name the target in the message, so it's clear which target's include is wrong when several sync at once
  • Fix the suggestion for top-level skills, which currently drops the first character of the name

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
@star-nebula
star-nebula deleted the fix/unmatched-include-warning branch October 2, 2026 08:29
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.

sync: target filters only accept the internal flat name, so a bare-name pattern silently matches nothing and prunes what was already synced

2 participants