const vscode = require('vscode'); const crypto = require('crypto'); function launchOpenClaude() { const configured = vscode.workspace.getConfiguration('openclaude'); const launchCommand = configured.get('launchCommand', 'openclaude'); const terminalName = configured.get('terminalName', 'OpenClaude'); const terminal = vscode.window.createTerminal({ name: terminalName, env: { CLAUDE_CODE_USE_OPENAI: configured.get('useOpenAIShim', true) ? '1' : undefined, }, }); terminal.show(true); terminal.sendText(launchCommand, true); } class OpenClaudeControlCenterProvider { resolveWebviewView(webviewView) { webviewView.webview.options = { enableScripts: true }; webviewView.webview.html = this.getHtml(webviewView.webview); webviewView.webview.onDidReceiveMessage(async (message) => { if (message?.type === 'launch') { launchOpenClaude(); return; } if (message?.type === 'docs') { await vscode.env.openExternal(vscode.Uri.parse('https://github.com/devNull-bootloader/openclaude')); return; } if (message?.type === 'commands') { await vscode.commands.executeCommand('workbench.action.showCommands'); } }); } getHtml(webview) { const nonce = crypto.randomBytes(16).toString('base64'); return `
openclaude control center online
READY FOR INPUT
Terminal-oriented workflow with direct command access.
$ openclaude --status
runtime: active
shim: CLAUDE_CODE_USE_OPENAI=1
$ awaiting command
Quick trigger: use Ctrl+Shift+P and run OpenClaude commands from anywhere.
`; } } /** * @param {vscode.ExtensionContext} context */ function activate(context) { const startCommand = vscode.commands.registerCommand('openclaude.start', async () => { launchOpenClaude(); }); const openDocsCommand = vscode.commands.registerCommand('openclaude.openDocs', async () => { await vscode.env.openExternal(vscode.Uri.parse('https://github.com/devNull-bootloader/openclaude')); }); const openUiCommand = vscode.commands.registerCommand('openclaude.openControlCenter', async () => { await vscode.commands.executeCommand('workbench.view.extension.openclaude'); }); const provider = new OpenClaudeControlCenterProvider(); const providerDisposable = vscode.window.registerWebviewViewProvider('openclaude.controlCenter', provider); context.subscriptions.push(startCommand, openDocsCommand, openUiCommand, providerDisposable); } function deactivate() {} module.exports = { activate, deactivate, };