refactor(workflow): convert all plugins to class/struct + factory pattern

- Python: class extending NodeExecutor + factory.py (80+ plugins)
- TypeScript: class implements NodeExecutor + factory.ts (7 groups, 116 classes)
- Go: struct with methods + factory.go (36 plugins)
- Rust: struct impl NodeExecutor trait + factory.rs (54 plugins)
- Mojo: struct + factory.mojo (11 plugins)

All package.json files now include:
- files array listing source files
- metadata.class/struct field
- metadata.entrypoint field

This enables a unified plugin loading system across all languages
with no import side effects (Spring-style DI pattern).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-22 14:53:04 +00:00
parent 2562c2f55b
commit 7ce8b4ae8a
653 changed files with 13243 additions and 3034 deletions

View File

@@ -0,0 +1,7 @@
"""Factory for TestAssertEquals plugin."""
from .test_assert_equals import TestAssertEquals
def create():
return TestAssertEquals()

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/test_assert_equals",
"version": "1.0.0",
"description": "test_assert_equals plugin",
"description": "Assert that two values are equal",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["test", "workflow", "plugin"],
"main": "test_assert_equals.py",
"files": ["test_assert_equals.py", "factory.py"],
"metadata": {
"plugin_type": "test.assert_equals",
"category": "test"
"category": "test",
"class": "TestAssertEquals",
"entrypoint": "execute"
}
}

View File

@@ -1,26 +1,35 @@
"""Workflow plugin: assert two values are equal."""
from ...base import NodeExecutor
def run(_runtime, inputs):
class TestAssertEquals(NodeExecutor):
"""Assert that two values are equal."""
actual = inputs.get("actual")
expected = inputs.get("expected")
message = inputs.get("message", "")
passed = actual == expected
node_type = "test.assert_equals"
category = "test"
description = "Assert that two values are equal"
def execute(self, inputs, runtime=None):
"""Assert that two values are equal."""
actual = inputs.get("actual")
expected = inputs.get("expected")
message = inputs.get("message", "")
passed = actual == expected
if not passed:
error_msg = f"Assertion failed: {message}" if message else "Assertion failed"
error_msg += f"\n Expected: {expected}\n Actual: {actual}"
return {
"passed": False,
"error": error_msg,
"expected": expected,
"actual": actual
}
if not passed:
error_msg = f"Assertion failed: {message}" if message else "Assertion failed"
error_msg += f"\n Expected: {expected}\n Actual: {actual}"
return {
"passed": False,
"error": error_msg,
"passed": True,
"expected": expected,
"actual": actual
}
return {
"passed": True,
"expected": expected,
"actual": actual
}

View File

@@ -0,0 +1,7 @@
"""Factory for TestAssertExists plugin."""
from .test_assert_exists import TestAssertExists
def create():
return TestAssertExists()

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/test_assert_exists",
"version": "1.0.0",
"description": "test_assert_exists plugin",
"description": "Assert that a value exists (is not None/null)",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["test", "workflow", "plugin"],
"main": "test_assert_exists.py",
"files": ["test_assert_exists.py", "factory.py"],
"metadata": {
"plugin_type": "test.assert_exists",
"category": "test"
"category": "test",
"class": "TestAssertExists",
"entrypoint": "execute"
}
}

View File

@@ -1,23 +1,32 @@
"""Workflow plugin: assert value exists (is not None/null)."""
from ...base import NodeExecutor
def run(_runtime, inputs):
class TestAssertExists(NodeExecutor):
"""Assert that a value exists (is not None)."""
value = inputs.get("value")
message = inputs.get("message", "")
passed = value is not None
node_type = "test.assert_exists"
category = "test"
description = "Assert that a value exists (is not None/null)"
def execute(self, inputs, runtime=None):
"""Assert that a value exists (is not None)."""
value = inputs.get("value")
message = inputs.get("message", "")
passed = value is not None
if not passed:
error_msg = f"Assertion failed: {message}" if message else "Assertion failed"
error_msg += f"\n Expected: non-null value\n Actual: None"
return {
"passed": False,
"error": error_msg,
"value": value
}
if not passed:
error_msg = f"Assertion failed: {message}" if message else "Assertion failed"
error_msg += f"\n Expected: non-null value\n Actual: None"
return {
"passed": False,
"error": error_msg,
"passed": True,
"value": value
}
return {
"passed": True,
"value": value
}

View File

@@ -0,0 +1,7 @@
"""Factory for TestAssertFalse plugin."""
from .test_assert_false import TestAssertFalse
def create():
return TestAssertFalse()

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/test_assert_false",
"version": "1.0.0",
"description": "test_assert_false plugin",
"description": "Assert that a value is false",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["test", "workflow", "plugin"],
"main": "test_assert_false.py",
"files": ["test_assert_false.py", "factory.py"],
"metadata": {
"plugin_type": "test.assert_false",
"category": "test"
"category": "test",
"class": "TestAssertFalse",
"entrypoint": "execute"
}
}

View File

@@ -1,23 +1,32 @@
"""Workflow plugin: assert value is false."""
from ...base import NodeExecutor
def run(_runtime, inputs):
class TestAssertFalse(NodeExecutor):
"""Assert that a value is false."""
value = inputs.get("value")
message = inputs.get("message", "")
passed = value is False
node_type = "test.assert_false"
category = "test"
description = "Assert that a value is false"
def execute(self, inputs, runtime=None):
"""Assert that a value is false."""
value = inputs.get("value")
message = inputs.get("message", "")
passed = value is False
if not passed:
error_msg = f"Assertion failed: {message}" if message else "Assertion failed"
error_msg += f"\n Expected: False\n Actual: {value}"
return {
"passed": False,
"error": error_msg,
"value": value
}
if not passed:
error_msg = f"Assertion failed: {message}" if message else "Assertion failed"
error_msg += f"\n Expected: False\n Actual: {value}"
return {
"passed": False,
"error": error_msg,
"passed": True,
"value": value
}
return {
"passed": True,
"value": value
}

