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

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 +284 -147
  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,21 +5148,30 @@ 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) {
5123
5168
  throw new FormCliError(
5124
5169
  FormCliErrorCode.PLUGIN_VERSION_MISMATCH,
5125
- `Plugin ${pluginKey} version mismatch: package.json actionPlugins declares ${declaredVersion}, node_modules has ${installedVersion}. Run "fullstack-cli action-plugin install ${pluginKey}@${declaredVersion}" to re-sync.`,
5126
- { details: { declaredVersion, installedVersion } }
5170
+ `Plugin ${pluginKey} version mismatch: package.json actionPlugins declares ${declaredVersion}, node_modules has ${installedVersion}`,
5171
+ {
5172
+ hint: `To use the declared version, run "fullstack-cli action-plugin install ${pluginKey}@${declaredVersion}"; to keep ${installedVersion}, run "fullstack-cli action-plugin install ${pluginKey}@${installedVersion}" so package.json records it.`,
5173
+ details: { declaredVersion, installedVersion }
5174
+ }
5127
5175
  );
5128
5176
  }
5129
5177
  return installedVersion;
@@ -5147,11 +5195,15 @@ async function resolveInstalledPlugin(pluginKey) {
5147
5195
  } catch (error) {
5148
5196
  throw new FormCliError(
5149
5197
  FormCliErrorCode.PLUGIN_LOAD_FAILED,
5150
- error instanceof Error ? error.message : String(error)
5198
+ `Failed to load plugin ${pluginKey} from node_modules: ${error instanceof Error ? error.message : String(error)}`,
5199
+ {
5200
+ hint: `Reinstall it with "fullstack-cli action-plugin install ${pluginKey}"; if it still fails, the plugin package is broken.`
5201
+ }
5151
5202
  );
5152
5203
  }
5153
5204
  return { key: pluginKey, version, manifest, module };
5154
5205
  }
5206
+ 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
5207
  function hasFormActionSdk(module) {
5156
5208
  return typeof module.runFormAction === "function" && typeof module.validateForm === "function" && typeof module.hasValidateForm === "function";
5157
5209
  }
@@ -5159,7 +5211,8 @@ function assertFormActionSdk(module, pluginKey) {
5159
5211
  if (!hasFormActionSdk(module)) {
5160
5212
  throw new FormCliError(
5161
5213
  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.`
5214
+ `Plugin ${pluginKey} was built with an SDK that has no form action support (runFormAction / validateForm / hasValidateForm missing)`,
5215
+ { hint: SDK_TOO_OLD_HINT(pluginKey) }
5163
5216
  );
5164
5217
  }
5165
5218
  }
@@ -5206,7 +5259,10 @@ function findFormAction(pluginKey, action, formActions) {
5206
5259
  throw new FormCliError(
5207
5260
  FormCliErrorCode.FORM_ACTION_NOT_FOUND,
5208
5261
  `Form action "${action}" not found in plugin ${pluginKey}. Available: ${keys.length ? keys.join(", ") : "(none)"}`,
5209
- { details: { available: keys } }
5262
+ {
5263
+ 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.`,
5264
+ details: { available: keys }
5265
+ }
5210
5266
  );
5211
5267
  }
5212
5268
  return found;
@@ -5324,11 +5380,11 @@ function parseOutputFormat(raw) {
5324
5380
  `--format must be json or pretty, got: ${raw}`
5325
5381
  );
5326
5382
  }
5327
- function finishWithFailure(error) {
5383
+ function finishWithFailure(error, pluginErrorHint) {
5328
5384
  if (process.env.DEBUG && error instanceof Error) {
5329
5385
  console.error(error.stack);
5330
5386
  }
5331
- finishWithJson(toFailureOutput(error, "EXECUTION_ERROR"), 1);
5387
+ finishWithJson(toFailureOutput(error, "EXECUTION_ERROR", pluginErrorHint), 1);
5332
5388
  }
5333
5389
  async function formActionList(options) {
5334
5390
  try {
@@ -5368,7 +5424,10 @@ async function formActionExecute(options) {
5368
5424
  });
5369
5425
  finishWithJson(result, 0);
5370
5426
  } catch (error) {
5371
- finishWithFailure(error);
5427
+ finishWithFailure(
5428
+ error,
5429
+ (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
5430
+ );
5372
5431
  }
5373
5432
  }
5374
5433
 
@@ -5533,31 +5592,72 @@ var listCommand = {
5533
5592
  });
5534
5593
  }
5535
5594
  };
5536
- var FORMAT_OPTION_DESC = "Output format: json (default) | pretty";
5595
+ var FORMAT_OPTION_DESC = "Output format: json (default) or pretty";
5537
5596
  var JSON_ARG_HINT = "inline JSON, @<file>, or - for stdin";
5597
+ var PLUGIN_OPTION_DESC = "(required) Plugin key, e.g. @office/feishu-bitable";
5598
+ var ACTION_OPTION_DESC = "(required) Form action key or alias from form-action-list, e.g. getTableFields or get-table-fields";
5538
5599
  var formActionListCommand = {
5539
5600
  name: "form-action-list",
5540
- description: "List the form actions (config-time queries) of an installed plugin",
5601
+ description: "List the form actions of an installed plugin (queries used while configuring it, e.g. search bases, list tables)",
5541
5602
  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) => {
5603
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--plugin <key>", PLUGIN_OPTION_DESC).option("--format <format>", FORMAT_OPTION_DESC).addHelpText(
5604
+ "after",
5605
+ `
5606
+ Reads the local plugin manifest only; no credential needed.
5607
+ Output: {key, version, formActions: [{key, alias, title, description}], hasValidateForm}
5608
+ Next: run form-action-get to see an action's input schema.
5609
+
5610
+ Example:
5611
+ fullstack-cli action-plugin form-action-list --plugin @office/feishu-bitable`
5612
+ ).action(async (options) => {
5543
5613
  await formActionList(options);
5544
5614
  });
5545
5615
  }
5546
5616
  };
5547
5617
  var formActionGetCommand = {
5548
5618
  name: "form-action-get",
5549
- description: "Show the input / output schema of a plugin form action",
5619
+ description: "Show the input and output schema of a plugin form action",
5550
5620
  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) => {
5621
+ 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(
5622
+ "after",
5623
+ `
5624
+ Reads the local plugin manifest only; no credential needed.
5625
+ Output: {key, version, action: {key, alias, title, description, inputSchema, outputSchema}}
5626
+ Next: build --input from inputSchema and run form-action-execute.
5627
+
5628
+ Example:
5629
+ fullstack-cli action-plugin form-action-get --plugin @office/feishu-bitable --action list-tables`
5630
+ ).action(async (options) => {
5552
5631
  await formActionGet(options);
5553
5632
  });
5554
5633
  }
