From 1d98b463ac79905b542d45d632e5135ea90af585 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sun, 9 Nov 2025 07:18:18 -0500 Subject: Implement epic and task types to replace project field Major refactoring of task data model: - Added TaskType enum (Epic | WorkTask) - Replaced taskProject with taskType and taskParent fields - Epics are containers for tasks (hierarchical organization) - Tasks can have optional parent epics - Updated createTask signature to accept type and parent - Updated CLI: --type=epic|task and --parent= options - Updated list command to filter by type and parent - Updated printTask to display type and parent info - Fixed naming collision (WorkTask instead of Task constructor) Example usage: task create "Auth System" --type=epic task create "Design API" --type=task --parent=t-abc123 task list --type=epic task list --parent=t-abc123 Completed task: t-8WR5Zg Amp-Thread-ID: https://ampcode.com/threads/T-85f4ee29-a529-4f59-ac6f-6ffec75b6a56 Co-authored-by: Amp --- Omni/Task.hs | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'Omni/Task.hs') diff --git a/Omni/Task.hs b/Omni/Task.hs index 2f3ec6f..153f899 100644 --- a/Omni/Task.hs +++ b/Omni/Task.hs @@ -33,8 +33,8 @@ task Usage: task init - task create <project> [--deps=<ids>] [--namespace=<ns>] - task list [--project=<project>] + task create <title> [--type=<type>] [--parent=<id>] [--deps=<ids>] [--namespace=<ns>] + task list [--type=<type>] [--parent=<id>] task ready task update <id> <status> task deps <id> @@ -45,7 +45,7 @@ Usage: Commands: init Initialize task database - create Create a new task + create Create a new task or epic list List all tasks ready Show ready tasks (not blocked) update Update task status @@ -56,7 +56,8 @@ Commands: Options: -h --help Show this help - --project=<project> Filter by project + --type=<type> Task type: epic or task (default: task) + --parent=<id> Parent epic ID --deps=<ids> Comma-separated list of dependency IDs --namespace=<ns> Optional namespace (e.g., Omni/Task, Biz/Cloud) --flush Force immediate export @@ -64,7 +65,6 @@ Options: Arguments: <title> Task title - <project> Project name <id> Task ID <status> Task status (open, in-progress, done) <file> JSONL file to import @@ -75,7 +75,14 @@ move args | args `Cli.has` Cli.command "init" = initTaskDb | args `Cli.has` Cli.command "create" = do title <- getArgText args "title" - project <- getArgText args "project" + taskType <- case Cli.getArg args (Cli.longOption "type") of + Nothing -> pure WorkTask + Just "epic" -> pure Epic + Just "task" -> pure WorkTask + Just other -> panic <| "Invalid task type: " <> T.pack other <> ". Use: epic or task" + parent <- case Cli.getArg args (Cli.longOption "parent") of + Nothing -> pure Nothing + Just p -> pure <| Just (T.pack p) deps <- case Cli.getArg args (Cli.longOption "deps") of Nothing -> pure [] Just depStr -> pure <| T.splitOn "," (T.pack depStr) @@ -86,13 +93,18 @@ move args let validNs = Namespace.fromHaskellModule ns nsPath = T.pack <| Namespace.toPath validNs pure <| Just nsPath - task <- createTask title project namespace deps - putStrLn <| "Created task: " <> T.unpack (taskId task) + createdTask <- createTask title taskType parent namespace deps + putStrLn <| "Created task: " <> T.unpack (taskId createdTask) | args `Cli.has` Cli.command "list" = do - maybeProject <- case Cli.getArg args (Cli.longOption "project") of + maybeType <- case Cli.getArg args (Cli.longOption "type") of + Nothing -> pure Nothing + Just "epic" -> pure <| Just Epic + Just "task" -> pure <| Just WorkTask + Just other -> panic <| "Invalid task type: " <> T.pack other + maybeParent <- case Cli.getArg args (Cli.longOption "parent") of Nothing -> pure Nothing Just p -> pure <| Just (T.pack p) - tasks <- listTasks maybeProject + tasks <- listTasks maybeType maybeParent traverse_ printTask tasks | args `Cli.has` Cli.command "ready" = do tasks <- getReadyTasks @@ -140,17 +152,17 @@ unitTests = when exists <| removeFile ".tasks/tasks.jsonl" initTaskDb - task <- createTask "Test task" "test-project" Nothing [] + task <- createTask "Test task" WorkTask Nothing Nothing [] taskTitle task Test.@?= "Test task" - taskProject task Test.@?= "test-project" + taskType task Test.@?= WorkTask taskStatus task Test.@?= Open null (taskDependencies task) Test.@?= True, Test.unit "can list tasks" <| do - tasks <- listTasks Nothing + tasks <- listTasks Nothing Nothing not (null tasks) Test.@?= True, Test.unit "ready tasks exclude blocked ones" <| do - task1 <- createTask "First task" "test" Nothing [] - task2 <- createTask "Blocked task" "test" Nothing [taskId task1] + task1 <- createTask "First task" WorkTask Nothing Nothing [] + task2 <- createTask "Blocked task" WorkTask Nothing Nothing [taskId task1] ready <- getReadyTasks (taskId task1 `elem` map taskId ready) Test.@?= True (taskId task2 `notElem` map taskId ready) Test.@?= True -- cgit v1.2.3