summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Omni/Agent/Worker.hs30
1 files changed, 20 insertions, 10 deletions
diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs
index d4809d2..e2c1635 100644
--- a/Omni/Agent/Worker.hs
+++ b/Omni/Agent/Worker.hs
@@ -76,7 +76,7 @@ processTask worker task = do
commitResult <- tryCommit repo commitMsg
case commitResult of
- Left commitErr -> do
+ CommitFailed commitErr -> do
AgentLog.log ("[worker] Commit failed: " <> commitErr)
-- Save failure context and reopen task for retry
@@ -98,8 +98,15 @@ processTask worker task = do
}
TaskCore.updateTaskStatus tid TaskCore.Open []
AgentLog.log ("[worker] Task reopened (attempt " <> tshow attempt <> "/3)")
- Right () -> do
- -- Only set to Review after successful commit
+ NoChanges -> do
+ -- No changes = task already implemented, mark as Done
+ AgentLog.log "[worker] No changes to commit - task already done"
+ TaskCore.clearRetryContext tid
+ TaskCore.updateTaskStatus tid TaskCore.Done []
+ AgentLog.log ("[worker] ✓ Task " <> tid <> " -> Done (no changes)")
+ AgentLog.update (\s -> s {AgentLog.statusTask = Nothing})
+ CommitSuccess -> do
+ -- Commit succeeded, set to Review
TaskCore.updateTaskStatus tid TaskCore.Review []
AgentLog.log ("[worker] ✓ Task " <> tid <> " -> Review")
AgentLog.update (\s -> s {AgentLog.statusTask = Nothing})
@@ -117,28 +124,31 @@ runFormatters repo = do
Exit.ExitSuccess -> pure (Right ())
Exit.ExitFailure _ -> pure (Right ()) -- lint --fix may exit non-zero but still fix things
--- | Try to commit, returning error message on failure
-tryCommit :: FilePath -> Text -> IO (Either Text ())
+data CommitResult = CommitSuccess | NoChanges | CommitFailed Text
+ deriving (Show, Eq)
+
+-- | Try to commit, returning result
+tryCommit :: FilePath -> Text -> IO CommitResult
tryCommit repo msg = do
-- Stage all changes
let addCmd = (Process.proc "git" ["add", "."]) {Process.cwd = Just repo}
(addCode, _, addErr) <- Process.readCreateProcessWithExitCode addCmd ""
case addCode of
- Exit.ExitFailure _ -> pure <| Left (Text.pack addErr)
+ Exit.ExitFailure _ -> pure <| CommitFailed (Text.pack addErr)
Exit.ExitSuccess -> do
-- Check for changes
let checkCmd = (Process.proc "git" ["diff", "--cached", "--quiet"]) {Process.cwd = Just repo}
(checkCode, _, _) <- Process.readCreateProcessWithExitCode checkCmd ""
case checkCode of
- Exit.ExitSuccess -> pure (Right ()) -- Nothing to commit
+ Exit.ExitSuccess -> pure NoChanges
Exit.ExitFailure 1 -> do
-- There are changes, commit them
let commitCmd = (Process.proc "git" ["commit", "-m", Text.unpack msg]) {Process.cwd = Just repo}
(commitCode, _, commitErr) <- Process.readCreateProcessWithExitCode commitCmd ""
case commitCode of
- Exit.ExitSuccess -> pure (Right ())
- Exit.ExitFailure _ -> pure <| Left (Text.pack commitErr)
- Exit.ExitFailure c -> pure <| Left ("git diff failed with code " <> tshow c)
+ Exit.ExitSuccess -> pure CommitSuccess
+ Exit.ExitFailure _ -> pure <| CommitFailed (Text.pack commitErr)
+ Exit.ExitFailure c -> pure <| CommitFailed ("git diff failed with code " <> tshow c)
runAmp :: FilePath -> TaskCore.Task -> IO (Exit.ExitCode, Text)
runAmp repo task = do