extension.rs

 1use std::sync::Arc;
 2
 3use collections::HashMap;
 4use schemars::JsonSchema;
 5use serde::{Deserialize, Serialize};
 6use settings_macros::{MergeFrom, with_fallible_options};
 7
 8#[with_fallible_options]
 9#[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
10pub struct ExtensionSettingsContent {
11    /// The extensions that should be automatically installed by Zed.
12    ///
13    /// This is used to make functionality provided by extensions (e.g., language support)
14    /// available out-of-the-box.
15    ///
16    /// Default: { "html": true }
17    #[serde(default)]
18    pub auto_install_extensions: HashMap<Arc<str>, bool>,
19    #[serde(default)]
20    pub auto_update_extensions: HashMap<Arc<str>, bool>,
21    /// The capabilities granted to extensions.
22    pub granted_extension_capabilities: Option<Vec<ExtensionCapabilityContent>>,
23    /// Extension language model providers that are allowed to read API keys from
24    /// environment variables. Each entry is in the format
25    /// "extension_id:provider_id:ENV_VAR_NAME" (e.g., "google-ai:google-ai:GEMINI_API_KEY").
26    ///
27    /// Default: []
28    pub allowed_env_var_providers: Option<Vec<Arc<str>>>,
29}
30
31/// A capability for an extension.
32#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)]
33#[serde(tag = "kind", rename_all = "snake_case")]
34pub enum ExtensionCapabilityContent {
35    #[serde(rename = "process:exec")]
36    ProcessExec {
37        /// The command to execute.
38        command: String,
39        /// The arguments to pass to the command. Use `*` for a single wildcard argument.
40        /// If the last element is `**`, then any trailing arguments are allowed.
41        args: Vec<String>,
42    },
43    DownloadFile {
44        host: String,
45        path: Vec<String>,
46    },
47    #[serde(rename = "npm:install")]
48    NpmInstallPackage {
49        package: String,
50    },
51}