Commit Graph
499 Commits
Author SHA1 Message Date
Willie 6ea5b91843 test(server): cover selected global config in dashboard log handlers
The handler test used the default test config directory, so it passed
without the oplog routing fix. Select a config in a folder named
skillshare so list, stats and clear prove they use the state-dir log.

Refs #609
2026-10-25 22:57:04 +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 1a79971df4 feat(ui): show skill descriptions in the list and redesign package rows (#635)
* feat(ui): show skill descriptions in the list and let expand all open packages

Reviewing a large library meant opening each detail page just to read
what a skill does (#627, proposal in #631). The resources list response
now carries each skill's and agent's frontmatter description, read in
the same pass as manual-only, and the list shows it truncated under the
name with the full text on hover.

The read now decodes the frontmatter once for both fields. An unquoted
": " in a description is invalid YAML, so a failed decode falls back to
the line scanner instead of dropping the description and manual-only.
Editing a skill refreshes the list too, so the new description shows
right away.

Expand all / Collapse all also opens and closes nested-skill packages
from #624; before, it only touched source and folder groups.

Closes #627

* feat(ui): redesign list packages as an inset panel with a description switch

The chevron-in-a-column nesting read as a second, unrelated table and gave
no room for the descriptions #627 asks for. A count pill after the package
name now opens its skills in one quiet inset panel, with deeper packages
indented under a faint guide, so the hierarchy stays readable at any depth.

The rest closes the gaps left against #627: a Show > Descriptions switch
keeps the compact list one click away, keyboard focus reveals the full
description, a search opens only the packages holding a match without
overwriting what the user left open, and the selection bar says how many
selected items are out of view. Only the name opens the detail page, since
whole-row clicks were easy to trigger by accident once rows held more text.

* fix(ui): keep linked-folder matches when searching a folder group

Searching while grouped by folder took package ancestors only from skills
whose folderOf matched the group key, but groupByFolder keys a linked
folder's skills by the link name. Every skill in a linked folder fell out
of its own group, so the header counted a match and drew no row. The
ancestor pool is now each folder group's unfiltered skills, keyed by
groupByFolder itself, which always contains the group's matches.

* fix(ui): keep the .ss-r .nm.m rule the design token export reads

Merging it into :is(.ss-r, .ss-nr) .nm.m removed the exact selector that
scripts/design/tokens.py looks up for the row name type scale, so the
design token tests failed in CI.
2026-10-24 21:43:12 +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
Rusty Shackleford d23a44aec9 refactor(projects): share safe dashboard and CLI operations (#602) 2026-10-23 02:07:54 +08:00
Krishnaswamy SubramanianandWillie dabe06a297 feat(targets): support OpenCode config directory accounts (#594)
* feat(targets): support OpenCode config directory accounts

OpenCode v2 introduces support for custom configuration directories
via OPENCODE_CONFIG_DIR, storing opencode.json and agent directories.

Previously, skillshare rejected OpenCode accounts configured with a
custom config directory because OpenCode was missing config_dir and
was excluded from accountAgents in hooks and MCP services.

- Define default config_dir (~/.config/opencode) in targets.yaml
- Add OpenCode to account agents and register OPENCODE_CONFIG_DIR
  across hooks and MCP service handlers
- Route OpenCode account MCP configuration to opencode.json inside
  the account config directory

Resolves #593.

* fix(targets): add OpenCode to schemas, completions and docs

Add opencode to the targetConfig.agent enum and config_dir description
in schemas/config.schema.json so configurations containing OpenCode
account targets pass schema validation.

Include opencode in the target --agent completion scripts for Bash,
Zsh, Fish, PowerShell, and Nushell.

Update website documentation and built-in skill references to describe
OpenCode accounts and OPENCODE_CONFIG_DIR management alongside other
account agents.

* fix(targets): support plugin accounts and overlap

Add OpenCode account recognition and OPENCODE_CONFIG_DIR resolution to
the plugin service so plugin sync works for OpenCode account targets.

Introduce TargetScanPaths to resolve cross-runtime scan paths using
TargetConfig.Agent for account targets while retaining the account's
own primary directory. Update path overlap detection, doctor checks,
and LeakedSkills to warn about leaked skills for account targets.

Update localized docs (zh-Hans, zh-Hant, ja, ko) and plugin references
to document OpenCode account targets and OPENCODE_CONFIG_DIR. Update
the available targets handler test to expect OpenCode's configDir.

* fix(targets): isolate OpenCode accounts and scan paths

Reject OPENCODE_CONFIG overrides when operating on OpenCode accounts
and clear OPENCODE_CONFIG in the account execution environment so
plugin operations target the account directory.

In TargetScanPaths, remap config-root paths to the account directory
while preserving external scan paths like Codex's ~/.agents/skills.

* fix(plugins): use account target in OpenCode update probe

Pass c.Target instead of a hardcoded "opencode" when probing whether
OpenCode supports plugin updates, ensuring account-configured CLI
binaries and account environment variables are used during preview.

* test(mcp): isolate XDG_CONFIG_HOME in account test service

Isolate XDG_CONFIG_HOME to the temporary test directory in
agentAccountService to prevent runner environment variables from leaking
into TestAccountEnvOverrideDoesNotPruneDefaultHome when testing OpenCode
account shell overrides.

---------

Co-authored-by: Willie <egg358358@gmail.com>
2026-10-22 21:50:06 +08:00
Willie 2bba224cdf fix(ui): update agents from the Updates tab and repo detail page (#601)
The Agents Updates tab updates through /api/update/stream, which resolved
every name against the skills source, so agent updates failed there. The
agent detail page names a tracked repo by its folder, which updateAgent
did not resolve, so updating an agent inside a repo failed with "agent not
found".

The stream now takes a kind and routes agent names to updateAgent, which
also resolves an agent repo folder under the agents source. The tab sends
its kind to the stream and to Prune, and matches update results by kind and
by the agent's path, so a nested agent is marked up to date after it
updates.

Closes #600
2026-10-22 00:39:12 +08:00
Willie 7b952c02a9 fix(update): honor accepted findings in dashboard tracked updates (#599)
* fix(update): honor accepted findings in dashboard tracked updates

The dashboard ignored findings accepted through the CLI, so a tracked repo
that `update --force` let through was blocked again on the next dashboard
update, and every dashboard Force Retry had to be repeated. Regular skill
updates in the dashboard already honored and recorded acceptances, so only
tracked repos differed.

Tracked-repo updates now always honor accepted findings and record the ones
an override lets through, for both callers. The opt-in option and the
AuditGate flag it fed are removed, since no caller turns them off.

Dashboard agent tracked repos passed an empty source dir, so a nested repo
kept acceptances in its group folder under a different key than the CLI.
They now pass the agents source, as the CLI does.

* fix(update): reload the agents store after agent repo refresh

Dashboard agent tracked repos now refresh metadata in the agents source,
but a metadata change reloaded the skills store, leaving the agents store
as it was until the next request. Reload the store that matches the source.

Every caller of update.TrackedRepo now passes a source dir, so the
empty-dir guard and its doc no longer describe a supported mode. The new
agent test reuses the tracked fixture instead of rebuilding it.
2026-10-21 23:28:16 +08:00
Willie f6e7265414 feat(hooks): read hook code and scripts from files next to the config (#586)
* feat(hooks): read hook code and scripts from files next to the config

Code Agent extensions and command scripts lived as strings in
config.yaml, so a longer Pi extension or shell script was edited inside
a YAML block scalar with no editor support, and nothing type-checked or
linted it. A breaking change in an Agent's extension API went unnoticed
because the generated file is not part of any tsconfig.

A binding now takes `codeFile: path` instead of `code`, and a `files`
value may be `{from: path}` instead of the contents. Paths resolve
against the folder of the config that holds the entry and are read
every time the config is read, so the regular typecheck or shellcheck
can cover the real source. The revision and drift checks use the
resolved contents, so a file edited after a preview fails the apply as
stale.

Saving keeps the references: enable/disable, `hooks edit` and the
dashboard write `codeFile` and `{from}` back instead of inlining the
contents. JSON carries the contents plus `codeFile`/`filesFrom`, and an
entry echoed back with both must match the file, so an edit is refused
rather than silently dropped. Paths must stay inside the config folder
without symlinks, so a cloned project cannot pull in files from
elsewhere. References are taken from the YAML tree before one strict
decode, which keeps unknown-field checks and anchors shared across
bindings working.

Closes #585

* fix(hooks): refuse an emptied file sent with its reference

An empty files value stood for "contents not sent", so a file cleared in
the dashboard's Git YAML editor while its filesFrom reference stayed was
treated as unsent: the file was read again from disk and the save
reported success with the user's edit discarded.

A value read from {from: path} now keeps a dedicated mark until it is
resolved, so an empty value is compared with the file like any other
contents and refused when they differ. Code keeps using empty as unsent,
since a code binding can never be empty.

* fix(hooks): render referenced files as they are on disk

RenderNative rendered the contents the caller sent. The dashboard sends
the entry it loaded, so after a referenced file changed, View
configuration still showed the old contents while describing them as
what sync would write.

Render now drops sent contents for codeFile and {from} references and
reads every reference again, like preview and save. Draft, render and
config decoding are the only paths that take an entry, and all three now
resolve references.

* fix(hooks): accept file references in JSON entries and anchored values

Two inputs that config.yaml accepts failed to load elsewhere.

A `{from}` value carrying its own YAML anchor, aliased from another
binding, lost its anchor because the value node was replaced instead of
rewritten, so the alias no longer resolved. The node is now rewritten in
place with its anchor kept.

An entry JSON file (`hooks add|edit --file x.json`) could not write a
files value as `{"from": path}`, because JSON decoded straight into
string contents. Binding now decodes JSON files values as contents or a
reference, strictly, like YAML, so both entry formats and the Web API
take the same shapes.
2026-10-19 22:48:00 +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 bfc402fe96 feat(mcp): open an Agent's MCP config folder, and project files, from the dashboard (#554)
* feat(mcp): open an Agent's MCP config folder, and project files, from the dashboard

A user who wants their own editor (Notepad++ on Windows) found setting
both PATH and $EDITOR too much just to open a config file, and could not
find any entry point for the MCP files of an mcp.projects root (#538).

Each Agent row on the MCP page now also has Open folder, which opens the
folder holding the file in the file manager, so any program can open it
from there. Before the Agent has written its file, it opens the closest
folder that exists. The project MCP tab gets the same Agents list for
that project's files. The open endpoint resolves project paths from the
config, as it does global ones, so a request still cannot name another
file, and folder and file opens keep the same-machine and headless
guards. The file manager launch is shared with the extensions folder.

* fix(mcp): keep a project's existing Agent files listed for remote viewers

Codex review: the project MCP tab built its Agents list from the
project's targets plus the files this viewer could open. A viewer on a
LAN address or behind a proxy can open none, so an existing file of an
Agent outside the project's targets dropped off the list, although the
docs say it shows with its path and only the open buttons go.

The list now returns which files exist apart from whether this viewer
may open them, and the page shows the open buttons only when local.

* fix(mcp): list the Agents a project's own servers write to in its file rail

Codex review: a server that exists only in one project can pick Agents
outside the project's targets, and sync writes their project files, but
the project tab listed only the project's targets and files that already
existed. Before the first sync such an Agent had no row, so its path
could not be copied and its folder could not be opened.

The list now also takes the targets of the project's own servers. Global
servers reach a project only through its targets, so they add nothing.
The rule lives in mcpView as projectFileTargets, with a unit test.
2026-10-13 15:00:39 +08:00
Willie 9e935b35fb fix(ui): accept a quoted editor path in $EDITOR (#553)
Open in editor split $VISUAL and $EDITOR on whitespace, so a Windows
path such as "C:\Program Files\Notepad++\notepad++.exe" broke at the
space and no editor was found. A user asked to open files in Notepad++,
which is not on PATH by default (#538).

Double or single quotes now keep a field together. Backslashes stay
literal, since Windows paths use them.
2026-10-13 10:41:27 +08:00
Willie 7ee08b913d feat(mcp): open an Agent's MCP config file from the dashboard (#552)
* feat(mcp): open an Agent's MCP config file from the dashboard

Users asked to jump from the MCP page straight into a client's config
file, such as opencode.json or .cursor/mcp.json, instead of copying the
path and opening it by hand (#538).

The open uses the same editor chain as a skill's Open in editor, so the
dashboard opens files one way. The endpoint takes a target, not a path,
and only opens a file the MCP page already lists. It answers only
requests from the machine running the dashboard, because the editor
starts on that machine. The list now reports which files exist, so the
button is hidden for a client detected before it has a file.

* fix(mcp): hide Open in editor where the server would refuse it

Codex review: the dashboard can be opened through a LAN IP, but the
open endpoint answers only loopback requests, so the button showed and
every click returned 403, while the docs promised it would open.

The list now reports `openable` instead of `existing`: the files that
exist, and only when the request comes from the dashboard's machine. A
viewer elsewhere does not see the button, and the docs say where it
appears.

* fix(mcp): don't treat a reverse proxy's viewers as local for Open in editor

Codex review: the documented Nginx and Caddy setups connect from
127.0.0.1, so the loopback socket check let any browser behind the proxy
see the button and launch editors on the server.

The browser now counts as local only when the socket and the Host it
used are both loopback and no proxy forwarding header is present. Both
documented proxies keep the browser's Host and add X-Real-IP or
X-Forwarded-For, so their viewers no longer qualify.
2026-10-13 10:40:27 +08:00
Willie 12dd041288 fix(plugin): accept OMP 18.6.1 and later instead of exactly 18.6.1 (#543)
* fix(plugin): accept OMP 18.6.1 and later instead of exactly 18.6.1

The OMP adapter pinned the native version to exactly 18.6.1, so every
newer release was refused: the dashboard reported "Installation requires
OMP 18.6.1" for a user on 18.8.7, and removal and standalone extension
selection were blocked the same way.

The sources the adapter depends on (marketplace cache/manager/types,
plugin-cli output, the project anchor in discovery/helpers.ts, extension
loading and the pi-natives file lock) are unchanged from v18.6.1 through
v18.10.2, so the pin is now a minimum. The install, removal and selection
gates share one check built on the existing plainVersion helper;
unparsable, prerelease and older versions stay blocked.

Messages, all dashboard locales, the plugin reference docs and the
built-in skill now state 18.6.1+. A test keeps the English guidance text
in en.json equal to the Go strings the dashboard matches on.

* fix(docs): record the OMP 18.6.1+ boundary in the cache safety report

The safety report still said installation is allowed only for OMP 18.6.1
and that an unknown version blocks it, which no longer matches the gate.
It now states the minimum, which versions stay blocked, and the source
comparison and native 18.8.7 run that justify replacing the pin. The two
OMP runbooks no longer require exactly 18.6.1.
2026-10-13 02:50:17 +08:00
Willie b9563ea4e8 feat(memory): add host-owned review and verification workflows (#539)
* feat(memory): add host-owned review and verification workflows

Share scoped memory tools between Dashboard and Memory, and route retrospective and Dreaming requests through the built-in skill. Keep agent execution in the host, require approval for reviewed edits, and preserve versioned CLI write safeguards.

Confirm scope before exposing prompts and include the resolved root in recent memory responses. Update provenance guidance and localized documentation, with regressions for unavailable scope and protected review prompts.

* fix(memory): distinguish trial copy controls for screen readers

Include the localized step title in each trial copy control accessible name while keeping the short visible label. Update the existing clipboard test selector for the distinct names; no new test or local test rerun was requested for this label-only fix.

* fix(memory): point connection hints to the trial tools

Replace stale verification-prompt directions in all eleven locales with the current Memory tools and Try across sessions labels. Interpolate the existing localized labels so future naming changes remain aligned.

No new tests or local test reruns for this copy-only correction, as requested by the maintainer.
2026-10-12 22:34:05 +08:00
Willie 8213a4a385 feat(ui): make shared memory easier to find and read (#537)
* feat(ui): surface existing shared memory on the dashboard

Make shared notes visible through recent updates and direct links, with file timestamps and an introductory state for untouched starters. Keep the dashboard quiet until memory is configured, and preserve access to existing notes when starter files are missing.

* fix(memory): bound dashboard reads and remember preview expansion

Count vault entries from metadata and read at most the two starters and four recent candidates instead of hashing the full vault on dashboard load. Keep incomplete starter states accessible and refresh the overview after source and instruction changes. Remember preview expansion in browser storage and raise the collapsed height to 360px.
2026-10-12 17:34:33 +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 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 89f4b9425a refactor(reconcile): share the lock pin mover, skip adoption when no record is gone (#524)
Cleanup after #523: install.MoveLockPins shared by skillmove and the project reconcile; one server store reload and reconcile dispatcher; adoption skips the source walk when no plain record's directory is missing.
2026-10-11 04:19:32 +08:00
Willie 3a5da6b529 feat(sync): adopt the install record of a skill moved by hand (#523)
After a plain mv, only install or Install missing moved an installed skill's record; sync now adopts it too (CLI global, CLI project, dashboard), never prunes, and skips on --dry-run. A hand-moved project skill keeps its lock pin; a same-name nested skill never takes a live record; metadata load failures are sync warnings.
2026-10-11 03:50:58 +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 81974cf350 fix(resource): never skip a hidden-named agents source root (#515)
AgentKind.Discover and the skill detail file listing skipped every
hidden directory, including the walk root itself. The `!= "."` guard in
agent.go never fires because walkRoot is an absolute resolved path, so a
sources.agents directory such as ~/.agents discovered zero agents.

Exempt the walk root (`path != walkRoot`), matching the other walks in
the repo. Nested hidden directories are still skipped.

Related to #511 (same class as #514).
2026-10-10 22:03:53 +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 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 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 0782395634 fix(config): skip the naming-mode check for targets with skills off
A target with skills disabled syncs no skill but still syncs agents,
yet prefixed naming with a merge mode marked it invalid, so sync and
the dashboard dropped it before agent sync. Check naming against mode
only when skills are enabled, for targets, projects and the mode PATCH.
2026-10-09 11:41:27 +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 e1889e4f6b fix(server): check unexpanded projects before changing the global mode
A project whose folder is missing expands into no target, so the
dashboard's mode PATCH never saw its skills settings and could move the
global mode off copy under a project inheriting prefixed naming. Run
the project naming check against the requested mode as well.
2026-10-09 11:07:11 +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 eabe5fbc10 test(api): cover skillsSharedWith in the targets list
Code review of the target-page warning found the new targets API field
only had a unit test on the config helper. The handler is what the UI
reads, so check that it names targets writing the same skills folder and
leaves out one that writes elsewhere.

Release-As: 0.25.4
2026-10-09 01:28:28 +08:00
Willie 06b37d0fcf feat(api): list the targets that share a target's skills folder
The target page needs to know which other targets write to the same
skills folder to warn when an unsaved mode or naming change would make
their syncs undo each other. Re-implementing the server's folder
normalisation (home expansion, path cleaning) in TypeScript would drift
from config.SkillsFolderConflicts, so the targets API now returns
skillsSharedWith, built from the same skillsFolder helper.
2026-10-09 01:25:04 +08:00
Willie 92f3d809c0 fix(server): refuse a global mode that breaks inherited prefixed naming
Targets that set prefixed naming but inherit the skills mode depend on the
global mode staying copy. Changing it from the dashboard left those targets
invalid until the next sync reported them; the global mode setter now runs
the same copy-only check the per-target setters do.
2026-10-09 00:58:34 +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 e1aaf343fe Merge branch 'main' into runkids/extras-mode-rules 2026-10-08 16:17:56 +08:00
Willie b90bf2086f Merge pull request #493 from runkids/runkids/extras-sync-api
refactor(extras): pass targets to sync and filter them in one discovery function
2026-10-08 16:17:22 +08:00
Willie d61b25bcf2 refactor(extras): apply target filters in one discovery function
The extras diff, list, status and remove-target commands and the
server's list and diff handlers each discovered an extra's source and
then filtered it with ExtraTargetFiles. A new view that forgot the
filter step would silently show the wrong file count or status.

DiscoverExtraTargetFiles now discovers and filters in one call and
returns the unmatched-include warnings that sync reports. Every caller,
including sync itself, uses it, and ExtraTargetFiles is gone. No
behavior change.

Refs #487
2026-10-08 16:08:03 +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 dde1dc6ef7 refactor(extras): keep target mode rules in config
The rules "an extension forces copy mode" and "symlink mode drops
include/exclude" were re-implemented in the create, edit-target, and
quick mode handlers. ExtraTargetConfig.EffectiveMode and Normalize now
hold them in one place, and the handlers call those instead. API
behavior is unchanged: edit-target still clears filters on symlink,
quick mode still rejects symlink when the target has filters, and an
extension still forces copy.

Refs #488
2026-10-08 16:08:03 +08:00
Willie 7740ee8798 fix(extras): relink symlinks to a missing source and accept negated includes
- Pointing a symlink-mode extra at a new source after its old folder was
  moved or deleted left the target broken: the old link no longer resolved,
  so it was not recognised as ours, and the next sync skipped it as pointing
  elsewhere. The link text is now compared with the old source as well.
- A negated include such as "!draft.md" only narrows earlier rules, so on
  its own it never matches and was always reported as matching no file.
  Negations are no longer checked for matches.

Refs #435
2026-10-08 15:52:47 +08:00
Willie 72ce921eeb fix(extras): validate hand-written filters and keep links when a save fails
- Sync validation skipped directory extras, so a malformed include such as
  "[" written in the config matched nothing and merge sync pruned every
  link. Extras with include/exclude now go through ValidateExtraConfig.
- The dashboard's quick Mode menu could switch a filtered target to symlink
  and save filters that every later sync rejects. That change is now
  validated with the target's filters and refused.
- Changing an extra's source removed the links into the old folder before
  saving the config, so a failed save left working targets broken. The
  config is saved first.

Refs #435
2026-10-08 15:44:39 +08:00