Commit Graph
2 Commits
Author SHA1 Message Date
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 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