@lark-apaas/fullstack-cli 1.1.71-alpha.20261104100603 → 1.1.71-alpha.20261104114555

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +279 -145
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -121,7 +121,7 @@ fullstack-cli action-plugin form-action-execute --plugin @office/feishu-bitable
121
121
 
122
122
  JSON 类参数(`--input`、`--form-value`、`--params-schema`)都接受三种写法:JSON 字面量、`@<文件路径>`、`-`(从 stdin 读,一条命令里只能有一个参数这么用)。
123
123
 
124
- 执行需要平台按次注入的操作人凭证 `MIAODA_AUTHN_CODE`(authn code,经管理端 innerapi 的 `X-Miaoda-Client-Token` 由网关解析身份),缺失报 `CONTEXT_UNAVAILABLE`;AK/SK、域名、`app_id` 用沙箱已有环境变量。失败时 stdout 输出 `{ok:false, code, message, details?}` 并退出码 1;执行层错误码:`PLUGIN_NOT_INSTALLED` / `PLUGIN_SDK_TOO_OLD` / `PLUGIN_VERSION_MISMATCH` / `PLUGIN_LOAD_FAILED` / `FORM_ACTION_NOT_FOUND` / `INSTANCE_MISMATCH` / `CONTEXT_UNAVAILABLE` / `EXECUTION_TIMEOUT` / `INVALID_INPUT`;插件抛 `PluginError` 时 `code` 原样透传。详见 [docs/commands/action-plugin.md](docs/commands/action-plugin.md)。
124
+ 执行需要平台按次注入的操作人凭证 `MIAODA_AUTHN_CODE`(authn code,经管理端 innerapi 的 `X-Miaoda-Client-Token` 由网关解析身份),缺失报 `CONTEXT_UNAVAILABLE`;AK/SK、域名、`app_id` 用沙箱已有环境变量。失败时 stdout 输出 `{ok:false, code, message, hint?, details?}` 并退出码 1,`hint` 给出下一步怎么做;执行层错误码:`PLUGIN_NOT_INSTALLED` / `PLUGIN_SDK_TOO_OLD` / `PLUGIN_VERSION_MISMATCH` / `PLUGIN_LOAD_FAILED` / `FORM_ACTION_NOT_FOUND` / `INSTANCE_NOT_FOUND` / `INSTANCE_MISMATCH` / `CONTEXT_UNAVAILABLE` / `EXECUTION_TIMEOUT` / `INVALID_INPUT`;插件抛 `PluginError` 时 `code` 原样透传。详见 [docs/commands/action-plugin.md](docs/commands/action-plugin.md)。
125
125
 
126
126
  **命令别名:**
127
127
  | 完整命令 | 别名 |
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import fs33 from "fs";
2
+ import fs34 from "fs";
3
3
  import path27 from "path";
4
4
  import { fileURLToPath as fileURLToPath5 } from "url";
5
5
  import { config as dotenvConfig } from "dotenv";
@@ -4816,6 +4816,9 @@ function logError(message) {
4816
4816
  console.error(`[capability] Error: ${message}`);
4817
4817
  }
4818
4818
 
4819
+ // src/commands/action-plugin/form-context.ts
4820
+ import fs19 from "fs";
4821
+
4819
4822
  // src/commands/action-plugin/form-errors.ts
4820
4823
  import fs18 from "fs";
