diff --git a/build.gradle.kts b/build.gradle.kts index b9618a87..35fd0b47 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,8 +26,10 @@ repositories { val kotlin_version = "2.0.0-Beta5" val jetty_version = "11.0.18" val slf4j_version = "2.0.9" -val skyenet_version = "1.0.63" +val skyenet_version = "1.0.64" val remoterobot_version = "0.11.21" +val jackson_version = "2.17.0" + dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0") @@ -39,7 +41,7 @@ dependencies { exclude(group = "org.jetbrains.kotlin", module = "") } - implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.52") + implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.53") { exclude(group = "org.jetbrains.kotlin", module = "") } @@ -59,6 +61,10 @@ dependencies { exclude(group = "org.jetbrains.kotlin", module = "") } + implementation(group = "com.fasterxml.jackson.core", name = "jackson-databind", version = jackson_version) + implementation(group = "com.fasterxml.jackson.core", name = "jackson-annotations", version = jackson_version) + implementation(group = "com.fasterxml.jackson.module", name = "jackson-module-kotlin", version = jackson_version) + implementation(group = "com.vladsch.flexmark", name = "flexmark-all", version = "0.64.8") implementation("com.googlecode.java-diff-utils:diffutils:1.3.0") implementation(group = "org.apache.httpcomponents.client5", name = "httpclient5", version = "5.2.3") diff --git a/gradle.properties b/gradle.properties index 97d7e1bd..99bd244b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ pluginName=intellij-aicoder pluginRepositoryUrl=https://github.com/SimiaCryptus/intellij-aicoder -pluginVersion=1.4.3 +pluginVersion=1.4.4 jvmArgs=-Xmx8g org.gradle.jvmargs=-Xmx8g diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/DebugChatAction.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/DebugChatAction.kt deleted file mode 100644 index c11badf2..00000000 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/DebugChatAction.kt +++ /dev/null @@ -1,96 +0,0 @@ -package com.github.simiacryptus.aicoder.actions.generic - -import com.github.simiacryptus.aicoder.AppServer -import com.github.simiacryptus.aicoder.actions.BaseAction -import com.github.simiacryptus.aicoder.config.AppSettingsState -import com.github.simiacryptus.aicoder.config.AppSettingsState.Companion.chatModel -import com.intellij.openapi.actionSystem.ActionUpdateThread -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.CommonDataKeys -import com.intellij.openapi.project.Project -import com.intellij.xdebugger.XDebuggerManager -import com.simiacryptus.skyenet.core.platform.ApplicationServices -import com.simiacryptus.skyenet.core.platform.Session -import com.simiacryptus.skyenet.core.platform.StorageInterface -import com.simiacryptus.skyenet.core.platform.User -import com.simiacryptus.skyenet.webui.application.ApplicationServer -import com.simiacryptus.skyenet.webui.chat.ChatServer -import com.simiacryptus.skyenet.webui.chat.ChatSocketManager -import com.simiacryptus.skyenet.webui.session.SocketManager -import org.slf4j.LoggerFactory -import java.awt.Desktop -import java.io.File - -class DebugChatAction : BaseAction() { - override fun getActionUpdateThread() = ActionUpdateThread.BGT - - val path = "/codeChat" - val model = AppSettingsState.instance.smartModel.chatModel() - - override fun handle(e: AnActionEvent) { - val project = e.getData(CommonDataKeys.PROJECT) - val debugSessionInfo = getDebugSessionInfo(project) - val systemPrompt = debugSessionInfo - val userInterfacePrompt = "" - val session = StorageInterface.newGlobalID() - agents[session] = ChatSocketManager( - session = session, - model = model, - initialAssistantPrompt = "", - userInterfacePrompt = userInterfacePrompt, - systemPrompt = systemPrompt, - api = api, - storage = ApplicationServices.dataStorageFactory(root), - applicationClass = ApplicationServer::class.java, - ) - - val server = AppServer.getServer(e.project) - val app = initApp(server, path) - app.sessions[session] = app.newSession(null, session) - - Thread { - Thread.sleep(500) - try { - Desktop.getDesktop().browse(server.server.uri.resolve("$path/#$session")) - } catch (e: Throwable) { - log.warn("Error opening browser", e) - } - }.start() - } - - private fun getDebugSessionInfo(project: Project?): String { - val debugSession = XDebuggerManager.getInstance(project ?: return "No project found").currentSession - val stackFrame = debugSession?.currentStackFrame ?: return "No stack frames found" - val frameContext = stackFrame.sourcePosition?.let { - val lines = it.file.toFile.readLines() - val context = ((it.line - 2) until (it.line + 2)).map { line -> lines.getOrNull(line) } - context.joinToString("\n") - } - //val frameVars = debugSession..map { it.name to it.value?.toString() } - return frameContext.toString() - } - - override fun isEnabled(event: AnActionEvent) = true - - companion object { - private val log = LoggerFactory.getLogger(CodeChatAction::class.java) - private val agents = mutableMapOf() - val root: File get() = File(AppSettingsState.instance.pluginHome, "code_chat") - private fun initApp(server: AppServer, path: String): ChatServer { - server.appRegistry[path]?.let { return it } - val socketServer = object : ApplicationServer( - applicationName = "Code Chat", - path = path, - showMenubar = false, - ) { - override val singleInput = false - override val stickyInput = true - override fun newSession(user: User?, session: Session) = - agents[session] ?: throw IllegalArgumentException("Unknown session: $session") - } - server.addApp(path, socketServer) - return socketServer - } - - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/PlanAheadAction.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/PlanAheadAction.kt index 44765132..76d6a9fb 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/PlanAheadAction.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/PlanAheadAction.kt @@ -61,9 +61,9 @@ class PlanAheadAction : BaseAction() { getModuleRootForFile(UITools.getSelectedFile(e)?.parent?.toFile ?: throw RuntimeException("")) } DataStorage.sessionPaths[session] = root - TaskRunnerApp.agents[session] = TaskRunnerApp(event = e, root = root) + PlanAheadApp.agents[session] = PlanAheadApp(event = e, root = root) val server = AppServer.getServer(e.project) - val app = TaskRunnerApp.initApp(server, path) + val app = PlanAheadApp.initApp(server, path) app.sessions[session] = app.newSession(null, session) Thread { Thread.sleep(500) @@ -76,7 +76,7 @@ class PlanAheadAction : BaseAction() { } } -class TaskRunnerApp( +class PlanAheadApp( applicationName: String = "Task Planning v1.0", path: String = "/taskDev", val event: AnActionEvent, @@ -110,7 +110,7 @@ class TaskRunnerApp( try { val settings = getSettings(session, user) if (api is ClientManager.MonitoredClient) api.budget = settings?.budget ?: 2.0 - TaskRunnerAgent( + PlanAheadAgent( user = user, session = session, dataStorage = dataStorage, @@ -146,12 +146,12 @@ class TaskRunnerApp( return socketServer } - private val log = LoggerFactory.getLogger(TaskRunnerApp::class.java) - val agents = mutableMapOf() + val agents = mutableMapOf() + private val log = LoggerFactory.getLogger(PlanAheadApp::class.java) } } -class TaskRunnerAgent( +class PlanAheadAgent( user: User?, session: Session, dataStorage: StorageInterface, @@ -168,6 +168,7 @@ class TaskRunnerAgent( val command: List = listOf(language), val actorMap: Map> = mapOf( ActorTypes.TaskBreakdown to ParsedActor( + name = "TaskBreakdown", resultClass = TaskBreakdownResult::class.java, prompt = """ |Given a user request, identify and list smaller, actionable tasks that can be directly implemented in code. @@ -320,7 +321,7 @@ class TaskRunnerAgent( val event: AnActionEvent, val root: Path -) : ActorSystem( +) : ActorSystem( actorMap.map { it.key.name to it.value }.toMap(), dataStorage, user, @@ -522,7 +523,9 @@ class TaskRunnerAgent( userMessage = userMessage, highLevelPlan = highLevelPlan, genState = genState, - task = genState.uitaskMap.get(taskId) ?: ui.newTask(false), + task = genState.uitaskMap.get(taskId) ?: ui.newTask(false).apply { + taskTabs[taskId] = placeholder + }, taskTabs = taskTabs ) } @@ -1137,7 +1140,7 @@ class TaskRunnerAgent( .let { '"' + it + '"' } companion object { - private val log = LoggerFactory.getLogger(TaskRunnerAgent::class.java) + private val log = LoggerFactory.getLogger(PlanAheadAgent::class.java) enum class ActorTypes { TaskBreakdown, diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index fc66a304..b9d94800 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -36,11 +36,6 @@ description="Start a chat session with an AI to discuss code or get assistance"> - - -