diff --git a/.github/actions/build-vscode-extension/action.yml b/.github/actions/build-vscode-extension/action.yml index fb17816f2..f9c17f31b 100644 --- a/.github/actions/build-vscode-extension/action.yml +++ b/.github/actions/build-vscode-extension/action.yml @@ -18,6 +18,9 @@ inputs: description: 'Commit SHA for version modification (optional, uses first 7 chars)' required: false default: '' + github-token: + description: 'GitHub token for downloading ripgrep' + required: true outputs: target: description: 'The target string used for the build' @@ -83,7 +86,7 @@ runs: npm ci env: # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333 - GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ inputs.github-token }} - name: Install gui dependencies shell: bash @@ -98,6 +101,12 @@ runs: npm ci npm i vectordb + - name: Build GUI + shell: bash + run: | + cd gui + npm run build + - name: Prepackage the extension shell: bash run: | diff --git a/.github/actions/run-jetbrains-tests/action.yml b/.github/actions/run-jetbrains-tests/action.yml index 71051101d..6c2d431ff 100644 --- a/.github/actions/run-jetbrains-tests/action.yml +++ b/.github/actions/run-jetbrains-tests/action.yml @@ -28,6 +28,13 @@ runs: cd core npm ci + - name: Install gui node_modules and build + shell: bash + run: | + cd gui + npm ci + npm run build + - name: Setup Java uses: actions/setup-java@v4.5.0 with: diff --git a/.github/workflows/auto-assign-issue.yaml b/.github/workflows/auto-assign-issue.yaml index 940f7cf54..1e62ae399 100644 --- a/.github/workflows/auto-assign-issue.yaml +++ b/.github/workflows/auto-assign-issue.yaml @@ -14,7 +14,7 @@ jobs: uses: pozil/auto-assign-issue@v2 with: repo-token: ${{ secrets.CI_GITHUB_TOKEN }} - assignees: sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa + assignees: Patrick-Erichsen,tomasz-stefaniak,RomneyDa,tingwai numOfAssignee: 1 # - name: "Add default labels" # uses: actions-ecosystem/action-add-labels@v1 diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2024b083b..739553f7b 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -80,8 +80,7 @@ jobs: arch: ${{ matrix.arch }} npm_config_arch: ${{ matrix.npm_config_arch }} pre-release: false - env: - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Upload .vsix artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/pr-build-upload-vsix.yaml b/.github/workflows/pr-build-upload-vsix.yaml index 17a3dc5ba..6a8250a83 100644 --- a/.github/workflows/pr-build-upload-vsix.yaml +++ b/.github/workflows/pr-build-upload-vsix.yaml @@ -36,8 +36,7 @@ jobs: npm_config_arch: ${{ matrix.arch }} pre-release: false commit-sha: ${{ github.sha }} - env: - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Upload build artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index 9ea007d5f..63afde345 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -269,8 +269,7 @@ jobs: npm_config_arch: x64 pre-release: false commit-sha: ${{ github.sha }} - env: - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Upload build artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 611a96f5e..434588f96 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -80,8 +80,7 @@ jobs: arch: ${{ matrix.arch }} npm_config_arch: ${{ matrix.npm_config_arch }} pre-release: true - env: - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Upload .vsix artifact uses: actions/upload-artifact@v4 diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 4b8646f07..a08ec41ef 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -12,24 +12,18 @@ "isDefault": true }, "presentation": { - "reveal": "always", - "panel": "new" + "group": "dev-watchers", + "panel": "dedicated", + "reveal": "always" } }, - // Compile and bundle the extension { "label": "vscode-extension:build", "dependsOn": [ - // TSC type checking "tsc:watch", - // To build the React app that is used in the extension "vscode-extension:continue-ui:build", - // // To bundle the code the same way we do for publishing "vscode-extension:esbuild", - // To ensure extension.js is regenerated even if - // vscode-extension:esbuild was already running in background "vscode-extension:esbuild-notify", - // Start the React app that is used in the extension "gui:dev" ], "group": { @@ -42,7 +36,15 @@ "dependsOn": ["vscode-extension:esbuild"], "type": "npm", "script": "esbuild-notify", - "path": "extensions/vscode" + "path": "extensions/vscode", + "presentation": { + "group": "build-tasks", + "panel": "shared", + "reveal": "silent", + "revealProblems": "onProblem", + "close": true, + "clear": true + } }, { "label": "vscode-extension:esbuild", @@ -51,6 +53,11 @@ "script": "esbuild-watch", "path": "extensions/vscode", "isBackground": true, + "presentation": { + "group": "dev-watchers", + "panel": "dedicated", + "reveal": "silent" + }, "problemMatcher": [ { "pattern": [ @@ -77,6 +84,11 @@ "type": "npm", "script": "package", "path": "extensions/vscode", + "presentation": { + "group": "build-tasks", + "panel": "shared", + "reveal": "always" + }, "problemMatcher": [ { "pattern": [ @@ -99,7 +111,11 @@ "args": ["${workspaceFolder}/extensions/vscode/scripts/prepackage.js"], "problemMatcher": ["$tsc"], "presentation": { + "group": "build-tasks", + "panel": "shared", + "reveal": "silent", "revealProblems": "onProblem", + "close": true, "clear": true }, "options": { @@ -109,16 +125,18 @@ "cwd": "${workspaceFolder}/extensions/vscode" } }, - // Install or update all dependencies for all projects in the monrepo { "label": "install-all-dependencies", "type": "shell", "windows": { "command": "./scripts/install-dependencies.ps1" }, "command": "./scripts/install-dependencies.sh", - "problemMatcher": [] // Empty so users are not prompted to select progress reporting + "problemMatcher": [], + "presentation": { + "group": "maintenance", + "panel": "shared", + "reveal": "always" + } }, - // - // Start the React App for debugging with Vite { "label": "gui:dev", "type": "shell", @@ -128,6 +146,16 @@ }, "args": ["run", "dev"], "isBackground": true, + "runOptions": { + "instanceLimit": 1 + }, + "presentation": { + "group": "dev-watchers", + "panel": "dedicated", + "reveal": "always", + "focus": false, + "showReuseMessage": false + }, "problemMatcher": [ { "pattern": [ @@ -146,14 +174,17 @@ } ] }, - // - // esbuild for the core binary { "label": "binary:esbuild", "type": "shell", "command": "npm", "args": ["run", "esbuild"], "problemMatcher": [], + "presentation": { + "group": "build-tasks", + "panel": "shared", + "reveal": "always" + }, "options": { "cwd": "binary" } @@ -164,6 +195,11 @@ "command": "npm", "args": ["run", "start", "--", "--no-open"], "problemMatcher": [], + "presentation": { + "group": "docs", + "panel": "dedicated", + "reveal": "always" + }, "options": { "cwd": "docs" } @@ -173,7 +209,12 @@ "type": "shell", "command": "node", "args": ["${workspaceFolder}/scripts/uninstall.js"], - "problemMatcher": [] + "problemMatcher": [], + "presentation": { + "group": "maintenance", + "panel": "shared", + "reveal": "always" + } }, { "label": "refresh-dependencies:core", @@ -185,6 +226,9 @@ "cwd": "${workspaceFolder}/core" }, "presentation": { + "group": "maintenance", + "panel": "shared", + "reveal": "silent", "close": true } }, @@ -198,6 +242,9 @@ "cwd": "${workspaceFolder}/extensions/vscode" }, "presentation": { + "group": "maintenance", + "panel": "shared", + "reveal": "silent", "close": true } }, @@ -211,6 +258,9 @@ "cwd": "${workspaceFolder}/gui" }, "presentation": { + "group": "maintenance", + "panel": "shared", + "reveal": "silent", "close": true } }, @@ -222,35 +272,45 @@ "refresh-dependencies:vscode" ], "type": "shell", - "problemMatcher": [] + "problemMatcher": [], + "presentation": { + "group": "maintenance", + "panel": "shared", + "reveal": "always" + } }, { - "label": "Build Continue packages", + "label": "continue-packages:build", "type": "shell", "command": "node ./scripts/build-packages.js", - "isBackground": true, - "problemMatcher": { - "pattern": { - "regexp": "__DUMMY_PATTERN_THAT_NEVER_MATCHES__", - "file": 1 - }, - "background": { - "activeOnStart": true, - "beginsPattern": ".", - "endsPattern": "." - } - }, + "problemMatcher": [], "presentation": { - "reveal": "silent", - "panel": "shared" + "group": "build-tasks", + "panel": "shared", + "reveal": "always", + "close": true, + "revealProblems": "onProblem" } }, { "label": "vscode-extension:build-with-packages", - // "dependsOn": ["vscode-extension:build"], - "dependsOn": ["Build Continue packages", "vscode-extension:build"], + "dependsOn": ["continue-packages:build", "vscode-extension:build"], "type": "shell", - "problemMatcher": [] + "command": "echo", + "args": ["Build with packages completed"], + "problemMatcher": [], + "dependsOrder": "sequence", + "runOptions": { + "instanceLimit": 1, + "reevaluateOnRerun": true + }, + "presentation": { + "group": "build-tasks", + "panel": "shared", + "reveal": "silent", + "close": true, + "focus": false + } } ] } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9824071c1..fe0165951 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,19 +20,19 @@ - [Debugging](#debugging) - [JetBrains](#jetbrains) - [Our Git Workflow](#our-git-workflow) - - [Development workflow](#development-workflow) + - [Development Workflow](#development-workflow) - [Formatting](#formatting) - [Theme Colors](#theme-colors) - [Testing](#testing) - [Review Process](#review-process) - - [Getting help](#getting-help) - - [Contribtuing new LLM Providers/Models](#contribtuing-new-llm-providersmodels) + - [Getting Help](#getting-help) + - [Contributing new LLM Providers/Models](#contributing-new-llm-providersmodels) - [Adding an LLM Provider](#adding-an-llm-provider) - [Adding Models](#adding-models) - [📐 Continue Architecture](#-continue-architecture) - [Continue VS Code Extension](#continue-vs-code-extension) - [Continue JetBrains Extension](#continue-jetbrains-extension) - - [Contibutor License Agreement](#contributor-license-agreement-cla) + - [Contributor License Agreement](#contributor-license-agreement-cla) # ❤️ Ways to Contribute @@ -212,17 +212,17 @@ Guidelines for using theme colors: Guidelines for adding/updating theme colors: - Choose sensible VS Code variables to add/update in [gui/src/styles/theme.ts](gui/src/styles/theme.ts) (see [here](https://code.visualstudio.com/api/references/theme-color) and [here](https://www.notion.so/1fa1d55165f78097b551e3bc296fcf76?pvs=25) for inspiration) -- Choose sensible Jetbrains named colors to add/update in `GetTheme.kt` (flagship LLMs can give you good suggestions to try) +- Choose sensible JetBrains named colors to add/update in `GetTheme.kt` (flagship LLMs can give you good suggestions to try) - Update `tailwind.config.js` if needed - Use the Theme Test Page to check colors. This can be accessed by going to `Settings` -> `Help` -> `Theme Test Page` in dev/debug mode. ### Testing We have a mix of unit, functional, and e2e test suites, with a primary focus on functional testing. These tests run on -each pull request. If your PR causes one of these tests to fail, we will ask that you to resolve the issue before we +each pull request. If your PR causes one of these tests to fail, we will ask you to resolve the issue before we merge. -When contributing, please update or create the appropriate tests to help verify the correctness of your implementaiton. +When contributing, please update or create the appropriate tests to help verify the correctness of your implementation. ### Review Process @@ -231,11 +231,11 @@ When contributing, please update or create the appropriate tests to help verify maintainable and follows our patterns. - **Approval & Merge** - Once the PR is approved, it will be merged into the `main` branch. -### Getting help +### Getting Help Join [#contribute on Discord](https://discord.gg/vapESyrFmJ) to engage with maintainers and other contributors. -## Contribtuing new LLM Providers/Models +## Contributing New LLM Providers/Models ### Adding an LLM Provider diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index b50fb638d..1ba43cfda 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -348,8 +348,8 @@ export class ConfigHandler { // External actions that can cause a cascading config refresh // Should not be used internally ////////////////// - async refreshAll() { - await this.cascadeInit("External refresh all"); + async refreshAll(reason?: string) { + await this.cascadeInit(reason ?? "External refresh all"); } // Ide settings change: refresh session and cascade refresh from the top diff --git a/core/config/yaml/LocalPlatformClient.ts b/core/config/yaml/LocalPlatformClient.ts index a728114c5..fe682396f 100644 --- a/core/config/yaml/LocalPlatformClient.ts +++ b/core/config/yaml/LocalPlatformClient.ts @@ -99,12 +99,32 @@ export class LocalPlatformClient implements PlatformClient { const results = await this.client.resolveFQSNs(fqsns, this.orgScopeId); - // For any secret that isn't found, look in .env files + // For any secret that isn't found, look in .env files, then process.env for (let i = 0; i < results.length; i++) { if (!results[i]?.found) { - const secretFromEnv = await this.findSecretInEnvFiles(fqsns[i]); - if (secretFromEnv?.found) { - results[i] = secretFromEnv; + let secretResult = await this.findSecretInEnvFiles(fqsns[i]); + + // If not found in .env files, try process.env + if (!secretResult?.found) { + const secretValueFromProcessEnv = process.env[fqsns[i].secretName]; + if (secretValueFromProcessEnv !== undefined) { + secretResult = { + found: true, + fqsn: fqsns[i], + value: secretValueFromProcessEnv, + secretLocation: { + secretName: fqsns[i].secretName, + // Cast to SecretType.ProcessEnv is necessary because the specific type + // ProcessEnvSecretLocation expects secretType to be exactly SecretType.ProcessEnv, + // not the general enum SecretType. + secretType: SecretType.ProcessEnv as SecretType.ProcessEnv, + }, + }; + } + } + + if (secretResult?.found) { + results[i] = secretResult; } } } diff --git a/core/config/yaml/LocalPlatformClient.vitest.ts b/core/config/yaml/LocalPlatformClient.vitest.ts index 1006cfea4..c4d9515fd 100644 --- a/core/config/yaml/LocalPlatformClient.vitest.ts +++ b/core/config/yaml/LocalPlatformClient.vitest.ts @@ -229,4 +229,185 @@ describe("LocalPlatformClient", () => { ).not.toContain(randomValueForWorkspaceDotEnv); }); }); + + describe("should be able to get secrets from process.env", () => { + const ogProcessEnv = { ...process.env }; + + beforeEach(async () => { + // Ensure secrets are not found in ControlPlane initially for these tests + const mockResolveFQSNsNotFound = async ( + fqsns: FQSN[], + ): Promise<(SecretResult | undefined)[]> => + fqsns.map((fqsn) => ({ + found: false, + fqsn, + secretLocation: { + secretName: fqsn.secretName, + secretType: SecretType.NotFound as SecretType.NotFound, + }, + })); + testControlPlaneClient.resolveFQSNs = vi.fn(mockResolveFQSNsNotFound); + + // Ensure secrets are not found in local .env files + const utilPaths = await import("../../util/paths"); + utilPaths.getContinueDotEnv = vi.fn(() => ({})); + + // Ensure secrets are not found in workspace .env files + testIde.fileExists = vi.fn(async () => false); + testIde.readFile = vi.fn(async () => ""); + + // Clear any potentially set process.env variables from previous tests in this block + delete process.env[testFQSN.secretName]; + delete process.env[testFQSN2.secretName]; + }); + + afterEach(() => { + // Restore original process.env + process.env = { ...ogProcessEnv }; + }); + + test("should resolve secret from process.env if not found elsewhere", async () => { + const processEnvSecretValue = "secret-from-process-env"; + process.env[testFQSN.secretName] = processEnvSecretValue; + + const localPlatformClient = new LocalPlatformClient( + null, + testControlPlaneClient, + testIde, + ); + const resolvedFQSNs = await localPlatformClient.resolveFQSNs([testFQSN]); + + expect(resolvedFQSNs.length).toBe(1); + const result = resolvedFQSNs[0]; + expect(result?.found).toBe(true); + expect((result as SecretResult & { value: unknown })?.value).toBe( + processEnvSecretValue, + ); + expect(result?.secretLocation?.secretType).toBe(SecretType.ProcessEnv); + // Check if the specific ProcessEnvSecretLocation is correctly formed + expect(result?.secretLocation).toEqual( + expect.objectContaining({ + secretName: testFQSN.secretName, + secretType: SecretType.ProcessEnv, + }), + ); + }); + + test("should return not found if secret is not in process.env or other locations", async () => { + // Ensure it's not in process.env + expect(process.env[testFQSN.secretName]).toBeUndefined(); + + const localPlatformClient = new LocalPlatformClient( + null, + testControlPlaneClient, + testIde, + ); + const resolvedFQSNs = await localPlatformClient.resolveFQSNs([testFQSN]); + + expect(resolvedFQSNs.length).toBe(1); + expect(resolvedFQSNs[0]?.found).toBe(false); + expect(resolvedFQSNs[0]?.secretLocation?.secretType).toBe( + SecretType.NotFound, + ); + }); + + test("should prioritize ControlPlane over process.env", async () => { + const controlPlaneValue = "secret-from-control-plane"; + + const mockResolveFQSNsControlPlaneFound = async (): Promise< + (SecretResult | undefined)[] + > => [ + { + found: true, + fqsn: testFQSN, + value: controlPlaneValue, + secretLocation: { + secretType: SecretType.Organization as SecretType.Organization, + orgSlug: (testResolvedFQSN.secretLocation as any).orgSlug, + secretName: testFQSN.secretName, + }, + }, + ]; + testControlPlaneClient.resolveFQSNs = vi.fn( + mockResolveFQSNsControlPlaneFound, + ); + + process.env[testFQSN.secretName] = + "secret-from-process-env-should-be-ignored"; + + const localPlatformClient = new LocalPlatformClient( + null, + testControlPlaneClient, + testIde, + ); + const resolvedFQSNs = await localPlatformClient.resolveFQSNs([testFQSN]); + + expect(resolvedFQSNs.length).toBe(1); + const result = resolvedFQSNs[0]; + expect(result?.found).toBe(true); + expect((result as SecretResult & { value: unknown })?.value).toBe( + controlPlaneValue, + ); + expect(result?.secretLocation?.secretType).toBe(SecretType.Organization); + }); + + test("should prioritize local ~/.continue/.env file over process.env", async () => { + const localEnvFileValue = "secret-from-local-dot-continue-env"; + const utilPaths = await import("../../util/paths"); + utilPaths.getContinueDotEnv = vi.fn(() => ({ + [testFQSN.secretName]: localEnvFileValue, + })); + + process.env[testFQSN.secretName] = + "secret-from-process-env-should-be-ignored"; + + const localPlatformClient = new LocalPlatformClient( + null, + testControlPlaneClient, + testIde, + ); + const resolvedFQSNs = await localPlatformClient.resolveFQSNs([testFQSN]); + + expect(resolvedFQSNs.length).toBe(1); + const result = resolvedFQSNs[0]; + expect(result?.found).toBe(true); + expect((result as SecretResult & { value: unknown })?.value).toBe( + localEnvFileValue, + ); + expect(result?.secretLocation?.secretType).toBe(SecretType.LocalEnv); + }); + + test("should prioritize workspace .env files over process.env", async () => { + const workspaceContinueEnvValue = "secret-from-workspace-continue-env"; + testIde.fileExists = vi.fn(async (fileUri: string) => + // Only mock existence for /.continue/.env + fileUri.includes(".continue/.env"), + ); + testIde.readFile = vi.fn(async (fileUri: string) => { + if (fileUri.includes(".continue/.env")) { + return `${testFQSN.secretName}=${workspaceContinueEnvValue}`; + } + return ""; + }); + + process.env[testFQSN.secretName] = + "secret-from-process-env-should-be-ignored"; + + const localPlatformClient = new LocalPlatformClient( + null, + testControlPlaneClient, + testIde, + ); + const resolvedFQSNs = await localPlatformClient.resolveFQSNs([testFQSN]); + + expect(resolvedFQSNs.length).toBe(1); + const result = resolvedFQSNs[0]; + expect(result?.found).toBe(true); + expect((result as SecretResult & { value: unknown })?.value).toBe( + workspaceContinueEnvValue, + ); + // This should be LocalEnv because findSecretInEnvFiles returns LocalEnv for workspace files too + expect(result?.secretLocation?.secretType).toBe(SecretType.LocalEnv); + }); + }); }); diff --git a/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts b/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts index ad966f89a..fa49bee2e 100644 --- a/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts +++ b/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts @@ -119,11 +119,11 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline { results.sort( (a, b) => scores[chunkIndexMap.get(b)!] - scores[chunkIndexMap.get(a)!], ); - results = results.slice(-this.options.nFinal); + results = results.slice(0, this.options.nFinal); return results; } catch (e) { console.warn(`Failed to rerank retrieval results\n${e}`); - return chunks.slice(-this.options.nFinal); + return chunks.slice(0, this.options.nFinal); } } diff --git a/core/core.ts b/core/core.ts index 7d09ec8fb..f961461ad 100644 --- a/core/core.ts +++ b/core/core.ts @@ -337,22 +337,17 @@ export class Core { ); }); - on("config/reload", async (msg) => { - // User force reloading will retrigger colocated rules - const codebaseRulesCache = CodebaseRulesCache.getInstance(); - await codebaseRulesCache.refresh(this.ide); - void this.configHandler.reloadConfig( - "Force reloaded (config/reload message)", - ); - }); - on("config/ideSettingsUpdate", async (msg) => { await this.configHandler.updateIdeSettings(msg.data); }); on("config/refreshProfiles", async (msg) => { - const { selectOrgId, selectProfileId } = msg.data ?? {}; - await this.configHandler.refreshAll(); + // User force reloading will retrigger colocated rules + const codebaseRulesCache = CodebaseRulesCache.getInstance(); + await codebaseRulesCache.refresh(this.ide); + + const { selectOrgId, selectProfileId, reason } = msg.data ?? {}; + await this.configHandler.refreshAll(reason); if (selectOrgId) { await this.configHandler.setSelectedOrgId(selectOrgId, selectProfileId); } else if (selectProfileId) { @@ -724,7 +719,7 @@ export class Core { } } if (localAssistantCreated) { - await this.configHandler.refreshAll(); + await this.configHandler.refreshAll("Local assistant file created"); } } }); diff --git a/core/llm/llms/TransformersJsWorkerThread.js b/core/llm/llms/TransformersJsWorkerThread.js deleted file mode 100644 index 6ea26172e..000000000 --- a/core/llm/llms/TransformersJsWorkerThread.js +++ /dev/null @@ -1,64 +0,0 @@ -import path from "node:path"; -import { parentPort } from "node:worker_threads"; - -import { - env, - pipeline, -} from "../../vendor/node_modules/@xenova/transformers/types/transformers"; - -import TransformersJsEmbeddingsProvider from "./TransformersJsEmbeddingsProvider"; - -env.allowLocalModels = true; -env.allowRemoteModels = false; -if (typeof window === "undefined") { - // The embeddings provider should just never be called in the browser - env.localModelPath = path.join(__dirname, "..", "models"); -} - -class EmbeddingsPipeline { - static task = "feature-extraction"; - static model = TransformersJsEmbeddingsProvider.ModelName; - static instance = null; - - static async getInstance() { - if (EmbeddingsPipeline.instance === null) { - EmbeddingsPipeline.instance = await pipeline( - EmbeddingsPipeline.task, - EmbeddingsPipeline.model, - ); - } - - return EmbeddingsPipeline.instance; - } -} - -parentPort.on("message", async (chunks) => { - try { - const extractor = await EmbeddingsPipeline.getInstance(); - - if (!extractor) { - throw new Error("TransformerJS embeddings pipeline is not initialized"); - } - - const outputs = []; - for ( - let i = 0; - i < chunks.length; - i += TransformersJsEmbeddingsProvider.maxGroupSize - ) { - const chunkGroup = chunks.slice( - i, - i + TransformersJsEmbeddingsProvider.maxGroupSize, - ); - const output = await extractor(chunkGroup, { - pooling: "mean", - normalize: true, - }); - outputs.push(...output.tolist()); - } - - parentPort.postMessage(outputs); - } catch (error) { - parentPort.postMessage({ error: error.message }); - } -}); diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 1a6e4dc20..85bca7242 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -94,11 +94,11 @@ export type ToCoreFromIdeOrWebviewProtocol = { }, ]; "config/deleteModel": [{ title: string }, void]; - "config/reload": [undefined, void]; "config/refreshProfiles": [ ( | undefined | { + reason?: string; selectOrgId?: string; selectProfileId?: string; } diff --git a/docs/customize/deep-dives/configuration.mdx b/docs/customize/deep-dives/configuration.mdx index 0668d9411..c3aa770b9 100644 --- a/docs/customize/deep-dives/configuration.mdx +++ b/docs/customize/deep-dives/configuration.mdx @@ -1,6 +1,6 @@ --- title: "Configuration" -description: Configuration +description: Learn how to access and manage Continue assistant configurations through Hub or local YAML files keywords: [config, settings, customize] --- @@ -82,4 +82,4 @@ export function modifyConfig(config: Config): Config { }); return config; } -``` +``` \ No newline at end of file diff --git a/docs/customize/deep-dives/mcp.mdx b/docs/customize/deep-dives/mcp.mdx index dcbff566e..6156b1f63 100644 --- a/docs/customize/deep-dives/mcp.mdx +++ b/docs/customize/deep-dives/mcp.mdx @@ -104,17 +104,17 @@ server block to your [config file](./configuration.md): MCP blocks follow the established syntax for blocks, with a few additional properties specific to MCP servers. -- `name` (**required**): A display name for the MCP server. -- `command` (**required**): The command to run to start the MCP server. -- `type` (optional): The type of the MCP server: `sse`, `stdio`, `streamable-http` -- `args` (optional): Arguments to pass to the command. -- `env` (optional): Secrets to be injected into the command as environment variables. +- `name`: A display name for the MCP server. +- `type`: The type of the MCP server: `sse`, `stdio`, `streamable-http` +- `command`: The command to run to start the MCP server. +- `args`: Arguments to pass to the command. +- `env`: Secrets to be injected into the command as environment variables. ### Transport Types MCP now supports remote server connections through HTTP-based transports, expanding beyond the traditional local stdio transport method. This enables integration with cloud-hosted MCP servers and distributed architectures. -#### Server-Sent Events (SSE) Transport +#### Server-Sent Events Transport (`sse`) For real-time streaming communication, use the SSE transport: @@ -125,7 +125,7 @@ mcpServers: url: https://.... ``` -#### Standard Input/Output (stdio) +#### Standard Input/Output (`stdio`) For local MCP servers that communicate via standard input and output: @@ -139,7 +139,7 @@ mcpServers: - "/path/to/your/database.db" ``` -#### Streamable HTTP Transport +#### Streamable HTTP Transport (`streamable-http`) For standard HTTP-based communication with streaming capabilities: diff --git a/docs/docs.json b/docs/docs.json index 6613e3074..9fcd181c9 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -239,6 +239,7 @@ "group": "Guides", "pages": [ "guides/overview", + "guides/understanding-assistants", "guides/cli", "guides/plan-mode-guide", "guides/ollama-guide", diff --git a/docs/getting-started/extensions.mdx b/docs/getting-started/extensions.mdx new file mode 100644 index 000000000..995ac79a5 --- /dev/null +++ b/docs/getting-started/extensions.mdx @@ -0,0 +1,6 @@ +--- +title: "Understanding Assistants" +description: "Continue offers two ways to configure your AI assistants" +--- + +This content has moved to our comprehensive guide: [Understanding Assistants: Hub vs Local Configuration](/guides/understanding-assistants) \ No newline at end of file diff --git a/docs/getting-started/overview.mdx b/docs/getting-started/overview.mdx index f1ed345ec..a24d5585f 100644 --- a/docs/getting-started/overview.mdx +++ b/docs/getting-started/overview.mdx @@ -3,6 +3,8 @@ title: "Overview" description: "To quickly understand what you can do with Continue, check out each tab below." --- +## Features + [Agent](/features/agent/quick-start) equips the Chat model with the tools needed to handle a wide range of coding tasks @@ -54,3 +56,8 @@ description: "To quickly understand what you can do with Continue, check out eac + + +## AI Coding Assistants + +Continue offers flexible AI assistants that enhance your development workflow. You can choose between cloud-managed **Hub Assistants** for easy setup and synchronization, or **Local Assistants** for complete control and privacy. Learn more about [understanding and configuring assistants](/guides/understanding-assistants). diff --git a/docs/guides/ollama-guide.mdx b/docs/guides/ollama-guide.mdx index 768160137..5ded49934 100644 --- a/docs/guides/ollama-guide.mdx +++ b/docs/guides/ollama-guide.mdx @@ -35,9 +35,9 @@ After installing Ollama, download the models you want to use. Here are some popu ``` # Popular models for development -ollama pull llama2 -ollama pull codellama ollama pull mistral +ollama pull qwen2.5-coder:1.5b-base +ollama pull nomic-embed-text:latest ``` ## Configuration @@ -46,19 +46,32 @@ Configure Continue to work with your local Ollama instance: ### Continue Configuration -```json -{ - "models": [ - { - "title": "Ollama", - "provider": "ollama", - "model": "llama2", - "apiBase": "http://localhost:11434" - } - ] -} +```yaml +models: + - name: mistral + provider: ollama + apiBase: http://localhost:11434 + model: mistral + roles: + - chat + - edit + - apply + - name: Qwen2.5-Coder 1.5B + provider: ollama + apiBase: http://localhost:11434 + model: qwen2.5-coder:1.5b-base + roles: + - autocomplete + - name: Nomic Embed + provider: ollama + apiBase: http://localhost:11434 + model: nomic-embed-text:latest + roles: + - embed ``` +You can update `apiBase` with the IP address of a remote machine serving Ollama. + ### Advanced Settings For optimal performance, consider these advanced configuration options: diff --git a/docs/guides/understanding-assistants.mdx b/docs/guides/understanding-assistants.mdx new file mode 100644 index 000000000..7dfad68e9 --- /dev/null +++ b/docs/guides/understanding-assistants.mdx @@ -0,0 +1,186 @@ +--- +title: "Understanding Assistants: Hub vs Local Configuration" +description: "Master the two approaches to configuring AI assistants in Continue - choosing the right path for your development workflow" +--- + +Every developer has unique needs when it comes to AI assistance. Some prefer the convenience of cloud-managed configurations, while others need the control and privacy of local setups. Continue offers both paths, and this guide will help you choose the right one for your workflow. + +## The Two Paths to AI Assistance + +Think of Continue's configuration options like choosing between a managed service and self-hosting. Both get you to the same destination—powerful AI assistance in your IDE—but the journey and control level differ significantly. + +### Accessing Your Assistant Configuration + +Before we dive into the specifics, let's understand how to access your configuration: + +1. Open the Continue Chat sidebar by pressing cmd/ctrl + L (VS Code) or cmd/ctrl + J (JetBrains) +2. Click the Assistant selector above the main chat input +3. Hover over an assistant and click: + - `new window` icon for Hub assistants + - `gear` icon for Local assistants + +![configure an assistant](/images/configure-continue.png) + +## Hub Assistants: The Managed Experience + +Hub Assistants represent the "it just works" philosophy. When you [sign in to Continue Hub](https://auth.continue.dev/), you gain access to a curated ecosystem of pre-configured assistants that sync seamlessly across all your development environments. + +### Why Choose Hub Assistants? + +**The Power of Simplicity** +- **Instant Setup**: Browse the [assistant marketplace](https://hub.continue.dev/explore/assistants) and add any assistant to your account with a single click +- **Web-Based Management**: Configure models, add secrets, and customize settings through an intuitive web interface—no JSON editing required +- **Automatic Synchronization**: Make a change on the hub, and it reflects immediately across all your IDE instances +- **Team Collaboration**: Share custom assistants with your team, ensuring everyone uses the same optimized configurations + +![nextjs assistant](/images/nextjs-assistant.png) + +### Getting Started with Hub Assistants + +The journey from zero to AI-powered coding takes just four steps: + +1. **Select Your Assistant**: Click the assistant selector in your IDE's Continue panel +2. **Explore or Create**: Browse community assistants or craft your own specialized helper +3. **Secure Your Keys**: Add API keys as [User Secrets](https://hub.continue.dev/settings/secrets) in the hub—they're encrypted and never exposed +4. **Sync and Code**: Click "Reload config" to pull your latest settings + +Pro tip: Hub Assistants are perfect for teams. Create a custom assistant with your team's coding standards, preferred models, and context sources, then share it with a simple link. + +### Managing Hub Assistants + +All Hub Assistant management happens through [the Hub](https://hub.continue.dev). For detailed customization, see our guide on [Editing an Assistant](/hub/assistants/edit-an-assistant). + +## Local Assistants: The Power User's Choice + +Local Assistants put you in the driver's seat. Using a `config.yaml` file, you have complete control over every aspect of your AI assistant's behavior, with all configuration stored directly on your machine. + +### Why Choose Local Assistants? + +**Complete Control and Privacy** +- **Your Data, Your Rules**: All configuration stays on your machine—perfect for air-gapped environments or strict data policies +- **Version Control Integration**: Check your `config.yaml` into git alongside your code, ensuring reproducible environments +- **Offline Capability**: Once configured, no internet connection needed (assuming you're using local models) +- **Unlimited Customization**: Access every configuration option, experimental feature, and advanced setting + +### Setting Up Local Assistants + +Local configuration lives in a single YAML file in your home directory: + +**File Locations:** +- macOS/Linux: `~/.continue/config.yaml` +- Windows: `%USERPROFILE%\.continue\config.yaml` + +**Quick Access Method:** +1. Open the assistants dropdown in your IDE +2. Click the gear icon next to "Local Assistant" +3. The `config.yaml` file opens in your editor + +![local-config-open-steps](/images/local-config-open-steps.png) + +### The Local Assistant Experience + +When you edit your `config.yaml`, Continue provides intelligent autocomplete for all available options. Save the file, and Continue automatically reloads your configuration—no restart required. + +The first time you use Continue, it generates a `config.yaml` with sensible defaults. From there, you can customize everything from model selection to context providers, slash commands, and more. + +For the complete configuration reference, see our [config.yaml documentation](/reference). + +## Making the Right Choice + +The decision between Hub and Local assistants often comes down to your specific needs and constraints. Here's a framework to help you decide: + +### Choose Hub Assistants When You: + +**Value Convenience Over Control** +- Want to start coding with AI assistance in under 60 seconds +- Prefer visual interfaces over editing configuration files +- Need to switch between multiple machines frequently +- Work in a team that needs standardized AI assistance + +**Need Advanced Collaboration** +- Want to share custom assistants with teammates +- Need centralized API key management +- Require quick updates across your entire organization + +**Are Getting Started** +- New to AI-powered development +- Want to experiment with different models and configurations +- Prefer guided setup experiences + +### Choose Local Assistants When You: + +**Require Maximum Control** +- Need to version control your exact configuration +- Want to customize every aspect of the AI behavior +- Require reproducible development environments + +**Have Privacy Requirements** +- Work with sensitive code that requires air-gapped environments +- Need to ensure all configuration data stays local +- Have strict compliance requirements about data storage + +**Are a Power User** +- Comfortable editing YAML/JSON files +- Want access to experimental features +- Need to integrate with local tools and scripts + +## The Hybrid Approach + +Here's a secret: you don't have to choose just one. Many developers use both approaches: + +- **Hub Assistants** for general development and experimentation +- **Local Assistants** for production work or client projects with specific requirements + +You can switch between them seamlessly using the assistant selector in your IDE. + +## Common Patterns and Best Practices + +### For Hub Assistant Users + +1. **Start with Community Assistants**: Before creating your own, explore what others have built +2. **Use Secrets Properly**: Never hardcode API keys—always use the User Secrets feature +3. **Create Specialized Assistants**: Make different assistants for different contexts (frontend, backend, DevOps) +4. **Share Liberally**: If you create something useful, share it with the community + +### For Local Assistant Users + +1. **Version Control Your Config**: Treat your `config.yaml` like code—commit it, review changes, and maintain history +2. **Use Environment Variables**: For sensitive data, reference environment variables instead of hardcoding values +3. **Document Your Setup**: Add comments to your config explaining non-obvious choices +4. **Keep a Backup**: Before major changes, save a working copy of your configuration + +## Troubleshooting and Tips + +### Hub Assistant Issues + +**Changes Not Reflecting?** +- Click "Reload config" in your IDE +- Check your internet connection +- Ensure you're signed in to the correct account + +**Assistant Not Available?** +- Verify it's added to your account on the hub +- Check if it requires specific API keys + +### Local Assistant Issues + +**Config Not Loading?** +- Verify file location matches your OS +- Check YAML syntax (Continue will show errors) +- Ensure file permissions allow reading + +**Autocomplete Not Working?** +- Update to the latest Continue version +- Check that you're editing the correct file + +## Next Steps + +Now that you understand both configuration approaches, you're ready to dive deeper: + +- **For Hub Users**: [Create Your First Assistant](/hub/assistants/create-an-assistant) +- **For Local Users**: [Explore the Config Reference](/reference) +- **For Everyone**: [Discover Available Models](/customize/model-providers/overview) + +Remember, the best configuration is the one that helps you code more effectively. Start simple, experiment freely, and gradually refine your setup as you discover what works best for your workflow. + +Happy coding with Continue! 🚀 \ No newline at end of file diff --git a/docs/hub/source-control.mdx b/docs/hub/source-control.mdx index 2920044e2..5e863336b 100644 --- a/docs/hub/source-control.mdx +++ b/docs/hub/source-control.mdx @@ -34,11 +34,11 @@ This is the only configuration necessary, but you can view the full list of opti ### 4. Commit and push -Add the [YAML for your assistants and blocks](/reference) to the appropriate directories: +Add the [YAML for your assistants and blocks](/reference) to the appropriate directories. The name of the file will be the slug of the assistant/block. - `assistants/public` for public assistants - `assistants/private` for private (visible only within your organization) assistants - `blocks/public` for public blocks - `blocks/private` for private blocks -Then, commit and push your changes. Once the GitHub Action has completed running, you should be able to view the assistants within your organization on hub.continue.dev. +Then, commit and push your changes. Once the GitHub Action has completed running, you should be able to view the assistants within your organization on hub.continue.dev. For subsequent changes, make sure to increment the `version` property of your updated YAML file(s). diff --git a/docs/images/nextjs-assistant.png b/docs/images/nextjs-assistant.png new file mode 100644 index 000000000..a20db5bdd Binary files /dev/null and b/docs/images/nextjs-assistant.png differ diff --git a/docs/package-lock.json b/docs/package-lock.json index e5bf20a17..c2baedd69 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -2801,14 +2801,14 @@ } }, "node_modules/axios": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.10.0.tgz", - "integrity": "sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.11.0.tgz", + "integrity": "sha512-1Lx3WLFQWm3ooKDYZD1eXmoGO9fxYQjrycfHFC8P0sCfQVXyROp0p9PFWBehewBOdCwHc+f/b8I0fMto5eSfwA==", "dev": true, "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", + "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, @@ -4948,9 +4948,9 @@ } }, "node_modules/form-data": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.3.tgz", - "integrity": "sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", "dev": true, "license": "MIT", "dependencies": { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/AsyncFileSaveListener.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/AsyncFileSaveListener.kt deleted file mode 100644 index e9dad3930..000000000 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/AsyncFileSaveListener.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.github.continuedev.continueintellijextension.`continue` - -import com.github.continuedev.continueintellijextension.services.ContinuePluginService -import com.intellij.openapi.vfs.AsyncFileListener -import com.intellij.openapi.vfs.newvfs.events.VFileEvent - -class AsyncFileSaveListener(private val continuePluginService: ContinuePluginService) : AsyncFileListener { - private val configFilePatterns = listOf( - ".continue/config.json", - ".continue/config.ts", - ".continue/config.yaml", - ".continuerc.json" - ) - - override fun prepareChange(events: MutableList): AsyncFileListener.ChangeApplier? { - val isConfigFile = events.any { event -> - configFilePatterns.any { pattern -> - event.path.endsWith(pattern) || event.path.endsWith(pattern.replace("/", "\\")) - } - } - - return if (isConfigFile) { - object : AsyncFileListener.ChangeApplier { - override fun afterVfsChange() { - continuePluginService.coreMessenger?.request("config/reload", null, null) { _ -> } - } - } - } else null - } -} \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index 983b7cbda..62c3cc8ab 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -48,12 +48,7 @@ class IdeProtocolClient( @OptIn(ExperimentalCoroutinesApi::class) private val limitedDispatcher = Dispatchers.IO.limitedParallelism(4) - init { - // Setup config.json / config.ts save listeners - VirtualFileManager.getInstance().addAsyncFileListener( - AsyncFileSaveListener(continuePluginService), project.service() - ) - } + init {} fun handleMessage(msg: String, respond: (Any?) -> Unit) { coroutineScope.launch(limitedDispatcher) { diff --git a/extensions/vscode/e2e/tests/PromptFile.test.ts b/extensions/vscode/e2e/tests/PromptFile.test.ts index 7cf87fd54..2717fd17e 100644 --- a/extensions/vscode/e2e/tests/PromptFile.test.ts +++ b/extensions/vscode/e2e/tests/PromptFile.test.ts @@ -42,11 +42,25 @@ describe("Prompt file", () => { "terminal", "tree", ]; + for (const provider of providers) { - await editor.typeText("@" + provider.slice(0, 2)); - await editor.typeText(Key.ENTER); + // Type the @ symbol to trigger completion + await editor.typeText("@"); + + // Wait a moment for the completion to appear + await new Promise((resolve) => setTimeout(resolve, 500)); + + // Type the first few characters + await editor.typeText(provider.slice(0, 2)); + + // Wait for completion popup to update + await new Promise((resolve) => setTimeout(resolve, 300)); + + // Use Tab to accept completion instead of Enter + await editor.typeText(Key.TAB); + const text = await editor.getText(); - expect(text).equals("@" + provider); + expect(text).to.include("@" + provider); await editor.clearText(); } diff --git a/extensions/vscode/scripts/prepackage.js b/extensions/vscode/scripts/prepackage.js index 802a4eb4f..29dbf2e8e 100644 --- a/extensions/vscode/scripts/prepackage.js +++ b/extensions/vscode/scripts/prepackage.js @@ -55,8 +55,6 @@ console.log("[info] Using target: ", target); const exe = os === "win32" ? ".exe" : ""; -const isInGitHubAction = !!process.env.GITHUB_ACTIONS; - const isArmTarget = target === "darwin-arm64" || target === "linux-arm64" || @@ -86,15 +84,6 @@ void (async () => { process.chdir(path.join(continueDir, "gui")); - if (isInGitHubAction) { - const guiBuildStart = Date.now(); - console.log(`[timer] Starting GUI build at ${new Date().toISOString()}`); - execCmdSync("npm run build"); - console.log( - `[timer] GUI build completed in ${Date.now() - guiBuildStart}ms`, - ); - } - // Copy over the dist folder to the JetBrains extension // const intellijExtensionWebviewPath = path.join( "..", @@ -140,6 +129,7 @@ void (async () => { // Then copy over the dist folder to the VSCode extension // const vscodeGuiPath = path.join("../extensions/vscode/gui"); + rimrafSync(vscodeGuiPath); fs.mkdirSync(vscodeGuiPath, { recursive: true }); const vscodeCopyStart = Date.now(); console.log(`[timer] Starting VSCode copy at ${new Date().toISOString()}`); diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index d5b0766ae..a8fcdbb88 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -251,6 +251,7 @@ export class VsCodeExtension { let orgId = queryParams.get("org_id"); this.core.invoke("config/refreshProfiles", { + reason: "VS Code deep link", selectOrgId: orgId === "null" ? undefined : (orgId ?? undefined), selectProfileId: profileId === "null" ? undefined : (profileId ?? undefined), diff --git a/gui/src/components/AssistantAndOrgListbox/index.tsx b/gui/src/components/AssistantAndOrgListbox/index.tsx index 20ede64f1..4af9846c4 100644 --- a/gui/src/components/AssistantAndOrgListbox/index.tsx +++ b/gui/src/components/AssistantAndOrgListbox/index.tsx @@ -152,7 +152,9 @@ export function AssistantAndOrgListbox() { value="reload-assistant" fontSizeModifier={-2} className="border-border border-b px-2 py-1.5" - onClick={() => refreshProfiles()} + onClick={() => + refreshProfiles("Manual refresh from assistant list") + } > { -
diff --git a/gui/src/components/OnboardingCard/components/OnboardingModelsAddOnTab.tsx b/gui/src/components/OnboardingCard/components/OnboardingModelsAddOnTab.tsx index 3d512d508..7110cd6b0 100644 --- a/gui/src/components/OnboardingCard/components/OnboardingModelsAddOnTab.tsx +++ b/gui/src/components/OnboardingCard/components/OnboardingModelsAddOnTab.tsx @@ -16,14 +16,16 @@ export function OnboardingModelsAddOnTab() { const isJetbrains = getLocalStorage("ide") === "jetbrains"; // Polling effect for JetBrains + // This is because jetbrains doesn't support deeplinking the same way as VS Code useEffect(() => { if (!isPolling || !isJetbrains) return; const interval = setInterval(() => { ideMessenger.post("config/refreshProfiles", { + reason: "Jetbrains onboarding polling", selectProfileId: "local", }); - }, 5000); + }, 7000); return () => clearInterval(interval); }, [isPolling, isJetbrains, ideMessenger]); diff --git a/gui/src/components/config/FatalErrorNotice.tsx b/gui/src/components/config/FatalErrorNotice.tsx index be052f75b..8c0a346c2 100644 --- a/gui/src/components/config/FatalErrorNotice.tsx +++ b/gui/src/components/config/FatalErrorNotice.tsx @@ -1,11 +1,16 @@ -import { useMemo } from "react"; +import { useContext, useMemo } from "react"; import { useNavigate } from "react-router-dom"; +import { useAuth } from "../../context/Auth"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useAppSelector } from "../../redux/hooks"; import { ROUTES } from "../../util/navigation"; +import Alert from "../gui/Alert"; import { useLump } from "../mainInput/Lump/LumpContext"; export const FatalErrorIndicator = () => { + const { refreshProfiles } = useAuth(); const configError = useAppSelector((store) => store.config.configError); + const ideMessenger = useContext(IdeMessengerContext); const navigate = useNavigate(); @@ -13,25 +18,62 @@ export const FatalErrorIndicator = () => { return configError?.some((error) => error.fatal); }, [configError]); - const { setSelectedSection } = useLump(); + const { setSelectedSection, selectedSection } = useLump(); + const configLoading = useAppSelector((state) => state.config.loading); const showLumpErrorSection = () => { navigate(ROUTES.HOME); setSelectedSection("error"); }; + const { selectedProfile } = useAuth(); + if (!hasFatalErrors) { return null; } + + const displayName = + selectedProfile?.title ?? + `${selectedProfile?.fullSlug?.ownerSlug}/${selectedProfile?.fullSlug?.packageSlug}` ?? + "assistant"; + return ( -
- Error!{" "} - Could not load config -
Learn More
-
+ + {`Error loading`}{" "} + {displayName} + {". "} + {`Chat is disabled until a model is available.`} +
+
{ + ideMessenger.post( + "openUrl", + "https://docs.continue.dev/troubleshooting", + ); + }} + className="cursor-pointer underline" + > + Help +
+ {configLoading ? ( +
Reloading...
+ ) : ( +
{ + refreshProfiles("Clicked reload in fatal indicator"); + }} + > + Reload +
+ )} +
+ View +
+
+
); }; diff --git a/gui/src/components/gui/Alert.tsx b/gui/src/components/gui/Alert.tsx index f7eb5b845..8035d8b8e 100644 --- a/gui/src/components/gui/Alert.tsx +++ b/gui/src/components/gui/Alert.tsx @@ -4,14 +4,12 @@ import { ExclamationTriangleIcon, InformationCircleIcon, } from "@heroicons/react/16/solid"; -import { ReactNode } from "react"; -import { vscBackground } from ".."; +import { cn } from "../../util/cn"; type AlertTypes = "info" | "success" | "warning" | "error"; type AlertSize = "sm" | "lg"; -export interface AlertProps { - children?: ReactNode; +export interface AlertProps extends React.HTMLAttributes { type?: AlertTypes; size?: AlertSize; } @@ -19,55 +17,72 @@ export interface AlertProps { type AlertConfig = { [key in AlertTypes]: { Icon: any; + iconColor: string; + background: string; + border: string; + text: string; }; }; const ALERT_CONFIGS: AlertConfig = { info: { Icon: InformationCircleIcon, + background: "bg-background", + border: "border-foreground", + iconColor: "text-foreground", + text: "text-foreground", }, success: { Icon: CheckCircleIcon, + background: "bg-green-600/20", + border: "border-success", + iconColor: "text-success", + text: "text-foreground", }, warning: { Icon: ExclamationTriangleIcon, + background: "bg-yellow-600/20", + border: "border-warning", + iconColor: "text-warning", + text: "text-foreground", }, error: { Icon: ExclamationCircleIcon, + background: "bg-red-600/20", + border: "border-error", + iconColor: "text-error", + text: "text-foreground", }, }; const alertSizes = { - sm: "px-2 py-1.5 rounded border-l-2", - lg: "px-4 py-3 rounded-lg border-l-4", + sm: "px-3 py-1.5 rounded-md border", + lg: "px-4 py-3 rounded-md border", }; const iconSizes = { - sm: "h-3 w-3", - lg: "h-5 w-5", + sm: "h-4 w-4 mt-1", + lg: "h-5 w-5 mt-0.5", }; const spacingSizes = { - sm: "ml-1.5", + sm: "ml-2", lg: "ml-3", }; -function Alert({ children, type = "info", size = "lg" }: AlertProps) { - const { Icon } = ALERT_CONFIGS[type]; +function Alert({ type = "info", size = "lg", ...props }: AlertProps) { + const { Icon, background, border, text, iconColor } = ALERT_CONFIGS[type]; return (
-
- - -
- {children} -
+ +
+
{props.children}
); diff --git a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx index bd06d197d..b9524ef78 100644 --- a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx @@ -2,17 +2,45 @@ import { ExclamationCircleIcon, ExclamationTriangleIcon, } from "@heroicons/react/24/outline"; +import { useContext } from "react"; +import { useAuth } from "../../../../../context/Auth"; +import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; import { useAppSelector } from "../../../../../redux/hooks"; export function ErrorSection() { const configError = useAppSelector((state) => state.config.configError); + const configLoading = useAppSelector((state) => state.config.loading); + const ideMessenger = useContext(IdeMessengerContext); + + const { refreshProfiles } = useAuth(); const sortedErrors = configError ? [...configError].sort((a, b) => (b.fatal ? 1 : 0) - (a.fatal ? 1 : 0)) : []; return ( -
+
+
+
{ + refreshProfiles("Clicked reload in Error section"); + }} + > + Reload +
+
{ + ideMessenger.post( + "openUrl", + "https://docs.continue.dev/troubleshooting", + ); + }} + className="text-description cursor-pointer text-xs underline" + > + Help +
+
    {sortedErrors.map((error, index) => (
  • { const handleKeyDown = (event: KeyboardEvent) => { diff --git a/gui/src/components/ui/Button.tsx b/gui/src/components/ui/Button.tsx index f0f669caa..4139641b0 100644 --- a/gui/src/components/ui/Button.tsx +++ b/gui/src/components/ui/Button.tsx @@ -11,7 +11,7 @@ type ButtonProps = React.ComponentProps<"button"> & { const buttonVariants = { primary: - "border-none text-foreground bg-primary hover:enabled:brightness-125", + "border-none text-primary-foreground bg-primary hover:enabled:brightness-125", secondary: "border-none text-foreground bg-border hover:enabled:brightness-125", outline: diff --git a/gui/src/context/Auth.tsx b/gui/src/context/Auth.tsx index 05bac4ad7..12eebae1c 100644 --- a/gui/src/context/Auth.tsx +++ b/gui/src/context/Auth.tsx @@ -27,7 +27,7 @@ interface AuthContextType { login: (useOnboarding: boolean) => Promise; selectedProfile: ProfileDescription | null; profiles: ProfileDescription[] | null; - refreshProfiles: () => Promise; + refreshProfiles: (reason?: string) => Promise; organizations: SerializedOrgWithProfiles[]; } @@ -99,18 +99,23 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ [], ); - const refreshProfiles = useCallback(async () => { - try { - dispatch(setConfigLoading(true)); - await ideMessenger.request("config/refreshProfiles", undefined); - ideMessenger.post("showToast", ["info", "Config refreshed"]); - } catch (e) { - console.error("Failed to refresh profiles", e); - ideMessenger.post("showToast", ["error", "Failed to refresh config"]); - } finally { - dispatch(setConfigLoading(false)); - } - }, [ideMessenger]); + const refreshProfiles = useCallback( + async (reason?: string) => { + try { + dispatch(setConfigLoading(true)); + await ideMessenger.request("config/refreshProfiles", { + reason, + }); + ideMessenger.post("showToast", ["info", "Config refreshed"]); + } catch (e) { + console.error("Failed to refresh profiles", e); + ideMessenger.post("showToast", ["error", "Failed to refresh config"]); + } finally { + dispatch(setConfigLoading(false)); + } + }, + [ideMessenger], + ); return (
+ {!hasDismissedExploreDialog && } {history.length === 0 && ( diff --git a/gui/src/pages/gui/StreamError.tsx b/gui/src/pages/gui/StreamError.tsx index fa740a307..649de4310 100644 --- a/gui/src/pages/gui/StreamError.tsx +++ b/gui/src/pages/gui/StreamError.tsx @@ -45,7 +45,7 @@ const StreamErrorDialog = ({ error }: StreamErrorProps) => { } = useMemo(() => analyzeError(error, selectedModel), [error, selectedModel]); const handleRefreshProfiles = () => { - void refreshProfiles(); + void refreshProfiles("Clicked reload config from stream error dialog"); dispatch(setShowDialog(false)); dispatch(setDialogMessage(undefined)); }; diff --git a/packages/config-yaml/src/interfaces/SecretResult.ts b/packages/config-yaml/src/interfaces/SecretResult.ts index b89e12e59..582caacd0 100644 --- a/packages/config-yaml/src/interfaces/SecretResult.ts +++ b/packages/config-yaml/src/interfaces/SecretResult.ts @@ -8,6 +8,7 @@ export enum SecretType { ModelsAddOn = "models_add_on", FreeTrial = "free_trial", LocalEnv = "local_env", + ProcessEnv = "process_env", } export interface OrgSecretLocation { @@ -45,6 +46,11 @@ export interface LocalEnvSecretLocation { secretName: string; } +export interface ProcessEnvSecretLocation { + secretType: SecretType.ProcessEnv; + secretName: string; +} + /** * If not found in user/package/org secrets, then there's a chance it's in * - the on-prem proxy @@ -63,7 +69,8 @@ export type SecretLocation = | NotFoundSecretLocation | ModelsAddOnSecretLocation | FreeTrialSecretLocation - | LocalEnvSecretLocation; + | LocalEnvSecretLocation + | ProcessEnvSecretLocation; export function encodeSecretLocation(secretLocation: SecretLocation): string { if (secretLocation.secretType === SecretType.Organization) { @@ -80,6 +87,8 @@ export function encodeSecretLocation(secretLocation: SecretLocation): string { return `${SecretType.FreeTrial}:${encodePackageSlug(secretLocation.blockSlug)}/${secretLocation.secretName}`; } else if (secretLocation.secretType === SecretType.LocalEnv) { return `${SecretType.LocalEnv}:${secretLocation.secretName}`; + } else if (secretLocation.secretType === SecretType.ProcessEnv) { + return `${SecretType.ProcessEnv}:${secretLocation.secretName}`; } else { throw new Error(`Invalid secret type: ${secretLocation}`); } @@ -137,6 +146,11 @@ export function decodeSecretLocation(secretLocation: string): SecretLocation { secretType: SecretType.LocalEnv, secretName, }; + case SecretType.ProcessEnv: + return { + secretType: SecretType.ProcessEnv, + secretName, + }; default: throw new Error(`Invalid secret type: ${secretType}`); } @@ -155,7 +169,8 @@ export interface FoundSecretResult { | PackageSecretLocation | ModelsAddOnSecretLocation | FreeTrialSecretLocation - | LocalEnvSecretLocation; + | LocalEnvSecretLocation + | ProcessEnvSecretLocation; fqsn: FQSN; } diff --git a/packages/openai-adapters/src/apis/AnthropicCachingStrategies.test.ts b/packages/openai-adapters/src/apis/AnthropicCachingStrategies.test.ts index afb0a2f22..c468f88df 100644 --- a/packages/openai-adapters/src/apis/AnthropicCachingStrategies.test.ts +++ b/packages/openai-adapters/src/apis/AnthropicCachingStrategies.test.ts @@ -59,6 +59,30 @@ describe("AnthropicCachingStrategies", () => { const result = CACHING_STRATEGIES.systemOnly(body); expect(result).toEqual(body); }); + + it("should not add more than 5 cached messages", () => { + const body = { + system: [ + { text: "system message 1" }, + { text: "system message 2" }, + { text: "system message 3" }, + { text: "system message 4" }, + { text: "system message 5" }, + ], + messages: [{ content: "user message" }], + }; + + const result = CACHING_STRATEGIES.systemOnly(body); + + expect(result.system).toEqual([ + { text: "system message 1", cache_control: { type: "ephemeral" } }, + { text: "system message 2", cache_control: { type: "ephemeral" } }, + { text: "system message 3", cache_control: { type: "ephemeral" } }, + { text: "system message 4", cache_control: { type: "ephemeral" } }, + { text: "system message 5" }, + ]); + expect(result.messages).toEqual(body.messages); + }); }); describe("systemAndToolsStrategy", () => { @@ -119,6 +143,30 @@ describe("AnthropicCachingStrategies", () => { const result = CACHING_STRATEGIES.systemAndTools(body); expect(result).toEqual(body); }); + + it("should add only 4 cache controls in total to both system and tools", () => { + const body = { + system: [ + { text: "system message 1" }, + { text: "system message 2" }, + { text: "system message 3" }, + { text: "system message 4" }, + ], + tools: [{ name: "tool1" }, { name: "tool2" }], + messages: [{ content: "user message" }], + }; + + const result = CACHING_STRATEGIES.systemAndTools(body); + + expect(result.system).toEqual([ + { text: "system message 1", cache_control: { type: "ephemeral" } }, + { text: "system message 2", cache_control: { type: "ephemeral" } }, + { text: "system message 3", cache_control: { type: "ephemeral" } }, + { text: "system message 4", cache_control: { type: "ephemeral" } }, + ]); + expect(result.tools).toEqual(body.tools); + expect(result.messages).toEqual(body.messages); + }); }); describe("optimizedStrategy", () => { @@ -203,6 +251,46 @@ describe("AnthropicCachingStrategies", () => { ]); }); + it("should add maximum 4 cache control blocks", () => { + const body = { + system: [{ text: "system message 1" }, { text: "system message 2" }], + tools: [{ name: "tool" }], + messages: [ + { content: "small content" }, + { content: "a".repeat(2100) }, + { content: "b".repeat(2100) }, + { + content: [ + { type: "text", text: "c".repeat(2100) }, + { type: "image", data: "image" }, + ], + }, + ], + }; + + const result = CACHING_STRATEGIES.optimized(body); + + expect(result.system).toEqual([ + { text: "system message 1", cache_control: { type: "ephemeral" } }, + { text: "system message 2", cache_control: { type: "ephemeral" } }, + ]); + expect(result.tools).toEqual([ + { name: "tool", cache_control: { type: "ephemeral" } }, + ]); + expect(result.messages[0]).toEqual({ content: "small content" }); + expect(result.messages[1]).toEqual({ + content: [ + { + type: "text", + text: "a".repeat(2100), + cache_control: { type: "ephemeral" }, + }, + ], + }); + expect(result.messages[2].content).toEqual(body.messages[2].content); + expect(result.messages[3].content).toEqual(body.messages[3].content); + }); + it("should handle complex message structure", () => { const body = { system: [{ text: "system" }], diff --git a/packages/openai-adapters/src/apis/AnthropicCachingStrategies.ts b/packages/openai-adapters/src/apis/AnthropicCachingStrategies.ts index 586a2828f..8d3065141 100644 --- a/packages/openai-adapters/src/apis/AnthropicCachingStrategies.ts +++ b/packages/openai-adapters/src/apis/AnthropicCachingStrategies.ts @@ -1,3 +1,5 @@ +const MAX_CACHING_MESSAGES = 4; + // Caching strategy type - transforms a clean Anthropic body by adding cache_control export type CachingStrategy = (anthropicBody: any) => any; @@ -9,13 +11,20 @@ const noCachingStrategy: CachingStrategy = (body) => body; // Strategy 2: System Messages Only (Current Implementation) const systemOnlyStrategy: CachingStrategy = (body) => { + let availableCacheMessages = MAX_CACHING_MESSAGES; if (body.system && Array.isArray(body.system)) { return { ...body, - system: body.system.map((item: any) => ({ - ...item, - cache_control: { type: "ephemeral" }, - })), + system: body.system.map((item: any) => { + if (availableCacheMessages > 0) { + availableCacheMessages -= 1; + return { + ...item, + cache_control: { type: "ephemeral" }, + }; + } + return item; + }), }; } return body; @@ -24,19 +33,27 @@ const systemOnlyStrategy: CachingStrategy = (body) => { // Strategy 3: System and Tools (High Impact) const systemAndToolsStrategy: CachingStrategy = (body) => { const result = { ...body }; + let availableCacheMessages = MAX_CACHING_MESSAGES; // Cache system messages if (result.system && Array.isArray(result.system)) { - result.system = result.system.map((item: any) => ({ - ...item, - cache_control: { type: "ephemeral" }, - })); + result.system = result.system.map((item: any) => { + if (availableCacheMessages > 0) { + availableCacheMessages -= 1; + return { + ...item, + cache_control: { type: "ephemeral" }, + }; + } + return item; + }); } // Cache tool definitions if (result.tools && Array.isArray(result.tools) && result.tools.length > 0) { result.tools = result.tools.map((tool: any, index: number) => { - if (index === result.tools.length - 1) { + if (index === result.tools.length - 1 && availableCacheMessages > 0) { + availableCacheMessages -= 1; return { ...tool, cache_control: { type: "ephemeral" }, @@ -52,19 +69,27 @@ const systemAndToolsStrategy: CachingStrategy = (body) => { // Strategy 4: Optimized (Intelligent Caching) const optimizedStrategy: CachingStrategy = (body) => { const result = { ...body }; + let availableCacheMessages = MAX_CACHING_MESSAGES; // Always cache system messages if (result.system && Array.isArray(result.system)) { - result.system = result.system.map((item: any) => ({ - ...item, - cache_control: { type: "ephemeral" }, - })); + result.system = result.system.map((item: any) => { + if (availableCacheMessages > 0) { + availableCacheMessages -= 1; + return { + ...item, + cache_control: { type: "ephemeral" }, + }; + } + return item; + }); } // Cache tool definitions if (result.tools && Array.isArray(result.tools) && result.tools.length > 0) { result.tools = result.tools.map((tool: any, index: number) => { - if (index === result.tools.length - 1) { + if (index === result.tools.length - 1 && availableCacheMessages > 0) { + availableCacheMessages -= 1; return { ...tool, cache_control: { type: "ephemeral" }, @@ -79,7 +104,8 @@ const optimizedStrategy: CachingStrategy = (body) => { result.messages = result.messages.map((message: any) => { if (message.content && typeof message.content === "string") { const tokens = estimateTokenCount(message.content); - if (tokens > 500) { + if (tokens > 500 && availableCacheMessages > 0) { + availableCacheMessages -= 1; return { ...message, content: [ @@ -95,7 +121,8 @@ const optimizedStrategy: CachingStrategy = (body) => { const updatedContent = message.content.map((item: any) => { if (item.type === "text" && item.text) { const tokens = estimateTokenCount(item.text); - if (tokens > 500) { + if (tokens > 500 && availableCacheMessages > 0) { + availableCacheMessages -= 1; return { ...item, cache_control: { type: "ephemeral" }, diff --git a/scripts/build-packages.js b/scripts/build-packages.js index 238a8f0ea..996323f8a 100644 --- a/scripts/build-packages.js +++ b/scripts/build-packages.js @@ -86,7 +86,7 @@ async function main() { await buildPackagesInParallel(["fetch", "config-yaml", "llm-info"]); // Phase 3: Build packages that depend on other local packages - await buildPackagesInParallel(["openai-adapters", "continue-sdk"], true); + await buildPackagesInParallel(["openai-adapters", "continue-sdk"]); console.log("🎉 All packages built successfully!"); } catch (error) {