← Back to Skills Marketplace
theosunny

cpn_modeling_tool

by sunny · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ Security Clean
38
Downloads
1
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install cpn-modeling
Description
从自然语言业务场景描述中自动提取 CPN(着色 Petri 网)模型,输出 JSON、CPN Tools XML(.cpn)和 HTML 可视化三种格式。当用户描述业务流程并提到 CPN、Petri 网、建模、FS 规则、工序依赖、库所、变迁等关键词时触发。也适用于电商订单、餐厅点餐、审批流程、工程工序等场景,即...
README (SKILL.md)

CPN 建模

模式判断

收到用户输入后,先判断意图:

用户意图 处理方式
描述了完整业务流程,要求建模 建模输出(三部分)
有业务想法但描述模糊、或说"不懂 CPN" 交互引导模式
询问"如何建模"、"怎么识别库所" 建模指导,参考 references/modeling-guide.md
要求看示例 → 展示 references/example-restaurant.md

交互引导模式

触发条件:用户描述模糊、不熟悉 CPN 概念、或明确说"帮我一步步来"。

核心原则:用业务语言提问,不暴露 CPN 术语,每次只问一个问题,用户回答后立即给出反馈并推进。

引导流程

第1步:了解业务场景
第2步:梳理流程步骤
第3步:识别参与者和资源
第4步:找出依赖关系
第5步:确认并生成模型

第1步:了解业务场景

"你想建模的是什么业务?用一句话描述它的目标,比如'顾客下单到收货'或'员工请假到审批通过'。"

收到回答后,用自己的话复述一遍,确认理解正确,然后进入第2步。


第2步:梳理流程步骤

"这个流程从头到尾,大概经过哪几个环节?不用精确,先列出来,比如:下单 → 付款 → 备货 → 发货 → 签收。"

收到回答后:

  1. 将每个环节整理为动作(变迁)和状态(库所)的对应关系,展示给用户确认:
你描述的流程:
  [顾客待下单] → 下单 → [订单已提交] → 付款 → [付款已完成] → ...
  1. 问:"这个顺序对吗?有没有遗漏的环节?"

第3步:识别参与者和资源

"这个流程里,除了主流程,还有没有其他参与方或资源?比如:库存、审批人、账户余额、服务员……这些东西会不会影响流程能不能继续?"

收到回答后,将资源整理为资源库所,展示:

识别到的资源:
  库存(初始状态:充足)→ 备货时需要消耗
  审批人(初始状态:空闲)→ 审批时需要占用

问:"这些资源对吗?还有其他的吗?"


第4步:找出依赖关系

针对流程中每个"等待"或"条件",逐一确认:

"流程里有没有'必须等某件事完成,才能做下一步'的情况?比如:付款完成后才能备货,或者库存充足才能接单。"

收到回答后,将每条依赖整理并分类,展示:

依赖关系:
  ① 付款完成 → 才能备货(同链顺序)
  ② 备货完成 → 才能发货(同链顺序)
  ③ 库存充足 → 才能备货(资源依赖)

问:"还有其他依赖吗?"


第5步:确认并生成

汇总前四步的信息,展示完整摘要:

流程名称:[用户描述]
库所(状态节点):P1 顾客_待下单 / P2 订单_已提交 / ...
变迁(动作节点):T1 下单 / T2 付款 / ...
资源库所:库存_充足(初始有 token)/ ...
依赖关系:DEP1 付款→备货 / DEP2 库存→备货 / ...

"以上内容准确吗?有需要调整的地方吗?确认后我就生成完整的 CPN 模型(JSON + 可视化)。"

用户确认后,执行建模输出(三部分)。


引导过程中的原则

  • 每次只问一个问题,不要把多个问题堆在一起
  • 用业务语言,不说"库所"、"变迁"、"token",说"状态"、"动作"、"资源"
  • 每步给反馈,把用户的回答整理成结构化内容展示,让用户看到进展
  • 允许回退,用户说"不对"时,回到上一步重新确认
  • 遇到模糊描述,举例帮助用户理解,如"比如付款是一个动作,付款完成是一个状态"

建模输出

从自然语言业务场景描述中提取 CPN 模型,依次输出三种格式。

提取规则

1. 库所(Place) — 名词性实体 + 状态词,命名格式:{实体名}_{状态}

2. 变迁(Transition) — 动词性业务动作,命名格式:{动作}{实体名}

3. 着色集合(Color Set) — 只对影响流程走向的属性建模

4. 依赖关系(Dependency)

  • arc_sequence:同链内顺序,token 自然流动
  • guard_condition:跨链依赖,变迁加守卫条件
  • fusion_place:跨子项目状态共享,融合库所

