Commit Graph
164 Commits
Author SHA1 Message Date
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 4c43506df3 feat: agent detail endpoint, project reconcile, and TrashPage badge
handler_skills: skill detail endpoint falls back to agents source when
skill not found. Returns agent .md file content and kind='agent'.

project_reconcile: add ReconcileProjectAgents() to scan agents source,
update registry with kind='agent' entries, and batch-update
.skillshare/.gitignore for agent files and metadata.

TrashPage: add KindBadge next to trashed item names with 'skill'
fallback for old trash items without kind field.
2026-04-07 18:05:40 +08:00
Willie 9a053a35b6 feat(ui): add agent stat card, kind filter tabs, and kind fields to API handlers
DashboardPage: add Agents stat card with Bot icon and accent color,
linking to /skills?kind=agent.

SkillsPage: add Skills/Agents filter tabs alongside existing filters.
KindBadge displayed on each skill card. matchFilter supports kind-based
filtering with accurate filter counts.

handler_collect: add kind field to localSkillItem response.
handler_uninstall: add kind field to batch request and result structs.
2026-04-07 18:05:40 +08:00
Willie 47da532bbe feat(cli,api): add agent info to status, doctor, and trash handler
status: show agents source path and agent count alongside skills source.

doctor: add checkAgentsSource() health check verifying agents source
directory exists, is a directory, and reports agent count. Non-existent
dir is info (not error) since agents are optional.

handler_trash: add kind field to trashItemJSON for frontend badge.
2026-04-07 18:05:40 +08:00
Willie 6f2932c650 feat(api): add agent support to overview, skills, and targets endpoints
Add agentsSource() helper to Server for mode-aware agent directory
resolution (global: EffectiveAgentsSource, project: .skillshare/agents).

handler_overview: add agentCount field counting .md files in agents dir.

handler_skills: add kind field ("skill"/"agent") to skillItem response.
Support ?kind= query param filter. List agents from agents source dir
alongside skills, with metadata enrichment from per-agent meta files.

handler_targets: add agentPath, agentLinkedCount, agentExpectedCount
fields to targetItem for frontend agent path display.
2026-04-07 18:05:40 +08:00
Willie bbf2e4343e feat(sync): unify extras symlinks through createLink
Replace direct os.Symlink calls in extras.go with createLink, gaining:
- Relative symlink support in project mode
- Windows junction fallback for extras (previously missing)

Thread projectRoot through SyncExtra, CollectExtraFiles, and all callers.

Ref: #120
2026-04-07 17:26:37 +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 343e29cfe5 fix(ui,server): harden target management, toggle, and tracked-repo UX
- Enable frontmatter parsing in DiscoverSourceSkillsAll so /api/skills
  returns saved targets (fixes target display reverting to All)
- Skip tracked-repo skills in batch/single target handlers to prevent
  dirty git state; reject with 400 for single-skill endpoint
- Add RefreshMetaHashes to recompute audit hashes after SKILL.md edits;
  batch handler refreshes outside the write lock
- Show 'Uninstall Repo' with confirm dialog for tracked-repo members
  instead of the always-failing individual uninstall action
- Return 409 Conflict when enabling a skill disabled by glob pattern
  in .skillignore/.skillignore.local instead of false success
- Preserve IsInRepo flag for root-skillignore-disabled skills so they
  remain visible in the Tracked tab after disable
- Update changelog and website changelog for v0.18.7
2026-04-04 17:05:22 +08:00
Willie 4fbee521ce fix(server): batch targets folder matching + reduce mutex scope
- Fix folder trailing slash bug: filepath.Clean now normalizes input
  before matchesFolder comparison (e.g. 'frontend/' → 'frontend')
- Narrow mutex scope in handleBatchSetTargets: RLock for config read,
  no lock during DiscoverSourceSkillsAll, Lock only for write loop
  (matches existing handleSetSkillTargets pattern)
- Defensive filepath.Clean on cleanEmptyParents inputs
- Add TestMatchesFolder unit test and trailing slash handler test
2026-04-04 17:05:22 +08:00
Willie 9abd9af71f feat(server): add SetFrontmatterList utility + batch/single target endpoints
New utility: SetFrontmatterList() writes/removes YAML list fields
in SKILL.md frontmatter with dot-notation support (metadata.targets).
Normalizes legacy top-level targets field. Preserves body content.

