Commit Graph
1041 Commits
Author SHA1 Message Date
Willie f0270c371b refactor(ui): let i18n own key validity and plural selection
The i18n module guaranteed parity between locales and left the rest to
callers. `t` takes any string, so a mistyped key rendered as the key and
nothing caught it; internal/plugin sends translation keys that nothing
compared with en.json; and about 130 call sites chose between `.one` and
`.other` by hand.

- keys.test.ts reads the dashboard source and fails on a key that is not
  in en.json. A key built at run time is checked by its fixed head, and a
  string that only looks like a key is named in a short documented list.
- internal/plugin/i18n_keys_test.go fails when a "plugins." literal the
  package emits is missing from en.json; the one key completed at run
  time lists its values.
- plural(key, count) in the i18n module picks the form, with the same
  "exactly 1" split the call sites used, so every rendered string is
  unchanged. No locale file changed.

Refs #448
2026-10-07 00:12:35 +08:00
Willie 6b4c34dec4 test(sourcefs): move the download write allowances to writeDownloadedFile
The raw write ratchet listed the os calls of downloadFile,
giteaDownloadFile and cnbWriteBlob. Those now go through
writeDownloadedFile, so the list names that function instead, with the
same clone reason.
2026-10-06 22:47:31 +08:00
Willie 7a501cecfa Merge branch 'main' into runkids/fix-visible-project-schema-execbit 2026-10-06 22:36:09 +08:00
Willie 7b3d84e7b8 fix(install): keep scripts executable on content API downloads
The GitHub, Gitea and CNB content API fallbacks wrote every file as
0644, so a skill's scripts lost their exec bit whenever sparse checkout
was not available. The APIs do not report the git mode, so a file that
starts with #! is now written as 0755; anything the kernel could run
directly carries one. The mode is set on both branches, because
O_TRUNC keeps the mode of a file that already existed.

Refs #439
2026-10-06 22:34:27 +08:00
Willie b2dc1ed6c9 fix(schema): list every config key the structs accept
Both schemas reject unknown keys, but plugins, cnb_hosts and
gitea_hosts were missing from both, the global schema also lacked
extras_source and log, and skillEntry had no kind, so editors flagged
valid configs. A test now compares the yaml tags of Config and
ProjectConfig with the schema properties.

Refs #438
2026-10-06 22:34:27 +08:00
Willie 627eecd5e7 fix(dashboard): detect a visible project directory
Two handlers checked for a project's own config by statting
.skillshare/config.yaml directly, so a project created with
init -p --visible (directory skillshare/) was reported as not having
one, and the MCP page missed its override conflict. Both now ask
projectdir.Find, which the CLI already uses.

Refs #437
2026-10-06 22:34:27 +08:00
Willie 2ef704a77b fix(sync): isolate extension modules and condense diagnostics
Keep bundled CommonJS converters working inside ESM projects. Show concise sync failures with expandable original diagnostics and clarify that the last-sync card covers skills and agents only.
2026-10-06 21:36:04 +08:00
Willie a3ddb88f99 fix(mcp): rebuild the catalog when discovery changes during a build
Discovery and the package loads read the tree separately. A nested skill
created in between was published only as a file of its parent, with no
entry of its own. Discover again after the loads and rebuild, up to three
times, until both agree.
2026-10-06 17:13:44 +08:00
Willie 69f7dfa89b fix(mcp): require an unindented closing frontmatter delimiter
The closing --- was matched after trimming spaces, so an indented line,
which is YAML content, closed the frontmatter. It now has to be exactly
---, like the opening one; a CRLF ending is still fine.
2026-10-06 17:08:41 +08:00
Willie 1c7cf1259c fix(mcp): read only the file the link check saw
Files were checked with Lstat and then opened by path, so one replaced
by a link in between was followed and published. Each read now checks
that the opened file is the one Lstat described, and skips the skill
otherwise.
2026-10-06 16:59:50 +08:00
Willie 321d3beeed fix(mcp): keep a nested skill's file entries when its parent disagrees
A parent lists its nested skills' files under the same URIs and was
loaded after them, so a file changed between the two reads had the
nested skill's entry overwritten by the parent's newer digest, and reads
of it no longer matched what the nested skill advertised. The parent is
now skipped for that build and served after the next refresh.
2026-10-06 16:51:34 +08:00
Willie 699dcb86ec fix(mcp): refuse cross-origin browser requests to mcp serve --http
The Streamable HTTP handler had no cross-origin check, so a web page
could call a loopback server that runs without a token. It now uses the
SDK's CrossOriginProtection, which refuses cross-site browser requests
and leaves non-browser clients alone.
2026-10-06 16:44:57 +08:00
Willie db3840b031 fix(mcp): keep an edited serve command's -p and reject padded names
Changing the served target rebuilt the command from the dashboard scope,
so editing `skillshare mcp serve -p --target old` in the global
dashboard silently dropped -p; the command now keeps its own flag.

Skill names were trimmed before validation, so a name and directory
padded with the same spaces passed. Names are no longer trimmed, and the
spaces fail the character rule.
2026-10-06 16:36:51 +08:00
Willie 76a49ada77 fix(mcp): find the frontmatter without splitting the whole SKILL.md
Splitting the file into lines cost one string header per line, so a
16 MiB newline-heavy body allocated about 256 MiB per parse. The parser
now scans lines up to the closing --- and keeps only offsets.
2026-10-06 16:26:49 +08:00
Willie a6166ed27b fix(mcp): match a skill's name to its directory exactly
The name rules are checked after NFKC, but the directory is the skill
path's last segment, which the Skills extension requires to equal the
name. A fullwidth abc in directory abc passed and was published under
a URI that did not match its name; the comparison is now exact.
2026-10-06 16:18:03 +08:00
Willie 7980c08a2d refactor(mcp): read each skill file once in skillpkg.Load
The review fixes left the per-file size and digest split across two
packages: a stat-based budget in the walk, a second bounded read in the
catalog, a SKILL.md special case hashed once per file, and the digest
format written out three times. skillpkg.Load now reads every file once
within one package budget and records its digest and size, so the
catalog only maps them, and skillpkg.Digest is the one digest format.

Also: Build settles skills in one deepest-first loop, the skills/list
cursor uses sort.Search, ParseFrontmatterMap splits the file once, mcp
serve names each value flag once, and the migration report is not
called twice in main.
2026-10-06 16:16:25 +08:00
Willie a8edbc715f fix(mcp): follow the reference validator for names and bound SKILL.md reads
The Agent Skills reference validator accepts lowercase Unicode letters
and digits after NFKC normalization and counts the 64-character limit in
characters, so names such as 技能-審查 or café were skipped although they
are valid. ValidateName now applies the same rules. sync's target naming
shares it and accepts those names too. golang.org/x/text becomes a
direct dependency at the version already in the module graph.

SKILL.md was size-checked and then read whole, so a file that grew in
between was still read into memory; the read itself now stops past 16 MiB.
2026-10-06 15:57:02 +08:00
Willie 97844aa7f8 fix(mcp): hash SKILL.md from the bytes its frontmatter came from
SKILL.md was parsed, then read again to hash, so a save in between paired
old frontmatter with the new file's digest and size, and hosts that
compare frontmatter against the file rejected the skill. The digest now
comes from the parsed bytes; a later read of a changed file is refused
until the next refresh.
2026-10-06 15:46:48 +08:00
Willie 6285e490e6 fix(mcp): reject an empty compatibility
The Agent Skills format requires a compatibility value, when present, to
hold 1 to 500 characters, so an empty one is skipped like an overlong one.
2026-10-06 15:39:06 +08:00
Willie 4f7f2d8151 fix(mcp): continue skills/list from a URI and cap the bytes hashed
The cursor was an offset, so a catalog rebuilt between pages shifted the
next page when a skill was added or removed ahead of it, repeating or
dropping entries. Skills are now ordered by URI and the cursor is the
last URI returned.

