@dazitech/cli 3.1.0 → 3.1.1

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 (65) hide show
  1. package/README.md +1 -1
  2. package/dist/clis/dazi-app.js +2 -2
  3. package/dist/clis/dazi-flow.js +2 -2
  4. package/dist/clis/dazi-onto.js +318 -40
  5. package/dist/clis/dazi.js +407 -185
  6. package/dist/docs/flow/flow-project-guide.md +1 -1
  7. package/dist/docs/guides/cli-reference.md +16 -3
  8. package/dist/docs/guides/troubleshooting.md +1 -1
  9. package/dist/docs/index.json +1 -13
  10. package/dist/docs/onto/dazi_script_sdk_reference.md +1 -1
  11. package/dist/docs/onto/dazi_script_seed_data_guide.md +1 -1
  12. package/dist/docs/onto/function-guide.md +6 -6
  13. package/dist/docs/onto//346/234/254/344/275/223/345/210/206/347/261/273/350/247/204/345/210/222/344/270/216SDK/346/211/251/345/261/225/346/226/271/346/241/210.md +169 -169
  14. 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 +3 -2
  15. package/dist/docs/onto//346/234/254/344/275/223/345/274/200/345/217/221/344/274/230/345/214/226/346/200/273/347/273/223.md +257 -242
  16. 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 +12 -12
  17. package/dist/docs/onto//346/234/254/344/275/223/350/247/204/345/210/222/346/214/207/345/215/227.md +14 -13
  18. package/dist/docs/onto//350/204/232/346/234/254/350/277/220/350/241/214/345/270/270/350/247/201/351/224/231/350/257/257/345/244/204/347/220/206.md +70 -15
  19. package/dist/examples/index.json +222 -6
  20. package/dist/examples/onto/README.md +34 -36
  21. package/dist/examples/onto/_templates/onto_preflight.ps1 +84 -0
  22. package/dist/examples/onto/index.json +53 -0
  23. package/dist/examples/onto/index.yaml +29 -0
  24. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/README.md +23 -0
  25. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/functions/save_test_arguments.ps1 +12 -11
  26. package/dist/{docs/onto → examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/plans}//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 +4 -4
  27. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_category_mount.py +1 -1
  28. package/dist/examples/onto//345/210/251/346/266/246/347/244/272/344/276/213/setup/profit_ontology_init.py +1 -1
  29. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/README.md +24 -0
  30. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_availability_analysis.py +84 -0
  31. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_downtime_breakdown.py +119 -0
  32. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_energy_intensity.py +98 -0
  33. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_get_summary.py +125 -0
  34. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_maintenance_compliance.py +77 -0
  35. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_mom_analysis.py +118 -0
  36. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_oee_analysis.py +126 -0
  37. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_plan_vs_actual.py +105 -0
  38. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_top_fault_equipment.py +104 -0
  39. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_unit_comparison.py +120 -0
  40. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/equip_ops_fn_yoy_analysis.py +115 -0
  41. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/save_test_arguments.ps1 +42 -0
  42. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.availability_analysis.json +7 -0
  43. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.downtime_breakdown.json +8 -0
  44. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.energy_intensity.json +8 -0
  45. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.get_summary.json +7 -0
  46. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.maintenance_compliance.json +7 -0
  47. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.mom_analysis.json +8 -0
  48. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.oee_analysis.json +8 -0
  49. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.plan_vs_actual.json +8 -0
  50. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.top_fault_equipment.json +8 -0
  51. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.unit_comparison.json +8 -0
  52. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/functions/test_arguments/equip_ops.fn.yoy_analysis.json +8 -0
  53. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/plans//345/214/226/345/267/245/350/256/276/345/244/207/350/277/220/350/220/245/345/210/206/346/236/220/346/234/254/344/275/223/346/226/271/346/241/210.md +735 -0
  54. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/setup/equip_ops_category_mount.py +106 -0
  55. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/setup/equip_ops_ontology_init.py +1077 -0
  56. package/dist/examples/onto//350/256/276/345/244/207/350/277/220/350/220/245/setup/equip_ops_seed_data.py +552 -0
  57. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/README.md +23 -0
  58. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/functions/save_test_arguments.ps1 +13 -12
  59. package/dist/{docs/onto → examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/plans}//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 +2 -2
  60. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_category_mount.py +1 -1
  61. package/dist/examples/onto//351/224/200/345/224/256/347/244/272/344/276/213/setup/sales_ontology_init.py +1 -1
  62. package/dist/prompts/index.json +1 -1
  63. package/dist/prompts/onto/planning-design.md +226 -104
  64. package/dist/prompts/onto/script-publish-run.md +8 -6
  65. package/package.json +1 -1
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 path15 = require("node:path");
970
- var fs18 = require("node:fs");
969
+ var path17 = require("node:path");
970
+ var fs20 = 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 = path15.resolve(baseDir, baseName);
1903
- if (fs18.existsSync(localBin)) return localBin;
1904
- if (sourceExt.includes(path15.extname(baseName))) return void 0;
1902
+ const localBin = path17.resolve(baseDir, baseName);
1903
+ if (fs20.existsSync(localBin)) return localBin;
1904
+ if (sourceExt.includes(path17.extname(baseName))) return void 0;
1905
1905
  const foundExt = sourceExt.find(
1906
- (ext) => fs18.existsSync(`${localBin}${ext}`)
1906
+ (ext) => fs20.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 = fs18.realpathSync(this._scriptPath);
1918
+ resolvedScriptPath = fs20.realpathSync(this._scriptPath);
1919
1919
  } catch (err2) {
1920
1920
  resolvedScriptPath = this._scriptPath;
1921
1921
  }
