Skip to content

Instantly share code, notes, and snippets.

@michaelsanford
Last active May 22, 2026 19:20
Show Gist options
  • Select an option

  • Save michaelsanford/28d89e34a44d8e99ee3708c8bc0189e1 to your computer and use it in GitHub Desktop.

Select an option

Save michaelsanford/28d89e34a44d8e99ee3708c8bc0189e1 to your computer and use it in GitHub Desktop.
Something cool to look at on a spare monitor

Start-BossKey

A small Windows-native PowerShell "boss key" terminal facade.

It is built around a mode registry so future modes can be added without changing the launcher behavior. If no mode is specified, the launcher randomly selects from the available modes.

Run

& .\Start-BossKey.ps1

Or choose the current mode explicitly:

& .\Start-BossKey.ps1 -Mode ops
& .\Start-BossKey.ps1 -Mode build
& .\Start-BossKey.ps1 -Mode trace
& .\Start-BossKey.ps1 -Mode db
& .\Start-BossKey.ps1 -Mode control

Press Q or Esc to exit.

For a quick non-interactive smoke test:

& .\Start-BossKey.ps1 -MaxTicks 3

Modes

  • ops: a realistic-looking full-screen operations console with live resource metrics, replication state, and event stream output.
  • build: a release pipeline verification console with execution stages, quality gates, artifact signing, and build output.
  • trace: a network capture console with route probing, session health, packet feed, and payload sample panes.
  • db: a relational database consistency audit with partitions, lock state, maintenance progress, and audit trail output.
  • control: a no-log control-plane widget wall with KPI tiles, service matrix, capacity gauges, regional balance, and risk/budget panels.
