|
| 1 | +# Marketplace Plugin Preview - Implementation Plan |
| 2 | + |
| 3 | +## Goal |
| 4 | +When viewing a marketplace plugin, replicate the existing [1]-[6] panel layout to show: |
| 5 | +- **Same panels**: Slash Commands, Subagents, Skills, Memory, MCPs, Hooks |
| 6 | +- **Plugin's content**: Show what customizations the plugin provides |
| 7 | +- **MainPane**: Show selected item content (same as normal mode) |
| 8 | +- Works for **both installed and uninstalled** plugins |
| 9 | + |
| 10 | +This gives users a full preview of plugin contents before installing. |
| 11 | + |
| 12 | +## UX Flow |
| 13 | +1. Press `M` to open marketplace (current modal or new view) |
| 14 | +2. Navigate to a plugin, press `Enter` or `p` to preview |
| 15 | +3. Sidebar shows plugin's [1]-[6] panels with its customizations |
| 16 | +4. Browse like normal mode, MainPane shows content |
| 17 | +5. Press `Esc` to return to marketplace browser |
| 18 | + |
| 19 | +## Complexity Assessment: **Medium-High** |
| 20 | + |
| 21 | +Key challenge: Loading customizations from plugin source directory (not installed path). |
| 22 | + |
| 23 | +## Implementation Steps |
| 24 | + |
| 25 | +### Step 1: Add plugin discovery to ConfigDiscoveryService |
| 26 | +**File:** `src/lazyclaude/services/discovery.py` |
| 27 | + |
| 28 | +Add method to discover customizations from a specific plugin directory (reuses existing `_discover_plugins` pattern): |
| 29 | +```python |
| 30 | +def discover_from_directory( |
| 31 | + self, plugin_dir: Path, plugin_info: PluginInfo | None = None |
| 32 | +) -> list[Customization]: |
| 33 | + """Discover customizations from a specific directory (for plugin preview).""" |
| 34 | + customizations: list[Customization] = [] |
| 35 | + level = ConfigLevel.PLUGIN |
| 36 | + |
| 37 | + # Scan for commands, agents, skills using existing SCAN_CONFIGS |
| 38 | + for config in SCAN_CONFIGS.values(): |
| 39 | + customizations.extend( |
| 40 | + self._scanner.scan_directory(plugin_dir, config, level, plugin_info) |
| 41 | + ) |
| 42 | + |
| 43 | + # Scan for MCPs and hooks using existing methods |
| 44 | + customizations.extend(self._discover_plugin_mcps(plugin_dir, plugin_info)) |
| 45 | + customizations.extend(self._discover_plugin_hooks(plugin_dir, plugin_info)) |
| 46 | + |
| 47 | + return self._sort_customizations(customizations) |
| 48 | +``` |
| 49 | + |
| 50 | +### Step 2: Add plugin path resolution to MarketplaceLoader |
| 51 | +**File:** `src/lazyclaude/services/marketplace_loader.py` |
| 52 | + |
| 53 | +Add method to get plugin source directory: |
| 54 | +```python |
| 55 | +def get_plugin_source_dir(self, plugin: MarketplacePlugin) -> Path | None: |
| 56 | + """Get the source directory for a plugin (installed or from marketplace).""" |
| 57 | + # For installed: use install_path |
| 58 | + if plugin.install_path and plugin.install_path.exists(): |
| 59 | + return plugin.install_path |
| 60 | + |
| 61 | + # For uninstalled: look in marketplace install_location/plugins/<name>/ |
| 62 | + marketplace = self._find_marketplace(plugin.marketplace_name) |
| 63 | + if marketplace: |
| 64 | + return marketplace.entry.install_location / "plugins" / plugin.name |
| 65 | + return None |
| 66 | +``` |
| 67 | + |
| 68 | +### Step 3: Add plugin preview mode to App |
| 69 | +**File:** `src/lazyclaude/app.py` |
| 70 | + |
| 71 | +Add state: |
| 72 | +```python |
| 73 | +self._plugin_preview_mode: bool = False |
| 74 | +self._previewing_plugin: MarketplacePlugin | None = None |
| 75 | +self._plugin_customizations: list[Customization] = [] |
| 76 | +``` |
| 77 | + |
| 78 | +Add preview action: |
| 79 | +```python |
| 80 | +def _enter_plugin_preview(self, plugin: MarketplacePlugin) -> None: |
| 81 | + """Enter plugin preview mode - show plugin's customizations in panels.""" |
| 82 | + plugin_dir = self._marketplace_loader.get_plugin_source_dir(plugin) |
| 83 | + if not plugin_dir or not plugin_dir.exists(): |
| 84 | + self.notify("Plugin source not found", severity="warning") |
| 85 | + return |
| 86 | + |
| 87 | + # Discover plugin's customizations |
| 88 | + self._plugin_customizations = self._discovery.discover_plugin_customizations(plugin_dir) |
| 89 | + self._previewing_plugin = plugin |
| 90 | + self._plugin_preview_mode = True |
| 91 | + |
| 92 | + # Hide marketplace modal/panel |
| 93 | + if self._marketplace_modal: |
| 94 | + self._marketplace_modal.hide() |
| 95 | + |
| 96 | + # Update panels with plugin customizations |
| 97 | + self._update_panels() # Modified to use _plugin_customizations when in preview mode |
| 98 | + |
| 99 | + self._update_subtitle() # Show "Preview: <plugin_name>" |
| 100 | +``` |
| 101 | + |
| 102 | +Modify `_update_panels()`: |
| 103 | +```python |
| 104 | +def _update_panels(self) -> None: |
| 105 | + if self._plugin_preview_mode: |
| 106 | + # Use plugin customizations instead of global |
| 107 | + customizations = self._plugin_customizations |
| 108 | + else: |
| 109 | + customizations = self._filter_service.filter(...) |
| 110 | + # ... rest of panel update logic |
| 111 | +``` |
| 112 | + |
| 113 | +Exit preview: |
| 114 | +```python |
| 115 | +def _exit_plugin_preview(self) -> None: |
| 116 | + self._plugin_preview_mode = False |
| 117 | + self._previewing_plugin = None |
| 118 | + self._plugin_customizations = [] |
| 119 | + self._update_panels() |
| 120 | + self._update_subtitle() |
| 121 | + # Re-show marketplace |
| 122 | + if self._marketplace_modal: |
| 123 | + self._marketplace_modal.show() |
| 124 | +``` |
| 125 | + |
| 126 | +### Step 4: Add preview binding to MarketplaceModal |
| 127 | +**File:** `src/lazyclaude/widgets/marketplace_modal.py` |
| 128 | + |
| 129 | +Add binding and message: |
| 130 | +```python |
| 131 | +Binding("enter", "preview_plugin", "Preview", show=False), |
| 132 | +# or |
| 133 | +Binding("p", "preview_plugin", "Preview", show=False), |
| 134 | + |
| 135 | +class PluginPreview(Message): |
| 136 | + def __init__(self, plugin: MarketplacePlugin) -> None: |
| 137 | + self.plugin = plugin |
| 138 | + super().__init__() |
| 139 | + |
| 140 | +def action_preview_plugin(self) -> None: |
| 141 | + node = self._tree.cursor_node |
| 142 | + if node and isinstance(node.data, MarketplacePlugin): |
| 143 | + self.post_message(self.PluginPreview(node.data)) |
| 144 | +``` |
| 145 | + |
| 146 | +Update footer for plugins: |
| 147 | +```python |
| 148 | +"[bold]Enter[/] Preview [bold]i[/] Install ..." |
| 149 | +``` |
| 150 | + |
| 151 | +### Step 5: Handle Esc in preview mode |
| 152 | +**File:** `src/lazyclaude/app.py` |
| 153 | + |
| 154 | +Modify escape handling: |
| 155 | +```python |
| 156 | +def action_escape(self) -> None: |
| 157 | + if self._plugin_preview_mode: |
| 158 | + self._exit_plugin_preview() |
| 159 | + elif self._marketplace_modal and self._marketplace_modal.is_visible: |
| 160 | + # ... existing modal close logic |
| 161 | +``` |
| 162 | + |
| 163 | +### Step 6: Update StatusPanel/subtitle |
| 164 | +Show current mode in status: |
| 165 | +- Normal: `~/.claude | All` |
| 166 | +- Preview: `Preview: handbook | Plugin` |
| 167 | + |
| 168 | +## Files Summary |
| 169 | + |
| 170 | +| File | Action | Changes | |
| 171 | +|------|--------|---------| |
| 172 | +| `src/lazyclaude/services/discovery.py` | Modify | Add `discover_from_directory()` method | |
| 173 | +| `src/lazyclaude/services/marketplace_loader.py` | Modify | Add `get_plugin_source_dir()` method | |
| 174 | +| `src/lazyclaude/app.py` | Modify | Add preview mode state, handlers, modify `_update_panels()` | |
| 175 | +| `src/lazyclaude/widgets/marketplace_modal.py` | Modify | Add `Enter` preview binding, `PluginPreview` message | |
| 176 | + |
| 177 | +## Key Advantages |
| 178 | + |
| 179 | +1. **Full reuse**: All existing panels, MainPane, navigation work as-is |
| 180 | +2. **Accurate preview**: Users see exactly what they'll get |
| 181 | +3. **No new widgets**: Just mode switching and customization source change |
| 182 | +4. **Works for uninstalled**: Load from marketplace source directory |
| 183 | + |
| 184 | +--- |
| 185 | +# This file is a copy of original plan ~/.claude/plans/abundant-baking-rose.md |
0 commit comments