Commit Graph
1462 Commits
Author SHA1 Message Date
Willie dfd69b7ea0 feat(ui): add kind param to sync API client
Accepts 'skill' | 'agent' to control sync scope.
2026-04-09 23:42:36 +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 aaabc3ad88 refactor: simplify audit code — constants, dedup helpers, cache pattern
- Add audit.CrossSkillResultName constant, use in Go + TS
- Merge toAuditInputs/toAgentAuditInputs into one with isFile param
- Extract discoverForKind() and toInputsForKind() to eliminate 5+ if-else branches
- Simplify launchAuditTUIWithTabs with otherKindFilter dispatch
- Use CROSS_SKILL_NAME constant in AuditPage.tsx
2026-04-09 16:23:01 +08:00
Willie f0f371c604 fix(list): group agents by directory in TUI
Set RepoName from parent directory for nested agents so
buildGroupedItems creates proper group headers (e.g. demo (27))
instead of putting all agents under standalone.
2026-04-09 16:07:07 +08:00
Willie ed924c9193 fix(list): fix tab bar clipped off screen in split layout
Panel height calculation was off by 1 (subtracted 7 but actual
overhead is 8 lines), causing the tab bar to be pushed above the
visible terminal area.
2026-04-09 16:02:05 +08:00
Willie ff1aedfd1a fix(audit): group agents by directory in TUI
auditRepoKey now groups any nested path (e.g. demo/code-reviewer.md)
by its first segment, not just tracked repo prefixes starting with _.
This gives agents the same directory grouping as the Resources page.
2026-04-09 15:41:29 +08:00
Willie 33cbd17ddc fix(audit): show 'No skills/agents' instead of 'No items' in TUI
Set list item name per tab so empty state shows contextual message.
Also align empty state text with left padding matching list title.
2026-04-09 15:39:18 +08:00
Willie 4c0674ddc1 fix(audit): set agentsSourcePath in project mode for TUI tab
Project mode was missing agentsSourcePath assignment, causing
Agents(0) in TUI even when agents exist. Also simplifies the
kind-based source selection to use the existing override at line 217.
2026-04-09 15:38:02 +08:00
Willie 486f13513e fix(audit): exclude _cross-skill from TUI tab counts
Filter out synthetic _cross-skill result before passing to TUI.
Fixes Skills(7) showing when only 6 real skills were scanned.
2026-04-09 15:35:45 +08:00
Willie 12490620b0 fix(ui): audit card icon color follows max severity
Icon/border color now maps to the highest severity finding in the card:
CRITICAL → red, HIGH/MEDIUM → orange, LOW → blue, INFO → gray.
Previously all non-blocked cards used the same orange regardless of
severity, making it impossible to gauge severity at a glance.
2026-04-09 15:29:10 +08:00
Willie e1c6549129 fix(ui): fix audit summary mixing agent counts with finding counts
Summary line now shows only consistent metrics:
- scanned/passed/blocked/with findings (all agent-level)
- total finding count (clearly labeled)
Removed low/info severity counts that were confusing because they
counted findings while adjacent numbers counted agents.
2026-04-09 15:24:44 +08:00
Willie 01a6f662c6 fix(ui): exclude _cross-skill from audit card count and show separately
Cross-skill analysis is a synthetic result, not an actual scanned
resource. Separating it fixes the mismatch between summary counts
(e.g. '4 warnings') and visible card count (was showing 5 cards).
Now shown as a distinct 'Cross-resource analysis' section.
2026-04-09 15:14:57 +08:00
Willie 91eabf3369 feat(ui): cache audit results with React Query
SSE scan results are written to query cache on completion. Navigating
away and back shows cached results instead of requiring a re-scan.
Cache expires after 5 minutes (staleTimes.audit). Per-kind cache keys
ensure skills and agents results are independent.
2026-04-09 15:02:46 +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 353f0cb068 fix(ui): match audit tab style to resources page
Replace the button-style tabs (filled bg, border-2) in AuditPage with
the underline+icon+badge style used by ResourcesPage, TrashPage, and
BatchUninstallPage for visual consistency across tabbed pages.

- Use nav with role=tablist and aria-selected for accessibility
- Add Puzzle/Bot icons matching ResourcesPage tabs
- Show count badge only when data is available (tab.count != null)
- Apply ss-resource-tab class for shared underline transition style
2026-04-09 14:46:02 +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 26c5050347 test(audit): verify agents/skills audit uses correct terminology
TestAudit_AgentsTerminology: ensures 'audit agents' says agent, not skill
TestAudit_SkillsTerminology: ensures default audit says skill, not agent
2026-04-09 14:37:53 +08:00
Willie 833fc86632 feat(ui): add Skills/Agents tab bar to audit page
Tab bar switches between skills and agents audit scans. Each tab
caches results independently. API calls include ?kind parameter.
Display text dynamized for skill/agent context.
2026-04-09 14:36:32 +08:00
Willie 86461ecc7d feat(audit): add Skills/Agents tab switching to TUI
Two-tab TUI following list_tui.go pattern. Tab/Shift+Tab cycles
between Skills and Agents tabs. Initial tab matches CLI argument.
Secondary kind scanned lazily when TUI launches via auditTUIContext.

Also adds agentsSourcePath param to auditInstalled/auditFiltered
and launchAuditTUIWithTabs helper for dual-kind scanning.
2026-04-09 14:31:14 +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 c6f24ab34a feat(audit): dynamize skill/agent terminology in CLI output
Thread kind parameter through auditInstalled, auditFiltered, and
auditSkillByName. All output text now uses Noun() for correct
skill(s)/agent(s) display. Set Result.Kind on all scan results.

Also update audit_project.go callers to pass kindSkills.
2026-04-09 14:23:20 +08:00
Willie baf6b181ae feat(audit): add Kind field to Result, Noun helpers to kind_filter, remove --all flag
- audit.Result gains a Kind string field ("skill"|"agent", set by caller)
  so callers can tag results for display without touching the scan engine
- resourceKindFilter gets Noun(count) and SingularNoun() helpers to produce
  correct singular/plural display nouns per resource type
- audit command switches from parseKindArgWithAll to parseKindArg, dropping
  the --all flag and its two help-text lines; agents subcommand is the way
  to target agents explicitly
2026-04-09 14:18:28 +08:00
Willie 6d1f675a17 fix(sync): strip .md extension in agent filter matching and add tests
FilterAgents matched against FlatName which includes .md (e.g.
"tutor.md"), so user patterns like "tutor" or "team-*" silently
matched nothing. Strip the .md suffix before pattern comparison so
agent filters behave consistently with skill filters.

Add FilterAgents unit tests (include, exclude, combined, nested,
glob, invalid pattern) and integration tests for both filter paths:
- include/exclude config patterns (4 tests)
- .agentignore disabled state (3 tests: explicit, glob, nested)
2026-04-09 14:14:05 +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 d2bf6a0fe3 docs: add agent management to README for v0.19.0
Update tagline, highlights, architecture diagram, and platform table
to reflect agents as a core resource type alongside skills and extras.
2026-04-09 04:18:08 +08:00
Willie 30da704406 fix(sync): pass -g flag to cmdSyncExtras in global --all mode
Without the explicit -g flag, cmdSyncExtras falls back to auto-detection
which picks project mode when cwd contains .skillshare/config.yaml,
causing 'sync --all -g' to display project extras messages instead of
global ones. Mirrors the project-mode path that already passes -p.
2026-04-09 04:11:31 +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 22e7028747 docs: update target/filtering docs for agent filters and metadata.targets
- Add --agent-mode, --add-agent-include/exclude flags to target command docs
- Update filtering reference with agent filter examples and storage paths
- Prefer metadata.targets over top-level targets in all examples
- Note agent filter limitations (merge/copy only, requires agents path)
- Update skill-format docs with metadata.targets precedence note
- Update built-in skill references/targets.md with agent filter examples
2026-04-09 03:14:58 +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 081348d39b refactor(collect): unify skills/agents flow with collectPlan + generics
Replace duplicated runCollectSkills/runCollectAgents (~110 lines of 95%
identical code) with a single runCollectPlan function driven by a
collectPlan struct + toCollectResources[T] generic converter.

Key changes:

- Add collectPlan/collectResources types and runCollectPlan unified flow
- Add toCollectResources[T] generic to bridge typed slices into the
  shared pipeline (scan → display → dry-run → confirm → pull → render)
- Replace fragile err.Error() == "already exists in source" string
  matching with ErrAlreadyExists sentinel error + errors.Is()
- Move os.MkdirAll from per-agent PullAgent to PullAgents (call once)
- Add FindLocalAgents/PullAgent/PullAgents to match FindLocalSkills API
- Add target selection, --force/--dry-run/--json support for agent collect
- Add integration tests for agent collect (target filter, dry-run, force,
  JSON, oplog, project mode)
- Update collect.md, agents.md, ui.md docs for agent collect support
2026-04-09 00:36:39 +08:00
Willie 4426ca5db7 fix: resolve macOS /var → /private/var symlink in agent sync test
TestSyncAgents_MergeMode_NestedSameBasename_IsStable compared raw
symlink targets against t.TempDir() paths without EvalSymlinks, causing
false failures on macOS where /var is a symlink to /private/var.
2026-04-08 22:43:50 +08:00
Willie 6e9177aae0 style: fix gofmt alignment in test files 2026-04-08 22:42:35 +08:00
Willie 9eaaae5295 feat(backup): auto backup agents before sync in global and project mode
Add agent auto backup to syncAgentsGlobal and syncAgentsProject so that
agent targets are backed up before destructive sync operations, matching
the existing auto backup behavior for skills.

