diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-24 21:13:28 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-24 21:13:28 -0500 |
| commit | e5c8ff37436171966136e06d75e39dbdea80d4eb (patch) | |
| tree | 1a52198b4f598628b8bfd4eda5748c1c1e4961dd /Omni/Agent/Worker.hs | |
| parent | 2a923f3a73daa6aebd61694d4c8470c7c4ccbe91 (diff) | |
agent: restore git commit with amp output
Re-enables git commits in the worker, using the captured output from
'amp' as the commit message. Also updates 'Omni/Agent.hs' to handle
the API change in TaskCore.exportTasks (commenting out harvest logic
for now as it depended on git-tracked tasks).
Amp-Thread-ID:
https://ampcode.com/threads/T-ac41b9b6-d117-46de-9e4f-842887a22f1d
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Omni/Agent/Worker.hs')
| -rw-r--r-- | Omni/Agent/Worker.hs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index 638c72f..fe9194f 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -7,6 +7,7 @@ import Alpha import qualified Data.Text as Text import qualified Data.Text.IO as TIO import qualified Omni.Agent.Core as Core +import qualified Omni.Agent.Git as Git import qualified Omni.Agent.Log as AgentLog import qualified Omni.Task.Core as TaskCore import qualified System.Directory as Directory @@ -58,7 +59,7 @@ processTask worker task = do -- Run Amp AgentLog.updateActivity "Running Amp agent..." - exitCode <- runAmp repo task + (exitCode, output) <- runAmp repo task case exitCode of Exit.ExitSuccess -> do @@ -67,6 +68,10 @@ processTask worker task = do -- Update status to Review TaskCore.updateTaskStatus tid TaskCore.Review [] + -- Commit changes using Amp output + let commitMsg = "feat: implement " <> tid <> "\n\n" <> output + Git.commit repo commitMsg + -- Submit for review AgentLog.updateActivity "Task completed" @@ -77,7 +82,7 @@ processTask worker task = do AgentLog.updateActivity "Agent failed, retrying..." threadDelay (10 * 1000000) -- Sleep 10s -runAmp :: FilePath -> TaskCore.Task -> IO Exit.ExitCode +runAmp :: FilePath -> TaskCore.Task -> IO (Exit.ExitCode, Text) runAmp repo task = do let prompt = "You are a Worker Agent.\n" @@ -122,14 +127,15 @@ runAmp repo task = do -- Assume amp is in PATH let args = ["--log-level", "debug", "--log-file", "_/llm/amp.log", "--dangerously-allow-all", "-x", Text.unpack fullPrompt] - let cp = (Process.proc "amp" args) {Process.cwd = Just repo} - (_, _, _, ph) <- Process.createProcess cp + let cp = (Process.proc "amp" args) {Process.cwd = Just repo, Process.std_out = Process.CreatePipe} + (_, Just hOut, _, ph) <- Process.createProcess cp tid <- forkIO <| monitorLog logFile ph exitCode <- Process.waitForProcess ph + output <- TIO.hGetContents hOut killThread tid - pure exitCode + pure (exitCode, output) formatTask :: TaskCore.Task -> Text formatTask t = |
