feat: support hierarchical config structure for oh-my-opencode#7
Merged
feat: support hierarchical config structure for oh-my-opencode#7
Conversation
Refactor configuration handling to support arbitrary nested structures in both opencode and oh-my-opencode configs using recursive merge functions. This makes the plugin future-proof against structure changes. Changes: - Add HierarchicalPreset type for recursive structure representation - Replace flat structure with recursive model/variant merge logic - Implement deepMergeModel for preserving non-model properties - Add recursive drift detection with hasDriftRecursive - Update status display to show hierarchical tree format Benefits: - Works with agents/categories structure in oh-my-opencode - Preserves custom properties (piyo, abc, etc.) during mode switches - No code changes needed when config structure evolves - Unified approach for both opencode and oh-my-opencode Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extract duplicate type guard and helper functions into dedicated modules to improve code organization and reduce duplication. Changes: - Extract isObject to src/config/guards.ts (shared utility) - Move test helpers to src/test-utils/recursive-helpers.ts - Extract isLeafNode helper for better code clarity - Add comprehensive JSDoc documentation to helpers Benefits: - Reduced code duplication across test and production code - Better separation of concerns - Improved testability by isolating recursive logic - Enhanced code readability with descriptive helper names Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ility Fixed deepMergeModel to correctly merge all preset properties (including new properties like color, icon, etc.) by changing spread order from valueRecord -> existing to existing -> valueRecord. Fixed hasConfigDrift to detect drift on all preset properties, not just model and variant. This ensures that newly added properties in presets are properly applied on opencode startup. Changes: - deepMergeModel: Corrected spread order to existing -> valueRecord - hasDriftRecursive: Check all preset properties instead of just model/variant - hasConfigDrift: Added early return when no configs exist, simplified nested conditions - switchMode: Changed toast to fire-and-forget pattern - Added tests for new property merging and drift detection Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixed deepMergeModel and hasDriftRecursive to properly handle ALL
preset properties, not just model and variant. This ensures that
new properties (color, icon, etc.) added to presets are correctly
merged into configs and drift is properly detected.
Changes:
- deepMergeModel: Spread entire preset instead of just model/variant
- hasDriftRecursive: Check all preset properties, not just model/variant
- Add tests for new property merging and drift detection
Example:
Preset with { model: "new", color: "blue" } now correctly merges
into existing config { model: "old", temp: 0.5 } resulting in
{ model: "new", temp: 0.5, color: "blue" }.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.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.
Summary
Refactor configuration handling to support arbitrary nested structures in both opencode and oh-my-opencode configs using recursive merge functions. This makes the plugin future-proof against structure changes.
Changes
Type System
HierarchicalPresettype for recursive structure representationModelConfigfully generic with[key: string]: unknownCore Functionality
deepMergeModelfor preserving non-model properties during mode switcheshasDriftRecursivefor hierarchical drift detectionformatHierarchicalTreeto show hierarchical tree formatCode Organization
isObjecttosrc/config/guards.ts(shared utility)src/test-utils/recursive-helpers.tsisLeafNodehelper for better code clarityTest Plan
bun run typecheck)bun run lint)bun run build)Benefits
🤖 Generated with Claude Code