Skip to content

Commit 3f81d73

Browse files
authored
1.3.2 (#138)
* 1.3.2 * wip * wip * fixes * Update StaticAppSettingsConfigurable.kt * wip
1 parent 3c5dbf1 commit 3f81d73

26 files changed

+910
-2100
lines changed

README.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,28 @@
88

99
# **AI Coding Assistant Plugin for IntelliJ**
1010

11-
**Fully open source plugin for IntelliJ that integrates with OpenAI's GPT-4 API**
12-
13-
* This requires an OpenAI access token, which you can get by signing up for a developer account at https://platform.openai.com/
14-
* No membership fees! API access is paid but is billed by usage, with no base fee. The plugin is free and open source.
15-
* Fully customizable actions in Groovy, including the ability to create your own actions.
11+
**Fully open source plugin for IntelliJ that integrates with a variety of LLM APIs**
12+
13+
* No membership fees! API access is typically paid but is billed by usage, with no base fee.
14+
* The plugin is free and open source, with a focus on utility. No hype here! I'm sharing a tool I use, and I hope you find it useful too.
15+
* A variety of APIs are supported! Get your api keys at:
16+
* https://platform.openai.com/
17+
* https://www.perplexity.ai/
18+
* https://console.groq.com/
19+
* https://modelslab.com/dashboard/
20+
* https://console.aws.amazon.com/bedrock/
21+
* Fully customizable actions, including the ability to create your own actions using AI
1622
* Toolbar UI for quick configuration of temperature/model and display of current token count
1723
* Ability to intercept, edit, and log API requests
18-
* Now with added support for models from https://www.perplexity.ai/, https://console.groq.com/, and https://modelslab.com/dashboard/, expanding the plugin's capabilities in code generation and analysis.
1924

2025
**NOTE**: This project is not affiliated with OpenAI, JetBrains, or any other corporation or organization.
21-
It is provided free of charge, as-is, with no warranty or guarantee of any kind.
26+
It is provided free of charge, as-is, with no warranty or guarantee of any kind.
27+
It is the work of a sole developer working as a hobby project.
2228

2329
## **Installation & Configuration**
2430

25-
To begin with AI Coding Assistant, you will need an [OpenAI access token](https://platform.openai.com/account/api-keys).
26-
After obtaining your OpenAI token, input it into the appropriate field in the plugin's settings panel.
27-
Now, you can also configure the plugin to use models from Perplexity AI, Groq Console, and Models Lab for enhanced coding assistance.
31+
To begin with AI Coding Assistant, you will need one or more api tokens,
32+
which needs to be input it into the appropriate field in the plugin's settings panel.
2833

2934
## **Usage Overview**
3035

@@ -37,14 +42,15 @@ over when and how to use them. You can access these actions via the context menu
3742
* **DiffChatAction**: Engage in a chat session to generate and apply code diffs directly within the IDE, streamlining the code review and modification process.
3843
* **MultiDiffChatAction**: Facilitates collaborative code review and diff generation across multiple files, enhancing team productivity.
3944
* **AutoDevAction**: Translates user directives into actionable development tasks and code modifications, automating parts of the development workflow.
45+
* **mermaid.js**: Generate diagrams using the mermaid.js library, providing a visual representation of your code and ideas.
4046

4147
## **Action Customization**
4248

43-
In our latest version, we provide the capability to tailor actions to your coding habits and project requirements.
44-
Within the settings UI, you can view, edit, clone, or delete actions, enabling you to fine-tune existing tools or create
45-
new ones from scratch.
49+
Tailor actions to your coding habits and project requirements!
50+
Within the settings UI, you can view, edit, clone, or delete actions,
51+
enabling you to fine-tune existing tools or create new ones from scratch.
4652

47-
These custom actions leverage Groovy scripting, and can be as complex or simple as required, even having access to the
53+
These custom actions use dynamically compiled Kotlin, and can be as complex or simple as required, even having access to the
4854
entire IntelliJ API. This powerful feature allows for numerous possibilities, from refining prompts to adding intricate
4955
logic to better support your preferred coding language.
5056

build.gradle.kts

Lines changed: 2 additions & 2 deletions
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.50"
29+
val skyenet_version = "1.0.52"
3030
val remoterobot_version = "0.11.21"
3131
dependencies {
3232

@@ -37,7 +37,7 @@ dependencies {
3737
exclude(group = "org.jetbrains.kotlin", module = "")
3838
}
3939

40-
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.46")
40+
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.48")
4141
{
4242
exclude(group = "org.jetbrains.kotlin", module = "")
4343
}

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.1
3+
pluginVersion=1.3.2
44

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

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.github.simiacryptus.aicoder.actions.dev.AppServer
66
import com.github.simiacryptus.aicoder.util.UITools
77
import com.github.simiacryptus.aicoder.util.addApplyDiffLinks
88
import com.intellij.openapi.actionSystem.AnActionEvent
9+
import com.intellij.openapi.actionSystem.PlatformDataKeys
910
import com.simiacryptus.jopenai.API
1011
import com.simiacryptus.jopenai.describe.Description
1112
import com.simiacryptus.jopenai.models.ChatModels
@@ -103,9 +104,9 @@ class AutoDevAction : BaseAction() {
103104
val ui: ApplicationInterface,
104105
val model: ChatModels,
105106
val tools: List<String> = emptyList(),
106-
val actorMap: Map<ActorTypes, BaseActor<*, *>> = mapOf(
107+
private val actorMap: Map<ActorTypes, BaseActor<*, *>> = mapOf(
107108
ActorTypes.DesignActor to ParsedActor(
108-
parserClass = TaskListParser::class.java,
109+
resultClass = TaskList::class.java,
109110
prompt = """
110111
Translate the user directive into an action plan for the project.
111112
Break the user's request into a list of simple tasks to be performed.
@@ -139,19 +140,25 @@ class AutoDevAction : BaseAction() {
139140
),
140141
),
141142
val event: AnActionEvent,
142-
) : ActorSystem<AutoDevAgent.ActorTypes>(actorMap, dataStorage, user, session) {
143+
) : ActorSystem<AutoDevAgent.ActorTypes>(actorMap.map { it.key.name to it.value.javaClass }.toMap(), dataStorage, user, session) {
143144
enum class ActorTypes {
144145
DesignActor,
145146
TaskCodingActor,
146147
}
147148

148-
val designActor by lazy { getActor(ActorTypes.DesignActor) as ParsedActor<TaskList> }
149-
val taskActor by lazy { getActor(ActorTypes.TaskCodingActor) as SimpleActor }
149+
private val designActor by lazy { getActor(ActorTypes.DesignActor) as ParsedActor<TaskList> }
150+
private val taskActor by lazy { getActor(ActorTypes.TaskCodingActor) as SimpleActor }
150151

151152
fun start(
152153
userMessage: String,
153154
) {
154155
val codeFiles = mutableMapOf<String, String>()
156+
val root = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(event.dataContext)?.map { it.toFile.toPath() }?.toTypedArray()?.commonRoot()!!
157+
PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(event.dataContext)?.forEach { file ->
158+
val code = file.inputStream.bufferedReader().use { it.readText() }
159+
codeFiles[root.relativize(file.toNioPath()).toString()] = code
160+
}
161+
require(codeFiles.isNotEmpty()) { "No files selected" }
155162
fun codeSummary() = codeFiles.entries.joinToString("\n\n") { (path, code) ->
156163
"# $path\n```${
157164
path.split('.').last()
@@ -177,15 +184,18 @@ class AutoDevAction : BaseAction() {
177184
val task = ui.newTask()
178185
task.header("Task: $description")
179186
AgentPatterns.retryable(ui,task) {
187+
val filter = codeFiles.filter { (path, _) -> paths?.find { path.contains(it) }?.isNotEmpty() == true }
188+
require(filter.isNotEmpty()) { "No files found for $paths" }
180189
renderMarkdown(
181190
ui.socketManager.addApplyDiffLinks(
182-
codeFiles.filter { (path, _) -> paths?.contains(path) == true },
183-
taskActor.answer(listOf(
191+
code = codeFiles,
192+
response = taskActor.answer(listOf(
193+
codeSummary(),
184194
userMessage,
185-
architectureResponse.text,
186-
codeFiles.filter { (path, _) -> paths?.contains(path) == true }.entries.joinToString("\n\n") {
195+
filter.entries.joinToString("\n\n") {
187196
"# ${it.key}\n```${it.key.split('.').last()}\n${it.value}\n```"
188197
},
198+
architectureResponse.text,
189199
"Provide a change for ${paths?.joinToString(",") { it } ?: ""} ($description)"
190200
), api)
191201
) { newCodeMap ->
@@ -229,11 +239,6 @@ class AutoDevAction : BaseAction() {
229239
return socketServer
230240
}
231241

232-
interface TaskListParser : java.util.function.Function<String, TaskList> {
233-
@Description("Parse out a list of tasks to be performed in this project")
234-
override fun apply(text: String): TaskList
235-
}
236-
237242
data class TaskList(
238243
@Description("List of tasks to be performed in this project")
239244
val tasks: List<Task> = emptyList()

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ class CreateFileAction : FileContextAction<CreateFileAction.Settings>(false, tru
1212

1313
class ProjectFile(var path: String = "", var code: String = "")
1414

15-
class SettingsUI {
16-
@Name("Directive")
17-
var directive: JTextArea = JTextArea(
18-
"""
19-
Create a default log4j configuration file
20-
""".trimIndent(), 3, 120
21-
)
22-
}
23-
2415
class Settings(var directive: String = "")
2516

2617
override fun processSelection(

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ class DocumentationCompilerAction : FileContextAction<DocumentationCompilerActio
3131
}
3232

3333
class SettingsUI {
34-
@Name("Transformation Message")
35-
var transformationMessage: JTextArea = JTextArea(
36-
"Create user documentation",
37-
3,
38-
120
39-
)
40-
41-
@Name("Output Filename")
42-
var outputFilename: JTextArea = JTextArea(
43-
"compiled_documentation.md",
44-
1,
45-
120
46-
)
4734

4835
@Name("Files to Process")
4936
var filesToProcessScrollPane: JBScrollPane = JBScrollPane()
@@ -82,7 +69,7 @@ class DocumentationCompilerAction : FileContextAction<DocumentationCompilerActio
8269
"Compile Documentation"
8370
) { }
8471
settings.filesToProcess = files.filter { path -> filesToProcess.isItemSelected(path) }.toList()
85-
//.map { path -> return@map root?.resolve(path) }.filterNotNull()
72+
//.map { path -> return@map root?.resolve(path) }.filterNotNull()
8673
return Settings(settings, project)
8774
}
8875

@@ -117,7 +104,14 @@ class DocumentationCompilerAction : FileContextAction<DocumentationCompilerActio
117104
markdownContent.append("\n\n")
118105
path
119106
}
120-
}.toTypedArray().map { future -> future.get() ?: return@map null }.filterNotNull()
107+
}.toTypedArray().map { future ->
108+
try {
109+
future.get() ?: return@map null
110+
} catch (e: Exception) {
111+
log.warn("Error processing file", e)
112+
return@map null
113+
}
114+
}.filterNotNull()
121115
Files.write(outputPath, markdownContent.toString().toByteArray())
122116
open(config?.project!!, outputPath)
123117
return arrayOf(outputPath.toFile())

0 commit comments

Comments
 (0)