Files
llm-intelligence/scripts/verify_t35.sh

70 lines
2.1 KiB
Bash
Raw Normal View History

#!/bin/bash
# verify_t35.sh — 验收 T-3.5:日报生成器同步产出 latest_models.json + Explorer fallback
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
REPORT="$PROJECT_ROOT/scripts/generate_daily_report.go"
EXPLORER="$PROJECT_ROOT/frontend/src/pages/Explorer.tsx"
LATEST="$PROJECT_ROOT/frontend/src/data/latest_models.json"
echo "=== T-3.5 验收检查 ==="
# T-3.5.1: generate_daily_report.go 含 latest_models.json 写入,且路径从 outDir 推导而非硬编码相对 cwd
if grep -q 'latest_models.json' "$REPORT" && \
grep -q 'outDir.*frontend.*latest_models.json\|filepath.Join.*outDir.*latest' "$REPORT"; then
echo "report-json-write PASS — latest_models.json 写入且路径从 outDir 推导"
else
echo "report-json-write FAIL"
exit 1
fi
# T-3.5.2: Explorer.tsx 含 latest_models.json 优先加载和 models.json fallback
if grep -q 'latest_models.json' "$EXPLORER" && \
grep -q 'models.json' "$EXPLORER"; then
echo "explorer-fallback PASS — latest 优先 + models fallback 同时存在"
else
echo "explorer-fallback FAIL"
exit 1
fi
# T-3.5.1 补丁验证: latest_models.json 免费模型 pricing 字段完整性
if [ ! -f "$LATEST" ]; then
echo "pricing-normalized FAIL — latest_models.json 不存在"
exit 1
fi
if python3 - "$LATEST" <<'PY'
import json
import sys
path = sys.argv[1]
with open(path, "r", encoding="utf-8") as f:
data = json.load(f)
free_models = [
model for model in data.get("models", [])
if isinstance(model.get("id"), str) and model["id"].endswith(":free")
]
if not free_models:
raise SystemExit(1)
for model in free_models:
pricing = model.get("pricing")
if not isinstance(pricing, dict):
raise SystemExit(1)
if "input" not in pricing or "output" not in pricing:
raise SystemExit(1)
if pricing["input"] != 0 or pricing["output"] != 0:
raise SystemExit(1)
PY
then
echo "pricing-normalized PASS — 免费模型 pricing.input/output 均显式为 0"
else
echo "pricing-normalized FAIL — 免费模型 pricing 字段缺失或未显式归一为 0"
exit 1
fi
echo ""
echo "all PASS"
exit 0