Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(hub): fence close must reject info strings per CommonMark spec
yushenefb149532686
diff --git a/src/hub/block-chunker.test.ts b/src/hub/block-chunker.test.tsindex a1b36b1671..dfda6cc609 100644--- a/src/hub/block-chunker.test.ts+++ b/src/hub/block-chunker.test.ts@@ -223,6 +223,23 @@ describe("BlockChunker", () => {expect(chunk + remainder).toBe(text);});+ it("does not treat fence with info string as closing fence", () => {+ const chunker = new BlockChunker(cfg({ minChars: 10, maxChars: 500 }));+ // The second ```python should NOT close the first fence (CommonMark: closing fence has no info string)+ const text = "Before.\n\n```python\ncode line 1\n```python\ncode line 2\n```\n\nAfter text here.";+ const result = chunker.tryChunk(text);+ expect(result).not.toBeNull();+ const chunk = result!.chunk;+ // The split should not land between ```python and ```python (inside fence)+ // It should either be before the fence or after the closing ```+ const fenceOpens = (chunk.match(/```python/g) || []).length;+ const fenceCloses = (chunk.match(/^```$/gm) || []).length;+ if (fenceOpens > 0) {+ // If chunk includes opening fences, it must include the real close+ expect(fenceCloses).toBeGreaterThanOrEqual(1);+ }+ });+it("handles multiple sequential code blocks", () => {const chunker = new BlockChunker(cfg({ minChars: 10, maxChars: 500 }));const text = "```js\nfoo()\n```\n\n```py\nbar()\n```\n\nEnd.";diff --git a/src/hub/block-chunker.ts b/src/hub/block-chunker.tsindex a7f04ed78d..6daadad010 100644--- a/src/hub/block-chunker.ts+++ b/src/hub/block-chunker.ts@@ -51,8 +51,8 @@ function detectFenceAt(text: string, upTo: number): FenceInfo | null {if (openFence === null) {// Opening a new fenceopenFence = { marker, lang };- } else if (markerChar === openFence.marker[0] && marker.length >= openFence.marker.length) {- // Closing the current fence (same char, at least as many chars)+ } else if (markerChar === openFence.marker[0] && marker.length >= openFence.marker.length && lang === "") {+ // Closing the current fence (same char, at least as many chars, no info string per CommonMark)openFence = null;}// Otherwise: different char or shorter marker, not a close — ignorediff --git a/src/hub/message-aggregator.test.ts b/src/hub/message-aggregator.test.tsindex 135a748ccb..525166485b 100644--- a/src/hub/message-aggregator.test.ts+++ b/src/hub/message-aggregator.test.ts@@ -112,6 +112,14 @@ describe("MessageAggregator", () => {expect(onBlock).not.toHaveBeenCalled();});+ it("passes through tool_execution_update immediately", () => {+ const agg = new MessageAggregator(smallConfig(), onBlock, onPassthrough);+ const event = { type: "tool_execution_update", toolCallId: "tool-1", content: "output" } as unknown as AgentEvent;+ agg.handleEvent(event);+ expect(onPassthrough).toHaveBeenCalledWith(event);+ expect(onBlock).not.toHaveBeenCalled();+ });+it("passes through compaction_start immediately", () => {const agg = new MessageAggregator(smallConfig(), onBlock, onPassthrough);const event = makeCompactionStart();