共用方式為


GitHub Copilot 現代化代理 CLI 指令

GitHub Copilot 現代化代理提供互動式與非互動式應用程式現代化模式。

指令模式

互動模式

啟動互動式文字使用者介面(TUI)以進行引導式現代化:

modernize

互動模式提供:

  • 現代化工作流程中以選單驅動的導航。
  • 視覺化計畫與進度指標。
  • 設定選項的引導提示。
  • 多資源庫選擇介面。

非互動模式

直接執行特定指令以進行自動化與腳本撰寫:

modernize <command> [options]

以下情況下使用非互動模式:

  • 整合 CI/CD 管線。
  • 自動化批次作業。
  • 腳本現代化工作流程。
  • 在無頭環境中奔跑。

全域選項

所有指令都支援以下全域選項:

Option 說明
--help-h 顯示幫助資訊。
--no-tty 關閉互動提示(無頭模式)。

Commands

評估

進行評估並產生完整的分析報告。

語法

modernize assess [options]

選項

Option 說明 預設值
--source <path> 通往源專案的路徑(相對或絕對局部路徑)。 . (現行目錄)
--output-path <path> 評估結果的自訂輸出路徑。 .github/modernize/assessment/
--issue-url <url> 一個用於更新評估摘要的 GitHub 議題網址。 沒有
--multi-repo 啟用多重回購評估。 掃描第一層次目錄以尋找多個儲存庫。 Disabled
--model <model> 要用的大型語言模型。 claude-sonnet-4.6
--delegate <delegate> 執行模式: local (此機器)或 cloud (雲端編碼代理)。 local
--wait 等待委派任務完成並產生結果(僅在 時 --delegate cloud有效)。 Disabled
--force 強制重新啟動委派,忽略正在進行的任務(僅在 --delegate cloud下有效)。 Disabled

Examples

現行名錄基本評估:

modernize assess

用自訂輸出位置評估:

modernize assess --output-path ./reports/assessment

評估並更新 GitHub 問題並附上結果:

modernize assess --issue-url https://github.com/org/repo/issues/123

評估特定專案目錄:

modernize assess --source /path/to/project

評估目前目錄中的多個儲存庫:

modernize assess  --multi-repo

Output

評估結果如下:

  • 報告檔案:詳細分析,格式為 JSON、MD 及 HTML 格式。
  • 摘要:主要發現與建議。
  • 議題更新 (如果你提供 --issue-url):GitHub 議題評論及摘要。

計畫創建

根據自然語言提示建立現代化計畫,描述您的現代化目標。

語法

modernize plan create <prompt> [options]

引數

Argument 說明
<prompt> 現代化目標的自然語言描述(必備)。

選項

Option 說明 預設值
--source <path> 通往應用程式原始碼的路徑。 目前目錄
--plan-name <name> 現代化計畫的名稱。 modernization-plan
--language <lang> 程式語言(javadotnet、 或 python)。 自動偵測
--overwrite 覆寫同名的現有計畫。 Disabled
--model <model> 要用的大型語言模型。 claude-sonnet-4.6

Examples

制定遷移計畫:

modernize plan create "migrate from oracle to azure postgresql"

產生一個自訂名稱的升級方案:

modernize plan create "upgrade to spring boot 3" --plan-name spring-boot-upgrade

產生部署計畫:

modernize plan create "deploy the app to azure container apps" --plan-name deploy-to-aca

完整選項範例:

modernize plan create "upgrade to .NET 8" \
    --source /path/to/project \
    --plan-name dotnet8-upgrade \
    --language dotnet \
    --issue-url https://github.com/org/repo/issues/456

提示範例

框架升級:

  • upgrade to spring boot 3
  • upgrade to .NET 10
  • upgrade to JDK 21
  • migrate from spring boot 2 to spring boot 3

資料庫遷移:

  • migrate from oracle to azure postgresql
  • migrate from SQL Server to azure cosmos db
  • switch from MySQL to azure database for mysql

雲端遷移:

  • migrate from on-premises to azure
  • containerize and deploy to azure container apps
  • migrate from rabbitmq to azure service bus

部署:

  • deploy to azure app service
  • deploy to azure kubernetes service
  • set up CI/CD pipeline for azure

Output

該指令會產生:

  • 計畫檔案.github/modernize/{plan-name}/plan.md):詳細現代化策略,包括:

    • 背景與目標
    • 方法與方法
    • 說明
  • 任務清單.github/modernize/{plan-name}/tasks.json):可執行任務的結構化分解,包含:

    • 任務說明
    • 可運用的技能
    • 成功準則

小提示

你可以手動編輯兩者 plan.md ,並在 tasks.json 生成後重新調整,在執行前自訂方法。

