summaryrefslogtreecommitdiff
path: root/Omni
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-11-08 16:32:23 -0500
committerBen Sima <ben@bsima.me>2025-11-08 16:32:23 -0500
commit305cd3d5077c7e6e2a512b77ac95435081e3e825 (patch)
tree19c5447d52c8b6173a0b88a409f8bf71c61d415f /Omni
parent6a4afe929749e0f5682c4527a68d2a016f6a5ac2 (diff)
Add optional namespace field to tasks
Tasks can now be associated with specific namespaces in the monorepo: - Added taskNamespace (Maybe Text) field to Task data type - Updated createTask to accept optional namespace parameter - Added --namespace CLI option to task create command - Display namespace in task list output (e.g., [Omni/Task]) - Updated tests to pass Nothing for namespace - Updated AGENTS.md documentation Example usage: task create "Fix bug" project --namespace="Omni/Task" Completed task: t-j0k1L2 Amp-Thread-ID: https://ampcode.com/threads/T-85f4ee29-a529-4f59-ac6f-6ffec75b6a56 Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Omni')
-rw-r--r--Omni/Task.hs14
-rw-r--r--Omni/Task/Core.hs11
2 files changed, 18 insertions, 7 deletions
diff --git a/Omni/Task.hs b/Omni/Task.hs
index be54d3d..808e73f 100644
--- a/Omni/Task.hs
+++ b/Omni/Task.hs
@@ -32,7 +32,7 @@ task
Usage:
task init
- task create <title> <project> [--deps=<ids>]
+ task create <title> <project> [--deps=<ids>] [--namespace=<ns>]
task list [--project=<project>]
task ready
task update <id> <status>
@@ -57,6 +57,7 @@ Options:
-h --help Show this help
--project=<project> Filter by project
--deps=<ids> Comma-separated list of dependency IDs
+ --namespace=<ns> Optional namespace (e.g., Omni/Task, Biz/Cloud)
--flush Force immediate export
-i <file> Input file for import
@@ -77,7 +78,10 @@ move args
deps <- case Cli.getArg args (Cli.longOption "deps") of
Nothing -> pure []
Just depStr -> pure <| T.splitOn "," (T.pack depStr)
- task <- createTask title project deps
+ namespace <- case Cli.getArg args (Cli.longOption "namespace") of
+ Nothing -> pure Nothing
+ Just ns -> pure <| Just (T.pack ns)
+ task <- createTask title project namespace deps
putStrLn <| "Created task: " <> T.unpack (taskId task)
| args `Cli.has` Cli.command "list" = do
maybeProject <- case Cli.getArg args (Cli.longOption "project") of
@@ -131,7 +135,7 @@ unitTests =
when exists <| removeFile ".tasks/tasks.jsonl"
initTaskDb
- task <- createTask "Test task" "test-project" []
+ task <- createTask "Test task" "test-project" Nothing []
taskTitle task Test.@?= "Test task"
taskProject task Test.@?= "test-project"
taskStatus task Test.@?= Open
@@ -140,8 +144,8 @@ unitTests =
tasks <- listTasks Nothing
not (null tasks) Test.@?= True,
Test.unit "ready tasks exclude blocked ones" <| do
- task1 <- createTask "First task" "test" []
- task2 <- createTask "Blocked task" "test" [taskId task1]
+ task1 <- createTask "First task" "test" Nothing []
+ task2 <- createTask "Blocked task" "test" Nothing [taskId task1]
ready <- getReadyTasks
(taskId task1 `elem` map taskId ready) Test.@?= True
(taskId task2 `notElem` map taskId ready) Test.@?= True
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs
index f49a8d2..f67c076 100644
--- a/Omni/Task/Core.hs
+++ b/Omni/Task/Core.hs
@@ -18,6 +18,7 @@ data Task = Task
{ taskId :: Text,
taskTitle :: Text,
taskProject :: Text,
+ taskNamespace :: Maybe Text, -- Optional namespace (e.g., "Omni/Task", "Biz/Cloud")
taskStatus :: Status,
taskDependencies :: [Text], -- List of task IDs this depends on
taskCreatedAt :: UTCTime,
@@ -95,8 +96,8 @@ saveTask task = do
BLC.appendFile ".tasks/tasks.jsonl" (json <> "\n")
-- Create a new task
-createTask :: Text -> Text -> [Text] -> IO Task
-createTask title project deps = do
+createTask :: Text -> Text -> Maybe Text -> [Text] -> IO Task
+createTask title project namespace deps = do
tid <- generateId
now <- getCurrentTime
let task =
@@ -104,6 +105,7 @@ createTask title project deps = do
{ taskId = tid,
taskTitle = title,
taskProject = project,
+ taskNamespace = namespace,
taskStatus = Open,
taskDependencies = deps,
taskCreatedAt = now,
@@ -169,6 +171,11 @@ printTask t =
<> " ("
<> taskProject t
<> ")"
+ <> namespaceInfo
+ where
+ namespaceInfo = case taskNamespace t of
+ Nothing -> ""
+ Just ns -> " [" <> ns <> "]"
-- Export tasks: Consolidate JSONL file (remove duplicates, keep latest version)
exportTasks :: IO ()