#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd -- "${SCRIPT_DIR}/.." && pwd)" mkdir -p /run/hk-ipo exec 9>/run/hk-ipo/analyst.lock if ! flock -n 9; then echo "$(date -Is) hk-ipo-analyst already running; skip" exit 0 fi cd "${REPO_ROOT}" AS_OF="$(date -u +%Y-%m-%dT%H:%M:%SZ)" PROMPT_TEMPLATE="$(cat <<'EOF' Use the `hk-ipo-analyst` skill from `.agents/skills/hk-ipo-analyst/SKILL.md`. Run one scheduled HK IPO analyst refresh as of __AS_OF__. Goals: - Inspect the current worktree and recent git history first. - Refresh archived facts through `hk-ipo-archivist` only when needed. - Rebuild the analysis dataset when inputs changed or freshness requires it. - Produce or update the latest broad IPO candidate report for actionable subscriptions. - Keep stage discipline: no later facts leaking into earlier-stage conclusions. - Write analyst output in Simplified Chinese. - Commit only related project changes and push the current branch if upstream exists. - If data is missing or stale, state the `data_gap` clearly instead of guessing. - Do not ask interactive questions during this scheduled run. - Do not change the systemd units or this wrapper script during this scheduled run. EOF )" PROMPT="${PROMPT_TEMPLATE//__AS_OF__/${AS_OF}}" codex --search exec \ -C "${REPO_ROOT}" \ -s danger-full-access \ -a never \ "${PROMPT}"