本快速入门将指导你安装 GitHub Copilot 现代化代理,并使用它实现示例应用程序的现代化。
先决条件
- GitHub Copilot 订阅:免费、Pro、Pro+、Business 或企业计划。 请参阅 Copilot 计划。
-
GitHub CLI:安装 GitHub CLI(
gh)进行身份验证或更高版本v2.45.0。 请参阅 安装 gh。
平台要求
- Windows:x64 或 ARM64。
-
Linux:具有
glibc2.27 或更高版本的 x64 或 ARM64(Ubuntu 18.04 或更高版本、Debian 10 或更高版本、Fedora 29 或更高版本、Azure Linux 2.0 或更高版本)。 - macOS:Apple Silicon 或 Intel。
安装现代化代理
使用以下命令安装现代化代理或更新到最新版本。
使用以下选项之一:
选项 1 - Winget (建议):
winget install GitHub.Copilot.modernization.agent
对于静默安装,无需提示:
winget install GitHub.Copilot.modernization.agent --silent
选项 2 - PowerShell 单行命令:
iex (irm 'https://raw.githubusercontent.com/microsoft/modernize-cli/main/scripts/install.ps1')
选项 3 - MSI 安装程序:
从 GitHub 发布页下载并运行最新的 MSI。
注释
安装后,打开新终端,使 modernize 命令在 PATH 上可用。 这些命令适用于初始安装和更新到最新版本。 将来的版本中将提供专用版本更新命令。
验证安装:
modernize --version
获取示例应用程序
对于本快速入门,请使用示例应用程序。 选择 Java 或 .NET:
git clone https://github.com/Azure-Samples/PhotoAlbum-Java.git
cd PhotoAlbum-Java
git checkout -b modernize
使用交互模式
最简单的入门方法是使用交互式模式。 首先,使用 GitHub CLI 进行身份验证:
gh auth login
然后,运行现代化代理:
modernize
此时会显示主菜单:
○ How would you like to modernize your Java app?
> 1. Assess application
Analyze the project and identify modernization opportunities
2. Create modernization plan
Generate a structured plan to guide the agent
3. Execute modernization plan
Run the tasks defined in the modernization plan
步骤 1:评估应用程序
- 选择 1。评估应用程序。
- 按照提示配置评估选项(或按 Enter 以使用默认值)。
- 查看所选内容,然后按 Enter 开始评估。
- 等待评估完成。
评估结果将保存到 .github\modernize\assessment\ 项目目录中。 代理将分析代码、依赖项和配置,以确定:
- 过时的框架版本
- 弃用的 API
- 云兼容性问题
- 迁移机会
步骤 2:创建现代化计划
评估完成后,代理会提示你根据已确定的问题创建现代化计划:
○ How would you like to continue?
> 1. Create modernization plan
Generate a plan.md file according to the identified issues
2. Return to main menu
- 选择 1。创建现代化计划。
- 输入计划名称或按 Enter 以使用默认名称。
- 输入您的现代化目标作为提示 默认情况下,提示为
References the assessment summary and creates plan,用于根据评估结果创建计划。 可以将它替换为任何其他迁移请求,例如:migrate the database to Azure PostgreSQLupgrade to Spring Boot 3deploy to Azure Container Apps
- 按 Enter 生成计划。
代理分析代码库并生成:
-
计划文件 (
.github/modernize/{plan-name}/plan.md):详细的策略和方法。 -
任务列表 (
.github/modernize/{plan-name}/tasks.json):可执行步骤的细分。
小窍门
可以手动编辑 plan.md 以添加澄清或调整详细信息。 还可以在执行计划之前更新 tasks.json 以修改、重新排序、添加或删除任务。
步骤 3:执行现代化计划
验证计划后,确认是否要执行该计划。
○ How would you like to continue?
> 1. Execute modernization plan
Run the tasks defined in the modernization plan
2. Return to main menu
- 选择 1。执行现代化计划。
- 按 Enter 执行计划。
- 在代理应用更改时监视进度。
代理按顺序执行每个任务:
- 根据计划进行代码更改。
- 在每个更改后验证构建。
- 扫描和处理 CVE。
- 提交更改。
步骤 4:查看结果
执行完成后,可以查看代理在合并之前所做的所有更改:
查看更改:检查当前分支上的修改。
git status git diff main创建一个拉取请求:如果您对更改感到满意,请创建一个 PR 以供团队评审。
gh pr create \ --title "Modernization: migrate the app to azure" \ --body "Automated modernization by GitHub Copilot agent"
后续步骤
提供反馈
我们重视你的输入! 如果对新式化代理有任何反馈, 请在 github-copilot-appmod 存储库中创建问题 ,或使用 GitHub Copilot 现代化反馈表单。