On main these two readers scanned SKILL.md line by line and returned at
the line they were looking for, keeping nothing. After the refactor they
first collected the whole frontmatter block, so a large block cost its
full size on every call even when name came first, and an unclosed one
cost the rest of the file. Sync, target naming and listing call them
once per skill or agent. Reported by Codex review on #457.
The per-line rule (which line opens and which closes the block) moves
into blockWalk, which locateFrontmatter and the new scanLenientBlock
both use, so the streaming path and the byte locator cannot drift.
ParseSkillName and ParseFrontmatterField stop at their key again; the
list and fields readers collect the block as they always did. Results
are unchanged for every entry point.
Refs #449
TestGitRemoteHash_DefaultBranchUsesAuth puts an extensionless shell
script named git first on PATH. On Windows exec.LookPath only resolves
names with a PATHEXT extension, so the script is ignored and the real
git.exe probes github.com, which answers "repository not found" for the
made-up repository. The auth env is built without any platform branch,
so the product path is unaffected; only the test double cannot work
there. Skip it for the same reason the fake-git tests in
internal/install/source_fallback_test.go already do.
Refs #444
Rebuilding the path readers on the shared locator made them read the
whole SKILL.md into memory, where they used to scan line by line and
stop at the closing delimiter. They run once per skill or agent during
sync and listing, so a large body, or a large file with no frontmatter
at all, now cost its full size on every call.
readHead goes back to a bufio.Scanner and keeps the lines from the
opening delimiter to the closing one, nothing before and nothing after.
Reading through the real Scanner also replaces the code that imitated
its quirks (64 KiB line cap, one \r dropped per line); ReadSkillBody,
which needs the body, takes them from scanLines. An unclosed block is
still kept to the end of the file, as the list and fields readers always
did.
Review follow-ups in the same files: RewriteFrontmatterList no longer
copies the content to a string and back, ParseFrontmatterField's two
loops no longer share an index, and the tests share one file helper.
Results are unchanged for every entry point.
Refs #449
Resolution.Run started a goroutine for every remote, even without
Parallel. The dashboard handlers run sequentially and rely on net/http
recovering a panic, which it only does on the request's goroutine, so a
panic while resolving a remote would have ended the server process
instead of failing one request, as it did before the resolution moved
into internal/check.
The sequential and the parallel path are now separate loops, so the
invariant is visible instead of being spread over three Parallel checks.
Refs #444
Review of the guidance move found no defect, but three things made the new
seam harder to read than it has to be:
- The plan and apply handlers nested the success path inside `if err == nil`
with one shared error write. They return early again, like the handlers
next to them.
- The handler derived the scope from IsProjectMode() while GuidanceInput
derived the same value from ProjectRoot. Scope() is exported so the status
response and the block inspection read one value.
- (*Server).memoryInstructions had become a one-line passthrough with a
single caller, so it is inlined.
GuidanceReader is now exported, so its doc states what the server always
guaranteed: at least one source, and Dest indexing one of them. The
ApplyGuidance and Config comments say what callers need to know, and the
architecture paragraph is rewrapped.
No behaviour change.
Refs #450
Each reader in internal/utils found the --- delimiters with its own
loop, under four different rules that were only visible by reading all
of them, and the list reader existed twice with a path copy and a bytes
copy that had drifted apart. A fix to one reader, like the mcp serve
fixes to the strict one, did not reach the others, and nobody could say
which rule an entry point followed without tracing it.
locateFrontmatter now does the locating for every reader, and the rule
is a frontmatterPolicy value: strictBlock, lenientBlock, bodyBlock and
rewriteBlock name the rules that exist and the entry points that use
them. The rules themselves are not unified; every entry point returns
what it returned before, including the bufio.Scanner quirks of the
readers that take a path (a line of 64 KiB or more ends the content,
one \r is dropped per line), which now live in scannable. The strict
reader still walks only to the closing delimiter and copies nothing.
Two more cases found by comparing old and new code on random input are
pinned: a block scalar on the last frontmatter line, and \r\r\n endings.
Refs #449
The guidance rules (status ranking, mixed_modes, multiple_blocks, the plan
token, and check -> backup -> recheck -> write) were methods on *Server, so
they could only be exercised over HTTP with a configured server, and the
recheck after backup depended on callers using the right helper.
internal/memory now owns status, plan, and apply behind GuidanceStatus,
PlanGuidance, and ApplyGuidance. The server resolves targets, assignments,
shared extras, and project reach into a GuidanceInput, syncs shared copies
through a callback after each written file, and maps results to JSON. Only
ApplyGuidance reaches the write steps, so the recheck cannot be skipped.
Note creation and guidance creation shared a copied O_EXCL create with
delete-on-failure; both now use createExclusive. Each keeps its own
behaviour: notes still chmod to 0644, guidance still creates parents.
HTTP routes, shapes, status codes, and error codes are unchanged. The raw
write allowances follow the calls to their new functions.
Refs #450
The CLI, GET /api/check and the check stream each wrote out the same
sequence: group skills by URL and branch, ask the remote hash, skip the
tree fetch when every skill matches, otherwise compare tree hashes and
assign a status. A fix such as branch handling had to be made three
times, and the sequence could only be tested against real repositories.
internal/check now owns it as Plan and Resolution.Run, with the remote
hash source injected and a per-remote progress callback. The CLI
progress bar and the SSE counter are adapters on that callback; the JSON
handler passes none.
The callers disagreed in two places, and both behaviours are kept: the
dashboard reports a skill removed upstream as update_available where the
CLI says stale, and gives no source or version for a skill without a
remote. The server adapter narrows the result accordingly.
Refs #444
The CLI, GET /api/check and the check stream each carry their own copy of
the resolution sequence, and only its leaf helpers were tested. Pin what
each caller reports for every outcome, against local bare remotes, so the
copies can be merged without changing output.
Refs #444
The readers in internal/utils locate the --- delimiters under different
rules, so the same SKILL.md can give different answers depending on the
entry point. Before they are rebuilt on one locator, these cases record
each entry point's current result on the inputs where the rules differ
(indented or late delimiters, unclosed and empty blocks, trailing
spaces, CRLF, BOM, delimiters in the body) and on a line longer than the
bufio.Scanner cap that the path readers silently stop at.
Refs #449
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.
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
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
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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
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
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.
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
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
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
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