mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
chore: remove unused old setup for CLI (#574)
Co-authored-by: Mic Neale <michael.neale@gmail.com> Co-authored-by: Salman Mohammed <smohammed@squareup.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<String>,
|
||||
},
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@ use std::path::PathBuf;
|
||||
pub struct Profile {
|
||||
pub provider: String,
|
||||
pub model: String,
|
||||
#[serde(default)]
|
||||
pub additional_systems: Vec<AdditionalSystem>,
|
||||
pub temperature: Option<f32>,
|
||||
pub context_limit: Option<usize>,
|
||||
pub max_tokens: Option<i32>,
|
||||
@@ -27,12 +25,6 @@ pub struct Profiles {
|
||||
pub profile_items: HashMap<String, Profile>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct AdditionalSystem {
|
||||
pub name: String,
|
||||
pub location: String,
|
||||
}
|
||||
|
||||
pub fn profile_path() -> Result<PathBuf> {
|
||||
let home_dir = dirs::home_dir().ok_or(anyhow::anyhow!("Could not determine home directory"))?;
|
||||
let config_dir = home_dir.join(".config").join("goose");
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
pub mod system_handler;
|
||||
@@ -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<Option<String>, Box<dyn std::error::Error>> {
|
||||
let full_url = format!("{}/fetch_name", url);
|
||||
match reqwest::get(full_url).await {
|
||||
Ok(response) => match response.json::<Value>().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<dyn Error>> {
|
||||
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<dyn Error>> {
|
||||
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(())
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user