@siming-org/cli 0.7.0 → 0.7.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.
Files changed (2) hide show
  1. package/dist/index.js +97 -67
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1293,6 +1293,60 @@ async function handleConvertIssues(client, input) {
1293
1293
  });
1294
1294
  }
1295
1295
 
1296
+ // src/client/handlers/project.ts
1297
+ async function handleListProjects(client, status) {
1298
+ return client.getJson(`/api/projects${status ? `?status=${encodeURIComponent(status)}` : ""}`);
1299
+ }
1300
+ async function handleGetProject(client, id) {
1301
+ return client.getJson(`/api/projects/${encodeURIComponent(id)}`);
1302
+ }
1303
+ async function handleCreateProject(client, input) {
1304
+ return client.postJson("/api/projects", input);
1305
+ }
1306
+ async function handleUpdateProject(client, id, patch) {
1307
+ return client.putJson(`/api/projects/${encodeURIComponent(id)}`, patch);
1308
+ }
1309
+ var OBJECT_ID_HEX = /^[a-f0-9]{24}$/;
1310
+ async function resolveProjectId(client, input) {
1311
+ if (OBJECT_ID_HEX.test(input)) return { success: true, data: input };
1312
+ const list = await handleListProjects(client);
1313
+ if (!list.success) return list;
1314
+ const hit = list.data.find((p) => p.key === input);
1315
+ if (!hit) {
1316
+ const error = {
1317
+ message: `project "${input}" not found`,
1318
+ httpStatus: 404,
1319
+ bizCode: "PROJECT_NOT_FOUND",
1320
+ hint: `check \`siming project list\` for available keys; pass --project <key|id>`
1321
+ };
1322
+ return fail(error);
1323
+ }
1324
+ if (!hit.id) {
1325
+ const error = {
1326
+ message: `project "${input}" has no id`,
1327
+ httpStatus: 500,
1328
+ hint: `server returned a project without id; check \`siming project list\``
1329
+ };
1330
+ return fail(error);
1331
+ }
1332
+ return { success: true, data: hit.id };
1333
+ }
1334
+ async function resolveProjectKey(client, input) {
1335
+ const list = await handleListProjects(client);
1336
+ if (!list.success) return list;
1337
+ const hit = list.data.find((p) => p.key === input || p.id === input);
1338
+ if (!hit) {
1339
+ const error = {
1340
+ message: `project "${input}" not found`,
1341
+ httpStatus: 404,
1342
+ bizCode: "PROJECT_NOT_FOUND",
1343
+ hint: `check \`siming project list\` for available keys; pass --project <key|id>`
1344
+ };
1345
+ return fail(error);
1346
+ }
1347
+ return { success: true, data: hit.key };
1348
+ }
1349
+
1296
1350
  // src/mcp/tools.ts
1297
1351
  import { z as z3 } from "zod";
1298
1352
  import { TASK_TYPES, ARTIFACT_TYPES as ARTIFACT_TYPES2 } from "@siming-org/core";
@@ -1907,7 +1961,7 @@ function createMcpServer() {
1907
1961
  );
