Skip to content

Repository files navigation

Copilot 設定

集中管理 GitHub Copilot 的自訂設定。依「作用範圍(scope)」分成兩份,各自對應一個同步目標。

原由本儲存庫管理的 Agent Skills 已於 8481b58 遷移至 skills 儲存庫,現已不再隨本專案維護。

Scope 目錄 套用位置 內容
User user/.copilot/ 同步到 %USERPROFILE%\.copilot,對該帳號所有專案生效 與專案無關的使用者層級設定:PowerShell 規則、危險指令攔截、共用子代理
Project project/.github/ 疊進某個 repo 的 .github/,只對該 repo 生效 依賴專案工具鏈的設定:寫檔後的 format / lint、repo-level agents / prompts / workflows

結構

user/.copilot/
├─ copilot-instructions.md                    # PowerShell 優先的環境規則
├─ hooks/
│  ├─ hooks.json                             # preToolUse
│  └─ scripts/block-dangerous.mjs            # PreToolUse:攔截危險指令
└─ agents/generic-test-quality-reviewer.md   # 語言/框架無關的測試品質審查子代理
project/.github/
├─ agents/code-review.agent.md               # repo-level code review agent
├─ hooks/
│  ├─ hooks.json                             # postToolUse / userPromptSubmitted
│  └─ scripts/
│     ├─ format-lint.mjs                     # PostToolUse:寫檔後 format / lint
│     └─ log-prompt.mjs                      # UserPromptSubmit:記錄 prompt log
├─ instructions/.keep                        # 保留 instructions 目錄骨架
├─ prompts/gitignore.prompt.md               # 可重用 prompt
└─ workflows/copilot-setup-steps.yml         # Copilot setup steps
scripts/sync-copilot-scope.ps1               # 同步腳本
sdd/                                         # SDD 流程紀錄(提案 / 任務清單)

同步腳本 scripts/sync-copilot-scope.ps1

需要 PowerShell 7+。所有模式都不會改動來源檔案。

-WhatIf-Diff-Force-Uninstall 對兩種 scope 都適用;其中 -WhatIf-Diff-Uninstall 三者互斥。同步後會在目標寫入 manifest(受管理檔案 + SHA-256),供 -Uninstall 判斷;被使用者修改過的檔案不會被移除。

User Scope

同步 user/.copilot/%USERPROFILE%\.copilot,並把 hooks\hooks.json 裡的 hook 工作目錄佔位字串改寫成實際絕對路徑。

pwsh -NoProfile -File .\scripts\sync-copilot-scope.ps1 -Scope User -WhatIf
pwsh -NoProfile -File .\scripts\sync-copilot-scope.ps1 -Scope User -Diff
pwsh -NoProfile -File .\scripts\sync-copilot-scope.ps1 -Scope User
pwsh -NoProfile -File .\scripts\sync-copilot-scope.ps1 -Scope User -Force
pwsh -NoProfile -File .\scripts\sync-copilot-scope.ps1 -Scope User -Uninstall

目標預設為 %USERPROFILE%\.copilot,可用 -UserScopePath <path> 覆寫。

Project Scope

project/.github/ 進指定 repo 的 .github/-TargetRepo 必填。

pwsh -NoProfile -File .\scripts\sync-copilot-scope.ps1 -Scope Project -TargetRepo C:\path\to\repo

本 repo 開發

根目錄 .github/ 已被 .gitignore 忽略。要在本 repo 內啟用 project scope:

pwsh -NoProfile -File .\scripts\sync-copilot-scope.ps1 -Scope Project -TargetRepo .

Hook 行為

  • block-dangerous.mjs(PreToolUse,Bash|PowerShell):指令執行前比對,命中即擋下。
  • format-lint.mjs(PostToolUse):偵測到目標 repo 有 package.json 與 pnpm 時,對受影響檔案執行 pnpm prettier --write;js/ts/svelte 再跑 pnpm eslint --fix
  • log-prompt.mjs(UserPromptSubmitted):將提示資訊寫入 logs/prompt_logs.jsonl,可用 LOG_LEVELLOG_DIRLOG_INCLUDE_PROMPT_CONTENTLOG_INCLUDE_RAW_PAYLOAD 控制輸出。

維護

  • 設定依性質放進對應 scope 目錄,不要混進同一份設定來源。
  • 改動後同步更新本 README。

About

收集過往使用的 Copilot 設定。

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages