Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.3.5 #141

Merged
merged 1 commit into from
Mar 26, 2024
Merged

1.3.5 #141

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ repositories {
val kotlin_version = "1.9.21"
val jetty_version = "11.0.18"
val slf4j_version = "2.0.9"
val skyenet_version = "1.0.55"
val skyenet_version = "1.0.56"
val remoterobot_version = "0.11.21"
dependencies {

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")

implementation("org.apache.commons:commons-text:1.11.0")

implementation(group = "com.simiacryptus.skyenet", name = "kotlin", version = skyenet_version)
{
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.3.4
pluginVersion=1.3.5

jvmArgs=-Xmx8g
org.gradle.jvmargs=-Xmx8g
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.github.simiacryptus.aicoder.config.AppSettingsState.Companion.chatModel
import com.github.simiacryptus.aicoder.config.Name
import com.github.simiacryptus.aicoder.util.UITools
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.LocalFileSystem
import com.simiacryptus.jopenai.ApiModel
import com.simiacryptus.jopenai.ApiModel.ChatMessage
import com.simiacryptus.jopenai.ApiModel.Role
import com.simiacryptus.jopenai.util.ClientUtil.toContentList
import com.simiacryptus.skyenet.core.actors.CodingActor.Companion.indent
import org.apache.commons.io.FileUtils
import org.apache.commons.io.IOUtils
import org.apache.commons.text.StringEscapeUtils.escapeHtml4
import java.io.File
import java.io.FileInputStream
import java.nio.file.Path
Expand Down Expand Up @@ -106,14 +108,14 @@ class AnalogueFileAction : FileContextAction<AnalogueFileAction.Settings>() {
),
ChatMessage(
Role.user, """
Create a new file based on the following directive: $directive

The file should be based on `${baseFile.path}` which contains the following code:

```
${baseFile.code}
```
""".trimIndent().toContentList(), null
|Create a new file based on the following directive: $directive
|
|The file should be based on `${baseFile.path}` which contains the following code:
|
|```
|${baseFile.code?.let { escapeHtml4(it).indent(" ") }}
|```
""".trimMargin().toContentList(), null
)

)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import com.simiacryptus.skyenet.Acceptable
import com.simiacryptus.skyenet.AgentPatterns
import com.simiacryptus.skyenet.Retryable
import com.simiacryptus.skyenet.core.actors.*
import com.simiacryptus.skyenet.core.actors.CodingActor.Companion.indent
import com.simiacryptus.skyenet.core.platform.*
import com.simiacryptus.skyenet.core.platform.file.DataStorage
import com.simiacryptus.skyenet.webui.application.ApplicationInterface
import com.simiacryptus.skyenet.webui.application.ApplicationServer
import com.simiacryptus.skyenet.webui.chat.ChatServer
import com.simiacryptus.skyenet.webui.util.MarkdownUtil.renderMarkdown
import org.apache.commons.text.StringEscapeUtils.escapeHtml4
import org.slf4j.LoggerFactory
import java.awt.Desktop
import java.io.File
Expand Down Expand Up @@ -171,7 +173,7 @@ class AutoDevAction : BaseAction() {
fun codeSummary() = codeFiles.entries.joinToString("\n\n") { (path, code) ->
"# $path\n```${
path.split('.').last()
}\n$code\n```"
}\n${code.indent(" ")}\n```"
}

val task = ui.newTask()
Expand All @@ -181,10 +183,10 @@ class AutoDevAction : BaseAction() {
userMessage = userMessage,
initialResponse = { it: String -> designActor.answer(toInput(it), api = api) },
outputFn = { design: ParsedResponse<TaskList> ->
// renderMarkdown("${design.text}\n\n```json\n${JsonUtil.toJson(design.obj)}\n```")
// renderMarkdown("${design.text}\n\n```json\n${JsonUtil.toJson(design.obj).indent(" ")}\n```")
AgentPatterns.displayMapInTabs(mapOf(
"Text" to renderMarkdown(design.text),
"JSON" to renderMarkdown("```json\n${toJson(design.obj)}\n```"),
"JSON" to renderMarkdown("```json\n${toJson(design.obj).indent(" ")}\n```"),
)
)
},
Expand Down Expand Up @@ -223,36 +225,36 @@ class AutoDevAction : BaseAction() {
|
""".trimMargin()
}
renderMarkdown(
ui.socketManager.addApplyDiffLinks2(
code = codeFiles,
response = taskActor.answer(listOf(
codeSummary(),
userMessage,
filter.entries.joinToString("\n\n") {
"# ${it.key}\n```${it.key.split('.').last()}\n${it.value}\n```"
},
architectureResponse.text,
"Provide a change for ${paths?.joinToString(",") { it } ?: ""} ($description)"
), api),
task = task,
handle = { newCodeMap ->
newCodeMap.forEach { (path, newCode) ->
val prev = codeFiles[path]
if (prev != newCode) {
codeFiles[path] = newCode
task.complete(
"<a href='${
task.saveFile(
path,
newCode.toByteArray(Charsets.UTF_8)
)
}'>$path</a> Updated"
)
}
ui.socketManager.addApplyDiffLinks2(
code = codeFiles,
response = taskActor.answer(listOf(
codeSummary(),
userMessage,
filter.entries.joinToString("\n\n") {
"# ${it.key}\n```${it.key.split('.').last()?.let { escapeHtml4(it).indent(" ") }}\n${it.value.indent(" ")}\n```"
},
architectureResponse.text,
"Provide a change for ${paths?.joinToString(",") { it } ?: ""} ($description)"
), api),
handle = { newCodeMap ->
newCodeMap.forEach { (path, newCode) ->
val prev = codeFiles[path]
if (prev != newCode) {
codeFiles[path] = newCode
task.complete(
"<a href='${
task.saveFile(
path,
newCode.toByteArray(Charsets.UTF_8)
)
}'>$path</a> Updated"
)
}
}
))
},
task = task,
ui = ui
)
}
Retryable(ui, task, process).apply { addTab(ui, process(container!!)) }
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.github.simiacryptus.aicoder.util.ComputerLanguage
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.simiacryptus.skyenet.core.actors.CodingActor.Companion.indent
import com.simiacryptus.skyenet.core.platform.ApplicationServices
import com.simiacryptus.skyenet.core.platform.Session
import com.simiacryptus.skyenet.core.platform.StorageInterface
Expand All @@ -19,6 +20,7 @@ import com.simiacryptus.skyenet.webui.chat.ChatSocketManager
import com.simiacryptus.skyenet.webui.session.SessionTask
import com.simiacryptus.skyenet.webui.session.SocketManager
import com.simiacryptus.skyenet.webui.util.MarkdownUtil.renderMarkdown
import org.apache.commons.text.StringEscapeUtils.escapeHtml4
import org.slf4j.LoggerFactory
import java.awt.Desktop
import java.io.File
Expand All @@ -44,7 +46,7 @@ class LineFilterChatAction : BaseAction() {
|# `$filename`
|
|```$language
|$code
|${code?.let { escapeHtml4(it).indent(" ") }}
|```
""".trimMargin().trim(),
systemPrompt = """
Expand All @@ -53,7 +55,7 @@ class LineFilterChatAction : BaseAction() {
|You will be answering questions about the following code located in `$filename`:
|
|```$language
|$codelines
|${codelines?.let { escapeHtml4(it).indent(" ") }}
|```
|
|Responses may use markdown formatting. Lines from the prompt can be included by using the line number in a response line (e.g. `\nLINE\n`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.PlatformDataKeys
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.simiacryptus.skyenet.core.actors.CodingActor.Companion.indent
import com.simiacryptus.skyenet.core.platform.ApplicationServices
import com.simiacryptus.skyenet.core.platform.Session
import com.simiacryptus.skyenet.core.platform.StorageInterface
Expand All @@ -20,7 +21,7 @@ import com.simiacryptus.skyenet.webui.chat.ChatServer
import com.simiacryptus.skyenet.webui.chat.ChatSocketManager
import com.simiacryptus.skyenet.webui.session.SessionTask
import com.simiacryptus.skyenet.webui.session.SocketManager
import com.simiacryptus.skyenet.webui.util.MarkdownUtil.renderMarkdown
import org.apache.commons.text.StringEscapeUtils.escapeHtml4
import org.slf4j.LoggerFactory
import java.awt.Desktop
import java.io.File
Expand Down Expand Up @@ -52,8 +53,8 @@ class MultiDiffChatAction : BaseAction() {

fun codeSummary() = codeFiles.entries.joinToString("\n\n") { (path, code) ->
"# $path\n```${
path.split('.').last()
}\n$code\n```"
path.split('.').lastOrNull()?.let { escapeHtml4(it).indent(" ") }
}\n${code?.let { escapeHtml4(it).indent(" ") }}\n```"
}
val session = StorageInterface.newGlobalID()
//DataStorage.sessionPaths[session] = root.toFile()
Expand All @@ -63,7 +64,7 @@ class MultiDiffChatAction : BaseAction() {
model = AppSettingsState.instance.smartModel.chatModel(),
userInterfacePrompt = """
|
|${codeSummary()}
|${escapeHtml4(codeSummary())}
|
""".trimMargin().trim(),
systemPrompt = """
Expand Down Expand Up @@ -95,7 +96,8 @@ class MultiDiffChatAction : BaseAction() {
storage = ApplicationServices.dataStorageFactory(DiffChatAction.root),
) {
override fun renderResponse(response: String, task: SessionTask): String {
val html = renderMarkdown(addApplyDiffLinks2(codeFiles, response, handle = { newCodeMap ->
val html = addApplyDiffLinks2(
code = codeFiles, response = response, handle = { newCodeMap ->
newCodeMap.map { (path, newCode) ->
val prev = codeFiles[path]
if (prev != newCode) {
Expand All @@ -115,7 +117,7 @@ class MultiDiffChatAction : BaseAction() {
""
}
}
}, task = task))
}, task = task, ui = null,)
return """<div>$html</div>"""
}
}
Expand Down
Loading
Loading