mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 14:44:21 +01:00
feat: allow for multiple values in cli options for adding extensions (#1070)
This commit is contained in:
@@ -15,8 +15,8 @@ use mcp_client::transport::Error as McpClientError;
|
|||||||
pub async fn build_session(
|
pub async fn build_session(
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
resume: bool,
|
resume: bool,
|
||||||
extension: Option<String>,
|
extensions: Vec<String>,
|
||||||
builtin: Option<String>,
|
builtins: Vec<String>,
|
||||||
) -> Session<'static> {
|
) -> Session<'static> {
|
||||||
// Load config and get provider/model
|
// Load config and get provider/model
|
||||||
let config = Config::global();
|
let config = Config::global();
|
||||||
@@ -64,8 +64,8 @@ pub async fn build_session(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add extension if provided
|
// Add extensions if provided
|
||||||
if let Some(extension_str) = extension {
|
for extension_str in extensions {
|
||||||
let mut parts: Vec<&str> = extension_str.split_whitespace().collect();
|
let mut parts: Vec<&str> = extension_str.split_whitespace().collect();
|
||||||
let mut envs = std::collections::HashMap::new();
|
let mut envs = std::collections::HashMap::new();
|
||||||
|
|
||||||
@@ -104,8 +104,8 @@ pub async fn build_session(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add builtin extension if provided
|
// Add builtin extensions
|
||||||
if let Some(name) = builtin {
|
for name in builtins {
|
||||||
let config = ExtensionConfig::Builtin { name };
|
let config = ExtensionConfig::Builtin { name };
|
||||||
agent.add_extension(config).await.unwrap_or_else(|e| {
|
agent.add_extension(config).await.unwrap_or_else(|e| {
|
||||||
eprintln!("Failed to start builtin extension: {}", e);
|
eprintln!("Failed to start builtin extension: {}", e);
|
||||||
|
|||||||
@@ -65,23 +65,25 @@ enum Command {
|
|||||||
)]
|
)]
|
||||||
resume: bool,
|
resume: bool,
|
||||||
|
|
||||||
/// Add a stdio extension with environment variables and command
|
/// Add stdio extensions with environment variables and commands
|
||||||
#[arg(
|
#[arg(
|
||||||
long = "with-extension",
|
long = "with-extension",
|
||||||
value_name = "COMMAND",
|
value_name = "COMMAND",
|
||||||
help = "Add a stdio extension (e.g., 'GITHUB_TOKEN=xyz npx -y @modelcontextprotocol/server-github')",
|
help = "Add stdio extensions (can be specified multiple times)",
|
||||||
long_help = "Add a stdio extension from a full command with environment variables. Format: 'ENV1=val1 ENV2=val2 command args...'"
|
long_help = "Add stdio extensions from full commands with environment variables. Can be specified multiple times. Format: 'ENV1=val1 ENV2=val2 command args...'",
|
||||||
|
action = clap::ArgAction::Append
|
||||||
)]
|
)]
|
||||||
extension: Option<String>,
|
extension: Vec<String>,
|
||||||
|
|
||||||
/// Add a builtin extension by name
|
/// Add builtin extensions by name
|
||||||
#[arg(
|
#[arg(
|
||||||
long = "with-builtin",
|
long = "with-builtin",
|
||||||
value_name = "NAME",
|
value_name = "NAME",
|
||||||
help = "Add a builtin extension by name (e.g., 'developer')",
|
help = "Add builtin extensions by name (e.g., 'developer' or multiple: 'developer,github')",
|
||||||
long_help = "Add a builtin extension that is bundled with goose by specifying its name"
|
long_help = "Add one or more builtin extensions that are bundled with goose by specifying their names, comma-separated",
|
||||||
|
value_delimiter = ','
|
||||||
)]
|
)]
|
||||||
builtin: Option<String>,
|
builtin: Vec<String>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Execute commands from an instruction file
|
/// Execute commands from an instruction file
|
||||||
@@ -128,23 +130,25 @@ enum Command {
|
|||||||
)]
|
)]
|
||||||
resume: bool,
|
resume: bool,
|
||||||
|
|
||||||
/// Add a stdio extension with environment variables and command
|
/// Add stdio extensions with environment variables and commands
|
||||||
#[arg(
|
#[arg(
|
||||||
long = "with-extension",
|
long = "with-extension",
|
||||||
value_name = "COMMAND",
|
value_name = "COMMAND",
|
||||||
help = "Add a stdio extension with environment variables and command (e.g., 'GITHUB_TOKEN=xyz npx -y @modelcontextprotocol/server-github')",
|
help = "Add stdio extensions (can be specified multiple times)",
|
||||||
long_help = "Add a stdio extension with environment variables and command. Format: 'ENV1=val1 ENV2=val2 command args...'"
|
long_help = "Add stdio extensions from full commands with environment variables. Can be specified multiple times. Format: 'ENV1=val1 ENV2=val2 command args...'",
|
||||||
|
action = clap::ArgAction::Append
|
||||||
)]
|
)]
|
||||||
extension: Option<String>,
|
extension: Vec<String>,
|
||||||
|
|
||||||
/// Add a builtin extension by name
|
/// Add builtin extensions by name
|
||||||
#[arg(
|
#[arg(
|
||||||
long = "with-builtin",
|
long = "with-builtin",
|
||||||
value_name = "NAME",
|
value_name = "NAME",
|
||||||
help = "Add a builtin extension by name (e.g., 'developer')",
|
help = "Add builtin extensions by name (e.g., 'developer' or multiple: 'developer,github')",
|
||||||
long_help = "Add a builtin extension that is compiled into goose by specifying its name"
|
long_help = "Add one or more builtin extensions that are bundled with goose by specifying their names, comma-separated",
|
||||||
|
value_delimiter = ','
|
||||||
)]
|
)]
|
||||||
builtin: Option<String>,
|
builtin: Vec<String>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// List available agent versions
|
/// List available agent versions
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ You can remove installed extensions.
|
|||||||
You can start a tailored goose session with specific extensions directly from the CLI. To do this, run the following command:
|
You can start a tailored goose session with specific extensions directly from the CLI. To do this, run the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
goose session --with-extension "{extension command}"
|
goose session --with-extension "{extension command}" --with-extension "{antoher extension command}"
|
||||||
```
|
```
|
||||||
|
|
||||||
:::info
|
:::info
|
||||||
@@ -261,6 +261,14 @@ goose session --with-extension "VAR=value command arg1 arg2"
|
|||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
You can also start a session with built-in extensions by using the `--with-builtin` flag.
|
||||||
|
```bash
|
||||||
|
goose session --with-builtin "developer,memory"
|
||||||
|
goose session --with-builtin developer --with-builtin memory
|
||||||
|
```
|
||||||
|
:::
|
||||||
|
|
||||||
## Developing Extensions
|
## Developing Extensions
|
||||||
Goose extensions are implemented with MCP, a standard protocol that allows AI models and agents to securely connect with local or remote resources. Learn how to build your own [extension as an MCP server](https://modelcontextprotocol.io/quickstart/server).
|
Goose extensions are implemented with MCP, a standard protocol that allows AI models and agents to securely connect with local or remote resources. Learn how to build your own [extension as an MCP server](https://modelcontextprotocol.io/quickstart/server).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user