@dazitech/cli 3.0.7 → 3.0.9

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 (70) 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 +73 -22
  5. package/dist/clis/dazi.js +266 -171
  6. package/dist/docs/flow/flow-project-guide.md +1 -1
  7. package/dist/docs/guides/quickstart.md +18 -4
  8. package/dist/docs/guides/troubleshooting.md +12 -1
  9. package/dist/docs/guides/workspace-v3.md +43 -23
  10. package/dist/docs/index.json +28 -3
  11. package/dist/docs/onto/action-guide.md +3 -3
  12. package/dist/docs/onto/dazi_script_sdk_reference.md +244 -174
  13. package/dist/docs/onto/dazi_script_seed_data_guide.md +158 -155
  14. package/dist/docs/onto/function-guide.md +82 -27
  15. package/dist/docs/onto/space-management.md +3 -1
  16. 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 +168 -0
  17. 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
  18. 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 +200 -34
  19. package/dist/docs/onto//346/234/254/344/275/223/350/247/204/345/210/222/346/214/207/345/215/227.md +188 -38
  20. 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 +213 -0
  21. 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 +620 -0
  22. 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 +680 -541
  23. package/dist/examples/index.json +208 -22
  24. package/dist/examples/onto/README.md +51 -0
  25. package/dist/examples/onto/_templates/ontology_function_template.py +50 -0
  26. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_account_breakdown.py +62 -0
  27. 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
  28. 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
  29. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_get_summary.py +61 -0
  30. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_mom_analysis.py +82 -0
  31. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_top_accounts.py +61 -0
  32. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/profit_fn_yoy_analysis.py +79 -0
  33. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/save_test_arguments.ps1 +38 -0
  34. 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
  35. 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
  36. 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
  37. 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
  38. 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
  39. 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
  40. 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
  41. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_ontology_init.py +679 -0
  42. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_seed_data.py +216 -0
  43. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_channel_mix.py +89 -0
  44. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_customer_segmentation.py +121 -0
  45. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_get_summary.py +78 -0
  46. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_mom_analysis.py +89 -0
  47. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_region_breakdown.py +84 -0
  48. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_top_products.py +98 -0
  49. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/sales_fn_yoy_analysis.py +87 -0
  50. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/save_test_arguments.ps1 +38 -0
  51. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.channel_mix.json +5 -0
  52. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.customer_segmentation.json +5 -0
  53. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.get_summary.json +5 -0
  54. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.mom_analysis.json +5 -0
  55. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.region_breakdown.json +5 -0
  56. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.top_products.json +5 -0
  57. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/test_arguments/sales.fn.yoy_analysis.json +5 -0
  58. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_ontology_init.py +539 -0
  59. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_seed_data.py +163 -0
  60. package/dist/prompts/index.json +2 -2
  61. package/dist/prompts/onto/action-design.md +4 -1
  62. package/dist/prompts/onto/function-design.md +46 -19
  63. package/dist/prompts/onto/rule-seed.md +5 -1
  64. package/dist/prompts/onto/script-publish-run.md +87 -25
  65. package/package.json +1 -1
  66. package/dist/examples/onto/function/profit_fn_customer_segmentation.py +0 -117
  67. package/dist/examples/onto/function/profit_fn_mom_analysis.py +0 -89
  68. package/dist/examples/onto/function/profit_fn_top_products.py +0 -89
  69. package/dist/examples/onto/function/profit_fn_yoy_analysis.py +0 -89
  70. package/dist/examples/onto/setup/profit_ontology_init.py +0 -388
