continue-custom/core/util/messageIde.ts
Nate Sesti ca884b8212
fix ollama onboarding (#1539)
* allow setting apiBase for bedrock provider

* ⚡️ better linking

* ✨ new prompt file action

* ⚡️ strip <COMPLETION> from GPT-4 completion

* continue proxy FIM support

* warn user if potentially dangerous command is generated

* tab autocomplete docs

* docs: update PR template (#1531)

* chore: add docs to install script (#1533)

* fix(extensions): schema for db ctx provider (#1534)

* fix(extensions): schema for db ctx provider

* fix: invalid enum

* prettierignore

* docs: add docs and schema for "OS" provider (#1536)

* tests (#1501)

* 👷 CI for jetbrains

* default working dir

* changelog

* build binaries

* binary testing setup

* idesettings

* core binary testing

* run binary tests in ci

* remove unused targets

* needs build

* console.log bin contents

* fix ci

* fix win32 binary download

* test

* no linux arm64

* macos latest

* macos-12

* binary permissions

* upload logs

* fix

* upload full folder as binary artifact

* test

* test macos only

* set full execute permissions

* copy sqlite binary

* cd

* it worked!

* build again in test job

* debug

* remove timeout

* info

* log

* log2

* more logs

* catch

* fewer logs

* test all platforms

* test downloaded artifact

* needs build

* updates

* build

* false

* release

* add tag and upload binaryes

* change tag name

* proper artifact upload

* jest updates

* ✅ generate a few unit tests with Continue

* fix imports related to IdeSettings

* run tsc on PRs

* remove shareSession command (unused)

* update release process

* update plugin version

* don't show ghost text when jetbrains completion visible

* run jetbrains ci in main

* check ts in dev

* ignore .env

* 🚑 fix constant warnings when onboarding with Ollama

---------

Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com>
2024-06-21 11:09:03 -07:00

193 lines
5.1 KiB
TypeScript

import type {
ContinueRcJson,
FileType,
IDE,
IdeInfo,
IdeSettings,
IndexTag,
Problem,
Range,
Thread,
} from "../index.js";
import { ToIdeFromWebviewOrCoreProtocol } from "../protocol/ide.js";
export class MessageIde implements IDE {
constructor(
private readonly request: <T extends keyof ToIdeFromWebviewOrCoreProtocol>(
messageType: T,
data: ToIdeFromWebviewOrCoreProtocol[T][0],
) => Promise<ToIdeFromWebviewOrCoreProtocol[T][1]>,
) {}
getIdeSettings(): Promise<IdeSettings> {
return this.request("getIdeSettings", undefined);
}
getGitHubAuthToken(): Promise<string | undefined> {
return this.request("getGitHubAuthToken", undefined);
}
getLastModified(files: string[]): Promise<{ [path: string]: number }> {
return this.request("getLastModified", { files });
}
getGitRootPath(dir: string): Promise<string | undefined> {
return this.request("getGitRootPath", { dir });
}
listDir(dir: string): Promise<[string, FileType][]> {
return this.request("listDir", { dir });
}
infoPopup(message: string): Promise<void> {
return this.request("errorPopup", { message });
}
errorPopup(message: string): Promise<void> {
return this.request("errorPopup", { message });
}
getRepoName(dir: string): Promise<string | undefined> {
return this.request("getRepoName", { dir });
}
getDebugLocals(threadIndex: number): Promise<string> {
return this.request("getDebugLocals", { threadIndex });
}
getTopLevelCallStackSources(
threadIndex: number,
stackDepth: number,
): Promise<string[]> {
return this.request("getTopLevelCallStackSources", {
threadIndex,
stackDepth,
});
}
getAvailableThreads(): Promise<Thread[]> {
return this.request("getAvailableThreads", undefined);
}
getTags(artifactId: string): Promise<IndexTag[]> {
return this.request("getTags", artifactId);
}
getIdeInfo(): Promise<IdeInfo> {
return this.request("getIdeInfo", undefined);
}
readRangeInFile(filepath: string, range: Range): Promise<string> {
return this.request("readRangeInFile", { filepath, range });
}
isTelemetryEnabled(): Promise<boolean> {
return this.request("isTelemetryEnabled", undefined);
}
getUniqueId(): Promise<string> {
return this.request("getUniqueId", undefined);
}
getWorkspaceConfigs(): Promise<ContinueRcJson[]> {
return this.request("getWorkspaceConfigs", undefined);
}
async getDiff() {
return await this.request("getDiff", undefined);
}
async getTerminalContents() {
return await this.request("getTerminalContents", undefined);
}
async listWorkspaceContents(
directory?: string,
useGitIgnore?: boolean,
): Promise<string[]> {
return await this.request("listWorkspaceContents", {
directory,
useGitIgnore,
});
}
async getWorkspaceDirs(): Promise<string[]> {
return await this.request("getWorkspaceDirs", undefined);
}
async showLines(
filepath: string,
startLine: number,
endLine: number,
): Promise<void> {
return await this.request("showLines", { filepath, startLine, endLine });
}
async listFolders(): Promise<string[]> {
return await this.request("listFolders", undefined);
}
_continueDir: string | null = null;
async getContinueDir(): Promise<string> {
if (this._continueDir) {
return this._continueDir;
}
const dir = await this.request("getContinueDir", undefined);
this._continueDir = dir;
return dir;
}
async writeFile(path: string, contents: string): Promise<void> {
await this.request("writeFile", { path, contents });
}
async showVirtualFile(title: string, contents: string): Promise<void> {
await this.request("showVirtualFile", { name: title, content: contents });
}
async openFile(path: string): Promise<void> {
await this.request("openFile", { path });
}
async runCommand(command: string): Promise<void> {
await this.request("runCommand", { command });
}
async saveFile(filepath: string): Promise<void> {
await this.request("saveFile", { filepath });
}
async readFile(filepath: string): Promise<string> {
return await this.request("readFile", { filepath });
}
async showDiff(
filepath: string,
newContents: string,
stepIndex: number,
): Promise<void> {
await this.request("showDiff", { filepath, newContents, stepIndex });
}
getOpenFiles(): Promise<string[]> {
return this.request("getOpenFiles", undefined);
}
getCurrentFile(): Promise<string | undefined> {
return this.request("getCurrentFile", undefined);
}
getPinnedFiles(): Promise<string[]> {
return this.request("getPinnedFiles", undefined);
}
getSearchResults(query: string): Promise<string> {
return this.request("getSearchResults", { query });
}
getProblems(filepath: string): Promise<Problem[]> {
return this.request("getProblems", { filepath });
}
subprocess(command: string): Promise<[string, string]> {
return this.request("subprocess", { command });
}
async getBranch(dir: string): Promise<string> {
return this.request("getBranch", { dir });
}
}