From 7c1e082535426596347d30aeb4c77e2bd11b22d4 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 28 Mar 2025 14:54:02 -0700 Subject: [PATCH 01/53] replace localhost host with 127.0.0.1 --- packages/fetch/package.json | 2 +- packages/fetch/src/fetch.ts | 6 +++--- packages/fetch/src/stream.ts | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/fetch/package.json b/packages/fetch/package.json index 6a7097284..e0a924706 100644 --- a/packages/fetch/package.json +++ b/packages/fetch/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/fetch", - "version": "1.0.4", + "version": "1.0.5", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/fetch/src/fetch.ts b/packages/fetch/src/fetch.ts index 01fc631db..d4e8145d0 100644 --- a/packages/fetch/src/fetch.ts +++ b/packages/fetch/src/fetch.ts @@ -15,9 +15,9 @@ export function fetchwithRequestOptions( init?: RequestInit, requestOptions?: RequestOptions, ): Promise { - let url = url_; - if (typeof url === "string") { - url = new URL(url); + const url = typeof url_ === "string" ? new URL(url_) : url_; + if (url.host === "localhost") { + url.host = "127.0.0.1"; } const TIMEOUT = 7200; // 7200 seconds = 2 hours diff --git a/packages/fetch/src/stream.ts b/packages/fetch/src/stream.ts index d0e8e4633..7f33e377d 100644 --- a/packages/fetch/src/stream.ts +++ b/packages/fetch/src/stream.ts @@ -2,6 +2,7 @@ export async function* toAsyncIterable( nodeReadable: NodeJS.ReadableStream, ): AsyncGenerator { for await (const chunk of nodeReadable) { + // @ts-expect-error yield chunk as Uint8Array; } } From 09e1c3ce591e818ce25f84781dc7cd71ebbbf3f9 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 1 Apr 2025 19:28:01 -0700 Subject: [PATCH 02/53] remove unused code --- gui/src/App.tsx | 9 - gui/src/components/Layout.tsx | 16 -- gui/src/pages/AddNewModel/AddNewModel.tsx | 238 ----------------- .../pages/AddNewModel/ConfigureProvider.tsx | 245 ------------------ gui/src/pages/AddNewModel/index.ts | 2 - gui/src/util/localStorage.ts | 2 - 6 files changed, 512 deletions(-) delete mode 100644 gui/src/pages/AddNewModel/AddNewModel.tsx delete mode 100644 gui/src/pages/AddNewModel/ConfigureProvider.tsx delete mode 100644 gui/src/pages/AddNewModel/index.ts diff --git a/gui/src/App.tsx b/gui/src/App.tsx index deb1e376f..8f7725db9 100644 --- a/gui/src/App.tsx +++ b/gui/src/App.tsx @@ -3,7 +3,6 @@ import Layout from "./components/Layout"; import { SubmenuContextProvidersProvider } from "./context/SubmenuContextProviders"; import { VscThemeProvider } from "./context/VscTheme"; import useSetup from "./hooks/useSetup"; -import { AddNewModel, ConfigureProvider } from "./pages/AddNewModel"; import ConfigPage from "./pages/config"; import ConfigErrorPage from "./pages/config-error"; import ErrorPage from "./pages/error"; @@ -34,14 +33,6 @@ const router = createMemoryRouter([ path: "/stats", element: , }, - { - path: "/addModel", - element: , - }, - { - path: "/addModel/provider/:providerName", - element: , - }, { path: ROUTES.CONFIG_ERROR, element: , diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index d2d91f1ea..5b70f2e62 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -6,7 +6,6 @@ import { AuthProvider } from "../context/Auth"; import { LocalStorageProvider } from "../context/LocalStorage"; import { useWebviewListener } from "../hooks/useWebviewListener"; import { useAppDispatch, useAppSelector } from "../redux/hooks"; -import { selectUseHub } from "../redux/selectors"; import { focusEdit, setEditStatus } from "../redux/slices/editModeState"; import { addCodeToEdit, @@ -250,21 +249,6 @@ const Layout = () => { } }, [location]); - const useHub = useAppSelector(selectUseHub); - - // Existing users that have already seen the onboarding card - // should be shown an intro card for hub.continue.dev - // useEffect(() => { - // if (useHub !== true) { - // return; - // } - // const seenHubIntro = getLocalStorage("seenHubIntro"); - // if (!onboardingCard.show && !seenHubIntro) { - // onboardingCard.setActiveTab("ExistingUserHubIntro"); - // } - // setLocalStorage("seenHubIntro", true); - // }, [onboardingCard.show, useHub]); - return ( diff --git a/gui/src/pages/AddNewModel/AddNewModel.tsx b/gui/src/pages/AddNewModel/AddNewModel.tsx deleted file mode 100644 index e2fa104ea..000000000 --- a/gui/src/pages/AddNewModel/AddNewModel.tsx +++ /dev/null @@ -1,238 +0,0 @@ -import { ArrowLeftIcon, Cog6ToothIcon } from "@heroicons/react/24/outline"; -import _ from "lodash"; -import React, { useContext } from "react"; -import { useDispatch } from "react-redux"; -import { Link, useNavigate } from "react-router-dom"; -import styled from "styled-components"; -import { - defaultBorderRadius, - lightGray, - vscBackground, -} from "../../components"; -import ModelCard from "../../components/modelSelection/ModelCard"; -import Toggle from "../../components/modelSelection/Toggle"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { useNavigationListener } from "../../hooks/useNavigationListener"; -import { setDefaultModel } from "../../redux/slices/configSlice"; -import { ModelPackage, models } from "./configs/models"; -import { providers } from "./configs/providers"; -import { CustomModelButton } from "./ConfigureProvider"; - -const IntroDiv = styled.div` - padding: 8px 12px; - border-radius: ${defaultBorderRadius}; - border: 1px solid ${lightGray}; - margin-top: 1rem; - margin-bottom: 1rem; -`; - -const GridDiv = styled.div` - display: grid; - grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); - grid-gap: 1.25rem; - justify-items: center; - align-items: center; -`; - -/** - * Used to display groupings in the Models tab - */ -const modelsByProvider: Record = { - "Open AI": [models.gpt4turbo, models.gpt4o, models.gpt35turbo], - Anthropic: [models.claude3Opus, models.claude3Sonnet, models.claude35Haiku], - Mistral: [ - models.codestral, - models.mistral7b, - models.mistral8x7b, - models.mistral8x22b, - models.mistralSmall, - models.mistralLarge, - ], - Cohere: [models.commandR, models.commandRPlus], - DeepSeek: [ - models.deepseekCoderApi, - models.deepseekChatApi, - models.deepseekReasonerApi, - ], - Gemini: [models.geminiPro, models.gemini15Pro, models.gemini15Flash], - "Open Source": [models.llama3Chat, models.mistralOs, models.deepseek], -}; - -function AddNewModel() { - const navigate = useNavigate(); - const dispatch = useDispatch(); - useNavigationListener(); - const ideMessenger = useContext(IdeMessengerContext); - - const [providersSelected, setProvidersSelected] = React.useState(true); - - return ( -
-
- navigate("/")} - className="ml-4 inline-block cursor-pointer" - /> -

Add a new model

-
-
-
- - To add a new model you can either: -
    -
  • - Start by selecting and configuring a provider, then choosing your - model -
  • -
  • Select a specific model directly
  • -
- - Visit our setup overview docs - {" "} - to learn more. -
- -
- { - setProvidersSelected((prev) => !prev); - }} - > -
- - {providersSelected ? ( - <> -
-

Providers

-

- Select a provider below, or configure your own in{" "} - config.json -

-
- - - {Object.entries(providers).map(([providerName, modelInfo], i) => - modelInfo ? ( - { - console.log(`/addModel/provider/${providerName}`); - navigate(`/addModel/provider/${providerName}`); - }} - /> - ) : null, - )} - - - ) : ( - <> -
-

Models

-

- Select a model from the most popular options below, or configure - your own in config.json -

-
- - {Object.entries(modelsByProvider).map( - ([providerTitle, modelConfigsByProviderTitle]) => ( -
-
-

{providerTitle}

-
-
- - - {modelConfigsByProviderTitle.map((config) => ( - { - if (!selectedProvider) { - return; - } - const model = { - ...config.params, - ..._.merge( - {}, - ...(config.dimensions?.map((dimension, i) => { - if (!dimensionChoices?.[i]) return {}; - return { - ...dimension.options[dimensionChoices[i]], - }; - }) || []), - ), - provider: providers[selectedProvider]?.provider, - }; - ideMessenger.post("config/addModel", { model }); - dispatch( - setDefaultModel({ - title: model.title, - force: true, - }), - ); - navigate("/"); - }} - /> - ))} - -
- ), - )} - - )} - - { - ideMessenger.post("config/openProfile", { - profileId: undefined, - }); - }} - > -

- - Open Assistant configuration -

-
-
-
- ); -} - -export default AddNewModel; diff --git a/gui/src/pages/AddNewModel/ConfigureProvider.tsx b/gui/src/pages/AddNewModel/ConfigureProvider.tsx deleted file mode 100644 index 33a3366d6..000000000 --- a/gui/src/pages/AddNewModel/ConfigureProvider.tsx +++ /dev/null @@ -1,245 +0,0 @@ -import { ArrowLeftIcon } from "@heroicons/react/24/outline"; -import _ from "lodash"; -import { useCallback, useContext, useEffect, useState } from "react"; -import { FormProvider, useForm } from "react-hook-form"; -import { useDispatch } from "react-redux"; -import { useNavigate, useParams } from "react-router-dom"; -import styled from "styled-components"; -import { - Input, - defaultBorderRadius, - lightGray, - vscBackground, -} from "../../components"; -import StyledMarkdownPreview from "../../components/markdown/StyledMarkdownPreview"; -import ModelCard from "../../components/modelSelection/ModelCard"; -import { ModelProviderTag } from "../../components/modelSelection/ModelProviderTag"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { useNavigationListener } from "../../hooks/useNavigationListener"; -import { updatedObj } from "../../util"; -import type { ProviderInfo } from "./configs/providers"; -import { providers } from "./configs/providers"; -import { setDefaultModel } from "../../redux/slices/configSlice"; - -const GridDiv = styled.div` - display: grid; - grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); - grid-gap: 2rem; - padding: 1rem; - justify-items: center; - align-items: center; -`; - -export const CustomModelButton = styled.div<{ disabled: boolean }>` - border: 1px solid ${lightGray}; - border-radius: ${defaultBorderRadius}; - padding: 4px 8px; - display: flex; - justify-content: center; - align-items: center; - transition: all 0.5s; - - ${(props) => - props.disabled - ? ` - opacity: 0.5; - ` - : ` - &:hover { - border: 1px solid #be1b55; - background-color: #be1b5522; - cursor: pointer; - } - `} -`; - -function ConfigureProvider() { - useNavigationListener(); - const formMethods = useForm(); - const { providerName } = useParams(); - const ideMessenger = useContext(IdeMessengerContext); - const dispatch = useDispatch(); - const navigate = useNavigate(); - const [modelInfo, setModelInfo] = useState( - undefined, - ); - - useEffect(() => { - if (providerName) { - setModelInfo(providers[providerName]); - } - }, [providerName]); - - const disableModelCards = useCallback(() => { - return ( - modelInfo?.collectInputFor?.some((d) => { - if (!d.required) return false; - const val = formMethods.watch(d.key); - return ( - typeof val === "undefined" || (typeof val === "string" && val === "") - ); - }) || false - ); - }, [modelInfo, formMethods]); - - return ( - -
-
- navigate("/addModel")} - className="ml-4 inline-block cursor-pointer" - /> -

- Configure provider -

-
- -
-
- {window.vscMediaUrl && modelInfo?.icon && ( - - )} -

{modelInfo?.title}

-
- - {modelInfo?.tags?.map((tag, i) => ( - - ))} - - -
- - {(modelInfo?.collectInputFor?.filter((d) => d.required).length || 0) > - 0 && ( - <> -

Enter required parameters

- - {modelInfo?.collectInputFor - ?.filter((d) => d.required) - .map((d, idx) => ( -
- - -
- ))} - - )} - - {(modelInfo?.collectInputFor?.filter((d) => !d.required).length || - 0) > 0 && ( -
- - Advanced (optional) - - - {modelInfo?.collectInputFor?.map((d, idx) => { - if (d.required) return null; - return ( -
- - -
- ); - })} -
- )} - -

Select a model preset

