Commit Graph
41 Commits
Author SHA1 Message Date
Willie 9a7271c1ae fix: address PR #151 review feedback
- Project mode JSON sync now includes context_cost (was nil)
- Server handler respects symlink mode (skips include/exclude filters)
- checkBudget reports all targets exceeding threshold (not just worst)
- Budget warnings include target name in CLI and UI output
- ConfigPage indentation restored to original 2-space style
2026-05-11 21:34:38 +08:00
Willie 9510476c45 feat(server): include context_cost in sync API response
Self-contained token estimation (chars/4) since buildAnalyzeEntries
is in main package. Returns grouped counts and budget violations.
2026-05-11 21:34:38 +08:00
Willie 3c4d057950 refactor(ui): centralize display name formatting via resourceNames utilities
Replace 25+ inline .replace(/__/g, '/') calls with shared utilities:
- formatSkillDisplayName() for flat name → path conversion
- formatTrackedRepoName() for tracked repo name display (strip _ + unflatten)
- formatAgentDisplayName() for agent names (.md removal + unflatten)

Consolidate error toasts into single summary in DashboardPage update-all.
Remove duplicate displayPath() in BatchUninstallPage (was reimplementing
formatSkillDisplayName).

Backend: refactor agentIgnorePayload to accept pre-discovered agents,
eliminating duplicate filesystem traversal in sync/diff handlers.
2026-04-10 02:25:27 +08:00
Willie 92d5fc66ba fix(agents): exclude convention files and respect agents/ subdir in tracked repos
Agent discovery was treating non-agent files (CLAUDE.md, AGENTS.md, etc.)
as agent resources when they appeared in tracked repos.

Two fixes:
- Expand ConventionalExcludes with 7 well-known convention filenames
  (CLAUDE.md, AGENTS.md, GEMINI.md, COPILOT.md, CONTRIBUTING.md,
  CODE_OF_CONDUCT.md, SUPPORT.md)
- For tracked repos with an agents/ subdirectory, only discover files
  inside agents/ — skip repo root files and other subdirs (docs/, etc.)

Also includes UI polish:
- Display flat names (__ separator) as path separators in toasts/labels
- Consolidate batch install errors into single toast
- Show .agentignore state in sync diff/preview responses
- Track badge + friendly repo name in resource list/folder tree
2026-04-10 02:14:15 +08:00
Willie da000c4d07 feat(server): agent tracked repo install, prune-on-empty, audit guards
- appendAgentDiffs helper deduplicates diff/stream agent logic
- handler_agent_diff: skip local copies, junction-aware checks
- handler_sync: prune orphan agents even when source is empty
- handler_install: tracked agent repo auto-detection and routing
- handler_skills: expose RepoRelPath and Targets for agents
- handler_skills_batch: agent target assignment via frontmatter
- handler_sync_matrix: pass agent Targets to ClassifySkillForTarget
- handler_update: tracked agent repo git pull update
- handler_audit: guard empty/missing source dirs gracefully
- Tests for all of the above
2026-04-10 02:05:13 +08:00
Willie a73d55dc26 refactor: extract agent helpers and simplify duplicated patterns
- Extract agent_helpers.go: kind constants, discoverActiveAgents(),
  resolveAgentPath(), builtinAgentTargets(), mergeAgentDiffItems()
- Replace 3 inline agent path resolution blocks with resolveAgentPath()
- Replace 3 inline agent discovery blocks with discoverActiveAgents()
- Replace 2 inline diff merge blocks with mergeAgentDiffItems()
- Fix handleSync prune triple-scan: capture index from merge pass
- Frontend: replace 10 filter() calls with single useMemo reduce pass
- Use kind constants instead of raw strings across all server files
2026-04-10 00:02:53 +08:00
Willie 568d2b7f64 fix: address code review findings
- Fix data race: read agentsSource inside RLock in handleDiffStream
- Validate kind param in handleSync (reject invalid values)
- Add test for symlink-points-elsewhere agent diff case
- Always show KindBadge on DiffItemRow (default to 'skill')
2026-04-09 23:50:42 +08:00
Willie d1ac3dd649 feat(server): support kind param in POST /api/sync
Accept 'kind' field in sync request body:
- 'skill': sync skills only (current behavior)
- 'agent': sync agents only via SyncAgents()
- '' (empty): sync both skills and agents

