cli-anything-mermaid

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

cli-anything-mermaid

cli-anything-mermaid

Create, edit, and render Mermaid diagrams via stateful project files and the mermaid.ink renderer. Designed for AI agents and power users who need to generate flowcharts, sequence diagrams, and other visualizations without a GUI.
通过有状态项目文件和mermaid.ink渲染器创建、编辑和渲染Mermaid图表。专为无需GUI即可生成流程图、时序图及其他可视化内容的AI Agent和高级用户设计。

Installation

安装

This CLI is installed as part of the cli-anything-mermaid package:
bash
pip install cli-anything-mermaid
Prerequisites:
  • Python 3.10+
  • No external software required (rendering uses mermaid.ink cloud service)
此CLI作为cli-anything-mermaid包的一部分进行安装:
bash
pip install cli-anything-mermaid
前置要求:
  • Python 3.10+
  • 无需外部软件(渲染使用mermaid.ink云服务)

Usage

使用方法

Basic Commands

基础命令

bash
undefined
bash
undefined

Show help

显示帮助信息

cli-anything-mermaid --help
cli-anything-mermaid --help

Start interactive REPL mode

启动交互式REPL模式

cli-anything-mermaid
cli-anything-mermaid

Create a new project

创建新项目

cli-anything-mermaid project new -o diagram.json
cli-anything-mermaid project new -o diagram.json

Run with JSON output (for agent consumption)

以JSON格式输出(供Agent使用)

cli-anything-mermaid --json project info
undefined
cli-anything-mermaid --json project info
undefined

REPL Mode

REPL模式

When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-mermaid
当不指定子命令调用时,CLI会进入交互式REPL会话:
bash
cli-anything-mermaid

Enter commands interactively with tab-completion and history

交互式输入命令,支持自动补全和历史记录

undefined
undefined

Command Groups

命令组

Project

项目

Project lifecycle commands.
CommandDescription
new
Create a new Mermaid project with optional sample preset and theme
open
Open an existing Mermaid project file
save
Save the current project to a file
info
Show current project information
samples
List available sample diagram presets
项目生命周期相关命令。
命令描述
new
创建带有可选示例预设和主题的新Mermaid项目
open
打开现有的Mermaid项目文件
save
将当前项目保存到文件
info
显示当前项目信息
samples
列出可用的示例图表预设

Diagram

图表

Diagram source manipulation commands.
CommandDescription
set
Replace the Mermaid source text (inline or from file)
show
Print the current Mermaid source code
图表源文件操作命令。
命令描述
set
替换Mermaid源代码(直接输入或从文件读取)
show
打印当前Mermaid源代码

Export

导出

Render and share commands.
CommandDescription
render
Render the diagram to SVG or PNG via mermaid.ink
share
Generate a Mermaid Live Editor URL for sharing
渲染和分享相关命令。
命令描述
render
通过mermaid.ink将图表渲染为SVG或PNG格式
share
生成用于分享的Mermaid Live Editor URL

Session

会话

Session state commands.
CommandDescription
status
Show current session state
undo
Undo the last diagram source change
redo
Redo the last undone change
会话状态相关命令。
命令描述
status
显示当前会话状态
undo
撤销上一次图表源文件修改
redo
重做上一次撤销的修改

Examples

示例

Create and Render a Flowchart

创建并渲染流程图

bash
undefined
bash
undefined

Create a project with flowchart sample

创建带有流程图示例的项目

cli-anything-mermaid project new --sample flowchart -o flow.json
cli-anything-mermaid project new --sample flowchart -o flow.json

Replace diagram source

替换图表源代码

cli-anything-mermaid --project flow.json diagram set --text "graph TD; A-->B; B-->C;"
cli-anything-mermaid --project flow.json diagram set --text "graph TD; A-->B; B-->C;"

Render to SVG

渲染为SVG格式

cli-anything-mermaid --project flow.json export render output.svg --format svg
undefined
cli-anything-mermaid --project flow.json export render output.svg --format svg
undefined

Create a Sequence Diagram

创建时序图

bash
undefined
bash
undefined

Create project with sequence sample

创建带有时序图示例的项目

cli-anything-mermaid project new --sample sequence -o seq.json
cli-anything-mermaid project new --sample sequence -o seq.json

Set diagram from file

从文件设置图表内容

cli-anything-mermaid --project seq.json diagram set --file my_diagram.mmd
cli-anything-mermaid --project seq.json diagram set --file my_diagram.mmd

Render to PNG

渲染为PNG格式

cli-anything-mermaid --project seq.json export render output.png --format png
undefined
cli-anything-mermaid --project seq.json export render output.png --format png
undefined

Share a Diagram

分享图表

bash
undefined
bash
undefined

Generate an editable Mermaid Live URL

生成可编辑的Mermaid Live URL

cli-anything-mermaid --project flow.json export share --mode edit
cli-anything-mermaid --project flow.json export share --mode edit

Generate a view-only URL

生成仅查看的URL

cli-anything-mermaid --project flow.json export share --mode view
undefined
cli-anything-mermaid --project flow.json export share --mode view
undefined

Interactive REPL Session

交互式REPL会话

bash
cli-anything-mermaid
bash
cli-anything-mermaid

new flowchart

new flowchart

set graph TD; A-->B; B-->C;

set graph TD; A-->B; B-->C;

render output.svg

render output.svg

share

share

quit

quit

undefined
undefined

State Management

状态管理

The CLI maintains session state with:
  • Undo/Redo: Revert or replay diagram source changes
  • Project persistence: Save/load project state as JSON
  • Session tracking: Track modifications and changes
CLI通过以下方式维护会话状态:
  • 撤销/重做:恢复或重放图表源代码修改
  • 项目持久化:将项目状态保存/加载为JSON文件
  • 会话跟踪:记录修改和变更

Output Formats

输出格式

All commands support dual output modes:
  • Human-readable (default): Tables, colors, formatted text
  • Machine-readable (
    --json
    flag): Structured JSON for agent consumption
bash
undefined
所有命令支持两种输出模式:
  • 人类可读格式(默认):表格、颜色、格式化文本
  • 机器可读格式
    --json
    参数):结构化JSON,供Agent使用
bash
undefined

Human output

人类可读输出

cli-anything-mermaid project info
cli-anything-mermaid project info

JSON output for agents

供Agent使用的JSON输出

cli-anything-mermaid --json project info
undefined
cli-anything-mermaid --json project info
undefined

For AI Agents

针对AI Agent的使用说明

When using this CLI programmatically:
  1. Always use
    --json
    flag
    for parseable output
  2. Check return codes - 0 for success, non-zero for errors
  3. Parse stderr for error messages on failure
  4. Use absolute paths for all file operations
  5. Verify outputs exist after render operations
以编程方式使用此CLI时:
  1. 始终使用
    --json
    参数
    以获得可解析的输出
  2. 检查返回码 - 0表示成功,非零表示错误
  3. 解析stderr以获取失败时的错误信息
  4. 文件操作使用绝对路径
  5. 渲染操作后验证输出文件是否存在

More Information

更多信息

  • Full documentation: See README.md in the package
  • Test coverage: See TEST.md in the package
  • Methodology: See HARNESS.md in the cli-anything-plugin
  • 完整文档:查看包中的README.md
  • 测试覆盖率:查看包中的TEST.md
  • 方法说明:查看cli-anything-plugin中的HARNESS.md

Version

版本

1.0.0
1.0.0