@dazitech/cli 3.0.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/LICENSE +21 -0
- package/README.md +104 -0
- package/dist/bin/dazi-app.cjs +4 -0
- package/dist/bin/dazi-flow.cjs +4 -0
- package/dist/bin/dazi-onto.cjs +4 -0
- package/dist/bin/dazi.cjs +4 -0
- package/dist/bin/run-cli-bin.cjs +62 -0
- package/dist/clis/dazi-app.js +16697 -0
- package/dist/clis/dazi-flow.js +6093 -0
- package/dist/clis/dazi-onto.js +3948 -0
- package/dist/clis/dazi.js +5677 -0
- package/dist/docs/app/app-init.md +69 -0
- package/dist/docs/app/build-upload.md +77 -0
- package/dist/docs/app/release-guide.md +51 -0
- package/dist/docs/app//344/270/273/350/246/201/350/264/242/345/212/241/346/214/207/346/240/207/345/244/215/346/235/202/346/212/245/350/241/250/345/274/200/345/217/221/345/256/236/350/267/265.md +261 -0
- package/dist/docs/auth/auth-login.md +41 -0
- package/dist/docs/auth/token-management.md +42 -0
- package/dist/docs/data/cube-guide.md +23 -0
- package/dist/docs/data/data-spaces.md +30 -0
- package/dist/docs/data/table-preview.md +41 -0
- package/dist/docs/flow/flow-project-guide.md +505 -0
- package/dist/docs/flow/flows-guide.md +302 -0
- package/dist/docs/flow/node-code-guide.md +399 -0
- package/dist/docs/flow/plan-guide.md +59 -0
- package/dist/docs/flow/run-guide.md +98 -0
- package/dist/docs/flow/source-guide.md +44 -0
- package/dist/docs/flow/variables-guide.md +406 -0
- package/dist/docs/flow//346/265/201/347/250/213/345/274/200/345/217/221/346/234/200/344/275/263/345/256/236/350/267/265-VS-flow0/346/241/210/344/276/213.md +344 -0
- package/dist/docs/guides/cli-invocation.md +93 -0
- package/dist/docs/guides/cli-reference.md +98 -0
- package/dist/docs/guides/mcp-setup.md +89 -0
- package/dist/docs/guides/migrate-v2-v3.md +54 -0
- package/dist/docs/guides/quickstart.md +77 -0
- package/dist/docs/guides/troubleshooting.md +82 -0
- package/dist/docs/guides/workspace-v3.md +53 -0
- package/dist/docs/index.json +204 -0
- package/dist/docs/onto/action-guide.md +48 -0
- package/dist/docs/onto/dazi_script_sdk_reference.md +168 -0
- package/dist/docs/onto/dazi_script_seed_data_guide.md +155 -0
- package/dist/docs/onto/function-guide.md +68 -0
- package/dist/docs/onto/rule-guide.md +52 -0
- package/dist/docs/onto/space-management.md +46 -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 +145 -0
- package/dist/docs/onto//346/234/254/344/275/223/350/247/204/345/210/222/346/214/207/345/215/227.md +131 -0
- 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 +541 -0
- package/dist/examples/index.json +36 -0
- package/dist/examples/onto/function/profit_fn_customer_segmentation.py +117 -0
- package/dist/examples/onto/function/profit_fn_mom_analysis.py +89 -0
- package/dist/examples/onto/function/profit_fn_top_products.py +89 -0
- package/dist/examples/onto/function/profit_fn_yoy_analysis.py +89 -0
- package/dist/examples/onto/setup/profit_ontology_init.py +388 -0
- package/dist/prompts/app/ui-design.md +48 -0
- package/dist/prompts/data/data-analysis.md +42 -0
- package/dist/prompts/data/sql-query.md +36 -0
- package/dist/prompts/flow/flow-design.md +77 -0
- package/dist/prompts/flow/plan-generate.md +61 -0
- package/dist/prompts/flow/run-debug.md +66 -0
- package/dist/prompts/flow/run-fix-loop.md +77 -0
- package/dist/prompts/general/ask-dazi.md +30 -0
- package/dist/prompts/general/code-review.md +31 -0
- package/dist/prompts/general/troubleshoot.md +41 -0
- package/dist/prompts/index.json +20 -0
- package/dist/prompts/onto/action-design.md +47 -0
- package/dist/prompts/onto/function-design.md +44 -0
- package/dist/prompts/onto/rule-seed.md +41 -0
- package/dist/prompts/onto/script-publish-run.md +146 -0
- package/package.json +27 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# 快速开始
|
|
2
|
+
|
|
3
|
+
**文档 ID**: `guides/quickstart`
|
|
4
|
+
**适用版本**: dazi-vscode v3.0+
|
|
5
|
+
|
|
6
|
+
> CLI 调用约定见 **[CLI 调用约定](./cli-invocation.md)**。生产环境在 `dazi-work` 根目录使用 `.\scripts\dazi.ps1`。
|
|
7
|
+
|
|
8
|
+
## 5 分钟完成首次配置
|
|
9
|
+
|
|
10
|
+
### 1. 安装扩展
|
|
11
|
+
|
|
12
|
+
在 VS Code / Cursor 中安装 **搭子** 扩展,或通过 `.vsix`:
|
|
13
|
+
|
|
14
|
+
```powershell
|
|
15
|
+
code --install-extension dazi-vscode-3.x.x.vsix
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### 2. 打开工作区
|
|
19
|
+
|
|
20
|
+
将 **`dazi-work`** 文件夹作为 VS Code 工作区根目录打开(含 `项目/`、`资源/`、`scripts/`)。
|
|
21
|
+
DRAP 应用项目位于 **`项目/app_<名称>/`**(完整 monorepo,见 [§331](../../docs/331-应用项目多项目与组件重构.md));不再要求根目录必须有 `runtime-apps/`。
|
|
22
|
+
|
|
23
|
+
### 3. 自检 CLI
|
|
24
|
+
|
|
25
|
+
```powershell
|
|
26
|
+
cd D:\path\to\dazi-work
|
|
27
|
+
.\scripts\doctor-cli.ps1
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
应解析到已安装扩展内的 `bundled/clis/dazi.js`(无需 monorepo 源码)。
|
|
31
|
+
|
|
32
|
+
### 4. 配置服务地址
|
|
33
|
+
|
|
34
|
+
在 VS Code 设置中搜索 `dazi.serverUrl`,填入搭子平台地址:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
https://your-dazi-server.example.com
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 5. 登录
|
|
41
|
+
|
|
42
|
+
在命令面板(`Ctrl+Shift+P`)搜索 **搭子: 登录**,或终端:
|
|
43
|
+
|
|
44
|
+
```powershell
|
|
45
|
+
.\scripts\dazi.ps1 auth login
|
|
46
|
+
# 或直接绑定 Token
|
|
47
|
+
.\scripts\dazi.ps1 auth set-token --token "your-jwt-token"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 6. 初始化工作区
|
|
51
|
+
|
|
52
|
+
```powershell
|
|
53
|
+
# 新项目(本体空间)
|
|
54
|
+
.\scripts\dazi.ps1 onto space init --space-id <your-space-id>
|
|
55
|
+
|
|
56
|
+
# 已有 v2 项目迁移
|
|
57
|
+
.\scripts\dazi.ps1 migrate workspace
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 7. 验证环境
|
|
61
|
+
|
|
62
|
+
```powershell
|
|
63
|
+
.\scripts\dazi.ps1 doctor
|
|
64
|
+
.\scripts\dazi.ps1 env
|
|
65
|
+
.\scripts\dazi.ps1 auth whoami
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
侧栏「搭子」图标应显示 6 个节点:帮助、数据资源、本体、流程、应用、工作区。
|
|
69
|
+
|
|
70
|
+
## 下一步
|
|
71
|
+
|
|
72
|
+
- [CLI 调用约定](./cli-invocation.md)
|
|
73
|
+
- [认证管理](../auth/auth-login.md)
|
|
74
|
+
- [本体开发入门](../onto/space-management.md)
|
|
75
|
+
- [数据流程项目开发](../flow/flow-project-guide.md) — **推荐**:`项目/flow_*`、菜单、pull/push
|
|
76
|
+
- [节点代码编写](../flow/node-code-guide.md) — python-script、sql-query 等
|
|
77
|
+
- [流程开发索引](../flow/flows-guide.md) — Flow 文档入口
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# 故障排查
|
|
2
|
+
|
|
3
|
+
**文档 ID**: `guides/troubleshooting`
|
|
4
|
+
|
|
5
|
+
> 终端命令统一使用 **`dazi-work` 根目录** 下的 `.\scripts\dazi.ps1`(见 [CLI 调用约定](./cli-invocation.md))。
|
|
6
|
+
|
|
7
|
+
## CLI 命令找不到(优先排查)
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
cd D:\path\to\dazi-work
|
|
11
|
+
.\scripts\doctor-cli.ps1
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
常见原因:
|
|
15
|
+
|
|
16
|
+
| 原因 | 处理 |
|
|
17
|
+
|------|------|
|
|
18
|
+
| 未安装 `dazi-vscode.vsix` | 安装扩展后重跑 doctor-cli |
|
|
19
|
+
| **Trae 已装扩展但 doctor 报未安装** | Trae 扩展在 `%USERPROFILE%\.trae\extensions`;更新 `dazi-work/scripts` 后重跑 doctor,或 `.\scripts\sync-clis-from-extension.ps1` |
|
|
20
|
+
| 扩展在但 `bundled/clis/dazi.js` 缺失 | 用完整 `pnpm run vsix` 重打包装;勿用缺 bundled 的旧包 |
|
|
21
|
+
| 直接输入 `dazi` / `dazi-onto` | 改用 `.\scripts\dazi.ps1 ...`(无全局 `dazi-onto`) |
|
|
22
|
+
| 未安装 Node.js 18+ | 安装 Node 并加入 PATH |
|
|
23
|
+
|
|
24
|
+
环境详情:
|
|
25
|
+
|
|
26
|
+
```powershell
|
|
27
|
+
.\scripts\dazi.ps1 doctor
|
|
28
|
+
.\scripts\dazi.ps1 env
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 401 未授权
|
|
32
|
+
|
|
33
|
+
```powershell
|
|
34
|
+
.\scripts\dazi.ps1 auth whoami
|
|
35
|
+
.\scripts\dazi.ps1 auth login
|
|
36
|
+
.\scripts\dazi.ps1 auth set-token --token "<new-token>"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Token 保存在 `~/.dazi/auth.json`,检查是否过期。
|
|
40
|
+
|
|
41
|
+
## 扩展侧栏空白
|
|
42
|
+
|
|
43
|
+
1. 检查 `dazi.serverUrl` 配置是否正确
|
|
44
|
+
2. 执行 `.\scripts\dazi.ps1 auth whoami` 确认登录状态
|
|
45
|
+
3. 右键侧栏节点选「刷新」
|
|
46
|
+
|
|
47
|
+
## 工作区目录找不到
|
|
48
|
+
|
|
49
|
+
```powershell
|
|
50
|
+
.\scripts\dazi.ps1 doctor --workspace-root D:\path\to\dazi-work
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
或在 VS Code 设置中配置 `dazi.workspaceRoot`。
|
|
54
|
+
|
|
55
|
+
## 从 v2 迁移后命令不匹配
|
|
56
|
+
|
|
57
|
+
| 旧命令 | v3 命令(dazi-work 根目录) |
|
|
58
|
+
|--------|----------------------------|
|
|
59
|
+
| `dazi-agent snapshot refresh` | `.\scripts\dazi.ps1 onto space snapshot` |
|
|
60
|
+
| `dazi-agent function-def list` | `.\scripts\dazi.ps1 onto function list` |
|
|
61
|
+
| `dazi-agent flow snapshot pull` | `.\scripts\dazi.ps1 flow snapshot pull` |
|
|
62
|
+
|
|
63
|
+
## MCP 连不上
|
|
64
|
+
|
|
65
|
+
检查 `.cursor/mcp.json` 配置。MCP 需能调用 bundled CLI,示例:
|
|
66
|
+
|
|
67
|
+
```powershell
|
|
68
|
+
$env:DAZI_BUNDLED_DIR = "$env:USERPROFILE\.cursor\extensions\dazitech.dazi-vscode-3.0.0\bundled\clis"
|
|
69
|
+
node "$env:DAZI_BUNDLED_DIR\dazi.js" mcp stdio
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
或使用 `.\scripts\dazi.ps1 mcp stdio`(在 dazi-work 根目录)。
|
|
73
|
+
|
|
74
|
+
## DRAP:`dazi-app` 找不到
|
|
75
|
+
|
|
76
|
+
```powershell
|
|
77
|
+
cd D:\path\to\dazi-work\项目\app_<名称>
|
|
78
|
+
pnpm install
|
|
79
|
+
pnpm run dazi-app -- --version
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
应用 CLI 由 bundled + 启动器提供,**不需要** monorepo 源码。
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# 工作区 v3 规范
|
|
2
|
+
|
|
3
|
+
**文档 ID**: `guides/workspace-v3`
|
|
4
|
+
**适用版本**: dazi-vscode v3.0+
|
|
5
|
+
**最后更新**: 2026-05-28(应用项目 `项目/app_*`)
|
|
6
|
+
|
|
7
|
+
## 目录结构(搭子工作区,如 dazi-work)
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
<workspace>/
|
|
11
|
+
├── 项目/
|
|
12
|
+
│ ├── onto_<名称>/ ← 本体项目(规划、脚本、快速启动)
|
|
13
|
+
│ └── app_<名称>/ ← ★ 应用项目 = DRAP monorepo(sdk、templates、apps)
|
|
14
|
+
├── 资源/ ← 帮助文档、提示词等(dazi docs sync)
|
|
15
|
+
├── scripts/ ← dazi.ps1、doctor-cli(终端 CLI 包装)
|
|
16
|
+
├── tools/dazi-clis/ ← 可选:离线 bundled CLI 副本
|
|
17
|
+
└── (可选)runtime-apps/ ← 兼容旧布局;可与 项目/app_* 并存
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
> v3.1+ **推荐**在 `项目/app_<名称>/` 下维护 DRAP,由扩展「新建应用项目」生成。详见 [§331](../../docs/331-应用项目多项目与组件重构.md)。
|
|
21
|
+
|
|
22
|
+
## 目录说明
|
|
23
|
+
|
|
24
|
+
| 路径 | 对应 CLI | 用途 |
|
|
25
|
+
|------|----------|------|
|
|
26
|
+
| `项目/onto_<名称>/` | `.\scripts\dazi.ps1 onto ...` | 本体规划、脚本、发布 |
|
|
27
|
+
| `项目/app_<名称>/` | `pnpm run dazi-app -- ...`(在应用项目根) | DRAP monorepo;组件在 `apps/<app_id>/` |
|
|
28
|
+
| `项目/app_<名称>/apps/<app_id>/` | 同上 + `--cwd apps/<app_id>` | 单个应用组件源码 |
|
|
29
|
+
| `资源/docs/` | `.\scripts\dazi.ps1 docs ...` | 同步后的内置文档 |
|
|
30
|
+
| `scripts/` | `.\scripts\dazi.ps1 ...` | 本体/流程/鉴权/数据(非 DRAP) |
|
|
31
|
+
| `~/.dazi/auth.json` | 共享 | 登录凭据(扩展与 CLI 共用) |
|
|
32
|
+
|
|
33
|
+
## 扩展侧栏对应
|
|
34
|
+
|
|
35
|
+
| 侧栏 | 工作区路径 |
|
|
36
|
+
|------|------------|
|
|
37
|
+
| 本体 | `项目/onto_*` |
|
|
38
|
+
| App 应用 | `项目/app_*`(monorepo)→ `apps/<app_id>` |
|
|
39
|
+
| 数据资源 | 平台数据空间(非目录) |
|
|
40
|
+
|
|
41
|
+
## v2 → v3 目录映射
|
|
42
|
+
|
|
43
|
+
| v2 | v3(搭子工作区) |
|
|
44
|
+
|----|----------------|
|
|
45
|
+
| `ontology/` | `项目/onto_*` |
|
|
46
|
+
| `runtime-apps/apps/*` | `项目/app_*/apps/*`(推荐)或 `<ws>/runtime-apps/apps/*`(兼容) |
|
|
47
|
+
| `.dazi-agent/auth.json` | `~/.dazi/auth.json` |
|
|
48
|
+
|
|
49
|
+
## 相关文档
|
|
50
|
+
|
|
51
|
+
- [§331 应用项目多项目与组件重构](../../docs/331-应用项目多项目与组件重构.md)
|
|
52
|
+
- [§333 本轮扩展总结](../../docs/333-dazi-vscode应用项目多项目与本轮优化总结.md)
|
|
53
|
+
- [CLI 调用约定](./cli-invocation.md)
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "3.0.0-beta.3",
|
|
3
|
+
"updatedAt": "2026-05-29T00:00:00.000Z",
|
|
4
|
+
"docs": [
|
|
5
|
+
{
|
|
6
|
+
"id": "guides/quickstart",
|
|
7
|
+
"title": "快速开始",
|
|
8
|
+
"category": "guides",
|
|
9
|
+
"file": "guides/quickstart.md"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "guides/cli-invocation",
|
|
13
|
+
"title": "CLI 调用约定",
|
|
14
|
+
"category": "guides",
|
|
15
|
+
"file": "guides/cli-invocation.md"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "guides/workspace-v3",
|
|
19
|
+
"title": "工作区 v3 规范",
|
|
20
|
+
"category": "guides",
|
|
21
|
+
"file": "guides/workspace-v3.md"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "guides/migrate-v2-v3",
|
|
25
|
+
"title": "从 v2 迁移到 v3",
|
|
26
|
+
"category": "guides",
|
|
27
|
+
"file": "guides/migrate-v2-v3.md"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "guides/cli-reference",
|
|
31
|
+
"title": "CLI 命令速查",
|
|
32
|
+
"category": "guides",
|
|
33
|
+
"file": "guides/cli-reference.md"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "guides/troubleshooting",
|
|
37
|
+
"title": "故障排查",
|
|
38
|
+
"category": "guides",
|
|
39
|
+
"file": "guides/troubleshooting.md"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "guides/mcp-setup",
|
|
43
|
+
"title": "MCP 配置指南",
|
|
44
|
+
"category": "guides",
|
|
45
|
+
"file": "guides/mcp-setup.md"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "auth/auth-login",
|
|
49
|
+
"title": "认证登录",
|
|
50
|
+
"category": "auth",
|
|
51
|
+
"file": "auth/auth-login.md"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "auth/token-management",
|
|
55
|
+
"title": "Token 管理",
|
|
56
|
+
"category": "auth",
|
|
57
|
+
"file": "auth/token-management.md"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "onto/space-management",
|
|
61
|
+
"title": "本体空间管理",
|
|
62
|
+
"category": "onto",
|
|
63
|
+
"file": "onto/space-management.md"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "onto/function-guide",
|
|
67
|
+
"title": "本体函数开发",
|
|
68
|
+
"category": "onto",
|
|
69
|
+
"file": "onto/function-guide.md"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "onto/action-guide",
|
|
73
|
+
"title": "本体动作(Action)开发",
|
|
74
|
+
"category": "onto",
|
|
75
|
+
"file": "onto/action-guide.md"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "onto/rule-guide",
|
|
79
|
+
"title": "本体规则管理",
|
|
80
|
+
"category": "onto",
|
|
81
|
+
"file": "onto/rule-guide.md"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": "onto/planning-guide",
|
|
85
|
+
"title": "本体规划指南",
|
|
86
|
+
"category": "onto",
|
|
87
|
+
"file": "onto/本体规划指南.md"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"id": "onto/planning-example-profit",
|
|
91
|
+
"title": "规划示例:利润分析本体",
|
|
92
|
+
"category": "onto",
|
|
93
|
+
"file": "onto/规划示例_利润分析本体方案.md"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "onto/script-authoring",
|
|
97
|
+
"title": "本体脚本编写指南(含发布)",
|
|
98
|
+
"category": "onto",
|
|
99
|
+
"file": "onto/本体脚本编写指南.md"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "onto/dazi-script-sdk-reference",
|
|
103
|
+
"title": "DaziScript SDK 参考",
|
|
104
|
+
"category": "onto",
|
|
105
|
+
"file": "onto/dazi_script_sdk_reference.md"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "onto/dazi-script-seed-data-guide",
|
|
109
|
+
"title": "DaziScript 灌数指南",
|
|
110
|
+
"category": "onto",
|
|
111
|
+
"file": "onto/dazi_script_seed_data_guide.md"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "flow/flow-project-guide",
|
|
115
|
+
"title": "数据流程项目开发指南",
|
|
116
|
+
"category": "flow",
|
|
117
|
+
"file": "flow/flow-project-guide.md"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"id": "flow/流程开发最佳实践-VS-flow0案例",
|
|
121
|
+
"title": "流程开发最佳实践(VS-flow0 案例)",
|
|
122
|
+
"category": "flow",
|
|
123
|
+
"file": "flow/流程开发最佳实践-VS-flow0案例.md"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"id": "flow/variables-guide",
|
|
127
|
+
"title": "流程变量系统指南",
|
|
128
|
+
"category": "flow",
|
|
129
|
+
"file": "flow/variables-guide.md"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"id": "flow/node-code-guide",
|
|
133
|
+
"title": "节点代码编写指南",
|
|
134
|
+
"category": "flow",
|
|
135
|
+
"file": "flow/node-code-guide.md"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "flow/flows-guide",
|
|
139
|
+
"title": "Flow 文档索引",
|
|
140
|
+
"category": "flow",
|
|
141
|
+
"file": "flow/flows-guide.md"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"id": "flow/run-guide",
|
|
145
|
+
"title": "Flow 运行管理",
|
|
146
|
+
"category": "flow",
|
|
147
|
+
"file": "flow/run-guide.md"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "flow/snapshot-guide",
|
|
151
|
+
"title": "Flow 快照管理",
|
|
152
|
+
"category": "flow",
|
|
153
|
+
"file": "flow/snapshot-guide.md"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "flow/source-guide",
|
|
157
|
+
"title": "数据源管理",
|
|
158
|
+
"category": "flow",
|
|
159
|
+
"file": "flow/source-guide.md"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"id": "flow/plan-guide",
|
|
163
|
+
"title": "Flow 执行计划",
|
|
164
|
+
"category": "flow",
|
|
165
|
+
"file": "flow/plan-guide.md"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"id": "app/app-init",
|
|
169
|
+
"title": "应用初始化",
|
|
170
|
+
"category": "app",
|
|
171
|
+
"file": "app/app-init.md"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": "app/build-upload",
|
|
175
|
+
"title": "应用构建与上传",
|
|
176
|
+
"category": "app",
|
|
177
|
+
"file": "app/build-upload.md"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"id": "app/release-guide",
|
|
181
|
+
"title": "应用发布管理",
|
|
182
|
+
"category": "app",
|
|
183
|
+
"file": "app/release-guide.md"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"id": "data/data-spaces",
|
|
187
|
+
"title": "数据空间管理",
|
|
188
|
+
"category": "data",
|
|
189
|
+
"file": "data/data-spaces.md"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"id": "data/table-preview",
|
|
193
|
+
"title": "数据表预览",
|
|
194
|
+
"category": "data",
|
|
195
|
+
"file": "data/table-preview.md"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"id": "data/cube-guide",
|
|
199
|
+
"title": "数据集(Cube)管理",
|
|
200
|
+
"category": "data",
|
|
201
|
+
"file": "data/cube-guide.md"
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# 本体动作(Action)开发
|
|
2
|
+
|
|
3
|
+
**文档 ID**: `onto/action-guide`
|
|
4
|
+
|
|
5
|
+
## Action 概念
|
|
6
|
+
|
|
7
|
+
Action 是可被外部系统触发的本体操作,通常用于:
|
|
8
|
+
- 写入数据
|
|
9
|
+
- 触发业务流程
|
|
10
|
+
- 执行审批操作
|
|
11
|
+
|
|
12
|
+
## 列出动作
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
.\scripts\dazi.ps1 onto action list --space <space-id>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 发布 Action
|
|
19
|
+
|
|
20
|
+
脚本放在 **`项目/onto_<项目名>/脚本/`**(可与函数脚本同目录,用文件名区分):
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
.\scripts\dazi.ps1 onto script publish 项目/onto_<项目名>/脚本/my_action.py \
|
|
24
|
+
--space <space-id> \
|
|
25
|
+
--register-action-id my_action_code \
|
|
26
|
+
--register-action-permission-tag "finance.write"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`<space-id>` 取自项目 **`README.md`**。
|
|
30
|
+
|
|
31
|
+
## 更新 Action 代码
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
.\scripts\dazi.ps1 onto action update-code my_action_code \
|
|
35
|
+
--space <space-id> \
|
|
36
|
+
--stem my_action
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Action 脚本结构
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
def main(params: dict, context: dict) -> dict:
|
|
43
|
+
"""
|
|
44
|
+
Action 入口。
|
|
45
|
+
context 包含触发者信息、权限标签等。
|
|
46
|
+
"""
|
|
47
|
+
return {"status": "ok"}
|
|
48
|
+
```
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# DaziScript SDK 参考
|
|
2
|
+
|
|
3
|
+
**文档 ID**: `onto/dazi-script-sdk-reference`
|
|
4
|
+
**适用**: dazi-vscode v3 + 搭子平台 DaziScript(ClickHouse 数据空间)
|
|
5
|
+
|
|
6
|
+
> 给 LLM 与开发者提供精简、可执行的 SDK 规范。脚本目录、类型与 **`.\scripts\dazi.ps1 onto script publish`** 等见 **[本体脚本编写指南](./本体脚本编写指南.md)**。
|
|
7
|
+
|
|
8
|
+
## 1. 工作区与脚本放置(dazi-vscode)
|
|
9
|
+
|
|
10
|
+
| 用途 | 路径 |
|
|
11
|
+
|------|------|
|
|
12
|
+
| **日常开发**(推荐) | `<工作区根>/项目/onto_<项目名>/脚本/*.py` |
|
|
13
|
+
| **空间 ID** | `项目/onto_<项目名>/README.md` 中的数据空间 ID |
|
|
14
|
+
| **参考示例** | `资源/examples/onto/setup/`、`资源/examples/onto/function/`(侧栏 **帮助 → 示例** 或 `.\scripts\dazi.ps1 examples sync`) |
|
|
15
|
+
| **本文档** | `资源/docs/onto/dazi_script_sdk_reference.md`(`.\scripts\dazi.ps1 docs sync` 后) |
|
|
16
|
+
|
|
17
|
+
- **禁止**将 `onto/<space_id>/editorial/` 作为 v3 本地开发约定(历史路径,仅 CLI `script sync` 可能拉回平台副本)。
|
|
18
|
+
- 脚本入口仅需定义 **`main()`**;平台执行时自动调用,**不要**写 `if __name__ == "__main__":`。
|
|
19
|
+
|
|
20
|
+
## 2. 基本约束
|
|
21
|
+
|
|
22
|
+
- 数据引擎:**ClickHouse**
|
|
23
|
+
- 新建空间须显式指定(若脚本内创建空间):
|
|
24
|
+
- `storage_engine="clickhouse"`
|
|
25
|
+
- `connection_config={"database": "<db_name>"}`
|
|
26
|
+
- 执行前确认已登录(`.\scripts\dazi.ps1 auth whoami`)且 `dazi.serverUrl` 正确。
|
|
27
|
+
|
|
28
|
+
## 3. 顶层对象与推荐调用
|
|
29
|
+
|
|
30
|
+
常用对象:
|
|
31
|
+
|
|
32
|
+
- `space`:空间管理与切换
|
|
33
|
+
- `s.sql`:原始 SQL
|
|
34
|
+
- `s.tables`:表注册与列同步
|
|
35
|
+
- `s.register_cube(...)`:Cube 注册
|
|
36
|
+
- `s.onto`:本体定义(对象、属性、链接、函数、活动)
|
|
37
|
+
- `s.ontology`:对象中心能力(objects/features)
|
|
38
|
+
- `s.ontology_rules`:规则集与规则
|
|
39
|
+
- `s.scripts`:脚本记录管理
|
|
40
|
+
- `output`:打印与成功提示(`output.print` / `output.success`)
|
|
41
|
+
|
|
42
|
+
命名规范(便于 LLM 推断):
|
|
43
|
+
|
|
44
|
+
- 读操作:`exists_*`、`get_*`、`require_*`、`list_*`
|
|
45
|
+
- 写操作:`create_*`、`ensure_*`、`update_*`、`delete_*`
|
|
46
|
+
- 派生/同步:`create_from_*`、`sync_*`
|
|
47
|
+
|
|
48
|
+
推荐本体落库路径(与 **[本体规划指南](./本体规划指南.md)** 一致):
|
|
49
|
+
|
|
50
|
+
1. `s.onto.define_object_type` → `s.onto.bind_source(..., "dazi_cube", config={"cube": ...})`
|
|
51
|
+
2. `s.onto.define_property`(`dimension` / `measure` 须带与 Cube 成员一致的 `qualified_name`)
|
|
52
|
+
3. `s.onto.define_link_type`(两端为对象类型 **`code`**,非 Cube 名)
|
|
53
|
+
4. `s.onto.register_function` / `s.onto.define_action`
|
|
54
|
+
5. `s.ontology.features.attach(object_code, feature_type, feature_id)`(`feature_type`: `function | action | rule`)
|
|
55
|
+
|
|
56
|
+
**关于 `s.ontology.objects.create_from_cubes`**:SDK 仍提供,**易与业务语义脱节**;规划文档、示例包与交付脚本**不应依赖**。仅隔离烟测按需使用。
|
|
57
|
+
|
|
58
|
+
## 4. 返回结构规范
|
|
59
|
+
|
|
60
|
+
### 4.1 批量派生返回(ResultBatch)
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"ok": true,
|
|
65
|
+
"created": [],
|
|
66
|
+
"updated": [],
|
|
67
|
+
"skipped": [],
|
|
68
|
+
"errors": [],
|
|
69
|
+
"summary": { "requested": 0, "created": 0, "updated": 0, "skipped": 0, "errors": 0 }
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 4.2 特征绑定返回(示例)
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"ok": true,
|
|
78
|
+
"id": "xxx",
|
|
79
|
+
"created": true,
|
|
80
|
+
"updated": false,
|
|
81
|
+
"message": ""
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 5. 模块速查
|
|
86
|
+
|
|
87
|
+
### 5.1 `space`
|
|
88
|
+
|
|
89
|
+
- `s = space.create(name, space_id=None, storage_engine="clickhouse", connection_config={"database": ...}, ...)`
|
|
90
|
+
- `s = space.get(name_or_id)`
|
|
91
|
+
- `space.use(handle_or_name)`
|
|
92
|
+
|
|
93
|
+
### 5.2 `s.sql`
|
|
94
|
+
|
|
95
|
+
- `s.sql.query(sql)` / `s.sql.query_one(sql)` / `s.sql.execute(sql)`
|
|
96
|
+
- `s.sql.insert_rows(table, rows)`(`rows` 为 `list[dict]`)
|
|
97
|
+
|
|
98
|
+
**ClickHouse:`INSERT ... VALUES` 与注释**
|
|
99
|
+
|
|
100
|
+
- **`VALUES` 与各元组之间禁止 SQL 行注释 `--`**,否则易出现 `Code: 27` 等解析错误。
|
|
101
|
+
- **推荐**:大批量灌数用 **`s.sql.insert_rows`**;详见 **[dazi_script_seed_data_guide](./dazi_script_seed_data_guide.md)**。
|
|
102
|
+
|
|
103
|
+
### 5.3 `s.tables`
|
|
104
|
+
|
|
105
|
+
- `s.tables.register(table_name, label=...)`
|
|
106
|
+
- `s.tables.sync_columns(table_name)`
|
|
107
|
+
- `s.tables.list()` / `s.tables.discover()`
|
|
108
|
+
- `s.tables.add_relationship(...)`
|
|
109
|
+
|
|
110
|
+
### 5.4 Cube
|
|
111
|
+
|
|
112
|
+
- `s.register_cube(name, table, title, measures, dimensions)`
|
|
113
|
+
|
|
114
|
+
### 5.5 `s.onto`
|
|
115
|
+
|
|
116
|
+
- `s.onto.define_object_type(code, name, ...)`
|
|
117
|
+
- `s.onto.bind_source(object_type_code, "dazi_cube", config={"cube": "CubeName"})`
|
|
118
|
+
- `s.onto.define_property(...)`
|
|
119
|
+
- `s.onto.define_link_type(code, name, from_object_type_code, to_object_type_code, ...)`
|
|
120
|
+
- `s.onto.register_function(function_id, adapter, ...)`
|
|
121
|
+
- `s.onto.define_action(action_code, ...)`
|
|
122
|
+
|
|
123
|
+
### 5.6 `s.ontology` / `s.ontology_rules` / `s.scripts`
|
|
124
|
+
|
|
125
|
+
见上文;规则:`ensure_rule_set` + `upsert_rule`;脚本记录:`create` / `ensure` / `list` 等。
|
|
126
|
+
|
|
127
|
+
## 6. 标准初始化流程(建议)
|
|
128
|
+
|
|
129
|
+
1. 确认 `space_id`(项目 README)
|
|
130
|
+
2. 建表与灌数(`s.sql`;灌数规范见 seed 指南)
|
|
131
|
+
3. `s.tables.register` + `sync_columns`
|
|
132
|
+
4. `s.register_cube`
|
|
133
|
+
5. `s.onto` 定义对象、属性、链接
|
|
134
|
+
6. 注册函数/动作并 `features.attach`
|
|
135
|
+
7. 配置规则(如需要)
|
|
136
|
+
|
|
137
|
+
## 7. 在 dazi-vscode 中发布与运行
|
|
138
|
+
|
|
139
|
+
开发完成后,在工作区根目录:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# 预检
|
|
143
|
+
.\scripts\dazi.ps1 onto script publish-preview 项目/onto_<项目名>/脚本/my_setup.py --space <space-id>
|
|
144
|
+
|
|
145
|
+
# 发布(初始化/灌数类脚本)
|
|
146
|
+
.\scripts\dazi.ps1 onto script publish 项目/onto_<项目名>/脚本/my_setup.py --space <space-id>
|
|
147
|
+
|
|
148
|
+
# 发布并注册为本体函数
|
|
149
|
+
.\scripts\dazi.ps1 onto script publish 项目/onto_<项目名>/脚本/my_func.py \
|
|
150
|
+
--space <space-id> \
|
|
151
|
+
--register-function-id my_func
|
|
152
|
+
|
|
153
|
+
# 运行已入库函数
|
|
154
|
+
.\scripts\dazi.ps1 onto function run my_func --space <space-id> --params '{}'
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
亦可用侧栏 **Onto 本体** → 发布函数 / 运行函数。
|
|
158
|
+
|
|
159
|
+
## 8. 回归与 JSON 摘要
|
|
160
|
+
|
|
161
|
+
- 支持 `--json` 时,输出前缀统一:`__JSON_SUMMARY__`
|
|
162
|
+
- 非 0 退出码即失败
|
|
163
|
+
- 会改写数据的步骤须提供跳过/禁用开关
|
|
164
|
+
|
|
165
|
+
**内置参考示例**(在用户工作区:**侧栏 帮助 → 示例 → 下载所有示例**,或执行 `.\scripts\dazi.ps1 examples sync`,得到 **`资源/examples/`**;可复制到 **`项目/<onto_项目名>/脚本/`** 再改,勿直接改写同步下来的只读备份):
|
|
166
|
+
|
|
167
|
+
- 初始化:**`<工作区根>/资源/examples/onto/setup/profit_ontology_init.py`**
|
|
168
|
+
- 函数样例:**`<工作区根>/资源/examples/onto/function/profit_fn_*.py`**
|