Agent sync uses existing SyncAgents/PruneOrphanAgentLinks/PruneOrphanAgentCopies.
Remove agent-exists-but-no-target warning (now obsolete).
2026-04-09 23:41:16 +08:00
Willie 55e2e0e5b3 feat(server): include agent diffs in handleDiff and handleDiffStream
- Discover agents from agentsSource() and compute per-target diffs
- Merge agent diff items into existing target results
- Set Kind='skill' on all existing skill diff items
- Set Kind='agent' on all agent diff items
- Targets without agentPath are skipped (matches CLI behavior)
2026-04-09 23:38:37 +08:00
Willie ca73b40e0f feat: warn when agents installed/synced but no targets support agents
Add Config.HasAgentTarget() helper that checks if any configured target
has an agents path set.

handler_install: append warning to install summary when agents are
installed but no targets support them.

handler_sync: after sync completes, check if agents exist in source
but no targets have agent paths — add warning to response.
2026-04-07 18:05:40 +08:00
Willie c176d89405 feat(api): add kind field to sync, audit, check, update, and install handlers
handler_sync: add Kind field to diff stream item struct.
handler_audit: add Kind field to audit stream result.
handler_check: add Kind field to check stream result.
handler_update: add Kind field to update stream result.
handler_install: add Kind field to install request for agent support.
2026-04-07 18:05:40 +08:00
Willie 465db305ca feat(sync): pass projectRoot from project-mode callers
Project-mode sync now passes the project root directory through to
createLink, enabling relative symlinks for all paths under the project.
Server handlers use s.projectRoot for project-mode dashboards.

Ref: #120
2026-04-07 17:26:37 +08:00
Willie 3c8c56002d feat(sync): wire projectRoot through merge and symlink sync paths
SyncTargetMerge, SyncTargetMergeWithSkills, CreateSymlink, and SyncTarget
now accept projectRoot. When non-empty, createLink uses relative symlinks
for paths under the project root.

All existing callers pass empty string (global mode, no behavior change).

Ref: #120
2026-04-07 17:26:37 +08:00
Willie e82d18cfa4 fix: sync must not prune registry entries for installed skills
Sync's registry prune logic removed entries for installed skills whose
files were missing from disk. This was wrong: the registry is the
authoritative record of installations managed by install/uninstall.

Remove PruneStaleSkills calls from sync (CLI global, CLI project, and
web UI handler). Reconcile (called during install) still uses prune
with full metadata context, which is correct.

Fixes: running 'sync' after 'install' would clear registry.yaml when
the installed skill's source files were not yet on disk.
2026-04-06 17:28:10 +08:00
Willie a570670a92 fix: registry cleanup after uninstall and sync, UI polish
- Fix UI batch uninstall not removing nested skill registry entries:
  handler used flat names (__) but registry stores path names (/),
  now tracks exact RelPath from discovered skills for matching

- Add stale entry pruning to ReconcileGlobalSkills and
  ReconcileProjectSkills using a live set built during disk walk,
  so skills deleted from source are removed from registry

- Trigger registry reconcile after sync in both UI handler (via defer
  for early-return safety) and CLI (global + project mode), writing
  warnings to stderr to avoid corrupting --json output

- UI: fix BatchUninstallPage search treating plain text as exact-match
  glob (now substring search when no * or ? present), display nested
  skill paths with / instead of __ in confirm and result dialogs

- UI: hide redundant 'X repo(s) and Y skill(s) already up to date'
  line on UpdatePage when everything is already current

- Fix test isolation: set XDG_CONFIG_HOME in server test helpers to
  prevent host agents dir leaking into test results, skip chmod-based
  oplog test when running as root

- Add README badge for Awesome Codex CLI
2026-04-01 22:30:39 +08:00
Willie 6f70e76758 fix(sync): accurate expectedSkillCount and surface skipped skills
Problem: Sync page showed 'in sync' but Targets page showed
39032/64075 — ~25000 skills silently dropped by name collisions
and SKILL.md validation in standard naming mode.

Root cause: expectedSkillCount used raw filtered count (pre-resolution)
while diff used post-resolution count. The gap was invisible.

Fix:
1. handler_targets.go: expectedSkillCount now uses resolution.Skills
   count (post-collision/validation), matching what sync actually does
2. handler_diff_stream.go: surfaces skippedCount and collisionCount
   in diff response so UI can explain why skills were dropped
