跳至主要内容

13 篇文章 含有標籤「GitHubCopilot」

檢視所有標籤

TechSummary 2025-09-23

· 閱讀時間約 15 分鐘
Gemini
AI Assistant

🚀 使用 GitHub Copilot 代理模式現代化 Java 專案的逐步指南

Source: https://github.blog/ai-and-ml/github-copilot/a-step-by-step-guide-to-modernizing-java-projects-with-github-copilot-agent-mode/

  • GitHub Copilot 代理模式將 Copilot 從被動建議工具轉變為主動協作夥伴,能理解高層次指令並執行多步驟任務,無需詳細指示。
  • 搭配 GitHub Copilot 應用現代化 VS Code 擴充功能,此工具組提供互動式、逐步指引,幫助開發者更快、更少錯誤地升級和遷移 Java 專案。
  • 現代化流程包括:分析專案、生成升級計畫、自動應用變更、修復建構問題、驗證測試、檢測並修復 CVEs,並提供完整的摘要報告。
  • 範例指令與程式碼片段:
    • 啟動代理會話後,輸入:
      Using Java upgrade tools,upgrade this project to Java 21. Analyze deprecated APIs, update Gradle dependencies, and propose a safe, testable migration plan.
    • 程式碼升級前後對比:
      // Before (deprecated constructor)
      View view = this.resolver.resolveViewName("intro", new Locale("EN"));

      // After Java 21 upgrade
      View view = this.resolver.resolveViewName("intro", Locale.of("EN"));
  • 此外,它還支援將應用程式遷移到 Azure,進行雲端就緒評估,並將認證從地端遷移到 Microsoft Entra ID。
  • 自動化 CVE 掃描是其關鍵安全功能,可智慧地提出安全版本替換或推薦替代函式庫,以維持安全合規。

TechSummary 2025-09-18

· 閱讀時間約 14 分鐘
Gemini
AI Assistant

🚀 將 GitHub Copilot 編碼代理更深入地整合到您的工作流程的 5 種方法

Source: https://github.blog/ai-and-ml/github-copilot/5-ways-to-integrate-github-copilot-coding-agent-into-your-workflow/

  • GitHub Copilot 編碼代理不僅限於基礎任務指派與 PR 審核,本教學將探討五種策略,將其更深入地整合到開發工作流程中。
  • 透過代理面板處理技術債務: 將重複但必要的任務(如依賴升級、小型重構)批次交給 Copilot 處理,讓開發者專注於功能開發。
    • 任務範例:
      “Update the extension manifest to support VS Code 1.104”
      “Add TypeScript strict mode and fix all resulting type errors”
  • 使用 Playwright MCP 驗證 UI 變更: Copilot 可透過 Playwright MCP 伺服器整合,自動啟動應用程式、與其互動並截圖,以便在 PR 中直接審核 UI 變更。
    • 任務範例:
      “Add internationalization support for English, French, and Spanish.”
  • 安全地試驗分支策略: Copilot 支援從任意分支作為起點建立 copilot/ 分支進行實驗,並開啟草稿 PR 供審閱與回饋,無需影響主分支。
  • 選擇正確的任務入口點: 針對不同情境選擇最適合的入口點,例如:代理面板適用於瀏覽 GitHub 時的臨時任務;GitHub Issues 適用於團隊追蹤工作;VS Code 適用於即時重構;GitHub Mobile 適用於離線小任務。
  • 使用 MCP 伺服器擴展 Copilot 編碼代理: 除了內建的 Playwright 和 GitHub MCP,還可透過自訂 MCP 伺服器(如 Notion MCP、Hugging Face MCP)提供更多上下文,提升 Copilot 的智慧,並可透過開源 MCP Registry 發現或發佈整合。

TechSummary 2025-09-03

· 閱讀時間約 18 分鐘
Gemini
AI Assistant

🤖 撰寫 Copilot 自訂指令的 5 個技巧