New endpoints:
- POST /api/skills/batch/targets — set targets for all skills in folder
- PATCH /api/skills/{name}/targets — set target for single skill
Both use s.mu.Lock() for safe concurrent access.

Includes 15 unit tests covering set/remove/traverse/root-only/not-found.
Part of issue #115.
2026-04-04 17:05:22 +08:00
Willie 115edf3f24 fix(server): correct project-mode gitignore path + prevent registry prune basename collision
P2-1: handleUninstallRepo and handleBatchUninstall used s.cfg.Source for
gitignore removal, but project-mode installs write to .skillshare/.gitignore
with a "skills/" prefix. Add gitignoreDir() helper that returns the correct
base directory per mode, and prefix entries in project mode.

P2-2: Registry prune used filepath.Base(repoName) to derive the legacy group,
causing sibling nested repos (e.g., org/_team-skills vs dept/_team-skills) to
collide on the same basename. Now uses exact Group match for nested repos and
restricts legacy basename matching to top-level repos only.

Tests added (15 new):
- resolveTrackedRepo: auto _ prefix, nested, already-prefixed, not-found,
  basename fallback
- Registry prune: full-path Group, nested members by prefix, sibling isolation
- Project-mode gitignore: single + batch uninstall
- updateSingle: basename fallback, not-found, regular skill priority
- cleanEmptyParents: multi-level, stops at non-empty, stops at boundary
2026-04-04 17:05:22 +08:00
Willie 7dcf64ea69 fix(server): drop reconcile from repo uninstall to avoid pruning agents
ReconcileGlobalSkills uses PruneStaleSkills(skillsOnly=false) which
removes agent entries unrelated to the uninstalled repo. The explicit
filter + Save is sufficient; full reconcile deferred to next sync.
2026-04-04 17:05:22 +08:00
Willie b22cd6b50b fix(server): scope registry prune to tracked entries only
Group-based filter now requires entry.Tracked to avoid removing
unrelated agent entries that happen to share the same group name.
2026-04-04 17:05:22 +08:00
Willie 657e400f8c fix(server): resolve order + registry prune for repo uninstall
- updateSingle: check exact skill path before resolveTrackedRepo
  fallback, preventing basename collision with nested repos
- handleUninstallRepo: match repo's own registry entry by FullName
  in addition to group-based matching for member skills
2026-04-04 17:05:22 +08:00
Willie a4984cd322 fix(server): resolve nested repos in update + prune registry on uninstall
P1: updateSingle now uses resolveTrackedRepo (shared with uninstall)
to find nested tracked repos like org/_team-skills instead of only
probing root-level _name/name.

P2: handleUninstallRepo now prunes registry entries belonging to the
uninstalled repo and runs ReconcileGlobalSkills/ReconcileProjectSkills,
matching the cleanup that handleUninstallBatch already does.

Extracted resolveTrackedRepo as a Server method to deduplicate the
nested path resolution logic between uninstall and update handlers.
2026-04-04 17:05:22 +08:00
Willie 7e160dee16 fix(trash): support nested tracked repo names in trash lifecycle
MoveToTrash, List, Restore, and Cleanup all assumed flat names.
When a nested tracked repo like org/_team-skills was uninstalled,
the trash entry landed in a subdirectory that List could not see
and Restore could not reach.

- MoveToTrash: create intermediate dirs via filepath.Dir(trashPath)
- List: recursive WalkDir to discover nested entries, store full
  relative path in TrashEntry.Name
- Restore: MkdirAll on destination parent before rename
- Cleanup: remove empty intermediate dirs after expiry via
  cleanEmptyParents helper

