mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 05:45:00 +00:00
refactor: separate root-only and anywhere important files
This commit is contained in:
parent
5532893ac9
commit
bcb88eb675
1 changed files with 72 additions and 197 deletions
269
aider/special.py
269
aider/special.py
|
@ -1,240 +1,115 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
IMPORTANT_FILES = [
|
ROOT_IMPORTANT_FILES = [
|
||||||
# Version Control
|
# Version Control
|
||||||
".gitignore",
|
".gitignore", ".gitattributes",
|
||||||
".gitattributes",
|
|
||||||
# Documentation
|
# Documentation
|
||||||
"README",
|
"README", "README.md", "README.txt", "README.rst",
|
||||||
"README.md",
|
"CONTRIBUTING", "CONTRIBUTING.md", "CONTRIBUTING.txt", "CONTRIBUTING.rst",
|
||||||
"README.txt",
|
"LICENSE", "LICENSE.md", "LICENSE.txt",
|
||||||
"README.rst",
|
"CHANGELOG", "CHANGELOG.md", "CHANGELOG.txt", "CHANGELOG.rst",
|
||||||
"CONTRIBUTING",
|
"SECURITY", "SECURITY.md", "SECURITY.txt",
|
||||||
"CONTRIBUTING.md",
|
|
||||||
"CONTRIBUTING.txt",
|
|
||||||
"CONTRIBUTING.rst",
|
|
||||||
"LICENSE",
|
|
||||||
"LICENSE.md",
|
|
||||||
"LICENSE.txt",
|
|
||||||
"CHANGELOG",
|
|
||||||
"CHANGELOG.md",
|
|
||||||
"CHANGELOG.txt",
|
|
||||||
"CHANGELOG.rst",
|
|
||||||
"SECURITY",
|
|
||||||
"SECURITY.md",
|
|
||||||
"SECURITY.txt",
|
|
||||||
"CODEOWNERS",
|
"CODEOWNERS",
|
||||||
# Package Management and Dependencies
|
# Package Management and Dependencies
|
||||||
"requirements.txt",
|
"requirements.txt", "Pipfile", "Pipfile.lock", "pyproject.toml",
|
||||||
"Pipfile",
|
"setup.py", "setup.cfg", "package.json", "package-lock.json",
|
||||||
"Pipfile.lock",
|
"yarn.lock", "npm-shrinkwrap.json", "Gemfile", "Gemfile.lock",
|
||||||
"pyproject.toml",
|
"composer.json", "composer.lock", "pom.xml", "build.gradle",
|
||||||
"setup.py",
|
"build.sbt", "go.mod", "go.sum", "Cargo.toml", "Cargo.lock",
|
||||||
"setup.cfg",
|
"mix.exs", "rebar.config", "project.clj", "Podfile", "Cartfile",
|
||||||
"package.json",
|
"dub.json", "dub.sdl",
|
||||||
"package-lock.json",
|
|
||||||
"yarn.lock",
|
|
||||||
"npm-shrinkwrap.json",
|
|
||||||
"Gemfile",
|
|
||||||
"Gemfile.lock",
|
|
||||||
"composer.json",
|
|
||||||
"composer.lock",
|
|
||||||
"pom.xml",
|
|
||||||
"build.gradle",
|
|
||||||
"build.sbt",
|
|
||||||
"go.mod",
|
|
||||||
"go.sum",
|
|
||||||
"Cargo.toml",
|
|
||||||
"Cargo.lock",
|
|
||||||
"mix.exs",
|
|
||||||
"rebar.config",
|
|
||||||
"project.clj",
|
|
||||||
"Podfile",
|
|
||||||
"Cartfile",
|
|
||||||
"dub.json",
|
|
||||||
"dub.sdl",
|
|
||||||
# Configuration and Settings
|
# Configuration and Settings
|
||||||
".env",
|
".env", ".env.example", ".editorconfig", "tsconfig.json", "jsconfig.json",
|
||||||
".env.example",
|
".babelrc", "babel.config.js", ".eslintrc", ".eslintignore", ".prettierrc",
|
||||||
".editorconfig",
|
".stylelintrc", "tslint.json", ".pylintrc", ".flake8", ".rubocop.yml",
|
||||||
"tsconfig.json",
|
".scalafmt.conf", ".dockerignore", ".gitpod.yml", "sonar-project.properties",
|
||||||
"jsconfig.json",
|
"renovate.json", "dependabot.yml", ".pre-commit-config.yaml", "mypy.ini",
|
||||||
".babelrc",
|
"tox.ini", ".yamllint", "pyrightconfig.json",
|
||||||
"babel.config.js",
|
|
||||||
".eslintrc",
|
|
||||||
".eslintignore",
|
|
||||||
".prettierrc",
|
|
||||||
".stylelintrc",
|
|
||||||
"tslint.json",
|
|
||||||
".pylintrc",
|
|
||||||
".flake8",
|
|
||||||
".rubocop.yml",
|
|
||||||
".scalafmt.conf",
|
|
||||||
".dockerignore",
|
|
||||||
".gitpod.yml",
|
|
||||||
"sonar-project.properties",
|
|
||||||
"renovate.json",
|
|
||||||
"dependabot.yml",
|
|
||||||
".pre-commit-config.yaml",
|
|
||||||
"mypy.ini",
|
|
||||||
"tox.ini",
|
|
||||||
".yamllint",
|
|
||||||
"pyrightconfig.json",
|
|
||||||
# Build and Compilation
|
# Build and Compilation
|
||||||
"Makefile",
|
"webpack.config.js", "rollup.config.js", "parcel.config.js", "gulpfile.js",
|
||||||
"CMakeLists.txt",
|
"Gruntfile.js", "build.xml", "build.boot", "project.json", "build.cake",
|
||||||
"webpack.config.js",
|
|
||||||
"rollup.config.js",
|
|
||||||
"parcel.config.js",
|
|
||||||
"gulpfile.js",
|
|
||||||
"Gruntfile.js",
|
|
||||||
"build.xml",
|
|
||||||
"build.boot",
|
|
||||||
"project.json",
|
|
||||||
"build.cake",
|
|
||||||
"MANIFEST.in",
|
"MANIFEST.in",
|
||||||
# Testing
|
# Testing
|
||||||
"pytest.ini",
|
"pytest.ini", "phpunit.xml", "karma.conf.js", "jest.config.js", "cypress.json",
|
||||||
"phpunit.xml",
|
".nycrc", ".nycrc.json",
|
||||||
"karma.conf.js",
|
|
||||||
"jest.config.js",
|
|
||||||
"cypress.json",
|
|
||||||
"conftest.py",
|
|
||||||
".nycrc",
|
|
||||||
".nycrc.json",
|
|
||||||
# CI/CD
|
# CI/CD
|
||||||
".travis.yml",
|
".travis.yml", ".gitlab-ci.yml", "Jenkinsfile", "azure-pipelines.yml",
|
||||||
".gitlab-ci.yml",
|
"bitbucket-pipelines.yml", "appveyor.yml", "circle.yml", ".circleci/config.yml",
|
||||||
"Jenkinsfile",
|
".github/dependabot.yml", "codecov.yml", ".coveragerc",
|
||||||
"azure-pipelines.yml",
|
|
||||||
"bitbucket-pipelines.yml",
|
|
||||||
"appveyor.yml",
|
|
||||||
"circle.yml",
|
|
||||||
".circleci/config.yml",
|
|
||||||
".github/dependabot.yml",
|
|
||||||
"codecov.yml",
|
|
||||||
".coveragerc",
|
|
||||||
# Docker and Containers
|
# Docker and Containers
|
||||||
"Dockerfile",
|
"Dockerfile", "docker-compose.yml", "docker-compose.override.yml",
|
||||||
"docker-compose.yml",
|
|
||||||
"docker-compose.override.yml",
|
|
||||||
# Cloud and Serverless
|
# Cloud and Serverless
|
||||||
"serverless.yml",
|
"serverless.yml", "firebase.json", "now.json", "netlify.toml", "vercel.json",
|
||||||
"firebase.json",
|
"app.yaml", "terraform.tf", "main.tf", "cloudformation.yaml", "cloudformation.json",
|
||||||
"now.json",
|
"ansible.cfg", "kubernetes.yaml", "k8s.yaml",
|
||||||
"netlify.toml",
|
|
||||||
"vercel.json",
|
|
||||||
"app.yaml",
|
|
||||||
"terraform.tf",
|
|
||||||
"main.tf",
|
|
||||||
"cloudformation.yaml",
|
|
||||||
"cloudformation.json",
|
|
||||||
"ansible.cfg",
|
|
||||||
"kubernetes.yaml",
|
|
||||||
"k8s.yaml",
|
|
||||||
# Database
|
# Database
|
||||||
"schema.sql",
|
"schema.sql", "liquibase.properties", "flyway.conf",
|
||||||
"liquibase.properties",
|
|
||||||
"flyway.conf",
|
|
||||||
# Framework-specific
|
# Framework-specific
|
||||||
"manage.py",
|
"next.config.js", "nuxt.config.js", "vue.config.js", "angular.json",
|
||||||
"settings.py", # Django
|
"gatsby-config.js", "gridsome.config.js",
|
||||||
"config/routes.rb",
|
|
||||||
"Rakefile", # Ruby on Rails
|
|
||||||
"next.config.js",
|
|
||||||
"nuxt.config.js", # Next.js, Nuxt.js
|
|
||||||
"vue.config.js",
|
|
||||||
"angular.json", # Vue.js, Angular
|
|
||||||
"gatsby-config.js",
|
|
||||||
"gridsome.config.js", # Gatsby, Gridsome
|
|
||||||
# API Documentation
|
# API Documentation
|
||||||
"swagger.yaml",
|
"swagger.yaml", "swagger.json", "openapi.yaml", "openapi.json",
|
||||||
"swagger.json",
|
|
||||||
"openapi.yaml",
|
|
||||||
"openapi.json",
|
|
||||||
# Language-specific
|
|
||||||
"__init__.py", # Python
|
|
||||||
"stack.yaml",
|
|
||||||
"package.yaml", # Haskell
|
|
||||||
".htaccess", # Apache
|
|
||||||
".bowerrc", # Bower
|
|
||||||
# Development environment
|
# Development environment
|
||||||
".nvmrc",
|
".nvmrc", ".ruby-version", ".python-version", "Vagrantfile",
|
||||||
".ruby-version",
|
|
||||||
".python-version",
|
|
||||||
"Vagrantfile",
|
|
||||||
# Quality and metrics
|
# Quality and metrics
|
||||||
".codeclimate.yml",
|
".codeclimate.yml", "codecov.yml",
|
||||||
".coveragerc",
|
|
||||||
"codecov.yml",
|
|
||||||
# Documentation
|
# Documentation
|
||||||
"mkdocs.yml",
|
"mkdocs.yml", "_config.yml", "book.toml", "readthedocs.yml", ".readthedocs.yaml",
|
||||||
"_config.yml",
|
|
||||||
"book.toml",
|
|
||||||
"docs/conf.py",
|
|
||||||
"readthedocs.yml",
|
|
||||||
".readthedocs.yaml",
|
|
||||||
# Package registries
|
# Package registries
|
||||||
".npmrc",
|
".npmrc", ".yarnrc",
|
||||||
".yarnrc",
|
|
||||||
# IDE and Editor
|
|
||||||
".vscode/settings.json",
|
|
||||||
".idea/workspace.xml",
|
|
||||||
".sublime-project",
|
|
||||||
".vim",
|
|
||||||
"_vimrc",
|
|
||||||
# Linting and formatting
|
# Linting and formatting
|
||||||
".isort.cfg",
|
".isort.cfg", ".markdownlint.json", ".markdownlint.yaml",
|
||||||
".markdownlint.json",
|
|
||||||
".markdownlint.yaml",
|
|
||||||
# Security
|
# Security
|
||||||
".bandit",
|
".bandit", ".secrets.baseline",
|
||||||
".secrets.baseline",
|
|
||||||
# Misc
|
# Misc
|
||||||
"CODEOWNERS",
|
".pypirc", ".gitkeep", ".npmignore",
|
||||||
".pypirc",
|
|
||||||
".gitkeep",
|
|
||||||
".npmignore",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
ANYWHERE_IMPORTANT_FILES = [
|
||||||
|
# Build and Compilation
|
||||||
|
"Makefile", "CMakeLists.txt",
|
||||||
|
# Framework-specific
|
||||||
|
"manage.py", "settings.py", # Django
|
||||||
|
"config/routes.rb", "Rakefile", # Ruby on Rails
|
||||||
|
# Language-specific
|
||||||
|
"__init__.py", # Python
|
||||||
|
"stack.yaml", "package.yaml", # Haskell
|
||||||
|
".htaccess", # Apache
|
||||||
|
".bowerrc", # Bower
|
||||||
|
# IDE and Editor
|
||||||
|
".vscode/settings.json", ".idea/workspace.xml", ".sublime-project",
|
||||||
|
".vim", "_vimrc",
|
||||||
|
# Testing
|
||||||
|
"conftest.py",
|
||||||
|
# Documentation
|
||||||
|
"docs/conf.py",
|
||||||
|
]
|
||||||
|
|
||||||
# Normalize IMPORTANT_FILES once
|
# Normalize the lists once
|
||||||
NORMALIZED_IMPORTANT_FILES = [os.path.normpath(path) for path in IMPORTANT_FILES]
|
NORMALIZED_ROOT_IMPORTANT_FILES = [os.path.normpath(path) for path in ROOT_IMPORTANT_FILES]
|
||||||
|
NORMALIZED_ANYWHERE_IMPORTANT_FILES = [os.path.normpath(path) for path in ANYWHERE_IMPORTANT_FILES]
|
||||||
|
|
||||||
def is_important(file_path):
|
def is_important(file_path):
|
||||||
file_name = os.path.basename(file_path)
|
file_name = os.path.basename(file_path)
|
||||||
dir_name = os.path.dirname(file_path)
|
dir_name = os.path.dirname(file_path)
|
||||||
|
normalized_path = os.path.normpath(file_path)
|
||||||
|
|
||||||
# Check for GitHub Actions workflow files
|
# Check for GitHub Actions workflow files
|
||||||
if (
|
if (os.path.basename(dir_name) == "workflows"
|
||||||
os.path.basename(dir_name) == "workflows"
|
|
||||||
and os.path.basename(os.path.dirname(dir_name)) == ".github"
|
and os.path.basename(os.path.dirname(dir_name)) == ".github"
|
||||||
and file_name.endswith(".yml")
|
and file_name.endswith(".yml")):
|
||||||
):
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Check for IDE-specific directories
|
# Check for IDE-specific directories
|
||||||
if file_name in [".idea", ".vscode"]:
|
if file_name in [".idea", ".vscode"]:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
"""
|
# Check if the file is in the root directory and matches ROOT_IMPORTANT_FILES
|
||||||
# Check for Kubernetes config files
|
if os.path.dirname(normalized_path) == '':
|
||||||
if "kubernetes" in os.path.normpath(dir_name).split(os.sep) and file_name.endswith(".yaml"):
|
return any(normalized_path == important_file for important_file in NORMALIZED_ROOT_IMPORTANT_FILES)
|
||||||
return True
|
|
||||||
|
|
||||||
# Check for migration directories
|
|
||||||
if file_name == "migrations" and os.path.isdir(file_path):
|
|
||||||
return True
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Check if the file_path matches any of the NORMALIZED_IMPORTANT_FILES
|
|
||||||
normalized_path = os.path.normpath(file_path)
|
|
||||||
return any(
|
|
||||||
normalized_path == important_file or normalized_path.endswith(os.sep + important_file)
|
|
||||||
for important_file in NORMALIZED_IMPORTANT_FILES
|
|
||||||
)
|
|
||||||
|
|
||||||
|
# Check if the file matches ANYWHERE_IMPORTANT_FILES
|
||||||
|
return any(normalized_path.endswith(os.sep + important_file) for important_file in NORMALIZED_ANYWHERE_IMPORTANT_FILES)
|
||||||
|
|
||||||
def filter_important_files(file_paths):
|
def filter_important_files(file_paths):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue