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.

feat: Add "Make Global" action to convert tool-specific skills to global (#83)

Josh Pigford6f059221a4d7
diff --git a/Chops/Models/Skill.swift b/Chops/Models/Skill.swift
index 6790de5..6f6d70d 100644
--- a/Chops/Models/Skill.swift
+++ b/Chops/Models/Skill.swift
@@ -252,6 +252,71 @@ final class Skill {
return Array(targets).sorted()
}
+ var canMakeGlobal: Bool {
+ itemKind == .skill
+ && isDirectory
+ && !isRemote
+ && !isReadOnly
+ && !toolSources.contains(.agents)
+ }
+
+ func makeGlobal() throws {
+ let fm = FileManager.default
+ let home = fm.homeDirectoryForCurrentUser.path
+
+ let currentSkillDir = URL(fileURLWithPath: filePath)
+ .deletingLastPathComponent()
+ let skillDirName = currentSkillDir.lastPathComponent
+
+ let agentsSkillsDir = "\(home)/.agents/skills"
+ let canonicalDir = "\(agentsSkillsDir)/\(skillDirName)"
+ let canonicalFile = "\(canonicalDir)/SKILL.md"
+
+ guard !fm.fileExists(atPath: canonicalDir) else {
+ throw MakeGlobalError.alreadyExists(skillDirName)
+ }
+
+ try fm.createDirectory(atPath: agentsSkillsDir, withIntermediateDirectories: true)
+
+ // Move original directory to canonical location
+ let originalDir = currentSkillDir.path
+ try fm.moveItem(atPath: originalDir, toPath: canonicalDir)
+
+ // Replace original with symlink to canonical
+ try fm.createSymbolicLink(atPath: originalDir, withDestinationPath: canonicalDir)
+
+ // Create symlinks from all installed agents
+ var newInstalledPaths = [canonicalFile, "\(originalDir)/SKILL.md"]
+ var newToolSources: [ToolSource] = [.agents]
+
+ if let originalTool = toolSources.first, originalTool != .agents {
+ newToolSources.append(originalTool)
+ }
+
+ for agent in AgentTarget.installed {
+ let agentDir = "\(agent.expandedSkillsDir)/\(skillDirName)"
+ if !fm.fileExists(atPath: agentDir) {
+ try fm.createDirectory(atPath: agent.expandedSkillsDir, withIntermediateDirectories: true)
+ try fm.createSymbolicLink(atPath: agentDir, withDestinationPath: canonicalDir)
+ }
+ let agentFilePath = "\(agentDir)/SKILL.md"
+ if !newInstalledPaths.contains(agentFilePath) {
+ newInstalledPaths.append(agentFilePath)
+ }
+ if let toolSource = ToolSource.allCases.first(where: { $0.globalPaths.contains(agent.expandedSkillsDir) }) {
+ if !newToolSources.contains(toolSource) {
+ newToolSources.append(toolSource)
+ }
+ }
+ }
+
+ resolvedPath = canonicalFile
+ filePath = canonicalFile
+ installedPaths = newInstalledPaths
+ toolSources = newToolSources
+ isGlobal = true
+ }
+
func deleteFromDisk() throws {
let fm = FileManager.default
@@ -267,6 +332,17 @@ final class Skill {
}
}
+enum MakeGlobalError: LocalizedError {
+ case alreadyExists(String)
+
+ var errorDescription: String? {
+ switch self {
+ case .alreadyExists(let name):
+ return "A global skill named \"\(name)\" already exists."
+ }
+ }
+}
+
enum SkillDeletionError: LocalizedError {
case notDeletable(String)
diff --git a/Chops/Views/Detail/SkillDetailView.swift b/Chops/Views/Detail/SkillDetailView.swift
index 79ba6fd..e81d1b9 100644
--- a/Chops/Views/Detail/SkillDetailView.swift
+++ b/Chops/Views/Detail/SkillDetailView.swift
@@ -62,14 +62,20 @@ private struct ClickableCursorOverlay: NSViewRepresentable {
struct SkillDetailView: View {
private enum ActiveAlert: Identifiable {
case confirmDelete
+ case confirmMakeGlobal
case deleteError(String)
+ case makeGlobalError(String)
var id: String {
switch self {
case .confirmDelete:
return "confirm-delete"
+ case .confirmMakeGlobal:
+ return "confirm-make-global"
case .deleteError(let message):
return "delete-error-\(message)"
+ case .makeGlobalError(let message):
+ return "make-global-error-\(message)"
}
}
}
@@ -185,9 +191,28 @@ struct SkillDetailView: View {
.help("Delete \(skill.displayTypeName)")
}
}
+ if skill.canMakeGlobal {
+ ToolbarItem(placement: .primaryAction) {
+ Button {
+ activeAlert = .confirmMakeGlobal
+ } label: {
+ Image(systemName: "globe")
+ }
+ .help("Make Global")
+ }
+ }
}
.alert(item: $activeAlert) { alert in
switch alert {
+ case .confirmMakeGlobal:
+ return Alert(
+ title: Text("Make \"\(skill.name)\" Global?"),
+ message: Text("This will move the skill to ~/.agents/skills/ and symlink it to all installed agents."),
+ primaryButton: .default(Text("Make Global")) {
+ makeSkillGlobal()
+ },
+ secondaryButton: .cancel()
+ )
case .confirmDelete:
return Alert(
title: Text("Delete \(skill.displayTypeName)?"),
@@ -203,6 +228,12 @@ struct SkillDetailView: View {
message: Text(message),
dismissButton: .default(Text("OK"))
)
+ case .makeGlobalError(let message):
+ return Alert(
+ title: Text("Make Global Failed"),
+ message: Text(message),
+ dismissButton: .default(Text("OK"))
+ )
}
}
}
@@ -219,6 +250,15 @@ struct SkillDetailView: View {
.padding(16)
}
+ private func makeSkillGlobal() {
+ do {
+ try skill.makeGlobal()
+ try? modelContext.save()
+ } catch {
+ activeAlert = .makeGlobalError(error.localizedDescription)
+ }
+ }
+
private func deleteSkill() {
guard !skill.isReadOnly else { return }
do {
diff --git a/Chops/Views/Sidebar/SkillListView.swift b/Chops/Views/Sidebar/SkillListView.swift
index f47850e..bf8cd1c 100644
--- a/Chops/Views/Sidebar/SkillListView.swift
+++ b/Chops/Views/Sidebar/SkillListView.swift
@@ -4,14 +4,20 @@ import SwiftData
struct SkillListView: View {
private enum ActiveAlert: Identifiable {
case confirmDelete(Skill)
+ case confirmMakeGlobal(Skill)
case deleteError(String)
+ case makeGlobalError(String)
var id: String {
switch self {
case .confirmDelete(let skill):
return "confirm-delete-\(skill.filePath)"
+ case .confirmMakeGlobal(let skill):
+ return "confirm-make-global-\(skill.filePath)"
case .deleteError(let message):
return "delete-error-\(message)"
+ case .makeGlobalError(let message):
+ return "make-global-error-\(message)"
}
}
}
@@ -115,6 +121,11 @@ struct SkillListView: View {
skill.isFavorite.toggle()
try? modelContext.save()
}
+ if skill.canMakeGlobal {
+ Button("Make Global") {
+ activeAlert = .confirmMakeGlobal(skill)
+ }
+ }
if !allCollections.isEmpty {
Menu("Collections") {
ForEach(allCollections) { collection in
@@ -148,6 +159,15 @@ struct SkillListView: View {
}
}
+ private func makeSkillGlobal(_ skill: Skill) {
+ do {
+ try skill.makeGlobal()
+ try? modelContext.save()
+ } catch {
+ activeAlert = .makeGlobalError(error.localizedDescription)
+ }
+ }
+
private func deleteSkill(_ skill: Skill) {
guard !skill.isReadOnly else { return }
do {
@@ -238,6 +258,15 @@ struct SkillListView: View {
}
.alert(item: $activeAlert) { alert in
switch alert {
+ case .confirmMakeGlobal(let skill):
+ return Alert(
+ title: Text("Make \"\(skill.name)\" Global?"),
+ message: Text("This will move the skill to ~/.agents/skills/ and symlink it to all installed agents."),
+ primaryButton: .default(Text("Make Global")) {
+ makeSkillGlobal(skill)
+ },
+ secondaryButton: .cancel()
+ )
case .confirmDelete(let skill):
return Alert(
title: Text("Delete \(skill.displayTypeName)?"),
@@ -253,6 +282,12 @@ struct SkillListView: View {
message: Text(message),
dismissButton: .default(Text("OK"))
)
+ case .makeGlobalError(let message):
+ return Alert(
+ title: Text("Make Global Failed"),
+ message: Text(message),
+ dismissButton: .default(Text("OK"))
+ )
}
}
.overlay {