[PR #974] [CLOSED] Replaced unzip with PowerShell on Windows #9767

Closed
opened 2026-02-16 18:14:08 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/974
Author: @opencode-agent[bot]
Created: 7/14/2025
Status: Closed

Base: devHead: opencode/issue967-20250714_150029


📝 Commits (1)

  • f63baed Replaced unzip with PowerShell on Windows

📊 Changes

3 files changed (+80 additions, -22 deletions)

View changed files

📝 packages/opencode/src/file/fzf.ts (+34 -10)
📝 packages/opencode/src/file/ripgrep.ts (+34 -10)
📝 packages/opencode/src/lsp/server.ts (+12 -2)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/974 **Author:** [@opencode-agent[bot]](https://github.com/apps/opencode-agent) **Created:** 7/14/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `opencode/issue967-20250714_150029` --- ### 📝 Commits (1) - [`f63baed`](https://github.com/anomalyco/opencode/commit/f63baed573d9457d98c49ef228fe658b6fb0b3e5) Replaced unzip with PowerShell on Windows ### 📊 Changes **3 files changed** (+80 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/file/fzf.ts` (+34 -10) 📝 `packages/opencode/src/file/ripgrep.ts` (+34 -10) 📝 `packages/opencode/src/lsp/server.ts` (+12 -2) </details> ### 📄 Description ## 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](https://opencode.ai/s/FE4h72NX) | [view log](/sst/opencode/actions/runs/16270330285) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:08 -05:00
yindo closed this issue 2026-02-16 18:14:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9767