git-agent for Kotlingit-agent handles Kotlin coroutine-based code, Android Jetpack patterns, and Ktor server changes, producing conventional commit messages that reflect modern Kotlin idioms.
diff --git a/app/src/main/kotlin/com/example/data/UserRepository.kt b/app/src/main/kotlin/com/example/data/UserRepository.kt
index 3e1f8b2..7d4c9a5 100644
--- a/app/src/main/kotlin/com/example/data/UserRepository.kt
+++ b/app/src/main/kotlin/com/example/data/UserRepository.kt
@@ -5,12 +5,24 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
+import kotlinx.coroutines.flow.catch
+import kotlinx.coroutines.flow.onStart
class UserRepository(private val api: UserApi, private val dao: UserDao) {
- fun getUser(id: String): Flow<User> = flow {
- emit(api.getUser(id))
- }
+ fun getUser(id: String): Flow<Result<User>> = flow {
+ emit(Result.success(api.getUser(id)))
+ }
+ .onStart { emit(Result.success(dao.getUser(id) ?: return@onStart)) }
+ .catch { emit(Result.failure(it)) }
}feat(data): wrap UserRepository flow emissions in Result for error propagation
- change return type from Flow<User> to Flow<Result<User>> for explicit error handling
- emit cached db result via onStart before network fetch for instant UI update
- catch network errors and emit Result.failure instead of crashing the flow
Collectors previously had to handle uncaught exceptions at the catch
operator level; wrapping in Result moves error handling into the type
system and enables consistent loading/error/success UI states.brew install gitagenthq/tap/git-agent
# inside your Kotlin project
git-agent init # detects Gradle module structure and suggests scopesDoes git-agent understand Kotlin data classes and sealed classes?Can git-agent handle Android resource file changes?Does git-agent work with Ktor server projects?