feat: osv-startup.ps1 — full green glow banner when all systems OK [visual feedback]

This commit is contained in:
chrischristiansen-glitch 2026-05-22 02:14:31 +02:00
parent e3ca6e8832
commit 7088ccce2d

View File

@ -1,6 +1,5 @@
# OSVauco · OPAX — VS Code Windows Startup Script # OSVauco · OPAX — VS Code Windows Startup Script
# Tilsvarer osvauco-opax-boot.sh men for PowerShell/Windows # Kjøres via settings.json:
# Kjøres via terminal.integrated.profiles.windows i VS Code settings.json:
# "args": ["-NoExit", "-File", "G:\\Shared drives\\OS-VAUCO-DRIVE\\OSVauco\\scripts\\osv-startup.ps1"] # "args": ["-NoExit", "-File", "G:\\Shared drives\\OS-VAUCO-DRIVE\\OSVauco\\scripts\\osv-startup.ps1"]
$REPO_PATH = "G:\Shared drives\OS-VAUCO-DRIVE\OSVauco" $REPO_PATH = "G:\Shared drives\OS-VAUCO-DRIVE\OSVauco"
@ -15,158 +14,134 @@ $PROTOCOL = "OPAX Protocol"
Set-Location $REPO_PATH Set-Location $REPO_PATH
Clear-Host Clear-Host
$gcOK = $false
$adcOK = $false
$opaxOK = $false
# ============================================================ # ============================================================
# BANNER # 1) GIT PULL (stille, før banner)
# ============================================================
$gitOut = git pull 2>&1
$gitOK = ($LASTEXITCODE -eq 0)
# ============================================================
# 2) GCP SDK + ADC (stille)
# ============================================================
try {
$gcAccount = gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>$null
if ($gcAccount) {
$gcOK = $true
gcloud config set project $PROJECT 2>$null | Out-Null
gcloud config set compute/region $REGION 2>$null | Out-Null
}
} catch {}
try {
$adcToken = gcloud auth application-default print-access-token 2>$null
if ($adcToken) { $adcOK = $true }
} catch {}
# ============================================================
# 3) OPAX PING (stille)
# ============================================================
try {
$response = Invoke-RestMethod -Uri $PING_URL -TimeoutSec 5
if ($response.status -eq 'ok') { $opaxOK = $true }
} catch {}
# ============================================================
# 4) BESTEM GLOW-FARGE
# ============================================================
$allOK = $gitOK -and $opaxOK
$bannerColor = if ($allOK) { 'Green' } else { 'Yellow' }
$glowChar = if ($allOK) { '█' } else { '□' }
# ============================================================
# 5) BANNER
# ============================================================ # ============================================================
Write-Host "============================================================" -ForegroundColor Cyan
Write-Host " O S V A U C O · O P A X" -ForegroundColor Cyan
Write-Host "============================================================" -ForegroundColor Cyan
Write-Host " VS Code · Windows · PowerShell" -ForegroundColor DarkCyan
Write-Host "" Write-Host ""
Write-Host " MCP_NAME : $MCP_NAME" -ForegroundColor Gray Write-Host " $glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar" -ForegroundColor $bannerColor
Write-Host " PROTOCOL : $PROTOCOL" -ForegroundColor Gray Write-Host ""
Write-Host " PROJECT : $PROJECT" -ForegroundColor Gray Write-Host " O S V A U C O · O P A X" -ForegroundColor $bannerColor
Write-Host " REGION : $REGION" -ForegroundColor Gray Write-Host ""
Write-Host " MODEL : $MODEL (locked — bruk for alle TUI-prompts)" -ForegroundColor Gray Write-Host " $glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar" -ForegroundColor $bannerColor
Write-Host " HUB_URL : $PING_URL" -ForegroundColor Gray Write-Host ""
Write-Host " SESSION : $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -ForegroundColor Gray
# Info-linjer i banner-farge når alt er OK, grå ellers
$infoColor = if ($allOK) { $bannerColor } else { 'Gray' }
Write-Host " MCP_NAME : $MCP_NAME" -ForegroundColor $infoColor
Write-Host " PROTOCOL : $PROTOCOL" -ForegroundColor $infoColor
Write-Host " PROJECT : $PROJECT" -ForegroundColor $infoColor
Write-Host " REGION : $REGION" -ForegroundColor $infoColor
Write-Host " MODEL : $MODEL ← locked for alle TUI-prompts" -ForegroundColor $infoColor
Write-Host " HUB_URL : https://opax.vauco.no" -ForegroundColor $infoColor
Write-Host " SESSION : $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -ForegroundColor $infoColor
Write-Host "" Write-Host ""
# ============================================================ # ============================================================
# NESTE OPPGAVE fra session log # 6) NESTE OPPGAVE
# ============================================================ # ============================================================
if (Test-Path $LOG_FILE) { if (Test-Path $LOG_FILE) {
$logContent = Get-Content $LOG_FILE -Raw $logContent = Get-Content $LOG_FILE -Raw
$match = [regex]::Match($logContent, '(?s)## NESTE OPPGAVE\r?\n(.*?)(?=\r?\n## |$)') $match = [regex]::Match($logContent, '(?s)## NESTE OPPGAVE\r?\n(.*?)(?=\r?\n## |$)')
if ($match.Success) { if ($match.Success) {
Write-Host " ▶ NESTE OPPGAVE:" -ForegroundColor Green Write-Host " ▶ NESTE OPPGAVE:" -ForegroundColor $bannerColor
$match.Groups[1].Value.Trim() -split "`n" | ForEach-Object { $match.Groups[1].Value.Trim() -split "`n" | ForEach-Object {
Write-Host " $_" -ForegroundColor Green Write-Host " $_" -ForegroundColor $bannerColor
} }
} else { Write-Host ""
Write-Host " ⚠ Ingen NESTE OPPGAVE — sjekk docs/VAUCO_OS_ROADMAP.md" -ForegroundColor Yellow
} }
} else {
Write-Host " ⚠ Session log ikke funnet" -ForegroundColor Yellow
} }
Write-Host ""
# ============================================================ # ============================================================
# SISTE DOCS-ENDRINGER (git log) # 7) SISTE DOCS-ENDRINGER
# ============================================================ # ============================================================
Write-Host " Siste endringer i docs/:" -ForegroundColor Blue Write-Host " Siste endringer i docs/:" -ForegroundColor $infoColor
try { try {
$gitLog = git -C $REPO_PATH log -5 --pretty=format:"%h %cd %s" --date=short -- docs 2>&1 $gitLog = git -C $REPO_PATH log -4 --pretty=format:"%h %cd %s" --date=short -- docs 2>&1
if ($gitLog) { if ($gitLog) {
$gitLog -split "`n" | ForEach-Object { $gitLog -split "`n" | ForEach-Object {
Write-Host " $_" -ForegroundColor DarkCyan Write-Host " $_" -ForegroundColor DarkGreen
} }
} else {
Write-Host " (ingen nylige docs-endringer)" -ForegroundColor DarkGray
} }
} catch { } catch {}
Write-Host " (git ikke tilgjengelig)" -ForegroundColor DarkGray
}
Write-Host "" Write-Host ""
# ============================================================ # ============================================================
# GIT PULL # 8) STATUS-LINJER
# ============================================================ # ============================================================
Write-Host " Git pull..." -NoNewline -ForegroundColor Blue # Git
try { $gitStatus = if ($gitOK) { if ($gitOut -match 'Already up to date') { '✅ up to date' } else { "✅ oppdatert" } } else { '❌ FEIL' }
$gitOut = git pull 2>&1 Write-Host " Git pull : $gitStatus" -ForegroundColor $(if ($gitOK) { 'Green' } else { 'Red' })
if ($LASTEXITCODE -eq 0) {
Write-Host " [OK]" -ForegroundColor Green # GCP
if ($gitOut -match 'Already up to date') { $gcStatus = if ($gcOK) { "$gcAccount" } else { '⚠ ikke logget inn — gcloud auth login' }
Write-Host " Already up to date" -ForegroundColor DarkGray Write-Host " GCP SDK : $gcStatus" -ForegroundColor $(if ($gcOK) { 'Green' } else { 'Yellow' })
} else {
$gitOut | Where-Object { $_ -match 'changed' } | ForEach-Object { # ADC
Write-Host " $_" -ForegroundColor Cyan $adcStatus = if ($adcOK) { '✅ Application Default Credentials OK' } else { '⚠ mangler — gcloud auth application-default login' }
} Write-Host " ADC : $adcStatus" -ForegroundColor $(if ($adcOK) { 'Green' } else { 'Yellow' })
}
} else { # OPAX
Write-Host " [FAIL]" -ForegroundColor Red $opaxStatus = if ($opaxOK) { '✅ https://opax.vauco.no' } else { '❌ nede — sjekk Cloud Run' }
} Write-Host " OPAX-MCP : $opaxStatus" -ForegroundColor $(if ($opaxOK) { 'Green' } else { 'Red' })
} catch {
Write-Host " [FAIL] $_" -ForegroundColor Red # Gemini
} Write-Host " Gemini : Cloud Shell → source scripts/osvauco-opax-boot.sh → gemini" -ForegroundColor $infoColor
Write-Host "" Write-Host ""
# ============================================================ # ============================================================
# GCLOUD ADC / SDK SJEKK # 9) READY-LINJE MED GLOW
# ============================================================ # ============================================================
Write-Host " GCP SDK + ADC status:" -ForegroundColor Blue Write-Host " $glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar" -ForegroundColor $bannerColor
$gcOK = $false
$adcOK = $false
try { if ($allOK) {
$gcAccount = gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>$null Write-Host " ▶▶ OSVAUCO / OPAX — ALL SYSTEMS GREEN ◀◀" -ForegroundColor Green
if ($gcAccount) {
$gcOK = $true
Write-Host " gcloud : OK — $gcAccount" -ForegroundColor Green
# Sett riktig prosjekt og region
gcloud config set project $PROJECT 2>$null | Out-Null
gcloud config set compute/region $REGION 2>$null | Out-Null
Write-Host " Project : $PROJECT" -ForegroundColor DarkGray
Write-Host " Region : $REGION" -ForegroundColor DarkGray
} else {
Write-Host " gcloud : IKKE LOGGET INN — kjør: gcloud auth login" -ForegroundColor Yellow
}
} catch {
Write-Host " gcloud : IKKE TILGJENGELIG i dette miljøet" -ForegroundColor DarkGray
}
try {
$adcToken = gcloud auth application-default print-access-token 2>$null
if ($adcToken) {
$adcOK = $true
Write-Host " ADC : OK (Application Default Credentials aktive)" -ForegroundColor Green
} else {
Write-Host " ADC : MANGLER — kjør: gcloud auth application-default login" -ForegroundColor Yellow
}
} catch {
Write-Host " ADC : ikke verifisert i dette miljøet" -ForegroundColor DarkGray
}
Write-Host ""
# ============================================================
# OPAX PING
# ============================================================
Write-Host " Tester OPAX-MCP: $PING_URL" -NoNewline -ForegroundColor Blue
try {
$response = Invoke-RestMethod -Uri $PING_URL -TimeoutSec 5
if ($response.status -eq 'ok') {
Write-Host " [OK]" -ForegroundColor Green
Write-Host " ✅ OPAX-MCP: OK — https://opax.vauco.no" -ForegroundColor Green
} else {
Write-Host " [WARN]" -ForegroundColor Yellow
}
} catch {
Write-Host " [FAIL]" -ForegroundColor Red
Write-Host " ❌ OPAX-MCP nede — sjekk Cloud Run / DNS" -ForegroundColor Red
}
Write-Host ""
# ============================================================
# GEMINI TUI REMINDER
# ============================================================
Write-Host " Gemini TUI:" -ForegroundColor Blue
Write-Host " Modell : $MODEL (bruk alltid denne i TUI)" -ForegroundColor DarkCyan
Write-Host " Boot TUI : start Cloud Shell → source scripts/osvauco-opax-boot.sh → gemini" -ForegroundColor DarkCyan
Write-Host " TUI lest : GEMINI.md lastes automatisk ved oppstart i Cloud Shell" -ForegroundColor DarkCyan
Write-Host ""
# ============================================================
# READY-LINJE
# ============================================================
Write-Host "============================================================" -ForegroundColor Cyan
if ($gcOK -and $adcOK) {
Write-Host " ▶ OSVAUCO/OPAX READY — GCP + ADC + OPAX verifisert" -ForegroundColor Green
} elseif ($gcOK) {
Write-Host " ▶ OSVAUCO/OPAX READY — OPAX OK. ADC ikke verifisert." -ForegroundColor Yellow
} else { } else {
Write-Host " ▶ OSVAUCO/OPAX PARTIAL — gcloud ikke tilgjengelig i VS Code shell" -ForegroundColor Yellow Write-Host " ⚠ OSVAUCO / OPAX — PARTIAL — sjekk status over" -ForegroundColor Yellow
Write-Host " (Bruk Cloud Shell for gcloud-kommandoer)" -ForegroundColor DarkGray
} }
Write-Host "============================================================" -ForegroundColor Cyan
Write-Host " $glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar$glowChar" -ForegroundColor $bannerColor
Write-Host "" Write-Host ""