summaryrefslogtreecommitdiff
path: root/Omni/Agent/harvest-tasks.sh
diff options
context:
space:
mode:
Diffstat (limited to 'Omni/Agent/harvest-tasks.sh')
-rwxr-xr-xOmni/Agent/harvest-tasks.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/Omni/Agent/harvest-tasks.sh b/Omni/Agent/harvest-tasks.sh
new file mode 100755
index 0000000..282beab
--- /dev/null
+++ b/Omni/Agent/harvest-tasks.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+set -e
+
+# Omni/Agent/harvest-tasks.sh
+# Imports task updates from all worker branches into the current branch (usually live).
+
+REPO_ROOT="$(git rev-parse --show-toplevel)"
+cd "$REPO_ROOT"
+
+echo "Harvesting task updates from workers..."
+
+# Find all worker branches (assuming naming convention omni-worker-*)
+# We filter for local branches
+WORKER_BRANCHES=$(git branch --list "omni-worker-*" --format="%(refname:short)")
+
+if [ -z "$WORKER_BRANCHES" ]; then
+ echo "No worker branches found."
+ exit 0
+fi
+
+UPDATED=0
+
+for branch in $WORKER_BRANCHES; do
+ echo "Checking $branch..."
+
+ # Extract tasks.jsonl from the worker branch
+ if git show "$branch:.tasks/tasks.jsonl" > .tasks/worker-tasks.jsonl 2>/dev/null; then
+ # Import into current DB
+ # The import command handles deduplication and timestamp conflict resolution
+ if "$REPO_ROOT/_/bin/task" import -i .tasks/worker-tasks.jsonl >/dev/null; then
+ echo " Imported tasks from $branch"
+ UPDATED=1
+ fi
+ else
+ echo " Warning: Could not read .tasks/tasks.jsonl from $branch"
+ fi
+done
+
+rm -f .tasks/worker-tasks.jsonl
+
+if [ "$UPDATED" -eq 1 ]; then
+ # Consolidate
+ "$REPO_ROOT/_/bin/task" export --flush
+
+ # Commit if there are changes
+ if [[ -n $(git status --porcelain .tasks/tasks.jsonl) ]]; then
+ git add .tasks/tasks.jsonl
+ git commit -m "task: harvest updates from workers"
+ echo "Success: Task database updated and committed."
+ else
+ echo "No effective changes found."
+ fi
+else
+ echo "No updates found."
+fi