📖 先備條件:請先完成第 02 章:情境與對話後再閱讀本附錄。
本附錄介紹兩項額外的情境功能:使用圖片,以及跨多個目錄的權限管理。
您可以在對話中使用 @ 語法引用圖片。Copilot 能分析螢幕截圖、設計稿、架構圖及其他視覺內容。
copilot
> @screenshot.png What's happening in this UI?
# Copilot analyzes the image and responds
> @mockup.png @current-design.png Compare these two designs
# You can also drag and drop images or paste from clipboard
| 格式 | 最適用於 |
|---|---|
| PNG | 螢幕截圖、UI 設計稿、架構圖 |
| JPG/JPEG | 照片、複雜影像 |
| GIF | 簡單示意圖(僅分析第一幀) |
| WebP | 網頁截圖 |
1. UI 除錯
> @bug-screenshot.png The button doesn't align properly. What CSS might cause this?
2. 設計實作
> @figma-export.png Write the HTML and Tailwind CSS to match this design
3. 錯誤分析
> @error-screenshot.png What does this error mean and how do I fix it?
4. 架構審查
> @whiteboard-diagram.png Convert this architecture diagram to a Mermaid diagram I can put in docs
5. 前後對比
> @before.png @after.png What changed between these two versions of the UI?
將圖片與程式碼情境搭配使用,效果更為強大:
copilot
> @screenshot-of-bug.png @src/components/Header.jsx
> The header looks wrong in the screenshot. What's causing it in the code?
預設情況下,Copilot 僅能存取您當前目錄中的檔案。若需存取其他位置的檔案,則須授予對應的存取權限。
# Add a directory to the allowed list
copilot --add-dir /path/to/other/project
# Add multiple directories
copilot --add-dir ~/workspace --add-dir /tmp
# Disable path restrictions entirely (use with caution)
copilot --allow-all-paths
copilot
> /add-dir /path/to/other/project
# Now you can reference files from that directory
> /list-dirs
# See all allowed directories
# Allow all permissions for non-interactive scripts
copilot -p "Review @src/" --allow-all
# Or use the memorable alias
copilot -p "Review @src/" --yolo
以下是常見的使用場景:
| ← 返回第 02 章 | 返回附錄 |