summaryrefslogtreecommitdiff
path: root/Omni
diff options
context:
space:
mode:
Diffstat (limited to 'Omni')
-rwxr-xr-xOmni/Jr.hs59
1 files changed, 59 insertions, 0 deletions
diff --git a/Omni/Jr.hs b/Omni/Jr.hs
index 714c5fb..d875b07 100755
--- a/Omni/Jr.hs
+++ b/Omni/Jr.hs
@@ -9,6 +9,7 @@
-- : dep servant-server
-- : dep lucid
-- : dep servant-lucid
+-- : run llm
module Omni.Jr where
import Alpha
@@ -423,6 +424,7 @@ autoReview tid task commitSha = do
TaskCore.clearRetryContext tid
TaskCore.updateTaskStatus tid TaskCore.Done []
putText ("[review] Task " <> tid <> " -> Done")
+ addCompletionSummary tid commitSha
extractFacts tid commitSha
checkEpicCompletion task
Exit.ExitFailure code -> do
@@ -503,6 +505,7 @@ interactiveReview tid task commitSha = do
TaskCore.clearRetryContext tid
TaskCore.updateTaskStatus tid TaskCore.Done []
putText ("Task " <> tid <> " marked as Done.")
+ addCompletionSummary tid commitSha
extractFacts tid commitSha
checkEpicCompletion task
| "r" `Text.isPrefixOf` c -> do
@@ -583,6 +586,62 @@ extractConflictFile line =
| not (Text.null rest) -> Just (Text.strip (Text.drop 3 rest))
_ -> Nothing
+-- | Generate and add a completion summary comment for a task
+addCompletionSummary :: Text -> String -> IO ()
+addCompletionSummary tid commitSha = do
+ -- Get the diff and commit message for this commit
+ (diffCode, diffOut, _) <- Process.readProcessWithExitCode "git" ["show", "--stat", commitSha] ""
+ (msgCode, msgOut, _) <- Process.readProcessWithExitCode "git" ["log", "-1", "--format=%B", commitSha] ""
+
+ when (diffCode == Exit.ExitSuccess && msgCode == Exit.ExitSuccess) <| do
+ -- Get list of modified files
+ (filesCode, filesOut, _) <- Process.readProcessWithExitCode "git" ["diff-tree", "--no-commit-id", "--name-only", "-r", commitSha] ""
+
+ let files = if filesCode == Exit.ExitSuccess then List.lines filesOut else []
+ commitMessage = Text.pack msgOut
+ diffSummary = Text.pack diffOut
+
+ -- Build prompt for llm
+ let prompt = buildCompletionPrompt tid commitMessage diffSummary files
+
+ -- Call llm CLI to generate summary
+ (llmCode, llmOut, llmErr) <- Process.readProcessWithExitCode "llm" [] (Text.unpack prompt)
+
+ case llmCode of
+ Exit.ExitSuccess -> do
+ let summary = Text.strip (Text.pack llmOut)
+ unless (Text.null summary) <| do
+ _ <- TaskCore.addComment tid ("## Completion Summary\n\n" <> summary)
+ putText "[review] Added completion summary comment"
+ Exit.ExitFailure _ -> do
+ putText ("[review] Failed to generate completion summary: " <> Text.pack llmErr)
+
+-- | Build prompt for LLM to generate completion summary
+buildCompletionPrompt :: Text -> Text -> Text -> [String] -> Text
+buildCompletionPrompt tid commitMessage diffSummary files =
+ Text.unlines
+ [ "Generate a concise completion summary for this task. The summary should be 2-4 sentences.",
+ "",
+ "Task ID: " <> tid,
+ "",
+ "Commit Message:",
+ commitMessage,
+ "",
+ "Files Modified (" <> tshow (length files) <> "):",
+ Text.unlines (map Text.pack (take 10 files)),
+ if length files > 10 then "... and " <> tshow (length files - 10) <> " more files" else "",
+ "",
+ "Diff Summary:",
+ diffSummary,
+ "",
+ "Write a brief summary that includes:",
+ "- What was accomplished (from the commit message and changes)",
+ "- Key files that were modified (mention 2-3 most important ones)",
+ "",
+ "Keep it professional and concise. Do NOT include markdown headers or formatting.",
+ "Just return the plain summary text."
+ ]
+
-- | Extract facts from completed task
extractFacts :: Text -> String -> IO ()
extractFacts tid commitSha = do