Protecting Code

To avoid sending sensitive information to an LLM, you can use the AI Assistant protect file. Each line in the protect file defines a pattern, specifying which files should or should not be protected. Content from protected files will be omitted from @snippet and #symbol expansion.

Attention

Content that is pasted or manually entered into the chat will not be safeguarded by this mechanism.

AI Assistant looks for the protect file in:

  • <project>/.dvt/ai/protect.

Pattern Format

Patterns match agains either absolute or relative paths. Those beginning with a / on Linux and MacOS, or a drive specifier on Windows, will match agains the absoult path. All other patterns will match agains the project relative path.

*

Matches zero or more characters without crossing directory boundaries.

**

Matches zero or more characters crossing directory boundaries.

?

Matches exactly one character.

[ ]

Matches a single character out of a set of characters. For example, [abc] matches a, b, or c.

Hyphen - may be used to specify a range. For example, [a-z] matches from a to z (inclusive).

Exclamation mark ! at the beginning of a set may be used for negation. For example, [!a-c] matches any character except a, b, or c.

{pattern1,pattern2}

Groups patterns separated by comma ,. Groups cannot be nested.

$VAR or ${VAR}

Expands to environment variable value.

!pattern

Negates the pattern. Any matching path protected by a previous pattern will become unprotected again.

#comment

Comment lines and empty lines are ignored.

Examples

  1. Protect files from specific directories and their descendents:

    # protect all files from a specific directory relative to the project root
    lib/ip1/rtl/**
    
    # protect all files from a specific directory in the filesystem
    /path/to/ip/store/ip1/rtl/**
    
    # protect all files in any directory named 'secret'
    **/secret/**
    
    # protect all files in the user home directory
    $HOME/**
    
  2. Protect everything except files inside a specific directory and its descendents:

    # protect all files
    **
    
    # do not protect files inside 'public' directory
    !/path/to/public/**
    
  3. Protect all files except those with specific extensions:

    # protect all files
    **
    
    # do not protect files with these extensions
    !**/*.{sv,svh}