@dazitech/cli 3.0.8 → 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 +12 -1
- package/dist/docs/index.json +21 -2
- package/dist/docs/onto/dazi_script_sdk_reference.md +246 -178
- package/dist/docs/onto/function-guide.md +123 -95
- 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 -0
- 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 -0
- 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 -249
- package/dist/docs/onto//346/234/254/344/275/223/350/247/204/345/210/222/346/214/207/345/215/227.md +304 -173
- 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 +361 -238
- 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 +385 -300
- package/dist/examples/index.json +22 -16
- package/dist/examples/onto/README.md +13 -5
- package/dist/examples/onto/_templates/ontology_function_template.py +50 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_account_breakdown.py +62 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_budget_vs_actual.py +69 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_cost_center_profit.py +64 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_get_summary.py +61 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_mom_analysis.py +82 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_top_accounts.py +61 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_yoy_analysis.py +79 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/save_test_arguments.ps1 +38 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/test_arguments/profit.fn.account_breakdown.json +1 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/test_arguments/profit.fn.budget_vs_actual.json +1 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/test_arguments/profit.fn.cost_center_profit.json +1 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/test_arguments/profit.fn.get_summary.json +1 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/test_arguments/profit.fn.mom_analysis.json +1 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/test_arguments/profit.fn.top_accounts.json +1 -0
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/test_arguments/profit.fn.yoy_analysis.json +1 -0
- 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 +169 -74
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_seed_data.py +16 -13
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_channel_mix.py +19 -16
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_customer_segmentation.py +48 -50
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_get_summary.py +3 -6
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_mom_analysis.py +11 -12
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_region_breakdown.py +6 -7
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_top_products.py +5 -8
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_yoy_analysis.py +3 -6
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/save_test_arguments.ps1 +32 -19
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.channel_mix.json +3 -6
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.customer_segmentation.json +2 -7
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.get_summary.json +2 -5
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.mom_analysis.json +2 -5
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.region_breakdown.json +2 -5
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.top_products.json +2 -7
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.yoy_analysis.json +2 -5
- 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 +240 -155
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_seed_data.py +59 -20
- package/dist/prompts/index.json +8 -1
- package/dist/prompts/onto/function-design.md +73 -53
- package/dist/prompts/onto/planning-design.md +104 -0
- package/dist/prompts/onto/script-publish-run.md +229 -194
- package/package.json +1 -1
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/profit_fn_account_breakdown.py +0 -99
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/profit_fn_budget_vs_actual.py +0 -116
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/profit_fn_cost_center_profit.py +0 -85
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/profit_fn_get_summary.py +0 -76
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/profit_fn_mom_analysis.py +0 -86
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/profit_fn_top_accounts.py +0 -103
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/profit_fn_yoy_analysis.py +0 -86
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/save_test_arguments.ps1 +0 -27
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/test_arguments/profit.fn.account_breakdown.json +0 -10
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/test_arguments/profit.fn.budget_vs_actual.json +0 -10
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/test_arguments/profit.fn.cost_center_profit.json +0 -9
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/test_arguments/profit.fn.get_summary.json +0 -9
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/test_arguments/profit.fn.mom_analysis.json +0 -9
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/test_arguments/profit.fn.top_accounts.json +0 -11
- package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/function/test_arguments/profit.fn.yoy_analysis.json +0 -9
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/README.md +0 -25
- package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/README.md +0 -5
package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_seed_data.py
CHANGED
|
@@ -1,34 +1,69 @@
|
|
|
1
|
-
"""产品销售演示数据灌入 —
|
|
1
|
+
"""产品销售演示数据灌入 — space__misc_01
|
|
2
2
|
|
|
3
3
|
前置:先执行 sales_ontology_init.py 建表。
|
|
4
|
-
幂等:
|
|
4
|
+
幂等:fact_sales_order_line 已有数据则跳过。
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
发布:dazi onto script publish
|
|
6
|
+
放置:项目/DAZI_TEST/本体/ontos/销售本体示例/setup/sales_seed_data.py
|
|
7
|
+
发布:dazi onto script publish 项目/DAZI_TEST/本体/ontos/销售本体示例/setup/sales_seed_data.py --space space__misc_01 --type data
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
import json
|
|
11
11
|
import random
|
|
12
12
|
from datetime import date, datetime, timedelta
|
|
13
13
|
|
|
14
|
+
|
|
14
15
|
_SEED_DT = datetime(2025, 1, 1, 0, 0, 0)
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
def main():
|
|
18
|
-
space_id = "
|
|
19
|
+
space_id = "space__misc_01"
|
|
19
20
|
s = space.get(space_id)
|
|
20
21
|
|
|
21
22
|
output.print("=== 产品销售演示数据灌入 ===")
|
|
22
23
|
|
|
24
|
+
# 检查是否已有数据
|
|
23
25
|
try:
|
|
24
|
-
n = int(s.sql.query_one("SELECT count() FROM
|
|
26
|
+
n = int(s.sql.query_one("SELECT count() FROM fact_sales_order_line") or 0)
|
|
25
27
|
except Exception:
|
|
26
28
|
n = 0
|
|
27
29
|
if n > 0:
|
|
28
|
-
output.print(f"
|
|
29
|
-
output.print("__JSON_SUMMARY__" + json.dumps({"ok": True, "skipped": True, "rows": n}, ensure_ascii=
|
|
30
|
+
output.print(f"fact_sales_order_line 已有 {n} 行,跳过灌数")
|
|
31
|
+
output.print("__JSON_SUMMARY__" + json.dumps({"ok": True, "skipped": True, "rows": n}, ensure_ascii=False))
|
|
30
32
|
return
|
|
31
33
|
|
|
34
|
+
# 1. 灌入 dim_date
|
|
35
|
+
output.print("\n[1/4] 灌入 dim_date...")
|
|
36
|
+
dim_date_rows = []
|
|
37
|
+
start_date = date(2025, 1, 1)
|
|
38
|
+
end_date = date(2026, 6, 30)
|
|
39
|
+
current = start_date
|
|
40
|
+
while current <= end_date:
|
|
41
|
+
date_key = int(current.strftime("%Y%m%d"))
|
|
42
|
+
year = current.year
|
|
43
|
+
month = current.month
|
|
44
|
+
quarter = (month - 1) // 3 + 1
|
|
45
|
+
week_of_year = current.isocalendar()[1]
|
|
46
|
+
day_of_week = current.weekday()
|
|
47
|
+
is_weekend = 1 if day_of_week >= 5 else 0
|
|
48
|
+
year_month = current.strftime("%Y-%m")
|
|
49
|
+
dim_date_rows.append({
|
|
50
|
+
"date_key": date_key,
|
|
51
|
+
"calendar_date": current,
|
|
52
|
+
"year": year,
|
|
53
|
+
"quarter": quarter,
|
|
54
|
+
"month": month,
|
|
55
|
+
"week_of_year": week_of_year,
|
|
56
|
+
"day_of_week": day_of_week,
|
|
57
|
+
"is_weekend": is_weekend,
|
|
58
|
+
"year_month": year_month,
|
|
59
|
+
})
|
|
60
|
+
current += timedelta(days=1)
|
|
61
|
+
s.sql.insert_rows("dim_date", dim_date_rows)
|
|
62
|
+
output.print(f"OK dim_date 插入 {len(dim_date_rows)} 行")
|
|
63
|
+
|
|
64
|
+
# 2. 灌入维表
|
|
65
|
+
output.print("\n[2/4] 灌入维表...")
|
|
66
|
+
|
|
32
67
|
products = [
|
|
33
68
|
{"product_id": "P001", "product_code": "OIL-92", "product_name": "92号汽油", "product_category": "成品油", "product_subcategory": "汽油", "brand": "潘达", "unit": "吨", "list_price": 8200.0, "cost_price": 7100.0, "status": "在售"},
|
|
34
69
|
{"product_id": "P002", "product_code": "OIL-0", "product_name": "0号柴油", "product_category": "成品油", "product_subcategory": "柴油", "brand": "潘达", "unit": "吨", "list_price": 7500.0, "cost_price": 6500.0, "status": "在售"},
|
|
@@ -57,11 +92,13 @@ def main():
|
|
|
57
92
|
{"channel_id": "CH03", "channel_code": "B2B", "channel_name": "B2B平台", "channel_type": "线上"},
|
|
58
93
|
]
|
|
59
94
|
|
|
60
|
-
s.sql.insert_rows("
|
|
61
|
-
s.sql.insert_rows("
|
|
62
|
-
s.sql.insert_rows("
|
|
63
|
-
output.print("OK
|
|
95
|
+
s.sql.insert_rows("dim_product", products)
|
|
96
|
+
s.sql.insert_rows("dim_customer", customers)
|
|
97
|
+
s.sql.insert_rows("dim_channel", channels)
|
|
98
|
+
output.print(f"OK dim_product {len(products)} 行, dim_customer {len(customers)} 行, dim_channel {len(channels)} 行")
|
|
64
99
|
|
|
100
|
+
# 3. 生成销售事实数据
|
|
101
|
+
output.print("\n[3/4] 生成销售事实数据...")
|
|
65
102
|
random.seed(627)
|
|
66
103
|
regions = {c["customer_id"]: c["customer_region"] for c in customers}
|
|
67
104
|
ctypes = {c["customer_id"]: c["customer_type"] for c in customers}
|
|
@@ -70,12 +107,10 @@ def main():
|
|
|
70
107
|
|
|
71
108
|
fact_rows = []
|
|
72
109
|
line_seq = 1
|
|
73
|
-
|
|
74
|
-
end = date(2026, 6, 30)
|
|
75
|
-
days = (end - start).days + 1
|
|
110
|
+
days = (end_date - start_date).days + 1
|
|
76
111
|
|
|
77
112
|
for d_offset in range(days):
|
|
78
|
-
order_date =
|
|
113
|
+
order_date = start_date + timedelta(days=d_offset)
|
|
79
114
|
if random.random() > 0.35:
|
|
80
115
|
continue
|
|
81
116
|
daily_orders = random.randint(2, 8)
|
|
@@ -90,9 +125,11 @@ def main():
|
|
|
90
125
|
unit_price = round(prices[product_id] * random.uniform(0.92, 1.0), 2)
|
|
91
126
|
discount = round(unit_price * qty * random.uniform(0, 0.05), 2)
|
|
92
127
|
sales_amount = round(unit_price * qty - discount, 2)
|
|
128
|
+
date_key = int(order_date.strftime("%Y%m%d"))
|
|
93
129
|
fact_rows.append({
|
|
94
130
|
"order_id": order_id,
|
|
95
131
|
"order_line_id": f"L{line_seq:06d}",
|
|
132
|
+
"date_key": date_key,
|
|
96
133
|
"order_date": order_date,
|
|
97
134
|
"product_id": product_id,
|
|
98
135
|
"product_category": pcats[product_id],
|
|
@@ -109,16 +146,18 @@ def main():
|
|
|
109
146
|
})
|
|
110
147
|
line_seq += 1
|
|
111
148
|
|
|
112
|
-
|
|
113
|
-
output.print(f"OK
|
|
149
|
+
s.sql.insert_rows("fact_sales_order_line", fact_rows)
|
|
150
|
+
output.print(f"OK fact_sales_order_line 插入 {len(fact_rows)} 行")
|
|
114
151
|
|
|
152
|
+
# 4. 完成
|
|
115
153
|
summary = {
|
|
116
154
|
"ok": True,
|
|
117
155
|
"space_id": space_id,
|
|
156
|
+
"dim_date": len(dim_date_rows),
|
|
118
157
|
"products": len(products),
|
|
119
158
|
"customers": len(customers),
|
|
120
159
|
"channels": len(channels),
|
|
121
|
-
"fact_inserted":
|
|
160
|
+
"fact_inserted": len(fact_rows),
|
|
122
161
|
}
|
|
123
162
|
output.success("灌数完成")
|
|
124
|
-
output.print("__JSON_SUMMARY__" + json.dumps(summary, ensure_ascii=
|
|
163
|
+
output.print("__JSON_SUMMARY__" + json.dumps(summary, ensure_ascii=False, default=str))
|
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,53 +1,73 @@
|
|
|
1
|
-
# 提示词:本体函数设计
|
|
2
|
-
|
|
3
|
-
**提示词 ID**: `onto/function-design`
|
|
4
|
-
**场景**: 设计新的本体函数
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
你是一名搭子平台本体工程师。请根据以下需求设计一个本体函数(ontology function)。
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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`
|