Skip to content

Commit b9fedb9

Browse files
committed
add CLAUDE.md
1 parent 93bc397 commit b9fedb9

1 file changed

Lines changed: 108 additions & 0 deletions

File tree

‎CLAUDE.md‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
GitHub Copilot for Xcode is a macOS application that provides AI-powered code completion and chat assistance for Xcode. It integrates GitHub Copilot's capabilities directly into the Xcode development environment through Xcode source editor extensions.
8+
9+
## Build Commands
10+
11+
### Local Development Build
12+
```bash
13+
cd ./Script
14+
sh ./uninstall-app.sh # Remove any previous installation
15+
del ../build # Clean the build directory (use del instead of rm)
16+
sh ./localbuild-app.sh # Build a fresh copy of the app
17+
```
18+
19+
### Server Components (Node.js/TypeScript)
20+
```bash
21+
cd Server
22+
npm install # Install dependencies
23+
npm run build # Build with webpack
24+
```
25+
26+
### Testing
27+
```bash
28+
# Run all unit tests (from Xcode or command line)
29+
xcodebuild test -scheme "Copilot for Xcode" -workspace "Copilot for Xcode.xcworkspace"
30+
31+
# Tests are configured in TestPlan.xctestplan
32+
# All new tests should be added to this test plan
33+
```
34+
35+
### Code Formatting
36+
- Uses SwiftFormat for Swift code formatting
37+
- Follows Ray Wenderlich Style Guide with 4 spaces for indentation
38+
39+
## Architecture Overview
40+
41+
The project is organized into several key targets and packages:
42+
43+
### Main Targets
44+
- **Copilot for Xcode**: Host app containing XPCService and editor extension, provides settings UI
45+
- **EditorExtension**: Xcode source editor extension that forwards editor content to XPCService
46+
- **ExtensionService**: Background service where all core features are implemented
47+
- **CommunicationBridge**: Maintains communication between host app/editor extension and ExtensionService
48+
49+
### Swift Packages
50+
- **Core**: Contains main application logic organized by feature areas
51+
- `Service`: ExtensionService implementation
52+
- `HostApp`: Host application implementation
53+
- `SuggestionWidget`: UI components for code suggestions
54+
- `ConversationTab`: Chat interface components
55+
- `ChatService`: Chat functionality and context management
56+
- `SuggestionService`: Code completion service
57+
- `PromptToCodeService`: Code generation from prompts
58+
59+
- **Tool**: Shared utilities and lower-level services
60+
- `GitHubCopilotService`: Core integration with GitHub Copilot Language Server
61+
- `Workspace`: File system and project management
62+
- `XcodeInspector`: Xcode app monitoring and interaction
63+
- `SuggestionBasic`: Core suggestion data types
64+
- `Preferences`: Configuration management
65+
- `Logger`: Logging infrastructure
66+
67+
- **Server**: Node.js/TypeScript components
68+
- Monaco editor integration for diff views
69+
- Terminal/xterm integration
70+
- Webpack-based build system
71+
72+
### Key Service Architecture
73+
- Uses actor-based concurrency with `@WorkspaceActor` and `@ServiceActor`
74+
- Dependency injection via swift-dependencies
75+
- Composable Architecture (TCA) for UI state management
76+
- XPC communication between sandboxed and non-sandboxed components
77+
78+
### Data Flow
79+
1. Editor extension captures Xcode content via source editor APIs
80+
2. Content forwarded to ExtensionService via CommunicationBridge XPC
81+
3. ExtensionService processes requests through GitHubCopilotService
82+
4. Language Server Protocol (LSP) communication with GitHub Copilot backend
83+
5. Results returned through same XPC chain back to editor
84+
85+
## Prerequisites
86+
87+
- macOS 12+
88+
- Xcode 8+
89+
- Node.js and npm (symlinked to /usr/local/bin for Xcode run scripts)
90+
- GitHub Copilot subscription
91+
92+
## Key Files to Understand
93+
94+
- `Core/Sources/Service/Service.swift`: Main service entry point
95+
- `Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotService.swift`: Core Copilot integration
96+
- `Core/Package.swift` & `Tool/Package.swift`: Swift package configurations
97+
- `TestPlan.xctestplan`: Centralized test configuration
98+
- `Version.xcconfig`: Version control for all targets
99+
- `DEVELOPMENT.md`: Detailed development setup and architecture notes
100+
101+
## Common Development Patterns
102+
103+
- All async operations use Swift concurrency (async/await)
104+
- UI built with SwiftUI using Composable Architecture patterns
105+
- Preference storage via UserDefaults with type-safe property wrappers
106+
- Logging via centralized Logger package with different log levels
107+
- File watching and workspace management through dedicated services
108+
- XPC communication follows request-response patterns with proper error handling

0 commit comments

Comments
 (0)