positron icon indicating copy to clipboard operation
positron copied to clipboard

Assistant: Provide a way to exclude some files from inline completions

Open jmcphers opened this issue 9 months ago • 1 comments

Currently, Assistant provides inline completions everywhere:

https://github.com/posit-dev/positron/blob/a8bf9ce8ef0c84a21ef95556c905e689ed1a4c1e/extensions/positron-assistant/src/extension.ts#L169

This can be at best annoying but at worst a security concern (e.g. you don't want it autocompleting secrets, nor sending secrets as context to a third party).

There are two sides to this issue; one is excluding auto-completions from being shown to the user (e.g. as in github.copilot.enable for a set of file types), and the other is excluding the file's content from inclusion in the context sent to the model for privacy and security reasons.

https://docs.github.com/en/copilot/managing-copilot/configuring-and-auditing-content-exclusion/excluding-content-from-github-copilot#limitations

Positron should ship with exclusions pre-configured for typical data science projects files that contain secrets, such as .Renviron and .env files (for example).

jmcphers avatar May 15 '25 20:05 jmcphers

We should also have exclusions for hidden files/folders like .git, .venv, .ssh, as well as binary/data files, and some opinionated .dotfiles like .Rproj if we aren't already.

For example, in RStudio: https://github.com/rstudio/rstudio/blob/8e3a3124784eab15cc2dd51e088bb06481e03c04/src/cpp/session/modules/SessionCopilot.cpp#L249-L278

jthomasmock avatar May 15 '25 21:05 jthomasmock

There is a preference to add exclusion patterns for inline completion. This uses the glob pattern rules found in other settings and a link is provided in the description that explains how to create the glob pattern.

Image

#8216 continues the work to exclude the files from the AI context so that excluded files aren't leaked when looking at the project files.

timtmok avatar Jun 20 '25 14:06 timtmok

@jthomasmock @timtmok Note: when interacting directly with .env file, Assistant does reveal my secret. But it doesn't do so in line completions or if I add .env to the list of glob patterns. Is this expected behavior?

Image

rodrigosf672 avatar Jun 23 '25 13:06 rodrigosf672

@rodrigosf672 https://github.com/posit-dev/positron/issues/8216 continues the work to exclude files from the context

timtmok avatar Jun 23 '25 14:06 timtmok

Verified Fixed

Positron Version(s) : 2025.07.0 (Universal) build 170
OS Version          : macOS Sequoia 15.5

Test scenario(s)

  • Files can be excluded from inline completions through settings
  • Link to VS Code docs on Glob Patterns Reference is provided to user
  • File types tested: .Renviron and .env.

rodrigosf672 avatar Jun 23 '25 14:06 rodrigosf672