5555
5634
  };
5556
5635
  var formActionExecuteCommand = {
5557
5636
  name: "form-action-execute",
5558
- description: "Execute a plugin form action (e.g., list tables) and print its JSON result",
5637
+ description: "Run a plugin form action (e.g. list tables) and print the result as JSON",
5559
5638
  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) => {
5639
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--plugin <key>", PLUGIN_OPTION_DESC).requiredOption("--action <name>", ACTION_OPTION_DESC).requiredOption(
5640
+ "--input <json>",
5641
+ `(required) Action input matching the action's inputSchema: ${JSON_ARG_HINT}`
5642
+ ).option(
5643
+ "--id <id>",
5644
+ "Existing capability ID; the plugin sees that instance's saved form value (e.g. to keep the user's previous choices)"
5645
+ ).option(
5646
+ "--form-value <json>",
5647
+ `Unsaved form value for the plugin to see instead of the saved one (JSON object; wins over --id): ${JSON_ARG_HINT}`
5648
+ ).option("--timeout <ms>", "Timeout in milliseconds (default: 60000)").addHelpText(
5649
+ "after",
5650
+ `
5651
+ Requires the operator credential MIAODA_AUTHN_CODE, which the platform injects when the
5652
+ command runs through agent_tool; it cannot run in a plain terminal.
5653
+ Output: on success, the plugin's result JSON (exit 0); on failure,
5654
+ {ok: false, code, message, hint?, details?} (exit 1). Logs go to stderr.
5655
+ At most one of --input / --form-value can read from stdin (-).
5656
+
5657
+ Examples:
5658
+ fullstack-cli action-plugin form-action-execute --plugin @office/feishu-bitable --action search-apps --input '{"keyword":"tasks"}'
5659
+ fullstack-cli action-plugin form-action-execute --plugin @office/feishu-bitable --action get-table-fields --input @./input.json --id bitable_tasks`
5660
+ ).action(async (options) => {
5561
5661
  await formActionExecute(options);
5562
5662
  });
5563
5663
  }