输出步骤

第一部分:JSON(格式参考 references/json-schema.md

第二部分:CPN XML(格式参考 references/cpn-xml-template.md

  • 每个子项目对应一个 \x3Cpage>
  • fusion_place → 目标 page 创建同名融合库所
  • guard_condition → 变迁的 \x3Ccondition> 写入守卫

第三部分:HTML 可视化(格式参考 references/html-viz-template.md

  • 将 JSON 对象替换模板中的 __CPN_DATA__
  • 使用 Write 工具直接写入文件,不要把 HTML 内容输出到对话中
  • 写入路径:/tmp/\x3Cproject_id>.html
  • 写入完成后,根据操作系统告知用户打开方式:

macOS:

open /tmp/\x3Cproject_id>.html

Windows:

Start-Process /tmp/\x3Cproject_id>.html

Linux:

xdg-open /tmp/\x3Cproject_id>.html

输出质量检查

  1. dependency_rules 是否覆盖所有"才能/完成后"依赖
  2. 多输入变迁的所有输入库所是否都能获得 token(防死锁)
  3. HTML 中 __CPN_DATA__ 是否已替换为实际 JSON
  4. 每个 \x3Cpage> 是否与 JSON 子项目一一对应

参考文件

  • 建模方法论:references/modeling-guide.md
  • 经典示例(餐厅点餐):references/example-restaurant.md
  • JSON 格式:references/json-schema.md
  • CPN XML 格式:references/cpn-xml-template.md
  • HTML 可视化模板:references/html-viz-template.md
Usage Guidance
This skill appears safe to use for CPN modeling. Before opening the generated /tmp HTML file, make sure the input text and project_id are trustworthy, especially if the process description contains confidential business details.
Capability Analysis
Type: OpenClaw Skill Name: cpn-modeling Version: 1.0.1 The skill bundle is a legitimate tool designed to extract Colored Petri Net (CPN) models from natural language descriptions. It provides structured interaction logic in SKILL.md and comprehensive templates for JSON, XML, and HTML visualization. The instructions to write visualization files to /tmp and provide shell commands (e.g., xdg-open, open) for the user to view them are consistent with the stated purpose of generating local visualizations. The JavaScript in references/html-viz-template.md is a self-contained Canvas-based simulation engine with no evidence of network exfiltration, obfuscation, or unauthorized data access.
Capability Assessment
Purpose & Capability
The artifacts consistently describe converting natural-language business processes into CPN JSON, CPN Tools XML, and HTML visualization output.
Instruction Scope
The instructions stay focused on modeling, interactive clarification, and output formatting; there is no evidence of goal override, hidden external communication, or deceptive behavior.
Install Mechanism
There is no install spec, no required binaries, no environment variables, no credentials, and no code files beyond documentation/templates.
Credentials
The skill asks the agent to create a local HTML file under /tmp and suggests opening it; this is proportionate to the visualization purpose but is still a local file write.
Persistence & Privilege
The generated HTML file may remain in /tmp after use, but the artifacts show no background service, auto-start behavior, elevated privilege request, or credential use.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install cpn-modeling
  3. After installation, invoke the skill by name or use /cpn-modeling
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.1
Version 1.0.1 - No changes detected in the skill files or documentation. - Functionality and usage remain identical to the previous version.
v1.0.0
- Initial release of cpn-modeling skill. - Automatically extracts CPN (Coloured Petri Net) models from natural language business scenarios. - Supports output in three formats: JSON, CPN Tools XML (.cpn), and HTML visualization. - Provides an interactive guided mode for users unfamiliar with CPN concepts, using business-oriented language. - Recognizes and acts upon keywords such as process modeling, dependencies, transitions, and state, even when CPN terms are not used. - Includes built-in guidance and examples to assist users step-by-step through the modeling process.
Metadata
Slug cpn-modeling
Version 1.0.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is cpn_modeling_tool?

从自然语言业务场景描述中自动提取 CPN(着色 Petri 网)模型,输出 JSON、CPN Tools XML(.cpn)和 HTML 可视化三种格式。当用户描述业务流程并提到 CPN、Petri 网、建模、FS 规则、工序依赖、库所、变迁等关键词时触发。也适用于电商订单、餐厅点餐、审批流程、工程工序等场景,即... It is an AI Agent Skill for Claude Code / OpenClaw, with 38 downloads so far.

How do I install cpn_modeling_tool?

Run "/install cpn-modeling" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is cpn_modeling_tool free?

Yes, cpn_modeling_tool is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does cpn_modeling_tool support?

cpn_modeling_tool is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created cpn_modeling_tool?

It is built and maintained by sunny (@theosunny); the current version is v1.0.1.

💬 Comments