Implemented a feature to show clear diffs when plugins are hot-reloaded, making it easier for developers to verify reload results during iterative plugin development.
-
PluginSnapshot: Captures plugin state at a point in time- Name, version, capabilities, commands, formatters, dependencies
-
PluginReloadDiff: Represents changes detected during reload- Version changes (old → new)
- Capability changes (enabled/disabled)
- Commands added/removed
- Formatters added/removed
- Dependencies added/removed
reload_plugin(): Now returnsPluginResult<PluginReloadDiff>instead ofPluginResult<()>- Captures plugin state before reload
- Captures plugin state after reload
- Computes diff between states
- Emits concise summary to logs
- Automatic change detection: Tracks all plugin metadata changes
- Sorted output: All lists (commands, formatters, dependencies) are sorted for consistent output
- Concise summaries: Human-readable format showing only what changed
- No changes detection: Special message when plugin reloads with no changes
- Exported
PluginReloadDifftype for use by other modules
Added section on "Hot-Reload with Change Detection" explaining:
- What changes are detected
- Example reload output
- Benefits for iterative development
Enhanced "Hot-Reload Support" section with:
- Detailed explanation of change detection
- Example outputs for various scenarios
- Benefits for plugin developers
Added 8 new test cases:
reload_diff_detects_version_changereload_diff_detects_capability_changesreload_diff_detects_added_and_removed_commandsreload_diff_detects_added_and_removed_formattersreload_diff_detects_dependency_changesreload_diff_reports_no_changes_when_identicalreload_diff_summary_is_concise_and_readable
Plugin 'example-logger' reload changes:
Version: 1.0.0 → 1.1.0
Capabilities:
provides_commands: false → true
Commands added: log-stats, clear-log
Formatters added: json-formatter
Dependencies added: helper-plugin
Plugin 'example-logger' reloaded with no changes
✅ Plugin reloads emit a concise diff of added, removed, and changed capabilities
✅ Developers can verify the reload result immediately
✅ Tests are added for the changed behavior
✅ User-facing docs are updated
src/plugin/registry.rs- Core implementationsrc/plugin/mod.rs- Module exportssrc/plugin/README.md- User documentationdocs/plugin-api.md- API documentation
- Compare versions (string equality)
- Compare each capability field (boolean equality)
- Convert command/formatter/dependency lists to HashSets
- Compute set differences for added/removed items
- Sort all result lists for consistent output
- Uses
Displaytrait implementation for easy printing - Hierarchical indentation for readability
- Only shows sections with changes
- Special handling for "no changes" case
- Immediate feedback: Developers know instantly what changed
- Trust: Clear verification that changes were loaded correctly
- Debugging: Easier to spot unintended changes or regressions
- Documentation: Reload output serves as a change log
Potential improvements for future iterations:
- Colorized output for better visual distinction
- Detailed command/formatter signature changes
- Performance metrics (reload time)
- Rollback capability on failed reloads