Hashing now stops past the package's remaining size budget, so a file
that grew after the walk is skipped rather than advertised over 16 MiB
or hashed without bound.
2026-10-06 15:32:06 +08:00
Willie 2ac0926cce fix(mcp): take a file's manifest size and digest from one read
The size came from the directory walk and the digest from a later read,
so a file replaced in between was listed with an old size and a new
digest, which verifying clients reject. Both now come from the same read.
2026-10-06 15:25:33 +08:00
Willie 78857ad6f1 fix(mcp): skip a linked SKILL.md and an indented opening delimiter
The manifest lists no links, so a skill whose SKILL.md is a link was
published without its own file and could not be read. It is now skipped
with a warning.

The Agent Skills reference parser requires the file to begin with ---
exactly, so an indented delimiter no longer opens frontmatter. A CRLF
file still parses.
2026-10-06 15:16:35 +08:00
Willie b5bad20e50 fix(mcp): serve only bytes that match the listed digest
The catalog is reused for up to 5 s, so a file edited after skills/list
was read live and failed the client's digest check. A read now hashes
what it returns and reports the file as changed when the digest no
longer matches; the next refresh lists it again.

Also: a BOM-prefixed SKILL.md is parsed from the stripped bytes instead
of being skipped, a non-text compatibility is rejected rather than
treated as absent, and an oversized SKILL.md is skipped before it is
read into memory.
2026-10-06 15:09:34 +08:00
Willie d13e03adfc fix(mcp): skip skills whose compatibility exceeds the format limit
The Agent Skills format caps compatibility at 500 characters, and hosts
that validate entries reject longer ones, so serve skips such a skill
with a warning, as it does for an overlong description.

metadata is deliberately not held to the format's string values: lists
there are common, tool-fallback clients read them fine, and skipping
those skills would hide them from every client to satisfy a few.
2026-10-06 15:00:35 +08:00
Willie 64898e145b fix(mcp): keep migration notices off stdout and require closed frontmatter
The first command after an upgrade reports legacy data it moved. For
mcp serve that notice landed on stdout ahead of the handshake, so it now
goes to stderr like serve's other messages.

A SKILL.md that opens frontmatter but never closes it could still parse,
so serve published a file hosts read as having no frontmatter; it is now
skipped with a warning.
2026-10-06 14:57:49 +08:00
Willie 96593f9411 fix(mcp): quote the served target and cap skill descriptions
A managed project's name may hold spaces, so the Skillshare tab built
`--target my app@claude`, which the save path split into two words and
serve rejected as an unknown target. The command is now joined from
quoted words.

The Agent Skills format caps a description at 1,024 characters, and
hosts validating entries reject longer ones, so serve skips such a skill
with a warning instead of advertising it. The docs list every skip reason.
2026-10-06 14:47:41 +08:00
Willie fd4f499be7 fix(mcp): keep serve digests and stdout trustworthy
Size and mtime cannot prove a file is unchanged (cp -p, rsync -t), and a
stale digest makes hosts that verify digests reject the file for good,
so every rebuild hashes every file again; 1,000 skills rebuild in about
140 ms, at most once per refresh interval.

Serve errors now go to stderr: stdout is the protocol stream, and a
startup error printed there is not JSON-RPC.

SKILL.md must begin with its frontmatter, as the Agent Skills format
requires; a later --- block no longer passes.
2026-10-06 14:39:21 +08:00
Willie 0ad3ffab5a fix(mcp): address review findings on mcp serve and its dashboard tab
A root under mcp.projects is served from the global config, where its
project targets (app@claude) live, so the Skillshare tab now offers that
project's targets beside the global ones and saves no -p, which would
fail in a folder with no .skillshare/.

A nested skill skipped for any reason, not only one left unselected, now
skips its parents too: they were settled before the child was validated
and published its files as their own.

