Let the planner reach for a diagram or a formula #7
- KC
Both already worked end to end. `math` and `inlineMath` are in the dialect's node allowlist with a `MathNode` behind them and KaTeX rendering in front, a `mermaid` fence renders to SVG, and the slash menu offers a human either one in a keystroke. The agent — which writes most of the plan — was given the bare word "math" inside a list of node names, with no delimiters anywhere.
## Why it needed saying
Guessing the wrong delimiters produces no error of any kind:
| written | validates | parses as | saved as | | --- | --- | --- | --- | | `$r = n / t$` | yes | `inlineMath` | `$r = n / t$` | | `$$\nt = n / r\n$$` | yes | `math` | unchanged | | `\(r = n / t\)` | yes | `text` | `(r = n / t)` | | `\[t = n / r\]` | yes | `text` | `\[t = n / r]` |
`\(…\)` is the more common LaTeX convention and so the likelier guess. It is not rejected — it parses as ordinary prose, and markdown eats the backslashes on the way out, so it lands in the plan as `(r = n/t)` and reads like a sentence somebody meant to write. Nothing anywhere would surface it. `\[…\]` survives half-escaped, which is no better for being different.
The other half is framing. That paragraph is the allowlist, so naming a construct in it says only that it will not be refused. Callout and Tabs each get a clause on when they earn their place; a diagram and a formula had none, under a standing instruction that prose is the default. The new paragraph sits before the components, so that damper still reads as being about components.
## The escaping
The counter-example is written `\\(…\\)` in the source. A template literal turns `\(` into `(`, so the obvious spelling would have shipped an instruction about parentheses — silently, in a prompt that nothing tests. Verified by printing `planner.prompt` and reading the rendered output rather than the source, which is the only check that means anything here.
## Checks
`bun run ci`, `bun run types` and `bun test` (500 pass) are clean. Nothing in this change is behaviour and there is no `planner.test.ts` to extend, so no test was added.
## Left undone
The markdown half of that section is still hand-written prose restating `NODES`, `LINK_PROTOCOLS` and `IMAGE_PROTOCOLS`, with nothing tying it to them. This does not widen the gap, but it does leave that as the only part of the dialect description able to drift without anything noticing — and the first draft of this very change asserted that `\(…\)` lands as literal backslashes, which is false. Running it through `parse` and `serialize` is what caught it.
Krzysztof-Cieslakmerged 07634025d03d3 months ago on GitHub
Krzysztof-Cieslakhead-ref-deleted3 months ago on GitHub