跳至主要内容

6 篇文章 含有標籤「GitHub Copilot」

檢視所有標籤

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 或網路資源存取需更新允許列表。

TechSummary 2025-07-01

· 閱讀時間約 5 分鐘
OpenAI
AI Assistant

從創意到PR:GitHub Copilot的代理式工作流程指南 🤖🚀

來源: https://github.blog/ai-and-ml/github-copilot/from-idea-to-pr-a-guide-to-github-copilots-agentic-workflows/

內容整理:

  • 作者利用Copilot的代理式工作流程,加速將模糊需求轉化為issue並自動產生PR,涵蓋Next.js與SwiftUI專案。
  • 介紹主要功能包括:Coding Agent、定制對話模式(Custom chat modes)、遠端MCP伺服器(Remote MCP Server)與Copilot代理模式。
  • 使用流程:
    1. 在Copilot Chat中描述需求,產生issue。
    2. 將issue指派給Copilot,啟動Coding Agent自動生成分支與PR。
    3. 重點在review、測試後手動合併,避免盲目交付。
  • 功能亮點:
    • Coding Agent:issue轉成PR,處理重複工序。
    • Custom chat modes:包裝指令與工具,簡化團隊操作。
    • Remote MCP Server:免安裝,安全存取GitHub資源,包括issue與PR。
    • Copilot代理模式:同步協作助手,推薦、編輯與執行任務。
  • 實作範例:在VS Code中用Prompt建立issue,Coding Agent自動產生PR,進行評審,甚至可以用註解指示進一步修改。

重點整理

  • 代理式工作流程能大幅提昇開發效率,尤其在多專案、多語言的情境下。
  • 設定與管理:需啟用Copilot的Coding agent、定制對話模式,並配置遠端MCP伺服器。
  • 建議:重點放在範圍明確的issue與review,避免過度依賴自動化。

TechSummary 2025-06-25

· 閱讀時間約 3 分鐘
OpenAI
AI Assistant

從配對到共同工程師:GitHub Copilot的自主流程願景 🤖

Source: https://github.blog/news-insights/product-news/from-pair-to-peer-programmer-our-vision-for-agentic-workflows-in-github-copilot/

本篇闡述GitHub Copilot不僅是助理,更朝向具有自治能力的AI代理發展。AI代理可以獨立解決問題、動態協作,並主動提升程式碼品質,進一步支持高層決策,讓開發者專注於策略。當前已有Agent模式(同步協作)和Coding agent(異步處理任務)兩種形式,未來會透過更智慧、透明、模組化的架構,實現更彈性的工作流程。