Skip to content

feat: support user-level include_patterns / exclude_patterns defaults in global_settings.yml - #306

Open
pranav440 wants to merge 2 commits into
cocoindex-io:mainfrom
pranav440:feat/user-level-patterns-global-settings
Open

pranav440 wants to merge 2 commits into
cocoindex-io:mainfrom
pranav440:feat/user-level-patterns-global-settings

Conversation

@pranav440

Copy link
Copy Markdown
Contributor

Fixes #305

Description

Allows users to define default include_patterns, exclude_patterns, and max_file_size once in ~/.cocoindex_code/global_settings.yml (UserSettings) so that projects on the machine automatically inherit them without duplicating rules across every .cocoindex_code/settings.yml.

Key Changes

  1. UserSettings dataclass: Added include_patterns: list[str] | None = None, exclude_patterns: list[str] | None = None, and max_file_size: int | None = None.
  2. Serialization & Validation:
    • _user_settings_to_dict serializes pattern lists and max_file_size when configured.
    • _user_settings_from_dict validates that patterns are lists of strings and parses human-readable sizes (parse_file_size).
  3. Inheritance & Overrides:
    • _project_settings_from_dict and load_project_settings check project-level settings first; if a project omits include_patterns, exclude_patterns, or max_file_size, it inherits the user-level default (falling back to global defaults if neither is defined).
    • If a project explicitly defines its own patterns, that list replaces the user-level default (replace rather than merge, maintaining predictable behavior).
    • default_project_settings seeds from UserSettings when available.
  4. Unit Tests:
    • Added unit tests in tests/test_settings.py covering user settings YAML round-trip, type validation for invalid patterns, project-level inheritance, and project-level override precedence.

Verification

All 77 unit tests in tests/test_settings.py pass cleanly (77 passed, 4 skipped).

…ts in global_settings.yml

Allows users to define default include_patterns, exclude_patterns, and max_file_size once in ~/.cocoindex_code/global_settings.yml (UserSettings) so projects without custom patterns automatically inherit them.

- Adds include_patterns, exclude_patterns, and max_file_size to UserSettings.
- Serializes and validates user-level pattern lists and file sizes in _user_settings_to_dict and _user_settings_from_dict.
- Updates _project_settings_from_dict and default_project_settings to inherit from UserSettings when project-level fields are omitted.
- Ensures project-level definitions override user defaults cleanly instead of merging.
- Adds comprehensive unit tests covering pattern inheritance, project overrides, and validation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support user-level include_patterns / exclude_patterns defaults in global_settings.yml

1 participant