@hcmai/cli 0.3.14 → 0.3.15

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/dist/index.js CHANGED
@@ -7656,17 +7656,25 @@ async function resolveCoreAction(request) {
7656
7656
  profile: request.profile
7657
7657
  });
7658
7658
  const description = await HcmClient17.fromAuthContext(auth).describe(request.model);
7659
- const matches = description.actions.filter((action2) => matchesRequest(action2, request));
7660
- if (matches.length === 0) {
7659
+ const named = description.actions.filter((action2) => action2.name === request.action);
7660
+ if (named.length === 0) {
7661
7661
  return failed(
7662
7662
  "action-metadata-not-found",
7663
- "Core \u5143\u6570\u636E\u4E2D\u6CA1\u6709\u4E0E\u672C\u6B21 method/scope \u7CBE\u786E\u5339\u914D\u7684 Action\uFF0C\u62D2\u7EDD\u6267\u884C\u3002"
7663
+ `Core \u5143\u6570\u636E\u91CC\u6CA1\u6709 ${request.model}.${request.action} \u8FD9\u4E2A Action\u3002next_step=\u7528 \`hcm describe ${request.model}\` \u6838\u5BF9 Action \u540D`
7664
+ );
7665
+ }
7666
+ const matches = request.explicitShape ? named.filter((action2) => matchesRequest(action2, request)) : named;
7667
+ if (matches.length === 0) {
7668
+ const shapes = named.map((a) => `scope=${a.scope ?? "?"} method=${(a.httpMethod ?? "?").toUpperCase()}`).join("\uFF1B");
7669
+ return failed(
7670
+ "action-shape-mismatch",
7671
+ `${request.model}.${request.action} \u5B58\u5728\uFF0C\u4F46\u5F62\u6001\u5BF9\u4E0D\u4E0A\uFF1A\u4F60\u7ED9\u7684\u662F scope=${request.scope} method=${request.httpMethod}\uFF0C\u5143\u6570\u636E\u91CC\u662F ${shapes}\u3002next_step=\u53BB\u6389 --scope/--method \u8BA9 CLI \u6309\u5143\u6570\u636E\u81EA\u52A8\u5224\u5B9A\uFF0C\u6216\u6539\u6210\u4E0A\u9762\u7684\u5F62\u6001`
7664
7672
  );
7665
7673
  }
7666
7674
  if (matches.length > 1) {
7667
7675
  return failed(
7668
7676
  "action-metadata-ambiguous",
7669
- "Core \u5143\u6570\u636E\u5B58\u5728\u591A\u4E2A\u4E0E\u672C\u6B21 method/scope \u5339\u914D\u7684 Action\uFF0C\u65E0\u6CD5\u552F\u4E00\u5224\u5B9A\uFF0C\u62D2\u7EDD\u6267\u884C\u3002"
7677
+ `${request.model}.${request.action} \u5728\u5143\u6570\u636E\u91CC\u6709\u591A\u79CD\u5F62\u6001\uFF0C\u65E0\u6CD5\u552F\u4E00\u5224\u5B9A\u3002next_step=\u7528 --scope \u4E0E --method \u6307\u660E\u8981\u8C03\u54EA\u4E00\u4E2A`
7670
7678
  );
7671
7679
  }
7672
7680
  const action = matches[0];
@@ -7679,8 +7687,8 @@ async function resolveCoreAction(request) {
7679
7687
  return {
7680
7688
  status: "resolved",
7681
7689
  policy: {
7682
- scope: action.scope,
7683
- httpMethod: action.httpMethod.toUpperCase(),
7690
+ scope: action.scope ?? request.scope,
7691
+ httpMethod: (action.httpMethod ?? request.httpMethod).toUpperCase(),
7684
7692
  readOnly: action.readOnly,
7685
7693
  ...action.source ? { source: action.source } : {}
7686
7694
  }
@@ -7702,7 +7710,8 @@ function parseActionRequest(inputArgv) {
7702
7710
  if (separator <= 0 || separator === spec.length - 1) {
7703
7711
  return failed("invalid-action-spec", "Action \u5FC5\u987B\u4F7F\u7528 <Model>.<Action> \u683C\u5F0F\u3002");
7704
7712
  }
7705
- const httpMethod = (flagValue2(argv, "--method") ?? "POST").toUpperCase();
7713
+ const explicitMethod = flagValue2(argv, "--method");
7714
+ const httpMethod = (explicitMethod ?? "POST").toUpperCase();
7706
7715
  if (!["GET", "POST", "PUT", "DELETE"].includes(httpMethod)) {
7707
7716
  return failed("invalid-action-method", "Action method \u5FC5\u987B\u662F GET\u3001POST\u3001PUT \u6216 DELETE\u3002");
7708
7717
  }
@@ -7716,6 +7725,7 @@ function parseActionRequest(inputArgv) {
7716
7725
  action: spec.slice(separator + 1),
7717
7726
  httpMethod,
7718
7727
  scope,
7728
+ ...explicitMethod !== void 0 || explicitScope !== void 0 ? { explicitShape: true } : {},
7719
7729
  env: flagValue2(argv, "--env"),
7720
7730
  identity: flagValue2(argv, "--as"),
7721
7731
  profile: flagValue2(argv, "--profile")