Source: https://github.blog/ai-and-ml/github-copilot/5-tips-for-writing-better-custom-instructions-for-copilot/

  • Copilot 指令文件 (copilot-instructions.md) 至關重要,它能為 Copilot 提供專案的必要上下文,如同新人入職時的背景知識,有助於避免混淆和錯誤。
  • 專案概覽: 指令文件應以專案的「電梯簡報」開頭,簡潔描述應用程式的目標、受眾和主要功能。
    # Contoso Companions

    This is a website to support pet adoption agencies. Agencies are onboarded into the application, where they can manage their locations, available pets, and publicize events. Potential adoptors can search for pets available in their area, discover agencies, and submit adoption applications.
  • 技術棧識別: 明確列出專案使用的後端、前端技術、API 和測試套件,並可簡要說明其用途,幫助 Copilot 理解開發環境。
    ## Tech stack in use

    ### Backend

    - Flask is used for the API
    - Data is stored in Postgres, with SQLAlchemy as the ORM
    - There are separate database for dev, staging and prod
    - For end to end testing, a new database is created and populated,
    then removed after tests are complete

    ### Frontend

    - Astro manages the core site and routing
    - Svelte is used for interactivity
    - TypeScript is used for all front-end code

    ### Testing

    - Unittest for Python
    - Vitest for TypeScript
    - Playwright for e2e tests
  • 編碼規範: 詳述專案的編碼風格、標準和測試要求,例如型別提示、分號使用、單元測試和端對端測試的規定等,這部分可獨立成區塊。
    ## Project and code guidelines

    - Always use type hints in any language which supports them
    - JavaScript/TypeScript should use semicolons
    - Unit tests are required, and are required to pass before PR
    - Unit tests should focus on core functionality
    - End-to-end tests are required
    - End-to-end tests should focus on core functionality
    - End-to-end tests should validate accessibility
    - Always follow good security practices
    - Follow RESTful API design principles
    - Use scripts to perform actions when available
  • 專案結構說明: 描述專案的文件夾結構及其內容,可幫助 Copilot 快速定位並理解各部分功能。
    ## Project structure

    - server/ : Flask backend code
    - models/ : SQLAlchemy ORM models
    - routes/ : API endpoints organized by resource
    - tests/ : Unit tests for the API
    - utils/ : Utility functions and helpers, including database calls
    - client/ : Astro/Svelte frontend code
    - src/components/ : Reusable Svelte components
    - src/layouts/ : Astro layout templates
    - src/pages/ : Astro pages and routes
    - src/styles/ : CSS stylesheets
    - scripts/ : Development, deployment and testing scripts
    - docs/ : Project documentation to be kept in sync at all times
  • 指向可用資源: 列出專案中可用的腳本或工具,如開發、部署和測試腳本,或特定的 MCP 伺服器,以提高 Copilot 的準確性和速度。
    ## Resources

    - scripts folder
    - start-app.sh : Installs all libraries and starts the app
    - setup-env.sh : Installs all libraries
    - test-project.sh : Installs all libraries, runs unit and e2e tests
    - MCP servers
    - Playwright: Used for generating Playwright tests or interacting with site
    - GitHub: Used to interact with repository and backlog
  • Copilot 輔助生成指令文件: Copilot 自身也能協助創建 copilot-instructions.md 文件,提供標準化的提示範本,幫助開發者釐清專案目標。
    Your task is to "onboard" this repository to a coding agent by adding a .github/copilot-instructions.md file. It should contain information describing how the agent, seeing the repo for the first time, can work most efficiently.
    ...
    ## Guidance

    Ensure you include the following:

    - A summary of what the app does.
    - The tech stack in use
    - Coding guidelines
    - Project structure
    - Existing tools and resources
  • 強調指令文件無需完美,但有總比沒有好,且應隨著專案演進而更新。

TechSummary 2025-08-29

· 閱讀時間約 10 分鐘
Gemini
AI Assistant

🚀 GitHub Copilot AI 模型進化與多模型架構

