222 Commits
Author SHA1 Message Date
Willie a2f958d288 feat(ui): background mode, in-place upgrade, and PWA support
Three user-visible additions to the web dashboard, plus the CLI surface
needed to drive them.

* `skillshare ui start` / `skillshare ui stop` — run the dashboard as a
  managed background process. Re-running start reuses the existing
  healthy process; stop uses the remembered host/port. Foreground
  `skillshare ui` keeps working unchanged. Process tracking lives in
  ui_process_{unix,windows,other}.go via a PID + current-state file.
* `--app` — opens the dashboard in a Chromium app-mode window (Chrome,
  Edge, Brave) on macOS, Windows, and Linux for a separate Dock/taskbar
  entry without browser chrome.
* In-place upgrade from the browser — the Update dialog and the Doctor
  page's Version card now expose an Update now button. Backed by two
  new endpoints (POST /api/upgrade, POST /api/restart in
  handler_restart_upgrade.go); the browser polls GET /api/health and
  reloads once the new server is ready. Dev builds short-circuit with
  `devMode: true` and a simulated restart so the flow can be exercised
  without rebuilding the binary.
* Progressive Web App — site.webmanifest, app icons (192/512), and a
  minimal service worker registered from main.tsx. Supporting browsers
  can install the dashboard as a standalone desktop app.
* Doctor Version card redesign — state-coloured icon (blue when an
  update is available, green when up to date), explicit
  `current → latest` delta, Update button only when there is something
  to upgrade.
* i18n — translate "DEV mode" in zh-TW / zh-CN / ko (previously left
  as raw English).

Adds CHANGELOG.md and website changelog entries for v0.19.20 and
refreshes website/docs/reference/commands/ui.md to document the new
modes, --app flag, new REST endpoints, and the in-place upgrade flow.
2026-05-24 01:21:06 +08:00
Willie 4d7011983c feat(sync): warn on skill path overlap with one-line hint
Detect overlapping target paths during sync — either two targets
sharing the same primary path, or cross-runtime discovery via the
also_scans table — and surface a brief one-liner pointing users at
`skillshare doctor` for the full breakdown.

Triggers in both CLI (sync.go, sync_project.go) and Web UI (sync API
warnings array, rendered by existing SyncPage warnings card). Detection
logic lives in internal/config/path_overlap.go and is shared between
both paths.

Quiet by design: no output when no overlap exists. JSON output mode
remains untouched.
2026-05-22 01:00:54 +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 68d5eadc0b feat: support custom project source directories via sources map
Add ProjectSources struct to ProjectConfig with optional skills, agents,
and extras fields. When set, project-mode commands resolve source paths
from these values instead of hardcoded .skillshare/{skills,agents,extras}/.

Config example:
  sources:
    skills: ./docs/skills
    agents: ./docs/agents

Three EffectiveXxxSource(projectRoot) methods provide the central
resolution logic with fallback to defaults. The projectRuntime gateway
and server layer route through these methods, so most commands get
custom source support automatically.

Closes #153
2026-05-20 15:42:53 +08:00
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 5975c1109a test: add regression tests for azure_hosts wiring in project install and agent update
- TestParseOptsFromConfig_IncludesAzureHosts: verify global config
  helper passes AzureHosts to ParseOptions
- TestParseOptsFromProjectConfig_IncludesAzureHosts: verify project
  config helper passes AzureHosts
- TestParseOptsFromProjectConfig_AzureHostsParseOnPrem: end-to-end
  verify project config azure_hosts produces correct on-prem CloneURL
- TestUpdateAgent_AzureOnPrem_UsesParseOpts: verify server agent
  update handler parses on-prem Azure source via ParseSourceWithOptions
2026-05-05 19:26:11 +08:00
Willie 204340c2e0 fix: wire azure_hosts through project install and agent update paths
- install_project.go: pass AzureHosts to temporary Config (was only
  passing GitLabHosts, so project-mode direct install ignored azure_hosts)
- update_agents.go: thread ParseOptions through batchUpdateAgents and
  reinstallAgent, replacing bare ParseSource with ParseSourceWithOptions
- handler_update.go: use ParseSourceWithOptions with s.parseOpts() for
  agent update in web UI

