Commit Graph
641 Commits
Author SHA1 Message Date
Willie 50b0aba714 fix(install): install orchestrator children as independent skills
An orchestrator repository containing a root SKILL.md together with
child SKILL.md directories (e.g. iOfficeAI/OfficeCLI) previously
installed as a single bundled directory that mirrored the git clone:
copying the root dragged every child skill dir into it, and children
marked selected were silently skipped as "included in parent" while
their computed dest paths were never written to.

Make each discovered skill a first-class install:

- New copyDirExcluding() skips subdirectories by slash-normalized
  relative path, so a skill directory is copied without duplicating
  any nested skill that is itself being installed elsewhere.
- installFromDiscoveryImpl computes the descendant skill paths of the
  skill currently being copied and passes them as excludes. For the
  root of an orchestrator repo this drops every child skill dir; for
  a non-root skill it drops any sub-skill nested inside it.
- installSelectedSkills stops skipping children after the root is
  installed. The existing dest-path logic already places each child
  under <parentName>/<childName>, so the children are written as
  siblings to the root install.

After the fix, a multi-skill repo with N skills produces N independent
installed directories discoverable by sync, updatable individually.

Refs: #124
2026-04-11 00:52:29 +08:00
Willie f3176da208 fix(install): include root skill in individual selection for orchestrator repos
When a repo contains both a root SKILL.md and child skills, picking
"Select individual skills" previously excluded the root entirely, so
the orchestrator skill could never be installed from the multi-select
UI — users had to resort to --name as a workaround.

Include the root skill in the individual selection list (listed first)
so it is visible and selectable alongside its children.

Refs: #124
2026-04-11 00:43:49 +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 ce7c7d154d fix(list): group TUI entries by tracked repo root and local top dir
The list TUI had two grouping bugs:

1. Local nested skills (e.g. mma/agent-browser, mma/docker-expert) were
   lumped into the "standalone" group because buildGroupedItems keyed on
   RepoName, which is empty for non-tracked skills.

2. Agents deep inside a tracked repo (e.g. _vijay-agents/agents/core/x.md,
   _vijay-agents/agents/specialized/python/y.md) were split into separate
   groups per sub-directory. discoverAndBuildAgentEntries set RepoName to
   filepath.Dir(RelPath), producing keys like '_vijay-agents/agents/core'
   instead of the tracked repo root.

Fix:

- discoverAndBuildAgentEntries now uses d.RepoRelPath (already computed
  by agent discovery) so tracked agents share one visual group regardless
  of nesting depth. This also corrects a pre-existing mis-count where
  local nested agents were counted as tracked in the summary footer.

- Add skillTopGroup() helper in list_tui_filter.go: tracked → RepoName;
  non-tracked nested → first RelPath segment; flat → "" (standalone).

