|
| 1 | +# Copilot Agent Instructions for GitHub Copilot for Xcode |
| 2 | + |
| 3 | +## Project Overview |
| 4 | +- **Purpose:** This project is an Xcode extension and companion app that brings GitHub Copilot's AI code suggestions and chat to Xcode, with deep integration for inline completions, chat, and agent-driven codebase modifications. |
| 5 | +- **Architecture:** |
| 6 | + - **Core/**: Swift Package containing main business logic, services, and UI components. Organized by feature (e.g., `ChatService`, `SuggestionService`, `PromptToCodeService`). |
| 7 | + - **EditorExtension/**: Implements Xcode Source Editor Extension commands (e.g., Accept/Reject Suggestion, Open Chat, etc.). |
| 8 | + - **CommunicationBridge/**: Handles XPC communication between the main app and extension services. |
| 9 | + - **ExtensionService/**: Manages the lifecycle and UI of the extension's background service. |
| 10 | + - **Server/**: Node.js backend for advanced features (optional, rarely modified). |
| 11 | + - **Docs/**: Images and documentation assets. |
| 12 | + |
| 13 | +## Key Workflows |
| 14 | +- **Build & Run:** |
| 15 | + - Open `Copilot for Xcode.xcworkspace` in Xcode. |
| 16 | + - Build the `GitHub Copilot for Xcode` app target for macOS 12+. |
| 17 | + - The extension is enabled via System Preferences > Extensions > Xcode Source Editor. |
| 18 | +- **Testing:** |
| 19 | + - Run Swift Package tests from the `Core/` directory using Xcode or `swift test`. |
| 20 | +- **Debugging:** |
| 21 | + - Use the `CommunicationBridge` and `ExtensionService` logs for troubleshooting XPC and extension issues. |
| 22 | + - See `TROUBLESHOOTING.md` for permission and integration issues. |
| 23 | + |
| 24 | +## Project Conventions |
| 25 | +- **Feature Folders:** Each major feature in `Core/Sources/` is a separate folder with its own logic and tests. |
| 26 | +- **Dependency Injection:** Uses [swift-dependencies](https://github.com/pointfreeco/swift-dependencies) and [Composable Architecture](https://github.com/pointfreeco/swift-composable-architecture) for state and effect management. |
| 27 | +- **XPC Communication:** All cross-process calls use protocols in `Tool/` and are implemented in `CommunicationBridge/` and `ExtensionService/`. |
| 28 | +- **Permissions:** Requires `Accessibility`, `Background`, and `Xcode Source Editor Extension` permissions. See `TROUBLESHOOTING.md` for details. |
| 29 | +- **External Packages:** Managed in `Core/Package.swift`. Do not add dependencies directly to Xcode project files. |
| 30 | + |
| 31 | +## Integration Points |
| 32 | +- **Xcode Extension:** Commands in `EditorExtension/` are registered in `Info.plist` and invoked via the Xcode Editor menu. |
| 33 | +- **App ↔ Extension:** Communication via XPC, with protocols defined in `Tool/` and implemented in `CommunicationBridge/ServiceDelegate.swift`. |
| 34 | +- **Updates:** Uses [Sparkle](https://sparkle-project.org/) for in-app updates. |
| 35 | + |
| 36 | +## Examples |
| 37 | +- To add a new chat feature: create a folder in `Core/Sources/`, add logic, register in `Package.swift`, and connect via the appropriate service. |
| 38 | +- To add a new editor command: implement in `EditorExtension/`, update `Info.plist`, and test in Xcode. |
| 39 | + |
| 40 | +## References |
| 41 | +- See `README.md` for user setup and onboarding. |
| 42 | +- See `TROUBLESHOOTING.md` for common integration and permission issues. |
| 43 | +- See `Core/Package.swift` for dependency and target structure. |
| 44 | + |
| 45 | +--- |
| 46 | +For questions about unclear patterns or missing documentation, ask for clarification or check the latest onboarding docs in `Docs/`. |
0 commit comments