mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-19 07:04:21 +01:00
Add /clear command to clear goose context (#1802)
Co-authored-by: Bradley Axen <baxen@squareup.com>
This commit is contained in:
@@ -17,6 +17,7 @@ pub enum InputResult {
|
|||||||
GooseMode(String),
|
GooseMode(String),
|
||||||
Plan(PlanCommandOptions),
|
Plan(PlanCommandOptions),
|
||||||
EndPlan,
|
EndPlan,
|
||||||
|
Clear,
|
||||||
Recipe(Option<String>),
|
Recipe(Option<String>),
|
||||||
Summarize,
|
Summarize,
|
||||||
}
|
}
|
||||||
@@ -91,6 +92,7 @@ fn handle_slash_command(input: &str) -> Option<InputResult> {
|
|||||||
const CMD_MODE: &str = "/mode ";
|
const CMD_MODE: &str = "/mode ";
|
||||||
const CMD_PLAN: &str = "/plan";
|
const CMD_PLAN: &str = "/plan";
|
||||||
const CMD_ENDPLAN: &str = "/endplan";
|
const CMD_ENDPLAN: &str = "/endplan";
|
||||||
|
const CMD_CLEAR: &str = "/clear";
|
||||||
const CMD_RECIPE: &str = "/recipe";
|
const CMD_RECIPE: &str = "/recipe";
|
||||||
const CMD_SUMMARIZE: &str = "/summarize";
|
const CMD_SUMMARIZE: &str = "/summarize";
|
||||||
|
|
||||||
@@ -134,6 +136,7 @@ fn handle_slash_command(input: &str) -> Option<InputResult> {
|
|||||||
}
|
}
|
||||||
s if s.starts_with(CMD_PLAN) => parse_plan_command(s[CMD_PLAN.len()..].trim().to_string()),
|
s if s.starts_with(CMD_PLAN) => parse_plan_command(s[CMD_PLAN.len()..].trim().to_string()),
|
||||||
s if s == CMD_ENDPLAN => Some(InputResult::EndPlan),
|
s if s == CMD_ENDPLAN => Some(InputResult::EndPlan),
|
||||||
|
s if s == CMD_CLEAR => Some(InputResult::Clear),
|
||||||
s if s.starts_with(CMD_RECIPE) => parse_recipe_command(s),
|
s if s.starts_with(CMD_RECIPE) => parse_recipe_command(s),
|
||||||
s if s == CMD_SUMMARIZE => Some(InputResult::Summarize),
|
s if s == CMD_SUMMARIZE => Some(InputResult::Summarize),
|
||||||
_ => None,
|
_ => None,
|
||||||
@@ -246,6 +249,7 @@ fn print_help() {
|
|||||||
If no filepath is provided, it will be saved to ./recipe.yaml.
|
If no filepath is provided, it will be saved to ./recipe.yaml.
|
||||||
/summarize - Summarize the current conversation to reduce context length while preserving key information.
|
/summarize - Summarize the current conversation to reduce context length while preserving key information.
|
||||||
/? or /help - Display this help message
|
/? or /help - Display this help message
|
||||||
|
/clear - Clears the current chat history
|
||||||
|
|
||||||
Navigation:
|
Navigation:
|
||||||
Ctrl+C - Interrupt goose (resets the interaction to before the interrupted user request)
|
Ctrl+C - Interrupt goose (resets the interaction to before the interrupted user request)
|
||||||
|
|||||||
@@ -521,6 +521,17 @@ impl Session {
|
|||||||
output::render_exit_plan_mode();
|
output::render_exit_plan_mode();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
input::InputResult::Clear => {
|
||||||
|
save_history(&mut editor);
|
||||||
|
|
||||||
|
self.messages.clear();
|
||||||
|
tracing::info!("Chat context cleared by user.");
|
||||||
|
output::render_message(
|
||||||
|
&Message::assistant().with_text("Chat context cleared."),
|
||||||
|
self.debug,
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
input::InputResult::PromptCommand(opts) => {
|
input::InputResult::PromptCommand(opts) => {
|
||||||
save_history(&mut editor);
|
save_history(&mut editor);
|
||||||
self.handle_prompt_command(opts).await?;
|
self.handle_prompt_command(opts).await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user