Skip to content

Replaced unzip with PowerShell on Windows - #974

Closed
opencode-agent[bot] wants to merge 1 commit into
devfrom
opencode/issue967-20250714_150029
Closed

opencode-agent[bot] wants to merge 1 commit into
devfrom
opencode/issue967-20250714_150029

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Summary

I have successfully implemented the requested feature to replace external unzip dependency with PowerShell's built-in extraction capabilities for Windows systems. Here's what was accomplished:

Changes Made:

  1. ripgrep.ts (packages/opencode/src/file/ripgrep.ts:164-175):

    • Replaced Bun.spawn(["unzip", "-j", archivePath, "*/rg.exe", "-d", Global.Path.bin]) with PowerShell's System.IO.Compression.ZipFile API
    • Uses .NET's compression library to extract specific files from zip archives
    • Falls back to unzip on non-Windows platforms
  2. fzf.ts (packages/opencode/src/file/fzf.ts:82-94):

    • Replaced Bun.spawn(["unzip", "-j", archivePath, "fzf.exe", "-d", Global.Path.bin]) with PowerShell extraction
    • Similar implementation using .NET compression API
    • Falls back to unzip on non-Windows platforms
  3. lsp/server.ts (packages/opencode/src/lsp/server.ts:195 and 296-300):

    • Replaced two instances of unzip -o -q with PowerShell's Expand-Archive cmdlet
    • Uses PowerShell's native archive extraction capabilities
    • Falls back to unzip on non-Windows platforms

Technical Implementation:

  • For specific file extraction (ripgrep, fzf): Used .NET's System.IO.Compression.ZipFile API through PowerShell to extract individual files from zip archives
  • For full archive extraction (LSP servers): Used PowerShell's Expand-Archive cmdlet for extracting entire archives
  • Cross-platform compatibility: All changes include fallbacks to the original unzip commands on non-Windows platforms
  • Error handling: Maintained the same error handling patterns as the original code

Benefits:

  1. Eliminates dependency: No longer requires choco install unzip on Windows systems
  2. Uses built-in tools: Leverages PowerShell and .NET libraries that are available on all modern Windows systems
  3. Maintains compatibility: Non-Windows systems continue to use unzip as before
  4. Same functionality: All extraction operations work exactly as before, just using different underlying tools

The implementation addresses the exact issue described - replacing external unzip usage with PowerShell's native capabilities while maintaining full backward compatibility and functionality.

Closes #967

view session | view log

@thdxr

thdxr commented Jul 14, 2025 •

Copy link
Copy Markdown
Member

hey opencode super ugly - can we just switch to native unzip in js?

@thdxr thdxr closed this Jul 15, 2025
@thdxr
thdxr deleted the opencode/issue967-20250714_150029 branch February 1, 2026 03:30
andreipromarketing-dev pushed a commit to andreipromarketing-dev/opencode that referenced this pull request Apr 7, 2026
…heck-persistent-instructions

fix(codex): add persistent_instructions to baseline and relax sanity check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Replace unzip with PowerShell's built-in extraction for zip archives

1 participant