From d167fef891c1266aed2a689b78a4ddc52686a037 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 17 Oct 2024 14:23:10 -0700 Subject: [PATCH] update default config --- .gitignore | 12 +- .idea/.name | 1 + .idea/codeStyles/Project.xml | 57 +++++++ .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/compiler.xml | 6 + .idea/git_toolbox_blame.xml | 6 + .idea/gradle.xml | 17 ++ .idea/jarRepositories.xml | 20 +++ .idea/kotlinc.xml | 6 + .idea/ktfmt.xml | 6 + .idea/misc.xml | 11 ++ .idea/modules.xml | 11 ++ ...nsion.continue-intellij-extension.main.iml | 8 + .idea/prettier.xml | 6 + .idea/vcs.xml | 6 + core/util/paths.ts | 6 +- .../constants/ServerConstants.kt | 148 ++++++++++++++++++ 17 files changed, 323 insertions(+), 9 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/compiler.xml create mode 100644 .idea/git_toolbox_blame.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/ktfmt.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/modules/com.github.continuedev.continueintellijextension.continue-intellij-extension.main.iml create mode 100644 .idea/prettier.xml create mode 100644 .idea/vcs.xml create mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt diff --git a/.gitignore b/.gitignore index 03db26b8e..78880810a 100644 --- a/.gitignore +++ b/.gitignore @@ -147,20 +147,20 @@ codeql **/**/.qodana **/**/build -**/.idea/**/* -core/.idea - continue_server.build continue_server.dist Icon Icon? -.continue - .prompts/ .aider* notes.md -manual-testing-sandbox/Continue/.idea/** \ No newline at end of file +manual-testing-sandbox/.idea/** +extensions/intellij/.idea/** + +**/.idea/workspace.xml +**/.idea/usage.statistics.xml +**/.idea/shelf/ diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 000000000..c0d78d1d5 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Continue IntelliJ Extension \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 000000000..49630cce2 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 000000000..79ee123c2 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 000000000..b589d56e9 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/git_toolbox_blame.xml b/.idea/git_toolbox_blame.xml new file mode 100644 index 000000000..7dc124965 --- /dev/null +++ b/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 000000000..6733405f9 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 000000000..fdc392fe8 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 000000000..fdf8d994a --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/ktfmt.xml b/.idea/ktfmt.xml new file mode 100644 index 000000000..bfb71662f --- /dev/null +++ b/.idea/ktfmt.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..efa79f7df --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..5b1c3f963 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/com.github.continuedev.continueintellijextension.continue-intellij-extension.main.iml b/.idea/modules/com.github.continuedev.continueintellijextension.continue-intellij-extension.main.iml new file mode 100644 index 000000000..d2841a905 --- /dev/null +++ b/.idea/modules/com.github.continuedev.continueintellijextension.continue-intellij-extension.main.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/prettier.xml b/.idea/prettier.xml new file mode 100644 index 000000000..b0c1c68fb --- /dev/null +++ b/.idea/prettier.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..35eb1ddfb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/core/util/paths.ts b/core/util/paths.ts index 864fc2c68..3002892ca 100644 --- a/core/util/paths.ts +++ b/core/util/paths.ts @@ -3,9 +3,9 @@ import dotenv from "dotenv"; import * as fs from "fs"; import * as os from "os"; import * as path from "path"; -import { defaultConfig, defaultConfigJetBrains } from "../config/default.js"; -import Types from "../config/types.js"; -import { IdeType, SerializedContinueConfig } from "../index.js"; +import { defaultConfig, defaultConfigJetBrains } from "../config/default"; +import Types from "../config/types"; +import { IdeType, SerializedContinueConfig } from "../"; dotenv.config(); diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt new file mode 100644 index 000000000..5a1b8af0e --- /dev/null +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt @@ -0,0 +1,148 @@ +/** + * Note: This file is out of sync with the contents of core/util/paths.ts, which we use in VS Code. + * This is potentially causing JetBrains specific bugs. + */ +package com.github.continuedev.continueintellijextension.constants + +import java.nio.file.Files +import java.nio.file.Paths + +// Uncertain if this is being used anywhere since we also attempt to write a default config in +// core/util/paths.ts +const val DEFAULT_CONFIG = + """ +{ + "models": [ + { + "model": "claude-3-5-sonnet-20240620", + "provider": "anthropic", + "apiKey": "", + "title": "Claude 3.5 Sonnet" + } + ], + "tabAutocompleteModel": { + "title": "Codestral", + "provider": "mistral", + "model": "codestral-latest", + "apiKey": "" + }, + "customCommands": [ + { + "name": "test", + "prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.", + "description": "Write unit tests for highlighted code" + } + ], + "contextProviders": [ + { + "name": "diff", + "params": {} + }, + { + "name": "folder", + "params": {} + }, + { + "name": "codebase", + "params": {} + } + ], + "slashCommands": [ + { + "name": "edit", + "description": "Edit selected code" + }, + { + "name": "comment", + "description": "Write comments for the selected code" + }, + { + "name": "share", + "description": "Export the current chat session to markdown" + }, + { + "name": "commit", + "description": "Generate a git commit message" + } + ], + "docs": [] +} +""" + +const val DEFAULT_CONFIG_JS = + """ +function modifyConfig(config) { + return config; +} +export { + modifyConfig +}; +""" + +fun getContinueGlobalPath(): String { + val continuePath = Paths.get(System.getProperty("user.home"), ".continue") + if (Files.notExists(continuePath)) { + Files.createDirectories(continuePath) + } + return continuePath.toString() +} + +fun getContinueRemoteConfigPath(remoteHostname: String): String { + val path = Paths.get(getContinueGlobalPath(), ".configs") + if (Files.notExists(path)) { + Files.createDirectories(path) + } + return Paths.get(path.toString(), remoteHostname).toString() +} + +fun getConfigJsonPath(remoteHostname: String? = null): String { + val path = + Paths.get( + if (remoteHostname != null) getContinueRemoteConfigPath(remoteHostname) + else getContinueGlobalPath(), + "config.json") + if (Files.notExists(path)) { + Files.createFile(path) + Files.writeString(path, if (remoteHostname == null) DEFAULT_CONFIG else "{}") + } + return path.toString() +} + +fun getConfigJsPath(remoteHostname: String? = null): String { + val path = + Paths.get( + if (remoteHostname != null) getContinueRemoteConfigPath(remoteHostname) + else getContinueGlobalPath(), + "config.js") + if (Files.notExists(path)) { + Files.createFile(path) + Files.writeString(path, DEFAULT_CONFIG_JS) + } + return path.toString() +} + +fun getSessionsDir(): String { + val path = Paths.get(getContinueGlobalPath(), "sessions") + if (Files.notExists(path)) { + Files.createDirectories(path) + } + return path.toString() +} + +fun getSessionsListPath(): String { + val path = Paths.get(getSessionsDir(), "sessions.json") + if (Files.notExists(path)) { + Files.createFile(path) + Files.writeString(path, "[]") + } + return path.toString() +} + +fun getSessionFilePath(sessionId: String): String { + val path = Paths.get(getSessionsDir(), "$sessionId.json") + if (Files.notExists(path)) { + Files.createFile(path) + Files.writeString(path, "{}") + } + return path.toString() +}