You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements a hierarchical configuration system for the MyCoder CLI with 4 levels of precedence:
1. CLI options (highest precedence)
2. Project-level config (.mycoder/config.json in current directory)
3. Global config (~/.mycoder/config.json)
4. Default values (lowest precedence)
- Enhanced settings.ts to support both global and project-level config directories
- Refactored config.ts to implement hierarchical configuration merging
- Updated the config command to support the --global / -g flag
- Added enhanced display of config sources in the list and get commands
- Added error handling for cases where project directory is not writable
Closes#153
* add --githubMode and --userPrompt as boolean CLI options that override config settings ([0390f94](https://github.com/drivecore/mycoder/commit/0390f94651e40de93a8cb9486a056a0b9cb2e165))
7
-
* remove modelProvider and modelName - instant decrepation ([59834dc](https://github.com/drivecore/mycoder/commit/59834dcf932051a5c75624bd6f6ab12254f43769))
5
+
- add --githubMode and --userPrompt as boolean CLI options that override config settings ([0390f94](https://github.com/drivecore/mycoder/commit/0390f94651e40de93a8cb9486a056a0b9cb2e165))
6
+
- implement hierarchical configuration system with project and global levels ([#153](https://github.com/drivecore/mycoder/issues/153))
7
+
- remove modelProvider and modelName - instant decrepation ([59834dc](https://github.com/drivecore/mycoder/commit/59834dcf932051a5c75624bd6f6ab12254f43769))
* change where anthropic key is declared ([f6f72d3](https://github.com/drivecore/mycoder/commit/f6f72d3bc18a65fc775151cd375398aba230a06f))
15
-
* ensure npm publish only happens on release branch ([ec352d6](https://github.com/drivecore/mycoder/commit/ec352d6956c717726ef388a07d88372c12b634a6))
16
-
13
+
- change where anthropic key is declared ([f6f72d3](https://github.com/drivecore/mycoder/commit/f6f72d3bc18a65fc775151cd375398aba230a06f))
14
+
- ensure npm publish only happens on release branch ([ec352d6](https://github.com/drivecore/mycoder/commit/ec352d6956c717726ef388a07d88372c12b634a6))
This PR implements a hierarchical configuration system for the mycoder CLI with 4 levels of precedence:
4
+
5
+
1. CLI options (highest precedence)
6
+
2. Project-level config (.mycoder/config.json in current directory)
7
+
3. Global config (~/.mycoder/config.json)
8
+
4. Default values (lowest precedence)
9
+
10
+
## Changes
11
+
12
+
- Enhanced `settings.ts` to support both global and project-level config directories
13
+
- Refactored `config.ts` to implement hierarchical configuration merging
14
+
- Updated the `config` command to support the `--global` / `-g` flag for storing settings at the global level
15
+
- Added enhanced display of config sources in the `list` and `get` commands
16
+
- Added tests for the hierarchical configuration system
17
+
18
+
## Usage Examples
19
+
20
+
```bash
21
+
# Set a project-level config (default)
22
+
mycoder config set githubMode true
23
+
24
+
# Set a global config
25
+
mycoder config set model claude-3-opus --global
26
+
# or using the short flag
27
+
mycoder config set provider anthropic -g
28
+
29
+
# List all settings (showing merged config with source indicators)
30
+
mycoder config list
31
+
32
+
# List only global settings
33
+
mycoder config list --global
34
+
35
+
# Get a specific setting (showing source)
36
+
mycoder config get model
37
+
38
+
# Clear a setting at project level
39
+
mycoder config clear githubMode
40
+
41
+
# Clear a setting at global level
42
+
mycoder config clear model --global
43
+
44
+
# Clear all project settings
45
+
mycoder config clear --all
46
+
47
+
# Clear all global settings
48
+
mycoder config clear --all --global
49
+
```
50
+
51
+
## Implementation Details
52
+
53
+
The configuration system now uses the [deepmerge](https://github.com/TehShrike/deepmerge) package to properly merge configuration objects from different levels. When retrieving configuration, it starts with the defaults and progressively applies global, project, and CLI options.
54
+
55
+
When displaying configuration, the system now shows the source of each setting (project, global, or default) to make it clear where each value is coming from.
56
+
57
+
## Testing
58
+
59
+
Added unit tests to verify the hierarchical configuration system works as expected.
0 commit comments