1908
1962
  server.tool(
1909
1963
  "siming_issue",
1910
- `\u95EE\u9898\u6C60\u5DE5\u5177\uFF08T202609150002\uFF09\uFF1A\u5C0F\u95EE\u9898\u4F4E\u6210\u672C\u5165\u6C60\uFF0C\u6C89\u6DC0\u540E\u7EDF\u4E00\u6574\u7406\u8F6C\u4EFB\u52A1\uFF08\u8F6C\u4EFB\u52A1/\u6574\u7406\u91CD\u4EA4\u4E92\u8D70 CLI siming issue convert \u6216 Web\uFF0C\u4E0D\u5728\u672C\u5DE5\u5177\u9762\uFF09\u3002action\uFF1Acreate(title \u5FC5\u586B 1-200 \u5B57\uFF1B\u53EF\u9009 description\u3001projectId\u2014\u2014\u7F3A\u7701\u6309\u5DE5\u4F5C\u533A defaultProject\uFF0C\u65E0\u914D\u7F6E\u65F6\u6309 key=default\uFF1B\u5F55\u5165\u540E source=mcp)\uFF1Bquery(\u53EF\u9009 view=open|all\u2014\u2014\u7F3A\u7701 open=\u6709\u6548\u672A\u8DDF\u8FDB\u5B8C\uFF0Call=\u5168\u91CF\uFF1Bstatus \u8FC7\u6EE4\u2014\u2014\u663E\u5F0F\u6307\u5B9A\u65F6\u4F18\u5148\u4E8E view\uFF0C\u53EF\u67E5\u5DF2\u53D6\u6D88/\u5DF2\u5B8C\u7ED3\uFF1BtaskId=\u4EFB\u52A1\u53CD\u67E5\uFF1BprojectId/page\u22651/limit 1-500\uFF1B\u54CD\u5E94 items \u542B progress {done,cancelled,total})\u3002\u8C03\u7528\u65B9\u5E94\u5728 fieldMask \u4E2D\u5217\u51FA\u672C\u6B21\u771F\u5B9E\u63D0\u4F9B\u7684\u53EF\u9009\u5B57\u6BB5\uFF0Cmask \u5916\u7531\u5BBF\u4E3B\u81EA\u52A8\u586B\u5145\u7684\u7A7A\u4E32\u3001\u7A7A\u6570\u7EC4\u3001false\u30010 \u5747\u5FFD\u7565\uFF1B\u5404 action \u56FA\u5B9A\u5FC5\u586B\u5B57\u6BB5\u65E0\u9700\u5199\u5165 mask\u3002`,
1964
+ `\u95EE\u9898\u6C60\u5DE5\u5177\uFF08T202609150002\uFF09\uFF1A\u5C0F\u95EE\u9898\u4F4E\u6210\u672C\u5165\u6C60\uFF0C\u6C89\u6DC0\u540E\u7EDF\u4E00\u6574\u7406\u8F6C\u4EFB\u52A1\uFF08\u8F6C\u4EFB\u52A1/\u6574\u7406\u91CD\u4EA4\u4E92\u8D70 CLI siming issue convert \u6216 Web\uFF0C\u4E0D\u5728\u672C\u5DE5\u5177\u9762\uFF09\u3002action\uFF1Acreate(title \u5FC5\u586B 1-200 \u5B57\uFF1B\u53EF\u9009 description\u3001projectId\u2014\u2014key|id \u53CC\u5F62\u6001\uFF0C\u901A\u9053\u5C42\u81EA\u52A8\u5F52\u4E00\u4E3A 24-hex id\uFF08hex \u96F6\u7F51\u7EDC\u5F00\u9500\u76F4\u901A\uFF09\uFF1B\u663E\u5F0F\u6307\u5B9A\u89E3\u6790\u5931\u8D25\u62A5\u9519\u4E0D\u515C\u5E95\uFF1B\u7F3A\u7701\u94FE\uFF1A\u672A\u4F20\u6216\u7A7A\u4E32\u65F6\u6309\u5DE5\u4F5C\u533A defaultProject \u89E3\u6790\uFF0C\u65E0\u914D\u7F6E\u6216\u89E3\u6790\u5931\u8D25\u65F6\u6309 key=default\uFF1B\u5F55\u5165\u540E source=mcp)\uFF1Bquery(\u53EF\u9009 view=open|all\u2014\u2014\u7F3A\u7701 open=\u6709\u6548\u672A\u8DDF\u8FDB\u5B8C\uFF0Call=\u5168\u91CF\uFF1Bstatus \u8FC7\u6EE4\u2014\u2014\u663E\u5F0F\u6307\u5B9A\u65F6\u4F18\u5148\u4E8E view\uFF0C\u53EF\u67E5\u5DF2\u53D6\u6D88/\u5DF2\u5B8C\u7ED3\uFF1BtaskId=\u4EFB\u52A1\u53CD\u67E5\uFF1BprojectId/page\u22651/limit 1-500\uFF1B\u54CD\u5E94 items \u542B progress {done,cancelled,total})\u3002\u8C03\u7528\u65B9\u5E94\u5728 fieldMask \u4E2D\u5217\u51FA\u672C\u6B21\u771F\u5B9E\u63D0\u4F9B\u7684\u53EF\u9009\u5B57\u6BB5\uFF0Cmask \u5916\u7531\u5BBF\u4E3B\u81EA\u52A8\u586B\u5145\u7684\u7A7A\u4E32\u3001\u7A7A\u6570\u7EC4\u3001false\u30010 \u5747\u5FFD\u7565\uFF1B\u5404 action \u56FA\u5B9A\u5FC5\u586B\u5B57\u6BB5\u65E0\u9700\u5199\u5165 mask\u3002`,
1911
1965
  issueArgs,
1912
1966
  async (rawArgs) => {
1913
1967
  const masked = applyFieldMask(rawArgs, ISSUE_FIELD_SPECS);
@@ -1920,11 +1974,25 @@ function createMcpServer() {
1920
1974
  return requireError("create", ["title"], args);
1921
1975
  }
1922
1976
  let projectId;
1923
- if (args.projectId !== void 0) {
1924
- projectId = args.projectId;
1977
+ const explicitProject = args.projectId !== void 0 && args.projectId.trim().length > 0 ? args.projectId : void 0;
1978
+ if (explicitProject !== void 0) {
1979
+ const resolved = await resolveProjectId(client, explicitProject);
1980
+ if (!resolved.success) {
1981
+ return mcpContent({
1982
+ ...resolved,
1983
+ error: {
1984
+ ...resolved.error,
1985
+ hint: "MCP \u8C03\u7528\u8BF7\u4F20 projectId \u5B57\u6BB5\uFF08\u9879\u76EE key \u6216 24-hex id \u53CC\u5F62\u6001\uFF0C\u81EA\u52A8\u5F52\u4E00\uFF09\uFF1B\u53EF\u7528 `siming project list` \u67E5\u8BE2\u53EF\u7528\u9879\u76EE"
1986
+ }
1987
+ });
1988
+ }
1989
+ projectId = resolved.data;
1925
1990
  } else {
1926
1991
  const wsDefaultProject = readWorkspaceConfig()?.defaultProject;
1927
- if (wsDefaultProject) projectId = wsDefaultProject;
1992
+ if (wsDefaultProject) {
1993
+ const resolved = await resolveProjectId(client, wsDefaultProject);
1994
+ if (resolved.success) projectId = resolved.data;
1995
+ }
1928
1996
  }
1929
1997
  return mcpContent(
1930
1998
  await handleCreateIssue(client, {
@@ -1989,60 +2057,6 @@ import {
1989
2057
  ContextViewSchema
1990
2058
  } from "@siming-org/core";
1991
2059
 
1992
- // src/client/handlers/project.ts
1993
- async function handleListProjects(client, status) {
1994
- return client.getJson(`/api/projects${status ? `?status=${encodeURIComponent(status)}` : ""}`);
1995
- }
1996
- async function handleGetProject(client, id) {
1997
- return client.getJson(`/api/projects/${encodeURIComponent(id)}`);
1998
- }
1999
- async function handleCreateProject(client, input) {
2000
- return client.postJson("/api/projects", input);
2001
- }
2002
- async function handleUpdateProject(client, id, patch) {
2003
- return client.putJson(`/api/projects/${encodeURIComponent(id)}`, patch);
2004
- }
2005
- var OBJECT_ID_HEX = /^[a-f0-9]{24}$/;
2006
- async function resolveProjectId(client, input) {
2007
- if (OBJECT_ID_HEX.test(input)) return { success: true, data: input };
2008
- const list = await handleListProjects(client);
2009
- if (!list.success) return list;
2010
- const hit = list.data.find((p) => p.key === input);
2011
- if (!hit) {
2012
- const error = {
2013
- message: `project "${input}" not found`,
2014
- httpStatus: 404,
2015
- bizCode: "PROJECT_NOT_FOUND",
2016
- hint: `check \`siming project list\` for available keys; pass --project <key|id>`
2017
- };
2018
- return fail(error);
2019
- }
2020
- if (!hit.id) {
2021
- const error = {
2022
- message: `project "${input}" has no id`,
2023
- httpStatus: 500,
2024
- hint: `server returned a project without id; check \`siming project list\``
2025
- };
2026
- return fail(error);
2027
- }
2028
- return { success: true, data: hit.id };
2029
- }
2030
- async function resolveProjectKey(client, input) {
2031
- const list = await handleListProjects(client);
2032
- if (!list.success) return list;
2033
- const hit = list.data.find((p) => p.key === input || p.id === input);
2034
- if (!hit) {
2035
- const error = {
2036
- message: `project "${input}" not found`,
2037
- httpStatus: 404,
2038
- bizCode: "PROJECT_NOT_FOUND",
2039
- hint: `check \`siming project list\` for available keys; pass --project <key|id>`
2040
- };
2041
- return fail(error);
2042
- }
2043
- return { success: true, data: hit.key };
2044
- }
2045
-
2046
2060
  // src/output/json.ts
2047
2061
  function renderJson(value) {
2048
2062
  console.log(JSON.stringify(value, null, 2));
@@ -3668,9 +3682,26 @@ import { Command as Command5 } from "commander";
3668
3682
  function createDagCommand() {
3669
3683
  const dag = new Command5("dag").description("DAG template & instance management");
3670
3684
  const tpl = dag.command("template").description("DAG template management");
3671
- withCommonOpts(tpl.command("list"), "table").option("--project <id>", "filter by projectId").description("List DAG templates (summary projection: node labels only, no prompts \u2014 use `show` for full detail)").action(async (opts) => {
3685
+ withCommonOpts(tpl.command("list"), "table").option("--project <key|id>", "filter by project (key or id; defaults to workspace defaultProject)").description("List DAG templates (summary projection: node labels only, no prompts \u2014 use `show` for full detail)").action(async (opts) => {
3672
3686
  const client = createClient(opts.url);
3673
- const result = await handleListTemplates(client, opts.project);
3687
+ const projectOpt = opts.project ?? readWorkspaceConfig()?.defaultProject;
3688
+ let projectId;
3689
+ if (projectOpt !== void 0) {
3690
+ const r = await resolveProjectId(client, projectOpt);
3691
+ if (!r.success) {
3692
+ if (opts.project === void 0) {
3693
+ renderResult(opts.format, fail({
3694
+ ...r.error,
3695
+ hint: `workspace defaultProject "${projectOpt}" \u89E3\u6790\u5931\u8D25\u2014\u2014siming config unset defaultProject \u540E\u91CD\u8BD5\uFF0C\u6216\u663E\u5F0F --project <key|id>`
3696
+ }));
3697
+ } else {
3698
+ renderResult(opts.format, r);
3699
+ }
3700
+ return;
3701
+ }
3702
+ projectId = r.data;
3703
+ }
3704
+ const result = await handleListTemplates(client, projectId);
3674
3705
  if (!result.success) {
3675
3706
  renderResult(opts.format, result);
3676
3707
  return;
@@ -4761,7 +4792,7 @@ function createFlowCommand() {
4761
4792
  });
4762
4793
  flow.command("install <pkg-spec>").description(
4763
4794
  "Install a node library package from npm \u2014 validate 1.1 manifest \u2192 plan complete assets \u2192 confirm \u2192 apply dependencies \u2192 nodes \u2192 library"
4764
- ).option("--url <url>", "server base URL").option("--scope <scope>", "install scope: global|project", "global").option("--project <key|id>", "target project (required when scope=project)").option("--registry <url>", "npm registry for pack (e.g. private mirror; default npm config)").option("--yes", "skip interactive confirmation").option("--force", "allow version downgrade; admin may also replace a conflicting model alias").action(async (pkgSpec, opts) => {
4795
+ ).option("--url <url>", "server base URL").option("--scope <scope>", "install scope: global|project", "global").option("--project <key|id>", "target project (required when scope=project)").option("--registry <url>", "npm registry for pack (e.g. private mirror; default npm config)").option("--yes", "skip interactive confirmation").option("--force", "allow version downgrade; admin may also sync a conflicting model alias display name (realModel is never overwritten)").action(async (pkgSpec, opts) => {
4765
4796
  const scopeResult = parseEnum(opts.scope, SkillScopeSchema3, "scope");
4766
4797
  if (!scopeResult.success) {
4767
4798
  renderResult("json", scopeResult);
@@ -4803,7 +4834,7 @@ function createFlowCommand() {
4803
4834
  ${conflicts.map((item) => ` ${item.kind}:${item.key} \u2014 ${item.reason ?? "\u5185\u5BB9\u51B2\u7A81"}`).join("\n")}`,
4804
4835
  httpStatus: 0,
4805
4836
  bizCode: conflicts.some((item) => item.conflictKind === "model-alias") ? "FLOW_MODEL_ALIAS_CONFLICT" : "FLOW_ASSET_SCOPE_CONFLICT",
4806
- hint: "\u6309\u6761\u76EE\u4FEE\u590D\u76EE\u6807\u73AF\u5883\u6216\u5305\u5185\u5BB9\u540E\u91CD\u65B0\u6267\u884C\uFF1B--force \u53EA\u653E\u884C\u7248\u672C\u964D\u7EA7\u53CA admin \u7684 Model Alias \u8986\u76D6"
4837
+ hint: "\u6309\u6761\u76EE\u4FEE\u590D\u76EE\u6807\u73AF\u5883\u6216\u5305\u5185\u5BB9\u540E\u91CD\u65B0\u6267\u884C\uFF1B--force \u53EA\u653E\u884C\u7248\u672C\u964D\u7EA7\u53CA admin \u5BF9 Model Alias \u5C55\u793A\u540D\u7684\u540C\u6B65\uFF08realModel \u6C38\u4E0D\u8986\u76D6\uFF09"
4807
4838
  }));
4808
4839
  return;
4809
4840
  }
@@ -5071,14 +5102,14 @@ function planModelAlias(payload, existing, access, force) {
5071
5102
  ...base,
5072
5103
  action: "conflict",
5073
5104
  conflictKind: "model-alias",
5074
- reason: `Model Alias \u5185\u5BB9\u4E0D\u540C\uFF08${diffs.join(", ")}\uFF09\uFF1B\u4EC5 admin \u663E\u5F0F --force \u53EF\u8986\u76D6`,
5105
+ reason: `Model Alias \u5C55\u793A\u540D\u4E0D\u540C\uFF08${diffs.join(", ")}\uFF09\uFF1B\u4EC5 admin \u663E\u5F0F --force \u53EF\u540C\u6B65\u5C55\u793A\u540D\uFF08realModel \u6C38\u4E0D\u8986\u76D6\uFF09`,
5075
5106
  expectedState: snapshotModelAlias(existing)
5076
5107
  };
5077
5108
  }
5078
5109
  return {
5079
5110
  ...base,
5080
5111
  action: "update",
5081
- reason: `admin --force \u8986\u76D6\u5DEE\u5F02\u5B57\u6BB5\uFF1A${diffs.join(", ")}`,
5112
+ reason: `admin --force \u540C\u6B65\u5C55\u793A\u540D\uFF1A${diffs.join(", ")}\uFF08realModel \u4E0D\u5199\u5165\uFF09`,
5082
5113
  expectedState: snapshotModelAlias(existing)
5083
5114
  };
5084
5115
  }
@@ -5286,7 +5317,6 @@ function diffAgent(payload, entity) {
5286
5317
  function diffModelAlias(payload, entity) {
5287
5318
  const diffs = [];
5288
5319
  if (entity.name !== payload.name) diffs.push("name");
5289
- if (entity.realModel !== payload.realModel) diffs.push("realModel");
5290
5320
  return diffs;
5291
5321
  }
5292
5322
  function diffNode(payload, entity, packageName) {
@@ -5340,7 +5370,7 @@ function snapshotAgent(entity) {
5340
5370
  };
5341
5371
  }
5342
5372
  function snapshotModelAlias(entity) {
5343
- return { code: entity.code, name: entity.name, realModel: entity.realModel };
5373
+ return { code: entity.code, name: entity.name };
5344
5374
  }
5345
5375
  function snapshotNode(entity) {
5346
5376
  return {
@@ -5503,7 +5533,7 @@ async function writeAsset(client, manifest, plan, item) {
5503
5533
  const input = { code: payload2.code, name: payload2.name, realModel: payload2.realModel };
5504
5534
  return client.postJson("/api/model-aliases", input);
5505
5535
  }
5506
- const patch2 = { name: payload2.name, realModel: payload2.realModel };
5536
+ const patch2 = { name: payload2.name };
5507
5537
  return client.putJson(`/api/model-aliases/${encodeURIComponent(payload2.code)}`, patch2);
5508
5538
  }
5509
5539
  if (item.kind === "skill") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siming-org/cli",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "license": "MIT",
5
5
  "author": "Wuchao",
6
6
  "engines": {
@@ -27,8 +27,8 @@
27
27
  "picocolors": "^1.1.1",
28
28
  "yaml": "^2.6.0",
29
29
  "zod": "^4.4.3",
30
- "@siming-org/core": "0.7.0",
31
- "@siming-org/server": "0.7.0"
30
+ "@siming-org/core": "0.7.2",
31
+ "@siming-org/server": "0.7.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "tsup": "^8.3.5",