Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Add audit fallback, builtin extensions, and ports

Juan Denisb4f5a466ce02
diff --git a/AGENTS.md b/AGENTS.md
index e8822922..96643fba 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -9,12 +9,12 @@ ServerKit is a server control panel for managing web applications, databases, Do
## Development Commands
```bash
-# Backend (port 5000, hot-reload)
+# Backend (launcher default port 47927, hot-reload)
cd backend && python -m venv venv && source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python run.py
-# Frontend (port 5173, Vite HMR)
+# Frontend (launcher default port 41921, Vite HMR)
cd frontend && npm install && npm run dev
# Both at once (Linux/WSL)
diff --git a/CLAUDE.md b/CLAUDE.md
index dd9cd25a..88447dd7 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -9,12 +9,12 @@ ServerKit is a server control panel for managing web applications, databases, Do
## Development Commands
```bash
-# Backend (port 5000, hot-reload)
+# Backend (launcher default port 47927, hot-reload)
cd backend && python -m venv venv && source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python run.py
-# Frontend (port 5173, Vite HMR)
+# Frontend (launcher default port 41921, Vite HMR)
cd frontend && npm install && npm run dev
# Both at once (Linux/WSL)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4ea92448..ae23d22a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -20,7 +20,7 @@ chmod +x ./scripts/dev/*.sh
./dev.sh
```
-Open http://localhost:5173 — login: `admin` / `admin`
+Open http://localhost:41921 — login: `admin` / `admin`
> **Troubleshooting:** If you get `bad interpreter` error, fix line endings:
> ```bash
diff --git a/Dockerfile b/Dockerfile
index b3d3866b..f9204160 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,6 +9,7 @@
#
# Build: docker build -t serverkit .
# Run: docker run -d -p 5000:5000 --env-file .env serverkit
+# Override the internal backend port with SERVERKIT_BACKEND_PORT if needed.
# ============================================
# Stage 1: Build Frontend
@@ -36,7 +37,7 @@ FROM python:3.11-slim-bookworm
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
FLASK_ENV=production \
- PORT=5000
+ SERVERKIT_BACKEND_PORT=5000
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -92,17 +93,10 @@ EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
- CMD curl -f http://localhost:5000/api/v1/system/health || exit 1
+ CMD curl -f "http://localhost:${SERVERKIT_BACKEND_PORT:-5000}/api/v1/system/health" || exit 1
# Working directory for the backend
WORKDIR /app/backend
# Default command - use gunicorn for production
-CMD ["gunicorn", \
- "--worker-class", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", \
- "--workers", "1", \
- "--bind", "0.0.0.0:5000", \
- "--timeout", "120", \
- "--access-logfile", "-", \
- "--error-logfile", "-", \
- "run:app"]
+CMD ["sh", "-c", "exec gunicorn --worker-class geventwebsocket.gunicorn.workers.GeventWebSocketWorker --workers 1 --bind 0.0.0.0:${SERVERKIT_BACKEND_PORT:-5000} --timeout 120 --access-logfile - --error-logfile - run:app"]
diff --git a/backend/.env.example b/backend/.env.example
index 1ba9c075..f104e7ad 100644
--- a/backend/.env.example
+++ b/backend/.env.example
@@ -14,10 +14,10 @@ DATABASE_URL=sqlite:///serverkit.db
JWT_SECRET_KEY=change-this-to-another-secure-random-string
# CORS - comma-separated list of allowed origins
-CORS_ORIGINS=http://localhost:5173,http://localhost:3000
+CORS_ORIGINS=http://localhost:41921,http://127.0.0.1:41921,http://localhost:47927,http://127.0.0.1:47927
# Server
-PORT=5000
+PORT=47927
# Security - Agent API Secret Encryption
# IMPORTANT: Generate a unique key for production!
diff --git a/backend/Dockerfile b/backend/Dockerfile
index 8f78167b..bb9d3e20 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -5,7 +5,7 @@ FROM python:3.11-slim-bookworm
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
FLASK_ENV=production \
- PORT=5000
+ SERVERKIT_BACKEND_PORT=5000
# Set working directory
WORKDIR /app
@@ -57,10 +57,7 @@ EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
- CMD curl -f http://localhost:5000/api/v1/system/health || exit 1
+ CMD curl -f "http://localhost:${SERVERKIT_BACKEND_PORT:-5000}/api/v1/system/health" || exit 1
# Run with gunicorn + gevent for WebSocket support
-CMD ["gunicorn", "-k", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", \
- "-w", "1", "-b", "0.0.0.0:5000", "--timeout", "120", \
- "--access-logfile", "-", "--error-logfile", "-", \
- "run:app"]
+CMD ["sh", "-c", "exec gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 -b 0.0.0.0:${SERVERKIT_BACKEND_PORT:-5000} --timeout 120 --access-logfile - --error-logfile - run:app"]
diff --git a/backend/app/__init__.py b/backend/app/__init__.py
index e405adfe..ee3b1bb2 100644
--- a/backend/app/__init__.py
+++ b/backend/app/__init__.py
@@ -61,12 +61,16 @@ def create_app(config_name=None):
from app.middleware.api_key_auth import register_api_key_auth
register_api_key_auth(app)
- # Register API analytics middleware
- from app.middleware.api_analytics import register_api_analytics
- register_api_analytics(app)
-
- # Update rate limiter with custom key function
- from app.middleware.rate_limit import get_rate_limit_key, register_rate_limit_headers
+ # Register API analytics middleware
+ from app.middleware.api_analytics import register_api_analytics
+ register_api_analytics(app)
+
+ # Register fallback audit logging for authenticated mutating API requests
+ from app.middleware.audit import register_audit_fallback
+ register_audit_fallback(app)
+
+ # Update rate limiter with custom key function
+ from app.middleware.rate_limit import get_rate_limit_key, register_rate_limit_headers
limiter._key_func = get_rate_limit_key
register_rate_limit_headers(app)
diff --git a/backend/app/api/marketplace.py b/backend/app/api/marketplace.py
index 5a0874bb..c24ac91c 100644
--- a/backend/app/api/marketplace.py
+++ b/backend/app/api/marketplace.py
@@ -1,6 +1,8 @@
from flask import Blueprint, request, jsonify
from flask_jwt_extended import jwt_required
from app.services.marketplace_service import MarketplaceService
+from app.services.audit_service import AuditService
+from app.models.audit_log import AuditLog
marketplace_bp = Blueprint('marketplace', __name__)
@@ -44,6 +46,13 @@ def create_extension():
return jsonify({'error': 'name required'}), 400
try:
ext = MarketplaceService.create_extension(data, user.id)
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_CREATE,
+ user_id=user.id,
+ target_type='marketplace_extension',
+ target_id=ext.id,
+ details={'name': ext.name, 'slug': ext.slug, 'version': ext.version},
+ )
return jsonify(ext.to_dict()), 201
except ValueError as e:
return jsonify({'error': str(e)}), 400
@@ -59,6 +68,13 @@ def update_extension(ext_id):
ext = MarketplaceService.update_extension(ext_id, data)
if not ext:
return jsonify({'error': 'Not found'}), 404
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_UPDATE,
+ user_id=user.id,
+ target_type='marketplace_extension',
+ target_id=ext.id,
+ details={'name': ext.name, 'slug': ext.slug, 'updated_fields': sorted((data or {}).keys())},
+ )
return jsonify(ext.to_dict())
@@ -71,6 +87,13 @@ def publish_extension(ext_id):
ext = MarketplaceService.publish_extension(ext_id)
if not ext:
return jsonify({'error': 'Not found'}), 404
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_UPDATE,
+ user_id=user.id,
+ target_type='marketplace_extension',
+ target_id=ext.id,
+ details={'name': ext.name, 'slug': ext.slug, 'status': ext.status, 'operation': 'publish'},
+ )
return jsonify(ext.to_dict())
@@ -80,8 +103,17 @@ def delete_extension(ext_id):
user = get_current_user()
if not user or not user.is_admin:
return jsonify({'error': 'Admin access required'}), 403
+ ext = MarketplaceService.get_extension(ext_id)
+ audit_details = {'name': ext.name if ext else None, 'slug': ext.slug if ext else None}
if not MarketplaceService.delete_extension(ext_id):
return jsonify({'error': 'Not found'}), 404
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_DELETE,
+ user_id=user.id,
+ target_type='marketplace_extension',
+ target_id=ext_id,
+ details=audit_details,
+ )
return jsonify({'message': 'Extension deleted'})
@@ -100,6 +132,18 @@ def install_extension(ext_id):
data = request.get_json() or {}
try:
install = MarketplaceService.install_extension(ext_id, user.id, data.get('config'))
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_INSTALL,
+ user_id=user.id,
+ target_type='marketplace_extension',
+ target_id=ext_id,
+ details={
+ 'install_id': install.id,
+ 'extension_id': install.extension_id,
+ 'extension_name': install.extension.display_name if install.extension else None,
+ 'version': install.installed_version,
+ },
+ )
return jsonify(install.to_dict()), 201
except ValueError as e:
return jsonify({'error': str(e)}), 400
@@ -111,18 +155,42 @@ def uninstall_extension(install_id):
user = get_current_user()
if not user or not user.is_admin:
return jsonify({'error': 'Admin access required'}), 403
+ install = MarketplaceService.get_install(install_id)
+ audit_details = {
+ 'extension_id': install.extension_id if install else None,
+ 'extension_name': install.extension.display_name if install and install.extension else None,
+ }
if not MarketplaceService.uninstall_extension(install_id):
return jsonify({'error': 'Not found'}), 404
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_UNINSTALL,
+ user_id=user.id,
+ target_type='marketplace_extension_install',
+ target_id=install_id,
+ details=audit_details,
+ )
return jsonify({'message': 'Extension uninstalled'})
@marketplace_bp.route('/installs/<int:install_id>/config', methods=['PUT'])
@jwt_required()
def update_config(install_id):
+ user = get_current_user()
data = request.get_json() or {}
install = MarketplaceService.update_extension_config(install_id, data.get('config', {}))
if not install:
return jsonify({'error': 'Not found'}), 404
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_UPDATE,
+ user_id=user.id if user else None,
+ target_type='marketplace_extension_install',
+ target_id=install.id,
+ details={
+ 'extension_id': install.extension_id,
+ 'extension_name': install.extension.display_name if install.extension else None,
+ 'operation': 'update_config',
+ },
+ )
return jsonify(install.to_dict())
diff --git a/backend/app/api/plugins.py b/backend/app/api/plugins.py
index 11deaa9d..25dc6574 100644
--- a/backend/app/api/plugins.py
+++ b/backend/app/api/plugins.py
@@ -205,6 +205,13 @@ def enable_plugin(plugin_id):
plugin = enable_plugin(plugin_id)
if not plugin:
return jsonify({'error': 'Plugin not found'}), 404
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_ENABLE,
+ user_id=user.id,
+ target_type='plugin',
+ target_id=plugin.id,
+ details={'name': plugin.name, 'version': plugin.version},
+ )
return jsonify(plugin.to_dict())
@@ -220,9 +227,58 @@ def disable_plugin(plugin_id):
plugin = disable_plugin(plugin_id)
if not plugin:
return jsonify({'error': 'Plugin not found'}), 404
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_DISABLE,
+ user_id=user.id,
+ target_type='plugin',
+ target_id=plugin.id,
+ details={'name': plugin.name, 'version': plugin.version},
+ )
return jsonify(plugin.to_dict())
+@plugins_bp.route('/builtin', methods=['GET'])
+@jwt_required()
+def list_builtin():
+ """Enumerate bundled extensions in BUILTIN_EXTENSIONS_DIR.
+
+ Used by the Marketplace UI to show one-click installs for plugins
+ that ship with the repo (e.g. the opt-in Git wrapper) without
+ making the user paste an absolute path.
+ """
+ from app.services.plugin_service import list_builtin_extensions
+ return jsonify({'builtin': list_builtin_extensions()})
+
+
+@plugins_bp.route('/builtin/<slug>/install', methods=['POST'])
+@jwt_required()
+def install_builtin(slug):
+ """Install a bundled extension by slug.
+
+ Mirror of /plugins/install — admin-only, since this writes to disk
+ and may execute lifecycle hooks.
+ """
+ user = get_current_user()
+ if not user or not user.is_admin:
+ return jsonify({'error': 'Admin access required'}), 403
+
+ from app.services.plugin_service import install_builtin_extension
+ try:
+ plugin = install_builtin_extension(slug, user_id=user.id)
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_CREATE,
+ user_id=user.id,
+ target_type='plugin',
+ target_id=plugin.id,
+ details={'name': plugin.name, 'version': plugin.version, 'source': 'builtin'},
+ )
+ return jsonify(plugin.to_dict()), 201
+ except ValueError as e:
+ return jsonify({'error': str(e)}), 400
+ except Exception as e:
+ return jsonify({'error': f'Installation failed: {e}'}), 500
+
+
@plugins_bp.route('/manifest-spec', methods=['GET'])
@jwt_required()
def get_manifest_spec():
@@ -268,10 +324,13 @@ def get_manifest_spec():
'type': 'object',
'properties': {
'nav': {'type': 'array', 'description': 'Sidebar items: {id, label, route, category, icon}.'},
- 'routes': {'type': 'array', 'description': 'SPA routes: {path, component}. component matches a named export of the plugin index module.'},
+ 'routes': {'type': 'array',
+ 'description': 'SPA routes: {path, component, layout?}. component matches a named export of the plugin index module. layout: padded (default) | full | bare | <custom-layout-id>.'},
'page_titles': {'type': 'object', 'description': 'Map of route path → document title.'},
'command_palette': {'type': 'array', 'description': '{label, path, category, keywords}.'},
'widgets': {'type': 'array', 'description': '{slot, component}. slot=global renders globally inside DashboardLayout.'},
+ 'layouts': {'type': 'array',
+ 'description': 'Custom layout components: {id, component}. The component must render <Outlet/> somewhere; it wraps every route that references its id. Built-in layouts (padded, full, bare) are reserved.'},
},
},
},
diff --git a/backend/app/api/sso.py b/backend/app/api/sso.py
index 89fb0103..48dd85f9 100644
--- a/backend/app/api/sso.py
+++ b/backend/app/api/sso.py
@@ -65,20 +65,16 @@ def callback(provider):
profile = sso_service.handle_oauth_callback(provider, code, state, redirect_uri)
user, is_new = sso_service.find_or_create_user(provider, profile)
except ValueError as e:
- AuditLog.log(
+ AuditService.log(
action=AuditLog.ACTION_SSO_LOGIN_FAILED,
details={'provider': provider, 'error': str(e)},
- ip_address=request.remote_addr,
)
- db.session.commit()
return jsonify({'error': str(e)}), 403
except Exception as e:
- AuditLog.log(
+ AuditService.log(
action=AuditLog.ACTION_SSO_LOGIN_FAILED,
details={'provider': provider, 'error': str(e)},
- ip_address=request.remote_addr,
)
- db.session.commit()
return jsonify({'error': 'SSO authentication failed'}), 500
return _complete_sso_login(user, provider, is_new)
@@ -241,12 +237,11 @@ def update_provider_config(provider):
SettingsService.set(full_key, value, user_id=user.id)
updated.append(key)
- AuditLog.log(
+ AuditService.log(
action=AuditLog.ACTION_SETTINGS_UPDATE,
user_id=user.id,
details={'sso_provider': provider, 'updated_fields': updated},
)
- db.session.commit()
return jsonify({'message': f'{provider} SSO config updated', 'updated': updated}), 200
@@ -273,12 +268,11 @@ def update_general_settings():
SettingsService.set(key, data[key], user_id=user.id)
updated.append(key)
- AuditLog.log(
+ AuditService.log(
action=AuditLog.ACTION_SETTINGS_UPDATE,
user_id=user.id,
details={'sso_general': updated},
)
- db.session.commit()
return jsonify({'message': 'SSO general settings updated', 'updated': updated}), 200
diff --git a/backend/app/middleware/audit.py b/backend/app/middleware/audit.py
new file mode 100644
index 00000000..0aa609b3
--- /dev/null
+++ b/backend/app/middleware/audit.py
@@ -0,0 +1,205 @@
+"""Fallback audit logging for authenticated mutating API requests."""
+import json
+import logging
+from datetime import datetime
+
+from flask import g, request
+
+from app import db
+from app.models.audit_log import AuditLog
+
+logger = logging.getLogger(__name__)
+
+MUTATING_METHODS = {'POST', 'PUT', 'PATCH', 'DELETE'}
+MAX_BODY_BYTES = 32 * 1024
+MAX_STRING_LENGTH = 500
+MAX_LIST_ITEMS = 20
+MAX_DICT_ITEMS = 50
+REDACTED = '[redacted]'
+
+SENSITIVE_KEY_PARTS = (
+ 'password',
+ 'passwd',
+ 'secret',
+ 'token',
+ 'credential',
+ 'private',
+ 'certificate',
+ 'api_key',
+ 'apikey',
+ 'authorization',
+ 'cookie',
+ 'session',
+ 'totp',
+ 'otp',
+ 'csrf',
+)
+
+NOISY_ENDPOINTS = {
+ 'auth.refresh',
+}
+
+
+def register_audit_fallback(app):
+ """Register an after-request fallback for missing explicit audit logs."""
+
+ @app.after_request
+ def audit_unlogged_mutation(response):
+ if not _should_audit(response):
+ return response
+
+ user_id = _get_user_id()
+ if user_id is None:
+ return response
+
+ details = _build_details(response)
+ values = {
+ 'action': AuditLog.ACTION_API_MUTATION,
+ 'user_id': user_id,
+ 'target_type': _target_type(),
+ 'target_id': _target_id(),
+ 'details': json.dumps(details),
+ 'ip_address': _ip_address(),
+ 'user_agent': (request.headers.get('User-Agent') or '')[:500],
+ 'created_at': datetime.utcnow(),
+ }
+
+ try:
+ # Use a separate transaction so fallback audit logging does not
+ # accidentally commit application changes left pending on db.session.
+ with db.engine.begin() as conn:
+ conn.execute(AuditLog.__table__.insert().values(**values))
+ except Exception as exc:
+ logger.warning('Fallback audit log failed: %s', exc)
+
+ return response
+
+
+def _should_audit(response):
+ if request.method not in MUTATING_METHODS:
+ return False
+ if not request.path.startswith('/api/'):
+ return False
+ if request.endpoint in NOISY_ENDPOINTS:
+ return False
+ if getattr(g, 'audit_logged', False):
+ return False
+ return True
+
+
+def _get_user_id():
+ api_key_user = getattr(g, 'api_key_user', None)
+ if api_key_user is not None:
+ return api_key_user.id
+
+ try:
+ from flask_jwt_extended import get_jwt_identity
+ identity = get_jwt_identity()
+ except Exception:
+ return None
+
+ if identity is None:
+ return None
+
+ try:
+ return int(identity)
+ except (TypeError, ValueError):
+ return identity
+
+
+def _build_details(response):
+ details = {
+ 'method': request.method,
+ 'path': request.path,
+ 'endpoint': request.endpoint,
+ 'status_code': response.status_code,
+ 'success': 200 <= response.status_code < 400,
+ }
+
+ if request.view_args:
+ details['route_args'] = _sanitize(request.view_args)
+
+ query = request.args.to_dict(flat=False)
+ if query:
+ details['query'] = _sanitize(query)
+
+ if request.is_json:
+ if (request.content_length or 0) > MAX_BODY_BYTES:
+ details['payload'] = '[omitted: request body too large]'
+ else:
+ payload = request.get_json(silent=True)
+ if payload is not None:
+ details['payload'] = _sanitize(payload)
+
+ if request.files:
+ details['files'] = {
+ field: _sanitize({'filename': file.filename, 'content_type': file.content_type})
+ for field, file in request.files.items()
+ }
+
+ return details
+
+
+def _target_type():
+ if request.blueprint:
+ return request.blueprint[:50]
+ if request.endpoint:
+ return request.endpoint.split('.')[0][:50]
+ parts = [part for part in request.path.split('/') if part]
+ return (parts[2] if len(parts) > 2 else 'api')[:50]
+
+
+def _target_id():
+ for key, value in (request.view_args or {}).items():
+ if key == 'id' or key.endswith('_id'):
+ try:
+ return int(value)
+ except (TypeError, ValueError):
+ continue
+ return None
+
+
+def _sanitize(value, key=None, depth=0):
+ if key and _is_sensitive_key(key):
+ return REDACTED
+ if depth >= 4:
+ return '[truncated]'
+
+ if isinstance(value, dict):
+ items = list(value.items())
+ result = {}
+ for item_key, item_value in items[:MAX_DICT_ITEMS]:
+ safe_key = str(item_key)[:MAX_STRING_LENGTH]
+ result[safe_key] = _sanitize(item_value, key=safe_key, depth=depth + 1)
+ if len(items) > MAX_DICT_ITEMS:
+ result['__truncated__'] = len(items) - MAX_DICT_ITEMS
+ return result
+
+ if isinstance(value, (list, tuple)):
+ result = [_sanitize(item, depth=depth + 1) for item in value[:MAX_LIST_ITEMS]]
+ if len(value) > MAX_LIST_ITEMS:
+ result.append(f'[truncated {len(value) - MAX_LIST_ITEMS} items]')
+ return result
+
+ if isinstance(value, str):
+ if len(value) > MAX_STRING_LENGTH:
+ return value[:MAX_STRING_LENGTH] + '...[truncated]'
+ return value
+
+ if value is None or isinstance(value, (bool, int, float)):
+ return value
+
+ return str(value)[:MAX_STRING_LENGTH]
+
+
+def _is_sensitive_key(key):
+ lowered = str(key).lower()
+ return any(part in lowered for part in SENSITIVE_KEY_PARTS)
+
+
+def _ip_address():
+ if request.headers.get('X-Forwarded-For'):
+ return request.headers.get('X-Forwarded-For').split(',')[0].strip()
+ if request.headers.get('X-Real-IP'):
+ return request.headers.get('X-Real-IP')
+ return request.remote_addr
diff --git a/backend/app/models/audit_log.py b/backend/app/models/audit_log.py
index 9f58ef30..bd256585 100644
--- a/backend/app/models/audit_log.py
+++ b/backend/app/models/audit_log.py
@@ -30,6 +30,16 @@ class AuditLog(db.Model):
ACTION_USER_DISABLE = 'user.disable'
ACTION_USER_ENABLE = 'user.enable'
ACTION_SETTINGS_UPDATE = 'settings.update'
+ ACTION_API_MUTATION = 'api.mutation'
+ ACTION_RESOURCE_CREATE = 'resource.create'
+ ACTION_RESOURCE_UPDATE = 'resource.update'
+ ACTION_RESOURCE_DELETE = 'resource.delete'
+ ACTION_RESOURCE_INSTALL = 'resource.install'
+ ACTION_RESOURCE_UNINSTALL = 'resource.uninstall'
+ ACTION_RESOURCE_ENABLE = 'resource.enable'
+ ACTION_RESOURCE_DISABLE = 'resource.disable'
+ ACTION_RESOURCE_ARCHIVE = 'resource.archive'
+ ACTION_RESOURCE_RESTORE = 'resource.restore'
ACTION_APP_CREATE = 'app.create'
ACTION_APP_UPDATE = 'app.update'
ACTION_APP_DELETE = 'app.delete'
diff --git a/backend/app/services/audit_service.py b/backend/app/services/audit_service.py
index 8f445705..a52cf7f6 100644
--- a/backend/app/services/audit_service.py
+++ b/backend/app/services/audit_service.py
@@ -1,8 +1,20 @@
"""Service for audit logging operations."""
-from flask import request
+from flask import g, has_request_context, request
from app import db
from app.models import AuditLog
+REDACTED = '[redacted]'
+SENSITIVE_SETTING_PARTS = (
+ 'password',
+ 'secret',
+ 'token',
+ 'credential',
+ 'private',
+ 'certificate',
+ 'api_key',
+ 'apikey',
+)
+
class AuditService:
"""Service for creating and querying audit logs."""
@@ -10,6 +22,9 @@ class AuditService:
@staticmethod
def get_request_info():
"""Extract IP address and user agent from the current request."""
+ if not has_request_context():
+ return None, None
+
ip_address = request.remote_addr
# Handle proxy headers
if request.headers.get('X-Forwarded-For'):
@@ -21,7 +36,7 @@ class AuditService:
return ip_address, user_agent
@staticmethod
- def log(action, user_id=None, target_type=None, target_id=None, details=None):
+ def log(action, user_id=None, target_type=None, target_id=None, details=None, commit=True):
"""
Create an audit log entry with request context.
@@ -31,6 +46,8 @@ class AuditService:
target_type: Type of the target (e.g., 'user', 'app', 'setting')
target_id: ID of the target entity
details: Dictionary with additional details
+ commit: Persist the entry immediately. Set to False when batching
+ audit rows into a larger explicit transaction.
Returns:
The created AuditLog entry
@@ -47,6 +64,9 @@ class AuditService:
user_agent=user_agent
)
+ if has_request_context():
+ g.audit_logged = True
+
# Emit webhook event for matching audit actions
try:
from app.services.event_service import EventService
@@ -54,6 +74,9 @@ class AuditService:
except Exception:
pass # Don't let event emission failures break audit logging
+ if commit:
+ db.session.commit()
+
return log_entry
@staticmethod
@@ -82,6 +105,10 @@ class AuditService:
@staticmethod
def log_settings_change(user_id, key, old_value, new_value):
"""Log a settings change."""
+ if AuditService.is_sensitive_key(key):
+ old_value = REDACTED if old_value is not None else None
+ new_value = REDACTED if new_value is not None else None
+
return AuditService.log(
action=AuditLog.ACTION_SETTINGS_UPDATE,
user_id=user_id,
@@ -89,6 +116,11 @@ class AuditService:
details={'key': key, 'old_value': old_value, 'new_value': new_value}
)
+ @staticmethod
+ def is_sensitive_key(key):
+ lowered = str(key).lower()
+ return any(part in lowered for part in SENSITIVE_SETTING_PARTS)
+
@staticmethod
def log_app_action(action, user_id, app_id, app_name=None, details=None):
"""Log an application action."""
diff --git a/backend/app/services/contribution_service.py b/backend/app/services/contribution_service.py
index 2720aa7d..5cd7f93b 100644
--- a/backend/app/services/contribution_service.py
+++ b/backend/app/services/contribution_service.py
@@ -5,12 +5,23 @@ A plugin manifest may declare a `contributions` block with any subset of:
{
"nav": [{ id, label, route, category, icon, ... }],
- "routes": [{ path, component }],
+ "routes": [{ path, component, layout? }],
"page_titles": { "/some-path": "Title" },
"command_palette":[{ label, path, category, keywords }],
- "widgets": [{ slot, component }]
+ "widgets": [{ slot, component }],
+ "layouts": [{ id, component }]
}
+The `layout` field on a route may be one of:
+
+ "padded" (default) — render inside DashboardLayout, normal padding
+ "full" — render inside DashboardLayout, no padding
+ (matches /workflow, /files, /docker shape)
+ "bare" — render OUTSIDE DashboardLayout (no sidebar)
+ under PrivateRoute, fullscreen authenticated
+ "<custom-id>" — wrap in a plugin-contributed layout component
+ declared via contributions.layouts
+
Each entry is tagged with the source plugin's slug so the frontend knows
which plugin a contribution came from (for error attribution + matching
the `component` string against modules discovered by import.meta.glob).
@@ -42,6 +53,7 @@ def get_active_contributions():
page_titles = {}
command_palette = []
widgets = []
+ layouts = []
for p in plugins:
contrib = (p.manifest or {}).get('contributions') or {}
@@ -52,6 +64,7 @@ def get_active_contributions():
routes.extend(_tag(contrib.get('routes'), p.slug))
command_palette.extend(_tag(contrib.get('command_palette'), p.slug))
widgets.extend(_tag(contrib.get('widgets'), p.slug))
+ layouts.extend(_tag(contrib.get('layouts'), p.slug))
titles = contrib.get('page_titles')
if isinstance(titles, dict):
@@ -65,4 +78,5 @@ def get_active_contributions():
'page_titles': page_titles,
'command_palette': command_palette,
'widgets': widgets,
+ 'layouts': layouts,
}
diff --git a/backend/app/services/marketplace_service.py b/backend/app/services/marketplace_service.py
index 912d53bb..b1999248 100644
--- a/backend/app/services/marketplace_service.py
+++ b/backend/app/services/marketplace_service.py
@@ -34,6 +34,10 @@ class MarketplaceService:
def get_extension_by_slug(slug):
return Extension.query.filter_by(slug=slug).first()
+ @staticmethod
+ def get_install(install_id):
+ return ExtensionInstall.query.get(install_id)
+
@staticmethod
def create_extension(data, user_id=None):
slug = data.get('slug', data['name'].lower().replace(' ', '-'))
diff --git a/backend/app/services/plugin_service.py b/backend/app/services/plugin_service.py
index 2b9e46e3..802f97ad 100644
--- a/backend/app/services/plugin_service.py
+++ b/backend/app/services/plugin_service.py
@@ -48,6 +48,15 @@ FRONTEND_PLUGINS_DIR = os.environ.get(
os.path.join(_PROJECT_ROOT, 'frontend', 'src', 'plugins'),
)
+# Folder of bundled-with-the-repo extensions that ship as plugins
+# but are not installed by default. The discovery endpoint enumerates
+# this folder so the Marketplace can show one-click installs without
+# requiring users to know absolute paths.
+BUILTIN_EXTENSIONS_DIR = os.environ.get(
+ 'SERVERKIT_BUILTIN_EXTENSIONS_DIR',
+ os.path.join(_PROJECT_ROOT, 'builtin-extensions'),
+)
+
def _ensure_backend_dir():
"""Create the backend plugin dir; raise a useful error if we can't."""
@@ -763,3 +772,56 @@ def get_plugin(plugin_id):
def get_plugin_by_slug(slug):
"""Get a plugin by its slug."""
return InstalledPlugin.query.filter_by(slug=slug).first()
+
+
+def list_builtin_extensions():
+ """Enumerate folders in BUILTIN_EXTENSIONS_DIR that look like plugins.
+
+ Each entry includes the manifest, the absolute source path, and the
+ install state (installed/active/disabled/error/not_installed). The
+ Marketplace UI uses this to render one-click installs.
+ """
+ out = []
+ if not os.path.isdir(BUILTIN_EXTENSIONS_DIR):
+ return out
+
+ for name in sorted(os.listdir(BUILTIN_EXTENSIONS_DIR)):
+ folder = os.path.join(BUILTIN_EXTENSIONS_DIR, name)
+ manifest_path = os.path.join(folder, 'plugin.json')
+ if not os.path.isfile(manifest_path):
+ continue
+
+ try:
+ with open(manifest_path, 'r', encoding='utf-8') as f:
+ manifest = json.load(f)
+ except Exception as e:
+ logger.warning(f'Skipping builtin {name}: bad plugin.json ({e})')
+ continue
+
+ slug = manifest.get('name') or name
+ existing = InstalledPlugin.query.filter_by(slug=slug).first()
+ installed_state = existing.status if existing else 'not_installed'
+
+ out.append({
+ 'folder': name,
+ 'path': folder,
+ 'slug': slug,
+ 'manifest': manifest,
+ 'installed': existing is not None,
+ 'install_id': existing.id if existing else None,
+ 'status': installed_state,
+ })
+
+ return out
+
+
+def install_builtin_extension(slug, user_id=None):
+ """Install a builtin extension by its slug (folder lookup)."""
+ if not os.path.isdir(BUILTIN_EXTENSIONS_DIR):
+ raise ValueError(f'Builtin extensions dir not found: {BUILTIN_EXTENSIONS_DIR}')
+
+ for entry in list_builtin_extensions():
+ if entry['slug'] == slug:
+ return install_from_path(entry['path'], user_id=user_id)
+
+ raise ValueError(f"No builtin extension with slug '{slug}'")
diff --git a/backend/config.py b/backend/config.py
index cadd43da..055c99e6 100644
--- a/backend/config.py
+++ b/backend/config.py
@@ -24,8 +24,18 @@ class Config:
JWT_ACCESS_TOKEN_EXPIRES = timedelta(minutes=15)
JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=30)
- # CORS - Allow both dev server and Flask server
- CORS_ORIGINS = os.environ.get('CORS_ORIGINS', 'http://localhost:5173,http://localhost:5274,http://localhost:5000,http://127.0.0.1:5173,http://127.0.0.1:5274,http://127.0.0.1:5000').split(',')
+ # CORS - allow the launcher defaults plus legacy local dev ports.
+ DEFAULT_CORS_ORIGINS = ','.join([
+ 'http://localhost:41921',
+ 'http://127.0.0.1:41921',
+ 'http://localhost:47927',
+ 'http://127.0.0.1:47927',
+ 'http://localhost:5173',
+ 'http://127.0.0.1:5173',
+ 'http://localhost:5000',
+ 'http://127.0.0.1:5000',
+ ])
+ CORS_ORIGINS = os.environ.get('CORS_ORIGINS', DEFAULT_CORS_ORIGINS).split(',')
class DevelopmentConfig(Config):
diff --git a/backend/tests/test_audit_log.py b/backend/tests/test_audit_log.py
new file mode 100644
index 00000000..987c30f0
--- /dev/null
+++ b/backend/tests/test_audit_log.py
@@ -0,0 +1,155 @@
+from app.models.audit_log import AuditLog
+
+
+def test_generic_resource_action_constants_are_defined():
+ assert AuditLog.ACTION_API_MUTATION == 'api.mutation'
+ assert AuditLog.ACTION_RESOURCE_CREATE == 'resource.create'
+ assert AuditLog.ACTION_RESOURCE_UPDATE == 'resource.update'
+ assert AuditLog.ACTION_RESOURCE_DELETE == 'resource.delete'
+ assert AuditLog.ACTION_RESOURCE_INSTALL == 'resource.install'
+ assert AuditLog.ACTION_RESOURCE_UNINSTALL == 'resource.uninstall'
+ assert AuditLog.ACTION_RESOURCE_ENABLE == 'resource.enable'
+ assert AuditLog.ACTION_RESOURCE_DISABLE == 'resource.disable'
+ assert AuditLog.ACTION_RESOURCE_ARCHIVE == 'resource.archive'
+ assert AuditLog.ACTION_RESOURCE_RESTORE == 'resource.restore'
+
+
+def test_audit_service_log_commits_without_caller_commit(app):
+ from app.services.audit_service import AuditService
+
+ with app.app_context():
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_CREATE,
+ user_id=None,
+ target_type='test_resource',
+ target_id=123,
+ details={'name': 'created'},
+ )
+
+ log = AuditLog.query.filter_by(
+ action=AuditLog.ACTION_RESOURCE_CREATE,
+ target_type='test_resource',
+ target_id=123,
+ ).one()
+ assert log.get_details() == {'name': 'created'}
+
+
+def test_sensitive_setting_audit_values_are_redacted(app):
+ from app.services.audit_service import AuditService
+
+ with app.app_context():
+ AuditService.log_settings_change(
+ user_id=None,
+ key='sso_google_client_secret',
+ old_value='old-secret',
+ new_value='new-secret',
+ )
+
+ log = AuditLog.query.filter_by(action=AuditLog.ACTION_SETTINGS_UPDATE).one()
+ assert log.get_details() == {
+ 'key': 'sso_google_client_secret',
+ 'old_value': '[redacted]',
+ 'new_value': '[redacted]',
+ }
+
+
+def test_fallback_audit_logs_unlogged_authenticated_mutation(app, client):
+ from flask import jsonify
+ from flask_jwt_extended import create_access_token, jwt_required
+ from werkzeug.security import generate_password_hash
+
+ from app import db
+ from app.models import User
+
+ @app.route('/api/v1/test-audit/items/<int:item_id>', methods=['PUT'])
+ @jwt_required()
+ def test_audit_update_item(item_id):
+ return jsonify({'item_id': item_id, 'ok': True})
+
+ with app.app_context():
+ user = User(
+ username='audituser',
+ password_hash=generate_password_hash('testpass'),
+ role=User.ROLE_ADMIN,
+ is_active=True,
+ )
+ db.session.add(user)
+ db.session.commit()
+ token = create_access_token(identity=user.id)
+
+ response = client.put(
+ '/api/v1/test-audit/items/42?filter=recent',
+ json={
+ 'name': 'updated',
+ 'password': 'plain-text-password',
+ 'nested': {'api_key': 'secret-key'},
+ },
+ headers={'Authorization': f'Bearer {token}'},
+ )
+
+ assert response.status_code == 200
+
+ with app.app_context():
+ log = AuditLog.query.filter_by(action=AuditLog.ACTION_API_MUTATION).one()
+ details = log.get_details()
+ assert log.user_id == user.id
+ assert log.target_type == 'test_audit_update_item'
+ assert log.target_id == 42
+ assert details['method'] == 'PUT'
+ assert details['path'] == '/api/v1/test-audit/items/42'
+ assert details['status_code'] == 200
+ assert details['route_args'] == {'item_id': 42}
+ assert details['query'] == {'filter': ['recent']}
+ assert details['payload']['name'] == 'updated'
+ assert details['payload']['password'] == '[redacted]'
+ assert details['payload']['nested']['api_key'] == '[redacted]'
+
+
+def test_explicit_audit_log_suppresses_fallback(app, client):
+ from flask import jsonify
+ from flask_jwt_extended import create_access_token, get_jwt_identity, jwt_required
+ from werkzeug.security import generate_password_hash
+
+ from app import db
+ from app.models import User
+ from app.services.audit_service import AuditService
+
+ @app.route('/api/v1/test-audit/explicit', methods=['POST'])
+ @jwt_required()
+ def test_audit_explicit():
+ user_id = int(get_jwt_identity())
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_CREATE,
+ user_id=user_id,
+ target_type='explicit_resource',
+ target_id=7,
+ details={'source': 'route'},
+ )
+ return jsonify({'ok': True})
+
+ with app.app_context():
+ user = User(
+ username='explicitaudit',
+ password_hash=generate_password_hash('testpass'),
+ role=User.ROLE_ADMIN,
+ is_active=True,
+ )
+ db.session.add(user)
+ db.session.commit()
+ token = create_access_token(identity=user.id)
+
+ response = client.post(
+ '/api/v1/test-audit/explicit',
+ json={'name': 'created'},
+ headers={'Authorization': f'Bearer {token}'},
+ )
+
+ assert response.status_code == 200
+
+ with app.app_context():
+ assert AuditLog.query.filter_by(action=AuditLog.ACTION_API_MUTATION).count() == 0
+ log = AuditLog.query.filter_by(action=AuditLog.ACTION_RESOURCE_CREATE).one()
+ assert log.target_type == 'explicit_resource'
+ assert log.target_id == 7
diff --git a/builtin-extensions/serverkit-git/frontend/index.jsx b/builtin-extensions/serverkit-git/frontend/index.jsx
new file mode 100644
index 00000000..dc44d152
--- /dev/null
+++ b/builtin-extensions/serverkit-git/frontend/index.jsx
@@ -0,0 +1,12 @@
+// Re-exports the existing host Git page as GitExtPage so the
+// contribution system can mount it at /git-ext while the hardcoded
+// /git route stays in place. Both routes hit the same /api/v1/git
+// backend and share state — this is intentional, the extension is
+// the same feature surfaced through the opt-in plugin pipeline so
+// you can A/B the two install paths.
+//
+// After install, this file lives at frontend/src/plugins/serverkit-git/
+// so the relative import resolves against the host's pages directory.
+import GitPage from '../../pages/Git';
+
+export const GitExtPage = GitPage;
diff --git a/builtin-extensions/serverkit-git/plugin.json b/builtin-extensions/serverkit-git/plugin.json
new file mode 100644
index 00000000..9d21de00
--- /dev/null
+++ b/builtin-extensions/serverkit-git/plugin.json
@@ -0,0 +1,37 @@
+{
+ "name": "serverkit-git",
+ "display_name": "Git Server (extension)",
+ "version": "1.0.0",
+ "description": "Self-hosted Git server (Gitea) wrapper exposed as the /git-ext route. Runs alongside the built-in /git page so you can compare the opt-in extension flow against the hardcoded one.",
+ "author": "ServerKit",
+ "license": "MIT",
+ "category": "deployment",
+ "homepage": "https://github.com/jhd3197/ServerKit",
+ "permissions": ["docker", "filesystem"],
+ "contributions": {
+ "nav": [
+ {
+ "id": "git-ext",
+ "label": "Git (ext)",
+ "route": "/git-ext",
+ "category": "infrastructure",
+ "icon": "<circle cx=\"18\" cy=\"18\" r=\"3\"/><circle cx=\"6\" cy=\"6\" r=\"3\"/><path d=\"M6 21V9a9 9 0 0 0 9 9\"/>"
+ }
+ ],
+ "routes": [
+ { "path": "git-ext", "component": "GitExtPage" },
+ { "path": "git-ext/:tab", "component": "GitExtPage" }
+ ],
+ "page_titles": {
+ "/git-ext": "Git (extension)"
+ },
+ "command_palette": [
+ {
+ "label": "Git (extension)",
+ "path": "/git-ext",
+ "category": "Pages",
+ "keywords": "git repos extension plugin"
+ }
+ ]
+ }
+}
diff --git a/docker-compose.yml b/docker-compose.yml
index d8e6ab6a..a15646de 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -24,7 +24,8 @@ services:
- SECRET_KEY=dev-secret-key-not-for-production
- JWT_SECRET_KEY=dev-jwt-key-not-for-production
- DATABASE_URL=sqlite:////app/instance/serverkit.db
- - CORS_ORIGINS=http://localhost,http://localhost:3847,http://localhost:5173
+ - CORS_ORIGINS=http://localhost,http://localhost:3847,http://localhost:41921
+ - SERVERKIT_BACKEND_PORT=5000
ports:
- "5849:5000"
volumes:
@@ -34,7 +35,7 @@ services:
- serverkit-network
restart: unless-stopped
healthcheck:
- test: ["CMD", "curl", "-f", "http://localhost:5000/api/v1/system/health"]
+ test: ["CMD-SHELL", "curl -f http://localhost:$${SERVERKIT_BACKEND_PORT:-5000}/api/v1/system/health"]
interval: 10s
timeout: 5s
retries: 3
diff --git a/docs/API.md b/docs/API.md
index aba38571..9eb0a4f8 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -6,7 +6,7 @@ This document provides complete REST API documentation for ServerKit.
## Overview
-**Base URL:** `http://localhost:5000/api/v1`
+**Base URL:** `http://localhost:47927/api/v1`
**Content Type:** All requests and responses use `application/json`
@@ -1136,7 +1136,7 @@ ServerKit uses Socket.IO for real-time updates.
**Connection:**
```javascript
-const socket = io('http://localhost:5000', {
+const socket = io('http://localhost:47927', {
auth: { token: 'your-access-token' }
});
```
@@ -1158,17 +1158,17 @@ const socket = io('http://localhost:5000', {
```bash
# Login
-TOKEN=$(curl -s -X POST http://localhost:5000/api/v1/auth/login \
+TOKEN=$(curl -s -X POST http://localhost:47927/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"password"}' \
| jq -r '.access_token')
# Get system metrics
-curl -s http://localhost:5000/api/v1/system/metrics \
+curl -s http://localhost:47927/api/v1/system/metrics \
-H "Authorization: Bearer $TOKEN" | jq
# Create application
-curl -s -X POST http://localhost:5000/api/v1/apps \
+curl -s -X POST http://localhost:47927/api/v1/apps \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"my-app","app_type":"php","php_version":"8.2"}'
@@ -1179,7 +1179,7 @@ curl -s -X POST http://localhost:5000/api/v1/apps \
```python
import requests
-BASE_URL = "http://localhost:5000/api/v1"
+BASE_URL = "http://localhost:47927/api/v1"
# Login
response = requests.post(f"{BASE_URL}/auth/login", json={
@@ -1198,7 +1198,7 @@ print(f"CPU: {metrics['cpu']['percent']}%")
### JavaScript
```javascript
-const BASE_URL = 'http://localhost:5000/api/v1';
+const BASE_URL = 'http://localhost:47927/api/v1';
// Login
const loginRes = await fetch(`${BASE_URL}/auth/login`, {
diff --git a/docs/LOCAL_DEVELOPMENT.md b/docs/LOCAL_DEVELOPMENT.md
index 76056b6d..b2862600 100644
--- a/docs/LOCAL_DEVELOPMENT.md
+++ b/docs/LOCAL_DEVELOPMENT.md
@@ -78,8 +78,9 @@ cat > .env << 'EOF'
SECRET_KEY=dev-secret-key-change-in-production
JWT_SECRET_KEY=dev-jwt-key-change-in-production
DATABASE_URL=sqlite:///backend/instance/serverkit.db
-CORS_ORIGINS=http://localhost,http://localhost:3000,http://localhost:5173
+CORS_ORIGINS=http://localhost:41921,http://127.0.0.1:41921,http://localhost:47927,http://127.0.0.1:47927
FLASK_ENV=development
+PORT=47927
EOF
# Create instance directory
@@ -96,17 +97,17 @@ export $(cat ../.env | xargs)
python run.py
```
-Backend will be available at: `http://localhost:5000`
+Backend will be available at: `http://localhost:47927`
### Step 5: Run Frontend (Terminal 2)
```bash
cd ~/ServerKit/frontend
npm install
-npm run dev
+npm run dev -- --host 127.0.0.1 --port 41921 --strictPort
```
-Frontend will be available at: `http://localhost:5173`
+Frontend will be available at: `http://localhost:41921`
---
@@ -133,9 +134,9 @@ services:
- SECRET_KEY=dev-secret-key
- JWT_SECRET_KEY=dev-jwt-key
- DATABASE_URL=sqlite:////app/instance/serverkit.db
- - CORS_ORIGINS=http://localhost,http://localhost:3000
+ - CORS_ORIGINS=http://localhost,http://localhost:3000,http://localhost:5849
ports:
- - "5000:5000"
+ - "5849:5000"
volumes:
- ./backend:/app
- dev-data:/app/instance
@@ -148,7 +149,7 @@ services:
dockerfile: Dockerfile.dev
container_name: serverkit-frontend-dev
environment:
- - VITE_API_URL=http://localhost:5000
+ - VITE_API_URL=http://localhost:5849/api/v1
ports:
- "3000:3000"
volumes:
@@ -236,7 +237,7 @@ To test PHP installation, firewall, etc. locally:
### Port already in use
```bash
# Find what's using the port
-sudo lsof -i :5000
+sudo lsof -i :47927
# Kill it
sudo kill -9 <PID>
```
@@ -260,7 +261,7 @@ rm backend/instance/serverkit.db-journal
When developing locally on Windows/WSL you may want a remote ServerKit agent (or
a Docker host on another machine) to connect back to your machine. The `dev.sh`
and `dev.ps1` scripts include a `tunnel` mode that starts the backend, frontend,
-and an ngrok tunnel pointed at the backend (port 5000).
+and an ngrok tunnel pointed at the active backend port printed by the launcher.
### Prerequisites
diff --git a/docs/README.md b/docs/README.md
index de344785..88602394 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -202,19 +202,19 @@ See [Deployment Guide](DEPLOYMENT.md) for complete CLI documentation.
ServerKit provides a REST API for automation and integration.
-**Base URL:** `http://localhost:5000/api/v1`
+**Base URL:** `http://localhost:47927/api/v1`
**Authentication:** JWT Bearer tokens
Quick example:
```bash
# Login
-curl -X POST http://localhost:5000/api/v1/auth/login \
+curl -X POST http://localhost:47927/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "password"}'
# Use token
-curl http://localhost:5000/api/v1/system/stats \
+curl http://localhost:47927/api/v1/system/stats \
-H "Authorization: Bearer <token>"
```
@@ -229,7 +229,7 @@ See [API Reference](API.md) for complete documentation.
**Container won't start:**
```bash
docker compose logs backend
-sudo lsof -i :5000
+sudo lsof -i :47927
```
**502 Bad Gateway:**
diff --git a/frontend/.env.development b/frontend/.env.development
index 644678f2..93fdaf95 100644
--- a/frontend/.env.development
+++ b/frontend/.env.development
@@ -1 +1 @@
-VITE_API_URL=http://localhost:5000/api/v1
+VITE_API_URL=http://localhost:47927/api/v1
diff --git a/frontend/README.md b/frontend/README.md
index f8e81b07..6932d11b 100644
--- a/frontend/README.md
+++ b/frontend/README.md
@@ -36,7 +36,7 @@ Start the development server:
npm run dev
```
-The app will be available at `http://localhost:5173`.
+The app will be available at `http://localhost:41921`.
### Building for Production
@@ -88,4 +88,4 @@ Access them in code via `import.meta.env.VITE_API_URL`.
## Contributing
-See the documentation files for AI agent permissions and guidelines.
\ No newline at end of file
+See the documentation files for AI agent permissions and guidelines.
diff --git a/frontend/how_it_works.md b/frontend/how_it_works.md
index 93fd3c27..791b6802 100644
--- a/frontend/how_it_works.md
+++ b/frontend/how_it_works.md
@@ -33,7 +33,7 @@ Start the development server:
npm run dev
```
-The app will be available at `http://localhost:5173`.
+The app will be available at `http://localhost:41921`.
### Building for Production
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 496ecec9..57ee6551 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -1,4 +1,4 @@
-import React, { useEffect } from 'react';
+import { useEffect } from 'react';
import { BrowserRouter as Router, Routes, Route, Navigate, useLocation } from 'react-router-dom';
import { AuthProvider, useAuth } from './contexts/AuthContext';
import { ToastProvider } from './contexts/ToastContext';
@@ -10,7 +10,6 @@ import Dashboard from './pages/Dashboard';
import Login from './pages/Login';
import Register from './pages/Register';
import Setup from './pages/Setup';
-import Applications from './pages/Applications';
import ApplicationDetail from './pages/ApplicationDetail';
import Docker from './pages/Docker';
import Databases from './pages/Databases';
@@ -44,7 +43,6 @@ import Email from './pages/Email';
import SSOCallback from './pages/SSOCallback';
import SourceConnectionCallback from './pages/SourceConnectionCallback';
import DatabaseMigration from './pages/DatabaseMigration';
-import AgentPlugins from './pages/AgentPlugins';
import ServerTemplates from './pages/ServerTemplates';
import Workspaces from './pages/Workspaces';
import DNSZones from './pages/DNSZones';
@@ -92,7 +90,7 @@ const PAGE_TITLES = {
'/migrate': 'Database Migration',
'/fleet': 'Agent Fleet',
'/fleet-monitor': 'Fleet Monitor',
- '/agent-plugins': 'Agent Plugins',
+ '/agent-plugins': 'Marketplace',
'/server-templates': 'Server Templates',
'/workspaces': 'Workspaces',
'/dns': 'DNS Zones',
@@ -188,7 +186,7 @@ function SetupRoute({ children }) {
}
function AppRoutes() {
- const extensionRoutes = useExtensionRoutes();
+ const { dashboardRoutes, standaloneGroups } = useExtensionRoutes();
return (
<Routes>
<Route path="/migrate" element={<DatabaseMigration />} />
@@ -217,6 +215,20 @@ function AppRoutes() {
<SourceConnectionCallback />
</PrivateRoute>
} />
+ {/* Standalone plugin layouts — bare or custom. Each group is
+ a sibling top-level Route under PrivateRoute, so the
+ plugin owns the chrome (no DashboardLayout sidebar). */}
+ {standaloneGroups.map((group) => {
+ const Layout = group.LayoutComponent;
+ return (
+ <Route
+ key={`standalone:${group.layoutId}`}
+ element={<PrivateRoute><Layout /></PrivateRoute>}
+ >
+ {group.routes}
+ </Route>
+ );
+ })}
<Route path="/" element={
<PrivateRoute>
<DashboardLayout />
@@ -250,7 +262,7 @@ function AppRoutes() {
<Route path="servers/:id/:tab" element={<ServerDetail />} />
<Route path="fleet" element={<AgentFleet />} />
<Route path="fleet-monitor" element={<FleetMonitor />} />
- <Route path="agent-plugins" element={<AgentPlugins />} />
+ <Route path="agent-plugins" element={<Navigate to="/marketplace" replace />} />
<Route path="server-templates" element={<ServerTemplates />} />
<Route path="workspaces" element={<Workspaces />} />
<Route path="dns" element={<DNSZones />} />
@@ -282,7 +294,7 @@ function AppRoutes() {
<Route path="terminal/:tab" element={<Terminal />} />
<Route path="settings" element={<Settings />} />
<Route path="settings/:tab" element={<Settings />} />
- {extensionRoutes}
+ {dashboardRoutes}
</Route>
</Routes>
);
diff --git a/frontend/src/components/sidebarItems.js b/frontend/src/components/sidebarItems.js
index b047aedf..322e2837 100644
--- a/frontend/src/components/sidebarItems.js
+++ b/frontend/src/components/sidebarItems.js
@@ -31,7 +31,6 @@ export const SIDEBAR_ITEMS = [
{ id: 'fleet', label: 'Agent Fleet', route: '/fleet', icon: '<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>' },
{ id: 'fleet-monitor', label: 'Fleet Monitor', route: '/fleet-monitor', icon: '<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>' },
{ id: 'cloud', label: 'Cloud Servers', route: '/cloud', icon: '<path d="M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z"/>' },
- { id: 'agent-plugins', label: 'Plugins', route: '/agent-plugins', icon: '<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>' },
{ id: 'server-templates', label: 'Config Templates', route: '/server-templates', icon: '<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/>' }
]
},
diff --git a/frontend/src/layouts/DashboardLayout.jsx b/frontend/src/layouts/DashboardLayout.jsx
index c7b0e9fe..01947ac8 100644
--- a/frontend/src/layouts/DashboardLayout.jsx
+++ b/frontend/src/layouts/DashboardLayout.jsx
@@ -1,11 +1,11 @@
-import { useState, useEffect, useCallback } from 'react';
+import { useState, useEffect, useCallback, useMemo } from 'react';
import { Outlet, useLocation } from 'react-router-dom';
import Sidebar from '../components/Sidebar';
import CommandPalette from '../components/CommandPalette';
import LogsDrawer from '../components/LogsDrawer';
import { LogsDrawerProvider } from '../contexts/LogsDrawerContext';
import PluginLoader from '../plugins/PluginLoader';
-import { refreshContributions } from '../plugins/contributions';
+import { refreshContributions, useContributions } from '../plugins/contributions';
import api from '../services/api';
const FULL_PAGE_ROUTES = ['/workflow', '/files', '/docker'];
@@ -13,7 +13,22 @@ const FULL_PAGE_ROUTES = ['/workflow', '/files', '/docker'];
const DashboardLayout = () => {
const location = useLocation();
const [paletteOpen, setPaletteOpen] = useState(false);
- const isFullPageRoute = FULL_PAGE_ROUTES.some((route) => (
+ const { routes: pluginRoutes } = useContributions();
+
+ // Plugin routes contribute their path relative to the dashboard
+ // parent (e.g. "git", "git/:tab"). Normalize to leading-slash and
+ // strip any :params so we can do a startsWith check below.
+ const fullPagePaths = useMemo(() => {
+ const fromPlugins = (pluginRoutes || [])
+ .filter((r) => r && r.layout === 'full' && r.path)
+ .map((r) => {
+ const stripped = r.path.split('/:')[0].replace(/^\/+/, '');
+ return '/' + stripped;
+ });
+ return [...FULL_PAGE_ROUTES, ...fromPlugins];
+ }, [pluginRoutes]);
+
+ const isFullPageRoute = fullPagePaths.some((route) => (
location.pathname === route || location.pathname.startsWith(`${route}/`)
));
diff --git a/frontend/src/layouts/StandaloneLayout.jsx b/frontend/src/layouts/StandaloneLayout.jsx
new file mode 100644
index 00000000..0c1e37b2
--- /dev/null
+++ b/frontend/src/layouts/StandaloneLayout.jsx
@@ -0,0 +1,13 @@
+/**
+ * Standalone layout — no sidebar, no chrome, just the route's outlet.
+ *
+ * Used for the built-in `bare` layout id: plugin pages that want the
+ * whole viewport with no host UI around them (think: a remote-desktop
+ * console, a fullscreen editor, a kiosk view). Authentication is still
+ * enforced by the parent PrivateRoute in App.jsx.
+ */
+import { Outlet } from 'react-router-dom';
+
+const StandaloneLayout = () => <Outlet />;
+
+export default StandaloneLayout;
diff --git a/frontend/src/pages/AgentPlugins.jsx b/frontend/src/pages/AgentPlugins.jsx
deleted file mode 100644
index fc608e86..00000000
--- a/frontend/src/pages/AgentPlugins.jsx
+++ /dev/null
@@ -1,299 +0,0 @@
-import React, { useState, useEffect, useCallback } from 'react';
-import { useNavigate } from 'react-router-dom';
-import api from '../services/api';
-import { useToast } from '../contexts/ToastContext';
-import { useAuth } from '../contexts/AuthContext';
-import Spinner from '../components/Spinner';
-import ConfirmDialog from '../components/ConfirmDialog';
-import { Button } from '@/components/ui/button';
-import { Input } from '@/components/ui/input';
-import { Label } from '@/components/ui/label';
-import { Textarea } from '@/components/ui/textarea';
-import { Badge } from '@/components/ui/badge';
-
-const AgentPlugins = () => {
- const navigate = useNavigate();
- const toast = useToast();
- const { user } = useAuth();
- const [plugins, setPlugins] = useState([]);
- const [loading, setLoading] = useState(true);
- const [showCreateModal, setShowCreateModal] = useState(false);
- const [showInstallModal, setShowInstallModal] = useState(false);
- const [selectedPlugin, setSelectedPlugin] = useState(null);
- const [deleteConfirm, setDeleteConfirm] = useState(null);
- const [servers, setServers] = useState([]);
- const [filter, setFilter] = useState('all');
-
- const [newPlugin, setNewPlugin] = useState({
- name: '', display_name: '', version: '1.0.0', description: '',
- author: '', capabilities: [], permissions: [],
- max_memory_mb: 128, max_cpu_percent: 10
- });
-
- const loadPlugins = useCallback(async () => {
- try {
- const data = await api.getAgentPlugins();
- setPlugins(data.plugins || []);
- } catch (err) {
- toast.error('Failed to load plugins');
- } finally {
- setLoading(false);
- }
- }, [toast]);
-
- useEffect(() => {
- loadPlugins();
- api.getServers().then(data => setServers(data.servers || [])).catch(() => {});
- }, [loadPlugins]);
-
- const handleCreate = async () => {
- try {
- await api.createAgentPlugin(newPlugin);
- toast.success('Plugin registered');
- setShowCreateModal(false);
- setNewPlugin({ name: '', display_name: '', version: '1.0.0', description: '', author: '', capabilities: [], permissions: [], max_memory_mb: 128, max_cpu_percent: 10 });
- loadPlugins();
- } catch (err) {
- toast.error(err.message);
- }
- };
-
- const handleDelete = async (id) => {
- try {
- await api.deleteAgentPlugin(id);
- toast.success('Plugin deleted');
- setDeleteConfirm(null);
- loadPlugins();
- } catch (err) {
- toast.error(err.message);
- }
- };
-
- const handleInstall = async (pluginId, serverId) => {
- try {
- await api.installAgentPlugin(pluginId, serverId);
- toast.success('Plugin installation initiated');
- setShowInstallModal(false);
- loadPlugins();
- } catch (err) {
- toast.error(err.message);
- }
- };
-
- const toggleCapability = (cap) => {
- setNewPlugin(prev => ({
- ...prev,
- capabilities: prev.capabilities.includes(cap)
- ? prev.capabilities.filter(c => c !== cap)
- : [...prev.capabilities, cap]
- }));
- };
-
- const togglePermission = (perm) => {
- setNewPlugin(prev => ({
- ...prev,
- permissions: prev.permissions.includes(perm)
- ? prev.permissions.filter(p => p !== perm)
- : [...prev.permissions, perm]
- }));
- };
-
- const filteredPlugins = filter === 'all' ? plugins
- : plugins.filter(p => p.status === filter);
-
- const capabilityLabels = {
- metrics: 'Custom Metrics',
- health_checks: 'Health Checks',
- commands: 'Custom Commands',
- scheduled_tasks: 'Scheduled Tasks',
- event_hooks: 'Event Hooks'
- };
-
- const permissionLabels = {
- filesystem: 'Filesystem',
- network: 'Network',
- docker: 'Docker',
- process: 'Process',
- system: 'System'
- };
-
- if (loading) return <Spinner />;
-
- return (
- <div className="page-container agent-plugins-page">
- <div className="page-header">
- <div className="page-header-content">
- <h1>Agent Plugins</h1>
- <p className="page-description">{plugins.length} plugin{plugins.length !== 1 ? 's' : ''} registered</p>
- </div>
- <div className="page-header-actions">
- <select value={filter} onChange={e => setFilter(e.target.value)} className="form-select">
- <option value="all">All Plugins</option>
- <option value="available">Available</option>
- <option value="deprecated">Deprecated</option>
- </select>
- {user?.is_admin && (
- <Button onClick={() => setShowCreateModal(true)}>
- Register Plugin
- </Button>
- )}
- </div>
- </div>
-
- <div className="plugins-grid">
- {filteredPlugins.map(plugin => (
- <div key={plugin.id} className="plugin-card card">
- <div className="plugin-card__header">
- <div className="plugin-card__info">
- <h3>{plugin.display_name}</h3>
- <span className="plugin-card__version">v{plugin.version}</span>
- </div>
- <Badge variant={plugin.status === 'available' ? 'success' : 'warning'}>
- {plugin.status}
- </Badge>
- </div>
- {plugin.description && (
- <p className="plugin-card__desc">{plugin.description}</p>
- )}
- <div className="plugin-card__meta">
- {plugin.author && <span>By {plugin.author}</span>}
- <span>{plugin.install_count} installation{plugin.install_count !== 1 ? 's' : ''}</span>
- </div>
- <div className="plugin-card__capabilities">
- {(plugin.capabilities || []).map(cap => (
- <Badge key={cap} variant="outline">{capabilityLabels[cap] || cap}</Badge>
- ))}
- </div>
- <div className="plugin-card__permissions">
- {(plugin.permissions || []).map(perm => (
- <Badge key={perm} variant="secondary">{permissionLabels[perm] || perm}</Badge>
- ))}
- </div>
- <div className="plugin-card__actions">
- <Button size="sm" onClick={() => { setSelectedPlugin(plugin); setShowInstallModal(true); }}>
- Install
- </Button>
- {user?.is_admin && (
- <Button size="sm" variant="destructive" onClick={() => setDeleteConfirm(plugin)}>
- Delete
- </Button>
- )}
- </div>
- </div>
- ))}
- {filteredPlugins.length === 0 && (
- <div className="empty-state">
- <p>No plugins found. Register a plugin to extend agent capabilities.</p>
- </div>
- )}
- </div>
-
- {/* Create Plugin Modal */}
- {showCreateModal && (
- <div className="modal-overlay" onClick={() => setShowCreateModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Register Plugin</h2>
- <button className="modal-close" onClick={() => setShowCreateModal(false)}>&times;</button>
- </div>
- <div className="modal-body">
- <div className="form-group">
- <Label>Plugin Name (identifier)</Label>
- <Input value={newPlugin.name} onChange={e => setNewPlugin({...newPlugin, name: e.target.value})} placeholder="my-plugin" />
- </div>
- <div className="form-group">
- <Label>Display Name</Label>
- <Input value={newPlugin.display_name} onChange={e => setNewPlugin({...newPlugin, display_name: e.target.value})} placeholder="My Plugin" />
- </div>
- <div className="form-group">
- <Label>Version</Label>
- <Input value={newPlugin.version} onChange={e => setNewPlugin({...newPlugin, version: e.target.value})} />
- </div>
- <div className="form-group">
- <Label>Description</Label>
- <Textarea value={newPlugin.description} onChange={e => setNewPlugin({...newPlugin, description: e.target.value})} rows={3} />
- </div>
- <div className="form-group">
- <Label>Author</Label>
- <Input value={newPlugin.author} onChange={e => setNewPlugin({...newPlugin, author: e.target.value})} />
- </div>
- <div className="form-group">
- <Label>Capabilities</Label>
- <div className="checkbox-group">
- {Object.entries(capabilityLabels).map(([key, label]) => (
- <label key={key} className="checkbox-label">
- <input type="checkbox" checked={newPlugin.capabilities.includes(key)} onChange={() => toggleCapability(key)} />
- {label}
- </label>
- ))}
- </div>
- </div>
- <div className="form-group">
- <Label>Permissions</Label>
- <div className="checkbox-group">
- {Object.entries(permissionLabels).map(([key, label]) => (
- <label key={key} className="checkbox-label">
- <input type="checkbox" checked={newPlugin.permissions.includes(key)} onChange={() => togglePermission(key)} />
- {label}
- </label>
- ))}
- </div>
- </div>
- <div className="form-row">
- <div className="form-group">
- <Label>Max Memory (MB)</Label>
- <Input type="number" value={newPlugin.max_memory_mb} onChange={e => setNewPlugin({...newPlugin, max_memory_mb: parseInt(e.target.value) || 128})} />
- </div>
- <div className="form-group">
- <Label>Max CPU (%)</Label>
- <Input type="number" value={newPlugin.max_cpu_percent} onChange={e => setNewPlugin({...newPlugin, max_cpu_percent: parseInt(e.target.value) || 10})} />
- </div>
- </div>
- </div>
- <div className="modal-footer">
- <Button variant="outline" onClick={() => setShowCreateModal(false)}>Cancel</Button>
- <Button onClick={handleCreate} disabled={!newPlugin.name || !newPlugin.display_name}>Register</Button>
- </div>
- </div>
- </div>
- )}
-
- {/* Install Plugin Modal */}
- {showInstallModal && selectedPlugin && (
- <div className="modal-overlay" onClick={() => setShowInstallModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Install {selectedPlugin.display_name}</h2>
- <button className="modal-close" onClick={() => setShowInstallModal(false)}>&times;</button>
- </div>
- <div className="modal-body">
- <p>Select a server to install this plugin on:</p>
- <div className="server-select-list">
- {servers.map(server => (
- <div key={server.id} className="server-select-item" onClick={() => handleInstall(selectedPlugin.id, server.id)}>
- <span className={`status-dot status-dot--${server.status === 'online' ? 'success' : 'danger'}`} />
- <span>{server.name}</span>
- <span className="text-muted">{server.hostname}</span>
- </div>
- ))}
- {servers.length === 0 && <p className="text-muted">No servers available</p>}
- </div>
- </div>
- </div>
- </div>
- )}
-
- {deleteConfirm && (
- <ConfirmDialog
- title="Delete Plugin"
- message={`Delete "${deleteConfirm.display_name}"? This cannot be undone.`}
- onConfirm={() => handleDelete(deleteConfirm.id)}
- onCancel={() => setDeleteConfirm(null)}
- variant="danger"
- />
- )}
- </div>
- );
-};
-
-export default AgentPlugins;
diff --git a/frontend/src/pages/Marketplace.jsx b/frontend/src/pages/Marketplace.jsx
index 1e20ec2c..e7032f79 100644
--- a/frontend/src/pages/Marketplace.jsx
+++ b/frontend/src/pages/Marketplace.jsx
@@ -1,7 +1,28 @@
-import React, { useState, useEffect, useCallback } from 'react';
+import { useState, useEffect, useCallback } from 'react';
+import {
+ Activity,
+ Archive,
+ CheckCircle2,
+ DownloadCloud,
+ FileArchive,
+ Filter,
+ FolderOpen,
+ Globe2,
+ LayoutGrid,
+ Package,
+ PackageCheck,
+ Plug,
+ PlugZap,
+ Search,
+ ServerCog,
+ ShieldCheck,
+ Sparkles,
+ Star,
+ UploadCloud,
+ X,
+} from 'lucide-react';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
-import { useAuth } from '../contexts/AuthContext';
import Spinner from '../components/Spinner';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
@@ -9,12 +30,115 @@ import { Textarea } from '@/components/ui/textarea';
import { Badge } from '@/components/ui/badge';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
+const CATEGORIES = ['monitoring', 'security', 'deployment', 'integration', 'ui', 'utility'];
+
+const INITIAL_EXTENSION_FORM = {
+ name: '',
+ display_name: '',
+ description: '',
+ category: 'utility',
+ version: '1.0.0',
+ author: '',
+};
+
+const CATEGORY_ICONS = {
+ monitoring: Activity,
+ security: ShieldCheck,
+ deployment: ServerCog,
+ integration: Plug,
+ ui: LayoutGrid,
+ utility: Package,
+};
+
+const PLUGIN_INSTALL_SOURCES = [
+ { id: 'url', label: 'URL', icon: Globe2 },
+ { id: 'path', label: 'Folder', icon: FolderOpen },
+ { id: 'upload', label: 'Zip', icon: FileArchive },
+];
+
+const numberFormatter = new Intl.NumberFormat();
+
+const formatCount = (value) => numberFormatter.format(Number(value) || 0);
+
+const titleCase = (value = '') => {
+ const cleaned = String(value || 'utility').replace(/[-_]/g, ' ');
+ return cleaned
+ .split(' ')
+ .filter(Boolean)
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
+ .join(' ');
+};
+
+const getCategoryIcon = (category) => CATEGORY_ICONS[category] || Package;
+
+const getPublishedCatalogEntry = (extension, installed) => ({
+ key: `published:${extension.id}`,
+ source: 'published',
+ sourceLabel: 'Published',
+ sourceDetail: 'Registry package',
+ installKey: extension.id,
+ displayName: extension.display_name || extension.name,
+ description: extension.description || 'No description provided.',
+ category: extension.category || 'utility',
+ version: extension.version || '0.0.0',
+ author: extension.author,
+ extensionType: extension.extension_type,
+ installed,
+ rating: extension.rating,
+ ratingCount: extension.rating_count,
+ downloadCount: extension.download_count,
+});
+
+const getInstalledPublishedEntry = (extension) => ({
+ key: `installed:${extension.id}`,
+ source: 'published',
+ sourceLabel: 'Published',
+ displayName: extension.extension_name,
+ version: extension.installed_version || '0.0.0',
+ installId: extension.id,
+});
+
+const getLocalCatalogEntry = (builtin) => {
+ const manifest = builtin.manifest || {};
+
+ return {
+ key: `local:${builtin.slug}`,
+ source: 'local',
+ sourceLabel: 'Local mapping',
+ sourceDetail: 'Mapped in local registry',
+ installKey: builtin.slug,
+ displayName: manifest.display_name || builtin.slug,
+ description: manifest.description || 'Local extension package.',
+ category: manifest.category || 'utility',
+ version: manifest.version || '0.0.0',
+ author: manifest.author,
+ extensionType: 'local',
+ installed: Boolean(builtin.installed),
+ status: builtin.status,
+ };
+};
+
+const catalogEntryMatches = (entry, search, category) => {
+ if (category && entry.category !== category) return false;
+
+ const query = search.trim().toLowerCase();
+ if (!query) return true;
+
+ return [
+ entry.displayName,
+ entry.description,
+ entry.category,
+ entry.author,
+ entry.sourceLabel,
+ ].some((value) => String(value || '').toLowerCase().includes(query));
+};
+
const Marketplace = () => {
const toast = useToast();
- const { user } = useAuth();
const [extensions, setExtensions] = useState([]);
const [myExtensions, setMyExtensions] = useState([]);
const [plugins, setPlugins] = useState([]);
+ const [builtins, setBuiltins] = useState([]);
const [loading, setLoading] = useState(true);
const [search, setSearch] = useState('');
const [category, setCategory] = useState('');
@@ -24,21 +148,21 @@ const Marketplace = () => {
const [pluginFile, setPluginFile] = useState(null);
const [installSource, setInstallSource] = useState('url');
const [installing, setInstalling] = useState(false);
- const [form, setForm] = useState({ name: '', display_name: '', description: '', category: 'utility', version: '1.0.0', author: '' });
-
- const categories = ['monitoring', 'security', 'deployment', 'integration', 'ui', 'utility'];
+ const [form, setForm] = useState(INITIAL_EXTENSION_FORM);
const loadExtensions = useCallback(async () => {
try {
- const [eData, mData, pData] = await Promise.all([
+ const [eData, mData, pData, bData] = await Promise.all([
api.getMarketplaceExtensions(category, search),
api.getMyExtensions(),
api.getInstalledPlugins().catch(() => ({ plugins: [] })),
+ api.getBuiltinExtensions().catch(() => ({ builtin: [] })),
]);
setExtensions(eData.extensions || []);
setMyExtensions(mData.extensions || []);
setPlugins(pData.plugins || []);
- } catch (err) {
+ setBuiltins(bData.builtin || []);
+ } catch {
toast.error('Failed to load extensions');
} finally {
setLoading(false);
@@ -63,6 +187,19 @@ const Marketplace = () => {
} catch (err) { toast.error(err.message); }
};
+ const handleBuiltinInstall = async (slug) => {
+ setInstalling(true);
+ try {
+ const result = await api.installBuiltinExtension(slug);
+ toast.success(`Installed "${result.display_name}". Hot-reload should pick it up; restart backend if blueprint routes do not appear.`);
+ loadExtensions();
+ } catch (err) {
+ toast.error(err.message || 'Local install failed');
+ } finally {
+ setInstalling(false);
+ }
+ };
+
const handlePluginInstall = async () => {
let action;
if (installSource === 'url') {
@@ -119,13 +256,14 @@ const Marketplace = () => {
await api.createMarketplaceExtension(form);
toast.success('Extension submitted');
setShowSubmit(false);
+ setForm(INITIAL_EXTENSION_FORM);
loadExtensions();
} catch (err) { toast.error(err.message); }
};
- const renderStars = (rating) => {
- const full = Math.floor(rating);
- return '★'.repeat(full) + '☆'.repeat(5 - full);
+ const resetFilters = () => {
+ setSearch('');
+ setCategory('');
};
const pluginStatusVariant = (status) => {
@@ -136,233 +274,376 @@ const Marketplace = () => {
if (loading) return <Spinner />;
- const installedIds = new Set(myExtensions.map(e => e.extension_id));
+ const installedIds = new Set(myExtensions.map((extension) => String(extension.extension_id)));
+ const localCatalogEntries = builtins.map(getLocalCatalogEntry);
+ const publishedCatalogEntries = extensions.map((extension) => (
+ getPublishedCatalogEntry(extension, installedIds.has(String(extension.id)))
+ ));
+ const installedCatalogEntries = [
+ ...localCatalogEntries.filter((entry) => entry.installed),
+ ...myExtensions.map(getInstalledPublishedEntry),
+ ];
+ const installedBuiltinCount = localCatalogEntries.filter((entry) => entry.installed).length;
+ const activePluginCount = plugins.filter((plugin) => plugin.status === 'active').length;
+ const pluginIssueCount = plugins.filter((plugin) => plugin.status === 'error').length;
+ const totalDownloads = extensions.reduce((total, extension) => total + (Number(extension.download_count) || 0), 0);
+ const availableCount = extensions.length + builtins.length;
+ const installedCatalogCount = installedCatalogEntries.length;
+ const catalogEntries = [...localCatalogEntries, ...publishedCatalogEntries]
+ .filter((entry) => catalogEntryMatches(entry, search, category));
+ const hasFilters = Boolean(search.trim() || category);
return (
<div className="page-container marketplace-page">
- <div className="page-header">
- <div className="page-header-content">
- <h1>Marketplace</h1>
- <p className="page-description">{extensions.length} extensions available</p>
+ <section className="marketplace-hero">
+ <div className="marketplace-hero__content">
+ <div className="marketplace-eyebrow">
+ <Sparkles aria-hidden="true" />
+ Extension control plane
+ </div>
+ <div className="page-header-content">
+ <h1>Marketplace</h1>
+ <p className="page-description">
+ One catalog for local registry mappings, published packages, and runtime plugins.
+ </p>
+ </div>
</div>
- <div className="page-header-actions">
- <Button variant="outline" onClick={() => setShowSubmit(true)}>Submit Extension</Button>
+ <div className="marketplace-hero__actions">
+ <Button variant="outline" onClick={() => setShowSubmit(true)}>
+ <UploadCloud aria-hidden="true" />
+ Submit Extension
+ </Button>
</div>
+ </section>
+
+ <div className="marketplace-stats" aria-label="Marketplace summary">
+ <StatTile icon={Package} label="Catalog" value={availableCount} tone="blue" />
+ <StatTile icon={Archive} label="Local Entries" value={builtins.length} tone="amber" />
+ <StatTile icon={PackageCheck} label="Installed" value={installedCatalogCount} tone="green" />
+ <StatTile icon={PlugZap} label="Active Plugins" value={`${activePluginCount}/${plugins.length}`} tone={pluginIssueCount > 0 ? 'red' : 'violet'} />
</div>
- <Tabs defaultValue="browse">
- <TabsList>
- <TabsTrigger value="browse">Browse</TabsTrigger>
- <TabsTrigger value="installed">Installed ({myExtensions.length})</TabsTrigger>
- <TabsTrigger value="plugins">Plugins ({plugins.length})</TabsTrigger>
+ <Tabs defaultValue="browse" className="marketplace-tabs">
+ <TabsList className="marketplace-tabs__list">
+ <TabsTrigger value="browse">
+ <LayoutGrid aria-hidden="true" />
+ Browse
+ </TabsTrigger>
+ <TabsTrigger value="installed">
+ <PackageCheck aria-hidden="true" />
+ Installed ({installedCatalogCount})
+ </TabsTrigger>
+ <TabsTrigger value="plugins">
+ <PlugZap aria-hidden="true" />
+ ServerKit Plugins ({plugins.length})
+ </TabsTrigger>
</TabsList>
<TabsContent value="browse">
- <div className="marketplace-filters">
- <Input placeholder="Search extensions..." value={search} onChange={e => setSearch(e.target.value)} />
- <select className="form-select" value={category} onChange={e => setCategory(e.target.value)}>
+ <div className="marketplace-toolbar">
+ <div className="marketplace-search">
+ <Search className="marketplace-search__icon" aria-hidden="true" />
+ <Input
+ placeholder="Search extensions..."
+ value={search}
+ onChange={(event) => setSearch(event.target.value)}
+ aria-label="Search extensions"
+ />
+ </div>
+ <select
+ className="form-select marketplace-category-select"
+ value={category}
+ onChange={(event) => setCategory(event.target.value)}
+ aria-label="Filter by category"
+ >
<option value="">All Categories</option>
- {categories.map(c => <option key={c} value={c}>{c.charAt(0).toUpperCase() + c.slice(1)}</option>)}
+ {CATEGORIES.map((item) => (
+ <option key={item} value={item}>{titleCase(item)}</option>
+ ))}
</select>
+ {hasFilters && (
+ <Button variant="ghost" size="sm" onClick={resetFilters}>
+ Reset
+ </Button>
+ )}
</div>
- <div className="extensions-grid">
- {extensions.map(ext => (
- <div key={ext.id} className="extension-card card">
- <div className="extension-card__header">
- <h3>{ext.display_name}</h3>
- <Badge variant="outline">{ext.category}</Badge>
+ <div className="marketplace-browse-grid">
+ <div className="marketplace-main-stack">
+ <section className="marketplace-section">
+ <SectionHeader
+ kicker="Catalog"
+ title="Extension catalog"
+ meta={`${catalogEntries.length} results`}
+ />
+ {catalogEntries.length > 0 ? (
+ <div className="extensions-grid">
+ {catalogEntries.map((entry) => (
+ <CatalogExtensionCard
+ key={entry.key}
+ entry={entry}
+ installing={installing}
+ onInstall={
+ entry.source === 'local'
+ ? handleBuiltinInstall
+ : handleInstall
+ }
+ statusVariant={pluginStatusVariant}
+ />
+ ))}
+ </div>
+ ) : (
+ <EmptyState
+ icon={Package}
+ title="No catalog entries found"
+ description={hasFilters ? 'No local or published entries match the current filter.' : 'No extension entries are available yet.'}
+ />
+ )}
+ </section>
+ </div>
+
+ <aside className="marketplace-side-panel" aria-label="Marketplace controls">
+ <div className="marketplace-panel">
+ <div className="marketplace-panel__title">
+ <Filter aria-hidden="true" />
+ Categories
</div>
- <p className="extension-card__desc">{ext.description}</p>
- <div className="extension-card__meta">
- <span className="extension-card__rating">{renderStars(ext.rating)} ({ext.rating_count})</span>
- <span>{ext.download_count} installs</span>
+ <div className="marketplace-category-list">
+ <button
+ type="button"
+ className={`marketplace-category ${category === '' ? 'marketplace-category--active' : ''}`}
+ onClick={() => setCategory('')}
+ >
+ All
+ </button>
+ {CATEGORIES.map((item) => {
+ const Icon = getCategoryIcon(item);
+ return (
+ <button
+ key={item}
+ type="button"
+ className={`marketplace-category marketplace-category--${item} ${category === item ? 'marketplace-category--active' : ''}`}
+ onClick={() => setCategory(item)}
+ >
+ <Icon aria-hidden="true" />
+ {titleCase(item)}
+ </button>
+ );
+ })}
</div>
- <div className="extension-card__info">
- <span>v{ext.version}</span>
- {ext.author && <span>by {ext.author}</span>}
- <Badge variant="secondary">{ext.extension_type}</Badge>
+ </div>
+
+ <div className="marketplace-panel">
+ <div className="marketplace-panel__title">
+ <ServerCog aria-hidden="true" />
+ Runtime
</div>
- <div className="extension-card__actions">
- {installedIds.has(ext.id) ? (
- <Badge variant="success">Installed</Badge>
- ) : (
- <Button size="sm" onClick={() => handleInstall(ext.id)}>Install</Button>
- )}
+ <div className="marketplace-runtime">
+ <RuntimeRow label="Published installs" value={formatCount(totalDownloads)} />
+ <RuntimeRow label="Local mappings" value={builtins.length} />
+ <RuntimeRow label="Installed local" value={`${installedBuiltinCount}/${builtins.length}`} />
+ <RuntimeRow label="Active plugins" value={`${activePluginCount}/${plugins.length}`} />
+ <RuntimeRow
+ label="Plugin issues"
+ value={pluginIssueCount}
+ danger={pluginIssueCount > 0}
+ />
</div>
</div>
- ))}
- {extensions.length === 0 && <div className="empty-state"><p>No extensions found.</p></div>}
+ </aside>
</div>
</TabsContent>
<TabsContent value="installed">
- <div className="installed-list">
- {myExtensions.map(inst => (
- <div key={inst.id} className="installed-item card">
- <div className="installed-item__info">
- <strong>{inst.extension_name}</strong>
- <span className="text-muted">v{inst.installed_version}</span>
- </div>
- <Button size="sm" variant="destructive" onClick={() => handleUninstall(inst.id)}>Uninstall</Button>
+ <section className="marketplace-section">
+ <SectionHeader
+ kicker="Installed"
+ title="Installed extensions"
+ meta={`${installedCatalogCount} installed`}
+ />
+ {installedCatalogEntries.length > 0 ? (
+ <div className="installed-list">
+ {installedCatalogEntries.map((entry) => (
+ <InstalledCatalogRow
+ key={entry.key}
+ entry={entry}
+ onUninstall={handleUninstall}
+ />
+ ))}
</div>
- ))}
- {myExtensions.length === 0 && <div className="empty-state"><p>No extensions installed.</p></div>}
- </div>
+ ) : (
+ <EmptyState
+ icon={PackageCheck}
+ title="No extensions installed"
+ description="Install a local or published extension to see it here."
+ />
+ )}
+ </section>
</TabsContent>
<TabsContent value="plugins">
<div className="plugins-section">
- <div className="plugin-install-form card">
- <h3>Install Plugin</h3>
-
- <div className="plugin-install-tabs" role="tablist">
- {[
- { id: 'url', label: 'From URL' },
- { id: 'path', label: 'From Folder' },
- { id: 'upload', label: 'Upload Zip' },
- ].map(t => (
- <button
- key={t.id}
- role="tab"
- type="button"
- aria-selected={installSource === t.id}
- className={`plugin-install-tab ${installSource === t.id ? 'plugin-install-tab--active' : ''}`}
- onClick={() => setInstallSource(t.id)}
- >
- {t.label}
- </button>
- ))}
- </div>
-
- {installSource === 'url' && (
- <>
- <p className="text-muted">Paste a GitHub repo URL, release URL, or direct zip link.</p>
- <div className="plugin-install-row">
- <Input
- placeholder="https://github.com/user/serverkit-plugin"
- value={pluginUrl}
- onChange={e => setPluginUrl(e.target.value)}
- onKeyDown={e => e.key === 'Enter' && handlePluginInstall()}
- disabled={installing}
- />
- <Button
- onClick={handlePluginInstall}
- disabled={installing || !pluginUrl.trim()}
- >
- {installing ? 'Installing...' : 'Install'}
- </Button>
+ <section className="marketplace-section">
+ <SectionHeader
+ kicker="Installer"
+ title="Install ServerKit plugin"
+ meta={titleCase(installSource)}
+ />
+ <div className="plugin-install-form">
+ <div className="plugin-install-form__heading">
+ <div className="plugin-install-form__icon">
+ <PlugZap aria-hidden="true" />
</div>
- </>
- )}
-
- {installSource === 'path' && (
- <>
- <p className="text-muted">
- Absolute path to a plugin folder <strong>on the panel host</strong>
- — not on your local machine. If the backend runs in Docker, the
- path must exist inside the container (bind-mount the folder, or
- use <em>Upload Zip</em> instead). Folder must contain
- <code> plugin.json</code>.
- </p>
- <div className="plugin-install-row">
- <Input
- placeholder={
- navigator.userAgent.toLowerCase().includes('win')
- ? 'C:\\Users\\you\\Documents\\GitHub\\my-plugin'
- : '/home/you/projects/my-plugin'
- }
- value={pluginPath}
- onChange={e => setPluginPath(e.target.value)}
- onKeyDown={e => e.key === 'Enter' && handlePluginInstall()}
- disabled={installing}
- />
- <Button
- onClick={handlePluginInstall}
- disabled={installing || !pluginPath.trim()}
- >
- {installing ? 'Installing...' : 'Install'}
- </Button>
+ <div>
+ <h3>Plugin source</h3>
+ <p className="text-muted">Load plugin packages from a repository, host folder, or zip archive.</p>
</div>
- </>
- )}
+ </div>
- {installSource === 'upload' && (
- <>
- <p className="text-muted">
- Upload a plugin zip (max 50 MB). The archive must contain
- <code> plugin.json</code> at the top level (or one folder deep,
- as GitHub source zips do).
- </p>
- <div className="plugin-install-row">
- <input
- type="file"
- accept=".zip,application/zip,application/x-zip-compressed"
- disabled={installing}
- onChange={e => setPluginFile(e.target.files?.[0] || null)}
- />
- <Button
- onClick={handlePluginInstall}
- disabled={installing || !pluginFile}
- >
- {installing ? 'Installing...' : 'Install'}
- </Button>
- </div>
- {pluginFile && (
- <div className="text-muted" style={{ marginTop: 6, fontSize: 12 }}>
- {pluginFile.name} · {(pluginFile.size / 1024).toFixed(1)} KB
- </div>
- )}
- </>
- )}
- </div>
+ <div className="plugin-install-tabs" role="tablist" aria-label="Plugin install source">
+ {PLUGIN_INSTALL_SOURCES.map((source) => {
+ const SourceIcon = source.icon;
+ return (
+ <button
+ key={source.id}
+ role="tab"
+ type="button"
+ aria-selected={installSource === source.id}
+ className={`plugin-install-tab ${installSource === source.id ? 'plugin-install-tab--active' : ''}`}
+ onClick={() => setInstallSource(source.id)}
+ >
+ <SourceIcon aria-hidden="true" />
+ {source.label}
+ </button>
+ );
+ })}
+ </div>
- <div className="installed-list">
- {plugins.map(plugin => (
- <div key={plugin.id} className={`installed-item card ${plugin.status === 'error' ? 'installed-item--error' : ''}`}>
- <div className="installed-item__info">
- <strong>{plugin.display_name}</strong>
- <span className="text-muted">v{plugin.version}</span>
- <Badge variant={pluginStatusVariant(plugin.status)}>
- {plugin.status}
- </Badge>
- {plugin.has_backend && <Badge variant="secondary">Backend</Badge>}
- {plugin.has_frontend && <Badge variant="secondary">Frontend</Badge>}
- </div>
- {plugin.description && <p className="text-muted" style={{ margin: '4px 0 8px', fontSize: '13px' }}>{plugin.description}</p>}
- {plugin.error_message && <p className="text-danger" style={{ margin: '4px 0 8px', fontSize: '12px' }}>{plugin.error_message}</p>}
- <div className="installed-item__actions">
- <Button
- size="sm"
- variant={plugin.status === 'active' ? 'outline' : 'default'}
- onClick={() => handlePluginToggle(plugin)}
- >
- {plugin.status === 'active' ? 'Disable' : 'Enable'}
- </Button>
- <Button size="sm" variant="destructive" onClick={() => handlePluginUninstall(plugin.id)}>Uninstall</Button>
+ {installSource === 'url' && (
+ <PluginInstallInput
+ description="Paste a GitHub repo URL, release URL, or direct zip link."
+ placeholder="https://github.com/user/serverkit-plugin"
+ value={pluginUrl}
+ onChange={setPluginUrl}
+ onInstall={handlePluginInstall}
+ disabled={installing}
+ installDisabled={installing || !pluginUrl.trim()}
+ />
+ )}
+
+ {installSource === 'path' && (
+ <PluginInstallInput
+ description="Use an absolute path that exists on the backend host or inside the backend container."
+ placeholder="/opt/serverkit/plugins/my-plugin"
+ value={pluginPath}
+ onChange={setPluginPath}
+ onInstall={handlePluginInstall}
+ disabled={installing}
+ installDisabled={installing || !pluginPath.trim()}
+ />
+ )}
+
+ {installSource === 'upload' && (
+ <div className="plugin-install-source">
+ <p className="text-muted">
+ Upload a plugin zip with <code>plugin.json</code> at the top level or one folder deep.
+ </p>
+ <div className="plugin-install-row">
+ <Input
+ type="file"
+ className="marketplace-file-input"
+ accept=".zip,application/zip,application/x-zip-compressed"
+ disabled={installing}
+ onChange={(event) => setPluginFile(event.target.files?.[0] || null)}
+ />
+ <Button
+ onClick={handlePluginInstall}
+ disabled={installing || !pluginFile}
+ >
+ <DownloadCloud aria-hidden="true" />
+ {installing ? 'Installing...' : 'Install'}
+ </Button>
+ </div>
+ {pluginFile && (
+ <div className="plugin-file-note">
+ {pluginFile.name} | {(pluginFile.size / 1024).toFixed(1)} KB
+ </div>
+ )}
</div>
+ )}
+ </div>
+ </section>
+
+ <section className="marketplace-section">
+ <SectionHeader
+ kicker="Runtime"
+ title="Installed ServerKit plugins"
+ meta={`${plugins.length} plugins`}
+ />
+ {plugins.length > 0 ? (
+ <div className="installed-list">
+ {plugins.map((plugin) => (
+ <PluginRow
+ key={plugin.id}
+ plugin={plugin}
+ onToggle={handlePluginToggle}
+ onUninstall={handlePluginUninstall}
+ statusVariant={pluginStatusVariant}
+ />
+ ))}
</div>
- ))}
- {plugins.length === 0 && (
- <div className="empty-state">
- <p>No plugins installed. Use the form above to install one from a URL.</p>
- </div>
+ ) : (
+ <EmptyState
+ icon={PlugZap}
+ title="No ServerKit plugins installed"
+ description="Install a plugin package to extend the panel runtime."
+ />
)}
- </div>
+ </section>
</div>
</TabsContent>
</Tabs>
{showSubmit && (
<div className="modal-overlay" onClick={() => setShowSubmit(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header"><h2>Submit Extension</h2><button className="modal-close" onClick={() => setShowSubmit(false)}>&times;</button></div>
- <div className="modal-body">
- <div className="form-group"><label>Name</label><Input value={form.name} onChange={e => setForm({...form, name: e.target.value})} /></div>
- <div className="form-group"><label>Display Name</label><Input value={form.display_name} onChange={e => setForm({...form, display_name: e.target.value})} /></div>
- <div className="form-group"><label>Description</label><Textarea value={form.description} onChange={e => setForm({...form, description: e.target.value})} rows={3} /></div>
- <div className="form-group"><label>Category</label><select className="form-select" value={form.category} onChange={e => setForm({...form, category: e.target.value})}>{categories.map(c => <option key={c} value={c}>{c}</option>)}</select></div>
- <div className="form-group"><label>Author</label><Input value={form.author} onChange={e => setForm({...form, author: e.target.value})} /></div>
+ <div className="modal marketplace-submit-modal" onClick={(event) => event.stopPropagation()}>
+ <div className="modal-header">
+ <div>
+ <h2>Submit Extension</h2>
+ <p className="text-muted">Publish a package listing to the local marketplace index.</p>
+ </div>
+ <button
+ className="modal-close"
+ type="button"
+ aria-label="Close submit extension dialog"
+ onClick={() => setShowSubmit(false)}
+ >
+ <X aria-hidden="true" />
+ </button>
+ </div>
+ <div className="modal-body marketplace-submit-grid">
+ <div className="form-group">
+ <label>Name</label>
+ <Input value={form.name} onChange={(event) => setForm({ ...form, name: event.target.value })} />
+ </div>
+ <div className="form-group">
+ <label>Display Name</label>
+ <Input value={form.display_name} onChange={(event) => setForm({ ...form, display_name: event.target.value })} />
+ </div>
+ <div className="form-group form-group--full">
+ <label>Description</label>
+ <Textarea value={form.description} onChange={(event) => setForm({ ...form, description: event.target.value })} rows={3} />
+ </div>
+ <div className="form-group">
+ <label>Category</label>
+ <select className="form-select" value={form.category} onChange={(event) => setForm({ ...form, category: event.target.value })}>
+ {CATEGORIES.map((item) => <option key={item} value={item}>{titleCase(item)}</option>)}
+ </select>
+ </div>
+ <div className="form-group">
+ <label>Author</label>
+ <Input value={form.author} onChange={(event) => setForm({ ...form, author: event.target.value })} />
+ </div>
</div>
<div className="modal-footer">
<Button variant="outline" onClick={() => setShowSubmit(false)}>Cancel</Button>
@@ -375,4 +656,226 @@ const Marketplace = () => {
);
};
+const StatTile = ({ icon: Icon, label, value, tone }) => (
+ <div className={`marketplace-stat marketplace-stat--${tone}`}>
+ <div className="marketplace-stat__icon">
+ <Icon aria-hidden="true" />
+ </div>
+ <div>
+ <div className="marketplace-stat__value">{value}</div>
+ <div className="marketplace-stat__label">{label}</div>
+ </div>
+ </div>
+);
+
+const SectionHeader = ({ kicker, title, meta }) => (
+ <div className="marketplace-section__header">
+ <div>
+ <p className="marketplace-kicker">{kicker}</p>
+ <h2>{title}</h2>
+ </div>
+ {meta && <Badge variant="outline">{meta}</Badge>}
+ </div>
+);
+
+const CatalogExtensionCard = ({ entry, installing, onInstall, statusVariant }) => {
+ const category = entry.category || 'utility';
+ const Icon = getCategoryIcon(category);
+ const isLocal = entry.source === 'local';
+ const installedLabel = isLocal && entry.status && entry.status !== 'active'
+ ? titleCase(entry.status)
+ : 'Installed';
+
+ return (
+ <article className={`extension-card extension-card--${entry.source} extension-card--${category} card`}>
+ <div className="extension-card__topline">
+ <div className={`extension-card__icon extension-card__icon--${category}`}>
+ <Icon aria-hidden="true" />
+ </div>
+ <div className="extension-card__badges">
+ <Badge variant={isLocal ? 'warning' : 'outline'}>{entry.sourceLabel}</Badge>
+ <Badge variant="outline">{titleCase(category)}</Badge>
+ </div>
+ </div>
+ <div className="extension-card__body">
+ <h3>{entry.displayName}</h3>
+ <p className="extension-card__desc">{entry.description}</p>
+ </div>
+ <div className="extension-card__signals">
+ {isLocal ? (
+ <>
+ <span>{entry.sourceDetail}</span>
+ <span>{entry.installed ? installedLabel : 'Ready to install'}</span>
+ </>
+ ) : (
+ <>
+ <span>
+ {renderStars(entry.rating)}
+ <span className="extension-card__signal-text">
+ {formatCount(entry.ratingCount)} reviews
+ </span>
+ </span>
+ <span>{formatCount(entry.downloadCount)} installs</span>
+ </>
+ )}
+ </div>
+ <div className="extension-card__footer">
+ <div className="extension-card__info">
+ <span>v{entry.version}</span>
+ {entry.author && <span>by {entry.author}</span>}
+ {entry.extensionType && (
+ <Badge variant="secondary">
+ {isLocal ? 'local db' : entry.extensionType}
+ </Badge>
+ )}
+ </div>
+ <div className="extension-card__actions">
+ {entry.installed ? (
+ <Badge variant={isLocal ? statusVariant(entry.status) : 'success'}>
+ <CheckCircle2 aria-hidden="true" />
+ {installedLabel}
+ </Badge>
+ ) : (
+ <Button
+ size="sm"
+ disabled={isLocal && installing}
+ onClick={() => onInstall(entry.installKey)}
+ >
+ <DownloadCloud aria-hidden="true" />
+ {isLocal && installing ? 'Installing...' : 'Install'}
+ </Button>
+ )}
+ </div>
+ </div>
+ </article>
+ );
+};
+
+const InstalledCatalogRow = ({ entry, onUninstall }) => {
+ const isLocal = entry.source === 'local';
+ const Icon = isLocal ? Archive : PackageCheck;
+
+ return (
+ <article className="installed-item card">
+ <div className="installed-item__main">
+ <div className={`installed-item__icon installed-item__icon--${isLocal ? 'local' : 'extension'}`}>
+ <Icon aria-hidden="true" />
+ </div>
+ <div className="installed-item__content">
+ <div className="installed-item__title-line">
+ <strong>{entry.displayName}</strong>
+ <span className="text-muted">v{entry.version}</span>
+ <Badge variant={isLocal ? 'warning' : 'outline'}>{entry.sourceLabel}</Badge>
+ </div>
+ {isLocal && (
+ <p className="installed-item__description">
+ Managed as a local registry mapping.
+ </p>
+ )}
+ </div>
+ </div>
+ <div className="installed-item__actions">
+ {isLocal ? (
+ <Badge variant="success">Installed</Badge>
+ ) : (
+ <Button size="sm" variant="destructive" onClick={() => onUninstall(entry.installId)}>
+ Uninstall
+ </Button>
+ )}
+ </div>
+ </article>
+ );
+};
+
+const PluginRow = ({ plugin, onToggle, onUninstall, statusVariant }) => (
+ <article className={`installed-item installed-item--plugin card ${plugin.status === 'error' ? 'installed-item--error' : ''}`}>
+ <div className="installed-item__main">
+ <div className="installed-item__icon installed-item__icon--plugin">
+ <PlugZap aria-hidden="true" />
+ </div>
+ <div className="installed-item__content">
+ <div className="installed-item__title-line">
+ <strong>{plugin.display_name}</strong>
+ <span className="text-muted">v{plugin.version}</span>
+ <Badge variant={statusVariant(plugin.status)}>{plugin.status}</Badge>
+ {plugin.has_backend && <Badge variant="secondary">Backend</Badge>}
+ {plugin.has_frontend && <Badge variant="secondary">Frontend</Badge>}
+ </div>
+ {plugin.description && <p className="installed-item__description">{plugin.description}</p>}
+ {plugin.error_message && <p className="installed-item__error">{plugin.error_message}</p>}
+ </div>
+ </div>
+ <div className="installed-item__actions">
+ <Button
+ size="sm"
+ variant={plugin.status === 'active' ? 'outline' : 'default'}
+ onClick={() => onToggle(plugin)}
+ >
+ {plugin.status === 'active' ? 'Disable' : 'Enable'}
+ </Button>
+ <Button size="sm" variant="destructive" onClick={() => onUninstall(plugin.id)}>
+ Uninstall
+ </Button>
+ </div>
+ </article>
+);
+
+const PluginInstallInput = ({
+ description,
+ placeholder,
+ value,
+ onChange,
+ onInstall,
+ disabled,
+ installDisabled,
+}) => (
+ <div className="plugin-install-source">
+ <p className="text-muted">{description}</p>
+ <div className="plugin-install-row">
+ <Input
+ placeholder={placeholder}
+ value={value}
+ onChange={(event) => onChange(event.target.value)}
+ onKeyDown={(event) => event.key === 'Enter' && onInstall()}
+ disabled={disabled}
+ />
+ <Button onClick={onInstall} disabled={installDisabled}>
+ <DownloadCloud aria-hidden="true" />
+ {disabled ? 'Installing...' : 'Install'}
+ </Button>
+ </div>
+ </div>
+);
+
+const RuntimeRow = ({ label, value, danger }) => (
+ <div className={`marketplace-runtime__row ${danger ? 'marketplace-runtime__row--danger' : ''}`}>
+ <span>{label}</span>
+ <strong>{value}</strong>
+ </div>
+);
+
+const EmptyState = ({ icon: Icon, title, description }) => (
+ <div className="empty-state marketplace-empty">
+ <Icon aria-hidden="true" />
+ <h3>{title}</h3>
+ <p>{description}</p>
+ </div>
+);
+
+const renderStars = (rating) => {
+ const normalizedRating = Math.max(0, Math.min(5, Number(rating) || 0));
+
+ return (
+ <span className="extension-card__stars" aria-label={`${normalizedRating.toFixed(1)} rating`}>
+ {Array.from({ length: 5 }, (_, index) => (
+ <Star
+ key={index}
+ aria-hidden="true"
+ className={index < Math.round(normalizedRating) ? 'is-filled' : ''}
+ />
+ ))}
+ </span>
+ );
+};
+
export default Marketplace;
diff --git a/frontend/src/plugins/ExtensionRoutes.jsx b/frontend/src/plugins/ExtensionRoutes.jsx
index 757a9cfe..b55b3b50 100644
--- a/frontend/src/plugins/ExtensionRoutes.jsx
+++ b/frontend/src/plugins/ExtensionRoutes.jsx
@@ -1,26 +1,43 @@
/**
- * Renders <Route> entries for each contributed route from active plugins.
+ * Extension route resolver.
*
- * Used by App.jsx inside the authenticated dashboard branch — extension
- * routes are protected by the same PrivateRoute guard as core pages.
+ * Splits contributed routes into two buckets based on their `layout`:
*
- * A contributed route is { path, component, layout? }. We resolve
- * `component` against the plugin's index module exports. Routes whose
- * components don't resolve are silently skipped (logged in dev) so a
- * misconfigured plugin can't blow up the whole route tree.
+ * dashboardRoutes — render inside <DashboardLayout/> alongside core
+ * pages (layout: 'padded' (default) | 'full').
+ *
+ * standaloneGroups — render OUTSIDE DashboardLayout. One group per
+ * distinct layout id (built-in 'bare' or any
+ * plugin-contributed layout). App.jsx wraps each
+ * group's routes in a parent <Route> that uses
+ * the layout component.
+ *
+ * Routes whose `component` (or whose custom `layout`) can't be resolved
+ * are skipped + logged in dev so a misconfigured plugin can't blow up
+ * the whole route tree.
*/
import { Route } from 'react-router-dom';
-import { useContributions, resolveComponent } from './contributions';
+import StandaloneLayout from '../layouts/StandaloneLayout';
+import {
+ useContributions,
+ resolveComponent,
+ resolveCustomLayout,
+ isInsideDashboard,
+} from './contributions';
+
+function devWarn(msg) {
+ if (import.meta.env.DEV) {
+ console.warn(`[plugins] ${msg}`);
+ }
+}
function buildRoute(contrib, key) {
const Component = resolveComponent(contrib.plugin, contrib.component);
if (!Component) {
- if (import.meta.env.DEV) {
- console.warn(
- `[plugins] Cannot resolve component "${contrib.component}" `
- + `for plugin "${contrib.plugin}" (route ${contrib.path})`
- );
- }
+ devWarn(
+ `Cannot resolve component "${contrib.component}" for plugin `
+ + `"${contrib.plugin}" (route ${contrib.path})`
+ );
return null;
}
return (
@@ -32,12 +49,53 @@ function buildRoute(contrib, key) {
);
}
-// React Router v6 requires Route children to be static JSX siblings —
-// returning a fragment of <Route>s from a function works because the
-// parent <Routes> walks the tree.
+// Built-in layout components for non-dashboard groups. Custom plugin
+// layouts get resolved via resolveCustomLayout().
+const BUILTIN_LAYOUT_COMPONENTS = {
+ bare: StandaloneLayout,
+};
+
export default function useExtensionRoutes() {
- const { routes } = useContributions();
- return (routes || [])
- .map((c, i) => buildRoute(c, `${c.plugin}:${c.path}:${i}`))
- .filter(Boolean);
+ const { routes, layouts } = useContributions();
+
+ const dashboardRoutes = [];
+ const groupsByLayout = new Map();
+
+ (routes || []).forEach((contrib, i) => {
+ const key = `${contrib.plugin}:${contrib.path}:${i}`;
+ const layoutId = contrib.layout || 'padded';
+
+ if (isInsideDashboard(layoutId)) {
+ const node = buildRoute(contrib, key);
+ if (node) dashboardRoutes.push(node);
+ return;
+ }
+
+ // Standalone (bare or custom). Resolve the layout component once
+ // per group; skip the whole route if its layout can't be found.
+ let LayoutComponent = BUILTIN_LAYOUT_COMPONENTS[layoutId]
+ || resolveCustomLayout(layoutId, layouts);
+ if (!LayoutComponent) {
+ devWarn(
+ `Cannot resolve layout "${layoutId}" for plugin `
+ + `"${contrib.plugin}" (route ${contrib.path})`
+ );
+ return;
+ }
+
+ const node = buildRoute(contrib, key);
+ if (!node) return;
+
+ let group = groupsByLayout.get(layoutId);
+ if (!group) {
+ group = { layoutId, LayoutComponent, routes: [] };
+ groupsByLayout.set(layoutId, group);
+ }
+ group.routes.push(node);
+ });
+
+ return {
+ dashboardRoutes,
+ standaloneGroups: Array.from(groupsByLayout.values()),
+ };
}
diff --git a/frontend/src/plugins/contributions.js b/frontend/src/plugins/contributions.js
index 3167c0e2..07faae60 100644
--- a/frontend/src/plugins/contributions.js
+++ b/frontend/src/plugins/contributions.js
@@ -57,8 +57,33 @@ const EMPTY = {
page_titles: {},
command_palette: [],
widgets: [],
+ layouts: [],
};
+// Built-in layout ids. These are reserved — a plugin can't redefine them.
+// padded → routes go inside DashboardLayout, normal padding (default)
+// full → routes go inside DashboardLayout, no padding (FULL_PAGE_ROUTES)
+// bare → routes go OUTSIDE DashboardLayout, just the page + auth guard
+export const BUILTIN_LAYOUTS = new Set(['padded', 'full', 'bare']);
+
+// True iff this layout is rendered inside the dashboard chrome. The
+// other case (bare + custom plugin layouts) gets its own top-level
+// route tree in App.jsx.
+export function isInsideDashboard(layoutId) {
+ if (!layoutId || layoutId === 'padded' || layoutId === 'full') return true;
+ return false;
+}
+
+// Resolve a custom (plugin-contributed) layout id to a React component.
+// Built-ins return null — App.jsx handles them directly. Returns null
+// if the id is unknown or the referenced component can't be found.
+export function resolveCustomLayout(layoutId, layouts) {
+ if (!layoutId || BUILTIN_LAYOUTS.has(layoutId)) return null;
+ const decl = (layouts || []).find((l) => l && l.id === layoutId);
+ if (!decl) return null;
+ return resolveComponent(decl.plugin, decl.component);
+}
+
let cachedPromise = null;
let cachedValue = null;
const subscribers = new Set();
diff --git a/frontend/src/plugins/plugins-manifest.json b/frontend/src/plugins/plugins-manifest.json
new file mode 100644
index 00000000..62e78a1a
--- /dev/null
+++ b/frontend/src/plugins/plugins-manifest.json
@@ -0,0 +1,12 @@
+{
+ "plugins": [
+ {
+ "name": "serverkit-git",
+ "slug": "serverkit-git",
+ "display_name": "Git Server (extension)",
+ "version": "1.0.0",
+ "frontend_entry": "",
+ "path": "serverkit-git"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/frontend/src/plugins/serverkit-git/index.jsx b/frontend/src/plugins/serverkit-git/index.jsx
new file mode 100644
index 00000000..dc44d152
--- /dev/null
+++ b/frontend/src/plugins/serverkit-git/index.jsx
@@ -0,0 +1,12 @@
+// Re-exports the existing host Git page as GitExtPage so the
+// contribution system can mount it at /git-ext while the hardcoded
+// /git route stays in place. Both routes hit the same /api/v1/git
+// backend and share state — this is intentional, the extension is
+// the same feature surfaced through the opt-in plugin pipeline so
+// you can A/B the two install paths.
+//
+// After install, this file lives at frontend/src/plugins/serverkit-git/
+// so the relative import resolves against the host's pages directory.
+import GitPage from '../../pages/Git';
+
+export const GitExtPage = GitPage;
diff --git a/frontend/src/plugins/serverkit-git/plugin.json b/frontend/src/plugins/serverkit-git/plugin.json
new file mode 100644
index 00000000..e9fc6767
--- /dev/null
+++ b/frontend/src/plugins/serverkit-git/plugin.json
@@ -0,0 +1,46 @@
+{
+ "name": "serverkit-git",
+ "display_name": "Git Server (extension)",
+ "version": "1.0.0",
+ "description": "Self-hosted Git server (Gitea) wrapper exposed as the /git-ext route. Runs alongside the built-in /git page so you can compare the opt-in extension flow against the hardcoded one.",
+ "author": "ServerKit",
+ "license": "MIT",
+ "category": "deployment",
+ "homepage": "https://github.com/jhd3197/ServerKit",
+ "permissions": [
+ "docker",
+ "filesystem"
+ ],
+ "contributions": {
+ "nav": [
+ {
+ "id": "git-ext",
+ "label": "Git (ext)",
+ "route": "/git-ext",
+ "category": "infrastructure",
+ "icon": "<circle cx=\"18\" cy=\"18\" r=\"3\"/><circle cx=\"6\" cy=\"6\" r=\"3\"/><path d=\"M6 21V9a9 9 0 0 0 9 9\"/>"
+ }
+ ],
+ "routes": [
+ {
+ "path": "git-ext",
+ "component": "GitExtPage"
+ },
+ {
+ "path": "git-ext/:tab",
+ "component": "GitExtPage"
+ }
+ ],
+ "page_titles": {
+ "/git-ext": "Git (extension)"
+ },
+ "command_palette": [
+ {
+ "label": "Git (extension)",
+ "path": "/git-ext",
+ "category": "Pages",
+ "keywords": "git repos extension plugin"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/services/api/plugins.js b/frontend/src/services/api/plugins.js
index 419a277b..4f67fea6 100644
--- a/frontend/src/services/api/plugins.js
+++ b/frontend/src/services/api/plugins.js
@@ -51,9 +51,22 @@ export async function disablePlugin(pluginId) {
}
// Returns the merged contribution envelope for active plugins:
-// { nav, routes, page_titles, command_palette, widgets }
+// { nav, routes, page_titles, command_palette, widgets, layouts }
// Each list item carries a `plugin` slug field so the UI can resolve
// `component` references against the right plugin module.
export async function getPluginContributions() {
return this.request('/plugins/contributions');
}
+
+// Returns extensions bundled with the repo at builtin-extensions/.
+// Each entry: { folder, path, slug, manifest, installed, install_id, status }.
+export async function getBuiltinExtensions() {
+ return this.request('/plugins/builtin');
+}
+
+// One-click install for a bundled extension by slug.
+export async function installBuiltinExtension(slug) {
+ return this.request(`/plugins/builtin/${encodeURIComponent(slug)}/install`, {
+ method: 'POST',
+ });
+}
diff --git a/frontend/src/styles/main.scss b/frontend/src/styles/main.scss
index 58190562..0d53a00c 100644
--- a/frontend/src/styles/main.scss
+++ b/frontend/src/styles/main.scss
@@ -97,7 +97,6 @@
@import 'pages/_services';
@import 'pages/_service-detail';
@import 'pages/_fleet-monitor';
-@import 'pages/_agent-plugins';
@import 'pages/_server-templates';
@import 'pages/_server-packages';
@import 'pages/_server-services';
diff --git a/frontend/src/styles/pages/_agent-plugins.scss b/frontend/src/styles/pages/_agent-plugins.scss
deleted file mode 100644
index 5337fb6b..00000000
--- a/frontend/src/styles/pages/_agent-plugins.scss
+++ /dev/null
@@ -1,111 +0,0 @@
-// Agent Plugins page styles
-
-.agent-plugins-page {
- .plugins-grid {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
- gap: $spacing-lg;
- margin-top: $spacing-lg;
- }
-
- .plugin-card {
- padding: $spacing-lg;
- display: flex;
- flex-direction: column;
- gap: $spacing-sm;
-
- &__header {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- }
-
- &__info {
- display: flex;
- align-items: baseline;
- gap: $spacing-sm;
-
- h3 {
- margin: 0;
- font-size: 1.1rem;
- }
- }
-
- &__version {
- color: $text-muted;
- font-size: 0.85rem;
- font-family: $font-mono;
- }
-
- &__desc {
- color: $text-secondary;
- font-size: 0.9rem;
- margin: 0;
- line-height: 1.5;
- }
-
- &__meta {
- display: flex;
- gap: $spacing-md;
- font-size: 0.85rem;
- color: $text-muted;
- }
-
- &__capabilities,
- &__permissions {
- display: flex;
- flex-wrap: wrap;
- gap: $spacing-xs;
- }
-
- &__actions {
- display: flex;
- gap: $spacing-sm;
- margin-top: $spacing-sm;
- padding-top: $spacing-sm;
- border-top: 1px solid $border-color;
- }
- }
-
- .server-select-list {
- display: flex;
- flex-direction: column;
- gap: $spacing-xs;
- max-height: 300px;
- overflow-y: auto;
- }
-
- .server-select-item {
- display: flex;
- align-items: center;
- gap: $spacing-sm;
- padding: $spacing-sm $spacing-md;
- border-radius: $radius-md;
- cursor: pointer;
- transition: background-color 0.15s;
-
- &:hover {
- background: $hover-bg;
- }
- }
-
- .checkbox-group {
- display: flex;
- flex-wrap: wrap;
- gap: $spacing-sm;
- }
-
- .checkbox-label {
- display: flex;
- align-items: center;
- gap: $spacing-xs;
- font-size: 0.9rem;
- cursor: pointer;
- }
-
- .form-row {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: $spacing-md;
- }
-}
diff --git a/frontend/src/styles/pages/_marketplace.scss b/frontend/src/styles/pages/_marketplace.scss
index 3afec784..61cb69d1 100644
--- a/frontend/src/styles/pages/_marketplace.scss
+++ b/frontend/src/styles/pages/_marketplace.scss
@@ -1,160 +1,846 @@
// Marketplace page styles
.marketplace-page {
- .marketplace-filters {
+ .card {
+ border-radius: $radius-lg;
+ }
+
+ .marketplace-hero {
+ position: relative;
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto;
+ align-items: center;
+ gap: $space-6;
+ margin-bottom: $space-5;
+ padding: $space-6;
+ overflow: hidden;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-lg;
+ background:
+ linear-gradient(135deg, fade($accent-primary-raw, 14%), transparent 36%),
+ linear-gradient(180deg, fade($bg-elevated-raw, 88%), fade($bg-card-raw, 96%));
+
+ &::before {
+ content: '';
+ position: absolute;
+ inset: 0 0 auto;
+ height: 2px;
+ background: linear-gradient(90deg, $accent-primary, $success, $warning);
+ }
+ }
+
+ .marketplace-hero__content {
+ min-width: 0;
+ }
+
+ .marketplace-hero__actions {
+ display: flex;
+ justify-content: flex-end;
+ }
+
+ .marketplace-eyebrow {
+ display: inline-flex;
+ align-items: center;
+ gap: $space-2;
+ margin-bottom: $space-3;
+ color: $accent-primary;
+ font-size: $font-size-sm;
+ font-weight: $font-weight-semibold;
+ letter-spacing: 0;
+
+ svg {
+ width: 16px;
+ height: 16px;
+ }
+ }
+
+ .page-header-content {
+ h1 {
+ margin: 0 0 $space-2;
+ font-size: $font-size-3xl;
+ line-height: $line-height-tight;
+ letter-spacing: 0;
+ }
+
+ .page-description {
+ max-width: 680px;
+ color: $text-secondary;
+ font-size: $font-size-base;
+ line-height: $line-height-normal;
+ }
+ }
+
+ .marketplace-stats {
+ display: grid;
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ gap: $space-3;
+ margin-bottom: $space-5;
+ }
+
+ .marketplace-stat {
+ display: flex;
+ align-items: center;
+ gap: $space-3;
+ min-height: 76px;
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-lg;
+ background: fade($bg-card-raw, 92%);
+ }
+
+ .marketplace-stat__icon {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 38px;
+ height: 38px;
+ flex: 0 0 38px;
+ border-radius: $radius-lg;
+
+ svg {
+ width: 19px;
+ height: 19px;
+ }
+ }
+
+ .marketplace-stat__value {
+ color: $text-primary;
+ font-size: $font-size-xl;
+ font-weight: $font-weight-bold;
+ line-height: 1.1;
+ }
+
+ .marketplace-stat__label {
+ margin-top: $space-1;
+ color: $text-tertiary;
+ font-size: $font-size-sm;
+ font-weight: $font-weight-medium;
+ }
+
+ .marketplace-stat--blue .marketplace-stat__icon {
+ background: fade($info, 14%);
+ color: $info;
+ }
+
+ .marketplace-stat--amber .marketplace-stat__icon {
+ background: fade($warning, 14%);
+ color: $warning;
+ }
+
+ .marketplace-stat--green .marketplace-stat__icon {
+ background: fade($success, 14%);
+ color: $success;
+ }
+
+ .marketplace-stat--violet .marketplace-stat__icon {
+ background: fade($accent-primary-raw, 14%);
+ color: $accent-primary;
+ }
+
+ .marketplace-stat--red .marketplace-stat__icon {
+ background: fade($danger, 14%);
+ color: $danger;
+ }
+
+ .marketplace-tabs__list {
+ margin-bottom: $space-5;
+
+ svg {
+ width: 16px;
+ height: 16px;
+ }
+ }
+
+ .marketplace-toolbar {
+ display: grid;
+ grid-template-columns: minmax(260px, 1fr) 220px auto;
+ gap: $space-3;
+ align-items: center;
+ margin-bottom: $space-6;
+ }
+
+ .marketplace-search {
+ position: relative;
+ min-width: 0;
+
+ .ui-input {
+ padding-left: 42px;
+ background: $bg-card;
+ }
+ }
+
+ .marketplace-search__icon {
+ position: absolute;
+ top: 50%;
+ left: $space-4;
+ z-index: 1;
+ width: 16px;
+ height: 16px;
+ color: $text-tertiary;
+ transform: translateY(-50%);
+ pointer-events: none;
+ }
+
+ .marketplace-category-select {
+ width: 100%;
+ height: 40px;
+ }
+
+ .marketplace-browse-grid {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) 292px;
+ gap: $space-6;
+ align-items: start;
+ }
+
+ .marketplace-main-stack,
+ .plugins-section {
+ display: flex;
+ flex-direction: column;
+ gap: $space-8;
+ min-width: 0;
+ }
+
+ .marketplace-section {
+ min-width: 0;
+ }
+
+ .marketplace-section__header {
display: flex;
- gap: $spacing-md;
- margin: $spacing-lg 0;
+ justify-content: space-between;
+ align-items: flex-end;
+ gap: $space-4;
+ margin-bottom: $space-4;
- .form-input { flex: 1; }
- .form-select { width: 200px; }
+ h2 {
+ margin: 0;
+ color: $text-primary;
+ font-size: $font-size-lg;
+ font-weight: $font-weight-semibold;
+ letter-spacing: 0;
+ }
+ }
+
+ .marketplace-kicker {
+ margin: 0 0 $space-1;
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-semibold;
+ letter-spacing: 0;
+ text-transform: uppercase;
}
.extensions-grid {
display: grid;
- grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
- gap: $spacing-lg;
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
+ gap: $space-4;
}
.extension-card {
- padding: $spacing-lg;
display: flex;
flex-direction: column;
- gap: $spacing-sm;
+ gap: $space-4;
+ min-height: 284px;
+ padding: $space-5;
+ background:
+ linear-gradient(180deg, fade($bg-elevated-raw, 76%), fade($bg-card-raw, 98%));
+ transition:
+ transform $transition-base,
+ border-color $transition-base,
+ box-shadow $transition-base;
+
+ &:hover {
+ transform: translateY(-2px);
+ border-color: $border-active;
+ box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
+ }
+ }
+
+ .extension-card__topline,
+ .extension-card__footer,
+ .extension-card__info,
+ .extension-card__actions,
+ .extension-card__signals {
+ display: flex;
+ align-items: center;
+ }
+
+ .extension-card__topline,
+ .extension-card__footer {
+ justify-content: space-between;
+ gap: $space-3;
+ }
+
+ .extension-card__badges {
+ display: flex;
+ justify-content: flex-end;
+ align-items: center;
+ gap: $space-2;
+ flex-wrap: wrap;
+ min-width: 0;
+ }
+
+ .extension-card__icon {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 42px;
+ height: 42px;
+ flex: 0 0 42px;
+ border-radius: $radius-lg;
+ color: $accent-primary;
+ background: fade($accent-primary-raw, 12%);
+
+ svg {
+ width: 21px;
+ height: 21px;
+ }
+ }
+
+ .extension-card__icon--monitoring {
+ color: $info;
+ background: fade($info, 12%);
+ }
+
+ .extension-card__icon--security {
+ color: $success;
+ background: fade($success, 12%);
+ }
+
+ .extension-card__icon--deployment {
+ color: $warning;
+ background: fade($warning, 12%);
+ }
+
+ .extension-card__icon--integration {
+ color: $color-docker;
+ background: fade($color-docker, 12%);
+ }
+
+ .extension-card__icon--ui {
+ color: #ec4899;
+ background: rgba(236, 72, 153, 0.12);
+ }
+
+ .extension-card__body {
+ min-width: 0;
+
+ h3 {
+ margin: 0 0 $space-2;
+ color: $text-primary;
+ font-size: $font-size-md;
+ line-height: $line-height-tight;
+ letter-spacing: 0;
+ }
+ }
+
+ .extension-card__desc {
+ display: -webkit-box;
+ min-height: 64px;
+ margin: 0;
+ overflow: hidden;
+ color: $text-secondary;
+ font-size: $font-size-base;
+ line-height: $line-height-normal;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 3;
+ }
- &__header {
- display: flex;
- justify-content: space-between;
+ .extension-card__signals {
+ justify-content: space-between;
+ gap: $space-3;
+ margin-top: auto;
+ color: $text-tertiary;
+ font-size: $font-size-sm;
+
+ > span {
+ display: inline-flex;
align-items: center;
- h3 { margin: 0; }
+ gap: $space-2;
+ min-width: 0;
}
+ }
- &__desc {
- color: $text-secondary;
- font-size: 0.9rem;
- margin: 0;
- line-height: 1.5;
+ .extension-card__stars {
+ display: inline-flex;
+ align-items: center;
+ gap: 2px;
+ color: $text-tertiary;
+
+ svg {
+ width: 13px;
+ height: 13px;
}
- &__meta {
- display: flex;
- justify-content: space-between;
- font-size: 0.85rem;
- color: $text-muted;
+ .is-filled {
+ color: $warning;
+ fill: currentColor;
}
+ }
+
+ .extension-card__signal-text {
+ color: $text-tertiary;
+ }
+
+ .extension-card__footer {
+ padding-top: $space-4;
+ border-top: 1px solid $border-subtle;
+ }
- &__rating {
- color: $warning-color;
- letter-spacing: 1px;
+ .extension-card__info {
+ flex-wrap: wrap;
+ gap: $space-2;
+ min-width: 0;
+ color: $text-tertiary;
+ font-size: $font-size-sm;
+ }
+
+ .marketplace-side-panel {
+ display: flex;
+ flex-direction: column;
+ gap: $space-4;
+ position: sticky;
+ top: $space-4;
+ }
+
+ .marketplace-panel {
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-lg;
+ background: fade($bg-card-raw, 92%);
+ }
+
+ .marketplace-panel__title {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ margin-bottom: $space-3;
+ color: $text-primary;
+ font-size: $font-size-base;
+ font-weight: $font-weight-semibold;
+
+ svg {
+ width: 16px;
+ height: 16px;
+ color: $accent-primary;
}
+ }
- &__info {
- display: flex;
- gap: $spacing-sm;
- font-size: 0.8rem;
- color: $text-muted;
+ .marketplace-category-list {
+ display: flex;
+ flex-direction: column;
+ gap: $space-2;
+ }
+
+ .marketplace-category {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ width: 100%;
+ height: 36px;
+ padding: 0 $space-3;
+ border: 1px solid transparent;
+ border-radius: $radius-md;
+ background: transparent;
+ color: $text-secondary;
+ font-family: inherit;
+ font-size: $font-size-sm + 1;
+ font-weight: $font-weight-medium;
+ text-align: left;
+ cursor: pointer;
+ transition:
+ color $transition-base,
+ background $transition-base,
+ border-color $transition-base;
+
+ svg {
+ width: 15px;
+ height: 15px;
+ }
+
+ &:hover,
+ &--active {
+ border-color: $border-active;
+ background: $bg-hover;
+ color: $text-primary;
+ }
+
+ &--active {
+ border-color: $accent-primary;
+ }
+ }
+
+ .marketplace-runtime {
+ display: flex;
+ flex-direction: column;
+ gap: $space-2;
+ }
+
+ .marketplace-runtime__row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: $space-3;
+ padding: $space-2 0;
+ color: $text-secondary;
+ font-size: $font-size-sm;
+ border-bottom: 1px solid $border-subtle;
+
+ &:last-child {
+ border-bottom: none;
+ }
+
+ strong {
+ color: $text-primary;
+ font-weight: $font-weight-semibold;
}
- &__actions {
- margin-top: $spacing-sm;
- padding-top: $spacing-sm;
- border-top: 1px solid $border-color;
+ &--danger strong {
+ color: $danger;
}
}
.installed-list {
display: flex;
flex-direction: column;
- gap: $spacing-sm;
- margin-top: $spacing-lg;
+ gap: $space-3;
}
.installed-item {
display: flex;
+ align-items: center;
justify-content: space-between;
+ gap: $space-4;
+ padding: $space-4;
+ }
+
+ .installed-item__main {
+ display: flex;
align-items: center;
- padding: $spacing-md;
- flex-wrap: wrap;
+ gap: $space-3;
+ min-width: 0;
+ flex: 1;
+ }
- &__info {
- display: flex;
- align-items: baseline;
- gap: $spacing-sm;
- flex-wrap: wrap;
- }
+ .installed-item__icon {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 38px;
+ height: 38px;
+ flex: 0 0 38px;
+ border-radius: $radius-lg;
- &__actions {
- display: flex;
- gap: $spacing-sm;
+ svg {
+ width: 19px;
+ height: 19px;
}
+ }
+
+ .installed-item__icon--extension {
+ color: $success;
+ background: fade($success, 12%);
+ }
+
+ .installed-item__icon--local {
+ color: $warning;
+ background: fade($warning, 12%);
+ }
+
+ .installed-item__icon--plugin {
+ color: $accent-primary;
+ background: fade($accent-primary-raw, 12%);
+ }
+
+ .installed-item__content {
+ display: flex;
+ flex-direction: column;
+ gap: $space-1;
+ min-width: 0;
- &--error {
- border-color: rgba(239, 68, 68, 0.3);
+ strong {
+ color: $text-primary;
+ font-size: $font-size-base;
}
}
- // Plugin install section
- .plugins-section {
- margin-top: $spacing-lg;
+ .installed-item__title-line,
+ .installed-item__actions {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ flex-wrap: wrap;
+ }
+
+ .installed-item__description,
+ .installed-item__error {
+ margin: $space-1 0 0;
+ color: $text-secondary;
+ font-size: $font-size-sm;
+ line-height: $line-height-normal;
+ }
+
+ .installed-item__error {
+ color: $danger;
+ }
+
+ .installed-item--error {
+ border-color: fade($danger, 30%);
}
.plugin-install-form {
- padding: $spacing-lg;
- margin-bottom: $spacing-lg;
+ padding: $space-5;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-lg;
+ background: fade($bg-card-raw, 92%);
+ }
+
+ .plugin-install-form__heading {
+ display: flex;
+ align-items: flex-start;
+ gap: $space-3;
+ margin-bottom: $space-4;
h3 {
margin: 0 0 $space-1;
+ color: $text-primary;
+ font-size: $font-size-md;
+ font-weight: $font-weight-semibold;
}
p {
- margin: 0 0 $spacing-md;
- font-size: $font-size-sm;
+ margin: 0;
}
}
- .plugin-install-row {
- display: flex;
- gap: $spacing-sm;
+ .plugin-install-form__icon {
+ display: inline-flex;
align-items: center;
+ justify-content: center;
+ width: 38px;
+ height: 38px;
+ flex: 0 0 38px;
+ border-radius: $radius-lg;
+ color: $accent-primary;
+ background: fade($accent-primary-raw, 12%);
- .form-input,
- input[type="text"] {
- flex: 1;
- }
-
- input[type="file"] {
- flex: 1;
- color: var(--text-muted);
- font-size: $font-size-sm;
+ svg {
+ width: 19px;
+ height: 19px;
}
}
.plugin-install-tabs {
display: inline-flex;
- gap: 0;
- margin-bottom: $spacing-md;
- background: var(--border-color, #2a2e36);
- border-radius: 6px;
- padding: 2px;
+ gap: $space-1;
+ margin-bottom: $space-4;
+ padding: $space-1;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-lg;
+ background: $bg-body;
}
.plugin-install-tab {
- padding: 6px 14px;
+ display: inline-flex;
+ align-items: center;
+ gap: $space-2;
+ height: 32px;
+ padding: 0 $space-3;
+ border: 1px solid transparent;
+ border-radius: $radius-md;
background: transparent;
- border: none;
- color: var(--text-muted);
- font-size: $font-size-sm;
- font-weight: 600;
+ color: $text-secondary;
+ font-family: inherit;
+ font-size: $font-size-sm + 1;
+ font-weight: $font-weight-semibold;
cursor: pointer;
- border-radius: 4px;
+ transition:
+ background $transition-base,
+ color $transition-base,
+ border-color $transition-base;
+
+ svg {
+ width: 14px;
+ height: 14px;
+ }
&:hover {
- color: var(--text-color);
+ color: $text-primary;
}
&--active {
- background: var(--primary-color, #6366f1);
- color: #fff;
+ border-color: $accent-primary;
+ background: fade($accent-primary-raw, 12%);
+ color: $text-primary;
+ }
+ }
+
+ .plugin-install-source {
+ p {
+ margin: 0 0 $space-3;
+ font-size: $font-size-sm;
+ }
+ }
+
+ .plugin-install-row {
+ display: flex;
+ align-items: center;
+ gap: $space-3;
+
+ .ui-input,
+ input[type='text'] {
+ flex: 1;
+ min-width: 0;
+ }
+ }
+
+ .marketplace-file-input {
+ flex: 1;
+ min-width: 0;
+ }
+
+ .plugin-file-note {
+ margin-top: $space-2;
+ color: $text-tertiary;
+ font-size: $font-size-sm;
+ }
+
+ .marketplace-empty {
+ border-radius: $radius-lg;
+
+ svg {
+ width: 30px;
+ height: 30px;
+ }
+ }
+
+ .marketplace-submit-modal {
+ max-width: 680px;
+
+ .modal-header {
+ align-items: flex-start;
+
+ h2 {
+ margin-bottom: $space-1;
+ }
+
+ p {
+ margin: 0;
+ font-size: $font-size-sm;
+ }
+ }
+
+ .modal-close {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+
+ svg {
+ width: 18px;
+ height: 18px;
+ }
+ }
+ }
+
+ .marketplace-submit-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: $space-4;
+
+ .form-group--full {
+ grid-column: 1 / -1;
+ }
+ }
+
+ @media (max-width: 1180px) {
+ .marketplace-browse-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .marketplace-side-panel {
+ position: static;
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+ }
+
+ @media (max-width: $breakpoint-md) {
+ .marketplace-hero {
+ grid-template-columns: 1fr;
+ padding: $space-5;
+ }
+
+ .marketplace-hero__actions {
+ justify-content: stretch;
+
+ .btn {
+ width: 100%;
+ }
+ }
+
+ .marketplace-stats,
+ .marketplace-side-panel {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+
+ .marketplace-toolbar {
+ grid-template-columns: 1fr;
+ }
+
+ .extensions-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .installed-item {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+
+ .installed-item__actions {
+ width: 100%;
+
+ .btn {
+ flex: 1;
+ }
+ }
+
+ .plugin-install-row {
+ align-items: stretch;
+ flex-direction: column;
+
+ .btn {
+ width: 100%;
+ }
+ }
+
+ }
+
+ @media (max-width: $breakpoint-sm) {
+ .page-header-content h1 {
+ font-size: $font-size-2xl;
+ }
+
+ .marketplace-stats,
+ .marketplace-side-panel,
+ .marketplace-submit-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .marketplace-section__header {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+
+ .extension-card__topline,
+ .extension-card__footer,
+ .extension-card__signals {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+
+ .extension-card__actions,
+ .extension-card__actions .btn {
+ width: 100%;
}
}
}
diff --git a/frontend/vite.config.js b/frontend/vite.config.js
index 5526f13b..eb92281f 100644
--- a/frontend/vite.config.js
+++ b/frontend/vite.config.js
@@ -5,7 +5,8 @@ import { fileURLToPath } from 'url'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
- const apiTarget = (env.VITE_API_URL || 'http://localhost:5000/api/v1').replace(/\/api\/v1\/?$/, '')
+ const frontendPort = Number(env.SERVERKIT_FRONTEND_PORT) || 41921
+ const apiTarget = (env.VITE_API_URL || 'http://localhost:47927/api/v1').replace(/\/api\/v1\/?$/, '')
return {
plugins: [react(), tailwindcss()],
@@ -20,7 +21,7 @@ export default defineConfig(({ mode }) => {
},
},
server: {
- port: 5274,
+ port: frontendPort,
proxy: {
'/api': {
target: apiTarget,
diff --git a/quick-start.sh b/quick-start.sh
index 230df9d5..547fafc5 100644
--- a/quick-start.sh
+++ b/quick-start.sh
@@ -72,8 +72,8 @@ fi
# 5. Launch
echo -e "\n${GREEN}✅ Setup Complete!${NC}"
echo -e "Starting ServerKit..."
-echo -e " - ${CYAN}Frontend:${NC} http://localhost:5173"
-echo -e " - ${CYAN}Backend:${NC} http://localhost:5000"
+echo -e " - ${CYAN}Frontend:${NC} http://localhost:41921"
+echo -e " - ${CYAN}Backend:${NC} http://localhost:47927"
echo -e "\n${YELLOW}Press Ctrl+C to stop both servers.${NC}\n"
# Run dev.sh to handle the dual-process execution
diff --git a/scripts/dev/setup-linux.sh b/scripts/dev/setup-linux.sh
index e028edbe..b3c74268 100755
--- a/scripts/dev/setup-linux.sh
+++ b/scripts/dev/setup-linux.sh
@@ -62,8 +62,9 @@ if [ ! -f ".env" ]; then
SECRET_KEY=dev-secret-key-change-in-production
JWT_SECRET_KEY=dev-jwt-key-change-in-production
DATABASE_URL=sqlite:///backend/instance/serverkit.db
-CORS_ORIGINS=http://localhost,http://localhost:3000,http://localhost:5173
+CORS_ORIGINS=http://localhost:41921,http://127.0.0.1:41921,http://localhost:47927,http://127.0.0.1:47927
FLASK_ENV=development
+PORT=47927
EOF
fi
@@ -85,6 +86,6 @@ echo " Terminal 2 (Frontend):"
echo " cd frontend && npm run dev"
echo ""
echo "Access:"
-echo " Frontend: http://localhost:5173"
-echo " Backend: http://localhost:5000"
+echo " Frontend: http://localhost:41921"
+echo " Backend: http://localhost:47927"
echo ""
diff --git a/scripts/dev/setup-wsl.sh b/scripts/dev/setup-wsl.sh
index 70f1abde..02473668 100755
--- a/scripts/dev/setup-wsl.sh
+++ b/scripts/dev/setup-wsl.sh
@@ -57,6 +57,8 @@ FLASK_DEBUG=1
SECRET_KEY=dev-secret-key-change-in-production
JWT_SECRET_KEY=jwt-secret-key-change-in-production
DATABASE_URL=sqlite:///instance/serverkit.db
+PORT=47927
+CORS_ORIGINS=http://localhost:41921,http://127.0.0.1:41921,http://localhost:47927,http://127.0.0.1:47927
EOF
fi
echo -e "${GREEN}Done!${NC}"
@@ -64,7 +66,7 @@ echo -e "${GREEN}Done!${NC}"
echo -e "${YELLOW}[5/6] Setting up frontend...${NC}"
cd "$PROJECT_ROOT/frontend"
npm install
-[ ! -f .env.development ] && echo "VITE_API_URL=http://localhost:5000/api/v1" > .env.development
+[ ! -f .env.development ] && echo "VITE_API_URL=http://localhost:47927/api/v1" > .env.development
echo -e "${GREEN}Done!${NC}"
echo -e "${YELLOW}[6/6] Creating admin user...${NC}"
@@ -103,5 +105,5 @@ echo " DB: ~/.serverkit/serverkit.db"
echo ""
echo " Start: ./dev.sh"
echo ""
-echo " Open: http://localhost:5173"
+echo " Open: http://localhost:41921"
echo ""
diff --git a/scripts/setup-wsl.sh b/scripts/setup-wsl.sh
index 2018313a..8a8cff9f 100644
--- a/scripts/setup-wsl.sh
+++ b/scripts/setup-wsl.sh
@@ -216,7 +216,7 @@ fi
if [ "$IN_WSL" -eq 1 ]; then
header "WSL tips"
info "Backend already binds to 0.0.0.0 and uses a stat-based reloader (good for WSL)."
- info "Vite dev server is reachable from Windows at http://localhost:5173 thanks to WSL2 localhost forwarding."
+ info "Vite dev server is reachable from Windows at http://localhost:41921 thanks to WSL2 localhost forwarding."
info "If hot-reload feels stuck, ensure the repo lives under your Linux home (~) rather than /mnt/c."
if command -v ngrok &>/dev/null; then
ok "ngrok is installed (use ./dev.sh tunnel to expose the backend)"