Also from review: a skill whose frontmatter JSON cannot carry (a
non-string key) is skipped instead of failing the whole skills/list page;
a listed file with a backslash in its name can be read; and stdio serve
exits 0 on SIGINT/SIGTERM without writing to stdout after the session.
2026-10-06 14:30:17 +08:00
Willie 5e02ef7ef0 refactor(sync): select a target's skills through SelectTargetSkills
Status, doctor, diff, the dashboard's target and diff handlers and analyze each
repeated FilterSkills followed by FilterSkillsByTarget, and only some dropped
disabled skills first. Routing them through SelectTargetSkills keeps their
answers identical to sync and mcp serve when a selection rule changes.

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

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

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

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

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

Refs: #428
2026-10-06 14:18:16 +08:00
Willie bfbce09a12 test(windows): compare against resolved paths for 8.3 temp dirs
The windows-latest runner's TEMP is an 8.3 short path
(C:\Users\RUNNER~1\...), while the product reports the resolved long
path. Four tests compared the short form and failed only on the runner;
the local guest has no short names. Resolve the expected path first.

Refs #344
2026-10-06 10:58:15 +08:00
Willie 8b01e9f5a4 Merge branch 'main' into runkids/sync-windows-tests 2026-10-06 10:51:56 +08:00
Willie 92183d5a09 test(windows): run audit, config, install, mcp and cmd tests on Windows CI
These packages were left out of the windows-test job because of failures
that came from test assumptions (POSIX paths, permission bits, HOME,
bash shims posing as git), not product behavior. Fix them and add the
packages to the list so they stay green.

Two failures were real product bugs:
- swapStagedIntoSource named its backup like the temp that
  sourcefs.MoveIn creates beside it. On a coarse clock (Windows) both
  names matched, the failed move removed the temp and with it the
  backup, and the old skill was lost.
- MetadataStore.GetByPath looked up OS-native paths in slash-form keys,
  so `update --group` missed nested skills on Windows.

The test sandbox now also sets USERPROFILE, which os.UserHomeDir reads
on Windows; tests were reading the real profile.

Refs #344
2026-10-06 10:46:37 +08:00
Willie c0f200f7d6 Merge branch 'main' into runkids/pi-cimd-validation 2026-10-06 10:36:04 +08:00
Willie 8f79733b4f fix(mcp): validate Pi CIMD OAuth settings
Reject unsupported client registration values and CIMD client or callback conflicts before syncing invalid settings to Pi. Keep dcr and custom Pi options supported, identify the legacy codemode alias, and document current Pi launch behavior.
2026-10-06 09:52:16 +08:00
Willie 8e9ef1c806 test(sync): make the tests pass on Windows and run them in CI
Ten tests assumed POSIX behaviour:

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

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

Refs #344
2026-10-06 09:40:50 +08:00
Willie 8f47b5962a test(trash): make the link tests pass on Windows
Three link tests assumed POSIX behaviour:

- alias/../checkout is resolved lexically on Windows, before the alias
  is followed, so the traversal case cannot hold and is skipped there.
- Windows drops `..` when it creates a relative symlink, so the expected
  link text is cleaned first.
- Windows stores `assets/note.txt` as `assets\note.txt`, so the nested
  link target is compared in slash form.

Refs #344
2026-10-06 09:40:49 +08:00
Willie e031274207 fix(utils): refuse a network path as a junction target
A junction cannot point at a UNC path; mklink /J exits 1 for one. The
reparse-point API would instead write an unusable mount point, so return
an error up front and leave nothing behind, as mklink did.

Refs #420
2026-10-06 01:28:55 +08:00
Willie 05b2f12023 fix(utils): detect junctions under GODEBUG=winsymlink=0
With winsymlink=0 Go reports a junction as ModeSymlink instead of
ModeIrregular, so IsJunction returned false and the trash fallback
recreated the junction with os.Symlink again. Read the reparse tag for
both modes.

Refs #420
2026-10-06 01:16:37 +08:00
Willie 4b2da26f9a fix(utils): accept extended-length paths as junction targets
The junction substitute name is an NT path (\??\C:\x). A target given as
a Win32 extended path (\\?\C:\x or \\?\Volume{GUID}\x) kept its prefix,
so prepending \??\ produced an invalid name and the junction could not
be read through. Swap the prefix instead of stacking it.

