From 7de62226f21784b56faa416864dc9fd771555372 Mon Sep 17 00:00:00 2001 From: Chris Dumas Date: Mon, 7 Sep 2026 08:01:22 +0000 Subject: [PATCH] Strip legacy anchor style note --- dumas_image_nodes.py | 15 +++++++++++++-- tests/test_dumas_image_nodes.py | 13 +++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/dumas_image_nodes.py b/dumas_image_nodes.py index 9c1f233..5cb67be 100644 --- a/dumas_image_nodes.py +++ b/dumas_image_nodes.py @@ -27,6 +27,12 @@ _H3_PLAN_IMAGE_BINDINGS_CAP = 128 _H3_PLAN_IMAGE_SLOTS = 9 _FOLDER_IMAGE_EXTS = (".png", ".jpg", ".jpeg", ".webp", ".bmp", ".gif", ".tiff", ".tif") _ANCHOR_STYLE_H3_NOTE = "" +_ANCHOR_STYLE_LEGACY_NOTE_RE = re.compile( + r"\s*Keep this anchor focused on persistent camera language, lighting, " + r"texture, environment treatment, and tone; do not name characters or " + r"describe one-off actions\.?", + re.I, +) _H3_PROMPT_REF_SLOTS = 9 _H3_PROMPT_MAX_CHARS = 7000 _PICTURE_TAG_RE = re.compile(r"<\s*picture[\s_\-]*(\d+)\s*>", re.I) @@ -420,6 +426,11 @@ def _anchor_style_description(style_name): return _ANCHOR_STYLE_PRESETS.get(str(style_name or "").strip().lower(), "") +def _clean_anchor_style_text(text): + cleaned = _ANCHOR_STYLE_LEGACY_NOTE_RE.sub("", str(text or "")) + return re.sub(r"[ \t]{2,}", " ", cleaned).strip() + + def _clean_input_token_value(value): cleaned = "" if value is not None: @@ -2704,9 +2715,9 @@ class DumasAnchorStyleNode: } def build_anchor(self, anchor_style, style_description): - text = str(style_description or "").strip() + text = _clean_anchor_style_text(style_description) if not text: - text = _anchor_style_description(anchor_style) + text = _clean_anchor_style_text(_anchor_style_description(anchor_style)) return (text,) diff --git a/tests/test_dumas_image_nodes.py b/tests/test_dumas_image_nodes.py index e862f83..56b058a 100644 --- a/tests/test_dumas_image_nodes.py +++ b/tests/test_dumas_image_nodes.py @@ -688,6 +688,19 @@ class DumasImageNodeTests(unittest.TestCase): self.assertIn("real time", result[0]) self.assertNotIn("persistent camera language", result[0]) + def test_anchor_style_node_strips_legacy_persistent_anchor_note(self): + node = self.image_nodes.DumasAnchorStyleNode() + legacy = ( + "Gritty handheld realism. Keep this anchor focused on persistent camera " + "language, lighting, texture, environment treatment, and tone; do not " + "name characters or describe one-off actions." + ) + + result = node.build_anchor("cinematic action movie", legacy) + + self.assertEqual(result[0], "Gritty handheld realism.") + self.assertNotIn("persistent camera language", result[0]) + def test_anchor_style_node_prefers_manual_description_edits(self): node = self.image_nodes.DumasAnchorStyleNode() custom = "Lo-fi pirate broadcast with smeared highlights and anxious zoom corrections."