cli-anything-mermaid
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecli-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-mermaidPrerequisites:
- 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
undefinedbash
undefinedShow 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
undefinedcli-anything-mermaid --json project info
undefinedREPL Mode
REPL模式
When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-mermaid当不指定子命令调用时,CLI会进入交互式REPL会话:
bash
cli-anything-mermaidEnter commands interactively with tab-completion and history
交互式输入命令,支持自动补全和历史记录
undefinedundefinedCommand Groups
命令组
Project
项目
Project lifecycle commands.
| Command | Description |
|---|---|
| Create a new Mermaid project with optional sample preset and theme |
| Open an existing Mermaid project file |
| Save the current project to a file |
| Show current project information |
| List available sample diagram presets |
项目生命周期相关命令。
| 命令 | 描述 |
|---|---|
| 创建带有可选示例预设和主题的新Mermaid项目 |
| 打开现有的Mermaid项目文件 |
| 将当前项目保存到文件 |
| 显示当前项目信息 |
| 列出可用的示例图表预设 |
Diagram
图表
Diagram source manipulation commands.
| Command | Description |
|---|---|
| Replace the Mermaid source text (inline or from file) |
| Print the current Mermaid source code |
图表源文件操作命令。
| 命令 | 描述 |
|---|---|
| 替换Mermaid源代码(直接输入或从文件读取) |
| 打印当前Mermaid源代码 |
Export
导出
Render and share commands.
| Command | Description |
|---|---|
| Render the diagram to SVG or PNG via mermaid.ink |
| Generate a Mermaid Live Editor URL for sharing |
渲染和分享相关命令。
| 命令 | 描述 |
|---|---|
| 通过mermaid.ink将图表渲染为SVG或PNG格式 |
| 生成用于分享的Mermaid Live Editor URL |
Session
会话
Session state commands.
| Command | Description |
|---|---|
| Show current session state |
| Undo the last diagram source change |
| Redo the last undone change |
会话状态相关命令。
| 命令 | 描述 |
|---|---|
| 显示当前会话状态 |
| 撤销上一次图表源文件修改 |
| 重做上一次撤销的修改 |
Examples
示例
Create and Render a Flowchart
创建并渲染流程图
bash
undefinedbash
undefinedCreate 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
undefinedcli-anything-mermaid --project flow.json export render output.svg --format svg
undefinedCreate a Sequence Diagram
创建时序图
bash
undefinedbash
undefinedCreate 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
undefinedcli-anything-mermaid --project seq.json export render output.png --format png
undefinedShare a Diagram
分享图表
bash
undefinedbash
undefinedGenerate 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
undefinedcli-anything-mermaid --project flow.json export share --mode view
undefinedInteractive REPL Session
交互式REPL会话
bash
cli-anything-mermaidbash
cli-anything-mermaidnew 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
undefinedundefinedState 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 (flag): Structured JSON for agent consumption
--json
bash
undefined所有命令支持两种输出模式:
- 人类可读格式(默认):表格、颜色、格式化文本
- 机器可读格式(参数):结构化JSON,供Agent使用
--json
bash
undefinedHuman output
人类可读输出
cli-anything-mermaid project info
cli-anything-mermaid project info
JSON output for agents
供Agent使用的JSON输出
cli-anything-mermaid --json project info
undefinedcli-anything-mermaid --json project info
undefinedFor AI Agents
针对AI Agent的使用说明
When using this CLI programmatically:
- Always use flag for parseable output
--json - Check return codes - 0 for success, non-zero for errors
- Parse stderr for error messages on failure
- Use absolute paths for all file operations
- Verify outputs exist after render operations
以编程方式使用此CLI时:
- 始终使用参数以获得可解析的输出
--json - 检查返回码 - 0表示成功,非零表示错误
- 解析stderr以获取失败时的错误信息
- 文件操作使用绝对路径
- 渲染操作后验证输出文件是否存在
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