Merge branch 'main' into feat/Improve-init-and-loading
This commit is contained in:
commit
6d47951ced
309 changed files with 7871 additions and 7772 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -157,11 +157,15 @@ Icon?
|
|||
notes.md
|
||||
|
||||
manual-testing-sandbox/.idea/**
|
||||
manual-testing-sandbox/.continue/**
|
||||
extensions/intellij/.idea/**
|
||||
|
||||
**/.idea/workspace.xml
|
||||
**/.idea/usage.statistics.xml
|
||||
**/.idea/shelf/
|
||||
**/.idea/inspectionProfiles/Project_Default.xml
|
||||
**/.idea/php.xml
|
||||
|
||||
|
||||
extensions/intellij/bin
|
||||
extensions/.continue-debug/
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
- [Writing Context Providers](#writing-context-providers)
|
||||
- [Adding an LLM Provider](#adding-an-llm-provider)
|
||||
- [Adding Models](#adding-models)
|
||||
- [Adding Pre-indexed Documentation](#adding-pre-indexed-documentation)
|
||||
- [📐 Continue Architecture](#-continue-architecture)
|
||||
- [Continue VS Code Extension](#continue-vs-code-extension)
|
||||
- [Continue JetBrains Extension](#continue-jetbrains-extension)
|
||||
|
|
@ -212,10 +211,6 @@ While any model that works with a supported provider can be used with Continue,
|
|||
- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Replicate](https://replicate.com/collections/streaming-language-models).
|
||||
- [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates.
|
||||
|
||||
### Adding Pre-indexed Documentation
|
||||
|
||||
Continue's @docs context provider lets you easily reference entire documentation sites and then uses embeddings to add the most relevant pages to context. To make the experience as smooth as possible, we pre-index many of the most popular documentation sites. If you'd like to add new documentation to this list, just add an object to the list in [preIndexedDocs.ts](./core/indexing/docs/preIndexedDocs.ts). `startUrl` is where the crawler will start and `rootUrl` will filter out any pages not on that site and under the path of `rootUrl`.
|
||||
|
||||
## 📐 Continue Architecture
|
||||
|
||||
Continue consists of 2 parts that are split so that it can be extended to work in other IDEs as easily as possible:
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
fs.mkdirSync(targetDir, { recursive: true });
|
||||
console.log(`[info] Building ${target}...`);
|
||||
execCmdSync(
|
||||
`npx pkg --no-bytecode --public-packages "*" --public pkgJson/${target} --out-path ${targetDir}`,
|
||||
`npx pkg --no-bytecode --public-packages "*" --public --compress GZip pkgJson/${target} --out-path ${targetDir}`,
|
||||
);
|
||||
|
||||
// Download and unzip prebuilt sqlite3 binary for the target
|
||||
|
|
|
|||
2
binary/package-lock.json
generated
2
binary/package-lock.json
generated
|
|
@ -51,7 +51,7 @@
|
|||
"@continuedev/config-yaml": "^1.0.63",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
"@continuedev/openai-adapters": "^1.0.18",
|
||||
"@modelcontextprotocol/sdk": "^1.5.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"eqeqeq": "error",
|
||||
"complexity": ["error", { "max": 38 }],
|
||||
"max-lines-per-function": ["error", { "max": 996 }],
|
||||
"max-statements": ["error", { "max": 112 }],
|
||||
"max-statements": ["error", { "max": 114 }],
|
||||
"max-depth": ["error", { "max": 6 }],
|
||||
"max-nested-callbacks": ["error", { "max": 4 }],
|
||||
"max-params": ["error", { "max": 11 }]
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {
|
|||
getParserForFile,
|
||||
getQueryForFile,
|
||||
} from "../../util/treeSitter";
|
||||
import { findUriInDirs } from "../../util/uri";
|
||||
|
||||
interface FileInfo {
|
||||
imports: { [key: string]: RangeInFileWithContents[] };
|
||||
|
|
@ -44,7 +45,15 @@ export class ImportDefinitionsService {
|
|||
|
||||
let fileContents: string | undefined = undefined;
|
||||
try {
|
||||
fileContents = await this.ide.readFile(filepath);
|
||||
const { foundInDir } = findUriInDirs(
|
||||
filepath,
|
||||
await this.ide.getWorkspaceDirs(),
|
||||
);
|
||||
if (!foundInDir) {
|
||||
return null;
|
||||
} else {
|
||||
fileContents = await this.ide.readFile(filepath);
|
||||
}
|
||||
} catch (err) {
|
||||
// File removed
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ export function slashFromCustomCommand(
|
|||
return {
|
||||
name: customCommand.name,
|
||||
description: customCommand.description ?? "",
|
||||
prompt: customCommand.prompt,
|
||||
run: async function* ({ input, llm, history, ide, completionOptions }) {
|
||||
// Remove slash command prefix from input
|
||||
let userInput = input;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
import { ContextItemWithId, RangeInFileWithContents } from "../";
|
||||
import { findUriInDirs, getUriPathBasename } from "../util/uri";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
export function rifWithContentsToContextItem(
|
||||
rif: RangeInFileWithContents,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ describe.skip("Test the ConfigHandler and E2E config loading", () => {
|
|||
|
||||
test("should load the default config successfully", async () => {
|
||||
const result = await testConfigHandler.loadConfig();
|
||||
expect(result.config!.models.length).toBe(defaultConfig.models.length);
|
||||
expect(result.config!.models.length).toBe(defaultConfig.models?.length);
|
||||
});
|
||||
|
||||
test.skip("should add a system message from config.ts", async () => {
|
||||
|
|
|
|||
|
|
@ -199,8 +199,8 @@ export class ConfigHandler {
|
|||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
this.writeLog,
|
||||
this.reloadConfig.bind(this),
|
||||
assistant.rawYaml,
|
||||
selectedOrgId,
|
||||
);
|
||||
|
||||
return new ProfileLifecycleManager(profileLoader, this.ide);
|
||||
|
|
|
|||
|
|
@ -1,93 +1,37 @@
|
|||
import {
|
||||
ContextProviderWithParams,
|
||||
ModelDescription,
|
||||
SerializedContinueConfig,
|
||||
SlashCommandDescription,
|
||||
} from "../";
|
||||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
|
||||
export const FREE_TRIAL_MODELS: ModelDescription[] = [
|
||||
{
|
||||
title: "Claude 3.5 Sonnet (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "GPT-4o (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-4o",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "Llama3.1 70b (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "llama3.1-70b",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "Codestral (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "codestral-latest",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
export const defaultContextProvidersVsCode: NonNullable<
|
||||
ConfigYaml["context"]
|
||||
>[number][] = [
|
||||
{ provider: "code" },
|
||||
{ provider: "docs" },
|
||||
{ provider: "diff" },
|
||||
{ provider: "terminal" },
|
||||
{ provider: "problems" },
|
||||
{ provider: "folder" },
|
||||
{ provider: "codebase" },
|
||||
];
|
||||
|
||||
export const defaultContextProvidersVsCode: ContextProviderWithParams[] = [
|
||||
{ name: "code", params: {} },
|
||||
{ name: "docs", params: {} },
|
||||
{ name: "diff", params: {} },
|
||||
{ name: "terminal", params: {} },
|
||||
{ name: "problems", params: {} },
|
||||
{ name: "folder", params: {} },
|
||||
{ name: "codebase", params: {} },
|
||||
export const defaultContextProvidersJetBrains: NonNullable<
|
||||
ConfigYaml["context"]
|
||||
>[number][] = [
|
||||
{ provider: "diff" },
|
||||
{ provider: "folder" },
|
||||
{ provider: "codebase" },
|
||||
];
|
||||
|
||||
export const defaultContextProvidersJetBrains: ContextProviderWithParams[] = [
|
||||
{ name: "diff", params: {} },
|
||||
{ name: "folder", params: {} },
|
||||
{ name: "codebase", params: {} },
|
||||
];
|
||||
|
||||
export const defaultSlashCommandsVscode: SlashCommandDescription[] = [
|
||||
{
|
||||
name: "share",
|
||||
description: "Export the current chat session to markdown",
|
||||
},
|
||||
{
|
||||
name: "cmd",
|
||||
description: "Generate a shell command",
|
||||
},
|
||||
{
|
||||
name: "commit",
|
||||
description: "Generate a git commit message",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultSlashCommandsJetBrains = [
|
||||
{
|
||||
name: "share",
|
||||
description: "Export the current chat session to markdown",
|
||||
},
|
||||
{
|
||||
name: "commit",
|
||||
description: "Generate a git commit message",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultConfig: SerializedContinueConfig = {
|
||||
export const defaultConfig: ConfigYaml = {
|
||||
name: "Local Assistant",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [],
|
||||
contextProviders: defaultContextProvidersVsCode,
|
||||
slashCommands: defaultSlashCommandsVscode,
|
||||
data: [],
|
||||
context: defaultContextProvidersVsCode,
|
||||
};
|
||||
|
||||
export const defaultConfigJetBrains: SerializedContinueConfig = {
|
||||
export const defaultConfigJetBrains: ConfigYaml = {
|
||||
name: "Local Assistant",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [],
|
||||
contextProviders: defaultContextProvidersJetBrains,
|
||||
slashCommands: defaultSlashCommandsJetBrains,
|
||||
data: [],
|
||||
context: defaultContextProvidersJetBrains,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import {
|
|||
IdeType,
|
||||
ILLM,
|
||||
LLMOptions,
|
||||
MCPOptions,
|
||||
ModelDescription,
|
||||
RerankerDescription,
|
||||
SerializedContinueConfig,
|
||||
|
|
@ -45,7 +44,6 @@ import ContinueProxyContextProvider from "../context/providers/ContinueProxyCont
|
|||
import CustomContextProviderClass from "../context/providers/CustomContextProvider";
|
||||
import FileContextProvider from "../context/providers/FileContextProvider";
|
||||
import { contextProviderClassFromName } from "../context/providers/index";
|
||||
import PromptFilesContextProvider from "../context/providers/PromptFilesContextProvider";
|
||||
import { useHub } from "../control-plane/env";
|
||||
import { allEmbeddingsProviders } from "../indexing/allEmbeddingsProviders";
|
||||
import { BaseLLM } from "../llm";
|
||||
|
|
@ -72,12 +70,6 @@ import {
|
|||
} from "../util/paths";
|
||||
import { localPathToUri } from "../util/pathToUri";
|
||||
|
||||
import {
|
||||
defaultContextProvidersJetBrains,
|
||||
defaultContextProvidersVsCode,
|
||||
defaultSlashCommandsJetBrains,
|
||||
defaultSlashCommandsVscode,
|
||||
} from "./default";
|
||||
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
||||
import { modifyAnyConfigWithSharedConfig } from "./sharedConfig";
|
||||
import { getModelByRole, isSupportedLanceDbCpuTargetForLinux } from "./util";
|
||||
|
|
@ -124,7 +116,7 @@ function loadSerializedConfig(
|
|||
let config: SerializedContinueConfig = overrideConfigJson!;
|
||||
if (!config) {
|
||||
try {
|
||||
config = resolveSerializedConfig(getConfigJsonPath(ideType));
|
||||
config = resolveSerializedConfig(getConfigJsonPath());
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to parse config.json: ${e}`);
|
||||
}
|
||||
|
|
@ -164,16 +156,6 @@ function loadSerializedConfig(
|
|||
);
|
||||
}
|
||||
|
||||
// Set defaults if undefined (this lets us keep config.json uncluttered for new users)
|
||||
config.contextProviders ??=
|
||||
ideType === "vscode"
|
||||
? [...defaultContextProvidersVsCode]
|
||||
: [...defaultContextProvidersJetBrains];
|
||||
config.slashCommands ??=
|
||||
ideType === "vscode"
|
||||
? [...defaultSlashCommandsVscode]
|
||||
: [...defaultSlashCommandsJetBrains];
|
||||
|
||||
if (os.platform() === "linux" && !isSupportedLanceDbCpuTargetForLinux(ide)) {
|
||||
config.disableIndexing = true;
|
||||
}
|
||||
|
|
@ -401,8 +383,6 @@ async function intermediateToFinalConfig(
|
|||
...(!config.disableIndexing
|
||||
? [new CodebaseContextProvider(codebaseContextParams)]
|
||||
: []),
|
||||
// Add prompt files provider if enabled
|
||||
...(loadPromptFiles ? [new PromptFilesContextProvider({})] : []),
|
||||
];
|
||||
|
||||
const DEFAULT_CONTEXT_PROVIDERS_TITLES = DEFAULT_CONTEXT_PROVIDERS.map(
|
||||
|
|
@ -520,7 +500,9 @@ async function intermediateToFinalConfig(
|
|||
...config,
|
||||
contextProviders,
|
||||
models,
|
||||
tools: allTools,
|
||||
tools: [...allTools],
|
||||
mcpServerStatuses: [],
|
||||
slashCommands: config.slashCommands ?? [],
|
||||
modelsByRole: {
|
||||
chat: models,
|
||||
edit: models,
|
||||
|
|
@ -541,53 +523,18 @@ async function intermediateToFinalConfig(
|
|||
},
|
||||
};
|
||||
|
||||
// Apply MCP if specified
|
||||
// Trigger MCP server refreshes (Config is reloaded again once connected!)
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
function getMcpId(options: MCPOptions) {
|
||||
return JSON.stringify(options);
|
||||
}
|
||||
if (config.experimental?.modelContextProtocolServers) {
|
||||
await mcpManager.removeUnusedConnections(
|
||||
config.experimental.modelContextProtocolServers.map(getMcpId),
|
||||
);
|
||||
}
|
||||
|
||||
if (config.experimental?.modelContextProtocolServers) {
|
||||
const abortController = new AbortController();
|
||||
const mcpConnectionTimeout = setTimeout(
|
||||
() => abortController.abort(),
|
||||
5000,
|
||||
);
|
||||
|
||||
await Promise.allSettled(
|
||||
config.experimental.modelContextProtocolServers?.map(
|
||||
async (server, index) => {
|
||||
try {
|
||||
const mcpId = getMcpId(server);
|
||||
const mcpConnection = mcpManager.createConnection(mcpId, server);
|
||||
await mcpConnection.modifyConfig(
|
||||
continueConfig,
|
||||
mcpId,
|
||||
abortController.signal,
|
||||
"MCP Server",
|
||||
server.faviconUrl,
|
||||
);
|
||||
} catch (e) {
|
||||
let errorMessage = "Failed to load MCP server";
|
||||
if (e instanceof Error) {
|
||||
errorMessage += ": " + e.message;
|
||||
}
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: errorMessage,
|
||||
});
|
||||
} finally {
|
||||
clearTimeout(mcpConnectionTimeout);
|
||||
}
|
||||
},
|
||||
) || [],
|
||||
);
|
||||
}
|
||||
mcpManager.setConnections(
|
||||
(config.experimental?.modelContextProtocolServers ?? []).map(
|
||||
(server, index) => ({
|
||||
id: `continue-mcp-server-${index + 1}`,
|
||||
name: `MCP Server`,
|
||||
...server,
|
||||
}),
|
||||
),
|
||||
false,
|
||||
);
|
||||
|
||||
// Handle experimental modelRole config values for apply and edit
|
||||
const inlineEditModel = getModelByRole(continueConfig, "inlineEdit")?.title;
|
||||
|
|
@ -667,11 +614,9 @@ async function finalToBrowserConfig(
|
|||
models: final.models.map(llmToSerializedModelDescription),
|
||||
systemMessage: final.systemMessage,
|
||||
completionOptions: final.completionOptions,
|
||||
slashCommands: final.slashCommands?.map((s) => ({
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
params: s.params, // TODO: is this why params aren't referenced properly by slash commands?
|
||||
})),
|
||||
slashCommands: final.slashCommands?.map(
|
||||
({ run, ...slashCommandDescription }) => slashCommandDescription,
|
||||
),
|
||||
contextProviders: final.contextProviders?.map((c) => c.description),
|
||||
disableIndexing: final.disableIndexing,
|
||||
disableSessionTitles: final.disableSessionTitles,
|
||||
|
|
@ -681,6 +626,7 @@ async function finalToBrowserConfig(
|
|||
rules: final.rules,
|
||||
docs: final.docs,
|
||||
tools: final.tools,
|
||||
mcpServerStatuses: final.mcpServerStatuses,
|
||||
tabAutocompleteOptions: final.tabAutocompleteOptions,
|
||||
usePlatform: await useHub(ide.getIdeSettings()),
|
||||
modelsByRole: Object.fromEntries(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { IDE } from "..";
|
||||
import { deduplicateArray } from "../util";
|
||||
import { GlobalContext } from "../util/GlobalContext";
|
||||
import { editConfigJson } from "../util/paths";
|
||||
import { resolveSerializedConfig } from "./load";
|
||||
import { SharedConfigSchema } from "./sharedConfig";
|
||||
|
||||
|
|
@ -196,11 +195,6 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void {
|
|||
|
||||
if (effected) {
|
||||
new GlobalContext().updateSharedConfig(shareConfigUpdates);
|
||||
editConfigJson(() => config);
|
||||
// void ide.showToast(
|
||||
// "warning",
|
||||
// "Migrated deprecated Continue JSON settings. Edit in the Settings Page",
|
||||
// );
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(`Migration: Failed to parse config.json: ${e}`);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { SerializedContinueConfig } from "../";
|
||||
|
||||
import { FREE_TRIAL_MODELS } from "./default";
|
||||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
|
||||
export const TRIAL_FIM_MODEL = "codestral-latest";
|
||||
export const LOCAL_ONBOARDING_PROVIDER_TITLE = "Ollama";
|
||||
|
|
@ -9,64 +7,46 @@ export const LOCAL_ONBOARDING_FIM_TITLE = "Qwen2.5-Coder 1.5B";
|
|||
export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b";
|
||||
export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B";
|
||||
export const LOCAL_ONBOARDING_EMBEDDINGS_MODEL = "nomic-embed-text:latest";
|
||||
export const LOCAL_ONBOARDING_EMBEDDINGS_TITLE = "Nomic Embed";
|
||||
|
||||
/**
|
||||
* We set the "best" chat + autocopmlete models by default
|
||||
* whenever a user doesn't have a config.json
|
||||
*/
|
||||
export function setupBestConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
export function setupBestConfig(config: ConfigYaml): ConfigYaml {
|
||||
return {
|
||||
...config,
|
||||
models: config.models.filter((model) => model.provider !== "free-trial"),
|
||||
models: config.models,
|
||||
};
|
||||
}
|
||||
|
||||
export function setupLocalConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
export function setupLocalConfig(config: ConfigYaml): ConfigYaml {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
{
|
||||
title: LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
name: LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
roles: ["chat", "edit", "apply"],
|
||||
},
|
||||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
{
|
||||
name: LOCAL_ONBOARDING_FIM_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_FIM_MODEL,
|
||||
roles: ["autocomplete"],
|
||||
},
|
||||
{
|
||||
name: LOCAL_ONBOARDING_EMBEDDINGS_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
|
||||
roles: ["embed"],
|
||||
},
|
||||
...(config.models ?? []),
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: LOCAL_ONBOARDING_FIM_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_FIM_MODEL,
|
||||
},
|
||||
embeddingsProvider: {
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function setupQuickstartConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
...FREE_TRIAL_MODELS,
|
||||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Tab Autocomplete",
|
||||
provider: "free-trial",
|
||||
model: TRIAL_FIM_MODEL,
|
||||
},
|
||||
embeddingsProvider: {
|
||||
provider: "free-trial",
|
||||
},
|
||||
reranker: {
|
||||
name: "free-trial",
|
||||
},
|
||||
};
|
||||
export function setupQuickstartConfig(config: ConfigYaml): ConfigYaml {
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { ConfigJson } from "@continuedev/config-types";
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { PRODUCTION_ENV } from "../../control-plane/env.js";
|
||||
import {
|
||||
ContinueConfig,
|
||||
IDE,
|
||||
|
|
@ -10,7 +11,6 @@ import {
|
|||
} from "../../index.js";
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
|
||||
import { PRODUCTION_ENV } from "../../control-plane/env.js";
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
|
|
@ -71,6 +71,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
|
|||
undefined,
|
||||
this.workspaceId,
|
||||
undefined,
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ export default class LocalProfileLoader implements IProfileLoader {
|
|||
undefined,
|
||||
this.description.id,
|
||||
this.overrideAssistantFile?.path,
|
||||
null,
|
||||
);
|
||||
|
||||
this.description.errors = result.errors;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import { AssistantUnrolled, ConfigResult } from "@continuedev/config-yaml";
|
||||
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { getControlPlaneEnv } from "../../control-plane/env.js";
|
||||
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
|
||||
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
|
||||
import { getControlPlaneEnv } from "../../control-plane/env.js";
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
|
|
@ -32,8 +31,8 @@ export default class PlatformProfileLoader implements IProfileLoader {
|
|||
private readonly ide: IDE,
|
||||
private ideSettingsPromise: Promise<IdeSettings>,
|
||||
private writeLog: (message: string) => Promise<void>,
|
||||
private readonly onReload: () => void,
|
||||
readonly description: ProfileDescription,
|
||||
private readonly orgScopeId: string | null,
|
||||
) {}
|
||||
|
||||
static async create(
|
||||
|
|
@ -46,8 +45,8 @@ export default class PlatformProfileLoader implements IProfileLoader {
|
|||
ide: IDE,
|
||||
ideSettingsPromise: Promise<IdeSettings>,
|
||||
writeLog: (message: string) => Promise<void>,
|
||||
onReload: () => void,
|
||||
rawYaml: string,
|
||||
orgScopeId: string | null,
|
||||
): Promise<PlatformProfileLoader> {
|
||||
const controlPlaneEnv = await getControlPlaneEnv(ideSettingsPromise);
|
||||
|
||||
|
|
@ -76,8 +75,8 @@ export default class PlatformProfileLoader implements IProfileLoader {
|
|||
ide,
|
||||
ideSettingsPromise,
|
||||
writeLog,
|
||||
onReload,
|
||||
description,
|
||||
orgScopeId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +102,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
|
|||
},
|
||||
this.description.id,
|
||||
undefined,
|
||||
this.orgScopeId,
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -6,18 +6,24 @@ import {
|
|||
ConfigValidationError,
|
||||
ModelRole,
|
||||
} from "@continuedev/config-yaml";
|
||||
|
||||
import {
|
||||
ContinueConfig,
|
||||
ContinueRcJson,
|
||||
IDE,
|
||||
IdeSettings,
|
||||
SerializedContinueConfig,
|
||||
Tool,
|
||||
} from "../../";
|
||||
import { constructMcpSlashCommand } from "../../commands/slash/mcp";
|
||||
import { MCPManagerSingleton } from "../../context/mcp";
|
||||
import MCPContextProvider from "../../context/providers/MCPContextProvider";
|
||||
import { ControlPlaneProxyInfo } from "../../control-plane/analytics/IAnalyticsProvider.js";
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { getControlPlaneEnv } from "../../control-plane/env.js";
|
||||
import { TeamAnalytics } from "../../control-plane/TeamAnalytics.js";
|
||||
import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
|
||||
import { encodeMCPToolUri } from "../../tools/callTool";
|
||||
import { getConfigJsonPath, getConfigYamlPath } from "../../util/paths";
|
||||
import { localPathOrUriToPath } from "../../util/pathToUri";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
|
|
@ -26,6 +32,7 @@ import { loadContinueConfigFromJson } from "../load";
|
|||
import { migrateJsonSharedConfig } from "../migrateSharedConfig";
|
||||
import { rectifySelectedModelsFromGlobalContext } from "../selectedModels";
|
||||
import { loadContinueConfigFromYaml } from "../yaml/loadYaml";
|
||||
|
||||
import { PlatformConfigMetadata } from "./PlatformProfileLoader";
|
||||
|
||||
export default async function doLoadConfig(
|
||||
|
|
@ -38,6 +45,7 @@ export default async function doLoadConfig(
|
|||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
profileId: string,
|
||||
overrideConfigYamlByPath: string | undefined,
|
||||
orgScopeId: string | null,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
const workspaceConfigs = await getWorkspaceConfigs(ide);
|
||||
const ideInfo = await ide.getIdeInfo();
|
||||
|
|
@ -47,7 +55,7 @@ export default async function doLoadConfig(
|
|||
|
||||
// Migrations for old config files
|
||||
// Removes
|
||||
const configJsonPath = getConfigJsonPath(ideInfo.ideType);
|
||||
const configJsonPath = getConfigJsonPath();
|
||||
if (fs.existsSync(configJsonPath)) {
|
||||
migrateJsonSharedConfig(configJsonPath, ide);
|
||||
}
|
||||
|
|
@ -63,7 +71,6 @@ export default async function doLoadConfig(
|
|||
if (overrideConfigYaml || fs.existsSync(configYamlPath)) {
|
||||
const result = await loadContinueConfigFromYaml(
|
||||
ide,
|
||||
workspaceConfigs.map((c) => JSON.stringify(c)),
|
||||
ideSettings,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
|
|
@ -73,6 +80,7 @@ export default async function doLoadConfig(
|
|||
platformConfigMetadata,
|
||||
controlPlaneClient,
|
||||
configYamlPath,
|
||||
orgScopeId,
|
||||
);
|
||||
newConfig = result.config;
|
||||
errors = result.errors;
|
||||
|
|
@ -93,15 +101,89 @@ export default async function doLoadConfig(
|
|||
configLoadInterrupted = result.configLoadInterrupted;
|
||||
}
|
||||
|
||||
// Rectify model selections for each role
|
||||
if (newConfig) {
|
||||
newConfig = rectifySelectedModelsFromGlobalContext(newConfig, profileId);
|
||||
}
|
||||
|
||||
if (configLoadInterrupted || !newConfig) {
|
||||
return { errors, config: newConfig, configLoadInterrupted: true };
|
||||
}
|
||||
|
||||
// TODO using config result but result with non-fatal errors is an antipattern?
|
||||
// Remove ability have undefined errors, just have an array
|
||||
errors = [...(errors ?? [])];
|
||||
|
||||
// Rectify model selections for each role
|
||||
newConfig = rectifySelectedModelsFromGlobalContext(newConfig, profileId);
|
||||
|
||||
// Add things from MCP servers
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
const mcpServerStatuses = mcpManager.getStatuses();
|
||||
|
||||
// Slightly hacky just need connection's client to make slash command for now
|
||||
const serializableStatuses = mcpServerStatuses.map((server) => {
|
||||
const { client, ...rest } = server;
|
||||
return rest;
|
||||
});
|
||||
newConfig.mcpServerStatuses = serializableStatuses;
|
||||
|
||||
for (const server of mcpServerStatuses) {
|
||||
if (server.status === "connected") {
|
||||
const serverTools: Tool[] = server.tools.map((tool) => ({
|
||||
displayTitle: server.name + " " + tool.name,
|
||||
function: {
|
||||
description: tool.description,
|
||||
name: tool.name,
|
||||
parameters: tool.inputSchema,
|
||||
},
|
||||
faviconUrl: server.faviconUrl,
|
||||
readonly: false,
|
||||
type: "function" as const,
|
||||
uri: encodeMCPToolUri(server.id, tool.name),
|
||||
group: server.name,
|
||||
}));
|
||||
newConfig.tools.push(...serverTools);
|
||||
|
||||
const serverSlashCommands = server.prompts.map((prompt) =>
|
||||
constructMcpSlashCommand(
|
||||
server.client,
|
||||
prompt.name,
|
||||
prompt.description,
|
||||
prompt.arguments?.map((a: any) => a.name),
|
||||
),
|
||||
);
|
||||
newConfig.slashCommands.push(...serverSlashCommands);
|
||||
|
||||
const submenuItems = server.resources.map((resource) => ({
|
||||
title: resource.name,
|
||||
description: resource.description ?? resource.name,
|
||||
id: resource.uri,
|
||||
icon: server.faviconUrl,
|
||||
}));
|
||||
if (submenuItems.length > 0) {
|
||||
const serverContextProvider = new MCPContextProvider({
|
||||
submenuItems,
|
||||
mcpId: server.id,
|
||||
});
|
||||
newConfig.contextProviders.push(serverContextProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Detect duplicate tool names
|
||||
const counts: Record<string, number> = {};
|
||||
newConfig.tools.forEach((tool) => {
|
||||
if (counts[tool.function.name]) {
|
||||
counts[tool.function.name] = counts[tool.function.name] + 1;
|
||||
} else {
|
||||
counts[tool.function.name] = 1;
|
||||
}
|
||||
});
|
||||
Object.entries(counts).forEach(([toolName, count]) => {
|
||||
if (count > 1) {
|
||||
errors!.push({
|
||||
fatal: false,
|
||||
message: `Duplicate (${count}) tools named "${toolName}" detected. Permissions will conflict and usage may be unpredictable`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
newConfig.allowAnonymousTelemetry =
|
||||
newConfig.allowAnonymousTelemetry && (await ide.isTelemetryEnabled());
|
||||
|
||||
|
|
|
|||
|
|
@ -2,17 +2,14 @@ import fs from "fs";
|
|||
import os from "os";
|
||||
|
||||
import {
|
||||
ContextProviderWithParams,
|
||||
ContinueConfig,
|
||||
ExperimentalModelRoles,
|
||||
IDE,
|
||||
ILLM,
|
||||
ModelDescription,
|
||||
ExperimentalModelRoles,
|
||||
} from "../";
|
||||
import { GlobalContext } from "../util/GlobalContext";
|
||||
import { editConfigJson } from "../util/paths";
|
||||
|
||||
import { ConfigHandler } from "./ConfigHandler";
|
||||
import { editConfigFile } from "../util/paths";
|
||||
|
||||
function stringify(obj: any, indentation?: number): string {
|
||||
return JSON.stringify(
|
||||
|
|
@ -24,78 +21,67 @@ function stringify(obj: any, indentation?: number): string {
|
|||
);
|
||||
}
|
||||
|
||||
export function addContextProvider(provider: ContextProviderWithParams, configHandler?: ConfigHandler) {
|
||||
let isAdded = false;
|
||||
editConfigJson((config) => {
|
||||
|
||||
if (!config.contextProviders) {
|
||||
config.contextProviders = [];
|
||||
}
|
||||
if (!config.contextProviders.some((p) => p.name === provider.name)) {
|
||||
config.contextProviders.push(provider);
|
||||
isAdded = true;
|
||||
}
|
||||
|
||||
return config;
|
||||
});
|
||||
|
||||
if (isAdded && configHandler) {
|
||||
void configHandler.reloadConfig();
|
||||
}
|
||||
}
|
||||
|
||||
export function addModel(
|
||||
model: ModelDescription,
|
||||
role?: keyof ExperimentalModelRoles,
|
||||
) {
|
||||
editConfigJson((config) => {
|
||||
if (config.models?.some((m: any) => stringify(m) === stringify(model))) {
|
||||
return config;
|
||||
}
|
||||
if (config.models?.some((m: any) => m?.title === model.title)) {
|
||||
model.title = `${model.title} (1)`;
|
||||
}
|
||||
|
||||
config.models.push(model);
|
||||
|
||||
// Set the role for the model
|
||||
if (role) {
|
||||
if (!config.experimental) {
|
||||
config.experimental = {};
|
||||
editConfigFile(
|
||||
(config) => {
|
||||
if (config.models?.some((m: any) => stringify(m) === stringify(model))) {
|
||||
return config;
|
||||
}
|
||||
if (!config.experimental.modelRoles) {
|
||||
config.experimental.modelRoles = {};
|
||||
if (config.models?.some((m: any) => m?.title === model.title)) {
|
||||
model.title = `${model.title} (1)`;
|
||||
}
|
||||
config.experimental.modelRoles[role] = model.title;
|
||||
}
|
||||
|
||||
return config;
|
||||
});
|
||||
}
|
||||
config.models.push(model);
|
||||
|
||||
export function addOpenAIKey(key: string) {
|
||||
editConfigJson((config) => {
|
||||
config.models = config.models
|
||||
.filter(
|
||||
(model) =>
|
||||
model.provider !== "free-trial" || model.model.startsWith("gpt"),
|
||||
)
|
||||
.map((m: ModelDescription) => {
|
||||
if (m.provider === "free-trial") {
|
||||
m.apiKey = key;
|
||||
m.provider = "openai";
|
||||
// Set the role for the model
|
||||
if (role) {
|
||||
if (!config.experimental) {
|
||||
config.experimental = {};
|
||||
}
|
||||
return m;
|
||||
if (!config.experimental.modelRoles) {
|
||||
config.experimental.modelRoles = {};
|
||||
}
|
||||
config.experimental.modelRoles[role] = model.title;
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
(config) => {
|
||||
if (config.models?.some((m: any) => m?.title === model.title)) {
|
||||
model.title = `${model.title} (1)`;
|
||||
}
|
||||
|
||||
if (!config.models) {
|
||||
config.models = [];
|
||||
}
|
||||
|
||||
config.models.push({
|
||||
name: model.title,
|
||||
provider: model.provider,
|
||||
model: model.model,
|
||||
apiKey: model.apiKey,
|
||||
apiBase: model.apiBase,
|
||||
defaultCompletionOptions: model.completionOptions,
|
||||
});
|
||||
return config;
|
||||
});
|
||||
return config;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteModel(title: string) {
|
||||
editConfigJson((config) => {
|
||||
config.models = config.models.filter((m: any) => m.title !== title);
|
||||
return config;
|
||||
});
|
||||
editConfigFile(
|
||||
(config) => {
|
||||
config.models = config.models.filter((m: any) => m.title !== title);
|
||||
return config;
|
||||
},
|
||||
(config) => {
|
||||
config.models = config.models?.filter((m: any) => m.name !== title);
|
||||
return config;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function getModelByRole<T extends keyof ExperimentalModelRoles>(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { ConfigValidationError } from "@continuedev/config-yaml";
|
||||
|
||||
import { ModelDescription, SerializedContinueConfig } from "../";
|
||||
import { Telemetry } from "../util/posthog";
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import CodebaseContextProvider from "../../context/providers/CodebaseContextProv
|
|||
import DocsContextProvider from "../../context/providers/DocsContextProvider";
|
||||
import FileContextProvider from "../../context/providers/FileContextProvider";
|
||||
import { contextProviderClassFromName } from "../../context/providers/index";
|
||||
import PromptFilesContextProvider from "../../context/providers/PromptFilesContextProvider";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
import { allEmbeddingsProviders } from "../../indexing/allEmbeddingsProviders";
|
||||
import FreeTrial from "../../llm/llms/FreeTrial";
|
||||
|
|
@ -42,22 +41,31 @@ import { getSystemPromptDotFile } from "../getSystemPromptDotFile";
|
|||
import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader";
|
||||
import { modifyAnyConfigWithSharedConfig } from "../sharedConfig";
|
||||
|
||||
import { getControlPlaneEnvSync } from "../../control-plane/env";
|
||||
import { llmsFromModelConfig } from "./models";
|
||||
|
||||
export class LocalPlatformClient implements PlatformClient {
|
||||
constructor(
|
||||
private orgScopeId: string | null,
|
||||
private readonly client: ControlPlaneClient,
|
||||
) {}
|
||||
|
||||
async resolveFQSNs(fqsns: FQSN[]): Promise<(SecretResult | undefined)[]> {
|
||||
return fqsns.map((fqsn) => {
|
||||
return undefined;
|
||||
});
|
||||
if (fqsns.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const response = await this.client.resolveFQSNs(fqsns, this.orgScopeId);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadConfigYaml(
|
||||
workspaceConfigs: string[],
|
||||
rawYaml: string,
|
||||
overrideConfigYaml: AssistantUnrolled | undefined,
|
||||
ide: IDE,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
orgScopeId: string | null,
|
||||
ideSettings: IdeSettings,
|
||||
): Promise<ConfigResult<AssistantUnrolled>> {
|
||||
let config =
|
||||
overrideConfigYaml ??
|
||||
|
|
@ -69,12 +77,18 @@ async function loadConfigYaml(
|
|||
versionSlug: "",
|
||||
},
|
||||
rawYaml,
|
||||
new RegistryClient(),
|
||||
new RegistryClient(
|
||||
await controlPlaneClient.getAccessToken(),
|
||||
getControlPlaneEnvSync(
|
||||
ideSettings.continueTestEnvironment,
|
||||
ideSettings.enableControlServerBeta,
|
||||
).CONTROL_PLANE_URL,
|
||||
),
|
||||
{
|
||||
currentUserSlug: "",
|
||||
onPremProxyUrl: null,
|
||||
orgScopeId: null,
|
||||
platformClient: new LocalPlatformClient(),
|
||||
orgScopeId,
|
||||
platformClient: new LocalPlatformClient(orgScopeId, controlPlaneClient),
|
||||
renderSecrets: true,
|
||||
},
|
||||
));
|
||||
|
|
@ -111,7 +125,8 @@ async function configYamlToContinueConfig(
|
|||
const continueConfig: ContinueConfig = {
|
||||
slashCommands: [],
|
||||
models: [],
|
||||
tools: allTools,
|
||||
tools: [...allTools],
|
||||
mcpServerStatuses: [],
|
||||
systemMessage: config.rules?.join("\n"),
|
||||
experimental: {
|
||||
modelContextProtocolServers: config.mcpServers?.map((mcpServer) => ({
|
||||
|
|
@ -206,7 +221,6 @@ async function configYamlToContinueConfig(
|
|||
continueConfig.systemMessage,
|
||||
);
|
||||
|
||||
//
|
||||
if (modelsArrayRoles.some((role) => model.roles?.includes(role))) {
|
||||
continueConfig.models.push(...llms);
|
||||
}
|
||||
|
|
@ -244,7 +258,10 @@ async function configYamlToContinueConfig(
|
|||
} else {
|
||||
continueConfig.modelsByRole.embed.push(
|
||||
new embeddingsProviderClass(
|
||||
options,
|
||||
{
|
||||
...options,
|
||||
title: options.name,
|
||||
},
|
||||
(url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
|
|
@ -265,10 +282,15 @@ async function configYamlToContinueConfig(
|
|||
const rerankerClass = AllRerankers[provider];
|
||||
if (rerankerClass) {
|
||||
continueConfig.modelsByRole.rerank.push(
|
||||
new rerankerClass(options, (url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
}),
|
||||
new rerankerClass(
|
||||
{
|
||||
...options,
|
||||
title: options.name,
|
||||
},
|
||||
(url: string | URL, init: any) =>
|
||||
fetchwithRequestOptions(url, init, {
|
||||
...options.requestOptions,
|
||||
}),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
|
|
@ -334,7 +356,6 @@ async function configYamlToContinueConfig(
|
|||
const DEFAULT_CONTEXT_PROVIDERS = [
|
||||
new FileContextProvider({}),
|
||||
new CodebaseContextProvider(codebaseContextParams),
|
||||
new PromptFilesContextProvider({}),
|
||||
];
|
||||
|
||||
const DEFAULT_CONTEXT_PROVIDERS_TITLES = DEFAULT_CONTEXT_PROVIDERS.map(
|
||||
|
|
@ -368,52 +389,19 @@ async function configYamlToContinueConfig(
|
|||
continueConfig.contextProviders.push(new DocsContextProvider({}));
|
||||
}
|
||||
|
||||
// Apply MCP if specified
|
||||
// Trigger MCP server refreshes (Config is reloaded again once connected!)
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
if (config.mcpServers) {
|
||||
await mcpManager.removeUnusedConnections(
|
||||
config.mcpServers.map((s) => s.name),
|
||||
);
|
||||
}
|
||||
|
||||
await Promise.allSettled(
|
||||
config.mcpServers?.map(async (server) => {
|
||||
const abortController = new AbortController();
|
||||
const mcpConnectionTimeout = setTimeout(
|
||||
() => abortController.abort(),
|
||||
5000,
|
||||
);
|
||||
|
||||
try {
|
||||
const mcpId = server.name;
|
||||
const mcpConnection = mcpManager.createConnection(mcpId, {
|
||||
transport: {
|
||||
type: "stdio",
|
||||
args: [],
|
||||
...server,
|
||||
},
|
||||
});
|
||||
|
||||
await mcpConnection.modifyConfig(
|
||||
continueConfig,
|
||||
mcpId,
|
||||
abortController.signal,
|
||||
server.name,
|
||||
server.faviconUrl,
|
||||
);
|
||||
} catch (e) {
|
||||
let errorMessage = `Failed to load MCP server ${server.name}`;
|
||||
if (e instanceof Error) {
|
||||
errorMessage += ": " + e.message;
|
||||
}
|
||||
localErrors.push({
|
||||
fatal: false,
|
||||
message: errorMessage,
|
||||
});
|
||||
} finally {
|
||||
clearTimeout(mcpConnectionTimeout);
|
||||
}
|
||||
}) ?? [],
|
||||
mcpManager.setConnections(
|
||||
(config.mcpServers ?? []).map((server) => ({
|
||||
id: server.name,
|
||||
name: server.name,
|
||||
transport: {
|
||||
type: "stdio",
|
||||
args: [],
|
||||
...server,
|
||||
},
|
||||
})),
|
||||
false,
|
||||
);
|
||||
|
||||
return { config: continueConfig, errors: localErrors };
|
||||
|
|
@ -421,7 +409,6 @@ async function configYamlToContinueConfig(
|
|||
|
||||
export async function loadContinueConfigFromYaml(
|
||||
ide: IDE,
|
||||
workspaceConfigs: string[],
|
||||
ideSettings: IdeSettings,
|
||||
ideInfo: IdeInfo,
|
||||
uniqueId: string,
|
||||
|
|
@ -431,6 +418,7 @@ export async function loadContinueConfigFromYaml(
|
|||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
configYamlPath: string | undefined,
|
||||
orgScopeId: string | null,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
const rawYaml =
|
||||
overrideConfigYaml === undefined
|
||||
|
|
@ -441,11 +429,11 @@ export async function loadContinueConfigFromYaml(
|
|||
: "";
|
||||
|
||||
const configYamlResult = await loadConfigYaml(
|
||||
workspaceConfigs,
|
||||
rawYaml,
|
||||
overrideConfigYaml,
|
||||
ide,
|
||||
controlPlaneClient,
|
||||
orgScopeId,
|
||||
ideSettings,
|
||||
);
|
||||
|
||||
if (!configYamlResult.config || configYamlResult.configLoadInterrupted) {
|
||||
|
|
|
|||
|
|
@ -4,16 +4,23 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
|
|||
import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js";
|
||||
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
||||
|
||||
import { ContinueConfig, MCPOptions, SlashCommand, Tool } from "../..";
|
||||
import { constructMcpSlashCommand } from "../../commands/slash/mcp";
|
||||
import { encodeMCPToolUri } from "../../tools/callTool";
|
||||
import MCPContextProvider from "../providers/MCPContextProvider";
|
||||
import {
|
||||
MCPConnectionStatus,
|
||||
MCPOptions,
|
||||
MCPPrompt,
|
||||
MCPResource,
|
||||
MCPServerStatus,
|
||||
MCPTool,
|
||||
} from "../..";
|
||||
|
||||
export class MCPManagerSingleton {
|
||||
private static instance: MCPManagerSingleton;
|
||||
|
||||
public onConnectionsRefreshed?: () => void;
|
||||
private connections: Map<string, MCPConnection> = new Map();
|
||||
|
||||
private abortController: AbortController = new AbortController();
|
||||
|
||||
private constructor() {}
|
||||
|
||||
public static getInstance(): MCPManagerSingleton {
|
||||
|
|
@ -46,18 +53,90 @@ export class MCPManagerSingleton {
|
|||
this.connections.delete(id);
|
||||
}
|
||||
|
||||
async removeUnusedConnections(keepIds: string[]) {
|
||||
const toRemove = Array.from(this.connections.keys()).filter(
|
||||
(k) => !keepIds.includes(k),
|
||||
);
|
||||
await Promise.all(toRemove.map((id) => this.removeConnection(id)));
|
||||
setConnections(servers: MCPOptions[], forceRefresh: boolean) {
|
||||
let refresh = false;
|
||||
|
||||
// Remove any connections that are no longer in config
|
||||
Array.from(this.connections.entries()).forEach(([id, connection]) => {
|
||||
if (!servers.find((s) => s.id === id)) {
|
||||
refresh = true;
|
||||
connection.abortController.abort();
|
||||
void connection.client.close();
|
||||
this.connections.delete(id);
|
||||
}
|
||||
});
|
||||
|
||||
// Add any connections that are not yet in manager
|
||||
servers.forEach((server) => {
|
||||
if (!this.connections.has(server.id)) {
|
||||
refresh = true;
|
||||
this.connections.set(server.id, new MCPConnection(server));
|
||||
}
|
||||
});
|
||||
|
||||
// NOTE the id is made by stringifying the options
|
||||
if (refresh) {
|
||||
void this.refreshConnections(forceRefresh);
|
||||
}
|
||||
}
|
||||
|
||||
async refreshConnection(serverId: string) {
|
||||
const connection = this.connections.get(serverId);
|
||||
if (!connection) {
|
||||
throw new Error(`MCP Connection ${serverId} not found`);
|
||||
}
|
||||
await connection.connectClient(true, this.abortController.signal);
|
||||
if (this.onConnectionsRefreshed) {
|
||||
this.onConnectionsRefreshed();
|
||||
}
|
||||
}
|
||||
|
||||
async refreshConnections(force: boolean) {
|
||||
this.abortController.abort();
|
||||
this.abortController = new AbortController();
|
||||
await Promise.race([
|
||||
new Promise((resolve) => {
|
||||
this.abortController.signal.addEventListener("abort", () => {
|
||||
resolve(undefined);
|
||||
});
|
||||
}),
|
||||
(async () => {
|
||||
await Promise.all(
|
||||
Array.from(this.connections.values()).map(async (connection) => {
|
||||
await connection.connectClient(force, this.abortController.signal);
|
||||
}),
|
||||
);
|
||||
if (this.onConnectionsRefreshed) {
|
||||
this.onConnectionsRefreshed();
|
||||
}
|
||||
})(),
|
||||
]);
|
||||
}
|
||||
|
||||
getStatuses(): (MCPServerStatus & { client: Client })[] {
|
||||
return Array.from(this.connections.values()).map((connection) => ({
|
||||
...connection.getStatus(),
|
||||
client: connection.client,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_MCP_TIMEOUT = 20_000; // 10 seconds
|
||||
|
||||
class MCPConnection {
|
||||
public client: Client;
|
||||
private transport: Transport;
|
||||
|
||||
private connectionPromise: Promise<unknown> | null = null;
|
||||
public abortController: AbortController;
|
||||
|
||||
public status: MCPConnectionStatus = "not-connected";
|
||||
public errors: string[] = [];
|
||||
|
||||
public prompts: MCPPrompt[] = [];
|
||||
public tools: MCPTool[] = [];
|
||||
public resources: MCPResource[] = [];
|
||||
|
||||
constructor(private readonly options: MCPOptions) {
|
||||
this.transport = this.constructTransport(options);
|
||||
|
||||
|
|
@ -70,6 +149,8 @@ class MCPConnection {
|
|||
capabilities: {},
|
||||
},
|
||||
);
|
||||
|
||||
this.abortController = new AbortController();
|
||||
}
|
||||
|
||||
private constructTransport(options: MCPOptions): Transport {
|
||||
|
|
@ -95,131 +176,170 @@ class MCPConnection {
|
|||
}
|
||||
}
|
||||
|
||||
private isConnected: boolean = false;
|
||||
private connectPromise: Promise<void> | null = null;
|
||||
|
||||
private async connectClient() {
|
||||
if (this.isConnected) {
|
||||
// Already connected
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.connectPromise) {
|
||||
// Connection is already in progress; wait for it to complete
|
||||
await this.connectPromise;
|
||||
return;
|
||||
}
|
||||
|
||||
this.connectPromise = (async () => {
|
||||
await this.client.connect(this.transport);
|
||||
this.isConnected = true;
|
||||
})();
|
||||
|
||||
try {
|
||||
await this.connectPromise;
|
||||
} finally {
|
||||
// Reset the promise so future attempts can try again if necessary
|
||||
this.connectPromise = null;
|
||||
}
|
||||
getStatus(): MCPServerStatus {
|
||||
return {
|
||||
...this.options,
|
||||
errors: this.errors,
|
||||
prompts: this.prompts,
|
||||
resources: this.resources,
|
||||
tools: this.tools,
|
||||
status: this.status,
|
||||
};
|
||||
}
|
||||
|
||||
async modifyConfig(
|
||||
config: ContinueConfig,
|
||||
mcpId: string,
|
||||
signal: AbortSignal,
|
||||
name: string,
|
||||
faviconUrl: string | undefined,
|
||||
) {
|
||||
try {
|
||||
await Promise.race([
|
||||
this.connectClient(),
|
||||
new Promise((_, reject) => {
|
||||
signal.addEventListener("abort", () =>
|
||||
reject(new Error("Connection timed out")),
|
||||
);
|
||||
}),
|
||||
]);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
const msg = error.message.toLowerCase();
|
||||
if (msg.includes("spawn") && msg.includes("enoent")) {
|
||||
const command = msg.split(" ")[1];
|
||||
throw new Error(
|
||||
`command "${command}" not found. To use this MCP server, install the ${command} CLI.`,
|
||||
);
|
||||
} else if (
|
||||
!error.message.startsWith("StdioClientTransport already started")
|
||||
) {
|
||||
// don't throw error if it's just a "server already running" case
|
||||
throw error;
|
||||
async connectClient(forceRefresh: boolean, externalSignal: AbortSignal) {
|
||||
if (!forceRefresh) {
|
||||
// Already connected
|
||||
if (this.status === "connected") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Connection is already in progress; wait for it to complete
|
||||
if (this.connectionPromise) {
|
||||
await this.connectionPromise;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.status = "connecting";
|
||||
this.tools = [];
|
||||
this.prompts = [];
|
||||
this.resources = [];
|
||||
this.errors = [];
|
||||
|
||||
this.abortController.abort();
|
||||
this.abortController = new AbortController();
|
||||
|
||||
this.connectionPromise = Promise.race([
|
||||
// If aborted by a refresh or other, cancel and don't do anything
|
||||
new Promise((resolve) => {
|
||||
externalSignal.addEventListener("abort", () => {
|
||||
resolve(undefined);
|
||||
});
|
||||
}),
|
||||
new Promise((resolve) => {
|
||||
this.abortController.signal.addEventListener("abort", () => {
|
||||
resolve(undefined);
|
||||
});
|
||||
}),
|
||||
(async () => {
|
||||
const timeoutController = new AbortController();
|
||||
const connectionTimeout = setTimeout(
|
||||
() => timeoutController.abort(),
|
||||
this.options.timeout ?? DEFAULT_MCP_TIMEOUT,
|
||||
);
|
||||
|
||||
try {
|
||||
await Promise.race([
|
||||
new Promise((_, reject) => {
|
||||
timeoutController.signal.addEventListener("abort", () => {
|
||||
reject(new Error("Connection timed out"));
|
||||
});
|
||||
}),
|
||||
(async () => {
|
||||
this.transport = this.constructTransport(this.options);
|
||||
try {
|
||||
await this.client.connect(this.transport);
|
||||
} catch (error) {
|
||||
// Allow the case where for whatever reason is already connected
|
||||
if (
|
||||
error instanceof Error &&
|
||||
error.message.startsWith(
|
||||
"StdioClientTransport already started",
|
||||
)
|
||||
) {
|
||||
await this.client.close();
|
||||
await this.client.connect(this.transport);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO register server notification handlers
|
||||
// this.client.transport?.onmessage(msg => console.log())
|
||||
// this.client.setNotificationHandler(, notification => {
|
||||
// console.log(notification)
|
||||
// })
|
||||
|
||||
const capabilities = this.client.getServerCapabilities();
|
||||
|
||||
// Resources <—> Context Provider
|
||||
if (capabilities?.resources) {
|
||||
try {
|
||||
const { resources } = await this.client.listResources(
|
||||
{},
|
||||
{ signal: timeoutController.signal },
|
||||
);
|
||||
this.resources = resources;
|
||||
} catch (e) {
|
||||
let errorMessage = `Error loading resources for MCP Server ${this.options.name}`;
|
||||
if (e instanceof Error) {
|
||||
errorMessage += `: ${e.message}`;
|
||||
}
|
||||
this.errors.push(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// Tools <—> Tools
|
||||
if (capabilities?.tools) {
|
||||
try {
|
||||
const { tools } = await this.client.listTools(
|
||||
{},
|
||||
{ signal: timeoutController.signal },
|
||||
);
|
||||
this.tools = tools;
|
||||
} catch (e) {
|
||||
let errorMessage = `Error loading tools for MCP Server ${this.options.name}`;
|
||||
if (e instanceof Error) {
|
||||
errorMessage += `: ${e.message}`;
|
||||
}
|
||||
this.errors.push(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// Prompts <—> Slash commands
|
||||
if (capabilities?.prompts) {
|
||||
try {
|
||||
const { prompts } = await this.client.listPrompts(
|
||||
{},
|
||||
{ signal: timeoutController.signal },
|
||||
);
|
||||
this.prompts = prompts;
|
||||
} catch (e) {
|
||||
let errorMessage = `Error loading prompts for MCP Server ${this.options.name}`;
|
||||
if (e instanceof Error) {
|
||||
errorMessage += `: ${e.message}`;
|
||||
}
|
||||
this.errors.push(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
this.status = "connected";
|
||||
})(),
|
||||
]);
|
||||
} catch (error) {
|
||||
// Otherwise it's a connection error
|
||||
let errorMessage = `Failed to connect to MCP server ${this.options.name}`;
|
||||
if (error instanceof Error) {
|
||||
const msg = error.message.toLowerCase();
|
||||
if (msg.includes("spawn") && msg.includes("enoent")) {
|
||||
const command = msg.split(" ")[1];
|
||||
errorMessage += `command "${command}" not found. To use this MCP server, install the ${command} CLI.`;
|
||||
} else {
|
||||
errorMessage += ": " + error.message;
|
||||
}
|
||||
}
|
||||
|
||||
this.status = "error";
|
||||
this.errors.push(errorMessage);
|
||||
} finally {
|
||||
this.connectionPromise = null;
|
||||
clearTimeout(connectionTimeout);
|
||||
}
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
})(),
|
||||
]);
|
||||
|
||||
const capabilities = this.client.getServerCapabilities();
|
||||
|
||||
// Resources <—> Context Provider
|
||||
if (capabilities?.resources) {
|
||||
const { resources } = await this.client.listResources({}, { signal });
|
||||
const submenuItems = resources.map((resource: any) => ({
|
||||
title: resource.name,
|
||||
description: resource.description,
|
||||
id: resource.uri,
|
||||
icon: faviconUrl,
|
||||
}));
|
||||
|
||||
if (!config.contextProviders) {
|
||||
config.contextProviders = [];
|
||||
}
|
||||
|
||||
config.contextProviders.push(
|
||||
new MCPContextProvider({
|
||||
submenuItems,
|
||||
mcpId,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// Tools <—> Tools
|
||||
if (capabilities?.tools) {
|
||||
const { tools } = await this.client.listTools({}, { signal });
|
||||
const continueTools: Tool[] = tools.map((tool: any) => ({
|
||||
displayTitle: name + " " + tool.name,
|
||||
function: {
|
||||
description: tool.description,
|
||||
name: tool.name,
|
||||
parameters: tool.inputSchema,
|
||||
},
|
||||
faviconUrl,
|
||||
readonly: false,
|
||||
type: "function",
|
||||
wouldLikeTo: `use the ${name} ${tool.name} tool`,
|
||||
uri: encodeMCPToolUri(mcpId, tool.name),
|
||||
}));
|
||||
|
||||
config.tools = [...continueTools, ...config.tools];
|
||||
}
|
||||
|
||||
// Prompts <—> Slash commands
|
||||
if (capabilities?.prompts) {
|
||||
const { prompts } = await this.client.listPrompts({}, { signal });
|
||||
if (!config.slashCommands) {
|
||||
config.slashCommands = [];
|
||||
}
|
||||
|
||||
const slashCommands: SlashCommand[] = prompts.map((prompt: any) =>
|
||||
constructMcpSlashCommand(
|
||||
this.client,
|
||||
prompt.name,
|
||||
prompt.description,
|
||||
prompt.arguments?.map((a: any) => a.name),
|
||||
),
|
||||
);
|
||||
|
||||
config.slashCommands.push(...slashCommands);
|
||||
}
|
||||
await this.connectionPromise;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import {
|
|||
LoadSubmenuItemsArgs,
|
||||
} from "../..";
|
||||
import DocsService from "../../indexing/docs/DocsService";
|
||||
import preIndexedDocs from "../../indexing/docs/preIndexedDocs";
|
||||
|
||||
import { INSTRUCTIONS_BASE_ITEM } from "./utils";
|
||||
|
||||
|
|
@ -64,23 +63,12 @@ class DocsContextProvider extends BaseContextProvider {
|
|||
return chunksCopy;
|
||||
}
|
||||
|
||||
private _sortByPreIndexedDocs(
|
||||
private _sortAlphabetically(
|
||||
submenuItems: ContextSubmenuItem[],
|
||||
): ContextSubmenuItem[] {
|
||||
// Sort submenuItems such that the objects with titles which don't occur in configs occur first, and alphabetized
|
||||
// Sort submenu items alphabetically by title
|
||||
return submenuItems.sort((a, b) => {
|
||||
const aTitleInConfigs = a.metadata?.preIndexed ?? false;
|
||||
const bTitleInConfigs = b.metadata?.preIndexed ?? false;
|
||||
|
||||
// Primary criterion: Items not in configs come first
|
||||
if (!aTitleInConfigs && bTitleInConfigs) {
|
||||
return -1;
|
||||
} else if (aTitleInConfigs && !bTitleInConfigs) {
|
||||
return 1;
|
||||
} else {
|
||||
// Secondary criterion: Alphabetical order when both items are in the same category
|
||||
return a.title.toString().localeCompare(b.title.toString());
|
||||
}
|
||||
return a.title.toString().localeCompare(b.title.toString());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -165,13 +153,13 @@ class DocsContextProvider extends BaseContextProvider {
|
|||
}
|
||||
await docsService.isInitialized;
|
||||
|
||||
// Create map of docs url -> submenu item
|
||||
const submenuItemsMap = new Map<string, ContextSubmenuItem>();
|
||||
// Create an array to hold submenu items
|
||||
const submenuItems: ContextSubmenuItem[] = [];
|
||||
|
||||
// Add custom docs from config
|
||||
// Get all indexed docs from the database
|
||||
const docs = (await docsService.listMetadata()) ?? [];
|
||||
for (const { startUrl, title, favicon } of docs) {
|
||||
submenuItemsMap.set(startUrl, {
|
||||
submenuItems.push({
|
||||
title,
|
||||
id: startUrl,
|
||||
description: new URL(startUrl).hostname,
|
||||
|
|
@ -179,32 +167,8 @@ class DocsContextProvider extends BaseContextProvider {
|
|||
});
|
||||
}
|
||||
|
||||
// Add pre-indexed docs if supported
|
||||
const canUsePreindexedDocs = await docsService.canUsePreindexedDocs();
|
||||
if (canUsePreindexedDocs) {
|
||||
for (const { startUrl, title } of Object.values(preIndexedDocs)) {
|
||||
// Skip if overridden in config
|
||||
if (docs.find((d) => d.startUrl === startUrl)) {
|
||||
continue;
|
||||
}
|
||||
submenuItemsMap.set(startUrl, {
|
||||
title,
|
||||
id: startUrl,
|
||||
description: new URL(startUrl).hostname,
|
||||
metadata: {
|
||||
preIndexed: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Create array and sort if pre-indexed is supported
|
||||
const submenuItems = Array.from(submenuItemsMap.values());
|
||||
if (canUsePreindexedDocs) {
|
||||
return this._sortByPreIndexedDocs(submenuItems);
|
||||
}
|
||||
|
||||
return submenuItems;
|
||||
// Sort alphabetically
|
||||
return this._sortAlphabetically(submenuItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
import { BaseContextProvider } from "..";
|
||||
import {
|
||||
ContextItem,
|
||||
ContextProviderDescription,
|
||||
ContextProviderExtras,
|
||||
ContextSubmenuItem,
|
||||
LoadSubmenuItemsArgs,
|
||||
} from "../../";
|
||||
import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles";
|
||||
import { parsePreamble } from "../../promptFiles/v2/parse";
|
||||
import { renderPromptFileV2 } from "../../promptFiles/v2/renderPromptFile";
|
||||
|
||||
class PromptFilesContextProvider extends BaseContextProvider {
|
||||
static description: ContextProviderDescription = {
|
||||
title: "prompt-files",
|
||||
displayTitle: "Prompt Files",
|
||||
description: ".prompt files",
|
||||
type: "submenu",
|
||||
};
|
||||
|
||||
async getContextItems(
|
||||
query: string,
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<ContextItem[]> {
|
||||
const rawContent = await extras.ide.readFile(query);
|
||||
const preamble = parsePreamble(query, rawContent);
|
||||
const [contextItems, body] = await renderPromptFileV2(rawContent, extras);
|
||||
return [
|
||||
...contextItems,
|
||||
{
|
||||
content: body,
|
||||
name: preamble.name,
|
||||
description: preamble.description,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
async loadSubmenuItems(
|
||||
args: LoadSubmenuItemsArgs,
|
||||
): Promise<ContextSubmenuItem[]> {
|
||||
const promptFiles = await getAllPromptFiles(
|
||||
args.ide,
|
||||
args.config.experimental?.promptPath,
|
||||
// Note, NOT checking v1 default folder here, deprecated for context provider
|
||||
);
|
||||
return promptFiles.map((file) => {
|
||||
const preamble = parsePreamble(file.path, file.content);
|
||||
return {
|
||||
id: file.path,
|
||||
title: preamble.name,
|
||||
description: preamble.description,
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default PromptFilesContextProvider;
|
||||
|
|
@ -5,6 +5,7 @@ import {
|
|||
FQSN,
|
||||
FullSlug,
|
||||
SecretResult,
|
||||
SecretType,
|
||||
} from "@continuedev/config-yaml";
|
||||
import fetch, { RequestInit, Response } from "node-fetch";
|
||||
|
||||
|
|
@ -46,7 +47,14 @@ export class ControlPlaneClient {
|
|||
): Promise<(SecretResult | undefined)[]> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
throw new Error("No user id");
|
||||
return fqsns.map((fqsn) => ({
|
||||
found: false,
|
||||
fqsn,
|
||||
secretLocation: {
|
||||
secretName: fqsn.secretName,
|
||||
secretType: SecretType.NotFound,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
const resp = await this.request("ide/sync-secrets", {
|
||||
|
|
|
|||
70
core/core.ts
70
core/core.ts
|
|
@ -10,7 +10,7 @@ import {
|
|||
setupLocalConfig,
|
||||
setupQuickstartConfig,
|
||||
} from "./config/onboarding";
|
||||
import { addContextProvider, addModel, deleteModel } from "./config/util";
|
||||
import { addModel, deleteModel } from "./config/util";
|
||||
import CodebaseContextProvider from "./context/providers/CodebaseContextProvider";
|
||||
import CurrentFileContextProvider from "./context/providers/CurrentFileContextProvider";
|
||||
import { recentlyEditedFilesCache } from "./context/retrieval/recentlyEditedFilesCache";
|
||||
|
|
@ -22,7 +22,6 @@ import { DataLogger } from "./data/log";
|
|||
import { streamDiffLines } from "./edit/streamDiffLines";
|
||||
import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer";
|
||||
import DocsService from "./indexing/docs/DocsService";
|
||||
import { getAllSuggestedDocs } from "./indexing/docs/suggestions";
|
||||
import Ollama from "./llm/llms/Ollama";
|
||||
import { createNewPromptFileV2 } from "./promptFiles/v2/createNewPromptFile";
|
||||
import { callTool } from "./tools/callTool";
|
||||
|
|
@ -30,7 +29,7 @@ import { ChatDescriber } from "./util/chatDescriber";
|
|||
import { clipboardCache } from "./util/clipboardCache";
|
||||
import { GlobalContext } from "./util/GlobalContext";
|
||||
import historyManager from "./util/history";
|
||||
import { editConfigJson, migrateV1DevDataFiles } from "./util/paths";
|
||||
import { editConfigFile, migrateV1DevDataFiles } from "./util/paths";
|
||||
import { Telemetry } from "./util/posthog";
|
||||
import { getSymbolsForManyFiles } from "./util/treeSitter";
|
||||
import { TTS } from "./util/tts";
|
||||
|
|
@ -42,7 +41,9 @@ import {
|
|||
type IndexingProgressUpdate,
|
||||
} from ".";
|
||||
|
||||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
import { isLocalAssistantFile } from "./config/loadLocalAssistants";
|
||||
import { MCPManagerSingleton } from "./context/mcp";
|
||||
import { shouldIgnore } from "./indexing/shouldIgnore";
|
||||
import { walkDirCache } from "./indexing/walkDir";
|
||||
import { llmStreamChat } from "./llm/streamChat";
|
||||
|
|
@ -120,6 +121,13 @@ export class Core {
|
|||
this.messenger,
|
||||
);
|
||||
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
mcpManager.onConnectionsRefreshed = async () => {
|
||||
// This ensures that it triggers a NEW load after waiting for config promise to finish
|
||||
await this.configHandler.loadConfig();
|
||||
await this.configHandler.reloadConfig();
|
||||
};
|
||||
|
||||
this.configHandler.onConfigUpdate(async (result) => {
|
||||
const serializedResult = await this.configHandler.getSerializedConfig();
|
||||
this.messenger.send("configUpdate", {
|
||||
|
|
@ -311,10 +319,6 @@ export class Core {
|
|||
await this.configHandler.loadAssistantsForSelectedOrg();
|
||||
});
|
||||
|
||||
on("config/addContextProvider", async (msg) => {
|
||||
addContextProvider(msg.data, this.configHandler);
|
||||
});
|
||||
|
||||
on("config/updateSharedConfig", async (msg) => {
|
||||
const newSharedConfig = this.globalContext.updateSharedConfig(msg.data);
|
||||
await this.configHandler.reloadConfig();
|
||||
|
|
@ -344,6 +348,9 @@ export class Core {
|
|||
return await this.configHandler.listOrganizations();
|
||||
});
|
||||
|
||||
on("mcp/reloadServer", async (msg) => {
|
||||
mcpManager.refreshConnection(msg.data.id);
|
||||
});
|
||||
// Context providers
|
||||
on("context/addDocs", async (msg) => {
|
||||
void this.docsService.indexAndAdd(msg.data);
|
||||
|
|
@ -597,38 +604,55 @@ export class Core {
|
|||
return;
|
||||
}
|
||||
|
||||
let editConfigJsonCallback: Parameters<typeof editConfigJson>[0];
|
||||
let editConfigYamlCallback: (config: ConfigYaml) => ConfigYaml;
|
||||
|
||||
switch (mode) {
|
||||
case "Local":
|
||||
editConfigJsonCallback = setupLocalConfig;
|
||||
editConfigYamlCallback = setupLocalConfig;
|
||||
break;
|
||||
|
||||
case "Quickstart":
|
||||
editConfigJsonCallback = setupQuickstartConfig;
|
||||
editConfigYamlCallback = setupQuickstartConfig;
|
||||
break;
|
||||
|
||||
case "Best":
|
||||
editConfigJsonCallback = setupBestConfig;
|
||||
editConfigYamlCallback = setupBestConfig;
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error(`Invalid mode: ${mode}`);
|
||||
editConfigJsonCallback = (config) => config;
|
||||
editConfigYamlCallback = (config) => config;
|
||||
}
|
||||
|
||||
editConfigJson(editConfigJsonCallback);
|
||||
editConfigFile((c) => c, editConfigYamlCallback);
|
||||
|
||||
void this.configHandler.reloadConfig();
|
||||
});
|
||||
|
||||
on("addAutocompleteModel", (msg) => {
|
||||
editConfigJson((config) => {
|
||||
return {
|
||||
const model = msg.data.model;
|
||||
editConfigFile(
|
||||
(config) => {
|
||||
return {
|
||||
...config,
|
||||
tabAutocompleteModel: model,
|
||||
};
|
||||
},
|
||||
(config) => ({
|
||||
...config,
|
||||
tabAutocompleteModel: msg.data.model,
|
||||
};
|
||||
});
|
||||
models: [
|
||||
...(config.models ?? []),
|
||||
{
|
||||
name: model.title,
|
||||
provider: model.provider,
|
||||
model: model.model,
|
||||
apiKey: model.apiKey,
|
||||
roles: ["autocomplete"],
|
||||
apiBase: model.apiBase,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
void this.configHandler.reloadConfig();
|
||||
});
|
||||
|
||||
|
|
@ -796,14 +820,6 @@ export class Core {
|
|||
// this.docsService.setPaused(msg.data.id, msg.data.paused); // not supported yet
|
||||
}
|
||||
});
|
||||
on("docs/getSuggestedDocs", async (msg) => {
|
||||
if (hasRequestedDocs) {
|
||||
return;
|
||||
} // TODO, remove, hack because of rerendering
|
||||
hasRequestedDocs = true;
|
||||
const suggestedDocs = await getAllSuggestedDocs(this.ide);
|
||||
this.messenger.send("docs/suggestions", suggestedDocs);
|
||||
});
|
||||
on("docs/initStatuses", async (msg) => {
|
||||
void this.docsService.initStatuses();
|
||||
});
|
||||
|
|
@ -977,5 +993,3 @@ export class Core {
|
|||
|
||||
// private
|
||||
}
|
||||
|
||||
let hasRequestedDocs = false;
|
||||
|
|
|
|||
130
core/index.d.ts
vendored
130
core/index.d.ts
vendored
|
|
@ -43,13 +43,13 @@ export interface IndexingProgressUpdate {
|
|||
desc: string;
|
||||
shouldClearIndexes?: boolean;
|
||||
status:
|
||||
| "loading"
|
||||
| "indexing"
|
||||
| "done"
|
||||
| "failed"
|
||||
| "paused"
|
||||
| "disabled"
|
||||
| "cancelled";
|
||||
| "loading"
|
||||
| "indexing"
|
||||
| "done"
|
||||
| "failed"
|
||||
| "paused"
|
||||
| "disabled"
|
||||
| "cancelled";
|
||||
debugInfo?: string;
|
||||
}
|
||||
|
||||
|
|
@ -236,7 +236,6 @@ export interface SiteIndexingConfig {
|
|||
maxDepth?: number;
|
||||
faviconUrl?: string;
|
||||
useLocalCrawling?: boolean;
|
||||
rootUrl?: string; // Currently only used by preindexed docs
|
||||
}
|
||||
|
||||
export interface DocsIndexingDetails {
|
||||
|
|
@ -244,7 +243,6 @@ export interface DocsIndexingDetails {
|
|||
config: SiteIndexingConfig;
|
||||
indexingStatus: IndexingStatus | undefined;
|
||||
chunks: Chunk[];
|
||||
isPreIndexedDoc: boolean;
|
||||
}
|
||||
|
||||
export interface IContextProvider {
|
||||
|
|
@ -316,7 +314,12 @@ export interface CompletionOptions extends BaseCompletionOptions {
|
|||
model: string;
|
||||
}
|
||||
|
||||
export type ChatMessageRole = "user" | "assistant" | "thinking" | "system" | "tool";
|
||||
export type ChatMessageRole =
|
||||
| "user"
|
||||
| "assistant"
|
||||
| "thinking"
|
||||
| "system"
|
||||
| "tool";
|
||||
|
||||
export type TextMessagePart = {
|
||||
type: "text";
|
||||
|
|
@ -434,7 +437,7 @@ export interface PromptLog {
|
|||
completion: string;
|
||||
}
|
||||
|
||||
export type MessageModes = "chat" | "edit";
|
||||
export type MessageModes = "chat" | "edit" | "agent";
|
||||
|
||||
export type ToolStatus =
|
||||
| "generating"
|
||||
|
|
@ -692,10 +695,10 @@ export interface IDE {
|
|||
getCurrentFile(): Promise<
|
||||
| undefined
|
||||
| {
|
||||
isUntitled: boolean;
|
||||
path: string;
|
||||
contents: string;
|
||||
}
|
||||
isUntitled: boolean;
|
||||
path: string;
|
||||
contents: string;
|
||||
}
|
||||
>;
|
||||
|
||||
getLastFileSaveTimestamp?(): number;
|
||||
|
|
@ -761,6 +764,7 @@ export interface ContinueSDK {
|
|||
export interface SlashCommand {
|
||||
name: string;
|
||||
description: string;
|
||||
prompt?: string;
|
||||
params?: { [key: string]: any };
|
||||
run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
|
||||
}
|
||||
|
|
@ -864,11 +868,7 @@ export interface ContextProviderWithParams {
|
|||
params: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface SlashCommandDescription {
|
||||
name: string;
|
||||
description: string;
|
||||
params?: { [key: string]: any };
|
||||
}
|
||||
export type SlashCommandDescription = Omit<SlashCommand, "run">;
|
||||
|
||||
export interface CustomCommand {
|
||||
name: string;
|
||||
|
|
@ -879,11 +879,11 @@ export interface CustomCommand {
|
|||
export interface Prediction {
|
||||
type: "content";
|
||||
content:
|
||||
| string
|
||||
| {
|
||||
type: "text";
|
||||
text: string;
|
||||
}[];
|
||||
| string
|
||||
| {
|
||||
type: "text";
|
||||
text: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface ToolExtras {
|
||||
|
|
@ -903,10 +903,13 @@ export interface Tool {
|
|||
};
|
||||
|
||||
displayTitle: string;
|
||||
wouldLikeTo: string;
|
||||
wouldLikeTo?: string;
|
||||
isCurrently?: string;
|
||||
hasAlready?: string;
|
||||
readonly: boolean;
|
||||
uri?: string;
|
||||
faviconUrl?: string;
|
||||
group: string;
|
||||
}
|
||||
|
||||
interface ToolChoice {
|
||||
|
|
@ -1042,8 +1045,54 @@ export interface SSEOptions {
|
|||
export type TransportOptions = StdioOptions | WebSocketOptions | SSEOptions;
|
||||
|
||||
export interface MCPOptions {
|
||||
name: string;
|
||||
id: string;
|
||||
transport: TransportOptions;
|
||||
faviconUrl?: string;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export type MCPConnectionStatus =
|
||||
| "connecting"
|
||||
| "connected"
|
||||
| "error"
|
||||
| "not-connected";
|
||||
|
||||
export interface MCPPrompt {
|
||||
name: string;
|
||||
description?: string;
|
||||
arguments?: {
|
||||
name: string;
|
||||
description?: string;
|
||||
required?: boolean;
|
||||
}[];
|
||||
}
|
||||
|
||||
// Leaving here to ideate on
|
||||
// export type ContinueConfigSource = "local-yaml" | "local-json" | "hub-assistant" | "hub"
|
||||
|
||||
export interface MCPResource {
|
||||
name: string;
|
||||
uri: string;
|
||||
description?: string;
|
||||
mimeType?: string;
|
||||
}
|
||||
export interface MCPTool {
|
||||
name: string;
|
||||
description?: string;
|
||||
inputSchema: {
|
||||
type: "object";
|
||||
properties?: Record<string, any>;
|
||||
};
|
||||
}
|
||||
|
||||
export interface MCPServerStatus extends MCPOptions {
|
||||
status: MCPConnectionStatus;
|
||||
errors: string[];
|
||||
|
||||
prompts: MCPPrompt[];
|
||||
tools: MCPTool[];
|
||||
resources: MCPResource[];
|
||||
}
|
||||
|
||||
export interface ContinueUIConfig {
|
||||
|
|
@ -1069,6 +1118,11 @@ export interface ExperimentalModelRoles {
|
|||
applyCodeBlock?: string;
|
||||
}
|
||||
|
||||
export interface ExperimentalMCPOptions {
|
||||
transport: TransportOptions;
|
||||
faviconUrl?: string;
|
||||
}
|
||||
|
||||
export type EditStatus =
|
||||
| "not-started"
|
||||
| "streaming"
|
||||
|
|
@ -1152,7 +1206,7 @@ export interface ExperimentalConfig {
|
|||
* This is needed to crawl a large number of documentation sites that are dynamically rendered.
|
||||
*/
|
||||
useChromiumForDocsCrawling?: boolean;
|
||||
modelContextProtocolServers?: MCPOptions[];
|
||||
modelContextProtocolServers?: ExperimentalMCPOptions[];
|
||||
}
|
||||
|
||||
export interface AnalyticsConfig {
|
||||
|
|
@ -1223,9 +1277,9 @@ export interface Config {
|
|||
embeddingsProvider?: EmbeddingsProviderDescription | ILLM;
|
||||
/** The model that Continue will use for tab autocompletions. */
|
||||
tabAutocompleteModel?:
|
||||
| CustomLLM
|
||||
| ModelDescription
|
||||
| (CustomLLM | ModelDescription)[];
|
||||
| CustomLLM
|
||||
| ModelDescription
|
||||
| (CustomLLM | ModelDescription)[];
|
||||
/** Options for tab autocomplete */
|
||||
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
/** UI styles customization */
|
||||
|
|
@ -1246,8 +1300,8 @@ export interface ContinueConfig {
|
|||
systemMessage?: string;
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
requestOptions?: RequestOptions;
|
||||
slashCommands?: SlashCommand[];
|
||||
contextProviders?: IContextProvider[];
|
||||
slashCommands: SlashCommand[];
|
||||
contextProviders: IContextProvider[];
|
||||
disableSessionTitles?: boolean;
|
||||
disableIndexing?: boolean;
|
||||
userToken?: string;
|
||||
|
|
@ -1257,6 +1311,7 @@ export interface ContinueConfig {
|
|||
analytics?: AnalyticsConfig;
|
||||
docs?: SiteIndexingConfig[];
|
||||
tools: Tool[];
|
||||
mcpServerStatuses: MCPServerStatus[];
|
||||
rules?: string[];
|
||||
modelsByRole: Record<ModelRole, ILLM[]>;
|
||||
selectedModelByRole: Record<ModelRole, ILLM | null>;
|
||||
|
|
@ -1269,8 +1324,8 @@ export interface BrowserSerializedContinueConfig {
|
|||
systemMessage?: string;
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
requestOptions?: RequestOptions;
|
||||
slashCommands?: SlashCommandDescription[];
|
||||
contextProviders?: ContextProviderDescription[];
|
||||
slashCommands: SlashCommandDescription[];
|
||||
contextProviders: ContextProviderDescription[];
|
||||
disableIndexing?: boolean;
|
||||
disableSessionTitles?: boolean;
|
||||
userToken?: string;
|
||||
|
|
@ -1279,6 +1334,7 @@ export interface BrowserSerializedContinueConfig {
|
|||
analytics?: AnalyticsConfig;
|
||||
docs?: SiteIndexingConfig[];
|
||||
tools: Tool[];
|
||||
mcpServerStatuses: MCPServerStatus[];
|
||||
rules?: string[];
|
||||
usePlatform: boolean;
|
||||
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
|
|
@ -1319,9 +1375,9 @@ export type PackageDetailsSuccess = PackageDetails & {
|
|||
export type PackageDocsResult = {
|
||||
packageInfo: ParsedPackageInfo;
|
||||
} & (
|
||||
| { error: string; details?: never }
|
||||
| { details: PackageDetailsSuccess; error?: never }
|
||||
);
|
||||
| { error: string; details?: never }
|
||||
| { details: PackageDetailsSuccess; error?: never }
|
||||
);
|
||||
|
||||
export interface TerminalOptions {
|
||||
reuseTerminal?: boolean;
|
||||
|
|
|
|||
25
core/indexing/docs/DocsCache.test.ts
Normal file
25
core/indexing/docs/DocsCache.test.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import OpenAI from "../../llm/llms/OpenAI";
|
||||
import { DocsCache } from "./DocsCache"; // adjust import path as needed
|
||||
|
||||
describe("DocsCache", () => {
|
||||
let openAIEmbeddings: OpenAI;
|
||||
|
||||
beforeAll(() => {
|
||||
openAIEmbeddings = new OpenAI({
|
||||
apiKey: "",
|
||||
model: "text-embedding-ada-002",
|
||||
});
|
||||
});
|
||||
|
||||
test("normalizeEmbeddingId() produces a valid ID without constructor name", async () => {
|
||||
// Get the embedding ID from OpenAI embeddings provider
|
||||
const embeddingId = DocsCache.normalizeEmbeddingId(
|
||||
openAIEmbeddings.embeddingId,
|
||||
);
|
||||
|
||||
// The ID should not contain the constructor name (OpenAI)
|
||||
expect(embeddingId).toEqual(
|
||||
`${openAIEmbeddings.model}::${openAIEmbeddings.maxEmbeddingChunkSize}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
83
core/indexing/docs/DocsCache.ts
Normal file
83
core/indexing/docs/DocsCache.ts
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
import request from "request";
|
||||
import { Chunk } from "../..";
|
||||
|
||||
export interface SiteIndexingResults {
|
||||
chunks: (Chunk & { embedding: number[] })[];
|
||||
url: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export class DocsCache {
|
||||
static readonly AWS_REGION: string = "us-west-1";
|
||||
static readonly BUCKET_NAME: string = "continue-preindexed-docs";
|
||||
|
||||
/**
|
||||
* Normalizes an embedding ID by stripping the constructor name part.
|
||||
* This is done because we don't care about the provider, just the
|
||||
* model and the max embedding chunk size.
|
||||
*/
|
||||
static normalizeEmbeddingId(embeddingId: string): string {
|
||||
// Split by "::" and remove the first part (constructor name)
|
||||
const parts = embeddingId.split("::");
|
||||
if (parts.length <= 1) return embeddingId; // Return original if no "::" found
|
||||
|
||||
// Return everything except the first part, joining with "::"
|
||||
return parts.slice(1).join("::");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the filepath for a given embedding ID and URL
|
||||
*/
|
||||
static getFilepathForEmbeddingIdAndUrl(
|
||||
embeddingId: string,
|
||||
url: string,
|
||||
): string {
|
||||
const normalizedEmbeddingId = DocsCache.normalizeEmbeddingId(embeddingId);
|
||||
const normalizedUrl = encodeURIComponent(url.replace(/\//g, "_"));
|
||||
return normalizedEmbeddingId + "/" + normalizedUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fully qualified S3 URL for a given filepath
|
||||
*/
|
||||
private static getS3Url(filepath: string): string {
|
||||
const pathname = filepath.split("/").map(encodeURIComponent).join("/");
|
||||
return `https://${this.BUCKET_NAME}.s3.${this.AWS_REGION}.amazonaws.com/${pathname}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads cached site indexing results from S3 for a given embedding ID and URL
|
||||
* @param embeddingId The embedding ID
|
||||
* @param url The URL of the document
|
||||
* @returns The downloaded data as a string
|
||||
*/
|
||||
static async getDocsCacheForUrl(
|
||||
embeddingId: string,
|
||||
url: string,
|
||||
): Promise<string> {
|
||||
const filepath = DocsCache.getFilepathForEmbeddingIdAndUrl(
|
||||
embeddingId,
|
||||
url,
|
||||
);
|
||||
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
let data = "";
|
||||
const url = this.getS3Url(filepath);
|
||||
const download = request({
|
||||
url,
|
||||
});
|
||||
|
||||
download.on("response", (response: any) => {
|
||||
if (response.statusCode !== 200) {
|
||||
reject(
|
||||
new Error("There was an error retrieving the pre-indexed doc"),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
download.on("error", (err: any) => reject(err));
|
||||
download.on("data", (chunk: any) => (data += chunk));
|
||||
download.on("end", () => resolve(data));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,156 +1,156 @@
|
|||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
import { ConfigHandler } from "../../config/ConfigHandler.js";
|
||||
import { SiteIndexingConfig } from "../../index.js";
|
||||
import FileSystemIde from "../../util/filesystem.js";
|
||||
import { editConfigJson } from "../../util/paths.js";
|
||||
// /**
|
||||
// * @jest-environment jsdom
|
||||
// */
|
||||
// import { ConfigHandler } from "../../config/ConfigHandler.js";
|
||||
// import { SiteIndexingConfig } from "../../index.js";
|
||||
// import FileSystemIde from "../../util/filesystem.js";
|
||||
// import { editConfigJson } from "../../util/paths.js";
|
||||
|
||||
import DocsService from "./DocsService.js";
|
||||
import preIndexedDocs from "./preIndexedDocs.js";
|
||||
// import DocsService from "./DocsService.js";
|
||||
// import preIndexedDocs from "./preIndexedDocs.js";
|
||||
|
||||
describe.skip("DocsService Integration Tests", () => {
|
||||
let ide: FileSystemIde;
|
||||
let configHandler: ConfigHandler;
|
||||
let docsService: DocsService;
|
||||
// describe.skip("DocsService Integration Tests", () => {
|
||||
// let ide: FileSystemIde;
|
||||
// let configHandler: ConfigHandler;
|
||||
// let docsService: DocsService;
|
||||
|
||||
const mockSiteConfig: SiteIndexingConfig = {
|
||||
startUrl: "https://amplified.dev/",
|
||||
title: "Test repo",
|
||||
faviconUrl: "https://github.com/favicon.ico",
|
||||
};
|
||||
// const mockSiteConfig: SiteIndexingConfig = {
|
||||
// startUrl: "https://amplified.dev/",
|
||||
// title: "Test repo",
|
||||
// faviconUrl: "https://github.com/favicon.ico",
|
||||
// };
|
||||
|
||||
/**
|
||||
* We need to reload config explicitly to handle the scenario where the
|
||||
* config file update listeners are not called before we attempt to
|
||||
* use the new config
|
||||
*/
|
||||
async function getReloadedConfig() {
|
||||
await configHandler.reloadConfig();
|
||||
const latestConfig = await configHandler.loadConfig();
|
||||
// /**
|
||||
// * We need to reload config explicitly to handle the scenario where the
|
||||
// * config file update listeners are not called before we attempt to
|
||||
// * use the new config
|
||||
// */
|
||||
// async function getReloadedConfig() {
|
||||
// await configHandler.reloadConfig();
|
||||
// const latestConfig = await configHandler.loadConfig();
|
||||
|
||||
return latestConfig;
|
||||
}
|
||||
// return latestConfig;
|
||||
// }
|
||||
|
||||
beforeEach(async () => {
|
||||
ide = new FileSystemIde(process.cwd());
|
||||
// beforeEach(async () => {
|
||||
// ide = new FileSystemIde(process.cwd());
|
||||
|
||||
const ideSettingsPromise = Promise.resolve({
|
||||
remoteConfigSyncPeriod: 60,
|
||||
userToken: "",
|
||||
enableControlServerBeta: false,
|
||||
continueTestEnvironment: "none" as const,
|
||||
pauseCodebaseIndexOnStart: false,
|
||||
ideSettings: {} as any,
|
||||
enableDebugLogs: false,
|
||||
remoteConfigServerUrl: "",
|
||||
});
|
||||
configHandler = new ConfigHandler(
|
||||
ide,
|
||||
ideSettingsPromise,
|
||||
async () => {},
|
||||
Promise.resolve(undefined),
|
||||
);
|
||||
// const ideSettingsPromise = Promise.resolve({
|
||||
// remoteConfigSyncPeriod: 60,
|
||||
// userToken: "",
|
||||
// enableControlServerBeta: false,
|
||||
// continueTestEnvironment: "none" as const,
|
||||
// pauseCodebaseIndexOnStart: false,
|
||||
// ideSettings: {} as any,
|
||||
// enableDebugLogs: false,
|
||||
// remoteConfigServerUrl: "",
|
||||
// });
|
||||
// configHandler = new ConfigHandler(
|
||||
// ide,
|
||||
// ideSettingsPromise,
|
||||
// async () => {},
|
||||
// Promise.resolve(undefined),
|
||||
// );
|
||||
|
||||
docsService = DocsService.createSingleton(configHandler, ide);
|
||||
// docsService = DocsService.createSingleton(configHandler, ide);
|
||||
|
||||
await docsService.isInitialized;
|
||||
});
|
||||
// await docsService.isInitialized;
|
||||
// });
|
||||
|
||||
test("Indexing, retrieval, and deletion of a new documentation site", async () => {
|
||||
await docsService.indexAndAdd(mockSiteConfig);
|
||||
// test("Indexing, retrieval, and deletion of a new documentation site", async () => {
|
||||
// await docsService.indexAndAdd(mockSiteConfig);
|
||||
|
||||
let latestConfig = await getReloadedConfig();
|
||||
// let latestConfig = await getReloadedConfig();
|
||||
|
||||
// Sqlite check
|
||||
expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(true);
|
||||
// // Sqlite check
|
||||
// expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(true);
|
||||
|
||||
// config.json check
|
||||
expect(latestConfig.config!.docs).toContainEqual(mockSiteConfig);
|
||||
// // config.json check
|
||||
// expect(latestConfig.config!.docs).toContainEqual(mockSiteConfig);
|
||||
|
||||
// Lance DB check
|
||||
let retrievedChunks = await docsService.retrieveChunksFromQuery(
|
||||
"test",
|
||||
mockSiteConfig.startUrl,
|
||||
5,
|
||||
);
|
||||
// // Lance DB check
|
||||
// let retrievedChunks = await docsService.retrieveChunksFromQuery(
|
||||
// "test",
|
||||
// mockSiteConfig.startUrl,
|
||||
// 5,
|
||||
// );
|
||||
|
||||
expect(retrievedChunks.length).toBeGreaterThan(0);
|
||||
// expect(retrievedChunks.length).toBeGreaterThan(0);
|
||||
|
||||
await docsService.delete(mockSiteConfig.startUrl);
|
||||
// await docsService.delete(mockSiteConfig.startUrl);
|
||||
|
||||
// Sqlite check
|
||||
expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(false);
|
||||
// // Sqlite check
|
||||
// expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(false);
|
||||
|
||||
// config.json check
|
||||
latestConfig = await getReloadedConfig();
|
||||
expect(latestConfig.config!.docs).not.toContainEqual(
|
||||
expect.objectContaining(mockSiteConfig),
|
||||
);
|
||||
// // config.json check
|
||||
// latestConfig = await getReloadedConfig();
|
||||
// expect(latestConfig.config!.docs).not.toContainEqual(
|
||||
// expect.objectContaining(mockSiteConfig),
|
||||
// );
|
||||
|
||||
// LanceDB check
|
||||
retrievedChunks = await docsService.retrieveChunksFromQuery(
|
||||
"test",
|
||||
mockSiteConfig.startUrl,
|
||||
5,
|
||||
);
|
||||
expect(retrievedChunks.length).toBe(0);
|
||||
});
|
||||
// // LanceDB check
|
||||
// retrievedChunks = await docsService.retrieveChunksFromQuery(
|
||||
// "test",
|
||||
// mockSiteConfig.startUrl,
|
||||
// 5,
|
||||
// );
|
||||
// expect(retrievedChunks.length).toBe(0);
|
||||
// });
|
||||
|
||||
// test("Reindexes when changing embeddings provider", async () => {
|
||||
// const originalEmbeddingsProvider =
|
||||
// await docsService.getEmbeddingsProvider();
|
||||
// // test("Reindexes when changing embeddings provider", async () => {
|
||||
// // const originalEmbeddingsProvider =
|
||||
// // await docsService.getEmbeddingsProvider();
|
||||
|
||||
// // Change embeddings provider
|
||||
// editConfigJson((config) => ({
|
||||
// ...config,
|
||||
// embeddingsProvider: {
|
||||
// provider: FreeTrial.providerName,
|
||||
// },
|
||||
// }));
|
||||
// // // Change embeddings provider
|
||||
// // editConfigJson((config) => ({
|
||||
// // ...config,
|
||||
// // embeddingsProvider: {
|
||||
// // provider: FreeTrial.providerName,
|
||||
// // },
|
||||
// // }));
|
||||
|
||||
// await getReloadedConfig();
|
||||
// // await getReloadedConfig();
|
||||
|
||||
// const { provider, isPreindexed} = await docsService.getEmbeddingsProvider();
|
||||
// // const { provider, isPreindexed} = await docsService.getEmbeddingsProvider();
|
||||
|
||||
// // Verify reindexing
|
||||
// const [originalVector] = await originalEmbeddingsProvider.embed(["test"]);
|
||||
// const [newMockVector] = await provider.embed(["test"]);
|
||||
// // // Verify reindexing
|
||||
// // const [originalVector] = await originalEmbeddingsProvider.embed(["test"]);
|
||||
// // const [newMockVector] = await provider.embed(["test"]);
|
||||
|
||||
// expect(originalVector).not.toEqual(newMockVector);
|
||||
// });
|
||||
// // expect(originalVector).not.toEqual(newMockVector);
|
||||
// // });
|
||||
|
||||
test("Handles pulling down and adding pre-indexed docs", async () => {
|
||||
const preIndexedDoc = Object.values(preIndexedDocs)[0];
|
||||
await docsService.indexAndAdd(preIndexedDoc);
|
||||
});
|
||||
// test("Handles pulling down and adding pre-indexed docs", async () => {
|
||||
// const preIndexedDoc = Object.values(preIndexedDocs)[0];
|
||||
// await docsService.indexAndAdd(preIndexedDoc);
|
||||
// });
|
||||
|
||||
test("Config synchronization with SQLite", async () => {
|
||||
await docsService.indexAndAdd(mockSiteConfig);
|
||||
// test("Config synchronization with SQLite", async () => {
|
||||
// await docsService.indexAndAdd(mockSiteConfig);
|
||||
|
||||
await getReloadedConfig();
|
||||
// await getReloadedConfig();
|
||||
|
||||
expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(true);
|
||||
// expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(true);
|
||||
|
||||
editConfigJson((config) => {
|
||||
const { docs, ...restConfig } = config;
|
||||
return restConfig;
|
||||
});
|
||||
// editConfigJson((config) => {
|
||||
// const { docs, ...restConfig } = config;
|
||||
// return restConfig;
|
||||
// });
|
||||
|
||||
await getReloadedConfig();
|
||||
// await getReloadedConfig();
|
||||
|
||||
const startTime = Date.now();
|
||||
const maxWaitTimeMs = 10_000;
|
||||
// const startTime = Date.now();
|
||||
// const maxWaitTimeMs = 10_000;
|
||||
|
||||
while (docsService.isSyncing) {
|
||||
if (Date.now() - startTime > maxWaitTimeMs) {
|
||||
throw new Error(
|
||||
`Timeout: docsService.isSyncing did not complete within within ${maxWaitTimeMs}ms`,
|
||||
);
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}
|
||||
// while (docsService.isSyncing) {
|
||||
// if (Date.now() - startTime > maxWaitTimeMs) {
|
||||
// throw new Error(
|
||||
// `Timeout: docsService.isSyncing did not complete within within ${maxWaitTimeMs}ms`,
|
||||
// );
|
||||
// }
|
||||
// await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
// }
|
||||
|
||||
expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(false);
|
||||
});
|
||||
});
|
||||
// expect(await docsService.hasMetadata(mockSiteConfig.startUrl)).toBe(false);
|
||||
// });
|
||||
// });
|
||||
|
|
|
|||
|
|
@ -13,18 +13,15 @@ import {
|
|||
SiteIndexingConfig,
|
||||
} from "../..";
|
||||
import { ConfigHandler } from "../../config/ConfigHandler";
|
||||
import {
|
||||
addContextProvider,
|
||||
isSupportedLanceDbCpuTargetForLinux,
|
||||
} from "../../config/util";
|
||||
import { isSupportedLanceDbCpuTargetForLinux } from "../../config/util";
|
||||
import DocsContextProvider from "../../context/providers/DocsContextProvider";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { FromCoreProtocol, ToCoreProtocol } from "../../protocol";
|
||||
import { IMessenger } from "../../protocol/messenger";
|
||||
import { fetchFavicon, getFaviconBase64 } from "../../util/fetchFavicon";
|
||||
import { fetchFavicon } from "../../util/fetchFavicon";
|
||||
import { GlobalContext } from "../../util/GlobalContext";
|
||||
import {
|
||||
editConfigJson,
|
||||
editConfigFile,
|
||||
getDocsSqlitePath,
|
||||
getLanceDbPath,
|
||||
} from "../../util/paths";
|
||||
|
|
@ -37,15 +34,9 @@ import {
|
|||
} from "./article";
|
||||
import DocsCrawler, { DocsCrawlerType, PageData } from "./crawlers/DocsCrawler";
|
||||
import { runLanceMigrations, runSqliteMigrations } from "./migrations";
|
||||
import {
|
||||
downloadFromS3,
|
||||
getS3Filename,
|
||||
S3Buckets,
|
||||
SiteIndexingResults,
|
||||
} from "./preIndexed";
|
||||
import preIndexedDocs from "./preIndexedDocs";
|
||||
|
||||
import type * as LanceType from "vectordb";
|
||||
import { DocsCache, SiteIndexingResults } from "./DocsCache";
|
||||
|
||||
// Purposefully lowercase because lancedb converts
|
||||
export interface LanceDbDocsRow {
|
||||
|
|
@ -89,8 +80,7 @@ export default class DocsService {
|
|||
static lanceTableName = "docs";
|
||||
static sqlitebTableName = "docs";
|
||||
|
||||
static preIndexedDocsEmbeddingsProvider =
|
||||
new TransformersJsEmbeddingsProvider();
|
||||
static defaultEmbeddingsProvider = new TransformersJsEmbeddingsProvider();
|
||||
|
||||
public isInitialized: Promise<void>;
|
||||
public isSyncing: boolean = false;
|
||||
|
|
@ -250,12 +240,8 @@ export default class DocsService {
|
|||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Currently, we generate and host embeddings for pre-indexed docs using transformers.
|
||||
* However, we don't ship transformers with the JetBrains extension.
|
||||
* So, we only include pre-indexed docs in the submenu for non-JetBrains IDEs.
|
||||
*/
|
||||
async canUsePreindexedDocs() {
|
||||
// Determine if transformers.js embeddings are supported in this environment
|
||||
async canUseTransformersEmbeddings() {
|
||||
const ideInfo = await this.ideInfoPromise;
|
||||
if (ideInfo.ideType === "jetbrains") {
|
||||
return false;
|
||||
|
|
@ -263,28 +249,26 @@ export default class DocsService {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Determines if using preIndexed and returns proper embeddings provider
|
||||
async getEmbeddingsProvider(startUrl: string) {
|
||||
// Conditions for using a pre-indexed doc
|
||||
|
||||
// Must be in pre indexed docs file
|
||||
const preIndexedDoc = preIndexedDocs[startUrl];
|
||||
if (preIndexedDoc) {
|
||||
// Most not be overriden by config
|
||||
if (!this.config?.docs?.find((doc) => doc.startUrl === startUrl)) {
|
||||
// Must be supported
|
||||
const canUsePreindexedDocs = await this.canUsePreindexedDocs();
|
||||
if (canUsePreindexedDocs) {
|
||||
return {
|
||||
provider: DocsService.preIndexedDocsEmbeddingsProvider,
|
||||
isPreindexed: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
// Get the appropriate embeddings provider
|
||||
async getEmbeddingsProvider() {
|
||||
// First check if there's a config selected embeddings provider
|
||||
if (this.config.selectedModelByRole.embed) {
|
||||
return {
|
||||
provider: this.config.selectedModelByRole.embed,
|
||||
};
|
||||
}
|
||||
|
||||
// Fall back to transformers if supported
|
||||
const canUseTransformers = await this.canUseTransformersEmbeddings();
|
||||
if (canUseTransformers) {
|
||||
return {
|
||||
provider: DocsService.defaultEmbeddingsProvider,
|
||||
};
|
||||
}
|
||||
|
||||
// No provider available
|
||||
return {
|
||||
provider: this.config.selectedModelByRole.embed,
|
||||
isPreindexed: false,
|
||||
provider: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -312,29 +296,6 @@ export default class DocsService {
|
|||
}
|
||||
|
||||
async syncDocsWithPrompt(reIndex: boolean = false) {
|
||||
if (!this.hasDocsContextProvider()) {
|
||||
const actionMsg = "Add 'docs' context provider";
|
||||
const res = await this.ide.showToast(
|
||||
"info",
|
||||
"Starting docs indexing",
|
||||
actionMsg,
|
||||
);
|
||||
|
||||
if (res === actionMsg) {
|
||||
addContextProvider({
|
||||
name: DocsContextProvider.description.title,
|
||||
params: {},
|
||||
});
|
||||
|
||||
void this.ide.showToast(
|
||||
"info",
|
||||
"Successfuly added docs context provider",
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await this.syncDocs(undefined, this.config, reIndex);
|
||||
|
||||
void this.ide.showToast("info", "Docs indexing completed");
|
||||
|
|
@ -379,6 +340,45 @@ export default class DocsService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to load document embeddings from cache
|
||||
* @returns true if cache was successfully loaded, false otherwise
|
||||
*/
|
||||
private async tryLoadFromCache(
|
||||
startUrl: string,
|
||||
embeddingId: string,
|
||||
siteIndexingConfig: SiteIndexingConfig,
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
const cacheHit = await this.tryFetchFromCache(startUrl, embeddingId);
|
||||
|
||||
if (cacheHit) {
|
||||
console.log(`Successfully loaded cached embeddings for ${startUrl}`);
|
||||
// Update status to complete
|
||||
this.handleStatusUpdate({
|
||||
type: "docs",
|
||||
id: startUrl,
|
||||
embeddingsProviderId: embeddingId,
|
||||
isReindexing: false,
|
||||
title: siteIndexingConfig.title,
|
||||
debugInfo: "Loaded from cache",
|
||||
icon: siteIndexingConfig.faviconUrl,
|
||||
url: startUrl,
|
||||
progress: 1,
|
||||
description: "Complete",
|
||||
status: "complete",
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`Error trying to fetch from cache: ${e}`);
|
||||
// Continue with regular indexing
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
async indexAndAdd(
|
||||
siteIndexingConfig: SiteIndexingConfig,
|
||||
forceReindex: boolean = false,
|
||||
|
|
@ -392,21 +392,28 @@ export default class DocsService {
|
|||
return;
|
||||
}
|
||||
|
||||
const { isPreindexed, provider } =
|
||||
await this.getEmbeddingsProvider(startUrl);
|
||||
if (isPreindexed) {
|
||||
console.warn("Attempted to indexAndAdd pre-indexed doc");
|
||||
return;
|
||||
}
|
||||
const { provider } = await this.getEmbeddingsProvider();
|
||||
if (!provider) {
|
||||
console.warn("@docs indexAndAdd: no embeddings provider found");
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to fetch from cache first before crawling
|
||||
if (!forceReindex) {
|
||||
const cacheLoaded = await this.tryLoadFromCache(
|
||||
startUrl,
|
||||
provider.embeddingId,
|
||||
siteIndexingConfig,
|
||||
);
|
||||
|
||||
if (cacheLoaded) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const startedWithEmbedder = provider.embeddingId;
|
||||
|
||||
// Check if doc has been successfully indexed with the given embedder
|
||||
// Note at this point we know it's not a pre-indexed doc
|
||||
const indexExists = await this.hasMetadata(startUrl);
|
||||
|
||||
// Build status update - most of it is fixed values
|
||||
|
|
@ -622,7 +629,7 @@ export default class DocsService {
|
|||
progress: 1,
|
||||
});
|
||||
|
||||
void this.ide.showToast("info", `Failed to index ${startUrl}`);
|
||||
// void this.ide.showToast("info", `Failed to index ${startUrl}`);
|
||||
markFailedInGlobalContext();
|
||||
return;
|
||||
}
|
||||
|
|
@ -672,7 +679,12 @@ export default class DocsService {
|
|||
progress: 1,
|
||||
});
|
||||
|
||||
void this.ide.showToast("info", `Successfully indexed ${startUrl}`);
|
||||
// Only show notificaitons if the user manually re-indexed, otherwise
|
||||
// they are too noisy, especially when switching embeddings providers
|
||||
// and we automatically re-index all docs
|
||||
if (forceReindex) {
|
||||
void this.ide.showToast("info", `Successfully indexed ${startUrl}`);
|
||||
}
|
||||
|
||||
this.messenger?.send("refreshSubmenuItems", {
|
||||
providers: ["docs"],
|
||||
|
|
@ -705,36 +717,42 @@ export default class DocsService {
|
|||
}
|
||||
}
|
||||
|
||||
// When user requests a pre-indexed doc for the first time
|
||||
// And pre-indexed embeddings are supported
|
||||
// Fetch pre-indexed embeddings from S3, add to Lance, and then search those
|
||||
private async fetchAndAddPreIndexedDocEmbeddings(title: string) {
|
||||
const data = await downloadFromS3(
|
||||
S3Buckets.continueIndexedDocs,
|
||||
getS3Filename(
|
||||
DocsService.preIndexedDocsEmbeddingsProvider.embeddingId,
|
||||
title,
|
||||
),
|
||||
);
|
||||
/**
|
||||
* Try to fetch embeddings from the S3 cache for any document URL
|
||||
* @param startUrl The URL of the documentation site
|
||||
* @param embeddingsProviderId The ID of the embeddings provider
|
||||
* @returns True if cache hit and successfully loaded, false otherwise
|
||||
*/
|
||||
private async tryFetchFromCache(
|
||||
startUrl: string,
|
||||
embeddingId: string,
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
const data = await DocsCache.getDocsCacheForUrl(embeddingId, startUrl);
|
||||
|
||||
const siteEmbeddings = JSON.parse(data) as SiteIndexingResults;
|
||||
const startUrl = new URL(siteEmbeddings.url).toString();
|
||||
// Parse the cached data
|
||||
const siteEmbeddings = JSON.parse(data) as SiteIndexingResults;
|
||||
|
||||
const faviconUrl = preIndexedDocs[startUrl].faviconUrl;
|
||||
const favicon =
|
||||
typeof faviconUrl === "string"
|
||||
? await getFaviconBase64(faviconUrl)
|
||||
: undefined;
|
||||
// Try to get a favicon for the site
|
||||
const favicon = await fetchFavicon(new URL(startUrl));
|
||||
|
||||
await this.add({
|
||||
favicon,
|
||||
siteIndexingConfig: {
|
||||
startUrl,
|
||||
title: siteEmbeddings.title,
|
||||
},
|
||||
chunks: siteEmbeddings.chunks,
|
||||
embeddings: siteEmbeddings.chunks.map((c) => c.embedding),
|
||||
});
|
||||
// Add the cached embeddings to our database
|
||||
await this.add({
|
||||
favicon,
|
||||
siteIndexingConfig: {
|
||||
startUrl,
|
||||
title: siteEmbeddings.title || new URL(startUrl).hostname,
|
||||
},
|
||||
chunks: siteEmbeddings.chunks,
|
||||
embeddings: siteEmbeddings.chunks.map((c) => c.embedding),
|
||||
});
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
// Cache miss or error - silently fail
|
||||
console.log(`Cache miss for ${startUrl} with provider ${embeddingId}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve docs embeds based on user input
|
||||
|
|
@ -743,8 +761,7 @@ export default class DocsService {
|
|||
startUrl: string,
|
||||
nRetrieve: number,
|
||||
) {
|
||||
const { isPreindexed, provider } =
|
||||
await this.getEmbeddingsProvider(startUrl);
|
||||
const { provider } = await this.getEmbeddingsProvider();
|
||||
|
||||
if (!provider) {
|
||||
void this.ide.showToast(
|
||||
|
|
@ -755,15 +772,11 @@ export default class DocsService {
|
|||
return [];
|
||||
}
|
||||
|
||||
if (isPreindexed) {
|
||||
void Telemetry.capture("docs_pre_indexed_doc_used", {
|
||||
doc: preIndexedDocs[startUrl]!["title"],
|
||||
});
|
||||
}
|
||||
|
||||
// Try to get embeddings for the query
|
||||
const [vector] = await provider.embed([query]);
|
||||
|
||||
return await this.retrieveChunks(startUrl, vector, nRetrieve, isPreindexed);
|
||||
// Retrieve chunks using the query vector
|
||||
return await this.retrieveChunks(startUrl, vector, nRetrieve);
|
||||
}
|
||||
|
||||
private lanceDBRowToChunk(row: LanceDbDocsRow): Chunk {
|
||||
|
|
@ -783,8 +796,7 @@ export default class DocsService {
|
|||
const db = await this.getOrCreateSqliteDb();
|
||||
|
||||
try {
|
||||
const { isPreindexed, provider } =
|
||||
await this.getEmbeddingsProvider(startUrl);
|
||||
const { provider } = await this.getEmbeddingsProvider();
|
||||
|
||||
if (!provider) {
|
||||
throw new Error("No embeddings model set");
|
||||
|
|
@ -819,22 +831,26 @@ export default class DocsService {
|
|||
config: siteIndexingConfig,
|
||||
indexingStatus: this.statuses.get(startUrl),
|
||||
chunks: rows.map(this.lanceDBRowToChunk),
|
||||
isPreIndexedDoc: isPreindexed,
|
||||
};
|
||||
} catch (e) {
|
||||
console.warn("Error getting details", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
// This is split into its own function so that it can be recursive
|
||||
// in the case of fetching preindexed docs from s3
|
||||
// This function attempts to retrieve chunks by vector similarity
|
||||
// It will also attempt to fetch from cache if no results are found
|
||||
async retrieveChunks(
|
||||
startUrl: string,
|
||||
vector: number[],
|
||||
nRetrieve: number,
|
||||
isPreindexed: boolean,
|
||||
isRetry: boolean = false,
|
||||
): Promise<Chunk[]> {
|
||||
// Get the appropriate embeddings provider
|
||||
const { provider } = await this.getEmbeddingsProvider();
|
||||
if (!provider) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Lance doesn't have an embeddingsprovider column, instead it includes it in the table name
|
||||
const table = await this.getOrCreateLanceTable({
|
||||
initializationVector: vector,
|
||||
|
|
@ -852,15 +868,22 @@ export default class DocsService {
|
|||
console.warn("Error retrieving chunks from LanceDB", e);
|
||||
}
|
||||
|
||||
// No docs are found for preindexed? try fetching once
|
||||
if (docs.length === 0 && isPreindexed) {
|
||||
if (isRetry) {
|
||||
return [];
|
||||
// If no docs are found and this isn't a retry, try fetching from cache
|
||||
if (docs.length === 0 && !isRetry) {
|
||||
try {
|
||||
// Try to fetch the document from the S3 cache
|
||||
const cacheHit = await this.tryFetchFromCache(
|
||||
startUrl,
|
||||
provider.embeddingId,
|
||||
);
|
||||
|
||||
if (cacheHit) {
|
||||
// If cache hit, retry the search once
|
||||
return await this.retrieveChunks(startUrl, vector, nRetrieve, true);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Error trying to fetch from cache:", e);
|
||||
}
|
||||
await this.fetchAndAddPreIndexedDocEmbeddings(
|
||||
preIndexedDocs[startUrl]!["title"],
|
||||
);
|
||||
return await this.retrieveChunks(startUrl, vector, nRetrieve, true, true);
|
||||
}
|
||||
|
||||
return docs.map(this.lanceDBRowToChunk);
|
||||
|
|
@ -912,10 +935,9 @@ export default class DocsService {
|
|||
return result.favicon;
|
||||
}
|
||||
|
||||
/*
|
||||
Sync with no embeddings provider change
|
||||
Ignores pre-indexed docs
|
||||
*/
|
||||
/**
|
||||
* Sync with no embeddings provider change
|
||||
*/
|
||||
private async syncDocs(
|
||||
oldConfig: ContinueConfig | undefined,
|
||||
newConfig: ContinueConfig,
|
||||
|
|
@ -933,11 +955,9 @@ export default class DocsService {
|
|||
const currentlyIndexedDocs = await this.listMetadata();
|
||||
const currentStartUrls = currentlyIndexedDocs.map((doc) => doc.startUrl);
|
||||
|
||||
// Anything found in sqlite but not in new config should be deleted if not preindexed
|
||||
// Anything found in sqlite but not in new config should be deleted
|
||||
const deletedDocs = currentlyIndexedDocs.filter(
|
||||
(doc) =>
|
||||
!preIndexedDocs[doc.startUrl] &&
|
||||
!newConfigStartUrls.includes(doc.startUrl),
|
||||
(doc) => !newConfigStartUrls.includes(doc.startUrl),
|
||||
);
|
||||
|
||||
// Anything found in old config, new config, AND sqlite that doesn't match should be reindexed
|
||||
|
|
@ -1063,7 +1083,7 @@ export default class DocsService {
|
|||
|
||||
const conn = await lance.connect(getLanceDbPath());
|
||||
const tableNames = await conn.tableNames();
|
||||
const { provider } = await this.getEmbeddingsProvider(startUrl);
|
||||
const { provider } = await this.getEmbeddingsProvider();
|
||||
|
||||
if (!provider) {
|
||||
throw new Error(
|
||||
|
|
@ -1164,15 +1184,30 @@ export default class DocsService {
|
|||
);
|
||||
|
||||
if (!doesEquivalentDocExist) {
|
||||
editConfigJson((config) => ({
|
||||
...config,
|
||||
docs: [
|
||||
...(config.docs?.filter(
|
||||
(doc) => doc.startUrl !== siteIndexingConfig.startUrl,
|
||||
) ?? []),
|
||||
siteIndexingConfig,
|
||||
],
|
||||
}));
|
||||
editConfigFile(
|
||||
(config) => ({
|
||||
...config,
|
||||
docs: [
|
||||
...(config.docs?.filter(
|
||||
(doc) => doc.startUrl !== siteIndexingConfig.startUrl,
|
||||
) ?? []),
|
||||
siteIndexingConfig,
|
||||
],
|
||||
}),
|
||||
(config) => ({
|
||||
...config,
|
||||
docs: [
|
||||
...(config.docs?.filter(
|
||||
(doc) => (doc as any).startUrl !== siteIndexingConfig.startUrl,
|
||||
) ?? []),
|
||||
{
|
||||
name: siteIndexingConfig.title,
|
||||
faviconUrl: siteIndexingConfig.faviconUrl,
|
||||
startUrl: siteIndexingConfig.startUrl,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1216,10 +1251,19 @@ export default class DocsService {
|
|||
(doc) => doc.startUrl === startUrl,
|
||||
);
|
||||
if (doesDocExist) {
|
||||
editConfigJson((config) => ({
|
||||
...config,
|
||||
docs: config.docs?.filter((doc) => doc.startUrl !== startUrl) || [],
|
||||
}));
|
||||
editConfigFile(
|
||||
(config) => ({
|
||||
...config,
|
||||
docs: config.docs?.filter((doc) => doc.startUrl !== startUrl) || [],
|
||||
}),
|
||||
(config) => ({
|
||||
...config,
|
||||
docs:
|
||||
config.docs?.filter(
|
||||
(doc) => "startUrl" in doc && doc.startUrl !== startUrl,
|
||||
) || [],
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import PCR from "puppeteer-chromium-resolver";
|
|||
|
||||
import { ContinueConfig, IDE } from "../../..";
|
||||
import {
|
||||
editConfigJson,
|
||||
editConfigFile,
|
||||
getChromiumPath,
|
||||
getContinueUtilsPath,
|
||||
} from "../../../util/paths";
|
||||
|
|
@ -26,13 +26,16 @@ export class ChromiumCrawler {
|
|||
) {}
|
||||
|
||||
static setUseChromiumForDocsCrawling(useChromiumForDocsCrawling: boolean) {
|
||||
editConfigJson((config) => ({
|
||||
...config,
|
||||
experimental: {
|
||||
...config.experimental,
|
||||
useChromiumForDocsCrawling,
|
||||
},
|
||||
}));
|
||||
editConfigFile(
|
||||
(config) => ({
|
||||
...config,
|
||||
experimental: {
|
||||
...config.experimental,
|
||||
useChromiumForDocsCrawling,
|
||||
},
|
||||
}),
|
||||
(config) => config, // Not used in config.yaml
|
||||
);
|
||||
}
|
||||
|
||||
async *crawl(): AsyncGenerator<PageData> {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { type Database } from "sqlite";
|
||||
import { type Table } from "vectordb";
|
||||
|
||||
import { editConfigJson, migrate } from "../../util/paths.js";
|
||||
import { editConfigFile, migrate } from "../../util/paths.js";
|
||||
|
||||
import DocsService, { SqliteDocsRow } from "./DocsService.js";
|
||||
|
||||
|
|
@ -58,10 +58,22 @@ export async function runSqliteMigrations(db: Database) {
|
|||
const sqliteDocs = await db.all<
|
||||
Array<Pick<SqliteDocsRow, "title" | "startUrl">>
|
||||
>(`SELECT title, startUrl FROM ${DocsService.sqlitebTableName}`);
|
||||
editConfigJson((config) => ({
|
||||
...config,
|
||||
docs: [...(config.docs || []), ...sqliteDocs],
|
||||
}));
|
||||
editConfigFile(
|
||||
(config) => ({
|
||||
...config,
|
||||
docs: [...(config.docs || []), ...sqliteDocs],
|
||||
}),
|
||||
(config) => ({
|
||||
...config,
|
||||
docs: [
|
||||
...(config.docs || []),
|
||||
...sqliteDocs.map((doc) => ({
|
||||
name: doc.title,
|
||||
startUrl: doc.startUrl,
|
||||
})),
|
||||
],
|
||||
}),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
resolve(undefined);
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
import request from "request";
|
||||
|
||||
import { Chunk } from "../../";
|
||||
|
||||
export function getS3Filename(
|
||||
embeddingsProviderId: string,
|
||||
title: string,
|
||||
): string {
|
||||
return `_TransformersJsEmbeddingsProvider::all-MiniLM-L6-v2/${title}`;
|
||||
}
|
||||
|
||||
export enum S3Buckets {
|
||||
continueIndexedDocs = "continue-indexed-docs",
|
||||
}
|
||||
|
||||
const AWS_REGION = "us-west-1";
|
||||
|
||||
export async function downloadFromS3(
|
||||
bucket: string,
|
||||
fileName: string,
|
||||
): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
let data = "";
|
||||
|
||||
const download = request({
|
||||
url: `https://${bucket}.s3.${AWS_REGION}.amazonaws.com/${fileName}`,
|
||||
});
|
||||
download.on("response", (response: any) => {
|
||||
if (response.statusCode !== 200) {
|
||||
reject(new Error("There was an error retreiving the pre-indexed doc"));
|
||||
}
|
||||
});
|
||||
|
||||
download.on("error", (err: any) => {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
download.on("data", (chunk: any) => {
|
||||
data += chunk;
|
||||
});
|
||||
|
||||
download.on("end", () => {
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export interface SiteIndexingResults {
|
||||
chunks: (Chunk & { embedding: number[] })[];
|
||||
url: string;
|
||||
title: string;
|
||||
}
|
||||
|
|
@ -1,368 +0,0 @@
|
|||
import { SiteIndexingConfig } from "../../";
|
||||
|
||||
const preIndexedDocs: Record<
|
||||
SiteIndexingConfig["startUrl"],
|
||||
SiteIndexingConfig
|
||||
> = {
|
||||
"https://jinja.palletsprojects.com/en/3.1.x/": {
|
||||
title: "Jinja",
|
||||
startUrl: "https://jinja.palletsprojects.com/en/3.1.x/",
|
||||
rootUrl: "https://jinja.palletsprojects.com/en/3.1.x/",
|
||||
faviconUrl: "https://jinja.palletsprojects.com/favicon.ico",
|
||||
},
|
||||
"https://react.dev/reference/": {
|
||||
title: "React",
|
||||
startUrl: "https://react.dev/reference/",
|
||||
rootUrl: "https://react.dev/reference/",
|
||||
faviconUrl: "https://react.dev/favicon.ico",
|
||||
},
|
||||
"https://posthog.com/docs": {
|
||||
title: "PostHog",
|
||||
startUrl: "https://posthog.com/docs",
|
||||
rootUrl: "https://posthog.com/docs",
|
||||
faviconUrl: "https://posthog.com/favicon.ico",
|
||||
},
|
||||
"https://expressjs.com/en/5x/api.html": {
|
||||
title: "Express",
|
||||
startUrl: "https://expressjs.com/en/5x/api.html",
|
||||
rootUrl: "https://expressjs.com/en/5x/",
|
||||
faviconUrl: "https://expressjs.com/favicon.ico",
|
||||
},
|
||||
"https://platform.openai.com/docs/": {
|
||||
title: "OpenAI",
|
||||
startUrl: "https://platform.openai.com/docs/",
|
||||
rootUrl: "https://platform.openai.com/docs/",
|
||||
faviconUrl: "https://platform.openai.com/favicon.ico",
|
||||
},
|
||||
"https://www.prisma.io/docs": {
|
||||
title: "Prisma",
|
||||
startUrl: "https://www.prisma.io/docs",
|
||||
rootUrl: "https://www.prisma.io/docs",
|
||||
faviconUrl: "https://www.prisma.io/favicon.ico",
|
||||
},
|
||||
"https://boto3.amazonaws.com/v1/documentation/api/latest/index.html": {
|
||||
title: "Boto3",
|
||||
startUrl:
|
||||
"https://boto3.amazonaws.com/v1/documentation/api/latest/index.html",
|
||||
rootUrl: "https://boto3.amazonaws.com/v1/documentation/api/latest/",
|
||||
faviconUrl: "https://boto3.amazonaws.com/favicon.ico",
|
||||
},
|
||||
"https://pytorch.org/docs/stable/": {
|
||||
title: "Pytorch",
|
||||
startUrl: "https://pytorch.org/docs/stable/",
|
||||
rootUrl: "https://pytorch.org/docs/stable/",
|
||||
faviconUrl: "https://pytorch.org/favicon.ico",
|
||||
},
|
||||
"https://redis.io/docs/": {
|
||||
title: "Redis",
|
||||
startUrl: "https://redis.io/docs/",
|
||||
rootUrl: "https://redis.io/docs/",
|
||||
faviconUrl: "https://redis.io/favicon.ico",
|
||||
},
|
||||
"https://axios-http.com/docs/intro": {
|
||||
title: "Axios",
|
||||
startUrl: "https://axios-http.com/docs/intro",
|
||||
rootUrl: "https://axios-http.com/docs",
|
||||
faviconUrl: "https://axios-http.com/favicon.ico",
|
||||
},
|
||||
"https://redwoodjs.com/docs/introduction": {
|
||||
title: "Redwood JS",
|
||||
startUrl: "https://redwoodjs.com/docs/introduction",
|
||||
rootUrl: "https://redwoodjs.com/docs",
|
||||
faviconUrl: "https://redwoodjs.com/favicon.ico",
|
||||
},
|
||||
"https://graphql.org/learn/": {
|
||||
title: "GraphQL",
|
||||
startUrl: "https://graphql.org/learn/",
|
||||
rootUrl: "https://graphql.org/learn/",
|
||||
faviconUrl: "https://graphql.org/favicon.ico",
|
||||
},
|
||||
"https://www.typescriptlang.org/docs/": {
|
||||
title: "Typescript",
|
||||
startUrl: "https://www.typescriptlang.org/docs/",
|
||||
rootUrl: "https://www.typescriptlang.org/docs/",
|
||||
faviconUrl: "https://www.typescriptlang.org/favicon.ico",
|
||||
},
|
||||
"https://jestjs.io/docs/getting-started": {
|
||||
title: "Jest",
|
||||
startUrl: "https://jestjs.io/docs/getting-started",
|
||||
rootUrl: "https://jestjs.io/docs",
|
||||
faviconUrl: "https://jestjs.io/favicon.ico",
|
||||
},
|
||||
"https://tailwindcss.com/docs/installation": {
|
||||
title: "Tailwind CSS",
|
||||
startUrl: "https://tailwindcss.com/docs/installation",
|
||||
rootUrl: "https://tailwindcss.com/docs",
|
||||
faviconUrl: "https://tailwindcss.com/favicon.ico",
|
||||
},
|
||||
"https://vuejs.org/guide/introduction.html": {
|
||||
title: "Vue.js",
|
||||
startUrl: "https://vuejs.org/guide/introduction.html",
|
||||
rootUrl: "https://vuejs.org",
|
||||
faviconUrl: "https://vuejs.org/favicon.ico",
|
||||
},
|
||||
"https://svelte.dev/docs/introduction": {
|
||||
title: "Svelte",
|
||||
startUrl: "https://svelte.dev/docs/introduction",
|
||||
rootUrl: "https://svelte.dev/docs",
|
||||
faviconUrl: "https://svelte.dev/favicon.ico",
|
||||
},
|
||||
"https://docs.github.com/en/actions": {
|
||||
title: "GitHub Actions",
|
||||
startUrl: "https://docs.github.com/en/actions",
|
||||
rootUrl: "https://docs.github.com/en/actions",
|
||||
faviconUrl: "https://docs.github.com/favicon.ico",
|
||||
},
|
||||
"https://nodejs.org/docs/latest/api/": {
|
||||
title: "NodeJS",
|
||||
startUrl: "https://nodejs.org/docs/latest/api/",
|
||||
rootUrl: "https://nodejs.org/docs/latest/api/",
|
||||
faviconUrl: "https://nodejs.org/favicon.ico",
|
||||
},
|
||||
"https://socket.io/docs/v4/": {
|
||||
title: "Socket.io",
|
||||
startUrl: "https://socket.io/docs/v4/",
|
||||
rootUrl: "https://socket.io/docs/v4/",
|
||||
faviconUrl: "https://socket.io/favicon.ico",
|
||||
},
|
||||
"https://docs.gradle.org/current/userguide/userguide.html": {
|
||||
title: "Gradle",
|
||||
startUrl: "https://docs.gradle.org/current/userguide/userguide.html",
|
||||
rootUrl: "https://docs.gradle.org/current",
|
||||
faviconUrl: "https://docs.gradle.org/favicon.ico",
|
||||
},
|
||||
"https://redux-toolkit.js.org/introduction/getting-started": {
|
||||
title: "Redux Toolkit",
|
||||
startUrl: "https://redux-toolkit.js.org/introduction/getting-started",
|
||||
rootUrl: "https://redux-toolkit.js.org",
|
||||
faviconUrl: "https://redux-toolkit.js.org/favicon.ico",
|
||||
},
|
||||
"https://docs.trychroma.com/": {
|
||||
title: "Chroma",
|
||||
startUrl: "https://docs.trychroma.com/",
|
||||
rootUrl: "https://docs.trychroma.com/",
|
||||
faviconUrl: "https://docs.trychroma.com/favicon.ico",
|
||||
},
|
||||
"https://www.sqlite.org/docs.html": {
|
||||
title: "SQLite",
|
||||
startUrl: "https://www.sqlite.org/docs.html",
|
||||
rootUrl: "https://www.sqlite.org",
|
||||
faviconUrl: "https://www.sqlite.org/favicon.ico",
|
||||
},
|
||||
"https://redux.js.org/introduction/getting-started": {
|
||||
title: "Redux",
|
||||
startUrl: "https://redux.js.org/introduction/getting-started",
|
||||
rootUrl: "https://redux.js.org",
|
||||
faviconUrl: "https://redux.js.org/favicon.ico",
|
||||
},
|
||||
"https://prettier.io/docs/en/": {
|
||||
title: "Prettier",
|
||||
startUrl: "https://prettier.io/docs/en/",
|
||||
rootUrl: "https://prettier.io/docs/en/",
|
||||
faviconUrl: "https://prettier.io/favicon.ico",
|
||||
},
|
||||
"https://code.visualstudio.com/api": {
|
||||
title: "VS Code Extension API",
|
||||
startUrl: "https://code.visualstudio.com/api",
|
||||
rootUrl: "https://code.visualstudio.com/api",
|
||||
faviconUrl: "https://code.visualstudio.com/favicon.ico",
|
||||
},
|
||||
"https://docs.continue.dev/intro": {
|
||||
title: "Continue",
|
||||
startUrl: "https://docs.continue.dev/intro",
|
||||
rootUrl: "https://docs.continue.dev",
|
||||
faviconUrl: "https://docs.continue.dev/favicon.ico",
|
||||
},
|
||||
"https://api.jquery.com/": {
|
||||
title: "jQuery",
|
||||
startUrl: "https://api.jquery.com/",
|
||||
rootUrl: "https://api.jquery.com/",
|
||||
faviconUrl: "https://api.jquery.com/favicon.ico",
|
||||
},
|
||||
"https://docs.python.org/3/": {
|
||||
title: "Python",
|
||||
startUrl: "https://docs.python.org/3/",
|
||||
rootUrl: "https://docs.python.org/3/",
|
||||
faviconUrl: "https://docs.python.org/favicon.ico",
|
||||
},
|
||||
"https://doc.rust-lang.org/book/": {
|
||||
title: "Rust",
|
||||
startUrl: "https://doc.rust-lang.org/book/",
|
||||
rootUrl: "https://doc.rust-lang.org/book/",
|
||||
faviconUrl: "https://doc.rust-lang.org/favicon.ico",
|
||||
},
|
||||
"https://plugins.jetbrains.com/docs/intellij/welcome.html": {
|
||||
title: "IntelliJ Platform SDK",
|
||||
startUrl: "https://plugins.jetbrains.com/docs/intellij/welcome.html",
|
||||
rootUrl: "https://plugins.jetbrains.com/docs/intellij",
|
||||
faviconUrl: "https://plugins.jetbrains.com/favicon.ico",
|
||||
},
|
||||
"https://docs.docker.com/": {
|
||||
title: "Docker",
|
||||
startUrl: "https://docs.docker.com/",
|
||||
rootUrl: "https://docs.docker.com/",
|
||||
faviconUrl: "https://docs.docker.com/favicon.ico",
|
||||
},
|
||||
"https://docs.npmjs.com/": {
|
||||
title: "NPM",
|
||||
startUrl: "https://docs.npmjs.com/",
|
||||
rootUrl: "https://docs.npmjs.com/",
|
||||
faviconUrl: "https://docs.npmjs.com/favicon.ico",
|
||||
},
|
||||
"https://tiptap.dev/docs/editor/introduction": {
|
||||
title: "TipTap",
|
||||
startUrl: "https://tiptap.dev/docs/editor/introduction",
|
||||
rootUrl: "https://tiptap.dev/docs",
|
||||
faviconUrl: "https://tiptap.dev/favicon.ico",
|
||||
},
|
||||
"https://esbuild.github.io/": {
|
||||
title: "esbuild",
|
||||
startUrl: "https://esbuild.github.io/",
|
||||
rootUrl: "https://esbuild.github.io/",
|
||||
faviconUrl: "https://esbuild.github.io/favicon.ico",
|
||||
},
|
||||
"https://tree-sitter.github.io/tree-sitter/": {
|
||||
title: "Tree Sitter",
|
||||
startUrl: "https://tree-sitter.github.io/tree-sitter/",
|
||||
rootUrl: "https://tree-sitter.github.io/tree-sitter/",
|
||||
faviconUrl: "https://tree-sitter.github.io/favicon.ico",
|
||||
},
|
||||
"https://docs.netlify.com/": {
|
||||
title: "Netlify",
|
||||
startUrl: "https://docs.netlify.com/",
|
||||
rootUrl: "https://docs.netlify.com/",
|
||||
faviconUrl: "https://docs.netlify.com/favicon.ico",
|
||||
},
|
||||
"https://replicate.com/docs": {
|
||||
title: "Replicate",
|
||||
startUrl: "https://replicate.com/docs",
|
||||
rootUrl: "https://replicate.com/docs",
|
||||
faviconUrl: "https://replicate.com/favicon.ico",
|
||||
},
|
||||
"https://www.w3schools.com/html/default.asp": {
|
||||
title: "HTML",
|
||||
startUrl: "https://www.w3schools.com/html/default.asp",
|
||||
rootUrl: "https://www.w3schools.com/html",
|
||||
faviconUrl: "https://www.w3schools.com/favicon.ico",
|
||||
},
|
||||
"https://www.w3schools.com/css/default.asp": {
|
||||
title: "CSS",
|
||||
startUrl: "https://www.w3schools.com/css/default.asp",
|
||||
rootUrl: "https://www.w3schools.com/css",
|
||||
faviconUrl: "https://www.w3schools.com/favicon.ico",
|
||||
},
|
||||
"https://python.langchain.com/docs/get_started/introduction": {
|
||||
title: "Langchain",
|
||||
startUrl: "https://python.langchain.com/docs/get_started/introduction",
|
||||
rootUrl: "https://python.langchain.com/docs",
|
||||
faviconUrl: "https://python.langchain.com/favicon.ico",
|
||||
},
|
||||
"https://developer.woocommerce.com/docs/": {
|
||||
title: "WooCommerce",
|
||||
startUrl: "https://developer.woocommerce.com/docs/",
|
||||
rootUrl: "https://developer.woocommerce.com/docs/",
|
||||
faviconUrl: "https://developer.woocommerce.com/favicon.ico",
|
||||
},
|
||||
"https://developer.wordpress.org/reference/": {
|
||||
title: "WordPress",
|
||||
startUrl: "https://developer.wordpress.org/reference/",
|
||||
rootUrl: "https://developer.wordpress.org/reference/",
|
||||
faviconUrl: "https://developer.wordpress.org/favicon.ico",
|
||||
},
|
||||
"https://doc.qt.io/qtforpython-6/quickstart.html": {
|
||||
title: "PySide6",
|
||||
startUrl: "https://doc.qt.io/qtforpython-6/quickstart.html",
|
||||
rootUrl: "https://doc.qt.io/qtforpython-6/api.html",
|
||||
faviconUrl: "https://doc.qt.io/favicon.ico",
|
||||
},
|
||||
"https://getbootstrap.com/docs/5.3/getting-started/introduction/": {
|
||||
title: "Bootstrap",
|
||||
startUrl: "https://getbootstrap.com/docs/5.3/getting-started/introduction/",
|
||||
rootUrl: "https://getbootstrap.com/docs/5.3/",
|
||||
faviconUrl: "https://getbootstrap.com/favicon.ico",
|
||||
},
|
||||
"https://alpinejs.dev/start-here": {
|
||||
title: "Alpine.js",
|
||||
startUrl: "https://alpinejs.dev/start-here",
|
||||
rootUrl: "https://alpinejs.dev/",
|
||||
faviconUrl: "https://alpinejs.dev/favicon.ico",
|
||||
},
|
||||
"https://learn.microsoft.com/en-us/dotnet/csharp/": {
|
||||
title: "C# Language Reference",
|
||||
startUrl: "https://learn.microsoft.com/en-us/dotnet/csharp/",
|
||||
rootUrl: "https://learn.microsoft.com/en-us/dotnet/csharp/",
|
||||
faviconUrl: "https://learn.microsoft.com/favicon.ico",
|
||||
},
|
||||
"https://docs.godotengine.org/en/latest/": {
|
||||
title: "Godot",
|
||||
startUrl: "https://docs.godotengine.org/en/latest/",
|
||||
rootUrl: "https://docs.godotengine.org/en/latest/",
|
||||
faviconUrl: "https://godotengine.org/favicon.ico",
|
||||
},
|
||||
"https://docs.amplify.aws/react/start/": {
|
||||
title: "AWS Amplify (Gen 2)",
|
||||
startUrl: "https://docs.amplify.aws/react/start/",
|
||||
rootUrl: "https://docs.amplify.aws/react/",
|
||||
faviconUrl: "https://docs.amplify.aws/favicon.ico",
|
||||
},
|
||||
"https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/": {
|
||||
title: "AWS SDK for JavaScript v3",
|
||||
startUrl: "https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/",
|
||||
rootUrl: "https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/",
|
||||
faviconUrl: "https://docs.aws.amazon.com/favicon.ico",
|
||||
},
|
||||
"https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html": {
|
||||
title: "AWS CDK v2",
|
||||
startUrl:
|
||||
"https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html",
|
||||
rootUrl: "https://docs.aws.amazon.com/cdk/api/v2/docs/",
|
||||
faviconUrl: "https://docs.aws.amazon.com/cdk/api/v2/img/favicon-32x32.png",
|
||||
},
|
||||
"https://awscli.amazonaws.com/v2/documentation/api/latest/index.html": {
|
||||
title: "AWS CLI commands",
|
||||
startUrl:
|
||||
"https://awscli.amazonaws.com/v2/documentation/api/latest/index.html",
|
||||
rootUrl: "https://awscli.amazonaws.com/v2/documentation/api/latest/",
|
||||
faviconUrl: "https://docs.aws.amazon.com/favicon.ico",
|
||||
},
|
||||
"https://llama-stack.readthedocs.io/": {
|
||||
title: "Llama Stack",
|
||||
startUrl: "https://llama-stack.readthedocs.io/",
|
||||
rootUrl: "https://llama-stack.readthedocs.io/",
|
||||
},
|
||||
"https://go.dev/doc": {
|
||||
title: "Go",
|
||||
startUrl: "https://go.dev/doc",
|
||||
rootUrl: "https://go.dev",
|
||||
faviconUrl: "https://go.dev/favicon.ico",
|
||||
},
|
||||
"https://api.flutter.dev": {
|
||||
title: "Flutter",
|
||||
startUrl: "https://api.flutter.dev",
|
||||
rootUrl: "https://api.flutter.dev",
|
||||
faviconUrl: "https://api.flutter.dev/flutter/static-assets/favicon.png",
|
||||
},
|
||||
"https://api.dart.dev": {
|
||||
title: "Dart",
|
||||
startUrl: "https://api.dart.dev",
|
||||
rootUrl: "https://api.dart.dev",
|
||||
faviconUrl: "https://api.dart.dev/static-assets/favicon.png",
|
||||
},
|
||||
"https://docs.asksage.ai/": {
|
||||
title: "Ask Sage",
|
||||
startUrl: "https://docs.asksage.ai/",
|
||||
rootUrl: "https://docs.asksage.ai/",
|
||||
},
|
||||
"https://angular.dev/": {
|
||||
title: "Angular",
|
||||
startUrl: "https://angular.dev/",
|
||||
rootUrl: "https://angular.dev/",
|
||||
},
|
||||
"https://docs.djangoproject.com/": {
|
||||
title: "Django",
|
||||
startUrl: "https://docs.djangoproject.com/",
|
||||
rootUrl: "https://docs.djangoproject.com/",
|
||||
}
|
||||
};
|
||||
|
||||
export default preIndexedDocs;
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
import {
|
||||
PackageDocsResult,
|
||||
FilePathAndName,
|
||||
PackageFilePathAndName,
|
||||
IDE,
|
||||
PackageDetails,
|
||||
ParsedPackageInfo,
|
||||
} from "../../..";
|
||||
import { getUriPathBasename } from "../../../util/uri";
|
||||
import { walkDir, walkDirs } from "../../walkDir";
|
||||
|
||||
import { PythonPackageCrawler } from "./packageCrawlers/Python";
|
||||
import { NodePackageCrawler } from "./packageCrawlers/TsJs";
|
||||
|
||||
const PACKAGE_CRAWLERS = [NodePackageCrawler, PythonPackageCrawler];
|
||||
|
||||
export interface PackageCrawler {
|
||||
packageRegistry: string;
|
||||
getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[];
|
||||
parsePackageFile(
|
||||
file: PackageFilePathAndName,
|
||||
contents: string,
|
||||
): ParsedPackageInfo[];
|
||||
getPackageDetails(packageInfo: ParsedPackageInfo): Promise<PackageDetails>;
|
||||
}
|
||||
|
||||
export async function getAllSuggestedDocs(ide: IDE) {
|
||||
const allFileUris = await walkDirs(ide);
|
||||
const allFiles = allFileUris.map((uri) => ({
|
||||
path: uri,
|
||||
name: getUriPathBasename(uri),
|
||||
}));
|
||||
|
||||
// Build map of language -> package files
|
||||
const packageFilesByRegistry: Record<string, PackageFilePathAndName[]> = {};
|
||||
for (const Crawler of PACKAGE_CRAWLERS) {
|
||||
const crawler = new Crawler();
|
||||
const packageFilePaths = crawler.getPackageFiles(allFiles);
|
||||
packageFilesByRegistry[crawler.packageRegistry] = packageFilePaths;
|
||||
}
|
||||
|
||||
// Get file contents for all unique package files
|
||||
const uniqueFilePaths = Array.from(
|
||||
new Set(
|
||||
Object.values(packageFilesByRegistry).flatMap((files) =>
|
||||
files.map((file) => file.path),
|
||||
),
|
||||
),
|
||||
);
|
||||
const fileContentsArray = await Promise.all(
|
||||
uniqueFilePaths.map(async (path) => {
|
||||
const contents = await ide.readFile(path);
|
||||
return { path, contents };
|
||||
}),
|
||||
);
|
||||
const fileContents = new Map(
|
||||
fileContentsArray.map(({ path, contents }) => [path, contents]),
|
||||
);
|
||||
|
||||
// Parse package files and build map of language -> packages
|
||||
const packagesByCrawler: Record<string, ParsedPackageInfo[]> = {};
|
||||
PACKAGE_CRAWLERS.forEach((Crawler) => {
|
||||
const crawler = new Crawler();
|
||||
packagesByCrawler[crawler.packageRegistry] = [];
|
||||
const packageFiles = packageFilesByRegistry[crawler.packageRegistry];
|
||||
packageFiles.forEach((file) => {
|
||||
const contents = fileContents.get(file.path);
|
||||
if (!contents) {
|
||||
return;
|
||||
}
|
||||
const packages = crawler.parsePackageFile(file, contents);
|
||||
packagesByCrawler[crawler.packageRegistry].push(...packages);
|
||||
});
|
||||
});
|
||||
|
||||
// Deduplicate packages per language
|
||||
// TODO - this is where you would allow docs for different versions
|
||||
// by e.g. using "name-version" as the map key instead of just name
|
||||
// For now have not allowed
|
||||
const registries = Object.keys(packagesByCrawler);
|
||||
registries.forEach((registry) => {
|
||||
const packages = packagesByCrawler[registry];
|
||||
const uniquePackages = Array.from(
|
||||
new Map(packages.map((pkg) => [pkg.name, pkg])).values(),
|
||||
);
|
||||
packagesByCrawler[registry] = uniquePackages;
|
||||
});
|
||||
|
||||
// Get documentation links for all packages
|
||||
const allDocsResults: PackageDocsResult[] = [];
|
||||
await Promise.all(
|
||||
PACKAGE_CRAWLERS.map(async (Crawler) => {
|
||||
const crawler = new Crawler();
|
||||
const packages = packagesByCrawler[crawler.packageRegistry];
|
||||
const docsByRegistry = await Promise.all(
|
||||
packages.map(async (packageInfo) => {
|
||||
try {
|
||||
const details = await crawler.getPackageDetails(packageInfo);
|
||||
if (!details.docsLink) {
|
||||
return {
|
||||
packageInfo,
|
||||
error: `No documentation link found for ${packageInfo.name}`,
|
||||
};
|
||||
}
|
||||
return {
|
||||
packageInfo,
|
||||
details: {
|
||||
...details,
|
||||
docsLink: details.docsLink,
|
||||
docsLinkWarning: details.docsLink.includes("github.com")
|
||||
? "Github docs not supported, find the docs site"
|
||||
: details.docsLink.includes("docs")
|
||||
? undefined
|
||||
: "May not be a docs site, check the URL",
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
packageInfo,
|
||||
error: `Error getting package details for ${packageInfo.name}`,
|
||||
};
|
||||
}
|
||||
}),
|
||||
);
|
||||
allDocsResults.push(...docsByRegistry);
|
||||
}),
|
||||
);
|
||||
return allDocsResults;
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
import { PackageCrawler } from "..";
|
||||
import {
|
||||
FilePathAndName,
|
||||
PackageDetails,
|
||||
PackageFilePathAndName,
|
||||
ParsedPackageInfo,
|
||||
} from "../../../..";
|
||||
|
||||
export class PythonPackageCrawler implements PackageCrawler {
|
||||
packageRegistry = "pypi";
|
||||
|
||||
getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[] {
|
||||
// For Python, we typically look for files like requirements.txt or Pipfile
|
||||
return files
|
||||
.filter(
|
||||
(file) => file.name === "requirements.txt" || file.name === "Pipfile",
|
||||
)
|
||||
.map((file) => ({
|
||||
...file,
|
||||
packageRegistry: "pypi",
|
||||
}));
|
||||
}
|
||||
|
||||
parsePackageFile(
|
||||
file: PackageFilePathAndName,
|
||||
contents: string,
|
||||
): ParsedPackageInfo[] {
|
||||
// Assume the fileContent is a string from a requirements.txt formatted file
|
||||
return contents
|
||||
.split("\n")
|
||||
.map((line) => {
|
||||
const [name, version] = line.split("==");
|
||||
return { name, version, packageFile: file, language: "py" };
|
||||
})
|
||||
.filter((pkg) => pkg.name && pkg.version);
|
||||
}
|
||||
|
||||
async getPackageDetails(
|
||||
packageInfo: ParsedPackageInfo,
|
||||
): Promise<PackageDetails> {
|
||||
// Fetch metadata from PyPI to find the documentation link
|
||||
const response = await fetch(
|
||||
`https://pypi.org/pypi/${packageInfo.name}/json`,
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Could not fetch data for package ${packageInfo.name}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
const homePage = data?.info?.home_page as string | undefined;
|
||||
|
||||
return {
|
||||
docsLink:
|
||||
(data?.info?.project_urls?.Documentation as string | undefined) ??
|
||||
homePage,
|
||||
title: data?.info?.name as string | undefined,
|
||||
description: data?.info?.summary as string | undefined,
|
||||
repo:
|
||||
(data?.info?.project_urls?.Repository as string | undefined) ??
|
||||
homePage,
|
||||
license: data?.info?.license as string | undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
import { PackageCrawler } from "..";
|
||||
import {
|
||||
FilePathAndName,
|
||||
PackageDetails,
|
||||
PackageFilePathAndName,
|
||||
ParsedPackageInfo,
|
||||
} from "../../../..";
|
||||
|
||||
export class NodePackageCrawler implements PackageCrawler {
|
||||
packageRegistry = "npm";
|
||||
|
||||
getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[] {
|
||||
// For Javascript/TypeScript, we look for package.json file
|
||||
return files
|
||||
.filter((file) => file.name === "package.json")
|
||||
.map((file) => ({
|
||||
...file,
|
||||
packageRegistry: this.packageRegistry,
|
||||
}));
|
||||
}
|
||||
|
||||
parsePackageFile(
|
||||
file: PackageFilePathAndName,
|
||||
contents: string,
|
||||
): ParsedPackageInfo[] {
|
||||
// Parse the package.json content
|
||||
const jsonData = JSON.parse(contents) as Record<string, Object>;
|
||||
const dependencies = Object.entries(jsonData.dependencies || {}).concat(
|
||||
Object.entries(jsonData.devDependencies || {}),
|
||||
);
|
||||
|
||||
// Filter out types packages and check if typescript is present
|
||||
let foundTypes = false;
|
||||
const filtered = dependencies.filter(([name, _]) => {
|
||||
if (name.startsWith("@types/")) {
|
||||
foundTypes = true;
|
||||
return false;
|
||||
}
|
||||
if (name.includes("typescript")) {
|
||||
foundTypes = true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return filtered.map(([name, version]) => ({
|
||||
name,
|
||||
version,
|
||||
packageFile: file,
|
||||
language: foundTypes ? "ts" : "js",
|
||||
}));
|
||||
}
|
||||
|
||||
async getPackageDetails(
|
||||
packageInfo: ParsedPackageInfo,
|
||||
): Promise<PackageDetails> {
|
||||
const { name } = packageInfo;
|
||||
// Fetch metadata from the NPM registry to find the documentation link
|
||||
const response = await fetch(`https://registry.npmjs.org/${name}`);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Could not fetch data for package ${name}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
|
||||
// const dependencies = Object.keys(packageContentData.dependencies || {})
|
||||
// .concat(Object.keys(packageContentData.devDependencies || {}));
|
||||
// const usesTypescript = dependencies.includes("typescript");
|
||||
|
||||
return {
|
||||
docsLink: data.homepage as string | undefined,
|
||||
title: name, // package.json doesn't have specific title field
|
||||
description: data.description as string | undefined,
|
||||
repo: Array.isArray(data.repository)
|
||||
? (data.respository[0]?.url as string | undefined)
|
||||
: undefined,
|
||||
license: data.license as string | undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,283 +0,0 @@
|
|||
// Generated by continue
|
||||
|
||||
import { getAllSuggestedDocs } from "./index";
|
||||
import { testIde } from "../../../test/fixtures";
|
||||
import {
|
||||
setUpTestDir,
|
||||
tearDownTestDir,
|
||||
addToTestDir,
|
||||
} from "../../../test/testDir";
|
||||
import fetch, { RequestInfo } from "node-fetch";
|
||||
|
||||
jest.mock("node-fetch", undefined, {
|
||||
virtual: false,
|
||||
});
|
||||
|
||||
describe.skip("getAllSuggestedDocs", () => {
|
||||
beforeEach(() => {
|
||||
setUpTestDir();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
tearDownTestDir();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("should return package docs for JavaScript and Python projects", async () => {
|
||||
// Set up test files
|
||||
addToTestDir([
|
||||
[
|
||||
"package.json",
|
||||
JSON.stringify({
|
||||
dependencies: {
|
||||
express: "^4.17.1",
|
||||
lodash: "^4.17.21",
|
||||
},
|
||||
devDependencies: {
|
||||
typescript: "^4.0.0",
|
||||
},
|
||||
}),
|
||||
],
|
||||
["requirements.txt", "requests==2.25.1\nflask==1.1.2"],
|
||||
]);
|
||||
|
||||
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
|
||||
mockedFetch.mockImplementation((url: URL | RequestInfo) => {
|
||||
if (url.toString().includes("registry.npmjs.org/express")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: jest.fn().mockResolvedValue({
|
||||
homepage: "https://expressjs.com/",
|
||||
name: "express",
|
||||
description: "Fast, unopinionated, minimalist web framework",
|
||||
license: "MIT",
|
||||
}),
|
||||
}) as any;
|
||||
} else if (url.toString().includes("registry.npmjs.org/lodash")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: jest.fn().mockResolvedValue({
|
||||
homepage: "https://lodash.com/",
|
||||
name: "lodash",
|
||||
description: "Lodash modular utilities.",
|
||||
license: "MIT",
|
||||
}),
|
||||
}) as any;
|
||||
} else if (url.toString().includes("pypi.org/pypi/requests/json")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: jest.fn().mockResolvedValue({
|
||||
info: {
|
||||
home_page: "https://docs.python-requests.org/",
|
||||
name: "requests",
|
||||
summary: "Python HTTP for Humans.",
|
||||
license: "Apache 2.0",
|
||||
},
|
||||
}),
|
||||
}) as any;
|
||||
} else if (url.toString().includes("pypi.org/pypi/flask/json")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: jest.fn().mockResolvedValue({
|
||||
info: {
|
||||
home_page: "https://palletsprojects.com/p/flask/",
|
||||
name: "flask",
|
||||
summary:
|
||||
"A simple framework for building complex web applications.",
|
||||
license: "BSD-3-Clause",
|
||||
},
|
||||
}),
|
||||
}) as any;
|
||||
} else {
|
||||
return Promise.reject(new Error(`Unhandled URL: ${url}`));
|
||||
}
|
||||
});
|
||||
|
||||
const results = await getAllSuggestedDocs(testIde);
|
||||
|
||||
expect(results).toHaveLength(4);
|
||||
expect(results).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
packageInfo: expect.objectContaining({ name: "express" }),
|
||||
details: expect.objectContaining({
|
||||
docsLink: "https://expressjs.com/",
|
||||
}),
|
||||
}),
|
||||
expect.objectContaining({
|
||||
packageInfo: expect.objectContaining({ name: "lodash" }),
|
||||
details: expect.objectContaining({
|
||||
docsLink: "https://lodash.com/",
|
||||
}),
|
||||
}),
|
||||
expect.objectContaining({
|
||||
packageInfo: expect.objectContaining({ name: "requests" }),
|
||||
details: expect.objectContaining({
|
||||
docsLink: "https://docs.python-requests.org/",
|
||||
}),
|
||||
}),
|
||||
expect.objectContaining({
|
||||
packageInfo: expect.objectContaining({ name: "flask" }),
|
||||
details: expect.objectContaining({
|
||||
docsLink: "https://palletsprojects.com/p/flask/",
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
|
||||
// Verify no errors are present
|
||||
results.forEach((result) => {
|
||||
expect(result.error).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle packages without documentation links", async () => {
|
||||
addToTestDir([
|
||||
[
|
||||
"package.json",
|
||||
JSON.stringify({
|
||||
dependencies: {
|
||||
"no-docs-package": "^1.0.0",
|
||||
},
|
||||
}),
|
||||
],
|
||||
]);
|
||||
|
||||
// Mock fetch
|
||||
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
|
||||
mockedFetch.mockImplementation((url: RequestInfo | URL) => {
|
||||
if (url.toString().includes("registry.npmjs.org/no-docs-package")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: jest.fn().mockResolvedValue({
|
||||
name: "no-docs-package",
|
||||
description: "A package without docs",
|
||||
license: "MIT",
|
||||
// No homepage provided
|
||||
}),
|
||||
}) as any;
|
||||
} else {
|
||||
return Promise.reject(new Error(`Unhandled URL: ${url}`));
|
||||
}
|
||||
});
|
||||
|
||||
const results = await getAllSuggestedDocs(testIde);
|
||||
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].error).toContain(
|
||||
"No documentation link found for no-docs-package",
|
||||
);
|
||||
expect(results[0].details).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should handle errors when fetching package details", async () => {
|
||||
addToTestDir([
|
||||
[
|
||||
"package.json",
|
||||
JSON.stringify({
|
||||
dependencies: {
|
||||
"error-package": "^1.0.0",
|
||||
},
|
||||
}),
|
||||
],
|
||||
]);
|
||||
|
||||
// Mock fetch
|
||||
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
|
||||
mockedFetch.mockImplementation((url: URL | RequestInfo) => {
|
||||
if (url.toString().includes("registry.npmjs.org/error-package")) {
|
||||
return Promise.resolve({
|
||||
ok: false,
|
||||
}) as any;
|
||||
} else {
|
||||
return Promise.reject(new Error(`Unhandled URL: ${url}`));
|
||||
}
|
||||
});
|
||||
|
||||
const results = await getAllSuggestedDocs(testIde);
|
||||
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].error).toContain(
|
||||
"Error getting package details for error-package",
|
||||
);
|
||||
expect(results[0].details).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should handle workspaces with no package files", async () => {
|
||||
const results = await getAllSuggestedDocs(testIde);
|
||||
|
||||
expect(results).toEqual([]);
|
||||
});
|
||||
|
||||
it("should handle packages with GitHub documentation links", async () => {
|
||||
addToTestDir([
|
||||
[
|
||||
"package.json",
|
||||
JSON.stringify({
|
||||
dependencies: {
|
||||
"github-docs-package": "^1.0.0",
|
||||
},
|
||||
}),
|
||||
],
|
||||
]);
|
||||
|
||||
// Mock fetch
|
||||
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
|
||||
mockedFetch.mockImplementation((url: URL | RequestInfo) => {
|
||||
if (url.toString().includes("registry.npmjs.org/github-docs-package")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: jest.fn().mockResolvedValue({
|
||||
homepage: "https://github.com/user/repo",
|
||||
name: "github-docs-package",
|
||||
description: "A package with GitHub docs",
|
||||
license: "MIT",
|
||||
}),
|
||||
}) as any;
|
||||
} else {
|
||||
return Promise.reject(new Error(`Unhandled URL: ${url}`));
|
||||
}
|
||||
});
|
||||
|
||||
const results = await getAllSuggestedDocs(testIde);
|
||||
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].details?.docsLink).toBe("https://github.com/user/repo");
|
||||
expect(results[0].details?.docsLinkWarning).toBe(
|
||||
"Github docs not supported, find the docs site",
|
||||
);
|
||||
});
|
||||
|
||||
it("should handle packages with non-docs links", async () => {
|
||||
addToTestDir([["requirements.txt", "non-docs-package==1.0.0"]]);
|
||||
|
||||
// Mock fetch
|
||||
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
|
||||
mockedFetch.mockImplementation((url: URL | RequestInfo) => {
|
||||
if (url.toString().includes("pypi.org/pypi/non-docs-package/json")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: jest.fn().mockResolvedValue({
|
||||
info: {
|
||||
home_page: "https://somewebsite.com",
|
||||
name: "non-docs-package",
|
||||
summary: "A package with non-docs homepage",
|
||||
license: "MIT",
|
||||
},
|
||||
}),
|
||||
}) as any;
|
||||
} else {
|
||||
return Promise.reject(new Error(`Unhandled URL: ${url}`));
|
||||
}
|
||||
});
|
||||
|
||||
const results = await getAllSuggestedDocs(testIde);
|
||||
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].details?.docsLink).toBe("https://somewebsite.com");
|
||||
expect(results[0].details?.docsLinkWarning).toBe(
|
||||
"May not be a docs site, check the URL",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
@ -177,7 +177,11 @@ export abstract class BaseLLM implements ILLM {
|
|||
|
||||
this.model = options.model;
|
||||
// Use @continuedev/llm-info package to autodetect certain parameters
|
||||
const llmInfo = findLlmInfo(this.model);
|
||||
const modelSearchString =
|
||||
this.providerName === "continue-proxy"
|
||||
? this.model?.split("/").pop() || this.model
|
||||
: this.model;
|
||||
const llmInfo = findLlmInfo(modelSearchString);
|
||||
|
||||
const templateType =
|
||||
options.template ?? autodetectTemplateType(options.model);
|
||||
|
|
@ -195,11 +199,11 @@ export abstract class BaseLLM implements ILLM {
|
|||
options.completionOptions?.maxTokens ??
|
||||
(llmInfo?.maxCompletionTokens
|
||||
? Math.min(
|
||||
llmInfo.maxCompletionTokens,
|
||||
// Even if the model has a large maxTokens, we don't want to use that every time,
|
||||
// because it takes away from the context length
|
||||
this.contextLength / 4,
|
||||
)
|
||||
llmInfo.maxCompletionTokens,
|
||||
// Even if the model has a large maxTokens, we don't want to use that every time,
|
||||
// because it takes away from the context length
|
||||
this.contextLength / 4,
|
||||
)
|
||||
: DEFAULT_MAX_TOKENS),
|
||||
};
|
||||
this.requestOptions = options.requestOptions;
|
||||
|
|
@ -840,7 +844,6 @@ export abstract class BaseLLM implements ILLM {
|
|||
signal,
|
||||
completionOptions,
|
||||
)) {
|
||||
|
||||
if (chunk.role === "assistant") {
|
||||
completion += chunk.content;
|
||||
yield chunk;
|
||||
|
|
@ -948,7 +951,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
);
|
||||
}
|
||||
|
||||
protected async * _streamComplete(
|
||||
protected async *_streamComplete(
|
||||
prompt: string,
|
||||
signal: AbortSignal,
|
||||
options: CompletionOptions,
|
||||
|
|
@ -956,7 +959,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
protected async * _streamChat(
|
||||
protected async *_streamChat(
|
||||
messages: ChatMessage[],
|
||||
signal: AbortSignal,
|
||||
options: CompletionOptions,
|
||||
|
|
|
|||
|
|
@ -140,8 +140,11 @@ function testLLM(
|
|||
},
|
||||
},
|
||||
type: "function",
|
||||
wouldLikeTo: "Say hello",
|
||||
wouldLikeTo: "say hello",
|
||||
isCurrently: "saying hello",
|
||||
hasAlready: "said hello",
|
||||
readonly: true,
|
||||
group: "Hello",
|
||||
},
|
||||
],
|
||||
toolChoice: {
|
||||
|
|
|
|||
|
|
@ -43,14 +43,16 @@ export class TransformersJsEmbeddingsProvider extends BaseLLM {
|
|||
static maxGroupSize: number = 1;
|
||||
static model: string = "all-MiniLM-L6-v2";
|
||||
static mockVector: number[] = Array.from({ length: 384 }).fill(2) as number[];
|
||||
static title: string = "Transformers.js (Built-In)";
|
||||
|
||||
static defaultOptions: Partial<LLMOptions> | undefined = {
|
||||
model: TransformersJsEmbeddingsProvider.model,
|
||||
};
|
||||
|
||||
constructor() {
|
||||
super({ model: TransformersJsEmbeddingsProvider.model });
|
||||
super({
|
||||
model: TransformersJsEmbeddingsProvider.model,
|
||||
title: "Transformers.js (Built-In)",
|
||||
});
|
||||
}
|
||||
|
||||
async embed(chunks: string[]) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ContinueProxy extends OpenAI {
|
|||
this.apiKey = value.workOsAccessToken;
|
||||
if (!this.onPremProxyUrl) {
|
||||
this.apiBase = new URL(
|
||||
"openai/v1/",
|
||||
"model-proxy/v1/",
|
||||
value.controlPlaneProxyUrl,
|
||||
).toString();
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ class ContinueProxy extends OpenAI {
|
|||
this.orgScopeId = options.orgScopeId;
|
||||
this.onPremProxyUrl = options.onPremProxyUrl;
|
||||
if (this.onPremProxyUrl) {
|
||||
this.apiBase = new URL("openai/v1/", this.onPremProxyUrl).toString();
|
||||
this.apiBase = new URL("model-proxy/v1/", this.onPremProxyUrl).toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
20
core/package-lock.json
generated
20
core/package-lock.json
generated
|
|
@ -13,9 +13,9 @@
|
|||
"@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.63",
|
||||
"@continuedev/config-yaml": "^1.0.67",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.18",
|
||||
"@modelcontextprotocol/sdk": "^1.5.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
|
|
@ -100,7 +100,8 @@
|
|||
"myers-diff": "^2.1.0",
|
||||
"onnxruntime-common": "1.14.0",
|
||||
"onnxruntime-web": "1.14.0",
|
||||
"ts-jest": "^29.1.1"
|
||||
"ts-jest": "^29.1.1",
|
||||
"typescript": "^5.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.11.0"
|
||||
|
|
@ -2973,9 +2974,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-yaml": {
|
||||
"version": "1.0.63",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.63.tgz",
|
||||
"integrity": "sha512-KBfyOUU/mWOXeNf6v+4IfMkbvfEEe/YP6n/g/reJBhrpApchG2A/P11JviH87N2To1SrhZxnW//0g5FIGupDFw==",
|
||||
"version": "1.0.67",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz",
|
||||
"integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
|
|
@ -2995,9 +2996,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@continuedev/llm-info": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/llm-info/-/llm-info-1.0.7.tgz",
|
||||
"integrity": "sha512-MyYmP4tbTzOnlT6hItC9tFkVZpYkaAg45AUXqdXzEfZhz8ZWpaiN8jZ789KLVmq+NKqhMUbKAHIZUUY1d39eRw=="
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/llm-info/-/llm-info-1.0.8.tgz",
|
||||
"integrity": "sha512-/htL7p4li3zQSwn9bXkI23WRpZNklWTPzRSSG3Fd5gvYW8cizjhlf7OzeDdKxBfi1S0lpqMm0VwHlx3KjMKLpw=="
|
||||
},
|
||||
"node_modules/@continuedev/openai-adapters": {
|
||||
"version": "1.0.18",
|
||||
|
|
@ -15449,7 +15450,6 @@
|
|||
"version": "5.7.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
|
||||
"integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
|
|
|
|||
|
|
@ -39,16 +39,17 @@
|
|||
"myers-diff": "^2.1.0",
|
||||
"onnxruntime-common": "1.14.0",
|
||||
"onnxruntime-web": "1.14.0",
|
||||
"ts-jest": "^29.1.1"
|
||||
"ts-jest": "^29.1.1",
|
||||
"typescript": "^5.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-bedrock-runtime": "^3.758.0",
|
||||
"@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.63",
|
||||
"@continuedev/config-yaml": "^1.0.67",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.18",
|
||||
"@modelcontextprotocol/sdk": "^1.5.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
|
|
|
|||
|
|
@ -53,16 +53,15 @@ export function slashCommandFromPromptFileV1(
|
|||
path: string,
|
||||
content: string,
|
||||
): SlashCommand | null {
|
||||
const { name, description, systemMessage, prompt, version } =
|
||||
parsePromptFileV1V2(path, content);
|
||||
|
||||
if (version !== 1) {
|
||||
return null;
|
||||
}
|
||||
const { name, description, systemMessage, prompt } = parsePromptFileV1V2(
|
||||
path,
|
||||
content,
|
||||
);
|
||||
|
||||
return {
|
||||
name,
|
||||
description,
|
||||
prompt,
|
||||
run: async function* (context) {
|
||||
const originalSystemMessage = context.llm.systemMessage;
|
||||
context.llm.systemMessage = systemMessage;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import * as YAML from "yaml";
|
||||
|
||||
import { getLastNPathParts } from "../../util/uri";
|
||||
|
||||
export function extractName(preamble: { name?: string }, path: string): string {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import * as YAML from "yaml";
|
||||
|
||||
import { getLastNPathParts } from "../../util/uri";
|
||||
|
||||
export function parsePromptFileV1V2(path: string, content: string) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { contextProviderClassFromName } from "../../context/providers";
|
|||
import URLContextProvider from "../../context/providers/URLContextProvider";
|
||||
import { resolveRelativePathInDir } from "../../util/ideUtils";
|
||||
import { getUriPathBasename } from "../../util/uri";
|
||||
|
||||
import { getPreambleAndBody } from "./parse";
|
||||
|
||||
async function resolveAttachment(
|
||||
|
|
|
|||
|
|
@ -1,17 +1,20 @@
|
|||
import { ConfigResult, ModelRole } from "@continuedev/config-yaml";
|
||||
import {
|
||||
ConfigResult,
|
||||
DevDataLogEvent,
|
||||
ModelRole,
|
||||
} from "@continuedev/config-yaml";
|
||||
|
||||
import { AutocompleteInput } from "../autocomplete/util/types";
|
||||
import { ProfileDescription } from "../config/ConfigHandler";
|
||||
import { OrganizationDescription } from "../config/ProfileLifecycleManager";
|
||||
import { SharedConfigSchema } from "../config/sharedConfig";
|
||||
import { GlobalContextModelSelections } from "../util/GlobalContext";
|
||||
|
||||
import { DevDataLogEvent } from "@continuedev/config-yaml";
|
||||
import type {
|
||||
BrowserSerializedContinueConfig,
|
||||
ChatMessage,
|
||||
ContextItem,
|
||||
ContextItemWithId,
|
||||
ContextProviderWithParams,
|
||||
ContextSubmenuItem,
|
||||
DiffLine,
|
||||
DocsIndexingDetails,
|
||||
|
|
@ -29,7 +32,6 @@ import type {
|
|||
SlashCommandDescription,
|
||||
ToolCall,
|
||||
} from "../";
|
||||
import { GlobalContextModelSelections } from "../util/GlobalContext";
|
||||
|
||||
export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart";
|
||||
|
||||
|
|
@ -67,7 +69,6 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
},
|
||||
];
|
||||
"config/deleteModel": [{ title: string }, void];
|
||||
"config/addContextProvider": [ContextProviderWithParams, void];
|
||||
"config/reload": [undefined, ConfigResult<BrowserSerializedContinueConfig>];
|
||||
"config/listProfiles": [
|
||||
undefined,
|
||||
|
|
@ -94,6 +95,12 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
},
|
||||
ContextItemWithId[],
|
||||
];
|
||||
"mcp/reloadServer": [
|
||||
{
|
||||
id: string;
|
||||
},
|
||||
void,
|
||||
];
|
||||
"context/getSymbolsForFiles": [{ uris: string[] }, FileSymbolMap];
|
||||
"context/loadSubmenuItems": [{ title: string }, ContextSubmenuItem[]];
|
||||
"autocomplete/complete": [AutocompleteInput, string[]];
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"history/save",
|
||||
"devdata/log",
|
||||
"config/addModel",
|
||||
"config/addContextProvider",
|
||||
"config/newPromptFile",
|
||||
"config/ideSettingsUpdate",
|
||||
"config/getSerializedProfileInfo",
|
||||
|
|
@ -26,6 +25,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"config/openProfile",
|
||||
"config/updateSharedConfig",
|
||||
"config/updateSelectedModel",
|
||||
"mcp/reloadServer",
|
||||
"context/getContextItems",
|
||||
"context/getSymbolsForFiles",
|
||||
"context/loadSubmenuItems",
|
||||
|
|
@ -51,7 +51,6 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"indexing/reindex",
|
||||
"indexing/abort",
|
||||
"indexing/setPaused",
|
||||
"docs/getSuggestedDocs",
|
||||
"docs/initStatuses",
|
||||
"docs/getDetails",
|
||||
//
|
||||
|
|
@ -80,7 +79,6 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] =
|
|||
"setTTSActive",
|
||||
"getWebviewHistoryLength",
|
||||
"getCurrentSessionId",
|
||||
"docs/suggestions",
|
||||
"didCloseFiles",
|
||||
"didSelectOrganization",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -37,6 +37,5 @@ export type ToWebviewFromIdeOrCoreProtocol = {
|
|||
setTTSActive: [boolean, void];
|
||||
getWebviewHistoryLength: [undefined, number];
|
||||
getCurrentSessionId: [undefined, string];
|
||||
"docs/suggestions": [PackageDocsResult[], void];
|
||||
"jetbrains/setColors": [Record<string, string>, void];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,4 +8,5 @@ export enum BuiltInToolNames {
|
|||
ExactSearch = "builtin_exact_search",
|
||||
SearchWeb = "builtin_search_web",
|
||||
ViewDiff = "builtin_view_diff",
|
||||
}
|
||||
}
|
||||
export const BUILT_IN_GROUP_NAME = "Built-In";
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
import { Tool } from "../..";
|
||||
import { BuiltInToolNames } from "../builtIn";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export const createNewFileTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "Create New File",
|
||||
wouldLikeTo: "create a new file",
|
||||
wouldLikeTo: "create a new file at {{{ filepath }}}",
|
||||
isCurrently: "creating a new file at {{{ filepath }}}",
|
||||
hasAlready: "created a new file at {{{ filepath }}}",
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
readonly: false,
|
||||
function: {
|
||||
name: BuiltInToolNames.CreateNewFile,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
import { Tool } from "../..";
|
||||
import { BuiltInToolNames } from "../builtIn";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export const exactSearchTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "Exact Search",
|
||||
wouldLikeTo: 'search for "{{{ query }}}" in the repository',
|
||||
isCurrently: 'getting search results for "{{{ query }}}"',
|
||||
hasAlready: 'retreived search results for "{{{ query }}}"',
|
||||
readonly: true,
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
function: {
|
||||
name: BuiltInToolNames.ExactSearch,
|
||||
description: "Perform an exact search over the repository using ripgrep.",
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
import { Tool } from "../..";
|
||||
import { BuiltInToolNames } from "../builtIn";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export const readCurrentlyOpenFileTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "Read Currently Open File",
|
||||
wouldLikeTo: "read the current file",
|
||||
isCurrently: "reading the current file",
|
||||
hasAlready: "read the current file",
|
||||
readonly: true,
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
function: {
|
||||
name: BuiltInToolNames.ReadCurrentlyOpenFile,
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
import { Tool } from "../..";
|
||||
import { BuiltInToolNames } from "../builtIn";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export const readFileTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "Read File",
|
||||
wouldLikeTo: "read {{{ filepath }}}",
|
||||
isCurrently: "reading {{{ filepath }}}",
|
||||
hasAlready: "read {{{ filepath }}}",
|
||||
readonly: true,
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
function: {
|
||||
name: BuiltInToolNames.ReadFile,
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
import { Tool } from "../..";
|
||||
import { BuiltInToolNames } from "../builtIn";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export const runTerminalCommandTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "Run Terminal Command",
|
||||
wouldLikeTo: "run a terminal command",
|
||||
wouldLikeTo: "run the following terminal command:",
|
||||
isCurrently: "running the following terminal command:",
|
||||
hasAlready: "ran the following terminal command:",
|
||||
readonly: false,
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
function: {
|
||||
name: BuiltInToolNames.RunTerminalCommand,
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
import { Tool } from "../..";
|
||||
|
||||
import { BuiltInToolNames } from "../builtIn";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export const searchWebTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "Search Web",
|
||||
wouldLikeTo: 'search the web for "{{{ query }}}"',
|
||||
isCurrently: 'searching the web for "{{{ query }}}"',
|
||||
hasAlready: 'searched the web fore "{{{ query }}}"',
|
||||
readonly: true,
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
function: {
|
||||
name: BuiltInToolNames.SearchWeb,
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
import { Tool } from "../..";
|
||||
|
||||
import { BuiltInToolNames } from "../builtIn";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export const viewDiffTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "View Diff",
|
||||
wouldLikeTo: "view a diff",
|
||||
wouldLikeTo: "view the git diff",
|
||||
isCurrently: "getting the git diff",
|
||||
hasAlready: "viewed the git diff",
|
||||
readonly: true,
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
function: {
|
||||
name: BuiltInToolNames.ViewDiff,
|
||||
description: "View the current diff of working changes",
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
import { Tool } from "../..";
|
||||
|
||||
import { BuiltInToolNames } from "../builtIn";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export const viewRepoMapTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "View Repo Map",
|
||||
wouldLikeTo: "view the repository map",
|
||||
isCurrently: "getting the repository map",
|
||||
hasAlready: "viewed the repository map",
|
||||
readonly: true,
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
function: {
|
||||
name: BuiltInToolNames.ViewRepoMap,
|
||||
description: "View the repository map",
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
import { Tool } from "../..";
|
||||
import { BuiltInToolNames } from "../builtIn";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export const viewSubdirectoryTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "View Subdirectory",
|
||||
wouldLikeTo: 'view the contents of "{{{ directory_path }}}"',
|
||||
wouldLikeTo: 'view a map of "{{{ directory_path }}}"',
|
||||
isCurrently: 'getting a map of "{{{ directory_path }}}"',
|
||||
hasAlready: 'viewed a map of "{{{ directory_path }}}"',
|
||||
readonly: true,
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
function: {
|
||||
name: BuiltInToolNames.ViewSubdirectory,
|
||||
description: "View the contents of a subdirectory",
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
import { ConfigYaml, DevEventName } from "@continuedev/config-yaml";
|
||||
import * as JSONC from "comment-json";
|
||||
import dotenv from "dotenv";
|
||||
|
||||
import { DevEventName } from "@continuedev/config-yaml";
|
||||
import { IdeType, SerializedContinueConfig } from "../";
|
||||
import { defaultConfig, defaultConfigJetBrains } from "../config/default";
|
||||
import Types from "../config/types";
|
||||
|
|
@ -91,27 +92,20 @@ export function getSessionsListPath(): string {
|
|||
return filepath;
|
||||
}
|
||||
|
||||
export function getConfigJsonPath(ideType: IdeType = "vscode"): string {
|
||||
export function getConfigJsonPath(): string {
|
||||
const p = path.join(getContinueGlobalPath(), "config.json");
|
||||
if (!fs.existsSync(p)) {
|
||||
if (ideType === "jetbrains") {
|
||||
fs.writeFileSync(p, JSON.stringify(defaultConfigJetBrains, null, 2));
|
||||
} else {
|
||||
fs.writeFileSync(p, JSON.stringify(defaultConfig, null, 2));
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
export function getConfigYamlPath(ideType?: IdeType): string {
|
||||
const p = path.join(getContinueGlobalPath(), "config.yaml");
|
||||
// if (!fs.existsSync(p)) {
|
||||
// if (ideType === "jetbrains") {
|
||||
// fs.writeFileSync(p, YAML.stringify(defaultConfigYamlJetBrains));
|
||||
// } else {
|
||||
// fs.writeFileSync(p, YAML.stringify(defaultConfigYaml));
|
||||
// }
|
||||
// }
|
||||
if (!fs.existsSync(p) && !fs.existsSync(getConfigJsonPath())) {
|
||||
if (ideType === "jetbrains") {
|
||||
fs.writeFileSync(p, YAML.stringify(defaultConfigJetBrains));
|
||||
} else {
|
||||
fs.writeFileSync(p, YAML.stringify(defaultConfig));
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
@ -234,7 +228,7 @@ export function getDevDataFilePath(
|
|||
return path.join(versionPath, `${String(eventName)}.jsonl`);
|
||||
}
|
||||
|
||||
export function editConfigJson(
|
||||
function editConfigJson(
|
||||
callback: (config: SerializedContinueConfig) => SerializedContinueConfig,
|
||||
): void {
|
||||
const config = fs.readFileSync(getConfigJsonPath(), "utf8");
|
||||
|
|
@ -248,6 +242,31 @@ export function editConfigJson(
|
|||
}
|
||||
}
|
||||
|
||||
function editConfigYaml(callback: (config: ConfigYaml) => ConfigYaml): void {
|
||||
const config = fs.readFileSync(getConfigYamlPath(), "utf8");
|
||||
let configYaml = YAML.parse(config);
|
||||
// Check if it's an object
|
||||
if (typeof configYaml === "object" && configYaml !== null) {
|
||||
configYaml = callback(configYaml as any) as any;
|
||||
fs.writeFileSync(getConfigYamlPath(), YAML.stringify(configYaml));
|
||||
} else {
|
||||
console.warn("config.yaml is not a valid object");
|
||||
}
|
||||
}
|
||||
|
||||
export function editConfigFile(
|
||||
configJsonCallback: (
|
||||
config: SerializedContinueConfig,
|
||||
) => SerializedContinueConfig,
|
||||
configYamlCallback: (config: ConfigYaml) => ConfigYaml,
|
||||
): void {
|
||||
if (fs.existsSync(getConfigYamlPath())) {
|
||||
editConfigYaml(configYamlCallback);
|
||||
} else if (fs.existsSync(getConfigJsonPath())) {
|
||||
editConfigJson(configJsonCallback);
|
||||
}
|
||||
}
|
||||
|
||||
function getMigrationsFolderPath(): string {
|
||||
const migrationsPath = path.join(getContinueGlobalPath(), ".migrations");
|
||||
if (!fs.existsSync(migrationsPath)) {
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
---
|
||||
title: Context selection
|
||||
description: Actions \-context selection
|
||||
keywords: [context, slash, debug, quick fix, right click]
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
## Slash commands
|
||||
|
||||
Slash commands can be combined with additional instructions, including [context providers](../customize/context-providers.mdx) or [highlighted code](../edit/context-selection#highlighted-code).
|
||||
|
||||
## Quick actions
|
||||
|
||||
Quick actions are always displayed above a class or function and will edit that class or function, but nothing outside of it.
|
||||
|
||||
## Right click actions
|
||||
|
||||
The highlighted code you’ve selected will be included in your prompt alongside a pre-written set of instructions depending on the selected action. This is the only section of code that the model will attempt to edit.
|
||||
|
||||
## Debug action
|
||||
|
||||
The debug action selects the most recently run terminal command and its output and then injects the following prompt into the chat window. There is no additional, non-visible information sent to the language model.
|
||||
|
||||
```
|
||||
I got the following error, can you please help explain how to fix it?
|
||||
|
||||
[ERROR_MESSAGE]
|
||||
```
|
||||
|
||||
## Quick fixes
|
||||
|
||||
Similarly to the debug action, quick actions transparently inject a prompt into the chat window. When you select “Ask Continue”, the 3 lines above and below the error are sent to the chat followed by the question “How do I fix the following problem in the above code?: [ERROR_MESSAGE]”.
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
---
|
||||
title: How it works
|
||||
description: How Actions work
|
||||
keywords: [how, slash, commands, prompt, right click, quick fix, debug, action]
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
While many Actions are based on templated prompts and can be customized with .prompt files, there are a number that execute more complex code under the hood.
|
||||
|
||||
Right click actions that generate inline diffs, use the same prompt and response processing logic as [Edit](../edit/how-it-works.md).
|
||||
|
||||
To learn how other slash commands work, see the full reference [here](../customize/slash-commands.mdx).
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
---
|
||||
title: How to customize
|
||||
description: How to customize Actions
|
||||
keywords: [customize, actions]
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
The easiest way to add actions is by adding [`prompt` blocks](../hub/blocks/block-types.md#prompts) to your assistant, which show up as slash commands in [Chat](../chat/how-it-works.md).
|
||||
|
||||
Check out the [slash commands deep dive](../customize/slash-commands.mdx) for more information on extending actions.
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
---
|
||||
title: Actions
|
||||
description: How to use Actions
|
||||
sidebar_label: How to use it
|
||||
keywords: [how, slash, commands, prompt, right click, quick fix, debug, action]
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||

|
||||
|
||||
## How to use it
|
||||
|
||||
Actions are shortcuts for common use cases. For example, you might want to review code, write tests, or add a docstring.
|
||||
|
||||
### Slash commands
|
||||
|
||||
The most common way to invoke an action is with a slash command. These are shortcuts that can be activated by typing '/' in a chat session (press <kbd>cmd/ctrl</kbd> + <kbd>L</kbd> (VS Code) or <kbd>cmd/ctrl</kbd> + <kbd>J</kbd> (JetBrains)), and selecting from the dropdown.
|
||||
|
||||

|
||||
|
||||
In YAML assistants, slash commands are generated from [`prompts` blocks](../hub/blocks/block-types.md#prompts).
|
||||
|
||||
Learn more about slash commands [here](../customize/slash-commands.mdx).
|
||||
|
||||
:::info
|
||||
Important: For assistants, slash commands only come from `prompts` blocks. When using older `config.json` configuration, other slash commands like `/share` and `/cmd` are included by default.
|
||||
:::
|
||||
|
||||
### Prompt files
|
||||
|
||||
It is also possible to write your own slash command by defining a “.prompt file.” Prompt files can be as simple as a text file, but also include templating so that you can refer to files, URLs, highlighted code, and more.
|
||||
|
||||
Learn more about prompt files [here](../customize/deep-dives/prompt-files.md)
|
||||
|
||||
### Other triggers for Actions (VS Code)
|
||||
|
||||
:::info
|
||||
Currently all of these are only available in VS Code
|
||||
:::
|
||||
|
||||
To make common use cases even more accessible, we provide a handful of other ways to invoke actions.
|
||||
|
||||
#### Quick actions
|
||||
|
||||
Quick Actions are displayed as buttons above top-level classes and functions in your source code, letting you invoke actions with one click. They can also be customized with .prompt files to perform custom actions.
|
||||
|
||||

|
||||
|
||||
By default, quick actions are disabled, but can be enabled with the “Continue: Enable Quick Actions” in VS Code settings.
|
||||
|
||||
#### Right click actions
|
||||
|
||||
Right click actions let you highlight a desired region of code, right click, and then select an action from the dropdown menu.
|
||||
|
||||

|
||||
|
||||
#### Debug action
|
||||
|
||||
The debug action is a special built-in keyboard shortcut in the VS Code extension. Use <kbd>cmd/ctrl</kbd> + <kbd>shift</kbd> + <kbd>R</kbd> to instantly copy the contents of the current terminal into the chat sidebar and get debugging advice.
|
||||
|
||||
#### Quick fixes
|
||||
|
||||
Whenever you see red/yellow underlines in your code indicating errors, you can place your cursor nearby and VS Code will display a lightbulb icon. Either clicking the lightbulb or using the keyboard shortcut <kbd>cmd/ctrl</kbd> + <kbd>.</kbd> will show a dropdown menu of quick fixes. One of these will be the “Ask Continue” action. Either click or use <kbd>cmd/ctrl</kbd> + <kbd>.</kbd> again and Continue will attempt to help solve the problem.
|
||||
|
||||

|
||||
|
|
@ -1,10 +0,0 @@
|
|||
---
|
||||
title: Model setup
|
||||
description: Actions model setup
|
||||
keywords: [model]
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
By default, Actions uses the same model as [Chat](chat/model-setup.mdx), since we recommend a similar, 400B+ parameter model or one of the frontier models for the complex instructions that will be carried out.
|
||||
|
||||
You can also set specific models to be used for Edit and Apply actions. See the [Model roles](../customize/model-roles/intro.mdx) page for more details.
|
||||
12
docs/docs/agent/context-selection.md
Normal file
12
docs/docs/agent/context-selection.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
title: Context selection
|
||||
description: How context can be selected for Chat
|
||||
keywords: [context]
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
You can use the same [methods to manually add context as Chat](../chat/context-selection.md).
|
||||
|
||||
In addition, tool call responses are automatically included as context items.
|
||||
|
||||
This enables Agent mode to see the result of the previous action and decide what to do next.
|
||||
38
docs/docs/agent/how-it-works.md
Normal file
38
docs/docs/agent/how-it-works.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
title: How it works
|
||||
description: How Agent works
|
||||
keywords: [how, agent, works]
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
Agent offers the same functionality as Chat, while also including tools in the request to the model and an interface for handling tool calls and responses.
|
||||
|
||||
## The tool handshake
|
||||
|
||||
Tools provide a flexible, powerful way for models to interface with the external world. They are provided to the model as a JSON object with a name and an arguments schema. For example, a `read_file` tool with a `filepath` argument will give the model the ability to request the contents of a specific file.
|
||||
|
||||
The following handshake describes how Agent uses tools:
|
||||
1. In Agent mode, available tools are sent along with `user` chat requests
|
||||
2. The model can choose to include a tool call in its response
|
||||
3. The user gives permission. This step is skipped if the policy for that tool is set to `Automatic`
|
||||
4. Continue calls the tool using built-in functionality or the MCP server that offers that particular tool
|
||||
5. Continue sends the result back to the model
|
||||
6. The model responds, potentially with another tool call and step 2 begins again
|
||||
|
||||
:::info
|
||||
In [Chat mode](../chat/how-to-use-it.md), tools are **not** included in the request to the model.
|
||||
:::
|
||||
|
||||
## Built-in tools
|
||||
|
||||
Continue includes several built-in tools which provide the model access to IDE functionality:
|
||||
|
||||
- **Read file** (`builtin_read_file`): read the contents of a file within the project
|
||||
- **Read currently open file** (`builtin_read_currently_open_file`): read the contents of the currently open file
|
||||
- **Create new file** (`builtin_create_new_file`): Create a new file within the project, with path and contents specified by the model
|
||||
- **Exact search** (`builtin_exact_search`): perform a `ripgrep` search within the project
|
||||
- **Run terminal command** (`builtin_run_terminal_command`): run a terminal command from the workspace root
|
||||
- **Search web** (`builtin_search_web`): Perform a web search to get top results
|
||||
- **View diff** (`builtin_view_diff`): View the current working git diff
|
||||
- **View repo map** (`builtin_view_repo_map`): request a copy of the repository map—same as the [Repo Map Context Provider](../customize/context-providers.mdx#repository-map)
|
||||
- **View subdirectory** (`builtin_view_subdirectory`): request a copy of a repo map for a specific directory within the project
|
||||
32
docs/docs/agent/how-to-customize.md
Normal file
32
docs/docs/agent/how-to-customize.md
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
title: How to customize
|
||||
description: How to customize Chat
|
||||
keywords: [customize, chat]
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
## Add MCP tools
|
||||
|
||||
You can add MCP servers to your assistant to give Agent access to more tools. [Explore MCP Servers on the Hub](https://hub.continue.dev/explore/mcp) and see the [MCP guide](../customize/deep-dives/mcp.mdx) for more details.
|
||||
|
||||
## Tool policies
|
||||
|
||||
You can adjust Agent's usage behavior for each tool in your assistant to one of these options:
|
||||
|
||||
- **Ask First (default)** - request permission from the user; show the `Cancel` and `Continue` buttons
|
||||
- **Automatic** - do not request permission, automatically call the tool and feed the response back to the model
|
||||
- **Excluded** - do not send this tool to the model
|
||||
|
||||
:::warning
|
||||
Be careful setting any tools to `automatic` if their behavior is not read-only.
|
||||
:::
|
||||
|
||||
First, open `Tool Policies` by clicking the tools icon in the input toolbar
|
||||
|
||||

|
||||
|
||||
Then, you can view and change tool policies. To change a policy, click on the policy text ("Excluded", etc.) to toggle it. You can also turn groups of tools (e.g. all Built-in tools or all tools from a specific MCP server) off using the section toggles.
|
||||
|
||||

|
||||
|
||||
Tool policies are stored locally per user.
|
||||
49
docs/docs/agent/how-to-use-it.md
Normal file
49
docs/docs/agent/how-to-use-it.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
title: Agent
|
||||
description: How to use Agent
|
||||
sidebar_label: How to use it
|
||||
keywords: [how, use, agent]
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||

|
||||
|
||||
## How to use it
|
||||
|
||||
Agent equips the Chat model with the tools needed to handle a wide range of coding tasks, allowing the model to make decisions and save you the work of manually finding context and performing actions.
|
||||
|
||||
### Use Agent
|
||||
|
||||
You can switch to `Agent` in the mode selector below the chat input box.
|
||||
|
||||

|
||||
|
||||
:::info
|
||||
If Agent is disabled with a `Not Supported` message, the selected model or provider doesn't support tools, or Continue doesn't yet support tools with it. See [Model Setup](./model-setup.mdx) for more information.
|
||||
:::
|
||||
|
||||
### Chat with Agent
|
||||
|
||||
Agent lives within the same interface as [Chat](../chat/how-it-works.md), so the same [input](../chat/how-to-use-it.md#type-a-request-and-press-enter) is used to send messages and you can still use the same manual methods of providing context, such as [`@` context providers](../chat/how-to-use-it.md#reference-context-with-the--symbol) or adding [highlighted code from the editor](../chat/how-to-use-it.md#highlight-a-code-section-to-include-as-context).
|
||||
|
||||
#### Use natural language
|
||||
|
||||
With Agent, you can provide natural language instruction and let the model do the work. As an example, you might say
|
||||
|
||||
> Set the @typescript-eslint/naming-convention rule to "off" for all eslint configurations in this project
|
||||
|
||||
Agent will then decide which tools to use to get the job done.
|
||||
|
||||
## Give Agent permission
|
||||
|
||||
By default, Agent will ask permission when it wants to use a tool. Click `Continue` to allow Agent mode to proceed with the tool call or `Cancel` to reject it.
|
||||
|
||||

|
||||
|
||||
You can use tool policies to exclude or make usage automatic for specific tools. See [How to Customize](./how-to-customize.md) for more background.
|
||||
|
||||
## View Tool Responses
|
||||
|
||||
Any data returned from a tool call is automatically fed back into the model as a context item. Most errors are also caught and returned, so that Agent mode can decide how to proceed.
|
||||
|
||||

|
||||
19
docs/docs/agent/model-setup.mdx
Normal file
19
docs/docs/agent/model-setup.mdx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
title: Model setup
|
||||
description: Models for Continue Agent
|
||||
keywords: [model, agent]
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
Agent can be used with models that support tool use through Continue.
|
||||
|
||||
For the best Agent experience we recommend Claude 3.7 Sonnet from Anthropic. Add Claude 3.7 Sonnet to your assistant from the hub [here](https://hub.continue.dev/anthropic/claude-3-7-sonnet). You can get an API key from the [Anthropic console](https://console.anthropic.com/settings/keys).
|
||||
|
||||
Currently the following providers are supported:
|
||||
|
||||
- [Anthropic](../customize/model-providers/top-level/anthropic.mdx) - we recommend [Claude Sonnet 3.7](https://hub.continue.dev/anthropic/claude-3-7-sonnet)
|
||||
- [Ollama](../customize/model-providers/top-level/ollama.mdx) - we recommend [Qwen 2.5 Coder 7b](https://hub.continue.dev/ollama/qwen2.5-coder-7b). Also see all Ollama models that support tools [here](https://ollama.com/search?c=tools).
|
||||
- [OpenAI](../customize/model-providers/top-level/openai.mdx) - we recommend [GPT-4o](https://hub.continue.dev/openai/gpt-4o)
|
||||
- [Gemini](../customize/model-providers/top-level/gemini.mdx) - we recommend [Gemini 2.0 Flash](https://hub.continue.dev/google/gemini-2.0-flash)
|
||||
|
||||
The best chat models generally support tool usage. See [recommended chat models](../customize/model-roles/chat.mdx#recommended-chat-models) for more.
|
||||
|
|
@ -5,6 +5,6 @@ keywords: [customize]
|
|||
sidebar_position: 5
|
||||
---
|
||||
|
||||
Continue offers a handful of settings to customize autocomplete behavior. For the most part, these options can be found in the [User Settings Page](../customize/settings.md).
|
||||
Continue offers a handful of settings to customize autocomplete behavior. Visit the [User Settings Page](../customize/deep-dives/settings.md) to manage these settings.
|
||||
|
||||
For a comprehensive guide on all configuration options and their impacts, see the [Autocomplete deep dive](../customize/deep-dives/autocomplete.mdx).
|
||||
|
|
|
|||
|
|
@ -10,6 +10,5 @@ There are a number of different ways to customize Chat:
|
|||
- You can add a [`rules` block](../hub/blocks/block-types.md#rules) to your assistant to give the model persistent instructions through the system prompt. See the [rules deep dive](../customize/deep-dives/rules.md) for more information.
|
||||
- You can configure [`@Codebase`](../customize/deep-dives/codebase.mdx)
|
||||
- You can configure [`@Docs`](../customize/deep-dives/docs.mdx)
|
||||
- You can configure and create custom [tools](../customize/tools.mdx)
|
||||
- You can [build your own context provider](../customize/tutorials/build-your-own-context-provider.mdx)
|
||||
- You can create your own [custom code RAG](../customize/tutorials/custom-code-rag.mdx)
|
||||
|
|
|
|||
|
|
@ -90,15 +90,15 @@ Explore autocomplete model configurations on [the hub](https://hub.continue.dev/
|
|||
|
||||
### Autocomplete User Settings
|
||||
|
||||
The following settings can be configured for autocompletion in the IDE extension [User Settings Page](../settings.md):
|
||||
{/* - `Use autocomplete cache`: If on, caches completions */}
|
||||
The following settings can be configured for autocompletion in the IDE extension [User Settings Page](./settings.md):
|
||||
|
||||
- `Use autocomplete cache`: If on, caches completions
|
||||
- `Multiline Autocompletions`: Controls multiline completions for autocomplete. Can be set to `always`, `never`, or `auto`. Defaults to `auto`
|
||||
- `Disable autocomplete in files`: List of comma-separated glob pattern to disable autocomplete in matching files. E.g., "\_/.md, \*/.txt"
|
||||
|
||||
### `config.json` Configuration
|
||||
|
||||
The `config.json` configuration format (deprecated) offers further configuration options through `tabAutocompleteOptions`. See the [JSON Reference](../../reference.md#tabautocompleteoptions) for more details.
|
||||
The `config.json` configuration format (deprecated) offers further configuration options through `tabAutocompleteOptions`. See the [JSON Reference](../../json-reference.md#tabautocompleteoptions) for more details.
|
||||
|
||||
## FAQs
|
||||
|
||||
|
|
|
|||
|
|
@ -5,20 +5,26 @@ keywords: [config, settings, customize]
|
|||
|
||||
# Configuration
|
||||
|
||||
You can easily access your assistant configuration from the Continue Chat sidebar. Open the sidebar by pressing <kbd>cmd/ctrl</kbd> + <kbd>L</kbd> (VS Code) or <kbd>cmd/ctrl</kbd> + <kbd>J</kbd> (JetBrains) and click the Assistant selector above the main chat input. Then, you can hover over an assistant and click the `new window` (hub assistants) or `gear` (local assistants) icon.
|
||||
|
||||

|
||||
|
||||
## Hub Assistants
|
||||
|
||||
Hub Assistants can be managed in [the Hub](https://hub.continue.dev). See [Editing an Assistant](../../hub/assistants/edit-an-assistant.md)
|
||||
|
||||
## YAML Config
|
||||
|
||||
Continue can be deeply customized. Local user-level configuration is stored and can be edited in your home directory in `config.yaml`:
|
||||
Local user-level configuration is stored and can be edited in your home directory in `config.yaml`:
|
||||
|
||||
To open `config.yaml`, you can click the "gear" icon in the header of the Continue Chat sidebar to open the settings page, and then click `Open Assistant configuration` to open the file. When editing this file, you can see the available options suggested as you type, or check the reference below.
|
||||
|
||||
- `~/.continue/config.yaml` (MacOS / Linux)
|
||||
- `%USERPROFILE%\.continue\config.yaml` (Windows)
|
||||
|
||||
To open your configuration file, you can click the "gear" icon in the bottom right corner of the Continue Chat sidebar. When editing this file, you can see the available options suggested as you type, or check the reference below.
|
||||
|
||||
When you save a config file from the IDE, Continue will automatically refresh to take into account your changes. A config file is automatically created the first time you use Continue, and always automatically generated with default values if it doesn't exist.
|
||||
|
||||
See the full reference for `config.yaml` [here](../../yaml-reference.md).
|
||||
See the full reference for `config.yaml` [here](../../reference.md).
|
||||
|
||||
## Deprecated configuration methods
|
||||
|
||||
|
|
@ -26,7 +32,7 @@ See the full reference for `config.yaml` [here](../../yaml-reference.md).
|
|||
View the `config.json` migration guide [here](../../yaml-migration.md)
|
||||
:::
|
||||
|
||||
- [`config.json`](../../reference.md) - The original configuration format which is stored in a file at the same location as `config.yaml`
|
||||
- [`config.json`](../../json-reference.md) - The original configuration format which is stored in a file at the same location as `config.yaml`
|
||||
- [`.continuerc.json`](#continuercjson) - Workspace-level configuration
|
||||
- [`config.ts`](#configts) - Advanced configuration (probably unnecessary) - a TypeScript file in your home directory that can be used to programmatically modify (_merged_) the `config.json` schema:
|
||||
- `~/.continue/config.ts` (MacOS / Linux)
|
||||
|
|
@ -49,7 +55,9 @@ Example
|
|||
|
||||
### `config.ts`
|
||||
|
||||
To programatically extend `config.json`, you can place a `config.ts` script in same directory as `config.json` and export a `modifyConfig` function, like:
|
||||
`config.yaml` or `config.json` can handle the vast majority of necessary configuration, so we recommend using it whenever possible. However, if you need to programmatically extend Continue configuration, you can use a `config.ts` file, placed at `~/.continue/config.ts` (MacOS / Linux) or `%USERPROFILE%\.continue\config.ts` (Windows).
|
||||
|
||||
`config.ts` must export a `modifyConfig` function, like:
|
||||
|
||||
```ts title="config.ts"
|
||||
export function modifyConfig(config: Config): Config {
|
||||
|
|
@ -75,4 +83,4 @@ export function modifyConfig(config: Config): Config {
|
|||
}
|
||||
```
|
||||
|
||||
This can be used for slash commands and custom context providers.
|
||||
For examples of how to use `config.ts`, see [writing custom slash commands](../tutorials/build-your-own-slash-command.md#custom-slash-commands) or [writing custom context providers](../tutorials/build-your-own-context-provider.mdx).
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ You can also configure custom destinations for your data, including remote HTTP
|
|||
|
||||
For hub assistants, data destinations are configured in `data` blocks. Visit the hub to [explore example data blocks](https://hub.continue.dev/explore/data) or [create your own](https://hub.continue.dev/new?type=block&blockType=data).
|
||||
|
||||
See more details about adding `data` blocks to your configuration files in the [YAML specification](../../yaml-reference.md#data)
|
||||
See more details about adding `data` blocks to your configuration files in the [YAML specification](../../reference.md#data)
|
||||
|
||||
When sending development data to your own HTTP endpoint, it will receive an event JSON blob at the given `schema` version. You can view event names, schema versions, and fields [here in the source code](https://github.com/continuedev/continue/tree/main/packages/config-yaml/src/schemas/data).
|
||||
|
|
|
|||
|
|
@ -54,12 +54,6 @@ The `@Docs` context provider works by
|
|||
3. Storing the embeddings locally on your machine
|
||||
4. Embedding chat input to include similar documentation chunks as context
|
||||
|
||||
## Pre-indexed Documentation Sites
|
||||
|
||||
In VS Code, Continue offers a selection of pre-indexed documentation sites for popular frameworks and libraries. You can view the list of [available pre-indexed sites and request additions here](https://github.com/continuedev/continue/blob/main/core/indexing/docs/preIndexedDocs.ts).
|
||||
|
||||
Pre-indexed docs are only available in VS Code because the VS Code extension ships with the Transformers.js embedder built in, while Jetbrains currently does not. You can override a pre-indexed doc to index it with your own embeddings provider by adding it to your config (unique by `startUrl`). Otherwise, it will always use Transformers.js for queries.
|
||||
|
||||
## Indexing Your Own Documentation
|
||||
|
||||
### Hub `docs` Blocks
|
||||
|
|
@ -221,7 +215,10 @@ If your documentation is private, you can skip the default crawler and use a loc
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
The default local crawler is a lightweight tool that cannot render sites that are dynamically generated using JavaScript. If your sites need to be rendered, you can enable the experimental `Use Chromium for Docs Crawling` feature from your [User Settings Page](../settings.md) This will download and install Chromium to `~/.continue/.utils`, and use it as the local crawler.
|
||||
:::info
|
||||
Chromium crawling has been deprecated
|
||||
{/* The default local crawler is a lightweight tool that cannot render sites that are dynamically generated using JavaScript. If your sites need to be rendered, you can enable the experimental `Use Chromium for Docs Crawling` feature from your [User Settings Page](../deep-dives/settings.md) This will download and install Chromium to `~/.continue/.utils`, and use it as the local crawler. */}
|
||||
:::
|
||||
|
||||
Further notes:
|
||||
|
||||
|
|
@ -248,7 +245,7 @@ You can also use the following IDE command to force a re-index of all docs: `Con
|
|||
|
||||
### VS Code minimal setup
|
||||
|
||||
The following configuration example works out of the box for VS Code. This uses the built-in embeddings provider with no reranking. Pre-indexed docs will be accessible.
|
||||
The following configuration example works out of the box for VS Code. This uses the built-in embeddings provider with no reranking.
|
||||
|
||||
<Tabs groupId="config-example">
|
||||
<TabItem value="yaml" label="YAML">
|
||||
|
|
@ -282,7 +279,7 @@ The following configuration example works out of the box for VS Code. This uses
|
|||
|
||||
### Jetbrains minimal setup
|
||||
|
||||
Here is the equivalent minimal example for Jetbrains, which requires setting up an [embeddings provider](../model-roles/embeddings.mdx). Pre-indexed docs will _not_ be accessible.
|
||||
Here is the equivalent minimal example for Jetbrains, which requires setting up an [embeddings provider](../model-roles/embeddings.mdx).
|
||||
|
||||
<Tabs groupId="config-example">
|
||||
<TabItem value="yaml" label="YAML">
|
||||
|
|
@ -407,4 +404,4 @@ The following configuration example includes:
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
This could also involve enabling Chromium as a backup for local documentation the [User Settings Page](../settings.md).
|
||||
{/* This could also involve enabling Chromium as a backup for local documentation the [User Settings Page](../deep-dives/settings.md). */}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,19 @@
|
|||
---
|
||||
title: Tools
|
||||
description: Tool use and customization
|
||||
title: MCP
|
||||
description: MCP use and customization
|
||||
keywords: [tool, use, function calling, claude, automatic]
|
||||
---
|
||||
|
||||
import TabItem from "@theme/TabItem";
|
||||
import Tabs from "@theme/Tabs";
|
||||
|
||||
Tools allow Continue to take action in your IDE and beyond (when you give permission). Currently, they are only supported for the following providers:
|
||||
|
||||
- [Anthropic](./model-providers/top-level/anthropic.mdx) - see recommended models [here](https://docs.anthropic.com/en/docs/build-with-claude/tool-use#choosing-a-model).
|
||||
- [Ollama](./model-providers/top-level/ollama.mdx) - see recommended models [here](https://ollama.com/search?c=tools).
|
||||
- [OpenAI](./model-providers/top-level/openai.mdx)
|
||||
- [Gemini](./model-providers/top-level/gemini.mdx)
|
||||
|
||||
To use tools, click on the icon in the input toolbar like below.
|
||||
|
||||

|
||||
|
||||
To let you balance speed and safety, each tool can be set to 1 of 3 modes:
|
||||
|
||||
- `Automatic`: When the LLM requests to use the tool, Continue will automatically call it and send the response to the LLM.
|
||||
- `Allowed`: When the LLM requests to use the tool, Continue will first give you the opportunity to "Cancel" or "Continue" with the tool.
|
||||
- `Disabled`: The LLM will not know about or be able to use the tool.
|
||||
|
||||
### Custom tools
|
||||
## MCP
|
||||
|
||||
Currently custom tools can be configured using the [Model Context Protocol](https://modelcontextprotocol.io/introduction), a standard proposed by Anthropic to unify prompts, context, and tool use.
|
||||
|
||||
MCP Servers can be added to hub Assistants using `mcpServers` blocks. You can explore available MCP server blocks [here](https://hub.continue.dev/explore/mcp).
|
||||
|
||||
To set up your own MCP server, read the [MCP quickstart](https://modelcontextprotocol.io/quickstart) and then [create an `mcpServers` block](https://hub.continue.dev/new?type=block&blockType=mcpServers) or add the following to your [config file](../customize/deep-dives/configuration.md):
|
||||
To set up your own MCP server, read the [MCP quickstart](https://modelcontextprotocol.io/quickstart) and then [create an `mcpServers` block](https://hub.continue.dev/new?type=block&blockType=mcpServers) or add the following to your [config file](./configuration.md):
|
||||
|
||||
<Tabs groupId="config-example">
|
||||
<TabItem value="yaml" label="YAML">
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
title: Prompt files
|
||||
---
|
||||
|
||||
Prompt files provide a convenient way to standardize common patterns and share a collection of LLM prompts with your team. They make it easy to build and use these prompts.
|
||||
Prompt files allow you to build and use local prompts, and provide a convenient way to test and iterate on prompts before publishing them to the Hub.
|
||||
|
||||
On the [hub](../../hub/introduction.md), prompt files are stored within [prompt blocks](../../hub/blocks/block-types.md#prompts), which show up as [slash commands](../slash-commands.mdx) in Chat. Visit the hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&blockType=rules).
|
||||
|
||||
Prompt files can also be stored within your project's root directory as `.prompt` files. See below.
|
||||
:::info
|
||||
Visit the Hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&blockType=prompts)
|
||||
:::
|
||||
|
||||
## Quick start
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ Attached is a summary of the current Ruby on Rails application, including the @G
|
|||
|
||||
Now to use this prompt, you can highlight code and use <kbd>cmd/ctrl</kbd> + <kbd>L</kbd> to select it in the Continue sidebar.
|
||||
|
||||
Then, type "@", select "Prompt files", and choose the one called "Rails Project". You can now ask any question as usual and the LLM will have the information from your .prompt file.
|
||||
Then, type <kbd>/</kbd> and choose the "Rails Project" prompt. You can now ask any question as usual and the LLM will have the information from your .prompt file.
|
||||
|
||||
## Format
|
||||
|
||||
|
|
|
|||
|
|
@ -14,21 +14,21 @@ Which takes you to this page:
|
|||
|
||||

|
||||
|
||||
Click the `Open Assistant configuration` button to open your configuration file. See the [Configuration Reference](../reference.md) for more information.
|
||||
|
||||
Below that, the following settings which are not part of a configuration file are available:
|
||||
|
||||
- `Show Session Tabs`: If on, displays tabs above the chat as an alternative way to organize and access your sessions. Off by default
|
||||
- `Wrap Codeblocks`: If on, enables text wrapping in code blocks. Off by default.
|
||||
- `Display Raw Markdown`: If on, shows raw markdown in responses. Off by default.
|
||||
- `Allow Anonymous Telemetry`: If on, allows Continue to send anonymous telemetry. **On** by default.
|
||||
- `Disable Indexing`: Prevents indexing of the codebase, useful primarily for debugging purposes. Off by default.
|
||||
- `Disable Session Titles`: Prevents generating summary titles for each chat session when turned on. Off by default
|
||||
- `Response Text to Speech`: If on, reads LLM responses aloud with TTS. Off by default.
|
||||
- `Show Chat Scrollbar`: If on, enables a scrollbar in the chat window. Off by default.
|
||||
- `Use autocomplete cache`: If on, caches completions.
|
||||
- `Use Chromium for Docs Crawling`: Use Chromium to crawl docs locally. Useful if the default Cheerio crawler fails on sites that require JavaScript rendering. Downloads and installs Chromium to ~/.continue/.utils. Off by default
|
||||
- `Codeblock Actions Position`: Sets the position for the actions that show when hovering over codeblocks. Defaults to `top`
|
||||
- `Multiline Autocompletions`: Controls multiline completions for autocomplete. Can be set to `always`, `never`, or `auto`. Defaults to `auto`
|
||||
- `Text-to-Speech Output`: If on, reads LLM responses aloud with TTS. Off by default.
|
||||
- `Enable Session Titles`: If on, generates summary titles for each chat session after the first message, using the current Chat model. On by default.
|
||||
- `Format Markdown`: If off, shows responses as raw text. On by default.
|
||||
- `Allow Anonymous Telemetry`: If on, allows Continue to send anonymous telemetry. **On** by default.
|
||||
- `Enable Indexing`: Enables indexing of the codebase for the @codebase and @code context providers. **On** by default.
|
||||
- `Font Size`: Specifies base font size for UI elements
|
||||
- `Workspace prompts path`: Where to find Prompt Files in a workspace - replaces the default .continue/prompts
|
||||
- `Multiline Autocompletions`: Controls multiline completions for autocomplete. Can be set to `always`, `never`, or `auto`. Defaults to `auto`
|
||||
- `Disable autocomplete in files`: List of comma-separated glob pattern to disable autocomplete in matching files. E.g., "\_/.md, \*/.txt"
|
||||
|
||||
<!-- - `Use autocomplete cache`: If on, caches completions. -->
|
||||
<!-- - `Use Chromium for Docs Crawling`: Use Chromium to crawl docs locally. Useful if the default Cheerio crawler fails on sites that require JavaScript rendering. Downloads and installs Chromium to ~/.continue/.utils. Off by default -->
|
||||
<!-- - `Codeblock Actions Position`: Sets the position for the actions that show when hovering over codeblocks. Defaults to `top` -->
|
||||
<!-- - `Workspace prompts path`: Where to find Prompt Files in a workspace - replaces the default .continue/prompts -->
|
||||
33
docs/docs/customize/deep-dives/slash-commands.mdx
Normal file
33
docs/docs/customize/deep-dives/slash-commands.mdx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
title: Slash commands
|
||||
description: Shortcuts that can be activated by prefacing your input with '/'
|
||||
keywords: [slash command, custom commands, step]
|
||||
---
|
||||
|
||||
import TabItem from "@theme/TabItem";
|
||||
import Tabs from "@theme/Tabs";
|
||||
|
||||

|
||||
|
||||
## Slash commands
|
||||
|
||||
Slash commands are shortcuts that can be activated by typing '/' in a chat session (press <kbd>cmd/ctrl</kbd> + <kbd>L</kbd> (VS Code) or <kbd>cmd/ctrl</kbd> + <kbd>J</kbd> (JetBrains)), and selecting from the dropdown.
|
||||
{/*  */}
|
||||
|
||||
Slash commands can be combined with additional instructions, including [context providers](../context-providers.mdx) or [highlighted code](../../edit/context-selection#highlighted-code).
|
||||
|
||||
## Prompts
|
||||
|
||||
### Assistant prompt blocks
|
||||
|
||||
The easiest way to add a slash command is by adding [`prompt` blocks](../../hub/blocks/block-types.md#prompts) to your assistant, which show up as slash commands in [Chat](../../chat/how-it-works.md).
|
||||
|
||||
### Prompt files
|
||||
|
||||
It is also possible to write your own slash command by defining a “.prompt file.” Prompt files can be as simple as a text file, but also include templating so that you can refer to files, URLs, highlighted code, and more.
|
||||
|
||||
Learn more about prompt files [here](./prompt-files.md)
|
||||
|
||||
### MCP Server prompts
|
||||
|
||||
Any prompts provided by [Model Context Protocol](https://modelcontextprotocol.io/introduction) servers are also accessible in chat as Slash Commands. See the [MCP Server Deep Dive](./mcp.mdx) for more details.
|
||||
49
docs/docs/customize/deep-dives/vscode-actions.md
Normal file
49
docs/docs/customize/deep-dives/vscode-actions.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
title: VS Code Actions
|
||||
description: VS Code Actions
|
||||
keywords: [vscode, quick actions, quick, actions]
|
||||
---
|
||||
|
||||
### Other triggers for Actions (VS Code)
|
||||
|
||||
:::info
|
||||
Currently all of these are only available in VS Code
|
||||
:::
|
||||
|
||||
To make common use cases even more accessible, we provide a handful of other ways to invoke actions in VS Code.
|
||||
|
||||
## Quick actions
|
||||
|
||||
Quick Actions are displayed as buttons above top-level classes and functions in your source code, letting you invoke actions with one click. They will edit that class or function, but nothing outside of it. They can also be customized with [.prompt files](./prompt-files.md) to perform custom actions.
|
||||
|
||||

|
||||
|
||||
By default, quick actions are disabled, but can be enabled with the “Continue: Enable Quick Actions” in VS Code settings.
|
||||
|
||||
## Right click actions
|
||||
|
||||
Right click actions let you highlight a desired region of code, right click, and then select an action from the dropdown menu.
|
||||
|
||||
The highlighted code you’ve selected will be included in your prompt alongside a pre-written set of instructions depending on the selected action. This is the only section of code that the model will attempt to edit.
|
||||
|
||||
Right click actions that generate inline diffs use the same prompt and response processing logic as [Edit](../../edit/how-it-works.md).
|
||||
|
||||

|
||||
|
||||
## Debug action
|
||||
|
||||
The debug action is a special built-in keyboard shortcut in the VS Code extension. Use <kbd>cmd/ctrl</kbd> + <kbd>shift</kbd> + <kbd>R</kbd> to instantly copy the contents of the most recent terminal output into the chat sidebar and get debugging advice. There is no additional, non-visible information sent to the language model.
|
||||
|
||||
```
|
||||
I got the following error, can you please help explain how to fix it?
|
||||
|
||||
[ERROR_MESSAGE]
|
||||
```
|
||||
|
||||
## Quick fixes
|
||||
|
||||
Whenever you see red/yellow underlines in your code indicating errors, you can place your cursor nearby and VS Code will display a lightbulb icon. Either clicking the lightbulb or using the keyboard shortcut <kbd>cmd/ctrl</kbd> + <kbd>.</kbd> will show a dropdown menu of quick fixes. One of these will be the “Ask Continue” action. Either click or use <kbd>cmd/ctrl</kbd> + <kbd>.</kbd> again and Continue will attempt to help solve the problem.
|
||||
|
||||
Similarly to the debug action, quick actions transparently inject a prompt into the chat window. When you select “Ask Continue”, the 3 lines above and below the error are sent to the chat followed by the question “How do I fix the following problem in the above code?: [ERROR_MESSAGE]”.
|
||||
|
||||

|
||||
|
|
@ -15,9 +15,9 @@ Available models can be found on the [Nebius AI Studio models page](https://stud
|
|||
<TabItem value="yaml" label="YAML">
|
||||
```yaml title="config.yaml"
|
||||
models:
|
||||
- name: Llama 3.1 405b
|
||||
- name: DeepSeek R1
|
||||
provider: nebius
|
||||
model: llama3.1-405b
|
||||
model: deepseek-ai/DeepSeek-R1
|
||||
apiKey: <YOUR_NEBIUS_API_KEY>
|
||||
```
|
||||
</TabItem>
|
||||
|
|
@ -26,9 +26,9 @@ Available models can be found on the [Nebius AI Studio models page](https://stud
|
|||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 405b",
|
||||
"title": "DeepSeek R1",
|
||||
"provider": "nebius",
|
||||
"model": "llama3.1-405b",
|
||||
"model": "deepseek-ai/DeepSeek-R1",
|
||||
"apiKey": "<YOUR_NEBIUS_API_KEY>"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import Tabs from "@theme/Tabs";
|
|||
|
||||
A "chat model" is an LLM that is trained to respond in a conversational format. Because they should be able to answer general questions and generate complex code, the best chat models are typically large, often 405B+ parameters.
|
||||
|
||||
In Continue, these models are used for [Chat](../../chat/how-to-use-it.md) and [Actions](../../actions/how-to-use-it.md). The selected chat model will also be used for [Edit](../../edit/how-to-use-it.md) and [Apply](./apply.mdx) if no `edit` or `apply` models are specified, respectively.
|
||||
In Continue, these models are used for normal [Chat](../../chat/how-to-use-it.md) and [VS Code actions](../deep-dives/vscode-actions.md). The selected chat model will also be used for [Edit](../../edit/how-to-use-it.md) and [Apply](./apply.mdx) if no `edit` or `apply` models are specified, respectively.
|
||||
|
||||
## Recommended Chat models
|
||||
|
||||
|
|
@ -51,117 +51,66 @@ Our current top recommendation is Claude 3.7 Sonnet from [Anthropic](../model-pr
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Llama 3.1 405B from Meta
|
||||
### Gemma from Google DeepMind
|
||||
|
||||
If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../model-providers/more/together.mdx) or [Groq](../model-providers/more/groq.mdx)) or self-host it (e.g. using [vLLM](../model-providers//more/vllm.mdx) or [Ollama](../model-providers/top-level/ollama.mdx)).
|
||||
If you prefer to use an open-weight model, then the Gemma family of Models from Google DeepMind is a good choice. You will need to decide if you use it through a SaaS model provider, e.g. [Together](../model-providers/more/together.mdx), or self-host it, e.g. [Ollama](../model-providers/top-level/ollama.mdx).
|
||||
|
||||
<Tabs groupId="config-example">
|
||||
{/* HUB_TODO nonexistent blocks */}
|
||||
{/* <TabItem value="hub" label="Hub">
|
||||
<TabItem value="hub" label="Hub">
|
||||
<Tabs groupId="providers">
|
||||
<TabItem value="Together">
|
||||
Add the [Together Llama 3.1 405b block](https://hub.continue.dev/explore/assistants) from the hub
|
||||
</TabItem>
|
||||
<TabItem value="Groq">
|
||||
Add the [Groq Llama 3.1 405b block](https://hub.continue.dev/explore/assistants) from the hub
|
||||
</TabItem>
|
||||
<TabItem value="vLLM">
|
||||
Add the [vLLM Llama 3.1 405b block](https://hub.continue.dev/explore/assistants) from the hub
|
||||
</TabItem>
|
||||
<TabItem value="Ollama">
|
||||
Add the [Ollama Llama 3.1 405b block](https://hub.continue.dev/explore/assistants) from the hub
|
||||
Add the [Ollama Gemma 3 27B block](https://hub.continue.dev/ollama/gemma3-27b) from the hub
|
||||
</TabItem>
|
||||
<TabItem value="Together">
|
||||
Add the [Together Gemma 2 27B Instruct block](https://hub.continue.dev/togetherai/gemma-2-instruct-27b) from the hub
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
</TabItem> */}
|
||||
</TabItem>
|
||||
<TabItem value="yaml" label="YAML">
|
||||
<Tabs groupId="providers">
|
||||
<TabItem value="Together">
|
||||
```yaml title="config.yaml"
|
||||
models:
|
||||
- name: "Llama 3.1 405B"
|
||||
provider: "together"
|
||||
model: "llama3.1-405b"
|
||||
apiKey: <YOUR_TOGETHER_API_KEY>
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="Groq">
|
||||
```yaml title="config.yaml"
|
||||
models:
|
||||
- name: "Llama 3.1 405B"
|
||||
provider: "groq"
|
||||
model: "llama3.1-405b"
|
||||
apiKey: <YOUR_GROQ_API_KEY>
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="vLLM">
|
||||
```yaml title="config.yaml"
|
||||
models:
|
||||
- name: "Llama 3.1 405B"
|
||||
provider: "vllm"
|
||||
model: "llama3.1-405b"
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="Ollama">
|
||||
```yaml title="config.yaml"
|
||||
models:
|
||||
- name: "Llama 3.1 405B"
|
||||
- name: "Gemma 3 27B"
|
||||
provider: "ollama"
|
||||
model: "llama3.1:405b"
|
||||
model: "gemma3:27b"
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="Together">
|
||||
```yaml title="config.yaml"
|
||||
models:
|
||||
- name: "Gemma 3 27B"
|
||||
provider: "together"
|
||||
model: "google/gemma-2-27b-it"
|
||||
apiKey: <YOUR_TOGETHER_API_KEY>
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
</TabItem>
|
||||
<TabItem value="json" label="JSON">
|
||||
<Tabs groupId="providers">
|
||||
<TabItem value="Together">
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 405B",
|
||||
"provider": "together",
|
||||
"model": "llama3.1-405b",
|
||||
"apiKey": "<YOUR_TOGETHER_API_KEY>"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="Groq">
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 405B",
|
||||
"provider": "groq",
|
||||
"model": "llama3.1-405b",
|
||||
"apiKey": "<YOUR_GROQ_API_KEY>"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="vLLM">
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 405B",
|
||||
"provider": "vllm",
|
||||
"model": "llama3.1-405b"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="Ollama">
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 405B",
|
||||
"title": "Gemma 3 27B",
|
||||
"provider": "ollama",
|
||||
"model": "llama3.1:405b"
|
||||
"model": "gemma3:27b"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="Together">
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Gemma 3 27B",
|
||||
"provider": "together",
|
||||
"model": "google/gemma-2-27b-it",
|
||||
"apiKey": "<YOUR_TOGETHER_API_KEY>"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ Models in Continue can be configured to be used for various roles in the extensi
|
|||
- [`embed`](./embeddings.mdx): Used to generate embeddings used for vector search (@Codebase and @Docs context providers)
|
||||
- [`rerank`](./reranking.mdx): Used to rerank results from vector search
|
||||
|
||||
These roles can be specified for a `config.yaml` model block using `roles`. See the [YAML Specification](../../yaml-reference.md#models) for more details.
|
||||
These roles can be specified for a `config.yaml` model block using `roles`. See the [YAML Specification](../../reference.md#models) for more details.
|
||||
|
||||
## Selecting model roles
|
||||
|
||||
You can control which of the models in your assistant for a given role will be currently used for that role. Visit the [Settings page](../settings.md) and go to the **Active Models** section.
|
||||
You can control which of the models in your assistant for a given role will be currently used for that role. Above the main input, click the 3 dots and then the cube icon to expand the `Models` section. Then you can use the dropdowns to select an active model for each role.
|
||||
|
||||

|
||||
|
||||
:::info
|
||||
Note that `roles` do not exist within `config.json` - they are infered by the top level keys like `embeddingsProvider`
|
||||
`roles` are not explicitly defined within `config.json` (deprecated) - they are infered by the top level keys like `embeddingsProvider`
|
||||
:::
|
||||
|
|
|
|||
|
|
@ -7,44 +7,18 @@ keywords: [customize, configure, config]
|
|||
Continue can be deeply customized. For example you might:
|
||||
|
||||
- **Change your Model Provider**. Continue allows you to choose your favorite or even add multiple model providers. This allows you to use different models for different tasks, or to try another model if you're not happy with the results from your current model. Continue supports all of the popular model providers, including OpenAI, Anthropic, Microsoft/Azure, Mistral, and more. You can even self host your own model provider if you'd like. Learn more about [model providers](../customize/model-providers/).
|
||||
- **Select different model providers for each Compose feature**. Different Continue features can use different model providers. We call these _model types_. For example, you can use a different model provider for chat than you do for autocomplete. Learn more about [model types](../customize/model-roles/) .
|
||||
- **Add a Context Provider**. Context providers allow you to add information to your prompts, giving your LLM additional context to work with. Context providers allow you to reference snippets from your codebase, or lookup relevant documentation, or use a search engine to find information and much more. Learn more about [context providers](/customize/context-providers).
|
||||
- **Create a Slash Command**. Slash commands allow you to easily add custom functionality to Continue. You can use a slash command that allows you to generate a shell command from natural language, or perhaps generate a commit message, or create your own custom command to do whatever you want. Learn more about [slash commands](/customize/slash-commands).
|
||||
- **Call external tools and functions**. Unchain your LLM with the power of _Tools_. You can call any external tool or function from your prompts. Currently only available with Anthropic. Learn more about [Tools](/customize/tools).
|
||||
- **Select different models for specific tasks**. Different Continue features can use different models. We call these _model roles_. For example, you can use a different model for chat than you do for autocomplete. Learn more about [model roles](./model-roles/) .
|
||||
- **Add a Context Provider**. Context providers allow you to add information to your prompts, giving your LLM additional context to work with. Context providers allow you to reference snippets from your codebase, or lookup relevant documentation, or use a search engine to find information and much more. Learn more about [context providers](./context-providers.mdx).
|
||||
- **Create a Slash Command**. Slash commands allow you to easily add custom functionality to Continue. You can use a slash command that allows you to generate a shell command from natural language, or perhaps generate a commit message, or create your own custom command to do whatever you want. Learn more about [slash commands](./deep-dives/slash-commands.mdx).
|
||||
- **Call external tools and functions**. Unchain your LLM with the power of tools using [Agent](../agent/how-to-use-it.md). Add custom tools using [MCP Servers](./deep-dives/mcp.mdx)
|
||||
|
||||
Whatever you choose, you'll probably start by editing `config.yaml`.
|
||||
Whatever you choose, you'll probably start by editing your Assistant.
|
||||
|
||||
## Editing config.json
|
||||
## Editing your assistant
|
||||
|
||||
Most custom configuration is done by editing `config.yaml` (or the older `config.json`). This is a YAML file that allows you to customize Continue to your liking. It is found at:
|
||||
You can easily access your assistant configuration from the Continue Chat sidebar. Open the sidebar by pressing <kbd>cmd/ctrl</kbd> + <kbd>L</kbd> (VS Code) or <kbd>cmd/ctrl</kbd> + <kbd>J</kbd> (JetBrains) and click the Assistant selector above the main chat input. Then, you can hover over an assistant and click the `new window` (hub assistants) or `gear` (local assistants) icon.
|
||||
|
||||
- MacOS and Linux: `~/.continue/config.yaml`
|
||||
- Windows: `%USERPROFILE%\.continue\config.yaml`
|
||||

|
||||
|
||||
You can easily access config file from the Continue Chat sidebar. Open the sidebar by pressing <kbd>cmd/ctrl</kbd> + <kbd>L</kbd> (VS Code) or <kbd>cmd/ctrl</kbd> + <kbd>J</kbd> (JetBrains) and click the "gear" icon in header to open the Settings page. Then click the button labeled `Open Assistant configuration`.
|
||||
|
||||

|
||||
|
||||
When editing this file, you can see the available options suggested as you type, or you can check the [full reference](./deep-dives/configuration.md).
|
||||
|
||||
:::info
|
||||
|
||||
A configuration file is created the first time you use Continue. If you'd like to reset your configuration to the default, you can delete this file and Continue will automatically recreate it with the default settings.
|
||||
|
||||
:::
|
||||
|
||||
:::info
|
||||
|
||||
When you save a configuration file from the IDE, Continue will automatically refresh to take into account your changes.
|
||||
|
||||
:::
|
||||
|
||||
## Per-workspace configuration
|
||||
|
||||
If you'd like to scope certain settings to a particular workspace, you can add a `.continuerc.json` to the root of your project. It has the same [definition](./deep-dives/configuration.md) as `config.json`, and will automatically be applied on top of the local config.json.
|
||||
|
||||
## Programmatic configuration
|
||||
|
||||
`config.yaml` or `config.json` can handle the vast majority of necessary configuration, so we recommend using it whenever possible. However, if you need to programmatically configure Continue, you can use `config.ts`, which is located at `~/.continue/config.ts` (MacOS / Linux) or `%USERPROFILE%\.continue\config.ts` (Windows).
|
||||
|
||||
For examples of how to use `config.ts`, see [writing custom slash commands](./tutorials/build-your-own-slash-command.md#custom-slash-commands) or [writing custom context providers](./tutorials/build-your-own-context-provider.mdx).
|
||||
- See [Editing Hub Assistants](../hub/assistants/edit-an-assistant.md) for more details on managing your hug assistant
|
||||
- See the [Config Deep Dive](./deep-dives/configuration.md) for more details on configuring local assistants.
|
||||
|
|
|
|||
|
|
@ -1,154 +0,0 @@
|
|||
---
|
||||
title: Slash commands
|
||||
description: Shortcuts that can be activated by prefacing your input with '/'
|
||||
keywords: [slash command, custom commands, step]
|
||||
---
|
||||
|
||||
import TabItem from "@theme/TabItem";
|
||||
import Tabs from "@theme/Tabs";
|
||||
|
||||
:::info
|
||||
Slash commands can currently only be added using [`config.json`](../reference.md). The [`YAML Config Format`](../reference.md) is the new and preferred format. We recommend looking into [Prompt Files](../customize/deep-dives/prompt-files.md) to achieve similar functionality.
|
||||
:::
|
||||
|
||||
Slash commands are shortcuts that can be activated by typing '/' and selecting from the dropdown. For example, the built-in '/edit' slash command lets you stream edits directly into your editor.
|
||||
|
||||

|
||||
|
||||
## Built-in Slash Commands
|
||||
|
||||
To use any of the built-in slash commands, open `config.json` and add it to the `slashCommands` list.
|
||||
|
||||
### `/share`
|
||||
|
||||
Generate a shareable markdown transcript of your current chat history.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "share",
|
||||
"description": "Export the current chat session to markdown",
|
||||
"params": { "outputDir": "~/.continue/session-transcripts" }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Use the `outputDir` parameter to specify where you want to the markdown file to be saved.
|
||||
|
||||
### `/cmd`
|
||||
|
||||
Generate a shell command from natural language and (only in VS Code) automatically paste it into the terminal.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "cmd",
|
||||
"description": "Generate a shell command"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/commit`
|
||||
|
||||
Shows the LLM your current git diff and asks it to generate a commit message.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "commit",
|
||||
"description": "Generate a commit message for the current changes"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/http`
|
||||
|
||||
Write a custom slash command at your own HTTP endpoint. Set 'url' in the params object for the endpoint you have setup. The endpoint should return a sequence of string updates, which will be streamed to the Continue sidebar. See our basic [FastAPI example](https://github.com/continuedev/continue/blob/74002369a5e435735b83278fb965e004ae38a97d/core/context/providers/context_provider_server.py#L34-L45) for reference.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "http",
|
||||
"description": "Does something custom",
|
||||
"params": { "url": "<my server endpoint>" }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/issue`
|
||||
|
||||
Describe the issue you'd like to generate, and Continue will turn into a well-formatted title and body, then give you a link to the draft so you can submit. Make sure to set the URL of the repository you want to generate issues for.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "issue",
|
||||
"description": "Generate a link to a drafted GitHub issue",
|
||||
"params": { "repositoryUrl": "https://github.com/continuedev/continue" }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/onboard`
|
||||
|
||||
The onboard slash command helps to familiarize yourself with a new project by analyzing the project structure, READMEs, and dependency files. It identifies key folders, explains their purpose, and highlights popular packages used. Additionally, it offers insights into the project's architecture.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "onboard",
|
||||
"description": "Familiarize yourself with the codebase"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Model Context Protocol
|
||||
|
||||
The [Model Context Protocol](https://modelcontextprotocol.io/introduction) is a standard proposed by Anthropic to unify prompts, context, and tool use. Continue supports MCP "prompts" by creating slash commands. Read their [quickstart](https://modelcontextprotocol.io/quickstart) to learn how to set up a local server and then set up your configuration like this:
|
||||
|
||||
<Tabs groupId="config-example">
|
||||
<TabItem value="yaml" label="YAML">
|
||||
```yaml title="config.yaml"
|
||||
mcpServers:
|
||||
- name: My MCP Server
|
||||
command: uvx
|
||||
args:
|
||||
- mcp-server-sqlite
|
||||
- --db-path
|
||||
- /Users/NAME/test.db
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="json" label="JSON">
|
||||
```json title="config.json"
|
||||
{
|
||||
"experimental": {
|
||||
"modelContextProtocolServers": [
|
||||
{
|
||||
"transport": {
|
||||
"type": "stdio",
|
||||
"command": "uvx",
|
||||
"args": ["mcp-server-sqlite", "--db-path", "/Users/NAME/test.db"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Build your own Slash Command
|
||||
|
||||
You can build your own slash command by following [this tutorial](/customize/tutorials/build-your-own-slash-command).
|
||||
|
|
@ -3,7 +3,7 @@ title: Build your own slash command
|
|||
---
|
||||
|
||||
:::info
|
||||
Slash commands can currently only be added using [`config.json`](../../reference.md) or `config.ts`. The [`YAML Config Format`](../../reference.md) is the new and preferred format. We recommend looking into [Prompt Files](../deep-dives/prompt-files.md) to achieve similar functionality.
|
||||
Slash commands can currently only be added using [`config.json`](../../json-reference.md) or `config.ts`. The [`YAML Config Format`](../../reference.md) is the new and preferred format. We recommend looking into [Prompt Files](../deep-dives/prompt-files.md) to achieve similar functionality.
|
||||
:::
|
||||
|
||||
There are two ways to add custom slash commands:
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ keywords: [no internet, air-gapped, local model]
|
|||
Continue can be run even on an air-gapped computer if you use a local model. Only a few adjustments are required for this to work.
|
||||
|
||||
1. Download the latest .vsix file from the [Open VSX Registry](https://open-vsx.org/extension/Continue/continue) and [install it to VS Code](https://code.visualstudio.com/docs/editor/extension-marketplace#_install-from-a-vsix).
|
||||
2. Open the [User Settings Page](../settings.md) and turn off "Allow Anonymous Telemetry". This will stop Continue from attempting requests to PostHog for [anonymous telemetry](../../telemetry.md).
|
||||
2. Open the [User Settings Page](../deep-dives/settings.md) and turn off "Allow Anonymous Telemetry". This will stop Continue from attempting requests to PostHog for [anonymous telemetry](../../telemetry.md).
|
||||
3. Also in `config.json`, set the default model to a local model. You can available options [here](../model-providers/).
|
||||
4. Restart VS Code to ensure that the changes to `config.json` or `config.yaml` take effect.
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ keywords: [edit, cmd i, works]
|
|||
|
||||
The input you provide is included in the prompt.
|
||||
|
||||
## Highlighted code
|
||||
## Code to Edit
|
||||
|
||||
The highlighted code you’ve selected is included in the prompt. This is the only section of code that the model will attempt to edit.
|
||||
The **entire contents** of each file (the current file for Jetbrains inline Edit, each `Code to Edit` item for VS Code Edit mode) are included in the prompt for context. The model will only attempt to edit the highlighted/specified ranges.
|
||||
|
||||
## Current file
|
||||
## Context Providers
|
||||
|
||||
The entire contents of the file containing your highlighted code selection are included as additional context. This gives the model a broader understanding of the code's environment. If the file is too large to fit within the context window, we will trim the file's contents to fit.
|
||||
In VS Code Edit mode, you can use `@` to add context using [Context Providers](../customize/context-providers.mdx), similar to [Chat](../chat/context-selection.md). Some context providers may be disabled in Edit mode.
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
---
|
||||
title: How Edit works
|
||||
sidebar_position: 4
|
||||
description: How Edit works
|
||||
description: How it works
|
||||
keywords: [edit, cmd l, works]
|
||||
---
|
||||
|
||||
Using the highlighted code, the contents of the file containing your highlight, and your input instructions, we prompt the model to edit the code according to your instructions. No other additional context is provided to the model.
|
||||
Using the highlighted code, the contents of the current file containing your highlight, and your input instructions, we prompt the model to edit the code according to your instructions. No other additional context is provided to the model.
|
||||
|
||||
The model response is then streamed directly back to the highlighted range in your code, where we apply a diff formatting to show the proposed changes.
|
||||
|
||||
If you accept the diff, we remove the previously highlighted lines, and if you reject the diff, we remove the proposed changes.
|
||||
|
||||
If you would like to view the exact prompt that is sent to the model during an edit, you can [view this in the prompt logs](../troubleshooting.mdx#check-the-logs).
|
||||
If you would like to view the exact prompt that is sent to the model during an edit, you can [find it in the prompt logs](../troubleshooting.mdx#check-the-logs).
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ description: How to customize Edit
|
|||
keywords: [edit, cmd i, works]
|
||||
---
|
||||
|
||||
import TabItem from "@theme/TabItem";
|
||||
import Tabs from "@theme/Tabs";
|
||||
## Setting active Edit/Apply model
|
||||
|
||||
You can configure a particular model to be used for Edit by setting/overriding `roles` in the model's YAML config. See [Edit role](../customize/model-roles/edit.mdx) for more details.
|
||||
You can configure particular models from your Assistant to be used for Edit and Apply requests (see [How it Works](./how-it-works.md)). Above the main input, click the 3 dots and then the cube icon to expand the `Models` section. Then, you can use the dropdowns to select models to use for Edit and Apply.
|
||||
|
||||

|
||||
|
||||
See [Edit role](../customize/model-roles/edit.mdx) and [Apply role](../customize/model-roles/apply.mdx) for more details.
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ keywords: [edit, cmd l, use]
|
|||
|
||||
## How to use it
|
||||
|
||||
Edit is a convenient way to modify code without leaving your current file. Highlight a block of code, describe your code changes, and a diff will be streamed inline to your file which you can accept or reject.
|
||||
Edit is a convenient way to make quick changes to specific code and files. Select code, describe your code changes, and a diff will be streamed inline to your file which you can accept or reject.
|
||||
|
||||
Edit is best used for small, quick changes such as:
|
||||
Edit is recommended for small, targeted changes, such as
|
||||
|
||||
- Writing comments
|
||||
- Generating unit tests
|
||||
|
|
@ -20,7 +20,7 @@ Edit is best used for small, quick changes such as:
|
|||
|
||||
## Highlight code and activate
|
||||
|
||||
Highlight the block of code you would like to modify, and press <kbd>cmd/ctrl</kbd> + <kbd>i</kbd> to activate the edit input.
|
||||
Highlight the block of code you would like to modify and press <kbd>cmd/ctrl</kbd> + <kbd>i</kbd> to active Edit mode. You can also enter Edit mode by pressing <kbd>cmd/ctrl</kbd> + <kbd>i</kbd> with no code highlighted.
|
||||
|
||||
## Describe code changes
|
||||
|
||||
|
|
@ -35,3 +35,45 @@ You can navigate through each proposed change, accepting or rejecting them using
|
|||
You can also accept or reject all changes at once using <kbd>cmd/ctrl</kbd> + <kbd>shift</kbd> + <kbd>enter</kbd> (to accept) or <kbd>cmd/ctrl</kbd> + <kbd>shift</kbd> + <kbd>delete/backspace</kbd> (to reject).
|
||||
|
||||
If you want to request a new suggestion for the same highlighted code section, you can use <kbd>cmd/ctrl</kbd> + <kbd>i</kbd> to re-prompt the model.
|
||||
|
||||
## VS Code
|
||||
|
||||
In VS Code, Edit is implemented in the extension sidebar with a similar interface to [Chat](../chat/how-it-works.md), and you can also enter Edit mode by using the Mode Selector below the main Chat input to select `Edit`.
|
||||
|
||||

|
||||
|
||||
You can also reject and accept diffs using the `Reject All` and `Accept All` buttons that show up in the Chat when diffs are present (see examples below).
|
||||
|
||||
### Adding Code to Edit
|
||||
|
||||
Along with adding highlighted code, you can also manually add files to edit using the `Add file` combobox or by clicking the dropdown and selecting `Add all open files` to add all files that are currently open in the editor.
|
||||
|
||||
**_Add file combobox_**
|
||||
|
||||

|
||||
|
||||
**_Add all open files dropdown_**
|
||||
|
||||

|
||||
|
||||
### Single File Edit
|
||||
|
||||
If one file/range is present in `Code to Edit` on submission, Continue will prompt the Edit model and then automatically stream the diff into the editor.
|
||||
|
||||

|
||||
|
||||
### Multi-File Edit
|
||||
|
||||
If multiple files/ranges are present in `Code to Edit` on submission, Continue will prompt the Edit model to output codeblocks per-file, which the user can then choose to apply and accept/reject independently.
|
||||
|
||||
**_Generated Content_**
|
||||
|
||||

|
||||
|
||||
**_Diffs_**
|
||||
|
||||

|
||||
|
||||
## Jetbrains
|
||||
|
||||
In Jetbrains, Edit is implemented as an inline popup (see the header GIF example) for single-file edit. Multi-file edit mode is not currently implemented.
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ description: How to set up an Edit model
|
|||
keywords: [edit, cmd l, model]
|
||||
---
|
||||
|
||||
By default, Edit uses the [same model as Chat](../chat/model-setup.mdx) since we recommend a similar, 400B+ parameter model or one of the frontier model for code edits.
|
||||
By default, Edit uses the [same model as Chat](../chat/model-setup.mdx), and we recommend [Claude 3.7 Sonnet](https://hub.continue.dev/anthropic/claude-3-7-sonnet) from Anthropic. Visit [the Hub](https://hub.continue.dev/explore/models?roles=edit) to explore other Edit models.
|
||||
|
||||
Visit [the hub](https://hub.continue.dev/explore/models?roles=edit) to explore Edit models.
|
||||
|
||||
You can configure a different model to be used for edits by updating your [configuration](../customize/model-roles/edit.mdx).
|
||||
For the best Edit experience, we also recommend setting up an Apply model, specially trained to apply diffs to files. We recommend [Morph v0 Fast Apply](https://hub.continue.dev/morphllm/morph-v0) or [Relace Instant Apply](https://hub.continue.dev/relace/instant-apply). Explore other apply models on the [the Hub](https://hub.continue.dev/explore/models?roles=apply).
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ description: Getting started with Continue
|
|||
keywords: [quickstart, start, overview, chat, autocomplete, edit, actions]
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
import Admonition from "@theme/Admonition";
|
||||
import TabItem from "@theme/TabItem";
|
||||
import Tabs from "@theme/Tabs";
|
||||
|
||||
To quickly understand what you can do with Continue, check out each tab below.
|
||||
|
||||
|
|
@ -33,26 +33,29 @@ To quickly understand what you can do with Continue, check out each tab below.
|
|||
</Admonition>
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="edit" label="Edit">
|
||||
|
||||
[Edit](../edit/how-to-use-it.md#how-to-use-it) is a convenient way to modify code without leaving your current file
|
||||
[Edit](../edit/how-to-use-it.md#how-to-use-it) is a convenient way to modify code without leaving your current file
|
||||
|
||||

|
||||

|
||||
|
||||
<Admonition type="info" title="Learn more" icon="📚">
|
||||
Learn more about [Edit](../edit/how-to-use-it.md#how-to-use-it)
|
||||
</Admonition>
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="agent" label="Agent">
|
||||
|
||||
[Agent](../agent/how-to-use-it.md#how-to-use-it) equips the Chat model with the tools needed to handle a wide range of coding tasks
|
||||
|
||||

|
||||
|
||||
<Admonition type="info" title="Learn more" icon="📚">
|
||||
Learn more about [Edit](../edit/how-to-use-it.md#how-to-use-it)
|
||||
Learn more about [Agent](../agent/how-to-use-it.md#how-to-use-it)
|
||||
</Admonition>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="s" label="Actions">
|
||||
|
||||
[Actions](../actions/how-to-use-it.md#how-to-use-it) are shortcuts for common use cases
|
||||
|
||||

|
||||
|
||||
<Admonition type="info" title="Learn more" icon="📚">
|
||||
Learn more about how to use [Actions](../actions/how-to-use-it.md#how-to-use-it)
|
||||
</Admonition>
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ Choose a name, slug, description, and icon for your assistant.
|
|||
|
||||
The easiest way to create an assistant is to click "Create assistant" with the default configuration and then add / remove blocks using the sidebar.
|
||||
|
||||
Alternatively, you can edit the assistant YAML directly before clicking "Create assistant". Refer to examples of assistants on [hub.continue.dev](https://hub.continue.dev/explore/assistants) and visit the [YAML Reference](../../yaml-reference.md#complete-yaml-config-example) docs for more details.
|
||||
Alternatively, you can edit the assistant YAML directly before clicking "Create assistant". Refer to examples of assistants on [hub.continue.dev](https://hub.continue.dev/explore/assistants) and visit the [YAML Reference](../../reference.md#complete-yaml-config-example) docs for more details.
|
||||
|
||||

|
||||
|
||||
|
|
|
|||
|
|
@ -11,31 +11,31 @@ sidebar_label: Types
|
|||
|
||||
Models are blocks that let you specify Large Language Models (LLMs) and other deep learning models to be used for various roles in the open-source IDE extension like Chat, Autocomplete, Edit, Embed, Rerank, etc. You can explore available models on [the hub](https://hub.continue.dev/explore/models).
|
||||
|
||||
Continue supports [many model providers](../../customize/model-providers), including Anthropic, OpenAI, Gemini, Ollama, Amazon Bedrock, Azure, xAI, DeepSeek, and more. Models can have one or more of the following roles depending on its capabilities, including `chat`, `edit`, `apply`, `autocomplete`, `embed`, and `rerank`. Read more about roles [here](../../customize/model-roles). View [`models`](../../yaml-reference.md#models) in the YAML Reference for more details.
|
||||
Continue supports [many model providers](../../customize/model-providers), including Anthropic, OpenAI, Gemini, Ollama, Amazon Bedrock, Azure, xAI, DeepSeek, and more. Models can have one or more of the following roles depending on its capabilities, including `chat`, `edit`, `apply`, `autocomplete`, `embed`, and `rerank`. Read more about roles [here](../../customize/model-roles). View [`models`](../../reference.md#models) in the YAML Reference for more details.
|
||||
|
||||
## Context
|
||||
|
||||
Context blocks define a context provider which can be referenced in Chat with `@` to pull in data from external sources such as files and folders, a URL, Jira or Confluence, and Github issues, among others. [Explore context provider blocks](https://hub.continue.dev/explore/context) on the hub.
|
||||
|
||||
Learn more about context providers [here](../../yaml-reference.md#context), and check out [this guide](../../customize/tutorials/build-your-own-context-provider.mdx) to creating your own custom context provider. The `config.yaml` spec for context can be found [`here`](../../yaml-reference.md#context).
|
||||
Learn more about context providers [here](../../reference.md#context), and check out [this guide](../../customize/tutorials/build-your-own-context-provider.mdx) to creating your own custom context provider. The `config.yaml` spec for context can be found [`here`](../../reference.md#context).
|
||||
|
||||
## Docs
|
||||
|
||||
Docs are blocks that point to documentation sites, which will be indexed locally and then can be referenced as context using @Docs in Chat. [Explore docs](https://hub.continue.dev/explore/docs) on the hub.
|
||||
|
||||
Learn more in the [@Docs deep dive](../../customize/deep-dives/docs.mdx), and view [`docs`](../../yaml-reference.md#docs) in the YAML Reference for more details.
|
||||
Learn more in the [@Docs deep dive](../../customize/deep-dives/docs.mdx), and view [`docs`](../../reference.md#docs) in the YAML Reference for more details.
|
||||
|
||||
## MCP Servers
|
||||
|
||||
Model Context Protocol (MCP) is a standard way of building and sharing tools for language models. MCP Servers can be defined in `mcpServers` blocks. [Explore MCP Servers](https://hub.continue.dev/explore/mcp) on the hub.
|
||||
|
||||
Learn more in the [Tools deep dive](../../customize/tools.mdx), and view [`mcpServers`](../../yaml-reference.md#mcpservers) in the YAML Reference for more details.
|
||||
Learn more in the [MCP deep dive](../../customize/deep-dives/mcp.mdx), and view [`mcpServers`](../../reference.md#mcpservers) in the YAML Reference for more details.
|
||||
|
||||
## Rules
|
||||
|
||||
Rules blocks are instructions that your custom AI code assistant will always keep in mind - the contents of rules are inserted into the system message for all Chat requests. [Explore rules](https://hub.continue.dev/explore/rules) on the hub.
|
||||
|
||||
Learn more in the [rules deep dive](../../customize/deep-dives/rules.md), and view [`rules`](../../yaml-reference.md#rules) in the YAML Reference for more details.
|
||||
Learn more in the [rules deep dive](../../customize/deep-dives/rules.md), and view [`rules`](../../reference.md#rules) in the YAML Reference for more details.
|
||||
|
||||
## Prompts
|
||||
|
||||
|
|
@ -43,13 +43,13 @@ Prompts blocks are pre-written, reusable prompts that can be referenced at any t
|
|||
|
||||
Prompt blocks have the same syntax as [prompt files](../../customize/deep-dives/prompt-files.md). There are two important differences between prompt blocks and prompt files:
|
||||
|
||||
1. Prompt blocks are stored within `config.yaml` rather than `.continue/prompts` in project directory and
|
||||
2. Prompt blocks only show up as slash commands in Chat, not under the `@Prompt Files` context provider
|
||||
1. Currently, prompt blocks cannot use context providers
|
||||
2. Prompt blocks are stored within `config.yaml` rather than `.continue/prompts` in project directory and
|
||||
|
||||
The `config.yaml` spec for `prompts` can be found [here](../../yaml-reference.md#prompts).
|
||||
The `config.yaml` spec for `prompts` can be found [here](../../reference.md#prompts).
|
||||
|
||||
## Data
|
||||
|
||||
Data blocks allow you send your development data to custom destinations of your choice. Development data can be used for a variety of purposes, including analyzing usage, gathering insights, or fine-tuning models. You can read more about development data [here](../../customize/deep-dives/development-data.md). Explore data block examples [here](https://hub.continue.dev/explore/data).
|
||||
|
||||
Data destinations are configured in the[`data`](../../yaml-reference.md#data) section of `config.yaml`.
|
||||
Data destinations are configured in the [`data`](../../reference.md#data) section of `config.yaml`.
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ To create a block from scratch, you will need to click “New block” in the to
|
|||
|
||||

|
||||
|
||||
After filling out information on the block, you will want to create a block following the `config.yaml` [reference documentation](../../yaml-reference.md). Refer to examples of blocks on [hub.continue.dev](https://hub.continue.dev/explore/models) and visit the [YAML Reference](../../yaml-reference.md#complete-yaml-config-example) docs for more details.
|
||||
After filling out information on the block, you will want to create a block following the `config.yaml` [reference documentation](../../reference.md). Refer to examples of blocks on [hub.continue.dev](https://hub.continue.dev/explore/models) and visit the [YAML Reference](../../reference.md#complete-yaml-config-example) docs for more details.
|
||||
|
||||

|
||||
|
||||
### Block inputs
|
||||
|
||||
Blocks can receive values, including secrets, as inputs through templating. For values that the user of the block needs to set, you can use template variables (e.g. `${{ inputs.API_KEY}}`). Then, the user can set `API_KEY: ${{ secrets.MY_API_KEY }}` in the `with` clause of their assistant.
|
||||
Blocks can receive values, including secrets, as inputs through templating. For values that the user of the block needs to set, you can use template variables (e.g. `${{ inputs.API_KEY}}`). Then, the user can set `API_KEY: ${{ secrets.MY_API_KEY }}` in the `with` clause of their assistant.
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue