Files
hk-ipo/scripts/run_hk_ipo_analyst_once.sh
T
geometrybase a0e7775284 Fix scheduled Codex option order
Request:
- Fix hk-ipo-analyst.service failing with 'unexpected argument -a' when the scheduled runner invokes Codex.

Changes:
- Moved Codex global options before the exec subcommand in scripts/run_hk_ipo_analyst_once.sh.
- Kept the existing scheduled prompt and systemd units unchanged.
- Reset the failed hk-ipo-analyst.service state after the previous invalid-argument failure.

Verification:
- Ran bash -n scripts/run_hk_ipo_analyst_once.sh.
- Ran git diff --cached --check.
- Confirmed 'codex --search -s danger-full-access -a never exec -C /root/projects/hk-ipo --help' parses successfully.
- Ran systemd-analyze verify for the service and timer; only unrelated system xfs unit warnings were reported.

Next useful context:
- I did not start hk-ipo-analyst.service after this fix to avoid triggering a full analyst refresh outside the timer window.
2026-06-22 15:46:46 +00:00

47 lines
2.2 KiB
Bash
Executable File

#!/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 the latest IPO candidate universe from online sources through `hk-ipo-archivist` before analysis.
- Update all relevant fresh network facts for the latest candidate report, especially live subscription-period market heat / margin subscription multiples, official T1 allotment demand when published, prospectus documents, listing calendars, and recent D1 review data.
- Keep unofficial subscription multiples in `ipo_market_heat` with their provider and `observed_at`; do not copy them into official T1 public oversubscription fields.
- Rebuild the analysis dataset after any archive refresh.
- Produce a complete latest broad IPO candidate report for actionable subscriptions, including ranking, fundamentals, break-risk/risk-reward, per-IPO notes, closed/waiting names, recent 30-day review, guardrails, and sources.
- Write the dated report as `reports/YYYY-MM-DD_latest_ipo_candidates_analysis.md`, then copy the same final content to `reports/README.md` so the reports directory opens on the latest report.
- Keep stage discipline: no later facts leaking into earlier-stage conclusions.
- Write analyst output in Simplified Chinese.
- Commit only related project changes, including the dated report and `reports/README.md`, 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 \
-s danger-full-access \
-a never \
exec \
-C "${REPO_ROOT}" \
"${PROMPT}"