Commit Graph
23 Commits
Author SHA1 Message Date
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 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 5e02ef7ef0 refactor(sync): select a target's skills through SelectTargetSkills
Status, doctor, diff, the dashboard's target and diff handlers and analyze each
repeated FilterSkills followed by FilterSkillsByTarget, and only some dropped
disabled skills first. Routing them through SelectTargetSkills keeps their
answers identical to sync and mcp serve when a selection rule changes.

The callers that did not drop disabled skills get discoveries without them, so
their output does not change.
2026-10-06 14:18:20 +08:00
Willie 89fc4fbdf1 feat(sourcewalk): follow first-level source links when enabled
Users link a checkout directly under the skills source (e.g.
skills/_dev-skills -> ~/code/dev-skills) and expect it to behave like any
other first-level entry. sourcewalk resolved only the root, so these links
were invisible to discovery, sync, update, and the dashboard.

follow_source_links (global and project config, default false) enables a
per-operation sourcewalk.Follow policy. Walk, WalkDir, and ReadDir report a
followed link under its own name as a directory and descend into its
target, so names, RelPath, FlatName, SourcePath, tracked-repo detection, and
metadata keys stay logical. Only entries directly under the source root are
followed. The policy is built from config and passed explicitly to every
discovery caller in the CLI, server, and reconcile, so counts agree; the
server keeps a per-instance snapshot refreshed on config load and save
instead of a process-global flag.

A link is skipped, with one warning per operation, when its target is
missing or unreadable, is the source or a parent of it, or overlaps an
active skills target. A missing or unreadable target marks the operation
incomplete: sync then skips pruning and copy-orphan deletion, and reconcile
keeps metadata, so an unmounted drive or a re-clone in progress cannot
erase target entries or install records. A link to an existing file is not
a directory link and stays an ordinary entry; treating it as incomplete
would disable pruning for anyone sharing a file such as .skillignore.

doctor keeps raw link identity: with the key off it still says the link is
not followed and names follow_source_links: true; with it on it reports
followed links and skipped links with the reason.

The raw-walk allowlist gains entries for the policy path in Walk and
WalkDir: the source root walk with a policy, and the walk of a validated
link target whose paths are remapped to the logical link path. Both live
in sourcewalk itself, the package that owns source traversal.

Refs #274
2026-10-05 14:26:09 +08:00
Willie 46b23cd2ad feat(targets): let a target keep its instructions with skills switched off
Some tools only need skillshare for AGENTS.md, MCP or agents, while their
skills folder is managed elsewhere or shared through another target.
Syncing skills into those folders duplicated what the tool already reads,
so a target can now turn skills off (`target <name> --no-skills`, the
dashboard switch) and sync, diff, status and doctor skip its skills.
Switching off warns about the other tools that read the same folder.

The target list also gains tools that were missing, with colored vendor
logos where their licenses allow it, and zencoder/replit default paths
follow their current documentation.

The dashboard's target pages get the matching UI: universal is pinned as
the shared folder when adding a target, the add dialog lists what will be
written, and the AGENTS.md tab shows where the file comes from in one card
with an in-place switch between shared files.
2026-09-29 04:51:24 +08:00
Willie 45854c5b57 fix(sync): count manifest-managed hidden entries in target scans
Flat target naming turns a source skill under a dot directory
(e.g. .system/example) into a hidden target entry (.system__example).
Target scans skipped every hidden name, so diff, doctor, status and the
dashboard reported these synced skills as missing, and prune never
removed them after the source skill was deleted.

Hidden entries are now skipped only when the target manifest does not
record them as managed, so files like .skillshare-manifest.json or
.DS_Store are still ignored.

Refs #294
2026-09-25 22:26:51 +08:00
Willie 3743a1ef3f fix(sync): honor file ignore patterns in copy mode
Apply config ignore patterns to copy-mode file traversal, checksum, mtime, CLI diff, and server sync/diff paths.

Add default ignores for .DS_Store, .git, and __pycache__ in global and project init configs.

Tests: go test ./... -count=1
2026-06-29 10:30:11 +08:00
Willie 996d00e342 feat(config): migrate consumers to Effective*Source helpers (Phase 3+5)
Make the v0.19.16 sources map actually do something: route all path
reads through Config.EffectiveSkillsSource() / EffectiveAgentsSource() /
EffectiveExtrasSource() so users who set sources.skills / sources.agents /
sources.extras get the configured paths everywhere.

Mechanical changes (~50 files):
- cmd/skillshare/**: replace cfg.Source / cfg.ExtrasSource reads with
  cfg.EffectiveSkillsSource() / cfg.EffectiveExtrasSource()
- internal/server/**: replace s.cfg.Source / s.cfg.ExtrasSource reads
  with the same helpers; server.skillsSource() / gitignoreDir() use the
  global-mode helper
- internal/config/config_validate.go: validate using EffectiveSkillsSource
  while still rejecting configs that set neither field explicitly
- internal/config/reconcile.go, registry.go: read via helpers

Behavioral fixes (paired with the migration):
- extras init / extras source / POST /api/extras no longer silently
  backfill the legacy extras_source field — the runtime fallback inside
  EffectiveExtrasSource() handles it. This stops surprise diffs in users'
  config.yaml after running extras commands.
- extras source command writes back to whichever field the user already
  configured (sources.extras if set, otherwise legacy extras_source) so
  the update is not shadowed.
- source_type in /api/extras and extras list correctly reports "default"
  vs "extras_source" by inspecting the raw (unresolved) configured value;
  sources.extras counts as configured for this purpose.

UI:
- ui/src/lib/fieldDocs.ts: neutralize sources / sources.* descriptions
  so they describe both project and global modes (Phase 5).

Preserved (intentional):
- Direct writes to cfg.Source / cfg.AgentsSource / cfg.ExtrasSource in
  init, migrate.go, cloneForSave, and server.reloadConfig — these are
  raw-field writes, not path reads.
- Updated test expectations for the removed backfills.
2026-05-21 14:49:11 +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 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 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 1016a155db fix(diff): filter out skills with SKILL.md targets mismatch
diff (CLI, TUI, Web UI) now applies FilterSkillsByTarget before
computing differences, matching the behavior of sync/status/doctor.
Previously, skills with unsupported targets values (e.g. targets: ["*"])
appeared as false 'source only' pending items that sync could never resolve.
2026-03-29 04:59:23 +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 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 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