From 85abbbdb0bc70b97895bfb157e4ee711ca53b2e8 Mon Sep 17 00:00:00 2001 From: Akhileshrangani4 Date: Mon, 4 Nov 2024 17:52:26 -0500 Subject: [PATCH] fix: ignore certains files and folders from the file tree - Created new config file for ignored paths in file system traversal - Separated ignored folders and files into dedicated arrays - Includes comprehensive ignore patterns for: - Package managers (node_modules, venv) - Build outputs and caches - Version control - IDE specific folders - Framework specific directories - System and config files - Lock files and compiled assets --- .../components/editor/AIChat/ContextTabs.tsx | 10 +- .../editor/AIChat/lib/ignored-paths.ts | 102 ++++++++++++++++++ 2 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 frontend/components/editor/AIChat/lib/ignored-paths.ts diff --git a/frontend/components/editor/AIChat/ContextTabs.tsx b/frontend/components/editor/AIChat/ContextTabs.tsx index 956a060..dad76ce 100644 --- a/frontend/components/editor/AIChat/ContextTabs.tsx +++ b/frontend/components/editor/AIChat/ContextTabs.tsx @@ -10,6 +10,8 @@ import { import { Input } from "@/components/ui/input" import { ContextTab } from "./types" import { ContextTabsProps } from "./types" +// Ignore certain folders and files from the file tree +import { ignoredFiles, ignoredFolders } from "./lib/ignored-paths" export default function ContextTabs({ contextTabs, @@ -48,9 +50,13 @@ export default function ContextTabs({ // Get all files from the file tree to search for context const getAllFiles = (items: (TFile | TFolder)[]): TFile[] => { return items.reduce((acc: TFile[], item) => { - if (item.type === "file") { + // Add file if it's not ignored + if (item.type === "file" && !ignoredFiles.some((pattern: string) => + item.name.endsWith(pattern.replace('*', '')) || item.name === pattern + )) { acc.push(item) - } else { + // Add all files from folder if it's not ignored + } else if (item.type === "folder" && !ignoredFolders.some((folder: string) => folder === item.name)) { acc.push(...getAllFiles(item.children)) } return acc diff --git a/frontend/components/editor/AIChat/lib/ignored-paths.ts b/frontend/components/editor/AIChat/lib/ignored-paths.ts new file mode 100644 index 0000000..75d8f2b --- /dev/null +++ b/frontend/components/editor/AIChat/lib/ignored-paths.ts @@ -0,0 +1,102 @@ +// Ignore certain folders and files from the file tree + +export const ignoredFolders = [ + // Package managers + 'node_modules', + 'venv', + '.env', + 'env', + '.venv', + 'virtualenv', + 'pip-wheel-metadata', + + // Build outputs + '.next', + 'dist', + 'build', + 'out', + '__pycache__', + '.webpack', + '.serverless', + 'storybook-static', + + // Version control + '.git', + '.svn', + '.hg', // Mercurial + + // Cache and temp files + '.cache', + 'coverage', + 'tmp', + '.temp', + '.npm', + '.pnpm', + '.yarn', + '.eslintcache', + '.stylelintcache', + + // IDE specific + '.idea', + '.vscode', + '.vs', + '.sublime', + + // Framework specific + '.streamlit', + '.next', + 'static', + '.pytest_cache', + '.nuxt', + '.docusaurus', + '.remix', + '.parcel-cache', + 'public/build', // Remix/Rails + '.turbo', // Turborepo + + // Logs + 'logs', + '*.log', + 'npm-debug.log*', + 'yarn-debug.log*', + 'yarn-error.log*', + 'pnpm-debug.log*', + ] as const; + + export const ignoredFiles = [ + '.DS_Store', + '.env.local', + '.env.development', + '.env.production', + '.env.test', + '.env*.local', + '.gitignore', + '.npmrc', + '.yarnrc', + '.editorconfig', + '.prettierrc', + '.eslintrc', + '.browserslistrc', + 'tsconfig.tsbuildinfo', + '*.pyc', + '*.pyo', + '*.pyd', + '*.so', + '*.dll', + '*.dylib', + '*.class', + '*.exe', + 'package-lock.json', + 'yarn.lock', + 'pnpm-lock.yaml', + 'composer.lock', + 'poetry.lock', + 'Gemfile.lock', + '*.min.js', + '*.min.css', + '*.map', + '*.chunk.*', + '*.hot-update.*', + '.vercel', + '.netlify' + ] as const; \ No newline at end of file