- buildGroupedItems now keys on skillTopGroup() so local nested groups
  (mma/*) render as their own bucket instead of standalone.

- sortSkillEntries default sort now groups by top-level bucket first,
  placing standalone last, so buildGroupedItems sees contiguous blocks.

- Remove 'if opts.SortBy != ""' gating in both global list paths: sort
  must always run to guarantee the TUI grouping invariant.

Tests: 4 new unit tests cover local nested grouping, deep tracked agents,
skillTopGroup cases, and the top-group-aware sort order.
2026-04-10 19:00:33 +08:00
Willie ea2abf0a68 refactor(tui): delete legacy tui_colors.go and add doctor theme check
Finishes the theme system migration:

- Deletes cmd/skillshare/tui_colors.go entirely (~152 lines). The
  tc struct and tcSevStyle/riskLabelStyle/formatRiskBadgeLipgloss
  helpers are all replaced by equivalents in internal/theme.
- Migrates last 6 helper-function callers in audit_tui.go and
  search_tui.go.
- Adds checkTheme() to doctor.go with warning status on fallback,
  wired into runDoctorChecks() after checkSymlinkSupport.
- Adds theme.Get() call early in main() so OSC 11 probe overhead
  happens at startup, not during TUI rendering.

After this commit:
- grep 'lipgloss.Color(' cmd/skillshare/ returns only the hardcoded
  brand yellow #D4D93C (logo color)
- grep 'tc.|ac.|lc.' cmd/skillshare/ returns only loop variables
- Full build and test suite pass

Refs: #125
2026-04-10 16:50:08 +08:00
Willie 8955ce7813 refactor(tui): migrate remaining TUIs to theme package
Replaces all tc.* references in 26 files under cmd/skillshare/
with the new internal/theme API. Also removes the file-local ac
struct from audit_tui.go and the lc struct from log_tui.go.

Files touched: analyze_tui.go, analyze_tui_item.go, audit_render.go,
audit_rules_tui.go, audit_tui.go, checklist_tui.go, diff_tui.go,
extras.go, extras_init_tui.go, extras_list_tui.go,
extras_list_tui_item.go, hub.go, install_prompt_tui.go, log_tui.go,
new_tui.go, restore_tui.go, search_batch.go, search_tui.go,
sync.go, sync_agents.go, sync_parallel.go, target_agents_test.go,
target_list_tui.go, trash_tui.go, tui_helpers.go.

tui_colors.go (the tc struct definition file) is kept for now; it
will be deleted in the final cleanup commit along with the doctor
integration and main.go early init call.

Refs: #125
2026-04-10 15:24:18 +08:00
Willie 47fe1b8318 refactor(tui): migrate list TUIs to theme package
Replaces all tc.* references in list_tui.go, list_tui_item.go, and
list_tui_content.go with the new internal/theme API. Also fixes the
hardcoded lipgloss.Color("15") at list_tui_item.go:296 — the root
cause of issue #125.

NOTE: The codebase does not compile at this commit alone because
other TUIs still reference the tc struct. The full build is
restored in commit 4 of this PR (migration of remaining TUIs and
deletion of legacy palettes). Treat this PR as one atomic change.

Fixes #125
2026-04-10 14:36:22 +08:00
Willie 49dcbd01c8 fix(doctor): exclude disabled agents from drift count
Doctor was passing all discovered agents (including those disabled
via .agentignore) to the agent target drift check, inflating the
expected count. This caused false drift warnings like '33/66 agents
linked' when the 33 missing agents were actually ignored.

Filter with resource.ActiveAgents() before passing to
checkAgentTargetInline, matching the pattern used by sync and
all server handlers.
2026-04-10 03:42:18 +08:00
Willie 40dca838db fix(cli): agent diff drift detection and sync prune when source empty
- diff_agents: detect symlink drift, local copy blocking, fix prune count
- sync_agents: continue to prune targets when source has no agents
  instead of returning early, matching skills behavior
2026-04-10 02:05:06 +08:00
Willie b23425aafd feat(cli): tracked agent repo support in install, check, update, doctor
- install: --agent + --track validation, InferTrackedKind dispatch
- install_handlers: agent kind routing, renderTrackedAgentRepoMeta
- check: enrich tracked agents with remote status (update_available, dirty)
- update_agents: batchUpdateAgents with tracked repo git pull
- list: agent repo URL fallback via RepoRelPath
- doctor: filter-aware agent count, project mode version check
2026-04-10 02:05:01 +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 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 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 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 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 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 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 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 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 1ff4360eb5 fix: keep (project) label on Source header only 2026-04-08 22:03:03 +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
Willie 89d40afd55 feat(diff-tui): single-line items with group headers
- Switch delegate to single-line mode (showDesc: false) with ▌ prefix bar
- Merge description info into Title() for both target and extra items
- Add ─ Targets (N) ── and ─ Extras (N) ── group headers with counts
- Add spacer row between Targets and Extras sections
- Skip separator on initial selection and filter reset
- Update status test to reflect always-show-both behavior
2026-04-08 21:40:09 +08:00
Willie 525ae0b9f4 refactor: status always shows both skills and agents
Remove kind filter (agents/--all) from status command — it now defaults
to showing everything, matching diff behavior. Status is a read-only
overview command; users expect the full picture without extra flags.

- Remove parseKindArgWithAll from cmdStatus, hardcode kindAll
- Update help text and usage examples
- Simplify tests: merge agents/all variants into default tests
- Update runbook steps 9-11 → 9-10
2026-04-08 21:40:03 +08:00
Willie eadfcf3d6f refactor: replace positional "all" keyword with --all flag for kind filter
Migrate from "ss list all" syntax to "ss list --all" across all commands
that support kind filtering (list, sync, status, check, audit, backup,
restore, trash).

- Remove "all" as a recognized positional keyword in parseKindArg
- Add extractAllFlag and parseKindArgWithAll helpers
- Update help text, usage examples, and runbook
- Update all integration tests to use --all flag
2026-04-08 21:31:41 +08:00
Willie 8dff3dfcc9 refactor: pass trash dir to cmdUninstallAgents and update help text
- Accept trashBase parameter in cmdUninstallAgents instead of
  hardcoding AgentTrashDir(), enabling correct project vs global
  trash routing from all call sites
- Use displayName (not internal t.Name) when trashing agents
- Sort list by RelPath instead of Name so grouped skills stay together
- Update printUsage to reflect agent support across commands
  (list, sync, check, update, diff, collect, trash, audit)
2026-04-08 20:57:44 +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 27f352e5d2 fix: resolve relative paths in project mode extras and agent targets
Extract resolveProjectPath() helper to centralize ~ expansion and
relative-to-project-root resolution. Fixes extras sync and agent
target path resolution in project mode when paths are relative.

Add integration tests for sync --all agents/extras overlap detection
in both global and project modes.
2026-04-08 18:35:36 +08:00
Willie 585b3cdde7 feat(tui): add [S]/[A] kind prefix in All tab and group by kind
In the All (resources) tab:
- Show [S] prefix for skills and [A] prefix for agents
- Group items by kind: skills first, agents second
- Each kind block preserves original repo grouping with
  kind-prefixed headers (e.g. 'Skills · standalone')

In Skills/Agents tabs: no prefix shown (context is clear).

Detail panel now shows 'Skill' or 'Agent' kind label in the
status bits alongside remote/local/tracked.

Spinner message is now tab-aware: 'Loading resources/skills/agents'.

Implementation uses a shared *listTab pointer between the model
and delegate so the delegate reads current tab state without
needing SetDelegate() on every tab switch.
2026-04-08 18:35:17 +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 b5266574a7 fix: rewrite agent update to use discovery + single-file installer
reinstallAgent previously called install.Install() which expects
directory-based skill installation. Agent sources point to .md files,
so the subdir resolver rejected them.

Now uses DiscoverFromGit/DiscoverFromGitSubdir + InstallAgentFromDiscovery
which correctly handles single-file agent copies. Also preserves the
original repo subdir scope for monorepo installs and reconstructs the
correct destination subdirectory for grouped agents.
2026-04-08 16:35:35 +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