#!/usr/bin/env bash
# task-mirror.sh  -  PostToolUse hook (TaskCreate|TaskUpdate) for the pipeline.
#
# Mirrors the host's native task list into the run's tracker-state.json, so the
# office panel and every other reader see what the task widget shows. The
# logic is in task-mirror.mjs; this wrapper exists because every hook the
# pipeline registers is a `bash "$HOME/.<host>/scripts/<name>"` command.
#
# Exits 0 on every path; its only output is a tile-ordering note for the
# model. A missing node or any internal error means no mirror, never a blocked
# tool call.

set -u

HERE="$(cd "$(dirname "$0")" 2>/dev/null && pwd || true)"
CORE="$HERE/task-mirror.mjs"
[ -f "$CORE" ] || exit 0
command -v node >/dev/null 2>&1 || exit 0

node "$CORE" 2>/dev/null || true
exit 0
