Skip to content

Commit 0833c79

Browse files
authored
1.3.9 (#147)
1 parent 25cec02 commit 0833c79

File tree

14 files changed

+104
-114
lines changed

14 files changed

+104
-114
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repositories {
2626
val kotlin_version = "1.9.21"
2727
val jetty_version = "11.0.18"
2828
val slf4j_version = "2.0.9"
29-
val skyenet_version = "1.0.59"
29+
val skyenet_version = "1.0.60"
3030
val remoterobot_version = "0.11.21"
3131
dependencies {
3232

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pluginName=intellij-aicoder
22
pluginRepositoryUrl=https://github.com/SimiaCryptus/intellij-aicoder
3-
pluginVersion=1.3.8
3+
pluginVersion=1.3.9
44

55
jvmArgs=-Xmx8g
66
org.gradle.jvmargs=-Xmx8g

src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/AnalogueFileAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class AnalogueFileAction : FileContextAction<AnalogueFileAction.Settings>() {
113113
|The file should be based on `${baseFile.path}` which contains the following code:
114114
|
115115
|```
116-
|${baseFile.code?.let { /*escapeHtml4*/it.indent(" ") }}
116+
|${baseFile.code?.let { /*escapeHtml4*/it/*.indent(" ")*/ }}
117117
|```
118118
""".trimMargin().toContentList(), null
119119
)

src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/AutoDevAction.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class AutoDevAction : BaseAction() {
173173
fun codeSummary() = codeFiles.entries.joinToString("\n\n") { (path, code) ->
174174
"# $path\n```${
175175
path.split('.').last()
176-
}\n${code.indent(" ")}\n```"
176+
}\n${code/*.indent(" ")*/}\n```"
177177
}
178178

179179
val task = ui.newTask()
@@ -183,11 +183,11 @@ class AutoDevAction : BaseAction() {
183183
userMessage = userMessage,
184184
initialResponse = { it: String -> designActor.answer(toInput(it), api = api) },
185185
outputFn = { design: ParsedResponse<TaskList> ->
186-
// renderMarkdown("${design.text}\n\n```json\n${JsonUtil.toJson(design.obj).indent(" ")}\n```")
186+
// renderMarkdown("${design.text}\n\n```json\n${JsonUtil.toJson(design.obj)/*.indent(" ")*/}\n```")
187187
AgentPatterns.displayMapInTabs(
188188
mapOf(
189-
"Text" to renderMarkdown(design.text),
190-
"JSON" to renderMarkdown("```json\n${toJson(design.obj).indent(" ")}\n```"),
189+
"Text" to renderMarkdown(design.text, ui=ui),
190+
"JSON" to renderMarkdown("```json\n${toJson(design.obj)/*.indent(" ")*/}\n```", ui=ui),
191191
)
192192
)
193193
},
@@ -207,7 +207,7 @@ class AutoDevAction : BaseAction() {
207207

208208
try {
209209
architectureResponse.obj.tasks.forEach { (paths, description) ->
210-
task.complete(ui.hrefLink(renderMarkdown("Task: $description")) {
210+
task.complete(ui.hrefLink(renderMarkdown("Task: $description", ui=ui)) {
211211
val task = ui.newTask()
212212
task.header("Task: $description")
213213
val process = { it: StringBuilder ->
@@ -235,8 +235,8 @@ class AutoDevAction : BaseAction() {
235235
userMessage,
236236
filter.entries.joinToString("\n\n") {
237237
"# ${it.key}\n```${
238-
it.key.split('.').last()?.let { /*escapeHtml4*/it.indent(" ") }
239-
}\n${it.value.indent(" ")}\n```"
238+
it.key.split('.').last()?.let { /*escapeHtml4*/it/*.indent(" ")*/ }
239+
}\n${it.value/*.indent(" ")*/}\n```"
240240
},
241241
architectureResponse.text,
242242
"Provide a change for ${paths?.joinToString(",") { it } ?: ""} ($description)"

src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/DiffChatAction.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import com.simiacryptus.skyenet.core.platform.ApplicationServices
1515
import com.simiacryptus.skyenet.core.platform.Session
1616
import com.simiacryptus.skyenet.core.platform.StorageInterface
1717
import com.simiacryptus.skyenet.core.platform.User
18+
import com.simiacryptus.skyenet.set
19+
import com.simiacryptus.skyenet.webui.application.ApplicationInterface
1820
import com.simiacryptus.skyenet.webui.application.ApplicationServer
1921
import com.simiacryptus.skyenet.webui.chat.ChatServer
2022
import com.simiacryptus.skyenet.webui.session.SessionTask
@@ -84,12 +86,15 @@ class DiffChatAction : BaseAction() {
8486
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.
8587
""".trimIndent()
8688

89+
val ui by lazy { ApplicationInterface(this) }
8790
override fun renderResponse(response: String, task: SessionTask): String {
88-
val withLinks = addApplyDiffLinks(rawText, response, handle = { newCode: String ->
91+
val codeBuffer = StringBuilder(rawText)
92+
val withLinks = addApplyDiffLinks(codeBuffer, response, handle = { newCode: String ->
8993
WriteCommandAction.runWriteCommandAction(e.project) {
90-
document.replaceString(selectionStart, selectionEnd, newCode)
94+
document.replaceString(selectionStart, selectionStart + codeBuffer.length, newCode)
9195
}
92-
}, task = task)
96+
codeBuffer.set(newCode)
97+
}, task = task, ui=ui)
9398
val html = renderMarkdown(withLinks)
9499
return """<div>$html</div>"""
95100
}

src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/LineFilterChatAction.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class LineFilterChatAction : BaseAction() {
4444
|# `$filename`
4545
|
4646
|```$language
47-
|${code?.let { /*escapeHtml4*/(it).indent(" ") }}
47+
|${code?.let { /*escapeHtml4*/(it)/*.indent(" ")*/ }}
4848
|```
4949
""".trimMargin().trim(),
5050
systemPrompt = """
@@ -53,7 +53,7 @@ class LineFilterChatAction : BaseAction() {
5353
|You will be answering questions about the following code located in `$filename`:
5454
|
5555
|```$language
56-
|${codelines?.let { /*escapeHtml4*/(it).indent(" ") }}
56+
|${codelines?.let { /*escapeHtml4*/(it)/*.indent(" ")*/ }}
5757
|```
5858
|
5959
|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`).

src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/TaskRunnerAction.kt

Lines changed: 61 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,6 @@ import java.util.concurrent.ThreadPoolExecutor
4848
import java.util.concurrent.atomic.AtomicReference
4949
import kotlin.reflect.KClass
5050

51-
/**
52-
* 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.
53-
*
54-
* ### Key Components and Flow:
55-
*
56-
* - **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.
57-
* - **AppServer & TaskRunnerApp**: Hosts the application server and registers the `TaskRunnerApp` which manages sessions and settings.
58-
* - **TaskRunnerAgent**: Acts as the central processor for user messages, utilizing an `ActorSystem` to delegate tasks to specific actors based on the task type.
59-
* - **ActorSystem & Actors (TaskBreakdown, DocumentationGenerator, etc.)**: Processes user messages to perform specific actions like task breakdown, documentation generation, file creation, patching, and inquiries.
60-
* - **Results (TaskBreakdownResult, Documentation, etc.)**: Outputs generated by the actors, which are used for further task planning, code documentation, file creation, or patching.
61-
*
62-
* 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.
63-
*
64-
* */
6551
class TaskRunnerAction : BaseAction() {
6652

6753
val path = "/taskDev"
@@ -295,7 +281,7 @@ class TaskRunnerAgent(
295281
model = model,
296282
temperature = temperature,
297283
),
298-
)+ (if (!shellCommandTaskEnabled) mapOf() else mapOf(
284+
) + (if (!shellCommandTaskEnabled) mapOf() else mapOf(
299285
ActorTypes.RunShellCommand to CodingActor(
300286
interpreterClass = ProcessInterpreter::class,
301287
details = """
@@ -408,7 +394,7 @@ class TaskRunnerAgent(
408394
"""
409395
|## $path
410396
|
411-
|${(codeFiles[path.toString()] ?: "").let { "```\n${it.indent(" ")}\n```" }}
397+
|${(codeFiles[path.toString()] ?: "").let { "```\n${it/*.indent(" ")*/}\n```" }}
412398
""".trimMargin()
413399
}
414400
}
@@ -423,14 +409,14 @@ class TaskRunnerAgent(
423409
}
424410
val highLevelPlan = Acceptable(
425411
task = task,
426-
heading = renderMarkdown(userMessage),
412+
heading = renderMarkdown(userMessage, ui=ui),
427413
userMessage = userMessage,
428414
initialResponse = { it: String -> taskBreakdownActor.answer(toInput(it), api = api) },
429415
outputFn = { design: ParsedResponse<TaskBreakdownResult> ->
430416
displayMapInTabs(
431417
mapOf(
432-
"Text" to renderMarkdown(design.text),
433-
"JSON" to renderMarkdown("```json\n${toJson(design.obj).indent(" ")}\n```"),
418+
"Text" to renderMarkdown(design.text, ui=ui),
419+
"JSON" to renderMarkdown("```json\n${toJson(design.obj)/*.indent(" ")*/}\n```", ui=ui),
434420
)
435421
)
436422
},
@@ -453,10 +439,10 @@ class TaskRunnerAgent(
453439
val genState = GenState(tasksByID.toMutableMap())
454440
val diagramTask = ui.newTask()
455441
val diagramBuffer =
456-
diagramTask.add(renderMarkdown("## Task Dependency Graph\n```mermaid\n${buildMermaidGraph(genState.subTasks)}\n```"))
442+
diagramTask.add(renderMarkdown("## Task Dependency Graph\n```mermaid\n${buildMermaidGraph(genState.subTasks)}\n```", ui=ui))
457443
val taskTabs = object : TabbedDisplay(ui.newTask()) {
458444
override fun renderTabButtons(): String {
459-
diagramBuffer?.set(renderMarkdown("## Task Dependency Graph\n```mermaid\n${buildMermaidGraph(genState.subTasks)}\n```"))
445+
diagramBuffer?.set(renderMarkdown("## Task Dependency Graph\n```mermaid\n${buildMermaidGraph(genState.subTasks)}\n```", ui=ui))
460446
diagramTask.complete()
461447
return buildString {
462448
append("<div class='tabs'>\n")
@@ -589,13 +575,13 @@ class TaskRunnerAgent(
589575
|${subTask.description ?: ""}
590576
|
591577
|```json
592-
|${toJson(subTask).indent(" ")}
578+
|${toJson(subTask)/*.indent(" ")*/}
593579
|```
594580
|
595581
|### Dependencies:
596582
|${dependencies.joinToString("\n") { "- $it" }}
597583
|
598-
""".trimMargin()
584+
""".trimMargin(), ui=ui
599585
)
600586
)
601587

@@ -678,7 +664,7 @@ class TaskRunnerAgent(
678664
}
679665

680666
TaskType.TaskPlanning -> {
681-
if(taskPlanningEnabled) taskPlanning(
667+
if (taskPlanningEnabled) taskPlanning(
682668
subTask = subTask,
683669
userMessage = userMessage,
684670
highLevelPlan = highLevelPlan,
@@ -740,49 +726,49 @@ class TaskRunnerAgent(
740726
taskTabs: TabbedDisplay,
741727
function: () -> Unit
742728
) {
743-
object : CodingAgent<ProcessInterpreter>(
744-
api = api,
745-
dataStorage = dataStorage,
746-
session = session,
747-
user = user,
748-
ui = ui,
749-
interpreter = shellCommandActor.interpreterClass as KClass<ProcessInterpreter>,
750-
symbols = shellCommandActor.symbols,
751-
temperature = shellCommandActor.temperature,
752-
details = shellCommandActor.details,
753-
model = shellCommandActor.model,
729+
object : CodingAgent<ProcessInterpreter>(
730+
api = api,
731+
dataStorage = dataStorage,
732+
session = session,
733+
user = user,
734+
ui = ui,
735+
interpreter = shellCommandActor.interpreterClass as KClass<ProcessInterpreter>,
736+
symbols = shellCommandActor.symbols,
737+
temperature = shellCommandActor.temperature,
738+
details = shellCommandActor.details,
739+
model = shellCommandActor.model,
740+
) {
741+
override fun displayFeedback(
742+
task: SessionTask,
743+
request: CodingActor.CodeRequest,
744+
response: CodingActor.CodeResult
754745
) {
755-
override fun displayFeedback(
756-
task: SessionTask,
757-
request: CodingActor.CodeRequest,
758-
response: CodingActor.CodeResult
759-
) {
760-
val formText = StringBuilder()
761-
var formHandle: StringBuilder? = null
762-
formHandle = task.add(
763-
"""
746+
val formText = StringBuilder()
747+
var formHandle: StringBuilder? = null
748+
formHandle = task.add(
749+
"""
764750
|<div style="display: flex;flex-direction: column;">
765751
|${if (!super.canPlay) "" else super.playButton(task, request, response, formText) { formHandle!! }}
766752
|${acceptButton(task, request, response, formText) { formHandle!! }}
767753
|</div>
768754
|${super.reviseMsg(task, request, response, formText) { formHandle!! }}
769755
""".trimMargin(), className = "reply-message"
770-
)
771-
formText.append(formHandle.toString())
772-
formHandle.toString()
773-
task.complete()
774-
}
756+
)
757+
formText.append(formHandle.toString())
758+
formHandle.toString()
759+
task.complete()
760+
}
775761

776762
fun acceptButton(
777-
task: SessionTask,
778-
request: CodingActor.CodeRequest,
779-
response: CodingActor.CodeResult,
780-
formText: StringBuilder,
781-
formHandle: () -> StringBuilder
782-
): String {
763+
task: SessionTask,
764+
request: CodingActor.CodeRequest,
765+
response: CodingActor.CodeResult,
766+
formText: StringBuilder,
767+
formHandle: () -> StringBuilder
768+
): String {
783769
return ui.hrefLink("\uD83D\uDC4D", "href-link play-button") {
784-
genState.taskResult[taskId] = response.let {
785-
"""
770+
genState.taskResult[taskId] = response.let {
771+
"""
786772
|## Shell Command Output
787773
|
788774
|```
@@ -793,17 +779,21 @@ class TaskRunnerAgent(
793779
|${response.renderedResponse}
794780
|```
795781
""".trimMargin()
796-
}
797-
function()
798782
}
783+
function()
799784
}
785+
}
800786
}.apply {
801-
start(codeRequest(listOf(
802-
userMessage to Role.user,
803-
highLevelPlan.text to Role.assistant,
804-
priorCode to Role.assistant,
805-
inputFileCode to Role.assistant,
806-
)))
787+
start(
788+
codeRequest(
789+
listOf(
790+
userMessage to Role.user,
791+
highLevelPlan.text to Role.assistant,
792+
priorCode to Role.assistant,
793+
inputFileCode to Role.assistant,
794+
)
795+
)
796+
)
807797
}
808798
}
809799

@@ -841,7 +831,7 @@ class TaskRunnerAgent(
841831
} else {
842832
task.complete("No changes to $path")
843833
}
844-
}) + accept(sb) {
834+
}, ui=ui) + accept(sb) {
845835
taskTabs.selectedTab = taskTabs.selectedTab + 1
846836
taskTabs.update()
847837
onComplete()
@@ -905,7 +895,7 @@ class TaskRunnerAgent(
905895
taskTabs.update()
906896
task.complete()
907897
onComplete()
908-
})
898+
}, ui=ui)
909899
}
910900
object : Retryable(ui, task, process) {
911901
init {
@@ -935,7 +925,7 @@ class TaskRunnerAgent(
935925
).filter { it.isNotBlank() }, api
936926
)
937927
genState.taskResult[taskId] = docResult
938-
renderMarkdown("## Generated Documentation\n$docResult") + accept(sb) {
928+
renderMarkdown("## Generated Documentation\n$docResult", ui=ui) + accept(sb) {
939929
taskTabs.selectedTab = taskTabs.selectedTab + 1
940930
taskTabs.update()
941931
task.complete()
@@ -995,7 +985,7 @@ class TaskRunnerAgent(
995985
heading = "",
996986
initialResponse = { it: String -> inquiryActor.answer(toInput(it), api = api) },
997987
outputFn = { design: String ->
998-
renderMarkdown(design)
988+
renderMarkdown(design, ui=ui)
999989
},
1000990
ui = ui,
1001991
reviseResponse = { userMessages: List<Pair<String, Role>> ->
@@ -1041,8 +1031,8 @@ class TaskRunnerAgent(
10411031
outputFn = { design: ParsedResponse<TaskBreakdownResult> ->
10421032
displayMapInTabs(
10431033
mapOf(
1044-
"Text" to renderMarkdown(design.text),
1045-
"JSON" to renderMarkdown("```json\n${toJson(design.obj).indent(" ")}\n```"),
1034+
"Text" to renderMarkdown(design.text, ui=ui),
1035+
"JSON" to renderMarkdown("```json\n${toJson(design.obj)/*.indent(" ")*/}\n```", ui=ui),
10461036
)
10471037
)
10481038
},

0 commit comments

Comments
 (0)