diff --git a/mcptools/update_bead.sh b/mcptools/update_bead.sh index adaebf3..49165ee 100755 --- a/mcptools/update_bead.sh +++ b/mcptools/update_bead.sh @@ -25,5 +25,21 @@ if [ -z "$MOUNT" ] || [ -z "$BEAD_ID" ] || [ -z "$FIELD" ]; then exit 1 fi -printf "update %s %s '%s'\n" "$BEAD_ID" "$FIELD" "$VALUE" | 9p write anvillm/beads/$MOUNT/ctl -echo "updated $BEAD_ID.$FIELD: $VALUE" +if [ "$FIELD" = "parent" ]; then + # Reparent: create new bead under parent with same data, then delete original + JSON=$(9p read "anvillm/beads/$MOUNT/$BEAD_ID/json") + TITLE=$(echo "$JSON" | jq -r '.title') + DESC=$(echo "$JSON" | jq -r '.description // ""') + STATUS=$(echo "$JSON" | jq -r '.status') + + # Create under new parent + printf "new '%s' '%s' %s\n" "$TITLE" "$DESC" "$VALUE" | 9p write anvillm/beads/$MOUNT/ctl + + # Delete original + printf "delete %s\n" "$BEAD_ID" | 9p write anvillm/beads/$MOUNT/ctl + + echo "reparented $BEAD_ID under $VALUE" +else + printf "update %s %s '%s'\n" "$BEAD_ID" "$FIELD" "$VALUE" | 9p write anvillm/beads/$MOUNT/ctl + echo "updated $BEAD_ID.$FIELD: $VALUE" +fi