diff --git a/.github/workflows/ai-issue-helper.yml b/.github/workflows/ai-issue-helper.yml index d0747501..56d29f43 100644 --- a/.github/workflows/ai-issue-helper.yml +++ b/.github/workflows/ai-issue-helper.yml @@ -14,37 +14,76 @@ jobs: # 只在用户提到 @ai-helper 时触发 if: contains(github.event.comment.body, '@ai-helper') steps: - - name: AI Assistance - uses: github/issue-assessment-action@v1 + - name: Get Issue Details + id: issue + uses: actions/github-script@v7 with: - assessments: - - name: help-request - prompt: | - 用户在 issue 中提到了 @ai-helper,请分析他们的问题并提供帮助。 + script: | + const issue = await github.rest.issues.get({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + return { + title: issue.data.title, + body: issue.data.body, + number: issue.data.number + }; - 检查: - 1. 用户遇到的具体问题 - 2. 可能的解决方案 - 3. 相关文档链接 - 4. 类似的已解决 issue + - name: AI Analysis + uses: actions/ai-inference@v1 + id: ai + with: + model: 'gpt-4o-mini' + system-prompt: | + 你是 ECS Framework 项目的 AI 助手。 + 项目信息: + - 这是一个高性能 TypeScript ECS (Entity-Component-System) 框架 + - 支持 Cocos Creator、Laya 引擎和 Web 平台 + - 文档地址:https://esengine.github.io/ecs-framework/ + - AI 文档:https://deepwiki.com/esengine/ecs-framework - 用中文友好地回复,提供: - - 问题分析 - - 建议的解决方案(如果可以推断) - - 相关资源链接 - - 需要提供的额外信息(如果需要) + 请用中文友好地回复用户的问题。 + prompt: | + 用户在 Issue #${{ github.event.issue.number }} 中请求帮助。 - 格式: - 👋 你好!我是 AI 助手,让我帮你分析这个问题。 + Issue 标题:${{ steps.issue.outputs.result.title }} - 【问题分析】 - ... + Issue 内容: + ${{ steps.issue.outputs.result.body }} - 【建议方案】 - ... + 用户评论: + ${{ github.event.comment.body }} - 【相关资源】 - - 📚 文档:... - - 💡 示例:... + 请分析用户的问题并提供帮助: + 1. 问题分析 + 2. 可能的解决方案 + 3. 相关文档链接 + 4. 需要补充的信息(如果有) - 如果我的建议没有解决问题,请提供更多信息,维护者会尽快回复! + 用以下格式回复: + + 👋 你好!我是 AI 助手,让我帮你分析这个问题。 + + **问题分析** + [分析内容] + + **建议方案** + [解决方案] + + **相关资源** + - 📚 [文档链接] + - 💡 [示例链接] + + 如果我的建议没有解决问题,请提供更多信息,维护者会尽快回复! + + - name: Post AI Response + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: `${{ steps.ai.outputs.response }}` + }); diff --git a/.github/workflows/ai-issue-moderator.yml b/.github/workflows/ai-issue-moderator.yml index f5730c34..9be6cb69 100644 --- a/.github/workflows/ai-issue-moderator.yml +++ b/.github/workflows/ai-issue-moderator.yml @@ -5,12 +5,6 @@ on: types: [opened] issue_comment: types: [created] - workflow_dispatch: - inputs: - issue_number: - description: 'Issue 编号(留空则检查所有打开的 issue)' - required: false - type: string permissions: issues: write @@ -20,46 +14,42 @@ jobs: moderate: runs-on: ubuntu-latest steps: - - name: Get issue number - id: issue - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - if [ -n "${{ github.event.inputs.issue_number }}" ]; then - echo "number=${{ github.event.inputs.issue_number }}" >> $GITHUB_OUTPUT - else - echo "number=all" >> $GITHUB_OUTPUT - fi - else - echo "number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT - fi - - name: AI Content Moderation - uses: github/content-moderation-action@v1 + - name: Check Content + uses: actions/ai-inference@v1 + id: check with: - # 检测垃圾内容 - spam-detection: true - - # 检测 AI 生成内容 - ai-generated-detection: true - - # 自定义提示 - custom-prompt: | - 分析这个 issue/评论是否包含: + model: 'gpt-4o-mini' + system-prompt: | + 你是一个内容审查助手。 + 检查内容是否包含: 1. 垃圾信息或广告 - 2. 纯 AI 生成的无意义内容 - 3. 恶意或攻击性内容 - 4. 与项目无关的内容 + 2. 恶意或攻击性内容 + 3. 与项目完全无关的内容 - 如果是垃圾内容,返回 "SPAM" - 如果是正常内容,返回 "OK" + 只返回 "SPAM" 或 "OK",不要其他内容。 + prompt: | + 标题:${{ github.event.issue.title || github.event.comment.body }} - # 垃圾内容处理 - on-spam: - labels: - - "spam" - minimize: true # 隐藏内容 - comment: | - 🤖 这个 issue 被 AI 检测为可能的垃圾内容,已自动隐藏。 - 如果这是误判,请联系维护者。 + 内容: + ${{ github.event.issue.body || github.event.comment.body }} - 🤖 This issue was detected as potential spam by AI and has been hidden. - If this is a false positive, please contact the maintainers. + - name: Mark as Spam + if: contains(steps.check.outputs.response, 'SPAM') + uses: actions/github-script@v7 + with: + script: | + // 添加 spam 标签 + github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: ['spam'] + }); + + // 添加评论 + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: '🤖 这个内容被 AI 检测为可能的垃圾内容。如果这是误判,请联系维护者。\n\n🤖 This content was detected as potential spam by AI. If this is a false positive, please contact the maintainers.' + }); diff --git a/.github/workflows/batch-label-issues.yml b/.github/workflows/batch-label-issues.yml index c0c13f0c..24a25058 100644 --- a/.github/workflows/batch-label-issues.yml +++ b/.github/workflows/batch-label-issues.yml @@ -146,9 +146,7 @@ jobs: gh issue edit $ISSUE_NUM --add-label "$label" 2>&1 | grep -v "already exists" || true done echo " 💬 添加说明评论..." - gh issue comment $ISSUE_NUM --body "🤖 自动标签系统检测到此 issue 并添加了相关标签。如有误判,请告知维护者。 - -🤖 Auto-labeling system detected and labeled this issue. Please let maintainers know if this is incorrect." || true + gh issue comment $ISSUE_NUM --body $'🤖 自动标签系统检测到此 issue 并添加了相关标签。如有误判,请告知维护者。\n\n🤖 Auto-labeling system detected and labeled this issue. Please let maintainers know if this is incorrect.' || true else echo " ℹ️ 未检测到明确类型" fi