code2prompt icon indicating copy to clipboard operation
code2prompt copied to clipboard

Cannot exclude filenames that start with a dot

Open yazoooo opened this issue 1 year ago • 0 comments

Bug: Unable to Exclude Dotfiles in .codetopromptrc Configuration

Description:
I am using the .codetopromptrc file to configure code2prompt and trying to exclude files that start with a dot (such as .gitignore and .codetopromptrc) using the exclude option. However, I cannot seem to exclude these dotfiles, including the .codetopromptrc file itself. I have tried various patterns, but the dotfiles still appear in the Table of Contents.

Steps to Reproduce:

  1. Create a .codetopromptrc configuration file with the following content:

    {
      "suppress_comments": false,
      "line_number": false,
      "encoding": "cl100k_base",
      "filter": "**.tsx, **.js, README.md, notes.txt, **/Dockerfile, package.json, tsconfig.json, *.yml, .env",
      "exclude": "**.txt, tests/*,prototypes/*, **/node_modules/**, **/frontend/build/**, **/.git/**, **/.vscode/**, **/.idea/**, backend/package-lock.json, code2prompt.txt, .gitignore, .codepromptrc",
      "tokens": false
    }
    
  2. Run the following command:

    code2prompt --output code2prompt.txt --tokens --path .
    
  3. The resulting table of contents still includes dotfiles, such as .gitignore and .codetopromptrc:

    # Table of Contents
    - notes.txt
    - README.md
    - .gitignore
    - .codetopromptrc
    - LICENSE
    - .github/workflows/ci-cd.yml
    - backend/Dockerfile
    - backend/package.json
    - backend/src/app.js
    - backend/src/handlers/health.js
    - frontend/tsconfig.json
    - frontend/package.json
    - frontend/src/react-app-env.d.ts
    - frontend/src/App.tsx
    - frontend/src/index.tsx
    - frontend/src/components/HealthCheck.tsx
    - frontend/src/pages/HealthCheck.tsx
    - frontend/public/index.html
    

Expected Behavior:
Files like .gitignore, .codetopromptrc, and other dotfiles should be excluded as specified in the exclude option.

Attempted Solutions:

  • Tried the following patterns in the exclude option to remove dotfiles:
    • .codetopromptrc
    • **.codetopromptrc
    • /\.codetopromptrc

None of these worked to exclude the dotfiles.

note: It might be intended, but if you specify the --gitignore option from the command line then it will ignore the exclude options in the .codetopromptrc file.

Environment: code2prompt version 0.6.5

Possible Fix:
There might be an issue with how the tool processes glob patterns for dotfiles in the exclude option. Support for better handling of dotfile exclusions would resolve this issue.

yazoooo avatar Sep 05 '24 11:09 yazoooo