A monorepo management tool for the agentic ages

missing

+116
+85
lib/txn_log.ml
··· 1 + (** Transaction log for debugging unpac operations. 2 + 3 + Uses Unix I/O so it works both inside and outside Eio context. *) 4 + 5 + let log_file = ".unpac.log" 6 + 7 + let timestamp () = 8 + let t = Unix.gettimeofday () in 9 + let tm = Unix.localtime t in 10 + let ms = int_of_float ((t -. floor t) *. 1000.) in 11 + Printf.sprintf "%04d-%02d-%02d %02d:%02d:%02d.%03d" 12 + (tm.Unix.tm_year + 1900) 13 + (tm.Unix.tm_mon + 1) 14 + tm.Unix.tm_mday 15 + tm.Unix.tm_hour 16 + tm.Unix.tm_min 17 + tm.Unix.tm_sec 18 + ms 19 + 20 + let append lines = 21 + try 22 + let oc = open_out_gen [Open_append; Open_creat; Open_text] 0o644 log_file in 23 + List.iter (fun line -> output_string oc (line ^ "\n")) lines; 24 + close_out oc 25 + with _ -> 26 + (* Silently ignore logging failures - don't break the main operation *) 27 + () 28 + 29 + let separator = "----------------------------------------" 30 + 31 + let start_session ~args = 32 + let ts = timestamp () in 33 + let cmd = String.concat " " ("unpac" :: args) in 34 + let cwd = Sys.getcwd () in 35 + append [ 36 + ""; 37 + separator; 38 + Printf.sprintf "[%s] SESSION START" ts; 39 + Printf.sprintf "Command: %s" cmd; 40 + Printf.sprintf "CWD: %s" cwd; 41 + separator; 42 + ] 43 + 44 + let end_session ~exit_code = 45 + let ts = timestamp () in 46 + let status = if exit_code = 0 then "SUCCESS" else Printf.sprintf "FAILED (exit %d)" exit_code in 47 + append [ 48 + separator; 49 + Printf.sprintf "[%s] SESSION END: %s" ts status; 50 + separator; 51 + ] 52 + 53 + let log_git_command ~args ~exit_code ~stdout ~stderr = 54 + let ts = timestamp () in 55 + let cmd = String.concat " " ("git" :: args) in 56 + let status = if exit_code = 0 then "OK" else Printf.sprintf "FAILED (exit %d)" exit_code in 57 + let lines = [ 58 + Printf.sprintf "[%s] GIT: %s" ts cmd; 59 + Printf.sprintf " Status: %s" status; 60 + ] in 61 + let lines = 62 + if String.trim stdout <> "" then 63 + lines @ [ 64 + " --- stdout ---"; 65 + String.concat "\n" (List.map (fun l -> " " ^ l) (String.split_on_char '\n' (String.trim stdout))); 66 + ] 67 + else lines 68 + in 69 + let lines = 70 + if String.trim stderr <> "" then 71 + lines @ [ 72 + " --- stderr ---"; 73 + String.concat "\n" (List.map (fun l -> " " ^ l) (String.split_on_char '\n' (String.trim stderr))); 74 + ] 75 + else lines 76 + in 77 + append lines 78 + 79 + let log_message msg = 80 + let ts = timestamp () in 81 + append [Printf.sprintf "[%s] INFO: %s" ts msg] 82 + 83 + let log_error msg = 84 + let ts = timestamp () in 85 + append [Printf.sprintf "[%s] ERROR: %s" ts msg]
+31
lib/txn_log.mli
··· 1 + (** Transaction log for debugging unpac operations. 2 + 3 + Maintains a persistent .unpac.log file with a trace of all operations 4 + and git commands for debugging purposes. Uses Unix I/O so it works 5 + both inside and outside Eio context. *) 6 + 7 + (** {1 Session Management} *) 8 + 9 + val start_session : args:string list -> unit 10 + (** [start_session ~args] logs the start of an unpac session with the 11 + given command-line arguments. *) 12 + 13 + val end_session : exit_code:int -> unit 14 + (** [end_session ~exit_code] logs the end of the current session. *) 15 + 16 + (** {1 Command Logging} *) 17 + 18 + val log_git_command : 19 + args:string list -> 20 + exit_code:int -> 21 + stdout:string -> 22 + stderr:string -> 23 + unit 24 + (** [log_git_command ~args ~exit_code ~stdout ~stderr] logs a git 25 + command execution with its full output. *) 26 + 27 + val log_message : string -> unit 28 + (** [log_message msg] logs an informational message. *) 29 + 30 + val log_error : string -> unit 31 + (** [log_error msg] logs an error message. *)