File size: 2,738 Bytes
279ebac
 
 
 
 
 
 
 
a86f482
279ebac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bbf8ffa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279ebac
 
 
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
# --- Ever Brain Web Installer for Windows ---
# This script downloads and installs Ever Brain globally.

$ErrorActionPreference = "Stop"

Write-Host "--- Ever Brain Installation Started ---" -ForegroundColor Cyan

# 1. Configuration
$BaseUrl = "https://projectsorg-ever-brain.hf.space" # In production, this would be your domain
$InstallDir = Join-Path $env:LOCALAPPDATA "EverBrain"
$BinDir = Join-Path $InstallDir "bin"
$ExeName = "ever-brain.exe"
$DownloadUrl = "$BaseUrl/download"

# 2. Create Install Directory
Write-Host "> Creating installation directory at $BinDir..." -ForegroundColor Gray
if (-not (Test-Path $BinDir)) {
    New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
}

# 3. Download Executable
Write-Host "> Downloading Ever Brain CLI..." -ForegroundColor Gray
Invoke-WebRequest -Uri $DownloadUrl -OutFile (Join-Path $BinDir $ExeName) -UseBasicParsing

# 4. Add to PATH
Write-Host "> Updating PATH environment variable..." -ForegroundColor Gray
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$BinDir*") {
    $NewPath = "$UserPath;$BinDir"
    [Environment]::SetEnvironmentVariable("Path", $NewPath, "User")
    $env:Path = "$env:Path;$BinDir"
    Write-Host "++ Added $BinDir to User PATH." -ForegroundColor Green
} else {
    Write-Host ">> $BinDir is already in PATH." -ForegroundColor DarkGray
}

# 5. Register in 'Add or Remove Programs'
Write-Host "> Registering with Windows for uninstallation..." -ForegroundColor Gray
$UninstallKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\EverBrain"
if (-not (Test-Path $UninstallKey)) {
    New-Item -Path $UninstallKey -Force | Out-Null
}

$UninstallCommand = "powershell.exe -Command `"[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'User').Replace('$BinDir', '').Replace(';;', ';'), 'User'); Remove-Item -Path '$InstallDir' -Recurse -Force; Remove-Item -Path '$UninstallKey' -Force`""

Set-ItemProperty -Path $UninstallKey -Name "DisplayName" -Value "Ever Brain"
Set-ItemProperty -Path $UninstallKey -Name "UninstallString" -Value $UninstallCommand
Set-ItemProperty -Path $UninstallKey -Name "DisplayVersion" -Value "0.1.0"
Set-ItemProperty -Path $UninstallKey -Name "Publisher" -Value "Ever Brain"
Set-ItemProperty -Path $UninstallKey -Name "InstallLocation" -Value "$InstallDir"
Set-ItemProperty -Path $UninstallKey -Name "NoModify" -Value 1
Set-ItemProperty -Path $UninstallKey -Name "NoRepair" -Value 1

Write-Host "`nSUCCESS! Ever Brain is now installed." -ForegroundColor Green
Write-Host "Please restart your terminal and run: ever-brain status" -ForegroundColor White
Write-Host "----------------------------------------" -ForegroundColor Cyan