forked from FrancyJGLisboa/agent-skills-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
224 lines (194 loc) · 8.15 KB
/
Copy pathinstall.ps1
File metadata and controls
224 lines (194 loc) · 8.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# install.ps1 — Link agent-skill-creator to all detected global platforms (Windows)
#
# For users who already cloned the repo. Creates directory junctions so
# `git pull` in the cloned directory updates all tools automatically.
#
# Usage:
# .\install.ps1 # Link to all detected platforms
# .\install.ps1 -DryRun # Preview without making changes
# .\install.ps1 -Uninstall # Remove all links pointing to this repo
param(
[switch]$DryRun,
[switch]$Uninstall,
[switch]$Help
)
$ErrorActionPreference = "Stop"
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
$SkillName = "agent-skill-creator"
$RepoDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$HomeDir = $env:USERPROFILE
# ---------------------------------------------------------------------------
# Logging helpers
# ---------------------------------------------------------------------------
function Write-Info { param($msg) Write-Host "[INFO] $msg" -ForegroundColor Blue }
function Write-Ok { param($msg) Write-Host "[OK] $msg" -ForegroundColor Green }
function Write-Warn { param($msg) Write-Host "[WARN] $msg" -ForegroundColor Yellow }
function Write-Err { param($msg) Write-Host "[ERROR] $msg" -ForegroundColor Red }
# ---------------------------------------------------------------------------
# Help
# ---------------------------------------------------------------------------
if ($Help) {
Write-Host @"
install.ps1 — Link agent-skill-creator to all detected platforms
USAGE
.\install.ps1 [-DryRun] [-Uninstall] [-Help]
OPTIONS
-DryRun Preview without making changes
-Uninstall Remove all links pointing to this repo
-Help Show this help message
"@
exit 0
}
# ---------------------------------------------------------------------------
# All global platform paths (user-level only)
# ---------------------------------------------------------------------------
function Get-AllPlatformEntries {
return @(
@{ DetectDir = ".claude"; InstallPath = ".claude\skills\$SkillName"; Display = "Claude Code" },
@{ DetectDir = ".copilot"; InstallPath = ".copilot\skills\$SkillName"; Display = "GitHub Copilot" },
@{ DetectDir = ".gemini"; InstallPath = ".gemini\skills\$SkillName"; Display = "Gemini CLI" },
@{ DetectDir = ".kiro"; InstallPath = ".kiro\skills\$SkillName"; Display = "Kiro" },
@{ DetectDir = ".cline"; InstallPath = ".cline\skills\$SkillName"; Display = "Cline" },
@{ DetectDir = ".roo"; InstallPath = ".roo\skills\$SkillName"; Display = "Roo Code" },
@{ DetectDir = ".kilocode"; InstallPath = ".kilocode\skills\$SkillName"; Display = "Kilo Code" },
@{ DetectDir = ".factory"; InstallPath = ".factory\skills\$SkillName"; Display = "Factory Droid" },
@{ DetectDir = ".cursor"; InstallPath = ".cursor\rules\$SkillName"; Display = "Cursor" },
@{ DetectDir = ".config\goose"; InstallPath = ".config\goose\skills\$SkillName"; Display = "Goose" },
@{ DetectDir = ".config\opencode"; InstallPath = ".config\opencode\skills\$SkillName"; Display = "OpenCode" }
)
}
# ---------------------------------------------------------------------------
# Create a directory junction (works without admin)
# ---------------------------------------------------------------------------
function New-SkillLink {
param([string]$Target, [string]$LinkPath)
if ($Target -eq $LinkPath) { return }
$parentDir = Split-Path $LinkPath -Parent
if (-not (Test-Path $parentDir)) {
New-Item -ItemType Directory -Path $parentDir -Force | Out-Null
}
if (Test-Path $LinkPath) {
Remove-Item $LinkPath -Recurse -Force
}
try {
cmd /c mklink /J "`"$LinkPath`"" "`"$Target`"" 2>$null | Out-Null
if (Test-Path $LinkPath) { return }
} catch {}
try {
New-Item -ItemType SymbolicLink -Path $LinkPath -Target $Target -Force | Out-Null
if (Test-Path $LinkPath) { return }
} catch {}
Write-Warn "Junction/symlink failed for $LinkPath - falling back to copy"
Copy-Item -Path $Target -Destination $LinkPath -Recurse -Force
}
# ---------------------------------------------------------------------------
# Check if a path is a junction/symlink pointing to our repo
# ---------------------------------------------------------------------------
function Test-IsOurLink {
param([string]$TestPath)
if (-not (Test-Path $TestPath)) { return $false }
$item = Get-Item $TestPath -Force
if ($item.Attributes -band [System.IO.FileAttributes]::ReparsePoint) {
$target = $item.Target
if ($target -and ($target -eq $RepoDir)) { return $true }
}
return $false
}
# ---------------------------------------------------------------------------
# Uninstall
# ---------------------------------------------------------------------------
function Remove-AllLinks {
Write-Host ""
Write-Host "Uninstalling agent-skill-creator links" -ForegroundColor White
Write-Host ""
# Check canonical location
$canonical = Join-Path $HomeDir ".agents\skills\$SkillName"
if (Test-IsOurLink $canonical) {
if ($DryRun) {
Write-Info "[dry-run] Would remove: $canonical"
} else {
Remove-Item $canonical -Recurse -Force
Write-Ok "Removed: $canonical"
}
}
# Check each platform path
$entries = Get-AllPlatformEntries
foreach ($entry in $entries) {
$dest = Join-Path $HomeDir $entry.InstallPath
if (Test-IsOurLink $dest) {
if ($DryRun) {
Write-Info "[dry-run] Would remove: $dest"
} else {
Remove-Item $dest -Recurse -Force
Write-Ok "Removed: $dest ($($entry.Display))"
}
}
}
if ($DryRun) {
Write-Host ""
Write-Warn "Dry run - no changes made."
} else {
Write-Host ""
Write-Host "Done. Links removed."
}
}
# ---------------------------------------------------------------------------
# Install
# ---------------------------------------------------------------------------
function Install-AllLinks {
Write-Host ""
Write-Host "Agent Skill Creator - Link Installer (Windows)" -ForegroundColor White
Write-Host ""
Write-Info "Source: $RepoDir"
$count = 0
# Always install to canonical location
$canonical = Join-Path $HomeDir ".agents\skills\$SkillName"
if ($DryRun) {
Write-Info "[dry-run] Would link: $canonical -> $RepoDir"
} else {
New-SkillLink -Target $RepoDir -LinkPath $canonical
Write-Ok "Canonical: $canonical"
}
$count++
# Install to each detected global platform
$entries = Get-AllPlatformEntries
foreach ($entry in $entries) {
$detectPath = Join-Path $HomeDir $entry.DetectDir
if (Test-Path $detectPath) {
$dest = Join-Path $HomeDir $entry.InstallPath
if ($DryRun) {
Write-Info "[dry-run] Would link: $dest -> $RepoDir ($($entry.Display))"
} else {
New-SkillLink -Target $RepoDir -LinkPath $dest
Write-Ok "Linked for $($entry.Display) -> $dest"
}
$count++
}
}
# Summary
Write-Host ""
Write-Host "Done!" -ForegroundColor Green
Write-Host ""
if ($DryRun) {
Write-Warn "Dry run - no changes made."
Write-Host ""
} else {
Write-Host " Links point to: $RepoDir"
Write-Host " Run 'git pull' from that directory to update all tools."
Write-Host ""
}
Write-Host "How to use:" -ForegroundColor White
Write-Host " Open your AI agent and type:"
Write-Host " /agent-skill-creator <describe your workflow>"
Write-Host ""
}
# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
if ($Uninstall) {
Remove-AllLinks
} else {
Install-AllLinks
}