Files
esengine/.github/workflows/ai-issue-helper.yml

94 lines
3.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: AI Issue Helper
on:
issue_comment:
types: [created]
permissions:
issues: write
contents: read
models: read
jobs:
ai-helper:
runs-on: ubuntu-latest
# 只在真实用户提到 @ai-helper 时触发,忽略机器人评论
if: |
contains(github.event.comment.body, '@ai-helper') &&
github.event.comment.user.type != 'Bot'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Create Prompt File
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const lines = [];
lines.push('用户在 Issue #' + context.issue.number + ' 中请求帮助。\n');
lines.push('Issue 标题:');
lines.push(issue.data.title || '(无标题)');
lines.push('\nIssue 内容:');
lines.push(issue.data.body || '(无内容)');
lines.push('\n用户评论');
lines.push(context.payload.comment.body);
lines.push('\n请按以下步骤回答');
lines.push('1. 使用 GitHub 工具搜索项目中的相关代码和文件');
lines.push('2. 分析用户的问题');
lines.push('3. 基于实际代码提供准确的解决方案');
lines.push('4. 提供相关文档链接和代码示例');
lines.push('\n用以下格式回复');
lines.push('\n你好我是 AI 助手,让我帮你分析这个问题。');
lines.push('\n**问题分析**');
lines.push('[分析内容]');
lines.push('\n**建议方案**');
lines.push('[基于项目实际代码的解决方案]');
lines.push('\n**相关代码**');
lines.push('[引用项目中的相关代码片段]');
lines.push('\n**相关资源**');
lines.push('- 文档链接');
lines.push('- 示例链接');
lines.push('\n如果我的建议没有解决问题请提供更多信息维护者会尽快回复');
fs.writeFileSync('prompt.txt', lines.join('\n'));
- name: AI Analysis
uses: actions/ai-inference@v1
id: ai
with:
model: 'gpt-4o-mini'
mcp: github
system-prompt: |
你是 ECS Framework 项目的 AI 助手。
项目信息:
- 这是一个高性能 TypeScript ECS (Entity-Component-System) 框架
- 支持 Cocos Creator、Laya 引擎和 Web 平台
- 主要代码在 packages/core/src 目录
- 文档地址https://esengine.github.io/ecs-framework/
- AI 文档https://deepwiki.com/esengine/ecs-framework
你可以使用 GitHub 工具搜索代码、查看文件内容来准确回答问题。
在回答之前,先搜索相关代码和文档,确保答案准确。
请用中文友好地回复用户的问题。
prompt: prompt.txt
- 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 }}`
});