Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions crates/goose/src/agents/platform_extensions/summon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::config::{Config, GooseMode};
use crate::providers;
use crate::recipe::build_recipe::build_recipe_from_template;
use crate::recipe::local_recipes::load_local_recipe_file;
use crate::recipe::{Recipe, Settings, RECIPE_FILE_EXTENSIONS};
use crate::recipe::{Recipe, RecipeParameter, Settings, RECIPE_FILE_EXTENSIONS};
use crate::session::extension_data::EnabledExtensionsState;
use crate::session::SessionType;
use crate::sources::parse_frontmatter;
Expand Down Expand Up @@ -557,7 +557,16 @@ impl SummonClient {

match load_local_recipe_file(&sr.path) {
Ok(recipe_file) => match Recipe::from_content(&recipe_file.content) {
Ok(recipe) => recipe.instructions.unwrap_or_default(),
Ok(recipe) => {
let mut content = recipe.instructions.unwrap_or_default();
if let Some(params) = &recipe.parameters {
if !params.is_empty() {
content.push_str("\n\n");
content.push_str(&Self::format_parameters(params));
}
}
content
}
Err(_) => recipe_file.content,
},
Err(_) => String::new(),
Expand Down Expand Up @@ -621,10 +630,8 @@ impl SummonClient {
let mut desc = recipe.description.clone();

if let Some(params) = &recipe.parameters {
let param_names: Vec<&str> = params.iter().map(|p| p.key.as_str()).collect();
if !param_names.is_empty() {
let params_str = param_names.join(", ");
desc = format!("{} (params: {})", desc, params_str);
if !params.is_empty() {
desc = format!("{}\n{}", desc, Self::format_parameters(params));
}
}

Expand All @@ -635,6 +642,24 @@ impl SummonClient {
format!("Subrecipe from {}", sr.path)
}

fn format_parameters(params: &[RecipeParameter]) -> String {
let mut out = String::from("Parameters:");
for p in params {
let mut detail = format!("\n - {} ({}, {})", p.key, p.input_type, p.requirement);
if let Some(default) = &p.default {
detail.push_str(&format!(", default: \"{}\"", default));
}
if let Some(options) = &p.options {
if !options.is_empty() {
detail.push_str(&format!(", options: [{}]", options.join(", ")));
}
}
detail.push_str(&format!(": {}", p.description));
out.push_str(&detail);
}
out
}

async fn handle_load(
&self,
session_id: &str,
Expand Down
Loading