Previously only 'skillshare sync' (skills path) and 'target remove'
had auto backup for agents (added in 693f75cc). The agent-only sync
paths ('skillshare sync agents' and 'skillshare sync agents -p') had
no auto backup at all.
2026-04-08 22:40:36 +08:00
Willie 693f75cc12 refactor: deduplicate agent path resolution and add agent backup to sync/target
Extract resolveAgentBackupPath() in restore_tui.go to replace 3 identical
inline agent path resolution blocks (~30 lines removed). The new helper
delegates to the canonical resolveAgentTargetPath() with builtin fallback.

Add agent directory backup before sync (backupTargetsBeforeSync) and
before target removal (backupTargets) so agent data is preserved alongside
skill backups. Extract resolveGlobalAgentBackupContextFromCfg to avoid
redundant config.Load() when config is already available.
2026-04-08 22:38:56 +08:00
Willie 36ee2fe15f fix: tone down doctor target colors — only status word is colored
Split status word from detail in displayTargetStatus. Only the status
word (merged/drift/linked) gets color, detail text uses dim. Reduces
the "wall of green" effect in doctor output.
2026-04-08 22:26:18 +08:00
Willie baea54d938 docs: update status, doctor, diff docs for unified agent layout
status.md:
  - Fix synced→merged for agents, add [merge] mode prefix
  - Remove synced from status table
  - Update project mode example

doctor.md:
  - Update example outputs with sub-item format (target name header + skills/agents indented)
  - Add agents source to environment checks table
  - Update targets section description
  - Single-line extras format
  - Remove leading spaces from output examples
2026-04-08 22:25:00 +08:00
Willie 2d1a370fef fix: use merged instead of synced for agent status
Agents use merge mode (symlinks), so show "merged" to be consistent
with the skills status terminology.
2026-04-08 22:21:11 +08:00
Willie 1dbfc84e5f fix: show [merge] mode in agent sub-items for status and doctor
Agents always use merge mode (symlink-per-file). Add [merge] prefix to
agent sub-item detail in status and doctor for consistency with skills.

Also refactor doctor displayTargetStatus to use sub-item format
(target name as header, skills/agents as indented sub-items).
2026-04-08 22:19:20 +08:00
Willie fa08916e3f fix: merge doctor extras check into single line per extra
Combine "source exists" and "targets reachable" into one line:
  ✓ rules: 4 files, 1/1 targets OK
Only show target details when there are unreachable targets.
2026-04-08 22:16:55 +08:00
Willie 6abfa47712 refactor: integrate agent checks into doctor targets section
Move agent target checks from standalone "Checking environment" output
into the "Checking targets" section as indented sub-items under each
target, matching the unified layout from status.

Also fix project mode doctor using wrong agents source path
(was falling back to global instead of project .skillshare/agents/).
2026-04-08 22:16:03 +08:00
Willie 8d909494ee docs: update status.md for unified layout with agents in targets
- Update example output to show new layout (agents as sub-items)
- Remove outdated agents/--all flags from options table
- Fix --json note: now supported in both global and project mode
- Add agents section to JSON output example
- Rewrite project mode example with new format
- Remove fictional "Remote Skills" section
2026-04-08 22:10:10 +08:00
Willie 4a84796160 docs: document agents_source config field
The agents_source field was already implemented but had no
documentation, unlike extras_source which was fully documented.

- Add agents_source to Full Example in configuration.md
- Add dedicated agents_source field reference section
- Add Custom Source Directory section to understand/agents.md
- Note agents_source in Skills vs Agents comparison table
2026-04-08 22:04:15 +08:00
Willie 1ff4360eb5 fix: keep (project) label on Source header only 2026-04-08 22:03:03 +08:00
Willie c6564c25f7 fix: remove leading spaces from ui.Status and Extras output 2026-04-08 22:01:56 +08:00
Willie bc31eb2384 fix: remove leading spaces from target name in status output
Target name now starts at column 0, sub-items indented 2 spaces.
2026-04-08 22:00:24 +08:00
Willie a726e363fc refactor: redesign status output — unified layout with agents in targets
Restructure status command output for both -g and -p modes:

- Remove "(project)" suffix from all section headers (logo already shows it)
- Merge agents source info into Source section alongside skills
- Show agents as sub-items under each target instead of a separate section
- Remove standalone printAgentStatus/printProjectAgentStatus (dead code)
- Simplify cmdStatus: remove kind parameter since status always shows all
- JSON output unchanged (backward compatible)
2026-04-08 21:55:32 +08:00