Commit Graph
37 Commits
Author SHA1 Message Date
Willie 1b8940a630 fix(extras): copy-mode idempotency and display mode label
- Add contentEqual() byte comparison for copy-mode idempotency check:
  re-running sync extras no longer marks identical copies as conflicts
- Restore mode default in CLI handler so display shows "(merge)"
  instead of "()" for targets with no explicit mode
2026-03-04 12:16:32 +08:00
Willie 55bc5289c6 refactor(extras): simplify after code review
- Fix bug: pass `rest` (not `args`) to cmdSyncExtras in --all path
- Return error from cmdSyncExtras when totalErrors > 0
- Remove empty if-block dead code in syncOneExtraFile
- Remove redundant mode default (SyncExtra already defaults to merge)
- Consolidate capitalize/capitalizeFirst into single Unicode-safe helper
- Remove trivial copyExtraFile wrapper, call copyFile directly
- Warn when --all is used in project mode (extras are global only)
- Cache os.UserHomeDir() at package level for shortenPath
- Use source file set instead of per-file os.Stat in pruneExtraOrphans
2026-03-04 12:16:32 +08:00
Willie 65c7d75c41 style: fix gofmt alignment in extras_test.go and ui.go 2026-03-04 12:16:32 +08:00
Willie fbccdb9628 feat(sync): add extras sync engine — walk, symlink/copy, prune 2026-03-04 12:16:32 +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 c426a801d7 fix(sync): preserve external symlinks during sync (dotfiles manager support)
When source or target directories are symlinks managed by external tools
(e.g., dotfiles managers), sync would incorrectly delete them during
mode conversion. This change:

- Add resolveWalkRoot() so filepath.Walk follows symlinked source dirs
- Add isSymlinkToSource() with canonicalization to distinguish internal
  symlink-mode targets from external symlinks (alias-safe)
- Protect external target symlinks in both merge and copy mode
- Allow FindLocalSkills to scan through external symlinked targets
- Handle external symlinks in CheckStatusMerge as normal directories
2026-03-02 10:05:57 +08:00
Willie d1370c0f98 fix(sync): preserve external symlinks in merge/copy mode conversions
When a target directory is an external symlink (e.g., dotfiles manager
pointing ~/.claude/skills/ elsewhere), sync previously deleted it
unconditionally during symlink→merge/copy mode conversion. This also
affected DiscoverSourceSkills which failed to traverse symlinked source
directories because filepath.Walk uses Lstat on root.

Changes:
- Add resolveWalkRoot() helper; use in both Discover functions so
  filepath.Walk enters symlinked source directories
- Add isSymlinkToSource() to distinguish source-pointing symlinks
  (symlink mode residue, safe to remove) from external symlinks
- Pass explicit sourcePath to SyncTargetMergeWithSkills and
  SyncTargetCopyWithSkills for reliable symlink origin detection
- Fix FindLocalSkills to use utils.ResolveLinkTarget (handles relative
  symlinks correctly) and follow external symlinks for scanning
- Fix CheckStatusMerge to follow external symlinks instead of returning
  StatusConflict
- Add 17 unit tests and 6 integration tests covering symlinked source,
  target, both, chained symlinks, idempotency, prune, and pull
2026-03-02 10:05:57 +08:00
Willie 6a5d2eaa98 perf(collect): remove eager calculateDirSize from FindLocalSkills
Size was computed by walking every file in every local skill directory
during the scan phase, before the user even confirms. CLI never displays
the size. Move to lazy on-demand calculation in the Web UI handler only.
2026-02-28 03:44:02 +08:00
Willie f29b4ac1b8 fix(sync): dereference directory symlinks in copy mode and update changelog
Copy mode now resolves directory symlinks to concrete directories,
preventing broken symlinks in targets that use file copying (e.g.,
Windsurf). DirChecksum follows symlinks for consistent hash comparison.
DirMaxMtime disables mtime fast-path for symlink-containing skills to
avoid stale cache hits. Cycle detection prevents infinite recursion.

Also updates CHANGELOG v0.16.3 with previously missing entries:
hub risk badge colors, batch failure output, repo-grouped cloning.
2026-02-27 05:39:49 +08:00
Willie 2b7ff5fa18 style: fix whitespace alignment in list_tui, log_tui, manifest 2026-02-26 22:27:23 +08:00
Willie 179d02ba0d perf(sync): mtime fast-path for copy mode + diff UX improvements
Copy mode previously computed DirChecksum (Walk + ReadFile + SHA256)
for every skill on every sync, even when nothing changed. Add mtime-
based short-circuit: if source dir max mtime matches the manifest
record, skip checksum entirely.

