Skip to content

Commit

Permalink
feat(runners): add HobbitHole to ShireRunner classes #24
Browse files Browse the repository at this point in the history
The ShireRunner classes now include a HobbitHole parameter. This change affects the CustomRemoteAgentRunner and ShireDefaultRunner classes. The HobbitHole parameter is used to handle different types of interactions in the handleResult function.
  • Loading branch information
phodal committed Jun 29, 2024
1 parent 63cf198 commit 9e55bd1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ open class ShireRunConfigurationProfileState(
val agent = compileResult.executeAgent
val shireRunner: ShireRunner = when {
agent != null -> {
CustomRemoteAgentRunner(myProject, configuration, console!!, processHandler, promptText, agent)
CustomRemoteAgentRunner(myProject, configuration, console!!, processHandler, promptText, hobbitHole, agent)
}
else -> {
val isLocalMode = compileResult.isLocalCommand
ShireDefaultRunner(myProject, configuration, console!!, processHandler, promptText, isLocalMode)
ShireDefaultRunner(myProject, configuration, console!!, processHandler, promptText, hobbitHole, isLocalMode)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.intellij.openapi.project.Project
import com.phodal.shirecore.agent.CustomAgent
import com.phodal.shire.agent.CustomAgentExecutor
import com.phodal.shirelang.ShireBundle
import com.phodal.shirelang.compiler.hobbit.HobbitHole
import com.phodal.shirelang.run.ShireConfiguration
import com.phodal.shirelang.run.flow.ShireConversationService
import com.phodal.shirelang.utils.ShireCoroutineScope
Expand All @@ -21,8 +22,9 @@ class CustomRemoteAgentRunner(
override val console: ConsoleViewWrapperBase,
override val processHandler: ProcessHandler,
override val prompt: String,
override val hole: HobbitHole?,
private val agent: CustomAgent,
) : ShireRunner(configuration, processHandler, console, myProject, prompt) {
) : ShireRunner(configuration, processHandler, console, myProject, hole, prompt) {
override fun execute(postFunction: (response: String) -> Unit) {
ApplicationManager.getApplication().invokeLater {
val stringFlow: Flow<String>? = CustomAgentExecutor(project = myProject).execute(prompt, agent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.project.Project
import com.phodal.shire.llm.LlmProvider
import com.phodal.shirelang.ShireBundle
import com.phodal.shirelang.compiler.hobbit.HobbitHole
import com.phodal.shirelang.run.ShireConfiguration
import com.phodal.shirelang.run.flow.ShireConversationService
import com.phodal.shirelang.utils.ShireCoroutineScope
import kotlinx.coroutines.*

class ShireDefaultRunner(
Expand All @@ -19,8 +19,9 @@ class ShireDefaultRunner(
override val console: ConsoleViewWrapperBase,
override val processHandler: ProcessHandler,
override val prompt: String,
override val hole: HobbitHole?,
private val isLocalMode: Boolean,
) : ShireRunner(configuration, processHandler, console, myProject, prompt) {
) : ShireRunner(configuration, processHandler, console, myProject, hole, prompt) {
override fun execute(postFunction: (response: String) -> Unit) {
ApplicationManager.getApplication().invokeLater({
if (isLocalMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,34 @@ package com.phodal.shirelang.run.runner
import com.intellij.execution.console.ConsoleViewWrapperBase
import com.intellij.execution.process.ProcessHandler
import com.intellij.openapi.project.Project
import com.phodal.shirecore.agent.InteractionType
import com.phodal.shirelang.compiler.hobbit.HobbitHole
import com.phodal.shirelang.run.ShireConfiguration

abstract class ShireRunner(
open val configuration: ShireConfiguration,
open val processHandler: ProcessHandler,
open val console: ConsoleViewWrapperBase,
open val myProject: Project,
open val hole: HobbitHole?,
open val prompt: String,
) {
abstract fun execute(postFunction: (response: String) -> Unit)
fun prepareTask() {

}

fun handleResult() {

Check warning on line 23 in shirelang/src/main/kotlin/com/phodal/shirelang/run/runner/ShireRunner.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Function "handleResult" is never used
when (hole?.interaction) {
InteractionType.AppendCursor -> TODO()
InteractionType.AppendCursorStream -> TODO()
InteractionType.OutputFile -> TODO()
InteractionType.ReplaceSelection -> TODO()
InteractionType.ReplaceCurrentFile -> TODO()
InteractionType.InsertBeforeSelection -> {
TODO()
}
null -> TODO()
}
}
}

0 comments on commit 9e55bd1

Please sign in to comment.