You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(builder): JSON format round before customer definitions are stored #293
Part of epic #261, phase 4 step 3 (see docs/superpowers/specs/2026-11-26-builder-direction-review.md on feature/builder). Must land before any customer JSON definition is stored: after that, every change is a migration.
Scope
Theme tokens: colours (and other theme values) as references ("$accent") to a theme section the host can override; round trip from C# theme objects.
Named assets: an assets map in the definition instead of sha256:… in the body; images with only a width or only a height.
Strict reader: unknown value formats ({{x:N2}}), padding with four values, a loop variable shadowing the data root, a text key missing in one language, markdown in literal text — errors (or warnings) instead of silent acceptance.
Renames for clarity (JSON and C#):textStyle/headerTextStyle → paragraphStyle/headerParagraphStyle, defaults.paragraph → defaults.paragraphStyle, cell align → verticalAlign, list if uses then like every other conditional.
texts by key:"title": {"de": …, "en": …}, so one wording change is one edit.
Named sections:{"section": "items", "blocks": […]} and c.Section(…) instead of group/from, as the unit for reading, replacing and diffing.
Cells: a style option; no ambiguous bare-array form.
Layout and small decisions: width counted from the indentation; \n/\t in text; reserved root keys (theme, assets, components, $schema).
C# API consistency: one position for the style parameter, one chaining rule.
F4 — Values that depend on the language but are not texts break the multi-language JSON export · significant for JSON
The definition measures column widths against each language's vocabulary (the widest label and value per column), so
German and English get different widths. TemplateJson.Export with TextLanguages = [de, en] then fails:
TB9204: The JSON would not build the same template for en: a text is changed by code (string.Format, ToUpper,
concatenated into a quoted value) or used where the JSON cannot hold it.
Two problems: the JSON has no place for a per-language length, and the message blames a text although the difference
is a column width. The port exports with one set of widths for both languages (an option of the definition) or one
JSON per language.
Related: TemplateTexts gives only the build language. Measuring against every language needs the catalog passed to
the definition separately.
template.Texts.In(CultureInfo.GetCultureInfo("en"))["label"];// another language's text
And TB9204 should name what differs: the first differing part and element.
F5 — Components cannot reach texts or a theme · significant for JSON, cosmetic for C#
ITemplateComponent.Compose(BlockComposer) sees neither the texts nor anything the definition shares. Every component
of the port therefore takes the theme and the texts in its constructor. That works in C#, but such a component cannot
be registered in a ComponentCatalog (its parameters are not paths or simple values), so the JSON export writes every
use as an expanded copy: 58 group blocks in this template, the block of an organisation three times, one status box
five times.
publicvoidCompose(BlockComposerc){TemplateTextst=c.Texts;// the build's textsBrandThemetheme=c.Shared<BrandTheme>();// what the definition registered with template.Share(theme)}
With that, a component's parameters are paths again and the catalog can write it as a reference.
F6 — No reusable inline fragments · cosmetic
Components are blocks. What repeats inside a paragraph (an icon followed by a word in a status colour; an address line
with guarded separators) is a C# extension method on InlineComposer in the port. Fine in C#, invisible to JSON.
F12 — The exported JSON is mostly indentation · cosmetic
The export of this template is 148,705 characters, of which 93,138 (63%) are leading spaces: components are nested groups and the tree is up to 35 levels deep. Minified it is 50,542 characters. For a file meant to be read and
edited by an agent, an export option without indentation would cut the cost by two thirds.
Done on feature/builder (commits referencing #293, up to 4fbc415). The issue stays open until the integration PR.
Format (decisions A1–A9 of the style review)
Strict reader: only known value formats (host formats via TemplateJsonImportOptions.ValueFormats), padding with one or two values, a loop variable may not shadow its own collection's root, every text in texts has the languages of the others (a regional language is covered by its parent), == is read as =, $schema ignored, components reserved. TB9204 names the first paragraph that differs.
Names: then in every conditional, elseIf: [{if, then}], paragraphStyle / headerParagraphStyle, defaults.paragraphStyle, cell verticalAlign.
Structure: texts key first, {"section": …, "blocks": …} (C# c.Section), cells are a string or an object, \n / \t in strings.
Named assets (assets at the root, ImageSource.WithName), images with one size.
Theme tokens: theme.colors / theme.fonts, "$accent" wherever a colour or font goes (also in borders and in registered components' parameters), host override TemplateJsonImportOptions.Theme (a colour token needs a colour; an unknown token warns, TB9205).
Components see the build's texts and shared objects (c.Texts, c.Shared<T>(), template.Share, TemplateJsonImportOptions.Shared); a parameterless component is {"component": "name"}; texts a registered component reads go into the JSON's texts.
Layout width counted without indentation; TemplateJsonExportOptions.Indented = false writes one line.
C#: the style parameter comes first everywhere (Text(style, text), Value(style, path[, format])); methods that add content return their composer, so short parts chain.
Docs and sample: "JSON definitions" in the developer docs is now a reference (API, root, content, values, strictness, texts, sections/components/assets/theme). The sample uses theme tokens, a named logo, sections, chaining and a parameterless component that reads shared objects and texts; its JSON round trip is byte-identical in DOCX and ODT, de and en.
Checks
A cheap model (one attempt, no validator) made 8 of 8 typical customer edits correctly on the new format: texts, a new table column, a row condition, moving a section, a new conditional box, a heading style, the brand colour (one theme value) and a component's text.
A final independent review found 6 problems, all fixed with tests: line breaks composed two ways, host value formats on export, incomplete TextLanguages, host theme values, tokens in component parameters, generic component names. Also fixed: two malformed-input cases that now give TB9200. Deferred minors: some composer-rejected values (e.g. a shadowing loop variable caught at build) surface at build rather than import; narrowing TextLanguages on re-export needs the build language; CellComposer options must come before content.
Activity
vaceslav commentedon Nov 26, 2026
Additional scope from the real-world port (#292):
F4 — Values that depend on the language but are not texts break the multi-language JSON export · significant for JSON
The definition measures column widths against each language's vocabulary (the widest label and value per column), so
German and English get different widths.
TemplateJson.ExportwithTextLanguages = [de, en]then fails:Two problems: the JSON has no place for a per-language length, and the message blames a text although the difference
is a column width. The port exports with one set of widths for both languages (an option of the definition) or one
JSON per language.
Related:
TemplateTextsgives only the build language. Measuring against every language needs the catalog passed tothe definition separately.
And TB9204 should name what differs: the first differing part and element.
F5 — Components cannot reach texts or a theme · significant for JSON, cosmetic for C#
ITemplateComponent.Compose(BlockComposer)sees neither the texts nor anything the definition shares. Every componentof the port therefore takes the theme and the texts in its constructor. That works in C#, but such a component cannot
be registered in a
ComponentCatalog(its parameters are not paths or simple values), so the JSON export writes everyuse as an expanded copy: 58
groupblocks in this template, the block of an organisation three times, one status boxfive times.
With that, a component's parameters are paths again and the catalog can write it as a reference.
F6 — No reusable inline fragments · cosmetic
Components are blocks. What repeats inside a paragraph (an icon followed by a word in a status colour; an address line
with guarded separators) is a C# extension method on
InlineComposerin the port. Fine in C#, invisible to JSON.F12 — The exported JSON is mostly indentation · cosmetic
The export of this template is 148,705 characters, of which 93,138 (63%) are leading spaces: components are nested
groups and the tree is up to 35 levels deep. Minified it is 50,542 characters. For a file meant to be read andedited by an agent, an export option without indentation would cut the cost by two thirds.
docs(builder): JSON format round plan (#293)
feat(builder): strict JSON reader — value formats, padding, loop vari…
feat(builder): names — then in every conditional, if in elseIf, parag…
feat(builder): texts by key, named sections instead of group (#293)
feat(builder): cells are a string or an object with style; tabs and l…
feat(builder): named assets and images with one size (#293)
feat(builder): theme tokens; components see texts and shared objects (#…
feat(builder): JSON layout width without indentation; export without …
feat(builder): style parameter first; content methods return their co…
fix(builder): registered components that read shared objects and text…
docs(builder): sample uses theme tokens, a named logo, sections, chai…
fix(builder): a text in the JSON's texts must have the languages of t…
docs(builder): JSON definitions as a reference: API, root, content, v…
style(builder): field naming in the JSON reader (#293)
fix(builder): final review of the JSON format round (#293)
docs(builder): host formats, theme overrides, complete export transla…
vaceslav commentedon Nov 26, 2026
Done on
feature/builder(commits referencing #293, up to 4fbc415). The issue stays open until the integration PR.Format (decisions A1–A9 of the style review)
TemplateJsonImportOptions.ValueFormats), padding with one or two values, a loop variable may not shadow its own collection's root, every text intextshas the languages of the others (a regional language is covered by its parent),==is read as=,$schemaignored,componentsreserved. TB9204 names the first paragraph that differs.thenin every conditional,elseIf: [{if, then}],paragraphStyle/headerParagraphStyle,defaults.paragraphStyle, cellverticalAlign.textskey first,{"section": …, "blocks": …}(C#c.Section), cells are a string or an object,\n/\tin strings.assetsat the root,ImageSource.WithName), images with one size.theme.colors/theme.fonts,"$accent"wherever a colour or font goes (also in borders and in registered components' parameters), host overrideTemplateJsonImportOptions.Theme(a colour token needs a colour; an unknown token warns, TB9205).c.Texts,c.Shared<T>(),template.Share,TemplateJsonImportOptions.Shared); a parameterless component is{"component": "name"}; texts a registered component reads go into the JSON'stexts.TemplateJsonExportOptions.Indented = falsewrites one line.C#: the style parameter comes first everywhere (
Text(style, text),Value(style, path[, format])); methods that add content return their composer, so short parts chain.Docs and sample: "JSON definitions" in the developer docs is now a reference (API, root, content, values, strictness, texts, sections/components/assets/theme). The sample uses theme tokens, a named logo, sections, chaining and a parameterless component that reads shared objects and texts; its JSON round trip is byte-identical in DOCX and ODT, de and en.
Checks
TextLanguages, host theme values, tokens in component parameters, generic component names. Also fixed: two malformed-input cases that now give TB9200. Deferred minors: some composer-rejected values (e.g. a shadowing loop variable caught at build) surface at build rather than import; narrowingTextLanguageson re-export needs the build language;CellComposeroptions must come before content.vaceslav commentedon Dec 2, 2026
Done on feature/builder, merged to main in #316 and released in builder 0.1.0.