$ show intitni/CopilotForXcode
Copilot for Xcode is a macOS application that integrates multiple AI code completion and chat services (GitHub Copilot, Codeium, OpenAI, Claude, Google Gemini, Ollama) directly into Xcode as a source editor extension. It provides inline code suggestions, a chat panel with context-aware memory, a prompt-to-code feature, and custom command execution. The architecture is a multi-process system: a host app manages settings and lifecycle, an XPC extension service handles AI requests and workspace state, and an Accessibility-powered widget overlays suggestion and chat panels on Xcode windows. The codebase is heavily modularized into Swift packages (Core, Tool, OverlayWindow) and uses the Composable Architecture (TCA) for state management. While primarily an application, it includes data-centric components like embedding services, vector stores (USearch), and a LangChain-inspired chain abstraction for retrieval-augmented generation, giving it a hybrid character.
The LLM identified 5 files worth highlighting for reuse:
Provides absolute and relative path types (AbsolutePath, RelativePath) with string-based normalization, parent/child traversal, and extension extraction. Originates from SwiftPM's TSC but is self-contained and could be extracted into any Swift project needing type-safe path manipulation without dependency on Foundation's URL.
Implements a line-based diff algorithm for code snippets, returning insertions, deletions, and unchanged lines. Includes a SnippetDiff type for highlighting changed characters within lines. Self-contained with no internal imports, making it reusable for any text comparison need (Git diff UI, update display).
Generic async debounce and throttle utilities using Swift's Task and Task.sleep. Provides DebounceFunction and ThrottleFunction as structs that wrap an async closure, canceling previous calls on debounce. Reusable pattern for rate-limiting expensive operations (search, API calls) in any Swift async context.
An actor-based AsyncPassthroughSubject that broadcasts values to multiple subscribers using AsyncStream. Provides a typed, thread-safe alternative to Combine's PassthroughSubject for structured concurrency. Minimal imports (Foundation, os.log) and can be extracted as a standalone utility for event-driven async code.
Abstracts syntax highlighting via Highlightr and highlight.js themes. Provides static methods to convert code strings into NSAttributedString or arrays of highlighted lines (CodeHighlighting). Decouples theme management from UI, allowing reuse in any macOS SwiftUI or AppKit view requiring code coloring.