From 7e8e2a6ce6d96ffa31c202ead6f31f18dc73c618 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 1 Dec 2024 10:06:20 +0800 Subject: feat: append shell execute command to history file (#1026) --- src/config/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/config') diff --git a/src/config/mod.rs b/src/config/mod.rs index 39c63a3..e0e1efa 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -137,6 +137,7 @@ pub struct Config { pub serve_addr: Option, pub user_agent: Option, + pub append_command_to_history_file: bool, pub clients: Vec, @@ -206,6 +207,7 @@ impl Default for Config { serve_addr: None, user_agent: None, + append_command_to_history_file: true, clients: vec![], @@ -1950,7 +1952,7 @@ impl Config { if output.is_empty() || !self.save { return Ok(()); } - let timestamp = now(); + let now = now(); let summary = input.summary(); let raw_input = input.raw(); let scope = if self.agent.is_none() { @@ -1983,7 +1985,7 @@ impl Config { None => String::new(), }; let output = format!( - "# CHAT: {summary} [{timestamp}]{scope}\n{raw_input}\n--------\n{tool_calls}{output}\n--------\n\n", + "# CHAT: {summary} [{now}]{scope}\n{raw_input}\n--------\n{tool_calls}{output}\n--------\n\n", ); file.write_all(output.as_bytes()) .with_context(|| "Failed to save message") @@ -2225,6 +2227,9 @@ impl Config { if let Some(v) = read_env_value::(&get_env_name("user_agent")) { self.user_agent = v; } + if let Some(Some(v)) = read_env_bool(&get_env_name("append_command_to_history_file")) { + self.append_command_to_history_file = v; + } } fn load_functions(&mut self) -> Result<()> { -- cgit v1.2.3