visualize

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

/visualize

/visualize

Auto-detect content shape and render the appropriate visualization. Follows the active-selection rule from
ai-workspace/rules/visualizations.md
.
自动识别内容形态并渲染合适的可视化效果。遵循
ai-workspace/rules/visualizations.md
中的当前选择规则。

Usage

使用方法

/visualize                              # visualize the last discussed concept
/visualize <topic or file>              # visualize specific content
/visualize --format mermaid <topic>     # force a specific format
/visualize                              # 可视化最后讨论的概念
/visualize <topic or file>              # 可视化特定内容
/visualize --format mermaid <topic>     # 强制使用特定格式

Steps

步骤

  1. Identify content. From args, recent conversation context, or a file path. Determine what needs visualizing.
  2. Classify content shape. Use this decision table:
    Content shapeSignalFormat
    Graph with nodes + edgesarchitecture, dependencies, flow between componentsMermaid
    graph
    or
    flowchart
    Sequence / interactionrequest flow, API calls, multi-step protocolMermaid
    sequenceDiagram
    State transitionsmodes, lifecycle, status changesMermaid
    stateDiagram-v2
    Comparison (3+ items)options, tradeoffs, feature matrixMarkdown table
    Hierarchy / treefile structure, org chart, simple nestingASCII art
    Contrast (2 items)before/after, good/bad, do/don'tInline pairs
    Entity relationshipsdata model, schemaMermaid
    erDiagram
  3. Check render surface. Mermaid in committed
    .md
    files renders on iOS/web/GitHub/VS Code. In terminal chunks, Mermaid is literal text — use ASCII instead. When surface is unknown, default to ASCII.
  4. Render.
    • ASCII / table / inline pairs: output directly in the response.
    • Mermaid: output as a fenced
      mermaid
      code block in the response. If high-resolution PNG is needed:
      bash
      node --import tsx scripts/render-mermaid.ts --input <mermaid-file> --output <png-path> --width 2400 --height 1800
    • Format override: if user passed
      --format
      , use that format regardless of auto-detection.
  5. Present. Show the visualization. If Mermaid PNG was rendered, display the path.
  1. 识别内容:从参数、最近的对话上下文或文件路径中获取。确定需要可视化的内容。
  2. 分类内容形态:使用以下决策表:
    内容形态特征格式
    带节点和边的图架构、依赖关系、组件间流程Mermaid
    graph
    flowchart
    序列/交互请求流程、API调用、多步骤协议Mermaid
    sequenceDiagram
    状态转换模式、生命周期、状态变化Mermaid
    stateDiagram-v2
    对比(3个及以上项)选项、权衡、功能矩阵Markdown表格
    层级/树状文件结构、组织结构图、简单嵌套ASCII艺术图
    对比(2个项)前后对比、优劣对比、该做/不该做内联配对
    实体关系数据模型、模式Mermaid
    erDiagram
  3. 检查渲染载体:提交的
    .md
    文件中的Mermaid可在iOS/网页/GitHub/VS Code中渲染。在终端块中,Mermaid是纯文本——改用ASCII格式。当载体未知时,默认使用ASCII。
  4. 渲染
    • ASCII/表格/内联配对:直接在响应中输出。
    • Mermaid:在响应中输出为带围栏的
      mermaid
      代码块。如果需要高分辨率PNG:
      bash
      node --import tsx scripts/render-mermaid.ts --input <mermaid-file> --output <png-path> --width 2400 --height 1800
    • 格式覆盖:如果用户传入
      --format
      参数,无论自动检测结果如何,都使用指定格式。
  5. 呈现:展示可视化效果。如果渲染了Mermaid PNG,显示其路径。

Failure modes

失败场景

ConditionBehavior
Content shape ambiguousAsk: "This could be a [X] or [Y] — which fits better?"
Mermaid syntax errorShow the error, offer to fix
mmdc not availableFall back to fenced Mermaid block (renders on GitHub/web)
条件行为
内容形态模糊询问:“这可以渲染为[X]或[Y]——哪种更合适?”
Mermaid语法错误显示错误信息,提供修复选项
mmdc不可用回退到带围栏的Mermaid代码块(可在GitHub/网页上渲染)

Cross-tool notes

跨工具说明

  • Codex / Cursor: run
    scripts/render-mermaid.ts
    directly for PNG rendering. Content-shape detection is agent reasoning, not script logic.
  • Codex / Cursor:直接运行
    scripts/render-mermaid.ts
    来渲染PNG。内容形态检测是Agent推理逻辑,而非脚本逻辑。