diff options
| -rw-r--r-- | Omni/Agent.hs | 25 | ||||
| -rw-r--r-- | Omni/Agent/Worker.hs | 16 |
2 files changed, 33 insertions, 8 deletions
diff --git a/Omni/Agent.hs b/Omni/Agent.hs index b7381b8..15ff77d 100644 --- a/Omni/Agent.hs +++ b/Omni/Agent.hs @@ -4,6 +4,7 @@ {-# LANGUAGE NoImplicitPrelude #-} -- : out agent +-- : dep sqlite-simple -- : dep temporary module Omni.Agent where @@ -100,11 +101,29 @@ harvest args = do when updated <| do -- Consolidate Directory.setCurrentDirectory path - TaskCore.exportTasks + -- Export to temporary file then commit? No, harvest implies we are merging back to source of truth. + -- But wait, tasks are now in SQLite. + -- If we are harvesting from branches, we are importing from JSONL in branches into our DB. + -- Then we probably want to export back to JSONL for git tracking? + -- The user said: "Remove git-tracked tasks.jsonl". + -- So harvest might need rethinking or just be disabled for now. + -- But strictly answering the compilation error: exportTasks takes an argument now. + -- Since we removed tasks.jsonl, maybe we shouldn't be exporting here at all if the goal is to just update the DB? + -- However, if harvest is about syncing multiple workers, it assumes a shared git repo. + -- If we removed git tracking of tasks, harvest via git branches makes less sense unless we still use JSONL for interchange. + -- For now, let's pass Nothing to exportTasks (stdout) which is probably not what we want, OR + -- if we want to save to DB, we don't need to call exportTasks because importTasks already updates the DB. + -- Let's remove the exportTasks call here as it seems redundant or incorrect given we removed the file. + -- But wait, if 'harvest' commits "task: harvest updates...", what is it committing? + -- The SQLite DB is likely .gitignore'd. + -- So harvest effectively does nothing useful for git if tasks are not in git. + -- I will comment out the commit and export for now to fix the build, assuming 'harvest' is legacy/deprecated with the removal of git-tracked tasks. + + -- TaskCore.exportTasks Nothing -- Commit if changed - Git.commit path "task: harvest updates from workers" - putText "Success: Task database updated and committed." + -- Git.commit path "task: harvest updates from workers" + putText "Success: Task database updated." processBranch :: FilePath -> Bool -> Text -> IO Bool processBranch repo updated branch = do 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 = |
