Streamed tool-call arguments are incomplete JSON by nature, so the same two
questions ('where does this brace close', 'what closers are missing') were
answered by four hand-written scan loops plus a naive regex counter inside
experimental_repairToolCall. That counter knew nothing about strings or escapes:
{"path":"a}b"} was judged short one brace, and it appended closers per bracket
type rather than in stack order, so [{"a":1 was repaired into [{"a":1]} — balanced
by count, still unparseable.
- shared/utils/jsonScan: scanJson / findJsonValueEnd / sliceJsonValue /
closeUnterminatedJson, used by the main-process adapter, the renderer argument
parser and the tool-call repair path.
- shared/utils/toolCallMarkup: the leaked-markup tag list both sides share, with
the JSON-payload subset the main-process adapter converts spelled out next to
the full list the renderer strips, so the split is documented instead of implied.
- Deleted three unreferenced modules: renderer/utils/partialJson.ts, its test
(named *.test.run.ts, so it never matched the vitest glob and reimplemented the
function under test anyway), and shared/utils/jsonUtils.ts (375 lines, no
importers outside the barrel).
19 new scanner tests.