Skip to content

Expose vertical writing through the API, MCP, and the agent skill - #19

Open
dani-polani wants to merge 1 commit into
mainfrom
feat/vertical-writing-api
Open

Expose vertical writing through the API, MCP, and the agent skill#19
dani-polani wants to merge 1 commit into
mainfrom
feat/vertical-writing-api

Conversation

@dani-polani

Copy link
Copy Markdown
Member

Follow-up to #18, which shipped column layout in the editor only. This makes it reachable programmatically and from an AI assistant.

What's added

Two fields, both following the existing rtl precedent:

  • settings.axis"rows" (default) or "columns"
  • lines[].orientation"upright" (default), "vertical", or "sideways"

The API only encodes state into a URL, so none of the layout work from #18 is involved here.

curl -X POST /api/align -H "Content-Type: application/json" -d '{
  "lines": [
    { "text": "The cat ate the fish", "sizePx": 26 },
    { "text": "猫 が 魚 を 食べた", "orientation": "vertical", "font": "Noto Serif JP", "sizePx": 34 }
  ],
  "alignments": [[0,0,1,0],[0,1,1,0],[0,3,1,2],[0,4,1,2],[0,2,1,4]],
  "settings": { "axis": "columns" }
}'

One trap worth knowing about

axis is spelled layoutAxis internally, and settings were merged with a spread. Left in the spread it would have landed as a stray key that the compact encoder silently drops: the field would have validated, the request would have succeeded, and the diagram would have come back horizontal. It is pulled out and mapped by hand, with a test asserting the decoded state rather than just the accepted input.

Unknown values are rejected with a named error instead of being normalized, matching palette and lineStyle.

Docs

pairs[].upper / lower mean earlier and later in the stack. That is above/below in rows but left/right in columns, and the names now say so on the /api page. The MCP tool description said links must be "vertically adjacent"; corrected, and both surfaces now state that Japanese and Chinese are not segmented for you. OpenAPI, the /api page, and the agent skill get a worked tategaki example.

Verification

196 tests green (7 added, covering both fields, the decoded state, defaults, and rejection of bad values). Driven end to end: POST to the running API, then the returned URL opened in Chromium — columns present, Japanese stacked, English upright beside it.

Found along the way, not fixed here

/api/og renders "NO GLYPH" boxes for any non-Latin script. og-fonts.ts bundles only Inter, loadSystemFonts is off, and the deploy image (node:22-bookworm-slim) has no fonts. This predates vertical writing: the horizontal Japanese example breaks the same way. It affects social cards for every non-Latin gallery page and the inline PNG the MCP tool returns. Left alone deliberately, since the fix is a build-weight tradeoff; tracked separately.

🤖 Generated with Claude Code

Two fields, both following the existing `rtl` precedent:

- `settings.axis` — "rows" (default) or "columns".
- `lines[].orientation` — "upright" (default), "vertical", or "sideways".

The API only encodes state into a URL, so none of the layout work is
involved. `axis` is spelled `layoutAxis` internally, so it is pulled out of
the settings spread and mapped by hand; leaving it in would have added a
stray key that the compact encoder silently drops, and the feature would
have looked wired up while doing nothing.

Unknown values are rejected with a named error rather than normalized, which
matches how `palette` and `lineStyle` behave.

Docs get the naming trap `upper`/`lower` set up: they mean earlier and later
in the stack, which is above/below in rows but left/right in columns. Same
correction in the MCP tool description, which also said links must be
"vertically adjacent". Both now mention that Japanese and Chinese are not
segmented for you.

OpenAPI, the /api page, and the agent skill get a worked tategaki example.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant