Support interactive add/stage input flow

This commit is contained in:
Joe Tretter
2026-05-13 19:12:06 -05:00
parent 482483deed
commit 3f6a764603
7 changed files with 150 additions and 5 deletions

View File

@@ -129,6 +129,20 @@ class GitRepositoryRuntime private constructor(
val shellTokens = GitSandboxEngine.tokenizeShellCommand(command)
val tokens = shellTokens.map { it.value }
if (tokens.isEmpty()) return inspectSandbox(level).copy(currentDir = currentRepo.currentDir) to emptyList()
if (currentRepo.interactiveAddSession != null) {
val (updatedRepo, output) = GitSandboxEngine.execute(currentRepo, command)
val newlyStagedPaths = updatedRepo.files.filter { updatedFile ->
updatedFile.staged && currentRepo.files.firstOrNull { it.name == updatedFile.name }?.staged != true
}.map { it.name }
if (newlyStagedPaths.isNotEmpty()) {
runGit(nativeGit, workingDir, listOf("add") + newlyStagedPaths)
}
val inspectedRepo = inspectSandbox(level).copy(
currentDir = updatedRepo.currentDir,
interactiveAddSession = updatedRepo.interactiveAddSession,
)
return augmentObservedRepoFacts(updatedRepo, inspectedRepo, tokens) to output
}
val expandedTokens = if (tokens.firstOrNull() == "echo") {
tokens
} else {