This file provides guidance to coding agents when working with code in this repository.
- Build and run:
xcodebuild -scheme "Leader Key" -configuration Debug build - Run all tests:
xcodebuild -scheme "Leader Key" -testPlan "TestPlan" test - Run single test:
xcodebuild -scheme "Leader Key" -testPlan "TestPlan" -only-testing:Leader KeyTests/UserConfigTests/testInitializesWithDefaults test - Bump version:
bin/bump - Create release:
bin/release
Leader Key is a macOS application that provides customizable keyboard shortcuts. The core architecture consists of:
Key Components:
AppDelegate: Application lifecycle, global shortcuts registration, update managementController: Central event handling, manages key sequences and window displayUserConfig: JSON configuration management with validationUserState: Tracks navigation through key sequencesMainWindow: Base class for theme windows
Theme System:
- Themes inherit from
MainWindowand implementdraw()method - Available themes: MysteryBox, Mini, Breadcrumbs, ForTheHorde, Cheater
- Each theme provides different visual representations of shortcuts
Configuration Flow:
- Config stored at
~/Library/Application Support/Leader Key/config.json FileMonitorwatches for changes and triggers reloadConfigValidatorensures no key conflicts- Actions support: applications, URLs, commands, folders
Testing Architecture:
- Uses XCTest with custom
TestAlertManagerfor UI testing - Tests use isolated UserDefaults and temporary directories
- Focus on configuration validation and state management
- Imports: Group Foundation/AppKit imports first, then third-party libraries (Combine, Defaults)
- Naming: Use descriptive camelCase for variables/functions, PascalCase for types
- Types: Use explicit type annotations for public properties and parameters
- Error Handling: Use appropriate error handling with do/catch blocks and alerts
- Extensions: Create extensions for additional functionality on existing types
- State Management: Use @Published and ObservableObject for reactive UI updates
- Testing: Create separate test cases with descriptive names, use XCTAssert* methods
- Access Control: Use appropriate access modifiers (private, fileprivate, internal)
- Documentation: Use comments for complex logic or non-obvious implementations
Follow Swift idioms and default formatting (4-space indentation, spaces around operators).