Add config layering system with user and project defaults - #191
Merged
Merged
Conversation
Implements #98: Config layering and profile defaults Features: - Support for user config at ~/.config/struct/config.yaml for global defaults - Layered config merging: CLI args > project config > user config > built-in defaults - New 'structkit config print' command to display effective configuration - Support for YAML and JSON output formats Changes: - Add structkit/config.py with layered config loading logic - Add structkit/commands/config.py for config command - Update structkit/main.py to integrate config layering - Add comprehensive tests for config layering and command - Update docs/configuration.md with config layering documentation Config precedence order: 1. Built-in defaults (lowest priority) 2. User config (~/.config/struct/config.yaml) 3. Project config (.struct.yaml or --config-file) 4. CLI arguments (highest priority) Fixes #98 Co-authored-by: Kenneth Belitzky <kenny@belitzky.com>
Add comprehensive examples demonstrating: - User config setup at ~/.config/struct/config.yaml - Project config usage - Config precedence and layering - Common use cases and tips Files: - examples/config-layering/README.md - examples/config-layering/user-config-example.yaml - examples/config-layering/project-config-example.yaml Co-authored-by: Kenneth Belitzky <kenny@belitzky.com>
Add documentation for the new 'structkit config print' command: - Command usage and syntax - Description of config layering - Examples of common use cases - Link to comprehensive configuration documentation Co-authored-by: Kenneth Belitzky <kenny@belitzky.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #98
Description
This PR implements a comprehensive config layering system that allows users to set defaults at multiple levels, reducing CLI verbosity and providing a flexible configuration hierarchy.
Key Features
Multi-layer Configuration Support
~/.config/struct/config.yamlfor personal global defaults.struct.yamlor--config-fileflagConfig Precedence Order
New
structkit config printCommandImplementation Details
New Files:
structkit/config.py- Core config layering logic with functions for loading, merging, and applying configurationsstructkit/commands/config.py- Config command withprintsubcommandtests/test_config_layering.py- Comprehensive tests for config layering (15 tests)tests/test_config_command.py- Tests for config command (6 tests)examples/config-layering/- Complete example with README and sample configsModified Files:
structkit/main.py- Integrated layered config loading into main CLI flowdocs/configuration.md- Added comprehensive documentation for config layeringSupported Config Options
All of the following can be set in config files:
structures_path- Path to custom structure definitionssource- Named source for structure definitionsinput_store- Path to the input store filefile_strategy- Strategy for handling existing filesbackup- Path to backup folderglobal_system_prompt- Global system prompt for OpenAInon_interactive- Run in non-interactive modeoutput- Output mode (file/console)log- Logging levellog_file- Path to log fileExample Usage
Create a user config:
View effective config:
Override with CLI args:
See
examples/config-layering/for more comprehensive examples and use cases.Checklist
Screenshots (if applicable)
Example output of
structkit config print:Additional Comments
--config-fileexamples/config-layering/with user and project config templates