summaryrefslogtreecommitdiff
path: root/Omni/Task
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-11-30 00:27:55 -0500
committerBen Sima <ben@bensima.com>2025-11-30 00:27:55 -0500
commitd05ca4732710dd9cef7fffd998a03615ad2cb58c (patch)
treef3a1259f49678b6b79c94fec1c1b8ede38af12a9 /Omni/Task
parentc4c5556c2906dbbdca0d884479b4fb67d032de07 (diff)
Add task complexity field and model selection
All tests pass. Let me summarize the changes made: - Added `taskComplexity :: Maybe Int` field to the `Task` data type (1-5 - Updated SQL schema to include `complexity INTEGER` column - Updated `FromRow` and `ToRow` instances to handle the new field - Updated `tasksColumns` migration spec for automatic schema migration - Updated `saveTask` to include complexity in SQL INSERT - Updated `createTask` signature to accept `Maybe Int` for complexity - Added `--complexity=<c>` option to the docopt help string - Added complexity parsing in `create` command (validates 1-5 range) - Added complexity parsing in `edit` command - Updated `modifyFn` in edit to handle complexity updates - Updated all unit tests to use new `createTask` signature with complexi - Added CLI tests for `--complexity` flag parsing - Added unit tests for complexity field storage and persistence - Updated `selectModel` to use `selectModelByComplexity` based on task c - Added `selectModelByComplexity :: Maybe Int -> Text` function with map - `Nothing` or 3-4 → `anthropic/claude-sonnet-4-20250514` (default) - 1-2 → `anthropic/claude-haiku` (trivial/low complexity) - 5 → `anthropic/claude-opus-4-20250514` (expert complexity) - Updated `createTask` calls to include `Nothing` for complexity Task-Id: t-141.5
Diffstat (limited to 'Omni/Task')
-rw-r--r--Omni/Task/Core.hs14
-rw-r--r--Omni/Task/RaceTest.hs4
2 files changed, 12 insertions, 6 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs
index 07c74fc..92936bb 100644
--- a/Omni/Task/Core.hs
+++ b/Omni/Task/Core.hs
@@ -35,6 +35,7 @@ data Task = Task
taskNamespace :: Maybe Text, -- Optional namespace (e.g., "Omni/Task", "Biz/Cloud")
taskStatus :: Status,
taskPriority :: Priority, -- Priority level (0-4)
+ taskComplexity :: Maybe Int, -- Complexity 1-5 for model selection
taskDependencies :: [Dependency], -- List of dependencies with types
taskDescription :: Text, -- Required description
taskComments :: [Comment], -- Timestamped comments for extra context
@@ -292,6 +293,7 @@ instance SQL.FromRow Task where
<*> SQL.field
<*> SQL.field
<*> SQL.field
+ <*> SQL.field -- complexity
<*> SQL.field
<*> (fromMaybe "" </ SQL.field) -- Handle NULL description from legacy data
<*> SQL.field -- comments
@@ -307,6 +309,7 @@ instance SQL.ToRow Task where
SQL.toField (taskNamespace t),
SQL.toField (taskStatus t),
SQL.toField (taskPriority t),
+ SQL.toField (taskComplexity t),
SQL.toField (taskDependencies t),
SQL.toField (taskDescription t),
SQL.toField (taskComments t),
@@ -444,6 +447,7 @@ initTaskDb = do
\ namespace TEXT, \
\ status TEXT NOT NULL, \
\ priority TEXT NOT NULL, \
+ \ complexity INTEGER, \
\ dependencies TEXT NOT NULL, \
\ description TEXT, \
\ comments TEXT NOT NULL DEFAULT '[]', \
@@ -531,6 +535,7 @@ tasksColumns =
("namespace", "TEXT"),
("status", "TEXT"),
("priority", "TEXT"),
+ ("complexity", "INTEGER"),
("dependencies", "TEXT"),
("description", "TEXT"),
("comments", "TEXT"),
@@ -639,13 +644,13 @@ saveTask task =
SQL.execute
conn
"INSERT OR REPLACE INTO tasks \
- \ (id, title, type, parent, namespace, status, priority, dependencies, description, comments, created_at, updated_at) \
- \ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
+ \ (id, title, type, parent, namespace, status, priority, complexity, dependencies, description, comments, created_at, updated_at) \
+ \ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
task
-- Create a new task
-createTask :: Text -> TaskType -> Maybe Text -> Maybe Text -> Priority -> [Dependency] -> Text -> IO Task
-createTask title taskType parent namespace priority deps description =
+createTask :: Text -> TaskType -> Maybe Text -> Maybe Text -> Priority -> Maybe Int -> [Dependency] -> Text -> IO Task
+createTask title taskType parent namespace priority complexity deps description =
withTaskLock <| do
let parent' = fmap normalizeId parent
deps' = map normalizeDependency deps
@@ -665,6 +670,7 @@ createTask title taskType parent namespace priority deps description =
taskNamespace = namespace,
taskStatus = Open,
taskPriority = priority,
+ taskComplexity = complexity,
taskDependencies = deps',
taskDescription = description,
taskComments = [],
diff --git a/Omni/Task/RaceTest.hs b/Omni/Task/RaceTest.hs
index 78410a4..8ab797a 100644
--- a/Omni/Task/RaceTest.hs
+++ b/Omni/Task/RaceTest.hs
@@ -28,7 +28,7 @@ raceTest =
initTaskDb
-- Create a parent epic
- parent <- createTask "Parent Epic" Epic Nothing Nothing P2 [] "Parent Epic description"
+ parent <- createTask "Parent Epic" Epic Nothing Nothing P2 Nothing [] "Parent Epic description"
let parentId = taskId parent
-- Create multiple children concurrently
@@ -39,7 +39,7 @@ raceTest =
-- Run concurrent creations
children <-
mapConcurrently
- (\i -> createTask ("Child " <> tshow i) WorkTask (Just parentId) Nothing P2 [] ("Child " <> tshow i <> " description"))
+ (\i -> createTask ("Child " <> tshow i) WorkTask (Just parentId) Nothing P2 Nothing [] ("Child " <> tshow i <> " description"))
indices
-- Check for duplicates in generated IDs