Skip to content

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

Closed

Description

@star-nebula

What happens

A target's include / exclude patterns are matched only against the path-joined internal name
(frontend__dev). The name that the target directory actually shows, and the name skillshare list
prints (dev), matches nothing.

Worse than a no-op: because the previously synced skills no longer resolve, the same sync prunes
them
. There is no diagnostic naming the mismatch, and trash stays empty.

Reproduction

Verified on main @ d5d7fc47 (v0.23.4), Go 1.26.0, Linux, isolated SKILLSHARE_CONFIG sandbox.

Two source skills, standard naming, one merge-mode target:

<source>/frontend/dev/SKILL.md                    # name: dev
<source>/_repos/demo/lark-sheets/SKILL.md         # name: lark-sheets   (tracked-repo dir)
source: <source>
target_naming: standard
targets:
  t1:
    path: <target>
    mode: merge

Step 1 — patterns written in the internal vocabulary:

    include: [frontend__dev, _repos__demo__lark-sheets]
$ skillshare sync -g
✓ Discovered 2 skills
  t1: merged (2 linked, 0 local, 0 updated, 0 pruned)
$ ls <target>
dev
lark-sheets

The links land under the bare names. skillshare list agrees:

Installed skills
  _repos/demo/
    → lark-sheets   tracked: _repos
  frontend/
    → dev   local

Step 2 — the same two skills, addressed by the name the target shows and the name list printed:

    include: [dev, lark-sheets]
$ skillshare sync -g
✓ Discovered 2 skills
  t1: merged (0 linked, 0 local, 0 updated, 2 pruned)
→  include: dev, lark-sheets
Sync complete: 1 targets, 0 linked, 0 local, 0 updated, 2 pruned (0.0s)
$ ls <target>
(empty)
$ skillshare trash list
→ Trash is empty

Nothing warns that dev and lark-sheets matched zero skills; the → include: line just echoes the
filters. skillshare target t1 --add-include dev is accepted the same way.

Why it is easy to hit

Every other surface the user reads — the target directory, list, diff, the N linked counts — speaks
the target-visible name. Only the filter vocabulary is different, and it is the one place that fails
silently.

Filtering agents already normalizes for intuition (FilterAgents strips the .md suffix so users
can write tutor instead of tutor.md); skills have no equivalent accommodation
(internal/sync/filter.go:31-45).

Root cause

  • FilterSkills matches filepath.Match(pattern, skill.FlatName) — internal/sync/filter.go:14-28,
    :112-120.
  • FlatName is the source-relative path with / replaced by __ — internal/utils/strings.go:25-39,
    assigned in internal/sync/discover_walk.go:307.
  • Naming is applied after filtering: ResolveTargetSkillsForTarget calls FilterSkills first
    (internal/sync/target_naming.go:34) and only then picks the target-visible name (:71-75). So a
    pattern written in post-naming vocabulary is evaluated against pre-naming vocabulary and can never
    match.
  • Prune resolves through the same function (internal/sync/sync.go:750-795), which is why the mismatch
    removes existing entries instead of merely failing to create them.

The CLI already has the missing diagnostic elsewhere: update and uninstall warn
%s: no skills match pattern (cmd/skillshare/update.go:283, cmd/skillshare/uninstall_handlers.go:254),
and audit errors no skills matched the given names/groups (cmd/skillshare/audit.go:735). The sync
path is the one place it is absent — and the one place where the consequence is destructive.

Proposal

  1. Minimum: in the sync path, warn per target for every include pattern that matches zero
    discovered skills, reusing the existing wording and, ideally, suggesting the closest internal name.
    This turns a silent 2 pruned into an actionable line. Small, focused, with a regression test — I
    can send it.
  2. Fuller: when the effective naming is standard, also accept the target-visible name (and the
    SKILL.md name for repo skills) in include / exclude, keeping today's flat patterns working.
    This changes resolution semantics, so it probably wants the proposal template — happy to draft it if
    you want it.

Notes

  • Not a regression of merge-mode prune deletes live links into the source that skillshare never created #314: the pruned links were created by skillshare and are in the manifest, so
    provenance pruning behaved as designed. Separate concern.
  • website/docs/reference/targets/configuration.md ("Matching is against target flat names (for example
    team__frontend__ui)") is worth re-wording either way: under target_naming: standard the target's
    names are not flat, so the sentence and the observable behaviour read as contradictory.

Activity

  1. added a commit that references this issue on Oct 2, 2026
    4e3b2b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions