Choose Directory
Windows directory picker for the OpenCode V2 home screen.
0
961
203 in 7 days
38.3
Multi-signal model
16 hours ago
2026-09-11
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-choose-directory@0.1.7"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-choose-directory@0.1.7"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D opencode-choose-directoryOpenCode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
Windows-only OpenCode V2 TUI plugin that adds a 选择目录 button to the home screen.
The button opens the native Windows Explorer-style folder picker. Selecting a directory keeps OpenCode on the home screen; OpenCode creates the session in that directory only after the first prompt is submitted.
Features
- Visible only on the OpenCode home screen
- Positioned at the far right of the home footer
- Native Windows
IFileDialogfolder picker - Pre-warmed picker process so the dialog opens without per-click startup delay
- Explorer-style address bar, search, navigation tree, and folder list
- Preserves the selected directory until the first prompt is submitted
- Does not create an empty session when a directory is selected
- No keyboard shortcut, command-palette entry, or slash command
- Handles spaces, Chinese characters, and other Unicode paths
Requirements
- Windows 10 or Windows 11
- OpenCode V2
- Windows PowerShell 5.1 (included with Windows)
Install
npm (recommended)
Install the latest version from npm and add it to the global OpenCode configuration:
opencode2 plugin add opencode-choose-directory
Restart opencode2 after installation.
To install a specific version:
opencode2 plugin add opencode-choose-directory@0.1.4
The package is available at npmjs.com/package/opencode-choose-directory.
Manual configuration
You can also add the npm package directly to ~/.config/opencode/cli.json:
{
"plugins": [
"opencode-choose-directory@latest"
]
}
Preserve any existing entries in plugins, then restart opencode2.
GitHub source installation
To run the plugin directly from source, clone the repository into your OpenCode configuration directory:
git clone https://github.com/huahai0202/opencode-choose-directory.git `
"$HOME\.config\opencode\plugins\opencode-choose-directory"
Set-Location "$HOME\.config\opencode\plugins\opencode-choose-directory"
npm install
Add the cloned TUI entrypoint to ~/.config/opencode/cli.json. Replace <USER> with your Windows user name:
{
"plugins": [
"file:///C:/Users/<USER>/.config/opencode/plugins/opencode-choose-directory/src/tui.tsx"
]
}
Update and uninstall
Install the newest npm release:
opencode2 plugin add opencode-choose-directory@latest
Remove the plugin from the global configuration:
opencode2 plugin remove opencode-choose-directory
How It Works
- The plugin appends a button to the outer
prompt.footerTUI slot so it stays at the far right. - The slot input supplies
sessionID; the button renders only when it is absent. - On startup the plugin launches one hidden Windows PowerShell worker in STA mode and pre-compiles the native picker helper. Failures stay silent and fall back to a one-shot process on click.
- Clicking the button sends the current directory to the warm worker, which shows the native
IFileDialogCOM picker withFOS_PICKFOLDERS. - The selected path is returned as UTF-8 Base64 between fixed markers.
- The plugin resolves the path through OpenCode and preloads the location-scoped agent/model catalogs.
- The plugin restores focus to the home prompt after the native dialog closes.
- OpenCode creates a session in that location when the first prompt is submitted.
Development
npm install
npm run typecheck
The main implementation is in src/tui.tsx. src/index.ts is the package entrypoint and declares that the package has a TUI plugin.
Limitations
- Windows only. The plugin does not register a button on other platforms.
- The native folder picker resembles File Explorer but does not include the full Explorer tab bar or file-operation toolbar.
- The OpenCode V2 plugin API is beta and may require compatibility updates.
License
MIT
Similar plugins
Session Recap
@kitlangton/opencode-session-recap
Transient session recaps for the OpenCode V2 TUI
Aside
opencode-aside
Claude Code's /btw side chat for opencode - ask a one-shot question in an overlay, with no tools and nothing added to the transcript
Session Elapsed
opencode-session-elapsed
OpenCode TUI plugin that shows session elapsed, cumulative work, and response timers in the prompt line.