Skip to content

armgit / chops

Public Imported from GitHub
0

Your AI agent skills, finally organized. A macOS app to browse, edit, and manage skills across Claude Code, Cursor, Codex, Windsurf, and Amp.

Trending browse + local filter for skills registry (#100)

Matt Anderson1b24ebd9187a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2dbe640..8366fc6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
## [Unreleased]
+- Browse Skills now opens to a Trending list of popular skills
+- Faster, broader skill search with an Official-only filter
+
## [1.15.0] - 2026-04-28
- AI Assist now drives your installed Claude and Codex CLIs directly — fewer moving parts, more reliable responses
diff --git a/Chops/Services/SkillRegistry.swift b/Chops/Services/SkillRegistry.swift
index bcedf88..440cdf6 100644
--- a/Chops/Services/SkillRegistry.swift
+++ b/Chops/Services/SkillRegistry.swift
@@ -2,6 +2,10 @@ import Foundation
@Observable
final class SkillRegistry {
+ /// One instance for the app so the trending and GitHub caches last the session,
+ /// not just a single sheet presentation.
+ static let shared = SkillRegistry()
+
var isSearching = false
var searchError: String?
@@ -9,6 +13,9 @@ final class SkillRegistry {
private var treeCache: [String: [String]] = [:] // source@branch -> [SKILL.md paths]
private var branchCache: [String: String] = [:] // source -> default branch
+ // Popular/trending skills, scraped from skills.sh. Cached in memory for the session.
+ private var trendingCache: [RegistrySkill]?
+
// MARK: - Search
struct SearchResponse: Codable {
@@ -17,11 +24,16 @@ final class SkillRegistry {
}
struct RegistrySkill: Identifiable, Codable {
- let id: String
let skillId: String
let name: String
let installs: Int
let source: String
+ let isOfficial: Bool?
+
+ // Derived rather than decoded: the search API sends an `id` field equal to
+ // "<source>/<skillId>", but the trending payload omits it. Computing it keeps
+ // both sources Identifiable without a fragile optional.
+ var id: String { "\(source)/\(skillId)" }
var formattedInstalls: String {
if installs >= 1_000_000 {
@@ -48,6 +60,66 @@ final class SkillRegistry {
return decoded.skills
}
+ // MARK: - Trending / Browse
+
+ /// Fetches the most-installed skills by scraping skills.sh's server-rendered
+ /// trending page (no public JSON API exists for this). The result — ~600 skills
+ /// ranked by install count — is cached for the session and powers instant local
+ /// browse + filtering, which is both faster and broader than the fuzzy search API.
+ func fetchTrending() async throws -> [RegistrySkill] {
+ if let cached = trendingCache { return cached }
+
+ var request = URLRequest(url: URL(string: "https://www.skills.sh/trending")!)
+ // Identify ourselves honestly since we're reading their HTML rather than a JSON API.
+ request.setValue(
+ "Chops/macOS (+https://github.com/Shpigford/chops)",
+ forHTTPHeaderField: "User-Agent"
+ )
+
+ let (data, response) = try await URLSession.shared.data(for: request)
+ guard let http = response as? HTTPURLResponse, http.statusCode == 200,
+ let html = String(data: data, encoding: .utf8) else {
+ throw RegistryError.trendingFailed
+ }
+
+ let skills = Self.parseTrending(html: html)
+ guard !skills.isEmpty else { throw RegistryError.trendingFailed }
+ trendingCache = skills
+ return skills
+ }
+
+ /// Extracts skill objects from the Next.js RSC payload embedded in the trending HTML.
+ /// The payload lives inside JS string literals, so JSON quotes arrive as `\"`; we
+ /// unescape, then pull out every flat `{…"skillId":…}` object and hand it to
+ /// JSONDecoder, which tolerates extra keys and any key order. Page order is
+ /// install-count descending, which we preserve.
+ static func parseTrending(html: String) -> [RegistrySkill] {
+ let unescaped = html.replacingOccurrences(of: "\\\"", with: "\"")
+ let pattern = #/\{[^{}]*"skillId":[^{}]*\}/#
+
+ let decoder = JSONDecoder()
+ var seen = Set<String>()
+ var result: [RegistrySkill] = []
+ for match in unescaped.matches(of: pattern) {
+ let json = String(match.output)
+ guard let skill = try? decoder.decode(RegistrySkill.self, from: Data(json.utf8)) else { continue }
+ if seen.insert(skill.id).inserted {
+ result.append(skill)
+ }
+ }
+ return result
+ }
+
+ /// Case-insensitive substring match across name, skillId, and source.
+ static func filter(_ skills: [RegistrySkill], query: String) -> [RegistrySkill] {
+ guard !query.isEmpty else { return skills }
+ return skills.filter {
+ $0.name.localizedCaseInsensitiveContains(query)
+ || $0.skillId.localizedCaseInsensitiveContains(query)
+ || $0.source.localizedCaseInsensitiveContains(query)
+ }
+ }
+
// MARK: - Content Resolution
func fetchContent(skill: RegistrySkill) async throws -> String {
@@ -238,6 +310,7 @@ final class SkillRegistry {
enum RegistryError: LocalizedError {
case searchFailed
+ case trendingFailed
case treeFetchFailed
case rateLimited
case skillNotFound
@@ -247,6 +320,7 @@ final class SkillRegistry {
var errorDescription: String? {
switch self {
case .searchFailed: "Search request failed"
+ case .trendingFailed: "Could not load trending skills from skills.sh"
case .treeFetchFailed: "Could not fetch repository contents"
case .rateLimited: "GitHub API rate limit reached — try again in a few minutes"
case .skillNotFound: "File not found in repository"
diff --git a/Chops/Views/Shared/RegistrySheet.swift b/Chops/Views/Shared/RegistrySheet.swift
index 1f08f8d..bec86b6 100644
--- a/Chops/Views/Shared/RegistrySheet.swift
+++ b/Chops/Views/Shared/RegistrySheet.swift
@@ -2,9 +2,13 @@ import SwiftUI
struct RegistrySheet: View {
@Environment(\.dismiss) private var dismiss
- @State private var registry = SkillRegistry()
+ private let registry = SkillRegistry.shared
@State private var searchText = ""
@State private var results: [SkillRegistry.RegistrySkill] = []
+ @State private var trending: [SkillRegistry.RegistrySkill] = []
+ @State private var isLoadingTrending = false
+ @State private var trendingError: String?
+ @State private var officialOnly = false
@State private var selectedSkill: SkillRegistry.RegistrySkill?
@State private var skillContent: String?
@State private var selectedAgents: Set<String> = []
@@ -20,6 +24,23 @@ struct RegistrySheet: View {
AgentTarget.installed
}
+ private var isBrowsing: Bool { searchText.count < 2 }
+
+ /// What the list renders: trending when idle, locally-filtered trending plus any
+ /// long-tail API hits when searching. Local matches come first (they're the popular
+ /// ones), API extras fill in skills that aren't in the trending set. The Official
+ /// filter only applies while browsing: the search API doesn't report `isOfficial`,
+ /// so filtering search results would silently drop every long-tail hit.
+ private var visibleSkills: [SkillRegistry.RegistrySkill] {
+ if isBrowsing {
+ return officialOnly ? trending.filter { $0.isOfficial == true } : trending
+ }
+ let local = SkillRegistry.filter(trending, query: searchText)
+ let localIDs = Set(local.map(\.id))
+ let extra = results.filter { !localIDs.contains($0.id) }
+ return local + extra
+ }
+
var body: some View {
VStack(spacing: 0) {
// Header
@@ -64,9 +85,10 @@ struct RegistrySheet: View {
}
}
.frame(width: 560, height: 500)
- .onAppear {
+ .task {
// Pre-select all installed agents
selectedAgents = Set(installedAgents.map(\.id))
+ await loadTrending()
}
.onDisappear {
searchTask?.cancel()
@@ -98,28 +120,58 @@ struct RegistrySheet: View {
debounceSearch(query: newValue)
}
+ // Browse header: section label + Official filter toggle
+ HStack {
+ Text(isBrowsing ? "Trending" : "Results")
+ .font(.caption)
+ .fontWeight(.semibold)
+ .foregroundStyle(.secondary)
+ Spacer()
+ if isBrowsing {
+ Toggle("Official only", isOn: $officialOnly)
+ .toggleStyle(.checkbox)
+ .font(.caption)
+ .controlSize(.small)
+ }
+ }
+ .padding(.horizontal, 20)
+ .padding(.bottom, 8)
+
Divider()
// Results
- if results.isEmpty && (isSearching || searchText.count < 2) {
+ if isBrowsing && isLoadingTrending {
+ Spacer()
+ ProgressView("Loading popular skills…")
+ Spacer()
+ } else if isBrowsing, trending.isEmpty, let trendingError {
ContentUnavailableView {
- Label("Search the Skills Registry", systemImage: "globe")
+ Label("Trending Unavailable", systemImage: "exclamationmark.triangle")
} description: {
- Text("Find and install skills from the open agent skills ecosystem.")
+ Text(trendingError)
+ } actions: {
+ Button("Retry") { Task { await loadTrending() } }
}
.frame(maxHeight: .infinity)
- } else if results.isEmpty && !isSearching && searchText.count >= 2 {
+ } else if visibleSkills.isEmpty && !isSearching {
ContentUnavailableView.search(text: searchText)
.frame(maxHeight: .infinity)
} else {
- List(results) { skill in
+ List(visibleSkills) { skill in
Button {
selectSkill(skill)
} label: {
HStack {
VStack(alignment: .leading, spacing: 3) {
- Text(skill.name)
- .fontWeight(.medium)
+ HStack(spacing: 5) {
+ Text(skill.name)
+ .fontWeight(.medium)
+ if skill.isOfficial == true {
+ Image(systemName: "checkmark.seal.fill")
+ .font(.caption2)
+ .foregroundStyle(.blue)
+ }
+ }
Text(skill.source)
.font(.caption)
.foregroundStyle(.secondary)
@@ -280,6 +332,18 @@ struct RegistrySheet: View {
// MARK: - Actions
+ private func loadTrending() async {
+ guard trending.isEmpty else { return }
+ isLoadingTrending = true
+ trendingError = nil
+ do {
+ trending = try await registry.fetchTrending()
+ } catch {
+ trendingError = error.localizedDescription
+ }
+ isLoadingTrending = false
+ }
+
private func debounceSearch(query: String) {
searchTask?.cancel()
error = nil
diff --git a/README.md b/README.md
index 55d793a..9a52316 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,7 @@ One macOS app to discover, organize, and edit coding agent skills and agents acr
- **Full-text search** — Search across name, description, and content
- **Create new skills & agents** — Generates correct boilerplate per tool
- **Remote servers** — Connect to servers running [OpenClaw](https://openclaw.ai), [Hermes](https://github.com/NousResearch/hermes-agent), or other layouts to discover, browse, and install skills
+- **Skills Discovery** — Browse, search, and install skills directly from the [skills.sh registry](https://skills.sh)
## Prerequisites