Skip to content

Commit 49d0bfe

Browse files
committed
feat(schema): refactor and extend JSON schema providers #271
- Removed `CustomPromptsJsonSchemaProviderFactory.kt` and related references. - Renamed `CustomAgentJsonSchemaProviderFactory.kt` to `AutoDevJsonSchemaProviderFactory.kt`. - Added `CustomLlmSchemaFileProvider.kt` for custom LLM schema handling. - Updated `AutoDevJsonSchemaProviderFactory` to include new providers. - Introduced `LlmData.kt` for LLM configuration models.
1 parent 2d8e8ba commit 49d0bfe

File tree

7 files changed

+77
-15
lines changed

7 files changed

+77
-15
lines changed

core/src/223/main/resources/META-INF/autodev-core.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686

8787
<extensions defaultExtensionNs="JavaScript.JsonSchema">
8888
<ProviderFactory implementation="cc.unitmesh.devti.custom.schema.AutoDevJsonSchemaProviderFactory"/>
89-
<ProviderFactory implementation="cc.unitmesh.devti.custom.schema.AutoDevPromptJsonSchemaProviderFactory"/>
9089
</extensions>
9190

9291
<extensionPoints>

core/src/233/main/resources/META-INF/autodev-core.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686

8787
<extensions defaultExtensionNs="JavaScript.JsonSchema">
8888
<ProviderFactory implementation="cc.unitmesh.devti.custom.schema.AutoDevJsonSchemaProviderFactory"/>
89-
<ProviderFactory implementation="cc.unitmesh.devti.custom.schema.AutoDevPromptJsonSchemaProviderFactory"/>
9089
</extensions>
9190

9291
<extensionPoints>

core/src/main/kotlin/cc/unitmesh/devti/custom/schema/CustomAgentJsonSchemaProviderFactory.kt renamed to core/src/main/kotlin/cc/unitmesh/devti/custom/schema/AutoDevJsonSchemaProviderFactory.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ import com.intellij.openapi.project.Project
44
import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider
55
import com.jetbrains.jsonSchema.extension.JsonSchemaProviderFactory
66

7-
class AutoDevJsonSchemaProviderFactory: JsonSchemaProviderFactory {
7+
class AutoDevJsonSchemaProviderFactory : JsonSchemaProviderFactory {
88
override fun getProviders(project: Project): MutableList<JsonSchemaFileProvider> {
9-
return mutableListOf(CustomAgentSchemaFileProvider(project))
9+
return mutableListOf(
10+
CustomAgentSchemaFileProvider(project),
11+
CustomLlmSchemaFileProvider(project),
12+
CustomPromptsSchemaFileProvider(project)
13+
)
1014
}
1115
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package cc.unitmesh.devti.custom.schema
2+
3+
import com.intellij.openapi.application.runReadAction
4+
import com.intellij.openapi.project.Project
5+
import com.intellij.openapi.vfs.VfsUtil
6+
import com.intellij.openapi.vfs.VirtualFile
7+
import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider
8+
import com.jetbrains.jsonSchema.extension.SchemaType
9+
10+
const val AUTODEV_CUSTOM_LLM_FILE = "AutoDevCustomLlmFile.json"
11+
12+
class CustomLlmSchemaFileProvider(val project: Project) : JsonSchemaFileProvider {
13+
override fun isAvailable(file: VirtualFile): Boolean {
14+
return runReadAction { isAutoDevCustomAgentFile(file) }
15+
}
16+
17+
private fun isAutoDevCustomAgentFile(file: VirtualFile): Boolean {
18+
if (!file.isValid) return false
19+
return file.name == AUTODEV_CUSTOM_LLM_FILE
20+
}
21+
22+
override fun getName(): String = "AutoDevCustomLlmFile"
23+
override fun getSchemaFile() = VfsUtil.findFileByURL(javaClass.getResource(CUSTOM_LLM_SCHEMA_FILE)!!)
24+
override fun getSchemaType(): SchemaType = SchemaType.embeddedSchema
25+
26+
companion object {
27+
private const val CUSTOM_LLM_SCHEMA_FILE = "autodev-custom-llm.json"
28+
}
29+
}

core/src/main/kotlin/cc/unitmesh/devti/custom/schema/CustomPromptsJsonSchemaProviderFactory.kt

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cc.unitmesh.devti.llm2.model
2+
3+
import kotlinx.serialization.Serializable
4+
5+
@Serializable
6+
data class Auth(
7+
val type: String,
8+
val token: String
9+
)
10+
11+
@Serializable
12+
data class LlmConfig(
13+
val name: String,
14+
val description: String,
15+
val url: String,
16+
val auth: Auth,
17+
val requestFormat: String,
18+
val responseFormat: String
19+
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "array",
4+
"items": {
5+
"type": "object",
6+
"properties": {
7+
"name": { "type": "string" },
8+
"description": { "type": "string" },
9+
"url": { "type": "string", "format": "uri" },
10+
"auth": {
11+
"type": "object",
12+
"properties": {
13+
"type": { "type": "string" },
14+
"token": { "type": "string" }
15+
},
16+
"required": ["type", "token"]
17+
},
18+
"requestFormat": { "type": "string" },
19+
"responseFormat": { "type": "string" }
20+
},
21+
"required": ["name", "description", "url", "auth", "requestFormat", "responseFormat"]
22+
}
23+
}

0 commit comments

Comments
 (0)