25 Commits
Author SHA1 Message Date
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
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 99c7911bf3 feat(plugins): update a batch of plugins over one stream (#534)
Updating several plugins from the dashboard was slow: each plugin took a
preview and an apply round trip, apply previewed again, every plugin cloned
its source on its own, and config reloaded after each one.

The dashboard now sends the picks to POST /api/plugins/update/stream. The
server holds the plugin lock once, previews each plugin once and applies that
plan, lets plugins from one source share a single read of it, and reloads
config once at the end. POST /api/plugins/update/stop lets the plugin under
way finish and starts no other; a closed page does not cut an install short.

The check-to-update safety moves to the server: an Agent whose source moved
since the check, or that no check showed, installs nothing. npm packages in
Pi are exempt, since Pi installs whatever npm names latest; the old
client-side comparison flagged them as moved on every update.

The update dialog follows the Skills update page, shows per-Agent old -> new
versions, fails rows a broken stream never finished, and lists every plugin
with its Agent and version when all are current.

Release-As: 0.25.6
2026-10-12 16:09:12 +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 c0d2d0409a fix(sync): rewrite the prefixed name of a read-only SKILL.md
A copy keeps the source file's mode, so a read-only SKILL.md (e.g. from
a read-only checkout) could not be reopened for the name rewrite and a
non-root sync failed, dropping the skill from the target mid-migration.
Lift the write bit for the rewrite only and restore the mode afterwards.
2026-10-09 10:37:50 +08:00
Willie 096de1ad9b fix(sync): drop a copy whose prefixed name could not be written
When the name: rewrite failed after the copy, the new folder stayed in the
target with no manifest entry, so later syncs took it for a user's folder
and never refreshed it. The copy helper now removes the folder it just made
before returning the error; the next sync copies it again.
2026-10-09 01:02:43 +08:00
Willie 16cfd048f1 test(sourcefs): allow the raw writes prefixed naming adds to targets
The raw-write ratchet flags SetFrontmatterValue and the rename-back after a
failed manifest write. Both only touch target entries (the copied SKILL.md
and a just-renamed managed folder), never the skills source, so they are
listed with the target reason.
2026-10-09 00:53:13 +08:00
Willie 11c2821350 fix(config): write the project migration through a fresh temp file
The legacy target migration wrote to the predictable path
config.yaml.tmp next to the validated destination. A cloned project
could ship that name as a symlink to a file outside the project, so
merely loading the project overwrote the outside file and the rename
then replaced the project config with the link.

Create the temp file with os.CreateTemp in the destination directory,
which never follows an existing name, and remove it if any step fails.
2026-10-07 10:46:00 +08:00
Willie 080bb3e5e4 fix(server): guard the dashboard raw config save in project mode
PUT /api/config wrote the raw editor content with os.WriteFile, which
follows a symlinked config.yaml. In project mode a link to a config
outside the project was overwritten, bypassing the boundary the other
config writers now enforce. Route this write through ConfigWritePath
and answer 400 with the link named.
2026-10-07 10:36:22 +08:00
Willie 49b43b228c fix(plugin): keep symlinked config.yaml and normalize plugin sources
Plugin saves wrote a temp file next to config.yaml and renamed it over
the path. When config.yaml is a symlink into a dotfiles folder, the
rename replaced the link with a regular file, so the shared config
never received the change and the machine silently forked. The plugin
writer also skipped preserve_tilde_on_save, saving sources as absolute
home paths. The one-time legacy target migrations for global and
project configs used the same temp+rename and replaced links as well.

Plugin sources were compared as raw strings. The snapshot owner marker
records the absolute path from add, so a config that spells the same
folder as ~/... failed every update with "snapshot ownership conflict".
For Agents whose snapshot location hashes the source, the new spelling
silently created a second snapshot instead.

Resolve the symlink before writing, normalize sources once where the
plugin section is decoded so owner checks and snapshot paths agree,
and fold sources back to ~ on save when preserve_tilde_on_save is set.

Refs #460
Refs #461
2026-10-07 09:56:48 +08:00
Willie 0117161c8b Merge remote-tracking branch 'origin/main' into runkids/436-managed-instruction-block 2026-10-07 01:13:44 +08:00
Willie a165bf7cf9 Merge branch 'main' into runkids/arch-444-check-resolution 2026-10-07 00:56:06 +08:00
Willie 05ff8c675a feat(extras): prepend and append modes for single-file extras
Tools without an @import directive (codex, gemini, cursor) could only
take a shared instruction file as a symlink or copy, which replaces the
target's own file. Teams that want one shared AGENTS.md plus the user's
own notes in the same file had no way to express that.

prepend and append write the source into the target file as a managed
block fenced by skillshare:extra markers that carry the source path and
a content hash. Sync inserts the block once and then rewrites it in
place, status reports modified when the block body no longer matches
its hash, Collect copies the edited body back to the source, Reapply
rewrites the block from the source, and restore removes only the
block. Lines outside the block, and markers inside code fences, are
never touched. Several managed blocks (and an import line) may share
one target file; the connection validator only rejects a file when a
replacing mode (symlink, copy, merge) is involved.

