Commit Graph
17 Commits
Author SHA1 Message Date
Willie 36a314442b refactor(server): decode JSON request bodies through one size-limited helper
About 57 handlers decoded request bodies with no size limit, and the few
that had one each picked their own. They now go through decodeJSON with a
1 MiB default; handlers that need more keep their larger limit. An
oversized body gets 413 instead of whatever the handler returned for bad
JSON (MCP and plugin requests used to answer 400). Every other decode
error keeps the handler's existing status and message.
2026-09-30 02:25:42 +08:00
Willie 6a325037f2 refactor(server): share the skills config reconcile step
Install, batch install, tracked-repo install, uninstall and rehydrate
each repeated the same nine-line block to reconcile the project or
global skills config. reconcileSkillsConfig now holds that block, so a
change to reconcile behavior or logging is made once instead of five
times. Each caller still passes its own source directory, so behavior
is unchanged.
2026-09-30 01:35:10 +08:00
Willie 20ae89a838 fix(server): stop dropping git and metadata errors in check, uninstall and batch targets
The dashboard check reimplemented the CLI's per-repo check but fetched
without the HTTPS token and ignored git status errors. Private tracked
repos could fail in the dashboard while `skillshare check` worked, and a
repo whose status could not be read showed as up to date. Both check
endpoints now call check.ParallelCheckRepos, the same code the CLI uses.
The JSON and SSE response shape does not change.

Batch uninstall treated a failed dirty check as clean and moved the
repo to trash. Without force, that item now fails with the git error
instead. This is stricter than the CLI, which only warns and continues.

Batch target updates ignored metadata save failures and still reported
success, so an override could silently disappear on the next reload.
They now return 500.
2026-09-30 01:34:58 +08:00
Willie bc01ff1b3e feat(server): let tracked-repo skills take dashboard targets
Setting targets on a skill inside a tracked repo used to be refused,
because writing its SKILL.md leaves the clone dirty and `update` then
skips the repo (or `--force` throws the setting away).

Store those targets in the source's .metadata.json instead, keyed by
the skill's path, and apply them at discovery over the frontmatter.
The clone stays clean, `update` keeps working, and the setting survives
it. Uninstalling a repo or skill drops its entries.

Overrides are saved in the same lock section that writes them: every
API request reloads the store from disk, so saving after unlocking
could lose them, and saving outside the lock raced with other writers.

Refs #295
2026-09-26 21:02:28 +08:00
Willie acb150dfe3 fix(server): allow uninstalling disabled skills via Web UI
The skill list endpoint discovers skills with DiscoverSourceSkillsAll
(which includes disabled skills), but the uninstall handler used
DiscoverSourceSkills, which excludes anything listed in .skillignore.
A disabled skill therefore stayed visible in the dashboard yet failed
to uninstall with "skill not found".

Switch handleBatchUninstallSkills to DiscoverSourceSkillsAll so the two
endpoints agree on which skills exist. The CLI was unaffected.

Fixes #190
2026-06-02 23:48:09 +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 5b7ca8ba3d fix: trash before gitignore cleanup and skip gitignore for external sources
Reorder handleUninstallRepo to move repo to trash before removing the
.gitignore entry, preventing accidental exposure of tracked content
when trashing fails.

ProjectGitignoreTarget now returns empty strings for source paths
outside projectRoot, since parent-relative patterns (../) are invalid
in .gitignore. All six callers guard on empty gitignoreDir and skip
gitignore management for external sources.
2026-05-20 16:34:02 +08:00
Willie 0c010c55f4 fix: wire custom sources into server reload and gitignore paths
reloadConfig now updates s.cfg.Source and s.cfg.AgentsSource from the
refreshed ProjectConfig so project UI handlers see the latest source
directories after a config edit.

Add ProjectGitignoreTarget helper that computes the correct .gitignore
directory and entry prefix based on whether the source path is inside
.skillshare/ or a custom location. All gitignore write and remove
operations (reconcile, install, uninstall, server handlers) now use
this helper instead of hardcoded 'skills/' prefix.

Fix nil projectCfg panics in three server tests that simulate project
mode by setting projectRoot without projectCfg.
2026-05-20 16:12:02 +08:00
Willie 2475acd35e feat(ui): add agent support to batch uninstall and trash pages
- Add agent-mode batch uninstall handler with kind-based routing
  in handler_uninstall.go (skill/agent dispatch)
- Add Skills/Agents tab navigation to BatchUninstallPage and TrashPage
  with per-tab filtering and scoped empty states
- Extract SourceBadge component to replace duplicated getTypeLabel /
  skillTypeLabel helpers across ResourcesPage, ResourceDetailPage,
  BatchUninstallPage, and AnalyzePage
- Add kind field to BatchUninstallRequest API type
- Capitalize badge labels for consistency (tracked → Tracked, etc.)
2026-04-09 13:48:30 +08:00
Willie 1f1790b6be refactor: replace Registry with MetadataStore in reconcile, server, install context
Phase 1 of caller migration:
- projectRuntime: registry → skillsStore + agentsStore
- globalInstallContext: reg → store
- ReconcileGlobalSkills/ProjectSkills/ProjectAgents: take *MetadataStore
- Server struct: registry → skillsStore + agentsStore
- handler_install, handler_skills, handler_uninstall: use MetadataStore
- install.go, search.go: post-install reconciliation via MetadataStore
2026-04-08 10:59:13 +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 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 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 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 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