🚧 separate default config for jetbrains
This commit is contained in:
parent
1cc94ea893
commit
b2ed790ef9
9 changed files with 109 additions and 16 deletions
|
|
@ -1,12 +1,17 @@
|
|||
import { SerializedContinueConfig } from "..";
|
||||
|
||||
const defaultConfig: SerializedContinueConfig = {
|
||||
export const defaultConfig: SerializedContinueConfig = {
|
||||
models: [
|
||||
{
|
||||
title: "GPT-4 Vision (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-4-vision-preview",
|
||||
},
|
||||
{
|
||||
title: "GPT-3.5-Turbo (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-3.5-turbo",
|
||||
},
|
||||
{
|
||||
title: "Gemini Pro (Free Trial)",
|
||||
provider: "free-trial",
|
||||
|
|
@ -29,7 +34,7 @@ const defaultConfig: SerializedContinueConfig = {
|
|||
},
|
||||
{
|
||||
name: "share",
|
||||
description: "Download and share this session",
|
||||
description: "Export this session as markdown",
|
||||
},
|
||||
{
|
||||
name: "cmd",
|
||||
|
|
@ -56,4 +61,55 @@ const defaultConfig: SerializedContinueConfig = {
|
|||
],
|
||||
};
|
||||
|
||||
export default defaultConfig;
|
||||
export const defaultConfigJetBrains: SerializedContinueConfig = {
|
||||
models: [
|
||||
{
|
||||
title: "GPT-4 Vision (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-4-vision-preview",
|
||||
},
|
||||
{
|
||||
title: "GPT-3.5-Turbo (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-3.5-turbo",
|
||||
},
|
||||
{
|
||||
title: "Gemini Pro (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gemini-pro",
|
||||
},
|
||||
{
|
||||
title: "Codellama 70b (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "codellama-70b",
|
||||
},
|
||||
],
|
||||
slashCommands: [
|
||||
{
|
||||
name: "edit",
|
||||
description: "Edit selected code",
|
||||
},
|
||||
{
|
||||
name: "comment",
|
||||
description: "Write comments for the selected code",
|
||||
},
|
||||
{
|
||||
name: "share",
|
||||
description: "Export this session as markdown",
|
||||
},
|
||||
],
|
||||
customCommands: [
|
||||
{
|
||||
name: "test",
|
||||
prompt:
|
||||
"Write 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: "open",
|
||||
params: {},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ export class ConfigHandler {
|
|||
|
||||
this.savedConfig = await loadFullConfigNode(
|
||||
this.ide.readFile,
|
||||
workspaceConfigs
|
||||
workspaceConfigs,
|
||||
(await this.ide.getIdeInfo()).ideType
|
||||
);
|
||||
this.savedConfig.allowAnonymousTelemetry =
|
||||
this.savedConfig.allowAnonymousTelemetry &&
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {
|
|||
CustomLLM,
|
||||
EmbeddingsProviderDescription,
|
||||
IContextProvider,
|
||||
IdeType,
|
||||
ModelDescription,
|
||||
SerializedContinueConfig,
|
||||
SlashCommand,
|
||||
|
|
@ -37,9 +38,10 @@ import {
|
|||
} from "../util/paths";
|
||||
|
||||
function loadSerializedConfig(
|
||||
workspaceConfigs: ContinueRcJson[]
|
||||
workspaceConfigs: ContinueRcJson[],
|
||||
ideType: IdeType = "vscode"
|
||||
): SerializedContinueConfig {
|
||||
const configPath = getConfigJsonPath();
|
||||
const configPath = getConfigJsonPath(ideType);
|
||||
let contents = fs.readFileSync(configPath, "utf8");
|
||||
let config = JSON.parse(contents) as SerializedContinueConfig;
|
||||
if (config.allowAnonymousTelemetry === undefined) {
|
||||
|
|
@ -354,9 +356,10 @@ async function buildConfigTs(browser: boolean) {
|
|||
|
||||
async function loadFullConfigNode(
|
||||
readFile: (filepath: string) => Promise<string>,
|
||||
workspaceConfigs: ContinueRcJson[]
|
||||
workspaceConfigs: ContinueRcJson[],
|
||||
ideType: IdeType
|
||||
): Promise<ContinueConfig> {
|
||||
let serialized = loadSerializedConfig(workspaceConfigs);
|
||||
let serialized = loadSerializedConfig(workspaceConfigs, ideType);
|
||||
let intermediate = serializedToIntermediateConfig(serialized);
|
||||
|
||||
const configJsContents = await buildConfigTs(false);
|
||||
|
|
|
|||
9
core/index.d.ts
vendored
9
core/index.d.ts
vendored
|
|
@ -290,7 +290,16 @@ export class Problem {
|
|||
message: string;
|
||||
}
|
||||
|
||||
export type IdeType = "vscode" | "jetbrains";
|
||||
export interface IdeInfo {
|
||||
ideType: IdeType;
|
||||
name: string;
|
||||
version: string;
|
||||
remoteName: string;
|
||||
}
|
||||
|
||||
export interface IDE {
|
||||
getIdeInfo(): Promise<IdeInfo>;
|
||||
getDiff(): Promise<string>;
|
||||
isTelemetryEnabled(): Promise<boolean>;
|
||||
getUniqueId(): Promise<string>;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,16 @@
|
|||
import * as fs from "fs";
|
||||
import { ContinueRcJson, IDE, Problem, Range } from "..";
|
||||
import { ContinueRcJson, IDE, IdeInfo, Problem, Range } from "..";
|
||||
import { getContinueGlobalPath } from "./paths";
|
||||
|
||||
class FileSystemIde implements IDE {
|
||||
getIdeInfo(): Promise<IdeInfo> {
|
||||
return Promise.resolve({
|
||||
ideType: "vscode",
|
||||
name: "na",
|
||||
version: "0.1",
|
||||
remoteName: "na",
|
||||
});
|
||||
}
|
||||
readRangeInFile(filepath: string, range: Range): Promise<string> {
|
||||
return Promise.resolve("");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
import { ContinueRcJson, IDE, Problem, Range } from "..";
|
||||
import { ContinueRcJson, IDE, IdeInfo, Problem, Range } from "..";
|
||||
|
||||
export class MessageIde implements IDE {
|
||||
constructor(
|
||||
private readonly request: (messageType: string, data: any) => Promise<any>
|
||||
) {}
|
||||
getIdeInfo(): Promise<IdeInfo> {
|
||||
return this.request("getIdeInfo", undefined);
|
||||
}
|
||||
|
||||
readRangeInFile(filepath: string, range: Range): Promise<string> {
|
||||
return this.request("readRangeInFile", { filepath, range });
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { SerializedContinueConfig } from "..";
|
||||
import defaultConfig from "../config/default";
|
||||
import { IdeType, SerializedContinueConfig } from "..";
|
||||
import { defaultConfig, defaultConfigJetBrains } from "../config/default";
|
||||
import Types from "../config/types";
|
||||
|
||||
export function getContinueGlobalPath(): string {
|
||||
|
|
@ -42,10 +42,14 @@ export function getSessionsListPath(): string {
|
|||
return filepath;
|
||||
}
|
||||
|
||||
export function getConfigJsonPath(): string {
|
||||
export function getConfigJsonPath(ideType: IdeType = "vscode"): string {
|
||||
const p = path.join(getContinueGlobalPath(), "config.json");
|
||||
if (!fs.existsSync(p)) {
|
||||
fs.writeFileSync(p, JSON.stringify(defaultConfig, null, 2));
|
||||
if (ideType === "jetbrains") {
|
||||
fs.writeFileSync(p, JSON.stringify(defaultConfigJetBrains, null, 2));
|
||||
} else {
|
||||
fs.writeFileSync(p, JSON.stringify(defaultConfig, null, 2));
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class IdeProtocolClient (
|
|||
mapOf("uniqueId" to uniqueId())
|
||||
)
|
||||
|
||||
"ide" -> {
|
||||
"getIdeInfo" -> {
|
||||
val applicationInfo = ApplicationInfo.getInstance()
|
||||
val ideName: String = applicationInfo.fullApplicationName
|
||||
val ideVersion = applicationInfo.fullVersion
|
||||
|
|
@ -159,6 +159,7 @@ class IdeProtocolClient (
|
|||
remoteName = "ssh"
|
||||
}
|
||||
respond(mapOf(
|
||||
"ideType" to "jetbrains",
|
||||
"name" to ideName,
|
||||
"version" to ideVersion,
|
||||
"remoteName" to remoteName
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import * as path from "path";
|
|||
import * as vscode from "vscode";
|
||||
|
||||
import * as child_process from "child_process";
|
||||
import { ContinueRcJson, IDE, Problem, Range } from "core";
|
||||
import { ContinueRcJson, IDE, IdeInfo, Problem, Range } from "core";
|
||||
import { DiffManager } from "./diff/horizontal";
|
||||
import { VsCodeIdeUtils } from "./util/ideUtils";
|
||||
import { traverseDirectory } from "./util/traverseDirectory";
|
||||
|
|
@ -16,6 +16,14 @@ class VsCodeIde implements IDE {
|
|||
constructor(private readonly diffManager: DiffManager) {
|
||||
this.ideUtils = new VsCodeIdeUtils();
|
||||
}
|
||||
getIdeInfo(): Promise<IdeInfo> {
|
||||
return Promise.resolve({
|
||||
ideType: "vscode",
|
||||
name: vscode.env.appName,
|
||||
version: vscode.version,
|
||||
remoteName: vscode.env.remoteName || "local",
|
||||
});
|
||||
}
|
||||
readRangeInFile(filepath: string, range: Range): Promise<string> {
|
||||
return this.ideUtils.readRangeInFile(
|
||||
filepath,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue