Skip to content

Commit

Permalink
1.8.0 (#194)
Browse files Browse the repository at this point in the history
* 1.8.0

* fix

* fix
  • Loading branch information
acharneski authored Oct 18, 2024
1 parent fee55c1 commit 1196e02
Show file tree
Hide file tree
Showing 79 changed files with 614 additions and 413 deletions.
12 changes: 7 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
id("org.jetbrains.intellij.platform") version "2.1.0"
id("org.jetbrains.changelog") version "2.2.1"
id("org.jetbrains.qodana") version "2024.2.3"
id("org.jetbrains.kotlinx.kover") version "0.9.0-RC"
//id("org.jetbrains.kotlinx.kover") version "0.9.0-RC"
id("org.jetbrains.dokka") version "2.0.0-Beta"
}

Expand All @@ -28,7 +28,7 @@ repositories {

val jetty_version = "11.0.24"
val slf4j_version = "2.0.16"
val skyenet_version = "1.2.11"
val skyenet_version = "1.2.12"
val remoterobot_version = "0.11.23"
val jackson_version = "2.17.2"

Expand All @@ -43,15 +43,15 @@ dependencies {
implementation("com.googlecode.java-diff-utils:diffutils:1.3.0")
implementation(group = "org.apache.httpcomponents.client5", name = "httpclient5", version = "5.2.3")

implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.1.9")
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.1.10")
implementation(group = "com.simiacryptus.skyenet", name = "kotlin", version = skyenet_version)
implementation(group = "com.simiacryptus.skyenet", name = "core", version = skyenet_version)
implementation(group = "com.simiacryptus.skyenet", name = "webui", version = skyenet_version)

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 ("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version")

implementation(group = "org.eclipse.jetty", name = "jetty-server", version = jetty_version)
implementation(group = "org.eclipse.jetty", name = "jetty-servlet", version = jetty_version)
Expand Down Expand Up @@ -181,7 +181,7 @@ intellijPlatform {
}

publishing {
// Include VCS plugin
// Include VCS plugin
token = providers.environmentVariable("PUBLISH_TOKEN")
// The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
Expand All @@ -208,6 +208,7 @@ changelog {
}

// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
/*
kover {
reports {
total {
Expand All @@ -217,6 +218,7 @@ kover {
}
}
}
*/

tasks {
wrapper {
Expand Down
21 changes: 7 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
pluginName=intellij-aicoder
pluginRepositoryUrl=https://github.com/SimiaCryptus/intellij-aicoder
pluginVersion=1.7.2

pluginVersion=1.8.0
jvmArgs=-Xmx8g
org.gradle.jvmargs=-Xmx8g -XX:MaxMetaspaceSize=1g

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild=233
pluginUntilBuild=242.*

platformType = IU
platformType=IU
platformVersion=2024.2
gradleVersion=8.10.2

platformPlugins =
platformBundledPlugins =

platformPlugins=
platformBundledPlugins=
# Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency=false

# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.configuration-cache = false
org.gradle.caching = true

org.gradle.configuration-cache=false
org.gradle.caching=true
# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
systemProp.org.gradle.unsafe.kotlin.assignment = true
systemProp.org.gradle.unsafe.kotlin.assignment=true
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
# Disable deprecated features warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import com.github.simiacryptus.aicoder.util.IdeaOpenAIClient
import com.github.simiacryptus.aicoder.util.UITools
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.util.NlsSafe
import com.simiacryptus.jopenai.ChatClient
import com.simiacryptus.jopenai.OpenAIClient
import org.slf4j.LoggerFactory
import javax.swing.Icon

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class FileContextAction<T : Any>(
}
val start = System.currentTimeMillis()
val fileSystem = LocalFileSystem.getInstance()
while(null == fileSystem.refreshAndFindFileByIoFile(newFiles.firstOrNull() ?: throw IllegalStateException())) {
while (null == fileSystem.refreshAndFindFileByIoFile(newFiles.firstOrNull() ?: throw IllegalStateException())) {
if (System.currentTimeMillis() - start > 10000) {
throw IllegalStateException("File not found: ${newFiles.firstOrNull()}")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.simiacryptus.aicoder.actions

import com.github.simiacryptus.aicoder.util.BrowseUtil
import com.github.simiacryptus.aicoder.util.BrowseUtil.browse
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.simiacryptus.aicoder.actions

import com.github.simiacryptus.aicoder.util.ComputerLanguage
import com.github.simiacryptus.aicoder.util.UITools
import com.github.simiacryptus.aicoder.util.LanguageUtils
import com.github.simiacryptus.aicoder.util.UITools
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.command.WriteCommandAction
Expand Down Expand Up @@ -55,9 +55,9 @@ abstract class SelectionAction<T : Any>(
val editorState = editorState(editor)
val (start, end) = retarget(editorState, selectedText, selectionStart, selectionEnd) ?: return
val text = editorState.text
selectedText = text.substring(start.coerceIn(0, text.length-1), end.coerceIn(0, text.length-1))
selectionEnd = end.coerceIn(0, text.length-1)
selectionStart = start.coerceIn(0, text.length-1)
selectedText = text.substring(start.coerceIn(0, (text.length - 1).coerceAtLeast(0)), end.coerceIn(0, (text.length - 1).coerceAtLeast(0)))
selectionEnd = end.coerceIn(0, (text.length - 1).coerceAtLeast(0))
selectionStart = start.coerceIn(0, (text.length - 1).coerceAtLeast(0))

UITools.redoableTask(e) {
val document = e.getData(CommonDataKeys.EDITOR)?.document
Expand All @@ -74,7 +74,7 @@ abstract class SelectionAction<T : Any>(
selectionOffset = selectionStart,
selectionLength = selectionEnd - selectionStart,
entireDocument = editor.document.text,
language = LanguageUtils.getComputerLanguage(e),
language = LanguageUtils.getComputerLanguage(e),
indent = indent,
contextRanges = editorState.contextRanges,
psiFile = editorState.psiFile,
Expand Down Expand Up @@ -160,7 +160,7 @@ abstract class SelectionAction<T : Any>(
if (start >= end) return false
}
}
val computerLanguage = LanguageUtils.getComputerLanguage(event)
val computerLanguage = LanguageUtils.getComputerLanguage(event)
return isLanguageSupported(computerLanguage)
}

Expand All @@ -177,7 +177,7 @@ abstract class SelectionAction<T : Any>(
)

open fun isLanguageSupported(computerLanguage: ComputerLanguage?): Boolean {
return LanguageUtils.isLanguageSupported(computerLanguage)
return LanguageUtils.isLanguageSupported(computerLanguage)
}

open fun defaultSelection(editorState: EditorState, offset: Int) = editorState.line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package com.github.simiacryptus.aicoder.actions.code

import com.github.simiacryptus.aicoder.actions.SelectionAction
import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.simiacryptus.jopenai.models.chatModel
import com.github.simiacryptus.aicoder.util.IndentedText
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.project.Project
import com.simiacryptus.jopenai.models.chatModel
import com.simiacryptus.jopenai.proxy.ChatProxy
import com.simiacryptus.util.StringUtil

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package com.github.simiacryptus.aicoder.actions.code

import com.github.simiacryptus.aicoder.actions.SelectionAction
import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.simiacryptus.jopenai.models.chatModel
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
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.models.ChatModels
import com.simiacryptus.jopenai.models.ChatModel
import com.simiacryptus.jopenai.models.chatModel
import com.simiacryptus.jopenai.proxy.ChatProxy
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import java.awt.Toolkit
import java.awt.datatransfer.DataFlavor
import kotlin.toString

abstract class PasteActionBase(private val model: (AppSettingsState) -> ChatModels) : SelectionAction<String>(false) {
abstract class PasteActionBase(private val model: (AppSettingsState) -> ChatModel) : SelectionAction<String>(false) {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

interface VirtualAPI {
Expand Down Expand Up @@ -81,20 +81,62 @@ abstract class PasteActionBase(private val model: (AppSettingsState) -> ChatMode
}
}

protected open fun scrubHtml(str: String): String {
protected open fun scrubHtml(str: String, maxLength: Int = 100 * 1024): String {
val document: Document = Jsoup.parse(str)
document.select("script, style").remove() // Remove script and style tags
document.select("*").forEach { element ->
val importantAttributes = listOf("href", "src", "alt", "title", "width", "height", "style", "class", "id")
element.attributes().filter { it.key !in importantAttributes }.forEach { element.removeAttr(it.key) }
} // Remove all non-important attributes
document.select("*").forEach { element ->
if (element.text().isNullOrEmpty()) {
element.remove()
// Remove unnecessary elements, attributes, and optimize the document
document.apply {
if (document.body().html().length > maxLength) return@apply
select("script, style, link, meta, iframe, noscript").remove() // Remove unnecessary and potentially harmful tags
outputSettings().prettyPrint(false) // Disable pretty printing for compact output
if (document.body().html().length > maxLength) return@apply
// Remove comments
select("*").forEach { it.childNodes().removeAll { node -> node.nodeName() == "#comment" } }
if (document.body().html().length > maxLength) return@apply
// Remove data-* attributes
select("*[data-*]").forEach { it.attributes().removeAll { attr -> attr.key.startsWith("data-") } }
if (document.body().html().length > maxLength) return@apply
select("*").forEach { element ->
val importantAttributes = setOf("href", "src", "alt", "title", "width", "height", "style", "class", "id", "name")
element.attributes().removeAll { it.key !in importantAttributes }
}
if (document.body().html().length > maxLength) return@apply
// Remove empty elements
select("*").filter { it.text().isBlank() && it.attributes().isEmpty() && !it.hasAttr("img") }.forEach { remove() }
if (document.body().html().length > maxLength) return@apply
// Unwrap single-child elements with no attributes
select("*").forEach { element ->
if (element.childNodes().size == 1 && element.childNodes()[0].nodeName() == "#text" && element.attributes().isEmpty()) {
element.unwrap()
}
}
if (document.body().html().length > maxLength) return@apply
// Convert relative URLs to absolute
select("[href],[src]").forEach { element ->
element.attr("href")?.let { href -> element.attr("href", href.makeAbsolute()) }
element.attr("src")?.let { src -> element.attr("src", src.makeAbsolute()) }
}
} // Remove elements with empty text
val text = document.toString()
return text // Return the plain text content
if (document.body().html().length > maxLength) return@apply
// Remove empty attributes
select("*").forEach { element ->
element.attributes().removeAll { it.value.isBlank() }
}
}

// Truncate if necessary
val result = document.body().html()
return if (result.length > maxLength) {
result.substring(0, maxLength)
} else {
result
}
}

private fun String.makeAbsolute(): String {
return if (startsWith("http://") || startsWith("https://") || startsWith("//")) {
this
} else {
"https://$this"
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.simiacryptus.jopenai.models.chatModel
import com.simiacryptus.skyenet.core.platform.ApplicationServices
import com.simiacryptus.skyenet.core.platform.StorageInterface
import com.simiacryptus.skyenet.core.platform.User
import com.simiacryptus.skyenet.core.platform.Session
import com.simiacryptus.skyenet.core.platform.model.User
import com.simiacryptus.skyenet.util.MarkdownUtil.renderMarkdown
import com.simiacryptus.skyenet.webui.application.ApplicationServer
import com.simiacryptus.skyenet.webui.chat.ChatSocketManager
Expand All @@ -27,7 +27,7 @@ class LineFilterChatAction : BaseAction() {

override fun handle(e: AnActionEvent) {
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
val session = StorageInterface.newGlobalID()
val session = Session.newGlobalID()
val language = ComputerLanguage.getComputerLanguage(e)?.name ?: return
val filename = FileDocumentManager.getInstance().getFile(editor.document)?.name ?: return
val code = editor.caretModel.primaryCaret.selectedText ?: editor.document.text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import com.github.simiacryptus.aicoder.AppServer
import com.github.simiacryptus.aicoder.actions.BaseAction
import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.simiacryptus.jopenai.models.chatModel
import com.github.simiacryptus.aicoder.util.BrowseUtil.browse
import com.github.simiacryptus.aicoder.util.CodeChatSocketManager
import com.github.simiacryptus.aicoder.util.LanguageUtils
import com.github.simiacryptus.aicoder.util.BrowseUtil.browse
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.simiacryptus.jopenai.models.chatModel
import com.simiacryptus.skyenet.core.platform.ApplicationServices
import com.simiacryptus.skyenet.core.platform.StorageInterface
import com.simiacryptus.skyenet.core.platform.Session
import com.simiacryptus.skyenet.webui.application.AppInfoData
import com.simiacryptus.skyenet.webui.application.ApplicationServer
import org.slf4j.LoggerFactory
Expand All @@ -23,7 +23,7 @@ class CodeChatAction : BaseAction() {
override fun handle(e: AnActionEvent) {
val editor = e.getData(CommonDataKeys.EDITOR) ?: return

val session = StorageInterface.newGlobalID()
val session = Session.newGlobalID()
val language = LanguageUtils.getComputerLanguage(e)?.name ?: ""
val filename = FileDocumentManager.getInstance().getFile(editor.document)?.name ?: return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ 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.util.UITools
import com.github.simiacryptus.aicoder.util.BrowseUtil.browse
import com.github.simiacryptus.aicoder.util.UITools
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.PlatformDataKeys
Expand All @@ -14,7 +14,7 @@ import com.intellij.openapi.ui.DialogWrapper
import com.simiacryptus.jopenai.models.chatModel
import com.simiacryptus.skyenet.apps.general.CmdPatchApp
import com.simiacryptus.skyenet.apps.general.PatchApp
import com.simiacryptus.skyenet.core.platform.StorageInterface
import com.simiacryptus.skyenet.core.platform.Session
import com.simiacryptus.skyenet.webui.application.AppInfoData
import com.simiacryptus.skyenet.webui.application.ApplicationServer
import org.slf4j.LoggerFactory
Expand All @@ -37,7 +37,7 @@ class CommandAutofixAction : BaseAction() {
} else {
event.project?.basePath?.let { File(it).toPath() }
}!!
val session = StorageInterface.newGlobalID()
val session = Session.newGlobalID()
val patchApp = CmdPatchApp(
root,
session,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.github.simiacryptus.aicoder.actions.generic

import ai.grazie.utils.dropPrefix
import com.github.simiacryptus.aicoder.actions.FileContextAction
import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.github.simiacryptus.aicoder.util.UITools
import com.github.simiacryptus.aicoder.config.Name
import com.github.simiacryptus.aicoder.util.UITools
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
Expand All @@ -29,10 +28,12 @@ class CreateFileFromDescriptionAction : FileContextAction<CreateFileFromDescript
120
)
}

class Settings(
var directive: String = "",
val project: Project? = null
)

override fun getConfig(project: Project?, e: AnActionEvent): Settings {
val userSettings = UITools.showDialog(
project,
Expand Down
Loading

0 comments on commit 1196e02

Please sign in to comment.