-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
321 lines (292 loc) · 13.3 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
321 lines (292 loc) · 13.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
plugins {
kotlin("jvm") version "2.1.0"
id("org.jetbrains.intellij.platform") version "2.11.0"
id("org.jetbrains.changelog")
id("com.google.protobuf") version "0.9.4"
id("org.jetbrains.kotlinx.kover") version "0.9.8"
}
group = "com.itangcent"
version = "3.1.9.252.0"
changelog {
val v = project.version.toString()
// version is like "3.1.5.252.0", changelog uses semver "3.1.5"
version.set(v.substringBeforeLast(".0").substringBeforeLast("."))
}
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}
dependencies {
intellijPlatform {
intellijIdeaCommunity("2025.2.1")
bundledPlugins(
"com.intellij.java",
"org.jetbrains.idea.maven",
"org.jetbrains.plugins.gradle",
"org.jetbrains.kotlin",
"org.intellij.groovy",
"org.intellij.intelliLang"
)
plugin("org.intellij.scala:2025.2.51")
pluginVerifier()
testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Platform)
testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Plugin.Java)
}
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.3")
implementation("com.google.code.gson:gson:2.11.0")
implementation("com.fasterxml.jackson.core:jackson-databind:2.12.2")
implementation("com.fasterxml.jackson.core:jackson-annotations:2.12.2")
implementation("com.fasterxml.jackson.core:jackson-core:2.12.2")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.2")
implementation("org.yaml:snakeyaml:1.33")
implementation("org.xerial:sqlite-jdbc:3.34.0")
// LangChain4j — AI agent substrate
// Explicit versions (avoid BOM — it imposes global kotlin-stdlib constraints
// that conflict with IntelliJ's bundled Kotlin 2.1+).
val langchain4jCoreVersion = "1.0.0-rc1" // core + open-ai
val langchain4jBetaVersion = "1.0.0-beta4" // anthropic, gemini, ollama, azure
implementation("dev.langchain4j:langchain4j:$langchain4jCoreVersion") {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.slf4j")
}
implementation("dev.langchain4j:langchain4j-core:$langchain4jCoreVersion") {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.slf4j")
}
implementation("dev.langchain4j:langchain4j-open-ai:$langchain4jCoreVersion") {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.slf4j")
}
implementation("dev.langchain4j:langchain4j-anthropic:$langchain4jBetaVersion") {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.slf4j")
}
implementation("dev.langchain4j:langchain4j-google-ai-gemini:$langchain4jBetaVersion") {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.slf4j")
}
implementation("dev.langchain4j:langchain4j-ollama:$langchain4jBetaVersion") {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.slf4j")
}
implementation("dev.langchain4j:langchain4j-azure-open-ai:$langchain4jBetaVersion") {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.slf4j")
}
testImplementation("junit:junit:4.13.2")
testImplementation("io.kotest:kotest-property-jvm:5.9.1") {
// Use the IntelliJ test runtime's compatible Kotlin and coroutines libraries.
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.jetbrains.kotlinx")
}
testImplementation("org.mockito:mockito-core:5.8.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.2.1")
val grpcVersion = "1.68.0"
val protobufVersion = "3.25.3"
testImplementation("io.grpc:grpc-netty-shaded:$grpcVersion")
testImplementation("io.grpc:grpc-api:$grpcVersion")
testImplementation("io.grpc:grpc-protobuf:$grpcVersion")
testImplementation("io.grpc:grpc-stub:$grpcVersion")
testImplementation("io.grpc:grpc-core:$grpcVersion")
testImplementation("io.grpc:grpc-services:$grpcVersion")
testImplementation("com.google.protobuf:protobuf-java:$protobufVersion")
testImplementation("com.google.protobuf:protobuf-java-util:$protobufVersion")
testImplementation("com.google.guava:guava:33.0.0-jre")
testImplementation("com.google.guava:failureaccess:1.0.2")
testImplementation("javax.annotation:javax.annotation-api:1.3.2")
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.25.3"
}
plugins {
create("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.68.0"
}
}
generateProtoTasks {
all().forEach { task ->
task.plugins {
create("grpc") {}
}
}
}
}
// Build with whatever JDK (17 or 21) the developer has installed — no pinned
// toolchain. The jvmTarget / sourceCompatibility / targetCompatibility below
// keep the bytecode JDK 17 compatible regardless of which JDK runs the build.
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
java {
}
// Guard against accidental use of JDK 21-only APIs when building with JDK 21
// but targeting JDK 17 bytecode (e.g. protobuf-generated Java sources).
tasks.withType<JavaCompile>().configureEach {
options.release.set(17)
}
tasks.withType<Test>().configureEach {
useJUnit()
maxParallelForks = 1
// The forked test JVM loads the full IntelliJ Platform + bundled plugins
// (Java, Kotlin, Groovy, Scala), which is memory-hungry. The default heap
// is far too small and leads to OOM-induced stub-index corruption
// (`Stubs` index status REQUIRES_REBUILD), which in turn fails tests
// non-deterministically. 3g gives the index/cache layer enough headroom
// for the full suite (5000+ tests) to run without OOM.
maxHeapSize = "3g"
testLogging {
events("started", "passed", "failed", "skipped")
showExceptions = true
showCauses = true
showStackTraces = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
intellijPlatform {
pluginConfiguration {
id = "com.itangcent.idea.plugin.easy-api"
name = "Easyapi"
version = project.version.toString()
description = file("src/main/resources/pluginDescription.html").readText()
changeNotes = provider {
changelog.renderItem(
changelog.getLatest(),
org.jetbrains.changelog.Changelog.OutputType.HTML
)
}
ideaVersion {
sinceBuild = "252"
untilBuild = provider { null }
}
}
buildSearchableOptions = false
sandboxContainer = layout.projectDirectory.dir("idea-sandbox")
}
kover {
reports {
filters {
excludes {
classes("jdk.internal.*")
}
}
total {
xml {
onCheck = false
}
html {
onCheck = false
}
}
}
}
// ─────────────────────────────────────────────────────────────────────────────
// Knowledge-base sync
//
// `docs/knowledge-base/` at the repo root is the single source of truth for
// the plugin documentation consumed by both AI rule-authoring surfaces:
// 1. The built-in IntelliJ agent — reads it from the plugin JAR at runtime
// via the `get_plugin_doc` tool (every *.md under that folder).
// 2. The external `easy-api-assistant` skill — ships a verbatim copy next
// to its SKILL.md so it works after `npx skills add` (which publishes
// only the skills/ folder, not the repo tree).
//
// This task copies the canonical files into both destinations. It is wired
// into `processResources` so the JAR always ships fresh docs, and can be run
// standalone (`./gradlew syncKnowledgeBase`) to refresh the git-tracked skill
// copy before commit. The copies are content-equality-checked, so an
// unchanged source produces no git diff (idempotent).
// ─────────────────────────────────────────────────────────────────────────────
val knowledgeBaseSourceDir = file("docs/knowledge-base")
val knowledgeBaseResourceDir = file("src/main/resources/docs/knowledge-base")
// The skill bundles its docs under a `docs/` subfolder next to SKILL.md to
// keep the skill root tidy (SKILL.md + docs/ + scripts/).
val knowledgeBaseSkillDir = file("skills/easy-api-assistant/docs")
val syncKnowledgeBase by tasks.registering {
group = "documentation"
description = "Sync docs/knowledge-base/*.md into the plugin resources and the easy-api-assistant skill folder."
// Re-run whenever any source doc changes (Gradle up-to-date checks).
val sourceFiles = fileTree(knowledgeBaseSourceDir) { include("*.md") }
inputs.files(sourceFiles)
// Declared outputs so the task is considered up-to-date when inputs are
// unchanged — keeping the destinations git-clean.
outputs.files(fileTree(knowledgeBaseResourceDir) { include("*.md") })
outputs.files(fileTree(knowledgeBaseSkillDir) { include("*.md") })
outputs.upToDateWhen { true }
// Resolve destination directories once, at configuration time.
val pluginDestDir: File = knowledgeBaseResourceDir
val skillDestDir: File = knowledgeBaseSkillDir
doLast {
val sources = sourceFiles.files.sortedBy { it.name }
logger.lifecycle("Syncing ${sources.size} knowledge-base doc(s) to plugin resources and skill folder:")
sources.forEach { source ->
val name = source.name
// Plugin resources: every knowledge-base doc ships in the JAR
// (the get_plugin_doc tool exposes overview/index/rule-guide/
// settings-guide/usage-guide/easyapi-script-reference).
copyFileIfDifferent(source, File(pluginDestDir, name))
// Skill folder: all canonical knowledge-base pages are bundled so
// the external skill mirrors the built-in agent's `get_plugin_doc`
// surface as closely as possible (works after `npx skills add`,
// which publishes only the skills/ folder). They live under a
// `docs/` subfolder to keep the skill root tidy.
copyFileIfDifferent(source, File(skillDestDir, name))
logger.lifecycle(" - $name")
}
}
}
/** Copies only when content differs, so an unchanged source stays git-clean. */
fun copyFileIfDifferent(source: File, target: File) {
target.parentFile.mkdirs()
if (target.isFile && target.readText() == source.readText()) {
return
}
source.copyTo(target, overwrite = true)
}
// ─────────────────────────────────────────────────────────────────────────────
// Agent catalog sync (R3-C3)
//
// `src/main/resources/ai/{detection,rules}/*.md` are the canonical prompt
// catalog the in-plugin agent loads at runtime via `PromptCatalog`. The
// external `easy-api-assistant` skill ships a verbatim copy under
// `skills/easy-api-assistant/ai/` so the external assistant has the same
// per-detection / per-key recipe surface (mirrored by the
// `get_detection_prompt.sh` / `get_rule_detail.sh` CLI scripts).
//
// This task is the catalog counterpart of `syncKnowledgeBase` — same
// content-equality-checked / idempotent contract. It does NOT sync
// `agent-base.md` or `catalog-manifest.txt`: those are in-plugin prompt
// infrastructure, not part of the external skill's surface (the external
// assistant reads the catalog via scripts, not via `agent-base.md`).
// ─────────────────────────────────────────────────────────────────────────────
val agentCatalogSourceDir = file("src/main/resources/ai")
val agentCatalogSkillDir = file("skills/easy-api-assistant/ai")
val syncAgentCatalog by tasks.registering {
group = "documentation"
description = "Sync src/main/resources/ai/{detection,rules}/*.md into the easy-api-assistant skill folder."
val sourceFiles = fileTree(agentCatalogSourceDir) {
include("detection/*.md")
include("rules/*.md")
}
inputs.files(sourceFiles)
outputs.files(fileTree(agentCatalogSkillDir) { include("**/*.md") })
outputs.upToDateWhen { true }
doLast {
val sources = sourceFiles.files.sortedBy { it.path }
logger.lifecycle("Syncing ${sources.size} agent-catalog file(s) into the easy-api-assistant skill folder:")
sources.forEach { source ->
val rel = source.relativeTo(agentCatalogSourceDir).path // detection/<id>.md / rules/<key>.md
copyFileIfDifferent(source, File(agentCatalogSkillDir, rel))
logger.lifecycle(" - $rel")
}
}
}
// Ensure the JAR always ships docs synced from the canonical source.
tasks.named("processResources") {
dependsOn("syncKnowledgeBase")
dependsOn("syncAgentCatalog")
}