1922
- executableDir = path15.resolve(
1923
- path15.dirname(resolvedScriptPath),
1922
+ executableDir = path17.resolve(
1923
+ path17.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 = path15.basename(
1930
+ const legacyName = path17.basename(
1931
1931
  this._scriptPath,
1932
- path15.extname(this._scriptPath)
1932
+ path17.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(path15.extname(executableFile));
1943
+ launchWithNode = sourceExt.includes(path17.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 = path15.basename(filename, path15.extname(filename));
2783
+ this._name = path17.basename(filename, path17.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(path16) {
2798
- if (path16 === void 0) return this._executableDir;
2799
- this._executableDir = path16;
2797
+ executableDir(path18) {
2798
+ if (path18 === void 0) return this._executableDir;
2799
+ this._executableDir = path18;
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(path15, opts = {}) {
3729
+ async function apiRequest(path17, 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}${path15}`;
3733
+ const url = `${serverBase}${path17}`;
3734
3734
  const headers = {
3735
3735
  "Content-Type": "application/json",
3736
3736
  Authorization: `Bearer ${auth.token}`,
@@ -3764,7 +3764,7 @@ async function apiRequest(path15, opts = {}) {
3764
3764
  }
3765
3765
  const ctx = {
3766
3766
  method,
3767
- path: path15,
3767
+ path: path17,
3768
3768
  url,
3769
3769
  status: res.status,
3770
3770
  label: opts.label,
@@ -3851,10 +3851,10 @@ function resolveWorkspace(cwd = process.cwd()) {
3851
3851
  };
3852
3852
  }
3853
3853
 
3854
- // cli/shared/src/version.ts
3855
- var DAZI_VERSION = true ? "3.1.0" : readDevVersion();
3854
+ // cli/shared/src/version.js
3855
+ var DAZI_VERSION = true ? "3.1.1" : readDevVersion();
3856
3856
 
3857
- // cli/shared/src/ontoWorkspaceAudit.ts
3857
+ // cli/shared/src/ontoWorkspaceAudit.js
3858
3858
  var import_fs3 = __toESM(require("fs"), 1);
3859
3859
  var import_path4 = __toESM(require("path"), 1);
3860
3860
  var WORKSPACE_PROJECTS_DIR = "\u9879\u76EE";
@@ -3873,9 +3873,11 @@ function existsDir(p) {
3873
3873
  function scanOntoLegacyPaths(wsRoot) {
3874
3874
  const findings = [];
3875
3875
  const projectsDir = import_path4.default.join(wsRoot, WORKSPACE_PROJECTS_DIR);
3876
- if (!existsDir(projectsDir)) return findings;
3876
+ if (!existsDir(projectsDir))
3877
+ return findings;
3877
3878
  for (const ent of import_fs3.default.readdirSync(projectsDir, { withFileTypes: true })) {
3878
- if (!ent.isDirectory()) continue;
3879
+ if (!ent.isDirectory())
3880
+ continue;
3879
3881
  const projectDir = import_path4.default.join(projectsDir, ent.name);
3880
3882
  const relProject = `${WORKSPACE_PROJECTS_DIR}/${ent.name}`;
3881
3883
  if (/^onto_/i.test(ent.name)) {
@@ -3901,9 +3903,11 @@ function scanOntoLegacyPaths(wsRoot) {
3901
3903
  });
3902
3904
  }
3903
3905
  const itemsDir = import_path4.default.join(ontoRoot, ONTO_ITEMS_DIR);
3904
- if (!existsDir(itemsDir)) continue;
3906
+ if (!existsDir(itemsDir))
3907
+ continue;
3905
3908
  for (const item of import_fs3.default.readdirSync(itemsDir, { withFileTypes: true })) {
3906
- if (!item.isDirectory()) continue;
3909
+ if (!item.isDirectory())
3910
+ continue;
3907
3911
  const itemDir = import_path4.default.join(itemsDir, item.name);
3908
3912
  const relItem = `${relProject}/${ONTO_SUBDIR}/${ONTO_ITEMS_DIR}/${item.name}`;
3909
3913
  if (existsDir(import_path4.default.join(itemDir, LEGACY_PLANS_DIR))) {
@@ -3925,10 +3929,79 @@ function scanOntoLegacyPaths(wsRoot) {
3925
3929
  return findings;
3926
3930
  }
3927
3931
 
3932
+ // cli/shared/src/ontoExampleIndex.ts
3933
+ var import_fs4 = __toESM(require("fs"), 1);
3934
+ var import_path5 = __toESM(require("path"), 1);
3935
+ function resolveBundledExamplesDir() {
3936
+ const bundledDir = process.env.DAZI_BUNDLED_DIR;
3937
+ if (bundledDir) {
3938
+ const p = import_path5.default.resolve(bundledDir, "..", "examples");
3939
+ if (import_fs4.default.existsSync(p)) return p;
3940
+ }
3941
+ const candidates = [
3942
+ import_path5.default.resolve(process.cwd(), "examples"),
3943
+ import_path5.default.resolve(process.cwd(), "dazi-vscode/examples")
3944
+ ];
3945
+ return candidates.find((c) => import_fs4.default.existsSync(import_path5.default.join(c, "onto", "index.json"))) ?? null;
3946
+ }
3947
+ function loadOntoExampleIndex(examplesRoot) {
3948
+ const root = examplesRoot ?? resolveBundledExamplesDir();
3949
+ if (!root) return null;
3950
+ const indexPath = import_path5.default.join(root, "onto", "index.json");
3951
+ if (!import_fs4.default.existsSync(indexPath)) return null;
3952
+ try {
3953
+ const raw = JSON.parse(import_fs4.default.readFileSync(indexPath, "utf-8"));
3954
+ if (!Array.isArray(raw.examples)) return null;
3955
+ return raw;
3956
+ } catch {
3957
+ return null;
3958
+ }
3959
+ }
3960
+ function findOntoExample(index, idOrDir) {
3961
+ const key = idOrDir.trim();
3962
+ return index.examples.find((e) => e.id === key) ?? index.examples.find((e) => e.dir === key);
3963
+ }
3964
+ function suggestOntoExamples(index, keywords, limit = 3) {
3965
+ const tokens = keywords.split(/[\s,、,/]+/).map((s) => s.trim().toLowerCase()).filter(Boolean);
3966
+ if (!tokens.length) {
3967
+ const order = index.defaultReadOrder ?? [];
3968
+ const featured = index.examples.filter((e) => e.featured);
3969
+ const sorted = [...featured].sort((a, b) => {
3970
+ const ai = order.indexOf(a.dir);
3971
+ const bi = order.indexOf(b.dir);
3972
+ return (ai < 0 ? 999 : ai) - (bi < 0 ? 999 : bi);
3973
+ });
3974
+ return sorted.slice(0, limit).map((e) => ({ ...e, score: 0 }));
3975
+ }
3976
+ const scored = index.examples.map((ex) => {
3977
+ const hay = [ex.title, ex.dir, ...ex.domain].join(" ").toLowerCase();
3978
+ let score = 0;
3979
+ for (const t of tokens) {
3980
+ if (hay.includes(t)) score += t.length >= 2 ? 2 : 1;
3981
+ for (const d of ex.domain) {
3982
+ if (d.toLowerCase() === t || d.toLowerCase().includes(t)) score += 3;
3983
+ }
3984
+ if (ex.id.toLowerCase() === t) score += 5;
3985
+ }
3986
+ return { ...ex, score };
3987
+ });
3988
+ return scored.filter((e) => e.score > 0).sort((a, b) => b.score - a.score).slice(0, limit);
3989
+ }
3990
+ function ontoExamplePlanRel(entry) {
3991
+ return `onto/${entry.dir}/${entry.planPrimary}`.replace(/\\/g, "/");
3992
+ }
3993
+ function ontoExampleReadmeRel(entry) {
3994
+ return `onto/${entry.dir}/README.md`.replace(/\\/g, "/");
3995
+ }
3996
+ function resolveOntoExampleFile(examplesRoot, relFile) {
3997
+ const p = import_path5.default.join(examplesRoot, relFile.replace(/\//g, import_path5.default.sep));
3998
+ return import_fs4.default.existsSync(p) ? p : null;
3999
+ }
4000
+
3928
4001
  // cli/dazi/src/commands/auth.ts
3929
4002
  var import_os3 = __toESM(require("os"), 1);
3930
- var import_path5 = __toESM(require("path"), 1);
3931
- var import_fs4 = __toESM(require("fs"), 1);
4003
+ var import_path6 = __toESM(require("path"), 1);
4004
+ var import_fs5 = __toESM(require("fs"), 1);
3932
4005
  function makeAuthCommand() {
3933
4006
  const cmd = new Command("auth").description("\u8D26\u53F7\u8BA4\u8BC1");
3934
4007
  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) => {
@@ -4013,10 +4086,10 @@ function makeAuthCommand() {
4013
4086
  });
4014
4087
  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) => {
4015
4088
  const candidates = [];
4016
- const appAuth = import_path5.default.join(import_os3.default.homedir(), ".dazi-app", "auth.json");
4017
- if (import_fs4.default.existsSync(appAuth)) {
4089
+ const appAuth = import_path6.default.join(import_os3.default.homedir(), ".dazi-app", "auth.json");
4090
+ if (import_fs5.default.existsSync(appAuth)) {
4018
4091
  try {
4019
- const d = JSON.parse(import_fs4.default.readFileSync(appAuth, "utf-8"));
4092
+ const d = JSON.parse(import_fs5.default.readFileSync(appAuth, "utf-8"));
4020
4093
  if (d.token) candidates.push({ src: appAuth, label: "dazi-app", data: d });
4021
4094
  } catch {
4022
4095
  }
@@ -4059,8 +4132,8 @@ function makeAuthCommand() {
4059
4132
 
4060
4133
  // cli/dazi/src/commands/doctor.ts
4061
4134
  var import_os4 = __toESM(require("os"), 1);
4062
- var import_path6 = __toESM(require("path"), 1);
4063
- var import_fs5 = __toESM(require("fs"), 1);
4135
+ var import_path7 = __toESM(require("path"), 1);
4136
+ var import_fs6 = __toESM(require("fs"), 1);
4064
4137
  function makeDoctorCommand() {
4065
4138
  return new Command("doctor").description("\u68C0\u67E5\u8FD0\u884C\u73AF\u5883").action(async () => {
4066
4139
  const checks = [];
@@ -4081,8 +4154,8 @@ function makeDoctorCommand() {
4081
4154
  }
4082
4155
  checks.push({ name: `\u7F51\u7EDC\u8FDE\u901A (${getServerUrl()})`, ok: networkOk, detail: networkDetail });
4083
4156
  const ontoWarnings = [];
4084
- const projectsDir = import_path6.default.join(process.cwd(), WORKSPACE_PROJECTS_DIR);
4085
- if (import_fs5.default.existsSync(projectsDir)) {
4157
+ const projectsDir = import_path7.default.join(process.cwd(), WORKSPACE_PROJECTS_DIR);
4158
+ if (import_fs6.default.existsSync(projectsDir)) {
4086
4159
  const findings = scanOntoLegacyPaths(process.cwd());
4087
4160
  if (!findings.length) {
4088
4161
  checks.push({
@@ -4139,8 +4212,8 @@ function makeEnvCommand() {
4139
4212
  }
4140
4213
 
4141
4214
  // cli/dazi/src/commands/data.ts
4142
- var import_path7 = __toESM(require("path"), 1);
4143
- var import_fs6 = __toESM(require("fs"), 1);
4215
+ var import_path8 = __toESM(require("path"), 1);
4216
+ var import_fs7 = __toESM(require("fs"), 1);
4144
4217
  function tableListLabel(t) {
4145
4218
  const display = t.display_name?.trim();
4146
4219
  const physical = (t.table_name ?? t.name ?? "").trim();
@@ -4471,14 +4544,14 @@ function makeFileSubCmd() {
4471
4544
  });
4472
4545
  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) => {
4473
4546
  try {
4474
- if (!import_fs6.default.existsSync(localFile)) {
4547
+ if (!import_fs7.default.existsSync(localFile)) {
4475
4548
  console.error(`\u6587\u4EF6\u4E0D\u5B58\u5728: ${localFile}`);
4476
4549
  process.exit(1);
4477
4550
  }
4478
4551
  const auth = loadAuth();
4479
- const buf = import_fs6.default.readFileSync(localFile);
4552
+ const buf = import_fs7.default.readFileSync(localFile);
4480
4553
  const formData = new FormData();
4481
- formData.append("file", new Blob([buf]), import_path7.default.basename(localFile));
4554
+ formData.append("file", new Blob([buf]), import_path8.default.basename(localFile));
4482
4555
  formData.append("destDir", opts.dest);
4483
4556
  formData.append("spaceId", opts.space);
4484
4557
  const url = `${auth.serverUrl.replace(/\/$/, "")}/api/dataspaces/${opts.space}/native-scripts/upload`;
@@ -4509,36 +4582,36 @@ function makeDataCommand() {
4509
4582
  }
4510
4583
 
4511
4584
  // cli/dazi/src/commands/docs.ts
4512
- var import_path8 = __toESM(require("path"), 1);
4513
- var import_fs7 = __toESM(require("fs"), 1);
4585
+ var import_path9 = __toESM(require("path"), 1);
4586
+ var import_fs8 = __toESM(require("fs"), 1);
4514
4587
  function resolveBundledDocsDir() {
4515
4588
  const bundledDir = process.env.DAZI_BUNDLED_DIR;
4516
4589
  if (bundledDir) {
4517
- const p = import_path8.default.resolve(bundledDir, "..", "docs");
4518
- if (import_fs7.default.existsSync(p)) return p;
4590
+ const p = import_path9.default.resolve(bundledDir, "..", "docs");
4591
+ if (import_fs8.default.existsSync(p)) return p;
4519
4592
  }
4520
4593
  const candidates = [
4521
- import_path8.default.resolve(__dirname, "..", "..", "docs"),
4594
+ import_path9.default.resolve(__dirname, "..", "..", "docs"),
4522
4595
  // dist layout
4523
- import_path8.default.resolve(process.execPath, "..", "docs")
4596
+ import_path9.default.resolve(process.execPath, "..", "docs")
4524
4597
  ];
4525
- return candidates.find((c) => import_fs7.default.existsSync(c)) ?? null;
4598
+ return candidates.find((c) => import_fs8.default.existsSync(c)) ?? null;
4526
4599
  }
4527
4600
  function loadBundledIndex(bundledDir) {
4528
- const indexPath = import_path8.default.join(bundledDir, "index.json");
4529
- if (!import_fs7.default.existsSync(indexPath)) return [];
4601
+ const indexPath = import_path9.default.join(bundledDir, "index.json");
4602
+ if (!import_fs8.default.existsSync(indexPath)) return [];
4530
4603
  try {
4531
- const raw = JSON.parse(import_fs7.default.readFileSync(indexPath, "utf-8"));
4604
+ const raw = JSON.parse(import_fs8.default.readFileSync(indexPath, "utf-8"));
4532
4605
  return raw.docs ?? [];
4533
4606
  } catch {
4534
4607
  return [];
4535
4608
  }
4536
4609
  }
4537
4610
  function loadWorkspaceIndex(ws) {
4538
- const indexPath = import_path8.default.join(ws.docs, "index.json");
4539
- if (!import_fs7.default.existsSync(indexPath)) return [];
4611
+ const indexPath = import_path9.default.join(ws.docs, "index.json");
4612
+ if (!import_fs8.default.existsSync(indexPath)) return [];
4540
4613
  try {
4541
- const raw = JSON.parse(import_fs7.default.readFileSync(indexPath, "utf-8"));
4614
+ const raw = JSON.parse(import_fs8.default.readFileSync(indexPath, "utf-8"));
4542
4615
  return raw.docs ?? [];
4543
4616
  } catch {
4544
4617
  return [];
@@ -4589,9 +4662,9 @@ function makeDocsCommand() {
4589
4662
  const wsIndex = loadWorkspaceIndex(ws);
4590
4663
  const wsEntry = wsIndex.find((d) => d.id === topicId);
4591
4664
  if (wsEntry) {
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");
4665
+ const p = import_path9.default.join(ws.docs, wsEntry.file);
4666
+ if (import_fs8.default.existsSync(p)) {
4667
+ content = import_fs8.default.readFileSync(p, "utf-8");
4595
4668
  source = "workspace";
4596
4669
  }
4597
4670
  }
@@ -4599,9 +4672,9 @@ function makeDocsCommand() {
4599
4672
  const bIndex = loadBundledIndex(bundledDir);
4600
4673
  const bEntry = bIndex.find((d) => d.id === topicId);
4601
4674
  if (bEntry) {
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");
4675
+ const p = import_path9.default.join(bundledDir, bEntry.file);
4676
+ if (import_fs8.default.existsSync(p)) {
4677
+ content = import_fs8.default.readFileSync(p, "utf-8");
4605
4678
  source = "bundled";
4606
4679
  }
4607
4680
  }
@@ -4621,7 +4694,7 @@ function makeDocsCommand() {
4621
4694
  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) => {
4622
4695
  try {
4623
4696
  const ws = resolveWorkspace();
4624
- if (!import_fs7.default.existsSync(ws.docs)) import_fs7.default.mkdirSync(ws.docs, { recursive: true });
4697
+ if (!import_fs8.default.existsSync(ws.docs)) import_fs8.default.mkdirSync(ws.docs, { recursive: true });
4625
4698
  if (opts.fromPlatform) {
4626
4699
  const docs = await apiRequest(
4627
4700
  "/api/v1/docs"
@@ -4638,24 +4711,24 @@ function makeDocsCommand() {
4638
4711
  const index = loadBundledIndex(bundledDir);
4639
4712
  let synced = 0, skipped = 0;
4640
4713
  for (const entry of index) {
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) {
4714
+ const srcFile = import_path9.default.join(bundledDir, entry.file);
4715
+ const dstFile = import_path9.default.join(ws.docs, entry.file);
4716
+ if (!import_fs8.default.existsSync(srcFile)) continue;
4717
+ if (import_fs8.default.existsSync(dstFile) && opts.skipExisting) {
4645
4718
  skipped++;
4646
4719
  if (opts.dryRun) console.log(` skip (\u5DF2\u5B58\u5728): ${entry.file}`);
4647
4720
  continue;
4648
4721
  }
4649
4722
  if (!opts.dryRun) {
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);
4723
+ const dstDir = import_path9.default.dirname(dstFile);
4724
+ if (!import_fs8.default.existsSync(dstDir)) import_fs8.default.mkdirSync(dstDir, { recursive: true });
4725
+ import_fs8.default.copyFileSync(srcFile, dstFile);
4653
4726
  }
4654
4727
  console.log(` ${opts.dryRun ? "[dry-run] " : ""}\u2192 ${entry.file}`);
4655
4728
  synced++;
4656
4729
  }
4657
4730
  if (!opts.dryRun) {
4658
- import_fs7.default.copyFileSync(import_path8.default.join(bundledDir, "index.json"), import_path8.default.join(ws.docs, "index.json"));
4731
+ import_fs8.default.copyFileSync(import_path9.default.join(bundledDir, "index.json"), import_path9.default.join(ws.docs, "index.json"));
4659
4732
  }
4660
4733
  console.log(`${opts.dryRun ? "[dry-run] " : ""}\u540C\u6B65 ${synced} \u7BC7\uFF0C\u8DF3\u8FC7 ${skipped} \u7BC7`);
4661
4734
  ok({ synced, skipped, dryRun: opts.dryRun });
@@ -4666,10 +4739,10 @@ function makeDocsCommand() {
4666
4739
  cmd.command("index").description("\u91CD\u5EFA\u5DE5\u4F5C\u533A docs/index.json").action(() => {
4667
4740
  try {
4668
4741
  const ws = resolveWorkspace();
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");
4742
+ if (!import_fs8.default.existsSync(ws.docs)) import_fs8.default.mkdirSync(ws.docs, { recursive: true });
4743
+ const files = import_fs8.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$/, "") }));
4744
+ const indexPath = import_path9.default.join(ws.docs, "index.json");
4745
+ import_fs8.default.writeFileSync(indexPath, JSON.stringify({ docs: files, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
4673
4746
  console.log(`\u2705 docs/index.json \u5DF2\u66F4\u65B0 (${files.length} \u7BC7)`);
4674
4747
  ok({ count: files.length });
4675
4748
  } catch (err2) {
@@ -4680,24 +4753,24 @@ function makeDocsCommand() {
4680
4753
  }
4681
4754
 
4682
4755
  // cli/dazi/src/commands/prompt.ts
4683
- var import_path9 = __toESM(require("path"), 1);
4684
- var import_fs8 = __toESM(require("fs"), 1);
4756
+ var import_path10 = __toESM(require("path"), 1);
4757
+ var import_fs9 = __toESM(require("fs"), 1);
4685
4758
  function resolveBundledPromptsDir() {
4686
4759
  const bundledDir = process.env.DAZI_BUNDLED_DIR;
4687
4760
  if (bundledDir) {
4688
- const p = import_path9.default.resolve(bundledDir, "..", "prompts");
4689
- if (import_fs8.default.existsSync(p)) return p;
4761
+ const p = import_path10.default.resolve(bundledDir, "..", "prompts");
4762
+ if (import_fs9.default.existsSync(p)) return p;
4690
4763
  }
4691
4764
  const candidates = [
4692
- import_path9.default.resolve(__dirname, "..", "..", "prompts")
4765
+ import_path10.default.resolve(__dirname, "..", "..", "prompts")
4693
4766
  ];
4694
- return candidates.find((c) => import_fs8.default.existsSync(c)) ?? null;
4767
+ return candidates.find((c) => import_fs9.default.existsSync(c)) ?? null;
4695
4768
  }
4696
4769
  function loadIndex(dir) {
4697
- const indexPath = import_path9.default.join(dir, "index.json");
4698
- if (!import_fs8.default.existsSync(indexPath)) return [];
4770
+ const indexPath = import_path10.default.join(dir, "index.json");
4771
+ if (!import_fs9.default.existsSync(indexPath)) return [];
4699
4772
  try {
4700
- const raw = JSON.parse(import_fs8.default.readFileSync(indexPath, "utf-8"));
4773
+ const raw = JSON.parse(import_fs9.default.readFileSync(indexPath, "utf-8"));
4701
4774
  return raw.prompts ?? [];
4702
4775
  } catch {
4703
4776
  return [];
@@ -4711,7 +4784,7 @@ function makePromptCommand() {
4711
4784
  const bundled = bundledDir ? loadIndex(bundledDir) : [];
4712
4785
  const ws = resolveWorkspace();
4713
4786
  const wsPromptDir = ws.prompts;
4714
- const workspace = import_fs8.default.existsSync(wsPromptDir) ? loadIndex(wsPromptDir) : [];
4787
+ const workspace = import_fs9.default.existsSync(wsPromptDir) ? loadIndex(wsPromptDir) : [];
4715
4788
  const map = /* @__PURE__ */ new Map();
4716
4789
  bundled.forEach((p) => map.set(p.id, { ...p, source: "bundled" }));
4717
4790
  workspace.forEach((p) => map.set(p.id, { ...p, source: "workspace" }));
@@ -4747,13 +4820,13 @@ function makePromptCommand() {
4747
4820
  let content = null;
4748
4821
  let source = "";
4749
4822
  const wsPromptDir = ws.prompts;
4750
- if (import_fs8.default.existsSync(wsPromptDir)) {
4823
+ if (import_fs9.default.existsSync(wsPromptDir)) {
4751
4824
  const wsIndex = loadIndex(wsPromptDir);
4752
4825
  const entry = wsIndex.find((p) => p.id === topicId);
4753
4826
  if (entry) {
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");
4827
+ const p = import_path10.default.join(wsPromptDir, entry.file);
4828
+ if (import_fs9.default.existsSync(p)) {
4829
+ content = import_fs9.default.readFileSync(p, "utf-8");
4757
4830
  source = "workspace";
4758
4831
  }
4759
4832
  }
@@ -4762,9 +4835,9 @@ function makePromptCommand() {
4762
4835
  const bIndex = loadIndex(bundledDir);
4763
4836
  const entry = bIndex.find((p) => p.id === topicId);
4764
4837
  if (entry) {
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");
4838
+ const p = import_path10.default.join(bundledDir, entry.file);
4839
+ if (import_fs9.default.existsSync(p)) {
4840
+ content = import_fs9.default.readFileSync(p, "utf-8");
4768
4841
  source = "bundled";
4769
4842
  }
4770
4843
  }
@@ -4790,28 +4863,28 @@ function makePromptCommand() {
4790
4863
  }
4791
4864
  const ws = resolveWorkspace();
4792
4865
  const wsPromptDir = ws.prompts;
4793
- if (!import_fs8.default.existsSync(wsPromptDir)) import_fs8.default.mkdirSync(wsPromptDir, { recursive: true });
4866
+ if (!import_fs9.default.existsSync(wsPromptDir)) import_fs9.default.mkdirSync(wsPromptDir, { recursive: true });
4794
4867
  const index = loadIndex(bundledDir);
4795
4868
  let synced = 0, skipped = 0;
4796
4869
  for (const entry of index) {
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) {
4870
+ const srcFile = import_path10.default.join(bundledDir, entry.file);
4871
+ const dstFile = import_path10.default.join(wsPromptDir, entry.file);
4872
+ if (!import_fs9.default.existsSync(srcFile)) continue;
4873
+ if (import_fs9.default.existsSync(dstFile) && opts.skipExisting) {
4801
4874
  skipped++;
4802
4875
  if (opts.dryRun) console.log(` skip (\u5DF2\u5B58\u5728): ${entry.file}`);
4803
4876
  continue;
4804
4877
  }
4805
4878
  if (!opts.dryRun) {
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);
4879
+ const dstDir = import_path10.default.dirname(dstFile);
4880
+ if (!import_fs9.default.existsSync(dstDir)) import_fs9.default.mkdirSync(dstDir, { recursive: true });
4881
+ import_fs9.default.copyFileSync(srcFile, dstFile);
4809
4882
  }
4810
4883
  console.log(` ${opts.dryRun ? "[dry-run] " : ""}\u2192 ${entry.file}`);
4811
4884
  synced++;
4812
4885
  }
4813
4886
  if (!opts.dryRun) {
4814
- import_fs8.default.copyFileSync(import_path9.default.join(bundledDir, "index.json"), import_path9.default.join(wsPromptDir, "index.json"));
4887
+ import_fs9.default.copyFileSync(import_path10.default.join(bundledDir, "index.json"), import_path10.default.join(wsPromptDir, "index.json"));
4815
4888
  }
4816
4889
  console.log(`${opts.dryRun ? "[dry-run] " : ""}\u540C\u6B65 ${synced} \u7BC7\uFF0C\u8DF3\u8FC7 ${skipped} \u7BC7`);
4817
4890
  ok({ synced, skipped });
@@ -4823,37 +4896,177 @@ function makePromptCommand() {
4823
4896
  }
4824
4897
 
4825
4898
  // cli/dazi/src/commands/examples.ts
4826
- var import_path10 = __toESM(require("path"), 1);
4827
- var import_fs9 = __toESM(require("fs"), 1);
4828
- function resolveBundledExamplesDir() {
4899
+ var import_path12 = __toESM(require("path"), 1);
4900
+ var import_fs11 = __toESM(require("fs"), 1);
4901
+
4902
+ // cli/dazi/src/commands/examplesOnto.ts
4903
+ var import_path11 = __toESM(require("path"), 1);
4904
+ var import_fs10 = __toESM(require("fs"), 1);
4905
+ function resolveExamplesRoot() {
4906
+ const ws = resolveWorkspace();
4907
+ const wsOntoIndex = import_path11.default.join(ws.examples, "onto", "index.json");
4908
+ if (import_fs10.default.existsSync(wsOntoIndex)) return ws.examples;
4909
+ return resolveBundledExamplesDir();
4910
+ }
4911
+ function printExampleRow(ex) {
4912
+ const domains = ex.domain.slice(0, 5).join("\u3001");
4913
+ const feat = ex.featured ? " \u2605" : "";
4914
+ console.log(` ${ex.id.padEnd(12)} ${ex.title}${feat}`);
4915
+ console.log(` \u76EE\u5F55: onto/${ex.dir}/`);
4916
+ console.log(` \u89C4\u5212: ${ex.planPrimary}`);
4917
+ console.log(` \u57DF: ${domains}`);
4918
+ }
4919
+ function makeExamplesOntoCommand() {
4920
+ const cmd = new Command("onto").description("\u672C\u4F53\u5B8C\u6574\u793A\u4F8B\uFF08plans + setup + functions\uFF09");
4921
+ cmd.command("list").description("\u5217\u51FA index.yaml / index.json \u6CE8\u518C\u7684\u672C\u4F53\u793A\u4F8B").option("--json", "\u8F93\u51FA JSON").option("--featured", "\u4EC5 featured").action((opts) => {
4922
+ try {
4923
+ const root = resolveExamplesRoot();
4924
+ if (!root) {
4925
+ console.error("\u627E\u4E0D\u5230 examples/onto/index.json\uFF08\u5148 dazi examples sync\uFF09");
4926
+ process.exit(1);
4927
+ }
4928
+ const index = loadOntoExampleIndex(root);
4929
+ if (!index) {
4930
+ console.error("\u65E0\u6CD5\u89E3\u6790 examples/onto/index.json");
4931
+ process.exit(1);
4932
+ }
4933
+ let items = index.examples;
4934
+ if (opts.featured) items = items.filter((e) => e.featured);
4935
+ if (opts.json) {
4936
+ console.log(JSON.stringify({ root, defaultReadOrder: index.defaultReadOrder, examples: items }, null, 2));
4937
+ ok({ examples: items });
4938
+ return;
4939
+ }
4940
+ console.log(`\u672C\u4F53\u793A\u4F8B\u7D22\u5F15: ${import_path11.default.join(root, "onto", "index.json")}`);
4941
+ if (index.defaultReadOrder?.length) {
4942
+ console.log(`\u9ED8\u8BA4\u9605\u8BFB\u987A\u5E8F: ${index.defaultReadOrder.join(" \u2192 ")}`);
4943
+ }
4944
+ console.log("");
4945
+ for (const ex of items) printExampleRow(ex);
4946
+ ok({ count: items.length });
4947
+ } catch (err2) {
4948
+ handleError(err2);
4949
+ }
4950
+ });
4951
+ cmd.command("show <idOrDir>").description("\u663E\u793A\u793A\u4F8B README + \u89C4\u5212\u6B63\u6587\u8DEF\u5F84\uFF08--plan \u8F93\u51FA\u89C4\u5212\u5168\u6587\uFF09").option("--plan", "\u8F93\u51FA\u89C4\u5212 Markdown \u5168\u6587").option("--readme", "\u8F93\u51FA README \u5168\u6587").action((idOrDir, opts) => {
4952
+ try {
4953
+ const root = resolveExamplesRoot();
4954
+ if (!root) {
4955
+ console.error("\u627E\u4E0D\u5230 examples \u76EE\u5F55");
4956
+ process.exit(1);
4957
+ }
4958
+ const index = loadOntoExampleIndex(root);
4959
+ if (!index) process.exit(1);
4960
+ const ex = findOntoExample(index, idOrDir);
4961
+ if (!ex) {
4962
+ console.error(`\u672A\u627E\u5230\u793A\u4F8B: ${idOrDir}\uFF08\u53EF\u7528: ${index.examples.map((e) => e.id).join(", ")}\uFF09`);
4963
+ process.exit(1);
4964
+ }
4965
+ const readmeRel = ontoExampleReadmeRel(ex);
4966
+ const planRel = ontoExamplePlanRel(ex);
4967
+ const readmePath = resolveOntoExampleFile(root, readmeRel);
4968
+ const planPath = resolveOntoExampleFile(root, planRel);
4969
+ console.log(`# ${ex.title} (${ex.id})`);
4970
+ console.log(`\u76EE\u5F55: \u8D44\u6E90/examples/${ex.dir}/`);
4971
+ console.log(`\u89C4\u5212: \u8D44\u6E90/examples/${planRel}`);
4972
+ if (readmePath) console.log(`README: ${readmePath}`);
4973
+ if (planPath) console.log(`Plan: ${planPath}`);
4974
+ console.log("");
4975
+ if (opts.readme && readmePath) {
4976
+ console.log("\u2500\u2500 README \u2500\u2500");
4977
+ console.log(import_fs10.default.readFileSync(readmePath, "utf-8"));
4978
+ console.log("");
4979
+ } else if (opts.readme && !readmePath) {
4980
+ console.error("README \u4E0D\u5B58\u5728");
4981
+ process.exit(1);
4982
+ }
4983
+ if (opts.plan && planPath) {
4984
+ console.log("\u2500\u2500 PLAN \u2500\u2500");
4985
+ console.log(import_fs10.default.readFileSync(planPath, "utf-8"));
4986
+ } else if (opts.plan && !planPath) {
4987
+ console.error("\u89C4\u5212\u6587\u4EF6\u4E0D\u5B58\u5728");
4988
+ process.exit(1);
4989
+ }
4990
+ if (!opts.plan && !opts.readme) {
4991
+ console.log("\u63D0\u793A: --readme / --plan \u8F93\u51FA\u5168\u6587");
4992
+ }
4993
+ ok({ id: ex.id, plan: planRel, readme: readmeRel });
4994
+ } catch (err2) {
4995
+ handleError(err2);
4996
+ }
4997
+ });
4998
+ cmd.command("suggest").description("\u6309\u5173\u952E\u8BCD\u63A8\u8350\u5BF9\u7167\u793A\u4F8B\uFF08\u89C4\u5212\u524D\u9009\u7528\uFF09").argument("[keywords]", "\u7A7A\u683C\u6216\u9017\u53F7\u5206\u9694\u5173\u952E\u8BCD\uFF0C\u5982\uFF1A\u8BBE\u5907 OEE \u505C\u673A").option("--json", "\u8F93\u51FA JSON").option("--limit <n>", "\u8FD4\u56DE\u6761\u6570", "3").action((keywords, opts) => {
4999
+ try {
5000
+ const root = resolveExamplesRoot();
5001
+ if (!root) process.exit(1);
5002
+ const index = loadOntoExampleIndex(root);
5003
+ if (!index) process.exit(1);
5004
+ const limit = parseInt(opts.limit, 10) || 3;
5005
+ const matches = suggestOntoExamples(index, keywords ?? "", limit);
5006
+ if (opts.json) {
5007
+ console.log(JSON.stringify(matches, null, 2));
5008
+ ok({ matches });
5009
+ return;
5010
+ }
5011
+ if (!matches.length) {
5012
+ console.log("\u65E0\u5339\u914D\uFF1B\u53EF\u7528: dazi examples onto list");
5013
+ ok({ matches: [] });
5014
+ return;
5015
+ }
5016
+ console.log(keywords?.trim() ? `\u5173\u952E\u8BCD\u300C${keywords}\u300D\u63A8\u8350\u793A\u4F8B\uFF1A` : "\u9ED8\u8BA4\u63A8\u8350\u9605\u8BFB\u987A\u5E8F\uFF1A");
5017
+ for (const ex of matches) {
5018
+ printExampleRow(ex);
5019
+ console.log(` \u2192 dazi examples onto show ${ex.id}`);
5020
+ console.log("");
5021
+ }
5022
+ ok({ matches: matches.map((m) => m.id) });
5023
+ } catch (err2) {
5024
+ handleError(err2);
5025
+ }
5026
+ });
5027
+ return cmd;
5028
+ }
5029
+
5030
+ // cli/dazi/src/commands/examples.ts
5031
+ function resolveBundledExamplesDir2() {
4829
5032
  const bundledDir = process.env.DAZI_BUNDLED_DIR;
4830
5033
  if (bundledDir) {
4831
- const p = import_path10.default.resolve(bundledDir, "..", "examples");
4832
- if (import_fs9.default.existsSync(p)) return p;
5034
+ const p = import_path12.default.resolve(bundledDir, "..", "examples");
5035
+ if (import_fs11.default.existsSync(p)) return p;
4833
5036
  }
4834
5037
  const candidates = [
4835
- import_path10.default.resolve(__dirname, "..", "..", "examples")
5038
+ import_path12.default.resolve(__dirname, "..", "..", "examples")
4836
5039
  ];
4837
- return candidates.find((c) => import_fs9.default.existsSync(c)) ?? null;
5040
+ return candidates.find((c) => import_fs11.default.existsSync(c)) ?? null;
5041
+ }
5042
+ function copyDirRecursive(src, dest) {
5043
+ if (!import_fs11.default.existsSync(src)) return;
5044
+ if (!import_fs11.default.existsSync(dest)) import_fs11.default.mkdirSync(dest, { recursive: true });
5045
+ for (const entry of import_fs11.default.readdirSync(src, { withFileTypes: true })) {
5046
+ const s = import_path12.default.join(src, entry.name);
5047
+ const d = import_path12.default.join(dest, entry.name);
5048
+ if (entry.isDirectory()) copyDirRecursive(s, d);
5049
+ else import_fs11.default.copyFileSync(s, d);
5050
+ }
4838
5051
  }
4839
5052
  function loadIndex2(dir) {
4840
- const indexPath = import_path10.default.join(dir, "index.json");
4841
- if (!import_fs9.default.existsSync(indexPath)) return [];
5053
+ const indexPath = import_path12.default.join(dir, "index.json");
5054
+ if (!import_fs11.default.existsSync(indexPath)) return [];
4842
5055
  try {
4843
- const raw = JSON.parse(import_fs9.default.readFileSync(indexPath, "utf-8"));
5056
+ const raw = JSON.parse(import_fs11.default.readFileSync(indexPath, "utf-8"));
4844
5057
  return raw.examples ?? [];
4845
5058
  } catch {
4846
5059
  return [];
4847
5060
  }
4848
5061
  }
4849
5062
  function resolveExampleFile(topicId, wsExamplesDir, bundledDir) {
4850
- if (import_fs9.default.existsSync(wsExamplesDir)) {
5063
+ if (import_fs11.default.existsSync(wsExamplesDir)) {
4851
5064
  const wsIndex = loadIndex2(wsExamplesDir);
4852
5065
  const wsEntry = wsIndex.find((e) => e.id === topicId);
4853
5066
  if (wsEntry) {
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 };
5067
+ const p = import_path12.default.join(wsExamplesDir, wsEntry.file);
5068
+ if (import_fs11.default.existsSync(p)) {
5069
+ return { content: import_fs11.default.readFileSync(p, "utf-8"), source: "workspace", filePath: p };
4857
5070
  }
4858
5071
  }
4859
5072
  }
@@ -4861,9 +5074,9 @@ function resolveExampleFile(topicId, wsExamplesDir, bundledDir) {
4861
5074
  const bIndex = loadIndex2(bundledDir);
4862
5075
  const bEntry = bIndex.find((e) => e.id === topicId);
4863
5076
  if (bEntry) {
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 };
5077
+ const p = import_path12.default.join(bundledDir, bEntry.file);
5078
+ if (import_fs11.default.existsSync(p)) {
5079
+ return { content: import_fs11.default.readFileSync(p, "utf-8"), source: "bundled", filePath: p };
4867
5080
  }
4868
5081
  }
4869
5082
  }
@@ -4873,11 +5086,11 @@ function makeExamplesCommand() {
4873
5086
  const cmd = new Command("examples").description("\u793A\u4F8B\u811A\u672C\u7BA1\u7406");
4874
5087
  cmd.command("list").description("\u5217\u51FA\u6240\u6709\u793A\u4F8B\uFF08\u5185\u7F6E + \u5DE5\u4F5C\u533A\uFF09").option("--category <cat>", "\u8FC7\u6EE4\u5206\u7C7B\uFF08onto-setup/onto-function \u7B49\uFF09").option("--json", "\u8F93\u51FA JSON").action((opts) => {
4875
5088
  try {
4876
- const bundledDir = resolveBundledExamplesDir();
5089
+ const bundledDir = resolveBundledExamplesDir2();
4877
5090
  const bundled = bundledDir ? loadIndex2(bundledDir) : [];
4878
5091
  const ws = resolveWorkspace();
4879
5092
  const wsExamplesDir = ws.examples;
4880
- const workspace = import_fs9.default.existsSync(wsExamplesDir) ? loadIndex2(wsExamplesDir) : [];
5093
+ const workspace = import_fs11.default.existsSync(wsExamplesDir) ? loadIndex2(wsExamplesDir) : [];
4881
5094
  const map = /* @__PURE__ */ new Map();
4882
5095
  bundled.forEach((e) => map.set(e.id, { ...e, source: "bundled" }));
4883
5096
  workspace.forEach((e) => map.set(e.id, { ...e, source: "workspace" }));
@@ -4909,7 +5122,7 @@ function makeExamplesCommand() {
4909
5122
  cmd.command("show <topicId>").description("\u663E\u793A\u793A\u4F8B\u811A\u672C\u5185\u5BB9\uFF08stdout\uFF09").action((topicId) => {
4910
5123
  try {
4911
5124
  const ws = resolveWorkspace();
4912
- const bundledDir = resolveBundledExamplesDir();
5125
+ const bundledDir = resolveBundledExamplesDir2();
4913
5126
  const resolved = resolveExampleFile(topicId, ws.examples, bundledDir);
4914
5127
  if (!resolved) {
4915
5128
  console.error(`\u793A\u4F8B\u672A\u627E\u5230: ${topicId}`);
@@ -4926,38 +5139,46 @@ function makeExamplesCommand() {
4926
5139
  });
4927
5140
  cmd.command("sync").description("\u5C06\u5185\u7F6E\u793A\u4F8B\u540C\u6B65\u5230\u5DE5\u4F5C\u533A \u8D44\u6E90/examples/\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("--dry-run", "\u4EC5\u9884\u89C8").action((opts) => {
4928
5141
  try {
4929
- const bundledDir = resolveBundledExamplesDir();
5142
+ const bundledDir = resolveBundledExamplesDir2();
4930
5143
  if (!bundledDir) {
4931
5144
  console.error("\u627E\u4E0D\u5230\u5185\u7F6E\u793A\u4F8B\u76EE\u5F55");
4932
5145
  process.exit(1);
4933
5146
  }
4934
5147
  const ws = resolveWorkspace();
4935
5148
  const wsExamplesDir = ws.examples;
4936
- if (!import_fs9.default.existsSync(wsExamplesDir)) import_fs9.default.mkdirSync(wsExamplesDir, { recursive: true });
5149
+ if (!import_fs11.default.existsSync(wsExamplesDir)) import_fs11.default.mkdirSync(wsExamplesDir, { recursive: true });
4937
5150
  const index = loadIndex2(bundledDir);
4938
5151
  let synced = 0, skipped = 0;
4939
5152
  for (const entry of index) {
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)) {
5153
+ const srcFile = import_path12.default.join(bundledDir, entry.file);
5154
+ const dstFile = import_path12.default.join(wsExamplesDir, entry.file);
5155
+ if (!import_fs11.default.existsSync(srcFile)) {
4943
5156
  console.warn(` \u8DF3\u8FC7\uFF08\u6E90\u6587\u4EF6\u7F3A\u5931\uFF09: ${entry.file}`);
4944
5157
  continue;
4945
5158
  }
4946
- if (import_fs9.default.existsSync(dstFile) && opts.skipExisting) {
5159
+ if (import_fs11.default.existsSync(dstFile) && opts.skipExisting) {
4947
5160
  skipped++;
4948
5161
  if (opts.dryRun) console.log(` skip (\u5DF2\u5B58\u5728): ${entry.file}`);
4949
5162
  continue;
4950
5163
  }
4951
5164
  if (!opts.dryRun) {
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);
5165
+ const dstDir = import_path12.default.dirname(dstFile);
5166
+ if (!import_fs11.default.existsSync(dstDir)) import_fs11.default.mkdirSync(dstDir, { recursive: true });
5167
+ import_fs11.default.copyFileSync(srcFile, dstFile);
4955
5168
  }
4956
5169
  console.log(` ${opts.dryRun ? "[dry-run] " : ""}\u2192 ${entry.file}`);
4957
5170
  synced++;
4958
5171
  }
4959
5172
  if (!opts.dryRun) {
4960
- import_fs9.default.copyFileSync(import_path10.default.join(bundledDir, "index.json"), import_path10.default.join(wsExamplesDir, "index.json"));
5173
+ import_fs11.default.copyFileSync(import_path12.default.join(bundledDir, "index.json"), import_path12.default.join(wsExamplesDir, "index.json"));
5174
+ const ontoSrc = import_path12.default.join(bundledDir, "onto");
5175
+ const ontoDst = import_path12.default.join(wsExamplesDir, "onto");
5176
+ if (import_fs11.default.existsSync(ontoSrc)) {
5177
+ copyDirRecursive(ontoSrc, ontoDst);
5178
+ console.log(" \u2192 onto/\uFF08\u5B8C\u6574\u793A\u4F8B\u6811\uFF09");
5179
+ }
5180
+ } else if (import_fs11.default.existsSync(import_path12.default.join(bundledDir, "onto"))) {
5181
+ console.log(" [dry-run] \u2192 onto/\uFF08\u5B8C\u6574\u793A\u4F8B\u6811\uFF09");
4961
5182
  }
4962
5183
  console.log(`${opts.dryRun ? "[dry-run] " : ""}\u540C\u6B65 ${synced} \u4E2A\uFF0C\u8DF3\u8FC7 ${skipped} \u4E2A`);
4963
5184
  ok({ synced, skipped });
@@ -4965,49 +5186,50 @@ function makeExamplesCommand() {
4965
5186
  handleError(err2);
4966
5187
  }
4967
5188
  });
5189
+ cmd.addCommand(makeExamplesOntoCommand());
4968
5190
  return cmd;
4969
5191
  }
4970
5192
 
4971
5193
  // cli/dazi/src/commands/migrate.ts
4972
5194
  var import_os6 = __toESM(require("os"), 1);
4973
- var import_path11 = __toESM(require("path"), 1);
4974
- var import_fs10 = __toESM(require("fs"), 1);
5195
+ var import_path13 = __toESM(require("path"), 1);
5196
+ var import_fs12 = __toESM(require("fs"), 1);
4975
5197
  function buildMigratePlan(wsRoot) {
4976
5198
  const actions = [];
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)) {
5199
+ const ontologyDir = import_path13.default.join(wsRoot, "ontology");
5200
+ const ontoDir = import_path13.default.join(wsRoot, "onto");
5201
+ if (import_fs12.default.existsSync(ontologyDir) && !import_fs12.default.existsSync(ontoDir)) {
4980
5202
  actions.push({ type: "rename", src: ontologyDir, dest: ontoDir, label: "ontology/ \u2192 onto/" });
4981
- } else if (!import_fs10.default.existsSync(ontoDir)) {
5203
+ } else if (!import_fs12.default.existsSync(ontoDir)) {
4982
5204
  actions.push({ type: "create", dest: ontoDir, label: "\u65B0\u5EFA onto/" });
4983
5205
  }
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)) {
5206
+ const isDrapRoot = (dir) => import_fs12.default.existsSync(import_path13.default.join(dir, "templates")) && import_fs12.default.existsSync(import_path13.default.join(dir, "sdk"));
5207
+ const runtimeAppsDir = import_path13.default.join(wsRoot, "runtime-apps");
5208
+ const appsDir = import_path13.default.join(wsRoot, "apps");
5209
+ if (import_fs12.default.existsSync(runtimeAppsDir) && isDrapRoot(runtimeAppsDir)) {
5210
+ } else if (import_fs12.default.existsSync(runtimeAppsDir) && !import_fs12.default.existsSync(appsDir)) {
4989
5211
  actions.push({ type: "rename", src: runtimeAppsDir, dest: appsDir, label: "runtime-apps/ \u2192 apps/" });
4990
- } else if (!import_fs10.default.existsSync(appsDir) && !import_fs10.default.existsSync(runtimeAppsDir)) {
5212
+ } else if (!import_fs12.default.existsSync(appsDir) && !import_fs12.default.existsSync(runtimeAppsDir)) {
4991
5213
  actions.push({ type: "create", dest: appsDir, label: "\u65B0\u5EFA apps/" });
4992
5214
  }
4993
- const resourcesDir = import_path11.default.join(wsRoot, "\u8D44\u6E90");
5215
+ const resourcesDir = import_path13.default.join(wsRoot, "\u8D44\u6E90");
4994
5216
  for (const dir of ["flows", "data", ".dazi"]) {
4995
- const p = import_path11.default.join(wsRoot, dir);
4996
- if (!import_fs10.default.existsSync(p)) {
5217
+ const p = import_path13.default.join(wsRoot, dir);
5218
+ if (!import_fs12.default.existsSync(p)) {
4997
5219
  actions.push({ type: "create", dest: p, label: `\u65B0\u5EFA ${dir}/` });
4998
5220
  }
4999
5221
  }
5000
- if (!import_fs10.default.existsSync(resourcesDir)) {
5222
+ if (!import_fs12.default.existsSync(resourcesDir)) {
5001
5223
  actions.push({ type: "create", dest: resourcesDir, label: "\u65B0\u5EFA \u8D44\u6E90/" });
5002
5224
  }
5003
5225
  for (const sub of ["dataspaces", "datasources", "docs", "prompts"]) {
5004
- const p = import_path11.default.join(resourcesDir, sub);
5005
- if (!import_fs10.default.existsSync(p)) {
5226
+ const p = import_path13.default.join(resourcesDir, sub);
5227
+ if (!import_fs12.default.existsSync(p)) {
5006
5228
  actions.push({ type: "create", dest: p, label: `\u65B0\u5EFA \u8D44\u6E90/${sub}/` });
5007
5229
  }
5008
5230
  }
5009
- const cfgPath = import_path11.default.join(wsRoot, ".dazi", "config.json");
5010
- if (!import_fs10.default.existsSync(cfgPath)) {
5231
+ const cfgPath = import_path13.default.join(wsRoot, ".dazi", "config.json");
5232
+ if (!import_fs12.default.existsSync(cfgPath)) {
5011
5233
  actions.push({ type: "copy-config", dest: cfgPath, label: "\u751F\u6210 .dazi/config.json" });
5012
5234
  }
5013
5235
  return actions;
@@ -5015,10 +5237,10 @@ function buildMigratePlan(wsRoot) {
5015
5237
  function executeActions(actions, wsRoot, backup) {
5016
5238
  if (backup) {
5017
5239
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
5018
- const backupDir = import_path11.default.join(wsRoot, ".dazi", "backup", ts);
5019
- import_fs10.default.mkdirSync(backupDir, { recursive: true });
5240
+ const backupDir = import_path13.default.join(wsRoot, ".dazi", "backup", ts);
5241
+ import_fs12.default.mkdirSync(backupDir, { recursive: true });
5020
5242
  for (const a of actions.filter((x) => x.type === "rename" && x.src)) {
5021
- const backupPath = import_path11.default.join(backupDir, import_path11.default.basename(a.src));
5243
+ const backupPath = import_path13.default.join(backupDir, import_path13.default.basename(a.src));
5022
5244
  copyDirSync(a.src, backupPath);
5023
5245
  console.log(` \u{1F4E6} \u5907\u4EFD: ${a.src} \u2192 ${backupPath}`);
5024
5246
  }
@@ -5026,16 +5248,16 @@ function executeActions(actions, wsRoot, backup) {
5026
5248
  for (const action of actions) {
5027
5249
  switch (action.type) {
5028
5250
  case "rename":
5029
- import_fs10.default.renameSync(action.src, action.dest);
5251
+ import_fs12.default.renameSync(action.src, action.dest);
5030
5252
  console.log(` \u2705 \u91CD\u547D\u540D: ${action.label}`);
5031
5253
  break;
5032
5254
  case "create":
5033
- import_fs10.default.mkdirSync(action.dest, { recursive: true });
5255
+ import_fs12.default.mkdirSync(action.dest, { recursive: true });
5034
5256
  console.log(` \u2705 \u521B\u5EFA: ${action.label}`);
5035
5257
  break;
5036
5258
  case "copy-config":
5037
- import_fs10.default.mkdirSync(import_path11.default.dirname(action.dest), { recursive: true });
5038
- import_fs10.default.writeFileSync(action.dest, JSON.stringify({
5259
+ import_fs12.default.mkdirSync(import_path13.default.dirname(action.dest), { recursive: true });
5260
+ import_fs12.default.writeFileSync(action.dest, JSON.stringify({
5039
5261
  migratedAt: (/* @__PURE__ */ new Date()).toISOString(),
5040
5262
  migratedBy: "dazi migrate workspace"
5041
5263
  }, null, 2));
@@ -5045,26 +5267,26 @@ function executeActions(actions, wsRoot, backup) {
5045
5267
  }
5046
5268
  }
5047
5269
  function copyDirSync(src, dest) {
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);
5270
+ if (!import_fs12.default.existsSync(src)) return;
5271
+ import_fs12.default.mkdirSync(dest, { recursive: true });
5272
+ for (const entry of import_fs12.default.readdirSync(src, { withFileTypes: true })) {
5273
+ const s = import_path13.default.join(src, entry.name);
5274
+ const d = import_path13.default.join(dest, entry.name);
5053
5275
  if (entry.isDirectory()) copyDirSync(s, d);
5054
- else import_fs10.default.copyFileSync(s, d);
5276
+ else import_fs12.default.copyFileSync(s, d);
5055
5277
  }
5056
5278
  }
5057
5279
  function makeMigrateCommand() {
5058
5280
  const cmd = new Command("migrate").description("\u8FC1\u79FB\u65E7\u7248\u914D\u7F6E / \u5DE5\u4F5C\u533A");
5059
5281
  cmd.command("config").description("\u5C06\u65E7\u7248 ~/.dazi-app/auth.json \u2192 ~/.dazi/auth.json").action(() => {
5060
5282
  try {
5061
- const legacyPath = import_path11.default.join(import_os6.default.homedir(), ".dazi-app", "auth.json");
5062
- if (!import_fs10.default.existsSync(legacyPath)) {
5283
+ const legacyPath = import_path13.default.join(import_os6.default.homedir(), ".dazi-app", "auth.json");
5284
+ if (!import_fs12.default.existsSync(legacyPath)) {
5063
5285
  console.log("\u672A\u627E\u5230\u65E7\u7248\u8BA4\u8BC1\u6587\u4EF6\uFF0C\u65E0\u9700\u8FC1\u79FB");
5064
5286
  ok({ migrated: false });
5065
5287
  return;
5066
5288
  }
5067
- const legacy = JSON.parse(import_fs10.default.readFileSync(legacyPath, "utf-8"));
5289
+ const legacy = JSON.parse(import_fs12.default.readFileSync(legacyPath, "utf-8"));
5068
5290
  saveAuth({
5069
5291
  token: legacy.token ?? "",
5070
5292
  userId: legacy.userId ?? "",
@@ -5080,9 +5302,9 @@ function makeMigrateCommand() {
5080
5302
  });
5081
5303
  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) => {
5082
5304
  try {
5083
- const wsRoot = import_path11.default.resolve(dir);
5305
+ const wsRoot = import_path13.default.resolve(dir);
5084
5306
  console.log(`\u5DE5\u4F5C\u533A: ${wsRoot}`);
5085
- if (!import_fs10.default.existsSync(wsRoot)) {
5307
+ if (!import_fs12.default.existsSync(wsRoot)) {
5086
5308
  console.error(`\u76EE\u5F55\u4E0D\u5B58\u5728: ${wsRoot}`);
5087
5309
  process.exit(1);
5088
5310
  }
@@ -5142,8 +5364,8 @@ function makeQuickstartCommand() {
5142
5364
  }
5143
5365
 
5144
5366
  // cli/dazi/src/commands/mcp.ts
5145
- var import_path12 = __toESM(require("path"), 1);
5146
- var import_fs11 = __toESM(require("fs"), 1);
5367
+ var import_path14 = __toESM(require("path"), 1);
5368
+ var import_fs13 = __toESM(require("fs"), 1);
5147
5369
  var import_child_process = require("child_process");
5148
5370
  function resolveBundledCliDir() {
5149
5371
  return process.env.DAZI_BUNDLED_DIR ?? null;
@@ -5151,14 +5373,14 @@ function resolveBundledCliDir() {
5151
5373
  function resolveBundledRoot() {
5152
5374
  const cliDir = resolveBundledCliDir();
5153
5375
  if (!cliDir) return null;
5154
- const parent = import_path12.default.resolve(cliDir, "..");
5155
- return import_fs11.default.existsSync(parent) ? parent : null;
5376
+ const parent = import_path14.default.resolve(cliDir, "..");
5377
+ return import_fs13.default.existsSync(parent) ? parent : null;
5156
5378
  }
5157
5379
  function resolveCli(name) {
5158
5380
  const dir = resolveBundledCliDir();
5159
5381
  if (!dir) return null;
5160
- const p = import_path12.default.join(dir, `${name}.js`);
5161
- return import_fs11.default.existsSync(p) ? p : null;
5382
+ const p = import_path14.default.join(dir, `${name}.js`);
5383
+ return import_fs13.default.existsSync(p) ? p : null;
5162
5384
  }
5163
5385
  function callCli(cliName, args) {
5164
5386
  const cliPath = resolveCli(cliName);
@@ -5195,10 +5417,10 @@ function err(msg) {
5195
5417
  function loadDocs() {
5196
5418
  const root = resolveBundledRoot();
5197
5419
  if (!root) return [];
5198
- const idx = import_path12.default.join(root, "docs", "index.json");
5199
- if (!import_fs11.default.existsSync(idx)) return [];
5420
+ const idx = import_path14.default.join(root, "docs", "index.json");
5421
+ if (!import_fs13.default.existsSync(idx)) return [];
5200
5422
  try {
5201
- return JSON.parse(import_fs11.default.readFileSync(idx, "utf-8")).docs ?? [];
5423
+ return JSON.parse(import_fs13.default.readFileSync(idx, "utf-8")).docs ?? [];
5202
5424
  } catch {
5203
5425
  return [];
5204
5426
  }
@@ -5206,16 +5428,16 @@ function loadDocs() {
5206
5428
  function loadPrompts() {
5207
5429
  const root = resolveBundledRoot();
5208
5430
  if (!root) return [];
5209
- const idx = import_path12.default.join(root, "prompts", "index.json");
5210
- if (!import_fs11.default.existsSync(idx)) return [];
5431
+ const idx = import_path14.default.join(root, "prompts", "index.json");
5432
+ if (!import_fs13.default.existsSync(idx)) return [];
5211
5433
  try {
5212
- return JSON.parse(import_fs11.default.readFileSync(idx, "utf-8")).prompts ?? [];
5434
+ return JSON.parse(import_fs13.default.readFileSync(idx, "utf-8")).prompts ?? [];
5213
5435
  } catch {
5214
5436
  return [];
5215
5437
  }
5216
5438
  }
5217
5439
  function readFile(filePath) {
5218
- return import_fs11.default.existsSync(filePath) ? import_fs11.default.readFileSync(filePath, "utf-8") : null;
5440
+ return import_fs13.default.existsSync(filePath) ? import_fs13.default.readFileSync(filePath, "utf-8") : null;
5219
5441
  }
5220
5442
  var MCP_TOOLS = [
5221
5443
  // ── 文档 ──────────────────────────────────────────────────────────────
@@ -5556,7 +5778,7 @@ function handleToolCall(name, args) {
5556
5778
  const entry = loadDocs().find((d) => d.id === String(args.id));
5557
5779
  if (!entry)
5558
5780
  return err(`\u6587\u6863\u672A\u627E\u5230: ${args.id}\uFF08\u4F7F\u7528 list_docs \u67E5\u770B\u53EF\u7528\u6587\u6863\uFF09`);
5559
- const content = readFile(import_path12.default.join(root, "docs", entry.file));
5781
+ const content = readFile(import_path14.default.join(root, "docs", entry.file));
5560
5782
  return content ? text(content) : err(`\u6587\u6863\u6587\u4EF6\u4E0D\u5B58\u5728: ${entry.file}`);
5561
5783
  }
5562
5784
  case "list_prompts": {
@@ -5573,7 +5795,7 @@ function handleToolCall(name, args) {
5573
5795
  return err(
5574
5796
  `\u63D0\u793A\u8BCD\u672A\u627E\u5230: ${args.id}\uFF08\u4F7F\u7528 list_prompts \u67E5\u770B\u53EF\u7528\u63D0\u793A\u8BCD\uFF09`
5575
5797
  );
5576
- const content = readFile(import_path12.default.join(root, "prompts", entry.file));
5798
+ const content = readFile(import_path14.default.join(root, "prompts", entry.file));
5577
5799
  return content ? text(content) : err(`\u63D0\u793A\u8BCD\u6587\u4EF6\u4E0D\u5B58\u5728: ${entry.file}`);
5578
5800
  }
5579
5801
  case "auth_whoami": {
@@ -5892,13 +6114,13 @@ function makeMcpCommand() {
5892
6114
 
5893
6115
  // cli/dazi/src/index.ts
5894
6116
  var import_child_process2 = require("child_process");
5895
- var import_path13 = __toESM(require("path"), 1);
5896
- var import_fs12 = __toESM(require("fs"), 1);
6117
+ var import_path15 = __toESM(require("path"), 1);
6118
+ var import_fs14 = __toESM(require("fs"), 1);
5897
6119
  function resolveBundledCli(name) {
5898
6120
  const dir = process.env.DAZI_BUNDLED_DIR;
5899
6121
  if (!dir) return null;
5900
- const p = import_path13.default.join(dir, `${name}.js`);
5901
- return import_fs12.default.existsSync(p) ? p : null;
6122
+ const p = import_path15.default.join(dir, `${name}.js`);
6123
+ return import_fs14.default.existsSync(p) ? p : null;
5902
6124
  }
5903
6125
  function forwardToCli(cliName, extraArgs) {
5904
6126
  const bundled = resolveBundledCli(cliName);