-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
77 lines (67 loc) · 2.91 KB
/
Copy pathinstall.ps1
File metadata and controls
77 lines (67 loc) · 2.91 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
# Claude Code Notify - One-click installer
# Run: powershell -ExecutionPolicy Bypass -File install.ps1
$ErrorActionPreference = "Stop"
$scriptsDir = "$env:USERPROFILE\.claude\scripts"
$settingsFile = "$env:USERPROFILE\.claude\settings.json"
$srcDir = "$PSScriptRoot\src"
Write-Host "=== Claude Code Notify Installer ===" -ForegroundColor Cyan
Write-Host ""
# 1. Copy scripts
Write-Host "[1/4] Copying scripts to $scriptsDir ..."
New-Item -ItemType Directory -Path $scriptsDir -Force | Out-Null
Copy-Item "$srcDir\notify-permission.ps1" $scriptsDir -Force
Copy-Item "$srcDir\notify-stop.ps1" $scriptsDir -Force
Copy-Item "$srcDir\focus-terminal.vbs" $scriptsDir -Force
Copy-Item "$srcDir\register-protocol.ps1" $scriptsDir -Force
Write-Host " OK" -ForegroundColor Green
# 2. Register claude-focus:// protocol
Write-Host "[2/4] Registering claude-focus:// protocol ..."
& "$scriptsDir\register-protocol.ps1"
Write-Host " OK" -ForegroundColor Green
# 3. Merge hooks into settings.json
Write-Host "[3/4] Configuring hooks in settings.json ..."
$rawHooks = Get-Content "$srcDir\hooks.json" -Raw -Encoding UTF8
$escapedScriptsDir = $scriptsDir.Replace('\', '\\')
$rawHooks = $rawHooks.Replace('__SCRIPTS_DIR__', $escapedScriptsDir)
$hooksTemplate = $rawHooks | ConvertFrom-Json
if (Test-Path $settingsFile) {
$settings = Get-Content $settingsFile -Raw -Encoding UTF8 | ConvertFrom-Json
} else {
$settings = @{}
}
# Deep merge hooks
if (-not $settings.hooks) { $settings | Add-Member -MemberType NoteProperty -Name hooks -Value @{} -Force }
$existingHooks = $settings.hooks
foreach ($hookType in $hooksTemplate.PSObject.Properties) {
$hookName = $hookType.Name
$hookValue = $hookType.Value
if ($existingHooks.$hookName) {
# Append to existing array, avoid duplicates
$existing = $existingHooks.$hookName
foreach ($item in $hookValue) {
$json = $item | ConvertTo-Json -Compress
$found = $false
foreach ($e in $existing) {
if (($e | ConvertTo-Json -Compress) -eq $json) { $found = $true; break }
}
if (-not $found) { $existing += $item }
}
$existingHooks.$hookName = $existing
} else {
$existingHooks | Add-Member -MemberType NoteProperty -Name $hookName -Value $hookValue -Force
}
}
$settings | ConvertTo-Json -Depth 10 | Out-File $settingsFile -Encoding UTF8
Write-Host " OK" -ForegroundColor Green
# 4. Done
Write-Host "[4/4] Done!" -ForegroundColor Green
Write-Host ""
Write-Host "What was installed:" -ForegroundColor Cyan
Write-Host " Scripts → $scriptsDir\"
Write-Host " Protocol → claude-focus://"
Write-Host " Hooks → merged into settings.json"
Write-Host ""
Write-Host "Restart Claude Code to activate. When Claude needs permission"
Write-Host "and you're not in the terminal, you'll get a Windows toast."
Write-Host ""
Write-Host "To uninstall, run: .\uninstall.ps1" -ForegroundColor DarkGray