VSCode Chat URI Extension
A VS Code extension that handles custom vscode:// URIs to start Copilot chat with a prompt.
Features
- Handles custom URI scheme:
vscode://xpl.chat-uri/startChat?prompt=...
- Opens the Copilot chat panel with the specified prompt
- Supports partial queries that wait for user input
Usage
vscode://xpl.chat-uri/startChat?prompt=YOUR_ENCODED_PROMPT
Parameters
| Parameter |
Description |
Required |
prompt |
URL-encoded prompt text to send to chat |
No (opens empty chat if omitted) |
partial |
Set to true to keep the prompt editable before sending |
No (default: false) |
mode |
Chat mode: agent, ask, or edit |
No (default: agent) |
newChat |
Set to false to continue in existing chat session |
No (default: true) |
Examples
Simple prompt (sends immediately):
vscode://xpl.chat-uri/startChat?prompt=Explain%20this%20code
Partial prompt (waits for user to edit/confirm):
vscode://xpl.chat-uri/startChat?prompt=Help%20me%20with&partial=true
Open empty chat:
vscode://xpl.chat-uri/startChat
Testing
- Press
F5 to launch the Extension Development Host
- Open a browser and navigate to one of the example URIs above
- VS Code should open and the chat panel should appear with your prompt
Alternatively, use the test command:
- Open Command Palette (
Cmd+Shift+P / Ctrl+Shift+P)
- Run "Chat URI Handler: Test" command
- Enter a prompt and it will open in chat
Development
Prerequisites
- Node.js 18.x or higher
- VS Code 1.85.0 or higher
Building
npm install
npm run compile
Watching for changes
npm run watch
How it Works
- The extension registers a
UriHandler that listens for URIs with the scheme vscode://xpl.chat-uri/...
- When a URI is received, it parses the path and query parameters
- If the path is
/startChat, it extracts the prompt parameter
- It then calls
workbench.action.chat.open with the prompt to open the Copilot chat
| |