Skip to content

Commit

Permalink
internal coder prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski committed Nov 26, 2023
1 parent b06e98f commit 08d9f02
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ repositories {
val kotlin_version = "1.9.20"
val jetty_version = "11.0.18"
val slf4j_version = "2.0.9"
val skyenet_version = "1.0.39"
val skyenet_version = "1.0.40"
dependencies {

implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.36")

implementation(group = "com.simiacryptus.skyenet", name = "core", version = skyenet_version)
implementation(group = "com.simiacryptus.skyenet", name = "kotlin", version = skyenet_version)
implementation(group = "com.simiacryptus.skyenet", name = "webui", version = skyenet_version)

implementation(group = "org.apache.httpcomponents.client5", name = "httpclient5", version = "5.2.1")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.github.simiacryptus.aicoder.actions.dev

import com.github.simiacryptus.aicoder.actions.BaseAction
import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.github.simiacryptus.aicoder.util.ComputerLanguage
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.simiacryptus.jopenai.OpenAIClient
import com.simiacryptus.skyenet.apps.coding.CodingApp
import com.simiacryptus.skyenet.core.platform.*
import com.simiacryptus.skyenet.kotlin.KotlinInterpreter
import com.simiacryptus.skyenet.webui.chat.CodeChatServer
import org.slf4j.LoggerFactory
import software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain
import java.awt.Desktop
import java.io.File
import java.util.*

class InternalCoderAction : BaseAction() {

override fun handle(e: AnActionEvent) {
val server = AppServer.getServer(e.project)
val uuid = UUID.randomUUID().toString()
val symbols: MutableMap<String, Any> = mapOf(
"event" to e,
).toMutableMap()
e.getData(CommonDataKeys.EDITOR)?.apply { symbols["editor"] = this }
e.getData(CommonDataKeys.PSI_FILE)?.apply { symbols["file"] = this }
e.getData(CommonDataKeys.PSI_ELEMENT)?.apply { symbols["element"] = this }
e.getData(CommonDataKeys.VIRTUAL_FILE)?.apply { symbols["virtualFile"] = this }
e.getData(CommonDataKeys.PROJECT)?.apply { symbols["project"] = this }
e.getData(CommonDataKeys.SYMBOLS)?.apply { symbols["symbols"] = this }
e.getData(CommonDataKeys.CARET)?.apply { symbols["psiElement"] = this }
e.getData(CommonDataKeys.CARET)?.apply { symbols["psiElement"] = this }
// TODO: Set this up at startup and lock ApplicationServices
ApplicationServices.clientManager = object : ClientManager() {
override fun createClient(session: Session, user: User?, dataStorage: DataStorage) =
this@InternalCoderAction.api

override fun createClient(session: Session, user: User?, logfile: File, key: String?) =
this@InternalCoderAction.api
}
server.addApp("/$uuid", CodingApp(
"IntelliJ Internal Coding Agent",
KotlinInterpreter::class,
symbols))
Thread {
Thread.sleep(500)
try {
Desktop.getDesktop().browse(server.server.uri.resolve("/$uuid/index.html"))
} catch (e: Throwable) {
log.warn("Error opening browser", e)
}
}.start()
}

override fun isEnabled(event: AnActionEvent) = when {
!AppSettingsState.instance.devActions -> false
else -> true
}

companion object {
private val log = LoggerFactory.getLogger(InternalCoderAction::class.java)
}
}
6 changes: 6 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@
-->
<add-to-group group-id="com.github.simiacryptus.aicoder.ui.EditorMenu" anchor="first"/>
</action>
<action class="com.github.simiacryptus.aicoder.actions.dev.InternalCoderAction"
text="Code Console"
description="Open code console">
<add-to-group group-id="com.github.simiacryptus.aicoder.ui.EditorMenu" anchor="first"/>
<add-to-group group-id="com.github.simiacryptus.aicoder.ui.ProjectMenu" anchor="first"/>
</action>

</actions>

Expand Down

0 comments on commit 08d9f02

Please sign in to comment.