這個快速入門指南將引導你安裝 GitHub Copilot 現代化代理程式,並用它現代化一個範例應用程式。
先決條件
- GitHub Copilot 訂閱方案:免費、Pro、Pro+、商業或企業方案。 請參閱副駕駛計畫。
- GitHub CLI:安裝 GitHub CLI
gh以用於認證,或安裝v2.45.0以上的版本。 請參見 安裝GH。
平台需求
- Windows:x64 或 ARM64。
-
Linux:x64 或 ARM64,搭載
glibc2.27 或更新版本(Ubuntu 18.04 或更新,Debian 10 或更新,Fedora 29 或更新,Azure Linux 2.0 或更新)。 - macOS:Apple Silicon 或 Intel。
安裝現代化代理程式
請使用以下指令安裝現代化代理程式或更新至最新版本。
使用下列其中一個選項:
選項一 - Winget(推薦):
winget install GitHub.Copilot.modernization.agent
無提示的靜音安裝:
winget install GitHub.Copilot.modernization.agent --silent
選項二 - PowerShell one-liner:
iex (irm 'https://raw.githubusercontent.com/microsoft/modernize-cli/main/scripts/install.ps1')
選項三 - 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。評估申請情況。
- 依照指示設定評量選項(或按 Enter 鍵使用預設值)。
- 檢視你的選擇並按 Enter 開始評估。
- 等評估完成。
評估結果會儲存於 .github\modernize\assessment\ 的您的專案目錄中。 代理會分析你的程式碼、相依性與設定,以識別:
- 過時的框架版本
- 已棄用的 API
- 雲端相容性問題
- 移民機會
步驟二:制定現代化計畫
評估結束後,客服會提示您根據所識別的問題制定現代化計畫:
○ 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 以修改、重新排序、新增或移除任務,然後再執行計畫。
步驟三:執行現代化計畫
確認計畫後,確認你想執行該計畫。
○ 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 漏洞。
- 提交變更。
步驟四:檢視結果
執行完成後,你可以檢視代理人在合併前所做的所有變更:
檢視變更:檢查目前分支的修改。
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 現代化回饋表。