@dazitech/cli 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/clis/dazi-app.js +90 -9
- package/dist/clis/dazi-flow.js +2 -2
- package/dist/clis/dazi-onto.js +5 -3
- package/dist/clis/dazi.js +139 -38
- package/dist/docs/guides/troubleshooting.md +7 -7
- package/dist/docs/index.json +1 -1
- package/dist/examples/index.json +1 -1
- package/dist/prompts/index.json +94 -16
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/clis/dazi-app.js
CHANGED
|
@@ -13775,7 +13775,7 @@ function applyPlaceholdersInTree(targetDir, ph, oldAppId = "${appId}") {
|
|
|
13775
13775
|
walk(targetDir);
|
|
13776
13776
|
}
|
|
13777
13777
|
function replacePlaceholders(text, ph, oldAppId) {
|
|
13778
|
-
return text.split("${appId}").join(ph.appId).split("${spaceId}").join(ph.spaceId).split("${appName}").join(ph.appName).split("space__demo").join(ph.spaceId).split(`/runtime-apps/${oldAppId}`).join(`/runtime-apps/${ph.appId}`).split(oldAppId).join(ph.appId);
|
|
13778
|
+
return text.split('"${spaceId}"').join(JSON.stringify(ph.spaceId)).split("${appId}").join(ph.appId).split("${spaceId}").join(ph.spaceId).split("${appName}").join(ph.appName).split("space__demo").join(ph.spaceId).split(`/runtime-apps/${oldAppId}`).join(`/runtime-apps/${ph.appId}`).split(oldAppId).join(ph.appId);
|
|
13779
13779
|
}
|
|
13780
13780
|
function writeContextMd(targetDir, ph) {
|
|
13781
13781
|
const aiDir = import_node_path9.default.join(targetDir, ".ai");
|
|
@@ -13910,6 +13910,34 @@ function parseDataspaceId(permissions) {
|
|
|
13910
13910
|
}
|
|
13911
13911
|
return void 0;
|
|
13912
13912
|
}
|
|
13913
|
+
function resolveManifestSpaceId(manifest) {
|
|
13914
|
+
const fromField = String(manifest.space_id ?? "").trim();
|
|
13915
|
+
if (fromField) return fromField;
|
|
13916
|
+
return parseDataspaceId(manifest.permissions);
|
|
13917
|
+
}
|
|
13918
|
+
function syncManifestSpace(cwd, spaceId) {
|
|
13919
|
+
const sid = spaceId.trim();
|
|
13920
|
+
if (!sid) throw new Error("spaceId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
13921
|
+
const manifestPath = import_node_path10.default.join(cwd, "manifest.json");
|
|
13922
|
+
const manifest = JSON.parse(
|
|
13923
|
+
import_node_fs11.default.readFileSync(manifestPath, "utf8")
|
|
13924
|
+
);
|
|
13925
|
+
const previous = resolveManifestSpaceId(manifest);
|
|
13926
|
+
const required = `dataspace:${sid}`;
|
|
13927
|
+
const perms = Array.isArray(manifest.permissions) ? manifest.permissions.map((p) => String(p).trim()) : [];
|
|
13928
|
+
const nextPerms = [
|
|
13929
|
+
...perms.filter((p) => !p.startsWith("dataspace:")),
|
|
13930
|
+
required
|
|
13931
|
+
];
|
|
13932
|
+
const changed = manifest.space_id !== sid || JSON.stringify(manifest.permissions) !== JSON.stringify(nextPerms);
|
|
13933
|
+
manifest.space_id = sid;
|
|
13934
|
+
manifest.permissions = nextPerms;
|
|
13935
|
+
if (changed) {
|
|
13936
|
+
import_node_fs11.default.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
13937
|
+
`, "utf8");
|
|
13938
|
+
}
|
|
13939
|
+
return { changed, previous: previous ?? void 0 };
|
|
13940
|
+
}
|
|
13913
13941
|
function validateDataSource(ds, index, projectRoot) {
|
|
13914
13942
|
const base = `data_sources[${index}]`;
|
|
13915
13943
|
const issues = [];
|
|
@@ -14229,23 +14257,55 @@ function validateManifestRecord(manifest, opts) {
|
|
|
14229
14257
|
}
|
|
14230
14258
|
}
|
|
14231
14259
|
}
|
|
14260
|
+
const declaredSpace = String(manifest.space_id ?? "").trim();
|
|
14232
14261
|
const perms = manifest.permissions;
|
|
14233
|
-
|
|
14262
|
+
const permSpace = parseDataspaceId(perms);
|
|
14263
|
+
if (!declaredSpace && !permSpace) {
|
|
14234
14264
|
issues.push(
|
|
14235
14265
|
issue(
|
|
14236
14266
|
"error",
|
|
14237
|
-
"
|
|
14238
|
-
"
|
|
14239
|
-
"\
|
|
14267
|
+
"SPACE_ID_REQUIRED",
|
|
14268
|
+
"space_id",
|
|
14269
|
+
"\u987B\u914D\u7F6E space_id\uFF08\u63A8\u8350\uFF09\u6216 permissions \u4E2D\u7684 dataspace:<\u7A7A\u95F4Id>"
|
|
14240
14270
|
)
|
|
14241
14271
|
);
|
|
14242
|
-
} else if (
|
|
14272
|
+
} else if (declaredSpace && permSpace && declaredSpace !== permSpace) {
|
|
14273
|
+
issues.push(
|
|
14274
|
+
issue(
|
|
14275
|
+
"error",
|
|
14276
|
+
"SPACE_ID_MISMATCH",
|
|
14277
|
+
"space_id",
|
|
14278
|
+
`space_id=${JSON.stringify(declaredSpace)} \u4E0E permissions dataspace:${permSpace} \u4E0D\u4E00\u81F4`
|
|
14279
|
+
)
|
|
14280
|
+
);
|
|
14281
|
+
}
|
|
14282
|
+
if (!Array.isArray(perms) || perms.length === 0) {
|
|
14283
|
+
if (!declaredSpace) {
|
|
14284
|
+
issues.push(
|
|
14285
|
+
issue(
|
|
14286
|
+
"error",
|
|
14287
|
+
"PERMISSIONS_REQUIRED",
|
|
14288
|
+
"permissions",
|
|
14289
|
+
"\u81F3\u5C11\u58F0\u660E permissions\uFF08\u5982 dataspace:<spaceId>\uFF09\u6216\u914D\u7F6E space_id"
|
|
14290
|
+
)
|
|
14291
|
+
);
|
|
14292
|
+
} else {
|
|
14293
|
+
issues.push(
|
|
14294
|
+
issue(
|
|
14295
|
+
"warning",
|
|
14296
|
+
"PERMISSIONS_DATASPACE",
|
|
14297
|
+
"permissions",
|
|
14298
|
+
`upload \u65F6\u5C06\u81EA\u52A8\u8865\u9F50 dataspace:${declaredSpace}`
|
|
14299
|
+
)
|
|
14300
|
+
);
|
|
14301
|
+
}
|
|
14302
|
+
} else if (!permSpace && !declaredSpace) {
|
|
14243
14303
|
issues.push(
|
|
14244
14304
|
issue(
|
|
14245
14305
|
"warning",
|
|
14246
14306
|
"PERMISSIONS_DATASPACE",
|
|
14247
14307
|
"permissions",
|
|
14248
|
-
"\u672A\u627E\u5230 dataspace:<id>\
|
|
14308
|
+
"\u672A\u627E\u5230 dataspace:<id>\uFF1B\u8BF7\u914D\u7F6E manifest.space_id"
|
|
14249
14309
|
)
|
|
14250
14310
|
);
|
|
14251
14311
|
}
|
|
@@ -14409,7 +14469,7 @@ function validateManifest(cwd, opts = {}) {
|
|
|
14409
14469
|
manifestPath,
|
|
14410
14470
|
appId: String(manifest.appId ?? "").trim() || void 0,
|
|
14411
14471
|
version: String(manifest.version ?? "").trim() || void 0,
|
|
14412
|
-
spaceId:
|
|
14472
|
+
spaceId: resolveManifestSpaceId(manifest),
|
|
14413
14473
|
dataSourceKeys,
|
|
14414
14474
|
kinds: [...kindSet],
|
|
14415
14475
|
issues,
|
|
@@ -14564,6 +14624,22 @@ function registerUpload(program3) {
|
|
|
14564
14624
|
program3.command("upload").description("\u6253\u5305\u5E76\u4E0A\u4F20\u5230 Registry\uFF08\u65E0 app \u5219\u5148 create\uFF09").option("--cwd <dir>", "DRAP \u9879\u76EE\u76EE\u5F55\uFF08\u9ED8\u8BA4\u81EA\u52A8\u8BC6\u522B\uFF1Ashell \u76EE\u5F55\u6216\u542B manifest.json \u7684\u7956\u5148\uFF09").option("--space <id>", "\u6570\u636E\u7A7A\u95F4 id\uFF08\u5FC5\u586B\uFF0C\u9996\u6B21 create\uFF09").option("--activate", "\u4E0A\u4F20\u540E\u6FC0\u6D3B", false).option("--changelog <text>", "\u53D8\u66F4\u8BF4\u660E").option("--file <path>", "\u5DF2\u6709 .dazi-app\uFF0C\u8DF3\u8FC7 package").option("--skip-validate", "\u8DF3\u8FC7 manifest \u6821\u9A8C\uFF08\u4E0D\u63A8\u8350\uFF09").option("--no-source", "\u4E0D\u4E0A\u4F20\u6E90\u7801\u5FEB\u7167\uFF08\u9ED8\u8BA4\u4E0A\u4F20\uFF0C\u4F9B release \u8F6C\u6A21\u677F\uFF09").option("--json").action(async (opts) => {
|
|
14565
14625
|
if (!loadAuth()) throw new Error("\u8BF7\u5148 dazi-app auth login");
|
|
14566
14626
|
const cwd = requireProjectCwd(opts.cwd);
|
|
14627
|
+
const manifestEarly = JSON.parse(
|
|
14628
|
+
import_node_fs13.default.readFileSync(import_node_path12.default.join(cwd, "manifest.json"), "utf8")
|
|
14629
|
+
);
|
|
14630
|
+
const uploadSpaceId = String(opts.space || "").trim() || resolveManifestSpaceId(manifestEarly) || "";
|
|
14631
|
+
if (!uploadSpaceId) {
|
|
14632
|
+
throw new Error(
|
|
14633
|
+
"manifest \u987B\u914D\u7F6E space_id\uFF0C\u6216 permissions \u542B dataspace:<\u7A7A\u95F4Id>\uFF1B\u4E5F\u53EF upload --space <id>"
|
|
14634
|
+
);
|
|
14635
|
+
}
|
|
14636
|
+
const sync = syncManifestSpace(cwd, uploadSpaceId);
|
|
14637
|
+
if (sync.changed && !opts.json) {
|
|
14638
|
+
const prev = sync.previous ? `\uFF08\u539F ${sync.previous}\uFF09` : "";
|
|
14639
|
+
console.warn(
|
|
14640
|
+
`\u5DF2\u540C\u6B65 manifest space_id / permissions \u2192 ${uploadSpaceId}${prev}`
|
|
14641
|
+
);
|
|
14642
|
+
}
|
|
14567
14643
|
if (!opts.skipValidate) {
|
|
14568
14644
|
const vr = validateManifest(cwd, { scanSrc: true });
|
|
14569
14645
|
if (!vr.ok) {
|
|
@@ -15416,10 +15492,13 @@ function registerInit(program3) {
|
|
|
15416
15492
|
const manifest = JSON.parse(import_node_fs22.default.readFileSync(manifestPath, "utf8"));
|
|
15417
15493
|
manifest.appId = appId;
|
|
15418
15494
|
manifest.name = appName;
|
|
15495
|
+
manifest.space_id = spaceId;
|
|
15419
15496
|
if (Array.isArray(manifest.permissions)) {
|
|
15420
15497
|
manifest.permissions = manifest.permissions.map(
|
|
15421
15498
|
(p) => p.startsWith("dataspace:") ? `dataspace:${spaceId}` : p
|
|
15422
15499
|
);
|
|
15500
|
+
} else {
|
|
15501
|
+
manifest.permissions = [`dataspace:${spaceId}`];
|
|
15423
15502
|
}
|
|
15424
15503
|
import_node_fs22.default.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf8");
|
|
15425
15504
|
patchPackageJsonForApp(outDir, appId, appName);
|
|
@@ -16672,7 +16751,9 @@ function registerLegacyCompatCommands(program3) {
|
|
|
16672
16751
|
|
|
16673
16752
|
// cli/dazi-app/src/index.ts
|
|
16674
16753
|
var program2 = new Command();
|
|
16675
|
-
program2.name("dazi-app").description(
|
|
16754
|
+
program2.name("dazi-app").description(
|
|
16755
|
+
"\u642D\u5B50 App CLI \u2014 DRAP \u524D\u7AEF\u5E94\u7528\uFF08manifest / build / upload / preview\uFF09"
|
|
16756
|
+
).version("3.0.2", "-v, --version");
|
|
16676
16757
|
registerAuth(program2);
|
|
16677
16758
|
registerBuild(program2);
|
|
16678
16759
|
registerDev(program2);
|
package/dist/clis/dazi-flow.js
CHANGED
|
@@ -4313,7 +4313,7 @@ function buildFlowDirQuickStartMarkdown(opts) {
|
|
|
4313
4313
|
"\u5728 **dazi-work \u6839**\uFF08\u6216\u5C06 `--dir` \u6307\u5411\u672C\u76EE\u5F55\uFF09\uFF1B\u9700\u5DF2\u5B89\u88C5\u5168\u5C40 CLI\uFF08`pnpm add -g @dazitech/cli`\uFF09\uFF1A",
|
|
4314
4314
|
"",
|
|
4315
4315
|
"```powershell",
|
|
4316
|
-
`cd "\u9879\u76EE\\${opts.projectFolder ?? "
|
|
4316
|
+
`cd "\u9879\u76EE\\${opts.projectFolder ?? "<\u9879\u76EE\u540D>"}\\\u6D41\u7A0B\\flows\\${name}"`,
|
|
4317
4317
|
"",
|
|
4318
4318
|
"# \u72B6\u6001 / \u62C9\u53D6 / \u63D0\u4EA4",
|
|
4319
4319
|
psFlowLine("project status --dir ."),
|
|
@@ -6503,7 +6503,7 @@ function makeManagedFilesCommand() {
|
|
|
6503
6503
|
|
|
6504
6504
|
// cli/dazi-flow/src/index.ts
|
|
6505
6505
|
var program2 = new Command();
|
|
6506
|
-
program2.name("dazi-flow").description("\u642D\u5B50 Flow CLI \u2014 \u5DE5\u4F5C\u6D41\u7BA1\u7406").version("3.0.
|
|
6506
|
+
program2.name("dazi-flow").description("\u642D\u5B50 Flow CLI \u2014 \u5DE5\u4F5C\u6D41\u7BA1\u7406").version("3.0.2", "-v, --version");
|
|
6507
6507
|
program2.addCommand(makeFlowsCommand());
|
|
6508
6508
|
program2.addCommand(makeSnapshotCommand());
|
|
6509
6509
|
program2.addCommand(makeProjectCommand());
|
package/dist/clis/dazi-onto.js
CHANGED
|
@@ -3895,7 +3895,9 @@ function makeObjectCommand() {
|
|
|
3895
3895
|
function makeMcpCommand() {
|
|
3896
3896
|
const cmd = new Command("mcp").description("MCP \u670D\u52A1\uFF08\u672C\u4F53\u4FA7\uFF09");
|
|
3897
3897
|
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(
|
|
3898
|
+
process.stderr.write(
|
|
3899
|
+
"[dazi-onto mcp serve] MCP stdio \u670D\u52A1 \u2014 Phase 5 \u5B8C\u6574\u5B9E\u73B0\n"
|
|
3900
|
+
);
|
|
3899
3901
|
process.stderr.write("\u5F53\u524D\u7248\u672C\u4EC5\u8F93\u51FA\u5360\u4F4D\u54CD\u5E94\n");
|
|
3900
3902
|
process.stdin.setEncoding("utf-8");
|
|
3901
3903
|
process.stdin.on("data", (data) => {
|
|
@@ -3911,7 +3913,7 @@ function makeMcpCommand() {
|
|
|
3911
3913
|
result: {
|
|
3912
3914
|
protocolVersion: "2024-11-05",
|
|
3913
3915
|
capabilities: { tools: {} },
|
|
3914
|
-
serverInfo: { name: "dazi-onto", version: "3.0.
|
|
3916
|
+
serverInfo: { name: "dazi-onto", version: "3.0.2" }
|
|
3915
3917
|
}
|
|
3916
3918
|
};
|
|
3917
3919
|
process.stdout.write(JSON.stringify(response) + "\n");
|
|
@@ -3934,7 +3936,7 @@ function makeMcpCommand() {
|
|
|
3934
3936
|
|
|
3935
3937
|
// cli/dazi-onto/src/index.ts
|
|
3936
3938
|
var program2 = new Command();
|
|
3937
|
-
program2.name("dazi-onto").description("\u642D\u5B50 Onto CLI \u2014 \u672C\u4F53\uFF08Ontology\uFF09\u7BA1\u7406").version("3.0.
|
|
3939
|
+
program2.name("dazi-onto").description("\u642D\u5B50 Onto CLI \u2014 \u672C\u4F53\uFF08Ontology\uFF09\u7BA1\u7406").version("3.0.2", "-v, --version");
|
|
3938
3940
|
program2.addCommand(makeSpaceCommand());
|
|
3939
3941
|
program2.addCommand(makeFunctionCommand());
|
|
3940
3942
|
program2.addCommand(makeActionCommand());
|
package/dist/clis/dazi.js
CHANGED
|
@@ -3959,7 +3959,7 @@ function makeEnvCommand() {
|
|
|
3959
3959
|
return new Command("env").description("\u663E\u793A\u73AF\u5883\u4FE1\u606F").action(() => {
|
|
3960
3960
|
const auth = tryLoadAuth();
|
|
3961
3961
|
const env = {
|
|
3962
|
-
version: "3.0.
|
|
3962
|
+
version: "3.0.2",
|
|
3963
3963
|
node: process.version,
|
|
3964
3964
|
platform: `${import_os5.default.type()} ${import_os5.default.arch()}`,
|
|
3965
3965
|
serverUrl: getServerUrl(),
|
|
@@ -5001,7 +5001,8 @@ function resolveCli(name) {
|
|
|
5001
5001
|
}
|
|
5002
5002
|
function callCli(cliName, args) {
|
|
5003
5003
|
const cliPath = resolveCli(cliName);
|
|
5004
|
-
if (!cliPath)
|
|
5004
|
+
if (!cliPath)
|
|
5005
|
+
return { error: `CLI ${cliName} \u672A\u627E\u5230\uFF0C\u8BF7\u786E\u8BA4 DAZI_BUNDLED_DIR \u5DF2\u8BBE\u7F6E` };
|
|
5005
5006
|
const result = (0, import_child_process.spawnSync)(process.execPath, [cliPath, ...args], {
|
|
5006
5007
|
encoding: "utf-8",
|
|
5007
5008
|
timeout: 3e4,
|
|
@@ -5077,7 +5078,10 @@ var MCP_TOOLS = [
|
|
|
5077
5078
|
inputSchema: {
|
|
5078
5079
|
type: "object",
|
|
5079
5080
|
properties: {
|
|
5080
|
-
id: {
|
|
5081
|
+
id: {
|
|
5082
|
+
type: "string",
|
|
5083
|
+
description: "\u6587\u6863 ID\uFF0C\u5982 guides/quickstart\u3001onto/function-guide"
|
|
5084
|
+
}
|
|
5081
5085
|
},
|
|
5082
5086
|
required: ["id"]
|
|
5083
5087
|
}
|
|
@@ -5103,7 +5107,10 @@ var MCP_TOOLS = [
|
|
|
5103
5107
|
inputSchema: {
|
|
5104
5108
|
type: "object",
|
|
5105
5109
|
properties: {
|
|
5106
|
-
id: {
|
|
5110
|
+
id: {
|
|
5111
|
+
type: "string",
|
|
5112
|
+
description: "\u63D0\u793A\u8BCD ID\uFF0C\u5982 onto/function-design"
|
|
5113
|
+
}
|
|
5107
5114
|
},
|
|
5108
5115
|
required: ["id"]
|
|
5109
5116
|
}
|
|
@@ -5186,7 +5193,10 @@ var MCP_TOOLS = [
|
|
|
5186
5193
|
type: "object",
|
|
5187
5194
|
properties: {
|
|
5188
5195
|
space_id: { type: "string" },
|
|
5189
|
-
script_type: {
|
|
5196
|
+
script_type: {
|
|
5197
|
+
type: "string",
|
|
5198
|
+
description: "\u811A\u672C\u7C7B\u578B\uFF08\u5982 ontology_function\uFF09"
|
|
5199
|
+
}
|
|
5190
5200
|
},
|
|
5191
5201
|
required: ["space_id"]
|
|
5192
5202
|
}
|
|
@@ -5210,7 +5220,10 @@ var MCP_TOOLS = [
|
|
|
5210
5220
|
type: "object",
|
|
5211
5221
|
properties: {
|
|
5212
5222
|
space_id: { type: "string", description: "\u6309\u7A7A\u95F4\u8FC7\u6EE4\uFF08\u53EF\u9009\uFF09" },
|
|
5213
|
-
status: {
|
|
5223
|
+
status: {
|
|
5224
|
+
type: "string",
|
|
5225
|
+
description: "\u6309\u72B6\u6001\u8FC7\u6EE4\uFF08active/draft/archived\uFF09"
|
|
5226
|
+
}
|
|
5214
5227
|
}
|
|
5215
5228
|
}
|
|
5216
5229
|
},
|
|
@@ -5233,7 +5246,10 @@ var MCP_TOOLS = [
|
|
|
5233
5246
|
properties: {
|
|
5234
5247
|
flow_id: { type: "string" },
|
|
5235
5248
|
limit: { type: "number", description: "\u6700\u591A\u8FD4\u56DE\u6761\u6570\uFF08\u9ED8\u8BA4 10\uFF09" },
|
|
5236
|
-
status: {
|
|
5249
|
+
status: {
|
|
5250
|
+
type: "string",
|
|
5251
|
+
description: "\u6309\u72B6\u6001\u8FC7\u6EE4\uFF08running/success/failed\uFF09"
|
|
5252
|
+
}
|
|
5237
5253
|
},
|
|
5238
5254
|
required: ["flow_id"]
|
|
5239
5255
|
}
|
|
@@ -5257,7 +5273,10 @@ var MCP_TOOLS = [
|
|
|
5257
5273
|
type: "object",
|
|
5258
5274
|
properties: {
|
|
5259
5275
|
flow_id: { type: "string" },
|
|
5260
|
-
run_id: {
|
|
5276
|
+
run_id: {
|
|
5277
|
+
type: "string",
|
|
5278
|
+
description: "\u6307\u5B9A Run ID\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u6700\u8FD1\u4E00\u6B21\uFF09"
|
|
5279
|
+
}
|
|
5261
5280
|
},
|
|
5262
5281
|
required: ["flow_id"]
|
|
5263
5282
|
}
|
|
@@ -5366,27 +5385,33 @@ function handleToolCall(name, args) {
|
|
|
5366
5385
|
switch (name) {
|
|
5367
5386
|
case "list_docs": {
|
|
5368
5387
|
let docs = loadDocs();
|
|
5369
|
-
if (args.category)
|
|
5388
|
+
if (args.category)
|
|
5389
|
+
docs = docs.filter((d) => d.category === args.category);
|
|
5370
5390
|
return json(docs);
|
|
5371
5391
|
}
|
|
5372
5392
|
case "get_doc": {
|
|
5373
5393
|
const root = resolveBundledRoot();
|
|
5374
5394
|
if (!root) return err("DAZI_BUNDLED_DIR \u672A\u8BBE\u7F6E");
|
|
5375
5395
|
const entry = loadDocs().find((d) => d.id === String(args.id));
|
|
5376
|
-
if (!entry)
|
|
5396
|
+
if (!entry)
|
|
5397
|
+
return err(`\u6587\u6863\u672A\u627E\u5230: ${args.id}\uFF08\u4F7F\u7528 list_docs \u67E5\u770B\u53EF\u7528\u6587\u6863\uFF09`);
|
|
5377
5398
|
const content = readFile(import_path10.default.join(root, "docs", entry.file));
|
|
5378
5399
|
return content ? text(content) : err(`\u6587\u6863\u6587\u4EF6\u4E0D\u5B58\u5728: ${entry.file}`);
|
|
5379
5400
|
}
|
|
5380
5401
|
case "list_prompts": {
|
|
5381
5402
|
let prompts = loadPrompts();
|
|
5382
|
-
if (args.category)
|
|
5403
|
+
if (args.category)
|
|
5404
|
+
prompts = prompts.filter((p) => p.category === args.category);
|
|
5383
5405
|
return json(prompts);
|
|
5384
5406
|
}
|
|
5385
5407
|
case "get_prompt": {
|
|
5386
5408
|
const root = resolveBundledRoot();
|
|
5387
5409
|
if (!root) return err("DAZI_BUNDLED_DIR \u672A\u8BBE\u7F6E");
|
|
5388
5410
|
const entry = loadPrompts().find((p) => p.id === String(args.id));
|
|
5389
|
-
if (!entry)
|
|
5411
|
+
if (!entry)
|
|
5412
|
+
return err(
|
|
5413
|
+
`\u63D0\u793A\u8BCD\u672A\u627E\u5230: ${args.id}\uFF08\u4F7F\u7528 list_prompts \u67E5\u770B\u53EF\u7528\u63D0\u793A\u8BCD\uFF09`
|
|
5414
|
+
);
|
|
5390
5415
|
const content = readFile(import_path10.default.join(root, "prompts", entry.file));
|
|
5391
5416
|
return content ? text(content) : err(`\u63D0\u793A\u8BCD\u6587\u4EF6\u4E0D\u5B58\u5728: ${entry.file}`);
|
|
5392
5417
|
}
|
|
@@ -5399,11 +5424,22 @@ function handleToolCall(name, args) {
|
|
|
5399
5424
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5400
5425
|
}
|
|
5401
5426
|
case "onto_list_functions": {
|
|
5402
|
-
const data = callCli("dazi-onto", [
|
|
5427
|
+
const data = callCli("dazi-onto", [
|
|
5428
|
+
"function",
|
|
5429
|
+
"list",
|
|
5430
|
+
"--space",
|
|
5431
|
+
String(args.space_id)
|
|
5432
|
+
]);
|
|
5403
5433
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5404
5434
|
}
|
|
5405
5435
|
case "onto_get_function": {
|
|
5406
|
-
const data = callCli("dazi-onto", [
|
|
5436
|
+
const data = callCli("dazi-onto", [
|
|
5437
|
+
"function",
|
|
5438
|
+
"get",
|
|
5439
|
+
String(args.function_id),
|
|
5440
|
+
"--space",
|
|
5441
|
+
String(args.space_id)
|
|
5442
|
+
]);
|
|
5407
5443
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5408
5444
|
}
|
|
5409
5445
|
case "onto_run_function": {
|
|
@@ -5420,23 +5456,43 @@ function handleToolCall(name, args) {
|
|
|
5420
5456
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5421
5457
|
}
|
|
5422
5458
|
case "onto_list_actions": {
|
|
5423
|
-
const data = callCli("dazi-onto", [
|
|
5459
|
+
const data = callCli("dazi-onto", [
|
|
5460
|
+
"action",
|
|
5461
|
+
"list",
|
|
5462
|
+
"--space",
|
|
5463
|
+
String(args.space_id)
|
|
5464
|
+
]);
|
|
5424
5465
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5425
5466
|
}
|
|
5426
5467
|
case "onto_list_rules": {
|
|
5427
|
-
const ruleArgs = [
|
|
5468
|
+
const ruleArgs = [
|
|
5469
|
+
"rule",
|
|
5470
|
+
"list",
|
|
5471
|
+
"--space",
|
|
5472
|
+
String(args.space_id)
|
|
5473
|
+
];
|
|
5428
5474
|
if (args.rule_set) ruleArgs.push("--rule-set", String(args.rule_set));
|
|
5429
5475
|
const data = callCli("dazi-onto", ruleArgs);
|
|
5430
5476
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5431
5477
|
}
|
|
5432
5478
|
case "onto_list_scripts": {
|
|
5433
|
-
const scriptArgs = [
|
|
5479
|
+
const scriptArgs = [
|
|
5480
|
+
"script",
|
|
5481
|
+
"list",
|
|
5482
|
+
"--space",
|
|
5483
|
+
String(args.space_id)
|
|
5484
|
+
];
|
|
5434
5485
|
if (args.script_type) scriptArgs.push("--type", String(args.script_type));
|
|
5435
5486
|
const data = callCli("dazi-onto", scriptArgs);
|
|
5436
5487
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5437
5488
|
}
|
|
5438
5489
|
case "onto_space_snapshot": {
|
|
5439
|
-
const data = callCli("dazi-onto", [
|
|
5490
|
+
const data = callCli("dazi-onto", [
|
|
5491
|
+
"space",
|
|
5492
|
+
"snapshot",
|
|
5493
|
+
"--space-id",
|
|
5494
|
+
String(args.space_id)
|
|
5495
|
+
]);
|
|
5440
5496
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5441
5497
|
}
|
|
5442
5498
|
case "flow_list_flows": {
|
|
@@ -5464,7 +5520,13 @@ function handleToolCall(name, args) {
|
|
|
5464
5520
|
}
|
|
5465
5521
|
case "flow_start_run": {
|
|
5466
5522
|
const input = args.input ? JSON.stringify(args.input) : "{}";
|
|
5467
|
-
const data = callCli("dazi-flow", [
|
|
5523
|
+
const data = callCli("dazi-flow", [
|
|
5524
|
+
"run",
|
|
5525
|
+
"start",
|
|
5526
|
+
String(args.flow_id),
|
|
5527
|
+
"--input",
|
|
5528
|
+
input
|
|
5529
|
+
]);
|
|
5468
5530
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5469
5531
|
}
|
|
5470
5532
|
case "flow_debug_run": {
|
|
@@ -5486,17 +5548,31 @@ function handleToolCall(name, args) {
|
|
|
5486
5548
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5487
5549
|
}
|
|
5488
5550
|
case "flow_table_structure": {
|
|
5489
|
-
const strArgs = [
|
|
5551
|
+
const strArgs = [
|
|
5552
|
+
"source",
|
|
5553
|
+
"table-structure",
|
|
5554
|
+
String(args.source_id),
|
|
5555
|
+
String(args.table_name)
|
|
5556
|
+
];
|
|
5490
5557
|
if (args.schema) strArgs.push("--schema", String(args.schema));
|
|
5491
5558
|
const data = callCli("dazi-flow", strArgs);
|
|
5492
5559
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5493
5560
|
}
|
|
5494
5561
|
case "flow_snapshot_pull": {
|
|
5495
|
-
const data = callCli("dazi-flow", [
|
|
5562
|
+
const data = callCli("dazi-flow", [
|
|
5563
|
+
"snapshot",
|
|
5564
|
+
"pull",
|
|
5565
|
+
"--flow",
|
|
5566
|
+
String(args.flow_id)
|
|
5567
|
+
]);
|
|
5496
5568
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5497
5569
|
}
|
|
5498
5570
|
case "flow_plan_llm_guide": {
|
|
5499
|
-
const data = callCli("dazi-flow", [
|
|
5571
|
+
const data = callCli("dazi-flow", [
|
|
5572
|
+
"plan",
|
|
5573
|
+
"llm-guide",
|
|
5574
|
+
String(args.flow_id)
|
|
5575
|
+
]);
|
|
5500
5576
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5501
5577
|
}
|
|
5502
5578
|
case "data_list_spaces": {
|
|
@@ -5504,7 +5580,13 @@ function handleToolCall(name, args) {
|
|
|
5504
5580
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5505
5581
|
}
|
|
5506
5582
|
case "data_list_tables": {
|
|
5507
|
-
const data = callCli("dazi", [
|
|
5583
|
+
const data = callCli("dazi", [
|
|
5584
|
+
"data",
|
|
5585
|
+
"table",
|
|
5586
|
+
"list",
|
|
5587
|
+
"--space",
|
|
5588
|
+
String(args.space_id)
|
|
5589
|
+
]);
|
|
5508
5590
|
return "error" in data ? err(String(data.error)) : json(data);
|
|
5509
5591
|
}
|
|
5510
5592
|
case "data_table_schema": {
|
|
@@ -5547,7 +5629,7 @@ function dispatch(msg) {
|
|
|
5547
5629
|
result: {
|
|
5548
5630
|
protocolVersion: "2024-11-05",
|
|
5549
5631
|
capabilities: { tools: {} },
|
|
5550
|
-
serverInfo: { name: "dazi", version: "3.0.
|
|
5632
|
+
serverInfo: { name: "dazi", version: "3.0.2" }
|
|
5551
5633
|
}
|
|
5552
5634
|
};
|
|
5553
5635
|
case "initialized":
|
|
@@ -5561,7 +5643,11 @@ function dispatch(msg) {
|
|
|
5561
5643
|
const result = handleToolCall(toolName, toolArgs);
|
|
5562
5644
|
return { jsonrpc: "2.0", id, result };
|
|
5563
5645
|
} catch (e) {
|
|
5564
|
-
return {
|
|
5646
|
+
return {
|
|
5647
|
+
jsonrpc: "2.0",
|
|
5648
|
+
id,
|
|
5649
|
+
result: err(e instanceof Error ? e.message : String(e))
|
|
5650
|
+
};
|
|
5565
5651
|
}
|
|
5566
5652
|
}
|
|
5567
5653
|
case "ping":
|
|
@@ -5575,20 +5661,32 @@ function dispatch(msg) {
|
|
|
5575
5661
|
}
|
|
5576
5662
|
}
|
|
5577
5663
|
function makeMcpCommand() {
|
|
5578
|
-
const cmd = new Command("mcp").description(
|
|
5579
|
-
|
|
5664
|
+
const cmd = new Command("mcp").description(
|
|
5665
|
+
"MCP \u670D\u52A1\uFF08\u805A\u5408\uFF1Aonto + flow + data + docs + prompts\uFF09"
|
|
5666
|
+
);
|
|
5667
|
+
cmd.command("stdio").description(
|
|
5668
|
+
"\u4EE5 stdio JSON-RPC \u6A21\u5F0F\u542F\u52A8\u642D\u5B50\u805A\u5408 MCP\uFF08\u4F9B Cursor/Claude \u8C03\u7528\uFF09"
|
|
5669
|
+
).action(() => {
|
|
5580
5670
|
const docs = loadDocs().length;
|
|
5581
5671
|
const prompts = loadPrompts().length;
|
|
5582
|
-
process.stderr.write(
|
|
5583
|
-
`
|
|
5672
|
+
process.stderr.write(
|
|
5673
|
+
`[dazi mcp stdio] \u642D\u5B50\u805A\u5408 MCP \u5DF2\u542F\u52A8 \u2014 ${MCP_TOOLS.length} \u4E2A\u5DE5\u5177
|
|
5674
|
+
`
|
|
5675
|
+
);
|
|
5584
5676
|
process.stderr.write(` \u6587\u6863: ${docs} \u7BC7 \u63D0\u793A\u8BCD: ${prompts} \u7BC7
|
|
5585
5677
|
`);
|
|
5586
|
-
process.stderr.write(
|
|
5587
|
-
`)
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
process.stderr.write(
|
|
5591
|
-
`)
|
|
5678
|
+
process.stderr.write(
|
|
5679
|
+
` onto: ${MCP_TOOLS.filter((t) => t.name.startsWith("onto_")).length} \u4E2A\u5DE5\u5177
|
|
5680
|
+
`
|
|
5681
|
+
);
|
|
5682
|
+
process.stderr.write(
|
|
5683
|
+
` flow: ${MCP_TOOLS.filter((t) => t.name.startsWith("flow_")).length} \u4E2A\u5DE5\u5177
|
|
5684
|
+
`
|
|
5685
|
+
);
|
|
5686
|
+
process.stderr.write(
|
|
5687
|
+
` data: ${MCP_TOOLS.filter((t) => t.name.startsWith("data_")).length} \u4E2A\u5DE5\u5177
|
|
5688
|
+
`
|
|
5689
|
+
);
|
|
5592
5690
|
let buffer = "";
|
|
5593
5691
|
process.stdin.setEncoding("utf-8");
|
|
5594
5692
|
process.stdin.on("data", (chunk) => {
|
|
@@ -5615,7 +5713,8 @@ function makeMcpCommand() {
|
|
|
5615
5713
|
let tools = MCP_TOOLS;
|
|
5616
5714
|
if (opts.category) {
|
|
5617
5715
|
tools = tools.filter((t) => {
|
|
5618
|
-
if (opts.category === "docs")
|
|
5716
|
+
if (opts.category === "docs")
|
|
5717
|
+
return t.name.startsWith("list_docs") || t.name.startsWith("get_doc") || t.name.startsWith("list_prompts") || t.name.startsWith("get_prompt");
|
|
5619
5718
|
return t.name.startsWith(`${opts.category}_`);
|
|
5620
5719
|
});
|
|
5621
5720
|
}
|
|
@@ -5644,14 +5743,16 @@ function forwardToCli(cliName, extraArgs) {
|
|
|
5644
5743
|
const bundled = resolveBundledCli(cliName);
|
|
5645
5744
|
let result;
|
|
5646
5745
|
if (bundled) {
|
|
5647
|
-
result = (0, import_child_process2.spawnSync)(process.execPath, [bundled, ...extraArgs], {
|
|
5746
|
+
result = (0, import_child_process2.spawnSync)(process.execPath, [bundled, ...extraArgs], {
|
|
5747
|
+
stdio: "inherit"
|
|
5748
|
+
});
|
|
5648
5749
|
} else {
|
|
5649
5750
|
result = (0, import_child_process2.spawnSync)(cliName, extraArgs, { stdio: "inherit", shell: true });
|
|
5650
5751
|
}
|
|
5651
5752
|
process.exit(result.status ?? 1);
|
|
5652
5753
|
}
|
|
5653
5754
|
var program2 = new Command();
|
|
5654
|
-
program2.name("dazi").description("\u642D\u5B50 v3 \u2014 Onto / Flow / App \u7EDF\u4E00 CLI").version("3.0.
|
|
5755
|
+
program2.name("dazi").description("\u642D\u5B50 v3 \u2014 Onto / Flow / App \u7EDF\u4E00 CLI").version("3.0.2", "-v, --version");
|
|
5655
5756
|
program2.addCommand(makeAuthCommand());
|
|
5656
5757
|
program2.addCommand(makeDoctorCommand());
|
|
5657
5758
|
program2.addCommand(makeEnvCommand());
|
|
@@ -53,12 +53,12 @@ dazi flow project repair-meta --dir .
|
|
|
53
53
|
dazi flow project push --dir . --canvas
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
| 现象
|
|
57
|
-
|
|
58
|
-
| 设计器「打开代码」失败
|
|
59
|
-
| 改了 `managed_file_id` 平台没有
|
|
60
|
-
| `node push` 无效果
|
|
61
|
-
| 本地 flow.json 对、快速启动写 2 节点 | pull 后手改画布未同步 meta
|
|
56
|
+
| 现象 | 原因 | 处理 |
|
|
57
|
+
| ------------------------------------ | ------------------------------------- | --------------- |
|
|
58
|
+
| 设计器「打开代码」失败 | `flow.meta.json` 无该 uuid 的 `dir` | `repair-meta` |
|
|
59
|
+
| 改了 `managed_file_id` 平台没有 | 只用了 `project push` 未加 `--canvas` | `push --canvas` |
|
|
60
|
+
| `node push` 无效果 | meta 未索引该节点 | `repair-meta` |
|
|
61
|
+
| 本地 flow.json 对、快速启动写 2 节点 | pull 后手改画布未同步 meta | `repair-meta` |
|
|
62
62
|
|
|
63
63
|
详见 [流程本地文件规范](../flow/local-files-spec.md)、[一致性检查表](./flow-consistency-checklist.md)。
|
|
64
64
|
|
|
@@ -83,7 +83,7 @@ dazi doctor --workspace-root D:\path\to\dazi-work
|
|
|
83
83
|
检查 `.cursor/mcp.json` 配置。MCP 需能调用 bundled CLI,示例:
|
|
84
84
|
|
|
85
85
|
```powershell
|
|
86
|
-
$env:DAZI_BUNDLED_DIR = "$env:USERPROFILE\.cursor\extensions\dazitech.dazi-vscode-3.0.
|
|
86
|
+
$env:DAZI_BUNDLED_DIR = "$env:USERPROFILE\.cursor\extensions\dazitech.dazi-vscode-3.0.2\bundled\clis"
|
|
87
87
|
node "$env:DAZI_BUNDLED_DIR\dazi.js" mcp stdio
|
|
88
88
|
```
|
|
89
89
|
|
package/dist/docs/index.json
CHANGED
package/dist/examples/index.json
CHANGED
package/dist/prompts/index.json
CHANGED
|
@@ -1,21 +1,99 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.0.
|
|
2
|
+
"version": "3.0.2",
|
|
3
3
|
"updatedAt": "2026-05-26T00:00:00.000Z",
|
|
4
4
|
"prompts": [
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
{
|
|
6
|
+
"id": "onto/script-publish-run",
|
|
7
|
+
"title": "本体脚本发布与运行(TRAE/智能体)",
|
|
8
|
+
"category": "onto",
|
|
9
|
+
"file": "onto/script-publish-run.md"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "onto/function-design",
|
|
13
|
+
"title": "本体函数设计",
|
|
14
|
+
"category": "onto",
|
|
15
|
+
"file": "onto/function-design.md"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "onto/action-design",
|
|
19
|
+
"title": "本体动作(Action)设计",
|
|
20
|
+
"category": "onto",
|
|
21
|
+
"file": "onto/action-design.md"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "onto/rule-seed",
|
|
25
|
+
"title": "规则种子脚本",
|
|
26
|
+
"category": "onto",
|
|
27
|
+
"file": "onto/rule-seed.md"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "flow/flow-design",
|
|
31
|
+
"title": "Flow 设计",
|
|
32
|
+
"category": "flow",
|
|
33
|
+
"file": "flow/flow-design.md",
|
|
34
|
+
"featured": true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "flow/ai-workflow-playbook",
|
|
38
|
+
"title": "流程 AI 工作手册",
|
|
39
|
+
"category": "flow",
|
|
40
|
+
"file": "flow/ai-workflow-playbook.md",
|
|
41
|
+
"featured": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "flow/run-debug",
|
|
45
|
+
"title": "Run 调试分析",
|
|
46
|
+
"category": "flow",
|
|
47
|
+
"file": "flow/run-debug.md"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "flow/run-fix-loop",
|
|
51
|
+
"title": "Flow 自主运行改错",
|
|
52
|
+
"category": "flow",
|
|
53
|
+
"file": "flow/run-fix-loop.md",
|
|
54
|
+
"featured": true
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "flow/plan-generate",
|
|
58
|
+
"title": "执行计划生成",
|
|
59
|
+
"category": "flow",
|
|
60
|
+
"file": "flow/plan-generate.md"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"id": "app/ui-design",
|
|
64
|
+
"title": "搭子 App UI 设计",
|
|
65
|
+
"category": "app",
|
|
66
|
+
"file": "app/ui-design.md"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "data/data-analysis",
|
|
70
|
+
"title": "数据分析",
|
|
71
|
+
"category": "data",
|
|
72
|
+
"file": "data/data-analysis.md"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "data/sql-query",
|
|
76
|
+
"title": "SQL 查询生成",
|
|
77
|
+
"category": "data",
|
|
78
|
+
"file": "data/sql-query.md"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"id": "general/ask-dazi",
|
|
82
|
+
"title": "询问搭子平台",
|
|
83
|
+
"category": "general",
|
|
84
|
+
"file": "general/ask-dazi.md"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "general/troubleshoot",
|
|
88
|
+
"title": "问题排查",
|
|
89
|
+
"category": "general",
|
|
90
|
+
"file": "general/troubleshoot.md"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "general/code-review",
|
|
94
|
+
"title": "搭子脚本代码审查",
|
|
95
|
+
"category": "general",
|
|
96
|
+
"file": "general/code-review.md"
|
|
97
|
+
}
|
|
20
98
|
]
|
|
21
99
|
}
|