Closes runkids/skillshare#116 follow-up (nested trash path)
2026-04-04 17:05:22 +08:00
amdoi7 b625b8ce9a Merge origin/main into fix/dashboard-tracked-repo-actions 2026-04-03 15:34:10 +08:00
amdoi7 b1dde02519 test(server): cover tracked repo uninstall edge cases
Add handler tests for nested tracked repo uninstall, ambiguous basename rejection, and traversal rejection.
Also isolate trash-backed server tests by setting XDG_DATA_HOME in test helpers.
2026-04-03 15:29:05 +08:00
amdoi7 e3ea2afb88 fix(ui): address tracked repo review feedback
Validate tracked repo names against path traversal and surface repository listing errors in the uninstall handler.
Track in-flight dashboard repo actions with sets so loading state stays correct during overlapping clicks.
2026-04-03 15:14:51 +08:00
amdoi7 14da64f33a fix(ui): manage tracked repos from dashboard
Add update and uninstall controls to the dashboard tracked repo list.
Handle nested tracked repo paths in the uninstall API so dashboard actions work for both top-level and nested repos.
2026-04-03 14:34:17 +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 94d7ccddef refactor: deduplicate branch helpers and cache per-repo git calls
- check.go: extract urlBranchKey()/splitURLBranch() helpers, used in 5 places
- handler_skills.go: extract enrichSkillBranch() helper, used in 2 handlers
- handler_targets.go: merge duplicate merge/copy resolution into single case
- list.go: cache git.GetCurrentBranch() per-repo instead of per-skill
2026-04-01 00:32:49 +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 903df9f446 feat(server): add branch to skills API and install handlers
- skillItem struct gains Branch field (json: branch,omitempty)
- handleListSkills and handleGetSkill populate Branch from SkillMeta;
  fall back to git.GetCurrentBranch for tracked repos with empty metadata branch
- handleDiscover, handleInstallBatch, handleInstall all accept Branch in
  request body and propagate it to Source.Branch and InstallOptions.Branch
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 e0d0313b0d refactor: simplify enable/disable after code review
- AddPattern returns (bool, error) — single file read, no TOCTOU
- Remove external HasPattern guard in CLI (AddPattern handles it)
- Merge handleDisableSkill/handleEnableSkill into handleToggleSkill
- Fix locking: RLock for discovery, Lock only for file write
- Handle errors from AddPattern/RemovePattern in TUI toggle
- Only write oplog when changes actually occurred
- Inline capitalizeFirst with strings.ToUpper
2026-03-29 04:59:23 +08:00
Willie 621b5c7ac6 test: integration tests for enable/disable and collect mode inheritance 2026-03-29 04:59:23 +08:00
Willie 18fac69e56 fix(collect): resolve inherited mode and stale manifest on copy→merge switch 2026-03-29 04:59:23 +08:00
Willie af1f62b62e feat: add enable/disable API, UI button, and disabled field 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 44420a8b84 feat(ui): improve analyze display, install picker, and tooltip UX
Analyze page:
- Display skill path (/) instead of flat name (__) in chart, table, dialog
- Widen chart name column from 150px to 220px
- Add skill path as first line in chart tooltip with separator
- Add hover highlight on chart rows

Tooltip component:
- Add followCursor mode that tracks mouse position
- Add viewport boundary detection to prevent clipping
- Measure natural size at (0,0) before clamping position
- Remove break-all to prevent mid-word breaks

