Commit Graph
217 Commits
Author SHA1 Message Date
Willie 19fce92fba Merge branch 'main' into runkids/collect-install-local 2026-10-10 00:21:28 +08:00
Willie 6adeea6409 fix(install,collect): keep a tracked source inside its destination; reject special SKILL.md files
--track --force removed the destination before cloning, so a local source
nested below it (or given as an explicit file:// URL) was deleted along with
any unpushed work, and the clone then failed. Resolve the source and refuse
when it is the destination or lies under it, for dry runs too.

HasSkillFile used a not-a-directory test, so a FIFO named SKILL.md counted as
a skill and the collect copy blocked on it. Require a regular file; a
symlinked SKILL.md still resolves through os.Stat.
2026-10-10 00:15:50 +08:00
Willie c638b46096 fix(sync): replace copy-mode copies with links when switching back to merge (#506)
* fix(sync): replace copy-mode copies with links when switching back to merge

Switching a target from copy back to merge left every copy whose entry name
did not change as a real folder. Merge sync treated it as the user's own
folder, so status and doctor kept saying "run skillshare sync" while sync
changed nothing, and only `sync --force` turned it into a link.

Copy mode already replaces merge-mode links with copies on its own, so merge
sync now replaces a folder the manifest records with a checksum (a copy-mode
copy) with a link, without --force. Folders the manifest does not record, or
records as a link, stay untouched. The pre-sync target backup is unchanged.

The CLI and dashboard diffs name these entries as copies sync replaces
instead of suggesting --force, and the sync-modes docs describe the switch.

* fix(sync): keep copy-mode copies the user edited when switching to merge

The first version replaced any folder the manifest recorded as a copy-mode
copy. The manifest checksum is only a record, so a copy edited since copy
mode made it was deleted too, and `sync --json` and project-mode dashboard
sync take no pre-sync backup to restore it from.

Replace the folder only while it still hashes to the recorded checksum
(Manifest.OwnsCopy). An edited copy is kept and `sync --force` still
replaces it; diff keeps suggesting --force for it. A copy whose name: was
rewritten by prefixed naming, or that was made with custom ignore patterns,
no longer hashes to the source checksum and is kept the same way.

* fix(ui): say a copy-mode copy in a merge target is replaced by a link

The Sync page picks a row's text from the diff item's action alone. The
copy-mode copy that merge sync now replaces comes from the server as an
update, which the page worded as "Link is broken or points elsewhere. Will
be relinked" even though no link exists yet.

Match the server's reason and show "Copy made by copy mode. Will be replaced
by a link" instead, in all eleven dashboard languages.

* docs(sync): say only unedited copy-mode copies are replaced on merge sync

The sync-modes paragraph promised that copies copy mode made are replaced
with links without --force. Merge sync keeps a copy that no longer hashes to
the checksum copy mode recorded, so an edited copy, or one whose name: copy
mode rewrote for prefixed naming, still needs --force.

State the three cases in sync-modes and qualify the diff Modified and Local
override labels, in English and the ja, ko, zh-Hans and zh-Hant copies.

* fix(sync): keep the copy until its replacement link exists

Replacing a copy-mode copy removed the folder first and then created the
link. If creating the link failed (no symlink or junction rights on a
Windows or network filesystem), sync returned an error with the skill gone
from the target. This path now also runs on a plain sync, not only on
--force.

Park the folder beside the entry, create the link, then delete the parked
folder; on failure the folder is moved back. A parked folder left by a run
that died mid-way may be the only copy, so the next sync stops with a message
instead of deleting it. The manifest also forgets the copy-mode mtime and
naming records of an entry that is now a link.

* test(sourcefs): register replaceWithLink's target writes in the raw-write ratchet

The previous commit moved the merge-mode folder replacement into
replaceWithLink, which the ratchet reports as new raw os calls and the old
os.RemoveAll allowance as stale. All of them act on the sync target, not the
skills source, like the neighbouring entries.

* fix(sync): bound the parked copy's name and document the naming exception

The folder parked while a link is created was named after the entry, so an
entry near the 255-byte filename limit (a long flattened nested skill)
could not be moved aside and its replacement failed. The parked name is now
a fixed-length hash of the entry name.

sync-modes also says what happens when `target_naming` changes in the same
sync: the copy gets a new entry name and the prune pass removes it as an
orphan whether or not it was edited, as it did before this change.
2026-10-10 00:13:29 +08:00
Willie ec2a8ab3aa fix(sync): close gaps found while simulating the prefixed naming switch (#504)
* fix(sync): close gaps found while simulating the prefixed naming switch

Simulating the #497 reporter's switch from merge + flat to copy + prefixed
turned up four problems:

- `target X --mode copy --target-naming prefixed` applied only --mode, since
  the setter dispatch returned after the first flag. Both flags given
  together now check the final pair, then apply in an order that keeps the
  saved pair valid (copy mode first, any other mode last).
- Skipped skills were only counted, so a prefixed name over 64 characters
  vanished with "1 skill(s) skipped". Sync now names the first five with
  their reason; the cap keeps huge sources from flooding the output.
- In copy mode a merge-mode link to the skill was not a managed entry, so
  when a local folder held the new name the old link was pruned and the
  skill left the target, contrary to the documented "old managed entry is
  preserved". Copy mode now migrates such links like managed copies.
- PATCH /api/targets validated the mode/naming pair against the current
  skills state, so disabling skills while changing mode was rejected. It now
  checks the state the request leaves the target in.

* docs(target): drop stray space in the Japanese mode+naming sentence

* fix(diff): save paired target settings once and report kept legacy entries

- `target X --mode M --target-naming N` ran the two setters, each saving
  the config, so a failed second save left half the change behind (Codex
  on #504). Both fields are now set and saved once, after the final pair
  is checked.
- When a local folder holds the name a skill's naming now gives it, sync
  keeps the skill under its old entry and leaves the folder alone, even
  with --force. diff still called the folder a "local copy" and suggested
  `sync --force`, which does nothing for it. CLI and Web API diff, copy
  and merge mode, now report the folder and the entry the skill stays at.

* fix(sync): migrate only links the manifest records as merge-made

Copy mode treated any link to the skill's source at an old naming's name as
the entry merge mode left behind, so a user's own link was renamed and
replaced with a copy (Codex on #504). A link now migrates only when the
manifest records it as "symlink", which merge mode writes for links it makes;
other links stay as the user left them. The value is now a named constant.

* fix(diff): mark kept legacy entries as unaffected by force

Two problems Codex found on #504:

- The Web API diff sent a local folder on a skill's new name as a "skip",
  which the dashboard shows as an edited entry that Force replaces. Sync
  keeps that folder and the legacy entry even with force, so the preview
  promised a change that never happens. It is now its own "kept" action,
  shown with its reason and not counted.
- `target X --mode M --target-naming N` printed the target's own naming as
  the old value, so a target inheriting standard or prefixed showed
  "flat -> ...". It now prints the naming the target had in effect.

* fix(diff): keep kept-name conflicts out of the sync count

Two problems Codex found on #504:

- A local folder on a skill's new name counted toward "N to sync" and
  fell through to the plain `skillshare sync` hint, though sync changes
  nothing there until the folder is renamed or removed. Such rows now
  carry a kept flag, count as neither sync nor local, and print their own
  hint; a target whose only row is kept still shows that row.
- The dashboard grouped targets by row name and icon only, so two targets
  keeping the same skill at different old entries merged and showed one
  target's old location for both. The row detail is now part of the key.

* fix(diff): do not list a kept local folder's files as deletions

A kept row (a local folder on a skill's new name) still pointed at that
folder, so `diff --stat` and `--patch` listed each of its files as removed,
though sync never touches the folder (Codex on #504). Kept rows no longer
point at a target directory, so no file-level diff is built for them in the
CLI or the TUI.

* fix(diff): report kept skills consistently in every diff view

An exhaustive review of the kept-row change (prompted by two Codex findings
on #504) found the same gap in several places:

- A target whose only rows were kept was summarized as "in sync", and mixed
  summaries left it out of every count. Such targets now count as "N kept
  under old name" with a warning mark, and the scan progress counts them.
- Plain output and the TUI hid where the skill stays; rows now read
  "name (stays at old-name)". The TUI also lacked the kept Next hint and
  called kept-only targets "differs"; it now matches the plain output.
- `diff --json` emitted kept rows as "remove", indistinguishable from
  local-only folders; it now emits "kept", as the Web API does. The diff
  docs' JSON example also showed actions the CLI never emits.
- Renamed rows whose old entry is a merge-made link showed a bogus file
  stat, because the link was walked as a file; a link now stands for the
  folder it points to.
- A dry-run migration printed "Would copy" to the old path; it now names
  the new one.

* fix(sync): stop reporting kept folders and skipped skills as pending work (#509)

Three reports told users to do something sync cannot do, or hid what it
did:

- Copy and merge sync kept a folder the user made on a skill's name but
  counted it as "up to date" with no hint. Sync now counts it as local and
  adds one capped line per target naming the folders and saying that
  `sync --force` replaces them. The line is added in SyncSkillTarget, so
  the dashboard gets it too.
- status and doctor counted skills that sync skips on purpose (invalid
  names under standard or prefixed naming, name collisions) as "not
  synced — run skillshare sync". Running sync can never add them, so the
  advice looped. They now compare against the skills sync places.
- diff marked a target whose only items were local-only folders as "to
  sync" and `synced: false`. Those items are still listed, but they no
  longer make the target pending.

* fix(target): apply every setting flag, require flag values, report no-ops as unchanged (#507)

* fix(target): apply every setting flag, require flag values, report no-ops as unchanged

`skillshare target <name>` dispatched --mode, --agent-mode and
--target-naming through an if-chain that returned after the first match,
so `--agent-mode copy --target-naming prefixed` applied one setting and
silently dropped the other. Filters, --skills and --dry-run had the same
early-return problem.

- Check --mode, --agent-mode and --target-naming as a whole and save
  once, in global and project mode (one targetSettingsUpdate replaces six
  per-flag functions).
- Reject --mode/--agent-mode/--target-naming combined with filters or
  --skills, and --dry-run without --skills, instead of dropping them.
- A value flag followed by another flag (or an empty string) now reports
  "<flag> requires a value"; `--target-naming -p` used to report an
  invalid naming '-p'.
- A value the target already has is reported as unchanged and the config
  is not rewritten.

* fix(target): leave the skills pair alone on agents-only changes

A target with skills off may keep target_naming prefixed with a merge
mode it cannot sync; validateGlobalTarget and validateProjectTarget only
check that pair for enabled skills. The combined settings update ran the
pair check for every setting, so `target claude --agent-mode copy` was
refused on such a target although the old agent-mode handler never looked
at skills settings. Check the pair only when --mode or --target-naming is
given.

* docs(target): show combined settings in --help and the built-in skill

The combined --mode/--agent-mode/--target-naming form is now the way to
move a target to copy + prefixed in one step, but neither the help
examples nor the built-in skill's target reference showed it.
2026-10-09 23:59:47 +08:00
Willie 9c994faa17 fix(frontmatter): read and rewrite SKILL.md that starts with a UTF-8 BOM (#505)
* fix(frontmatter): read and rewrite SKILL.md that starts with a UTF-8 BOM

Windows editors such as Notepad write a BOM before the opening ---. The
lenient readers (ParseSkillName, ParseFrontmatterField/Fields/List, ReadSkillBody)
did not skip it, so under target_naming standard/prefixed the skill had no
readable name and was silently skipped. Strip the BOM in the shared frontmatter
locator and the line scanner, and in the hub, search, audit and sync/context
readers that split lines themselves (utils.TrimBOM).

The writers kept working on the unstripped text, so SetFrontmatterValue
prepended a second block and ToggleFrontmatterFlag/RewriteFrontmatterList
could leave a BOM in the middle of the file. They now split the BOM off and
put it back in front, rewriting only the name value (or flag/list) as before.

* fix(frontmatter): cover the dashboard parser and stop auditing a leading BOM

A consumer sweep after the first BOM commit found two more places that
mishandled a SKILL.md written by Notepad:

- audit reported the leading BOM as a HIGH hidden-unicode finding (U+FEFF is
  in the zero-width rule), so every such skill showed a risk score. A BOM at
  the very start of a file is its encoding mark and hides nothing; one past
  the start is still reported.
- the dashboard's parseSkillMarkdown saw no frontmatter, so the skill editor
  would treat the whole file as body and write a second block on save.

The audit-engine page and its four translations note the exemption.

* fix(ui): keep the BOM when the skill editor saves a SKILL.md

parseSkillMarkdown dropped the BOM so the editor could see the frontmatter,
but SkillEditor writes the composed text back through PUT .../content, so every
dashboard edit silently removed the marker from a Notepad-written file. The
parse result now carries the BOM and composeSkillMarkdown puts it back in front,
matching the Go rewrite paths.
2026-10-09 23:58:56 +08:00
Willie eb72272b37 fix(collect,install): keep UNC file URLs intact; require SKILL.md to be a file
The drive-letter fix lived in the helper shared with explicit file:// URLs,
which rewrote file://server/share/repo into a local path. Keep the slash
logic in the local-path --track case only and leave explicit URLs as parsed.

A subdirectory named SKILL.md passed the existence check, so a scratch folder
holding one was still collected. Both collect entry points (scan and the
dashboard request) now share sync.HasSkillFile, which rejects directories.
2026-10-09 23:47:32 +08:00
Willie e31309fe7c fix(collect,install): collect only real skills; let --track take a local git path
collect treated every directory in a target as a local skill, so a scratch
folder was listed and `collect --force` copied it into the source. A folder
now counts only when it holds SKILL.md; the dashboard scan shares
FindLocalSkills and the dashboard collect request rejects such a folder.

`install /path/to/repo --track` failed with "requires a git repository
source" while file:///path worked. A local path that is a git repository
root is now normalized to the same file:// clone URL for --track (also past
the --branch guard); other local folders get an error that names file://.
Help text, docs (English and i18n) and the built-in skill reference follow.
2026-10-09 23:31:15 +08:00
Willie 7febeb9007 fix(sync): keep Unicode letters and digits in the repo prefix
The prefix kept only [a-z0-9], while skill names allow lowercase letters
and digits in any script after NFKC. A repo named _技能 got no prefix
at all and _café collapsed to caf, which could collide with _caf.
Normalize the repo name the way the name validator reads it.
2026-10-09 12:24:38 +08:00
Willie 2ff8bdeb59 fix(diff): report a copy recorded under another naming as modified
Sync re-copies a managed copy whose recorded naming differs from the
current one, for example after a migration stopped between the rename
and the re-copy. Diff skipped it on the mtime fast path and reported the
target in sync while its SKILL.md kept the old name. Check the recorded
naming first in both the CLI and the dashboard diff.
2026-10-09 12:10:08 +08:00
Willie c0d2d0409a fix(sync): rewrite the prefixed name of a read-only SKILL.md
A copy keeps the source file's mode, so a read-only SKILL.md (e.g. from
a read-only checkout) could not be reopened for the name rewrite and a
non-root sync failed, dropping the skill from the target mid-migration.
Lift the write bit for the rewrite only and restore the mode afterwards.
2026-10-09 10:37:50 +08:00
Willie 0477f1e837 fix(diff): report a target naming migration as a rename
After target_naming changes, sync renames the managed entry in place,
but diff looked only under the new name, so the CLI and the dashboard
showed the skill as new while hiding the old entry. Resolve the legacy
entry and report it as a rename instead.
2026-10-09 10:29:36 +08:00
Willie f5f45e56ea refactor(sync): return the legacy entry as a namedTarget
findLegacyTargetEntry returned the old entry's name and naming as two loose strings although namedTarget already pairs them; returning the struct keeps the pair together for both callers.
2026-10-09 01:03:08 +08:00
Willie 096de1ad9b fix(sync): drop a copy whose prefixed name could not be written
When the name: rewrite failed after the copy, the new folder stayed in the
target with no manifest entry, so later syncs took it for a user's folder
and never refreshed it. The copy helper now removes the folder it just made
before returning the error; the next sync copies it again.
2026-10-09 01:02:43 +08:00
Willie e0b930cad0 refactor(sync): trim the naming migration's I/O and manifest bookkeeping
The legacy lookup stat'ed the skill's current entry before looking for old
names, adding syscalls to every flat sync; it now stats only the candidate
names other than the current one (usually none exist) and checks the
current entry only once an old managed entry is found. ReadManifest now
always returns a Naming map, Manifest.Remove drops an entry's records in
one place, copySkillToTarget takes the name to write instead of deciding
it, and diff reads the manifest only for copy targets.
2026-10-09 00:58:34 +08:00
Willie 1e00939512 fix(sync): keep naming migration from claiming another skill's entry
The legacy lookup checks a skill's flat, standard and prefixed names. With
a manifest that has no naming records yet, aaa/dev looked at "dev", found
the top-level dev skill's managed copy and synced into it, because nothing
said the entry belonged to someone else. A skill that already has its
current entry now skips the lookup, and names other skills sync to in the
same run are never treated as old names.
2026-10-09 00:53:13 +08:00
Willie 35f3bb0e28 feat(sync): add target_naming: prefixed for copy-mode targets
Two tracked repos that ship a skill with the same name cannot both reach a
tool today: standard drops both, flat keeps both folders but tools list
skills by name:. Prefixed gives a skill inside a tracked repo the folder and
name: <repo>-<name> in the copy, so both stay usable and the name shows
where the skill came from. It is copy-only because a merge symlink points
at the source, where name: must not change; config validation rejects it
elsewhere, per target, like extension does.

Switching naming used to know only the flat name as the old one, so
standard <-> prefixed would orphan entries. The migration now checks the
skill's name under every naming, and the copy manifest records the naming
that produced each entry: a switch finds the exact old entry, and a renamed
copy is re-copied so its name: matches even when the source is unchanged.
Manifests without the record fall back to flat, standard, prefixed in turn.
A rename is written to the manifest at once, so a later failure cannot
leave the renamed folder looking user-owned.
2026-10-09 00:44:47 +08:00
Willie fb43038179 test(sync): skip the uninspectable-target case on Windows
Windows reports a path under a regular file as not-exist rather than
ENOTDIR, so ClearExtraTarget correctly treats it as missing and the
test's error case cannot occur there. This failed the Windows CI job
since e5dcaa5f6.
2026-10-08 16:48:52 +08:00
Willie 18d6b11347 test: test each rule once, in the package that owns it
Many integration and handler tests re-checked rules that internal/
packages already test, duplicated each other, or ran no product code at
all (a few re-implemented the logic inline, two could never fail). They
slowed the suite without catching anything new.

Delete those, keeping tests for CLI wiring, JSON output, exit codes,
project/global mode and cmd-only logic. Move the agents/extras overlap
check into sync.AgentTargetPaths so the CLI and the server share one
implementation and it is covered by unit tests instead of seven
integration tests.
2026-10-08 16:41:09 +08:00
Willie 0127a150db fix(extras): only treat an actual link as linking to the source
ResolveLinkTarget falls back to EvalSymlinks, which also resolves a real
directory. A real directory reached through a symlinked ancestor of the
source then counted as a link to it, so --remove-target --prune failed with
"not a symlink" instead of keeping the directory. LinksTo now requires the
path itself to be a symlink or junction.

Refs #491
2026-10-08 16:33:19 +08:00
Willie e5dcaa5f64 fix(extras): keep a target in config when it cannot be inspected
ClearExtraTarget treated every Lstat failure on a symlink-mode target as
"nothing there", so a permission or I/O error made the CLI drop the target
from the config and report nothing pruned. Only a missing target is now
forgotten; other errors are returned so the config is kept for a retry.

Refs #491
2026-10-08 16:27:58 +08:00
Willie 44e8bd5927 fix(extras): recognize junctions as links to the extra's source
On Windows without Developer Mode, directory links fall back to junctions,
which os.Readlink can fail to read. LinksTo then treated a skillshare-made
target as foreign, so --remove-target --prune dropped the config entry and
left the junction behind. It now uses utils.ResolveLinkTarget, which falls
back to EvalSymlinks, and compares with utils.PathsEqual.

Refs #491
2026-10-08 16:22:02 +08:00
Willie 36113be45e fix(extras): prune a symlink target only when it links to the source
The CLI's `--remove-target --prune` removed a symlink-mode target no matter
where it pointed, while the dashboard removed it only when it still linked
to the extra's source folder. A user who repointed that link at their own
folder could lose it from the CLI. Both now go through one shared
sync.ClearExtraTarget, so the safer rule applies everywhere; the CLI warns
and leaves anything that is not a link to the source instead of failing.

Refs #491
2026-10-08 16:19:32 +08:00
Willie b90bf2086f Merge pull request #493 from runkids/runkids/extras-sync-api
refactor(extras): pass targets to sync and filter them in one discovery function
2026-10-08 16:17:22 +08:00
Willie d61b25bcf2 refactor(extras): apply target filters in one discovery function
The extras diff, list, status and remove-target commands and the
server's list and diff handlers each discovered an extra's source and
then filtered it with ExtraTargetFiles. A new view that forgot the
filter step would silently show the wrong file count or status.

DiscoverExtraTargetFiles now discovers and filters in one call and
returns the unmatched-include warnings that sync reports. Every caller,
including sync itself, uses it, and ExtraTargetFiles is gone. No
behavior change.

Refs #487
2026-10-08 16:08:03 +08:00
Willie 7a4103b9a8 refactor(extras): validate every mode change and share special extra names
cmdExtrasMode only ran ValidateExtraConfig behind a growing list of
conditions, so each new restriction needed another clause. For a plain
folder extra the full check adds only the mode-name and flatten+symlink
rules, which sync already rejects, so validating unconditionally cannot
refuse a config that syncs today.

The agents and memory extra names were string literals in sync, the
server handlers, the memory store, and the CLI. They now live in
internal/config, and the rename guard moves to ValidateExtraRename so a
future CLI rename reuses it instead of copying the check.

Refs #489
2026-10-08 16:08:03 +08:00
Willie 5c50cc4b2b refactor(sync): pass extra targets instead of long argument lists
syncExtraDir took ten positional arguments, three of them bools, and
CollectExtraFiles took nine. Every new target field meant changing each
signature and every call site, and swapped bools compiled silently.

Both now take the target as config.ExtraTargetConfig plus an
ExtraSyncOptions for dry run, force and project root; SyncExtraTarget
takes the same options. The SyncExtra wrapper only served tests, so it
is gone and the tests call syncExtraDir directly. No behavior change.

Refs #486
2026-10-08 16:08:03 +08:00
Willie 7740ee8798 fix(extras): relink symlinks to a missing source and accept negated includes
- Pointing a symlink-mode extra at a new source after its old folder was
  moved or deleted left the target broken: the old link no longer resolved,
  so it was not recognised as ours, and the next sync skipped it as pointing
  elsewhere. The link text is now compared with the old source as well.
- A negated include such as "!draft.md" only narrows earlier rules, so on
  its own it never matches and was always reported as matching no file.
  Negations are no longer checked for matches.

Refs #435
2026-10-08 15:52:47 +08:00
Willie a9ae5349a2 feat(extras): choose which files each target syncs, and edit targets in place
A directory extra used to sync every file to every target, so a tool that
only wanted a few docs got the whole folder. Each target can now set
gitignore-style include/exclude patterns, matched on the path inside the
source. Merge targets prune links to files that stop matching; copy targets
keep earlier copies, since nothing records which copied files are ours.
Filters are rejected for symlink mode and single-file extras, and sync warns
when an include matches nothing.

The dashboard previously forced users to delete and re-add a target or an
extra to change it. Edit target now changes the folder, file name, mode,
flatten and filters with a live preview; Edit extra renames an extra or
points it at another source folder. A moved target or source drops the
links left at the old place and syncs right away.

CLI: --include/--exclude on extras init, and --add-include, --add-exclude,
--remove-include, --remove-exclude on extras <name>.

Refs #435
2026-10-08 15:31:51 +08:00
Willie 81e0824396 fix(sync): skip unmatched include notices when the source is incomplete
When a followed source link cannot be read, the skill list is partial and
pruning is already skipped. Reporting a filter as unmatched in that state
told users the target gets no skills and sent them to edit a filter that
may be fine.
2026-10-08 14:59:59 +08:00
Willie 47be5105f5 fix(sync): link each target's unmatched filter and ignore blank includes
Two global targets with the same unmatched filter were merged into one
notice whose Edit filter link opened only the first target, leaving the
other unfixed. Only a project's targets share a filter, so other targets
now keep their own notice and link.

A target whose includes were an unmatched pattern plus a blank entry was
not marked as getting no skills, because the check counted the raw list
while filtering drops blanks. It now counts the effective patterns.
2026-10-08 14:48:29 +08:00
Willie 5d5b0f3efb feat(sync): explain include filters that select no skill
The dashboard showed the CLI's raw line, "api-server@claude: include pattern
"*review*" matches no skill in the source", once per target. It named a
config field, did not say the target ends up with no skills, and gave no way
to fix it. Sync now returns these as structured entries; the Sync page
groups a project's targets into one localized notice that says what happens
and links to where the filter is edited. The CLI line also says the filter
adds nothing to the target.
2026-10-08 14:26:41 +08:00
Willie c9b649143d refactor: return slash repo paths and simplify --into repo lookup
GetTrackedRepos returned OS-native paths, so every caller that compared
them with slash paths (RepoRelPath, dashboard repoPath, metadata keys)
had to convert first. Two callers in install_queries already did, and
this branch added four more. It now returns slash paths on every OS,
matching GetMissingTrackedRepos; filepath.Join and filepath.Base accept
them on Windows, and `update org/_repo` now also matches by full path
there. The per-call-site conversions are gone.

Smaller cleanups in the same code:
- repoOf takes the slash relPath and looks up prefixes by substring, so
  the walk no longer splits and joins per directory;
- repo .skillignore matchers are keyed by the same slash rel path, so
  isSkillIgnored no longer needs walkRoot;
- batch uninstall uses utils.IsTrackedRepoDir instead of a literal "_";
- the dashboard uses repoOf where it spelled out isInRepo && folderOf;
- the new tests reuse postBatchUninstall and share one --into sandbox.
2026-10-07 21:35:05 +08:00
Willie 4dd62d4ce5 fix: treat tracked repos installed with --into as repos
`install --track --into org` clones to org/_repo, but skill discovery
only marked a skill as in-repo when the first path segment started with
"_". Everything downstream also assumed the repo name was that first
segment. Skills of such a repo were therefore treated as loose skills:
no source in the dashboard, not grouped under the repo, a skill count of
0 in `status`, and an install hint that pointed at the wrong name.

Discovery now records each skill's tracked repo root (RepoRelPath). A
first-segment "_" folder still counts as before; a deeper one counts
only when the walk saw it as a git clone, so a plain org/_drafts folder
stays a folder. The repo's .skillignore is looked up by the same root.

Consumers move from "first segment" to that root:
- the API exposes it as repoPath, and the dashboard groups, updates and
  uninstalls repos by it;
- `list` and `status` use it for repo names and counts;
- batch uninstall accepts a nested repo name, so the dashboard can still
  remove an --into repo now that its skills are in-repo;
- repo names sent to the dashboard by check and update-all use slash
  paths, so they match repoPath on Windows too;
- the install hint suggests `skillshare update org/_repo`.

Fixes #470
2026-10-07 21:23:26 +08:00
Willie 920b18510a fix(doctor): count only folders with SKILL.md as hand-kept skills
An empty or cache folder in claude's skills folder was reported as a
skill OpenCode loads, and any same-named path in OpenCode's folder hid
a real one. OpenCode loads only folders with SKILL.md, so check for it
on both sides.

Refs #458
2026-10-07 13:07:25 +08:00
Willie 3ec60a3732 fix(doctor): count skills kept by hand in another target's folder
The leak check compared only source skills, so a skill the user keeps
in ~/.claude/skills (which merge mode preserves) passed as harmless,
although OpenCode loads it. Read the writer's folder too and count
entries sync did not put there and OpenCode's own folder lacks.

The wording no longer says these skills are left out by filters, and
the suggestion asks to sync them to opencode, which fits both causes.

Refs #458
2026-10-07 12:58:22 +08:00
Willie 20807579a1 refactor(doctor): keep OpenCode's one-skill-per-name fact in targets.yaml
The rule that OpenCode loads one skill per name lived in a Go map
while its other facts (also_scans, disabled_by_env) live in
targets.yaml. Move it there as one_skill_per_name so a newly verified
runtime needs only a data change.

Also fold doctor's two cross-target warning branches into one, so the
leak and generic messages cannot drift apart, and reuse cmp.Or for the
symlink-mode check.

Refs #458
2026-10-07 11:46:19 +08:00
Willie 03cde2b098 fix(doctor): keep the overlap warning for symlink-mode writers
A symlink-mode target folder is the source itself, so it also exposes
skills that .skillignore hides. Doctor, sync, and the dashboard pass
discovery results without those skills, so a symlink-mode claude
target looked harmless to OpenCode even when OpenCode loaded an
ignored skill through it. Treat that pairing as unknown and keep the
previous warning, unless OpenCode links the source as well.

Refs #458
2026-10-07 11:16:30 +08:00
Willie 834f88efb9 fix(doctor): compare resolved skills when judging OpenCode overlap
OpenCode loads skill files concurrently, so which copy of a name wins
is not fixed; its own folder does not reliably win. A source skill
synced to both folders is harmless anyway because both copies have
the same content. Count only source skills in OpenCode's folder, so a
local skill there no longer marks a same-named skill from another
folder as already present.

The comparison used each target's filtered selection, which skips the
target_naming: standard validation and collision handling sync applies.
When two skills named dev collide in OpenCode's standard folder, sync
writes neither there, yet a claude target filtered to one of them
still delivered it to OpenCode and no warning appeared. Use the
resolved skills that sync writes instead.

Refs #458
2026-10-07 11:10:30 +08:00
Willie d055f9c22a fix(doctor): warn about OpenCode overlap only when skills leak
OpenCode reads .claude/skills and .agents/skills first and its own
skills folder last, keeping the last skill of each name. A skill synced
to both opencode and claude therefore loads once, yet doctor and the
sync summary warned on every setup with both targets, with no way to
silence it.

The real effect is different: skills kept out of opencode by targets:
or include/exclude still reach it through another target's folder.
For opencode, count only those skills, name them in doctor, and point
at OpenCode's OPENCODE_DISABLE_CLAUDE_CODE_SKILLS and
OPENCODE_DISABLE_EXTERNAL_SKILLS. Other runtimes keep the old check
until their rule for same-named skills is verified.

Refs #458
2026-10-07 11:00:05 +08:00
Willie ede7f29aea fix(extras): read written blocks back and keep user lines in block-created files
Two gaps found by the fifth Codex review of #451:

- A source line that reads as a block marker, such as an unfenced
  end marker, was copied into the body, so the freshly written target
  parsed as damaged and every later sync, collect and detach failed.
  The block is now parsed back before writing, and a source whose block
  would not read back as itself is refused.
- When a block had created the target and the user then added lines
  outside it, switching to symlink or copy kept the "created" record,
  so restoring the link later removed the file and the user's lines
  with it. Those lines are now recorded as the restore point.

Refs #436
2026-10-07 00:43:13 +08:00
Willie 15dc6f47e3 fix(extras): guard block targets against source links, open fences and sibling reordering
Four gaps found by the fourth Codex review of #451:

- The check that refuses a target linked to another extra's source ran
  for import only, so a prepend or append target linked that way had
  its block written straight into that source. It now runs for every
  mode that edits the target in place.
- Switching a target with a damaged block to symlink or copy recorded
  the damaged block as the user's restore point, so detaching later
  brought it back. Recording the restore point now fails on a damaged
  block.
- Appending to a file that ends inside an open code fence put the begin
  marker inside that fence, so the next sync missed the block and
  appended another. Such an append is refused. Separately, a block body
  with an unclosed fence now ends at the end marker whose body matches
  the block's hash, even when the user's own code follows.
- A second prepend block counted its sibling above it as misplacing it,
  so each sync moved one ahead of the other. Placement now ignores other
  managed blocks on the same side.

Refs #436
2026-10-07 00:37:40 +08:00
Willie 876e165f25 fix(extras): refuse damaged blocks and plan block defaults without the leaving files
Five gaps found by the third Codex review of #451:

- Switching a target with a damaged block (a deleted end marker) to
  import ignored the parse error and added the @ line, so the tool read
  the stale block as well. The switch now fails until the block is
  repaired.
- Detaching such a target reported success without touching the file,
  so Assign dropped the connection and left the block with nothing
  configured to remove it. Detach now returns the error.
- PlanAssign decided whether a non-import target could take several
  files, and Assign chose each new file's mode, from the extras before
  the files being detached were gone. Removing the only block holder
  while adding two files therefore passed the plan, then gave both new
  files a link, the second replacing the first. The plan now detaches
  first and Assign applies the modes the plan validated.
- When the last block left a file it had created but the user had since
  added lines to, the created record stayed, so a later link attach and
  restore deleted the user's file. The attach record is cleared once no
  managed block or import line remains.
- A source with a fence that never closes swallowed the block's own end
  marker on the next parse, so a freshly written target read as
  damaged. An open block's end marker now ends it when the fence never
  closes.

Refs #436
2026-10-07 00:30:34 +08:00
Willie c88b7ff341 fix(extras): drop the old representation when a target enters or leaves a block mode
The mode picker stores the new mode before syncing, so the block and
import handlers saw the previous mode's output as the user's content:
copy → prepend kept the whole copied source beside the new block,
import → prepend kept the @ line, and prepend → import kept the block.
The tool then read the instructions twice, and detaching removed only
the new representation.

Entering a block mode now rebuilds a leftover copy from the attach-time
base (backing up an edited copy as a mode-switch drift, as import does)
and drops this extra's @ line; entering import mode drops this extra's
block, keeping a hand-edited one as a drift backup.

Refs #436
2026-10-07 00:21:01 +08:00
Willie 899b52a78e fix(extras): keep block edits and placement straight across mode changes
Four gaps in the managed-block modes, found by Codex review of #451:

- Switching a block target to symlink or copy recorded the restore point
  from the file as it stood, block included, so restoring the target
  later brought back instructions the user had removed. The restore
  point now strips this extra's block, as it already stripped its
  import line.
- Detaching a target whose block had been edited by hand dropped the
  edit outright. The edited file is now kept as a drift backup first,
  as an edited copy or link is.
- Fences were only tracked outside a block, so a source that quoted a
  marker in a fenced example produced a target that read as damaged on
  the next sync. Fences are tracked inside the block body too.
- Changing a synced target between prepend and append left the block
  where the old mode had put it, since body and hash still matched. A
  block in the other mode's place is moved.

Refs #436
2026-10-07 00:13:50 +08:00
Willie 05ff8c675a feat(extras): prepend and append modes for single-file extras
Tools without an @import directive (codex, gemini, cursor) could only
take a shared instruction file as a symlink or copy, which replaces the
target's own file. Teams that want one shared AGENTS.md plus the user's
own notes in the same file had no way to express that.

prepend and append write the source into the target file as a managed
block fenced by skillshare:extra markers that carry the source path and
a content hash. Sync inserts the block once and then rewrites it in
place, status reports modified when the block body no longer matches
its hash, Collect copies the edited body back to the source, Reapply
rewrites the block from the source, and restore removes only the
block. Lines outside the block, and markers inside code fences, are
never touched. Several managed blocks (and an import line) may share
one target file; the connection validator only rejects a file when a
replacing mode (symlink, copy, merge) is involved.

Refs #436
2026-10-07 00:04:00 +08:00
Willie 2ef704a77b fix(sync): isolate extension modules and condense diagnostics
Keep bundled CommonJS converters working inside ESM projects. Show concise sync failures with expandable original diagnostics and clarify that the last-sync card covers skills and agents only.
2026-10-06 21:36:04 +08:00
Willie 5e02ef7ef0 refactor(sync): select a target's skills through SelectTargetSkills
Status, doctor, diff, the dashboard's target and diff handlers and analyze each
repeated FilterSkills followed by FilterSkillsByTarget, and only some dropped
disabled skills first. Routing them through SelectTargetSkills keeps their
answers identical to sync and mcp serve when a selection rule changes.

The callers that did not drop disabled skills get discoveries without them, so
their output does not change.
2026-10-06 14:18:20 +08:00
Willie cc7d802411 feat(mcp): serve skills over MCP with the SEP-2640 Skills extension
Agents on a disposable VM, in a hosted assistant or behind an MCP gateway can
reach an MCP endpoint but not the folder skills sync to, so they got tools and
none of the user's skills (#428).

`skillshare mcp serve` is a read-only server for the skills skillshare already
manages. It declares io.modelcontextprotocol/skills and implements skills/list,
skills/get and resources/read: one entry per skill, its URI from the source
path, the full frontmatter, and every file with a sha256 digest and size.
--target applies that target's selection, and the source is reread at most
every 5 seconds so install, update, enable and disable show up without a
restart; unchanged files keep their digest. stdio is the default; --http
serves Streamable HTTP and needs SKILLSHARE_MCP_TOKEN off loopback.

Skills the extension cannot carry are skipped with a warning instead of being
published incomplete: a name that breaks the Agent Skills rules or differs from
its directory, more than 512 files or 16 MiB, or a nested skill that is not
served. --check lists them without serving. The naming rules moved to
internal/skillpkg so sync and the server share them.

Few clients support the extension yet, so the server also offers list_skills
and read_skill tools. A client that declares the extension does not see them,
so it never gets each skill twice.

sync.SelectTargetSkills is the one place that turns discovered skills into a
target's selection (enabled, include/exclude, frontmatter targets).

Refs: #428
2026-10-06 14:18:16 +08:00
Willie 8e9ef1c806 test(sync): make the tests pass on Windows and run them in CI
Ten tests assumed POSIX behaviour:

- Five asserted os.ModeSymlink, but Windows links with a junction;
  check utils.IsLinkMode instead.
- Two used `/abs/...` as an absolute path, which has no volume on
  Windows; give the fixtures one.
- Windows has no permission bits to preserve, so the 0600 check is
  skipped there.
- Reading a file as a directory reports not-exist on Windows, which
  prune ignores, so that prune-error test is skipped there.
- A single-file extension relies on the shebang and the executable bit,
  so ListExtensions finds only directory extensions on Windows, as the
  extras docs describe.

Add ./internal/sync and ./internal/trash to the windows-test package
list so they stay green.

Refs #344
2026-10-06 09:40:50 +08:00
Willie d97f6d88b7 fix(trash): keep junctions as junctions when moving across volumes
When the skills source and the trash live on different volumes, the
cross-device fallback in moveLink and copyDir recreated a Windows
junction with os.Symlink. That needs Developer Mode or elevation, which
the junction was chosen to avoid, so `unlink` and `trash restore` could
fail after `link` had succeeded.

Recreate a junction as a junction through a shared helper, and keep the
original link in place when creation fails. CreateJunction moves from
internal/sync to internal/utils so trash can reuse it.

Refs #420
2026-10-06 00:32:38 +08:00