@dazitech/cli 3.0.1 → 3.0.3

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.
@@ -3061,11 +3061,27 @@ var AuthError = class extends DaziError {
3061
3061
  }
3062
3062
  };
3063
3063
  var NetworkError = class extends DaziError {
3064
- constructor(message, status) {
3064
+ constructor(message, status, request) {
3065
3065
  super(message, "ERR_NETWORK", 3);
3066
3066
  this.status = status;
3067
+ this.request = request;
3067
3068
  this.name = "NetworkError";
3068
3069
  }
3070
+ /** 多行人类可读详情,写入 stderr / OutputChannel */
3071
+ formatDetailLines() {
3072
+ const lines = [`\u9519\u8BEF: ${this.message}`];
3073
+ const r = this.request;
3074
+ if (!r)
3075
+ return lines;
3076
+ if (r.label)
3077
+ lines.push(`\u6B65\u9AA4: ${r.label}`);
3078
+ lines.push(`\u8BF7\u6C42: ${r.method} ${r.path}`);
3079
+ lines.push(`\u5B8C\u6574 URL: ${r.url}`);
3080
+ lines.push(`HTTP \u72B6\u6001: ${r.status}`);
3081
+ if (r.responseSnippet)
3082
+ lines.push(`\u54CD\u5E94\u6458\u8981: ${r.responseSnippet}`);
3083
+ return lines;
3084
+ }
3069
3085
  };
3070
3086
 
3071
3087
  // cli/shared/src/auth.js
@@ -3084,30 +3100,74 @@ function loadAuth() {
3084
3100
  }
3085
3101
 
3086
3102
  // cli/shared/src/httpClient.js
3103
+ var SNIPPET_MAX = 280;
3104
+ function truncateSnippet(text) {
3105
+ const oneLine = text.replace(/\s+/g, " ").trim();
3106
+ if (oneLine.length <= SNIPPET_MAX)
3107
+ return oneLine;
3108
+ return `${oneLine.slice(0, SNIPPET_MAX)}\u2026`;
3109
+ }
3110
+ function buildHttpErrorMessage(ctx, detail) {
3111
+ const parts = [
3112
+ ctx.label ? `${ctx.label}\u5931\u8D25` : "HTTP \u8BF7\u6C42\u5931\u8D25",
3113
+ `[${ctx.status} ${ctx.method} ${ctx.path}]`,
3114
+ detail
3115
+ ].filter(Boolean);
3116
+ return parts.join(" \u2014 ");
3117
+ }
3087
3118
  async function apiRequest(path7, opts = {}) {
3088
3119
  const auth = opts.token || opts.serverUrl ? { token: opts.token ?? "", serverUrl: opts.serverUrl ?? "" } : loadAuth();
3089
- const url = `${auth.serverUrl.replace(/\/$/, "")}${path7}`;
3120
+ const method = (opts.method ?? "GET").toUpperCase();
3121
+ const serverBase = auth.serverUrl.replace(/\/$/, "");
3122
+ const url = `${serverBase}${path7}`;
3090
3123
  const headers = {
3091
3124
  "Content-Type": "application/json",
3092
3125
  Authorization: `Bearer ${auth.token}`,
3093
3126
  ...opts.headers
3094
3127
  };
3095
3128
  const res = await fetch(url, {
3096
- method: opts.method ?? "GET",
3129
+ method,
3097
3130
  headers,
3098
3131
  body: opts.body != null ? JSON.stringify(opts.body) : void 0
3099
3132
  });
3100
3133
  if (!res.ok) {
3101
- let msg = `HTTP ${res.status} ${res.statusText}`;
3102
- try {
3103
- const j = await res.json();
3104
- if (j.message)
3105
- msg = j.message;
3106
- } catch {
3134
+ let detail = `HTTP ${res.status} ${res.statusText}`;
3135
+ let responseSnippet;
3136
+ const rawText = await res.text();
3137
+ if (rawText) {
3138
+ responseSnippet = truncateSnippet(rawText);
3139
+ try {
3140
+ const j = JSON.parse(rawText);
3141
+ if (typeof j.detail === "string" && j.detail.trim()) {
3142
+ detail = j.detail;
3143
+ } else if (Array.isArray(j.detail) && j.detail.length) {
3144
+ detail = j.detail.map((d) => d.msg ?? JSON.stringify(d)).join("; ");
3145
+ } else if (j.message) {
3146
+ detail = j.message;
3147
+ }
3148
+ } catch {
3149
+ if (rawText.trim() && detail.startsWith("HTTP ")) {
3150
+ detail = `\u975E JSON \u54CD\u5E94\uFF08\u53EF\u80FD\u662F\u7F51\u5173/\u524D\u7AEF 404\uFF09`;
3151
+ }
3152
+ }
3107
3153
  }
3108
- throw new NetworkError(msg, res.status);
3154
+ const ctx = {
3155
+ method,
3156
+ path: path7,
3157
+ url,
3158
+ status: res.status,
3159
+ label: opts.label,
3160
+ responseSnippet
3161
+ };
3162
+ throw new NetworkError(buildHttpErrorMessage(ctx, detail), res.status, ctx);
3163
+ }
3164
+ if (res.status === 204 || res.headers.get("content-length") === "0") {
3165
+ return void 0;
3109
3166
  }
3110
- return res.json();
3167
+ const text = await res.text();
3168
+ if (!text.trim())
3169
+ return void 0;
3170
+ return JSON.parse(text);
3111
3171
  }
3112
3172
 
3113
3173
  // cli/shared/src/output.js
@@ -3121,7 +3181,12 @@ function fail(code, message) {
3121
3181
  printJsonSummary({ ok: false, error: { code, message } });
3122
3182
  }
3123
3183
  function handleError(err) {
3124
- if (err instanceof Error) {
3184
+ if (err instanceof NetworkError) {
3185
+ for (const line of err.formatDetailLines()) {
3186
+ console.error(line);
3187
+ }
3188
+ fail(err.code, err.message);
3189
+ } else if (err instanceof Error) {
3125
3190
  const code = err.code ?? "ERR_UNKNOWN";
3126
3191
  console.error(`\u9519\u8BEF: ${err.message}`);
3127
3192
  fail(code, err.message);
@@ -3895,7 +3960,9 @@ function makeObjectCommand() {
3895
3960
  function makeMcpCommand() {
3896
3961
  const cmd = new Command("mcp").description("MCP \u670D\u52A1\uFF08\u672C\u4F53\u4FA7\uFF09");
3897
3962
  cmd.command("serve").description("\u4EE5 stdio JSON-RPC \u6A21\u5F0F\u542F\u52A8\u672C\u4F53 MCP \u670D\u52A1").option("--space <spaceId>", "\u9ED8\u8BA4\u7A7A\u95F4 ID").action((opts) => {
3898
- process.stderr.write("[dazi-onto mcp serve] MCP stdio \u670D\u52A1 \u2014 Phase 5 \u5B8C\u6574\u5B9E\u73B0\n");
3963
+ process.stderr.write(
3964
+ "[dazi-onto mcp serve] MCP stdio \u670D\u52A1 \u2014 Phase 5 \u5B8C\u6574\u5B9E\u73B0\n"
3965
+ );
3899
3966
  process.stderr.write("\u5F53\u524D\u7248\u672C\u4EC5\u8F93\u51FA\u5360\u4F4D\u54CD\u5E94\n");
3900
3967
  process.stdin.setEncoding("utf-8");
3901
3968
  process.stdin.on("data", (data) => {
@@ -3911,7 +3978,7 @@ function makeMcpCommand() {
3911
3978
  result: {
3912
3979
  protocolVersion: "2024-11-05",
3913
3980
  capabilities: { tools: {} },
3914
- serverInfo: { name: "dazi-onto", version: "3.0.0-beta.1" }
3981
+ serverInfo: { name: "dazi-onto", version: "3.0.3" }
3915
3982
  }
3916
3983
  };
3917
3984
  process.stdout.write(JSON.stringify(response) + "\n");
@@ -3934,7 +4001,7 @@ function makeMcpCommand() {
3934
4001
 
3935
4002
  // cli/dazi-onto/src/index.ts
3936
4003
  var program2 = new Command();
3937
- program2.name("dazi-onto").description("\u642D\u5B50 Onto CLI \u2014 \u672C\u4F53\uFF08Ontology\uFF09\u7BA1\u7406").version("3.0.0", "-v, --version");
4004
+ program2.name("dazi-onto").description("\u642D\u5B50 Onto CLI \u2014 \u672C\u4F53\uFF08Ontology\uFF09\u7BA1\u7406").version("3.0.3", "-v, --version");
3938
4005
  program2.addCommand(makeSpaceCommand());
3939
4006
  program2.addCommand(makeFunctionCommand());
3940
4007
  program2.addCommand(makeActionCommand());
package/dist/clis/dazi.js CHANGED
@@ -3659,11 +3659,27 @@ var AuthError = class extends DaziError {
3659
3659
  }
3660
3660
  };
3661
3661
  var NetworkError = class extends DaziError {
3662
- constructor(message, status) {
3662
+ constructor(message, status, request) {
3663
3663
  super(message, "ERR_NETWORK", 3);
3664
3664
  this.status = status;
3665
+ this.request = request;
3665
3666
  this.name = "NetworkError";
3666
3667
  }
3668
+ /** 多行人类可读详情,写入 stderr / OutputChannel */
3669
+ formatDetailLines() {
3670
+ const lines = [`\u9519\u8BEF: ${this.message}`];
3671
+ const r = this.request;
3672
+ if (!r)
3673
+ return lines;
3674
+ if (r.label)
3675
+ lines.push(`\u6B65\u9AA4: ${r.label}`);
3676
+ lines.push(`\u8BF7\u6C42: ${r.method} ${r.path}`);
3677
+ lines.push(`\u5B8C\u6574 URL: ${r.url}`);
3678
+ lines.push(`HTTP \u72B6\u6001: ${r.status}`);
3679
+ if (r.responseSnippet)
3680
+ lines.push(`\u54CD\u5E94\u6458\u8981: ${r.responseSnippet}`);
3681
+ return lines;
3682
+ }
3667
3683
  };
3668
3684
 
3669
3685
  // cli/shared/src/auth.js
@@ -3700,30 +3716,74 @@ function tryLoadAuth() {
3700
3716
  }
3701
3717
 
3702
3718
  // cli/shared/src/httpClient.js
3719
+ var SNIPPET_MAX = 280;
3720
+ function truncateSnippet(text2) {
3721
+ const oneLine = text2.replace(/\s+/g, " ").trim();
3722
+ if (oneLine.length <= SNIPPET_MAX)
3723
+ return oneLine;
3724
+ return `${oneLine.slice(0, SNIPPET_MAX)}\u2026`;
3725
+ }
3726
+ function buildHttpErrorMessage(ctx, detail) {
3727
+ const parts = [
3728
+ ctx.label ? `${ctx.label}\u5931\u8D25` : "HTTP \u8BF7\u6C42\u5931\u8D25",
3729
+ `[${ctx.status} ${ctx.method} ${ctx.path}]`,
3730
+ detail
3731
+ ].filter(Boolean);
3732
+ return parts.join(" \u2014 ");
3733
+ }
3703
3734
  async function apiRequest(path13, opts = {}) {
3704
3735
  const auth = opts.token || opts.serverUrl ? { token: opts.token ?? "", serverUrl: opts.serverUrl ?? "" } : loadAuth();
3705
- const url = `${auth.serverUrl.replace(/\/$/, "")}${path13}`;
3736
+ const method = (opts.method ?? "GET").toUpperCase();
3737
+ const serverBase = auth.serverUrl.replace(/\/$/, "");
3738
+ const url = `${serverBase}${path13}`;
3706
3739
  const headers = {
3707
3740
  "Content-Type": "application/json",
3708
3741
  Authorization: `Bearer ${auth.token}`,
3709
3742
  ...opts.headers
3710
3743
  };
3711
3744
  const res = await fetch(url, {
3712
- method: opts.method ?? "GET",
3745
+ method,
3713
3746
  headers,
3714
3747
  body: opts.body != null ? JSON.stringify(opts.body) : void 0
3715
3748
  });
3716
3749
  if (!res.ok) {
3717
- let msg = `HTTP ${res.status} ${res.statusText}`;
3718
- try {
3719
- const j = await res.json();
3720
- if (j.message)
3721
- msg = j.message;
3722
- } catch {
3750
+ let detail = `HTTP ${res.status} ${res.statusText}`;
3751
+ let responseSnippet;
3752
+ const rawText = await res.text();
3753
+ if (rawText) {
3754
+ responseSnippet = truncateSnippet(rawText);
3755
+ try {
3756
+ const j = JSON.parse(rawText);
3757
+ if (typeof j.detail === "string" && j.detail.trim()) {
3758
+ detail = j.detail;
3759
+ } else if (Array.isArray(j.detail) && j.detail.length) {
3760
+ detail = j.detail.map((d) => d.msg ?? JSON.stringify(d)).join("; ");
3761
+ } else if (j.message) {
3762
+ detail = j.message;
3763
+ }
3764
+ } catch {
3765
+ if (rawText.trim() && detail.startsWith("HTTP ")) {
3766
+ detail = `\u975E JSON \u54CD\u5E94\uFF08\u53EF\u80FD\u662F\u7F51\u5173/\u524D\u7AEF 404\uFF09`;
3767
+ }
3768
+ }
3723
3769
  }
3724
- throw new NetworkError(msg, res.status);
3770
+ const ctx = {
3771
+ method,
3772
+ path: path13,
3773
+ url,
3774
+ status: res.status,
3775
+ label: opts.label,
3776
+ responseSnippet
3777
+ };
3778
+ throw new NetworkError(buildHttpErrorMessage(ctx, detail), res.status, ctx);
3779
+ }
3780
+ if (res.status === 204 || res.headers.get("content-length") === "0") {
3781
+ return void 0;
3725
3782
  }
3726
- return res.json();
3783
+ const text2 = await res.text();
3784
+ if (!text2.trim())
3785
+ return void 0;
3786
+ return JSON.parse(text2);
3727
3787
  }
3728
3788
 
3729
3789
  // cli/shared/src/output.js
@@ -3737,7 +3797,12 @@ function fail(code, message) {
3737
3797
  printJsonSummary({ ok: false, error: { code, message } });
3738
3798
  }
3739
3799
  function handleError(err2) {
3740
- if (err2 instanceof Error) {
3800
+ if (err2 instanceof NetworkError) {
3801
+ for (const line of err2.formatDetailLines()) {
3802
+ console.error(line);
3803
+ }
3804
+ fail(err2.code, err2.message);
3805
+ } else if (err2 instanceof Error) {
3741
3806
  const code = err2.code ?? "ERR_UNKNOWN";
3742
3807
  console.error(`\u9519\u8BEF: ${err2.message}`);
3743
3808
  fail(code, err2.message);
@@ -3959,7 +4024,7 @@ function makeEnvCommand() {
3959
4024
  return new Command("env").description("\u663E\u793A\u73AF\u5883\u4FE1\u606F").action(() => {
3960
4025
  const auth = tryLoadAuth();
3961
4026
  const env = {
3962
- version: "3.0.0-alpha.0",
4027
+ version: "3.0.3",
3963
4028
  node: process.version,
3964
4029
  platform: `${import_os5.default.type()} ${import_os5.default.arch()}`,
3965
4030
  serverUrl: getServerUrl(),
@@ -5001,7 +5066,8 @@ function resolveCli(name) {
5001
5066
  }
5002
5067
  function callCli(cliName, args) {
5003
5068
  const cliPath = resolveCli(cliName);
5004
- if (!cliPath) return { error: `CLI ${cliName} \u672A\u627E\u5230\uFF0C\u8BF7\u786E\u8BA4 DAZI_BUNDLED_DIR \u5DF2\u8BBE\u7F6E` };
5069
+ if (!cliPath)
5070
+ return { error: `CLI ${cliName} \u672A\u627E\u5230\uFF0C\u8BF7\u786E\u8BA4 DAZI_BUNDLED_DIR \u5DF2\u8BBE\u7F6E` };
5005
5071
  const result = (0, import_child_process.spawnSync)(process.execPath, [cliPath, ...args], {
5006
5072
  encoding: "utf-8",
5007
5073
  timeout: 3e4,
@@ -5077,7 +5143,10 @@ var MCP_TOOLS = [
5077
5143
  inputSchema: {
5078
5144
  type: "object",
5079
5145
  properties: {
5080
- id: { type: "string", description: "\u6587\u6863 ID\uFF0C\u5982 guides/quickstart\u3001onto/function-guide" }
5146
+ id: {
5147
+ type: "string",
5148
+ description: "\u6587\u6863 ID\uFF0C\u5982 guides/quickstart\u3001onto/function-guide"
5149
+ }
5081
5150
  },
5082
5151
  required: ["id"]
5083
5152
  }
@@ -5103,7 +5172,10 @@ var MCP_TOOLS = [
5103
5172
  inputSchema: {
5104
5173
  type: "object",
5105
5174
  properties: {
5106
- id: { type: "string", description: "\u63D0\u793A\u8BCD ID\uFF0C\u5982 onto/function-design" }
5175
+ id: {
5176
+ type: "string",
5177
+ description: "\u63D0\u793A\u8BCD ID\uFF0C\u5982 onto/function-design"
5178
+ }
5107
5179
  },
5108
5180
  required: ["id"]
5109
5181
  }
@@ -5186,7 +5258,10 @@ var MCP_TOOLS = [
5186
5258
  type: "object",
5187
5259
  properties: {
5188
5260
  space_id: { type: "string" },
5189
- script_type: { type: "string", description: "\u811A\u672C\u7C7B\u578B\uFF08\u5982 ontology_function\uFF09" }
5261
+ script_type: {
5262
+ type: "string",
5263
+ description: "\u811A\u672C\u7C7B\u578B\uFF08\u5982 ontology_function\uFF09"
5264
+ }
5190
5265
  },
5191
5266
  required: ["space_id"]
5192
5267
  }
@@ -5210,7 +5285,10 @@ var MCP_TOOLS = [
5210
5285
  type: "object",
5211
5286
  properties: {
5212
5287
  space_id: { type: "string", description: "\u6309\u7A7A\u95F4\u8FC7\u6EE4\uFF08\u53EF\u9009\uFF09" },
5213
- status: { type: "string", description: "\u6309\u72B6\u6001\u8FC7\u6EE4\uFF08active/draft/archived\uFF09" }
5288
+ status: {
5289
+ type: "string",
5290
+ description: "\u6309\u72B6\u6001\u8FC7\u6EE4\uFF08active/draft/archived\uFF09"
5291
+ }
5214
5292
  }
5215
5293
  }
5216
5294
  },
@@ -5233,7 +5311,10 @@ var MCP_TOOLS = [
5233
5311
  properties: {
5234
5312
  flow_id: { type: "string" },
5235
5313
  limit: { type: "number", description: "\u6700\u591A\u8FD4\u56DE\u6761\u6570\uFF08\u9ED8\u8BA4 10\uFF09" },
5236
- status: { type: "string", description: "\u6309\u72B6\u6001\u8FC7\u6EE4\uFF08running/success/failed\uFF09" }
5314
+ status: {
5315
+ type: "string",
5316
+ description: "\u6309\u72B6\u6001\u8FC7\u6EE4\uFF08running/success/failed\uFF09"
5317
+ }
5237
5318
  },
5238
5319
  required: ["flow_id"]
5239
5320
  }
@@ -5257,7 +5338,10 @@ var MCP_TOOLS = [
5257
5338
  type: "object",
5258
5339
  properties: {
5259
5340
  flow_id: { type: "string" },
5260
- run_id: { type: "string", description: "\u6307\u5B9A Run ID\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u6700\u8FD1\u4E00\u6B21\uFF09" }
5341
+ run_id: {
5342
+ type: "string",
5343
+ description: "\u6307\u5B9A Run ID\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u6700\u8FD1\u4E00\u6B21\uFF09"
5344
+ }
5261
5345
  },
5262
5346
  required: ["flow_id"]
5263
5347
  }
@@ -5366,27 +5450,33 @@ function handleToolCall(name, args) {
5366
5450
  switch (name) {
5367
5451
  case "list_docs": {
5368
5452
  let docs = loadDocs();
5369
- if (args.category) docs = docs.filter((d) => d.category === args.category);
5453
+ if (args.category)
5454
+ docs = docs.filter((d) => d.category === args.category);
5370
5455
  return json(docs);
5371
5456
  }
5372
5457
  case "get_doc": {
5373
5458
  const root = resolveBundledRoot();
5374
5459
  if (!root) return err("DAZI_BUNDLED_DIR \u672A\u8BBE\u7F6E");
5375
5460
  const entry = loadDocs().find((d) => d.id === String(args.id));
5376
- if (!entry) return err(`\u6587\u6863\u672A\u627E\u5230: ${args.id}\uFF08\u4F7F\u7528 list_docs \u67E5\u770B\u53EF\u7528\u6587\u6863\uFF09`);
5461
+ if (!entry)
5462
+ return err(`\u6587\u6863\u672A\u627E\u5230: ${args.id}\uFF08\u4F7F\u7528 list_docs \u67E5\u770B\u53EF\u7528\u6587\u6863\uFF09`);
5377
5463
  const content = readFile(import_path10.default.join(root, "docs", entry.file));
5378
5464
  return content ? text(content) : err(`\u6587\u6863\u6587\u4EF6\u4E0D\u5B58\u5728: ${entry.file}`);
5379
5465
  }
5380
5466
  case "list_prompts": {
5381
5467
  let prompts = loadPrompts();
5382
- if (args.category) prompts = prompts.filter((p) => p.category === args.category);
5468
+ if (args.category)
5469
+ prompts = prompts.filter((p) => p.category === args.category);
5383
5470
  return json(prompts);
5384
5471
  }
5385
5472
  case "get_prompt": {
5386
5473
  const root = resolveBundledRoot();
5387
5474
  if (!root) return err("DAZI_BUNDLED_DIR \u672A\u8BBE\u7F6E");
5388
5475
  const entry = loadPrompts().find((p) => p.id === String(args.id));
5389
- if (!entry) return err(`\u63D0\u793A\u8BCD\u672A\u627E\u5230: ${args.id}\uFF08\u4F7F\u7528 list_prompts \u67E5\u770B\u53EF\u7528\u63D0\u793A\u8BCD\uFF09`);
5476
+ if (!entry)
5477
+ return err(
5478
+ `\u63D0\u793A\u8BCD\u672A\u627E\u5230: ${args.id}\uFF08\u4F7F\u7528 list_prompts \u67E5\u770B\u53EF\u7528\u63D0\u793A\u8BCD\uFF09`
5479
+ );
5390
5480
  const content = readFile(import_path10.default.join(root, "prompts", entry.file));
5391
5481
  return content ? text(content) : err(`\u63D0\u793A\u8BCD\u6587\u4EF6\u4E0D\u5B58\u5728: ${entry.file}`);
5392
5482
  }
@@ -5399,11 +5489,22 @@ function handleToolCall(name, args) {
5399
5489
  return "error" in data ? err(String(data.error)) : json(data);
5400
5490
  }
5401
5491
  case "onto_list_functions": {
5402
- const data = callCli("dazi-onto", ["function", "list", "--space", String(args.space_id)]);
5492
+ const data = callCli("dazi-onto", [
5493
+ "function",
5494
+ "list",
5495
+ "--space",
5496
+ String(args.space_id)
5497
+ ]);
5403
5498
  return "error" in data ? err(String(data.error)) : json(data);
5404
5499
  }
5405
5500
  case "onto_get_function": {
5406
- const data = callCli("dazi-onto", ["function", "get", String(args.function_id), "--space", String(args.space_id)]);
5501
+ const data = callCli("dazi-onto", [
5502
+ "function",
5503
+ "get",
5504
+ String(args.function_id),
5505
+ "--space",
5506
+ String(args.space_id)
5507
+ ]);
5407
5508
  return "error" in data ? err(String(data.error)) : json(data);
5408
5509
  }
5409
5510
  case "onto_run_function": {
@@ -5420,23 +5521,43 @@ function handleToolCall(name, args) {
5420
5521
  return "error" in data ? err(String(data.error)) : json(data);
5421
5522
  }
5422
5523
  case "onto_list_actions": {
5423
- const data = callCli("dazi-onto", ["action", "list", "--space", String(args.space_id)]);
5524
+ const data = callCli("dazi-onto", [
5525
+ "action",
5526
+ "list",
5527
+ "--space",
5528
+ String(args.space_id)
5529
+ ]);
5424
5530
  return "error" in data ? err(String(data.error)) : json(data);
5425
5531
  }
5426
5532
  case "onto_list_rules": {
5427
- const ruleArgs = ["rule", "list", "--space", String(args.space_id)];
5533
+ const ruleArgs = [
5534
+ "rule",
5535
+ "list",
5536
+ "--space",
5537
+ String(args.space_id)
5538
+ ];
5428
5539
  if (args.rule_set) ruleArgs.push("--rule-set", String(args.rule_set));
5429
5540
  const data = callCli("dazi-onto", ruleArgs);
5430
5541
  return "error" in data ? err(String(data.error)) : json(data);
5431
5542
  }
5432
5543
  case "onto_list_scripts": {
5433
- const scriptArgs = ["script", "list", "--space", String(args.space_id)];
5544
+ const scriptArgs = [
5545
+ "script",
5546
+ "list",
5547
+ "--space",
5548
+ String(args.space_id)
5549
+ ];
5434
5550
  if (args.script_type) scriptArgs.push("--type", String(args.script_type));
5435
5551
  const data = callCli("dazi-onto", scriptArgs);
5436
5552
  return "error" in data ? err(String(data.error)) : json(data);
5437
5553
  }
5438
5554
  case "onto_space_snapshot": {
5439
- const data = callCli("dazi-onto", ["space", "snapshot", "--space-id", String(args.space_id)]);
5555
+ const data = callCli("dazi-onto", [
5556
+ "space",
5557
+ "snapshot",
5558
+ "--space-id",
5559
+ String(args.space_id)
5560
+ ]);
5440
5561
  return "error" in data ? err(String(data.error)) : json(data);
5441
5562
  }
5442
5563
  case "flow_list_flows": {
@@ -5464,7 +5585,13 @@ function handleToolCall(name, args) {
5464
5585
  }
5465
5586
  case "flow_start_run": {
5466
5587
  const input = args.input ? JSON.stringify(args.input) : "{}";
5467
- const data = callCli("dazi-flow", ["run", "start", String(args.flow_id), "--input", input]);
5588
+ const data = callCli("dazi-flow", [
5589
+ "run",
5590
+ "start",
5591
+ String(args.flow_id),
5592
+ "--input",
5593
+ input
5594
+ ]);
5468
5595
  return "error" in data ? err(String(data.error)) : json(data);
5469
5596
  }
5470
5597
  case "flow_debug_run": {
@@ -5486,17 +5613,31 @@ function handleToolCall(name, args) {
5486
5613
  return "error" in data ? err(String(data.error)) : json(data);
5487
5614
  }
5488
5615
  case "flow_table_structure": {
5489
- const strArgs = ["source", "table-structure", String(args.source_id), String(args.table_name)];
5616
+ const strArgs = [
5617
+ "source",
5618
+ "table-structure",
5619
+ String(args.source_id),
5620
+ String(args.table_name)
5621
+ ];
5490
5622
  if (args.schema) strArgs.push("--schema", String(args.schema));
5491
5623
  const data = callCli("dazi-flow", strArgs);
5492
5624
  return "error" in data ? err(String(data.error)) : json(data);
5493
5625
  }
5494
5626
  case "flow_snapshot_pull": {
5495
- const data = callCli("dazi-flow", ["snapshot", "pull", "--flow", String(args.flow_id)]);
5627
+ const data = callCli("dazi-flow", [
5628
+ "snapshot",
5629
+ "pull",
5630
+ "--flow",
5631
+ String(args.flow_id)
5632
+ ]);
5496
5633
  return "error" in data ? err(String(data.error)) : json(data);
5497
5634
  }
5498
5635
  case "flow_plan_llm_guide": {
5499
- const data = callCli("dazi-flow", ["plan", "llm-guide", String(args.flow_id)]);
5636
+ const data = callCli("dazi-flow", [
5637
+ "plan",
5638
+ "llm-guide",
5639
+ String(args.flow_id)
5640
+ ]);
5500
5641
  return "error" in data ? err(String(data.error)) : json(data);
5501
5642
  }
5502
5643
  case "data_list_spaces": {
@@ -5504,7 +5645,13 @@ function handleToolCall(name, args) {
5504
5645
  return "error" in data ? err(String(data.error)) : json(data);
5505
5646
  }
5506
5647
  case "data_list_tables": {
5507
- const data = callCli("dazi", ["data", "table", "list", "--space", String(args.space_id)]);
5648
+ const data = callCli("dazi", [
5649
+ "data",
5650
+ "table",
5651
+ "list",
5652
+ "--space",
5653
+ String(args.space_id)
5654
+ ]);
5508
5655
  return "error" in data ? err(String(data.error)) : json(data);
5509
5656
  }
5510
5657
  case "data_table_schema": {
@@ -5547,7 +5694,7 @@ function dispatch(msg) {
5547
5694
  result: {
5548
5695
  protocolVersion: "2024-11-05",
5549
5696
  capabilities: { tools: {} },
5550
- serverInfo: { name: "dazi", version: "3.0.0" }
5697
+ serverInfo: { name: "dazi", version: "3.0.3" }
5551
5698
  }
5552
5699
  };
5553
5700
  case "initialized":
@@ -5561,7 +5708,11 @@ function dispatch(msg) {
5561
5708
  const result = handleToolCall(toolName, toolArgs);
5562
5709
  return { jsonrpc: "2.0", id, result };
5563
5710
  } catch (e) {
5564
- return { jsonrpc: "2.0", id, result: err(e instanceof Error ? e.message : String(e)) };
5711
+ return {
5712
+ jsonrpc: "2.0",
5713
+ id,
5714
+ result: err(e instanceof Error ? e.message : String(e))
5715
+ };
5565
5716
  }
5566
5717
  }
5567
5718
  case "ping":
@@ -5575,20 +5726,32 @@ function dispatch(msg) {
5575
5726
  }
5576
5727
  }
5577
5728
  function makeMcpCommand() {
5578
- const cmd = new Command("mcp").description("MCP \u670D\u52A1\uFF08\u805A\u5408\uFF1Aonto + flow + data + docs + prompts\uFF09");
5579
- cmd.command("stdio").description("\u4EE5 stdio JSON-RPC \u6A21\u5F0F\u542F\u52A8\u642D\u5B50\u805A\u5408 MCP\uFF08\u4F9B Cursor/Claude \u8C03\u7528\uFF09").action(() => {
5729
+ const cmd = new Command("mcp").description(
5730
+ "MCP \u670D\u52A1\uFF08\u805A\u5408\uFF1Aonto + flow + data + docs + prompts\uFF09"
5731
+ );
5732
+ cmd.command("stdio").description(
5733
+ "\u4EE5 stdio JSON-RPC \u6A21\u5F0F\u542F\u52A8\u642D\u5B50\u805A\u5408 MCP\uFF08\u4F9B Cursor/Claude \u8C03\u7528\uFF09"
5734
+ ).action(() => {
5580
5735
  const docs = loadDocs().length;
5581
5736
  const prompts = loadPrompts().length;
5582
- process.stderr.write(`[dazi mcp stdio] \u642D\u5B50\u805A\u5408 MCP \u5DF2\u542F\u52A8 \u2014 ${MCP_TOOLS.length} \u4E2A\u5DE5\u5177
5583
- `);
5737
+ process.stderr.write(
5738
+ `[dazi mcp stdio] \u642D\u5B50\u805A\u5408 MCP \u5DF2\u542F\u52A8 \u2014 ${MCP_TOOLS.length} \u4E2A\u5DE5\u5177
5739
+ `
5740
+ );
5584
5741
  process.stderr.write(` \u6587\u6863: ${docs} \u7BC7 \u63D0\u793A\u8BCD: ${prompts} \u7BC7
5585
5742
  `);
5586
- process.stderr.write(` onto: ${MCP_TOOLS.filter((t) => t.name.startsWith("onto_")).length} \u4E2A\u5DE5\u5177
5587
- `);
5588
- process.stderr.write(` flow: ${MCP_TOOLS.filter((t) => t.name.startsWith("flow_")).length} \u4E2A\u5DE5\u5177
5589
- `);
5590
- process.stderr.write(` data: ${MCP_TOOLS.filter((t) => t.name.startsWith("data_")).length} \u4E2A\u5DE5\u5177
5591
- `);
5743
+ process.stderr.write(
5744
+ ` onto: ${MCP_TOOLS.filter((t) => t.name.startsWith("onto_")).length} \u4E2A\u5DE5\u5177
5745
+ `
5746
+ );
5747
+ process.stderr.write(
5748
+ ` flow: ${MCP_TOOLS.filter((t) => t.name.startsWith("flow_")).length} \u4E2A\u5DE5\u5177
5749
+ `
5750
+ );
5751
+ process.stderr.write(
5752
+ ` data: ${MCP_TOOLS.filter((t) => t.name.startsWith("data_")).length} \u4E2A\u5DE5\u5177
5753
+ `
5754
+ );
5592
5755
  let buffer = "";
5593
5756
  process.stdin.setEncoding("utf-8");
5594
5757
  process.stdin.on("data", (chunk) => {
@@ -5615,7 +5778,8 @@ function makeMcpCommand() {
5615
5778
  let tools = MCP_TOOLS;
5616
5779
  if (opts.category) {
5617
5780
  tools = tools.filter((t) => {
5618
- if (opts.category === "docs") return t.name.startsWith("list_docs") || t.name.startsWith("get_doc") || t.name.startsWith("list_prompts") || t.name.startsWith("get_prompt");
5781
+ if (opts.category === "docs")
5782
+ return t.name.startsWith("list_docs") || t.name.startsWith("get_doc") || t.name.startsWith("list_prompts") || t.name.startsWith("get_prompt");
5619
5783
  return t.name.startsWith(`${opts.category}_`);
5620
5784
  });
5621
5785
  }
@@ -5644,14 +5808,16 @@ function forwardToCli(cliName, extraArgs) {
5644
5808
  const bundled = resolveBundledCli(cliName);
5645
5809
  let result;
5646
5810
  if (bundled) {
5647
- result = (0, import_child_process2.spawnSync)(process.execPath, [bundled, ...extraArgs], { stdio: "inherit" });
5811
+ result = (0, import_child_process2.spawnSync)(process.execPath, [bundled, ...extraArgs], {
5812
+ stdio: "inherit"
5813
+ });
5648
5814
  } else {
5649
5815
  result = (0, import_child_process2.spawnSync)(cliName, extraArgs, { stdio: "inherit", shell: true });
5650
5816
  }
5651
5817
  process.exit(result.status ?? 1);
5652
5818
  }
5653
5819
  var program2 = new Command();
5654
- program2.name("dazi").description("\u642D\u5B50 v3 \u2014 Onto / Flow / App \u7EDF\u4E00 CLI").version("3.0.0", "-v, --version");
5820
+ program2.name("dazi").description("\u642D\u5B50 v3 \u2014 Onto / Flow / App \u7EDF\u4E00 CLI").version("3.0.3", "-v, --version");
5655
5821
  program2.addCommand(makeAuthCommand());
5656
5822
  program2.addCommand(makeDoctorCommand());
5657
5823
  program2.addCommand(makeEnvCommand());
@@ -1,7 +1,7 @@
1
1
  # 流程项目 AI 工作手册
2
2
 
3
3
  **文档 ID**: `flow/ai-workflow-playbook`
4
- **适用**: Cursor / Trae / 任何 Agent 修改 `项目/flow_*/流程/<名>/`
4
+ **适用**: Cursor / Trae / 任何 Agent 修改 `项目/<业务名>/流程/flows/<流程名>/`
5
5
 
6
6
  > 完整文件规范见 [流程本地文件规范](./local-files-spec.md)。
7
7
 
@@ -34,20 +34,21 @@
34
34
  ## 3. 标准流程(改现有 excel-python)
35
35
 
36
36
  ```powershell
37
- cd "项目\flow_xxx\流程\<流程名>"
37
+ # 推荐绝对路径(禁止在 dazi-work 根 --dir .)
38
+ $flowDir = "D:\path\to\dazi-work\项目\<业务名>\流程\flows\<流程名>"
38
39
 
39
- dazi flow project doctor --dir .
40
+ dazi flow project doctor --dir $flowDir
40
41
  # 若不一致:
41
- dazi flow project repair-meta --dir .
42
+ dazi flow project repair-meta --dir $flowDir
42
43
 
43
44
  # 改 flow.json 配置后:
44
- dazi flow project push --dir . --canvas
45
+ dazi flow project push --dir $flowDir --canvas
45
46
 
46
47
  # 改 code.py 后:
47
- dazi flow node push --node <node_uuid> --dir .
48
+ dazi flow node push --node <node_uuid> --dir $flowDir
48
49
 
49
- dazi flow run node-exec --node <node_uuid> --dir .
50
- dazi flow run flow-exec --dir . --type debug
50
+ dazi flow run node-exec --node <node_uuid> --dir $flowDir
51
+ dazi flow run flow-exec --dir $flowDir --type debug
51
52
  ```
52
53
 
53
54
  确认终端出现 **`✅ 画布已全量推送`**。