diff --git a/crates/goose/src/developer.rs b/crates/goose/src/developer.rs index ac3a5caa50..090288b350 100644 --- a/crates/goose/src/developer.rs +++ b/crates/goose/src/developer.rs @@ -16,7 +16,8 @@ pub struct DeveloperSystem { tools: Vec, cwd: Mutex, active_files: Mutex>, - file_history: Mutex>>, // Moved file_history here + file_history: Mutex>>, + instructions: String, } impl Default for DeveloperSystem { @@ -60,6 +61,7 @@ impl DeveloperSystem { indoc! {r#" Perform text editing operations on files. The `command` parameter specifies the operation to perform. + You can use "write" to fully overwrite an existing file or to create a new file. "#}, json!({ "type": "object", @@ -70,7 +72,7 @@ impl DeveloperSystem { "description": "Path to the file. Can be absolute or relative to the system CWD" }, "command": { - "enum": ["view", "create", "replace", "insert", "undo"], + "enum": ["view", "write", "replace", "insert", "undo"], "description": "The commands to run." }, "new_str": { @@ -97,11 +99,34 @@ impl DeveloperSystem { }), ); + let instructions = formatdoc!{r#" + The developer system is loaded in the directory listed below. + You can use the shell tool to run any command that would work on the relevant operating system. + Use the shell tool as needed to locate files or interact with the project. Only files + that have been read or modified using the edit tools will show up in the active files list. + + bash + - Prefer ripgrep - `rg` - when you need to locate content, it will respected ignored files for + efficiency. + - to locate files by name: `rg --files | rg example.py` + - to locate consent inside files: `rg 'class Example'` + - The operating system for these commands is {os} + + + text_edit + - Always use 'view' command first before any edit operations + - File edits are tracked and can be undone with 'undo' + - String replacements must match exactly once in the file + - Line numbers start at 1 for insert operations + "#, + os=std::env::consts::OS, + }; Self { tools: vec![bash_tool, text_editor_tool], cwd: Mutex::new(std::env::current_dir().unwrap()), active_files: Mutex::new(HashSet::new()), - file_history: Mutex::new(HashMap::new()), // Initialize file_history + file_history: Mutex::new(HashMap::new()), + instructions: instructions, } } @@ -181,7 +206,7 @@ impl DeveloperSystem { match command { "view" => self.text_editor_view(&path).await, - "create" => { + "write" => { let file_text = params .get("file_text") .and_then(|v| v.as_str()) @@ -407,11 +432,12 @@ impl System for DeveloperSystem { } fn description(&self) -> &str { - "A system that provides bash and text editing capabilities" + "Use the developer system to build software and solve problems by editing files and +running commands on the shell." } fn instructions(&self) -> &str { - "Use the provided tools to perform bash operations and text editing tasks." + self.instructions.as_str() } fn tools(&self) -> &[Tool] { diff --git a/crates/goose/src/prompts/system.md b/crates/goose/src/prompts/system.md index dd00d5c348..1619e81ddc 100644 --- a/crates/goose/src/prompts/system.md +++ b/crates/goose/src/prompts/system.md @@ -2,18 +2,13 @@ You are a general purpose AI agent called Goose. You are capable of dynamically plugging into new sytems and learning how to use them. You solve higher level problems using the tools in these systems, and can -interact with multiple at once. In addition to using tools, you answer -questions based on your background knowledge and memories. +interact with multiple at once. Because you dynamically load systems, your conversation history may refer to interactions with sytems that are not currently active. The currently active systems are below. Each of these systems provides tools that are in your tool specification. -If the user asks how to add a new system to your capabilities, let them know -that they can use /discover https://system/endpoint. If you currently have no -systems or tools, let them know they can add them via that command. - # Systems: {% for system in systems %}