From 40d8c1c31d58854f8df78dc0d7d55b0068c72612 Mon Sep 17 00:00:00 2001 From: Tom <37050939+tomolom@users.noreply.github.com> Date: Sun, 12 Apr 2026 19:15:25 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20strip=20all=20accumulated=20tags=20in=20?= =?UTF-8?q?stripTagPrefix=20to=20prevent=20=C2=A7N=C2=A7=20accumulation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TAG_PREFIX_REGEX was only matching a single tag prefix, causing tags to accumulate when content is processed multiple times during transform passes, compartment compaction, or message replay. Changed the regex from /^§\d+§\s*/ to /^(?:§\d+§\s*)+/ to match one or more consecutive tags at the start of the string. This ensures stripTagPrefix removes ALL accumulated tags before prependTag adds a fresh one. Fixes #11 --- .../plugin/src/hooks/magic-context/tag-content-primitives.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin/src/hooks/magic-context/tag-content-primitives.ts b/packages/plugin/src/hooks/magic-context/tag-content-primitives.ts index 9cac9b2..66eb84f 100644 --- a/packages/plugin/src/hooks/magic-context/tag-content-primitives.ts +++ b/packages/plugin/src/hooks/magic-context/tag-content-primitives.ts @@ -1,7 +1,7 @@ import type { ThinkingLikePart } from "./tag-messages"; const encoder = new TextEncoder(); -const TAG_PREFIX_REGEX = /^§\d+§\s*/; +const TAG_PREFIX_REGEX = /^(?:§\d+§\s*)+/; export function byteSize(value: string): number { return encoder.encode(value).length;