Changes:
- Add DirMaxMtime() — Walk + lstat only, no file reads
- Extend Manifest with Mtimes map (omitempty, backward-compatible)
- SyncTargetCopyWithSkills: mtime fast-path with target validity check
- diff: two-phase scan-then-display with spinner (no more interleaved
  spinner + diff output), discovery spinner for both global/project
- Clearer diff reasons: "missing" → "source only",
  "missing (deleted from target)" → "deleted from target"
- Server handleDiff: same mtime fast-path for copy mode
- Prune cleans up orphan mtime entries
2026-02-26 22:27:23 +08:00
Willie 2f6dd42695 perf(sync): cache discovery + add progress UI for sync operations
DiscoverSourceSkills was called 1+2N times (N = number of targets),
each doing a full filepath.Walk + SKILL.md frontmatter parsing.
Now discovered once and passed to all targets via WithSkills variants.

Changes:
- Add SyncTargetMergeWithSkills, PruneOrphanLinksWithSkills (PruneOptions struct)
- Add SyncTargetCopyWithSkills with onProgress callback, PruneOrphanCopiesWithSkills
- Discovery spinner + per-target reporting + summary line in CLI
- Copy mode shows per-skill spinner progress during slow checksum+copy
- Collision report uses dim gray text to avoid confusion with sync results
- Server handlers (handleSync, handlePull) use single discovery pass
- Fix pre-existing TestLog_StatsOutput assertion ("Success rate" → "OK:")
2026-02-26 22:27:23 +08:00
Willie 7079a705f3 feat(sync): add DiscoverSourceSkillsLite and ParseFrontmatterFields
DiscoverSourceSkillsLite skips frontmatter parsing during directory
walk and collects tracked repos in a single pass — significantly
faster for large skill collections.

ParseFrontmatterFields extracts specific YAML fields from SKILL.md
without parsing the full document, used by the TUI detail panel.
2026-02-25 19:39:28 +08:00
Willie a05d3448f2 fix(sync): match targets by shared path and track local dirs in prune
MatchesTargetName now falls back to path comparison when name-based
matching fails, so targets sharing the same project_path (e.g. codex
and universal both using .agents/skills) correctly match in
FilterSkillsByTarget.