@@ -5664,6 +5764,7 @@ function isLegacyManifest(manifest) {
5664
5764
  function isRecord(value) {
5665
5765
  return !!value && typeof value === "object" && !Array.isArray(value);
5666
5766
  }
5767
+ 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
5768
  function normalizeIssue(issue) {
5668
5769
  if (!isRecord(issue)) {
5669
5770
  return void 0;
@@ -5688,7 +5789,8 @@ function normalizeResult(raw) {
5688
5789
  if (!isRecord(raw) || typeof raw.success !== "boolean" || raw.issues !== void 0 && !Array.isArray(raw.issues)) {
5689
5790
  throw new FormCliError(
5690
5791
  FormCliErrorCode.VALIDATION_EXECUTION_FAILED,
5691
- "validateForm returned an unexpected shape: expected { success: boolean, issues?: FormIssue[] }"
5792
+ "validateForm returned an unexpected shape: expected { success: boolean, issues?: FormIssue[] }",
5793
+ { hint: PLUGIN_BUG_HINT }
5692
5794
  );
5693
5795
  }
5694
5796
  const rawIssues = raw.issues ?? [];
@@ -5698,7 +5800,7 @@ function normalizeResult(raw) {
5698
5800
  throw new FormCliError(
5699
5801
  FormCliErrorCode.VALIDATION_EXECUTION_FAILED,
5700
5802
  `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 } }
5803
+ { hint: PLUGIN_BUG_HINT, details: { issue: rawIssue } }
5702
5804
  );
5703
5805
  }
5704
5806
  return issue;
@@ -5721,6 +5823,7 @@ async function runValidate(options) {
5721
5823
  ok: false,
5722
5824
  code: FormCliErrorCode.INVALID_INPUT,
5723
5825
  message: `form value does not match plugin ${options.plugin} config schema (${issues.length} issue(s))`,
5826
+ hint: "Fix the fields listed in issues (path is a JSON Pointer into the form value) and run again.",
5724
5827
  issues,
5725
5828
  validated: false,
5726
5829
  pluginVersion
@@ -5735,7 +5838,8 @@ async function runValidate(options) {
5735
5838
  if (manifestClaims && (!sdkReady || typeof module.validateForm !== "function")) {
5736
5839
  throw new FormCliError(
5737
5840
  FormCliErrorCode.VALIDATION_EXECUTION_FAILED,
5738
- `Plugin ${options.plugin} manifest declares hasValidateForm but the loaded module has no validateForm`
5841
+ `Plugin ${options.plugin} manifest declares hasValidateForm but the loaded module has no validateForm`,
5842
+ { hint: PLUGIN_BUG_HINT }
5739
5843
  );
5740
5844
  }
5741
5845
  let pluginHas = false;
@@ -5744,13 +5848,15 @@ async function runValidate(options) {
5744
5848
  } else if (!isLegacyManifest(manifest)) {
5745
5849
  throw new FormCliError(
5746
5850
  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.`
5851
+ `Plugin ${options.plugin} manifest has form action fields but the module lacks runFormAction / validateForm / hasValidateForm`,
5852
+ { hint: SDK_TOO_OLD_HINT(options.plugin) }
5748
5853
  );
5749
5854
  }
5750
5855
  if (manifestClaims && !pluginHas) {
5751
5856
  throw new FormCliError(
5752
5857
  FormCliErrorCode.VALIDATION_EXECUTION_FAILED,
5753
- `Plugin ${options.plugin} manifest declares hasValidateForm but plugin.hasValidateForm() returned false`
5858
+ `Plugin ${options.plugin} manifest declares hasValidateForm but plugin.hasValidateForm() returned false`,
5859
+ { hint: PLUGIN_BUG_HINT }
5754
5860
  );
5755
5861
  }
5756
5862
  if (!pluginHas) {
@@ -5786,7 +5892,10 @@ async function runValidate(options) {
5786
5892
  throw new FormCliError(
5787
5893
  FormCliErrorCode.VALIDATION_EXECUTION_FAILED,
5788
5894
  `validateForm of ${options.plugin} threw: ${cause.message}`,
5789
- { details: { cause } }
5895
+ {
5896
+ 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.",
5897
+ details: { cause }
5898
+ }
5790
5899
  );
5791
5900
  }
5792
5901
  const output = {
@@ -5799,6 +5908,7 @@ async function runValidate(options) {
5799
5908
  if (!checked.success) {
5800
5909
  output.code = FormCliErrorCode.VALIDATION_FAILED;
5801
5910
  output.message = checked.issues[0]?.message ?? `plugin ${options.plugin} validateForm did not pass`;
5911
+ 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
5912
  }
5803
5913
  return output;
5804
5914
  }
@@ -5818,7 +5928,7 @@ async function validate(options) {
5818
5928
  }
5819
5929
 
5820
5930
  // src/commands/capability/write.handler.ts
5821
- import fs19 from "fs";
5931
+ import fs20 from "fs";
5822
5932
  import path15 from "path";
5823
5933
  var CAPABILITY_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
5824
5934
  var CREATED_BY_PLACEHOLDER = "__fullstack_cli_created_by__";
@@ -5847,7 +5957,7 @@ function toProjectRelative(absolutePath) {
5847
5957
  function readPluginIcon(pluginKey) {
5848
5958
  try {
5849
5959
  const pkg2 = JSON.parse(
5850
- fs19.readFileSync(
5960
+ fs20.readFileSync(
5851
5961
  path15.join(getPluginPath(pluginKey), "package.json"),
5852
5962
  "utf-8"
5853
5963
  )
@@ -5866,30 +5976,33 @@ function serializeCapability(record, createdByToken) {
5866
5976
  }
5867
5977
  function writeAtomically(filePath, content, options) {
5868
5978
  const dir = path15.dirname(filePath);
5869
- fs19.mkdirSync(dir, { recursive: true });
5979
+ fs20.mkdirSync(dir, { recursive: true });
5870
5980
  const tmp = path15.join(
5871
5981
  dir,
5872
5982
  `.${path15.basename(filePath)}.${process.pid}.${Date.now()}.tmp`
5873
5983
  );
5874
- fs19.writeFileSync(tmp, content);
5984
+ fs20.writeFileSync(tmp, content);
5875
5985
  try {
5876
5986
  if (options.exclusive) {
5877
5987
  try {
5878
- fs19.linkSync(tmp, filePath);
5988
+ fs20.linkSync(tmp, filePath);
5879
5989
  } catch (error) {
5880
5990
  if (error.code === "EEXIST") {
5881
5991
  throw new FormCliError(
5882
5992
  FormCliErrorCode.INSTANCE_EXISTS,
5883
- `Capability file ${toProjectRelative(filePath)} was created concurrently; use "capability update" to modify it`
5993
+ `Capability file ${toProjectRelative(filePath)} was created concurrently`,
5994
+ {
5995
+ hint: 'Use "fullstack-cli capability update" to modify it, or pick another --id.'
5996
+ }
5884
5997
  );
5885
5998
  }
5886
5999
  throw error;
5887
6000
  }
5888
6001
  } else {
5889
- fs19.renameSync(tmp, filePath);
6002
+ fs20.renameSync(tmp, filePath);
5890
6003
  }
5891
6004
  } finally {
5892
- fs19.rmSync(tmp, { force: true });
6005
+ fs20.rmSync(tmp, { force: true });
5893
6006
  }
5894
6007
  }
5895
6008
  function readParamsSchema(raw) {
@@ -5916,10 +6029,13 @@ async function runCreate(options) {
5916
6029
  );
5917
6030
  }
5918
6031
  const filePath = capabilityFilePath(options.id);
5919
- if (fs19.existsSync(filePath)) {
6032
+ if (fs20.existsSync(filePath)) {
5920
6033
  throw new FormCliError(
5921
6034
  FormCliErrorCode.INSTANCE_EXISTS,
5922
- `Capability ${options.id} already exists at ${toProjectRelative(filePath)}; use "capability update" to modify it`
6035
+ `Capability ${options.id} already exists at ${toProjectRelative(filePath)}`,
6036
+ {
6037
+ hint: 'Use "fullstack-cli capability update" to modify it, or pick another --id.'
6038
+ }
5923
6039
  );
5924
6040
  }
5925
6041
  assertSingleStdinArg({
@@ -5957,13 +6073,16 @@ async function runCreate(options) {
5957
6073
  async function runUpdate(options) {
5958
6074
  assertValidId(options.id);
5959
6075
  const filePath = capabilityFilePath(options.id);
5960
- if (!fs19.existsSync(filePath)) {
6076
+ if (!fs20.existsSync(filePath)) {
5961
6077
  throw new FormCliError(
5962
6078
  FormCliErrorCode.INSTANCE_NOT_FOUND,
5963
- `Capability ${options.id} not found at ${toProjectRelative(filePath)}; use "capability create" to create it`
6079
+ `Capability ${options.id} not found at ${toProjectRelative(filePath)}`,
6080
+ {
6081
+ hint: 'Check the id with "fullstack-cli capability list --summary", or use "fullstack-cli capability create" to create it.'
6082
+ }
5964
6083
  );
5965
6084
  }
5966
- const rawText = fs19.readFileSync(filePath, "utf-8");
6085
+ const rawText = fs20.readFileSync(filePath, "utf-8");
5967
6086
  let existing;
5968
6087
  try {
5969
6088
  const parsed = JSON.parse(rawText);
@@ -6055,22 +6174,31 @@ var getCommand = {
6055
6174
  });
6056
6175
  }
6057
6176
  };
6177
+ var PLUGIN_OPTION_DESC2 = "(required) Plugin key, e.g. @office/feishu-bitable";
6178
+ var TIMEOUT_OPTION_DESC = "Timeout for the plugin's validateForm in milliseconds (default: 60000)";
6179
+ var WRITE_OUTPUT_HELP = `Output: {ok, id, path, pluginVersion, validated, issues, affectedFilePaths} (exit 0);
6180
+ when the check fails, the same output as "capability validate" and nothing is written (exit 1).
6181
+ Requires MIAODA_AUTHN_CODE only when the plugin defines validateForm.`;
6058
6182
  var validateCommand = {
6059
6183
  name: "validate",
6060
- description: "Validate a capability form value with the plugin (config schema + validateForm)",
6184
+ description: "Check a form value before saving: the plugin's config schema, then the plugin's own validateForm. Writes nothing",
6061
6185
  register(program) {
6062
- program.command(this.name).description(this.description).requiredOption(
6063
- "--plugin <key>",
6064
- "Plugin key (e.g., @office/feishu-bitable)"
6065
- ).requiredOption(
6186
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--plugin <key>", PLUGIN_OPTION_DESC2).requiredOption(
6066
6187
  "--form-value <json>",
6067
- `Full form value to save: ${JSON_ARG_HINT2}`
6188
+ `(required) Complete form value to check (JSON object): ${JSON_ARG_HINT2}`
6068
6189
  ).option(
6069
6190
  "--id <id>",
6070
- "Existing capability ID when modifying (omit when creating)"
6071
- ).option(
6072
- "--timeout <ms>",
6073
- "Timeout for validateForm in milliseconds (default: 60000)"
6191
+ "Existing capability ID when modifying; its saved form value is passed to the plugin as the previous value. Omit when creating"
6192
+ ).option("--timeout <ms>", TIMEOUT_OPTION_DESC).addHelpText(
6193
+ "after",
6194
+ `
6195
+ Output: {ok, validated, pluginVersion, issues, normalizedFormValue} (exit 0); when the check fails,
6196
+ ok: false with code VALIDATION_FAILED or INVALID_INPUT, plus issues and hint (exit 1).
6197
+ validated: false means the plugin has no validateForm, so only the schema check ran.
6198
+ Requires MIAODA_AUTHN_CODE only when the plugin defines validateForm.
6199
+
6200
+ Example:
6201
+ fullstack-cli capability validate --plugin @office/feishu-bitable --form-value @./form.json`
6074
6202
  ).action(
6075
6203
  async (options) => {
6076
6204
  await validate(options);
@@ -6080,23 +6208,26 @@ var validateCommand = {
6080
6208
  };
6081
6209
  var createCommand = {
6082
6210
  name: "create",
6083
- description: 'Create a capability instance file after passing "capability validate" (not written if any error issue)',
6211
+ description: 'Create a capability instance; runs the same checks as "capability validate" first and writes nothing if they fail',
6084
6212
  register(program) {
6085
- program.command(this.name).description(this.description).requiredOption(
6086
- "--plugin <key>",
6087
- "Plugin key (e.g., @office/feishu-bitable)"
6088
- ).requiredOption(
6213
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--plugin <key>", PLUGIN_OPTION_DESC2).requiredOption(
6089
6214
  "--id <id>",
6090
- 'New capability ID (letters, digits, "_" and "-")'
6091
- ).requiredOption("--name <name>", "Capability display name").requiredOption(
6215
+ '(required) New capability ID: letters, digits, "_" and "-", starting with a letter or digit, max 128'
6216
+ ).requiredOption("--name <name>", "(required) Display name").requiredOption(
6092
6217
  "--form-value <json>",
6093
- `Full form value: ${JSON_ARG_HINT2}`
6094
- ).option("--description <text>", "Capability description").option(
6218
+ `(required) Complete form value (JSON object): ${JSON_ARG_HINT2}`
6219
+ ).option("--description <text>", "Description (default: empty)").option(
6095
6220
  "--params-schema <json>",
6096
- `paramsSchema (default: {}): ${JSON_ARG_HINT2}`
6097
- ).option(
6098
- "--timeout <ms>",
6099
- "Timeout for validateForm in milliseconds (default: 60000)"
6221
+ `paramsSchema (JSON object, default: {}): ${JSON_ARG_HINT2}`
6222
+ ).option("--timeout <ms>", TIMEOUT_OPTION_DESC).addHelpText(
6223
+ "after",
6224
+ `
6225
+ Writes <CAPABILITIES_DIR>/<id>.json (default: shared/capabilities if it exists, else server/capabilities).
6226
+ Fails with INSTANCE_EXISTS when the id is taken.
6227
+ ${WRITE_OUTPUT_HELP}
6228
+
6229
+ Example:
6230
+ fullstack-cli capability create --plugin @office/feishu-bitable --id bitable_tasks --name Tasks --form-value @./form.json`
6100
6231
  ).action(async (options) => {
6101
6232
  await create(options);
6102
6233
  });
@@ -6104,17 +6235,23 @@ var createCommand = {
6104
6235
  };
6105
6236
  var updateCommand2 = {
6106
6237
  name: "update",
6107
- description: 'Update an existing capability instance after passing "capability validate" (not written if any error issue)',
6238
+ description: 'Update an existing capability instance; runs the same checks as "capability validate" first and writes nothing if they fail',
6108
6239
  register(program) {
6109
- program.command(this.name).description(this.description).requiredOption("--id <id>", "Existing capability ID").requiredOption(
6240
+ outputParseErrorsAsJson(program.command(this.name)).description(this.description).requiredOption("--id <id>", "(required) Existing capability ID").requiredOption(
6110
6241
  "--form-value <json>",
6111
- `Full new form value: ${JSON_ARG_HINT2}`
6242
+ `(required) Complete new form value (JSON object), replacing the saved one: ${JSON_ARG_HINT2}`
6112
6243
  ).option("--name <name>", "New display name (kept when omitted)").option("--description <text>", "New description (kept when omitted)").option(
6113
6244
  "--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)"
6245
+ `New paramsSchema (JSON object, kept when omitted): ${JSON_ARG_HINT2}`
6246
+ ).option("--timeout <ms>", TIMEOUT_OPTION_DESC).addHelpText(
6247
+ "after",
6248
+ `
6249
+ The plugin key comes from the existing instance file; other fields such as createdAt are kept.
6250
+ Fails with INSTANCE_NOT_FOUND when the id does not exist.
6251
+ ${WRITE_OUTPUT_HELP}
6252
+
6253
+ Example:
6254
+ fullstack-cli capability update --id bitable_tasks --form-value @./form.json`
6118
6255
  ).action(async (options) => {
6119
6256
  await update2(options);
6120
6257
  });
@@ -6136,7 +6273,7 @@ var capabilityCommandGroup = {
6136
6273
  import { execFile } from "child_process";
6137
6274
 
6138
6275
  // src/commands/component/registry-preparer.ts
6139
- import fs20 from "fs";
6276
+ import fs21 from "fs";
6140
6277
  import path16 from "path";
6141
6278
  import os from "os";
6142
6279
 
@@ -6212,8 +6349,8 @@ function getLocalRegistryPath(key) {
6212
6349
  return path16.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
6213
6350
  }
6214
6351
  function ensureDir(dirPath) {
6215
- if (!fs20.existsSync(dirPath)) {
6216
- fs20.mkdirSync(dirPath, { recursive: true });
6352
+ if (!fs21.existsSync(dirPath)) {
6353
+ fs21.mkdirSync(dirPath, { recursive: true });
6217
6354
  }
6218
6355
  }
6219
6356
  async function prepareRecursive(key, visited) {
@@ -6247,7 +6384,7 @@ async function prepareRecursive(key, visited) {
6247
6384
  };
6248
6385
  const localPath = getLocalRegistryPath(key);
6249
6386
  ensureDir(path16.dirname(localPath));
6250
- fs20.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
6387
+ fs21.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
6251
6388
  debug("\u4FDD\u5B58\u5230: %s", localPath);
6252
6389
  }
6253
6390
  async function prepareComponentRegistryItems(id) {
@@ -6257,18 +6394,18 @@ async function prepareComponentRegistryItems(id) {
6257
6394
  }
6258
6395
  function cleanupTempDir() {
6259
6396
  try {
6260
- if (fs20.existsSync(REGISTRY_TEMP_DIR)) {
6261
- fs20.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
6397
+ if (fs21.existsSync(REGISTRY_TEMP_DIR)) {
6398
+ fs21.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
6262
6399
  }
6263
6400
  } catch {
6264
6401
  }
6265
6402
  }
6266
6403
  function getDownloadedRegistryItem(itemId) {
6267
6404
  const localPath = getLocalRegistryPath(itemId);
6268
- if (!fs20.existsSync(localPath)) {
6405
+ if (!fs21.existsSync(localPath)) {
6269
6406
  return null;
6270
6407
  }
6271
- const content = fs20.readFileSync(localPath, "utf-8");
6408
+ const content = fs21.readFileSync(localPath, "utf-8");
6272
6409
  return JSON.parse(content);
6273
6410
  }
6274
6411
 
@@ -6436,7 +6573,7 @@ var componentCommandGroup = {
6436
6573
  };
6437
6574
 
6438
6575
  // src/commands/migration/version-manager.ts
6439
- import fs21 from "fs";
6576
+ import fs22 from "fs";
6440
6577
  import path17 from "path";
6441
6578
  var PACKAGE_JSON = "package.json";
6442
6579
  var VERSION_FIELD = "migrationVersion";
@@ -6445,25 +6582,25 @@ function getPackageJsonPath2() {
6445
6582
  }
6446
6583
  function getCurrentVersion() {
6447
6584
  const pkgPath = getPackageJsonPath2();
6448
- if (!fs21.existsSync(pkgPath)) {
6585
+ if (!fs22.existsSync(pkgPath)) {
6449
6586
  throw new Error("package.json not found");
6450
6587
  }
6451
- const pkg2 = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
6588
+ const pkg2 = JSON.parse(fs22.readFileSync(pkgPath, "utf-8"));
6452
6589
  return pkg2[VERSION_FIELD] ?? 0;
6453
6590
  }
6454
6591
  function setCurrentVersion(version) {
6455
6592
  const pkgPath = getPackageJsonPath2();
6456
- const pkg2 = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
6593
+ const pkg2 = JSON.parse(fs22.readFileSync(pkgPath, "utf-8"));
6457
6594
  pkg2[VERSION_FIELD] = version;
6458
- fs21.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
6595
+ fs22.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
6459
6596
  }
6460
6597
 
6461
6598
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
6462
- import fs23 from "fs";
6599
+ import fs24 from "fs";
6463
6600
  import path19 from "path";
6464
6601
 
6465
6602
  // src/commands/migration/versions/v001_capability/utils.ts
6466
- import fs22 from "fs";
6603
+ import fs23 from "fs";
6467
6604
  import path18 from "path";
6468
6605
  var CAPABILITIES_DIR2 = "server/capabilities";
6469
6606
  function getProjectRoot3() {
@@ -6480,14 +6617,14 @@ function getPluginManifestPath2(pluginKey) {
6480
6617
  function detectJsonMigration() {
6481
6618
  const capabilitiesDir = getCapabilitiesDir2();
6482
6619
  const oldFilePath = path19.join(capabilitiesDir, "capabilities.json");
6483
- if (!fs23.existsSync(oldFilePath)) {
6620
+ if (!fs24.existsSync(oldFilePath)) {
6484
6621
  return {
6485
6622
  needsMigration: false,
6486
6623
  reason: "capabilities.json not found"
6487
6624
  };
6488
6625
  }
6489
6626
  try {
6490
- const content = fs23.readFileSync(oldFilePath, "utf-8");
6627
+ const content = fs24.readFileSync(oldFilePath, "utf-8");
6491
6628
  const parsed = JSON.parse(content);
6492
6629
  if (!Array.isArray(parsed)) {
6493
6630
  return {
@@ -6538,7 +6675,7 @@ async function check(options) {
6538
6675
  }
6539
6676
 
6540
6677
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
6541
- import fs24 from "fs";
6678
+ import fs25 from "fs";
6542
6679
  import path20 from "path";
6543
6680
 
6544
6681
  // src/commands/migration/versions/v001_capability/mapping.ts
@@ -6769,10 +6906,10 @@ function transformCapabilities(oldCapabilities) {
6769
6906
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
6770
6907
  function loadExistingCapabilities() {
6771
6908
  const capabilitiesDir = getCapabilitiesDir2();
6772
- if (!fs24.existsSync(capabilitiesDir)) {
6909
+ if (!fs25.existsSync(capabilitiesDir)) {
6773
6910
  return [];
6774
6911
  }
6775
- const files = fs24.readdirSync(capabilitiesDir);
6912
+ const files = fs25.readdirSync(capabilitiesDir);
6776
6913
  const capabilities = [];
6777
6914
  for (const file of files) {
6778
6915
  if (file === "capabilities.json" || !file.endsWith(".json")) {
@@ -6780,7 +6917,7 @@ function loadExistingCapabilities() {
6780
6917
  }
6781
6918
  try {
6782
6919
  const filePath = path20.join(capabilitiesDir, file);
6783
- const content = fs24.readFileSync(filePath, "utf-8");
6920
+ const content = fs25.readFileSync(filePath, "utf-8");
6784
6921
  const capability = JSON.parse(content);
6785
6922
  if (capability.id && capability.pluginKey) {
6786
6923
  capabilities.push(capability);
@@ -6840,7 +6977,7 @@ async function migrateJsonFiles(options) {
6840
6977
  for (const cap of newCapabilities) {
6841
6978
  const filePath = path20.join(capabilitiesDir, `${cap.id}.json`);
6842
6979
  const content = JSON.stringify(cap, null, 2);
6843
- fs24.writeFileSync(filePath, content, "utf-8");
6980
+ fs25.writeFileSync(filePath, content, "utf-8");
6844
6981
  console.log(` \u2713 Created: ${cap.id}.json`);
6845
6982
  }
6846
6983
  return {
@@ -6852,11 +6989,11 @@ async function migrateJsonFiles(options) {
6852
6989
  }
6853
6990
 
6854
6991
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
6855
- import fs25 from "fs";
6992
+ import fs26 from "fs";
6856
6993
  function isPluginInstalled2(pluginKey) {
6857
6994
  const actionPlugins = readActionPlugins();
6858
6995
  const manifestPath = getPluginManifestPath2(pluginKey);
6859
- return fs25.existsSync(manifestPath) && !!actionPlugins[pluginKey];
6996
+ return fs26.existsSync(manifestPath) && !!actionPlugins[pluginKey];
6860
6997
  }
6861
6998
  function detectPluginsToInstall(capabilities) {
6862
6999
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -6936,7 +7073,7 @@ import path22 from "path";
6936
7073
  import { Project as Project3 } from "ts-morph";
6937
7074
 
6938
7075
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
6939
- import fs26 from "fs";
7076
+ import fs27 from "fs";
6940
7077
  import path21 from "path";
6941
7078
  var EXCLUDED_DIRS = [
6942
7079
  "node_modules",
@@ -6952,7 +7089,7 @@ var EXCLUDED_PATTERNS = [
6952
7089
  /\.d\.ts$/
6953
7090
  ];
6954
7091
  function scanDirectory(dir, files = []) {
6955
- const entries = fs26.readdirSync(dir, { withFileTypes: true });
7092
+ const entries = fs27.readdirSync(dir, { withFileTypes: true });
6956
7093
  for (const entry of entries) {
6957
7094
  const fullPath = path21.join(dir, entry.name);
6958
7095
  if (entry.isDirectory()) {
@@ -6971,13 +7108,13 @@ function scanDirectory(dir, files = []) {
6971
7108
  }
6972
7109
  function scanServerFiles() {
6973
7110
  const serverDir = path21.join(getProjectRoot3(), "server");
6974
- if (!fs26.existsSync(serverDir)) {
7111
+ if (!fs27.existsSync(serverDir)) {
6975
7112
  return [];
6976
7113
  }
6977
7114
  return scanDirectory(serverDir);
6978
7115
  }
6979
7116
  function hasCapabilityImport(filePath) {
6980
- const content = fs26.readFileSync(filePath, "utf-8");
7117
+ const content = fs27.readFileSync(filePath, "utf-8");
6981
7118
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
6982
7119
  }
6983
7120
  function scanFilesToMigrate() {
@@ -7468,17 +7605,17 @@ function getSuggestion(analysis) {
7468
7605
  }
7469
7606
 
7470
7607
  // src/commands/migration/versions/v001_capability/cleanup.ts
7471
- import fs27 from "fs";
7608
+ import fs28 from "fs";
7472
7609
  import path23 from "path";
7473
7610
  function cleanupOldFiles(capabilities, dryRun) {
7474
7611
  const deletedFiles = [];
7475
7612
  const errors = [];
7476
7613
  const capabilitiesDir = getCapabilitiesDir2();
7477
7614
  const oldJsonPath = path23.join(capabilitiesDir, "capabilities.json");
7478
- if (fs27.existsSync(oldJsonPath)) {
7615
+ if (fs28.existsSync(oldJsonPath)) {
7479
7616
  try {
7480
7617
  if (!dryRun) {
7481
- fs27.unlinkSync(oldJsonPath);
7618
+ fs28.unlinkSync(oldJsonPath);
7482
7619
  }
7483
7620
  deletedFiles.push("capabilities.json");
7484
7621
  } catch (error) {
@@ -7487,10 +7624,10 @@ function cleanupOldFiles(capabilities, dryRun) {
7487
7624
  }
7488
7625
  for (const cap of capabilities) {
7489
7626
  const tsFilePath = path23.join(capabilitiesDir, `${cap.id}.ts`);
7490
- if (fs27.existsSync(tsFilePath)) {
7627
+ if (fs28.existsSync(tsFilePath)) {
7491
7628
  try {
7492
7629
  if (!dryRun) {
7493
- fs27.unlinkSync(tsFilePath);
7630
+ fs28.unlinkSync(tsFilePath);
7494
7631
  }
7495
7632
  deletedFiles.push(`${cap.id}.ts`);
7496
7633
  } catch (error) {
@@ -7506,7 +7643,7 @@ function cleanupOldFiles(capabilities, dryRun) {
7506
7643
  }
7507
7644
 
7508
7645
  // src/commands/migration/versions/v001_capability/report-generator.ts
7509
- import fs28 from "fs";
7646
+ import fs29 from "fs";
7510
7647
  import path24 from "path";
7511
7648
  var REPORT_FILE = "capability-migration-report.md";
7512
7649
  function printSummary(result) {
@@ -7670,15 +7807,15 @@ async function generateReport(result) {
7670
7807
  }
7671
7808
  lines.push("");
7672
7809
  const logDir = process.env.LOG_DIR || "logs";
7673
- if (!fs28.existsSync(logDir)) {
7810
+ if (!fs29.existsSync(logDir)) {
7674
7811
  return;
7675
7812
  }
7676
7813
  const reportDir = path24.join(logDir, "migration");
7677
- if (!fs28.existsSync(reportDir)) {
7678
- fs28.mkdirSync(reportDir, { recursive: true });
7814
+ if (!fs29.existsSync(reportDir)) {
7815
+ fs29.mkdirSync(reportDir, { recursive: true });
7679
7816
  }
7680
7817
  const reportPath = path24.join(reportDir, REPORT_FILE);
7681
- fs28.writeFileSync(reportPath, lines.join("\n"), "utf-8");
7818
+ fs29.writeFileSync(reportPath, lines.join("\n"), "utf-8");
7682
7819
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
7683
7820
  }
7684
7821
 
@@ -8213,7 +8350,7 @@ var migrationCommand = {
8213
8350
  import path25 from "path";
8214
8351
 
8215
8352
  // src/commands/read-logs/std-utils.ts
8216
- import fs29 from "fs";
8353
+ import fs30 from "fs";
8217
8354
  function formatStdPrefixTime(localTime) {
8218
8355
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
8219
8356
  if (!match) return localTime;
@@ -8243,11 +8380,11 @@ function stripPrefixFromStdLine(line) {
8243
8380
  return `[${time}] ${content}`;
8244
8381
  }
8245
8382
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
8246
- const stat = fs29.statSync(filePath);
8383
+ const stat = fs30.statSync(filePath);
8247
8384
  if (stat.size === 0) {
8248
8385
  return { lines: [], markerFound: false, totalLinesCount: 0 };
8249
8386
  }
8250
- const fd = fs29.openSync(filePath, "r");
8387
+ const fd = fs30.openSync(filePath, "r");
8251
8388
  const chunkSize = 64 * 1024;
8252
8389
  let position = stat.size;
8253
8390
  let remainder = "";
@@ -8261,7 +8398,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
8261
8398
  const length = Math.min(chunkSize, position);
8262
8399
  position -= length;
8263
8400
  const buffer = Buffer.alloc(length);
8264
- fs29.readSync(fd, buffer, 0, length, position);
8401
+ fs30.readSync(fd, buffer, 0, length, position);
8265
8402
  let chunk = buffer.toString("utf8");
8266
8403
  if (remainder) {
8267
8404
  chunk += remainder;
@@ -8303,7 +8440,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
8303
8440
  }
8304
8441
  }
8305
8442
  } finally {
8306
- fs29.closeSync(fd);
8443
+ fs30.closeSync(fd);
8307
8444
  }
8308
8445
  return { lines: collected.reverse(), markerFound, totalLinesCount };
8309
8446
  }
@@ -8324,21 +8461,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
8324
8461
  }
8325
8462
 
8326
8463
  // src/commands/read-logs/tail.ts
8327
- import fs30 from "fs";
8464
+ import fs31 from "fs";
8328
8465
  function fileExists(filePath) {
8329
8466
  try {
8330
- fs30.accessSync(filePath, fs30.constants.F_OK | fs30.constants.R_OK);
8467
+ fs31.accessSync(filePath, fs31.constants.F_OK | fs31.constants.R_OK);
8331
8468
  return true;
8332
8469
  } catch {
8333
8470
  return false;
8334
8471
  }
8335
8472
  }
8336
8473
  function readFileTailLines(filePath, maxLines) {
8337
- const stat = fs30.statSync(filePath);
8474
+ const stat = fs31.statSync(filePath);
8338
8475
  if (stat.size === 0) {
8339
8476
  return [];
8340
8477
  }
8341
- const fd = fs30.openSync(filePath, "r");
8478
+ const fd = fs31.openSync(filePath, "r");
8342
8479
  const chunkSize = 64 * 1024;
8343
8480
  const chunks = [];
8344
8481
  let position = stat.size;
@@ -8348,13 +8485,13 @@ function readFileTailLines(filePath, maxLines) {
8348
8485
  const length = Math.min(chunkSize, position);
8349
8486
  position -= length;
8350
8487
  const buffer = Buffer.alloc(length);
8351
- fs30.readSync(fd, buffer, 0, length, position);
8488
+ fs31.readSync(fd, buffer, 0, length, position);
8352
8489
  chunks.unshift(buffer.toString("utf8"));
8353
8490
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
8354
8491
  collectedLines += chunkLines;
8355
8492
  }
8356
8493
  } finally {
8357
- fs30.closeSync(fd);
8494
+ fs31.closeSync(fd);
8358
8495
  }
8359
8496
  const content = chunks.join("");
8360
8497
  const allLines = content.split("\n");
@@ -8370,11 +8507,11 @@ function readFileTailLines(filePath, maxLines) {
8370
8507
  return allLines.slice(allLines.length - maxLines);
8371
8508
  }
8372
8509
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
8373
- const stat = fs30.statSync(filePath);
8510
+ const stat = fs31.statSync(filePath);
8374
8511
  if (stat.size === 0) {
8375
8512
  return { lines: [], totalLinesCount: 0 };
8376
8513
  }
8377
- const fd = fs30.openSync(filePath, "r");
8514
+ const fd = fs31.openSync(filePath, "r");
8378
8515
  const chunkSize = 64 * 1024;
8379
8516
  let position = stat.size;
8380
8517
  let remainder = "";
@@ -8386,7 +8523,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
8386
8523
  const length = Math.min(chunkSize, position);
8387
8524
  position -= length;
8388
8525
  const buffer = Buffer.alloc(length);
8389
- fs30.readSync(fd, buffer, 0, length, position);
8526
+ fs31.readSync(fd, buffer, 0, length, position);
8390
8527
  let chunk = buffer.toString("utf8");
8391
8528
  if (remainder) {
8392
8529
  chunk += remainder;
@@ -8417,7 +8554,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
8417
8554
  }
8418
8555
  }
8419
8556
  } finally {
8420
- fs30.closeSync(fd);
8557
+ fs31.closeSync(fd);
8421
8558
  }
8422
8559
  return { lines: collected.reverse(), totalLinesCount };
8423
8560
  }
@@ -8559,7 +8696,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
8559
8696
  }
8560
8697
 
8561
8698
  // src/commands/read-logs/json-lines.ts
8562
- import fs31 from "fs";
8699
+ import fs32 from "fs";
8563
8700
 
8564
8701
  // src/commands/read-logs/structured-log.ts
8565
8702
  function normalizeLevelName(value) {
@@ -8635,11 +8772,11 @@ function buildWantedLevelSet(levels) {
8635
8772
  return set.size > 0 ? set : null;
8636
8773
  }
8637
8774
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
8638
- const stat = fs31.statSync(filePath);
8775
+ const stat = fs32.statSync(filePath);
8639
8776
  if (stat.size === 0) {
8640
8777
  return { lines: [], totalLinesCount: 0 };
8641
8778
  }
8642
- const fd = fs31.openSync(filePath, "r");
8779
+ const fd = fs32.openSync(filePath, "r");
8643
8780
  const chunkSize = 64 * 1024;
8644
8781
  let position = stat.size;
8645
8782
  let remainder = "";
@@ -8654,7 +8791,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
8654
8791
  const length = Math.min(chunkSize, position);
8655
8792
  position -= length;
8656
8793
  const buffer = Buffer.alloc(length);
8657
- fs31.readSync(fd, buffer, 0, length, position);
8794
+ fs32.readSync(fd, buffer, 0, length, position);
8658
8795
  let chunk = buffer.toString("utf8");
8659
8796
  if (remainder) {
8660
8797
  chunk += remainder;
@@ -8716,7 +8853,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
8716
8853
  }
8717
8854
  }
8718
8855
  } finally {
8719
- fs31.closeSync(fd);
8856
+ fs32.closeSync(fd);
8720
8857
  }
8721
8858
  return { lines: collected.reverse(), totalLinesCount };
8722
8859
  }
@@ -8759,11 +8896,11 @@ function extractTraceId(obj) {
8759
8896
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
8760
8897
  const wanted = traceId.trim();
8761
8898
  if (!wanted) return { lines: [], totalLinesCount: 0 };
8762
- const stat = fs31.statSync(filePath);
8899
+ const stat = fs32.statSync(filePath);
8763
8900
  if (stat.size === 0) {
8764
8901
  return { lines: [], totalLinesCount: 0 };
8765
8902
  }
8766
- const fd = fs31.openSync(filePath, "r");
8903
+ const fd = fs32.openSync(filePath, "r");
8767
8904
  const chunkSize = 64 * 1024;
8768
8905
  let position = stat.size;
8769
8906
  let remainder = "";
@@ -8776,7 +8913,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
8776
8913
  const length = Math.min(chunkSize, position);
8777
8914
  position -= length;
8778
8915
  const buffer = Buffer.alloc(length);
8779
- fs31.readSync(fd, buffer, 0, length, position);
8916
+ fs32.readSync(fd, buffer, 0, length, position);
8780
8917
  let chunk = buffer.toString("utf8");
8781
8918
  if (remainder) {
8782
8919
  chunk += remainder;
@@ -8829,7 +8966,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
8829
8966
  }
8830
8967
  }
8831
8968
  } finally {
8832
- fs31.closeSync(fd);
8969
+ fs32.closeSync(fd);
8833
8970
  }
8834
8971
  return { lines: collected.reverse(), totalLinesCount };
8835
8972
  }
@@ -8838,11 +8975,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
8838
8975
  if (!wantedLevelSet) {
8839
8976
  return { lines: [], totalLinesCount: 0 };
8840
8977
  }
8841
- const stat = fs31.statSync(filePath);
8978
+ const stat = fs32.statSync(filePath);
8842
8979
  if (stat.size === 0) {
8843
8980
  return { lines: [], totalLinesCount: 0 };
8844
8981
  }
8845
- const fd = fs31.openSync(filePath, "r");
8982
+ const fd = fs32.openSync(filePath, "r");
8846
8983
  const chunkSize = 64 * 1024;
8847
8984
  let position = stat.size;
8848
8985
  let remainder = "";
@@ -8854,7 +8991,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
8854
8991
  const length = Math.min(chunkSize, position);
8855
8992
  position -= length;
8856
8993
  const buffer = Buffer.alloc(length);
8857
- fs31.readSync(fd, buffer, 0, length, position);
8994
+ fs32.readSync(fd, buffer, 0, length, position);
8858
8995
  let chunk = buffer.toString("utf8");
8859
8996
  if (remainder) {
8860
8997
  chunk += remainder;
@@ -8901,7 +9038,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
8901
9038
  }
8902
9039
  }
8903
9040
  } finally {
8904
- fs31.closeSync(fd);
9041
+ fs32.closeSync(fd);
8905
9042
  }
8906
9043
  return { lines: collected.reverse(), totalLinesCount };
8907
9044
  }
@@ -9587,7 +9724,7 @@ function camelToKebab2(str) {
9587
9724
  }
9588
9725
 
9589
9726
  // src/commands/build/upload-static.handler.ts
9590
- import * as fs32 from "fs";
9727
+ import * as fs33 from "fs";
9591
9728
  import * as os2 from "os";
9592
9729
  import * as path26 from "path";
9593
9730
  import { execFileSync } from "child_process";
@@ -9614,7 +9751,7 @@ async function uploadStatic(options) {
9614
9751
  region = UPLOAD_STATIC_DEFAULTS.region
9615
9752
  } = options;
9616
9753
  const resolvedStaticDir = path26.resolve(staticDir);
9617
- if (!fs32.existsSync(resolvedStaticDir)) {
9754
+ if (!fs33.existsSync(resolvedStaticDir)) {
9618
9755
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
9619
9756
  return;
9620
9757
  }
@@ -9648,7 +9785,7 @@ async function uploadStatic(options) {
9648
9785
  }
9649
9786
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
9650
9787
  const confPath = path26.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
9651
- fs32.writeFileSync(confPath, "");
9788
+ fs33.writeFileSync(confPath, "");
9652
9789
  try {
9653
9790
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
9654
9791
  configureTosutil(resolvedTosutil, confPath, {
@@ -9662,7 +9799,7 @@ async function uploadStatic(options) {
9662
9799
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
9663
9800
  } finally {
9664
9801
  try {
9665
- fs32.unlinkSync(confPath);
9802
+ fs33.unlinkSync(confPath);
9666
9803
  } catch {
9667
9804
  }
9668
9805
  }
@@ -9683,7 +9820,7 @@ async function uploadStatic(options) {
9683
9820
  }
9684
9821
  function resolveTosutilPath(tosutilPath) {
9685
9822
  if (path26.isAbsolute(tosutilPath)) {
9686
- return fs32.existsSync(tosutilPath) ? tosutilPath : null;
9823
+ return fs33.existsSync(tosutilPath) ? tosutilPath : null;
9687
9824
  }
9688
9825
  try {
9689
9826
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -9728,7 +9865,7 @@ async function resolveBucketId(appId) {
9728
9865
  return bucketId;
9729
9866
  }
9730
9867
  function isDirEmpty(dirPath) {
9731
- const entries = fs32.readdirSync(dirPath);
9868
+ const entries = fs33.readdirSync(dirPath);
9732
9869
  return entries.length === 0;
9733
9870
  }
9734
9871
 
@@ -9825,12 +9962,12 @@ var commands = [
9825
9962
  // src/index.ts
9826
9963
  for (const filename of [".env.local", ".env"]) {
9827
9964
  const envPath = path27.join(process.cwd(), filename);
9828
- if (fs33.existsSync(envPath)) {
9965
+ if (fs34.existsSync(envPath)) {
9829
9966
  dotenvConfig({ path: envPath });
9830
9967
  }
9831
9968
  }
9832
9969
  var __dirname = path27.dirname(fileURLToPath5(import.meta.url));
9833
- var pkg = JSON.parse(fs33.readFileSync(path27.join(__dirname, "../package.json"), "utf-8"));
9970
+ var pkg = JSON.parse(fs34.readFileSync(path27.join(__dirname, "../package.json"), "utf-8"));
9834
9971
  var cli = new FullstackCLI(pkg.version);
9835
9972
  cli.useAll(commands);
9836
9973
  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.20261104122311",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",