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.99k stars 1.62k forks source link

@open Context Provider doesn't work #2313

Open Snowman-25 opened 1 month ago

Snowman-25 commented 1 month ago

Before submitting your bug report

Relevant environment info

- OS: Windows 11 23H2 (Build 22631.4169)
- Continue:   v0.8.52
- IDE:        VSCode 1.92.1 (user setup)
- Model:      deepseek-coder-v2:latest
- config.json:

{
  "models": [
    {
      "title": "Ollama",
      "provider": "ollama",
      "model": "AUTODETECT"
    }
  ],
  "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": "desc",
      "prompt": "{{{ input }}}\n\nWrite a comprehensive comment for each block of the selected code. It should describe what it does and show possible caveats.",
      "description": "Comment the highlighted code"
    }
  ],
  "tabAutocompleteModel": {
    "title": "Starcoder 3b",
    "provider": "ollama",
    "model": "starcoder2"
  },
  "allowAnonymousTelemetry": false,
  "embeddingsProvider": {
    "provider": "transformers.js"
  },
  "contextProviders": [
    {
      "name": "open",
      "params": {
        "onlyPinned": false
      }
     }
  ],
  "experimental": {
    "readResponseTTS": true
  },
  "ui": {
    "showChatScrollbar": true
  },
  "docs": []
}

Description

@open doesn't send the correct context or sometimes ANY content to the LLM

The Errors about config.json not found in the log output are instances where Continue tried to use config.json as the only context to my prompt, despite having multiple files open and config.json not being the active Tab. Also, the file is existant in that location. Note, that while I'm running VSCode on my Win11 Computer, my workspace resides on a Unix-Server using the Remote-SSH extension.

To reproduce

  1. Add @open to your config.json
  2. Try to use @open in your prompt
  3. See that no context was given or the wrong has file been given as context

Log output

console.ts:137 [Extension Host] Error reading file EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, stat '/Users/USERNAME/.continue/config.json'
    at P.e (c:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:153:6919)
    at Object.stat (c:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:153:3977)
    at async _VsCodeIdeUtils.readFile (c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:555520:29)
    at async VsCodeIde.readFile (c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:556110:16)
    at async c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:454120:3
    at async Promise.all (index 0)
    at async OpenFilesContextProvider.getContextItems (c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:454115:16)
    at async c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:516575:27
    at async c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:556420:20
    at async i.value (c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:523120:32)
y @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
S @ rpcProtocol.ts:458
Q @ rpcProtocol.ts:443
M @ rpcProtocol.ts:373
L @ rpcProtocol.ts:299
(anonymous) @ rpcProtocol.ts:161
B @ event.ts:1230
fire @ event.ts:1261
fire @ ipc.net.ts:652
K.onmessage @ localProcessExtensionHost.ts:378
console.ts:137 [Extension Host] [file-inspection] language set by file inspection
2console.ts:137 [Extension Host] Ansible found in the workspace
2console.ts:137 [Extension Host] Error reading file EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, stat '/Users/USERNAME/.continue/config.json'
    at P.e (c:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:153:6919)
    at Object.stat (c:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:153:3977)
    at async _VsCodeIdeUtils.readFile (c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:555520:29)
    at async VsCodeIde.readFile (c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:556110:16)
    at async c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:454120:3
    at async Promise.all (index 0)
    at async OpenFilesContextProvider.getContextItems (c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:454115:16)
    at async c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:516575:27
    at async c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:556420:20
    at async i.value (c:\Users\USERNAME\.vscode\extensions\continue.continue-0.8.52-win32-x64\out\extension.js:523120:32)
y @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
S @ rpcProtocol.ts:458
Q @ rpcProtocol.ts:443
M @ rpcProtocol.ts:373
L @ rpcProtocol.ts:299
(anonymous) @ rpcProtocol.ts:161
B @ event.ts:1230
fire @ event.ts:1261
fire @ ipc.net.ts:652
K.onmessage @ localProcessExtensionHost.ts:378
console.ts:137 [Extension Host] [file-inspection] language set by file inspection
2console.ts:137 [Extension Host] Ansible found in the workspace
Patrick-Erichsen commented 1 month ago

Hi @Snowman-25 , thanks for the writeup here. I just tried using @Open Files locally and it seems to be working, so I think this may be the root of the issue:

Note, that while I'm running VSCode on my Win11 Computer, my workspace resides on a Unix-Server using the Remote-SSH extension.

Not sure what would be causing that unfortunately since we read files through the IDE to ensure we're pulling from the right filesystem.

Snowman-25 commented 1 month ago

Not sure what would be causing that unfortunately since we read files through the IDE to ensure we're pulling from the right filesystem.

Does this imply that unsaved changes/files also aren't visible to @open?

€dit: I've been testing a bit: If my workspace is local, proper context is given. All open files except for unsaved ones are given as context to the prompt (All 'as-saved-on-disk' versions of the open tabs, to be specific). When the workspace is remote, no remote files are used as context. Local Files (such as config.json) are given.

2nd €dit: When using @file, context works correct, even in a remote workspace