From 900bf890aa81f92471ee5e0cb51e8a452954017b Mon Sep 17 00:00:00 2001 From: kali-upper Date: Tue, 3 Nov 2026 02:43:25 +0200 Subject: [PATCH] feat(zcode): persist clone-launch console output to tools/logs transcripts The launcher windows opened by GHOST.bat ZCode [1]-[6] close automatically when done, and the Desktop/Start-menu shortcuts run the same script with -WindowStyle Hidden - so the ram-guard exchange, seed/telegram/sync steps, spawn PID and taskbar stamping were unreviewable after the fact. launch_zcode_second_instance.ps1 now appends every run to tools/logs/launch_zcode_.log via Start-Transcript (one file per instance so the five parallel launchers never interleave; -Append + -IncludeInvocationHeader). Setup and teardown are best-effort: transcript failure prints a yellow warning and never blocks the launch, and Stop-Transcript runs before the ram-guard exit-0 paths and at script end. GHOST.bat ZCode [6] prints the log location after opening the windows. --- CHANGELOG.md | 12 ++++++++++ GHOST.bat | 1 + src/windows/launch_zcode_second_instance.ps1 | 24 ++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 456e721..f9c8282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,18 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ## [Unreleased] ### Added +- **ZCode clone launches persist their console output to a log** (2026-11-03): + `launch_zcode_second_instance.ps1` appends every run to + `tools\logs\launch_zcode_.log` via a PowerShell transcript (one + file per instance, `-Append` with invocation headers) — the auto-closing + GHOST.bat launcher windows (ZCode [1]-[6]) and the hidden Desktop/Start-menu + shortcut launches no longer lose their output: the ram-guard question and + answer, seed/telegram/sync step results, spawn PID and taskbar stamping are + all reviewable after the fact. Logging is fully best-effort: a transcript + failure prints a yellow warning and never blocks the launch, and + `Stop-Transcript` runs before the ram-guard `exit 0` paths and at script + end. GHOST.bat ZCode [6] also prints the log location after opening the + five windows. - **ZCode patch [27] waits for you to close the app** (2026-10-31): `patch_zcode_icon_override.ps1` gained `-WaitForClose` (GHOST.bat ZCode [27] passes it via `:RunWith`'s new optional extra-args slot) — when diff --git a/GHOST.bat b/GHOST.bat index e676d0c..0277299 100644 --- a/GHOST.bat +++ b/GHOST.bat @@ -488,6 +488,7 @@ if "%~1"=="18" ( call :StartClone "ZCode Orange" "src\windows\launch_zcode_second_instance.ps1" "-Instance Sixth" echo Five launcher windows opened - each closes automatically when done. echo First runs clone the Primary profile, so expect a short delay per clone. + echo Launch logs: tools\logs\launch_zcode_Second..Sixth.log - one file per clone. pause exit /b ) diff --git a/src/windows/launch_zcode_second_instance.ps1 b/src/windows/launch_zcode_second_instance.ps1 index 7079da9..c476f21 100644 --- a/src/windows/launch_zcode_second_instance.ps1 +++ b/src/windows/launch_zcode_second_instance.ps1 @@ -38,6 +38,26 @@ param( ) $ErrorActionPreference = 'Stop' +# --- Persistent launch log --------------------------------------------------- +# The launcher windows close automatically when done (GHOST.bat :StartClone) and +# the Desktop/Start-menu shortcuts run this script with -WindowStyle Hidden, so +# the console output is otherwise lost entirely. Append every run to +# tools\logs\launch_zcode_.log via a transcript. One file per instance +# keeps the five parallel launchers from interleaving. Everything here is +# best-effort: a logging failure must never block the launch. +try { + $logDir = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..\tools\logs')) + New-Item -ItemType Directory -Force -Path $logDir | Out-Null + $script:LaunchLogPath = Join-Path $logDir ("launch_zcode_{0}.log" -f $Instance) + Start-Transcript -Path $script:LaunchLogPath -Append -IncludeInvocationHeader | Out-Null + Write-Host "[log] transcript: $script:LaunchLogPath" +} catch { + Write-Host "[log] transcript disabled: $($_.Exception.Message)" -ForegroundColor Yellow +} +function Stop-LaunchLog { + try { Stop-Transcript | Out-Null } catch { } +} + # Portable paths: work for any Windows user, no hardcoded username. $UserProfile = $env:USERPROFILE if ([string]::IsNullOrWhiteSpace($UserProfile)) { $UserProfile = [Environment]::GetFolderPath('UserProfile') } @@ -210,6 +230,7 @@ if ($mainsNow.Count -ge $MaxConcurrent) { $guardAnswer = Read-Host '[ram-guard] Launch anyway? (y/N)' if ($guardAnswer -notmatch '^[Yy]') { Write-Host '[ram-guard] Launch cancelled - nothing was started.' + Stop-LaunchLog exit 0 } } else { @@ -217,6 +238,7 @@ if ($mainsNow.Count -ge $MaxConcurrent) { # invisible and hang the launch forever - ask via a dialog instead. if (-not (Show-GhostRamGuardDialog ($guardLines -join "`n"))) { Write-Host '[ram-guard] Launch cancelled - nothing was started.' + Stop-LaunchLog exit 0 } } @@ -782,3 +804,5 @@ if ($targetProc) { } else { Write-Host "[taskbar] no window found - identity left to the app's process-level AUMID." -ForegroundColor Yellow } + +Stop-LaunchLog