#!/usr/bin/env bash
set -euo pipefail

root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
readme="${root}/README.md"

required_entries=(
  "smart-healthcare-2026/src/mtran"
  "src/mtran/dependencies"
  "./auto_install.sh"
  "source ~/.bashrc"
  "colcon build --packages-select mtran"
  "ros2 launch mtran translator.launch.py"
  "mtran/srv/TranslateEnglishToChinese"
  "/translate_en_to_zh"
  "脚本不会安装 ROS2"
  "x86_64"
  "aarch64"
  "records.json"
  "MT_OFFLINE=true"
  "8989"
)

for required in "${required_entries[@]}"; do
  grep -Fq "${required}" "${readme}"
done

if rg -n 'mtran_ros2|MTranServer/migrate_ws|Path\.cwd|build_mtranserver\.sh' "${readme}"; then
  echo "README still contains an obsolete package name or local path" >&2
  exit 1
fi
