summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-11-24 21:53:27 -0500
committerBen Sima <ben@bensima.com>2025-11-24 21:53:27 -0500
commitcd4df25878ad0908d10a01298a24a7ba002252b1 (patch)
tree38865185cf2bb4bc06f042a2b893e4836d369a50
parent6b9b5f5129dff789753df7d0c82939d3c219b29b (diff)
feat: implement t-1o2egbj8o0n.3
I have implemented the `jr work` command in `Omni/Jr.hs`. **Changes:** 1. **Modified `Omni/Jr.hs`**: * Added necessary imports (`Omni.Agent.Core`, `Omni.Agent.Worker`, `System.Directory`, `System.FilePath`, `Data.Text`). * Updated the Docopt usage to include `jr work [<task-id>]`. * Implemented the `work` command handler in the `move` function to initialize a `Worker` and call `Worker.start`, mirroring the logic in `Omni/Agent.hs`. * Added unit tests to verify parsing of the `work` command with and without a task ID. **Verification:** * Ran `bild --test Omni/Jr.hs` which passed, confirming the code compiles and tests pass. * Ran `lint Omni/Jr.hs` which passed. * Verified `_/bin/jr --help` shows the new command. I am now ready to exit.
-rw-r--r--Omni/Jr.hs40
1 files changed, 37 insertions, 3 deletions
diff --git a/Omni/Jr.hs b/Omni/Jr.hs
index b4b8941..db22fdc 100644
--- a/Omni/Jr.hs
+++ b/Omni/Jr.hs
@@ -7,11 +7,16 @@
module Omni.Jr where
import Alpha
+import qualified Data.Text as Text
+import qualified Omni.Agent.Core as AgentCore
+import qualified Omni.Agent.Worker as AgentWorker
import qualified Omni.Cli as Cli
import qualified Omni.Task as Task
import qualified Omni.Test as Test
import qualified System.Console.Docopt as Docopt
+import qualified System.Directory as Directory
import System.Environment (withArgs)
+import System.FilePath (takeFileName)
main :: IO ()
main = Cli.main plan
@@ -32,7 +37,7 @@ jr
Usage:
jr task [<args>...]
- jr work [<args>...]
+ jr work [<task-id>]
jr test
jr (-h | --help)
@@ -50,12 +55,41 @@ move args
let extraArgs = Cli.getAllArgs args (Cli.argument "args")
withArgs extraArgs Task.main
| args `Cli.has` Cli.command "work" = do
- putText "Work command not implemented yet"
+ -- Always run in current directory
+ let path = "."
+
+ -- Infer name from current directory
+ absPath <- Directory.getCurrentDirectory
+ let name = Text.pack (takeFileName absPath)
+
+ let worker =
+ AgentCore.Worker
+ { AgentCore.workerName = name,
+ AgentCore.workerPid = Nothing,
+ AgentCore.workerStatus = AgentCore.Idle,
+ AgentCore.workerPath = path
+ }
+
+ let taskId = fmap Text.pack (Cli.getArg args (Cli.argument "task-id"))
+
+ AgentWorker.start worker taskId
| otherwise = putText (str <| Docopt.usage help)
test :: Test.Tree
test =
Test.group
"Omni.Jr"
- [ Test.unit "can run tests" <| True Test.@?= True
+ [ Test.unit "can run tests" <| True Test.@?= True,
+ Test.unit "can parse work command" <| do
+ let result = Docopt.parseArgs help ["work"]
+ case result of
+ Left err -> Test.assertFailure <| "Failed to parse 'work': " <> show err
+ Right args -> args `Cli.has` Cli.command "work" Test.@?= True,
+ Test.unit "can parse work command with task id" <| do
+ let result = Docopt.parseArgs help ["work", "t-123"]
+ case result of
+ Left err -> Test.assertFailure <| "Failed to parse 'work t-123': " <> show err
+ Right args -> do
+ args `Cli.has` Cli.command "work" Test.@?= True
+ Cli.getArg args (Cli.argument "task-id") Test.@?= Just "t-123"
]