← Back to task

Commit 2e4bfbff

commit 2e4bfbffba747efcee6c5de25f8a5325b36859c4
Author: Ben Sima <ben@bensima.com>
Date:   Tue Nov 25 23:09:03 2025

    worker: format commit messages for gitlint compliance
    
    Split amp output into subject/body with blank line separator.
    
    Task-Id: t-1jbp4l5o Amp-Thread-ID:
    https://ampcode.com/threads/T-7d88c849-530f-4703-9f90-cbc86d608e3c
    Co-authored-by: Amp <amp@ampcode.com>

diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs
index eec0cf78..89800e41 100644
--- a/Omni/Agent/Worker.hs
+++ b/Omni/Agent/Worker.hs
@@ -69,7 +69,7 @@ processTask worker task = do
       TaskCore.updateTaskStatus tid TaskCore.Review []
 
       -- Commit changes using Amp output (Gerrit-style trailer)
-      let commitMsg = Text.strip output <> "\n\nTask-Id: " <> tid
+      let commitMsg = formatCommitMessage output tid
       Git.commit repo commitMsg
 
       -- Submit for review
@@ -167,6 +167,17 @@ formatTask t =
   where
     formatDep dep = "  - " <> TaskCore.depId dep <> " [" <> Text.pack (show (TaskCore.depType dep)) <> "]"
 
+formatCommitMessage :: Text -> Text -> Text
+formatCommitMessage ampOutput taskId =
+  case Text.lines (Text.strip ampOutput) of
+    [] -> "Task completed\n\nTask-Id: " <> taskId
+    [subject] -> subject <> "\n\nTask-Id: " <> taskId
+    (subject : rest) ->
+      let body = Text.strip (Text.unlines (dropWhile Text.null rest))
+       in if Text.null body
+            then subject <> "\n\nTask-Id: " <> taskId
+            else subject <> "\n\n" <> body <> "\n\nTask-Id: " <> taskId
+
 monitorLog :: FilePath -> Process.ProcessHandle -> IO ()
 monitorLog path ph = do
   waitForFile path