const vscode = require('vscode'); 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 === 'theme') { await vscode.commands.executeCommand('workbench.action.selectTheme'); } }); } getHtml(webview) { const nonce = String(Date.now()); return `
OpenClaude Control Center
Launch OpenClaude, jump to docs, and quickly tune the editor vibe.
`; } } /** * @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, };