Skip to content

feat(plugins): add advanced plugin system with full TUI customization#551

Merged
echobt merged 10 commits intomasterfrom
feat/plugins-advanced-tui-system-1769999160
Feb 2, 2026
Merged

feat(plugins): add advanced plugin system with full TUI customization#551
echobt merged 10 commits intomasterfrom
feat/plugins-advanced-tui-system-1769999160

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Feb 2, 2026

Summary

This PR introduces a comprehensive enhancement to the plugin system, enabling developers to fully customize the CLI and TUI through plugins.

Changes

TUI Event Hooks

  • Add event hooks for all TUI interactions (key press, mouse, focus, scroll)
  • Support for intercepting and modifying TUI events before processing
  • Plugin lifecycle events for TUI initialization/shutdown

UI Hooks Expansion

  • Advanced TUI customization types (panels, widgets, themes)
  • Layout customization hooks for panel arrangement
  • Theme override capabilities
  • Custom widget registration system

Hook Registry

  • Full TUI hook support with priority-based execution
  • Widget, keybinding, and theme registration
  • Event interception and modification hooks

SDK Enhancements

  • Hot-reload support for plugin development
  • Comprehensive plugin templates
  • Builder patterns for hook registration

Command Completion

  • Plugin-powered command autocompletion
  • Dynamic completion suggestions based on context

Security Improvements

  • Path traversal protection
  • Sandboxed file system access
  • Permission validation for sensitive operations
  • Rate limiting for resource-intensive hooks

Testing

  • cargo check passes
  • All existing functionality preserved
  • Security measures validated

echobt added 10 commits February 2, 2026 01:26
- Add UiRegion enum for content injection zones (header, footer, sidebars, overlays)
- Add comprehensive style types: Color, TextStyle, WidgetStyle, BorderStyle
- Add WidgetSize/WidgetConstraints for layout control
- Expand UiWidget with Text, List, Table, Gauge, Sparkline, layouts, Block
- Add keyboard binding types: KeyBinding, KeyModifier, KeyBindingResult
- Add ThemeColors and ThemeOverride for dynamic theming
- Add hooks: WidgetRegisterHook, KeyBindingHook, ThemeOverrideHook
- Add LayoutCustomizeHook with LayoutPanel and LayoutDirection
- Add ModalInjectHook with ModalDefinition and ModalLayer
- Add ToastShowHook with ToastDefinition and ToastLevel
- All public types documented, 9 unit tests passing
- Add TypeScript template for JS/TS plugin development
- Add tsconfig.json template for TypeScript plugins
- Add hot-reload configuration template with watch patterns and debounce
- Add testing utilities template with MockContext and MockToolInput
- Add advanced Rust template with TUI hooks, widgets, and keybindings
- Add HotReloadConfig struct with builder pattern
- Add scaffold_advanced() method for advanced plugin scaffolding
- Add tests for all new generator functions
Add comprehensive hook registration support for all TUI-related hooks:
- UI hooks: UiRender, WidgetRegister, KeyBinding, ThemeOverride,
  LayoutCustomize, ModalInject, ToastShow
- TUI event hooks: TuiEventSubscribe, TuiEventDispatch,
  CustomEventEmit, EventIntercept, AnimationFrame
- Additional hooks: CommandExecuteBefore/After, InputIntercept,
  SessionStart/End, FocusChange

Each hook type includes:
- Registered hook wrapper struct with plugin_id, hook, and priority
- Registration method with priority-based sorting
- Unregistration support via unregister_plugin()
- Hook count tracking via hook_count() and total_hook_count()
- Plugin tracking via registered_plugins()
…stem

WASM Runtime DoS Protection:
- Add fuel-based CPU limiting (10M operations max)
- Add epoch interruption support for timeout handling
- Implement ResourceLimiter with 16MB memory cap
- Add table/instance/memory limits
- Remove panic-prone Default impl for WasmRuntime

Path Traversal Prevention:
- Canonicalize all paths before access checks
- Resolve symlinks to prevent traversal via symlinks
- Validate paths stay within allowed boundaries
- Handle non-existent paths safely for write operations

Fail-Closed Security Model:
- Empty command allowlist now denies all commands
- Empty domain allowlist now denies all network access
- None allowed_domains denies network access
- Explicit opt-in required via '*' wildcard

SSRF Protection:
- Block localhost/loopback addresses (127.0.0.1, ::1, etc.)
- Block private IP ranges (10.x, 172.16-31.x, 192.168.x)
- Block link-local addresses (169.254.x.x)
- Block .local/.internal domain suffixes
- Block dangerous ports (SSH, databases, etc.)
- Allow only http/https protocols

Permission Hook Security:
- Document security implications of Allow decision
- Add requires_elevated_trust() method
- Add validate_for_third_party() method

Hook Priority Security:
- Reserve priorities 0-49 for system use
- Add SYSTEM_CRITICAL, SYSTEM, SYSTEM_HIGH constants
- Add PLUGIN_MIN (50), PLUGIN_HIGH (75) for third-party
- Add validate_for_plugin() method
- Deprecate HIGHEST/HIGH in favor of explicit names

SDK Safety Documentation:
- Add SAFETY comments to all unsafe FFI calls
- Document host contract assumptions
@echobt echobt merged commit ff6f17c into master Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments