-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathreload-hintshell.ps1
More file actions
90 lines (78 loc) · 3.48 KB
/
Copy pathreload-hintshell.ps1
File metadata and controls
90 lines (78 loc) · 3.48 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
# Script to reload HintShell module (dev mode)
# Copies fresh binaries from target/release/ into the local module directory
Write-Host "🔄 Reloading HintShell..." -ForegroundColor Cyan
$moduleDir = ".\integrations\powershell\HintShellModule"
$releaseBin = ".\target\release"
# 1. Stop daemon if running
Write-Host "Stopping daemon..." -ForegroundColor Yellow
$cliPath = Join-Path $moduleDir "hintshell.exe"
if (Test-Path $cliPath) {
& $cliPath stop 2>$null
Start-Sleep -Milliseconds 500
}
# Also kill any stray daemon processes
Get-Process hintshell-core -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
# 2. Remove module if loaded
Write-Host "Removing old module..." -ForegroundColor Yellow
Remove-Module HintShellModule -ErrorAction SilentlyContinue
# 3. Copy fresh binaries + data from build output
Write-Host "Copying fresh binaries..." -ForegroundColor Yellow
if (Test-Path $releaseBin) {
$coreBin = Join-Path $releaseBin "hintshell-core.exe"
$cliBin = Join-Path $releaseBin "hintshell.exe"
if (Test-Path $coreBin) { Copy-Item $coreBin $moduleDir -Force }
if (Test-Path $cliBin) { Copy-Item $cliBin $moduleDir -Force }
}
# Copy default-commands.json
$defaultsJson = ".\core\default-commands.json"
if (Test-Path $defaultsJson) { Copy-Item $defaultsJson $moduleDir -Force }
# 3.5 Sync to ~/.hintshell/ (so new terminals get latest code)
Write-Host "Syncing to ~/.hintshell/..." -ForegroundColor Yellow
$installRoot = Join-Path $env:USERPROFILE ".hintshell"
$installModuleDir = Join-Path $installRoot "module"
$installBinDir = Join-Path $installRoot "bin"
if (-not (Test-Path $installModuleDir)) { New-Item -ItemType Directory -Path $installModuleDir -Force | Out-Null }
if (-not (Test-Path $installBinDir)) { New-Item -ItemType Directory -Path $installBinDir -Force | Out-Null }
Copy-Item "$moduleDir\*" $installModuleDir -Recurse -Force
if (Test-Path $defaultsJson) { Copy-Item $defaultsJson $installRoot -Force }
# Keep bin/ and module/ cores in sync (module used to lag and spawn old daemons)
if (Test-Path $releaseBin) {
$coreBin = Join-Path $releaseBin "hintshell-core.exe"
$cliBin = Join-Path $releaseBin "hintshell.exe"
$hsBin = Join-Path $releaseBin "hs.exe"
if (Test-Path $coreBin) {
Copy-Item $coreBin $installBinDir -Force
Copy-Item $coreBin $installModuleDir -Force
}
if (Test-Path $cliBin) {
Copy-Item $cliBin $installBinDir -Force
Copy-Item $cliBin $installModuleDir -Force
if (Test-Path $hsBin) {
Copy-Item $hsBin $installBinDir -Force
} else {
Copy-Item $cliBin (Join-Path $installBinDir "hs.exe") -Force
}
}
}
# Remove disabled flag so dev reload always starts fresh
$disabledFile = Join-Path $installRoot ".disabled"
if (Test-Path $disabledFile) { Remove-Item $disabledFile -Force }
# 4. Import module
Write-Host "Importing module..." -ForegroundColor Yellow
$modulePsm = Join-Path $moduleDir "HintShellModule.psm1"
if (Test-Path $modulePsm) {
Import-Module $modulePsm -Force
} else {
Write-Error "❌ HintShellModule.psm1 not found at $modulePsm"
return
}
# 5. Start HintShell
Write-Host "Starting HintShell..." -ForegroundColor Yellow
if (Get-Command Start-HintShell -ErrorAction SilentlyContinue) {
Start-HintShell
} else {
Write-Error "❌ Start-HintShell function not found. Module import failed?"
return
}
Write-Host "`n✅ HintShell reloaded successfully!" -ForegroundColor Green
Write-Host "Try typing: git" -ForegroundColor Gray