Merge branch 'main' into pe/remove-tools

This commit is contained in:
Patrick Erichsen 2025-03-12 11:54:54 -07:00
commit 9bdf5f8567
24 changed files with 189 additions and 88 deletions

2
.gitignore vendored
View file

@ -169,4 +169,4 @@ extensions/.continue-debug/
*.vsix
.continuerules
.continue/assistants/
**/.continue/assistants/

View file

@ -16,7 +16,7 @@ import {
import Ollama from "../llm/llms/Ollama.js";
import { GlobalContext } from "../util/GlobalContext.js";
import { getAllAssistantFiles } from "./getSystemPromptDotFile.js";
import { getAllAssistantFiles } from "./loadLocalAssistants.js";
import {
LOCAL_ONBOARDING_CHAT_MODEL,
LOCAL_ONBOARDING_PROVIDER_TITLE,
@ -50,6 +50,7 @@ export class ConfigHandler {
private ideSettingsPromise: Promise<IdeSettings>,
private readonly writeLog: (text: string) => Promise<void>,
sessionInfoPromise: Promise<ControlPlaneSessionInfo | undefined>,
private readonly didSelectOrganization?: (orgId: string | null) => void,
) {
this.ide = ide;
this.ideSettingsPromise = ideSettingsPromise;
@ -114,12 +115,6 @@ export class ConfigHandler {
}
private async init() {
try {
await this.loadLocalProfilesOnly();
} catch (e) {
console.error("Failed to load local assistants: ", e);
}
try {
await this.fetchControlPlaneProfiles();
} catch (e) {
@ -346,7 +341,8 @@ export class ConfigHandler {
async getSelectedOrgId(): Promise<string | null> {
const selectedOrgs =
this.globalContext.get("lastSelectedOrgIdForWorkspace") ?? {};
return selectedOrgs[await this.getWorkspaceId()] ?? null;
const workspaceId = await this.getWorkspaceId();
return selectedOrgs[workspaceId] ?? null;
}
async setSelectedOrgId(orgId: string | null) {
@ -354,9 +350,13 @@ export class ConfigHandler {
this.globalContext.get("lastSelectedOrgIdForWorkspace") ?? {};
selectedOrgs[await this.getWorkspaceId()] = orgId;
this.globalContext.update("lastSelectedOrgIdForWorkspace", selectedOrgs);
this.didSelectOrganization?.(orgId);
}
async setSelectedProfile(profileId: string | null) {
console.log(
`Changing selected profile from ${this.selectedProfileId} to ${profileId}`,
);
this.selectedProfileId = profileId;
const result = await this.loadConfig();
this.notifyConfigListeners(result);
@ -388,6 +388,17 @@ export class ConfigHandler {
Promise.resolve(sessionInfo),
this.ideSettingsPromise,
);
// After login, default to the first org as the selected org
try {
const orgs = await this.controlPlaneClient.listOrganizations();
if (orgs.length) {
await this.setSelectedOrgId(orgs[0].id);
}
} catch (e) {
console.error("Failed to fetch control plane profiles: ", e);
}
this.fetchControlPlaneProfiles().catch(async (e) => {
console.error("Failed to fetch control plane profiles: ", e);
await this.loadLocalProfilesOnly();

View file

@ -1,7 +1,4 @@
import { IDE } from "..";
import { walkDir } from "../indexing/walkDir";
import { getGlobalAssistantsPath } from "../util/paths";
import { localPathToUri } from "../util/pathToUri";
import { joinPathsToUri } from "../util/uri";
export const SYSTEM_PROMPT_DOT_FILE = ".continuerules";
@ -27,56 +24,3 @@ export async function getSystemPromptDotFile(ide: IDE): Promise<string | null> {
return prompts.join("\n\n");
}
export const ASSISTANTS_FOLDER = ".continue/assistants";
export async function getAssistantFilesFromDir(
ide: IDE,
dir: string,
): Promise<{ path: string; content: string }[]> {
try {
const exists = await ide.fileExists(dir);
if (!exists) {
return [];
}
const uris = await walkDir(dir, ide);
const assistantFilePaths = uris.filter(
(p) => p.endsWith(".yaml") || p.endsWith(".yml"),
);
const results = assistantFilePaths.map(async (uri) => {
const content = await ide.readFile(uri); // make a try catch
return { path: uri, content };
});
return Promise.all(results);
} catch (e) {
console.error(e);
return [];
}
}
export async function getAllAssistantFiles(
ide: IDE,
): Promise<{ path: string; content: string }[]> {
const workspaceDirs = await ide.getWorkspaceDirs();
let assistantFiles: { path: string; content: string }[] = [];
let dirsToCheck = [ASSISTANTS_FOLDER];
const fullDirs = workspaceDirs
.map((dir) => dirsToCheck.map((d) => joinPathsToUri(dir, d)))
.flat();
fullDirs.push(localPathToUri(getGlobalAssistantsPath()));
assistantFiles = (
await Promise.all(fullDirs.map((dir) => getAssistantFilesFromDir(ide, dir)))
).flat();
return await Promise.all(
assistantFiles.map(async (file) => {
const content = await ide.readFile(file.path);
return { path: file.path, content };
}),
);
}

View file

@ -0,0 +1,76 @@
import ignore from "ignore";
import { IDE } from "..";
import {
DEFAULT_IGNORE_DIRS,
DEFAULT_IGNORE_FILETYPES,
} from "../indexing/ignore";
import { walkDir } from "../indexing/walkDir";
import { getGlobalAssistantsPath } from "../util/paths";
import { localPathToUri } from "../util/pathToUri";
import { joinPathsToUri } from "../util/uri";
export const ASSISTANTS_FOLDER = ".continue/assistants";
export function isLocalAssistantFile(uri: string): boolean {
if (!uri.endsWith(".yaml") && !uri.endsWith(".yml")) {
return false;
}
const normalizedUri = uri.replace(/\\/g, "/");
return normalizedUri.includes(`/${ASSISTANTS_FOLDER}/`);
}
export async function getAssistantFilesFromDir(
ide: IDE,
dir: string,
): Promise<{ path: string; content: string }[]> {
try {
const exists = await ide.fileExists(dir);
if (!exists) {
return [];
}
const overrideIgnore = ignore()
.add(DEFAULT_IGNORE_FILETYPES.filter((t) => t !== "config.yaml"))
.add(DEFAULT_IGNORE_DIRS);
const uris = await walkDir(dir, ide, { overrideIgnore });
const assistantFilePaths = uris.filter(
(p) => p.endsWith(".yaml") || p.endsWith(".yml"),
);
const results = assistantFilePaths.map(async (uri) => {
const content = await ide.readFile(uri); // make a try catch
return { path: uri, content };
});
return Promise.all(results);
} catch (e) {
console.error(e);
return [];
}
}
export async function getAllAssistantFiles(
ide: IDE,
): Promise<{ path: string; content: string }[]> {
const workspaceDirs = await ide.getWorkspaceDirs();
let assistantFiles: { path: string; content: string }[] = [];
let dirsToCheck = [ASSISTANTS_FOLDER];
const fullDirs = workspaceDirs
.map((dir) => dirsToCheck.map((d) => joinPathsToUri(dir, d)))
.flat();
fullDirs.push(localPathToUri(getGlobalAssistantsPath()));
assistantFiles = (
await Promise.all(fullDirs.map((dir) => getAssistantFilesFromDir(ide, dir)))
).flat();
return await Promise.all(
assistantFiles.map(async (file) => {
const content = await ide.readFile(file.path);
return { path: file.path, content };
}),
);
}

View file

@ -6,6 +6,7 @@ import { ProfileDescription } from "../ProfileLifecycleManager.js";
import { getPrimaryConfigFilePath } from "../../util/paths.js";
import { localPathToUri } from "../../util/pathToUri.js";
import { getUriPathBasename } from "../../util/uri.js";
import doLoadConfig from "./doLoadConfig.js";
import { IProfileLoader } from "./IProfileLoader.js";
@ -30,7 +31,9 @@ export default class LocalProfileLoader implements IProfileLoader {
versionSlug: "",
},
iconUrl: "",
title: overrideAssistantFile?.path ?? "Local Config",
title: overrideAssistantFile?.path
? getUriPathBasename(overrideAssistantFile.path)
: "Local Assistant",
errors: undefined,
uri:
overrideAssistantFile?.path ??

View file

@ -1,4 +1,4 @@
import { ModelConfig, AssistantUnrolled } from "@continuedev/config-yaml";
import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml";
import { SerializedContinueConfig } from "../..";
@ -6,7 +6,7 @@ export function convertConfigJsonToConfigYaml(
configJson: SerializedContinueConfig,
): AssistantUnrolled {
return {
name: "Local Config",
name: "Local Assistant",
version: "1.0.0",
models: [
...configJson.models.map(

View file

@ -4,13 +4,13 @@ import { AssistantUnrolled } from "@continuedev/config-yaml";
export const defaultConfigYaml: AssistantUnrolled = {
models: [],
context: [],
name: "Local Config",
name: "Local Assistant",
version: "1.0.0",
};
export const defaultConfigYamlJetBrains: AssistantUnrolled = {
models: [],
context: [],
name: "Local Config",
name: "Local Assistant",
version: "1.0.0",
};

View file

@ -35,8 +35,10 @@ async function modelConfigToBaseLLM(
return undefined;
}
const { capabilities, ...rest } = model;
let options: LLMOptions = {
...model,
...rest,
completionOptions: {
...(model.defaultCompletionOptions ?? {}),
model: model.model,
@ -55,6 +57,22 @@ async function modelConfigToBaseLLM(
},
};
// Model capabilities - need to be undefined if not found
// To fallback to our autodetection
if (capabilities?.find((c) => c === "tool_use")) {
options.capabilities = {
...options.capabilities,
tools: true,
};
}
if (capabilities?.find((c) => c === "image_input")) {
options.capabilities = {
...options.capabilities,
uploadImage: true,
};
}
if (model.embedOptions?.maxBatchSize) {
options.maxEmbeddingBatchSize = model.embedOptions.maxBatchSize;
}

View file

@ -44,6 +44,7 @@ import {
type IndexingProgressUpdate,
} from ".";
import { isLocalAssistantFile } from "./config/loadLocalAssistants";
import { shouldIgnore } from "./indexing/shouldIgnore";
import type { FromCoreProtocol, ToCoreProtocol } from "./protocol";
import type { IMessenger, Message } from "./protocol/messenger";
@ -106,6 +107,11 @@ export class Core {
ideSettingsPromise,
this.onWrite,
sessionInfoPromise,
(orgId: string | null) => {
void messenger.request("didSelectOrganization", {
orgId,
});
},
);
this.docsService = DocsService.createSingleton(
@ -294,8 +300,11 @@ export class Core {
this.configHandler.updateIdeSettings(msg.data);
});
on("config/listProfiles", (msg) => {
return this.configHandler.listProfiles();
on("config/listProfiles", async (msg) => {
const profiles = this.configHandler.listProfiles();
const selectedProfileId =
this.configHandler.currentProfile?.profileDescription.id ?? null;
return { profiles, selectedProfileId };
});
on("config/refreshProfiles", async (msg) => {
@ -926,6 +935,13 @@ export class Core {
on("files/created", async ({ data }) => {
if (data?.uris?.length) {
void refreshIfNotIgnored(data.uris);
// If it's a local assistant being created, we want to reload all assistants so it shows up in the list
for (const uri of data.uris) {
if (isLocalAssistantFile(uri)) {
await this.configHandler.loadAssistantsForSelectedOrg();
}
}
}
});

View file

@ -12,6 +12,7 @@ import {
export interface WalkerOptions {
onlyDirs?: boolean;
returnRelativeUrisPaths?: boolean;
overrideIgnore?: Ignore;
}
type Entry = [string, FileType];
@ -46,7 +47,7 @@ class DFSWalker {
// walk is a depth-first search implementation
public async *walk(): AsyncGenerator<string> {
const defaultAndGlobalIgnores = ignore()
.add(defaultIgnoreFileAndDir)
.add(this.options.overrideIgnore ?? defaultIgnoreFileAndDir)
.add(getGlobalContinueIgArray());
const rootContext: WalkContext = {

View file

@ -68,7 +68,10 @@ export type ToCoreFromIdeOrWebviewProtocol = {
"config/deleteModel": [{ title: string }, void];
"config/addContextProvider": [ContextProviderWithParams, void];
"config/reload": [undefined, ConfigResult<BrowserSerializedContinueConfig>];
"config/listProfiles": [undefined, ProfileDescription[] | null];
"config/listProfiles": [
undefined,
{ profiles: ProfileDescription[] | null; selectedProfileId: string | null },
];
"config/refreshProfiles": [undefined, void];
"config/openProfile": [{ profileId: string | undefined }, void];
"config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema];

View file

@ -15,4 +15,5 @@ export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol & {
{ profiles: ProfileDescription[]; selectedProfileId: string | null },
void,
];
didSelectOrganization: [{ orgId: string | null }, void];
};

View file

@ -85,4 +85,5 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] =
"getCurrentSessionId",
"docs/suggestions",
"didCloseFiles",
"didSelectOrganization",
];

View file

@ -36,6 +36,7 @@ Each model has specific configuration options tailored to its provider and funct
- `engine`: Engine for Azure OpenAI requests.
- `capabilities`: Override auto-detected capabilities:
- `uploadImage`: Boolean indicating if the model supports image uploads.
- `tools`: Boolean indicating if the model supports tool calls.
_(AWS Only)_

View file

@ -134,6 +134,7 @@ The `models` section defines the language models used in your configuration. Mod
- `provider` (**required**): The provider of the model (e.g., `openai`, `ollama`).
- `model` (**required**): The specific model name (e.g., `gpt-4`, `starcoder`).
- `roles`: An array specifying the roles this model can fulfill, such as `chat`, `autocomplete`, `embed`, `rerank`, `edit`, `apply`, `summarize`. The default value is `[chat, edit, apply, summarize]`. Note that the `summarize` role is not currently used.
- `capabilities`: Array of strings denoting model capabilities, which will overwrite Continue's autodetection based on provider and model. Supported capabilities include `tool_use` and `image_input`.
- `embedOptions`: If the model includes role `embed`, these settings apply for embeddings:
- `maxChunkSize`: Maximum tokens per document chunk. Minimum is 128 tokens.
@ -187,6 +188,17 @@ models:
model: codestral-latest
roles:
- autocomplete
- name: My Model - OpenAI-Compatible
provider: openai
apiBase: http://my-endpoint/v1
model: my-custom-model
capabilities:
- tool_use
- image_input
roles:
- chat
- edit
```
---

View file

@ -72,6 +72,7 @@ class MessageTypes {
"getCurrentSessionId",
"docs/suggestions",
"didCloseFiles",
"didSelectOrganization"
)
// Note: If updating these values, make a corresponding update in

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "1.1.7",
"version": "1.1.8",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "1.1.7",
"version": "1.1.8",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/fetch": "^1.0.3",

8
gui/package-lock.json generated
View file

@ -7,7 +7,7 @@
"name": "gui",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-yaml": "^1.0.58",
"@continuedev/config-yaml": "^1.0.56",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",
@ -555,9 +555,9 @@
}
},
"node_modules/@continuedev/config-yaml": {
"version": "1.0.58",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.58.tgz",
"integrity": "sha512-SvIeEUwitG0Jt2gBa5J8wS4UJPTi+DttezBtS+MEJ+K6A8WCuP58XEAHVj5fwjz6am3mKelWyGYWawnNHYY72A==",
"version": "1.0.56",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.56.tgz",
"integrity": "sha512-2OBhmlSFOgZ+Z/ZQ18R/JR9zo6HIzkQ09PCuHQQ9NanN+g5AEVCdWgEtMyOq5DmQM3HLJCoLMXwqzQ9qSJEfFg==",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",

View file

@ -15,7 +15,7 @@
"test:watch": "vitest"
},
"dependencies": {
"@continuedev/config-yaml": "^1.0.58",
"@continuedev/config-yaml": "^1.0.56",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",

View file

@ -168,8 +168,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
if (result.status === "success") {
dispatch(
updateProfilesThunk({
profiles: result.content,
selectedProfileId: null,
profiles: result.content.profiles,
selectedProfileId: result.content.selectedProfileId,
}),
);
}

View file

@ -5,6 +5,7 @@ import {
UserCircleIcon,
} from "@heroicons/react/24/outline";
import { useAuth } from "../../context/Auth";
import { useWebviewListener } from "../../hooks/useWebviewListener";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import { selectOrgThunk } from "../../redux/thunks/profileAndOrg";
@ -19,6 +20,10 @@ export function ScopeSelect() {
dispatch(selectOrgThunk(newValue));
};
useWebviewListener("didSelectOrganization", async (data) => {
handleChange(data.orgId);
});
const CurScopeEntityFallBackIcon = selectedOrgId
? BuildingOfficeIcon
: UserCircleIcon;

View file

@ -88,9 +88,8 @@ export const uiSlice = createSlice({
state.useTools = !state.useTools;
},
addTool: (state, action: PayloadAction<Tool>) => {
state.toolSettings[action.payload.function.name] = action.payload.readonly
? "allowedWithoutPermission"
: "allowedWithPermission";
state.toolSettings[action.payload.function.name] =
"allowedWithPermission";
},
toggleToolSetting: (state, action: PayloadAction<string>) => {
const setting = state.toolSettings[action.payload];

View file

@ -1,6 +1,6 @@
{
"name": "@continuedev/config-yaml",
"version": "1.0.58",
"version": "1.0.56",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View file

@ -31,6 +31,14 @@ export const modelRolesSchema = z.enum([
]);
export type ModelRole = z.infer<typeof modelRolesSchema>;
// TODO consider just using array of strings for model capabilities
// To allow more dynamic string parsing
export const modelCapabilitySchema = z.union([
z.literal("tool_use"),
z.literal("image_input"),
]);
export type ModelCapability = z.infer<typeof modelCapabilitySchema>;
export const completionOptionsSchema = z.object({
contextLength: z.number().optional(),
maxTokens: z.number().optional(),
@ -61,6 +69,7 @@ const baseModelFields = {
apiKey: z.string().optional(),
apiBase: z.string().optional(),
roles: modelRolesSchema.array().optional(),
capabilities: modelCapabilitySchema.array().optional(),
defaultCompletionOptions: completionOptionsSchema.optional(),
requestOptions: requestOptionsSchema.optional(),
embedOptions: embedOptionsSchema.optional(),