7 Commits
Author SHA1 Message Date
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 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
Willie a9ae5349a2 feat(extras): choose which files each target syncs, and edit targets in place
A directory extra used to sync every file to every target, so a tool that
only wanted a few docs got the whole folder. Each target can now set
gitignore-style include/exclude patterns, matched on the path inside the
source. Merge targets prune links to files that stop matching; copy targets
keep earlier copies, since nothing records which copied files are ours.
Filters are rejected for symlink mode and single-file extras, and sync warns
when an include matches nothing.

The dashboard previously forced users to delete and re-add a target or an
extra to change it. Edit target now changes the folder, file name, mode,
flatten and filters with a live preview; Edit extra renames an extra or
points it at another source folder. A moved target or source drops the
links left at the old place and syncs right away.

CLI: --include/--exclude on extras init, and --add-include, --add-exclude,
--remove-include, --remove-exclude on extras <name>.

Refs #435
2026-10-08 15:31:51 +08:00