158 lines
6.6 KiB
PowerShell
158 lines
6.6 KiB
PowerShell
# OSVauco · OPAX — VS Code Windows Startup Script
|
||
# settings.json: "args": ["-NoExit", "-File", "G:\\Shared drives\\OS-VAUCO-DRIVE\\OSVauco\\scripts\\osv-startup.ps1"]
|
||
|
||
$REPO_PATH = "G:\Shared drives\OS-VAUCO-DRIVE\OSVauco"
|
||
$PING_URL = "https://opax.vauco.no/ping"
|
||
$LOG_FILE = "$REPO_PATH\docs\OSVAUCO_OPAX_SESSION_LOG.md"
|
||
$PROJECT = "propane-will-491900-m5"
|
||
$REGION = "us-central1"
|
||
$MODEL = "gemini-2.5-pro"
|
||
$MCP_NAME = "OPAX-MCP"
|
||
$PROTOCOL = "OPAX Protocol"
|
||
$LINE = " " + ("█" * 54)
|
||
$THIN = " " + ("─" * 54)
|
||
|
||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||
$env:PYTHONUTF8 = "1"
|
||
|
||
Set-Location $REPO_PATH
|
||
Clear-Host
|
||
|
||
$gcOK = $false
|
||
$adcOK = $false
|
||
$opaxOK = $false
|
||
$gitOK = $false
|
||
|
||
# ---- GIT PULL -----------------------------------------------
|
||
$gitOut = git pull 2>&1
|
||
$gitOK = ($LASTEXITCODE -eq 0)
|
||
|
||
# ---- GCP SDK ------------------------------------------------
|
||
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 {}
|
||
|
||
# ---- ADC ----------------------------------------------------
|
||
try {
|
||
$adcToken = gcloud auth application-default print-access-token 2>$null
|
||
if ($adcToken) { $adcOK = $true }
|
||
} catch {}
|
||
|
||
# ---- OPAX PING ----------------------------------------------
|
||
try {
|
||
$r = Invoke-RestMethod -Uri $PING_URL -TimeoutSec 5
|
||
if ($r.status -eq 'ok') { $opaxOK = $true }
|
||
} catch {}
|
||
|
||
# ---- FARGE-LOGIKK -------------------------------------------
|
||
$allOK = $gitOK -and $opaxOK -and $gcOK
|
||
$bannerCol = if ($allOK) { 'Green' } else { 'Yellow' }
|
||
$infoCol = if ($allOK) { 'Green' } else { 'Gray' }
|
||
$Purple = 'Magenta'
|
||
|
||
# ============================================================
|
||
# TOPP-BLOKK
|
||
# ============================================================
|
||
Write-Host ""
|
||
Write-Host $LINE -ForegroundColor $bannerCol
|
||
Write-Host " █ █" -ForegroundColor $bannerCol
|
||
Write-Host " █ O S V A U C O · O P A X █" -ForegroundColor $bannerCol
|
||
Write-Host " █ VS Code · Windows · PowerShell █" -ForegroundColor $bannerCol
|
||
Write-Host " █ █" -ForegroundColor $bannerCol
|
||
Write-Host $LINE -ForegroundColor $bannerCol
|
||
Write-Host ""
|
||
|
||
# ============================================================
|
||
# LOCKED DEFINITIONS
|
||
# ============================================================
|
||
Write-Host " ■ LOCKED DEFINITIONS" -ForegroundColor $Purple
|
||
Write-Host $THIN -ForegroundColor $Purple
|
||
Write-Host " █ MCP_NAME : $MCP_NAME" -ForegroundColor $infoCol
|
||
Write-Host " █ PROTOCOL : $PROTOCOL" -ForegroundColor $infoCol
|
||
Write-Host " █ PROJECT : $PROJECT" -ForegroundColor $infoCol
|
||
Write-Host " █ REGION : $REGION" -ForegroundColor $infoCol
|
||
Write-Host " █ MODEL : $MODEL ← locked for alle TUI-prompts" -ForegroundColor $infoCol
|
||
Write-Host " █ HUB_URL : https://opax.vauco.no" -ForegroundColor $infoCol
|
||
Write-Host " █ SESSION : $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -ForegroundColor $infoCol
|
||
Write-Host $THIN -ForegroundColor $Purple
|
||
Write-Host ""
|
||
|
||
# ============================================================
|
||
# NESTE OPPGAVE
|
||
# ============================================================
|
||
Write-Host " ■ NESTE OPPGAVE" -ForegroundColor $Purple
|
||
Write-Host $THIN -ForegroundColor $Purple
|
||
if (Test-Path $LOG_FILE) {
|
||
$logContent = Get-Content $LOG_FILE -Raw -Encoding UTF8
|
||
$match = [regex]::Match($logContent, '(?s)## NESTE OPPGAVE\r?\n(.*?)(?=\r?\n## |$)')
|
||
if ($match.Success) {
|
||
$match.Groups[1].Value.Trim() -split "`n" | ForEach-Object {
|
||
Write-Host " █ $_" -ForegroundColor $bannerCol
|
||
}
|
||
} else {
|
||
Write-Host " █ Ingen NESTE OPPGAVE — sjekk docs/VAUCO_OS_ROADMAP.md" -ForegroundColor Yellow
|
||
}
|
||
} else {
|
||
Write-Host " █ Session log ikke funnet" -ForegroundColor Yellow
|
||
}
|
||
Write-Host $THIN -ForegroundColor $Purple
|
||
Write-Host ""
|
||
|
||
# ============================================================
|
||
# SISTE DOCS-ENDRINGER
|
||
# ============================================================
|
||
Write-Host " ■ SISTE ENDRINGER I DOCS/" -ForegroundColor $Purple
|
||
Write-Host $THIN -ForegroundColor $Purple
|
||
try {
|
||
$env:GIT_TERMINAL_PROMPT = "0"
|
||
$gitLog = git -C $REPO_PATH log -4 --pretty=format:"%h %cd %s" --date=short -- docs 2>&1
|
||
if ($gitLog) {
|
||
$gitLog -split "`n" | ForEach-Object {
|
||
Write-Host " █ $_" -ForegroundColor DarkGreen
|
||
}
|
||
} else {
|
||
Write-Host " █ (ingen nylige endringer)" -ForegroundColor DarkGray
|
||
}
|
||
} catch {
|
||
Write-Host " █ (git ikke tilgjengelig)" -ForegroundColor DarkGray
|
||
}
|
||
Write-Host $THIN -ForegroundColor $Purple
|
||
Write-Host ""
|
||
|
||
# ============================================================
|
||
# SYSTEM STATUS
|
||
# ============================================================
|
||
Write-Host " ■ SYSTEM STATUS" -ForegroundColor $Purple
|
||
Write-Host $THIN -ForegroundColor $Purple
|
||
|
||
$gitTxt = if ($gitOK) { if ($gitOut -match 'Already up to date') { "✅ up to date" } else { "✅ oppdatert" } } else { "❌ FEIL" }
|
||
$gcTxt = if ($gcOK) { "✅ $gcAccount" } else { "⚠ ikke logget inn — kjør: gcloud auth login" }
|
||
$adcTxt = if ($adcOK) { "✅ Application Default Credentials OK" } else { "⚠ kjør: gcloud auth application-default login" }
|
||
$opaxTxt = if ($opaxOK){ "✅ https://opax.vauco.no" } else { "❌ nede — sjekk Cloud Run" }
|
||
|
||
Write-Host " █ Git pull : $gitTxt" -ForegroundColor $(if ($gitOK) { 'Green' } else { 'Red' })
|
||
Write-Host " █ GCP SDK : $gcTxt" -ForegroundColor $(if ($gcOK) { 'Green' } else { 'Yellow' })
|
||
Write-Host " █ ADC : $adcTxt" -ForegroundColor $(if ($adcOK) { 'Green' } else { 'Yellow' })
|
||
Write-Host " █ OPAX-MCP : $opaxTxt" -ForegroundColor $(if ($opaxOK) { 'Green' } else { 'Red' })
|
||
Write-Host " █ Gemini : ℹ Cloud Shell → source scripts/osvauco-opax-boot.sh → gemini" -ForegroundColor $infoCol
|
||
|
||
Write-Host $THIN -ForegroundColor $Purple
|
||
Write-Host ""
|
||
|
||
# ============================================================
|
||
# BUNN-BLOKK
|
||
# ============================================================
|
||
Write-Host $LINE -ForegroundColor $bannerCol
|
||
if ($allOK) {
|
||
Write-Host " █ ▶▶ OSVAUCO / OPAX — ALL SYSTEMS GREEN ◀◀ █" -ForegroundColor Green
|
||
} else {
|
||
Write-Host " █ ⚠ OSVAUCO / OPAX — PARTIAL — sjekk status over █" -ForegroundColor Yellow
|
||
}
|
||
Write-Host $LINE -ForegroundColor $bannerCol
|
||
Write-Host ""
|