@dazitech/cli 3.0.9 → 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 (67) 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 +324 -41
  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 +3 -3
  9. package/dist/docs/index.json +3 -15
  10. package/dist/docs/onto/dazi_script_sdk_reference.md +246 -244
  11. package/dist/docs/onto/dazi_script_seed_data_guide.md +1 -1
  12. package/dist/docs/onto/function-guide.md +123 -123
  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 -168
  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 +403 -402
  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 -0
  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 +339 -311
  17. package/dist/docs/onto//346/234/254/344/275/223/350/247/204/345/210/222/346/214/207/345/215/227.md +305 -281
  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 +297 -0
  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 +37 -35
  27. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_category_mount.py +85 -0
  28. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_ontology_init.py +3 -66
  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 +34 -34
  60. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_category_mount.py +82 -0
  61. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_ontology_init.py +3 -54
  62. package/dist/prompts/index.json +8 -1
  63. package/dist/prompts/onto/function-design.md +73 -73
  64. package/dist/prompts/onto/planning-design.md +226 -0
  65. package/dist/prompts/onto/script-publish-run.md +231 -208
  66. package/package.json +1 -1
  67. package/dist/docs/onto//350/204/232/346/234/254/350/277/220/350/241/214/347/272/240/351/224/231_/345/225/206/345/212/241/346/210/220/346/234/254/346/226/271/346/241/210/345/274/200/345/217/221/350/277/207/347/250/213.md +0 -213
@@ -2,8 +2,10 @@
2
2
 
3
3
  **文档 ID**: `onto/planning-example-product-sales`
4
4
 
