Skip to content

Commit

Permalink
1.0.61 (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski authored Apr 5, 2024
1 parent 23e7147 commit 9ad78fc
Show file tree
Hide file tree
Showing 17 changed files with 764 additions and 348 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ group = properties("libraryGroup")
version = properties("libraryVersion")

//plugins {
// id("org.jetbrains.kotlin.jvm") version "1.9.21"
// id("org.jetbrains.kotlin.jvm") version "2.0.0-Beta5"
//}

tasks {
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = properties("libraryVersion")
plugins {
java
`java-library`
id("org.jetbrains.kotlin.jvm") version "1.9.21"
id("org.jetbrains.kotlin.jvm") version "2.0.0-Beta5"
`maven-publish`
id("signing")
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gradle Releases -> https://github.com/gradle/gradle/releases
libraryGroup = com.simiacryptus.skyenet
libraryVersion = 1.0.60
libraryVersion = 1.0.61
gradleVersion = 7.6.1
4 changes: 2 additions & 2 deletions groovy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = properties("libraryVersion")
plugins {
java
`java-library`
id("org.jetbrains.kotlin.jvm") version "1.9.21"
id("org.jetbrains.kotlin.jvm") version "2.0.0-Beta5"
`maven-publish`
id("signing")
}
Expand All @@ -26,7 +26,7 @@ kotlin {
jvmToolchain(11)
}

val kotlin_version = "1.9.21"
val kotlin_version = "2.0.0-Beta5"
dependencies {
implementation(project(":core"))

Expand Down
2 changes: 1 addition & 1 deletion kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = properties("libraryVersion")
plugins {
java
`java-library`
id("org.jetbrains.kotlin.jvm") version "1.9.21"
id("org.jetbrains.kotlin.jvm") version "2.0.0-Beta5"
`maven-publish`
id("signing")
}
Expand Down
2 changes: 1 addition & 1 deletion scala/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
`java-library`
`scala`
`maven-publish`
id("org.jetbrains.kotlin.jvm") version "1.9.21"
id("org.jetbrains.kotlin.jvm") version "2.0.0-Beta5"
id("signing")
}

Expand Down
4 changes: 2 additions & 2 deletions webui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version = properties("libraryVersion")
plugins {
java
`java-library`
id("org.jetbrains.kotlin.jvm") version "1.9.21"
id("org.jetbrains.kotlin.jvm") version "2.0.0-Beta5"
`maven-publish`
id("signing")
id("io.freefair.sass-base") version "8.4"
Expand All @@ -30,7 +30,7 @@ kotlin {
// jvmToolchain(17)
}

val kotlin_version = "1.9.21"
val kotlin_version = "2.0.0-Beta5"
val jetty_version = "11.0.18"
val jackson_version = "2.15.3"
dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.github.simiacryptus.aicoder.util

import com.simiacryptus.skyenet.AgentPatterns.displayMapInTabs
import com.simiacryptus.skyenet.webui.application.ApplicationInterface
import com.simiacryptus.skyenet.webui.session.SessionTask
import com.simiacryptus.skyenet.webui.session.SocketManagerBase
import com.simiacryptus.skyenet.webui.util.MarkdownUtil.renderMarkdown

fun SocketManagerBase.addApplyDiffLinks(
code: StringBuilder,
response: String,
handle: (String) -> Unit,
task: SessionTask,
ui: ApplicationInterface? = null,
): String {
val diffPattern = """(?s)(?<![^\n])```diff\n(.*?)\n```""".toRegex()
val matches = diffPattern.findAll(response).distinct()
val withLinks = matches.fold(response) { markdown, diffBlock ->
val diffVal: String = diffBlock.groupValues[1]
val hrefLink = hrefLink("Apply Diff") {
try {
val newCode = PatchUtil.patch(code.toString(), diffVal).replace("\r", "")
handle(newCode)
task.complete("""<div class="user-message">Diff Applied</div>""")
} catch (e: Throwable) {
task.error(ui, e)
}
}
val reverseHrefLink = hrefLink("(Bottom to Top)") {
try {
val reversedCode = code.lines().reversed().joinToString("\n")
val reversedDiff = diffVal.lines().reversed().joinToString("\n")
val newReversedCode = PatchUtil.patch(reversedCode, reversedDiff).replace("\r", "")
val newCode = newReversedCode.lines().reversed().joinToString("\n")
handle(newCode)
task.complete("""<div class="user-message">Diff Applied (Bottom to Top)</div>""")
} catch (e: Throwable) {
task.error(ui, e)
}
}
val patch = PatchUtil.patch(code.toString(), diffVal).replace("\r", "")
val test1 = DiffUtil.formatDiff(
DiffUtil.generateDiff(
code.toString().replace("\r", "").lines(),
patch.lines()
)
)
val patchRev = PatchUtil.patch(
code.lines().reversed().joinToString("\n"),
diffVal.lines().reversed().joinToString("\n")
).replace("\r", "")
val test2 = DiffUtil.formatDiff(
DiffUtil.generateDiff(
code.lines(),
patchRev.lines().reversed()
)
)
val newValue = if (patchRev == patch) {
displayMapInTabs(
mapOf(
"Diff" to renderMarkdown("```diff\n$diffVal\n```", ui = ui, tabs = true),
"Verify" to renderMarkdown("```diff\n$test1\n```", ui = ui, tabs = true),
), ui = ui, split = true
) + "\n" + hrefLink
} else {
displayMapInTabs(
mapOf(
"Diff" to renderMarkdown("```diff\n$diffVal\n```", ui = ui, tabs = true),
"Verify" to renderMarkdown("```diff\n$test1\n```", ui = ui, tabs = true),
"Reverse" to renderMarkdown("```diff\n$test2\n```", ui = ui, tabs = true),
), ui = ui, split = true
) + "\n" + hrefLink + "\n" + reverseHrefLink
}
markdown.replace(diffBlock.value, newValue)
}
return withLinks
}
Loading

0 comments on commit 9ad78fc

Please sign in to comment.