Conversation
Review (at
|
9d1f57f to
3678037
Compare
|
@backnotprop The rewrite is ready for review. |
…lement The plugin previously pushes planning prompts and improvement contexts as separate elements in the output.system array. This change appends them to output.system[0] with newline separators instead. This keeps all system instructions within a single message block to prevent potential parsing or formatting issues when the agent processes the context.
…ralize system prompt assembly and add unit tests
f457f54 to
bfc41e4
Compare
|
Removed extra |
Re-review (at
|
…stem array to prevent data loss Previously, `output.system` was cleared with `length = 0` before being passed into `composeSystemPrompt`, causing the function to compose from an empty array instead of the original system content. The fix stores the composition result in a variable first, then pushes it after clearing. Additionally, add `.trim()` in `stripConflictingPlanModeRules` to normalize whitespace before filtering empty entries, and include a test case for empty string collapse behavior.
|
Addressed the bug and 2 points. |
|
Re-verified at One item remains, and it is the last one: the return [system.concat(additions).map((s) => s.trim()).filter(Boolean).join("\n\n")];drop the now-redundant map at AI-assisted verification, by execution. |
…nModeRules to composeSystemPrompt for centralized whitespace handling
|
Moved the trim to the proper location and added a trimming test case. |
|
Verified at |
…bering, OpenCode 2 parity) (#1258) * fix(opencode): consolidate V2 system parts into one composed prompt (#1114) The OpenCode 2 adapter still shipped the pre-#1114 multi-part system injection: replacePlanningSystemParts kept one part per source and the generic reminder pushed a separate part, so Qwen3.x Jinja template corruption persisted for OpenCode 2 users. Mirror the V1 entry exactly: compose the stripped existing text plus additions into a single system part via composeSystemPrompt, and compose the generic reminder into the existing text instead of appending a second part. Also adds the regression tests for the bug class flagged in #1114's review: both helpers must read/compose the existing system text BEFORE truncating the array (a reorder to 'system.length = 0' first drops the host prompt and goes red here). * perf(annotate): harden the raw-HTML overlay reconcile (dead-target backoff, cull, batching) Bridge-script hardening for mutation-heavy pages and large annotation sets, plus the lost click-to-select hover affordance: - A: dead-target re-search now carries a wall-clock backoff (300ms doubling to a 5s cap, reset on success) ON TOP of the generation gate, plus a 2-searches-per-reconcile-pass budget with a scheduled follow-up pass for budget-skipped eligible targets. A page that mutates every frame advances domGeneration every frame, so the generation gate alone re-ran the whole-document TreeWalker sweep (and anchor re-resolution) per frame forever for permanently unresolvable targets. - B1: early viewport cull (64px margin) for element and range targets: wholly offscreen targets skip targetStyleHidden / getComputedStyle / clipBoundsFor / client-rect collection entirely and just omit their markers, which is what the visible pipeline produced anyway. - B2: read/write batching in renderAnnotationOverlay: highlight rects are queued during the read phase and flushed as one write phase, so the pass no longer forces a synchronous layout per record. - B3: restoreAnnotation defers its render through the existing rAF-coalesced reconcile scheduler; restoring N annotations now renders once instead of N full passes (searches stay synchronous for the mark-applied reply). DOM tests flush the frame via the suite's standard macrotask flush. - B4: zero-work observer gate: page mutations with no records, no pending draft, and pinpoint inactive still bump domGeneration but no longer schedule a reconcile frame. - D: hover affordance for click-to-select: the rAF-throttled mousemove hit-tests the pointer against the CACHED rendered committed rects and toggles a brightness class on that annotation's rect divs inside the shadow root. No page-DOM writes, rects stay pointer-transparent, and shadow-root writes are unobserved so there is no reconcile loop. - G: while a text drag is in progress in drag mode, placed markers yield pointer input (data-pn-hittest) so the 25px bubble cannot capture a selection drag; armed only by a >4px primary-button move from a non-overlay mousedown, so marker clicks and click-to-select paths are untouched. withMarkersYielded now restores (not clears) the attribute. New regression tests for A, B1, B3, B4, D; A/B1/B3 mutation-verified (fix reverted, test observed failing, fix restored). * fix(annotate): make on-page marker numbers match exportAnnotations numbering The HtmlViewer sync excluded GLOBAL_COMMENT annotations before numbering while exportAnnotations numbers '## N.' sections across the FULL list including globals — so an on-page 'Comment 2' could be '## 3.' in the feedback the agent reads. The sync now derives each marker's number from its position in the full createdA-sorted list (globals occupy a number but ship no entry, leaving the correct gaps on-page). Export format is unchanged. New buildSyncNumbering helper + tests asserting a mixed list yields identical numbers between the sync payload and exportAnnotations output (mutation-verified against the pre-fix ordering). * chore: sync stale workspace versions in bun.lock (0.26.1 -> 0.26.7) * docs: document raw-HTML overlay model, multi-target types, and known limitations - Data Types: add htmlAdditionalTargets to the Annotation listing plus the HtmlElementAnchor (including the optional normalized point used by placed markers) and HtmlAnnotationTarget shapes. - Annotation System: describe the post-#1257 raw-HTML surface (placed comment markers + overlay-projected highlights, no inline mark mutation; durable anchors persisted, disposable markers projected) and the print-parity limitation. - URL Sharing: note that share links intentionally drop HTML element anchors and additional targets (restore is text-search based, per sharing.multiTarget.test.ts). * test: fix Range.getClientRects stub typing in the B1 cull test * fix(annotate): hover-race teardown and unbounded one-shot dead-search passes Polish round on the overlay hardening: - Hover race (1): switching into pinpoint mode (or opening a draft) now tears hover down fully via clearHoverHighlight() — cancels the pending rAF hit test and clears the tracked position and id — and the rAF callback itself refuses to paint outside drag mode / with an open draft. Previously the pending callback re-applied the class after the mode switch and every flushQueuedHighlights re-painted it from the stale hoverHighlightId, leaving a permanent phantom hover. - One-shot budgets (3): beginDeadSearchPass takes a per-pass budget. Reconcile passes keep 2 (they repeat, skipped targets get follow-up frames); print and scroll-to are user-initiated one-shots with no follow-up and now run unbounded (backoff and generation gates still apply), so printing with 3+ dead-but-recoverable targets no longer silently prints fewer highlights. Both changes carry new regression tests, mutation-verified (fix reverted, test observed failing, fix restored). * fix(annotate): number markers by array position and cap entries after dropping globals The createdA sort made the export-match invariant false with external annotations: exportAnnotations' sort keys tie for every raw-HTML annotation (blockId '', startOffset 0), so its stable sort numbers the combined [...local, ...external] list in ARRAY order — and external annotations arrive appended with server-stamped createdA values that can interleave with local timestamps. buildSyncNumbering now numbers by array position of the input (verified to be the same combined list both consumers receive from packages/editor/App.tsx allAnnotations; the viewerAnnotations diffContext filter is order-preserving and vacuous on the raw-HTML surface). Also reorders the cap: number the full list, drop globals, THEN slice 512 entries — globals no longer waste sync capacity and a non-global the export numbers past position 512 still syncs while slots remain. Numbers may now exceed 512 (array positions); the bridge's own bound (100000) accepts them and its 512-entry cap still agrees with the sender. Tests updated: interleaved-external agreement with exportAnnotations (mutation-verified against the createdA sort) and slice-after-filter capacity. * docs(opencode): note the accepted cache-hint flattening trade-off in V2 consolidation
…bering, OpenCode 2 parity) (backnotprop#1258) * fix(opencode): consolidate V2 system parts into one composed prompt (backnotprop#1114) The OpenCode 2 adapter still shipped the pre-backnotprop#1114 multi-part system injection: replacePlanningSystemParts kept one part per source and the generic reminder pushed a separate part, so Qwen3.x Jinja template corruption persisted for OpenCode 2 users. Mirror the V1 entry exactly: compose the stripped existing text plus additions into a single system part via composeSystemPrompt, and compose the generic reminder into the existing text instead of appending a second part. Also adds the regression tests for the bug class flagged in backnotprop#1114's review: both helpers must read/compose the existing system text BEFORE truncating the array (a reorder to 'system.length = 0' first drops the host prompt and goes red here). * perf(annotate): harden the raw-HTML overlay reconcile (dead-target backoff, cull, batching) Bridge-script hardening for mutation-heavy pages and large annotation sets, plus the lost click-to-select hover affordance: - A: dead-target re-search now carries a wall-clock backoff (300ms doubling to a 5s cap, reset on success) ON TOP of the generation gate, plus a 2-searches-per-reconcile-pass budget with a scheduled follow-up pass for budget-skipped eligible targets. A page that mutates every frame advances domGeneration every frame, so the generation gate alone re-ran the whole-document TreeWalker sweep (and anchor re-resolution) per frame forever for permanently unresolvable targets. - B1: early viewport cull (64px margin) for element and range targets: wholly offscreen targets skip targetStyleHidden / getComputedStyle / clipBoundsFor / client-rect collection entirely and just omit their markers, which is what the visible pipeline produced anyway. - B2: read/write batching in renderAnnotationOverlay: highlight rects are queued during the read phase and flushed as one write phase, so the pass no longer forces a synchronous layout per record. - B3: restoreAnnotation defers its render through the existing rAF-coalesced reconcile scheduler; restoring N annotations now renders once instead of N full passes (searches stay synchronous for the mark-applied reply). DOM tests flush the frame via the suite's standard macrotask flush. - B4: zero-work observer gate: page mutations with no records, no pending draft, and pinpoint inactive still bump domGeneration but no longer schedule a reconcile frame. - D: hover affordance for click-to-select: the rAF-throttled mousemove hit-tests the pointer against the CACHED rendered committed rects and toggles a brightness class on that annotation's rect divs inside the shadow root. No page-DOM writes, rects stay pointer-transparent, and shadow-root writes are unobserved so there is no reconcile loop. - G: while a text drag is in progress in drag mode, placed markers yield pointer input (data-pn-hittest) so the 25px bubble cannot capture a selection drag; armed only by a >4px primary-button move from a non-overlay mousedown, so marker clicks and click-to-select paths are untouched. withMarkersYielded now restores (not clears) the attribute. New regression tests for A, B1, B3, B4, D; A/B1/B3 mutation-verified (fix reverted, test observed failing, fix restored). * fix(annotate): make on-page marker numbers match exportAnnotations numbering The HtmlViewer sync excluded GLOBAL_COMMENT annotations before numbering while exportAnnotations numbers '## N.' sections across the FULL list including globals — so an on-page 'Comment 2' could be '## 3.' in the feedback the agent reads. The sync now derives each marker's number from its position in the full createdA-sorted list (globals occupy a number but ship no entry, leaving the correct gaps on-page). Export format is unchanged. New buildSyncNumbering helper + tests asserting a mixed list yields identical numbers between the sync payload and exportAnnotations output (mutation-verified against the pre-fix ordering). * chore: sync stale workspace versions in bun.lock (0.26.1 -> 0.26.7) * docs: document raw-HTML overlay model, multi-target types, and known limitations - Data Types: add htmlAdditionalTargets to the Annotation listing plus the HtmlElementAnchor (including the optional normalized point used by placed markers) and HtmlAnnotationTarget shapes. - Annotation System: describe the post-backnotprop#1257 raw-HTML surface (placed comment markers + overlay-projected highlights, no inline mark mutation; durable anchors persisted, disposable markers projected) and the print-parity limitation. - URL Sharing: note that share links intentionally drop HTML element anchors and additional targets (restore is text-search based, per sharing.multiTarget.test.ts). * test: fix Range.getClientRects stub typing in the B1 cull test * fix(annotate): hover-race teardown and unbounded one-shot dead-search passes Polish round on the overlay hardening: - Hover race (1): switching into pinpoint mode (or opening a draft) now tears hover down fully via clearHoverHighlight() — cancels the pending rAF hit test and clears the tracked position and id — and the rAF callback itself refuses to paint outside drag mode / with an open draft. Previously the pending callback re-applied the class after the mode switch and every flushQueuedHighlights re-painted it from the stale hoverHighlightId, leaving a permanent phantom hover. - One-shot budgets (3): beginDeadSearchPass takes a per-pass budget. Reconcile passes keep 2 (they repeat, skipped targets get follow-up frames); print and scroll-to are user-initiated one-shots with no follow-up and now run unbounded (backoff and generation gates still apply), so printing with 3+ dead-but-recoverable targets no longer silently prints fewer highlights. Both changes carry new regression tests, mutation-verified (fix reverted, test observed failing, fix restored). * fix(annotate): number markers by array position and cap entries after dropping globals The createdA sort made the export-match invariant false with external annotations: exportAnnotations' sort keys tie for every raw-HTML annotation (blockId '', startOffset 0), so its stable sort numbers the combined [...local, ...external] list in ARRAY order — and external annotations arrive appended with server-stamped createdA values that can interleave with local timestamps. buildSyncNumbering now numbers by array position of the input (verified to be the same combined list both consumers receive from packages/editor/App.tsx allAnnotations; the viewerAnnotations diffContext filter is order-preserving and vacuous on the raw-HTML surface). Also reorders the cap: number the full list, drop globals, THEN slice 512 entries — globals no longer waste sync capacity and a non-global the export numbers past position 512 still syncs while slots remain. Numbers may now exceed 512 (array positions); the bridge's own bound (100000) accepts them and its 512-entry cap still agrees with the sender. Tests updated: interleaved-external agreement with exportAnnotations (mutation-verified against the createdA sort) and slice-after-filter capacity. * docs(opencode): note the accepted cache-hint flattening trade-off in V2 consolidation
…led lookup keeps the session's answer
…tool before the first run (#1886) * Inbox: a one-line reminder at session start, and Claude Code's Inbox tool before the first run - inboxReminder (config.json, a boolean or one per host; on by default wherever the session has plannotator_inbox): resolveInboxReminder / configuredInboxReminder in packages/shared/config.ts, mirrored by the mod's resolveInboxReminderEnabled. No env var of its own: the tool switch gates it. - INBOX_REMINDER_TEXT (and INBOX_REMINDER_TEXT_NO_WAKE for OpenCode 1) in the connection contract. - Claude Code mod: a prompt.context block (plannotatorInbox) once per conversation, only with the tool and the switch on. - Claude Code mod: plannotator_inbox is registered before the Inbox ever ran, from a bundled tool list (inbox-default-tools.ts, generated by scripts/sync-mod-inbox-tools.ts and pinned to a real Inbox's /mcp). The link stays silent (no HTTP, no files) until a call starts the Inbox. - Pi: a hidden before_agent_start message (plannotator-inbox-reminder) on the session's first prompt, not repeated after /reload or /resume, re-delivered only after a compaction that summarized it away; the Ask-this-session bridge never reads it as a take-over. - OpenCode 2: a composed system line on requests that offer the tool (primary agents, not title requests); OpenCode 1: the no-wake line in experimental.chat.system.transform. * Inbox reminder on OpenCode 2: gate on the Inbox connection, not on the lazy tool transform registerInboxOpenCode2 reports whether the host's tool draft took the tool, but OpenCode 2 applies a tool transform per request, so at plugin setup the answer is still false and the context hook was never registered. Gate on the connection being found; addInboxReminder already checks each request's own tool list, so the line still never names a tool the agent lacks. Proved on the real opencode2 2.0.19 (inbox-v2.test.ts, 5/5). * Inbox reminder: review follow-ups - The reminder speaks only for an Inbox that has run here: the Claude Code mod still registers plannotator_inbox before the first run (bundled list), but adds the prompt.context block only when inbox/inbox.json existed at the first session.start. Pi and OpenCode already need the registry for the tool. - Claude Code names the tool by the full name $.tool.register returned (inboxReminderText), so tool search finds the deferred tool. Fixed per process. - OpenCode 2 without session.prompt (tool registered wakes:false) gets the wait_for_reply wording (openCode2InboxReminder). - OpenCode 1: the line is its own system part (never merged into the host's parts), and only for an agent that has the tool: not a subagent, not an agent whose tools switch plannotator_inbox off (wildcards too). - Docs: no "Settings writes inboxReminder" claim yet; OpenCode's line is on every request; Claude Code's tool needs no first run. - Tests: engine harness for no registry (tool, no reminder), -p (none), a refused tool.register (none), the full name; OpenCode 1 agent gating and part layout; OpenCode 2 no-wake wording. * OpenCode 1 Inbox reminder: end of the last system part (#1114), a failed lookup keeps the session's answer * OpenCode 2 Inbox wake: a stop signal for the wakes; test the draft without add and stop the wake after each test
…ttings → Agents (#1889) * Inbox: plannotator inbox connects the agents on this computer; uninstall removes what it added A person's plannotator inbox (never --background, the shim or a connection's start) adds a plannotator-inbox MCP server to every terminal agent it finds that has no record yet: through the agent's own mcp add (Codex, Gemini CLI, Windsurf/Devin, Amp, Cline, Pi without the extension), else one key in a strictly parsed plain-JSON file (Cursor, Kiro, the Claude desktop app). Pi and OpenCode with Plannotator's extension or plugin get inboxTool on. Claude Code gets nothing. An Inbox an agent started is asked over the new token-guarded /api/inbox/control/connect. Later runs connect agents installed since and say so once; a recorded agent (turned off, removed outside, a foreign entry) is never added back; another plannotator-inbox entry is never replaced. PLANNOTATOR_INBOX_CONNECT=0 skips it. plannotator uninstall (plain and --purge) removes the entries it added, by record then by scanning the known files; --dry-run lists them. Tests use fake agent CLIs on a scratch PATH and HOME; the preload and every CLI test sandbox set PLANNOTATOR_INBOX_CONNECT=0, and the guard test now fails on a path from the real home to an agent folder or a connect without an agent environment. * Inbox: a one-line reminder at session start, and Claude Code's Inbox tool before the first run - inboxReminder (config.json, a boolean or one per host; on by default wherever the session has plannotator_inbox): resolveInboxReminder / configuredInboxReminder in packages/shared/config.ts, mirrored by the mod's resolveInboxReminderEnabled. No env var of its own: the tool switch gates it. - INBOX_REMINDER_TEXT (and INBOX_REMINDER_TEXT_NO_WAKE for OpenCode 1) in the connection contract. - Claude Code mod: a prompt.context block (plannotatorInbox) once per conversation, only with the tool and the switch on. - Claude Code mod: plannotator_inbox is registered before the Inbox ever ran, from a bundled tool list (inbox-default-tools.ts, generated by scripts/sync-mod-inbox-tools.ts and pinned to a real Inbox's /mcp). The link stays silent (no HTTP, no files) until a call starts the Inbox. - Pi: a hidden before_agent_start message (plannotator-inbox-reminder) on the session's first prompt, not repeated after /reload or /resume, re-delivered only after a compaction that summarized it away; the Ask-this-session bridge never reads it as a take-over. - OpenCode 2: a composed system line on requests that offer the tool (primary agents, not title requests); OpenCode 1: the no-wake line in experimental.chat.system.transform. * wip: notes and agents settings model * Inbox: agent notes, Settings → Agents routes, plannotator inbox --notes * Inbox: install prompt and --help offer the note; scratch home in the help test * Inbox: the first-open agents card (what plannotator inbox connected, the one-time note question) * Inbox: Settings → Agents block (reach, reminder, note per agent) * Inbox: e2e for the agents card on the compiled binary * Docs: the note, the card and Settings → Agents * Inbox: Settings → Agents classes of their own (ib-arow and ib-dot were taken) * e2e: the theme wait has its own short limit * Tests: the uninstall lines name the path with the platform's separator * Tests: the note line names the path with the platform's separator * Inbox reminder on OpenCode 2: gate on the Inbox connection, not on the lazy tool transform registerInboxOpenCode2 reports whether the host's tool draft took the tool, but OpenCode 2 applies a tool transform per request, so at plugin setup the answer is still false and the context hook was never registered. Gate on the connection being found; addInboxReminder already checks each request's own tool list, so the line still never names a tool the agent lacks. Proved on the real opencode2 2.0.19 (inbox-v2.test.ts, 5/5). * Inbox: Settings → Agents in the Agents section (after #1883); read again when the section opens * Inbox: drop the unused agents lock style; name the agents spec in the e2e config * Inbox reminder: review follow-ups - The reminder speaks only for an Inbox that has run here: the Claude Code mod still registers plannotator_inbox before the first run (bundled list), but adds the prompt.context block only when inbox/inbox.json existed at the first session.start. Pi and OpenCode already need the registry for the tool. - Claude Code names the tool by the full name $.tool.register returned (inboxReminderText), so tool search finds the deferred tool. Fixed per process. - OpenCode 2 without session.prompt (tool registered wakes:false) gets the wait_for_reply wording (openCode2InboxReminder). - OpenCode 1: the line is its own system part (never merged into the host's parts), and only for an agent that has the tool: not a subagent, not an agent whose tools switch plannotator_inbox off (wildcards too). - Docs: no "Settings writes inboxReminder" claim yet; OpenCode's line is on every request; Claude Code's tool needs no first run. - Tests: engine harness for no registry (tool, no reminder), -p (none), a refused tool.register (none), the full name; OpenCode 1 agent gating and part layout; OpenCode 2 no-wake wording. * Inbox agents: review fixes (version checks, TOML, lossless JSON, exact ownership, said-once failures) - Pi before 0.99 (no pi mcp) and any CLI whose --version line is not its own (cln's pi, amp.rs, another codex) are left to the person; Cline is not run. - Codex's config.toml is read with Bun.TOML.parse (every form); GEMINI_CLI_HOME and a relative CODEX_HOME are honored; an entry Plannotator did not write is never replaced. - JSON edits are lossless (json-edit.ts): only the one member's text changes, BOM, dominant line ending, numbers and escapes stay; duplicate keys refused. - Ours = this CLI's command or the recorded one; the plannotator heuristic is exact-name only. Uninstall removes only entries recorded as added (or, with no record, ones running exactly the binary being removed). - Copy no longer promises Settings; a lasting failure is said once. - OpenCode 2 plugins in { package } form are found. - Agent CLIs run in their own process group, killed on timeout; a grandchild holding stdout does not hold the run. Docs and the Devin snippet path. * Inbox notes, card and Settings → Agents: review fixes - Records hold the resolved path (a symlinked ~/.claude), so off and uninstall delete the file the note created; the uninstall scan resolves stale records too. - Notes edit the file's own text: dominant line ending for new lines, BOM kept, no rewrite when unchanged; one file shared by two agents holds one section owned by both. - Uninstall names a damaged section it left; with agent-notes.json lost it still deletes Claude Code's own rules file. - Card ticks follow the model until touched, defaulting per DESIGN Q2; Try again clears the failure (setInboxAgentReach) or shows the server's error; Not now is ignored during Add. - Settings keeps the Inbox tool switch for Claude Code, Pi and OpenCode in reach when not found; second clicks while saving are ignored; OpenCode says no file yet. - --notes and the card refuse agents not found here and leave the question open when every add failed. PLANNOTATOR_INBOX_NOTES=0 implemented. - The agents model runs no agent CLI (version probe only before a write); a test Inbox without its own agent environment gets an empty scratch one; the tailnet refuses every agents route (tested). * OpenCode 1 Inbox reminder: end of the last system part (#1114), a failed lookup keeps the session's answer * OpenCode 2 Inbox wake: a stop signal for the wakes; test the draft without add and stop the wake after each test * AGENTS.md: the reminder switch is in Settings → Agents * Inbox connect: the terminal says once why an agent needs connecting by hand * Inbox connect: say a time limit as it was (1.5 s, not 2 s) * Inbox uninstall: with no record, an entry that runs this binary is named, never removed; docs say what the terminal prints * Inbox connect: Codex CLI before 0.35 and Gemini CLI before 0.1.19 have no mcp add, so they are left to the person * Inbox Settings: a note cannot be added for an agent not found here (as the card and --notes) * Inbox notes: with PLANNOTATOR_INBOX_NOTES=0 a note already written is still listed in Settings so it can be turned off * Inbox notes: removal gives back a mostly-CRLF file that ends in a lone LF byte for byte * Inbox notes (Codex): Off removes the note from the recorded file and the file the agent reads now; the status shows a note left in the older file * Inbox notes and JSON entries: add then remove gives the file back byte for byte (no final newline, empty files, LF and CRLF) * Inbox notes: a whitespace-only file without a final line break gets the start marker on its own line, and comes back byte for byte
Issue
The OpenCode plugin's
system.transformhook was corrupting OpenCode's Jinja template when injecting planning prompts. The error appeared as:This occurred when using Qwen3.6 models with their chat template.
Root Cause
The plugin was pushing planning prompts and improvement context as separate elements in the
output.systemarray:OpenCode maps each element of
output.systemto a separate system message. The Qwen3.6 Jinja template only allows one system message at position 0:When the plugin pushed multiple elements, OpenCode created multiple system messages, causing the template to fail at position > 0.
Jinja template reference: https://huggingface.co/Qwen/Qwen3.6-35B-A3B-FP8/raw/main/chat_template.jinja
Solution
Instead of pushing new elements to
output.system, the plugin now appends content to the first element (output.system[0]):This preserves the multi-message
output.systemarray structure while keeping all injected content within the original system message (element 0). The Jinja template sees only one system message at position 0, containing all the plugin's additions.Testing
plan-mode.test.ts)