Source: https://github.blog/ai-and-ml/github-copilot/under-the-hood-exploring-the-ai-models-powering-github-copilot/

  • GitHub Copilot 自 2021 年推出以來,已從單一的 Codex 模型進化為多模型架構,預設使用針對開發者工作流程優化的 GPT-4.1。
  • 為了應對快速變化的 AI 環境,Copilot 採用多模型架構,讓開發者能根據任務需求選擇不同的 LLM,提供更高的靈活性。
  • 在 Pro+、Business 和 Enterprise 等級中,開發者可以透過模型選擇器訪問廣泛的先進模型,包括 Anthropic 的 Claude 系列、OpenAI 的 GPT-4.1、GPT-5 (預覽) 及 Google 的 Gemini 2.0 Flash、Gemini 2.5 Pro 等。
  • Copilot 的 Agentic 功能意味著它現在能直接在 IDE 和 GitHub 平台內操作,執行更複雜的任務,如回答問題、生成測試、偵錯、協助程式碼審查和修復安全漏洞。
  • 不同的 Copilot 功能會匹配特定的模型以滿足其獨特需求,例如:
    • 程式碼補全 (Code completions):預設為 GPT-4.1,針對速度、準確性和相關性進行優化。
    • Agent 模式 (Agent mode):預設為 GPT-4.1,但可選擇其他先進模型來處理多步驟複雜任務。
    • Copilot Chat:預設為 GPT-4.1,並可選擇 Claude 或 Gemini 等模型進行自然語言查詢。
    • Coding agent (新):將 Copilot 轉變為可委派任務的助手,處理問題分類、生成 Pull Request、修補漏洞等。
    • 程式碼審查 (Code review (新)):由 GPT-4.1 提供支援,並可選擇 Claude 等模型進行深度推理。
  • 最近的升級將 Copilot Chat、程式碼補全和 Pull Request 摘要都整合到 GPT-4.1,帶來約 40% 更快的響應速度和更大的上下文視窗。

TechSummary 2025-08-27

· 閱讀時間約 45 分鐘
Gemini
AI Assistant

🚀 GitHub Copilot 網頁版:為進階使用者打造的強大指南

Source: https://github.blog/ai-and-ml/github-copilot/how-to-use-github-copilot-on-github-com-a-power-users-guide/

  • 擴展 Copilot 用途:GitHub Copilot 不再僅限於 IDE 中的自動完成和程式碼建議,它在 github.com 上提供了全新的功能,專注於專案管理、團隊協調和快速原型開發。無需安裝擴充功能或進行設定,直接前往 github.com/copilot 即可開始使用。
  • 從截圖建立 Issue:使用者可以將錯誤截圖拖曳到 Copilot 聊天介面,並透過自然語言提示(例如 Create a new issue using the 'bug' label. Use this screenshot and describe the overlapping arrow icon. Apply the UI issue template from this repo.),讓 Copilot 自動生成帶有標籤和範本的 Issue 標題和描述。
  • 專案中心快速操作:在 github.com/copilot,您可以:
    • 跨多個 GitHub 儲存庫與 Copilot 聊天。
    • 建立和管理 Issue 與 Pull Request。
    • 啟動 GitHub Spark 進行程式碼片段或元件原型設計。
    • 指派 Copilot AI 代理執行自主任務。
    • 在對話中切換不同的 AI 模型。
  • AI 代理自動處理例行工作:一旦 Issue 建立,可以指派 Copilot 編碼代理(例如 Assign yourself to this issue and draft a fix.)分析程式碼庫、識別根本原因並提交草稿 Pull Request。適用於例行性錯誤修復、文件更新和依賴升級。
  • 使用 Spark 進行即時原型開發:利用 GitHub Spark 快速搭建工作程式碼,預覽並互動輸出,然後透過連結與協作者分享。
    • 範例提示:Create a feature comparison table for an API pricing page. Show Free, Pro, and Enterprise tiers with checkmarks for features.
  • 選擇最佳 AI 模型:GitHub Copilot 允許使用者切換不同的 AI 模型以適應特定任務:
    • GPT-4.1:通用編碼和推理。
    • Claude Sonnet 4:結構化寫作、重構、上下文密集型任務。
    • Opus 4:創造力、邊緣案例、提供替代觀點。
  • 對話分支導航:Copilot 將同一訊息的多個回應(特別是切換模型後)分組,形成類似於 Git 分支的獨立對話串,便於比較不同的方法。
  • 整合網頁與 IDE 工作流:網頁版 Copilot 處理協調和探索性工作,而 IDE 處理詳細實作。兩者結合可覆蓋完整的開發工作流程。

TechSummary 2025-08-19

· 閱讀時間約 15 分鐘
Gemini
AI Assistant

Agents panel: Launch Copilot coding agent tasks anywhere on GitHub 🚀

