Files
2026-05-30 14:03:11 +08:00

64 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# update-graph.sh — 增量更新知识图谱
# 用法:
# ./scripts/update-graph.sh # 更新前后端
# ./scripts/update-graph.sh backend # 只更新后端
# ./scripts/update-graph.sh frontend # 只更新前端
#
# 由 AI Agent 在完成代码修改后自动调用,或手动执行。
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
PYTHON="/Users/zlwu/.pyenv/versions/3.12.13/bin/python"
# 检查 graphify 是否可用
if ! "$PYTHON" -m graphify --help >/dev/null 2>&1; then
echo "[graphify] 未安装,请运行: $PYTHON -m pip install graphify"
exit 1
fi
# 更新单个项目的图谱
update_graph() {
local name="$1"
local label="$2"
echo ""
echo "=== 更新 ${label} 知识图谱 (${name}) ==="
if [ ! -d "$ROOT_DIR/$name" ]; then
echo "[graphify] 目录不存在: $ROOT_DIR/$name"
return 1
fi
"$PYTHON" -m graphify update "$ROOT_DIR/$name" --force
echo "[graphify] ${label} 图谱更新完成 ✓"
}
# ---- Main ----
TARGET="${1:-all}"
echo "╔══════════════════════════════════════╗"
echo "║ shanxia2.0 知识图谱增量更新工具 ║"
echo "╚══════════════════════════════════════╝"
case "$TARGET" in
backend)
update_graph "backend" "后端"
;;
frontend)
update_graph "web-admin" "前端"
;;
all|"")
update_graph "backend" "后端"
update_graph "web-admin" "前端"
;;
*)
echo "用法: $0 [backend|frontend|all]"
exit 1
;;
esac
echo ""
echo "✅ 知识图谱更新完毕。HTML 可视化: */graphify-out/graph.html"