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
2 changes: 2 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
shellexpand = "3.1"
strum = { version = "0.27", features = ["derive"] }
tempfile = "3"
thiserror = "1.0"
tokio = { version = "1.49", features = ["full"] }
Expand Down
1 change: 1 addition & 0 deletions crates/goose-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ tokio = { workspace = true }
futures = { workspace = true }
serde = { workspace = true }
serde_yaml = { workspace = true }
strum = { workspace = true }
tempfile = { workspace = true }
etcetera = { workspace = true }
rand = { workspace = true }
Expand Down
4 changes: 3 additions & 1 deletion crates/goose-cli/src/session/completion.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use goose::config::GooseMode;
use rustyline::completion::{Completer, FilenameCompleter, Pair};
use rustyline::highlight::{CmdKind, Highlighter};
use rustyline::hint::Hinter;
use rustyline::validate::Validator;
use rustyline::{Context, Helper, Result};
use std::borrow::Cow;
use std::sync::Arc;
use strum::VariantNames;

use super::{CompletionCache, HintStatus};

Expand Down Expand Up @@ -81,7 +83,7 @@ impl GooseCompleter {

/// Complete flags for the /mode command
fn complete_mode_flags(&self, line: &str) -> Result<(usize, Vec<Pair>)> {
let modes = ["auto", "approve", "smart_approve", "chat"];
let modes = GooseMode::VARIANTS;

let parts: Vec<&str> = line.split_whitespace().collect();

Expand Down
6 changes: 4 additions & 2 deletions crates/goose-cli/src/session/input.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use super::completion::GooseCompleter;
use super::{CompletionCache, HintStatus};
use anyhow::Result;
use goose::config::Config;
use goose::config::{Config, GooseMode};
use rustyline::Editor;
use shlex;
use std::collections::HashMap;
use std::sync::Arc;
use strum::VariantNames;

#[derive(Debug)]
pub enum InputResult {
Expand Down Expand Up @@ -409,6 +410,7 @@ fn get_input_prompt_string() -> String {

fn print_help() {
let newline_key = get_newline_key().to_ascii_uppercase();
let modes = GooseMode::VARIANTS.join(", ");
println!(
"Available commands:
/exit or /quit - Exit the session
Expand All @@ -419,7 +421,7 @@ fn print_help() {
/builtin <names> - Add builtin extensions by name (comma-separated)
/prompts [--extension <name>] - List all available prompts, optionally filtered by extension
/prompt <n> [--info] [key=value...] - Get prompt info or execute a prompt
/mode <name> - Set the goose mode to use ('auto', 'approve', 'chat', 'smart_approve')
/mode <name> - Set the goose mode to use ({modes})
/plan <message_text> - Enters 'plan' mode with optional message. Create a plan based on the current messages and asks user if they want to act on it.
If user acts on the plan, goose mode is set to 'auto' and returns to 'normal' goose mode.
To warm up goose before using '/plan', we recommend setting '/mode approve' & putting appropriate context into goose.
Expand Down
7 changes: 4 additions & 3 deletions crates/goose-cli/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use input::InputResult;
use rmcp::model::PromptMessage;
use rmcp::model::ServerNotification;
use rmcp::model::{ErrorCode, ErrorData};
use strum::VariantNames;

use goose::config::paths::Paths;
use goose::conversation::message::{ActionRequiredData, Message, MessageContent};
Expand Down Expand Up @@ -717,14 +718,14 @@ impl CliSession {
Ok(mode) => mode,
Err(_) => {
output::render_error(&format!(
"Invalid mode '{}'. Mode must be one of: auto, approve, chat, smart_approve",
mode
"Invalid mode '{mode}'. Mode must be one of: {}",
GooseMode::VARIANTS.join(", ")
));
return Ok(());
}
};
config.set_goose_mode(mode)?;
output::goose_mode_message(&format!("Goose mode set to '{:?}'", mode));
output::goose_mode_message(&format!("Goose mode set to '{mode}'"));
Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions crates/goose/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ keyring = { version = "3.6.2", features = [
"vendored",
] }
serde_yaml = { workspace = true }
strum = { workspace = true }
once_cell = { workspace = true }
etcetera = { workspace = true }
rand = { workspace = true }
Expand Down
32 changes: 15 additions & 17 deletions crates/goose/src/config/goose_mode.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
use std::str::FromStr;

use serde::{Deserialize, Serialize};
use strum::{Display, EnumString, IntoStaticStr, VariantNames};

#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[derive(
Copy,
Clone,
Debug,
Eq,
PartialEq,
Serialize,
Deserialize,
Display,
EnumString,
IntoStaticStr,
VariantNames,
)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum GooseMode {
Auto,
Approve,
SmartApprove,
Chat,
}

impl FromStr for GooseMode {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"auto" => Ok(GooseMode::Auto),
"approve" => Ok(GooseMode::Approve),
"smart_approve" => Ok(GooseMode::SmartApprove),
"chat" => Ok(GooseMode::Chat),
_ => Err(format!("invalid mode: {}", s)),
}
}
}
8 changes: 1 addition & 7 deletions crates/goose/tests/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,8 @@ impl ProviderTester {
message: &str,
label: &str,
) -> Result<()> {
let mode_str = match mode {
GooseMode::Approve => "approve",
GooseMode::SmartApprove => "smart_approve",
GooseMode::Auto => "auto",
GooseMode::Chat => "chat",
};
// Guard must live through agent.reply() — providers read GOOSE_MODE at spawn time.
let _guard = env_lock::lock_env([("GOOSE_MODE", Some(mode_str))]);
let _guard = env_lock::lock_env([("GOOSE_MODE", Some(<&str>::from(mode)))]);
let provider = if self.is_cli_provider {
create_with_named_model(
&self.name.to_lowercase(),
Expand Down
Loading