Refs #420
2026-10-06 01:02:09 +08:00
Willie 3375419c63 test(sourcefs): allow the raw writes in CreateJunction
The previous commit moved junction creation onto os.Mkdir and os.Remove
inside CreateJunction. The raw-write ratchet lists every such call, so
record them with the same reason as the neighbouring link helpers.

Refs #420
2026-10-06 00:54:38 +08:00
Willie eb359a7626 fix(utils): create junctions through the reparse-point API
Quoting the paths for `cmd /c mklink` stops `&` from splitting the
command, but cmd.exe still expands `%VAR%` inside quotes, so a path with
a token such as `%TEMP%` pointed the junction somewhere else or failed.

Create the directory and set its mount-point reparse data with
FSCTL_SET_REPARSE_POINT instead. No shell parses the paths, which also
removes the need for quoting. Like mklink /J it refuses an existing
link path, and it removes the directory it made if setting the reparse
data fails.

Refs #420
2026-10-06 00:52:54 +08:00
Willie 377eae3d89 fix(utils): quote junction paths passed to cmd.exe
CreateJunction passed both paths to `cmd /c mklink` as plain exec
arguments. Go quotes an argument only when it has whitespace, so a path
with a cmd metacharacter such as `&` was split into a second command:
the junction was not created, and a crafted name could run a command.

Build the command line ourselves and quote both paths. A Windows path
cannot contain a double quote, so the quoting cannot be broken out of.
The regression test uses unspaced paths with `&`, which fail without
this change.

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

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

Refs #420
2026-10-06 00:32:38 +08:00
Willie 06f6362f3b Merge remote-tracking branch 'origin/main' into runkids/419-link-unlink 2026-10-05 23:45:45 +08:00
Willie 6c9c3f5fce fix(server): roll back the dashboard link when enabling fails
POST /api/source-links with enable: true left the new link in the source
when the config could not be saved, so the dialog reported a failure the
filesystem did not match and a retry failed with "already exists". Share
one sourcelink.Discard rollback between the CLI and the handler.
2026-10-05 23:16:58 +08:00
Willie 147b509e5f fix(plugins): show the commit when a source changes without a new version
Update checks compare the source digest, not the version, so a repo that
pushes commits without bumping its manifest (ponytail ships dozens a day)
showed "4.12.0" with an Update button and looked like a stuck update.

Check now returns the source commit, and the version tag adds
"old → new" commits when the version itself did not move.
2026-10-05 23:03:03 +08:00
Willie d6a533d1b6 fix(server): reflect traversal failures on standalone source links
sourceLinks were built before discovery ran, so a target readable at its
root whose subtree failed during traversal stayed available: true with
no warning while sourceLinkWarnings already reported it as incomplete.
Build the items after discovery and treat a recorded skip as unavailable.
2026-10-05 23:01:50 +08:00
Willie 9db36b472a Merge remote-tracking branch 'origin/main' into runkids/419-link-unlink
# Conflicts:
#	internal/server/handler_skills.go
#	skills/skillshare/references/TROUBLESHOOTING.md
#	website/docs/reference/commands/ui.md
#	website/docs/reference/targets/configuration.md
#	website/i18n/ja/docusaurus-plugin-content-docs/current/reference/commands/ui.md
#	website/i18n/ja/docusaurus-plugin-content-docs/current/reference/targets/configuration.md
#	website/i18n/ko/docusaurus-plugin-content-docs/current/reference/commands/ui.md
#	website/i18n/ko/docusaurus-plugin-content-docs/current/reference/targets/configuration.md
#	website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/commands/ui.md
#	website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/targets/configuration.md
#	website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/reference/commands/ui.md
#	website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/reference/targets/configuration.md
#	website/src/data/featureMap.ts
2026-10-05 22:49:25 +08:00
Willie 891c687a47 fix(server): anchor target frontmatter writes to the source
Rewrite frontmatter as bytes and read and write target assignments through sourcefs with the discovery follow policy. Refuse nested SKILL.md links with per-skill batch errors or HTTP 400 while regular followed skills remain editable and outside files stay unchanged.
2026-10-05 22:35:00 +08:00