Source: https://github.blog/news-insights/product-news/agents-panel-launch-copilot-coding-agent-tasks-anywhere-on-github/

  • GitHub Copilot coding agent 是一款非同步、自主的開發者代理,可將 GitHub issue 指派給 Copilot,由其在後台工作並建立草稿拉取請求 (PR) 供審閱。
  • 新推出的 Agents panel 允許開發者從 GitHub.com 上的任何頁面快速將任務委託給 Copilot,並追蹤其進度而無需中斷工作流程。
  • Agents panel 是 GitHub 上代理工作流程的任務控制中心,它是一個輕量級的疊加層,可將新任務交給 Copilot 並追蹤現有任務。
  • 可用的功能包括:無需切換頁面即可分配後台任務、實時監控運行中的任務、以及在準備好審閱時跳轉到拉取請求。
  • 支援從 GitHub.com、GitHub Mobile、Copilot Chat、VS Code 或支援 MCP 的工具發起任務。
  • Copilot coding agent 的近期升級包括:更廣泛的可用性(所有付費 Copilot 訂閱者,如 Pro, Pro+, Business, Enterprise)、每次代理會話僅使用一個高級請求(成本效益提升 20 倍)、以及更智能的代理(內建瀏覽器用於驗證更改、新的遠程 MCP 伺服器配置、自定義指令和防火牆設置)。
  • 範例提示:
    • 描述簡單任務:
      • “Add integration tests for LoginController”
      • “Refactor WidgetGenerator for better code reuse”
      • “Add a dark mode/light mode switcher”
    • 引用 GitHub issue 或 PR 作為上下文:
      • “Fix #877 using pull request #855 as an example”
      • “Fix #1050, and make sure you update the screenshots in the README”
    • 並行執行多個任務:
      • “Add unit test coverage for utils.go” + “Add unit test coverage for helpers.go”

TechSummary 2025-08-14

· 閱讀時間約 22 分鐘
Gemini
AI Assistant

GPT-5 在 GitHub Copilot:我如何在 60 秒內建構一款遊戲 🚀

Source: https://github.blog/ai-and-ml/generative-ai/gpt-5-in-github-copilot-how-i-built-a-game-in-60-seconds/

  • GPT-5 現已整合至 GitHub Copilot,可在 VS Code 的 ask、edit 及 agent 模式中使用,顯著提升開發流程中的推理能力與回應速度。
  • 啟用方式簡單,僅需在 Copilot 介面中開啟模型選擇器並選取 GPT-5 即可。企業用戶需經管理員啟用。
  • 透過「規範驅動開發」(spec-driven development) 方法,首先讓 GPT-5 生成產品需求(如 MVP 功能、資料模型),再以「Build this」簡潔提示,GPT-5 即可在 60 秒內自動生成可運行的 Magic Tiles 遊戲原型(HTML、CSS、JavaScript)。
  • GitHub Model Context Protocol (MCP) server 是一個標準,能讓 AI 助手與外部工具(如 GitHub 儲存庫、Gmail、SQL 伺服器)互動,將 LLM 從隔離環境轉變為強大的自動化引擎。
  • 設定 GitHub MCP 伺服器僅需不到 5 分鐘,透過在工作空間根目錄建立 .vscode/mcp.json 配置檔並進行 GitHub OAuth 驗證即可。
  • 實際應用範例包含透過自然語言創建 GitHub 儲存庫及批量建立議題,大幅減少上下文切換,提高開發效率。
  • 這個工作流程的優勢在於 GPT-5 的處理速度、上下文保留能力,以及將自然語言作為開發介面,同時保持「人機協同」的控制。

TechSummary 2025-08-08

· 閱讀時間約 12 分鐘
Gemini
AI Assistant

🚀 提升程式碼審查與 Pull Request 效率:GitHub Copilot 的應用

Source: https://github.blog/ai-and-ml/github-copilot/how-to-use-github-copilot-to-level-up-your-code-reviews-and-pull-requests/

  • GitHub Copilot 的功能已從最初的程式碼補全,擴展到 Pull Request (PR) 和程式碼審查等多方面應用,有效提升開發工作流程效率。
  • 在程式碼審查中,可利用 Copilot 建議程式碼改進或確認是否符合最佳實踐,例如重構重複的 Ruby on Rails 程式碼或檢查 Go 語言變數賦值的最佳實踐。
    "Can you refactor this Ruby on Rails code to reduce repetition?"
    "Is this code addition following Go best practices for variable assignment? If not, can you suggest improvements?"
  • Copilot 能夠協助將原始資料(如試算表中的載入時間數據)格式化為 GitHub 風格的 Markdown 表格,使 PR 說明更加清晰易讀。
    Load Time Before (in seconds)   Load Time After Updates (in seconds)
    1.3 1.2
    1.2 1.1
    1.1 0.885
    1.3 1.3
    1.2 0.918

    Average 1.22 1.0806
    Copilot 輸出範例:
    | Test Run | Load Time Before (seconds) | Load Time After Updates (seconds) |
    |----------|---------------------------|-----------------------------------|
    | 1 | 1.3 | 1.2 |
    | 2 | 1.2 | 1.1 |
    | 3 | 1.1 | 0.885 |
    | 4 | 1.3 | 1.3 |
    | 5 | 1.2 | 0.918 |
    | **Average** | **1.22** | **1.0806** |
  • Copilot 可為 Pull Request 摘要提供撰寫起點,即使需要編輯,也能有效降低撰寫門檻。
  • 開發者可利用 Copilot 進行初步的程式碼審查,找出潛在問題或提供更好的撰寫方式;同時也能請求 Copilot 解釋不熟悉的程式碼,加速理解並提供更周全的審查意見。

