Skip to content

Conversation

@Guo-Chenxu
Copy link
Contributor

Ⅰ. Describe what this PR did

support self-define system prompt while generating release notes

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

the content between ## system prompt and the next ## is system prompt, like this:

## system prompt

here is your self-define system prompt

## ...

Ⅴ. Special notes for reviews

Signed-off-by: guochenxu <[email protected]>
Signed-off-by: guochenxu <[email protected]>
@lingma-agents
Copy link

lingma-agents bot commented Sep 23, 2025

支持自定义系统提示词生成 Release Notes

变更概述
  • 新功能

    • 在 Release Notes 生成流程中新增对自定义系统提示词(system prompt)的支持。
    • 系统会从 Release 页面 HTML 中提取位于 ## system prompt 和下一个 ## 标题之间的内容作为系统提示词。
    • 提取的提示词经过 HTML 标签清理和实体解码后,保存为临时文件并传递给报告生成脚本。
  • 配置调整

    • 修改了 GitHub Actions 工作流 .github/workflows/generate-release-notes.yaml,增加了提取和处理系统提示词的逻辑。
    • 调整了 Python 脚本的调用参数,支持通过 --sys_prompt_file 参数传入自定义系统提示词文件路径。
  • 其他

    • 添加了清理临时文件的逻辑,确保生成过程中产生的 temp_system_prompt.txt 文件在使用后被删除。
变更文件
文件路径 变更说明
.​github/​workflows/​generate-release-notes.​yaml 新增提取 Release 页面中自定义系统提示词的逻辑,并将其传递给报告生成脚本。同时更新了脚本调用参数以支持系统提示词文件输入。

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

Copy link

@lingma-agents lingma-agents bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎 代码评审报告

🎯 评审意见概览
严重度 数量 说明
🔴 Blocker 0 阻断性问题,需立即修复。例如:系统崩溃、关键功能不可用或严重安全漏洞。
🟠 Critical 0 严重问题,高优先级修复。例如:核心功能异常或性能瓶颈影响用户体验。
🟡 Major 1 主要问题,建议修复。例如:非核心功能缺陷或代码维护性较差。
🟢 Minor 1 次要问题,酬情优化。例如:代码格式不规范或注释缺失。

总计: 2 个问题

📋 评审意见详情
💡 代码实现建议
以下是文件级别的代码建议,聚焦于代码的可读性、可维护性和潜在问题。
⚙️ .github/workflows/generate-release-notes.yaml (2 💬)
🚀 架构设计建议
以下是对代码架构和设计的综合分析,聚焦于跨文件交互、系统一致性和潜在优化空间。
🔍1. 系统提示提取逻辑的健壮性和可维护性问题

当前在工作流中直接使用grep、sed和tail等shell命令来解析HTML并提取系统提示内容,这种方法非常脆弱,容易因HTML结构的微小变化而失效。建议采用更健壮的HTML解析方法(如Python中的BeautifulSoup),以提高代码的可维护性和可靠性。

📌 关键代码

# Extract system prompt content from HTML
echo "Extracting system prompt content..."
SYSTEM_PROMPT=""
# Find the line number where system prompt starts
system_prompt_start=$(grep -n "<h2>system prompt</h2>" release_page.html | cut -d: -f1)
if [ -n "$system_prompt_start" ]; then
    # Find the next h2 tag after system prompt
    next_h2_line=$(tail -n +$((system_prompt_start + 1)) release_page.html | grep -n "<h2>" | head -1 | cut -d: -f1)
    if [ -n "$next_h2_line" ]; then
        # Calculate actual line number and extract content between the two h2 tags
        system_prompt_end=$((system_prompt_start + next_h2_line))
        system_prompt_raw=$(sed -n "${system_prompt_start},$((system_prompt_end - 1))p" release_page.html)
    else
        # If no next h2 found, extract till end of file
        system_prompt_raw=$(tail -n +${system_prompt_start} release_page.html)
    fi
    # Clean up HTML tags and decode entities, store in variable
    SYSTEM_PROMPT=$(echo "$system_prompt_raw" | \
        sed 's/&lt;/</g; s/&gt;/>/g; s/&amp;/\&/g; s/&quot;/"/g; s/&#39;/'"'"'/g' | \
        sed '/^$/d' | \
        sed '1d')  # Remove the first line (system prompt header)
    echo "System Prompt Content:"
    echo "$SYSTEM_PROMPT"
