Skip to content

Commit 3d846d7

Browse files
authored
1.5.9 (#171)
* 1.5.9 * wip * Update build.gradle.kts * Update settings.gradle.kts * autofix * Update CommandAutofixAction.kt * autofix * wip
1 parent 910d5a2 commit 3d846d7

File tree

11 files changed

+1345
-114
lines changed

11 files changed

+1345
-114
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repositories {
2525
val kotlin_version = "2.0.0-Beta5"
2626
val jetty_version = "11.0.18"
2727
val slf4j_version = "2.0.9"
28-
val skyenet_version = "1.0.75"
28+
val skyenet_version = "1.0.77"
2929
val remoterobot_version = "0.11.21"
3030
val jackson_version = "2.17.0"
3131

@@ -42,7 +42,7 @@ dependencies {
4242
exclude(group = "org.jetbrains.kotlin", module = "")
4343
}
4444

45-
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.60")
45+
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.61")
4646
{
4747
exclude(group = "org.jetbrains.kotlin", module = "")
4848
}

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.5.8
3+
pluginVersion=1.5.9
44

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

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

Lines changed: 402 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ import java.nio.file.Path
2828
import java.util.concurrent.Executors
2929
import java.util.concurrent.Future
3030
import java.util.concurrent.TimeUnit
31-
import javax.swing.BoxLayout
32-
import javax.swing.JComponent
33-
import javax.swing.JLabel
34-
import javax.swing.JPanel
31+
import javax.swing.*
3532

3633

3734
class GenerateDocumentationAction : FileContextAction<GenerateDocumentationAction.Settings>() {
@@ -43,6 +40,9 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
4340
}
4441

4542
class SettingsUI {
43+
@Name("Single Output File")
44+
val singleOutputFile = JCheckBox("Produce a single output file", true)
45+
4646
@Name("Files to Process")
4747
val filesToProcess = CheckBoxList<Path>()
4848

@@ -57,6 +57,7 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
5757
var transformationMessage: String = "Create user documentation",
5858
var outputFilename: String = "compiled_documentation.md",
5959
var filesToProcess: List<Path> = listOf(),
60+
var singleOutputFile: Boolean = true
6061
)
6162

6263
class Settings(
@@ -79,8 +80,9 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
7980
}
8081
val dialog = DocumentationCompilerDialog(project, settingsUI)
8182
dialog.show()
82-
val result = dialog.isOK
8383
val settings: UserSettings = dialog.userSettings
84+
settings.singleOutputFile = settingsUI.singleOutputFile.isSelected
85+
val result = dialog.isOK
8486
settings.filesToProcess = when {
8587
result -> files.filter { path -> settingsUI.filesToProcess.isItemSelected(path) }.toList()
8688
else -> listOf()
@@ -116,22 +118,32 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
116118
val fileContent =
117119
IOUtils.toString(FileInputStream(path.toFile()), "UTF-8") ?: return@submit null
118120
val transformContent = transformContent(fileContent, transformationMessage)
119-
markdownContent.append("# ${root.relativize(path)}\n\n")
120-
markdownContent.append(transformContent.replace("(?s)(?<![^\\n])#".toRegex(), "\n##"))
121-
markdownContent.append("\n\n")
121+
if (config?.settings?.singleOutputFile == true) {
122+
markdownContent.append("# ${root.relativize(path)}\n\n")
123+
markdownContent.append(transformContent.replace("(?s)(?<![^\\n])#".toRegex(), "\n##"))
124+
} else {
125+
root.relativize(path).let { it.parent.resolve(it.fileName.toString().split('.').dropLast(1).joinToString(".") + "_" + outputPath.fileName) }
126+
val individualOutputPath = root.resolve("${root.relativize(path)}.md")
127+
Files.write(individualOutputPath, transformContent.toByteArray())
128+
}
122129
path
123130
}
124131
}.toTypedArray().map { future ->
125132
try {
126-
future.get() ?: return@map null
133+
future.get()
127134
} catch (e: Exception) {
128135
log.warn("Error processing file", e)
129136
return@map null
130137
}
131138
}.filterNotNull()
132-
Files.write(outputPath, markdownContent.toString().toByteArray())
133-
open(config?.project!!, outputPath)
134-
return arrayOf(outputPath.toFile())
139+
if (config?.settings?.singleOutputFile == true) {
140+
Files.write(outputPath, markdownContent.toString().toByteArray())
141+
open(config?.project!!, outputPath)
142+
return arrayOf(outputPath.toFile())
143+
} else {
144+
open(config?.project!!, outputPath)
145+
return pathList.toList().map { it.toFile() }.toTypedArray()
146+
}
135147
} finally {
136148
executorService.shutdown()
137149
}
@@ -199,7 +211,6 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
199211
val filesScrollPane = JBScrollPane(settingsUI.filesToProcess).apply {
200212
preferredSize = Dimension(400, 300) // Adjust the preferred size as needed
201213
}
202-
add(JLabel("Files to Process"), BorderLayout.NORTH)
203214
add(filesScrollPane, BorderLayout.CENTER) // Make the files list the dominant element
204215

205216
val optionsPanel = JPanel().apply {
@@ -208,6 +219,7 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
208219
add(settingsUI.transformationMessage)
209220
add(JLabel("Output File"))
210221
add(settingsUI.outputFilename)
222+
add(settingsUI.singleOutputFile)
211223
}
212224
add(optionsPanel, BorderLayout.SOUTH)
213225
}
@@ -222,6 +234,7 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
222234
// userSettings.filesToProcess = settingsUI.filesToProcess.selectedValuesList
223235
userSettings.filesToProcess =
224236
settingsUI.filesToProcess.items.filter { path -> settingsUI.filesToProcess.isItemSelected(path) }
237+
userSettings.singleOutputFile = settingsUI.singleOutputFile.isSelected
225238
}
226239
}
227240
}
@@ -233,4 +246,4 @@ val <T> CheckBoxList<T>.items: List<T>
233246
items.add(getItemAt(i)!!)
234247
}
235248
return items
236-
}
249+
}

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,14 @@ class MultiDiffChatAction : BaseAction() {
9191
) {
9292
override val singleInput = false
9393
override val stickyInput = true
94-
private val mainActor: SimpleActor
95-
get() = SimpleActor(
94+
override fun userMessage(
95+
session: Session,
96+
user: User?,
97+
userMessage: String,
98+
ui: ApplicationInterface,
99+
api: API
100+
) {
101+
val mainActor = SimpleActor(
96102
prompt = """
97103
|You are a helpful AI that helps people with coding.
98104
|
@@ -138,13 +144,6 @@ class MultiDiffChatAction : BaseAction() {
138144
model = AppSettingsState.instance.defaultSmartModel()
139145
)
140146

141-
override fun userMessage(
142-
session: Session,
143-
user: User?,
144-
userMessage: String,
145-
ui: ApplicationInterface,
146-
api: API
147-
) {
148147
val settings = getSettings(session, user) ?: Settings()
149148
if (api is ClientManager.MonitoredClient) api.budget = settings.budget ?: 2.00
150149

0 commit comments

Comments
 (0)