provider factories, plugin, and package scripts
This commit is contained in:
parent
ea32d60177
commit
680edf3572
9 changed files with 117 additions and 71 deletions
9
.idea/continue.iml
generated
Normal file
9
.idea/continue.iml
generated
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
2
.idea/modules.xml
generated
2
.idea/modules.xml
generated
|
|
@ -2,7 +2,7 @@
|
|||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/continue-intellij-extension.iml" filepath="$PROJECT_DIR$/.idea/modules/continue-intellij-extension.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/continue.iml" filepath="$PROJECT_DIR$/.idea/continue.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -22,7 +22,7 @@ class ConfigJsonSchemaProviderFactory : JsonSchemaProviderFactory {
|
|||
|
||||
class ConfigJsonSchemaFileProvider : JsonSchemaFileProvider {
|
||||
override fun isAvailable(file: VirtualFile): Boolean {
|
||||
return file.name == "config.json" || file.name == ".continuerc.json"
|
||||
return path.endsWith("/.continue/config.json") || file.name == ".continuerc.json"
|
||||
}
|
||||
|
||||
override fun getName(): String {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
package com.github.continuedev.continueintellijextension.`continue`
|
||||
|
||||
import com.github.continuedev.continueintellijextension.activities.ContinuePluginStartupActivity
|
||||
import com.github.continuedev.continueintellijextension.constants.getContinueGlobalPath
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.io.StreamUtil
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider
|
||||
import com.jetbrains.jsonSchema.extension.JsonSchemaProviderFactory
|
||||
import com.jetbrains.jsonSchema.extension.SchemaType
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.Paths
|
||||
|
||||
class ConfigJsonSchemaProviderFactory : JsonSchemaProviderFactory {
|
||||
override fun getProviders(project: Project): MutableList<JsonSchemaFileProvider> {
|
||||
return mutableListOf(ConfigJsonSchemaFileProvider())
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigJsonSchemaFileProvider : JsonSchemaFileProvider {
|
||||
override fun isAvailable(file: VirtualFile): Boolean {
|
||||
return file.name == ".continuerc.json"
|
||||
}
|
||||
|
||||
override fun getName(): String {
|
||||
return "config.json"
|
||||
}
|
||||
|
||||
override fun getSchemaFile(): VirtualFile? {
|
||||
ContinuePluginStartupActivity::class.java.getClassLoader().getResourceAsStream("continue_rc_schema.json")
|
||||
.use { `is` ->
|
||||
if (`is` == null) {
|
||||
throw IOException("Resource not found: continue_rc_schema.json")
|
||||
}
|
||||
val content = StreamUtil.readText(`is`, StandardCharsets.UTF_8)
|
||||
val filepath = Paths.get(getContinueGlobalPath(), "continue_rc_schema.json").toString()
|
||||
File(filepath).writeText(content)
|
||||
return LocalFileSystem.getInstance().findFileByPath(filepath)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSchemaType(): SchemaType {
|
||||
return SchemaType.embeddedSchema
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,6 +15,10 @@
|
|||
<ProviderFactory
|
||||
implementation="com.github.continuedev.continueintellijextension.continue.ConfigJsonSchemaProviderFactory"/>
|
||||
</extensions>
|
||||
<extensions defaultExtensionNs="JavaScript.JsonSchema">
|
||||
<ProviderFactory
|
||||
implementation="com.github.continuedev.continueintellijextension.continue.ConfigRcJsonSchemaProviderFactory"/>
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<editorFactoryListener
|
||||
|
|
|
|||
|
|
@ -494,7 +494,7 @@
|
|||
},
|
||||
"jsonValidation": [
|
||||
{
|
||||
"fileMatch": "config.json",
|
||||
"fileMatch": "**/.continue/config.json",
|
||||
"url": "./config_schema.json"
|
||||
},
|
||||
{
|
||||
|
|
@ -601,4 +601,4 @@
|
|||
"ws": "^8.13.0",
|
||||
"yarn": "^1.22.21"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ function isWin() {
|
|||
async function package(target, os, arch, exe) {
|
||||
console.log("[info] Packaging extension for target ", target);
|
||||
|
||||
// Copy config_schema.json to config.json in docs and intellij
|
||||
// Copy config_schema to docs and intellij
|
||||
copyConfigSchema();
|
||||
|
||||
// Install node_modules
|
||||
|
|
@ -153,10 +153,9 @@ async function package(target, os, arch, exe) {
|
|||
|
||||
// onnx runtime bindngs
|
||||
`bin/napi-v3/${os}/${arch}/onnxruntime_binding.node`,
|
||||
`bin/napi-v3/${os}/${arch}/${
|
||||
os === "darwin"
|
||||
? "libonnxruntime.1.14.0.dylib"
|
||||
: os === "linux"
|
||||
`bin/napi-v3/${os}/${arch}/${os === "darwin"
|
||||
? "libonnxruntime.1.14.0.dylib"
|
||||
: os === "linux"
|
||||
? "libonnxruntime.so.1.14.0"
|
||||
: "onnxruntime.dll"
|
||||
}`,
|
||||
|
|
@ -193,17 +192,15 @@ async function package(target, os, arch, exe) {
|
|||
|
||||
// out/node_modules (to be accessed by extension.js)
|
||||
`out/node_modules/@vscode/ripgrep/bin/rg${exe}`,
|
||||
`out/node_modules/@esbuild/${
|
||||
target === "win32-arm64"
|
||||
? "esbuild.exe"
|
||||
: target === "win32-x64"
|
||||
`out/node_modules/@esbuild/${target === "win32-arm64"
|
||||
? "esbuild.exe"
|
||||
: target === "win32-x64"
|
||||
? "win32-x64/esbuild.exe"
|
||||
: `${target}/bin/esbuild`
|
||||
}`,
|
||||
`out/node_modules/@lancedb/vectordb-${
|
||||
os === "win32"
|
||||
? "win32-x64-msvc"
|
||||
: `${target}${os === "linux" ? "-gnu" : ""}`
|
||||
`out/node_modules/@lancedb/vectordb-${os === "win32"
|
||||
? "win32-x64-msvc"
|
||||
: `${target}${os === "linux" ? "-gnu" : ""}`
|
||||
}/index.node`,
|
||||
`out/node_modules/esbuild/lib/main.js`,
|
||||
`out/node_modules/esbuild/bin/esbuild`,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ const {
|
|||
execCmdSync,
|
||||
autodetectPlatformAndArch,
|
||||
} = require("../../../scripts/util/index");
|
||||
const { copyConfigSchema } = require("./utils");
|
||||
|
||||
// Clear folders that will be packaged to ensure clean slate
|
||||
rimrafSync(path.join(__dirname, "..", "bin"));
|
||||
|
|
@ -48,33 +49,8 @@ const exe = os === "win32" ? ".exe" : "";
|
|||
(async () => {
|
||||
console.log("[info] Packaging extension for target ", target);
|
||||
|
||||
// Copy config_schema.json to config.json in docs and intellij
|
||||
fs.copyFileSync(
|
||||
"config_schema.json",
|
||||
path.join("..", "..", "docs", "static", "schemas", "config.json"),
|
||||
);
|
||||
fs.copyFileSync(
|
||||
"config_schema.json",
|
||||
path.join(
|
||||
"..",
|
||||
"intellij",
|
||||
"src",
|
||||
"main",
|
||||
"resources",
|
||||
"config_schema.json",
|
||||
),
|
||||
);
|
||||
// Modify and copy for .continuerc.json
|
||||
const schema = JSON.parse(fs.readFileSync("config_schema.json", "utf8"));
|
||||
schema.definitions.SerializedContinueConfig.properties.mergeBehavior = {
|
||||
type: "string",
|
||||
enum: ["merge", "overwrite"],
|
||||
default: "merge",
|
||||
title: "Merge behavior",
|
||||
markdownDescription:
|
||||
"If set to 'merge', .continuerc.json will be applied on top of config.json (arrays and objects are merged). If set to 'overwrite', then every top-level property of .continuerc.json will overwrite that property from config.json.",
|
||||
};
|
||||
fs.writeFileSync("continue_rc_schema.json", JSON.stringify(schema, null, 2));
|
||||
// Copy config schemas to docs and intellij
|
||||
copyConfigSchema();
|
||||
|
||||
if (!process.cwd().endsWith("vscode")) {
|
||||
// This is sometimes run from root dir instead (e.g. in VS Code tasks)
|
||||
|
|
@ -505,12 +481,11 @@ const exe = os === "win32" ? ".exe" : "";
|
|||
|
||||
// onnx runtime bindngs
|
||||
`bin/napi-v3/${os}/${arch}/onnxruntime_binding.node`,
|
||||
`bin/napi-v3/${os}/${arch}/${
|
||||
os === "darwin"
|
||||
? "libonnxruntime.1.14.0.dylib"
|
||||
: os === "linux"
|
||||
? "libonnxruntime.so.1.14.0"
|
||||
: "onnxruntime.dll"
|
||||
`bin/napi-v3/${os}/${arch}/${os === "darwin"
|
||||
? "libonnxruntime.1.14.0.dylib"
|
||||
: os === "linux"
|
||||
? "libonnxruntime.so.1.14.0"
|
||||
: "onnxruntime.dll"
|
||||
}`,
|
||||
"builtin-themes/dark_modern.json",
|
||||
|
||||
|
|
@ -545,17 +520,15 @@ const exe = os === "win32" ? ".exe" : "";
|
|||
|
||||
// out/node_modules (to be accessed by extension.js)
|
||||
`out/node_modules/@vscode/ripgrep/bin/rg${exe}`,
|
||||
`out/node_modules/@esbuild/${
|
||||
target === "win32-arm64"
|
||||
? "esbuild.exe"
|
||||
: target === "win32-x64"
|
||||
? "win32-x64/esbuild.exe"
|
||||
: `${target}/bin/esbuild`
|
||||
`out/node_modules/@esbuild/${target === "win32-arm64"
|
||||
? "esbuild.exe"
|
||||
: target === "win32-x64"
|
||||
? "win32-x64/esbuild.exe"
|
||||
: `${target}/bin/esbuild`
|
||||
}`,
|
||||
`out/node_modules/@lancedb/vectordb-${
|
||||
os === "win32"
|
||||
? "win32-x64-msvc"
|
||||
: `${target}${os === "linux" ? "-gnu" : ""}`
|
||||
`out/node_modules/@lancedb/vectordb-${os === "win32"
|
||||
? "win32-x64-msvc"
|
||||
: `${target}${os === "linux" ? "-gnu" : ""}`
|
||||
}/index.node`,
|
||||
`out/node_modules/esbuild/lib/main.js`,
|
||||
`out/node_modules/esbuild/bin/esbuild`,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,19 @@ const {
|
|||
const continueDir = path.join(__dirname, "..", "..", "..");
|
||||
|
||||
function copyConfigSchema() {
|
||||
// Modify and copy for .continuerc.json
|
||||
const schema = JSON.parse(fs.readFileSync("config_schema.json", "utf8"));
|
||||
schema.definitions.SerializedContinueConfig.properties.mergeBehavior = {
|
||||
type: "string",
|
||||
enum: ["merge", "overwrite"],
|
||||
default: "merge",
|
||||
title: "Merge behavior",
|
||||
markdownDescription:
|
||||
"If set to 'merge', .continuerc.json will be applied on top of config.json (arrays and objects are merged). If set to 'overwrite', then every top-level property of .continuerc.json will overwrite that property from config.json.",
|
||||
};
|
||||
fs.writeFileSync("continue_rc_schema.json", JSON.stringify(schema, null, 2));
|
||||
|
||||
// Copy config schemas to docs and intellij
|
||||
fs.copyFileSync(
|
||||
"config_schema.json",
|
||||
path.join("..", "..", "docs", "static", "schemas", "config.json"),
|
||||
|
|
@ -26,17 +39,18 @@ function copyConfigSchema() {
|
|||
"config_schema.json",
|
||||
),
|
||||
);
|
||||
// Modify and copy for .continuerc.json
|
||||
const schema = JSON.parse(fs.readFileSync("config_schema.json", "utf8"));
|
||||
schema.definitions.SerializedContinueConfig.properties.mergeBehavior = {
|
||||
type: "string",
|
||||
enum: ["merge", "overwrite"],
|
||||
default: "merge",
|
||||
title: "Merge behavior",
|
||||
markdownDescription:
|
||||
"If set to 'merge', .continuerc.json will be applied on top of config.json (arrays and objects are merged). If set to 'overwrite', then every top-level property of .continuerc.json will overwrite that property from config.json.",
|
||||
};
|
||||
fs.writeFileSync("continue_rc_schema.json", JSON.stringify(schema, null, 2));
|
||||
fs.copyFileSync(
|
||||
"continue_rc_schema.json",
|
||||
path.join(
|
||||
"..",
|
||||
"intellij",
|
||||
"src",
|
||||
"main",
|
||||
"resources",
|
||||
"continue_rc_schema.json",
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function copyTokenizers() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue