From c0bd987ec10c9d014d6ef66519282d5b3493d5e8 Mon Sep 17 00:00:00 2001 From: rookiestar28 Date: Sun, 26 Apr 2026 18:46:18 +0800 Subject: [PATCH] refactor(nodes): align node categories with canonical naming --- nodes/batch_variants.py | 5 ++--- nodes/image_to_prompt.py | 2 +- nodes/prompt_planner.py | 2 +- nodes/prompt_refiner.py | 2 +- tests/test_node_class_aliases.py | 26 ++++++++++++++++++++++++++ 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/nodes/batch_variants.py b/nodes/batch_variants.py index a4066b5..951cd45 100644 --- a/nodes/batch_variants.py +++ b/nodes/batch_variants.py @@ -1,5 +1,6 @@ import json import logging +import random from typing import Any, Dict, List, Tuple try: @@ -55,7 +56,7 @@ class OpenClawBatchVariants: OUTPUT_IS_LIST = (True, True, True) FUNCTION = "generate_variants" - CATEGORY = "moltbot" + CATEGORY = "openclaw" def generate_variants( self, @@ -95,8 +96,6 @@ class OpenClawBatchVariants: # Let's stick to simple increment for now or random python if implied? # "randomized" usually means unpredictable. # Let's implement a simple hash for now to be deterministic but "jumpy" - import random - r = random.Random(seed_base + i) current_seed = r.randint(0, 0xFFFFFFFFFFFFFFFF) diff --git a/nodes/image_to_prompt.py b/nodes/image_to_prompt.py index 12f1a7f..be6eaf7 100644 --- a/nodes/image_to_prompt.py +++ b/nodes/image_to_prompt.py @@ -63,7 +63,7 @@ class OpenClawImageToPrompt: RETURN_TYPES = ("STRING", "STRING", "STRING") RETURN_NAMES = ("caption", "tags", "prompt_suggestion") FUNCTION = "generate_prompt" - CATEGORY = "moltbot" + CATEGORY = "openclaw" # R154: keep the compatibility method name, but bind the shared helper # directly so node wrappers do not duplicate image conversion logic. diff --git a/nodes/prompt_planner.py b/nodes/prompt_planner.py index f0692fe..f082405 100644 --- a/nodes/prompt_planner.py +++ b/nodes/prompt_planner.py @@ -59,7 +59,7 @@ class OpenClawPromptPlanner: RETURN_TYPES = ("STRING", "STRING", "STRING") RETURN_NAMES = ("positive", "negative", "params_json") FUNCTION = "plan_generation" - CATEGORY = "moltbot" + CATEGORY = "openclaw" def plan_generation( self, profile: str, requirements: str, style_directives: str, seed: int diff --git a/nodes/prompt_refiner.py b/nodes/prompt_refiner.py index 2252381..c30a1ed 100644 --- a/nodes/prompt_refiner.py +++ b/nodes/prompt_refiner.py @@ -75,7 +75,7 @@ class OpenClawPromptRefiner: "rationale", ) FUNCTION = "refine_prompt" - CATEGORY = "moltbot" + CATEGORY = "openclaw" # R154: keep the compatibility method name, but bind the shared helper # directly so node wrappers do not duplicate image conversion logic. diff --git a/tests/test_node_class_aliases.py b/tests/test_node_class_aliases.py index a3a8fc1..bef7a2c 100644 --- a/tests/test_node_class_aliases.py +++ b/tests/test_node_class_aliases.py @@ -1,5 +1,8 @@ +import ast +import inspect import os import sys +import textwrap import unittest sys.path.append(os.getcwd()) @@ -17,6 +20,29 @@ class TestNodeClassAliases(unittest.TestCase): self.assertIs(MoltbotImageToPrompt, OpenClawImageToPrompt) self.assertIs(MoltbotPromptRefiner, OpenClawPromptRefiner) + def test_current_node_categories_use_openclaw_baseline(self): + node_classes = ( + OpenClawPromptPlanner, + OpenClawBatchVariants, + OpenClawImageToPrompt, + OpenClawPromptRefiner, + ) + + for node_class in node_classes: + with self.subTest(node_class=node_class.__name__): + self.assertEqual(node_class.CATEGORY, "openclaw") + + def test_batch_variants_execution_path_has_no_local_imports(self): + source = inspect.getsource(OpenClawBatchVariants.generate_variants) + tree = ast.parse(textwrap.dedent(source)) + + local_imports = [ + node + for node in ast.walk(tree) + if isinstance(node, (ast.Import, ast.ImportFrom)) + ] + self.assertEqual(local_imports, []) + if __name__ == "__main__": unittest.main()