else
    echo "No system prompt found in the release page."
fi

⚠️ 潜在风险

HTML结构变化可能导致解析失败,影响发布说明的生成;维护成本高,难以扩展。

🔍2. 临时文件管理的安全性和一致性问题

在工作流中创建了临时文件temp_system_prompt.txt来传递系统提示内容,但清理逻辑仅在特定条件下执行。建议使用更安全的临时文件管理方式(如mktemp)并在脚本结束时统一清理,以防止临时文件残留和潜在的安全风险。

📌 关键代码

if [ -n "${SYSTEM_PROMPT}" ]; then
    echo "${SYSTEM_PROMPT}" > temp_system_prompt.txt
    CMD_ARGS="${CMD_ARGS} --sys_prompt_file temp_system_prompt.txt"
fi
uv run report_main.py ${CMD_ARGS}
# Clean up temporary file
if [ -f "temp_system_prompt.txt" ]; then
    rm temp_system_prompt.txt
fi

⚠️ 潜在风险

临时文件可能因脚本异常退出而未被清理,占用磁盘空间或泄露敏感信息;清理逻辑不统一,存在遗漏风险。

审查详情
📒 文件清单 (1 个文件)
📝 变更: 1 个文件

📝 变更文件:

  • .github/workflows/generate-release-notes.yaml

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

Comment on lines 69 to 99
# Extract system prompt content from HTML
echo "Extracting system prompt content..."
SYSTEM_PROMPT=""
# Find the line number where system prompt starts
system_prompt_start=$(grep -n "<h2>system prompt</h2>" release_page.html | cut -d: -f1)
if [ -n "$system_prompt_start" ]; then
# Find the next h2 tag after system prompt
next_h2_line=$(tail -n +$((system_prompt_start + 1)) release_page.html | grep -n "<h2>" | head -1 | cut -d: -f1)
if [ -n "$next_h2_line" ]; then
# Calculate actual line number and extract content between the two h2 tags
system_prompt_end=$((system_prompt_start + next_h2_line))
system_prompt_raw=$(sed -n "${system_prompt_start},$((system_prompt_end - 1))p" release_page.html)
else
# If no next h2 found, extract till end of file
system_prompt_raw=$(tail -n +${system_prompt_start} release_page.html)
fi
# Clean up HTML tags and decode entities, store in variable
SYSTEM_PROMPT=$(echo "$system_prompt_raw" | \
sed 's/&lt;/</g; s/&gt;/>/g; s/&amp;/\&/g; s/&quot;/"/g; s/&#39;/'"'"'/g' | \
sed '/^$/d' | \
sed '1d') # Remove the first line (system prompt header)
echo "System Prompt Content:"
echo "$SYSTEM_PROMPT"
else
echo "No system prompt found in the release page."
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应使用更健壮的方法来解析HTML内容,而不是依赖grep和sed。

🟡 Major | 🧹 Code Smells

📋 问题详情

当前使用grep和sed来提取HTML中的内容容易出错且难以维护。如果HTML结构稍有变化,或者标签属性发生变化,这种硬编码的解析方式将失效。此外,使用shell命令处理HTML内容也不够安全,容易受到注入攻击。建议使用专门的HTML解析工具或库来处理HTML内容,以提高代码的健壮性和安全性。

💡 解决方案

考虑使用Python脚本配合BeautifulSoup库来解析HTML内容,这样可以更准确地定位和提取所需信息。例如:

