<# .SYNOPSIS Prüft hugin-install.ps1 unter Windows PowerShell 5.1 gegen einen laufenden Hugin. .DESCRIPTION Gegenstück zu scripts/integration-test.sh für Windows. Braucht einen Hugin mit den Beispielpaketen, z. B. scripts/demo.sh auf einem anderen Rechner: HOST=0.0.0.0 scripts/demo.sh # auf dem Mac/Linux-Rechner Dann unter Windows (PowerShell 5.1, nicht pwsh): powershell -ExecutionPolicy Bypass -File integration-test.ps1 ` -Server http://:8080 -Key Ändert nichts außerhalb eines Temp-Ordners. Rückgabewert 0, wenn alles passt. #> param( [Parameter(Mandatory = $true)][string]$Server, [Parameter(Mandatory = $true)][string]$Key, # Nur zum Vorabtest auf anderen Systemen, z. B. -PowerShell pwsh; unter Windows weglassen [string]$PowerShell = 'powershell.exe' ) Set-StrictMode -Version 2 $ErrorActionPreference = 'Stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $Utf8 = New-Object System.Text.UTF8Encoding($false) $failures = 0 function Check([string]$Name, [bool]$Ok, [string]$Info = '') { if ($Ok) { Write-Host "OK $Name" } else { Write-Host "FEHLER $Name $Info" -ForegroundColor Red; $script:failures++ } } Write-Host "PowerShell $($PSVersionTable.PSVersion) ($($PSVersionTable.PSEdition))" if ($PSVersionTable.PSVersion.Major -ne 5) { Write-Warning 'Dieser Test ist für Windows PowerShell 5.1 gedacht.' } $work = Join-Path ([IO.Path]::GetTempPath()) ("hugin-test-" + [Guid]::NewGuid().ToString('N').Substring(0, 8)) $repo = Join-Path $work 'repo' New-Item -ItemType Directory -Path $repo -Force | Out-Null try { # Skript vom Server laden, wie eine Softwareverteilung es tun würde $script = Join-Path $work 'hugin-install.ps1' Invoke-WebRequest -UseBasicParsing -Uri ($Server.TrimEnd('/') + '/api/v1/delivery/client.ps1') ` -Headers @{ Authorization = "Bearer $Key" } -OutFile $script $raw = [IO.File]::ReadAllBytes($script) Check 'client.ps1 mit BOM (für PowerShell 5.1)' ($raw[0] -eq 0xEF -and $raw[1] -eq 0xBB -and $raw[2] -eq 0xBF) [IO.File]::WriteAllText((Join-Path $repo 'CLAUDE.md'), "# Werk`r`n`r`nUnser Projekt.`r`n", $Utf8) [IO.File]::WriteAllText((Join-Path $repo 'opencode.json'), "{`n `"model`": `"anthropic/claude-sonnet-5-5`"`n}`n", $Utf8) function Run([string[]]$More) { $output = & $PowerShell -NoProfile -ExecutionPolicy Bypass -File $script -Server $Server -Key $Key ` -Repo $repo -Tools 'claude=2.1.302,opencode=1.19.3' -Client 'windows-test' @More 2>&1 | Out-String return @{ Text = $output; Rc = $LASTEXITCODE } } $first = Run @('-Packages', 'pub-munin-nutzen,pub-hausregeln,pub-code-review') Check 'Erstinstallation' ($first.Rc -eq 0) $first.Text foreach ($rel in '.claude\skills\pub-munin-nutzen\SKILL.md', '.claude\agents\pub-code-review.md', '.opencode\agents\pub-code-review.md', '.hugin\rules\pub-hausregeln.md', '.mcp.json', 'hugin.lock.json') { Check "Datei $rel" (Test-Path -LiteralPath (Join-Path $repo $rel)) } $skill = [IO.File]::ReadAllBytes((Join-Path $repo '.claude\skills\pub-munin-nutzen\SKILL.md')) Check 'SKILL.md ohne BOM' (-not ($skill[0] -eq 0xEF -and $skill[1] -eq 0xBB)) Check 'SKILL.md mit LF, ohne CRLF' (-not $Utf8.GetString($skill).Contains("`r`n")) $claude = [IO.File]::ReadAllText((Join-Path $repo 'CLAUDE.md'), $Utf8) Check 'CLAUDE.md behält Inhalt und CRLF' ($claude.StartsWith("# Werk`r`n`r`nUnser Projekt.`r`n`r`n