@dazitech/cli 3.0.9 → 3.1.0
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.
- package/README.md +1 -1
- package/dist/clis/dazi-app.js +1 -1
- package/dist/clis/dazi-flow.js +1 -1
- package/dist/clis/dazi-onto.js +7 -2
- package/dist/clis/dazi.js +1 -1
- package/dist/docs/flow/flow-project-guide.md +1 -1
- package/dist/docs/guides/troubleshooting.md +3 -3
- package/dist/docs/index.json +3 -3
- package/dist/docs/onto/dazi_script_sdk_reference.md +246 -244
- package/dist/docs/onto/function-guide.md +123 -123
- 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 +24 -23
- 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 +402 -402
- 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 +242 -0
- 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
- package/dist/docs/onto//346/234/254/344/275/223/350/247/204/345/210/222/346/214/207/345/215/227.md +304 -281
- 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 +242 -0
- package/dist/docs/onto//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 +32 -32
- package/dist/docs/onto//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 +34 -32
- package/dist/examples/index.json +1 -1
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_category_mount.py +85 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_ontology_init.py +2 -65
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_category_mount.py +82 -0
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_ontology_init.py +2 -53
- package/dist/prompts/index.json +8 -1
- package/dist/prompts/onto/function-design.md +73 -73
- package/dist/prompts/onto/planning-design.md +104 -0
- package/dist/prompts/onto/script-publish-run.md +229 -208
- package/package.json +1 -1
- 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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""利润分析本体 — 平台分类挂载(CATEGORY_REGISTRY)
|
|
2
|
+
|
|
3
|
+
与灌数脚本类似,**独立步骤、放在实施流程最后**:
|
|
4
|
+
init → seed → 发布全部函数 → **本脚本**。
|
|
5
|
+
|
|
6
|
+
放置:资源/examples/onto/利润示例/setup/profit_category_mount.py
|
|
7
|
+
发布:dazi onto script publish <item-path>/setup/profit_category_mount.py --space <space-id> --type setup
|
|
8
|
+
规划对照:资源/docs/onto/规划示例_利润分析本体方案.md 附录 B
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
|
|
13
|
+
# 与规划附录 B 一一对应;category 值必须是平台标准分类中文名
|
|
14
|
+
CATEGORY_REGISTRY = {
|
|
15
|
+
"table": {
|
|
16
|
+
"维度表": ["dim_account", "dim_cost_center"],
|
|
17
|
+
"事实表": ["fact_gl_journal_entry", "fact_budget_entry"],
|
|
18
|
+
},
|
|
19
|
+
"cube": {
|
|
20
|
+
"流程型": ["ActualCube", "BudgetCube"],
|
|
21
|
+
"主体型": ["AccountActualCube", "CostCenterActualCube", "TimeActualCube"],
|
|
22
|
+
},
|
|
23
|
+
"object": {
|
|
24
|
+
"主数据": ["Account", "CostCenter"],
|
|
25
|
+
"事务": ["JournalEntry", "BudgetLine"],
|
|
26
|
+
"分析": ["ProfitAnalysis", "BudgetAnalysis"],
|
|
27
|
+
},
|
|
28
|
+
"relation": {
|
|
29
|
+
"时间关联": [
|
|
30
|
+
("fact_gl_journal_entry", "dim_date"),
|
|
31
|
+
("fact_budget_entry", "dim_date"),
|
|
32
|
+
],
|
|
33
|
+
"主数据关联": [
|
|
34
|
+
("fact_gl_journal_entry", "dim_account"),
|
|
35
|
+
("fact_gl_journal_entry", "dim_cost_center"),
|
|
36
|
+
("fact_budget_entry", "dim_account"),
|
|
37
|
+
("fact_budget_entry", "dim_cost_center"),
|
|
38
|
+
],
|
|
39
|
+
"层级自关联": [("dim_account", "dim_account")],
|
|
40
|
+
},
|
|
41
|
+
"link": {
|
|
42
|
+
"归属关系": [
|
|
43
|
+
"entry_belongs_account",
|
|
44
|
+
"entry_belongs_cost_center",
|
|
45
|
+
"budget_for_account",
|
|
46
|
+
"budget_for_cost_center",
|
|
47
|
+
],
|
|
48
|
+
"分析归因": [
|
|
49
|
+
"analysis_by_account",
|
|
50
|
+
"analysis_by_cost_center",
|
|
51
|
+
"account_contributes_profit",
|
|
52
|
+
"cost_center_contributes_profit",
|
|
53
|
+
],
|
|
54
|
+
"层级关系": ["account_has_parent"],
|
|
55
|
+
"对比关系": ["budget_compared_to_actual"],
|
|
56
|
+
},
|
|
57
|
+
"function": {
|
|
58
|
+
"总览分析": ["profit.fn.get_summary"],
|
|
59
|
+
"趋势分析": ["profit.fn.yoy_analysis", "profit.fn.mom_analysis"],
|
|
60
|
+
"结构分析": ["profit.fn.account_breakdown", "profit.fn.top_accounts"],
|
|
61
|
+
"预实分析": ["profit.fn.budget_vs_actual"],
|
|
62
|
+
"组织分析": ["profit.fn.cost_center_profit"],
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def main():
|
|
68
|
+
space_id = "space__misc_01"
|
|
69
|
+
s = space.get(space_id)
|
|
70
|
+
|
|
71
|
+
output.print("=== 利润分析 — 平台分类挂载 ===")
|
|
72
|
+
output.print(f"空间: {space_id}")
|
|
73
|
+
|
|
74
|
+
cat_counts = s.categories.apply_registry(CATEGORY_REGISTRY, skip_missing=True)
|
|
75
|
+
for kind, cnt in cat_counts.items():
|
|
76
|
+
if cnt:
|
|
77
|
+
output.print(f"OK 分类[{kind}] 挂载 {cnt} 项")
|
|
78
|
+
|
|
79
|
+
summary = {
|
|
80
|
+
"ok": True,
|
|
81
|
+
"space_id": space_id,
|
|
82
|
+
"category_mounts": cat_counts,
|
|
83
|
+
}
|
|
84
|
+
output.success("平台分类挂载完成")
|
|
85
|
+
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. 创建物理表(科目表、成本中心维表、实际分录表、预算表)
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
4. 注册Cube(5个)及派生度量
|
|
8
8
|
5. 定义对象类型(6种)、绑定数据源、属性、链接
|
|
9
9
|
6. 同步指标引用
|
|
10
|
-
7.
|
|
10
|
+
7. 平台分类挂载见 profit_category_mount.py(init/seed/函数 publish 之后执行)
|
|
11
11
|
|
|
12
12
|
放置:资源/examples/onto/利润示例/setup/profit_ontology_init.py(复制到项目 ontos/<实现名>/setup/)
|
|
13
13
|
发布:dazi onto script publish <item-path>/setup/profit_ontology_init.py --space <space-id> --type setup
|
|
@@ -105,60 +105,6 @@ TABLE_REGISTRY = {
|
|
|
105
105
|
},
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
# 与 347 + 附录 B 对齐;category 值必须是 347 标准中文名
|
|
109
|
-
CATEGORY_REGISTRY = {
|
|
110
|
-
"table": {
|
|
111
|
-
"维度表": ["dim_account", "dim_cost_center"],
|
|
112
|
-
"事实表": ["fact_gl_journal_entry", "fact_budget_entry"],
|
|
113
|
-
},
|
|
114
|
-
"cube": {
|
|
115
|
-
"流程型": ["ActualCube", "BudgetCube"],
|
|
116
|
-
"主体型": ["AccountActualCube", "CostCenterActualCube", "TimeActualCube"],
|
|
117
|
-
},
|
|
118
|
-
"object": {
|
|
119
|
-
"主数据": ["Account", "CostCenter"],
|
|
120
|
-
"事务": ["JournalEntry", "BudgetLine"],
|
|
121
|
-
"分析": ["ProfitAnalysis", "BudgetAnalysis"],
|
|
122
|
-
},
|
|
123
|
-
"relation": {
|
|
124
|
-
"时间关联": [
|
|
125
|
-
("fact_gl_journal_entry", "dim_date"),
|
|
126
|
-
("fact_budget_entry", "dim_date"),
|
|
127
|
-
],
|
|
128
|
-
"主数据关联": [
|
|
129
|
-
("fact_gl_journal_entry", "dim_account"),
|
|
130
|
-
("fact_gl_journal_entry", "dim_cost_center"),
|
|
131
|
-
("fact_budget_entry", "dim_account"),
|
|
132
|
-
("fact_budget_entry", "dim_cost_center"),
|
|
133
|
-
],
|
|
134
|
-
"层级自关联": [("dim_account", "dim_account")],
|
|
135
|
-
},
|
|
136
|
-
"link": {
|
|
137
|
-
"归属关系": [
|
|
138
|
-
"entry_belongs_account",
|
|
139
|
-
"entry_belongs_cost_center",
|
|
140
|
-
"budget_for_account",
|
|
141
|
-
"budget_for_cost_center",
|
|
142
|
-
],
|
|
143
|
-
"分析归因": [
|
|
144
|
-
"analysis_by_account",
|
|
145
|
-
"analysis_by_cost_center",
|
|
146
|
-
"account_contributes_profit",
|
|
147
|
-
"cost_center_contributes_profit",
|
|
148
|
-
],
|
|
149
|
-
"层级关系": ["account_has_parent"],
|
|
150
|
-
"对比关系": ["budget_compared_to_actual"],
|
|
151
|
-
},
|
|
152
|
-
"function": {
|
|
153
|
-
"总览分析": ["profit.fn.get_summary"],
|
|
154
|
-
"趋势分析": ["profit.fn.yoy_analysis", "profit.fn.mom_analysis"],
|
|
155
|
-
"结构分析": ["profit.fn.account_breakdown", "profit.fn.top_accounts"],
|
|
156
|
-
"预实分析": ["profit.fn.budget_vs_actual"],
|
|
157
|
-
"组织分析": ["profit.fn.cost_center_profit"],
|
|
158
|
-
},
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
108
|
def main():
|
|
163
109
|
space_id = "space__misc_01"
|
|
164
110
|
s = space.get(space_id)
|
|
@@ -654,14 +600,6 @@ def main():
|
|
|
654
600
|
s.sync_metric_refs()
|
|
655
601
|
output.print("OK sync_metric_refs")
|
|
656
602
|
|
|
657
|
-
# 10. 347 对齐分类
|
|
658
|
-
output.print("\n[10/10] 配置对象分类(347 对齐)...")
|
|
659
|
-
|
|
660
|
-
cat_counts = s.categories.apply_registry(CATEGORY_REGISTRY, skip_missing=True)
|
|
661
|
-
for kind, cnt in cat_counts.items():
|
|
662
|
-
if cnt:
|
|
663
|
-
output.print(f"OK 分类[{kind}] 挂载 {cnt} 项")
|
|
664
|
-
|
|
665
603
|
summary = {
|
|
666
604
|
"ok": True,
|
|
667
605
|
"space_id": space_id,
|
|
@@ -671,7 +609,6 @@ def main():
|
|
|
671
609
|
"object_types": 6,
|
|
672
610
|
"properties": 42,
|
|
673
611
|
"link_types": 10,
|
|
674
|
-
"category_mounts": cat_counts,
|
|
675
612
|
}
|
|
676
613
|
|
|
677
614
|
output.print("\n=== 利润分析本体初始化完成 ===")
|
|
@@ -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
|
+
规划对照:资源/docs/onto/规划示例_产品销售本体规划方案.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,7 +7,7 @@
|
|
|
7
7
|
4. 注册 Cube(4 个)及派生度量
|
|
8
8
|
5. 定义对象类型(5 种)、绑定数据源、属性、链接
|
|
9
9
|
6. 同步指标引用
|
|
10
|
-
7. 配置
|
|
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
|
|
@@ -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}")
|
package/dist/prompts/index.json
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.0
|
|
2
|
+
"version": "3.1.0",
|
|
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
|
|
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`。
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# 本体规划设计(TRAE / 智能体)
|
|
2
|
+
|
|
3
|
+
**文档 ID**: `onto/planning-design`
|
|
4
|
+
**场景**: 新建本体实现、撰写 `plans/` 规划、能力评估(**默认任务模式**)
|
|
5
|
+
**前置**: 已打开本体实现单元;`README.md` / `快速启动_*.md` 中有 `space_id`
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 0. 任务边界(强制)
|
|
10
|
+
|
|
11
|
+
本提示词用于 **规划阶段**,产出仅为 **`plans/<主题>.md`**(及自检附录)。
|
|
12
|
+
|
|
13
|
+
| 允许 | 禁止(未获用户明确要求「快速 demo」前) |
|
|
14
|
+
| ---- | ---------------------------------------- |
|
|
15
|
+
| 阅读 `资源/docs/onto/规划示例_*.md` **学结构** | 复制 `资源/examples/onto/**/setup/*.py` 到本项目 |
|
|
16
|
+
| 阅读 `本体规划指南.md`、`本体命名规范_*.md` | 复制 `项目/*/本体/ontos/*` 整目录到其他实现 |
|
|
17
|
+
| 在 `plans/` **独立撰写**业务方案 | 把规划示例全文另存为 `plans/` |
|
|
18
|
+
| 对照侧栏 **数据资源** 了解现网表/Cube | `dazi onto script publish` / 写 `setup/`、`functions/` |
|
|
19
|
+
|
|
20
|
+
**用户说「创建/设计本体方案」** → 先规划,**不是**先复制 init。
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 1. 开始前读取
|
|
25
|
+
|
|
26
|
+
1. `项目/<业务>/本体/ontos/<实现名>/README.md` — **space_id**
|
|
27
|
+
2. `快速启动_<实现名>.md` — §0 任务模式、§2 域路由表
|
|
28
|
+
3. `dazi docs sync` 后:`资源/docs/onto/本体规划指南.md`
|
|
29
|
+
|
|
30
|
+
```powershell
|
|
31
|
+
dazi doctor
|
|
32
|
+
dazi auth whoami
|
|
33
|
+
dazi onto space get <space-id> # 可选:现网资产
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 2. 业务域路由(只读参照)
|
|
39
|
+
|
|
40
|
+
| 用户意图关键词 | 只读对照规划 | 勿混用 |
|
|
41
|
+
| -------------- | ------------ | ------ |
|
|
42
|
+
| 销售、订单、产品、渠道、SKU | `规划示例_产品销售本体规划方案.md` | 利润 GL 表结构 |
|
|
43
|
+
| 利润、科目、预算、GL、成本中心、预实 | `规划示例_利润分析本体方案.md` | 销售订单事实表 |
|
|
44
|
+
|
|
45
|
+
规划示例是 **参照答案**,须结合本实现的业务背景 **重写**,并写 **「与参照示例的差异说明」** 章节。
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 3. 规划方法(业务世界 → 三层)
|
|
50
|
+
|
|
51
|
+
**顺序**:对象类型 + 链接(业务语言)→ 反推物理表 + 表间关系 → Cube 读模型 → 函数清单。
|
|
52
|
+
|
|
53
|
+
每层须 **独立成章**(见规划指南标准结构):
|
|
54
|
+
|
|
55
|
+
| 章节 | 必填要点 |
|
|
56
|
+
| ---- | -------- |
|
|
57
|
+
| 业务场景 | 域边界、分析问题、空间约束 |
|
|
58
|
+
| 物理层 | `dim_date` + `fact_*` 含 `date_key`;表/列 **显示名+说明** |
|
|
59
|
+
| 表间关系 | 从事实到维表;`join_keys`;与本体链接对照 |
|
|
60
|
+
| **Cube 层** | 每 Cube:类别、事实源、维度、度量、派生度量、支撑对象 |
|
|
61
|
+
| 本体层 | 对象 `code`、分类、bind_source、属性、链接 |
|
|
62
|
+
| 函数 | function_id、参数、返回值、test_arguments |
|
|
63
|
+
| 差异说明 | 与所选规划示例的业务/表/Cube/对象差异 |
|
|
64
|
+
| 附录 B | CATEGORY_REGISTRY 对照(平台分类) |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 4. 产出路径
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
项目/<业务>/本体/ontos/<实现名>/plans/<主题>.md
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
定稿前勾选 [规划完整性自检清单](资源/docs/onto/本体规划指南.md)(含 Cube 层、6a–6e 分类)。
|
|
75
|
+
|
|
76
|
+
规划阶段 **不** 创建或发布 `setup/`、`functions/` 脚本。
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 5. 反模式(视为不合格)
|
|
81
|
+
|
|
82
|
+
- `plans/` 为空即开始写 init
|
|
83
|
+
- 表名/Cube/对象与规划示例 **逐字相同** 且无差异说明
|
|
84
|
+
- 利润域任务却使用销售域 `fact_sales_order_line` 等且无业务论证
|
|
85
|
+
- 复制潘达石化或其他 `项目/` 下历史实现充数
|
|
86
|
+
- 规划缺 **Cube 独立章节**(仅表+对象+函数)
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 6. 进入实施
|
|
91
|
+
|
|
92
|
+
规划定稿且用户确认后,切换提示词 **`onto/script-publish-run`**,按 `plans/` 实现 `setup/`、`functions/`。
|
|
93
|
+
|
|
94
|
+
实施顺序:**init → seed → 发布全部函数 → `*_category_mount.py`**(类灌数,含附录 B 全量六类)。可选:各 publish 带 `--register-platform-category` 与 category_mount 幂等并存。
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 7. 相关文档
|
|
99
|
+
|
|
100
|
+
- `onto/本体规划指南.md`
|
|
101
|
+
- `onto/规划示例_产品销售本体规划方案.md`
|
|
102
|
+
- `onto/规划示例_利润分析本体方案.md`
|
|
103
|
+
- `onto/本体命名规范_物理表Cube与对象.md`
|
|
104
|
+
- `onto/本体分类规划与SDK扩展方案.md`
|