Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/goose-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ shlex = "1.3.0"
async-trait = "0.1.86"
base64 = "0.22.1"
regex = "1.11.1"
minijinja = "2.8.0"
minijinja = { version = "2.8.0", features = ["loader"] }
nix = { version = "0.30.1", features = ["process", "signal"] }
tar = "0.4"
# Web server dependencies
Expand Down
41 changes: 33 additions & 8 deletions crates/goose-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use crate::commands::schedule::{
};
use crate::commands::session::{handle_session_list, handle_session_remove};
use crate::logging::setup_logging;
use crate::recipes::recipe::{explain_recipe_with_parameters, load_recipe_as_template};
use crate::recipes::recipe::{
explain_recipe_with_parameters, load_recipe_as_template, load_recipe_content_as_template,
};
use crate::session;
use crate::session::{build_session, SessionBuilderConfig, SessionSettings};
use goose_bench::bench_config::BenchRunConfig;
Expand Down Expand Up @@ -431,6 +433,13 @@ enum Command {
)]
explain: bool,

/// Print the rendered recipe instead of running it
#[arg(
long = "render-recipe",
help = "Print the rendered recipe instead of running it."
)]
render_recipe: bool,

/// Maximum number of consecutive identical tool calls allowed
#[arg(
long = "max-tool-repetitions",
Expand Down Expand Up @@ -681,6 +690,7 @@ pub async fn cli() -> Result<()> {
handle_projects_interactive()?;
return Ok(());
}

Some(Command::Run {
instructions,
input_text,
Expand All @@ -697,11 +707,17 @@ pub async fn cli() -> Result<()> {
builtins,
params,
explain,
render_recipe,
quiet,
}) => {
let (input_config, session_settings) = match (instructions, input_text, recipe, explain)
{
(Some(file), _, _, _) if file == "-" => {
let (input_config, session_settings) = match (
instructions,
input_text,
recipe,
explain,
render_recipe,
) {
(Some(file), _, _, _, _) if file == "-" => {
let mut input = String::new();
std::io::stdin()
.read_to_string(&mut input)
Expand All @@ -716,7 +732,7 @@ pub async fn cli() -> Result<()> {
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{}",
Expand All @@ -733,19 +749,28 @@ pub async fn cli() -> Result<()> {
None,
)
}
(_, Some(text), _, _) => (
(_, Some(text), _, _, _) => (
InputConfig {
contents: Some(text),
extensions_override: None,
additional_system_prompt: system,
},
None,
),
(_, _, Some(recipe_name), explain) => {
(_, _, Some(recipe_name), explain, render_recipe) => {
if explain {
explain_recipe_with_parameters(&recipe_name, params)?;
return Ok(());
}
if render_recipe {
let recipe = load_recipe_content_as_template(&recipe_name, params)
.unwrap_or_else(|err| {
eprintln!("{}: {}", console::style("Error").red().bold(), err);
std::process::exit(1);
});
println!("{}", recipe);
return Ok(());
}
let recipe =
load_recipe_as_template(&recipe_name, params).unwrap_or_else(|err| {
eprintln!("{}: {}", console::style("Error").red().bold(), err);
Expand All @@ -764,7 +789,7 @@ pub async fn cli() -> Result<()> {
}),
)
}
(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);
}
Expand Down
Loading
Loading