# OSVauco · OPAX — VS Code Windows Startup $REPO = "G:\Shared drives\OS-VAUCO-DRIVE\OSVauco" $PING = "https://opax.vauco.no/ping" $LOG = "$REPO\docs\OSVAUCO_OPAX_SESSION_LOG.md" $W = 54 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 Set-Location $REPO Clear-Host # ---- GCLOUD PATH DETECTION ----------------------------------- $gcloudCmd = $null $gcloudPaths = @( "gcloud", "$env:LOCALAPPDATA\Google\Cloud SDK\google-cloud-sdk\bin\gcloud.cmd", "$env:PROGRAMFILES\Google\Cloud SDK\google-cloud-sdk\bin\gcloud.cmd", "$env:USERPROFILE\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\gcloud.cmd" ) foreach ($p in $gcloudPaths) { try { $null = & $p version 2>$null; if ($LASTEXITCODE -eq 0 -or $?) { $gcloudCmd = $p; break } } catch {} } # ---- SJEKKER ------------------------------------------------- $gcOK = $false; $adcOK = $false; $opaxOK = $false; $gitOK = $false $gcAcc = ""; $gcNotInstalled = ($null -eq $gcloudCmd) $gitOut = git pull 2>&1; $gitOK = ($LASTEXITCODE -eq 0) if (-not $gcNotInstalled) { try { $gcAcc = & $gcloudCmd auth list --filter=status:ACTIVE --format="value(account)" 2>$null if ($gcAcc) { $gcOK = $true & $gcloudCmd config set project propane-will-491900-m5 2>$null | Out-Null & $gcloudCmd config set compute/region us-central1 2>$null | Out-Null } } catch {} try { $t = & $gcloudCmd auth application-default print-access-token 2>$null; if ($t) { $adcOK = $true } } catch {} } try { if ((Invoke-RestMethod -Uri $PING -TimeoutSec 5).status -eq 'ok') { $opaxOK = $true } } catch {} $allOK = $gitOK -and $opaxOK -and $gcOK $PU = 'Magenta'; $GR = 'Green'; $DG = 'DarkGreen' # ---- STATUS STRENGER ----------------------------------------- $gitTxt = if ($gitOK) { if ($gitOut -match 'Already') { "✅ Git : up to date" } else { "✅ Git : oppdatert" } } else { "❌ Git : FEIL" } $gcTxt = if ($gcNotInstalled) { "ℹ GCP : ikke funnet — bruk Cloud Shell" } elseif ($gcOK) { "✅ GCP : " + ($gcAcc -replace '@vauco.no','') } else { "⚠ GCP : gcloud auth login" } $adcTxt = if ($gcNotInstalled) { "ℹ ADC : ikke tilgjengelig" } elseif ($adcOK) { "✅ ADC : OK" } else { "⚠ ADC : gcloud auth application-default login" } $opaxTxt = if ($opaxOK) { "✅ OPAX : opax.vauco.no" } else { "❌ OPAX : nede — sjekk Cloud Run" } # ---- HJELPEFUNKSJONER ---------------------------------------- function Pad($text, $width) { if ($text.Length -gt $width) { return $text.Substring(0, $width - 1) + "…" } return $text + (" " * ($width - $text.Length)) } function GlowBox($lines) { $seg = [math]::Floor($W / 3); $r = $W - $seg * 2 Write-Host " " -NoNewline Write-Host ("█" * $seg) -NoNewline -ForegroundColor $PU Write-Host ("█" * $seg) -NoNewline -ForegroundColor $DG Write-Host ("█" * $r) -ForegroundColor $GR foreach ($line in $lines) { $inner = Pad $line ($W - 4) Write-Host " " -NoNewline Write-Host "█" -NoNewline -ForegroundColor $PU Write-Host (" $inner ") -NoNewline -ForegroundColor $GR Write-Host "█" -ForegroundColor $GR } Write-Host " " -NoNewline Write-Host ("█" * $r) -NoNewline -ForegroundColor $GR Write-Host ("█" * $seg) -NoNewline -ForegroundColor $DG Write-Host ("█" * $seg) -ForegroundColor $PU } function DocBox($line) { $hash = ""; $date = ""; $msg = $line if ($line -match '^([0-9a-f]{7}) (\d{4}-\d{2}-\d{2}) (.+)$') { $hash = $matches[1]; $date = $matches[2]; $msg = $matches[3] } Write-Host " " -NoNewline; Write-Host "┌─ " -NoNewline -ForegroundColor $PU Write-Host $hash -NoNewline -ForegroundColor $GR; Write-Host " $date" -ForegroundColor $DG Write-Host " " -NoNewline; Write-Host "│ " -NoNewline -ForegroundColor $PU Write-Host (Pad $msg ($W - 4)) -ForegroundColor $GR Write-Host " " -NoNewline; Write-Host "└" -NoNewline -ForegroundColor $PU Write-Host ("─" * ($W - 2)) -ForegroundColor $PU } function NesteBox($text) { Write-Host " " -NoNewline; Write-Host "┌" -NoNewline -ForegroundColor $PU Write-Host ("─" * ($W - 2)) -ForegroundColor $PU Write-Host " " -NoNewline; Write-Host "│ " -NoNewline -ForegroundColor $PU Write-Host (Pad $text ($W - 4)) -ForegroundColor $GR Write-Host " " -NoNewline; Write-Host "└" -NoNewline -ForegroundColor $PU Write-Host ("─" * ($W - 2)) -ForegroundColor $PU } function StatusLine($text) { $col = if ($text -match "^✅") { $GR } elseif ($text -match "^❌") { 'Red' } else { $PU } Write-Host " " -NoNewline; Write-Host "▒ " -NoNewline -ForegroundColor $col Write-Host $text -ForegroundColor $col } # ============================================================== Write-Host "" GlowBox @("", " O S V A U C O · O P A X", " us-central1 · gemini-2.5-pro", " $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')", "") Write-Host "" Write-Host " ■ NESTE OPPGAVE" -ForegroundColor $PU $nesteLines = @("Sjekk docs/VAUCO_OS_ROADMAP.md") if (Test-Path $LOG) { $m = [regex]::Match((Get-Content $LOG -Raw -Encoding UTF8), '(?s)## NESTE OPPGAVE\r?\n(.*?)(?=\r?\n## |$)') if ($m.Success) { $nesteLines = $m.Groups[1].Value.Trim() -split "`n" | Where-Object { $_.Trim() -and $_.Trim() -ne '---' } | Select-Object -First 3 | ForEach-Object { $_.Trim() } } } foreach ($nl in $nesteLines) { NesteBox $nl } Write-Host "" Write-Host " ■ SISTE DOCS" -ForegroundColor $PU $docLines = git -C $REPO log -3 --pretty=format:"%h %cd %s" --date=short -- docs 2>&1 | ForEach-Object { ($_ -replace '[^\x00-\x7F\u00e6\u00f8\u00e5\u00c6\u00d8\u00c5\u2014\u2013]+', '').Trim() } | Where-Object { $_ } foreach ($dl in $docLines) { DocBox $dl } Write-Host "" Write-Host " ■ STATUS" -ForegroundColor $PU StatusLine $gitTxt; StatusLine $gcTxt; StatusLine $adcTxt; StatusLine $opaxTxt Write-Host "" # Ingen bunn-boks — status-linjene er avslutning # ============================================================== # CUSTOM PROMPT # ============================================================== function prompt { Write-Host " G:\Shared-drives\" -NoNewline -ForegroundColor Magenta Write-Host "OS" -NoNewline -ForegroundColor White # Sterkt grønn glødende OSVauco via ANSI bold $e = [char]27 Write-Host "${e}[1;92mVauco${e}[0m" -NoNewline Write-Host " ❯" -NoNewline -ForegroundColor Green return " " }