@dazitech/cli 3.1.0 → 3.1.1

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 (65) hide show
  1. package/README.md +1 -1
  2. package/dist/clis/dazi-app.js +2 -2
  3. package/dist/clis/dazi-flow.js +2 -2
  4. package/dist/clis/dazi-onto.js +318 -40
  5. package/dist/clis/dazi.js +407 -185
  6. package/dist/docs/flow/flow-project-guide.md +1 -1
  7. package/dist/docs/guides/cli-reference.md +16 -3
  8. package/dist/docs/guides/troubleshooting.md +1 -1
  9. package/dist/docs/index.json +1 -13
  10. package/dist/docs/onto/dazi_script_sdk_reference.md +1 -1
  11. package/dist/docs/onto/dazi_script_seed_data_guide.md +1 -1
  12. package/dist/docs/onto/function-guide.md +6 -6
  13. package/dist/docs/onto//346/234/254/344/275/223/345/210/206/347/261/273/350/247/204/345/210/222/344/270/216SDK/346/211/251/345/261/225/346/226/271/346/241/210.md +169 -169
  14. package/dist/docs/onto//346/234/254/344/275/223/345/221/275/345/220/215/350/247/204/350/214/203_/347/211/251/347/220/206/350/241/250Cube/344/270/216/345/257/271/350/261/241.md +3 -2
  15. package/dist/docs/onto//346/234/254/344/275/223/345/274/200/345/217/221/344/274/230/345/214/226/346/200/273/347/273/223.md +257 -242
  16. package/dist/docs/onto//346/234/254/344/275/223/350/204/232/346/234/254/347/274/226/345/206/231/346/214/207/345/215/227.md +12 -12
  17. package/dist/docs/onto//346/234/254/344/275/223/350/247/204/345/210/222/346/214/207/345/215/227.md +14 -13
  18. package/dist/docs/onto//350/204/232/346/234/254/350/277/220/350/241/214/345/270/270/350/247/201/351/224/231/350/257/257/345/244/204/347/220/206.md +70 -15
  19. package/dist/examples/index.json +222 -6
  20. package/dist/examples/onto/README.md +34 -36
  21. package/dist/examples/onto/_templates/onto_preflight.ps1 +84 -0
  22. package/dist/examples/onto/index.json +53 -0
  23. package/dist/examples/onto/index.yaml +29 -0
  24. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/README.md +23 -0
  25. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/save_test_arguments.ps1 +12 -11
  26. package/dist/{docs/onto → examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/plans}//350/247/204/345/210/222/347/244/272/344/276/213_/345/210/251/346/266/246/345/210/206/346/236/220/346/234/254/344/275/223/346/226/271/346/241/210.md +4 -4
  27. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_category_mount.py +1 -1
  28. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_ontology_init.py +1 -1
  29. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/README.md +24 -0
  30. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_availability_analysis.py +84 -0
  31. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_downtime_breakdown.py +119 -0
  32. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_energy_intensity.py +98 -0
  33. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_get_summary.py +125 -0
  34. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_maintenance_compliance.py +77 -0
  35. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_mom_analysis.py +118 -0
  36. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_oee_analysis.py +126 -0
  37. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_plan_vs_actual.py +105 -0
  38. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_top_fault_equipment.py +104 -0
  39. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_unit_comparison.py +120 -0
  40. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_yoy_analysis.py +115 -0
  41. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/save_test_arguments.ps1 +42 -0
  42. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.availability_analysis.json +7 -0
  43. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.downtime_breakdown.json +8 -0
  44. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.energy_intensity.json +8 -0
  45. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.get_summary.json +7 -0
  46. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.maintenance_compliance.json +7 -0
  47. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.mom_analysis.json +8 -0
  48. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.oee_analysis.json +8 -0
  49. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.plan_vs_actual.json +8 -0
  50. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.top_fault_equipment.json +8 -0
  51. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.unit_comparison.json +8 -0
  52. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.yoy_analysis.json +8 -0
  53. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/plans//345/214/226/345/267/245/350/256/276/345/244/207/350/277/220/350/220/245/345/210/206/346/236/220/346/234/254/344/275/223/346/226/271/346/241/210.md +735 -0
  54. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/setup/equip_ops_category_mount.py +106 -0
  55. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/setup/equip_ops_ontology_init.py +1077 -0
  56. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/setup/equip_ops_seed_data.py +552 -0
  57. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/README.md +23 -0
  58. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/save_test_arguments.ps1 +13 -12
  59. package/dist/{docs/onto → examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/plans}//350/247/204/345/210/222/347/244/272/344/276/213_/344/272/247/345/223/201/351/224/200/345/224/256/346/234/254/344/275/223/350/247/204/345/210/222/346/226/271/346/241/210.md +2 -2
  60. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_category_mount.py +1 -1
  61. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_ontology_init.py +1 -1
  62. package/dist/prompts/index.json +1 -1
  63. package/dist/prompts/onto/planning-design.md +226 -104
  64. package/dist/prompts/onto/script-publish-run.md +8 -6
  65. package/package.json +1 -1
@@ -86,7 +86,7 @@
86
86
 
87
87
  **字段表**建议列:`字段名 | 类型 | 显示名 | 说明`(原单列「说明」若混有 FK/PK 标记,拆到 **说明** 列;**显示名** 写面向用户的短标签)。
88
88
 