5
- > **推荐**:本体规划阶段**首选参考示例**。覆盖物理表、**表间关系**、Cube、本体链接、函数与 **test_arguments** 完整落地;表/Cube/对象命名遵循 [本体命名规范](./本体命名规范_物理表Cube与对象.md)
6
- > 补充示例(利润分析域):[规划示例_利润分析本体方案.md](./规划示例_利润分析本体方案.md)
5
+ > **只读参照**:本体规划阶段**首选结构示例**(非可复制模板)。覆盖物理表、**表间关系**、Cube、本体链接、函数与 **test_arguments** 完整落地;**不得**整篇粘贴为本项目 `plans/`。须独立撰写并写差异说明(见 [本体规划指南 · 任务模式](./本体规划指南.md#任务模式与反模式))。
6
+
7
+ > 表/Cube/对象命名遵循 [本体命名规范](./本体命名规范_物理表Cube与对象.md)。
8
+ > 补充示例(利润分析域):[利润示例 plans](../../利润示例/plans/规划示例_利润分析本体方案.md)
7
9
 
8
10
  **占位符**(复制到工作区 `plans/` 后替换为实际值):
9
11
 
@@ -53,7 +55,7 @@
53
55
 
54
56
  **物理表清单**(命名见 [命名规范 §2](./本体命名规范_物理表Cube与对象.md#2-物理表类别与前缀)):
55
57
 
56
- | 表名 | 前缀类别 | **347 分类** | 显示名 | 说明 | 角色 |
58
+ | 表名 | 前缀类别 | **平台分类** | 显示名 | 说明 | 角色 |
57
59
  | ---- | -------- | ------------ | ------ | ---- | ---- |
58
60
  | **`dim_date`** | 时间维(**强制**) | **时间维** | 日期维表 | 全空间共享;PK **`date_key`** | 时间维 |
59
61
  | `dim_product` | dim | **维度表** | 产品维表 | 可售产品主数据 | dim |
@@ -62,7 +64,7 @@
62
64
  | **`fact_sales_order_line`** | fact | **事实表** | 销售订单行事实表 | 订单行粒度销售流水;含 **`date_key`** | fact |
63
65
 
64
66
  > 规划原则:**先**定义业务对象(Product、SalesOrder 等)与链接,**再**反推 Cube 与物理表。事实表通过 `date_key` 关联 `dim_date`,支撑同比/环比与时间层次分析。
65
- > init 脚本 `资源/examples/onto/销售示例/setup/sales_ontology_init.py` 顶部 **`TABLE_REGISTRY`** 与上表及 §3.x 字段 **显示名/说明** 一一对应,经 `s.tables.register_with_meta` 注册;**`CATEGORY_REGISTRY`** 与 [附录 B](#附录-b347-分类挂载对照表category_registry) 及 `apply_registry` 步骤对齐。
67
+ > init 脚本 `资源/examples/onto/销售示例/setup/sales_ontology_init.py` 顶部 **`TABLE_REGISTRY`** 与上表及 §3.x 字段 **显示名/说明** 一一对应,经 `s.tables.register_with_meta` 注册;**`CATEGORY_REGISTRY`** 与 [附录 B](#附录-b平台-分类挂载对照表category_registry) 及 `apply_registry` 步骤对齐。
66
68
 
67
69
  ---
68
70
 
@@ -189,7 +191,7 @@
189
191
 
190
192
  **关系清单(5 条)**:
191
193
 
192
- | 关系 ID | **347 分类** | 类型 | 从表 | 到表 | join_keys | 说明 |
194
+ | 关系 ID | **平台分类** | 类型 | 从表 | 到表 | join_keys | 说明 |
193
195
  | ------- | ------------ | ---- | ---- | ---- | --------- | ---- |
194
196
  | rel_sales_date | **时间关联** | many_to_one | fact_sales_order_line | dim_date | date_key → date_key | 订单行关联日历 |
195
197
  | rel_sales_product | **主数据关联** | many_to_one | fact_sales_order_line | dim_product | product_id → product_id | 订单行关联产品 |
@@ -235,7 +237,7 @@ s.tables.add_relationship(
235
237
 
236
238
  ### 4.0 Cube 清单与类别
237
239
 
238
- | Cube | 类别 | **347 分类** | 事实源 | 时间维 | 支撑对象 |
240
+ | Cube | 类别 | **平台分类** | 事实源 | 时间维 | 支撑对象 |
239
241
  | ---- | ---- | ------------ | ------ | ------ | -------- |
240
242
  | **SalesCube** | Process | **流程型** | fact_sales_order_line | dim_date(year/month/quarter) | SalesOrder, SalesAnalysis |
241
243
  | **ProductSalesCube** | Subject | **主体型** | fact_sales_order_line | 同上 | Product |
@@ -299,7 +301,7 @@ s.tables.add_relationship(
299
301
 
300
302
  ### 5.1 对象类型(5 种)
301
303
 
302
- | code | 分类 | **347 分类** | 名称 | bind_source | 主物理支撑 |
304
+ | code | 分类 | **平台分类** | 名称 | bind_source | 主物理支撑 |
303
305
  | ---- | ---- | ------------ | ---- | ------------- | ---------- |
304
306
  | Product | Master | **主数据** | 产品 | ProductSalesCube | dim_product |
305
307
  | Customer | Master | **主数据** | 客户 | CustomerSalesCube | dim_customer |
@@ -339,7 +341,7 @@ s.tables.add_relationship(
339
341
 
340
342
  ### 5.3 链接类型(8 种)
341
343
 
342
- | 链接 code | **347 分类** | 名称 | from | to | 说明 |
344
+ | 链接 code | **平台分类** | 名称 | from | to | 说明 |
343
345
  | ---------------------- | ------------ | -------------- | ------------- | ------------- | -------------------- |
344
346
  | order_contains_product | **归属关系** | 订单包含产品 | SalesOrder | Product | 订单行对应产品 |
345
347
  | order_belongs_customer | **归属关系** | 订单归属客户 | SalesOrder | Customer | 订单归属客户 |
@@ -367,7 +369,7 @@ s.tables.add_relationship(
367
369
 
368
370
  ### 6.1 函数清单
369
371
 
370
- | 函数 ID | **347 分类** | 功能 | 参数 |
372
+ | 函数 ID | **平台分类** | 功能 | 参数 |
371
373
  | --------------------------------- | ------------ | ------------ | ------------------------------------------------- |
372
374
  | sales.fn.get_summary | **总览分析** | 销售总览 | start_date, end_date(可选) |
373
375
  | sales.fn.yoy_analysis | **趋势分析** | 同比分析 | start_date, end_date |
@@ -458,24 +460,22 @@ JSON 格式须含 `v`、`arguments`、`object_type_code`(与平台函数定义
458
460
  | 11 | define_property(约 29 个) |
459
461
  | 12 | define_link_type(8 种) |
460
462
  | 13 | sync_metric_refs |
461
- | 14 | **CATEGORY_REGISTRY** + `s.categories.apply_registry`(347 对齐) |
462
-
463
- ### 7.4 阶段四:函数与数据(中)
463
+ ### 7.4 阶段四:灌数、函数与分类(中)
464
464
 
465
465
  | 步骤 | 任务 |
466
466
  | ---- | -------------------------------------------------------------------- |
467
- | 14 | `销售示例/functions/sales_fn_*.py` 复制并适配(SQL 表名按本规划) |
468
- | 15 | seed 灌数:**dim_date** + 维表 + fact(写入 date_key) |
469
- | 16 | publish + run 验证 |
470
- | 17 | **`save-test-arguments`** 写入各函数 `test_arguments`(侧栏预填;见 §6.4) |
467
+ | 14 | seed 灌数:**dim_date** + 维表 + fact(写入 date_key) |
468
+ | 15 | `销售示例/functions/sales_fn_*.py` 复制并适配;**publish --register-function-id** |
469
+ | 16 | `function run` + **`save-test-arguments`**(侧栏预填;见 §6.4) |
470
+ | 17 | **`sales_category_mount.py`**:`CATEGORY_REGISTRY` + `apply_registry`(**最后**,类灌数) |
471
471
 
472
- ### 7.5 快速实施路径
472
+ ### 7.5 实施阶段参考(须 plans 已定稿后)
473
473
 
474
- 本仓库 **`资源/examples/onto/销售示例/setup/sales_ontology_init.py`** 含完整 init 逻辑(含 **`TABLE_REGISTRY`** 与 `register_with_meta`),与本文 §2.3、§3.x 对齐:
474
+ `资源/examples/onto/销售示例/setup/sales_ontology_init.py` 含完整 init 逻辑,与本文 §2.3、§3.x 对齐,供 **对照实施** 时参考:
475
475
 
476
- 1. 复制 `sales_ontology_init.py`、`sales_seed_data.py` 实现单元 `setup/`(`dazi examples sync` 或侧栏 **帮助 → 示例**)
477
- 2. init/seed `space_id` 改为 README 中的 `<space-id>`
478
- 3. [快速启动](./本体规划指南.md) 发布执行
476
+ 1. 确认 `plans/` 已定稿并通过自检(快速启动 §3 门禁)
477
+ 2. 按需借鉴或复制示例 init/seed,**按本实现 plans 改造**表名与元数据
478
+ 3. `space_id` 后按 [本体脚本编写指南](./本体脚本编写指南.md) 发布执行
479
479
 
480
480
  ---
481
481
 
@@ -500,7 +500,7 @@ JSON 格式须含 `v`、`arguments`、`object_type_code`(与平台函数定义
500
500
  | **表间关系** | **4 条**(含 fact → dim_date) |
501
501
  | Cube | **4 个** Cube;SalesCube 含时间维 |
502
502
  | 对象类型 | 5 种 + 分类列;8 种链接 |
503
- | **347 平台分类** | 侧栏分类名与附录 B 一致;init 重跑幂等 |
503
+ | **平台侧栏分类** | 侧栏分类名与附录 B 一致;`category_mount` 重跑幂等 |
504
504
  | 函数 | get_summary、top_products 可运行 |
505
505
  | test_arguments | 各 function_id 已 save-test-arguments |
506
506
  | 数据 | 种子灌入后指标与手工 SQL 一致 |
@@ -519,13 +519,13 @@ JSON 格式须含 `v`、`arguments`、`object_type_code`(与平台函数定义
519
519
 
520
520
  ---
521
521
 
522
- ## 附录 B:347 分类挂载对照表(CATEGORY_REGISTRY)
522
+ ## 附录 B:平台分类挂载对照表(CATEGORY_REGISTRY)
523
523
 
524
- 与 `销售示例/setup/sales_ontology_init.py` 顶部 **`CATEGORY_REGISTRY`** 一一对应;平台 `category_name` **=** 347 标准中文名(见 [349 方案](./本体分类规划与SDK扩展方案.md))。
524
+ 与 `销售示例/setup/sales_category_mount.py` 顶部 **`CATEGORY_REGISTRY`** 一一对应;平台 `category_name` **=** 平台标准分类中文名(见 [本体分类规划与SDK扩展方案](./本体分类规划与SDK扩展方案.md))。**init 不含分类挂载**;本附录在 **全部函数 publish 后** 由 `category_mount` 脚本执行。
525
525
 
526
526
  ### B.1 物理表(table)
527
527
 
528
- | 347 分类 | 表名 |
528
+ | 平台分类 | 表名 |
529
529
  | -------- | ---- |
530
530
  | 时间维 | dim_date |
531
531
  | 维度表 | dim_product, dim_customer, dim_channel |
@@ -533,14 +533,14 @@ JSON 格式须含 `v`、`arguments`、`object_type_code`(与平台函数定义
533
533
 
534
534
  ### B.2 Cube(cube)
535
535
 
536
- | 347 分类 | Cube |
536
+ | 平台分类 | Cube |
537
537
  | -------- | ---- |
538
538
  | 流程型 | SalesCube |
539
539
  | 主体型 | ProductSalesCube, CustomerSalesCube, ChannelSalesCube |
540
540
 
541
541
  ### B.3 对象类型(object)
542
542
 
543
- | 347 分类 | code |
543
+ | 平台分类 | code |
544
544
  | -------- | ---- |
545
545
  | 主数据 | Product, Customer |
546
546
  | 参考 | SalesChannel |
@@ -549,23 +549,23 @@ JSON 格式须含 `v`、`arguments`、`object_type_code`(与平台函数定义
549
549
 
550
550
  ### B.4 表间关系(relation)
551
551
 
552
- | 347 分类 | 从表 → 到表 |
552
+ | 平台分类 | 从表 → 到表 |
553
553
  | -------- | ----------- |
554
554
  | 时间关联 | fact_sales_order_line → dim_date |
555
555
  | 主数据关联 | fact_sales_order_line → dim_product / dim_customer / dim_channel |
556
556
 
557
557
  ### B.5 链接类型(link)
558
558
 
559
- | 347 分类 | link code |
559
+ | 平台分类 | link code |
560
560
  | -------- | --------- |
561
561
  | 归属关系 | order_contains_product, order_belongs_customer, order_via_channel, product_has_orders, customer_places_orders |
562
562
  | 分析归因 | analysis_by_product, analysis_by_customer, analysis_by_channel |
563
563
 
564
564
  ### B.6 本体函数(function)
565
565
 
566
- init 脚本**不**注册函数;函数发布后单独执行 `apply_registry` 的 `function` 段,或 `skip_missing=True` 跳过。建议分类:
566
+ 函数在 `functions/` 中 **publish 注册**;`sales_category_mount.py` 在 **init + seed + 全部函数 publish 之后** 统一 `apply_registry`(含 function 段,`skip_missing=True` 可重跑)。建议分类:
567
567
 
568
- | 347 分类 | function_id |
568
+ | 平台分类 | function_id |
569
569
  | -------- | ----------- |
570
570
  | 总览分析 | sales.fn.get_summary |
571
571
  | 趋势分析 | sales.fn.yoy_analysis, sales.fn.mom_analysis |
@@ -595,7 +595,7 @@ init 脚本**不**注册函数;函数发布后单独执行 `apply_registry`
595
595
  | 8 | 函数清单 | ☑ |
596
596
  | 9 | test_arguments | ☑ |
597
597
  | 10 | 实施与验收 | ☑ |
598
- | 6a–6e | 347 平台分类 | ☑(附录 B + init 步骤 10) |
598
+ | 6a–6e | 平台侧栏分类 | ☑(附录 B + `sales_category_mount.py`) |
599
599
 
600
600
  ---
601
601
 
@@ -609,8 +609,8 @@ init 脚本**不**注册函数;函数发布后单独执行 `apply_registry`
609
609
  | 函数开发 | [function-guide.md](./function-guide.md) |
610
610
  | 参考实现(init/seed/函数) | `资源/examples/onto/销售示例/` → 复制到 `<item-path>/` |
611
611
  | **内置脚本示例** | `资源/examples/onto/销售示例/`(`dazi examples sync` 后复制到实现单元) |
612
- | 补充示例(利润) | [规划示例_利润分析本体方案.md](./规划示例_利润分析本体方案.md) · `资源/examples/onto/利润示例/` |
613
- | 349 · 分类方案 | [本体分类规划与 SDK 扩展方案](./本体分类规划与SDK扩展方案.md) |
612
+ | 补充示例(利润) | [利润示例 plans](../../利润示例/plans/规划示例_利润分析本体方案.md) |
613
+ | 分类方案 | [本体分类规划与 SDK 扩展方案](./本体分类规划与SDK扩展方案.md) |
614
614
 
615
615
  ---
616
616
 
@@ -0,0 +1,82 @@
1
+ """产品销售本体 — 平台分类挂载(CATEGORY_REGISTRY)
2
+
3
+ 与灌数脚本类似,**独立步骤、放在实施流程最后**:
4
+ init → seed → 发布全部函数 → **本脚本**。
5
+
6
+ 放置:资源/examples/onto/销售示例/setup/sales_category_mount.py
7
+ 发布:dazi onto script publish <item-path>/setup/sales_category_mount.py --space <space-id> --type setup
8
+ 规划对照:资源/examples/onto/销售示例/plans/规划示例_产品销售本体规划方案.md 附录 B
9
+ """
10
+
11
+ import json
12
+
13
+ CATEGORY_REGISTRY = {
14
+ "table": {
15
+ "时间维": ["dim_date"],
16
+ "维度表": ["dim_product", "dim_customer", "dim_channel"],
17
+ "事实表": ["fact_sales_order_line"],
18
+ },
19
+ "cube": {
20
+ "流程型": ["SalesCube"],
21
+ "主体型": ["ProductSalesCube", "CustomerSalesCube", "ChannelSalesCube"],
22
+ },
23
+ "object": {
24
+ "主数据": ["Product", "Customer"],
25
+ "参考": ["SalesChannel"],
26
+ "事务": ["SalesOrder"],
27
+ "分析": ["SalesAnalysis"],
28
+ },
29
+ "relation": {
30
+ "时间关联": [("fact_sales_order_line", "dim_date")],
31
+ "主数据关联": [
32
+ ("fact_sales_order_line", "dim_product"),
33
+ ("fact_sales_order_line", "dim_customer"),
34
+ ("fact_sales_order_line", "dim_channel"),
35
+ ],
36
+ },
37
+ "link": {
38
+ "归属关系": [
39
+ "order_contains_product",
40
+ "order_belongs_customer",
41
+ "order_via_channel",
42
+ "product_has_orders",
43
+ "customer_places_orders",
44
+ ],
45
+ "分析归因": [
46
+ "analysis_by_product",
47
+ "analysis_by_customer",
48
+ "analysis_by_channel",
49
+ ],
50
+ },
51
+ "function": {
52
+ "总览分析": ["sales.fn.get_summary"],
53
+ "趋势分析": ["sales.fn.yoy_analysis", "sales.fn.mom_analysis"],
54
+ "结构分析": [
55
+ "sales.fn.top_products",
56
+ "sales.fn.customer_segmentation",
57
+ "sales.fn.channel_mix",
58
+ ],
59
+ "组织分析": ["sales.fn.region_breakdown"],
60
+ },
61
+ }
62
+
63
+
64
+ def main():
65
+ space_id = "space__misc_01"
66
+ s = space.get(space_id)
67
+
68
+ output.print("=== 产品销售 — 平台分类挂载 ===")
69
+ output.print(f"空间: {space_id}")
70
+
71
+ cat_counts = s.categories.apply_registry(CATEGORY_REGISTRY, skip_missing=True)
72
+ for kind, cnt in cat_counts.items():
73
+ if cnt:
74
+ output.print(f"OK 分类[{kind}] 挂载 {cnt} 项")
75
+
76
+ summary = {
77
+ "ok": True,
78
+ "space_id": space_id,
79
+ "category_mounts": cat_counts,
80
+ }
81
+ output.success("平台分类挂载完成")
82
+ output.print("__JSON_SUMMARY__" + json.dumps(summary, ensure_ascii=True, default=str))
@@ -1,4 +1,4 @@
1
- """产品销售本体初始化脚本 — space__misc_01
1
+ """产品销售本体初始化脚本 — space__misc_01
2
2
 
3
3
  初始化内容:
4
4
  1. 创建物理表(dim_date + 3 维表 + 1 事实表)
@@ -7,11 +7,11 @@
7
7
  4. 注册 Cube(4 个)及派生度量
8
8
  5. 定义对象类型(5 种)、绑定数据源、属性、链接
9
9
  6. 同步指标引用
10
- 7. 配置 347 对齐分类(ads_categories + 桥表)
10
+ 7. 配置 平台分类对齐分类(ads_categories + 桥表)
11
11
 
12
12
  放置:资源/examples/onto/销售示例/setup/sales_ontology_init.py(复制到项目 ontos/<实现名>/setup/)
13
13
  发布:dazi onto script publish <item-path>/setup/sales_ontology_init.py --space <space-id> --type setup
14
- 规划对照:资源/docs/onto/规划示例_产品销售本体规划方案.md
14
+ 规划对照:资源/examples/onto/销售示例/plans/规划示例_产品销售本体规划方案.md
15
15
  """
16
16
 
17
17
  import json
@@ -98,48 +98,6 @@ TABLE_REGISTRY = {
98
98
  },
99
99
  }
100
100
 
101
- # 与 347 + 附录 B 对齐;category 值必须是 347 标准中文名
102
- CATEGORY_REGISTRY = {
103
- "table": {
104
- "时间维": ["dim_date"],
105
- "维度表": ["dim_product", "dim_customer", "dim_channel"],
106
- "事实表": ["fact_sales_order_line"],
107
- },
108
- "cube": {
109
- "流程型": ["SalesCube"],
110
- "主体型": ["ProductSalesCube", "CustomerSalesCube", "ChannelSalesCube"],
111
- },
112
- "object": {
113
- "主数据": ["Product", "Customer"],
114
- "参考": ["SalesChannel"],
115
- "事务": ["SalesOrder"],
116
- "分析": ["SalesAnalysis"],
117
- },
118
- "relation": {
119
- "时间关联": [("fact_sales_order_line", "dim_date")],
120
- "主数据关联": [
121
- ("fact_sales_order_line", "dim_product"),
122
- ("fact_sales_order_line", "dim_customer"),
123
- ("fact_sales_order_line", "dim_channel"),
124
- ],
125
- },
126
- "link": {
127
- "归属关系": [
128
- "order_contains_product",
129
- "order_belongs_customer",
130
- "order_via_channel",
131
- "product_has_orders",
132
- "customer_places_orders",
133
- ],
134
- "分析归因": [
135
- "analysis_by_product",
136
- "analysis_by_customer",
137
- "analysis_by_channel",
138
- ],
139
- },
140
- }
141
-
142
-
143
101
  def main():
144
102
  space_id = "space__misc_01"
145
103
  s = space.get(space_id)
@@ -515,14 +473,6 @@ def main():
515
473
  s.sync_metric_refs()
516
474
  output.print("OK sync_metric_refs")
517
475
 
518
- # 10. 347 对齐分类
519
- output.print("\n[10/10] 配置对象分类(347 对齐)...")
520
-
521
- cat_counts = s.categories.apply_registry(CATEGORY_REGISTRY, skip_missing=True)
522
- for kind, cnt in cat_counts.items():
523
- if cnt:
524
- output.print(f"OK 分类[{kind}] 挂载 {cnt} 项")
525
-
526
476
  summary = {
527
477
  "ok": True,
528
478
  "space_id": space_id,
@@ -532,7 +482,6 @@ def main():
532
482
  "object_types": 5,
533
483
  "properties": len(properties),
534
484
  "link_types": len(link_types),
535
- "category_mounts": cat_counts,
536
485
  }
537
486
  output.success("本体初始化完成")
538
487
  output.print(f"space_id: {space_id}")
@@ -1,7 +1,14 @@
1
1
  {
2
- "version": "3.0.9",
2
+ "version": "3.1.1",
3
3
  "updatedAt": "2026-06-05T00:00:00.000Z",
4
4
  "prompts": [
5
+ {
6
+ "id": "onto/planning-design",
7
+ "title": "本体规划设计(TRAE/智能体 · 默认)",
8
+ "category": "onto",
9
+ "file": "onto/planning-design.md",
10
+ "featured": true
11
+ },
5
12
  {
6
13
  "id": "onto/script-publish-run",
7
14
  "title": "本体脚本发布与运行(TRAE/智能体)",
@@ -1,73 +1,73 @@
1
- # 提示词:本体函数设计
2
-
3
- **提示词 ID**: `onto/function-design`
4
- **场景**: 设计新的本体函数
5
-
6
- ---
7
-
8
- 你是一名搭子平台本体工程师。请根据以下需求设计一个本体函数(ontology function)。
9
-
10
- **执行脚本前必读**:`资源/docs/onto/脚本运行纠错_商务成本方案开发过程.md`(`onto/script-run-troubleshooting`)。
11
- **必须复制结构**:`资源/examples/onto/_templates/ontology_function_template.py` 或 `销售示例/functions/sales_fn_get_summary.py`。
12
-
13
- ## 函数需求
14
-
15
- {{function_description}}
16
-
17
- ## 要求
18
-
19
- 1. 文件名 `snake_case`,如 `cost_fn_get_summary.py`;`function_id` 如 `domain.fn.get_summary`
20
- 2. **`def main():` 无参** — 禁止 `main(params: dict)`;入参来自 `ctx.params`
21
- 3. 业务逻辑写在 **`_ontology_fn_body(p)`**;`main()` 末尾 **`return _ontology_fn_body(p)`**
22
- 4. 输出使用 **`return p.function_result(columns=..., data=..., row_count=...)`** — **禁止** `output.print_json()`、`print()` 作为平台输出
23
- 5. SQL 用 **`p.sql.query()`** 取多列;聚合勿误用 `query_one().get()`
24
- 6. 脚本顶部 **`TEST_ARGUMENTS`** 与 `functions/test_arguments/<function_id>.json` 同步
25
- 7. 中文 docstring:目的、参数、返回值、发布命令
26
-
27
- ## 输出格式(必须遵循)
28
-
29
- ```python
30
- TEST_ARGUMENTS = {
31
- "v": 1,
32
- "arguments": { ... },
33
- "object_type_code": "<ObjectTypeCode>",
34
- }
35
-
36
-
37
- def _ontology_fn_body(p):
38
- params = dict(p.get_params() or {})
39
- # ... p.sql.query(...)
40
- return p.function_result(
41
- columns=[...],
42
- data=[{...}],
43
- row_count=1,
44
- )
45
-
46
-
47
- def main():
48
- s = space.get(ctx.space_id or "")
49
- _Ports = type(
50
- "_Ports",
51
- (),
52
- {
53
- "get_params": lambda self: dict(ctx.params or {}),
54
- "function_result": lambda self, **kw: onto.function_result(**kw),
55
- },
56
- )
57
- p = _Ports()
58
- p.sql = s.sql
59
- return _ontology_fn_body(p)
60
- ```
61
-
62
- 脚本落盘:`项目/<业务名>/本体/ontos/<实现名>/functions/<file>.py`
63
-
64
- 发布与运行(dazi-work 根;**勿用** `dazi-onto`):
65
-
66
- ```powershell
67
- dazi onto script publish 项目/<业务名>/本体/ontos/<实现名>/functions/<file>.py --space <space-id> --register-function-id <id>
68
- dazi onto function run <id> --space <space-id>
69
- dazi onto function save-test-arguments <ofn_internal_id> --space <space-id> `
70
- --arguments-json-file 项目/<业务名>/本体/ontos/<实现名>/functions/test_arguments/<id>.json
71
- ```
72
-
73
- 详见 `onto/script-publish-run`、`onto/function-guide`。
1
+ # 提示词:本体函数设计
2
+
3
+ **提示词 ID**: `onto/function-design`
4
+ **场景**: 设计新的本体函数
5
+
6
+ ---
7
+
8
+ 你是一名搭子平台本体工程师。请根据以下需求设计一个本体函数(ontology function)。
9
+
10
+ **执行脚本前必读**:`资源/docs/onto/脚本运行常见错误处理.md`(`onto/script-run-troubleshooting`)。
11
+ **必须复制结构**:`资源/examples/onto/_templates/ontology_function_template.py` 或 `销售示例/functions/sales_fn_get_summary.py`。
12
+
13
+ ## 函数需求
14
+
15
+ {{function_description}}
16
+
17
+ ## 要求
18
+
19
+ 1. 文件名 `snake_case`,如 `cost_fn_get_summary.py`;`function_id` 如 `domain.fn.get_summary`
20
+ 2. **`def main():` 无参** — 禁止 `main(params: dict)`;入参来自 `ctx.params`
21
+ 3. 业务逻辑写在 **`_ontology_fn_body(p)`**;`main()` 末尾 **`return _ontology_fn_body(p)`**
22
+ 4. 输出使用 **`return p.function_result(columns=..., data=..., row_count=...)`** — **禁止** `output.print_json()`、`print()` 作为平台输出
23
+ 5. SQL 用 **`p.sql.query()`** 取多列;聚合勿误用 `query_one().get()`
24
+ 6. 脚本顶部 **`TEST_ARGUMENTS`** 与 `functions/test_arguments/<function_id>.json` 同步
25
+ 7. 中文 docstring:目的、参数、返回值、发布命令
26
+
27
+ ## 输出格式(必须遵循)
28
+
29
+ ```python
30
+ TEST_ARGUMENTS = {
31
+ "v": 1,
32
+ "arguments": { ... },
33
+ "object_type_code": "<ObjectTypeCode>",
34
+ }
35
+
36
+
37
+ def _ontology_fn_body(p):
38
+ params = dict(p.get_params() or {})
39
+ # ... p.sql.query(...)
40
+ return p.function_result(
41
+ columns=[...],
42
+ data=[{...}],
43
+ row_count=1,
44
+ )
45
+
46
+
47
+ def main():
48
+ s = space.get(ctx.space_id or "")
49
+ _Ports = type(
50
+ "_Ports",
51
+ (),
52
+ {
53
+ "get_params": lambda self: dict(ctx.params or {}),
54
+ "function_result": lambda self, **kw: onto.function_result(**kw),
55
+ },
56
+ )
57
+ p = _Ports()
58
+ p.sql = s.sql
59
+ return _ontology_fn_body(p)
60
+ ```
61
+
62
+ 脚本落盘:`项目/<业务名>/本体/ontos/<实现名>/functions/<file>.py`
63
+
64
+ 发布与运行(dazi-work 根;**勿用** `dazi-onto`):
65
+
66
+ ```powershell
67
+ dazi onto script publish 项目/<业务名>/本体/ontos/<实现名>/functions/<file>.py --space <space-id> --register-function-id <id>
68
+ dazi onto function run <id> --space <space-id>
69
+ dazi onto function save-test-arguments <ofn_internal_id> --space <space-id> `
70
+ --arguments-json-file 项目/<业务名>/本体/ontos/<实现名>/functions/test_arguments/<id>.json
71
+ ```
72
+
73
+ 详见 `onto/script-publish-run`、`onto/function-guide`。