| 110 | } |
| 111 | |
| 112 | export function activate(context: vscode.ExtensionContext) { |
| 113 | let ws = initWs(context); |
| 114 | ws.onerror = (e) => { |
| 115 | initWs(context); |
| 116 | }; |
| 117 | |
| 118 | const aiTerminal = vscode.window.createTerminal({ |
| 119 | name: "AI Terminal", |
| 120 | hideFromUser: false |
| 121 | }); |
| 122 | |
| 123 | // Store the terminal for future reference |
| 124 | context.globalState.update('aiTerminalId', aiTerminal.processId); |
| 125 | |
| 126 | // Show the terminal |
| 127 | aiTerminal.show(); |
| 128 | |
| 129 | // Pin the terminal (this requires the terminal tabs feature) |
| 130 | vscode.commands.executeCommand('workbench.action.terminal.focus'); |
| 131 | |
| 132 | // Register a command to send text to the AI terminal |
| 133 | let sendToAiTerminal = vscode.commands.registerCommand('extension.sendToAiTerminal', async (text) => { |
| 134 | const terminalId = context.globalState.get('aiTerminalId'); |
| 135 | const terminals = vscode.window.terminals; |
| 136 | const aiTerm = terminals.find(t => t.processId === terminalId); |
| 137 | |
| 138 | if (aiTerm) { |
| 139 | aiTerm.sendText(text); |
| 140 | } else { |
| 141 | vscode.window.showErrorMessage('AI Terminal not found. It may have been closed.'); |
| 142 | |
| 143 | const aiTerminal = vscode.window.createTerminal({ |
| 144 | name: "AI Terminal", |
| 145 | hideFromUser: false |
| 146 | }); |
| 147 | context.globalState.update('aiTerminalId', aiTerminal.processId); |
| 148 | aiTerminal.show(); |
| 149 | aiTerminal.sendText(text); |
| 150 | } |
| 151 | }); |
| 152 | |
| 153 | context.subscriptions.push(sendToAiTerminal); |
| 154 | |
| 155 | const disposable = vscode.commands.registerCommand('bolty-listener.helloWorld', () => { |
| 156 | vscode.window.showInformationMessage('Hello World from bolty-listener!'); |
| 157 | vscode.commands.executeCommand("workbench.action.terminal.new"); |
| 158 | vscode.commands.executeCommand("workbench.action.terminal.sendSequence", {text: "npm run build"}); |
| 159 | vscode.commands.executeCommand("workbench.action.terminal.sendSequence", {text: "\r"}); |
| 160 | }); |
| 161 | |
| 162 | context.subscriptions.push(disposable); |
| 163 | } |
| 164 | |
| 165 | export function deactivate() {} |