package/dist/clis/dazi.js CHANGED
@@ -966,8 +966,8 @@ var require_command = __commonJS({
966
966
  "node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js"(exports2) {
967
967
  var EventEmitter = require("node:events").EventEmitter;
968
968
  var childProcess2 = require("node:child_process");
969
- var path13 = require("node:path");
970
- var fs16 = require("node:fs");
969
+ var path15 = require("node:path");
970
+ var fs18 = require("node:fs");
971
971
  var process8 = require("node:process");
972
972
  var { Argument: Argument2, humanReadableArgName } = require_argument();
973
973
  var { CommanderError: CommanderError2 } = require_error();
@@ -1899,11 +1899,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1899
1899
  let launchWithNode = false;
1900
1900
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1901
1901
  function findFile(baseDir, baseName) {
1902
- const localBin = path13.resolve(baseDir, baseName);
1903
- if (fs16.existsSync(localBin)) return localBin;
1904
- if (sourceExt.includes(path13.extname(baseName))) return void 0;
1902
+ const localBin = path15.resolve(baseDir, baseName);
1903
+ if (fs18.existsSync(localBin)) return localBin;
1904
+ if (sourceExt.includes(path15.extname(baseName))) return void 0;
1905
1905
  const foundExt = sourceExt.find(
1906
- (ext) => fs16.existsSync(`${localBin}${ext}`)
1906
+ (ext) => fs18.existsSync(`${localBin}${ext}`)
1907
1907
  );
1908
1908
  if (foundExt) return `${localBin}${foundExt}`;
1909
1909
  return void 0;
@@ -1915,21 +1915,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
1915
1915
  if (this._scriptPath) {
1916
1916
  let resolvedScriptPath;
1917
1917
  try {
1918
- resolvedScriptPath = fs16.realpathSync(this._scriptPath);
1918
+ resolvedScriptPath = fs18.realpathSync(this._scriptPath);
1919
1919
  } catch (err2) {
1920
1920
  resolvedScriptPath = this._scriptPath;
1921
1921
  }
1922
- executableDir = path13.resolve(
1923
- path13.dirname(resolvedScriptPath),
1922
+ executableDir = path15.resolve(
1923
+ path15.dirname(resolvedScriptPath),
1924
1924
  executableDir
1925
1925
  );
1926
1926
  }
1927
1927
  if (executableDir) {
1928
1928
  let localFile = findFile(executableDir, executableFile);
1929
1929
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1930
- const legacyName = path13.basename(
1930
+ const legacyName = path15.basename(
1931
1931
  this._scriptPath,
1932
- path13.extname(this._scriptPath)
1932
+ path15.extname(this._scriptPath)
1933
1933
  );
1934
1934
  if (legacyName !== this._name) {
1935
1935
  localFile = findFile(
@@ -1940,7 +1940,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1940
1940
  }
1941
1941
  executableFile = localFile || executableFile;
1942
1942
  }
1943
- launchWithNode = sourceExt.includes(path13.extname(executableFile));
1943
+ launchWithNode = sourceExt.includes(path15.extname(executableFile));
1944
1944
  let proc;
1945
1945
  if (process8.platform !== "win32") {
1946
1946
  if (launchWithNode) {
@@ -2780,7 +2780,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2780
2780
  * @return {Command}
2781
2781
  */
2782
2782
  nameFromFilename(filename) {
2783
- this._name = path13.basename(filename, path13.extname(filename));
2783
+ this._name = path15.basename(filename, path15.extname(filename));
2784
2784
  return this;
2785
2785
  }
2786
2786
  /**
@@ -2794,9 +2794,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2794
2794
  * @param {string} [path]
2795
2795
  * @return {(string|null|Command)}
2796
2796
  */
2797
- executableDir(path14) {
2798
- if (path14 === void 0) return this._executableDir;
2799
- this._executableDir = path14;
2797
+ executableDir(path16) {
2798
+ if (path16 === void 0) return this._executableDir;
2799
+ this._executableDir = path16;
2800
2800
  return this;
2801
2801
  }
2802
2802
  /**
@@ -3726,11 +3726,11 @@ function buildHttpErrorMessage(ctx, detail) {
3726
3726
  ].filter(Boolean);
3727
3727
  return parts.join(" \u2014 ");
3728
3728
  }
3729
- async function apiRequest(path13, opts = {}) {
3729
+ async function apiRequest(path15, opts = {}) {
3730
3730
  const auth = opts.token || opts.serverUrl ? { token: opts.token ?? "", serverUrl: opts.serverUrl ?? "" } : loadAuth();
3731
3731
  const method = (opts.method ?? "GET").toUpperCase();
3732
3732
  const serverBase = auth.serverUrl.replace(/\/$/, "");
3733
- const url = `${serverBase}${path13}`;
3733
+ const url = `${serverBase}${path15}`;
3734
3734
  const headers = {
3735
3735
  "Content-Type": "application/json",
3736
3736
  Authorization: `Bearer ${auth.token}`,
@@ -3764,7 +3764,7 @@ async function apiRequest(path13, opts = {}) {
3764
3764
  }
3765
3765
  const ctx = {
3766
3766
  method,
3767
- path: path13,
3767
+ path: path15,
3768
3768
  url,
3769
3769
  status: res.status,
3770
3770
  label: opts.label,
@@ -3852,12 +3852,83 @@ function resolveWorkspace(cwd = process.cwd()) {
3852
3852
  }
3853
3853
 
3854
3854
  // cli/shared/src/version.ts
3855
- var DAZI_VERSION = true ? "3.0.7" : readDevVersion();
3855
+ var DAZI_VERSION = true ? "3.0.9" : readDevVersion();
3856
+
3857
+ // cli/shared/src/ontoWorkspaceAudit.ts
3858
+ var import_fs3 = __toESM(require("fs"), 1);
3859
+ var import_path4 = __toESM(require("path"), 1);
3860
+ var WORKSPACE_PROJECTS_DIR = "\u9879\u76EE";
3861
+ var ONTO_SUBDIR = "\u672C\u4F53";
3862
+ var ONTO_ITEMS_DIR = "ontos";
3863
+ var PLANS_DIR = "plans";
3864
+ var LEGACY_PLANS_DIR = "\u89C4\u5212";
3865
+ var LEGACY_SCRIPT_DIR = "\u811A\u672C";
3866
+ function existsDir(p) {
3867
+ try {
3868
+ return import_fs3.default.existsSync(p) && import_fs3.default.statSync(p).isDirectory();
3869
+ } catch {
3870
+ return false;
3871
+ }
3872
+ }
3873
+ function scanOntoLegacyPaths(wsRoot) {
3874
+ const findings = [];
3875
+ const projectsDir = import_path4.default.join(wsRoot, WORKSPACE_PROJECTS_DIR);
3876
+ if (!existsDir(projectsDir)) return findings;
3877
+ for (const ent of import_fs3.default.readdirSync(projectsDir, { withFileTypes: true })) {
3878
+ if (!ent.isDirectory()) continue;
3879
+ const projectDir = import_path4.default.join(projectsDir, ent.name);
3880
+ const relProject = `${WORKSPACE_PROJECTS_DIR}/${ent.name}`;
3881
+ if (/^onto_/i.test(ent.name)) {
3882
+ findings.push({
3883
+ kind: "onto_prefix_project",
3884
+ path: projectDir,
3885
+ message: `\u65E7\u7248\u672C\u4F53\u9879\u76EE\u524D\u7F00\u76EE\u5F55\u300C${relProject}\u300D\u3002\u8BF7\u624B\u52A8\u8FC1\u5165\u300C${WORKSPACE_PROJECTS_DIR}/<\u4E1A\u52A1\u540D>/${ONTO_SUBDIR}/${ONTO_ITEMS_DIR}/<\u5B9E\u73B0\u540D>/\u300D\u3002`
3886
+ });
3887
+ }
3888
+ if (existsDir(import_path4.default.join(projectDir, LEGACY_PLANS_DIR)) || existsDir(import_path4.default.join(projectDir, LEGACY_SCRIPT_DIR))) {
3889
+ findings.push({
3890
+ kind: "legacy_plan_or_script",
3891
+ path: projectDir,
3892
+ message: `\u300C${relProject}\u300D\u542B\u65E7\u76EE\u5F55\u300C${LEGACY_PLANS_DIR}/\u300D\u6216\u300C${LEGACY_SCRIPT_DIR}/\u300D\u3002\u89C4\u5212\u8FC1\u81F3 ${ONTO_SUBDIR}/${ONTO_ITEMS_DIR}/<\u5B9E\u73B0\u540D>/${PLANS_DIR}/\uFF0C\u811A\u672C\u8FC1\u81F3 setup/\u3001functions/\u3002`
3893
+ });
3894
+ }
3895
+ const ontoRoot = import_path4.default.join(projectDir, ONTO_SUBDIR);
3896
+ if (existsDir(import_path4.default.join(ontoRoot, PLANS_DIR))) {
3897
+ findings.push({
3898
+ kind: "onto_root_plans",
3899
+ path: import_path4.default.join(ontoRoot, PLANS_DIR),
3900
+ message: `\u300C${relProject}/${ONTO_SUBDIR}/${PLANS_DIR}/\u300D\u4E3A\u65E7\u811A\u624B\u67B6\u4F4D\u7F6E\u3002\u89C4\u5212\u76EE\u5F55\u5E94\u5728\u300C${ONTO_SUBDIR}/${ONTO_ITEMS_DIR}/<\u5B9E\u73B0\u540D>/${PLANS_DIR}/\u300D\u3002`
3901
+ });
3902
+ }
3903
+ const itemsDir = import_path4.default.join(ontoRoot, ONTO_ITEMS_DIR);
3904
+ if (!existsDir(itemsDir)) continue;
3905
+ for (const item of import_fs3.default.readdirSync(itemsDir, { withFileTypes: true })) {
3906
+ if (!item.isDirectory()) continue;
3907
+ const itemDir = import_path4.default.join(itemsDir, item.name);
3908
+ const relItem = `${relProject}/${ONTO_SUBDIR}/${ONTO_ITEMS_DIR}/${item.name}`;
3909
+ if (existsDir(import_path4.default.join(itemDir, LEGACY_PLANS_DIR))) {
3910
+ findings.push({
3911
+ kind: "legacy_plan_or_script",
3912
+ path: import_path4.default.join(itemDir, LEGACY_PLANS_DIR),
3913
+ message: `\u300C${relItem}/${LEGACY_PLANS_DIR}/\u300D\u8BF7\u91CD\u547D\u540D\u4E3A\u300C${PLANS_DIR}/\u300D\u3002`
3914
+ });
3915
+ }
3916
+ if (existsDir(import_path4.default.join(itemDir, LEGACY_SCRIPT_DIR))) {
3917
+ findings.push({
3918
+ kind: "legacy_plan_or_script",
3919
+ path: import_path4.default.join(itemDir, LEGACY_SCRIPT_DIR),
3920
+ message: `\u300C${relItem}/${LEGACY_SCRIPT_DIR}/\u300D\u8BF7\u5C06\u811A\u672C\u8FC1\u5165 setup/\u3001functions/\u3002`
3921
+ });
3922
+ }
3923
+ }
3924
+ }
3925
+ return findings;
3926
+ }
3856
3927
 
3857
3928
  // cli/dazi/src/commands/auth.ts
3858
3929
  var import_os3 = __toESM(require("os"), 1);
3859
- var import_path4 = __toESM(require("path"), 1);
3860
- var import_fs3 = __toESM(require("fs"), 1);
3930
+ var import_path5 = __toESM(require("path"), 1);
3931
+ var import_fs4 = __toESM(require("fs"), 1);
3861
3932
  function makeAuthCommand() {
3862
3933
  const cmd = new Command("auth").description("\u8D26\u53F7\u8BA4\u8BC1");
3863
3934
  cmd.command("login").description("\u767B\u5F55\u642D\u5B50\u5E73\u53F0").option("-s, --server <url>", "\u5E73\u53F0\u5730\u5740", getServerUrl()).option("--token <token>", "\u76F4\u63A5\u4F7F\u7528 token \u767B\u5F55\uFF08CI / Token \u6A21\u5F0F\uFF09").option("-u, --username <username>", "\u7528\u6237\u540D\u6216\u90AE\u7BB1\uFF08\u8D26\u53F7\u5BC6\u7801\u6A21\u5F0F\uFF09").option("-p, --password <password>", "\u5BC6\u7801\uFF08\u8D26\u53F7\u5BC6\u7801\u6A21\u5F0F\uFF09").action(async (opts) => {
@@ -3942,10 +4013,10 @@ function makeAuthCommand() {
3942
4013
  });
3943
4014
  cmd.command("migrate").description("\u5C06\u65E7\u7248\u8BA4\u8BC1\u6587\u4EF6\u8FC1\u79FB\u5230 ~/.dazi/auth.json").option("--dry-run", "\u4EC5\u9884\u89C8\uFF0C\u4E0D\u5199\u5165").action(async (opts) => {
3944
4015
  const candidates = [];
3945
- const appAuth = import_path4.default.join(import_os3.default.homedir(), ".dazi-app", "auth.json");
3946
- if (import_fs3.default.existsSync(appAuth)) {
4016
+ const appAuth = import_path5.default.join(import_os3.default.homedir(), ".dazi-app", "auth.json");
4017
+ if (import_fs4.default.existsSync(appAuth)) {
3947
4018
  try {
3948
- const d = JSON.parse(import_fs3.default.readFileSync(appAuth, "utf-8"));
4019
+ const d = JSON.parse(import_fs4.default.readFileSync(appAuth, "utf-8"));
3949
4020
  if (d.token) candidates.push({ src: appAuth, label: "dazi-app", data: d });
3950
4021
  } catch {
3951
4022
  }
@@ -3988,6 +4059,8 @@ function makeAuthCommand() {
3988
4059
 
3989
4060
  // cli/dazi/src/commands/doctor.ts
3990
4061
  var import_os4 = __toESM(require("os"), 1);
4062
+ var import_path6 = __toESM(require("path"), 1);
4063
+ var import_fs5 = __toESM(require("fs"), 1);
3991
4064
  function makeDoctorCommand() {
3992
4065
  return new Command("doctor").description("\u68C0\u67E5\u8FD0\u884C\u73AF\u5883").action(async () => {
3993
4066
  const checks = [];
@@ -4007,6 +4080,25 @@ function makeDoctorCommand() {
4007
4080
  networkDetail = String(err2);
4008
4081
  }
4009
4082
  checks.push({ name: `\u7F51\u7EDC\u8FDE\u901A (${getServerUrl()})`, ok: networkOk, detail: networkDetail });
4083
+ const ontoWarnings = [];
4084
+ const projectsDir = import_path6.default.join(process.cwd(), WORKSPACE_PROJECTS_DIR);
4085
+ if (import_fs5.default.existsSync(projectsDir)) {
4086
+ const findings = scanOntoLegacyPaths(process.cwd());
4087
+ if (!findings.length) {
4088
+ checks.push({
4089
+ name: "\u672C\u4F53\u76EE\u5F55\u7ED3\u6784",
4090
+ ok: true,
4091
+ detail: "\u672A\u53D1\u73B0 onto_* / \u89C4\u5212 / \u811A\u672C \u7B49\u65E7\u5E03\u5C40"
4092
+ });
4093
+ } else {
4094
+ ontoWarnings.push(...findings.map((f) => f.message));
4095
+ checks.push({
4096
+ name: "\u672C\u4F53\u76EE\u5F55\u7ED3\u6784",
4097
+ ok: true,
4098
+ detail: `\u53D1\u73B0 ${findings.length} \u5904\u65E7\u5E03\u5C40\uFF08\u89C1\u4E0B\u65B9 \u26A0 \u63D0\u793A\uFF09`
4099
+ });
4100
+ }
4101
+ }
4010
4102
  checks.push({ name: "\u64CD\u4F5C\u7CFB\u7EDF", ok: true, detail: `${import_os4.default.type()} ${import_os4.default.release()} (${import_os4.default.arch()})` });
4011
4103
  let allOk = true;
4012
4104
  for (const c of checks) {
@@ -4014,6 +4106,9 @@ function makeDoctorCommand() {
4014
4106
  console.log(`${icon} ${c.name}: ${c.detail}`);
4015
4107
  if (!c.ok) allOk = false;
4016
4108
  }
4109
+ for (const w of ontoWarnings) {
4110
+ console.log(`\u26A0\uFE0F ${w}`);
4111
+ }
4017
4112
  ok({ checks, allOk });
4018
4113
  if (!allOk) process.exit(1);
4019
4114
  });
@@ -4044,8 +4139,8 @@ function makeEnvCommand() {
4044
4139
  }
4045
4140
 
4046
4141
  // cli/dazi/src/commands/data.ts
4047
- var import_path5 = __toESM(require("path"), 1);
4048
- var import_fs4 = __toESM(require("fs"), 1);
4142
+ var import_path7 = __toESM(require("path"), 1);
4143
+ var import_fs6 = __toESM(require("fs"), 1);
4049
4144
  function tableListLabel(t) {
4050
4145
  const display = t.display_name?.trim();
4051
4146
  const physical = (t.table_name ?? t.name ?? "").trim();
@@ -4376,14 +4471,14 @@ function makeFileSubCmd() {
4376
4471
  });
4377
4472
  cmd.command("upload <localFile>").description("\u4E0A\u4F20\u672C\u5730\u6587\u4EF6\u5230\u5E73\u53F0").requiredOption("--space <spaceId>", "\u7A7A\u95F4 ID").option("--dest <destPath>", "\u76EE\u6807\u8DEF\u5F84", "/").action(async (localFile, opts) => {
4378
4473
  try {
4379
- if (!import_fs4.default.existsSync(localFile)) {
4474
+ if (!import_fs6.default.existsSync(localFile)) {
4380
4475
  console.error(`\u6587\u4EF6\u4E0D\u5B58\u5728: ${localFile}`);
4381
4476
  process.exit(1);
4382
4477
  }
4383
4478
  const auth = loadAuth();
4384
- const buf = import_fs4.default.readFileSync(localFile);
4479
+ const buf = import_fs6.default.readFileSync(localFile);
4385
4480
  const formData = new FormData();
4386
- formData.append("file", new Blob([buf]), import_path5.default.basename(localFile));
4481
+ formData.append("file", new Blob([buf]), import_path7.default.basename(localFile));
4387
4482
  formData.append("destDir", opts.dest);
4388
4483
  formData.append("spaceId", opts.space);
4389
4484
  const url = `${auth.serverUrl.replace(/\/$/, "")}/api/dataspaces/${opts.space}/native-scripts/upload`;
@@ -4414,36 +4509,36 @@ function makeDataCommand() {
4414
4509
  }
4415
4510
 
4416
4511
  // cli/dazi/src/commands/docs.ts
4417
- var import_path6 = __toESM(require("path"), 1);
4418
- var import_fs5 = __toESM(require("fs"), 1);
4512
+ var import_path8 = __toESM(require("path"), 1);
4513
+ var import_fs7 = __toESM(require("fs"), 1);
4419
4514
  function resolveBundledDocsDir() {
4420
4515
  const bundledDir = process.env.DAZI_BUNDLED_DIR;
4421
4516
  if (bundledDir) {
4422
- const p = import_path6.default.resolve(bundledDir, "..", "docs");
4423
- if (import_fs5.default.existsSync(p)) return p;
4517
+ const p = import_path8.default.resolve(bundledDir, "..", "docs");
4518
+ if (import_fs7.default.existsSync(p)) return p;
4424
4519
  }
4425
4520
  const candidates = [
4426
- import_path6.default.resolve(__dirname, "..", "..", "docs"),
4521
+ import_path8.default.resolve(__dirname, "..", "..", "docs"),
4427
4522
  // dist layout
4428
- import_path6.default.resolve(process.execPath, "..", "docs")
4523
+ import_path8.default.resolve(process.execPath, "..", "docs")
4429
4524
  ];
4430
- return candidates.find((c) => import_fs5.default.existsSync(c)) ?? null;
4525
+ return candidates.find((c) => import_fs7.default.existsSync(c)) ?? null;
4431
4526
  }
4432
4527
  function loadBundledIndex(bundledDir) {
4433
- const indexPath = import_path6.default.join(bundledDir, "index.json");
4434
- if (!import_fs5.default.existsSync(indexPath)) return [];
4528
+ const indexPath = import_path8.default.join(bundledDir, "index.json");
4529
+ if (!import_fs7.default.existsSync(indexPath)) return [];
4435
4530
  try {
4436
- const raw = JSON.parse(import_fs5.default.readFileSync(indexPath, "utf-8"));
4531
+ const raw = JSON.parse(import_fs7.default.readFileSync(indexPath, "utf-8"));
4437
4532
  return raw.docs ?? [];
4438
4533
  } catch {
4439
4534
  return [];
4440
4535
  }
4441
4536
  }
4442
4537
  function loadWorkspaceIndex(ws) {
4443
- const indexPath = import_path6.default.join(ws.docs, "index.json");
4444
- if (!import_fs5.default.existsSync(indexPath)) return [];
4538
+ const indexPath = import_path8.default.join(ws.docs, "index.json");
4539
+ if (!import_fs7.default.existsSync(indexPath)) return [];
4445
4540
  try {
4446
- const raw = JSON.parse(import_fs5.default.readFileSync(indexPath, "utf-8"));
4541
+ const raw = JSON.parse(import_fs7.default.readFileSync(indexPath, "utf-8"));
4447
4542
  return raw.docs ?? [];
4448
4543
  } catch {
4449
4544
  return [];
@@ -4494,9 +4589,9 @@ function makeDocsCommand() {
4494
4589
  const wsIndex = loadWorkspaceIndex(ws);
4495
4590
  const wsEntry = wsIndex.find((d) => d.id === topicId);
4496
4591
  if (wsEntry) {
4497
- const p = import_path6.default.join(ws.docs, wsEntry.file);
4498
- if (import_fs5.default.existsSync(p)) {
4499
- content = import_fs5.default.readFileSync(p, "utf-8");
4592
+ const p = import_path8.default.join(ws.docs, wsEntry.file);
4593
+ if (import_fs7.default.existsSync(p)) {
4594
+ content = import_fs7.default.readFileSync(p, "utf-8");
4500
4595
  source = "workspace";
4501
4596
  }
4502
4597
  }
@@ -4504,9 +4599,9 @@ function makeDocsCommand() {
4504
4599
  const bIndex = loadBundledIndex(bundledDir);
4505
4600
  const bEntry = bIndex.find((d) => d.id === topicId);
4506
4601
  if (bEntry) {
4507
- const p = import_path6.default.join(bundledDir, bEntry.file);
4508
- if (import_fs5.default.existsSync(p)) {
4509
- content = import_fs5.default.readFileSync(p, "utf-8");
4602
+ const p = import_path8.default.join(bundledDir, bEntry.file);
4603
+ if (import_fs7.default.existsSync(p)) {
4604
+ content = import_fs7.default.readFileSync(p, "utf-8");
4510
4605
  source = "bundled";
4511
4606
  }
4512
4607
  }
@@ -4526,7 +4621,7 @@ function makeDocsCommand() {
4526
4621
  cmd.command("sync").description("\u5C06\u5185\u7F6E\u6587\u6863\u540C\u6B65\u5230\u5DE5\u4F5C\u533A \u8D44\u6E90/docs/\uFF08\u9ED8\u8BA4\u8986\u76D6\u5DF2\u6709\u6587\u4EF6\uFF09").option("--skip-existing", "\u5DF2\u5B58\u5728\u65F6\u8DF3\u8FC7\uFF08\u4E0D\u8986\u76D6\uFF09").option("--from-platform", "\u4ECE\u5E73\u53F0\u540C\u6B65\u6587\u6863\uFF08\u9700\u767B\u5F55\uFF09").option("--dry-run", "\u4EC5\u9884\u89C8").action(async (opts) => {
4527
4622
  try {
4528
4623
  const ws = resolveWorkspace();
4529
- if (!import_fs5.default.existsSync(ws.docs)) import_fs5.default.mkdirSync(ws.docs, { recursive: true });
4624
+ if (!import_fs7.default.existsSync(ws.docs)) import_fs7.default.mkdirSync(ws.docs, { recursive: true });
4530
4625
  if (opts.fromPlatform) {
4531
4626
  const docs = await apiRequest(
4532
4627
  "/api/v1/docs"
@@ -4543,24 +4638,24 @@ function makeDocsCommand() {
4543
4638
  const index = loadBundledIndex(bundledDir);
4544
4639
  let synced = 0, skipped = 0;
4545
4640
  for (const entry of index) {
4546
- const srcFile = import_path6.default.join(bundledDir, entry.file);
4547
- const dstFile = import_path6.default.join(ws.docs, entry.file);
4548
- if (!import_fs5.default.existsSync(srcFile)) continue;
4549
- if (import_fs5.default.existsSync(dstFile) && opts.skipExisting) {
4641
+ const srcFile = import_path8.default.join(bundledDir, entry.file);
4642
+ const dstFile = import_path8.default.join(ws.docs, entry.file);
4643
+ if (!import_fs7.default.existsSync(srcFile)) continue;
4644
+ if (import_fs7.default.existsSync(dstFile) && opts.skipExisting) {
4550
4645
  skipped++;
4551
4646
  if (opts.dryRun) console.log(` skip (\u5DF2\u5B58\u5728): ${entry.file}`);
4552
4647
  continue;
4553
4648
  }
4554
4649
  if (!opts.dryRun) {
4555
- const dstDir = import_path6.default.dirname(dstFile);
4556
- if (!import_fs5.default.existsSync(dstDir)) import_fs5.default.mkdirSync(dstDir, { recursive: true });
4557
- import_fs5.default.copyFileSync(srcFile, dstFile);
4650
+ const dstDir = import_path8.default.dirname(dstFile);
4651
+ if (!import_fs7.default.existsSync(dstDir)) import_fs7.default.mkdirSync(dstDir, { recursive: true });
4652
+ import_fs7.default.copyFileSync(srcFile, dstFile);
4558
4653
  }
4559
4654
  console.log(` ${opts.dryRun ? "[dry-run] " : ""}\u2192 ${entry.file}`);
4560
4655
  synced++;
4561
4656
  }
4562
4657
  if (!opts.dryRun) {
4563
- import_fs5.default.copyFileSync(import_path6.default.join(bundledDir, "index.json"), import_path6.default.join(ws.docs, "index.json"));
4658
+ import_fs7.default.copyFileSync(import_path8.default.join(bundledDir, "index.json"), import_path8.default.join(ws.docs, "index.json"));
4564
4659
  }
4565
4660
  console.log(`${opts.dryRun ? "[dry-run] " : ""}\u540C\u6B65 ${synced} \u7BC7\uFF0C\u8DF3\u8FC7 ${skipped} \u7BC7`);
4566
4661
  ok({ synced, skipped, dryRun: opts.dryRun });
@@ -4571,10 +4666,10 @@ function makeDocsCommand() {
4571
4666
  cmd.command("index").description("\u91CD\u5EFA\u5DE5\u4F5C\u533A docs/index.json").action(() => {
4572
4667
  try {
4573
4668
  const ws = resolveWorkspace();
4574
- if (!import_fs5.default.existsSync(ws.docs)) import_fs5.default.mkdirSync(ws.docs, { recursive: true });
4575
- const files = import_fs5.default.readdirSync(ws.docs, { recursive: true }).filter((f) => typeof f === "string" && f.endsWith(".md")).map((f) => ({ file: f.replace(/\\/g, "/"), id: f.replace(/\\/g, "/").replace(/\.md$/, "") }));
4576
- const indexPath = import_path6.default.join(ws.docs, "index.json");
4577
- import_fs5.default.writeFileSync(indexPath, JSON.stringify({ docs: files, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
4669
+ if (!import_fs7.default.existsSync(ws.docs)) import_fs7.default.mkdirSync(ws.docs, { recursive: true });
4670
+ const files = import_fs7.default.readdirSync(ws.docs, { recursive: true }).filter((f) => typeof f === "string" && f.endsWith(".md")).map((f) => ({ file: f.replace(/\\/g, "/"), id: f.replace(/\\/g, "/").replace(/\.md$/, "") }));
4671
+ const indexPath = import_path8.default.join(ws.docs, "index.json");
4672
+ import_fs7.default.writeFileSync(indexPath, JSON.stringify({ docs: files, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
4578
4673
  console.log(`\u2705 docs/index.json \u5DF2\u66F4\u65B0 (${files.length} \u7BC7)`);
4579
4674
  ok({ count: files.length });
4580
4675
  } catch (err2) {
@@ -4585,24 +4680,24 @@ function makeDocsCommand() {
4585
4680
  }
4586
4681
 
4587
4682
  // cli/dazi/src/commands/prompt.ts
4588
- var import_path7 = __toESM(require("path"), 1);
4589
- var import_fs6 = __toESM(require("fs"), 1);
4683
+ var import_path9 = __toESM(require("path"), 1);
4684
+ var import_fs8 = __toESM(require("fs"), 1);
4590
4685
  function resolveBundledPromptsDir() {
4591
4686
  const bundledDir = process.env.DAZI_BUNDLED_DIR;
4592
4687
  if (bundledDir) {
4593
- const p = import_path7.default.resolve(bundledDir, "..", "prompts");
4594
- if (import_fs6.default.existsSync(p)) return p;
4688
+ const p = import_path9.default.resolve(bundledDir, "..", "prompts");
4689
+ if (import_fs8.default.existsSync(p)) return p;
4595
4690
  }
4596
4691
  const candidates = [
4597
- import_path7.default.resolve(__dirname, "..", "..", "prompts")
4692
+ import_path9.default.resolve(__dirname, "..", "..", "prompts")
4598
4693
  ];
4599
- return candidates.find((c) => import_fs6.default.existsSync(c)) ?? null;
4694
+ return candidates.find((c) => import_fs8.default.existsSync(c)) ?? null;
4600
4695
  }
4601
4696
  function loadIndex(dir) {
4602
- const indexPath = import_path7.default.join(dir, "index.json");
4603
- if (!import_fs6.default.existsSync(indexPath)) return [];
4697
+ const indexPath = import_path9.default.join(dir, "index.json");
4698
+ if (!import_fs8.default.existsSync(indexPath)) return [];
4604
4699
  try {
4605
- const raw = JSON.parse(import_fs6.default.readFileSync(indexPath, "utf-8"));
4700
+ const raw = JSON.parse(import_fs8.default.readFileSync(indexPath, "utf-8"));
4606
4701
  return raw.prompts ?? [];
4607
4702
  } catch {
4608
4703
  return [];
@@ -4616,7 +4711,7 @@ function makePromptCommand() {
4616
4711
  const bundled = bundledDir ? loadIndex(bundledDir) : [];
4617
4712
  const ws = resolveWorkspace();
4618
4713
  const wsPromptDir = ws.prompts;
4619
- const workspace = import_fs6.default.existsSync(wsPromptDir) ? loadIndex(wsPromptDir) : [];
4714
+ const workspace = import_fs8.default.existsSync(wsPromptDir) ? loadIndex(wsPromptDir) : [];
4620
4715
  const map = /* @__PURE__ */ new Map();
4621
4716
  bundled.forEach((p) => map.set(p.id, { ...p, source: "bundled" }));
4622
4717
  workspace.forEach((p) => map.set(p.id, { ...p, source: "workspace" }));
@@ -4652,13 +4747,13 @@ function makePromptCommand() {
4652
4747
  let content = null;
4653
4748
  let source = "";
4654
4749
  const wsPromptDir = ws.prompts;
4655
- if (import_fs6.default.existsSync(wsPromptDir)) {
4750
+ if (import_fs8.default.existsSync(wsPromptDir)) {
4656
4751
  const wsIndex = loadIndex(wsPromptDir);
4657
4752
  const entry = wsIndex.find((p) => p.id === topicId);
4658
4753
  if (entry) {
4659
- const p = import_path7.default.join(wsPromptDir, entry.file);
4660
- if (import_fs6.default.existsSync(p)) {
4661
- content = import_fs6.default.readFileSync(p, "utf-8");
4754
+ const p = import_path9.default.join(wsPromptDir, entry.file);
4755
+ if (import_fs8.default.existsSync(p)) {
4756
+ content = import_fs8.default.readFileSync(p, "utf-8");
4662
4757
  source = "workspace";
4663
4758
  }
4664
4759
  }
@@ -4667,9 +4762,9 @@ function makePromptCommand() {
4667
4762
  const bIndex = loadIndex(bundledDir);
4668
4763
  const entry = bIndex.find((p) => p.id === topicId);
4669
4764
  if (entry) {
4670
- const p = import_path7.default.join(bundledDir, entry.file);
4671
- if (import_fs6.default.existsSync(p)) {
4672
- content = import_fs6.default.readFileSync(p, "utf-8");
4765
+ const p = import_path9.default.join(bundledDir, entry.file);
4766
+ if (import_fs8.default.existsSync(p)) {
4767
+ content = import_fs8.default.readFileSync(p, "utf-8");
4673
4768
  source = "bundled";
4674
4769
  }
4675
4770
  }
@@ -4695,28 +4790,28 @@ function makePromptCommand() {
4695
4790
  }
4696
4791
  const ws = resolveWorkspace();
4697
4792
  const wsPromptDir = ws.prompts;
4698
- if (!import_fs6.default.existsSync(wsPromptDir)) import_fs6.default.mkdirSync(wsPromptDir, { recursive: true });
4793
+ if (!import_fs8.default.existsSync(wsPromptDir)) import_fs8.default.mkdirSync(wsPromptDir, { recursive: true });
4699
4794
  const index = loadIndex(bundledDir);
4700
4795
  let synced = 0, skipped = 0;
4701
4796
  for (const entry of index) {
4702
- const srcFile = import_path7.default.join(bundledDir, entry.file);
4703
- const dstFile = import_path7.default.join(wsPromptDir, entry.file);
4704
- if (!import_fs6.default.existsSync(srcFile)) continue;
4705
- if (import_fs6.default.existsSync(dstFile) && opts.skipExisting) {
4797
+ const srcFile = import_path9.default.join(bundledDir, entry.file);
4798
+ const dstFile = import_path9.default.join(wsPromptDir, entry.file);
4799
+ if (!import_fs8.default.existsSync(srcFile)) continue;
4800
+ if (import_fs8.default.existsSync(dstFile) && opts.skipExisting) {
4706
4801
  skipped++;
4707
4802
  if (opts.dryRun) console.log(` skip (\u5DF2\u5B58\u5728): ${entry.file}`);
4708
4803
  continue;
4709
4804
  }
4710
4805
  if (!opts.dryRun) {
4711
- const dstDir = import_path7.default.dirname(dstFile);
4712
- if (!import_fs6.default.existsSync(dstDir)) import_fs6.default.mkdirSync(dstDir, { recursive: true });
4713
- import_fs6.default.copyFileSync(srcFile, dstFile);
4806
+ const dstDir = import_path9.default.dirname(dstFile);
4807
+ if (!import_fs8.default.existsSync(dstDir)) import_fs8.default.mkdirSync(dstDir, { recursive: true });
4808
+ import_fs8.default.copyFileSync(srcFile, dstFile);
4714
4809
  }
4715
4810
  console.log(` ${opts.dryRun ? "[dry-run] " : ""}\u2192 ${entry.file}`);
4716
4811
  synced++;
4717
4812
  }
4718
4813
  if (!opts.dryRun) {
4719
- import_fs6.default.copyFileSync(import_path7.default.join(bundledDir, "index.json"), import_path7.default.join(wsPromptDir, "index.json"));
4814
+ import_fs8.default.copyFileSync(import_path9.default.join(bundledDir, "index.json"), import_path9.default.join(wsPromptDir, "index.json"));
4720
4815
  }
4721
4816
  console.log(`${opts.dryRun ? "[dry-run] " : ""}\u540C\u6B65 ${synced} \u7BC7\uFF0C\u8DF3\u8FC7 ${skipped} \u7BC7`);
4722
4817
  ok({ synced, skipped });
@@ -4728,37 +4823,37 @@ function makePromptCommand() {
4728
4823
  }
4729
4824
 
4730
4825
  // cli/dazi/src/commands/examples.ts
4731
- var import_path8 = __toESM(require("path"), 1);
4732
- var import_fs7 = __toESM(require("fs"), 1);
4826
+ var import_path10 = __toESM(require("path"), 1);
4827
+ var import_fs9 = __toESM(require("fs"), 1);
4733
4828
  function resolveBundledExamplesDir() {
4734
4829
  const bundledDir = process.env.DAZI_BUNDLED_DIR;
4735
4830
  if (bundledDir) {
4736
- const p = import_path8.default.resolve(bundledDir, "..", "examples");
4737
- if (import_fs7.default.existsSync(p)) return p;
4831
+ const p = import_path10.default.resolve(bundledDir, "..", "examples");
4832
+ if (import_fs9.default.existsSync(p)) return p;
4738
4833
  }
4739
4834
  const candidates = [
4740
- import_path8.default.resolve(__dirname, "..", "..", "examples")
4835
+ import_path10.default.resolve(__dirname, "..", "..", "examples")
4741
4836
  ];
4742
- return candidates.find((c) => import_fs7.default.existsSync(c)) ?? null;
4837
+ return candidates.find((c) => import_fs9.default.existsSync(c)) ?? null;
4743
4838
  }
4744
4839
  function loadIndex2(dir) {
4745
- const indexPath = import_path8.default.join(dir, "index.json");
4746
- if (!import_fs7.default.existsSync(indexPath)) return [];
4840
+ const indexPath = import_path10.default.join(dir, "index.json");
4841
+ if (!import_fs9.default.existsSync(indexPath)) return [];
4747
4842
  try {
4748
- const raw = JSON.parse(import_fs7.default.readFileSync(indexPath, "utf-8"));
4843
+ const raw = JSON.parse(import_fs9.default.readFileSync(indexPath, "utf-8"));
4749
4844
  return raw.examples ?? [];
4750
4845
  } catch {
4751
4846
  return [];
4752
4847
  }
4753
4848
  }
4754
4849
  function resolveExampleFile(topicId, wsExamplesDir, bundledDir) {
4755
- if (import_fs7.default.existsSync(wsExamplesDir)) {
4850
+ if (import_fs9.default.existsSync(wsExamplesDir)) {
4756
4851
  const wsIndex = loadIndex2(wsExamplesDir);
4757
4852
  const wsEntry = wsIndex.find((e) => e.id === topicId);
4758
4853
  if (wsEntry) {
4759
- const p = import_path8.default.join(wsExamplesDir, wsEntry.file);
4760
- if (import_fs7.default.existsSync(p)) {
4761
- return { content: import_fs7.default.readFileSync(p, "utf-8"), source: "workspace", filePath: p };
4854
+ const p = import_path10.default.join(wsExamplesDir, wsEntry.file);
4855
+ if (import_fs9.default.existsSync(p)) {
4856
+ return { content: import_fs9.default.readFileSync(p, "utf-8"), source: "workspace", filePath: p };
4762
4857
  }
4763
4858
  }
4764
4859
  }
@@ -4766,9 +4861,9 @@ function resolveExampleFile(topicId, wsExamplesDir, bundledDir) {
4766
4861
  const bIndex = loadIndex2(bundledDir);
4767
4862
  const bEntry = bIndex.find((e) => e.id === topicId);
4768
4863
  if (bEntry) {
4769
- const p = import_path8.default.join(bundledDir, bEntry.file);
4770
- if (import_fs7.default.existsSync(p)) {
4771
- return { content: import_fs7.default.readFileSync(p, "utf-8"), source: "bundled", filePath: p };
4864
+ const p = import_path10.default.join(bundledDir, bEntry.file);
4865
+ if (import_fs9.default.existsSync(p)) {
4866
+ return { content: import_fs9.default.readFileSync(p, "utf-8"), source: "bundled", filePath: p };
4772
4867
  }
4773
4868
  }
4774
4869
  }
@@ -4782,7 +4877,7 @@ function makeExamplesCommand() {
4782
4877
  const bundled = bundledDir ? loadIndex2(bundledDir) : [];
4783
4878
  const ws = resolveWorkspace();
4784
4879
  const wsExamplesDir = ws.examples;
4785
- const workspace = import_fs7.default.existsSync(wsExamplesDir) ? loadIndex2(wsExamplesDir) : [];
4880
+ const workspace = import_fs9.default.existsSync(wsExamplesDir) ? loadIndex2(wsExamplesDir) : [];
4786
4881
  const map = /* @__PURE__ */ new Map();
4787
4882
  bundled.forEach((e) => map.set(e.id, { ...e, source: "bundled" }));
4788
4883
  workspace.forEach((e) => map.set(e.id, { ...e, source: "workspace" }));
@@ -4838,31 +4933,31 @@ function makeExamplesCommand() {
4838
4933
  }
4839
4934
  const ws = resolveWorkspace();
4840
4935
  const wsExamplesDir = ws.examples;
4841
- if (!import_fs7.default.existsSync(wsExamplesDir)) import_fs7.default.mkdirSync(wsExamplesDir, { recursive: true });
4936
+ if (!import_fs9.default.existsSync(wsExamplesDir)) import_fs9.default.mkdirSync(wsExamplesDir, { recursive: true });
4842
4937
  const index = loadIndex2(bundledDir);
4843
4938
  let synced = 0, skipped = 0;
4844
4939
  for (const entry of index) {
4845
- const srcFile = import_path8.default.join(bundledDir, entry.file);
4846
- const dstFile = import_path8.default.join(wsExamplesDir, entry.file);
4847
- if (!import_fs7.default.existsSync(srcFile)) {
4940
+ const srcFile = import_path10.default.join(bundledDir, entry.file);
4941
+ const dstFile = import_path10.default.join(wsExamplesDir, entry.file);
4942
+ if (!import_fs9.default.existsSync(srcFile)) {
4848
4943
  console.warn(` \u8DF3\u8FC7\uFF08\u6E90\u6587\u4EF6\u7F3A\u5931\uFF09: ${entry.file}`);
4849
4944
  continue;
4850
4945
  }
4851
- if (import_fs7.default.existsSync(dstFile) && opts.skipExisting) {
4946
+ if (import_fs9.default.existsSync(dstFile) && opts.skipExisting) {
4852
4947
  skipped++;
4853
4948
  if (opts.dryRun) console.log(` skip (\u5DF2\u5B58\u5728): ${entry.file}`);
4854
4949
  continue;
4855
4950
  }
4856
4951
  if (!opts.dryRun) {
4857
- const dstDir = import_path8.default.dirname(dstFile);
4858
- if (!import_fs7.default.existsSync(dstDir)) import_fs7.default.mkdirSync(dstDir, { recursive: true });
4859
- import_fs7.default.copyFileSync(srcFile, dstFile);
4952
+ const dstDir = import_path10.default.dirname(dstFile);
4953
+ if (!import_fs9.default.existsSync(dstDir)) import_fs9.default.mkdirSync(dstDir, { recursive: true });
4954
+ import_fs9.default.copyFileSync(srcFile, dstFile);
4860
4955
  }
4861
4956
  console.log(` ${opts.dryRun ? "[dry-run] " : ""}\u2192 ${entry.file}`);
4862
4957
  synced++;
4863
4958
  }
4864
4959
  if (!opts.dryRun) {
4865
- import_fs7.default.copyFileSync(import_path8.default.join(bundledDir, "index.json"), import_path8.default.join(wsExamplesDir, "index.json"));
4960
+ import_fs9.default.copyFileSync(import_path10.default.join(bundledDir, "index.json"), import_path10.default.join(wsExamplesDir, "index.json"));
4866
4961
  }
4867
4962
  console.log(`${opts.dryRun ? "[dry-run] " : ""}\u540C\u6B65 ${synced} \u4E2A\uFF0C\u8DF3\u8FC7 ${skipped} \u4E2A`);
4868
4963
  ok({ synced, skipped });
@@ -4875,44 +4970,44 @@ function makeExamplesCommand() {
4875
4970
 
4876
4971
  // cli/dazi/src/commands/migrate.ts
4877
4972
  var import_os6 = __toESM(require("os"), 1);
4878
- var import_path9 = __toESM(require("path"), 1);
4879
- var import_fs8 = __toESM(require("fs"), 1);
4973
+ var import_path11 = __toESM(require("path"), 1);
4974
+ var import_fs10 = __toESM(require("fs"), 1);
4880
4975
  function buildMigratePlan(wsRoot) {
4881
4976
  const actions = [];
4882
- const ontologyDir = import_path9.default.join(wsRoot, "ontology");
4883
- const ontoDir = import_path9.default.join(wsRoot, "onto");
4884
- if (import_fs8.default.existsSync(ontologyDir) && !import_fs8.default.existsSync(ontoDir)) {
4977
+ const ontologyDir = import_path11.default.join(wsRoot, "ontology");
4978
+ const ontoDir = import_path11.default.join(wsRoot, "onto");
4979
+ if (import_fs10.default.existsSync(ontologyDir) && !import_fs10.default.existsSync(ontoDir)) {
4885
4980
  actions.push({ type: "rename", src: ontologyDir, dest: ontoDir, label: "ontology/ \u2192 onto/" });
4886
- } else if (!import_fs8.default.existsSync(ontoDir)) {
4981
+ } else if (!import_fs10.default.existsSync(ontoDir)) {
4887
4982
  actions.push({ type: "create", dest: ontoDir, label: "\u65B0\u5EFA onto/" });
4888
4983
  }
4889
- const isDrapRoot = (dir) => import_fs8.default.existsSync(import_path9.default.join(dir, "templates")) && import_fs8.default.existsSync(import_path9.default.join(dir, "sdk"));
4890
- const runtimeAppsDir = import_path9.default.join(wsRoot, "runtime-apps");
4891
- const appsDir = import_path9.default.join(wsRoot, "apps");
4892
- if (import_fs8.default.existsSync(runtimeAppsDir) && isDrapRoot(runtimeAppsDir)) {
4893
- } else if (import_fs8.default.existsSync(runtimeAppsDir) && !import_fs8.default.existsSync(appsDir)) {
4984
+ const isDrapRoot = (dir) => import_fs10.default.existsSync(import_path11.default.join(dir, "templates")) && import_fs10.default.existsSync(import_path11.default.join(dir, "sdk"));
4985
+ const runtimeAppsDir = import_path11.default.join(wsRoot, "runtime-apps");
4986
+ const appsDir = import_path11.default.join(wsRoot, "apps");
4987
+ if (import_fs10.default.existsSync(runtimeAppsDir) && isDrapRoot(runtimeAppsDir)) {
4988
+ } else if (import_fs10.default.existsSync(runtimeAppsDir) && !import_fs10.default.existsSync(appsDir)) {
4894
4989
  actions.push({ type: "rename", src: runtimeAppsDir, dest: appsDir, label: "runtime-apps/ \u2192 apps/" });
4895
- } else if (!import_fs8.default.existsSync(appsDir) && !import_fs8.default.existsSync(runtimeAppsDir)) {
4990
+ } else if (!import_fs10.default.existsSync(appsDir) && !import_fs10.default.existsSync(runtimeAppsDir)) {
4896
4991
  actions.push({ type: "create", dest: appsDir, label: "\u65B0\u5EFA apps/" });
4897
4992
  }
4898
- const resourcesDir = import_path9.default.join(wsRoot, "\u8D44\u6E90");
4993
+ const resourcesDir = import_path11.default.join(wsRoot, "\u8D44\u6E90");
4899
4994
  for (const dir of ["flows", "data", ".dazi"]) {
4900
- const p = import_path9.default.join(wsRoot, dir);
4901
- if (!import_fs8.default.existsSync(p)) {
4995
+ const p = import_path11.default.join(wsRoot, dir);
4996
+ if (!import_fs10.default.existsSync(p)) {
4902
4997
  actions.push({ type: "create", dest: p, label: `\u65B0\u5EFA ${dir}/` });
4903
4998
  }
4904
4999
  }
4905
- if (!import_fs8.default.existsSync(resourcesDir)) {
5000
+ if (!import_fs10.default.existsSync(resourcesDir)) {
4906
5001
  actions.push({ type: "create", dest: resourcesDir, label: "\u65B0\u5EFA \u8D44\u6E90/" });
4907
5002
  }
4908
5003
  for (const sub of ["dataspaces", "datasources", "docs", "prompts"]) {
4909
- const p = import_path9.default.join(resourcesDir, sub);
4910
- if (!import_fs8.default.existsSync(p)) {
5004
+ const p = import_path11.default.join(resourcesDir, sub);
5005
+ if (!import_fs10.default.existsSync(p)) {
4911
5006
  actions.push({ type: "create", dest: p, label: `\u65B0\u5EFA \u8D44\u6E90/${sub}/` });
4912
5007
  }
4913
5008
  }
4914
- const cfgPath = import_path9.default.join(wsRoot, ".dazi", "config.json");
4915
- if (!import_fs8.default.existsSync(cfgPath)) {
5009
+ const cfgPath = import_path11.default.join(wsRoot, ".dazi", "config.json");
5010
+ if (!import_fs10.default.existsSync(cfgPath)) {
4916
5011
  actions.push({ type: "copy-config", dest: cfgPath, label: "\u751F\u6210 .dazi/config.json" });
4917
5012
  }
4918
5013
  return actions;
@@ -4920,10 +5015,10 @@ function buildMigratePlan(wsRoot) {
4920
5015
  function executeActions(actions, wsRoot, backup) {
4921
5016
  if (backup) {
4922
5017
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
4923
- const backupDir = import_path9.default.join(wsRoot, ".dazi", "backup", ts);
4924
- import_fs8.default.mkdirSync(backupDir, { recursive: true });
5018
+ const backupDir = import_path11.default.join(wsRoot, ".dazi", "backup", ts);
5019
+ import_fs10.default.mkdirSync(backupDir, { recursive: true });
4925
5020
  for (const a of actions.filter((x) => x.type === "rename" && x.src)) {
4926
- const backupPath = import_path9.default.join(backupDir, import_path9.default.basename(a.src));
5021
+ const backupPath = import_path11.default.join(backupDir, import_path11.default.basename(a.src));
4927
5022
  copyDirSync(a.src, backupPath);
4928
5023
  console.log(` \u{1F4E6} \u5907\u4EFD: ${a.src} \u2192 ${backupPath}`);
4929
5024
  }
@@ -4931,16 +5026,16 @@ function executeActions(actions, wsRoot, backup) {
4931
5026
  for (const action of actions) {
4932
5027
  switch (action.type) {
4933
5028
  case "rename":
4934
- import_fs8.default.renameSync(action.src, action.dest);
5029
+ import_fs10.default.renameSync(action.src, action.dest);
4935
5030
  console.log(` \u2705 \u91CD\u547D\u540D: ${action.label}`);
4936
5031
  break;
4937
5032
  case "create":
4938
- import_fs8.default.mkdirSync(action.dest, { recursive: true });
5033
+ import_fs10.default.mkdirSync(action.dest, { recursive: true });
4939
5034
  console.log(` \u2705 \u521B\u5EFA: ${action.label}`);
4940
5035
  break;
4941
5036
  case "copy-config":
4942
- import_fs8.default.mkdirSync(import_path9.default.dirname(action.dest), { recursive: true });
4943
- import_fs8.default.writeFileSync(action.dest, JSON.stringify({
5037
+ import_fs10.default.mkdirSync(import_path11.default.dirname(action.dest), { recursive: true });
5038
+ import_fs10.default.writeFileSync(action.dest, JSON.stringify({
4944
5039
  migratedAt: (/* @__PURE__ */ new Date()).toISOString(),
4945
5040
  migratedBy: "dazi migrate workspace"
4946
5041
  }, null, 2));
@@ -4950,26 +5045,26 @@ function executeActions(actions, wsRoot, backup) {
4950
5045
  }
4951
5046
  }
4952
5047
  function copyDirSync(src, dest) {
4953
- if (!import_fs8.default.existsSync(src)) return;
4954
- import_fs8.default.mkdirSync(dest, { recursive: true });
4955
- for (const entry of import_fs8.default.readdirSync(src, { withFileTypes: true })) {
4956
- const s = import_path9.default.join(src, entry.name);
4957
- const d = import_path9.default.join(dest, entry.name);
5048
+ if (!import_fs10.default.existsSync(src)) return;
5049
+ import_fs10.default.mkdirSync(dest, { recursive: true });
5050
+ for (const entry of import_fs10.default.readdirSync(src, { withFileTypes: true })) {
5051
+ const s = import_path11.default.join(src, entry.name);
5052
+ const d = import_path11.default.join(dest, entry.name);
4958
5053
  if (entry.isDirectory()) copyDirSync(s, d);
4959
- else import_fs8.default.copyFileSync(s, d);
5054
+ else import_fs10.default.copyFileSync(s, d);
4960
5055
  }
4961
5056
  }
4962
5057
  function makeMigrateCommand() {
4963
5058
  const cmd = new Command("migrate").description("\u8FC1\u79FB\u65E7\u7248\u914D\u7F6E / \u5DE5\u4F5C\u533A");
4964
5059
  cmd.command("config").description("\u5C06\u65E7\u7248 ~/.dazi-app/auth.json \u2192 ~/.dazi/auth.json").action(() => {
4965
5060
  try {
4966
- const legacyPath = import_path9.default.join(import_os6.default.homedir(), ".dazi-app", "auth.json");
4967
- if (!import_fs8.default.existsSync(legacyPath)) {
5061
+ const legacyPath = import_path11.default.join(import_os6.default.homedir(), ".dazi-app", "auth.json");
5062
+ if (!import_fs10.default.existsSync(legacyPath)) {
4968
5063
  console.log("\u672A\u627E\u5230\u65E7\u7248\u8BA4\u8BC1\u6587\u4EF6\uFF0C\u65E0\u9700\u8FC1\u79FB");
4969
5064
  ok({ migrated: false });
4970
5065
  return;
4971
5066
  }
4972
- const legacy = JSON.parse(import_fs8.default.readFileSync(legacyPath, "utf-8"));
5067
+ const legacy = JSON.parse(import_fs10.default.readFileSync(legacyPath, "utf-8"));
4973
5068
  saveAuth({
4974
5069
  token: legacy.token ?? "",
4975
5070
  userId: legacy.userId ?? "",
@@ -4985,9 +5080,9 @@ function makeMigrateCommand() {
4985
5080
  });
4986
5081
  cmd.command("workspace").description("\u5C06\u65E7\u7248\u5DE5\u4F5C\u533A\u76EE\u5F55\u5E03\u5C40\u8FC1\u79FB\u81F3 v3 \u89C4\u8303").argument("[dir]", "\u5DE5\u4F5C\u533A\u76EE\u5F55\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09", ".").option("--dry-run", "\u4EC5\u9884\u89C8\u53D8\u66F4\uFF0C\u4E0D\u6267\u884C", false).option("--no-backup", "\u8DF3\u8FC7\u5907\u4EFD\u6B65\u9AA4\uFF08\u5371\u9669\uFF09").action((dir, opts) => {
4987
5082
  try {
4988
- const wsRoot = import_path9.default.resolve(dir);
5083
+ const wsRoot = import_path11.default.resolve(dir);
4989
5084
  console.log(`\u5DE5\u4F5C\u533A: ${wsRoot}`);
4990
- if (!import_fs8.default.existsSync(wsRoot)) {
5085
+ if (!import_fs10.default.existsSync(wsRoot)) {
4991
5086
  console.error(`\u76EE\u5F55\u4E0D\u5B58\u5728: ${wsRoot}`);
4992
5087
  process.exit(1);
4993
5088
  }
@@ -5047,8 +5142,8 @@ function makeQuickstartCommand() {
5047
5142
  }
5048
5143
 
5049
5144
  // cli/dazi/src/commands/mcp.ts
5050
- var import_path10 = __toESM(require("path"), 1);
5051
- var import_fs9 = __toESM(require("fs"), 1);
5145
+ var import_path12 = __toESM(require("path"), 1);
5146
+ var import_fs11 = __toESM(require("fs"), 1);
5052
5147
  var import_child_process = require("child_process");
5053
5148
  function resolveBundledCliDir() {
5054
5149
  return process.env.DAZI_BUNDLED_DIR ?? null;
@@ -5056,14 +5151,14 @@ function resolveBundledCliDir() {
5056
5151
  function resolveBundledRoot() {
5057
5152
  const cliDir = resolveBundledCliDir();
5058
5153
  if (!cliDir) return null;
5059
- const parent = import_path10.default.resolve(cliDir, "..");
5060
- return import_fs9.default.existsSync(parent) ? parent : null;
5154
+ const parent = import_path12.default.resolve(cliDir, "..");
5155
+ return import_fs11.default.existsSync(parent) ? parent : null;
5061
5156
  }
5062
5157
  function resolveCli(name) {
5063
5158
  const dir = resolveBundledCliDir();
5064
5159
  if (!dir) return null;
5065
- const p = import_path10.default.join(dir, `${name}.js`);
5066
- return import_fs9.default.existsSync(p) ? p : null;
5160
+ const p = import_path12.default.join(dir, `${name}.js`);
5161
+ return import_fs11.default.existsSync(p) ? p : null;
5067
5162
  }
5068
5163
  function callCli(cliName, args) {
5069
5164
  const cliPath = resolveCli(cliName);
@@ -5100,10 +5195,10 @@ function err(msg) {
5100
5195
  function loadDocs() {
5101
5196
  const root = resolveBundledRoot();
5102
5197
  if (!root) return [];
5103
- const idx = import_path10.default.join(root, "docs", "index.json");
5104
- if (!import_fs9.default.existsSync(idx)) return [];
5198
+ const idx = import_path12.default.join(root, "docs", "index.json");
5199
+ if (!import_fs11.default.existsSync(idx)) return [];
5105
5200
  try {
5106
- return JSON.parse(import_fs9.default.readFileSync(idx, "utf-8")).docs ?? [];
5201
+ return JSON.parse(import_fs11.default.readFileSync(idx, "utf-8")).docs ?? [];
5107
5202
  } catch {
5108
5203
  return [];
5109
5204
  }
@@ -5111,16 +5206,16 @@ function loadDocs() {
5111
5206
  function loadPrompts() {
5112
5207
  const root = resolveBundledRoot();
5113
5208
  if (!root) return [];
5114
- const idx = import_path10.default.join(root, "prompts", "index.json");
5115
- if (!import_fs9.default.existsSync(idx)) return [];
5209
+ const idx = import_path12.default.join(root, "prompts", "index.json");
5210
+ if (!import_fs11.default.existsSync(idx)) return [];
5116
5211
  try {
5117
- return JSON.parse(import_fs9.default.readFileSync(idx, "utf-8")).prompts ?? [];
5212
+ return JSON.parse(import_fs11.default.readFileSync(idx, "utf-8")).prompts ?? [];
5118
5213
  } catch {
5119
5214
  return [];
5120
5215
  }
5121
5216
  }
5122
5217
  function readFile(filePath) {
5123
- return import_fs9.default.existsSync(filePath) ? import_fs9.default.readFileSync(filePath, "utf-8") : null;
5218
+ return import_fs11.default.existsSync(filePath) ? import_fs11.default.readFileSync(filePath, "utf-8") : null;
5124
5219
  }
5125
5220
  var MCP_TOOLS = [
5126
5221
  // ── 文档 ──────────────────────────────────────────────────────────────
@@ -5461,7 +5556,7 @@ function handleToolCall(name, args) {
5461
5556
  const entry = loadDocs().find((d) => d.id === String(args.id));
5462
5557
  if (!entry)
5463
5558
  return err(`\u6587\u6863\u672A\u627E\u5230: ${args.id}\uFF08\u4F7F\u7528 list_docs \u67E5\u770B\u53EF\u7528\u6587\u6863\uFF09`);
5464
- const content = readFile(import_path10.default.join(root, "docs", entry.file));
5559
+ const content = readFile(import_path12.default.join(root, "docs", entry.file));
5465
5560
  return content ? text(content) : err(`\u6587\u6863\u6587\u4EF6\u4E0D\u5B58\u5728: ${entry.file}`);
5466
5561
  }
5467
5562
  case "list_prompts": {
@@ -5478,7 +5573,7 @@ function handleToolCall(name, args) {
5478
5573
  return err(
5479
5574
  `\u63D0\u793A\u8BCD\u672A\u627E\u5230: ${args.id}\uFF08\u4F7F\u7528 list_prompts \u67E5\u770B\u53EF\u7528\u63D0\u793A\u8BCD\uFF09`
5480
5575
  );
5481
- const content = readFile(import_path10.default.join(root, "prompts", entry.file));
5576
+ const content = readFile(import_path12.default.join(root, "prompts", entry.file));
5482
5577
  return content ? text(content) : err(`\u63D0\u793A\u8BCD\u6587\u4EF6\u4E0D\u5B58\u5728: ${entry.file}`);
5483
5578
  }
5484
5579
  case "auth_whoami": {
@@ -5797,13 +5892,13 @@ function makeMcpCommand() {
5797
5892
 
5798
5893
  // cli/dazi/src/index.ts
5799
5894
  var import_child_process2 = require("child_process");
5800
- var import_path11 = __toESM(require("path"), 1);
5801
- var import_fs10 = __toESM(require("fs"), 1);
5895
+ var import_path13 = __toESM(require("path"), 1);
5896
+ var import_fs12 = __toESM(require("fs"), 1);
5802
5897
  function resolveBundledCli(name) {
5803
5898
  const dir = process.env.DAZI_BUNDLED_DIR;
5804
5899
  if (!dir) return null;
5805
- const p = import_path11.default.join(dir, `${name}.js`);
5806
- return import_fs10.default.existsSync(p) ? p : null;
5900
+ const p = import_path13.default.join(dir, `${name}.js`);
5901
+ return import_fs12.default.existsSync(p) ? p : null;
5807
5902
  }
5808
5903
  function forwardToCli(cliName, extraArgs) {
5809
5904
  const bundled = resolveBundledCli(cliName);