| 1 | import { getContinueRcPath, getTsConfigPath } from "core/util/paths"; |
| 2 | import { Telemetry } from "core/util/posthog"; |
| 3 | import * as vscode from "vscode"; |
| 4 | |
| 5 | import * as path from "path"; |
| 6 | import { VsCodeExtension } from "../extension/VsCodeExtension"; |
| 7 | import registerQuickFixProvider from "../lang-server/codeActions"; |
| 8 | import { getExtensionVersion } from "../util/util"; |
| 9 | |
| 10 | import { VsCodeContinueApi } from "./api"; |
| 11 | import setupInlineTips from "./InlineTipManager"; |
| 12 | |
| 13 | export async function activateExtension(context: vscode.ExtensionContext) { |
| 14 | // Add necessary files |
| 15 | getTsConfigPath(); |
| 16 | getContinueRcPath(); |
| 17 | |
| 18 | // Register commands and providers |
| 19 | registerQuickFixProvider(); |
| 20 | setupInlineTips(context); |
| 21 | |
| 22 | const vscodeExtension = new VsCodeExtension(context); |
| 23 | |
| 24 | // Load Continue configuration |
| 25 | if (!context.globalState.get("hasBeenInstalled")) { |
| 26 | context.globalState.update("hasBeenInstalled", true); |
| 27 | Telemetry.capture( |
| 28 | "install", |
| 29 | { |
| 30 | extensionVersion: getExtensionVersion(), |
| 31 | }, |
| 32 | true, |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | // Only set the YAML schema configuration if it hasn't been set before |
| 37 | if (!context.globalState.get("yamlSchemaConfigured")) { |
| 38 | vscode.workspace.getConfiguration("yaml").update( |
| 39 | "schemas", |
| 40 | { |
| 41 | [path.join( |
| 42 | context.extension.extensionUri.fsPath, |
| 43 | "config-yaml-schema.json", |
| 44 | )]: [".continue/**/*.yaml"], |
| 45 | }, |
| 46 | vscode.ConfigurationTarget.Global, |
| 47 | ); |
| 48 | // Mark that we've configured the YAML schema |
| 49 | context.globalState.update("yamlSchemaConfigured", true); |
| 50 | } |
| 51 | |
| 52 | const api = new VsCodeContinueApi(vscodeExtension); |
| 53 | const continuePublicApi = { |
| 54 | registerCustomContextProvider: api.registerCustomContextProvider.bind(api), |
| 55 | }; |
| 56 | |
| 57 | // 'export' public api-surface |
| 58 | // or entire extension for testing |
| 59 | return process.env.NODE_ENV === "test" |
| 60 | ? { |
| 61 | ...continuePublicApi, |
| 62 | extension: vscodeExtension, |
| 63 | } |
| 64 | : continuePublicApi; |
| 65 | } |