commit 3bb2c291840b798664f7aa9228855db30ba603fc
Author: Ben Sima <ben@bensima.com>
Date: Tue Dec 30 19:34:31 2025
Omni/Task: Use shared database at /var/lib/omni/tasks.db
- Change default DB path from ~/.local/share/jr/jr.db to /var/lib/omni/tasks.db
- Update pi-*.sh scripts to find task binary in repo or PATH
- Enables both ben and ava users to share task database
Task-Id: t-294
diff --git a/Omni/Ide/pi-code.sh b/Omni/Ide/pi-code.sh
index ac22595e..a85db697 100755
--- a/Omni/Ide/pi-code.sh
+++ b/Omni/Ide/pi-code.sh
@@ -72,12 +72,24 @@ if [ -z "$TASK_ID" ]; then
exit 1
fi
+# Find task binary
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
+if [ -x "$REPO_ROOT/_/bin/task" ]; then
+ TASK_CMD="$REPO_ROOT/_/bin/task"
+elif command -v task &> /dev/null; then
+ TASK_CMD="task"
+else
+ error "task binary not found. Run 'bild Omni/Task.hs' first."
+ exit 1
+fi
+
# Claim task
status "Claiming task ${BOLD}$TASK_ID${NC}..."
-task update "$TASK_ID" in-progress --json > /dev/null
+$TASK_CMD update "$TASK_ID" in-progress --json > /dev/null
# Get task context
-TASK_JSON=$(task show "$TASK_ID" --json)
+TASK_JSON=$($TASK_CMD show "$TASK_ID" --json)
TITLE=$(echo "$TASK_JSON" | jq -r '.taskTitle')
DESC=$(echo "$TASK_JSON" | jq -r '.taskDescription')
NAMESPACE=$(echo "$TASK_JSON" | jq -r '.taskNamespace // empty')
diff --git a/Omni/Ide/pi-orchestrate.sh b/Omni/Ide/pi-orchestrate.sh
index 5ad8b96d..e1cfbd8c 100755
--- a/Omni/Ide/pi-orchestrate.sh
+++ b/Omni/Ide/pi-orchestrate.sh
@@ -107,6 +107,17 @@ fi
# Get script directory for calling sibling scripts
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
+
+# Find task binary - check repo's _/bin first, then PATH
+if [ -x "$REPO_ROOT/_/bin/task" ]; then
+ TASK_CMD="$REPO_ROOT/_/bin/task"
+elif command -v task &> /dev/null; then
+ TASK_CMD="task"
+else
+ error "task binary not found. Run 'bild Omni/Task.hs' first."
+ exit 1
+fi
# Build review args
REVIEW_ARGS=""
@@ -145,7 +156,7 @@ while [ $ITERATION -le "$MAX_ITERATIONS" ]; do
# Step 3: Check task status
echo ""
status "Checking task status..."
- TASK_JSON=$(task show "$TASK_ID" --json)
+ TASK_JSON=$($TASK_CMD show "$TASK_ID" --json)
STATUS=$(echo "$TASK_JSON" | jq -r '.taskStatus')
case "$STATUS" in
diff --git a/Omni/Ide/pi-review.sh b/Omni/Ide/pi-review.sh
index a26629d4..abc0ae31 100755
--- a/Omni/Ide/pi-review.sh
+++ b/Omni/Ide/pi-review.sh
@@ -88,6 +88,18 @@ if [ -z "$TASK_ID" ]; then
exit 1
fi
+# Find task binary
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
+if [ -x "$REPO_ROOT/_/bin/task" ]; then
+ TASK_CMD="$REPO_ROOT/_/bin/task"
+elif command -v task &> /dev/null; then
+ TASK_CMD="task"
+else
+ echo "Error: task binary not found. Run 'bild Omni/Task.hs' first."
+ exit 1
+fi
+
if [ "$DRY_RUN" = true ]; then
echo "========================================"
echo "=== DRY RUN MODE - No changes will be made ==="
@@ -103,7 +115,7 @@ if git diff --quiet && git diff --cached --quiet && [ -z "$UNTRACKED" ]; then
fi
# Get task context
-TASK_JSON=$(task show "$TASK_ID" --json)
+TASK_JSON=$($TASK_CMD show "$TASK_ID" --json)
TITLE=$(echo "$TASK_JSON" | jq -r '.taskTitle')
DESC=$(echo "$TASK_JSON" | jq -r '.taskDescription')
NAMESPACE=$(echo "$TASK_JSON" | jq -r '.taskNamespace // empty')
@@ -285,17 +297,17 @@ if [ "$DRY_RUN" = true ]; then
fi
echo "Would: git add -A"
echo "Would: git commit -m \"$SUBJECT\" -m \"Automated via pi-review.\" --trailer \"Task-Id: $TASK_ID\""
- echo "Would: task update $TASK_ID done"
+ echo "Would: $TASK_CMD update $TASK_ID done"
;;
REJECT)
FEEDBACK=$(echo "$REVIEW_OUTPUT" | sed '/^VERDICT:/d')
echo "Would: git checkout -- ."
echo "Would: git clean -fd"
- echo "Would: task comment $TASK_ID \"REJECTED: ...\""
- echo "Would: task update $TASK_ID needs-help"
+ echo "Would: $TASK_CMD comment $TASK_ID \"REJECTED: ...\""
+ echo "Would: $TASK_CMD update $TASK_ID needs-help"
;;
REQUEST_CHANGES)
- echo "Would: task comment $TASK_ID \"CHANGES REQUESTED: ...\""
+ echo "Would: $TASK_CMD comment $TASK_ID \"CHANGES REQUESTED: ...\""
;;
*)
echo "Error: Could not parse verdict from reviewer output."
@@ -319,7 +331,7 @@ case "$VERDICT" in
fi
git commit -m "$SUBJECT" -m "Automated via pi-review." --trailer "Task-Id: $TASK_ID"
git push origin HEAD
- task update "$TASK_ID" "done" --json > /dev/null
+ $TASK_CMD update "$TASK_ID" "done" --json > /dev/null
echo "Task $TASK_ID marked as done."
;;
@@ -329,8 +341,8 @@ case "$VERDICT" in
FEEDBACK=$(echo "$REVIEW_OUTPUT" | sed '/^VERDICT:/d')
git checkout -- .
git clean -fd
- task comment "$TASK_ID" "REJECTED: $FEEDBACK" --json > /dev/null
- task update "$TASK_ID" needs-help --json > /dev/null
+ $TASK_CMD comment "$TASK_ID" "REJECTED: $FEEDBACK" --json > /dev/null
+ $TASK_CMD update "$TASK_ID" needs-help --json > /dev/null
echo "Task $TASK_ID marked as needs-help with feedback."
;;
@@ -338,7 +350,7 @@ case "$VERDICT" in
echo "Changes requested. Keeping changes for retry..."
# Extract feedback (everything before the verdict)
FEEDBACK=$(echo "$REVIEW_OUTPUT" | sed '/^VERDICT:/d')
- task comment "$TASK_ID" "CHANGES REQUESTED: $FEEDBACK" --json > /dev/null
+ $TASK_CMD comment "$TASK_ID" "CHANGES REQUESTED: $FEEDBACK" --json > /dev/null
echo "Feedback added to task $TASK_ID. Coder can retry."
;;
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs
index 0a1187f4..a9ecfa4e 100644
--- a/Omni/Task/Core.hs
+++ b/Omni/Task/Core.hs
@@ -21,9 +21,9 @@ import qualified Database.SQLite.Simple.FromField as SQL
import qualified Database.SQLite.Simple.Ok as SQLOk
import qualified Database.SQLite.Simple.ToField as SQL
import GHC.Generics ()
-import System.Directory (XdgDirectory (..), createDirectoryIfMissing, doesFileExist, getXdgDirectory)
+import System.Directory (createDirectoryIfMissing, doesFileExist)
import System.Environment (lookupEnv)
-import System.FilePath (takeDirectory, (</>))
+import System.FilePath (takeDirectory)
import System.IO.Unsafe (unsafePerformIO)
import Web.HttpApiData (FromHttpApiData (..))
@@ -429,9 +429,8 @@ getTasksDbPath = do
case (testMode, customPath) of
(Just "1", _) -> pure "_/tmp/tasks-test.db"
(_, Just p) -> pure p
- _ -> do
- xdgData <- getXdgDirectory XdgData "jr"
- pure (xdgData </> "jr.db")
+ -- Default to shared location accessible by both ben and ava users
+ _ -> pure "/var/lib/omni/tasks.db"
-- DB Helper
withDb :: (SQL.Connection -> IO a) -> IO a