OpenCode Wrapper Extension
November 5, 2025 ยท View on GitHub
A VSCode extension that runs NuShell scripts interactively with a native-looking terminal interface beside your editor.
Features
- ๐ฅ๏ธ Real Terminal Experience - Full PTY (pseudoterminal) with interactive shell
- โจ๏ธ Direct Keyboard Input - Type directly into the terminal, just like a real terminal
- ๐จ VSCode Theme Integration - Matches your VSCode theme colors
- ๐ Runs in Background - No visible terminal window, process runs silently
- โก Real-time I/O - Live output streaming with full terminal capabilities
- ๐ง Full Terminal Features - Supports Ctrl+C, arrow keys, backspace, and more
Usage
Running Interactive NuShell Script
- Open Command Palette (
Cmd+Shift+PorCtrl+Shift+P) - Type "OpenCode: Run in Current Directory"
- Select a script:
- If only one
.nufile exists, it runs automatically - If multiple
.nufiles exist, choose from the list - If no
.nufiles found, browse for a file
- If only one
- Interactive terminal panel opens beside your editor
- Script runs and shows output in real-time
- Type directly into the terminal - it works just like a real terminal:
- Type your responses and press Enter
- Use Backspace, arrow keys, Ctrl+C, etc.
- All keyboard input is sent directly to the shell
- Continue interacting with the script naturally
Note: Extension does NOT auto-start. You must manually trigger it via command palette.
Development
Prerequisites
- Node.js (v20+)
- npm
- VSCode
- OpenCode CLI tool
Setup
-
Install dependencies:
npm install -
Compile TypeScript:
npm run compile -
Press
F5to run the extension in debug mode
Build
npm run compile
Watch Mode
npm run watch
Extension Structure
.
โโโ src/
โ โโโ extension.ts # Main extension logic (runs opencode)
โโโ resources/
โ โโโ icon.svg # Extension icon
โโโ .vscode/
โ โโโ launch.json # Debug configuration
โ โโโ tasks.json # Build tasks
โโโ package.json # Extension manifest
โโโ tsconfig.json # TypeScript configuration
Commands
nullshell.runScript- Manually run OpenCode in current directory
Requirements
- NuShell must be installed on your system
- The
nucommand must be available in your PATH - Install from: https://www.nushell.sh/
Configuration
The extension works out of the box:
- Create any
.nuscript in your workspace - Open the workspace in VSCode
- Trigger via Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) - Type "OpenCode: Run in Current Directory"
- Select your script (or it auto-runs if only one exists)
- Interactive terminal panel opens beside your editor
How It Works
- User triggers command via Command Palette
- Extension searches for
.nufiles in workspace:- One file: Runs automatically
- Multiple files: Shows quick pick menu
- No files: Opens file browser
- Extension creates webview panel with real terminal interface (opens beside editor)
- Spawns
nu <script>process using node-pty (PTY/pseudoterminal) - Working directory is set to the script's folder
- PTY provides full terminal capabilities (TTY emulation)
- Captures all terminal output in real-time and displays it
- Interactive Mode:
- User types directly into the terminal (no separate input field)
- Each keystroke is sent to the PTY
- Supports special keys (Enter, Backspace, Ctrl+C, arrow keys, etc.)
- Process receives input exactly like a real terminal
- Session stays alive until script completes or panel is closed
Future Enhancements
- Configurable command via settings
- Custom arguments support
- Multiple workspace support
- Command history
Contributing
Feel free to open issues and pull requests!
License
MIT