-
- - {modelInfo?.packages.map((pkg, idx) => { - return ( - { - if (disableModelCards()) return; - let formParams: any = {}; - for (const d of modelInfo.collectInputFor || []) { - const val = formMethods.watch(d.key); - if (val === "" || val === undefined || val === null) { - continue; - } - formParams = updatedObj(formParams, { - [d.key]: d.inputType === "text" ? val : parseFloat(val), - }); - } - - const model = { - ...pkg.params, - ...modelInfo.params, - ..._.merge( - {}, - ...(pkg.dimensions?.map((dimension, i) => { - if (!dimensionChoices?.[i]) return {}; - return { - ...dimension.options[dimensionChoices[i]], - }; - }) || []), - ), - ...formParams, - provider: modelInfo.provider, - }; - ideMessenger.post("config/addModel", { model }); - dispatch( - setDefaultModel({ title: model.title, force: true }), - ); - navigate("/"); - }} - /> - ); - })} - -
-
- ); -} - -export default ConfigureProvider; diff --git a/gui/src/pages/AddNewModel/index.ts b/gui/src/pages/AddNewModel/index.ts deleted file mode 100644 index fa5775f14..000000000 --- a/gui/src/pages/AddNewModel/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as AddNewModel } from "./AddNewModel"; -export { default as ConfigureProvider } from "./ConfigureProvider"; diff --git a/gui/src/util/localStorage.ts b/gui/src/util/localStorage.ts index 28d63b847..918618723 100644 --- a/gui/src/util/localStorage.ts +++ b/gui/src/util/localStorage.ts @@ -15,8 +15,6 @@ type LocalStorageTypes = { showTutorialCard: boolean; shownProfilesIntroduction: boolean; disableIndexing: boolean; - /** Indicates whether the user has seen any kind of onboarding card since hub.continue.dev */ - seenHubIntro: boolean; }; export enum LocalStorageKey { From d0e922dad4947ac8af4e9d0c76921da56cdc2953 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 11:15:47 -0700 Subject: [PATCH 03/53] feat: if rules --- packages/config-yaml/src/schemas/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 1ca03b0b6..afc9c1afc 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -28,6 +28,12 @@ const docSchema = z.object({ faviconUrl: z.string().optional(), }); +const ruleObjectSchema = z.object({ + name: z.string(), + rule: z.string(), + if: z.string().optional(), +}); + export const blockItemWrapperSchema = (schema: T) => z.object({ uses: z.string(), @@ -95,7 +101,9 @@ export const blockSchema = baseConfigYamlSchema.and( z.object({ context: z.array(contextSchema).length(1) }), z.object({ data: z.array(dataSchema).length(1) }), z.object({ mcpServers: z.array(mcpServerSchema).length(1) }), - z.object({ rules: z.array(z.string()).length(1) }), + z.object({ + rules: z.array(z.union([z.string(), ruleObjectSchema])).length(1), + }), z.object({ prompts: z.array(promptSchema).length(1) }), z.object({ docs: z.array(docSchema).length(1) }), ]), From 4480ee3ac358e60182304e0e052c27ae45815e2f Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 11:30:24 -0700 Subject: [PATCH 04/53] fix: unset system message --- core/config/yaml/loadYaml.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index f2fefbb39..feafd170c 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -127,7 +127,7 @@ async function configYamlToContinueConfig( models: [], tools: [...allTools], mcpServerStatuses: [], - systemMessage: config.rules?.join("\n"), + systemMessage: undefined, experimental: { modelContextProtocolServers: config.mcpServers?.map((mcpServer) => ({ transport: { From 79780e8d60421568b92dbb3d63adba9c713a3dcc Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 11:31:43 -0700 Subject: [PATCH 05/53] refactor: simplify --- core/llm/index.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/llm/index.ts b/core/llm/index.ts index 028bc42c3..1b250d808 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -298,11 +298,6 @@ export abstract class BaseLLM implements ILLM { ); } - private _getSystemMessage(): string | undefined { - // TODO: Merge with config system message - return this.systemMessage; - } - private _templatePromptLikeMessages(prompt: string): string { if (!this.templateMessages) { return prompt; @@ -310,7 +305,7 @@ export abstract class BaseLLM implements ILLM { const msgs: ChatMessage[] = [{ role: "user", content: prompt }]; - const systemMessage = this._getSystemMessage(); + const systemMessage = this.systemMessage; if (systemMessage) { msgs.unshift({ role: "system", content: systemMessage }); } @@ -601,6 +596,7 @@ export abstract class BaseLLM implements ILLM { ) { const { completionOptions, logEnabled, raw } = this._parseCompletionOptions(options); + debugger; let prompt = pruneRawPromptFromTop( completionOptions.model, @@ -765,6 +761,7 @@ export abstract class BaseLLM implements ILLM { signal: AbortSignal, options: LLMFullCompletionOptions = {}, ): AsyncGenerator { + debugger; let { completionOptions, logEnabled } = this._parseCompletionOptions(options); From 44212e45828bb72c035bf63de4c13342935dcf0f Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 13:09:28 -0700 Subject: [PATCH 06/53] fix: types --- core/config/yaml/loadYaml.ts | 6 +++--- core/config/yaml/models.ts | 27 ++++++++++++++++++--------- core/llm/index.ts | 5 +++-- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index feafd170c..bd15c6ce6 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -211,15 +211,15 @@ async function configYamlToContinueConfig( for (const model of config.models ?? []) { model.roles = model.roles ?? modelsArrayRoles; // Default to all 4 chat-esque roles if not specified try { - const llms = await llmsFromModelConfig( + const llms = await llmsFromModelConfig({ model, ide, uniqueId, ideSettings, writeLog, platformConfigMetadata, - continueConfig.systemMessage, - ); + systemMessage: continueConfig.systemMessage, + }); if (modelsArrayRoles.some((role) => model.roles?.includes(role))) { continueConfig.models.push(...llms); diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index e9d5bd55c..92e29debb 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -29,6 +29,7 @@ async function modelConfigToBaseLLM( platformConfigMetadata: PlatformConfigMetadata | undefined, systemMessage: string | undefined, ): Promise { + debugger; const cls = getModelClass(model); if (!cls) { @@ -167,15 +168,23 @@ async function autodetectModels( } } -export async function llmsFromModelConfig( - model: ModelConfig, - ide: IDE, - uniqueId: string, - ideSettings: IdeSettings, - writeLog: (log: string) => Promise, - platformConfigMetadata: PlatformConfigMetadata | undefined, - systemMessage: string | undefined, -): Promise { +export async function llmsFromModelConfig({ + model, + ide, + uniqueId, + ideSettings, + writeLog, + platformConfigMetadata, + systemMessage, +}: { + model: ModelConfig; + ide: IDE; + uniqueId: string; + ideSettings: IdeSettings; + writeLog: (log: string) => Promise; + platformConfigMetadata: PlatformConfigMetadata | undefined; + systemMessage: string | undefined; +}): Promise { const baseLlm = await modelConfigToBaseLLM( model, uniqueId, diff --git a/core/llm/index.ts b/core/llm/index.ts index 1b250d808..410a70dc4 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -189,6 +189,7 @@ export abstract class BaseLLM implements ILLM { this.title = options.title; this.uniqueId = options.uniqueId ?? "None"; this.systemMessage = options.systemMessage; + // debugger; this.contextLength = options.contextLength ?? llmInfo?.contextLength ?? DEFAULT_CONTEXT_LENGTH; this.maxStopWords = options.maxStopWords ?? this.maxStopWords; @@ -596,7 +597,7 @@ export abstract class BaseLLM implements ILLM { ) { const { completionOptions, logEnabled, raw } = this._parseCompletionOptions(options); - debugger; + // debugger; let prompt = pruneRawPromptFromTop( completionOptions.model, @@ -761,7 +762,7 @@ export abstract class BaseLLM implements ILLM { signal: AbortSignal, options: LLMFullCompletionOptions = {}, ): AsyncGenerator { - debugger; + // debugger; let { completionOptions, logEnabled } = this._parseCompletionOptions(options); From 4b120e543e7c2cec0d33714cfebe88800604fbfd Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 13:15:26 -0700 Subject: [PATCH 07/53] fix: types --- core/config/yaml/loadYaml.ts | 2 +- core/config/yaml/models.ts | 96 +++++++++++++++++++++--------------- 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index bd15c6ce6..f157bf21d 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -218,7 +218,7 @@ async function configYamlToContinueConfig( ideSettings, writeLog, platformConfigMetadata, - systemMessage: continueConfig.systemMessage, + config: continueConfig, }); if (modelsArrayRoles.some((role) => model.roles?.includes(role))) { diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index 92e29debb..5e5088df8 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -1,6 +1,6 @@ import { ModelConfig } from "@continuedev/config-yaml"; -import { IDE, IdeSettings, LLMOptions } from "../.."; +import { ContinueConfig, IDE, IdeSettings, LLMOptions } from "../.."; import { BaseLLM } from "../../llm"; import { LLMClasses } from "../../llm/llms"; import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader"; @@ -13,22 +13,29 @@ function getModelClass( return LLMClasses.find((llm) => llm.providerName === model.provider); } -function getContinueProxyModelName( - ownerSlug: string, - packageSlug: string, - model: ModelConfig, -): string { - return `${ownerSlug}/${packageSlug}/${model.provider}/${model.model}`; -} +// function getContinueProxyModelName( +// ownerSlug: string, +// packageSlug: string, +// model: ModelConfig, +// ): string { +// return `${ownerSlug}/${packageSlug}/${model.provider}/${model.model}`; +// } -async function modelConfigToBaseLLM( - model: ModelConfig, - uniqueId: string, - ideSettings: IdeSettings, - writeLog: (log: string) => Promise, - platformConfigMetadata: PlatformConfigMetadata | undefined, - systemMessage: string | undefined, -): Promise { +async function modelConfigToBaseLLM({ + model, + uniqueId, + ideSettings, + writeLog, + platformConfigMetadata, + config, +}: { + model: ModelConfig; + uniqueId: string; + ideSettings: IdeSettings; + writeLog: (log: string) => Promise; + platformConfigMetadata: PlatformConfigMetadata | undefined; + config: ContinueConfig; +}): Promise { debugger; const cls = getModelClass(model); @@ -51,7 +58,7 @@ async function modelConfigToBaseLLM( writeLog, uniqueId, title: model.name, - systemMessage, + systemMessage: config.systemMessage, promptTemplates: model.promptTemplates, capabilities: { tools: model.capabilities?.includes("tool_use"), @@ -128,16 +135,25 @@ async function modelConfigToBaseLLM( return llm; } -async function autodetectModels( - llm: BaseLLM, - model: ModelConfig, - ide: IDE, - uniqueId: string, - ideSettings: IdeSettings, - writeLog: (log: string) => Promise, - platformConfigMetadata: PlatformConfigMetadata | undefined, - systemMessage: string | undefined, -): Promise { +async function autodetectModels({ + llm, + model, + ide, + uniqueId, + ideSettings, + writeLog, + platformConfigMetadata, + config, +}: { + llm: BaseLLM; + model: ModelConfig; + ide: IDE; + uniqueId: string; + ideSettings: IdeSettings; + writeLog: (log: string) => Promise; + platformConfigMetadata: PlatformConfigMetadata | undefined; + config: ContinueConfig; +}): Promise { try { const modelNames = await llm.listModels(); const detectedModels = await Promise.all( @@ -147,8 +163,8 @@ async function autodetectModels( return undefined; } - return await modelConfigToBaseLLM( - { + return await modelConfigToBaseLLM({ + model: { ...model, model: modelName, name: modelName, @@ -157,8 +173,8 @@ async function autodetectModels( ideSettings, writeLog, platformConfigMetadata, - systemMessage, - ); + config, + }); }), ); return detectedModels.filter((x) => typeof x !== "undefined") as BaseLLM[]; @@ -175,7 +191,7 @@ export async function llmsFromModelConfig({ ideSettings, writeLog, platformConfigMetadata, - systemMessage, + config, }: { model: ModelConfig; ide: IDE; @@ -183,31 +199,31 @@ export async function llmsFromModelConfig({ ideSettings: IdeSettings; writeLog: (log: string) => Promise; platformConfigMetadata: PlatformConfigMetadata | undefined; - systemMessage: string | undefined; + config: ContinueConfig; }): Promise { - const baseLlm = await modelConfigToBaseLLM( + const baseLlm = await modelConfigToBaseLLM({ model, uniqueId, ideSettings, writeLog, platformConfigMetadata, - systemMessage, - ); + config, + }); if (!baseLlm) { return []; } if (model.model === AUTODETECT) { - const models = await autodetectModels( - baseLlm, + const models = await autodetectModels({ + llm: baseLlm, model, ide, uniqueId, ideSettings, writeLog, platformConfigMetadata, - systemMessage, - ); + config, + }); return models; } else { return [baseLlm]; From be27552e3330b3a18ecb1065b6ab7210a4375826 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 13:43:14 -0700 Subject: [PATCH 08/53] fix: types --- core/package.json | 2 +- packages/config-yaml/src/load/unroll.ts | 3 ++- packages/config-yaml/src/schemas/index.ts | 10 ++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/package.json b/core/package.json index 205e3b778..5cbe16115 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "file:../packages/config-yaml/dist", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index f376fbc84..60dabf710 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -17,6 +17,7 @@ import { blockSchema, ConfigYaml, configYamlSchema, + Rule, } from "../schemas/index.js"; import { useProxyForUnrenderedSecrets } from "./clientRender.js"; @@ -315,7 +316,7 @@ export async function unrollBlocks( // Rules are a bit different because they're just strings, so handle separately if (assistant.rules) { - const rules: string[] = []; + const rules: Rule[] = []; for (const rule of assistant.rules) { if (typeof rule === "string") { rules.push(rule); diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index afc9c1afc..3a394ba05 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -34,6 +34,12 @@ const ruleObjectSchema = z.object({ if: z.string().optional(), }); +const ruleSchema = z.union([z.string(), ruleObjectSchema]); + +export type Rule = z.infer; + +export type RuleObject = z.infer; + export const blockItemWrapperSchema = (schema: T) => z.object({ uses: z.string(), @@ -88,7 +94,7 @@ export const assistantUnrolledSchema = baseConfigYamlSchema.extend({ context: z.array(contextSchema).optional(), data: z.array(dataSchema).optional(), mcpServers: z.array(mcpServerSchema).optional(), - rules: z.array(z.string()).optional(), + rules: z.array(ruleSchema).optional(), prompts: z.array(promptSchema).optional(), docs: z.array(docSchema).optional(), }); @@ -102,7 +108,7 @@ export const blockSchema = baseConfigYamlSchema.and( z.object({ data: z.array(dataSchema).length(1) }), z.object({ mcpServers: z.array(mcpServerSchema).length(1) }), z.object({ - rules: z.array(z.union([z.string(), ruleObjectSchema])).length(1), + rules: z.array(ruleSchema).length(1), }), z.object({ prompts: z.array(promptSchema).length(1) }), z.object({ docs: z.array(docSchema).length(1) }), From 5faecca09f27a7490b4050b7191197c74fe38299 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 13:52:02 -0700 Subject: [PATCH 09/53] fix: types --- packages/config-yaml/src/load/unroll.ts | 2 +- packages/config-yaml/src/schemas/index.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index 60dabf710..a41b965fc 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -320,7 +320,7 @@ export async function unrollBlocks( for (const rule of assistant.rules) { if (typeof rule === "string") { rules.push(rule); - } else { + } else if ("uses" in rule) { const blockConfigYaml = await resolveBlock( decodeFullSlug(rule.uses), rule.with, diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 3a394ba05..ae12c99a7 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -38,8 +38,6 @@ const ruleSchema = z.union([z.string(), ruleObjectSchema]); export type Rule = z.infer; -export type RuleObject = z.infer; - export const blockItemWrapperSchema = (schema: T) => z.object({ uses: z.string(), @@ -75,7 +73,7 @@ export const configYamlSchema = baseConfigYamlSchema.extend({ rules: z .array( z.union([ - z.string(), + ruleSchema, z.object({ uses: z.string(), with: z.record(z.string()).optional(), From 82cad596c85d0ee0b17ceccdf1f6cca5811b8f94 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 13:53:48 -0700 Subject: [PATCH 10/53] fix: types --- core/config/yaml/models.ts | 1 + core/index.d.ts | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index 5e5088df8..fd1a0beff 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -59,6 +59,7 @@ async function modelConfigToBaseLLM({ uniqueId, title: model.name, systemMessage: config.systemMessage, + rules: config.rules, promptTemplates: model.promptTemplates, capabilities: { tools: model.capabilities?.includes("tool_use"), diff --git a/core/index.d.ts b/core/index.d.ts index ba97377d3..9a6a40c21 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1,4 +1,4 @@ -import { DataDestination, ModelRole } from "@continuedev/config-yaml"; +import { DataDestination, ModelRole, Rule } from "@continuedev/config-yaml"; import Parser from "web-tree-sitter"; import { GetGhTokenArgs } from "./protocol/ide"; declare global { @@ -497,6 +497,7 @@ export interface LLMOptions { templateMessages?: (messages: ChatMessage[]) => string; writeLog?: (str: string) => Promise; llmRequestHook?: (model: string, prompt: string) => any; + rules?: Rule[]; apiKey?: string; // continueProperties @@ -1312,7 +1313,7 @@ export interface ContinueConfig { docs?: SiteIndexingConfig[]; tools: Tool[]; mcpServerStatuses: MCPServerStatus[]; - rules?: string[]; + rules?: Rule[]; modelsByRole: Record; selectedModelByRole: Record; data?: DataDestination[]; @@ -1335,7 +1336,7 @@ export interface BrowserSerializedContinueConfig { docs?: SiteIndexingConfig[]; tools: Tool[]; mcpServerStatuses: MCPServerStatus[]; - rules?: string[]; + rules?: Rule[]; usePlatform: boolean; tabAutocompleteOptions?: Partial; modelsByRole: Record; From 5c49505f2071504481c17976670d883efebddb4a Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 14:20:24 -0700 Subject: [PATCH 11/53] fix: type errors --- extensions/vscode/package-lock.json | 2 +- gui/package-lock.json | 2 +- .../mainInput/Lump/sections/RulesSection.tsx | 39 +++++++++++-------- packages/config-yaml/src/load/unroll.ts | 4 +- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 3b3f05ad0..699444702 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -106,7 +106,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "file:../packages/config-yaml/dist", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/package-lock.json b/gui/package-lock.json index 78eb2e61d..e963d2cf2 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -111,7 +111,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "file:../packages/config-yaml/dist", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx index 4cb7b0051..3b25e2efa 100644 --- a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx @@ -1,4 +1,4 @@ -import { parseConfigYaml } from "@continuedev/config-yaml"; +import { parseConfigYaml, Rule } from "@continuedev/config-yaml"; import { ArrowsPointingOutIcon, PencilIcon } from "@heroicons/react/24/outline"; import { useContext, useMemo } from "react"; import { useSelector } from "react-redux"; @@ -17,7 +17,7 @@ import { ExploreBlocksButton } from "./ExploreBlocksButton"; interface RuleCardProps { index: number; - rule: string; + rule: Rule; onClick: () => void; title: string; } @@ -31,7 +31,10 @@ const RuleCard: React.FC = ({ index, rule, onClick, title }) => { setDialogMessage(

{title}

-
{rule}
+
+            {/** TODO: Render the rule in a more readable way */}
+            {JSON.stringify(rule)}
+          
, ), ); @@ -62,7 +65,8 @@ const RuleCard: React.FC = ({ index, rule, onClick, title }) => { }} className="line-clamp-3 text-gray-400" > - {rule} + {/** TODO: Render the rule in a more readable way */} + {JSON.stringify(rule)}
@@ -137,21 +141,22 @@ export function RulesSection() { ); } - if (!rule.ruleFromYaml?.uses) { - return null; + if ("uses" in rule.ruleFromYaml) { + const ruleSlug = rule.ruleFromYaml?.uses; + + return ( + openUrl(`${ruleSlug}/new-version`)} + title={ruleSlug} + /> + ); } - const ruleSlug = rule.ruleFromYaml?.uses; - - return ( - openUrl(`${ruleSlug}/new-version`)} - title={ruleSlug} - /> - ); + // TODO: Handle rules as object with 'if' + return null; })}
diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index a41b965fc..5a7549ddd 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -314,11 +314,11 @@ export async function unrollBlocks( } } - // Rules are a bit different because they're just strings, so handle separately + // Rules are a bit different because they can be strings, so hanlde separately if (assistant.rules) { const rules: Rule[] = []; for (const rule of assistant.rules) { - if (typeof rule === "string") { + if (typeof rule === "string" || !("uses" in rule)) { rules.push(rule); } else if ("uses" in rule) { const blockConfigYaml = await resolveBlock( From 5cc2cb250683f9907e60b1fae7c8d4f2d14d73b6 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 2 Apr 2025 14:38:32 -0700 Subject: [PATCH 12/53] unused commands - remove --- extensions/vscode/src/commands.ts | 41 ------------------------------- 1 file changed, 41 deletions(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 6a1e35424..836360e51 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -634,16 +634,6 @@ const getCommandsMap: ( editDecorationManager.clear(); void sidebar.webviewProtocol?.request("exitEditMode", undefined); }, - // "continue.quickEdit": async (args: QuickEditShowParams) => { - // let linesOfCode = undefined; - // if (args.range) { - // linesOfCode = args.range.end.line - args.range.start.line; - // } - // captureCommandTelemetry("quickEdit", { - // linesOfCode, - // }); - // quickEdit.show(args); - // }, "continue.writeCommentsForCode": async () => { captureCommandTelemetry("writeCommentsForCode"); @@ -708,37 +698,6 @@ const getCommandsMap: ( vscode.commands.executeCommand("continue.continueGUIView.focus"); sidebar.webviewProtocol?.request("addModel", undefined); }, - "continue.sendMainUserInput": (text: string) => { - sidebar.webviewProtocol?.request("userInput", { - input: text, - }); - }, - "continue.selectRange": (startLine: number, endLine: number) => { - if (!vscode.window.activeTextEditor) { - return; - } - vscode.window.activeTextEditor.selection = new vscode.Selection( - startLine, - 0, - endLine, - 0, - ); - }, - "continue.foldAndUnfold": ( - foldSelectionLines: number[], - unfoldSelectionLines: number[], - ) => { - vscode.commands.executeCommand("editor.unfold", { - selectionLines: unfoldSelectionLines, - }); - vscode.commands.executeCommand("editor.fold", { - selectionLines: foldSelectionLines, - }); - }, - "continue.sendToTerminal": (text: string) => { - captureCommandTelemetry("sendToTerminal"); - ide.runCommand(text); - }, "continue.newSession": () => { sidebar.webviewProtocol?.request("newSession", undefined); }, From b20b1ab5ee44d704619327a3b087b1290c634dd7 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 16:03:10 -0700 Subject: [PATCH 13/53] feat: filttrex --- core/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/core/package.json b/core/package.json index 5cbe16115..f4e12a2d8 100644 --- a/core/package.json +++ b/core/package.json @@ -66,6 +66,7 @@ "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", + "filtrex": "^3.1.0", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", From 1a1b854fda4630e136d0d18b4ea69e71a00ced1e Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 2 Apr 2025 16:05:39 -0700 Subject: [PATCH 14/53] feat: evaluate rule --- core/llm/rules/isRuleActive.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 core/llm/rules/isRuleActive.ts diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts new file mode 100644 index 000000000..205b98138 --- /dev/null +++ b/core/llm/rules/isRuleActive.ts @@ -0,0 +1,17 @@ +import { Rule } from "@continuedev/config-yaml"; + +const evaluateIf = (condition: string) => { + return true; +}; + +export const isRuleActive = (rule: Rule): boolean => { + if (typeof rule === "string") { + return true; + } + + if (rule.if) { + return evaluateIf(rule.if); + } + + return true; +}; From 466deef9d6ff183a31a45b12a28bca7e638f5c55 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 2 Apr 2025 21:52:12 -0700 Subject: [PATCH 15/53] fix bedrock reranker credentials --- core/llm/llms/Bedrock.ts | 253 ++++++++++++++++++++++++--------------- 1 file changed, 154 insertions(+), 99 deletions(-) diff --git a/core/llm/llms/Bedrock.ts b/core/llm/llms/Bedrock.ts index 573170ece..7fefbd329 100644 --- a/core/llm/llms/Bedrock.ts +++ b/core/llm/llms/Bedrock.ts @@ -4,7 +4,7 @@ import { ConverseStreamCommand, ConverseStreamCommandOutput, InvokeModelCommand, - Message + Message, } from "@aws-sdk/client-bedrock-runtime"; import { fromNodeProviderChain } from "@aws-sdk/credential-providers"; @@ -12,7 +12,7 @@ import { ChatMessage, Chunk, CompletionOptions, - LLMOptions + LLMOptions, } from "../../index.js"; import { renderChatMessage } from "../../util/messageContent.js"; import { BaseLLM } from "../index.js"; @@ -52,10 +52,14 @@ class Bedrock extends BaseLLM { private _currentToolResponse: Partial | null = null; private _promptCachingMetrics: PromptCachingMetrics = { cacheReadInputTokens: 0, - cacheWriteInputTokens: 0 + cacheWriteInputTokens: 0, }; - public requestOptions: { region?: string; credentials?: any; headers?: Record }; + public requestOptions: { + region?: string; + credentials?: any; + headers?: Record; + }; constructor(options: LLMOptions) { super(options); @@ -121,12 +125,17 @@ class Bedrock extends BaseLLM { }, ); - const input = this._generateConverseInput(messages, { ...options, stream: true }); + const input = this._generateConverseInput(messages, { + ...options, + stream: true, + }); const command = new ConverseStreamCommand(input); let response: ConverseStreamCommandOutput; try { - response = await client.send(command, { abortSignal: signal }) as ConverseStreamCommandOutput; + response = (await client.send(command, { + abortSignal: signal, + })) as ConverseStreamCommandOutput; } catch (error: unknown) { console.error(error); const message = error instanceof Error ? error.message : "Unknown error"; @@ -140,9 +149,9 @@ class Bedrock extends BaseLLM { // Reset cache metrics for new request this._promptCachingMetrics = { cacheReadInputTokens: 0, - cacheWriteInputTokens: 0 + cacheWriteInputTokens: 0, }; - + try { for await (const chunk of response.stream) { if (chunk.metadata?.usage) { @@ -150,47 +159,69 @@ class Bedrock extends BaseLLM { } if (chunk.contentBlockDelta?.delta) { - - const delta: any = chunk.contentBlockDelta.delta + const delta: any = chunk.contentBlockDelta.delta; // Handle text content if (chunk.contentBlockDelta.delta.text) { - yield { role: "assistant", content: chunk.contentBlockDelta.delta.text }; + yield { + role: "assistant", + content: chunk.contentBlockDelta.delta.text, + }; continue; } // Handle text content if ((chunk.contentBlockDelta.delta as any).reasoningContent?.text) { - yield { role: "thinking", content: (chunk.contentBlockDelta.delta as any).reasoningContent.text }; + yield { + role: "thinking", + content: (chunk.contentBlockDelta.delta as any).reasoningContent + .text, + }; continue; } // Handle signature for thinking if (delta.reasoningContent?.signature) { - yield { role: "thinking", content: "", signature: delta.reasoningContent.signature }; + yield { + role: "thinking", + content: "", + signature: delta.reasoningContent.signature, + }; continue; } // Handle redacted thinking if (delta.redactedReasoning?.data) { - yield { role: "thinking", content: "", redactedThinking: delta.redactedReasoning.data }; + yield { + role: "thinking", + content: "", + redactedThinking: delta.redactedReasoning.data, + }; continue; } - if (chunk.contentBlockDelta.delta.toolUse?.input && this._currentToolResponse) { + if ( + chunk.contentBlockDelta.delta.toolUse?.input && + this._currentToolResponse + ) { // Append the new input to the existing string if (this._currentToolResponse.input === undefined) { this._currentToolResponse.input = ""; } - this._currentToolResponse.input += chunk.contentBlockDelta.delta.toolUse.input; + this._currentToolResponse.input += + chunk.contentBlockDelta.delta.toolUse.input; continue; } } if (chunk.contentBlockStart?.start) { - const start: any = chunk.contentBlockStart.start + const start: any = chunk.contentBlockStart.start; if (start.redactedReasoning) { - yield { role: "thinking", content: "", redactedThinking: start.redactedReasoning.data }; + yield { + role: "thinking", + content: "", + redactedThinking: start.redactedReasoning.data, + }; continue; } @@ -199,7 +230,7 @@ class Bedrock extends BaseLLM { this._currentToolResponse = { toolUseId: toolUse.toolUseId, name: toolUse.name, - input: "" + input: "", }; } continue; @@ -210,14 +241,16 @@ class Bedrock extends BaseLLM { yield { role: "assistant", content: "", - toolCalls: [{ - id: this._currentToolResponse.toolUseId, - type: "function", - function: { - name: this._currentToolResponse.name, - arguments: this._currentToolResponse.input - } - }], + toolCalls: [ + { + id: this._currentToolResponse.toolUseId, + type: "function", + function: { + name: this._currentToolResponse.name, + arguments: this._currentToolResponse.input, + }, + }, + ], }; this._currentToolResponse = null; } @@ -229,13 +262,16 @@ class Bedrock extends BaseLLM { if (error instanceof Error) { if ("code" in error) { // AWS SDK specific errors - throw new Error(`AWS Bedrock stream error (${(error as any).code}): ${error.message}`); + throw new Error( + `AWS Bedrock stream error (${(error as any).code}): ${error.message}`, + ); } throw new Error(`Error processing Bedrock stream: ${error.message}`); } - throw new Error("Error processing Bedrock stream: Unknown error occurred"); + throw new Error( + "Error processing Bedrock stream: Unknown error occurred", + ); } - } /** @@ -252,39 +288,41 @@ class Bedrock extends BaseLLM { const shouldCacheSystemMessage = !!this.systemMessage && this.cacheBehavior?.cacheSystemMessage; - const enablePromptCaching = shouldCacheSystemMessage || this.cacheBehavior?.cacheConversation; + const enablePromptCaching = + shouldCacheSystemMessage || this.cacheBehavior?.cacheConversation; // Add header for prompt caching if (enablePromptCaching) { this.requestOptions.headers = { ...this.requestOptions.headers, - "x-amzn-bedrock-enablepromptcaching": "true" + "x-amzn-bedrock-enablepromptcaching": "true", }; } - const supportsTools = PROVIDER_TOOL_SUPPORT.bedrock?.(options.model || "") ?? false; + const supportsTools = + PROVIDER_TOOL_SUPPORT.bedrock?.(options.model || "") ?? false; return { modelId: options.model, messages: convertedMessages, - system: this.systemMessage ? ( - shouldCacheSystemMessage ? - [ - { text: this.systemMessage }, - { cachePoint: { type: "default" } } - ] : - [{ text: this.systemMessage }] - ) : undefined, - toolConfig: supportsTools && options.tools ? { - tools: options.tools.map(tool => ({ - toolSpec: { - name: tool.function.name, - description: tool.function.description, - inputSchema: { - json: tool.function.parameters + system: this.systemMessage + ? shouldCacheSystemMessage + ? [{ text: this.systemMessage }, { cachePoint: { type: "default" } }] + : [{ text: this.systemMessage }] + : undefined, + toolConfig: + supportsTools && options.tools + ? { + tools: options.tools.map((tool) => ({ + toolSpec: { + name: tool.function.name, + description: tool.function.description, + inputSchema: { + json: tool.function.parameters, + }, + }, + })), } - } - })) - } : undefined, + : undefined, inferenceConfig: { maxTokens: options.maxTokens, temperature: options.temperature, @@ -302,21 +340,28 @@ class Bedrock extends BaseLLM { .slice(0, 4), }, additionalModelRequestFields: { - "thinking": options.reasoning ? { - "type": "enabled", - "budget_tokens": options.reasoningBudgetTokens - } : undefined, - } + thinking: options.reasoning + ? { + type: "enabled", + budget_tokens: options.reasoningBudgetTokens, + } + : undefined, + }, }; } - private _convertMessage(message: ChatMessage, addCaching: boolean = false): Message | null { + private _convertMessage( + message: ChatMessage, + addCaching: boolean = false, + ): Message | null { // Handle system messages explicitly if (message.role === "system") { return null; } - const cachePoint = addCaching ? { cachePoint: { type: "default" } } : undefined; + const cachePoint = addCaching + ? { cachePoint: { type: "default" } } + : undefined; // Tool response handling if (message.role === "tool") { @@ -328,12 +373,12 @@ class Bedrock extends BaseLLM { toolUseId: message.toolCallId, content: [ { - text: message.content || "" - } - ] - } - } - ] + text: message.content || "", + }, + ], + }, + }, + ], }; } @@ -346,8 +391,8 @@ class Bedrock extends BaseLLM { toolUseId: toolCall.id, name: toolCall.function?.name, input: JSON.parse(toolCall.function?.arguments || "{}"), - } - })) + }, + })), }; } @@ -355,26 +400,27 @@ class Bedrock extends BaseLLM { if (message.redactedThinking) { const content: ContentBlock.ReasoningContentMember = { reasoningContent: { - redactedContent: new Uint8Array(Buffer.from(message.redactedThinking)) - } + redactedContent: new Uint8Array( + Buffer.from(message.redactedThinking), + ), + }, }; return { role: "assistant", - content: [content] + content: [content], }; } else { const content: ContentBlock.ReasoningContentMember = { reasoningContent: { reasoningText: { text: (message.content as string) || "", - signature: message.signature - } - - } + signature: message.signature, + }, + }, }; return { role: "assistant", - content: [content] + content: [content], }; } } @@ -387,7 +433,7 @@ class Bedrock extends BaseLLM { } return { role: message.role, - content + content, }; } @@ -396,7 +442,7 @@ class Bedrock extends BaseLLM { const content: any[] = []; // Process all parts first - message.content.forEach(part => { + message.content.forEach((part) => { if (part.type === "text") { content.push({ text: part.text }); } else if (part.type === "imageUrl" && part.imageUrl) { @@ -407,9 +453,9 @@ class Bedrock extends BaseLLM { image: { format, source: { - bytes: Buffer.from(base64Data, "base64") - } - } + bytes: Buffer.from(base64Data, "base64"), + }, + }, }); } catch (error) { console.warn(`Failed to process image: ${error}`); @@ -424,7 +470,7 @@ class Bedrock extends BaseLLM { return { role: message.role, - content + content, } as Message; } return null; @@ -439,22 +485,24 @@ class Bedrock extends BaseLLM { .filter((index) => index !== -1) .slice(-2); - const converted = filteredmessages.map((message, filteredMsgIdx) => { - // Add cache_control parameter to the last two user messages - // The second-to-last because it retrieves potentially already cached contents, - // The last one because we want it cached for later retrieval. - // See: https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html - const addCaching = - this.cacheBehavior?.cacheConversation && - lastTwoUserMsgIndices.includes(filteredMsgIdx); + const converted = filteredmessages + .map((message, filteredMsgIdx) => { + // Add cache_control parameter to the last two user messages + // The second-to-last because it retrieves potentially already cached contents, + // The last one because we want it cached for later retrieval. + // See: https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html + const addCaching = + this.cacheBehavior?.cacheConversation && + lastTwoUserMsgIndices.includes(filteredMsgIdx); - try { - return this._convertMessage(message, addCaching); - } catch (error) { - console.error(`Failed to convert message: ${error}`); - return null; - } - }).filter(Boolean); + try { + return this._convertMessage(message, addCaching); + } catch (error) { + console.error(`Failed to convert message: ${error}`); + return null; + } + }) + .filter(Boolean); return converted; } @@ -520,7 +568,6 @@ class Bedrock extends BaseLLM { return modelConfig.extractEmbeddings(responseBody); } - private _getModelConfig() { const modelConfigs: { [key: string]: ModelConfig } = { cohere: { @@ -558,7 +605,11 @@ class Bedrock extends BaseLLM { const credentials = await this._getCredentials(); const client = new BedrockRuntimeClient({ region: this.region, - credentials, + credentials: { + accessKeyId: credentials.accessKeyId, + secretAccessKey: credentials.secretAccessKey, + sessionToken: credentials.sessionToken || "", + }, }); // Base payload for both models @@ -597,11 +648,15 @@ class Bedrock extends BaseLLM { if (error instanceof Error) { if ("code" in error) { // AWS SDK specific errors - throw new Error(`AWS Bedrock rerank error (${(error as any).code}): ${error.message}`); + throw new Error( + `AWS Bedrock rerank error (${(error as any).code}): ${error.message}`, + ); } throw new Error(`Error in BedrockReranker.rerank: ${error.message}`); } - throw new Error("Error in BedrockReranker.rerank: Unknown error occurred"); + throw new Error( + "Error in BedrockReranker.rerank: Unknown error occurred", + ); } } } From ea72a5a87e426de567594429fe2cd5107fb268af Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 2 Apr 2025 21:52:40 -0700 Subject: [PATCH 16/53] bump --- extensions/intellij/gradle.properties | 2 +- extensions/vscode/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index b9c409a6d..506f6bf62 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension pluginName=continue-intellij-extension pluginRepositoryUrl=https://github.com/continuedev/continue # SemVer format -> https://semver.org -pluginVersion=1.0.10 +pluginVersion=1.0.11 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild=223 # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 769ed476b..15599a1c0 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.1.19", + "version": "1.1.20", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From f95cdfaf83569159cd7aed02134be7dd5f4029cf Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 08:45:54 -0700 Subject: [PATCH 17/53] feat: rule glob --- packages/config-yaml/src/load/unroll.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index 5a7549ddd..92a0b0157 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -63,7 +63,7 @@ export function parseBlock(configYaml: string): Block { } } -const TEMPLATE_VAR_REGEX = /\${{[\s]*([^}\s]+)[\s]*}}/g; +export const TEMPLATE_VAR_REGEX = /\${{[\s]*([^}\s]+)[\s]*}}/g; export function getTemplateVariables(templatedYaml: string): string[] { const variables = new Set(); From 2ffb4aefeb01073c924beb1c203e60c586cf96bb Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 09:20:41 -0700 Subject: [PATCH 18/53] feat: extract paths --- core/llm/utils/extractPathsFromCodeBlocks.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 core/llm/utils/extractPathsFromCodeBlocks.ts diff --git a/core/llm/utils/extractPathsFromCodeBlocks.ts b/core/llm/utils/extractPathsFromCodeBlocks.ts new file mode 100644 index 000000000..98494ba0f --- /dev/null +++ b/core/llm/utils/extractPathsFromCodeBlocks.ts @@ -0,0 +1,16 @@ +/** + * Extracts file paths from markdown code blocks + */ +export function extractPathsFromCodeBlocks(content: string): string[] { + const codeBlockRegex = /```[\w-+#]*\s+([^\s(]+)(?:\s|$|\()/g; + const paths: string[] = []; + let match; + + while ((match = codeBlockRegex.exec(content)) !== null) { + if (match[1]) { + paths.push(match[1]); + } + } + + return paths; +} From 4156d83171712789ba60fb97c7deb68ebb6c1ae7 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 09:28:41 -0700 Subject: [PATCH 19/53] refactor: clean up code --- core/llm/countTokens.ts | 57 ++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 16ac82100..6136aad3e 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -384,6 +384,39 @@ function chatMessageIsEmpty(message: ChatMessage): boolean { } } +function addSystemMessage( + messages: ChatMessage[], + systemMessage: string | undefined, + originalMessages: ChatMessage[] | undefined, +): ChatMessage[] { + if ( + !(systemMessage && systemMessage.trim() !== "") && + originalMessages?.[0]?.role !== "system" + ) { + return messages; + } + + let content = ""; + if (originalMessages?.[0]?.role === "system") { + content = renderChatMessage(originalMessages[0]); + } + if (systemMessage && systemMessage.trim() !== "") { + const shouldAddNewLines = content !== ""; + if (shouldAddNewLines) { + content += "\n\n"; + } + content += systemMessage; + } + + const systemChatMsg: ChatMessage = { + role: "system", + content, + }; + // Insert as second to last + messages.splice(-1, 0, systemChatMsg); + return messages; +} + function compileChatMessages( modelName: string, msgs: ChatMessage[] | undefined, @@ -410,29 +443,7 @@ function compileChatMessages( msgsCopy.push(promptMsg); } - if ( - (systemMessage && systemMessage.trim() !== "") || - msgs?.[0]?.role === "system" - ) { - let content = ""; - if (msgs?.[0]?.role === "system") { - content = renderChatMessage(msgs?.[0]); - } - if (systemMessage && systemMessage.trim() !== "") { - const shouldAddNewLines = content !== ""; - if (shouldAddNewLines) { - content += "\n\n"; - } - content += systemMessage; - } - const systemChatMsg: ChatMessage = { - role: "system", - content, - }; - // Insert as second to last - // Later moved to top, but want second-priority to last user message - msgsCopy.splice(-1, 0, systemChatMsg); - } + msgsCopy = addSystemMessage(msgsCopy, systemMessage, msgs); let functionTokens = 0; if (functions) { From 0c0d0c92f65c74378822c254286e83a9b25133f3 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 09:32:13 -0700 Subject: [PATCH 20/53] refactor: clean up code --- core/llm/countTokens.ts | 29 +++++++++++++++++++---------- core/llm/index.ts | 18 ++++++++++-------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 6136aad3e..75d7bf5ff 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -417,16 +417,25 @@ function addSystemMessage( return messages; } -function compileChatMessages( - modelName: string, - msgs: ChatMessage[] | undefined, - contextLength: number, - maxTokens: number, - supportsImages: boolean, - prompt: string | undefined = undefined, - functions: any[] | undefined = undefined, - systemMessage: string | undefined = undefined, -): ChatMessage[] { +function compileChatMessages({ + modelName, + msgs, + contextLength, + maxTokens, + supportsImages, + prompt, + functions, + systemMessage, +}: { + modelName: string; + msgs: ChatMessage[] | undefined; + contextLength: number; + maxTokens: number; + supportsImages: boolean; + prompt: string | undefined; + functions: any[] | undefined; + systemMessage: string | undefined; +}): ChatMessage[] { let msgsCopy = msgs ? msgs .map((msg) => ({ ...msg })) diff --git a/core/llm/index.ts b/core/llm/index.ts index 410a70dc4..23cba7702 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -166,6 +166,7 @@ export abstract class BaseLLM implements ILLM { protected openaiAdapter?: BaseLlmApi; constructor(_options: LLMOptions) { + // debugger; this._llmOptions = _options; // Set default options @@ -287,19 +288,20 @@ export abstract class BaseLLM implements ILLM { CONTEXT_LENGTH_FOR_MODEL[options.model] || DEFAULT_CONTEXT_LENGTH; } - return compileChatMessages( - options.model, - messages, + return compileChatMessages({ + modelName: options.model, + msgs: messages, contextLength, - options.maxTokens ?? DEFAULT_MAX_TOKENS, - this.supportsImages(), - undefined, + maxTokens: options.maxTokens ?? DEFAULT_MAX_TOKENS, + supportsImages: this.supportsImages(), + prompt: undefined, functions, - this.systemMessage, - ); + systemMessage: this.systemMessage, + }); } private _templatePromptLikeMessages(prompt: string): string { + debugger; if (!this.templateMessages) { return prompt; } From a3bc2e13f976e8575cfe4d32316fa9452dc2c566 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 09:36:18 -0700 Subject: [PATCH 21/53] refactor: clean up code --- core/llm/countTokens.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 75d7bf5ff..f2bc7b37d 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -384,11 +384,15 @@ function chatMessageIsEmpty(message: ChatMessage): boolean { } } -function addSystemMessage( - messages: ChatMessage[], - systemMessage: string | undefined, - originalMessages: ChatMessage[] | undefined, -): ChatMessage[] { +function addSystemMessage({ + messages, + systemMessage, + originalMessages, +}: { + messages: ChatMessage[]; + systemMessage: string | undefined; + originalMessages: ChatMessage[] | undefined; +}): ChatMessage[] { if ( !(systemMessage && systemMessage.trim() !== "") && originalMessages?.[0]?.role !== "system" @@ -452,7 +456,11 @@ function compileChatMessages({ msgsCopy.push(promptMsg); } - msgsCopy = addSystemMessage(msgsCopy, systemMessage, msgs); + msgsCopy = addSystemMessage({ + messages: msgsCopy, + systemMessage, + originalMessages: msgs, + }); let functionTokens = 0; if (functions) { From 0b07020d7dd9bf59ca1d804668a215174273625b Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 09:51:36 -0700 Subject: [PATCH 22/53] fix: messages --- core/llm/countTokens.ts | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index f2bc7b37d..b733e1783 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -1,7 +1,13 @@ import { Tiktoken, encodingForModel as _encodingForModel } from "js-tiktoken"; -import { ChatMessage, MessageContent, MessagePart } from "../index.js"; +import { + ChatMessage, + MessageContent, + MessagePart, + UserChatMessage, +} from "../index.js"; +import { Rule } from "@continuedev/config-yaml"; import { renderChatMessage } from "../util/messageContent.js"; import { AsyncEncoder, @@ -421,6 +427,30 @@ function addSystemMessage({ return messages; } +const getSystemMessage = ({ + userMessage, +}: { + userMessage: UserChatMessage; + rules: Rule[]; +}) => { + if (systemMessage) { + return ""; + } + + return systemMessage; +}; + +function getLastUserMessage(messages: ChatMessage[]): ChatMessage | undefined { + // Iterate backwards through messages to find the last user message + for (let i = messages.length - 1; i >= 0; i--) { + if (messages[i].role === "user") { + return messages[i]; + } + } + + return undefined; +} + function compileChatMessages({ modelName, msgs, @@ -440,6 +470,7 @@ function compileChatMessages({ functions: any[] | undefined; systemMessage: string | undefined; }): ChatMessage[] { + debugger; let msgsCopy = msgs ? msgs .map((msg) => ({ ...msg })) @@ -456,6 +487,8 @@ function compileChatMessages({ msgsCopy.push(promptMsg); } + const lastUserMessage = getLastUserMessage(msgsCopy); + msgsCopy = addSystemMessage({ messages: msgsCopy, systemMessage, From ccdc1b953e22ca4aa26e32b9e80bc31ea30f274c Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 09:54:33 -0700 Subject: [PATCH 23/53] feat: if-rules --- core/llm/countTokens.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index b733e1783..9336dbfb2 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -429,22 +429,26 @@ function addSystemMessage({ const getSystemMessage = ({ userMessage, + rules, }: { - userMessage: UserChatMessage; + userMessage?: UserChatMessage; rules: Rule[]; }) => { - if (systemMessage) { - return ""; - } + return "Respond in Spanish"; + // if (systemMessage) { + // return ""; + // } - return systemMessage; + // return systemMessage; }; -function getLastUserMessage(messages: ChatMessage[]): ChatMessage | undefined { +function getLastUserMessage( + messages: ChatMessage[], +): UserChatMessage | undefined { // Iterate backwards through messages to find the last user message for (let i = messages.length - 1; i >= 0; i--) { if (messages[i].role === "user") { - return messages[i]; + return messages[i] as UserChatMessage; } } @@ -491,7 +495,12 @@ function compileChatMessages({ msgsCopy = addSystemMessage({ messages: msgsCopy, - systemMessage, + systemMessage: + systemMessage ?? + getSystemMessage({ + userMessage: lastUserMessage, + rules: [], + }), originalMessages: msgs, }); From 0a13a4604d7607793bea66b9cea3e89353bf3af4 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 10:00:21 -0700 Subject: [PATCH 24/53] feat: if-rules --- core/llm/countTokens.ts | 5 ++++- core/llm/index.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 9336dbfb2..e5b895556 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -434,6 +434,7 @@ const getSystemMessage = ({ userMessage?: UserChatMessage; rules: Rule[]; }) => { + debugger; return "Respond in Spanish"; // if (systemMessage) { // return ""; @@ -464,6 +465,7 @@ function compileChatMessages({ prompt, functions, systemMessage, + rules, }: { modelName: string; msgs: ChatMessage[] | undefined; @@ -473,6 +475,7 @@ function compileChatMessages({ prompt: string | undefined; functions: any[] | undefined; systemMessage: string | undefined; + rules: Rule[]; }): ChatMessage[] { debugger; let msgsCopy = msgs @@ -499,7 +502,7 @@ function compileChatMessages({ systemMessage ?? getSystemMessage({ userMessage: lastUserMessage, - rules: [], + rules, }), originalMessages: msgs, }); diff --git a/core/llm/index.ts b/core/llm/index.ts index 23cba7702..9b5d5ebdd 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -1,4 +1,4 @@ -import { ModelRole } from "@continuedev/config-yaml"; +import { ModelRole, Rule } from "@continuedev/config-yaml"; import { fetchwithRequestOptions } from "@continuedev/fetch"; import { findLlmInfo } from "@continuedev/llm-info"; import { @@ -143,6 +143,7 @@ export abstract class BaseLLM implements ILLM { cacheBehavior?: CacheBehavior; capabilities?: ModelCapability; roles?: ModelRole[]; + rules?: Rule[]; deployment?: string; apiVersion?: string; @@ -244,6 +245,7 @@ export abstract class BaseLLM implements ILLM { this.accountId = options.accountId; this.capabilities = options.capabilities; this.roles = options.roles; + this.rules = options.rules; this.deployment = options.deployment; this.apiVersion = options.apiVersion; @@ -297,6 +299,7 @@ export abstract class BaseLLM implements ILLM { prompt: undefined, functions, systemMessage: this.systemMessage, + rules: this.rules ?? [], }); } From 9baa4e93be7f9c2fe057e453237eaa9d1aaa8ff0 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 10:29:13 -0700 Subject: [PATCH 25/53] feat: if-rule --- core/llm/countTokens.ts | 34 ++++++++++++++++++++++++++++------ core/llm/rules/isRuleActive.ts | 2 +- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index e5b895556..85c49f73c 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -17,6 +17,8 @@ import { import { autodetectTemplateType } from "./autodetect.js"; import { TOKEN_BUFFER_FOR_SAFETY } from "./constants.js"; import llamaTokenizer from "./llamaTokenizer.js"; +import { isRuleActive } from "./rules/isRuleActive.js"; +import { extractPathsFromCodeBlocks } from "./utils/extractPathsFromCodeBlocks.js"; interface Encoding { encode: Tiktoken["encode"]; decode: Tiktoken["decode"]; @@ -427,6 +429,27 @@ function addSystemMessage({ return messages; } +function getMessageStringContent(message?: UserChatMessage): string { + if (!message) { + return ""; + } + + if (typeof message.content === "string") { + return message.content; + } + + // Handle MessagePart array + return message.content + .map((part) => { + if (part.type === "text") { + return part.text; + } + + return ""; + }) + .join("\n"); +} + const getSystemMessage = ({ userMessage, rules, @@ -434,13 +457,12 @@ const getSystemMessage = ({ userMessage?: UserChatMessage; rules: Rule[]; }) => { + const messageStringContent = getMessageStringContent(userMessage); + const filePathsFromMessage = extractPathsFromCodeBlocks(messageStringContent); debugger; - return "Respond in Spanish"; - // if (systemMessage) { - // return ""; - // } - - // return systemMessage; + return rules.filter((rule) => { + return isRuleActive({ rule }); + }); }; function getLastUserMessage( diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts index 205b98138..b6952db59 100644 --- a/core/llm/rules/isRuleActive.ts +++ b/core/llm/rules/isRuleActive.ts @@ -4,7 +4,7 @@ const evaluateIf = (condition: string) => { return true; }; -export const isRuleActive = (rule: Rule): boolean => { +export const isRuleActive = ({ rule }: { rule: Rule }): boolean => { if (typeof rule === "string") { return true; } From f19b6b8abdb4dfb64c804efee851dee0bb00471c Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 10:29:52 -0700 Subject: [PATCH 26/53] fix: type errors --- core/llm/countTokens.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 85c49f73c..c27b0e9a0 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -460,9 +460,11 @@ const getSystemMessage = ({ const messageStringContent = getMessageStringContent(userMessage); const filePathsFromMessage = extractPathsFromCodeBlocks(messageStringContent); debugger; - return rules.filter((rule) => { - return isRuleActive({ rule }); - }); + return rules + .filter((rule) => { + return isRuleActive({ rule }); + }) + .join("\n"); }; function getLastUserMessage( From 9cb5170b1a23552f917265dc330ff1e05838a3de Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 10:45:42 -0700 Subject: [PATCH 27/53] feat: get paths --- core/llm/utils/extractPathsFromCodeBlocks.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/llm/utils/extractPathsFromCodeBlocks.ts b/core/llm/utils/extractPathsFromCodeBlocks.ts index 98494ba0f..7573a1f6f 100644 --- a/core/llm/utils/extractPathsFromCodeBlocks.ts +++ b/core/llm/utils/extractPathsFromCodeBlocks.ts @@ -2,13 +2,19 @@ * Extracts file paths from markdown code blocks */ export function extractPathsFromCodeBlocks(content: string): string[] { - const codeBlockRegex = /```[\w-+#]*\s+([^\s(]+)(?:\s|$|\()/g; + // Match: + // 1. Starting ``` + // 2. Optional language identifier + // 3. Required whitespace + // 4. File path (captured) that must contain a dot and extension + const codeBlockRegex = /```(?:[\w-+#]+)?\s+([^\s\n()]+\.[a-zA-Z0-9]+)/g; const paths: string[] = []; let match; while ((match = codeBlockRegex.exec(content)) !== null) { - if (match[1]) { - paths.push(match[1]); + const path = match[1]; + if (path && !path.startsWith("```")) { + paths.push(path); } } From 8c5ca401d4fbda64eacf23cc0585e2c9830db345 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 10:47:42 -0700 Subject: [PATCH 28/53] feat: glob rules --- core/llm/countTokens.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index c27b0e9a0..efb7c4eee 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -459,11 +459,17 @@ const getSystemMessage = ({ }) => { const messageStringContent = getMessageStringContent(userMessage); const filePathsFromMessage = extractPathsFromCodeBlocks(messageStringContent); - debugger; + return rules .filter((rule) => { return isRuleActive({ rule }); }) + .map((rule) => { + if (typeof rule === "string") { + return rule; + } + return rule.rule; + }) .join("\n"); }; From 05a3eec21ed1c26aa4d9825e6be5e209cdb9563c Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 11:49:16 -0700 Subject: [PATCH 29/53] fix: regex --- core/llm/countTokens.ts | 2 +- core/llm/rules/isRuleActive.ts | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index efb7c4eee..175e0ba75 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -507,7 +507,7 @@ function compileChatMessages({ systemMessage: string | undefined; rules: Rule[]; }): ChatMessage[] { - debugger; + // debugger; let msgsCopy = msgs ? msgs .map((msg) => ({ ...msg })) diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts index b6952db59..402b0f23d 100644 --- a/core/llm/rules/isRuleActive.ts +++ b/core/llm/rules/isRuleActive.ts @@ -1,10 +1,25 @@ import { Rule } from "@continuedev/config-yaml"; +const TEMPLATE_VAR_REGEX = /^\$\{\{(\s*.*?\s*)\}\}$/; + const evaluateIf = (condition: string) => { + debugger; + + const expression = condition.match(TEMPLATE_VAR_REGEX)?.[1]?.trim(); + + if (!expression) { + return false; + } + return true; }; - -export const isRuleActive = ({ rule }: { rule: Rule }): boolean => { +export const isRuleActive = ({ + rule, + activePaths, +}: { + rule: Rule; + activePaths: string[]; +}): boolean => { if (typeof rule === "string") { return true; } From 6224af63d36e6b96b068c6d4230ee2315bd94d43 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 11:54:53 -0700 Subject: [PATCH 30/53] feat: if rules --- core/llm/rules/isRuleActive.test.ts | 55 +++++++++++++++++++++++++++++ core/llm/rules/isRuleActive.ts | 35 +++++++++++++++--- 2 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 core/llm/rules/isRuleActive.test.ts diff --git a/core/llm/rules/isRuleActive.test.ts b/core/llm/rules/isRuleActive.test.ts new file mode 100644 index 000000000..1afcd84a0 --- /dev/null +++ b/core/llm/rules/isRuleActive.test.ts @@ -0,0 +1,55 @@ +import { isRuleActive } from "./isRuleActive"; + +describe("isRuleActive", () => { + it("evaluates glob patterns correctly", () => { + const activePaths = ["src/foo.ts", "src/bar.tsx", "README.md"]; + + expect( + isRuleActive({ + rule: { + name: "Test Rule", + rule: "Some rule", + if: '${{ glob("src/*.ts") }}', + }, + activePaths, + }), + ).toBe(true); + + expect( + isRuleActive({ + rule: { + name: "Test Rule", + rule: "Some rule", + if: '${{ glob("*.md") }}', + }, + activePaths, + }), + ).toBe(true); + + expect( + isRuleActive({ + rule: { + name: "Test Rule", + rule: "Some rule", + if: '${{ glob("*.py") }}', + }, + activePaths, + }), + ).toBe(false); + }); + + it("evaluates combined conditions correctly", () => { + const activePaths = ["src/foo.ts"]; + + expect( + isRuleActive({ + rule: { + name: "Test Rule", + rule: "Some rule", + if: '${{ glob("src/*.ts") && current.model === "gpt-4" }}', + }, + activePaths, + }), + ).toBe(true); + }); +}); diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts index 402b0f23d..827c485d0 100644 --- a/core/llm/rules/isRuleActive.ts +++ b/core/llm/rules/isRuleActive.ts @@ -1,18 +1,43 @@ import { Rule } from "@continuedev/config-yaml"; +import { compileExpression } from "filtrex"; +import { minimatch } from "minimatch"; const TEMPLATE_VAR_REGEX = /^\$\{\{(\s*.*?\s*)\}\}$/; -const evaluateIf = (condition: string) => { - debugger; +const createGlobFunction = (activePaths: string[]) => { + return (pattern: string) => { + return activePaths.some((path) => minimatch(path, pattern)); + }; +}; +const evaluateIf = (condition: string, activePaths: string[]) => { const expression = condition.match(TEMPLATE_VAR_REGEX)?.[1]?.trim(); if (!expression) { - return false; + return true; } - return true; + try { + const context = { + glob: createGlobFunction(activePaths), + current: { + model: "gpt-4", // Hardcoded for now + }, + }; + + const evaluate = compileExpression(expression, { + extraFunctions: { + glob: (pattern: string) => context.glob(pattern), + }, + }); + + return evaluate(context); + } catch (error) { + console.error("Error evaluating rule condition:", error); + return false; + } }; + export const isRuleActive = ({ rule, activePaths, @@ -25,7 +50,7 @@ export const isRuleActive = ({ } if (rule.if) { - return evaluateIf(rule.if); + return evaluateIf(rule.if, activePaths); } return true; From 2620064c53ecf7de3d61b34043d2c0450f68b13c Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 12:27:22 -0700 Subject: [PATCH 31/53] feat: rules --- core/llm/countTokens.ts | 2 +- core/llm/rules/isRuleActive.ts | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 175e0ba75..c710c80c9 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -462,7 +462,7 @@ const getSystemMessage = ({ return rules .filter((rule) => { - return isRuleActive({ rule }); + return isRuleActive({ rule, activePaths: filePathsFromMessage }); }) .map((rule) => { if (typeof rule === "string") { diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts index 827c485d0..01cf1d98d 100644 --- a/core/llm/rules/isRuleActive.ts +++ b/core/llm/rules/isRuleActive.ts @@ -12,26 +12,23 @@ const createGlobFunction = (activePaths: string[]) => { const evaluateIf = (condition: string, activePaths: string[]) => { const expression = condition.match(TEMPLATE_VAR_REGEX)?.[1]?.trim(); - if (!expression) { return true; } try { - const context = { - glob: createGlobFunction(activePaths), - current: { - model: "gpt-4", // Hardcoded for now - }, - }; + debugger; const evaluate = compileExpression(expression, { extraFunctions: { - glob: (pattern: string) => context.glob(pattern), + glob: createGlobFunction(activePaths), + }, + constants: { + current: { model: "gpt-4" }, // Hardcoded for now }, }); - return evaluate(context); + return evaluate({}); } catch (error) { console.error("Error evaluating rule condition:", error); return false; From 06b76d752fb4f83b14053fffe2f85cb819e39ae6 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 12:32:25 -0700 Subject: [PATCH 32/53] feat: if-rules --- core/llm/rules/isRuleActive.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts index 01cf1d98d..197a816bf 100644 --- a/core/llm/rules/isRuleActive.ts +++ b/core/llm/rules/isRuleActive.ts @@ -19,12 +19,14 @@ const evaluateIf = (condition: string, activePaths: string[]) => { try { debugger; - const evaluate = compileExpression(expression, { - extraFunctions: { - glob: createGlobFunction(activePaths), - }, + const evaluate = compileExpression(`current.model == "gpt-4"`, { + // extraFunctions: { + // glob: createGlobFunction(activePaths), + // }, constants: { - current: { model: "gpt-4" }, // Hardcoded for now + current: { + model: "gpt-4", + }, }, }); From a6dd5a83dedcae099f320a2da9362490eadde299 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 12:38:30 -0700 Subject: [PATCH 33/53] fix: if rules --- core/llm/rules/isRuleActive.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts index 197a816bf..a7c6f6fbe 100644 --- a/core/llm/rules/isRuleActive.ts +++ b/core/llm/rules/isRuleActive.ts @@ -19,10 +19,10 @@ const evaluateIf = (condition: string, activePaths: string[]) => { try { debugger; - const evaluate = compileExpression(`current.model == "gpt-4"`, { - // extraFunctions: { - // glob: createGlobFunction(activePaths), - // }, + const evaluate = compileExpression(expression, { + extraFunctions: { + glob: createGlobFunction(activePaths), + }, constants: { current: { model: "gpt-4", From b39cb836ad6180226d39abe85f5637a6e2dac44d Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 12:40:46 -0700 Subject: [PATCH 34/53] fix: rules --- core/llm/rules/isRuleActive.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts index a7c6f6fbe..1d701a65a 100644 --- a/core/llm/rules/isRuleActive.ts +++ b/core/llm/rules/isRuleActive.ts @@ -17,8 +17,6 @@ const evaluateIf = (condition: string, activePaths: string[]) => { } try { - debugger; - const evaluate = compileExpression(expression, { extraFunctions: { glob: createGlobFunction(activePaths), From 211fcb77407cd261f2bb26198667388ea6270a05 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 13:36:33 -0700 Subject: [PATCH 35/53] feat: if-rule --- core/llm/countTokens.ts | 10 +++++++++- core/llm/rules/isRuleActive.ts | 21 ++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index c710c80c9..7d4e415de 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -453,16 +453,22 @@ function getMessageStringContent(message?: UserChatMessage): string { const getSystemMessage = ({ userMessage, rules, + currentModel, }: { userMessage?: UserChatMessage; rules: Rule[]; + currentModel: string; }) => { const messageStringContent = getMessageStringContent(userMessage); const filePathsFromMessage = extractPathsFromCodeBlocks(messageStringContent); return rules .filter((rule) => { - return isRuleActive({ rule, activePaths: filePathsFromMessage }); + return isRuleActive({ + rule, + activePaths: filePathsFromMessage, + currentModel, + }); }) .map((rule) => { if (typeof rule === "string") { @@ -525,6 +531,7 @@ function compileChatMessages({ } const lastUserMessage = getLastUserMessage(msgsCopy); + debugger; msgsCopy = addSystemMessage({ messages: msgsCopy, @@ -533,6 +540,7 @@ function compileChatMessages({ getSystemMessage({ userMessage: lastUserMessage, rules, + currentModel: modelName, }), originalMessages: msgs, }); diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts index 1d701a65a..aa1a40f33 100644 --- a/core/llm/rules/isRuleActive.ts +++ b/core/llm/rules/isRuleActive.ts @@ -10,7 +10,19 @@ const createGlobFunction = (activePaths: string[]) => { }; }; -const evaluateIf = (condition: string, activePaths: string[]) => { +const contains = (str: string, searchStr: string): boolean => { + return str.toLowerCase().includes(searchStr.toLowerCase()); +}; + +const evaluateIf = ({ + condition, + activePaths, + currentModel, +}: { + condition: string; + activePaths: string[]; + currentModel: string; +}) => { const expression = condition.match(TEMPLATE_VAR_REGEX)?.[1]?.trim(); if (!expression) { return true; @@ -20,10 +32,11 @@ const evaluateIf = (condition: string, activePaths: string[]) => { const evaluate = compileExpression(expression, { extraFunctions: { glob: createGlobFunction(activePaths), + contains, }, constants: { current: { - model: "gpt-4", + model: { model: currentModel }, }, }, }); @@ -38,16 +51,18 @@ const evaluateIf = (condition: string, activePaths: string[]) => { export const isRuleActive = ({ rule, activePaths, + currentModel, }: { rule: Rule; activePaths: string[]; + currentModel: string; }): boolean => { if (typeof rule === "string") { return true; } if (rule.if) { - return evaluateIf(rule.if, activePaths); + return evaluateIf({ condition: rule.if, activePaths, currentModel }); } return true; From 2b97efe5c6d045b461c76068c0e06df298d95902 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 14:00:15 -0700 Subject: [PATCH 36/53] fix: isRuleActive --- core/llm/rules/isRuleActive.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts index aa1a40f33..9215f997d 100644 --- a/core/llm/rules/isRuleActive.ts +++ b/core/llm/rules/isRuleActive.ts @@ -6,12 +6,14 @@ const TEMPLATE_VAR_REGEX = /^\$\{\{(\s*.*?\s*)\}\}$/; const createGlobFunction = (activePaths: string[]) => { return (pattern: string) => { - return activePaths.some((path) => minimatch(path, pattern)); + const result = activePaths.some((path) => minimatch(path, pattern)); + debugger; + return result; }; }; const contains = (str: string, searchStr: string): boolean => { - return str.toLowerCase().includes(searchStr.toLowerCase()); + return str.includes(searchStr); }; const evaluateIf = ({ @@ -29,6 +31,7 @@ const evaluateIf = ({ } try { + debugger; const evaluate = compileExpression(expression, { extraFunctions: { glob: createGlobFunction(activePaths), From 81acb446019a773ce2df98467e4dcb8e5c2a428e Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 14:03:14 -0700 Subject: [PATCH 37/53] fix: tests --- core/llm/rules/isRuleActive.test.ts | 72 +++++++++++++---------------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/core/llm/rules/isRuleActive.test.ts b/core/llm/rules/isRuleActive.test.ts index 1afcd84a0..db7dc1f5c 100644 --- a/core/llm/rules/isRuleActive.test.ts +++ b/core/llm/rules/isRuleActive.test.ts @@ -1,55 +1,47 @@ import { isRuleActive } from "./isRuleActive"; describe("isRuleActive", () => { - it("evaluates glob patterns correctly", () => { - const activePaths = ["src/foo.ts", "src/bar.tsx", "README.md"]; + it("should correctly evaluate combined contains and glob conditions", () => { + const rule = { + name: "My Rule", + rule: "Do no harm", + if: "${{ and(contains(current.model.model, 'claude-3-7-sonnet'), glob('*.tsx')) }}", + }; + // Should be false when activePaths is empty expect( isRuleActive({ - rule: { - name: "Test Rule", - rule: "Some rule", - if: '${{ glob("src/*.ts") }}', - }, - activePaths, + rule, + activePaths: [], + currentModel: "claude-3-7-sonnet", + }), + ).toBe(false); + + // Should be false when no matching paths + expect( + isRuleActive({ + rule, + activePaths: ["test.py", "main.js"], + currentModel: "claude-3-7-sonnet", + }), + ).toBe(false); + + // Should be true when both conditions are met + expect( + isRuleActive({ + rule, + activePaths: ["Component.tsx", "main.js"], + currentModel: "claude-3-7-sonnet", }), ).toBe(true); + // Should be false when only glob matches expect( isRuleActive({ - rule: { - name: "Test Rule", - rule: "Some rule", - if: '${{ glob("*.md") }}', - }, - activePaths, - }), - ).toBe(true); - - expect( - isRuleActive({ - rule: { - name: "Test Rule", - rule: "Some rule", - if: '${{ glob("*.py") }}', - }, - activePaths, + rule, + activePaths: ["Component.tsx"], + currentModel: "gpt-4", }), ).toBe(false); }); - - it("evaluates combined conditions correctly", () => { - const activePaths = ["src/foo.ts"]; - - expect( - isRuleActive({ - rule: { - name: "Test Rule", - rule: "Some rule", - if: '${{ glob("src/*.ts") && current.model === "gpt-4" }}', - }, - activePaths, - }), - ).toBe(true); - }); }); From 6d27ac6777ba3a1992ff6753eee955ca7064d49e Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 14:05:53 -0700 Subject: [PATCH 38/53] test: rules --- core/llm/rules/isRuleActive.test.ts | 32 ++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/core/llm/rules/isRuleActive.test.ts b/core/llm/rules/isRuleActive.test.ts index db7dc1f5c..6d7bd0d04 100644 --- a/core/llm/rules/isRuleActive.test.ts +++ b/core/llm/rules/isRuleActive.test.ts @@ -1,14 +1,13 @@ import { isRuleActive } from "./isRuleActive"; describe("isRuleActive", () => { - it("should correctly evaluate combined contains and glob conditions", () => { - const rule = { - name: "My Rule", - rule: "Do no harm", - if: "${{ and(contains(current.model.model, 'claude-3-7-sonnet'), glob('*.tsx')) }}", - }; + const rule = { + name: "My Rule", + rule: "Do no harm", + if: "${{ and(contains(current.model.model, 'claude-3-7-sonnet') and glob('*.tsx')) }}", + }; - // Should be false when activePaths is empty + it("should return false when activePaths is empty", () => { expect( isRuleActive({ rule, @@ -16,8 +15,9 @@ describe("isRuleActive", () => { currentModel: "claude-3-7-sonnet", }), ).toBe(false); + }); - // Should be false when no matching paths + it("should return false when no matching paths exist", () => { expect( isRuleActive({ rule, @@ -25,8 +25,9 @@ describe("isRuleActive", () => { currentModel: "claude-3-7-sonnet", }), ).toBe(false); + }); - // Should be true when both conditions are met + it("should return true when both conditions are met", () => { expect( isRuleActive({ rule, @@ -34,8 +35,9 @@ describe("isRuleActive", () => { currentModel: "claude-3-7-sonnet", }), ).toBe(true); + }); - // Should be false when only glob matches + it("should return false when only glob matches but model doesn't", () => { expect( isRuleActive({ rule, @@ -44,4 +46,14 @@ describe("isRuleActive", () => { }), ).toBe(false); }); + + it("should return false when model matches but glob doesn't", () => { + expect( + isRuleActive({ + rule, + activePaths: ["Component.ts"], + currentModel: "claude-3-7-sonnet", + }), + ).toBe(false); + }); }); From cb2e0a7c0e9330d9b79a3e9878c851b9eba92ade Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 14:48:00 -0700 Subject: [PATCH 39/53] fix: failing tests --- core/llm/rules/isRuleActive.test.ts | 2 +- core/llm/rules/isRuleActive.ts | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/core/llm/rules/isRuleActive.test.ts b/core/llm/rules/isRuleActive.test.ts index 6d7bd0d04..f50b9972a 100644 --- a/core/llm/rules/isRuleActive.test.ts +++ b/core/llm/rules/isRuleActive.test.ts @@ -4,7 +4,7 @@ describe("isRuleActive", () => { const rule = { name: "My Rule", rule: "Do no harm", - if: "${{ and(contains(current.model.model, 'claude-3-7-sonnet') and glob('*.tsx')) }}", + if: '${{ contains(current.model.model, "claude-3-7-sonnet") and glob("*.tsx") }}', }; it("should return false when activePaths is empty", () => { diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts index 9215f997d..47125c644 100644 --- a/core/llm/rules/isRuleActive.ts +++ b/core/llm/rules/isRuleActive.ts @@ -7,7 +7,6 @@ const TEMPLATE_VAR_REGEX = /^\$\{\{(\s*.*?\s*)\}\}$/; const createGlobFunction = (activePaths: string[]) => { return (pattern: string) => { const result = activePaths.some((path) => minimatch(path, pattern)); - debugger; return result; }; }; @@ -31,16 +30,13 @@ const evaluateIf = ({ } try { - debugger; const evaluate = compileExpression(expression, { extraFunctions: { glob: createGlobFunction(activePaths), contains, }, constants: { - current: { - model: { model: currentModel }, - }, + "current.model.model": currentModel, }, }); From ea6b2344d0b2cde7def58de549e604142a40a353 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 14:55:37 -0700 Subject: [PATCH 40/53] fix: type errors --- core/llm/countTokens.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/llm/countTokens.test.ts b/core/llm/countTokens.test.ts index 6895e9269..92f9d92c5 100644 --- a/core/llm/countTokens.test.ts +++ b/core/llm/countTokens.test.ts @@ -1,3 +1,4 @@ +// @ts-nocheck // Generated by continue import { ChatMessage, MessagePart } from "../index.js"; import { From 2820f43503743ec33d1b12951f7f9fc261ee6cc5 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 14:56:22 -0700 Subject: [PATCH 41/53] improv: clean up --- .../context/root-path-context/RootPathContextService.ts | 2 -- core/llm/countTokens.ts | 1 - core/llm/index.ts | 4 ---- 3 files changed, 7 deletions(-) diff --git a/core/autocomplete/context/root-path-context/RootPathContextService.ts b/core/autocomplete/context/root-path-context/RootPathContextService.ts index 79b598f1e..7a29f8a8f 100644 --- a/core/autocomplete/context/root-path-context/RootPathContextService.ts +++ b/core/autocomplete/context/root-path-context/RootPathContextService.ts @@ -88,7 +88,6 @@ export class RootPathContextService { default: // const type = node.type; // console.log(getSyntaxTreeString(node)); - // debugger; query = await getQueryForFile( filepath, @@ -165,7 +164,6 @@ export class RootPathContextService { )) { const key = RootPathContextService.keyFromNode(parentKey, astNode); // const type = astNode.type; - // debugger; const foundInCache = this.cache.get(key); const newSnippets = diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 7d4e415de..241c0f29d 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -513,7 +513,6 @@ function compileChatMessages({ systemMessage: string | undefined; rules: Rule[]; }): ChatMessage[] { - // debugger; let msgsCopy = msgs ? msgs .map((msg) => ({ ...msg })) diff --git a/core/llm/index.ts b/core/llm/index.ts index 9b5d5ebdd..42b63cafd 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -167,7 +167,6 @@ export abstract class BaseLLM implements ILLM { protected openaiAdapter?: BaseLlmApi; constructor(_options: LLMOptions) { - // debugger; this._llmOptions = _options; // Set default options @@ -191,7 +190,6 @@ export abstract class BaseLLM implements ILLM { this.title = options.title; this.uniqueId = options.uniqueId ?? "None"; this.systemMessage = options.systemMessage; - // debugger; this.contextLength = options.contextLength ?? llmInfo?.contextLength ?? DEFAULT_CONTEXT_LENGTH; this.maxStopWords = options.maxStopWords ?? this.maxStopWords; @@ -602,7 +600,6 @@ export abstract class BaseLLM implements ILLM { ) { const { completionOptions, logEnabled, raw } = this._parseCompletionOptions(options); - // debugger; let prompt = pruneRawPromptFromTop( completionOptions.model, @@ -767,7 +764,6 @@ export abstract class BaseLLM implements ILLM { signal: AbortSignal, options: LLMFullCompletionOptions = {}, ): AsyncGenerator { - // debugger; let { completionOptions, logEnabled } = this._parseCompletionOptions(options); From d2545e48d2bba2fde0084e99cd0a78947ed4c573 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 15:21:35 -0700 Subject: [PATCH 42/53] improv: clean up code --- core/config/yaml/models.ts | 1 - core/llm/countTokens.ts | 1 - core/llm/index.ts | 1 - .../mainInput/Lump/sections/RulesSection.tsx | 23 +++++++++++++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index fd1a0beff..6eabfd040 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -36,7 +36,6 @@ async function modelConfigToBaseLLM({ platformConfigMetadata: PlatformConfigMetadata | undefined; config: ContinueConfig; }): Promise { - debugger; const cls = getModelClass(model); if (!cls) { diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 241c0f29d..4f04a3925 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -530,7 +530,6 @@ function compileChatMessages({ } const lastUserMessage = getLastUserMessage(msgsCopy); - debugger; msgsCopy = addSystemMessage({ messages: msgsCopy, diff --git a/core/llm/index.ts b/core/llm/index.ts index 42b63cafd..cc7d7123c 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -302,7 +302,6 @@ export abstract class BaseLLM implements ILLM { } private _templatePromptLikeMessages(prompt: string): string { - debugger; if (!this.templateMessages) { return prompt; } diff --git a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx index 3b25e2efa..6bb3d1637 100644 --- a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx @@ -40,6 +40,23 @@ const RuleCard: React.FC = ({ index, rule, onClick, title }) => { ); } + const renderRuleContent = () => { + if (typeof rule === "string") { + return
{rule}
; + } + + if (rule.rule) { + return ( +
+
{rule.rule}
+ {rule.if &&
if: {rule.if}
} +
+ ); + } + + return
{JSON.stringify(rule)}
; + }; + return (
= ({ index, rule, onClick, title }) => { }} className="line-clamp-3 text-gray-400" > - {/** TODO: Render the rule in a more readable way */} - {JSON.stringify(rule)} + {renderRuleContent()}
@@ -163,6 +179,3 @@ export function RulesSection() {
); } -function useTypedDispatch() { - throw new Error("Function not implemented."); -} From fccae8732e1a4f447ff0ab650e9ae717c2022ffc Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 15:23:12 -0700 Subject: [PATCH 43/53] fix: dependencies --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index f4e12a2d8..d709d6b8c 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "file:../packages/config-yaml/dist", + "@continuedev/config-yaml": "^1.0.67", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", From cc063fdd124d66515bdcb9e2c64f575b40cc99d8 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 15:25:00 -0700 Subject: [PATCH 44/53] fix: dependencies --- core/package-lock.json | 14 ++++++++++---- core/package.json | 2 +- gui/package-lock.json | 3 ++- package-lock.json | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 50df2a6f3..f92a977f8 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.68", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -32,6 +32,7 @@ "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", + "filtrex": "^3.1.0", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", @@ -2974,9 +2975,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.67", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", - "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", + "version": "1.0.70", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.70.tgz", + "integrity": "sha512-0hwc2a2NyUDDNDAx23SOFfY4sV8EafuCow4JNpRzCz8swH3ZfO+vdOzKMIEzAzcYXcpjldsOAZsYE4iypu1L+Q==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", @@ -8585,6 +8586,11 @@ "node": ">=8" } }, + "node_modules/filtrex": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/filtrex/-/filtrex-3.1.0.tgz", + "integrity": "sha512-mHzZ2wUISETF1OaEcNRiGz1ljuIV8c/C9td9qyAZ+wTwigkAk5RO9YrCxQKk5H9v7joDRFIBik9U5RTK9eXZ/A==" + }, "node_modules/find-replace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", diff --git a/core/package.json b/core/package.json index d709d6b8c..0287c2611 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.68", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/package-lock.json b/gui/package-lock.json index e963d2cf2..1769ac246 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -111,7 +111,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "file:../packages/config-yaml/dist", + "@continuedev/config-yaml": "^1.0.68", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -130,6 +130,7 @@ "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", + "filtrex": "^3.1.0", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", diff --git a/package-lock.json b/package-lock.json index 6a0a55705..cdfb21273 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,8 @@ "@typescript-eslint/parser": "^7.8.0", "eslint-plugin-import": "^2.29.1", "prettier": "^3.3.3", - "prettier-plugin-tailwindcss": "^0.6.8" + "prettier-plugin-tailwindcss": "^0.6.8", + "typescript": "^5.6.3" } }, "node_modules/@eslint-community/eslint-utils": { @@ -2976,7 +2977,6 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", "dev": true, - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" From e4d1d8fda1e14102baeea732212436bac93e31c8 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 3 Apr 2025 15:25:35 -0700 Subject: [PATCH 45/53] readme for publishing --- packages/config-yaml/package.json | 2 +- packages/config-yaml/src/README.md | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index d7d96c4f0..703632362 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.67", + "version": "1.0.71", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-yaml/src/README.md b/packages/config-yaml/src/README.md index 4ef80cb49..550563891 100644 --- a/packages/config-yaml/src/README.md +++ b/packages/config-yaml/src/README.md @@ -15,3 +15,14 @@ This happens on the server, unless using local mode. ## Client rendering The unrolled config.yaml is then rendered on the client. This is done by replacing all user secret template variables with their values and replacing all other secrets with secret locations. + +## Publishing + +First, bump the version in `package.json` and then run: + +```bash +npm run build +npm publish --access public +``` + +Make sure you have an `NPM_TOKEN` set in your `packages/config-yaml/.env` file. From 8efb3be1b1f2253f9a7fd3035d8f0055de8f426e Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 15:25:49 -0700 Subject: [PATCH 46/53] fix: dependencies --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index 0287c2611..759c4705c 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.68", + "@continuedev/config-yaml": "^1.0.71", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", From 07bf42548cd75ce59f35055fd93e802e8025ffdb Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 3 Apr 2025 15:28:49 -0700 Subject: [PATCH 47/53] bump version --- core/package-lock.json | 14 ++++++++++---- core/package.json | 2 +- gui/package-lock.json | 11 ++++++----- gui/package.json | 2 +- packages/config-yaml/src/README.md | 6 +++--- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 50df2a6f3..41257b92f 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.71", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -32,6 +32,7 @@ "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", + "filtrex": "^3.1.0", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", @@ -2974,9 +2975,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.67", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", - "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", + "version": "1.0.71", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.71.tgz", + "integrity": "sha512-c7KVaYfldaYHf2EqeqE9Oo1son33iTp6MAY+WRPJVs9XWmRWOA6Cn7YDf575FpwX6UsPCT/Eb0JJme8AC7UE6g==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", @@ -8585,6 +8586,11 @@ "node": ">=8" } }, + "node_modules/filtrex": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/filtrex/-/filtrex-3.1.0.tgz", + "integrity": "sha512-mHzZ2wUISETF1OaEcNRiGz1ljuIV8c/C9td9qyAZ+wTwigkAk5RO9YrCxQKk5H9v7joDRFIBik9U5RTK9eXZ/A==" + }, "node_modules/find-replace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", diff --git a/core/package.json b/core/package.json index d709d6b8c..759c4705c 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.71", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/gui/package-lock.json b/gui/package-lock.json index e963d2cf2..025b11b27 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.71", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -111,7 +111,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "file:../packages/config-yaml/dist", + "@continuedev/config-yaml": "^1.0.71", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -130,6 +130,7 @@ "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", + "filtrex": "^3.1.0", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", @@ -554,9 +555,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.67", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", - "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", + "version": "1.0.71", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.71.tgz", + "integrity": "sha512-c7KVaYfldaYHf2EqeqE9Oo1son33iTp6MAY+WRPJVs9XWmRWOA6Cn7YDf575FpwX6UsPCT/Eb0JJme8AC7UE6g==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/gui/package.json b/gui/package.json index 3210a55f5..fa4b439af 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.71", "@headlessui/react": "^2.2.0", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", diff --git a/packages/config-yaml/src/README.md b/packages/config-yaml/src/README.md index 550563891..c68cd8fdc 100644 --- a/packages/config-yaml/src/README.md +++ b/packages/config-yaml/src/README.md @@ -18,11 +18,11 @@ The unrolled config.yaml is then rendered on the client. This is done by replaci ## Publishing -First, bump the version in `package.json` and then run: +Make sure you are logged into the npm registry with `npm login`. + +Then, bump the version in `package.json` and then run: ```bash npm run build npm publish --access public ``` - -Make sure you have an `NPM_TOKEN` set in your `packages/config-yaml/.env` file. From 93c93a871fde3d5db1fabbef3c31632b6a7e49d8 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 15:42:38 -0700 Subject: [PATCH 48/53] fix: node modules eslint --- extensions/vscode/.eslintrc.json | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/vscode/.eslintrc.json b/extensions/vscode/.eslintrc.json index f4973fa87..3bf3ca621 100644 --- a/extensions/vscode/.eslintrc.json +++ b/extensions/vscode/.eslintrc.json @@ -4,6 +4,7 @@ "project": "./tsconfig.json" }, "extends": ["../../.eslintrc.shared.json"], + "ignorePatterns": ["**/node_modules/**", "dist/**"], "rules": { "@typescript-eslint/naming-convention": "off" } From 648829fe007e9c5cf8ea8b7c22444817be8a8c69 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 15:46:51 -0700 Subject: [PATCH 49/53] Revert "fix: node modules eslint" This reverts commit 93c93a871fde3d5db1fabbef3c31632b6a7e49d8. --- extensions/vscode/.eslintrc.json | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/vscode/.eslintrc.json b/extensions/vscode/.eslintrc.json index 3bf3ca621..f4973fa87 100644 --- a/extensions/vscode/.eslintrc.json +++ b/extensions/vscode/.eslintrc.json @@ -4,7 +4,6 @@ "project": "./tsconfig.json" }, "extends": ["../../.eslintrc.shared.json"], - "ignorePatterns": ["**/node_modules/**", "dist/**"], "rules": { "@typescript-eslint/naming-convention": "off" } From 384fb562e5aac023301d592a186982a4b575fe98 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 15:47:12 -0700 Subject: [PATCH 50/53] fix: dependencies --- binary/package-lock.json | 3 ++- extensions/vscode/package-lock.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/binary/package-lock.json b/binary/package-lock.json index d1c773550..087f976bb 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -48,7 +48,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.67", + "@continuedev/config-yaml": "^1.0.71", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -67,6 +67,7 @@ "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", + "filtrex": "^3.1.0", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 699444702..9e01ab495 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -106,7 +106,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "file:../packages/config-yaml/dist", + "@continuedev/config-yaml": "^1.0.71", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -125,6 +125,7 @@ "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", + "filtrex": "^3.1.0", "follow-redirects": "^1.15.5", "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", From e83cd625eee9c2dc46a3868b0a8d2cea8e9da177 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 15:48:11 -0700 Subject: [PATCH 51/53] fix: tsconfig --- extensions/vscode/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/tsconfig.json b/extensions/vscode/tsconfig.json index b35899669..b353eb71f 100644 --- a/extensions/vscode/tsconfig.json +++ b/extensions/vscode/tsconfig.json @@ -17,6 +17,7 @@ "../../core/dist/**/*", "../../core/**/*.test.ts", "../../core/**/test/**/*", - "../../core/**/*.skip.ts" + "../../core/**/*.skip.ts", + "../../core/node_modules/**/*" ] } From c73c388e10f03893efbb6b743630ee89d4842150 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 15:48:59 -0700 Subject: [PATCH 52/53] Revert "fix: tsconfig" This reverts commit e83cd625eee9c2dc46a3868b0a8d2cea8e9da177. --- extensions/vscode/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/vscode/tsconfig.json b/extensions/vscode/tsconfig.json index b353eb71f..b35899669 100644 --- a/extensions/vscode/tsconfig.json +++ b/extensions/vscode/tsconfig.json @@ -17,7 +17,6 @@ "../../core/dist/**/*", "../../core/**/*.test.ts", "../../core/**/test/**/*", - "../../core/**/*.skip.ts", - "../../core/node_modules/**/*" + "../../core/**/*.skip.ts" ] } From 8549981e200e7e62f4a5895babc1c87c45b59db0 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Apr 2025 15:51:17 -0700 Subject: [PATCH 53/53] fix: tsconfig --- extensions/vscode/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/vscode/tsconfig.json b/extensions/vscode/tsconfig.json index b35899669..a7a58f894 100644 --- a/extensions/vscode/tsconfig.json +++ b/extensions/vscode/tsconfig.json @@ -9,6 +9,7 @@ "strict": true, "esModuleInterop": true, "resolveJsonModule": true, + "skipLibCheck": true, "types": ["mocha"] // This solves conflict between jest and mocha: https://github.com/cypress-io/cypress/issues/7435#issuecomment-631695007 }, "include": ["src/**/*", "../../core/**/*.ts", "../../core/**/*.d.ts"],