3. handler_sync.go: diffTarget struct gains SkippedCount/CollisionCount
4. TargetsPage: shows warning when skills are skipped with collision count
5. SyncPage: shows naming conflict notice in 'in sync' cards
6. API client: Target and DiffTarget types gain optional fields
2026-04-01 00:32:49 +08:00
Willie ccdafd3293 feat(sync): add target_naming config option (flat/standard)
Add per-target target_naming setting that controls how skill directories
are named in sync targets. 'flat' (default) preserves the existing
flattened __ separator behavior. 'standard' uses the SKILL.md name field
directly, following the Agent Skills specification.

Standard mode:
- Validates SKILL.md names match directory basenames
- Detects and skips name collisions with warnings
- Auto-migrates managed entries when switching from flat to standard
- Preserves legacy entries when bare name is already occupied

Also includes:
- Per-target toggle via CLI (--target-naming), TUI (N key), and Web UI
- Collision output redesigned as deduplicated compact summary
- Config inheritance: global target_naming → per-target override
- JSON schema + UI validation for the new field

Closes #110
2026-04-01 00:32:49 +08:00
Willie 41dd81b7f2 refactor: migrate all callers to SkillsConfig() / EnsureSkills()
44 files across CLI commands, sync engine, and server handlers now use
SkillsConfig() for reads and EnsureSkills() for writes instead of
accessing flat TargetConfig fields directly.

