Description
Add a global configuration option to exclude sensitive files from being included in any context document, with seamless integration of existing .gitignore
patterns to leverage established exclusion rules.
Proposed Solution
Configuration Structure
Add a new top-level exclude
section with an option to respect .gitignore
files:
$schema: https://raw.githubusercontent.com/context-hub/generator/refs/heads/main/json-schema.json
# Global exclusion patterns
exclude:
# File patterns to exclude globally
patterns:
- "**/.env*"
- "**/config/secrets.yaml"
- "**/*.pem"
- "**/*.key"
- "**/id_rsa"
- "**/credentials.json"
# Paths to exclude globally
paths:
- ".secrets/"
- "config/credentials/"
# GitIgnore integration
gitignore:
enabled: true # Whether to respect .gitignore files
paths: # Optional: specific .gitignore files to use
- ".gitignore" # Project root .gitignore
- "submodules/**/.gitignore" # Submodule .gitignore files
ignoreGlobalGitignore: false # Whether to ignore global .gitignore files
# Regular configuration continues
documents:
- description: "Project Documentation"
outputPath: "docs/project.md"
# ...
Implementation Plan
-
GitIgnore Integration:
- Parse and respect .gitignore files throughout the project
- Support hierarchical .gitignore rules (parent directories, subdirectories)
- Parse global .gitignore files when applicable
-
Exclusion Priority:
- Global explicit exclusions (highest priority)
- Document-level explicit exclusions
- .gitignore patterns (respecting hierarchy)
- Source-specific exclusions
-
Configuration Options:
- Toggle .gitignore support
- Specify additional .gitignore files to respect
- Option to ignore global .gitignore files
-
Performance Optimization:
- Cache parsed .gitignore rules for better performance
- Optimize path matching algorithms for large codebases
-
CLI Support:
- Add a global flag to enable/disable .gitignore integration
- Allow specifying additional exclusions via command line
Benefits
- Leverage Existing Patterns: Reuse carefully crafted .gitignore patterns that already exclude sensitive files
- Consistency with Git Workflows: Files excluded from Git are likely candidates for exclusion from context
- No Duplication Required: Avoids having to maintain two separate sets of exclusion patterns
- Project-Specific Adaptability: Respects the granular .gitignore rules that may exist in complex projects
Example Use Cases
- A development team can instantly leverage their extensive .gitignore configuration without additional setup
- Organizations can combine global security policies (in CTX config) with project-specific exclusions (.gitignore)
- New projects get immediate protection from credential exposure by using standard .gitignore templates
Metadata
Metadata
Assignees
Labels
Type
Projects
Status