mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-23 09:04:26 +01:00
feat(cli): add mcp prompt support via slash commands (#1323)
This commit is contained in:
@@ -72,9 +72,9 @@ pub fn load_prompt_files() -> HashMap<String, Prompt> {
|
||||
description: arg.description,
|
||||
required: arg.required,
|
||||
})
|
||||
.collect();
|
||||
.collect::<Vec<PromptArgument>>();
|
||||
|
||||
let prompt = Prompt::new(&template.id, &template.template, arguments);
|
||||
let prompt = Prompt::new(&template.id, Some(&template.template), Some(arguments));
|
||||
|
||||
if prompts.contains_key(&prompt.name) {
|
||||
eprintln!("Duplicate prompt name '{}' found. Skipping.", prompt.name);
|
||||
@@ -905,47 +905,35 @@ impl Router for DeveloperRouter {
|
||||
Box::pin(async move { Ok("".to_string()) })
|
||||
}
|
||||
|
||||
fn list_prompts(&self) -> Option<Vec<Prompt>> {
|
||||
if self.prompts.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(self.prompts.values().cloned().collect())
|
||||
}
|
||||
fn list_prompts(&self) -> Vec<Prompt> {
|
||||
self.prompts.values().cloned().collect()
|
||||
}
|
||||
|
||||
fn get_prompt(
|
||||
&self,
|
||||
prompt_name: &str,
|
||||
) -> Option<Pin<Box<dyn Future<Output = Result<String, PromptError>> + Send + 'static>>> {
|
||||
) -> Pin<Box<dyn Future<Output = Result<String, PromptError>> + Send + 'static>> {
|
||||
let prompt_name = prompt_name.trim().to_owned();
|
||||
|
||||
// Validate prompt name is not empty
|
||||
if prompt_name.is_empty() {
|
||||
return Some(Box::pin(async move {
|
||||
return Box::pin(async move {
|
||||
Err(PromptError::InvalidParameters(
|
||||
"Prompt name cannot be empty".to_string(),
|
||||
))
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
let prompts = Arc::clone(&self.prompts);
|
||||
|
||||
Some(Box::pin(async move {
|
||||
Box::pin(async move {
|
||||
match prompts.get(&prompt_name) {
|
||||
Some(prompt) => {
|
||||
if prompt.description.trim().is_empty() {
|
||||
Err(PromptError::InternalError(format!(
|
||||
"Prompt '{prompt_name}' has an empty description"
|
||||
)))
|
||||
} else {
|
||||
Ok(prompt.description.clone())
|
||||
}
|
||||
}
|
||||
Some(prompt) => Ok(prompt.description.clone().unwrap_or_default()),
|
||||
None => Err(PromptError::NotFound(format!(
|
||||
"Prompt '{prompt_name}' not found"
|
||||
))),
|
||||
}
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user