JSON Render Table
Overview
Render generic structured data into compact table images using json-render-cli components (Column, Row, Container, Text, Badge).
Use this skill for non-ticket table use cases.
Workflow
- 1. Ensure
json-render is available. If missing, run npm i -g json-render-cli; if Chromium is missing, run npx playwright install chromium. - Define target columns and row schema for the current dataset.
- Generate message JSON in memory from the table template.
- Pass config via process substitution (
-c <(...)) to avoid temporary config files. - Set
screenshot.fullPage=true when row count or line wrapping is variable. - Tune viewport width/height to the current content footprint before final render, and avoid oversized fixed
--size. - Render PNG and return output path (or Base64 only when explicitly requested).
- Theme mode is configured with
theme.mode; use system by default, or force light / dark when needed.
Agent Coordination
- - Prefer rendering in the current (main) agent when the image must be delivered in the same turn.
- Delegate rendering to a sub-agent only when output-path handoff is explicit and deterministic.
- Keep rendered PNG files intact in sub-agent execution; do not delete or move them there.
- Perform garbage collection only in the main agent, and only after delivery succeeds.
Model Routing
- - If the current assistant model is high-cost (for example, Opus-class), route simple deterministic rendering to a lower-cost fast model (for example,
gemini3flash) only when Agent Coordination rules can be enforced; otherwise render in the current main agent.
Use Case Selection
- - Generic table: use
references/compact-table-template.md. - Ticket-focused table: use
json-render-ticket-table. - Information cards (KPI/compare/summary): use
json-render-info-cards. - Announcement/hero cards: use
json-render-announcement-cards. - Flow/timeline summaries: use
json-render-flow-summary.
Build And Render
Use references/compact-table-template.md.
Treat the included template as an executable starter and customize columns and widths per dataset.
Default style:
- - No title area
- Compact header + body
- Edge-to-edge screenshot
- Stable column widths
- Bottom rows remain visible (
screenshot.fullPage=true)
Layout Rules
- - Define columns with
Row + Container and explicit widths. - Keep spacing compact and deterministic.
- Use
Badge only for categorical status-like fields. - Resize the widest column first when content overflows.
- Keep viewport width close to the sum of column widths and avoid large horizontal slack.
- Start from a compact viewport height and expand only when clipping appears.
Output Rules
- - Prefer
-o /tmp/<name>.png for image delivery. - Use
-o stdout only when caller explicitly asks for Base64. - Avoid temporary JSON files unless explicitly requested.
- If a sub-agent renders the PNG, return path only and skip cleanup in that sub-agent.
- Run final PNG cleanup only in the main agent after image delivery.
Troubleshooting
- - If Chromium is missing, run:
npx playwright install chromium. - If rendering is too wide, reduce wide columns or font size.
- If left/right whitespace is too large, decrease viewport width or topic column width and rerender.
- If top/bottom whitespace is too large, decrease viewport height and rerender.
- If bottom rows are clipped, enable
screenshot.fullPage=true.
JSON 渲染表格
概述
使用 json-render-cli 组件(Column、Row、Container、Text、Badge)将通用结构化数据渲染为紧凑的表格图片。此技能适用于非工单类表格场景。
工作流程
- 1. 确保 json-render 可用。若缺失,运行 npm i -g json-render-cli;若 Chromium 缺失,运行 npx playwright install chromium。
- 为当前数据集定义目标列和行模式。
- 根据表格模板在内存中生成消息 JSON。
- 通过进程替换(-c <(...))传递配置,避免使用临时配置文件。
- 当行数或自动换行可变时,设置 screenshot.fullPage=true。
- 在最终渲染前,根据当前内容尺寸调整视口宽度/高度,避免使用过大的固定 --size。
- 渲染 PNG 并返回输出路径(仅在明确要求时返回 Base64)。
- 主题模式通过 theme.mode 配置;默认使用 system,必要时可强制设为 light 或 dark。
代理协作
- - 当图片需在同一轮对话中交付时,优先在当前(主)代理中渲染。
- 仅在输出路径交接明确且确定时,将渲染任务委托给子代理。
- 在子代理执行中保持渲染后的 PNG 文件完整,不进行删除或移动。
- 仅在主代理中执行垃圾回收,且仅在交付成功后进行。
模型路由
- - 若当前助手模型成本较高(例如 Opus 级别),仅在可执行代理协作规则时将简单确定性渲染路由至低成本快速模型(例如 gemini3flash);否则在当前主代理中渲染。
使用场景选择
- - 通用表格:使用 references/compact-table-template.md。
- 工单类表格:使用 json-render-ticket-table。
- 信息卡片(KPI/对比/摘要):使用 json-render-info-cards。
- 公告/英雄卡片:使用 json-render-announcement-cards。
- 流程/时间线摘要:使用 json-render-flow-summary。
构建与渲染
使用 references/compact-table-template.md。
将包含的模板视为可执行起点,并根据每个数据集自定义列和宽度。
默认样式:
- - 无标题区域
- 紧凑的页眉 + 正文
- 边缘到边缘截图
- 稳定的列宽
- 底部行保持可见(screenshot.fullPage=true)
布局规则
- - 使用 Row + Container 定义列,并指定显式宽度。
- 保持间距紧凑且确定。
- 仅对分类状态类字段使用 Badge。
- 当内容溢出时,优先调整最宽的列。
- 保持视口宽度接近列宽总和,避免过大的水平空白。
- 从紧凑的视口高度开始,仅在出现裁剪时扩展。
输出规则
- - 图片交付优先使用 -o /tmp/<名称>.png。
- 仅在调用方明确要求 Base64 时使用 -o stdout。
- 除非明确要求,避免使用临时 JSON 文件。
- 若子代理渲染 PNG,仅返回路径,不在该子代理中执行清理。
- 图片交付后,仅在主代理中执行最终 PNG 清理。
故障排除
- - 若 Chromium 缺失,运行:npx playwright install chromium。
- 若渲染过宽,缩小宽列或减小字号。
- 若左右空白过大,减小视口宽度或主题列宽度并重新渲染。
- 若上下空白过大,减小视口高度并重新渲染。
- 若底部行被裁剪,启用 screenshot.fullPage=true。