Commit Graph
490 Commits
Author SHA1 Message Date
Willie 2e22257520 fix(check): report failed update checks as failures (#643)
Return nonzero exit status for failed skill and agent checks while preserving JSON results. Propagate agent remote errors and prioritize dashboard check failures over the up-to-date summary.

Add regression coverage and document exit status in all command reference locales. Related to runkids/skillshare-app#85.
2026-10-26 01:20:22 +08:00
Rusty ShacklefordandClaude Opus 5.5 61eedffe1e fix(oplog): keep selected global config logs in the state dir (#609)
SKILLSHARE_CONFIG can select a global config in a directory named
skillshare or .skillshare. Treating it as a project config puts logs and
a .gitignore beside the shared config and labels global logs as project logs.

Exclude selected and read-only global config paths from project routing.
Share the check with the log command so readers and writers agree.
Run the legacy config regression explicitly in Windows CI so it is exercised
without enabling unrelated tests that still need Windows fixes.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 22:55:36 +08:00
Willie abc47a344d test(integration): drop EvalSymlinks workarounds made redundant by #610
NewSandbox now resolves its root, so these tests no longer need to
canonicalize macOS /var temp paths themselves. The leftovers were no-ops
that suggested the sandbox could still hand out symlinked paths.
2026-10-24 18:00:12 +08:00
Rusty ShacklefordandClaude Opus 5.5 51cecbeab4 test(testutil): align sandbox paths with symlinked temp dirs (#610)
On macOS, TMPDIR sits under /var, a symlink to /private/var. Sandbox
paths kept the unresolved form while the CLI reports canonical paths,
so tests needed per-case EvalSymlinks workarounds. NewSandbox now
resolves its root once.

RunCLIInDir and RunCLIInDirWithInput pass an explicit Env, so os/exec
does not set PWD and the child inherits the test process's PWD. The CLI
then falls back to getcwd and reports the canonical path even when
invoked through a symlinked directory, unlike a real shell. Set PWD to
the requested dir so the helper matches shell behavior.

The affected integration tests now create explicit symlink aliases so
they keep covering aliased working directories and config paths.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:58:31 +08:00
Willie 2d196c286b feat(check): show what changed in a skill since install (#623)
* feat(check): show what changed in a skill since install

#622 made a hand-edited skill visible as modified and kept update from
overwriting it, but there was still no way to see the edits before
deciding to keep or discard them (#621).

LocalChanges compares the skill's files with the hashes recorded at
install, fetches the source at the recorded commit only when a recorded
file changed, and diffs each file against it, so the diff shows the
user's edits even after upstream moves on. A skill without a recorded
commit is refused rather than diffed against HEAD, which would show
upstream changes as the user's.

It backs `check <name> --diff`, GET /api/resources/{name}/local-changes,
and the dashboard: the Modified locally dialog on the skill page lists
the diffs, and the Updates tab links a modified skill to it. update's
skip hints now point at --diff. The route looks up the exact record and
refuses non-local names, so a nested or ../ path cannot borrow a
top-level skill's record or read outside the source. The file diff
helper moved to textdiff so the CLI and server share it.

* fix(install): diff local changes against the full installed commit

entry.Version holds the short SHA from `rev-parse --short`. A targeted
fetch needs the full SHA, so checkoutCommit fell back to fetching every
branch and tag with --unshallow: viewing one edited skill could download
the repository's whole history, and fail when the commit is only
reachable by its full SHA.

Use entry.Commit, the full SHA install records, when it is the same
commit as Version; a Commit left from an older install, or a legacy
record without one, falls back to Version.

* test(install): keep checkout line endings when editing in LocalChanges test

On Windows git checks the installed copy out with CRLF, so overwriting
SKILL.md with LF content made every line differ and the expected diff
failed. Edit the installed file in place, as an editor would, and compare
the diff without carriage returns.
2026-10-24 17:32:34 +08:00
Willie 7a7cceefab feat(update): flag and protect skills edited since install (#622)
* feat(update): flag and protect skills edited since install

A skill installed from a repository and then edited by hand looked
exactly like an untouched one: check said up to date, and update either
reported it current or silently reinstalled it over the edit (#621).

Install already records each file's hash, so check now compares a
remote skill's files with those hashes and reports "modified", and
update skips such a skill until --force (CLI single, --all/--group,
dashboard). --force, the dashboard's Force Retry on the skipped row, or
the confirmation on the skill page discards the edit and reinstalls.

Two hash paths had to be made reliable for this to be trusted: the
dashboard's folder-wide target edit refreshed hashes by basename, so a
nested skill looked edited after skillshare's own change, and a skill
whose files cannot be hashed now counts as modified instead of being
overwritten.

* fix(server): keep earlier local edits when a target change rewrites SKILL.md

Changing a skill's targets in the dashboard rewrites its SKILL.md, and
both the folder-wide and the single-skill handler then re-hashed the
whole directory as the new baseline. An edit the user had already made
to any file in the skill was absorbed into that baseline, so the skill
stopped counting as modified and the next update overwrote the edit
without --force.

Both handlers now move only SKILL.md's recorded hash, and only when the
file still matched it before the rewrite. skillshare's own target edit
no longer reads as a local change, and an earlier edit still does. The
whole-directory refresh helpers lost their last callers and are removed.
2026-10-24 16:33:37 +08:00
Willie 330114bd6a fix(install): use frontmatter names for generic skill directories (#617)
* fix(install): use frontmatter names for generic skill directories

Resolve meaningful defaults for generic containers while preserving explicit names, tracked paths, existing update destinations, and directory-based source selection. Fall back on unsafe or colliding names to prevent overwrites.

Cover global and project installs, local and Git sources, naming overrides, tracked reports, collision safety, and updates. Closes #616.

* fix(install): preserve names during source-based updates

Resolve source-based updates against existing metadata before choosing destinations. Reject ambiguous or colliding update targets before writes, and reserve case-insensitive discovery names across filesystems.

Add global/project regressions for local and Git source updates, legacy destinations, grouping, and upstream-added collisions.

* fix(install): retain update ownership and selection checks

Only allow a metadata-verified same-source update to bypass destination conflicts. Reject occupied fallback destinations for both local and Git sources unless overwrite is explicitly forced.

Resolve destinations after skill selection so unrelated conflicts do not block filtered updates. Cover cross-source and unmanaged destinations, selected/excluded updates, and collision aborts in global and project modes.
2026-10-23 20:04:45 +08:00
Willie 829cbb176d fix(plugins): honor native OMP marketplace builds (#588)
* fix(plugins): honor native OMP marketplace builds

Resolve OMP entries from their native marketplace when present and inspect package.json extension-only plugins. Keep target-specific source paths, marketplace identities and components so Claude adoption and hybrid manifests remain valid.\n\nShow separate builds in text discovery without changing logical JSON selection, and cover native precedence, invalid catalogs, manifestless and hybrid packages, global/project materialization and CLI output with regression tests. Update the plugin docs and existing translations.\n\nFixes #587

* fix(plugins): preserve native build metadata across consumers

Keep OMP catalog versions in target discovery metadata and materialized marketplace entries so previews, cache guards, and native installs use the same version, including legacy catalog fallback. Cover catalog versions that differ from package manifests.

Show each dashboard discovery target's own version, components, and source path instead of presenting a merged candidate as one build.

* fix(plugins): avoid ambiguous shared build versions

Derive candidate versions from agreement across supported targets and recompute after catalog overrides. No-Agent records and lists no longer inherit an arbitrary native build version; equal versions remain available and unknown versions stay unknown.

Keep Cursor and Antigravity inventory target-specific when manifests disagree. Cover no-Agent preview and persistence, equal and unknown versions, catalog overrides, and mixed-manifest local inventories. Align English and translated plugin references.

* fix(plugins): accept Pi extension manifests for OMP catalogs

Reuse the existing OMP extension detector instead of requiring an OMP-specific manifest key. Native OMP accepts Pi extension manifests too, so the extra gate rejected supported native catalog entries.

Cover Pi-only discovery with scoped package names and global/project materialization. Align the English plugin references and all existing translations.
2026-10-20 12:22:05 +08:00
Willie 70ceacca9b feat(mcp): serve an Executor skill index from mcp serve --http (#583)
* feat(mcp): serve an Executor skill index from mcp serve --http

Executor apps load remote skills with wellKnownSkills, but could only
reach Skillshare's skills through a copy in Git, so an edit saved with
apply_skill_edit never reached them without a commit and push. With
--http, mcp serve now also answers /.well-known/agent-skills/index.json
and the files it lists, built from the same catalog and token, so
Executor sees an edit on its next check.

The format is the one Executor's loader reads, not the agent-skills
discovery draft v0.2. One skill that loader rejects fails its whole
load, so the index leaves out skills it would reject (non-text metadata,
license or allowed-tools, files over 2 MB, non-UTF-8 files, file names
decodeURIComponent cannot handle, names used twice) and lists them in
--check and on stderr at startup. Versions are digests of each skill's
paths and file digests, and the output is stable while nothing changes,
because the loader reads the index twice and compares the bytes. An
index over Executor's file or byte limits answers with an error naming
--target.

Manifest files now record their path within the listing skill: a
parent's entry otherwise took its nested skill's paths, which would
have listed SKILL.md twice. The index route repeats the MCP handler's
DNS rebinding check for loopback servers without a token.

Closes #574

* fix(mcp): accept proxied hosts with a token and use Executor's app accounts

Behind the documented TLS proxy, a loopback mcp serve sees the proxy's
public Host, and the DNS rebinding check answered 403 even with a valid
bearer token. The index route had it, and so did the MCP endpoint through
the go-sdk's localhost protection. A rebinding page cannot send the token,
so both checks now apply only when no token is set; the docs say a
tokenless server behind a proxy needs a loopback Host.

The Executor example used the account form apps 0.0.1-beta.90 removed
(`{ accounts }` and `ctx.accounts`, now typed as never). It declares the
token as an app account and reads ctx.app.accounts, in all five locales.
The wellKnownSkills loader itself is unchanged at the v2 head (b98424d9).
2026-10-18 23:48:42 +08:00
Willie 4a5dacac6b feat(mcp): let mcp serve clients edit listed skills (#577)
* feat(mcp): let mcp serve clients edit listed skills

A remote assistant that reaches skills only through `mcp serve` could
read them but had to hand every change back to a person (#540). Skills
listed in `mcp.serve.edit.skills` can now be changed one existing file
at a time: `preview_skill_edit` writes nothing and returns the full
diff, the audit result and a preview id, and `apply_skill_edit` saves
exactly that preview, once.

Every save is tied to the revision the client read, so a file changed
in the meantime fails with a conflict instead of being overwritten.
Skills that `update` would overwrite stay read-only: tracked repos,
upstream installs, and skills nested inside an install. The skill is
validated and audited in a temporary copy before anything is written;
as with install, a finding at or above `audit.block_threshold` refuses
the edit unless it was accepted with `--force`, and findings are marked
new or existing so the client can see what its change adds.

The write is atomic, keeps the file mode, goes through sourcefs link
checks, and is recorded in the operation log. Native Skills extension
clients still see the edit tools, since the extension cannot write.

* fix(mcp): close gaps in mcp serve skill editing

Codex review of #577 found five ways the edit tools could do more, or
record less, than they promise:

- A blank pattern in mcp.serve.edit.skills was dropped by the filter,
  and no patterns match every skill, so `skills: [' ']` made every skill
  editable. Blank patterns are now a config error.
- preview_ttl was only checked when skills were listed, so the dashboard
  could save an invalid value that later stopped mcp serve. It is now
  checked whenever edit is present.
- Apply compared only the edited file's digest, so two previews of
  different files, or an edit made elsewhere in between, could save a
  skill state that was never validated or audited. Apply now checks and
  audits the skill again as it will be saved.
- Edit audits were not written to audit.log, so blocked attempts left no
  trace in `skillshare log --audit`. Each preview and apply audit is now
  logged like install's audit gate.
- The writability check migrated legacy metadata, so a "writes nothing"
  preview (and --check) could rewrite .metadata.json and delete
  registry.yaml. It now reads the store without migrating; a legacy
  registry.yaml keeps every skill read-only, and a legacy sidecar marks
  its skill as installed.
2026-10-15 22:30:39 +08:00
Colin MasonandWillie c4b183f6ef fix(update): read store in batch fast path (#569)
* fix(update): read store in batch fast path

The grouped update fast path read per-skill .skillshare-meta.json
sidecars. The migration to .metadata.json deletes those files, so the
check never matched and update --all reinstalled every skill on every
run.

Read the central store instead, and refresh version and commit there
instead of writing a sidecar. Require SKILL.md on disk so the update
restores a deleted install. --force now skips the check and reinstalls
everything.

* test(update): cover legacy grouped metadata keys

Grouped skills can still be stored under a basename key with a Group
field. Check that the current-skill lookup finds that entry and that the
version refresh updates it in place instead of adding a new key.

* feat(update): report up-to-date skills

The summary lumped skills the fast path skipped in with failures. Count
them as "up to date" in the summary and as up_to_date in --json
output.

* feat(update): log up-to-date count in oplog

The operations log recorded updated, skipped, pruned, and blocked counts
for update but not the new up-to-date count. Record it as up_to_date
so the log matches the summary and --json output.

* test(update): cover up-to-date batch skills

update --all reinstalled every grouped skill on every run. Check that
unchanged skills report as up to date in global and project mode, that
an upstream change updates only the changed skill, and that --force
reinstalls everything.

* docs(update): describe up-to-date batch skills

Describe how update --all and --group leave unchanged skills alone and
report them as up to date, the up_to_date JSON field, and the new
meaning of --force.

* fix(update): keep lock pins on tree-only matches

A tree-hash match after upstream HEAD moved refreshed the full commit in
the store. A project lock pin follows that field, so an unrelated
upstream commit rewrote skills.lock.json even though the skill's files
did not change. Refresh only the version, as the old sidecar refresh
did. check compares the version, so it still reports the skill as up to
date.

The help text, docs and skill reference said --all and --group skip
current skills. The skip lives in the batch path, which runs for any
update of several skills, and a single skill always takes the reinstall
path. Say that instead.

* fix(update): load the store once per batch

Each skill skipped as current reloaded .metadata.json before comparing
its version, so an unchanged batch reparsed the whole store once per
skill. Compare the version already read from the snapshot first, and
refresh the skills that do lag HEAD with one load and save after the
loop. An unchanged batch of 400 skills drops from about 520ms to 64ms.

The help text and docs said any update of several skills takes this
path. In global mode, named and glob targets carry no metadata and
reinstall on the standalone path. Name what does take it: --all,
--group, and several skills named in project mode.

---------

Co-authored-by: Willie <egg358358@gmail.com>
2026-10-14 23:36:56 +08:00
Colin MasonandWillie 322abb1e1f fix(update): warn when a repo fetch fails (#570)
* test(update): cover batch fetch failure warning

A batch update that cannot fetch a repo counts its skills as skipped and
prints nothing about it. Remove the remote after installing two grouped
skills and check that update --all names the repo in a warning.

* fix(update): warn when a repo fetch fails

When a clone failed during update --all, the summary counted its skills
as skipped and printed nothing. That hid a repo that timed out on every
run. Print the repo and the error.

* fix(update): redact credentials in fetch warning

The fetch warning printed the stored repo URL as is. An HTTPS URL can
carry a token as userinfo, and git error text can echo that URL, so the
token reached stdout and CI logs. Name the repo with DisplayURL, which
already strips userinfo for submodule URLs, and redact the userinfo
from the error text.

* fix(update): redact query tokens in fetch warning

The fetch warning redacted only the userinfo of the repo URL. A token in
the query survived in the error text, since git echoes the full URL.
And DisplayURL treats the last "@" anywhere as the end of userinfo, so
an "@" in the path named a different repo.

Parse http(s) repo URLs the way git does: userinfo ends at the last "@"
before the first "/", and the query and fragment go too. Remove the
same parts from the error text. Other URLs print unchanged. DisplayURL
goes back to being private to submodule.go.

---------

Co-authored-by: Willie <egg358358@gmail.com>
2026-10-14 23:15:01 +08:00
Willie 6cc790965a feat(mcp): pin tool definitions in mcp check --live and warn when they change (#560)
* feat(mcp): pin tool definitions in mcp check --live and warn when they change

An Agent reads a server's tool names and descriptions as instructions,
and a server can change them after the user reviewed it (a "rug pull").
The MCP spec 2026-07-28 local-server security guide notes the protocol
does nothing about this and advises clients that re-prompt on a changed
definition; most clients do not.

`mcp check --live` now records one SHA-256 per tool over name,
description and inputSchema the first time a server answers, in
mcp/tool-pins.json of the state directory, keyed by scope and server.
Later probes report a changed or new tool as a `tool-change` warning and
a removed one as info, until `--accept-tools` (only with --live) records
the current definitions. Without --live the pins are never read or
written. An unreadable pin file is never rewritten, since it may hold
other servers' pins. The dashboard words both warnings in every locale.

* fix(mcp): keep schema numbers exact, name the scope to accept in, and log acceptance

Codex review on #560:

- Tool definitions were decoded through float64 before hashing, so a
  schema bound changed from 9007199254740992 to 9007199254740993 hashed
  the same and raised no warning. Numbers now keep their literal text.
- The suggested accept command left out -g/-p; run from inside a project
  after a global check, it would accept the project's server instead.
  It now names the scope of the check that warned.
- Accepting changed tool definitions approves a possible rug pull, but
  left no record. --accept-tools now writes an operations log entry with
  the servers it accepted.

* fix(mcp): log a tool acceptance only when its baseline was saved

Codex review on #560: when comparing succeeded but writing tool-pins.json
failed (lock held, state directory unwritable), the report kept its
"accepted" finding, so the operations log listed the server as accepted
with status ok although its old pins remained. Such a server is now
logged under `failed` and the entry's status is error.

* fix(mcp): log first pins as accepted and report errors in the accept entry

Codex review on #560:

- A check that accepted one server but found an error on another still
  logged status ok, while the command itself exited 1. A server with an
  error is now listed under `failed` and the entry's status is error.
- --accept-tools on a server's first probe records its baseline, but the
  finding says "pinned", so the entry listed nothing as accepted. A first
  pin counts as accepted now.

* chore(release): request version 0.25.11

The MCP pin checks (#559, #560) and the backup staging fix (#558) ship
as 0.25.11 instead of the computed 0.26.0, per maintainer decision.

Release-As: 0.25.11
2026-10-13 23:22:57 +08:00
Willie cf5783ee88 fix(backup): reclaim abandoned staging directories safely (#558)
* fix(backup): reclaim abandoned staging directories safely

Interrupted backup copies leave hidden .snapshot-* directories that retention cleanup never discovers. Hold a shared process lock during copies and use an exclusive cleanup lock to reclaim orphaned staging without deleting active work.

Share retention planning with non-mutating dry runs, report busy manual cleanup in the CLI and API, and align dashboard messages and translated docs. Cover process interruption and automatic cleanup with regression tests and an executable E2E runbook.

Closes #556

* fix(backup): address staging cleanup review findings

Keep cleanup reachable for staging-only dashboard backups and disclose abandoned incomplete directory deletion in every confirmation locale. Cover the empty-state confirmation with a regression test.

Read staging entries before a read-only lock probe so first-use dry runs cannot count a newly active writer. Refresh entries only under the acquired lock and classify both backup-root reads in the filesystem guard.

* fix(backup): align cleanup guides and doctor status

Disclose abandoned incomplete directory removal in backup help, completion descriptions, and the daily backup guide with all four translations. Add help and completion regressions so these consumers stay aligned with cleanup.

Keep the doctor Backups row visible when only the persistent lock remains after cleanup, preserving the existing JSON check and covering the lock-only state.

* fix(backup): complete cleanup documentation disclosure

Cleanup reclaims abandoned incomplete directories regardless of retention, so retention-only summaries understated the action. Align the backup synopsis, option table and previews, related workflow guides, built-in reference and all four website translations. Scope the retention defaults to completed snapshots.
2026-10-13 22:42:05 +08:00
Willie 656437c2b5 fix(sync): limit project adoption writes to moved skills (#548)
* fix(sync): limit project adoption writes to moved skills

A stale install record could trigger a full project reconcile during sync, adding unrelated remote installs to the manifest, ignore rules and lockfile. Skip project writes when nothing was re-keyed, and update only moved declarations, ignore rules and existing pins while preserving full explicit reconcile behavior.

Cover the visible project directory sharing its global source with byte-identical no-move checks and a real move that preserves unrelated entries and audit acceptances.

* fix(sync): preserve existing move destination declarations

The adoption-only config rewrite could duplicate a destination already declared in the project manifest. Keep that destination declaration and remove the moved old entry, matching full reconcile behavior while preserving the destination fields.

Add a regression that fails with duplicate entries and passes with the existing destination branch retained. Re-run make check after the fix.
2026-10-13 10:37:41 +08:00
Willie 111dd71a53 fix(sync): let prefixed naming keep skills whose name differs from their folder (#531)
Prefixed naming rewrites name: in every copy to the entry name, so the
target folder and name: always agree. Requiring name: to equal the source
folder only skipped skills it could sync: a tracked repo that is itself a
skill lives in _<repo>, so its root SKILL.md could never pass.

Only standard naming now requires the match; name format rules still
apply to both. Sync lists the skills named this way, so a user looking
for _ooux in the target finds ooux.

The dashboard's skipped-skills hint always blamed folders that end in the
same name, even when skills were skipped for their name. The diff API now
reports naming skips apart from collisions and the hint names the cause.

Refs #530
2026-10-12 13:59:59 +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 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 e610006ba4 fix(sync): credit target naming for isolated duplicate names
Under prefixed naming, two same-named skills from different repos reach a
target under distinct names, yet sync said they were isolated by target
filters. The note now names both causes. The new test also covers the
merge + flat to copy + prefixed switch a user plans to make.
2026-10-09 22:20:14 +08:00
Willie 33892c2f9e fix(sync): report collisions that only a target's naming creates
reportCollisions returned when no two skills shared a SKILL.md name,
but prefixed naming can make distinct names collide (_a/b-c becomes
a-b-c, a local skill's name). Sync then said only "1 name collision(s)
excluded" without naming the skills. Report whenever a target has
collisions.
2026-10-09 12:58:53 +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 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 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 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 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 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 89a12074ce Merge remote-tracking branch 'origin/main' into runkids/feat-497-prefixed-naming 2026-10-09 09:44:06 +08:00
Willie 22e2958113 Merge branch 'main' into runkids/fix-498-shared-folder-conflict 2026-10-09 01:19:22 +08:00
Willie 9d0b56db91 test(install): install the subdir test skill from this repo
TestInstall_GitHubSubdirViaAPI installed skills/documents/atlassian-search
from majiayu000/claude-skill-registry, which dropped its skills/ tree on
2026-10-08, so the online job fails on every branch. Subdir installs take
the same sparse-checkout-then-Contents-API path whatever the repo, so
install runkids/skillshare/skills/skillshare instead: same assertions,
and the source can't move under us.
2026-10-09 00:59:11 +08:00
Willie e44466c9fc test(sync): cover prefixed naming in project mode
Project mode inherits target_naming from the project config through a separate path (defaultTargetNaming on ProjectTargetEntry), so it gets its own end-to-end check that two same-named tracked-repo skills both sync.
2026-10-09 00:53:37 +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 226c5c9a74 feat(target): offer prefixed naming in the CLI, dashboard and schemas
The new naming has to be choosable wherever naming already is: target
--target-naming, the target list TUI, the dashboard target page, shell
completions and the config schemas. Each setter checks the copy-only rule
before saving, for a naming change and for a mode change on a prefixed
target, so an invalid pair never reaches the config file and only surfaces
later as a failed sync.
2026-10-09 00:47:20 +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 366fb236c1 fix(sync): flag shared skills folders whose mode or naming differ
Two targets writing one skills folder with different target_naming or
mode undo each other on every sync (flat links vs standard names, merge
vs copy), but only include/exclude were compared, so sync and doctor
fell back to the generic shared-path hint.

Compare the effective mode and target naming too, so an unset value
equals the default it resolves to. The global default mode is not
carried on the target, so SkillsFolderConflicts takes it from its three
callers. The warning now says "different settings" instead of "different
filters".

Fixes #498
2026-10-09 00:28:34 +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 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 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 c182c42d1a fix(extras): keep filter changes from being dropped or saved invalid
- On a multi-target extra, `extras <name> --flatten --add-exclude ...`
  without --target took the flatten-for-all-targets path, which returned
  before the filter flags were applied, and still reported success. Filter
  flags now require --target there, like --mode.
- The `extras list` TUI mode picker saved a mode without validation, so a
  filtered target could be switched to symlink and break every later sync.
  The change is now validated before saving.

Refs #435
2026-10-08 16:01:01 +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 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 414d193114 fix(update): keep an existing skill ahead of the nested shorthand
Codex review of #481 found three problems with the shorthand change:

- `update org/team -p` and the dashboard stream updated the org/_team
  repo even when a skill exists at org/team, which used to win because
  the shorthand was not rewritten there. FindTrackedCheckoutUnlessSkill
  skips the nested shorthand when a directory exists at the typed path;
  plain names keep their repo-first behavior.
- Global `update team/` cleaned the name for repo matching but not for
  skill matching, so it silently updated `_team` instead of reporting the
  skill/repo collision that `update team` reports. resolveByBasename now
  cleans the name once for both.
- The update.md example sits in the Project Mode section but lacked -p
  (also in the four translations).
2026-10-07 23:58:43 +08:00
Willie 84ed67b13d fix(update): accept the org/team shorthand for --into repos in every entry point
A repo installed with `--track --into org` lives at `org/_team`. Only
POST /api/update accepted `org/team`; the dashboard stream and
`update -p` prefixed the whole name (`_org/team`), and global `update`
compared the full name with the basename, so each reported not found.

Move the candidate rule (the name as typed, then `_` added to the last
segment, never leaving the source root) into install.FindTrackedCheckout
and the basename match into install.MatchTrackedRepos, and use them from
the single update, the stream, project and global CLI update. A shorthand
resolves to its own `org/_team`, never to a top-level `_team`; plain names
and full paths keep their behavior.
2026-10-07 23:51:37 +08:00
Willie 27f4b1f61c Merge branch 'main' into runkids/fix-audit-markdown-context 2026-10-07 23:25:52 +08:00
Willie 75a732ae91 Merge branch 'main' into runkids/fix-audit-markdown-context 2026-10-07 23:21:55 +08:00
Willie 0be5164159 fix(update): use the tracked checkout rule in every update and reconcile path
#474 made install.IsTrackedCheckout (a _-prefixed git repo) the rule for what
a tracked repo is, but several paths still treated any git checkout as one, so
the same directory was classified differently depending on the entry point. An
unprefixed checkout, including a submodule or worktree whose .git is a file,
could be pulled as a tracked repo from the dashboard batch stream, the CLI
--group and project-mode name resolution, and the dashboard single update's
direct-path lookup, and reconcile wrote tracked: true for it.

All of them now use IsTrackedCheckout, so an unprefixed checkout updates as a
regular skill or is skipped, while _-prefixed repos, including --into repos
such as org/_team, still update as tracked repos.

Reconcile no longer registers an unprefixed checkout as tracked or creates an
entry for it from the git remote. An existing entry that an older reconcile
flagged tracked on such a checkout is kept with its source and branch; only the
flag is cleared on the next reconcile, so no user data is removed.

Fixes #476
2026-10-07 23:10:13 +08:00
Willie e589336bef Merge origin/main (#472) into runkids/473-tracked-repo-update
Resolve the conflict in getTrackedReposImpl by keeping both sides: the
IsTrackedCheckout rule from this branch and the slash-form paths #472
returns for --into repos (org/_repo). Add a GetUpdatableSkills test for a
rewritten --into checkout next to a top-level one.
2026-10-07 22:46:15 +08:00