Skip to content

Commit 103dc07

Browse files
authored
Improve fs_write tool functionality (#735)
1 parent 70a72a4 commit 103dc07

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

crates/q_cli/src/cli/chat/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ const WELCOME_TEXT: &str = color_print::cstr! {"
8989
• Write unit tests for my application.
9090
• Help me understand my git status
9191
92+
<em>/acceptall</em> <black!>Toggles acceptance prompting for the session.</black!>
9293
<em>/help</em> <black!>Show the help dialogue</black!>
9394
<em>/quit</em> <black!>Quit the application</black!>
94-
<em>/acceptall</em> <black!>Toggle tool use acceptance prompting</black!>
9595
9696
9797
"};
@@ -101,14 +101,12 @@ const HELP_TEXT: &str = color_print::cstr! {"
101101
<magenta,em>q</magenta,em> (Amazon Q Chat)
102102
103103
<em>/clear</em> <black!>Clear the conversation history</black!>
104+
<em>/acceptall</em> <black!>Toggles acceptance prompting for the session.</black!>
104105
<em>/help</em> <black!>Show this help dialogue</black!>
105106
<em>/quit</em> <black!>Quit the application</black!>
106107
107108
<em>!{command}</em> <black!>Quickly execute a command in your current session</black!>
108109
109-
<black!>Use the following dangerous command at your own discretion.</black!>
110-
<em>/acceptall</em> <black!>Disables acceptance prompting for the session.</black!>
111-
112110
"};
113111

114112
pub async fn chat(input: Option<String>, accept_all: bool) -> Result<ExitCode> {
@@ -530,9 +528,10 @@ where
530528
execute!(
531529
self.output,
532530
style::SetForegroundColor(Color::Green),
533-
style::Print(format!("\n{} acceptance prompting.\n\n", match self.accept_all {
534-
true => "Disabled",
535-
false => "Enabled",
531+
style::Print(format!("\n{}\n\n", match self.accept_all {
532+
true =>
533+
"Disabled acceptance prompting.\nAgents can sometimes do unexpected things so understand the risks.",
534+
false => "Enabled acceptance prompting. Run again to disable.",
536535
})),
537536
style::SetForegroundColor(Color::Reset)
538537
)?;

crates/q_cli/src/cli/chat/tools/fs_write.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ impl FsWrite {
5555
FsWrite::Create { path, .. } => {
5656
let file_text = self.canonical_create_command_text();
5757
let path = sanitize_path_tool_arg(ctx, path);
58+
if let Some(parent) = path.parent() {
59+
fs.create_dir_all(parent).await?;
60+
}
61+
5862
let invoke_description = if fs.exists(&path) { "Replacing: " } else { "Creating: " };
5963
queue!(
6064
updates,

0 commit comments

Comments
 (0)