4821
4824
  var FormCliErrorCode = {
@@ -4828,7 +4831,7 @@ var FormCliErrorCode = {
4828
4831
  INSTANCE_MISMATCH: "INSTANCE_MISMATCH",
4829
4832
  /** capability create:目标 id 已存在,不覆盖 */
4830
4833
  INSTANCE_EXISTS: "INSTANCE_EXISTS",
4831
- /** capability update:目标 id 不存在 */
4834
+ /** capability update / --id:目标实例不存在 */
4832
4835
  INSTANCE_NOT_FOUND: "INSTANCE_NOT_FOUND",
4833
4836
  CONTEXT_UNAVAILABLE: "CONTEXT_UNAVAILABLE",
4834
4837
  VALIDATION_EXECUTION_FAILED: "VALIDATION_EXECUTION_FAILED",
@@ -4843,6 +4846,7 @@ var FormCliError = class _FormCliError extends Error {
4843
4846
  super(message);
4844
4847
  this.name = "FormCliError";
4845
4848
  this.code = code;
4849
+ this.hint = options.hint;
4846
4850
  this.details = options.details;
4847
4851
  this.issues = options.issues;
4848
4852
  Object.setPrototypeOf(this, _FormCliError.prototype);
@@ -4855,13 +4859,14 @@ function isPluginError(error) {
4855
4859
  const candidate = error;
4856
4860
  return candidate.name === "PluginError" && typeof candidate.code === "string";
4857
4861
  }
4858
- function toFailureOutput(error, fallbackCode) {
4862
+ function toFailureOutput(error, fallbackCode, pluginErrorHint) {
4859
4863
  if (error instanceof FormCliError) {
4860
4864
  const output = {
4861
4865
  ok: false,
4862
4866
  code: error.code,
4863
4867
  message: error.message
4864
4868
  };
4869
+ if (error.hint !== void 0) output.hint = error.hint;
4865
4870
  if (error.details !== void 0) output.details = error.details;
4866
4871
  if (error.issues !== void 0) output.issues = error.issues;
4867
4872
  return output;
@@ -4872,6 +4877,8 @@ function toFailureOutput(error, fallbackCode) {
4872
4877
  code: error.code,
4873
4878
  message: error.message
4874
4879
  };
4880
+ const hint = pluginErrorHint?.(error.code);
4881
+ if (hint !== void 0) output.hint = hint;
4875
4882
  if (error.details !== void 0) output.details = error.details;
4876
4883
  return output;
4877
4884
  }
@@ -4892,6 +4899,7 @@ function withTimeout(promise, timeoutMs, what) {
4892
4899
  FormCliErrorCode.EXECUTION_TIMEOUT,
4893
4900
  `${what} timed out after ${timeoutMs}ms`,
4894
4901
  {
4902
+ hint: `Retry later, or pass a larger --timeout (current: ${timeoutMs} ms).`,
4895
4903
  details: { timeoutMs }
4896
4904
  }
4897
4905
  )
@@ -4995,6 +5003,23 @@ function readJsonObjectArg(raw, flag) {
4995
5003
  }
4996
5004
  return value;
4997
5005
  }
5006
+ function outputParseErrorsAsJson(command) {
5007
+ const target = command;
5008
+ target._outputConfiguration = { ...target._outputConfiguration };
5009
+ return command.configureOutput({
5010
+ outputError: (str) => {
5011
+ const usage = [command.parent?.name(), command.name()].filter(Boolean).join(" ");
5012
+ const output = {
5013
+ ok: false,
5014
+ code: FormCliErrorCode.INVALID_INPUT,
5015
+ message: str.replace(/^error:\s*/, "").trim(),
5016
+ hint: `Run "fullstack-cli ${usage} --help" for usage.`
5017
+ };
5018
+ fs18.writeSync(1, `${JSON.stringify(output, null, 2)}
5019
+ `);
5020
+ }
5021
+ });
5022
+ }
4998
5023
  function camelToKebab(name) {
4999
5024
  return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
5000
5025
  }
@@ -5030,7 +5055,10 @@ function assertOperatorCredential(env = process.env) {
5030
5055
  if (!env[AUTHN_CODE_ENV]) {
5031
5056
  throw new FormCliError(
5032
5057
  FormCliErrorCode.CONTEXT_UNAVAILABLE,
5033
- `operator credential is unavailable: environment variable ${AUTHN_CODE_ENV} is not set`
5058
+ `Operator credential is unavailable: environment variable ${AUTHN_CODE_ENV} is not set`,
5059
+ {
5060
+ hint: `This command calls the platform as the current operator. Run it through the platform's command execution (agent_tool), which injects ${AUTHN_CODE_ENV}; it cannot run in a plain terminal.`
5061
+ }
5034
5062
  );
5035
5063
  }
5036
5064
  }
@@ -5054,12 +5082,21 @@ function createStderrLogger(prefix) {
5054
5082
  };
5055
5083
  }
5056
5084
  function readMatchingCapability(instanceId, pluginKey) {
5085
+ if (!fs19.existsSync(getCapabilityPath(instanceId))) {
5086
+ throw new FormCliError(
5087
+ FormCliErrorCode.INSTANCE_NOT_FOUND,
5088
+ `Capability instance ${instanceId} not found`,
5089
+ {
5090
+ hint: 'Check the id with "fullstack-cli capability list --summary", or omit --id when creating a new instance.'
5091
+ }
5092
+ );
5093
+ }
5057
5094
  let capability;
5058
5095
  try {
5059
5096
  capability = readCapability(instanceId);
5060
5097
  } catch (error) {
5061
5098
  throw new FormCliError(
5062
- FormCliErrorCode.INSTANCE_MISMATCH,
5099
+ FormCliErrorCode.INVALID_INPUT,
5063
5100
  `Capability instance ${instanceId} cannot be read: ${error instanceof Error ? error.message : String(error)}`
5064
5101
  );
5065
5102
  }
@@ -5068,6 +5105,7 @@ function readMatchingCapability(instanceId, pluginKey) {
5068
5105
  FormCliErrorCode.INSTANCE_MISMATCH,
5069
5106
  `Capability instance ${instanceId} belongs to plugin ${capability.pluginKey}, not ${pluginKey}`,
5070
5107
  {
5108
+ hint: `Use --plugin ${capability.pluginKey}, or pick an instance of ${pluginKey}.`,
5071
5109
  details: {
5072
5110
  instancePluginKey: capability.pluginKey,
5073
5111
  requestedPluginKey: pluginKey
@@ -5100,7 +5138,8 @@ function checkInstalledVersion(pluginKey) {
5100
5138
  if (!installedVersion) {
5101
5139
  throw new FormCliError(
5102
5140
  FormCliErrorCode.PLUGIN_NOT_INSTALLED,
5103
- `Plugin ${pluginKey} is not installed in node_modules. Run "fullstack-cli action-plugin install ${pluginKey}" first.`
5141
+ `Plugin ${pluginKey} is not installed in node_modules`,
5142
+ { hint: `Run "fullstack-cli action-plugin install ${pluginKey}" first.` }
5104
5143
  );
5105
5144
  }
5106
5145
  let declaredVersion;
@@ -5109,14 +5148,20 @@ function checkInstalledVersion(pluginKey) {
5109
5148
  } catch (error) {
5110
5149
  throw new FormCliError(
5111
5150
  FormCliErrorCode.PLUGIN_NOT_INSTALLED,
5112
- `Cannot read package.json actionPlugins: ${error instanceof Error ? error.message : String(error)}`
5151
+ `Cannot read package.json actionPlugins: ${error instanceof Error ? error.message : String(error)}`,
5152
+ {
5153
+ hint: "Run the command in the project root (the directory containing package.json)."
5154
+ }
5113
5155
  );
5114
5156
  }
5115
5157
  if (!declaredVersion) {
5116
5158
  throw new FormCliError(
5117
5159
  FormCliErrorCode.PLUGIN_NOT_INSTALLED,
5118
- `Plugin ${pluginKey} is not recorded in package.json actionPlugins. Run "fullstack-cli action-plugin install ${pluginKey}" first.`,
5119
- { details: { installedVersion } }
5160
+ `Plugin ${pluginKey} is not recorded in package.json actionPlugins`,
5161
+ {
5162
+ hint: `Run "fullstack-cli action-plugin install ${pluginKey}" first.`,
5163
+ details: { installedVersion }
5164
+ }
5120
5165
  );
5121
5166
  }
5122
5167
  if (declaredVersion !== installedVersion) {
@@ -5147,11 +5192,15 @@ async function resolveInstalledPlugin(pluginKey) {
5147
5192
  } catch (error) {
5148
5193
  throw new FormCliError(
5149
5194
  FormCliErrorCode.PLUGIN_LOAD_FAILED,
5150
- error instanceof Error ? error.message : String(error)
5195
+ `Failed to load plugin ${pluginKey} from node_modules: ${error instanceof Error ? error.message : String(error)}`,
5196
+ {
5197
+ hint: `Reinstall it with "fullstack-cli action-plugin install ${pluginKey}"; if it still fails, the plugin package is broken.`
5198
+ }
5151
5199
  );
5152
5200
  }
5153
5201
  return { key: pluginKey, version, manifest, module };
5154
5202
  }
5203
+ var SDK_TOO_OLD_HINT = (pluginKey) => `Run "fullstack-cli action-plugin update ${pluginKey}" to get the latest version; if it still fails, this plugin does not support form actions or validateForm.`;
5155
5204
  function hasFormActionSdk(module) {
5156
5205
  return typeof module.runFormAction === "function" && typeof module.validateForm === "function" && typeof module.hasValidateForm === "function";
5157
5206
  }
@@ -5159,7 +5208,8 @@ function assertFormActionSdk(module, pluginKey) {
5159
5208
  if (!hasFormActionSdk(module)) {
5160
5209
  throw new FormCliError(
5161
5210
  FormCliErrorCode.PLUGIN_SDK_TOO_OLD,
5162
- `Plugin ${pluginKey} was built with an action-plugin-core that has no form action support (runFormAction / validateForm / hasValidateForm missing). Upgrade the plugin to a version built with the formActions-capable SDK.`
5211
+ `Plugin ${pluginKey} was built with an SDK that has no form action support (runFormAction / validateForm / hasValidateForm missing)`,
5212
+ { hint: SDK_TOO_OLD_HINT(pluginKey) }
5163
5213
  );
5164
5214
  }
5165
5215
  }
@@ -5206,7 +5256,10 @@ function findFormAction(pluginKey, action, formActions) {
5206
5256
  throw new FormCliError(
5207
5257
  FormCliErrorCode.FORM_ACTION_NOT_FOUND,
5208
5258
  `Form action "${action}" not found in plugin ${pluginKey}. Available: ${keys.length ? keys.join(", ") : "(none)"}`,
5209
- { details: { available: keys } }
5259
+ {
5260
+ hint: keys.length ? "Use one of details.available as --action." : `Plugin ${pluginKey} has no form actions; upgrade it with "fullstack-cli action-plugin update ${pluginKey}" if a newer version adds them.`,
5261
+ details: { available: keys }
5262
+ }
5210
5263
  );
5211
5264
  }
5212
5265
  return found;
@@ -5324,11 +5377,11 @@ function parseOutputFormat(raw) {
5324
5377
  `--format must be json or pretty, got: ${raw}`
5325
5378
  );
5326
5379
  }
5327
- function finishWithFailure(error) {
5380
+ function finishWithFailure(error, pluginErrorHint) {
5328
5381
  if (process.env.DEBUG && error instanceof Error) {
5329
5382
  console.error(error.stack);
5330
5383
  }
5331
- finishWithJson(toFailureOutput(error, "EXECUTION_ERROR"), 1);
5384
+ finishWithJson(toFailureOutput(error, "EXECUTION_ERROR", pluginErrorHint), 1);
5332
5385
  }
5333
5386
  async function formActionList(options) {
5334
5387
  try {
@@ -5368,7 +5421,10 @@ async function formActionExecute(options) {
5368
5421
  });
5369
5422
  finishWithJson(result, 0);
5370
5423
  } catch (error) {
5371
- finishWithFailure(error);
5424
+ finishWithFailure(
5425
+ error,
5426
+ (code) => code === FormCliErrorCode.INVALID_INPUT ? `Check --input against the action's inputSchema: run "fullstack-cli action-plugin form-action-get --plugin ${options.plugin} --action ${options.action}".` : void 0
5427
+ );
5372
5428
  }
5373
5429
  }
5374
5430
 
@@ -5533,31 +5589,72 @@ var listCommand = {
5533
5589
  });
5534
5590
  }
5535
5591
  };
5536
- var FORMAT_OPTION_DESC = "Output format: json (default) | pretty";
5592
+ var FORMAT_OPTION_DESC = "Output format: json (default) or pretty";
5537
5593
  var JSON_ARG_HINT = "inline JSON, @<file>, or - for stdin";
5594
+ var PLUGIN_OPTION_DESC = "(required) Plugin key, e.g. @office/feishu-bitable";
5595
+ var ACTION_OPTION_DESC = "(required) Form action key or alias from form-action-list, e.g. getTableFields or get-table-fields";
5538
5596
  var formActionListCommand = {
5539
5597
  name: "form-action-list",
5540
- description: "List the form actions (config-time queries) of an installed plugin",
5598
+ description: "List the form actions of an installed plugin (queries used while configuring it, e.g. search bases, list tables)",
5541
5599
  register(program) {
5542
- program.command(this.name).description(this.description).requiredOption("--plugin <key>", "Plugin key (e.g., @office/feishu-bitable)").option("--format <format>", FORMAT_OPTION_DESC).action(async (options) => {
5600
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--plugin <key>", PLUGIN_OPTION_DESC).option("--format <format>", FORMAT_OPTION_DESC).addHelpText(
5601
+ "after",
5602
+ `
5603
+ Reads the local plugin manifest only; no credential needed.
5604
+ Output: {key, version, formActions: [{key, alias, title, description}], hasValidateForm}
5605
+ Next: run form-action-get to see an action's input schema.
5606
+
5607
+ Example:
5608
+ fullstack-cli action-plugin form-action-list --plugin @office/feishu-bitable`
5609
+ ).action(async (options) => {
5543
5610
  await formActionList(options);
5544
5611
  });
5545
5612
  }
5546
5613
  };
5547
5614
  var formActionGetCommand = {
5548
5615
  name: "form-action-get",
5549
- description: "Show the input / output schema of a plugin form action",
5616
+ description: "Show the input and output schema of a plugin form action",
5550
5617
  register(program) {
5551
- program.command(this.name).description(this.description).requiredOption("--plugin <key>", "Plugin key (e.g., @office/feishu-bitable)").requiredOption("--action <name>", "Form action name, camelCase or kebab-case (e.g., getTableFields / get-table-fields)").option("--format <format>", FORMAT_OPTION_DESC).action(async (options) => {
5618
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--plugin <key>", PLUGIN_OPTION_DESC).requiredOption("--action <name>", ACTION_OPTION_DESC).option("--format <format>", FORMAT_OPTION_DESC).addHelpText(
5619
+ "after",
5620
+ `
5621
+ Reads the local plugin manifest only; no credential needed.
5622
+ Output: {key, version, action: {key, alias, title, description, inputSchema, outputSchema}}
5623
+ Next: build --input from inputSchema and run form-action-execute.
5624
+
5625
+ Example:
5626
+ fullstack-cli action-plugin form-action-get --plugin @office/feishu-bitable --action list-tables`
5627
+ ).action(async (options) => {
5552
5628
  await formActionGet(options);
5553
5629
  });
5554
5630
  }
5555
5631
  };
5556
5632
  var formActionExecuteCommand = {
5557
5633
  name: "form-action-execute",
5558
- description: "Execute a plugin form action (e.g., list tables) and print its JSON result",
5634
+ description: "Run a plugin form action (e.g. list tables) and print the result as JSON",
5559
5635
  register(program) {
5560
- program.command(this.name).description(this.description).requiredOption("--plugin <key>", "Plugin key (e.g., @office/feishu-bitable)").requiredOption("--action <name>", "Form action name, camelCase or kebab-case (e.g., getTableFields / get-table-fields)").requiredOption("--input <json>", `Action input: ${JSON_ARG_HINT}`).option("--id <id>", "Existing capability ID; its formValue becomes ctx.formValue").option("--form-value <json>", `Current form value used as ctx.formValue, replacing the instance value entirely: ${JSON_ARG_HINT}`).option("--timeout <ms>", "Execution timeout in milliseconds (default: 60000)").action(async (options) => {
5636
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--plugin <key>", PLUGIN_OPTION_DESC).requiredOption("--action <name>", ACTION_OPTION_DESC).requiredOption(
5637
+ "--input <json>",
5638
+ `(required) Action input matching the action's inputSchema: ${JSON_ARG_HINT}`
5639
+ ).option(
5640
+ "--id <id>",
5641
+ "Existing capability ID; the plugin sees that instance's saved form value (e.g. to keep the user's previous choices)"
5642
+ ).option(
5643
+ "--form-value <json>",
5644
+ `Unsaved form value for the plugin to see instead of the saved one (JSON object; wins over --id): ${JSON_ARG_HINT}`
5645
+ ).option("--timeout <ms>", "Timeout in milliseconds (default: 60000)").addHelpText(
5646
+ "after",
5647
+ `
5648
+ Requires the operator credential MIAODA_AUTHN_CODE, which the platform injects when the
5649
+ command runs through agent_tool; it cannot run in a plain terminal.
5650
+ Output: on success, the plugin's result JSON (exit 0); on failure,
5651
+ {ok: false, code, message, hint?, details?} (exit 1). Logs go to stderr.
5652
+ At most one of --input / --form-value can read from stdin (-).
5653
+
5654
+ Examples:
5655
+ fullstack-cli action-plugin form-action-execute --plugin @office/feishu-bitable --action search-apps --input '{"keyword":"tasks"}'
5656
+ fullstack-cli action-plugin form-action-execute --plugin @office/feishu-bitable --action get-table-fields --input @./input.json --id bitable_tasks`
5657
+ ).action(async (options) => {
5561
5658
  await formActionExecute(options);
5562
5659
  });
5563
5660
  }
@@ -5664,6 +5761,7 @@ function isLegacyManifest(manifest) {
5664
5761
  function isRecord(value) {
5665
5762
  return !!value && typeof value === "object" && !Array.isArray(value);
5666
5763
  }
5764
+ var PLUGIN_BUG_HINT = "This is a bug in the plugin, not in the form value. Do not retry or change the form value for it; report it to the plugin author.";
5667
5765
  function normalizeIssue(issue) {
5668
5766
  if (!isRecord(issue)) {
5669
5767
  return void 0;
@@ -5688,7 +5786,8 @@ function normalizeResult(raw) {
5688
5786
  if (!isRecord(raw) || typeof raw.success !== "boolean" || raw.issues !== void 0 && !Array.isArray(raw.issues)) {
5689
5787
  throw new FormCliError(
5690
5788
  FormCliErrorCode.VALIDATION_EXECUTION_FAILED,
5691
- "validateForm returned an unexpected shape: expected { success: boolean, issues?: FormIssue[] }"
5789
+ "validateForm returned an unexpected shape: expected { success: boolean, issues?: FormIssue[] }",
5790
+ { hint: PLUGIN_BUG_HINT }
5692
5791
  );
5693
5792
  }
5694
5793
  const rawIssues = raw.issues ?? [];
@@ -5698,7 +5797,7 @@ function normalizeResult(raw) {
5698
5797
  throw new FormCliError(
5699
5798
  FormCliErrorCode.VALIDATION_EXECUTION_FAILED,
5700
5799
  `validateForm returned a malformed issue at index ${index}: message must be a non-empty string; code, if given, must be a non-empty string; path, if given, must be a string`,
5701
- { details: { issue: rawIssue } }
5800
+ { hint: PLUGIN_BUG_HINT, details: { issue: rawIssue } }
5702
5801
  );
5703
5802
  }
5704
5803
  return issue;
@@ -5721,6 +5820,7 @@ async function runValidate(options) {
5721
5820
  ok: false,
5722
5821
  code: FormCliErrorCode.INVALID_INPUT,
5723
5822
  message: `form value does not match plugin ${options.plugin} config schema (${issues.length} issue(s))`,
5823
+ hint: "Fix the fields listed in issues (path is a JSON Pointer into the form value) and run again.",
5724
5824
  issues,
5725
5825
  validated: false,
5726
5826
  pluginVersion
@@ -5735,7 +5835,8 @@ async function runValidate(options) {
5735
5835
  if (manifestClaims && (!sdkReady || typeof module.validateForm !== "function")) {
5736
5836
  throw new FormCliError(
5737
5837
  FormCliErrorCode.VALIDATION_EXECUTION_FAILED,
5738
- `Plugin ${options.plugin} manifest declares hasValidateForm but the loaded module has no validateForm`
5838
+ `Plugin ${options.plugin} manifest declares hasValidateForm but the loaded module has no validateForm`,
5839
+ { hint: PLUGIN_BUG_HINT }
5739
5840
  );
5740
5841
  }
5741
5842
  let pluginHas = false;
@@ -5744,13 +5845,15 @@ async function runValidate(options) {
5744
5845
  } else if (!isLegacyManifest(manifest)) {
5745
5846
  throw new FormCliError(
5746
5847
  FormCliErrorCode.PLUGIN_SDK_TOO_OLD,
5747
- `Plugin ${options.plugin} manifest has form action fields but the module lacks runFormAction / validateForm / hasValidateForm. Reinstall or upgrade the plugin.`
5848
+ `Plugin ${options.plugin} manifest has form action fields but the module lacks runFormAction / validateForm / hasValidateForm`,
5849
+ { hint: SDK_TOO_OLD_HINT(options.plugin) }
5748
5850
  );
5749
5851
  }
5750
5852
  if (manifestClaims && !pluginHas) {
5751
5853
  throw new FormCliError(
5752
5854
  FormCliErrorCode.VALIDATION_EXECUTION_FAILED,
5753
- `Plugin ${options.plugin} manifest declares hasValidateForm but plugin.hasValidateForm() returned false`
5855
+ `Plugin ${options.plugin} manifest declares hasValidateForm but plugin.hasValidateForm() returned false`,
5856
+ { hint: PLUGIN_BUG_HINT }
5754
5857
  );
5755
5858
  }
5756
5859
  if (!pluginHas) {
@@ -5786,7 +5889,10 @@ async function runValidate(options) {
5786
5889
  throw new FormCliError(
5787
5890
  FormCliErrorCode.VALIDATION_EXECUTION_FAILED,
5788
5891
  `validateForm of ${options.plugin} threw: ${cause.message}`,
5789
- { details: { cause } }
5892
+ {
5893
+ hint: "See details.cause: a permission or platform error needs to be resolved first (or retried later if it is transient); anything else is a bug in the plugin, so do not change the form value for it.",
5894
+ details: { cause }
5895
+ }
5790
5896
  );
5791
5897
  }
5792
5898
  const output = {
@@ -5799,6 +5905,7 @@ async function runValidate(options) {
5799
5905
  if (!checked.success) {
5800
5906
  output.code = FormCliErrorCode.VALIDATION_FAILED;
5801
5907
  output.message = checked.issues[0]?.message ?? `plugin ${options.plugin} validateForm did not pass`;
5908
+ output.hint = checked.issues.length > 0 ? "Fix the form value according to issues and run again." : "The plugin rejected the form value without giving a reason; review the values against the plugin schema and run again.";
5802
5909
  }
5803
5910
  return output;
5804
5911
  }
@@ -5818,7 +5925,7 @@ async function validate(options) {
5818
5925
  }
5819
5926
 
5820
5927
  // src/commands/capability/write.handler.ts
5821
- import fs19 from "fs";
5928
+ import fs20 from "fs";
5822
5929
  import path15 from "path";
5823
5930
  var CAPABILITY_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
5824
5931
  var CREATED_BY_PLACEHOLDER = "__fullstack_cli_created_by__";
@@ -5847,7 +5954,7 @@ function toProjectRelative(absolutePath) {
5847
5954
  function readPluginIcon(pluginKey) {
5848
5955
  try {
5849
5956
  const pkg2 = JSON.parse(
5850
- fs19.readFileSync(
5957
+ fs20.readFileSync(
5851
5958
  path15.join(getPluginPath(pluginKey), "package.json"),
5852
5959
  "utf-8"
5853
5960
  )
@@ -5866,30 +5973,33 @@ function serializeCapability(record, createdByToken) {
5866
5973
  }
5867
5974
  function writeAtomically(filePath, content, options) {
5868
5975
  const dir = path15.dirname(filePath);
5869
- fs19.mkdirSync(dir, { recursive: true });
5976
+ fs20.mkdirSync(dir, { recursive: true });
5870
5977
  const tmp = path15.join(
5871
5978
  dir,
5872
5979
  `.${path15.basename(filePath)}.${process.pid}.${Date.now()}.tmp`
5873
5980
  );
5874
- fs19.writeFileSync(tmp, content);
5981
+ fs20.writeFileSync(tmp, content);
5875
5982
  try {
5876
5983
  if (options.exclusive) {
5877
5984
  try {
5878
- fs19.linkSync(tmp, filePath);
5985
+ fs20.linkSync(tmp, filePath);
5879
5986
  } catch (error) {
5880
5987
  if (error.code === "EEXIST") {
5881
5988
  throw new FormCliError(
5882
5989
  FormCliErrorCode.INSTANCE_EXISTS,
5883
- `Capability file ${toProjectRelative(filePath)} was created concurrently; use "capability update" to modify it`
5990
+ `Capability file ${toProjectRelative(filePath)} was created concurrently`,
5991
+ {
5992
+ hint: 'Use "fullstack-cli capability update" to modify it, or pick another --id.'
5993
+ }
5884
5994
  );
5885
5995
  }
5886
5996
  throw error;
5887
5997
  }
5888
5998
  } else {
5889
- fs19.renameSync(tmp, filePath);
5999
+ fs20.renameSync(tmp, filePath);
5890
6000
  }
5891
6001
  } finally {
5892
- fs19.rmSync(tmp, { force: true });
6002
+ fs20.rmSync(tmp, { force: true });
5893
6003
  }
5894
6004
  }
5895
6005
  function readParamsSchema(raw) {
@@ -5916,10 +6026,13 @@ async function runCreate(options) {
5916
6026
  );
5917
6027
  }
5918
6028
  const filePath = capabilityFilePath(options.id);
5919
- if (fs19.existsSync(filePath)) {
6029
+ if (fs20.existsSync(filePath)) {
5920
6030
  throw new FormCliError(
5921
6031
  FormCliErrorCode.INSTANCE_EXISTS,
5922
- `Capability ${options.id} already exists at ${toProjectRelative(filePath)}; use "capability update" to modify it`
6032
+ `Capability ${options.id} already exists at ${toProjectRelative(filePath)}`,
6033
+ {
6034
+ hint: 'Use "fullstack-cli capability update" to modify it, or pick another --id.'
6035
+ }
5923
6036
  );
5924
6037
  }
5925
6038
  assertSingleStdinArg({
@@ -5957,13 +6070,16 @@ async function runCreate(options) {
5957
6070
  async function runUpdate(options) {
5958
6071
  assertValidId(options.id);
5959
6072
  const filePath = capabilityFilePath(options.id);
5960
- if (!fs19.existsSync(filePath)) {
6073
+ if (!fs20.existsSync(filePath)) {
5961
6074
  throw new FormCliError(
5962
6075
  FormCliErrorCode.INSTANCE_NOT_FOUND,
5963
- `Capability ${options.id} not found at ${toProjectRelative(filePath)}; use "capability create" to create it`
6076
+ `Capability ${options.id} not found at ${toProjectRelative(filePath)}`,
6077
+ {
6078
+ hint: 'Check the id with "fullstack-cli capability list --summary", or use "fullstack-cli capability create" to create it.'
6079
+ }
5964
6080
  );
5965
6081
  }
5966
- const rawText = fs19.readFileSync(filePath, "utf-8");
6082
+ const rawText = fs20.readFileSync(filePath, "utf-8");
5967
6083
  let existing;
5968
6084
  try {
5969
6085
  const parsed = JSON.parse(rawText);
@@ -6055,22 +6171,31 @@ var getCommand = {
6055
6171
  });
6056
6172
  }
6057
6173
  };
6174
+ var PLUGIN_OPTION_DESC2 = "(required) Plugin key, e.g. @office/feishu-bitable";
6175
+ var TIMEOUT_OPTION_DESC = "Timeout for the plugin's validateForm in milliseconds (default: 60000)";
6176
+ var WRITE_OUTPUT_HELP = `Output: {ok, id, path, pluginVersion, validated, issues, affectedFilePaths} (exit 0);
6177
+ when the check fails, the same output as "capability validate" and nothing is written (exit 1).
6178
+ Requires MIAODA_AUTHN_CODE only when the plugin defines validateForm.`;
6058
6179
  var validateCommand = {
6059
6180
  name: "validate",
6060
- description: "Validate a capability form value with the plugin (config schema + validateForm)",
6181
+ description: "Check a form value before saving: the plugin's config schema, then the plugin's own validateForm. Writes nothing",
6061
6182
  register(program) {
6062
- program.command(this.name).description(this.description).requiredOption(
6063
- "--plugin <key>",
6064
- "Plugin key (e.g., @office/feishu-bitable)"
6065
- ).requiredOption(
6183
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--plugin <key>", PLUGIN_OPTION_DESC2).requiredOption(
6066
6184
  "--form-value <json>",
6067
- `Full form value to save: ${JSON_ARG_HINT2}`
6185
+ `(required) Complete form value to check (JSON object): ${JSON_ARG_HINT2}`
6068
6186
  ).option(
6069
6187
  "--id <id>",
6070
- "Existing capability ID when modifying (omit when creating)"
6071
- ).option(
6072
- "--timeout <ms>",
6073
- "Timeout for validateForm in milliseconds (default: 60000)"
6188
+ "Existing capability ID when modifying; its saved form value is passed to the plugin as the previous value. Omit when creating"
6189
+ ).option("--timeout <ms>", TIMEOUT_OPTION_DESC).addHelpText(
6190
+ "after",
6191
+ `
6192
+ Output: {ok, validated, pluginVersion, issues, normalizedFormValue} (exit 0); when the check fails,
6193
+ ok: false with code VALIDATION_FAILED or INVALID_INPUT, plus issues and hint (exit 1).
6194
+ validated: false means the plugin has no validateForm, so only the schema check ran.
6195
+ Requires MIAODA_AUTHN_CODE only when the plugin defines validateForm.
6196
+
6197
+ Example:
6198
+ fullstack-cli capability validate --plugin @office/feishu-bitable --form-value @./form.json`
6074
6199
  ).action(
6075
6200
  async (options) => {
6076
6201
  await validate(options);
@@ -6080,23 +6205,26 @@ var validateCommand = {
6080
6205
  };
6081
6206
  var createCommand = {
6082
6207
  name: "create",
6083
- description: 'Create a capability instance file after passing "capability validate" (not written if any error issue)',
6208
+ description: 'Create a capability instance; runs the same checks as "capability validate" first and writes nothing if they fail',
6084
6209
  register(program) {
6085
- program.command(this.name).description(this.description).requiredOption(
6086
- "--plugin <key>",
6087
- "Plugin key (e.g., @office/feishu-bitable)"
6088
- ).requiredOption(
6210
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--plugin <key>", PLUGIN_OPTION_DESC2).requiredOption(
6089
6211
  "--id <id>",
6090
- 'New capability ID (letters, digits, "_" and "-")'
6091
- ).requiredOption("--name <name>", "Capability display name").requiredOption(
6212
+ '(required) New capability ID: letters, digits, "_" and "-", starting with a letter or digit, max 128'
6213
+ ).requiredOption("--name <name>", "(required) Display name").requiredOption(
6092
6214
  "--form-value <json>",
6093
- `Full form value: ${JSON_ARG_HINT2}`
6094
- ).option("--description <text>", "Capability description").option(
6215
+ `(required) Complete form value (JSON object): ${JSON_ARG_HINT2}`
6216
+ ).option("--description <text>", "Description (default: empty)").option(
6095
6217
  "--params-schema <json>",
6096
- `paramsSchema (default: {}): ${JSON_ARG_HINT2}`
6097
- ).option(
6098
- "--timeout <ms>",
6099
- "Timeout for validateForm in milliseconds (default: 60000)"
6218
+ `paramsSchema (JSON object, default: {}): ${JSON_ARG_HINT2}`
6219
+ ).option("--timeout <ms>", TIMEOUT_OPTION_DESC).addHelpText(
6220
+ "after",
6221
+ `
6222
+ Writes <CAPABILITIES_DIR>/<id>.json (default: shared/capabilities if it exists, else server/capabilities).
6223
+ Fails with INSTANCE_EXISTS when the id is taken.
6224
+ ${WRITE_OUTPUT_HELP}
6225
+
6226
+ Example:
6227
+ fullstack-cli capability create --plugin @office/feishu-bitable --id bitable_tasks --name Tasks --form-value @./form.json`
6100
6228
  ).action(async (options) => {
6101
6229
  await create(options);
6102
6230
  });
@@ -6104,17 +6232,23 @@ var createCommand = {
6104
6232
  };
6105
6233
  var updateCommand2 = {
6106
6234
  name: "update",
6107
- description: 'Update an existing capability instance after passing "capability validate" (not written if any error issue)',
6235
+ description: 'Update an existing capability instance; runs the same checks as "capability validate" first and writes nothing if they fail',
6108
6236
  register(program) {
6109
- program.command(this.name).description(this.description).requiredOption("--id <id>", "Existing capability ID").requiredOption(
6237
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--id <id>", "(required) Existing capability ID").requiredOption(
6110
6238
  "--form-value <json>",
6111
- `Full new form value: ${JSON_ARG_HINT2}`
6239
+ `(required) Complete new form value (JSON object), replacing the saved one: ${JSON_ARG_HINT2}`
6112
6240
  ).option("--name <name>", "New display name (kept when omitted)").option("--description <text>", "New description (kept when omitted)").option(
6113
6241
  "--params-schema <json>",
6114
- `New paramsSchema (kept when omitted): ${JSON_ARG_HINT2}`
6115
- ).option(
6116
- "--timeout <ms>",
6117
- "Timeout for validateForm in milliseconds (default: 60000)"
6242
+ `New paramsSchema (JSON object, kept when omitted): ${JSON_ARG_HINT2}`
6243
+ ).option("--timeout <ms>", TIMEOUT_OPTION_DESC).addHelpText(
6244
+ "after",
6245
+ `
6246
+ The plugin key comes from the existing instance file; other fields such as createdAt are kept.
6247
+ Fails with INSTANCE_NOT_FOUND when the id does not exist.
6248
+ ${WRITE_OUTPUT_HELP}
6249
+
6250
+ Example:
6251
+ fullstack-cli capability update --id bitable_tasks --form-value @./form.json`
6118
6252
  ).action(async (options) => {
6119
6253
  await update2(options);
6120
6254
  });
@@ -6136,7 +6270,7 @@ var capabilityCommandGroup = {
6136
6270
  import { execFile } from "child_process";
6137
6271
 
6138
6272
  // src/commands/component/registry-preparer.ts
6139
- import fs20 from "fs";
6273
+ import fs21 from "fs";
6140
6274
  import path16 from "path";
6141
6275
  import os from "os";
6142
6276
 
@@ -6212,8 +6346,8 @@ function getLocalRegistryPath(key) {
6212
6346
  return path16.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
6213
6347
  }
6214
6348
  function ensureDir(dirPath) {
6215
- if (!fs20.existsSync(dirPath)) {
6216
- fs20.mkdirSync(dirPath, { recursive: true });
6349
+ if (!fs21.existsSync(dirPath)) {
6350
+ fs21.mkdirSync(dirPath, { recursive: true });
6217
6351
  }
6218
6352
  }
6219
6353
  async function prepareRecursive(key, visited) {
@@ -6247,7 +6381,7 @@ async function prepareRecursive(key, visited) {
6247
6381
  };
6248
6382
  const localPath = getLocalRegistryPath(key);
6249
6383
  ensureDir(path16.dirname(localPath));
6250
- fs20.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
6384
+ fs21.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
6251
6385
  debug("\u4FDD\u5B58\u5230: %s", localPath);
6252
6386
  }
6253
6387
  async function prepareComponentRegistryItems(id) {
@@ -6257,18 +6391,18 @@ async function prepareComponentRegistryItems(id) {
6257
6391
  }
6258
6392
  function cleanupTempDir() {
6259
6393
  try {
6260
- if (fs20.existsSync(REGISTRY_TEMP_DIR)) {
6261
- fs20.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
6394
+ if (fs21.existsSync(REGISTRY_TEMP_DIR)) {
6395
+ fs21.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
6262
6396
  }
6263
6397
  } catch {
6264
6398
  }
6265
6399
  }
6266
6400
  function getDownloadedRegistryItem(itemId) {
6267
6401
  const localPath = getLocalRegistryPath(itemId);
6268
- if (!fs20.existsSync(localPath)) {
6402
+ if (!fs21.existsSync(localPath)) {
6269
6403
  return null;
6270
6404
  }
6271
- const content = fs20.readFileSync(localPath, "utf-8");
6405
+ const content = fs21.readFileSync(localPath, "utf-8");
6272
6406
  return JSON.parse(content);
6273
6407
  }
6274
6408
 
@@ -6436,7 +6570,7 @@ var componentCommandGroup = {
6436
6570
  };
6437
6571
 
6438
6572
  // src/commands/migration/version-manager.ts
6439
- import fs21 from "fs";
6573
+ import fs22 from "fs";
6440
6574
  import path17 from "path";
6441
6575
  var PACKAGE_JSON = "package.json";
6442
6576
  var VERSION_FIELD = "migrationVersion";
@@ -6445,25 +6579,25 @@ function getPackageJsonPath2() {
6445
6579
  }
6446
6580
  function getCurrentVersion() {
6447
6581
  const pkgPath = getPackageJsonPath2();
6448
- if (!fs21.existsSync(pkgPath)) {
6582
+ if (!fs22.existsSync(pkgPath)) {
6449
6583
  throw new Error("package.json not found");
6450
6584
  }
6451
- const pkg2 = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
6585
+ const pkg2 = JSON.parse(fs22.readFileSync(pkgPath, "utf-8"));
6452
6586
  return pkg2[VERSION_FIELD] ?? 0;
6453
6587
  }
6454
6588
  function setCurrentVersion(version) {
6455
6589
  const pkgPath = getPackageJsonPath2();
6456
- const pkg2 = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
6590
+ const pkg2 = JSON.parse(fs22.readFileSync(pkgPath, "utf-8"));
6457
6591
  pkg2[VERSION_FIELD] = version;
6458
- fs21.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
6592
+ fs22.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
6459
6593
  }
6460
6594
 
6461
6595
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
6462
- import fs23 from "fs";
6596
+ import fs24 from "fs";
6463
6597
  import path19 from "path";
6464
6598
 
6465
6599
  // src/commands/migration/versions/v001_capability/utils.ts
6466
- import fs22 from "fs";
6600
+ import fs23 from "fs";
6467
6601
  import path18 from "path";
6468
6602
  var CAPABILITIES_DIR2 = "server/capabilities";
6469
6603
  function getProjectRoot3() {
@@ -6480,14 +6614,14 @@ function getPluginManifestPath2(pluginKey) {
6480
6614
  function detectJsonMigration() {
6481
6615
  const capabilitiesDir = getCapabilitiesDir2();
6482
6616
  const oldFilePath = path19.join(capabilitiesDir, "capabilities.json");
6483
- if (!fs23.existsSync(oldFilePath)) {
6617
+ if (!fs24.existsSync(oldFilePath)) {
6484
6618
  return {
6485
6619
  needsMigration: false,
6486
6620
  reason: "capabilities.json not found"
6487
6621
  };
6488
6622
  }
6489
6623
  try {
6490
- const content = fs23.readFileSync(oldFilePath, "utf-8");
6624
+ const content = fs24.readFileSync(oldFilePath, "utf-8");
6491
6625
  const parsed = JSON.parse(content);
6492
6626
  if (!Array.isArray(parsed)) {
6493
6627
  return {
@@ -6538,7 +6672,7 @@ async function check(options) {
6538
6672
  }
6539
6673
 
6540
6674
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
6541
- import fs24 from "fs";
6675
+ import fs25 from "fs";
6542
6676
  import path20 from "path";
6543
6677
 
6544
6678
  // src/commands/migration/versions/v001_capability/mapping.ts
@@ -6769,10 +6903,10 @@ function transformCapabilities(oldCapabilities) {
6769
6903
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
6770
6904
  function loadExistingCapabilities() {
6771
6905
  const capabilitiesDir = getCapabilitiesDir2();
6772
- if (!fs24.existsSync(capabilitiesDir)) {
6906
+ if (!fs25.existsSync(capabilitiesDir)) {
6773
6907
  return [];
6774
6908
  }
6775
- const files = fs24.readdirSync(capabilitiesDir);
6909
+ const files = fs25.readdirSync(capabilitiesDir);
6776
6910
  const capabilities = [];
6777
6911
  for (const file of files) {
6778
6912
  if (file === "capabilities.json" || !file.endsWith(".json")) {
@@ -6780,7 +6914,7 @@ function loadExistingCapabilities() {
6780
6914
  }
6781
6915
  try {
6782
6916
  const filePath = path20.join(capabilitiesDir, file);
6783
- const content = fs24.readFileSync(filePath, "utf-8");
6917
+ const content = fs25.readFileSync(filePath, "utf-8");
6784
6918
  const capability = JSON.parse(content);
6785
6919
  if (capability.id && capability.pluginKey) {
6786
6920
  capabilities.push(capability);
@@ -6840,7 +6974,7 @@ async function migrateJsonFiles(options) {
6840
6974
  for (const cap of newCapabilities) {
6841
6975
  const filePath = path20.join(capabilitiesDir, `${cap.id}.json`);
6842
6976
  const content = JSON.stringify(cap, null, 2);
6843
- fs24.writeFileSync(filePath, content, "utf-8");
6977
+ fs25.writeFileSync(filePath, content, "utf-8");
6844
6978
  console.log(` \u2713 Created: ${cap.id}.json`);
6845
6979
  }
6846
6980
  return {
@@ -6852,11 +6986,11 @@ async function migrateJsonFiles(options) {
6852
6986
  }
6853
6987
 
6854
6988
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
6855
- import fs25 from "fs";
6989
+ import fs26 from "fs";
6856
6990
  function isPluginInstalled2(pluginKey) {
6857
6991
  const actionPlugins = readActionPlugins();
6858
6992
  const manifestPath = getPluginManifestPath2(pluginKey);
6859
- return fs25.existsSync(manifestPath) && !!actionPlugins[pluginKey];
6993
+ return fs26.existsSync(manifestPath) && !!actionPlugins[pluginKey];
6860
6994
  }
6861
6995
  function detectPluginsToInstall(capabilities) {
6862
6996
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -6936,7 +7070,7 @@ import path22 from "path";
6936
7070
  import { Project as Project3 } from "ts-morph";
6937
7071
 
6938
7072
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
6939
- import fs26 from "fs";
7073
+ import fs27 from "fs";
6940
7074
  import path21 from "path";
6941
7075
  var EXCLUDED_DIRS = [
6942
7076
  "node_modules",
@@ -6952,7 +7086,7 @@ var EXCLUDED_PATTERNS = [
6952
7086
  /\.d\.ts$/
6953
7087
  ];
6954
7088
  function scanDirectory(dir, files = []) {
6955
- const entries = fs26.readdirSync(dir, { withFileTypes: true });
7089
+ const entries = fs27.readdirSync(dir, { withFileTypes: true });
6956
7090
  for (const entry of entries) {
6957
7091
  const fullPath = path21.join(dir, entry.name);
6958
7092
  if (entry.isDirectory()) {
@@ -6971,13 +7105,13 @@ function scanDirectory(dir, files = []) {
6971
7105
  }
6972
7106
  function scanServerFiles() {
6973
7107
  const serverDir = path21.join(getProjectRoot3(), "server");
6974
- if (!fs26.existsSync(serverDir)) {
7108
+ if (!fs27.existsSync(serverDir)) {
6975
7109
  return [];
6976
7110
  }
6977
7111
  return scanDirectory(serverDir);
6978
7112
  }
6979
7113
  function hasCapabilityImport(filePath) {
6980
- const content = fs26.readFileSync(filePath, "utf-8");
7114
+ const content = fs27.readFileSync(filePath, "utf-8");
6981
7115
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
6982
7116
  }
6983
7117
  function scanFilesToMigrate() {
@@ -7468,17 +7602,17 @@ function getSuggestion(analysis) {
7468
7602
  }
7469
7603
 
7470
7604
  // src/commands/migration/versions/v001_capability/cleanup.ts
7471
- import fs27 from "fs";
7605
+ import fs28 from "fs";
7472
7606
  import path23 from "path";
7473
7607
  function cleanupOldFiles(capabilities, dryRun) {
7474
7608
  const deletedFiles = [];
7475
7609
  const errors = [];
7476
7610
  const capabilitiesDir = getCapabilitiesDir2();
7477
7611
  const oldJsonPath = path23.join(capabilitiesDir, "capabilities.json");
7478
- if (fs27.existsSync(oldJsonPath)) {
7612
+ if (fs28.existsSync(oldJsonPath)) {
7479
7613
  try {
7480
7614
  if (!dryRun) {
7481
- fs27.unlinkSync(oldJsonPath);
7615
+ fs28.unlinkSync(oldJsonPath);
7482
7616
  }
7483
7617
  deletedFiles.push("capabilities.json");
7484
7618
  } catch (error) {
@@ -7487,10 +7621,10 @@ function cleanupOldFiles(capabilities, dryRun) {
7487
7621
  }
7488
7622
  for (const cap of capabilities) {
7489
7623
  const tsFilePath = path23.join(capabilitiesDir, `${cap.id}.ts`);
7490
- if (fs27.existsSync(tsFilePath)) {
7624
+ if (fs28.existsSync(tsFilePath)) {
7491
7625
  try {
7492
7626
  if (!dryRun) {
7493
- fs27.unlinkSync(tsFilePath);
7627
+ fs28.unlinkSync(tsFilePath);
7494
7628
  }
7495
7629
  deletedFiles.push(`${cap.id}.ts`);
7496
7630
  } catch (error) {
@@ -7506,7 +7640,7 @@ function cleanupOldFiles(capabilities, dryRun) {
7506
7640
  }
7507
7641
 
7508
7642
  // src/commands/migration/versions/v001_capability/report-generator.ts
7509
- import fs28 from "fs";
7643
+ import fs29 from "fs";
7510
7644
  import path24 from "path";
7511
7645
  var REPORT_FILE = "capability-migration-report.md";
7512
7646
  function printSummary(result) {
@@ -7670,15 +7804,15 @@ async function generateReport(result) {
7670
7804
  }
7671
7805
  lines.push("");
7672
7806
  const logDir = process.env.LOG_DIR || "logs";
7673
- if (!fs28.existsSync(logDir)) {
7807
+ if (!fs29.existsSync(logDir)) {
7674
7808
  return;
7675
7809
  }
7676
7810
  const reportDir = path24.join(logDir, "migration");
7677
- if (!fs28.existsSync(reportDir)) {
7678
- fs28.mkdirSync(reportDir, { recursive: true });
7811
+ if (!fs29.existsSync(reportDir)) {
7812
+ fs29.mkdirSync(reportDir, { recursive: true });
7679
7813
  }
7680
7814
  const reportPath = path24.join(reportDir, REPORT_FILE);
7681
- fs28.writeFileSync(reportPath, lines.join("\n"), "utf-8");
7815
+ fs29.writeFileSync(reportPath, lines.join("\n"), "utf-8");
7682
7816
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
7683
7817
  }
7684
7818
 
@@ -8213,7 +8347,7 @@ var migrationCommand = {
8213
8347
  import path25 from "path";
8214
8348
 
8215
8349
  // src/commands/read-logs/std-utils.ts
8216
- import fs29 from "fs";
8350
+ import fs30 from "fs";
8217
8351
  function formatStdPrefixTime(localTime) {
8218
8352
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
8219
8353
  if (!match) return localTime;
@@ -8243,11 +8377,11 @@ function stripPrefixFromStdLine(line) {
8243
8377
  return `[${time}] ${content}`;
8244
8378
  }
8245
8379
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
8246
- const stat = fs29.statSync(filePath);
8380
+ const stat = fs30.statSync(filePath);
8247
8381
  if (stat.size === 0) {
8248
8382
  return { lines: [], markerFound: false, totalLinesCount: 0 };
8249
8383
  }
8250
- const fd = fs29.openSync(filePath, "r");
8384
+ const fd = fs30.openSync(filePath, "r");
8251
8385
  const chunkSize = 64 * 1024;
8252
8386
  let position = stat.size;
8253
8387
  let remainder = "";
@@ -8261,7 +8395,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
8261
8395
  const length = Math.min(chunkSize, position);
8262
8396
  position -= length;
8263
8397
  const buffer = Buffer.alloc(length);
8264
- fs29.readSync(fd, buffer, 0, length, position);
8398
+ fs30.readSync(fd, buffer, 0, length, position);
8265
8399
  let chunk = buffer.toString("utf8");
8266
8400
  if (remainder) {
8267
8401
  chunk += remainder;
@@ -8303,7 +8437,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
8303
8437
  }
8304
8438
  }
8305
8439
  } finally {
8306
- fs29.closeSync(fd);
8440
+ fs30.closeSync(fd);
8307
8441
  }
8308
8442
  return { lines: collected.reverse(), markerFound, totalLinesCount };
8309
8443
  }
@@ -8324,21 +8458,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
8324
8458
  }
8325
8459
 
8326
8460
  // src/commands/read-logs/tail.ts
8327
- import fs30 from "fs";
8461
+ import fs31 from "fs";
8328
8462
  function fileExists(filePath) {
8329
8463
  try {
8330
- fs30.accessSync(filePath, fs30.constants.F_OK | fs30.constants.R_OK);
8464
+ fs31.accessSync(filePath, fs31.constants.F_OK | fs31.constants.R_OK);
8331
8465
  return true;
8332
8466
  } catch {
8333
8467
  return false;
8334
8468
  }
8335
8469
  }
8336
8470
  function readFileTailLines(filePath, maxLines) {
8337
- const stat = fs30.statSync(filePath);
8471
+ const stat = fs31.statSync(filePath);
8338
8472
  if (stat.size === 0) {
8339
8473
  return [];
8340
8474
  }
8341
- const fd = fs30.openSync(filePath, "r");
8475
+ const fd = fs31.openSync(filePath, "r");
8342
8476
  const chunkSize = 64 * 1024;
8343
8477
  const chunks = [];
8344
8478
  let position = stat.size;
@@ -8348,13 +8482,13 @@ function readFileTailLines(filePath, maxLines) {
8348
8482
  const length = Math.min(chunkSize, position);
8349
8483
  position -= length;
8350
8484
  const buffer = Buffer.alloc(length);
8351
- fs30.readSync(fd, buffer, 0, length, position);
8485
+ fs31.readSync(fd, buffer, 0, length, position);
8352
8486
  chunks.unshift(buffer.toString("utf8"));
8353
8487
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
8354
8488
  collectedLines += chunkLines;
8355
8489
  }
8356
8490
  } finally {
8357
- fs30.closeSync(fd);
8491
+ fs31.closeSync(fd);
8358
8492
  }
8359
8493
  const content = chunks.join("");
8360
8494
  const allLines = content.split("\n");
@@ -8370,11 +8504,11 @@ function readFileTailLines(filePath, maxLines) {
8370
8504
  return allLines.slice(allLines.length - maxLines);
8371
8505
  }
8372
8506
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
8373
- const stat = fs30.statSync(filePath);
8507
+ const stat = fs31.statSync(filePath);
8374
8508
  if (stat.size === 0) {
8375
8509
  return { lines: [], totalLinesCount: 0 };
8376
8510
  }
8377
- const fd = fs30.openSync(filePath, "r");
8511
+ const fd = fs31.openSync(filePath, "r");
8378
8512
  const chunkSize = 64 * 1024;
8379
8513
  let position = stat.size;
8380
8514
  let remainder = "";
@@ -8386,7 +8520,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
8386
8520
  const length = Math.min(chunkSize, position);
8387
8521
  position -= length;
8388
8522
  const buffer = Buffer.alloc(length);
8389
- fs30.readSync(fd, buffer, 0, length, position);
8523
+ fs31.readSync(fd, buffer, 0, length, position);
8390
8524
  let chunk = buffer.toString("utf8");
8391
8525
  if (remainder) {
8392
8526
  chunk += remainder;
@@ -8417,7 +8551,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
8417
8551
  }
8418
8552
  }
8419
8553
  } finally {
8420
- fs30.closeSync(fd);
8554
+ fs31.closeSync(fd);
8421
8555
  }
8422
8556
  return { lines: collected.reverse(), totalLinesCount };
8423
8557
  }
@@ -8559,7 +8693,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
8559
8693
  }
8560
8694
 
8561
8695
  // src/commands/read-logs/json-lines.ts
8562
- import fs31 from "fs";
8696
+ import fs32 from "fs";
8563
8697
 
8564
8698
  // src/commands/read-logs/structured-log.ts
8565
8699
  function normalizeLevelName(value) {
@@ -8635,11 +8769,11 @@ function buildWantedLevelSet(levels) {
8635
8769
  return set.size > 0 ? set : null;
8636
8770
  }
8637
8771
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
8638
- const stat = fs31.statSync(filePath);
8772
+ const stat = fs32.statSync(filePath);
8639
8773
  if (stat.size === 0) {
8640
8774
  return { lines: [], totalLinesCount: 0 };
8641
8775
  }
8642
- const fd = fs31.openSync(filePath, "r");
8776
+ const fd = fs32.openSync(filePath, "r");
8643
8777
  const chunkSize = 64 * 1024;
8644
8778
  let position = stat.size;
8645
8779
  let remainder = "";
@@ -8654,7 +8788,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
8654
8788
  const length = Math.min(chunkSize, position);
8655
8789
  position -= length;
8656
8790
  const buffer = Buffer.alloc(length);
8657
- fs31.readSync(fd, buffer, 0, length, position);
8791
+ fs32.readSync(fd, buffer, 0, length, position);
8658
8792
  let chunk = buffer.toString("utf8");
8659
8793
  if (remainder) {
8660
8794
  chunk += remainder;
@@ -8716,7 +8850,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
8716
8850
  }
8717
8851
  }
8718
8852
  } finally {
8719
- fs31.closeSync(fd);
8853
+ fs32.closeSync(fd);
8720
8854
  }
8721
8855
  return { lines: collected.reverse(), totalLinesCount };
8722
8856
  }
@@ -8759,11 +8893,11 @@ function extractTraceId(obj) {
8759
8893
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
8760
8894
  const wanted = traceId.trim();
8761
8895
  if (!wanted) return { lines: [], totalLinesCount: 0 };
8762
- const stat = fs31.statSync(filePath);
8896
+ const stat = fs32.statSync(filePath);
8763
8897
  if (stat.size === 0) {
8764
8898
  return { lines: [], totalLinesCount: 0 };
8765
8899
  }
8766
- const fd = fs31.openSync(filePath, "r");
8900
+ const fd = fs32.openSync(filePath, "r");
8767
8901
  const chunkSize = 64 * 1024;
8768
8902
  let position = stat.size;
8769
8903
  let remainder = "";
@@ -8776,7 +8910,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
8776
8910
  const length = Math.min(chunkSize, position);
8777
8911
  position -= length;
8778
8912
  const buffer = Buffer.alloc(length);
8779
- fs31.readSync(fd, buffer, 0, length, position);
8913
+ fs32.readSync(fd, buffer, 0, length, position);
8780
8914
  let chunk = buffer.toString("utf8");
8781
8915
  if (remainder) {
8782
8916
  chunk += remainder;
@@ -8829,7 +8963,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
8829
8963
  }
8830
8964
  }
8831
8965
  } finally {
8832
- fs31.closeSync(fd);
8966
+ fs32.closeSync(fd);
8833
8967
  }
8834
8968
  return { lines: collected.reverse(), totalLinesCount };
8835
8969
  }
@@ -8838,11 +8972,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
8838
8972
  if (!wantedLevelSet) {
8839
8973
  return { lines: [], totalLinesCount: 0 };
8840
8974
  }
8841
- const stat = fs31.statSync(filePath);
8975
+ const stat = fs32.statSync(filePath);
8842
8976
  if (stat.size === 0) {
8843
8977
  return { lines: [], totalLinesCount: 0 };
8844
8978
  }
8845
- const fd = fs31.openSync(filePath, "r");
8979
+ const fd = fs32.openSync(filePath, "r");
8846
8980
  const chunkSize = 64 * 1024;
8847
8981
  let position = stat.size;
8848
8982
  let remainder = "";
@@ -8854,7 +8988,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
8854
8988
  const length = Math.min(chunkSize, position);
8855
8989
  position -= length;
8856
8990
  const buffer = Buffer.alloc(length);
8857
- fs31.readSync(fd, buffer, 0, length, position);
8991
+ fs32.readSync(fd, buffer, 0, length, position);
8858
8992
  let chunk = buffer.toString("utf8");
8859
8993
  if (remainder) {
8860
8994
  chunk += remainder;
@@ -8901,7 +9035,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
8901
9035
  }
8902
9036
  }
8903
9037
  } finally {
8904
- fs31.closeSync(fd);
9038
+ fs32.closeSync(fd);
8905
9039
  }
8906
9040
  return { lines: collected.reverse(), totalLinesCount };
8907
9041
  }
@@ -9587,7 +9721,7 @@ function camelToKebab2(str) {
9587
9721
  }
9588
9722
 
9589
9723
  // src/commands/build/upload-static.handler.ts
9590
- import * as fs32 from "fs";
9724
+ import * as fs33 from "fs";
9591
9725
  import * as os2 from "os";
9592
9726
  import * as path26 from "path";
9593
9727
  import { execFileSync } from "child_process";
@@ -9614,7 +9748,7 @@ async function uploadStatic(options) {
9614
9748
  region = UPLOAD_STATIC_DEFAULTS.region
9615
9749
  } = options;
9616
9750
  const resolvedStaticDir = path26.resolve(staticDir);
9617
- if (!fs32.existsSync(resolvedStaticDir)) {
9751
+ if (!fs33.existsSync(resolvedStaticDir)) {
9618
9752
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
9619
9753
  return;
9620
9754
  }
@@ -9648,7 +9782,7 @@ async function uploadStatic(options) {
9648
9782
  }
9649
9783
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
9650
9784
  const confPath = path26.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
9651
- fs32.writeFileSync(confPath, "");
9785
+ fs33.writeFileSync(confPath, "");
9652
9786
  try {
9653
9787
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
9654
9788
  configureTosutil(resolvedTosutil, confPath, {
@@ -9662,7 +9796,7 @@ async function uploadStatic(options) {
9662
9796
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
9663
9797
  } finally {
9664
9798
  try {
9665
- fs32.unlinkSync(confPath);
9799
+ fs33.unlinkSync(confPath);
9666
9800
  } catch {
9667
9801
  }
9668
9802
  }
@@ -9683,7 +9817,7 @@ async function uploadStatic(options) {
9683
9817
  }
9684
9818
  function resolveTosutilPath(tosutilPath) {
9685
9819
  if (path26.isAbsolute(tosutilPath)) {
9686
- return fs32.existsSync(tosutilPath) ? tosutilPath : null;
9820
+ return fs33.existsSync(tosutilPath) ? tosutilPath : null;
9687
9821
  }
9688
9822
  try {
9689
9823
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -9728,7 +9862,7 @@ async function resolveBucketId(appId) {
9728
9862
  return bucketId;
9729
9863
  }
9730
9864
  function isDirEmpty(dirPath) {
9731
- const entries = fs32.readdirSync(dirPath);
9865
+ const entries = fs33.readdirSync(dirPath);
9732
9866
  return entries.length === 0;
9733
9867
  }
9734
9868
 
@@ -9825,12 +9959,12 @@ var commands = [
9825
9959
  // src/index.ts
9826
9960
  for (const filename of [".env.local", ".env"]) {
9827
9961
  const envPath = path27.join(process.cwd(), filename);
9828
- if (fs33.existsSync(envPath)) {
9962
+ if (fs34.existsSync(envPath)) {
9829
9963
  dotenvConfig({ path: envPath });
9830
9964
  }
9831
9965
  }
9832
9966
  var __dirname = path27.dirname(fileURLToPath5(import.meta.url));
9833
- var pkg = JSON.parse(fs33.readFileSync(path27.join(__dirname, "../package.json"), "utf-8"));
9967
+ var pkg = JSON.parse(fs34.readFileSync(path27.join(__dirname, "../package.json"), "utf-8"));
9834
9968
  var cli = new FullstackCLI(pkg.version);
9835
9969
  cli.useAll(commands);
9836
9970
  cli.run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.71-alpha.20261104100603",
3
+ "version": "1.1.71-alpha.20261104114555",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",