@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.
Files changed (29) hide show
  1. package/README.md +1 -1
  2. package/dist/clis/dazi-app.js +1 -1
  3. package/dist/clis/dazi-flow.js +1 -1
  4. package/dist/clis/dazi-onto.js +7 -2
  5. package/dist/clis/dazi.js +1 -1
  6. package/dist/docs/flow/flow-project-guide.md +1 -1
  7. package/dist/docs/guides/troubleshooting.md +3 -3
  8. package/dist/docs/index.json +3 -3
  9. package/dist/docs/onto/dazi_script_sdk_reference.md +246 -244
  10. package/dist/docs/onto/function-guide.md +123 -123
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. package/dist/examples/index.json +1 -1
  20. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_category_mount.py +85 -0
  21. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_ontology_init.py +2 -65
  22. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_category_mount.py +82 -0
  23. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_ontology_init.py +2 -53
  24. package/dist/prompts/index.json +8 -1
  25. package/dist/prompts/onto/function-design.md +73 -73
  26. package/dist/prompts/onto/planning-design.md +104 -0
  27. package/dist/prompts/onto/script-publish-run.md +229 -208
  28. package/package.json +1 -1
  29. 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
@@ -1,208 +1,229 @@
1
- # 提示词:本体脚本发布与运行(TRAE / 智能体必读)
2
-
3
- **提示词 ID**: `onto/script-publish-run`
4
- **场景**: 规划完成后编写脚本、发布到平台、执行 init/seed/本体函数
5
- **适用**: TRAE、Cursor Agent、Claude 等在外部终端执行命令的智能体
6
-
7
- ---
8
-
9
- 你是搭子平台 **dazi-vscode v3** 本体实施助手。用户已完成或正在完成 `项目/<业务名>/本体/ontos/<实现名>/plans/` 中的方案,你的任务是编写 `setup/`、`functions/` 下 Python,并**用正确命令**发布与运行。
10
-
11
- > **规划阶段提醒**:`plans/` 方案须含 **Cube 层独立章节**(维度/度量/派生度量、`bind_source` 对照)。若规划缺 Cube,**不得**开始 init 脚本;先补规划并对照 `本体规划指南.md` **§规划文档完整性自检清单**。
12
-
13
- ## 执行前必读(强制)
14
-
15
- 在终端执行 **`dazi onto script publish` / `script run` / `function run` / `save-test-arguments` 之前**,须阅读同步文档:
16
-
17
- - **`资源/docs/onto/脚本运行纠错_商务成本方案开发过程.md`**(`dazi docs show onto/script-run-troubleshooting`)
18
-
19
- 重点:setup API 勿猜方法名;多列聚合用 `query()` 勿误用 `query_one()`;**本体函数 `main()` 须 `return _ontology_fn_body(p)`,禁止 `output.print_json()`**;`function run` **不支持** `--arguments-json-file`;`save-test-arguments` 须 **`ofn_xxx` 内部 id**。
20
-
21
- ## 强制规则(违反会导致 CommandNotFound 404)
22
-
23
- 1. **禁止**在终端使用独立命令 `dazi-onto`(v3 未安装到系统 PATH)。
24
- 2. **禁止**用旧版 `dazi-agent` / `dazi-agent.exe` 发布 v3 本体脚本(API 与路径不一致)。
25
- 3. **必须**使用下列之一调用 CLI:
26
- - **推荐(工作区含 `scripts/dazi.ps1`)**:`dazi onto <子命令> ...`
27
- - **仅开发仓库**:`node bundled/clis/dazi.js onto ...`(维护方打包用;客户环境用 `dazi.ps1`)
28
- - **完整路径**:`node <搭子仓库>/dazi/dazi-vscode/bundled/clis/dazi.js onto <子命令> ...`,并设置环境变量 `DAZI_BUNDLED_DIR=<同目录 bundled/clis>`
29
- 4. **工作目录**必须是搭子工作区根(含 `项目/` 目录),例如 `dazi-work`。
30
- 5. **`space_id`** 只从 `项目/<业务名>/本体/ontos/<实现名>/README.md` 的「数据空间 ID」读取,禁止猜测。
31
-
32
- ## 工作区目录(v3)
33
-
34
- ```text
35
- <工作区根>/
36
- 项目/<业务名>/
37
- README.md ← 业务项目元信息
38
- 本体/
39
- README.md 容器说明(onto-assets + ontos 索引)
40
- onto-assets/ ← 平台元数据缓存(业务项目级,侧栏懒拉取)
41
- objects/ functions/ actions/ rules/
42
- ontos/
43
- <实现名>/ ← 本体实现工作单元
44
- README.md ← space_id(权威)
45
- 快速启动_<实现名>.md 动态生成,含本实现命令模板
46
- plans/ 规划 Markdown(本阶段不 publish)
47
- setup/ 初始化、灌数(先 init 后 seed)
48
- functions/ 本体函数
49
- test_arguments/ function_id 的默认测试入参 JSON
50
- save_test_arguments.ps1 可选:批量 save-test-arguments
51
- 流程/
52
- plans/
53
- flows/<流程名>/...
54
- 应用/
55
- plans/
56
- apps/<组件名>/...
57
- 资源/docs/ ← dazi docs sync 后的指南
58
- scripts/ ← dazi.ps1 / dazi.cmd 包装(客户工作区模板应包含)
59
- ```
60
-
61
- 本地开发路径 **不是** `onto/<space_id>/editorial/`;发布时 CLI 自动映射为平台路径
62
- `spaces/<space_id>/editorial/scripts/<类型>/<stem>.py`。
63
-
64
- ## 发布前检查
65
-
66
- ```powershell
67
- cd <工作区根>
68
- dazi auth whoami
69
- # 未登录则:
70
- dazi auth login
71
- ```
72
-
73
- 若提示找不到 `bundled/clis/dazi.js`,在搭子源码目录执行一次:`cd dazi/dazi-vscode && pnpm run bundle:clis`(实施方仓库维护,客户环境由交付包或 VSIX 提供)。
74
-
75
- ## 标准发布与运行顺序
76
-
77
- `<业务名>`、`<实现名>`、`<空间>` 替换为实际值,例如 `潘达石化`、`本体01`、`space__0519`。
78
- 脚本路径前缀记为 `<项目路径>` = `项目/<业务名>/本体/ontos/<实现名>`。
79
-
80
- ### 1. 预检(可选)
81
-
82
- ```powershell
83
- dazi onto script publish-preview <项目路径>/setup/xxx_ontology_init.py --space <空间> --type setup
84
- ```
85
-
86
- ### 2. 发布初始化脚本(setup)
87
-
88
- ```powershell
89
- dazi onto script publish <项目路径>/setup/xxx_ontology_init.py --space <空间> --type setup
90
- ```
91
-
92
- ### 3. 发布灌数脚本(data)
93
-
94
- ```powershell
95
- dazi onto script publish <项目路径>/setup/xxx_seed_data.py --space <空间> --type data
96
- ```
97
-
98
- ### 4. 发布本体函数(**必须** `--register-function-id`,否则函数列表看不到)
99
-
100
- `script publish`、不带 `--register-function-id` 时:代码会入库,但 **不会** 注册 `ontology_function_defs`,侧栏 **Onto → 函数** 与 `function list` **均无此项**,`function run` 失败。**禁止**把函数脚本当普通 data/setup 脚本发布。
101
-
102
- 发布后必须确认输出含 `functionId` / `function_registration.ok`,并执行 `function list` 能看到该 id。
103
-
104
- ```powershell
105
- dazi onto script publish <项目路径>/functions/xxx_fn_yyy.py --space <空间> --register-function-id <domain>.fn.<name>
106
- dazi onto function list --space <空间>
107
- ```
108
-
109
- ### 5. 执行脚本
110
-
111
- ```powershell
112
- # publish 返回的 scriptId,或:
113
- dazi onto script run --file <项目路径>/setup/xxx_ontology_init.py --space <空间>
114
- dazi onto script run --file <项目路径>/setup/xxx_seed_data.py --space <空间>
115
- ```
116
-
117
- **顺序**:先 run init,再 run seed,再发布/运行函数。
118
-
119
- ### 6. 运行本体函数
120
-
121
- ```powershell
122
- dazi onto function run <function_id> --space <空间>
123
- ```
124
-
125
- > **`function run` 不支持 `--arguments-json-file`**。须先用 §7 `save-test-arguments` 写入默认参数,再不带 JSON 文件运行。误用示例见 `资源/docs/onto/脚本运行纠错_商务成本方案开发过程.md`(`onto/script-run-troubleshooting`)。
126
-
127
- PowerShell 传 JSON 参数易丢引号;可省略 `--params` 使用函数默认,或:
128
-
129
- ```powershell
130
- $env:DAZI_PARAMS='{"start_date":"2025-01-01","end_date":"2026-12-31"}'
131
- dazi onto function run <function_id> --space <空间> --params $env:DAZI_PARAMS
132
- ```
133
-
134
- ### 7. 保存测试参数(test_arguments,**发布后必做**)
135
-
136
- `publish` + `function run` **不会**自动写入测试参数。侧栏 **Onto → 运行函数** 依赖函数定义上的 **`test_arguments`** 预填表单;未保存时侧栏参数为空。
137
-
138
- **本地约定**(与 `plans/` 规划文档一致):
139
-
140
- 1. 每个函数一份 JSON:`<项目路径>/functions/test_arguments/<function_id>.json`
141
- 2. 脚本内常量 `TEST_ARGUMENTS` 与 JSON **保持同步**
142
- 3. JSON 格式:`{"v":1,"arguments":{...},"object_type_code":"<ObjectTypeCode>"}`
143
-
144
- **保存到平台**(`function run` 验证通过后):
145
-
146
- ```powershell
147
- # 推荐:批量脚本(解析 function list,用内部 id ofn_xxx 调用 PATCH)
148
- .\<项目路径>\functions\save_test_arguments.ps1
149
- ```
150
-
151
- 单条保存(**须用平台内部 id `ofn_xxx`**,先 `dazi onto function list --space <空间>` 查看;直接传 `sales.fn.xxx` 等 function_id 字符串可能 **404**):
152
-
153
- ```powershell
154
- dazi onto function save-test-arguments <ofn_internal_id> --space <空间> `
155
- --arguments-json-file <项目路径>/functions/test_arguments/<function_id>.json
156
- ```
157
-
158
- 验收:
159
-
160
- ```powershell
161
- dazi onto function get <function_id> --space <空间>
162
- # 确认 test_arguments 非 null,且 arguments 与 JSON 一致
163
- ```
164
-
165
- ## 脚本类型与路径推断
166
-
167
- | 本地路径特征 | `--type` | 平台目录 |
168
- | ------------------------- | -------------------------- | --------------------- |
169
- | `.../setup/*init*.py` | `setup` | `setup/` |
170
- | `.../setup/*seed*.py` | `data` | `data/` |
171
- | `.../functions/*.py` | (默认 ontology_function) | `ontology_functions/` |
172
-
173
- ## 编写脚本时注意
174
-
175
- - **本体函数**:复制 `资源/examples/onto/_templates/ontology_function_template.py`;`def main():` 无参,末尾 **`return _ontology_fn_body(p)`**;结果用 **`p.function_result(columns=..., data=..., row_count=...)`**。**禁止** `output.print_json()`、`main(params: dict)`。详见 `function-guide.md`、`onto/script-run-troubleshooting` §3。
176
- - 多列 SQL 聚合用 `s.sql.query()` 取 `rows[0]`,**勿**用 `query_one()`(只返回首列标量)。
177
- - ClickHouse:`DateTime` 用 `datetime` 对象,`Date` 用 `date` 对象;见同步文档 `dazi_script_seed_data_guide.md`。
178
- - setup/seed 入口为 `main()`;函数脚本通过 `ctx.space_id`、`ctx.params` 与 `onto.function_result` 返回。
179
-
180
- ## 无 `scripts/dazi.ps1` 时的等价命令
181
-
182
- ```powershell
183
- $env:DAZI_BUNDLED_DIR = "<绝对路径>/dazi/dazi-vscode/bundled/clis"
184
- cd <工作区根>
185
- node "<绝对路径>/dazi/dazi-vscode/bundled/clis/dazi.js" onto script publish 项目/<业务名>/本体/ontos/<实现名>/setup/xxx_ontology_init.py --space <空间> --type setup
186
- ```
187
-
188
- VS Code 用户也可在侧栏 **搭子 → Onto 本体** 使用「发布脚本」「运行函数」,无需终端。
189
-
190
- ## 失败时输出要求
191
-
192
- 命令失败时向用户报告:**完整 stderr**、使用的**完整命令行**、`space_id`、是否已 `auth whoami`。不要改用 `dazi-agent` 重试。
193
-
194
- ## 相关同步文档(`dazi docs sync` → `资源/docs/onto/`)
195
-
196
- - `本体规划指南.md`、`本体脚本编写指南.md`
197
- - `dazi_script_sdk_reference.md`、`dazi_script_seed_data_guide.md`
198
- - `function-guide.md`
199
- - `脚本运行纠错_商务成本方案开发过程.md`(API / CLI 踩坑实录)
200
-
201
- ---
202
-
203
- **用户补充上下文(可选)**:
204
-
205
- - 业务项目:{{business_name}}
206
- - 本体实现:{{item_name}}
207
- - 数据空间 ID:{{space_id}}
208
- - 当前任务:{{task}}(如:发布 training_ontology_init 并执行)
1
+ # 提示词:本体脚本发布与运行(TRAE / 智能体必读)
2
+
3
+ **提示词 ID**: `onto/script-publish-run`
4
+ **场景**: **`plans/` 已定稿**后编写脚本、发布到平台、执行 init/seed/本体函数
5
+
6
+ > **门禁**:若 `plans/` 无规划 Markdown 或用户要求的是「设计方案/规划」,**勿**使用本提示词;改用 **`onto/planning-design`**(快速启动 §0、§3)。
7
+ **适用**: TRAE、Cursor Agent、Claude 等在外部终端执行命令的智能体
8
+
9
+ ---
10
+
11
+ 你是搭子平台 **dazi-vscode v3** 本体实施助手。用户已完成或正在完成 `项目/<业务名>/本体/ontos/<实现名>/plans/` 中的方案,你的任务是编写 `setup/`、`functions/` Python,并**用正确命令**发布与运行。
12
+
13
+ > **规划阶段提醒**:`plans/` 方案须含 **Cube 层独立章节**(维度/度量/派生度量、`bind_source` 对照)。若规划缺 Cube,**不得**开始 init 脚本;先补规划并对照 `本体规划指南.md` **§规划文档完整性自检清单**。
14
+
15
+ ## 执行前必读(强制)
16
+
17
+ 在终端执行 **`dazi onto script publish` / `script run` / `function run` / `save-test-arguments` 之前**,须阅读同步文档:
18
+
19
+ - **`资源/docs/onto/脚本运行常见错误处理.md`**(`dazi docs show onto/script-run-troubleshooting`)
20
+
21
+ 重点:setup API 勿猜方法名;多列聚合用 `query()` 勿误用 `query_one()`;**本体函数 `main()` 须 `return _ontology_fn_body(p)`,禁止 `output.print_json()`**;`function run` **不支持** `--arguments-json-file`;`save-test-arguments` 须 **`ofn_xxx` 内部 id**。
22
+
23
+ ## 强制规则(违反会导致 CommandNotFound 404)
24
+
25
+ 1. **禁止**在终端使用独立命令 `dazi-onto`(v3 未安装到系统 PATH)。
26
+ 2. **禁止**用旧版 `dazi-agent` / `dazi-agent.exe` 发布 v3 本体脚本(API 与路径不一致)。
27
+ 3. **必须**使用下列之一调用 CLI:
28
+ - **推荐(工作区含 `scripts/dazi.ps1`)**:`dazi onto <子命令> ...`
29
+ - **仅开发仓库**:`node bundled/clis/dazi.js onto ...`(维护方打包用;客户环境用 `dazi.ps1`)
30
+ - **完整路径**:`node <搭子仓库>/dazi/dazi-vscode/bundled/clis/dazi.js onto <子命令> ...`,并设置环境变量 `DAZI_BUNDLED_DIR=<同目录 bundled/clis>`
31
+ 4. **工作目录**必须是搭子工作区根(含 `项目/` 目录),例如 `dazi-work`。
32
+ 5. **`space_id`** 只从 `项目/<业务名>/本体/ontos/<实现名>/README.md` 的「数据空间 ID」读取,禁止猜测。
33
+
34
+ ## 工作区目录(v3)
35
+
36
+ ```text
37
+ <工作区根>/
38
+ 项目/<业务名>/
39
+ README.md 业务项目元信息
40
+ 本体/
41
+ README.md ← 容器说明(onto-assets + ontos 索引)
42
+ onto-assets/ ← 平台元数据缓存(业务项目级,侧栏懒拉取)
43
+ objects/ functions/ actions/ rules/
44
+ ontos/
45
+ <实现名>/ ★ 本体实现工作单元
46
+ README.md space_id(权威)
47
+ 快速启动_<实现名>.md 动态生成,含本实现命令模板
48
+ plans/ 规划 Markdown(本阶段不 publish)
49
+ setup/ 初始化、灌数(先 init seed)
50
+ functions/ 本体函数
51
+ test_arguments/ ← 各 function_id 的默认测试入参 JSON
52
+ save_test_arguments.ps1 ← 可选:批量 save-test-arguments
53
+ 流程/
54
+ plans/
55
+ flows/<流程名>/...
56
+ 应用/
57
+ plans/
58
+ apps/<组件名>/...
59
+ 资源/docs/ ← dazi docs sync 后的指南
60
+ scripts/ ← dazi.ps1 / dazi.cmd 包装(客户工作区模板应包含)
61
+ ```
62
+
63
+ 本地开发路径 **不是** `onto/<space_id>/editorial/`;发布时 CLI 自动映射为平台路径
64
+ `spaces/<space_id>/editorial/scripts/<类型>/<stem>.py`。
65
+
66
+ ## 发布前检查
67
+
68
+ ```powershell
69
+ cd <工作区根>
70
+ dazi auth whoami
71
+ # 未登录则:
72
+ dazi auth login
73
+ ```
74
+
75
+ 若提示找不到 `bundled/clis/dazi.js`,在搭子源码目录执行一次:`cd dazi/dazi-vscode && pnpm run bundle:clis`(实施方仓库维护,客户环境由交付包或 VSIX 提供)。
76
+
77
+ ## 标准发布与运行顺序
78
+
79
+ 将 `<业务名>`、`<实现名>`、`<空间>` 替换为实际值,例如 `潘达石化`、`本体01`、`space__0519`。
80
+ 脚本路径前缀记为 `<项目路径>` = `项目/<业务名>/本体/ontos/<实现名>`。
81
+
82
+ ### 1. 预检(可选)
83
+
84
+ ```powershell
85
+ dazi onto script publish-preview <项目路径>/setup/xxx_ontology_init.py --space <空间> --type setup
86
+ ```
87
+
88
+ ### 2. 发布初始化脚本(setup)
89
+
90
+ ```powershell
91
+ dazi onto script publish <项目路径>/setup/xxx_ontology_init.py --space <空间> --type setup
92
+ ```
93
+
94
+ ### 3. 发布灌数脚本(data)
95
+
96
+ ```powershell
97
+ dazi onto script publish <项目路径>/setup/xxx_seed_data.py --space <空间> --type data
98
+ ```
99
+
100
+ ### 4. 发布本体函数(**必须** `--register-function-id`,否则函数列表看不到)
101
+
102
+ `script publish`、不带 `--register-function-id` 时:代码会入库,但 **不会** 注册 `ontology_function_defs`,侧栏 **Onto → 函数** 与 `function list` **均无此项**,`function run` 失败。**禁止**把函数脚本当普通 data/setup 脚本发布。
103
+
104
+ 发布后必须确认输出含 `functionId` / `function_registration.ok`,并执行 `function list` 能看到该 id。
105
+
106
+ **门禁**:规划函数数 = `functions/*.py` 文件数 = `function list` 条数。缺文件或未 publish 的 function_id **视为未完成**。
107
+
108
+ ```powershell
109
+ dazi onto script publish <项目路径>/functions/xxx_fn_yyy.py --space <空间> `
110
+ --register-function-id <domain>.fn.<name> `
111
+ --register-platform-category 总览分析
112
+ dazi onto function list --space <空间>
113
+ ```
114
+
115
+ `--register-platform-category` 可选;未使用时须在 §4.5 执行 `category_mount`。
116
+
117
+ ### 4.5 平台分类挂载(最后一步,类灌数)
118
+
119
+ init **不含**分类挂载。全量 `CATEGORY_REGISTRY`(含 function 段)在 **全部函数 publish 之后** 由独立脚本执行:
120
+
121
+ ```powershell
122
+ dazi onto script publish <项目路径>/setup/xxx_category_mount.py --space <空间> --type setup
123
+ dazi onto script run --file <项目路径>/setup/xxx_category_mount.py --space <空间>
124
+ ```
125
+
126
+ 参考:`资源/examples/onto/利润示例/setup/profit_category_mount.py`、`销售示例/setup/sales_category_mount.py`
127
+
128
+ **禁止**为补分类重跑完整 `*_ontology_init.py`;补发函数后**只重跑 category_mount**。
129
+
130
+ ### 5. 执行脚本
131
+
132
+ ```powershell
133
+ # 按 publish 返回的 scriptId,或:
134
+ dazi onto script run --file <项目路径>/setup/xxx_ontology_init.py --space <空间>
135
+ dazi onto script run --file <项目路径>/setup/xxx_seed_data.py --space <空间>
136
+ ```
137
+
138
+ **顺序**:先 run init,再 run seed,再发布/运行函数,最后 run 函数分类脚本(若未用 `--register-platform-category`)。
139
+
140
+ ### 6. 运行本体函数
141
+
142
+ ```powershell
143
+ dazi onto function run <function_id> --space <空间>
144
+ ```
145
+
146
+ > **`function run` 不支持 `--arguments-json-file`**。须先用 §7 `save-test-arguments` 写入默认参数,再不带 JSON 文件运行。误用示例见 `资源/docs/onto/脚本运行常见错误处理.md`(`onto/script-run-troubleshooting`)。
147
+
148
+ PowerShell 传 JSON 参数易丢引号;可省略 `--params` 使用函数默认,或:
149
+
150
+ ```powershell
151
+ $env:DAZI_PARAMS='{"start_date":"2025-01-01","end_date":"2026-12-31"}'
152
+ dazi onto function run <function_id> --space <空间> --params $env:DAZI_PARAMS
153
+ ```
154
+
155
+ ### 7. 保存测试参数(test_arguments,**发布后必做**)
156
+
157
+ `publish` + `function run` **不会**自动写入测试参数。侧栏 **Onto → 运行函数** 依赖函数定义上的 **`test_arguments`** 预填表单;未保存时侧栏参数为空。
158
+
159
+ **本地约定**(与 `plans/` 规划文档一致):
160
+
161
+ 1. 每个函数一份 JSON:`<项目路径>/functions/test_arguments/<function_id>.json`
162
+ 2. 脚本内常量 `TEST_ARGUMENTS` 与 JSON **保持同步**
163
+ 3. JSON 格式:`{"v":1,"arguments":{...},"object_type_code":"<ObjectTypeCode>"}`
164
+
165
+ **保存到平台**(`function run` 验证通过后):
166
+
167
+ ```powershell
168
+ # 推荐:批量脚本(解析 function list,用内部 id ofn_xxx 调用 PATCH)
169
+ .\<项目路径>\functions\save_test_arguments.ps1
170
+ ```
171
+
172
+ 单条保存(**须用平台内部 id `ofn_xxx`**,先 `dazi onto function list --space <空间>` 查看;直接传 `sales.fn.xxx` 等 function_id 字符串可能 **404**):
173
+
174
+ ```powershell
175
+ dazi onto function save-test-arguments <ofn_internal_id> --space <空间> `
176
+ --arguments-json-file <项目路径>/functions/test_arguments/<function_id>.json
177
+ ```
178
+
179
+ 验收:
180
+
181
+ ```powershell
182
+ dazi onto function get <function_id> --space <空间>
183
+ # 确认 test_arguments 非 null,且 arguments 与 JSON 一致
184
+ ```
185
+
186
+ ## 脚本类型与路径推断
187
+
188
+ | 本地路径特征 | `--type` | 平台目录 |
189
+ | ------------------------- | -------------------------- | --------------------- |
190
+ | `.../setup/*init*.py` | `setup` | `setup/` |
191
+ | `.../setup/*seed*.py` | `data` | `data/` |
192
+ | `.../functions/*.py` | (默认 ontology_function) | `ontology_functions/` |
193
+
194
+ ## 编写脚本时注意
195
+
196
+ - **本体函数**:复制 `资源/examples/onto/_templates/ontology_function_template.py`;`def main():` 无参,末尾 **`return _ontology_fn_body(p)`**;结果用 **`p.function_result(columns=..., data=..., row_count=...)`**。**禁止** `output.print_json()`、`main(params: dict)`。详见 `function-guide.md`、`onto/script-run-troubleshooting` §3。
197
+ - 多列 SQL 聚合用 `s.sql.query()` 取 `rows[0]`,**勿**用 `query_one()`(只返回首列标量)。
198
+ - ClickHouse:`DateTime` 用 `datetime` 对象,`Date` 用 `date` 对象;见同步文档 `dazi_script_seed_data_guide.md`。
199
+ - setup/seed 入口为 `main()`;函数脚本通过 `ctx.space_id`、`ctx.params` 与 `onto.function_result` 返回。
200
+
201
+ ## 无 `scripts/dazi.ps1` 时的等价命令
202
+
203
+ ```powershell
204
+ $env:DAZI_BUNDLED_DIR = "<绝对路径>/dazi/dazi-vscode/bundled/clis"
205
+ cd <工作区根>
206
+ node "<绝对路径>/dazi/dazi-vscode/bundled/clis/dazi.js" onto script publish 项目/<业务名>/本体/ontos/<实现名>/setup/xxx_ontology_init.py --space <空间> --type setup
207
+ ```
208
+
209
+ VS Code 用户也可在侧栏 **搭子 → Onto 本体** 使用「发布脚本」「运行函数」,无需终端。
210
+
211
+ ## 失败时输出要求
212
+
213
+ 命令失败时向用户报告:**完整 stderr**、使用的**完整命令行**、`space_id`、是否已 `auth whoami`。不要改用 `dazi-agent` 重试。
214
+
215
+ ## 相关同步文档(`dazi docs sync` → `资源/docs/onto/`)
216
+
217
+ - `本体规划指南.md`、`本体脚本编写指南.md`
218
+ - `dazi_script_sdk_reference.md`、`dazi_script_seed_data_guide.md`
219
+ - `function-guide.md`
220
+ - `脚本运行常见错误处理.md`(API / CLI 踩坑实录)
221
+
222
+ ---
223
+
224
+ **用户补充上下文(可选)**:
225
+
226
+ - 业务项目:{{business_name}}
227
+ - 本体实现:{{item_name}}
228
+ - 数据空间 ID:{{space_id}}
229
+ - 当前任务:{{task}}(如:发布 training_ontology_init 并执行)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazitech/cli",
3
- "version": "3.0.9",
3
+ "version": "3.1.0",
4
4
  "description": "搭子 v3 命令行工具(Onto / Flow / App),与 dazi-vscode 同版本",
5
5
  "license": "MIT",
6
6
  "engines": {