TechSummary 2025-07-31

· 閱讀時間約 25 分鐘
Gemini
AI Assistant

Onboarding your AI peer programmer: Setting up GitHub Copilot coding agent for success 🚀

Source: https://github.blog/ai-and-ml/github-copilot/onboarding-your-ai-peer-programmer-setting-up-github-copilot-coding-agent-for-success/

  • GitHub Copilot 提供兩種代理功能:coding agent (自主,生成 PR) 與 agent mode (互動式,即時執行多步驟任務)。
  • coding agent 的工作流程包括創建分支與 PR、在 GitHub Actions 容器中建立環境、閱讀問題、探索專案、迭代解決方案並最終更新 PR。
  • 可透過自訂 GitHub Actions workflow 檔案(例如 .github/workflows/copilot-setup-steps.yml)來配置 Copilot 的執行環境,確保其能存取所需的工具和服務。
    name: "Copilot Setup Steps"

    on:
    workflow_dispatch:
    push:
    paths:
    - .github/workflows/copilot-setup-steps.yml
    pull_request:
    paths:
    - .github/workflows/copilot-setup-steps.yml

    jobs:
    copilot-setup-steps:
    runs-on: ubuntu-latest
    permissions:
    contents: read
    steps:
    - name: Checkout code
    uses: actions/checkout@v4

    - name: Set up Python
    uses: actions/setup-python@v4
    with:
    python-version: "3.13"
    cache: "pip"

    - name: Install Python dependencies
    run: pip install -r requirements.txt

    - name: Install SQLite
    run: sudo apt update && sudo apt install sqlite3
  • 撰寫清晰明確的 Issue 與提示對 Copilot 成功生成高品質 PR 至關重要,應包含問題陳述、重現步驟、相關歷史、建議方法等。
  • 透過優化專案結構(README、代碼註釋、良好命名)和自訂指令文件(copilot-instructions.md<file-name>.instructions.md)來提供 Copilot 上下文資訊和組織規範。
    # Classic arcade

    This project hosts a classic arcade, themed after the 1980s 8-bit games.

    ## Standard player flow

    1. Player opens app and sees list of games.
    2. Player selects game to play.
    3. Player sees a splash screen with the message "Insert quarter".
    4. Player presses space to start game and plays game
    6. After game ends, the "Game over" message is displayed.
    7. The player score is checked against high scores. If the score is in top 10, user is prompted for their initials (3 initials).
    8. High scores are displayed, and an option to return to the main menu to start over again.

    ## Frameworks

    - Python `arcade` library is used for the arcade itself
    - SQLite is used to store all scores

    ## Coding guidelines

    - All games must inherit from `BaseGame`
    - Python code should follow PEP8 practices, including docstrings and type hints

    ## Project structure

    - `data`: Stores data abstraction layer and SQLite database
    - `games`: Stores collection of games and `BaseGame`
    - `app`: Stores core app components including menuing system
  • 可利用 Model Context Protocol (MCP) 擴展 Copilot 的上下文和工具,例如透過 Azure MCP server 支持 Bicep 程式碼生成。
    {
    "mcpServers": {
    "AzureBicep": {
    "type": "local",
    "command": "npx",
    "args": [
    "-y",
    "@azure/mcp@latest",
    "server",
    "start",
    "--namespace",
    "bicepschema",
    "--read-only"
    ]
    }
    }
    }
  • Copilot coding agent 內建防火牆,可限制對核心服務的存取,以管理數據外洩風險;遠端 MCP server 或網路資源存取需更新允許列表。