@sparkelf/dsh-dataops-managed 0.4.0 → 0.4.2

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/lib/index.js CHANGED
@@ -877,6 +877,11 @@ const AI_TOOL_ACCESS = {
877
877
  review_notifications_list: {},
878
878
  review_notifications_read: {},
879
879
  dataops_api_docs: { superAdminOnly: true },
880
+ synonym_group_list: { superAdminOnly: true },
881
+ synonym_group_get: { superAdminOnly: true },
882
+ synonym_group_create: { superAdminOnly: true },
883
+ synonym_group_update: { superAdminOnly: true },
884
+ synonym_group_delete: { superAdminOnly: true },
880
885
  workflow_query: { superAdminOnly: true },
881
886
  workflow_definition: { superAdminOnly: true },
882
887
  workflow_deployment: { superAdminOnly: true },
@@ -3711,6 +3716,196 @@ function buildAiManagementTools(ctx, reviewApi, readScope, collectHub) {
3711
3716
  };
3712
3717
  }
3713
3718
  })
3719
+ },
3720
+ {
3721
+ name: "synonym_group_list",
3722
+ definition: defineTool({
3723
+ name: "synonym_group_list",
3724
+ description: "List DataOps synonym groups: the canonical wording, its aliases and the catalog node it belongs to. Read-only. Super administrators only.",
3725
+ parameters: {
3726
+ catalog_node_id: {
3727
+ type: "number",
3728
+ description: "Only groups attached to this catalog node id."
3729
+ },
3730
+ keyword: {
3731
+ type: "string",
3732
+ description: "Substring of the canonical term, or an exact alias."
3733
+ }
3734
+ },
3735
+ output: {
3736
+ schema: OPEN_OBJECT_SCHEMA,
3737
+ render: renderJson
3738
+ },
3739
+ execute: async (args) => {
3740
+ const query = new URLSearchParams();
3741
+ if (args.catalog_node_id !== void 0) query.set("catalogNodeId", String(args.catalog_node_id));
3742
+ if (args.keyword !== void 0 && args.keyword.trim() !== "") query.set("keyword", args.keyword.trim());
3743
+ return await call("/api/ai/synonym-groups?" + query.toString());
3744
+ }
3745
+ })
3746
+ },
3747
+ {
3748
+ name: "synonym_group_get",
3749
+ definition: defineTool({
3750
+ name: "synonym_group_get",
3751
+ description: "Read one DataOps synonym group by id. Read-only. Super administrators only.",
3752
+ parameters: { group_id: {
3753
+ type: "number",
3754
+ required: true,
3755
+ description: "Synonym group id."
3756
+ } },
3757
+ output: {
3758
+ schema: OPEN_OBJECT_SCHEMA,
3759
+ render: renderJson
3760
+ },
3761
+ execute: async (args) => {
3762
+ if (!Number.isSafeInteger(args.group_id) || args.group_id <= 0) throw new Error("group_id must be a positive integer");
3763
+ return await call("/api/ai/synonym-groups/" + args.group_id.toString());
3764
+ }
3765
+ })
3766
+ },
3767
+ {
3768
+ name: "synonym_group_create",
3769
+ definition: defineTool({
3770
+ name: "synonym_group_create",
3771
+ description: "Create one synonym group: a canonical wording plus up to 12 aliases. Aliases are unique across groups. Requires explicit user approval; DataOps rebuilds the search index after the write. Super administrators only.",
3772
+ parameters: {
3773
+ canonical: {
3774
+ type: "string",
3775
+ required: true,
3776
+ description: "The standard wording, e.g. 酒店."
3777
+ },
3778
+ aliases: {
3779
+ type: "array",
3780
+ items: { type: "string" },
3781
+ description: "Alternative wordings, e.g. 旅馆, 宾馆, hotel."
3782
+ },
3783
+ catalog_node_id: {
3784
+ type: "number",
3785
+ description: "Optional catalog node id the group belongs to."
3786
+ },
3787
+ description: {
3788
+ type: "string",
3789
+ description: "Optional description."
3790
+ },
3791
+ is_enabled: {
3792
+ type: "boolean",
3793
+ description: "Whether the group takes effect immediately (default true)."
3794
+ }
3795
+ },
3796
+ output: {
3797
+ schema: OPEN_OBJECT_SCHEMA,
3798
+ render: renderJson
3799
+ },
3800
+ execute: async (args, exec) => {
3801
+ if (typeof args.canonical !== "string" || args.canonical.trim() === "") throw new Error("canonical is required");
3802
+ await approve("synonym_group_create", exec, "Create synonym group " + args.canonical.trim());
3803
+ const body = {
3804
+ canonical: args.canonical.trim(),
3805
+ aliases: args.aliases ?? [],
3806
+ catalogNodeId: args.catalog_node_id ?? null,
3807
+ description: args.description ?? null,
3808
+ isEnabled: args.is_enabled ?? true
3809
+ };
3810
+ const value = await call("/api/ai/synonym-groups", {
3811
+ method: "POST",
3812
+ body: JSON.stringify(body)
3813
+ });
3814
+ audit("synonym_group_create", exec, {
3815
+ canonical: body.canonical,
3816
+ aliasCount: body.aliases.length
3817
+ });
3818
+ return value;
3819
+ }
3820
+ })
3821
+ },
3822
+ {
3823
+ name: "synonym_group_update",
3824
+ definition: defineTool({
3825
+ name: "synonym_group_update",
3826
+ description: "Update one synonym group: canonical wording, aliases, catalog node, description or enabled flag. Requires explicit user approval; DataOps rebuilds the documents that expanded the group. Super administrators only.",
3827
+ parameters: {
3828
+ group_id: {
3829
+ type: "number",
3830
+ required: true,
3831
+ description: "Synonym group id."
3832
+ },
3833
+ canonical: {
3834
+ type: "string",
3835
+ description: "New standard wording."
3836
+ },
3837
+ aliases: {
3838
+ type: "array",
3839
+ items: { type: "string" },
3840
+ description: "Full replacement alias list (max 12)."
3841
+ },
3842
+ catalog_node_id: {
3843
+ type: "number",
3844
+ description: "New catalog node id."
3845
+ },
3846
+ description: {
3847
+ type: "string",
3848
+ description: "New description."
3849
+ },
3850
+ is_enabled: {
3851
+ type: "boolean",
3852
+ description: "Enable or disable the group."
3853
+ }
3854
+ },
3855
+ output: {
3856
+ schema: OPEN_OBJECT_SCHEMA,
3857
+ render: renderJson
3858
+ },
3859
+ execute: async (args, exec) => {
3860
+ if (!Number.isSafeInteger(args.group_id) || args.group_id <= 0) throw new Error("group_id must be a positive integer");
3861
+ await approve("synonym_group_update", exec, "Update synonym group " + args.group_id.toString());
3862
+ const body = {};
3863
+ if (args.canonical !== void 0) body.canonical = args.canonical;
3864
+ if (args.aliases !== void 0) body.aliases = args.aliases;
3865
+ if (args.catalog_node_id !== void 0) body.catalogNodeId = args.catalog_node_id;
3866
+ if (args.description !== void 0) body.description = args.description;
3867
+ if (args.is_enabled !== void 0) body.isEnabled = args.is_enabled;
3868
+ const value = await call("/api/ai/synonym-groups/" + args.group_id.toString(), {
3869
+ method: "PATCH",
3870
+ body: JSON.stringify(body)
3871
+ });
3872
+ audit("synonym_group_update", exec, { groupId: args.group_id });
3873
+ return value;
3874
+ }
3875
+ })
3876
+ },
3877
+ {
3878
+ name: "synonym_group_delete",
3879
+ definition: defineTool({
3880
+ name: "synonym_group_delete",
3881
+ description: "Disable a synonym group (default) or permanently delete it with purge=true. Requires explicit user approval. Super administrators only.",
3882
+ parameters: {
3883
+ group_id: {
3884
+ type: "number",
3885
+ required: true,
3886
+ description: "Synonym group id."
3887
+ },
3888
+ purge: {
3889
+ type: "boolean",
3890
+ description: "Delete permanently instead of disabling."
3891
+ }
3892
+ },
3893
+ output: {
3894
+ schema: OPEN_OBJECT_SCHEMA,
3895
+ render: renderJson
3896
+ },
3897
+ execute: async (args, exec) => {
3898
+ if (!Number.isSafeInteger(args.group_id) || args.group_id <= 0) throw new Error("group_id must be a positive integer");
3899
+ const purge = args.purge === true;
3900
+ await approve("synonym_group_delete", exec, (purge ? "Delete" : "Disable") + " synonym group " + args.group_id.toString());
3901
+ const value = await call("/api/ai/synonym-groups/" + args.group_id.toString() + (purge ? "?purge=true" : ""), { method: "DELETE" });
3902
+ audit("synonym_group_delete", exec, {
3903
+ groupId: args.group_id,
3904
+ purge
3905
+ });
3906
+ return value;
3907
+ }
3908
+ })
3714
3909
  }
