From 77dab28c9a9bd995c37801ea126ada8f67b99999 Mon Sep 17 00:00:00 2001 From: Julian lechner Date: Wed, 16 Sep 2026 15:06:55 +0200 Subject: [PATCH] fix(doctor): implement buffered PASS output in summary mode Implement proper buffering for PASS lines in summary mode: - PASS lines are buffered when -Summary/--summary is active - WARN and FAIL lines print immediately (never buffered) - On success: buffer is discarded, print tally line only - On failure: buffer is flushed before tally line Revert out-of-scope try/catch around Python command (not part of Task 4). Co-Authored-By: Claude Haiku 4.5 --- scripts/doctor.ps1 | 15 ++++++++++++--- scripts/doctor.sh | 13 +++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/scripts/doctor.ps1 b/scripts/doctor.ps1 index 2606aee..50efa3e 100644 --- a/scripts/doctor.ps1 +++ b/scripts/doctor.ps1 @@ -6,10 +6,15 @@ $root = Split-Path $PSScriptRoot -Parent $homePath = [Environment]::GetFolderPath('UserProfile') $script:fail = $false $script:checkCount = 0 +$script:passBuffer = @() function Result($state, $message) { $script:checkCount++ if ($state -eq 'FAIL') { $script:fail = $true } - if (-not $Summary -or $script:fail -or $state -ne 'PASS') { Write-Output ("$state $message") } + if ($Summary -and $state -eq 'PASS') { + $script:passBuffer += "$state $message" + } else { + Write-Output ("$state $message") + } } foreach ($tool in @('codex','claude')) { if (Get-Command $tool -ErrorAction SilentlyContinue) { $version = & $tool --version 2>&1 | Select-Object -First 1; Result 'PASS' "$tool available ($version)" } else { Result 'WARN' "$tool unavailable" } } @@ -47,7 +52,7 @@ if (Test-Path -LiteralPath $settingsPath) { } $configTomlPath = Join-Path $homePath '.codex/config.toml' if (Test-Path -LiteralPath $configTomlPath) { - try { $parseResult = & python -c 'import sys,tomllib,pathlib; tomllib.loads(pathlib.Path(sys.argv[1]).read_text(encoding="utf-8-sig"))' $configTomlPath 2>&1 } catch { $parseResult = $_ } + $parseResult = & python -c 'import sys,tomllib,pathlib; tomllib.loads(pathlib.Path(sys.argv[1]).read_text(encoding="utf-8-sig"))' $configTomlPath 2>&1 if ($LASTEXITCODE -eq 0) { Result 'PASS' 'installed .codex/config.toml parses as TOML' } else { Result 'FAIL' "installed .codex/config.toml is invalid TOML: $parseResult" } if (Get-Command codex -ErrorAction SilentlyContinue) { $previousCodexHome = $env:CODEX_HOME @@ -83,7 +88,11 @@ foreach ($client in @('codex','claude')) { } if ($Summary) { - if ($script:fail) { Write-Output "Doctor: FAIL | $script:checkCount checks"; exit 1 } + if ($script:fail) { + $script:passBuffer | ForEach-Object { Write-Output $_ } + Write-Output "Doctor: FAIL | $script:checkCount checks" + exit 1 + } Write-Output "Doctor: PASS | $script:checkCount checks" } else { if ($script:fail) { exit 1 } diff --git a/scripts/doctor.sh b/scripts/doctor.sh index d4cb84f..b4d6f46 100755 --- a/scripts/doctor.sh +++ b/scripts/doctor.sh @@ -14,11 +14,16 @@ root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd) home_path=${HOME:?HOME is required} failed=false check_count=0 +pass_buffer=() result() { check_count=$((check_count + 1)) [ "$1" != FAIL ] || failed=true - if [ "$summary" = false ] || [ "$failed" = true ] || [ "$1" != PASS ]; then printf '%s %s\n' "$1" "$2"; fi + if [ "$summary" = true ] && [ "$1" = PASS ]; then + pass_buffer+=("$1 $2") + else + printf '%s %s\n' "$1" "$2" + fi } for tool in codex claude; do @@ -96,7 +101,11 @@ for path in shared/rules shared/skills shared/agents shared/hooks/scripts; do done if [ "$summary" = true ]; then - if [ "$failed" = true ]; then printf 'Doctor: FAIL | %s checks\n' "$check_count"; exit 1; fi + if [ "$failed" = true ]; then + for line in "${pass_buffer[@]}"; do printf '%s\n' "$line"; done + printf 'Doctor: FAIL | %s checks\n' "$check_count" + exit 1 + fi printf 'Doctor: PASS | %s checks\n' "$check_count" else [ "$failed" = false ] || exit 1