feat: show recipe explanation (#2530)
Co-authored-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::commands::project::{handle_project_default, handle_projects_interacti
|
||||
use crate::commands::recipe::{handle_deeplink, handle_validate};
|
||||
use crate::commands::session::{handle_session_list, handle_session_remove};
|
||||
use crate::logging::setup_logging;
|
||||
use crate::recipes::recipe::load_recipe;
|
||||
use crate::recipes::recipe::{explain_recipe_with_parameters, load_recipe_as_template};
|
||||
use crate::session;
|
||||
use crate::session::{build_session, SessionBuilderConfig};
|
||||
use goose_bench::bench_config::BenchRunConfig;
|
||||
@@ -333,6 +333,13 @@ enum Command {
|
||||
)]
|
||||
no_session: bool,
|
||||
|
||||
/// Show the recipe title, description, and parameters
|
||||
#[arg(
|
||||
long = "explain",
|
||||
help = "Show the recipe title, description, and parameters"
|
||||
)]
|
||||
explain: bool,
|
||||
|
||||
/// Maximum number of consecutive identical tool calls allowed
|
||||
#[arg(
|
||||
long = "max-tool-repetitions",
|
||||
@@ -536,9 +543,10 @@ pub async fn cli() -> Result<()> {
|
||||
remote_extensions,
|
||||
builtins,
|
||||
params,
|
||||
explain,
|
||||
}) => {
|
||||
let input_config = match (instructions, input_text, recipe) {
|
||||
(Some(file), _, _) if file == "-" => {
|
||||
let input_config = match (instructions, input_text, recipe, explain) {
|
||||
(Some(file), _, _, _) if file == "-" => {
|
||||
let mut input = String::new();
|
||||
std::io::stdin()
|
||||
.read_to_string(&mut input)
|
||||
@@ -550,7 +558,7 @@ pub async fn cli() -> Result<()> {
|
||||
additional_system_prompt: None,
|
||||
}
|
||||
}
|
||||
(Some(file), _, _) => {
|
||||
(Some(file), _, _, _) => {
|
||||
let contents = std::fs::read_to_string(&file).unwrap_or_else(|err| {
|
||||
eprintln!(
|
||||
"Instruction file not found — did you mean to use goose run --text?\n{}",
|
||||
@@ -564,14 +572,18 @@ pub async fn cli() -> Result<()> {
|
||||
additional_system_prompt: None,
|
||||
}
|
||||
}
|
||||
(_, Some(text), _) => InputConfig {
|
||||
(_, Some(text), _, _) => InputConfig {
|
||||
contents: Some(text),
|
||||
extensions_override: None,
|
||||
additional_system_prompt: None,
|
||||
},
|
||||
(_, _, Some(recipe_name)) => {
|
||||
(_, _, Some(recipe_name), explain) => {
|
||||
if explain {
|
||||
explain_recipe_with_parameters(&recipe_name, params)?;
|
||||
return Ok(());
|
||||
}
|
||||
let recipe =
|
||||
load_recipe(&recipe_name, true, Some(params)).unwrap_or_else(|err| {
|
||||
load_recipe_as_template(&recipe_name, params).unwrap_or_else(|err| {
|
||||
eprintln!("{}: {}", console::style("Error").red().bold(), err);
|
||||
std::process::exit(1);
|
||||
});
|
||||
@@ -581,7 +593,7 @@ pub async fn cli() -> Result<()> {
|
||||
additional_system_prompt: recipe.instructions,
|
||||
}
|
||||
}
|
||||
(None, None, None) => {
|
||||
(None, None, None, _) => {
|
||||
eprintln!("Error: Must provide either --instructions (-i), --text (-t), or --recipe. Use -i - for stdin.");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user