Commit Graph
13 Commits
Author SHA1 Message Date
Willie efcc3e6f61 fix(update): honour installed branch in batch update and web UI check/update
Skills installed from a non-default branch record that branch in metadata,
but the grouped update path (update --all) cloned the remote default branch,
so the skills were either downgraded or reported as removed upstream and
pruned. The web UI update and check handlers had the same gap, comparing
against the remote HEAD instead of the installed branch.

Group batch updates and web UI checks by URL+branch, pass the branch through
to the clone, and resolve remote tree hashes for that branch as well.

Refs #268
2026-09-02 13:08:40 +08:00
Willie 7e30699eaa feat: add tracked agent repo discovery and install support
- DiscoveredResource gains RepoRelPath and Targets fields
- AgentKind.Discover populates RepoRelPath via findTrackedRepoRelPath
- AgentCheckResult gains RepoPath and dirty status for tracked repos
- InferTrackedKind auto-detects pure-agent repos for --track install
- TrackedRepoResult reports AgentCount and Agents list
2026-04-10 02:04:55 +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 49d33938a2 feat(sync): skip extras 'agents' targets that overlap with agents sync
When extras has an entry named 'agents' whose target paths overlap with
the resolved agent target paths from targets.yaml, the extras targets
are skipped with a warning — the agents sync system takes priority.

Detection uses dual conditions: extras name == 'agents' AND resolved
path overlap. Non-'agents' extras targeting agent paths are unaffected.
Agents source must exist with actual files; empty/missing source means
no overlap (extras sync normally).

Also fixes:
- CheckAgents now recurses into subdirectories via resource.AgentKind
- update agents resolves nested agent names via filepath.Base
- filterAgentCheckResults matches both full path and basename
2026-04-07 22:35:59 +08:00
Willie 2cb830f736 feat(check): add remote update detection for tracked agents
Add RepoURL field to AgentCheckResult. Add EnrichAgentResultsWithRemote()
that batches remote HEAD hash checks via ParallelCheckURLs and marks
agents as 'update_available' when remote has newer commits than the
installed version.
2026-04-07 18:05:40 +08:00
Willie 949fd444e0 feat(check,trash): add agent drift detection and agent trash support
Add CheckAgents() in internal/check/ that scans agents source directory,
reads per-agent metadata (<name>.skillshare-meta.json), and compares
file hashes to detect drift. Statuses: up_to_date, drifted, local, error.

Add agent trash functions in internal/trash/:
- AgentTrashDir() / ProjectAgentTrashDir() for agent-specific trash paths
- MoveAgentToTrash() moves agent .md file + metadata to timestamped
  trash subdirectory with rename-or-copy-then-delete fallback

6 unit tests for agent check covering empty dir, local agent, hash
match, drift detection, nonexistent dir, and non-md filtering.
2026-04-07 18:05:40 +08:00
Willie db69638e30 feat(install): project mode --branch support and branch display in check
- Set source.Branch in project install path
- Sync branch in project reconcile
- Add Branch to checkRepoResult and RepoCheckOutput for JSON/display
- Read current branch from tracked repos in check

Ref: #90
2026-04-01 00:32:49 +08:00
Willie 354db51928 feat(check): branch-aware remote ref comparison and registry rebuild
- Add GetRemoteRefHash/WithAuth/WithEnv to internal/git/info.go:
  uses git ls-remote with refs/heads/<branch> when branch is set,
  falls back to HEAD when branch is empty
- Add Branch field to URLCheckInput and URLCheckOutput in check/parallel.go;
  ParallelCheckURLs dispatches to GetRemoteRefHashWithAuth when Branch is set
- check.go: group skills by RepoURL@branch composite key so skills on
  different branches of the same repo are checked against the correct ref;
  urlHashMap keyed by same composite key for correct broadcast
- install_config.go (InstallFromConfig): propagate SkillEntryDTO.Branch
  into Source.Branch for both plain and tracked skill phases so registry
  rebuild (install --from-config) respects the recorded branch
2026-04-01 00:32:49 +08:00
Willie 117b319050 feat(check): per-skill tree hash comparison for precise update detection
Previously `skillshare check` compared repo-level commit hashes, causing
all skills from a registry repo to show "update_available" whenever any
commit was pushed — even if the individual skill's files were unchanged.

Now each skill records its git tree hash (subdir-level SHA) at install
time. During check, a three-tier comparison is used:

1. Fast path: commit hash matches → up_to_date (zero extra cost)
2. Tree hash path: blobless fetch (~150KB) + batch ls-tree → per-skill
   comparison; unchanged subdirs stay up_to_date
3. Fallback: no tree hash (old installs) → commit comparison (unchanged)

Also fixes pterm progress bar printing twice when it auto-stops at 100%.
2026-02-25 07:02:54 +08:00
Willie 846bedb630 feat(check): add ParallelCheckURLs for deduped ls-remote 2026-02-25 07:02:54 +08:00
Willie 662dca58b8 fix(check): handle IsDirty error, improve test coverage
- Return early with error status when git.IsDirty fails instead of
  silently ignoring the error, which could mask real issues
- Add TestParallelCheckRepos_NilCallback for nil callback with real inputs
- Add index alignment assertions to TestParallelCheckRepos_CallbackCount
2026-02-25 07:02:54 +08:00
Willie 2947617d1e feat(check): add ParallelCheckRepos with bounded semaphore
Introduce internal/check package with ParallelCheckRepos that checks
multiple tracked repos concurrently using an 8-worker semaphore pattern
(matching audit/parallel.go). Each repo is checked for dirty state and
behind count via internal/git. Includes types for future URL-based
remote hash probing.
2026-02-25 07:02:54 +08:00