git-agent for Swift

Conventional commits for Swift and SwiftUI projects

git-agent understands Swift Package Manager layouts, SwiftUI view hierarchies, and actor concurrency patterns, producing conventional commits that reflect iOS and macOS development conventions.

diff --git a/Sources/App/Services/ImageLoader.swift b/Sources/App/Services/ImageLoader.swift index 6c3d2a1..4f8e9b7 100644 --- a/Sources/App/Services/ImageLoader.swift +++ b/Sources/App/Services/ImageLoader.swift @@ -1,14 +1,26 @@ import Foundation +import OSLog -class ImageLoader: ObservableObject { - @Published var image: UIImage? +@MainActor +final class ImageLoader: ObservableObject { + @Published var image: UIImage? + @Published var isLoading = false - func load(url: URL) { - URLSession.shared.dataTask(with: url) { data, _, _ in - if let data = data { - DispatchQueue.main.async { - self.image = UIImage(data: data) - } - } - }.resume() - } + private let logger = Logger(subsystem: "com.example.app", category: "ImageLoader") + + func load(url: URL) async { + isLoading = true + defer { isLoading = false } + do { + let (data, _) = try await URLSession.shared.data(from: url) + image = UIImage(data: data) + } catch { + logger.error("Failed to load image from \(url): \(error)") + } + } }
git-agent output
refactor(services): migrate ImageLoader to async/await and MainActor isolation - annotate with @MainActor to eliminate manual DispatchQueue.main.async dispatch - convert load(url:) to async throws using URLSession's async data(from:) method - add isLoading published property with defer-based cleanup - replace print with OSLog Logger for structured logging The DispatchQueue approach was not safe under strict concurrency checking; @MainActor annotation satisfies the compiler and makes the isolation intent explicit.
  • Understands Swift Package Manager target structure for accurate scope detection
  • Recognises SwiftUI View body changes versus ViewModel changes
  • Handles actor, async/await, and structured concurrency diffs correctly
  • Groups Xcode project file (.xcodeproj) changes into chore commits
brew install gitagenthq/tap/git-agent # inside your Swift project git-agent init # reads Package.swift targets to suggest scopes
Does git-agent handle Xcode project file changes?
Yes. .xcodeproj and .xcworkspace changes are detected and committed separately as chore commits to keep them out of feature history.
Can git-agent work with Swift on Linux?
git-agent itself runs on macOS and Linux. For Swift on Linux (server-side Swift), it works identically as it reads diffs without needing the Swift toolchain installed.
How does git-agent handle SwiftUI previews?
#Preview and PreviewProvider blocks are recognised as non-production code. Changes to preview code alone are grouped into a docs or test commit rather than a feat commit.