25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(ci): use Python for robust JSON handling in auto-review
t8y21777e1735368
diff --git a/.github/workflows/auto-review.yml b/.github/workflows/auto-review.ymlindex 36b7217750..ac3c182d05 100644--- a/.github/workflows/auto-review.yml+++ b/.github/workflows/auto-review.yml@@ -15,55 +15,65 @@ jobs:fetch-depth: 0- name: Get PR diff- id: diffenv:GH_TOKEN: ${{ github.token }}run: |gh pr diff ${{ github.event.pull_request.number }} > /tmp/pr.diff- # Truncate to ~30k chars to stay within LLM contexthead -c 30000 /tmp/pr.diff > /tmp/pr_truncated.diff- name: Review with DeepSeekid: reviewenv:DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}+ PR_TITLE: ${{ github.event.pull_request.title }}+ PR_BODY: ${{ github.event.pull_request.body }}run: |- DIFF=$(cat /tmp/pr_truncated.diff | jq -Rs .)- TITLE=$(echo '${{ github.event.pull_request.title }}' | jq -Rs .)- BODY=$(echo '${{ github.event.pull_request.body }}' | head -c 2000 | jq -Rs .)+ python3 - <<'PYEOF'+ import os, json, urllib.request- RESPONSE=$(curl -s https://api.deepseek.com/chat/completions \- -H "Authorization: Bearer ${DEEPSEEK_API_KEY}" \- -H "Content-Type: application/json" \- -d "{- \"model\": \"deepseek-chat\",- \"messages\": [- {- \"role\": \"system\",- \"content\": \"你是一个专业的代码审查员。请审查以下 Pull Request 的代码变更,给出简洁的中文评审意见。重点关注:1. 潜在的 bug 或逻辑错误 2. 安全问题 3. 性能问题 4. 代码风格和可读性。如果代码没有问题,简单说 LGTM 并给出简短总结。不要逐行重复代码。\"- },- {- \"role\": \"user\",- \"content\": \"PR 标题: ${TITLE}\n\nPR 描述: ${BODY}\n\n代码变更:\n${DIFF}\"- }+ diff = open("/tmp/pr_truncated.diff").read()+ title = os.environ.get("PR_TITLE", "")+ body = os.environ.get("PR_BODY", "")[:2000]+ api_key = os.environ["DEEPSEEK_API_KEY"]++ payload = json.dumps({+ "model": "deepseek-chat",+ "messages": [+ {+ "role": "system",+ "content": "你是一个专业的代码审查员。请审查以下 Pull Request 的代码变更,给出简洁的中文评审意见。重点关注:1. 潜在的 bug 或逻辑错误 2. 安全问题 3. 性能问题 4. 代码风格和可读性。如果代码没有问题,简单说 LGTM 并给出简短总结。不要逐行重复代码。"+ },+ {+ "role": "user",+ "content": f"PR 标题: {title}\n\nPR 描述: {body}\n\n代码变更:\n{diff}"+ }],- \"max_tokens\": 2000- }")+ "max_tokens": 2000+ }).encode()++ req = urllib.request.Request(+ "https://api.deepseek.com/chat/completions",+ data=payload,+ headers={+ "Authorization": f"Bearer {api_key}",+ "Content-Type": "application/json",+ },+ )- REVIEW=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "审查失败,请手动检查。"')+ with urllib.request.urlopen(req, timeout=120) as resp:+ data = json.loads(resp.read())- EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)- echo "comment<<$EOF" >> "$GITHUB_OUTPUT"- echo "$REVIEW" >> "$GITHUB_OUTPUT"- echo "$EOF" >> "$GITHUB_OUTPUT"+ review = data["choices"][0]["message"]["content"]++ with open(os.environ["GITHUB_OUTPUT"], "a") as f:+ delim = "EOF_REVIEW"+ f.write(f"comment<<{delim}\n{review}\n{delim}\n")+ PYEOF- name: Post review commentenv:GH_TOKEN: ${{ github.token }}+ REVIEW: ${{ steps.review.outputs.comment }}run: |- gh pr comment ${{ github.event.pull_request.number }} --body "$(cat <<'EOF'- 🤖 **Auto Review by DeepSeek**-- ${{ steps.review.outputs.comment }}- EOF- )"+ printf '🤖 **Auto Review by DeepSeek**\n\n%s' "$REVIEW" > /tmp/comment.md+ gh pr comment ${{ github.event.pull_request.number }} --body-file /tmp/comment.md