Elffuss BraidHub

kikocis/continue public

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