continuedev / continue

⏩ Continue is the leading open-source AI code assistant. You can connect any models and any context to build custom autocomplete and chat experiences inside VS Code and JetBrains
https://docs.continue.dev/
Apache License 2.0
18.91k stars 1.6k forks source link

config.ts build fails with newest release #1947

Open mjmaurer opened 3 months ago

mjmaurer commented 3 months ago

Before submitting your bug report

Relevant environment info

- OS: MacOS Sonoma 14.6 (M1 Pro)
- Continue: 0.8.45
- IDE: VSCode

Description

My previously-working config.ts has stopped working in the latest release. Rolling back to 0.8.44 fixes the issue.

The following message appears in VSCode web devtools:

Build error. Please check your ~/.continue/config.ts file: TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.

mainThreadExtensionService.ts:78 [Continue.continue]Parsing failed
mainThreadExtensionService.ts:79 Error: Parsing failed
    at _Parser.parse (vscode-file://vscode…tension.js:89161:81)
    at _ImportDefinitionsService._getFileInfo (vscode-file://vscode…tension.js:90067:28)
    at async PrecalculatedLruCache.initKey (vscode-file://vscode…tension.js:88017:25)

Not sure if this helps, but I noticed that none of the files in ~/.continue have been updated recently (with the exception of folders like index and sessions). Not sure if you attempt to manage those across releases somehow.

To reproduce

Attempt to load extension (via Reload Window, etc)

Log output

No response

Patrick-Erichsen commented 3 months ago

Hey @mjmaurer , mind sharing your config.ts/config.json? We made some updates to tsconfig in this release that might be what's causing this issue.

mjmaurer commented 3 months ago

Sure no problem @Patrick-Erichsen

config.ts

//// <reference types="/Users/mmaurer7/.continue/types/core/index.d.ts" />
export function modifyConfig(config: Config): Config {
  const anthropicKey = process.env.ANTHROPIC_API_KEY;
  if (anthropicKey) {
    config.models.push({
      title: "Claude 3.5 Sonnet",
      provider: "anthropic",
      model: "claude-3-5-sonnet-20240620",
      apiKey: anthropicKey,
    });
    console.info("Antropic loaded");
  } else {
    console.error("Missing ANTHROPIC_API_KEY");
  }
  const codestralKey = process.env.CODESTRAL_API_KEY;
  if (codestralKey) {
    const codstral: ModelDescription = {
      title: "Codestral Latest",
      provider: "mistral",
      model: "codestral-latest",
      apiKey: codestralKey,
    };
    config.models.push(codstral);
    config.tabAutocompleteModel = codstral;
    console.info("Codestral loaded");
  } else {
    console.error("Missing CODESTRAL_API_KEY");
  }
  const voyageKey = process.env.VOYAGE_API_KEY;
  if (voyageKey) {
    config.embeddingsProvider = {
      provider: "openai",
      model: "voyage-code-2",
      apiBase: "https://api.voyageai.com/v1/",
      apiKey: voyageKey,
    };
    console.info("Voyage loaded");
  } else {
    console.error("Missing VOYAGE_API_KEY");
  }
  const openAiKey = process.env.OPENAI_API_KEY;
  if (openAiKey) {
    config.models.push({
      title: "GPT 4",
      provider: "openai",
      model: "gpt-4",
      apiKey: openAiKey,
    });
    config.models.push({
      title: "GPT 4o",
      provider: "openai",
      model: "gpt-4o",
      apiKey: openAiKey,
    });
    console.info("OpenAI loaded");
  } else {
    console.error("Missing OPENAI_API_KEY");
  }

  return config;
}

config.json

{
    "models": [],
    "customCommands": [
        {
            "name": "test",
            "prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
            "description": "Write unit tests for highlighted code"
        },
        {
            "name": "check",
            "description": "Check for mistakes in my code",
            "prompt": "{{{ input }}}\n\nPlease read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant:\n- Syntax errors\n- Logic errors\n- Security vulnerabilities\n- Performance issues\n- Anything else that looks wrong\n\nOnce you find an error, please explain it as clearly as possible, but without using extra words. For example, instead of saying 'I think there is a syntax error on line 5', you should say 'Syntax error on line 5'. Give your answer as one bullet point per mistake found."
        }
    ],
    "allowAnonymousTelemetry": false
}
Patrick-Erichsen commented 3 months ago

Neat use case for config.ts!

Thanks for sharing though. Will look into this tomorrow 👍

migs911 commented 3 months ago

I caught the same error when I was trying to set up a custom model. I tried to paste the code from this instruction, but there are no new models in the list. https://docs.continue.dev/setup/configuration#defining-a-custom-llm-provider

fry69 commented 3 months ago

Does this still happen with Pre-Release 0.9.195?

migs911 commented 3 months ago

Does this still happen with Pre-Release 0.9.145?

yes, this still happen with v0.9.195 pre-release

guillem-riera commented 3 months ago

I just wanted to mention that I experienced the same problem with my custom context provider after updating the extension to 0.8.45. Reverting to 0.8.44 solved the problem for me too.

sestinj commented 3 months ago

For folks experiencing this issue, would you be able to share the Node.js version being used by your VS Code? (in the "About - VS Code" menu in the upper left on your Mac when in VS Code)

AlrikOlson commented 3 months ago

I'm on Windows and my custom context providers defined in the config.ts are no longer showing up. I can't find anything in any Continue-related logs/output that would explain why they aren't showing up.

Edit: This seems related to #1936

Here is my VS Code's "About" dialog contents:

Version: 1.92.0 (user setup)
Commit: b1c0a14de1414fcdaa400695b4db1c0799bc3124
Date: 2024-07-31T23:26:45.634Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631
mjmaurer commented 3 months ago
Version: 1.92.0 (Universal)
Commit: b1c0a14de1414fcdaa400695b4db1c0799bc3124
Date: 2024-07-31T23:26:45.634Z (1 wk ago)
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Darwin arm64 23.6.0
jayrepo commented 3 months ago

It occurred with sample config from the doc.

Version: 1.92.1
Commit: eaa41d57266683296de7d118f574d0c2652e1fc4
Date: 2024-08-07T20:16:39.455Z (1 day ago)
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Darwin arm64 23.6.0

Error in the dev tools console:

[Extension Host] Build error. Please check your ~/.continue/config.ts file: TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.
Patrick-Erichsen commented 2 months ago

@mjmaurer @migs911 @AlrikOlson @fry69 - this should be resolved with https://github.com/continuedev/continue/pull/1975.

Previously we were targeting CommonJS in the core package, which transpiled the dynamic import used in our config loading, but we recently moved to targeting ESNext and now need to explicitly transpile dynamic imports when packaging the extension.

Apologies for the bug, and thanks all for your help troubleshooting!

This fix will be included in the next pre-release later today.

fry69 commented 2 months ago

Current stable versions >=0.8.46 (and Pre-Release >=0.9.196) contain this fix, please test and confirm if the problem is solved (or not).

AlrikOlson commented 2 months ago

Current stable versions >=0.8.46 (and Pre-Release >=0.9.196) contain this fix, please test and confirm if the problem is solved (or not).

Just upgraded to 0.8.46 and things seem to be working again for me. Thanks for getting the fix out so fast!

guillem-riera commented 2 months ago

I can confirm that 0.8.46 fixes the problem for me. Everything is again working perfectly!.

Thanks for fixing it!