持续 AI
持续 AI 是 MyDeskBot 的强大功能,能够在整个开发工作流程中提供自动化的、持续的 AI 辅助。本指南解释如何设置和利用持续 AI 来简化您的开发流程。
什么是持续 AI?
持续 AI 监控您的开发活动并主动提供帮助,而无需明确的提示。它可以:
- 自动审查代码更改
- 建议改进和优化
- 检测潜在问题和错误
- 提供上下文相关的文档
- 自动化重复任务
启用持续 AI
基本设置
在配置中启用持续 AI:
yaml
# .mydeskbot/config.yaml
continuousAI:
enabled: true
watchPaths:
- "src/**/*"
- "tests/**/*"
ignorePaths:
- "node_modules/**/*"
- ".git/**/*"
- "dist/**/*"触发事件
配置哪些事件触发持续 AI:
yaml
continuousAI:
enabled: true
triggers:
- eventType: "fileSave"
paths:
- "src/**/*.js"
- "src/**/*.ts"
- eventType: "gitCommit"
branches:
- "main"
- "develop"
- eventType: "pullRequest"
providers:
- "github"
- "gitlab"工作流程自动化
代码审查自动化
设置自动代码审查:
yaml
continuousAI:
enabled: true
workflows:
- name: "code-review"
trigger:
eventType: "fileSave"
paths:
- "src/**/*.js"
- "src/**/*.ts"
actions:
- action: "reviewCode"
rules:
- "security-first"
- "performance-optimized"
- "coding-standards"
- action: "suggestImprovements"
- action: "documentChanges"测试辅助
自动生成和更新测试:
yaml
continuousAI:
enabled: true
workflows:
- name: "test-assistance"
trigger:
eventType: "fileSave"
paths:
- "src/**/*.js"
actions:
- action: "generateUnitTests"
targetPath: "tests/unit/{{fileName}}.test.js"
- action: "updateExistingTests"
paths:
- "tests/unit/**/*.test.js"文档更新
保持文档与代码更改同步:
yaml
continuousAI:
enabled: true
workflows:
- name: "documentation-sync"
trigger:
eventType: "fileSave"
paths:
- "src/**/*.js"
actions:
- action: "updateAPI docs"
targetPath: "docs/api/{{fileName}}.md"
- action: "updateREADME"
targetPath: "README.md"自定义工作流程
定义工作流程
为您的特定需求创建自定义工作流程:
yaml
continuousAI:
enabled: true
workflows:
- name: "frontend-workflow"
description: "前端开发工作流程"
trigger:
eventType: "fileSave"
paths:
- "src/components/**/*.jsx"
- "src/pages/**/*.jsx"
conditions:
- branch: "feature/*"
actions:
- action: "lintCode"
tool: "eslint"
- action: "reviewAccessibility"
- action: "optimizePerformance"
- action: "notifyTeam"
recipients:
- "frontend-team@company.com"操作类型
工作流程可用的操作类型:
yaml
workflows:
- name: "comprehensive-workflow"
trigger:
eventType: "fileSave"
actions:
# 代码分析操作
- action: "reviewCode"
- action: "suggestImprovements"
- action: "detectBugs"
- action: "securityScan"
# 文档操作
- action: "generateDocs"
- action: "updateWiki"
# 测试操作
- action: "generateTests"
- action: "runTests"
# 通知操作
- action: "sendNotification"
recipients:
- "team@company.com"
message: "检测到新的代码更改并已审查"
# 集成操作
- action: "createTicket"
system: "jira"
project: "DEV"
type: "Task"与开发工具集成
Git 集成
自动化 Git 工作流程:
yaml
continuousAI:
enabled: true
workflows:
- name: "git-automation"
trigger:
eventType: "gitCommit"
branches:
- "main"
actions:
- action: "validateCommit"
- action: "generateChangelog"
- action: "createReleaseNotes"
- action: "notifyTeam"
recipients:
- "dev-team@company.com"最佳实践
工作流程设计
- 从简单开始:从基本工作流程开始并添加复杂性
- 明确触发器:明确定义何时触发操作
- 限制范围:专注于关键任务以避免噪音
- 监控结果:跟踪工作流程的有效性
性能优化
- 使用过滤:仅在必要时触发操作
- 异步执行:不要阻塞开发工作流程
- 缓存结果:避免重复的昂贵操作
- 批处理操作:将相似操作分组在一起
下一步
在设置持续 AI 后,探索这些相关指南: