Merge pull request #6680 from continuedev/dallin/remove-get-configs
chore: remove getWorkspaceConfigs
This commit is contained in:
commit
3b615634db
15 changed files with 33 additions and 113 deletions
31
core/config/json/loadRcConfigs.ts
Normal file
31
core/config/json/loadRcConfigs.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import * as JSONC from "comment-json";
|
||||
import { ContinueRcJson, FileType, IDE } from "../..";
|
||||
import { joinPathsToUri } from "../../util/uri";
|
||||
|
||||
export async function getWorkspaceRcConfigs(
|
||||
ide: IDE,
|
||||
): Promise<ContinueRcJson[]> {
|
||||
try {
|
||||
const workspaces = await ide.getWorkspaceDirs();
|
||||
const rcFiles = await Promise.all(
|
||||
workspaces.map(async (dir) => {
|
||||
const ls = await ide.listDir(dir);
|
||||
const rcFiles = ls
|
||||
.filter(
|
||||
(entry) =>
|
||||
(entry[1] === (1 as FileType.File) ||
|
||||
entry[1] === (64 as FileType.SymbolicLink)) &&
|
||||
entry[0].endsWith(".continuerc.json"),
|
||||
)
|
||||
.map((entry) => joinPathsToUri(dir, entry[0]));
|
||||
return await Promise.all(rcFiles.map(ide.readFile));
|
||||
}),
|
||||
);
|
||||
return rcFiles
|
||||
.flat()
|
||||
.map((file) => JSONC.parse(file) as unknown as ContinueRcJson);
|
||||
} catch (e) {
|
||||
console.debug("Failed to load workspace configs: ", e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -64,6 +64,7 @@ import { localPathToUri } from "../util/pathToUri";
|
|||
|
||||
import { getToolsForIde } from "../tools";
|
||||
import { resolveRelativePathInDir } from "../util/ideUtils";
|
||||
import { getWorkspaceRcConfigs } from "./json/loadRcConfigs";
|
||||
import { modifyAnyConfigWithSharedConfig } from "./sharedConfig";
|
||||
import {
|
||||
getModelByRole,
|
||||
|
|
@ -877,7 +878,6 @@ async function buildConfigTsandReadConfigJs(ide: IDE, ideType: IdeType) {
|
|||
|
||||
async function loadContinueConfigFromJson(
|
||||
ide: IDE,
|
||||
workspaceConfigs: ContinueRcJson[],
|
||||
ideSettings: IdeSettings,
|
||||
ideInfo: IdeInfo,
|
||||
uniqueId: string,
|
||||
|
|
@ -885,6 +885,7 @@ async function loadContinueConfigFromJson(
|
|||
workOsAccessToken: string | undefined,
|
||||
overrideConfigJson: SerializedContinueConfig | undefined,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
const workspaceConfigs = await getWorkspaceRcConfigs(ide);
|
||||
// Serialized config
|
||||
let {
|
||||
config: serialized,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import {
|
|||
|
||||
import {
|
||||
ContinueConfig,
|
||||
ContinueRcJson,
|
||||
IDE,
|
||||
IdeSettings,
|
||||
ILLMLogger,
|
||||
|
|
@ -86,7 +85,6 @@ export default async function doLoadConfig(options: {
|
|||
packageIdentifier,
|
||||
} = options;
|
||||
|
||||
const workspaceConfigs = await getWorkspaceConfigs(ide);
|
||||
const ideInfo = await ide.getIdeInfo();
|
||||
const uniqueId = await ide.getUniqueId();
|
||||
const ideSettings = await ideSettingsPromise;
|
||||
|
|
@ -126,7 +124,6 @@ export default async function doLoadConfig(options: {
|
|||
} else {
|
||||
const result = await loadContinueConfigFromJson(
|
||||
ide,
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
|
|
@ -365,21 +362,3 @@ async function injectControlPlaneProxyInfo(
|
|||
|
||||
return config;
|
||||
}
|
||||
|
||||
async function getWorkspaceConfigs(ide: IDE): Promise<ContinueRcJson[]> {
|
||||
const ideInfo = await ide.getIdeInfo();
|
||||
let workspaceConfigs: ContinueRcJson[] = [];
|
||||
|
||||
try {
|
||||
workspaceConfigs = await ide.getWorkspaceConfigs();
|
||||
|
||||
// Config is sent over the wire from JB so we need to parse it
|
||||
if (ideInfo.ideType === "jetbrains") {
|
||||
workspaceConfigs = (workspaceConfigs as any).map(JSON.parse);
|
||||
}
|
||||
} catch (e) {
|
||||
console.debug("Failed to load workspace configs: ", e);
|
||||
}
|
||||
|
||||
return workspaceConfigs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -682,8 +682,6 @@ declare global {
|
|||
|
||||
getWorkspaceDirs(): Promise<string[]>;
|
||||
|
||||
getWorkspaceConfigs(): Promise<ContinueRcJson[]>;
|
||||
|
||||
fileExists(filepath: string): Promise<boolean>;
|
||||
|
||||
writeFile(path: string, contents: string): Promise<void>;
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -806,8 +806,6 @@ export interface IDE {
|
|||
|
||||
getWorkspaceDirs(): Promise<string[]>;
|
||||
|
||||
getWorkspaceConfigs(): Promise<ContinueRcJson[]>;
|
||||
|
||||
fileExists(fileUri: string): Promise<boolean>;
|
||||
|
||||
writeFile(path: string, contents: string): Promise<void>;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import type {
|
||||
ContinueRcJson,
|
||||
FileStatsMap,
|
||||
FileType,
|
||||
IDE,
|
||||
|
|
@ -52,7 +51,6 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
showLines: [{ filepath: string; startLine: number; endLine: number }, void];
|
||||
readRangeInFile: [{ filepath: string; range: Range }, string];
|
||||
getDiff: [{ includeUnstaged: boolean }, string[]];
|
||||
getWorkspaceConfigs: [undefined, ContinueRcJson[]];
|
||||
getTerminalContents: [undefined, string];
|
||||
getDebugLocals: [{ threadIndex: number }, string];
|
||||
getTopLevelCallStackSources: [
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { FromIdeProtocol } from "..";
|
|||
import { ToIdeFromWebviewOrCoreProtocol } from "../ide";
|
||||
|
||||
import type {
|
||||
ContinueRcJson,
|
||||
FileStatsMap,
|
||||
FileType,
|
||||
IDE,
|
||||
|
|
@ -123,10 +122,6 @@ export class MessageIde implements IDE {
|
|||
return this.request("getUniqueId", undefined);
|
||||
}
|
||||
|
||||
getWorkspaceConfigs(): Promise<ContinueRcJson[]> {
|
||||
return this.request("getWorkspaceConfigs", undefined);
|
||||
}
|
||||
|
||||
async getDiff(includeUnstaged: boolean) {
|
||||
return await this.request("getDiff", { includeUnstaged });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,10 +89,6 @@ export class ReverseMessageIde {
|
|||
return this.ide.getUniqueId();
|
||||
});
|
||||
|
||||
this.on("getWorkspaceConfigs", () => {
|
||||
return this.ide.getWorkspaceConfigs();
|
||||
});
|
||||
|
||||
this.on("getIdeSettings", () => {
|
||||
return this.ide.getIdeSettings();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import * as fs from "node:fs";
|
|||
|
||||
import { fileURLToPath } from "node:url";
|
||||
import {
|
||||
ContinueRcJson,
|
||||
FileStatsMap,
|
||||
FileType,
|
||||
IDE,
|
||||
|
|
@ -145,10 +144,6 @@ class FileSystemIde implements IDE {
|
|||
return Promise.resolve("NOT_UNIQUE");
|
||||
}
|
||||
|
||||
getWorkspaceConfigs(): Promise<ContinueRcJson[]> {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
getDiff(includeUnstaged: boolean): Promise<string[]> {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ class MessageTypes {
|
|||
"readRangeInFile",
|
||||
"isTelemetryEnabled",
|
||||
"getUniqueId",
|
||||
"getWorkspaceConfigs",
|
||||
"getDiff",
|
||||
"getTerminalContents",
|
||||
"getWorkspaceDirs",
|
||||
|
|
|
|||
|
|
@ -196,11 +196,6 @@ class IdeProtocolClient(
|
|||
respond(tags)
|
||||
}
|
||||
|
||||
"getWorkspaceConfigs" -> {
|
||||
val configs = ide.getWorkspaceConfigs()
|
||||
respond(configs)
|
||||
}
|
||||
|
||||
"getTerminalContents" -> {
|
||||
val contents = ide.getTerminalContents()
|
||||
respond(contents)
|
||||
|
|
|
|||
|
|
@ -180,29 +180,6 @@ class IntelliJIDE(
|
|||
return workspaceDirectories().toList()
|
||||
}
|
||||
|
||||
override suspend fun getWorkspaceConfigs(): List<ContinueRcJson> {
|
||||
val workspaceDirs = this.getWorkspaceDirs()
|
||||
|
||||
val configs = mutableListOf<String>()
|
||||
|
||||
for (workspaceDir in workspaceDirs) {
|
||||
val dir = VirtualFileManager.getInstance().findFileByUrl(workspaceDir)
|
||||
if (dir != null) {
|
||||
val contents = dir.children.mapNotNull { it.toUriOrNull() }
|
||||
|
||||
// Find any .continuerc.json files
|
||||
for (file in contents) {
|
||||
if (file.endsWith(".continuerc.json")) {
|
||||
val fileContent = UriUtils.uriToFile(file).readText()
|
||||
configs.add(fileContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return configs as List<ContinueRcJson>
|
||||
}
|
||||
|
||||
override suspend fun fileExists(filepath: String): Boolean =
|
||||
fileUtils.fileExists(filepath)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,6 @@ enum class FileType(val value: Int) {
|
|||
SYMBOLIC_LINK(64)
|
||||
}
|
||||
|
||||
enum class ConfigMergeType {
|
||||
MERGE,
|
||||
OVERWRITE
|
||||
}
|
||||
|
||||
data class Position(val line: Int, val character: Int)
|
||||
|
||||
data class Range(val start: Position, val end: Position)
|
||||
|
|
@ -149,10 +144,6 @@ data class IdeSettings(
|
|||
val continueTestEnvironment: String
|
||||
)
|
||||
|
||||
data class ContinueRcJson(
|
||||
val mergeBehavior: ConfigMergeType
|
||||
)
|
||||
|
||||
data class TerminalOptions(
|
||||
val reuseTerminal: Boolean?,
|
||||
val terminalName: String?,
|
||||
|
|
@ -187,8 +178,6 @@ interface IDE {
|
|||
|
||||
suspend fun getWorkspaceDirs(): List<String>
|
||||
|
||||
suspend fun getWorkspaceConfigs(): List<ContinueRcJson>
|
||||
|
||||
suspend fun fileExists(filepath: String): Boolean
|
||||
|
||||
suspend fun writeFile(path: String, contents: String)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import { getExtensionUri, openEditorAndRevealRange } from "./util/vscode";
|
|||
import { VsCodeWebviewProtocol } from "./webviewProtocol";
|
||||
|
||||
import type {
|
||||
ContinueRcJson,
|
||||
FileStatsMap,
|
||||
FileType,
|
||||
IDE,
|
||||
|
|
@ -266,32 +265,6 @@ class VsCodeIde implements IDE {
|
|||
return await this.ideUtils.getAvailableThreads();
|
||||
}
|
||||
|
||||
async getWorkspaceConfigs() {
|
||||
const workspaceDirs =
|
||||
vscode.workspace.workspaceFolders?.map((folder) => folder.uri) || [];
|
||||
const configs: ContinueRcJson[] = [];
|
||||
for (const workspaceDir of workspaceDirs) {
|
||||
const files = await this.ideUtils.readDirectory(workspaceDir);
|
||||
if (files === null) {
|
||||
//Unlikely, but just in case...
|
||||
continue;
|
||||
}
|
||||
for (const [filename, type] of files) {
|
||||
if (
|
||||
(type === vscode.FileType.File ||
|
||||
type === vscode.FileType.SymbolicLink) &&
|
||||
filename === ".continuerc.json"
|
||||
) {
|
||||
const contents = await this.readFile(
|
||||
vscode.Uri.joinPath(workspaceDir, filename).toString(),
|
||||
);
|
||||
configs.push(JSON.parse(contents));
|
||||
}
|
||||
}
|
||||
}
|
||||
return configs;
|
||||
}
|
||||
|
||||
async getWorkspaceDirs(): Promise<string[]> {
|
||||
return this.ideUtils.getWorkspaceDirectories().map((uri) => uri.toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -418,10 +418,6 @@ export class VsCodeMessenger {
|
|||
return await ide.isTelemetryEnabled();
|
||||
});
|
||||
|
||||
this.onWebviewOrCore("getWorkspaceConfigs", async (msg) => {
|
||||
return await ide.getWorkspaceConfigs();
|
||||
});
|
||||
|
||||
this.onWebviewOrCore("getUniqueId", async (msg) => {
|
||||
return await ide.getUniqueId();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue