[PR #13648] feat: add PowerShell Core (pwsh) tool #14755

Open
opened 2026-02-16 18:19:31 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13648

State: open
Merged: No


Summary

Adds a dedicated pwsh tool alongside the existing bash tool. Works on any platform where PowerShell Core is installed. Uses tree-sitter-powershell for AST-based permission analysis and spawns pwsh -NoProfile -NonInteractive -Command.

What changed

  • pwsh tool (pwsh.ts): tree-sitter parsing, path resolution, permission/auto-approval logic

  • Windows security (pwsh-windows.ts): Windows-only hardening gated behind process.platform === "win32" — encoded command detection, execution policy bypass, download-and-execute cradles, registry critical-path blocking, provider-aware read/write checks, BLOCK > ASK > ALLOW decision model

  • Permission analysis (pwsh-arity.ts): PowerShell-specific arity table for cmdlets, aliases, and external tools

  • UI wiring: routes pwsh through existing bash rendering paths in TUI, web share view, and i18n labels across 15 locales

Verification

From packages/opencode:

  • bun test test/tool/pwsh.test.ts — 32 pass, 0 fail
  • bun test test/tool/pwsh-windows.test.ts — 82 pass, 0 fail
  • bun test test/permission/pwsh-arity.test.ts — 12 pass, 0 fail
  • bun run typecheck — clean

Fixes #8924
Fixes #6703
Refs #8136
Refs #4683
Refs #11288

If the linked issues aren't sufficient to justify this feature, happy to open a design discussion first, just let me know.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13648 **State:** open **Merged:** No --- ## Summary Adds a dedicated `pwsh` tool alongside the existing bash tool. Works on any platform where PowerShell Core is installed. Uses tree-sitter-powershell for AST-based permission analysis and spawns `pwsh -NoProfile -NonInteractive -Command`. ## What changed - **pwsh tool** (`pwsh.ts`): tree-sitter parsing, path resolution, permission/auto-approval logic - **Windows security** (`pwsh-windows.ts`): Windows-only hardening gated behind `process.platform === "win32"` — encoded command detection, execution policy bypass, download-and-execute cradles, registry critical-path blocking, provider-aware read/write checks, `BLOCK > ASK > ALLOW` decision model - **Permission analysis** (`pwsh-arity.ts`): PowerShell-specific arity table for cmdlets, aliases, and external tools - **UI wiring**: routes pwsh through existing bash rendering paths in TUI, web share view, and i18n labels across 15 locales ## Verification From `packages/opencode`: - `bun test test/tool/pwsh.test.ts` — 32 pass, 0 fail - `bun test test/tool/pwsh-windows.test.ts` — 82 pass, 0 fail - `bun test test/permission/pwsh-arity.test.ts` — 12 pass, 0 fail - `bun run typecheck` — clean Fixes #8924 Fixes #6703 Refs #8136 Refs #4683 Refs #11288 --- If the linked issues aren't sufficient to justify this feature, happy to open a design discussion first, just let me know.
yindo added the pull-request label 2026-02-16 18:19:31 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14755