From 79c9b0d0f4e3cfcacc79af804b5049b09f40d52b Mon Sep 17 00:00:00 2001
From: uinstinct <61635505+uinstinct@users.noreply.github.com>
Date: Mon, 7 Jul 2025 19:37:40 +0530
Subject: [PATCH 001/244] improve: show notification for unsupported platform
---
extensions/vscode/src/activation/activate.ts | 30 +++++++++++++-
extensions/vscode/src/util/util.ts | 41 +++++++++++++++++++-
2 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts
index 21f7fcb3f..3fc5aa24b 100644
--- a/extensions/vscode/src/activation/activate.ts
+++ b/extensions/vscode/src/activation/activate.ts
@@ -6,12 +6,40 @@ import * as vscode from "vscode";
import { VsCodeExtension } from "../extension/VsCodeExtension";
import registerQuickFixProvider from "../lang-server/codeActions";
-import { getExtensionVersion } from "../util/util";
+import {
+ getArchitecture,
+ getExtensionVersion,
+ getPlatform,
+ isUnsupportedPlatform,
+} from "../util/util";
import { VsCodeContinueApi } from "./api";
import setupInlineTips from "./InlineTipManager";
export async function activateExtension(context: vscode.ExtensionContext) {
+ const platformCheck = isUnsupportedPlatform();
+ if (platformCheck.isUnsupported) {
+ const platformTarget = `${getPlatform()}-${getArchitecture()}`;
+ void vscode.window.showErrorMessage(
+ `Continue extension cannot activate on ${platformTarget}: ${platformCheck.reason}`,
+ );
+ const error = new Error(
+ `Continue extension cannot activate on ${platformTarget}: ${platformCheck.reason}`,
+ );
+
+ void Telemetry.capture(
+ "unsupported_platform_activation_attempt",
+ {
+ platform: platformTarget,
+ extensionVersion: getExtensionVersion(),
+ reason: platformCheck.reason,
+ },
+ true,
+ );
+
+ throw error;
+ }
+
// Add necessary files
getTsConfigPath();
getContinueRcPath();
diff --git a/extensions/vscode/src/util/util.ts b/extensions/vscode/src/util/util.ts
index a7c125ff1..949843fc4 100644
--- a/extensions/vscode/src/util/util.ts
+++ b/extensions/vscode/src/util/util.ts
@@ -1,6 +1,6 @@
-import * as vscode from "vscode";
+import * as os from "node:os";
-const os = require("node:os");
+import * as vscode from "vscode";
function charIsEscapedAtIndex(index: number, str: string): boolean {
if (index === 0) {
@@ -70,6 +70,7 @@ export function debounced(delay: number, fn: (...args: any[]) => void) {
}
type Platform = "mac" | "linux" | "windows" | "unknown";
+type Architecture = "x64" | "arm64" | "unknown";
export function getPlatform(): Platform {
const platform = os.platform();
@@ -84,6 +85,42 @@ export function getPlatform(): Platform {
}
}
+export function getArchitecture(): Architecture {
+ const arch = os.arch();
+ if (arch === "x64" || arch === "ia32") {
+ return "x64";
+ } else if (arch === "arm64" || arch === "arm") {
+ return "arm64";
+ } else {
+ return "unknown";
+ }
+}
+
+export function isUnsupportedPlatform(): {
+ isUnsupported: boolean;
+ reason?: string;
+} {
+ const platform = getPlatform();
+ const arch = getArchitecture();
+
+ if (platform === "mac" && arch === "arm64") {
+ return {
+ isUnsupported: true,
+ reason:
+ "Windows ARM64 is not currently supported due to missing native dependencies (sqlite3, onnxruntime). Please use the extension on Windows x64, macOS, or Linux instead.",
+ };
+ }
+
+ if (platform === "unknown" || arch === "unknown") {
+ return {
+ isUnsupported: true,
+ reason: `Unsupported platform combination: ${os.platform()}-${os.arch()}. Continue extension supports Windows x64, macOS (Intel/Apple Silicon), and Linux (x64/ARM64).`,
+ };
+ }
+
+ return { isUnsupported: false };
+}
+
export function getAltOrOption() {
if (getPlatform() === "mac") {
return "⌥";
From 01cd8f37ecaaba0d3a1303eadb38af996d03633e Mon Sep 17 00:00:00 2001
From: uinstinct <61635505+uinstinct@users.noreply.github.com>
Date: Mon, 7 Jul 2025 19:39:58 +0530
Subject: [PATCH 002/244] correction
---
extensions/vscode/src/util/util.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/extensions/vscode/src/util/util.ts b/extensions/vscode/src/util/util.ts
index 949843fc4..00316abc5 100644
--- a/extensions/vscode/src/util/util.ts
+++ b/extensions/vscode/src/util/util.ts
@@ -103,7 +103,7 @@ export function isUnsupportedPlatform(): {
const platform = getPlatform();
const arch = getArchitecture();
- if (platform === "mac" && arch === "arm64") {
+ if (platform === "windows" && arch === "arm64") {
return {
isUnsupported: true,
reason:
From 0e851394960e0455588c0d1bbe11214f5462f83d Mon Sep 17 00:00:00 2001
From: uinstinct <61635505+uinstinct@users.noreply.github.com>
Date: Thu, 10 Jul 2025 16:02:04 +0530
Subject: [PATCH 003/244] add tests
---
extensions/vscode/src/util/util.vitest.ts | 61 +++++++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100644 extensions/vscode/src/util/util.vitest.ts
diff --git a/extensions/vscode/src/util/util.vitest.ts b/extensions/vscode/src/util/util.vitest.ts
new file mode 100644
index 000000000..1187e1d3c
--- /dev/null
+++ b/extensions/vscode/src/util/util.vitest.ts
@@ -0,0 +1,61 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+describe("isUnsupportedPlatform", () => {
+ afterEach(() => {
+ vi.resetAllMocks();
+ });
+
+ it("should be true when os is winarm64", async () => {
+ vi.doMock("os", () => ({
+ platform: vi.fn().mockReturnValue("win32"),
+ arch: vi.fn().mockReturnValue("arm64"),
+ }));
+
+ // "vscode" import should only be mocked during runtime
+ vi.doMock("vscode", () => ({}));
+
+ // import after mocks are done
+ const { isUnsupportedPlatform } = await import("./util");
+
+ const platformCheck = isUnsupportedPlatform();
+
+ expect(platformCheck.isUnsupported).toBe(true);
+ expect(platformCheck.reason).toMatch(/windows/gi);
+ expect(platformCheck.reason).toMatch(/arm64/gi);
+ });
+
+ it("should be true when os is unsupported", async () => {
+ vi.doMock("os", () => ({
+ platform: vi.fn().mockReturnValue("bsd"),
+ arch: vi.fn().mockReturnValue("x64"),
+ }));
+
+ // "vscode" import should only be mocked during runtime
+ vi.doMock("vscode", () => ({}));
+
+ // import after mocks are done
+ const { isUnsupportedPlatform } = await import("./util");
+
+ const platformCheck = isUnsupportedPlatform();
+
+ expect(platformCheck.isUnsupported).toBe(true);
+ expect(platformCheck.reason).toMatch(/unsupported/gi);
+ });
+
+ it("should not be true when os is supported", async () => {
+ vi.doMock("os", () => ({
+ platform: vi.fn().mockReturnValue("linux"),
+ arch: vi.fn().mockReturnValue("arm64"),
+ }));
+
+ // "vscode" import should only be mocked during runtime
+ vi.doMock("vscode", () => ({}));
+
+ // import after mocks are done
+ const { isUnsupportedPlatform } = await import("./util");
+
+ const platformCheck = isUnsupportedPlatform();
+
+ expect(platformCheck.isUnsupported).toBe(true);
+ });
+});
From 34dc6857f031300ee765edd24f252975d6799465 Mon Sep 17 00:00:00 2001
From: Nate
Date: Thu, 10 Jul 2025 11:24:00 -0700
Subject: [PATCH 004/244] Add retry logic with exponential backoff to
listOrganizations for user account creation delay
---
core/control-plane/client.ts | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts
index a1fe22099..6deca88b4 100644
--- a/core/control-plane/client.ts
+++ b/core/control-plane/client.ts
@@ -135,14 +135,33 @@ export class ControlPlaneClient {
return [];
}
- try {
- const resp = await this.request("ide/list-organizations", {
- method: "GET",
- });
- const { organizations } = (await resp.json()) as any;
- return organizations;
- } catch (e) {
- return [];
+ // We try again here because when users sign up with an email domain that is
+ // captured by an org, we need to wait for the user account creation webhook to
+ // take effect. Otherwise the organization(s) won't show up.
+ let retries = 0;
+ const maxRetries = 5;
+ const maxWaitTime = 20000; // 20 seconds in milliseconds
+
+ while (true) {
+ try {
+ const resp = await this.request("ide/list-organizations", {
+ method: "GET",
+ });
+ const { organizations } = (await resp.json()) as any;
+ return organizations;
+ } catch (error: any) {
+ if (error?.message?.includes("404") && retries < maxRetries) {
+ retries++;
+ const waitTime = Math.min(
+ Math.pow(2, retries) * 100,
+ maxWaitTime / maxRetries,
+ );
+ await new Promise((resolve) => setTimeout(resolve, waitTime));
+ } else {
+ // If not a 404 error or we've exceeded max retries, rethrow
+ throw error;
+ }
+ }
}
}
From b8175ffe426a870b4e3ec69f6fcaafe64faa54f2 Mon Sep 17 00:00:00 2001
From: uinstinct <61635505+uinstinct@users.noreply.github.com>
Date: Fri, 11 Jul 2025 10:35:02 +0530
Subject: [PATCH 005/244] show info instead of throwing error
---
extensions/vscode/src/activation/activate.ts | 22 +++++++-------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts
index 3fc5aa24b..40ae55235 100644
--- a/extensions/vscode/src/activation/activate.ts
+++ b/extensions/vscode/src/activation/activate.ts
@@ -6,25 +6,19 @@ import * as vscode from "vscode";
import { VsCodeExtension } from "../extension/VsCodeExtension";
import registerQuickFixProvider from "../lang-server/codeActions";
-import {
- getArchitecture,
- getExtensionVersion,
- getPlatform,
- isUnsupportedPlatform,
-} from "../util/util";
+import { getExtensionVersion, isUnsupportedPlatform } from "../util/util";
import { VsCodeContinueApi } from "./api";
import setupInlineTips from "./InlineTipManager";
export async function activateExtension(context: vscode.ExtensionContext) {
const platformCheck = isUnsupportedPlatform();
- if (platformCheck.isUnsupported) {
- const platformTarget = `${getPlatform()}-${getArchitecture()}`;
- void vscode.window.showErrorMessage(
- `Continue extension cannot activate on ${platformTarget}: ${platformCheck.reason}`,
- );
- const error = new Error(
- `Continue extension cannot activate on ${platformTarget}: ${platformCheck.reason}`,
+ if (!platformCheck.isUnsupported) {
+ // const platformTarget = `${getPlatform()}-${getArchitecture()}`;
+ const platformTarget = "windows-arm64";
+
+ void vscode.window.showInformationMessage(
+ `Continue detected that you are using ${platformTarget}. Due to native dependencies, Continue may not be able to start`,
);
void Telemetry.capture(
@@ -36,8 +30,6 @@ export async function activateExtension(context: vscode.ExtensionContext) {
},
true,
);
-
- throw error;
}
// Add necessary files
From 92cd0cc31bc864ef96f58f383621a2a76b64fa8f Mon Sep 17 00:00:00 2001
From: Nate
Date: Mon, 14 Jul 2025 10:47:48 -0700
Subject: [PATCH 006/244] check status code
---
core/control-plane/client.ts | 55 +++++++++++++++++++++---------------
1 file changed, 32 insertions(+), 23 deletions(-)
diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts
index 6deca88b4..63c140bcc 100644
--- a/core/control-plane/client.ts
+++ b/core/control-plane/client.ts
@@ -57,7 +57,7 @@ export class ControlPlaneClient {
}));
}
- const resp = await this.request("ide/sync-secrets", {
+ const resp = await this.requestAndHandleError("ide/sync-secrets", {
method: "POST",
body: JSON.stringify({ fqsns, orgScopeId }),
});
@@ -94,6 +94,15 @@ export class ControlPlaneClient {
},
});
+ return resp;
+ }
+
+ private async requestAndHandleError(
+ path: string,
+ init: RequestInit,
+ ): Promise {
+ const resp = await this.request(path, init);
+
if (!resp.ok) {
throw new Error(
`Control plane request failed: ${resp.status} ${await resp.text()}`,
@@ -121,7 +130,7 @@ export class ControlPlaneClient {
? `ide/list-assistants?organizationId=${organizationId}`
: "ide/list-assistants";
- const resp = await this.request(url, {
+ const resp = await this.requestAndHandleError(url, {
method: "GET",
});
return (await resp.json()) as any;
@@ -138,30 +147,30 @@ export class ControlPlaneClient {
// We try again here because when users sign up with an email domain that is
// captured by an org, we need to wait for the user account creation webhook to
// take effect. Otherwise the organization(s) won't show up.
+ // This error manifests as a 404 (user not found)
let retries = 0;
const maxRetries = 5;
const maxWaitTime = 20000; // 20 seconds in milliseconds
while (true) {
- try {
- const resp = await this.request("ide/list-organizations", {
- method: "GET",
- });
- const { organizations } = (await resp.json()) as any;
- return organizations;
- } catch (error: any) {
- if (error?.message?.includes("404") && retries < maxRetries) {
- retries++;
- const waitTime = Math.min(
- Math.pow(2, retries) * 100,
- maxWaitTime / maxRetries,
- );
- await new Promise((resolve) => setTimeout(resolve, waitTime));
- } else {
- // If not a 404 error or we've exceeded max retries, rethrow
- throw error;
- }
+ const resp = await this.request("ide/list-organizations", {
+ method: "GET",
+ });
+
+ if (resp.status === 404) {
+ retries++;
+ const waitTime = Math.min(
+ Math.pow(2, retries) * 100,
+ maxWaitTime / maxRetries,
+ );
+ await new Promise((resolve) => setTimeout(resolve, waitTime));
+ } else if (!resp.ok) {
+ throw new Error(
+ `Failed to list organizations (${resp.status}): ${await resp.text()}`,
+ );
}
+ const { organizations } = (await resp.json()) as any;
+ return organizations;
}
}
@@ -177,7 +186,7 @@ export class ControlPlaneClient {
: "ide/list-assistant-full-slugs";
try {
- const resp = await this.request(url, {
+ const resp = await this.requestAndHandleError(url, {
method: "GET",
});
const { fullSlugs } = (await resp.json()) as any;
@@ -193,7 +202,7 @@ export class ControlPlaneClient {
}
try {
- const resp = await this.request("ide/free-trial-status", {
+ const resp = await this.requestAndHandleError("ide/free-trial-status", {
method: "GET",
});
return (await resp.json()) as FreeTrialStatus;
@@ -224,7 +233,7 @@ export class ControlPlaneClient {
params.set("vscode_uri_scheme", vsCodeUriScheme);
}
- const resp = await this.request(
+ const resp = await this.requestAndHandleError(
`ide/get-models-add-on-checkout-url?${params.toString()}`,
{
method: "GET",
From 907c576947fbe26b61410db0a5eb46dd907c75c3 Mon Sep 17 00:00:00 2001
From: Nate
Date: Mon, 14 Jul 2025 10:49:26 -0700
Subject: [PATCH 007/244] fix: continue through loop and return [] instead of
throwing
---
core/control-plane/client.ts | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts
index 63c140bcc..2287fb8c6 100644
--- a/core/control-plane/client.ts
+++ b/core/control-plane/client.ts
@@ -164,10 +164,12 @@ export class ControlPlaneClient {
maxWaitTime / maxRetries,
);
await new Promise((resolve) => setTimeout(resolve, waitTime));
+ continue;
} else if (!resp.ok) {
- throw new Error(
+ console.warn(
`Failed to list organizations (${resp.status}): ${await resp.text()}`,
);
+ return [];
}
const { organizations } = (await resp.json()) as any;
return organizations;
From ec910c7047755c2ffa004b5f855f313be955088a Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 14 Jul 2025 16:41:13 -0700
Subject: [PATCH 008/244] feat: add getReferences
---
core/config/types.ts | 1 +
core/index.d.ts | 1 +
core/protocol/ide.ts | 1 +
core/protocol/messenger/messageIde.ts | 4 ++++
core/util/filesystem.ts | 4 ++++
.../continueintellijextension/continue/IntelliJIde.kt | 6 +++++-
.../continuedev/continueintellijextension/types.kt | 3 ++-
extensions/vscode/src/VsCodeIde.ts | 11 +++++++++++
extensions/vscode/src/extension/VsCodeMessenger.ts | 4 ++++
9 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/core/config/types.ts b/core/config/types.ts
index 406f40ddd..25ae3247a 100644
--- a/core/config/types.ts
+++ b/core/config/types.ts
@@ -745,6 +745,7 @@ declare global {
// LSP
gotoDefinition(location: Location): Promise;
+ getReferences(location: Location): Promise;
// Callbacks
onDidChangeActiveTextEditor(callback: (filepath: string) => void): void;
diff --git a/core/index.d.ts b/core/index.d.ts
index e211c824e..8c7b2c1a6 100644
--- a/core/index.d.ts
+++ b/core/index.d.ts
@@ -836,6 +836,7 @@ export interface IDE {
// LSP
gotoDefinition(location: Location): Promise;
+ getReferences(location: Location): Promise;
// Callbacks
onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void;
diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts
index ba4cf4f88..ed108ba9b 100644
--- a/core/protocol/ide.ts
+++ b/core/protocol/ide.ts
@@ -82,6 +82,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
getFileStats: [{ files: string[] }, FileStatsMap];
gotoDefinition: [{ location: Location }, RangeInFile[]];
+ getReferences: [{ location: Location }, RangeInFile[]];
getControlPlaneSessionInfo: [
{ silent: boolean; useOnboarding: boolean },
diff --git a/core/protocol/messenger/messageIde.ts b/core/protocol/messenger/messageIde.ts
index 30d9b8177..de1ed3ecc 100644
--- a/core/protocol/messenger/messageIde.ts
+++ b/core/protocol/messenger/messageIde.ts
@@ -45,6 +45,10 @@ export class MessageIde implements IDE {
return this.request("gotoDefinition", { location });
}
+ async getReferences(location: Location): Promise {
+ return this.request("getReferences", { location });
+ }
+
onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void {
this.on("didChangeActiveTextEditor", (data) => callback(data.filepath));
}
diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts
index f415e5e86..254bbe28a 100644
--- a/core/util/filesystem.ts
+++ b/core/util/filesystem.ts
@@ -44,6 +44,10 @@ class FileSystemIde implements IDE {
return Promise.resolve([]);
}
+ getReferences(location: Location): Promise {
+ return Promise.resolve([]);
+ }
+
onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void {
return;
}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt
index 2dfc3e3e1..1ce14b3fd 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt
@@ -592,6 +592,10 @@ class IntelliJIDE(
throw NotImplementedError("gotoDefinition not implemented yet")
}
+ override suspend fun getReferences(location: Location): List {
+ throw NotImplementedError("getReferences not implemented yet")
+ }
+
override fun onDidChangeActiveTextEditor(callback: (filepath: String) -> Unit) {
throw NotImplementedError("onDidChangeActiveTextEditor not implemented yet")
}
@@ -622,4 +626,4 @@ class IntelliJIDE(
return listOfNotNull(project.guessProjectDir()?.toUriOrNull()).toTypedArray()
}
-}
\ No newline at end of file
+}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt
index 5ff9e9454..4e6c6c771 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt
@@ -191,6 +191,7 @@ interface IDE {
// LSP
suspend fun gotoDefinition(location: Location): List
+ suspend fun getReferences(location: Location): List
// Callbacks
fun onDidChangeActiveTextEditor(callback: (filepath: String) -> Unit)
@@ -247,4 +248,4 @@ data class AcceptOrRejectDiffPayload(
data class ShowFilePayload(
val filepath: String
-)
\ No newline at end of file
+)
diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts
index 91fb6154b..97c48f174 100644
--- a/extensions/vscode/src/VsCodeIde.ts
+++ b/extensions/vscode/src/VsCodeIde.ts
@@ -86,6 +86,17 @@ class VsCodeIde implements IDE {
return result;
}
+ async getReferences(location: Location): Promise {
+ const result = await executeGotoProvider({
+ uri: vscode.Uri.parse(location.filepath),
+ line: location.position.line,
+ character: location.position.character,
+ name: "vscode.executeReferenceProvider",
+ });
+
+ return result;
+ }
+
onDidChangeActiveTextEditor(callback: (uri: string) => void): void {
vscode.window.onDidChangeActiveTextEditor((editor) => {
if (editor) {
diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts
index 430c4fff1..7f9158da5 100644
--- a/extensions/vscode/src/extension/VsCodeMessenger.ts
+++ b/extensions/vscode/src/extension/VsCodeMessenger.ts
@@ -390,6 +390,10 @@ export class VsCodeMessenger {
return await ide.gotoDefinition(msg.data.location);
});
+ this.onWebviewOrCore("getReferences", async (msg) => {
+ return await ide.getReferences(msg.data.location);
+ });
+
this.onWebviewOrCore("getFileStats", async (msg) => {
return await ide.getFileStats(msg.data.files);
});
From 1f8d667bf861894ffd7458244334861ac88b19bf Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 15 Jul 2025 17:43:38 -0700
Subject: [PATCH 009/244] feat: create prefetch queue data structure
---
core/util/PrefetchQueue.ts | 90 ++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
create mode 100644 core/util/PrefetchQueue.ts
diff --git a/core/util/PrefetchQueue.ts b/core/util/PrefetchQueue.ts
new file mode 100644
index 000000000..36b55ff10
--- /dev/null
+++ b/core/util/PrefetchQueue.ts
@@ -0,0 +1,90 @@
+import { NextEditProvider } from "../nextEdit/NextEditProvider";
+
+export class PrefetchQueue {
+ private currentPromise: Promise | null = null;
+ private nextPromise: Promise | null = null;
+ private resourceQueue: R[];
+ private other: O | undefined;
+ private fetchFunction: (
+ previousData: T | undefined,
+ resource: R | undefined,
+ other: O | undefined,
+ ) => Promise;
+
+ constructor(
+ fetchFunction: (
+ previousData: T | undefined,
+ resource: R | undefined,
+ other: O | undefined,
+ ) => Promise,
+ resources: R[],
+ other: O | undefined,
+ ) {
+ this.fetchFunction = fetchFunction;
+ this.resourceQueue = [...resources];
+ this.other = other;
+ }
+
+ loadResource(resources: R[]) {
+ // if (this.resourceQueue.length > 0) {
+ // throw new Error("Queue already initialized");
+ // }
+ this.resourceQueue = [...this.resourceQueue, ...resources];
+ }
+
+ loadOther(other: O) {
+ this.other = other;
+ }
+
+ async initialize(): Promise {
+ // Get the first response (no resource needed).
+ this.currentPromise = this.fetchFunction(undefined, undefined, this.other);
+ const firstData = await this.currentPromise;
+ // TODO: cleanse editable_region_start and trailing newline.
+
+ // Create the next promise based on the first response and first resource.
+ // if (this.resourceQueue.length > 0) {
+ const resource = this.resourceQueue.shift()!;
+ this.nextPromise = this.fetchFunction(firstData, resource, this.other);
+ // }
+ }
+
+ async pop(): Promise {
+ if (!this.currentPromise) {
+ // throw new Error("Queue not initialized");
+ return undefined;
+ }
+
+ const currentData = await this.currentPromise;
+
+ // Move next promise to current (if it exists).
+ if (this.nextPromise) {
+ this.currentPromise = this.nextPromise;
+
+ // Create new next promise if we have resources left.
+ const resource = this.resourceQueue.shift()!;
+ this.nextPromise = this.currentPromise.then((data) =>
+ this.fetchFunction(data, resource, this.other),
+ );
+ // if (this.resourceQueue.length > 0) {
+ // } else {
+ // this.nextPromise = null;
+ // }
+ } else {
+ NextEditProvider.currentEditChainId = null;
+ // throw new Error("No more items in queue");
+ return undefined;
+ }
+
+ console.log("currentData:", currentData);
+ return currentData;
+ }
+
+ hasNext(): boolean {
+ return this.nextPromise !== null;
+ }
+
+ getRemainingResourceCount(): number {
+ return this.resourceQueue.length;
+ }
+}
From e3b61b989022642297b25698d93c4d2867cef756 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 15 Jul 2025 17:44:03 -0700
Subject: [PATCH 010/244] refactor: factor out final cursor position
calculation
---
core/nextEdit/diff/diff.ts | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/core/nextEdit/diff/diff.ts b/core/nextEdit/diff/diff.ts
index bca4a6d08..b89d638a4 100644
--- a/core/nextEdit/diff/diff.ts
+++ b/core/nextEdit/diff/diff.ts
@@ -1,4 +1,6 @@
+import { Position } from "shiki";
import { DiffLine } from "../..";
+import { myersDiff } from "../../diff/myers";
/**
* Given a diff of two editable regions, get the offset position at the last new line inside the editable region.
@@ -192,3 +194,34 @@ export function checkFim(
return { isFim, fimText: null };
}
}
+
+export function calculateFinalCursorPosition(
+ currCursorPos: Position,
+ editableRegionStartLine: number,
+ oldEditRangeSlice: string,
+ newEditRangeSlice: string,
+) {
+ // How far away is the current line from the start of the editable region?
+ const lineOffsetAtCursorPos = currCursorPos.line - editableRegionStartLine;
+
+ // How long is the line at the current cursor position?
+ const lineContentAtCursorPos =
+ newEditRangeSlice.split("\n")[lineOffsetAtCursorPos];
+
+ const diffLines = myersDiff(oldEditRangeSlice, newEditRangeSlice);
+
+ const offset = getOffsetPositionAtLastNewLine(
+ diffLines,
+ lineContentAtCursorPos,
+ lineOffsetAtCursorPos,
+ );
+
+ // Calculate the actual line number in the editor by adding the startPos offset
+ // to the line number from the diff calculation.
+ const finalCursorPos: Position = {
+ line: editableRegionStartLine + offset.line,
+ character: offset.character,
+ };
+
+ return finalCursorPos;
+}
From 263e340d07be4a9591ce78ab443b97bc2834120d Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 15 Jul 2025 17:44:31 -0700
Subject: [PATCH 011/244] feat: extend NextEditOutcome type to include final
cursor position and the editable region start and end lines
---
core/nextEdit/types.ts | 3 +++
1 file changed, 3 insertions(+)
diff --git a/core/nextEdit/types.ts b/core/nextEdit/types.ts
index 0837c5494..26e2b156a 100644
--- a/core/nextEdit/types.ts
+++ b/core/nextEdit/types.ts
@@ -53,7 +53,10 @@ export interface NextEditOutcome extends TabAutocompleteOptions {
originalEditableRange: string;
completion: string;
cursorPosition: { line: number; character: number };
+ finalCursorPosition: { line: number; character: number };
accepted?: boolean;
+ editableRegionStartLine: number;
+ editableRegionEndLine: number;
}
export interface PromptMetadata {
From 90cdcafee2ce8ff034846ed70a94667d789ce579 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 15 Jul 2025 17:44:56 -0700
Subject: [PATCH 012/244] feat: use prefetch queue to prefetch inference
results
---
core/nextEdit/NextEditProvider.ts | 253 +++++++++++++++++-
.../templating/NextEditPromptEngine.ts | 59 +++-
2 files changed, 306 insertions(+), 6 deletions(-)
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index fba86df33..9ae8a635e 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -1,11 +1,12 @@
import * as path from "path";
import { ConfigHandler } from "../config/ConfigHandler.js";
-import { ChatMessage, IDE, ILLM } from "../index.js";
+import { ChatMessage, IDE, ILLM, Position, RangeInFile } from "../index.js";
import OpenAI from "../llm/llms/OpenAI.js";
import { DEFAULT_AUTOCOMPLETE_OPTS } from "../util/parameters.js";
import { ContextRetrievalService } from "../autocomplete/context/ContextRetrievalService.js";
+import { randomUUID } from "crypto";
import { BracketMatchingService } from "../autocomplete/filtering/BracketMatchingService.js";
import { CompletionStreamer } from "../autocomplete/generation/CompletionStreamer.js";
import { shouldPrefilter } from "../autocomplete/prefiltering/index.js";
@@ -15,11 +16,17 @@ import { AutocompleteDebouncer } from "../autocomplete/util/AutocompleteDebounce
import AutocompleteLruCache from "../autocomplete/util/AutocompleteLruCache.js";
import { HelperVars } from "../autocomplete/util/HelperVars.js";
import { AutocompleteInput } from "../autocomplete/util/types.js";
+import { myersDiff } from "../diff/myers.js";
+import { PrefetchQueue } from "../util/PrefetchQueue.js";
import { replaceEscapedCharacters } from "../util/text.js";
import {
NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
} from "./constants.js";
+import {
+ calculateFinalCursorPosition,
+ getOffsetPositionAtLastNewLine,
+} from "./diff/diff.js";
import { NextEditLoggingService } from "./NextEditLoggingService.js";
import {
renderDefaultSystemPrompt,
@@ -52,6 +59,21 @@ export class NextEditProvider {
private endpointType: "default" | "fineTuned";
private diffContext: string = "";
private promptMetadata: PromptMetadata | null = null;
+ private prefetchQueue: PrefetchQueue<
+ NextEditOutcome,
+ RangeInFile,
+ {
+ helper: HelperVars;
+ diffContext: string;
+ llm: ILLM;
+ token: AbortSignal;
+ startTime: number;
+ newCursorPos: Position;
+ }
+ >;
+ // private refQueue: RangeInFile[] = [];
+ // TODO: This needs to be cleared globally on cancel.
+ public static currentEditChainId: string | null = null;
private constructor(
private readonly configHandler: ConfigHandler,
@@ -65,6 +87,121 @@ export class NextEditProvider {
this.contextRetrievalService = new ContextRetrievalService(this.ide);
this.endpointType = endpointType;
this.loggingService = NextEditLoggingService.getInstance();
+
+ const fetchFunction = async (
+ previousData: NextEditOutcome | undefined,
+ resource: RangeInFile | undefined,
+ other?: {
+ helper: HelperVars;
+ diffContext: string;
+ llm: ILLM;
+ token: AbortSignal;
+ startTime: number;
+ newCursorPos: Position;
+ },
+ ) => {
+ if (!other) return undefined;
+ // render prompt
+ // TODO: this has to set the editable region properly.
+ console.log("fetchfunction - previousData:", previousData?.completion);
+ const promptMetadata = renderPrompt(
+ other.helper,
+ other.diffContext,
+ previousData,
+ resource,
+ );
+ this.promptMetadata = promptMetadata;
+ // call llm.chat
+ const msg = await other.llm.chat([promptMetadata.prompt], other.token);
+ // built and return outcome
+ if (typeof msg.content === "string") {
+ if (msg.content === "") return undefined;
+ // TODO: There are cases where msg.conetnt.split("<|start|>")[1] is undefined
+ const nextCompletion = replaceEscapedCharacters(
+ msg.content.split("<|editable_region_start|>\n")[1],
+ ).replace(/\n$/, "");
+
+ const currCursorPos = other.helper.pos;
+ const editableRegionStartLine = Math.max(
+ currCursorPos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
+ 0,
+ );
+ const editableRegionEndLine = Math.min(
+ currCursorPos.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
+ other.helper.fileLines.length - 1,
+ );
+ const oldEditRangeSlice = other.helper.fileContents
+ .split("\n")
+ .slice(editableRegionStartLine, editableRegionEndLine + 1)
+ .join("\n");
+
+ // How far away is the current line from the start of the editable region?
+ const lineOffsetAtCursorPos =
+ currCursorPos.line - editableRegionStartLine;
+
+ // How long is the line at the current cursor position?
+ const newEditRangeSlice = nextCompletion;
+ const lineContentAtCursorPos =
+ newEditRangeSlice.split("\n")[lineOffsetAtCursorPos];
+
+ const diffLines = myersDiff(oldEditRangeSlice, newEditRangeSlice);
+
+ const offset = getOffsetPositionAtLastNewLine(
+ diffLines,
+ lineContentAtCursorPos,
+ lineOffsetAtCursorPos,
+ );
+
+ // Calculate the actual line number in the editor by adding the startPos offset
+ // to the line number from the diff calculation.
+ const finalCursorPos: Position = {
+ line: editableRegionStartLine + offset.line,
+ character: offset.character,
+ };
+
+ const outcomeNext: NextEditOutcome = {
+ elapsed: Date.now() - other.startTime,
+ modelProvider: other.llm.underlyingProviderName,
+ modelName: other.llm.model + ":zetaDataset",
+ completionOptions: null,
+ // filepath: helper.filepath,
+ completionId: other.helper.input.completionId,
+ gitRepo: await this.ide.getRepoName(other.helper.filepath),
+ uniqueId: await this.ide.getUniqueId(),
+ timestamp: Date.now(),
+ fileUri: other.helper.filepath,
+ workspaceDirUri:
+ other.helper.workspaceUris[0] ??
+ path.dirname(other.helper.filepath),
+ prompt: this.promptMetadata!.prompt.content,
+ userEdits: this.promptMetadata!.userEdits,
+ userExcerpts: this.promptMetadata!.userExcerpts,
+ originalEditableRange: oldEditRangeSlice,
+ completion: nextCompletion,
+ cursorPosition: other.helper.pos,
+ finalCursorPosition: finalCursorPos,
+ editableRegionStartLine,
+ editableRegionEndLine,
+ ...other.helper.options,
+ };
+ return outcomeNext;
+ } else {
+ return undefined;
+ }
+ };
+
+ this.prefetchQueue = new PrefetchQueue<
+ NextEditOutcome,
+ RangeInFile,
+ {
+ helper: HelperVars;
+ diffContext: string;
+ llm: ILLM;
+ token: AbortSignal;
+ startTime: number;
+ newCursorPos: Position;
+ }
+ >(fetchFunction, [], undefined);
}
public static initialize(
@@ -247,6 +384,26 @@ export class NextEditProvider {
prompts.push(promptMetadata.prompt);
}
+ const editableRegionStartLine = Math.max(
+ helper.pos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
+ 0,
+ );
+ const editableRegionEndLine = Math.min(
+ helper.pos.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
+ helper.fileLines.length - 1,
+ );
+ const oldEditRangeSlice = helper.fileContents
+ .split("\n")
+ .slice(editableRegionStartLine, editableRegionEndLine + 1)
+ .join("\n");
+
+ const finalCursorPos = calculateFinalCursorPosition(
+ helper.pos,
+ editableRegionStartLine,
+ oldEditRangeSlice,
+ "",
+ );
+
if (this.endpointType === "default") {
const msg: ChatMessage = await llm.chat(prompts, token);
if (typeof msg.content === "string") {
@@ -270,6 +427,9 @@ export class NextEditProvider {
originalEditableRange: "",
completion: nextCompletion,
cursorPosition: helper.pos,
+ finalCursorPosition: finalCursorPos,
+ editableRegionStartLine: 0,
+ editableRegionEndLine: 0,
...helper.options,
};
return outcomeNext;
@@ -298,6 +458,13 @@ export class NextEditProvider {
.slice(editableRegionStartLine, editableRegionEndLine + 1)
.join("\n");
+ const finalCursorPos = calculateFinalCursorPosition(
+ helper.pos,
+ editableRegionStartLine,
+ oldEditRangeSlice,
+ "",
+ );
+
const outcomeNext: NextEditOutcome = {
elapsed: Date.now() - startTime,
modelProvider: llm.underlyingProviderName,
@@ -317,6 +484,9 @@ export class NextEditProvider {
originalEditableRange: oldEditRangeSlice,
completion: nextCompletion,
cursorPosition: helper.pos,
+ finalCursorPosition: finalCursorPos,
+ editableRegionStartLine,
+ editableRegionEndLine,
...helper.options,
};
return outcomeNext;
@@ -330,4 +500,85 @@ export class NextEditProvider {
this.loggingService.deleteAbortController(input.completionId);
}
}
+
+ public async provideNextEditPrediction(
+ input: AutocompleteInput,
+ token: AbortSignal | undefined,
+ ) {
+ try {
+ if (NextEditProvider.currentEditChainId) {
+ return await this.prefetchQueue.pop();
+ }
+
+ // Create abort signal if not given
+ if (!token) {
+ const controller = this.loggingService.createAbortController(
+ input.completionId,
+ );
+ token = controller.signal;
+ }
+ const startTime = Date.now();
+ const options = await this._getAutocompleteOptions();
+
+ // Debounce
+ if (await this.debouncer.delayAndShouldDebounce(options.debounceDelay)) {
+ return undefined;
+ }
+
+ const llm = await this._prepareLlm();
+ if (!llm) {
+ return undefined;
+ }
+
+ if (llm.promptTemplates?.autocomplete) {
+ options.template = llm.promptTemplates.autocomplete as string;
+ }
+
+ const helper = await HelperVars.create(
+ input,
+ options,
+ llm.model,
+ this.ide,
+ );
+
+ if (await shouldPrefilter(helper, this.ide)) {
+ return undefined;
+ }
+
+ NextEditProvider.currentEditChainId = randomUUID();
+
+ this.prefetchQueue.loadOther({
+ helper,
+ diffContext: this.diffContext,
+ llm,
+ token,
+ startTime,
+ newCursorPos: helper.pos,
+ });
+
+ const [snippetPayload, workspaceDirs] = await Promise.all([
+ getAllSnippetsWithoutRace({
+ helper,
+ ide: this.ide,
+ getDefinitionsFromLsp: this.getDefinitionsFromLsp,
+ contextRetrievalService: this.contextRetrievalService,
+ }),
+ this.ide.getWorkspaceDirs(),
+ ]);
+
+ // TODO: Get the references.
+ const refQueue = await this.ide.getReferences({
+ filepath: helper.filepath,
+ position: helper.pos,
+ });
+
+ this.prefetchQueue.loadResource(refQueue);
+ await this.prefetchQueue.initialize();
+ return await this.prefetchQueue.pop();
+ } catch (e: any) {
+ this.onError(e);
+ } finally {
+ this.loggingService.deleteAbortController(input.completionId);
+ }
+ }
}
diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts
index 93f794a63..a257f0621 100644
--- a/core/nextEdit/templating/NextEditPromptEngine.ts
+++ b/core/nextEdit/templating/NextEditPromptEngine.ts
@@ -1,5 +1,5 @@
import Handlebars from "handlebars";
-import { Position } from "../..";
+import { Position, RangeInFile } from "../..";
import { SnippetPayload } from "../../autocomplete/snippets";
import { HelperVars } from "../../autocomplete/util/HelperVars";
import {
@@ -9,7 +9,9 @@ import {
NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
USER_CURSOR_IS_HERE_TOKEN,
} from "../constants";
+import { createDiff, DiffFormatType } from "../context/diffFormatting";
import {
+ NextEditOutcome,
NextEditTemplate,
PromptMetadata,
SystemPrompt,
@@ -49,6 +51,8 @@ function templateRendererOfModel(
export function renderPrompt(
helper: HelperVars,
userEdits: string,
+ prevOutcome?: NextEditOutcome,
+ toApply?: RangeInFile,
): PromptMetadata {
let modelName = helper.modelName as NextEditModelName;
@@ -80,10 +84,55 @@ export function renderPrompt(
}
const renderer = templateRendererOfModel(modelName);
- const editedCodeWithTokens = insertTokens(
- helper.fileContents.split("\n"),
- helper.pos,
- );
+ let editedCodeWithTokens = "";
+
+ // TODO: apply prevOutcome to existing content. we will need the line range.
+ // Also display the diff between existing content and applied content.
+ if (prevOutcome) {
+ console.log(
+ "beforeInsert:",
+ helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
+ );
+ console.log("toInsert: ", prevOutcome?.completion.split("\n"));
+ console.log(
+ "afterInsert:",
+ helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
+ );
+ let appliedContent = [
+ ...helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
+ ...(prevOutcome?.completion.split("\n") ?? []),
+ ...helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
+ ];
+ // console.log("helper.fileContents:", helper.fileContents);
+ // TODO: I'm not sure, but <|user_cursor_is_here|> is somehow being added to appliedContent.
+ // The individual parts don't contain this.
+ console.log("appliedContent:", appliedContent);
+ appliedContent = appliedContent.filter(
+ (line) => !line.includes(USER_CURSOR_IS_HERE_TOKEN),
+ );
+ // TODO: helper.pos is outdated.
+ // Given a previous response, we need to calculate where the cursor would be.
+ // I think it's a good idea to calculate this in the response.
+ editedCodeWithTokens = insertTokens(
+ appliedContent,
+ prevOutcome.finalCursorPosition,
+ );
+ console.log("new editedCodeWithTokens:", editedCodeWithTokens);
+ userEdits = createDiff({
+ beforeContent: helper.fileContents,
+ afterContent: appliedContent.join("\n"),
+ filePath: helper.filepath,
+ diffType: DiffFormatType.Unified,
+ contextLines: 3,
+ });
+ userEdits = userEdits.replace(USER_CURSOR_IS_HERE_TOKEN, "");
+ console.log("new userDiff:", userEdits);
+ } else {
+ editedCodeWithTokens = insertTokens(
+ helper.fileContents.split("\n"),
+ helper.pos,
+ );
+ }
const tv: TemplateVars = {
userEdits,
From 51818bffee9a9c76f921e4d3c4cd62040eda8500 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 15 Jul 2025 17:45:12 -0700
Subject: [PATCH 013/244] feat: reset edit chain id to null
---
.../vscode/src/activation/NextEditWindowManager.ts | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/extensions/vscode/src/activation/NextEditWindowManager.ts b/extensions/vscode/src/activation/NextEditWindowManager.ts
index 58d03239d..25171c935 100644
--- a/extensions/vscode/src/activation/NextEditWindowManager.ts
+++ b/extensions/vscode/src/activation/NextEditWindowManager.ts
@@ -12,6 +12,7 @@ import {
} from "core/nextEdit/constants";
import { getOffsetPositionAtLastNewLine } from "core/nextEdit/diff/diff";
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
+import { NextEditProvider } from "core/nextEdit/NextEditProvider";
import { getThemeString } from "../util/getTheme";
export interface TextApplier {
@@ -199,10 +200,10 @@ export class NextEditWindowManager {
await NextEditWindowManager.freeTabAndEsc();
// Register HIDE_TOOLTIP_COMMAND and ACCEPT_NEXT_EDIT_COMMAND with their corresponding callbacks.
- this.registerCommandSafely(
- HIDE_NEXT_EDIT_SUGGESTION_COMMAND,
- async () => await this.hideAllNextEditWindowsAndResetCompletionId(),
- );
+ this.registerCommandSafely(HIDE_NEXT_EDIT_SUGGESTION_COMMAND, async () => {
+ NextEditProvider.currentEditChainId = null;
+ await this.hideAllNextEditWindowsAndResetCompletionId();
+ });
this.registerCommandSafely(
ACCEPT_NEXT_EDIT_SUGGESTION_COMMAND,
async () => await this.acceptNextEdit(),
@@ -317,6 +318,8 @@ export class NextEditWindowManager {
* Hide all tooltips in all editors.
*/
public async hideAllNextEditWindows() {
+ NextEditProvider.currentEditChainId = null;
+
if (this.currentDecoration) {
vscode.window.visibleTextEditors.forEach((editor) => {
editor.setDecorations(this.currentDecoration!, []);
From 3d0ef7afbc7f0f040352f44c1ca61a484523399e Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 15 Jul 2025 17:45:18 -0700
Subject: [PATCH 014/244] feat: reset edit chain id to null
---
extensions/vscode/src/extension/VsCodeExtension.ts | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts
index 0bc47f90d..802c5f28a 100644
--- a/extensions/vscode/src/extension/VsCodeExtension.ts
+++ b/extensions/vscode/src/extension/VsCodeExtension.ts
@@ -42,6 +42,7 @@ import { VsCodeIde } from "../VsCodeIde";
import { ConfigYamlDocumentLinkProvider } from "./ConfigYamlDocumentLinkProvider";
import { VsCodeMessenger } from "./VsCodeMessenger";
+import { NextEditProvider } from "core/nextEdit/NextEditProvider";
import setupNextEditWindowManager, {
NextEditWindowManager,
} from "../activation/NextEditWindowManager";
@@ -368,6 +369,19 @@ export class VsCodeExtension {
}
});
+ // TODO: check if next edit provider's chain id is cleared properly.
+ // Listen for editor changes to clean up decorations when editor closes.
+ vscode.window.onDidChangeVisibleTextEditors(async () => {
+ // If our active editor is no longer visible, clear decorations.
+ NextEditProvider.currentEditChainId = null;
+ });
+
+ // Listen for selection changes to hide tooltip when cursor moves.
+ vscode.window.onDidChangeTextEditorSelection(async (e) => {
+ // If the selection changed in our active editor, hide the tooltip.
+ NextEditProvider.currentEditChainId = null;
+ });
+
// Refresh index when branch is changed
void this.ide.getWorkspaceDirs().then((dirs) =>
dirs.forEach(async (dir) => {
From 007f40948ef27cce2d66113c3c781c8227afd564 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 15 Jul 2025 17:45:30 -0700
Subject: [PATCH 015/244] feat: use the new prefetch method
---
.../src/autocomplete/completionProvider.ts | 43 ++++++++++++++-----
1 file changed, 32 insertions(+), 11 deletions(-)
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 88131a3e8..2237c68a4 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -236,23 +236,44 @@ export class ContinueCompletionProvider
setupStatusBar(undefined, true);
+ // TODO: Consume next edit generator.
+ let outcome: AutocompleteOutcome | NextEditOutcome | undefined;
+
+ // Check if editChainId exists or needs to be refreshed.
+ if (this.isNextEditActive) {
+ outcome = await this.nextEditProvider.provideNextEditPrediction(
+ input,
+ signal,
+ );
+ } else {
+ outcome = await this.completionProvider.provideInlineCompletionItems(
+ input,
+ signal,
+ wasManuallyTriggered,
+ );
+ }
+
// TODO: fix type of outcome to be a union between NextEditOutcome and AutocompleteOutcome.
- const outcome: AutocompleteOutcome | NextEditOutcome | undefined = this
- .isNextEditActive
- ? await this.nextEditProvider.provideInlineCompletionItems(
- input,
- signal,
- )
- : await this.completionProvider.provideInlineCompletionItems(
- input,
- signal,
- wasManuallyTriggered,
- );
+ // const outcome: AutocompleteOutcome | NextEditOutcome | undefined = this
+ // .isNextEditActive
+ // ? await this.nextEditProvider.provideInlineCompletionItems(
+ // input,
+ // signal,
+ // )
+ // : await this.completionProvider.provideInlineCompletionItems(
+ // input,
+ // signal,
+ // wasManuallyTriggered,
+ // );
if (!outcome || !outcome.completion) {
return null;
}
+ console.log("======");
+ console.log(outcome.completion);
+ console.log("======");
+
// VS Code displays dependent on selectedCompletionInfo (their docstring below)
// We should first always make sure we have a valid completion, but if it goes wrong we
// want telemetry to be correct
From 4f7ec0dc13b119aeed0e0caf288d78fc2f329bf5 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 15 Jul 2025 19:55:20 -0700
Subject: [PATCH 016/244] chore: remove console logs and add timer
---
core/nextEdit/NextEditProvider.ts | 2 +-
.../templating/NextEditPromptEngine.ts | 24 +++++++++----------
.../src/autocomplete/completionProvider.ts | 7 +++---
3 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index 9ae8a635e..9d30741be 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -103,7 +103,7 @@ export class NextEditProvider {
if (!other) return undefined;
// render prompt
// TODO: this has to set the editable region properly.
- console.log("fetchfunction - previousData:", previousData?.completion);
+ // console.log("fetchfunction - previousData:", previousData?.completion);
const promptMetadata = renderPrompt(
other.helper,
other.diffContext,
diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts
index a257f0621..98f382126 100644
--- a/core/nextEdit/templating/NextEditPromptEngine.ts
+++ b/core/nextEdit/templating/NextEditPromptEngine.ts
@@ -89,15 +89,15 @@ export function renderPrompt(
// TODO: apply prevOutcome to existing content. we will need the line range.
// Also display the diff between existing content and applied content.
if (prevOutcome) {
- console.log(
- "beforeInsert:",
- helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
- );
- console.log("toInsert: ", prevOutcome?.completion.split("\n"));
- console.log(
- "afterInsert:",
- helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
- );
+ // console.log(
+ // "beforeInsert:",
+ // helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
+ // );
+ // console.log("toInsert: ", prevOutcome?.completion.split("\n"));
+ // console.log(
+ // "afterInsert:",
+ // helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
+ // );
let appliedContent = [
...helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
...(prevOutcome?.completion.split("\n") ?? []),
@@ -106,7 +106,7 @@ export function renderPrompt(
// console.log("helper.fileContents:", helper.fileContents);
// TODO: I'm not sure, but <|user_cursor_is_here|> is somehow being added to appliedContent.
// The individual parts don't contain this.
- console.log("appliedContent:", appliedContent);
+ // console.log("appliedContent:", appliedContent);
appliedContent = appliedContent.filter(
(line) => !line.includes(USER_CURSOR_IS_HERE_TOKEN),
);
@@ -117,7 +117,7 @@ export function renderPrompt(
appliedContent,
prevOutcome.finalCursorPosition,
);
- console.log("new editedCodeWithTokens:", editedCodeWithTokens);
+ // console.log("new editedCodeWithTokens:", editedCodeWithTokens);
userEdits = createDiff({
beforeContent: helper.fileContents,
afterContent: appliedContent.join("\n"),
@@ -126,7 +126,7 @@ export function renderPrompt(
contextLines: 3,
});
userEdits = userEdits.replace(USER_CURSOR_IS_HERE_TOKEN, "");
- console.log("new userDiff:", userEdits);
+ // console.log("new userDiff:", userEdits);
} else {
editedCodeWithTokens = insertTokens(
helper.fileContents.split("\n"),
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 2237c68a4..4e401f72b 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -241,10 +241,13 @@ export class ContinueCompletionProvider
// Check if editChainId exists or needs to be refreshed.
if (this.isNextEditActive) {
+ const st = performance.now();
outcome = await this.nextEditProvider.provideNextEditPrediction(
input,
signal,
);
+ console.log(performance.now() - st);
+ console.log(outcome?.elapsed);
} else {
outcome = await this.completionProvider.provideInlineCompletionItems(
input,
@@ -270,10 +273,6 @@ export class ContinueCompletionProvider
return null;
}
- console.log("======");
- console.log(outcome.completion);
- console.log("======");
-
// VS Code displays dependent on selectedCompletionInfo (their docstring below)
// We should first always make sure we have a valid completion, but if it goes wrong we
// want telemetry to be correct
From c8c0472d8105239a28a2f331ed3c4b1d60e99ce0 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Wed, 16 Jul 2025 15:36:57 -0700
Subject: [PATCH 017/244] feat: retrieve five most relevant code chunks given a
code snippet
---
.../pipelines/BaseRetrievalPipeline.ts | 24 ++++-
.../pipelines/NextEditRetrievalPipeline.ts | 99 +++++++++++++++++++
core/nextEdit/NextEditProvider.ts | 14 +++
3 files changed, 136 insertions(+), 1 deletion(-)
create mode 100644 core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
diff --git a/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts b/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts
index 5089678c1..33789da6e 100644
--- a/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts
+++ b/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts
@@ -77,6 +77,21 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
);
}
+ // Add this to BaseRetrievalPipeline.ts
+ protected async ensureLanceDbInitialized(): Promise {
+ if (!this.lanceDbIndex) {
+ // Re-run the initialization logic
+ const embedModel = this.options.config.selectedModelByRole.embed;
+ if (!embedModel) {
+ return false;
+ }
+ this.lanceDbIndex = await LanceDbIndex.create(embedModel, (uri) =>
+ this.options.ide.readFile(uri),
+ );
+ }
+ return this.lanceDbIndex !== null;
+ }
+
private getCleanedTrigrams(
query: RetrievalPipelineRunArguments["query"],
): string[] {
@@ -163,12 +178,19 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
input: string,
n: number,
): Promise {
- if (!this.lanceDbIndex) {
+ const initialized = await this.ensureLanceDbInitialized();
+ if (!initialized || !this.lanceDbIndex) {
console.warn(
"LanceDB index not available, skipping embeddings retrieval",
);
return [];
}
+ // if (!this.lanceDbIndex) {
+ // console.warn(
+ // "LanceDB index not available, skipping embeddings retrieval",
+ // );
+ // return [];
+ // }
return this.lanceDbIndex.retrieve(
input,
diff --git a/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts b/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
new file mode 100644
index 000000000..bbf5d8350
--- /dev/null
+++ b/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
@@ -0,0 +1,99 @@
+import { BranchAndDir, Chunk, ContinueConfig, IDE, ILLM } from "../../..";
+import BaseRetrievalPipeline, {
+ RetrievalPipelineRunArguments,
+} from "./BaseRetrievalPipeline";
+
+export default class NextEditRetrievalPipeline extends BaseRetrievalPipeline {
+ async run(args: RetrievalPipelineRunArguments): Promise {
+ if (args.includeEmbeddings) {
+ await this.ensureLanceDbInitialized();
+ }
+ // Collect chunks from multiple sources.
+ const [embeddingChunks, ftsChunks, recentChunks, toolChunks] =
+ await Promise.all([
+ // Get chunks using embeddings similarity (vector search).
+ args.includeEmbeddings
+ ? this.retrieveEmbeddings(args.query, this.options.nRetrieve)
+ : Promise.resolve([]),
+
+ // Get chunks using full-text search.
+ this.retrieveFts(args, this.options.nRetrieve),
+
+ // Get chunks from recently edited files.
+ this.retrieveAndChunkRecentlyEditedFiles(this.options.nRetrieve),
+
+ // Get chunks using LLM-guided tool selection.
+ this.retrieveWithTools(args.query),
+ ]);
+
+ // Combine all chunks.
+ let allChunks = [
+ ...embeddingChunks,
+ ...ftsChunks,
+ ...recentChunks,
+ ...toolChunks,
+ ];
+
+ // Remove duplicates by digest.
+ const uniqueDigests = new Set();
+ const uniqueChunks = allChunks.filter((chunk) => {
+ if (uniqueDigests.has(chunk.digest)) {
+ return false;
+ }
+ uniqueDigests.add(chunk.digest);
+ return true;
+ });
+
+ // If we have too many chunks and embedding retrieval is available,
+ // prioritize chunks from embedding search as they're likely more semantically relevant.
+ if (uniqueChunks.length > this.options.nFinal) {
+ // First include embedding chunks (most semantically relevant).
+ const result: Chunk[] = [...embeddingChunks];
+
+ // Then add unique chunks from other sources until we reach nFinal.
+ const remainingChunks = uniqueChunks.filter(
+ (chunk) => !embeddingChunks.some((ec) => ec.digest === chunk.digest),
+ );
+
+ result.push(
+ ...remainingChunks.slice(0, this.options.nFinal - result.length),
+ );
+
+ return result.slice(0, this.options.nFinal);
+ }
+
+ // Otherwise just return the unique chunks up to nFinal.
+ return uniqueChunks.slice(0, this.options.nFinal);
+ }
+}
+
+export async function getTopRelevantCodeChunks(
+ codeSnippet: string,
+ options: {
+ ide: IDE;
+ llm: ILLM;
+ config: ContinueConfig;
+ tags: BranchAndDir[];
+ filterDirectory?: string;
+ },
+): Promise {
+ const retrievalPipeline = new NextEditRetrievalPipeline({
+ llm: options.llm,
+ config: options.config,
+ ide: options.ide,
+ input: codeSnippet,
+ nRetrieve: 10, // retrieve more initially for better filtering
+ nFinal: 5, // return top 5
+ tags: options.tags,
+ filterDirectory: options.filterDirectory,
+ });
+
+ const chunks = await retrievalPipeline.run({
+ query: codeSnippet,
+ tags: options.tags,
+ filterDirectory: options.filterDirectory,
+ includeEmbeddings: true,
+ });
+
+ return chunks;
+}
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index 9d30741be..df47476ff 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -16,6 +16,7 @@ import { AutocompleteDebouncer } from "../autocomplete/util/AutocompleteDebounce
import AutocompleteLruCache from "../autocomplete/util/AutocompleteLruCache.js";
import { HelperVars } from "../autocomplete/util/HelperVars.js";
import { AutocompleteInput } from "../autocomplete/util/types.js";
+import { getTopRelevantCodeChunks } from "../context/retrieval/pipelines/NextEditRetrievalPipeline.js";
import { myersDiff } from "../diff/myers.js";
import { PrefetchQueue } from "../util/PrefetchQueue.js";
import { replaceEscapedCharacters } from "../util/text.js";
@@ -572,6 +573,19 @@ export class NextEditProvider {
position: helper.pos,
});
+ const { config } = await this.configHandler.loadConfig();
+ const chunks = await getTopRelevantCodeChunks(
+ "pow(number, exponent) {\n return number ** exponent;\n}",
+ {
+ ide: this.ide,
+ llm: llm,
+ config: config!,
+ tags: [],
+ // filterDirectory: getUriPathBasename(helper.workspaceUris[0]),
+ },
+ );
+ console.log("chunks:", JSON.stringify(chunks));
+
this.prefetchQueue.loadResource(refQueue);
await this.prefetchQueue.initialize();
return await this.prefetchQueue.pop();
From fdde91b13865f788d601910bd2f7b508ee67eb2a Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Wed, 16 Jul 2025 18:16:53 -0700
Subject: [PATCH 018/244] feat: wrap each retrieval methods in try catches
---
.../pipelines/NextEditRetrievalPipeline.ts | 111 ++++++++++++------
core/nextEdit/NextEditProvider.ts | 25 +++-
2 files changed, 99 insertions(+), 37 deletions(-)
diff --git a/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts b/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
index bbf5d8350..2c18a407d 100644
--- a/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
+++ b/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
@@ -8,25 +8,62 @@ export default class NextEditRetrievalPipeline extends BaseRetrievalPipeline {
if (args.includeEmbeddings) {
await this.ensureLanceDbInitialized();
}
- // Collect chunks from multiple sources.
+
+ // Try each retrieval method.
+ // Embeddings can fail if query.execute() goes wrong.
+ const embeddingPromise = async () => {
+ if (!args.includeEmbeddings) return [];
+ try {
+ return await this.retrieveEmbeddings(
+ args.query,
+ this.options.nRetrieve,
+ );
+ } catch (error) {
+ console.error("Error retrieving embeddings:", error);
+ return [];
+ }
+ };
+
+ const ftsPromise = async () => {
+ try {
+ return await this.retrieveFts(args, this.options.nRetrieve);
+ } catch (error) {
+ console.error("Error retrieving from full-text search:", error);
+ return [];
+ }
+ };
+
+ const recentFilesPromise = async () => {
+ try {
+ return await this.retrieveAndChunkRecentlyEditedFiles(
+ this.options.nRetrieve,
+ );
+ } catch (error) {
+ console.error("Error retrieving recently edited files:", error);
+ return [];
+ }
+ };
+
+ const toolsPromise = async () => {
+ try {
+ return await this.retrieveWithTools(args.query);
+ } catch (error) {
+ console.error("Error retrieving with tools:", error);
+ return [];
+ }
+ };
+
const [embeddingChunks, ftsChunks, recentChunks, toolChunks] =
await Promise.all([
- // Get chunks using embeddings similarity (vector search).
- args.includeEmbeddings
- ? this.retrieveEmbeddings(args.query, this.options.nRetrieve)
- : Promise.resolve([]),
-
- // Get chunks using full-text search.
- this.retrieveFts(args, this.options.nRetrieve),
-
- // Get chunks from recently edited files.
- this.retrieveAndChunkRecentlyEditedFiles(this.options.nRetrieve),
-
- // Get chunks using LLM-guided tool selection.
- this.retrieveWithTools(args.query),
+ embeddingPromise(),
+ ftsPromise(),
+ recentFilesPromise(),
+ toolsPromise(),
]);
- // Combine all chunks.
+ // console.log(`Retrieved chunks: ${embeddingChunks.length} from embeddings, ${ftsChunks.length} from FTS, ${recentChunks.length} from recent
+ // files, ${toolChunks.length} from tools`);
+
let allChunks = [
...embeddingChunks,
...ftsChunks,
@@ -46,7 +83,10 @@ export default class NextEditRetrievalPipeline extends BaseRetrievalPipeline {
// If we have too many chunks and embedding retrieval is available,
// prioritize chunks from embedding search as they're likely more semantically relevant.
- if (uniqueChunks.length > this.options.nFinal) {
+ if (
+ uniqueChunks.length > this.options.nFinal &&
+ embeddingChunks.length > 0
+ ) {
// First include embedding chunks (most semantically relevant).
const result: Chunk[] = [...embeddingChunks];
@@ -77,23 +117,28 @@ export async function getTopRelevantCodeChunks(
filterDirectory?: string;
},
): Promise {
- const retrievalPipeline = new NextEditRetrievalPipeline({
- llm: options.llm,
- config: options.config,
- ide: options.ide,
- input: codeSnippet,
- nRetrieve: 10, // retrieve more initially for better filtering
- nFinal: 5, // return top 5
- tags: options.tags,
- filterDirectory: options.filterDirectory,
- });
+ try {
+ const retrievalPipeline = new NextEditRetrievalPipeline({
+ llm: options.llm,
+ config: options.config,
+ ide: options.ide,
+ input: codeSnippet,
+ nRetrieve: 10, // retrieve more initially for better filtering
+ nFinal: 5, // return top 5
+ tags: options.tags,
+ filterDirectory: options.filterDirectory,
+ });
- const chunks = await retrievalPipeline.run({
- query: codeSnippet,
- tags: options.tags,
- filterDirectory: options.filterDirectory,
- includeEmbeddings: true,
- });
+ const chunks = await retrievalPipeline.run({
+ query: codeSnippet,
+ tags: options.tags,
+ filterDirectory: options.filterDirectory,
+ includeEmbeddings: !options.config.experimental?.codebaseToolCallingOnly,
+ });
- return chunks;
+ return chunks;
+ } catch (error) {
+ console.error("Error getting relevant code chunks:", error);
+ return [];
+ }
}
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index df47476ff..3bc5f80ea 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -1,6 +1,13 @@
import * as path from "path";
import { ConfigHandler } from "../config/ConfigHandler.js";
-import { ChatMessage, IDE, ILLM, Position, RangeInFile } from "../index.js";
+import {
+ BranchAndDir,
+ ChatMessage,
+ IDE,
+ ILLM,
+ Position,
+ RangeInFile,
+} from "../index.js";
import OpenAI from "../llm/llms/OpenAI.js";
import { DEFAULT_AUTOCOMPLETE_OPTS } from "../util/parameters.js";
@@ -574,17 +581,27 @@ export class NextEditProvider {
});
const { config } = await this.configHandler.loadConfig();
+ const branches = await Promise.all(
+ workspaceDirs.map((dir) => this.ide.getBranch(dir)),
+ );
+ const tags: BranchAndDir[] = workspaceDirs.map((directory, i) => ({
+ directory,
+ branch: branches[i],
+ }));
const chunks = await getTopRelevantCodeChunks(
- "pow(number, exponent) {\n return number ** exponent;\n}",
+ ` add(number) {
+ this.result += number;
+ return this;
+ }`,
{
ide: this.ide,
llm: llm,
config: config!,
- tags: [],
+ tags: tags,
// filterDirectory: getUriPathBasename(helper.workspaceUris[0]),
},
);
- console.log("chunks:", JSON.stringify(chunks));
+ console.log("chunks:", JSON.stringify(chunks, null, 2));
this.prefetchQueue.loadResource(refQueue);
await this.prefetchQueue.initialize();
From 0001645b7efd2f75e9f761cb1051acf928be9756 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Wed, 16 Jul 2025 20:02:02 -0700
Subject: [PATCH 019/244] feat: add jump-specific chunking
---
.../pipelines/NextEditRetrievalPipeline.ts | 109 +++++++++++++++++-
1 file changed, 108 insertions(+), 1 deletion(-)
diff --git a/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts b/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
index 2c18a407d..515eb9bc8 100644
--- a/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
+++ b/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
@@ -1,4 +1,11 @@
-import { BranchAndDir, Chunk, ContinueConfig, IDE, ILLM } from "../../..";
+import {
+ BranchAndDir,
+ Chunk,
+ ContinueConfig,
+ IDE,
+ ILLM,
+ Position,
+} from "../../..";
import BaseRetrievalPipeline, {
RetrievalPipelineRunArguments,
} from "./BaseRetrievalPipeline";
@@ -142,3 +149,103 @@ export async function getTopRelevantCodeChunks(
return [];
}
}
+
+export async function retrieveRelevantSnippetsInFile(
+ query: string,
+ filepath: string,
+ cursorPosition: Position,
+ maxSnippets: number = 5,
+ snippetSize: number = 10, // lines per snippet
+ ide: IDE,
+): Promise {
+ try {
+ const fileContent = await ide.readFile(filepath);
+ const lines = fileContent.split("\n");
+
+ // Create smaller overlapping chunks around the cursor position.
+ const chunks: Chunk[] = [];
+ const totalLines = lines.length;
+
+ // If file is too small, skip chunking.
+ // Ideally we want to keep the chunk size smaller for jump purposes.
+ if (totalLines <= snippetSize * 2) {
+ return [];
+ }
+
+ // Use sliding window to create chunks in the file.
+ // Make sure to overlap the window while sliding.
+ for (
+ let startLine = 0;
+ startLine < totalLines - snippetSize;
+ startLine += Math.floor(snippetSize / 2)
+ ) {
+ // Skip the chunk that contains the cursor.
+ // NOTE: We might just include it.
+ if (
+ startLine <= cursorPosition.line &&
+ cursorPosition.line < startLine + snippetSize
+ ) {
+ continue;
+ }
+
+ const endLine = Math.min(startLine + snippetSize - 1, totalLines - 1);
+ const content = lines.slice(startLine, endLine + 1).join("\n");
+
+ chunks.push({
+ content,
+ startLine,
+ endLine,
+ digest: `${filepath}:${startLine}-${endLine}`,
+ filepath,
+ index: chunks.length,
+ });
+ }
+
+ // Calculate relevance score for each chunk.
+ // For now, we use simple keyword matching
+ // In the future we should use embeddings or cosine similarity.
+ const keywords = query
+ .toLowerCase()
+ .split(/\s+/)
+ .filter((k) => k.length > 2);
+
+ const scoredChunks = chunks.map((chunk) => {
+ const lowerContent = chunk.content.toLowerCase();
+ const score = keywords.reduce((sum, keyword) => {
+ return sum + (lowerContent.includes(keyword) ? 1 : 0);
+ }, 0);
+
+ return { chunk, score };
+ });
+
+ // Sort by score desc.
+ return scoredChunks
+ .sort((a, b) => b.score - a.score)
+ .slice(0, maxSnippets)
+ .map((sc) => sc.chunk);
+ } catch (error) {
+ console.error("Error finding relevant in-file snippets:", error);
+ return [];
+ }
+}
+
+export function cosineSimilarity(a: number[], b: number[]): number {
+ let dotProduct = 0;
+ let normA = 0;
+ let normB = 0;
+
+ for (let i = 0; i < a.length; i++) {
+ dotProduct += a[i] * b[i];
+ normA += a[i] * a[i];
+ normB += b[i] * b[i];
+ }
+
+ return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
+}
+
+// export async function getJumpDestinations(
+// codeSnippet: string,
+// cursorPosition: Position,
+// filepath: string,
+// ): Promise {
+// }
From 57fceb53a54b7d933b92bac462fa6b24a1674983 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 14:14:51 -0700
Subject: [PATCH 020/244] feat: add a jump manager to handle jumps
---
.../vscode/src/activation/JumpManager.ts | 162 ++++++++++++++++++
1 file changed, 162 insertions(+)
create mode 100644 extensions/vscode/src/activation/JumpManager.ts
diff --git a/extensions/vscode/src/activation/JumpManager.ts b/extensions/vscode/src/activation/JumpManager.ts
new file mode 100644
index 000000000..cf3c83290
--- /dev/null
+++ b/extensions/vscode/src/activation/JumpManager.ts
@@ -0,0 +1,162 @@
+import * as vscode from "vscode";
+// TODO:
+// Checks for current viewport range.
+// Creates and saves the Tab to Jump SVG decoration.
+// Given the range to replace, determines whether to display the SVG or not.
+// When SVG is displayed, reserve Tab and Esc for jumping.
+
+export class JumpManager {
+ private static _instance: JumpManager | undefined;
+
+ // Decoration state.
+ private _jumpDecoration: vscode.TextEditorDecorationType | undefined;
+ private _jumpDecorationVisible = false;
+ private _disposables: vscode.Disposable[] = [];
+
+ private constructor() {}
+
+ initialize() {}
+
+ public static getInstance(): JumpManager {
+ if (!JumpManager._instance) {
+ JumpManager._instance = new JumpManager();
+ }
+ return JumpManager._instance;
+ }
+
+ public static clearInstance() {
+ if (JumpManager._instance) {
+ JumpManager._instance.dispose();
+ JumpManager._instance = undefined;
+ }
+ }
+
+ public dispose() {
+ // Dispose current decoration.
+ this._disposables.forEach((d) => d.dispose());
+ this._disposables = [];
+ }
+
+ private async suggestJump(nextJumpLocation: vscode.Position) {
+ const editor = vscode.window.activeTextEditor;
+
+ if (editor) {
+ const visibleRanges = editor.visibleRanges;
+
+ if (visibleRanges.length > 0) {
+ const visibleRange = visibleRanges[0];
+ const topLineNumber = visibleRange.start.line;
+ const bottomLineNumber = visibleRange.end.line;
+
+ const decorationLine = nextJumpLocation.line;
+
+ // Check if jump location is outside the visible range.
+ if (decorationLine < topLineNumber) {
+ await this.renderTabToJumpDecoration(
+ editor,
+ topLineNumber,
+ nextJumpLocation,
+ );
+ } else if (decorationLine > bottomLineNumber) {
+ await this.renderTabToJumpDecoration(
+ editor,
+ bottomLineNumber,
+ nextJumpLocation,
+ );
+ } else {
+ // No suggestion is made when the decoration is within visibleRange.
+ return;
+ }
+
+ // Scroll to show the jump location.
+ editor.revealRange(
+ new vscode.Range(decorationLine, 0, decorationLine, 0),
+ vscode.TextEditorRevealType.InCenter,
+ );
+ }
+ }
+ }
+
+ private async renderTabToJumpDecoration(
+ editor: vscode.TextEditor,
+ lineToRenderOn: number,
+ jumpPosition: vscode.Position,
+ ) {
+ // Clean up any existing decoration beforehand.
+ await this.clearJumpDecoration();
+
+ // Create a decoration for jump.
+ this._jumpDecoration = vscode.window.createTextEditorDecorationType({
+ before: {
+ contentText: "📌 Press Tab to jump, Esc to cancel",
+ color: new vscode.ThemeColor("editorInfo.foreground"),
+ backgroundColor: new vscode.ThemeColor("editorInfo.background"),
+ margin: "0 0 0 0",
+ },
+ isWholeLine: true,
+ });
+
+ // Apply the decoration.
+ editor.setDecorations(this._jumpDecoration, [
+ new vscode.Range(lineToRenderOn, 0, lineToRenderOn, 0),
+ ]);
+
+ // Set the context key to enable tab/esc shortcuts.
+ await vscode.commands.executeCommand(
+ "setContext",
+ "continue.jumpDecorationVisible",
+ true,
+ );
+ this._jumpDecorationVisible = true;
+
+ // Register the key listeners.
+ await this.registerKeyListeners(editor, jumpPosition);
+ }
+
+ private async clearJumpDecoration() {
+ if (this._jumpDecoration) {
+ this._jumpDecoration.dispose();
+ this._jumpDecoration = undefined;
+ }
+
+ // Dispose any active listeners.
+ this._disposables.forEach((d) => d.dispose());
+ this._disposables = [];
+
+ // Reset the context.
+ await vscode.commands.executeCommand(
+ "setContext",
+ "continue.jumpDecorationVisible",
+ false,
+ );
+ this._jumpDecorationVisible = false;
+ }
+
+ private async registerKeyListeners(
+ editor: vscode.TextEditor,
+ jumpPosition: vscode.Position,
+ ) {
+ const acceptJumpCommand = vscode.commands.registerCommand(
+ "continue.acceptJump",
+ async () => {
+ if (this._jumpDecorationVisible) {
+ // Move cursor to the jump position.
+ editor.selection = new vscode.Selection(jumpPosition, jumpPosition);
+ await this.clearJumpDecoration();
+ }
+ },
+ );
+
+ const rejectJumpCommand = vscode.commands.registerCommand(
+ "continue.rejectJump",
+ async () => {
+ if (this._jumpDecorationVisible) {
+ await this.clearJumpDecoration();
+ }
+ },
+ );
+
+ // This allows us to dispose the command after a jump is completed.
+ this._disposables.push(acceptJumpCommand, rejectJumpCommand);
+ }
+}
From dd162c889d5bf69ca07e690a56951722072f92d4 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 14:15:00 -0700
Subject: [PATCH 021/244] feat: add jump commands
---
extensions/vscode/package.json | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json
index f7c6b6ea5..923343624 100644
--- a/extensions/vscode/package.json
+++ b/extensions/vscode/package.json
@@ -350,6 +350,16 @@
"category": "Continue",
"title": "Continue: Force Next Edit"
},
+ {
+ "command": "continue.acceptJump",
+ "category": "Continue",
+ "title": "Continue: Accept Jump Suggestion"
+ },
+ {
+ "command": "continue.rejectJump",
+ "category": "Continue",
+ "title": "Continue: Reject Jump Suggestion"
+ },
{
"command": "continue.generateRule",
"category": "Continue",
@@ -451,12 +461,22 @@
{
"command": "continue.nextEditWindow.hideNextEditSuggestion",
"key": "escape",
- "when": "editorTextFocus && nextEditWindowActive"
+ "when": "editorTextFocus && nextEditWindowActive && !continue.jumpDecorationVisible"
},
{
"command": "continue.nextEditWindow.acceptNextEditSuggestion",
"key": "tab",
- "when": "editorTextFocus && nextEditWindowActive"
+ "when": "editorTextFocus && nextEditWindowActive && !continue.jumpDecorationVisible"
+ },
+ {
+ "command": "continue.acceptJump",
+ "key": "tab",
+ "when": "editorTextFocus && continue.jumpDecorationVisible"
+ },
+ {
+ "command": "continue.rejectJump",
+ "key": "escape",
+ "when": "editorTextFocus && continue.jumpDecorationVisible"
}
],
"submenus": [
From 9d62771da8fe77dd6a081836c8fd338d4a4a89dc Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 14:15:16 -0700
Subject: [PATCH 022/244] feat: activate and clear jump manager singleton
---
extensions/vscode/src/extension/VsCodeExtension.ts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts
index 802c5f28a..bf703606f 100644
--- a/extensions/vscode/src/extension/VsCodeExtension.ts
+++ b/extensions/vscode/src/extension/VsCodeExtension.ts
@@ -49,6 +49,7 @@ import setupNextEditWindowManager, {
import { getDefinitionsFromLsp } from "../autocomplete/lsp";
import { handleTextDocumentChange } from "../util/editLoggingUtils";
import type { VsCodeWebviewProtocol } from "../webviewProtocol";
+import { JumpManager } from "../activation/JumpManager";
export class VsCodeExtension {
// Currently some of these are public so they can be used in testing (test/test-suites)
@@ -171,10 +172,14 @@ export class VsCodeExtension {
this.activateNextEdit();
await NextEditWindowManager.freeTabAndEsc();
+
+ JumpManager.getInstance();
} else {
NextEditWindowManager.clearInstance();
this.deactivateNextEdit();
await NextEditWindowManager.freeTabAndEsc();
+
+ JumpManager.clearInstance();
}
if (configLoadInterrupted) {
From 0264db58072347799eb323f10634d4b47d1abb41 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 21:28:19 -0700
Subject: [PATCH 023/244] feat: add a class to find next editable region
---
core/nextEdit/NextEditEditableRegionCarver.ts | 302 ++++++++++++++++++
1 file changed, 302 insertions(+)
create mode 100644 core/nextEdit/NextEditEditableRegionCarver.ts
diff --git a/core/nextEdit/NextEditEditableRegionCarver.ts b/core/nextEdit/NextEditEditableRegionCarver.ts
new file mode 100644
index 000000000..0576a714b
--- /dev/null
+++ b/core/nextEdit/NextEditEditableRegionCarver.ts
@@ -0,0 +1,302 @@
+import { RangeInFile } from "..";
+import { cosineSimilarity } from "../context/retrieval/pipelines/NextEditRetrievalPipeline";
+
+export enum EditableRegionStrategy {
+ Naive = "naive",
+ Model = "model",
+ Sliding = "sliding",
+}
+
+export function getNextEditableRegion(
+ strategy: EditableRegionStrategy,
+ ctx: any,
+): RangeInFile | null {
+ switch (strategy) {
+ case EditableRegionStrategy.Naive:
+ return naiveJump(ctx);
+ case EditableRegionStrategy.Model:
+ return modelJump(ctx);
+ case EditableRegionStrategy.Sliding:
+ return slidingJump(ctx);
+ default:
+ return null;
+ }
+}
+
+// Naive assumes that the entire file is editable.
+function naiveJump(ctx: any): RangeInFile | null {
+ const { fileLines, filepath } = ctx;
+ if (!fileLines || !filepath) {
+ console.warn("Missing required context for naive jump");
+ return null;
+ }
+
+ return {
+ filepath,
+ range: {
+ start: { line: 0, character: 0 },
+ end: {
+ line: fileLines.length - 1,
+ character: fileLines.at(-1).length,
+ },
+ },
+ };
+}
+
+// A naive jump uses the next edit model to predict edits for the entire file.
+// Then it calculates the diff between that and the original to get the jump location.
+function modelJump(ctx: any): RangeInFile | null {
+ try {
+ const { fileContent, predictedContent, filepath } = ctx;
+
+ if (!fileContent || !predictedContent || !filepath) {
+ console.warn("Missing required context for model jump");
+ return null;
+ }
+
+ const originalLines = fileContent.split("\n");
+ const predictedLines = predictedContent.split("\n");
+
+ // Find the first line that differs.
+ for (
+ let i = 0;
+ i < Math.min(originalLines.length, predictedLines.length);
+ i++
+ ) {
+ if (originalLines[i] !== predictedLines[i]) {
+ // Calculate the end of the differing section (find where they align again).
+ let endLine = i;
+ while (
+ endLine < Math.min(originalLines.length, predictedLines.length) &&
+ originalLines[endLine] !== predictedLines[endLine]
+ ) {
+ endLine++;
+ }
+
+ // Return a range that covers the differences.
+ return {
+ filepath,
+ range: {
+ start: { line: i, character: 0 },
+ end: {
+ line: Math.min(endLine, originalLines.length - 1),
+ character:
+ originalLines[Math.min(endLine, originalLines.length - 1)]
+ .length,
+ },
+ },
+ };
+ }
+ }
+
+ // If no difference found but files have different lengths,
+ if (originalLines.length !== predictedLines.length) {
+ const diffStartLine = Math.min(
+ originalLines.length,
+ predictedLines.length,
+ );
+ return {
+ filepath,
+ range: {
+ start: { line: diffStartLine, character: 0 },
+ end: {
+ line: originalLines.length - 1,
+ character: originalLines.at(-1).length,
+ },
+ },
+ };
+ }
+
+ // No differences found.
+ return null;
+ } catch (error) {
+ console.error("Error in model jump:", error);
+ return null;
+ }
+}
+
+// A sliding jump uses a sliding window to split the current file into zones.
+// Then each zone is ranked on how similar it is to the model's next edit prediction.
+function slidingJump(ctx: any): RangeInFile | null {
+ try {
+ const { fileContent, predictedContent, filepath, windowSize = 5 } = ctx;
+
+ if (!fileContent || !predictedContent || !filepath) {
+ console.warn("Missing required context for sliding jump");
+ return null;
+ }
+
+ const originalLines = fileContent.split("\n");
+ const predictedLines = predictedContent.split("\n");
+
+ // Create sliding windows/zones from the file.
+ const zones: Array<{
+ startLine: number;
+ endLine: number;
+ similarity: number;
+ }> = [];
+
+ for (
+ let i = 0;
+ i <= originalLines.length - windowSize;
+ i += Math.floor(windowSize / 2)
+ ) {
+ const originalWindow = originalLines.slice(i, i + windowSize).join("\n");
+
+ // For each zone, find the most similar section in the predicted content.
+ let highestSimilarity = 0;
+
+ for (
+ let j = 0;
+ j <= predictedLines.length - windowSize;
+ j += Math.floor(windowSize / 2)
+ ) {
+ const predictedWindow = predictedLines
+ .slice(j, j + windowSize)
+ .join("\n");
+
+ // Convert to simple vector representation for similarity calculation.
+ const originalVector = createSimpleVector(originalWindow);
+ const predictedVector = createSimpleVector(predictedWindow);
+
+ const similarity = cosineSimilarity(originalVector, predictedVector);
+
+ if (similarity > highestSimilarity) {
+ highestSimilarity = similarity;
+ }
+ }
+
+ zones.push({
+ startLine: i,
+ endLine: Math.min(i + windowSize - 1, originalLines.length - 1),
+ similarity: highestSimilarity,
+ });
+ }
+
+ // Find the zone with the highest similarity score.
+ const mostSimilarZone = zones.reduce((prev, current) =>
+ prev.similarity > current.similarity ? prev : current,
+ );
+
+ // Return the range of the most similar zone.
+ return {
+ filepath,
+ range: {
+ start: { line: mostSimilarZone.startLine, character: 0 },
+ end: {
+ line: mostSimilarZone.endLine,
+ character: originalLines[mostSimilarZone.endLine].length,
+ },
+ },
+ };
+ } catch (error) {
+ console.error("Error in sliding jump:", error);
+ return null;
+ }
+}
+
+// A rerank jump splits the current file into chunks.
+// Then it uses a rerank model to get the most relevant chunks and their positions.
+function rerankJump(ctx: any): RangeInFile | null {
+ try {
+ const { fileContent, query, filepath, reranker, chunkSize = 10 } = ctx;
+
+ if (!fileContent || !query || !filepath || !reranker) {
+ console.warn("Missing required context for rerank jump");
+ return null;
+ }
+
+ const lines = fileContent.split("\n");
+ const chunks: Array<{
+ content: string;
+ startLine: number;
+ endLine: number;
+ }> = [];
+
+ // Create chunks from the file
+ for (let i = 0; i < lines.length; i += Math.floor(chunkSize / 2)) {
+ const endLine = Math.min(i + chunkSize - 1, lines.length - 1);
+ const chunkContent = lines.slice(i, endLine + 1).join("\n");
+ chunks.push({
+ content: chunkContent,
+ startLine: i,
+ endLine: endLine,
+ });
+ }
+
+ // Use the reranker to score each chunk against the query
+ const scoredChunks = chunks.map((chunk) => ({
+ ...chunk,
+ score: reranker.rerank(query, [{ content: chunk.content }])[0],
+ }));
+
+ // Sort by score in descending order and get the highest scoring chunk
+ const mostRelevantChunk = scoredChunks.sort((a, b) => b.score - a.score)[0];
+
+ if (!mostRelevantChunk) {
+ return null;
+ }
+
+ // Return the range of the most relevant chunk
+ return {
+ filepath,
+ range: {
+ start: { line: mostRelevantChunk.startLine, character: 0 },
+ end: {
+ line: mostRelevantChunk.endLine,
+ character: lines[mostRelevantChunk.endLine].length,
+ },
+ },
+ };
+ } catch (error) {
+ console.error("Error in rerank jump:", error);
+ return null;
+ }
+}
+
+// Helper method to create a simple vector representation of a text string.
+function createSimpleVector(text: string): number[] {
+ const tokenFrequency: Record = {};
+
+ // Split text into tokens.
+ const tokens = text
+ .toLowerCase()
+ .split(/[\s.,\/#!$%\^&\*;:{}=\-_`~()\[\]]/g)
+ .map((s) => s.trim())
+ .filter((s) => s.length > 0);
+
+ // Count frequency of each token.
+ for (const token of tokens) {
+ tokenFrequency[token] = (tokenFrequency[token] || 0) + 1;
+ }
+
+ // Create a fixed-dimension vector (using common programming keywords as dimensions).
+ const dimensions = [
+ "function",
+ "return",
+ "if",
+ "else",
+ "for",
+ "while",
+ "const",
+ "let",
+ "var",
+ "class",
+ "import",
+ "export",
+ "interface",
+ "type",
+ "new",
+ "this",
+ "try",
+ "catch",
+ "async",
+ "await",
+ "true",
+ "false",
+ "null",
+ "undefined",
+ ];
+
+ return dimensions.map((dim) => tokenFrequency[dim] || 0);
+}
From 2a4ad72aa3a74f7c219243688cf6cab9cd6b09e1 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 21:28:36 -0700
Subject: [PATCH 024/244] feat: add some helpful diff functions
---
core/diff/myers.ts | 135 +++++++++++++++++++++++++++++++++++++
core/nextEdit/diff/diff.ts | 34 ++++++++++
2 files changed, 169 insertions(+)
diff --git a/core/diff/myers.ts b/core/diff/myers.ts
index b39ddccf3..9d4ea1740 100644
--- a/core/diff/myers.ts
+++ b/core/diff/myers.ts
@@ -209,3 +209,138 @@ export function myersCharDiff(
return result;
}
+
+export interface ChangeRange {
+ startLine: number;
+ endLine: number;
+ changeType: "deletion" | "addition" | "modification";
+}
+
+export function findChangedLineRanges(
+ diffLines: DiffLine[],
+ // oldCodeBlock: string,
+ // newCodeBlock: string,
+): ChangeRange[] {
+ const changes: ChangeRange[] = [];
+ let oldLineNumber = 0;
+ let newLineNumber = 0;
+ let currentChangeStart: number | null = null;
+ let currentChangeType: "deletion" | "addition" | "modification" | null = null;
+
+ for (let i = 0; i < diffLines.length; i++) {
+ const line = diffLines[i];
+
+ if (line.type === "same") {
+ // If we were tracking a change, close it
+ if (currentChangeStart !== null) {
+ changes.push({
+ startLine: currentChangeStart,
+ endLine: oldLineNumber - 1,
+ changeType: currentChangeType!,
+ });
+ currentChangeStart = null;
+ currentChangeType = null;
+ }
+
+ // Both old and new advance for 'same' lines
+ oldLineNumber++;
+ newLineNumber++;
+ } else if (line.type === "old") {
+ // Start tracking change if not already
+ if (currentChangeStart === null) {
+ currentChangeStart = oldLineNumber;
+ currentChangeType = "deletion";
+ }
+
+ // Check if this is part of a modification (old followed by new)
+ if (currentChangeType === "deletion") {
+ // Look ahead to see if there are 'new' lines following
+ let hasNewLines = false;
+ for (let j = i + 1; j < diffLines.length; j++) {
+ if (diffLines[j].type === "new") {
+ hasNewLines = true;
+ break;
+ } else if (diffLines[j].type === "same") {
+ break;
+ }
+ }
+ if (hasNewLines) {
+ currentChangeType = "modification";
+ }
+ }
+
+ oldLineNumber++;
+ } else if (line.type === "new") {
+ // Start tracking change if not already
+ if (currentChangeStart === null) {
+ currentChangeStart = oldLineNumber;
+ currentChangeType = "addition";
+ }
+
+ // If we were tracking deletions, this becomes a modification
+ if (currentChangeType === "deletion") {
+ currentChangeType = "modification";
+ }
+
+ newLineNumber++;
+ }
+ }
+
+ // Close any remaining change
+ if (currentChangeStart !== null) {
+ changes.push({
+ startLine: currentChangeStart,
+ endLine: oldLineNumber - 1,
+ changeType: currentChangeType!,
+ });
+ }
+
+ return changes;
+}
+
+// Alternative simpler approach if you just want deletion/modification ranges
+export function findChangedLineRangesSimple(
+ diffLines: DiffLine[],
+): ChangeRange[] {
+ const changes: ChangeRange[] = [];
+ let oldLineNumber = 0;
+ let currentChangeStart: number | null = null;
+
+ for (const line of diffLines) {
+ if (line.type === "same") {
+ // Close any current change
+ if (currentChangeStart !== null) {
+ changes.push({
+ startLine: currentChangeStart,
+ endLine: oldLineNumber - 1,
+ changeType: "modification",
+ });
+ currentChangeStart = null;
+ }
+ oldLineNumber++;
+ } else if (line.type === "old") {
+ // Start change if not already started
+ if (currentChangeStart === null) {
+ currentChangeStart = oldLineNumber;
+ }
+ oldLineNumber++;
+ } else if (line.type === "new") {
+ // Start change if not already started (for pure additions)
+ if (currentChangeStart === null) {
+ currentChangeStart = oldLineNumber;
+ }
+ // Don't increment oldLineNumber for 'new' lines
+ }
+ }
+
+ // Close any remaining change
+ if (currentChangeStart !== null) {
+ changes.push({
+ startLine: currentChangeStart,
+ endLine: oldLineNumber - 1,
+ changeType: "modification",
+ });
+ }
+
+ return changes;
+}
diff --git a/core/nextEdit/diff/diff.ts b/core/nextEdit/diff/diff.ts
index b89d638a4..cc6908690 100644
--- a/core/nextEdit/diff/diff.ts
+++ b/core/nextEdit/diff/diff.ts
@@ -136,6 +136,8 @@ export function checkFim(
isFim: false;
fimText: null;
} {
+ console.log("oldEditRange", oldEditRange);
+ console.log("newEditRange", newEditRange);
// Find the common prefix.
let prefixLength = 0;
while (
@@ -225,3 +227,35 @@ export function calculateFinalCursorPosition(
return finalCursorPos;
}
+
+/**
+ * Applies a completion to file content by replacing lines starting from a specific line number
+ *
+ * @param fileContent The original file content
+ * @param completion The completion text to apply
+ * @param startLineNumber The line number (0-based) where replacement should start
+ * @param linesToReplace Optional number of lines to replace; if not provided, will replace the same number of lines as in the completion
+ * @returns The file content with the completion applied
+ */
+export function applyCompletionToFile(
+ fileContent: string,
+ completion: string,
+ startLineNumber: number,
+ linesToReplace?: number,
+): string {
+ const lines = fileContent.split("\n");
+ const completionLines = completion.split("\n");
+
+ // Determine how many lines to replace
+ const numLinesToReplace =
+ linesToReplace !== undefined ? linesToReplace : completionLines.length;
+
+ // Replace the lines
+ const newLines = [
+ ...lines.slice(0, startLineNumber),
+ ...completionLines,
+ ...lines.slice(startLineNumber + numLinesToReplace),
+ ];
+
+ return newLines.join("\n");
+}
From 6b848298b894ef61567bc9ef8d85c89017d7c4cf Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 21:28:47 -0700
Subject: [PATCH 025/244] feat: prefetch queue for next edit
---
core/nextEdit/NextEditPrefetchQueue.ts | 136 +++++++++++++++++++++++++
1 file changed, 136 insertions(+)
create mode 100644 core/nextEdit/NextEditPrefetchQueue.ts
diff --git a/core/nextEdit/NextEditPrefetchQueue.ts b/core/nextEdit/NextEditPrefetchQueue.ts
new file mode 100644
index 000000000..99fff2b35
--- /dev/null
+++ b/core/nextEdit/NextEditPrefetchQueue.ts
@@ -0,0 +1,136 @@
+import { ILLM, Position, RangeInFile } from "..";
+import { HelperVars } from "../autocomplete/util/HelperVars";
+import { findChangedLineRanges, myersDiff } from "../diff/myers";
+import { PrefetchQueue } from "../util/PrefetchQueue";
+import { applyCompletionToFile } from "./diff/diff";
+import { EditableRegionStrategy } from "./NextEditEditableRegionCarver";
+import { NextEditProvider } from "./NextEditProvider";
+import { NextEditOutcome } from "./types";
+
+export class NextEditPrefetchQueue extends PrefetchQueue<
+ NextEditOutcome,
+ RangeInFile,
+ {
+ helper: HelperVars;
+ diffContext: string;
+ llm: ILLM;
+ token: AbortSignal;
+ startTime: number;
+ newCursorPos: Position;
+ editableRegionStrategy: EditableRegionStrategy;
+ }
+> {
+ async initialize(): Promise {
+ const firstPromise = this.fetchFunction(undefined, undefined, this.other);
+ this.promiseQueue.push(firstPromise);
+
+ const firstData = await firstPromise;
+ if (this.resourceQueue.length > 0) {
+ const resource = this.resourceQueue.shift()!;
+ const nextPromise = this.fetchFunction(firstData, resource, this.other);
+ this.promiseQueue.push(nextPromise);
+ }
+
+ if (this.other?.editableRegionStrategy === EditableRegionStrategy.Naive) {
+ // Get the response from fetchFunction and compare with firstData to identify changed regions
+ const resource =
+ this.resourceQueue.length > 0 ? this.resourceQueue[0] : undefined;
+ const secondPromise = this.fetchFunction(firstData, resource, this.other);
+ const secondData = await secondPromise;
+ // console.log(secondData?.completion);
+
+ // if (secondPromise) {
+ // Process this in the background
+ // secondPromise
+ // .then((secondData) => {
+
+ if (firstData && secondData) {
+ // Use myersDiff to find differences between the two completions
+ // const firstCompletionLines = firstData.completion.split("\n");
+ // const secondCompletionLines = secondData.completion.split("\n");
+
+ // TODO: this should be comparing old file and new file, not the completions.
+ // Compare the file after first completion is merged,
+ // and compare the file after first and second completion is merged.
+ const appliedFirst = applyCompletionToFile(
+ this.other.helper.fileContents,
+ firstData.completion,
+ firstData.editableRegionStartLine,
+ );
+ // const appliedFirstAndSecond = applyCompletionToFile(
+ // appliedFirst,
+ // secondData.completion,
+ // secondData.editableRegionStartLine,
+ // );
+ const diffLines = myersDiff(appliedFirst, secondData.completion);
+
+ // Track chunks of differences
+ console.log(diffLines, appliedFirst, secondData.completion);
+ const changedLineRanges = findChangedLineRanges(diffLines);
+ changedLineRanges.forEach((change) => {
+ // Inclusive, zero-based line numbers.
+ const chunk = {
+ startLine: change.startLine,
+ endLine: change.endLine,
+ };
+ console.log("chunk:", chunk);
+ const chunkOutcome: NextEditOutcome = {
+ ...firstData,
+ uniqueId: `${firstData.uniqueId}-chunk-${chunk.startLine}-${chunk.endLine}`,
+ editableRegionStartLine: chunk.startLine,
+ editableRegionEndLine: chunk.endLine,
+ };
+
+ this.promiseQueue.push(Promise.resolve(chunkOutcome));
+ });
+ }
+ }
+ }
+
+ async pop(): Promise {
+ if (this.promiseQueue.length === 0) {
+ return undefined;
+ }
+
+ if (this.other?.editableRegionStrategy === EditableRegionStrategy.Naive) {
+ // The queue should already be preloaded.
+ // We don't need to make extra calls to the model
+ // because we assume that the items already in the queue
+ // are the only items in this chain of edit.
+ const currentPromise = this.promiseQueue.shift()!;
+
+ if (this.promiseQueue.length === 0) {
+ NextEditProvider.currentEditChainId = null;
+ }
+
+ return await currentPromise;
+ }
+
+ // Get and remove the first promise from the queue
+ const currentPromise = this.promiseQueue.shift()!;
+ const currentData = await currentPromise;
+
+ // If we have resources left, prefetch the next item
+ if (this.resourceQueue.length > 0) {
+ // Get the most recently added promise (now at the end of the queue)
+ const previousPromise =
+ this.promiseQueue.length > 0
+ ? this.promiseQueue[this.promiseQueue.length - 1]
+ : Promise.resolve(currentData);
+
+ // Create new promise based on the previous one and next resource
+ const resource = this.resourceQueue.shift()!;
+ const nextPromise = previousPromise.then((data) =>
+ this.fetchFunction(data, resource, this.other),
+ );
+
+ this.promiseQueue.push(nextPromise);
+ } else if (this.promiseQueue.length === 0) {
+ // No more items in the queue and no more resources
+ NextEditProvider.currentEditChainId = null;
+ }
+
+ // console.log("currentData:", currentData);
+ return currentData;
+ }
+}
From 4f087fb8cfdf68b2a371b1214574fcefea6b6dd9 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 21:29:02 -0700
Subject: [PATCH 026/244] refactor: use the next edit prefetch queue
---
core/nextEdit/NextEditProvider.ts | 77 ++++++++++++++-----------------
1 file changed, 35 insertions(+), 42 deletions(-)
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index 3bc5f80ea..6265f06db 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -23,9 +23,7 @@ import { AutocompleteDebouncer } from "../autocomplete/util/AutocompleteDebounce
import AutocompleteLruCache from "../autocomplete/util/AutocompleteLruCache.js";
import { HelperVars } from "../autocomplete/util/HelperVars.js";
import { AutocompleteInput } from "../autocomplete/util/types.js";
-import { getTopRelevantCodeChunks } from "../context/retrieval/pipelines/NextEditRetrievalPipeline.js";
import { myersDiff } from "../diff/myers.js";
-import { PrefetchQueue } from "../util/PrefetchQueue.js";
import { replaceEscapedCharacters } from "../util/text.js";
import {
NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
@@ -35,7 +33,9 @@ import {
calculateFinalCursorPosition,
getOffsetPositionAtLastNewLine,
} from "./diff/diff.js";
+import { EditableRegionStrategy } from "./NextEditEditableRegionCarver.js";
import { NextEditLoggingService } from "./NextEditLoggingService.js";
+import { NextEditPrefetchQueue } from "./NextEditPrefetchQueue.js";
import {
renderDefaultSystemPrompt,
renderDefaultUserPrompt,
@@ -67,18 +67,7 @@ export class NextEditProvider {
private endpointType: "default" | "fineTuned";
private diffContext: string = "";
private promptMetadata: PromptMetadata | null = null;
- private prefetchQueue: PrefetchQueue<
- NextEditOutcome,
- RangeInFile,
- {
- helper: HelperVars;
- diffContext: string;
- llm: ILLM;
- token: AbortSignal;
- startTime: number;
- newCursorPos: Position;
- }
- >;
+ private prefetchQueue: NextEditPrefetchQueue;
// private refQueue: RangeInFile[] = [];
// TODO: This needs to be cleared globally on cancel.
public static currentEditChainId: string | null = null;
@@ -106,25 +95,29 @@ export class NextEditProvider {
token: AbortSignal;
startTime: number;
newCursorPos: Position;
+ editableRegionStrategy: EditableRegionStrategy;
},
) => {
if (!other) return undefined;
+ // console.log("previousData:", previousData?.completion);
// render prompt
// TODO: this has to set the editable region properly.
// console.log("fetchfunction - previousData:", previousData?.completion);
const promptMetadata = renderPrompt(
other.helper,
other.diffContext,
+ other.editableRegionStrategy,
previousData,
resource,
);
this.promptMetadata = promptMetadata;
+ // console.log("prompt:", promptMetadata.prompt);
// call llm.chat
const msg = await other.llm.chat([promptMetadata.prompt], other.token);
// built and return outcome
if (typeof msg.content === "string") {
if (msg.content === "") return undefined;
- // TODO: There are cases where msg.conetnt.split("<|start|>")[1] is undefined
+ // NOTE: There are cases where msg.conetnt.split("<|start|>")[1] is undefined
const nextCompletion = replaceEscapedCharacters(
msg.content.split("<|editable_region_start|>\n")[1],
).replace(/\n$/, "");
@@ -167,6 +160,8 @@ export class NextEditProvider {
character: offset.character,
};
+ // TODO: if editable region strategy is naive, then we need to split the prediction up into regions. Also potentially filling up the prefetch queue.
+
const outcomeNext: NextEditOutcome = {
elapsed: Date.now() - other.startTime,
modelProvider: other.llm.underlyingProviderName,
@@ -198,18 +193,11 @@ export class NextEditProvider {
}
};
- this.prefetchQueue = new PrefetchQueue<
- NextEditOutcome,
- RangeInFile,
- {
- helper: HelperVars;
- diffContext: string;
- llm: ILLM;
- token: AbortSignal;
- startTime: number;
- newCursorPos: Position;
- }
- >(fetchFunction, [], undefined);
+ this.prefetchQueue = new NextEditPrefetchQueue(
+ fetchFunction,
+ [],
+ undefined,
+ );
}
public static initialize(
@@ -387,7 +375,11 @@ export class NextEditProvider {
prompts.push(renderDefaultSystemPrompt());
prompts.push(renderDefaultUserPrompt(snippetPayload, helper));
} else {
- const promptMetadata = renderPrompt(helper, this.diffContext);
+ const promptMetadata = renderPrompt(
+ helper,
+ this.diffContext,
+ EditableRegionStrategy.Naive,
+ );
this.promptMetadata = promptMetadata;
prompts.push(promptMetadata.prompt);
}
@@ -562,6 +554,7 @@ export class NextEditProvider {
token,
startTime,
newCursorPos: helper.pos,
+ editableRegionStrategy: EditableRegionStrategy.Naive,
});
const [snippetPayload, workspaceDirs] = await Promise.all([
@@ -588,20 +581,20 @@ export class NextEditProvider {
directory,
branch: branches[i],
}));
- const chunks = await getTopRelevantCodeChunks(
- ` add(number) {
- this.result += number;
- return this;
- }`,
- {
- ide: this.ide,
- llm: llm,
- config: config!,
- tags: tags,
- // filterDirectory: getUriPathBasename(helper.workspaceUris[0]),
- },
- );
- console.log("chunks:", JSON.stringify(chunks, null, 2));
+ // const chunks = await getTopRelevantCodeChunks(
+ // ` add(number) {
+ // this.result += number;
+ // return this;
+ // }`,
+ // {
+ // ide: this.ide,
+ // llm: llm,
+ // config: config!,
+ // tags: tags,
+ // // filterDirectory: getUriPathBasename(helper.workspaceUris[0]),
+ // },
+ // );
+ // console.log("chunks:", JSON.stringify(chunks, null, 2));
this.prefetchQueue.loadResource(refQueue);
await this.prefetchQueue.initialize();
From 1ca57b1c5ef1a11acdb17941a18181384555cb0b Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 21:29:23 -0700
Subject: [PATCH 027/244] feat: use an actual queue data type instead of a two
pointer
---
core/util/PrefetchQueue.ts | 67 +++++++++++++++++++-------------------
1 file changed, 33 insertions(+), 34 deletions(-)
diff --git a/core/util/PrefetchQueue.ts b/core/util/PrefetchQueue.ts
index 36b55ff10..360c6bf82 100644
--- a/core/util/PrefetchQueue.ts
+++ b/core/util/PrefetchQueue.ts
@@ -1,11 +1,10 @@
import { NextEditProvider } from "../nextEdit/NextEditProvider";
export class PrefetchQueue {
- private currentPromise: Promise | null = null;
- private nextPromise: Promise | null = null;
- private resourceQueue: R[];
- private other: O | undefined;
- private fetchFunction: (
+ protected promiseQueue: Promise[] = [];
+ protected resourceQueue: R[];
+ protected other: O | undefined;
+ protected fetchFunction: (
previousData: T | undefined,
resource: R | undefined,
other: O | undefined,
@@ -26,9 +25,6 @@ export class PrefetchQueue {
}
loadResource(resources: R[]) {
- // if (this.resourceQueue.length > 0) {
- // throw new Error("Queue already initialized");
- // }
this.resourceQueue = [...this.resourceQueue, ...resources];
}
@@ -37,43 +33,45 @@ export class PrefetchQueue {
}
async initialize(): Promise {
- // Get the first response (no resource needed).
- this.currentPromise = this.fetchFunction(undefined, undefined, this.other);
- const firstData = await this.currentPromise;
- // TODO: cleanse editable_region_start and trailing newline.
+ // Get the first response (no resource needed)
+ const firstPromise = this.fetchFunction(undefined, undefined, this.other);
+ this.promiseQueue.push(firstPromise);
- // Create the next promise based on the first response and first resource.
- // if (this.resourceQueue.length > 0) {
- const resource = this.resourceQueue.shift()!;
- this.nextPromise = this.fetchFunction(firstData, resource, this.other);
- // }
+ // Prefetch the next item using the first resource
+ const firstData = await firstPromise;
+ if (this.resourceQueue.length > 0) {
+ const resource = this.resourceQueue.shift()!;
+ const nextPromise = this.fetchFunction(firstData, resource, this.other);
+ this.promiseQueue.push(nextPromise);
+ }
}
async pop(): Promise {
- if (!this.currentPromise) {
- // throw new Error("Queue not initialized");
+ if (this.promiseQueue.length === 0) {
return undefined;
}
- const currentData = await this.currentPromise;
+ // Get and remove the first promise from the queue
+ const currentPromise = this.promiseQueue.shift()!;
+ const currentData = await currentPromise;
- // Move next promise to current (if it exists).
- if (this.nextPromise) {
- this.currentPromise = this.nextPromise;
+ // If we have resources left, prefetch the next item
+ if (this.resourceQueue.length > 0) {
+ // Get the most recently added promise (now at the end of the queue)
+ const previousPromise =
+ this.promiseQueue.length > 0
+ ? this.promiseQueue[this.promiseQueue.length - 1]
+ : Promise.resolve(currentData);
- // Create new next promise if we have resources left.
+ // Create new promise based on the previous one and next resource
const resource = this.resourceQueue.shift()!;
- this.nextPromise = this.currentPromise.then((data) =>
+ const nextPromise = previousPromise.then((data) =>
this.fetchFunction(data, resource, this.other),
);
- // if (this.resourceQueue.length > 0) {
- // } else {
- // this.nextPromise = null;
- // }
- } else {
- NextEditProvider.currentEditChainId = null;
- // throw new Error("No more items in queue");
- return undefined;
+
+ this.promiseQueue.push(nextPromise);
+ } else if (this.promiseQueue.length === 0) {
+ // No more items in the queue and no more resources
}
console.log("currentData:", currentData);
@@ -81,10 +79,11 @@ export class PrefetchQueue {
}
hasNext(): boolean {
- return this.nextPromise !== null;
+ return this.promiseQueue.length > 0;
}
getRemainingResourceCount(): number {
return this.resourceQueue.length;
}
}
+
From 0363bb63c14df653fe2f666a2523365b697e3a6d Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 21:29:34 -0700
Subject: [PATCH 028/244] feat: use strategies
---
.../templating/NextEditPromptEngine.ts | 57 +++++++++++++++----
1 file changed, 45 insertions(+), 12 deletions(-)
diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts
index 98f382126..8b02ad401 100644
--- a/core/nextEdit/templating/NextEditPromptEngine.ts
+++ b/core/nextEdit/templating/NextEditPromptEngine.ts
@@ -10,6 +10,10 @@ import {
USER_CURSOR_IS_HERE_TOKEN,
} from "../constants";
import { createDiff, DiffFormatType } from "../context/diffFormatting";
+import {
+ EditableRegionStrategy,
+ getNextEditableRegion,
+} from "../NextEditEditableRegionCarver";
import {
NextEditOutcome,
NextEditTemplate,
@@ -51,6 +55,7 @@ function templateRendererOfModel(
export function renderPrompt(
helper: HelperVars,
userEdits: string,
+ editableRegionStrategy: EditableRegionStrategy,
prevOutcome?: NextEditOutcome,
toApply?: RangeInFile,
): PromptMetadata {
@@ -89,6 +94,7 @@ export function renderPrompt(
// TODO: apply prevOutcome to existing content. we will need the line range.
// Also display the diff between existing content and applied content.
if (prevOutcome) {
+ // console.log("renderPrompt prevOutcome:", prevOutcome.completion);
// console.log(
// "beforeInsert:",
// helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
@@ -104,18 +110,27 @@ export function renderPrompt(
...helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
];
// console.log("helper.fileContents:", helper.fileContents);
- // TODO: I'm not sure, but <|user_cursor_is_here|> is somehow being added to appliedContent.
+ // NOTE: I'm not sure, but <|user_cursor_is_here|> is somehow being added to appliedContent.
// The individual parts don't contain this.
// console.log("appliedContent:", appliedContent);
appliedContent = appliedContent.filter(
(line) => !line.includes(USER_CURSOR_IS_HERE_TOKEN),
);
- // TODO: helper.pos is outdated.
// Given a previous response, we need to calculate where the cursor would be.
// I think it's a good idea to calculate this in the response.
+
+ const editableRegion = getNextEditableRegion(editableRegionStrategy, {
+ fileLines: appliedContent,
+ filepath: helper.filepath,
+ });
+
+ // console.log("appliedContent:", appliedContent);
+ // console.log("startLine:", editableRegion?.range.start.line);
editedCodeWithTokens = insertTokens(
appliedContent,
prevOutcome.finalCursorPosition,
+ editableRegion?.range.start.line ?? undefined,
+ editableRegion?.range.end.line ?? undefined,
);
// console.log("new editedCodeWithTokens:", editedCodeWithTokens);
userEdits = createDiff({
@@ -313,9 +328,19 @@ export function renderDefaultUserPrompt(
// }
// }
-function insertTokens(lines: string[], cursorPos: Position) {
+function insertTokens(
+ lines: string[],
+ cursorPos: Position,
+ editableRegionStart?: number,
+ editableRegionEnd?: number,
+) {
const a = insertCursorToken(lines, cursorPos);
- const b = insertEditableRegionTokensWithStaticRange(a, cursorPos);
+ const b = insertEditableRegionTokensWithStaticRange(
+ a,
+ cursorPos,
+ editableRegionStart,
+ editableRegionEnd,
+ );
return b.join("\n");
}
@@ -339,20 +364,28 @@ function insertCursorToken(lines: string[], cursorPos: Position) {
function insertEditableRegionTokensWithStaticRange(
lines: string[],
cursorPos: Position,
+ editableRegionStart?: number,
+ editableRegionEnd?: number,
) {
if (cursorPos.line < 0 || cursorPos.line >= lines.length) {
return lines;
}
// Ensure editable regions are within bounds.
- const editableRegionStart = Math.max(
- cursorPos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
- 0,
- );
- const editableRegionEnd = Math.min(
- cursorPos.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
- lines.length - 1, // Line numbers should be zero-indexed.
- );
+ if (editableRegionStart === undefined) {
+ editableRegionStart = Math.max(
+ cursorPos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
+ 0,
+ );
+ }
+ if (editableRegionEnd === undefined) {
+ editableRegionEnd = Math.min(
+ cursorPos.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
+ lines.length - 1, // Line numbers should be zero-indexed.
+ );
+ }
+
+ // console.log("editableRegionStart:", editableRegionStart);
const instrumentedLines = [
...lines.slice(0, editableRegionStart),
From 00a996c1f9e7b28937d7260b80258cb16ced2fe2 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 21:35:40 -0700
Subject: [PATCH 029/244] feat: add a jump manager
---
extensions/vscode/src/activation/JumpManager.ts | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/extensions/vscode/src/activation/JumpManager.ts b/extensions/vscode/src/activation/JumpManager.ts
index cf3c83290..66036ae08 100644
--- a/extensions/vscode/src/activation/JumpManager.ts
+++ b/extensions/vscode/src/activation/JumpManager.ts
@@ -1,9 +1,4 @@
import * as vscode from "vscode";
-// TODO:
-// Checks for current viewport range.
-// Creates and saves the Tab to Jump SVG decoration.
-// Given the range to replace, determines whether to display the SVG or not.
-// When SVG is displayed, reserve Tab and Esc for jumping.
export class JumpManager {
private static _instance: JumpManager | undefined;
@@ -37,7 +32,7 @@ export class JumpManager {
this._disposables = [];
}
- private async suggestJump(nextJumpLocation: vscode.Position) {
+ public async suggestJump(nextJumpLocation: vscode.Position) {
const editor = vscode.window.activeTextEditor;
if (editor) {
From ef5986367ec0f9c5abeff07a55f2a73f0261fabf Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Thu, 17 Jul 2025 21:36:30 -0700
Subject: [PATCH 030/244] feat: use the jump manager
---
.../vscode/src/autocomplete/completionProvider.ts | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 4e401f72b..231c480e9 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -24,6 +24,7 @@ import { checkFim } from "core/nextEdit/diff/diff";
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
import { NextEditProvider } from "core/nextEdit/NextEditProvider";
import { NextEditOutcome } from "core/nextEdit/types";
+import { JumpManager } from "../activation/JumpManager";
import { NextEditWindowManager } from "../activation/NextEditWindowManager";
import { getDefinitionsFromLsp } from "./lsp";
import { RecentlyEditedTracker } from "./recentlyEdited";
@@ -66,6 +67,7 @@ export class ContinueCompletionProvider
private completionProvider: CompletionProvider;
private nextEditProvider: NextEditProvider;
private nextEditLoggingService: NextEditLoggingService;
+ private jumpManager: JumpManager;
public recentlyVisitedRanges: RecentlyVisitedRangesService;
public recentlyEditedTracker: RecentlyEditedTracker;
@@ -112,6 +114,8 @@ export class ContinueCompletionProvider
"fineTuned",
);
+ this.jumpManager = JumpManager.getInstance();
+
this.recentlyVisitedRanges = new RecentlyVisitedRangesService(ide);
}
@@ -366,6 +370,12 @@ export class ContinueCompletionProvider
(autocompleteCompletionItem as any).completeBracketPairs = true;
if (this.isNextEditActive) {
+ this.jumpManager.suggestJump(
+ new vscode.Position(
+ (outcome as NextEditOutcome).editableRegionStartLine,
+ 0,
+ ),
+ );
const editor = vscode.window.activeTextEditor;
if (!editor) {
return undefined;
From 72533b6169e1eeba0f0842e41d5c43145d141694 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 09:35:27 -0700
Subject: [PATCH 031/244] fix: reranker jump
---
core/nextEdit/NextEditEditableRegionCarver.ts | 130 +++++++++---------
1 file changed, 68 insertions(+), 62 deletions(-)
diff --git a/core/nextEdit/NextEditEditableRegionCarver.ts b/core/nextEdit/NextEditEditableRegionCarver.ts
index 0576a714b..dbe906814 100644
--- a/core/nextEdit/NextEditEditableRegionCarver.ts
+++ b/core/nextEdit/NextEditEditableRegionCarver.ts
@@ -1,19 +1,22 @@
-import { RangeInFile } from "..";
+import { Chunk, ChunkWithoutID, ILLM, RangeInFile } from "..";
import { cosineSimilarity } from "../context/retrieval/pipelines/NextEditRetrievalPipeline";
export enum EditableRegionStrategy {
Naive = "naive",
+ Rerank = "rerank",
Model = "model",
Sliding = "sliding",
}
-export function getNextEditableRegion(
+export async function getNextEditableRegion(
strategy: EditableRegionStrategy,
ctx: any,
-): RangeInFile | null {
+): Promise {
switch (strategy) {
case EditableRegionStrategy.Naive:
return naiveJump(ctx);
+ case EditableRegionStrategy.Rerank:
+ return await rerankJump(ctx);
case EditableRegionStrategy.Model:
return modelJump(ctx);
case EditableRegionStrategy.Sliding:
@@ -24,6 +27,7 @@ export function getNextEditableRegion(
}
// Naive assumes that the entire file is editable.
+// This relies on the next edit model to figure out where to jump next.
function naiveJump(ctx: any): RangeInFile | null {
const { fileLines, filepath } = ctx;
if (!fileLines || !filepath) {
@@ -43,6 +47,67 @@ function naiveJump(ctx: any): RangeInFile | null {
};
}
+// A rerank jump splits the current file into chunks.
+// Then it uses a rerank model to get the most relevant chunks and their positions.
+async function rerankJump(ctx: {
+ fileContent: string;
+ query: string;
+ filepath: string;
+ reranker: ILLM;
+ chunkSize: number;
+}): Promise {
+ try {
+ const { fileContent, query, filepath, reranker, chunkSize = 5 } = ctx;
+
+ if (!fileContent || !query || !filepath || !reranker) {
+ console.warn("Missing required context for rerank jump");
+ return null;
+ }
+
+ const lines = fileContent.split("\n");
+ const chunks: Array = [];
+
+ // Create chunks from the file.
+ for (let i = 0; i < lines.length; i += Math.floor(chunkSize / 2)) {
+ const endLine = Math.min(i + chunkSize - 1, lines.length - 1);
+ const chunkContent = lines.slice(i, endLine + 1).join("\n");
+ chunks.push({
+ content: chunkContent,
+ startLine: i,
+ endLine: endLine,
+ digest: `chunk-${i}-${endLine}`,
+ filepath: filepath,
+ index: i,
+ });
+ }
+
+ // Use the reranker to score each chunk against the query.
+ const scores = await reranker.rerank(query, chunks);
+
+ // Sort by score in descending order and get the highest scoring chunk.
+ chunks.sort(
+ (a, b) => scores[chunks.indexOf(b)] - scores[chunks.indexOf(a)],
+ );
+
+ const mostRelevantChunk = chunks[0];
+
+ // Return the range of the most relevant chunk.
+ return {
+ filepath,
+ range: {
+ start: { line: mostRelevantChunk.startLine, character: 0 },
+ end: {
+ line: mostRelevantChunk.endLine,
+ character: lines[mostRelevantChunk.endLine].length,
+ },
+ },
+ };
+ } catch (error) {
+ console.error("Error in rerank jump:", error);
+ return null;
+ }
+}
+
// A naive jump uses the next edit model to predict edits for the entire file.
// Then it calculates the diff between that and the original to get the jump location.
function modelJump(ctx: any): RangeInFile | null {
@@ -195,65 +260,6 @@ function slidingJump(ctx: any): RangeInFile | null {
}
}
-// A rerank jump splits the current file into chunks.
-// Then it uses a rerank model to get the most relevant chunks and their positions.
-function rerankJump(ctx: any): RangeInFile | null {
- try {
- const { fileContent, query, filepath, reranker, chunkSize = 10 } = ctx;
-
- if (!fileContent || !query || !filepath || !reranker) {
- console.warn("Missing required context for rerank jump");
- return null;
- }
-
- const lines = fileContent.split("\n");
- const chunks: Array<{
- content: string;
- startLine: number;
- endLine: number;
- }> = [];
-
- // Create chunks from the file
- for (let i = 0; i < lines.length; i += Math.floor(chunkSize / 2)) {
- const endLine = Math.min(i + chunkSize - 1, lines.length - 1);
- const chunkContent = lines.slice(i, endLine + 1).join("\n");
- chunks.push({
- content: chunkContent,
- startLine: i,
- endLine: endLine,
- });
- }
-
- // Use the reranker to score each chunk against the query
- const scoredChunks = chunks.map((chunk) => ({
- ...chunk,
- score: reranker.rerank(query, [{ content: chunk.content }])[0],
- }));
-
- // Sort by score in descending order and get the highest scoring chunk
- const mostRelevantChunk = scoredChunks.sort((a, b) => b.score - a.score)[0];
-
- if (!mostRelevantChunk) {
- return null;
- }
-
- // Return the range of the most relevant chunk
- return {
- filepath,
- range: {
- start: { line: mostRelevantChunk.startLine, character: 0 },
- end: {
- line: mostRelevantChunk.endLine,
- character: lines[mostRelevantChunk.endLine].length,
- },
- },
- };
- } catch (error) {
- console.error("Error in rerank jump:", error);
- return null;
- }
-}
-
// Helper method to create a simple vector representation of a text string.
function createSimpleVector(text: string): number[] {
const tokenFrequency: Record = {};
From bfbce53f3a5c367a98558f6e0ef9e6b94251f465 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 09:35:48 -0700
Subject: [PATCH 032/244] fix: ditch the prefetch queue for now
---
extensions/vscode/src/autocomplete/completionProvider.ts | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 231c480e9..63d175df8 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -240,18 +240,17 @@ export class ContinueCompletionProvider
setupStatusBar(undefined, true);
- // TODO: Consume next edit generator.
let outcome: AutocompleteOutcome | NextEditOutcome | undefined;
// Check if editChainId exists or needs to be refreshed.
if (this.isNextEditActive) {
const st = performance.now();
- outcome = await this.nextEditProvider.provideNextEditPrediction(
+ outcome = await this.nextEditProvider.provideInlineCompletionItems(
input,
signal,
);
- console.log(performance.now() - st);
- console.log(outcome?.elapsed);
+ // console.log(performance.now() - st);
+ // console.log(outcome?.elapsed);
} else {
outcome = await this.completionProvider.provideInlineCompletionItems(
input,
From ae36095a89531a98fd97c71560a178d163cab163 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 12:32:39 -0700
Subject: [PATCH 033/244] chore: remove console.logs
---
core/nextEdit/diff/diff.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/core/nextEdit/diff/diff.ts b/core/nextEdit/diff/diff.ts
index cc6908690..91d2eae41 100644
--- a/core/nextEdit/diff/diff.ts
+++ b/core/nextEdit/diff/diff.ts
@@ -136,8 +136,8 @@ export function checkFim(
isFim: false;
fimText: null;
} {
- console.log("oldEditRange", oldEditRange);
- console.log("newEditRange", newEditRange);
+ // console.log("oldEditRange", oldEditRange);
+ // console.log("newEditRange", newEditRange);
// Find the common prefix.
let prefixLength = 0;
while (
From deae3c66d3ed28d9de4b818dbc5ad4e7e93d0f54 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 12:33:20 -0700
Subject: [PATCH 034/244] feat: render jump suggestion at the location of the
next decoration when the decoration should be rendered inside the viewport
---
extensions/vscode/src/activation/JumpManager.ts | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/extensions/vscode/src/activation/JumpManager.ts b/extensions/vscode/src/activation/JumpManager.ts
index 66036ae08..b459f1002 100644
--- a/extensions/vscode/src/activation/JumpManager.ts
+++ b/extensions/vscode/src/activation/JumpManager.ts
@@ -60,7 +60,12 @@ export class JumpManager {
);
} else {
// No suggestion is made when the decoration is within visibleRange.
- return;
+ await this.renderTabToJumpDecoration(
+ editor,
+ decorationLine,
+ nextJumpLocation,
+ );
+ // return;
}
// Scroll to show the jump location.
@@ -92,8 +97,14 @@ export class JumpManager {
});
// Apply the decoration.
+ const lastIndexOfLine = editor.document.lineAt(lineToRenderOn).text.length;
editor.setDecorations(this._jumpDecoration, [
- new vscode.Range(lineToRenderOn, 0, lineToRenderOn, 0),
+ new vscode.Range(
+ lineToRenderOn,
+ lastIndexOfLine,
+ lineToRenderOn,
+ lastIndexOfLine,
+ ),
]);
// Set the context key to enable tab/esc shortcuts.
From 39cc73f3a2c835ed5cce4e33b235b6de71ef28a2 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 12:33:47 -0700
Subject: [PATCH 035/244] fix: reranker expects non-empty chunk contents
---
core/nextEdit/NextEditEditableRegionCarver.ts | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/core/nextEdit/NextEditEditableRegionCarver.ts b/core/nextEdit/NextEditEditableRegionCarver.ts
index dbe906814..85cbb30ee 100644
--- a/core/nextEdit/NextEditEditableRegionCarver.ts
+++ b/core/nextEdit/NextEditEditableRegionCarver.ts
@@ -1,4 +1,4 @@
-import { Chunk, ChunkWithoutID, ILLM, RangeInFile } from "..";
+import { Chunk, ILLM, RangeInFile } from "..";
import { cosineSimilarity } from "../context/retrieval/pipelines/NextEditRetrievalPipeline";
export enum EditableRegionStrategy {
@@ -60,17 +60,26 @@ async function rerankJump(ctx: {
const { fileContent, query, filepath, reranker, chunkSize = 5 } = ctx;
if (!fileContent || !query || !filepath || !reranker) {
- console.warn("Missing required context for rerank jump");
+ console.warn(
+ "Missing required context for rerank jump:",
+ !fileContent,
+ !query,
+ !filepath,
+ !reranker,
+ );
return null;
}
+ console.log("reranker", reranker);
+
const lines = fileContent.split("\n");
- const chunks: Array = [];
+ const chunks: Chunk[] = [];
// Create chunks from the file.
for (let i = 0; i < lines.length; i += Math.floor(chunkSize / 2)) {
const endLine = Math.min(i + chunkSize - 1, lines.length - 1);
const chunkContent = lines.slice(i, endLine + 1).join("\n");
+ if (chunkContent === "") continue; // Voyager throws an error if there are empty strings in its document field in the body.
chunks.push({
content: chunkContent,
startLine: i,
@@ -92,6 +101,9 @@ async function rerankJump(ctx: {
const mostRelevantChunk = chunks[0];
// Return the range of the most relevant chunk.
+ // NOTE: It might be better to return a list of chunks,
+ // because it's very difficult to gauge when to stop the model.
+ // We could argue that we should always try to jump until the user says no.
return {
filepath,
range: {
From 8e867fa362bc819a49405df46e8efa682ee3e165 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 12:34:00 -0700
Subject: [PATCH 036/244] feat: add chain-related methods
---
core/nextEdit/NextEditProvider.ts | 36 +++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 6 deletions(-)
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index 6265f06db..88906b056 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -1,4 +1,5 @@
import * as path from "path";
+import { v4 as uuidv4 } from "uuid";
import { ConfigHandler } from "../config/ConfigHandler.js";
import {
BranchAndDir,
@@ -13,7 +14,6 @@ import { DEFAULT_AUTOCOMPLETE_OPTS } from "../util/parameters.js";
import { ContextRetrievalService } from "../autocomplete/context/ContextRetrievalService.js";
-import { randomUUID } from "crypto";
import { BracketMatchingService } from "../autocomplete/filtering/BracketMatchingService.js";
import { CompletionStreamer } from "../autocomplete/generation/CompletionStreamer.js";
import { shouldPrefilter } from "../autocomplete/prefiltering/index.js";
@@ -69,8 +69,8 @@ export class NextEditProvider {
private promptMetadata: PromptMetadata | null = null;
private prefetchQueue: NextEditPrefetchQueue;
// private refQueue: RangeInFile[] = [];
- // TODO: This needs to be cleared globally on cancel.
- public static currentEditChainId: string | null = null;
+ private currentEditChainId: string | null = null;
+ private previousCompletions: string[] = [];
private constructor(
private readonly configHandler: ConfigHandler,
@@ -318,6 +318,27 @@ export class NextEditProvider {
return options;
}
+ public chainExists(): boolean {
+ return this.currentEditChainId !== null;
+ }
+
+ public getPreviousCompletion(): string | null {
+ return this.previousCompletions[0];
+ }
+
+ public deleteChain(): void {
+ this.currentEditChainId = null;
+ this.previousCompletions = [];
+ }
+
+ public startChain(id?: string) {
+ this.currentEditChainId = id ?? uuidv4();
+ }
+
+ public isStartOfChain() {
+ return this.previousCompletions.length === 1;
+ }
+
public async provideInlineCompletionItems(
input: AutocompleteInput,
token: AbortSignal | undefined,
@@ -444,6 +465,8 @@ export class NextEditProvider {
msg.content.split("<|editable_region_start|>\n")[1],
).replace(/\n$/, "");
+ this.previousCompletions.push(nextCompletion);
+
const currCursorPos = helper.pos;
const editableRegionStartLine = Math.max(
currCursorPos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
@@ -462,7 +485,8 @@ export class NextEditProvider {
helper.pos,
editableRegionStartLine,
oldEditRangeSlice,
- "",
+ // "",
+ nextCompletion,
);
const outcomeNext: NextEditOutcome = {
@@ -506,7 +530,7 @@ export class NextEditProvider {
token: AbortSignal | undefined,
) {
try {
- if (NextEditProvider.currentEditChainId) {
+ if (this.currentEditChainId) {
return await this.prefetchQueue.pop();
}
@@ -545,7 +569,7 @@ export class NextEditProvider {
return undefined;
}
- NextEditProvider.currentEditChainId = randomUUID();
+ // this.currentEditChainId = randomUUID();
this.prefetchQueue.loadOther({
helper,
From c7b182f5f3e5f1a85c83d64b97421667fd009b08 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 12:34:14 -0700
Subject: [PATCH 037/244] feat: display jump decoration
---
.../src/autocomplete/completionProvider.ts | 66 ++++++++++++++-----
1 file changed, 49 insertions(+), 17 deletions(-)
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 63d175df8..9f7eab8eb 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -21,9 +21,14 @@ import {
NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
} from "core/nextEdit/constants";
import { checkFim } from "core/nextEdit/diff/diff";
+import {
+ EditableRegionStrategy,
+ getNextEditableRegion,
+} from "core/nextEdit/NextEditEditableRegionCarver";
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
import { NextEditProvider } from "core/nextEdit/NextEditProvider";
import { NextEditOutcome } from "core/nextEdit/types";
+import { localPathOrUriToPath } from "core/util/pathToUri";
import { JumpManager } from "../activation/JumpManager";
import { NextEditWindowManager } from "../activation/NextEditWindowManager";
import { getDefinitionsFromLsp } from "./lsp";
@@ -95,6 +100,7 @@ export class ContinueCompletionProvider
}
return config.selectedModelByRole.autocomplete ?? undefined;
}
+
this.completionProvider = new CompletionProvider(
this.configHandler,
this.ide,
@@ -121,6 +127,14 @@ export class ContinueCompletionProvider
_lastShownCompletion: AutocompleteOutcome | NextEditOutcome | undefined;
+ private async getRerankModel() {
+ const { config } = await this.configHandler.loadConfig();
+ if (!config) {
+ return;
+ }
+ return config.selectedModelByRole.rerank ?? undefined;
+ }
+
public async provideInlineCompletionItems(
document: vscode.TextDocument,
position: vscode.Position,
@@ -171,14 +185,36 @@ export class ContinueCompletionProvider
token.onCancellationRequested(() => abortController.abort());
// Handle notebook cells
- const pos = {
+ let pos = {
line: position.line,
character: position.character,
};
- // const pos = {
- // line: 0,
- // character: 0,
- // };
+
+ if (this.nextEditProvider.chainExists()) {
+ // If the user has accepted the previous completion, the chain of edits is alive.
+ // Get the next editable region and set the pos to be within that range.
+ const nextEditableRegion = await getNextEditableRegion(
+ EditableRegionStrategy.Rerank,
+ {
+ fileContent: document.getText(),
+ query: this.nextEditProvider.getPreviousCompletion(), // previous completion in the chain
+ filepath: localPathOrUriToPath(document.uri.toString()),
+ reranker: await this.getRerankModel(),
+ chunkSize: 5,
+ },
+ );
+
+ if (nextEditableRegion) {
+ pos = {
+ line: nextEditableRegion.range.start.line,
+ character: nextEditableRegion.range.start.character,
+ };
+ }
+ } else {
+ // If the user has rejected, then we start a new chain of edits.
+ this.nextEditProvider.startChain();
+ }
+
let manuallyPassFileContents: string | undefined = undefined;
if (document.uri.scheme === "vscode-notebook-cell") {
const notebook = vscode.workspace.notebookDocuments.find((notebook) =>
@@ -244,13 +280,10 @@ export class ContinueCompletionProvider
// Check if editChainId exists or needs to be refreshed.
if (this.isNextEditActive) {
- const st = performance.now();
outcome = await this.nextEditProvider.provideInlineCompletionItems(
input,
signal,
);
- // console.log(performance.now() - st);
- // console.log(outcome?.elapsed);
} else {
outcome = await this.completionProvider.provideInlineCompletionItems(
input,
@@ -319,10 +352,7 @@ export class ContinueCompletionProvider
// Construct the range/text to show
const startPos = selectedCompletionInfo?.range.start ?? position;
- // const startPos = new vscode.Position(0, 0);
- // const endPos = new vscode.Position(0, 5);
let range = new vscode.Range(startPos, startPos);
- // let range = new vscode.Range(startPos, endPos);
let completionText = outcome.completion;
// NOTE: This seems like an autocomplete logic.
@@ -369,12 +399,14 @@ export class ContinueCompletionProvider
(autocompleteCompletionItem as any).completeBracketPairs = true;
if (this.isNextEditActive) {
- this.jumpManager.suggestJump(
- new vscode.Position(
- (outcome as NextEditOutcome).editableRegionStartLine,
- 0,
- ),
- );
+ if (!this.nextEditProvider.isStartOfChain()) {
+ await this.jumpManager.suggestJump(
+ new vscode.Position(
+ (outcome as NextEditOutcome).editableRegionStartLine,
+ 0,
+ ),
+ );
+ }
const editor = vscode.window.activeTextEditor;
if (!editor) {
return undefined;
From 4c15e87b86a75e46460acd0fd0fc9d89ea446d87 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 13:32:33 -0700
Subject: [PATCH 038/244] feat: feat
---
.../vscode/src/activation/JumpManager.ts | 34 ++++++++++++++++++-
.../src/autocomplete/completionProvider.ts | 14 +++++---
extensions/vscode/src/commands.ts | 9 +++++
3 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/extensions/vscode/src/activation/JumpManager.ts b/extensions/vscode/src/activation/JumpManager.ts
index b459f1002..d0da8faa2 100644
--- a/extensions/vscode/src/activation/JumpManager.ts
+++ b/extensions/vscode/src/activation/JumpManager.ts
@@ -32,7 +32,10 @@ export class JumpManager {
this._disposables = [];
}
- public async suggestJump(nextJumpLocation: vscode.Position) {
+ public async suggestJump(
+ nextJumpLocation: vscode.Position,
+ nextEditData?: any,
+ ) {
const editor = vscode.window.activeTextEditor;
if (editor) {
@@ -75,6 +78,35 @@ export class JumpManager {
);
}
}
+
+ if (nextEditData) {
+ this.pendingNextEditData = nextEditData;
+
+ const disposable = vscode.window.onDidChangeTextEditorSelection((e) => {
+ const editor = vscode.window.activeTextEditor;
+ if (editor && e.textEditor === editor) {
+ const currentPosition = editor.selection.active;
+
+ if (Math.abs(currentPosition.line - nextJumpLocation.line) <= 1) {
+ disposable.dispose();
+
+ vscode.commands.executeCommand("continue.showNextEditAfterJump", {
+ ...this.pendingNextEditData,
+ currentPosition,
+ });
+
+ this.pendingNextEditData = undefined;
+ }
+ }
+ });
+
+ setTimeout(() => {
+ if (this.pendingNextEditData) {
+ disposable.dispose();
+ this.pendingNextEditData = undefined;
+ }
+ }, 10000);
+ }
}
private async renderTabToJumpDecoration(
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 9f7eab8eb..d9883f928 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -400,12 +400,16 @@ export class ContinueCompletionProvider
if (this.isNextEditActive) {
if (!this.nextEditProvider.isStartOfChain()) {
- await this.jumpManager.suggestJump(
- new vscode.Position(
- (outcome as NextEditOutcome).editableRegionStartLine,
- 0,
- ),
+ const jumpPosition = new vscode.Position(
+ (outcome as NextEditOutcome).editableRegionStartLine,
+ 0,
);
+ await this.jumpManager.suggestJump(jumpPosition, {
+ completionId: input.completionId,
+ outcome: outcome as NextEditOutcome,
+ });
+
+ return undefined;
}
const editor = vscode.window.activeTextEditor;
if (!editor) {
diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts
index 3b247f88b..c4a1e4d9e 100644
--- a/extensions/vscode/src/commands.ts
+++ b/extensions/vscode/src/commands.ts
@@ -805,6 +805,15 @@ const getCommandsMap: (
"editor.action.inlineSuggest.trigger",
);
},
+ "continue.showNextEditAfterJump": async (data) => {
+ const { completionId, outcome, currCursorPos } = data;
+ const editor = vscode.window.activeTextEditor;
+ if (!editor) return;
+
+ // This would be the same logic as in the renderNextEditSuggestion method
+ // from my first suggestion
+ // ...
+ },
};
};
From 9dce2baa8faaec876575a9755e58d257e7f9384d Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 15:06:44 -0700
Subject: [PATCH 039/244] feat: delay the next edit decoration until the jump
is complete
---
.../vscode/src/activation/JumpManager.ts | 64 ++++++++++---------
.../src/autocomplete/completionProvider.ts | 18 ++++--
2 files changed, 47 insertions(+), 35 deletions(-)
diff --git a/extensions/vscode/src/activation/JumpManager.ts b/extensions/vscode/src/activation/JumpManager.ts
index d0da8faa2..b6704fd8f 100644
--- a/extensions/vscode/src/activation/JumpManager.ts
+++ b/extensions/vscode/src/activation/JumpManager.ts
@@ -8,6 +8,9 @@ export class JumpManager {
private _jumpDecorationVisible = false;
private _disposables: vscode.Disposable[] = [];
+ private _jumpInProgress: boolean = false;
+ private _completionAfterJump: any = null;
+
private constructor() {}
initialize() {}
@@ -32,10 +35,9 @@ export class JumpManager {
this._disposables = [];
}
- public async suggestJump(
- nextJumpLocation: vscode.Position,
- nextEditData?: any,
- ) {
+ public async suggestJump(nextJumpLocation: vscode.Position) {
+ this._jumpInProgress = true;
+
const editor = vscode.window.activeTextEditor;
if (editor) {
@@ -68,7 +70,6 @@ export class JumpManager {
decorationLine,
nextJumpLocation,
);
- // return;
}
// Scroll to show the jump location.
@@ -79,34 +80,27 @@ export class JumpManager {
}
}
- if (nextEditData) {
- this.pendingNextEditData = nextEditData;
+ // Set up a way to detect when the jump is complete.
+ const disposable = vscode.window.onDidChangeTextEditorSelection(() => {
+ this._jumpInProgress = false;
+ disposable.dispose();
- const disposable = vscode.window.onDidChangeTextEditorSelection((e) => {
- const editor = vscode.window.activeTextEditor;
- if (editor && e.textEditor === editor) {
- const currentPosition = editor.selection.active;
+ // If there's a completion waiting to be shown after the jump,
+ // execute the command to show it.
+ if (this._completionAfterJump) {
+ vscode.commands.executeCommand(
+ "continue.showNextEditAfterJump",
+ this._completionAfterJump,
+ );
+ this._completionAfterJump = null;
+ }
+ });
- if (Math.abs(currentPosition.line - nextJumpLocation.line) <= 1) {
- disposable.dispose();
-
- vscode.commands.executeCommand("continue.showNextEditAfterJump", {
- ...this.pendingNextEditData,
- currentPosition,
- });
-
- this.pendingNextEditData = undefined;
- }
- }
- });
-
- setTimeout(() => {
- if (this.pendingNextEditData) {
- disposable.dispose();
- this.pendingNextEditData = undefined;
- }
- }, 10000);
- }
+ // Clean up after timeout if no jump has been made.
+ setTimeout(() => {
+ this._jumpInProgress = false;
+ disposable.dispose();
+ }, 5000);
}
private async renderTabToJumpDecoration(
@@ -197,4 +191,12 @@ export class JumpManager {
// This allows us to dispose the command after a jump is completed.
this._disposables.push(acceptJumpCommand, rejectJumpCommand);
}
+
+ isJumpInProgress(): boolean {
+ return this._jumpInProgress;
+ }
+
+ setCompletionAfterJump(completionData: any): void {
+ this._completionAfterJump = completionData;
+ }
}
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index d9883f928..294e09dd5 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -404,13 +404,23 @@ export class ContinueCompletionProvider
(outcome as NextEditOutcome).editableRegionStartLine,
0,
);
- await this.jumpManager.suggestJump(jumpPosition, {
- completionId: input.completionId,
- outcome: outcome as NextEditOutcome,
- });
+
+ await this.jumpManager.suggestJump(jumpPosition);
+
+ // If a jump was just suggested, don't show ghost text yet.
+ if (this.jumpManager.isJumpInProgress()) {
+ // Store this completion for later use when jump is complete.
+ this.jumpManager.setCompletionAfterJump({
+ completionId: input.completionId,
+ outcome: outcome as NextEditOutcome,
+ });
+
+ return undefined; // Don't show anything yet!
+ }
return undefined;
}
+
const editor = vscode.window.activeTextEditor;
if (!editor) {
return undefined;
From 07c7371ba53cd9bc42645be3a3894439fae77969 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 15:07:07 -0700
Subject: [PATCH 040/244] feat: add a display after jump command
---
extensions/vscode/src/commands.ts | 113 ++++++++++++++++++++++++++++--
1 file changed, 107 insertions(+), 6 deletions(-)
diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts
index c4a1e4d9e..d7f23f3d0 100644
--- a/extensions/vscode/src/commands.ts
+++ b/extensions/vscode/src/commands.ts
@@ -17,7 +17,14 @@ import * as YAML from "yaml";
import { convertJsonToYamlConfig } from "../../../packages/config-yaml/dist";
+import { myersDiff } from "core/diff/myers";
+import {
+ NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
+ NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
+} from "core/nextEdit/constants";
+import { checkFim } from "core/nextEdit/diff/diff";
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
+import { NextEditWindowManager } from "./activation/NextEditWindowManager";
import {
getAutocompleteStatusBarDescription,
getAutocompleteStatusBarTitle,
@@ -806,13 +813,107 @@ const getCommandsMap: (
);
},
"continue.showNextEditAfterJump": async (data) => {
- const { completionId, outcome, currCursorPos } = data;
- const editor = vscode.window.activeTextEditor;
- if (!editor) return;
+ // NOTE: This could use some cleanup or abstraction.
+ // The logic is largely similar to that of completionProvider.ts
+ // but we don't have access to the class.
- // This would be the same logic as in the renderNextEditSuggestion method
- // from my first suggestion
- // ...
+ const { completionId, outcome, currentPosition } = data;
+
+ const editor = vscode.window.activeTextEditor;
+ if (!editor) {
+ console.log("No active editor when trying to show next edit");
+ return;
+ }
+
+ // Calculate the editable region boundaries around the current cursor position/
+ const editableRegionStartLine = Math.max(
+ currentPosition.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
+ 0,
+ );
+ const editableRegionEndLine = Math.min(
+ currentPosition.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
+ editor.document.lineCount - 1,
+ );
+
+ // Get the current text in the editable region.
+ const oldEditRangeSlice = editor.document
+ .getText()
+ .split("\n")
+ .slice(editableRegionStartLine, editableRegionEndLine + 1)
+ .join("\n");
+
+ // Get the suggested new text from the completion outcome.
+ const newEditRangeSlice = outcome.completion;
+
+ // Skip showing edit if the suggestion is empty.
+ if (newEditRangeSlice === "") {
+ const loggingService = NextEditLoggingService.getInstance();
+ loggingService.cancelRejectionTimeout(completionId);
+ return;
+ }
+
+ // Skip showing edit if the suggestion is identical to current text.
+ if (oldEditRangeSlice === newEditRangeSlice) {
+ const loggingService = NextEditLoggingService.getInstance();
+ loggingService.cancelRejectionTimeout(completionId);
+ return;
+ }
+
+ // Check if this is a simple "fill in middle" (FIM) type edit.
+ const { isFim, fimText } = checkFim(
+ oldEditRangeSlice,
+ newEditRangeSlice,
+ currentPosition,
+ );
+
+ if (isFim) {
+ // For FIM edits, create an inline completion item.
+ const nextEditCompletionItem = new vscode.InlineCompletionItem(
+ fimText,
+ new vscode.Range(
+ new vscode.Position(
+ currentPosition.line,
+ currentPosition.character,
+ ),
+ new vscode.Position(
+ currentPosition.line,
+ currentPosition.character,
+ ),
+ ),
+ {
+ title: "Log Next Edit Outcome",
+ command: "continue.logNextEditOutcomeAccept",
+ arguments: [completionId, NextEditLoggingService.getInstance()],
+ },
+ );
+
+ // Show the ghost text using VS Code's inline completion API.
+ // We need to trigger this manually since we're not in the completion provider.
+ await vscode.commands.executeCommand(
+ "editor.action.inlineCompletions.showNext",
+ {
+ completions: [nextEditCompletionItem],
+ position: currentPosition,
+ },
+ );
+ } else {
+ // For more complex edits, we display a diff inside a window.
+ const diffLines = myersDiff(oldEditRangeSlice, newEditRangeSlice);
+
+ if (NextEditWindowManager.isInstantiated()) {
+ const windowManager = NextEditWindowManager.getInstance();
+ windowManager.updateCurrentCompletionId(completionId);
+
+ await windowManager.showNextEditWindow(
+ editor,
+ currentPosition,
+ editableRegionStartLine,
+ oldEditRangeSlice,
+ newEditRangeSlice,
+ diffLines,
+ );
+ }
+ }
},
};
};
From 2488df36fcd35a3294d8aa33d1451fd7fa4c4182 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 19:05:17 -0700
Subject: [PATCH 041/244] feat: jump only when necessary
---
.../vscode/src/activation/JumpManager.ts | 130 +++++++++++++++++-
1 file changed, 123 insertions(+), 7 deletions(-)
diff --git a/extensions/vscode/src/activation/JumpManager.ts b/extensions/vscode/src/activation/JumpManager.ts
index b6704fd8f..1d180c072 100644
--- a/extensions/vscode/src/activation/JumpManager.ts
+++ b/extensions/vscode/src/activation/JumpManager.ts
@@ -1,5 +1,13 @@
+import { NextEditProvider } from "core/nextEdit/NextEditProvider";
+import { NextEditOutcome } from "core/nextEdit/types";
import * as vscode from "vscode";
+export interface CompletionDataForAfterJump {
+ completionId: string;
+ outcome: NextEditOutcome;
+ currentPosition: vscode.Position;
+}
+
export class JumpManager {
private static _instance: JumpManager | undefined;
@@ -9,7 +17,8 @@ export class JumpManager {
private _disposables: vscode.Disposable[] = [];
private _jumpInProgress: boolean = false;
- private _completionAfterJump: any = null;
+ private _completionAfterJump: CompletionDataForAfterJump | null = null;
+ private _oldCursorPosition: vscode.Position | undefined;
private constructor() {}
@@ -35,8 +44,84 @@ export class JumpManager {
this._disposables = [];
}
- public async suggestJump(nextJumpLocation: vscode.Position) {
+ public async suggestJump(
+ currentPosition: vscode.Position,
+ nextJumpLocation: vscode.Position,
+ completionContent?: string,
+ ) {
+ // Deduplication logic.
+ // If the content at the next jump location is
+ // identical to the completion content,
+ // then we don't have to jump.
+ if (completionContent !== undefined) {
+ const editor = vscode.window.activeTextEditor;
+ if (editor) {
+ try {
+ const completionLines = completionContent.split("\n");
+
+ // Get document content at jump location spanning multiple lines.
+ const document = editor.document;
+ const startLine = nextJumpLocation.line;
+ const endLine = Math.min(
+ startLine + completionLines.length - 1,
+ document.lineCount - 1,
+ );
+
+ // Check if we have enough lines in the document to compare.
+ if (endLine - startLine + 1 < completionLines.length) {
+ // Not enough lines in document, so content can't be identical.
+ // Proceed to jump!
+ } else {
+ // Check the first line first for early exit.
+ const firstLineText = document.lineAt(startLine).text;
+ const firstLineSubstring = firstLineText.substring(
+ nextJumpLocation.character,
+ );
+ const firstCompletionLine = completionLines[0];
+
+ if (!firstLineSubstring.startsWith(firstCompletionLine)) {
+ // First line doesn't match, so proceed to jump.
+ } else {
+ // Check remaining lines if there are any.
+ if (completionLines.length > 1) {
+ let fullMatch = true;
+
+ // Process remaining lines.
+ for (let i = 1; i < completionLines.length; i++) {
+ const documentLine = startLine + i;
+ if (documentLine <= endLine) {
+ const lineText = document.lineAt(documentLine).text;
+ if (lineText !== completionLines[i]) {
+ fullMatch = false;
+ break;
+ }
+ }
+ }
+
+ if (fullMatch) {
+ console.log(
+ "Skipping jump as content is identical at jump location",
+ );
+ return; // Exit early, don't suggest jump.
+ }
+ } else {
+ // Only one line and it matches.
+ console.log(
+ "Skipping jump as content is identical at jump location",
+ );
+ return; // Exit early, don't suggest jump.
+ }
+ }
+ }
+ } catch (error) {
+ console.error("Error checking content at jump location:", error);
+ // Continue with jump even if there's an error checking content.
+ }
+ }
+ }
+
this._jumpInProgress = true;
+ this._oldCursorPosition = currentPosition;
const editor = vscode.window.activeTextEditor;
@@ -114,12 +199,11 @@ export class JumpManager {
// Create a decoration for jump.
this._jumpDecoration = vscode.window.createTextEditorDecorationType({
before: {
- contentText: "📌 Press Tab to jump, Esc to cancel",
+ contentText: "🦘 Press Tab to jump, Esc to cancel",
color: new vscode.ThemeColor("editorInfo.foreground"),
backgroundColor: new vscode.ThemeColor("editorInfo.background"),
- margin: "0 0 0 0",
+ margin: `0 0 0 4px`,
},
- isWholeLine: true,
});
// Apply the decoration.
@@ -183,20 +267,52 @@ export class JumpManager {
"continue.rejectJump",
async () => {
if (this._jumpDecorationVisible) {
+ console.log(
+ "deleteChain from JumpManager.ts: rejectJump and decoration visible",
+ );
+ NextEditProvider.getInstance().deleteChain();
await this.clearJumpDecoration();
}
},
);
+ // Add a selection change listener to the editor to reject jump when cursor moves.
+ const selectionChangeListener =
+ vscode.window.onDidChangeTextEditorSelection((e) => {
+ // If jump decoration isn't visible, nothing to do.
+ if (!this._jumpDecorationVisible) {
+ return;
+ }
+
+ const currentPosition = e.selections[0].active;
+
+ // If cursor moved to jump position, this is likely the result of acceptJump.
+ if (currentPosition.isEqual(jumpPosition)) {
+ return;
+ }
+
+ // If cursor position changed for any other reason, reject the jump.
+ if (
+ this._oldCursorPosition &&
+ !currentPosition.isEqual(this._oldCursorPosition)
+ ) {
+ vscode.commands.executeCommand("continue.rejectJump");
+ }
+ });
+
// This allows us to dispose the command after a jump is completed.
- this._disposables.push(acceptJumpCommand, rejectJumpCommand);
+ this._disposables.push(
+ acceptJumpCommand,
+ rejectJumpCommand,
+ selectionChangeListener,
+ );
}
isJumpInProgress(): boolean {
return this._jumpInProgress;
}
- setCompletionAfterJump(completionData: any): void {
+ setCompletionAfterJump(completionData: CompletionDataForAfterJump): void {
this._completionAfterJump = completionData;
}
}
From f137cc3d9a618d156e4e30588812cc99f2cdfdcf Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 19:06:04 -0700
Subject: [PATCH 042/244] chore: remove console.log
---
core/nextEdit/NextEditEditableRegionCarver.ts | 2 --
1 file changed, 2 deletions(-)
diff --git a/core/nextEdit/NextEditEditableRegionCarver.ts b/core/nextEdit/NextEditEditableRegionCarver.ts
index 85cbb30ee..69a6708e7 100644
--- a/core/nextEdit/NextEditEditableRegionCarver.ts
+++ b/core/nextEdit/NextEditEditableRegionCarver.ts
@@ -70,8 +70,6 @@ async function rerankJump(ctx: {
return null;
}
- console.log("reranker", reranker);
-
const lines = fileContent.split("\n");
const chunks: Chunk[] = [];
From b6ab6e3585bf0713fe105c28d4932118670a8675 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 19:06:21 -0700
Subject: [PATCH 043/244] feat: await renderPrompt
---
core/nextEdit/NextEditProvider.ts | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index 88906b056..ad969a84f 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -103,7 +103,7 @@ export class NextEditProvider {
// render prompt
// TODO: this has to set the editable region properly.
// console.log("fetchfunction - previousData:", previousData?.completion);
- const promptMetadata = renderPrompt(
+ const promptMetadata = await renderPrompt(
other.helper,
other.diffContext,
other.editableRegionStrategy,
@@ -335,6 +335,10 @@ export class NextEditProvider {
this.currentEditChainId = id ?? uuidv4();
}
+ public getChain() {
+ return this.previousCompletions;
+ }
+
public isStartOfChain() {
return this.previousCompletions.length === 1;
}
@@ -396,7 +400,7 @@ export class NextEditProvider {
prompts.push(renderDefaultSystemPrompt());
prompts.push(renderDefaultUserPrompt(snippetPayload, helper));
} else {
- const promptMetadata = renderPrompt(
+ const promptMetadata = await renderPrompt(
helper,
this.diffContext,
EditableRegionStrategy.Naive,
From d3c250ff85fd0215756c1fe62a8e4e9a8dbf12f3 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 19:06:34 -0700
Subject: [PATCH 044/244] feat: await for other functions
---
core/nextEdit/templating/NextEditPromptEngine.ts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts
index 8b02ad401..5efb341ce 100644
--- a/core/nextEdit/templating/NextEditPromptEngine.ts
+++ b/core/nextEdit/templating/NextEditPromptEngine.ts
@@ -52,13 +52,13 @@ function templateRendererOfModel(
};
}
-export function renderPrompt(
+export async function renderPrompt(
helper: HelperVars,
userEdits: string,
editableRegionStrategy: EditableRegionStrategy,
prevOutcome?: NextEditOutcome,
toApply?: RangeInFile,
-): PromptMetadata {
+): Promise {
let modelName = helper.modelName as NextEditModelName;
if (modelName === "this field is not used") {
@@ -119,7 +119,7 @@ export function renderPrompt(
// Given a previous response, we need to calculate where the cursor would be.
// I think it's a good idea to calculate this in the response.
- const editableRegion = getNextEditableRegion(editableRegionStrategy, {
+ const editableRegion = await getNextEditableRegion(editableRegionStrategy, {
fileLines: appliedContent,
filepath: helper.filepath,
});
From 6e36bc89ef4ad990f19d6c35741446a7d9ad9fd6 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 19:07:41 -0700
Subject: [PATCH 045/244] feat: pass data for rendering completion after jump
---
extensions/vscode/src/commands.ts | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts
index d7f23f3d0..693fbd9aa 100644
--- a/extensions/vscode/src/commands.ts
+++ b/extensions/vscode/src/commands.ts
@@ -24,6 +24,8 @@ import {
} from "core/nextEdit/constants";
import { checkFim } from "core/nextEdit/diff/diff";
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
+import { NextEditProvider } from "core/nextEdit/NextEditProvider";
+import { CompletionDataForAfterJump } from "./activation/JumpManager";
import { NextEditWindowManager } from "./activation/NextEditWindowManager";
import {
getAutocompleteStatusBarDescription,
@@ -812,7 +814,9 @@ const getCommandsMap: (
"editor.action.inlineSuggest.trigger",
);
},
- "continue.showNextEditAfterJump": async (data) => {
+ "continue.showNextEditAfterJump": async (
+ data: CompletionDataForAfterJump,
+ ) => {
// NOTE: This could use some cleanup or abstraction.
// The logic is largely similar to that of completionProvider.ts
// but we don't have access to the class.
@@ -867,6 +871,10 @@ const getCommandsMap: (
);
if (isFim) {
+ if (!fimText) {
+ console.log("deleteChain from commands.ts: !fimText");
+ NextEditProvider.getInstance().deleteChain();
+ }
// For FIM edits, create an inline completion item.
const nextEditCompletionItem = new vscode.InlineCompletionItem(
fimText,
@@ -899,6 +907,11 @@ const getCommandsMap: (
} else {
// For more complex edits, we display a diff inside a window.
const diffLines = myersDiff(oldEditRangeSlice, newEditRangeSlice);
+ if (diffLines.length === 0) {
+ console.log("deleteChain from commands.ts: diffLines.length === 0");
+ NextEditProvider.getInstance().deleteChain();
+ }
+ console.log("number of difflines:", diffLines.length);
if (NextEditWindowManager.isInstantiated()) {
const windowManager = NextEditWindowManager.getInstance();
From 1e02676ff13354298393b83847b9f5ab9ca12a84 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 19:08:10 -0700
Subject: [PATCH 046/244] feat: remove static member, add hasAccepted method
---
.../vscode/src/activation/NextEditWindowManager.ts | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/extensions/vscode/src/activation/NextEditWindowManager.ts b/extensions/vscode/src/activation/NextEditWindowManager.ts
index 25171c935..37414830e 100644
--- a/extensions/vscode/src/activation/NextEditWindowManager.ts
+++ b/extensions/vscode/src/activation/NextEditWindowManager.ts
@@ -201,7 +201,10 @@ export class NextEditWindowManager {
// Register HIDE_TOOLTIP_COMMAND and ACCEPT_NEXT_EDIT_COMMAND with their corresponding callbacks.
this.registerCommandSafely(HIDE_NEXT_EDIT_SUGGESTION_COMMAND, async () => {
- NextEditProvider.currentEditChainId = null;
+ console.log(
+ "deleteChain from NextEditWindowManager.ts: hide next edit command",
+ );
+ NextEditProvider.getInstance().deleteChain();
await this.hideAllNextEditWindowsAndResetCompletionId();
});
this.registerCommandSafely(
@@ -318,8 +321,6 @@ export class NextEditWindowManager {
* Hide all tooltips in all editors.
*/
public async hideAllNextEditWindows() {
- NextEditProvider.currentEditChainId = null;
-
if (this.currentDecoration) {
vscode.window.visibleTextEditors.forEach((editor) => {
editor.setDecorations(this.currentDecoration!, []);
@@ -848,6 +849,10 @@ export class NextEditWindowManager {
// If all else fails, return a reasonable default
return SVG_CONFIG.fontSize * 0.6;
}
+
+ public hasAccepted() {
+ return this.accepted;
+ }
}
export default async function setupNextEditWindowManager(
From adfa2a8b59a70b99fc2b8e5bf69642b0b8a83562 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 19:09:11 -0700
Subject: [PATCH 047/244] feat: use new jump manager methods
---
.../src/autocomplete/completionProvider.ts | 44 ++++++++++++++++---
1 file changed, 37 insertions(+), 7 deletions(-)
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 294e09dd5..eae812873 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -31,6 +31,7 @@ import { NextEditOutcome } from "core/nextEdit/types";
import { localPathOrUriToPath } from "core/util/pathToUri";
import { JumpManager } from "../activation/JumpManager";
import { NextEditWindowManager } from "../activation/NextEditWindowManager";
+import { GhostTextAcceptanceTracker } from "./GhostTextAcceptanceTracker";
import { getDefinitionsFromLsp } from "./lsp";
import { RecentlyEditedTracker } from "./recentlyEdited";
import { RecentlyVisitedRangesService } from "./RecentlyVisitedRangesService";
@@ -398,14 +399,27 @@ export class ContinueCompletionProvider
(autocompleteCompletionItem as any).completeBracketPairs = true;
+ const editor = vscode.window.activeTextEditor;
+ if (!editor) {
+ return undefined;
+ }
+
+ const currCursorPos = editor.selection.active;
+
if (this.isNextEditActive) {
+ console.log(this.nextEditProvider.getChain().length);
+
if (!this.nextEditProvider.isStartOfChain()) {
const jumpPosition = new vscode.Position(
(outcome as NextEditOutcome).editableRegionStartLine,
0,
);
- await this.jumpManager.suggestJump(jumpPosition);
+ await this.jumpManager.suggestJump(
+ currCursorPos,
+ jumpPosition,
+ outcome.completion,
+ );
// If a jump was just suggested, don't show ghost text yet.
if (this.jumpManager.isJumpInProgress()) {
@@ -413,6 +427,7 @@ export class ContinueCompletionProvider
this.jumpManager.setCompletionAfterJump({
completionId: input.completionId,
outcome: outcome as NextEditOutcome,
+ currentPosition: jumpPosition,
});
return undefined; // Don't show anything yet!
@@ -421,11 +436,6 @@ export class ContinueCompletionProvider
return undefined;
}
- const editor = vscode.window.activeTextEditor;
- if (!editor) {
- return undefined;
- }
-
// Check the diff between old and new editable region.
const newEditRangeSlice = completionText;
@@ -438,7 +448,6 @@ export class ContinueCompletionProvider
}
// Get the contents of the old (current) editable region.
- const currCursorPos = editor.selection.active;
const editableRegionStartLine = Math.max(
currCursorPos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
0,
@@ -468,6 +477,21 @@ export class ContinueCompletionProvider
currCursorPos,
);
if (isFim) {
+ if (!fimText) {
+ console.log("deleteChain from completionProvider.ts: !fimText");
+ this.nextEditProvider.deleteChain();
+ return undefined;
+ }
+
+ // const completionId = input.completionId;
+
+ // Track this ghost text for acceptance detection.
+ GhostTextAcceptanceTracker.getInstance().setExpectedGhostTextAcceptance(
+ document,
+ fimText,
+ new vscode.Position(currCursorPos.line, currCursorPos.character),
+ );
+
const nextEditCompletionItem = new vscode.InlineCompletionItem(
fimText,
new vscode.Range(
@@ -485,6 +509,12 @@ export class ContinueCompletionProvider
// Else, render a next edit window.
const diffLines = myersDiff(oldEditRangeSlice, newEditRangeSlice);
+ if (diffLines.length === 0) {
+ console.log(
+ "deleteChain from completionProvider.ts: diffLines.length === 0",
+ );
+ NextEditProvider.getInstance().deleteChain();
+ }
if (NextEditWindowManager.isInstantiated()) {
NextEditWindowManager.getInstance().updateCurrentCompletionId(
From 0b4bd55da32227ac09b8ad5a237e81773552cfec Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 19:09:34 -0700
Subject: [PATCH 048/244] feat: create a ghost text acceptance tracker to
quickly check if a completion has been accepted
---
.../GhostTextAcceptanceTracker.ts | 188 ++++++++++++++++++
1 file changed, 188 insertions(+)
create mode 100644 extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts
diff --git a/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts b/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts
new file mode 100644
index 000000000..610a3c7fe
--- /dev/null
+++ b/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts
@@ -0,0 +1,188 @@
+// export class CompletionAcceptanceTracker {
+// private static instance: CompletionAcceptanceTracker;
+// private acceptedCompletionIds: Set = new Set();
+
+// static getInstance(): CompletionAcceptanceTracker {
+// if (!CompletionAcceptanceTracker.instance) {
+// CompletionAcceptanceTracker.instance = new CompletionAcceptanceTracker();
+// }
+// return CompletionAcceptanceTracker.instance;
+// }
+
+// markGhostTextAccepted(completionId: string) {
+// this.acceptedCompletionIds.add(completionId);
+
+// // Keep a reasonable history size
+// if (this.acceptedCompletionIds.size > 1) {
+// // Remove the oldest item (using the fact that Sets maintain insertion order)
+// const oldestId = this.acceptedCompletionIds.values().next().value;
+// if (oldestId) {
+// this.acceptedCompletionIds.delete(oldestId);
+// }
+// }
+// }
+
+// wasCompletionAccepted(completionId: string): boolean {
+// return this.acceptedCompletionIds.has(completionId);
+// }
+
+// // Add a method to check if the most recent completion was accepted
+// wasRecentCompletionAccepted(): boolean {
+// return this.acceptedCompletionIds.size > 0;
+// }
+// }
+// In completionAcceptanceTracker.ts
+// export class CompletionAcceptanceTracker {
+// private static instance: CompletionAcceptanceTracker;
+// private acceptedCompletionIds: Set = new Set();
+// private currentCompletionId: string | null = null;
+
+// static getInstance(): CompletionAcceptanceTracker {
+// if (!CompletionAcceptanceTracker.instance) {
+// CompletionAcceptanceTracker.instance = new CompletionAcceptanceTracker();
+// }
+// return CompletionAcceptanceTracker.instance;
+// }
+
+// setCurrentCompletionId(completionId: string) {
+// this.currentCompletionId = completionId;
+// }
+
+// markGhostTextAccepted(completionId: string) {
+// console.log("mark");
+// this.acceptedCompletionIds.add(completionId);
+
+// // Keep a reasonable history size
+// if (this.acceptedCompletionIds.size > 1) {
+// // Remove the oldest item (using the fact that Sets maintain insertion order)
+// const oldestId = this.acceptedCompletionIds.values().next().value;
+// if (oldestId) {
+// this.acceptedCompletionIds.delete(oldestId);
+// }
+// }
+// }
+
+// wasCompletionAccepted(completionId: string): boolean {
+// return this.acceptedCompletionIds.has(completionId);
+// }
+
+// isCurrentCompletionAccepted(): boolean {
+// return (
+// this.currentCompletionId !== null &&
+// this.acceptedCompletionIds.has(this.currentCompletionId)
+// );
+// }
+
+// clearCurrentCompletionId() {
+// this.currentCompletionId = null;
+// }
+// }
+// New file: extensions/vscode/src/activation/GhostTextAcceptanceTracker.ts
+import * as vscode from "vscode";
+
+export interface ExpectedGhostTextAcceptance {
+ documentUri: string;
+ documentVersion: number;
+ text: string;
+ startLine: number;
+ startCharacter: number;
+ endLine: number;
+ endCharacter: number;
+}
+
+export class GhostTextAcceptanceTracker {
+ private static instance: GhostTextAcceptanceTracker | undefined;
+ private expectedAcceptance: ExpectedGhostTextAcceptance | null = null;
+
+ private constructor() {}
+
+ public static getInstance(): GhostTextAcceptanceTracker {
+ if (!GhostTextAcceptanceTracker.instance) {
+ GhostTextAcceptanceTracker.instance = new GhostTextAcceptanceTracker();
+ }
+ return GhostTextAcceptanceTracker.instance;
+ }
+
+ public static clearInstance() {
+ GhostTextAcceptanceTracker.instance = undefined;
+ }
+
+ public setExpectedGhostTextAcceptance(
+ document: vscode.TextDocument,
+ text: string,
+ startPosition: vscode.Position,
+ ) {
+ // Calculate end position
+ const lines = text.split("\n");
+ let endLine: number;
+ let endCharacter: number;
+
+ if (lines.length > 1) {
+ endLine = startPosition.line + lines.length - 1;
+ endCharacter = lines[lines.length - 1].length;
+ } else {
+ endLine = startPosition.line;
+ endCharacter = startPosition.character + text.length;
+ }
+
+ this.expectedAcceptance = {
+ documentUri: document.uri.toString(),
+ documentVersion: document.version,
+ text,
+ startLine: startPosition.line,
+ startCharacter: startPosition.character,
+ endLine,
+ endCharacter,
+ };
+ }
+
+ public checkGhostTextWasAccepted(
+ document: vscode.TextDocument,
+ newPosition: vscode.Position,
+ ): boolean {
+ if (!this.expectedAcceptance) return false;
+
+ // Check document match
+ if (this.expectedAcceptance.documentUri !== document.uri.toString()) {
+ return false;
+ }
+
+ // Check document version (must be newer)
+ if (document.version <= this.expectedAcceptance.documentVersion) {
+ return false;
+ }
+
+ // Check if cursor is at expected end position
+ const expectedEndPos = new vscode.Position(
+ this.expectedAcceptance.endLine,
+ this.expectedAcceptance.endCharacter,
+ );
+
+ if (newPosition.isEqual(expectedEndPos)) {
+ // The cursor is where we'd expect after accepting the ghost text
+
+ // Verify text was inserted (optional additional check)
+ const startPos = new vscode.Position(
+ this.expectedAcceptance.startLine,
+ this.expectedAcceptance.startCharacter,
+ );
+ const expectedText = this.expectedAcceptance.text;
+
+ try {
+ const actualRange = new vscode.Range(startPos, expectedEndPos);
+
+ const actualText = document.getText(actualRange);
+
+ if (actualText === expectedText) {
+ // Clear the expectation
+ this.expectedAcceptance = null;
+ return true;
+ }
+ } catch (error) {
+ // Range might be invalid, just fall through
+ }
+ }
+
+ return false;
+ }
+}
From 3d08b80666e61f4ee1ab00eba1d3f24d85ee5279 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 19:10:40 -0700
Subject: [PATCH 049/244] feat: clear chain of edits in cursor movement, but
not when part of next edit or jump
---
.../vscode/src/extension/VsCodeExtension.ts | 46 +++++++++++++++++--
1 file changed, 42 insertions(+), 4 deletions(-)
diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts
index bf703606f..3efbd6bf4 100644
--- a/extensions/vscode/src/extension/VsCodeExtension.ts
+++ b/extensions/vscode/src/extension/VsCodeExtension.ts
@@ -43,13 +43,14 @@ import { ConfigYamlDocumentLinkProvider } from "./ConfigYamlDocumentLinkProvider
import { VsCodeMessenger } from "./VsCodeMessenger";
import { NextEditProvider } from "core/nextEdit/NextEditProvider";
+import { JumpManager } from "../activation/JumpManager";
import setupNextEditWindowManager, {
NextEditWindowManager,
} from "../activation/NextEditWindowManager";
+import { GhostTextAcceptanceTracker } from "../autocomplete/GhostTextAcceptanceTracker";
import { getDefinitionsFromLsp } from "../autocomplete/lsp";
import { handleTextDocumentChange } from "../util/editLoggingUtils";
import type { VsCodeWebviewProtocol } from "../webviewProtocol";
-import { JumpManager } from "../activation/JumpManager";
export class VsCodeExtension {
// Currently some of these are public so they can be used in testing (test/test-suites)
@@ -174,12 +175,14 @@ export class VsCodeExtension {
await NextEditWindowManager.freeTabAndEsc();
JumpManager.getInstance();
+ GhostTextAcceptanceTracker.getInstance();
} else {
NextEditWindowManager.clearInstance();
this.deactivateNextEdit();
await NextEditWindowManager.freeTabAndEsc();
JumpManager.clearInstance();
+ GhostTextAcceptanceTracker.clearInstance();
}
if (configLoadInterrupted) {
@@ -378,13 +381,48 @@ export class VsCodeExtension {
// Listen for editor changes to clean up decorations when editor closes.
vscode.window.onDidChangeVisibleTextEditors(async () => {
// If our active editor is no longer visible, clear decorations.
- NextEditProvider.currentEditChainId = null;
+ console.log(
+ "deleteChain from VsCodeExtension.ts: onDidChangeVisibleTextEditors",
+ );
+ NextEditProvider.getInstance().deleteChain();
});
// Listen for selection changes to hide tooltip when cursor moves.
vscode.window.onDidChangeTextEditorSelection(async (e) => {
- // If the selection changed in our active editor, hide the tooltip.
- NextEditProvider.currentEditChainId = null;
+ console.log("move detected");
+ // Don't delete the chain if:
+
+ // 1. A next edit window was just accepted.
+ if (
+ NextEditWindowManager.isInstantiated() &&
+ NextEditWindowManager.getInstance().hasAccepted()
+ ) {
+ return;
+ }
+
+ // 2. A jump is in progress.
+ if (JumpManager.getInstance().isJumpInProgress()) {
+ return;
+ }
+
+ // 3. A ghost text was just accepted.
+ // Check if this selection change matches our expected ghost text acceptance.
+ const wasGhostTextAccepted =
+ GhostTextAcceptanceTracker.getInstance().checkGhostTextWasAccepted(
+ e.textEditor.document,
+ e.selections[0].active,
+ );
+
+ if (wasGhostTextAccepted) {
+ // Ghost text was accepted - don't delete the chain.
+ return;
+ }
+
+ // Otherwise, delete the chain (for rejection or unrelated movement).
+ console.log(
+ "deleteChain from VsCodeExtension.ts: onDidChangeTextEditorSelection",
+ );
+ NextEditProvider.getInstance().deleteChain();
});
// Refresh index when branch is changed
From a08b4ae3114ff18f65996b143607bd50f660472d Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 18 Jul 2025 20:59:04 -0700
Subject: [PATCH 050/244] chore: test around with rerank
---
core/nextEdit/NextEditEditableRegionCarver.ts | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/core/nextEdit/NextEditEditableRegionCarver.ts b/core/nextEdit/NextEditEditableRegionCarver.ts
index 69a6708e7..d6c831923 100644
--- a/core/nextEdit/NextEditEditableRegionCarver.ts
+++ b/core/nextEdit/NextEditEditableRegionCarver.ts
@@ -96,7 +96,11 @@ async function rerankJump(ctx: {
(a, b) => scores[chunks.indexOf(b)] - scores[chunks.indexOf(a)],
);
- const mostRelevantChunk = chunks[0];
+ // const mostRelevantChunk = chunks[0];
+ // Get the third most relevant chunk if there are enough chunks,
+ // otherwise fallback to second or first.
+ const chunkIndex = Math.min(2, chunks.length - 1);
+ const mostRelevantChunk = chunks[chunkIndex];
// Return the range of the most relevant chunk.
// NOTE: It might be better to return a list of chunks,
From c1322f44adf175e93a306304f820ee12aecbd82c Mon Sep 17 00:00:00 2001
From: uinstinct <61635505+uinstinct@users.noreply.github.com>
Date: Mon, 21 Jul 2025 22:55:14 +0530
Subject: [PATCH 051/244] remove postgres provider
---
.../providers/PostgresContextProvider.ts | 137 ------------------
core/context/providers/index.ts | 2 -
2 files changed, 139 deletions(-)
delete mode 100644 core/context/providers/PostgresContextProvider.ts
diff --git a/core/context/providers/PostgresContextProvider.ts b/core/context/providers/PostgresContextProvider.ts
deleted file mode 100644
index 55c00ae3c..000000000
--- a/core/context/providers/PostgresContextProvider.ts
+++ /dev/null
@@ -1,137 +0,0 @@
-import {
- ContextItem,
- ContextProviderDescription,
- ContextProviderExtras,
- ContextSubmenuItem,
- LoadSubmenuItemsArgs,
-} from "../../index.js";
-import { BaseContextProvider } from "../index.js";
-
-class PostgresContextProvider extends BaseContextProvider {
- static description: ContextProviderDescription = {
- title: "postgres",
- displayTitle: "PostgreSQL",
- description: "Retrieve PostgreSQL table schema and sample rows",
- type: "submenu",
- renderInlineAs: "",
- };
-
- static ALL_TABLES = "__all_tables";
- static DEFAULT_SAMPLE_ROWS = 3;
-
- private async getPool() {
- // @ts-ignore
- const pg = await import("pg");
-
- return new pg.Pool({
- host: this.options.host,
- port: this.options.port,
- user: this.options.user,
- password: this.options.password,
- database: this.options.database,
- });
- }
-
- private async getTableNames(pool: any): Promise {
- const schema = this.options.schema ?? "public";
- let tablesInfoQuery = `
-SELECT table_schema, table_name
-FROM information_schema.tables`;
- if (schema !== null) {
- tablesInfoQuery += ` WHERE table_schema = '${schema}'`;
- }
- const { rows: tablesInfo } = await pool.query(tablesInfoQuery);
- return tablesInfo.map(
- (tableInfo: any) => `${tableInfo.table_schema}.${tableInfo.table_name}`,
- );
- }
-
- async getContextItems(
- query = "",
- _: ContextProviderExtras = {} as ContextProviderExtras,
- ): Promise {
- const pool = await this.getPool();
-
- try {
- const contextItems: ContextItem[] = [];
-
- const tableNames = [];
- if (query === PostgresContextProvider.ALL_TABLES) {
- tableNames.push(...(await this.getTableNames(pool)));
- } else {
- tableNames.push(query);
- }
-
- for (const tableName of tableNames) {
- // Get the table schema
- if (!tableName.includes(".")) {
- throw new Error(
- `Table name must be in format schema.table_name, got ${tableName}`,
- );
- }
- const schemaQuery = `
-SELECT column_name, data_type, character_maximum_length
-FROM INFORMATION_SCHEMA.COLUMNS
-WHERE table_schema = '${tableName.split(".")[0]}'
- AND table_name = '${tableName.split(".")[1]}'`;
- console.log("schemaQuery", schemaQuery);
- const { rows: tableSchema } = await pool.query(schemaQuery);
-
- // Get the sample rows
- const sampleRows =
- this.options.sampleRows ??
- PostgresContextProvider.DEFAULT_SAMPLE_ROWS;
- const { rows: sampleRowResults } = await pool.query(`
-SELECT *
-FROM ${tableName}
-LIMIT ${sampleRows}`);
-
- // Create prompt from the table schema and sample rows
- let prompt = `Postgres schema for database ${this.options.database} table ${tableName}:\n`;
- prompt += `${JSON.stringify(tableSchema, null, 2)}\n\n`;
- prompt += `Sample rows: ${JSON.stringify(sampleRowResults, null, 2)}`;
-
- contextItems.push({
- name: `${this.options.database}-${tableName}-schema-and-sample-rows`,
- description: `Schema and sample rows for table ${tableName}`,
- content: prompt,
- });
- }
-
- return contextItems;
- } catch (error) {
- throw new Error(`Failed to query PostgreSQL database: ${error}`);
- } finally {
- }
- }
-
- async loadSubmenuItems(
- _: LoadSubmenuItemsArgs,
- ): Promise {
- const pool = await this.getPool();
-
- try {
- const contextItems: ContextSubmenuItem[] = [];
- const tableNames = await this.getTableNames(pool);
-
- for (const tableName of tableNames) {
- contextItems.push({
- id: tableName,
- title: tableName,
- description: `Schema from ${tableName} and ${this.options.sampleRows} sample rows.`,
- });
- }
- contextItems.push({
- id: PostgresContextProvider.ALL_TABLES,
- title: "All tables",
- description: `Schema from all tables and ${this.options.sampleRows} sample rows each.`,
- });
-
- return contextItems;
- } catch (error) {
- throw new Error(`Failed to query PostgreSQL database: ${error}`);
- }
- }
-}
-
-export default PostgresContextProvider;
diff --git a/core/context/providers/index.ts b/core/context/providers/index.ts
index 910b16c14..e70f30e55 100644
--- a/core/context/providers/index.ts
+++ b/core/context/providers/index.ts
@@ -24,7 +24,6 @@ import JiraIssuesContextProvider from "./JiraIssuesContextProvider/";
import MCPContextProvider from "./MCPContextProvider";
import OpenFilesContextProvider from "./OpenFilesContextProvider";
import OSContextProvider from "./OSContextProvider";
-import PostgresContextProvider from "./PostgresContextProvider";
import ProblemsContextProvider from "./ProblemsContextProvider";
import RepoMapContextProvider from "./RepoMapContextProvider";
import RulesContextProvider from "./RulesContextProvider";
@@ -56,7 +55,6 @@ export const Providers: (typeof BaseContextProvider)[] = [
DocsContextProvider,
GitLabMergeRequestContextProvider,
JiraIssuesContextProvider,
- PostgresContextProvider,
DatabaseContextProvider,
CodebaseContextProvider,
CodeContextProvider,
From ed194a03f604d163f2af169293318c21d0a1b150 Mon Sep 17 00:00:00 2001
From: uinstinct <61635505+uinstinct@users.noreply.github.com>
Date: Mon, 21 Jul 2025 22:57:15 +0530
Subject: [PATCH 052/244] add deprecation message for postgres
---
.../mainInput/Lump/sections/errors/ErrorSection.tsx | 3 ++-
packages/config-yaml/src/schemas/index.ts | 8 +++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx
index bd06d197d..5ec608f8a 100644
--- a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx
+++ b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx
@@ -2,6 +2,7 @@ import {
ExclamationCircleIcon,
ExclamationTriangleIcon,
} from "@heroicons/react/24/outline";
+import { Remark } from "react-remark";
import { useAppSelector } from "../../../../../redux/hooks";
export function ErrorSection() {
@@ -32,7 +33,7 @@ export function ErrorSection() {
className="m-0 whitespace-pre-wrap text-wrap"
style={{ wordBreak: "break-word" }}
>
- {error.message}
+ {error.message}
))}
diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts
index 4ac2aa1f5..f2c6204db 100644
--- a/packages/config-yaml/src/schemas/index.ts
+++ b/packages/config-yaml/src/schemas/index.ts
@@ -9,7 +9,13 @@ import {
export const contextSchema = z.object({
name: z.string().optional(),
- provider: z.string(),
+ provider: z
+ .string()
+ // postgres context provider deprecation message. to be removed in a later version
+ .regex(/^(?!postgres$).*$/, {
+ message:
+ "The **postgres** context provider is no longer supported. Please use the [Postgres MCP server](https://github.com/crystaldba/postgres-mcp) instead.",
+ }),
params: z.any().optional(),
});
From c3240f898dfcc92389d873348f2704398797aec0 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 21 Jul 2025 15:03:23 -0700
Subject: [PATCH 053/244] fix: use relative cursor position instead of absolute
---
core/nextEdit/diff/diff.ts | 17 +++++---
core/nextEdit/diff/diff.vitest.ts | 40 +++++++++++++++++++
.../src/autocomplete/completionProvider.ts | 10 ++++-
extensions/vscode/src/commands.ts | 12 ++++--
4 files changed, 69 insertions(+), 10 deletions(-)
diff --git a/core/nextEdit/diff/diff.ts b/core/nextEdit/diff/diff.ts
index 91d2eae41..fdcb78fb4 100644
--- a/core/nextEdit/diff/diff.ts
+++ b/core/nextEdit/diff/diff.ts
@@ -172,12 +172,19 @@ export function checkFim(
// Convert cursor position to an offset in the string.
// For simplicity, we need to calculate the cursor's position in the string.
// This requires knowledge of line endings in the oldEditRange.
- const lines = oldEditRange.substring(0, prefixLength).split("\n");
+ // const lines = oldEditRange.substring(0, prefixLength).split("\n");
+ // const lines = oldEditRange.split("\n");
+ // const cursorOffset =
+ // lines.length > 1
+ // ? lines.slice(0, -1).reduce((sum, line) => sum + line.length + 1, 0) +
+ // cursorPosition.character
+ // : cursorPosition.character;
+ const oldEditLines = oldEditRange.split("\n");
const cursorOffset =
- lines.length > 1
- ? lines.slice(0, -1).reduce((sum, line) => sum + line.length + 1, 0) +
- cursorPosition.character
- : cursorPosition.character;
+ oldEditLines
+ .slice(0, cursorPosition.line)
+ .reduce((sum, line) => sum + line.length + 1, 0) +
+ cursorPosition.character;
// Check if the cursor is positioned between the prefix and suffix.
const cursorBetweenPrefixAndSuffix =
diff --git a/core/nextEdit/diff/diff.vitest.ts b/core/nextEdit/diff/diff.vitest.ts
index fa161d49c..706fed14c 100644
--- a/core/nextEdit/diff/diff.vitest.ts
+++ b/core/nextEdit/diff/diff.vitest.ts
@@ -79,6 +79,46 @@ describe("checkFim", () => {
"const data = fetchData();\n const result = processData(data);",
},
},
+ {
+ name: "interesting case",
+ oldEditRange: [" }", "}", ""].join("\n"),
+ newEditRange: [" }", "}", "", "module.exports = Calculator;"].join("\n"),
+ cursorPosition: { line: 0, character: 0 },
+ expected: {
+ isFim: false,
+ fimText: null,
+ },
+ },
+ {
+ name: "calculator.js divide",
+ oldEditRange: [
+ " ",
+ " if (number === 0) {",
+ ' throw new Error("Cannot divide by zero");',
+ " }",
+ " this.result /= number;",
+ " return this;",
+ ].join("\n"),
+ newEditRange: [
+ " if (typeof number !== 'number') {",
+ ' throw new Error("Invalid input: must be a number");',
+ " }",
+ " if (number === 0) {",
+ ' throw new Error("Cannot divide by zero");',
+ " }",
+ " this.result /= number;",
+ " return this;",
+ ].join("\n"),
+ cursorPosition: { line: 0, character: 4 },
+ expected: {
+ isFim: true,
+ fimText: [
+ "if (typeof number !== 'number') {",
+ ' throw new Error("Invalid input: must be a number");',
+ " }",
+ ].join("\n"),
+ },
+ },
];
testCases.forEach(
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index eae812873..862ea83d7 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -470,12 +470,19 @@ export class ContinueCompletionProvider
return undefined;
}
+ // Create a cursor position relative to the edit range slice.
+ const relativeCursorPos = {
+ line: currCursorPos.line - editableRegionStartLine,
+ character: currCursorPos.character,
+ };
+
// If the diff is a FIM, render a ghost text.
const { isFim, fimText } = checkFim(
oldEditRangeSlice,
newEditRangeSlice,
- currCursorPos,
+ relativeCursorPos,
);
+
if (isFim) {
if (!fimText) {
console.log("deleteChain from completionProvider.ts: !fimText");
@@ -504,6 +511,7 @@ export class ContinueCompletionProvider
arguments: [input.completionId, this.nextEditLoggingService], // TODO: this may have to be this.completionProvider.
},
);
+ console.log(nextEditCompletionItem);
return [nextEditCompletionItem];
}
diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts
index 693fbd9aa..25f5f0487 100644
--- a/extensions/vscode/src/commands.ts
+++ b/extensions/vscode/src/commands.ts
@@ -820,7 +820,7 @@ const getCommandsMap: (
// NOTE: This could use some cleanup or abstraction.
// The logic is largely similar to that of completionProvider.ts
// but we don't have access to the class.
-
+ console.log("continue.showNextEditAfterJump");
const { completionId, outcome, currentPosition } = data;
const editor = vscode.window.activeTextEditor;
@@ -863,11 +863,15 @@ const getCommandsMap: (
return;
}
- // Check if this is a simple "fill in middle" (FIM) type edit.
+ // Create a cursor position relative to the edit range slice
+ const relativeCursorPos = {
+ line: currentPosition.line - editableRegionStartLine,
+ character: currentPosition.character,
+ };
const { isFim, fimText } = checkFim(
oldEditRangeSlice,
newEditRangeSlice,
- currentPosition,
+ relativeCursorPos,
);
if (isFim) {
@@ -898,7 +902,7 @@ const getCommandsMap: (
// Show the ghost text using VS Code's inline completion API.
// We need to trigger this manually since we're not in the completion provider.
await vscode.commands.executeCommand(
- "editor.action.inlineCompletions.showNext",
+ "editor.action.inlineSuggest.trigger",
{
completions: [nextEditCompletionItem],
position: currentPosition,
From 281a79a1fc8a907ffb30037984d9a55a8f2df462 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 21 Jul 2025 15:03:37 -0700
Subject: [PATCH 054/244] chore: remove print
---
extensions/vscode/src/commands.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts
index 25f5f0487..70a602a0f 100644
--- a/extensions/vscode/src/commands.ts
+++ b/extensions/vscode/src/commands.ts
@@ -820,7 +820,7 @@ const getCommandsMap: (
// NOTE: This could use some cleanup or abstraction.
// The logic is largely similar to that of completionProvider.ts
// but we don't have access to the class.
- console.log("continue.showNextEditAfterJump");
+
const { completionId, outcome, currentPosition } = data;
const editor = vscode.window.activeTextEditor;
From f9c4baa91f900bc96a36e0027afefc84fd5bae70 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 21 Jul 2025 16:07:30 -0700
Subject: [PATCH 055/244] refactor: rename file and update imports
---
...bleRegionCarver.ts => NextEditEditableRegionCalculator.ts} | 3 +++
core/nextEdit/NextEditPrefetchQueue.ts | 2 +-
core/nextEdit/NextEditProvider.ts | 2 +-
core/nextEdit/templating/NextEditPromptEngine.ts | 2 +-
extensions/vscode/src/activation/JumpManager.ts | 4 ++++
5 files changed, 10 insertions(+), 3 deletions(-)
rename core/nextEdit/{NextEditEditableRegionCarver.ts => NextEditEditableRegionCalculator.ts} (98%)
diff --git a/core/nextEdit/NextEditEditableRegionCarver.ts b/core/nextEdit/NextEditEditableRegionCalculator.ts
similarity index 98%
rename from core/nextEdit/NextEditEditableRegionCarver.ts
rename to core/nextEdit/NextEditEditableRegionCalculator.ts
index d6c831923..18aa52c0e 100644
--- a/core/nextEdit/NextEditEditableRegionCarver.ts
+++ b/core/nextEdit/NextEditEditableRegionCalculator.ts
@@ -99,6 +99,9 @@ async function rerankJump(ctx: {
// const mostRelevantChunk = chunks[0];
// Get the third most relevant chunk if there are enough chunks,
// otherwise fallback to second or first.
+ // The most relevant chunk seems to be the one that
+ // is similar enough lexically,
+ // but different enough to still justify making an edit.
const chunkIndex = Math.min(2, chunks.length - 1);
const mostRelevantChunk = chunks[chunkIndex];
diff --git a/core/nextEdit/NextEditPrefetchQueue.ts b/core/nextEdit/NextEditPrefetchQueue.ts
index 99fff2b35..43b8697e4 100644
--- a/core/nextEdit/NextEditPrefetchQueue.ts
+++ b/core/nextEdit/NextEditPrefetchQueue.ts
@@ -3,7 +3,7 @@ import { HelperVars } from "../autocomplete/util/HelperVars";
import { findChangedLineRanges, myersDiff } from "../diff/myers";
import { PrefetchQueue } from "../util/PrefetchQueue";
import { applyCompletionToFile } from "./diff/diff";
-import { EditableRegionStrategy } from "./NextEditEditableRegionCarver";
+import { EditableRegionStrategy } from "./NextEditEditableRegionCalculator";
import { NextEditProvider } from "./NextEditProvider";
import { NextEditOutcome } from "./types";
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index 29a91c62d..a1163aaf9 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -33,7 +33,7 @@ import {
calculateFinalCursorPosition,
getOffsetPositionAtLastNewLine,
} from "./diff/diff.js";
-import { EditableRegionStrategy } from "./NextEditEditableRegionCarver.js";
+import { EditableRegionStrategy } from "./NextEditEditableRegionCalculator.js";
import { NextEditLoggingService } from "./NextEditLoggingService.js";
import { NextEditPrefetchQueue } from "./NextEditPrefetchQueue.js";
import {
diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts
index 5efb341ce..98ae5db3e 100644
--- a/core/nextEdit/templating/NextEditPromptEngine.ts
+++ b/core/nextEdit/templating/NextEditPromptEngine.ts
@@ -13,7 +13,7 @@ import { createDiff, DiffFormatType } from "../context/diffFormatting";
import {
EditableRegionStrategy,
getNextEditableRegion,
-} from "../NextEditEditableRegionCarver";
+} from "../NextEditEditableRegionCalculator";
import {
NextEditOutcome,
NextEditTemplate,
diff --git a/extensions/vscode/src/activation/JumpManager.ts b/extensions/vscode/src/activation/JumpManager.ts
index 1d180c072..9ed09851c 100644
--- a/extensions/vscode/src/activation/JumpManager.ts
+++ b/extensions/vscode/src/activation/JumpManager.ts
@@ -314,5 +314,9 @@ export class JumpManager {
setCompletionAfterJump(completionData: CompletionDataForAfterJump): void {
this._completionAfterJump = completionData;
+ console.log(
+ "setCompletionAfterJump: saved",
+ JSON.stringify(completionData, null, 2),
+ );
}
}
From 8fa0bfaea63761bab4eb9c999f07b6d10b6e8221 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 21 Jul 2025 16:08:38 -0700
Subject: [PATCH 056/244] refactor: remove unused methods
---
.../NextEditEditableRegionCalculator.ts | 206 ------------------
1 file changed, 206 deletions(-)
diff --git a/core/nextEdit/NextEditEditableRegionCalculator.ts b/core/nextEdit/NextEditEditableRegionCalculator.ts
index 18aa52c0e..b5d9fa634 100644
--- a/core/nextEdit/NextEditEditableRegionCalculator.ts
+++ b/core/nextEdit/NextEditEditableRegionCalculator.ts
@@ -1,11 +1,8 @@
import { Chunk, ILLM, RangeInFile } from "..";
-import { cosineSimilarity } from "../context/retrieval/pipelines/NextEditRetrievalPipeline";
export enum EditableRegionStrategy {
Naive = "naive",
Rerank = "rerank",
- Model = "model",
- Sliding = "sliding",
}
export async function getNextEditableRegion(
@@ -17,10 +14,6 @@ export async function getNextEditableRegion(
return naiveJump(ctx);
case EditableRegionStrategy.Rerank:
return await rerankJump(ctx);
- case EditableRegionStrategy.Model:
- return modelJump(ctx);
- case EditableRegionStrategy.Sliding:
- return slidingJump(ctx);
default:
return null;
}
@@ -124,202 +117,3 @@ async function rerankJump(ctx: {
return null;
}
}
-
-// A naive jump uses the next edit model to predict edits for the entire file.
-// Then it calculates the diff between that and the original to get the jump location.
-function modelJump(ctx: any): RangeInFile | null {
- try {
- const { fileContent, predictedContent, filepath } = ctx;
-
- if (!fileContent || !predictedContent || !filepath) {
- console.warn("Missing required context for model jump");
- return null;
- }
-
- const originalLines = fileContent.split("\n");
- const predictedLines = predictedContent.split("\n");
-
- // Find the first line that differs.
- for (
- let i = 0;
- i < Math.min(originalLines.length, predictedLines.length);
- i++
- ) {
- if (originalLines[i] !== predictedLines[i]) {
- // Calculate the end of the differing section (find where they align again).
- let endLine = i;
- while (
- endLine < Math.min(originalLines.length, predictedLines.length) &&
- originalLines[endLine] !== predictedLines[endLine]
- ) {
- endLine++;
- }
-
- // Return a range that covers the differences.
- return {
- filepath,
- range: {
- start: { line: i, character: 0 },
- end: {
- line: Math.min(endLine, originalLines.length - 1),
- character:
- originalLines[Math.min(endLine, originalLines.length - 1)]
- .length,
- },
- },
- };
- }
- }
-
- // If no difference found but files have different lengths,
- if (originalLines.length !== predictedLines.length) {
- const diffStartLine = Math.min(
- originalLines.length,
- predictedLines.length,
- );
- return {
- filepath,
- range: {
- start: { line: diffStartLine, character: 0 },
- end: {
- line: originalLines.length - 1,
- character: originalLines.at(-1).length,
- },
- },
- };
- }
-
- // No differences found.
- return null;
- } catch (error) {
- console.error("Error in model jump:", error);
- return null;
- }
-}
-
-// A sliding jump uses a sliding window to split the current file into zones.
-// Then each zone is ranked on how similar it is to the model's next edit prediction.
-function slidingJump(ctx: any): RangeInFile | null {
- try {
- const { fileContent, predictedContent, filepath, windowSize = 5 } = ctx;
-
- if (!fileContent || !predictedContent || !filepath) {
- console.warn("Missing required context for sliding jump");
- return null;
- }
-
- const originalLines = fileContent.split("\n");
- const predictedLines = predictedContent.split("\n");
-
- // Create sliding windows/zones from the file.
- const zones: Array<{
- startLine: number;
- endLine: number;
- similarity: number;
- }> = [];
-
- for (
- let i = 0;
- i <= originalLines.length - windowSize;
- i += Math.floor(windowSize / 2)
- ) {
- const originalWindow = originalLines.slice(i, i + windowSize).join("\n");
-
- // For each zone, find the most similar section in the predicted content.
- let highestSimilarity = 0;
-
- for (
- let j = 0;
- j <= predictedLines.length - windowSize;
- j += Math.floor(windowSize / 2)
- ) {
- const predictedWindow = predictedLines
- .slice(j, j + windowSize)
- .join("\n");
-
- // Convert to simple vector representation for similarity calculation.
- const originalVector = createSimpleVector(originalWindow);
- const predictedVector = createSimpleVector(predictedWindow);
-
- const similarity = cosineSimilarity(originalVector, predictedVector);
-
- if (similarity > highestSimilarity) {
- highestSimilarity = similarity;
- }
- }
-
- zones.push({
- startLine: i,
- endLine: Math.min(i + windowSize - 1, originalLines.length - 1),
- similarity: highestSimilarity,
- });
- }
-
- // Find the zone with the highest similarity score.
- const mostSimilarZone = zones.reduce((prev, current) =>
- prev.similarity > current.similarity ? prev : current,
- );
-
- // Return the range of the most similar zone.
- return {
- filepath,
- range: {
- start: { line: mostSimilarZone.startLine, character: 0 },
- end: {
- line: mostSimilarZone.endLine,
- character: originalLines[mostSimilarZone.endLine].length,
- },
- },
- };
- } catch (error) {
- console.error("Error in sliding jump:", error);
- return null;
- }
-}
-
-// Helper method to create a simple vector representation of a text string.
-function createSimpleVector(text: string): number[] {
- const tokenFrequency: Record = {};
-
- // Split text into tokens.
- const tokens = text
- .toLowerCase()
- .split(/[\s.,\/#!$%\^&\*;:{}=\-_`~()\[\]]/g)
- .map((s) => s.trim())
- .filter((s) => s.length > 0);
-
- // Count frequency of each token.
- for (const token of tokens) {
- tokenFrequency[token] = (tokenFrequency[token] || 0) + 1;
- }
-
- // Create a fixed-dimension vector (using common programming keywords as dimensions).
- const dimensions = [
- "function",
- "return",
- "if",
- "else",
- "for",
- "while",
- "const",
- "let",
- "var",
- "class",
- "import",
- "export",
- "interface",
- "type",
- "new",
- "this",
- "try",
- "catch",
- "async",
- "await",
- "true",
- "false",
- "null",
- "undefined",
- ];
-
- return dimensions.map((dim) => tokenFrequency[dim] || 0);
-}
From 3651d626a8e7a6f63dc6ddfe971753408ba01d1a Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 21 Jul 2025 16:12:43 -0700
Subject: [PATCH 057/244] fix: prettier
---
core/util/PrefetchQueue.ts | 3 ---
1 file changed, 3 deletions(-)
diff --git a/core/util/PrefetchQueue.ts b/core/util/PrefetchQueue.ts
index 360c6bf82..91a240dcc 100644
--- a/core/util/PrefetchQueue.ts
+++ b/core/util/PrefetchQueue.ts
@@ -1,5 +1,3 @@
-import { NextEditProvider } from "../nextEdit/NextEditProvider";
-
export class PrefetchQueue {
protected promiseQueue: Promise[] = [];
protected resourceQueue: R[];
@@ -86,4 +84,3 @@ export class PrefetchQueue {
return this.resourceQueue.length;
}
}
-
From 153e97458ea7dd21f696a414edbe360a8acd8eea Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 21 Jul 2025 16:28:18 -0700
Subject: [PATCH 058/244] fix: undefined field error
---
core/nextEdit/NextEditPrefetchQueue.ts | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/core/nextEdit/NextEditPrefetchQueue.ts b/core/nextEdit/NextEditPrefetchQueue.ts
index 43b8697e4..54a43bc29 100644
--- a/core/nextEdit/NextEditPrefetchQueue.ts
+++ b/core/nextEdit/NextEditPrefetchQueue.ts
@@ -4,7 +4,6 @@ import { findChangedLineRanges, myersDiff } from "../diff/myers";
import { PrefetchQueue } from "../util/PrefetchQueue";
import { applyCompletionToFile } from "./diff/diff";
import { EditableRegionStrategy } from "./NextEditEditableRegionCalculator";
-import { NextEditProvider } from "./NextEditProvider";
import { NextEditOutcome } from "./types";
export class NextEditPrefetchQueue extends PrefetchQueue<
@@ -100,7 +99,7 @@ export class NextEditPrefetchQueue extends PrefetchQueue<
const currentPromise = this.promiseQueue.shift()!;
if (this.promiseQueue.length === 0) {
- NextEditProvider.currentEditChainId = null;
+ // NextEditProvider.currentEditChainId = null;
}
return await currentPromise;
@@ -127,7 +126,7 @@ export class NextEditPrefetchQueue extends PrefetchQueue<
this.promiseQueue.push(nextPromise);
} else if (this.promiseQueue.length === 0) {
// No more items in the queue and no more resources
- NextEditProvider.currentEditChainId = null;
+ // NextEditProvider.currentEditChainId = null;
}
// console.log("currentData:", currentData);
From 4af947dd250bb229ed0f87fe237c63a4860c4815 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 21 Jul 2025 16:33:08 -0700
Subject: [PATCH 059/244] refactor: update package imports
---
extensions/vscode/src/autocomplete/completionProvider.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 862ea83d7..1ea7fa29c 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -24,7 +24,7 @@ import { checkFim } from "core/nextEdit/diff/diff";
import {
EditableRegionStrategy,
getNextEditableRegion,
-} from "core/nextEdit/NextEditEditableRegionCarver";
+} from "core/nextEdit/NextEditEditableRegionCalculator";
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
import { NextEditProvider } from "core/nextEdit/NextEditProvider";
import { NextEditOutcome } from "core/nextEdit/types";
From 4746edf06a3bd2265f2bed933460c03476292132 Mon Sep 17 00:00:00 2001
From: Nate
Date: Mon, 21 Jul 2025 19:51:40 -0700
Subject: [PATCH 060/244] fix: remove !
---
extensions/vscode/src/activation/activate.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts
index 40ae55235..66a665221 100644
--- a/extensions/vscode/src/activation/activate.ts
+++ b/extensions/vscode/src/activation/activate.ts
@@ -13,7 +13,7 @@ import setupInlineTips from "./InlineTipManager";
export async function activateExtension(context: vscode.ExtensionContext) {
const platformCheck = isUnsupportedPlatform();
- if (!platformCheck.isUnsupported) {
+ if (platformCheck.isUnsupported) {
// const platformTarget = `${getPlatform()}-${getArchitecture()}`;
const platformTarget = "windows-arm64";
From 885c9e19ec01e9c5e938fe267f50d163996278ae Mon Sep 17 00:00:00 2001
From: Nate
Date: Mon, 21 Jul 2025 19:52:37 -0700
Subject: [PATCH 061/244] avoid warnigns unless we are sure it's an unsupported
platform
---
extensions/vscode/src/util/util.ts | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/extensions/vscode/src/util/util.ts b/extensions/vscode/src/util/util.ts
index 00316abc5..759c79b4a 100644
--- a/extensions/vscode/src/util/util.ts
+++ b/extensions/vscode/src/util/util.ts
@@ -111,12 +111,12 @@ export function isUnsupportedPlatform(): {
};
}
- if (platform === "unknown" || arch === "unknown") {
- return {
- isUnsupported: true,
- reason: `Unsupported platform combination: ${os.platform()}-${os.arch()}. Continue extension supports Windows x64, macOS (Intel/Apple Silicon), and Linux (x64/ARM64).`,
- };
- }
+ // if (platform === "unknown" || arch === "unknown") {
+ // return {
+ // isUnsupported: true,
+ // reason: `Unsupported platform combination: ${os.platform()}-${os.arch()}. Continue extension supports Windows x64, macOS (Intel/Apple Silicon), and Linux (x64/ARM64).`,
+ // };
+ // }
return { isUnsupported: false };
}
From 98e41cdccc302cf5fa419b62d50fbedb012d71d1 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 22 Jul 2025 13:12:11 -0700
Subject: [PATCH 062/244] feat: add getDocumentSymbols LSP method
---
core/config/types.ts | 1 +
core/index.d.ts | 54 +++++++++++
core/protocol/ide.ts | 2 +
core/protocol/messenger/messageIde.ts | 7 ++
core/util/filesystem.ts | 5 +
.../continue/IntelliJIde.kt | 4 +
.../continueintellijextension/types.kt | 8 ++
extensions/vscode/src/VsCodeIde.ts | 14 ++-
extensions/vscode/src/autocomplete/lsp.ts | 95 ++++++++++++++++++-
.../vscode/src/extension/VsCodeMessenger.ts | 4 +
10 files changed, 192 insertions(+), 2 deletions(-)
diff --git a/core/config/types.ts b/core/config/types.ts
index 25ae3247a..9fd2720f1 100644
--- a/core/config/types.ts
+++ b/core/config/types.ts
@@ -746,6 +746,7 @@ declare global {
// LSP
gotoDefinition(location: Location): Promise;
getReferences(location: Location): Promise;
+ getDocumentSymbols(textDocumentIdentifier: string): Promise;
// Callbacks
onDidChangeActiveTextEditor(callback: (filepath: string) => void): void;
diff --git a/core/index.d.ts b/core/index.d.ts
index 99f1cd6cd..f026c17c2 100644
--- a/core/index.d.ts
+++ b/core/index.d.ts
@@ -872,6 +872,7 @@ export interface IDE {
// LSP
gotoDefinition(location: Location): Promise;
getReferences(location: Location): Promise;
+ getDocumentSymbols(textDocumentIdentifier: string): Promise;
// Callbacks
onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void;
@@ -1722,3 +1723,56 @@ export interface CompiledMessagesResult {
export interface MessageOption {
precompiled: boolean;
}
+
+/* LSP-specific interfaces. */
+
+// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#symbolKind.
+// We shift this one index down to match vscode.SymbolKind.
+export enum SymbolKind {
+ File = 0,
+ Module = 1,
+ Namespace = 2,
+ Package = 3,
+ Class = 4,
+ Method = 5,
+ Property = 6,
+ Field = 7,
+ Constructor = 8,
+ Enum = 9,
+ Interface = 10,
+ Function = 11,
+ Variable = 12,
+ Constant = 13,
+ String = 14,
+ Number = 15,
+ Boolean = 16,
+ Array = 17,
+ Object = 18,
+ Key = 19,
+ Null = 20,
+ EnumMember = 21,
+ Struct = 22,
+ Event = 23,
+ Operator = 24,
+ TypeParameter = 25,
+}
+
+// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#symbolTag.
+export namespace SymbolTag {
+ export const Deprecated: 1 = 1;
+}
+
+// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#symbolTag.
+export type SymbolTag = 1;
+
+// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#documentSymbol.
+export interface DocumentSymbol {
+ name: string;
+ detail?: string;
+ kind: SymbolKind;
+ tags?: SymbolTag[];
+ deprecated?: boolean;
+ range: Range;
+ selectionRange: Range;
+ children?: DocumentSymbol[];
+}
diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts
index ed108ba9b..49030e8a5 100644
--- a/core/protocol/ide.ts
+++ b/core/protocol/ide.ts
@@ -1,5 +1,6 @@
import type {
ContinueRcJson,
+ DocumentSymbol,
FileStatsMap,
FileType,
IDE,
@@ -83,6 +84,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
gotoDefinition: [{ location: Location }, RangeInFile[]];
getReferences: [{ location: Location }, RangeInFile[]];
+ getDocumentSymbols: [{ textDocumentIdentifier: string }, DocumentSymbol[]];
getControlPlaneSessionInfo: [
{ silent: boolean; useOnboarding: boolean },
diff --git a/core/protocol/messenger/messageIde.ts b/core/protocol/messenger/messageIde.ts
index de1ed3ecc..bb72b8d63 100644
--- a/core/protocol/messenger/messageIde.ts
+++ b/core/protocol/messenger/messageIde.ts
@@ -3,6 +3,7 @@ import { ToIdeFromWebviewOrCoreProtocol } from "../ide";
import type {
ContinueRcJson,
+ DocumentSymbol,
FileStatsMap,
FileType,
IDE,
@@ -49,6 +50,12 @@ export class MessageIde implements IDE {
return this.request("getReferences", { location });
}
+ async getDocumentSymbols(
+ textDocumentIdentifier: string,
+ ): Promise {
+ return this.request("getDocumentSymbols", { textDocumentIdentifier });
+ }
+
onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void {
this.on("didChangeActiveTextEditor", (data) => callback(data.filepath));
}
diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts
index 7a9a08f8c..b0fa43f78 100644
--- a/core/util/filesystem.ts
+++ b/core/util/filesystem.ts
@@ -3,6 +3,7 @@ import * as fs from "node:fs";
import { fileURLToPath } from "node:url";
import {
ContinueRcJson,
+ DocumentSymbol,
FileStatsMap,
FileType,
IDE,
@@ -48,6 +49,10 @@ class FileSystemIde implements IDE {
return Promise.resolve([]);
}
+ getDocumentSymbols(fileUri: string): Promise {
+ return Promise.resolve([]);
+ }
+
onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void {
return;
}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt
index 58b8de1a9..5a3778d30 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt
@@ -598,6 +598,10 @@ class IntelliJIDE(
throw NotImplementedError("getReferences not implemented yet")
}
+ override suspend fun getDocumentSymbols(textDocumentIdentifier: String): List {
+ throw NotImplementedError("getDocumentSymbols not implemented yet")
+ }
+
override fun onDidChangeActiveTextEditor(callback: (filepath: String) -> Unit) {
throw NotImplementedError("onDidChangeActiveTextEditor not implemented yet")
}
diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt
index 6d16351cf..3566bf345 100644
--- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt
+++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt
@@ -64,6 +64,13 @@ data class RangeInFileWithContents(
val contents: String
)
+data class DocumentSymbol(
+ val name: String,
+ val kind: String,
+ val range: Range,
+ val selectionRange: Range
+)
+
data class ControlPlaneSessionInfo(
val accessToken: String,
val account: Account
@@ -193,6 +200,7 @@ interface IDE {
// LSP
suspend fun gotoDefinition(location: Location): List
suspend fun getReferences(location: Location): List
+ suspend fun getDocumentSymbols(textDocumentIdentifier: String): List
// Callbacks
fun onDidChangeActiveTextEditor(callback: (filepath: String) -> Unit)
diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts
index b6f1cea7d..43be229e3 100644
--- a/extensions/vscode/src/VsCodeIde.ts
+++ b/extensions/vscode/src/VsCodeIde.ts
@@ -6,7 +6,7 @@ import { EXTENSION_NAME } from "core/control-plane/env";
import * as URI from "uri-js";
import * as vscode from "vscode";
-import { executeGotoProvider } from "./autocomplete/lsp";
+import { executeGotoProvider, executeSymbolProvider } from "./autocomplete/lsp";
import { Repository } from "./otherExtensions/git";
import { SecretStorage } from "./stubs/SecretStorage";
import { VsCodeIdeUtils } from "./util/ideUtils";
@@ -15,6 +15,7 @@ import { VsCodeWebviewProtocol } from "./webviewProtocol";
import type {
ContinueRcJson,
+ DocumentSymbol,
FileStatsMap,
FileType,
IDE,
@@ -98,6 +99,17 @@ class VsCodeIde implements IDE {
return result;
}
+ async getDocumentSymbols(
+ textDocumentIdentifier: string, // uri
+ ): Promise {
+ const result = await executeSymbolProvider({
+ uri: vscode.Uri.parse(textDocumentIdentifier),
+ name: "vscode.executeDocumentSymbolProvider"
+ });
+
+ return result;
+ }
+
onDidChangeActiveTextEditor(callback: (uri: string) => void): void {
vscode.window.onDidChangeActiveTextEditor((editor) => {
if (editor) {
diff --git a/extensions/vscode/src/autocomplete/lsp.ts b/extensions/vscode/src/autocomplete/lsp.ts
index a6900291a..fbf69932d 100644
--- a/extensions/vscode/src/autocomplete/lsp.ts
+++ b/extensions/vscode/src/autocomplete/lsp.ts
@@ -13,7 +13,13 @@ import { intersection } from "core/util/ranges";
import * as URI from "uri-js";
import * as vscode from "vscode";
-import type { IDE, Range, RangeInFile, RangeInFileWithContents } from "core";
+import type {
+ DocumentSymbol,
+ IDE,
+ Range,
+ RangeInFile,
+ RangeInFileWithContents,
+} from "core";
import type Parser from "web-tree-sitter";
type GotoProviderName =
@@ -382,3 +388,90 @@ export const getDefinitionsFromLsp: GetLspDefinitionsFunction = async (
return [];
}
};
+
+type SymbolProviderName = "vscode.executeDocumentSymbolProvider";
+
+interface SymbolInput {
+ uri: vscode.Uri;
+ name: SymbolProviderName;
+}
+
+function symbolInputKey(input: SymbolInput) {
+ return `${input.name}${input.uri.toString()}`;
+}
+
+const MAX_SYMBOL_CACHE_SIZE = 100;
+const symbolCache = new Map();
+
+export async function executeSymbolProvider(
+ input: SymbolInput,
+): Promise {
+ const cacheKey = symbolInputKey(input);
+ const cached = symbolCache.get(cacheKey);
+ if (cached) {
+ return cached;
+ }
+
+ try {
+ const symbols = (await vscode.commands.executeCommand(
+ input.name,
+ input.uri,
+ // )) as vscode.DocumentSymbol[] | vscode.SymbolInformation[];
+ )) as vscode.DocumentSymbol[];
+
+ const results: DocumentSymbol[] = [];
+
+ // Handle both possible return types from the symbol provider
+ if (symbols.length > 0) {
+ // if ("location" in symbols[0]) {
+ // // SymbolInformation type
+ // results.push(
+ // ...symbols.map((s: vscode.SymbolInformation) => ({
+ // filepath: s.location.uri.toString(),
+ // range: s.location.range,
+ // })),
+ // );
+ // } else {
+ // DocumentSymbol type - collect symbols recursively
+ function collectSymbols(
+ symbols: vscode.DocumentSymbol[],
+ uri: vscode.Uri,
+ ): DocumentSymbol[] {
+ const result: DocumentSymbol[] = [];
+ for (const symbol of symbols) {
+ result.push({
+ name: symbol.name,
+ range: symbol.range,
+ selectionRange: symbol.selectionRange,
+ kind: symbol.kind,
+ });
+
+ if (symbol.children && symbol.children.length > 0) {
+ result.push(...collectSymbols(symbol.children, uri));
+ }
+ }
+ return result;
+ }
+
+ results.push(
+ ...collectSymbols(symbols as vscode.DocumentSymbol[], input.uri),
+ );
+ // }
+ }
+
+ // Add to cache
+ if (symbolCache.size >= MAX_SYMBOL_CACHE_SIZE) {
+ // Remove the oldest item from the cache
+ const oldestKey = symbolCache.keys().next().value;
+ if (oldestKey) {
+ symbolCache.delete(oldestKey);
+ }
+ }
+ symbolCache.set(cacheKey, results);
+
+ return results;
+ } catch (e) {
+ console.warn(`Error executing ${input.name}:`, e);
+ return [];
+ }
+}
diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts
index 7f9158da5..a114a542c 100644
--- a/extensions/vscode/src/extension/VsCodeMessenger.ts
+++ b/extensions/vscode/src/extension/VsCodeMessenger.ts
@@ -394,6 +394,10 @@ export class VsCodeMessenger {
return await ide.getReferences(msg.data.location);
});
+ this.onWebviewOrCore("getDocumentSymbols", async (msg) => {
+ return await ide.getDocumentSymbols(msg.data.textDocumentIdentifier);
+ });
+
this.onWebviewOrCore("getFileStats", async (msg) => {
return await ide.getFileStats(msg.data.files);
});
From b1946329aebcf7b322435b112db4b6a01ba3df30 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 22 Jul 2025 13:12:24 -0700
Subject: [PATCH 063/244] feat: save NextEditOutcome instead of string
---
core/nextEdit/NextEditProvider.ts | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index a1163aaf9..c84a76bba 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -70,7 +70,7 @@ export class NextEditProvider {
private prefetchQueue: NextEditPrefetchQueue;
// private refQueue: RangeInFile[] = [];
private currentEditChainId: string | null = null;
- private previousCompletions: string[] = [];
+ private previousCompletions: NextEditOutcome[] = [];
private constructor(
private readonly configHandler: ConfigHandler,
@@ -322,7 +322,7 @@ export class NextEditProvider {
return this.currentEditChainId !== null;
}
- public getPreviousCompletion(): string | null {
+ public getPreviousCompletion(): NextEditOutcome | null {
return this.previousCompletions[0];
}
@@ -481,7 +481,7 @@ export class NextEditProvider {
).replace(/\n$/, "")
: "";
- this.previousCompletions.push(nextCompletion);
+ // this.previousCompletions.push(nextCompletion);
const currCursorPos = helper.pos;
const editableRegionStartLine = Math.max(
@@ -530,6 +530,8 @@ export class NextEditProvider {
...helper.options,
};
+ this.previousCompletions.push(outcomeNext);
+
// When using the JetBrains extension, mark as displayed.
// This helps us not need to make additional network calls just to mark as displayed.
const ideType = (await this.ide.getIdeInfo()).ideType;
From b4b126ca082d55ebc52f89e5e99585235ea16fbf Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 22 Jul 2025 13:12:37 -0700
Subject: [PATCH 064/244] chore: remove console.logs
---
extensions/vscode/src/extension/VsCodeExtension.ts | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts
index 2cb2faeee..4983583ab 100644
--- a/extensions/vscode/src/extension/VsCodeExtension.ts
+++ b/extensions/vscode/src/extension/VsCodeExtension.ts
@@ -386,15 +386,15 @@ export class VsCodeExtension {
// Listen for editor changes to clean up decorations when editor closes.
vscode.window.onDidChangeVisibleTextEditors(async () => {
// If our active editor is no longer visible, clear decorations.
- console.log(
- "deleteChain from VsCodeExtension.ts: onDidChangeVisibleTextEditors",
- );
+ // console.log(
+ // "deleteChain from VsCodeExtension.ts: onDidChangeVisibleTextEditors",
+ // );
NextEditProvider.getInstance().deleteChain();
});
// Listen for selection changes to hide tooltip when cursor moves.
vscode.window.onDidChangeTextEditorSelection(async (e) => {
- console.log("move detected");
+ // console.log("move detected");
// Don't delete the chain if:
// 1. A next edit window was just accepted.
From 517837226fa78d3eb9f44280d247ca9b118727d2 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 22 Jul 2025 13:13:06 -0700
Subject: [PATCH 065/244] feat: add a static-based jump method
---
.../NextEditEditableRegionCalculator.ts | 428 +++++++++++++++++-
.../src/autocomplete/completionProvider.ts | 42 +-
2 files changed, 465 insertions(+), 5 deletions(-)
diff --git a/core/nextEdit/NextEditEditableRegionCalculator.ts b/core/nextEdit/NextEditEditableRegionCalculator.ts
index b5d9fa634..9d159f74b 100644
--- a/core/nextEdit/NextEditEditableRegionCalculator.ts
+++ b/core/nextEdit/NextEditEditableRegionCalculator.ts
@@ -1,8 +1,11 @@
-import { Chunk, ILLM, RangeInFile } from "..";
+import Parser from "web-tree-sitter";
+import { Chunk, IDE, ILLM, Position, Range, RangeInFile } from "..";
+import { getAst } from "../autocomplete/util/ast";
export enum EditableRegionStrategy {
Naive = "naive",
Rerank = "rerank",
+ Static = "static",
}
export async function getNextEditableRegion(
@@ -14,6 +17,8 @@ export async function getNextEditableRegion(
return naiveJump(ctx);
case EditableRegionStrategy.Rerank:
return await rerankJump(ctx);
+ case EditableRegionStrategy.Static:
+ return await staticJump(ctx);
default:
return null;
}
@@ -117,3 +122,424 @@ async function rerankJump(ctx: {
return null;
}
}
+
+// A static jump runs a lightweight static analysis on the file
+// to jump to relevant locations.
+async function staticJump(ctx: {
+ oldFileContent: string;
+ newFileContent: string;
+ completionRange: Range;
+ filepath: string;
+ ide: IDE;
+ reranker?: ILLM;
+ chunkSize?: number;
+}): Promise {
+ try {
+ const { oldFileContent, newFileContent, completionRange, filepath, ide } =
+ ctx;
+
+ if (
+ !oldFileContent ||
+ !newFileContent ||
+ !completionRange ||
+ !filepath ||
+ !ide
+ ) {
+ console.warn(
+ "Missing required context for static jump:",
+ !oldFileContent,
+ !newFileContent,
+ !completionRange,
+ !filepath,
+ !ide,
+ );
+ return null;
+ }
+
+ // TODO:
+ // Parse the old file contents into an AST.
+ // Parse the new file contents into an AST.
+ // Compare the two trees and find which nodes have changed.
+ // Save the queue of changed nodes. The queue should contain the old node and the new node. Each of them can be null if the change is a deletion or insertion.
+ // Rank the queue by node depth (decreasing order because we want granular edits).
+ // Pop front until we find a queue item with an old node != null.
+ // Search the codebase for the old node's expression. For this, either use ide.getReferences(some_location), or other methods you see fit. If you can utilize the strategy pattern, even better.
+ // For now, filter out results from outside files. We only want to keep the results in the current file.
+ // Return the first result from this filtered list of results.
+
+ // Parse the old file contents into an AST.
+ const oldAst = await getAst(filepath, oldFileContent);
+ if (!oldAst) return null;
+
+ // Parse the new file contents into an AST.
+ const newAst = await getAst(filepath, newFileContent);
+ if (!newAst) return null;
+
+ // Compare the two trees and find which nodes have changed.
+ const changedNodes = compareAsts(oldAst, newAst);
+ if (!changedNodes || changedNodes.length === 0) return null;
+
+ // Save the queue of changed nodes.
+ // The queue should contain the old node and the new node.
+ // Each can be null if the change is a deletion or insertion.
+ // const nodeQueue = changedNodes.map((change) => ({
+ // oldNode: change.oldNode,
+ // newNode: change.newNode,
+ // depth: change.depth,
+ // }));
+
+ // Rank the queue by node depth.
+ // Decreasing order for granular edits.
+ // Increasing order for larger definition-based searches.
+ // Making it decreasing has issues when the deepest node is a string_fragment.
+ const nodeQueue = changedNodes.sort((a, b) => a.depth - b.depth);
+ console.log(
+ "nodeQueue:",
+ nodeQueue.map((node) => ({
+ oldText: node.oldNode?.text || "",
+ newText: node.newNode?.text || "",
+ oldType: node.oldNode?.type || "",
+ newType: node.newNode?.type || "",
+ depth: node.depth,
+ })),
+ );
+
+ // Find the first item with a non-null old node.
+ let targetNode = null;
+ while (nodeQueue.length > 0 && !targetNode) {
+ const candidate = nodeQueue.shift();
+ if (
+ candidate &&
+ candidate.oldNode &&
+ candidate.oldNode.type !== "program"
+ ) {
+ targetNode = candidate.oldNode;
+ }
+ }
+
+ if (!targetNode) return null;
+
+ // Get the text representation of the old node's expression.
+ const nodeText = getNodeText(targetNode);
+ if (!nodeText || nodeText.trim() === "") return null;
+
+ // Search for similar code in the file.
+ let references: RangeInFile[] = [];
+
+ // Try to use IDE's reference finding capabilities if available.
+ try {
+ // Get the position of the target node in the old file.
+ const nodePosition = getNodePosition(targetNode);
+ if (nodePosition) {
+ // Use IDE to find references.
+
+ // TODO:
+ // Get the list of document symbols using await ide.getDocumentSymbols.
+ // Each document symbol will be our query.
+ // Use the rerank model to rank the nodeText against the query.
+ // Get the highest scoring query and its location.
+
+ // Get the list of document symbols using await ide.getDocumentSymbols.
+ // Filter out symbols that are directly inside the completion range.
+ const symbols = await ide.getDocumentSymbols(filepath);
+
+ // Filter out symbols that are directly inside the completion range
+ const filteredSymbols = symbols.filter((symbol) => {
+ // Check if the symbol's range is outside of the completion range
+ return !doRangesOverlap(symbol.range, completionRange);
+ });
+
+ // Use the reranker to rank the filtered symbols against the node text.
+ if (!ctx.reranker) {
+ console.warn("No reranker available for static jump symbol ranking");
+ return null;
+ }
+
+ const symbolChunks: Chunk[] = filteredSymbols.map((symbol) => ({
+ content: symbol.name,
+ startLine: symbol.range.start.line,
+ endLine: symbol.range.end.line,
+ digest: `symbol-${symbol.name}-${symbol.range.start.line}`,
+ filepath: filepath,
+ index: symbol.range.start.line,
+ }));
+
+ if (symbolChunks.length === 0) {
+ console.warn("No symbols found for ranking");
+ return null;
+ }
+
+ const scores = await ctx.reranker.rerank(nodeText, symbolChunks);
+ symbolChunks.sort(
+ (a, b) =>
+ scores[symbolChunks.indexOf(b)] - scores[symbolChunks.indexOf(a)],
+ );
+
+ const mostRelevantSymbol = symbolChunks[0];
+ const originalSymbol = filteredSymbols.find(
+ (symbol) =>
+ symbol.range.start.line === mostRelevantSymbol.startLine &&
+ symbol.range.end.line === mostRelevantSymbol.endLine,
+ );
+
+ if (originalSymbol) {
+ references = [
+ {
+ filepath,
+ range: originalSymbol.range,
+ },
+ ];
+ }
+
+ // const foundReferences = await ide.getReferences({
+ // filepath,
+ // position: nodePosition,
+ // });
+
+ // if (foundReferences && foundReferences.length > 0) {
+ // references = foundReferences;
+ // }
+ }
+ } catch (e) {
+ console.warn(
+ "Failed to use IDE references, falling back to text search:",
+ e,
+ );
+ }
+
+ // If IDE reference finding failed or returned no results, fall back to text search.
+ if (references.length === 0) {
+ references = findTextOccurrences(oldFileContent, nodeText).map(
+ (range) => ({ filepath, range }),
+ );
+ }
+
+ // Filter out results from outside the current file.
+ const currentFileReferences = references.filter(
+ (ref) => ref.filepath === filepath,
+ );
+
+ // Return the first reference if any found.
+ if (currentFileReferences.length > 0) {
+ return currentFileReferences[0];
+ }
+
+ return null;
+ } catch (error) {
+ console.error("Error in static jump:", error);
+ return null;
+ }
+}
+
+// Helper function to compare ASTs and find changed nodes.
+function compareAsts(oldAst: Parser.Tree, newAst: Parser.Tree) {
+ const changedNodes: {
+ oldNode: Parser.SyntaxNode | null;
+ newNode: Parser.SyntaxNode | null;
+ depth: number;
+ }[] = [];
+
+ // This is a simplified implementation.
+ // In practice, you would traverse both ASTs in parallel
+ // and identify nodes that differ.
+
+ function traverse(
+ oldNode: Parser.SyntaxNode | null,
+ newNode: Parser.SyntaxNode | null,
+ depth: number = 0,
+ ) {
+ if (!oldNode && !newNode) return;
+
+ // If one node exists and the other doesn't, or they're different types.
+ if (
+ (!oldNode && newNode) ||
+ (oldNode && !newNode) ||
+ oldNode?.type !== newNode?.type
+ ) {
+ changedNodes.push({ oldNode, newNode, depth });
+ return;
+ }
+
+ // Compare properties.
+ if (oldNode?.text !== newNode?.text) {
+ changedNodes.push({ oldNode, newNode, depth });
+ }
+
+ // Recursively compare children.
+ const oldChildCount = oldNode?.childCount || 0;
+ const newChildCount = newNode?.childCount || 0;
+
+ const maxLength = Math.max(oldChildCount, newChildCount);
+ for (let i = 0; i < maxLength; i++) {
+ const oldChild = i < oldChildCount ? oldNode?.child(i) || null : null;
+ const newChild = i < newChildCount ? newNode?.child(i) || null : null;
+ traverse(oldChild, newChild, depth + 1);
+ }
+ }
+
+ traverse(oldAst.rootNode, newAst.rootNode);
+ return changedNodes;
+}
+
+// Helper function to get a node's text.
+function getNodeText(node: Parser.SyntaxNode): string {
+ if (!node) return "";
+
+ return node.text;
+}
+
+// Helper function to get a node's position.
+function getNodePosition(node: Parser.SyntaxNode): Position | null {
+ if (!node) return null;
+
+ // Tree-sitter nodes have startPosition property that contains row and column.
+ return {
+ line: node.startPosition.row,
+ character: node.startPosition.column,
+ };
+}
+
+// Helper function to find all occurrences of text in a string.
+function findTextOccurrences(text: string, searchText: string): Range[] {
+ const results: Range[] = [];
+ const lines = text.split("\n");
+
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
+ const line = lines[lineIndex];
+ let charIndex = 0;
+
+ while (charIndex < line.length) {
+ const foundIndex = line.indexOf(searchText, charIndex);
+ if (foundIndex === -1) break;
+
+ results.push({
+ start: { line: lineIndex, character: foundIndex },
+ end: { line: lineIndex, character: foundIndex + searchText.length },
+ });
+
+ charIndex = foundIndex + 1;
+ }
+ }
+
+ return results;
+}
+
+// Helper function to check if a range is within another range.
+function isRangeWithin(innerRange: Range, outerRange: Range): boolean {
+ // Check if the inner range's start position is after or equal to the outer range's start.
+ const startWithin =
+ innerRange.start.line > outerRange.start.line ||
+ (innerRange.start.line === outerRange.start.line &&
+ innerRange.start.character >= outerRange.start.character);
+
+ // Check if the inner range's end position is before or equal to the outer range's end.
+ const endWithin =
+ innerRange.end.line < outerRange.end.line ||
+ (innerRange.end.line === outerRange.end.line &&
+ innerRange.end.character <= outerRange.end.character);
+
+ return startWithin && endWithin;
+}
+
+// Helper function to check if two ranges overlap.
+function doRangesOverlap(range1: Range, range2: Range): boolean {
+ // Check if one range starts after the other ends
+ const range1StartsAfterRange2Ends =
+ range1.start.line > range2.end.line ||
+ (range1.start.line === range2.end.line &&
+ range1.start.character > range2.end.character);
+
+ const range2StartsAfterRange1Ends =
+ range2.start.line > range1.end.line ||
+ (range2.start.line === range1.end.line &&
+ range2.start.character > range1.end.character);
+
+ // If either condition is true, the ranges don't overlap
+ return !(range1StartsAfterRange2Ends || range2StartsAfterRange1Ends);
+}
+
+// Helper function to check if the upper part of range1 overlaps with range2.
+function doesUpperPartOverlap(range1: Range, range2: Range): boolean {
+ // Check if range1 starts before range2 ends
+ const range1StartsBeforeRange2Ends =
+ range1.start.line < range2.end.line ||
+ (range1.start.line === range2.end.line &&
+ range1.start.character <= range2.end.character);
+
+ // Check if range1 starts before range2 starts (meaning it's "upper" than range2)
+ const range1StartsBeforeRange2Starts =
+ range1.start.line < range2.start.line ||
+ (range1.start.line === range2.start.line &&
+ range1.start.character < range2.start.character);
+
+ // The upper part overlaps if range1 starts before range2 ends
+ // AND range1 starts before range2 starts
+ return range1StartsBeforeRange2Ends && range1StartsBeforeRange2Starts;
+}
+
+// Helper function to check if the lower part of range1 overlaps with range2.
+function doesLowerPartOverlap(range1: Range, range2: Range): boolean {
+ // Check if range1 starts inside range2
+ const range1StartsInsideRange2 =
+ (range1.start.line > range2.start.line ||
+ (range1.start.line === range2.start.line &&
+ range1.start.character >= range2.start.character)) &&
+ (range1.start.line < range2.end.line ||
+ (range1.start.line === range2.end.line &&
+ range1.start.character < range2.end.character));
+
+ // Check if range1 ends after range2 ends
+ const range1EndsAfterRange2 =
+ range1.end.line > range2.end.line ||
+ (range1.end.line === range2.end.line &&
+ range1.end.character > range2.end.character);
+
+ // The lower part overlaps if range1 starts inside range2
+ // AND range1 ends after range2 ends
+ return range1StartsInsideRange2 && range1EndsAfterRange2;
+}
+
+// Helper function to check if a range overlaps with another range from either end
+function doesRangePartiallyOverlap(range1: Range, range2: Range): boolean {
+ // Upper part overlap: range1 starts before range2 starts but ends inside range2
+ const upperPartOverlap =
+ (range1.start.line < range2.start.line ||
+ (range1.start.line === range2.start.line &&
+ range1.start.character < range2.start.character)) &&
+ (range1.end.line > range2.start.line ||
+ (range1.end.line === range2.start.line &&
+ range1.end.character > range2.start.character)) &&
+ (range1.end.line < range2.end.line ||
+ (range1.end.line === range2.end.line &&
+ range1.end.character <= range2.end.character));
+
+ // Lower part overlap: range1 starts inside range2 but ends after range2 ends
+ const lowerPartOverlap =
+ (range1.start.line > range2.start.line ||
+ (range1.start.line === range2.start.line &&
+ range1.start.character >= range2.start.character)) &&
+ (range1.start.line < range2.end.line ||
+ (range1.start.line === range2.end.line &&
+ range1.start.character < range2.end.character)) &&
+ (range1.end.line > range2.end.line ||
+ (range1.end.line === range2.end.line &&
+ range1.end.character > range2.end.character));
+
+ return upperPartOverlap || lowerPartOverlap;
+}
+
+// Utility function to print chunks.
+function printChunks(chunks: Chunk[]) {
+ console.log(
+ "chunks:",
+ JSON.stringify(
+ chunks.map((chunk) => ({
+ content: chunk.content,
+ startLine: chunk.startLine,
+ endLine: chunk.endLine,
+ })),
+ null,
+ 2,
+ ),
+ );
+}
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 1ea7fa29c..7d4a186d4 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -77,6 +77,8 @@ export class ContinueCompletionProvider
public recentlyVisitedRanges: RecentlyVisitedRangesService;
public recentlyEditedTracker: RecentlyEditedTracker;
+ private oldFileContent: string = "";
+
private isNextEditActive: boolean = false;
public activateNextEdit() {
@@ -194,17 +196,47 @@ export class ContinueCompletionProvider
if (this.nextEditProvider.chainExists()) {
// If the user has accepted the previous completion, the chain of edits is alive.
// Get the next editable region and set the pos to be within that range.
+ // const nextEditableRegion = await getNextEditableRegion(
+ // EditableRegionStrategy.Rerank,
+ // {
+ // fileContent: document.getText(),
+ // query: this.nextEditProvider.getPreviousCompletion(), // previous completion in the chain
+ // filepath: localPathOrUriToPath(document.uri.toString()),
+ // reranker: await this.getRerankModel(),
+ // chunkSize: 5,
+ // },
+ // );
+ const newFileContent = document.getText();
const nextEditableRegion = await getNextEditableRegion(
- EditableRegionStrategy.Rerank,
+ EditableRegionStrategy.Static,
{
- fileContent: document.getText(),
- query: this.nextEditProvider.getPreviousCompletion(), // previous completion in the chain
+ oldFileContent: this.oldFileContent,
+ newFileContent,
+ completionRange: {
+ start: {
+ line:
+ this.nextEditProvider.getPreviousCompletion()
+ ?.editableRegionStartLine ?? 0,
+ character: 0,
+ },
+ end: {
+ line:
+ this.nextEditProvider.getPreviousCompletion()
+ ?.editableRegionEndLine ?? document.lineCount - 1,
+ character: 0,
+ },
+ },
filepath: localPathOrUriToPath(document.uri.toString()),
+ ide: this.ide,
reranker: await this.getRerankModel(),
- chunkSize: 5,
},
);
+ console.log(
+ "nextEditableRegion:",
+ JSON.stringify(nextEditableRegion, null, 2),
+ );
+
if (nextEditableRegion) {
pos = {
line: nextEditableRegion.range.start.line,
@@ -277,6 +309,8 @@ export class ContinueCompletionProvider
setupStatusBar(undefined, true);
+ this.oldFileContent = document.getText();
+
let outcome: AutocompleteOutcome | NextEditOutcome | undefined;
// Check if editChainId exists or needs to be refreshed.
From 24f4918c982246691c96d582d036cc4da161774e Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Tue, 22 Jul 2025 13:13:31 -0700
Subject: [PATCH 066/244] chore: remove console.logs
---
extensions/vscode/src/activation/JumpManager.ts | 4 ----
1 file changed, 4 deletions(-)
diff --git a/extensions/vscode/src/activation/JumpManager.ts b/extensions/vscode/src/activation/JumpManager.ts
index 9ed09851c..1d180c072 100644
--- a/extensions/vscode/src/activation/JumpManager.ts
+++ b/extensions/vscode/src/activation/JumpManager.ts
@@ -314,9 +314,5 @@ export class JumpManager {
setCompletionAfterJump(completionData: CompletionDataForAfterJump): void {
this._completionAfterJump = completionData;
- console.log(
- "setCompletionAfterJump: saved",
- JSON.stringify(completionData, null, 2),
- );
}
}
From 92f956a654bd26bf0552fc0b28f987c482de67ea Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Wed, 23 Jul 2025 15:51:18 -0700
Subject: [PATCH 067/244] feat: add a truly static strategy
---
.../NextEditEditableRegionCalculator.ts | 234 ++++++++++++++++--
1 file changed, 209 insertions(+), 25 deletions(-)
diff --git a/core/nextEdit/NextEditEditableRegionCalculator.ts b/core/nextEdit/NextEditEditableRegionCalculator.ts
index 9d159f74b..c6353b0c5 100644
--- a/core/nextEdit/NextEditEditableRegionCalculator.ts
+++ b/core/nextEdit/NextEditEditableRegionCalculator.ts
@@ -5,18 +5,21 @@ import { getAst } from "../autocomplete/util/ast";
export enum EditableRegionStrategy {
Naive = "naive",
Rerank = "rerank",
+ StaticRerank = "staticRerank",
Static = "static",
}
export async function getNextEditableRegion(
strategy: EditableRegionStrategy,
ctx: any,
-): Promise {
+): Promise {
switch (strategy) {
case EditableRegionStrategy.Naive:
return naiveJump(ctx);
case EditableRegionStrategy.Rerank:
return await rerankJump(ctx);
+ case EditableRegionStrategy.StaticRerank:
+ return await staticRerankJump(ctx);
case EditableRegionStrategy.Static:
return await staticJump(ctx);
default:
@@ -26,23 +29,25 @@ export async function getNextEditableRegion(
// Naive assumes that the entire file is editable.
// This relies on the next edit model to figure out where to jump next.
-function naiveJump(ctx: any): RangeInFile | null {
+function naiveJump(ctx: any): RangeInFile[] | null {
const { fileLines, filepath } = ctx;
if (!fileLines || !filepath) {
console.warn("Missing required context for naive jump");
return null;
}
- return {
- filepath,
- range: {
- start: { line: 0, character: 0 },
- end: {
- line: fileLines.length - 1,
- character: fileLines.at(-1).length,
+ return [
+ {
+ filepath,
+ range: {
+ start: { line: 0, character: 0 },
+ end: {
+ line: fileLines.length - 1,
+ character: fileLines.at(-1).length,
+ },
},
},
- };
+ ];
}
// A rerank jump splits the current file into chunks.
@@ -53,7 +58,7 @@ async function rerankJump(ctx: {
filepath: string;
reranker: ILLM;
chunkSize: number;
-}): Promise {
+}): Promise {
try {
const { fileContent, query, filepath, reranker, chunkSize = 5 } = ctx;
@@ -107,25 +112,27 @@ async function rerankJump(ctx: {
// NOTE: It might be better to return a list of chunks,
// because it's very difficult to gauge when to stop the model.
// We could argue that we should always try to jump until the user says no.
- return {
- filepath,
- range: {
- start: { line: mostRelevantChunk.startLine, character: 0 },
- end: {
- line: mostRelevantChunk.endLine,
- character: lines[mostRelevantChunk.endLine].length,
+ return [
+ {
+ filepath,
+ range: {
+ start: { line: mostRelevantChunk.startLine, character: 0 },
+ end: {
+ line: mostRelevantChunk.endLine,
+ character: lines[mostRelevantChunk.endLine].length,
+ },
},
},
- };
+ ];
} catch (error) {
console.error("Error in rerank jump:", error);
return null;
}
}
-// A static jump runs a lightweight static analysis on the file
-// to jump to relevant locations.
-async function staticJump(ctx: {
+// A static rerank jump runs a lightweight static analysis on the file
+// and uses the reranker to jump to relevant locations.
+async function staticRerankJump(ctx: {
oldFileContent: string;
newFileContent: string;
completionRange: Range;
@@ -133,7 +140,7 @@ async function staticJump(ctx: {
ide: IDE;
reranker?: ILLM;
chunkSize?: number;
-}): Promise {
+}): Promise {
try {
const { oldFileContent, newFileContent, completionRange, filepath, ide } =
ctx;
@@ -146,7 +153,7 @@ async function staticJump(ctx: {
!ide
) {
console.warn(
- "Missing required context for static jump:",
+ "Missing required context for static rerank jump:",
!oldFileContent,
!newFileContent,
!completionRange,
@@ -321,7 +328,8 @@ async function staticJump(ctx: {
// Return the first reference if any found.
if (currentFileReferences.length > 0) {
- return currentFileReferences[0];
+ return [currentFileReferences[0]];
+ // return currentFileReferences;
}
return null;
@@ -331,6 +339,180 @@ async function staticJump(ctx: {
}
}
+// Static jump relies purely on static analysis
+// to determine where to edit next.
+async function staticJump(ctx: {
+ fileContent: string;
+ cursorPosition: { line: number; character: number };
+ filepath: string;
+ ide: IDE;
+}): Promise {
+ try {
+ const { fileContent, cursorPosition, filepath, ide } = ctx;
+ if (!fileContent || !cursorPosition || !filepath || !ide) {
+ console.warn(
+ "Missing required context for static jump:",
+ !fileContent,
+ !cursorPosition,
+ !filepath,
+ !ide,
+ );
+ return null;
+ }
+
+ // Get the file's AST.
+ // Getting this once helps us live-track the current node.
+ const tree = await getAst(filepath, fileContent);
+ if (!tree) return null;
+
+ // Convert cursor position to tree-sitter point format (0-based).
+ const point = {
+ row: cursorPosition.line,
+ column: cursorPosition.character,
+ };
+
+ // Find the node at the cursor position.
+ const nodeAtCursor = tree.rootNode.descendantForPosition(point);
+ if (!nodeAtCursor) {
+ console.log("No node found at cursor position");
+ return null;
+ }
+
+ // Find the closest identifier node.
+ const identifierNode = findClosestIdentifierNode(nodeAtCursor);
+ if (!identifierNode) {
+ console.log("No identifier node found near cursor position");
+ return null;
+ }
+
+ // Get all references to this identifier using the IDE's API
+ const references = await ide.getReferences({
+ filepath,
+ position: {
+ line: identifierNode.startPosition.row,
+ character: identifierNode.startPosition.column,
+ },
+ });
+
+ if (!references || references.length === 0) {
+ console.log(`No references found for identifier: ${identifierNode.text}`);
+ return null;
+ }
+
+ return references;
+ } catch (error) {
+ console.error("Error in staticJump:", error);
+ return null;
+ }
+}
+
+/* AST HELPER FUNCTIONS */
+
+// Helper function to find the closest identifier node.
+function findClosestIdentifierNode(
+ node: Parser.SyntaxNode | null,
+): Parser.SyntaxNode | null {
+ if (!node) return null;
+
+ if (isIdentifierNode(node)) return node;
+
+ // Check if the parent is an identifier.
+ // NOTE: This will probably never get triggered.
+ // Most identifiers are leaf nodes.
+ const parent = node.parent;
+ if (parent && isIdentifierNode(parent)) {
+ return parent;
+ }
+
+ if (parent) {
+ // Check if one of the siblings is an identifier.
+ for (let i = 0; i < parent.childCount; ++i) {
+ const sibling = node.child(i);
+ if (sibling && isIdentifierNode(sibling)) {
+ // Get the leftmost identifier sibling.
+ return sibling;
+ }
+ }
+ }
+
+ return findClosestIdentifierNode(parent);
+}
+
+// Helper function to check if a node is an identifier.
+function isIdentifierNode(node: Parser.SyntaxNode) {
+ const nodeType = node.type;
+
+ if (nodeType === "identifier") return true;
+ if (nodeType.includes("identifier")) return true;
+
+ // Most language grammars will use the term "identifier".
+ // However some might not.
+ // Update this as they come.
+ const specialIdentifiers = ["name", "constant"];
+ return specialIdentifiers.includes(nodeType);
+}
+
+// // Helper function to find the closest identifier node.
+// function findClosestIdentifierNode(
+// node: Parser.SyntaxNode | undefined,
+// ): Parser.SyntaxNode | undefined {
+// if (!node) return undefined;
+
+// // Check if the current node is an identifier
+// if (isIdentifierLike(node)) {
+// return node;
+// }
+
+// // Check if the parent is an identifier
+// const parent = node.parent;
+// if (parent && isIdentifierLike(parent)) {
+// return parent;
+// }
+
+// // Check if any of the node's children are identifiers
+// // Return the leftmost identifier child if found
+// for (let i = 0; i < node.childCount; i++) {
+// const child = node.child(i);
+// if (child && isIdentifierLike(child)) {
+// return child;
+// }
+// }
+
+// // Check if any of the parent's children are identifiers
+// if (parent) {
+// for (let i = 0; i < parent.childCount; i++) {
+// const sibling = parent.child(i);
+// if (sibling && isIdentifierLike(sibling)) {
+// return sibling;
+// }
+// }
+// }
+
+// // Recurse on the parent if we haven't found anything yet
+// return findClosestIdentifierNode(parent);
+// }
+
+// // Helper function to determine if a node is identifier-like
+// function isIdentifierLike(node: Parser.SyntaxNode): boolean {
+// // Common identifier node types across languages
+// const commonIdentifierTypes = [
+// "identifier",
+// "property_identifier",
+// "type_identifier",
+// "field_identifier",
+// "variable_identifier",
+// "constant",
+// "symbol",
+// ];
+
+// if (commonIdentifierTypes.includes(node.type)) {
+// return true;
+// }
+
+// // Check for common identifier patterns in node types
+// return /identifier$|^identifier|_identifier/.test(node.type);
+// }
+
// Helper function to compare ASTs and find changed nodes.
function compareAsts(oldAst: Parser.Tree, newAst: Parser.Tree) {
const changedNodes: {
@@ -399,6 +581,8 @@ function getNodePosition(node: Parser.SyntaxNode): Position | null {
};
}
+/* OTHER HELPER FUNCTIONS */
+
// Helper function to find all occurrences of text in a string.
function findTextOccurrences(text: string, searchText: string): Range[] {
const results: Range[] = [];
From 34ebf350c94c6d35785f1a7854476b17d613e114 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Wed, 23 Jul 2025 15:51:43 -0700
Subject: [PATCH 068/244] refactor: update to use RangeInFile[] instead of
RangeInFile
---
.../templating/NextEditPromptEngine.ts | 11 +++-
.../src/autocomplete/completionProvider.ts | 51 +++++++++++--------
2 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts
index 98ae5db3e..01a18ac7f 100644
--- a/core/nextEdit/templating/NextEditPromptEngine.ts
+++ b/core/nextEdit/templating/NextEditPromptEngine.ts
@@ -93,6 +93,7 @@ export async function renderPrompt(
// TODO: apply prevOutcome to existing content. we will need the line range.
// Also display the diff between existing content and applied content.
+ // NOTE: This only runs in fetchFunction.
if (prevOutcome) {
// console.log("renderPrompt prevOutcome:", prevOutcome.completion);
// console.log(
@@ -119,6 +120,8 @@ export async function renderPrompt(
// Given a previous response, we need to calculate where the cursor would be.
// I think it's a good idea to calculate this in the response.
+ // TODO: handle cases where there are more than one next editable region.
+ // NOTE: we might set it so that we receive the next editable region as an argument.
const editableRegion = await getNextEditableRegion(editableRegionStrategy, {
fileLines: appliedContent,
filepath: helper.filepath,
@@ -129,8 +132,12 @@ export async function renderPrompt(
editedCodeWithTokens = insertTokens(
appliedContent,
prevOutcome.finalCursorPosition,
- editableRegion?.range.start.line ?? undefined,
- editableRegion?.range.end.line ?? undefined,
+ editableRegion && editableRegion[0]?.range.start.line !== undefined
+ ? editableRegion[0].range.start.line
+ : undefined,
+ editableRegion && editableRegion[0]?.range.end.line !== undefined
+ ? editableRegion[0].range.end.line
+ : undefined,
);
// console.log("new editedCodeWithTokens:", editedCodeWithTokens);
userEdits = createDiff({
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 7d4a186d4..495e68da0 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -206,29 +206,39 @@ export class ContinueCompletionProvider
// chunkSize: 5,
// },
// );
- const newFileContent = document.getText();
+ // const newFileContent = document.getText();
+ // const nextEditableRegion = await getNextEditableRegion(
+ // EditableRegionStrategy.StaticRerank,
+ // {
+ // oldFileContent: this.oldFileContent,
+ // newFileContent,
+ // completionRange: {
+ // start: {
+ // line:
+ // this.nextEditProvider.getPreviousCompletion()
+ // ?.editableRegionStartLine ?? 0,
+ // character: 0,
+ // },
+ // end: {
+ // line:
+ // this.nextEditProvider.getPreviousCompletion()
+ // ?.editableRegionEndLine ?? document.lineCount - 1,
+ // character: 0,
+ // },
+ // },
+ // filepath: localPathOrUriToPath(document.uri.toString()),
+ // ide: this.ide,
+ // reranker: await this.getRerankModel(),
+ // },
+ // );
const nextEditableRegion = await getNextEditableRegion(
EditableRegionStrategy.Static,
{
- oldFileContent: this.oldFileContent,
- newFileContent,
- completionRange: {
- start: {
- line:
- this.nextEditProvider.getPreviousCompletion()
- ?.editableRegionStartLine ?? 0,
- character: 0,
- },
- end: {
- line:
- this.nextEditProvider.getPreviousCompletion()
- ?.editableRegionEndLine ?? document.lineCount - 1,
- character: 0,
- },
- },
+ fileContent: this.oldFileContent,
+ cursorPosition:
+ this.nextEditProvider.getPreviousCompletion()?.cursorPosition,
filepath: localPathOrUriToPath(document.uri.toString()),
ide: this.ide,
- reranker: await this.getRerankModel(),
},
);
@@ -237,10 +247,11 @@ export class ContinueCompletionProvider
JSON.stringify(nextEditableRegion, null, 2),
);
+ // TODO: handle cases where there are more than one next editable region.
if (nextEditableRegion) {
pos = {
- line: nextEditableRegion.range.start.line,
- character: nextEditableRegion.range.start.character,
+ line: nextEditableRegion[0].range.start.line,
+ character: nextEditableRegion[0].range.start.character,
};
}
} else {
From 79b547bfe45b649a02ee4464f05f4a4d2c1f3835 Mon Sep 17 00:00:00 2001
From: uinstinct <61635505+uinstinct@users.noreply.github.com>
Date: Thu, 24 Jul 2025 20:04:06 +0530
Subject: [PATCH 069/244] revert postgrescontextprovider removal
---
.../providers/PostgresContextProvider.ts | 137 ++++++++++++++++++
core/context/providers/index.ts | 2 +
.../Lump/sections/errors/ErrorSection.tsx | 3 +-
packages/config-yaml/src/schemas/index.ts | 8 +-
4 files changed, 141 insertions(+), 9 deletions(-)
create mode 100644 core/context/providers/PostgresContextProvider.ts
diff --git a/core/context/providers/PostgresContextProvider.ts b/core/context/providers/PostgresContextProvider.ts
new file mode 100644
index 000000000..55c00ae3c
--- /dev/null
+++ b/core/context/providers/PostgresContextProvider.ts
@@ -0,0 +1,137 @@
+import {
+ ContextItem,
+ ContextProviderDescription,
+ ContextProviderExtras,
+ ContextSubmenuItem,
+ LoadSubmenuItemsArgs,
+} from "../../index.js";
+import { BaseContextProvider } from "../index.js";
+
+class PostgresContextProvider extends BaseContextProvider {
+ static description: ContextProviderDescription = {
+ title: "postgres",
+ displayTitle: "PostgreSQL",
+ description: "Retrieve PostgreSQL table schema and sample rows",
+ type: "submenu",
+ renderInlineAs: "",
+ };
+
+ static ALL_TABLES = "__all_tables";
+ static DEFAULT_SAMPLE_ROWS = 3;
+
+ private async getPool() {
+ // @ts-ignore
+ const pg = await import("pg");
+
+ return new pg.Pool({
+ host: this.options.host,
+ port: this.options.port,
+ user: this.options.user,
+ password: this.options.password,
+ database: this.options.database,
+ });
+ }
+
+ private async getTableNames(pool: any): Promise {
+ const schema = this.options.schema ?? "public";
+ let tablesInfoQuery = `
+SELECT table_schema, table_name
+FROM information_schema.tables`;
+ if (schema !== null) {
+ tablesInfoQuery += ` WHERE table_schema = '${schema}'`;
+ }
+ const { rows: tablesInfo } = await pool.query(tablesInfoQuery);
+ return tablesInfo.map(
+ (tableInfo: any) => `${tableInfo.table_schema}.${tableInfo.table_name}`,
+ );
+ }
+
+ async getContextItems(
+ query = "",
+ _: ContextProviderExtras = {} as ContextProviderExtras,
+ ): Promise {
+ const pool = await this.getPool();
+
+ try {
+ const contextItems: ContextItem[] = [];
+
+ const tableNames = [];
+ if (query === PostgresContextProvider.ALL_TABLES) {
+ tableNames.push(...(await this.getTableNames(pool)));
+ } else {
+ tableNames.push(query);
+ }
+
+ for (const tableName of tableNames) {
+ // Get the table schema
+ if (!tableName.includes(".")) {
+ throw new Error(
+ `Table name must be in format schema.table_name, got ${tableName}`,
+ );
+ }
+ const schemaQuery = `
+SELECT column_name, data_type, character_maximum_length
+FROM INFORMATION_SCHEMA.COLUMNS
+WHERE table_schema = '${tableName.split(".")[0]}'
+ AND table_name = '${tableName.split(".")[1]}'`;
+ console.log("schemaQuery", schemaQuery);
+ const { rows: tableSchema } = await pool.query(schemaQuery);
+
+ // Get the sample rows
+ const sampleRows =
+ this.options.sampleRows ??
+ PostgresContextProvider.DEFAULT_SAMPLE_ROWS;
+ const { rows: sampleRowResults } = await pool.query(`
+SELECT *
+FROM ${tableName}
+LIMIT ${sampleRows}`);
+
+ // Create prompt from the table schema and sample rows
+ let prompt = `Postgres schema for database ${this.options.database} table ${tableName}:\n`;
+ prompt += `${JSON.stringify(tableSchema, null, 2)}\n\n`;
+ prompt += `Sample rows: ${JSON.stringify(sampleRowResults, null, 2)}`;
+
+ contextItems.push({
+ name: `${this.options.database}-${tableName}-schema-and-sample-rows`,
+ description: `Schema and sample rows for table ${tableName}`,
+ content: prompt,
+ });
+ }
+
+ return contextItems;
+ } catch (error) {
+ throw new Error(`Failed to query PostgreSQL database: ${error}`);
+ } finally {
+ }
+ }
+
+ async loadSubmenuItems(
+ _: LoadSubmenuItemsArgs,
+ ): Promise {
+ const pool = await this.getPool();
+
+ try {
+ const contextItems: ContextSubmenuItem[] = [];
+ const tableNames = await this.getTableNames(pool);
+
+ for (const tableName of tableNames) {
+ contextItems.push({
+ id: tableName,
+ title: tableName,
+ description: `Schema from ${tableName} and ${this.options.sampleRows} sample rows.`,
+ });
+ }
+ contextItems.push({
+ id: PostgresContextProvider.ALL_TABLES,
+ title: "All tables",
+ description: `Schema from all tables and ${this.options.sampleRows} sample rows each.`,
+ });
+
+ return contextItems;
+ } catch (error) {
+ throw new Error(`Failed to query PostgreSQL database: ${error}`);
+ }
+ }
+}
+
+export default PostgresContextProvider;
diff --git a/core/context/providers/index.ts b/core/context/providers/index.ts
index e70f30e55..910b16c14 100644
--- a/core/context/providers/index.ts
+++ b/core/context/providers/index.ts
@@ -24,6 +24,7 @@ import JiraIssuesContextProvider from "./JiraIssuesContextProvider/";
import MCPContextProvider from "./MCPContextProvider";
import OpenFilesContextProvider from "./OpenFilesContextProvider";
import OSContextProvider from "./OSContextProvider";
+import PostgresContextProvider from "./PostgresContextProvider";
import ProblemsContextProvider from "./ProblemsContextProvider";
import RepoMapContextProvider from "./RepoMapContextProvider";
import RulesContextProvider from "./RulesContextProvider";
@@ -55,6 +56,7 @@ export const Providers: (typeof BaseContextProvider)[] = [
DocsContextProvider,
GitLabMergeRequestContextProvider,
JiraIssuesContextProvider,
+ PostgresContextProvider,
DatabaseContextProvider,
CodebaseContextProvider,
CodeContextProvider,
diff --git a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx
index 5ec608f8a..bd06d197d 100644
--- a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx
+++ b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx
@@ -2,7 +2,6 @@ import {
ExclamationCircleIcon,
ExclamationTriangleIcon,
} from "@heroicons/react/24/outline";
-import { Remark } from "react-remark";
import { useAppSelector } from "../../../../../redux/hooks";
export function ErrorSection() {
@@ -33,7 +32,7 @@ export function ErrorSection() {
className="m-0 whitespace-pre-wrap text-wrap"
style={{ wordBreak: "break-word" }}
>
- {error.message}
+ {error.message}
))}
diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts
index ed087c0b8..e15a5655d 100644
--- a/packages/config-yaml/src/schemas/index.ts
+++ b/packages/config-yaml/src/schemas/index.ts
@@ -9,13 +9,7 @@ import {
export const contextSchema = z.object({
name: z.string().optional(),
- provider: z
- .string()
- // postgres context provider deprecation message. to be removed in a later version
- .regex(/^(?!postgres$).*$/, {
- message:
- "The **postgres** context provider is no longer supported. Please use the [Postgres MCP server](https://github.com/crystaldba/postgres-mcp) instead.",
- }),
+ provider: z.string(),
params: z.any().optional(),
});
From b28d78ccc7eb56911fdb597315f4cae00f5d6b2f Mon Sep 17 00:00:00 2001
From: uinstinct <61635505+uinstinct@users.noreply.github.com>
Date: Thu, 24 Jul 2025 20:24:39 +0530
Subject: [PATCH 070/244] show deprecation message as toast
---
core/config/yaml/loadYaml.ts | 59 +++++++++++++------
core/context/index.ts | 4 ++
.../providers/CustomContextProvider.ts | 4 ++
.../providers/PostgresContextProvider.ts | 4 ++
core/index.d.ts | 2 +
core/util/GlobalContext.ts | 3 +
6 files changed, 58 insertions(+), 18 deletions(-)
diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts
index b1682e751..051784056 100644
--- a/core/config/yaml/loadYaml.ts
+++ b/core/config/yaml/loadYaml.ts
@@ -394,25 +394,48 @@ async function configYamlToContinueConfig(options: {
({ description: { title } }) => title,
);
- continueConfig.contextProviders = (config.context
- ?.map((context) => {
- const cls = contextProviderClassFromName(context.provider) as any;
- if (!cls) {
- if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(context.provider)) {
- localErrors.push({
- fatal: false,
- message: `Unknown context provider ${context.provider}`,
- });
+ const globalContext = new GlobalContext();
+
+ continueConfig.contextProviders =
+ config.context
+ ?.map((context) => {
+ const cls = contextProviderClassFromName(context.provider) as any;
+ if (!cls) {
+ if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(context.provider)) {
+ localErrors.push({
+ fatal: false,
+ message: `Unknown context provider ${context.provider}`,
+ });
+ }
+ return undefined;
}
- return undefined;
- }
- const instance: IContextProvider = new cls({
- name: context.name,
- ...context.params,
- });
- return instance;
- })
- .filter((p) => !!p) ?? []) as IContextProvider[];
+ const instance: IContextProvider = new cls({
+ name: context.name,
+ ...context.params,
+ });
+ return instance;
+ })
+ .filter((p) => !!p)
+ .filter((p) => {
+ if (p.isDeprecated()) {
+ const providerTitle = p.description.title;
+ const shownWarnings =
+ globalContext.get("shownDeprecatedProviderWarnings") ?? {};
+ if (!shownWarnings[providerTitle]) {
+ ide.showToast(
+ "warning",
+ `Context provider ${providerTitle} is deprecated and will be removed in a future version.`,
+ );
+ globalContext.update("shownDeprecatedProviderWarnings", {
+ ...shownWarnings,
+ [providerTitle]: true,
+ });
+ }
+ return true;
+ }
+ return false;
+ }) ?? [];
+
continueConfig.contextProviders.push(...DEFAULT_CONTEXT_PROVIDERS);
if (
diff --git a/core/context/index.ts b/core/context/index.ts
index 7ad48f112..c00d611aa 100644
--- a/core/context/index.ts
+++ b/core/context/index.ts
@@ -31,4 +31,8 @@ export abstract class BaseContextProvider implements IContextProvider {
): Promise {
return [];
}
+
+ isDeprecated(): boolean {
+ return false;
+ }
}
diff --git a/core/context/providers/CustomContextProvider.ts b/core/context/providers/CustomContextProvider.ts
index f87a4554f..150e22e58 100644
--- a/core/context/providers/CustomContextProvider.ts
+++ b/core/context/providers/CustomContextProvider.ts
@@ -30,6 +30,10 @@ class CustomContextProviderClass implements IContextProvider {
async loadSubmenuItems(args: LoadSubmenuItemsArgs) {
return this.custom.loadSubmenuItems?.(args) ?? [];
}
+
+ isDeprecated() {
+ return false;
+ }
}
export default CustomContextProviderClass;
diff --git a/core/context/providers/PostgresContextProvider.ts b/core/context/providers/PostgresContextProvider.ts
index 55c00ae3c..70406e3d2 100644
--- a/core/context/providers/PostgresContextProvider.ts
+++ b/core/context/providers/PostgresContextProvider.ts
@@ -132,6 +132,10 @@ LIMIT ${sampleRows}`);
throw new Error(`Failed to query PostgreSQL database: ${error}`);
}
}
+
+ isDeprecated() {
+ return true;
+ }
}
export default PostgresContextProvider;
diff --git a/core/index.d.ts b/core/index.d.ts
index f9fdc34cf..b3524da73 100644
--- a/core/index.d.ts
+++ b/core/index.d.ts
@@ -256,6 +256,8 @@ export interface IContextProvider {
): Promise;
loadSubmenuItems(args: LoadSubmenuItemsArgs): Promise;
+
+ isDeprecated(): boolean;
}
export interface Session {
diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts
index 6885edde2..7466718b6 100644
--- a/core/util/GlobalContext.ts
+++ b/core/util/GlobalContext.ts
@@ -39,6 +39,9 @@ export type GlobalContextType = {
isSupportedLanceDbCpuTargetForLinux: boolean;
sharedConfig: SharedConfigSchema;
failedDocs: SiteIndexingConfig[];
+ shownDeprecatedProviderWarnings: {
+ [providerTitle: string]: boolean;
+ };
};
/**
From f969659e8b9680cea7e39854f5d8a9f45ca7d175 Mon Sep 17 00:00:00 2001
From: uinstinct <61635505+uinstinct@users.noreply.github.com>
Date: Thu, 24 Jul 2025 20:34:57 +0530
Subject: [PATCH 071/244] get the deprecation message from the provider itself
---
core/config/yaml/loadYaml.ts | 7 ++-----
core/context/index.ts | 4 ++--
core/context/providers/PostgresContextProvider.ts | 4 ++--
core/index.d.ts | 2 +-
4 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts
index 051784056..9d9bee33e 100644
--- a/core/config/yaml/loadYaml.ts
+++ b/core/config/yaml/loadYaml.ts
@@ -417,15 +417,12 @@ async function configYamlToContinueConfig(options: {
})
.filter((p) => !!p)
.filter((p) => {
- if (p.isDeprecated()) {
+ if (p.deprecationMessage) {
const providerTitle = p.description.title;
const shownWarnings =
globalContext.get("shownDeprecatedProviderWarnings") ?? {};
if (!shownWarnings[providerTitle]) {
- ide.showToast(
- "warning",
- `Context provider ${providerTitle} is deprecated and will be removed in a future version.`,
- );
+ ide.showToast("warning", p.deprecationMessage);
globalContext.update("shownDeprecatedProviderWarnings", {
...shownWarnings,
[providerTitle]: true,
diff --git a/core/context/index.ts b/core/context/index.ts
index c00d611aa..cde6b9440 100644
--- a/core/context/index.ts
+++ b/core/context/index.ts
@@ -32,7 +32,7 @@ export abstract class BaseContextProvider implements IContextProvider {
return [];
}
- isDeprecated(): boolean {
- return false;
+ get deprecationMessage(): string | null {
+ return null;
}
}
diff --git a/core/context/providers/PostgresContextProvider.ts b/core/context/providers/PostgresContextProvider.ts
index 70406e3d2..4f79c2e00 100644
--- a/core/context/providers/PostgresContextProvider.ts
+++ b/core/context/providers/PostgresContextProvider.ts
@@ -133,8 +133,8 @@ LIMIT ${sampleRows}`);
}
}
- isDeprecated() {
- return true;
+ get deprecationMessage() {
+ return "The Postgres context provider is deprecated. Please consider using the Postgres MCP (such as github.com/crystaldba/postgres-mcp) instead.";
}
}
diff --git a/core/index.d.ts b/core/index.d.ts
index b3524da73..1bbc21e2d 100644
--- a/core/index.d.ts
+++ b/core/index.d.ts
@@ -257,7 +257,7 @@ export interface IContextProvider {
loadSubmenuItems(args: LoadSubmenuItemsArgs): Promise;
- isDeprecated(): boolean;
+ get deprecationMessage(): string | null;
}
export interface Session {
From 44bb9aa0b82a4569da6666bd4a567c9fa137e432 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 10:17:24 -0700
Subject: [PATCH 072/244] feat: add a a document ast tracker to cache ASTs
---
core/nextEdit/DocumentAstTracker.ts | 207 ++++++++++++++++++++++++++++
1 file changed, 207 insertions(+)
create mode 100644 core/nextEdit/DocumentAstTracker.ts
diff --git a/core/nextEdit/DocumentAstTracker.ts b/core/nextEdit/DocumentAstTracker.ts
new file mode 100644
index 000000000..1bbdc98b7
--- /dev/null
+++ b/core/nextEdit/DocumentAstTracker.ts
@@ -0,0 +1,207 @@
+// TODO:
+// Create a DocumentAstTracker singleton class that keeps track of a map of document paths to their history of ASTs.
+// There should be a map from document path to history of ASTs (a LIFO stack of ASTs where the newest AST is at the front)
+// We want to expose these methods:
+// add document and its first AST
+// push to an existing document's AST history stack
+// get the most recent AST of an existing document's AST
+// The AST and nodes will be using web-tree-sitter types.
+// save map to file as a documentAstTracker.json inside the user's global continue path
+// delete document from map
+// clear map
+import * as fs from "fs";
+import * as path from "path";
+import Parser from "web-tree-sitter";
+import { getContinueGlobalPath } from "../util/paths";
+
+/**
+ * Singleton class that keeps track of a map of document paths to their history of ASTs.
+ */
+export class DocumentAstTracker {
+ private static instance: DocumentAstTracker | null = null;
+
+ // Map from document path to history of ASTs (LIFO stack where newest AST is at the front).
+ private documentAstMap: Map;
+ private documentContentHistoryMap: Map;
+
+ // Path to save the AST tracker data.
+ private readonly savePath: string;
+
+ private constructor() {
+ this.documentAstMap = new Map();
+ this.documentContentHistoryMap = new Map();
+ this.savePath = path.join(
+ getContinueGlobalPath(),
+ "documentAstTracker.jsonl",
+ );
+
+ // Try to load existing data.
+ // this.loadFromFile();
+ }
+
+ /**
+ * Get the singleton instance of DocumentAstTracker.
+ */
+ public static getInstance(): DocumentAstTracker {
+ if (!DocumentAstTracker.instance) {
+ DocumentAstTracker.instance = new DocumentAstTracker();
+ }
+
+ return DocumentAstTracker.instance;
+ }
+
+ /**
+ * Add a document and its first AST to the tracker.
+ *
+ * @param documentPath The path of the document.
+ * @param ast The first AST of the document.
+ */
+ public addDocument(
+ documentPath: string,
+ documentContent: string,
+ ast: Parser.Tree,
+ ): void {
+ this.documentAstMap.set(documentPath, [ast]);
+ this.documentContentHistoryMap.set(documentPath, [documentContent]);
+ // this.saveToFile();
+ }
+
+ /**
+ * Push a new AST to an existing document's history stack.
+ *
+ * @param documentPath The path of the document.
+ * @param ast The new AST to push to the document's history stack.
+ * @throws Error if the document doesn't exist in the tracker.
+ */
+ public pushAst(
+ documentPath: string,
+ documentContent: string,
+ ast: Parser.Tree,
+ ): void {
+ const astHistory = this.documentAstMap.get(documentPath);
+ const documentHistory = this.documentContentHistoryMap.get(documentPath);
+
+ if (!astHistory || !documentHistory) {
+ console.error(`Document ${documentPath} not found in AST tracker`);
+ this.addDocument(documentPath, documentContent, ast);
+ }
+
+ console.log("same AST:", this.getMostRecentAst(documentPath) !== ast);
+
+ // Add the new AST to the front of the array (LIFO stack).
+ astHistory!.unshift(ast);
+ documentHistory!.unshift(documentContent);
+ // this.saveToFile();
+ }
+
+ /**
+ * Get the most recent AST of a document.
+ *
+ * @param documentPath The path of the document.
+ * @returns The most recent AST of the document.
+ * @throws Error if the document doesn't exist in the tracker.
+ */
+ public getMostRecentAst(documentPath: string): Parser.Tree | null {
+ const astHistory = this.documentAstMap.get(documentPath);
+
+ if (!astHistory) {
+ console.error(`Document ${documentPath} not found in AST tracker`);
+ return null;
+ }
+ if (astHistory.length === 0) {
+ console.error(`Document ${documentPath} has no ASTs`);
+ return null;
+ }
+
+ // Return the first element (most recent AST).
+ return astHistory[0];
+ }
+
+ /**
+ * Get the most recent AST of a document.
+ *
+ * @param documentPath The path of the document.
+ * @returns The most recent document history of the document.
+ * @throws Error if the document doesn't exist in the tracker.
+ */
+ public getMostRecentDocumentHistory(documentPath: string): string | null {
+ const documentHistory = this.documentContentHistoryMap.get(documentPath);
+
+ if (!documentHistory) {
+ console.error(`Document ${documentPath} not found in AST tracker`);
+ return null;
+ }
+ if (documentHistory.length === 0) {
+ console.error(`Document ${documentPath} has no history`);
+ return null;
+ }
+
+ // Return the first element (most recent doc history).
+ return documentHistory[0];
+ }
+
+ /**
+ * Delete a document from the tracker.
+ *
+ * @param documentPath The path of the document to delete.
+ */
+ public deleteDocument(documentPath: string): void {
+ this.documentAstMap.delete(documentPath);
+ this.documentContentHistoryMap.delete(documentPath);
+ // this.saveToFile();
+ }
+
+ /**
+ * Clear all documents from the tracker.
+ */
+ public clearMap(): void {
+ this.documentAstMap.clear();
+ this.documentContentHistoryMap.clear();
+ // this.saveToFile();
+ }
+
+ /**
+ * Save the current state of the tracker to a file.
+ */
+ private saveToFile(): void {
+ try {
+ // We can't directly serialize Tree objects to JSON.
+ // So we'll just save the paths - this serves as a record of which documents we're tracking.
+ // The actual ASTs will need to be recreated when needed.
+ const documentPaths = Array.from(this.documentAstMap.keys());
+ const serializableData = { documentPaths };
+
+ fs.writeFileSync(
+ this.savePath,
+ JSON.stringify(serializableData, null, 2),
+ );
+ } catch (error) {
+ console.error("Error saving AST tracker data to file:", error);
+ }
+ }
+
+ /**
+ * Load the tracker state from a file.
+ */
+ private loadFromFile(): void {
+ try {
+ if (fs.existsSync(this.savePath)) {
+ const fileContent = fs.readFileSync(this.savePath, "utf-8");
+ const data = JSON.parse(fileContent);
+
+ // We only saved the paths, not the actual Trees.
+ // The Trees need to be reparsed when the documents are loaded again.
+ if (data && data.documentPaths) {
+ // Initialize empty arrays for each document.
+ data.documentPaths.forEach((path: string) => {
+ this.documentAstMap.set(path, []);
+ });
+ }
+ }
+ } catch (error) {
+ console.error("Error loading AST tracker data from file:", error);
+ // If loading fails, we'll start with an empty map.
+ this.documentAstMap = new Map();
+ }
+ }
+}
From d5ce1aec0ab946fc3af83277b8016b9f66e23564 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 10:19:20 -0700
Subject: [PATCH 073/244] feat: use the document ast tracker
---
.../NextEditEditableRegionCalculator.ts | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/core/nextEdit/NextEditEditableRegionCalculator.ts b/core/nextEdit/NextEditEditableRegionCalculator.ts
index c6353b0c5..74dc011ba 100644
--- a/core/nextEdit/NextEditEditableRegionCalculator.ts
+++ b/core/nextEdit/NextEditEditableRegionCalculator.ts
@@ -1,6 +1,7 @@
import Parser from "web-tree-sitter";
import { Chunk, IDE, ILLM, Position, Range, RangeInFile } from "..";
import { getAst } from "../autocomplete/util/ast";
+import { DocumentAstTracker } from "./DocumentAstTracker";
export enum EditableRegionStrategy {
Naive = "naive",
@@ -362,7 +363,9 @@ async function staticJump(ctx: {
// Get the file's AST.
// Getting this once helps us live-track the current node.
- const tree = await getAst(filepath, fileContent);
+ const tree =
+ await DocumentAstTracker.getInstance().getMostRecentAst(filepath);
+ // const tree = await getAst(filepath, fileContent);
if (!tree) return null;
// Convert cursor position to tree-sitter point format (0-based).
@@ -384,6 +387,7 @@ async function staticJump(ctx: {
console.log("No identifier node found near cursor position");
return null;
}
+ console.log("closest identifier:", identifierNode.text);
// Get all references to this identifier using the IDE's API
const references = await ide.getReferences({
@@ -399,7 +403,19 @@ async function staticJump(ctx: {
return null;
}
- return references;
+ console.log(
+ "references:",
+ JSON.stringify(
+ references.map((ref) => ({
+ line: ref.range.start.line,
+ character: ref.range.start.character,
+ })),
+ null,
+ 2,
+ ),
+ );
+
+ return references.length > 1 ? references.slice(1) : null;
} catch (error) {
console.error("Error in staticJump:", error);
return null;
From 04868195e37b61d56b28057fbf586a8ca144e011 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 10:19:33 -0700
Subject: [PATCH 074/244] feat: add fileContentsBeforeAccept field
---
core/nextEdit/types.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/core/nextEdit/types.ts b/core/nextEdit/types.ts
index 26e2b156a..e4ae1f328 100644
--- a/core/nextEdit/types.ts
+++ b/core/nextEdit/types.ts
@@ -47,9 +47,10 @@ export interface NextEditOutcome extends TabAutocompleteOptions {
// New for Next Edit.
fileUri: string;
workspaceDirUri: string;
+ fileContentsBeforeAccept: string;
prompt: string;
userEdits: string;
- userExcerpts: string;
+ userExcerpts: string; // For now, this is the same as fileContentsBeforeAccept, but that assumption should not be relied on.
originalEditableRange: string;
completion: string;
cursorPosition: { line: number; character: number };
From c172170569a5d10a4311a41074ff076e0f23fe8c Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 10:20:43 -0700
Subject: [PATCH 075/244] feat: add a method to request the model within a
given chain
---
core/nextEdit/NextEditProvider.ts | 161 +++++++++++++++++++++++++++++-
1 file changed, 157 insertions(+), 4 deletions(-)
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index c84a76bba..851572ce7 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -7,6 +7,7 @@ import {
IDE,
ILLM,
Position,
+ Range,
RangeInFile,
} from "../index.js";
import OpenAI from "../llm/llms/OpenAI.js";
@@ -18,22 +19,30 @@ import { BracketMatchingService } from "../autocomplete/filtering/BracketMatchin
import { CompletionStreamer } from "../autocomplete/generation/CompletionStreamer.js";
import { shouldPrefilter } from "../autocomplete/prefiltering/index.js";
import { getAllSnippetsWithoutRace } from "../autocomplete/snippets/index.js";
+import { AutocompleteCodeSnippet } from "../autocomplete/snippets/types.js";
import { GetLspDefinitionsFunction } from "../autocomplete/types.js";
+import { getAst } from "../autocomplete/util/ast.js";
import { AutocompleteDebouncer } from "../autocomplete/util/AutocompleteDebouncer.js";
import AutocompleteLruCache from "../autocomplete/util/AutocompleteLruCache.js";
import { HelperVars } from "../autocomplete/util/HelperVars.js";
import { AutocompleteInput } from "../autocomplete/util/types.js";
import { myersDiff } from "../diff/myers.js";
+import { localPathOrUriToPath } from "../util/pathToUri.js";
import { replaceEscapedCharacters } from "../util/text.js";
import {
NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
} from "./constants.js";
+import { createDiff, DiffFormatType } from "./context/diffFormatting.js";
import {
calculateFinalCursorPosition,
getOffsetPositionAtLastNewLine,
} from "./diff/diff.js";
-import { EditableRegionStrategy } from "./NextEditEditableRegionCalculator.js";
+import { DocumentAstTracker } from "./DocumentAstTracker.js";
+import {
+ EditableRegionStrategy,
+ getNextEditableRegion,
+} from "./NextEditEditableRegionCalculator.js";
import { NextEditLoggingService } from "./NextEditLoggingService.js";
import { NextEditPrefetchQueue } from "./NextEditPrefetchQueue.js";
import {
@@ -41,7 +50,12 @@ import {
renderDefaultUserPrompt,
renderPrompt,
} from "./templating/NextEditPromptEngine.js";
-import { NextEditOutcome, Prompt, PromptMetadata } from "./types.js";
+import {
+ NextEditOutcome,
+ Prompt,
+ PromptMetadata,
+ RecentlyEditedRange,
+} from "./types.js";
// import { renderPrompt } from "./templating/NextEditPromptEngine.js";
const autocompleteCache = AutocompleteLruCache.get();
@@ -70,7 +84,10 @@ export class NextEditProvider {
private prefetchQueue: NextEditPrefetchQueue;
// private refQueue: RangeInFile[] = [];
private currentEditChainId: string | null = null;
+ private previousRequest: AutocompleteInput | null = null;
private previousCompletions: NextEditOutcome[] = [];
+ private nextEditableRegionsInTheCurrentChain: RangeInFile[] = [];
+ // TODO: keep track of the last completion request (at least the file path it came from)
private constructor(
private readonly configHandler: ConfigHandler,
@@ -176,6 +193,7 @@ export class NextEditProvider {
workspaceDirUri:
other.helper.workspaceUris[0] ??
path.dirname(other.helper.filepath),
+ fileContentsBeforeAccept: other.helper.fileContents,
prompt: this.promptMetadata!.prompt.content,
userEdits: this.promptMetadata!.userEdits,
userExcerpts: this.promptMetadata!.userExcerpts,
@@ -326,9 +344,24 @@ export class NextEditProvider {
return this.previousCompletions[0];
}
- public deleteChain(): void {
+ public async deleteChain(): Promise {
this.currentEditChainId = null;
this.previousCompletions = [];
+ this.nextEditableRegionsInTheCurrentChain = [];
+
+ if (this.previousRequest) {
+ const fileContent =
+ // await fs.readFile(localPathOrUriToPath(this.previousRequest.filepath)
+ (await this.ide.readFile(this.previousRequest.filepath)).toString();
+ const ast = await getAst(this.previousRequest.filepath, fileContent);
+ if (ast) {
+ DocumentAstTracker.getInstance().pushAst(
+ localPathOrUriToPath(this.previousRequest.filepath),
+ fileContent,
+ ast,
+ );
+ }
+ }
}
public startChain(id?: string) {
@@ -348,6 +381,7 @@ export class NextEditProvider {
token: AbortSignal | undefined,
): Promise {
try {
+ this.previousRequest = input;
// Create abort signal if not given
if (!token) {
const controller = this.loggingService.createAbortController(
@@ -399,12 +433,34 @@ export class NextEditProvider {
prompts.push(renderDefaultSystemPrompt());
prompts.push(renderDefaultUserPrompt(snippetPayload, helper));
} else {
+ const historyDiff = createDiff({
+ beforeContent:
+ DocumentAstTracker.getInstance().getMostRecentDocumentHistory(
+ localPathOrUriToPath(helper.filepath),
+ ) ?? "",
+ afterContent: helper.fileContents,
+ filePath: helper.filepath,
+ diffType: DiffFormatType.Unified,
+ contextLines: 3,
+ });
const promptMetadata = await renderPrompt(
helper,
- this.diffContext,
+ // this.diffContext,
+ historyDiff ?? this.diffContext,
EditableRegionStrategy.Naive,
+ // input.recentlyEditedRanges,
);
this.promptMetadata = promptMetadata;
+ prompts.push({
+ role: "system",
+ content: [
+ "When the user deletes or replaces over previous code, you should respect that decision.",
+ "Respect the new code the user is writing, and complete it.",
+ "For example, if the user is changing a field name, try to autocomplete the new field name. Don't suggest the previous field name.",
+ "Do not roll back to previous content.",
+ "If the user has made a change, make sure you respect that and try to apply it to other parts of the code that used to use the old content.",
+ ].join("\n"),
+ });
prompts.push(promptMetadata.prompt);
}
@@ -445,6 +501,7 @@ export class NextEditProvider {
fileUri: helper.filepath,
workspaceDirUri:
helper.workspaceUris[0] ?? path.dirname(helper.filepath),
+ fileContentsBeforeAccept: helper.fileContents,
prompt: prompts.join("\n"),
userEdits: "",
userExcerpts: "",
@@ -518,6 +575,7 @@ export class NextEditProvider {
fileUri: helper.filepath,
workspaceDirUri:
helper.workspaceUris[0] ?? path.dirname(helper.filepath),
+ fileContentsBeforeAccept: helper.fileContents,
prompt: this.promptMetadata!.prompt.content,
userEdits: this.promptMetadata!.userEdits,
userExcerpts: this.promptMetadata!.userExcerpts,
@@ -551,6 +609,101 @@ export class NextEditProvider {
}
}
+ public async provideInlineCompletionItemsWithChain(
+ ctx: {
+ completionId: string;
+ manuallyPassFileContents?: string;
+ manuallyPassPrefix?: string;
+ selectedCompletionInfo?: {
+ text: string;
+ range: Range;
+ };
+ isUntitledFile: boolean;
+ recentlyVisitedRanges: AutocompleteCodeSnippet[];
+ recentlyEditedRanges: RecentlyEditedRange[];
+ },
+ token: AbortSignal | undefined,
+ ) {
+ // TODO:
+ // If we don't have a precomputed list of next editable regions already, compute it.
+ // Store this list as a class attribute.
+ // Pop the frontmost RangeInFile and use that to build an input.
+ try {
+ const previousOutcome = this.getPreviousCompletion();
+ if (!previousOutcome) {
+ return undefined;
+ }
+ // TODO: This is actually getting the contents after the user typed something.
+ // we need the file before the user has typed anything.
+ // console.log("previousOutcome:", previousOutcome.fileContentsBeforeAccept);
+ // console.log("previousCursorPosition:", previousOutcome.cursorPosition);
+
+ const fileContent = previousOutcome.fileContentsBeforeAccept;
+ const filepath = localPathOrUriToPath(previousOutcome.fileUri);
+
+ if (this.nextEditableRegionsInTheCurrentChain.length === 0) {
+ this.loadNextEditableRegionsInTheCurrentChain(
+ (await getNextEditableRegion(EditableRegionStrategy.Static, {
+ fileContent,
+ cursorPosition: previousOutcome.cursorPosition,
+ filepath,
+ ide: this.ide,
+ })) ?? [],
+ );
+
+ if (this.nextEditableRegionsInTheCurrentChain.length === 0) {
+ await this.deleteChain();
+ return undefined;
+ }
+ }
+
+ const input = await this.buildAutocompleteInputFromChain(
+ previousOutcome,
+ this.nextEditableRegionsInTheCurrentChain[0],
+ ctx,
+ );
+ if (!input) {
+ return undefined;
+ }
+
+ return await this.provideInlineCompletionItems(input, token);
+ } catch (e: any) {
+ this.onError(e);
+ }
+ }
+
+ private buildAutocompleteInputFromChain(
+ previousOutcome: NextEditOutcome,
+ nextEditableRegion: RangeInFile,
+ ctx: {
+ completionId: string;
+ manuallyPassFileContents?: string;
+ manuallyPassPrefix?: string;
+ selectedCompletionInfo?: {
+ text: string;
+ range: Range;
+ };
+ isUntitledFile: boolean;
+ recentlyVisitedRanges: AutocompleteCodeSnippet[];
+ recentlyEditedRanges: RecentlyEditedRange[];
+ },
+ ): AutocompleteInput | undefined {
+ const input: AutocompleteInput = {
+ pos: {
+ line: nextEditableRegion.range.start.line,
+ character: nextEditableRegion.range.start.character,
+ },
+ filepath: previousOutcome.fileUri,
+ ...ctx,
+ };
+
+ return input;
+ }
+
+ public loadNextEditableRegionsInTheCurrentChain(regions: RangeInFile[]) {
+ this.nextEditableRegionsInTheCurrentChain = regions;
+ }
+
public async provideNextEditPrediction(
input: AutocompleteInput,
token: AbortSignal | undefined,
From f319a40c6424100e7d50fc35a3b6fac0bb4338c3 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 10:21:16 -0700
Subject: [PATCH 076/244] refactor: calculate document content separately
---
extensions/vscode/src/commands.ts | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts
index 70a602a0f..4c00fee06 100644
--- a/extensions/vscode/src/commands.ts
+++ b/extensions/vscode/src/commands.ts
@@ -829,6 +829,8 @@ const getCommandsMap: (
return;
}
+ const documentContent = editor.document.getText();
+
// Calculate the editable region boundaries around the current cursor position/
const editableRegionStartLine = Math.max(
currentPosition.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
@@ -840,8 +842,7 @@ const getCommandsMap: (
);
// Get the current text in the editable region.
- const oldEditRangeSlice = editor.document
- .getText()
+ const oldEditRangeSlice = documentContent
.split("\n")
.slice(editableRegionStartLine, editableRegionEndLine + 1)
.join("\n");
From 333757f003c1c0223dbd1340425168ab1304808f Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 10:22:07 -0700
Subject: [PATCH 077/244] feat: handle cases where there are existing edit
chains
---
.../src/autocomplete/completionProvider.ts | 205 ++++++++----------
1 file changed, 91 insertions(+), 114 deletions(-)
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 495e68da0..26a7b1308 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -21,14 +21,9 @@ import {
NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
} from "core/nextEdit/constants";
import { checkFim } from "core/nextEdit/diff/diff";
-import {
- EditableRegionStrategy,
- getNextEditableRegion,
-} from "core/nextEdit/NextEditEditableRegionCalculator";
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
import { NextEditProvider } from "core/nextEdit/NextEditProvider";
import { NextEditOutcome } from "core/nextEdit/types";
-import { localPathOrUriToPath } from "core/util/pathToUri";
import { JumpManager } from "../activation/JumpManager";
import { NextEditWindowManager } from "../activation/NextEditWindowManager";
import { GhostTextAcceptanceTracker } from "./GhostTextAcceptanceTracker";
@@ -193,72 +188,6 @@ export class ContinueCompletionProvider
character: position.character,
};
- if (this.nextEditProvider.chainExists()) {
- // If the user has accepted the previous completion, the chain of edits is alive.
- // Get the next editable region and set the pos to be within that range.
- // const nextEditableRegion = await getNextEditableRegion(
- // EditableRegionStrategy.Rerank,
- // {
- // fileContent: document.getText(),
- // query: this.nextEditProvider.getPreviousCompletion(), // previous completion in the chain
- // filepath: localPathOrUriToPath(document.uri.toString()),
- // reranker: await this.getRerankModel(),
- // chunkSize: 5,
- // },
- // );
- // const newFileContent = document.getText();
- // const nextEditableRegion = await getNextEditableRegion(
- // EditableRegionStrategy.StaticRerank,
- // {
- // oldFileContent: this.oldFileContent,
- // newFileContent,
- // completionRange: {
- // start: {
- // line:
- // this.nextEditProvider.getPreviousCompletion()
- // ?.editableRegionStartLine ?? 0,
- // character: 0,
- // },
- // end: {
- // line:
- // this.nextEditProvider.getPreviousCompletion()
- // ?.editableRegionEndLine ?? document.lineCount - 1,
- // character: 0,
- // },
- // },
- // filepath: localPathOrUriToPath(document.uri.toString()),
- // ide: this.ide,
- // reranker: await this.getRerankModel(),
- // },
- // );
- const nextEditableRegion = await getNextEditableRegion(
- EditableRegionStrategy.Static,
- {
- fileContent: this.oldFileContent,
- cursorPosition:
- this.nextEditProvider.getPreviousCompletion()?.cursorPosition,
- filepath: localPathOrUriToPath(document.uri.toString()),
- ide: this.ide,
- },
- );
-
- console.log(
- "nextEditableRegion:",
- JSON.stringify(nextEditableRegion, null, 2),
- );
-
- // TODO: handle cases where there are more than one next editable region.
- if (nextEditableRegion) {
- pos = {
- line: nextEditableRegion[0].range.start.line,
- character: nextEditableRegion[0].range.start.character,
- };
- }
- } else {
- // If the user has rejected, then we start a new chain of edits.
- this.nextEditProvider.startChain();
- }
-
let manuallyPassFileContents: string | undefined = undefined;
if (document.uri.scheme === "vscode-notebook-cell") {
const notebook = vscode.workspace.notebookDocuments.find((notebook) =>
@@ -304,40 +233,67 @@ export class ContinueCompletionProvider
const wasManuallyTriggered =
context.triggerKind === vscode.InlineCompletionTriggerKind.Invoke;
- const input: AutocompleteInput = {
- pos,
- manuallyPassFileContents,
- manuallyPassPrefix,
- selectedCompletionInfo,
- injectDetails,
- isUntitledFile: document.isUntitled,
- completionId: uuidv4(),
- filepath: document.uri.toString(),
- recentlyVisitedRanges: this.recentlyVisitedRanges.getSnippets(),
- recentlyEditedRanges:
- await this.recentlyEditedTracker.getRecentlyEditedRanges(),
- };
+ let outcome: AutocompleteOutcome | NextEditOutcome | undefined;
+ const completionId = uuidv4();
+ const filepath = document.uri.toString();
+ const recentlyVisitedRanges = this.recentlyVisitedRanges.getSnippets();
+ let recentlyEditedRanges =
+ await this.recentlyEditedTracker.getRecentlyEditedRanges();
+ console.log("one:", JSON.stringify(recentlyEditedRanges, null, 2));
- setupStatusBar(undefined, true);
+ if (this.nextEditProvider.chainExists()) {
+ // If the user has accepted the previous completion, the chain of edits is alive.
+ // Get the next editable region and set the pos to be within that range.
+ outcome =
+ await this.nextEditProvider.provideInlineCompletionItemsWithChain(
+ {
+ completionId,
+ manuallyPassFileContents,
+ manuallyPassPrefix,
+ selectedCompletionInfo,
+ isUntitledFile: document.isUntitled,
+ recentlyVisitedRanges,
+ recentlyEditedRanges,
+ },
+ signal,
+ );
+ } else {
+ // If the user has rejected, then we start a new chain of edits.
+ this.nextEditProvider.startChain();
+
+ const input: AutocompleteInput = {
+ pos,
+ manuallyPassFileContents,
+ manuallyPassPrefix,
+ selectedCompletionInfo,
+ injectDetails,
+ isUntitledFile: document.isUntitled,
+ completionId,
+ filepath,
+ recentlyVisitedRanges,
+ recentlyEditedRanges,
+ };
+
+ setupStatusBar(undefined, true);
+ // Check if editChainId exists or needs to be refreshed.
+ if (this.isNextEditActive) {
+ outcome = await this.nextEditProvider.provideInlineCompletionItems(
+ input,
+ signal,
+ );
+ console.log("outcome.completion:");
+ console.log(outcome?.completion);
+ } else {
+ outcome = await this.completionProvider.provideInlineCompletionItems(
+ input,
+ signal,
+ wasManuallyTriggered,
+ );
+ }
+ }
this.oldFileContent = document.getText();
- let outcome: AutocompleteOutcome | NextEditOutcome | undefined;
-
- // Check if editChainId exists or needs to be refreshed.
- if (this.isNextEditActive) {
- outcome = await this.nextEditProvider.provideInlineCompletionItems(
- input,
- signal,
- );
- } else {
- outcome = await this.completionProvider.provideInlineCompletionItems(
- input,
- signal,
- wasManuallyTriggered,
- );
- }
-
// TODO: fix type of outcome to be a union between NextEditOutcome and AutocompleteOutcome.
// const outcome: AutocompleteOutcome | NextEditOutcome | undefined = this
// .isNextEditActive
@@ -352,7 +308,30 @@ export class ContinueCompletionProvider
// );
if (!outcome || !outcome.completion) {
- return null;
+ // TODO: At this point we assume that the user typed something "whole".
+ // AKA, the user's edit was good enough to start an edit chain.
+ // We actually started the chain before getting the outcome. This makes logical sense.
+ // Then all we need to do is to calculate next editable region.
+ // We also need to use the user's edits to create a user edits section in renderPrompt.
+ recentlyEditedRanges =
+ await this.recentlyEditedTracker.getRecentlyEditedRanges();
+ console.log("two:", JSON.stringify(recentlyEditedRanges, null, 2));
+ outcome =
+ await this.nextEditProvider.provideInlineCompletionItemsWithChain(
+ {
+ completionId,
+ manuallyPassFileContents,
+ manuallyPassPrefix,
+ selectedCompletionInfo,
+ isUntitledFile: document.isUntitled,
+ recentlyVisitedRanges,
+ recentlyEditedRanges,
+ },
+ signal,
+ );
+ if (!outcome || !outcome.completion) {
+ return null;
+ }
}
// VS Code displays dependent on selectedCompletionInfo (their docstring below)
@@ -385,12 +364,12 @@ export class ContinueCompletionProvider
// the current outcome as a value of the key completionId.
if (this.isNextEditActive) {
this.nextEditProvider.markDisplayed(
- input.completionId,
+ completionId,
outcome as NextEditOutcome,
);
} else {
this.completionProvider.markDisplayed(
- input.completionId,
+ completionId,
outcome as AutocompleteOutcome,
);
}
@@ -438,7 +417,7 @@ export class ContinueCompletionProvider
{
title: "Log Autocomplete Outcome",
command: "continue.logAutocompleteOutcome",
- arguments: [input.completionId, this.completionProvider],
+ arguments: [completionId, this.completionProvider],
},
);
@@ -470,7 +449,7 @@ export class ContinueCompletionProvider
if (this.jumpManager.isJumpInProgress()) {
// Store this completion for later use when jump is complete.
this.jumpManager.setCompletionAfterJump({
- completionId: input.completionId,
+ completionId: completionId,
outcome: outcome as NextEditOutcome,
currentPosition: jumpPosition,
});
@@ -486,9 +465,7 @@ export class ContinueCompletionProvider
// We don't need to show the next edit window if the predicted edits is empty.
if (newEditRangeSlice === "") {
- this.nextEditLoggingService.cancelRejectionTimeout(
- input.completionId,
- );
+ this.nextEditLoggingService.cancelRejectionTimeout(completionId);
return undefined;
}
@@ -509,9 +486,7 @@ export class ContinueCompletionProvider
// We don't need to show the next edit window if the predicted edits are identical to the previous version.
if (oldEditRangeSlice === newEditRangeSlice) {
- this.nextEditLoggingService.cancelRejectionTimeout(
- input.completionId,
- );
+ this.nextEditLoggingService.cancelRejectionTimeout(completionId);
return undefined;
}
@@ -527,6 +502,8 @@ export class ContinueCompletionProvider
newEditRangeSlice,
relativeCursorPos,
);
+ console.log("isFim:", isFim);
+ console.log("fimText:", fimText);
if (isFim) {
if (!fimText) {
@@ -553,7 +530,7 @@ export class ContinueCompletionProvider
{
title: "Log Next Edit Outcome",
command: "continue.logNextEditOutcomeAccept",
- arguments: [input.completionId, this.nextEditLoggingService], // TODO: this may have to be this.completionProvider.
+ arguments: [completionId, this.nextEditLoggingService], // TODO: this may have to be this.completionProvider.
},
);
console.log(nextEditCompletionItem);
@@ -571,7 +548,7 @@ export class ContinueCompletionProvider
if (NextEditWindowManager.isInstantiated()) {
NextEditWindowManager.getInstance().updateCurrentCompletionId(
- input.completionId,
+ completionId,
);
await NextEditWindowManager.getInstance().showNextEditWindow(
From 895c2855145d1f33fcde3f57f2337d1a171c1c4a Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 10:22:24 -0700
Subject: [PATCH 078/244] fix: actually update the recently edited ranges
---
extensions/vscode/src/autocomplete/recentlyEdited.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/extensions/vscode/src/autocomplete/recentlyEdited.ts b/extensions/vscode/src/autocomplete/recentlyEdited.ts
index 9fa48cd98..fc4eab517 100644
--- a/extensions/vscode/src/autocomplete/recentlyEdited.ts
+++ b/extensions/vscode/src/autocomplete/recentlyEdited.ts
@@ -67,6 +67,7 @@ export class RecentlyEditedTracker {
lines: contents.split("\n"),
symbols: getSymbolsForSnippet(contents),
};
+ this.recentlyEditedRanges[i] = range;
return;
}
}
From 00efd382a825546b1801040606d8c96cf2371f6e Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 10:22:48 -0700
Subject: [PATCH 079/244] feat: handle typing sessions separately from cursor
movements
---
.../vscode/src/extension/VsCodeExtension.ts | 58 ++++++++++++++++++-
1 file changed, 56 insertions(+), 2 deletions(-)
diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts
index 4983583ab..d0c4fdd5b 100644
--- a/extensions/vscode/src/extension/VsCodeExtension.ts
+++ b/extensions/vscode/src/extension/VsCodeExtension.ts
@@ -42,7 +42,14 @@ import { VsCodeIde } from "../VsCodeIde";
import { ConfigYamlDocumentLinkProvider } from "./ConfigYamlDocumentLinkProvider";
import { VsCodeMessenger } from "./VsCodeMessenger";
+import { getAst } from "core/autocomplete/util/ast";
+import { DocumentAstTracker } from "core/nextEdit/DocumentAstTracker";
+import {
+ EditableRegionStrategy,
+ getNextEditableRegion,
+} from "core/nextEdit/NextEditEditableRegionCalculator";
import { NextEditProvider } from "core/nextEdit/NextEditProvider";
+import { localPathOrUriToPath } from "core/util/pathToUri";
import { JumpManager } from "../activation/JumpManager";
import setupNextEditWindowManager, {
NextEditWindowManager,
@@ -71,6 +78,18 @@ export class VsCodeExtension {
private fileSearch: FileSearch;
private uriHandler = new UriEventHandler();
private completionProvider: ContinueCompletionProvider;
+ // Track whether the user is currently typing
+ private isTypingSession = false;
+ private typingTimer: NodeJS.Timeout | null = null;
+ private lastDocumentChangeTime = 0;
+
+ // Reset typing session after a delay
+ resetTypingSession = () => {
+ if (this.typingTimer) clearTimeout(this.typingTimer);
+ this.typingTimer = setTimeout(() => {
+ this.isTypingSession = false;
+ }, 2000); // Typing session considered over after 2 seconds of inactivity
+ };
constructor(context: vscode.ExtensionContext) {
// Register auth provider
@@ -320,6 +339,12 @@ export class VsCodeExtension {
});
vscode.workspace.onDidChangeTextDocument(async (event) => {
+ if (event.contentChanges.length > 0) {
+ this.isTypingSession = true;
+ this.lastDocumentChangeTime = Date.now();
+ this.resetTypingSession();
+ }
+
const editInfo = await handleTextDocumentChange(
event,
this.configHandler,
@@ -355,6 +380,19 @@ export class VsCodeExtension {
});
});
+ vscode.workspace.onDidOpenTextDocument(async (event) => {
+ console.log("onDidOpenTextDocument");
+ const ast = await getAst(event.fileName, event.getText());
+ console.log(ast === undefined);
+ if (ast) {
+ DocumentAstTracker.getInstance().addDocument(
+ localPathOrUriToPath(event.fileName),
+ event.getText(),
+ ast,
+ );
+ }
+ });
+
// When GitHub sign-in status changes, reload config
vscode.authentication.onDidChangeSessions(async (e) => {
const env = await getControlPlaneEnv(this.ide.getIdeSettings());
@@ -389,7 +427,7 @@ export class VsCodeExtension {
// console.log(
// "deleteChain from VsCodeExtension.ts: onDidChangeVisibleTextEditors",
// );
- NextEditProvider.getInstance().deleteChain();
+ await NextEditProvider.getInstance().deleteChain();
});
// Listen for selection changes to hide tooltip when cursor moves.
@@ -423,11 +461,27 @@ export class VsCodeExtension {
return;
}
+ // 4. The selection change is part of a typing session
+ // Check if this selection change is close enough to a document change to be considered typing
+ const timeSinceLastDocChange = Date.now() - this.lastDocumentChangeTime;
+ if (this.isTypingSession && timeSinceLastDocChange < 500) {
+ // This selection change is likely due to typing, don't delete the chain
+ return;
+ }
+
// Otherwise, delete the chain (for rejection or unrelated movement).
console.log(
"deleteChain from VsCodeExtension.ts: onDidChangeTextEditorSelection",
);
- NextEditProvider.getInstance().deleteChain();
+ await NextEditProvider.getInstance().deleteChain();
+ NextEditProvider.getInstance().loadNextEditableRegionsInTheCurrentChain(
+ (await getNextEditableRegion(EditableRegionStrategy.Static, {
+ fileContent: e.textEditor.document.getText(),
+ cursorPosition: e.selections[0].anchor,
+ filepath: localPathOrUriToPath(e.textEditor.document.uri.toString()),
+ ide: this.ide,
+ })) ?? [],
+ );
});
// Refresh index when branch is changed
From 3413cf563304a0781e05915b4ba785872b52c0ba Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 10:23:15 -0700
Subject: [PATCH 080/244] feat: get the editor contents instead of file
contents
---
extensions/vscode/src/util/ideUtils.ts | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/extensions/vscode/src/util/ideUtils.ts b/extensions/vscode/src/util/ideUtils.ts
index 6f213b302..d8593f7d0 100644
--- a/extensions/vscode/src/util/ideUtils.ts
+++ b/extensions/vscode/src/util/ideUtils.ts
@@ -111,6 +111,7 @@ export class VsCodeIdeUtils {
/**
* Read the entire contents of a file from the given URI.
+ * If there are unsaved changes in an open editor, returns those instead of the file on disk.
*
* @param uri - The URI of the file to read.
* @param ignoreMissingProviders - Optional flag to ignore missing file system providers for unsupported schemes.
@@ -124,6 +125,18 @@ export class VsCodeIdeUtils {
uri: vscode.Uri,
ignoreMissingProviders: boolean = true,
): Promise {
+ // First check if there's an open document with this URI that might have unsaved changes.
+ const openDocuments = vscode.workspace.textDocuments;
+ for (const document of openDocuments) {
+ if (document.uri.toString() === uri.toString()) {
+ // Found an open document with this URI.
+ // Return its current content (including any unsaved changes) as Uint8Array.
+ const docText = document.getText();
+ return Buffer.from(docText, "utf8");
+ }
+ }
+
+ // If no open document found or if it's not dirty, fall back to reading from disk.
return await this.fsOperation(
uri,
async (u) => {
From 7030eb80af7a35c5b204e5f4e9ed19e2562e4dc4 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 15:16:44 -0700
Subject: [PATCH 081/244] refactor: rename file
---
.../nextEdit/{DocumentAstTracker.ts => DocumentHistoryTracker.ts} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename core/nextEdit/{DocumentAstTracker.ts => DocumentHistoryTracker.ts} (100%)
diff --git a/core/nextEdit/DocumentAstTracker.ts b/core/nextEdit/DocumentHistoryTracker.ts
similarity index 100%
rename from core/nextEdit/DocumentAstTracker.ts
rename to core/nextEdit/DocumentHistoryTracker.ts
From 1480e1b0bdedad995346ab9a765a1493f235d017 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 15:17:53 -0700
Subject: [PATCH 082/244] feat: check if the completion request is within a
chain, and shift the next editable region accordingly
---
core/nextEdit/NextEditProvider.ts | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index 851572ce7..b8512cd4e 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -38,7 +38,7 @@ import {
calculateFinalCursorPosition,
getOffsetPositionAtLastNewLine,
} from "./diff/diff.js";
-import { DocumentAstTracker } from "./DocumentAstTracker.js";
+import { DocumentAstTracker } from "./DocumentHistoryTracker.js";
import {
EditableRegionStrategy,
getNextEditableRegion,
@@ -379,6 +379,7 @@ export class NextEditProvider {
public async provideInlineCompletionItems(
input: AutocompleteInput,
token: AbortSignal | undefined,
+ withChain: boolean,
): Promise {
try {
this.previousRequest = input;
@@ -397,6 +398,12 @@ export class NextEditProvider {
return undefined;
}
+ // Depending on whether this method is called from provideInlineCompletionItemsWithChain,
+ // shift the next editable regions.
+ if (withChain) {
+ this.shiftNextEditableRegionsInTheCurrentChain();
+ }
+
const llm = await this._prepareLlm();
if (!llm) {
return undefined;
@@ -451,6 +458,7 @@ export class NextEditProvider {
// input.recentlyEditedRanges,
);
this.promptMetadata = promptMetadata;
+
prompts.push({
role: "system",
content: [
@@ -640,8 +648,13 @@ export class NextEditProvider {
const fileContent = previousOutcome.fileContentsBeforeAccept;
const filepath = localPathOrUriToPath(previousOutcome.fileUri);
+ console.log(
+ "number of next editable regions:",
+ this.nextEditableRegionsInTheCurrentChain.length,
+ );
if (this.nextEditableRegionsInTheCurrentChain.length === 0) {
+ console.log("empty next editable regions list");
this.loadNextEditableRegionsInTheCurrentChain(
(await getNextEditableRegion(EditableRegionStrategy.Static, {
fileContent,
@@ -659,14 +672,15 @@ export class NextEditProvider {
const input = await this.buildAutocompleteInputFromChain(
previousOutcome,
- this.nextEditableRegionsInTheCurrentChain[0],
+ this.nextEditableRegionsInTheCurrentChain[0], // this will be shifted after debouncer check
ctx,
);
if (!input) {
return undefined;
}
- return await this.provideInlineCompletionItems(input, token);
+ const WITH_CHAIN = true;
+ return await this.provideInlineCompletionItems(input, token, WITH_CHAIN);
} catch (e: any) {
this.onError(e);
}
@@ -701,9 +715,15 @@ export class NextEditProvider {
}
public loadNextEditableRegionsInTheCurrentChain(regions: RangeInFile[]) {
+ console.log("regions after load:", regions.length);
this.nextEditableRegionsInTheCurrentChain = regions;
}
+ public shiftNextEditableRegionsInTheCurrentChain() {
+ console.log("shift", this.nextEditableRegionsInTheCurrentChain.length);
+ this.nextEditableRegionsInTheCurrentChain.shift();
+ }
+
public async provideNextEditPrediction(
input: AutocompleteInput,
token: AbortSignal | undefined,
From e454ede427e532b0d0d9f5ca415f12c4bad99fba Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 15:18:23 -0700
Subject: [PATCH 083/244] chore: remove console.logs
---
extensions/vscode/src/commands.ts | 1 -
1 file changed, 1 deletion(-)
diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts
index 4c00fee06..ce69ea87b 100644
--- a/extensions/vscode/src/commands.ts
+++ b/extensions/vscode/src/commands.ts
@@ -916,7 +916,6 @@ const getCommandsMap: (
console.log("deleteChain from commands.ts: diffLines.length === 0");
NextEditProvider.getInstance().deleteChain();
}
- console.log("number of difflines:", diffLines.length);
if (NextEditWindowManager.isInstantiated()) {
const windowManager = NextEditWindowManager.getInstance();
From c9acabe58ff5161c6a058ff13cf15398fd9cae7e Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 15:18:45 -0700
Subject: [PATCH 084/244] fix: we don't need to set inlineSuggest manually
anymore
---
.../vscode/src/activation/NextEditWindowManager.ts | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/extensions/vscode/src/activation/NextEditWindowManager.ts b/extensions/vscode/src/activation/NextEditWindowManager.ts
index 37414830e..00e340e17 100644
--- a/extensions/vscode/src/activation/NextEditWindowManager.ts
+++ b/extensions/vscode/src/activation/NextEditWindowManager.ts
@@ -404,9 +404,9 @@ export class NextEditWindowManager {
// Disable inline suggestions temporarily.
// This prevents the race condition between vscode's inline completion provider
// and the next edit window manager's cursor repositioning logic.
- await vscode.workspace
- .getConfiguration()
- .update("editor.inlineSuggest.enabled", false, true);
+ // await vscode.workspace
+ // .getConfiguration()
+ // .update("editor.inlineSuggest.enabled", false, true);
}
if (success) {
@@ -418,9 +418,9 @@ export class NextEditWindowManager {
);
// Reenable inline suggestions after we move the cursor.
- await vscode.workspace
- .getConfiguration()
- .update("editor.inlineSuggest.enabled", true, true);
+ // await vscode.workspace
+ // .getConfiguration()
+ // .update("editor.inlineSuggest.enabled", true, true);
await this.hideAllNextEditWindows();
}
From a14c1bf397c75912cd8de58407ae58c90bf331e5 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 15:19:41 -0700
Subject: [PATCH 085/244] refactor: pass withChain boolean and remove
console.logs
---
core/core.ts | 1 +
.../src/autocomplete/completionProvider.ts | 64 +++++++++++--------
.../vscode/src/extension/VsCodeExtension.ts | 3 +-
3 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/core/core.ts b/core/core.ts
index a3fe4cab5..c97837fde 100644
--- a/core/core.ts
+++ b/core/core.ts
@@ -593,6 +593,7 @@ export class Core {
const outcome = await this.nextEditProvider.provideInlineCompletionItems(
msg.data,
undefined,
+ false,
);
return outcome ? [outcome.completion, outcome.originalEditableRange] : [];
});
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 26a7b1308..4919377c9 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -140,6 +140,14 @@ export class ContinueCompletionProvider
token: vscode.CancellationToken,
//@ts-ignore
): ProviderResult {
+ console.log("================================================");
+ console.log(
+ "editor.inlineSuggest.enabled:",
+ vscode.workspace
+ .getConfiguration()
+ .get("editor.inlineSuggest.enabled"),
+ );
+ // console.log("trigger!!", token.isCancellationRequested);
const enableTabAutocomplete =
getStatusBarStatus() === StatusBarStatus.Enabled;
if (token.isCancellationRequested || !enableTabAutocomplete) {
@@ -239,7 +247,12 @@ export class ContinueCompletionProvider
const recentlyVisitedRanges = this.recentlyVisitedRanges.getSnippets();
let recentlyEditedRanges =
await this.recentlyEditedTracker.getRecentlyEditedRanges();
- console.log("one:", JSON.stringify(recentlyEditedRanges, null, 2));
+ // console.log("one:", JSON.stringify(recentlyEditedRanges, null, 2));
+ console.log(
+ this.nextEditProvider.chainExists()
+ ? "chain is alive"
+ : "chain is not alive",
+ );
if (this.nextEditProvider.chainExists()) {
// If the user has accepted the previous completion, the chain of edits is alive.
@@ -280,9 +293,33 @@ export class ContinueCompletionProvider
outcome = await this.nextEditProvider.provideInlineCompletionItems(
input,
signal,
+ false,
);
console.log("outcome.completion:");
console.log(outcome?.completion);
+ if (!outcome || !outcome.completion) {
+ // TODO: At this point we assume that the user typed something "whole".
+ // AKA, the user's edit was good enough to start an edit chain.
+ // We actually started the chain before getting the outcome. This makes logical sense.
+ // Then all we need to do is to calculate next editable region.
+ // We also need to use the user's edits to create a user edits section in renderPrompt.
+ recentlyEditedRanges =
+ await this.recentlyEditedTracker.getRecentlyEditedRanges();
+ // console.log("two:", JSON.stringify(recentlyEditedRanges, null, 2));
+ outcome =
+ await this.nextEditProvider.provideInlineCompletionItemsWithChain(
+ {
+ completionId,
+ manuallyPassFileContents,
+ manuallyPassPrefix,
+ selectedCompletionInfo,
+ isUntitledFile: document.isUntitled,
+ recentlyVisitedRanges,
+ recentlyEditedRanges,
+ },
+ signal,
+ );
+ }
} else {
outcome = await this.completionProvider.provideInlineCompletionItems(
input,
@@ -308,30 +345,7 @@ export class ContinueCompletionProvider
// );
if (!outcome || !outcome.completion) {
- // TODO: At this point we assume that the user typed something "whole".
- // AKA, the user's edit was good enough to start an edit chain.
- // We actually started the chain before getting the outcome. This makes logical sense.
- // Then all we need to do is to calculate next editable region.
- // We also need to use the user's edits to create a user edits section in renderPrompt.
- recentlyEditedRanges =
- await this.recentlyEditedTracker.getRecentlyEditedRanges();
- console.log("two:", JSON.stringify(recentlyEditedRanges, null, 2));
- outcome =
- await this.nextEditProvider.provideInlineCompletionItemsWithChain(
- {
- completionId,
- manuallyPassFileContents,
- manuallyPassPrefix,
- selectedCompletionInfo,
- isUntitledFile: document.isUntitled,
- recentlyVisitedRanges,
- recentlyEditedRanges,
- },
- signal,
- );
- if (!outcome || !outcome.completion) {
- return null;
- }
+ return null;
}
// VS Code displays dependent on selectedCompletionInfo (their docstring below)
diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts
index d0c4fdd5b..776c59843 100644
--- a/extensions/vscode/src/extension/VsCodeExtension.ts
+++ b/extensions/vscode/src/extension/VsCodeExtension.ts
@@ -43,7 +43,7 @@ import { ConfigYamlDocumentLinkProvider } from "./ConfigYamlDocumentLinkProvider
import { VsCodeMessenger } from "./VsCodeMessenger";
import { getAst } from "core/autocomplete/util/ast";
-import { DocumentAstTracker } from "core/nextEdit/DocumentAstTracker";
+import { DocumentAstTracker } from "core/nextEdit/DocumentHistoryTracker";
import {
EditableRegionStrategy,
getNextEditableRegion,
@@ -383,7 +383,6 @@ export class VsCodeExtension {
vscode.workspace.onDidOpenTextDocument(async (event) => {
console.log("onDidOpenTextDocument");
const ast = await getAst(event.fileName, event.getText());
- console.log(ast === undefined);
if (ast) {
DocumentAstTracker.getInstance().addDocument(
localPathOrUriToPath(event.fileName),
From bc7ae7c7c74c7d709dee2f370643f50ec6374819 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 15:20:07 -0700
Subject: [PATCH 086/244] feat: handle declaration nodes separately
---
.../NextEditEditableRegionCalculator.ts | 61 ++++++++++++++++++-
1 file changed, 59 insertions(+), 2 deletions(-)
diff --git a/core/nextEdit/NextEditEditableRegionCalculator.ts b/core/nextEdit/NextEditEditableRegionCalculator.ts
index 74dc011ba..04c5247c3 100644
--- a/core/nextEdit/NextEditEditableRegionCalculator.ts
+++ b/core/nextEdit/NextEditEditableRegionCalculator.ts
@@ -1,7 +1,7 @@
import Parser from "web-tree-sitter";
import { Chunk, IDE, ILLM, Position, Range, RangeInFile } from "..";
import { getAst } from "../autocomplete/util/ast";
-import { DocumentAstTracker } from "./DocumentAstTracker";
+import { DocumentAstTracker } from "./DocumentHistoryTracker";
export enum EditableRegionStrategy {
Naive = "naive",
@@ -431,6 +431,7 @@ function findClosestIdentifierNode(
if (!node) return null;
if (isIdentifierNode(node)) return node;
+ if (isDeclarationNode(node)) return findLeftmostIdentifier(node);
// Check if the parent is an identifier.
// NOTE: This will probably never get triggered.
@@ -441,9 +442,12 @@ function findClosestIdentifierNode(
}
if (parent) {
+ if (isDeclarationNode(parent)) return findLeftmostIdentifier(parent);
+
// Check if one of the siblings is an identifier.
for (let i = 0; i < parent.childCount; ++i) {
- const sibling = node.child(i);
+ // const sibling = node.child(i);
+ const sibling = parent.child(i);
if (sibling && isIdentifierNode(sibling)) {
// Get the leftmost identifier sibling.
return sibling;
@@ -454,6 +458,22 @@ function findClosestIdentifierNode(
return findClosestIdentifierNode(parent);
}
+function findLeftmostIdentifier(
+ node: Parser.SyntaxNode,
+): Parser.SyntaxNode | null {
+ if (isIdentifierNode(node)) return node;
+
+ for (let i = 0; i < node.childCount; ++i) {
+ const child = node.child(i);
+ if (child) {
+ const result = findLeftmostIdentifier(child);
+ if (result) return result;
+ }
+ }
+
+ return null;
+}
+
// Helper function to check if a node is an identifier.
function isIdentifierNode(node: Parser.SyntaxNode) {
const nodeType = node.type;
@@ -468,6 +488,43 @@ function isIdentifierNode(node: Parser.SyntaxNode) {
return specialIdentifiers.includes(nodeType);
}
+// Helper function to check if a node is a declaration.
+function isDeclarationNode(node: Parser.SyntaxNode) {
+ const nodeType = node.type;
+
+ // Common declaration patterns.
+ if (nodeType.endsWith("_declaration")) return true;
+ if (nodeType.endsWith("_definition")) return true;
+ if (nodeType.endsWith("_item")) return true; // Rust.
+
+ // Language-specific patterns.
+ const declarationTypes = [
+ // Python.
+ "function_definition",
+ "class_definition",
+ "async_function_definition",
+ "decorated_definition",
+
+ // Ruby.
+ "method",
+ "class",
+ "module",
+ "singleton_method",
+
+ // Java.
+ "variable_declarator",
+ "local_variable_declaration",
+
+ // Go.
+ "short_var_declaration",
+
+ // General
+ "method_definition",
+ ];
+
+ return declarationTypes.includes(nodeType);
+}
+
// // Helper function to find the closest identifier node.
// function findClosestIdentifierNode(
// node: Parser.SyntaxNode | undefined,
From cd8450f9d586c940a528e13ef711932b5de53963 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Fri, 25 Jul 2025 15:23:14 -0700
Subject: [PATCH 087/244] feat: await for deleteChain
---
extensions/vscode/src/commands.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts
index ce69ea87b..01db39411 100644
--- a/extensions/vscode/src/commands.ts
+++ b/extensions/vscode/src/commands.ts
@@ -878,7 +878,7 @@ const getCommandsMap: (
if (isFim) {
if (!fimText) {
console.log("deleteChain from commands.ts: !fimText");
- NextEditProvider.getInstance().deleteChain();
+ await NextEditProvider.getInstance().deleteChain();
}
// For FIM edits, create an inline completion item.
const nextEditCompletionItem = new vscode.InlineCompletionItem(
@@ -914,7 +914,7 @@ const getCommandsMap: (
const diffLines = myersDiff(oldEditRangeSlice, newEditRangeSlice);
if (diffLines.length === 0) {
console.log("deleteChain from commands.ts: diffLines.length === 0");
- NextEditProvider.getInstance().deleteChain();
+ await NextEditProvider.getInstance().deleteChain();
}
if (NextEditWindowManager.isInstantiated()) {
From 3ad095d70f73ca07d26a5986875f29e8f112c330 Mon Sep 17 00:00:00 2001
From: Nate
Date: Mon, 28 Jul 2025 11:06:35 -0700
Subject: [PATCH 088/244] fix test
---
extensions/vscode/src/util/util.vitest.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/extensions/vscode/src/util/util.vitest.ts b/extensions/vscode/src/util/util.vitest.ts
index 1d5eab4ec..246b81087 100644
--- a/extensions/vscode/src/util/util.vitest.ts
+++ b/extensions/vscode/src/util/util.vitest.ts
@@ -1,4 +1,4 @@
-import { afterEach, describe, expect, it, vi } from "vitest";
+import { afterEach, describe, expect, it, test, vi } from "vitest";
import * as vscode from "vscode";
// Mock the vscode module
From 94d32b6aeb41e62602bc2e0cd9c01c723cd3bdc1 Mon Sep 17 00:00:00 2001
From: Nate
Date: Mon, 28 Jul 2025 11:20:21 -0700
Subject: [PATCH 089/244] fix: respect maxRetries
---
core/control-plane/client.ts | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts
index c1686a75d..58b2ed71b 100644
--- a/core/control-plane/client.ts
+++ b/core/control-plane/client.ts
@@ -156,16 +156,22 @@ export class ControlPlaneClient {
// take effect. Otherwise the organization(s) won't show up.
// This error manifests as a 404 (user not found)
let retries = 0;
- const maxRetries = 5;
+ const maxRetries = 10;
const maxWaitTime = 20000; // 20 seconds in milliseconds
- while (true) {
+ while (retries < maxRetries) {
const resp = await this.request("ide/list-organizations", {
method: "GET",
});
if (resp.status === 404) {
retries++;
+ if (retries >= maxRetries) {
+ console.warn(
+ `Failed to list organizations after ${maxRetries} retries: user not found`,
+ );
+ return [];
+ }
const waitTime = Math.min(
Math.pow(2, retries) * 100,
maxWaitTime / maxRetries,
@@ -181,6 +187,12 @@ export class ControlPlaneClient {
const { organizations } = (await resp.json()) as any;
return organizations;
}
+
+ // This should never be reached due to the while condition, but adding for safety
+ console.warn(
+ `Failed to list organizations after ${maxRetries} retries: maximum attempts exceeded`,
+ );
+ return [];
}
public async listAssistantFullSlugs(
From 81dd2c3112653a1ee4f209baa072cef1eebc4c85 Mon Sep 17 00:00:00 2001
From: Patrick Erichsen
Date: Mon, 28 Jul 2025 14:15:49 -0700
Subject: [PATCH 090/244] Reapply "feat: enhance oneper utility and refactor
build system for commit SHA versioning" (#6811)
This reverts commit 880786b66fea10fa3c758f20d5ac79f64e230623.
---
.github/workflows/build-vscode-extension.yml | 204 +++++++
.github/workflows/main-build.yaml | 30 ++
.github/workflows/main.yaml | 146 +----
.github/workflows/pr_checks.yaml | 536 ++++---------------
.github/workflows/preview.yaml | 151 +-----
.vscode/launch.json | 6 +-
.vscode/tasks.json | 17 +
core/jest.config.js | 2 +-
core/llm/utils/retry.test.ts | 5 +-
core/llm/utils/retry.ts | 6 +-
core/package-lock.json | 69 ++-
core/package.json | 4 +-
extensions/vscode/package-lock.json | 79 +--
extensions/vscode/package.json | 4 +-
gui/package-lock.json | 9 +-
package-lock.json | 2 +-
packages/config-types/src/index.ts | 2 +-
packages/config-yaml/package-lock.json | 22 +-
packages/config-yaml/package.json | 2 +-
packages/continue-sdk/package-lock.json | 2 +-
packages/continue-sdk/package.json | 3 +-
packages/fetch/package-lock.json | 43 +-
packages/fetch/package.json | 3 +-
packages/llm-info/src/providers/gemini.ts | 6 +-
packages/openai-adapters/package-lock.json | 119 ++--
packages/openai-adapters/package.json | 6 +-
scripts/build-packages.ps1 | 38 +-
scripts/build-packages.sh | 42 +-
scripts/install-dependencies.ps1 | 37 +-
scripts/install-dependencies.sh | 37 +-
scripts/oneper | 14 +-
31 files changed, 707 insertions(+), 939 deletions(-)
create mode 100644 .github/workflows/build-vscode-extension.yml
create mode 100644 .github/workflows/main-build.yaml
diff --git a/.github/workflows/build-vscode-extension.yml b/.github/workflows/build-vscode-extension.yml
new file mode 100644
index 000000000..fd959807e
--- /dev/null
+++ b/.github/workflows/build-vscode-extension.yml
@@ -0,0 +1,204 @@
+name: Build VS Code Extension
+
+on:
+ workflow_call:
+ inputs:
+ platforms:
+ description: "JSON array of platform configurations (defaults to all platforms)"
+ required: false
+ type: string
+ default: |
+ [
+ {
+ "os": "windows-latest",
+ "platform": "win32",
+ "arch": "x64",
+ "npm_config_arch": "x64"
+ },
+ {
+ "os": "windows-latest",
+ "platform": "win32",
+ "arch": "arm64",
+ "npm_config_arch": "arm"
+ },
+ {
+ "os": "ubuntu-latest",
+ "platform": "linux",
+ "arch": "x64",
+ "npm_config_arch": "x64"
+ },
+ {
+ "os": "ubuntu-latest",
+ "platform": "linux",
+ "arch": "arm64",
+ "npm_config_arch": "arm64"
+ },
+ {
+ "os": "ubuntu-latest",
+ "platform": "linux",
+ "arch": "armhf",
+ "npm_config_arch": "arm"
+ },
+ {
+ "os": "ubuntu-latest",
+ "platform": "alpine",
+ "arch": "x64",
+ "npm_config_arch": "x64"
+ },
+ {
+ "os": "macos-13",
+ "platform": "darwin",
+ "arch": "x64",
+ "npm_config_arch": "x64"
+ },
+ {
+ "os": "macos-13",
+ "platform": "darwin",
+ "arch": "arm64",
+ "npm_config_arch": "arm64"
+ }
+ ]
+ pre-release:
+ description: "Whether to build as pre-release"
+ required: false
+ type: boolean
+ default: false
+ commit-sha:
+ description: "Commit SHA for version modification (optional, uses first 7 chars)"
+ required: false
+ type: string
+
+jobs:
+ build:
+ strategy:
+ matrix:
+ include: ${{ fromJson(inputs.platforms) }}
+ runs-on: ${{ matrix.os }}
+ steps:
+ # 1. Check-out repository
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0 # This ensures all tags are fetched
+
+ # 2. Install npm dependencies
+ - name: Use Node.js from .nvmrc
+ uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
+
+ - name: Cache extension node_modules
+ uses: actions/cache@v4
+ with:
+ path: extensions/vscode/node_modules
+ key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
+
+ - name: Cache core node_modules
+ uses: actions/cache@v4
+ with:
+ path: core/node_modules
+ key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
+
+ - name: Cache gui node_modules
+ uses: actions/cache@v4
+ with:
+ path: gui/node_modules
+ key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
+
+ # Build all packages using the authoritative build script
+ - name: Build packages (Windows)
+ run: ./scripts/build-packages.ps1
+ if: matrix.os == 'windows-latest'
+
+ - name: Build packages (Linux/macOS)
+ run: ./scripts/build-packages.sh
+ if: matrix.os != 'windows-latest'
+
+ - name: Install extension Dependencies
+ run: |
+ cd extensions/vscode
+ npm ci
+ env:
+ # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
+ GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
+
+ - name: Install gui Dependencies
+ run: |
+ cd gui
+ npm ci
+
+ # npm ci doesn't end up capturing the @lancedb/... dep because it's not in the package-lock.json
+ - name: Install Core Dependencies
+ run: |
+ cd core
+ npm ci
+ npm i vectordb
+
+ # 2.5. Pre package
+ - name: Set var for environment info
+ shell: pwsh
+ run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
+
+ - name: Prepackage the extension
+ run: |
+ cd extensions/vscode
+ npm run prepackage -- --target ${{ env.target }}
+
+ # 3. Re-install esbuild (for cases that we force installed for another arch in prepackage.js)
+ - name: Re-install esbuild
+ run: |
+ cd extensions/vscode
+ npm install -f esbuild
+
+ # 3.5. Modify version with commit SHA
+ - name: Modify package.json version with commit SHA
+ if: inputs.commit-sha != ''
+ run: |
+ cd extensions/vscode
+ # Get current version from package.json
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
+
+ # Create new version with short commit SHA (first 7 chars)
+ COMMIT_SHORT="${{ inputs.commit-sha }}"
+ NEW_VERSION="${CURRENT_VERSION}-${COMMIT_SHORT:0:7}"
+
+ echo "📝 Updating package.json version from $CURRENT_VERSION to $NEW_VERSION"
+
+ # Update version in package.json
+ sed -i.bak "s/\"version\": \"$CURRENT_VERSION\"/\"version\": \"$NEW_VERSION\"/" package.json
+
+ # Remove backup file
+ rm -f package.json.bak
+
+ # Verify the change
+ echo "✅ New version: $(node -p "require('./package.json').version")"
+
+ # 4. Package the extension
+ - name: Package extension (build artifacts)
+ run: |
+ cd extensions/vscode
+ npm run package
+
+ - name: Package extension (.vsix files)
+ run: |
+ cd extensions/vscode
+ if [ "${{ inputs.pre-release }}" = "true" ]; then
+ npx vsce package --pre-release --no-dependencies --target ${{ env.target }}
+ else
+ npx vsce package --no-dependencies --target ${{ env.target }}
+ fi
+ shell: bash
+
+ # 5. Upload build artifacts (for e2e tests)
+ - name: Upload build artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: vscode-extension-build-${{ runner.os }}
+ path: extensions/vscode/build
+
+ # 6. Upload .vsix artifacts (for releases and downloading)
+ - name: Upload .vsix artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ env.target }}-vsix
+ path: "extensions/vscode/*.vsix"
diff --git a/.github/workflows/main-build.yaml b/.github/workflows/main-build.yaml
new file mode 100644
index 000000000..de22d6c53
--- /dev/null
+++ b/.github/workflows/main-build.yaml
@@ -0,0 +1,30 @@
+name: Build Extension on Main
+
+on:
+ push:
+ branches:
+ - main
+
+jobs:
+ build:
+ uses: ./.github/workflows/build-vscode-extension.yml
+ with:
+ # Build only for macOS latest and Ubuntu latest
+ platforms: |
+ [
+ {
+ "os": "ubuntu-latest",
+ "platform": "linux",
+ "arch": "x64",
+ "npm_config_arch": "x64"
+ },
+ {
+ "os": "macos-latest",
+ "platform": "darwin",
+ "arch": "arm64",
+ "npm_config_arch": "arm64"
+ }
+ ]
+ pre-release: false
+ commit-sha: ${{ github.sha }}
+ secrets: inherit
\ No newline at end of file
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index ce1e59e66..a8abf6cb3 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -29,44 +29,15 @@ jobs:
build:
needs: check_release_name
if: needs.check_release_name.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
- strategy:
- matrix:
- include:
- - os: windows-latest
- platform: win32
- arch: x64
- npm_config_arch: x64
- - os: windows-latest
- platform: win32
- arch: arm64
- npm_config_arch: arm
- - os: ubuntu-latest
- platform: linux
- arch: x64
- npm_config_arch: x64
- - os: ubuntu-latest
- platform: linux
- arch: arm64
- npm_config_arch: arm64
- - os: ubuntu-latest
- platform: linux
- arch: armhf
- npm_config_arch: arm
- - os: ubuntu-latest
- platform: alpine
- arch: x64
- npm_config_arch: x64
- - os: macos-13
- platform: darwin
- arch: x64
- npm_config_arch: x64
- - os: macos-13
- platform: darwin
- arch: arm64
- npm_config_arch: arm64
- runs-on: ${{ matrix.os }}
+ uses: ./.github/workflows/build-vscode-extension.yml
+ with:
+ # Uses default platforms (all supported platforms)
+ pre-release: false
+ secrets: inherit
+
+ check-version:
+ runs-on: ubuntu-latest
steps:
- # 1. Check-out repository
- name: Checkout
uses: actions/checkout@v4
with:
@@ -80,107 +51,6 @@ jobs:
cd extensions/vscode
node scripts/versionCheck.js
- # 2. Install npm dependencies
- - name: Use Node.js from .nvmrc
- uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - name: Cache extension node_modules
- uses: actions/cache@v3
- with:
- path: extensions/vscode/node_modules
- key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
-
- - name: Cache core node_modules
- uses: actions/cache@v3
- with:
- path: core/node_modules
- key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
-
- - name: Cache gui node_modules
- uses: actions/cache@v3
- with:
- path: gui/node_modules
- key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
-
- - name: Build packages (Windows)
- run: ./scripts/build-packages.ps1
- if: matrix.os == 'windows-latest'
-
- - name: Build packages (Unix)
- run: ./scripts/build-packages.sh
- if: matrix.os != 'windows-latest'
-
- - name: Install extension Dependencies
- run: |
- cd extensions/vscode
- npm ci
- env:
- # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
- GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
-
- - name: Install gui Dependencies
- run: |
- cd gui
- npm ci
-
- # npm ci doesn't end up capturing the @lancedb/... dep because it's not in the package-lock.json
- - name: Install Core Dependencies
- run: |
- cd core
- npm ci
- npm i vectordb
-
- # - name: Run core tests
- # run: |
- # cd core
- # npm run test
- # env:
- # OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
-
- # 2.5. Pre package
- - name: Set var for environment info
- shell: pwsh
- run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
-
- - name: Prepackage the extension
- run: |
- cd extensions/vscode
- npm run prepackage -- --target ${{ env.target }}
-
- # 3. Re-install esbuild (for cases that we force installed for another arch in prepackage.js)
- - name: Re-install esbuild
- run: |
- cd extensions/vscode
- npm install -f esbuild
-
- # 4. Run tests for the extension
- # - name: Install Xvfb for Linux and run tests
- # run: |
- # sudo apt-get install -y xvfb # Install Xvfb
- # Xvfb :99 & # Start Xvfb
- # export DISPLAY=:99 # Export the display number to the environment
- # cd extensions/vscode
- # npm run test
- # if: matrix.os == 'ubuntu-latest'
-
- # - name: Run extension tests
- # run: |
- # cd extensions/vscode
- # npm run test
- # if: matrix.os != 'ubuntu-latest'
-
- # 5. Package the extension
- - name: Package the extension
- run: cd extensions/vscode && npx vsce package --no-dependencies --target ${{ env.target }}
-
- # 6. Upload the .vsix as an artifact
- - uses: actions/upload-artifact@v4
- with:
- name: ${{ env.target }}-vsix
- path: "extensions/vscode/*.vsix"
-
release:
permissions:
contents: write
diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml
index b4333890d..9733f856c 100644
--- a/.github/workflows/pr_checks.yaml
+++ b/.github/workflows/pr_checks.yaml
@@ -48,12 +48,9 @@ jobs:
- name: Check code formatting with Prettier
run: npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}" --ignore-path .gitignore --ignore-path .prettierignore
- install-config-yaml:
+ build-packages:
needs: install-root
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- os: [ubuntu-latest, macos-latest]
+ runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -61,55 +58,11 @@ jobs:
with:
node-version-file: ".nvmrc"
- - uses: actions/cache@v4
- with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - name: Install config-yaml dependencies
- if: steps.config-yaml-cache.outputs.cache-hit != 'true'
- run: |
- cd packages/config-yaml
- npm ci
-
- install-openai-adapters:
- needs: install-root
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- os: [ubuntu-latest, macos-latest]
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Install openai-adapters dependencies
- if: steps.openai-adapters-cache.outputs.cache-hit != 'true'
- run: |
- cd packages/openai-adapters
- npm ci
+ - name: Build packages (Unix)
+ run: ./scripts/build-packages.sh
config-yaml-checks:
- needs: install-config-yaml
+ needs: build-packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -123,19 +76,13 @@ jobs:
path: node_modules
key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - name: Build and check config-yaml
+ - name: Build packages and check config-yaml
run: |
+ ./scripts/build-packages.sh
cd packages/config-yaml
npx tsc --noEmit
# Tests are currently failing, commenting out for now
- # npm test
- npm run build
+ # npm test
install-core:
needs: install-root
@@ -169,7 +116,7 @@ jobs:
npm ci
core-checks:
- needs: [install-core, install-config-yaml, install-openai-adapters]
+ needs: install-core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -179,38 +126,21 @@ jobs:
node-version-file: ".nvmrc"
- uses: actions/cache@v4
- id: root-cache
with:
path: node_modules
key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
- uses: actions/cache@v4
- id: core-cache
with:
path: core/node_modules
key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and install core dependencies
run: |
- cd packages/config-yaml
- npm run build
+ ./scripts/build-packages.sh
+ cd core
+ npm ci
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
- name: Type check and lint
run: |
cd core
@@ -220,8 +150,7 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
install-gui:
- needs:
- [install-root, install-core, install-config-yaml, install-openai-adapters]
+ needs: [install-root, install-core]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -246,33 +175,15 @@ jobs:
path: gui/node_modules
key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and install dependencies
run: |
- cd packages/config-yaml
- npm run build
-
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
-
- - name: Install gui dependencies
- if: steps.gui-cache.outputs.cache-hit != 'true'
- run: |
- cd gui
- npm ci
+ ./scripts/build-packages.sh
+ if [ "${{ steps.gui-cache.outputs.cache-hit }}" != "true" ]; then
+ cd core
+ npm ci
+ cd ../gui
+ npm ci
+ fi
gui-checks:
needs: install-gui
@@ -294,32 +205,17 @@ jobs:
key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
- uses: actions/cache@v4
- id: gui-cache
with:
path: gui/node_modules
key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }}
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and install dependencies
run: |
- cd packages/config-yaml
- npm run build
-
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
+ ./scripts/build-packages.sh
+ cd core
+ npm ci
+ cd ../gui
+ npm ci
- name: Type check and lint
run: |
@@ -328,8 +224,7 @@ jobs:
npm run lint
binary-checks:
- needs:
- [install-root, install-core, install-config-yaml, install-openai-adapters]
+ needs: [install-root, install-core]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -354,33 +249,15 @@ jobs:
path: binary/node_modules
key: ${{ runner.os }}-binary-node-modules-${{ hashFiles('binary/package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and install dependencies
run: |
- cd packages/config-yaml
- npm run build
-
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
-
- - name: Install binary dependencies
- if: steps.binary-cache.outputs.cache-hit != 'true'
- run: |
- cd binary
- npm ci
+ ./scripts/build-packages.sh
+ if [ "${{ steps.binary-cache.outputs.cache-hit }}" != "true" ]; then
+ cd core
+ npm ci
+ cd ../binary
+ npm ci
+ fi
- name: Type check
run: |
@@ -388,8 +265,7 @@ jobs:
npx tsc --noEmit
install-vscode:
- needs:
- [install-root, install-core, install-config-yaml, install-openai-adapters]
+ needs: [install-root, install-core]
runs-on: ${{ matrix.os }}
strategy:
matrix:
@@ -417,33 +293,15 @@ jobs:
path: extensions/vscode/node_modules
key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and install dependencies
run: |
- cd packages/config-yaml
- npm run build
-
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
-
- - name: Install vscode dependencies
- if: steps.vscode-cache.outputs.cache-hit != 'true'
- run: |
- cd extensions/vscode
- npm ci
+ ./scripts/build-packages.sh
+ if [ "${{ steps.vscode-cache.outputs.cache-hit }}" != "true" ]; then
+ cd core
+ npm ci
+ cd ../extensions/vscode
+ npm ci
+ fi
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
@@ -473,27 +331,15 @@ jobs:
path: extensions/vscode/node_modules
key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and install dependencies
run: |
- cd packages/config-yaml
- npm run build
-
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
+ ./scripts/build-packages.sh
+ cd core
+ npm ci
+ cd ../extensions/vscode
+ npm ci
+ env:
+ GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
- name: Type check and lint
run: |
@@ -508,7 +354,7 @@ jobs:
npm run vitest
core-tests:
- needs: [install-core, install-config-yaml, install-openai-adapters]
+ needs: install-core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -522,27 +368,11 @@ jobs:
path: core/node_modules
key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and install core dependencies
run: |
- cd packages/config-yaml
- npm run build
-
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
+ ./scripts/build-packages.sh
+ cd core
+ npm ci
- name: Run core tests
run: |
@@ -569,23 +399,13 @@ jobs:
with:
node-version-file: ".nvmrc"
- - uses: actions/cache@v4
- with:
- path: core/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - name: Install dependencies
- run: |
- cd packages/config-yaml
- npm ci
-
- - name: Run config-yaml tests
+ - name: Build packages and run tests
run: |
+ ./scripts/build-packages.sh
cd packages/config-yaml
npm test
openai-adapters-tests:
- needs: install-openai-adapters
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -599,14 +419,9 @@ jobs:
path: node_modules
key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Run openai-adapters tests
+ - name: Build packages and run tests
run: |
+ ./scripts/build-packages.sh
cd packages/openai-adapters
npm test
env:
@@ -623,7 +438,7 @@ jobs:
vscode-get-test-file-matrix:
runs-on: ubuntu-latest
- needs: [install-root, install-vscode, install-config-yaml]
+ needs: [install-root, install-vscode]
outputs:
test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }}
steps:
@@ -635,21 +450,13 @@ jobs:
path: extensions/vscode/node_modules
key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - name: Build config-yaml
- run: |
- cd packages/config-yaml
- npm run build
-
- - name: Get test files
+ - name: Build packages and get test files
id: vscode-get-test-file-matrix
run: |
- cd extensions/vscode
+ ./scripts/build-packages.sh
+ cd core
+ npm ci
+ cd ../extensions/vscode
npm ci
npm run e2e:compile
if [[ "${{ github.event.pull_request.head.repo.fork }}" == "true" || "${{ github.actor }}" == "dependabot[bot]" ]]; then
@@ -671,78 +478,32 @@ jobs:
echo "Test files: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }}"
vscode-package-extension:
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- os: [ubuntu-latest, macos-latest]
- needs:
- [
- install-vscode,
- install-core,
- install-config-yaml,
- install-openai-adapters,
- ]
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- id: vscode-node-modules-cache
- with:
- path: extensions/vscode/node_modules
- key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: core-node-modules-cache
- with:
- path: core/node_modules
- key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Build config-yaml
- run: |
- cd packages/config-yaml
- npm run build
-
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
-
- - name: Package extension
- run: |
- cd extensions/vscode
- npm run package
-
- - name: Upload build artifact
- uses: actions/upload-artifact@v4
- with:
- name: vscode-extension-build-${{ runner.os }}
- path: extensions/vscode/build
+ needs: [install-vscode, install-core]
+ uses: ./.github/workflows/build-vscode-extension.yml
+ with:
+ # Limited platforms for faster PR checks
+ platforms: |
+ [
+ {
+ "os": "ubuntu-latest",
+ "platform": "linux",
+ "arch": "x64",
+ "npm_config_arch": "x64"
+ },
+ {
+ "os": "macos-13",
+ "platform": "darwin",
+ "arch": "x64",
+ "npm_config_arch": "x64"
+ }
+ ]
+ pre-release: false
+ commit-sha: ${{ github.sha }}
+ secrets: inherit
vscode-download-e2e-dependencies:
runs-on: ubuntu-latest
- needs:
- [
- install-vscode,
- install-core,
- install-config-yaml,
- install-openai-adapters,
- ]
+ needs: [install-vscode, install-core]
steps:
- uses: actions/checkout@v4
@@ -762,22 +523,15 @@ jobs:
path: extensions/vscode/e2e/storage
key: ${{ runner.os }}-vscode-storage-${{ hashFiles('extensions/vscode/package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and download e2e dependencies
run: |
- cd packages/config-yaml
- npm run build
-
- - name: Download Dependencies
- if: steps.storage-cache.outputs.cache-hit != 'true'
- run: |
- cd extensions/vscode
- npm run e2e:ci:download
+ ./scripts/build-packages.sh
+ if [ "${{ steps.storage-cache.outputs.cache-hit }}" != "true" ]; then
+ cd core
+ npm ci
+ cd ../extensions/vscode
+ npm run e2e:ci:download
+ fi
- name: Upload e2e dependencies
uses: actions/upload-artifact@v4
@@ -794,8 +548,6 @@ jobs:
vscode-package-extension,
install-vscode,
install-core,
- install-config-yaml,
- install-openai-adapters,
]
runs-on: ubuntu-latest
# Tests requiring secrets need approval from maintainers
@@ -836,27 +588,11 @@ jobs:
name: vscode-e2e-dependencies
path: extensions/vscode/e2e/storage
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and install core dependencies
run: |
- cd packages/config-yaml
- npm run build
-
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
+ ./scripts/build-packages.sh
+ cd core
+ npm ci
- name: Fix VSCode binary permissions
run: |
@@ -921,8 +657,7 @@ jobs:
path: extensions/vscode/e2e.log
gui-tests:
- needs:
- [install-gui, install-core, install-config-yaml, install-openai-adapters]
+ needs: [install-gui, install-core]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -932,7 +667,6 @@ jobs:
node-version-file: ".nvmrc"
- uses: actions/cache@v4
- id: gui-cache
with:
path: gui/node_modules
key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }}
@@ -942,31 +676,13 @@ jobs:
path: core/node_modules
key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and install dependencies
run: |
- cd packages/config-yaml
- npm run build
-
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
-
- - name: Install GUI dependencies
- if: steps.gui-cache.outputs.cache-hit != 'true'
- run: cd gui && npm ci
+ ./scripts/build-packages.sh
+ cd core
+ npm ci
+ cd ../gui
+ npm ci
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
@@ -976,8 +692,7 @@ jobs:
npm test
jetbrains-tests:
- needs:
- [install-root, core-checks, install-config-yaml, install-openai-adapters]
+ needs: [install-root, core-checks]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -986,27 +701,11 @@ jobs:
path: core/node_modules
key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
- - uses: actions/cache@v4
- id: config-yaml-cache
- with:
- path: packages/config-yaml/node_modules
- key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: openai-adapters-cache
- with:
- path: packages/openai-adapters/node_modules
- key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
-
- - name: Build config-yaml
+ - name: Build packages and install core dependencies
run: |
- cd packages/config-yaml
- npm run build
-
- - name: Build openai-adapters
- run: |
- cd packages/openai-adapters
- npm run build
+ ./scripts/build-packages.sh
+ cd core
+ npm ci
- name: Setup Java
uses: actions/setup-java@v4.5.0
@@ -1121,8 +820,7 @@ jobs:
- gui-tests
- jetbrains-tests
- config-yaml-checks
- - install-config-yaml
- - install-openai-adapters
+ - build-packages
- openai-adapters-tests
steps:
diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml
index 3ef4920ed..54d737e45 100644
--- a/.github/workflows/preview.yaml
+++ b/.github/workflows/preview.yaml
@@ -29,152 +29,11 @@ jobs:
build:
needs: check_release_name
if: needs.check_release_name.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
- strategy:
- matrix:
- include:
- - os: windows-latest
- platform: win32
- arch: x64
- npm_config_arch: x64
- - os: windows-latest
- platform: win32
- arch: arm64
- npm_config_arch: arm
- - os: ubuntu-latest
- platform: linux
- arch: x64
- npm_config_arch: x64
- - os: ubuntu-latest
- platform: linux
- arch: arm64
- npm_config_arch: arm64
- - os: ubuntu-latest
- platform: linux
- arch: armhf
- npm_config_arch: arm
- - os: ubuntu-latest
- platform: alpine
- arch: x64
- npm_config_arch: x64
- - os: macos-13
- platform: darwin
- arch: x64
- npm_config_arch: x64
- - os: macos-13
- platform: darwin
- arch: arm64
- npm_config_arch: arm64
- runs-on: ${{ matrix.os }}
- steps:
- # 1. Check-out repository
- - name: Checkout
- uses: actions/checkout@v4
- with:
- fetch-depth: 0 # This ensures all tags are fetched
-
- - name: Checkout tag
- run: git checkout ${GITHUB_REF#refs/tags/}
-
- # 2. Install npm dependencies
- - name: Use Node.js from .nvmrc
- uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - name: Cache extension node_modules
- uses: actions/cache@v3
- with:
- path: extensions/vscode/node_modules
- key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
-
- - name: Cache core node_modules
- uses: actions/cache@v3
- with:
- path: core/node_modules
- key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
-
- - name: Cache gui node_modules
- uses: actions/cache@v3
- with:
- path: gui/node_modules
- key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
-
- - name: Build packages (Windows)
- run: ./scripts/build-packages.ps1
- if: matrix.os == 'windows-latest'
-
- - name: Build packages (Unix)
- run: ./scripts/build-packages.sh
- if: matrix.os != 'windows-latest'
-
- - name: Install extension Dependencies
- run: |
- cd extensions/vscode
- npm ci
- env:
- # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
- GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
-
- - name: Install gui Dependencies
- run: |
- cd gui
- npm ci
-
- # npm ci doesn't end up capturing the @lancedb/... dep because it's not in the package-lock.json
- - name: Install Core Dependencies
- run: |
- cd core
- npm ci
- npm i vectordb
-
- # - name: Run core tests
- # run: |
- # cd core
- # npm run test
- # env:
- # OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
-
- # 2.5. Pre package
- - name: Set var for environment info
- shell: pwsh
- run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
-
- - name: Prepackage the extension
- run: |
- cd extensions/vscode
- npm run prepackage -- --target ${{ env.target }}
-
- # 3. Re-install esbuild (for cases that we force installed for another arch in prepackage.js)
- - name: Re-install esbuild
- run: |
- cd extensions/vscode
- npm install -f esbuild
-
- # 4. Run tests for the extension
- # - name: Install Xvfb for Linux and run tests
- # run: |
- # sudo apt-get install -y xvfb # Install Xvfb
- # Xvfb :99 & # Start Xvfb
- # export DISPLAY=:99 # Export the display number to the environment
- # cd extensions/vscode
- # npm run test
- # if: matrix.os == 'ubuntu-latest'
-
- # - name: Run extension tests
- # run: |
- # cd extensions/vscode
- # npm run test
- # if: matrix.os != 'ubuntu-latest'
-
- # 5. Package the extension
- - name: Package the extension
- run: cd extensions/vscode && npx vsce package --pre-release --no-dependencies --target ${{ env.target }}
-
- # 6. Upload the .vsix as an artifact
- - uses: actions/upload-artifact@v4
- with:
- name: ${{ env.target }}-vsix
- path: "extensions/vscode/*.vsix"
+ uses: ./.github/workflows/build-vscode-extension.yml
+ with:
+ # Uses default platforms (all supported platforms)
+ pre-release: true
+ secrets: inherit
release:
permissions:
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 53632f8d2..7d8624157 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -12,13 +12,13 @@
"cwd": "${workspaceFolder}/extensions/vscode",
"args": [
// Pass a directory to manually test in
- "${workspaceFolder}/manual-testing-sandbox",
- "${workspaceFolder}/manual-testing-sandbox/test.js",
+ "${workspaceFolder}/core",
+ "${workspaceFolder}/package.json",
"--extensionDevelopmentPath=${workspaceFolder}/extensions/vscode"
],
"pauseForSourceMap": false,
"outFiles": ["${workspaceFolder}/extensions/vscode/out/extension.js"],
- "preLaunchTask": "vscode-extension:build",
+ "preLaunchTask": "vscode-extension:build-with-packages",
"env": {
// "CONTROL_PLANE_ENV": "local",
"CONTINUE_GLOBAL_DIR": "${workspaceFolder}/extensions/.continue-debug"
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 5b0636368..9cb87f64c 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -223,6 +223,23 @@
],
"type": "shell",
"problemMatcher": []
+ },
+ {
+ "label": "build-packages",
+ "type": "shell",
+ "windows": { "command": "./scripts/build-packages.ps1" },
+ "command": "./scripts/build-packages.sh",
+ "problemMatcher": [],
+ "presentation": {
+ "reveal": "silent",
+ "panel": "shared"
+ }
+ },
+ {
+ "label": "vscode-extension:build-with-packages",
+ "dependsOn": ["build-packages", "vscode-extension:build"],
+ "type": "shell",
+ "problemMatcher": []
}
]
}
diff --git a/core/jest.config.js b/core/jest.config.js
index e4464b264..2fcbc3c5c 100644
--- a/core/jest.config.js
+++ b/core/jest.config.js
@@ -7,7 +7,7 @@ export default {
"ts-jest",
{
useESM: true,
- useIsolatedModules: true,
+ isolatedModules: true,
tsconfig: {
experimentalDecorators: true,
emitDecoratorMetadata: true,
diff --git a/core/llm/utils/retry.test.ts b/core/llm/utils/retry.test.ts
index 665e010c1..111463a0d 100644
--- a/core/llm/utils/retry.test.ts
+++ b/core/llm/utils/retry.test.ts
@@ -450,8 +450,9 @@ describe("Retry Functionality", () => {
expect(result).toBe("success");
// Should be capped at maxDelay (200ms) not header value (10000ms)
- expect(delays[0]).toBeGreaterThan(190);
- expect(delays[0]).toBeLessThan(210);
+ // Jitter is applied before maxDelay cap, so delay should never exceed maxDelay
+ expect(delays[0]).toBeGreaterThanOrEqual(190);
+ expect(delays[0]).toBeLessThanOrEqual(200);
});
it("should handle case-insensitive header names", async () => {
diff --git a/core/llm/utils/retry.ts b/core/llm/utils/retry.ts
index 416851378..dce06ef5c 100644
--- a/core/llm/utils/retry.ts
+++ b/core/llm/utils/retry.ts
@@ -149,10 +149,10 @@ function calculateDelay(
delayMs = Number(retryAfter) * 1000;
}
- // Respect maxDelay and add small jitter to spread requests
- const cappedDelay = Math.min(delayMs, maxDelay);
+ // Apply small jitter to spread requests, then respect maxDelay as hard limit
const jitterMultiplier = 1 + (Math.random() * 0.1 - 0.05); // Small jitter ±5%
- return Math.max(0, Math.floor(cappedDelay * jitterMultiplier));
+ const jitteredDelay = delayMs * jitterMultiplier;
+ return Math.max(0, Math.floor(Math.min(jitteredDelay, maxDelay)));
}
}
diff --git a/core/package-lock.json b/core/package-lock.json
index d2afa4b76..a864be394 100644
--- a/core/package-lock.json
+++ b/core/package-lock.json
@@ -14,8 +14,8 @@
"@aws-sdk/credential-providers": "^3.778.0",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "file:../packages/config-yaml",
- "@continuedev/fetch": "^1.0.14",
- "@continuedev/llm-info": "^1.0.8",
+ "@continuedev/fetch": "file:../packages/fetch",
+ "@continuedev/llm-info": "file:../packages/llm-info",
"@continuedev/openai-adapters": "file:../packages/openai-adapters",
"@modelcontextprotocol/sdk": "^1.12.0",
"@mozilla/readability": "^0.5.0",
@@ -38,6 +38,7 @@
"handlebars": "^4.7.8",
"http-proxy-agent": "^7.0.1",
"https-proxy-agent": "^7.0.3",
+ "iconv-lite": "^0.6.3",
"ignore": "^5.3.1",
"is-localhost-ip": "^2.0.0",
"jinja-js": "0.1.8",
@@ -145,7 +146,7 @@
"version": "1.0.96",
"license": "Apache-2.0",
"dependencies": {
- "@continuedev/config-types": "^1.0.14",
+ "@continuedev/config-types": "file:../config-types",
"yaml": "^2.6.1",
"zod": "^3.24.2"
},
@@ -167,17 +168,44 @@
"zod-to-json-schema": "^3.24.5"
}
},
+ "../packages/fetch": {
+ "name": "@continuedev/fetch",
+ "version": "1.0.15",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@continuedev/config-types": "file:../config-types",
+ "follow-redirects": "^1.15.6",
+ "http-proxy-agent": "^7.0.2",
+ "https-proxy-agent": "^7.0.5",
+ "node-fetch": "^3.3.2"
+ },
+ "devDependencies": {
+ "@types/follow-redirects": "^1.14.4",
+ "typescript": "^5.0.0",
+ "vitest": "^3.2.0"
+ }
+ },
+ "../packages/llm-info": {
+ "name": "@continuedev/llm-info",
+ "version": "1.0.9",
+ "license": "Apache-2.0",
+ "devDependencies": {
+ "@types/node": "^22.15.29",
+ "typescript": "^5.5.2"
+ }
+ },
"../packages/openai-adapters": {
"name": "@continuedev/openai-adapters",
- "version": "1.0.45",
+ "version": "1.0.46",
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/client-bedrock-runtime": "^3.842.0",
"@aws-sdk/credential-providers": "^3.840.0",
- "@continuedev/config-types": "^1.0.5",
- "@continuedev/config-yaml": "^1.0.51",
- "@continuedev/fetch": "^1.0.15",
+ "@continuedev/config-types": "file:../config-types",
+ "@continuedev/config-yaml": "file:../config-yaml",
+ "@continuedev/fetch": "file:../fetch",
"dotenv": "^16.5.0",
+ "google-auth-library": "^10.1.0",
"json-schema": "^0.4.0",
"node-fetch": "^3.3.2",
"openai": "^4.104.0",
@@ -185,13 +213,20 @@
"zod": "^3.24.2"
},
"devDependencies": {
+ "@semantic-release/changelog": "^6.0.3",
+ "@semantic-release/commit-analyzer": "^13.0.1",
+ "@semantic-release/git": "^10.0.1",
+ "@semantic-release/github": "^11.0.3",
+ "@semantic-release/npm": "^12.0.2",
+ "@semantic-release/release-notes-generator": "^14.0.3",
"@types/follow-redirects": "^1.14.4",
"@types/jest": "^29.5.14",
"@types/json-schema": "^7.0.15",
"cross-env": "^7.0.3",
+ "semantic-release": "^24.2.7",
"ts-jest": "^29.2.3",
"ts-node": "^10.9.2",
- "vitest": "^1.6.1"
+ "vitest": "^3.2.4"
}
},
"node_modules/@75lb/deep-merge": {
@@ -2918,22 +2953,12 @@
"link": true
},
"node_modules/@continuedev/fetch": {
- "version": "1.0.14",
- "resolved": "https://registry.npmjs.org/@continuedev/fetch/-/fetch-1.0.14.tgz",
- "integrity": "sha512-r/CUwW0tt7VrjLVNeowA281aq7VQvToE+Ro9+0EhfINBMNre4eU2MbNOgbRmYCr5VkIuSnltPUDI357Kns7uCw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@continuedev/config-types": "^1.0.5",
- "follow-redirects": "^1.15.6",
- "http-proxy-agent": "^7.0.2",
- "https-proxy-agent": "^7.0.5",
- "node-fetch": "^3.3.2"
- }
+ "resolved": "../packages/fetch",
+ "link": true
},
"node_modules/@continuedev/llm-info": {
- "version": "1.0.8",
- "resolved": "https://registry.npmjs.org/@continuedev/llm-info/-/llm-info-1.0.8.tgz",
- "integrity": "sha512-/htL7p4li3zQSwn9bXkI23WRpZNklWTPzRSSG3Fd5gvYW8cizjhlf7OzeDdKxBfi1S0lpqMm0VwHlx3KjMKLpw=="
+ "resolved": "../packages/llm-info",
+ "link": true
},
"node_modules/@continuedev/openai-adapters": {
"resolved": "../packages/openai-adapters",
diff --git a/core/package.json b/core/package.json
index 13830d83b..cebf2c189 100644
--- a/core/package.json
+++ b/core/package.json
@@ -54,8 +54,8 @@
"@aws-sdk/credential-providers": "^3.778.0",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "file:../packages/config-yaml",
- "@continuedev/fetch": "^1.0.14",
- "@continuedev/llm-info": "^1.0.8",
+ "@continuedev/fetch": "file:../packages/fetch",
+ "@continuedev/llm-info": "file:../packages/llm-info",
"@continuedev/openai-adapters": "file:../packages/openai-adapters",
"@modelcontextprotocol/sdk": "^1.12.0",
"@mozilla/readability": "^0.5.0",
diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json
index 3768befe3..9483160c6 100644
--- a/extensions/vscode/package-lock.json
+++ b/extensions/vscode/package-lock.json
@@ -1,16 +1,16 @@
{
"name": "continue",
- "version": "1.1.68",
+ "version": "1.1.67",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
- "version": "1.1.68",
+ "version": "1.1.67",
"license": "Apache-2.0",
"dependencies": {
- "@continuedev/config-types": "^1.0.14",
- "@continuedev/fetch": "^1.0.10",
+ "@continuedev/config-types": "file:../../packages/config-types",
+ "@continuedev/fetch": "file:../../packages/fetch",
"@electron/rebuild": "^3.2.10",
"@reduxjs/toolkit": "^1.9.3",
"@vscode/ripgrep": "^1.15.9",
@@ -105,8 +105,8 @@
"@aws-sdk/credential-providers": "^3.778.0",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "file:../packages/config-yaml",
- "@continuedev/fetch": "^1.0.14",
- "@continuedev/llm-info": "^1.0.8",
+ "@continuedev/fetch": "file:../packages/fetch",
+ "@continuedev/llm-info": "file:../packages/llm-info",
"@continuedev/openai-adapters": "file:../packages/openai-adapters",
"@modelcontextprotocol/sdk": "^1.12.0",
"@mozilla/readability": "^0.5.0",
@@ -129,6 +129,7 @@
"handlebars": "^4.7.8",
"http-proxy-agent": "^7.0.1",
"https-proxy-agent": "^7.0.3",
+ "iconv-lite": "^0.6.3",
"ignore": "^5.3.1",
"is-localhost-ip": "^2.0.0",
"jinja-js": "0.1.8",
@@ -142,7 +143,7 @@
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
"onnxruntime-node": "1.14.0",
- "openai": "^4.76.0",
+ "openai": "^4.104.0",
"p-limit": "^6.1.0",
"partial-json": "^0.1.7",
"pg": "^8.11.3",
@@ -207,6 +208,41 @@
"node": ">=20.19.0"
}
},
+ "../../packages/config-types": {
+ "name": "@continuedev/config-types",
+ "version": "1.0.14",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "zod": "^3.24.2"
+ },
+ "devDependencies": {
+ "@types/node": "^20.11.19",
+ "typescript": "^5.5.2"
+ }
+ },
+ "../../packages/fetch": {
+ "name": "@continuedev/fetch",
+ "version": "1.0.15",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@continuedev/config-types": "file:../config-types",
+ "follow-redirects": "^1.15.6",
+ "http-proxy-agent": "^7.0.2",
+ "https-proxy-agent": "^7.0.5",
+ "node-fetch": "^3.3.2"
+ },
+ "devDependencies": {
+ "@types/follow-redirects": "^1.14.4",
+ "typescript": "^5.0.0",
+ "vitest": "^3.2.0"
+ }
+ },
+ "../packages/config-types": {
+ "extraneous": true
+ },
+ "../packages/fetch": {
+ "extraneous": true
+ },
"node_modules/@75lb/deep-merge": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.2.tgz",
@@ -702,25 +738,12 @@
}
},
"node_modules/@continuedev/config-types": {
- "version": "1.0.14",
- "resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz",
- "integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==",
- "dependencies": {
- "zod": "^3.23.8"
- }
+ "resolved": "../../packages/config-types",
+ "link": true
},
"node_modules/@continuedev/fetch": {
- "version": "1.0.10",
- "resolved": "https://registry.npmjs.org/@continuedev/fetch/-/fetch-1.0.10.tgz",
- "integrity": "sha512-RBUXtm/VDz+9Itgw+CxrHXwVXoHCAedGzPOgA7gS5HZ9lObaeCJgEfzmfbln1ocFsfqSFmn5X5wSE7DHgfxpVA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@continuedev/config-types": "^1.0.5",
- "follow-redirects": "^1.15.6",
- "http-proxy-agent": "^7.0.2",
- "https-proxy-agent": "^7.0.5",
- "node-fetch": "^3.3.2"
- }
+ "resolved": "../../packages/fetch",
+ "link": true
},
"node_modules/@electron/node-gyp": {
"version": "10.2.0-electron.1",
@@ -16741,14 +16764,6 @@
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
- },
- "node_modules/zod": {
- "version": "3.23.8",
- "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
- "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
- "funding": {
- "url": "https://github.com/sponsors/colinhacks"
- }
}
}
}
diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json
index a3ca3a6b7..3f372f322 100644
--- a/extensions/vscode/package.json
+++ b/extensions/vscode/package.json
@@ -717,8 +717,8 @@
"vscode-extension-tester": "^8.14.1"
},
"dependencies": {
- "@continuedev/config-types": "^1.0.14",
- "@continuedev/fetch": "^1.0.10",
+ "@continuedev/config-types": "file:../../packages/config-types",
+ "@continuedev/fetch": "file:../../packages/fetch",
"@electron/rebuild": "^3.2.10",
"@reduxjs/toolkit": "^1.9.3",
"@vscode/ripgrep": "^1.15.9",
diff --git a/gui/package-lock.json b/gui/package-lock.json
index d611543e2..ce7be87e5 100644
--- a/gui/package-lock.json
+++ b/gui/package-lock.json
@@ -116,8 +116,8 @@
"@aws-sdk/credential-providers": "^3.778.0",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "file:../packages/config-yaml",
- "@continuedev/fetch": "^1.0.14",
- "@continuedev/llm-info": "^1.0.8",
+ "@continuedev/fetch": "file:../packages/fetch",
+ "@continuedev/llm-info": "file:../packages/llm-info",
"@continuedev/openai-adapters": "file:../packages/openai-adapters",
"@modelcontextprotocol/sdk": "^1.12.0",
"@mozilla/readability": "^0.5.0",
@@ -140,6 +140,7 @@
"handlebars": "^4.7.8",
"http-proxy-agent": "^7.0.1",
"https-proxy-agent": "^7.0.3",
+ "iconv-lite": "^0.6.3",
"ignore": "^5.3.1",
"is-localhost-ip": "^2.0.0",
"jinja-js": "0.1.8",
@@ -153,7 +154,7 @@
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
"onnxruntime-node": "1.14.0",
- "openai": "^4.76.0",
+ "openai": "^4.104.0",
"p-limit": "^6.1.0",
"partial-json": "^0.1.7",
"pg": "^8.11.3",
@@ -223,7 +224,7 @@
"version": "1.0.96",
"license": "Apache-2.0",
"dependencies": {
- "@continuedev/config-types": "^1.0.14",
+ "@continuedev/config-types": "file:../config-types",
"yaml": "^2.6.1",
"zod": "^3.24.2"
},
diff --git a/package-lock.json b/package-lock.json
index 0a2538840..b4289d422 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "wt-openai-adapters-tests",
+ "name": "continue",
"lockfileVersion": 3,
"requires": true,
"packages": {
diff --git a/packages/config-types/src/index.ts b/packages/config-types/src/index.ts
index fbc2d45fc..11c1ca20c 100644
--- a/packages/config-types/src/index.ts
+++ b/packages/config-types/src/index.ts
@@ -205,7 +205,7 @@ export type DevData = z.infer;
export const siteIndexingConfigSchema = z.object({
startUrl: z.string(),
- // rootUrl: z.string(),
+ rootUrl: z.string().optional(),
title: z.string(),
maxDepth: z.number().optional(),
faviconUrl: z.string().optional(),
diff --git a/packages/config-yaml/package-lock.json b/packages/config-yaml/package-lock.json
index 51091ea04..0689fc256 100644
--- a/packages/config-yaml/package-lock.json
+++ b/packages/config-yaml/package-lock.json
@@ -9,7 +9,7 @@
"version": "1.0.96",
"license": "Apache-2.0",
"dependencies": {
- "@continuedev/config-types": "^1.0.14",
+ "@continuedev/config-types": "file:../config-types",
"yaml": "^2.6.1",
"zod": "^3.24.2"
},
@@ -31,6 +31,18 @@
"zod-to-json-schema": "^3.24.5"
}
},
+ "../config-types": {
+ "name": "@continuedev/config-types",
+ "version": "1.0.14",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "zod": "^3.24.2"
+ },
+ "devDependencies": {
+ "@types/node": "^20.11.19",
+ "typescript": "^5.5.2"
+ }
+ },
"node_modules/@ampproject/remapping": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
@@ -558,12 +570,8 @@
}
},
"node_modules/@continuedev/config-types": {
- "version": "1.0.14",
- "resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz",
- "integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==",
- "dependencies": {
- "zod": "^3.23.8"
- }
+ "resolved": "../config-types",
+ "link": true
},
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",
diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json
index e0cb53693..ae0dd6d42 100644
--- a/packages/config-yaml/package.json
+++ b/packages/config-yaml/package.json
@@ -23,7 +23,7 @@
"author": "Continue Dev, Inc.",
"license": "Apache-2.0",
"dependencies": {
- "@continuedev/config-types": "^1.0.14",
+ "@continuedev/config-types": "file:../config-types",
"yaml": "^2.6.1",
"zod": "^3.24.2"
},
diff --git a/packages/continue-sdk/package-lock.json b/packages/continue-sdk/package-lock.json
index 85d4ac59e..7bae25f24 100644
--- a/packages/continue-sdk/package-lock.json
+++ b/packages/continue-sdk/package-lock.json
@@ -23,7 +23,7 @@
"version": "1.0.96",
"license": "Apache-2.0",
"dependencies": {
- "@continuedev/config-types": "^1.0.14",
+ "@continuedev/config-types": "file:../config-types",
"yaml": "^2.6.1",
"zod": "^3.24.2"
},
diff --git a/packages/continue-sdk/package.json b/packages/continue-sdk/package.json
index 1a450621e..fe08d0c05 100644
--- a/packages/continue-sdk/package.json
+++ b/packages/continue-sdk/package.json
@@ -4,6 +4,7 @@
"description": "SDK Generator for Continue.dev",
"type": "module",
"scripts": {
+ "build": "echo 'No build step needed'",
"generate-client:typescript": "openapi-generator-cli generate -i ./openapi.yaml -g typescript-fetch -o ./typescript/api -c ./openapi-generator-config.json",
"generate-client:python": "openapi-generator-cli generate -i ./openapi.yaml -g python -o ./python/api -c ./openapi-generator-config.json",
"generate-client:ALL": "npm run generate-client:typescript && npm run generate-client:python",
@@ -20,4 +21,4 @@
"devDependencies": {
"typescript": "^5.0.0"
}
-}
+}
\ No newline at end of file
diff --git a/packages/fetch/package-lock.json b/packages/fetch/package-lock.json
index a9a4742ff..a951dd5ce 100644
--- a/packages/fetch/package-lock.json
+++ b/packages/fetch/package-lock.json
@@ -9,7 +9,7 @@
"version": "1.0.16",
"license": "Apache-2.0",
"dependencies": {
- "@continuedev/config-types": "^1.0.5",
+ "@continuedev/config-types": "file:../config-types",
"follow-redirects": "^1.15.6",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.5",
@@ -17,17 +17,26 @@
},
"devDependencies": {
"@types/follow-redirects": "^1.14.4",
+ "typescript": "^5.0.0",
"vitest": "^3.2.0"
}
},
- "node_modules/@continuedev/config-types": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.5.tgz",
- "integrity": "sha512-Uv3JWKmpgSo9cMhZb2hWoJgR2ezuAn3CenEziWT/5d7mddPLzvuuHgFX6aDjLVVMojS1ul0rpfAd2LGxEb6nDQ==",
+ "../config-types": {
+ "name": "@continuedev/config-types",
+ "version": "1.0.14",
+ "license": "Apache-2.0",
"dependencies": {
- "zod": "^3.23.8"
+ "zod": "^3.24.2"
+ },
+ "devDependencies": {
+ "@types/node": "^20.11.19",
+ "typescript": "^5.5.2"
}
},
+ "node_modules/@continuedev/config-types": {
+ "resolved": "../config-types",
+ "link": true
+ },
"node_modules/@esbuild/aix-ppc64": {
"version": "0.25.5",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.5.tgz",
@@ -1350,6 +1359,20 @@
"node": ">=14.0.0"
}
},
+ "node_modules/typescript": {
+ "version": "5.8.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
+ "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "bin": {
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=14.17"
+ }
+ },
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
@@ -1585,14 +1608,6 @@
"engines": {
"node": ">=8"
}
- },
- "node_modules/zod": {
- "version": "3.23.8",
- "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
- "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
- "funding": {
- "url": "https://github.com/sponsors/colinhacks"
- }
}
}
}
diff --git a/packages/fetch/package.json b/packages/fetch/package.json
index b50a7ce84..e45cb829e 100644
--- a/packages/fetch/package.json
+++ b/packages/fetch/package.json
@@ -12,7 +12,7 @@
"author": "Nate Sesti and Ty Dunn",
"license": "Apache-2.0",
"dependencies": {
- "@continuedev/config-types": "^1.0.5",
+ "@continuedev/config-types": "file:../config-types",
"follow-redirects": "^1.15.6",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.5",
@@ -20,6 +20,7 @@
},
"devDependencies": {
"@types/follow-redirects": "^1.14.4",
+ "typescript": "^5.0.0",
"vitest": "^3.2.0"
}
}
diff --git a/packages/llm-info/src/providers/gemini.ts b/packages/llm-info/src/providers/gemini.ts
index 214ad1299..43eb8532b 100644
--- a/packages/llm-info/src/providers/gemini.ts
+++ b/packages/llm-info/src/providers/gemini.ts
@@ -43,7 +43,7 @@ export const Gemini: ModelProvider = {
contextLength: 1048576,
maxCompletionTokens: 8192,
mediaTypes: AllMediaTypes,
- regex: /gemini-2\.0-flash/i,
+ regex: /^gemini-2\.0-flash$/i,
recommendedFor: ["chat"],
},
{
@@ -54,7 +54,7 @@ export const Gemini: ModelProvider = {
contextLength: 1048576,
maxCompletionTokens: 8192,
mediaTypes: AllMediaTypes,
- regex: /gemini-2\.0-flash-lite/i,
+ regex: /^gemini-2\.0-flash-lite$/i,
recommendedFor: ["chat"],
},
{
@@ -86,7 +86,7 @@ export const Gemini: ModelProvider = {
contextLength: 1048576,
maxCompletionTokens: 8192,
mediaTypes: AllMediaTypes,
- regex: /gemini-2\.0-flash-exp/i,
+ regex: /^gemini-2\.0-flash-exp$/i,
recommendedFor: ["chat"],
},
{
diff --git a/packages/openai-adapters/package-lock.json b/packages/openai-adapters/package-lock.json
index a8769bb20..1aec0451a 100644
--- a/packages/openai-adapters/package-lock.json
+++ b/packages/openai-adapters/package-lock.json
@@ -11,9 +11,9 @@
"dependencies": {
"@aws-sdk/client-bedrock-runtime": "^3.842.0",
"@aws-sdk/credential-providers": "^3.840.0",
- "@continuedev/config-types": "^1.0.5",
- "@continuedev/config-yaml": "^1.0.51",
- "@continuedev/fetch": "^1.0.16",
+ "@continuedev/config-types": "file:../config-types",
+ "@continuedev/config-yaml": "file:../config-yaml",
+ "@continuedev/fetch": "file:../fetch",
"dotenv": "^16.5.0",
"google-auth-library": "^10.1.0",
"json-schema": "^0.4.0",
@@ -39,6 +39,65 @@
"vitest": "^3.2.4"
}
},
+ "../config-types": {
+ "name": "@continuedev/config-types",
+ "version": "1.0.14",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "zod": "^3.24.2"
+ },
+ "devDependencies": {
+ "@types/node": "^20.11.19",
+ "typescript": "^5.5.2"
+ }
+ },
+ "../config-yaml": {
+ "name": "@continuedev/config-yaml",
+ "version": "1.0.96",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@continuedev/config-types": "file:../config-types",
+ "yaml": "^2.6.1",
+ "zod": "^3.24.2"
+ },
+ "bin": {
+ "config-yaml": "dist/cli.js"
+ },
+ "devDependencies": {
+ "@semantic-release/changelog": "^6.0.3",
+ "@semantic-release/git": "^10.0.1",
+ "@semantic-release/github": "^9.2.6",
+ "@semantic-release/npm": "^10.0.6",
+ "@types/jest": "^29.5.14",
+ "@types/node": "^20.0.0",
+ "cross-env": "^7.0.3",
+ "jest": "^29.7.0",
+ "semantic-release": "^21.1.2",
+ "ts-jest": "^29.2.3",
+ "ts-node": "^10.9.2",
+ "zod-to-json-schema": "^3.24.5"
+ }
+ },
+ "../fetch": {
+ "name": "@continuedev/fetch",
+ "version": "1.0.15",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@continuedev/config-types": "file:../config-types",
+ "follow-redirects": "^1.15.6",
+ "http-proxy-agent": "^7.0.2",
+ "https-proxy-agent": "^7.0.5",
+ "node-fetch": "^3.3.2"
+ },
+ "devDependencies": {
+ "@types/follow-redirects": "^1.14.4",
+ "typescript": "^5.0.0",
+ "vitest": "^3.2.0"
+ }
+ },
+ "../packages/fetch": {
+ "extraneous": true
+ },
"node_modules/@ampproject/remapping": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
@@ -1333,35 +1392,16 @@
}
},
"node_modules/@continuedev/config-types": {
- "version": "1.0.14",
- "resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz",
- "integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==",
- "dependencies": {
- "zod": "^3.23.8"
- }
+ "resolved": "../config-types",
+ "link": true
},
"node_modules/@continuedev/config-yaml": {
- "version": "1.0.68",
- "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.68.tgz",
- "integrity": "sha512-rCegSGkv7Ws7LLnYVVGwXsoVZFpNFJnG6b1dVrj/u+2ZsFdA2leQUNtFGoeE/ixyfhUfBpMlgjEyPrmmy7gLjw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@continuedev/config-types": "^1.0.14",
- "yaml": "^2.6.1",
- "zod": "^3.24.2"
- }
+ "resolved": "../config-yaml",
+ "link": true
},
"node_modules/@continuedev/fetch": {
- "version": "1.0.16",
- "resolved": "https://registry.npmjs.org/@continuedev/fetch/-/fetch-1.0.16.tgz",
- "integrity": "sha512-LSjVbTKA+UwqCjV8x45sfJQGtG/iekkqCYpSJsakY0ruad807swwEuuui5luuYVUhJAZZpVfZzeJArHfjiJJSw==",
- "dependencies": {
- "@continuedev/config-types": "^1.0.5",
- "follow-redirects": "^1.15.6",
- "http-proxy-agent": "^7.0.2",
- "https-proxy-agent": "^7.0.5",
- "node-fetch": "^3.3.2"
- }
+ "resolved": "../fetch",
+ "link": true
},
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",
@@ -5857,25 +5897,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/follow-redirects": {
- "version": "1.15.6",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
- "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
- "funding": [
- {
- "type": "individual",
- "url": "https://github.com/sponsors/RubenVerborgh"
- }
- ],
- "engines": {
- "node": ">=4.0"
- },
- "peerDependenciesMeta": {
- "debug": {
- "optional": true
- }
- }
- },
"node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
@@ -6302,6 +6323,7 @@
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz",
"integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==",
+ "dev": true,
"dependencies": {
"agent-base": "^7.1.0",
"debug": "^4.3.4"
@@ -13209,6 +13231,9 @@
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz",
"integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==",
+ "dev": true,
+ "optional": true,
+ "peer": true,
"bin": {
"yaml": "bin.mjs"
},
diff --git a/packages/openai-adapters/package.json b/packages/openai-adapters/package.json
index 51771868f..0065bba17 100644
--- a/packages/openai-adapters/package.json
+++ b/packages/openai-adapters/package.json
@@ -14,9 +14,9 @@
"dependencies": {
"@aws-sdk/client-bedrock-runtime": "^3.842.0",
"@aws-sdk/credential-providers": "^3.840.0",
- "@continuedev/config-types": "^1.0.5",
- "@continuedev/config-yaml": "^1.0.51",
- "@continuedev/fetch": "^1.0.16",
+ "@continuedev/config-types": "file:../config-types",
+ "@continuedev/config-yaml": "file:../config-yaml",
+ "@continuedev/fetch": "file:../fetch",
"dotenv": "^16.5.0",
"google-auth-library": "^10.1.0",
"json-schema": "^0.4.0",
diff --git a/scripts/build-packages.ps1 b/scripts/build-packages.ps1
index cd415b3df..740587330 100755
--- a/scripts/build-packages.ps1
+++ b/scripts/build-packages.ps1
@@ -1,13 +1,43 @@
+# Use npm ci in CI, npm install in development
+if ($env:CI -eq "true") {
+ $npmInstallCmd = "npm ci"
+} else {
+ $npmInstallCmd = "npm install"
+}
+
Push-Location packages
-Push-Location "openai-adapters"
-npm ci
+# Phase 1: Build config-types (foundation - no dependencies)
+Push-Location "config-types"
+& cmd /c $npmInstallCmd
+npm run build
+Pop-Location
+
+# Phase 2: Build packages that depend on config-types
+Push-Location "fetch"
+& cmd /c $npmInstallCmd
npm run build
Pop-Location
Push-Location "config-yaml"
-npm ci
+& cmd /c $npmInstallCmd
npm run build
Pop-Location
-Pop-Location
\ No newline at end of file
+Push-Location "llm-info"
+& cmd /c $npmInstallCmd
+npm run build
+Pop-Location
+
+# Phase 3: Build packages that depend on other local packages
+Push-Location "openai-adapters"
+& cmd /c $npmInstallCmd
+npm run build
+Pop-Location
+
+Push-Location "continue-sdk"
+& cmd /c $npmInstallCmd
+npm run build
+Pop-Location
+
+Pop-Location
diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh
index fa6f62731..a2390ad5a 100755
--- a/scripts/build-packages.sh
+++ b/scripts/build-packages.sh
@@ -1,13 +1,45 @@
# Build @continuedev packages for monorepo style linking
+# Use npm ci in CI, npm install in development
+if [ "$CI" = "true" ]; then
+ NPM_INSTALL_CMD="npm ci"
+else
+ NPM_INSTALL_CMD="npm install"
+fi
+
cd packages
-cd openai-adapters
-npm ci
+# Phase 1: Build config-types (foundation - no dependencies)
+cd config-types
+$NPM_INSTALL_CMD
npm run build
-
cd ..
-cd config-yaml
-npm ci
+# Phase 2: Build packages that depend on config-types
+cd fetch
+$NPM_INSTALL_CMD
npm run build
+cd ..
+
+cd config-yaml
+$NPM_INSTALL_CMD
+npm run build
+cd ..
+
+cd llm-info
+$NPM_INSTALL_CMD
+npm run build
+cd ..
+
+# Phase 3: Build packages that depend on other local packages
+cd openai-adapters
+rm -rf node_modules
+$NPM_INSTALL_CMD
+npm run build
+cd ..
+
+cd continue-sdk
+rm -rf node_modules
+$NPM_INSTALL_CMD
+npm run build
+cd ..
\ No newline at end of file
diff --git a/scripts/install-dependencies.ps1 b/scripts/install-dependencies.ps1
index 1e258f9fd..bb957b090 100644
--- a/scripts/install-dependencies.ps1
+++ b/scripts/install-dependencies.ps1
@@ -76,41 +76,8 @@ if (($null -eq $node)) {
Write-Host "`nInstalling root-level dependencies..." -ForegroundColor White
npm install
-Write-Host "`nBuilding config-types..." -ForegroundColor White
-Push-Location packages/config-types
-npm install
-npm run build
-Pop-Location
-
-Write-Host "`nBuilding fetch..." -ForegroundColor White
-Push-Location packages/fetch
-npm install
-npm run build
-Pop-Location
-
-Write-Host "`nBuilding llm-info..." -ForegroundColor White
-Push-Location packages/llm-info
-npm install
-npm run build
-Pop-Location
-
-Write-Host "`nBuilding config-yaml..." -ForegroundColor White
-Push-Location packages/config-yaml
-npm install
-npm run build
-Pop-Location
-
-Write-Host "`nBuilding openai-adapters..." -ForegroundColor White
-Push-Location packages/openai-adapters
-npm install
-npm run build
-Pop-Location
-
-Write-Host "`nBuilding hub..." -ForegroundColor White
-Push-Location packages/hub
-npm install
-npm run build
-Pop-Location
+Write-Host "`nBuilding packages (fetch, openai-adapters, config-yaml)..." -ForegroundColor White
+& .\scripts\build-packages.ps1
Write-Host "`nInstalling Core extension dependencies..." -ForegroundColor White
Push-Location core
diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh
index 3f3e54f7b..294ce5628 100755
--- a/scripts/install-dependencies.sh
+++ b/scripts/install-dependencies.sh
@@ -30,41 +30,8 @@ fi
echo "Installing root-level dependencies..."
npm install
-echo "Building config-types..."
-pushd packages/config-types
-npm install
-npm run build
-popd
-
-echo "Building fetch..."
-pushd packages/fetch
-npm install
-npm run build
-popd
-
-echo "Building llm-info..."
-pushd packages/llm-info
-npm install
-npm run build
-popd
-
-echo "Building config-yaml..."
-pushd packages/config-yaml
-npm install
-npm run build
-popd
-
-echo "Building openai-adapters..."
-pushd packages/openai-adapters
-npm install
-npm run build
-popd
-
-echo "Building hub..."
-pushd packages/hub
-npm install
-npm run build
-popd
+echo "Building packages (fetch, openai-adapters, config-yaml)..."
+./scripts/build-packages.sh
echo "Installing Core extension dependencies..."
pushd core
diff --git a/scripts/oneper b/scripts/oneper
index 52ad8623a..6d22fb03c 100755
--- a/scripts/oneper
+++ b/scripts/oneper
@@ -74,6 +74,7 @@ ensure_oneper_dir() {
fi
}
+
install_from_pr() {
local pr_number=$1
local platform=${2:-$(detect_os)} # Auto-detect OS if not specified
@@ -153,17 +154,17 @@ install_from_pr() {
exit 1
fi
- # Extract version from the original VSIX filename (e.g., continue-1.1.66.vsix -> 1.1.66)
+ # Extract full version from the original VSIX filename (e.g., continue-1.1.66-a1b2c3d.vsix -> 1.1.66-a1b2c3d)
local original_filename=$(basename "$vsix_file")
- local version=$(echo "$original_filename" | sed 's/continue-\(.*\)\.vsix/\1/')
+ local full_version=$(echo "$original_filename" | sed 's/continue-\(.*\)\.vsix/\1/')
- if [ -z "$version" ]; then
+ if [ -z "$full_version" ]; then
echo "⚠️ Could not extract version from filename: $original_filename"
- version="unknown"
+ full_version="unknown-pr${pr_number}"
fi
- # Create new VSIX name with version and PR number
- local target_path="$ONEPER_DIR/continue-${version}-${pr_number}.vsix"
+ # Use the full version (which includes commit SHA) for the target filename
+ local target_path="$ONEPER_DIR/continue-${full_version}.vsix"
# Check if file already exists and notify about overwrite
if [ -f "$target_path" ]; then
@@ -181,6 +182,7 @@ install_from_pr() {
if code --install-extension "$target_path"; then
echo "✅ Successfully installed Continue extension from PR #$pr_number"
echo "📄 VSIX file saved to: $target_path"
+ echo "🔖 Extension version: ${full_version} (includes commit SHA)"
echo ""
echo "💡 To use the new extension version, reload your VS Code window:"
echo " • Press Ctrl+Shift+P (Cmd+Shift+P on Mac)"
From 0f582f200200af881c23531c6acc1112fd367584 Mon Sep 17 00:00:00 2001
From: Patrick Erichsen
Date: Mon, 28 Jul 2025 14:22:11 -0700
Subject: [PATCH 091/244] feat: restore enhanced build system and integrate
parallel build script
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This PR combines two improvements to the build system:
1. **Restore Enhanced Build System** (reverts PR #6811)
- Restores commit SHA versioning for VS Code extensions
- Brings back reusable GitHub Actions workflows
- Re-enables monorepo build system with local file dependencies
- Restores enhanced oneper utility with commit SHA support
2. **Integrate Parallel Build Script** (integrates PR #6821)
- Replaces shell/PowerShell build scripts with JavaScript version
- Implements parallel package building for 40% faster builds (20s → 12s)
- Cross-platform compatibility using Node.js instead of platform-specific scripts
- Enhanced error reporting and build status visibility
## Key Changes
- ✅ Reusable GitHub Actions workflow for VS Code extension builds
- ✅ Commit SHA versioning restored in extension package.json
- ✅ Enhanced oneper utility with full commit SHA support
- ✅ New `scripts/build-packages.js` with parallel execution
- ✅ Removed platform-specific `build-packages.sh` and `build-packages.ps1`
- ✅ Updated all workflows and tasks to use the new build script
## Performance Impact
Build time improvement: **20s → 12s** (40% faster) due to parallel execution
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude
---
.github/workflows/build-vscode-extension.yml | 9 +-
.github/workflows/jetbrains-release.yaml | 2 +-
.github/workflows/pr_checks.yaml | 32 +++---
.vscode/tasks.json | 3 +-
packages/openai-adapters/package-lock.json | 2 +-
scripts/build-packages.js | 100 +++++++++++++++++++
scripts/build-packages.ps1 | 43 --------
scripts/build-packages.sh | 45 ---------
scripts/install-dependencies.ps1 | 2 +-
scripts/install-dependencies.sh | 2 +-
10 files changed, 123 insertions(+), 117 deletions(-)
create mode 100644 scripts/build-packages.js
delete mode 100755 scripts/build-packages.ps1
delete mode 100755 scripts/build-packages.sh
diff --git a/.github/workflows/build-vscode-extension.yml b/.github/workflows/build-vscode-extension.yml
index fd959807e..4bb008d46 100644
--- a/.github/workflows/build-vscode-extension.yml
+++ b/.github/workflows/build-vscode-extension.yml
@@ -106,13 +106,8 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
# Build all packages using the authoritative build script
- - name: Build packages (Windows)
- run: ./scripts/build-packages.ps1
- if: matrix.os == 'windows-latest'
-
- - name: Build packages (Linux/macOS)
- run: ./scripts/build-packages.sh
- if: matrix.os != 'windows-latest'
+ - name: Build packages
+ run: node ./scripts/build-packages.js
- name: Install extension Dependencies
run: |
diff --git a/.github/workflows/jetbrains-release.yaml b/.github/workflows/jetbrains-release.yaml
index 531129c79..afdb544f3 100644
--- a/.github/workflows/jetbrains-release.yaml
+++ b/.github/workflows/jetbrains-release.yaml
@@ -167,7 +167,7 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
- name: Build packages (Unix)
- run: cd ../.. && ./scripts/build-packages.sh
+ run: cd ../.. && node ./scripts/build-packages.js
# npm install core
- name: Install core node_modules
diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml
index 9733f856c..a78035a6e 100644
--- a/.github/workflows/pr_checks.yaml
+++ b/.github/workflows/pr_checks.yaml
@@ -59,7 +59,7 @@ jobs:
node-version-file: ".nvmrc"
- name: Build packages (Unix)
- run: ./scripts/build-packages.sh
+ run: node ./scripts/build-packages.js
config-yaml-checks:
needs: build-packages
@@ -78,7 +78,7 @@ jobs:
- name: Build packages and check config-yaml
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd packages/config-yaml
npx tsc --noEmit
# Tests are currently failing, commenting out for now
@@ -137,7 +137,7 @@ jobs:
- name: Build packages and install core dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd core
npm ci
@@ -177,7 +177,7 @@ jobs:
- name: Build packages and install dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
if [ "${{ steps.gui-cache.outputs.cache-hit }}" != "true" ]; then
cd core
npm ci
@@ -211,7 +211,7 @@ jobs:
- name: Build packages and install dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd core
npm ci
cd ../gui
@@ -251,7 +251,7 @@ jobs:
- name: Build packages and install dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
if [ "${{ steps.binary-cache.outputs.cache-hit }}" != "true" ]; then
cd core
npm ci
@@ -295,7 +295,7 @@ jobs:
- name: Build packages and install dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
if [ "${{ steps.vscode-cache.outputs.cache-hit }}" != "true" ]; then
cd core
npm ci
@@ -333,7 +333,7 @@ jobs:
- name: Build packages and install dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd core
npm ci
cd ../extensions/vscode
@@ -370,7 +370,7 @@ jobs:
- name: Build packages and install core dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd core
npm ci
@@ -401,7 +401,7 @@ jobs:
- name: Build packages and run tests
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd packages/config-yaml
npm test
@@ -421,7 +421,7 @@ jobs:
- name: Build packages and run tests
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd packages/openai-adapters
npm test
env:
@@ -453,7 +453,7 @@ jobs:
- name: Build packages and get test files
id: vscode-get-test-file-matrix
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd core
npm ci
cd ../extensions/vscode
@@ -525,7 +525,7 @@ jobs:
- name: Build packages and download e2e dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
if [ "${{ steps.storage-cache.outputs.cache-hit }}" != "true" ]; then
cd core
npm ci
@@ -590,7 +590,7 @@ jobs:
- name: Build packages and install core dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd core
npm ci
@@ -678,7 +678,7 @@ jobs:
- name: Build packages and install dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd core
npm ci
cd ../gui
@@ -703,7 +703,7 @@ jobs:
- name: Build packages and install core dependencies
run: |
- ./scripts/build-packages.sh
+ node ./scripts/build-packages.js
cd core
npm ci
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 9cb87f64c..5fd0c86b7 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -227,8 +227,7 @@
{
"label": "build-packages",
"type": "shell",
- "windows": { "command": "./scripts/build-packages.ps1" },
- "command": "./scripts/build-packages.sh",
+ "command": "node ./scripts/build-packages.js",
"problemMatcher": [],
"presentation": {
"reveal": "silent",
diff --git a/packages/openai-adapters/package-lock.json b/packages/openai-adapters/package-lock.json
index 1aec0451a..731bfe01b 100644
--- a/packages/openai-adapters/package-lock.json
+++ b/packages/openai-adapters/package-lock.json
@@ -80,7 +80,7 @@
},
"../fetch": {
"name": "@continuedev/fetch",
- "version": "1.0.15",
+ "version": "1.0.16",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-types": "file:../config-types",
diff --git a/scripts/build-packages.js b/scripts/build-packages.js
new file mode 100644
index 000000000..e268cd215
--- /dev/null
+++ b/scripts/build-packages.js
@@ -0,0 +1,100 @@
+const { spawn } = require("child_process");
+const path = require("path");
+const fs = require("fs");
+const fsPromises = require("fs/promises");
+
+const npmInstallCmd = process.env.CI === "true" ? "npm ci" : "npm install";
+
+function runCommand(command, cwd, packageName) {
+ return new Promise((resolve, reject) => {
+ console.log(`Starting ${packageName}: ${command}`);
+
+ const [cmd, ...args] = command.split(" ");
+ const child = spawn(cmd, args, {
+ cwd,
+ stdio: "pipe",
+ shell: true,
+ });
+
+ let stdout = "";
+ let stderr = "";
+
+ child.stdout.on("data", (data) => {
+ stdout += data.toString();
+ });
+
+ child.stderr.on("data", (data) => {
+ stderr += data.toString();
+ });
+
+ child.on("close", (code) => {
+ if (code === 0) {
+ console.log(`✅ ${packageName}: ${command} completed successfully`);
+ resolve({ packageName, command, stdout, stderr });
+ } else {
+ console.error(`❌ ${packageName}: ${command} failed with code ${code}`);
+ console.error(`stderr: ${stderr}`);
+ reject(
+ new Error(`${packageName} failed: ${command} (exit code ${code})`),
+ );
+ }
+ });
+
+ child.on("error", (error) => {
+ console.error(`❌ ${packageName}: Failed to start ${command}:`, error);
+ reject(error);
+ });
+ });
+}
+
+// Helper function to build a package (install + build)
+async function buildPackage(packageName, cleanNodeModules = false) {
+ const packagePath = path.join(__dirname, "..", "packages", packageName);
+
+ if (!fs.existsSync(packagePath)) {
+ throw new Error(`Package directory not found: ${packagePath}`);
+ }
+
+ if (cleanNodeModules) {
+ const nodeModulesPath = path.join(packagePath, "node_modules");
+ if (fs.existsSync(nodeModulesPath)) {
+ console.log(`🧹 Cleaning node_modules for ${packageName}`);
+ await fsPromises.rm(nodeModulesPath, { recursive: true, force: true });
+ }
+ }
+
+ await runCommand(npmInstallCmd, packagePath, `${packageName} (install)`);
+
+ return runCommand("npm run build", packagePath, `${packageName} (build)`);
+}
+
+async function buildPackagesInParallel(packages, cleanNodeModules = false) {
+ const buildPromises = packages.map((pkg) =>
+ buildPackage(pkg, cleanNodeModules),
+ );
+ return Promise.all(buildPromises);
+}
+
+async function main() {
+ try {
+ console.log("🚀 Starting package builds...\n");
+
+ // Phase 1: Build config-types (foundation - no dependencies)
+ await buildPackagesInParallel(["config-types"]);
+
+ // Phase 2: Build packages that depend on config-types
+ await buildPackagesInParallel(["fetch", "config-yaml", "llm-info"]);
+
+ // Phase 3: Build packages that depend on other local packages
+ await buildPackagesInParallel(["openai-adapters", "continue-sdk"], true);
+
+ console.log("🎉 All packages built successfully!");
+ } catch (error) {
+ console.error("💥 Build failed:", error.message);
+ process.exit(1);
+ }
+}
+
+if (require.main === module) {
+ main();
+}
\ No newline at end of file
diff --git a/scripts/build-packages.ps1 b/scripts/build-packages.ps1
deleted file mode 100755
index 740587330..000000000
--- a/scripts/build-packages.ps1
+++ /dev/null
@@ -1,43 +0,0 @@
-# Use npm ci in CI, npm install in development
-if ($env:CI -eq "true") {
- $npmInstallCmd = "npm ci"
-} else {
- $npmInstallCmd = "npm install"
-}
-
-Push-Location packages
-
-# Phase 1: Build config-types (foundation - no dependencies)
-Push-Location "config-types"
-& cmd /c $npmInstallCmd
-npm run build
-Pop-Location
-
-# Phase 2: Build packages that depend on config-types
-Push-Location "fetch"
-& cmd /c $npmInstallCmd
-npm run build
-Pop-Location
-
-Push-Location "config-yaml"
-& cmd /c $npmInstallCmd
-npm run build
-Pop-Location
-
-Push-Location "llm-info"
-& cmd /c $npmInstallCmd
-npm run build
-Pop-Location
-
-# Phase 3: Build packages that depend on other local packages
-Push-Location "openai-adapters"
-& cmd /c $npmInstallCmd
-npm run build
-Pop-Location
-
-Push-Location "continue-sdk"
-& cmd /c $npmInstallCmd
-npm run build
-Pop-Location
-
-Pop-Location
diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh
deleted file mode 100755
index a2390ad5a..000000000
--- a/scripts/build-packages.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-# Build @continuedev packages for monorepo style linking
-
-# Use npm ci in CI, npm install in development
-if [ "$CI" = "true" ]; then
- NPM_INSTALL_CMD="npm ci"
-else
- NPM_INSTALL_CMD="npm install"
-fi
-
-cd packages
-
-# Phase 1: Build config-types (foundation - no dependencies)
-cd config-types
-$NPM_INSTALL_CMD
-npm run build
-cd ..
-
-# Phase 2: Build packages that depend on config-types
-cd fetch
-$NPM_INSTALL_CMD
-npm run build
-cd ..
-
-cd config-yaml
-$NPM_INSTALL_CMD
-npm run build
-cd ..
-
-cd llm-info
-$NPM_INSTALL_CMD
-npm run build
-cd ..
-
-# Phase 3: Build packages that depend on other local packages
-cd openai-adapters
-rm -rf node_modules
-$NPM_INSTALL_CMD
-npm run build
-cd ..
-
-cd continue-sdk
-rm -rf node_modules
-$NPM_INSTALL_CMD
-npm run build
-cd ..
\ No newline at end of file
diff --git a/scripts/install-dependencies.ps1 b/scripts/install-dependencies.ps1
index bb957b090..33a269219 100644
--- a/scripts/install-dependencies.ps1
+++ b/scripts/install-dependencies.ps1
@@ -77,7 +77,7 @@ Write-Host "`nInstalling root-level dependencies..." -ForegroundColor White
npm install
Write-Host "`nBuilding packages (fetch, openai-adapters, config-yaml)..." -ForegroundColor White
-& .\scripts\build-packages.ps1
+node ./scripts/build-packages.js
Write-Host "`nInstalling Core extension dependencies..." -ForegroundColor White
Push-Location core
diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh
index 294ce5628..836b8e11b 100755
--- a/scripts/install-dependencies.sh
+++ b/scripts/install-dependencies.sh
@@ -31,7 +31,7 @@ echo "Installing root-level dependencies..."
npm install
echo "Building packages (fetch, openai-adapters, config-yaml)..."
-./scripts/build-packages.sh
+node ./scripts/build-packages.js
echo "Installing Core extension dependencies..."
pushd core
From e5708fcb822946ed3f1f2af025f20482c4e6f6eb Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 28 Jul 2025 15:08:54 -0700
Subject: [PATCH 092/244] refactor: clean up
---
.../NextEditEditableRegionCalculator.ts | 6 +-
core/nextEdit/NextEditPrefetchQueue.ts | 135 ---------
core/nextEdit/NextEditProvider.ts | 272 +-----------------
.../templating/NextEditPromptEngine.ts | 124 ++++----
core/nextEdit/types.ts | 3 +-
core/util/PrefetchQueue.ts | 86 ------
.../GhostTextAcceptanceTracker.ts | 94 +-----
.../src/autocomplete/completionProvider.ts | 75 ++---
.../vscode/src/extension/VsCodeExtension.ts | 22 +-
9 files changed, 108 insertions(+), 709 deletions(-)
delete mode 100644 core/nextEdit/NextEditPrefetchQueue.ts
delete mode 100644 core/util/PrefetchQueue.ts
diff --git a/core/nextEdit/NextEditEditableRegionCalculator.ts b/core/nextEdit/NextEditEditableRegionCalculator.ts
index 04c5247c3..a4dc04794 100644
--- a/core/nextEdit/NextEditEditableRegionCalculator.ts
+++ b/core/nextEdit/NextEditEditableRegionCalculator.ts
@@ -343,17 +343,15 @@ async function staticRerankJump(ctx: {
// Static jump relies purely on static analysis
// to determine where to edit next.
async function staticJump(ctx: {
- fileContent: string;
cursorPosition: { line: number; character: number };
filepath: string;
ide: IDE;
}): Promise {
try {
- const { fileContent, cursorPosition, filepath, ide } = ctx;
- if (!fileContent || !cursorPosition || !filepath || !ide) {
+ const { cursorPosition, filepath, ide } = ctx;
+ if (!cursorPosition || !filepath || !ide) {
console.warn(
"Missing required context for static jump:",
- !fileContent,
!cursorPosition,
!filepath,
!ide,
diff --git a/core/nextEdit/NextEditPrefetchQueue.ts b/core/nextEdit/NextEditPrefetchQueue.ts
deleted file mode 100644
index 54a43bc29..000000000
--- a/core/nextEdit/NextEditPrefetchQueue.ts
+++ /dev/null
@@ -1,135 +0,0 @@
-import { ILLM, Position, RangeInFile } from "..";
-import { HelperVars } from "../autocomplete/util/HelperVars";
-import { findChangedLineRanges, myersDiff } from "../diff/myers";
-import { PrefetchQueue } from "../util/PrefetchQueue";
-import { applyCompletionToFile } from "./diff/diff";
-import { EditableRegionStrategy } from "./NextEditEditableRegionCalculator";
-import { NextEditOutcome } from "./types";
-
-export class NextEditPrefetchQueue extends PrefetchQueue<
- NextEditOutcome,
- RangeInFile,
- {
- helper: HelperVars;
- diffContext: string;
- llm: ILLM;
- token: AbortSignal;
- startTime: number;
- newCursorPos: Position;
- editableRegionStrategy: EditableRegionStrategy;
- }
-> {
- async initialize(): Promise {
- const firstPromise = this.fetchFunction(undefined, undefined, this.other);
- this.promiseQueue.push(firstPromise);
-
- const firstData = await firstPromise;
- if (this.resourceQueue.length > 0) {
- const resource = this.resourceQueue.shift()!;
- const nextPromise = this.fetchFunction(firstData, resource, this.other);
- this.promiseQueue.push(nextPromise);
- }
-
- if (this.other?.editableRegionStrategy === EditableRegionStrategy.Naive) {
- // Get the response from fetchFunction and compare with firstData to identify changed regions
- const resource =
- this.resourceQueue.length > 0 ? this.resourceQueue[0] : undefined;
- const secondPromise = this.fetchFunction(firstData, resource, this.other);
- const secondData = await secondPromise;
- // console.log(secondData?.completion);
-
- // if (secondPromise) {
- // Process this in the background
- // secondPromise
- // .then((secondData) => {
-
- if (firstData && secondData) {
- // Use myersDiff to find differences between the two completions
- // const firstCompletionLines = firstData.completion.split("\n");
- // const secondCompletionLines = secondData.completion.split("\n");
-
- // TODO: this should be comparing old file and new file, not the completions.
- // Compare the file after first completion is merged,
- // and compare the file after first and second completion is merged.
- const appliedFirst = applyCompletionToFile(
- this.other.helper.fileContents,
- firstData.completion,
- firstData.editableRegionStartLine,
- );
- // const appliedFirstAndSecond = applyCompletionToFile(
- // appliedFirst,
- // secondData.completion,
- // secondData.editableRegionStartLine,
- // );
- const diffLines = myersDiff(appliedFirst, secondData.completion);
-
- // Track chunks of differences
- console.log(diffLines, appliedFirst, secondData.completion);
- const changedLineRanges = findChangedLineRanges(diffLines);
- changedLineRanges.forEach((change) => {
- // Inclusive, zero-based line numbers.
- const chunk = {
- startLine: change.startLine,
- endLine: change.endLine,
- };
- console.log("chunk:", chunk);
- const chunkOutcome: NextEditOutcome = {
- ...firstData,
- uniqueId: `${firstData.uniqueId}-chunk-${chunk.startLine}-${chunk.endLine}`,
- editableRegionStartLine: chunk.startLine,
- editableRegionEndLine: chunk.endLine,
- };
-
- this.promiseQueue.push(Promise.resolve(chunkOutcome));
- });
- }
- }
- }
-
- async pop(): Promise {
- if (this.promiseQueue.length === 0) {
- return undefined;
- }
-
- if (this.other?.editableRegionStrategy === EditableRegionStrategy.Naive) {
- // The queue should already be preloaded.
- // We don't need to make extra calls to the model
- // because we assume that the items already in the queue
- // are the only items in this chain of edit.
- const currentPromise = this.promiseQueue.shift()!;
-
- if (this.promiseQueue.length === 0) {
- // NextEditProvider.currentEditChainId = null;
- }
-
- return await currentPromise;
- }
-
- // Get and remove the first promise from the queue
- const currentPromise = this.promiseQueue.shift()!;
- const currentData = await currentPromise;
-
- // If we have resources left, prefetch the next item
- if (this.resourceQueue.length > 0) {
- // Get the most recently added promise (now at the end of the queue)
- const previousPromise =
- this.promiseQueue.length > 0
- ? this.promiseQueue[this.promiseQueue.length - 1]
- : Promise.resolve(currentData);
-
- // Create new promise based on the previous one and next resource
- const resource = this.resourceQueue.shift()!;
- const nextPromise = previousPromise.then((data) =>
- this.fetchFunction(data, resource, this.other),
- );
-
- this.promiseQueue.push(nextPromise);
- } else if (this.promiseQueue.length === 0) {
- // No more items in the queue and no more resources
- // NextEditProvider.currentEditChainId = null;
- }
-
- // console.log("currentData:", currentData);
- return currentData;
- }
-}
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index b8512cd4e..f266b27bf 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -1,15 +1,7 @@
import * as path from "path";
import { v4 as uuidv4 } from "uuid";
import { ConfigHandler } from "../config/ConfigHandler.js";
-import {
- BranchAndDir,
- ChatMessage,
- IDE,
- ILLM,
- Position,
- Range,
- RangeInFile,
-} from "../index.js";
+import { ChatMessage, IDE, ILLM, Range, RangeInFile } from "../index.js";
import OpenAI from "../llm/llms/OpenAI.js";
import { DEFAULT_AUTOCOMPLETE_OPTS } from "../util/parameters.js";
@@ -26,7 +18,6 @@ import { AutocompleteDebouncer } from "../autocomplete/util/AutocompleteDebounce
import AutocompleteLruCache from "../autocomplete/util/AutocompleteLruCache.js";
import { HelperVars } from "../autocomplete/util/HelperVars.js";
import { AutocompleteInput } from "../autocomplete/util/types.js";
-import { myersDiff } from "../diff/myers.js";
import { localPathOrUriToPath } from "../util/pathToUri.js";
import { replaceEscapedCharacters } from "../util/text.js";
import {
@@ -34,17 +25,13 @@ import {
NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
} from "./constants.js";
import { createDiff, DiffFormatType } from "./context/diffFormatting.js";
-import {
- calculateFinalCursorPosition,
- getOffsetPositionAtLastNewLine,
-} from "./diff/diff.js";
+import { calculateFinalCursorPosition } from "./diff/diff.js";
import { DocumentAstTracker } from "./DocumentHistoryTracker.js";
import {
EditableRegionStrategy,
getNextEditableRegion,
} from "./NextEditEditableRegionCalculator.js";
import { NextEditLoggingService } from "./NextEditLoggingService.js";
-import { NextEditPrefetchQueue } from "./NextEditPrefetchQueue.js";
import {
renderDefaultSystemPrompt,
renderDefaultUserPrompt,
@@ -56,7 +43,6 @@ import {
PromptMetadata,
RecentlyEditedRange,
} from "./types.js";
-// import { renderPrompt } from "./templating/NextEditPromptEngine.js";
const autocompleteCache = AutocompleteLruCache.get();
@@ -81,8 +67,6 @@ export class NextEditProvider {
private endpointType: "default" | "fineTuned";
private diffContext: string = "";
private promptMetadata: PromptMetadata | null = null;
- private prefetchQueue: NextEditPrefetchQueue;
- // private refQueue: RangeInFile[] = [];
private currentEditChainId: string | null = null;
private previousRequest: AutocompleteInput | null = null;
private previousCompletions: NextEditOutcome[] = [];
@@ -101,121 +85,6 @@ export class NextEditProvider {
this.contextRetrievalService = new ContextRetrievalService(this.ide);
this.endpointType = endpointType;
this.loggingService = NextEditLoggingService.getInstance();
-
- const fetchFunction = async (
- previousData: NextEditOutcome | undefined,
- resource: RangeInFile | undefined,
- other?: {
- helper: HelperVars;
- diffContext: string;
- llm: ILLM;
- token: AbortSignal;
- startTime: number;
- newCursorPos: Position;
- editableRegionStrategy: EditableRegionStrategy;
- },
- ) => {
- if (!other) return undefined;
- // console.log("previousData:", previousData?.completion);
- // render prompt
- // TODO: this has to set the editable region properly.
- // console.log("fetchfunction - previousData:", previousData?.completion);
- const promptMetadata = await renderPrompt(
- other.helper,
- other.diffContext,
- other.editableRegionStrategy,
- previousData,
- resource,
- );
- this.promptMetadata = promptMetadata;
- // console.log("prompt:", promptMetadata.prompt);
- // call llm.chat
- const msg = await other.llm.chat([promptMetadata.prompt], other.token);
- // built and return outcome
- if (typeof msg.content === "string") {
- if (msg.content === "") return undefined;
- // NOTE: There are cases where msg.conetnt.split("<|start|>")[1] is undefined
- const nextCompletion = replaceEscapedCharacters(
- msg.content.split("<|editable_region_start|>\n")[1],
- ).replace(/\n$/, "");
-
- const currCursorPos = other.helper.pos;
- const editableRegionStartLine = Math.max(
- currCursorPos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
- 0,
- );
- const editableRegionEndLine = Math.min(
- currCursorPos.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
- other.helper.fileLines.length - 1,
- );
- const oldEditRangeSlice = other.helper.fileContents
- .split("\n")
- .slice(editableRegionStartLine, editableRegionEndLine + 1)
- .join("\n");
-
- // How far away is the current line from the start of the editable region?
- const lineOffsetAtCursorPos =
- currCursorPos.line - editableRegionStartLine;
-
- // How long is the line at the current cursor position?
- const newEditRangeSlice = nextCompletion;
- const lineContentAtCursorPos =
- newEditRangeSlice.split("\n")[lineOffsetAtCursorPos];
-
- const diffLines = myersDiff(oldEditRangeSlice, newEditRangeSlice);
-
- const offset = getOffsetPositionAtLastNewLine(
- diffLines,
- lineContentAtCursorPos,
- lineOffsetAtCursorPos,
- );
-
- // Calculate the actual line number in the editor by adding the startPos offset
- // to the line number from the diff calculation.
- const finalCursorPos: Position = {
- line: editableRegionStartLine + offset.line,
- character: offset.character,
- };
-
- // TODO: if editable region strategy is naive, then we need to split the prediction up into regions. Also potentially filling up the prefetch queue.
-
- const outcomeNext: NextEditOutcome = {
- elapsed: Date.now() - other.startTime,
- modelProvider: other.llm.underlyingProviderName,
- modelName: other.llm.model + ":zetaDataset",
- completionOptions: null,
- // filepath: helper.filepath,
- completionId: other.helper.input.completionId,
- gitRepo: await this.ide.getRepoName(other.helper.filepath),
- uniqueId: await this.ide.getUniqueId(),
- timestamp: Date.now(),
- fileUri: other.helper.filepath,
- workspaceDirUri:
- other.helper.workspaceUris[0] ??
- path.dirname(other.helper.filepath),
- fileContentsBeforeAccept: other.helper.fileContents,
- prompt: this.promptMetadata!.prompt.content,
- userEdits: this.promptMetadata!.userEdits,
- userExcerpts: this.promptMetadata!.userExcerpts,
- originalEditableRange: oldEditRangeSlice,
- completion: nextCompletion,
- cursorPosition: other.helper.pos,
- finalCursorPosition: finalCursorPos,
- editableRegionStartLine,
- editableRegionEndLine,
- ...other.helper.options,
- };
- return outcomeNext;
- } else {
- return undefined;
- }
- };
-
- this.prefetchQueue = new NextEditPrefetchQueue(
- fetchFunction,
- [],
- undefined,
- );
}
public static initialize(
@@ -350,9 +219,9 @@ export class NextEditProvider {
this.nextEditableRegionsInTheCurrentChain = [];
if (this.previousRequest) {
- const fileContent =
- // await fs.readFile(localPathOrUriToPath(this.previousRequest.filepath)
- (await this.ide.readFile(this.previousRequest.filepath)).toString();
+ const fileContent = (
+ await this.ide.readFile(this.previousRequest.filepath)
+ ).toString();
const ast = await getAst(this.previousRequest.filepath, fileContent);
if (ast) {
DocumentAstTracker.getInstance().pushAst(
@@ -452,10 +321,8 @@ export class NextEditProvider {
});
const promptMetadata = await renderPrompt(
helper,
- // this.diffContext,
historyDiff ?? this.diffContext,
EditableRegionStrategy.Naive,
- // input.recentlyEditedRanges,
);
this.promptMetadata = promptMetadata;
@@ -509,7 +376,6 @@ export class NextEditProvider {
fileUri: helper.filepath,
workspaceDirUri:
helper.workspaceUris[0] ?? path.dirname(helper.filepath),
- fileContentsBeforeAccept: helper.fileContents,
prompt: prompts.join("\n"),
userEdits: "",
userExcerpts: "",
@@ -546,8 +412,6 @@ export class NextEditProvider {
).replace(/\n$/, "")
: "";
- // this.previousCompletions.push(nextCompletion);
-
const currCursorPos = helper.pos;
const editableRegionStartLine = Math.max(
currCursorPos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
@@ -566,7 +430,6 @@ export class NextEditProvider {
helper.pos,
editableRegionStartLine,
oldEditRangeSlice,
- // "",
nextCompletion,
);
@@ -583,7 +446,6 @@ export class NextEditProvider {
fileUri: helper.filepath,
workspaceDirUri:
helper.workspaceUris[0] ?? path.dirname(helper.filepath),
- fileContentsBeforeAccept: helper.fileContents,
prompt: this.promptMetadata!.prompt.content,
userEdits: this.promptMetadata!.userEdits,
userExcerpts: this.promptMetadata!.userExcerpts,
@@ -632,32 +494,18 @@ export class NextEditProvider {
},
token: AbortSignal | undefined,
) {
- // TODO:
- // If we don't have a precomputed list of next editable regions already, compute it.
- // Store this list as a class attribute.
- // Pop the frontmost RangeInFile and use that to build an input.
try {
const previousOutcome = this.getPreviousCompletion();
if (!previousOutcome) {
return undefined;
}
- // TODO: This is actually getting the contents after the user typed something.
- // we need the file before the user has typed anything.
- // console.log("previousOutcome:", previousOutcome.fileContentsBeforeAccept);
- // console.log("previousCursorPosition:", previousOutcome.cursorPosition);
- const fileContent = previousOutcome.fileContentsBeforeAccept;
const filepath = localPathOrUriToPath(previousOutcome.fileUri);
- console.log(
- "number of next editable regions:",
- this.nextEditableRegionsInTheCurrentChain.length,
- );
+ // If we don't have a precomputed list of next editable regions already, compute and load it.
if (this.nextEditableRegionsInTheCurrentChain.length === 0) {
- console.log("empty next editable regions list");
this.loadNextEditableRegionsInTheCurrentChain(
(await getNextEditableRegion(EditableRegionStrategy.Static, {
- fileContent,
cursorPosition: previousOutcome.cursorPosition,
filepath,
ide: this.ide,
@@ -670,6 +518,7 @@ export class NextEditProvider {
}
}
+ // Use the frontmost RangeInFile to build an input.
const input = await this.buildAutocompleteInputFromChain(
previousOutcome,
this.nextEditableRegionsInTheCurrentChain[0], // this will be shifted after debouncer check
@@ -715,117 +564,10 @@ export class NextEditProvider {
}
public loadNextEditableRegionsInTheCurrentChain(regions: RangeInFile[]) {
- console.log("regions after load:", regions.length);
this.nextEditableRegionsInTheCurrentChain = regions;
}
public shiftNextEditableRegionsInTheCurrentChain() {
- console.log("shift", this.nextEditableRegionsInTheCurrentChain.length);
this.nextEditableRegionsInTheCurrentChain.shift();
}
-
- public async provideNextEditPrediction(
- input: AutocompleteInput,
- token: AbortSignal | undefined,
- ) {
- try {
- if (this.currentEditChainId) {
- return await this.prefetchQueue.pop();
- }
-
- // Create abort signal if not given
- if (!token) {
- const controller = this.loggingService.createAbortController(
- input.completionId,
- );
- token = controller.signal;
- }
- const startTime = Date.now();
- const options = await this._getAutocompleteOptions();
-
- // Debounce
- if (await this.debouncer.delayAndShouldDebounce(options.debounceDelay)) {
- return undefined;
- }
-
- const llm = await this._prepareLlm();
- if (!llm) {
- return undefined;
- }
-
- if (llm.promptTemplates?.autocomplete) {
- options.template = llm.promptTemplates.autocomplete as string;
- }
-
- const helper = await HelperVars.create(
- input,
- options,
- llm.model,
- this.ide,
- );
-
- if (await shouldPrefilter(helper, this.ide)) {
- return undefined;
- }
-
- // this.currentEditChainId = randomUUID();
-
- this.prefetchQueue.loadOther({
- helper,
- diffContext: this.diffContext,
- llm,
- token,
- startTime,
- newCursorPos: helper.pos,
- editableRegionStrategy: EditableRegionStrategy.Naive,
- });
-
- const [snippetPayload, workspaceDirs] = await Promise.all([
- getAllSnippetsWithoutRace({
- helper,
- ide: this.ide,
- getDefinitionsFromLsp: this.getDefinitionsFromLsp,
- contextRetrievalService: this.contextRetrievalService,
- }),
- this.ide.getWorkspaceDirs(),
- ]);
-
- // TODO: Get the references.
- const refQueue = await this.ide.getReferences({
- filepath: helper.filepath,
- position: helper.pos,
- });
-
- const { config } = await this.configHandler.loadConfig();
- const branches = await Promise.all(
- workspaceDirs.map((dir) => this.ide.getBranch(dir)),
- );
- const tags: BranchAndDir[] = workspaceDirs.map((directory, i) => ({
- directory,
- branch: branches[i],
- }));
- // const chunks = await getTopRelevantCodeChunks(
- // ` add(number) {
- // this.result += number;
- // return this;
- // }`,
- // {
- // ide: this.ide,
- // llm: llm,
- // config: config!,
- // tags: tags,
- // // filterDirectory: getUriPathBasename(helper.workspaceUris[0]),
- // },
- // );
- // console.log("chunks:", JSON.stringify(chunks, null, 2));
-
- this.prefetchQueue.loadResource(refQueue);
- await this.prefetchQueue.initialize();
- return await this.prefetchQueue.pop();
- } catch (e: any) {
- this.onError(e);
- } finally {
- this.loggingService.deleteAbortController(input.completionId);
- }
- }
}
diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts
index 01a18ac7f..d6cd8dacf 100644
--- a/core/nextEdit/templating/NextEditPromptEngine.ts
+++ b/core/nextEdit/templating/NextEditPromptEngine.ts
@@ -9,11 +9,7 @@ import {
NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
USER_CURSOR_IS_HERE_TOKEN,
} from "../constants";
-import { createDiff, DiffFormatType } from "../context/diffFormatting";
-import {
- EditableRegionStrategy,
- getNextEditableRegion,
-} from "../NextEditEditableRegionCalculator";
+import { EditableRegionStrategy } from "../NextEditEditableRegionCalculator";
import {
NextEditOutcome,
NextEditTemplate,
@@ -94,67 +90,67 @@ export async function renderPrompt(
// TODO: apply prevOutcome to existing content. we will need the line range.
// Also display the diff between existing content and applied content.
// NOTE: This only runs in fetchFunction.
- if (prevOutcome) {
- // console.log("renderPrompt prevOutcome:", prevOutcome.completion);
- // console.log(
- // "beforeInsert:",
- // helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
- // );
- // console.log("toInsert: ", prevOutcome?.completion.split("\n"));
- // console.log(
- // "afterInsert:",
- // helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
- // );
- let appliedContent = [
- ...helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
- ...(prevOutcome?.completion.split("\n") ?? []),
- ...helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
- ];
- // console.log("helper.fileContents:", helper.fileContents);
- // NOTE: I'm not sure, but <|user_cursor_is_here|> is somehow being added to appliedContent.
- // The individual parts don't contain this.
- // console.log("appliedContent:", appliedContent);
- appliedContent = appliedContent.filter(
- (line) => !line.includes(USER_CURSOR_IS_HERE_TOKEN),
- );
- // Given a previous response, we need to calculate where the cursor would be.
- // I think it's a good idea to calculate this in the response.
+ // if (prevOutcome) {
+ // // console.log("renderPrompt prevOutcome:", prevOutcome.completion);
+ // // console.log(
+ // // "beforeInsert:",
+ // // helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
+ // // );
+ // // console.log("toInsert: ", prevOutcome?.completion.split("\n"));
+ // // console.log(
+ // // "afterInsert:",
+ // // helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
+ // // );
+ // let appliedContent = [
+ // ...helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
+ // ...(prevOutcome?.completion.split("\n") ?? []),
+ // ...helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
+ // ];
+ // // console.log("helper.fileContents:", helper.fileContents);
+ // // NOTE: I'm not sure, but <|user_cursor_is_here|> is somehow being added to appliedContent.
+ // // The individual parts don't contain this.
+ // // console.log("appliedContent:", appliedContent);
+ // appliedContent = appliedContent.filter(
+ // (line) => !line.includes(USER_CURSOR_IS_HERE_TOKEN),
+ // );
+ // // Given a previous response, we need to calculate where the cursor would be.
+ // // I think it's a good idea to calculate this in the response.
- // TODO: handle cases where there are more than one next editable region.
- // NOTE: we might set it so that we receive the next editable region as an argument.
- const editableRegion = await getNextEditableRegion(editableRegionStrategy, {
- fileLines: appliedContent,
- filepath: helper.filepath,
- });
+ // // TODO: handle cases where there are more than one next editable region.
+ // // NOTE: we might set it so that we receive the next editable region as an argument.
+ // const editableRegion = await getNextEditableRegion(editableRegionStrategy, {
+ // fileLines: appliedContent,
+ // filepath: helper.filepath,
+ // });
- // console.log("appliedContent:", appliedContent);
- // console.log("startLine:", editableRegion?.range.start.line);
- editedCodeWithTokens = insertTokens(
- appliedContent,
- prevOutcome.finalCursorPosition,
- editableRegion && editableRegion[0]?.range.start.line !== undefined
- ? editableRegion[0].range.start.line
- : undefined,
- editableRegion && editableRegion[0]?.range.end.line !== undefined
- ? editableRegion[0].range.end.line
- : undefined,
- );
- // console.log("new editedCodeWithTokens:", editedCodeWithTokens);
- userEdits = createDiff({
- beforeContent: helper.fileContents,
- afterContent: appliedContent.join("\n"),
- filePath: helper.filepath,
- diffType: DiffFormatType.Unified,
- contextLines: 3,
- });
- userEdits = userEdits.replace(USER_CURSOR_IS_HERE_TOKEN, "");
- // console.log("new userDiff:", userEdits);
- } else {
- editedCodeWithTokens = insertTokens(
- helper.fileContents.split("\n"),
- helper.pos,
- );
- }
+ // // console.log("appliedContent:", appliedContent);
+ // // console.log("startLine:", editableRegion?.range.start.line);
+ // editedCodeWithTokens = insertTokens(
+ // appliedContent,
+ // prevOutcome.finalCursorPosition,
+ // editableRegion && editableRegion[0]?.range.start.line !== undefined
+ // ? editableRegion[0].range.start.line
+ // : undefined,
+ // editableRegion && editableRegion[0]?.range.end.line !== undefined
+ // ? editableRegion[0].range.end.line
+ // : undefined,
+ // );
+ // // console.log("new editedCodeWithTokens:", editedCodeWithTokens);
+ // userEdits = createDiff({
+ // beforeContent: helper.fileContents,
+ // afterContent: appliedContent.join("\n"),
+ // filePath: helper.filepath,
+ // diffType: DiffFormatType.Unified,
+ // contextLines: 3,
+ // });
+ // userEdits = userEdits.replace(USER_CURSOR_IS_HERE_TOKEN, "");
+ // // console.log("new userDiff:", userEdits);
+ // } else {
+ editedCodeWithTokens = insertTokens(
+ helper.fileContents.split("\n"),
+ helper.pos,
+ );
+ // }
const tv: TemplateVars = {
userEdits,
diff --git a/core/nextEdit/types.ts b/core/nextEdit/types.ts
index e4ae1f328..26e2b156a 100644
--- a/core/nextEdit/types.ts
+++ b/core/nextEdit/types.ts
@@ -47,10 +47,9 @@ export interface NextEditOutcome extends TabAutocompleteOptions {
// New for Next Edit.
fileUri: string;
workspaceDirUri: string;
- fileContentsBeforeAccept: string;
prompt: string;
userEdits: string;
- userExcerpts: string; // For now, this is the same as fileContentsBeforeAccept, but that assumption should not be relied on.
+ userExcerpts: string;
originalEditableRange: string;
completion: string;
cursorPosition: { line: number; character: number };
diff --git a/core/util/PrefetchQueue.ts b/core/util/PrefetchQueue.ts
deleted file mode 100644
index 91a240dcc..000000000
--- a/core/util/PrefetchQueue.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-export class PrefetchQueue {
- protected promiseQueue: Promise[] = [];
- protected resourceQueue: R[];
- protected other: O | undefined;
- protected fetchFunction: (
- previousData: T | undefined,
- resource: R | undefined,
- other: O | undefined,
- ) => Promise;
-
- constructor(
- fetchFunction: (
- previousData: T | undefined,
- resource: R | undefined,
- other: O | undefined,
- ) => Promise,
- resources: R[],
- other: O | undefined,
- ) {
- this.fetchFunction = fetchFunction;
- this.resourceQueue = [...resources];
- this.other = other;
- }
-
- loadResource(resources: R[]) {
- this.resourceQueue = [...this.resourceQueue, ...resources];
- }
-
- loadOther(other: O) {
- this.other = other;
- }
-
- async initialize(): Promise {
- // Get the first response (no resource needed)
- const firstPromise = this.fetchFunction(undefined, undefined, this.other);
- this.promiseQueue.push(firstPromise);
-
- // Prefetch the next item using the first resource
- const firstData = await firstPromise;
- if (this.resourceQueue.length > 0) {
- const resource = this.resourceQueue.shift()!;
- const nextPromise = this.fetchFunction(firstData, resource, this.other);
- this.promiseQueue.push(nextPromise);
- }
- }
-
- async pop(): Promise {
- if (this.promiseQueue.length === 0) {
- return undefined;
- }
-
- // Get and remove the first promise from the queue
- const currentPromise = this.promiseQueue.shift()!;
- const currentData = await currentPromise;
-
- // If we have resources left, prefetch the next item
- if (this.resourceQueue.length > 0) {
- // Get the most recently added promise (now at the end of the queue)
- const previousPromise =
- this.promiseQueue.length > 0
- ? this.promiseQueue[this.promiseQueue.length - 1]
- : Promise.resolve(currentData);
-
- // Create new promise based on the previous one and next resource
- const resource = this.resourceQueue.shift()!;
- const nextPromise = previousPromise.then((data) =>
- this.fetchFunction(data, resource, this.other),
- );
-
- this.promiseQueue.push(nextPromise);
- } else if (this.promiseQueue.length === 0) {
- // No more items in the queue and no more resources
- }
-
- console.log("currentData:", currentData);
- return currentData;
- }
-
- hasNext(): boolean {
- return this.promiseQueue.length > 0;
- }
-
- getRemainingResourceCount(): number {
- return this.resourceQueue.length;
- }
-}
diff --git a/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts b/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts
index 610a3c7fe..f40047c4f 100644
--- a/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts
+++ b/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts
@@ -1,83 +1,3 @@
-// export class CompletionAcceptanceTracker {
-// private static instance: CompletionAcceptanceTracker;
-// private acceptedCompletionIds: Set = new Set();
-
-// static getInstance(): CompletionAcceptanceTracker {
-// if (!CompletionAcceptanceTracker.instance) {
-// CompletionAcceptanceTracker.instance = new CompletionAcceptanceTracker();
-// }
-// return CompletionAcceptanceTracker.instance;
-// }
-
-// markGhostTextAccepted(completionId: string) {
-// this.acceptedCompletionIds.add(completionId);
-
-// // Keep a reasonable history size
-// if (this.acceptedCompletionIds.size > 1) {
-// // Remove the oldest item (using the fact that Sets maintain insertion order)
-// const oldestId = this.acceptedCompletionIds.values().next().value;
-// if (oldestId) {
-// this.acceptedCompletionIds.delete(oldestId);
-// }
-// }
-// }
-
-// wasCompletionAccepted(completionId: string): boolean {
-// return this.acceptedCompletionIds.has(completionId);
-// }
-
-// // Add a method to check if the most recent completion was accepted
-// wasRecentCompletionAccepted(): boolean {
-// return this.acceptedCompletionIds.size > 0;
-// }
-// }
-// In completionAcceptanceTracker.ts
-// export class CompletionAcceptanceTracker {
-// private static instance: CompletionAcceptanceTracker;
-// private acceptedCompletionIds: Set = new Set();
-// private currentCompletionId: string | null = null;
-
-// static getInstance(): CompletionAcceptanceTracker {
-// if (!CompletionAcceptanceTracker.instance) {
-// CompletionAcceptanceTracker.instance = new CompletionAcceptanceTracker();
-// }
-// return CompletionAcceptanceTracker.instance;
-// }
-
-// setCurrentCompletionId(completionId: string) {
-// this.currentCompletionId = completionId;
-// }
-
-// markGhostTextAccepted(completionId: string) {
-// console.log("mark");
-// this.acceptedCompletionIds.add(completionId);
-
-// // Keep a reasonable history size
-// if (this.acceptedCompletionIds.size > 1) {
-// // Remove the oldest item (using the fact that Sets maintain insertion order)
-// const oldestId = this.acceptedCompletionIds.values().next().value;
-// if (oldestId) {
-// this.acceptedCompletionIds.delete(oldestId);
-// }
-// }
-// }
-
-// wasCompletionAccepted(completionId: string): boolean {
-// return this.acceptedCompletionIds.has(completionId);
-// }
-
-// isCurrentCompletionAccepted(): boolean {
-// return (
-// this.currentCompletionId !== null &&
-// this.acceptedCompletionIds.has(this.currentCompletionId)
-// );
-// }
-
-// clearCurrentCompletionId() {
-// this.currentCompletionId = null;
-// }
-// }
-// New file: extensions/vscode/src/activation/GhostTextAcceptanceTracker.ts
import * as vscode from "vscode";
export interface ExpectedGhostTextAcceptance {
@@ -142,26 +62,26 @@ export class GhostTextAcceptanceTracker {
): boolean {
if (!this.expectedAcceptance) return false;
- // Check document match
+ // Check document match.
if (this.expectedAcceptance.documentUri !== document.uri.toString()) {
return false;
}
- // Check document version (must be newer)
+ // Check document version (must be newer).
if (document.version <= this.expectedAcceptance.documentVersion) {
return false;
}
- // Check if cursor is at expected end position
+ // Check if cursor is at expected end position.
const expectedEndPos = new vscode.Position(
this.expectedAcceptance.endLine,
this.expectedAcceptance.endCharacter,
);
if (newPosition.isEqual(expectedEndPos)) {
- // The cursor is where we'd expect after accepting the ghost text
+ // The cursor is where we'd expect after accepting the ghost text.
- // Verify text was inserted (optional additional check)
+ // Verify text was inserted (optional additional check).
const startPos = new vscode.Position(
this.expectedAcceptance.startLine,
this.expectedAcceptance.startCharacter,
@@ -174,12 +94,12 @@ export class GhostTextAcceptanceTracker {
const actualText = document.getText(actualRange);
if (actualText === expectedText) {
- // Clear the expectation
+ // Clear the expectation.
this.expectedAcceptance = null;
return true;
}
} catch (error) {
- // Range might be invalid, just fall through
+ // Range might be invalid, just fall through.
}
}
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index 4919377c9..5e22b5c7e 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -5,8 +5,6 @@ import {
type AutocompleteOutcome,
} from "core/autocomplete/util/types";
import { ConfigHandler } from "core/config/ConfigHandler";
-// import { IS_NEXT_EDIT_ACTIVE } from "core/nextEdit/constants";
-// import { NextEditProvider } from "core/nextEdit/NextEditProvider";
import * as URI from "uri-js";
import { v4 as uuidv4 } from "uuid";
import * as vscode from "vscode";
@@ -72,8 +70,6 @@ export class ContinueCompletionProvider
public recentlyVisitedRanges: RecentlyVisitedRangesService;
public recentlyEditedTracker: RecentlyEditedTracker;
- private oldFileContent: string = "";
-
private isNextEditActive: boolean = false;
public activateNextEdit() {
@@ -140,14 +136,6 @@ export class ContinueCompletionProvider
token: vscode.CancellationToken,
//@ts-ignore
): ProviderResult {
- console.log("================================================");
- console.log(
- "editor.inlineSuggest.enabled:",
- vscode.workspace
- .getConfiguration()
- .get("editor.inlineSuggest.enabled"),
- );
- // console.log("trigger!!", token.isCancellationRequested);
const enableTabAutocomplete =
getStatusBarStatus() === StatusBarStatus.Enabled;
if (token.isCancellationRequested || !enableTabAutocomplete) {
@@ -247,15 +235,9 @@ export class ContinueCompletionProvider
const recentlyVisitedRanges = this.recentlyVisitedRanges.getSnippets();
let recentlyEditedRanges =
await this.recentlyEditedTracker.getRecentlyEditedRanges();
- // console.log("one:", JSON.stringify(recentlyEditedRanges, null, 2));
- console.log(
- this.nextEditProvider.chainExists()
- ? "chain is alive"
- : "chain is not alive",
- );
if (this.nextEditProvider.chainExists()) {
- // If the user has accepted the previous completion, the chain of edits is alive.
+ // The chain of edits is alive because the user has accepted the previous completion.
// Get the next editable region and set the pos to be within that range.
outcome =
await this.nextEditProvider.provideInlineCompletionItemsWithChain(
@@ -288,6 +270,7 @@ export class ContinueCompletionProvider
};
setupStatusBar(undefined, true);
+
// Check if editChainId exists or needs to be refreshed.
if (this.isNextEditActive) {
outcome = await this.nextEditProvider.provideInlineCompletionItems(
@@ -295,17 +278,16 @@ export class ContinueCompletionProvider
signal,
false,
);
- console.log("outcome.completion:");
- console.log(outcome?.completion);
+
if (!outcome || !outcome.completion) {
- // TODO: At this point we assume that the user typed something "whole".
- // AKA, the user's edit was good enough to start an edit chain.
- // We actually started the chain before getting the outcome. This makes logical sense.
- // Then all we need to do is to calculate next editable region.
+ // Hitting this condition means that the model could not predict a next edit action.
+ // That happens when the user's recent edit is good enough, or if the model is totally lost.
+ // At this point we assume that the user typed something good enough to maintain a chain of edits.
+ // All we need to do here is to calculate next editable region.
// We also need to use the user's edits to create a user edits section in renderPrompt.
recentlyEditedRanges =
await this.recentlyEditedTracker.getRecentlyEditedRanges();
- // console.log("two:", JSON.stringify(recentlyEditedRanges, null, 2));
+
outcome =
await this.nextEditProvider.provideInlineCompletionItemsWithChain(
{
@@ -321,6 +303,7 @@ export class ContinueCompletionProvider
);
}
} else {
+ // Handle autocomplete request.
outcome = await this.completionProvider.provideInlineCompletionItems(
input,
signal,
@@ -329,21 +312,8 @@ export class ContinueCompletionProvider
}
}
- this.oldFileContent = document.getText();
-
- // TODO: fix type of outcome to be a union between NextEditOutcome and AutocompleteOutcome.
- // const outcome: AutocompleteOutcome | NextEditOutcome | undefined = this
- // .isNextEditActive
- // ? await this.nextEditProvider.provideInlineCompletionItems(
- // input,
- // signal,
- // )
- // : await this.completionProvider.provideInlineCompletionItems(
- // input,
- // signal,
- // wasManuallyTriggered,
- // );
-
+ // If the model cannot predict a completion or a next edit,
+ // then it's safe to assume that there are no more changes to be made.
if (!outcome || !outcome.completion) {
return null;
}
@@ -374,8 +344,8 @@ export class ContinueCompletionProvider
return null;
}
- // Marking the outcome as displayed saves
- // the current outcome as a value of the key completionId.
+ // Marking the outcome as displayed saves the current outcome
+ // as a value of the key completionId.
if (this.isNextEditActive) {
this.nextEditProvider.markDisplayed(
completionId,
@@ -394,7 +364,6 @@ export class ContinueCompletionProvider
let range = new vscode.Range(startPos, startPos);
let completionText = outcome.completion;
- // NOTE: This seems like an autocomplete logic.
const isSingleLineCompletion = outcome.completion.split("\n").length <= 1;
if (isSingleLineCompletion) {
@@ -445,14 +414,14 @@ export class ContinueCompletionProvider
const currCursorPos = editor.selection.active;
if (this.isNextEditActive) {
- console.log(this.nextEditProvider.getChain().length);
-
if (!this.nextEditProvider.isStartOfChain()) {
const jumpPosition = new vscode.Position(
(outcome as NextEditOutcome).editableRegionStartLine,
0,
);
+ // Suggest a jump if there is a valid next location.
+ // This will set isJumpInProgress if a jump is suggested.
await this.jumpManager.suggestJump(
currCursorPos,
jumpPosition,
@@ -461,7 +430,7 @@ export class ContinueCompletionProvider
// If a jump was just suggested, don't show ghost text yet.
if (this.jumpManager.isJumpInProgress()) {
- // Store this completion for later use when jump is complete.
+ // Store this completion to be rendered after jump is complete.
this.jumpManager.setCompletionAfterJump({
completionId: completionId,
outcome: outcome as NextEditOutcome,
@@ -516,8 +485,6 @@ export class ContinueCompletionProvider
newEditRangeSlice,
relativeCursorPos,
);
- console.log("isFim:", isFim);
- console.log("fimText:", fimText);
if (isFim) {
if (!fimText) {
@@ -526,9 +493,12 @@ export class ContinueCompletionProvider
return undefined;
}
- // const completionId = input.completionId;
-
// Track this ghost text for acceptance detection.
+ // Ghost text acceptance can *technically* be acted upon in
+ // the command handler for "continue.logNextEditOutcomeAccept",
+ // but there is a substantial delay between accepting and logging,
+ // which introduces a lot of race conditions with different event handlers.
+ // Plus, separating these concerns seems to make sense logically as well.
GhostTextAcceptanceTracker.getInstance().setExpectedGhostTextAcceptance(
document,
fimText,
@@ -544,10 +514,9 @@ export class ContinueCompletionProvider
{
title: "Log Next Edit Outcome",
command: "continue.logNextEditOutcomeAccept",
- arguments: [completionId, this.nextEditLoggingService], // TODO: this may have to be this.completionProvider.
+ arguments: [completionId, this.nextEditLoggingService],
},
);
- console.log(nextEditCompletionItem);
return [nextEditCompletionItem];
}
diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts
index 776c59843..94bf619df 100644
--- a/extensions/vscode/src/extension/VsCodeExtension.ts
+++ b/extensions/vscode/src/extension/VsCodeExtension.ts
@@ -419,20 +419,15 @@ export class VsCodeExtension {
}
});
- // TODO: check if next edit provider's chain id is cleared properly.
// Listen for editor changes to clean up decorations when editor closes.
vscode.window.onDidChangeVisibleTextEditors(async () => {
// If our active editor is no longer visible, clear decorations.
- // console.log(
- // "deleteChain from VsCodeExtension.ts: onDidChangeVisibleTextEditors",
- // );
await NextEditProvider.getInstance().deleteChain();
});
// Listen for selection changes to hide tooltip when cursor moves.
vscode.window.onDidChangeTextEditorSelection(async (e) => {
- // console.log("move detected");
- // Don't delete the chain if:
+ // Don't delete the chain of edits if:
// 1. A next edit window was just accepted.
if (
@@ -461,21 +456,22 @@ export class VsCodeExtension {
}
// 4. The selection change is part of a typing session
- // Check if this selection change is close enough to a document change to be considered typing
+ // Check if this selection change is close enough to a document change to be considered typing.
const timeSinceLastDocChange = Date.now() - this.lastDocumentChangeTime;
- if (this.isTypingSession && timeSinceLastDocChange < 500) {
- // This selection change is likely due to typing, don't delete the chain
+ const ARBITRARY_TYPING_DELAY = 500;
+ if (
+ this.isTypingSession &&
+ timeSinceLastDocChange < ARBITRARY_TYPING_DELAY
+ ) {
+ // This selection change is likely due to typing, don't delete the chain.
return;
}
// Otherwise, delete the chain (for rejection or unrelated movement).
- console.log(
- "deleteChain from VsCodeExtension.ts: onDidChangeTextEditorSelection",
- );
await NextEditProvider.getInstance().deleteChain();
+
NextEditProvider.getInstance().loadNextEditableRegionsInTheCurrentChain(
(await getNextEditableRegion(EditableRegionStrategy.Static, {
- fileContent: e.textEditor.document.getText(),
cursorPosition: e.selections[0].anchor,
filepath: localPathOrUriToPath(e.textEditor.document.uri.toString()),
ide: this.ide,
From f68bf5759ff9d2bc4ed49392c66bae2f5bf47543 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 28 Jul 2025 15:34:51 -0700
Subject: [PATCH 093/244] refactor: clean up
---
.../pipelines/BaseRetrievalPipeline.ts | 6 -
.../pipelines/NextEditRetrievalPipeline.ts | 7 --
core/nextEdit/DocumentHistoryTracker.ts | 103 +++---------------
.../NextEditEditableRegionCalculator.ts | 4 +-
core/nextEdit/NextEditProvider.ts | 6 +-
.../GhostTextAcceptanceTracker.ts | 9 ++
.../vscode/src/extension/VsCodeExtension.ts | 4 +-
7 files changed, 32 insertions(+), 107 deletions(-)
diff --git a/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts b/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts
index 617240410..f5d8a89f6 100644
--- a/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts
+++ b/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts
@@ -189,12 +189,6 @@ export default class BaseRetrievalPipeline implements IRetrievalPipeline {
);
return [];
}
- // if (!this.lanceDbIndex) {
- // console.warn(
- // "LanceDB index not available, skipping embeddings retrieval",
- // );
- // return [];
- // }
return this.lanceDbIndex.retrieve(
input,
diff --git a/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts b/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
index 515eb9bc8..b95aa0a6b 100644
--- a/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
+++ b/core/context/retrieval/pipelines/NextEditRetrievalPipeline.ts
@@ -242,10 +242,3 @@ export function cosineSimilarity(a: number[], b: number[]): number {
return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
}
-
-// export async function getJumpDestinations(
-// codeSnippet: string,
-// cursorPosition: Position,
-// filepath: string,
-// ): Promise {
-// }
diff --git a/core/nextEdit/DocumentHistoryTracker.ts b/core/nextEdit/DocumentHistoryTracker.ts
index 1bbdc98b7..34ea763bf 100644
--- a/core/nextEdit/DocumentHistoryTracker.ts
+++ b/core/nextEdit/DocumentHistoryTracker.ts
@@ -1,59 +1,38 @@
-// TODO:
-// Create a DocumentAstTracker singleton class that keeps track of a map of document paths to their history of ASTs.
-// There should be a map from document path to history of ASTs (a LIFO stack of ASTs where the newest AST is at the front)
-// We want to expose these methods:
-// add document and its first AST
-// push to an existing document's AST history stack
-// get the most recent AST of an existing document's AST
-// The AST and nodes will be using web-tree-sitter types.
-// save map to file as a documentAstTracker.json inside the user's global continue path
-// delete document from map
-// clear map
-import * as fs from "fs";
-import * as path from "path";
import Parser from "web-tree-sitter";
-import { getContinueGlobalPath } from "../util/paths";
/**
- * Singleton class that keeps track of a map of document paths to their history of ASTs.
+ * Singleton class that keeps track of a map of document paths to their history.
+ * The point here is to prevent re-calculating the AST,
+ * and to preserve an older, original state of the document before any user edits.
*/
-export class DocumentAstTracker {
- private static instance: DocumentAstTracker | null = null;
+export class DocumentHistoryTracker {
+ private static instance: DocumentHistoryTracker | null = null;
- // Map from document path to history of ASTs (LIFO stack where newest AST is at the front).
+ // Map from document path to history (LIFO stack where newest representation is at the front).
private documentAstMap: Map;
private documentContentHistoryMap: Map;
- // Path to save the AST tracker data.
- private readonly savePath: string;
-
private constructor() {
this.documentAstMap = new Map();
this.documentContentHistoryMap = new Map();
- this.savePath = path.join(
- getContinueGlobalPath(),
- "documentAstTracker.jsonl",
- );
-
- // Try to load existing data.
- // this.loadFromFile();
}
/**
- * Get the singleton instance of DocumentAstTracker.
+ * Get the singleton instance of DocumentHistoryTracker.
*/
- public static getInstance(): DocumentAstTracker {
- if (!DocumentAstTracker.instance) {
- DocumentAstTracker.instance = new DocumentAstTracker();
+ public static getInstance(): DocumentHistoryTracker {
+ if (!DocumentHistoryTracker.instance) {
+ DocumentHistoryTracker.instance = new DocumentHistoryTracker();
}
- return DocumentAstTracker.instance;
+ return DocumentHistoryTracker.instance;
}
/**
- * Add a document and its first AST to the tracker.
+ * Add a document and its first state to the tracker.
*
* @param documentPath The path of the document.
+ * @param documentContent The first content of the document.
* @param ast The first AST of the document.
*/
public addDocument(
@@ -63,17 +42,17 @@ export class DocumentAstTracker {
): void {
this.documentAstMap.set(documentPath, [ast]);
this.documentContentHistoryMap.set(documentPath, [documentContent]);
- // this.saveToFile();
}
/**
* Push a new AST to an existing document's history stack.
*
* @param documentPath The path of the document.
+ * @param documentContent The new content to push to the document's history stack.
* @param ast The new AST to push to the document's history stack.
* @throws Error if the document doesn't exist in the tracker.
*/
- public pushAst(
+ public push(
documentPath: string,
documentContent: string,
ast: Parser.Tree,
@@ -86,12 +65,9 @@ export class DocumentAstTracker {
this.addDocument(documentPath, documentContent, ast);
}
- console.log("same AST:", this.getMostRecentAst(documentPath) !== ast);
-
- // Add the new AST to the front of the array (LIFO stack).
+ // Push to top (LIFO).
astHistory!.unshift(ast);
documentHistory!.unshift(documentContent);
- // this.saveToFile();
}
/**
@@ -148,7 +124,6 @@ export class DocumentAstTracker {
public deleteDocument(documentPath: string): void {
this.documentAstMap.delete(documentPath);
this.documentContentHistoryMap.delete(documentPath);
- // this.saveToFile();
}
/**
@@ -157,51 +132,5 @@ export class DocumentAstTracker {
public clearMap(): void {
this.documentAstMap.clear();
this.documentContentHistoryMap.clear();
- // this.saveToFile();
- }
-
- /**
- * Save the current state of the tracker to a file.
- */
- private saveToFile(): void {
- try {
- // We can't directly serialize Tree objects to JSON.
- // So we'll just save the paths - this serves as a record of which documents we're tracking.
- // The actual ASTs will need to be recreated when needed.
- const documentPaths = Array.from(this.documentAstMap.keys());
- const serializableData = { documentPaths };
-
- fs.writeFileSync(
- this.savePath,
- JSON.stringify(serializableData, null, 2),
- );
- } catch (error) {
- console.error("Error saving AST tracker data to file:", error);
- }
- }
-
- /**
- * Load the tracker state from a file.
- */
- private loadFromFile(): void {
- try {
- if (fs.existsSync(this.savePath)) {
- const fileContent = fs.readFileSync(this.savePath, "utf-8");
- const data = JSON.parse(fileContent);
-
- // We only saved the paths, not the actual Trees.
- // The Trees need to be reparsed when the documents are loaded again.
- if (data && data.documentPaths) {
- // Initialize empty arrays for each document.
- data.documentPaths.forEach((path: string) => {
- this.documentAstMap.set(path, []);
- });
- }
- }
- } catch (error) {
- console.error("Error loading AST tracker data from file:", error);
- // If loading fails, we'll start with an empty map.
- this.documentAstMap = new Map();
- }
}
}
diff --git a/core/nextEdit/NextEditEditableRegionCalculator.ts b/core/nextEdit/NextEditEditableRegionCalculator.ts
index a4dc04794..7f5d13b66 100644
--- a/core/nextEdit/NextEditEditableRegionCalculator.ts
+++ b/core/nextEdit/NextEditEditableRegionCalculator.ts
@@ -1,7 +1,7 @@
import Parser from "web-tree-sitter";
import { Chunk, IDE, ILLM, Position, Range, RangeInFile } from "..";
import { getAst } from "../autocomplete/util/ast";
-import { DocumentAstTracker } from "./DocumentHistoryTracker";
+import { DocumentHistoryTracker } from "./DocumentHistoryTracker";
export enum EditableRegionStrategy {
Naive = "naive",
@@ -362,7 +362,7 @@ async function staticJump(ctx: {
// Get the file's AST.
// Getting this once helps us live-track the current node.
const tree =
- await DocumentAstTracker.getInstance().getMostRecentAst(filepath);
+ await DocumentHistoryTracker.getInstance().getMostRecentAst(filepath);
// const tree = await getAst(filepath, fileContent);
if (!tree) return null;
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index f266b27bf..3af145859 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -26,7 +26,7 @@ import {
} from "./constants.js";
import { createDiff, DiffFormatType } from "./context/diffFormatting.js";
import { calculateFinalCursorPosition } from "./diff/diff.js";
-import { DocumentAstTracker } from "./DocumentHistoryTracker.js";
+import { DocumentHistoryTracker } from "./DocumentHistoryTracker.js";
import {
EditableRegionStrategy,
getNextEditableRegion,
@@ -224,7 +224,7 @@ export class NextEditProvider {
).toString();
const ast = await getAst(this.previousRequest.filepath, fileContent);
if (ast) {
- DocumentAstTracker.getInstance().pushAst(
+ DocumentHistoryTracker.getInstance().push(
localPathOrUriToPath(this.previousRequest.filepath),
fileContent,
ast,
@@ -311,7 +311,7 @@ export class NextEditProvider {
} else {
const historyDiff = createDiff({
beforeContent:
- DocumentAstTracker.getInstance().getMostRecentDocumentHistory(
+ DocumentHistoryTracker.getInstance().getMostRecentDocumentHistory(
localPathOrUriToPath(helper.filepath),
) ?? "",
afterContent: helper.fileContents,
diff --git a/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts b/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts
index f40047c4f..a72c67202 100644
--- a/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts
+++ b/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts
@@ -10,6 +10,15 @@ export interface ExpectedGhostTextAcceptance {
endCharacter: number;
}
+/**
+ * This singleton tracks whether a given ghost text is accepted or not.
+ * We need this because there is no clean way of determining if a ghost text has been accepted outside of vscode command callback.
+ * The above mentioned callback is not viable because it's too slow.
+ * We need a way to reject model predictions on cursor movement, but cursor can move due to many reasons -- one being accepting a ghost text.
+ * We need to differentiate the ghost text acceptance from a deliberate cursor movement to reject the completion.
+ * The cursor movement event listener fires much before the vscode command callback, so the chain of edits often breaks when cursor moves due to accepting a ghost text.
+ * This is not what we want, as we want to keep the current chain of edits alive when the user accepts the completion.
+ */
export class GhostTextAcceptanceTracker {
private static instance: GhostTextAcceptanceTracker | undefined;
private expectedAcceptance: ExpectedGhostTextAcceptance | null = null;
diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts
index 94bf619df..c32ecfc9c 100644
--- a/extensions/vscode/src/extension/VsCodeExtension.ts
+++ b/extensions/vscode/src/extension/VsCodeExtension.ts
@@ -43,7 +43,7 @@ import { ConfigYamlDocumentLinkProvider } from "./ConfigYamlDocumentLinkProvider
import { VsCodeMessenger } from "./VsCodeMessenger";
import { getAst } from "core/autocomplete/util/ast";
-import { DocumentAstTracker } from "core/nextEdit/DocumentHistoryTracker";
+import { DocumentHistoryTracker } from "core/nextEdit/DocumentHistoryTracker";
import {
EditableRegionStrategy,
getNextEditableRegion,
@@ -384,7 +384,7 @@ export class VsCodeExtension {
console.log("onDidOpenTextDocument");
const ast = await getAst(event.fileName, event.getText());
if (ast) {
- DocumentAstTracker.getInstance().addDocument(
+ DocumentHistoryTracker.getInstance().addDocument(
localPathOrUriToPath(event.fileName),
event.getText(),
ast,
From 4c94fd84464b2bc1b7ff22ba298f256c34ebf62a Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 28 Jul 2025 15:42:16 -0700
Subject: [PATCH 094/244] refactor: cleanup
---
core/nextEdit/NextEditProvider.ts | 14 ++--
.../templating/NextEditPromptEngine.ts | 67 +------------------
2 files changed, 11 insertions(+), 70 deletions(-)
diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts
index 3af145859..b431f0503 100644
--- a/core/nextEdit/NextEditProvider.ts
+++ b/core/nextEdit/NextEditProvider.ts
@@ -71,7 +71,6 @@ export class NextEditProvider {
private previousRequest: AutocompleteInput | null = null;
private previousCompletions: NextEditOutcome[] = [];
private nextEditableRegionsInTheCurrentChain: RangeInFile[] = [];
- // TODO: keep track of the last completion request (at least the file path it came from)
private constructor(
private readonly configHandler: ConfigHandler,
@@ -305,6 +304,7 @@ export class NextEditProvider {
// TODO: Toggle between the default endpoint and the finetuned endpoint.
const prompts: Prompt[] = [];
+
if (this.endpointType === "default") {
prompts.push(renderDefaultSystemPrompt());
prompts.push(renderDefaultUserPrompt(snippetPayload, helper));
@@ -319,11 +319,12 @@ export class NextEditProvider {
diffType: DiffFormatType.Unified,
contextLines: 3,
});
+
const promptMetadata = await renderPrompt(
helper,
historyDiff ?? this.diffContext,
- EditableRegionStrategy.Naive,
);
+
this.promptMetadata = promptMetadata;
prompts.push({
@@ -336,6 +337,7 @@ export class NextEditProvider {
"If the user has made a change, make sure you respect that and try to apply it to other parts of the code that used to use the old content.",
].join("\n"),
});
+
prompts.push(promptMetadata.prompt);
}
@@ -343,10 +345,12 @@ export class NextEditProvider {
helper.pos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
0,
);
+
const editableRegionEndLine = Math.min(
helper.pos.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
helper.fileLines.length - 1,
);
+
const oldEditRangeSlice = helper.fileContents
.split("\n")
.slice(editableRegionStartLine, editableRegionEndLine + 1)
@@ -361,6 +365,7 @@ export class NextEditProvider {
if (this.endpointType === "default") {
const msg: ChatMessage = await llm.chat(prompts, token);
+
if (typeof msg.content === "string") {
const nextCompletion = JSON.parse(msg.content).newCode;
const outcomeNext: NextEditOutcome = {
@@ -368,7 +373,6 @@ export class NextEditProvider {
modelProvider: llm.underlyingProviderName,
modelName: llm.model + ":zetaDataset",
completionOptions: null,
- // filepath: helper.filepath,
completionId: helper.input.completionId,
gitRepo: await this.ide.getRepoName(helper.filepath),
uniqueId: await this.ide.getUniqueId(),
@@ -413,14 +417,17 @@ export class NextEditProvider {
: "";
const currCursorPos = helper.pos;
+
const editableRegionStartLine = Math.max(
currCursorPos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
0,
);
+
const editableRegionEndLine = Math.min(
currCursorPos.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
helper.fileLines.length - 1,
);
+
const oldEditRangeSlice = helper.fileContents
.split("\n")
.slice(editableRegionStartLine, editableRegionEndLine + 1)
@@ -438,7 +445,6 @@ export class NextEditProvider {
modelProvider: llm.underlyingProviderName,
modelName: llm.model + ":zetaDataset",
completionOptions: null,
- // filepath: helper.filepath,
completionId: helper.input.completionId,
gitRepo: await this.ide.getRepoName(helper.filepath),
uniqueId: await this.ide.getUniqueId(),
diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts
index d6cd8dacf..bad3f5166 100644
--- a/core/nextEdit/templating/NextEditPromptEngine.ts
+++ b/core/nextEdit/templating/NextEditPromptEngine.ts
@@ -1,5 +1,5 @@
import Handlebars from "handlebars";
-import { Position, RangeInFile } from "../..";
+import { Position } from "../..";
import { SnippetPayload } from "../../autocomplete/snippets";
import { HelperVars } from "../../autocomplete/util/HelperVars";
import {
@@ -9,9 +9,7 @@ import {
NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN,
USER_CURSOR_IS_HERE_TOKEN,
} from "../constants";
-import { EditableRegionStrategy } from "../NextEditEditableRegionCalculator";
import {
- NextEditOutcome,
NextEditTemplate,
PromptMetadata,
SystemPrompt,
@@ -51,9 +49,6 @@ function templateRendererOfModel(
export async function renderPrompt(
helper: HelperVars,
userEdits: string,
- editableRegionStrategy: EditableRegionStrategy,
- prevOutcome?: NextEditOutcome,
- toApply?: RangeInFile,
): Promise {
let modelName = helper.modelName as NextEditModelName;
@@ -87,70 +82,10 @@ export async function renderPrompt(
const renderer = templateRendererOfModel(modelName);
let editedCodeWithTokens = "";
- // TODO: apply prevOutcome to existing content. we will need the line range.
- // Also display the diff between existing content and applied content.
- // NOTE: This only runs in fetchFunction.
- // if (prevOutcome) {
- // // console.log("renderPrompt prevOutcome:", prevOutcome.completion);
- // // console.log(
- // // "beforeInsert:",
- // // helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
- // // );
- // // console.log("toInsert: ", prevOutcome?.completion.split("\n"));
- // // console.log(
- // // "afterInsert:",
- // // helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
- // // );
- // let appliedContent = [
- // ...helper.fileLines.slice(0, prevOutcome?.editableRegionStartLine),
- // ...(prevOutcome?.completion.split("\n") ?? []),
- // ...helper.fileLines.slice(prevOutcome?.editableRegionEndLine),
- // ];
- // // console.log("helper.fileContents:", helper.fileContents);
- // // NOTE: I'm not sure, but <|user_cursor_is_here|> is somehow being added to appliedContent.
- // // The individual parts don't contain this.
- // // console.log("appliedContent:", appliedContent);
- // appliedContent = appliedContent.filter(
- // (line) => !line.includes(USER_CURSOR_IS_HERE_TOKEN),
- // );
- // // Given a previous response, we need to calculate where the cursor would be.
- // // I think it's a good idea to calculate this in the response.
-
- // // TODO: handle cases where there are more than one next editable region.
- // // NOTE: we might set it so that we receive the next editable region as an argument.
- // const editableRegion = await getNextEditableRegion(editableRegionStrategy, {
- // fileLines: appliedContent,
- // filepath: helper.filepath,
- // });
-
- // // console.log("appliedContent:", appliedContent);
- // // console.log("startLine:", editableRegion?.range.start.line);
- // editedCodeWithTokens = insertTokens(
- // appliedContent,
- // prevOutcome.finalCursorPosition,
- // editableRegion && editableRegion[0]?.range.start.line !== undefined
- // ? editableRegion[0].range.start.line
- // : undefined,
- // editableRegion && editableRegion[0]?.range.end.line !== undefined
- // ? editableRegion[0].range.end.line
- // : undefined,
- // );
- // // console.log("new editedCodeWithTokens:", editedCodeWithTokens);
- // userEdits = createDiff({
- // beforeContent: helper.fileContents,
- // afterContent: appliedContent.join("\n"),
- // filePath: helper.filepath,
- // diffType: DiffFormatType.Unified,
- // contextLines: 3,
- // });
- // userEdits = userEdits.replace(USER_CURSOR_IS_HERE_TOKEN, "");
- // // console.log("new userDiff:", userEdits);
- // } else {
editedCodeWithTokens = insertTokens(
helper.fileContents.split("\n"),
helper.pos,
);
- // }
const tv: TemplateVars = {
userEdits,
From 885654ede28c53dc89701044d38febe1ade761f3 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 28 Jul 2025 15:53:14 -0700
Subject: [PATCH 095/244] test: add vitest for GhostTextAcceptanceTracker
---
.../GhostTextAcceptanceTracker.vitest.ts | 246 ++++++++++++++++++
1 file changed, 246 insertions(+)
create mode 100644 extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.vitest.ts
diff --git a/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.vitest.ts b/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.vitest.ts
new file mode 100644
index 000000000..18a1b80ff
--- /dev/null
+++ b/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.vitest.ts
@@ -0,0 +1,246 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import * as vscode from "vscode";
+import { GhostTextAcceptanceTracker } from "./GhostTextAcceptanceTracker";
+
+// Mock the vscode module
+vi.mock("vscode", () => ({
+ Position: vi.fn((line: number, character: number) => ({
+ line,
+ character,
+ isEqual: vi.fn(
+ (other: any) => other.line === line && other.character === character,
+ ),
+ })),
+ Range: vi.fn((start: any, end: any) => ({ start, end })),
+}));
+
+describe("GhostTextAcceptanceTracker", () => {
+ let tracker: GhostTextAcceptanceTracker;
+ let mockDocument: vscode.TextDocument;
+
+ beforeEach(() => {
+ // Clear any existing instance
+ GhostTextAcceptanceTracker.clearInstance();
+ tracker = GhostTextAcceptanceTracker.getInstance();
+
+ // Create mock document
+ mockDocument = {
+ uri: {
+ toString: () => "file:///test.ts",
+ },
+ version: 1,
+ getText: vi.fn(),
+ } as any;
+ });
+
+ describe("getInstance", () => {
+ it("should return the same instance when called multiple times", () => {
+ const instance1 = GhostTextAcceptanceTracker.getInstance();
+ const instance2 = GhostTextAcceptanceTracker.getInstance();
+ expect(instance1).toBe(instance2);
+ });
+
+ it("should create a new instance after clearInstance is called", () => {
+ const instance1 = GhostTextAcceptanceTracker.getInstance();
+ GhostTextAcceptanceTracker.clearInstance();
+ const instance2 = GhostTextAcceptanceTracker.getInstance();
+ expect(instance1).not.toBe(instance2);
+ });
+ });
+
+ describe("setExpectedGhostTextAcceptance", () => {
+ it("should set expected acceptance for single line text", () => {
+ const startPosition = new vscode.Position(5, 10);
+ const text = "console.log('hello')";
+
+ tracker.setExpectedGhostTextAcceptance(mockDocument, text, startPosition);
+
+ // Verify internal state by testing checkGhostTextWasAccepted.
+ const newDocument = {
+ ...mockDocument,
+ version: 2,
+ getText: vi.fn().mockReturnValue(text),
+ } as any;
+ const endPosition = new vscode.Position(5, 30); // 10 in startPosition + 20 characters in text
+
+ expect(tracker.checkGhostTextWasAccepted(newDocument, endPosition)).toBe(
+ true,
+ );
+ });
+
+ it("should set expected acceptance for multi-line text", () => {
+ const startPosition = new vscode.Position(5, 10);
+ const text = "function test() {\n return 'hello';\n}";
+
+ tracker.setExpectedGhostTextAcceptance(mockDocument, text, startPosition);
+
+ // For multi-line, end position should be at line 7 (5 + 3 lines - 1), character 1 (length of last line).
+ const newDocument = {
+ ...mockDocument,
+ version: 2,
+ getText: vi.fn().mockReturnValue(text),
+ } as any;
+ const endPosition = new vscode.Position(7, 1);
+
+ expect(tracker.checkGhostTextWasAccepted(newDocument, endPosition)).toBe(
+ true,
+ );
+ });
+ });
+
+ describe("checkGhostTextWasAccepted", () => {
+ beforeEach(() => {
+ const startPosition = new vscode.Position(5, 10);
+ const text = "console.log('test')";
+ tracker.setExpectedGhostTextAcceptance(mockDocument, text, startPosition);
+ });
+
+ it("should return false when no expected acceptance is set", () => {
+ GhostTextAcceptanceTracker.clearInstance();
+ const newTracker = GhostTextAcceptanceTracker.getInstance();
+
+ const newDocument = { ...mockDocument, version: 2 } as any;
+ const position = new vscode.Position(5, 29);
+
+ expect(newTracker.checkGhostTextWasAccepted(newDocument, position)).toBe(
+ false,
+ );
+ });
+
+ it("should return false when document URI doesn't match", () => {
+ const differentDocument = {
+ ...mockDocument,
+ uri: { toString: () => "file:///different.ts" },
+ version: 2,
+ } as any;
+ const position = new vscode.Position(5, 29);
+
+ expect(
+ tracker.checkGhostTextWasAccepted(differentDocument, position),
+ ).toBe(false);
+ });
+
+ it("should return false when document version is not newer", () => {
+ const sameVersionDocument = {
+ ...mockDocument,
+ version: 1, // same version
+ } as any;
+ const position = new vscode.Position(5, 29);
+
+ expect(
+ tracker.checkGhostTextWasAccepted(sameVersionDocument, position),
+ ).toBe(false);
+
+ const olderVersionDocument = {
+ ...mockDocument,
+ version: 0, // older version
+ } as any;
+
+ expect(
+ tracker.checkGhostTextWasAccepted(olderVersionDocument, position),
+ ).toBe(false);
+ });
+
+ it("should return false when cursor position doesn't match expected end position", () => {
+ const newDocument = {
+ ...mockDocument,
+ version: 2,
+ getText: vi.fn().mockReturnValue("console.log('test')"),
+ } as any;
+ const wrongPosition = new vscode.Position(5, 20); // wrong position
+
+ expect(
+ tracker.checkGhostTextWasAccepted(newDocument, wrongPosition),
+ ).toBe(false);
+ });
+
+ it("should return false when text content doesn't match", () => {
+ const newDocument = {
+ ...mockDocument,
+ version: 2,
+ getText: vi.fn().mockReturnValue("different text"), // wrong text
+ } as any;
+ const correctPosition = new vscode.Position(5, 29);
+
+ expect(
+ tracker.checkGhostTextWasAccepted(newDocument, correctPosition),
+ ).toBe(false);
+ });
+
+ it("should return true when all conditions match and clear expectation", () => {
+ const expectedText = "console.log('test')";
+ const newDocument = {
+ ...mockDocument,
+ version: 2,
+ getText: vi.fn().mockReturnValue(expectedText),
+ } as any;
+ const correctPosition = new vscode.Position(5, 29); // 10 + 19 characters
+
+ expect(
+ tracker.checkGhostTextWasAccepted(newDocument, correctPosition),
+ ).toBe(true);
+
+ // Check for clearing logic.
+ expect(
+ tracker.checkGhostTextWasAccepted(newDocument, correctPosition),
+ ).toBe(false);
+ });
+
+ it("should handle getText throwing an error gracefully", () => {
+ const newDocument = {
+ ...mockDocument,
+ version: 2,
+ getText: vi.fn().mockImplementation(() => {
+ throw new Error("Range invalid");
+ }),
+ } as any;
+ const correctPosition = new vscode.Position(5, 29);
+
+ expect(
+ tracker.checkGhostTextWasAccepted(newDocument, correctPosition),
+ ).toBe(false);
+ });
+
+ it("should work with multi-line ghost text acceptance", () => {
+ const startPosition = new vscode.Position(0, 0);
+ const multiLineText = "if (condition) {\n doSomething();\n}";
+ tracker.setExpectedGhostTextAcceptance(
+ mockDocument,
+ multiLineText,
+ startPosition,
+ );
+
+ const newDocument = {
+ ...mockDocument,
+ version: 2,
+ getText: vi.fn().mockReturnValue(multiLineText),
+ } as any;
+ const endPosition = new vscode.Position(2, 1); // line 2, character 1 (length of "}")
+
+ expect(tracker.checkGhostTextWasAccepted(newDocument, endPosition)).toBe(
+ true,
+ );
+ });
+
+ it("should handle empty text", () => {
+ const startPosition = new vscode.Position(10, 5);
+ const emptyText = "";
+ tracker.setExpectedGhostTextAcceptance(
+ mockDocument,
+ emptyText,
+ startPosition,
+ );
+
+ const newDocument = {
+ ...mockDocument,
+ version: 2,
+ getText: vi.fn().mockReturnValue(""),
+ } as any;
+ const samePosition = new vscode.Position(10, 5); // should be same as start for empty text
+
+ expect(tracker.checkGhostTextWasAccepted(newDocument, samePosition)).toBe(
+ true,
+ );
+ });
+ });
+});
From b061f7f04707ae8c6f34f589fe0894716a34a18e Mon Sep 17 00:00:00 2001
From: Patrick Erichsen
Date: Mon, 28 Jul 2025 15:54:17 -0700
Subject: [PATCH 096/244] more CI updates
---
.../actions/build-vscode-extension/action.yml | 146 ++++++
.github/actions/setup-component/action.yml | 48 ++
.github/actions/setup-node-base/action.yml | 11 +
.github/actions/setup-packages/action.yml | 20 +
.github/workflows/build-vscode-extension.yml | 13 +
.github/workflows/main-build.yaml | 63 ++-
.github/workflows/main.yaml | 64 ++-
.github/workflows/pr_checks.yaml | 447 ++++++------------
.github/workflows/preview.yaml | 64 ++-
scripts/build-packages.js | 2 +-
10 files changed, 538 insertions(+), 340 deletions(-)
create mode 100644 .github/actions/build-vscode-extension/action.yml
create mode 100644 .github/actions/setup-component/action.yml
create mode 100644 .github/actions/setup-node-base/action.yml
create mode 100644 .github/actions/setup-packages/action.yml
diff --git a/.github/actions/build-vscode-extension/action.yml b/.github/actions/build-vscode-extension/action.yml
new file mode 100644
index 000000000..d3a7bbcae
--- /dev/null
+++ b/.github/actions/build-vscode-extension/action.yml
@@ -0,0 +1,146 @@
+name: 'Build VS Code Extension'
+description: 'Build VS Code extension for a specific platform'
+inputs:
+ platform:
+ description: 'Target platform (win32, linux, alpine, darwin)'
+ required: true
+ arch:
+ description: 'Target architecture (x64, arm64, armhf)'
+ required: true
+ npm_config_arch:
+ description: 'npm config arch (x64, arm64, arm)'
+ required: true
+ pre-release:
+ description: 'Whether to build as pre-release'
+ required: false
+ default: 'false'
+ commit-sha:
+ description: 'Commit SHA for version modification (optional, uses first 7 chars)'
+ required: false
+ default: ''
+outputs:
+ target:
+ description: 'The target string used for the build'
+ value: ${{ steps.set-target.outputs.target }}
+ vsix-path:
+ description: 'Path to the generated VSIX file'
+ value: 'extensions/vscode/*.vsix'
+ build-path:
+ description: 'Path to the build artifacts'
+ value: 'extensions/vscode/build'
+
+runs:
+ using: 'composite'
+ steps:
+ - name: Set target variable
+ id: set-target
+ shell: bash
+ run: echo "target=${{ inputs.platform }}-${{ inputs.arch }}" >> $GITHUB_OUTPUT
+
+ - name: Cache npm
+ uses: actions/cache@v4
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-npm-cache-build-${{ hashFiles('**/package-lock.json') }}
+
+ - name: Cache extension node_modules
+ uses: actions/cache@v4
+ with:
+ path: extensions/vscode/node_modules
+ key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
+
+ - name: Cache core node_modules
+ uses: actions/cache@v4
+ with:
+ path: core/node_modules
+ key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
+
+ - name: Cache gui node_modules
+ uses: actions/cache@v4
+ with:
+ path: gui/node_modules
+ key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
+
+ - name: Cache packages node_modules
+ uses: actions/cache@v4
+ with:
+ path: |
+ packages/*/node_modules
+ key: ${{ runner.os }}-packages-node-modules-${{ hashFiles('packages/*/package-lock.json') }}
+
+ - name: Build packages
+ shell: bash
+ run: node ./scripts/build-packages.js
+
+ - name: Install extension dependencies
+ shell: bash
+ run: |
+ cd extensions/vscode
+ npm ci
+ env:
+ # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
+ GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
+
+ - name: Install gui dependencies
+ shell: bash
+ run: |
+ cd gui
+ npm ci
+
+ - name: Install core dependencies
+ shell: bash
+ run: |
+ cd core
+ npm ci
+ npm i vectordb
+
+ - name: Prepackage the extension
+ shell: bash
+ run: |
+ cd extensions/vscode
+ npm run prepackage -- --target ${{ steps.set-target.outputs.target }}
+
+ - name: Re-install esbuild
+ shell: bash
+ run: |
+ cd extensions/vscode
+ npm install -f esbuild
+
+ - name: Modify package.json version with commit SHA
+ if: inputs.commit-sha != ''
+ shell: bash
+ run: |
+ cd extensions/vscode
+ # Get current version from package.json
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
+
+ # Create new version with short commit SHA (first 7 chars)
+ COMMIT_SHORT="${{ inputs.commit-sha }}"
+ NEW_VERSION="${CURRENT_VERSION}-${COMMIT_SHORT:0:7}"
+
+ echo "📝 Updating package.json version from $CURRENT_VERSION to $NEW_VERSION"
+
+ # Update version in package.json
+ sed -i.bak "s/\"version\": \"$CURRENT_VERSION\"/\"version\": \"$NEW_VERSION\"/" package.json
+
+ # Remove backup file
+ rm -f package.json.bak
+
+ # Verify the change
+ echo "✅ New version: $(node -p "require('./package.json').version")"
+
+ - name: Package extension (build artifacts)
+ shell: bash
+ run: |
+ cd extensions/vscode
+ npm run package
+
+ - name: Package extension (.vsix files)
+ shell: bash
+ run: |
+ cd extensions/vscode
+ if [ "${{ inputs.pre-release }}" = "true" ]; then
+ npx vsce package --pre-release --no-dependencies --target ${{ steps.set-target.outputs.target }}
+ else
+ npx vsce package --no-dependencies --target ${{ steps.set-target.outputs.target }}
+ fi
\ No newline at end of file
diff --git a/.github/actions/setup-component/action.yml b/.github/actions/setup-component/action.yml
new file mode 100644
index 000000000..e51831cdb
--- /dev/null
+++ b/.github/actions/setup-component/action.yml
@@ -0,0 +1,48 @@
+name: 'Setup Component'
+description: 'Cache and install dependencies for a specific component'
+inputs:
+ component:
+ description: 'Component name (core, gui, vscode, binary)'
+ required: true
+ include-packages:
+ description: 'Whether to include packages cache (default: true)'
+ required: false
+ default: 'true'
+ include-root:
+ description: 'Whether to include root cache (default: false)'
+ required: false
+ default: 'false'
+
+runs:
+ using: 'composite'
+ steps:
+ - uses: actions/cache@v4
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-npm-cache-${{ inputs.component }}-${{ hashFiles(format('{0}/package-lock.json', inputs.component)) }}
+
+ - uses: actions/cache@v4
+ if: inputs.include-packages == 'true'
+ with:
+ path: |
+ packages/*/node_modules
+ key: ${{ runner.os }}-packages-node-modules-${{ hashFiles('packages/*/package-lock.json') }}
+
+ - uses: actions/cache@v4
+ if: inputs.include-root == 'true'
+ with:
+ path: node_modules
+ key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
+
+ - uses: actions/cache@v4
+ id: component-cache
+ with:
+ path: ${{ inputs.component }}/node_modules
+ key: ${{ runner.os }}-${{ inputs.component }}-node-modules-${{ hashFiles(format('{0}/package-lock.json', inputs.component)) }}
+
+ - name: Install component dependencies
+ if: steps.component-cache.outputs.cache-hit != 'true'
+ shell: bash
+ run: |
+ cd ${{ inputs.component }}
+ npm ci
\ No newline at end of file
diff --git a/.github/actions/setup-node-base/action.yml b/.github/actions/setup-node-base/action.yml
new file mode 100644
index 000000000..f98bd4b48
--- /dev/null
+++ b/.github/actions/setup-node-base/action.yml
@@ -0,0 +1,11 @@
+name: 'Setup Node Base'
+description: 'Checkout repository and setup Node.js with .nvmrc version'
+
+runs:
+ using: 'composite'
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
\ No newline at end of file
diff --git a/.github/actions/setup-packages/action.yml b/.github/actions/setup-packages/action.yml
new file mode 100644
index 000000000..0e1212c8a
--- /dev/null
+++ b/.github/actions/setup-packages/action.yml
@@ -0,0 +1,20 @@
+name: 'Setup Packages'
+description: 'Cache and build packages with npm caching'
+
+runs:
+ using: 'composite'
+ steps:
+ - uses: actions/cache@v4
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-npm-cache-packages-${{ hashFiles('packages/*/package-lock.json') }}
+
+ - uses: actions/cache@v4
+ with:
+ path: |
+ packages/*/node_modules
+ key: ${{ runner.os }}-packages-node-modules-${{ hashFiles('packages/*/package-lock.json') }}
+
+ - name: Build packages
+ shell: bash
+ run: node ./scripts/build-packages.js
\ No newline at end of file
diff --git a/.github/workflows/build-vscode-extension.yml b/.github/workflows/build-vscode-extension.yml
index 4bb008d46..5a85691b9 100644
--- a/.github/workflows/build-vscode-extension.yml
+++ b/.github/workflows/build-vscode-extension.yml
@@ -87,6 +87,12 @@ jobs:
with:
node-version-file: ".nvmrc"
+ - name: Cache npm
+ uses: actions/cache@v4
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-npm-cache-build-${{ hashFiles('**/package-lock.json') }}
+
- name: Cache extension node_modules
uses: actions/cache@v4
with:
@@ -105,6 +111,13 @@ jobs:
path: gui/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
+ - name: Cache packages node_modules
+ uses: actions/cache@v4
+ with:
+ path: |
+ packages/*/node_modules
+ key: ${{ runner.os }}-packages-node-modules-${{ hashFiles('packages/*/package-lock.json') }}
+
# Build all packages using the authoritative build script
- name: Build packages
run: node ./scripts/build-packages.js
diff --git a/.github/workflows/main-build.yaml b/.github/workflows/main-build.yaml
index de22d6c53..9ac6d5d81 100644
--- a/.github/workflows/main-build.yaml
+++ b/.github/workflows/main-build.yaml
@@ -7,24 +7,45 @@ on:
jobs:
build:
- uses: ./.github/workflows/build-vscode-extension.yml
- with:
- # Build only for macOS latest and Ubuntu latest
- platforms: |
- [
- {
- "os": "ubuntu-latest",
- "platform": "linux",
- "arch": "x64",
- "npm_config_arch": "x64"
- },
- {
- "os": "macos-latest",
- "platform": "darwin",
- "arch": "arm64",
- "npm_config_arch": "arm64"
- }
- ]
- pre-release: false
- commit-sha: ${{ github.sha }}
- secrets: inherit
\ No newline at end of file
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ include:
+ - os: ubuntu-latest
+ platform: linux
+ arch: x64
+ npm_config_arch: x64
+ - os: macos-latest
+ platform: darwin
+ arch: arm64
+ npm_config_arch: arm64
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
+
+ - uses: ./.github/actions/build-vscode-extension
+ with:
+ platform: ${{ matrix.platform }}
+ arch: ${{ matrix.arch }}
+ npm_config_arch: ${{ matrix.npm_config_arch }}
+ pre-release: false
+ commit-sha: ${{ github.sha }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
+
+ - name: Upload build artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: vscode-extension-build-${{ runner.os }}
+ path: extensions/vscode/build
+
+ - name: Upload .vsix artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ matrix.platform }}-${{ matrix.arch }}-vsix
+ path: "extensions/vscode/*.vsix"
\ No newline at end of file
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index a8abf6cb3..2024b083b 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -29,11 +29,65 @@ jobs:
build:
needs: check_release_name
if: needs.check_release_name.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
- uses: ./.github/workflows/build-vscode-extension.yml
- with:
- # Uses default platforms (all supported platforms)
- pre-release: false
- secrets: inherit
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ include:
+ - os: windows-latest
+ platform: win32
+ arch: x64
+ npm_config_arch: x64
+ - os: windows-latest
+ platform: win32
+ arch: arm64
+ npm_config_arch: arm
+ - os: ubuntu-latest
+ platform: linux
+ arch: x64
+ npm_config_arch: x64
+ - os: ubuntu-latest
+ platform: linux
+ arch: arm64
+ npm_config_arch: arm64
+ - os: ubuntu-latest
+ platform: linux
+ arch: armhf
+ npm_config_arch: arm
+ - os: ubuntu-latest
+ platform: alpine
+ arch: x64
+ npm_config_arch: x64
+ - os: macos-13
+ platform: darwin
+ arch: x64
+ npm_config_arch: x64
+ - os: macos-13
+ platform: darwin
+ arch: arm64
+ npm_config_arch: arm64
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
+
+ - uses: ./.github/actions/build-vscode-extension
+ with:
+ platform: ${{ matrix.platform }}
+ arch: ${{ matrix.arch }}
+ npm_config_arch: ${{ matrix.npm_config_arch }}
+ pre-release: false
+ env:
+ GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
+
+ - name: Upload .vsix artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ matrix.platform }}-${{ matrix.arch }}-vsix
+ path: "extensions/vscode/*.vsix"
check-version:
runs-on: ubuntu-latest
diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml
index a78035a6e..132ffdf6c 100644
--- a/.github/workflows/pr_checks.yaml
+++ b/.github/workflows/pr_checks.yaml
@@ -11,14 +11,11 @@ on:
- main
jobs:
- install-root:
+
+ prettier-check:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
+ - uses: ./.github/actions/setup-node-base
- uses: actions/cache@v4
id: root-cache
@@ -30,116 +27,43 @@ jobs:
if: steps.root-cache.outputs.cache-hit != 'true'
run: npm ci
- prettier-check:
- needs: install-root
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- name: Check code formatting with Prettier
run: npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}" --ignore-path .gitignore --ignore-path .prettierignore
build-packages:
- needs: install-root
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - name: Build packages (Unix)
- run: node ./scripts/build-packages.js
+ - uses: ./.github/actions/setup-node-base
+ - uses: ./.github/actions/setup-packages
config-yaml-checks:
- needs: build-packages
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
+ - uses: ./.github/actions/setup-node-base
+ - uses: ./.github/actions/setup-packages
- uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
- - name: Build packages and check config-yaml
+ - name: Check config-yaml
run: |
- node ./scripts/build-packages.js
cd packages/config-yaml
npx tsc --noEmit
# Tests are currently failing, commenting out for now
# npm test
- install-core:
- needs: install-root
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- os: [ubuntu-latest, macos-latest]
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- id: root-cache
- with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - uses: actions/cache@v4
- id: core-cache
- with:
- path: core/node_modules
- key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
-
- - name: Install core dependencies
- if: steps.core-cache.outputs.cache-hit != 'true'
- run: |
- cd core
- npm ci
core-checks:
- needs: install-core
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
+ - uses: ./.github/actions/setup-node-base
+ - uses: ./.github/actions/setup-packages
+ - uses: ./.github/actions/setup-component
with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - uses: actions/cache@v4
- with:
- path: core/node_modules
- key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
-
- - name: Build packages and install core dependencies
- run: |
- node ./scripts/build-packages.js
- cd core
- npm ci
+ component: core
+ include-root: true
- name: Type check and lint
run: |
@@ -149,73 +73,20 @@ jobs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- install-gui:
- needs: [install-root, install-core]
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - uses: actions/cache@v4
- with:
- path: core/node_modules
- key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: gui-cache
- with:
- path: gui/node_modules
- key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }}
-
- - name: Build packages and install dependencies
- run: |
- node ./scripts/build-packages.js
- if [ "${{ steps.gui-cache.outputs.cache-hit }}" != "true" ]; then
- cd core
- npm ci
- cd ../gui
- npm ci
- fi
gui-checks:
- needs: install-gui
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-node@v4
+ - uses: ./.github/actions/setup-node-base
+ - uses: ./.github/actions/setup-packages
+ - uses: ./.github/actions/setup-component
with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
+ component: core
+ include-root: true
+ - uses: ./.github/actions/setup-component
with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - uses: actions/cache@v4
- with:
- path: core/node_modules
- key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
-
- - uses: actions/cache@v4
- with:
- path: gui/node_modules
- key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }}
-
- - name: Build packages and install dependencies
- run: |
- node ./scripts/build-packages.js
- cd core
- npm ci
- cd ../gui
- npm ci
+ component: gui
+ include-packages: false
- name: Type check and lint
run: |
@@ -224,89 +95,26 @@ jobs:
npm run lint
binary-checks:
- needs: [install-root, install-core]
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
+ - uses: ./.github/actions/setup-node-base
+ - uses: ./.github/actions/setup-packages
+ - uses: ./.github/actions/setup-component
with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
+ component: core
+ include-root: true
+ - uses: ./.github/actions/setup-component
with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - uses: actions/cache@v4
- with:
- path: core/node_modules
- key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: binary-cache
- with:
- path: binary/node_modules
- key: ${{ runner.os }}-binary-node-modules-${{ hashFiles('binary/package-lock.json') }}
-
- - name: Build packages and install dependencies
- run: |
- node ./scripts/build-packages.js
- if [ "${{ steps.binary-cache.outputs.cache-hit }}" != "true" ]; then
- cd core
- npm ci
- cd ../binary
- npm ci
- fi
+ component: binary
+ include-packages: false
- name: Type check
run: |
cd binary
npx tsc --noEmit
- install-vscode:
- needs: [install-root, install-core]
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- os: [ubuntu-latest, macos-latest]
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - uses: actions/cache@v4
- with:
- path: core/node_modules
- key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: vscode-cache
- with:
- path: extensions/vscode/node_modules
- key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
-
- - name: Build packages and install dependencies
- run: |
- node ./scripts/build-packages.js
- if [ "${{ steps.vscode-cache.outputs.cache-hit }}" != "true" ]; then
- cd core
- npm ci
- cd ../extensions/vscode
- npm ci
- fi
- env:
- GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
vscode-checks:
- needs: install-vscode
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -354,25 +162,13 @@ jobs:
npm run vitest
core-tests:
- needs: install-core
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
+ - uses: ./.github/actions/setup-node-base
+ - uses: ./.github/actions/setup-packages
+ - uses: ./.github/actions/setup-component
with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- with:
- path: core/node_modules
- key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
-
- - name: Build packages and install core dependencies
- run: |
- node ./scripts/build-packages.js
- cd core
- npm ci
+ component: core
- name: Run core tests
run: |
@@ -390,39 +186,20 @@ jobs:
AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }}
AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }}
- package-tests:
- runs-on: ubuntu-latest
+ test-packages:
+ needs: build-packages
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, macos-latest]
+ package: [hub, config-yaml, fetch, openai-adapters]
steps:
- - uses: actions/checkout@v4
+ - uses: ./.github/actions/setup-node-base
+ - uses: ./.github/actions/setup-packages
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - name: Build packages and run tests
+ - name: Test ${{ matrix.package }}
run: |
- node ./scripts/build-packages.js
- cd packages/config-yaml
- npm test
-
- openai-adapters-tests:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - name: Build packages and run tests
- run: |
- node ./scripts/build-packages.js
- cd packages/openai-adapters
+ cd packages/${{ matrix.package }}
npm test
env:
IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }}
@@ -438,14 +215,33 @@ jobs:
vscode-get-test-file-matrix:
runs-on: ubuntu-latest
- needs: [install-root, install-vscode]
outputs:
test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }}
steps:
- uses: actions/checkout@v4
- - name: Cache node modules
+ - name: Cache npm
uses: actions/cache@v4
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-npm-cache-matrix-${{ hashFiles('core/package-lock.json', 'extensions/vscode/package-lock.json') }}
+
+ - name: Cache packages node_modules
+ uses: actions/cache@v4
+ with:
+ path: |
+ packages/*/node_modules
+ key: ${{ runner.os }}-packages-node-modules-${{ hashFiles('packages/*/package-lock.json') }}
+
+ - name: Cache core node modules
+ uses: actions/cache@v4
+ with:
+ path: core/node_modules
+ key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
+
+ - name: Cache vscode extension node modules
+ uses: actions/cache@v4
+ id: vscode-cache
with:
path: extensions/vscode/node_modules
key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
@@ -454,10 +250,13 @@ jobs:
id: vscode-get-test-file-matrix
run: |
node ./scripts/build-packages.js
- cd core
- npm ci
- cd ../extensions/vscode
- npm ci
+ if [ "${{ steps.vscode-cache.outputs.cache-hit }}" != "true" ]; then
+ cd core
+ npm ci
+ cd ../extensions/vscode
+ npm ci
+ fi
+ cd extensions/vscode
npm run e2e:compile
if [[ "${{ github.event.pull_request.head.repo.fork }}" == "true" || "${{ github.actor }}" == "dependabot[bot]" ]]; then
# Exclude SSH tests for forks
@@ -478,32 +277,51 @@ jobs:
echo "Test files: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }}"
vscode-package-extension:
- needs: [install-vscode, install-core]
- uses: ./.github/workflows/build-vscode-extension.yml
- with:
- # Limited platforms for faster PR checks
- platforms: |
- [
- {
- "os": "ubuntu-latest",
- "platform": "linux",
- "arch": "x64",
- "npm_config_arch": "x64"
- },
- {
- "os": "macos-13",
- "platform": "darwin",
- "arch": "x64",
- "npm_config_arch": "x64"
- }
- ]
- pre-release: false
- commit-sha: ${{ github.sha }}
- secrets: inherit
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ include:
+ - os: ubuntu-latest
+ platform: linux
+ arch: x64
+ npm_config_arch: x64
+ - os: macos-13
+ platform: darwin
+ arch: x64
+ npm_config_arch: x64
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
+
+ - uses: ./.github/actions/build-vscode-extension
+ with:
+ platform: ${{ matrix.platform }}
+ arch: ${{ matrix.arch }}
+ npm_config_arch: ${{ matrix.npm_config_arch }}
+ pre-release: false
+ commit-sha: ${{ github.sha }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
+
+ - name: Upload build artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: vscode-extension-build-${{ runner.os }}
+ path: extensions/vscode/build
+
+ - name: Upload .vsix artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ matrix.platform }}-${{ matrix.arch }}-vsix
+ path: "extensions/vscode/*.vsix"
vscode-download-e2e-dependencies:
runs-on: ubuntu-latest
- needs: [install-vscode, install-core]
steps:
- uses: actions/checkout@v4
@@ -546,8 +364,6 @@ jobs:
vscode-download-e2e-dependencies,
vscode-get-test-file-matrix,
vscode-package-extension,
- install-vscode,
- install-core,
]
runs-on: ubuntu-latest
# Tests requiring secrets need approval from maintainers
@@ -657,7 +473,6 @@ jobs:
path: extensions/vscode/e2e.log
gui-tests:
- needs: [install-gui, install-core]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -692,7 +507,7 @@ jobs:
npm test
jetbrains-tests:
- needs: [install-root, core-checks]
+ needs: [core-checks]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -726,17 +541,38 @@ jobs:
with:
node-version-file: ".nvmrc"
+ - uses: actions/cache@v4
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-npm-cache-jetbrains-${{ hashFiles('extensions/vscode/package-lock.json') }}
+
+ - uses: actions/cache@v4
+ id: vscode-extension-cache
+ with:
+ path: extensions/vscode/node_modules
+ key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
+
- uses: actions/cache@v4
id: gui-cache
with:
path: gui/node_modules
key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }}
- # We can shave off another minute off our CI script by finding a way to share this with vscode-tests
+ # Cache prepackaged extension build to share with other jobs
+ - uses: actions/cache@v4
+ id: vscode-prepackage-cache
+ with:
+ path: extensions/vscode/build
+ key: ${{ runner.os }}-vscode-prepackage-${{ hashFiles('extensions/vscode/package-lock.json', 'extensions/vscode/**/*.ts', 'extensions/vscode/**/*.json') }}
+
+ # Only run prepackage if not cached - saves ~1 minute
- name: Run prepackage script
+ if: steps.vscode-prepackage-cache.outputs.cache-hit != 'true'
run: |
cd extensions/vscode
- npm ci
+ if [ "${{ steps.vscode-extension-cache.outputs.cache-hit }}" != "true" ]; then
+ npm ci
+ fi
npm run prepackage
env:
# https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
@@ -802,17 +638,13 @@ jobs:
if: always()
runs-on: ubuntu-latest
needs:
- - install-root
- prettier-check
- - install-core
- core-checks
- - install-gui
- gui-checks
- binary-checks
- - install-vscode
- vscode-checks
- core-tests
- - package-tests
+ - test-packages
- vscode-get-test-file-matrix
- vscode-package-extension
- vscode-download-e2e-dependencies
@@ -821,7 +653,6 @@ jobs:
- jetbrains-tests
- config-yaml-checks
- build-packages
- - openai-adapters-tests
steps:
- name: Decide whether the needed jobs succeeded or failed
diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml
index 54d737e45..611a96f5e 100644
--- a/.github/workflows/preview.yaml
+++ b/.github/workflows/preview.yaml
@@ -29,11 +29,65 @@ jobs:
build:
needs: check_release_name
if: needs.check_release_name.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
- uses: ./.github/workflows/build-vscode-extension.yml
- with:
- # Uses default platforms (all supported platforms)
- pre-release: true
- secrets: inherit
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ include:
+ - os: windows-latest
+ platform: win32
+ arch: x64
+ npm_config_arch: x64
+ - os: windows-latest
+ platform: win32
+ arch: arm64
+ npm_config_arch: arm
+ - os: ubuntu-latest
+ platform: linux
+ arch: x64
+ npm_config_arch: x64
+ - os: ubuntu-latest
+ platform: linux
+ arch: arm64
+ npm_config_arch: arm64
+ - os: ubuntu-latest
+ platform: linux
+ arch: armhf
+ npm_config_arch: arm
+ - os: ubuntu-latest
+ platform: alpine
+ arch: x64
+ npm_config_arch: x64
+ - os: macos-13
+ platform: darwin
+ arch: x64
+ npm_config_arch: x64
+ - os: macos-13
+ platform: darwin
+ arch: arm64
+ npm_config_arch: arm64
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
+
+ - uses: ./.github/actions/build-vscode-extension
+ with:
+ platform: ${{ matrix.platform }}
+ arch: ${{ matrix.arch }}
+ npm_config_arch: ${{ matrix.npm_config_arch }}
+ pre-release: true
+ env:
+ GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
+
+ - name: Upload .vsix artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ matrix.platform }}-${{ matrix.arch }}-vsix
+ path: "extensions/vscode/*.vsix"
release:
permissions:
diff --git a/scripts/build-packages.js b/scripts/build-packages.js
index e268cd215..238a8f0ea 100644
--- a/scripts/build-packages.js
+++ b/scripts/build-packages.js
@@ -97,4 +97,4 @@ async function main() {
if (require.main === module) {
main();
-}
\ No newline at end of file
+}
From 502b07dc7e1e32345a0e57b06f4a436d4a7fb378 Mon Sep 17 00:00:00 2001
From: Patrick Erichsen
Date: Mon, 28 Jul 2025 16:06:59 -0700
Subject: [PATCH 097/244] fix checkout logic
---
.github/actions/setup-node-base/action.yml | 11 -
.github/workflows/build-vscode-extension.yml | 212 -------------------
.github/workflows/pr_checks.yaml | 40 +++-
3 files changed, 32 insertions(+), 231 deletions(-)
delete mode 100644 .github/actions/setup-node-base/action.yml
delete mode 100644 .github/workflows/build-vscode-extension.yml
diff --git a/.github/actions/setup-node-base/action.yml b/.github/actions/setup-node-base/action.yml
deleted file mode 100644
index f98bd4b48..000000000
--- a/.github/actions/setup-node-base/action.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-name: 'Setup Node Base'
-description: 'Checkout repository and setup Node.js with .nvmrc version'
-
-runs:
- using: 'composite'
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
\ No newline at end of file
diff --git a/.github/workflows/build-vscode-extension.yml b/.github/workflows/build-vscode-extension.yml
deleted file mode 100644
index 5a85691b9..000000000
--- a/.github/workflows/build-vscode-extension.yml
+++ /dev/null
@@ -1,212 +0,0 @@
-name: Build VS Code Extension
-
-on:
- workflow_call:
- inputs:
- platforms:
- description: "JSON array of platform configurations (defaults to all platforms)"
- required: false
- type: string
- default: |
- [
- {
- "os": "windows-latest",
- "platform": "win32",
- "arch": "x64",
- "npm_config_arch": "x64"
- },
- {
- "os": "windows-latest",
- "platform": "win32",
- "arch": "arm64",
- "npm_config_arch": "arm"
- },
- {
- "os": "ubuntu-latest",
- "platform": "linux",
- "arch": "x64",
- "npm_config_arch": "x64"
- },
- {
- "os": "ubuntu-latest",
- "platform": "linux",
- "arch": "arm64",
- "npm_config_arch": "arm64"
- },
- {
- "os": "ubuntu-latest",
- "platform": "linux",
- "arch": "armhf",
- "npm_config_arch": "arm"
- },
- {
- "os": "ubuntu-latest",
- "platform": "alpine",
- "arch": "x64",
- "npm_config_arch": "x64"
- },
- {
- "os": "macos-13",
- "platform": "darwin",
- "arch": "x64",
- "npm_config_arch": "x64"
- },
- {
- "os": "macos-13",
- "platform": "darwin",
- "arch": "arm64",
- "npm_config_arch": "arm64"
- }
- ]
- pre-release:
- description: "Whether to build as pre-release"
- required: false
- type: boolean
- default: false
- commit-sha:
- description: "Commit SHA for version modification (optional, uses first 7 chars)"
- required: false
- type: string
-
-jobs:
- build:
- strategy:
- matrix:
- include: ${{ fromJson(inputs.platforms) }}
- runs-on: ${{ matrix.os }}
- steps:
- # 1. Check-out repository
- - name: Checkout
- uses: actions/checkout@v4
- with:
- fetch-depth: 0 # This ensures all tags are fetched
-
- # 2. Install npm dependencies
- - name: Use Node.js from .nvmrc
- uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - name: Cache npm
- uses: actions/cache@v4
- with:
- path: ~/.npm
- key: ${{ runner.os }}-npm-cache-build-${{ hashFiles('**/package-lock.json') }}
-
- - name: Cache extension node_modules
- uses: actions/cache@v4
- with:
- path: extensions/vscode/node_modules
- key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
-
- - name: Cache core node_modules
- uses: actions/cache@v4
- with:
- path: core/node_modules
- key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
-
- - name: Cache gui node_modules
- uses: actions/cache@v4
- with:
- path: gui/node_modules
- key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
-
- - name: Cache packages node_modules
- uses: actions/cache@v4
- with:
- path: |
- packages/*/node_modules
- key: ${{ runner.os }}-packages-node-modules-${{ hashFiles('packages/*/package-lock.json') }}
-
- # Build all packages using the authoritative build script
- - name: Build packages
- run: node ./scripts/build-packages.js
-
- - name: Install extension Dependencies
- run: |
- cd extensions/vscode
- npm ci
- env:
- # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
- GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
-
- - name: Install gui Dependencies
- run: |
- cd gui
- npm ci
-
- # npm ci doesn't end up capturing the @lancedb/... dep because it's not in the package-lock.json
- - name: Install Core Dependencies
- run: |
- cd core
- npm ci
- npm i vectordb
-
- # 2.5. Pre package
- - name: Set var for environment info
- shell: pwsh
- run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
-
- - name: Prepackage the extension
- run: |
- cd extensions/vscode
- npm run prepackage -- --target ${{ env.target }}
-
- # 3. Re-install esbuild (for cases that we force installed for another arch in prepackage.js)
- - name: Re-install esbuild
- run: |
- cd extensions/vscode
- npm install -f esbuild
-
- # 3.5. Modify version with commit SHA
- - name: Modify package.json version with commit SHA
- if: inputs.commit-sha != ''
- run: |
- cd extensions/vscode
- # Get current version from package.json
- CURRENT_VERSION=$(node -p "require('./package.json').version")
-
- # Create new version with short commit SHA (first 7 chars)
- COMMIT_SHORT="${{ inputs.commit-sha }}"
- NEW_VERSION="${CURRENT_VERSION}-${COMMIT_SHORT:0:7}"
-
- echo "📝 Updating package.json version from $CURRENT_VERSION to $NEW_VERSION"
-
- # Update version in package.json
- sed -i.bak "s/\"version\": \"$CURRENT_VERSION\"/\"version\": \"$NEW_VERSION\"/" package.json
-
- # Remove backup file
- rm -f package.json.bak
-
- # Verify the change
- echo "✅ New version: $(node -p "require('./package.json').version")"
-
- # 4. Package the extension
- - name: Package extension (build artifacts)
- run: |
- cd extensions/vscode
- npm run package
-
- - name: Package extension (.vsix files)
- run: |
- cd extensions/vscode
- if [ "${{ inputs.pre-release }}" = "true" ]; then
- npx vsce package --pre-release --no-dependencies --target ${{ env.target }}
- else
- npx vsce package --no-dependencies --target ${{ env.target }}
- fi
- shell: bash
-
- # 5. Upload build artifacts (for e2e tests)
- - name: Upload build artifact
- uses: actions/upload-artifact@v4
- with:
- name: vscode-extension-build-${{ runner.os }}
- path: extensions/vscode/build
-
- # 6. Upload .vsix artifacts (for releases and downloading)
- - name: Upload .vsix artifact
- uses: actions/upload-artifact@v4
- with:
- name: ${{ env.target }}-vsix
- path: "extensions/vscode/*.vsix"
diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml
index 132ffdf6c..2f4f7cf0c 100644
--- a/.github/workflows/pr_checks.yaml
+++ b/.github/workflows/pr_checks.yaml
@@ -15,7 +15,10 @@ jobs:
prettier-check:
runs-on: ubuntu-latest
steps:
- - uses: ./.github/actions/setup-node-base
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
- uses: actions/cache@v4
id: root-cache
@@ -33,13 +36,19 @@ jobs:
build-packages:
runs-on: ubuntu-latest
steps:
- - uses: ./.github/actions/setup-node-base
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
- uses: ./.github/actions/setup-packages
config-yaml-checks:
runs-on: ubuntu-latest
steps:
- - uses: ./.github/actions/setup-node-base
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
- uses: ./.github/actions/setup-packages
- uses: actions/cache@v4
@@ -58,7 +67,10 @@ jobs:
core-checks:
runs-on: ubuntu-latest
steps:
- - uses: ./.github/actions/setup-node-base
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
- uses: ./.github/actions/setup-packages
- uses: ./.github/actions/setup-component
with:
@@ -77,7 +89,10 @@ jobs:
gui-checks:
runs-on: ubuntu-latest
steps:
- - uses: ./.github/actions/setup-node-base
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
- uses: ./.github/actions/setup-packages
- uses: ./.github/actions/setup-component
with:
@@ -97,7 +112,10 @@ jobs:
binary-checks:
runs-on: ubuntu-latest
steps:
- - uses: ./.github/actions/setup-node-base
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
- uses: ./.github/actions/setup-packages
- uses: ./.github/actions/setup-component
with:
@@ -164,7 +182,10 @@ jobs:
core-tests:
runs-on: ubuntu-latest
steps:
- - uses: ./.github/actions/setup-node-base
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
- uses: ./.github/actions/setup-packages
- uses: ./.github/actions/setup-component
with:
@@ -194,7 +215,10 @@ jobs:
os: [ubuntu-latest, macos-latest]
package: [hub, config-yaml, fetch, openai-adapters]
steps:
- - uses: ./.github/actions/setup-node-base
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
- uses: ./.github/actions/setup-packages
- name: Test ${{ matrix.package }}
From 982e051981412f02c18ef46011c263ed118cc686 Mon Sep 17 00:00:00 2001
From: Patrick Erichsen
Date: Mon, 28 Jul 2025 16:10:47 -0700
Subject: [PATCH 098/244] CI fixes
---
.github/actions/setup-packages/action.yml | 14 +++++++++++++-
.github/workflows/pr_checks.yaml | 3 +--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/.github/actions/setup-packages/action.yml b/.github/actions/setup-packages/action.yml
index 0e1212c8a..9cf5c5ad1 100644
--- a/.github/actions/setup-packages/action.yml
+++ b/.github/actions/setup-packages/action.yml
@@ -17,4 +17,16 @@ runs:
- name: Build packages
shell: bash
- run: node ./scripts/build-packages.js
\ No newline at end of file
+ run: node ./scripts/build-packages.js
+
+ - name: Install package dependencies
+ shell: bash
+ run: |
+ for package_dir in packages/*/; do
+ if [ -f "$package_dir/package.json" ]; then
+ echo "Installing dependencies for $package_dir"
+ cd "$package_dir"
+ npm ci
+ cd - > /dev/null
+ fi
+ done
\ No newline at end of file
diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml
index 2f4f7cf0c..567425cff 100644
--- a/.github/workflows/pr_checks.yaml
+++ b/.github/workflows/pr_checks.yaml
@@ -209,10 +209,9 @@ jobs:
test-packages:
needs: build-packages
- runs-on: ${{ matrix.os }}
+ runs-on: ubuntu-latest
strategy:
matrix:
- os: [ubuntu-latest, macos-latest]
package: [hub, config-yaml, fetch, openai-adapters]
steps:
- uses: actions/checkout@v4
From 21b15eb7b4ea4e40c5c18f3b803db4e2916b878a Mon Sep 17 00:00:00 2001
From: Patrick Erichsen
Date: Mon, 28 Jul 2025 16:17:08 -0700
Subject: [PATCH 099/244] CI fixes
---
.github/actions/setup-packages/action.yml | 4 +++-
packages/hub/package.json | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/.github/actions/setup-packages/action.yml b/.github/actions/setup-packages/action.yml
index 9cf5c5ad1..dc0462d70 100644
--- a/.github/actions/setup-packages/action.yml
+++ b/.github/actions/setup-packages/action.yml
@@ -23,10 +23,12 @@ runs:
shell: bash
run: |
for package_dir in packages/*/; do
- if [ -f "$package_dir/package.json" ]; then
+ if [ -f "$package_dir/package.json" ] && [ ! -d "$package_dir/node_modules" ]; then
echo "Installing dependencies for $package_dir"
cd "$package_dir"
npm ci
cd - > /dev/null
+ elif [ -d "$package_dir/node_modules" ]; then
+ echo "Using cached dependencies for $package_dir"
fi
done
\ No newline at end of file
diff --git a/packages/hub/package.json b/packages/hub/package.json
index e6f3ab8d3..af9db232c 100644
--- a/packages/hub/package.json
+++ b/packages/hub/package.json
@@ -6,7 +6,7 @@
"types": "dist/index.d.ts",
"type": "module",
"scripts": {
- "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
"build": "tsc"
},
"author": "Continue Dev, Inc.",
From b07dd9b7c2ce16bd52125cfb2d0c645e08f0d9a3 Mon Sep 17 00:00:00 2001
From: Patrick Erichsen
Date: Mon, 28 Jul 2025 16:36:56 -0700
Subject: [PATCH 100/244] remove macOS build dep
---
.github/workflows/main-build.yaml | 51 -----------------------
.github/workflows/main.yaml | 4 +-
.github/workflows/pr_checks.yaml | 67 ++++++++++++++++++++-----------
.github/workflows/preview.yaml | 4 +-
4 files changed, 47 insertions(+), 79 deletions(-)
delete mode 100644 .github/workflows/main-build.yaml
diff --git a/.github/workflows/main-build.yaml b/.github/workflows/main-build.yaml
deleted file mode 100644
index 9ac6d5d81..000000000
--- a/.github/workflows/main-build.yaml
+++ /dev/null
@@ -1,51 +0,0 @@
-name: Build Extension on Main
-
-on:
- push:
- branches:
- - main
-
-jobs:
- build:
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- include:
- - os: ubuntu-latest
- platform: linux
- arch: x64
- npm_config_arch: x64
- - os: macos-latest
- platform: darwin
- arch: arm64
- npm_config_arch: arm64
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - uses: ./.github/actions/build-vscode-extension
- with:
- platform: ${{ matrix.platform }}
- arch: ${{ matrix.arch }}
- npm_config_arch: ${{ matrix.npm_config_arch }}
- pre-release: false
- commit-sha: ${{ github.sha }}
- env:
- GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
-
- - name: Upload build artifact
- uses: actions/upload-artifact@v4
- with:
- name: vscode-extension-build-${{ runner.os }}
- path: extensions/vscode/build
-
- - name: Upload .vsix artifact
- uses: actions/upload-artifact@v4
- with:
- name: ${{ matrix.platform }}-${{ matrix.arch }}-vsix
- path: "extensions/vscode/*.vsix"
\ No newline at end of file
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index 2024b083b..a3a266f3b 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -57,11 +57,11 @@ jobs:
platform: alpine
arch: x64
npm_config_arch: x64
- - os: macos-13
+ - os: macos-latest
platform: darwin
arch: x64
npm_config_arch: x64
- - os: macos-13
+ - os: macos-latest
platform: darwin
arch: arm64
npm_config_arch: arm64
diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml
index 567425cff..65134d222 100644
--- a/.github/workflows/pr_checks.yaml
+++ b/.github/workflows/pr_checks.yaml
@@ -11,7 +11,6 @@ on:
- main
jobs:
-
prettier-check:
runs-on: ubuntu-latest
steps:
@@ -63,7 +62,6 @@ jobs:
# Tests are currently failing, commenting out for now
# npm test
-
core-checks:
runs-on: ubuntu-latest
steps:
@@ -85,7 +83,6 @@ jobs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
-
gui-checks:
runs-on: ubuntu-latest
steps:
@@ -131,7 +128,6 @@ jobs:
cd binary
npx tsc --noEmit
-
vscode-checks:
runs-on: ubuntu-latest
steps:
@@ -299,19 +295,8 @@ jobs:
run: |
echo "Test files: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }}"
- vscode-package-extension:
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- include:
- - os: ubuntu-latest
- platform: linux
- arch: x64
- npm_config_arch: x64
- - os: macos-13
- platform: darwin
- arch: x64
- npm_config_arch: x64
+ vscode-package-extension-linux:
+ runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
@@ -323,9 +308,9 @@ jobs:
- uses: ./.github/actions/build-vscode-extension
with:
- platform: ${{ matrix.platform }}
- arch: ${{ matrix.arch }}
- npm_config_arch: ${{ matrix.npm_config_arch }}
+ platform: linux
+ arch: x64
+ npm_config_arch: x64
pre-release: false
commit-sha: ${{ github.sha }}
env:
@@ -334,13 +319,46 @@ jobs:
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
- name: vscode-extension-build-${{ runner.os }}
+ name: vscode-extension-build-Linux
path: extensions/vscode/build
- name: Upload .vsix artifact
uses: actions/upload-artifact@v4
with:
- name: ${{ matrix.platform }}-${{ matrix.arch }}-vsix
+ name: linux-x64-vsix
+ path: "extensions/vscode/*.vsix"
+
+ vscode-package-extension-macos:
+ runs-on: macos-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
+
+ - uses: ./.github/actions/build-vscode-extension
+ with:
+ platform: darwin
+ arch: x64
+ npm_config_arch: x64
+ pre-release: false
+ commit-sha: ${{ github.sha }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
+
+ - name: Upload build artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: vscode-extension-build-macOS
+ path: extensions/vscode/build
+
+ - name: Upload .vsix artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: darwin-x64-vsix
path: "extensions/vscode/*.vsix"
vscode-download-e2e-dependencies:
@@ -386,7 +404,7 @@ jobs:
[
vscode-download-e2e-dependencies,
vscode-get-test-file-matrix,
- vscode-package-extension,
+ vscode-package-extension-linux,
]
runs-on: ubuntu-latest
# Tests requiring secrets need approval from maintainers
@@ -669,7 +687,8 @@ jobs:
- core-tests
- test-packages
- vscode-get-test-file-matrix
- - vscode-package-extension
+ - vscode-package-extension-linux
+ - vscode-package-extension-macos
- vscode-download-e2e-dependencies
- vscode-e2e-tests
- gui-tests
diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml
index 611a96f5e..60563beee 100644
--- a/.github/workflows/preview.yaml
+++ b/.github/workflows/preview.yaml
@@ -57,11 +57,11 @@ jobs:
platform: alpine
arch: x64
npm_config_arch: x64
- - os: macos-13
+ - os: macos-latest
platform: darwin
arch: x64
npm_config_arch: x64
- - os: macos-13
+ - os: macos-latest
platform: darwin
arch: arm64
npm_config_arch: arm64
From f93a18e390b0c7302844f46f14697ff5d556eba3 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 28 Jul 2025 16:46:22 -0700
Subject: [PATCH 101/244] feat: pass end line
---
extensions/vscode/src/commands.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts
index 01db39411..2ffd24418 100644
--- a/extensions/vscode/src/commands.ts
+++ b/extensions/vscode/src/commands.ts
@@ -925,6 +925,7 @@ const getCommandsMap: (
editor,
currentPosition,
editableRegionStartLine,
+ editableRegionEndLine,
oldEditRangeSlice,
newEditRangeSlice,
diffLines,
From f6699bae062beb46a2ff21bbe18d0bcaf01c73b1 Mon Sep 17 00:00:00 2001
From: Patrick Erichsen
Date: Mon, 28 Jul 2025 16:46:26 -0700
Subject: [PATCH 102/244] Update pr_checks.yaml
---
.github/workflows/pr_checks.yaml | 117 ++++++++-----------------------
1 file changed, 31 insertions(+), 86 deletions(-)
diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml
index 65134d222..0051c9901 100644
--- a/.github/workflows/pr_checks.yaml
+++ b/.github/workflows/pr_checks.yaml
@@ -83,6 +83,22 @@ jobs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
+ - name: Run tests
+ run: |
+ cd core
+ npm test
+ npm run vitest
+ env:
+ IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }}
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
+ GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
+ MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
+ AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
+ AZURE_FOUNDRY_CODESTRAL_API_KEY: ${{ secrets.AZURE_FOUNDRY_CODESTRAL_API_KEY }}
+ AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }}
+ AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }}
+
gui-checks:
runs-on: ubuntu-latest
steps:
@@ -99,6 +115,8 @@ jobs:
with:
component: gui
include-packages: false
+ env:
+ GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
- name: Type check and lint
run: |
@@ -106,6 +124,11 @@ jobs:
npx tsc --noEmit
npm run lint
+ - name: Run tests
+ run: |
+ cd gui
+ npm test
+
binary-checks:
runs-on: ubuntu-latest
steps:
@@ -132,34 +155,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
-
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
+ - uses: ./.github/actions/setup-packages
+ - uses: ./.github/actions/setup-component
with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - uses: actions/cache@v4
+ component: core
+ include-root: true
+ - uses: ./.github/actions/setup-component
with:
- path: core/node_modules
- key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: vscode-cache
- with:
- path: extensions/vscode/node_modules
- key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
-
- - name: Build packages and install dependencies
- run: |
- node ./scripts/build-packages.js
- cd core
- npm ci
- cd ../extensions/vscode
- npm ci
+ component: vscode
+ include-packages: false
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
@@ -175,40 +182,13 @@ jobs:
cd extensions/vscode
npm run vitest
- core-tests:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
- - uses: ./.github/actions/setup-packages
- - uses: ./.github/actions/setup-component
- with:
- component: core
-
- - name: Run core tests
- run: |
- cd core
- npm test
- npm run vitest
- env:
- IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }}
- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
- MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
- AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
- AZURE_FOUNDRY_CODESTRAL_API_KEY: ${{ secrets.AZURE_FOUNDRY_CODESTRAL_API_KEY }}
- AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }}
- AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }}
test-packages:
needs: build-packages
runs-on: ubuntu-latest
strategy:
matrix:
- package: [hub, config-yaml, fetch, openai-adapters]
+ package: [hub, config-yaml, fetch]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
@@ -513,39 +493,6 @@ jobs:
name: e2e-logs-${{ steps.sanitize_filename.outputs.sanitized_test_file || 'unknown' }}-${{ matrix.command == 'e2e:ci:run-yaml' && 'yaml' || 'json' }}
path: extensions/vscode/e2e.log
- gui-tests:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- with:
- path: gui/node_modules
- key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }}
-
- - uses: actions/cache@v4
- with:
- path: core/node_modules
- key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
-
- - name: Build packages and install dependencies
- run: |
- node ./scripts/build-packages.js
- cd core
- npm ci
- cd ../gui
- npm ci
- env:
- GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
-
- - name: Run gui tests
- run: |
- cd gui
- npm test
jetbrains-tests:
needs: [core-checks]
@@ -684,14 +631,12 @@ jobs:
- gui-checks
- binary-checks
- vscode-checks
- - core-tests
- test-packages
- vscode-get-test-file-matrix
- vscode-package-extension-linux
- vscode-package-extension-macos
- vscode-download-e2e-dependencies
- vscode-e2e-tests
- - gui-tests
- jetbrains-tests
- config-yaml-checks
- build-packages
From a265cbd5cbf9767adcf035e1373cc33df7baaea6 Mon Sep 17 00:00:00 2001
From: Jacob Kim
Date: Mon, 28 Jul 2025 16:47:41 -0700
Subject: [PATCH 103/244] chore: bump version
---
binary/package-lock.json | 3 ++-
core/package-lock.json | 15 ++++++++++++---
extensions/vscode/package-lock.json | 4 ++--
package-lock.json | 2 +-
4 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/binary/package-lock.json b/binary/package-lock.json
index 11dd6505b..85ce515a1 100644
--- a/binary/package-lock.json
+++ b/binary/package-lock.json
@@ -77,6 +77,7 @@
"handlebars": "^4.7.8",
"http-proxy-agent": "^7.0.1",
"https-proxy-agent": "^7.0.3",
+ "iconv-lite": "^0.6.3",
"ignore": "^5.3.1",
"is-localhost-ip": "^2.0.0",
"jinja-js": "0.1.8",
@@ -90,7 +91,7 @@
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
"onnxruntime-node": "1.14.0",
- "openai": "^4.76.0",
+ "openai": "^4.104.0",
"p-limit": "^6.1.0",
"partial-json": "^0.1.7",
"pg": "^8.11.3",
diff --git a/core/package-lock.json b/core/package-lock.json
index d2afa4b76..8dfc3a735 100644
--- a/core/package-lock.json
+++ b/core/package-lock.json
@@ -38,6 +38,7 @@
"handlebars": "^4.7.8",
"http-proxy-agent": "^7.0.1",
"https-proxy-agent": "^7.0.3",
+ "iconv-lite": "^0.6.3",
"ignore": "^5.3.1",
"is-localhost-ip": "^2.0.0",
"jinja-js": "0.1.8",
@@ -169,15 +170,16 @@
},
"../packages/openai-adapters": {
"name": "@continuedev/openai-adapters",
- "version": "1.0.45",
+ "version": "1.1.1",
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/client-bedrock-runtime": "^3.842.0",
"@aws-sdk/credential-providers": "^3.840.0",
"@continuedev/config-types": "^1.0.5",
"@continuedev/config-yaml": "^1.0.51",
- "@continuedev/fetch": "^1.0.15",
+ "@continuedev/fetch": "^1.0.16",
"dotenv": "^16.5.0",
+ "google-auth-library": "^10.1.0",
"json-schema": "^0.4.0",
"node-fetch": "^3.3.2",
"openai": "^4.104.0",
@@ -185,13 +187,20 @@
"zod": "^3.24.2"
},
"devDependencies": {
+ "@semantic-release/changelog": "^6.0.3",
+ "@semantic-release/commit-analyzer": "^13.0.1",
+ "@semantic-release/git": "^10.0.1",
+ "@semantic-release/github": "^11.0.3",
+ "@semantic-release/npm": "^12.0.2",
+ "@semantic-release/release-notes-generator": "^14.0.3",
"@types/follow-redirects": "^1.14.4",
"@types/jest": "^29.5.14",
"@types/json-schema": "^7.0.15",
"cross-env": "^7.0.3",
+ "semantic-release": "^24.2.7",
"ts-jest": "^29.2.3",
"ts-node": "^10.9.2",
- "vitest": "^1.6.1"
+ "vitest": "^3.2.4"
}
},
"node_modules/@75lb/deep-merge": {
diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json
index 0f419444a..7b50769d1 100644
--- a/extensions/vscode/package-lock.json
+++ b/extensions/vscode/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "continue",
- "version": "1.1.68",
+ "version": "1.1.69",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
- "version": "1.1.68",
+ "version": "1.1.69",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
diff --git a/package-lock.json b/package-lock.json
index 0a2538840..b4289d422 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "wt-openai-adapters-tests",
+ "name": "continue",
"lockfileVersion": 3,
"requires": true,
"packages": {
From 3a64311bdf1cdf0351f3ffeb803ffe5ef212fdb1 Mon Sep 17 00:00:00 2001
From: Patrick Erichsen
Date: Mon, 28 Jul 2025 16:52:48 -0700
Subject: [PATCH 104/244] add action for running e2e tess
---
.../actions/run-vscode-e2e-test/action.yml | 127 ++++++++++++++++++
.github/actions/setup-component/action.yml | 8 +-
.github/workflows/pr_checks.yaml | 102 +-------------
3 files changed, 137 insertions(+), 100 deletions(-)
create mode 100644 .github/actions/run-vscode-e2e-test/action.yml
diff --git a/.github/actions/run-vscode-e2e-test/action.yml b/.github/actions/run-vscode-e2e-test/action.yml
new file mode 100644
index 000000000..61faa84eb
--- /dev/null
+++ b/.github/actions/run-vscode-e2e-test/action.yml
@@ -0,0 +1,127 @@
+name: 'Run VS Code E2E Test'
+description: 'Run a single VS Code E2E test with all required setup'
+inputs:
+ test_file:
+ description: 'E2E test file to run'
+ required: true
+ command:
+ description: 'Command to run (e2e:ci:run or e2e:ci:run-yaml)'
+ required: true
+ ssh_key:
+ description: 'SSH private key for testing'
+ required: false
+ ssh_host:
+ description: 'SSH host for testing'
+ required: false
+ is_fork:
+ description: 'Whether this is a fork (affects SSH tests)'
+ required: false
+ default: 'false'
+
+runs:
+ using: 'composite'
+ steps:
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: ".nvmrc"
+
+ - uses: actions/cache@v4
+ id: vscode-node-modules-cache
+ with:
+ path: extensions/vscode/node_modules
+ key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
+
+ # We don't want to cache the Continue extension, so it is deleted at the end of the job
+ - uses: actions/cache@v4
+ id: test-extensions-cache
+ with:
+ path: extensions/vscode/e2e/.test-extensions
+ key: CONSTANT
+
+ - name: Download build artifact
+ uses: actions/download-artifact@v4
+ with:
+ name: vscode-extension-build-Linux
+ path: extensions/vscode/build
+
+ - name: Download e2e dependencies
+ uses: actions/download-artifact@v4
+ with:
+ name: vscode-e2e-dependencies
+ path: extensions/vscode/e2e/storage
+
+ - name: Build packages and install core dependencies
+ shell: bash
+ run: |
+ node ./scripts/build-packages.js
+ cd core
+ npm ci
+
+ - name: Fix VSCode binary permissions
+ shell: bash
+ run: |
+ chmod +x extensions/vscode/e2e/storage/VSCode-linux-x64/code
+ chmod +x extensions/vscode/e2e/storage/chromedriver-linux64/chromedriver
+
+ - name: Set up SSH
+ if: ${{ inputs.ssh_key != '' && inputs.ssh_host != '' && inputs.is_fork == 'false' }}
+ shell: bash
+ env:
+ SSH_KEY: ${{ inputs.ssh_key }}
+ SSH_HOST: ${{ inputs.ssh_host }}
+ run: |
+ mkdir -p ~/.ssh
+ echo "$SSH_KEY" > ~/.ssh/id_rsa
+ chmod 600 ~/.ssh/id_rsa
+ ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts
+ echo -e "Host ssh-test-container\n\tHostName $SSH_HOST\n\tUser ec2-user\n\tIdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
+
+ - name: Set up Xvfb
+ shell: bash
+ run: |
+ Xvfb :99 &
+ export DISPLAY=:99
+
+ - name: Run e2e tests
+ shell: bash
+ run: |
+ cd extensions/vscode
+ IGNORE_SSH_TESTS="${{ inputs.is_fork }}" TEST_FILE="${{ inputs.test_file }}" npm run ${{ inputs.command }}
+ env:
+ DISPLAY: :99
+
+ - name: Delete continue from test extensions
+ shell: bash
+ run: |
+ cd extensions/vscode
+ rm -rf e2e/.test-extensions/continue*
+
+ - name: Sanitize test file name
+ id: sanitize_filename
+ if: always()
+ shell: bash
+ run: |
+ FILENAME="${{ inputs.test_file }}"
+ SANITIZED_FILENAME="${FILENAME//\//-}" # Replace / with - using bash parameter expansion
+ echo "sanitized_test_file=${SANITIZED_FILENAME}" >> $GITHUB_OUTPUT
+
+ - name: Upload e2e test screenshots
+ if: failure()
+ uses: actions/upload-artifact@v4
+ with:
+ name: e2e-failure-screenshots-${{ steps.sanitize_filename.outputs.sanitized_test_file || 'unknown' }}-${{ inputs.command == 'e2e:ci:run-yaml' && 'yaml' || 'json' }}
+ path: extensions/vscode/e2e/storage/screenshots
+
+ - name: Find e2e log file
+ if: always()
+ shell: bash
+ run: |
+ echo "Searching for e2e.log file..."
+ find $GITHUB_WORKSPACE -name "e2e.log" -type f
+
+ - name: Upload e2e logs
+ if: always()
+ uses: actions/upload-artifact@v4
+ with:
+ name: e2e-logs-${{ steps.sanitize_filename.outputs.sanitized_test_file || 'unknown' }}-${{ inputs.command == 'e2e:ci:run-yaml' && 'yaml' || 'json' }}
+ path: extensions/vscode/e2e.log
\ No newline at end of file
diff --git a/.github/actions/setup-component/action.yml b/.github/actions/setup-component/action.yml
index e51831cdb..fbc4eb273 100644
--- a/.github/actions/setup-component/action.yml
+++ b/.github/actions/setup-component/action.yml
@@ -19,7 +19,7 @@ runs:
- uses: actions/cache@v4
with:
path: ~/.npm
- key: ${{ runner.os }}-npm-cache-${{ inputs.component }}-${{ hashFiles(format('{0}/package-lock.json', inputs.component)) }}
+ key: ${{ runner.os }}-npm-cache-${{ inputs.component }}-${{ hashFiles(inputs.component == 'vscode' && 'extensions/vscode/package-lock.json' || format('{0}/package-lock.json', inputs.component)) }}
- uses: actions/cache@v4
if: inputs.include-packages == 'true'
@@ -37,12 +37,12 @@ runs:
- uses: actions/cache@v4
id: component-cache
with:
- path: ${{ inputs.component }}/node_modules
- key: ${{ runner.os }}-${{ inputs.component }}-node-modules-${{ hashFiles(format('{0}/package-lock.json', inputs.component)) }}
+ path: ${{ inputs.component == 'vscode' && 'extensions/vscode/node_modules' || format('{0}/node_modules', inputs.component) }}
+ key: ${{ runner.os }}-${{ inputs.component }}-node-modules-${{ hashFiles(inputs.component == 'vscode' && 'extensions/vscode/package-lock.json' || format('{0}/package-lock.json', inputs.component)) }}
- name: Install component dependencies
if: steps.component-cache.outputs.cache-hit != 'true'
shell: bash
run: |
- cd ${{ inputs.component }}
+ cd ${{ inputs.component == 'vscode' && 'extensions/vscode' || inputs.component }}
npm ci
\ No newline at end of file
diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml
index 0051c9901..a6a8123f2 100644
--- a/.github/workflows/pr_checks.yaml
+++ b/.github/workflows/pr_checks.yaml
@@ -395,103 +395,13 @@ jobs:
command: ["e2e:ci:run", "e2e:ci:run-yaml"]
steps:
- uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
+ - uses: ./.github/actions/run-vscode-e2e-test
with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- id: vscode-node-modules-cache
- with:
- path: extensions/vscode/node_modules
- key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
-
- # We don't want to cache the Continue extension, so it is deleted at the end of the job
- - uses: actions/cache@v4
- id: test-extensions-cache
- with:
- path: extensions/vscode/e2e/.test-extensions
- key: CONSTANT
-
- - name: Download build artifact
- uses: actions/download-artifact@v4
- with:
- name: vscode-extension-build-Linux
- path: extensions/vscode/build
-
- - name: Download e2e dependencies
- uses: actions/download-artifact@v4
- with:
- name: vscode-e2e-dependencies
- path: extensions/vscode/e2e/storage
-
- - name: Build packages and install core dependencies
- run: |
- node ./scripts/build-packages.js
- cd core
- npm ci
-
- - name: Fix VSCode binary permissions
- run: |
- chmod +x extensions/vscode/e2e/storage/VSCode-linux-x64/code
- chmod +x extensions/vscode/e2e/storage/chromedriver-linux64/chromedriver
-
- - name: Set up SSH
- env:
- SSH_KEY: ${{ secrets.GH_ACTIONS_SSH_TEST_KEY_PEM }}
- SSH_HOST: ${{ secrets.GH_ACTIONS_SSH_TEST_DNS_NAME }}
- run: |
- mkdir -p ~/.ssh
- echo "$SSH_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts
- echo -e "Host ssh-test-container\n\tHostName $SSH_HOST\n\tUser ec2-user\n\tIdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
- if: ${{ github.event.pull_request.head.repo.fork == false && github.actor != 'dependabot[bot]' }}
-
- - name: Set up Xvfb
- run: |
- Xvfb :99 &
- export DISPLAY=:99
-
- - name: Run e2e tests
- run: |
- cd extensions/vscode
- IGNORE_SSH_TESTS="${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }}" TEST_FILE="${{ matrix.test_file }}" npm run ${{ matrix.command }}
- env:
- DISPLAY: :99
-
- - name: Delete continue from test extensions
- run: |
- cd extensions/vscode
- rm -rf e2e/.test-extensions/continue*
-
- - name: Sanitize test file name
- id: sanitize_filename
- if: always()
- run: |
- FILENAME="${{ matrix.test_file }}"
- SANITIZED_FILENAME="${FILENAME//\//-}" # Replace / with - using bash parameter expansion
- echo "sanitized_test_file=${SANITIZED_FILENAME}" >> $GITHUB_OUTPUT
-
- - name: Upload e2e test screenshots
- if: failure()
- uses: actions/upload-artifact@v4
- with:
- name: e2e-failure-screenshots-${{ steps.sanitize_filename.outputs.sanitized_test_file || 'unknown' }}-${{ matrix.command == 'e2e:ci:run-yaml' && 'yaml' || 'json' }}
- path: extensions/vscode/e2e/storage/screenshots
-
- - name: Find e2e log file
- if: always()
- run: |
- echo "Searching for e2e.log file..."
- find $GITHUB_WORKSPACE -name "e2e.log" -type f
-
- - name: Upload e2e logs
- if: always()
- uses: actions/upload-artifact@v4
- with:
- name: e2e-logs-${{ steps.sanitize_filename.outputs.sanitized_test_file || 'unknown' }}-${{ matrix.command == 'e2e:ci:run-yaml' && 'yaml' || 'json' }}
- path: extensions/vscode/e2e.log
+ test_file: ${{ matrix.test_file }}
+ command: ${{ matrix.command }}
+ ssh_key: ${{ secrets.GH_ACTIONS_SSH_TEST_KEY_PEM }}
+ ssh_host: ${{ secrets.GH_ACTIONS_SSH_TEST_DNS_NAME }}
+ is_fork: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }}
jetbrains-tests:
From b248bb6f848c661500d49898f1dbd6a125f94708 Mon Sep 17 00:00:00 2001
From: Patrick Erichsen
Date: Mon, 28 Jul 2025 17:00:29 -0700
Subject: [PATCH 105/244] move more logic into actions
---
.../actions/run-vscode-e2e-test/action.yml | 25 ++--
.github/workflows/pr_checks.yaml | 113 ++++++------------
2 files changed, 51 insertions(+), 87 deletions(-)
diff --git a/.github/actions/run-vscode-e2e-test/action.yml b/.github/actions/run-vscode-e2e-test/action.yml
index 61faa84eb..1fcba5245 100644
--- a/.github/actions/run-vscode-e2e-test/action.yml
+++ b/.github/actions/run-vscode-e2e-test/action.yml
@@ -38,24 +38,31 @@ runs:
path: extensions/vscode/e2e/.test-extensions
key: CONSTANT
+ - uses: actions/cache@v4
+ id: storage-cache
+ with:
+ path: extensions/vscode/e2e/storage
+ key: ${{ runner.os }}-vscode-storage-${{ hashFiles('extensions/vscode/package-lock.json') }}
+
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: vscode-extension-build-Linux
path: extensions/vscode/build
- - name: Download e2e dependencies
- uses: actions/download-artifact@v4
- with:
- name: vscode-e2e-dependencies
- path: extensions/vscode/e2e/storage
-
- - name: Build packages and install core dependencies
+ - name: Build packages and download e2e dependencies
shell: bash
run: |
node ./scripts/build-packages.js
- cd core
- npm ci
+ if [ "${{ steps.storage-cache.outputs.cache-hit }}" != "true" ]; then
+ cd core
+ npm ci
+ cd ../extensions/vscode
+ npm run e2e:ci:download
+ else
+ cd core
+ npm ci
+ fi
- name: Fix VSCode binary permissions
shell: bash
diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml
index a6a8123f2..5f09bc8be 100644
--- a/.github/workflows/pr_checks.yaml
+++ b/.github/workflows/pr_checks.yaml
@@ -39,28 +39,9 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- - uses: ./.github/actions/setup-packages
+ - name: Setup packages
+ uses: ./.github/actions/setup-packages
- config-yaml-checks:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
- - uses: ./.github/actions/setup-packages
-
- - uses: actions/cache@v4
- with:
- path: node_modules
- key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
-
- - name: Check config-yaml
- run: |
- cd packages/config-yaml
- npx tsc --noEmit
- # Tests are currently failing, commenting out for now
- # npm test
core-checks:
runs-on: ubuntu-latest
@@ -69,8 +50,10 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- - uses: ./.github/actions/setup-packages
- - uses: ./.github/actions/setup-component
+ - name: Setup packages
+ uses: ./.github/actions/setup-packages
+ - name: Setup core component
+ uses: ./.github/actions/setup-component
with:
component: core
include-root: true
@@ -106,12 +89,15 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- - uses: ./.github/actions/setup-packages
- - uses: ./.github/actions/setup-component
+ - name: Setup packages
+ uses: ./.github/actions/setup-packages
+ - name: Setup core component
+ uses: ./.github/actions/setup-component
with:
component: core
include-root: true
- - uses: ./.github/actions/setup-component
+ - name: Setup gui component
+ uses: ./.github/actions/setup-component
with:
component: gui
include-packages: false
@@ -136,12 +122,15 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- - uses: ./.github/actions/setup-packages
- - uses: ./.github/actions/setup-component
+ - name: Setup packages
+ uses: ./.github/actions/setup-packages
+ - name: Setup core component
+ uses: ./.github/actions/setup-component
with:
component: core
include-root: true
- - uses: ./.github/actions/setup-component
+ - name: Setup binary component
+ uses: ./.github/actions/setup-component
with:
component: binary
include-packages: false
@@ -158,12 +147,15 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- - uses: ./.github/actions/setup-packages
- - uses: ./.github/actions/setup-component
+ - name: Setup packages
+ uses: ./.github/actions/setup-packages
+ - name: Setup core component
+ uses: ./.github/actions/setup-component
with:
component: core
include-root: true
- - uses: ./.github/actions/setup-component
+ - name: Setup vscode component
+ uses: ./.github/actions/setup-component
with:
component: vscode
include-packages: false
@@ -183,7 +175,7 @@ jobs:
npm run vitest
- test-packages:
+ packages-checks:
needs: build-packages
runs-on: ubuntu-latest
strategy:
@@ -194,9 +186,10 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- - uses: ./.github/actions/setup-packages
+ - name: Setup packages
+ uses: ./.github/actions/setup-packages
- - name: Test ${{ matrix.package }}
+ - name: Test and check ${{ matrix.package }}
run: |
cd packages/${{ matrix.package }}
npm test
@@ -286,7 +279,8 @@ jobs:
with:
node-version-file: ".nvmrc"
- - uses: ./.github/actions/build-vscode-extension
+ - name: Build VS Code extension
+ uses: ./.github/actions/build-vscode-extension
with:
platform: linux
arch: x64
@@ -319,7 +313,8 @@ jobs:
with:
node-version-file: ".nvmrc"
- - uses: ./.github/actions/build-vscode-extension
+ - name: Build VS Code extension
+ uses: ./.github/actions/build-vscode-extension
with:
platform: darwin
arch: x64
@@ -341,48 +336,11 @@ jobs:
name: darwin-x64-vsix
path: "extensions/vscode/*.vsix"
- vscode-download-e2e-dependencies:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - uses: actions/cache@v4
- id: vscode-node-modules-cache
- with:
- path: extensions/vscode/node_modules
- key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
-
- - uses: actions/cache@v4
- id: storage-cache
- with:
- path: extensions/vscode/e2e/storage
- key: ${{ runner.os }}-vscode-storage-${{ hashFiles('extensions/vscode/package-lock.json') }}
-
- - name: Build packages and download e2e dependencies
- run: |
- node ./scripts/build-packages.js
- if [ "${{ steps.storage-cache.outputs.cache-hit }}" != "true" ]; then
- cd core
- npm ci
- cd ../extensions/vscode
- npm run e2e:ci:download
- fi
-
- - name: Upload e2e dependencies
- uses: actions/upload-artifact@v4
- with:
- name: vscode-e2e-dependencies
- path: extensions/vscode/e2e/storage
vscode-e2e-tests:
name: ${{ matrix.test_file || 'unknown' }} (${{ matrix.command }})
needs:
[
- vscode-download-e2e-dependencies,
vscode-get-test-file-matrix,
vscode-package-extension-linux,
]
@@ -395,7 +353,8 @@ jobs:
command: ["e2e:ci:run", "e2e:ci:run-yaml"]
steps:
- uses: actions/checkout@v4
- - uses: ./.github/actions/run-vscode-e2e-test
+ - name: Run VS Code E2E test
+ uses: ./.github/actions/run-vscode-e2e-test
with:
test_file: ${{ matrix.test_file }}
command: ${{ matrix.command }}
@@ -541,14 +500,12 @@ jobs:
- gui-checks
- binary-checks
- vscode-checks
- - test-packages
+ - packages-checks
- vscode-get-test-file-matrix
- vscode-package-extension-linux
- vscode-package-extension-macos
- - vscode-download-e2e-dependencies
- vscode-e2e-tests
- jetbrains-tests
- - config-yaml-checks
- build-packages
steps:
From c9ad52599b5b48c42ecd36e7f33c55afebca7789 Mon Sep 17 00:00:00 2001
From: Ting-Wai To <40179554+tingwai@users.noreply.github.com>
Date: Mon, 28 Jul 2025 16:56:49 -0700
Subject: [PATCH 106/244] docs: fix vscode marketplace broken links and readme
wording
---
README.md | 2 +-
extensions/intellij/README.md | 4 ++--
extensions/vscode/README.md | 14 +++++++-------
extensions/vscode/media/agent.gif | Bin 0 -> 3926119 bytes
extensions/vscode/media/autocomplete.gif | Bin 0 -> 5118629 bytes
extensions/vscode/media/chat.gif | Bin 0 -> 7124844 bytes
extensions/vscode/media/edit.gif | Bin 0 -> 3748198 bytes
7 files changed, 10 insertions(+), 10 deletions(-)
create mode 100644 extensions/vscode/media/agent.gif
create mode 100644 extensions/vscode/media/autocomplete.gif
create mode 100644 extensions/vscode/media/chat.gif
create mode 100644 extensions/vscode/media/edit.gif
diff --git a/README.md b/README.md
index 654f22d24..fcef59184 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ and [hub of models, rules, prompts, docs, and other building blocks](https://hub
-
+
diff --git a/extensions/intellij/README.md b/extensions/intellij/README.md
index 45a1f05f0..ae56a541c 100644
--- a/extensions/intellij/README.md
+++ b/extensions/intellij/README.md
@@ -4,7 +4,7 @@
-[**Continue**](https://docs.continue.dev) enables developers to create, share, and use custom AI code assistants with our open-source [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension) extension and [hub of models, rules, prompts, docs, and other building blocks](https://hub.continue.dev).
+[**Continue**](https://docs.continue.dev) enables developers to create, share, and use custom AI code assistants with our open-source [JetBrains extension](https://plugins.jetbrains.com/plugin/22707-continue-extension) and [hub of models, rules, prompts, docs, and other building blocks](https://hub.continue.dev).
@@ -38,6 +38,6 @@ Agent equips the Chat model with the tools needed to handle a wide range of codi
## License
-[Apache 2.0 © 2023-2024 Continue Dev, Inc.](./LICENSE)
+[Apache 2.0 © 2023-2025 Continue Dev, Inc.](./LICENSE)
diff --git a/extensions/vscode/README.md b/extensions/vscode/README.md
index a076fdabe..f655c4df2 100644
--- a/extensions/vscode/README.md
+++ b/extensions/vscode/README.md
@@ -8,7 +8,7 @@
-**[Continue](https://docs.continue.dev) enables to developers create, share, and use custom AI code assistants with our open-source [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) extension and [hub of models, rules, prompts, docs, and other building blocks](https://hub.continue.dev)**
+**[Continue](https://docs.continue.dev) enables developers to create, share, and use custom AI code assistants with our open-source [VS Code extension](https://marketplace.visualstudio.com/items?itemName=Continue.continue) and [hub of models, rules, prompts, docs, and other building blocks](https://hub.continue.dev)**
@@ -18,7 +18,7 @@
-
+
@@ -30,30 +30,30 @@
[Agent](https://continue.dev/docs/agent/how-to-use-it) enables you to make more substantial changes to your codebase
-
+
## Chat
[Chat](https://continue.dev/docs/chat/how-to-use-it) makes it easy to ask for help from an LLM without needing to leave
the IDE
-
+
## Autocomplete
[Autocomplete](https://continue.dev/docs/autocomplete/how-to-use-it) provides inline code suggestions as you type
-
+
## Edit
[Edit](https://continue.dev/docs/edit/how-to-use-it) is a convenient way to modify code without leaving your current
file
-
+
## License
-[Apache 2.0 © 2023-2024 Continue Dev, Inc.](./LICENSE)
+[Apache 2.0 © 2023-2025 Continue Dev, Inc.](./LICENSE)
diff --git a/extensions/vscode/media/agent.gif b/extensions/vscode/media/agent.gif
new file mode 100644
index 0000000000000000000000000000000000000000..7edf735a685ab8b7e232a707916c995a85663df9
GIT binary patch
literal 3926119
zcmV(!K;^$jNk%w1VN?Xr0{2z`ZE|)G6&frsH90;*6&4x=2n!Y)AQ&DYe1?qx0R~S|
zRSFCfn3eQDb7TOO2UO
zv9csGJSQJBV$INEi=myl#&5{hZ%lHWELSM9amvFYH12rVUKfSS)0#WtII-}mtCaLS*6J@cZD8xbToX9SfI}O-R$3B>pAUMDrlfwXPTmo7b~SZ$#%aSVnwL6)
zfuK{HS!i{;T)~Guogt2&B#M?Eg@mqLvYk)5p*roOL*%DE@ti)~eo~bzdx;Z-iW7sF
z5PXsqjiw!tvlNi69AI9?#l{b8at~u^(9qHkVPpX*hP;ZF@_u|^5e*p9$^7f39Drg8Z;Kk
zoJq5$&6}KZ;?&8rr%zHpg9;r=w5U;_NRujE%CxD|r=Orkl{&Sm)vH*kX5GrQtJkk!
z!-^eC7OSJOX3?HayLM{Zw^8B7g-dsCUAuSJ=Ix}nuiw9b1M?j$xG>?vh7&7Z%sA57
z$BrXIo=my&9Ltv*OWur`v**s5KZnjtTD0lYo9U=t&APSg*RWS7oK1V8?b{r2OU%u?
zqwkU^g9{&S(&EbFEnx)-va`AK=SQPUpH5w?_3PNPYe&1iyLay2)#CqUOJ02W^Lxo^
zM$EqP_|fa(%b!obzJ1j9@q^Z%zx00p`~~P)Yy`44gK7uTk>G)~HK^Nz5JpH*ZxmJt
z97^T{mm!A43CB`JEWttpbI_G&Vs$8{sA705w&>!E;Ke8-j5F3KV|(VI7vFpC^|#}X
zK;r1*kVF<~bUj7v`8NeTm#kEy4fl5}It*YU{0Y;;HMd
zeDaE&puO_xXt2a0I;gS3CadhS%r@)nq|iny?X;Jsmg#CwE(qnP+=l8cso?%5ZmPwR
z+v+o3{&gy
z!$BrlZDa&$+nNxvb*u5W;dWf=spX<7vbn0F6zi)Yu8Sra@V4x7ob$#kGt4ySYxB)G
zAFMNt2=DCk&pkDkdOgH^3#7{#lwZuwNoN0m>Be?Cx9Cz*U*C3M|
z^4KG@3TByOqAP21$F%##%QM#ucieK_uqi?95~WICq1~pg%fUg
z;!ZcdxZ_dhSLoCbqo!$-PG-!t*AIg2dDvoyzNOhCsjcqm%gt@~-K(?idh4*qE_=Ou
z*M0cyzT&QXu)FsTFyo5*4*BrJ6Z-h^#V3#a^2`@+>GRNAd+nyGZO(b;pJxxc=%J@=
zoY}0Je!6nU)I_4&s?V;zt?R$uRQvG9FTZy+_dEZ=_tS2_{3H-nh6&!Y+}nOejnta>l2w
z)TIwP{d*fRWJtp})o_Nj%AXE*$iw&b@P|N*;r{=INW>xx5&jVdhv^345RTfXt@GWk5e9$k_fXG!gE~2jUa(z8!IA5I)(R(T^9Uq6WHb1t|g@SwzBBx1BnpE>Ai;Sc;x0yt4dh?sz?4&ryxyf?cPn4iM
zCpy=u&UUi1l<$P6JL4%&Th{ZQ_?%}x?aBYoe){vDxNHw1DoDm%Ud@*d`lWB`II=nd
z!=Z6ZRWToGOmi`FnHR-qADOAH6|xN$ssYVv
zK@F-kPIVQb22to7$7;v2k^`c0bf{YGSjUOFm7)=i>s#jv*SgYmq8YuYUdhDK6~gMT
z=o*G#2Ro}p1X83T4Wvw7y4b}s7Kf0nVN4$zS;|V*sF%g8W+$st^=$OW_Ga
zwU!mm@NZ`e+^t%zVsyY5aV2CWwEbNNyo4WP(`qHa5NWjk1)dOyw%;*UDJFGJfBy<(VG%%UuSu
zn8QrwF-N$+Q8a3r*NkS(o>~9RZ)P)`~Tc7B#G-;&tYR9SHK>UkWKFmi
zLhchk*XYY#F1jh5Zl=Hc=}?b4yG7madf(f~JFfb^c^vTYc3rRohs6ro2JthTfn|x6
zb(1Y#af-9O?Qo|u#^+A=y1(7-c&EF4^?vuh&;0MUrn$`pPx!&hoZ*E}yy6Yd_{BH=
z@qmZCK?oP-dAruzG46R
z+H+m7UeCSli@bZ?llS+)PjV2J%r3OgI^l}&`+JkG{Ji76`Oc5N^rugK=vV*x*pI$U
z^B(yt^S%3OemMWj9gcGHo4@?%Kfn6Z&;Iqdf3xq8Km6ry`N`YA{`k-T=Jn5i%=iEQ
z0JwhwxKt7Jd9lGDL+3^ch;&O=T~g;_sTYC0H-QuAVzhT}{g!GK*b6)6d$sp<<3(6u
z=W1jS1SR-3A{A>Qr3Jof2;2CVCBMdJ;Hq
zQg?wA*m`T&hHm(J9>{xfC|+~e3myn|!DolCFmPcP1S@!aPNoP=mR>Sgh&5P)F_?&m
zXnskUgO30Bh>#eGk~oPwc!S$liAG3;nz)Ha$cdgve}SNcpGb0{2#TaQilvx}swj$@
z$c3)>im(`qvZ#1%AZN8$X!LYJW%L?im?6GMdSz&asi%g+_=d)Kj1*Xh%D9Ync!$lH
zhtIf&dw2|jh;Y`pf@NoMYX@b7xQNX6jck{E;&^xCSdQj+j*Xa(;<%3NNQv&qi0>GW
z@;Hz5SdZ1Wim2Fx`Dlvx*pI9zg#a0lqBx5LSqg@=#`QPcufRe)gFLB8~8rB@EB
zSCOZehP%gx8L5%T*pbZmkR2$dfu5ltMX_L|K$Zsg6gPluEgjNZFM3_>}Y50}v;bP6?H#c$N8x
ziu;(AcrcKy*p>eHk6|g6WXX?ZX_f-{a{ai9?8laE`Ic@OmvA|kbXk|Kc#CU>m$~SW
zU>K1YQFId-j2C%^9$A=%36gY}m?pWHjM-m9S|HvRRe0X`8rto3)vny4jnzIhMZp
zo5Bg4YZ;uwS(e9{oU>V+%(GUoYEPc&{>_7p{qo2OZuyV;dCnuIy(a65{ljM$^TNu$OYqeLpCMS7%2+MPZZ&Jr_H*o&Kj-qS*Q9b
ztx|!@~srFi_
z_nNQzy083-ul_2cp$f198?XdBu%+6S2fLyQo3O9SunzmM4I8l#E3p(iu@-x=r;4!!
zTd^A3u^fA_JrJrP>!~DLvL<`7D4Vh#o3Sg~vMLLfFB`ME3bQmjvo`;Gvp9>Ty}Fmj
zV}PGBtU$XF=5}s`X|33LwApH{;7W%}%dJkEwEZcrQahki%b(;*wSbDCT03y*sFpw{}an_nNnQ%eNQnw|zUZ
zr7E~{>#~M>xQLs#A6v01>!FG(vyKb7k~_JS>#~)5xtN=|n!CB2+qs^5vV@BVq5HXA
zX|g%XtBJ?6o|j9)N~~g9tQT3P7zwSkYqU#Sr}hc1y8E=@y1Tr4wOAXxz&pIcd$m=&
zwaA;2E8vF>I<{n6qHdeE(c6=4TdCEHw|$Gf{Cc<93%K3;z25&DzThjq<6FLHK)Bi)
zq8n?zk-NU+`@J3;vvw=L^IN}-OS%qAzxcbqhr7T2`@aBOx-~1n0X)Dmi>sCAPhPq;
z=lQx0te&zPb#aQcwo9$J>#W6)t-1TVzRST+OSK?Oyu~ZR#GAY(e4t&cyu7dim-()O
z_`L0^p)ahqG<>}^Jfb$7!#2#lJj}j6{KGvQ#6mp8L=415{J!do#7b<$Ox(mv?8NTd
zzEEtxQtZR`Tg6nI#VM=BT-?P4{Ka4##$r6i|I4I~r@9N=x)1z|lZIlmTfuPLrWvfk
zb4;Ige8+Z-$9lXAd)&uChThLO176d!|iIe
zZL7mKjLDh2$v51|J3Pgpe8i$0%A-um>07DjYsyc&%Bt+euKdcd?8=0j%4I;yv3$$8
zEX#8{x+B}mpu5Yz+y%aDvb-G3!(7Y6oXodoT3#(`O;Z;FN-Nx>Mr&UxI)=Ape4vOd&+|OTCOpXXY|o0k&-E+|
zj_l6>?a1l+&jFp1j{MJEdknmA1}r?ul^nwl4bhg&$z@y7gJ97YozWV-(HPCq9^KI&
z9nv5@(jr~bBz@8*ozfkR(k!jgE{)Q9`^lv|(=`8G(>8t6Ld*hptJ6Hp)1#crKy9}^
z4a`EF#Y276L7mh}z0^$I)J}cHQ2o?W{khS+%+p-WQkl(!$B0}y+{S&}uT9#@ecH_3
z+{o?R(EZ%fo!fbR0o>3ChA;(FumlQRP__Rs)?)qL;Vq_R9l^1%3;dAY>b>6mklyXx
z-uwXH@a^8~UElT{-}L?7_^sdX-QWC;-vA!q^F83|P2lu>-~wLY3Xb3g&fonV-w)mo
z5&qv4&fowp;TL}2@(tk?uHPB{;TzuJ`~BhfUE(Hw;wYZtD!$?@-r_F);xHcLGJfJ4
zPU7`l<2ZicIiBGjF5)9T;uQ|$Ki=a)9^yrQFohpf6*Uj
zoL=dk-sy)P>Yy&_pHAwfe(I*4>Z7jetiI~5-s-Ua>arf|v_9*$j_SCc>$<+{yx!}z
ze(Sy-?7}|m#9r*ie(cB&?8(0D%HHgtE(3Kga-guKt4ko_t><|@rW84t;vfiyUg*E>
z?BYJ|@A|&){NC^A{_g-E@aP`x
z_G9N?Z7F$v?R&26ZF~-BI_Ul$@d7{b6kqWYfAJWf@fyGJ9N+OC|M4In@*+R-7GLrv
zFX`Ki#t5JA3$N{G{qpAk?xz1P^Y>2jCx7!eZ}U38^E}`4KL7JTAM`>$^f_Pj!=Cc&
zgy+~!-YyUGzYq*HPxMAV^-@puR)6(apY>Y5^<3ZeUjOxAANIJO2uNUZvh*J;-}2+O
zp2467Vqf)d5BG6D_jF(Pc7OMHpZ9vd_gLQsN+4}#|EsP6-fFK9W7X#}*7kfa_lw{7
zj*sg!59*OW`I1lhm4Eq`pZQS_?3$1Hp1=8wkMEto=%b(Rr4Rb3pZcor>r7DgvK9C%
zukhj>w1;1&5gZKtVELi{_`KiyUQg)z5d6YF{KQ}U#((_CpZvre(X*3H}ZZ{WR!4<}ySxWL25l`r3$9O1rr9#jbU65)#g3?WMJ
zqb-wXW$>7TYR*ijGiaty(Tg5^RqHISvrw1qH(_n9V%+fBymma6scABk({0
z6I8Ia1$*mGFy|VSkfsP(;s=fi?n_`p4o8rHgZ{$er-$$?6Ymfd$=hrWr5$fHjI2FSyMO>E6WgH0v%^;cjEiZobaAw&rzWRq2vQG$jo*02YWtdhZJGfHxw
z2lB&o+YK)eG9fWP1vON2T2wQttk6C6994Z`^}!PGRN=bD;;}a#S2ajMfDsU=_FsUN
zbT(ju#ai}YgcTLG;J>0RbXsZ|ZuF#hB;fYq5lpDCQ%}WB@ndp7ThCO}+D&y;hp(U~
z4+1V2APioG3<=xnEES;FhJySyWwnAlY}2o}8~7ugcSgu)o+VZqxw3{H$myk{Oc=6c
z1)2X6>Zq@!k|dpz)~9QYf{eJ>jXAjVVlGtx6rpfE9(P4i(>s@BHrag>WoEB1A=V3O
zjYlW$L}0n^J%<&+H4S9LIwJ;R(^p9D9zdD_oXI*oaR!oXZ1Jecp7Y+dYoiD0&Vf~y
zJE8YUJ$0>1Z*ry*N~rSM=sfUXyPO^fA#oADa&Di;^bx@X*C$Sh9{bSd_6ylLB@qwk
zJ9Zo7PT($gWV*95+2nUyD#0~A2B0Qd2Ewqly1&uFmIHhBeT*LXXQl^Vkot+gF5T%7
z;ZOJz#uW81i+i0K2!(42aXPb#Y0q*^k@IT
znXyiUAw(7fImbZ(A&VbXs6s!gAT$=ba9I!wScM+o0fvZ8B*1%}MfiaL4?JKKaG;z_
zQlJ6H=&pYBqhS2#;QC#^$>2(+cVZQ&4HQ|LnU%s4$zP_KGP
z8Cj{?Go!n;t9u0z0d+K>0n%BpJ_Uf)k3z=~24oHl@d&~Ecr-c@^r#<%Yz^r$qC{7f
zzyrJsfn$2K9Vp)Ljtt<(YC@m@;=S&BLhHu^?8SiSAdZs=C_yP*(@F%~Q3Sf{zynT*
zLLzxEiYiph-+-r>+1P7z^Ao}7dbvwncF=07lR*h&u*-c^;h6fsw!}$~
z4kWUeCAfe}1?~IK#vP#ZXXSprR3s~xek;de}trm1c@54eVD*j9pGdl
zJK&g{!cPU!>8btlV1mT;LvW1w07;YSxszxWpvBbcFb5dLR{oMZ!3-vtzDg)%RiOj`
z1xXbi(7PE{L!yH1JmCMXd4L})>7jw%
z1+gD_XeECbV9PAw^Z}B@qm}y6%1)*)Ar&ghyzsDsorw$n)KL*gd
z?}^|7ste?0!6Za}e5q1D<-mKNIsgp_Rgk7-42g-Gkk-03Z3_Qgf*H?PTNRB;$`Xy^
zZh4E*hs0}7oHbq@^%RD0V#J&9djREv+>h!y7tM=lOi-PsyOEqTcr7)7DTf!yKmyNO
zn>4aqzNf)X?yi`(S|oQz`&oOb;BXU+hXPIs;s?Xk#D7bSK%sl-DC%#V3SO&t!Jt(u
zR&8vN)=jbo2;CQ2t%dxML0+F@O=TiEn*zS+b)SZl%koMwcO`EAF2sRKQLfCZ`E-q;
z$d4QL;{uOCVs+8XAAS9_&q}hNt?BqhC2vRru_fbdpA6+Sa%Rd?NtbRZdeM|sR|6OL
z!i)iFE~34`0(Jc?v~+
zI@GZ)Z&n<+q!V((*$KG17l^ha!Em7qe1O-{xxgj{r~%b2CeXvn+@CH4KZ^f*6T6GJ
zq$*UgY;%YJ517ehy#4KmhT9R?quaTATMR5aBp!Ce(*&1Qf|qrmI*ujUg-IB~)fv5E
zI*$zSg6!PEG;npwreDsdc0~=>{5VeQ4$lg2ZOLCLVUJf>vwA+LjoG{8y>#zMuIPBj
zUtaZpAK~XqtvNiXc88`tZn(`YjjaFt_TRoFOCyMtABzTE>BtHNPYSsV#tygOTY`fM2qTeA48d?XmgL{qR
zmZ;m`9(RWz??(ayzX1A?30=aY(NJz
zKTc5q*}E9po0BH!0{Bw|+{-=82sgGfw<^0op1BY_S+_6H5aQbv0{9X20xR;nKoqh-
z926J`oEi!IJ{>Hn2?Q`GnY(P`CMFxf_zMr)svh1e8SR0Sx7!6O#6R$Ju`tL3-C4Ig
z$`Md%4EEbWF&slO3@~QdxiJjFl2F41gcAP+;ukRb0wj#B+fzakEI}uH!qTw6VxU4Q
zq=YFc0e-0tLKJ`y5CDx~!!le%Mr=e!ybDDcEsRcq&7wf*1h7
zPn5q-5JlhPLq7yWlW?F10vlY6MjjkBY5W&k^tuXkMH~z?42YGiiWGiuKldv}a6?AB
z`8`wgLs?)(YOF?gOcYvdM|qq_daOr#yhnVbhdo4iS!%t@WxNuKOUpZv+56iEmJN*^pKqC85ZOiHE9Ns!D4
zgsg)>2tky@!-ix@D&z%rY)YBjO0E=2ul&lc6vC#N6S5pjvy2wBEX%Y!OSR0tl8nle
zoJ!lGGOJX_m#oOJ%uBu8OTO&Oy+BApfXcZ1L{RCyb%~=X+y$4!O1$(-$9zo4j7-Vw
zCKd?HguG0-91o(fiu!X%yL3sI1k1@BP0}n))BGyH#LU55LaNN3x>U@o%u201P1>wY
z+q}*1drQld%FHwh&NR$Dl*0eSyvjdpOx!$9pK
z?95KhTRraVPVf9q@C;A!98dBrPxCxa^h{6kG=xIfP2MC&%=k^1;{Zw9bi`P0@T&7>!XGolzRCQ5(Hc9JL9M;IR%E03U?_
z{tHqe9a17KQX@T5Bu!E!T~a1(QYU>642?NdMf(>x`BJ0MXl
z-BK<+QIctwFP*|*2vc5oR0TX!Nu5+mwTTkAL_p0{P2E&Z?Nm?wR8YlJK_yh@e9p}T
zPOE5_6m?Wy_y8BJR9KBwzx<(>DS%MDRb0(gUENh)ty2paR4gq~Lj}c;X}fcTk14Fr
zM}5>WB~w{_R%m6!U1ZZi~Q!TgLQq=$HEZ1da%vUv7j_ugYON?3_fj4znk}X-2{Zxo`&r&^9pwQR(lul%Q
z$g9j)jdfO!y;+=H8dn+FlkHib{aHOt*+GcdVI|f_px9AV)ntXuj2+mVeOjp9MkDl9
zpsiY~Jz1f>*Kf^NimirJ6<07NS20D`s4ZKwg_IxSSvS2}wr$&o1y-V6S=yQ&q>VzQ
zwWyYC)POzLjXhhx{oCtnG&t23wRKy=J=|SQS<94Id_`0!?AN7b)ta?gz^z=%O(8)H
zRK(p}&h=Eq)moMxACEGQO)JCyDaP%5;^1I88-5k`1Y`N3I_1wjZ~i!hX3
z?=?dXXj8&nTiq>R^9@?K4OZX%-Fy|@x+UG?qui#mv`q81HxiDxvngSdMu<07;
z$h7SkA@NcnpE^L=4l&05e6-Qa~n;x$D_Jzl4s76;Y`4AvjU0G_#8IH~I-
zsY@BfsF2f=I{k@Qi4S^SzWcPf`kT{IjL4zl0cwo28e@S%rS2_ZK;BL*(U9BaRXjOlL?(bQ
zNaRH>WEg(rJ^kF?mD@vg*`yuU(&YsTK-Zs&ohd%8wOT3Q87q1yuq0OCI3@@JY9*9Y
zo$as}A!e{v*0gb&AG<3iI}Wd|E4B#fq)rnc`$0LyxB}>y;G^4sCMG5WDm|_G9}KdZ
zU9uksw&TZ$<_SV(;W;ZIPAbPht>y{j5e{c@9%pjai-6L*g>5&~%HN_<9YTTtNRDTE
zO<(n$Vb)Be$7M-nrP&=eX9oJ9M4aGT4je0%IVG-M;cHM}vYIDmxaM(;Sxz5Z#;gAW
z!)1`@-t0w7U*@?3gJ>##;BFQYWS*=3d0_ilD=Tu~Q$rTPIyKa3&;%2N(@H7^s~}L`
zfCJOua^7j4?rER?X`l{jp>~OLT3Ah_;5b`7Ar4u2ZfZTHXJJjq#%SB9=!28m3YjSEpAvtn!K9cs(IY|PGV&ED+Sv!H#j
z6nPDUKe@T??4&$#YSi{ssJ7=yu4=2UDB>(#3@}a#5(#y>-j%Z=4RYWj3q$`MTCGz4
zFbx_fkZ9=qlcKo*Vq+TO*{C)k?%!ROV}Kf_#XvAGu7aqm?(D{H9mVa4C}s}(um|pK
zL7?aYCT<|c?u_Pa_HJ+YesB1W?=`fbN^xXfg#gtePj-7(`@Yo`PVM`E>Pco_kE!a4
zirI(EWaRZ}@RY~yRG<0T>W@^b`gT*CquC3UwUDfzq);;K32CTLm^>82$av>jbB4=>VuJ52FP|c4#!E-0~Q^K9W7Z+J8XWS8N-+X>;rp@t3-DDp3ax!mpM}Krk
z@1Y|{=SXIAZ+w7VX>(Bxft?voIoFVOvz-rk!CP&BOZmPc0BYs)9Qkt+2y{=B
z>ZwMNb-7{cM0Bi_a7K@GU;lMr5B3r(bI^`tJ~`wD$dUgO@eb&8@iYO85!u!NQWwPY
zJbwW^`2co1WNfeV3TWg-rt>nhj}LhPB|mMEdOq0|78DRqs?iXW=A|bvdwuJ_y#h?aeH|*sRv^MelWCk9hxypLq9H6cqdSRfhm=
z`KVuvy-IiX@N9PvId+kql?KR<9-V+YnvT!n12*`m0YvpKgn9eWmI?T*56DDT$Mfv?
zB$3*k51UvT+}d8z$OnRM0^neA#kkA#ERu*_AI4+`mV5T>sAch
zxN_&xt!wu#-n@F>^6l&QFW|sn1`{r9STN$miWmPgZtVCm6;86Iu>wuuR05==<>rGknO15^traUqY23lD}*
z%)-pJj*8x#DL&~^gIc$ckiB@ngHn?
zJUIUXQH2Qu@S%Z!9BB|wNdtu80R|8}w_9uxN+=Uf3Qj1~9dZyg)KGOCrBqW-1tJwy
zRAIGMR$F-mR#;(;bry`g>>(Oxd)atnjXCPLBac1$_#==(3OOW^MH+ddAh+#P8iW@v
zs2~9&1ecl$FHKk-KT2w8n+Ywk#=vV2N#Os11{!qtfCigDkcUKJJg|ud9^_ZvloNEI
zos8cQLN`5bo;fyqEd
z4-)qPAAnqVs)ReCN#TerUY8{CqvBMgBEV9We
zyDYQKI{R#~#3p$gKd_yOlSdG>W}tl6c97+k;pPS*PRMyFzyJaWfD^jmVYluV17NUc
zOFQkEz`Y8=OKungl*6+Wp%^QZn5dXWIx)M)t(!KygAVHI>
zdi*hl8g2-yth0t#tF4C|f@_K^_UixZuQJkjShO|U3@y$%>%241J^TDK(0xs-4{1x9
zwyFRhbkKo!4wQ!~mf?!)Wf(3I(4@TzsoJrs3%mqy0oQu1HH9&OT{cWne*GugX{X(>
zm0g28H^{AyOtQ%*r)=Vhx~lkcFfhj)Y|w?%d^qBXE5116jXVB0oqPT{=%E9tBtJ}gyeH~aL;V4`QY$$g$Z$hVH|=fLemm}Lry=s)vF1%{$}IDm
z>&w2D72}MCi@rSb%{%`*^wCQ{J@wUFe?9iuCq{a;vgaOKb+ozux|de=gmz8dqi=qy
z=UV2X)}bKJcB7Um{fB2uqm36t3`g6yx2iWK}Y~p^Sf^SQ)N#
zRlKkSE`YyEUXeT~#32%~h(>+789w+MKZFHj(j8}BPq#AQnHeb^h_7k;>8f=@iZ&xhb9k6I)S*Plcqc+Dr@(`
z-gyXre*B~GbhyJpB2WK;JF+A$bE(T+^0Jq{{3S4hDM`*`(u>_o+TY${`8U7`4lM)}WsiiZ&ULc0o$h=mJmV=(TUMr+
zq$wRIvH7QkNuUD1@#jDJSxS8pw4j|_W;3hV&2qMqgB596@tD}rlD3*vTWmKQ>)40>Pok2I*#LQg
z0d#V)v$nl0ZgZpF;;c~aT^E+*EQ~T89Dp#(vDBf#hwg*|{Rj;nAAbhPW-}%y)otPnOVZE#0{mO5#
zELClJAIsdy-u1aQz3E>(sJtN7x4{m6FeN$X+a(cIwEVp=hI``QLM#-n!3!j7A)DTq
z$@ahqMx6iD7JT9p6OkYEphrBKxg~UFms$|Mac99*I#6z@jHB^!C>2@8X9k&jHO_94
ziwxxVYVOEc!e@q~EaeEH_P-vsp?L=^Km)rsTr2)En8O?`A-cF9W`41c%WP&P`xuly
zt__ak?A0?j)677o^PPk2Og7Wlw@bdPP+v?BP0AR}t$T4Ovt;Nc(ODmAR@~sg~G#O)?*WHe$
zqJRHAL`pxqT9`ifr2`h;qj(y?x00)tNi4JIPTJM>zBgUeA_9Vdii4@n_xNg^Y;Q-K
zXhcr7u?3FsaASMT!G8Ew_Z*LK+a}@8CODeiyyr#R+0C=&b)y3v=|%gN+d5W@$7>DE
zYO5UNLk;=3$!$zaqr2w&1urW*{Ara{g|)49EiJG5Z%i^7-$uXp8PVi{r7xWU6UU1O
z&m7};OkI3nV6>fEUT2ik8k7U4FrXnWc8xMy;}t(MqkWz1t0$Y*1W!B0AH8j>b9>Me
z_qJ_RUU0k@n(NYr`^x7Ic9q8*b51U-g>A0*!&dpNJLfsP<9$`LK$qx6KRV{ae8&H!
zhr|P&U%Cju1@M4-z3W3hxxWQYn$nm4$YXzfN2g8rK+pW`T(5P*mA!CXXM0))=R2|q
zedvb6*zDWx_VN7=c3$_{#FaZdlov1k(h@i4j(_}e(c9d!6xb{^bv|V-pZW2#xCBgh
zhzLZmk&rw<1oVu$i^IM5U*o#|Zuh#k#SQ!YV|4bj-*%$eU)E{dGtJuXUE8s_oWa!}
z-vyw_5t_-}9|SU6+Lc+^>7V#LpRM6j;!R&tbs!1ZjtOBC&LvbgjTd>{5Fm-#&v6A=
zIM;Kb8u&>@;gO#Wju}009s@9w2*g+kJb>ptfYrSPnPpt0{aBmnngu@F5%T|^6ZT)n
z?VZ7GVD3HH#(^6Ef}Dd|xZmiR(Tl}c
z^M&0LW};91A3R;6>oF4L;8$pQ7aWG5etAzRqR$B8q5PB}E4dq}MP5u94~eP3&<$b+
z8lo=VMLz&x`|(3Olz=0~*yb5TmQ11<{h1~%BQthYtl<|2a+mtRAuFO4D&AomrQ$VJ
zp9$_^3PN6p%~gwRAB@~pYzZPR=Hf1{V_eX~o3vm01)~q9-L8%bmQP~#h+lq>Sl^?l3CJ7y#pOp^w*-$s;x
znQg?r0iiu2qduM_O7ayy9v-9VN!XlHHHr-#*3r$;BsQXrHda&PCFD1%K{ZsvIONKx
z1r86*l#Ixr<$a=-s2G^_0|IzJ`<1{Zz~h?;<2&ACN@k^2_S8y3Uo<+&2tY~LRKRNB
z}3=B3_O-#Pcy1W2D4%Y}sK*flb+_;S%y3*tEoErF~
zPi6%~Mx;@4Sx_nEZNOI{_F_mlVhTiMLj)rS7z9>srDuMoMs@$CSGwUHih!Ufga?=e
z*1RN6sHRMmfN7k~$3Vc+e86@k2OZsI+6aJ0D2;`9ji#|rl%x^VR7VKdrhMR$Y|i9w
z!ljc8KnDzn0@MpmvW6WFX1f)p${c1j9Hvjk!Z-zvSG?BobYF>CBu-(ZMrLHvK_%6V
z#J<58RBi$Xp%`f1Cw{_{XzE#6t;!d;SObJ*vgKvE*ri`?(7%vnKYc+w5J&_J0LOsL
zaHtD|;KbGV)06~^ZUn&9z>9>chJQFH#HeM5lIR3%=;?ex2&AP72+9GxC{CQHfdZ6X
z&ZutS1bUH}Kg359xu!JH0|>ZPHmM4*%h
zZ^lV^Xo^SNWu~$R0stwQB+XN*K%+h-(?x0oI6$P533LKsgG8#Ij18)^=u*Av(iv)t
z#z_YN=|jNHLAq6TYNvM|W-KVH8pJ{@{6a7grL^)wU73Y>o@Y8r+EOwlnC*iIph-tQ
z05zBZNj|^>#KYpKsk*M~E~P73-5zPKQ9PV02gLuw4syqH@WBRPKnZ|H9>fEriaJ@{$BC9Ir1B=ya6khLzU-9PRa{R004081I!D>IzV$?taH*Kqz)7TOel~h2Z+iE1U!K1
z(BWVdqx!xkXrmfm~
zmVM4xx5X=JfY5=UiAgX3HM~Fv2!wIu2R$&vw{F6CG^hX=1S!p?a7gS62yLZYz~M5D
za5SoK@+{OaY`h4EZT1s`I86i;sR3ZX2c-Y($4CIBA`Hzc2naYp!zusn~g}4X2Y)o(zX^DqoT_+Ap6iQ-o}Nj#|P1LTKEYyxZ+1e*wi5K0HYcI2OG
zfO=E}LSXF0gh1*lz~UY8IiwUYF+En;HF%&1#_)3};!mUjVYt;;Znk0?;
zqQIjZM5(H17n?v@nh7->a0B230TV!SOveE{uopW(2Y>*FI;sKV>V??J(uifE-buiC
zF2|w(bn5I~vT?*HgsMi#AY)7#OMsqOfC41Van7+K6EJWvjREj1D_%`-e1L^OEF+@;
z0qBW;q;c6S?XfB(4j*RJDl0AgFf2Q7DnzS!n&Z4tZ}nPl5@YWSMzJsd@)S++XzC_~
z(96OgjD;q%fg-bRUJZvjGc-rD0Z_r
z`n9x6zqCu6>0SWizQMFjGgCkpG>%n)K`*pVv#l`mr;B0GL`xY#)=}c6vns`BwO+*<>DpvrVE+Yf@|%!m@vbfGN`5kLHZ5YT`ORKX7ffe;7*Pj}H*
z|Fw3LSzj-AV3)6B$EA3CU}MXq2+d>%mUjrIVzC;R$<$C($uoD>a}eA!W@B|$M=L9Q
zw$>i;XxAI7?L(z>Gmoaxa0bi+JWdH5vR#U@)&D{OXWgLYSs*?+6_iS@e=CmKs4;UPT}7@Uy`boh@6feZlIbSoo{S2}m=c#e~yoBFsuL3Ap4ItfL#@pg37
zc0*O;b4X`3XYcoChj#d7`L^2If`55~qd99x;$8?iGdp;#L-Pcf09{KBJzM|-+!II!
z`oxIqP+3%wNyGZ~?Nsh){N4oFv^j-geja$0EI~k_$xL|`ir>_c;7x`JmB$3Mw
zDvvs1PIV7gwZv<-R%`WVTX{+kw5#!h2cx;idwIR@g=&6$H~+?5v-x|8K%*lWpwGFq
zn=u6R!*gT_z>+(IIK&5x05d7gMx3}PnE-qYdd2ztXmG&ilKYZKtVIZ6pTK4w^q`%X
z--&ZPvES^u@^5PT)^ppnbVGXSJa@nU`@aW#rem8MrZ$?RecJ1&+ONHV5@(nzHqaiH
za!z!6E4e}@YZi28WlOyChO}k}!<2KjXS+HL!g{Q?8a+S>$+x`#usB{YiI?*_JA(kO
z+nWcSuZDmBPz5A=o+7{t%qs*a8i1&LxW|LeFF2?Oga-K7x3=hzNkpA5iD}A9j1@=e
zJjCly9G#j#JY0L}94$Xozyk=QN67rs6GkX)JwH@84bT8zR{<4Jy4Y7gz-zp~3$>e8
z$i{Ym_uJ<8hrjrbKly_{_;-0pDK$E)KS8no`Ww~7ih4ZDH{VPAWk-2Q&obe+dQJlb
z7=ii*64bZPAVP%+85$Jx5Mo4$6DdygFd+&K7(p9lzC2{v80uU|Z=^dNYM2NdDc5)V|++ZS&D1HADF4tUTn%!jOhOAO%Kuu70B
zg81nevRF_RAvDg`ym=XOX3d*9clP`lbZF6|NtZT#8g**bt3y|IZ4qN7;zhS
zfiM~v^!8nXns4DHgbxp1oB?p;y_Fj;L0rN|>C-z_w|*UacJ0)q8`%CGe0cHLxsR`&
zd%^9DcjS!fLkK?nGKA)r>2e=GojY(@OimI?EE8~ZTAEa7Lp~M&!
z1X9){os`l_Exi=eOf}t<(z8Yk(Z_|r0_%b>(5q2^R8{>#)m8;y)zwsCjg{6~Rej;r
zSEcG+lWJeFE#t-V&-Y_;9?1Qdill|4J&
zi;uo?>&uTn|I`hTz%0~Au)zdlc`%j;?VT_c3WM-jc>H`lvAj&5Q;$f2m22>Crs1H7PfRen<#K7Z|Md*jF
z2a2+bps@V>ILs10KuasKx>DI@onH2!&Zr*vV5yu;h$oN3@?d};x?*-S4-GI*h#whf
zsA9H#_^ILtAwK04?X=Zio9(vUe*31gF9S7h*+@0@RNU~!+tvSU
zHT-#Cfo-q7Zn-uBSbk
z+nnb<7dp`u=w0qIU4!NoA=ZrpUlZEbzBII<-Qf<1xf9w2nHQ6OC~RRI2?+@3al4A_
zqXQ^uR(DYL!y-zgHDIZr*usXtA&L!uT>Iidy12!gXi|Gu+c*n7o?FU~8B`tZ`OJDvH
zm_n?jC)F6nyB!jl$yDYtnMt`ss<4rcd?X|hBuUlPt6o8%h3j;f3Vy||lR*?G-89HY
zSxV$hr=*Swi1(p>q=;Cqv=J4XcutB06QB9i=RWz_PqvkDm>9%hIcWpPWg1R#2yNy<
z8QM_D5g>E%VI=1$D$Qv|G7Ir?&^W50O>AaTlNajYzs5PvTJExT%o|fH)d{6`$^>Gq
zoT9}TAWB*K6Q?=V=}vj7(>YL3Jl<&R_(yzP8}122_{@my)0SDLB=T(M_FdK#&^-W9KT)$67J
ziqe4+v^Gf<>|hDYP^LEZTo!#HfjS|>(itdqG`!|VC6upC_KXwc9ZZ+gsoMmU1M(jc}i-$Q80c
zv5W0QV@W5;jbihLID}Azyva$fYWAy~H6~E)88OwG^{gX#mpbtT?l#`v^wbYI`Mz870JYv!;5pa%&ihGlD;5)s
zFD@Lgc6~YG8vWr(Z>B~nfO4WMHR6>6FfYiMo9kR4i`&u_
ziX9I#E%MmLR`F;*Si)$2>?|V$0Z6QtNBaGts$~T4!)7|nUma#8zfVnB#MzkD5_sD9
zl{VS;iQ!pO{qr3rGuI#B_E|%I&Cp|r;OCV2>!$wkN1q?=&zbts&wa#0(B~{}@dk-%
zqx@|*Zrz^cNSXCLGZ
zJVHV#$|4UwEcrCzPaftiknhU>Ff4g)E~Q}VGo-{}USs;aua=N(jBs!@T!j4!;tBgG3L7FUhR9IBz}8#?{nBk9yy9%qLR4I&C&KV1
z`e6wH@BZQ||2m|P{3zkBWw-`V4wLE0h{6D~B1M$S;r7sRn5ycY3JLBbUH(J49HI3R
ztdc$|$Sh0jFwpi!E{t@KM^X*cL`?%^Bj04|yTSki>dE+`NIY7r`8H-`ny@F``oj;uiIB6>-KL5n>h9Z)DJKA#oA?cCja}
zzzoAN`}~m|vC;n0kgwK|3jxdVhHef+k`9eUTTWmCI^Yharzj>s4>PayP>;YIFp{<|
z(!Q=<7>p4s#2YTe+-mO;PpXR~@nIf-eE9depzXBfrzrud@(kry`EDaMdlhGg+a%AZ8F6{CwA+t#0k1i*2F~K4gt?@2X
z(H#F09hGidE8Ds=B~8xlh@#mBSOH{jL5@Q
z%>_F#17)x?CK3#Vka`YtHsp~nT2o5Q#2yXBHq(MZ&yF}n#ZX#v9}E*A@A53IM`$qA
zd#aE@kyAJSg-}8H0xebXLhT1b!4Q62)O(`Qdp@)IhM}NGAeMhdr$-LUQs#AnZWPj9j0VXQ?w9Gac{ZK>_nYLlhsSBusboAWV};abh8%&qyis9#OP0(c%ibB1%qFE`yPO
za#Jh+-IQ6WH7sW{M2nRA`Vm6$ktyu*eToE0?9y6|RWJF%CrGp%;dJ`c^n1coOs=s=
z-SHZybt}ViW^zv>h$;G1~_*y-#6*aY~)lSG}TOX~P7d
zRWR`=bA97^g&s`-JE0579$aN{?a%(!5
z9Xl5P@H9`2N$nJH1R`LNIFWm7MgsC6iXKM-n1rYV-~o^ZBSruNG$4A_V`n(vRTc+u
z5Q?>;?ze1KJOfn%1VaP1*8nd-0uprr{jdQAQD_U1bhZu=FV#I?C!~nXCubEBNlqwd
z!fRK}5^s(ls@FeRiizm%foF<}me7FjsWakFHpEh17nXx(aadLJE08fLL>Dvv)v_z>
zGB2gV`wp`-|5hMB6bE0FV4IUNiIYlQ6B!FPTdfCwY?S`IHDY@+O(D~JAQOnu(JnAF
zAYXGAyW(B3^eeY=T3uL6Y&V6O^K&`#gm<$`XE-)>7-9`~E{W4&v`=3FmtM`VG~F*>
zrFc%e5e&i5M|l-VOxJji7kN8UsNT?d1xWxHKm#CPYO+S&zTgF{?01@O07i8L6b3gq
zpibz*Wd~pYHh}@ugL~k_C}4%(e#i65*J8?d0C=we2+({%5@+x5P|^4F%F{gUV+lG3
zQumjC)$_S-5~Mb(FC8$z*jPSV^^16<7wjDk(xK!-H%8Gx&+x@GQ!x
zE&HlORaYC^GG|oxeMV)A$ReB16bpq$i^$mszxkTOMvFyw@X!!}xngb+Qk=WO3BO3p
z0E&(1S(lQteRPyrw>g{XnIg#u`i_toaSQOok9z)&jOuxAyF#8L8jaGKix3(dADW+|
z*i84BkNX(tf^Kt0X|>?bbBsX
z1OYx^YBWG^+9WCX22T9XVmv?uOh$W4kdWIX4?f!Z5$e>c2OVq>KOr+2Lp~bK~=Ifg|ZLWzW$VX2ZvQu
zyL=xfFqp(;J-d)|7D|kwsq;Vta0F^hU}$a{9Vv#n9LtqX41tQYGL*KVhRH{Ab>8u
zATI)C^m5w-?%Tq>_eq9C0P>BrA>gYEYt74ES})R&y_bi~n;fy(=ez@_%)72kuOpcOo>>e~b)LAL1@R8QH4v4*t72T%
z=EkbrlV0i5Fu|>vq)A=@l^a~-XSchPkW*SvD*yr%=68A=BVGVkG9p)gXX|aYls!T^
znwwReP5=f}>@z}?KSBT&Ig+>is=Yey8(eGuv0ACR69T}V#0!~ycU-KGE4zpNv8d{r
zFqNA;jwhQo<~dNyd1R;<7?tp(tNt2VK7!gm1TFGV+6@%km!9-XAK>CVpekEWg5?U(2hP~rAwzjohngg?hOZ>hRd-Y(v%S)cFqrqoY%
zHzIsx3!jn5+H;uv;?Ual*pt$FS@tlEyvtkipPeG&VJVr?13aJLiC#J$dCEAT=gTVo
zvn0PY*!1ro|GTW|o&Mke!aqsD>*H+tOI
zF~P@?Bukn+*>PdQgclgZW1xUR2?j9#Q*yL-X+HL4ynPD=av%Vlj*xJAV9_Uqu204pK((lXB*rA|MCOD`LV=%at_`JpDz(
zUC*9HK-di1^yv`&SljlzIJfTIynFlp4LrE;;lzs@KaM=P^5x8%JAV#6y7cM#1|K$z
zSUL86{P($(f7Q5p|vmBz{&HjS+qUuB6aT
z8UPr91_H=e&>e>Kfz%*MHN{l_7d==g)l^eql~sq1bOoYUV~uqdiD{|j7F?{vMOR&`
z0d^aVfho3KcDluAn+O;nC>v=9(S{>q{HTD?X$SeZ*#NZ#sgGor$!1z4qF?wN;2BmNnv9C!&~QFe|P|mt8Vi
zIU|i|o_Qmyjp_5i7qLOPnF%k(xKFK{oq$>ZnqekD34<|Nf~}@mcBHaDA+W2gWKK(M
zwbovXZMNEOi{*8&CbwPxci$V1QqIz<>xQJdg)U7zjYHvLMKNLfHa?Z8pAYuU+532C1L{0v>2EKnWsjvLm?!
zTdlzd4)|>+p9d{W>7^KUp`oS~bNZo(j&BV4SskOOVqC$X<6_A?%jhc9vC8V&Xtx4g
zBnLaQDv-;hAt(U<(Kt#b!RWU_U~JJ&-;R6ky6?_=?%vuMwbX11?9opP0{9-fn;pRX
z1rSuwZ|s;ce}HJ0O(1=d0{q8z_uhj9UxCgJ@NRwvxH%sA1FSy*z4@X*_)!uT;_wm}
zMy&Y6i*x0;h>)8&Dz~KQEv5=tv^0mn&i$@8DLatMMAtF_R4IX1U_kkTwi#$`ZZDyc
z-LN#{fMeONIlv=K2~XI&6smBAENr2d7KlRQU}tK2i9l7|6&=KvoV00uDdf)E%=
zh#(-J3XBK>Lt)?oKg1peBH+UYRPB3I{N5BXQZV#|Em9CH9#I}tIKxSdVw*xlr}`%r
zT9Ali0j%8rTv#MB3MSA-Ph+68`tcgfAgM=RXu#<4SUJOatP_pOpF?69NFNw)aViJb03Z9wxF}xbqt55>Sg8h6yNu02h!z1bQL>=K*nj
z1b`kBYYBo_LSRP`IA0Zi**)ahN0{-+VtpzTze+)DnPV)Y89fD}|EVQ_q=Jh#E|;nU
z%CS`n^xR@t#SaD)31=Ua)C07+!CpBFSml(|7j$JM3;wE$?D@h2{y0M9NRpD1+-D^<
z3DAHFbfDTYQ$J0}P2S9qhVKi|4d25P6)2#GAvnk?oyST8OrVG6VV^2*DS)r7i(|rv+W-*gFKQShbjQiuCd|CeiCKi+#!2b7p!8@
z1C&f{YCpR3RHpW$A0|*%Atm(_AURSWg2bS(NY_W#n2gH6uO}8v5ykn7Zdk2(bvjWq7tQNJ2f)^L|O?w
z)9dZcu2+JsKC(C^*ur6|uz@Ogi;~EFS{2SI)abT#y40<%bxrnGxXSR84BZ?0AnP9g
zMh1;~yR5)}Omkkxs<%&<8D{vr``F4-$bN^Lsb)8uF^vI`ns4c8T;>u-(k4{92K}e3
zcst&5T1IxaYUfp#MG44C5GIvcN6|PPn{7wUyeiil+qcdVh?P{;1?Vf}5