@@ -930,6 +930,41 @@ function Test-OcsWorks {
930930 return $true
931931}
932932
933+ function Test-OcsPowerShellPolicyBlocked {
934+ param ([ref ]$Diagnostic )
935+
936+ $Diagnostic.Value = " "
937+
938+ if ($env: OS -ne " Windows_NT" ) {
939+ return $false
940+ }
941+
942+ $ps1Path = Join-Path $env: USERPROFILE " .bun\bin\ocs.ps1"
943+ if (-not (Test-Path $ps1Path )) {
944+ return $false
945+ }
946+
947+ $escapedPath = $ps1Path.Replace (" '" , " ''" )
948+
949+ try {
950+ $probeOutput = (& powershell - NoProfile - Command " & '$escapedPath ' --help" 2>&1 | Out-String ).Trim()
951+ $probeExit = $LASTEXITCODE
952+
953+ if ($probeExit -ne 0 -and $probeOutput -match " running scripts is disabled|PSSecurityException|cannot be loaded because running scripts is disabled" ) {
954+ $Diagnostic.Value = $probeOutput
955+ return $true
956+ }
957+ } catch {
958+ $message = $_.Exception.Message
959+ if ($message -match " running scripts is disabled|PSSecurityException|cannot be loaded because running scripts is disabled" ) {
960+ $Diagnostic.Value = $message
961+ return $true
962+ }
963+ }
964+
965+ return $false
966+ }
967+
933968function Test-OpencodeWorks {
934969 param ([int ]$TimeoutSeconds = 8 )
935970
@@ -1892,6 +1927,27 @@ if (-not (Ensure-OcsCommand -PluginPath $PLUGIN_DIR -BasePath $rootDir -IsLocalS
18921927 Write-Warning " Manual fallback: clone private suite repo, then run bun install -g <repo-path>."
18931928 Write-Warning " If needed, add to PATH: $bunBin (and open a new terminal)"
18941929}
1930+ $policyProbe = " "
1931+ if (Test-OcsPowerShellPolicyBlocked - Diagnostic ([ref ]$policyProbe )) {
1932+ Write-Warning " PowerShell execution policy is blocking ocs.ps1 in regular shells."
1933+ Write-Output " "
1934+ Write-Output " QUICK FIX (no policy change):"
1935+ Write-Output " - Use cmd shim commands:"
1936+ Write-Output " ocs.cmd setup:profile"
1937+ Write-Output " ocs.cmd prefs"
1938+ Write-Output " "
1939+ Write-Output " Optional persistent fix (CurrentUser):"
1940+ Write-Output " Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force"
1941+ Write-Output " "
1942+ Write-Output " Session-only alternative:"
1943+ Write-Output " powershell -NoProfile -ExecutionPolicy Bypass -Command \" ocs setup:profile\" "
1944+ Write-Output " "
1945+ if ($policyProbe ) {
1946+ Write-Output " Detected error snippet:"
1947+ Write-Output " $policyProbe "
1948+ Write-Output " "
1949+ }
1950+ }
18951951Write-Output " "
18961952Ensure- OpencodePathEntries
18971953Write-Output " Checking opencode command..."
@@ -1913,15 +1969,19 @@ if (Test-OpencodeWorks) {
19131969Write-Output " "
19141970Write-Output " Next steps:"
19151971Write-Output " 1. Configure profile globally: ocs setup:profile"
1916- Write-Output " 2. Setup Exa MCP via ocs command:"
1917- Write-Output " - Create Exa account: https://dashboard.exa.ai"
1918- Write-Output " - Create API key: https://dashboard.exa.ai/api-keys"
1919- Write-Output " - Run: ocs exa setup --api-key <YOUR_EXA_API_KEY>"
1920- Write-Output " - Verify: ocs exa check"
1921- Write-Output " 3. Add account via: opencode auth login"
1922- Write-Output " 4. Running Opencode via web UI:"
1972+ Write-Output " If Windows PowerShell blocks ocs.ps1, use fallback: ocs.cmd setup:profile"
1973+ Write-Output " 2. Optional PowerShell policy fix (CurrentUser):"
1974+ Write-Output " Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force"
1975+ Write-Output " Session-only alternative: powershell -NoProfile -ExecutionPolicy Bypass -Command \" ocs setup:profile\" "
1976+ Write-Output " 3. Setup Exa MCP: ocs exa setup --api-key <YOUR_EXA_API_KEY>"
1977+ Write-Output " If blocked, use fallback: ocs.cmd exa setup --api-key <YOUR_EXA_API_KEY>"
1978+ Write-Output " 4. Verify Exa MCP: ocs exa check"
1979+ Write-Output " If blocked, use fallback: ocs.cmd exa check"
1980+ Write-Output " 5. Configure preferences: ocs prefs (optional, advanced users)"
1981+ Write-Output " If still blocked, use fallback: ocs.cmd prefs"
1982+ Write-Output " 6. Add account via: opencode auth login"
1983+ Write-Output " 7. Running Opencode via web UI:"
19231984Write-Output " opencode web --port 8089"
1924- Write-Output " 5. (Optional advanced) Configure preferences: ocs prefs"
19251985Write-Output " "
19261986
19271987if (Test-Path $TMP_DIR ) {
0 commit comments