-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREVITHION-STARTUP.ps1
More file actions
241 lines (220 loc) · 11.2 KB
/
REVITHION-STARTUP.ps1
File metadata and controls
241 lines (220 loc) · 11.2 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# ============================================================================
# REVITHION-STARTUP.ps1 — DevTeam6 Copilot CLI Session Launcher
# ============================================================================
# Author: SpiralCloudOmega
# Repo: SpiralCloudOmega/DevTeam6
#
# PURPOSE:
# Double-click (via .bat wrapper) to instantly restore your Copilot CLI
# development session for REVITHION STUDIO. This script:
# 1. Displays system status (RAM, GPU, disk)
# 2. Checks WSL availability and services
# 3. Launches WSL Ubuntu with the session-startup.sh companion script
# 4. That script runs `copilot --resume` to restore your last session
#
# AFTER SESSION RESTORES:
# - Type /yolo to enable autonomous execution mode (no confirmation prompts)
# - Type /fleet to enable parallel sub-agent dispatching
# These must be enabled manually each session.
#
# USAGE:
# Option A: Double-click REVITHION-STARTUP.bat (recommended)
# Option B: Right-click this .ps1 → "Run with PowerShell"
# Option C: powershell -ExecutionPolicy Bypass -File REVITHION-STARTUP.ps1
# ============================================================================
$ErrorActionPreference = "Continue"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$LogFile = Join-Path $ScriptDir ".github\scripts\startup.log"
# --- Window Title ---
$Host.UI.RawUI.WindowTitle = "REVITHION STUDIO — DevTeam6"
# --- Utility: Colored output ---
function Write-Status { param($msg) Write-Host " [*] " -ForegroundColor Cyan -NoNewline; Write-Host $msg }
function Write-OK { param($msg) Write-Host " [+] " -ForegroundColor Green -NoNewline; Write-Host $msg }
function Write-Warn { param($msg) Write-Host " [!] " -ForegroundColor Yellow -NoNewline; Write-Host $msg }
function Write-Err { param($msg) Write-Host " [-] " -ForegroundColor Red -NoNewline; Write-Host $msg }
function Write-Section { param($msg) Write-Host "`n === $msg ===" -ForegroundColor Magenta }
# ============================================================================
# ASCII BANNER
# ============================================================================
Write-Host ""
Write-Host @"
╔══════════════════════════════════════════════════════════════════╗
║ ║
║ ██████╗ ███████╗██╗ ██╗██╗████████╗██╗ ██╗██╗ ██████╗ ███╗ ║
║ ██╔══██╗██╔════╝██║ ██║██║╚══██╔══╝██║ ██║██║██╔═══██╗████║║
║ ██████╔╝█████╗ ██║ ██║██║ ██║ ███████║██║██║ ██║██╔██║║
║ ██╔══██╗██╔══╝ ╚██╗ ██╔╝██║ ██║ ██╔══██║██║██║ ██║██║╚╝║
║ ██║ ██║███████╗ ╚████╔╝ ██║ ██║ ██║ ██║██║╚██████╔╝██║ ║
║ ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ║
║ ║
║ S T U D I O — D e v T e a m 6 ║
║ ALL-IN-ONE Audio / Video / 3D Production Suite ║
║ ║
╚══════════════════════════════════════════════════════════════════╝
"@ -ForegroundColor DarkCyan
Write-Host " Ryzen 9 5950X | 64GB DDR4 | RTX 3090 24GB | 8.4TB Storage" -ForegroundColor DarkGray
Write-Host " $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss zzz')" -ForegroundColor DarkGray
Write-Host ""
# ============================================================================
# SYSTEM STATUS
# ============================================================================
Write-Section "System Status"
# --- RAM ---
try {
$os = Get-CimInstance Win32_OperatingSystem
$totalGB = [math]::Round($os.TotalVisibleMemorySize / 1MB, 1)
$freeGB = [math]::Round($os.FreePhysicalMemory / 1MB, 1)
$usedGB = [math]::Round($totalGB - $freeGB, 1)
$pct = [math]::Round(($usedGB / $totalGB) * 100, 0)
if ($pct -gt 85) {
Write-Warn "RAM: ${usedGB}GB / ${totalGB}GB used (${pct}%) — HIGH"
} else {
Write-OK "RAM: ${usedGB}GB / ${totalGB}GB used (${pct}%)"
}
} catch {
Write-Err "RAM: Could not query — $($_.Exception.Message)"
}
# --- GPU (nvidia-smi) ---
try {
$nvidiaSmi = Get-Command nvidia-smi -ErrorAction SilentlyContinue
if ($nvidiaSmi) {
$gpuInfo = & nvidia-smi --query-gpu=name,memory.used,memory.total,temperature.gpu,utilization.gpu --format=csv,noheader,nounits 2>$null
if ($gpuInfo) {
$parts = $gpuInfo.Trim() -split ",\s*"
$gpuName = $parts[0]
$memUsed = $parts[1]
$memTotal = $parts[2]
$temp = $parts[3]
$utilGpu = $parts[4]
$memFree = [int]$memTotal - [int]$memUsed
Write-OK "GPU: $gpuName — ${memUsed}MB / ${memTotal}MB VRAM (${memFree}MB free)"
Write-OK "GPU: ${temp}°C | ${utilGpu}% utilization"
}
} else {
Write-Warn "GPU: nvidia-smi not found in PATH"
}
} catch {
Write-Err "GPU: Query failed — $($_.Exception.Message)"
}
# --- Disk Usage ---
try {
$drives = Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Used -ne $null }
foreach ($d in $drives) {
$usedDisk = [math]::Round($d.Used / 1GB, 1)
$freeDisk = [math]::Round($d.Free / 1GB, 1)
$totalDisk = [math]::Round(($d.Used + $d.Free) / 1GB, 1)
if ($totalDisk -gt 0) {
Write-OK "Disk $($d.Name): ${usedDisk}GB / ${totalDisk}GB used (${freeDisk}GB free)"
}
}
} catch {
Write-Err "Disk: Query failed"
}
# ============================================================================
# SERVICES CHECK
# ============================================================================
Write-Section "Services"
$services = @(
@{ Name = "Ollama"; Process = "ollama"; Port = 11434 },
@{ Name = "PostgreSQL"; Process = "postgres"; Port = 5432 },
@{ Name = "Docker"; Process = "com.docker"; Port = $null },
@{ Name = "Gitea"; Process = $null; Port = 3000 }
)
foreach ($svc in $services) {
$running = $false
if ($svc.Process) {
$proc = Get-Process -Name $svc.Process -ErrorAction SilentlyContinue
if ($proc) { $running = $true }
}
if (-not $running -and $svc.Port) {
$conn = Get-NetTCPConnection -LocalPort $svc.Port -ErrorAction SilentlyContinue
if ($conn) { $running = $true }
}
if ($running) {
Write-OK "$($svc.Name): Running$(if ($svc.Port) { " (port $($svc.Port))" })"
} else {
Write-Status "$($svc.Name): Not detected"
}
}
# ============================================================================
# WSL CHECK
# ============================================================================
Write-Section "WSL Environment"
$wslPath = Get-Command wsl.exe -ErrorAction SilentlyContinue
if (-not $wslPath) {
Write-Err "WSL is not installed or not in PATH. Cannot continue."
Write-Host ""
Write-Host " Press any key to exit..." -ForegroundColor Yellow
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
exit 1
}
Write-OK "WSL: Available"
# Check default distro
try {
$distros = wsl.exe --list --verbose 2>$null | Out-String
if ($distros -match "Ubuntu") {
Write-OK "WSL: Ubuntu distro found"
} else {
Write-Warn "WSL: Ubuntu not found in distro list"
}
} catch {
Write-Warn "WSL: Could not list distros"
}
# Check copilot CLI in WSL
$copilotCheck = wsl.exe -d Ubuntu -- bash -c "command -v copilot 2>/dev/null && echo FOUND || echo MISSING" 2>$null
if ($copilotCheck -match "FOUND") {
Write-OK "Copilot CLI: Installed in WSL"
} else {
Write-Err "Copilot CLI: Not found in WSL Ubuntu"
Write-Host ""
Write-Warn "Install with: gh extension install github/gh-copilot"
Write-Host " Press any key to exit..." -ForegroundColor Yellow
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
exit 1
}
# ============================================================================
# LOG TIMESTAMP
# ============================================================================
try {
$logDir = Split-Path $LogFile -Parent
if (-not (Test-Path $logDir)) {
New-Item -ItemType Directory -Path $logDir -Force | Out-Null
}
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss zzz"
Add-Content -Path $LogFile -Value "[$timestamp] REVITHION-STARTUP.ps1 launched"
Write-OK "Logged startup at $timestamp"
} catch {
Write-Warn "Could not write to log file"
}
# ============================================================================
# LAUNCH WSL SESSION
# ============================================================================
Write-Section "Launching Session"
Write-Host ""
Write-Host " Entering WSL Ubuntu → DevTeam6 repo..." -ForegroundColor White
Write-Host " Running session-startup.sh → copilot --resume" -ForegroundColor White
Write-Host ""
Write-Host " ┌─────────────────────────────────────────────────────────┐" -ForegroundColor DarkYellow
Write-Host " │ AFTER SESSION RESTORES: │" -ForegroundColor DarkYellow
Write-Host " │ 1. Select session #1 (most recent) from the list │" -ForegroundColor DarkYellow
Write-Host " │ 2. Type: /yolo — enables autonomous execution │" -ForegroundColor DarkYellow
Write-Host " │ 3. Type: /fleet — enables parallel sub-agents │" -ForegroundColor DarkYellow
Write-Host " └─────────────────────────────────────────────────────────┘" -ForegroundColor DarkYellow
Write-Host ""
# Build the WSL command: run companion script if it exists, otherwise manual fallback
$wslCommand = @"
cd '/mnt/c/Users/autom/VS Code GitHub Repos/DevTeam6' && \
if [ -x '.github/scripts/session-startup.sh' ]; then
bash .github/scripts/session-startup.sh
else
echo '[!] session-startup.sh not found, falling back to manual launch...'
source ~/projects/devteam6-env.sh 2>/dev/null
copilot --resume
fi
"@
# Launch WSL interactively — this replaces the PowerShell window with the WSL session
wsl.exe -d Ubuntu -- bash -c $wslCommand
# If WSL exits, show a message
Write-Host ""
Write-Host " Session ended. Window will close in 5 seconds..." -ForegroundColor DarkGray
Start-Sleep -Seconds 5