(context: vscode.ExtensionContext)
| 120 | // This method is called when your extension is activated. |
| 121 | // Your extension is activated the very first time the command is executed. |
| 122 | export async function activate(context: vscode.ExtensionContext) { |
| 123 | extensionContext = context |
| 124 | outputChannel = vscode.window.createOutputChannel(Package.outputChannel) |
| 125 | context.subscriptions.push(outputChannel) |
| 126 | outputChannel.appendLine(`${Package.name} extension activated - ${JSON.stringify(Package)}`) |
| 127 | |
| 128 | // Initialize network proxy configuration early, before any network requests. |
| 129 | // When proxyUrl is configured, all HTTP/HTTPS traffic will be routed through it. |
| 130 | // Only applied in debug mode (F5). |
| 131 | await initializeNetworkProxy(context, outputChannel) |
| 132 | |
| 133 | // Set extension path for custom tool registry to find bundled esbuild |
| 134 | customToolRegistry.setExtensionPath(context.extensionPath) |
| 135 | |
| 136 | // Migrate old settings to new |
| 137 | await migrateSettings(context, outputChannel) |
| 138 | |
| 139 | // Initialize telemetry service. |
| 140 | const telemetryService = TelemetryService.createInstance() |
| 141 | |
| 142 | try { |
| 143 | telemetryService.register(new PostHogTelemetryClient()) |
| 144 | } catch (error) { |
| 145 | console.warn("Failed to register PostHogTelemetryClient:", error) |
| 146 | } |
| 147 | |
| 148 | // Create logger for cloud services. |
| 149 | const cloudLogger = createDualLogger(createOutputChannelLogger(outputChannel)) |
| 150 | |
| 151 | // Initialize MDM service |
| 152 | const mdmService = await MdmService.createInstance(cloudLogger) |
| 153 | |
| 154 | // Initialize i18n for internationalization support. |
| 155 | initializeI18n(context.globalState.get("language") ?? formatLanguage(vscode.env.language)) |
| 156 | |
| 157 | // Initialize terminal shell execution handlers. |
| 158 | TerminalRegistry.initialize() |
| 159 | |
| 160 | // Initialize OpenAI Codex OAuth manager for ChatGPT subscription-based access. |
| 161 | openAiCodexOAuthManager.initialize(context, (message) => outputChannel.appendLine(message)) |
| 162 | |
| 163 | // Initialize Zoo Code auth service for extension session token management. |
| 164 | await initZooCodeAuth(context) |
| 165 | |
| 166 | // Get default commands from configuration. |
| 167 | const defaultCommands = vscode.workspace.getConfiguration(Package.name).get<string[]>("allowedCommands") || [] |
| 168 | |
| 169 | // Initialize global state if not already set. |
| 170 | if (!context.globalState.get("allowedCommands")) { |
| 171 | context.globalState.update("allowedCommands", defaultCommands) |
| 172 | } |
| 173 | |
| 174 | const contextProxy = await ContextProxy.getInstance(context) |
| 175 | |
| 176 | // Initialize code index managers for all workspace folders. |
| 177 | const codeIndexManagers: CodeIndexManager[] = [] |
| 178 | |
| 179 | if (vscode.workspace.workspaceFolders) { |
no test coverage detected