From 04986e2fc5c8863672c2a84e644777505878318b Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sun, 9 Nov 2025 07:37:25 -0500 Subject: Add enhanced dependency types to task manager Implement four dependency types based on beads patterns: - Blocks: Hard dependency, blocks ready work queue (default) - DiscoveredFrom: Work discovered during implementation (doesn't block) - ParentChild: Epic/task relationships (blocks ready work) - Related: Soft relationships (doesn't block) Key changes: - New Dependency data type with depId and depType fields - New DependencyType enum with four relationship types - Updated CLI with --dep-type and --discovered-from flags - Enhanced getReadyTasks to respect only blocking dependency types - Added comprehensive tests for all dependency behaviors - Updated AGENTS.md with usage examples and patterns The discovered-from pattern is especially important for AI agents to maintain context of work found during implementation while keeping it immediately available in the ready work queue. Amp-Thread-ID: https://ampcode.com/threads/T-178b273a-3ac7-416c-a964-db89bac3c8f7 Co-authored-by: Amp --- Omni/Task.hs | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'Omni/Task.hs') diff --git a/Omni/Task.hs b/Omni/Task.hs index 153f899..571c72e 100644 --- a/Omni/Task.hs +++ b/Omni/Task.hs @@ -33,7 +33,7 @@ task Usage: task init - task create [--type=<type>] [--parent=<id>] [--deps=<ids>] [--namespace=<ns>] + task create <title> [--type=<type>] [--parent=<id>] [--deps=<ids>] [--dep-type=<type>] [--discovered-from=<id>] [--namespace=<ns>] task list [--type=<type>] [--parent=<id>] task ready task update <id> <status> @@ -59,6 +59,8 @@ Options: --type=<type> Task type: epic or task (default: task) --parent=<id> Parent epic ID --deps=<ids> Comma-separated list of dependency IDs + --dep-type=<type> Dependency type: blocks, discovered-from, parent-child, related (default: blocks) + --discovered-from=<id> Shortcut for --deps=<id> --dep-type=discovered-from --namespace=<ns> Optional namespace (e.g., Omni/Task, Biz/Cloud) --flush Force immediate export -i <file> Input file for import @@ -83,9 +85,26 @@ move args 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) + + -- Handle --discovered-from as shortcut + (depIds, depType) <- case Cli.getArg args (Cli.longOption "discovered-from") of + Just discoveredId -> pure ([T.pack discoveredId], DiscoveredFrom) + Nothing -> do + -- Parse regular --deps and --dep-type + ids <- case Cli.getArg args (Cli.longOption "deps") of + Nothing -> pure [] + Just depStr -> pure <| T.splitOn "," (T.pack depStr) + dtype <- case Cli.getArg args (Cli.longOption "dep-type") of + Nothing -> pure Blocks + Just "blocks" -> pure Blocks + Just "discovered-from" -> pure DiscoveredFrom + Just "parent-child" -> pure ParentChild + Just "related" -> pure Related + Just other -> panic <| "Invalid dependency type: " <> T.pack other <> ". Use: blocks, discovered-from, parent-child, or related" + pure (ids, dtype) + + let deps = map (\did -> Dependency {depId = did, depType = depType}) depIds + namespace <- case Cli.getArg args (Cli.longOption "namespace") of Nothing -> pure Nothing Just ns -> do @@ -162,8 +181,25 @@ unitTests = not (null tasks) Test.@?= True, Test.unit "ready tasks exclude blocked ones" <| do task1 <- createTask "First task" WorkTask Nothing Nothing [] - task2 <- createTask "Blocked task" WorkTask Nothing Nothing [taskId task1] + let blockingDep = Dependency {depId = taskId task1, depType = Blocks} + task2 <- createTask "Blocked task" WorkTask Nothing Nothing [blockingDep] + ready <- getReadyTasks + (taskId task1 `elem` map taskId ready) Test.@?= True + (taskId task2 `notElem` map taskId ready) Test.@?= True, + Test.unit "discovered-from dependencies don't block" <| do + task1 <- createTask "Original task" WorkTask Nothing Nothing [] + let discDep = Dependency {depId = taskId task1, depType = DiscoveredFrom} + task2 <- createTask "Discovered work" WorkTask Nothing Nothing [discDep] + ready <- getReadyTasks + -- Both should be ready since DiscoveredFrom doesn't block + (taskId task1 `elem` map taskId ready) Test.@?= True + (taskId task2 `elem` map taskId ready) Test.@?= True, + Test.unit "related dependencies don't block" <| do + task1 <- createTask "Task A" WorkTask Nothing Nothing [] + let relDep = Dependency {depId = taskId task1, depType = Related} + task2 <- createTask "Task B" WorkTask Nothing Nothing [relDep] ready <- getReadyTasks + -- Both should be ready since Related doesn't block (taskId task1 `elem` map taskId ready) Test.@?= True - (taskId task2 `notElem` map taskId ready) Test.@?= True + (taskId task2 `elem` map taskId ready) Test.@?= True ] -- cgit v1.2.3