diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-26 07:54:57 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-26 07:54:57 -0500 |
| commit | 60c97ba9fac9eb9298b1b448ed5494765a33be39 (patch) | |
| tree | ff53762216cb038939659057ed4fe758dbf0c53e /Omni/Agent/Worker.hs | |
| parent | 30f6e16fe4fd3c9cbfcb39cd8053504ddd11167b (diff) | |
Use task title as commit subject, amp output as body
Fixes gitlint failures by using the pre-validated task title as the
commit subject line, while preserving amp's output in the body for
review context. Body lines are truncated to 72 chars for compliance.
Diffstat (limited to 'Omni/Agent/Worker.hs')
| -rw-r--r-- | Omni/Agent/Worker.hs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index f732436..3190bc7 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -69,7 +69,7 @@ processTask worker task = do _ <- runFormatters repo -- Try to commit (this runs git hooks which may fail) - let commitMsg = formatCommitMessage output tid + let commitMsg = formatCommitMessage task output AgentLog.updateActivity "Committing..." commitResult <- tryCommit repo commitMsg @@ -257,21 +257,15 @@ 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] -> cleanSubject subject <> "\n\nTask-Id: " <> taskId - (subject : rest) -> - let body = Text.strip (Text.unlines (dropWhile Text.null rest)) - in if Text.null body - then cleanSubject subject <> "\n\nTask-Id: " <> taskId - else cleanSubject subject <> "\n\n" <> body <> "\n\nTask-Id: " <> taskId +formatCommitMessage :: TaskCore.Task -> Text -> Text +formatCommitMessage task ampOutput = + let tid = TaskCore.taskId task + subject = cleanSubject (TaskCore.taskTitle task) + body = cleanBody ampOutput + in if Text.null body + then subject <> "\n\nTask-Id: " <> tid + else subject <> "\n\n" <> body <> "\n\nTask-Id: " <> tid where - -- Clean subject line for gitlint compliance: - -- - Remove trailing punctuation (.:!?) - -- - Truncate to 72 chars - -- - Capitalize first letter cleanSubject s = let stripped = Text.dropWhileEnd (`elem` ['.', ':', '!', '?', ' ']) s truncated = if Text.length stripped > 72 then Text.take 69 stripped <> "..." else stripped @@ -280,6 +274,13 @@ formatCommitMessage ampOutput taskId = Nothing -> truncated in capitalized + cleanBody :: Text -> Text + cleanBody output = + let stripped = Text.strip output + lns = Text.lines stripped + cleaned = map (Text.take 72) lns + in Text.intercalate "\n" cleaned + monitorLog :: FilePath -> Process.ProcessHandle -> IO () monitorLog path ph = do waitForFile path |