Install page:
- Add singleSelect mode to SkillPickerModal (radio UI) when custom name is set
- Add custom name support to batch install API (backend + frontend)
- Remove cross-path duplicate check for batch installs
- Fix: don't show success summary toast when all skills failed
- Fix: keep picker open on install failure
- Preserve source input after install (don't clear on reset)
- Widen SkillPickerModal from md to 2xl
- Align severity badge and description text in warning dialogs

Toast: raise z-index above dialog overlay (z-50 → z-[60])
2026-03-28 02:30:50 +08:00
Willie bb029f7950 fix(analyze): handle null targets array in API response
Go nil slice serializes to JSON null instead of []. When no targets
match, buildGroups() receives null and for...of throws TypeError.

- Backend: use make([]..., 0) so JSON marshal produces []
- Frontend: add ?? [] guard and optional chaining for null safety
2026-03-28 01:55:25 +08:00
Willie eabb556cc6 refactor(config): cache SourceRoot in Config.RegistryDir
Eliminates redundant .git/ directory walks on every LoadRegistry call.
SourceRoot() is now computed once in config.Load() and cached in
cfg.RegistryDir. All 11 call sites use the cached value.
2026-03-26 23:32:15 +08:00
Willie a7de6a3a69 feat(registry): move registry.yaml to source dir for git sync (#103)
- Add SourceRoot() helper to find git repo root from cfg.Source
- Add MigrateRegistryToSource() for one-time migration
- Update all 11 global-mode LoadRegistry/Save call sites
- registry.yaml now lives in skills/ dir and is tracked by git
2026-03-26 22:42:00 +08:00
Willie fe3e72fe38 feat(ui): add GET /api/analyze endpoint
Expose per-target context-window budget analysis via the REST API.
The handler discovers source skills with context metadata (desc/body
char counts, lint issues), applies each target's filter/mode rules,
and returns aggregated always-loaded vs on-demand token estimates.
2026-03-26 19:20:52 +08:00
Willie 2ce1544dd1 docs: add flatten documentation, changelog, and contributor
Extras command docs, config reference, built-in skill, website
changelog, release notes. Add mk-imagine to README contributors.

Ref: #97
2026-03-25 21:14:16 +08:00
Willie 4c83ef71fb feat(ui): add flatten support to Web UI
Server handlers accept/return flatten field. Extras page shows flatten
checkbox per target. Config editor validates flatten+symlink constraint.

Ref: #97
2026-03-25 21:14:16 +08:00
Willie 5d9dd0cdbb feat(extras): add flatten option to extras sync engine
When flatten=true, SyncExtra maps subdirectory files to target root
using filepath.Base(). First file wins on collision, subsequent are
skipped with warnings. Includes config validation, sync-time guard,
CheckSyncStatus collision handling, and CollectExtraFiles support.

Ref: #97
2026-03-25 21:14:16 +08:00
Willie ed8596fc7e fix(server): fix extras sync response key and add read lock
- Change JSON key from 'results' to 'extras' to match frontend type
- Add RLock snapshot pattern matching handleExtras GET handler
- Replace s.extrasSourceDir() with inline resolution using snapshotted values
2026-03-20 18:29:05 +08:00
Willie 76e614c2f6 fix(server): return ignored skills stats even without root .skillignore
Previously the GET /api/skillignore handler returned no stats when
the root .skillignore file didn't exist, hiding tracked repo ignores.
Now always runs DiscoverSourceSkillsWithStats so tracked repos'
.skillignore entries are always reported.
2026-03-20 02:36:50 +08:00
Willie 14823027b5 test: comprehensive extras source config coverage
Unit tests:
- ResolveExtrasSourceDir 3-level priority + empty fallbacks
- ResolveExtrasSourceType per-extra/extras_source/default
- Config Load() tilde expansion for ExtrasSource and per-extra Source

Server tests:
- GET /api/extras includes source_type
- POST /api/extras with/without source field
- Project mode returns default source_type
- Create backfills extras_source

Integration tests:
- extras_source config, per-extra --source flag
- source_type in JSON, priority chain
- sync/collect/doctor/status with custom source
- sync auto-creates missing source dirs
- init backfills extras_source

E2E runbook (24 steps, mdproof verified):
- All three sync modes with content verification
- Tilde expansion, backward compatibility
2026-03-20 02:36:50 +08:00
Willie 23224b5467 feat: extras source config in server API and Web UI
Server:
- GET /api/extras returns source_type field
- POST /api/extras accepts optional source field
- extrasSourceDir helper uses ResolveExtrasSourceDir
- Auto-backfill extras_source on create, auto-create dirs on sync
- Fix data race: snapshot ExtrasSource under RLock in handleExtrasDiff

Web UI:
- ExtraCard shows source type badge for non-default sources
- AddExtraModal includes optional source path input
- Comprehensive cache invalidation: config/extras/targets mutations
  invalidate all dependent queries across pages
2026-03-20 02:36:50 +08:00
Willie 0b5eba205d feat(ui): add batch uninstall route, nav entry, and link from SkillsPage
- Add lazy import and route for BatchUninstallPage in App.tsx
  (placed before skills/:name to avoid capturing as dynamic param)
- Add "Batch Uninstall" nav entry with Trash2 icon in Layout.tsx MANAGE group
- Add "Batch Uninstall" secondary button next to "New Skill" in SkillsPage header
2026-03-19 16:33:24 +08:00
Willie bb04987f75 feat(server): add POST /api/uninstall/batch endpoint
Batch uninstall with skip-and-continue semantics, registry cleanup,
config reconciliation, and gitignore batch removal. Supports both
global and project mode.
2026-03-19 16:33:24 +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 2eb6a79670 fix: address code review findings from simplify pass
- Add cleanup (os.RemoveAll) on scaffold dir creation failure
- Use skill.ValidNameRe in isValidSkillName (remove duplicate regex)
- Derive canAdvance from nameError instead of re-calling validateName
- Remove redundant total param from ProgressBar (derive from steps.length)
- Fix popstate handler to read event.state.step directly
- Use Plus icon for PageHeader (icon prop is required)
2026-03-18 22:35:02 +08:00
Willie 7b6cb70a0b test(server): add tests for create skill and templates endpoints 2026-03-18 22:35:02 +08:00