feat: add more next edit endpoints to protocol (#7110)
* feat: add endpoint handlers in core * feat: export interface * feat: update protocol to support more next edit endpoints * feat: add new next edit endpoints to passthrough * feat: support new next edit endpoints to jetbrains
This commit is contained in:
parent
308f685a6e
commit
3606665992
5 changed files with 121 additions and 5 deletions
69
core/core.ts
69
core/core.ts
|
|
@ -76,6 +76,7 @@ import type { FromCoreProtocol, ToCoreProtocol } from "./protocol";
|
|||
import { OnboardingModes } from "./protocol/core";
|
||||
import type { IMessenger, Message } from "./protocol/messenger";
|
||||
import { getUriPathBasename } from "./util/uri";
|
||||
import { PrefetchQueue } from "./nextEdit/NextEditPrefetchQueue";
|
||||
|
||||
const hasRulesFiles = (uris: string[]): boolean => {
|
||||
for (const uri of uris) {
|
||||
|
|
@ -578,18 +579,80 @@ export class Core {
|
|||
// Next Edit
|
||||
on("nextEdit/predict", async (msg) => {
|
||||
const outcome = await this.nextEditProvider.provideInlineCompletionItems(
|
||||
msg.data,
|
||||
msg.data.input,
|
||||
undefined,
|
||||
{ withChain: false, usingFullFileDiff: true },
|
||||
{
|
||||
withChain: msg.data.options?.withChain ?? false,
|
||||
usingFullFileDiff: msg.data.options?.usingFullFileDiff ?? true,
|
||||
},
|
||||
);
|
||||
return outcome ? [outcome.completion, outcome.originalEditableRange] : [];
|
||||
return outcome;
|
||||
// ? [outcome.completion, outcome.originalEditableRange]
|
||||
});
|
||||
on("nextEdit/accept", async (msg) => {
|
||||
console.log("nextEdit/accept");
|
||||
this.nextEditProvider.accept(msg.data.completionId);
|
||||
});
|
||||
on("nextEdit/reject", async (msg) => {
|
||||
console.log("nextEdit/reject");
|
||||
this.nextEditProvider.reject(msg.data.completionId);
|
||||
});
|
||||
on("nextEdit/startChain", async (msg) => {
|
||||
console.log("nextEdit/startChain");
|
||||
NextEditProvider.getInstance().startChain();
|
||||
return;
|
||||
});
|
||||
|
||||
on("nextEdit/deleteChain", async (msg) => {
|
||||
console.log("nextEdit/deleteChain");
|
||||
await NextEditProvider.getInstance().deleteChain();
|
||||
return;
|
||||
});
|
||||
|
||||
on("nextEdit/isChainAlive", async (msg) => {
|
||||
console.log("nextEdit/isChainAlive");
|
||||
return NextEditProvider.getInstance().chainExists();
|
||||
});
|
||||
|
||||
on("nextEdit/queue/getProcessedCount", async (msg) => {
|
||||
console.log("nextEdit/queue/getProcessedCount");
|
||||
const queue = PrefetchQueue.getInstance();
|
||||
console.log(queue.processedCount);
|
||||
return queue.processedCount;
|
||||
});
|
||||
|
||||
on("nextEdit/queue/dequeueProcessed", async (msg) => {
|
||||
console.log("nextEdit/queue/dequeueProcessed");
|
||||
const queue = PrefetchQueue.getInstance();
|
||||
return queue.dequeueProcessed() || null;
|
||||
});
|
||||
|
||||
on("nextEdit/queue/processOne", async (msg) => {
|
||||
console.log("nextEdit/queue/processOne");
|
||||
const { ctx, recentlyVisitedRanges, recentlyEditedRanges } = msg.data;
|
||||
const queue = PrefetchQueue.getInstance();
|
||||
|
||||
await queue.process({
|
||||
...ctx,
|
||||
recentlyVisitedRanges,
|
||||
recentlyEditedRanges,
|
||||
});
|
||||
return;
|
||||
});
|
||||
|
||||
on("nextEdit/queue/clear", async (msg) => {
|
||||
console.log("nextEdit/queue/clear");
|
||||
const queue = PrefetchQueue.getInstance();
|
||||
queue.clear();
|
||||
return;
|
||||
});
|
||||
|
||||
on("nextEdit/queue/abort", async (msg) => {
|
||||
console.log("nextEdit/queue/abort");
|
||||
const queue = PrefetchQueue.getInstance();
|
||||
queue.abort();
|
||||
return;
|
||||
});
|
||||
|
||||
on("streamDiffLines", async (msg) => {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { RangeInFile } from "..";
|
|||
import { NextEditProvider } from "./NextEditProvider";
|
||||
import { NextEditOutcome } from "./types";
|
||||
|
||||
interface ProcessedItem {
|
||||
export interface ProcessedItem {
|
||||
location: RangeInFile;
|
||||
outcome: NextEditOutcome; // Result from the model
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ import {
|
|||
ControlPlaneSessionInfo,
|
||||
} from "../control-plane/AuthTypes";
|
||||
import { FreeTrialStatus } from "../control-plane/client";
|
||||
import { NextEditOutcome } from "../nextEdit/types";
|
||||
import { ProcessedItem } from "../nextEdit/NextEditPrefetchQueue";
|
||||
|
||||
export enum OnboardingModes {
|
||||
API_KEY = "API Key",
|
||||
|
|
@ -153,9 +155,44 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
"context/indexDocs": [{ reIndex: boolean }, void];
|
||||
"autocomplete/cancel": [undefined, void];
|
||||
"autocomplete/accept": [{ completionId: string }, void];
|
||||
"nextEdit/predict": [AutocompleteInput, string[]];
|
||||
"nextEdit/predict": [
|
||||
{
|
||||
input: AutocompleteInput;
|
||||
options?: {
|
||||
withChain?: boolean;
|
||||
usingFullFileDiff?: boolean;
|
||||
};
|
||||
},
|
||||
NextEditOutcome | undefined,
|
||||
];
|
||||
"nextEdit/reject": [{ completionId: string }, void];
|
||||
"nextEdit/accept": [{ completionId: string }, void];
|
||||
"nextEdit/startChain": [undefined, void];
|
||||
"nextEdit/deleteChain": [undefined, void];
|
||||
"nextEdit/isChainAlive": [undefined, boolean];
|
||||
"nextEdit/queue/getProcessedCount": [undefined, number];
|
||||
"nextEdit/queue/dequeueProcessed": [undefined, ProcessedItem | null];
|
||||
"nextEdit/queue/processOne": [
|
||||
{
|
||||
ctx: {
|
||||
completionId: string;
|
||||
manuallyPassFileContents?: string;
|
||||
manuallyPassPrefix?: string;
|
||||
selectedCompletionInfo?: {
|
||||
text: string;
|
||||
range: Range;
|
||||
};
|
||||
isUntitledFile: boolean;
|
||||
recentlyVisitedRanges: AutocompleteCodeSnippet[];
|
||||
recentlyEditedRanges: RecentlyEditedRange[];
|
||||
};
|
||||
recentlyVisitedRanges: AutocompleteCodeSnippet[];
|
||||
recentlyEditedRanges: RecentlyEditedRange[];
|
||||
},
|
||||
void,
|
||||
];
|
||||
"nextEdit/queue/clear": [undefined, void];
|
||||
"nextEdit/queue/abort": [undefined, void];
|
||||
"llm/complete": [
|
||||
{
|
||||
prompt: string;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,14 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"nextEdit/predict",
|
||||
"nextEdit/reject",
|
||||
"nextEdit/accept",
|
||||
"nextEdit/startChain",
|
||||
"nextEdit/deleteChain",
|
||||
"nextEdit/isChainAlive",
|
||||
"nextEdit/queue/getProcessedCount",
|
||||
"nextEdit/queue/dequeueProcessed",
|
||||
"nextEdit/queue/processOne",
|
||||
"nextEdit/queue/clear",
|
||||
"nextEdit/queue/abort",
|
||||
"tts/kill",
|
||||
"llm/complete",
|
||||
"llm/streamChat",
|
||||
|
|
|
|||
|
|
@ -105,6 +105,14 @@ class MessageTypes {
|
|||
"nextEdit/predict",
|
||||
"nextEdit/reject",
|
||||
"nextEdit/accept",
|
||||
"nextEdit/startChain",
|
||||
"nextEdit/deleteChain",
|
||||
"nextEdit/isChainAlive",
|
||||
"nextEdit/queue/getProcessedCount",
|
||||
"nextEdit/queue/dequeueProcessed",
|
||||
"nextEdit/queue/processOne",
|
||||
"nextEdit/queue/clear",
|
||||
"nextEdit/queue/abort",
|
||||
"tts/kill",
|
||||
"llm/complete",
|
||||
"llm/streamChat",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue