dwf-platform-cli 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. dwf_cli/__init__.py +3 -0
  2. dwf_cli/__main__.py +4 -0
  3. dwf_cli/api/__init__.py +3 -0
  4. dwf_cli/api/auth.py +46 -0
  5. dwf_cli/api/client.py +113 -0
  6. dwf_cli/api/datamodel.py +458 -0
  7. dwf_cli/api/formmodel.py +197 -0
  8. dwf_cli/api/funcmodel.py +436 -0
  9. dwf_cli/cli/__init__.py +69 -0
  10. dwf_cli/cli/_common.py +152 -0
  11. dwf_cli/cli/auth.py +197 -0
  12. dwf_cli/cli/config.py +200 -0
  13. dwf_cli/cli/datamodel.py +2270 -0
  14. dwf_cli/cli/formmodel.py +1007 -0
  15. dwf_cli/cli/funcmodel.py +2055 -0
  16. dwf_cli/cli/schema.py +210 -0
  17. dwf_cli/core/__init__.py +0 -0
  18. dwf_cli/core/config.py +177 -0
  19. dwf_cli/core/crypto.py +22 -0
  20. dwf_cli/core/errors.py +63 -0
  21. dwf_cli/core/output.py +6 -0
  22. dwf_cli/core/validator.py +129 -0
  23. dwf_cli/mcp/__init__.py +3 -0
  24. dwf_cli/mcp/server.py +411 -0
  25. dwf_cli/schemas/__init__.py +37 -0
  26. dwf_cli/schemas/datamodel/attribute_bind.schema.json +21 -0
  27. dwf_cli/schemas/datamodel/attribute_create.schema.json +24 -0
  28. dwf_cli/schemas/datamodel/attribute_update.schema.json +21 -0
  29. dwf_cli/schemas/datamodel/create.schema.json +27 -0
  30. dwf_cli/schemas/datamodel/excel_confirm.schema.json +65 -0
  31. dwf_cli/schemas/datamodel/external_create.schema.json +47 -0
  32. dwf_cli/schemas/datamodel/external_update.schema.json +47 -0
  33. dwf_cli/schemas/datamodel/object_create.schema.json +24 -0
  34. dwf_cli/schemas/datamodel/object_update.schema.json +17 -0
  35. dwf_cli/schemas/datamodel/relation_create.schema.json +34 -0
  36. dwf_cli/schemas/datamodel/relation_update.schema.json +34 -0
  37. dwf_cli/schemas/datamodel/update.schema.json +26 -0
  38. dwf_cli/schemas/funcmodel/app_create.schema.json +150 -0
  39. dwf_cli/schemas/funcmodel/app_update.schema.json +153 -0
  40. dwf_cli/schemas/funcmodel/language-package_create.schema.json +15 -0
  41. dwf_cli/schemas/funcmodel/operations_create.schema.json +77 -0
  42. dwf_cli/schemas/funcmodel/operations_update.schema.json +76 -0
  43. dwf_platform_cli-0.2.0.dist-info/METADATA +347 -0
  44. dwf_platform_cli-0.2.0.dist-info/RECORD +47 -0
  45. dwf_platform_cli-0.2.0.dist-info/WHEEL +4 -0
  46. dwf_platform_cli-0.2.0.dist-info/entry_points.txt +3 -0
  47. dwf_platform_cli-0.2.0.dist-info/licenses/LICENSE +190 -0
@@ -0,0 +1,77 @@
1
+ {
2
+ "description": "新增快速查询操作。oprScript/extSettings/viewType 传 JSON 对象自动转字符串",
3
+ "api": "POST /dwf/v1/meta/queryoperations-create (param: autoGenerateName)",
4
+ "type": "object",
5
+ "fields": [
6
+ {"name": "displayName", "type": "string", "required": true, "description": "操作显示名称(中文名),最长32字符", "example": "创建用户"},
7
+ {"name": "moduleName", "type": "string", "required": true, "description": "所属模块类英文名(className)", "example": "UserModule"},
8
+ {"name": "action", "type": "string", "required": true, "description": "操作类型,决定行为模式", "enum": ["create", "next_create", "edit", "visit", "url", "implement", "global_implement", "list", "folder"], "example": "create"},
9
+ {"name": "authority", "type": "string", "required": true, "description": "操作权限标识(英文名)。编辑时作为唯一标识,新增时可由后端 autoGenerateName 自动生成", "example": "createUser"},
10
+ {"name": "conType", "type": "string", "required": true, "description": "操作展现形式(容器类型)", "enum": ["dialog", "drawerR", "drawerL", "drawerT", "drawerB", "tab", "tip", "page"], "example": "dialog"},
11
+ {"name": "targetClass", "type": "string", "required": false, "description": "目标类全名(goal)。action=create/edit/visit/next_create 时必填", "example": "com.example.model.User"},
12
+ {"name": "viewOid", "type": "string", "required": false, "description": "表单视图OID。viewName='*' 时为 null(默认表单)。action=create/edit/visit/next_create 时必填", "example": "view-oid-12345"},
13
+ {"name": "viewName", "type": "string", "required": false, "description": "表单视图名称。viewOid 为 null 时设为 '*' 兼容旧数据", "example": "userForm"},
14
+ {"name": "viewTitle", "type": "string", "required": false, "description": "弹窗标题/视图标题", "example": "创建用户"},
15
+ {"name": "icon", "type": "string", "required": false, "description": "系统图标名称(btmIconType='系统图标'时使用)", "example": "ios-cube-outline"},
16
+ {"name": "order", "type": "number", "required": false, "description": "排序编号,控制菜单显示顺序", "default": 0, "example": 1},
17
+ {"name": "params", "type": "string", "required": false, "description": "参数配置,拼接前后置脚本参数", "example": "APP_beforeScript:console.log('before')APP_afterScript:console.log('after')"},
18
+ {"name": "conditionExpre", "type": "string", "required": false, "description": "条件表达式。action=url 时存链接URL;action=implement/global_implement 时存插件路径('addin:'前缀);其余存查询条件", "example": "status=1"},
19
+ {"name": "parentOprId", "type": "string", "required": false, "description": "父节点操作ID"},
20
+ {"name": "isHidden", "type": "boolean", "required": false, "description": "是否在菜单中隐藏", "default": false, "example": false},
21
+ {"name": "implementType", "type": "string", "required": false, "description": "实现方式类型(action=implement/global_implement 时必填)", "enum": ["", "addin", "serverScript", "clientScript"]},
22
+ {"name": "oprScript", "type": "object", "required": false, "description": "脚本配置(自动转 JSON 字符串),含 implement/appBefore/appAfter/appClose 四组"},
23
+ {"name": "oprScript.implement", "type": "object", "required": false, "description": "实现脚本,含 entry/client/server"},
24
+ {"name": "oprScript.appBefore", "type": "object", "required": false, "description": "前置脚本"},
25
+ {"name": "oprScript.appAfter", "type": "object", "required": false, "description": "后置脚本"},
26
+ {"name": "oprScript.appClose", "type": "object", "required": false, "description": "关闭脚本"},
27
+ {"name": "extSettings", "type": "object", "required": false, "description": "扩展设置(自动转 JSON 字符串),含按钮行为、刷新策略等"},
28
+ {"name": "extSettings.needDefaultOpr", "type": "boolean", "required": false, "description": "是否需要默认操作按钮(保存/取消)", "default": false},
29
+ {"name": "extSettings.backRefresh", "type": "boolean", "required": false, "description": "操作完成后是否返回刷新", "default": true},
30
+ {"name": "extSettings.sourceFormFreshStatus", "type": "boolean", "required": false, "description": "源表单是否刷新", "default": false},
31
+ {"name": "extSettings.targetFormFreshStatus", "type": "boolean", "required": false, "description": "目标表单是否刷新", "default": true},
32
+ {"name": "extSettings.needDialogDefaultOpr", "type": "boolean", "required": false, "description": "弹窗是否需要默认操作按钮", "default": true},
33
+ {"name": "extSettings.autoClose", "type": "string", "required": false, "description": "自动关闭策略", "enum": ["auto", "manual"], "default": "auto"},
34
+ {"name": "extSettings.sysBindOpr", "type": "boolean", "required": false, "description": "是否为系统绑定操作", "default": false},
35
+ {"name": "extSettings.btmIconType", "type": "string", "required": false, "description": "底部图标类型", "enum": ["系统图标", "自定义图标"], "default": "系统图标"},
36
+ {"name": "extSettings.btmIconDefColor", "type": "string", "required": false, "description": "底部图标默认颜色", "default": "#646566"},
37
+ {"name": "extSettings.btmIconActColor", "type": "string", "required": false, "description": "底部图标激活颜色", "default": "#1989fa"},
38
+ {"name": "extSettings.defImg", "type": "string", "required": false, "description": "自定义默认图标文件ID"},
39
+ {"name": "extSettings.actImg", "type": "string", "required": false, "description": "自定义选中图标文件ID"},
40
+ {"name": "viewType", "type": "object", "required": false, "description": "弹窗参数配置(自动转 JSON 字符串),含尺寸、位置、拖拽等"},
41
+ {"name": "viewType.needPopTitle", "type": "boolean", "required": false, "description": "是否需要弹窗标题", "default": false},
42
+ {"name": "viewType.popTitleTxt", "type": "string", "required": false, "description": "弹窗标题文字", "default": "提示"},
43
+ {"name": "viewType.popTitleFs", "type": "number", "required": false, "description": "弹窗标题字号(px)", "default": 14},
44
+ {"name": "viewType.popTitleColor", "type": "string", "required": false, "description": "弹窗标题颜色", "default": "#333"},
45
+ {"name": "viewType.tipPlacement", "type": "string", "required": false, "description": "tip提示位置(conType='tip'时使用)", "enum": ["左边", "右边", "上边", "下边"], "default": "右边"},
46
+ {"name": "viewType.popWidth", "type": "number", "required": false, "description": "tip弹窗宽度(px)", "default": 400},
47
+ {"name": "viewType.dialogWidth", "type": "number", "required": false, "description": "弹窗宽度数值", "default": 86},
48
+ {"name": "viewType.dialogWidthType", "type": "string", "required": false, "description": "弹窗宽度单位", "enum": ["%", "px"], "default": "%"},
49
+ {"name": "viewType.dialogAutoHeight", "type": "boolean", "required": false, "description": "弹窗是否自动高度", "default": true},
50
+ {"name": "viewType.dialogHeight", "type": "number", "required": false, "description": "弹窗高度数值", "default": 400},
51
+ {"name": "viewType.dialogHeightType", "type": "string", "required": false, "description": "弹窗高度单位", "enum": ["px", "%"], "default": "px"},
52
+ {"name": "viewType.dragDialog", "type": "boolean", "required": false, "description": "弹窗是否可拖拽", "default": false},
53
+ {"name": "viewType.drawerWidth", "type": "number", "required": false, "description": "抽屉宽度(px)", "default": 720},
54
+ {"name": "viewType.drawerWidthType", "type": "string", "required": false, "description": "抽屉宽度单位", "enum": ["px", "%"], "default": "px"},
55
+ {"name": "viewType.drawerHeight", "type": "number", "required": false, "description": "抽屉高度数值", "default": 100},
56
+ {"name": "viewType.drawerHeightType", "type": "string", "required": false, "description": "抽屉高度单位", "enum": ["%", "px"], "default": "%"}
57
+ ],
58
+ "examples": [
59
+ {
60
+ "displayName": "创建用户",
61
+ "moduleName": "UserModule",
62
+ "action": "create",
63
+ "authority": "createUser",
64
+ "conType": "dialog",
65
+ "targetClass": "com.example.model.User",
66
+ "viewOid": "view-oid-12345",
67
+ "oprScript": {
68
+ "implement": {"entry": "client", "client": {"default": {"script": "console.log('hi')"}}, "server": {"default": {"script": "", "displayName": "默认脚本"}}}
69
+ },
70
+ "extSettings": {"needDefaultOpr": false, "autoClose": "auto", "btmIconType": "系统图标"},
71
+ "viewType": {"dialogWidth": 86, "dialogWidthType": "%", "dialogAutoHeight": true},
72
+ "icon": "ios-cube-outline",
73
+ "order": 1,
74
+ "isHidden": false
75
+ }
76
+ ]
77
+ }
@@ -0,0 +1,76 @@
1
+ {
2
+ "description": "更新快速查询操作。oprScript/extSettings/viewType 传 JSON 对象自动转字符串",
3
+ "api": "POST /dwf/v1/meta/queryoperations-update (param: forceUpdate)",
4
+ "type": "object",
5
+ "fields": [
6
+ {"name": "oid", "type": "string", "required": true, "description": "操作OID(必填,标识要更新的操作)", "example": "A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6"},
7
+ {"name": "displayName", "type": "string", "required": false, "description": "操作显示名称(中文名),最长32字符", "example": "创建用户"},
8
+ {"name": "moduleName", "type": "string", "required": false, "description": "所属模块类英文名", "example": "UserModule"},
9
+ {"name": "action", "type": "string", "required": false, "description": "操作类型", "enum": ["create", "next_create", "edit", "visit", "url", "implement", "global_implement", "list", "folder"]},
10
+ {"name": "authority", "type": "string", "required": false, "description": "操作权限标识(英文名)", "example": "createUser"},
11
+ {"name": "conType", "type": "string", "required": false, "description": "操作展现形式", "enum": ["dialog", "drawerR", "drawerL", "drawerT", "drawerB", "tab", "tip", "page"]},
12
+ {"name": "targetClass", "type": "string", "required": false, "description": "目标类全名", "example": "com.example.model.User"},
13
+ {"name": "viewOid", "type": "string", "required": false, "description": "表单视图OID"},
14
+ {"name": "viewName", "type": "string", "required": false, "description": "表单视图名称"},
15
+ {"name": "viewTitle", "type": "string", "required": false, "description": "弹窗标题"},
16
+ {"name": "icon", "type": "string", "required": false, "description": "系统图标名称"},
17
+ {"name": "order", "type": "number", "required": false, "description": "排序编号", "default": 0},
18
+ {"name": "params", "type": "string", "required": false, "description": "参数配置字符串"},
19
+ {"name": "conditionExpre", "type": "string", "required": false, "description": "条件表达式"},
20
+ {"name": "parentOprId", "type": "string", "required": false, "description": "父节点操作ID"},
21
+ {"name": "isHidden", "type": "boolean", "required": false, "description": "是否在菜单中隐藏", "default": false},
22
+ {"name": "implementType", "type": "string", "required": false, "description": "实现方式类型", "enum": ["", "addin", "serverScript", "clientScript"]},
23
+ {"name": "modifyTime", "type": "string", "required": false, "description": "最后修改时间,回传以检测并发冲突", "example": "2024-01-15T10:30:00"},
24
+ {"name": "oprScript", "type": "object", "required": false, "description": "脚本配置(自动转 JSON 字符串)"},
25
+ {"name": "oprScript.implement", "type": "object", "required": false, "description": "实现脚本"},
26
+ {"name": "oprScript.appBefore", "type": "object", "required": false, "description": "前置脚本"},
27
+ {"name": "oprScript.appAfter", "type": "object", "required": false, "description": "后置脚本"},
28
+ {"name": "oprScript.appClose", "type": "object", "required": false, "description": "关闭脚本"},
29
+ {"name": "extSettings", "type": "object", "required": false, "description": "扩展设置(自动转 JSON 字符串)"},
30
+ {"name": "extSettings.needDefaultOpr", "type": "boolean", "required": false, "description": "是否需要默认操作按钮", "default": false},
31
+ {"name": "extSettings.backRefresh", "type": "boolean", "required": false, "description": "操作完成后是否返回刷新", "default": true},
32
+ {"name": "extSettings.sourceFormFreshStatus", "type": "boolean", "required": false, "description": "源表单是否刷新", "default": false},
33
+ {"name": "extSettings.targetFormFreshStatus", "type": "boolean", "required": false, "description": "目标表单是否刷新", "default": true},
34
+ {"name": "extSettings.needDialogDefaultOpr", "type": "boolean", "required": false, "description": "弹窗是否需要默认操作按钮", "default": true},
35
+ {"name": "extSettings.autoClose", "type": "string", "required": false, "description": "自动关闭策略", "enum": ["auto", "manual"], "default": "auto"},
36
+ {"name": "extSettings.sysBindOpr", "type": "boolean", "required": false, "description": "是否为系统绑定操作", "default": false},
37
+ {"name": "extSettings.btmIconType", "type": "string", "required": false, "description": "底部图标类型", "enum": ["系统图标", "自定义图标"], "default": "系统图标"},
38
+ {"name": "extSettings.btmIconDefColor", "type": "string", "required": false, "description": "底部图标默认颜色", "default": "#646566"},
39
+ {"name": "extSettings.btmIconActColor", "type": "string", "required": false, "description": "底部图标激活颜色", "default": "#1989fa"},
40
+ {"name": "extSettings.defImg", "type": "string", "required": false, "description": "自定义默认图标文件ID"},
41
+ {"name": "extSettings.actImg", "type": "string", "required": false, "description": "自定义选中图标文件ID"},
42
+ {"name": "viewType", "type": "object", "required": false, "description": "弹窗参数配置(自动转 JSON 字符串)"},
43
+ {"name": "viewType.needPopTitle", "type": "boolean", "required": false, "description": "是否需要弹窗标题", "default": false},
44
+ {"name": "viewType.popTitleTxt", "type": "string", "required": false, "description": "弹窗标题文字", "default": "提示"},
45
+ {"name": "viewType.popTitleFs", "type": "number", "required": false, "description": "弹窗标题字号(px)", "default": 14},
46
+ {"name": "viewType.popTitleColor", "type": "string", "required": false, "description": "弹窗标题颜色", "default": "#333"},
47
+ {"name": "viewType.tipPlacement", "type": "string", "required": false, "description": "tip提示位置", "enum": ["左边", "右边", "上边", "下边"], "default": "右边"},
48
+ {"name": "viewType.popWidth", "type": "number", "required": false, "description": "tip弹窗宽度(px)", "default": 400},
49
+ {"name": "viewType.dialogWidth", "type": "number", "required": false, "description": "弹窗宽度数值", "default": 86},
50
+ {"name": "viewType.dialogWidthType", "type": "string", "required": false, "description": "弹窗宽度单位", "enum": ["%", "px"], "default": "%"},
51
+ {"name": "viewType.dialogAutoHeight", "type": "boolean", "required": false, "description": "弹窗是否自动高度", "default": true},
52
+ {"name": "viewType.dialogHeight", "type": "number", "required": false, "description": "弹窗高度数值", "default": 400},
53
+ {"name": "viewType.dialogHeightType", "type": "string", "required": false, "description": "弹窗高度单位", "enum": ["px", "%"], "default": "px"},
54
+ {"name": "viewType.dragDialog", "type": "boolean", "required": false, "description": "弹窗是否可拖拽", "default": false},
55
+ {"name": "viewType.drawerWidth", "type": "number", "required": false, "description": "抽屉宽度(px)", "default": 720},
56
+ {"name": "viewType.drawerWidthType", "type": "string", "required": false, "description": "抽屉宽度单位", "enum": ["px", "%"], "default": "px"},
57
+ {"name": "viewType.drawerHeight", "type": "number", "required": false, "description": "抽屉高度数值", "default": 100},
58
+ {"name": "viewType.drawerHeightType", "type": "string", "required": false, "description": "抽屉高度单位", "enum": ["%", "px"], "default": "%"}
59
+ ],
60
+ "examples": [
61
+ {
62
+ "oid": "A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6",
63
+ "displayName": "编辑用户(改名)",
64
+ "modifyTime": "2024-01-15T10:30:00"
65
+ },
66
+ {
67
+ "oid": "A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6",
68
+ "isHidden": true
69
+ },
70
+ {
71
+ "oid": "A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6",
72
+ "extSettings": {"needDefaultOpr": true, "autoClose": "manual"},
73
+ "viewType": {"dialogWidth": 90, "dialogWidthType": "%"}
74
+ }
75
+ ]
76
+ }
@@ -0,0 +1,347 @@
1
+ Metadata-Version: 2.4
2
+ Name: dwf-platform-cli
3
+ Version: 0.2.0
4
+ Summary: DWF platform CLI and MCP server for AI agents and developers
5
+ Project-URL: Repository, https://gitee.com/tsinghua-nercbds/dwf-cli
6
+ Project-URL: Documentation, https://gitee.com/tsinghua-nercbds/dwf-cli#readme
7
+ Project-URL: Issues, https://gitee.com/tsinghua-nercbds/dwf-cli/issues
8
+ Author-email: nercbds dwf group <csliuyb@qq.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: ai-agent,cli,dwf,llm-tools,mcp
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.12
23
+ Requires-Dist: httpx>=0.28.0
24
+ Requires-Dist: mcp>=1.0.0
25
+ Requires-Dist: pycryptodome>=3.23.0
26
+ Requires-Dist: pypinyin>=0.52.0
27
+ Requires-Dist: rich>=13.0.0
28
+ Requires-Dist: typer>=0.25.1
29
+ Description-Content-Type: text/markdown
30
+
31
+ # DWF-CLI
32
+
33
+ DWF(Digital Workflow)平台命令行工具,通过 REST API 与 DWF 后端交互,为 AI 智能体和开发人员提供数据模型查询、数据操作、认证管理等功能。
34
+
35
+ ## 功能
36
+
37
+ - **用户认证** — 登录/登出/状态查询(AES 加密密码传输)
38
+ - **数据模型管理** — 查询/创建/更新/删除实体类、关联类、外部实体类及其属性
39
+ - **数据操作** — 对象数据的增删改查(CRUD),支持 `--if-not-exists` 幂等创建
40
+ - **高级查询** — 对象列表支持 `refs`(关联字段拉平)和 `options`(嵌套子查询)
41
+ - **Excel 快速建表** — 上传 Excel 一键完成建表和数据导入
42
+ - **功能模型** — 应用管理、全局操作列表
43
+ - **表单模型** — 视图的查询/创建/更新/删除
44
+ - **Schema 自省** — `dwf-cli schema` 查看命令参数定义,`--validate` 校验输入
45
+ - **配置管理** — 服务器地址、AES 密钥等配置项管理
46
+
47
+ ## 快速开始
48
+
49
+ ### 环境要求
50
+
51
+ - Python 3.12+
52
+ - [uv](https://docs.astral.sh/uv/) 包管理器
53
+
54
+ ### 安装
55
+
56
+ ```bash
57
+ # 安装(推荐 uv tool)
58
+ uv tool install dwf-cli
59
+
60
+ # 或从源码安装
61
+ git clone https://gitee.com/tsinghua-nercbds/dwf-cli.git
62
+ cd dwf-cli
63
+ uv tool install .
64
+ ```
65
+
66
+ ### 配置与登录
67
+
68
+ ```bash
69
+ # 方式一:自动检测(推荐,从 DWF 服务获取配置)
70
+ dwf-cli config detect http://your-dwf-server:6060 --save
71
+
72
+ # 方式二:手动配置
73
+ dwf-cli config set server http://your-dwf-server:6060
74
+ dwf-cli config set app_server http://your-dwf-server:9090
75
+
76
+ # 登录(TTY 模式交互输入密码)
77
+ dwf-cli auth login --username admin
78
+
79
+ # 非 TTY 模式(CI / AI agent)
80
+ echo 'password' > /tmp/pw && dwf-cli auth login --username admin --password-file /tmp/pw
81
+
82
+ # 查看登录状态
83
+ dwf-cli auth status
84
+ ```
85
+
86
+ ### 使用示例
87
+
88
+ ```bash
89
+ # 查询实体类列表
90
+ dwf-cli datamodel list
91
+ dwf-cli datamodel list -p 1 -s 10
92
+
93
+ # 查询关联类 / 外部实体类
94
+ dwf-cli datamodel list -t r
95
+ dwf-cli datamodel list -t x
96
+
97
+ # 包含系统类
98
+ dwf-cli datamodel list --system
99
+
100
+ # 查看某个类的属性
101
+ dwf-cli datamodel show User
102
+ dwf-cli datamodel show Animate -f json
103
+
104
+ # 创建实体类(支持 --type entity|relation|external)
105
+ dwf-cli datamodel create --data '[{"className":"TestClass","displayName":"测试类"}]'
106
+ dwf-cli datamodel create -t relation --data '[{"className":"UserAsset","leftClass":"User","rightClass":"Asset"}]'
107
+ dwf-cli datamodel create -t external --external-mode sql --file ext.json
108
+
109
+ # 更新类信息
110
+ dwf-cli datamodel update --data '{"id":"ABC123","displayName":"新名称"}'
111
+ dwf-cli datamodel update -t external --data '{"id":"EXT123","displayName":"新名称"}'
112
+
113
+ # 属性管理
114
+ dwf-cli datamodel attribute list --keyword name
115
+ dwf-cli datamodel attribute create --data '[{"attributeName":"phone","valueType":"String"}]'
116
+ dwf-cli datamodel attribute bind -c User --data '[{"attributeName":"phone"}]'
117
+
118
+ # 对象数据操作
119
+ dwf-cli datamodel object list -c User -p 0
120
+ dwf-cli datamodel object get <oid> -c User
121
+ dwf-cli datamodel object create -c User --data '{"name":"test"}'
122
+ dwf-cli datamodel object create -c User --data '{"name":"test"}' --if-not-exists
123
+
124
+ # 对象高级查询(refs 关联字段拉平)
125
+ dwf-cli datamodel object list -c Animate --file query.json
126
+
127
+ # Excel 一键建表
128
+ dwf-cli datamodel excel-quickstart template.xlsx
129
+
130
+ # Schema 自省
131
+ dwf-cli schema --all
132
+ dwf-cli schema datamodel create
133
+
134
+ # 功能模型
135
+ dwf-cli funcmodel app list
136
+ dwf-cli funcmodel operations list
137
+
138
+ # 表单模型
139
+ dwf-cli formmodel view list -c User
140
+ dwf-cli formmodel view create -c User --name myView
141
+
142
+ # 配置管理
143
+ dwf-cli config list
144
+ dwf-cli config get server
145
+ dwf-cli config set aes_key "your-key"
146
+ ```
147
+
148
+ ## 文档
149
+
150
+ 完整文档使用 MkDocs + Material 主题构建:
151
+
152
+ ```bash
153
+ # 本地预览(默认不含 API 参考文档,构建更快)
154
+ uv run mkdocs serve
155
+
156
+ # 包含 API 参考文档
157
+ DWF_INCLUDE_API_DOCS=1 uv run mkdocs serve
158
+
159
+ # 重新生成 API 文档(从 OpenAPI JSON)
160
+ uv run python scripts/openapi_to_md.py
161
+ ```
162
+
163
+ 文档站点自动部署至 Tomcat(通过 Jenkinsfile CI)。
164
+
165
+ ## 架构
166
+
167
+ 项目采用三层分离架构:
168
+
169
+ ```
170
+ cli/ → api/ → core/
171
+ ```
172
+
173
+ - **`cli/`** — CLI 层:Typer 命令定义、参数解析、Rich 表格输出
174
+ - **`api/`** — API 层:DWF 后端 REST API 的 Python SDK(httpx)
175
+ - **`core/`** — 基础设施层:配置管理、AES 加密、错误定义、输出格式化
176
+
177
+ 依赖方向严格单向:`cli → api → core`,禁止反向依赖。
178
+
179
+ 详细架构设计见 [ARCHITECTURE.md](ARCHITECTURE.md)。
180
+
181
+ ## 项目结构
182
+
183
+ ```
184
+ src/dwf_cli/
185
+ ├── __init__.py # 入口点 (dwf-cli = "dwf_cli:app")
186
+ ├── __main__.py # python -m dwf_cli
187
+ ├── api/ # DWF 后端 REST SDK
188
+ │ ├── client.py # HTTP 客户端(baseURL、token 注入、错误映射)
189
+ │ ├── auth.py # 认证接口
190
+ │ ├── datamodel.py # 数据模型 + 对象 CRUD 接口
191
+ │ ├── funcmodel.py # 功能模型接口
192
+ │ └── formmodel.py # 表单模型接口
193
+ ├── cli/ # Typer 命令
194
+ │ ├── __init__.py # 命令注册 + 上下文初始化(双 client:modeler + app)
195
+ │ ├── _common.py # 共享工具(ContextObj、get_client、get_app_client)
196
+ │ ├── auth.py # dwf-cli auth {login, logout, status}
197
+ │ ├── datamodel.py # dwf-cli datamodel {list, show, object CRUD}
198
+ │ ├── funcmodel.py # dwf-cli funcmodel {app, operations}
199
+ │ ├── formmodel.py # dwf-cli formmodel {view}
200
+ │ └── config.py # dwf-cli config {get, set, list, detect}
201
+ ├── mcp/ # MCP Server(供 AI 工具直接集成)
202
+ │ ├── __init__.py
203
+ │ └── server.py # FastMCP server,入口点 dwf-cli-mcp
204
+ └── core/ # 基础设施
205
+ ├── config.py # 配置管理(JSON 持久化)+ config.js 解析
206
+ ├── crypto.py # AES 密码加密
207
+ ├── errors.py # 异常层级 + 退出码
208
+ └── output.py # Rich 表格/JSON 输出
209
+ ```
210
+
211
+ ## 开发
212
+
213
+ ### 添加新命令
214
+
215
+ 只需 3 步:
216
+
217
+ 1. 新建 `src/dwf_cli/api/xxx.py` — 定义 API 调用函数
218
+ 2. 新建 `src/dwf_cli/cli/xxx.py` — 定义 Typer 命令
219
+ 3. 编辑 `src/dwf_cli/cli/__init__.py` — 添加 `app.add_typer()`
220
+
221
+ ### 开发命令
222
+
223
+ ```bash
224
+ uv run dwf-cli --help # 开发时运行 CLI
225
+ uv run pytest -v # 运行测试
226
+ uv run ruff check . # 代码检查
227
+ uv run ruff format . # 代码格式化
228
+ uv add <package> # 添加依赖
229
+ ```
230
+
231
+ 安装后直接使用:
232
+
233
+ ```bash
234
+ dwf-cli --help # 已安装环境直接调用
235
+ ```
236
+
237
+ ### 文档命令
238
+
239
+ ```bash
240
+ uv run mkdocs serve # 本地预览文档
241
+ DWF_INCLUDE_API_DOCS=1 uv run mkdocs serve # 含 API 参考
242
+ uv run python scripts/openapi_to_md.py # 重新生成 API 文档
243
+ ```
244
+
245
+ ## 技术栈
246
+
247
+ - [Typer](https://typer.tiangolo.com/) — CLI 框架
248
+ - [httpx](https://www.python-httpx.org/) — HTTP 客户端
249
+ - [Rich](https://rich.readthedocs.io/) — 终端美化输出
250
+ - [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) — MCP Server 实现
251
+ - [pycryptodome](https://www.pycryptodome.org/) — AES 密码加密
252
+ - [uv](https://docs.astral.sh/uv/) — 包管理器
253
+ - [pytest](https://docs.pytest.org/) — 测试框架
254
+ - [Ruff](https://docs.astral.sh/ruff/) — 代码检查与格式化
255
+
256
+ ## AI Agent 集成
257
+
258
+ DWF-CLI 提供两种方式供 AI 编程工具使用:
259
+
260
+ ### 方式一:CLI 命令(所有 AI 工具通用)
261
+
262
+ AI 编程工具(Claude Code、OpenCode、Codex 等)可通过 bash 直接调用 `dwf-cli` 命令。
263
+
264
+ 在你的项目 `AGENTS.md`(opencode)或 `CLAUDE.md`(Claude Code)中添加以下内容:
265
+
266
+ ```markdown
267
+ ## DWF CLI
268
+ Use `dwf-cli` to interact with the DWF platform.
269
+ - Run `dwf-cli schema --all` to get full command + parameter reference as JSON
270
+ - Run `dwf-cli <command> --help` for specific command usage
271
+ - Always use `--format json` for output parsing
272
+ - Use `--data` for inline JSON, `--file` for file input
273
+ - Use `--dry-run` to preview before executing
274
+ - Setup: `dwf-cli config detect <url> --save` then `dwf-cli auth login --username <user>` (TTY) or `--password-file` (non-interactive)
275
+ ```
276
+
277
+ ### 方式二:MCP Server(深度集成,推荐)
278
+
279
+ MCP (Model Context Protocol) 让 AI 工具直接调用 DWF 功能,无需拼 shell 命令。
280
+
281
+ **安装后配置:**
282
+
283
+ Claude Code (`~/.claude/settings.json`):
284
+
285
+ ```json
286
+ {
287
+ "mcpServers": {
288
+ "dwf": {
289
+ "command": "uvx",
290
+ "args": ["dwf-cli-mcp"]
291
+ }
292
+ }
293
+ }
294
+ ```
295
+
296
+ Cursor / Windsurf (`.cursor/mcp.json`):
297
+
298
+ ```json
299
+ {
300
+ "mcpServers": {
301
+ "dwf": {
302
+ "command": "uvx",
303
+ "args": ["dwf-cli-mcp"]
304
+ }
305
+ }
306
+ }
307
+ ```
308
+
309
+ 从源码运行:
310
+
311
+ ```json
312
+ {
313
+ "mcpServers": {
314
+ "dwf": {
315
+ "command": "uv",
316
+ "args": ["--directory", "/path/to/dwf-cli", "run", "dwf-cli-mcp"]
317
+ }
318
+ }
319
+ }
320
+ ```
321
+
322
+ **提供的 MCP 工具:**
323
+
324
+ | 工具 | 说明 |
325
+ |------|------|
326
+ | `dwf_auth_status` | 检查认证状态 |
327
+ | `dwf_config_list` | 查看配置 |
328
+ | `dwf_datamodel_list` | 列出数据模型 |
329
+ | `dwf_datamodel_show` | 查看模型详情 |
330
+ | `dwf_datamodel_create` | 创建数据模型 |
331
+ | `dwf_datamodel_delete` | 删除数据模型 |
332
+ | `dwf_attribute_list` | 列出属性 |
333
+ | `dwf_attribute_create` | 创建属性 |
334
+ | `dwf_attribute_bind` | 绑定属性到模型 |
335
+ | `dwf_object_list` | 列出对象 |
336
+ | `dwf_object_get` | 获取单个对象 |
337
+ | `dwf_object_create` | 创建对象 |
338
+ | `dwf_object_update` | 更新对象 |
339
+ | `dwf_object_delete` | 删除对象 |
340
+ | `dwf_object_count` | 统计对象数量 |
341
+ | `dwf_funcmodel_app_list` | 列出应用 |
342
+ | `dwf_funcmodel_operation_list` | 列出功能操作 |
343
+ | `dwf_formmodel_view_list` | 列出表单视图 |
344
+
345
+ ## License
346
+
347
+ Apache-2.0
@@ -0,0 +1,47 @@
1
+ dwf_cli/__init__.py,sha256=UAdh062wQFcGEMLvFCiqZpasYSDcJB3skX0rRTCfXVc,47
2
+ dwf_cli/__main__.py,sha256=gkYwh4gwBPoucIh514AytZHHVaGfqjn0S4GLS1e5_LQ,85
3
+ dwf_cli/api/__init__.py,sha256=a8AHEF8qoCCVNe-fOdgFP0ag5JN93gkDYJyKIPyJ11A,66
4
+ dwf_cli/api/auth.py,sha256=N4BBeG1YrYYGiYpS5Cfs7vZN3ihlM-08PixTr5KqiUE,1171
5
+ dwf_cli/api/client.py,sha256=Qh3cEyS5f6g5H8secxSvZ_3bCFkxslAf5h8WpTVoJdk,3441
6
+ dwf_cli/api/datamodel.py,sha256=a2KRAwPTJ-pP_gXkvMLO_LvHPmFnQf7bVXLKd6JZcnA,10713
7
+ dwf_cli/api/formmodel.py,sha256=Pp2SGluLrGHONWSPRg2WRF90KSm6WW6RWpx3P2VsKJM,4336
8
+ dwf_cli/api/funcmodel.py,sha256=E2muMWBQ2dNagZIiHciw-OmEBUpVoNL7bcM1IfJUT4E,13020
9
+ dwf_cli/cli/__init__.py,sha256=1y9lrc-uiy0elIRRSvwBzPR3FITpGxNfENDuFSchayQ,1905
10
+ dwf_cli/cli/_common.py,sha256=X3EH_TVlBpKrYV3S9VZl5i7id2B0ZGRX65Ah7PNp5Ns,3787
11
+ dwf_cli/cli/auth.py,sha256=0LsEDu5hsVMI3iqUUrPnrgWZAyzt6AT9LuyuNKrdnWc,5749
12
+ dwf_cli/cli/config.py,sha256=4BES0242YjZQ0c1Y2LUD8fpILp4vjT1SPppq03or-SU,6407
13
+ dwf_cli/cli/datamodel.py,sha256=rC-SOUSCE0xlpdLrR_PESSdgYlJl3idppvWgFX6AYP0,76519
14
+ dwf_cli/cli/formmodel.py,sha256=0vNLkc5qfZCH6kWzZa2bGSJhky-qscTYSh4dVPfF-sk,31642
15
+ dwf_cli/cli/funcmodel.py,sha256=VxcjQE9lLnXfj0PsKG4kAvWQ0Ot8QEeMujziNIPvOyU,70364
16
+ dwf_cli/cli/schema.py,sha256=SzpvYaeDgkzUr5nlxiZ9jvkLZI2mQTxJUb7QRDcYNt4,6332
17
+ dwf_cli/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ dwf_cli/core/config.py,sha256=pvCpmLjnlnJQOPAPl0XNjGPrZJ77lxK1U14JstpBg6A,5502
19
+ dwf_cli/core/crypto.py,sha256=QTVn2aiUC9UvNqUV-En1DY2set-sZbDboTzqJmDR7bw,804
20
+ dwf_cli/core/errors.py,sha256=KRUN4Q2nPaUMdJuc0GqwKOCWpX2v74b_q6uIvfFn3t4,1643
21
+ dwf_cli/core/output.py,sha256=UBaNoN3VCukCpz9lvUHUBU-aUbz6NoTodOp8nINOyuc,93
22
+ dwf_cli/core/validator.py,sha256=MbsPZaH0UYwEwjIXnVKx5iXAGVUgmKPjKFS0HIO3XtE,3822
23
+ dwf_cli/mcp/__init__.py,sha256=Tu0R5iU_ZW8i9XKkc8baqi0Vbtu6gjZUCPQaCenfOR8,54
24
+ dwf_cli/mcp/server.py,sha256=N2_0Vtp7DpU8EgHXj1IM64VSDdt6MhVCkRVtn3HtaKk,11550
25
+ dwf_cli/schemas/__init__.py,sha256=DgGtwPEoW1WI593u4Lt4Ile0yfWCvBmhe2tn52Qx10g,982
26
+ dwf_cli/schemas/datamodel/attribute_bind.schema.json,sha256=g-ATHDmi-KcYLU6pqb_6n5YE-9gSlSJEdoQhvuFncBQ,1702
27
+ dwf_cli/schemas/datamodel/attribute_create.schema.json,sha256=sTwxPQxpdQbDC1fDZKtiDIX8IJ9bCL_u3GBJzTjNAtk,1930
28
+ dwf_cli/schemas/datamodel/attribute_update.schema.json,sha256=XEEf-aUXZiqRuM8ccS6nkq7pl3U3-wvj_Mql6OPrZa4,1688
29
+ dwf_cli/schemas/datamodel/create.schema.json,sha256=458XsYV8zIAOqpt6o7-eh8U4YZZgDVdeXbM314Oi3YA,2743
30
+ dwf_cli/schemas/datamodel/excel_confirm.schema.json,sha256=h8sddJcfsfWRbmsFHlEZNVstAux2EgYdoTw5Sb_AoTs,3976
31
+ dwf_cli/schemas/datamodel/external_create.schema.json,sha256=CixPAeOZ5a-j6yPHH7X1CrSrBMHfvuJmAc_MIb2Uk24,2845
32
+ dwf_cli/schemas/datamodel/external_update.schema.json,sha256=vGrO3CdEmJgJhJSr93cuQS8qJhCV1jj1HpuWwJRRWOs,2858
33
+ dwf_cli/schemas/datamodel/object_create.schema.json,sha256=qRD6N99G7gt1JY1DQCCuH1RfS_gVjRQJ8qGdDbuwpvg,742
34
+ dwf_cli/schemas/datamodel/object_update.schema.json,sha256=rI4n0O6095DlCC0XYqfT-n4ruxWCseY0LCHwUN3kb5g,697
35
+ dwf_cli/schemas/datamodel/relation_create.schema.json,sha256=Ia8ym9e5OKBfZpS-2z7Zyyi_GiQTjKxEGJWJCmmswdM,3377
36
+ dwf_cli/schemas/datamodel/relation_update.schema.json,sha256=8bnT4HW4gVBM4Ml24UFmy9iGs6mNRyjrcXKE7AX8SWM,3127
37
+ dwf_cli/schemas/datamodel/update.schema.json,sha256=oeStlqhWkvwfcEAT1awcj6zLOr96qopiK5Et-U_Cx78,2250
38
+ dwf_cli/schemas/funcmodel/app_create.schema.json,sha256=noaxdKi13Xr1U4IJ9OGjKgkxOCEeGPCNWGd2zFyTQFY,9244
39
+ dwf_cli/schemas/funcmodel/app_update.schema.json,sha256=mT6qEaCTGIMjtTakDmhge1__AMwg0WvY-Tbpo-uKX7I,9066
40
+ dwf_cli/schemas/funcmodel/language-package_create.schema.json,sha256=QWGElvixG97-Uov1XieSmsGDoYSg6N_3nUN6aJ-WoG4,1239
41
+ dwf_cli/schemas/funcmodel/operations_create.schema.json,sha256=TFls3SJhxgqsmJ7w3shEZFN7H4OZZPBUkD7vmDr7P5k,8928
42
+ dwf_cli/schemas/funcmodel/operations_update.schema.json,sha256=y6GpekGWntFiL_mHKCsdfOoxL1P-OLc0MMA7nwRx23o,7879
43
+ dwf_platform_cli-0.2.0.dist-info/METADATA,sha256=E2Lm7hUuzbDwH924-LHXPCH3SVVlthufdG_mOJ3uIzI,11143
44
+ dwf_platform_cli-0.2.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
45
+ dwf_platform_cli-0.2.0.dist-info/entry_points.txt,sha256=hIgm82JXWtUmS1pFjix3kGI88tBMMWl18iEt6bc8ZFo,83
46
+ dwf_platform_cli-0.2.0.dist-info/licenses/LICENSE,sha256=pdH5MQWzhp8Cq-_PWUCWGwtnUu1a2QtHs3TP5AhSg74,10762
47
+ dwf_platform_cli-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ dwf-cli = dwf_cli:app
3
+ dwf-platform-mcp = dwf_cli.mcp.server:main