Add backend plugin architecture and library proof-of-concept#219
Draft
davewaring wants to merge 16 commits intomainfrom
Draft
Add backend plugin architecture and library proof-of-concept#219davewaring wants to merge 16 commits intomainfrom
davewaring wants to merge 16 commits intomainfrom
Conversation
Implements Phase 1 & 2 of library-integration project: Endpoints: - GET /api/v1/fs/config - Get Library configuration (path, exists) - GET /api/v1/fs/read - Read file content - POST /api/v1/fs/write - Create/replace file - POST /api/v1/fs/append - Append to file - GET /api/v1/fs/list - List directory contents - DELETE /api/v1/fs/delete - Delete file (admin only) - POST /api/v1/fs/init - Initialize Library with starter content Configuration: - LIBRARY_PATH setting in config.py (default: ~/BrainDrive-Library) - Supports .env override - Tilde expansion for home directory Security: - Path traversal prevention - Restricted to text file extensions (.md, .txt, .json, .yaml, .yml) - Delete requires admin authentication - All endpoints require user authentication See: projects/active/library-integration/build-plan.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements core infrastructure for backend plugins that can register REST API endpoints dynamically without modifying core code. Phase 1 - Core Infrastructure: - Add @plugin_endpoint decorator for marking endpoint functions - Add PluginRouteLoader for dynamic route loading/unloading - Add admin endpoint POST /admin/plugins/reload-routes - Integrate route loader with app startup Phase 2.1 - Plugin Database Model: - Add plugin_type field (frontend/backend/fullstack) - Add endpoints_file field for Python endpoint file - Add route_prefix field for URL prefix - Add backend_dependencies field (JSON list of slugs) - Add Alembic migration for new fields Also includes: - Library API append-file endpoint for writing to project docs - CORS config property helpers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… 2.2-2.3) Phase 2.2 - Extend BaseLifecycleManager: - Add module documentation for backend plugin support - Add VALID_PLUGIN_TYPES constant (frontend, backend, fullstack) - Update validate_plugin_metadata() with backend field validation - Require endpoints_file for backend/fullstack plugins - Validate backend_dependencies is a list, route_prefix starts with / - Add is_backend_plugin() and get_backend_metadata() helper methods Phase 2.3 - Update Plugin Repository: - Add get_backend_plugins(user_id) - returns backend/fullstack plugins - Add get_enabled_backend_plugins(user_id) - enabled backend plugins only - Add get_plugins_depending_on(backend_slug, user_id) - for cascade disable - Add get_all_enabled_backend_plugins() - for route loader startup Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 3.1 - Route Reload Triggers:
- Add _trigger_route_reload_if_backend() helper for route reloads
- Trigger reload after install/uninstall/update of backend plugins
- Support all install methods: local, GitHub, file upload, remote URL
Phase 3.2 - Cascade Disable:
- Update PATCH /plugins/{plugin_id} to cascade-disable dependent plugins
- When disabling backend plugin, find and disable dependents first
- Return cascade_disabled list in response for transparency
- Trigger route reload after enable/disable of backend plugins
Phase 3.3 - Auto-Install Backend Dependencies:
- Add _auto_install_backend_dependencies() to check plugin metadata
- Auto-install missing backend dependencies before main plugin
- Return auto_installed_dependencies in response
- Fail with clear error if required dependency cannot be installed
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Frontend: - Add PluginTypeTabs component (All/Frontend/Backend/Fullstack) - Add BackendPluginWarningDialog for security warnings - Add backend/fullstack badges to ModuleCard - Add dependency relationships display in ModuleDetailHeader - Add cascade disable confirmation dialog - Add pluginType filter support to useModules hook and moduleService - Add plugin_type to installer types and InstallationResult Backend: - Fix route_loader.py: Change prefix from /api/v1/plugins to /api/v1/plugin-api to avoid removing core plugin management routes - Add plugin_type filter parameter to /plugins/manager endpoint - Add pluginType field to module response from parent plugin Co-Authored-By: Claude <noreply@anthropic.com>
Creates the braindrive-library backend plugin as proof of concept
for the backend plugin architecture.
**Plugin Structure:**
- `backend/plugins/shared/braindrive-library/v1/`
- `lifecycle_manager.py` - Plugin metadata and lifecycle hooks
- `endpoints.py` - REST API endpoints using @plugin_endpoint decorator
**Endpoints:**
- `GET /plugin-api/braindrive-library/library/projects` - List projects by lifecycle
- `GET /plugin-api/braindrive-library/library/project/{slug}/context` - Get project context
- `POST /plugin-api/braindrive-library/library/projects` - Create new project
**Configuration:**
- Added LIBRARY_PATH to config.py (default: ~/BrainDrive-Library)
- Updated .gitignore to track backend/plugins/shared/
**Project:** library-integration
**Related:** modularizing-backend (provides plugin architecture)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds POST /append-file endpoint with path traversal validation, extension allowlisting, and project existence checks. Includes tests for happy path and validation rejections. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…E.md Phase 6 of library-integration: creates Chat plugin v1.0.26 with Library scope support (menu item, project selection submenu, visual indicator, context injection), adds frontend tests (LibraryIntegration + LibraryService), E2E backend tests covering the full user journey, and repo CLAUDE.md. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Routes for enabled backend plugins (e.g. braindrive-library) are now loaded automatically when the server starts, using the lifespan handler. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move closeAllMenus() before parent callbacks to prevent re-render race condition. Also exclude test files from webpack and tsconfig builds. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove redundant onLibraryToggle() calls from handleLibrarySelectProject and handleLibrarySelectAll in ChatInput. The onLibrarySelectProject handler already sets enabled: true, so the subsequent toggle was reversing it back to false due to React setState batching. Co-Authored-By: Claude Opus 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\n- add backend plugin route loader, decorator, admin reload, and startup integration\n- extend plugin metadata/model/repository for backend plugins\n- integrate lifecycle operations (reload, cascade disable, auto-install deps)\n- add Plugin Manager UI support for backend plugins\n- add BrainDrive Library backend plugin proof-of-concept\n- add backend plugin docs + integration tests\n\n## Testing\n- pytest -q backend/tests/test_backend_plugin_integration.py\n