Overview
The@bunli/plugin-config plugin loads configuration from multiple JSON files and merges them into your CLI’s configuration. This allows users to:
- Store configuration in standard locations
- Override defaults with user-specific settings
- Use project-specific configuration files
Installation
Usage
Default Config Sources
By default, the plugin loads configuration from:~/.config/{{name}}/config.json- User-level config.{{name}}rc- Project root config.{{name}}rc.json- Project root config (explicit JSON).config/{{name}}.json- Project .config directory
{{name}} placeholder is replaced with your CLI name.
Example
For a CLI namedmy-cli, these locations are checked:
Configuration
Custom Sources
Specify custom configuration sources:Merge Strategies
Deep Merge (Default)
Recursively merges nested objects:Shallow Merge
Only merges top-level properties:Load Order
Configs are loaded in source order, with later configs taking precedence:Stop on First
Load only the first found config:Real-World Examples
User + Project Config
~/.config/my-build-tool/defaults.json):
.my-build-toolrc.json):
Environment-Specific Config
Team Shared Config
Error Handling
The plugin gracefully handles missing files:Source Implementation
packages/plugin-config/src/index.ts
Configuration File Format
Config files must be valid JSON:TypeScript Support
Define config types for autocomplete:Best Practices
Use Standard Locations
Follow XDG Base Directory specification:Document Config Options
Provide an example config file:Validate Merged Config
UseconfigResolved hook:
Next Steps
MCP Plugin
Create commands from MCP tools
AI Detection
Detect AI coding assistants
Creating Plugins
Build your own plugins
Configuration
Learn about CLI configuration