<#
.SYNOPSIS
Starts a full-screen technical-looking terminal facade.
.DESCRIPTION
Start-BossKey renders a Windows PowerShell/.NET terminal application designed
for quick visual context switching. If no mode is specified, it randomly picks
one of the available modes.
Press Q or Esc to exit any interactive mode.
.PARAMETER Mode
Selects the display mode to run.
Available modes:
- ops: consolidated operations dashboard with resource metrics and event stream
- build: CI orchestration board with pipeline lanes and release artifacts
- trace: network capture console with route probing, packet feed, and payload sample
- db: relational database consistency audit with partition and lock state
- control: no-log control-plane widget wall with KPI and risk panels
If omitted, one available mode is selected at random.
.PARAMETER RefreshMilliseconds
Controls the redraw/update interval in milliseconds.
Defaults to 1000, or one update per second.
.PARAMETER MaxTicks
Stops after the specified number of update ticks.
The default value, 0, runs until Q or Esc is pressed. This option is primarily
useful for smoke tests and redirected/non-interactive runs.
.EXAMPLE
.\Start-BossKey.ps1
Runs a randomly selected mode.
.EXAMPLE
.\Start-BossKey.ps1 -Mode control
Runs the control-plane widget mode.
.EXAMPLE
.\Start-BossKey.ps1 -Mode trace -RefreshMilliseconds 500
Runs the network trace mode with updates twice per second.
.EXAMPLE
.\Start-BossKey.ps1 -Mode build -MaxTicks 3
Runs a short non-interactive smoke test for the build mode.
#>
param(
[ValidateSet("ops", "build", "trace", "db", "control")]
[string] $Mode,
[int] $RefreshMilliseconds = 1000,
[int] $MaxTicks = 0
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
function Get-BossKeyModes {
[ordered]@{
ops = {
Start-OpsConsole -RefreshMilliseconds $RefreshMilliseconds -MaxTicks $MaxTicks
}
build = {
Start-BuildConsole -RefreshMilliseconds $RefreshMilliseconds -MaxTicks $MaxTicks
}
trace = {
Start-TraceConsole -RefreshMilliseconds $RefreshMilliseconds -MaxTicks $MaxTicks
}
db = {
Start-DatabaseConsole -RefreshMilliseconds $RefreshMilliseconds -MaxTicks $MaxTicks
}
control = {
Start-ControlConsole -RefreshMilliseconds $RefreshMilliseconds -MaxTicks $MaxTicks
}
}
}
function Select-BossKeyMode {
param([string] $RequestedMode)
$modes = Get-BossKeyModes
if ($RequestedMode) {
return $RequestedMode
}
$names = @($modes.Keys)
return $names[(Get-Random -Minimum 0 -Maximum $names.Count)]
}
function Write-At {
param(
[int] $Left,
[int] $Top,
[string] $Text,
[ConsoleColor] $Foreground = [ConsoleColor]::Gray,
[ConsoleColor] $Background = [ConsoleColor]::Black
)
if ($Top -lt 0 -or $Top -ge [Console]::WindowHeight) { return }
if ($Left -lt 0 -or $Left -ge [Console]::WindowWidth) { return }
$remaining = [Console]::WindowWidth - $Left
if ($remaining -le 0) { return }
if ($Text.Length -gt $remaining) {
$Text = $Text.Substring(0, $remaining)
}
[Console]::SetCursorPosition($Left, $Top)
[Console]::ForegroundColor = $Foreground
[Console]::BackgroundColor = $Background
[Console]::Write($Text)
}
function Clear-LineAt {
param([int] $Top)
if ($Top -lt 0 -or $Top -ge [Console]::WindowHeight) { return }
[Console]::SetCursorPosition(0, $Top)
[Console]::Write((" " * [Console]::WindowWidth))
}
function Write-PaddedAt {
param(
[int] $Left,
[int] $Top,
[int] $Width,
[string] $Text,
[ConsoleColor] $Foreground = [ConsoleColor]::Gray,
[ConsoleColor] $Background = [ConsoleColor]::Black
)
if ($Width -le 0) { return }
if ($Text.Length -gt $Width) {
$Text = $Text.Substring(0, $Width)
}
Write-At $Left $Top ($Text.PadRight($Width)) $Foreground $Background
}
function Draw-Box {
param(
[int] $Left,
[int] $Top,
[int] $Width,
[int] $Height,
[string] $Title = "",
[ConsoleColor] $Color = [ConsoleColor]::DarkCyan
)
if ($Width -lt 4 -or $Height -lt 3) { return }
$right = $Left + $Width - 1
$bottom = $Top + $Height - 1
if ($Left -lt 0 -or $Top -lt 0 -or $right -ge [Console]::WindowWidth -or $bottom -ge [Console]::WindowHeight) {
return
}
$horizontal = "-" * ($Width - 2)
Write-At $Left $Top "+$horizontal+" $Color
for ($y = $Top + 1; $y -lt $bottom; $y++) {
Write-At $Left $y "|" $Color
Write-At $right $y "|" $Color
}
Write-At $Left $bottom "+$horizontal+" $Color
if ($Title) {
$label = " $Title "
$max = [Math]::Max(0, $Width - 4)
if ($label.Length -gt $max) { $label = $label.Substring(0, $max) }
Write-At ($Left + 2) $Top $label White
}
}
function New-Bar {
param(
[double] $Value,
[int] $Width
)
$normalized = [Math]::Max(0, [Math]::Min(100, $Value))
$filled = [int][Math]::Round(($normalized / 100) * $Width)
return ("#" * $filled).PadRight($Width, ".")
}
function New-Sparkline {
param([int] $Width)
$chars = @(".", ":", "-", "=", "+", "#")
$spark = ""
for ($i = 0; $i -lt $Width; $i++) {
$spark += $chars[(Get-Random -Minimum 0 -Maximum $chars.Count)]
}
return $spark
}
function Invoke-Walk {
param(
[double] $Current,
[double] $Min,
[double] $Max,
[double] $Step
)
$next = $Current + (Get-Random -Minimum (-1.0 * $Step) -Maximum $Step)
return [Math]::Round([Math]::Max($Min, [Math]::Min($Max, $next)), 1)
}
function Get-FakeLogLine {
param([int] $Tick)
$verbs = @(
"Reconciled shard lease",
"Validated checkpoint vector",
"Applied schema hint",
"Indexed delta segment",
"Compacted journal extent",
"Rotated service token",
"Hydrated policy cache",
"Merged telemetry frame",
"Resampled queue depth",
"Verified replica heartbeat"
)
$areas = @("north-2", "edge-a", "ledger", "ingest", "policy", "api", "cache", "warehouse", "events", "audit")
$codes = @("OK", "DEFER", "TRACE", "SYNC", "READY", "STABLE")
$code = $codes | Get-Random
$verb = $verbs | Get-Random
$area = $areas | Get-Random
$id = Get-Random -Minimum 4096 -Maximum 16777215
return "{0:HH:mm:ss.fff} [{1}] {2,-28} {3,-9} id={4:x6}" -f (Get-Date), $code, $verb, $area, $id
}
function Get-BuildLogLine {
param([int] $Tick)
$verbs = @(
"Restored package graph",
"Compiled service boundary",
"Generated binding manifest",
"Executed contract fixture",
"Packed symbol archive",
"Signed release artifact",
"Validated provenance chain",
"Published cache segment",
"Scanned dependency closure",
"Merged coverage snapshot",
"Promoted image layer",
"Resolved feature flag matrix"
)
$areas = @("auth", "billing", "orchestrator", "worker", "gateway", "ui-shell", "data-access", "scheduler", "notifier", "reports")
$codes = @("PASS", "CACHE", "TRACE", "LINK", "PACK", "TEST", "SIGN")
$code = $codes | Get-Random
$verb = $verbs | Get-Random
$area = $areas | Get-Random
$duration = Get-Random -Minimum 18 -Maximum 1900
return "{0:HH:mm:ss.fff} [{1}] {2,-30} module={3,-12} {4,4}ms" -f (Get-Date), $code, $verb, $area, $duration
}
function Get-TracePacketLine {
param([int] $Tick)
$protocols = @("TLS1.3", "HTTP/2", "QUIC", "DNSSEC", "mTLS", "gRPC", "AMQP", "NTP")
$states = @("SYN", "ACK", "FIN", "ESTAB", "VERIFY", "ROUTE", "CACHE", "PASS")
$ports = @(443, 53, 123, 5671, 8443, 9443, 50051)
$src = "10.{0}.{1}.{2}" -f (Get-Random -Minimum 16 -Maximum 32), (Get-Random -Minimum 1 -Maximum 254), (Get-Random -Minimum 10 -Maximum 240)
$dst = "172.{0}.{1}.{2}" -f (Get-Random -Minimum 18 -Maximum 30), (Get-Random -Minimum 1 -Maximum 254), (Get-Random -Minimum 10 -Maximum 240)
$protocol = $protocols | Get-Random
$state = $states | Get-Random
$port = $ports | Get-Random
$bytes = Get-Random -Minimum 64 -Maximum 49152
return "{0:HH:mm:ss.fff} {1,-7} {2,-6} {3,-15} -> {4,-15}:{5,-5} {6,6}b" -f (Get-Date), $protocol, $state, $src, $dst, $port, $bytes
}
function New-HexLine {
param([int] $Offset)
$bytes = @()
for ($i = 0; $i -lt 16; $i++) {
$bytes += "{0:x2}" -f (Get-Random -Minimum 0 -Maximum 256)
}
return "{0:x8} {1}" -f $Offset, ($bytes -join " ")
}
function Get-DatabaseAuditLine {
param([int] $Tick)
$verbs = @(
"Checked foreign key window",
"Advanced migration cursor",
"Verified page checksum",
"Rebuilt filtered index",
"Sampled row-version chain",
"Flushed write-ahead marker",
"Compared materialized view",
"Pinned catalog snapshot",
"Measured lock escalation",
"Validated collation boundary",
"Replayed compensating batch",
"Marked partition consistent"
)
$tables = @("customer_ledger", "invoice_line", "payment_batch", "tenant_profile", "audit_event", "inventory_delta", "subscription_term", "queue_outbox")
$codes = @("OK", "SCAN", "LOCK", "PAGE", "IDX", "MVCC", "PLAN")
$code = $codes | Get-Random
$verb = $verbs | Get-Random
$table = $tables | Get-Random
$rows = Get-Random -Minimum 128 -Maximum 98000
return "{0:HH:mm:ss.fff} [{1}] {2,-31} table={3,-18} rows={4,6:n0}" -f (Get-Date), $code, $verb, $table, $rows
}
function Start-OpsConsole {
param(
[int] $RefreshMilliseconds,
[int] $MaxTicks
)
if ([Console]::IsOutputRedirected) {
if ($MaxTicks -gt 0) {
Write-Output "Start-BossKey smoke test passed: mode=ops ticks=$MaxTicks"
return
}
throw "Start-BossKey requires an interactive terminal because it uses full-screen console rendering."
}
$originalTitle = [Console]::Title
$originalCursor = [Console]::CursorVisible
$originalForeground = [Console]::ForegroundColor
$originalBackground = [Console]::BackgroundColor
$rngSeed = Get-Random -Minimum 100000 -Maximum 999999
$cpu = Get-Random -Minimum 38 -Maximum 64
$memory = Get-Random -Minimum 46 -Maximum 72
$queue = Get-Random -Minimum 18 -Maximum 47
$io = Get-Random -Minimum 24 -Maximum 58
$latency = Get-Random -Minimum 11 -Maximum 32
$commit = Get-Random -Minimum 60 -Maximum 93
$tick = 0
$lastWidth = 0
$lastHeight = 0
$layoutDirty = $true
$wasTooSmall = $false
$logs = New-Object System.Collections.Generic.List[string]
try {
[Console]::Title = "Enterprise Data Consolidation Monitor"
[Console]::CursorVisible = $false
[Console]::BackgroundColor = [ConsoleColor]::Black
[Console]::Clear()
while ($true) {
while ([Console]::KeyAvailable) {
$key = [Console]::ReadKey($true)
if ($key.Key -in @([ConsoleKey]::Escape, [ConsoleKey]::Q)) {
return
}
}
$tick++
$width = [Console]::WindowWidth
$height = [Console]::WindowHeight
if ($width -ne $lastWidth -or $height -ne $lastHeight) {
[Console]::Clear()
$lastWidth = $width
$lastHeight = $height
$layoutDirty = $true
}
if ($MaxTicks -gt 0 -and $tick -gt $MaxTicks) {
return
}
if ($width -lt 80 -or $height -lt 24) {
if (-not $wasTooSmall) {
[Console]::Clear()
$wasTooSmall = $true
}
Write-At 2 2 "Resize terminal to at least 80x24. Press Q or Esc to exit." Yellow
Start-Sleep -Milliseconds 500
continue
}
$wasTooSmall = $false
$cpu = Invoke-Walk $cpu 18 91 5.6
$memory = Invoke-Walk $memory 32 88 3.4
$queue = Invoke-Walk $queue 4 76 7.2
$io = Invoke-Walk $io 12 95 6.6
$latency = Invoke-Walk $latency 4 79 5.1
$commit = Invoke-Walk $commit 50 99 2.6
$leftW = [int]($width * 0.38)
$rightW = $width - $leftW - 3
$logTop = 15
$logHeight = $height - 18
$logLeft = 3
$logWidth = $width - 6
$newLogCount = Get-Random -Minimum 2 -Maximum 5
for ($i = 0; $i -lt $newLogCount; $i++) {
$logs.Insert(0, (Get-FakeLogLine -Tick $tick))
}
while ($logs.Count -lt $logHeight) {
$logs.Add((Get-FakeLogLine -Tick $tick))
}
while ($logs.Count -gt $logHeight) {
$logs.RemoveAt($logs.Count - 1)
}
if ($layoutDirty) {
$header = " CONSOLIDATED OPERATIONS FABRIC :: LIVE RECONCILIATION "
Write-At 0 0 ("=" * $width) DarkCyan
Write-At ([Math]::Max(0, [int](($width - $header.Length) / 2))) 0 $header White
Write-At 2 1 ("tenant=prod-west runbook=CR-{0} session={1} press Q/Esc to release" -f (Get-Date -Format "yyyyMMdd"), $rngSeed) DarkGray
Draw-Box 1 3 $leftW 10 "node resource envelope" DarkCyan
Draw-Box ($leftW + 2) 3 $rightW 10 "replication state" DarkCyan
Draw-Box 1 14 ($width - 2) ($height - 16) "event stream" DarkCyan
Write-At 0 ($height - 1) ("=" * $width) DarkCyan
$layoutDirty = $false
}
Write-PaddedAt ($width - 28) 1 26 (Get-Date -Format "yyyy-MM-dd HH:mm:ss") Cyan
$barW = [Math]::Max(10, $leftW - 21)
$metrics = @(
[pscustomobject]@{ Label = "cpu pressure"; Value = $cpu; Color = "DarkGreen" },
[pscustomobject]@{ Label = "memory map"; Value = $memory; Color = "DarkYellow" },
[pscustomobject]@{ Label = "queue depth"; Value = $queue; Color = "DarkMagenta" },
[pscustomobject]@{ Label = "disk journal"; Value = $io; Color = "DarkCyan" },
[pscustomobject]@{ Label = "p95 latency"; Value = $latency; Color = "DarkRed" }
)
for ($i = 0; $i -lt $metrics.Count; $i++) {
$m = $metrics[$i]
$row = 5 + $i
Write-PaddedAt 4 $row 13 ("{0,-13}" -f $m.Label) Gray
Write-PaddedAt 18 $row ($barW + 2) ("[{0}]" -f (New-Bar $m.Value $barW)) ([ConsoleColor]$m.Color)
}
$phase = @("snapshot", "diff scan", "lease renew", "index swap", "checksum", "publish")[$tick % 6]
$replicaRows = @(
"primary west-us-3 healthy lsn={0:n0}" -f (8812042 + ($tick * 31)),
"secondary east-us-1 catching-up lag={0:n1} ms" -f $latency,
"archive coldline-7 sealed extents={0}" -f (420 + ($tick % 47)),
"controller quorum {0,-12} votes=5/5" -f $phase,
"deployment blue/green steady commit={0:n1}%" -f $commit
)
for ($i = 0; $i -lt $replicaRows.Count; $i++) {
$color = if ($i -eq 1 -and $latency -gt 55) { [ConsoleColor]::Yellow } else { [ConsoleColor]::Gray }
Write-PaddedAt ($leftW + 5) (5 + $i) ($rightW - 8) $replicaRows[$i] $color
}
$spark = ""
for ($i = 0; $i -lt [Math]::Min(48, $rightW - 8); $i++) {
$spark += @(".", ":", "-", "=", "+", "#")[(Get-Random -Minimum 0 -Maximum 6)]
}
Write-PaddedAt ($leftW + 5) 11 ($rightW - 8) ("signal: {0}" -f $spark) DarkGray
for ($i = 0; $i -lt $logHeight; $i++) {
$line = $logs[$i]
$color = if ($line -match "DEFER") { [ConsoleColor]::Yellow } elseif ($line -match "TRACE") { [ConsoleColor]::DarkGray } else { [ConsoleColor]::Gray }
Write-PaddedAt $logLeft ($logTop + $i) $logWidth $line $color
}
Write-PaddedAt 2 ($height - 1) ($width - 4) ("refresh={0}s reconciliations={1:n0} last checkpoint={2:HH:mm:ss}" -f ($RefreshMilliseconds / 1000), $tick, (Get-Date)) White
Start-Sleep -Milliseconds $RefreshMilliseconds
}
}
finally {
[Console]::ResetColor()
[Console]::Clear()
[Console]::Title = $originalTitle
[Console]::CursorVisible = $originalCursor
[Console]::ForegroundColor = $originalForeground
[Console]::BackgroundColor = $originalBackground
}
}
function Start-BuildConsole {
param(
[int] $RefreshMilliseconds,
[int] $MaxTicks
)
if ([Console]::IsOutputRedirected) {
if ($MaxTicks -gt 0) {
Write-Output "Start-BossKey smoke test passed: mode=build ticks=$MaxTicks"
return
}
throw "Start-BossKey requires an interactive terminal because it uses full-screen console rendering."
}
$originalTitle = [Console]::Title
$originalCursor = [Console]::CursorVisible
$originalForeground = [Console]::ForegroundColor
$originalBackground = [Console]::BackgroundColor
$pipelineId = Get-Random -Minimum 21000 -Maximum 98000
$compile = Get-Random -Minimum 35 -Maximum 70
$tests = Get-Random -Minimum 18 -Maximum 48
$coverage = Get-Random -Minimum 72 -Maximum 88
$scan = Get-Random -Minimum 28 -Maximum 64
$publish = Get-Random -Minimum 12 -Maximum 38
$tick = 0
$lastWidth = 0
$lastHeight = 0
$layoutDirty = $true
$wasTooSmall = $false
$logs = New-Object System.Collections.Generic.List[string]
try {
[Console]::Title = "Release Pipeline Verification"
[Console]::CursorVisible = $false
[Console]::BackgroundColor = [ConsoleColor]::Black
[Console]::Clear()
while ($true) {
while ([Console]::KeyAvailable) {
$key = [Console]::ReadKey($true)
if ($key.Key -in @([ConsoleKey]::Escape, [ConsoleKey]::Q)) {
return
}
}
$tick++
$width = [Console]::WindowWidth
$height = [Console]::WindowHeight
if ($width -ne $lastWidth -or $height -ne $lastHeight) {
[Console]::Clear()
$lastWidth = $width
$lastHeight = $height
$layoutDirty = $true
}
if ($MaxTicks -gt 0 -and $tick -gt $MaxTicks) {
return
}
if ($width -lt 80 -or $height -lt 24) {
if (-not $wasTooSmall) {
[Console]::Clear()
$wasTooSmall = $true
}
Write-At 2 2 "Resize terminal to at least 80x24. Press Q or Esc to exit." Yellow
Start-Sleep -Milliseconds 500
continue
}
$wasTooSmall = $false
$compile = Invoke-Walk $compile 20 100 8.0
$tests = Invoke-Walk $tests 10 100 9.5
$coverage = Invoke-Walk $coverage 66 96 2.2
$scan = Invoke-Walk $scan 14 100 10.0
$publish = Invoke-Walk $publish 8 100 7.4
$laneW = [int](($width - 5) / 4)
$lane1 = 1
$lane2 = $lane1 + $laneW + 1
$lane3 = $lane2 + $laneW + 1
$lane4 = $lane3 + $laneW + 1
$laneH = [Math]::Max(9, [int](($height - 8) * 0.44))
$bottomTop = 4 + $laneH
$bottomH = $height - $bottomTop - 2
$leftW = [int](($width - 4) * 0.32)
$midW = [int](($width - 4) * 0.28)
$rightW = $width - $leftW - $midW - 4
$tailTop = $bottomTop + 2
$tailHeight = [Math]::Max(3, $bottomH - 3)
$tailLeft = $leftW + $midW + 4
$tailWidth = $rightW - 2
$newLogCount = Get-Random -Minimum 3 -Maximum 6
for ($i = 0; $i -lt $newLogCount; $i++) {
$logs.Insert(0, (Get-BuildLogLine -Tick $tick))
}
while ($logs.Count -lt $tailHeight) {
$logs.Add((Get-BuildLogLine -Tick $tick))
}
while ($logs.Count -gt $tailHeight) {
$logs.RemoveAt($logs.Count - 1)
}
if ($layoutDirty) {
$header = " CI ORCHESTRATION BOARD :: RELEASE CANDIDATE "
Write-At 0 0 ("=" * $width) DarkGreen
Write-At ([Math]::Max(0, [int](($width - $header.Length) / 2))) 0 $header White
Write-At 2 1 ("repo=platform/services branch=main run=RP-{0} agent-pool=windows-x64 press Q/Esc to release" -f $pipelineId) DarkGray
Draw-Box $lane1 3 $laneW $laneH "restore" DarkGreen
Draw-Box $lane2 3 $laneW $laneH "compile" DarkGreen
Draw-Box $lane3 3 $laneW $laneH "test" DarkGreen
Draw-Box $lane4 3 $laneW $laneH "release" DarkGreen
Draw-Box 1 $bottomTop $leftW $bottomH "test shards" DarkGreen
Draw-Box ($leftW + 2) $bottomTop $midW $bottomH "artifact manifest" DarkGreen
Draw-Box ($leftW + $midW + 3) $bottomTop $rightW $bottomH "console tail" DarkGreen
Write-At 0 ($height - 1) ("=" * $width) DarkGreen
$layoutDirty = $false
}
Write-PaddedAt ($width - 28) 1 26 (Get-Date -Format "yyyy-MM-dd HH:mm:ss") Green
$laneBarW = [Math]::Max(8, $laneW - 8)
$lanes = @(
[pscustomobject]@{ Left = $lane1; Percent = 100; Color = "DarkGreen"; Jobs = @("nuget graph", "tool restore", "cache hydrate", "sdk probe") },
[pscustomobject]@{ Left = $lane2; Percent = $compile; Color = "Green"; Jobs = @("core api", "worker host", "admin ui", "contracts") },
[pscustomobject]@{ Left = $lane3; Percent = $tests; Color = "DarkCyan"; Jobs = @("unit x64", "browser e2e", "contract", "mutation") },
[pscustomobject]@{ Left = $lane4; Percent = $publish; Color = "DarkMagenta"; Jobs = @("image pack", "sbom", "signing", "promote") }
)
foreach ($lane in $lanes) {
Write-PaddedAt ($lane.Left + 3) 5 ($laneW - 5) ("[{0}]" -f (New-Bar $lane.Percent $laneBarW)) ([ConsoleColor]$lane.Color)
Write-PaddedAt ($lane.Left + 3) 6 ($laneW - 5) ("{0,5:n1}% complete" -f $lane.Percent) Gray
for ($j = 0; $j -lt [Math]::Min($lane.Jobs.Count, $laneH - 5); $j++) {
$mark = if ($j -lt (($tick + $lane.Left) % ($lane.Jobs.Count + 1))) { "done" } else { "run " }
$color = if ($mark -eq "done") { [ConsoleColor]::Green } else { [ConsoleColor]::DarkGray }
Write-PaddedAt ($lane.Left + 3) (8 + $j) ($laneW - 5) ("{0} {1}" -f $mark, $lane.Jobs[$j]) $color
}
}
$failed = if ($tick % 17 -eq 0) { 1 } else { 0 }
$shards = @(
[pscustomobject]@{ Name = "unit-a"; Count = 418 + ($tick * 2); Status = "pass" },
[pscustomobject]@{ Name = "unit-b"; Count = 391 + ($tick * 2); Status = "pass" },
[pscustomobject]@{ Name = "api"; Count = 146 + $tick; Status = "pass" },
[pscustomobject]@{ Name = "e2e"; Count = 63 + ($tick % 12); Status = if ($failed) { "retry" } else { "pass" } },
[pscustomobject]@{ Name = "smoke"; Count = 28 + ($tick % 5); Status = "pass" }
)
for ($i = 0; $i -lt [Math]::Min($shards.Count, $bottomH - 3); $i++) {
$shard = $shards[$i]
$color = if ($shard.Status -eq "retry") { [ConsoleColor]::Yellow } else { [ConsoleColor]::Green }
Write-PaddedAt 4 ($bottomTop + 2 + $i) ($leftW - 6) ("{0,-8} {1,4:n0} tests {2}" -f $shard.Name, $shard.Count, $shard.Status) $color
}
Write-PaddedAt 4 ($bottomTop + $bottomH - 2) ($leftW - 6) ("coverage {0:n1}% flaky quarantine={1}" -f $coverage, ($tick % 4)) DarkGray
$artifacts = @(
"service-api.zip {0,5:n1} MB" -f (42 + ($compile / 9)),
"worker-host.zip {0,5:n1} MB" -f (31 + ($tests / 11)),
"web-assets.tgz {0,5:n1} MB" -f (18 + ($publish / 13)),
"sbom.spdx.json signed",
"provenance.intoto verified",
"image digest {0:x8}" -f (Get-Random -Minimum 1048576 -Maximum 2147483647)
)
for ($i = 0; $i -lt [Math]::Min($artifacts.Count, $bottomH - 3); $i++) {
$color = if ($artifacts[$i] -match "signed|verified") { [ConsoleColor]::Green } else { [ConsoleColor]::Gray }
Write-PaddedAt ($leftW + 5) ($bottomTop + 2 + $i) ($midW - 8) $artifacts[$i] $color
}
for ($i = 0; $i -lt $tailHeight; $i++) {
$line = $logs[$i]
$color = if ($line -match "PASS|SIGN") { [ConsoleColor]::Green } elseif ($line -match "TRACE|CACHE") { [ConsoleColor]::DarkGray } else { [ConsoleColor]::Gray }
Write-PaddedAt $tailLeft ($tailTop + $i) $tailWidth $line $color
}
Write-PaddedAt 2 ($height - 1) ($width - 4) ("refresh={0}s run={1} gates=coverage:{2:n1}% scan:{3:n1}% publish:{4:n1}%" -f ($RefreshMilliseconds / 1000), $pipelineId, $coverage, $scan, $publish) White
Start-Sleep -Milliseconds $RefreshMilliseconds
}
}
finally {
[Console]::ResetColor()
[Console]::Clear()
[Console]::Title = $originalTitle
[Console]::CursorVisible = $originalCursor
[Console]::ForegroundColor = $originalForeground
[Console]::BackgroundColor = $originalBackground
}
}
function Start-TraceConsole {
param(
[int] $RefreshMilliseconds,
[int] $MaxTicks
)
if ([Console]::IsOutputRedirected) {
if ($MaxTicks -gt 0) {
Write-Output "Start-BossKey smoke test passed: mode=trace ticks=$MaxTicks"
return
}
throw "Start-BossKey requires an interactive terminal because it uses full-screen console rendering."
}
$originalTitle = [Console]::Title
$originalCursor = [Console]::CursorVisible
$originalForeground = [Console]::ForegroundColor
$originalBackground = [Console]::BackgroundColor
$captureId = Get-Random -Minimum 300000 -Maximum 999999
$tick = 0
$lastWidth = 0
$lastHeight = 0
$layoutDirty = $true
$wasTooSmall = $false
$packetLines = New-Object System.Collections.Generic.List[string]
$hexOffset = Get-Random -Minimum 1048576 -Maximum 16777216
$loss = Get-Random -Minimum 0 -Maximum 3
$jitter = Get-Random -Minimum 4 -Maximum 18
$sessions = Get-Random -Minimum 80 -Maximum 160
try {
[Console]::Title = "Network Trace Capture"
[Console]::CursorVisible = $false
[Console]::BackgroundColor = [ConsoleColor]::Black
[Console]::Clear()
while ($true) {
while ([Console]::KeyAvailable) {
$key = [Console]::ReadKey($true)
if ($key.Key -in @([ConsoleKey]::Escape, [ConsoleKey]::Q)) {
return
}
}
$tick++
$width = [Console]::WindowWidth
$height = [Console]::WindowHeight
if ($width -ne $lastWidth -or $height -ne $lastHeight) {
[Console]::Clear()
$lastWidth = $width
$lastHeight = $height
$layoutDirty = $true
}
if ($MaxTicks -gt 0 -and $tick -gt $MaxTicks) {
return
}
if ($width -lt 90 -or $height -lt 26) {
if (-not $wasTooSmall) {
[Console]::Clear()
$wasTooSmall = $true
}
Write-At 2 2 "Resize terminal to at least 90x26. Press Q or Esc to exit." Yellow
Start-Sleep -Milliseconds 500
continue
}
$wasTooSmall = $false
$leftW = [int]($width * 0.58)
$rightW = $width - $leftW - 3
$topBoxHeight = 8
$feedTop = 12
$feedHeight = $height - 15
$feedWidth = $leftW - 4
$hexTop = 12
$hexHeight = $height - 15
$hexWidth = $rightW - 4
$loss = Invoke-Walk $loss 0 8 1.4
$jitter = Invoke-Walk $jitter 2 45 5.2
$sessions = [int](Invoke-Walk $sessions 42 310 18)
$newPacketCount = Get-Random -Minimum 4 -Maximum 8
for ($i = 0; $i -lt $newPacketCount; $i++) {
$packetLines.Insert(0, (Get-TracePacketLine -Tick $tick))
}
while ($packetLines.Count -lt $feedHeight) {
$packetLines.Add((Get-TracePacketLine -Tick $tick))
}
while ($packetLines.Count -gt $feedHeight) {
$packetLines.RemoveAt($packetLines.Count - 1)
}
if ($layoutDirty) {
$title = " PACKET TRACE :: SESSION CAPTURE "
Write-At 0 0 ("-" * $width) DarkMagenta
Write-At ([Math]::Max(0, [int](($width - $title.Length) / 2))) 0 $title White
Write-At 2 1 ("adapter=vEthernet(Default Switch) capture=NT-{0} filter=tcp or udp press Q/Esc to release" -f $captureId) DarkGray
Draw-Box 1 3 $leftW $topBoxHeight "route probe" DarkMagenta
Draw-Box ($leftW + 2) 3 $rightW $topBoxHeight "session health" DarkMagenta
Draw-Box 1 11 $leftW ($height - 13) "packet feed" DarkMagenta
Draw-Box ($leftW + 2) 11 $rightW ($height - 13) "payload sample" DarkMagenta
Write-At 0 ($height - 1) ("-" * $width) DarkMagenta
$layoutDirty = $false
}
Write-PaddedAt ($width - 28) 1 26 (Get-Date -Format "yyyy-MM-dd HH:mm:ss") Magenta
$hops = @(
"local nic 10.24.18.42 metric=5 mtu=1500",
"edge gateway 10.24.18.1 metric=10 nat=active",
"regional mux 172.20.8.14 metric=18 qos=gold",
"service mesh 172.24.90.33 metric=21 tls=mutual",
"origin cluster 172.26.11.204 metric=24 healthy"
)
for ($i = 0; $i -lt $hops.Count; $i++) {
$arrow = if ($i -eq ($tick % $hops.Count)) { "=>" } else { " " }
$color = if ($arrow -eq "=>") { [ConsoleColor]::Cyan } else { [ConsoleColor]::Gray }
Write-PaddedAt 4 (5 + $i) ($leftW - 6) ("{0} {1}" -f $arrow, $hops[$i]) $color
}
$healthRows = @(
"sessions {0,5:n0} active" -f $sessions,
"packet loss {0,5:n1}% sampled" -f $loss,
"jitter p95 {0,5:n1} ms" -f $jitter,
"cipher TLS_AES_256_GCM_SHA384",
"verdict pass-through inspection"
)
for ($i = 0; $i -lt $healthRows.Count; $i++) {
$color = if ($i -eq 1 -and $loss -gt 5) { [ConsoleColor]::Yellow } elseif ($i -eq 4) { [ConsoleColor]::Green } else { [ConsoleColor]::Gray }
Write-PaddedAt ($leftW + 5) (5 + $i) ($rightW - 8) $healthRows[$i] $color
}
for ($i = 0; $i -lt $feedHeight; $i++) {
$line = $packetLines[$i]
$color = if ($line -match "SYN|FIN") { [ConsoleColor]::Yellow } elseif ($line -match "PASS|ACK") { [ConsoleColor]::Cyan } else { [ConsoleColor]::Gray }
Write-PaddedAt 3 ($feedTop + $i) $feedWidth $line $color
}
for ($i = 0; $i -lt $hexHeight; $i++) {
$line = New-HexLine -Offset ($hexOffset + (($tick + $i) * 16))
$color = if ($i % 4 -eq 0) { [ConsoleColor]::DarkCyan } else { [ConsoleColor]::DarkGray }
Write-PaddedAt ($leftW + 4) ($hexTop + $i) $hexWidth $line $color
}
Write-PaddedAt 2 ($height - 1) ($width - 4) ("refresh={0}s captured={1:n0} packets ring-buffer={2:n0}kb" -f ($RefreshMilliseconds / 1000), ($tick * 37 + $packetLines.Count), (4096 + ($tick % 512))) White
Start-Sleep -Milliseconds $RefreshMilliseconds
}
}
finally {
[Console]::ResetColor()
[Console]::Clear()
[Console]::Title = $originalTitle
[Console]::CursorVisible = $originalCursor
[Console]::ForegroundColor = $originalForeground
[Console]::BackgroundColor = $originalBackground
}
}
function Start-DatabaseConsole {
param(
[int] $RefreshMilliseconds,
[int] $MaxTicks
)
if ([Console]::IsOutputRedirected) {
if ($MaxTicks -gt 0) {
Write-Output "Start-BossKey smoke test passed: mode=db ticks=$MaxTicks"
return
}
throw "Start-BossKey requires an interactive terminal because it uses full-screen console rendering."
}
$originalTitle = [Console]::Title
$originalCursor = [Console]::CursorVisible
$originalForeground = [Console]::ForegroundColor
$originalBackground = [Console]::BackgroundColor
$jobId = Get-Random -Minimum 700000 -Maximum 999999
$tick = 0
$lastWidth = 0
$lastHeight = 0
$layoutDirty = $true
$wasTooSmall = $false
$auditLines = New-Object System.Collections.Generic.List[string]
$readLag = Get-Random -Minimum 8 -Maximum 24
$writeLag = Get-Random -Minimum 4 -Maximum 18
$lockWait = Get-Random -Minimum 1 -Maximum 12
$checksum = Get-Random -Minimum 55 -Maximum 86
$vacuum = Get-Random -Minimum 18 -Maximum 49
try {
[Console]::Title = "Database Integrity Audit"
[Console]::CursorVisible = $false
[Console]::BackgroundColor = [ConsoleColor]::Black
[Console]::Clear()
while ($true) {
while ([Console]::KeyAvailable) {
$key = [Console]::ReadKey($true)
if ($key.Key -in @([ConsoleKey]::Escape, [ConsoleKey]::Q)) {
return
}
}
$tick++
$width = [Console]::WindowWidth
$height = [Console]::WindowHeight
if ($width -ne $lastWidth -or $height -ne $lastHeight) {
[Console]::Clear()
$lastWidth = $width
$lastHeight = $height
$layoutDirty = $true
}
if ($MaxTicks -gt 0 -and $tick -gt $MaxTicks) {
return
}
if ($width -lt 90 -or $height -lt 26) {
if (-not $wasTooSmall) {
[Console]::Clear()
$wasTooSmall = $true
}
Write-At 2 2 "Resize terminal to at least 90x26. Press Q or Esc to exit." Yellow
Start-Sleep -Milliseconds 500
continue
}
$wasTooSmall = $false
$readLag = Invoke-Walk $readLag 1 80 6.5
$writeLag = Invoke-Walk $writeLag 1 64 5.4
$lockWait = Invoke-Walk $lockWait 0 35 4.0
$checksum = Invoke-Walk $checksum 45 100 4.2
$vacuum = Invoke-Walk $vacuum 8 100 6.8
$leftW = [int]($width * 0.36)
$middleW = [int]($width * 0.31)
$rightW = $width - $leftW - $middleW - 4
$auditTop = 14
$auditHeight = $height - 17
$auditWidth = $width - 6
$newAuditCount = Get-Random -Minimum 2 -Maximum 6
for ($i = 0; $i -lt $newAuditCount; $i++) {
$auditLines.Insert(0, (Get-DatabaseAuditLine -Tick $tick))
}
while ($auditLines.Count -lt $auditHeight) {
$auditLines.Add((Get-DatabaseAuditLine -Tick $tick))
}
while ($auditLines.Count -gt $auditHeight) {
$auditLines.RemoveAt($auditLines.Count - 1)
}
if ($layoutDirty) {
$title = " RELATIONAL STORE :: CONSISTENCY AUDIT "
Write-At 0 0 ("." * $width) DarkYellow
Write-At ([Math]::Max(0, [int](($width - $title.Length) / 2))) 0 $title White
Write-At 2 1 ("cluster=sql-prod-a job=DBA-{0} isolation=snapshot press Q/Esc to release" -f $jobId) DarkGray
Draw-Box 1 3 $leftW 9 "partition map" DarkYellow
Draw-Box ($leftW + 2) 3 $middleW 9 "lock monitor" DarkYellow
Draw-Box ($leftW + $middleW + 3) 3 $rightW 9 "maintenance" DarkYellow
Draw-Box 1 13 ($width - 2) ($height - 15) "audit trail" DarkYellow
Write-At 0 ($height - 1) ("." * $width) DarkYellow
$layoutDirty = $false
}
Write-PaddedAt ($width - 28) 1 26 (Get-Date -Format "yyyy-MM-dd HH:mm:ss") Yellow
$partitionRows = @(
"p2026_01 sealed {0,8:n0} pages" -f (81240 + ($tick * 3)),
"p2026_02 sealed {0,8:n0} pages" -f (84518 + ($tick * 2)),
"p2026_03 active {0,8:n0} pages" -f (90214 + ($tick * 9)),
"p2026_04 active {0,8:n0} pages" -f (73420 + ($tick * 11)),
"p_hot writable {0,8:n0} pages" -f (18112 + ($tick * 17))
)
for ($i = 0; $i -lt $partitionRows.Count; $i++) {
$color = if ($partitionRows[$i] -match "hot|active") { [ConsoleColor]::Cyan } else { [ConsoleColor]::Gray }
Write-PaddedAt 4 (5 + $i) ($leftW - 6) $partitionRows[$i] $color
}
$lockRows = @(
"read replica lag {0,5:n1} ms" -f $readLag,
"write queue lag {0,5:n1} ms" -f $writeLag,
"lock wait p95 {0,5:n1} ms" -f $lockWait,
"deadlock monitor quiet",
"snapshot age {0,5:n0} sec" -f (28 + ($tick % 90))
)
for ($i = 0; $i -lt $lockRows.Count; $i++) {
$color = if ($i -eq 2 -and $lockWait -gt 24) { [ConsoleColor]::Yellow } elseif ($i -eq 3) { [ConsoleColor]::Green } else { [ConsoleColor]::Gray }
Write-PaddedAt ($leftW + 5) (5 + $i) ($middleW - 8) $lockRows[$i] $color
}
$barW = [Math]::Max(8, $rightW - 18)
$maintenanceRows = @(
[pscustomobject]@{ Label = "checksum"; Value = $checksum; Color = "Green" },
[pscustomobject]@{ Label = "vacuum"; Value = $vacuum; Color = "DarkCyan" },
[pscustomobject]@{ Label = "reindex"; Value = ((($tick * 7) % 100)); Color = "DarkMagenta" }
)
for ($i = 0; $i -lt $maintenanceRows.Count; $i++) {
$row = $maintenanceRows[$i]
Write-PaddedAt ($leftW + $middleW + 6) (5 + $i) 9 ("{0,-9}" -f $row.Label) Gray
Write-PaddedAt ($leftW + $middleW + 16) (5 + $i) ($barW + 2) ("[{0}]" -f (New-Bar $row.Value $barW)) ([ConsoleColor]$row.Color)
}
Write-PaddedAt ($leftW + $middleW + 6) 9 ($rightW - 8) ("plan hash 0x{0:x8}" -f (Get-Random -Minimum 1048576 -Maximum 2147483647)) DarkGray
for ($i = 0; $i -lt $auditHeight; $i++) {
$line = $auditLines[$i]
$color = if ($line -match "LOCK") { [ConsoleColor]::Yellow } elseif ($line -match "IDX|MVCC") { [ConsoleColor]::Cyan } else { [ConsoleColor]::Gray }
Write-PaddedAt 3 ($auditTop + $i) $auditWidth $line $color
}
Write-PaddedAt 2 ($height - 1) ($width - 4) ("refresh={0}s snapshots={1:n0} xid={2:x8}" -f ($RefreshMilliseconds / 1000), $tick, (Get-Random -Minimum 1048576 -Maximum 2147483647)) White
Start-Sleep -Milliseconds $RefreshMilliseconds
}
}
finally {
[Console]::ResetColor()
[Console]::Clear()
[Console]::Title = $originalTitle
[Console]::CursorVisible = $originalCursor
[Console]::ForegroundColor = $originalForeground
[Console]::BackgroundColor = $originalBackground
}
}
function Start-ControlConsole {
param(
[int] $RefreshMilliseconds,
[int] $MaxTicks
)
if ([Console]::IsOutputRedirected) {
if ($MaxTicks -gt 0) {
Write-Output "Start-BossKey smoke test passed: mode=control ticks=$MaxTicks"
return
}
throw "Start-BossKey requires an interactive terminal because it uses full-screen console rendering."
}
$originalTitle = [Console]::Title
$originalCursor = [Console]::CursorVisible
$originalForeground = [Console]::ForegroundColor
$originalBackground = [Console]::BackgroundColor
$consoleId = Get-Random -Minimum 1000 -Maximum 9999
$tick = 0
$lastWidth = 0
$lastHeight = 0
$layoutDirty = $true
$wasTooSmall = $false
$throughput = Get-Random -Minimum 58 -Maximum 82
$saturation = Get-Random -Minimum 28 -Maximum 54
$availability = Get-Random -Minimum 96 -Maximum 100
$backlog = Get-Random -Minimum 14 -Maximum 42
$risk = Get-Random -Minimum 8 -Maximum 26
$budget = Get-Random -Minimum 60 -Maximum 86
try {
[Console]::Title = "Service Control Widgets"
[Console]::CursorVisible = $false
[Console]::BackgroundColor = [ConsoleColor]::Black
[Console]::Clear()
while ($true) {
while ([Console]::KeyAvailable) {
$key = [Console]::ReadKey($true)
if ($key.Key -in @([ConsoleKey]::Escape, [ConsoleKey]::Q)) {
return
}
}
$tick++
$width = [Console]::WindowWidth
$height = [Console]::WindowHeight
if ($width -ne $lastWidth -or $height -ne $lastHeight) {
[Console]::Clear()
$lastWidth = $width
$lastHeight = $height
$layoutDirty = $true
}
if ($MaxTicks -gt 0 -and $tick -gt $MaxTicks) {
return
}
if ($width -lt 96 -or $height -lt 30) {
if (-not $wasTooSmall) {
[Console]::Clear()
$wasTooSmall = $true
}
Write-At 2 2 "Resize terminal to at least 96x30. Press Q or Esc to exit." Yellow
Start-Sleep -Milliseconds 500
continue
}
$wasTooSmall = $false
$throughput = Invoke-Walk $throughput 35 98 5.8
$saturation = Invoke-Walk $saturation 12 88 7.0
$availability = Invoke-Walk $availability 93 100 0.9
$backlog = Invoke-Walk $backlog 0 92 8.0
$risk = Invoke-Walk $risk 1 76 5.4
$budget = Invoke-Walk $budget 30 100 4.2
$tileW = [int](($width - 5) / 4)
$col1 = 1
$col2 = $col1 + $tileW + 1
$col3 = $col2 + $tileW + 1
$col4 = $col3 + $tileW + 1
$mainTop = 10
$mainH = [int](($height - 14) / 2)
$bottomTop = $mainTop + $mainH + 1
$bottomH = $height - $bottomTop - 2
$leftW = [int](($width - 4) * 0.42)
$midW = [int](($width - 4) * 0.32)
$rightW = $width - $leftW - $midW - 4
if ($layoutDirty) {
$title = " CONTROL PLANE :: WIDGET SUMMARY "
Write-At 0 0 ("#" * $width) DarkBlue
Write-At ([Math]::Max(0, [int](($width - $title.Length) / 2))) 0 $title White
Write-At 2 1 ("console=CP-{0} window=rolling-15m source=service-fabric press Q/Esc to release" -f $consoleId) DarkGray
Draw-Box $col1 3 $tileW 6 "throughput" DarkBlue
Draw-Box $col2 3 $tileW 6 "availability" DarkBlue
Draw-Box $col3 3 $tileW 6 "backlog" DarkBlue
Draw-Box $col4 3 $tileW 6 "risk" DarkBlue
Draw-Box 1 $mainTop $leftW $mainH "capacity mix" DarkBlue
Draw-Box ($leftW + 2) $mainTop $midW $mainH "service matrix" DarkBlue
Draw-Box ($leftW + $midW + 3) $mainTop $rightW $mainH "window plan" DarkBlue
Draw-Box 1 $bottomTop $leftW $bottomH "regional balance" DarkBlue
Draw-Box ($leftW + 2) $bottomTop $midW $bottomH "dependency risk" DarkBlue
Draw-Box ($leftW + $midW + 3) $bottomTop $rightW $bottomH "budget guard" DarkBlue
Write-At 0 ($height - 1) ("#" * $width) DarkBlue
$layoutDirty = $false
}
Write-PaddedAt ($width - 28) 1 26 (Get-Date -Format "yyyy-MM-dd HH:mm:ss") Blue
$tileValues = @(
[pscustomobject]@{ Left = $col1; Value = "{0:n1}k/min" -f (42 + ($throughput * 1.7)); Detail = "flow {0}" -f (New-Sparkline ([Math]::Max(6, $tileW - 12))); Color = "Cyan" },
[pscustomobject]@{ Left = $col2; Value = "{0:n2}%" -f $availability; Detail = "slo 99.50 target"; Color = "Green" },
[pscustomobject]@{ Left = $col3; Value = "{0:n0} jobs" -f (120 + ($backlog * 16)); Detail = "queue {0}" -f (New-Bar $backlog ([Math]::Max(6, $tileW - 12))); Color = "Yellow" },
[pscustomobject]@{ Left = $col4; Value = "{0:n1} score" -f $risk; Detail = "drift {0}" -f (New-Sparkline ([Math]::Max(6, $tileW - 13))); Color = "Magenta" }
)
foreach ($tile in $tileValues) {
$color = [ConsoleColor]$tile.Color
Write-PaddedAt ($tile.Left + 3) 5 ($tileW - 5) $tile.Value $color
Write-PaddedAt ($tile.Left + 3) 7 ($tileW - 5) $tile.Detail DarkGray
}
$capRows = @(
[pscustomobject]@{ Label = "compute"; Value = $throughput; Color = "DarkCyan" },
[pscustomobject]@{ Label = "memory"; Value = $saturation; Color = "DarkYellow" },
[pscustomobject]@{ Label = "network"; Value = (100 - $risk); Color = "DarkGreen" },
[pscustomobject]@{ Label = "storage"; Value = $budget; Color = "DarkMagenta" },
[pscustomobject]@{ Label = "scheduler"; Value = (100 - $backlog); Color = "DarkBlue" }
)
$capBarW = [Math]::Max(8, $leftW - 18)
for ($i = 0; $i -lt [Math]::Min($capRows.Count, $mainH - 3); $i++) {
$row = $capRows[$i]
Write-PaddedAt 4 ($mainTop + 2 + $i) 10 ("{0,-10}" -f $row.Label) Gray
Write-PaddedAt 15 ($mainTop + 2 + $i) ($capBarW + 2) ("[{0}]" -f (New-Bar $row.Value $capBarW)) ([ConsoleColor]$row.Color)
}
$services = @("auth", "jobs", "billing", "search", "edge", "cache", "report", "sync")
for ($i = 0; $i -lt [Math]::Min($services.Count, $mainH - 3); $i++) {
$state = @("steady", "warm", "green", "watch")[(Get-Random -Minimum 0 -Maximum 4)]
$color = if ($state -eq "watch") { [ConsoleColor]::Yellow } elseif ($state -eq "green") { [ConsoleColor]::Green } else { [ConsoleColor]::Gray }
Write-PaddedAt ($leftW + 5) ($mainTop + 2 + $i) ($midW - 8) ("{0,-10} {1,-7} r={2,3:n0}ms" -f $services[$i], $state, (Get-Random -Minimum 18 -Maximum 180)) $color
}
$planRows = @(
"00-15 batch drain active",
"15-30 canary compare queued",
"30-45 policy refresh ready",
"45-60 tenant rebalance ready",
"next hold window clear"
)
for ($i = 0; $i -lt [Math]::Min($planRows.Count, $mainH - 3); $i++) {
$color = if ($i -eq ($tick % $planRows.Count)) { [ConsoleColor]::Cyan } else { [ConsoleColor]::Gray }
Write-PaddedAt ($leftW + $midW + 6) ($mainTop + 2 + $i) ($rightW - 8) $planRows[$i] $color
}
$regions = @("nam-east", "nam-west", "eur-core", "apac-1", "latam")
$regionBarW = [Math]::Max(8, $leftW - 20)
for ($i = 0; $i -lt [Math]::Min($regions.Count, $bottomH - 3); $i++) {
$value = Get-Random -Minimum 30 -Maximum 96
Write-PaddedAt 4 ($bottomTop + 2 + $i) 11 ("{0,-11}" -f $regions[$i]) Gray
Write-PaddedAt 16 ($bottomTop + 2 + $i) ($regionBarW + 2) ("[{0}]" -f (New-Bar $value $regionBarW)) DarkCyan
}
$riskCells = @("idp", "queue", "cdn", "vault", "sql", "bus", "dns", "obs", "smtp")
$cellW = [Math]::Max(7, [int](($midW - 8) / 3))
for ($i = 0; $i -lt [Math]::Min($riskCells.Count, (($bottomH - 3) * 3)); $i++) {
$x = ($leftW + 5) + (($i % 3) * $cellW)
$y = $bottomTop + 2 + [int]($i / 3)
$status = @("OK", "OK", "OK", "WARN")[(Get-Random -Minimum 0 -Maximum 4)]
$color = if ($status -eq "WARN") { [ConsoleColor]::Yellow } else { [ConsoleColor]::Green }
Write-PaddedAt $x $y ($cellW - 1) ("{0}:{1}" -f $riskCells[$i], $status) $color
}
$budgetBarW = [Math]::Max(8, $rightW - 12)
$budgetRows = @(
[pscustomobject]@{ Label = "commit"; Value = $budget; Color = "Green" },
[pscustomobject]@{ Label = "error"; Value = ((100 - $availability) * 18); Color = "DarkYellow" },
[pscustomobject]@{ Label = "spend"; Value = (100 - $budget); Color = "DarkMagenta" }
)
for ($i = 0; $i -lt [Math]::Min($budgetRows.Count, $bottomH - 3); $i++) {
$row = $budgetRows[$i]
Write-PaddedAt ($leftW + $midW + 6) ($bottomTop + 2 + ($i * 2)) ($rightW - 8) ("{0,-7} [{1}]" -f $row.Label, (New-Bar $row.Value $budgetBarW)) ([ConsoleColor]$row.Color)
}
Write-PaddedAt 2 ($height - 1) ($width - 4) ("refresh={0}s panels={1} policy epoch={2:n0}" -f ($RefreshMilliseconds / 1000), 22, (8800 + $tick)) White
Start-Sleep -Milliseconds $RefreshMilliseconds
}
}
finally {
[Console]::ResetColor()
[Console]::Clear()
[Console]::Title = $originalTitle
[Console]::CursorVisible = $originalCursor
[Console]::ForegroundColor = $originalForeground
[Console]::BackgroundColor = $originalBackground
}
}
$selectedMode = Select-BossKeyMode -RequestedMode $Mode
$modeTable = Get-BossKeyModes
& $modeTable[$selectedMode]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment