@@ -18,7 +18,10 @@ pub struct AuditEntry {
1818 pub timestamp : u64 ,
1919 /// Session ID where the command was run.
2020 pub session_id : String ,
21- /// The command that was executed.
21+ /// The tool that was executed (e.g. "run", "write", "edit").
22+ #[ serde( default = "default_tool_name" ) ]
23+ pub tool_name : String ,
24+ /// The primary argument: shell command for "run", file path for "write"/"edit".
2225 pub command : String ,
2326 /// Exit code of the command (0 = success).
2427 pub exit_code : i32 ,
@@ -28,6 +31,10 @@ pub struct AuditEntry {
2831 pub duration_ms : u64 ,
2932}
3033
34+ fn default_tool_name ( ) -> String {
35+ "run" . to_string ( )
36+ }
37+
3138// ── Audit log path ──────────────────────────────────────────────────────────
3239
3340/// Get the default audit log path: ~/.local/share/tinyharness/audit.jsonl
@@ -50,6 +57,7 @@ pub fn ensure_audit_dir() -> std::io::Result<()> {
5057/// Append a command execution to the audit log.
5158pub fn log_command (
5259 session_id : & str ,
60+ tool_name : & str ,
5361 command : & str ,
5462 exit_code : i32 ,
5563 auto_accepted : bool ,
@@ -60,6 +68,7 @@ pub fn log_command(
6068 let entry = AuditEntry {
6169 timestamp : now_timestamp ( ) ,
6270 session_id : session_id. to_string ( ) ,
71+ tool_name : tool_name. to_string ( ) ,
6372 command : command. to_string ( ) ,
6473 exit_code,
6574 auto_accepted,
@@ -150,14 +159,15 @@ pub fn show_last(n: usize) {
150159
151160 // Header
152161 println ! (
153- " {}{:20} {:30 } {:6} {:8} {:10}{}" ,
154- BOLD , "Timestamp" , "Command" , "Exit" , "Auto?" , "Duration" , RESET
162+ " {}{:20} {:6} {:26 } {:6} {:8} {:10}{}" ,
163+ BOLD , "Timestamp" , "Tool" , " Command", "Exit" , "Auto?" , "Duration" , RESET
155164 ) ;
156165 println ! (
157- " {}{:20} {:30 } {:6} {:8} {:10}{}" ,
166+ " {}{:20} {:6} {:26 } {:6} {:8} {:10}{}" ,
158167 GRAY ,
159168 "────────────────────" ,
160- "──────────────────────────────" ,
169+ "──────" ,
170+ "──────────────────────────" ,
161171 "──────" ,
162172 "────────" ,
163173 "──────────" ,
@@ -166,8 +176,13 @@ pub fn show_last(n: usize) {
166176
167177 for entry in & entries {
168178 let ts_str = format_timestamp ( entry. timestamp ) ;
169- let cmd_display = if entry. command . len ( ) > 30 {
170- format ! ( "{}..." , & entry. command[ ..27 ] )
179+ let tool_display = if entry. tool_name . len ( ) > 6 {
180+ format ! ( "{}..." , & entry. tool_name[ ..3 ] )
181+ } else {
182+ entry. tool_name . clone ( )
183+ } ;
184+ let cmd_display = if entry. command . len ( ) > 26 {
185+ format ! ( "{}..." , & entry. command[ ..23 ] )
171186 } else {
172187 entry. command . clone ( )
173188 } ;
@@ -196,8 +211,8 @@ pub fn show_last(n: usize) {
196211 } ;
197212
198213 println ! (
199- " {}{} {} {} {} {}" ,
200- GRAY , ts_str, cmd_display, exit_str, auto_str, duration_str
214+ " {}{} {}{}{} {} {} {} {}" ,
215+ GRAY , ts_str, CYAN , tool_display , RESET , cmd_display, exit_str, auto_str, duration_str
201216 ) ;
202217 }
203218
@@ -220,14 +235,15 @@ pub fn show_session(session_id: &str) {
220235
221236 // Header
222237 println ! (
223- " {}{:20} {:30 } {:6} {:8} {:10}{}" ,
224- BOLD , "Timestamp" , "Command" , "Exit" , "Auto?" , "Duration" , RESET
238+ " {}{:20} {:6} {:26 } {:6} {:8} {:10}{}" ,
239+ BOLD , "Timestamp" , "Tool" , " Command", "Exit" , "Auto?" , "Duration" , RESET
225240 ) ;
226241 println ! (
227- " {}{:20} {:30 } {:6} {:8} {:10}{}" ,
242+ " {}{:20} {:6} {:26 } {:6} {:8} {:10}{}" ,
228243 GRAY ,
229244 "────────────────────" ,
230- "──────────────────────────────" ,
245+ "──────" ,
246+ "──────────────────────────" ,
231247 "──────" ,
232248 "────────" ,
233249 "──────────" ,
@@ -236,8 +252,13 @@ pub fn show_session(session_id: &str) {
236252
237253 for entry in & entries {
238254 let ts_str = format_timestamp ( entry. timestamp ) ;
239- let cmd_display = if entry. command . len ( ) > 30 {
240- format ! ( "{}..." , & entry. command[ ..27 ] )
255+ let tool_display = if entry. tool_name . len ( ) > 6 {
256+ format ! ( "{}..." , & entry. tool_name[ ..3 ] )
257+ } else {
258+ entry. tool_name . clone ( )
259+ } ;
260+ let cmd_display = if entry. command . len ( ) > 26 {
261+ format ! ( "{}..." , & entry. command[ ..23 ] )
241262 } else {
242263 entry. command . clone ( )
243264 } ;
@@ -266,8 +287,8 @@ pub fn show_session(session_id: &str) {
266287 } ;
267288
268289 println ! (
269- " {}{} {} {} {} {}" ,
270- GRAY , ts_str, cmd_display, exit_str, auto_str, duration_str
290+ " {}{} {}{}{} {} {} {} {}" ,
291+ GRAY , ts_str, CYAN , tool_display , RESET , cmd_display, exit_str, auto_str, duration_str
271292 ) ;
272293 }
273294
0 commit comments