#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2025 Jiri Vyskocil
# SPDX-License-Identifier: Apache-2.0
# terok:container — this file is deployed into task containers, not used on the host.

# ACP wrapper for Claude Code.
#
# Sets up per-agent git identity and injects terok system instructions
# before exec-ing the real claude-agent-acp adapter.
#
# Instructions: --append-system-prompt flag injects the resolved terok
# instructions from /home/dev/.terok/instructions.md (per-task, written by
# prepare_agent_config_dir on the host).  Same mechanism as the headless wrapper.
#
# Unrestricted mode: claude-agent-acp reads /etc/claude-code/managed-settings.json
# (enterprise managed settings, highest precedence).  Written once by
# init-ssh-and-repo.sh at container startup — no per-invocation action needed.

set -euo pipefail

_AGENT_NAME="Claude"
_AGENT_EMAIL="noreply@anthropic.com"
. /usr/local/share/terok/terok-acp-env.sh

_args=()
if [[ -f /home/dev/.terok/instructions.md ]]; then
    _args+=(--append-system-prompt "$(cat /home/dev/.terok/instructions.md)")
fi

exec claude-agent-acp "${_args[@]}" "$@"