PruneOrphanLinks records user-created directories in LocalDirs instead
of emitting misleading "unknown directory" warnings, and syncMergeMode
counts them toward the local skill total.
2026-02-25 07:02:54 +08:00
Willie 3721d69b54 fix: prune orphaned real directories in merge mode via manifest (#45)
- Extend .skillshare-manifest.json tracking from copy mode to merge mode.
- Update PruneOrphanLinks to prioritize manifest records over naming patterns.
- Ensure SyncTargetMerge writes to manifest for all linked/updated skills.
- Add integration tests for uninstall + sync orphan directory cleanup.
- Maintain backward compatibility for targets without existing manifests.
2026-02-24 01:47:38 +08:00
Willie a8fb965b8b test: add unit tests for sync, install, and server packages
Boost unit test coverage across three core packages:
- internal/sync: 11.6% → 54.6% (discovery, status, checksum, manifest, pull, merge/prune)
- internal/install: 40.7% → 60.0% (meta, ignore, copy, updatable, local install, options, gitignore, source)
- internal/server: 15.1% → 40.0% (health, overview, skills, targets, config, log, trash, sync, collect, check, backup, diff, audit, hub)
2026-02-23 04:18:01 +08:00
Willie 5b25fa6845 fix(sync): propagate errors in DirChecksum instead of swallowing them
Unreadable files or unresolvable paths now cause DirChecksum to return
an error rather than silently producing an incomplete checksum.

Ref: PR #33 review (gemini-code-assist)
2026-02-21 06:07:35 +08:00
Willie d7d4804312 fix(sync): handle non-directory entries in copy mode
- SyncTargetCopy replaces non-directory managed entries with proper
  skill directories; skips local non-directory entries unless --force
- CheckStatusCopy only counts managed entries that are actual
  directories on disk
- diff and server diff handlers report "target entry is not a
  directory" for both managed and unmanaged non-directory entries
- Add tests for non-directory edge cases in sync, diff, and target info
2026-02-21 06:07:35 +08:00
Willie eb6b4cb650 fix(sync): verify target directory exists before trusting manifest
- P1: diff now checks target skill directory exists before comparing
  checksums; deleted directories are reported as "missing" instead of
  being silently treated as synced
- P2: CheckStatusCopy counts only managed entries that exist on disk,
  so target info shows accurate managed count
- Add tests for deleted target dir detection and manifest/disk mismatch
2026-02-21 06:07:35 +08:00
Willie 854b90e1b0 fix(sync): fix copy mode diff, target info, and project remove bugs
- P1: diff now compares checksums to detect content drift in copy mode
- P2: diff routes on config mode instead of manifest presence
- P2: project target remove cleans up manifest file
- P3: target info uses mode-appropriate status check (copy/merge/symlink)
- Export DirChecksum for use by diff and server handlers
- Add 4 integration tests covering all fixed scenarios
2026-02-21 06:07:35 +08:00
Willie 3b721ee3e2 feat(sync): add copy mode for AI CLIs that can't follow symlinks
Add a third sync mode (`copy`) that copies skills as real files instead
of symlinks, with a `.skillshare-manifest.json` tracking managed skills
and SHA256 checksums for incremental updates.

- Manifest-based tracking: skip unchanged, update modified, --force all
- Pruning: remove managed copies no longer in source
- Mode conversion: bidirectional merge↔copy and symlink↔copy
- Full command support: sync, status, doctor, diff, target, collect
- Server API + Web UI: targets list, drift detection, filter editing
- include/exclude filters work in both merge and copy modes
- 12 integration tests covering all acceptance criteria
- Documentation updated across 13 pages

Closes #31
2026-02-21 06:07:35 +08:00
Willie 76e1f6e3a9 fix: prune broken external symlinks after data migration (#28)
After data migration (e.g. XDG path change), target symlinks still
point to old source path. PruneOrphanLinks treated these as "external"
and always preserved them, even with --force.

- Auto-remove broken external symlinks (target no longer exists)
- Pass force flag to PruneOrphanLinks; force removes valid external symlinks
- Use utils.PathHasPrefix for Windows case-insensitive path comparison
2026-02-16 15:23:03 +08:00
Willie 403aafb254 feat: unify project target names with global names, add aliases for backward compat
Project targets now use the same short names as global targets (e.g.,
"claude" instead of "claude-code"). Old project_name values are preserved
as aliases so existing configs continue to work.

- Add Aliases field to targetSpec (deprecated, remove once safe)
- Update 11 targets in targets.yaml: project_name = global_name
- LookupProjectTarget falls back to alias lookup
- Fix 3 callers that bypassed LookupProjectTarget
- Extend MatchesTargetName and KnownTargetNames with alias support
- Add TestLookupProjectTarget_Alias
- Update all integration tests, docs, CLI help, and FAQ
2026-02-16 00:08:59 +08:00
Willie a29e198725 feat: add target filter CLI, skill-level targets field, and Web UI support
- CLI: `target <name> --add-include/--add-exclude/--remove-include/--remove-exclude`
- SKILL.md `targets` frontmatter restricts sync to specified targets
- Cross-mode matching (e.g. "claude" matches "claude-code" project target)
- Web UI: inline filter editor on Targets page, target badges on Skills pages
- API: PATCH /api/targets/{name} for filter updates
- Fix drift detection in doctor/status/handler to account for skill-level targets
- `check` warns about unknown target names in skill-level targets field
- Docs: update skill-format, target command, configuration, creating-skills
2026-02-15 23:29:30 +08:00
Willie 43d12b11c1 feat: per-target collision detection with filter-aware reporting
Collision checks previously ran on all skills before target filters,
producing false positive warnings when users route same-named skills
to different targets via include/exclude. Now collision detection
runs per-target after filtering, downgrading to info when filters
correctly isolate duplicates.

- Add CheckNameCollisionsForTargets() to internal/sync
- Replace collision blocks in sync.go and sync_project.go
- Show human-readable filter summary per merge target
- Add unit tests (5 cases) and integration test
- Update docs with new two-tier collision output examples
2026-02-14 18:35:21 +08:00
Willie bd75ef8939 feat: support target include/exclude filters across sync, UI, and docs 2026-02-14 00:21:48 +08:00
Willie f2017a35aa feat: fix tracked repo discovery, improve naming, and unify project list
Sync discovery (DiscoverSourceSkills) was skipping all hidden directories
via utils.IsHidden(), causing skills inside .curated/ and .system/ (like
openai/skills) to be invisible after install. Now only .git is skipped,
matching the install-time discovery that was already fixed in 8ec5306.

Tracked repo naming now uses owner-repo format (e.g., _openai-skills
instead of _skills) via new Source.TrackName() method, preventing
collisions between repos that share the same basename.

Project-mode `list` command now uses recursive DiscoverSourceSkills()
instead of shallow os.ReadDir(), aligning with global list and web UI
behavior so tracked repo skills are visible everywhere.

Also includes CHANGELOG for v0.11.0, README updates, docs improvements,
and minor UI nav reorder.
2026-02-10 03:13:21 +08:00
Willie 6185849328 fix: handle Windows junctions in sync and diff 2026-02-08 15:14:16 +08:00
Willie 32014986ec fix(diff,sync): improve diff clarity and fix sync --force for merge mode
diff improvements:
- Use sync.DiscoverSourceSkills for proper tracked repo handling
- Remove "Diff:" prefix, show target name directly
- Clearer descriptions: "missing", "local copy (sync --force to replace)", "local only"
- Add action hints explaining what sync/pull commands will do

sync --force fix:
- Now properly replaces local copies with symlinks in merge mode
- Previously --force only worked for symlink mode conflicts

help improvements:
- Add GIT REMOTE section grouping push and pull --remote together
- Remove logo from status command (high-frequency operation)

docs: update sync.md with new diff output format and symbols table
2026-01-31 20:22:51 +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
Willie Hung a869838c2b feat(windows): use junction instead of symlink, show git progress
Windows symlinks require admin or Developer Mode. This commit:
- Add platform-specific link creation (junction on Windows, symlink on Unix)
- Show git clone progress instead of quiet mode for better UX
- Update doctor to test link support using the new createLink function
2026-01-31 01:18:14 +08:00
Willie Hung fd4387460a feat: Team Edition - tracked repos, nested skills, collision detection
## New Features
- Tracked repositories: `install --track` to clone team skill repos
- Nested skills: organize in folders, auto-flatten on sync (work/api → work__api)
- Name collision detection: warns when multiple skills share same SKILL.md name
- Auto-pruning: orphaned symlinks cleaned on sync
- Custom naming: `--name` flag for tracked repos

## Changes
- Require target path to exist when adding targets
- Add sync reminder after adding target
- Improve pruning messages (broken vs orphan symlinks)
- Add `{team}:{name}` naming convention recommendation

## Files
- New: update.go, gitignore.go, frontmatter.go
- Updated: sync.go, install.go, uninstall.go, validate.go
- Docs: README.md, SKILL.md
2026-01-20 01:56:07 +08:00
Willie Hung 0a410234fd feat: add skill installer and expand dry-run previews 2026-01-15 23:15:38 +08:00
Willie f5e9d9644e docs: improve README with better structure and content
- Add badges (License, Go version, Release)
- Add ASCII flow diagram showing architecture
- Add Table of Contents for navigation
- Add "Why skillshare?" comparison table
- Add Use Cases section (Individual, Team, Open Source)
- Add FAQ section with common questions
- Add Contributing guide with development setup
- Reorganize sections for better readability
2026-01-14 22:12:56 +08:00
Willie 95ca07be89 feat: add target info/mode commands, show mode in status/doctor
- Add `skillshare target <name>` to show target details
- Add `skillshare target <name> --mode <mode>` to change target mode
- Show sync mode [merge/symlink] in status and doctor output
- Show warning when configured mode doesn't match actual state
- Fix sync to properly convert between symlink and merge modes
- Simplify module name to `skillshare`
- Remove go install option from README (incompatible with simplified module)
2026-01-14 20:43:00 +08:00
Willie 75c0e4bead feat: add merge mode, make it default
- merge mode: symlink individual skills, preserve local skills
- symlink mode: entire directory becomes symlink
- safer default that won't move existing skills
2026-01-14 20:06:14 +08:00
Willie b3b7bcf0fc feat: initial release of skillshare
Share skills across AI CLI tools (Claude Code, Codex, Cursor, Gemini, OpenCode)
with a single source directory and symlinks.

Commands:
- init: Initialize with source directory, auto-detect CLI tools
- sync: Migrate existing skills and create symlinks
- status: Show target status
- target: Manage targets (add/remove/list)
2026-01-14 18:09:36 +08:00