Plugin Development Guide#
This guide explains how to implement production plugins beyond the quick demonstration.
See also: PLUGIN_DEMONSTRATION
1. Contract summary#
A plugin module should provide:
PLUGIN_MANIFEST(orget_plugin_manifest())one of:
register_plugin(registrar)PLUGIN_METHODS
Required manifest fields:
plugin_idnameversionapi_version(currently"1")
Optional fields:
descriptionauthorcapabilitiesentrypoint
2. Feature key targeting#
Methods are registered to a feature key + method name.
Example:
registrar.register_method("batch_processing.auto_typing", "lab_summary", my_func)
If selected method exists as plugin method, it overrides same-name builtin method at runtime.
3. Method signature strategy#
Use the builtin feature function signature as reference for compatibility.
Examples:
batch auto typing method receives
(folder, options, config)simplification method receives
(dataframe, config)validation run method receives
(swc_text, config)
When replacing a method, return the same output shape expected by caller.
4. Loading behavior#
swcstudio plugins load <module>is process-local.SWCSTUDIO_PLUGINSenables autoload each new process.
macOS/Linux:
export SWCSTUDIO_PLUGINS="my_lab_plugins.plugin_a,my_lab_plugins.plugin_b"
Windows PowerShell:
$env:SWCSTUDIO_PLUGINS = "my_lab_plugins.plugin_a,my_lab_plugins.plugin_b"
Windows cmd:
set SWCSTUDIO_PLUGINS=my_lab_plugins.plugin_a,my_lab_plugins.plugin_b
5. Safety recommendations#
validate inputs early (paths/config fields)
return deterministic payloads
include clear error messages
avoid side effects outside output/log paths
write logs/reports for auditability
6. Versioning recommendations#
bump plugin
versionon behavior changeskeep
api_versionaligned with app supportmaintain changelog in plugin repo/lab docs
7. Testing checklist#
module import works in target venv
swcstudio plugins load ...succeedsswcstudio plugins list --feature-key ...shows methodcommand using
--config-json {"method":"..."}executesoutput/report files are generated correctly
8. Thin-wrapper pattern#
For third-party tools or in-house libraries:
plugin method accepts swcstudio inputs
plugin method calls external command/library
plugin method maps output back into swcstudio result payload
This pattern avoids rewriting third-party algorithms while still integrating into SWC-Studio workflows.