-
Notifications
You must be signed in to change notification settings - Fork 2
Why Plugins
Small core, big plugin system - this is how we build tools that adapt to humans, not the other way around.
Traditional performance testing tools suffer from:
- One-size-fits-none: Beginners are overwhelmed, experts are slowed down
- Feature bloat: Every feature is loaded even if unused
- Rigid workflows: Can't adapt to different skill levels
- Poor maintainability: Core changes affect everything
Django Mercury's plugin architecture embodies the 80-20 Human-in-the-Loop philosophy:
The core only handles:
- Basic test execution
- Performance metric collection
- Plugin orchestration
- Profile management
Plugins provide everything else:
- Educational features
- Discovery mechanisms
- Interactive interfaces
- Reporting formats
- AI integrations
The plugin system enables Mercury to serve three distinct audiences through profiles:
mercury-test --profile studentEnabled plugins:
-
learn: Interactive quizzes and tutorials -
wizard: Guided test selection -
hints: Performance tips after tests -
discovery: Helpful error messages
Experience: Slower, educational, builds understanding
mercury-test --profile expertEnabled plugins:
-
discovery: Fast project location only
Disabled:
- No interruptions
- No tutorials
- No hints
Experience: Fast, direct, professional
mercury-test --profile agentEnabled plugins:
-
discovery: Automated project finding
Output:
- Structured JSON
- Machine-readable errors
- Automation-friendly
Experience: Predictable, parseable, integrable
Users start with educational plugins and gradually move to expert mode:
# Student starting out
[profiles.student]
plugins.enabled = ["discovery", "wizard", "learn", "hints"]
# Growing expertise - fewer educational interruptions
[profiles.intermediate]
plugins.enabled = ["discovery", "wizard", "hints"]
# Expert - just the essentials
[profiles.expert]
plugins.enabled = ["discovery"]Each plugin is self-contained:
# plugin_hints.py - completely independent
class HintsPlugin(MercuryPlugin):
name = "hints"
audiences = ["student"]
def post_test_hook(self, args, result, elapsed):
if elapsed > 100:
self.show_performance_tips()Anyone can add features without touching core:
# Custom plugin for your team
class TeamStandardsPlugin(MercuryPlugin):
name = "team_standards"
def post_test_hook(self, args, result, elapsed):
self.check_team_performance_standards()
self.generate_team_report()Only load what you need:
# Lazy loading based on profile
if "learn" in enabled_plugins:
from .learn import LearnPlugin # Heavy educational content
# Expert mode never loads educational contentThe discovery plugin demonstrates adaptable behavior:
def smart_find_manage_py(self, args):
location = self._search_for_project()
if not location:
# Educational error message
print("❌ Could not find Django project")
print("💡 Suggestions:")
print(" • Make sure you're in a Django project")
print(" • Look for a manage.py file")
print(" • Try: mercury-test --search-deep")
print("📚 Learn about Django structure: [link]")def smart_find_manage_py(self, args):
location = self._search_for_project()
if not location:
# Concise error
print("No Django project found")
return Nonedef smart_find_manage_py(self, args):
location = self._search_for_project()
return {
"status": "error" if not location else "success",
"location": str(location) if location else None,
"search_paths": self._get_searched_paths()
}Every plugin should know its audience:
class MercuryPlugin:
audiences = ["student", "expert", "agent"] # Who is this for?
complexity_level = 1 # 1-5 scaleStart simple, reveal complexity as needed:
def show_results(self, results, verbosity=1):
if verbosity == 1:
print(f"Found {len(results)} issues")
elif verbosity == 2:
for issue in results:
print(f"- {issue.type}: {issue.location}")
else:
# Full details with explanationsPlugins should never break the core:
def execute(self, args):
try:
return self._do_work(args)
except Exception as e:
logger.warning(f"Plugin {self.name} failed: {e}")
return 0 # Don't crash# mercury_config.toml
[mercury]
profile = "student" # This determines everything
[profiles.student]
plugins.enabled = ["discovery", "wizard", "learn", "hints"]
educational_mode = true
verbosity = "high"
[profiles.expert]
plugins.enabled = ["discovery"]
educational_mode = false
verbosity = "low"Plugins can be enabled/disabled per run:
# Expert wanting to learn something new
mercury-test --learn # Temporarily enable learn plugin
# Student wanting faster results
mercury-test --no-hints # Temporarily disable hintsPlugins preserve human wisdom while enabling automation:
-
learn: Builds understanding through quizzes -
wizard: Guides decision-making -
hints: Provides contextual tips
-
discovery: Automates project finding - Future:
auto_fix: Safe automatic fixes - Future:
ci_reporter: CI/CD integration
- Future:
mentor: AI-assisted learning - Future:
reviewer: Automated code review with explanations
The plugin architecture ensures Django Mercury:
- Grows with users - From student to expert
- Adapts to contexts - Development, CI/CD, education
- Preserves learning - Never fully automates understanding
- Enables innovation - Community can extend freely
- Learn about Student Plugins for educational features
- Explore Expert Plugins for professional workflows
- Understand Agent Plugins for AI integration
- Create your own plugin for your team
Remember: The best tools adapt to humans, not the other way around. That's why we build with plugins.