chore(clean up): remove unused imports, unnecessary object impls, concurrency/coroutine issues, trailing commas, etc.
This commit is contained in:
@@ -132,20 +132,24 @@ class RunCommand : CliktCommand(name = "run") {
|
||||
setExitCode(0)
|
||||
false
|
||||
}
|
||||
|
||||
"SessionFailed" -> {
|
||||
val reason = field("reason") ?: "unknown"
|
||||
printLine("session_failed", mapOf("sessionId" to ctx.sid, "reason" to reason), ctx.outputJson)
|
||||
setExitCode(1)
|
||||
false
|
||||
}
|
||||
|
||||
"StageStarted" -> {
|
||||
printLine("stage_started", mapOf("stageId" to (field("stageId") ?: "")), ctx.outputJson)
|
||||
true
|
||||
}
|
||||
|
||||
"StageCompleted" -> {
|
||||
printLine("stage_completed", mapOf("stageId" to (field("stageId") ?: "")), ctx.outputJson)
|
||||
true
|
||||
}
|
||||
|
||||
"StageFailed" -> {
|
||||
printLine(
|
||||
"stage_failed",
|
||||
@@ -154,14 +158,17 @@ class RunCommand : CliktCommand(name = "run") {
|
||||
)
|
||||
true
|
||||
}
|
||||
|
||||
"ToolStarted" -> {
|
||||
printLine("tool_started", mapOf("tool" to (field("toolName") ?: "")), ctx.outputJson)
|
||||
true
|
||||
}
|
||||
|
||||
"ToolCompleted" -> {
|
||||
printLine("tool_completed", mapOf("tool" to (field("toolName") ?: "")), ctx.outputJson)
|
||||
true
|
||||
}
|
||||
|
||||
"ToolFailed" -> {
|
||||
printLine(
|
||||
"tool_failed",
|
||||
@@ -170,6 +177,7 @@ class RunCommand : CliktCommand(name = "run") {
|
||||
)
|
||||
true
|
||||
}
|
||||
|
||||
"ToolRejected" -> {
|
||||
printLine(
|
||||
"tool_rejected",
|
||||
@@ -178,6 +186,7 @@ class RunCommand : CliktCommand(name = "run") {
|
||||
)
|
||||
true
|
||||
}
|
||||
|
||||
"ApprovalRequired" -> {
|
||||
val approvalCtx = ApprovalContext(
|
||||
session = session,
|
||||
@@ -187,6 +196,7 @@ class RunCommand : CliktCommand(name = "run") {
|
||||
)
|
||||
handleApproval(approvalCtx, ctx, setExitCode)
|
||||
}
|
||||
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
@@ -200,7 +210,7 @@ class RunCommand : CliktCommand(name = "run") {
|
||||
|
||||
val steeringNote = if (decision == "STEER" && ctx.isTty) {
|
||||
print("Steering note: ")
|
||||
readLine()
|
||||
readlnOrNull()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
@@ -225,10 +235,11 @@ class RunCommand : CliktCommand(name = "run") {
|
||||
ctx.autoApprove -> "APPROVE"
|
||||
!ctx.isTty -> {
|
||||
System.err.println(
|
||||
"WARNING: approval required but no TTY and --auto-approve not set — denying"
|
||||
"WARNING: approval required but no TTY and --auto-approve not set — denying",
|
||||
)
|
||||
"REJECT"
|
||||
}
|
||||
|
||||
else -> promptApproval(toolName, preview)
|
||||
}
|
||||
|
||||
@@ -236,7 +247,7 @@ class RunCommand : CliktCommand(name = "run") {
|
||||
println("\nApproval required for tool: $toolName")
|
||||
preview?.let { println("Preview: $it") }
|
||||
print("[a]pprove / [r]eject / [s]teer: ")
|
||||
return when (readLine()?.trim()?.lowercase()) {
|
||||
return when (readlnOrNull()?.trim()?.lowercase()) {
|
||||
"a", "approve" -> "APPROVE"
|
||||
"s", "steer" -> "STEER"
|
||||
else -> "REJECT"
|
||||
@@ -256,4 +267,4 @@ class RunCommand : CliktCommand(name = "run") {
|
||||
}
|
||||
}
|
||||
|
||||
class SystemExitException(val code: Int) : Exception("exit $code")
|
||||
class SystemExitException(code: Int) : Exception("exit $code")
|
||||
|
||||
Reference in New Issue
Block a user