計畫執行

執行由 制定的 modernize plan create現代化計畫。

語法

modernize plan execute [prompt] [options]

引數

Argument 說明
[prompt] 執行時可選的自然語言指令(例如「跳過測試」)。

選項

Option 說明 預設值
--source <path> 通往應用程式原始碼的路徑。 目前目錄
--plan-name <name> 執行計畫的名稱。 modernization-plan
--language <lang> 程式語言(javadotnet)。 自動偵測
--model <model> 要用的大型語言模型。 claude-sonnet-4.6
--delegate <delegate> 執行模式: local (此機器)或 cloud (雲端編碼代理)。 local
--force 即使CCA工作進行中,也會強制執行。 Disabled

Examples

互動式執行最新計畫:

modernize plan execute

執行具體計畫:

modernize plan execute --plan-name spring-boot-upgrade

使用額外指令執行:

modernize plan execute "skip the test" --plan-name spring-boot-upgrade

CI/CD 的無頭模式執行:

modernize plan execute --plan-name spring-boot-upgrade --no-tty

執行行為

執行過程中,代理人:

  1. 載入計畫:讀取計畫與任務清單 .github/modernization/{plan-name}/

  2. 執行任務:依序處理任務清單中的每個任務:

    • 套用程式碼轉換。
    • 變更後驗證建置。
    • 掃描 CVE。
    • 提交帶有描述性訊息的變更。
  3. 產生摘要:提供所有變更與結果的報告。

Output

  • 提交歷史:每個執行任務的詳細提交紀錄。
  • 摘要報告:概述變更、成功及遇到的問題。
  • 建置驗證:確認應用程式成功建置。
  • CVE 報告:已識別並解決安全漏洞。

升級

能在單一指令中執行端對端的升級流程——規劃與執行。

語法

modernize upgrade [prompt] [options]

引數

Argument 說明
[prompt] 目標版本,例如 Java 17Spring Boot 3.2.NET 10。 預設是最新的 LTS。

選項

Option 說明 預設值
--source <source> 路徑到來源專案(相對或絕對局部路徑)。 . (現行目錄)
--delegate <delegate> 執行模式: local (此機器)或 cloud (雲端編碼代理)。 local
--model <model> 要用的大型語言模型。 claude-sonnet-4.6

Examples

在目前目錄上執行 upgrade

modernize upgrade "Java 17"
modernize upgrade ".NET 10"

針對特定專案進行 upgrade

modernize upgrade "Java 17" --source /path/to/project

使用雲端編碼代理程式來執行 upgrade

modernize upgrade "Java 17" --delegate cloud

help

提供協助與資訊指令。

語法

modernize help [command]

Commands

命令 說明
models 列出可用的大型語言模型及其乘數。

Examples

可選車型列表:

modernize help models

設定 CLI

透過使用現代化代理程式,你可以透過 JSON 檔案和環境變數來自訂應用程式行為。

環境變數

設定環境變數覆蓋所有其他配置範圍:

變數 說明 預設值
MODERNIZE_LOG_LEVEL 伐木層級(noneerrorwarninginfodebug, , ) all info
MODERNIZE_MODEL 要用的大型語言模型。 claude-sonnet-4.6
MODERNIZE_COLLECT_TELEMETRY 啟用或停用遙測收集。 true

範例:

export MODERNIZE_LOG_LEVEL=debug
export MODERNIZE_MODEL=claude-sonnet-4.6
modernize assess

使用者設定

將使用者專屬偏好設定儲存在 ~/.modernize/config.json.github/modernize/config.json

{
  "model": "claude-sonnet-4.6",
  "log_level": "info",
  "trusted_folders": [
    "/path/to/trusted/project",
  ]
}

trusted_folders 屬性指定了哪些資料夾被信任,可以在互動模式下使用 LLM。

備註

環境變數優先權最高,其次是使用者設定,最後是儲存庫設定。 使用環境變數來覆蓋 CI/CD,並根據個人偏好設定使用者設定。

多儲存庫配置

建立 .github/modernize/repos.json 一個檔案以啟用多儲存庫模式:

[
  {
    "name": "PhotoAlbum-Java",
    "url": "https://github.com/Azure-Samples/PhotoAlbum-Java.git"
  },
  {
    "name": "PhotoAlbum",
    "url": "https://github.com/Azure-Samples/PhotoAlbum.git"
  }
]

repos.json檔案安裝完成後,請使用以下指令在所有已設定的儲存庫間操作:

在地評估所有資料庫:

modernize assess

使用雲端編碼代理工具評估所有資料庫:

modernize assess --delegate cloud

透過使用 Cloud Coding Agent 升級所有儲存庫:

modernize upgrade --delegate cloud

下一步