View File

@@ -0,0 +1,7 @@
"""Factory for TestAssertTrue plugin."""
from .test_assert_true import TestAssertTrue
def create():
return TestAssertTrue()

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/test_assert_true",
"version": "1.0.0",
"description": "test_assert_true plugin",
"description": "Assert that a value is true",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["test", "workflow", "plugin"],
"main": "test_assert_true.py",
"files": ["test_assert_true.py", "factory.py"],
"metadata": {
"plugin_type": "test.assert_true",
"category": "test"
"category": "test",
"class": "TestAssertTrue",
"entrypoint": "execute"
}
}

View File

@@ -1,23 +1,32 @@
"""Workflow plugin: assert value is true."""
from ...base import NodeExecutor
def run(_runtime, inputs):
class TestAssertTrue(NodeExecutor):
"""Assert that a value is true."""
value = inputs.get("value")
message = inputs.get("message", "")
passed = value is True
node_type = "test.assert_true"
category = "test"
description = "Assert that a value is true"
def execute(self, inputs, runtime=None):
"""Assert that a value is true."""
value = inputs.get("value")
message = inputs.get("message", "")
passed = value is True
if not passed:
error_msg = f"Assertion failed: {message}" if message else "Assertion failed"
error_msg += f"\n Expected: True\n Actual: {value}"
return {
"passed": False,
"error": error_msg,
"value": value
}
if not passed:
error_msg = f"Assertion failed: {message}" if message else "Assertion failed"
error_msg += f"\n Expected: True\n Actual: {value}"
return {
"passed": False,
"error": error_msg,
"passed": True,
"value": value
}
return {
"passed": True,
"value": value
}

View File

@@ -0,0 +1,7 @@
"""Factory for TestRunSuite plugin."""
from .test_run_suite import TestRunSuite
def create():
return TestRunSuite()

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/test_run_suite",
"version": "1.0.0",
"description": "test_run_suite plugin",
"description": "Run a suite of test assertions and report results",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["test", "workflow", "plugin"],
"main": "test_run_suite.py",
"files": ["test_run_suite.py", "factory.py"],
"metadata": {
"plugin_type": "test.run_suite",
"category": "test"
"category": "test",
"class": "TestRunSuite",
"entrypoint": "execute"
}
}

View File

@@ -1,63 +1,72 @@
"""Workflow plugin: run a suite of test assertions and report results."""
from ...base import NodeExecutor
def run(_runtime, inputs):
"""Run a suite of test assertions and aggregate results.
Inputs:
- results: Array of test result objects (each with 'passed' field)
- suite_name: Optional name for the test suite
class TestRunSuite(NodeExecutor):
"""Run a suite of test assertions and aggregate results."""
Outputs:
- passed: Boolean indicating if all tests passed
- total: Total number of tests
- passed_count: Number of tests that passed
- failed_count: Number of tests that failed
- failures: Array of failed test details
"""
results = inputs.get("results", [])
suite_name = inputs.get("suite_name", "Test Suite")
node_type = "test.run_suite"
category = "test"
description = "Run a suite of test assertions and report results"
if not isinstance(results, list):
return {
"passed": False,
"error": "results must be an array",
"total": 0,
"passed_count": 0,
"failed_count": 0,
"failures": []
}
def execute(self, inputs, runtime=None):
"""Run a suite of test assertions and aggregate results.
total = len(results)
passed_count = 0
failed_count = 0
failures = []
Inputs:
- results: Array of test result objects (each with 'passed' field)
- suite_name: Optional name for the test suite
for i, result in enumerate(results):
if isinstance(result, dict) and result.get("passed") is True:
passed_count += 1
else:
failed_count += 1
failure_info = {
"test_index": i,
"error": result.get("error", "Unknown error") if isinstance(result, dict) else str(result)
Outputs:
- passed: Boolean indicating if all tests passed
- total: Total number of tests
- passed_count: Number of tests that passed
- failed_count: Number of tests that failed
- failures: Array of failed test details
"""
results = inputs.get("results", [])
suite_name = inputs.get("suite_name", "Test Suite")
if not isinstance(results, list):
return {
"passed": False,
"error": "results must be an array",
"total": 0,
"passed_count": 0,
"failed_count": 0,
"failures": []
}
if isinstance(result, dict):
failure_info.update({
"expected": result.get("expected"),
"actual": result.get("actual")
})
failures.append(failure_info)
all_passed = failed_count == 0 and total > 0
total = len(results)
passed_count = 0
failed_count = 0
failures = []
summary = f"{suite_name}: {passed_count}/{total} tests passed"
for i, result in enumerate(results):
if isinstance(result, dict) and result.get("passed") is True:
passed_count += 1
else:
failed_count += 1
failure_info = {
"test_index": i,
"error": result.get("error", "Unknown error") if isinstance(result, dict) else str(result)
}
if isinstance(result, dict):
failure_info.update({
"expected": result.get("expected"),
"actual": result.get("actual")
})
failures.append(failure_info)
return {
"passed": all_passed,
"total": total,
"passed_count": passed_count,
"failed_count": failed_count,
"failures": failures,
"summary": summary
}
all_passed = failed_count == 0 and total > 0
summary = f"{suite_name}: {passed_count}/{total} tests passed"
return {
"passed": all_passed,
"total": total,
"passed_count": passed_count,
"failed_count": failed_count,
"failures": failures,
"summary": summary
}