airi/packages/mathjson
RainbowBird 69d60cf95f release: v0.15.4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 03:53:10 +07:00
..
src feat(core-agent,stage-ui): now speech formula, math, chem correctly (#3054) 2026-10-21 17:15:49 +08:00
package.json release: v0.15.4 2026-11-13 03:53:10 +07:00
README.md feat(core-agent,stage-ui): now speech formula, math, chem correctly (#3054) 2026-10-21 17:15:49 +08:00
tsconfig.json feat(core-agent,stage-ui): now speech formula, math, chem correctly (#3054) 2026-10-21 17:15:49 +08:00
tsdown.config.ts feat(core-agent,stage-ui): now speech formula, math, chem correctly (#3054) 2026-10-21 17:15:49 +08:00

@proj-airi/mathjson

Types and small helpers for the MathJSON of the speech transformers. The package has no dependency.

Use it for

  • The type of a lowered formula: MathJson, MathJsonFunction, and MathJsonNumber.
  • Reading or building nodes: headOf, argsOf, isFunction, isNumber, isSymbol, text, textOf, and nothing.

Do not use it for

  • Parsing or reading formulas. Use @proj-airi/speech-transformer-math.
  • Full MathJSON with evaluation. Use @cortex-js/compute-engine.

Shape

The shape follows MathJSON. A function is an array with its head first, a string is a symbol, and a quoted string, for example 'kg', is text. The speech transformers add heads for reading, for example Apply, Bracket, and Chemistry.

const expression: MathJson = ['Add', 'x', { num: '1' }]
headOf(expression) // => 'Add'

Checks

pnpm -F @proj-airi/mathjson typecheck