Refs #436
2026-10-07 00:04:00 +08:00
Willie c23daf8ccc refactor(memory): move guidance plan and apply out of the dashboard handler
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
2026-10-07 00:03:50 +08:00
Willie 1f3e61b830 test(check): pin update-status resolution for the CLI and dashboard
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
2026-10-07 00:03:34 +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 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 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 f20b7f7f1f fix(trash): record link copying in the write ratchet
Register link recreation alongside the existing trash and agent recovery copy operations. Keep translated trash guidance separate from the existing group paragraph.
2026-10-05 22:27:55 +08:00
Willie e7eecffeab Merge remote-tracking branch 'origin/main' into runkids/274-follow-source-links 2026-10-05 21:32:38 +08:00
Willie 97446744ff feat(omp): add native Oh My Pi support (#423)
* feat(omp): add native Oh My Pi support

Support OMP skills, instructions, MCP, code hooks and guarded extension selection using its verified native contracts rather than Pi aliases.

Add reviewed marketplace plugin installation, cache-preserving scoped removal and fresh-cache reinstall. Align Pi/OMP extension cards and localize inventory guidance while keeping native ownership and read-only constraints.

Include regression coverage, isolated E2E runbooks, documentation and verification policies. Native plugin updates and unverified runtime platforms remain guarded.

Refs #409

* fix(omp): guard runtime ownership and localize inventory guidance

Native install recursively replaces its runtime destination, and a missing cache manifest could leave the real runtime link installed after removal. Bind and recheck an absent reviewed destination, and recover removal names only from verified scope-local links.

Localize fixed backend reasons and warnings across dashboard locales while preserving paths and external diagnostics. Restore the reviewed source in the existing reinstall fixture and record real native verification.

* fix(omp): allow forgetting natively removed plugins

A different plugin can retain node_modules after native uninstall deletes this installation. When its cache, registration and known runtime state are absent, forget only the stale Skillshare binding instead of demanding runtime-name proof for unrelated files.

Extend the existing removal recovery test with a failing-before-fix case that verifies the binding is dropped and unrelated native lock bytes and plugin files are preserved. make check passes.
2026-10-05 20:36:39 +08:00
Willie 2b76402240 test(source-links): align group test and raw-write ratchet with the review fixes
uninstall --group on a followed link is now refused, and restore no
longer creates parents with a raw MkdirAll, so the ratchet allowance
for it is stale.
2026-10-05 15:50:00 +08:00
Willie d4a9a28e04 fix(sourcefs): anchor MoveIn through a followed link in the opened root
MoveIn below a followed link ended in a pathname os.Rename against the
link target's directory. That pathname can be renamed away and replaced
by a link to another directory after through() cached the second root,
so the move landed outside the checkout the root was opened on.

The followed route now copies the staged tree through the root handle to
a temporary name, renames it into place through the handle, and removes
the staged source only after that. The primary root keeps its rename, so
behavior without a follow policy is unchanged.
2026-10-05 15:38:48 +08:00
Willie c0e66720ce fix(source-links): preserve trashed links and resolve audit and hash roots
Trash moves and restores the link entry without copying or removing its target, including when rename fails. Relative link text is stored as an absolute target so relocation cannot change its meaning; list and TUI expose the link target without inventorying its contents.

Pass the operation-scoped Follow policy into audit and hash operations, resolving their physical root while keeping logical result and metadata keys. Calls without a policy keep their existing behavior and ScanSkill retains its original function signature.

Update six stale trash raw-write allowances for the injected rename test seam and classify moveLink creation/removal: it moves a checked source entry to trash or restores an entry into source, never writes through its target. Raw sourcewalk calls and allowances are unchanged.
2026-10-05 14:45:41 +08:00
Willie 8c60f51b9f feat(source): add the sourcewalk walker and sourcefs write boundary for proposal 274 (#385)
Implements rollout steps 1 and 2 of proposals/274-skillfollow.md. Nothing follows a link or parses .skillfollow yet.

Step 1: doctor reports first-level symlinks and junctions in the skills source as info, in text and JSON, without following them.

Step 2a: internal/sourcewalk owns traversal of the skills source. Thirteen raw walks move onto it with identical behavior, and a go/parser ratchet fails the tests on any new unclassified walk.

Step 2b: internal/sourcefs wraps an os.Root opened at the skills source and refuses any write whose path has a link component. The six write sites the proposal found in review move onto it, including the cross-device copy fallback, and a second ratchet covers raw os write calls. The only behavior change is that an explicit path crossing a link inside the source is refused instead of written through.

Refs #274

Release-As: 0.24.3
2026-10-04 15:15:43 +08:00