-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.ps1
More file actions
128 lines (113 loc) · 3.62 KB
/
Copy pathinstall.ps1
File metadata and controls
128 lines (113 loc) · 3.62 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
<#
.SYNOPSIS
Install the Helm skill into a coding agent's skills directory.
.DESCRIPTION
SKILL.md is an agent-neutral format, so the same folder works in Codex,
Cursor, OpenCode, Claude Code and anything else that reads Agent Skills.
All this script does is put skills\helm where a given agent looks for it.
.EXAMPLE
.\install.ps1 # -> ~\.agents\skills (the shared location)
.EXAMPLE
.\install.ps1 codex cursor # -> that agent's own directory as well
.EXAMPLE
.\install.ps1 -Copy # copy instead of a junction
.EXAMPLE
.\install.ps1 -Uninstall # remove whatever this script installed
.EXAMPLE
.\install.ps1 -List # show where Helm is currently installed
#>
[CmdletBinding()]
param(
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $Agents,
[switch] $Copy,
[switch] $Uninstall,
[switch] $List
)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
$src = Join-Path $root 'skills\helm'
$all = @('agents', 'codex', 'cursor', 'opencode', 'claude', 'project')
function Get-TargetDir([string] $name) {
switch ($name) {
'agents' { return (Join-Path $HOME '.agents\skills') }
'codex' {
$codexHome = $env:CODEX_HOME
if (-not $codexHome) { $codexHome = Join-Path $HOME '.codex' }
return (Join-Path $codexHome 'skills')
}
'cursor' { return (Join-Path $HOME '.cursor\skills') }
'opencode' {
$cfg = $env:XDG_CONFIG_HOME
if (-not $cfg) { $cfg = Join-Path $HOME '.config' }
return (Join-Path $cfg 'opencode\skills')
}
'claude' { return (Join-Path $HOME '.claude\skills') }
'project' { return (Join-Path (Get-Location) '.agents\skills') }
default { throw "unknown agent: $name (choose from: $($all -join ', '))" }
}
}
function Test-IsLink([string] $path) {
$item = Get-Item -LiteralPath $path -Force
return [bool]($item.Attributes -band [IO.FileAttributes]::ReparsePoint)
}
if ($List) {
foreach ($name in $all) {
$dest = Join-Path (Get-TargetDir $name) 'helm'
if (Test-Path -LiteralPath $dest) {
if (Test-IsLink $dest) { $kind = 'linked' } else { $kind = 'copied' }
' {0,-9} {1} ({2})' -f $name, $dest, $kind
}
}
return
}
$targets = $Agents | Where-Object { $_ }
if (-not $targets) { $targets = @('agents') }
foreach ($name in $targets) { Get-TargetDir $name | Out-Null }
if (-not (Test-Path -LiteralPath (Join-Path $src 'SKILL.md'))) {
throw "no skill found at $src"
}
foreach ($name in $targets) {
$dir = Get-TargetDir $name
$dest = Join-Path $dir 'helm'
if ($Uninstall) {
if (Test-Path -LiteralPath $dest) {
Remove-Item -LiteralPath $dest -Recurse -Force
"removed $dest"
}
else {
"not there $dest"
}
continue
}
if (-not (Test-Path -LiteralPath $dir)) {
New-Item -ItemType Directory -Path $dir -Force | Out-Null
}
if (Test-Path -LiteralPath $dest) {
Remove-Item -LiteralPath $dest -Recurse -Force
}
# A junction, unlike a symlink, needs no administrator rights and no
# developer mode -- and it follows a later git pull, which a copy does not.
$linked = $false
if (-not $Copy) {
try {
New-Item -ItemType Junction -Path $dest -Target $src | Out-Null
$linked = $true
}
catch {
$linked = $false
}
}
if ($linked) {
"linked $dest -> $src"
}
else {
Copy-Item -LiteralPath $src -Destination $dest -Recurse -Force
"copied $dest"
if (-not $Copy) { " (junction unavailable; re-run this script after a git pull)" }
}
}
if (-not $Uninstall) {
''
'Restart the agent, then ask it what coding agents are installed on this machine.'
}