-          # Extract system prompt content from HTML
-          echo "Extracting system prompt content..."
-          SYSTEM_PROMPT=""
-
-          # Find the line number where system prompt starts
-          system_prompt_start=$(grep -n "<h2>system prompt</h2>" release_page.html | cut -d: -f1)
-
-          if [ -n "$system_prompt_start" ]; then
-              # Find the next h2 tag after system prompt
-              next_h2_line=$(tail -n +$((system_prompt_start + 1)) release_page.html | grep -n "<h2>" | head -1 | cut -d: -f1)
-
-              if [ -n "$next_h2_line" ]; then
-                  # Calculate actual line number and extract content between the two h2 tags
-                  system_prompt_end=$((system_prompt_start + next_h2_line))
-                  system_prompt_raw=$(sed -n "${system_prompt_start},$((system_prompt_end - 1))p" release_page.html)
-              else
-                  # If no next h2 found, extract till end of file
-                  system_prompt_raw=$(tail -n +${system_prompt_start} release_page.html)
-              fi
-
-              # Clean up HTML tags and decode entities, store in variable
-              SYSTEM_PROMPT=$(echo "$system_prompt_raw" | \
-                  sed 's/&lt;/</g; s/&gt;/>/g; s/&amp;/\&/g; s/&quot;/"/g; s/&#39;/'"'"'/g' | \
-                  sed '/^$/d' | \
-                  sed '1d')  # Remove the first line (system prompt header)
-
-              echo "System Prompt Content:"
-              echo "$SYSTEM_PROMPT"
-          else
-              echo "No system prompt found in the release page."
-          fi
+          # Extract system prompt content from HTML using Python
+          echo "Extracting system prompt content..."
+          SYSTEM_PROMPT=$(python3 -c "
+import sys
+from bs4 import BeautifulSoup
+
+with open('release_page.html', 'r') as f:
+    soup = BeautifulSoup(f, 'html.parser')
+
+system_prompt_header = soup.find('h2', string='system prompt')
+if system_prompt_header:
+    content = []
+    for sibling in system_prompt_header.next_siblings:
+        if sibling.name == 'h2':
+            break
+        content.append(str(sibling))
+    print(''.join(content).strip())
+else:
+    print('No system prompt found in the release page.')
+")


<!-- Suggestion code flag -->




---

> 您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)

  [有用意见👍](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-5163edd6a7b8&feedback_type=helpful) | [无用意见👎](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-5163edd6a7b8&feedback_type=neutral) | [错误意见❌](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-5163edd6a7b8&feedback_type=misleading)



<!-- This is an auto-generated comment by LingmaAgent -->

Comment on lines +136 to +139
# Clean up temporary file
if [ -f "temp_system_prompt.txt" ]; then
rm temp_system_prompt.txt
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应确保在所有退出路径上都清理临时文件,以防止残留文件占用磁盘空间。

🟢 Minor | 🧹 Code Smells

📋 问题详情

目前只在脚本正常执行完毕后清理临时文件temp_system_prompt.txt。如果脚本在执行过程中因错误而提前退出,临时文件将不会被清理,从而占用磁盘空间。为了确保临时文件总是被清理,应该使用trap命令在脚本退出时自动清理临时文件。

💡 解决方案

使用trap命令在脚本退出时自动清理临时文件。

-          # Clean up temporary file
-          if [ -f "temp_system_prompt.txt" ]; then
-              rm temp_system_prompt.txt
-          fi
+          # Set trap to clean up temporary file on exit
+          trap 'if [ -f "temp_system_prompt.txt" ]; then rm temp_system_prompt.txt; fi' EXIT


<!-- Suggestion code flag -->




---

> 您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)

  [有用意见👍](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-74a0788a7ef2&feedback_type=helpful) | [无用意见👎](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-74a0788a7ef2&feedback_type=neutral) | [错误意见❌](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-74a0788a7ef2&feedback_type=misleading)



<!-- This is an auto-generated comment by LingmaAgent -->

@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.95%. Comparing base (ef31e09) to head (74644f5).
⚠️ Report is 723 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2943      +/-   ##
==========================================
+ Coverage   35.91%   44.95%   +9.03%     
==========================================
  Files          69       82      +13     
  Lines       11576    13377    +1801     
==========================================
+ Hits         4157     6013    +1856     
+ Misses       7104     7016      -88     
- Partials      315      348      +33     

see 80 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@johnlanni johnlanni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@johnlanni johnlanni merged commit bfca466 into alibaba:main Sep 23, 2025
8 checks passed
Tsukilc pushed a commit to Tsukilc/higress that referenced this pull request Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants