#!/usr/bin/env bash
# taskctl shim — generated by `install.sh --target <actor-kind>`.
#
# Attributes every CLI call to this agent. It injects **both halves of the
# identity**: `--agent <name>` and `--actor-kind <kind>`, so a write from a hook,
# a slash command or a session is recorded as this agent on this platform.
#
# The kind is not decoration. It is what the board reads to tell a person from an
# agent — a human's `decision` is what goes on the record (I5), what resumes an
# `awaiting` card, and what the patrol counts as the leader acting — so a shim
# that set only the name would record every agent write as a human's.
#
# `TASKCTL_AGENT` / `TASKCTL_ACTOR_KIND` still win when set, and a caller's own
# flags win over both, so a session can override either deliberately.
#
# To write as the *human* instead — recording something they said, in their voice
# — pass `--as-human`. That takes the name from `TASKCTL_HUMAN`, and it is the one
# write an agent makes on somebody else's behalf.
#
# It does not point at the project map: `projects.json` lives at the config root,
# which the CLI resolves itself (the same one the poll pass reads).
set -u

agent="${TASKCTL_AGENT:-{{AGENT}}}"
kind="${TASKCTL_ACTOR_KIND:-{{ACTOR_KIND}}}"
human="${TASKCTL_HUMAN:-{{HUMAN}}}"
export TASKCTL_AGENT="$agent"
export TASKCTL_ACTOR_KIND="$kind"
export TASKCTL_HUMAN="$human"
exec node "{{REPO}}/src/cli/index.mjs" --agent "$agent" --actor-kind "$kind" "$@"
