From ea6ec0d3e24063c74c4e83818eb199f24fb9ba18 Mon Sep 17 00:00:00 2001 From: Bradley Axen Date: Mon, 13 Jan 2025 11:47:20 -0800 Subject: [PATCH] chore: remove unused old setup for CLI (#574) Co-authored-by: Mic Neale Co-authored-by: Salman Mohammed --- crates/goose-cli/src/commands/configure.rs | 11 --- crates/goose-cli/src/main.rs | 43 --------- crates/goose-cli/src/profile.rs | 8 -- crates/goose-cli/src/systems/mod.rs | 1 - .../goose-cli/src/systems/system_handler.rs | 93 ------------------- 5 files changed, 156 deletions(-) delete mode 100644 crates/goose-cli/src/systems/mod.rs delete mode 100644 crates/goose-cli/src/systems/system_handler.rs diff --git a/crates/goose-cli/src/commands/configure.rs b/crates/goose-cli/src/commands/configure.rs index 99298f433f..b97c08ab73 100644 --- a/crates/goose-cli/src/commands/configure.rs +++ b/crates/goose-cli/src/commands/configure.rs @@ -103,20 +103,9 @@ pub async fn handle_configure( .interact()? }; - // Forward any existing systems from the profile if present - let additional_systems = - existing_profile.map_or(Vec::new(), |profile| profile.additional_systems.clone()); - - if !additional_systems.is_empty() { - let _ = cliclack::log::info( - format!("We kept the existing systems from your {} profile. You can edit this with `goose system`", profile_name) - ); - } - let profile = Profile { provider: provider_name.to_string(), model: model.clone(), - additional_systems, temperature: None, context_limit: None, max_tokens: None, diff --git a/crates/goose-cli/src/main.rs b/crates/goose-cli/src/main.rs index 833217527d..daa6e4e4f6 100644 --- a/crates/goose-cli/src/main.rs +++ b/crates/goose-cli/src/main.rs @@ -8,7 +8,6 @@ mod logging; mod profile; mod prompt; mod session; -mod systems; use commands::agent_version::AgentCommand; use commands::configure::handle_configure; @@ -22,8 +21,6 @@ use std::io::{self, Read}; #[cfg(test)] mod test_helpers; -use crate::systems::system_handler::{add_system, remove_system}; - #[derive(Parser)] #[command(author, about, long_about = None)] struct Cli { @@ -67,13 +64,6 @@ enum Command { model: Option, }, - /// Manage system prompts and behaviors - #[command(about = "Manage the systems that goose can operate")] - System { - #[command(subcommand)] - action: SystemCommands, - }, - /// Manage system prompts and behaviors #[command(about = "Run one of the mcp servers bundled with goose")] Mcp { name: String }, @@ -187,29 +177,6 @@ enum Command { Agents(AgentCommand), } -#[derive(Subcommand)] -enum SystemCommands { - /// Add a new system prompt - #[command(about = "Add a new system prompt from URL")] - Add { - #[arg( - help = "URL of the system prompt to add", - long_help = "URL pointing to a file containing the system prompt to be added." - )] - url: String, - }, - - /// Remove an existing system prompt - #[command(about = "Remove an existing system prompt")] - Remove { - #[arg( - help = "URL of the system prompt to remove", - long_help = "URL of the system prompt that should be removed from the configuration." - )] - url: String, - }, -} - #[derive(clap::ValueEnum, Clone, Debug)] enum CliProviderVariant { OpenAi, @@ -235,16 +202,6 @@ async fn main() -> Result<()> { let _ = handle_configure(profile_name, provider, model).await; return Ok(()); } - Some(Command::System { action }) => match action { - SystemCommands::Add { url } => { - add_system(url).await.unwrap(); - return Ok(()); - } - SystemCommands::Remove { url } => { - remove_system(url).await.unwrap(); - return Ok(()); - } - }, Some(Command::Mcp { name }) => { let _ = run_server(&name).await; } diff --git a/crates/goose-cli/src/profile.rs b/crates/goose-cli/src/profile.rs index d62dfc5b86..78494b4b16 100644 --- a/crates/goose-cli/src/profile.rs +++ b/crates/goose-cli/src/profile.rs @@ -14,8 +14,6 @@ use std::path::PathBuf; pub struct Profile { pub provider: String, pub model: String, - #[serde(default)] - pub additional_systems: Vec, pub temperature: Option, pub context_limit: Option, pub max_tokens: Option, @@ -27,12 +25,6 @@ pub struct Profiles { pub profile_items: HashMap, } -#[derive(Serialize, Deserialize, Clone, Debug)] -pub struct AdditionalSystem { - pub name: String, - pub location: String, -} - pub fn profile_path() -> Result { let home_dir = dirs::home_dir().ok_or(anyhow::anyhow!("Could not determine home directory"))?; let config_dir = home_dir.join(".config").join("goose"); diff --git a/crates/goose-cli/src/systems/mod.rs b/crates/goose-cli/src/systems/mod.rs deleted file mode 100644 index 0d60bb1235..0000000000 --- a/crates/goose-cli/src/systems/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod system_handler; diff --git a/crates/goose-cli/src/systems/system_handler.rs b/crates/goose-cli/src/systems/system_handler.rs deleted file mode 100644 index 3fd9eac5b6..0000000000 --- a/crates/goose-cli/src/systems/system_handler.rs +++ /dev/null @@ -1,93 +0,0 @@ -use crate::profile::{load_profiles, save_profile, AdditionalSystem}; -use serde_json::Value; -use std::error::Error; - -pub async fn fetch_system(url: &str) -> Result, Box> { - let full_url = format!("{}/fetch_name", url); - match reqwest::get(full_url).await { - Ok(response) => match response.json::().await { - Ok(json) => { - if let Some(name) = json.get("name").and_then(|n| n.as_str()) { - return Ok(Some(name.to_string())); - } else { - println!("No 'name' field in the JSON response."); - } - } - Err(err) => { - println!("Failed to parse JSON: {}", err); - } - }, - Err(err) => { - println!("Failed to fetch URL: {}", err); - } - } - Ok(None) -} - -pub async fn add_system(url: String) -> Result<(), Box> { - let system_name = fetch_system(url.as_str()).await?; - if system_name.is_none() { - println!("System not found. Please enter a valid system location."); - return Ok(()); - } - let system_name = system_name.unwrap(); - match load_profiles() { - Ok(mut profiles) => { - if profiles.is_empty() { - println!("No profiles found. Please create a profile first via goose configure"); - return Ok(()); - } - for (profile_name, profile) in profiles.iter_mut() { - if profile.additional_systems.iter().any(|s| s.location == url) { - continue; - } - profile.additional_systems.push(AdditionalSystem { - name: system_name.to_string(), - location: url.to_string(), - }); - save_profile(profile_name, profile.clone())? - } - println!( - "System '{}' at '{}' added to all profiles", - system_name, url - ); - Ok(()) - } - Err(err) => { - println!("Failed to load profiles: {}", err); - Ok(()) - } - } -} - -pub async fn remove_system(url: String) -> Result<(), Box> { - let mut removed = false; - match load_profiles() { - Ok(mut profiles) => { - if profiles.is_empty() { - return Ok(()); - } - for (profile_name, profile) in profiles.iter_mut() { - if let Some(pos) = profile - .additional_systems - .iter() - .position(|s| s.location == url) - { - profile.additional_systems.remove(pos); - save_profile(profile_name, profile.clone())?; - removed = true; - } - } - if removed { - println!("System at '{}' has been removed from all profiles", url); - } else { - println!("System at '{}' not found in any profiles", url); - } - Ok(()) - } - Err(err) => { - println!("Failed to load profiles: {}", err); - Ok(()) - } - } -}