Elffuss BraidHub

kikocis/continue public

eca53d6fa452 · 2.9 KiBRawPermalink
1import { getContinueRcPath, getTsConfigPath } from "core/util/paths";
2import { Telemetry } from "core/util/posthog";
3import * as vscode from "vscode";
4
5import { VsCodeExtension } from "../extension/VsCodeExtension";
6import registerQuickFixProvider from "../lang-server/codeActions";
7import { getExtensionVersion, isUnsupportedPlatform } from "../util/util";
8
9import { GlobalContext } from "core/util/GlobalContext";
10import { VsCodeContinueApi } from "./api";
11import setupInlineTips from "./InlineTipManager";
12
13export async function activateExtension(context: vscode.ExtensionContext) {
14 const platformCheck = isUnsupportedPlatform();
15 const globalContext = new GlobalContext();
16 const hasShownUnsupportedPlatformWarning = globalContext.get(
17 "hasShownUnsupportedPlatformWarning",
18 );
19
20 if (platformCheck.isUnsupported && !hasShownUnsupportedPlatformWarning) {
21 const platformTarget = "windows-arm64";
22
23 globalContext.update("hasShownUnsupportedPlatformWarning", true);
24 void vscode.window.showInformationMessage(
25 `Continue detected that you are using ${platformTarget}. Due to native dependencies, Continue may not be able to start`,
26 );
27
28 void Telemetry.capture(
29 "unsupported_platform_activation_attempt",
30 {
31 platform: platformTarget,
32 extensionVersion: getExtensionVersion(),
33 reason: platformCheck.reason,
34 },
35 true,
36 );
37 }
38
39 // Add necessary files
40 getTsConfigPath();
41 getContinueRcPath();
42
43 // Register commands and providers
44 registerQuickFixProvider();
45 setupInlineTips(context);
46
47 const vscodeExtension = new VsCodeExtension(context);
48
49 // Load Continue configuration
50 if (!context.globalState.get("hasBeenInstalled")) {
51 void context.globalState.update("hasBeenInstalled", true);
52 void Telemetry.capture(
53 "install",
54 {
55 extensionVersion: getExtensionVersion(),
56 },
57 true,
58 );
59 }
60
61 // Register config.yaml schema by removing old entries and adding new one (uri.fsPath changes with each version)
62 const yamlMatcher = ".continue/**/*.yaml";
63 const yamlConfig = vscode.workspace.getConfiguration("yaml");
64
65 const newPath = vscode.Uri.joinPath(
66 context.extension.extensionUri,
67 "config-yaml-schema.json",
68 ).toString();
69
70 try {
71 await yamlConfig.update(
72 "schemas",
73 { [newPath]: [yamlMatcher] },
74 vscode.ConfigurationTarget.Global,
75 );
76 } catch (error) {
77 console.error(
78 "Failed to register Continue config.yaml schema, most likely, YAML extension is not installed",
79 error,
80 );
81 }
82
83 const api = new VsCodeContinueApi(vscodeExtension);
84 const continuePublicApi = {
85 registerCustomContextProvider: api.registerCustomContextProvider.bind(api),
86 };
87
88 // 'export' public api-surface
89 // or entire extension for testing
90 return process.env.NODE_ENV === "test"
91 ? {
92 ...continuePublicApi,
93 extension: vscodeExtension,
94 }
95 : continuePublicApi;
96}