Commit Graph
3 Commits
Author SHA1 Message Date
iFwu 5403595120 feat(config): preserve ~ in saved config paths (opt-in)
Add PreserveTildeOnSave config flag (default false). When enabled, the
Save path folds $HOME prefixes back to ~ when serializing the in-memory
Config to YAML so the on-disk config stays portable across machines
(e.g. when shared via dotfiles).

The in-memory Config is left untouched; cloneForSave() produces a
shallow copy with path fields rewritten. Mirrors the existing
expandPath() calls performed in Load():
  - cfg.Source, cfg.ExtrasSource
  - cfg.Targets[*].Path / Skills.Path / Agents.Path
  - cfg.Extras[*].Source and Extras[*].Targets[*].Path

Adds:
  - utils.FoldHomePath() helper with unit tests (exact-home, child,
    sibling-non-home, unrelated-abs, relative, Windows case-insensitive)
  - 3 Save-path tests covering default-off, fold-on, and Load→Save
    idempotency.

Default off keeps the change backward compatible: existing users see no
behavior difference. Users who share their config via dotfiles can opt
in with:

    preserve_tilde_on_save: true
2026-05-14 13:09:56 +08:00
Willie 38f8f1c796 fix(symlink): resolve symlinked source/target dirs across all Walk callsites
filepath.Walk/WalkDir silently skip symlinked root directories because
os.Lstat sees the root as a non-directory symlink and never enters it.
This affected update, uninstall, reconcile, and server handlers when
the source directory was a symlink (common with dotfiles managers).

Extract ResolveSymlink() from sync.go into internal/utils/path.go and
apply it at every filepath.Walk/WalkDir callsite on source/target dirs.

Also add containment guards to resolveGroupSkills (uninstall) and
resolveGroupUpdatable (update) to reject group directories that are
symlinks pointing outside the source tree.
2026-03-02 10:05:57 +08:00
Willie Hung 0f7ba6ff8d fix(windows): improve junction error messages and path comparison
- Add detailed error messages when junction/symlink creation fails
  - Pre-flight checks for source existence and target conflicts
  - Capture mklink /J stderr output
  - Show both junction and symlink failure reasons

- Add case-insensitive path comparison for Windows (NTFS)
  - New PathsEqual() and PathHasPrefix() in utils/path.go
  - Fix 8 path comparisons that could fail due to case differences
  - Affects sync, pull, target remove, diff, and doctor commands
2026-01-31 16:50:39 +08:00