feat: osv-startup.ps1 — tight boxes, concise text, glow on checkmarks, custom prompt [Phase 4]
This commit is contained in:
parent
2e66e6c510
commit
5ceb0cd282
|
|
@ -1,157 +1,100 @@
|
|||
# OSVauco · OPAX — VS Code Windows Startup Script
|
||||
# settings.json: "args": ["-NoExit", "-File", "G:\\Shared drives\\OS-VAUCO-DRIVE\\OSVauco\\scripts\\osv-startup.ps1"]
|
||||
# OSVauco · OPAX — VS Code Windows Startup
|
||||
# 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)
|
||||
$REPO = "G:\Shared drives\OS-VAUCO-DRIVE\OSVauco"
|
||||
$PING = "https://opax.vauco.no/ping"
|
||||
$LOG = "$REPO\docs\OSVAUCO_OPAX_SESSION_LOG.md"
|
||||
$W = 52
|
||||
$LINE = " " + ("█" * $W)
|
||||
$THIN = " " + ("─" * $W)
|
||||
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
$env:PYTHONUTF8 = "1"
|
||||
|
||||
Set-Location $REPO_PATH
|
||||
Set-Location $REPO
|
||||
Clear-Host
|
||||
|
||||
$gcOK = $false
|
||||
$adcOK = $false
|
||||
$opaxOK = $false
|
||||
$gitOK = $false
|
||||
$gcOK = $adcOK = $opaxOK = $gitOK = $false
|
||||
$gitOut = git pull 2>&1; $gitOK = ($LASTEXITCODE -eq 0)
|
||||
try { $gcAcc = gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>$null
|
||||
if ($gcAcc) { $gcOK = $true; gcloud config set project propane-will-491900-m5 2>$null|Out-Null
|
||||
gcloud config set compute/region us-central1 2>$null|Out-Null } } catch {}
|
||||
try { if (gcloud auth application-default print-access-token 2>$null) { $adcOK = $true } } catch {}
|
||||
try { if ((Invoke-RestMethod -Uri $PING -TimeoutSec 5).status -eq 'ok') { $opaxOK = $true } } catch {}
|
||||
|
||||
# ---- GIT PULL -----------------------------------------------
|
||||
$gitOut = git pull 2>&1
|
||||
$gitOK = ($LASTEXITCODE -eq 0)
|
||||
$allOK = $gitOK -and $opaxOK -and $gcOK
|
||||
$BC = if ($allOK) { 'Green' } else { 'Yellow' }
|
||||
$IC = if ($allOK) { 'Green' } else { 'Gray' }
|
||||
$P = 'Magenta'
|
||||
|
||||
# ---- 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
|
||||
function Box($text, $color) {
|
||||
$pad = $W - 4 - $text.Length
|
||||
if ($pad -lt 0) { $text = $text.Substring(0, $W-5) + "…"; $pad = 0 }
|
||||
Write-Host (" █ " + $text + (" " * $pad) + " █") -ForegroundColor $color
|
||||
}
|
||||
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
|
||||
function Glow($label, $val, $ok) {
|
||||
$sym = if ($ok) { "✅" } else { "⚠ " }
|
||||
$col = if ($ok) { 'Green' } else { 'Yellow' }
|
||||
$line = "$sym $label : $val"
|
||||
Box $line $col
|
||||
}
|
||||
Write-Host $THIN -ForegroundColor $Purple
|
||||
|
||||
# ── TOPP ────────────────────────────────────────────────────
|
||||
Write-Host ""
|
||||
Write-Host $LINE -ForegroundColor $BC
|
||||
Box " O S V A U C O · O P A X" $BC
|
||||
Box " VS Code · us-central1 · gemini-2.5-pro" $IC
|
||||
Box " $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" $IC
|
||||
Write-Host $LINE -ForegroundColor $BC
|
||||
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
|
||||
# ── NESTE OPPGAVE ───────────────────────────────────────────
|
||||
Write-Host " ■ NESTE OPPGAVE" -ForegroundColor $P
|
||||
Write-Host $THIN -ForegroundColor $P
|
||||
if (Test-Path $LOG) {
|
||||
$m = [regex]::Match((Get-Content $LOG -Raw -Encoding UTF8),'(?s)## NESTE OPPGAVE\r?\n(.*?)(?=\r?\n## |$)')
|
||||
if ($m.Success) {
|
||||
$m.Groups[1].Value.Trim() -split "`n" | Select-Object -First 3 | ForEach-Object {
|
||||
$t = $_.Trim(); if ($t -and $t -ne '---') { Box $t $BC }
|
||||
}
|
||||
} else { Box "Sjekk docs/VAUCO_OS_ROADMAP.md" Yellow }
|
||||
} else { Box "Session log ikke funnet" Yellow }
|
||||
Write-Host $THIN -ForegroundColor $P
|
||||
Write-Host ""
|
||||
|
||||
# ============================================================
|
||||
# BUNN-BLOKK
|
||||
# ============================================================
|
||||
Write-Host $LINE -ForegroundColor $bannerCol
|
||||
# ── DOCS ────────────────────────────────────────────────────
|
||||
Write-Host " ■ SISTE DOCS" -ForegroundColor $P
|
||||
Write-Host $THIN -ForegroundColor $P
|
||||
git -C $REPO log -3 --pretty=format:"%h %cd %s" --date=short -- docs 2>&1 | ForEach-Object {
|
||||
$s = $_ -replace '[^\x00-\x7FæøåÆØÅ—–’“”]+',''
|
||||
Box $s DarkGreen
|
||||
}
|
||||
Write-Host $THIN -ForegroundColor $P
|
||||
Write-Host ""
|
||||
|
||||
# ── STATUS ──────────────────────────────────────────────────
|
||||
Write-Host " ■ STATUS" -ForegroundColor $P
|
||||
Write-Host $THIN -ForegroundColor $P
|
||||
Glow "Git " (if ($gitOut -match 'Already') {'up to date'} else {'oppdatert'}) $gitOK
|
||||
Glow "GCP " ($gcAcc -replace '@vauco.no','') $gcOK
|
||||
Glow "ADC " (if ($adcOK) {'OK'} else {'kjør: gcloud auth application-default login'}) $adcOK
|
||||
Glow "OPAX" "opax.vauco.no" $opaxOK
|
||||
Write-Host $THIN -ForegroundColor $P
|
||||
Write-Host ""
|
||||
|
||||
# ── BUNN ────────────────────────────────────────────────────
|
||||
Write-Host $LINE -ForegroundColor $BC
|
||||
if ($allOK) {
|
||||
Write-Host " █ ▶▶ OSVAUCO / OPAX — ALL SYSTEMS GREEN ◀◀ █" -ForegroundColor Green
|
||||
Box " ▶▶ ALL SYSTEMS GREEN ◀◀" 'Green'
|
||||
} else {
|
||||
Write-Host " █ ⚠ OSVAUCO / OPAX — PARTIAL — sjekk status over █" -ForegroundColor Yellow
|
||||
Box " ⚠ PARTIAL — sjekk status over" 'Yellow'
|
||||
}
|
||||
Write-Host $LINE -ForegroundColor $bannerCol
|
||||
Write-Host $LINE -ForegroundColor $BC
|
||||
Write-Host ""
|
||||
|
||||
# ── CUSTOM PROMPT ───────────────────────────────────────────
|
||||
function prompt {
|
||||
Write-Host " G:\Shared-drives\" -NoNewline -ForegroundColor Magenta
|
||||
Write-Host "OS" -NoNewline -ForegroundColor White
|
||||
Write-Host "Vauco" -NoNewline -ForegroundColor Green
|
||||
Write-Host " ❯" -NoNewline -ForegroundColor Green
|
||||
return " "
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user