Skip to content

Commit

Permalink
1.4.5 (#158)
Browse files Browse the repository at this point in the history
* 1.4.5

* 1.4.5
  • Loading branch information
acharneski authored Apr 26, 2024
1 parent 967151f commit 5cdd394
Show file tree
Hide file tree
Showing 16 changed files with 392 additions and 232 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ 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.64"
val skyenet_version = "1.0.65"
val remoterobot_version = "0.11.21"
val jackson_version = "2.17.0"

Expand All @@ -41,7 +41,7 @@ dependencies {
exclude(group = "org.jetbrains.kotlin", module = "")
}

implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.53")
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.54")
{
exclude(group = "org.jetbrains.kotlin", module = "")
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginName=intellij-aicoder
pluginRepositoryUrl=https://github.com/SimiaCryptus/intellij-aicoder
pluginVersion=1.4.4
pluginVersion=1.4.5

jvmArgs=-Xmx8g
org.gradle.jvmargs=-Xmx8g
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class FileContextAction<T : Any>(

open fun getConfig(project: Project?, e: AnActionEvent): T? = null

private var isDevAction = false
var isDevAction = false
override fun isEnabled(event: AnActionEvent): Boolean {
if (!super.isEnabled(event)) return false
if (isDevAction && !AppSettingsState.instance.devActions) return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class LineFilterChatAction : BaseAction() {
}.start()
}

override fun isEnabled(event: AnActionEvent) = true
override fun isEnabled(event: AnActionEvent) = AppSettingsState.instance.devActions

companion object {
private val log = LoggerFactory.getLogger(LineFilterChatAction::class.java)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import com.github.simiacryptus.aicoder.actions.SelectionAction
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.project.Project
import com.simiacryptus.jopenai.ApiModel.*
import com.simiacryptus.jopenai.util.ClientUtil.toContentList

class AppendTextWithChatAction : SelectionAction<String>() {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun isEnabled(event: AnActionEvent) = AppSettingsState.instance.enableLegacyActions

override fun getConfig(project: Project?): String {
return ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.github.simiacryptus.aicoder.config.AppSettingsState.Companion.chatModel
import com.github.simiacryptus.aicoder.util.ComputerLanguage
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import com.simiacryptus.jopenai.proxy.ChatProxy

class CommentsAction : SelectionAction<String>() {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun isEnabled(event: AnActionEvent) = AppSettingsState.instance.enableLegacyActions

override fun getConfig(project: Project?): String {
return ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import com.github.simiacryptus.aicoder.util.ComputerLanguage
import com.github.simiacryptus.aicoder.util.IndentedText
import com.github.simiacryptus.aicoder.util.psi.PsiUtil
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import com.simiacryptus.jopenai.proxy.ChatProxy

class DocAction : SelectionAction<String>() {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun isEnabled(event: AnActionEvent) = AppSettingsState.instance.enableLegacyActions

interface DocAction_VirtualAPI {
fun processCode(
code: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.github.simiacryptus.aicoder.config.AppSettingsState.Companion.chatMod
import com.github.simiacryptus.aicoder.util.ComputerLanguage
import com.github.simiacryptus.aicoder.util.psi.PsiUtil
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import com.simiacryptus.jopenai.proxy.ChatProxy
import com.simiacryptus.jopenai.util.StringUtil
Expand All @@ -14,6 +15,8 @@ import java.util.*
class ImplementStubAction : SelectionAction<String>() {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun isEnabled(event: AnActionEvent) = AppSettingsState.instance.enableLegacyActions

interface VirtualAPI {
fun editCode(
code: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import com.github.simiacryptus.aicoder.util.UITools
import com.github.simiacryptus.aicoder.util.psi.PsiClassContext
import com.github.simiacryptus.aicoder.util.psi.PsiUtil
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.project.Project
import com.simiacryptus.jopenai.proxy.ChatProxy

class InsertImplementationAction : SelectionAction<String>() {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun isEnabled(event: AnActionEvent) = AppSettingsState.instance.enableLegacyActions

interface VirtualAPI {
fun implementCode(
specification: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import com.simiacryptus.jopenai.proxy.ChatProxy
open class RenameVariablesAction : SelectionAction<String>() {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun isEnabled(event: AnActionEvent) = AppSettingsState.instance.enableLegacyActions

interface RenameAPI {
fun suggestRenames(
code: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import kotlin.math.pow
open class ReplaceWithSuggestionsAction : SelectionAction<String>() {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun isEnabled(event: AnActionEvent) = AppSettingsState.instance.enableLegacyActions

interface VirtualAPI {
fun suggestText(template: String, examples: List<String>): Suggestions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.simiacryptus.aicoder.actions.legacy

import com.github.simiacryptus.aicoder.actions.BaseAction
import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.github.simiacryptus.aicoder.util.UITools
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
Expand Down Expand Up @@ -116,6 +117,7 @@ class VoiceToTextAction : BaseAction() {
}

override fun isEnabled(event: AnActionEvent): Boolean {
if(!AppSettingsState.instance.enableLegacyActions) return false
return try {
null != targetDataLine.get(50, TimeUnit.MILLISECONDS)
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,18 @@ class AppSettingsComponent : com.intellij.openapi.Disposable {
)
}

@Suppress("unused")
@Name("Shell Command")
val shellCommand = JBTextField()

@Suppress("unused")
@Name("Show Welcome Screen")
val showWelcomeScreen = JBCheckBox("Show Welcome Screen", true)

@Suppress("unused")
@Name("Enable Legacy Actions")
val enableLegacyActions = JBCheckBox()

@Suppress("unused")
@Name("Temperature")
val temperature = JBTextField()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil
import com.simiacryptus.jopenai.models.ChatModels
import com.simiacryptus.jopenai.util.JsonUtil
import java.io.File
import java.util.*

@State(name = "org.intellij.sdk.settings.AppSettingsState", storages = [Storage("SdkSettingsPlugin.xml")])
data class AppSettingsState(
Expand All @@ -35,12 +36,14 @@ data class AppSettingsState(
if (logPath == null) {
logPath = System.getProperty("user.home")
}

File(logPath, "AICodingAsst")
},
var showWelcomeScreen: Boolean = true,
var greetedVersion: String = "",
var shellCommand: String = getDefaultShell(),
var enableLegacyActions: Boolean = false,
) : PersistentStateComponent<SimpleEnvelope> {

private var onSettingsLoadedListeners = mutableListOf<() -> Unit>()
private val recentCommands = mutableMapOf<String, MRUItems>()

Expand Down Expand Up @@ -105,12 +108,14 @@ data class AppSettingsState(
if (recentCommands != other.recentCommands) return false
if (showWelcomeScreen != other.showWelcomeScreen) return false
if (greetedVersion != other.greetedVersion) return false
if (enableLegacyActions != other.enableLegacyActions) return false
return true
}

override fun hashCode(): Int {
var result = temperature.hashCode()
result = 31 * result + smartModel.hashCode()
result = 31 * result + enableLegacyActions.hashCode()
result = 31 * result + fastModel.hashCode()
result = 31 * result + listeningPort
result = 31 * result + listeningEndpoint.hashCode()
Expand Down Expand Up @@ -144,5 +149,10 @@ data class AppSettingsState(
it.value.modelName == this || it.key == this
}?.value ?: ChatModels.GPT35Turbo
}

private fun getDefaultShell(): String {
val os = System.getProperty("os.name").toLowerCase(Locale.ROOT)
return if (os.contains("win")) "powershell" else "bash"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class StaticAppSettingsConfigurable : AppSettingsConfigurable() {
add(JLabel("Developer Tools:"))
add(component.devActions)
})
add(JPanel(FlowLayout(FlowLayout.LEFT)).apply {
add(JLabel("Enable Legacy Actions:"))
add(component.enableLegacyActions)
})
add(JPanel(FlowLayout(FlowLayout.LEFT)).apply {
// Removed sections that reference non-existing components
add(JPanel(FlowLayout(FlowLayout.LEFT)).apply {
Expand Down Expand Up @@ -96,6 +100,10 @@ class StaticAppSettingsConfigurable : AppSettingsConfigurable() {
add(component.pluginHome)
add(component.choosePluginHome)
})
add(JPanel(FlowLayout(FlowLayout.LEFT)).apply {
add(JLabel("Shell Command:"))
add(component.shellCommand)
})
add(JPanel(FlowLayout(FlowLayout.LEFT)).apply {
//add(JLabel("Show Welcome Screen:"))
add(component.showWelcomeScreen)
Expand Down Expand Up @@ -124,13 +132,15 @@ class StaticAppSettingsConfigurable : AppSettingsConfigurable() {
component.editRequests.isSelected = settings.editRequests
component.temperature.text = settings.temperature.toString()
component.pluginHome.text = settings.pluginHome.absolutePath
component.shellCommand.text = settings.shellCommand
val model = component.apis.model as DefaultTableModel
model.rowCount = 0 // Clear existing rows
APIProvider.values().forEach { value ->
val key = value.name
model.addRow(arrayOf(key, settings.apiKey?.get(key) ?: "", settings.apiBase?.get(key) ?: value.base))
}
component.showWelcomeScreen.isSelected = settings.showWelcomeScreen
component.enableLegacyActions.isSelected = settings.enableLegacyActions
} catch (e: Exception) {
log.warn("Error setting UI", e)
}
Expand All @@ -150,6 +160,8 @@ class StaticAppSettingsConfigurable : AppSettingsConfigurable() {
settings.editRequests = component.editRequests.isSelected
settings.temperature = component.temperature.text.safeDouble()
settings.pluginHome = File(component.pluginHome.text)
settings.shellCommand = component.shellCommand.text
settings.enableLegacyActions = component.enableLegacyActions.isSelected
val model = component.apis.model as DefaultTableModel
for (row in 0 until model.rowCount) {
val provider = model.getValueAt(row, 0) as String
Expand Down

0 comments on commit 5cdd394

Please sign in to comment.