mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-30 02:00:50 +08:00
76d6234de6
* Agent features (#6345) * Test agent (#6220) * squash: compress all commits into one * feat: plan response in ui * response ui * perf: agent config * merge * tool select ux * perf: chat ui * perf: agent editform * tmp code * feat: save chat * Complete agent parent (#6049) * add role and tools filling * add: file-upload --------- Co-authored-by: xxyyh <2289112474@qq> * perf: top agent code * top agent (#6062) Co-authored-by: xxyyh <2289112474@qq> * fix: ts * skill editor ui * ui * perf: rewrite type with zod * skill edit ui * skill agent (#6089) * cp skill chat * rebasefdf933dand add skill chat * 1. skill 的 CRUD 2. skill 的信息渲染到前端界面 * solve comment * remove chatid and chatItemId * skill match * perf: skill manage * fix: ts --------- Co-authored-by: xxyyh <2289112474@qq> Co-authored-by: archer <545436317@qq.com> * fix: ts * fix: loop import * skill tool config (#6114) Co-authored-by: xxyyh <2289112474@qq> * feat: load tool in agent * skill memory (#6126) Co-authored-by: xxyyh <2289112474@qq> * perf: agent skill editor * perf: helperbot ui * agent code * perf: context * fix: request context * agent usage * perf: agent context and pause * perf: plan response * Test agent sigle skill (#6184) * feat:top box fill * prompt fix --------- Co-authored-by: xxyyh <2289112474@qq> * perf: agent chat ui * Test agent new (#6219) * have-replan * agent --------- Co-authored-by: xxyyh <2289112474@qq> * fix: ts --------- Co-authored-by: YeYuheng <57035043+YYH211@users.noreply.github.com> Co-authored-by: xxyyh <2289112474@qq> * feat: consolidate agent and MCP improvements This commit consolidates 17 commits including: - MCP tools enhancements and fixes - Agent system improvements and optimizations - Auth limit and prompt updates - Tool response compression and error tracking - Simple app adaptation - Code quality improvements (TypeScript, ESLint, Zod) - Version type migration to schema - Remove deprecated useRequest2 - Add LLM error tracking - Toolset ID validation fixes --------- Co-authored-by: YeYuheng <57035043+YYH211@users.noreply.github.com> Co-authored-by: xxyyh <2289112474@qq> * fix: transform avatar copy;perf: filter invalid tool * update llm response storage time * fix: openapi schema * update skill desc * feat: cache hit data * i18n * lock * chat logs support error filter & user search (#6373) * chat log support searching by user name * support error filter * fix * fix overflow * optimize * fix init script * fix * perf: get log users * updat ecomment * fix: ts * fix: test --------- Co-authored-by: archer <545436317@qq.com> * Fix: agent (#6376) * Agent features (#6345) * Test agent (#6220) * squash: compress all commits into one * feat: plan response in ui * response ui * perf: agent config * merge * tool select ux * perf: chat ui * perf: agent editform * tmp code * feat: save chat * Complete agent parent (#6049) * add role and tools filling * add: file-upload --------- Co-authored-by: xxyyh <2289112474@qq> * perf: top agent code * top agent (#6062) Co-authored-by: xxyyh <2289112474@qq> * fix: ts * skill editor ui * ui * perf: rewrite type with zod * skill edit ui * skill agent (#6089) * cp skill chat * rebasefdf933dand add skill chat * 1. skill 的 CRUD 2. skill 的信息渲染到前端界面 * solve comment * remove chatid and chatItemId * skill match * perf: skill manage * fix: ts --------- Co-authored-by: xxyyh <2289112474@qq> Co-authored-by: archer <545436317@qq.com> * fix: ts * fix: loop import * skill tool config (#6114) Co-authored-by: xxyyh <2289112474@qq> * feat: load tool in agent * skill memory (#6126) Co-authored-by: xxyyh <2289112474@qq> * perf: agent skill editor * perf: helperbot ui * agent code * perf: context * fix: request context * agent usage * perf: agent context and pause * perf: plan response * Test agent sigle skill (#6184) * feat:top box fill * prompt fix --------- Co-authored-by: xxyyh <2289112474@qq> * perf: agent chat ui * Test agent new (#6219) * have-replan * agent --------- Co-authored-by: xxyyh <2289112474@qq> * fix: ts --------- Co-authored-by: YeYuheng <57035043+YYH211@users.noreply.github.com> Co-authored-by: xxyyh <2289112474@qq> * feat: consolidate agent and MCP improvements This commit consolidates 17 commits including: - MCP tools enhancements and fixes - Agent system improvements and optimizations - Auth limit and prompt updates - Tool response compression and error tracking - Simple app adaptation - Code quality improvements (TypeScript, ESLint, Zod) - Version type migration to schema - Remove deprecated useRequest2 - Add LLM error tracking - Toolset ID validation fixes --------- Co-authored-by: YeYuheng <57035043+YYH211@users.noreply.github.com> Co-authored-by: xxyyh <2289112474@qq> * 1. 把辅助生成前端上的 system prompt 加入到上下文中 2. mcp工具的前端渲染(图标) 3. 文件读取工具和文件上传进行关联 4. 添加了辅助生成返回格式出错的重试方案 5. ask 不出现在 plan 步骤中 6. 添加了辅助生成的头像和交互 UI * fix:read_file * helperbot ui * ts error * helper ui * delete Unused import * perf: helper bot * lock --------- Co-authored-by: Archer <545436317@qq.com> Co-authored-by: xxyyh <2289112474@qq> * fix date variable required & model auth (#6386) * fix date variable required & model auth * doc * feat: add chat id to finish callback * fix: iphone safari shareId (#6387) * fix: iphone safari shareId * fix: mcp file list can't setting * fix: reason output field * fix: skip JSON validation for HTTP tool body with variable (#6392) * fix: skip JSON validation for HTTP tool body with variable * doc * workflow fitview * perf: selecting memory * perf: cp api * ui * perf: toolcall auto adapt * fix: catch workflow error * fix: ts * perf: pagination type * remove * ignore * update doc * fix: simple app tool select * add default avatar to logs user * perf: loading user * select dataset ui * rename version * feat: add global/common test * perf: packages/global/common test * feat: package/global/ai,app test * add global/chat test * global/core test * global/core test * feat: packages/global all test * perf: test * add server api test * perf: init shell * perf: init4150 shell * remove invalid code * update doc * remove log * fix: chat effect * fix: plan fake tool (#6398) * 1. 提示词防注入功能 2. 无工具不进入 plan,防止虚拟工具生成 * Agent-dataset * dataset * dataset presetInfo * prefix * perf: prompt --------- Co-authored-by: xxyyh <2289112474@qq> Co-authored-by: archer <545436317@qq.com> * fix: review * adapt kimi2.5 think toolcall * feat: invoke fastgpt user info (#6403) feat: invoke fastgpt user info * fix: invoke fastgpt user info return orgs (#6404) * skill and version * retry helperbot (#6405) Co-authored-by: xxyyh <2289112474@qq> * update template * remove log * doc * update doc * doc * perf: internal ip check * adapt get paginationRecords * tool call adapt * fix: test * doc * fix: agent initial version * adapt completions v1 * feat: instrumentation check * rename skill * add workflow demo mode tracks (#6407) * chore: 统一 skills 目录命名为小写 将 .claude/Skills/ 重命名为 .claude/skills/ 以保持命名一致性。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * add workflow demo mode tracks * code * optimize * fix: improve workflowDemoTrack based on PR review - Add comment to empty catch block for maintainability - Add @param docs to onDemoChange clarifying nodeCount usage - Replace silent .catch with console.debug for dev debugging - Handle appId changes by reporting old data before re-init Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: archer <545436317@qq.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * remove repeat skill * fix(workflow): filter out orphan edges to prevent runtime errors (#6399) * fix(workflow): filter out orphan edges to prevent runtime errors Runtime edges that reference non-existent nodes (orphan edges) can cause unexpected behavior or crashes during workflow dispatch. This change adds a pre-check to filter out such edges before execution begins, ensuring system stability even with inconsistent graph data. * fix(workflow): enhance orphan edge filtering with logging and tests - Refactor: Extract logic to 'filterOrphanEdges' in utils.ts for better reusability - Feat: Add performance monitoring (warn if >100ms) and comprehensive logging - Feat: Support detailed edge inspection in debug mode - Docs: Add JSDoc explaining causes of orphan edges (migration, manual edits) - Test: Add unit tests covering edge cases and performance (1000 edges) Addresses PR review feedback regarding logging, variable naming, and testing." * move code * move code * add more unit test --------- Co-authored-by: archer <545436317@qq.com> * test * perf: test * add server/common/string test * fix: resolve $ref references in MCP tool input schemas (#6395) (#6409) * fix: resolve $ref references in MCP tool input schemas (#6395) * add test code --------- Co-authored-by: archer <545436317@qq.com> * chore(docs): add fastgpt, fastgpt-plugin version choice guide (#6411) * chore(doc): add fastgpt version description * doc * doc --------- Co-authored-by: archer <545436317@qq.com> * fix:dataset cite and description info (#6410) * 1. 添加知识库引用(plan 步骤和直接知识库调用) 2. 提示词框中的@知识库工具 3. plan 中 step 的 description dataset_search 改为中文 * fix: i18n * prompt * prompt --------- Co-authored-by: xxyyh <2289112474@qq> * fix: tool call * perf: workflow props * fix: merge ECharts toolbox options instead of overwriting (#6269) (#6412) * feat: integrate logtape and otel (#6400) * fix: deps * feat(logger): integrate logtape and otel * wip(log): add basic infras logs * wip(log): add request id and inject it into context * wip(log): add basic tx logs * wip(log): migrate * wip(log): category * wip(log): more sub category * fix: type * fix: sessionRun * fix: export getLogger from client.ts * chore: improve logs * docs: update signoz and changelog * change type * fix: ts * remove skill.md * fix: lockfile specifier * fix: test --------- Co-authored-by: archer <545436317@qq.com> * init log * doc * remove invalid log * fix: review * template * replace new log * fix: ts * remove log * chore: migrate all addLog to logtape * move skill * chore: migrate all addLog to logtape (#6417) * update skill * remove log * fix: tool check --------- Co-authored-by: YeYuheng <57035043+YYH211@users.noreply.github.com> Co-authored-by: xxyyh <2289112474@qq> Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: xuyafei1996 <54217479+xuyafei1996@users.noreply.github.com> Co-authored-by: ToukoYui <2331631097@qq.com> Co-authored-by: roy <whoeverimf5@gmail.com>
6.9 KiB
6.9 KiB
name, description
| name | description |
|---|---|
| pr-review | 当用户传入一个 review 的 pr 链接时候,触发该 skill,对 pr 进行代码审查。 |
When to Use This Skill
用户传入一个 review 的 pr 链接
PR Review 代码审查技能
全面审查 Pull Request 的代码质量、安全性、性能和架构设计,提供专业的改进建议
快速开始
# 审查当前分支的 PR
gh pr view
# 审查指定 PR
gh pr view 6324
# 查看变更内容
gh pr diff 6324
工具集成
使用 gh CLI 加速审查
# 查看并审查 PR
gh pr view <number> && gh pr diff <number>
# 添加审查评论
gh pr review <number> --comment -b "我的审查意见"
# 批准 PR
gh pr review <number> --approve
# 请求修改
gh pr review <number> --request-changes
本地测试 PR
# 检出 PR 分支到本地
gh pr checkout <number>
# 运行测试
pnpm test
# 运行 lint
pnpm lint
# 类型检查
pnpm tsc --noEmit
# 启动开发服务器验证
pnpm dev
常见命令参考
# PR 信息查看
gh pr view --json title,body,author,state,files,additions,deletions
# PR diff 查看
gh pr diff
gh pr diff <number> > /tmp/pr.diff # 保存到文件
# PR commits 查看
gh pr view --json commits --jq '.commits[].messageHeadline'
# PR checks 状态
gh pr checks
# PR 评论
gh pr comment <number> --body "评论内容"
# PR 审查提交
gh pr review <number> --approve
gh pr review <number> --request-changes
gh pr review <number> --comment -b "评论内容"
# PR 操作
gh pr merge <number> --squash # Squash merge
gh pr close <number> # 关闭 PR
审查流程
1. 信息收集阶段
自动执行以下步骤:
# 1. 获取 PR 基本信息
gh pr view --json title,body,author,state,headRefName,baseRefName,additions,deletions,files
# 2. 获取 PR 变更 diff
gh pr diff
# 3. 获取 PR 的 commit 历史
gh pr view --json commits
# 4. 检查 CI/CD 状态
gh pr checks
2. 多维度代码审查
按照以下三个维度进行系统性审查:
维度 1: 基本代码质量标准 📐
通用的代码质量标准,适用于所有项目:
- 安全性: 输入验证、权限检查、注入防护、敏感信息保护
- 正确性: 错误处理、边界条件、类型安全
- 性能: 算法复杂度、数据库优化、内存管理
- 可测试性: 测试覆盖、测试质量、Mock 使用
📖 详细指南: code-quality-standards.md
维度 2: FastGPT 风格规范 🎨
FastGPT 项目特定的代码规范和约定:
- API 路由开发: 路由定义、权限验证、错误处理: API 路由开发规范
- 前端组件开发: TypeScript + React、Chakra UI、状态管理: 前端组件开发规范
- 数据库操作: Model 定义、查询优化、索引设计: 数据库操作规范
- 包结构与依赖: 依赖方向、导入规范、类型导出: 包结构与依赖规范
- 日志与可观测性: 统一日志分类、结构化字段、敏感信息、OTEL 导出等审查标准: 日志review 标准
维度 3: 常见问题检查清单 🔍
快速识别和修复常见问题模式:
- TypeScript 问题: any 类型滥用、类型定义不完整、不安全断言
- 异步错误处理: 未处理 Promise、错误信息丢失、静默失败
- React 性能: 不必要的重渲染、渲染中创建对象、缺少 memoization
- 工作流节点: isEntry 未重置、交互历史未清理、白名单遗漏
- 安全漏洞: 注入攻击、XSS、文件上传漏洞
📖 详细清单: common-issues-checklist.md
3. 生成并提交审查报告
PR 审查输出分为两个部分:
- 整体审查报告: 提交为 PR 顶部的总体评论
- 行级代码评论: 直接在代码行的位置添加具体评论
步骤 1: 分析代码并准备评论
在审查过程中,需要为每个问题记录:
- 文件路径: 如
packages/service/core/workflow/dispatch.ts - 行号: 如
L142-L150 - 问题类型: 🔴严重 / 🟡改进 / 🟢优化
- 评论内容: 具体的问题描述和建议
步骤 2: 提交代码审查评论
GitHub CLI 的 gh pr review 命令不支持直接提交行级评论,需要使用 GitHub API。
# 1. 获取仓库信息
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
# 2. 准备 review 数据(包含行级评论)
cat > /tmp/review-data.json << 'EOF'
{
"body": "## 📊 代码审查总结\n\n详细的审查意见请查看下方的行级评论。",
"event": "COMMENT",
"comments": [
{
"path": "packages/service/core/workflow/dispatch.ts",
"line": 142,
"body": "🔴 **严重问题**: 这里缺少错误处理,如果 runtimeNode 为 null 会导致运行时错误。\n\n**建议**:\n```typescript\nif (!runtimeNode) {\n throw new Error(`Runtime node not found: ${nodeId}`);\n}\n```"
},
{
"path": "packages/service/core/workflow/dispatch.ts",
"line": 150,
"body": "🟡 **性能优化**: 建议将此正则表达式编译提取到函数外部,避免每次调用都重新编译。\n\n**建议**:\n```typescript\nconst NODE_ID_PATTERN = /^node_([a-f0-9]+)$/; // 在模块顶部定义\n```"
}
]
}
EOF
# 3. 使用 GitHub API 提交 review
gh api repos/$REPO/pulls/<number>/reviews \
--method POST \
--input /tmp/review-data.json
步骤 3: 生成整体审查报告
# PR Review: {PR Title}
## 📊 变更概览
- **PR 编号**: #{number}
- **作者**: @author
- **分支**: {baseRefName} ← {headRefName}
- **变更统计**: +{additions} -{deletions} 行
- **涉及文件**: {files.length} 个文件
## ✅ 优点
{列出做得好的地方}
## ⚠️ 问题汇总
### 🔴 严重问题 ({count} 个,必须修复)
{简要列出每个严重问题,并在下方添加行级评论}
### 🟡 建议改进 ({count} 个)
{简要列出每个建议}
### 🟢 可选优化 ({count} 个)
{简要列出优化建议}
## 🧪 测试建议
{建议的测试方法}
## 💬 总体评价
- **代码质量**: ⭐⭐⭐⭐☆ (4/5)
- **安全性**: ⭐⭐⭐⭐⭐ (5/5)
- **性能**: ⭐⭐⭐⭐☆ (4/5)
- **可维护性**: ⭐⭐⭐⭐☆ (4/5)
## 🚀 审查结论
{建议: 通过/需修改/拒绝}
---
## 📍 详细代码评论
已在以下位置添加了具体的行级评论:
{列出所有添加了行级评论的位置}
步骤 4: 提交整体审查报告
通过 GitHub CLI 提交整体审查报告到评论区。
审查命令快速参考:
| 场景 | 命令 |
|---|---|
| 批准 PR | gh pr review <number> --approve |
| 请求修改 | gh pr review <number> --request-changes |
| 一般评论 | gh pr review <number> --comment |
| 从文件提交 | gh pr review <number> --body-file /tmp/review.md |
| 添加普通评论 | gh pr comment <number> --body "内容" |
| 撤销审查 | gh pr review <number> --dismiss |