3715
3910
  ];
3716
3911
  }
@@ -5737,6 +5932,93 @@ const CONNECTOR_SKILL = {
5737
5932
  * 没有权限时返回空列表,`get` 也拒绝,避免只靠 SKILL.md 里的 frontmatter 声明。
5738
5933
  */
5739
5934
  let connectorSkillAllowed = () => false;
5935
+ /** Admin data-governance skill: imports resources, writes metadata, and reads full platform metadata. */
5936
+ const GOVERNANCE_SKILL_NAME = "dataops-governance";
5937
+ const GOVERNANCE_SKILL_FILE = new URL("../skills/dataops-governance/SKILL.md", import.meta.url);
5938
+ const GOVERNANCE_SKILL = {
5939
+ name: GOVERNANCE_SKILL_NAME,
5940
+ description: "管理员/超管导入资源、维护资源/列/指标/血缘与可见性、查询全量平台元数据时使用。",
5941
+ invocation: {
5942
+ modelInvocable: true,
5943
+ userInvocable: true
5944
+ },
5945
+ provider: GOVERNANCE_SKILL_NAME,
5946
+ source: "bundled",
5947
+ resourceBase: {
5948
+ kind: "directory",
5949
+ path: fileURLToPath(new URL("../skills/dataops-governance/", import.meta.url))
5950
+ },
5951
+ rank: BUNDLED_SKILL_RANK,
5952
+ locator: GOVERNANCE_SKILL_FILE
5953
+ };
5954
+ const governanceSkillProvider = {
5955
+ name: GOVERNANCE_SKILL_NAME,
5956
+ list: () => Promise.resolve([GOVERNANCE_SKILL]),
5957
+ async get() {
5958
+ return {
5959
+ ...GOVERNANCE_SKILL,
5960
+ content: await readFile(GOVERNANCE_SKILL_FILE, "utf8")
5961
+ };
5962
+ }
5963
+ };
5964
+ /** Synonym-governance skill: discovers and maintains synonym groups for resource search. */
5965
+ const SYNONYM_SKILL_NAME = "dataops-synonym-governance";
5966
+ const SYNONYM_SKILL_FILE = new URL("../skills/dataops-synonym-governance/SKILL.md", import.meta.url);
5967
+ const SYNONYM_SKILL = {
5968
+ name: SYNONYM_SKILL_NAME,
5969
+ description: "超管维护资源检索的同义词组:从数据目录自底向上抽词、判定等价、确认后写入。",
5970
+ invocation: {
5971
+ modelInvocable: true,
5972
+ userInvocable: true
5973
+ },
5974
+ provider: SYNONYM_SKILL_NAME,
5975
+ source: "bundled",
5976
+ resourceBase: {
5977
+ kind: "directory",
5978
+ path: fileURLToPath(new URL("../skills/dataops-synonym-governance/", import.meta.url))
5979
+ },
5980
+ rank: BUNDLED_SKILL_RANK,
5981
+ locator: SYNONYM_SKILL_FILE
5982
+ };
5983
+ const synonymSkillProvider = {
5984
+ name: SYNONYM_SKILL_NAME,
5985
+ list: () => Promise.resolve([SYNONYM_SKILL]),
5986
+ async get() {
5987
+ return {
5988
+ ...SYNONYM_SKILL,
5989
+ content: await readFile(SYNONYM_SKILL_FILE, "utf8")
5990
+ };
5991
+ }
5992
+ };
5993
+ /** Metadata optimizer skill: inventories metadata and proposes governance improvements. */
5994
+ const METADATA_OPTIMIZER_SKILL_NAME = "dataops-metadata-optimizer";
5995
+ const METADATA_OPTIMIZER_SKILL_FILE = new URL("../skills/dataops-metadata-optimizer/SKILL.md", import.meta.url);
5996
+ const METADATA_OPTIMIZER_SKILL = {
5997
+ name: METADATA_OPTIMIZER_SKILL_NAME,
5998
+ description: "盘点资源/列/指标/血缘,识别命名、口径、冗余与缺失问题,生成治理提案并预览影响。",
5999
+ invocation: {
6000
+ modelInvocable: true,
6001
+ userInvocable: true
6002
+ },
6003
+ provider: METADATA_OPTIMIZER_SKILL_NAME,
6004
+ source: "bundled",
6005
+ resourceBase: {
6006
+ kind: "directory",
6007
+ path: fileURLToPath(new URL("../skills/dataops-metadata-optimizer/", import.meta.url))
6008
+ },
6009
+ rank: BUNDLED_SKILL_RANK,
6010
+ locator: METADATA_OPTIMIZER_SKILL_FILE
6011
+ };
6012
+ const metadataOptimizerSkillProvider = {
6013
+ name: METADATA_OPTIMIZER_SKILL_NAME,
6014
+ list: () => Promise.resolve([METADATA_OPTIMIZER_SKILL]),
6015
+ async get() {
6016
+ return {
6017
+ ...METADATA_OPTIMIZER_SKILL,
6018
+ content: await readFile(METADATA_OPTIMIZER_SKILL_FILE, "utf8")
6019
+ };
6020
+ }
6021
+ };
5740
6022
  const connectorSkillProvider = {
5741
6023
  name: CONNECTOR_SKILL_NAME,
5742
6024
  list: () => Promise.resolve(connectorSkillAllowed() ? [CONNECTOR_SKILL] : []),
@@ -5879,6 +6161,9 @@ async function apply(ctx, config) {
5879
6161
  let mcpFiber;
5880
6162
  ctx.skills.registerProvider(() => querySkillProvider);
5881
6163
  ctx.skills.registerProvider(() => collectSkillProvider);
6164
+ ctx.skills.registerProvider(() => governanceSkillProvider);
6165
+ ctx.skills.registerProvider(() => synonymSkillProvider);
6166
+ ctx.skills.registerProvider(() => metadataOptimizerSkillProvider);
5882
6167
  ctx.skills.registerProvider(() => connectorSkillProvider);
5883
6168
  ctx.skills.registerProvider(() => prefectScriptSkillProvider);
5884
6169
  ctx.skills.registerProvider(() => provisioningSkillProvider);
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Browser-version notice.
3
+ *
4
+ * The workspace is a web app; the local browser bridge only supports current Chromium
5
+ * releases. This banner is deliberately a sibling of the workspace-image banner: it uses
6
+ * the same shell-overlay seat and the same quiet notice geometry, while keeping the
7
+ * browser floor and the installer URL owned by this plugin.
8
+ *
9
+ * @module BrowserVersionPrompt
10
+ */
11
+ import type { en } from './locales.ts';
12
+ /** Lowest Chromium major the local browser bridge supports. */
13
+ export declare const MIN_BROWSER_MAJOR = 150;
14
+ export interface BrowserVersionPromptProps {
15
+ /** Resolve one managed DataOps message key. */
16
+ readonly t: (key: keyof typeof en) => string;
17
+ }
18
+ /**
19
+ * Extract the Chromium major from the user agent.
20
+ *
21
+ * `navigator.userAgentData` is preferred in modern Chromium; the UA fallback keeps
22
+ * Firefox/Safari and older embedded WebViews from producing a false positive.
23
+ */
24
+ export declare function chromiumMajor(ua: string): number | null;
25
+ /** Render the browser-version banner while the current browser is below the floor. */
26
+ export declare function BrowserVersionPrompt(props: BrowserVersionPromptProps): import("react").JSX.Element | null;
@@ -156,6 +156,10 @@ export declare const en: {
156
156
  readonly upgradeBusy: "Upgrading workspace…";
157
157
  readonly upgradeStarted: "Upgrade started. Reload this page when the workspace reconnects.";
158
158
  readonly upgradeFailed: "The workspace upgrade could not be started. Try again.";
159
+ readonly browserVersionTitle: "Browser version is out of date";
160
+ readonly browserVersionBody: "This browser is version {version}; version {minimum} or newer is recommended for the local browser bridge. Download the fully offline bridge installer.";
161
+ readonly browserVersionAction: "Download browser package";
162
+ readonly browserVersionLater: "Later";
159
163
  readonly upgradeRetry: "Retry";
160
164
  };
161
165
  /** Stable key set shared by every managed DataOps locale. */
@@ -142,6 +142,21 @@ export declare const AI_TOOL_ACCESS: {
142
142
  readonly dataops_api_docs: {
143
143
  readonly superAdminOnly: true;
144
144
  };
145
+ readonly synonym_group_list: {
146
+ readonly superAdminOnly: true;
147
+ };
148
+ readonly synonym_group_get: {
149
+ readonly superAdminOnly: true;
150
+ };
151
+ readonly synonym_group_create: {
152
+ readonly superAdminOnly: true;
153
+ };
154
+ readonly synonym_group_update: {
155
+ readonly superAdminOnly: true;
156
+ };
157
+ readonly synonym_group_delete: {
158
+ readonly superAdminOnly: true;
159
+ };
145
160
  readonly workflow_query: {
146
161
  readonly superAdminOnly: true;
147
162
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkelf/dsh-dataops-managed",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "DataOps JWT intake and credential-backed MCP tools for managed DeepSeek Harness workspaces.",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -47,7 +47,9 @@
47
47
  "README.md",
48
48
  "LICENSE",
49
49
  "skills/**/SKILL.md",
50
- "skills/browser/references/**/*"
50
+ "skills/browser/references/**/*",
51
+ "skills/**/i18n/*.json",
52
+ "skills/**/references/**/*.md"
51
53
  ],
52
54
  "scripts": {
53
55
  "build": "rm -rf lib && tsc -p tsconfig.build.json && tsdown",
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: dataops-governance
3
+ description: 管理员/超管使用的正常数据治理技能:导入资源、写资源/列/指标/血缘、查全量平台元数据。普通用户问“我的资源/可申请资源”走 dataops-query 的 metadata-query,不用本技能。
4
+ ---
5
+
6
+ # 数据治理
7
+
8
+ ## 适用范围
9
+
10
+ 管理员/超管需要:
11
+
12
+ - 导入表格/Excel/CSV,建成可问数资源;
13
+ - 接 OpenAPI/接口文档,导入接口资源;
14
+ - 改资源、列、指标、血缘、可见性;
15
+ - 查全量平台元数据(不限当前用户授权)。
16
+
17
+ 普通用户不要用本技能;普通用户的受控元数据查询在 `dataops-query/references/metadata-query.md`。
18
+
19
+ ## 硬规则
20
+
21
+ 1. **写元数据只走 `govern_metadata`**:先 `search_resources` 查真实事实,再 `preview`,用户确认后 `apply`;禁止 shell/SQL/Prisma 直写。
22
+ 2. **指标只写 SQL 片段**:`name`、`displayName`、`description`、`sqlFragment`、`enabled`、`accessLevel`、`aiVisible`;不写 aggregation/grain/dimension/aliases/MetricColumn。
23
+ 3. **没有 `govern_metric` 就只提案**:不要用 SQL 直写 `metrics`;记录 `GAP-METRIC-WRITE`。
24
+ 4. **导入与治理分开**:文件导入读 `01-file-import`;接口导入读 `02-api-import`。
25
+ 5. **不做 Benchmark 特判**:产品技能只按正常用户流程执行。
26
+
27
+ ## 流程
28
+
29
+ 1. 判断意图:导入文件 / 导入接口 / 写元数据 / 读元数据。
30
+ 2. 读对应 reference。
31
+ 3. 写操作必须 preview + 用户确认 + apply。
32
+ 4. 完成后回读并汇报结果;失败按错误合同停止。
33
+
34
+ ## Reference 路由
35
+
36
+ | 意图 | 读哪个 |
37
+ | --- | --- |
38
+ | 表格/Excel/CSV 导入 | `references/01-file-import.md` |
39
+ | OpenAPI/接口文档导入 | `references/02-api-import.md` |
40
+ | 写资源/列/指标/血缘/可见性 | `references/03-metadata-write.md` |
41
+ | 全量平台元数据查询 | `references/04-metadata-read.md` |
@@ -0,0 +1,10 @@
1
+ {
2
+ "_meta": {
3
+ "sourceHash": "1bdca8934cf5a192a59c35e811f4f49c9b97ff40",
4
+ "model": "manual-zh",
5
+ "translatedAt": "2026-11-23T10:25:00+08:00"
6
+ },
7
+ "title": "数据治理",
8
+ "description": "管理员/超管导入资源、维护资源/列/指标/血缘与可见性、查询全量平台元数据时使用。",
9
+ "summary": "覆盖表格/Excel/CSV 导入、OpenAPI 接入、元数据写入和全量元数据读取;写操作必须先 preview,用户确认后再 apply。"
10
+ }
@@ -0,0 +1,201 @@
1
+ # 文件导入(合并自 dataops-collect)
2
+
3
+ # 数据采集(AI 建资源)
4
+
5
+ 用户把一份表格交给 AI,AI 解析、出计划、用户确认后建表写数,最后得到一个能问数的资源。第一版只做一次性导入;一个会话一份文件、一个目标资源。
6
+
7
+ ## 一、什么时候用
8
+
9
+ 用户表达下面任一意图时使用本技能:
10
+
11
+ - 把这份表格建成能问数的资源
12
+ - 这个 Excel 帮我导进来
13
+ - 上传个表能问数吗
14
+ - 把这份数据加到已有的那个资源里
15
+ - 追加到 XX 资源
16
+ - 新建一个数据资源
17
+ - 表格导入 / 导入成表 / 建成资源
18
+ - 把 CSV 变成能查的表 / 能问数的表
19
+ - 这份数据帮我入库 / 建表
20
+ - 把这个 sheet 建成资源
21
+ - 这个表以后能用来问数吗
22
+ - 把这份销售表导入
23
+ - 把这份名单建成资源
24
+ - 加到门店销售明细里
25
+ - 追加一份月度数据
26
+ - 建个新资源,用这个文件
27
+ - 导入到数据中台
28
+ - 这个文件能建成资源吗
29
+ - 把附件建成资源
30
+ - 用这个表格建一张表
31
+
32
+ 不适用:纯问数、取数、查数据(用 `dataops-query`);只讨论表结构但不导入。
33
+
34
+ ## 二、四个硬规则
35
+
36
+ 1. **一次会话一份文件、一个目标资源。** 多文件批量不做。
37
+ 2. **有引用 = 追加;无引用 = 先问,不默认新建。** 用户话里已经说清“新建”或“追加”的,跳过这一问;没说清又没引用,必须先出「新建资源 / 选择已有资源」二选一,不能直接出新建计划。
38
+ 3. **计划确认是唯一硬闸。** 用户明确回复「确认」「开始吧」「可以」等之前,绝不调用 `dataops_collect_execute`,绝不建表、绝不写数。预览和计划工具本身不建表,可以放心调用。
39
+ 4. **执行走原生工具流。** 不要自己造执行卡、进度卡;工具参数、结果、耗时、失败原因都在原生工具卡里。你只在旁边说人话。
40
+
41
+ ## 三、主流程
42
+
43
+ ### 1. 找到文件
44
+
45
+ 从当前消息的附件 / 系统上下文里取得表格在工作区的路径(通常是 `/workspace/...` 或 `temp/conversations/.../attachments/...`)。没有路径时,不要猜目录、不要扫全工作区;直接说“请把表格拖进输入框,或点输入框的 + 上传”,并给一个内联上传提示。
46
+
47
+ ### 2. 预览,不要建表
48
+
49
+ 调用:
50
+
51
+ `dataops_collect_preview({ file_path })`
52
+
53
+ 返回 `sessionId`、`preview`、`dataSources`。用大白话复述:
54
+
55
+ > 看了下,明细 sheet 共 12,000 行、18 列;表头在第 2 行。我先按明细建资源。
56
+
57
+ 文件读不出来也在这里说清楚:
58
+
59
+ > 这个 xlsx 读不出来,可能加密了。你换个文件,或者告诉我表头在第几行。
60
+
61
+ ### 3. 先定去向
62
+
63
+ - 当前会话里有 `resource-ref` 引用块 → 追加到该资源;
64
+ - 用户说“新建 / 建个新资源 / 不要加到已有的” → 新建;
65
+ - 用户说“追加 / 加到 / 并到 / 合到” → 追加;没有具体资源时先让用户选;
66
+ - 都没有 → 出「新建资源 / 选择已有资源」GenUI,等用户选。
67
+
68
+ 选择已有资源时:
69
+ 1. 调用 `dataops_collect_resources({ query, limit: 8 })`;
70
+ 2. 用 `choices` 或 `list` + 按钮列出最多 8 个候选(资源名 + 表名 + 行数);
71
+ 3. 用户选中后,把该资源作为本次目标,进入计划。
72
+
73
+ ### 3.5 判定业务域
74
+
75
+ 每次新建/导入资源前,由会话模型根据**表名、表注释、字段名/注释、术语、少量样例值**判断业务域,不依赖代码里的固定表名规则。判断结果是资源目录的一部分,必须写入导入参数:
76
+
77
+ - `business_domain`:业务域名称,例如「金融域」「软件研发域」;不确定时不要猜,留空或传「未分类」。
78
+ - `domain_inference_source`:`MODEL`(模型根据元数据判断)、`USER`(用户明确指定)、`RULE`(已有治理规则)、`UNKNOWN`。
79
+ - `domain_inference_confidence`:`HIGH` / `MEDIUM` / `LOW`。`LOW` 或无法判断时统一落 `/业务域/未分类`,不要为了好看硬塞一个域。
80
+
81
+ 判定顺序:
82
+
83
+ 1. 用户明确说了业务域 → `USER` + `HIGH`。
84
+ 2. 表名/注释/字段/术语有明确业务语义 → `MODEL` + `HIGH` 或 `MEDIUM`。
85
+ 3. 只能靠库名或样例值猜测 → `MODEL` + `LOW`,最终落未分类。
86
+ 4. 完全无信号 → `UNKNOWN` + `LOW`,落未分类。
87
+
88
+ 常见公开数据集的业务域示例(仅作判断参考,不是代码规则):
89
+
90
+ - BIRD `codebase_community` → 软件研发域
91
+ - `financial` / `debit_card_specializing` → 金融域
92
+ - `student_club` → 教育域
93
+ - `thrombosis_prediction` / `toxicology` → 医疗域
94
+ - `european_football_2` / `formula_1` → 体育域
95
+ - `card_games` / `superhero` → 娱乐域
96
+
97
+ 目录规则:资源挂在 `/业务域/<业务域>/<数据源>/<库>/<schema>`,无 schema 时省略该层;不为每张表单独建目录。系统表不属于业务域,统一在 `/系统域/<模块>`。
98
+
99
+ ### 4. 生成计划,不要执行
100
+
101
+ 调用:
102
+
103
+ `dataops_collect_plan({ session_id, data_source_urn, target_schema?, target_table? })`
104
+
105
+ - 不传 `target_table` = 新建表(CREATE_TABLE);
106
+ - 传 `target_schema` + `target_table` = 追加到已有表(EXISTING_TABLE)。
107
+
108
+ 返回后检查 `plan`:
109
+ - 新建表:`plan.mode === 'CREATE_TABLE'`,有 `plan.createTable`、`plan.createSql`;
110
+ - 追加:`plan.mode === 'EXISTING_TABLE'`,有 `plan.mappings`,并在计划里多一行映射摘要(匹配 N 个字段、新增 N 个、N 个类型不兼容)。
111
+
112
+ ### 5. 出计划 GenUI(只读预览,语言确认)
113
+
114
+ 计划是主确认点,但**只读**:卡上不放 `input` / `textarea` / 下拉 / `submit`,也不放「开始导入」「再调整」按钮。用户看完卡后,直接用自然语言回复「确认」「开始吧」才执行。
115
+
116
+ 必须包含(全部纯展示):
117
+
118
+ - 资源名(AI 起草)
119
+ - 去向(新建资源 / 追加到「已有资源名」)
120
+ - 目标表(库.表)
121
+ - 导入数据源
122
+ - 行数 / 字段数
123
+ - 业务域(含推断来源/置信度;未分类也要写明)
124
+ - **表头映射**:原表头 → 目标字段 → 类型;低置信度类型写「需确认」,并用 warning callout 再列一遍(GenUI 表格单元格不支持单独标黄)
125
+ - 默认权限
126
+
127
+ 计划 GenUI 示例(把 `<...>` 换成真实值;注意没有任何输入控件):
128
+
129
+ ```dsh-ui
130
+ {"title":"导入计划","items":[{"type":"text","size":"body","content":"看了下,明细 sheet 共 <行数> 行、<列数> 列;我先按明细建资源。"},{"type":"card","title":"<资源名>","items":[{"type":"keyvalue","pairs":[{"key":"资源名","value":"<资源名>"},{"key":"去向","value":"新建资源"},{"key":"目标表","value":"<schema.table>"},{"key":"导入数据源","value":"<数据源名>"},{"key":"行数 / 字段数","value":"<行数> 行 / <字段数> 列"},{"key":"默认权限","value":"仅自己可见"}]},{"type":"table","columns":["原表头","目标字段","类型"],"rows":[["<原表头1>","<目标字段1>","<类型1>"],["<原表头2>","<目标字段2>","⚠️ 需确认"]]},{"type":"callout","tone":"warning","content":"以下类型需要确认:<列出低置信度字段>。"},{"type":"callout","tone":"info","content":"确认无误请直接回复「确认」或「开始吧」;要改表名、类型或资源名,直接说,我会重新出计划,不会执行。"}]}]}
131
+ ```
132
+
133
+ 规则:
134
+
135
+ - 用户提出修改(「表名换成 xxx」「金额按文本存」「资源名改成 xxx」)→ 只在对话里改参数,然后重新调用 `dataops_collect_plan` / 调整计划,**重新出只读计划卡,不要执行**;
136
+ - 用户确认后,计划折叠成一行“已按此计划执行”的回执,把屏幕让给工具流;
137
+ - 确认后如果要改参数,先停,再出新计划。
138
+
139
+ ### 6. 执行
140
+
141
+ 用户明确回复「确认」「开始吧」「可以」后,使用计划卡上展示的资源名/目标表/描述调用:
142
+
143
+ `dataops_collect_execute({ session_id, data_source_urn, mode, target_schema?, target_table?, create_plan_json, mappings_json, resource_name, resource_description, resource_tags?, ai_visible?, access_level?, business_domain?, domain_inference_source?, domain_inference_confidence? })`
144
+
145
+ - `mode` 用 `plan.mode`;
146
+ - 新建表:`create_plan_json` 传 `JSON.stringify(plan.createTable)`,`mappings_json` 传 `"[]"`;
147
+ - 追加:`mappings_json` 传 `JSON.stringify(plan.mappings)`;
148
+ - `resource_name` 用计划卡上展示、用户确认过的资源名;
149
+ - `access_level` 默认 `PRIVATE`;`ai_visible` 默认 `true`。
150
+ - `business_domain` / `domain_inference_source` / `domain_inference_confidence` 按 3.5 的判定结果传入;不传时后端落 `/业务域/未分类`。
151
+
152
+ 执行期间只说阶段小结,例如:
153
+
154
+ > 表建好了。现在写数据,一万两千行,估计一两分钟。
155
+ >
156
+ > 写完了,正在生成字段说明。
157
+
158
+ 失败只说三类,并给一个动作:
159
+ - 文件问题 → 重新上传 / 告诉我表头在第几行;
160
+ - 字段问题 → 调整映射 / 改类型;
161
+ - 系统问题 → 重试。
162
+
163
+ ### 7. 结果 GenUI + 打开资源页签
164
+
165
+ 执行成功后:
166
+
167
+ 1. 调用 `dataops_open_resource_tab({ resource_id, resource_name, mode: 'focus' })`,让右侧栏自动打开 `dataops-resources` 页签并定位新资源;
168
+ 2. 出结果 GenUI,必须包含资源名、目标表、行数、字段数、业务域(含推断来源/置信度;未分类要明确写“未分类”)、 “已可问数”、当前可见范围(默认“仅自己可见”),以及三个动作:**分配权限 / 去问数 / 查看详情**,外加一条 **查看操作记录** 文字链。
169
+
170
+ 结果 GenUI 示例:
171
+
172
+ ```dsh-ui
173
+ {"title":"导入完成","items":[{"type":"callout","tone":"success","title":"已可问数","content":"资源已建成,可以开始问数。"},{"type":"keyvalue","pairs":[{"key":"资源名","value":"<资源名>"},{"key":"目标表","value":"<schema.table>"},{"key":"行数","value":"<行数>"},{"key":"字段数","value":"<字段数>"},{"key":"可见范围","value":"仅自己可见"}]},{"type":"row","items":[{"type":"button","label":"分配权限","tone":"primary","action":"dataops_open_grant"},{"type":"button","label":"去问数","action":"dataops_ask"},{"type":"button","label":"查看详情","action":"dataops_open_detail"}]},{"type":"button","label":"查看操作记录 →","tone":"ghost","small":true,"action":"dataops_open_audit"}]}
174
+ ```
175
+
176
+ 三个动作的处理:
177
+
178
+ - 分配权限 → `dataops_open_resource_tab({ resource_id, mode: 'grant' })`,侧栏资源卡定位并自动打开授权弹窗;
179
+ - 去问数 → 不要跳页,直接在对话里给 2-3 个可以问的问题示例,并说明资源已可被检索;
180
+ - 查看详情 → `dataops_open_resource_tab({ resource_id, mode: 'detail' })`;
181
+ - 查看操作记录 → `dataops_open_resource_tab({ resource_id, mode: 'audit' })`。
182
+
183
+ ## 四、引用资源(追加)
184
+
185
+ 引用可能来自输入框的资源 chip,也可能来自右侧栏资源卡的「添加到对话」。如果引用以结构化块出现,形如:
186
+
187
+ ```resource-ref
188
+ {"kind":"dataops-resource","resourceId":123,"name":"门店销售明细","table":"dwd_store_sales"}
189
+ ```
190
+
191
+ 就把它当作本次追加目标,不要再问“新建还是追加”。如果用户在上传文件之前先引用了资源,直接按追加处理。
192
+
193
+ 如果「添加到对话」降级成发送一条消息,消息里必须带这个 `resource-ref` 块;没有结构化块时,按“用户口头提到资源名”处理,先用 `dataops_collect_resources` 找到资源再确认,不要凭名字猜 id。
194
+
195
+ ## 五、边界
196
+
197
+ - 不做定时采集、增量水位、失败重试策略;
198
+ - 不做多文件批量、文件夹上传;
199
+ - 不做覆盖(只追加);
200
+ - 不在对话里做权限表单(GenUI 没有人员选择器);
201
+ - 不在 DSH 里做审计弹窗;操作记录在 DataOps 资源详情 / 系统审计。
@@ -0,0 +1,11 @@
1
+ # 接口导入
2
+
3
+ OpenAPI / Swagger / 接口说明导入接口资源,按现有 `api-connector-authoring` 技能执行;本 reference 只负责在治理技能内路由,不复制其步骤。
4
+
5
+ 要求:
6
+
7
+ - 先解析接口文档,判断一个 connector 还是多个;
8
+ - 资源命名用业务语义,不用 `api_v1`;
9
+ - 导入前用 GenUI 预览,用户确认后才导入;
10
+ - 字段返回英文缩写时给中文语义名;
11
+ - 不在本流程里写指标/血缘。