Commit Graph
1210 Commits
Author SHA1 Message Date
Willie 5338d6a4c1 feat(ui): check plugin updates on load and update them in one batch (#527)
* feat(ui): check plugin updates on load and update them in one batch

Updating plugins took four steps each: press Check updates, press Update
on one row, review a second preview, apply, then check again because the
list did not know the update had happened. Six plugins meant six rounds.

The page now checks once in the background when it opens, so rows show
their new version without a click. The header's Check updates button
becomes "Update N" when something is behind and opens one dialog: every
plugin with an update is ticked, a plugin on several Agents is one row
whose Agents can be left out, and imported installs Skillshare cannot
update sit apart. One button runs them in turn through the existing
preview and apply, so no new API is needed. Progress, results, errors
and per-Agent retry stay in the same dialog, and the applied results
update the page state, so nothing has to be checked again.

The count and the dialog both come from what is still behind after the
last check, limited to Agents that can be updated from here, so a
partial batch is not offered again and Agents with check but no update
(OMP, Antigravity CLI, Grok) do not inflate the count.

* fix(ui): keep batch plugin updates to what the user reviewed

Codex review of #527 found four ways the batch update could act on
something other than what the dialog showed:

- A source that moved between the background check and the click was
  installed straight from the fresh preview, so a newer version or new
  components went in unreviewed. The batch now compares each fresh plan
  with the version and commit the check showed, applies nothing when
  they differ, says so on the row, and runs a quiet check so the next
  dialog shows the new version for review.
- A retry of the failed Agents that failed again lost that subset, so a
  third try re-sent Agents that had already updated. A failed row now
  always keeps the Agents it failed on.
- An update the server skipped (its marketplace gone, say) counted as
  done: the row said updated and the plugin left the update count.
  Skipped outcomes now keep the Agent pending and show as skipped.
- A plugin removed after the check stayed in the update count and
  failed with "not found" when picked. Pending updates now drop any
  plugin or Agent binding the inventory no longer has.

* fix(ui): show a manual check's result and each Agent's own version move

Codex's second review of #527 found two gaps:

- A check the user pressed that found nothing to update from here (only
  imported installs, or everything current) opened nothing, so the
  "update inside the Agent" guidance and the up-to-date result never
  showed. The check now reports whether it came back, and a check the
  user asked for opens the dialog; the background check on load stays
  quiet.
- A plugin on several Agents showed one version move built from the
  first Agent's installed version and the first new version found, which
  can mix Agents that come from different sources. The row now shows one
  move only when every Agent makes the same one, and each Agent's own
  move otherwise.

* fix(plugin): carry the source digest on a check so a batch update can tell it moved

Codex's third review of #527: a local-directory plugin has no commit,
so when its files changed again after the check while the manifest
version stayed the same, the batch's version and commit comparison
passed and the fresh preview was applied without the user seeing it.

The check copied the installed binding, so its digest was the one
already installed, not the source's. It now sets the discovered digest
alongside the version and commit, as the update preview already does.
The dashboard keeps that digest with each update it found and refuses
to apply when the fresh preview's digest differs, marking the row as
changed since the check. An npm package has no digest and is unaffected.

* fix(ui): list blocked check results and drop unticked Agents from the batch

Codex's fourth review of #527:

- A check can mark an Agent blocked when the updated source no longer
  offers a compatible plugin for it. The update dialog listed only
  updatable, native-check and up-to-date results, so it hid the block
  and could say everything was current. Blocked results now get their
  own section with the reason, and the empty state says nothing can be
  updated from here rather than that everything is up to date.
- An Agent unticked after the check stayed in the pending updates;
  picking it produced a no-op that the batch reported as updated.
  Pending updates now skip bindings with sync off, as the row's own
  behind count already does.

* fix(ui): count partly skipped plugins as updated and surface a failed re-check

Codex's fifth review of #527:

- When one Agent of a plugin updated and another came back skipped, the
  row was marked skipped, the summary counted no update, and the Agent
  that did update was not shown. A row now names which Agents updated
  and which were skipped, and the summary counts any plugin with an
  updated Agent.
- After a source moved since the check, the follow-up check ran quietly,
  so if it failed the stale update stayed offered and every retry hit
  the same skip. The moved plugin now leaves the found updates, and the
  follow-up check reports its failure like any check the user started.
2026-10-11 22:19:14 +08:00
Willie 0792d0e1a2 fix(config): keep the comments of a key the command removed (#528)
A comment on a key the command removed was lost. It now sits in front of the next surviving key, or on the last entry of its section, in source order. Adds the config_keeps_comments runbook.

Refs #525
2026-10-11 22:02:55 +08:00
Willie 551a1546df fix(config): keep the comments of config.yaml when a command writes it (#526)
Every writer re-encoded the in-memory struct, so a command such as target --mode copy dropped every comment. marshalConfig now takes the file being replaced and copies its comments onto the keys that are still present; list items are matched by name, and a read error fails the save. registry.yaml goes the same way.

Fixes #525
2026-10-11 21:21:31 +08:00
Willie 89f4b9425a refactor(reconcile): share the lock pin mover, skip adoption when no record is gone (#524)
Cleanup after #523: install.MoveLockPins shared by skillmove and the project reconcile; one server store reload and reconcile dispatcher; adoption skips the source walk when no plain record's directory is missing.
2026-10-11 04:19:32 +08:00
Willie 3a5da6b529 feat(sync): adopt the install record of a skill moved by hand (#523)
After a plain mv, only install or Install missing moved an installed skill's record; sync now adopts it too (CLI global, CLI project, dashboard), never prunes, and skips on --dry-run. A hand-moved project skill keeps its lock pin; a same-name nested skill never takes a live record; metadata load failures are sync warnings.
2026-10-11 03:50:58 +08:00
Willie f1ca009de3 fix(move): recompute collisions after a refusal, report an unreadable .skillignore, preflight batch dry-run --into (#522)
Three follow-ups from the review of #520: a name refused for a
collision no longer makes an unrelated name in the same batch fail
for a path that will not exist, a .skillignore that cannot be read
after the rename is reported instead of silently skipped, and the
batch install --dry-run path runs the same --into preflight as the
real install.

Closes #521
2026-10-11 01:04:53 +08:00
Willie bf1731dec4 feat(move): move installed skills and folders without losing their records (#520)
Add skillshare move and POST /api/resources/batch/move so skills and
whole folders can change folder inside the source while keeping their
.metadata.json entry, accepted audit findings, lockfile pin, config
group, .gitignore and literal .skillignore lines. Moving by hand lost
the record and made the next install start over. install --into now
refuses a folder inside a skill or a tracked checkout.

Refs #510
2026-10-11 00:43:47 +08:00
Willie dcffa2ec5e fix(install): keep a moved skill's record instead of reinstalling it (#513)
* fix(install): keep a moved skill's record instead of reinstalling it

Install records are keyed by path, so a skill moved with mv shows up as
missing. "Install missing" (and bare `skillshare install`) then cloned it
again at the old path, leaving two copies that both sync to targets, and
reconcile could hand the new copy's record to the moved one.

A gone record now follows an unrecorded directory of the same name whose
files match the recorded hashes, when exactly one such directory exists.
Install-from-config skips such entries and reconcile re-keys the record,
so the moved copy keeps its source. Same-name skills with other files are
left alone, so an update can never overwrite them from that source.

Refs: #510

* fix(install): keep audit acceptances and unreadable links out of moves

Re-keying a moved skill went through Remove, which also drops the audit
findings accepted for the old path, so an unchanged skill could block or
prompt again on its next update. MoveEntry now carries them to the new key.

A record below a first-level source link that cannot be read looks gone
to Lstat, so an identical copy elsewhere could take its record while the
link was down. Such records are no longer matched as moved.

* fix(install): drop legacy-path acceptances and respect lock pins on move

A legacy basename key such as `demo` with group `old` keeps its accepted
audit findings under `old/demo`. MoveEntry removed only the key's own
acceptances, so the old path kept them and a later skill placed there
would inherit them without a new --force. It now deletes the old path.

When the lockfile pins another commit than the moved copy holds, treating
the copy as the moved skill re-keyed its stale record and let the project
lock be rewritten with the older commit. Such copies no longer count as a
move, so the pinned commit is installed as before.

* fix(install): search for moved skills only where reconcile looks

The search for a moved copy walked into installed skills and tracked
checkouts, which reconcile skips. A copy found there made install skip the
skill, then reconcile never saw the copy and pruned the record, and in
project mode the config entry with it. The search now stops at the same
boundaries.

* fix(install): never take a recorded skill as another's moved copy

Two identical skills can be recorded at different paths. When one of them
went missing, the other matched its hashes and was taken as its moved
copy, so install skipped the missing skill and reconcile pruned its record.
A directory with a record of its own is now never a move destination.

* fix(install): derive moved-copy paths from the resolved source root

sourcewalk.WalkDir reports paths under the resolved source root, but the
moved-copy search took them relative to the unresolved one. With a linked
source (or Windows short temp paths) every path came out as ../..., so the
installed-skill boundary never matched and a copy inside an installed
parent could be taken as the move, after which reconcile pruned the record.
The search now resolves the root first, as reconcile does.

* fix(install): move a record only to one copy of what the config declares

Three cases still let a move drop or misplace a record:

- In project mode the manifest can point a skill at a new source while a
  copy of the old one exists elsewhere; that copy was taken as the skill,
  so the new source was never installed. The record's source and branch
  must now match the config entry.
- A git checkout reconcile treats as tracked could be accepted before the
  tracked boundary was checked; the boundaries now run first.
- With two identical copies, reconcile re-keyed the record to whichever
  it walked first. Both reconcile and the install-from-config search now
  require exactly one destination, and reconcile decides after the walk.

* fix(install): clear accepted findings left at a move destination

A removed legacy grouped entry can leave findings accepted for its path
behind. MoveEntry only wrote the destination when the moved skill had its
own acceptances, so a skill moved into that path inherited findings it
never accepted. The destination is now cleared before the transfer.

* fix(install): follow a moved skill only while its declaration still matches

The install-from-config search compared source and branch but not the
tracking mode, so a skill switched to tracked was satisfied by an old
plain copy and never cloned.

Project reconciliation, which other installs also run, inferred moves
without looking at the manifest at all. A record whose declaration now
names another source could follow a copy of the old source, after which
the manifest entry was rewritten to that old source. Moves in project
mode now require the declaration to still match the record, through the
same MatchesDeclaration check the install path uses.

* fix(install): infer no move while a source link is unreadable

An unreadable followed source link can hide a second identical copy, so
a copy that looked unique could take the record arbitrarily. Reconcile
and the install-from-config search now infer a move only from a complete
inventory; reconcile already keeps the gone record in that case.

* fix(install): infer no move when the source walk hit an error

Both walks dropped traversal errors, so an unreadable directory that hid
a second identical copy left the visible one looking unique and it could
take the record. Any walk error now counts as an incomplete inventory,
like an unreadable source link, and no move is inferred from it.

* fix(install): keep a record whose move waits on a failed walk

When a walk error deferred a move, the walk still counted as complete, so
pruning dropped the gone record along with its accepted audit findings
and it could never follow the copy. A failed walk that deferred a move
now marks the inventory incomplete, as an unreadable source link does;
a failed walk with no move candidate keeps the old behavior.

Also correct InstallFromConfig's comments, which still said reconcile
runs only after an install.

* fix(install): move a moved skill's gitignore rule in project mode

Project reconcile added the managed ignore rule for a moved skill's new
path but left the old one, and the gitignore update only ever adds. If
the old path later held source-controlled files, Git kept ignoring them
without a word. Reconcile now reports the paths records moved away from,
and project reconcile removes their managed rules before adding the new.

* test(config): skip the unreadable-directory reconcile test on Windows

Windows does not stop reading a directory created with mode 0, and
os.Geteuid reports -1 there, so the root-only skip let the test run and
fail on the Windows runner.

* fix(install): count a candidate that cannot be hashed as an incomplete search

MovedEntryKey dropped a same-name candidate whose files could not be
hashed, so a readable identical copy beside it looked unique and could
take the record. It now returns the hash error, and reconcile and the
install-from-config search treat it like a walk error: no move is
inferred from that scan, and reconcile keeps the record waiting.
2026-10-10 23:14:52 +08:00
Willie 81974cf350 fix(resource): never skip a hidden-named agents source root (#515)
AgentKind.Discover and the skill detail file listing skipped every
hidden directory, including the walk root itself. The `!= "."` guard in
agent.go never fires because walkRoot is an absolute resolved path, so a
sources.agents directory such as ~/.agents discovered zero agents.

Exempt the walk root (`path != walkRoot`), matching the other walks in
the repo. Nested hidden directories are still skipped.

Related to #511 (same class as #514).
2026-10-10 22:03:53 +08:00
Willie d2f5936be9 fix(sourcewalk): never skip the source root as a target dotdir (#514)
SkipTargetDotDir only exempted dotdirs directly under the walk root, never
the root itself. ProjectTargetDotDirs() always contains ".skillshare", so a
source whose basename is a target dotdir (".skillshare", ".claude", ...) had
its first Walk callback return SkipDir. Discovery then saw an empty source:
`skillshare list` returned [] and sync pruned previously managed links.

Exempt path == walkRoot in the shared helper so both callers
(sync discovery and resource skill discovery) are fixed. Nested target
dotdirs are still skipped and first-level ones stay visible.

Fixes #511
2026-10-10 21:43:35 +08:00
Willie 2ce46834e2 fix(collect,install): collect only real skills; let --track take a local git path (#508)
* 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.

* fix(install): keep the drive letter in file:// clone URLs for local --track paths

A Windows path such as C:/repo produced file://C:/repo, which makes C: the
URI authority instead of part of the path, so a tracked install from a local
Windows repository could clone the wrong location. Prefix the missing slash
so the URL is file:///C:/repo; POSIX paths are unchanged. Also cover the
dashboard install endpoint with a local-path --track test.

* 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.

* fix(install): escape the local path in the file:// URL used by --track

Git decodes a file:// URL, so a repository path containing %20, %2F, a space
or # was cloned from a different path than the one IsGitRepo accepted. Build
the URL with net/url so those characters are escaped; drive-letter and POSIX
paths keep their form. The integration test now installs from a directory
whose name contains a space and a literal %20.

* fix(install): accept a local bare repository path for --track

A bare repository has HEAD and objects at its root but no .git entry, so the
local-path check rejected it while file:///same/path cloned fine. Add
IsLocalGitRepo (working tree or bare) and use it for both the --track
normalization and the --branch guard.

* test(install): build the bare repo path from a Windows file URL correctly

makeRemote returns file:///C:/dir on Windows; trimming only file:// left
/C:/dir, which filepath.Abs turned into D:\C:\dir, so the bare-repo test
failed on the Windows runner. Drop the slash before the drive letter.

* fix(install): refuse a --track local source that is the install destination

--force removes the tracked destination before cloning. When the local path
given to --track is that same directory, the removal deleted the only clone
source (and any unpushed work) before the clone failed. Compare the two with
os.SameFile, which also covers symlinked paths, and stop before touching the
destination.

* 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.

* fix(install): treat file://localhost URLs as local clone sources

Git clones file://localhost/path from the local filesystem, but the
containment guard only recognised an empty authority, so --track --force
could still delete a source given that way. Accept localhost (any case) as
local.

* test(install): build the localhost file URL from a slash path

On Windows the temp path starts with a drive letter, so prefixing it onto
file://localhost produced file://localhostC:\... instead of a valid URL and
the case failed on the Windows runner. Convert to slashes and add the
separator explicitly.

* fix(install): clone --track --force into a staging dir and swap it in last

--force removed the existing tracked repo before cloning, so any source that
lived under it (plain path, file:///, file://localhost, UNC, symlink or 8.3
alias) was destroyed before git could read it, and a failed clone also lost
the old repo. Clone beside the destination, run the checks and the audit on
the staging copy, then move the old repo aside, rename the new one in and
drop the backup; on any failure the staging copy is removed and the old repo
stays. The pre-removal containment refusal now covers plain local paths only
(the url.Parse special-casing is gone).

* fix(install): refuse a file:// --track source inside the forced destination

The staged swap in 7375400 still lost data for a file:///, file://localhost
or UNC source nested under the destination: the clone succeeded, the old repo
(with the source inside it) was renamed to the backup, and removing the backup
deleted the source's uncommitted work, which a clone cannot carry.

Restore the file URL to local path mapping (now including UNC hosts) so the
containment refusal covers every local spelling, not only plain paths. The
test now keeps an uncommitted file in the source and requires it to survive.

* fix(install): apply the source-inside-destination refusal only to --force

The refusal ran before the --update branch, so `install <tracked repo path>
--track --update` was rejected even though an update pulls the existing
checkout in place and removes nothing. Only the forced replacement can
destroy a source that lives under the destination, so check there.

* fix(install): report a forced clone's root skill under its tracked name

With --force the repo is discovered in the .skillshare-clone-<stamp> staging
directory, and discoverSkills names a root SKILL.md after the directory, so
the CLI summary, dashboard response and oplog listed a random staging name
instead of _foo. Use the tracked name for the root entry.

* fix(install): stage fresh tracked clones so cleanup never hits another installer

A fresh tracked install cloned straight into the destination, and the
deferred cleanup removed it on any failure. If another process created the
same tracked repo between the existence check and the clone, the failing
install deleted that process's checkout. Clone every install into its own
staging directory and rename it in last; a claimed destination makes the
rename fail and only the staging copy is removed.
2026-10-10 01:06:23 +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 b0d87fba28 feat(sync): make prefixed target naming misconfigurations visible (#503)
* feat(sync): make prefixed target naming misconfigurations visible

Prefixed naming (#497) works, but several of its failure modes only showed up
at sync time or gave advice that cannot be followed:

- A collision that only prefixing creates told the user to "rename one in
  SKILL.md", which a tracked skill cannot do, and never said the prefix caused
  it. The hint now names the prefixing and points at renaming the other skill or
  re-tracking the repo with --name.
- `target add` silently wrote mode: copy when the inherited naming is prefixed.
  The CLI now says so.
- A target that resolves to prefixed outside copy mode was reported only by
  sync. status, doctor and target list (plain and JSON) now flag it, and the
  sync/validation and `--skills=true` errors say how to fix it.
- The dim "duplicate skill names (isolated by ...)" line printed on every sync
  even when nothing was wrong, and before a failing sync. Isolated duplicates
  are not a problem, so it is dropped; the website docs still showed an
  outdated form of this output and are corrected in all locales.

* fix(status): flag prefixed-outside-copy in the TUI list and status --json

Codex review of #503 found two surfaces the new check missed:

- The interactive `target list` (the default on a terminal) never read the
  item's naming error, so a prefixed + merge target looked healthy there. The
  list row now marks the mode with "!" and the detail panel shows the fix.
- `status --json` (global and project) builds its target entries directly, so
  scripts got no signal. Each target now carries a `warning` string, matching
  `target list --json`.

* docs(troubleshooting): sync no longer prints a message for isolated duplicates

The collision troubleshooting tip still said sync shows an info message when
filters isolate duplicate skill names. That line was dropped, so the tip now
says sync prints nothing about them. Codex review of #503 flagged the stale
English page and its four translations.

* fix(config): point managed-project naming errors at the project settings

The "set mode: copy on the target" hint is wrong for a target a global
`projects:` entry expands into: it cannot be edited with `target` or under
`targets:`, and the mode lives in the project's skills settings. The hint now
depends on whether the target belongs to a managed project (Codex review of
#503).

The naming/mode check becomes a TargetConfig method so status, doctor and
target list share it, which also lets the hint see the project root. Along the
way: doctor reuses it, the TUI list renders the mode once, and
reportTargetAdded takes a flag instead of comparing a mode string.

* fix(config): hint the project settings for managed-project naming errors

ProjectNamingError (the config-load check for a global `projects:` entry) still
returned the bare naming error, so a project that inherits prefixed with a
non-copy mode got no fix. It now names the project's skills settings, like the
expanded targets do. The built-in skill's sync reference also mentions that
status, doctor and target list flag the misconfiguration before sync.

Found by the second /code-review pass on #503.

* fix(sync): detect prefix collisions from the colliding paths

reportCollisions decided a collision came from prefixing when its name was not
also a duplicate in the source. A tracked skill that joined two ordinary
skills already sharing the name was therefore sent to the "rename one in
SKILL.md" hint, which a tracked skill cannot follow (Codex review of #503).

A collision on a prefixed target that includes a tracked path now gets the
tracked-skill hint, whatever else shares the name. The wording no longer claims
prefixing renamed the skill, since a name that already starts with the repo
name is unchanged.

* fix(sync): use discovered repo metadata for the tracked-skill hint

The collision hint treated any path segment starting with "_" as a tracked
repo, so an ordinary skill under a folder such as org/_drafts (no .git) was
told it could not be renamed and to re-track a repo that does not exist. It now
uses DiscoveredSkill.IsInRepo, the same signal prefixed naming uses.

The prefixed docs also gain the fix for a target a global `projects:` entry
expands into (projects.<root>.skills.mode: copy), since `target` cannot edit
those. Both from Codex review of #503.

* fix(sync): keep both collision hints when targets disagree

The same name can clash on a prefixed target with a tracked skill and on
another target between ordinary skills only. The prefixed flag was OR-ed across
targets, so the second case lost its rename/filter hint. Track both kinds
separately while grouping, and print each hint that applies (Codex review of
#503).

* fix(sync): keep the rename hint inside a mixed collision group

When a tracked skill and two ordinary skills share a prefixed name, re-tracking
the repo fixes only the tracked one; the ordinary pair still clashes and is
excluded. The group now also shows the rename/filter hint when at least two of
its participants are not tracked (Codex review of #503).

* fix(sync): offer filters in the tracked-skill collision hint

Two tracked skills of the same repo with the same name collide after
prefixing, and neither renaming a tracked skill nor re-tracking the repo
separates them. The hint now also names include/exclude filters, so every
collision on a prefixed target has an actionable remedy (Codex review of #503).

* docs(sync-modes): limit the target list claim to targets under targets

target list builds from the config without project expansion, so it cannot
flag a target a `projects:` entry expands into; status and doctor can. The
prefixed paragraph and the built-in skill reference said all three flag it
(Codex review of #503).
2026-10-10 00:00:23 +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 4c433281a8 fix(sync): add a missing name before the first frontmatter key
Appending an inherited (merge-key) name at the end of the frontmatter
kept running into what may follow the mapping: a "..." end marker,
comments after it at any indent. Its indent also came from the first
key node's column, which sits after "? " for an explicit key. Insert
the key before the first key instead, with that line's own indent; an
explicit key overrides a merged one wherever it stands.
2026-10-09 12:52:41 +08:00
Willie 666df43edd fix(sync): rewrite only the name value, keeping its key as written
Rewriting the whole name line dropped whatever sat on the key side: an
anchor on the key (&f name:) left its aliases undefined, and quoting,
"name :" spacing or an explicit "? name" key were rewritten. Keep the
text before the value as written, located from the YAML node, and
replace only the value span, keeping the value's own anchor.
2026-10-09 12:44:24 +08:00
Willie 183beeba54 fix(sync): keep the name's YAML anchor when prefixing it
A name that defines an anchor (name: &n prototype) lost it on rewrite
while aliases to it (description: *n) stayed, so the copied frontmatter
had an undefined alias. Keep the anchor on the new value, in both the
line rewrite and the flow-mapping rewrite.
2026-10-09 12:37:04 +08:00
Willie 967e1fad07 fix(sync): find a document end marker followed by a comment
Only a bare "..." was taken for the end marker, so "... # end" (or
comment lines after the marker) still got the inherited prefixed name
appended outside the mapping. Accept a trailing comment on the marker
and skip comment lines while looking for it.
2026-10-09 12:31:18 +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 5cf18e2723 fix(sync): add the prefixed name before a YAML document end marker
When the name is inherited (a merge key) and the frontmatter ends with
"...", the new name: was appended after the marker, outside the
mapping, so the copy kept the old name or held an invalid second
document. Insert the key before the marker.
2026-10-09 12:16:54 +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 4e850e5a3f fix(sync): decode the whole block when the name line is not a string
A multi-line quoted name such as "proto\ followed by an indented line
fails to decode alone, and the literal first line was returned, so the
skill was skipped. Decode the whole frontmatter whenever the name line
does not decode to a string; keep the literal only for frontmatter YAML
rejects.
2026-10-09 12:10:08 +08:00
Willie ca38177d25 fix(sync): decode the whole frontmatter when no plain name line is found
Each YAML form the line scanner did not know (explicit "? name" keys
this time, after aliases, merge keys and flow mappings) came back as an
empty name and the skill was skipped under standard and prefixed
naming. Keep the early stop for a plain name line and decode the whole
block otherwise, which also replaces the per-form special cases.
2026-10-09 12:03:11 +08:00
Willie adf375d3e2 fix(sync): keep the indent of an indented root mapping when renaming
ParseSkillName accepts frontmatter whose root mapping is indented as a
whole, but SetFrontmatterValue wrote name: at column zero beside the
indented keys, so a prefixed copy got malformed YAML. Write the key at
the column the mapping's keys use.
2026-10-09 11:56:12 +08:00
Willie 86ff94fa8a fix(target): check prefixed naming when turning skills back on
Skills-off targets may now keep prefixed naming under a merge mode, but
target --skills=true and the dashboard's skills toggle flipped them on
without checking, so the next sync skipped the target and its agents.
Refuse to turn skills on while the effective naming needs copy mode.
2026-10-09 11:47:51 +08:00
Willie 0782395634 fix(config): skip the naming-mode check for targets with skills off
A target with skills disabled syncs no skill but still syncs agents,
yet prefixed naming with a merge mode marked it invalid, so sync and
the dashboard dropped it before agent sync. Check naming against mode
only when skills are enabled, for targets, projects and the mode PATCH.
2026-10-09 11:41:27 +08:00
Willie dd8d03fa7c fix(config): keep agents-only projects valid under prefixed naming
An agents-only project expands into a target whose skills config only
excludes everything, and it inherited the global naming, so prefixed
with a merge global mode marked the whole target invalid and its agents
stopped syncing. Give that skills config flat naming, since it syncs no
skill.
2026-10-09 11:34:00 +08:00
Willie 65f468c0fd fix(sync): resolve a skill name inherited through a YAML merge key
A name brought in by "<<: *defaults" has no literal top-level name line,
so ParseSkillName returned empty and naming validation skipped the
skill. When a merge key is present and no explicit name is found,
decode the whole block; an explicit name still wins.
2026-10-09 11:34:00 +08:00
Willie a9e3613282 fix(target): add global targets in copy mode when they would inherit prefixed
Top-level prefixed naming with a merge global mode is valid while every
target overrides copy, but target add (CLI, dashboard, and Agent config
directories) wrote new targets without a mode, so they inherited the
invalid pair and failed at sync. Share one rule for global and project
additions: write copy mode when the inherited naming needs it.
2026-10-09 11:26:40 +08:00
Willie fae3439647 fix(sync): resolve a skill name given as a YAML alias
ParseSkillName decoded the name line alone, so "name: *anchor" lost the
anchor defined earlier and came back as the literal alias, which naming
validation rejected. Decode the whole frontmatter block for an alias.
2026-10-09 11:26:40 +08:00
Willie 7b676502a5 fix(target): add project targets in copy mode under prefixed naming
A project target defaults to merge mode and target add has no mode
option, so adding one to a project whose top-level target_naming is
prefixed reported success and then failed validation at sync. Give the
new target copy mode in both the CLI and the dashboard API.
2026-10-09 11:17:48 +08:00
Willie e1889e4f6b fix(server): check unexpanded projects before changing the global mode
A project whose folder is missing expands into no target, so the
dashboard's mode PATCH never saw its skills settings and could move the
global mode off copy under a project inheriting prefixed naming. Run
the project naming check against the requested mode as well.
2026-10-09 11:07:11 +08:00
Willie 04dacce117 fix(sync): read a block-scalar skill name
ParseSkillName stopped at "name: >-" and decoded only that header, so
the name was empty and the skill was skipped under standard and
prefixed naming. Keep reading the indented lines of a block scalar
before decoding it.
2026-10-09 11:07:11 +08:00
Willie c95e385698 fix(sync): read a skill's name from any valid YAML key form
Target naming resolution read name: by literal line prefix, so a quoted
key, "name :", a flow mapping or a trailing comment gave an empty or
wrong name and the skill was skipped under standard and prefixed naming;
an indented metadata.name could also win. Match only top-level keys,
decode the name line as YAML, and decode a flow mapping whole, while
still stopping at the name line.
2026-10-09 10:58:48 +08:00
Willie 6e328b0a88 fix(config): reject prefixed naming on a managed project in raw configs
The dashboard's raw config save validates before projects expand into
targets, so a project with target_naming: prefixed and a non-copy mode
was saved and then skipped at sync. Check each project's effective
naming and mode in ValidateConfig, sharing the check ValidateProjects
already ran.
2026-10-09 10:46:00 +08:00
Willie 84cccb0d2f fix(sync): rewrite the name inside flow-style frontmatter
Keys of a flow mapping share one line, so the span-based rewrite added a
second name: beside {name: ...}, or dropped the whole line and the
fields before name when it came last. Write a flow mapping back whole
with the new value instead.
2026-10-09 10:46:00 +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 0b496c9de7 fix(config): validate a project target against the inherited naming
ValidateProjectConfigForSync read the target naming from loader-only
state, so a raw project config (the dashboard's config save) with
top-level target_naming: prefixed and a merge-mode target passed
validation, then failed at sync. Seed the project default before
validating each target, as the global validator already does.
2026-10-09 10:19:49 +08:00
Willie 330b34510e fix(sync): replace the whole name entry when prefixing a copied skill
The prefixed rename matched "name:" line by line, while resolution parses
the frontmatter as YAML. A quoted key, "name :" or a multi-line scalar
was accepted upstream but left a duplicate key or orphaned continuation
lines in the copy. Locate the key through YAML and replace its full span.
2026-10-09 09:56:12 +08:00
Willie 73eb44ee36 Merge remote-tracking branch 'origin/main' into runkids/feat-497-prefixed-naming
# Conflicts:
#	ui/src/i18n/locales/de.json
#	ui/src/i18n/locales/en.json
#	ui/src/i18n/locales/es.json
#	ui/src/i18n/locales/fa.json
#	ui/src/i18n/locales/fr.json
#	ui/src/i18n/locales/id.json
#	ui/src/i18n/locales/ja.json
#	ui/src/i18n/locales/ko.json
#	ui/src/i18n/locales/pt-BR.json
#	ui/src/i18n/locales/zh-CN.json
#	ui/src/i18n/locales/zh-TW.json
#	ui/src/pages/TargetDetailPage.test.tsx
#	ui/src/pages/TargetDetailPage.tsx
2026-10-09 09:48:45 +08:00
Willie eabe5fbc10 test(api): cover skillsSharedWith in the targets list
Code review of the target-page warning found the new targets API field
only had a unit test on the config helper. The handler is what the UI
reads, so check that it names targets writing the same skills folder and
leaves out one that writes elsewhere.

Release-As: 0.25.4
2026-10-09 01:28:28 +08:00
Willie 06b37d0fcf feat(api): list the targets that share a target's skills folder
The target page needs to know which other targets write to the same
skills folder to warn when an unsaved mode or naming change would make
their syncs undo each other. Re-implementing the server's folder
normalisation (home expansion, path cleaning) in TypeScript would drift
from config.SkillsFolderConflicts, so the targets API now returns
skillsSharedWith, built from the same skillsFolder helper.
2026-10-09 01:25:04 +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 9ed8272891 fix(config): reject prefixed naming on non-copy projects entries
The dashboard saves projects: through ValidateProjects, which checked only
the sync mode, so a project with prefixed naming and the merge default was
accepted and failed later at sync. It now applies the same copy-only rule,
with the project inheriting the global mode and naming like its targets do.
2026-10-09 01:02:13 +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 92f3d809c0 fix(server): refuse a global mode that breaks inherited prefixed naming
Targets that set prefixed naming but inherit the skills mode depend on the
global mode staying copy. Changing it from the dashboard left those targets
invalid until the next sync reported them; the global mode setter now runs
the same copy-only check the per-target setters do.
2026-10-09 00:58:34 +08:00
Willie 8a24ff9211 refactor(sync): treat symlink targets on one folder as never conflicting
A /simplify pass on #499 found the symlink exception too narrow: symlink
mode links the whole folder to the source and reads neither target naming
nor include/exclude, yet two symlink targets with different filters were
still reported as undoing each other. State the rule once (same symlink
mode means same folder contents) instead of exempting only naming, and
resolve the mode with cmp.Or like sync's isSymlinkMode rather than a
local copy of the sync package's resolver. Docs now say none of these
settings matter in symlink mode.
2026-10-09 00:55:53 +08:00