89
- init 脚本在 `setup/*_ontology_init.py` 顶部维护 `TABLE_REGISTRY`,与规划 **一一对应**。内置参考:`资源/examples/onto/利润示例`、`销售示例` init `资源/docs/onto/规划示例_*.md`;详见 [本体脚本编写指南 §表注册](./本体脚本编写指南.md#表注册-table_registry--register_with_meta)。
89
+ init 脚本在 `setup/*_ontology_init.py` 顶部维护 `TABLE_REGISTRY`,与规划 **一一对应**。内置完整示例位于 **`资源/examples/onto/<示例名>/`**(规划在 `plans/`,脚本在 `setup/`、`functions/`);索引见 `index.yaml` / `index.json`、总览见 `README.md`(`dazi examples sync`)。规划前可用 **`dazi examples onto suggest <关键词>`** 选对照示例。详见 [本体脚本编写指南 §表注册](./本体脚本编写指南.md#表注册-table_registry--register_with_meta)。
90
90
 
91
91
  ## 平台分类(平台分类对齐 · 强制)
92
92
 
@@ -114,7 +114,7 @@ init 脚本在 `setup/*_ontology_init.py` 顶部维护 `TABLE_REGISTRY`,与规
114
114
  | 链接 | — | 归属关系 / 分析归因 / 层级关系 / 对比关系 |
115
115
  | 函数 | — | 总览分析 / 趋势分析 / 结构分析 / 预实分析 / 组织分析 |
116
116
 
117
- 参考附录 B:[规划示例_产品销售](./规划示例_产品销售本体规划方案.md#附录-b平台-分类挂载对照表category_registry)、[规划示例_利润分析](./规划示例_利润分析本体方案.md#附录-b平台-分类挂载对照表category_registry)。
117
+ 参考附录 B:各示例 `plans/*.md` 附录 B,与同目录 `setup/*_category_mount.py` 一致。路径示例:`资源/examples/onto/销售示例/plans/…`、`利润示例/plans/…`、`设备运营/plans/…`。
118
118
 
119
119
  ## 规划文档标准结构(建议章节)
120
120
 
@@ -134,7 +134,7 @@ init 脚本在 `setup/*_ontology_init.py` 顶部维护 `TABLE_REGISTRY`,与规
134
134
  | **附录 B:平台分类挂载对照** | `CATEGORY_REGISTRY` 与 `*_category_mount.py` 一致 |
135
135
  | **附录:规划完整性自检清单** | 见本文 [§规划文档完整性自检清单](#规划文档完整性自检清单) |
136
136
 
137
- 参考全文结构:[规划示例_产品销售本体规划方案.md](./规划示例_产品销售本体规划方案.md)[规划示例_利润分析本体方案.md](./规划示例_利润分析本体方案.md)
137
+ 参考全文结构:`资源/examples/onto/` 下各示例的 `plans/*.md`(推荐 [销售示例 plans](../../examples/onto/销售示例/plans/规划示例_产品销售本体规划方案.md)[设备运营 plans](../../examples/onto/设备运营/plans/化工设备运营分析本体方案.md))。CLI:`dazi examples onto show sales --plan`。
138
138
 
139
139
  ## Cube 层设计(强制独立章节)
140
140
 
@@ -157,11 +157,10 @@ Cube 是 **表 → 分析语义 → 本体读模型** 的中间层。规划阶
157
157
 
158
158
  ## 必读文档
159
159
 
160
- 1. **本体规划示例(推荐)**:[`规划示例_产品销售本体规划方案.md`](./规划示例_产品销售本体规划方案.md)含表间关系、test_arguments 与完整脚本对照(`dazi docs sync` 后位于 `资源/docs/onto/`)
161
- 2. **本体命名规范**:[`本体命名规范_物理表Cube与对象.md`](./本体命名规范_物理表Cube与对象.md)(`onto/naming-conventions`)— 物理表前缀、`dim_date`、Cube 类别、对象 Palantir 式分类
162
- 3. **补充示例**:[`规划示例_利润分析本体方案.md`](./规划示例_利润分析本体方案.md) — 利润分析域参考
163
- 4. **工作区与 CLI**:`guides/workspace-v3.md`、`guides/cli-reference.md`(`dazi docs sync` 后位于 `资源/docs/guides/`)
164
- 5. **可运行脚本示例**:`资源/examples/onto/销售示例/`(推荐)、`资源/examples/onto/利润示例/`(`dazi examples sync` 或侧栏 **帮助 → 示例**)
160
+ 1. **内置本体示例(规划 + 脚本,至少读一个)**:`资源/examples/onto/` `dazi examples sync` 或侧栏 **帮助 → 示例**;索引 `index.json`(`dazi examples onto list`)、总览 `README.md`。每个子目录含 `plans/`、`setup/`、`functions/`,与业务 `ontos/<实现>/` 同构。
161
+ 2. **本体命名规范**:[`本体命名规范_物理表Cube与对象.md`](./本体命名规范_物理表Cube与对象.md)(`onto/naming-conventions`)
162
+ 3. **工作区与 CLI**:`guides/workspace-v3.md`、`guides/cli-reference.md`
163
+ 4. **规范指南(无案例正文)**:本文、[本体脚本编写指南](./本体脚本编写指南.md)、[脚本运行常见错误处理](./脚本运行常见错误处理.md)
165
164
 
166
165
  ## 产出约定
167
166
 
@@ -195,7 +194,8 @@ Cube 是 **表 → 分析语义 → 本体读模型** 的中间层。规划阶
195
194
  setup/ ← 初始化 / 灌数脚本
196
195
  functions/ ← 本体函数 / 动作脚本
197
196
  test_arguments/ ← 各 function_id 的 test_arguments JSON(与 .py 内 TEST_ARGUMENTS 同步)
198
- 资源/docs/onto/ ← 本体指南与规划示例(dazi docs sync
197
+ 资源/docs/onto/ ← 规范指南(规划示例正文已迁至 examples/onto
198
+ 资源/examples/onto/ ← ★ 完整本体示例(plans + setup + functions)
199
199
  资源/dataspaces/ ← 侧栏下载的表结构 Markdown
200
200
  ```
201
201
 
@@ -212,6 +212,9 @@ Cube 是 **表 → 分析语义 → 本体读模型** 的中间层。规划阶
212
212
  dazi doctor
213
213
  dazi auth whoami
214
214
  dazi docs sync # 可选:同步帮助文档到 资源/docs/
215
+ dazi examples sync # 同步完整示例到 资源/examples/
216
+ dazi examples onto suggest 销售 # 按关键词推荐对照示例(可选)
217
+ dazi examples onto show sales --plan # 输出规划全文(可选)
215
218
  ```
216
219
 
217
220
  **核对数据空间与现网资产**(`<space_id>` 取自当前实现单元的 `README.md`,勿另猜目录):
@@ -232,7 +235,7 @@ dazi onto space get <space_id> # 可选:查看空间详情
232
235
 
233
236
  > 规划阶段**不**要求本地 `snapshot.json`、`editorial/` 或 `onto/<space_id>/` 目录;以侧栏 **数据资源** 与项目内文档为准即可。
234
237
 
235
- 规划阶段 **只产出 Markdown**:写入 **`项目/<业务名>/本体/ontos/<实现名>/plans/<主题>.md`**,**首选参考** [`规划示例_产品销售本体规划方案.md`](./规划示例_产品销售本体规划方案.md)。此阶段不发布脚本。
238
+ 规划阶段 **只产出 Markdown**:写入 **`项目/<业务名>/本体/ontos/<实现名>/plans/<主题>.md`**。**须至少阅读一个** `资源/examples/onto/<示例>/` 的 `README.md` + `plans/*.md` 学结构(`dazi examples onto suggest <关键词>` 或见 `index.json` 域路由)。此阶段不发布脚本。
236
239
 
237
240
  **定稿门槛**:对照 [§规划文档完整性自检清单](#规划文档完整性自检清单),**尤其第 4 项 Cube 层**;未通过不得进入脚本实施。
238
241
 
@@ -297,8 +300,6 @@ dazi onto function run <function_id> --space <space_id> --params '{}'
297
300
  ## 相关文档
298
301
 
299
302
  - [本体脚本编写指南](./本体脚本编写指南.md)
300
- - [本体规划指南](./本体规划指南.md)
301
- - [规划示例:产品销售本体(推荐)](./规划示例_产品销售本体规划方案.md)
302
- - [规划示例:利润分析本体(补充)](./规划示例_利润分析本体方案.md)
303
+ - [内置示例总览](../../examples/onto/README.md)(`资源/examples/onto/`)
303
304
  - [本体分类规划与 SDK 扩展方案](./本体分类规划与SDK扩展方案.md)
304
305
  - [脚本运行常见错误处理](./脚本运行常见错误处理.md)
@@ -19,9 +19,43 @@
19
19
  | `bind_source(source_type=..., source_name=...)` | `bind_source(obj_code, "dazi_cube", config={"cube": "CubeName"})` | 见利润/销售示例 |
20
20
  | `define_property(object_type_code=..., title=...)` | `define_property(obj_code, code, name, ...)` | 位置参数 |
21
21
  | `define_link_type(title=..., from_object_type=...)` | `define_link_type(name=..., from_object_type_code=..., to_object_type_code=...)` | 以 `_code` 结尾 |
22
+ | **Reference 对象无 Cube 仍 define_property** | 参考型对象不 `bind_source` 则**禁止** `define_property` | 见 §1.1 |
22
23
 
23
24
  **教训**:对照 `资源/examples/onto/利润示例`、`销售示例` 的 init,勿猜 API。
24
25
 
26
+ ### 1.1 无 Cube 绑定的对象禁止 define_property
27
+
28
+ | 对象分类(347) | bind_source | define_property |
29
+ | --------------- | ----------- | --------------- |
30
+ | 主数据 / 事务 / 分析 | **必须**绑定 Cube | ✅ 可定义属性 |
31
+ | 参考 / 配置(无 Cube) | 无 | ❌ **禁止** — 会报「对象类型未绑定任何 DaziCube」 |
32
+
33
+ 规划阶段:Reference/Master 无 Cube 时,属性章节须标注「跳过或需补 Cube + bind_source」。
34
+
35
+ ### 1.2 本域首次 init 检查表(5 条)
36
+
37
+ init `script run` 前逐项确认:
38
+
39
+ | # | 检查项 | 通过标准 |
40
+ | --- | ------ | -------- |
41
+ | 1 | **dim_date** | 共用空间时确认已存在,或 init 含幂等 `ensure_dim_date` |
42
+ | 2 | **bind_source** | 每个需读模型的分析/主数据/事务对象已绑定 Cube |
43
+ | 3 | **define_property** | 无 Cube 的参考对象未调用 define_property |
44
+ | 4 | **function_result** | 函数模板使用 `columns=`/`data=` kwargs,非 dict positional |
45
+ | 5 | **relationship_count** | init 日志关系数与 plans §表间关系一致 |
46
+ | 6 | **init 不含 apply_registry** | 分类在 `*_category_mount.py`;init 只做表/Cube/对象/链接 |
47
+
48
+ ### 1.3 init 与 category_mount 职责分离
49
+
50
+ | 脚本 | 职责 | 时机 |
51
+ | ---- | ---- | ---- |
52
+ | `*_ontology_init.py` | 建表、register_with_meta、关系、Cube、对象/链接、sync_metric_refs | init → seed 之前 |
53
+ | `*_category_mount.py` | `CATEGORY_REGISTRY` + `apply_registry` | **最后**(全部函数 publish 后) |
54
+
55
+ **禁止**:在 init 内调用 `s.categories.apply_registry`(函数未 publish 时 function 段会被 skip;重跑 init 成本高)。
56
+
57
+ `dazi onto script publish-preview` 对 `*init*.py` 会报错 `[init-no-apply-registry]`。
58
+
25
59
  ---
26
60
 
27
61
  ## 2. SQL 聚合:`query_one` 返回类型
@@ -71,26 +105,36 @@ def main():
71
105
 
72
106
  ## 4. CLI 参数误用
73
107
 
74
- ### 4.1 `function run` 不支持 `--arguments-json-file`
108
+ ### 4.1 `function run` 与默认参数
109
+
110
+ **推荐顺序**:`publish` → `function run`(验证)→ `save-test-arguments`(侧栏预填)。
111
+
112
+ 未传 `--params` 或 `--params '{}'` 时,CLI **自动回退**:
113
+
114
+ 1. 已保存的 `test_arguments.arguments`
115
+ 2. 否则脚本内 `TEST_ARGUMENTS.arguments`
75
116
 
76
117
  ```powershell
77
- # 错误
78
- dazi onto function run <function_id> --space <空间> --arguments-json-file xxx.json
118
+ # 首次 run(无 save-test-arguments 也可,回退脚本内 TEST_ARGUMENTS)
119
+ dazi onto function run sales.fn.yoy_analysis --space <空间>
79
120
 
80
- # 正确:先 save-test-arguments,再 run(不带 JSON 文件)
81
- dazi onto function run <function_id> --space <空间>
121
+ # 显式传参
122
+ dazi onto function run sales.fn.yoy_analysis --space <空间> --params '{"start_date":"2025-01-01","end_date":"2025-12-31"}'
82
123
  ```
83
124
 
84
- ### 4.2 `save-test-arguments` 须用 `ofn_xxx` 内部 ID
125
+ **不支持** `--arguments-json-file`(勿与 save-test-arguments 混淆)。
126
+
127
+ ### 4.2 `save-test-arguments`:ofn_xxx 或 --function-id
85
128
 
86
129
  ```powershell
87
- # 错误 function_id 字符串
88
- dazi onto function save-test-arguments profit.fn.get_summary --space <空间> ...
130
+ # 推荐:function_id 别名(无需查 ofn_xxx)
131
+ dazi onto function save-test-arguments --function-id profit.fn.get_summary --space <空间> `
132
+ --arguments-json-file <项目路径>/functions/test_arguments/profit.fn.get_summary.json
89
133
 
90
- # 正确 — list 返回的 id 字段
91
- dazi onto function list --space <空间>
134
+ # 或使用平台内部 id
135
+ dazi onto function list --space <空间> --json # 含 save_command 字段
92
136
  dazi onto function save-test-arguments ofn_xxxxxxxx --space <空间> `
93
- --arguments-json-file <项目路径>/functions/test_arguments/<function_id>.json
137
+ --arguments-json-file <项目路径>/functions/test_arguments/profit.fn.get_summary.json
94
138
  ```
95
139
 
96
140
  ### 4.3 函数发布未带 `--register-function-id`
@@ -117,7 +161,18 @@ dazi onto function list --space <空间> # 必须能看到该 id
117
161
 
118
162
  **结论**:init **不负责**注册本体函数;每个 `functions/*.py` 须单独 publish 并注册。
119
163
 
120
- **门禁**:规划函数数 = `functions/*.py` 数 = `function list` 条数。
164
+ **门禁**:规划函数数 = `functions/*.py` 数 = `function list` 条数。可运行 `functions/onto_preflight.ps1`(见 `资源/examples/onto/_templates/`)自动核对。
165
+
166
+ ## 5.1 本体函数 publish-preview 静态预检
167
+
168
+ `dazi onto script publish-preview` / `script publish`(本体函数)会在本地检查:
169
+
170
+ | 级别 | 规则 |
171
+ | ---- | ---- |
172
+ | error | 禁止 `output.print_json`;须 `def main():`;须 `function_result(columns=...)` kwargs |
173
+ | warn | 缺少 `TEST_ARGUMENTS`;`params.get("start_date", "")` 空串默认 |
174
+
175
+ 有 **error** 时预检失败,须修复后再 publish。
121
176
 
122
177
  ---
123
178
 
@@ -225,9 +280,9 @@ dazi onto function run <function_id> --space <空间>
225
280
  | 发布 data | `dazi onto script publish <path> --space <空间> --type data` |
226
281
  | 发布并注册函数 | `... --register-function-id <id> [--register-platform-category <分类>]` |
227
282
  | 执行脚本 | `dazi onto script run --file <path> --space <空间>` |
228
- | 运行函数 | `dazi onto function run <function_id> --space <空间>` |
229
- | 函数列表 | `dazi onto function list --space <空间>` |
230
- | 保存默认参数 | `dazi onto function save-test-arguments <ofn_id> --space <空间> --arguments-json-file <json>` |
283
+ | 运行函数 | `dazi onto function run <function_id> --space <空间>`(无参时回退 TEST_ARGUMENTS) |
284
+ | 函数列表 | `dazi onto function list --space <空间> [--json]` |
285
+ | 保存默认参数 | `dazi onto function save-test-arguments --function-id <id> --space <空间> --arguments-json-file <json>` |
231
286
 
232
287
  ---
233
288
 
@@ -1,18 +1,222 @@
1
1
  {
2
- "version": "3.1.0",
3
- "updatedAt": "2026-06-05T18:00:00.000Z",
2
+ "version": "3.1.1",
3
+ "updatedAt": "2026-06-07T12:00:00.000Z",
4
4
  "examples": [
5
5
  {
6
6
  "id": "onto/readme",
7
- "title": "Onto 示例总览(利润 + 销售)",
7
+ "title": "Onto 内置示例总览(销售 + 利润 + 设备运营)",
8
8
  "category": "onto",
9
9
  "file": "onto/README.md"
10
10
  },
11
11
  {
12
- "id": "onto/template/ontology-function",
13
- "title": "本体函数脚本模板(标准 main + function_result)",
12
+ "id": "onto/template/onto-preflight",
13
+ "title": "Onto 函数 publish 门禁脚本模板",
14
14
  "category": "onto-模板",
15
- "file": "onto/_templates/ontology_function_template.py"
15
+ "file": "onto/_templates/onto_preflight.ps1"
16
+ },
17
+ {
18
+ "id": "onto/index",
19
+ "title": "Onto 示例索引(index.yaml)",
20
+ "category": "onto",
21
+ "file": "onto/index.yaml"
22
+ },
23
+ {
24
+ "id": "onto/index-json",
25
+ "title": "Onto 示例索引(index.json,CLI 机器可读)",
26
+ "category": "onto",
27
+ "file": "onto/index.json"
28
+ },
29
+ {
30
+ "id": "onto/sales/readme",
31
+ "title": "销售示例 · 总览",
32
+ "category": "onto-销售",
33
+ "file": "onto/销售示例/README.md"
34
+ },
35
+ {
36
+ "id": "onto/sales/plan",
37
+ "title": "销售示例 · 规划正文",
38
+ "category": "onto-销售",
39
+ "file": "onto/销售示例/plans/规划示例_产品销售本体规划方案.md"
40
+ },
41
+ {
42
+ "id": "onto/profit/readme",
43
+ "title": "利润示例 · 总览",
44
+ "category": "onto-利润",
45
+ "file": "onto/利润示例/README.md"
46
+ },
47
+ {
48
+ "id": "onto/profit/plan",
49
+ "title": "利润示例 · 规划正文",
50
+ "category": "onto-利润",
51
+ "file": "onto/利润示例/plans/规划示例_利润分析本体方案.md"
52
+ },
53
+ {
54
+ "id": "onto/equip-ops/readme",
55
+ "title": "设备运营 · 总览",
56
+ "category": "onto-设备运营",
57
+ "file": "onto/设备运营/README.md"
58
+ },
59
+ {
60
+ "id": "onto/equip-ops/plan",
61
+ "title": "设备运营 · 规划正文",
62
+ "category": "onto-设备运营",
63
+ "file": "onto/设备运营/plans/化工设备运营分析本体方案.md"
64
+ },
65
+ {
66
+ "id": "onto/equip-ops/setup/ontology-init",
67
+ "title": "设备运营 · 本体初始化",
68
+ "category": "onto-设备运营-初始化",
69
+ "file": "onto/设备运营/setup/equip_ops_ontology_init.py"
70
+ },
71
+ {
72
+ "id": "onto/equip-ops/setup/seed-data",
73
+ "title": "设备运营 · 演示灌数",
74
+ "category": "onto-设备运营-初始化",
75
+ "file": "onto/设备运营/setup/equip_ops_seed_data.py"
76
+ },
77
+ {
78
+ "id": "onto/equip-ops/setup/category-mount",
79
+ "title": "设备运营 · 平台分类挂载",
80
+ "category": "onto-设备运营-初始化",
81
+ "file": "onto/设备运营/setup/equip_ops_category_mount.py"
82
+ },
83
+ {
84
+ "id": "onto/equip-ops/function/get-summary",
85
+ "title": "设备运营 · 运营总览",
86
+ "category": "onto-设备运营-函数",
87
+ "file": "onto/设备运营/functions/equip_ops_fn_get_summary.py"
88
+ },
89
+ {
90
+ "id": "onto/equip-ops/function/oee",
91
+ "title": "设备运营 · OEE 分析",
92
+ "category": "onto-设备运营-函数",
93
+ "file": "onto/设备运营/functions/equip_ops_fn_oee_analysis.py"
94
+ },
95
+ {
96
+ "id": "onto/equip-ops/function/availability",
97
+ "title": "设备运营 · 可用率分析",
98
+ "category": "onto-设备运营-函数",
99
+ "file": "onto/设备运营/functions/equip_ops_fn_availability_analysis.py"
100
+ },
101
+ {
102
+ "id": "onto/equip-ops/function/downtime-breakdown",
103
+ "title": "设备运营 · 停机分解",
104
+ "category": "onto-设备运营-函数",
105
+ "file": "onto/设备运营/functions/equip_ops_fn_downtime_breakdown.py"
106
+ },
107
+ {
108
+ "id": "onto/equip-ops/function/maintenance-compliance",
109
+ "title": "设备运营 · 维保合规",
110
+ "category": "onto-设备运营-函数",
111
+ "file": "onto/设备运营/functions/equip_ops_fn_maintenance_compliance.py"
112
+ },
113
+ {
114
+ "id": "onto/equip-ops/function/energy-intensity",
115
+ "title": "设备运营 · 能耗强度",
116
+ "category": "onto-设备运营-函数",
117
+ "file": "onto/设备运营/functions/equip_ops_fn_energy_intensity.py"
118
+ },
119
+ {
120
+ "id": "onto/equip-ops/function/plan-vs-actual",
121
+ "title": "设备运营 · 计划 vs 实际",
122
+ "category": "onto-设备运营-函数",
123
+ "file": "onto/设备运营/functions/equip_ops_fn_plan_vs_actual.py"
124
+ },
125
+ {
126
+ "id": "onto/equip-ops/function/unit-comparison",
127
+ "title": "设备运营 · 装置对比",
128
+ "category": "onto-设备运营-函数",
129
+ "file": "onto/设备运营/functions/equip_ops_fn_unit_comparison.py"
130
+ },
131
+ {
132
+ "id": "onto/equip-ops/function/top-fault-equipment",
133
+ "title": "设备运营 · 故障设备 Top N",
134
+ "category": "onto-设备运营-函数",
135
+ "file": "onto/设备运营/functions/equip_ops_fn_top_fault_equipment.py"
136
+ },
137
+ {
138
+ "id": "onto/equip-ops/function/yoy",
139
+ "title": "设备运营 · 同比 (YoY)",
140
+ "category": "onto-设备运营-函数",
141
+ "file": "onto/设备运营/functions/equip_ops_fn_yoy_analysis.py"
142
+ },
143
+ {
144
+ "id": "onto/equip-ops/function/mom",
145
+ "title": "设备运营 · 环比 (MoM)",
146
+ "category": "onto-设备运营-函数",
147
+ "file": "onto/设备运营/functions/equip_ops_fn_mom_analysis.py"
148
+ },
149
+ {
150
+ "id": "onto/equip-ops/function/save-test-arguments",
151
+ "title": "设备运营 · 批量保存 test_arguments",
152
+ "category": "onto-设备运营-工具",
153
+ "file": "onto/设备运营/functions/save_test_arguments.ps1"
154
+ },
155
+ {
156
+ "id": "onto/equip-ops/test-args/get-summary",
157
+ "title": "test_arguments · equip_ops.fn.get_summary",
158
+ "category": "onto-设备运营-测试参数",
159
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.get_summary.json"
160
+ },
161
+ {
162
+ "id": "onto/equip-ops/test-args/oee",
163
+ "title": "test_arguments · equip_ops.fn.oee_analysis",
164
+ "category": "onto-设备运营-测试参数",
165
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.oee_analysis.json"
166
+ },
167
+ {
168
+ "id": "onto/equip-ops/test-args/availability",
169
+ "title": "test_arguments · equip_ops.fn.availability_analysis",
170
+ "category": "onto-设备运营-测试参数",
171
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.availability_analysis.json"
172
+ },
173
+ {
174
+ "id": "onto/equip-ops/test-args/downtime-breakdown",
175
+ "title": "test_arguments · equip_ops.fn.downtime_breakdown",
176
+ "category": "onto-设备运营-测试参数",
177
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.downtime_breakdown.json"
178
+ },
179
+ {
180
+ "id": "onto/equip-ops/test-args/maintenance-compliance",
181
+ "title": "test_arguments · equip_ops.fn.maintenance_compliance",
182
+ "category": "onto-设备运营-测试参数",
183
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.maintenance_compliance.json"
184
+ },
185
+ {
186
+ "id": "onto/equip-ops/test-args/energy-intensity",
187
+ "title": "test_arguments · equip_ops.fn.energy_intensity",
188
+ "category": "onto-设备运营-测试参数",
189
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.energy_intensity.json"
190
+ },
191
+ {
192
+ "id": "onto/equip-ops/test-args/plan-vs-actual",
193
+ "title": "test_arguments · equip_ops.fn.plan_vs_actual",
194
+ "category": "onto-设备运营-测试参数",
195
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.plan_vs_actual.json"
196
+ },
197
+ {
198
+ "id": "onto/equip-ops/test-args/unit-comparison",
199
+ "title": "test_arguments · equip_ops.fn.unit_comparison",
200
+ "category": "onto-设备运营-测试参数",
201
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.unit_comparison.json"
202
+ },
203
+ {
204
+ "id": "onto/equip-ops/test-args/top-fault-equipment",
205
+ "title": "test_arguments · equip_ops.fn.top_fault_equipment",
206
+ "category": "onto-设备运营-测试参数",
207
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.top_fault_equipment.json"
208
+ },
209
+ {
210
+ "id": "onto/equip-ops/test-args/yoy",
211
+ "title": "test_arguments · equip_ops.fn.yoy_analysis",
212
+ "category": "onto-设备运营-测试参数",
213
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.yoy_analysis.json"
214
+ },
215
+ {
216
+ "id": "onto/equip-ops/test-args/mom",
217
+ "title": "test_arguments · equip_ops.fn.mom_analysis",
218
+ "category": "onto-设备运营-测试参数",
219
+ "file": "onto/设备运营/functions/test_arguments/equip_ops.fn.mom_analysis.json"
16
220
  },
17
221
  {
18
222
  "id": "onto/profit/setup/ontology-init",
@@ -26,6 +230,12 @@
26
230
  "category": "onto-利润-初始化",
27
231
  "file": "onto/利润示例/setup/profit_seed_data.py"
28
232
  },
233
+ {
234
+ "id": "onto/profit/setup/category-mount",
235
+ "title": "利润分析 · 平台分类挂载",
236
+ "category": "onto-利润-初始化",
237
+ "file": "onto/利润示例/setup/profit_category_mount.py"
238
+ },
29
239
  {
30
240
  "id": "onto/profit/function/get-summary",
31
241
  "title": "利润分析 · 利润总览",
@@ -128,6 +338,12 @@
128
338
  "category": "onto-销售-初始化",
129
339
  "file": "onto/销售示例/setup/sales_seed_data.py"
130
340
  },
341
+ {
342
+ "id": "onto/sales/setup/category-mount",
343
+ "title": "产品销售 · 平台分类挂载",
344
+ "category": "onto-销售-初始化",
345
+ "file": "onto/销售示例/setup/sales_category_mount.py"
346
+ },
131
347
  {
132
348
  "id": "onto/sales/function/get-summary",
133
349
  "title": "产品销售 · 销售概览",
@@ -1,51 +1,49 @@
1
1
  # Onto 内置示例
2
2
 
3
- `dazi examples sync` 后位于 **`资源/examples/onto/`**。复制到业务项目的 **`项目/<业务名>/本体/ontos/<实现名>/`** 对应子目录后再改 `space_id` 与业务字段。
3
+ `dazi examples sync` 后位于 **`资源/examples/onto/`**。每个子目录是**完整本体单元**(与业务 `ontos/<实现>/` 同构):
4
4
 
5
- ## 利润示例(`利润示例/`)
5
+ ```text
6
+ <示例名>/
7
+ ├── README.md
8
+ ├── plans/ ← ★ 规划正文(真理源)
9
+ ├── setup/ ← init、seed、category_mount
10
+ └── functions/ ← 本体函数 + test_arguments
11
+ ```
12
+
13
+ **规划 / 脚本前**:须至少阅读 **一个** 示例的 `README.md` + `plans/*.md`。索引见 **`index.yaml`** / **`index.json`**(`dazi examples onto list`)。
6
14
 
7
- | 路径 | 说明 | 规划文档 |
8
- |------|------|----------|
9
- | `setup/profit_ontology_init.py` | GL 域 init(科目/分录/预算表、Cube、对象、链接) | [规划示例_利润分析本体方案](../../docs/onto/规划示例_利润分析本体方案.md) |
10
- | `setup/profit_seed_data.py` | 演示灌数(科目树、成本中心、实际分录、预算) | 同上 |
11
- | `functions/profit_fn_*.py` | 7 个 GL 分析函数(总览/同比/环比/预实/科目/组织/Top 科目) | 同上 |
12
- | `functions/test_arguments/*.json` | 各 `profit.fn.*` 默认测试入参 | 规划 §6.5 |
13
- | `functions/save_test_arguments.ps1` | 批量写入平台 `test_arguments` | 发布函数后执行 |
15
+ ## 示例一览
14
16
 
15
- 发布后须 **`function run` 验证** **`save-test-arguments`** 写入默认测试入参(见规划 §6.5)。
17
+ | 目录 | | 规划(plans/) | 函数数 |
18
+ |------|-----|----------------|--------|
19
+ | [销售示例](./销售示例/) | 销售、订单、渠道 | `规划示例_产品销售本体规划方案.md` | 7 |
20
+ | [利润示例](./利润示例/) | GL、科目、预实 | `规划示例_利润分析本体方案.md` | 7 |
21
+ | [设备运营](./设备运营/) | 设备、OEE、停机 | `化工设备运营分析本体方案.md` | 11 |
16
22
 
17
- 推荐空间:`space__zlj`(以你的实现单元 README 为准)。
23
+ > 规划正文仅在 `examples/onto/<示例>/plans/`;`dazi examples onto show <id> --plan`。
18
24
 
19
- ## 销售示例(`销售示例/`)
25
+ ## 复制到业务项目
20
26
 
21
- | 路径 | 说明 | 规划文档 |
22
- |------|------|----------|
23
- | `setup/sales_ontology_init.py` | 产品销售 init(表间关系 + Cube + 本体) | [规划示例_产品销售本体规划方案](../../docs/onto/规划示例_产品销售本体规划方案.md) |
24
- | `setup/sales_seed_data.py` | 演示灌数(产品/销售/维表) | 同上 |
25
- | `functions/sales_fn_*.py` | 7 个销售分析函数 | 同上 |
26
- | `functions/test_arguments/*.json` | 各 `function_id` 默认测试入参 | 与规划 §函数清单一致 |
27
- | `functions/save_test_arguments.ps1` | 批量写入平台 `test_arguments` | 发布函数后执行 |
27
+ ```text
28
+ 资源/examples/onto/<示例>/setup/* → 项目/<业务>/本体/ontos/<实现>/setup/
29
+ 资源/examples/onto/<示例>/functions/* → 项目/<业务>/本体/ontos/<实现>/functions/
30
+ ```
28
31
 
29
- 推荐空间:`space__zlj`(以你的实现单元 README 为准)。
32
+ 规划须在本项目 **`plans/` 独立撰写**;示例 `plans/` 仅供只读对照(见快速启动 §0)。
30
33
 
31
- ## 模板(`_templates/`)
34
+ ## 模板与工具
32
35
 
33
36
  | 路径 | 说明 |
34
37
  |------|------|
35
- | `_templates/ontology_function_template.py` | **新建本体函数时复制此文件**;`main()` `return _ontology_fn_body(p)`,禁止 `output.print_json()` |
36
-
37
- `dazi examples show onto/template/ontology-function`
38
-
39
- ## 复制示例
40
-
41
- ```text
42
- 资源/examples/onto/利润示例/setup/*.py → 项目/<业务>/本体/ontos/<实现>/setup/
43
- 资源/examples/onto/利润示例/functions/*.py → 项目/<业务>/本体/ontos/<实现>/functions/
44
- 资源/examples/onto/利润示例/functions/test_arguments/ → .../functions/test_arguments/
45
-
46
- 资源/examples/onto/销售示例/setup/*.py → 项目/<业务>/本体/ontos/<实现>/setup/
47
- 资源/examples/onto/销售示例/functions/*.py → 项目/<业务>/本体/ontos/<实现>/functions/
48
- 资源/examples/onto/销售示例/functions/test_arguments/ → .../functions/test_arguments/
38
+ | [_templates/ontology_function_template.py](./_templates/ontology_function_template.py) | 新建函数结构模板 |
39
+ | [_templates/onto_preflight.ps1](./_templates/onto_preflight.ps1) | 函数数 / publish-preview 门禁 |
40
+
41
+ ```powershell
42
+ dazi examples onto list
43
+ dazi examples onto suggest 设备 OEE
44
+ dazi examples onto show equip-ops --plan
45
+ dazi examples list --category onto
46
+ dazi examples show onto/readme
49
47
  ```
50
48
 
51
- 侧栏 **帮助 → 示例** 可按分类浏览;`dazi examples list --category onto-利润-函数` 可过滤。
49
+ 侧栏 **帮助 → 示例** 可按 `onto-销售-函数`、`onto-设备运营-函数` 等分类浏览。
@@ -0,0 +1,84 @@
1
+ # onto_preflight.ps1 — 本体实施门禁(规划 ↔ 函数文件 ↔ 平台注册)
2
+ # 用法(在 dazi-work 根目录):
3
+ # .\项目\<业务>\本体\ontos\<实现>\functions\onto_preflight.ps1
4
+ # 或复制到 functions/ 后修改下方 $spaceId、$itemRel
5
+
6
+ param(
7
+ [string]$SpaceId = "space__misc_01",
8
+ [string]$ItemRel = "项目/DAZI_TEST/本体/ontos/销售本体示例"
9
+ )
10
+
11
+ $ErrorActionPreference = "Stop"
12
+ $functionsDir = Join-Path $PSScriptRoot "."
13
+ $plansDir = Join-Path (Split-Path $PSScriptRoot -Parent) "plans"
14
+
15
+ Write-Host "=== 本体 preflight ===" -ForegroundColor Cyan
16
+ Write-Host "空间: $SpaceId"
17
+ Write-Host "实现: $ItemRel"
18
+
19
+ $exitCode = 0
20
+
21
+ # 1. functions/*.py 数量
22
+ $pyFiles = @(Get-ChildItem -Path $functionsDir -Filter "*.py" -File | Where-Object { $_.Name -notmatch "^_" })
23
+ $pyCount = $pyFiles.Count
24
+ Write-Host "`n[1] functions/*.py 数量: $pyCount"
25
+
26
+ # 2. 平台 function list
27
+ Write-Host "[2] 拉取 function list ..."
28
+ $fnListRaw = & dazi onto function list --space $SpaceId --json 2>&1
29
+ if ($LASTEXITCODE -ne 0) {
30
+ Write-Host " ✗ function list 失败" -ForegroundColor Red
31
+ exit 1
32
+ }
33
+ # 去掉 __JSON_SUMMARY__ 行后解析
34
+ $jsonLines = ($fnListRaw | Where-Object { $_ -notmatch '__JSON_SUMMARY__' }) -join "`n"
35
+ $fnList = $jsonLines | ConvertFrom-Json
36
+ $listCount = @($fnList).Count
37
+ Write-Host " 平台已注册: $listCount"
38
+
39
+ if ($pyCount -ne $listCount) {
40
+ Write-Host " ✗ 文件数 ($pyCount) ≠ 平台注册数 ($listCount)" -ForegroundColor Red
41
+ $exitCode = 1
42
+ } else {
43
+ Write-Host " ✓ 文件数与平台注册数一致" -ForegroundColor Green
44
+ }
45
+
46
+ # 3. 规划函数表行数(粗略:plans/*.md 中含 .fn. 的行)
47
+ $planFnCount = 0
48
+ if (Test-Path $plansDir) {
49
+ $planFiles = Get-ChildItem -Path $plansDir -Filter "*.md" -File
50
+ foreach ($pf in $planFiles) {
51
+ $content = Get-Content $pf.FullName -Raw -Encoding UTF8
52
+ $matches = [regex]::Matches($content, '\w+\.fn\.\w+')
53
+ $planFnCount += $matches.Count
54
+ }
55
+ }
56
+ if ($planFnCount -gt 0) {
57
+ Write-Host "`n[3] plans 中 .fn. 引用约: $planFnCount"
58
+ if ($planFnCount -ne $pyCount) {
59
+ Write-Host " ⚠ 规划引用数 ($planFnCount) ≠ functions/*.py ($pyCount)" -ForegroundColor Yellow
60
+ } else {
61
+ Write-Host " ✓ 与 functions/*.py 数量一致" -ForegroundColor Green
62
+ }
63
+ } else {
64
+ Write-Host "`n[3] 跳过 plans 计数(无 plans/*.md 或未找到 .fn.)" -ForegroundColor Yellow
65
+ }
66
+
67
+ # 4. 本地 publish-preview 静态预检(每个函数)
68
+ Write-Host "`n[4] 本体函数 publish-preview 静态预检 ..."
69
+ foreach ($py in $pyFiles) {
70
+ $rel = "$ItemRel/functions/$($py.Name)"
71
+ Write-Host " → $($py.Name)"
72
+ & dazi onto script publish-preview $rel --space $SpaceId 2>&1 | Out-Host
73
+ if ($LASTEXITCODE -ne 0) {
74
+ Write-Host " ✗ $($py.Name) 预检失败" -ForegroundColor Red
75
+ $exitCode = 1
76
+ }
77
+ }
78
+
79
+ if ($exitCode -eq 0) {
80
+ Write-Host "`n=== preflight 通过 ===" -ForegroundColor Green
81
+ } else {
82
+ Write-Host "`n=== preflight 未通过 ===" -ForegroundColor Red
83
+ }
84
+ exit $exitCode