Skip to content

Commit

Permalink
1.3.9 (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski authored Apr 2, 2024
1 parent 25cec02 commit 0833c79
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 114 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repositories {
val kotlin_version = "1.9.21"
val jetty_version = "11.0.18"
val slf4j_version = "2.0.9"
val skyenet_version = "1.0.59"
val skyenet_version = "1.0.60"
val remoterobot_version = "0.11.21"
dependencies {

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.8
pluginVersion=1.3.9

jvmArgs=-Xmx8g
org.gradle.jvmargs=-Xmx8g
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class AnalogueFileAction : FileContextAction<AnalogueFileAction.Settings>() {
|The file should be based on `${baseFile.path}` which contains the following code:
|
|```
|${baseFile.code?.let { /*escapeHtml4*/it.indent(" ") }}
|${baseFile.code?.let { /*escapeHtml4*/it/*.indent(" ")*/ }}
|```
""".trimMargin().toContentList(), null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class AutoDevAction : BaseAction() {
fun codeSummary() = codeFiles.entries.joinToString("\n\n") { (path, code) ->
"# $path\n```${
path.split('.').last()
}\n${code.indent(" ")}\n```"
}\n${code/*.indent(" ")*/}\n```"
}

val task = ui.newTask()
Expand All @@ -183,11 +183,11 @@ 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).indent(" ")}\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).indent(" ")}\n```"),
"Text" to renderMarkdown(design.text, ui=ui),
"JSON" to renderMarkdown("```json\n${toJson(design.obj)/*.indent(" ")*/}\n```", ui=ui),
)
)
},
Expand All @@ -207,7 +207,7 @@ class AutoDevAction : BaseAction() {

try {
architectureResponse.obj.tasks.forEach { (paths, description) ->
task.complete(ui.hrefLink(renderMarkdown("Task: $description")) {
task.complete(ui.hrefLink(renderMarkdown("Task: $description", ui=ui)) {
val task = ui.newTask()
task.header("Task: $description")
val process = { it: StringBuilder ->
Expand Down Expand Up @@ -235,8 +235,8 @@ class AutoDevAction : BaseAction() {
userMessage,
filter.entries.joinToString("\n\n") {
"# ${it.key}\n```${
it.key.split('.').last()?.let { /*escapeHtml4*/it.indent(" ") }
}\n${it.value.indent(" ")}\n```"
it.key.split('.').last()?.let { /*escapeHtml4*/it/*.indent(" ")*/ }
}\n${it.value/*.indent(" ")*/}\n```"
},
architectureResponse.text,
"Provide a change for ${paths?.joinToString(",") { it } ?: ""} ($description)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ 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.set
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.session.SessionTask
Expand Down Expand Up @@ -84,12 +86,15 @@ class DiffChatAction : BaseAction() {
Note: The diff should accurately reflect the changes to be made to the code, including sufficient context to ensure the modifications can be correctly applied.
""".trimIndent()

val ui by lazy { ApplicationInterface(this) }
override fun renderResponse(response: String, task: SessionTask): String {
val withLinks = addApplyDiffLinks(rawText, response, handle = { newCode: String ->
val codeBuffer = StringBuilder(rawText)
val withLinks = addApplyDiffLinks(codeBuffer, response, handle = { newCode: String ->
WriteCommandAction.runWriteCommandAction(e.project) {
document.replaceString(selectionStart, selectionEnd, newCode)
document.replaceString(selectionStart, selectionStart + codeBuffer.length, newCode)
}
}, task = task)
codeBuffer.set(newCode)
}, task = task, ui=ui)
val html = renderMarkdown(withLinks)
return """<div>$html</div>"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LineFilterChatAction : BaseAction() {
|# `$filename`
|
|```$language
|${code?.let { /*escapeHtml4*/(it).indent(" ") }}
|${code?.let { /*escapeHtml4*/(it)/*.indent(" ")*/ }}
|```
""".trimMargin().trim(),
systemPrompt = """
Expand All @@ -53,7 +53,7 @@ class LineFilterChatAction : BaseAction() {
|You will be answering questions about the following code located in `$filename`:
|
|```$language
|${codelines?.let { /*escapeHtml4*/(it).indent(" ") }}
|${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 @@ -48,20 +48,6 @@ import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.atomic.AtomicReference
import kotlin.reflect.KClass

/**
* The provided Kotlin code outlines a complex application designed for task planning and execution, integrating with a chat server and utilizing AI models for task breakdown, documentation generation, new file creation, file patching, and inquiries. The application leverages several components, including an IntelliJ plugin, a web UI, and AI-driven actors for processing user inputs and generating code or documentation. Below is a mermaid.js diagram that visualizes the high-level architecture and flow of this application.
*
* ### Key Components and Flow:
*
* - **TaskRunner**: Initiates the task planning process, interacts with the `AppServer` for web UI, selects files via `DataStorage`, and opens a browser window for user interaction.
* - **AppServer & TaskRunnerApp**: Hosts the application server and registers the `TaskRunnerApp` which manages sessions and settings.
* - **TaskRunnerAgent**: Acts as the central processor for user messages, utilizing an `ActorSystem` to delegate tasks to specific actors based on the task type.
* - **ActorSystem & Actors (TaskBreakdown, DocumentationGenerator, etc.)**: Processes user messages to perform specific actions like task breakdown, documentation generation, file creation, patching, and inquiries.
* - **Results (TaskBreakdownResult, Documentation, etc.)**: Outputs generated by the actors, which are used for further task planning, code documentation, file creation, or patching.
*
* This diagram and description provide a simplified overview of the application's architecture and logic flow. The actual implementation may involve more detailed interactions and components not fully captured here.
*
* */
class TaskRunnerAction : BaseAction() {

val path = "/taskDev"
Expand Down Expand Up @@ -295,7 +281,7 @@ class TaskRunnerAgent(
model = model,
temperature = temperature,
),
)+ (if (!shellCommandTaskEnabled) mapOf() else mapOf(
) + (if (!shellCommandTaskEnabled) mapOf() else mapOf(
ActorTypes.RunShellCommand to CodingActor(
interpreterClass = ProcessInterpreter::class,
details = """
Expand Down Expand Up @@ -408,7 +394,7 @@ class TaskRunnerAgent(
"""
|## $path
|
|${(codeFiles[path.toString()] ?: "").let { "```\n${it.indent(" ")}\n```" }}
|${(codeFiles[path.toString()] ?: "").let { "```\n${it/*.indent(" ")*/}\n```" }}
""".trimMargin()
}
}
Expand All @@ -423,14 +409,14 @@ class TaskRunnerAgent(
}
val highLevelPlan = Acceptable(
task = task,
heading = renderMarkdown(userMessage),
heading = renderMarkdown(userMessage, ui=ui),
userMessage = userMessage,
initialResponse = { it: String -> taskBreakdownActor.answer(toInput(it), api = api) },
outputFn = { design: ParsedResponse<TaskBreakdownResult> ->
displayMapInTabs(
mapOf(
"Text" to renderMarkdown(design.text),
"JSON" to renderMarkdown("```json\n${toJson(design.obj).indent(" ")}\n```"),
"Text" to renderMarkdown(design.text, ui=ui),
"JSON" to renderMarkdown("```json\n${toJson(design.obj)/*.indent(" ")*/}\n```", ui=ui),
)
)
},
Expand All @@ -453,10 +439,10 @@ class TaskRunnerAgent(
val genState = GenState(tasksByID.toMutableMap())
val diagramTask = ui.newTask()
val diagramBuffer =
diagramTask.add(renderMarkdown("## Task Dependency Graph\n```mermaid\n${buildMermaidGraph(genState.subTasks)}\n```"))
diagramTask.add(renderMarkdown("## Task Dependency Graph\n```mermaid\n${buildMermaidGraph(genState.subTasks)}\n```", ui=ui))
val taskTabs = object : TabbedDisplay(ui.newTask()) {
override fun renderTabButtons(): String {
diagramBuffer?.set(renderMarkdown("## Task Dependency Graph\n```mermaid\n${buildMermaidGraph(genState.subTasks)}\n```"))
diagramBuffer?.set(renderMarkdown("## Task Dependency Graph\n```mermaid\n${buildMermaidGraph(genState.subTasks)}\n```", ui=ui))
diagramTask.complete()
return buildString {
append("<div class='tabs'>\n")
Expand Down Expand Up @@ -589,13 +575,13 @@ class TaskRunnerAgent(
|${subTask.description ?: ""}
|
|```json
|${toJson(subTask).indent(" ")}
|${toJson(subTask)/*.indent(" ")*/}
|```
|
|### Dependencies:
|${dependencies.joinToString("\n") { "- $it" }}
|
""".trimMargin()
""".trimMargin(), ui=ui
)
)

Expand Down Expand Up @@ -678,7 +664,7 @@ class TaskRunnerAgent(
}

TaskType.TaskPlanning -> {
if(taskPlanningEnabled) taskPlanning(
if (taskPlanningEnabled) taskPlanning(
subTask = subTask,
userMessage = userMessage,
highLevelPlan = highLevelPlan,
Expand Down Expand Up @@ -740,49 +726,49 @@ class TaskRunnerAgent(
taskTabs: TabbedDisplay,
function: () -> Unit
) {
object : CodingAgent<ProcessInterpreter>(
api = api,
dataStorage = dataStorage,
session = session,
user = user,
ui = ui,
interpreter = shellCommandActor.interpreterClass as KClass<ProcessInterpreter>,
symbols = shellCommandActor.symbols,
temperature = shellCommandActor.temperature,
details = shellCommandActor.details,
model = shellCommandActor.model,
object : CodingAgent<ProcessInterpreter>(
api = api,
dataStorage = dataStorage,
session = session,
user = user,
ui = ui,
interpreter = shellCommandActor.interpreterClass as KClass<ProcessInterpreter>,
symbols = shellCommandActor.symbols,
temperature = shellCommandActor.temperature,
details = shellCommandActor.details,
model = shellCommandActor.model,
) {
override fun displayFeedback(
task: SessionTask,
request: CodingActor.CodeRequest,
response: CodingActor.CodeResult
) {
override fun displayFeedback(
task: SessionTask,
request: CodingActor.CodeRequest,
response: CodingActor.CodeResult
) {
val formText = StringBuilder()
var formHandle: StringBuilder? = null
formHandle = task.add(
"""
val formText = StringBuilder()
var formHandle: StringBuilder? = null
formHandle = task.add(
"""
|<div style="display: flex;flex-direction: column;">
|${if (!super.canPlay) "" else super.playButton(task, request, response, formText) { formHandle!! }}
|${acceptButton(task, request, response, formText) { formHandle!! }}
|</div>
|${super.reviseMsg(task, request, response, formText) { formHandle!! }}
""".trimMargin(), className = "reply-message"
)
formText.append(formHandle.toString())
formHandle.toString()
task.complete()
}
)
formText.append(formHandle.toString())
formHandle.toString()
task.complete()
}

fun acceptButton(
task: SessionTask,
request: CodingActor.CodeRequest,
response: CodingActor.CodeResult,
formText: StringBuilder,
formHandle: () -> StringBuilder
): String {
task: SessionTask,
request: CodingActor.CodeRequest,
response: CodingActor.CodeResult,
formText: StringBuilder,
formHandle: () -> StringBuilder
): String {
return ui.hrefLink("\uD83D\uDC4D", "href-link play-button") {
genState.taskResult[taskId] = response.let {
"""
genState.taskResult[taskId] = response.let {
"""
|## Shell Command Output
|
|```
Expand All @@ -793,17 +779,21 @@ class TaskRunnerAgent(
|${response.renderedResponse}
|```
""".trimMargin()
}
function()
}
function()
}
}
}.apply {
start(codeRequest(listOf(
userMessage to Role.user,
highLevelPlan.text to Role.assistant,
priorCode to Role.assistant,
inputFileCode to Role.assistant,
)))
start(
codeRequest(
listOf(
userMessage to Role.user,
highLevelPlan.text to Role.assistant,
priorCode to Role.assistant,
inputFileCode to Role.assistant,
)
)
)
}
}

Expand Down Expand Up @@ -841,7 +831,7 @@ class TaskRunnerAgent(
} else {
task.complete("No changes to $path")
}
}) + accept(sb) {
}, ui=ui) + accept(sb) {
taskTabs.selectedTab = taskTabs.selectedTab + 1
taskTabs.update()
onComplete()
Expand Down Expand Up @@ -905,7 +895,7 @@ class TaskRunnerAgent(
taskTabs.update()
task.complete()
onComplete()
})
}, ui=ui)
}
object : Retryable(ui, task, process) {
init {
Expand Down Expand Up @@ -935,7 +925,7 @@ class TaskRunnerAgent(
).filter { it.isNotBlank() }, api
)
genState.taskResult[taskId] = docResult
renderMarkdown("## Generated Documentation\n$docResult") + accept(sb) {
renderMarkdown("## Generated Documentation\n$docResult", ui=ui) + accept(sb) {
taskTabs.selectedTab = taskTabs.selectedTab + 1
taskTabs.update()
task.complete()
Expand Down Expand Up @@ -995,7 +985,7 @@ class TaskRunnerAgent(
heading = "",
initialResponse = { it: String -> inquiryActor.answer(toInput(it), api = api) },
outputFn = { design: String ->
renderMarkdown(design)
renderMarkdown(design, ui=ui)
},
ui = ui,
reviseResponse = { userMessages: List<Pair<String, Role>> ->
Expand Down Expand Up @@ -1041,8 +1031,8 @@ class TaskRunnerAgent(
outputFn = { design: ParsedResponse<TaskBreakdownResult> ->
displayMapInTabs(
mapOf(
"Text" to renderMarkdown(design.text),
"JSON" to renderMarkdown("```json\n${toJson(design.obj).indent(" ")}\n```"),
"Text" to renderMarkdown(design.text, ui=ui),
"JSON" to renderMarkdown("```json\n${toJson(design.obj)/*.indent(" ")*/}\n```", ui=ui),
)
)
},
Expand Down
Loading

0 comments on commit 0833c79

Please sign in to comment.