Repository navigation
Expand file tree
/
Copy pathinstall.ps1
More file actions
55 lines (49 loc) · 2.73 KB
/
Copy pathinstall.ps1
File metadata and controls
55 lines (49 loc) · 2.73 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
# spec-sonar → ~/.claude/skills 安裝器(PowerShell 版,與 install.sh 等價)
#
# 為什麼需要這支:見 install.sh 檔頭。摘要:audit-existing-project 的兩個 reference 檔
# 在 repo 裡不在 skill 資料夾內(modes/ 與 tools/),安裝時要搬家 —— 所以不能用 symlink,
# 也因此在這支腳本出現前靠人手做、全域副本會悄悄落後正本。
#
# 用法: pwsh -File install.ps1 # 安裝/更新全部三支
# pwsh -File install.ps1 -Check # 只比對差異、不寫入(exit 1 = 有漂移)
param([switch]$Check)
$ErrorActionPreference = 'Stop'
$SRC = Split-Path -Parent $MyInvocation.MyCommand.Path
$DEST = if ($env:CLAUDE_SKILLS_DIR) { $env:CLAUDE_SKILLS_DIR } else { Join-Path $HOME '.claude\skills' }
$script:drift = 0
function Place($from, $to) {
if (-not (Test-Path $from)) { Write-Output " X 缺來源檔:$from"; $script:drift = 1; return }
if ($Check) {
# 換行符正規化後再比(理由同 install.sh:否則恆報一次假漂移)
$norm = { param($p) (Get-Content $p -Raw) -replace "`r`n", "`n" }
$same = (Test-Path $to) -and ((& $norm $from) -eq (& $norm $to))
if ($same) { Write-Output " OK $(Split-Path $to -Leaf)" }
else { Write-Output " !! 漂移/缺少:$to"; $script:drift = 1 }
} else {
$dir = Split-Path $to -Parent
if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Force -Path $dir | Out-Null }
Copy-Item $from $to -Force
Write-Output " -> $to"
}
}
Write-Output "spec-sonar skills $(if ($Check) {'差異檢查'} else {'安裝'}) → $DEST"
foreach ($name in @('audit-existing-project', 'goal-decomposer', 'idea-to-spec')) {
Write-Output "[$name]"
Place (Join-Path $SRC "skills\$name\SKILL.md") (Join-Path $DEST "$name\SKILL.md")
$refDir = Join-Path $SRC "skills\$name\references"
if (Test-Path $refDir) {
foreach ($f in Get-ChildItem $refDir -File) {
Place $f.FullName (Join-Path $DEST "$name\references\$($f.Name)")
}
}
}
# 特例:audit-existing-project 的 references 來自 repo 其他目錄(安裝時搬家)
Write-Output "[audit-existing-project · 轉換件]"
Place (Join-Path $SRC 'modes\audit-mode.md') (Join-Path $DEST 'audit-existing-project\references\audit-mode.md')
Place (Join-Path $SRC 'tools\project-scanner.py') (Join-Path $DEST 'audit-existing-project\references\project-scanner.py')
if ($Check) {
if ($script:drift -eq 0) { Write-Output "OK 全部與正本一致" } else { Write-Output "!! 有漂移 —— 跑 pwsh -File install.ps1 重新安裝" }
exit $script:drift
}
Write-Output "OK 完成。這三支 skill 現在會在 Claude Code 自動觸發。"
Write-Output " 之後正本有更動 → 重跑本腳本;想先看差異 → pwsh -File install.ps1 -Check"