Skip to content

Commit

Permalink
Merge branch 'v1.0' into wtang/server_prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
wendytang committed Jan 13, 2025
2 parents 0477f7a + bf65a7d commit 95253fe
Show file tree
Hide file tree
Showing 68 changed files with 3,443 additions and 814 deletions.
11 changes: 0 additions & 11 deletions crates/goose-cli/src/commands/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
43 changes: 0 additions & 43 deletions crates/goose-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ mod logging;
mod profile;
mod prompt;
mod session;
mod systems;

use commands::agent_version::AgentCommand;
use commands::configure::handle_configure;
Expand All @@ -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 {
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down
8 changes: 0 additions & 8 deletions crates/goose-cli/src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand All @@ -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");
Expand Down
1 change: 0 additions & 1 deletion crates/goose-cli/src/systems/mod.rs

This file was deleted.

93 changes: 0 additions & 93 deletions crates/goose-cli/src/systems/system_handler.rs

This file was deleted.

5 changes: 3 additions & 2 deletions crates/goose-mcp/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
### Test with MCP Inspector

Update examples/mcp.rs to use the appropriate the MCP server (eg. DeveloperRouter)

```bash
npx @modelcontextprotocol/inspector cargo run -p developer
npx @modelcontextprotocol/inspector cargo run -p jetbrains
npx @modelcontextprotocol/inspector cargo run -p goose-mcp --example mcp
```

Then visit the Inspector in the browser window and test the different endpoints.
36 changes: 36 additions & 0 deletions crates/goose-mcp/examples/mcp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// An example script to run an MCP server
use anyhow::Result;
use goose_mcp::DeveloperRouter;
use mcp_server::router::RouterService;
use mcp_server::{ByteTransport, Server};
use tokio::io::{stdin, stdout};
use tracing_appender::rolling::{RollingFileAppender, Rotation};
use tracing_subscriber::{self, EnvFilter};

#[tokio::main]
async fn main() -> Result<()> {
// Set up file appender for logging
let file_appender = RollingFileAppender::new(Rotation::DAILY, "logs", "mcp-server.log");

// Initialize the tracing subscriber with file and stdout logging
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env().add_directive(tracing::Level::INFO.into()))
.with_writer(file_appender)
.with_target(false)
.with_thread_ids(true)
.with_file(true)
.with_line_number(true)
.init();

tracing::info!("Starting MCP server");

// Create an instance of our counter router
let router = RouterService(DeveloperRouter::new());

// Create and run the server
let server = Server::new(router);
let transport = ByteTransport::new(stdin(), stdout());

tracing::info!("Server initialized and ready to handle requests");
Ok(server.run(transport).await?)
}
2 changes: 1 addition & 1 deletion crates/goose-mcp/src/developer/developer_prompt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use mcp_core::prompt::{Prompt, PromptArgument, PromptTemplate};
use include_dir::{include_dir, Dir};
use mcp_core::prompt::{Prompt, PromptArgument, PromptTemplate};

static PROMPTS_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/src/developer/prompts");

Expand Down
6 changes: 4 additions & 2 deletions crates/goose-mcp/src/developer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ impl DeveloperRouter {
let child = Command::new("bash")
.stdout(Stdio::piped()) // These two pipes required to capture output later.
.stderr(Stdio::piped())
.stdin(Stdio::null())
.kill_on_drop(true) // Critical so that the command is killed when the agent.reply stream is interrupted.
.arg("-c")
.arg(cmd_with_redirect)
Expand Down Expand Up @@ -783,8 +784,9 @@ impl Router for DeveloperRouter {

fn capabilities(&self) -> ServerCapabilities {
CapabilitiesBuilder::new()
.with_tools(true)
.with_prompts(true)
.with_tools(false)
.with_prompts(false)
.with_resources(false, false)
.build()
}

Expand Down
6 changes: 5 additions & 1 deletion crates/goose-mcp/src/developer2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ impl Developer2Router {
let child = Command::new("bash")
.stdout(Stdio::piped()) // These two pipes required to capture output later.
.stderr(Stdio::piped())
.stdin(Stdio::null())
.kill_on_drop(true) // Critical so that the command is killed when the agent.reply stream is interrupted.
.arg("-c")
.arg(cmd_with_redirect)
Expand Down Expand Up @@ -483,7 +484,10 @@ impl Router for Developer2Router {
}

fn capabilities(&self) -> ServerCapabilities {
CapabilitiesBuilder::new().with_tools(true).build()
CapabilitiesBuilder::new()
.with_tools(false)
.with_resources(false, false)
.build()
}

fn list_tools(&self) -> Vec<Tool> {
Expand Down
5 changes: 4 additions & 1 deletion crates/goose-mcp/src/nondeveloper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,10 @@ impl Router for NonDeveloperRouter {
}

fn capabilities(&self) -> ServerCapabilities {
CapabilitiesBuilder::new().with_tools(true).build()
CapabilitiesBuilder::new()
.with_tools(false)
.with_resources(false, false)
.build()
}

fn list_tools(&self) -> Vec<Tool> {
Expand Down
Loading

0 comments on commit 95253fe

Please sign in to comment.