Without this fix, azure_hosts in .skillshare/config.yaml was silently
ignored during project install and agent update, causing on-prem Azure
DevOps URLs to be parsed incorrectly.
2026-05-05 18:54:45 +08:00
Willie e48a301623 feat: add azure_hosts config for Azure DevOps Server on-premises
Add azure_hosts config parameter (analogous to gitlab_hosts) that allows
users to register self-hosted Azure DevOps Server hostnames so they
receive proper URL parsing without appending .git to clone URLs.

- Add AzureHosts field to Config and ProjectConfig structs
- Add SKILLSHARE_AZURE_HOSTS env var support with merge semantics
- Generalize hostname validation into shared normalizeHostList/mergeHostsFromEnv
- Add azureOnPremPattern regex and parseAzureOnPrem for /_git/ URL routing
- Add isAzureHost for config-based host detection (no auto-detect)
- Update TrackName to handle on-prem Azure DevOps clone URLs
- Wire AzureHosts through InstallContext, ParseOptions, and Server
- Add JSON Schema, UI fieldDocs, and website documentation
- Add 19 new tests covering config, source parsing, and server

Closes #147
2026-05-05 18:33:07 +08:00
Willie a4da5fc7f6 fix: migrate legacy root orchestrator updates 2026-05-01 13:25:37 +08:00
Willie 07c091529b refactor(search): harden preview error handling, cache, and a11y
- Add ErrSkillNotFound sentinel error in search/preview.go so callers
  can distinguish 404 from other errors with errors.Is instead of
  brittle string matching
- Cap previewCache at 200 entries with TTL purge + full reset on
  overflow to prevent unbounded memory growth
- Make Card and SearchResultsTable rows keyboard-accessible
  (role=button, tabIndex=0, Enter/Space handlers)
- Refactor SkillPreviewModal to accept a single SearchResult prop
  instead of 6 individual fields — reduces prop drilling and keeps
  the modal in sync with the result shape
- Fix search_online_test: add --list flag so output is not gated
  behind interactive TUI
