diff --git a/scripts/tests/test-shell-packages.ps1 b/scripts/tests/test-shell-packages.ps1 index f700e52..042dfcb 100644 --- a/scripts/tests/test-shell-packages.ps1 +++ b/scripts/tests/test-shell-packages.ps1 @@ -2,6 +2,11 @@ param([switch]$Summary) $ErrorActionPreference = 'Stop' $root = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent +$sandboxSupported = [Environment]::OSVersion.Platform -eq [PlatformID]::Unix +if ($sandboxSupported) { + $kernel = (& uname -r 2>$null | Out-String).Trim() + if ($kernel -match '(?i)microsoft') { $sandboxSupported = $kernel -match '(?i)microsoft-standard-WSL2' } +} $sourceAgentCount = @(Get-ChildItem (Join-Path $root 'shared/agents') -Directory).Count $sourceSkillCount = @(Get-ChildItem (Join-Path $root 'shared/skills') -Filter 'SKILL.md' -Recurse).Count $rulesRoot = Join-Path $root 'shared/rules' @@ -56,10 +61,10 @@ foreach ($shell in @('powershell','bash')) { throw "Claude finish hook is incorrect in $package" } elseif ($content -notmatch '"defaultMode"\s*:\s*"auto"') { throw "Claude auto permission mode is missing in $package" - } elseif ($shell -eq 'powershell' -and ($settings.sandbox.enabled -ne $false -or $settings.sandbox.PSObject.Properties.Count -ne 1)) { - throw "Claude sandbox must be disabled in $package" - } elseif ($shell -eq 'bash' -and (-not $settings.sandbox.enabled -or $settings.sandbox.allowUnsandboxedCommands -ne $false -or $settings.sandbox.failIfUnavailable -ne $true)) { + } elseif ($sandboxSupported -and ($settings.sandbox.enabled -ne $true -or $settings.sandbox.allowUnsandboxedCommands -ne $false -or $settings.sandbox.failIfUnavailable -ne $true -or $settings.sandbox.PSObject.Properties.Count -ne 3)) { throw "Claude strict sandbox is missing in $package" + } elseif (-not $sandboxSupported -and ($settings.sandbox.enabled -ne $false -or $settings.sandbox.PSObject.Properties.Count -ne 1)) { + throw "Claude sandbox must be disabled in $package" } elseif (-not (Test-Path -LiteralPath (Join-Path $package "statusline/statusline.$(if ($shell -eq 'powershell') { 'ps1' } else { 'sh' })")) -or $settings.statusLine.command -notmatch "statusline\.$(if ($shell -eq 'powershell') { 'ps1' } else { 'sh' })") { throw "Claude status line is incorrect in $package" } diff --git a/scripts/tests/test-shell-packages.sh b/scripts/tests/test-shell-packages.sh index c1037ce..df04dde 100644 --- a/scripts/tests/test-shell-packages.sh +++ b/scripts/tests/test-shell-packages.sh @@ -8,6 +8,17 @@ while [ $# -gt 0 ]; do esac done root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd) +sandbox_supported=false +case "$(uname -s 2>/dev/null || true)" in + Darwin) sandbox_supported=true ;; + Linux) + kernel=$(uname -r 2>/dev/null || true) + case "$kernel" in + *microsoft*) [[ "$kernel" == *microsoft-standard-WSL2* ]] && sandbox_supported=true ;; + *) sandbox_supported=true ;; + esac + ;; +esac source_agent_count=$(find "$root/shared/agents" -mindepth 1 -maxdepth 1 -type d | wc -l) source_skill_count=$(find "$root/shared/skills" -name SKILL.md | wc -l) mapfile -t rule_paths < <(find "$root/shared/rules" -mindepth 1 -type f -name '*.md' ! -name general.md -printf '%P\n' | sort) @@ -62,7 +73,7 @@ for shell in powershell bash; do ! grep -q 'flashbang-if-input' "$package/$file" ! grep -q '"async"[[:space:]]*:[[:space:]]*true' "$package/$file" grep -q '"defaultMode"[[:space:]]*:[[:space:]]*"auto"' "$package/$file" - python3 -c 'import json,sys; settings=json.load(open(sys.argv[1], encoding="utf-8-sig")); expected={"enabled": False} if sys.argv[2] == "powershell" else {"enabled": True, "allowUnsandboxedCommands": False, "failIfUnavailable": True}; assert settings["sandbox"] == expected' "$package/$file" "$shell" + python3 -c 'import json,sys; settings=json.load(open(sys.argv[1], encoding="utf-8-sig")); expected={"enabled": True, "allowUnsandboxedCommands": False, "failIfUnavailable": True} if sys.argv[2] == "true" else {"enabled": False}; assert settings["sandbox"] == expected' "$package/$file" "$sandbox_supported" statusline_extension='sh' [ "$shell" != powershell ] || statusline_extension=ps1 test -f "$package/statusline/statusline.$statusline_extension"