@@ -48,20 +48,6 @@ import java.util.concurrent.ThreadPoolExecutor
4848import java.util.concurrent.atomic.AtomicReference
4949import 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- * */
6551class 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