2026-04-23 16:46:53 +08:00
Willie a3235473eb feat: add skill preview modal to Search page (#141)
Add a preview modal so users can read a skill's SKILL.md content
before installing. Clicking a search result card or table row opens
the modal; the Install button is now inside the modal.

Backend:
- New GET /api/preview?source=owner/repo/path endpoint
- FetchSkillContent fetches SKILL.md from GitHub Contents API
- Git Tree API fallback for hub sources where the install shorthand
  doesn't match the repo's actual file path
- In-memory TTL cache (5 min) via sync.Map
- Proper 404/429/500 error handling with rate-limit support

Frontend:
- SkillPreviewModal component (DialogShell-based, lazy-fetch)
- Cards and table rows clickable to open preview
- Graceful fallback: if fetch fails but hub metadata exists, show
  description + tags instead of error
- Hide Stars column in table view for hub mode
- Fix Card component missing onClick prop passthrough
- Fix IntersectionObserver not reconnecting after loading more items
- Prevent background scroll when any modal is open (DialogShell)
- i18n keys added to all 11 locales

Closes #141
2026-04-23 14:20:42 +08:00
Willie 63a4a57a0c feat(ui): allow editing source URL on skill detail page
Add PATCH /api/resources/{name}/source endpoint to update the source URL
for installed skills. For tracked repos, all sibling skills sharing the
same git remote are updated together with the new repo base URL, and the
git remote origin is also updated.

Frontend changes:
- Add Source URL input field in the skill editor (visible for all skills
  with metadata)
- Use shared Input/Textarea components in FrontmatterEditor for visual
  consistency, with new size='sm' variant
- Replace custom kind-badge/tracked-badge with shared KindBadge/SourceBadge
  components in the editor header
- Preserve original YAML frontmatter formatting when only the body or
  source URL is changed (avoids spurious quote style / line wrap diffs)
- Skip diff review dialog when only source URL is modified

Backend fixes:
- Two-pass skill lookup in handleGetSkill: prefer exact FlatName match
  over baseName fallback to prevent name collisions between standalone
  and tracked repo skills
- Add basename-only fallback in MetadataStore.GetByPath for tracked repo
  skills stored with short keys
- Use cfg.Source (global) consistently in save/patch handlers to match
  the source used by list/detail handlers in project mode

Closes #142
2026-04-22 23:06:53 +08:00
Willie 8f4890680a fix(server): restrict editor whitelist and harden withinDir path check
- pickEditor now rejects unknown editor aliases instead of executing
  arbitrary binaries from PATH (security)
- withinDir uses filepath.Rel instead of strings.HasPrefix for
  correctness on case-insensitive filesystems
2026-04-19 09:29:18 +08:00
Willie c663fe542c chore: release v0.19.3 2026-04-19 09:29:18 +08:00
Willie 489cbcffae feat: add i18n 2026-04-19 09:29:18 +08:00
Willie 5fc5ee4fe5 feat(ui): add web-based skill editor with metadata, live preview, and diff review
Introduces a full in-browser skill editor reachable from the skill detail
page, replacing the previous read-only detail view for edits.

Editor
- Two-pane layout with Markdown textarea, live preview, and synced scroll
- Edit / Split / Preview mode toggle in the status bar (⌘P to cycle)
- Keyboard shortcuts: ⌘S save (with diff review), Esc cancel
- Outline drawer with jump-to-heading
- Token / word / line / file count in status bar, 5K budget warning

Frontmatter
- Grouped field editor (Identity / Invocation / Execution / Metadata)
  matching the 13 official SKILL.md fields
- Shared 1,536-char budget enforced across description + when_to_use
- Switch toggles for booleans, segmented control for enums, chip array
  inputs for list-valued fields
- Metadata group edits nested metadata.* keys directly, with stable row
  ids so typing key → clicking value no longer remounts the inputs
- Special handling for metadata.targets so values serialize as a YAML
  list (backend ParseFrontmatterList requires arrays)
- YAML mode for raw editing; Fields ↔ YAML round-trips cleanly
- Legacy root-level 'targets:' migrated to metadata.targets on load

Diff review
- Save triggers a side-by-side diff modal built on the shared DialogShell
  with focus trap and backdrop, using the Button component for actions
- YAML serializer emits plain scalars when safe instead of wrapping every
  value containing ':', '*', '#', or '"', eliminating spurious churn in
  the save diff

Misc
- DialogShell gains 4xl–7xl maxWidth presets
- Resource detail sidebar shows a Targets row when metadata.targets is set

Backend additions (server handlers):
- POST /api/resources/:name/content   save SKILL.md content
- POST /api/resources/:name/open      open in local editor
2026-04-19 09:29:18 +08:00
Willie 85abcb8bd6 chore: release v0.19.2 2026-04-14 18:16:11 +08:00
Willie 8a2196acdb feat(ui): show local agent count in targets and fix agent batch uninstall
Add agentLocalCount to target API and CLI JSON output so the UI can
display how many local (non-source) agents exist per target.

- Add LocalCount to AgentSummary, computed via FindLocalAgents
- Surface agentLocalCount in both CLI target list JSON and server API
- Show local agent counts in target detail summaries (CLI + UI)
- Collect button now appears for targets with local agents and routes
  to CollectPage with scope=agent query param
- CollectPage reads scope from URL and auto-scans on mount
- Fix BatchUninstallPage: agents tab was collapsing individual agent
  names into the repo name via buildApiNames(), causing 'agent not
  found' errors; now sends each agent flatName individually
- Invalidate targets + diff queries after successful collect
2026-04-14 18:03:41 +08:00
Willie f2a6a391bc chore: release v0.19.0 2026-04-11 03:37:48 +08:00
Willie 788f9bc6e9 feat(agents): JSON output + audit gate for install/update
Extend install/update with agent-aware --json output and apply the same
audit block-threshold gate skills already use.

Install:
- install --json: imply --force; imply --all only when neither
  --skill nor --agent is set (so explicit selectors still work)
- project-mode install now routes through cmdInstallProjectParsed
  so --json suppresses UI and emits a pure-JSON payload
- agent installs propagate SourceDir so metadata lands in the
  agents root, not the install subdir
- validation error lists --agent / --kind / --branch explicitly

Update agents:
- update agents supports --force, --skip-audit, --audit-threshold
- tracked agent repos + metadata-backed single-file agents now run
  the same audit gate as skills; blocks roll back from a temp stage
- JSON output returns the final per-agent status
  (updated/skipped/failed/up_to_date/...) by merging check results
  with batch update outcomes

Audit:
- auditInstalledAgent shares one helper with auditInstalledSkill
  (scan + cleanup callbacks); single-file agent scans now use
  audit.ScanFile / ScanFileForProject instead of staging the file
  into a temp directory
- UpdateAgentFromDiscovery stages to temp, audits, then renames
  atomically (rename already overwrites on POSIX)

Refactors pulled in while reworking these paths:
- extract jsonUISuppressor helper in json_output.go and use it
  from install/update/update_agents; collapses 4 copies of the
  suppress/restore closure dance and the per-error failJSON block
- drop relPath plumbing from installAgentFromDiscoveryInternal
  now that ScanFile doesn't need a staged relative path
- list.go render functions now use theme.ANSI() so NO_COLOR is
  respected in plain-text output

Tests:
- add TestInstallAgentFromDiscovery_HighFindingBlocked (unit)
- add TestUpdate_Agents_HighFindingBlockedByThreshold (integration)
- add TestInstall_Project_JSON_Agent_PureJSON,
  TestUpdate_Agents_JSON_ReportsFinalStatus
- fix TestList_SKILLSHARE_THEME_Light / TestList_NO_COLOR to
  write a config before invoking list
- fix TestTargetList_NoTUI_FallsBackToPlainText assertion to match
  the new structured Mode: merge output
- fix TestDoctor_AllGood_PassesAll by pinning SKILLSHARE_THEME=dark
  so the no-TTY theme fallback warning doesn't fire
- add list_tui_content_test.go covering light/dark glamour base
- list detail pane now picks LightStyleConfig on light terminals

Docs:
- update install.md, update.md, understand/agents.md for the new
  flags, JSON shapes, and agents update workflow
2026-04-10 23:27:26 +08:00
Willie 0efdb643b2 feat(ui): add .agentignore tab to Config page
Add GET/PUT /api/agentignore endpoints mirroring the existing
skillignore API, backed by skillignore.ReadAgentIgnoreMatcher()
and resource.AgentKind{}.Discover() for ignore stats.

On the frontend, extend the Config page with a third tab for
editing .agentignore. Generalize the former SkillignoreTab into
a shared IgnoreTab component with a kind prop, and extend
AssistantPanel to show ignored agents in the sidebar.
2026-04-10 03:38:43 +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 b8a189ba58 Improve resource install agent support
Add local-path resource discovery so install flows can detect agents as well as skills. Preserve nested agent paths and suffixless agent metadata keys during batch install and update, and refresh the UI copy to use resource-aware wording on the install surface.
2026-04-10 01:26:40 +08:00
Willie 4b37f1f21d feat(server): extend collect endpoint to pull agents via kind field
collectSkillRef now has optional kind field. Items with kind=agent
are resolved against agent target paths and pulled via PullAgents().
Results from skills and agents are merged into a single response.

Oplog tracks skill and agent counts separately for observability.
2026-04-10 00:25:25 +08:00
Willie 4834e4580d feat(server): extend collect scan to support kind=agent parameter
handleCollectScan now accepts ?kind=skill|agent query parameter.
When kind=agent, scans for local agent files in agent target dirs.
When kind is empty, scans for both skills and agents.
2026-04-10 00:20:01 +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 335092066f feat(server): add computeAgentTargetDiff for agent diff in UI
Port agent diff logic from CLI (diff_agents.go) to server package.
Returns []diffItem with Kind='agent' for link/update/prune/local actions.
2026-04-09 23:34:21 +08:00
Willie 40347477d5 fix(audit): scan all agents including disabled ones
Security audit should scan ALL agents regardless of .agentignore
status — disabled agents may still contain threats.
2026-04-09 14:49:24 +08:00
Willie 1b9ba78719 fix(audit): scan agents as individual files, not directories
Agents are individual .md files discovered by resource.AgentKind{}.Discover(),
but audit was using collectInstalledSkillPaths() which calls
sync.DiscoverSourceSkillsLite() — designed for skill directories. Then
ParallelScan() called ScanSkill() which expects directories, not files.

Changes:
- Add IsFile flag to audit.SkillInput; when set, ParallelScan uses
  ScanFile/ScanFileForProject instead of ScanSkill variants
- Add collectInstalledAgentPaths() using resource.AgentKind{}.Discover()
  and resource.ActiveAgents() for proper agent file discovery
- Add toAgentAuditInputs() helper that sets IsFile=true
- Branch on kindAgents in auditInstalled(), auditFiltered(), and
  launchAuditTUIWithTabs() to use agent-specific discovery and inputs
- Add discoverAuditAgents() in server handler and update
  resolveAuditSource() to return isAgents flag
- Update handleAuditAll, handleAuditStream to use agent-aware discovery
  and build SkillInput with IsFile=true for agents
2026-04-09 14:45:24 +08:00
Willie e1c94b5427 feat(server): add ?kind=agents param to audit API handlers
- Add resolveAuditSource() helper that returns source dir and result kind
  based on ?kind query param (agents → agentsSource(), default → skills)
- Update handleAuditAll() to use resolveAuditSource() and set Kind on
  all results after processAuditResults()
- Update handleAuditStream() with the same pattern for SSE endpoint
- Update toAuditResponse() to propagate result.Kind into response JSON
2026-04-09 14:24:43 +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 2a91a72f6e fix(server): sync matrix agent handling and stale test routes
- Fix sync matrix using wrong builtin agent targets in project mode
  (DefaultAgentTargets → branch on IsProjectMode)
- Fix sync matrix not skipping filters for agent symlink mode,
  matching the existing skill symlink behavior
- Remove double-defensive slice copies in handleListTargets since
  targetsummary.Builder already clones Include/Exclude
- Extract shared findAgent() to deduplicate discovery logic between
  resolveAgentResource and resolveAgentRelPathWithStatus
- Update test URLs from /api/skills to /api/resources and response
  keys from skills/skill to resources/resource to match the route
  rename from the resources refactor
2026-04-09 04:07:35 +08:00
Willie 5836a8802f feat: add agent filter support to Filter Studio, targets CLI, and overview API
Backend:
- PATCH /api/targets/:name accepts agent_include/agent_exclude fields
- POST /api/sync-matrix/preview returns agent entries with kind=agent
- GET /api/overview returns agentsSource and extrasSource paths
- Fix ResolveProjectTargets to resolve Agents sub-key (path + filters)
- Add agent filter CLI flags: --add-agent-include, --add-agent-exclude,
  --remove-agent-include, --remove-agent-exclude, --agent-mode
- Unify target list JSON/TUI to show agent info and filters

Frontend:
- FilterStudioPage: kind-driven single-context view (?kind=skill|agent)
- KindBadge: use design system tokens (ss-badge + wobble in playful)
- TargetsPage: link to Filter Studio with ?kind= param
- ResourceDetailPage: capitalize type labels (Local, GitHub)
- ResourcesPage: sync activeTab from URL searchParams on navigation
- DashboardPage: show agents/extras source dirs, link skills card
  with ?tab=skills for reliable tab switching
- API client: extend updateTarget and previewSyncMatrix for agent filters

Tests:
- Agent include/exclude round-trip persistence
- Invalid agent pattern returns 400
- Preview with agent entries and kind field
- No agent entries for targets without agent path
- CLI target agent filter integration tests
2026-04-09 03:50:28 +08:00
Willie 3db5e02137 feat(ui): redesign Targets page with equal Skills/Agents sections and modal picker
- Promote agents from nested dashed box to equal-level section panels
  with same visual treatment as skills (bg panel, label, controls)
- Move StatusBadge from card header into per-section labels
- Add agent mode dropdown (PATCH /api/targets/{name} now accepts agent_mode)
- Unify agent filter text to match skills pattern (All N agents / N/M agents)
- Add agentPath to available targets API and Add Target flow
- Convert inline Add Target form to DialogShell modal (max-h-[60vh])
- Add Agents Path input for custom targets and selected target preview
- Show both Skills/Agents paths in picker rows for supported targets
2026-04-09 03:13:49 +08:00
Willie f5af6c3909 feat(ui): unify skills/agents under /resources route and API
- Rename route /skills → /resources (pages, detail, new)
- Rename API /api/skills → /api/resources with response keys
  skills → resources, skill → resource
- Rename SkillDetailPage → ResourceDetailPage, variable skill → resource
- KindBadge: show full 'Skill'/'Agent' text, remove size prop
- Show 'local' type badge when source type is empty
- Dashboard: remove Sync Mode stat card, use 4-col grid
- Resources: remove redundant Skills/Agents filter chips (tabs handle it)
- Agent audit: add ?kind=agent support to /api/audit endpoint
- Agent sync matrix: include agents in /api/sync-matrix with
  builtin target path fallback and include/exclude filtering
- FilterAgents: new function in internal/sync/filter.go
- Agent sync: apply include/exclude filters before syncing
2026-04-09 01:26:30 +08:00
Willie 43c5154a78 Flatten nested agent sync names
Align agent target naming with the skills-style __ flattening so nested agents do not collide by basename in flat agent directories. Add unit and project-mode integration coverage to verify repeated syncs stay stable and no longer report false updates.
2026-04-08 20:52:29 +08:00
Willie d16c4f3812 fix: correct metadata store routing, corruption handling, and lookup depth
Three bugs introduced during centralized metadata migration:

1. Batch agent installs via UI wrote metadata to skills/.metadata.json
   instead of agents/.metadata.json because handleInstallBatch hard-coded
   SourceDir to s.cfg.Source. Override SourceDir with agentsSource() when
   body.Kind is agent.

2. CheckAgents used LoadMetadataOrNew which silently converts parse
   failures into an empty store, making all tracked agents appear local
   and suppressing drift/update diagnostics. Switch to LoadMetadata and
   surface corruption as status=error with the parse error message.

3. findMetaEntry only climbed 3 parent directories when searching for
   .metadata.json, but --into supports arbitrary nesting depth. Raise
   the ceiling to 10 (root sentinel still terminates early).
2026-04-08 18:06:20 +08:00
Willie 7552c76973 refactor: eliminate sidecar reads and use centralized metadata store
Production code no longer reads or writes .skillshare-meta.json sidecars:
- InstallAgentFromDiscovery: write to centralized store via WriteMetaToStore
- agent_check.go: read from centralized store passed as parameter
- handler_skills.go: read agents from s.agentsStore
- audit.go: readMetaFileHashes reads from parent .metadata.json
- analyzer_metadata.go: extract findMetaEntry to deduplicate walk logic
- uninstall_agents.go: remove entry from centralized store on uninstall
- batchUpdateAgents: pass store to reinstallAgent, remove dead field
- Replace LoadMetadata+nil guard with LoadMetadataOrNew across 6 files
2026-04-08 17:43:30 +08:00
Willie 4af128fcf0 fix: migrate metadata consumers from Get(basename) to GetByPath
All call sites that looked up metadata entries using filepath.Base()
now use store.GetByPath(relPath) which handles both full-path keys
and legacy basename+group keys transparently.

Also fixes makeInstallOpts() to set SourceDir from updateContext,
preventing nested skill updates from writing metadata to wrong dir.
2026-04-08 16:35:27 +08:00
Willie 2acfec82ec refactor: simplify metadata — extract helpers, remove dual-write, add kind constants
Code quality fixes from review:
- Extract RemoveByNames() to eliminate copy-paste in uninstall Phase 7
- Add MetadataKindSkill/MetadataKindAgent constants
- Remove dual-write shim (findSkillsRoot + writeMetaToCentralized)
- install_apply.go uses WriteMetaToStore with SourceDir (no sidecar)
- Move LoadMetadata out of walk loops (P0 efficiency fix)
- isGroupDir accepts store parameter to avoid redundant loads
- Add SourceDir to InstallOptions for --into group support
2026-04-08 15:00:22 +08:00
Willie e91890d2b0 test: fix all integration tests for centralized .metadata.json format
- Dual-write in WriteMeta: also writes to .metadata.json for backward compat
- Migration looks in parent dir for registry.yaml
- Group uninstall matches entries by Group field + full path
- Sync test uses MetadataStore instead of registry.yaml
- All integration tests pass (0 FAIL)
2026-04-08 14:28:57 +08:00
Willie ed1beb1ccb refactor: replace all remaining ReadMeta/LoadRegistry with MetadataStore
Replace every remaining call to the old per-skill metadata API
(ReadMeta, RefreshMetaHashes, config.LoadRegistry) with the centralized
MetadataStore across 10 files:

Server handlers:
- handler_check.go: use s.skillsStore.Get() instead of ReadMeta
- handler_check_stream.go: same pattern as handler_check.go
- handler_skills_batch.go: use s.skillsStore.RefreshHashes() + Save()

CLI commands:
- check.go: load store once in collectCheckItems, use MetadataEntry
- doctor.go: load store once in checkSkillIntegrity
- list.go: load store once in buildSkillEntries (replaces parallel ReadMeta)
- uninstall.go: use skillsStore for display/dry-run/finalize
- uninstall_project.go: same pattern, remove config.LoadRegistry
- update_batch.go: pruneRegistry now uses MetadataStore

Hub:
- hub/index.go: load store once in BuildIndex

The only remaining ReadMeta call is in a test file
(search_batch_meta_roundtrip_test.go) which tests the shim itself.
2026-04-08 11:19:27 +08:00