From 796e1fe4547a5b9187b6cfa1c7bc0ca5273ac7cb Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Mon, 6 Apr 2026 00:33:35 +0000 Subject: [PATCH] fix(kugetsu-index): call kugetsu_add_notification from bash instead of os.system() os.system() spawns a new subprocess that cannot access bash functions. Now calling kugetsu_add_notification directly from bash after Python updates JSON. Fixes #167 --- skills/kugetsu/scripts/kugetsu-index.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/skills/kugetsu/scripts/kugetsu-index.sh b/skills/kugetsu/scripts/kugetsu-index.sh index eba8a90..8eec8c2 100755 --- a/skills/kugetsu/scripts/kugetsu-index.sh +++ b/skills/kugetsu/scripts/kugetsu-index.sh @@ -202,9 +202,10 @@ update_queue_item_state() { return 1 fi + local issue_ref=$(python3 -c "import json; print(json.load(open('$item_file')).get('issue_ref', ''))" 2>/dev/null || echo "") + python3 << PYEOF import json -import os from datetime import datetime item_file = "$item_file" @@ -215,8 +216,6 @@ pid = "$pid" with open(item_file, 'r') as f: item = json.load(f) -issue_ref = item.get('issue_ref', '') - item['state'] = new_state if new_state == "notified": @@ -227,14 +226,18 @@ if new_state == "notified": item['pid'] = int(pid) if pid.isdigit() else None elif new_state == "completed": item['completed_at'] = datetime.now().isoformat() + "Z" - os.system(f"kugetsu_add_notification 'task_completed' 'Task completed: {issue_ref}' '{issue_ref}'") elif new_state == "error": item['error'] = datetime.now().isoformat() + "Z" - os.system(f"kugetsu_add_notification 'task_error' 'Task error: {issue_ref}' '{issue_ref}'") with open(item_file, 'w') as f: json.dump(item, f, indent=2) print(f"Updated $queue_id to state: $new_state") PYEOF + + if [ "$new_state" = "completed" ]; then + kugetsu_add_notification "task_completed" "Task completed: $issue_ref" "$issue_ref" + elif [ "$new_state" = "error" ]; then + kugetsu_add_notification "task_error" "Task error: $issue_ref" "$issue_ref" + fi } -- 2.49.1