forked from niuniu/llm-intelligence
chore(frontend): split fixture and generated model snapshots
This commit is contained in:
@@ -1,36 +1,62 @@
|
||||
#!/bin/bash
|
||||
# verify_t35.sh — 验收 T-3.5:日报生成器同步产出 latest_models.json + Explorer fallback
|
||||
# verify_t35.sh — 验收 T-3.5:前端本地 latest 快照语义 + fixture 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"
|
||||
MODELS_LIB="$PROJECT_ROOT/frontend/src/lib/models.ts"
|
||||
GITIGNORE="$PROJECT_ROOT/.gitignore"
|
||||
LATEST="$PROJECT_ROOT/frontend/src/data/latest_models.json"
|
||||
FIXTURE="$PROJECT_ROOT/frontend/src/data/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 推导"
|
||||
# T-3.5.1: latest_models.json 视为本地运行快照,不纳入 git 跟踪
|
||||
if grep -q '^frontend/src/data/latest_models.json$' "$GITIGNORE"; then
|
||||
echo "latest-ignore PASS — latest_models.json 已被 .gitignore 标记为本地运行快照"
|
||||
else
|
||||
echo "report-json-write FAIL"
|
||||
echo "latest-ignore 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 同时存在"
|
||||
# T-3.5.2: 回退层在 models.ts 中定义 latest 优先 + models fixture fallback
|
||||
if grep -q 'latest_models.json' "$MODELS_LIB" && \
|
||||
grep -q 'models.json' "$MODELS_LIB"; then
|
||||
echo "fallback-order PASS — latest 优先 + models fixture fallback 同时存在"
|
||||
else
|
||||
echo "explorer-fallback FAIL"
|
||||
echo "fallback-order FAIL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# T-3.5.1 补丁验证: latest_models.json 免费模型 pricing 字段完整性
|
||||
# T-3.5.3: committed fixture 必须长期存在,保证无 API 时仍能展示基础数据
|
||||
if [ ! -f "$FIXTURE" ]; then
|
||||
echo "fixture-present FAIL — models.json fixture 不存在"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if python3 - "$FIXTURE" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
|
||||
path = sys.argv[1]
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
assert isinstance(data.get("models"), list) and len(data["models"]) > 0
|
||||
assert all("pricing" in model for model in data["models"])
|
||||
PY
|
||||
then
|
||||
echo "fixture-present PASS — models.json fixture 存在且结构可用"
|
||||
else
|
||||
echo "fixture-present FAIL — models.json fixture 结构异常"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# T-3.5.4: latest_models.json 如果存在,必须满足快照 schema 和免费模型归一化
|
||||
if [ ! -f "$LATEST" ]; then
|
||||
echo "pricing-normalized FAIL — latest_models.json 不存在"
|
||||
exit 1
|
||||
echo "latest-optional PASS — latest_models.json 当前不存在,前端将回退到 committed fixture"
|
||||
echo ""
|
||||
echo "all PASS"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if python3 - "$LATEST" <<'PY'
|
||||
@@ -58,9 +84,9 @@ for model in free_models:
|
||||
raise SystemExit(1)
|
||||
PY
|
||||
then
|
||||
echo "pricing-normalized PASS — 免费模型 pricing.input/output 均显式为 0"
|
||||
echo "latest-schema PASS — latest_models.json 存在且免费模型 pricing.input/output 均显式为 0"
|
||||
else
|
||||
echo "pricing-normalized FAIL — 免费模型 pricing 字段缺失或未显式归一为 0"
|
||||
echo "latest-schema FAIL — latest_models.json schema 异常或免费模型 pricing 未归一"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user