Key changes:
- sync engine (SyncTargetMerge/Copy/Symlink): reads sc := target.SkillsConfig()
- target commands: filter add/remove and mode set use EnsureSkills()
- target TUI: mode picker, filter ops, detail panel all via SkillsConfig()
- server handlers: backup, restore, targets, sync, diff, collect, analyze
- init/init_project: new target creation uses Skills sub-key
- doctor, status, diff: target display reads from SkillsConfig()
- computeTargetDiff: accepts config.TargetConfig directly (was anon struct)
2026-03-29 04:59:23 +08:00
Willie 643e3c5c07 fix: auto-create missing target directories with notification (#87)
v0.17.5 blocked sync when target directories didn't exist, which
prevented first-time users on fresh CLI installs from syncing.

Sync now auto-creates missing directories and reports what it did
in CLI output, dry-run preview, and the Web UI. Init also creates
target directories when it detects an installed CLI tool.

Web UI: Sync Preview modal stays open after sync with a success
banner instead of immediately closing, so users can review results.

Closes #87
2026-03-19 03:57:08 +08:00
Willie 92603f5be6 feat: add config save validation and sync safety checks
Validate config semantics (source path, sync modes, target paths) at
save time (API + CLI) instead of failing at sync time with cryptic
errors. Sync no longer auto-creates missing target directories — fails
fast to catch typos like ~/.cusor/skills. Dry-run also validates paths.

- ValidateConfig / ValidateProjectConfig with warnings + errors
- handlePutConfig returns 400 for invalid configs, 200 + warnings
- handleSync pre-checks via ValidateConfig
- ensureRealTargetDir shared helper (replaces duplicated blocks)
- UI: warning toast on config save, warning banners on sync/preview
- Dashboard shows full absolute source path
2026-03-18 22:35:02 +08:00
Willie 4d2d540127 refactor: simplify ignore payload and deduplicate formatting
- Remove dead nil check in ignorePayload() (repoFiles already initialized)
- Replace manual map merge loops with maps.Copy in 3 handler sites
- Deduplicate fmt.Sprintf + ui.Success in doctor checkSkillignore
- Extract extractIgnoreSources() helper in SyncPage to DRY two identical
  state-setting blocks
2026-03-18 00:19:30 +08:00
Willie cc68453eb1 feat(sync): pass .skillignore source files in API for accurate UI hints
Add ignore_root and ignore_repos fields to sync/diff/diff-stream API
responses from IgnoreStats. UI now uses real file paths instead of
heuristic (skill name starts with _) to determine ignore source.
2026-03-18 00:19:30 +08:00
Willie 8c7b93eec9 feat(server): include ignored skills in sync and diff API responses
Switch from DiscoverSourceSkills to DiscoverSourceSkillsWithStats so
the sync, diff, and diff-stream endpoints can surface .skillignore
stats (ignored_count, ignored_skills) in their JSON responses.
2026-03-18 00:19:30 +08:00
Willie 5307b3276e fix(server): use snapshot pattern to eliminate map races and narrow lock scope
Addresses P1 and P2 from code review on the RWMutex commit:

P1 — Stream handlers now snapshot config under RLock before streaming:
- handleDiffStream: clone Targets map to prevent concurrent map panic
- handleCheckStream, handleAuditStream: snapshot source/projectRoot
- handleUpdateStream: snapshot source (per-item Lock already correct)

P2 — All read handlers now use narrow snapshot instead of defer RUnlock:
- RLock → copy needed fields to locals → RUnlock → do work with locals
- Prevents slow I/O (git fetch, version check, audit scan) from blocking
  the auto-reload middleware's exclusive Lock on concurrent requests

Other changes:
- computeTargetDiff takes source parameter (no more s.cfg.Source access)
- Add cloneTargets() helper for safe map copying
- Add writeOpsLogTo/writeAuditLogTo for lock-free oplog writes
2026-03-17 04:48:42 +08:00
Willie 11f696cffe fix(server): upgrade Mutex to RWMutex for concurrent read safety
Addresses PR #82 review: read-only handlers accessed s.cfg without
synchronization, risking data races with concurrent config reloads.

- Upgrade sync.Mutex → sync.RWMutex (drop-in compatible)
- Add RLock to 26 non-streaming read handlers
- Keep exclusive Lock for write handlers (unchanged)
- Skip SSE streaming handlers to avoid blocking writes during streams
- Fix isConfigGitignored to propagate GitignoreContains errors
2026-03-17 04:48:42 +08:00
Willie 344b067806 feat(ui): add SSE streaming for update, check, and diff pages
Replace sequential POST loops and blocking useQuery calls with
Server-Sent Events for real-time progress feedback on Update, Check,
and Diff operations. Extract shared helpers to reduce duplication:

- initSSE() in middleware.go consolidates SSE preamble across 4 handlers
- createSSEStream() in client.ts unifies EventSource lifecycle management
- StreamProgressBar component replaces 3 near-identical progress bars
- handleDiff now delegates to computeTargetDiff (eliminates ~150 lines)
- Paginate audit results (20 cards + 10 findings per card) to prevent
  DOM overload with large skill counts
2026-03-05 02:13:21 +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 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 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 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 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 bd75ef8939 feat: support target include/exclude filters across sync, UI, and docs 2026-02-14 00:21:48 +08:00
Willie e5813cc7e0 feat: add oplog instrumentation to all API handlers, improve audit/log/sync CLI
- Add oplog write helpers to server (oplog_helper.go) and instrument
  all handler_*.go endpoints with ops/audit logging
- Improve audit CLI with structured auditRunSummary and severity counts
- Enhance log CLI with richer filtering and detail display
- Improve sync CLI with drift detection summaries in oplog
- Reorder web UI sidebar nav by user workflow (core → acquire → distribute → maintain → monitor)
- Enhance LogPage with better formatting and filtering
- Add server oplog unit tests (logging_test.go, log_test.go)
- Update docs for log command and quick-reference
2026-02-10 03:50:03 +08:00
Willie 5a65993304 feat: add operation log — JSONL-based persistent audit trail for CLI, API, and web UI
Add oplog package (internal/oplog) that records every mutating command
(install, uninstall, sync, push, pull, collect, backup, restore, update,
audit) as a JSONL entry with timestamp, status, duration, and args.

- CLI: `skillshare log` with --audit, --tail, --clear, --project flags
- API: GET/DELETE /api/log endpoints with type and limit params
- Web UI: LogPage with ops/audit tabs, table view, clear and refresh
- Instrumentation across 12 command handlers (CLI + server)
2026-02-10 02:56:59 +08:00
Willie 6185849328 fix: handle Windows junctions in sync and diff 2026-02-08 15:14:16 +08:00
Willie 092fb14f8a feat: add web dashboard with embedded React SPA (skillshare ui)
Single-binary web UI for visual skill management — React 19 + Vite
frontend embedded via go:embed, Go net/http REST API backend (30+
endpoints). Includes dashboard, skills browser, targets, sync, collect,
search, install, config editor, backup/restore, and git sync pages.

Also adds Bitbucket/GitLab URL parsing for install, git operations
library, skill version checking, CI frontend build steps, Docker
sandbox support, and website docs for the ui command.
2026-02-08 05:08:30 +08:00